diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ab6030b2a21c40c0bc74e6eec95cfc822b117928..1bc5a6f072b0b84282eac06eedbe9c53e6b71871 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -23,7 +23,7 @@ variables: PRM_FILES: "scripts/config/self_test.prm scripts/config/self_test_ltv.prm" TESTCASE_TIMEOUT_STV: 900 TESTCASE_TIMEOUT_LTV: 2400 - TESTCASE_TIMEOUT_LTV_SANITIZERS: 6000 + TESTCASE_TIMEOUT_LTV_SANITIZERS: 10800 CI_REGRESSION_THRESH_MLD: "0.1" CI_REGRESSION_THRESH_MAX_ABS_DIFF: "50" CI_REGRESSION_THRESH_SSNR: "-1" @@ -32,12 +32,15 @@ variables: INSTR_DIR: "scripts/c-code_instrument" BUILD_WITH_DEBUG_MODE_INFO: "" ENCODER_TEST: "" + COMPARE_DMX: "" + SKIP_REGRESSION_CHECK: "" MANUAL_PIPELINE_TYPE: description: "Type for the manual pipeline run. Use 'pytest-compare' to run comparison test against reference float codec." value: 'default' options: - 'default' - 'pytest-compare' + - 'pytest-compare-enc-dmx' - 'pytest-compare-long' - 'pytest-compare-to-input' - 'pytest-saturation-smoke-test' @@ -71,6 +74,9 @@ workflow: - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'pytest-compare' variables: IVAS_PIPELINE_NAME: 'Run comparison tools against float ref: $CI_COMMIT_BRANCH' + - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'pytest-compare-enc-dmx' + variables: + IVAS_PIPELINE_NAME: 'Run encoder dmx comparison against float ref: $CI_COMMIT_BRANCH' - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'pytest-compare-long' variables: IVAS_PIPELINE_NAME: 'Run comparison tools against float ref (long test vectors): $CI_COMMIT_BRANCH' @@ -121,6 +127,13 @@ stages: echo "Commit time was $CI_COMMIT_TIMESTAMP" date | xargs echo "System time is" +.print-common-info-windows: &print-common-info-windows + - | + echo "Printing common information for build job." + echo "Current job is run on commit $CI_COMMIT_SHA" + echo "Commit time was $CI_COMMIT_TIMESTAMP" + ("echo 'System time is'", "Get-Date -Format 'dddd dd/MM/yyyy HH:mm K'") | Invoke-Expression + .activate-debug-mode-info-if-set: &activate-debug-mode-info-if-set - if [ "$BUILD_WITH_DEBUG_MODE_INFO" = "true" ]; then - sed -i.bak -e "s/\/\*\ *\(#define\ *DEBUGGING\ *\)\*\//\1/g" lib_com/options.h @@ -133,6 +146,7 @@ stages: - git checkout $REFERENCE_BRANCH - git pull - *activate-debug-mode-info-if-set + - cat lib_com/options.h - make clean - make -j - mv ./IVAS_cod ./$REF_ENCODER_PATH @@ -159,9 +173,18 @@ stages: - python3 tests/create_short_testvectors.py # create references - exit_code=0 + - enc_stats_arg="" - - if [ "$ENCODER_TEST" = "true" ]; then enc_stats_arg="--enc_stats"; fi - - python3 -m pytest $TEST_SUITE -v --update_ref 1 $enc_stats_arg --create_ref -n auto --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH || exit_code=$? + - if [ "$ENCODER_TEST" = "true" ]; then + - enc_stats_arg="--enc_stats" + - fi + + - enc_dmx_arg="" + - if [ "$COMPARE_DMX" = "true" ]; then + - enc_dmx_arg="--compare_enc_dmx" + - fi + + - python3 -m pytest $TEST_SUITE -v --update_ref 1 $enc_stats_arg $enc_dmx_arg --create_ref -n auto --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH || exit_code=$? .update-scripts-repo: &update-scripts-repo - cd $SCRIPTS_DIR @@ -194,6 +217,10 @@ stages: .activate-Werror-linux: &activate-Werror-linux - sed -i.bak "s/^# \(CFLAGS += -Werror\)/\1/" Makefile +.activate-WX-windows: &activate-WX-windows + - (Get-Content -Path "CMakeLists.txt") -replace '# \(add_compile_options\("\/WX"\)\)', '$1' | Set-Content -Path "CMakeLists.txt" + - Get-ChildItem -Path "Workspace_msvc" -Filter "*.vcxproj" | ForEach-Object { (Get-Content -Path $_.FullName) -replace 'false', 'true' | Set-Content -Path $_.FullName } + .rules-pytest-to-ref-short: rules: - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "pytest-compare" @@ -211,12 +238,9 @@ stages: - if: $CI_PIPELINE_SOURCE == 'schedule' when: never -# TODO: only temporary as long the MR encoder tests should not compare to main -.rules-pytest-to-ref-enc-short-temp: +.rules-pytest-to-ref-enc-sort-dmx: rules: - - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "pytest-compare" - - if: $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH - - if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main" # only have MR pipelines for MRs to main + - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "pytest-compare-enc-dmx" - if: $CI_PIPELINE_SOURCE == 'push' when: never - if: $CI_PIPELINE_SOURCE == 'schedule' @@ -271,6 +295,13 @@ stages: tags: - ivas-basop-linux +.build-job-windows: + stage: build + needs: [] + timeout: "4 minutes" + tags: + - ivas-windows + # template for test jobs on linux that need the TESTV_DIR .test-job-linux-needs-testv-dir: extends: .test-job-linux @@ -291,6 +322,7 @@ stages: SUMMARY_HTML_ARTIFACT_NAME: "summary_$CI_JOB_NAME.html" IMAGES_ARTIFACT_NAME: "images_$CI_JOB_NAME" script: + - set -euxo pipefail - *print-common-info - *update-scripts-repo - if [ $USE_LTV -eq 1 ]; then @@ -302,15 +334,24 @@ stages: - fi - python3 ci/remove_unsupported_testcases.py $PRM_FILES - - if [ $LEVEL_SCALING != "1.0" ];then + - if [ $LEVEL_SCALING != "1.0" ]; then - *apply-testv-scaling - fi - - if [ "$ENCODER_TEST" = "true" ]; then BUILD_WITH_DEBUG_MODE_INFO="true"; fi + - if [ "$COMPARE_DMX" = "true" ] || [ "$ENCODER_TEST" = "true" ]; then + - BUILD_WITH_DEBUG_MODE_INFO="true" + - fi - *build-and-create-reference-outputs - comp_args="--mld --ssnr --odg" - - if [ "$ENCODER_TEST" = "true" ]; then comp_args="${comp_args} --enc_stats"; fi + - if [ "$ENCODER_TEST" = "true" ]; then + - comp_args="${comp_args} --enc_stats" + - fi + + # DMX comparison only in manual job with no other metrics + - if [ "$COMPARE_DMX" = "true" ]; then + - comp_args="--compare_enc_dmx" + - fi - echo "$comp_args" ### run pytest @@ -383,6 +424,7 @@ stages: IMAGES_ARTIFACT_NAME: "images_$CI_JOB_NAME" SUMMARY_HTML_ARTIFACT_NAME: "summary_$CI_JOB_NAME.html" script: + - set -euxo pipefail - *print-common-info - *update-scripts-repo - if [ $USE_LTV -eq 1 ]; then @@ -430,7 +472,10 @@ stages: - diff_sba=0 - diff_param=0 - diff_report=0 - - python3 scripts/batch_comp_audio.py --tool pyaudio3dtools -sd tests/dut/sba_bs/raw tests/dut_branch/sba_bs/raw || diff_sba=$? + # SHORT_TEST_SUITE_ENCODER does not contain test_sba.py. This leads to non-existing output folders being compared and to diff_sba=1. Therefore, this is skipped for the encoder tests + - if [ "$TEST_SUITE" != "$SHORT_TEST_SUITE_ENCODER" ]; then + - python3 scripts/batch_comp_audio.py --tool pyaudio3dtools -sd tests/dut/sba_bs/raw tests/dut_branch/sba_bs/raw || diff_sba=$? + - fi - python3 scripts/batch_comp_audio.py --tool pyaudio3dtools -sd tests/dut/param_file/dec tests/dut_branch/param_file/dec || diff_param=$? - diff $CSV_BRANCH $CSV_MAIN || diff_report=$? - if [ $diff_param -eq 0 ] && [ $diff_sba -eq 0 ] && [ $diff_report -eq 0 ] && [ $zero_errors_branch -eq 1 ]; then @@ -446,11 +491,11 @@ stages: ### compare the two csv files for regressions - regressions_found=0 - - python3 scripts/basop_check_for_changes_in_testcases.py $CSV_BRANCH $CSV_MAIN || regressions_found=$? + - python3 scripts/basop_check_for_changes_in_testcases.py --xml_report $XML_REPORT_BRANCH $CSV_MAIN $CSV_BRANCH || regressions_found=$? - if [ $exit_code -eq 1 ]; then echo "Differences encountered"; exit_code=$EXIT_CODE_NON_BE; fi - if [ $zero_errors_branch != 1 ]; then echo "Run errors encountered!"; exit_code=$EXIT_CODE_NON_BE; fi - - if [ $regressions_found != 0 ]; then + - if [ $regressions_found != 0 ] && [ "$SKIP_REGRESSION_CHECK" != "true" ]; then - if [ $allow_regressions_flag == 0 ]; then - echo "Detected regression wrt to main, [allow regression] not set!" - exit_code=$EXIT_CODE_FAIL; @@ -494,7 +539,7 @@ stages: .ivas-pytest-sanitizers-anchor: &ivas-pytest-sanitizers-anchor stage: test needs: ["build-codec-linux-make"] - timeout: "300 minutes" + timeout: "600 minutes" rules: - if: $CI_PIPELINE_SOURCE == 'push' when: never @@ -510,7 +555,7 @@ stages: - *build-reference-and-dut-binaries - make clean - make -j CLANG=$CLANG_NUM - - if [[ $CLANG_NUM == 3 ]]; then export UBSAN_OPTIONS="suppressions=scripts/ubsan.supp,report_error_type=1"; fi + - if [[ $CLANG_NUM == 3 ]]; then export UBSAN_OPTIONS="suppressions=scripts/ubsan_basop.supp,report_error_type=1"; fi - testcase_timeout=$TESTCASE_TIMEOUT_LTV_SANITIZERS - python3 -m pytest $TEST_SUITE -v --tb=no --update_ref 1 --html=report.html --self-contained-html --junit-xml=report-junit.xml --testcase_timeout $testcase_timeout --ref_encoder_path $DUT_ENCODER_PATH --ref_decoder_path $DUT_DECODER_PATH artifacts: @@ -722,44 +767,64 @@ build-codec-linux-debugging-make: - *activate-debug-mode-info-if-set - make -j +build-codec-windows-msbuild: + rules: + - if: $CI_PIPELINE_SOURCE == 'web' + - if: $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' # trigger build job for all MRs + - if: $CI_PIPELINE_SOURCE == 'schedule' + - if: $CI_PIPELINE_SOURCE == 'push' + when: never + extends: + - .build-job-windows + timeout: "7 minutes" + tags: + - ivas-windows + script: + - *print-common-info-windows + - *activate-WX-windows + - MSBuild.exe -maxcpucount .\Workspace_msvc\Workspace_msvc.sln /property:Configuration=Debug + # --------------------------------------------------------------- # Short test jobs that run in merge request pipelines # --------------------------------------------------------------- ### jobs that test fx encoder -> flt decoder -# TODO: reenable once encoder tests shall compare to main -# ivas-pytest-compare_to_main-short-enc: -# extends: -# - .rules-pytest-to-main-short -# - .test-job-linux -# before_script: -# - USE_LTV=0 -# - DUT_DECODER_PATH=./IVAS_dec_ref -# - TEST_SUITE="$SHORT_TEST_SUITE_ENCODER" -# - LEVEL_SCALING=1.0 -# <<: *ivas-pytest-on-merge-request-anchor - -# ivas-pytest-compare_to_main-short-enc-lev-10: -# extends: -# - .rules-pytest-to-main-short -# - .test-job-linux -# before_script: -# - USE_LTV=0 -# - DUT_DECODER_PATH=./IVAS_dec_ref -# - TEST_SUITE="$SHORT_TEST_SUITE_ENCODER" -# - LEVEL_SCALING=0.3162 -# <<: *ivas-pytest-on-merge-request-anchor - -# ivas-pytest-compare_to_main-short-enc-lev+10: -# extends: -# - .rules-pytest-to-main-short -# - .test-job-linux -# before_script: -# - USE_LTV=0 -# - DUT_DECODER_PATH=./IVAS_dec_ref -# - TEST_SUITE="$SHORT_TEST_SUITE_ENCODER" -# - LEVEL_SCALING=3.162 -# <<: *ivas-pytest-on-merge-request-anchor +ivas-pytest-compare_to_main-short-enc: + extends: + - .rules-pytest-to-main-short + - .test-job-linux + before_script: + - USE_LTV=0 + - DUT_DECODER_PATH=./IVAS_dec_ref + - TEST_SUITE="$SHORT_TEST_SUITE_ENCODER" + - LEVEL_SCALING=1.0 + - SKIP_REGRESSION_CHECK="true" + <<: *ivas-pytest-on-merge-request-anchor + +ivas-pytest-compare_to_main-short-enc-lev-10: + extends: + - .rules-pytest-to-main-short + - .test-job-linux + before_script: + - USE_LTV=0 + - DUT_DECODER_PATH=./IVAS_dec_ref + - TEST_SUITE="$SHORT_TEST_SUITE_ENCODER" + - LEVEL_SCALING=0.3162 + - SKIP_REGRESSION_CHECK="true" + <<: *ivas-pytest-on-merge-request-anchor + +ivas-pytest-compare_to_main-short-enc-lev+10: + extends: + - .rules-pytest-to-main-short + - .test-job-linux + before_script: + - USE_LTV=0 + - DUT_DECODER_PATH=./IVAS_dec_ref + - TEST_SUITE="$SHORT_TEST_SUITE_ENCODER" + - LEVEL_SCALING=3.162 + - SKIP_REGRESSION_CHECK="true" + <<: *ivas-pytest-on-merge-request-anchor ### jobs that test flt encoder -> fx decoder ivas-pytest-compare_to_main-short-dec: @@ -805,8 +870,7 @@ ivas-pytest-compare_to_main-short-dec-lev+10: ### jobs that test fx encoder -> flt decoder ivas-pytest-compare_to_ref-short-enc: extends: - #- .rules-pytest-to-ref-short - - .rules-pytest-to-ref-enc-short-temp + - .rules-pytest-to-ref-short - .test-job-linux before_script: - USE_LTV=0 @@ -818,9 +882,8 @@ ivas-pytest-compare_to_ref-short-enc: ivas-pytest-compare_to_ref-short-enc-lev-10: extends: - #- .rules-pytest-to-ref-short - - .rules-pytest-to-ref-enc-short-temp - - .test-job-linux + - .rules-pytest-to-ref-short + - .test-job-linux before_script: - USE_LTV=0 - ENCODER_TEST="true" @@ -831,12 +894,51 @@ ivas-pytest-compare_to_ref-short-enc-lev-10: ivas-pytest-compare_to_ref-short-enc-lev+10: extends: - #- .rules-pytest-to-ref-short - - .rules-pytest-to-ref-enc-short-temp - - .test-job-linux + - .rules-pytest-to-ref-short + - .test-job-linux + before_script: + - USE_LTV=0 + - ENCODER_TEST="true" + - DUT_DECODER_PATH=./$REF_DECODER_PATH + - TEST_SUITE="$SHORT_TEST_SUITE_ENCODER" + - LEVEL_SCALING=3.162 + <<: *ivas-pytest-anchor + +# encoder dmx comparison jobs +ivas-pytest-compare_to_ref-dmx-short-enc: + extends: + - .rules-pytest-to-ref-enc-sort-dmx + - .test-job-linux + before_script: + - USE_LTV=0 + - ENCODER_TEST="true" + - COMPARE_DMX="true" + - DUT_DECODER_PATH=./$REF_DECODER_PATH + - TEST_SUITE="$SHORT_TEST_SUITE_ENCODER" + - LEVEL_SCALING=1.0 + <<: *ivas-pytest-anchor + +ivas-pytest-compare_to_ref-dmx-short-enc-lev-10: + extends: + - .rules-pytest-to-ref-enc-sort-dmx + - .test-job-linux + before_script: + - USE_LTV=0 + - ENCODER_TEST="true" + - COMPARE_DMX="true" + - DUT_DECODER_PATH=./$REF_DECODER_PATH + - TEST_SUITE="$SHORT_TEST_SUITE_ENCODER" + - LEVEL_SCALING=0.3162 + <<: *ivas-pytest-anchor + +ivas-pytest-compare_to_ref-dmx-short-enc-lev+10: + extends: + - .rules-pytest-to-ref-enc-sort-dmx + - .test-job-linux before_script: - USE_LTV=0 - ENCODER_TEST="true" + - COMPARE_DMX="true" - DUT_DECODER_PATH=./$REF_DECODER_PATH - TEST_SUITE="$SHORT_TEST_SUITE_ENCODER" - LEVEL_SCALING=3.162 @@ -845,6 +947,8 @@ ivas-pytest-compare_to_ref-short-enc-lev+10: ivas-pytest-enc-msan: extends: - .test-job-linux + tags: + - ivas-basop-linux-fast before_script: - CLANG_NUM=1 - DUT_DECODER_PATH=./$REF_DECODER_PATH @@ -854,6 +958,8 @@ ivas-pytest-enc-msan: ivas-pytest-enc-asan: extends: - .test-job-linux + tags: + - ivas-basop-linux-fast before_script: - CLANG_NUM=2 - DUT_DECODER_PATH=./$REF_DECODER_PATH @@ -863,6 +969,8 @@ ivas-pytest-enc-asan: ivas-pytest-enc-usan: extends: - .test-job-linux + tags: + - ivas-basop-linux-fast before_script: - CLANG_NUM=3 - DUT_DECODER_PATH=./$REF_DECODER_PATH @@ -929,6 +1037,8 @@ ivas-pytest-compare-to-input-short-enc: ivas-pytest-dec-msan: extends: - .test-job-linux + tags: + - ivas-basop-linux-fast before_script: - CLANG_NUM=1 - DUT_ENCODER_PATH=./$REF_ENCODER_PATH @@ -938,6 +1048,8 @@ ivas-pytest-dec-msan: ivas-pytest-dec-asan: extends: - .test-job-linux + tags: + - ivas-basop-linux-fast before_script: - CLANG_NUM=2 - DUT_ENCODER_PATH=./$REF_ENCODER_PATH @@ -947,6 +1059,8 @@ ivas-pytest-dec-asan: ivas-pytest-dec-usan: extends: - .test-job-linux + tags: + - ivas-basop-linux-fast before_script: - CLANG_NUM=3 - DUT_ENCODER_PATH=./$REF_ENCODER_PATH @@ -1205,16 +1319,34 @@ voip-be-on-merge-request: - job_id=$(python3 ci/get_id_of_last_job_occurence.py $CI_COMMIT_REF_NAME $CI_JOB_NAME $CI_PROJECT_ID) - echo $job_id - # TODO: remove. This is a hack to try out if the complexity history can be brought back. - # hack: explicitly set the id of the last succesful job which has all the artifacts - # this will only work for stereo, but just to try out if things work at all... + # this is a testing/maintenance mechanism to force getting the log history from a specific job id + # see below in the concrete complexity jobs - if [ "$JOB_ID_INJECT" != "" ]; then job_id=$JOB_ID_INJECT; fi - curl --request GET "https://forge.3gpp.org/rep/api/v4/projects/$CI_PROJECT_ID/jobs/$job_id/artifacts" --output artifacts.zip - unzip artifacts.zip || true # this may fail on first run, when there are no artifacts there and the zip file is actually just "404"-html - ls - public_dir="$CI_JOB_NAME-public" + # if is needed to catch case when no artifact is there (first run), similarly as above - - if [[ -d $public_dir ]]; then mv $public_dir/* wmops/; fi + # 1. check for public_dir being there as this might not be the case when artifact download failed + # 2. check for public dir not being empty - handle job failures in prev job that happen after the dir is created. In that case, the empty dir is in the artifacts + - if [ -d $public_dir ] && [ ! -z "$( ls -A $public_dir )" ]; then + - mv $public_dir/* wmops/ + # check here if we have the split-by-levels files present - if not, fake them up with the existing global one + # this is needed for the first run with split graphs on a branch where the global version did run previously + # NOTE: checking only for level_1 file here as this should already be sufficient + # NOTE2: also not chechking for RAM for same reason + - wmops_all_global="wmops/log_wmops_all.txt" + - ram_all_global="wmops/log_ram_all.txt" + - if [ -f "${wmops_all_global}" ] && [ ! -f "wmops/log_wmops_all_level_1.txt" ]; then + - declare -a suffixes=("level_1" "level_2" "level_3" "rate_sw") + - for suffix in "${suffixes[@]}"; do + - cp ${wmops_all_global} wmops/log_wmops_all_${suffix}.txt + - cp ${ram_all_global} wmops/log_ram_all_${suffix}.txt + - done + - fi + - fi + - ls wmops - rm artifacts.zip - rm -rf $public_dir @@ -1231,7 +1363,7 @@ voip-be-on-merge-request: &complexity-measurements-prepare-artifacts # prepare artifacts -> move to public directory - public_dir="$CI_JOB_NAME-public" - mkdir $public_dir - - mv -f wmops/log_*_all.txt ./*.js ${public_dir}/ + - mv -f wmops/log_*_all*.txt ./*.js ${public_dir}/ # move logfiles for links - mkdir $public_dir/logs # first move logs @@ -1275,7 +1407,7 @@ complexity-stereo-in-stereo-out: rules: - if: $MEASURE_COMPLEXITY_LINUX variables: - JOB_ID_INJECT: "368633" + JOB_ID_INJECT: "" script: - in_format=stereo - out_format=stereo @@ -1291,7 +1423,7 @@ complexity-ism-in-binaural-out: when: delayed start_in: 1 hour variables: - JOB_ID_INJECT: "368636" + JOB_ID_INJECT: "" script: - in_format=ISM - out_format=BINAURAL @@ -1308,7 +1440,7 @@ complexity-ism-in-binaural_room_ir-out: when: delayed start_in: 2 hours variables: - JOB_ID_INJECT: "368638" + JOB_ID_INJECT: "" script: - in_format=ISM - out_format=BINAURAL_ROOM_IR @@ -1325,7 +1457,7 @@ complexity-ism-in-ext-out: when: delayed start_in: 3 hours 30 minutes variables: - JOB_ID_INJECT: "368640" + JOB_ID_INJECT: "" script: - in_format=ISM - out_format=EXT @@ -1342,7 +1474,7 @@ complexity-sba-hoa3-in-hoa3-out: when: delayed start_in: 4 hours 30 minutes variables: - JOB_ID_INJECT: "368642" + JOB_ID_INJECT: "" script: - in_format=HOA3 - out_format=HOA3 @@ -1359,7 +1491,7 @@ complexity-sba-hoa3-in-binaural-out: when: delayed start_in: 5 hours 30 minutes variables: - JOB_ID_INJECT: "368643" + JOB_ID_INJECT: "" script: - in_format=HOA3 - out_format=BINAURAL @@ -1376,7 +1508,7 @@ complexity-sba-hoa3-in-binaural_room_ir-out: when: delayed start_in: 6 hours 30 minutes variables: - JOB_ID_INJECT: "368645" + JOB_ID_INJECT: "" script: - in_format=HOA3 - out_format=BINAURAL_ROOM_IR @@ -1393,7 +1525,7 @@ complexity-mc-in-7_1_4-out: when: delayed start_in: 7 hours 30 minutes variables: - JOB_ID_INJECT: "368647" + JOB_ID_INJECT: "" script: - in_format=MC - out_format=7_1_4 @@ -1410,7 +1542,7 @@ complexity-mc-in-binaural-out: when: delayed start_in: 10 hours variables: - JOB_ID_INJECT: "368649" + JOB_ID_INJECT: "" script: - in_format=MC - out_format=BINAURAL @@ -1427,7 +1559,7 @@ complexity-mc-in-binaural_room_ir-out: when: delayed start_in: 12 hours 30 minutes variables: - JOB_ID_INJECT: "368650" + JOB_ID_INJECT: "" script: - in_format=MC - out_format=BINAURAL_ROOM_IR @@ -1444,7 +1576,7 @@ complexity-masa-in-ext-out: when: delayed start_in: 15 hours variables: - JOB_ID_INJECT: "368651" + JOB_ID_INJECT: "" script: - in_format=MASA - out_format=EXT @@ -1461,7 +1593,7 @@ complexity-masa-in-binaural-out: when: delayed start_in: 16 hours variables: - JOB_ID_INJECT: "368652" + JOB_ID_INJECT: "" script: - in_format=MASA - out_format=BINAURAL @@ -1478,7 +1610,7 @@ complexity-masa-in-hoa3-out: when: delayed start_in: 17 hours variables: - JOB_ID_INJECT: "368653" + JOB_ID_INJECT: "" script: - in_format=MASA - out_format=HOA3 @@ -1494,6 +1626,8 @@ complexity-masa-in-hoa3-out: # - if: $MEASURE_COMPLEXITY_LINUX # when: delayed # start_in: 13 hours + # variables: + # JOB_ID_INJECT: "" # script: # - in_format=OMASA # - out_format=EXT @@ -1510,7 +1644,7 @@ complexity-omasa-in-binaural-out: when: delayed start_in: 18 hours variables: - JOB_ID_INJECT: "368654" + JOB_ID_INJECT: "" script: - in_format=OMASA - out_format=BINAURAL @@ -1527,7 +1661,7 @@ complexity-omasa-in-hoa3-out: when: delayed start_in: 20 hours variables: - JOB_ID_INJECT: "368655" + JOB_ID_INJECT: "" script: - in_format=OMASA - out_format=HOA3 @@ -1544,7 +1678,7 @@ complexity-StereoDmxEVS-stereo-in-mono-out: when: delayed start_in: 22 hours variables: - JOB_ID_INJECT: "368656" + JOB_ID_INJECT: "" script: - in_format=StereoDmxEVS - out_format=mono @@ -1576,7 +1710,7 @@ complexity-osba-in-binaural-out: when: delayed start_in: 22 hours 30 minutes variables: - JOB_ID_INJECT: "368657" + JOB_ID_INJECT: "" script: - in_format=OSBA - out_format=BINAURAL @@ -1593,7 +1727,7 @@ complexity-osba-in-binaural_room_ir-out: when: delayed start_in: 25 hours variables: - JOB_ID_INJECT: "368658" + JOB_ID_INJECT: "" script: - in_format=OSBA - out_format=BINAURAL_ROOM_IR diff --git a/.gitlab/issue_templates/float-update-porting.md b/.gitlab/issue_templates/float-update-porting.md new file mode 100644 index 0000000000000000000000000000000000000000..84d15a8c850ecb0ed5e6f92a0e0ba63f8fd057cf --- /dev/null +++ b/.gitlab/issue_templates/float-update-porting.md @@ -0,0 +1,8 @@ +# Basic Info + + +- Original merge request in float repo: +- Branch for float ref update: +- Branch for BASOP update: + +/label ~Type:FloatUpdatePorting ~Status::ToDo diff --git a/.gitlab/merge_request_templates/float-update-porting.md b/.gitlab/merge_request_templates/float-update-porting.md new file mode 100644 index 0000000000000000000000000000000000000000..7ffdee33307968e9991dffe88727976355a3d246 --- /dev/null +++ b/.gitlab/merge_request_templates/float-update-porting.md @@ -0,0 +1,6 @@ + +- Link to issue in BASOP repo: +- Link to original issue in float repo: +- Requested reviewers: + +/label Type:FloatUpdatePorting diff --git a/Workspace_msvc/lib_com.vcxproj b/Workspace_msvc/lib_com.vcxproj index 9182dd36282cc0652cc43986fb561b0be255385e..c88725ef0a7c34891cf22d6eaeffdddc1a237dab 100644 --- a/Workspace_msvc/lib_com.vcxproj +++ b/Workspace_msvc/lib_com.vcxproj @@ -319,6 +319,7 @@ + diff --git a/Workspace_msvc/lib_com.vcxproj.filters b/Workspace_msvc/lib_com.vcxproj.filters index 93a2b1c00c5b944283f3f7778ccbe44a5f1548ff..195d4deb1b9c6d4f5896ac00802e50b4ec695f51 100644 --- a/Workspace_msvc/lib_com.vcxproj.filters +++ b/Workspace_msvc/lib_com.vcxproj.filters @@ -501,6 +501,9 @@ common_h + + common_h + diff --git a/Workspace_msvc/lib_enc.vcxproj b/Workspace_msvc/lib_enc.vcxproj index 43e7af2af14af672f137859d9dd72b04aace709b..75831970efdfb8fc2a9230f03be6eba7eb990195 100644 --- a/Workspace_msvc/lib_enc.vcxproj +++ b/Workspace_msvc/lib_enc.vcxproj @@ -379,71 +379,33 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Workspace_msvc/lib_enc.vcxproj.filters b/Workspace_msvc/lib_enc.vcxproj.filters index abc2ccec7162cae15eb0dd94fbadef0a8deabae2..ac23c810ff27ac52177114f39d480d36a817c8bf 100644 --- a/Workspace_msvc/lib_enc.vcxproj.filters +++ b/Workspace_msvc/lib_enc.vcxproj.filters @@ -67,36 +67,14 @@ enc_evs_c - - enc_evs_c - enc_evs_c - - enc_evs_c - - - enc_evs_c - - - enc_evs_c - - - enc_evs_c - - - enc_evs_c - - enc_evs_c enc_evs_c - - enc_evs_c - enc_all_c @@ -160,15 +138,6 @@ enc_all_c - - enc_all_c - - - enc_all_c - - - enc_all_c - enc_all_c @@ -247,16 +216,6 @@ enc_all_c - - enc_all_c - - - enc_all_c - - - enc_all_c - - enc_all_c @@ -268,88 +227,12 @@ enc_all_c - - enc_all_c - - - enc_all_c - - - enc_all_c - enc_all_c enc_all_c - - enc_all_c - - - enc_all_c - - - enc_all_c - - - enc_all_c - - - enc_all_c - - - enc_all_c - - - enc_all_c - - - enc_all_c - - - enc_all_c - - - enc_all_c - - - enc_all_c - - - enc_all_c - - - enc_all_c - - - enc_all_c - - - enc_all_c - - - enc_all_c - - - enc_all_c - - - enc_all_c - - - enc_all_c - - - enc_all_c - - - enc_all_c - - - enc_all_c - - enc_all_c diff --git a/apps/encoder.c b/apps/encoder.c index 56991959f9394bad3a8126d6056eacfcac3dc238..165d03543d7f2f9357d23f09b26001c09d79bfb2 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -369,6 +369,15 @@ int main( goto cleanup; } +#ifdef SUPPORT_FORCE_TCX10_TCX20 +#ifdef DEBUGGING + if ( arg.forcedMode == IVAS_ENC_FORCE_TCX10 && totalBitrate < 48000 ) + { + fprintf( stderr, "Warning: Enforcing the TCX10 mode is only supported for bitrates higher or equal than 48 kbps!\n\n" ); + } +#endif +#endif + /*------------------------------------------------------------------------------------------* * Configure and initialize (allocate memory for static variables) the encoder *------------------------------------------------------------------------------------------*/ @@ -1044,7 +1053,24 @@ static bool parseCmdlIVAS_enc( } else { +#ifdef SUPPORT_FORCE_TCX10_TCX20 + if ( arg->forcedMode == IVAS_ENC_FORCE_TCX10 ) + { + strcpy( stmp, "TCX10" ); + } + else if ( arg->forcedMode == IVAS_ENC_FORCE_TCX20 ) + { + strcpy( stmp, "TCX20" ); + } + else + { + strncpy( stmp, argv[i + 1], sizeof( stmp ) ); + } + + fprintf( stdout, "Forcing codec to: %s\n", stmp ); +#else fprintf( stdout, "Forcing codec to: %s\n", argv[i + 1] ); +#endif } #endif @@ -2019,10 +2045,24 @@ static IVAS_ENC_FORCED_MODE parseForcedMode( { return IVAS_ENC_FORCE_GSC; } - if ( ( strcmp( forcedModeChar, "TCX" ) == 0 ) || ( strcmp( forcedModeChar, "'TCX'" ) == 0 ) ) + if ( ( strcmp( forcedModeChar, "TCX" ) == 0 ) || ( strcmp( forcedModeChar, "'TCX'" ) == 0 ) +#ifdef SUPPORT_FORCE_TCX10_TCX20 + || ( strcmp( forcedModeChar, "TCX20" ) == 0 ) || ( strcmp( forcedModeChar, "'TCX20'" ) == 0 ) +#endif + ) { +#ifdef SUPPORT_FORCE_TCX10_TCX20 + return IVAS_ENC_FORCE_TCX20; +#else return IVAS_ENC_FORCE_TCX; +#endif } +#ifdef SUPPORT_FORCE_TCX10_TCX20 + if ( ( strcmp( forcedModeChar, "TCX10" ) == 0 ) || ( strcmp( forcedModeChar, "'TCX10'" ) == 0 ) ) + { + return IVAS_ENC_FORCE_TCX10; + } +#endif if ( ( strcmp( forcedModeChar, "HQ" ) == 0 ) || ( strcmp( forcedModeChar, "'HQ'" ) == 0 ) ) { return IVAS_ENC_FORCE_HQ; diff --git a/apps/renderer.c b/apps/renderer.c index 44ed320adee991ab4ce37f040724affb9ffab334..f5c0a8847264b45944f245818f8a7b332efd9d0a 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -655,6 +655,10 @@ 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 ) || @@ -816,6 +820,50 @@ 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 ); + + if ( args.inConfig.numAudioObjects > 0 ) + { + if ( args.inConfig.numAudioObjects == 1 ) + { + IVAS_REND_PrintInputConfig( IVAS_AUDIO_CONFIG_ISM1 ); + } + else if ( args.inConfig.numAudioObjects == 2 ) + { + IVAS_REND_PrintInputConfig( IVAS_AUDIO_CONFIG_ISM2 ); + } + else if ( args.inConfig.numAudioObjects == 3 ) + { + IVAS_REND_PrintInputConfig( IVAS_AUDIO_CONFIG_ISM3 ); + } + else if ( args.inConfig.numAudioObjects == 4 ) + { + IVAS_REND_PrintInputConfig( IVAS_AUDIO_CONFIG_ISM4 ); + } + } + for ( i = 0; i < args.inConfig.numMultiChannelBuses; i++ ) + { + IVAS_REND_PrintInputConfig( args.inConfig.multiChannelBuses[i].audioConfig ); + } + for ( i = 0; i < args.inConfig.numMasaBuses; i++ ) + { + IVAS_REND_PrintInputConfig( args.inConfig.masaBuses[i].audioConfig ); + } + for ( i = 0; i < args.inConfig.numAmbisonicsBuses; i++ ) + { + IVAS_REND_PrintInputConfig( args.inConfig.ambisonicsBuses[i].audioConfig ); + } + + if ( ( error = IVAS_REND_PrintConfig( hIvasRend ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\n IVAS_REND_PrintConfig failed: %s\n\n", ivas_error_to_string( error ) ); + // goto cleanup; + exit( -1 ); + } + +#endif /* === Configure === */ if ( ( error = IVAS_REND_InitConfig( hIvasRend, args.outConfig.audioConfig ) ) != IVAS_ERR_OK ) { diff --git a/lib_com/arith_coder_fx.c b/lib_com/arith_coder_fx.c index 12a4fa6702649fe221fa2124e28407fea64f51d4..de22a7cf34863a72a79c2ba62661753766146176 100644 --- a/lib_com/arith_coder_fx.c +++ b/lib_com/arith_coder_fx.c @@ -224,12 +224,8 @@ void tcx_arith_scale_envelope( tmp = norm_l( env[k] ); tmp2 = sub( 15, tmp ); -#ifdef BASOP_NOGLOB tmp = Inv16( round_fx_o( L_shl_o( env[k], tmp, &Overflow ), &Overflow ), &tmp2 ); /* exp(tmp2) */ -#else - tmp = Inv16( round_fx( L_shl( env[k], tmp ) ), &tmp2 ); -#endif - ienv[k] = L_shl( L_deposit_h( tmp ), sub( tmp2, 15 ) ); /* Q16 */ + ienv[k] = L_shl( L_deposit_h( tmp ), sub( tmp2, 15 ) ); /* Q16 */ move32(); mean = L_add( mean, ienv[k] ); /* Q16 */ } @@ -276,11 +272,7 @@ void tcx_arith_scale_envelope( tmp2 = BASOP_Util_Add_MantExp( negate( b ), b_e, tmp, tmp2, &scale ); /* exp(scale) */ scale = BASOP_Util_Divide1616_Scale( scale, round_fx( a ), &tmp ); -#ifdef BASOP_NOGLOB scale = shl_o( scale, sub( sub( add( tmp, tmp2 ), a_e ), 1 ), &Overflow ); /* Q15 */ -#else - scale = shl( scale, sub( sub( add( tmp, tmp2 ), a_e ), 1 ) ); /* Q15 */ -#endif /* iscale = 1.0f / scale; */ iscale_e = 0; @@ -329,11 +321,7 @@ void tcx_arith_scale_envelope( L_tmp = L_add( L_tmp, L_shl( Mpy_32_16_1( env[k], mult_r( 1147 /*0.035f Q15*/, iscale ) ), iscale_e ) ); /* Q16 */ tmp = norm_l( L_tmp ); -#ifdef BASOP_NOGLOB statesi = mult_r( statesi, round_fx_o( L_shl_o( L_tmp, tmp, &Overflow ), &Overflow ) ); -#else - statesi = mult_r( statesi, round_fx( L_shl( L_tmp, tmp ) ) ); -#endif bits = add( bits, sub( 15, tmp ) ); tmp = norm_s( statesi ); @@ -420,11 +408,7 @@ void tcx_arith_scale_envelope( *s_env_e = sub( add( 15, iscale_e ), tmp ); move16(); BASOP_SATURATE_WARNING_OFF_EVS; -#ifdef BASOP_NOGLOB a = L_shl_o( 1265000, sub( 15, *s_env_e ), &Overflow ); -#else /* BASOP_NOGLOB */ - a = L_shl( 1265000, sub( 15, *s_env_e ) ); -#endif BASOP_SATURATE_WARNING_ON_EVS; FOR( k = 0; k < L_frame; k++ ) diff --git a/lib_com/basop32.c b/lib_com/basop32.c index 732e33b2a5ef05c6b47458c63f0c854a73cf7b4d..200757026ace2be6b9fb369f8baad912c2723d8a 100644 --- a/lib_com/basop32.c +++ b/lib_com/basop32.c @@ -162,9 +162,7 @@ HISTORY: #include "options.h" #include "stl.h" -#ifdef BASOP_NOGLOB #include -#endif /* BASOP_NOGLOB */ #define WMC_TOOL_SKIP @@ -178,9 +176,7 @@ HISTORY: | Local Functions | |___________________________________________________________________________| */ -#ifdef BASOP_NOGLOB static Word16 saturate_o( Word32 L_var1, Flag *Overflow ); -#endif /* BASOP_NOGLOB */ static Word16 saturate( Word32 L_var1 ); @@ -189,7 +185,6 @@ static Word16 saturate( Word32 L_var1 ); | Constants and Globals | |___________________________________________________________________________| */ -#ifdef BASOP_NOGLOB #ifdef BASOP_PRINT_ON_WARNING #include @@ -416,10 +411,6 @@ Flag get_carry( const Flag *carry ) #undef B_HELPER_SET_GLOBAL #undef B_HELPER_GET_GLOBAL -#else /* BASOP_NOGLOB */ -Flag Overflow = 0; -Flag Carry = 0; -#endif /* BASOP_NOGLOB */ /*___________________________________________________________________________ | | @@ -456,30 +447,18 @@ Flag Carry = 0; | range : 0xffff 8000 <= var_out <= 0x0000 7fff. | |___________________________________________________________________________| */ -#ifndef BASOP_NOGLOB -static Word16 saturate( Word32 L_var1 ) -#else /* BASOP_NOGLOB */ static Word16 saturate_o( Word32 L_var1, Flag *Overflow ) -#endif /* BASOP_NOGLOB */ { Word16 var_out; if ( L_var1 > 0X00007fffL ) { -#ifndef BASOP_NOGLOB - Overflow = 1; -#else /* BASOP_NOGLOB */ *Overflow = 1; -#endif /* BASOP_NOGLOB */ var_out = MAX_16; } else if ( L_var1 < (Word32) 0xffff8000L ) { -#ifndef BASOP_NOGLOB - Overflow = 1; -#else /* BASOP_NOGLOB */ *Overflow = 1; -#endif /* BASOP_NOGLOB */ var_out = MIN_16; } else @@ -495,7 +474,6 @@ static Word16 saturate_o( Word32 L_var1, Flag *Overflow ) return ( var_out ); } -#ifdef BASOP_NOGLOB static Word16 saturate( Word32 L_var1 ) { Word16 var_out; @@ -522,7 +500,6 @@ static Word16 saturate( Word32 L_var1 ) return ( var_out ); } -#endif /* BASOP_NOGLOB */ /*___________________________________________________________________________ | | @@ -557,7 +534,6 @@ static Word16 saturate( Word32 L_var1 ) | range : 0xffff 8000 <= var_out <= 0x0000 7fff. | |___________________________________________________________________________| */ -#ifdef BASOP_NOGLOB Word16 add_o( Word16 var1, Word16 var2, Flag *Overflow ) { Word16 var_out; @@ -572,7 +548,6 @@ Word16 add_o( Word16 var1, Word16 var2, Flag *Overflow ) return ( var_out ); } -#endif /* BASOP_NOGLOB */ Word16 add( Word16 var1, Word16 var2 ) { Word16 var_out; @@ -586,13 +561,11 @@ Word16 add( Word16 var1, Word16 var2 ) #endif return ( var_out ); } -#ifdef BASOP_NOGLOB Word16 add_sat( Word16 var1, Word16 var2 ) { Flag Overflow; return add_o( var1, var2, &Overflow ); } -#endif /*___________________________________________________________________________ | | | Function Name : sub | @@ -626,7 +599,6 @@ Word16 add_sat( Word16 var1, Word16 var2 ) | range : 0xffff 8000 <= var_out <= 0x0000 7fff. | |___________________________________________________________________________| */ -#ifdef BASOP_NOGLOB Word16 sub_o( Word16 var1, Word16 var2, Flag *Overflow ) { Word16 var_out; @@ -641,7 +613,6 @@ Word16 sub_o( Word16 var1, Word16 var2, Flag *Overflow ) return ( var_out ); } -#endif /* BASOP_NOGLOB */ Word16 sub( Word16 var1, Word16 var2 ) { Word16 var_out; @@ -655,13 +626,11 @@ Word16 sub( Word16 var1, Word16 var2 ) #endif return ( var_out ); } -#ifdef BASOP_NOGLOB Word16 sub_sat( Word16 var1, Word16 var2 ) { Flag Overflow; return sub_o( var1, var2, &Overflow ); } -#endif /*___________________________________________________________________________ | | | Function Name : abs_s | @@ -753,11 +722,7 @@ Word16 abs_s( Word16 var1 ) | range : 0xffff 8000 <= var_out <= 0x0000 7fff. | |___________________________________________________________________________| */ -#ifndef BASOP_NOGLOB -Word16 shl( Word16 var1, Word16 var2 ) -#else /* BASOP_NOGLOB */ Word16 shl_o( Word16 var1, Word16 var2, Flag *Overflow ) -#endif /* BASOP_NOGLOB */ { Word16 var_out; Word32 result; @@ -779,11 +744,7 @@ Word16 shl_o( Word16 var1, Word16 var2, Flag *Overflow ) if ( ( var2 > 15 && var1 != 0 ) || ( result != (Word32) ( (Word16) result ) ) ) { -#ifndef BASOP_NOGLOB - Overflow = 1; -#else /* BASOP_NOGLOB */ *Overflow = 1; -#endif /* BASOP_NOGLOB */ var_out = ( var1 > 0 ) ? MAX_16 : MIN_16; } else @@ -806,7 +767,6 @@ Word16 shl_o( Word16 var1, Word16 var2, Flag *Overflow ) return ( var_out ); } -#ifdef BASOP_NOGLOB Word16 shl( Word16 var1, Word16 var2 ) { Word16 var_out; @@ -856,7 +816,6 @@ Word16 shl_sat( Word16 var1, Word16 var2 ) Flag Overflow; return shl_o( var1, var2, &Overflow ); } -#endif /* BASOP_NOGLOB */ /*___________________________________________________________________________ | | @@ -892,11 +851,7 @@ Word16 shl_sat( Word16 var1, Word16 var2 ) | range : 0xffff 8000 <= var_out <= 0x0000 7fff. | |___________________________________________________________________________| */ -#ifdef BASOP_NOGLOB Word16 shr_o( Word16 var1, Word16 var2, Flag *Overflow ) -#else /* BASOP_NOGLOB */ -Word16 shr( Word16 var1, Word16 var2 ) -#endif /* BASOP_NOGLOB */ { Word16 var_out; @@ -905,11 +860,7 @@ Word16 shr( Word16 var1, Word16 var2 ) if ( var2 < -16 ) var2 = -16; var2 = -var2; -#ifdef BASOP_NOGLOB var_out = shl_o( var1, var2, Overflow ); -#else /* BASOP_NOGLOB */ - var_out = shl( var1, var2 ); -#endif /* BASOP_NOGLOB */ #ifdef WMOPS multiCounter[currCounter].shl--; @@ -943,7 +894,6 @@ Word16 shr( Word16 var1, Word16 var2 ) return ( var_out ); } -#ifdef BASOP_NOGLOB Word16 shr( Word16 var1, Word16 var2 ) { return shr_o( var1, var2, NULL ); @@ -953,7 +903,6 @@ Word16 shr_sat( Word16 var1, Word16 var2 ) Flag Overflow; return shr_o( var1, var2, &Overflow ); } -#endif /* BASOP_NOGLOB */ /*___________________________________________________________________________ @@ -990,11 +939,7 @@ Word16 shr_sat( Word16 var1, Word16 var2 ) | range : 0xffff 8000 <= var_out <= 0x0000 7fff. | |___________________________________________________________________________| */ -#ifdef BASOP_NOGLOB Word16 mult_o( Word16 var1, Word16 var2, Flag *Overflow ) -#else /* BASOP_NOGLOB */ -Word16 mult( Word16 var1, Word16 var2 ) -#endif /* BASOP_NOGLOB */ { Word16 var_out; Word32 L_product; @@ -1006,11 +951,7 @@ Word16 mult( Word16 var1, Word16 var2 ) if ( L_product & (Word32) 0x00010000L ) L_product = L_product | (Word32) 0xffff0000L; -#ifdef BASOP_NOGLOB var_out = saturate_o( L_product, Overflow ); -#else /* BASOP_NOGLOB */ - var_out = saturate( L_product ); -#endif /* BASOP_NOGLOB */ #ifdef WMOPS multiCounter[currCounter].mult++; @@ -1019,7 +960,6 @@ Word16 mult( Word16 var1, Word16 var2 ) BASOP_CHECK(); return ( var_out ); } -#ifdef BASOP_NOGLOB Word16 mult( Word16 var1, Word16 var2 ) { Word16 var_out; @@ -1046,7 +986,6 @@ Word16 mult_sat( Word16 var1, Word16 var2 ) return mult_o( var1, var2, &Overflow ); } -#endif /*___________________________________________________________________________ | | @@ -1082,11 +1021,7 @@ Word16 mult_sat( Word16 var1, Word16 var2 ) | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. | |___________________________________________________________________________| */ -#ifndef BASOP_NOGLOB -Word32 L_mult( Word16 var1, Word16 var2 ) -#else /* BASOP_NOGLOB */ Word32 L_mult_o( Word16 var1, Word16 var2, Flag *Overflow ) -#endif /* BASOP_NOGLOB */ { Word32 L_var_out; @@ -1098,11 +1033,7 @@ Word32 L_mult_o( Word16 var1, Word16 var2, Flag *Overflow ) } else { -#ifndef BASOP_NOGLOB - Overflow = 1; -#else /* BASOP_NOGLOB */ *Overflow = 1; -#endif /* BASOP_NOGLOB */ L_var_out = MAX_32; } @@ -1115,7 +1046,6 @@ Word32 L_mult_o( Word16 var1, Word16 var2, Flag *Overflow ) return ( L_var_out ); } -#ifdef BASOP_NOGLOB Word32 L_mult( Word16 var1, Word16 var2 ) { Word32 L_var_out; @@ -1146,7 +1076,6 @@ Word32 L_mult_sat( Word16 var1, Word16 var2 ) Flag Overflow; return L_mult_o( var1, var2, &Overflow ); } -#endif /* BASOP_NOGLOB */ /*___________________________________________________________________________ | | @@ -1312,7 +1241,6 @@ Word16 extract_l( Word32 L_var1 ) | range : 0xffff 8000 <= var_out <= 0x0000 7fff. | |___________________________________________________________________________| */ -#ifdef BASOP_NOGLOB Word16 round_fx_o( Word32 L_var1, Flag *Overflow ) { Word16 var_out; @@ -1334,7 +1262,6 @@ Word16 round_fx_o( Word32 L_var1, Flag *Overflow ) return ( var_out ); } -#endif /* BASOP_NOGLOB */ Word16 round_fx( Word32 L_var1 ) { Word16 var_out; @@ -1354,13 +1281,11 @@ Word16 round_fx( Word32 L_var1 ) return ( var_out ); } -#ifdef BASOP_NOGLOB Word16 round_fx_sat( Word32 L_var1 ) { Flag Overflow; return round_fx_o( L_var1, &Overflow ); } -#endif /*___________________________________________________________________________ | | | Function Name : L_mac | @@ -1397,7 +1322,6 @@ Word16 round_fx_sat( Word32 L_var1 ) | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. | |___________________________________________________________________________| */ -#ifdef BASOP_NOGLOB Word32 L_mac_o( Word32 L_var3, Word16 var1, Word16 var2, Flag *Overflow ) { Word32 L_var_out; @@ -1415,7 +1339,6 @@ Word32 L_mac_o( Word32 L_var3, Word16 var1, Word16 var2, Flag *Overflow ) return ( L_var_out ); } -#endif /* BASOP_NOGLOB */ Word32 L_mac( Word32 L_var3, Word16 var1, Word16 var2 ) { Word32 L_var_out; @@ -1433,13 +1356,11 @@ Word32 L_mac( Word32 L_var3, Word16 var1, Word16 var2 ) return ( L_var_out ); } -#ifdef BASOP_NOGLOB Word32 L_mac_sat( Word32 L_var3, Word16 var1, Word16 var2 ) { Flag Overflow; return L_mac_o( L_var3, var1, var2, &Overflow ); } -#endif /*___________________________________________________________________________ | | | Function Name : L_msu | @@ -1476,7 +1397,6 @@ Word32 L_mac_sat( Word32 L_var3, Word16 var1, Word16 var2 ) | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. | |___________________________________________________________________________| */ -#ifdef BASOP_NOGLOB Word32 L_msu_o( Word32 L_var3, Word16 var1, Word16 var2, Flag *Overflow ) { Word32 L_var_out; @@ -1494,7 +1414,6 @@ Word32 L_msu_o( Word32 L_var3, Word16 var1, Word16 var2, Flag *Overflow ) return ( L_var_out ); } -#endif /* BASOP_NOGLOB */ Word32 L_msu( Word32 L_var3, Word16 var1, Word16 var2 ) { Word32 L_var_out; @@ -1512,13 +1431,11 @@ Word32 L_msu( Word32 L_var3, Word16 var1, Word16 var2 ) return ( L_var_out ); } -#ifdef BASOP_NOGLOB Word32 L_msu_sat( Word32 L_var3, Word16 var1, Word16 var2 ) { Flag Overflow; return L_msu_o( L_var3, var1, var2, &Overflow ); } -#endif /*___________________________________________________________________________ | | | Function Name : L_macNs | @@ -1557,21 +1474,16 @@ Word32 L_msu_sat( Word32 L_var3, Word16 var1, Word16 var2 ) | | | Caution : | | | -#ifndef BASOP_NOGLOB - | In some cases the Carry flag has to be cleared or set before using | -#else | In some cases the BASOP_Carry flag has to be cleared or set before using | -#endif | operators which take into account its value. | |___________________________________________________________________________| */ -#ifdef BASOP_NOGLOB Word32 DEPR_L_macNs( Word32 L_var3, Word16 var1, Word16 var2, Flag *Carry ) { Word32 L_var_out; L_var_out = L_mult( var1, var2 ); - L_var_out = DEPR_L_add_c( L_var3, L_var_out, Carry ); + L_var_out = L_add_c( L_var3, L_var_out, Carry ); #ifdef WMOPS multiCounter[currCounter].L_mult--; @@ -1582,25 +1494,14 @@ Word32 DEPR_L_macNs( Word32 L_var3, Word16 var1, Word16 var2, Flag *Carry ) /* BASOP_CHECK(); Do not check for overflow here, function produces the carry bit instead */ return ( L_var_out ); } -#endif -#ifdef BASOP_NOGLOB Word32 L_macNs_co( Word32 L_var3, Word16 var1, Word16 var2, Flag *Carry, Flag *Overflow ) -#else /* BASOP_NOGLOB */ -Word32 L_macNs( Word32 L_var3, Word16 var1, Word16 var2 ) -#endif /* BASOP_NOGLOB */ { Word32 L_var_out; -#ifdef BASOP_NOGLOB L_var_out = L_mult_o( var1, var2, Overflow ); L_var_out = L_add_co( L_var3, L_var_out, Carry, Overflow ); -#else /* BASOP_NOGLOB */ - L_var_out = L_mult( var1, var2 ); - L_var_out = L_add_c( L_var3, L_var_out ); -#endif /* BASOP_NOGLOB */ return ( L_var_out ); } -#ifdef BASOP_NOGLOB Word32 L_macNs( Word32 L_var3, Word16 var1, Word16 var2 ) { return L_macNs_co( L_var3, var1, var2, NULL, NULL ); @@ -1610,7 +1511,6 @@ Word32 L_macNs_sat( Word32 L_var3, Word16 var1, Word16 var2 ) Flag Carry, Overflow; return L_macNs_co( L_var3, var1, var2, &Carry, &Overflow ); } -#endif /*___________________________________________________________________________ | | | Function Name : L_msuNs | @@ -1649,28 +1549,16 @@ Word32 L_macNs_sat( Word32 L_var3, Word16 var1, Word16 var2 ) | | | Caution : | | | -#ifndef BASOP_NOGLOB - | In some cases the Carry flag has to be cleared or set before using | -#else | In some cases the BASOP_Carry flag has to be cleared or set before using | -#endif | operators which take into account its value. | |___________________________________________________________________________| */ -#ifndef BASOP_NOGLOB -Word32 L_msuNs( Word32 L_var3, Word16 var1, Word16 var2 ) -#else /* BASOP_NOGLOB */ Word32 DEPR_L_msuNs( Word32 L_var3, Word16 var1, Word16 var2, Flag *Carry ) -#endif /* BASOP_NOGLOB */ { Word32 L_var_out; L_var_out = L_mult( var1, var2 ); -#ifndef BASOP_NOGLOB - L_var_out = L_sub_c( L_var3, L_var_out ); -#else /* BASOP_NOGLOB */ L_var_out = DEPR_L_sub_c( L_var3, L_var_out, Carry ); -#endif /* BASOP_NOGLOB */ #ifdef WMOPS multiCounter[currCounter].L_mult--; @@ -1683,7 +1571,6 @@ Word32 DEPR_L_msuNs( Word32 L_var3, Word16 var1, Word16 var2, Flag *Carry ) return ( L_var_out ); } -#ifdef BASOP_NOGLOB Word32 L_msuNs_co( Word32 L_var3, Word16 var1, Word16 var2, Flag *Carry, Flag *Overflow ) { Word32 L_var_out; @@ -1704,7 +1591,6 @@ Word32 L_msuNs_sat( Word32 L_var3, Word16 var1, Word16 var2 ) Flag Carry, Overflow; return L_msuNs_co( L_var3, var1, var2, &Carry, &Overflow ); } -#endif /*___________________________________________________________________________ | | | Function Name : L_add | @@ -1736,11 +1622,7 @@ Word32 L_msuNs_sat( Word32 L_var3, Word16 var1, Word16 var2 ) | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. | |___________________________________________________________________________| */ -#ifndef BASOP_NOGLOB -Word32 L_add( Word32 L_var1, Word32 L_var2 ) -#else /* BASOP_NOGLOB */ Word32 L_add_o( Word32 L_var1, Word32 L_var2, Flag *Overflow ) -#endif /* BASOP_NOGLOB */ { Word32 L_var_out; @@ -1751,11 +1633,7 @@ Word32 L_add_o( Word32 L_var1, Word32 L_var2, Flag *Overflow ) if ( ( L_var_out ^ L_var1 ) & MIN_32 ) { L_var_out = ( L_var1 < 0 ) ? MIN_32 : MAX_32; -#ifndef BASOP_NOGLOB - Overflow = 1; -#else /* BASOP_NOGLOB */ *Overflow = 1; -#endif /* BASOP_NOGLOB */ } } @@ -1769,7 +1647,6 @@ Word32 L_add_o( Word32 L_var1, Word32 L_var2, Flag *Overflow ) return ( L_var_out ); } -#ifdef BASOP_NOGLOB Word32 L_add( Word32 L_var1, Word32 L_var2 ) { Word32 L_var_out; @@ -1795,7 +1672,6 @@ Word32 L_add_sat( Word32 L_var1, Word32 L_var2 ) Flag Overflow; return L_add_o( L_var1, L_var2, &Overflow ); } -#endif /* BASOP_NOGLOB */ /*___________________________________________________________________________ | | @@ -1828,11 +1704,7 @@ Word32 L_add_sat( Word32 L_var1, Word32 L_var2 ) | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. | |___________________________________________________________________________| */ -#ifndef BASOP_NOGLOB -Word32 L_sub( Word32 L_var1, Word32 L_var2 ) -#else /* BASOP_NOGLOB */ Word32 L_sub_o( Word32 L_var1, Word32 L_var2, Flag *Overflow ) -#endif /* BASOP_NOGLOB */ { Word32 L_var_out; @@ -1843,11 +1715,7 @@ Word32 L_sub_o( Word32 L_var1, Word32 L_var2, Flag *Overflow ) if ( ( L_var_out ^ L_var1 ) & MIN_32 ) { L_var_out = ( L_var1 < 0L ) ? MIN_32 : MAX_32; -#ifndef BASOP_NOGLOB - Overflow = 1; -#else /* BASOP_NOGLOB */ *Overflow = 1; -#endif /* BASOP_NOGLOB */ } } @@ -1860,7 +1728,6 @@ Word32 L_sub_o( Word32 L_var1, Word32 L_var2, Flag *Overflow ) return ( L_var_out ); } -#ifdef BASOP_NOGLOB Word32 L_sub( Word32 L_var1, Word32 L_var2 ) { Word32 L_var_out; @@ -1888,7 +1755,6 @@ Word32 L_sub_sat( Word32 L_var1, Word32 L_var2 ) Flag Overflow; return L_sub_o( L_var1, L_var2, &Overflow ); } -#endif /* BASOP_NOGLOB */ /*___________________________________________________________________________ | | @@ -1897,11 +1763,7 @@ Word32 L_sub_sat( Word32 L_var1, Word32 L_var2 ) | Purpose : | | | | Performs 32 bits addition of the two 32 bits variables (L_var1+L_var2+C)| -#ifndef BASOP_NOGLOB - | with carry. No saturation. Generate carry and Overflow values. The car- | -#else | with carry. No saturation. Generate carry and BASOP_Overflow values. The car- | -#endif | ry and overflow values are binary variables which can be tested and as- | | signed values. | | | @@ -1927,37 +1789,22 @@ Word32 L_sub_sat( Word32 L_var1, Word32 L_var2 ) | | | Caution : | | | -#ifndef BASOP_NOGLOB - | In some cases the Carry flag has to be cleared or set before using | -#else | In some cases the BASOP_Carry flag has to be cleared or set before using | -#endif | operators which take into account its value. | |___________________________________________________________________________| */ -#ifndef BASOP_NOGLOB -Word32 L_add_c( Word32 L_var1, Word32 L_var2 ) -#else /* BASOP_NOGLOB */ -Word32 DEPR_L_add_c( Word32 L_var1, Word32 L_var2, Flag *Carry ) -#endif /* BASOP_NOGLOB */ +Word32 L_add_c( Word32 L_var1, Word32 L_var2, Flag *Carry ) { Word32 L_var_out; Word32 L_test; Flag carry_int = 0; -#ifndef BASOP_NOGLOB - L_var_out = L_var1 + L_var2 + Carry; -#else /* BASOP_NOGLOB */ L_var_out = L_var1 + L_var2 + *Carry; -#endif /* BASOP_NOGLOB */ L_test = L_var1 + L_var2; if ( ( L_var1 > 0 ) && ( L_var2 > 0 ) && ( L_test < 0 ) ) { -#ifndef BASOP_NOGLOB - Overflow = 1; -#endif /* ! BASOP_NOGLOB */ carry_int = 0; } else @@ -1966,16 +1813,10 @@ Word32 DEPR_L_add_c( Word32 L_var1, Word32 L_var2, Flag *Carry ) { if ( L_test >= 0 ) { -#ifndef BASOP_NOGLOB - Overflow = 1; -#endif /* ! BASOP_NOGLOB */ carry_int = 1; } else { -#ifndef BASOP_NOGLOB - Overflow = 0; -#endif /* ! BASOP_NOGLOB */ carry_int = 1; } } @@ -1983,63 +1824,36 @@ Word32 DEPR_L_add_c( Word32 L_var1, Word32 L_var2, Flag *Carry ) { if ( ( ( L_var1 ^ L_var2 ) < 0 ) && ( L_test >= 0 ) ) { -#ifndef BASOP_NOGLOB - Overflow = 0; -#endif /* ! BASOP_NOGLOB */ carry_int = 1; } else { -#ifndef BASOP_NOGLOB - Overflow = 0; -#endif /* ! BASOP_NOGLOB */ carry_int = 0; } } } -#ifndef BASOP_NOGLOB - if ( Carry ) -#else /* BASOP_NOGLOB */ if ( *Carry ) -#endif /* BASOP_NOGLOB */ { if ( L_test == MAX_32 ) { -#ifndef BASOP_NOGLOB - Overflow = 1; - Carry = carry_int; -#else /* BASOP_NOGLOB */ *Carry = carry_int; -#endif /* BASOP_NOGLOB */ } else { if ( L_test == (Word32) 0xFFFFFFFFL ) { -#ifndef BASOP_NOGLOB - Carry = 1; -#else /* BASOP_NOGLOB */ *Carry = 1; -#endif /* BASOP_NOGLOB */ } else { -#ifndef BASOP_NOGLOB - Carry = carry_int; -#else /* BASOP_NOGLOB */ *Carry = carry_int; -#endif /* BASOP_NOGLOB */ } } } else { -#ifndef BASOP_NOGLOB - Carry = carry_int; -#else /* BASOP_NOGLOB */ *Carry = carry_int; -#endif /* BASOP_NOGLOB */ } #ifdef WMOPS @@ -2051,7 +1865,6 @@ Word32 DEPR_L_add_c( Word32 L_var1, Word32 L_var2, Flag *Carry ) return ( L_var_out ); } -#ifdef BASOP_NOGLOB Word32 L_add_co( Word32 L_var1, Word32 L_var2, Flag *Carry, Flag *Overflow ) { Word32 L_var_out; @@ -2121,13 +1934,12 @@ Word32 L_add_co( Word32 L_var1, Word32 L_var2, Flag *Carry, Flag *Overflow ) carry_int ? set_carry( Carry ) : unset_carry( Carry ); } +#ifdef WMOPS + multiCounter[currCounter].L_add_c++; +#endif return ( L_var_out ); } -Word32 L_add_c( Word32 L_var1, Word32 L_var2 ) -{ - return L_add_co( L_var1, L_var2, NULL, NULL ); -} -#endif + /*___________________________________________________________________________ | | | Function Name : L_sub_c | @@ -2135,11 +1947,7 @@ Word32 L_add_c( Word32 L_var1, Word32 L_var2 ) | Purpose : | | | | Performs 32 bits subtraction of the two 32 bits variables with carry | -#ifndef BASOP_NOGLOB - | (borrow) : L_var1-L_var2-C. No saturation. Generate carry and Overflow | -#else | (borrow) : L_var1-L_var2-C. No saturation. Generate carry and BASOP_Overflow | -#endif | values. The carry and overflow values are binary variables which can | | be tested and assigned values. | | | @@ -2165,42 +1973,22 @@ Word32 L_add_c( Word32 L_var1, Word32 L_var2 ) | | | Caution : | | | -#ifndef BASOP_NOGLOB - | In some cases the Carry flag has to be cleared or set before using | -#else | In some cases the BASOP_Carry flag has to be cleared or set before using | -#endif | operators which take into account its value. | |___________________________________________________________________________| */ -#ifndef BASOP_NOGLOB -Word32 L_sub_c( Word32 L_var1, Word32 L_var2 ) -#else /* BASOP_NOGLOB */ Word32 DEPR_L_sub_c( Word32 L_var1, Word32 L_var2, Flag *Carry ) -#endif /* BASOP_NOGLOB */ { Word32 L_var_out; Word32 L_test; Flag carry_int = 0; -#ifndef BASOP_NOGLOB - if ( Carry ) -#else /* BASOP_NOGLOB */ if ( *Carry ) -#endif /* BASOP_NOGLOB */ { -#ifndef BASOP_NOGLOB - Carry = 0; -#else /* BASOP_NOGLOB */ *Carry = 0; -#endif /* BASOP_NOGLOB */ if ( L_var2 != MIN_32 ) { -#ifndef BASOP_NOGLOB - L_var_out = L_add_c( L_var1, -L_var2 ); -#else /* BASOP_NOGLOB */ - L_var_out = DEPR_L_add_c( L_var1, -L_var2, Carry ); -#endif /* BASOP_NOGLOB */ + L_var_out = L_add_c( L_var1, -L_var2, Carry ); #ifdef WMOPS multiCounter[currCounter].L_add_c--; #endif @@ -2210,12 +1998,7 @@ Word32 DEPR_L_sub_c( Word32 L_var1, Word32 L_var2, Flag *Carry ) L_var_out = L_var1 - L_var2; if ( L_var1 > 0L ) { -#ifndef BASOP_NOGLOB - Overflow = 1; - Carry = 0; -#else /* BASOP_NOGLOB */ *Carry = 0; -#endif /* BASOP_NOGLOB */ } } } @@ -2226,41 +2009,23 @@ Word32 DEPR_L_sub_c( Word32 L_var1, Word32 L_var2, Flag *Carry ) if ( ( L_test < 0 ) && ( L_var1 > 0 ) && ( L_var2 < 0 ) ) { -#ifndef BASOP_NOGLOB - Overflow = 1; -#endif /* ! BASOP_NOGLOB */ carry_int = 0; } else if ( ( L_test > 0 ) && ( L_var1 < 0 ) && ( L_var2 > 0 ) ) { -#ifndef BASOP_NOGLOB - Overflow = 1; -#endif /* ! BASOP_NOGLOB */ carry_int = 1; } else if ( ( L_test > 0 ) && ( ( L_var1 ^ L_var2 ) > 0 ) ) { -#ifndef BASOP_NOGLOB - Overflow = 0; -#endif /* ! BASOP_NOGLOB */ carry_int = 1; } if ( L_test == MIN_32 ) { -#ifndef BASOP_NOGLOB - Overflow = 1; - Carry = carry_int; -#else /* BASOP_NOGLOB */ *Carry = carry_int; -#endif /* BASOP_NOGLOB */ } else { -#ifndef BASOP_NOGLOB - Carry = carry_int; -#else /* BASOP_NOGLOB */ *Carry = carry_int; -#endif /* BASOP_NOGLOB */ } } @@ -2273,7 +2038,6 @@ Word32 DEPR_L_sub_c( Word32 L_var1, Word32 L_var2, Flag *Carry ) return ( L_var_out ); } -#ifdef BASOP_NOGLOB Word32 L_sub_co( Word32 L_var1, Word32 L_var2, Flag *Carry, Flag *Overflow ) { Word32 L_var_out; @@ -2329,7 +2093,6 @@ Word32 L_sub_c( Word32 L_var1, Word32 L_var2 ) { return L_sub_co( L_var1, L_var2, NULL, NULL ); } -#endif /*___________________________________________________________________________ | | | Function Name : L_negate | @@ -2407,7 +2170,6 @@ Word32 L_negate( Word32 L_var1 ) | range : 0x8000 <= var_out <= 0x7fff. | |___________________________________________________________________________| */ -#ifdef BASOP_NOGLOB Word16 mult_ro( Word16 var1, Word16 var2, Flag *Overflow ) { Word16 var_out; @@ -2431,7 +2193,6 @@ Word16 mult_ro( Word16 var1, Word16 var2, Flag *Overflow ) return ( var_out ); } -#endif /* BASOP_NOGLOB */ Word16 mult_r( Word16 var1, Word16 var2 ) { Word16 var_out; @@ -2454,13 +2215,11 @@ Word16 mult_r( Word16 var1, Word16 var2 ) return ( var_out ); } -#ifdef BASOP_NOGLOB Word16 mult_r_sat( Word16 var1, Word16 var2 ) { Flag Overflow; return mult_ro( var1, var2, &Overflow ); } -#endif /*___________________________________________________________________________ | | | Function Name : L_shl | @@ -2494,11 +2253,7 @@ Word16 mult_r_sat( Word16 var1, Word16 var2 ) | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. | |___________________________________________________________________________| */ -#ifndef BASOP_NOGLOB -Word32 L_shl( Word32 L_var1, Word16 var2 ) -#else /* BASOP_NOGLOB */ Word32 L_shl_o( Word32 L_var1, Word16 var2, Flag *Overflow ) -#endif /* BASOP_NOGLOB */ { Word32 L_var_out = 0L; @@ -2519,11 +2274,7 @@ Word32 L_shl_o( Word32 L_var1, Word16 var2, Flag *Overflow ) { if ( L_var1 > (Word32) 0X3fffffffL ) { -#ifndef BASOP_NOGLOB - Overflow = 1; -#else /* BASOP_NOGLOB */ *Overflow = 1; -#endif /* BASOP_NOGLOB */ L_var_out = MAX_32; break; } @@ -2531,11 +2282,7 @@ Word32 L_shl_o( Word32 L_var1, Word16 var2, Flag *Overflow ) { if ( L_var1 < (Word32) 0xc0000000L ) { -#ifndef BASOP_NOGLOB - Overflow = 1; -#else /* BASOP_NOGLOB */ *Overflow = 1; -#endif /* BASOP_NOGLOB */ L_var_out = MIN_32; break; } @@ -2555,7 +2302,6 @@ Word32 L_shl_o( Word32 L_var1, Word16 var2, Flag *Overflow ) return ( L_var_out ); } -#ifdef BASOP_NOGLOB Word32 L_shl( Word32 L_var1, Word16 var2 ) { @@ -2610,7 +2356,6 @@ Word32 L_shl_sat( Word32 L_var1, Word16 var2 ) return L_shl_o( L_var1, var2, &Overflow ); } -#endif /* BASOP_NOGLOB */ /*___________________________________________________________________________ | | | Function Name : L_shr | @@ -2644,7 +2389,6 @@ Word32 L_shl_sat( Word32 L_var1, Word16 var2 ) | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. | |___________________________________________________________________________| */ -#ifdef BASOP_NOGLOB Word32 L_shr_o( Word32 L_var1, Word16 var2, Flag *Overflow ) { Word32 L_var_out; @@ -2688,7 +2432,6 @@ Word32 L_shr_o( Word32 L_var1, Word16 var2, Flag *Overflow ) return ( L_var_out ); } -#endif /* BASOP_NOGLOB */ Word32 L_shr( Word32 L_var1, Word16 var2 ) { Word32 L_var_out; @@ -2730,13 +2473,11 @@ Word32 L_shr( Word32 L_var1, Word16 var2 ) return ( L_var_out ); } -#ifdef BASOP_NOGLOB Word32 L_shr_sat( Word32 L_var1, Word16 var2 ) { Flag Overflow; return L_shr_o( L_var1, var2, &Overflow ); } -#endif /*___________________________________________________________________________ | | | Function Name : shr_r | @@ -2810,7 +2551,6 @@ Word16 shr_r( Word16 var1, Word16 var2 ) return ( var_out ); } -#ifdef BASOP_NOGLOB Word16 shr_ro( Word16 var1, Word16 var2, Flag *Overflow ) { Word16 var_out; @@ -2852,7 +2592,6 @@ Word16 shr_r_sat( Word16 var1, Word16 var2 ) Flag Overflow; return shr_ro( var1, var2, &Overflow ); } -#endif /*___________________________________________________________________________ | | | Function Name : mac_r | @@ -2891,7 +2630,6 @@ Word16 shr_r_sat( Word16 var1, Word16 var2 ) | range : 0x0000 8000 <= L_var_out <= 0x0000 7fff. | |___________________________________________________________________________| */ -#ifdef BASOP_NOGLOB Word16 mac_ro( Word32 L_var3, Word16 var1, Word16 var2, Flag *Overflow ) { Word16 var_out; @@ -2913,7 +2651,6 @@ Word16 mac_ro( Word32 L_var3, Word16 var1, Word16 var2, Flag *Overflow ) return ( var_out ); } -#endif /* BASOP_NOGLOB */ Word16 mac_r( Word32 L_var3, Word16 var1, Word16 var2 ) { Word16 var_out; @@ -2934,13 +2671,11 @@ Word16 mac_r( Word32 L_var3, Word16 var1, Word16 var2 ) return ( var_out ); } -#ifdef BASOP_NOGLOB Word16 mac_r_sat( Word32 L_var3, Word16 var1, Word16 var2 ) { Flag Overflow; return mac_ro( L_var3, var1, var2, &Overflow ); } -#endif /*___________________________________________________________________________ | | | Function Name : msu_r | @@ -2979,7 +2714,6 @@ Word16 mac_r_sat( Word32 L_var3, Word16 var1, Word16 var2 ) | range : 0x0000 8000 <= L_var_out <= 0x0000 7fff. | |___________________________________________________________________________| */ -#ifdef BASOP_NOGLOB Word16 msu_ro( Word32 L_var3, Word16 var1, Word16 var2, Flag *Overflow ) { Word16 var_out; @@ -2999,7 +2733,6 @@ Word16 msu_ro( Word32 L_var3, Word16 var1, Word16 var2, Flag *Overflow ) return ( var_out ); } -#endif /* BASOP_NOGLOB */ Word16 msu_r( Word32 L_var3, Word16 var1, Word16 var2 ) { Word16 var_out; @@ -3018,13 +2751,11 @@ Word16 msu_r( Word32 L_var3, Word16 var1, Word16 var2 ) return ( var_out ); } -#ifdef BASOP_NOGLOB Word16 msu_r_sat( Word32 L_var3, Word16 var1, Word16 var2 ) { Flag Overflow; return msu_ro( L_var3, var1, var2, &Overflow ); } -#endif /*___________________________________________________________________________ | | | Function Name : L_deposit_h | @@ -3189,7 +2920,6 @@ Word32 L_shr_r( Word32 L_var1, Word16 var2 ) return ( L_var_out ); } -#ifdef BASOP_NOGLOB Word32 L_shr_ro( Word32 L_var1, Word16 var2, Flag *Overflow ) { Word32 L_var_out; @@ -3217,7 +2947,6 @@ Word32 L_shr_r_sat( Word32 L_var1, Word16 var2 ) Flag Overflow = 0; return L_shr_ro( L_var1, var2, &Overflow ); } -#endif /*___________________________________________________________________________ | | | Function Name : L_abs | @@ -3307,11 +3036,7 @@ Word32 L_abs( Word32 L_var1 ) | range : 0x8000 0000 <= var_out <= 0x7fff ffff. | |___________________________________________________________________________| */ -#ifndef BASOP_NOGLOB -Word32 L_sat( Word32 L_var1 ) -#else /* BASOP_NOGLOB */ Word32 DEPR_L_sat_co( Word32 L_var1, Flag Overflow, Flag Carry ) -#endif /* BASOP_NOGLOB */ { Word32 L_var_out; @@ -3328,11 +3053,6 @@ Word32 DEPR_L_sat_co( Word32 L_var1, Flag Overflow, Flag Carry ) { L_var_out = MAX_32; } -#ifndef BASOP_NOGLOB - - Carry = 0; - Overflow = 0; -#endif /* ! BASOP_NOGLOB */ } #ifdef WMOPS @@ -3344,7 +3064,6 @@ Word32 DEPR_L_sat_co( Word32 L_var1, Flag Overflow, Flag Carry ) return ( L_var_out ); } -#ifdef BASOP_NOGLOB Word32 L_sat_co( Word32 L_var1, Flag Carry, Flag Overflow ) { Word32 L_var_out; @@ -3371,7 +3090,6 @@ Word32 L_sat( Word32 L_var1 ) assert( 0 ); /* Overflow and Carry are no longer global, must be passed as parameters */ return L_sat_co( L_var1, 0, 0 ); } -#endif /*___________________________________________________________________________ | | | Function Name : norm_s | @@ -3661,7 +3379,6 @@ Word16 norm_l( Word32 L_var1 ) | | |___________________________________________________________________________| */ -#ifdef BASOP_NOGLOB Word32 L_mls_o( Word32 Lv, Word16 v, Flag *Overflow ) { Word32 Temp; @@ -3683,7 +3400,6 @@ Word32 L_mls_o( Word32 Lv, Word16 v, Flag *Overflow ) return Temp; } -#endif /* BASOP_NOGLOB */ Word32 L_mls( Word32 Lv, Word16 v ) { Word32 Temp; @@ -3704,13 +3420,11 @@ Word32 L_mls( Word32 Lv, Word16 v ) return Temp; } -#ifdef BASOP_NOGLOB Word32 L_mls_sat( Word32 Lv, Word16 v ) { Flag Overflow; return L_mls_o( Lv, v, &Overflow ); } -#endif /*__________________________________________________________________________ | | @@ -3848,11 +3562,7 @@ Word16 div_l( Word32 L_num, Word16 den ) | are performed if ORIGINAL_G7231 is defined. | |___________________________________________________________________________| */ -#ifndef BASOP_NOGLOB -Word16 i_mult( Word16 a, Word16 b ) -#else /* BASOP_NOGLOB */ Word16 DEPR_i_mult( Word16 a, Word16 b ) -#endif /* BASOP_NOGLOB */ { #ifdef ORIGINAL_G7231 return a * b; @@ -3865,7 +3575,6 @@ Word16 DEPR_i_mult( Word16 a, Word16 b ) #endif } -#ifdef BASOP_NOGLOB Word16 i_mult_o( Word16 a, Word16 b, Flag *Overflow ) { #ifdef ORIGINAL_G7231 @@ -3884,7 +3593,6 @@ Word16 i_mult_sat( Word16 a, Word16 b ) Flag Overflow; return i_mult_o( a, b, &Overflow ); } -#endif /* ****************************************************************************** * The following three operators are not part of the original @@ -3964,7 +3672,6 @@ Word32 L_mult0( Word16 var1, Word16 var2 ) | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. |___________________________________________________________________________ */ -#ifdef BASOP_NOGLOB Word32 L_mac0_o( Word32 L_var3, Word16 var1, Word16 var2, Flag *Overflow ) { Word32 L_var_out; @@ -3984,7 +3691,6 @@ Word32 L_mac0_o( Word32 L_var3, Word16 var1, Word16 var2, Flag *Overflow ) return ( L_var_out ); } -#endif /* BASOP_NOGLOB */ Word32 L_mac0( Word32 L_var3, Word16 var1, Word16 var2 ) { Word32 L_var_out; @@ -4004,13 +3710,11 @@ Word32 L_mac0( Word32 L_var3, Word16 var1, Word16 var2 ) return ( L_var_out ); } -#ifdef BASOP_NOGLOB Word32 L_mac0_sat( Word32 L_var3, Word16 var1, Word16 var2 ) { Flag Overflow; return L_mac0_o( L_var3, var1, var2, &Overflow ); } -#endif /*___________________________________________________________________________ | | Function Name : L_msu0 @@ -4041,7 +3745,6 @@ Word32 L_mac0_sat( Word32 L_var3, Word16 var1, Word16 var2 ) | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. |___________________________________________________________________________ */ -#ifdef BASOP_NOGLOB Word32 L_msu0_o( Word32 L_var3, Word16 var1, Word16 var2, Flag *Overflow ) { Word32 L_var_out; @@ -4061,7 +3764,6 @@ Word32 L_msu0_o( Word32 L_var3, Word16 var1, Word16 var2, Flag *Overflow ) return ( L_var_out ); } -#endif /* BASOP_NOGLOB */ Word32 L_msu0( Word32 L_var3, Word16 var1, Word16 var2 ) { Word32 L_var_out; @@ -4081,12 +3783,10 @@ Word32 L_msu0( Word32 L_var3, Word16 var1, Word16 var2 ) return ( L_var_out ); } -#ifdef BASOP_NOGLOB Word32 L_msu0_sat( Word32 L_var3, Word16 var1, Word16 var2 ) { Flag Overflow; return L_msu0_o( L_var3, var1, var2, &Overflow ); } -#endif #undef WMC_TOOL_SKIP diff --git a/lib_com/basop32.h b/lib_com/basop32.h index 785a4bf5629ea7cd01cc505904a6b30d47a40ce5..96fd8d166c1b84b767435db9a59f577baaf154de 100644 --- a/lib_com/basop32.h +++ b/lib_com/basop32.h @@ -86,17 +86,11 @@ | Constants and Globals | |___________________________________________________________________________| */ -#ifndef BASOP_NOGLOB -extern Flag Overflow, Overflow2; -extern Flag Carry; - -#else /* BASOP_NOGLOB */ /* DISABLED TO AVOID GLOBAL VARIABLES */ /* extern Flag BASOP_Overflow, BASOP_Overflow2; extern Flag BASOP_Carry; */ -#endif /* BASOP_NOGLOB */ #define BASOP_SATURATE_WARNING_ON_EVS #define BASOP_SATURATE_WARNING_OFF_EVS #define BASOP_SATURATE_ERROR_ON_EVS @@ -114,36 +108,17 @@ extern Flag BASOP_Carry; #define MAX_16 (Word16) 0x7fff #define MIN_16 (Word16) 0x8000 -#ifdef BASOP_NOGLOB void set_overflow( Flag *overflow ); void unset_overflow( Flag *overflow ); void set_carry( Flag *carry ); void unset_carry( Flag *carry ); Flag get_carry( const Flag *carry ); -#endif /* BASOP_NOGLOB */ /*___________________________________________________________________________ | | | Prototypes for basic arithmetic operators | |___________________________________________________________________________| */ -#ifndef BASOP_NOGLOB -Word16 add( Word16 var1, Word16 var2 ); /* Short add, 1 */ -Word16 sub( Word16 var1, Word16 var2 ); /* Short sub, 1 */ -Word16 abs_s( Word16 var1 ); /* Short abs, 1 */ -Word16 shl( Word16 var1, Word16 var2 ); /* Short shift left, 1 */ -Word16 shr( Word16 var1, Word16 var2 ); /* Short shift right, 1 */ -Word16 mult( Word16 var1, Word16 var2 ); /* Short mult, 1 */ -Word32 L_mult( Word16 var1, Word16 var2 ); /* Long mult, 1 */ -Word16 negate( Word16 var1 ); /* Short negate, 1 */ -Word16 extract_h( Word32 L_var1 ); /* Extract high, 1 */ -Word16 extract_l( Word32 L_var1 ); /* Extract low, 1 */ -Word16 round_fx( Word32 L_var1 ); /* Round, 1 */ -Word32 L_mac( Word32 L_var3, Word16 var1, Word16 var2 ); /* Mac, 1 */ -Word32 L_msu( Word32 L_var3, Word16 var1, Word16 var2 ); /* Msu, 1 */ -Word32 L_macNs( Word32 L_var3, Word16 var1, Word16 var2 ); /* Mac without - sat, 1 */ -#else /* BASOP_NOGLOB */ Word16 add( Word16 var1, Word16 var2 ); /* Short add, 1 */ Word16 sub( Word16 var1, Word16 var2 ); /* Short sub, 1 */ Word16 abs_s( Word16 var1 ); /* Short abs, 1 */ @@ -163,33 +138,14 @@ Word32 L_macNs( Word32 L_var3, Word16 var1, Word16 var2 ); /* Word32 L_msuNs( Word32 L_var3, Word16 var1, Word16 var2 ); /* Msu without sat, 1 */ Word32 L_add_co( Word32 L_var1, Word32 L_var2, Flag *Carry, Flag *Overflow ); Word32 L_sub_co( Word32 L_var1, Word32 L_var2, Flag *Carry, Flag *Overflow ); -Word32 L_add_c( Word32 L_var1, Word32 L_var2 ); /* Long add with c, 2 */ -Word32 L_sub_c( Word32 L_var1, Word32 L_var2 ); /* Long sub with c, 2 */ +Word32 L_sub_c( Word32 L_var1, Word32 L_var2 ); /* Long sub with c, 2 */ -#endif /* BASOP_NOGLOB */ -#ifndef BASOP_NOGLOB -Word32 L_msuNs( Word32 L_var3, Word16 var1, Word16 var2 ); /* Msu without - sat, 1 */ -#else /* BASOP_NOGLOB */ Word32 DEPR_L_msuNs( Word32 L_var3, Word16 var1, Word16 var2, Flag *Carry ); /* Msu without sat, 1 */ -#endif /* BASOP_NOGLOB */ -#ifndef BASOP_NOGLOB -Word32 L_add( Word32 L_var1, Word32 L_var2 ); /* Long add, 1 */ -Word32 L_sub( Word32 L_var1, Word32 L_var2 ); /* Long sub, 1 */ -Word32 L_add_c( Word32 L_var1, Word32 L_var2 ); /* Long add with c, 2 */ -Word32 L_sub_c( Word32 L_var1, Word32 L_var2 ); /* Long sub with c, 2 */ -Word32 L_negate( Word32 L_var1 ); /* Long negate, 1 */ -Word16 mult_r( Word16 var1, Word16 var2 ); /* Mult with round, 1 */ -Word32 L_shl( Word32 L_var1, Word16 var2 ); /* Long shift left, 1 */ -Word32 L_shr( Word32 L_var1, Word16 var2 ); /* Long shift right, 1 */ -Word16 shr_r( Word16 var1, Word16 var2 ); /* Shift right with - round, 2 */ -#else /* BASOP_NOGLOB */ Word32 L_add( Word32 L_var1, Word32 L_var2 ); /* Long add, 1 */ Word32 L_sub( Word32 L_var1, Word32 L_var2 ); /* Long sub, 1 */ -Word32 DEPR_L_add_c( Word32 L_var1, Word32 L_var2, Flag *Carry ); /* Long add with c, 2 */ +Word32 L_add_c( Word32 L_var1, Word32 L_var2, Flag *Carry ); /* Long add with c, 2 */ Word32 DEPR_L_sub_c( Word32 L_var1, Word32 L_var2, Flag *Carry ); /* Long sub with c, 2 */ Word32 L_negate( Word32 L_var1 ); /* Long negate, 1 */ Word16 mult_r( Word16 var1, Word16 var2 ); /* Mult with round, 1 */ @@ -197,67 +153,32 @@ Word32 L_shl( Word32 L_var1, Word16 var2 ); /* Word32 L_shr( Word32 L_var1, Word16 var2 ); /* Long shift right, 1 */ Word16 shr_r( Word16 var1, Word16 var2 ); /* Shift right with round, 2 */ -#endif /* BASOP_NOGLOB */ -#ifndef BASOP_NOGLOB Word16 mac_r( Word32 L_var3, Word16 var1, Word16 var2 ); /* Mac with - rounding, 1 */ -#else /* BASOP_NOGLOB */ -Word16 mac_r( Word32 L_var3, Word16 var1, Word16 var2 ); /* Mac with - rounding, 1 */ -#endif /* BASOP_NOGLOB */ -#ifndef BASOP_NOGLOB + rounding, 1 */ Word16 msu_r( Word32 L_var3, Word16 var1, Word16 var2 ); /* Msu with - rounding, 1 */ -#else /* BASOP_NOGLOB */ -Word16 msu_r( Word32 L_var3, Word16 var1, Word16 var2 ); /* Msu with - rounding, 1 */ -#endif /* BASOP_NOGLOB */ -#ifndef BASOP_NOGLOB -Word32 L_deposit_h( Word16 var1 ); /* 16 bit var1 -> MSB, 1 */ -Word32 L_deposit_l( Word16 var1 ); /* 16 bit var1 -> LSB, 1 */ -#else /* BASOP_NOGLOB */ -Word32 L_deposit_h( Word16 var1 ); /* 16 bit var1 -> MSB, 1 */ -Word32 L_deposit_l( Word16 var1 ); /* 16 bit var1 -> LSB, 1 */ -#endif /* BASOP_NOGLOB */ - -#ifndef BASOP_NOGLOB -Word32 L_shr_r( Word32 L_var1, Word16 var2 ); /* Long shift right with - round, 3 */ -#else /* BASOP_NOGLOB */ -Word32 L_shr_r( Word32 L_var1, Word16 var2 ); /* Long shift right with - round, 3 */ -#endif /* BASOP_NOGLOB */ -#ifndef BASOP_NOGLOB -Word32 L_abs( Word32 L_var1 ); /* Long abs, 1 */ -Word32 L_sat( Word32 L_var1 ); /* Long saturation, 4 */ -Word16 norm_s( Word16 var1 ); /* Short norm, 1 */ -Word16 div_s( Word16 var1, Word16 var2 ); /* Short division, 18 */ -Word16 norm_l( Word32 L_var1 ); /* Long norm, 1 */ -#else /* BASOP_NOGLOB */ -Word32 L_abs( Word32 L_var1 ); /* Long abs, 1 */ -Word32 DEPR_L_sat_co( Word32 L_var1, Flag Overflow, Flag Carry ); /* Long saturation, 4 */ -Word16 norm_s( Word16 var1 ); /* Short norm, 1 */ -Word16 div_s( Word16 var1, Word16 var2 ); /* Short division, 18 */ + rounding, 1 */ +Word32 L_deposit_h( Word16 var1 ); /* 16 bit var1 -> MSB, 1 */ +Word32 L_deposit_l( Word16 var1 ); /* 16 bit var1 -> LSB, 1 */ + +Word32 L_shr_r( Word32 L_var1, Word16 var2 ); /* Long shift right with + round, 3 */ +Word32 L_abs( Word32 L_var1 ); /* Long abs, 1 */ +Word32 DEPR_L_sat_co( Word32 L_var1, Flag Overflow, Flag Carry ); /* Long saturation, 4 */ +Word16 norm_s( Word16 var1 ); /* Short norm, 1 */ +Word16 div_s( Word16 var1, Word16 var2 ); /* Short division, 18 */ Word32 div_w( Word32 L_num, Word32 L_den ); -Word16 norm_l( Word32 L_var1 ); /* Long norm, 1 */ -Word32 L_sat( Word32 L_var1 ); /* Long saturation, 4 */ -#endif /* BASOP_NOGLOB */ +Word16 norm_l( Word32 L_var1 ); /* Long norm, 1 */ +Word32 L_sat( Word32 L_var1 ); /* Long saturation, 4 */ /* * Additional G.723.1 operators */ -#ifndef BASOP_NOGLOB -Word32 L_mls( Word32, Word16 ); /* Weight FFS; currently assigned 5 */ -Word16 div_l( Word32, Word16 ); /* Weight FFS; currently assigned 32 */ -Word16 i_mult( Word16 a, Word16 b ); /* Weight FFS; currently assigned 3 */ -#else /* BASOP_NOGLOB */ Word32 L_mls( Word32, Word16 ); /* Weight FFS; currently assigned 5 */ Word16 div_l( Word32, Word16 ); /* Weight FFS; currently assigned 32 */ Word16 i_mult( Word16 a, Word16 b ); /* Weight FFS; currently assigned 3 */ Word16 DEPR_i_mult( Word16 a, Word16 b ); /* Weight FFS; currently assigned 3 */ -#endif /* BASOP_NOGLOB */ /* * New shiftless operators, not used in G.729/G.723.1 @@ -265,7 +186,6 @@ Word16 DEPR_i_mult( Word16 a, Word16 b ); /* Weight FFS; currently assigned 3 */ Word32 L_mult0( Word16 v1, Word16 v2 ); /* 32-bit Multiply w/o shift 1 */ Word32 L_mac0( Word32 L_v3, Word16 v1, Word16 v2 ); /* 32-bit Mac w/o shift 1 */ Word32 L_msu0( Word32 L_v3, Word16 v1, Word16 v2 ); /* 32-bit Msu w/o shift 1 */ -#ifdef BASOP_NOGLOB /* * Overflowing operators @@ -296,7 +216,6 @@ Word32 L_shr_ro( Word32 L_var1, Word16 var2, Flag *Overflow ); Word32 L_macNs_co( Word32 L_var3, Word16 var1, Word16 var2, Flag *Carry, Flag *Overflow ); Word32 L_msuNs_co( Word32 L_var3, Word16 var1, Word16 var2, Flag *Carry, Flag *Overflow ); -#endif /* BASOP_NOGLOB */ /* * Saturating operators diff --git a/lib_com/basop_lsf_tools.c b/lib_com/basop_lsf_tools.c index aac96ae5fc98a6ed855b0d907ae0a3cf8220e037..3e49411d63690ff800c15573e0e7247ab7352ed1 100644 --- a/lib_com/basop_lsf_tools.c +++ b/lib_com/basop_lsf_tools.c @@ -245,9 +245,7 @@ static Word16 E_LPC_f_lsp_pol_get( Word16 Ovf = 0; Word16 Q_out; Word16 m2; -#ifdef BASOP_NOGLOB Flag Overflow; -#endif /* BASOP_NOGLOB */ move16(); // move for Ovf = 0 Q_out = 31 - 23; @@ -302,9 +300,7 @@ static Word16 E_LPC_f_lsp_pol_get( test(); IF( Overflow > 0 && isMODE1 ) { -#ifdef BASOP_NOGLOB assert( 0 ); -#endif /* BASOP_NOGLOB */ /* If an overflow is detected, redo the computation with 1 bit less */ Ovf = add( Ovf, 1 ); Ovf = E_LPC_f_lsp_pol_get( lsp, f, n, Ovf, isMODE1 ); /* Q0 */ diff --git a/lib_com/basop_util.c b/lib_com/basop_util.c index c4f40c6df6080faab71efb203dacdb31e808d86b..19b654e5e07cecc2c85544a6cd708fed1fb1d0a8 100644 --- a/lib_com/basop_util.c +++ b/lib_com/basop_util.c @@ -45,9 +45,6 @@ #include "basop_settings.h" #include "cnst.h" - -#define WMC_TOOL_SKIP - extern const Word32 SqrtTable[32]; // Q31 extern const Word16 SqrtDiffTable[32]; /* Q15 */ @@ -306,11 +303,7 @@ void BASOP_Util_Divide_MantExp( Word16 a_m, /*!< Mantissa of dividend a /* normalize result */ postShift = norm_l( m32 ); -#ifdef BASOP_NOGLOB m = round_fx_o( L_shl( m32, postShift ), &Overflow ); -#else - m = round_fx( L_shl( m32, postShift ) ); -#endif /* exponent */ *ptrResult_e = sub( add( add( a_e, sub( 1, b_e ) ), preShift ), postShift ); @@ -326,9 +319,7 @@ static Word16 Sqrt16_common( Word16 m, Word16 e ) { Word16 index, frac; -#ifdef BASOP_NOGLOB Flag Overflow; -#endif assert( ( m >= 0x4000 ) || ( m == 0 ) ); @@ -344,11 +335,7 @@ static Word16 Sqrt16_common( Word16 m, if ( m != 0 ) { BASOP_SATURATE_WARNING_OFF_EVS; -#ifdef BASOP_NOGLOB m = mac_ro( SqrtTable[index], SqrtDiffTable[index], frac, &Overflow ); -#else - m = mac_r( SqrtTable[index], SqrtDiffTable[index], frac ); -#endif BASOP_SATURATE_WARNING_ON_EVS; } @@ -371,11 +358,7 @@ static Word32 Sqrt32_common( Word32 m, assert( ( m >= 0x40000000 ) || ( m == 0 ) ); -#ifdef BASOP_NOGLOB m16 = round_fx_o( m, &Overflow ); -#else /* BASOP_NOGLOB */ - m16 = round_fx( m ); -#endif /* BASOP_NOGLOB */ /* get table index (upper 6 bits minus 32) */ /* index = (m16 >> 9) - 32; */ @@ -388,11 +371,7 @@ static Word32 Sqrt32_common( Word32 m, if ( m != 0 ) { BASOP_SATURATE_WARNING_OFF_EVS; -#ifdef BASOP_NOGLOB m = L_mac_sat( SqrtTable[index], SqrtDiffTable[index], frac ); -#else - m = L_mac( SqrtTable[index], SqrtDiffTable[index], frac ); -#endif BASOP_SATURATE_WARNING_ON_EVS; } @@ -423,7 +402,9 @@ static Word16 ISqrt16_common( Word16 m, /* handle even exponents */ if ( s_and( e, 1 ) == 0 ) + { m = mult_r( m, 0x5a82 ); + } return m; } @@ -438,8 +419,7 @@ static Word32 ISqrt32_common( Word32 m, #endif assert( m >= 0x40000000 ); - -#ifdef BASOP_NOGLOB +#ifdef BASOP_NOGLOB_DECLARE_LOCAL m16 = round_fx_o( m, &Overflow ); #else m16 = round_fx( m ); @@ -457,7 +437,9 @@ static Word32 ISqrt32_common( Word32 m, /* handle even exponents */ if ( s_and( e, 1 ) == 0 ) + { m = Mpy_32_16_1( m, 0x5a82 ); + } return m; } @@ -676,13 +658,8 @@ void BASOP_Util_Sqrt_InvSqrt_MantExp( Word16 mantissa, /*!< mantissa */ /* interpolate */ BASOP_SATURATE_WARNING_OFF_EVS; -#ifdef BASOP_NOGLOB m = mac_r_sat( SqrtTable[index], SqrtDiffTable[index], frac ); mi = msu_r_sat( ISqrtTable[index], ISqrtDiffTable[index], frac ); -#else - m = mac_r( SqrtTable[index], SqrtDiffTable[index], frac ); - mi = msu_r( ISqrtTable[index], ISqrtDiffTable[index], frac ); -#endif BASOP_SATURATE_WARNING_ON_EVS; /* handle even/odd exponents */ @@ -929,11 +906,7 @@ Word16 divide3232( Word32 L_num, Word32 L_denom ) L_denom = L_shl( L_denom, z ); /* round_fx instead of extract_h improves spectral distortion in E_UTIL_lev_dur (schur version). */ -#ifdef BASOP_NOGLOB z = div_l( L_num, round_fx_o( L_denom, &Overflow ) ); -#else - z = div_l( L_num, round_fx( L_denom ) ); -#endif if ( 0 != sign ) { z = negate( z ); @@ -1436,11 +1409,7 @@ Word16 getCosWord16R2( BASOP_SATURATE_WARNING_OFF sine = negate( sine ); /* Saturation has been included based on the recommendation from the PC group */ -#ifdef BASOP_NOGLOB result = msu_r_sat( L_mult( sine, residual ), cosine, -32768 ); -#else - result = msu_r( L_mult( sine, residual ), cosine, -32768 ); -#endif BASOP_SATURATE_WARNING_ON return result; @@ -1483,11 +1452,7 @@ Word16 getSqrtWord32( Word32 val ) exp = sub( 31 - 32, exp2 ); L_temp = Isqrt_lc( L_temp2, &exp ); /* 12 clks */ -#ifdef BASOP_NOGLOB temp = round_fx_sat( L_temp ); -#else - temp = round_fx( L_temp ); -#endif L_temp = Mpy_32_16_1( L_temp2, temp ); /* 2 clks */ L_temp = L_shl( L_temp, sub( exp, exp2 ) ); @@ -1675,13 +1640,8 @@ Word32 norm_llQ31( /* o : normalized result Q31 */ /* Move MSBit of L_sum into L_c */ Carry = 0; -#ifdef BASOP_NOGLOB L_tmp = L_add_co( L_sum, L_sum, &Carry, &Overflow ); /* L_tmp = L_sum << 1 */ L_c = L_add_co( L_c, L_c, &Carry, &Overflow ); -#else /* BASOP_NOGLOB */ - L_tmp = L_add_c( L_sum, L_sum ); /* L_tmp = L_sum << 1 */ - L_c = L_add_c( L_c, L_c ); -#endif L_add( 0, 0 ); test(); IF( ( L_c != (Word32) 0L ) && ( L_c != (Word32) 0xFFFFFFFFL ) ) @@ -1777,13 +1737,8 @@ Word32 Norm32Norm( const Word32 *x, const Word16 headroom, const Word16 length, if ( L_tmp2 >= 0 ) L_tmp = L_shr( L_tmp, 2 ); -#ifdef BASOP_NOGLOB tmp = round_fx_sat( L_shl_sat( x[i], shift ) ); L_tmp = L_mac0_sat( L_tmp, tmp, tmp ); /* exponent = (1-shift*2) , Q(30+shift*2) */ -#else - tmp = round_fx( L_shl( x[i], shift ) ); - L_tmp = L_mac0( L_tmp, tmp, tmp ); /* exponent = (1-shift*2) , Q(30+shift*2) */ -#endif } move16(); @@ -2217,11 +2172,7 @@ Word16 BASOP_Util_Cmp_Mant32Exp /*!< o: flag: result of comparison */ } BASOP_SATURATE_WARNING_OFF_EVS -#ifdef BASOP_NOGLOB diff_m = L_sub_sat( a_m, b_m ); -#else - diff_m = L_sub( a_m, b_m ); -#endif BASOP_SATURATE_WARNING_ON_EVS diff_e = sub( a_e, b_e ); @@ -2392,11 +2343,7 @@ void bufferCopyFx( { FOR( i = 0; i < length; i++ ) { -#ifdef BASOP_NOGLOB *( dest + i ) = shr_sat( *( src + i ), tmp_16 ); -#else - *( dest + i ) = shr( *( src + i ), tmp_16 ); -#endif move16(); } } @@ -2710,6 +2657,3 @@ cmplx CL_mult_32x16( cmplx input, cmplx_s coeff ) #endif return result; } - - -#undef WMC_TOOL_SKIP diff --git a/lib_com/bitalloc_fx.c b/lib_com/bitalloc_fx.c index 3400b533d9ca4beb7db245b4e4df2ae4d639b7a0..92a8e3928cf25b050ed7cc0a5766181b60f4a66f 100644 --- a/lib_com/bitalloc_fx.c +++ b/lib_com/bitalloc_fx.c @@ -55,11 +55,7 @@ void bitalloc_fx( move16(); FOR( m = 1; m < im; m++ ) { -#ifdef BASOP_NOGLOB v = sub_o( temp, y[m], &Overflow ); /* Q0 */ -#else /* BASOP_NOGLOB */ - v = sub( temp, y[m] ); -#endif temp = s_max( temp, y[m] ); if ( v < 0 ) { @@ -380,11 +376,7 @@ Word16 BitAllocF_fx( exp1 = sub( norm_l( L_tmp1 ), 1 ); exp2 = norm_s( n ); tmp = div_s( extract_h( L_shl( L_tmp1, exp1 ) ), shl( n, exp2 ) ); /*15 + 15 + exp1 - 16 - exp2*/ -#ifdef BASOP_NOGLOB - m_fx = shl_sat( tmp, sub( exp2, exp1 ) ); /*Q14*/ -#else - m_fx = shl( tmp, sub( exp2, exp1 ) ); /*Q14*/ -#endif + m_fx = shl_sat( tmp, sub( exp2, exp1 ) ); /*Q14*/ t_fx = L_deposit_l( 0 ); n = 0; move16(); @@ -451,11 +443,7 @@ Word16 BitAllocF_fx( exp1 = sub( norm_l( L_tmp2 ), 1 ); exp2 = norm_s( n ); tmp = div_s( extract_h( L_shl( L_tmp2, exp1 ) ), shl( n, exp2 ) ); /*15 + 15 + exp1 - 16 - exp2*/ -#ifdef BASOP_NOGLOB - m_fx = shl_o( tmp, sub( exp2, exp1 ), &Overflow ); /*Q14*/ -#else - m_fx = shl( tmp, sub( exp2, exp1 ) ); /*Q14*/ -#endif + m_fx = shl_o( tmp, sub( exp2, exp1 ), &Overflow ); /*Q14*/ if ( L_tmp1 < 0 ) { m_fx = negate( m_fx ); diff --git a/lib_com/bits_alloc_fx.c b/lib_com/bits_alloc_fx.c index 83a98a85f8b00d2bfa36490cd4df6db4f98682d1..f2a074ba52262775d8bd34d2298645746b971661 100644 --- a/lib_com/bits_alloc_fx.c +++ b/lib_com/bits_alloc_fx.c @@ -762,17 +762,20 @@ 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 */ + 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 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 */ @@ -1068,14 +1071,20 @@ ivas_error config_acelp1( { bits = sub( bits, TDM_IC_LSF_PRED_BITS ); } - /* gain Q bit-budget - part 1 */ + /* gain Q bit-budget - part 1: 'Es_pred' of memory-less gain Q */ test(); test(); test(); 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(); @@ -1196,7 +1205,11 @@ 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(); @@ -1414,7 +1427,14 @@ 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++ ) @@ -1478,7 +1498,13 @@ 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++ ) { @@ -1587,7 +1613,12 @@ 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++ ) { @@ -1627,7 +1658,13 @@ 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; @@ -1768,7 +1805,12 @@ 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(); @@ -1877,17 +1919,20 @@ 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 */ + 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 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 */ @@ -2168,8 +2213,13 @@ ivas_error config_acelp1_IVAS( test(); test(); test(); - /* gain Q bit-budget - part 1 */ + /* 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(); @@ -2294,7 +2344,11 @@ 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(); @@ -2510,7 +2564,13 @@ 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++ ) @@ -2574,7 +2634,13 @@ 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++ ) { @@ -2675,7 +2741,12 @@ 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++ ) { @@ -2713,7 +2784,13 @@ 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; @@ -2854,7 +2931,12 @@ 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/cldfb.c b/lib_com/cldfb.c index 5a3d2e1a27b1fd60aba746579f8bc5cee346fe1e..b6eafd993ccf0ed5786ef9c075f171c8c45fad8f 100644 --- a/lib_com/cldfb.c +++ b/lib_com/cldfb.c @@ -1213,7 +1213,7 @@ void cldfbSynthesis_ivas_fx( /*cplxMult(&iBuffer[2*i], &iBuffer[2*i+1],-imagBuffer[k][2*i], imagBuffer[k][M1-1-2*i], rot_vctr_re[i], rot_vctr_im[i]);*/ iBuffer_fx[2 * i] = Msub_32_32( Mpy_32_32( ( L_negate( imagBuffer_fx[k][2 * i] ) ), rot_vctr_re_fx[i] ), imagBuffer_fx[k][( M1 - 1 ) - ( i * 2 )], rot_vctr_im_fx[i] ); // Qx move32(); - iBuffer_fx[2 * i + 1] = Madd_32_32( Mpy_32_32( ( L_negate( imagBuffer_fx[k][2 * i] ) ), rot_vctr_im_fx[i] ), imagBuffer_fx[k][( M1 - 1 ) - ( i * 2 )], rot_vctr_re_fx[i] ); // Qx + iBuffer_fx[2 * i + 1] = Msub_32_32( Mpy_32_32( imagBuffer_fx[k][( M1 - 1 ) - ( i * 2 )], rot_vctr_re_fx[i] ), imagBuffer_fx[k][2 * i], rot_vctr_im_fx[i] ); // Qx move32(); } diff --git a/lib_com/cldfb_evs.c b/lib_com/cldfb_evs.c index 923d2b8873b3f15ed2a49e3371ce98da27b4d4f2..d74b9b64671902f550e2b560d4b3a3992a05ee3e 100644 --- a/lib_com/cldfb_evs.c +++ b/lib_com/cldfb_evs.c @@ -72,7 +72,6 @@ cldfb_init_proto_and_twiddles( HANDLE_CLDFB_FILTER_BANK hs ); iyr = CL_Extract_real( CL_iy ); \ iyi = CL_Extract_imag( CL_iy ); \ rxr += sx, rxi += sx, ixr += sx, ixi += sx, cr += sr, ci += sr -#ifdef BASOP_NOGLOB #define add1( y1, y2, y3, y4, rr12, ri12, ir12, ii12, s ) \ *y1 = round_fx_sat( L_shl_sat( L_negate( L_add_sat( rr12, ii12 ) ), s ) ); \ @@ -88,21 +87,6 @@ cldfb_init_proto_and_twiddles( HANDLE_CLDFB_FILTER_BANK hs ); *y4 = round_fx_sat( L_shl_sat( L_sub_sat( rr12, ii12 ), s ) ); \ y1 += 2, y2 -= 2, y3 -= 2, y4 += 2 -#else -#define add1( y1, y2, y3, y4, rr12, ri12, ir12, ii12, s ) \ - *y1 = round_fx( L_shl( L_negate( L_add( rr12, ii12 ) ), s ) ); \ - *y2 = round_fx( L_shl( L_negate( L_add( ri12, ir12 ) ), s ) ); \ - *y3 = round_fx( L_shl( L_sub( rr12, ii12 ), s ) ); \ - *y4 = round_fx( L_shl( L_sub( ir12, ri12 ), s ) ); \ - y1 += 2, y2 -= 2, y3 -= 2, y4 += 2 - -#define add2( y1, y2, y3, y4, rr12, ri12, ir12, ii12, s ) \ - *y1 = round_fx( L_shl( L_add( ri12, ir12 ), s ) ); \ - *y2 = round_fx( L_shl( L_add( rr12, ii12 ), s ) ); \ - *y3 = round_fx( L_shl( L_sub( ir12, ri12 ), s ) ); \ - *y4 = round_fx( L_shl( L_sub( rr12, ii12 ), s ) ); \ - y1 += 2, y2 -= 2, y3 -= 2, y4 += 2 -#endif #define ptrUpdate16( y11, y12, y13, y14, r11, x11, x12, x13, x14, r12, y21, y22, y23, y24, r21, x21, x22, x23, x24, r22 ) \ y11 += 2 * N8, y12 -= 2 * N8, y13 -= 2 * N8, y14 += 2 * N8, r11 -= 1 * N8; \ @@ -497,11 +481,7 @@ void cldfbAnalysisFiltering( HANDLE_CLDFB_FILTER_BANK cldfbBank, /* move and scale filter states */ FOR( i = 0; i < offset; i++ ) { -#ifdef BASOP_NOGLOB pStates[i] = shl_sat( pStates[i + nSamplesUpd], scale ); // Q(15-(timeIn_e-FilterStates_eg)) -#else - pStates[i] = shl( pStates[i + nSamplesUpd], scale ); -#endif move16(); } @@ -509,11 +489,7 @@ void cldfbAnalysisFiltering( HANDLE_CLDFB_FILTER_BANK cldfbBank, scale = sub( timeIn_e, cldfbBank->FilterStates_eg ); FOR( i = 0; i < nSamples; i++ ) { -#ifdef BASOP_NOGLOB pStates[offset + i] = shl_sat( *timeIn, scale ); // Q(15-scale) -#else - pStates[offset + i] = shl( *timeIn, scale ); -#endif move16(); timeIn = timeIn + stride; } @@ -880,11 +856,7 @@ void cldfbSynthesisFiltering( HANDLE_CLDFB_FILTER_BANK cldfbBank, acc = L_mac( acc, nBuffer[sub( channels1, i )], *pFilterM++ ); BASOP_SATURATE_WARNING_OFF_EVS -#ifdef BASOP_NOGLOB timeOut[( offset1 - i ) * stride] = round_fx_sat( L_shl_sat( acc, outScale ) ); -#else - timeOut[( offset1 - i ) * stride] = round_fx( L_shl( acc, outScale ) ); -#endif BASOP_SATURATE_WARNING_ON_EVS move16(); } @@ -916,11 +888,7 @@ void cldfbSynthesisFiltering( HANDLE_CLDFB_FILTER_BANK cldfbBank, pFilterM++; BASOP_SATURATE_WARNING_OFF_EVS -#ifdef BASOP_NOGLOB timeOut[( offset2 - i ) * stride] = round_fx_sat( L_shl_sat( acc, outScale ) ); -#else - timeOut[( offset2 - i ) * stride] = round_fx( L_shl( acc, outScale ) ); -#endif BASOP_SATURATE_WARNING_ON_EVS move16(); } @@ -1167,13 +1135,8 @@ AnalysisPostSpectrumScaling_Fx( HANDLE_CLDFB_FILTER_BANK cldfbBank, /*!< Handle { FOR( j = 0; j < cldfbBank->no_channels; j++ ) { -#ifdef BASOP_NOGLOB rSubband16[i][j] = round_fx_sat( L_shl_sat( rSubband32[i][j], headRoom ) ); // Q(cldfbSacle_headRoom) iSubband16[i][j] = round_fx_sat( L_shl_sat( iSubband32[i][j], headRoom ) ); // Q(cldfbSacle+headRoom) -#else - rSubband16[i][j] = round_fx( L_shl( rSubband32[i][j], headRoom ) ); - iSubband16[i][j] = round_fx( L_shl( iSubband32[i][j], headRoom ) ); -#endif move16(); move16(); } @@ -1378,11 +1341,7 @@ void GetEnergyCldfb( Word32 *energyLookahead, /*!< o: Q(*sf_energyLookahead) { FOR( j = 20; j < numberBandsM; j++ ) { -#ifdef BASOP_NOGLOB nrg = L_add_o( nrg, L_shr_o( energyValues[k][j], s, &Overflow ), &Overflow ); -#else - nrg = L_add( nrg, L_shr( energyValues[k][j], s ) ); -#endif } } @@ -1405,11 +1364,7 @@ void GetEnergyCldfb( Word32 *energyLookahead, /*!< o: Q(*sf_energyLookahead) { FOR( j = 20; j < numberBandsM; j++ ) { -#ifdef BASOP_NOGLOB nrg = L_add_o( nrg, L_shr_o( energyValues[k][j], s, &Overflow ), &Overflow ); -#else - nrg = L_add( nrg, L_shr( energyValues[k][j], s ) ); -#endif } } @@ -1417,13 +1372,8 @@ void GetEnergyCldfb( Word32 *energyLookahead, /*!< o: Q(*sf_energyLookahead) sm = sub( s_min( s, 44 ), 1 ); BASOP_SATURATE_WARNING_OFF_EVS /* nrg + 6.1e-5f => value 0x40000000, scale 44 */ -#ifdef BASOP_NOGLOB *energyLookahead = L_add_sat( L_shr_sat( nrg, sub( s, sm ) ), L_shr_sat( 0x40000000, s_max( -31, s_min( 31, sub( 44, sm ) ) ) ) ); -#else - *energyLookahead = L_add( L_shr( nrg, sub( s, sm ) ), - L_shr( 0x40000000, s_max( -31, s_min( 31, sub( 44, sm ) ) ) ) ); -#endif move32(); BASOP_SATURATE_WARNING_ON_EVS *sf_energyLookahead = sm; diff --git a/lib_com/cng_exc_fx.c b/lib_com/cng_exc_fx.c index 6ca0d4c3a4dd00bfea52492faa4dcc4ce3de12a7..3eab0b1f5251aef2467b21caed74f9d40672a597 100644 --- a/lib_com/cng_exc_fx.c +++ b/lib_com/cng_exc_fx.c @@ -194,11 +194,7 @@ FOR( i_subfr = 0; i_subfr < L_frame; i_subfr += L_SUBFR ) *------------------------------------------------------------*/ L_tmp = Mult_32_16( *lp_ener, Random( cng_ener_seed ) ); // Q6 L_tmp = Mult_32_16( L_tmp, GAIN_VAR ); // Q6 -#ifdef BASOP_NOGLOB L_tmp = L_add_sat( L_tmp, *lp_ener ); -#else - L_tmp = L_add( L_tmp, *lp_ener ); -#endif L_tmp = L_max( L_tmp, 1 ); /* enr = dot_product( exc2, exc2, L_SUBFR ) + 0.01f */ @@ -234,11 +230,7 @@ FOR( i_subfr = 0; i_subfr < L_frame; i_subfr += L_SUBFR ) { /* exc2[i] *= enr */ L_tmp = L_mult( exc2[i_subfr + i], tmp ); /* Q-4 * Q_exc+19 -> Q_exc +16 */ -#ifdef BASOP_NOGLOB exc2[i_subfr + i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); -#else - exc2[i_subfr + i] = round_fx( L_shl( L_tmp, exp ) ); -#endif move16(); } } @@ -250,11 +242,7 @@ IF( NE_16( Opt_AMR_WB, 1 ) ) exp = norm_l( *Enew ); L_tmp = L_shl( *Enew, exp ); /* Q(exp+6) */ L_tmp = Mult_32_16( L_tmp, shl( L_frame, 5 ) ); /* Q(exp+6+5-15=exp-4) */ -#ifdef BASOP_NOGLOB - L_tmp = L_shr_sat( L_tmp, sub( exp, 10 ) ); /* Q6 */ -#else - L_tmp = L_shr( L_tmp, sub( exp, 10 ) ); /* Q6 */ -#endif + L_tmp = L_shr_sat( L_tmp, sub( exp, 10 ) ); /* Q6 */ exp = norm_l( L_tmp ); fra = Log2_norm_lc( L_shl( L_tmp, exp ) ); exp = sub( sub( 30, exp ), 6 ); @@ -320,19 +308,11 @@ IF( NE_16( Opt_AMR_WB, 1 ) ) FOR( i = 0; i < NUM_ENV_CNG; i++ ) { /* env[i] = 2.0f*(*ptR * *ptR + *ptI * *ptI)/L_FFT; */ - L_tmp = L_mult0( *ptR, *ptR ); /* 2*Q_exc */ -#ifdef BASOP_NOGLOB + L_tmp = L_mult0( *ptR, *ptR ); /* 2*Q_exc */ L_tmp = L_mac0_sat( L_tmp, *ptI, *ptI ); /* 2*Q_exc */ -#else - L_tmp = L_mac0( L_tmp, *ptI, *ptI ); /* 2*Q_exc */ -#endif - L_tmp = L_shr( L_tmp, 1 ); /* 2*Q_exc+6 */ + L_tmp = L_shr( L_tmp, 1 ); /* 2*Q_exc+6 */ tmp = add( Q_exc, Q_exc ); -#ifdef BASOP_NOGLOB env[i] = L_shr_sat( L_tmp, tmp ); -#else - env[i] = L_shr( L_tmp, tmp ); -#endif move32(); /* Q6 */ ptR++; ptI--; @@ -341,13 +321,8 @@ IF( NE_16( Opt_AMR_WB, 1 ) ) FOR( i = 0; i < NUM_ENV_CNG; i++ ) { /* denv[i] = lp_env[i] + 2*(*lp_ener) - env[i]; */ -#ifdef BASOP_NOGLOB L_tmp = L_add_sat( *lp_ener, *lp_ener ); denv[i] = L_sub_sat( L_add_sat( lp_env[i], L_tmp ), env[i] ); -#else - L_tmp = L_add( *lp_ener, *lp_ener ); - denv[i] = L_sub( L_add( lp_env[i], L_tmp ), env[i] ); -#endif move32(); /* Q6 */ if ( denv[i] < 0 ) @@ -384,13 +359,8 @@ IF( NE_16( Opt_AMR_WB, 1 ) ) /* itmp[i] += own_random( cng_ener_seed1 )*denv[i]*0.000011f + denv[i]; */ L_tmp = Mult_32_16( denv[i], Random( cng_ener_seed1 ) ); // Q6 L_tmp = Mult_32_16( L_tmp, GAIN_VAR ); // Q6 -#ifdef BASOP_NOGLOB L_tmp = L_add_sat( L_tmp, denv[i] ); itmp[i] = L_add_sat( L_tmp, itmp[i] ); -#else - L_tmp = L_add( L_tmp, denv[i] ); - itmp[i] = L_add( L_tmp, itmp[i] ); -#endif move32(); /* Q6 */ if ( itmp[i] < 0 ) @@ -427,19 +397,11 @@ IF( NE_16( Opt_AMR_WB, 1 ) ) L_tmp = L_deposit_h( tmp ); L_tmp = Isqrt_lc( L_tmp, &exp ); /*Q(31-exp)*/ - L_tmp2 = Mult_32_16( L_tmp, *ptR ); /*Q(16-exp)*/ -#ifdef BASOP_NOGLOB + L_tmp2 = Mult_32_16( L_tmp, *ptR ); /*Q(16-exp)*/ *ptR = extract_h( L_shl_sat( L_tmp2, add( exp, Q_exc ) ) ); /*Q_exc*/ -#else - *ptR = extract_h( L_shl( L_tmp2, add( exp, Q_exc ) ) ); /*Q_exc*/ -#endif move16(); - L_tmp2 = Mult_32_16( L_tmp, *ptI ); /*Q(16-exp)*/ -#ifdef BASOP_NOGLOB + L_tmp2 = Mult_32_16( L_tmp, *ptI ); /*Q(16-exp)*/ *ptI = extract_h( L_shl_sat( L_tmp2, add( exp, Q_exc ) ) ); /*Q_exc*/ -#else - *ptI = extract_h( L_shl( L_tmp2, add( exp, Q_exc ) ) ); /*Q_exc*/ -#endif move16(); ptR++; ptI--; @@ -518,11 +480,7 @@ IF( NE_16( Opt_AMR_WB, 1 ) ) test(); IF( NE_32( last_core_brate, SID_2k40 ) && NE_32( last_core_brate, SID_1k75 ) && ( last_core_brate != FRAME_NO_DATA ) && EQ_32( core_brate, SID_2k40 ) ) { -#ifdef BASOP_NOGLOB IF( GT_32( L_tmp, L_shl_sat( 1, sub( 31, exp ) ) ) ) -#else - IF( GT_32( L_tmp, L_shl( 1, sub( 31, exp ) ) ) ) -#endif { L_tmp = L_shl( 1, sub( 31, exp ) ); } @@ -542,11 +500,7 @@ IF( NE_16( Opt_AMR_WB, 1 ) ) { /* fft_io[i] = 0.75f*fft_io[i] + exc2[i];*/ tmp = mult( fft_io[i], 24576 /*.75f in Q15*/ ); -#ifdef BASOP_NOGLOB fft_io[i] = add_sat( tmp, exc2[i] ); -#else - fft_io[i] = add( tmp, exc2[i] ); -#endif move16(); /*Q_exc*/ } @@ -561,15 +515,9 @@ IF( NE_16( Opt_AMR_WB, 1 ) ) { L_tmp = L_mult0( *pt_fft_io, *pt_fft_io ); pt_fft_io++; -#ifdef BASOP_NOGLOB L_tmp = L_mac0_sat( L_tmp, *pt_fft_io, *pt_fft_io ); /* 2*(Q_exc) */ pt_fft_io++; L_tmp2 = L_add_sat( L_tmp2, L_shr( L_tmp, 7 ) ); /* 2*(Q_exc)+1, divide by L_frame done here */ -#else - L_tmp = L_mac0( L_tmp, *pt_fft_io, *pt_fft_io ); /* 2*(Q_exc) */ - pt_fft_io++; - L_tmp2 = L_add( L_tmp2, L_shr( L_tmp, 7 ) ); /* 2*(Q_exc)+1, divide by L_frame done here */ -#endif } } ELSE /* L_FRAME16k */ @@ -578,11 +526,7 @@ IF( NE_16( Opt_AMR_WB, 1 ) ) { L_tmp = L_mult0( *pt_fft_io, *pt_fft_io ); pt_fft_io++; -#ifdef BASOP_NOGLOB L_tmp = L_mac0_sat( L_tmp, *pt_fft_io, *pt_fft_io ); /* 2*(Q_exc) */ -#else - L_tmp = L_mac0( L_tmp, *pt_fft_io, *pt_fft_io ); /* 2*(Q_exc) */ -#endif pt_fft_io++; L_tmp2 = L_add( L_tmp2, L_shr( Mult_32_16( L_tmp, 26214 /* 256/320, Q15 */ ), 7 ) ); /* 2*(Q_exc)+15+1-16+1, divide by L_frame done here */ } @@ -614,11 +558,7 @@ IF( NE_16( Opt_AMR_WB, 1 ) ) L_tmp = L_deposit_h( tmp ); L_tmp = Isqrt_lc( L_tmp, &exp ); /*Q(31-exp)*/ -#ifdef BASOP_NOGLOB ftmp = extract_h( L_shl_sat( L_tmp, exp ) ); /* Q15 */ -#else /* BASOP_NOGLOB */ - ftmp = extract_h( L_shl( L_tmp, exp ) ); /* Q15 */ -#endif /* BASOP_NOGLOB */ FOR( i = 0; i < L_frame; i++ ) { /* fft_io[i] *= ftmp;*/ @@ -710,15 +650,9 @@ void cng_params_postupd_fx( FOR( i = 0; i < NUM_ENV_CNG; i++ ) { /* sp[i] = 2.0f*(*ptR * *ptR + *ptI * *ptI)/L_FFT; */ -#ifdef BASOP_NOGLOB L_tmp = L_mult_o( *ptR, *ptR, &Overflow ); /* 2*Q_exc+1 */ L_tmp = L_add_o( L_tmp, L_mult_o( *ptI, *ptI, &Overflow ), &Overflow ); /* 2*Q_exc+1 */ L_tmp = L_add_o( L_tmp, L_tmp, &Overflow ); /* 2*Q_exc+1 */ -#else /* BASOP_NOGLOB */ - L_tmp = L_mult( *ptR, *ptR ); /* 2*Q_exc+1 */ - L_tmp = L_add( L_tmp, L_mult( *ptI, *ptI ) ); /* 2*Q_exc+1 */ - L_tmp = L_add( L_tmp, L_tmp ); /* 2*Q_exc+1 */ -#endif /* BASOP_NOGLOB */ 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 ) ); @@ -835,15 +769,9 @@ void cng_params_postupd_ivas_fx( FOR( i = 0; i < NUM_ENV_CNG; i++ ) { /* sp[i] = 2.0f*(*ptR * *ptR + *ptI * *ptI)/L_FFT; */ -#ifdef BASOP_NOGLOB L_tmp = L_mult_o( *ptR, *ptR, &Overflow ); /* 2*Q_exc+1 */ L_tmp = L_add_o( L_tmp, L_mult_o( *ptI, *ptI, &Overflow ), &Overflow ); /* 2*Q_exc+1 */ L_tmp = L_add_o( L_tmp, L_tmp, &Overflow ); /* 2*Q_exc+1 */ -#else /* BASOP_NOGLOB */ - L_tmp = L_mult( *ptR, *ptR ); /* 2*Q_exc+1 */ - L_tmp = L_add( L_tmp, L_mult( *ptI, *ptI ) ); /* 2*Q_exc+1 */ - L_tmp = L_add( L_tmp, L_tmp ); /* 2*Q_exc+1 */ -#endif /* BASOP_NOGLOB */ L_tmp = Mult_32_16( L_tmp, 128 ); /* 2*Q_exc+1 */ tmp = add( add( Q_exc, Q_exc ), 1 ); // To do : Saturation to be re-validated. @@ -994,17 +922,9 @@ void cng_params_upd_fx( L_tmp = L_mult0( tmpv, tmpv ); /* 2*(Q_exc+scale) */ pt_exc2++; tmpv = shl( *pt_exc2, scale ); -#ifdef BASOP_NOGLOB L_tmp = L_mac0_o( L_tmp, tmpv, tmpv, &Overflow ); -#else - L_tmp = L_mac0( L_tmp, tmpv, tmpv ); -#endif pt_exc2++; -#ifdef BASOP_NOGLOB L_ener = L_add_o( L_ener, L_shr_o( L_tmp, 7, &Overflow ), &Overflow ); /* Q(2*(Q_exc+scale)+1) ,division by L_frame done here */ -#else - L_ener = L_add( L_ener, L_shr( L_tmp, 7 ) ); /* Q(2*(Q_exc+scale)+1) ,division by L_frame done here */ -#endif } } ELSE /* L_FRAME16k */ @@ -1015,24 +935,12 @@ void cng_params_upd_fx( L_tmp = L_mult0( tmpv, tmpv ); /* 2*(Q_exc+scale) */ pt_exc2++; tmpv = shl( *pt_exc2, scale ); -#ifdef BASOP_NOGLOB L_tmp = L_mac0_o( L_tmp, tmpv, tmpv, &Overflow ); -#else - L_tmp = L_mac0( L_tmp, tmpv, tmpv ); -#endif pt_exc2++; -#ifdef BASOP_NOGLOB L_ener = L_add_o( L_ener, L_shr_o( Mult_32_16( L_tmp, 26214 /* 256/320, Q15 */ ), 7, &Overflow ), &Overflow ); /* Q(2*(Q_exc+scale)+15+1-16+1) ,division by L_frame done here */ -#else - L_ener = L_add( L_ener, L_shr( Mult_32_16( L_tmp, 26214 /* 256/320, Q15 */ ), 7 ) ); /* Q(2*(Q_exc+scale)+15+1-16+1) ,division by L_frame done here */ -#endif } } -#ifdef BASOP_NOGLOB L_ener = L_shr_o( L_ener, sub( shl( add( Q_exc, scale ), 1 ), 5 ), &Overflow ); /* Q6 (2*(Q_exc+scale)+1-2*(Q_exc+scale)+5) */ -#else /* BASOP_NOGLOB */ - L_ener = L_shr( L_ener, sub( shl( add( Q_exc, scale ), 1 ), 5 ) ); /* Q6 (2*(Q_exc+scale)+1-2*(Q_exc+scale)+5) */ -#endif /* update the circular buffer of old energies */ ho_ener_circ[*ho_circ_ptr] = L_ener; @@ -1066,16 +974,10 @@ void cng_params_upd_fx( FOR( i = 0; i < NUM_ENV_CNG; i++ ) { /* sp[i] = 2.0f*(*ptR * *ptR + *ptI * *ptI)/L_FFT; */ -#ifdef BASOP_NOGLOB L_tmp = L_mult_o( *ptR, *ptR, &Overflow ); /* 2*Q_exc+1 */ L_tmp = L_add_o( L_tmp, L_mult_o( *ptI, *ptI, &Overflow ), &Overflow ); /* 2*Q_exc+1 */ L_tmp = L_add_o( L_tmp, L_tmp, &Overflow ); /* 2*Q_exc+1 */ -#else - L_tmp = L_mult( *ptR, *ptR ); /* 2*Q_exc+1 */ - L_tmp = L_add( L_tmp, L_mult( *ptI, *ptI ) ); /* 2*Q_exc+1 */ - L_tmp = L_add( L_tmp, L_tmp ); /* 2*Q_exc+1 */ -#endif - L_tmp = Mult_32_16( L_tmp, 128 ); /* 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 ) ); move32(); /* Q6 */ @@ -1207,17 +1109,9 @@ void cng_params_upd_ivas_fx( L_tmp = L_mult0( tmpv, tmpv ); /* 2*(Q_exc+scale) */ pt_exc2++; tmpv = shl( *pt_exc2, scale ); -#ifdef BASOP_NOGLOB L_tmp = L_mac0_o( L_tmp, tmpv, tmpv, &Overflow ); -#else - L_tmp = L_mac0( L_tmp, tmpv, tmpv ); -#endif pt_exc2++; -#ifdef BASOP_NOGLOB L_ener = L_add_o( L_ener, L_shr_o( L_tmp, 7, &Overflow ), &Overflow ); /* Q(2*(Q_exc+scale)+1) ,division by L_frame done here */ -#else - L_ener = L_add( L_ener, L_shr( L_tmp, 7 ) ); /* Q(2*(Q_exc+scale)+1) ,division by L_frame done here */ -#endif } } ELSE /* L_FRAME16k */ @@ -1228,24 +1122,12 @@ void cng_params_upd_ivas_fx( L_tmp = L_mult0( tmpv, tmpv ); /* 2*(Q_exc+scale) */ pt_exc2++; tmpv = shl( *pt_exc2, scale ); -#ifdef BASOP_NOGLOB L_tmp = L_mac0_o( L_tmp, tmpv, tmpv, &Overflow ); -#else - L_tmp = L_mac0( L_tmp, tmpv, tmpv ); -#endif pt_exc2++; -#ifdef BASOP_NOGLOB L_ener = L_add_o( L_ener, L_shr_o( Mult_32_16( L_tmp, 26214 /* 256/320, Q15 */ ), 7, &Overflow ), &Overflow ); /* Q(2*(Q_exc+scale)+15+1-16+1) ,division by L_frame done here */ -#else - L_ener = L_add( L_ener, L_shr( Mult_32_16( L_tmp, 26214 /* 256/320, Q15 */ ), 7 ) ); /* Q(2*(Q_exc+scale)+15+1-16+1) ,division by L_frame done here */ -#endif } } -#ifdef BASOP_NOGLOB L_ener = L_shr_o( L_ener, sub( shl( add( Q_exc, scale ), 1 ), 5 ), &Overflow ); /* Q6 (2*(Q_exc+scale)+1-2*(Q_exc+scale)+5) */ -#else /* BASOP_NOGLOB */ - L_ener = L_shr( L_ener, sub( shl( add( Q_exc, scale ), 1 ), 5 ) ); /* Q6 (2*(Q_exc+scale)+1-2*(Q_exc+scale)+5) */ -#endif /* update the circular buffer of old energies */ ho_ener_circ[*ho_circ_ptr] = L_ener; @@ -1279,16 +1161,10 @@ void cng_params_upd_ivas_fx( FOR( i = 0; i < NUM_ENV_CNG; i++ ) { /* sp[i] = 2.0f*(*ptR * *ptR + *ptI * *ptI)/L_FFT; */ -#ifdef BASOP_NOGLOB L_tmp = L_mult_o( *ptR, *ptR, &Overflow ); /* 2*Q_exc+1 */ L_tmp = L_add_o( L_tmp, L_mult_o( *ptI, *ptI, &Overflow ), &Overflow ); /* 2*Q_exc+1 */ L_tmp = L_add_o( L_tmp, L_tmp, &Overflow ); /* 2*Q_exc+1 */ -#else - L_tmp = L_mult( *ptR, *ptR ); /* 2*Q_exc+1 */ - L_tmp = L_add( L_tmp, L_mult( *ptI, *ptI ) ); /* 2*Q_exc+1 */ - L_tmp = L_add( L_tmp, L_tmp ); /* 2*Q_exc+1 */ -#endif - L_tmp = Mult_32_16( L_tmp, 128 ); /* 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 ) ); move32(); /* Q6 */ diff --git a/lib_com/cnst.h b/lib_com/cnst.h index fe16db670a45815e431324c572e699d454512c4a..a5030ac9c98bb3bf1f430798afe117443c43918a 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -137,6 +137,7 @@ #define FOUR_IN_Q28 1073741824 #define MAX_WORD16 32767 +#define ONE_IN_Q45 (Word64)0x200000000000 #define ONE_IN_Q62 (Word64)0x4000000000000000 /*----------------------------------------------------------------------------------* * General constants @@ -190,8 +191,14 @@ #define FORCE_MUSIC 101 /* debugging - force music on the command line */ #define FORCE_ACELP 102 /* debugging - force ACELP core on the command line */ #define FORCE_GSC 103 /* debugging - force GSC core on the command line */ +#ifdef SUPPORT_FORCE_TCX10_TCX20 +#define FORCE_TCX10 104 /* debugging - force TCX10 core on the command line */ +#define FORCE_TCX20 105 /* debugging - force TCX20 core on the command line */ +#define FORCE_HQ 106 /* debugging - force HQ core on the command line */ +#else #define FORCE_TCX 104 /* debugging - force TCX core on the command line */ #define FORCE_HQ 105 /* debugging - force HQ core on the command line */ +#endif #define FORCE_TD_RENDERER 201 #define FORCE_CLDFB_RENDERER 202 #endif @@ -754,6 +761,8 @@ enum #define FORMANT_SHARPENING_NOISE_THRESHOLD 21.0f /* lp_noise level above which formant sharpening is deactivated */ #define E_MIN_FX 1 /* QSCALE (Q7)*/ #define E_MIN_IVAS_FX 1835 /* (Q19) (E12) */ +#define E_MIN_IVAS_FX_Q31 7516193 /* (Q31) (0.0035f) */ + #define STEP_DELTA_FX 11 #define FORMANT_SHARPENING_NOISE_THRESHOLD_FX 5376 /* 21 (!8)lp_noise level above which formant sharpening is deactivated - at this level most of 20 dB SNR office noisy speech still uses sharpening */ @@ -1224,6 +1233,7 @@ enum #define SPC 0.0234952f #define SPC_plus SPC * 1.001f #define ALPHA_SQ ( ( 0.5f / PI2 ) * ( 0.5f / PI2 ) ) +#define ALPHA_SQ_Q30 (6799549) /* ( ( 0.5f / PI2 ) * ( 0.5f / PI2 ) ) in Q30 */ #define NC M / 2 #define LSF_GAP 50.0f diff --git a/lib_com/codec_tcx_common.c b/lib_com/codec_tcx_common.c index 85e353d597392ef3eee1c7bdb521b4dc803b53ab..f6da34b5583d96ee20611780db70092f10014bfa 100644 --- a/lib_com/codec_tcx_common.c +++ b/lib_com/codec_tcx_common.c @@ -40,11 +40,7 @@ Word16 tcxGetNoiseFillingTilt( Copy_Scale_sig( A, As, add( lpcorder, 1 ), sub( norm_s( A[0] ), 2 ) ); // Q(12) tmp = get_gain( As + 1, As, lpcorder ); BASOP_SATURATE_WARNING_OFF_EVS; -#ifdef BASOP_NOGLOB *noiseTiltFactor = add_sat( round_fx_sat( L_shl_sat( tmp, 15 ) ), 3072 /*0.09375f Q15*/ ); -#else - *noiseTiltFactor = add( round_fx( L_shl( tmp, 15 ) ), 3072 /*0.09375f Q15*/ ); -#endif move16(); BASOP_SATURATE_WARNING_ON_EVS; } @@ -144,11 +140,7 @@ void tcxFormantEnhancement( { fac = add( fac0, mult( d, extract_l( L_mult0( j, inv_int[n] ) ) ) ); BASOP_SATURATE_WARNING_OFF_EVS; -#ifdef BASOP_NOGLOB xn_buf[l + j] = s_min( xn_one, shl_o( mult( xn_buf[l + j], fac ), fac_e, &Overflow ) ); -#else - xn_buf[l + j] = s_min( xn_one, shl( mult( xn_buf[l + j], fac ), fac_e ) ); -#endif move16(); BASOP_SATURATE_WARNING_ON_EVS; } @@ -193,11 +185,7 @@ void tcxFormantEnhancement( { fac = add( fac0, mult( d, extract_l( L_mult0( j, inv_int[n] ) ) ) ); BASOP_SATURATE_WARNING_OFF_EVS; -#ifdef BASOP_NOGLOB xn_buf[l + j] = s_min( xn_one, shl_sat( mult( xn_buf[l + j], fac ), fac_e ) ); -#else - xn_buf[l + j] = s_min( xn_one, shl( mult( xn_buf[l + j], fac ), fac_e ) ); -#endif move16(); BASOP_SATURATE_WARNING_ON_EVS; } @@ -322,11 +310,7 @@ void tcxFormantEnhancement_with_shift( { fac = add( fac0, mult( d, extract_l( L_mult0( j, inv_int[n] ) ) ) ); BASOP_SATURATE_WARNING_OFF_EVS; -#ifdef BASOP_NOGLOB xn_buf[l + j] = s_min( xn_one, shl_o( mult( xn_buf[l + j], fac ), fac_e, &Overflow ) ); -#else - xn_buf[l + j] = s_min( xn_one, shl( mult( xn_buf[l + j], fac ), fac_e ) ); -#endif move16(); BASOP_SATURATE_WARNING_ON_EVS; } @@ -371,11 +355,7 @@ void tcxFormantEnhancement_with_shift( { fac = add( fac0, mult( d, extract_l( L_mult0( j, inv_int[n] ) ) ) ); BASOP_SATURATE_WARNING_OFF_EVS; -#ifdef BASOP_NOGLOB xn_buf[l + j] = s_min( xn_one, shl_o( mult( xn_buf[l + j], fac ), fac_e, &Overflow ) ); -#else - xn_buf[l + j] = s_min( xn_one, shl( mult( xn_buf[l + j], fac ), fac_e ) ); -#endif move16(); BASOP_SATURATE_WARNING_ON_EVS; } diff --git a/lib_com/deemph.c b/lib_com/deemph.c index 3f60bf44c1128c4812b7e266914009f5f2d05ee0..8cddd75804b1f8f78ee8e8cf01853cb42dce8350 100644 --- a/lib_com/deemph.c +++ b/lib_com/deemph.c @@ -103,26 +103,16 @@ void deemph_fx( move32(); #endif - L_tmp = L_deposit_h( signal[0] ); /*Qx+16*/ -#ifdef BASOP_NOGLOB + L_tmp = L_deposit_h( signal[0] ); /*Qx+16*/ L_tmp = L_mac_o( L_tmp, *mem, mu, &Overflow ); /*Qx+16*/ signal[0] = round_fx_o( L_tmp, &Overflow ); /*Qx*/ -#else - L_tmp = L_mac( L_tmp, *mem, mu ); - signal[0] = round_fx( L_tmp ); -#endif move16(); FOR( i = 1; i < L; i++ ) { - L_tmp = L_deposit_h( signal[i] ); /*Qx+16*/ -#ifdef BASOP_NOGLOB + L_tmp = L_deposit_h( signal[i] ); /*Qx+16*/ L_tmp = L_mac_o( L_tmp, signal[i - 1], mu, &Overflow ); /*Qx+16*/ signal[i] = round_fx_o( L_tmp, &Overflow ); /*Qx*/ -#else /* BASOP_NOGLOB */ - L_tmp = L_mac( L_tmp, signal[i - 1], mu ); - signal[i] = round_fx( L_tmp ); -#endif /* BASOP_NOGLOB */ move16(); } @@ -158,12 +148,8 @@ void Deemph2( FOR( i = 1; i < L; i++ ) { - L_tmp = L_mult( x[i], 16384 /*0.5f in Q15*/ ); /*Qx+16*/ -#ifdef BASOP_NOGLOB + L_tmp = L_mult( x[i], 16384 /*0.5f in Q15*/ ); /*Qx+16*/ x[i] = mac_ro( L_tmp, x[i - 1], mu, &Overflow ); /*Qx-1*/ -#else - x[i] = mac_r( L_tmp, x[i - 1], mu ); -#endif move16(); } @@ -206,13 +192,8 @@ void E_UTIL_deemph2( Word16 shift, Word16 *x, const Word16 mu, const Word16 L, W shift = shr( -32768, shift ); /*Q15 - shift*/ FOR( i = 0; i < L; i++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_msu_o( Mpy_32_16_1( L_tmp, mu ), x[i], shift, &Overflow ); /*Qx-shift+16*/ x[i] = round_fx_o( L_tmp, &Overflow ); /*Qx-shift*/ -#else - L_tmp = L_msu( Mpy_32_16_1( L_tmp, mu ), x[i], shift ); - x[i] = round_fx( L_tmp ); -#endif move16(); } } @@ -220,13 +201,8 @@ void E_UTIL_deemph2( Word16 shift, Word16 *x, const Word16 mu, const Word16 L, W { FOR( i = 0; i < L; i++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_msu_o( Mpy_32_16_1( L_tmp, mu ), shr_o( x[i], shift, &Overflow ), -32768 /*1.0f in Q15*/, &Overflow ); /*Qx-shift+16*/ x[i] = round_fx_o( L_tmp, &Overflow ); /*Qx-shift*/ -#else /* BASOP_NOGLOB */ - L_tmp = L_msu( Mpy_32_16_1( L_tmp, mu ), shr( x[i], shift ), -32768 ); - x[i] = round_fx( L_tmp ); -#endif move16(); } } diff --git a/lib_com/disclaimer.c b/lib_com/disclaimer.c index 58452de2447869a116d61e533e9e34f78194e82a..44fc3627aa5b1b590b6711ae385fe04a0ee7e2e9 100644 --- a/lib_com/disclaimer.c +++ b/lib_com/disclaimer.c @@ -44,7 +44,11 @@ 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 301b666660a15d1530083c6acffda04ee43247dd..8d77da13a7eb7df052bb309302e7f19bdef81432 100644 --- a/lib_com/edct_fx.c +++ b/lib_com/edct_fx.c @@ -457,23 +457,13 @@ void edct_16fx( { i2 = shl( i, 1 ); - L_tmp = L_mult( x[i2], edct_table[i] ); /*Q(Qx+16) */ -#ifdef BASOP_NOGLOB + L_tmp = L_mult( x[i2], edct_table[i] ); /*Q(Qx+16) */ Lacc = L_mac_o( L_tmp, *px, *pt, &Overflow ); /*Q(Qx+16) */ re2[i] = round_fx_o( L_shl_o( Lacc, Q_edct, &Overflow ), &Overflow ); /* Q(Qx+Q_edct) */ -#else - Lacc = L_mac( L_tmp, *px, *pt ); /*Q(Qx+16) */ - re2[i] = round_fx( L_shl( Lacc, Q_edct ) ); /* Q(Qx+Q_edct) */ -#endif move16(); - L_tmp = L_mult( *px, edct_table[i] ); /*Q(Qx+16) */ -#ifdef BASOP_NOGLOB + L_tmp = L_mult( *px, edct_table[i] ); /*Q(Qx+16) */ Lacc = L_msu_o( L_tmp, x[i2], *pt, &Overflow ); /*Q(Qx+16) */ im2[i] = round_fx_o( L_shl_o( Lacc, Q_edct, &Overflow ), &Overflow ); /* Q(Qx+Q_edct) */ -#else - Lacc = L_msu( L_tmp, x[i2], *pt ); /*Q(Qx+16) */ - im2[i] = round_fx( L_shl( Lacc, Q_edct ) ); /* Q(Qx+Q_edct) */ -#endif move16(); px -= 2; pt--; @@ -498,23 +488,13 @@ void edct_16fx( fact = round_fx( L_shl( L_tmp, 2 ) ); /*Q15 */ FOR( i = 0; i < shr( length, 1 ); i++ ) { - tmp = mult_r( im2[i], fact ); /*Q(Qx+Q_edct) */ -#ifdef BASOP_NOGLOB + tmp = mult_r( im2[i], fact ); /*Q(Qx+Q_edct) */ re[i] = sub_o( re2[i], tmp, &Overflow ); /*Q(Qx+Q_edct) */ move16(); -#else - re[i] = sub( re2[i], tmp ); /*Q(Qx+Q_edct) */ - move16(); -#endif - tmp = mult_r( re2[i], fact ); /*Q(Qx+Q_edct) */ -#ifdef BASOP_NOGLOB + tmp = mult_r( re2[i], fact ); /*Q(Qx+Q_edct) */ im[i] = add_o( im2[i], tmp, &Overflow ); /*Q(Qx+Q_edct) */ move16(); -#else - im[i] = add( im2[i], tmp ); /*Q(Qx+Q_edct) */ - move16(); -#endif } /* Post-rotate and obtain the output data */ @@ -524,23 +504,14 @@ void edct_16fx( { i2 = shl( i, 1 ); - L_tmp = L_mult( re[i], edct_table[i] ); /*Q(Qx+Q_edct+16) */ -#ifdef BASOP_NOGLOB + L_tmp = L_mult( re[i], edct_table[i] ); /*Q(Qx+Q_edct+16) */ Lacc = L_mac_o( L_tmp, im[i], *pt, &Overflow ); /*Q(Qx+Q_edct+16) */ y[i2] = round_fx_o( L_shr_o( Lacc, Q_edct, &Overflow ), &Overflow ); /* Q(Qx) */ -#else /* BASOP_NOGLOB */ - Lacc = L_mac( L_tmp, im[i], *pt ); /*Q(Qx+Q_edct+16) */ - y[i2] = round_fx( L_shr( Lacc, Q_edct ) ); /* Q(Qx) */ -#endif /* BASOP_NOGLOB */ move16(); L_tmp = L_mult( re[i], edct_table[sub( shr( length, 1 ), add( 1, i ) )] ); /*Q(Qx+Q_edct+16) */ Lacc = L_msu( L_tmp, im[i], edct_table[i] ); /*Q(Qx+Q_edct+16) */ -#ifdef BASOP_NOGLOB - *py = round_fx_o( L_shr_o( Lacc, Q_edct, &Overflow ), &Overflow ); /* Q(Qx) */ -#else /* BASOP_NOGLOB */ - *py = round_fx( L_shr( Lacc, Q_edct ) ); /* Q(Qx) */ -#endif + *py = round_fx_o( L_shr_o( Lacc, Q_edct, &Overflow ), &Overflow ); /* Q(Qx) */ move16(); py -= 2; diff --git a/lib_com/enh1632.c b/lib_com/enh1632.c index 04c22ae97c40afa265e386e9fc2f3e268ef10795..bac18231eed2314f224537ba36dbb19baf08f159 100644 --- a/lib_com/enh1632.c +++ b/lib_com/enh1632.c @@ -376,21 +376,13 @@ Word32 L_lshr( Word32 L_var1, Word16 var2 ) * the range : 0xffff 8000 <= var_out <= 0x0000 7fff. * *****************************************************************************/ -#ifdef BASOP_NOGLOB Word16 shl_ro( Word16 var1, Word16 var2, Flag *Overflow ) -#else -Word16 shl_r( Word16 var1, Word16 var2 ) -#endif { Word16 var_out; if ( var2 >= 0 ) { -#ifdef BASOP_NOGLOB var_out = shl_o( var1, var2, Overflow ); -#else - var_out = shl( var1, var2 ); -#endif #ifdef WMOPS multiCounter[currCounter].shl--; #endif /* ifdef WMOPS */ @@ -398,11 +390,7 @@ Word16 shl_r( Word16 var1, Word16 var2 ) else { var2 = -var2; -#ifdef BASOP_NOGLOB var_out = shr_ro( var1, var2, Overflow ); -#else - var_out = shr_r( var1, var2 ); -#endif #ifdef WMOPS multiCounter[currCounter].shr_r--; #endif /* ifdef WMOPS */ @@ -414,12 +402,10 @@ Word16 shl_r( Word16 var1, Word16 var2 ) return ( var_out ); } -#ifdef BASOP_NOGLOB Word16 shl_r( Word16 var1, Word16 var2 ) { return shl_ro( var1, var2, NULL ); } -#endif /***************************************************************************** * * Function Name : L_shl_r diff --git a/lib_com/enh1632.h b/lib_com/enh1632.h index eed55ccad44963372710d7919bbb3e9f13eed012..10c10866ae65e278c1b159c4be3273bcb76fbdf3 100644 --- a/lib_com/enh1632.h +++ b/lib_com/enh1632.h @@ -40,9 +40,7 @@ * Prototypes for enhanced 16/32 bit arithmetic operators * *****************************************************************************/ -#ifdef BASOP_NOGLOB Word16 shl_ro( Word16 var1, Word16 var2, Flag *Overflow ); -#endif Word16 shl_r( Word16 var1, Word16 var2 ); Word32 L_shl_r( Word32 L_var1, Word16 var2 ); diff --git a/lib_com/enh32.c b/lib_com/enh32.c index 64afe89869987ec7073e0cdef0dfe2965f57926f..cf40bbec972f96c6858e957dfe8509f9907b4e40 100644 --- a/lib_com/enh32.c +++ b/lib_com/enh32.c @@ -76,11 +76,7 @@ Word32 Mpy_32_32( Word32 L_var1, Word32 L_var2 ) #endif L64_var1 = ( (Word64) L_var1 * L_var2 ); -#ifdef BASOP_NOGLOB L64_var1 = W_shl_o( L64_var1, 1, &Overflow ); -#else /* BASOP_NOGLOB */ - L64_var1 = W_shl( L64_var1, 1 ); -#endif /* BASOP_NOGLOB */ L_var_out = W_extract_h( L64_var1 ); #ifdef WMOPS multiCounter[currCounter].Mpy_32_32++; @@ -114,11 +110,7 @@ Word32 Madd_32_16( Word32 L_var3, Word32 L_var1, Word16 var2 ) #endif L_var_out = Mpy_32_16_1( L_var1, var2 ); -#ifdef BASOP_NOGLOB L_var_out = L_add_o( L_var3, L_var_out, &Overflow ); -#else /* BASOP_NOGLOB */ - L_var_out = L_add( L_var3, L_var_out ); -#endif /* BASOP_NOGLOB */ #ifdef WMOPS multiCounter[currCounter].Mpy_32_16_1--; @@ -151,11 +143,7 @@ Word32 Msub_32_16( Word32 L_var3, Word32 L_var1, Word16 var2 ) #endif L_var_out = Mpy_32_16_1( L_var1, var2 ); -#ifdef BASOP_NOGLOB L_var_out = L_sub_o( L_var3, L_var_out, &Overflow ); -#else /* BASOP_NOGLOB */ - L_var_out = L_sub( L_var3, L_var_out ); -#endif #ifdef WMOPS multiCounter[currCounter].Mpy_32_16_1--; diff --git a/lib_com/enh40.c b/lib_com/enh40.c index 929e3a950652d6fd12162aadbaa2e7a3c2ffdb57..89960030f0bbe25c1f2bfa2623d8b858e4d17b54 100644 --- a/lib_com/enh40.c +++ b/lib_com/enh40.c @@ -96,9 +96,7 @@ #include #include #include "stl.h" -#ifdef BASOP_NOGLOB #include -#endif /* BASOP_NOGLOB */ #define WMC_TOOL_SKIP @@ -160,11 +158,7 @@ * the range : MIN_40 <= L40_var_out <= MAX_40. * *****************************************************************************/ -#ifndef BASOP_NOGLOB -Word40 L40_shl( Word40 L40_var1, Word16 var2 ) -#else /* BASOP_NOGLOB */ Word40 L40_shl_o( Word40 L40_var1, Word16 var2, Flag *Overflow ) -#endif /* BASOP_NOGLOB */ { Word40 L40_var_out; @@ -194,27 +188,15 @@ Word40 L40_shl_o( Word40 L40_var1, Word16 var2, Flag *Overflow ) if ( L40_var_out > 0x003fffffffffLL ) #endif { -#ifndef BASOP_NOGLOB - Overflow = 1; - exit( 1 ); - /* L40_var_out = L40_OVERFLOW_OCCURED( L40_var_out); */ -#else /* BASOP_NOGLOB */ *Overflow = 1; L40_var_out = MAX_40; -#endif /* BASOP_NOGLOB */ break; } else if ( L40_var_out < L40_constant ) { -#ifndef BASOP_NOGLOB - Overflow = 1; - exit( 2 ); - /* L40_var_out = L40_UNDERFLOW_OCCURED( L40_var_out); */ -#else /* BASOP_NOGLOB */ *Overflow = 1; L40_var_out = MIN_40; -#endif /* BASOP_NOGLOB */ break; } @@ -234,7 +216,6 @@ Word40 L40_shl_o( Word40 L40_var1, Word16 var2, Flag *Overflow ) return ( L40_var_out ); } -#ifdef BASOP_NOGLOB Word40 L40_shl( Word40 L40_var1, Word16 var2 ) { @@ -293,7 +274,6 @@ Word40 L40_shl( Word40 L40_var1, Word16 var2 ) return ( L40_var_out ); } -#endif /* BASOP_NOGLOB */ /***************************************************************************** * @@ -422,7 +402,6 @@ Word40 L40_negate( Word40 L40_var1 ) * the range : MIN_40 <= L40_var_out <= MAX_40. * *****************************************************************************/ -#ifdef BASOP_NOGLOB Word40 L40_add_o( Word40 L40_var1, Word40 L40_var2, Flag *Overflow ) { @@ -465,7 +444,6 @@ Word40 L40_add_o( Word40 L40_var1, Word40 L40_var2, Flag *Overflow ) return ( L40_var_out ); } -#endif /* BASOP_NOGLOB */ Word40 L40_add( Word40 L40_var1, Word40 L40_var2 ) { Word40 L40_var_out; @@ -475,48 +453,24 @@ Word40 L40_add( Word40 L40_var1, Word40 L40_var2 ) #if defined( _MSC_VER ) && ( _MSC_VER <= 1200 ) if ( ( ( ( L40_var1 & 0x8000000000 ) >> 39 ) != 0 ) && ( ( ( L40_var2 & 0x8000000000 ) >> 39 ) != 0 ) && ( ( ( L40_var_out & 0x8000000000 ) >> 39 ) == 0 ) ) { -#ifndef BASOP_NOGLOB - Overflow = 1; - exit( 2 ); - /* L40_var_out = L40_UNDERFLOW_OCCURED( L40_var_out); */ -#else /* BASOP_NOGLOB */ assert( 0 ); L40_var_out = MIN_40; -#endif /* BASOP_NOGLOB */ } else if ( ( ( ( L40_var1 & 0x8000000000 ) >> 39 ) == 0 ) && ( ( ( L40_var2 & 0x8000000000 ) >> 39 ) == 0 ) && ( ( ( L40_var_out & 0x8000000000 ) >> 39 ) != 0 ) ) { -#ifndef BASOP_NOGLOB - Overflow = 1; - exit( 1 ); - /* L40_var_out = L40_OVERFLOW_OCCURED( L40_var_out); */ -#else /* BASOP_NOGLOB */ assert( 0 ); L40_var_out = MAX_40; -#endif /* BASOP_NOGLOB */ } #else if ( ( ( ( L40_var1 & 0x8000000000LL ) >> 39 ) != 0 ) && ( ( ( L40_var2 & 0x8000000000LL ) >> 39 ) != 0 ) && ( ( ( L40_var_out & 0x8000000000LL ) >> 39 ) == 0 ) ) { -#ifndef BASOP_NOGLOB - Overflow = 1; - exit( 2 ); - /* L40_var_out = L40_UNDERFLOW_OCCURED( L40_var_out); */ -#else /* BASOP_NOGLOB */ assert( 0 ); L40_var_out = MIN_40; -#endif /* BASOP_NOGLOB */ } else if ( ( ( ( L40_var1 & 0x8000000000LL ) >> 39 ) == 0 ) && ( ( ( L40_var2 & 0x8000000000LL ) >> 39 ) == 0 ) && ( ( ( L40_var_out & 0x8000000000LL ) >> 39 ) != 0 ) ) { -#ifndef BASOP_NOGLOB - Overflow = 1; - exit( 1 ); - /* L40_var_out = L40_OVERFLOW_OCCURED( L40_var_out); */ -#else /* BASOP_NOGLOB */ assert( 0 ); L40_var_out = MAX_40; -#endif /* BASOP_NOGLOB */ } #endif @@ -561,11 +515,7 @@ Word40 L40_add( Word40 L40_var1, Word40 L40_var2 ) * the range : MIN_40 <= L40_var_out <= MAX_40. * *****************************************************************************/ -#ifndef BASOP_NOGLOB -Word40 L40_sub( Word40 L40_var1, Word40 L40_var2 ) -#else /* BASOP_NOGLOB */ Word40 L40_sub_o( Word40 L40_var1, Word40 L40_var2, Flag *Overflow ) -#endif /* BASOP_NOGLOB */ { Word40 L40_var_out; @@ -574,48 +524,24 @@ Word40 L40_sub_o( Word40 L40_var1, Word40 L40_var2, Flag *Overflow ) #if defined( _MSC_VER ) && ( _MSC_VER <= 1200 ) if ( ( ( ( L40_var1 & 0x8000000000 ) >> 39 ) != 0 ) && ( ( ( L40_var2 & 0x8000000000 ) >> 39 ) == 0 ) && ( ( ( L40_var_out & 0x8000000000 ) >> 39 ) == 0 ) ) { -#ifndef BASOP_NOGLOB - Overflow = 1; - exit( 2 ); - /* L40_var_out = L40_UNDERFLOW_OCCURED( L40_var_out); */ -#else /* BASOP_NOGLOB */ *Overflow = 1; L40_var_out = MIN_40; -#endif /* BASOP_NOGLOB */ } else if ( ( ( ( L40_var1 & 0x8000000000 ) >> 39 ) == 0 ) && ( ( ( L40_var2 & 0x8000000000 ) >> 39 ) != 0 ) && ( ( ( L40_var_out & 0x8000000000 ) >> 39 ) != 0 ) ) { -#ifndef BASOP_NOGLOB - Overflow = 1; - exit( 1 ); - /* L40_var_out = L40_OVERFLOW_OCCURED( L40_var_out); */ -#else /* BASOP_NOGLOB */ *Overflow = 1; L40_var_out = MAX_40; -#endif /* BASOP_NOGLOB */ } #else if ( ( ( ( L40_var1 & 0x8000000000LL ) >> 39 ) != 0 ) && ( ( ( L40_var2 & 0x8000000000LL ) >> 39 ) == 0 ) && ( ( ( L40_var_out & 0x8000000000LL ) >> 39 ) == 0 ) ) { -#ifndef BASOP_NOGLOB - Overflow = 1; - exit( 2 ); - /* L40_var_out = L40_UNDERFLOW_OCCURED( L40_var_out); */ -#else /* BASOP_NOGLOB */ *Overflow = 1; L40_var_out = MIN_40; -#endif /* BASOP_NOGLOB */ } else if ( ( ( ( L40_var1 & 0x8000000000LL ) >> 39 ) == 0 ) && ( ( ( L40_var2 & 0x8000000000LL ) >> 39 ) != 0 ) && ( ( ( L40_var_out & 0x8000000000LL ) >> 39 ) != 0 ) ) { -#ifndef BASOP_NOGLOB - Overflow = 1; - exit( 1 ); - /* L40_var_out = L40_OVERFLOW_OCCURED( L40_var_out); */ -#else /* BASOP_NOGLOB */ *Overflow = 1; L40_var_out = MAX_40; -#endif /* BASOP_NOGLOB */ } #endif @@ -629,7 +555,6 @@ Word40 L40_sub_o( Word40 L40_var1, Word40 L40_var2, Flag *Overflow ) return ( L40_var_out ); } -#ifdef BASOP_NOGLOB Word40 L40_sub( Word40 L40_var1, Word40 L40_var2 ) { Word40 L40_var_out; @@ -669,7 +594,6 @@ Word40 L40_sub( Word40 L40_var1, Word40 L40_var2 ) return ( L40_var_out ); } -#endif /* BASOP_NOGLOB */ /***************************************************************************** * @@ -838,12 +762,8 @@ Word40 L40_min( Word40 L40_var1, Word40 L40_var2 ) * the range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. * *****************************************************************************/ -#ifndef BASOP_NOGLOB -Word32 L_saturate40( Word40 L40_var1 ) -#else /* BASOP_NOGLOB */ Word32 L_saturate40_o( Word40 L40_var1, Flag *Overflow ) -#endif /* BASOP_NOGLOB */ { Word32 L_var_out; @@ -853,21 +773,13 @@ Word32 L_saturate40_o( Word40 L40_var1, Flag *Overflow ) if ( L40_var1 < UNDER_L40_var2 ) { L40_var1 = UNDER_L40_var2; -#ifndef BASOP_NOGLOB - Overflow = 1; -#else /* BASOP_NOGLOB */ *Overflow = 1; -#endif /* BASOP_NOGLOB */ } if ( L40_var1 > OVER_L40_var2 ) { L40_var1 = OVER_L40_var2; -#ifndef BASOP_NOGLOB - Overflow = 1; -#else /* BASOP_NOGLOB */ *Overflow = 1; -#endif /* BASOP_NOGLOB */ } L_var_out = L_Extract40( L40_var1 ); @@ -882,7 +794,6 @@ Word32 L_saturate40_o( Word40 L40_var1, Flag *Overflow ) return ( L_var_out ); } -#ifdef BASOP_NOGLOB Word32 L_saturate40( Word40 L40_var1 ) { Word32 L_var_out; @@ -913,7 +824,6 @@ Word32 L_saturate40( Word40 L40_var1 ) return ( L_var_out ); } -#endif /* BASOP_NOGLOB */ /***************************************************************************** * diff --git a/lib_com/enh40.h b/lib_com/enh40.h index ca78cb33e757efa0b842cccef662c45d1d96fa50..ff1a86b92a75af311f77dda943af271a548a507c 100644 --- a/lib_com/enh40.h +++ b/lib_com/enh40.h @@ -56,10 +56,8 @@ #include "stl.h" -#if defined( BASOP_NOGLOB ) || defined( _MSC_VER ) #define MAX_40 ( 0x0000007fffffffff ) #define MIN_40 ( 0xffffff8000000000 ) -#endif #define L40_OVERFLOW_OCCURED( L40_var1 ) ( Overflow = 1, exit( 1 ), L40_var1 ) #define L40_UNDERFLOW_OCCURED( L40_var1 ) ( Overflow = 1, exit( 2 ), L40_var1 ) @@ -111,7 +109,6 @@ Word40 L40_max( Word40 L40_var1, Word40 L40_var2 ); Word40 L40_min( Word40 L40_var1, Word40 L40_var2 ); Word32 L_saturate40( Word40 L40_var1 ); Word16 norm_L40( Word40 L40_var1 ); -#ifdef BASOP_NOGLOB /* * Overflowing operators */ @@ -119,7 +116,6 @@ Word40 L40_shl_o( Word40 L40_var1, Word16 var2, Flag *Overflow ); Word40 L40_add_o( Word40 L40_var1, Word40 L40_var2, Flag *Overflow ); Word40 L40_sub_o( Word40 L40_var1, Word40 L40_var2, Flag *Overflow ); Word32 L_saturate40_o( Word40 L40_var1, Flag *Overflow ); -#endif /* BASOP_NOGLOB */ /*#ifdef _MSC_VER*/ static __inline Word40 L40_set( Word40 L40_var1 ) { diff --git a/lib_com/enh64.c b/lib_com/enh64.c index 9eb58c4d399848547a585ff714a0f212adecad7d..8bffb620cc8dfb0b2164e718b83fa365fb048430 100644 --- a/lib_com/enh64.c +++ b/lib_com/enh64.c @@ -161,11 +161,7 @@ Word64 W_sub_nosat( Word64 L64_var1, Word64 L64_var2 ) | range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | |___________________________________________________________________________| */ -#ifdef BASOP_NOGLOB Word64 W_shl_o( Word64 L64_var1, Word16 var2, Flag *Overflow ) -#else /* BASOP_NOGLOB */ -Word64 W_shl( Word64 L64_var1, Word16 var2 ) -#endif /* BASOP_NOGLOB */ { Word64 L64_var_out = 0LL; @@ -183,11 +179,7 @@ Word64 W_shl( Word64 L64_var1, Word16 var2 ) { if ( L64_var1 > (Word64) 0X3fffffffffffffffLL ) { -#ifdef BASOP_NOGLOB set_overflow( Overflow ); -#else /* BASOP_NOGLOB */ - Overflow = 1; -#endif /* BASOP_NOGLOB */ L64_var_out = (Word64) 0X7fffffffffffffffLL; break; } @@ -195,11 +187,7 @@ Word64 W_shl( Word64 L64_var1, Word16 var2 ) { if ( L64_var1 < (Word64) 0xc000000000000000LL ) { -#ifdef BASOP_NOGLOB set_overflow( Overflow ); -#else /* BASOP_NOGLOB */ - Overflow = 1; -#endif /* BASOP_NOGLOB */ L64_var_out = (Word64) 0x8000000000000000LL; break; } @@ -217,12 +205,10 @@ Word64 W_shl( Word64 L64_var1, Word16 var2 ) return ( L64_var_out ); } -#ifdef BASOP_NOGLOB Word64 W_shl( Word64 L64_var1, Word16 var2 ) { return W_shl_o( L64_var1, var2, NULL ); } -#endif /* BASOP_NOGLOB */ /*___________________________________________________________________________ @@ -1185,11 +1171,7 @@ Word32 W_shl_sat_l( Word64 L64_var, Word16 n ) | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. | |__________________________________________________________________________________| */ -#ifdef BASOP_NOGLOB Word32 W_round48_L_o( Word64 L64_var1, Flag *Overflow ) -#else /* BASOP_NOGLOB */ -Word32 W_round48_L( Word64 L64_var1 ) -#endif /* BASOP_NOGLOB */ { Word64 L64_var_out; Word32 L_result; @@ -1207,11 +1189,7 @@ Word32 W_round48_L( Word64 L64_var1 ) if ( ( L64_var_out ^ L64_var1 ) & L64_MIN ) { L64_var_out = ( L64_var1 < 0 ) ? L64_MIN : L64_MAX; -#ifdef BASOP_NOGLOB set_overflow( Overflow ); -#else /* BASOP_NOGLOB */ - Overflow = 1; -#endif /* BASOP_NOGLOB */ } } L_result = W_extract_h( L64_var_out ); @@ -1224,12 +1202,10 @@ Word32 W_round48_L( Word64 L64_var1 ) return ( L_result ); } -#ifdef BASOP_NOGLOB Word32 W_round48_L( Word64 L64_var1 ) { return W_round48_L_o( L64_var1, NULL ); } -#endif /* BASOP_NOGLOB */ /*__________________________________________________________________________________ | | @@ -1258,11 +1234,7 @@ Word32 W_round48_L( Word64 L64_var1 ) | range : 0xffff 8000 <= var_out <= 0x0000 7fff. | |__________________________________________________________________________________| */ -#ifdef BASOP_NOGLOB Word16 W_round32_s_o( Word64 L64_var1, Flag *Overflow ) -#else /* BASOP_NOGLOB */ -Word16 W_round32_s( Word64 L64_var1 ) -#endif /* BASOP_NOGLOB */ { Word64 L64_var_out; Word32 L_var; @@ -1281,11 +1253,7 @@ Word16 W_round32_s( Word64 L64_var1 ) if ( ( L64_var_out ^ L64_var1 ) & L64_MIN ) { L64_var_out = ( L64_var1 < 0 ) ? L64_MIN : L64_MAX; -#ifdef BASOP_NOGLOB set_overflow( Overflow ); -#else /* BASOP_NOGLOB */ - Overflow = 1; -#endif /* BASOP_NOGLOB */ } } L_var = W_extract_h( L64_var_out ); @@ -1300,12 +1268,10 @@ Word16 W_round32_s( Word64 L64_var1 ) return ( var_out ); } -#ifdef BASOP_NOGLOB Word16 W_round32_s( Word64 L64_var1 ) { return W_round32_s_o( L64_var1, NULL ); } -#endif /* BASOP_NOGLOB */ /*___________________________________________________________________________ | | @@ -1398,11 +1364,7 @@ Word16 W_norm( Word64 L64_var1 ) | range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | |_______________________________________________________________________________| */ -#ifdef BASOP_NOGLOB Word64 W_add_o( Word64 L64_var1, Word64 L64_var2, Flag *Overflow ) -#else /* BASOP_NOGLOB */ -Word64 W_add( Word64 L64_var1, Word64 L64_var2 ) -#endif /* BASOP_NOGLOB */ { Word64 L64_var_out; @@ -1413,11 +1375,7 @@ Word64 W_add( Word64 L64_var1, Word64 L64_var2 ) if ( ( L64_var_out ^ L64_var1 ) & MIN_64 ) { L64_var_out = ( L64_var1 < 0 ) ? MIN_64 : MAX_64; -#ifdef BASOP_NOGLOB set_overflow( Overflow ); -#else /* BASOP_NOGLOB */ - Overflow = 1; -#endif /* BASOP_NOGLOB */ } } @@ -1427,12 +1385,10 @@ Word64 W_add( Word64 L64_var1, Word64 L64_var2 ) return L64_var_out; } -#ifdef BASOP_NOGLOB Word64 W_add( Word64 L64_var1, Word64 L64_var2 ) { return W_add_o( L64_var1, L64_var2, NULL ); } -#endif /* BASOP_NOGLOB */ /*______________________________________________________________________________ | | @@ -1465,11 +1421,7 @@ Word64 W_add( Word64 L64_var1, Word64 L64_var2 ) | range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | |_______________________________________________________________________________| */ -#ifdef BASOP_NOGLOB Word64 W_sub_o( Word64 L64_var1, Word64 L64_var2, Flag *Overflow ) -#else /* BASOP_NOGLOB */ -Word64 W_sub( Word64 L64_var1, Word64 L64_var2 ) -#endif /* BASOP_NOGLOB */ { Word64 L64_var_out; @@ -1480,11 +1432,7 @@ Word64 W_sub( Word64 L64_var1, Word64 L64_var2 ) if ( ( L64_var_out ^ L64_var1 ) & MIN_64 ) { L64_var_out = ( L64_var1 < 0 ) ? MIN_64 : MAX_64; -#ifdef BASOP_NOGLOB set_overflow( Overflow ); -#else /* BASOP_NOGLOB */ - Overflow = 1; -#endif /* BASOP_NOGLOB */ } } @@ -1494,12 +1442,10 @@ Word64 W_sub( Word64 L64_var1, Word64 L64_var2 ) return L64_var_out; } -#ifdef BASOP_NOGLOB Word64 W_sub( Word64 L64_var1, Word64 L64_var2 ) { return W_sub_o( L64_var1, L64_var2, NULL ); } -#endif /* BASOP_NOGLOB */ /*______________________________________________________________________________ @@ -1529,22 +1475,14 @@ Word64 W_sub( Word64 L64_var1, Word64 L64_var2 ) | range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | |_______________________________________________________________________________| */ -#ifdef BASOP_NOGLOB Word64 W_neg_o( Word64 L64_var1, Flag *Overflow ) -#else /* BASOP_NOGLOB */ -Word64 W_neg( Word64 L64_var1 ) -#endif /* BASOP_NOGLOB */ { Word64 L64_var_out; if ( L64_var1 == MIN_64 ) { L64_var_out = MAX_64; -#ifdef BASOP_NOGLOB set_overflow( Overflow ); -#else /* BASOP_NOGLOB */ - Overflow = 1; -#endif /* BASOP_NOGLOB */ } else { @@ -1558,12 +1496,10 @@ Word64 W_neg( Word64 L64_var1 ) return ( L64_var_out ); } -#ifdef BASOP_NOGLOB Word64 W_neg( Word64 L64_var1 ) { return W_neg_o( L64_var1, NULL ); } -#endif /* BASOP_NOGLOB */ /*___________________________________________________________________________ @@ -1593,22 +1529,14 @@ Word64 W_neg( Word64 L64_var1 ) | range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | |___________________________________________________________________________| */ -#ifdef BASOP_NOGLOB Word64 W_abs_o( Word64 L64_var1, Flag *Overflow ) -#else /* BASOP_NOGLOB */ -Word64 W_abs( Word64 L64_var1 ) -#endif /* BASOP_NOGLOB */ { Word64 L64_var_out; if ( L64_var1 == MIN_64 ) { L64_var_out = MAX_64; -#ifdef BASOP_NOGLOB set_overflow( Overflow ); -#else /* BASOP_NOGLOB */ - Overflow = 1; -#endif /* BASOP_NOGLOB */ } else { @@ -1629,12 +1557,10 @@ Word64 W_abs( Word64 L64_var1 ) return ( L64_var_out ); } -#ifdef BASOP_NOGLOB Word64 W_abs( Word64 L64_var1 ) { return W_abs_o( L64_var1, NULL ); } -#endif /* BASOP_NOGLOB */ /*_________________________________________________________________________________________________ | | @@ -1668,22 +1594,14 @@ Word64 W_abs( Word64 L64_var1 ) | range : 0x80000000 00000000LL <= L64_var_out <= 0x7fffffff ffffffffLL. | |_________________________________________________________________________________________________| */ -#ifdef BASOP_NOGLOB Word64 W_mult_32_32_o( Word32 L_var1, Word32 L_var2, Flag *Overflow ) -#else /* BASOP_NOGLOB */ -Word64 W_mult_32_32( Word32 L_var1, Word32 L_var2 ) -#endif /* BASOP_NOGLOB */ { Word64 L64_var_out; if ( ( L_var1 == MIN_32 ) && ( L_var2 == MIN_32 ) ) { L64_var_out = MAX_64; -#ifdef BASOP_NOGLOB set_overflow( Overflow ); -#else /* BASOP_NOGLOB */ - Overflow = 1; -#endif /* BASOP_NOGLOB */ } else { @@ -1696,12 +1614,10 @@ Word64 W_mult_32_32( Word32 L_var1, Word32 L_var2 ) return L64_var_out; } -#ifdef BASOP_NOGLOB Word64 W_mult_32_32( Word32 L_var1, Word32 L_var2 ) { return W_mult_32_32_o( L_var1, L_var2, NULL ); } -#endif /* BASOP_NOGLOB */ /*_________________________________________________________________________________________________ | | diff --git a/lib_com/enh64.h b/lib_com/enh64.h index 8aed870a67e0688ab7e3398caa7f7aa040f186b0..c3896bb0d257aa053df48da5c84948b8255e0401 100644 --- a/lib_com/enh64.h +++ b/lib_com/enh64.h @@ -65,7 +65,6 @@ UWord64 W_lshl( UWord64 L64_var1, Word16 var2 ); UWord64 W_lshr( UWord64 L64_var1, Word16 var2 ); Word32 W_round64_L( Word64 L64_var1 ); -#ifdef BASOP_NOGLOB /* * Overflowing operators */ @@ -77,7 +76,6 @@ Word64 W_sub_o( Word64 L64_var1, Word64 L64_var2, Flag *Overflow ); Word64 W_neg_o( Word64 L64_var1, Flag *Overflow ); Word64 W_abs_o( Word64 L64_var1, Flag *Overflow ); Word64 W_mult_32_32_o( Word32 L_var1, Word32 L_var2, Flag *Overflow ); -#endif /* BASOP_NOGLOB */ #endif /* #ifdef ENH_64_BIT_OPERATOR */ diff --git a/lib_com/enhancer_fx.c b/lib_com/enhancer_fx.c index 88bc7049710728f6e8e47966219719ddc606e6e0..7df474a5d6ab88a9f6ca0ae8f706f590ae0affe7 100644 --- a/lib_com/enhancer_fx.c +++ b/lib_com/enhancer_fx.c @@ -137,11 +137,7 @@ void enhancer_fx( *-----------------------------------------------------------*/ /* tmp = 0.5f * (1.0f - voice_fac) */ -#ifdef BASOP_NOGLOB tmp = msu_r_sat( 0x40000000 /*0.5.Q31*/, voice_fac, 16384 /*0.5.Q15*/ ); /*Q15 */ /* 1=unvoiced, 0=voiced */ -#else - tmp = msu_r( 0x40000000, voice_fac, 16384 ); /*Q15 */ /* 1=unvoiced, 0=voiced */ -#endif /* fac = stab_fac * tmp */ fac = mult( stab_fac, tmp ); /*Q15*/ @@ -193,11 +189,7 @@ void enhancer_fx( test(); IF( Opt_AMR_WB && ( EQ_32( core_brate, ACELP_8k85 ) || EQ_32( core_brate, ACELP_6k60 ) ) ) { -#ifdef BASOP_NOGLOB pit_sharp = shl_sat( gain_pit, 1 ); /* saturation can occur here Q14 -> Q15 */ -#else - pit_sharp = shl( gain_pit, 1 ); /* saturation can occur here Q14 -> Q15 */ -#endif /* saturation takes care of "if (pit_sharp > 1.0) { pit_sharp=1.0; }" */ IF( GT_16( pit_sharp, 16384 /*0.5.Q15*/ ) ) { @@ -232,45 +224,27 @@ void enhancer_fx( /* pt_exc2[0] += code[0] - tmp * code[1] */ L_tmp = L_deposit_h( code[0] ); /* if Enc :Q9 * Q15 -> Q25 */ L_tmp = L_msu( L_tmp, code[1], tmp ); /* Q12 * Q15 -> Q28 */ -#ifdef BASOP_NOGLOB L_tmp = L_shl_sat( L_mult( gain_code_hi, extract_h( L_tmp ) ), sc ); pt_exc2[0] = msu_r_sat( L_tmp, -32768, pt_exc2[0] ); move16(); -#else - L_tmp = L_shl( L_mult( gain_code_hi, extract_h( L_tmp ) ), sc ); - pt_exc2[0] = msu_r( L_tmp, -32768, pt_exc2[0] ); - move16(); -#endif FOR( i = 1; i < L_SUBFR - 1; i++ ) { /* pt_exc2[i] += code[i] - tmp * code[i-1] - tmp * code[i+1] */ L_tmp = L_msu( -32768, code[i], -32768 ); L_tmp = L_msu( L_tmp, code[i + 1], tmp ); -#ifdef BASOP_NOGLOB tmp16 = msu_r_sat( L_tmp, code[i - 1], tmp ); L_tmp = L_shl_sat( L_mult( gain_code_hi, tmp16 ), sc ); pt_exc2[i] = msu_r_sat( L_tmp, -32768, pt_exc2[i] ); move16(); -#else - tmp16 = msu_r( L_tmp, code[i - 1], tmp ); - L_tmp = L_shl( L_mult( gain_code_hi, tmp16 ), sc ); - pt_exc2[i] = msu_r( L_tmp, -32768, pt_exc2[i] ); - move16(); /* in Q_exc */ -#endif } /* pt_exc2[L_SUBFR-1] += code[L_SUBFR-1] - tmp * code[L_SUBFR-2] */ L_tmp = L_deposit_h( code[L_SUBFR - 1] ); /*Q28 */ L_tmp = L_msu( L_tmp, code[L_SUBFR - 2], tmp ); /*Q28 */ L_tmp = L_shl( L_mult( gain_code_hi, extract_h( L_tmp ) ), sc ); -#ifdef BASOP_NOGLOB pt_exc2[L_SUBFR - 1] = msu_r_sat( L_tmp, -32768, pt_exc2[L_SUBFR - 1] ); move16(); -#else - pt_exc2[L_SUBFR - 1] = msu_r( L_tmp, -32768, pt_exc2[L_SUBFR - 1] ); - move16(); -#endif test(); test(); IF( Opt_AMR_WB && ( EQ_32( core_brate, ACELP_8k85 ) || EQ_32( core_brate, ACELP_6k60 ) ) ) @@ -280,11 +254,7 @@ void enhancer_fx( FOR( i = 0; i < L_SUBFR; i++ ) { /* excp[i] += pt_exc2[i] */ -#ifdef BASOP_NOGLOB excp[i] = add_sat( excp[i], pt_exc2[i] ); -#else - excp[i] = add( excp[i], pt_exc2[i] ); -#endif move16(); } agc2_fx( pt_exc2, excp, L_SUBFR ); @@ -440,11 +410,7 @@ void enhancer_ivas_fx( *-----------------------------------------------------------*/ /* tmp = 0.5f * (1.0f - voice_fac) */ -#ifdef BASOP_NOGLOB tmp = msu_r_sat( 0x40000000 /*0.5.Q31*/, voice_fac, 16384 /*0.5.Q14*/ ); /*Q15 */ /* 1=unvoiced, 0=voiced */ -#else - tmp = msu_r( 0x40000000, voice_fac, 16384 ); /*Q15 */ /* 1=unvoiced, 0=voiced */ -#endif /* fac = stab_fac * tmp */ fac = mult( stab_fac, tmp ); /*Q15*/ @@ -496,11 +462,7 @@ void enhancer_ivas_fx( test(); IF( Opt_AMR_WB && ( EQ_32( core_brate, ACELP_8k85 ) || EQ_32( core_brate, ACELP_6k60 ) ) ) { -#ifdef BASOP_NOGLOB pit_sharp = shl_sat( gain_pit, 1 ); /* saturation can occur here Q14 -> Q15 */ -#else - pit_sharp = shl( gain_pit, 1 ); /* saturation can occur here Q14 -> Q15 */ -#endif /* saturation takes care of "if (pit_sharp > 1.0) { pit_sharp=1.0; }" */ IF( GT_16( pit_sharp, 16384 /*0.5.Q15*/ ) ) { @@ -546,11 +508,7 @@ void enhancer_ivas_fx( L_tmp = L_msu( L_tmp, code[i + 1], tmp ); tmp16 = msu_r( L_tmp, code[i - 1], tmp ); L_tmp = L_shl( L_mult( gain_code_hi, tmp16 ), sc ); -#ifdef BASOP_NOGLOB pt_exc2[i] = msu_r_sat( L_tmp, -32768, pt_exc2[i] ); -#else - pt_exc2[i] = msu_r( L_tmp, -32768, pt_exc2[i] ); -#endif move16(); /* in Q_exc */ } @@ -661,11 +619,7 @@ void enhancer_ivas_fx2( *-----------------------------------------------------------*/ /* tmp = 0.5f * (1.0f - voice_fac) */ -#ifdef BASOP_NOGLOB tmp = msu_r_sat( 0x40000000 /*0.5.Q31*/, voice_fac, 16384 /*0.5.Q15*/ ); /*Q15 */ /* 1=unvoiced, 0=voiced */ -#else - tmp = msu_r( 0x40000000, voice_fac, 16384 ); /*Q15 */ /* 1=unvoiced, 0=voiced */ -#endif /* fac = stab_fac * tmp */ fac = mult( stab_fac, tmp ); /*Q15*/ @@ -717,11 +671,7 @@ void enhancer_ivas_fx2( test(); IF( Opt_AMR_WB && ( EQ_32( core_brate, ACELP_8k85 ) || EQ_32( core_brate, ACELP_6k60 ) ) ) { -#ifdef BASOP_NOGLOB pit_sharp = shl_sat( gain_pit, 1 ); /* saturation can occur here Q14 -> Q15 */ -#else - pit_sharp = shl( gain_pit, 1 ); /* saturation can occur here Q14 -> Q15 */ -#endif /* saturation takes care of "if (pit_sharp > 1.0) { pit_sharp=1.0; }" */ IF( GT_16( pit_sharp, 16384 /*0.5.Q15*/ ) ) { @@ -788,11 +738,7 @@ void enhancer_ivas_fx2( FOR( i = 0; i < L_SUBFR; i++ ) { /* excp[i] += pt_exc2[i] */ -#ifdef BASOP_NOGLOB excp[i] = add_sat( excp[i], pt_exc2[i] ); -#else - excp[i] = add( excp[i], pt_exc2[i] ); -#endif move16(); } agc2_fx( pt_exc2, excp, L_SUBFR ); @@ -877,11 +823,7 @@ Word16 E_UTIL_enhancer( /* if gain_code is computed function of energy, noise enhancer is by-passed.*/ BASOP_SATURATE_WARNING_OFF_EVS -#ifdef BASOP_NOGLOB tmp = msu_r_sat( 1073741824l /*0.5f Q31*/, 16384 /*0.5f Q15*/, voice_fac ); /* 1=unvoiced, 0=voiced */ -#else /* BASOP_NOGLOB */ - tmp = msu_r( 1073741824l /*0.5f Q31*/, 16384 /*0.5f Q15*/, voice_fac ); /* 1=unvoiced, 0=voiced */ -#endif BASOP_SATURATE_WARNING_ON_EVS fac = mult_r( stab_fac, tmp ); /* fac in Q15 */ @@ -912,13 +854,8 @@ Word16 E_UTIL_enhancer( /* exponent of code: 31-16 + 15-11 - tmp + code_exp */ code_exp = sub( add( 31 - 16 + 15 - 11, code_exp ), tmp ); -#ifdef BASOP_NOGLOB L_tmp = L_shl_sat( L_tmp, tmp ); gain = round_fx_sat( L_tmp ); -#else - L_tmp = L_shl( L_tmp, tmp ); - gain = round_fx( L_tmp ); -#endif FOR( i = 0; i < L_subfr; i++ ) { @@ -948,24 +885,15 @@ Word16 E_UTIL_enhancer( L_tmp = L_msu0( L_tmp, tmp, code[1] ); IF( gain ) { -#ifdef BASOP_NOGLOB L_tmp = L_shl_sat( L_tmp, gain ); -#else - L_tmp = L_shl( L_tmp, gain ); -#endif } -#ifdef BASOP_NOGLOB exc2[0] = msu_r_sat( L_tmp, -32768, exc2[0] ); -#else - exc2[0] = msu_r( L_tmp, -32768, exc2[0] ); -#endif move16(); FOR( i = 1; i < L_subfr - 1; i++ ) { /* exc2[i] = exc2[i] + code[i] - tmp*(code[i+1]+code[i-1]); */ L_tmp = L_mult( code[i], 16384 ); -#ifdef BASOP_NOGLOB L_tmp = L_msu0_sat( L_tmp, tmp, code[i - 1] ); L_tmp = L_msu0_sat( L_tmp, tmp, code[i + 1] ); IF( gain ) @@ -973,34 +901,16 @@ Word16 E_UTIL_enhancer( L_tmp = L_shl_sat( L_tmp, gain ); } exc2[i] = msu_r_sat( L_tmp, -32768, exc2[i] ); -#else - L_tmp = L_msu0( L_tmp, tmp, code[i - 1] ); - L_tmp = L_msu0( L_tmp, tmp, code[i + 1] ); - if ( gain ) - { - L_tmp = L_shl( L_tmp, gain ); - } - exc2[i] = msu_r( L_tmp, -32768, exc2[i] ); -#endif move16(); } /* exc2[L_subfr-1] = exc2[L_subfr-1] + code[L_subfr-1] - tmp*code[L_subfr-2]; */ L_tmp = L_mult( code[i], 16384 ); -#ifdef BASOP_NOGLOB L_tmp = L_msu0_sat( L_tmp, tmp, code[i - 1] ); IF( gain ) { L_tmp = L_shl_sat( L_tmp, gain ); } exc2[i] = msu_r_sat( L_tmp, -32768, exc2[i] ); -#else - L_tmp = L_msu0( L_tmp, tmp, code[i - 1] ); - if ( gain ) - { - L_tmp = L_shl( L_tmp, gain ); - } - exc2[i] = msu_r( L_tmp, -32768, exc2[i] ); -#endif move16(); return code_exp; @@ -1079,11 +989,7 @@ static void phase_dispersion_fx( prev_gain_pit[0] = gain_pit; move16(); -#ifdef BASOP_NOGLOB IF( GT_32( L_sub_sat( gain_code, *prev_gain_code ), L_shl_sat( *prev_gain_code, 1 ) ) ) -#else - IF( GT_32( L_sub( gain_code, *prev_gain_code ), L_shl( *prev_gain_code, 1 ) ) ) -#endif { state = s_min( add( state, 1 ), 2 ); } @@ -1208,11 +1114,7 @@ static void agc2_fx( FOR( i = 1; i < l_trm; i++ ) { temp = shr( sig_out[i], 2 ); -#ifdef BASOP_NOGLOB s = L_mac0_sat( s, temp, temp ); -#else - s = L_mac0( s, temp, temp ); -#endif } IF( s != 0 ) { @@ -1225,11 +1127,7 @@ static void agc2_fx( FOR( i = 1; i < l_trm; i++ ) { temp = shr( sig_in[i], 2 ); -#ifdef BASOP_NOGLOB s = L_mac0_sat( s, temp, temp ); -#else - s = L_mac0( s, temp, temp ); -#endif } g0 = 0; @@ -1237,11 +1135,7 @@ static void agc2_fx( IF( s != 0 ) { i = norm_l( s ); -#ifdef BASOP_NOGLOB gain_in = round_fx_sat( L_shl_sat( s, i ) ); -#else - gain_in = round_fx( L_shl( s, i ) ); -#endif exp = sub( exp, i ); /*---------------------------------------------------* @@ -1251,21 +1145,13 @@ static void agc2_fx( s = L_shr( s, exp ); /* add exponent */ s = Isqrt( s ); -#ifdef BASOP_NOGLOB g0 = round_fx_sat( L_shl_sat( s, 9 ) ); -#else - g0 = round_fx( L_shl( s, 9 ) ); -#endif } /* sig_out(n) = gain(n) sig_out(n) */ FOR( i = 0; i < l_trm; i++ ) { -#ifdef BASOP_NOGLOB sig_out[i] = round_fx_sat( L_shl_sat( L_mac( -8192, sig_out[i], g0 ), 2 ) ); -#else - sig_out[i] = round_fx( L_shl( L_mac( -8192, sig_out[i], g0 ), 2 ) ); -#endif move16(); } } diff --git a/lib_com/enr_1_az.c b/lib_com/enr_1_az.c index 8bc24ddbedd500b2b50d451125cf677c19801305..e11a500dbfda62e276c962e873780bb769d8ee0b 100644 --- a/lib_com/enr_1_az.c +++ b/lib_com/enr_1_az.c @@ -42,18 +42,11 @@ #include "prot_fx.h" -#ifdef BASOP_NOGLOB Word16 Enr_1_Az_fx_o( /* o : impulse response energy Q3 */ const Word16 Aq[], /* i : LP filter coefs Qx based on the fact that Aq[0] == 1.0 */ const Word16 len, /* i : impulse response length Q0 */ Flag *Overflow_out /* o : propagating the Overflow flag to upper level */ ) -#else -Word16 Enr_1_Az_fx( /* o : impulse response energy Q3 */ - const Word16 Aq[], /* i : LP filter coefs Qx based on the fact that Aq[0] == 1.0 */ - const Word16 len /* i : impulse response length Q0 */ -) -#endif { Word16 h1[2 * L_SUBFR]; Word16 *y; @@ -94,23 +87,13 @@ Word16 Enr_1_Az_fx( /* o : impulse response energy Q3 L_tmp = L_msu( 0, Aq[1], y[-1] ); FOR( j = 2; j <= i; j++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_msu_o( L_tmp, Aq[j], y[-j], &Overflow ); -#else - L_tmp = L_msu( L_tmp, Aq[j], y[-j] ); -#endif } -#ifdef BASOP_NOGLOB L_tmp = L_shl_o( L_tmp, q, &Overflow ); *y = round_fx_o( L_tmp, &Overflow ); move16(); L_tmp2 = L_mac_o( L_tmp2, *y, *y, &Overflow ); -#else - L_tmp = L_shl( L_tmp, q ); - *y = round_fx( L_tmp ); - L_tmp2 = L_mac( L_tmp2, *y, *y ); -#endif y++; } /* Normal Filtering */ @@ -119,34 +102,19 @@ Word16 Enr_1_Az_fx( /* o : impulse response energy Q3 L_tmp = L_msu( 0, Aq[1], y[-1] ); FOR( j = 2; j <= M; j++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_msu_o( L_tmp, Aq[j], y[-j], &Overflow ); -#else - L_tmp = L_msu( L_tmp, Aq[j], y[-j] ); -#endif } -#ifdef BASOP_NOGLOB L_tmp = L_shl_o( L_tmp, q, &Overflow ); *y = round_fx_o( L_tmp, &Overflow ); move16(); L_tmp2 = L_mac_o( L_tmp2, *y, *y, &Overflow ); -#else - L_tmp = L_shl( L_tmp, q ); - *y = round_fx( L_tmp ); - L_tmp2 = L_mac( L_tmp2, *y, *y ); -#endif y++; } -#ifdef BASOP_NOGLOB *Overflow_out = Overflow; move32(); return round_fx_o( L_tmp2, Overflow_out ); /* Q19 to Q3 */ -#else - return round_fx( L_tmp2 ); /* Q19 to Q3 */ -#endif } -#ifdef BASOP_NOGLOB Word16 Enr_1_Az_fx( /* o : impulse response energy Q3 */ const Word16 Aq[], /* i : LP filter coefs Qx based on the fact that Aq[0] == 1.0 */ const Word16 len /* i : impulse response length Q0 */ @@ -156,4 +124,3 @@ Word16 Enr_1_Az_fx( /* o : impulse response energy Q3 move32(); return Enr_1_Az_fx_o( Aq, len, &Overflow ); } -#endif diff --git a/lib_com/env_adj.c b/lib_com/env_adj.c index d0e3877ded0f17a6edf0d832cd140b69df105e8e..554cf1dbe79d63b81c06842dcce05477f06f539a 100644 --- a/lib_com/env_adj.c +++ b/lib_com/env_adj.c @@ -145,12 +145,8 @@ void env_adj_fx( IF( EQ_16( att_state, 1 ) ) /* End of attenuation region found */ { /* tmp = min(1, max(0, len-ENV_ADJ_START)*(1.0f/ENV_ADJ_INCL)); */ -#ifdef BASOP_NOGLOB tmp = round_fx_sat( L_shl_sat( L_mult0( s_max( 0, sub( len, ENV_ADJ_START_FX ) ), ENV_ADJ_INV_INCL_FX ), 16 ) ); /* Q15 (15+16-16) */ -#else - tmp = round_fx( L_shl( L_mult0( s_max( 0, sub( len, ENV_ADJ_START_FX ) ), ENV_ADJ_INV_INCL_FX ), 16 ) ); /* Q15 (15+16-16) */ -#endif - tmp_diff = sub( MAX_16, tmp ); /* Q15 */ + tmp_diff = sub( MAX_16, tmp ); /* Q15 */ FOR( j = start; j < i; j++ ) { /* adj[j] = max(tmp + (1-tmp)*adj[j],env_stab); */ @@ -192,12 +188,8 @@ void env_adj_fx( IF( EQ_16( att_state, 1 ) ) { /* tmp = min(1, max(0, len-ENV_ADJ_START)*(1.0f/ENV_ADJ_INCL)); */ -#ifdef BASOP_NOGLOB tmp = round_fx_sat( L_shl_sat( L_mult0( s_max( 0, sub( len, ENV_ADJ_START_FX ) ), ENV_ADJ_INV_INCL_FX ), 16 ) ); /* Q15 (15+16-16) */ -#else - tmp = round_fx( L_shl( L_mult0( s_max( 0, sub( len, ENV_ADJ_START_FX ) ), ENV_ADJ_INV_INCL_FX ), 16 ) ); /* Q15 (15+16-16) */ -#endif - tmp_diff = sub( MAX_16, tmp ); /* Q15 */ + tmp_diff = sub( MAX_16, tmp ); /* Q15 */ move16(); FOR( j = start; j < i; j++ ) { diff --git a/lib_com/env_stab.c b/lib_com/env_stab.c index 0a04508b6c22a7d255e3a1c8bfdf6309efe4db5a..be19b55e0a8eeebcc091e4422beb4bb5a3df0323 100644 --- a/lib_com/env_stab.c +++ b/lib_com/env_stab.c @@ -88,11 +88,7 @@ Word16 env_stability_fx( /* in Q15 */ } Overflow = 0; move16(); -#ifdef BASOP_NOGLOB /* Critical Overflow */ env_delta = shl_o( *mem_env_delta, 1, &Overflow ); -#else - env_delta = shl( *mem_env_delta, 1 ); -#endif } ELSE { @@ -125,29 +121,15 @@ Word16 env_stability_fx( /* in Q15 */ } exp = shr( exp, 1 ); -#ifdef BASOP_NOGLOB /* Critical Overflow */ env_delta = round_fx_sat( L_shl_sat( L_tmp, sub( 26, exp ) ) ); /* Q10 */ -#else - env_delta = round_fx( L_shl( L_tmp, sub( 26, exp ) ) ); /* Q10 */ -#endif L_tmp = L_mult0( 26214, env_delta ); /* 26214 is 0.1 in Q18. Q28 */ -#ifdef BASOP_NOGLOB /* Critical Overflow */ L_tmp = L_mac_sat( L_tmp, 29491, *mem_env_delta ); /* 29491 is 0.9 in Q15. Q28 */ *mem_env_delta = round_fx_sat( L_tmp ); /* Q12 */ -#else - L_tmp = L_mac( L_tmp, 29491, *mem_env_delta ); /* 29491 is 0.9 in Q15. Q28 */ - - *mem_env_delta = round_fx( L_tmp ); /* Q12 */ -#endif Overflow = 0; move16(); -#ifdef BASOP_NOGLOB /* Critical Overflow */ env_delta = round_fx_o( L_shl_o( L_tmp, 1, &Overflow ), &Overflow ); /* Q13 */ -#else - env_delta = round_fx( L_shl( L_tmp, 1 ) ); /* Q13 */ -#endif } IF( Overflow != 0 ) /* Saturated due to the above up-shifting operation. */ { @@ -245,13 +227,8 @@ Word16 env_stab_smo_fx( /* Q0 */ /*tmp = shl(tmp, add(exp, 1));*/ /* Q15 */ FOR( i = 0; i < NUM_ENV_STAB_PLC_STATES; i++ ) { -#ifdef BASOP_NOGLOB env_stab_state_p[i] = round_fx_o( L_shl_o( L_mult_o( env_stab_state_p[i], tmp, &Overflow ), add( exp, 1 ), &Overflow ), &Overflow ); /* Q15 */ move16(); -#else - env_stab_state_p[i] = round_fx( L_shl( L_mult( env_stab_state_p[i], tmp ), add( exp, 1 ) ) ); /* Q15 */ - move16(); -#endif } /* find maximum index as return value */ diff --git a/lib_com/est_tilt_fx.c b/lib_com/est_tilt_fx.c index d47a47191a7adeed24e8fd12b3f4e64528cd0aa8..138b8c1bc082d6d0b0b4db78e771cc1115c46458 100644 --- a/lib_com/est_tilt_fx.c +++ b/lib_com/est_tilt_fx.c @@ -70,13 +70,8 @@ Word16 est_tilt_fx( /* o : tilt of the code i = sub( exp1, exp2 ); BASOP_SATURATE_WARNING_OFF_EVS -#ifdef BASOP_NOGLOB ener1 = shr_sat( ener1, sub( 1, s_min( i, 0 ) ) ); ener2 = shr_sat( ener2, add( s_max( 0, i ), 1 ) ); -#else - ener1 = shr( ener1, sub( 1, s_min( i, 0 ) ) ); - ener2 = shr( ener2, add( s_max( 0, i ), 1 ) ); -#endif BASOP_SATURATE_WARNING_ON_EVS tmp = sub( ener1, ener2 ); ener1 = add( add( ener1, ener2 ), 1 ); @@ -160,13 +155,8 @@ Word16 est_tilt_ivas_fx( /* o : tilt of the code i = sub( exp1, exp2 ); BASOP_SATURATE_WARNING_OFF_EVS -#ifdef BASOP_NOGLOB ener1 = shr_sat( ener1, sub( 1, s_min( i, 0 ) ) ); ener2 = shr_sat( ener2, add( s_max( 0, i ), 1 ) ); -#else - ener1 = shr( ener1, sub( 1, s_min( i, 0 ) ) ); - ener2 = shr( ener2, add( s_max( 0, i ), 1 ) ); -#endif BASOP_SATURATE_WARNING_ON_EVS tmp = sub( ener1, ener2 ); ener1 = add( add( ener1, ener2 ), 1 ); @@ -341,21 +331,13 @@ void E_UTIL_voice_factor( Word16 *exc, /* i : pointer to the excitation f IF( i >= 0 ) { ener = L_shr( ener, 1 ); -#ifdef BASOP_NOGLOB tmp = L_shr_sat( tmp, add( 1, i ) ); -#else - tmp = L_shr( tmp, add( 1, i ) ); -#endif } ELSE { tmp = L_shr( tmp, 1 ); BASOP_SATURATE_WARNING_OFF_EVS -#ifdef BASOP_NOGLOB ener = L_shr_sat( ener, sub( 1, i ) ); -#else - ener = L_shr( ener, sub( 1, i ) ); -#endif BASOP_SATURATE_WARNING_ON_EVS } diff --git a/lib_com/fd_cng_com_fx.c b/lib_com/fd_cng_com_fx.c index 86e27427ece5aabcaea4b905c56f1dcf588fe6ea..f4468bd0b7107909f4d29adb81472267ff836aa8 100644 --- a/lib_com/fd_cng_com_fx.c +++ b/lib_com/fd_cng_com_fx.c @@ -692,11 +692,7 @@ void minimum_statistics( { /* calculate scalar with normalized msPeriodogSum[cnt], exponent -2*s1 */ s1 = norm_l( msPeriodogSum[cnt] ); -#ifdef BASOP_NOGLOB msPeriodogSum16 = round_fx_sat( L_shl_sat( msPeriodogSum[cnt], s1 ) ); -#else - msPeriodogSum16 = round_fx( L_shl( msPeriodogSum[cnt], s1 ) ); -#endif scalar = L_mult( msPeriodogSum16, msPeriodogSum16 ); /* calculate difference, both elements in 16Q15 format, use absolute value @@ -710,11 +706,7 @@ void minimum_statistics( /* use absolute value to avoid -1.0 x -1.0 multiplications */ s2 = norm_l( scalar2 ); } -#ifdef BASOP_NOGLOB scalar216 = round_fx_o( L_shl_o( scalar2, s2, &Overflow ), &Overflow ); -#else - scalar216 = round_fx( L_shl( scalar2, s2 ) ); -#endif scalar2 = L_mult( scalar216, scalar216 ); /* find common exponent */ @@ -864,11 +856,7 @@ void minimum_statistics( s2 = s_min( s2, WORD32_BITS - 1 ); /* beta: scaled by s2 */ -#ifdef BASOP_NOGLOB tmp16 = round_fx_o( L_shl_o( tmp, s1, &Overflow ), &Overflow ); -#else - tmp16 = round_fx( L_shl( tmp, s1 ) ); -#endif beta = mult_r( tmp16, tmp16 ); /* scalar3: scaled by s3 */ @@ -956,11 +944,7 @@ void minimum_statistics( move32(); /* exponent msCurrentMinSubWindow[j]: CNG_S */ BASOP_SATURATE_WARNING_OFF_EVS; -#ifdef BASOP_NOGLOB msCurrentMinSubWindow[j] = L_shl_o( Mpy_32_32( scalar, msBminSubWin[j] ), 5, &Overflow ); -#else /* BASOP_NOGLOB */ - msCurrentMinSubWindow[j] = L_shl( Mpy_32_32( scalar, msBminSubWin[j] ), 5 ); -#endif /* BASOP_NOGLOB */ move32(); BASOP_SATURATE_WARNING_ON_EVS; } @@ -1327,11 +1311,7 @@ void minimum_statistics_fx( /* use absolute value to avoid -1.0 x -1.0 multiplications */ s2 = norm_l( scalar2 ); } -#ifdef BASOP_NOGLOB scalar216 = round_fx_o( L_shl_o( scalar2, s2, &Overflow ), &Overflow ); -#else - scalar216 = round_fx( L_shl( scalar2, s2 ) ); -#endif scalar2 = L_mult( scalar216, scalar216 ); /* find common exponent */ @@ -1479,11 +1459,7 @@ void minimum_statistics_fx( s2 = s_min( s2, WORD32_BITS - 1 ); /* beta: scaled by s2 */ -#ifdef BASOP_NOGLOB tmp16 = round_fx_o( L_shl_o( tmp, s1, &Overflow ), &Overflow ); -#else - tmp16 = round_fx( L_shl( tmp, s1 ) ); -#endif beta = mult_r( tmp16, tmp16 ); /* scalar3: scaled by s3 */ @@ -1571,11 +1547,7 @@ void minimum_statistics_fx( move32(); /* exponent msCurrentMinSubWindow[j]: CNG_S */ BASOP_SATURATE_WARNING_OFF_EVS; -#ifdef BASOP_NOGLOB msCurrentMinSubWindow[j] = L_shl_o( Mpy_32_32( scalar, msBminSubWin[j] ), 5, &Overflow ); -#else /* BASOP_NOGLOB */ - msCurrentMinSubWindow[j] = L_shl( Mpy_32_32( scalar, msBminSubWin[j] ), 5 ); -#endif /* BASOP_NOGLOB */ move32(); BASOP_SATURATE_WARNING_ON_EVS; } @@ -2044,11 +2016,7 @@ void scalebands( s = norm_l( tmp ); s1 = sub( delta_s, s ); -#ifdef BASOP_NOGLOB delta = round_fx_sat( L_shl_sat( tmp, s ) ); // Q(14+s) -#else - delta = round_fx( L_shl( tmp, s ) ); -#endif /* Choose scale such that the interpolation start and end point both are representable and add 1 additional bit hr. */ delta_s = sub( s_min( norm_l( partpow[j - 1] ), norm_l( partpow[j] ) ), 1 ); val = L_shl( partpow[j - 1], delta_s ); @@ -2192,11 +2160,7 @@ void scalebands_fx( s = norm_l( tmp ); s1 = sub( delta_s, s ); -#ifdef BASOP_NOGLOB delta = round_fx_sat( L_shl_sat( tmp, s ) ); // Q(14+s) -#else - delta = round_fx( L_shl( tmp, s ) ); -#endif /* Choose scale such that the interpolation start and end point both are representable and add 1 additional bit hr. */ delta_s = sub( s_min( norm_l( partpow[j - 1] ), norm_l( partpow[j] ) ), 1 ); val = L_shl( partpow[j - 1], delta_s ); @@ -2306,11 +2270,7 @@ static void getmidbands( move16(); FOR( j = 0; j < npart; j++ ) { -#ifdef BASOP_NOGLOB psize_norm[j] = shl_o( psize[j], shift, &Overflow ); // Q(15 - psize_norm_exp) -#else /* BASOP_NOGLOB */ - psize_norm[j] = shl( psize[j], shift ); -#endif move16(); } /* minimum_statistics needs fixed exponent of 6 */ @@ -2364,13 +2324,8 @@ void AnalysisSTFT( { move32(); move32(); -#ifdef BASOP_NOGLOB fftBuffer[i + len] = L_mult( shr_sat( timeDomainInput[i], Q ), mult_r( olapWin[i].v.re, 23170 /*1.4142135623730950488016887242097 Q14*/ ) ); fftBuffer[i + len + len2] = L_mult( shr_sat( timeDomainInput[i + len2], Q ), mult_r( olapWin[len2 - 1 - i].v.im, 23170 /*1.4142135623730950488016887242097 Q14*/ ) ); -#else - fftBuffer[i + len] = L_mult( shr( timeDomainInput[i], Q ), mult_r( olapWin[i].v.re, 23170 /*1.4142135623730950488016887242097 Q14*/ ) ); - fftBuffer[i + len + len2] = L_mult( shr( timeDomainInput[i + len2], Q ), mult_r( olapWin[len2 - 1 - i].v.im, 23170 /*1.4142135623730950488016887242097 Q14*/ ) ); -#endif } /* Perform FFT */ @@ -2378,11 +2333,7 @@ void AnalysisSTFT( FOR( i = 0; i < len; i++ ) { -#ifdef BASOP_NOGLOB olapBuffer[i] = shr_sat( timeDomainInput[sub( hFdCngCom->frameSize, len ) + i], Q ); -#else - olapBuffer[i] = shr( timeDomainInput[sub( hFdCngCom->frameSize, len ) + i], Q ); -#endif move16(); } } @@ -3064,11 +3015,7 @@ void lpc_from_spectrum( maxVal = L_max( maxVal, L_abs( powspec[i] ) ); } s1 = norm_l( maxVal ); -#ifdef BASOP_NOGLOB nf = L_shr_r_sat( 1099511680l /*1e-3f Q40*/, add( sub( powspec_exp, s1 ), 9 ) ); -#else - nf = L_shr_r( 1099511680l /*1e-3f Q40*/, add( sub( powspec_exp, s1 ), 9 ) ); -#endif ptr = fftBuffer; pti = fftBuffer + 1; diff --git a/lib_com/fft_fx_evs.c b/lib_com/fft_fx_evs.c index e2fce166cce3c92ef431fcb91aba2f248974075e..b6f2bb2acee04e556e60e2a0cd36c85d7c81763d 100644 --- a/lib_com/fft_fx_evs.c +++ b/lib_com/fft_fx_evs.c @@ -1096,34 +1096,18 @@ static void fft5_shift4_16fx( move16(); T3 = zRe[i4]; move16(); -#ifdef BASOP_NOGLOB T4 = add_sat( T2, T3 ); -#else - T4 = add( T2, T3 ); -#endif T5 = zRe[i2]; move16(); T6 = zRe[i3]; move16(); -#ifdef BASOP_NOGLOB T7 = add_sat( T5, T6 ); T8 = add_sat( T4, T7 ); Tt = sub_sat( T5, T6 ); -#else - T7 = add( T5, T6 ); - T8 = add( T4, T7 ); - Tt = sub( T5, T6 ); -#endif /* T9 = KP559016994 * (T4 - T7); */ -#ifdef BASOP_NOGLOB L_tmp = Mult_32_16( KP559016994_16FX, sub_sat( T4, T7 ) ); // Q(16 +x) T9 = round_fx_sat( L_tmp ); // Qx Ts = sub_sat( T2, T3 ); -#else - L_tmp = Mult_32_16( KP559016994_16FX, sub( T4, T7 ) ); - T9 = round_fx( L_tmp ); - Ts = sub( T2, T3 ); -#endif T2 = zIm[i1]; move16(); @@ -1134,52 +1118,27 @@ static void fft5_shift4_16fx( move16(); T6 = zIm[i3]; move16(); -#ifdef BASOP_NOGLOB T7 = add_sat( T5, T6 ); Te = sub_sat( T2, T3 ); Tp = add_sat( T4, T7 ); Th = sub_sat( T5, T6 ); -#else - T7 = add( T5, T6 ); - Te = sub( T2, T3 ); - Tp = add( T4, T7 ); - Th = sub( T5, T6 ); -#endif -#ifdef BASOP_NOGLOB /* Tn = KP559016994 * (T4 - T7); */ L_tmp = Mult_32_16( KP559016994_16FX, sub_sat( T4, T7 ) ); // Q(16 +x) Tn = round_fx_sat( L_tmp ); // Qx zRe[i0] = add_sat( T1, T8 ); move16(); zIm[i0] = add_sat( To, Tp ); -#else - /* Tn = KP559016994 * (T4 - T7); */ - L_tmp = Mult_32_16( KP559016994_16FX, sub( T4, T7 ) ); - Tn = round_fx( L_tmp ); - zRe[i0] = add( T1, T8 ); - move16(); - zIm[i0] = add( To, Tp ); -#endif move16(); /* T2 = KP951056516*Te + KP587785252*Th; */ L_tmp = Mult_32_16( KP951056516_16FX, Te ); // Q(16 +x) L_tmp = Madd_32_16( L_tmp, KP587785252_16FX, Th ); // Q(16 +x) -#ifdef BASOP_NOGLOB - T2 = round_fx_sat( L_tmp ); // Qx -#else - T2 = round_fx( L_tmp ); -#endif + T2 = round_fx_sat( L_tmp ); // Qx /*T3 = KP951056516*Th - KP587785252*Te; */ L_tmp = Mult_32_16( KP951056516_16FX, Th ); // Q(16 +x) L_tmp = Msub_32_16( L_tmp, KP587785252_16FX, Te ); // Q(16 +x) -#ifdef BASOP_NOGLOB - T3 = round_fx_sat( L_tmp ); // Qx -#else - T3 = round_fx( L_tmp ); -#endif -#ifdef BASOP_NOGLOB + T3 = round_fx_sat( L_tmp ); // Qx T6 = sub_sat( T1, shr_sat( T8, 2 ) ); T4 = add_sat( T9, T6 ); T5 = sub_sat( T6, T9 ); @@ -1191,38 +1150,16 @@ static void fft5_shift4_16fx( move16(); zRe[i3] = sub_sat( T5, T3 ); move16(); -#else - T6 = sub( T1, shr( T8, 2 ) ); - T4 = add( T9, T6 ); - T5 = sub( T6, T9 ); - zRe[i1] = sub( T4, T2 ); - move16(); - zRe[i2] = add( T5, T3 ); - move16(); - zRe[i4] = add( T4, T2 ); - move16(); - zRe[i3] = sub( T5, T3 ); - move16(); -#endif /* T2 = KP951056516 * Ts + KP587785252 * Tt; */ L_tmp = Mult_32_16( KP951056516_16FX, Ts ); // Q(16 +x) L_tmp = Madd_32_16( L_tmp, KP587785252_16FX, Tt ); // Q(16 +x) -#ifdef BASOP_NOGLOB - T2 = round_fx_sat( L_tmp ); // Qx -#else - T2 = round_fx( L_tmp ); -#endif + T2 = round_fx_sat( L_tmp ); // Qx /* T3 = KP951056516 * Tt - KP587785252 * Ts; */ L_tmp = Mult_32_16( KP951056516_16FX, Tt ); // Q(16 +x) L_tmp = Msub_32_16( L_tmp, KP587785252_16FX, Ts ); // Q(16 +x) -#ifdef BASOP_NOGLOB - T3 = round_fx_sat( L_tmp ); // Qx -#else - T3 = round_fx( L_tmp ); -#endif -#ifdef BASOP_NOGLOB - T6 = sub_sat( To, shr( Tp, 2 ) ); // To - (Tp / 4) + T3 = round_fx_sat( L_tmp ); // Qx + T6 = sub_sat( To, shr( Tp, 2 ) ); // To - (Tp / 4) T4 = add_sat( Tn, T6 ); T5 = sub_sat( T6, Tn ); zIm[i4] = sub_sat( T4, T2 ); @@ -1233,19 +1170,6 @@ static void fft5_shift4_16fx( move16(); zIm[i3] = add_sat( T3, T5 ); move16(); -#else - T6 = sub( To, shr( Tp, 2 ) ); - T4 = add( Tn, T6 ); - T5 = sub( T6, Tn ); - zIm[i4] = sub( T4, T2 ); - move16(); - zIm[i2] = sub( T5, T3 ); - move16(); - zIm[i1] = add( T2, T4 ); - move16(); - zIm[i3] = add( T3, T5 ); - move16(); -#endif return; } @@ -1287,7 +1211,6 @@ static void fft5_32_16fx( T3 = zRe[i4]; // Qx move16(); -#ifdef BASOP_NOGLOB T4 = add_sat( T2, T3 ); T5 = zRe[i2]; move16(); @@ -1296,17 +1219,6 @@ static void fft5_32_16fx( T7 = add_o( T5, T6, &Overflow ); T8 = add_o( T4, T7, &Overflow ); Tt = sub_o( T5, T6, &Overflow ); -#else - T4 = add( T2, T3 ); - T5 = zRe[i2]; - move16(); - T6 = zRe[i3]; - move16(); - T7 = add( T5, T6 ); - T8 = add( T4, T7 ); - Tt = sub( T5, T6 ); -#endif -#ifdef BASOP_NOGLOB /* T9 = KP559016994 * (T4 - T7); */ L_tmp = Mult_32_16( KP559016994_16FX, sub_sat( T4, T7 ) ); // Q(16 +x) T9 = round_fx_sat( L_tmp ); // Qx @@ -1327,43 +1239,13 @@ static void fft5_32_16fx( Th = sub_sat( T5, T6 ); L_tmp = Mult_32_16( KP559016994_16FX, sub_sat( T4, T7 ) ); // Q(16 +x) Tn = round_fx_sat( L_tmp ); // Qx -#else - /* T9 = KP559016994 * (T4 - T7); */ - L_tmp = Mult_32_16( KP559016994_16FX, sub( T4, T7 ) ); - T9 = round_fx( L_tmp ); - Ts = sub( T2, T3 ); - - T2 = zIm[i1]; - move16(); - T3 = zIm[i4]; - move16(); - T4 = add( T2, T3 ); - T5 = zIm[i2]; - move16(); - T6 = zIm[i3]; - move16(); - T7 = add( T5, T6 ); - Te = sub( T2, T3 ); - Tp = add( T4, T7 ); - Th = sub( T5, T6 ); - L_tmp = Mult_32_16( KP559016994_16FX, sub( T4, T7 ) ); - Tn = round_fx( L_tmp ); -#endif -#ifdef BASOP_NOGLOB zRe[i0] = add_o( T1, T8, &Overflow ); move16(); zIm[i0] = add_o( To, Tp, &Overflow ); move32(); -#else - zRe[i0] = add( T1, T8 ); - move16(); - zIm[i0] = add( To, Tp ); - move32(); -#endif -#ifdef BASOP_NOGLOB /*T2 = KP951056516*Te + KP587785252*Th; */ L_tmp = Mult_32_16( KP951056516_16FX, Te ); // Q(16 +x) L_tmp = Madd_32_16( L_tmp, KP587785252_16FX, Th ); // Q(16 +x) @@ -1387,31 +1269,6 @@ static void fft5_32_16fx( move32(); zRe[i4] = sub_o( T5, T3, &Overflow ); move32(); -#else - /*T2 = KP951056516*Te + KP587785252*Th; */ - L_tmp = Mult_32_16( KP951056516_16FX, Te ); - L_tmp = Madd_32_16( L_tmp, KP587785252_16FX, Th ); - T2 = round_fx( L_tmp ); - - /*T3 = KP951056516*Th - KP587785252*Te; */ - L_tmp = Mult_32_16( KP951056516_16FX, Th ); - L_tmp = Msub_32_16( L_tmp, KP587785252_16FX, Te ); - T3 = round_fx( L_tmp ); - - - T6 = sub( T1, shr( T8, 2 ) ); - T4 = add( T9, T6 ); - T5 = sub( T6, T9 ); - - zRe[i3] = sub( T4, T2 ); - move32(); - zRe[i1] = add( T5, T3 ); - move32(); - zRe[i2] = add( T4, T2 ); - move32(); - zRe[i4] = sub( T5, T3 ); - move32(); -#endif /* T2 = KP951056516 * Ts + KP587785252 * Tt; */ L_tmp = Mult_32_16( KP951056516_16FX, Ts ); // Q(16 +x) @@ -1422,7 +1279,6 @@ static void fft5_32_16fx( L_tmp = Mult_32_16( KP951056516_16FX, Tt ); // Q(16 +x) L_tmp = Msub_32_16( L_tmp, KP587785252_16FX, Ts ); // Q(16 +x) -#ifdef BASOP_NOGLOB T3 = round_fx_sat( L_tmp ); // Qx T6 = sub_sat( To, shr( Tp, 2 ) ); @@ -1436,21 +1292,6 @@ static void fft5_32_16fx( move16(); zIm[i4] = add_sat( T3, T5 ); move16(); -#else - T3 = round_fx( L_tmp ); - - T6 = sub( To, shr( Tp, 2 ) ); - T4 = add( Tn, T6 ); - T5 = sub( T6, Tn ); - zIm[i2] = sub( T4, T2 ); - move16(); - zIm[i1] = sub( T5, T3 ); - move16(); - zIm[i3] = add( T2, T4 ); - move16(); - zIm[i4] = add( T3, T5 ); - move16(); -#endif return; } @@ -1890,7 +1731,6 @@ static void cftfsub_16fx( { FOR( j = 0; j < l; j += 2 ) { -#ifdef BASOP_NOGLOB j1 = add_o( j, l, &Overflow ); x0r = sub_o( a[j], a[j1], &Overflow ); x0i = sub_o( a[j + 1], a[j1 + 1], &Overflow ); @@ -1902,19 +1742,6 @@ static void cftfsub_16fx( move16(); a[j1 + 1] = x0i; move16(); -#else - j1 = add( j, l ); - x0r = sub( a[j], a[j1] ); - x0i = sub( a[j + 1], a[j1 + 1] ); - a[j] = add( a[j], a[j1] ); - move16(); - a[j + 1] = add( a[j + 1], a[j1 + 1] ); - move16(); - a[j1] = x0r; - move16(); - a[j1 + 1] = x0i; - move16(); -#endif } } return; @@ -1940,7 +1767,6 @@ static void cft1st_16fx( move32(); #endif -#ifdef BASOP_NOGLOB x0r = add_o( a[0], a[2], &Overflow ); x0i = add_o( a[1], a[3], &Overflow ); x1r = sub_o( a[0], a[2], &Overflow ); @@ -1964,36 +1790,9 @@ static void cft1st_16fx( a[6] = add_o( x1r, x3i, &Overflow ); move16(); a[7] = sub_o( x1i, x3r, &Overflow ); -#else - x0r = add( a[0], a[2] ); - x0i = add( a[1], a[3] ); - x1r = sub( a[0], a[2] ); - x1i = sub( a[1], a[3] ); - x2r = add( a[4], a[6] ); - x2i = add( a[5], a[7] ); - x3r = sub( a[4], a[6] ); - x3i = sub( a[5], a[7] ); - a[0] = add( x0r, x2r ); - move16(); - a[1] = add( x0i, x2i ); - move16(); - a[4] = sub( x0r, x2r ); - move16(); - a[5] = sub( x0i, x2i ); - move16(); - a[2] = sub( x1r, x3i ); - move16(); - a[3] = add( x1i, x3r ); - move16(); - a[6] = add( x1r, x3i ); - move16(); - a[7] = sub( x1i, x3r ); - move16(); -#endif wk1r = w[2]; move32(); -#ifdef BASOP_NOGLOB x0r = add_o( a[8], a[10], &Overflow ); x0i = add_o( a[9], a[11], &Overflow ); x1r = sub_o( a[8], a[10], &Overflow ); @@ -2014,31 +1813,8 @@ static void cft1st_16fx( x0r = sub_o( x1r, x3i, &Overflow ); x0i = add_o( x1i, x3r, &Overflow ); tmp = sub_o( x0r, x0i, &Overflow ); -#else - x0r = add( a[8], a[10] ); - x0i = add( a[9], a[11] ); - x1r = sub( a[8], a[10] ); - x1i = sub( a[9], a[11] ); - x2r = add( a[12], a[14] ); - x2i = add( a[13], a[15] ); - x3r = sub( a[12], a[14] ); - x3i = sub( a[13], a[15] ); - a[8] = add( x0r, x2r ); - move16(); - a[9] = add( x0i, x2i ); - move16(); - a[12] = sub( x2i, x0i ); - move16(); - a[13] = sub( x0r, x2r ); - move16(); - - x0r = sub( x1r, x3i ); - x0i = add( x1i, x3r ); - tmp = sub( x0r, x0i ); -#endif L_tmp = Mult_32_16( wk1r, tmp ); /*Q(15+Qx+Q_edct) */ -#ifdef BASOP_NOGLOB a[10] = round_fx_o( L_shl_o( L_tmp, 1, &Overflow ), &Overflow ); /*Q(Qx+Q_edct) */ move16(); @@ -2058,23 +1834,6 @@ static void cft1st_16fx( L_tmp = Mult_32_16( wk1r, tmp ); /*Q(15+Qx+Q_edct) */ a[15] = round_fx_o( L_shl_o( L_tmp, 1, &Overflow ), &Overflow ); /*Q(Qx+Q_edct) */ move16(); -#else - a[10] = round_fx( L_shl( L_tmp, 1 ) ); /*Q(Qx+Q_edct) */ - - tmp = add( x0r, x0i ); - L_tmp = Mult_32_16( wk1r, tmp ); /*Q(15+Qx+Q_edct) */ - a[11] = round_fx( L_shl( L_tmp, 1 ) ); /* Q(Qx+Q_edct) */ - - x0r = add( x3i, x1r ); - x0i = sub( x3r, x1i ); - tmp = sub( x0i, x0r ); - L_tmp = Mult_32_16( wk1r, tmp ); /*Q(15+Qx+Q_edct) */ - a[14] = round_fx( L_shl( L_tmp, 1 ) ); /*Q(Qx+Q_edct) */ - - tmp = add( x0i, x0r ); - L_tmp = Mult_32_16( wk1r, tmp ); /*Q(15+Qx+Q_edct) */ - a[15] = round_fx( L_shl( L_tmp, 1 ) ); /*Q(Qx+Q_edct) */ -#endif k1 = 0; move16(); @@ -2097,7 +1856,6 @@ static void cft1st_16fx( L_tmp = L_shl( Mult_32_32( wk2i, wk1r ), 1 ); /*Q29 */ wk3i = L_sub( L_shl( L_tmp, 1 ), wk1i ); /*Q30 */ -#ifdef BASOP_NOGLOB x0r = add_o( a[j], a[j + 2], &Overflow ); x0i = add_o( a[j + 1], a[j + 3], &Overflow ); x1r = sub_o( a[j], a[j + 2], &Overflow ); @@ -2208,106 +1966,6 @@ static void cft1st_16fx( L_tmp = Madd_32_16( L_tmp, wk3i, x0r ); /*Q(15+Qx+Q_edct) */ a[j + 15] = round_fx_o( L_shl_o( L_tmp, 1, &Overflow ), &Overflow ); /*Q(Qx+Q_edct) */ move16(); -#else - x0r = add( a[j], a[j + 2] ); - x0i = add( a[j + 1], a[j + 3] ); - x1r = sub( a[j], a[j + 2] ); - x1i = sub( a[j + 1], a[j + 3] ); - x2r = add( a[j + 4], a[j + 6] ); - x2i = add( a[j + 5], a[j + 7] ); - x3r = sub( a[j + 4], a[j + 6] ); - x3i = sub( a[j + 5], a[j + 7] ); - a[j] = add( x0r, x2r ); - move16(); - a[j + 1] = add( x0i, x2i ); - move16(); - - x0r = sub( x0r, x2r ); - x0i = sub( x0i, x2i ); - L_tmp = Mult_32_16( wk2r, x0r ); /*Q(15+Qx+Q_edct) */ - L_tmp = Msub_32_16( L_tmp, wk2i, x0i ); /*Q(15+Qx+Q_edct) */ - a[j + 4] = round_fx( L_shl( L_tmp, 1 ) ); /*Q(Qx+Q_edct) */ - - L_tmp = Mult_32_16( wk2r, x0i ); /*Q(15+Qx+Q_edct) */ - L_tmp = Madd_32_16( L_tmp, wk2i, x0r ); /*Q(15+Qx+Q_edct) */ - a[j + 5] = round_fx( L_shl( L_tmp, 1 ) ); /*Q(Qx+Q_edct) */ - - x0r = sub( x1r, x3i ); - x0i = add( x1i, x3r ); - L_tmp = Mult_32_16( wk1r, x0r ); /*Q(15+Qx+Q_edct) */ - L_tmp = Msub_32_16( L_tmp, wk1i, x0i ); /*Q(15+Qx+Q_edct) */ - a[j + 2] = round_fx( L_shl( L_tmp, 1 ) ); /*Q(Qx+Q_edct) */ - - L_tmp = Mult_32_16( wk1r, x0i ); /*Q(15+Qx+Q_edct) */ - L_tmp = Madd_32_16( L_tmp, wk1i, x0r ); /*Q(15+Qx+Q_edct) */ - a[j + 3] = round_fx( L_shl( L_tmp, 1 ) ); /*Q(Qx+Q_edct) */ - - x0r = add( x1r, x3i ); - x0i = sub( x1i, x3r ); - L_tmp = Mult_32_16( wk3r, x0r ); /*Q(15+Qx+Q_edct) */ - L_tmp = Msub_32_16( L_tmp, wk3i, x0i ); /*Q(15+Qx+Q_edct) */ - a[j + 6] = round_fx( L_shl( L_tmp, 1 ) ); /*Q(Qx+Q_edct) */ - - L_tmp = Mult_32_16( wk3r, x0i ); /*Q(15+Qx+Q_edct) */ - L_tmp = Madd_32_16( L_tmp, wk3i, x0r ); /*Q(15+Qx+Q_edct) */ - a[j + 7] = round_fx( L_shl( L_tmp, 1 ) ); /*Q(Qx+Q_edct) */ - - wk1r = w[k2 + 2]; - move32(); - wk1i = w[k2 + 3]; - move32(); - L_tmp = L_shl( Mult_32_32( wk2r, wk1i ), 1 ); /*Q29 */ - wk3r = L_sub( wk1r, L_shl( L_tmp, 1 ) ); /*Q30 */ - - L_tmp = L_shl( Mult_32_32( wk2r, wk1r ), 1 ); /*Q29 */ - wk3i = L_sub( L_shl( L_tmp, 1 ), wk1i ); /*Q30 */ - - x0r = add( a[j + 8], a[j + 10] ); - x0i = add( a[j + 9], a[j + 11] ); - x1r = sub( a[j + 8], a[j + 10] ); - x1i = sub( a[j + 9], a[j + 11] ); - x2r = add( a[j + 12], a[j + 14] ); - x2i = add( a[j + 13], a[j + 15] ); - x3r = sub( a[j + 12], a[j + 14] ); - x3i = sub( a[j + 13], a[j + 15] ); - a[j + 8] = add( x0r, x2r ); - move16(); - a[j + 9] = add( x0i, x2i ); - move16(); - - x0r = sub( x0r, x2r ); - x0i = sub( x0i, x2i ); - tmp = negate( x0r ); - L_tmp = Mult_32_16( wk2i, tmp ); /*Q(15+Qx+Q_edct) */ - L_tmp = Msub_32_16( L_tmp, wk2r, x0i ); /*Q(15+Qx+Q_edct) */ - a[j + 12] = round_fx( L_shl( L_tmp, 1 ) ); /*Q(Qx+Q_edct) */ - - tmp = negate( x0i ); - L_tmp = Mult_32_16( wk2i, tmp ); /*Q(15+Qx+Q_edct) */ - L_tmp = Madd_32_16( L_tmp, wk2r, x0r ); /*Q(15+Qx+Q_edct) */ - a[j + 13] = round_fx( L_shl( L_tmp, 1 ) ); /*Q(Qx+Q_edct) */ - - x0r = sub( x1r, x3i ); - x0i = add( x1i, x3r ); - L_tmp = Mult_32_16( wk1r, x0r ); /*Q(15+Qx+Q_edct) */ - L_tmp = Msub_32_16( L_tmp, wk1i, x0i ); /*Q(15+Qx+Q_edct) */ - a[j + 10] = round_fx( L_shl( L_tmp, 1 ) ); /*Q(Qx+Q_edct) */ - - L_tmp = Mult_32_16( wk1r, x0i ); /*Q(15+Qx+Q_edct) */ - L_tmp = Madd_32_16( L_tmp, wk1i, x0r ); /*Q(15+Qx+Q_edct) */ - a[j + 11] = round_fx( L_shl( L_tmp, 1 ) ); /*Q(Qx+Q_edct) */ - - x0r = add( x1r, x3i ); - x0i = sub( x1i, x3r ); - - L_tmp = Mult_32_16( wk3r, x0r ); /*Q(15+Qx+Q_edct) */ - L_tmp = Msub_32_16( L_tmp, wk3i, x0i ); /*Q(15+Qx+Q_edct) */ - a[j + 14] = round_fx( L_shl( L_tmp, 1 ) ); /*Q(Qx+Q_edct) */ - - L_tmp = Mult_32_16( wk3r, x0i ); /*Q(15+Qx+Q_edct) */ - L_tmp = Madd_32_16( L_tmp, wk3i, x0r ); /*Q(15+Qx+Q_edct) */ - a[j + 15] = round_fx( L_shl( L_tmp, 1 ) ); /*Q(Qx+Q_edct) */ -#endif } return; @@ -2337,7 +1995,6 @@ static void cftmdl_16fx( m = shl( l, 2 ); FOR( j = 0; j < l; j += 2 ) { -#ifdef BASOP_NOGLOB j1 = add_o( j, l, &Overflow ); j2 = add_o( j1, l, &Overflow ); j3 = add_o( j2, l, &Overflow ); @@ -2365,35 +2022,6 @@ static void cftmdl_16fx( move16(); a[j3 + 1] = sub_o( x1i, x3r, &Overflow ); move16(); -#else - j1 = add( j, l ); - j2 = add( j1, l ); - j3 = add( j2, l ); - x0r = add( a[j], a[j1] ); - x0i = add( a[j + 1], a[j1 + 1] ); - x1r = sub( a[j], a[j1] ); - x1i = sub( a[j + 1], a[j1 + 1] ); - x2r = add( a[j2], a[j3] ); - x2i = add( a[j2 + 1], a[j3 + 1] ); - x3r = sub( a[j2], a[j3] ); - x3i = sub( a[j2 + 1], a[j3 + 1] ); - a[j] = add( x0r, x2r ); - move16(); - a[j + 1] = add( x0i, x2i ); - move16(); - a[j2] = sub( x0r, x2r ); - move16(); - a[j2 + 1] = sub( x0i, x2i ); - move16(); - a[j1] = sub( x1r, x3i ); - move16(); - a[j1 + 1] = add( x1i, x3r ); - move16(); - a[j3] = add( x1r, x3i ); - move16(); - a[j3 + 1] = sub( x1i, x3r ); - move16(); -#endif } wk1r = w[2]; @@ -2401,7 +2029,6 @@ static void cftmdl_16fx( tmp2 = add( l, m ); FOR( j = m; j < tmp2; j += 2 ) { -#ifdef BASOP_NOGLOB j1 = add_o( j, l, &Overflow ); j2 = add_o( j1, l, &Overflow ); j3 = add_o( j2, l, &Overflow ); @@ -2445,47 +2072,6 @@ static void cftmdl_16fx( L_tmp = Mult_32_16( wk1r, tmp ); /*Q(15+Qx+Q_edct) */ a[j3 + 1] = round_fx_o( L_shl_o( L_tmp, 1, &Overflow ), &Overflow ); /*Q(Qx+Q_edct) */ move16(); -#else - j1 = add( j, l ); - j2 = add( j1, l ); - j3 = add( j2, l ); - x0r = add( a[j], a[j1] ); - x0i = add( a[j + 1], a[j1 + 1] ); - x1r = sub( a[j], a[j1] ); - x1i = sub( a[j + 1], a[j1 + 1] ); - x2r = add( a[j2], a[j3] ); - x2i = add( a[j2 + 1], a[j3 + 1] ); - x3r = sub( a[j2], a[j3] ); - x3i = sub( a[j2 + 1], a[j3 + 1] ); - a[j] = add( x0r, x2r ); - move16(); - a[j + 1] = add( x0i, x2i ); - move16(); - a[j2] = sub( x2i, x0i ); - move16(); - a[j2 + 1] = sub( x0r, x2r ); - move16(); - - x0r = sub( x1r, x3i ); - x0i = add( x1i, x3r ); - tmp = sub( x0r, x0i ); - L_tmp = Mult_32_16( wk1r, tmp ); /*Q(15+Qx+Q_edct) */ - a[j1] = round_fx( L_shl( L_tmp, 1 ) ); /*Q(Qx+Q_edct) */ - - tmp = add( x0r, x0i ); - L_tmp = Mult_32_16( wk1r, tmp ); /*Q(15+Qx+Q_edct) */ - a[j1 + 1] = round_fx( L_shl( L_tmp, 1 ) ); /*Q(Qx+Q_edct) */ - - x0r = add( x3i, x1r ); - x0i = sub( x3r, x1i ); - tmp = sub( x0i, x0r ); - L_tmp = Mult_32_16( wk1r, tmp ); /*Q(15+Qx+Q_edct) */ - a[j3] = round_fx( L_shl( L_tmp, 1 ) ); /*Q(Qx+Q_edct) */ - - tmp = add( x0i, x0r ); - L_tmp = Mult_32_16( wk1r, tmp ); /*Q(15+Qx+Q_edct) */ - a[j3 + 1] = round_fx( L_shl( L_tmp, 1 ) ); /*Q(Qx+Q_edct) */ -#endif } k1 = 0; @@ -2512,7 +2098,6 @@ static void cftmdl_16fx( tmp2 = add( l, k ); FOR( j = k; j < tmp2; j += 2 ) { -#ifdef BASOP_NOGLOB j1 = add_o( j, l, &Overflow ); j2 = add_o( j1, l, &Overflow ); j3 = add_o( j2, l, &Overflow ); @@ -2568,80 +2153,20 @@ static void cftmdl_16fx( L_tmp = Madd_32_16( L_tmp, wk3i, x0r ); /*Q(15+Qx+Q_edct) */ a[j3 + 1] = round_fx_o( L_shl_o( L_tmp, 1, &Overflow ), &Overflow ); /*Q(Qx+Q_edct) */ move16(); -#else - j1 = add( j, l ); - j2 = add( j1, l ); - j3 = add( j2, l ); - x0r = add( a[j], a[j1] ); - x0i = add( a[j + 1], a[j1 + 1] ); - x1r = sub( a[j], a[j1] ); - x1i = sub( a[j + 1], a[j1 + 1] ); - x2r = add( a[j2], a[j3] ); - x2i = add( a[j2 + 1], a[j3 + 1] ); - x3r = sub( a[j2], a[j3] ); - x3i = sub( a[j2 + 1], a[j3 + 1] ); - a[j] = add( x0r, x2r ); - move16(); - a[j + 1] = add( x0i, x2i ); - move16(); - - x0r = sub( x0r, x2r ); - x0i = sub( x0i, x2i ); - - L_tmp = Mult_32_16( wk2r, x0r ); /*Q(15+Qx+Q_edct) */ - L_tmp = Msub_32_16( L_tmp, wk2i, x0i ); /*Q(15+Qx+Q_edct) */ - a[j2] = round_fx( L_shl( L_tmp, 1 ) ); /*Q(Qx+Q_edct) */ - - L_tmp = Mult_32_16( wk2r, x0i ); /*Q(15+Qx+Q_edct) */ - L_tmp = Madd_32_16( L_tmp, wk2i, x0r ); /*Q(15+Qx+Q_edct) */ - a[j2 + 1] = round_fx( L_shl( L_tmp, 1 ) ); /*Q(Qx+Q_edct) */ - - x0r = sub( x1r, x3i ); - x0i = add( x1i, x3r ); - - L_tmp = Mult_32_16( wk1r, x0r ); /*Q(15+Qx+Q_edct) */ - L_tmp = Msub_32_16( L_tmp, wk1i, x0i ); /*Q(15+Qx+Q_edct) */ - a[j1] = round_fx( L_shl( L_tmp, 1 ) ); /*Q(Qx+Q_edct) */ - - L_tmp = Mult_32_16( wk1r, x0i ); /*Q(15+Qx+Q_edct) */ - L_tmp = Madd_32_16( L_tmp, wk1i, x0r ); /*Q(15+Qx+Q_edct) */ - a[j1 + 1] = round_fx( L_shl( L_tmp, 1 ) ); /*Q(Qx+Q_edct) */ - - L_x0r = L_add( (Word32) x1r, (Word32) x3i ); - L_x0i = L_sub( (Word32) x1i, (Word32) x3r ); - x0r = extract_l( L_x0r ); - x0i = extract_l( L_x0i ); - L_tmp = Mult_32_16( wk3r, x0r ); /*Q(15+Qx+Q_edct) */ - L_tmp = Msub_32_16( L_tmp, wk3i, x0i ); /*Q(15+Qx+Q_edct) */ - a[j3] = round_fx( L_shl( L_tmp, 1 ) ); /*Q(Qx+Q_edct) */ - - L_tmp = Mult_32_16( wk3r, x0i ); /*Q(15+Qx+Q_edct) */ - L_tmp = Madd_32_16( L_tmp, wk3i, x0r ); /*Q(15+Qx+Q_edct) */ - a[j3 + 1] = round_fx( L_shl( L_tmp, 1 ) ); /*Q(Qx+Q_edct) */ -#endif } wk1r = w[k2 + 2]; move32(); wk1i = w[k2 + 3]; move32(); -#ifdef BASOP_NOGLOB L_tmp = L_shl_o( Mult_32_32( wk2r, wk1i ), 1, &Overflow ); /*Q29 */ wk3r = L_sub_o( wk1r, L_shl_o( L_tmp, 1, &Overflow ), &Overflow ); /*Q30 */ L_tmp = L_shl_o( Mult_32_32( wk2r, wk1r ), 1, &Overflow ); /*Q29 */ wk3i = L_sub_o( L_shl_o( L_tmp, 1, &Overflow ), wk1i, &Overflow ); /*Q30 */ -#else - L_tmp = L_shl( Mult_32_32( wk2r, wk1i ), 1 ); /*Q29 */ - wk3r = L_sub( wk1r, L_shl( L_tmp, 1 ) ); /*Q30 */ - - L_tmp = L_shl( Mult_32_32( wk2r, wk1r ), 1 ); /*Q29 */ - wk3i = L_sub( L_shl( L_tmp, 1 ), wk1i ); /*Q30 */ -#endif tmp2 = add( l, add( k, m ) ); FOR( j = add( k, m ); j < tmp2; j += 2 ) { -#ifdef BASOP_NOGLOB j1 = add_o( j, l, &Overflow ); j2 = add_o( j1, l, &Overflow ); j3 = add_o( j2, l, &Overflow ); @@ -2698,58 +2223,6 @@ static void cftmdl_16fx( L_tmp = Madd_32_16( L_tmp, wk3i, x0r ); /*Q(15+Qx+Q_edct) */ a[j3 + 1] = round_fx_o( L_shl_o( L_tmp, 1, &Overflow ), &Overflow ); /*Q(Qx+Q_edct) */ move16(); -#else - j1 = add( j, l ); - j2 = add( j1, l ); - j3 = add( j2, l ); - x0r = add( a[j], a[j1] ); - x0i = add( a[j + 1], a[j1 + 1] ); - x1r = sub( a[j], a[j1] ); - x1i = sub( a[j + 1], a[j1 + 1] ); - x2r = add( a[j2], a[j3] ); - x2i = add( a[j2 + 1], a[j3 + 1] ); - x3r = sub( a[j2], a[j3] ); - x3i = sub( a[j2 + 1], a[j3 + 1] ); - a[j] = add( x0r, x2r ); - move16(); - a[j + 1] = add( x0i, x2i ); - move16(); - - x0r = sub( x0r, x2r ); - x0i = sub( x0i, x2i ); - - tmp = negate( x0r ); - L_tmp = Mult_32_16( wk2i, tmp ); /*Q(15+Qx+Q_edct) */ - L_tmp = Msub_32_16( L_tmp, wk2r, x0i ); /*Q(15+Qx+Q_edct) */ - a[j2] = round_fx( L_shl( L_tmp, 1 ) ); /*Q(Qx+Q_edct) */ - - tmp = negate( x0i ); - L_tmp = Mult_32_16( wk2i, tmp ); /*Q(15+Qx+Q_edct) */ - L_tmp = Madd_32_16( L_tmp, wk2r, x0r ); /*Q(15+Qx+Q_edct) */ - a[j2 + 1] = round_fx( L_shl( L_tmp, 1 ) ); /*Q(Qx+Q_edct) */ - - x0r = sub( x1r, x3i ); - x0i = add( x1i, x3r ); - - L_tmp = Mult_32_16( wk1r, x0r ); /*Q(15+Qx+Q_edct) */ - L_tmp = Msub_32_16( L_tmp, wk1i, x0i ); /*Q(15+Qx+Q_edct) */ - a[j1] = round_fx( L_shl( L_tmp, 1 ) ); /*Q(Qx+Q_edct) */ - - L_tmp = Mult_32_16( wk1r, x0i ); /*Q(15+Qx+Q_edct) */ - L_tmp = Madd_32_16( L_tmp, wk1i, x0r ); /*Q(15+Qx+Q_edct) */ - a[j1 + 1] = round_fx( L_shl( L_tmp, 1 ) ); /*Q(Qx+Q_edct) */ - - x0r = add( x1r, x3i ); - x0i = sub( x1i, x3r ); - - L_tmp = Mult_32_16( wk3r, x0r ); /*Q(15+Qx+Q_edct) */ - L_tmp = Msub_32_16( L_tmp, wk3i, x0i ); /*Q(15+Qx+Q_edct) */ - a[j3] = round_fx( L_shl( L_tmp, 1 ) ); /*Q(Qx+Q_edct) */ - - L_tmp = Mult_32_16( wk3r, x0i ); /*Q(15+Qx+Q_edct) */ - L_tmp = Madd_32_16( L_tmp, wk3i, x0r ); /*Q(15+Qx+Q_edct) */ - a[j3 + 1] = round_fx( L_shl( L_tmp, 1 ) ); /*Q(Qx+Q_edct) */ -#endif } } @@ -2854,13 +2327,9 @@ void fft3_fx( const Word16 X[] /*Qx*/, Word16 Y[] /*Qx*/, const Word16 n ) move16(); /* special case: i = 0 */ - acc = L_mult( *RZ0++, 0x4000 /*1.Q14*/ ); // Q15 + Qx - acc = L_mac( acc, *RZ1++, 0x4000 /*1.Q14*/ ); // Q15 + Qx -#ifdef BASOP_NOGLOB + acc = L_mult( *RZ0++, 0x4000 /*1.Q14*/ ); // Q15 + Qx + acc = L_mac( acc, *RZ1++, 0x4000 /*1.Q14*/ ); // Q15 + Qx *RY++ = mac_r_sat( acc, *RZ2++, 0x4000 /*1.Q14*/ ); // Qx -#else - *RY++ = mac_r( acc, *RZ2++, 0x4000 ); -#endif move16(); /* first 3/12-- from 1 to (3*m/8)-1 */ @@ -3456,21 +2925,12 @@ void ifft3_fx( const Word16 Z[] /*Qx*/, Word16 X[] /*Qx*/, const Word16 n ) pX = X; FOR( i = 0; i < m; i++ ) { -#ifdef BASOP_NOGLOB *pX++ = shl_sat( mult_r( *y0++, FFT3_ONE_THIRD ), 1 ); // Qx move16(); *pX++ = shl_sat( mult_r( *y1++, FFT3_ONE_THIRD ), 1 ); // Qx move16(); *pX++ = shl_sat( mult_r( *y2++, FFT3_ONE_THIRD ), 1 ); // Qx move16(); -#else - *pX++ = shl( mult_r( *y0++, FFT3_ONE_THIRD ), 1 ); - move16(); - *pX++ = shl( mult_r( *y1++, FFT3_ONE_THIRD ), 1 ); - move16(); - *pX++ = shl( mult_r( *y2++, FFT3_ONE_THIRD ), 1 ); - move16(); -#endif } return; diff --git a/lib_com/fft_rel.c b/lib_com/fft_rel.c index 88f80e798703ed2b34902db2703d30753c1b7698..aa3b578bdb1a0df53f8fd8541e0ff198da03d704 100644 --- a/lib_com/fft_rel.c +++ b/lib_com/fft_rel.c @@ -301,6 +301,168 @@ void fft_rel( return; } +void fft_rel_16_32fx( + Word16 x[], /* i/o: input/output vector Qx */ + Word16 *q_x, /* extra scaling added on speech buffer*/ + Word16 i_subfr, + const Word16 n, /* i : vector length */ + const Word16 m /* i : log2 of vector length */ +) +{ + Word16 i, j, k, n1, n2, n4; + Word16 step; + Word32 xt, t1, t2; + Word32 *x0, *x1, *x2; + const Word16 *s, *c; + Word32 *xi2, *xi3, *xi4, *xi1; + + Word32 fft_bff32[L_FFT]; + Copy_Scale_sig_16_32_no_sat( x, fft_bff32, L_FFT, 0 ); // copying x to fft_bff32 without scaling + + /*-----------------------------------------------------------------* + * Digit reverse counter + *-----------------------------------------------------------------*/ + + j = 0; + move16(); + x0 = &fft_bff32[0]; // Qx + FOR( i = 0; i < n - 1; i++ ) + { + IF( LT_16( i, j ) ) + { + xt = fft_bff32[j]; // Qx + move32(); + fft_bff32[j] = *x0; // Qx + move32(); + *x0 = xt; // Qx + move32(); + } + x0++; + k = shr( n, 1 ); + WHILE( ( k <= j ) ) + { + j = sub( j, k ); + k = shr( k, 1 ); + } + j = add( j, k ); + } + + /*-----------------------------------------------------------------* + * Length two butterflies + *-----------------------------------------------------------------*/ + + x0 = &fft_bff32[0]; + x1 = &fft_bff32[1]; + FOR( i = 0; i < ( n >> 1 ); i++ ) + { + xt = *x0; + move32(); + *x0 = L_add( xt, *x1 ); + move32(); + *x1 = L_sub( xt, *x1 ); + move32(); + x0++; + x0++; + x1++; + x1++; + } + + /*-----------------------------------------------------------------* + * Other butterflies + * + * The implementation described in [1] has been changed by using + * table lookup for evaluating sine and cosine functions. The + * variable ind and its increment step are needed to access table + * entries. Note that this implementation assumes n4 to be so + * small that ind will never exceed the table. Thus the input + * argument n and the constant N_MAX_SAS must be set properly. + *-----------------------------------------------------------------*/ + + n2 = 1; + move16(); + /* step = N_MAX_SAS/4; */ + FOR( k = 2; k <= m; k++ ) + { + n4 = n2; + move16(); + n2 = shl( n4, 1 ); + n1 = shl( n2, 1 ); + + step = idiv1616( N_MAX_SAS, n1 ); + + x0 = fft_bff32; + x1 = fft_bff32 + n2; + x2 = fft_bff32 + add( n2, n4 ); + FOR( i = 0; i < n; i += n1 ) + { + xt = *x0; + move32(); /* xt = x[i]; */ + *x0 = L_add( xt, *x1 ); + move32(); /* x[i] = xt + x[i+n2]; */ + *x1 = L_sub( xt, *x1 ); + move32(); /* x[i+n2] = xt - x[i+n2]; */ + *x2 = L_negate( *x2 ); + move32(); /* x[i+n2+n4] = -x[i+n2+n4]; */ + + + s = sincos_t_fx + step; // Q15 + c = s + 64; // Q15 + xi1 = fft_bff32 + add( i, 1 ); + xi3 = xi1 + n2; + xi2 = xi3 - 2; + xi4 = xi1 + sub( n1, 2 ); + + FOR( j = 1; j < n4; j++ ) + { + t1 = L_add( Mpy_32_16_1( *xi3, *c ), Mpy_32_16_1( *xi4, *s ) ); /* t1 = *xi3**(pt_c+ind) + *xi4**(pt_s+ind); Qx */ + t2 = L_sub( Mpy_32_16_1( *xi3, *s ), Mpy_32_16_1( *xi4, *c ) ); /* t2 = *xi3**(pt_s+ind) - *xi4**(pt_c+ind); Qx */ + *xi4 = L_sub( *xi2, t2 ); + move32(); + *xi3 = L_negate( L_add( *xi2, t2 ) ); + move32(); + *xi2 = L_sub( *xi1, t1 ); + move32(); + *xi1 = L_add( *xi1, t1 ); + move32(); + + xi4--; + xi2--; + xi3++; + xi1++; + c += step; + s += step; /* autoincrement by ar0 */ + } + + x0 += n1; + x1 += n1; + x2 += n1; + } + /* step = shr(step, 1); */ + } + Word16 norm = L_norm_arr( fft_bff32, L_FFT ); + IF( i_subfr == 0 ) + { + Copy_Scale_sig32_16( fft_bff32, x, L_FFT, norm ); + *q_x = sub( norm, 16 ); + move16(); + } + ELSE + { + IF( LT_16( sub( norm, 16 ), *q_x ) ) + { + scale_sig( x - L_FFT, L_FFT, sub( sub( norm, 16 ), *q_x ) ); + Copy_Scale_sig32_16( fft_bff32, x, L_FFT, norm ); + *q_x = sub( norm, 16 ); + move16(); + } + ELSE + { + Copy_Scale_sig32_16( fft_bff32, x, L_FFT, add( 16, *q_x ) ); + } + } + + return; +} void fft_rel_fx( Word16 x[], /* i/o: input/output vector Qx */ @@ -361,17 +523,9 @@ void fft_rel_fx( { xt = *x0; move16(); -#ifdef BASOP_NOGLOB *x0 = add_o( xt, *x1, &Overflow ); -#else - *x0 = add( xt, *x1 ); -#endif move16(); -#ifdef BASOP_NOGLOB *x1 = sub_o( xt, *x1, &Overflow ); -#else - *x1 = sub( xt, *x1 ); -#endif move16(); x0++; x0++; @@ -409,17 +563,9 @@ void fft_rel_fx( { xt = *x0; move16(); /* xt = x[i]; */ -#ifdef BASOP_NOGLOB *x0 = add_o( xt, *x1, &Overflow ); -#else /* BASOP_NOGLOB */ - *x0 = add( xt, *x1 ); -#endif /* BASOP_NOGLOB */ move16(); /* x[i] = xt + x[i+n2]; */ -#ifdef BASOP_NOGLOB *x1 = sub_o( xt, *x1, &Overflow ); -#else /* BASOP_NOGLOB */ - *x1 = sub( xt, *x1 ); -#endif /* BASOP_NOGLOB */ move16(); /* x[i+n2] = xt - x[i+n2]; */ *x2 = negate( *x2 ); move16(); /* x[i+n2+n4] = -x[i+n2+n4]; */ @@ -434,33 +580,15 @@ void fft_rel_fx( FOR( j = 1; j < n4; j++ ) { -#ifdef BASOP_NOGLOB t1 = add_o( mult_r( *xi3, *c ), mult_r( *xi4, *s ), &Overflow ); /* t1 = *xi3**(pt_c+ind) + *xi4**(pt_s+ind); Qx */ t2 = sub_o( mult_r( *xi3, *s ), mult_r( *xi4, *c ), &Overflow ); /* t2 = *xi3**(pt_s+ind) - *xi4**(pt_c+ind); Qx */ *xi4 = sub_o( *xi2, t2, &Overflow ); -#else /* BASOP_NOGLOB */ - t1 = add( mult_r( *xi3, *c ), mult_r( *xi4, *s ) ); /* t1 = *xi3**(pt_c+ind) + *xi4**(pt_s+ind); */ - t2 = sub( mult_r( *xi3, *s ), mult_r( *xi4, *c ) ); /* t2 = *xi3**(pt_s+ind) - *xi4**(pt_c+ind); */ - *xi4 = sub( *xi2, t2 ); -#endif /* BASOP_NOGLOB */ move16(); -#ifdef BASOP_NOGLOB *xi3 = negate( add_o( *xi2, t2, &Overflow ) ); -#else /* BASOP_NOGLOB */ - *xi3 = negate( add( *xi2, t2 ) ); -#endif /* BASOP_NOGLOB */ move16(); -#ifdef BASOP_NOGLOB *xi2 = sub_o( *xi1, t1, &Overflow ); -#else /* BASOP_NOGLOB */ - *xi2 = sub( *xi1, t1 ); -#endif /* BASOP_NOGLOB */ move16(); -#ifdef BASOP_NOGLOB *xi1 = add_o( *xi1, t1, &Overflow ); -#else /* BASOP_NOGLOB */ - *xi1 = add( *xi1, t1 ); -#endif /* BASOP_NOGLOB */ move16(); xi4--; diff --git a/lib_com/fft_rel_fx.c b/lib_com/fft_rel_fx.c index 1285049bcb6afd76f90b084ac1a759671f2dbfec..5461ce55baae37f1bfdd25c36fac6607fd69e0c1 100644 --- a/lib_com/fft_rel_fx.c +++ b/lib_com/fft_rel_fx.c @@ -136,26 +136,15 @@ static void c_fft_fx( input_ptr1 = in_ptr + ( const Word16 )( (uintptr_t) ( *table_ptr++ ) >> (uintptr_t) shift ); -#ifdef BASOP_NOGLOB tmp1 = msu_r_sat( L_tmp1, *input_ptr1, 16384 ); tmp3 = mac_r_sat( L_tmp1, *input_ptr1++, 16384 ); -#else - tmp1 = msu_r( L_tmp1, *input_ptr1, 16384 ); - tmp3 = mac_r( L_tmp1, *input_ptr1++, 16384 ); -#endif input_ptr2 = in_ptr + ( const Word16 )( (uintptr_t) ( *table_ptr++ ) >> (uintptr_t) shift ); input_ptr3 = in_ptr + ( const Word16 )( (uintptr_t) ( *table_ptr++ ) >> (uintptr_t) shift ); L_tmp1 = L_mult( *input_ptr2++, 16384 ); -#ifdef BASOP_NOGLOB tmp2 = mac_r_sat( L_tmp1, *input_ptr3, 16384 ); tmp4 = msu_r_sat( L_tmp1, *input_ptr3++, 16384 ); -#else - tmp2 = mac_r( L_tmp1, *input_ptr3, 16384 ); - tmp4 = msu_r( L_tmp1, *input_ptr3++, 16384 ); -#endif L_tmp1 = L_mult( tmp3, 16384 ); -#ifdef BASOP_NOGLOB out_ptr[k] = mac_r_sat( L_tmp1, tmp2, 16384 ); move16(); out_ptr[k + 4] = msu_r_sat( L_tmp1, tmp2, 16384 ); @@ -163,57 +152,25 @@ static void c_fft_fx( tmp2 = mac_r_sat( L_tmp2, *input_ptr1, 16384 ); tmp3 = msu_r_sat( L_tmp2, *input_ptr1, 16384 ); -#else - out_ptr[k] = mac_r( L_tmp1, tmp2, 16384 ); - move16(); - out_ptr[k + 4] = msu_r( L_tmp1, tmp2, 16384 ); - move16(); - - tmp2 = mac_r( L_tmp2, *input_ptr1, 16384 ); - tmp3 = msu_r( L_tmp2, *input_ptr1, 16384 ); -#endif L_tmp2 = L_mult( *input_ptr2, 16384 ); L_tmp1 = L_mult( tmp1, 16384 ); -#ifdef BASOP_NOGLOB tmp1 = msu_r_sat( L_tmp2, *input_ptr3, 16384 ); out_ptr[k + 2] = mac_r_sat( L_tmp1, tmp1, 16384 ); move16(); out_ptr[k + 6] = msu_r_sat( L_tmp1, tmp1, 16384 ); move16(); -#else - tmp1 = msu_r( L_tmp2, *input_ptr3, 16384 ); - out_ptr[k + 2] = mac_r( L_tmp1, tmp1, 16384 ); - move16(); - out_ptr[k + 6] = msu_r( L_tmp1, tmp1, 16384 ); - move16(); -#endif L_tmp1 = L_mult( tmp2, 16384 ); -#ifdef BASOP_NOGLOB tmp2 = mac_r_sat( L_tmp2, *input_ptr3, 16384 ); out_ptr[k + 1] = mac_r_sat( L_tmp1, tmp2, 16384 ); move16(); out_ptr[k + 5] = msu_r_sat( L_tmp1, tmp2, 16384 ); move16(); -#else - tmp2 = mac_r( L_tmp2, *input_ptr3, 16384 ); - out_ptr[k + 1] = mac_r( L_tmp1, tmp2, 16384 ); - move16(); - out_ptr[k + 5] = msu_r( L_tmp1, tmp2, 16384 ); - move16(); -#endif L_tmp1 = L_mult( tmp3, 16384 ); -#ifdef BASOP_NOGLOB out_ptr[k + 3] = msu_r_sat( L_tmp1, tmp4, 16384 ); move16(); out_ptr[k + 7] = mac_r_sat( L_tmp1, tmp4, 16384 ); move16(); -#else - out_ptr[k + 3] = msu_r( L_tmp1, tmp4, 16384 ); - move16(); - out_ptr[k + 7] = mac_r( L_tmp1, tmp4, 16384 ); - move16(); -#endif } /* Remaining Stages */ @@ -333,7 +290,6 @@ static void c_fft_fx( kj = add( k, jj ); /* kj is butterfly bottom */ /* Butterfly computations */ -#ifdef BASOP_NOGLOB tmp1 = mac_r_sat( L_mult_sat( out_ptr[kj], table_ptr[ji] ), out_ptr[kj + 1], table_ptr[ji + 1] ); tmp2 = msu_r_sat( L_mult_sat( out_ptr[kj + 1], table_ptr[ji] ), out_ptr[kj], table_ptr[ji + 1] ); @@ -346,22 +302,6 @@ static void c_fft_fx( move16(); out_ptr[k + 1] = add_sat( out_ptr[k + 1], tmp2 ); move16(); -#else - tmp1 = mac_r( L_mult( out_ptr[kj], table_ptr[ji] ), - out_ptr[kj + 1], table_ptr[ji + 1] ); - - tmp2 = msu_r( L_mult( out_ptr[kj + 1], table_ptr[ji] ), - out_ptr[kj], table_ptr[ji + 1] ); - - out_ptr[kj] = sub( out_ptr[k], tmp1 ); - move16(); - out_ptr[kj + 1] = sub( out_ptr[k + 1], tmp2 ); - move16(); - out_ptr[k] = add( out_ptr[k], tmp1 ); - move16(); - out_ptr[k + 1] = add( out_ptr[k + 1], tmp2 ); - move16(); -#endif } ji = add( ji, ii ); } @@ -420,7 +360,6 @@ void r_fft_fx_lc( FOR( i = 2; i <= SIZE2; i += 2 ) { Ltmp1_imag = L_mult( temp[i + 1], 16384 ); -#ifdef BASOP_NOGLOB Ltmp1_imag = L_msu_sat( Ltmp1_imag, *ptrDn, 16384 ); tmp2_real = add_sat( temp[i + 1], *ptrDn-- ); @@ -439,26 +378,6 @@ void r_fft_fx_lc( move16(); *ptRealDn-- = mac_r_sat( Ltmp1_real, tmp2_real, *phstbl_ptrDn-- ); move16(); -#else - Ltmp1_imag = L_msu( Ltmp1_imag, *ptrDn, 16384 ); - tmp2_real = add( temp[i + 1], *ptrDn-- ); - - Ltmp1_real = L_mult( temp[i], 16384 ); - Ltmp1_real = L_mac( Ltmp1_real, *ptrDn, 16384 ); - tmp2_imag = sub( *ptrDn--, temp[i] ); - - - *ptRealUp++ = msu_r( L_mac( Ltmp1_real, tmp2_real, phs_tbl[i] ), tmp2_imag, phs_tbl[i + 1] ); - move16(); - *ptImaDn-- = mac_r( L_mac( Ltmp1_imag, tmp2_imag, phs_tbl[i] ), tmp2_real, phs_tbl[i + 1] ); - move16(); - Ltmp1 = L_mac( L_negate( Ltmp1_imag ), tmp2_real, *phstbl_ptrDn ); - Ltmp1_real = L_mac( Ltmp1_real, tmp2_imag, *phstbl_ptrDn-- ); - *ptImaUp++ = msu_r( Ltmp1, tmp2_imag, *phstbl_ptrDn ); - move16(); - *ptRealDn-- = mac_r( Ltmp1_real, tmp2_real, *phstbl_ptrDn-- ); - move16(); -#endif } } ELSE /* The ifFT part */ @@ -486,7 +405,6 @@ void r_fft_fx_lc( /* Now, handle the remaining positive frequencies */ FOR( i = 2; i <= SIZE2; i += 2 ) { -#ifdef BASOP_NOGLOB Ltmp1_imag = L_mult( *ptImaDn, 16384 ); Ltmp1_imag = L_msu_sat( Ltmp1_imag, *ptImaUp, 16384 ); tmp2_real = add_sat( *ptImaDn--, *ptImaUp++ ); @@ -503,26 +421,6 @@ void r_fft_fx_lc( move16(); *ptrDn-- = msu_r_sat( Ltmp1_real, tmp2_real, *phstbl_ptrDn-- ); move16(); -#else - Ltmp1_imag = L_mult( *ptImaDn, 16384 ); - Ltmp1_imag = L_msu( Ltmp1_imag, *ptImaUp, 16384 ); - tmp2_real = add( *ptImaDn--, *ptImaUp++ ); - Ltmp1_real = L_mult( *ptRealUp, 16384 ); - Ltmp1_real = L_mac( Ltmp1_real, *ptRealDn, 16384 ); - tmp2_imag = sub( *ptRealUp++, *ptRealDn-- ); - - - temp[i] = mac_r( L_msu( Ltmp1_real, tmp2_real, phs_tbl[i] ), tmp2_imag, phs_tbl[i + 1] ); - move16(); - temp[i + 1] = mac_r( L_mac( Ltmp1_imag, tmp2_imag, phs_tbl[i] ), tmp2_real, phs_tbl[i + 1] ); - move16(); - Ltmp1 = L_mac( L_negate( Ltmp1_imag ), tmp2_real, *phstbl_ptrDn ); - Ltmp1_real = L_msu( Ltmp1_real, tmp2_imag, *phstbl_ptrDn-- ); - *ptrDn-- = msu_r( Ltmp1, tmp2_imag, *phstbl_ptrDn ); - move16(); - *ptrDn-- = msu_r( Ltmp1_real, tmp2_real, *phstbl_ptrDn-- ); - move16(); -#endif } /* Perform the complex ifFT */ diff --git a/lib_com/fill_spectrum.c b/lib_com/fill_spectrum.c index 111ac6d2fdd84f8e6d115a17a6e3aea35c131f6a..5a4f7c4bcf05136cd631454daeb55423b9a26817 100644 --- a/lib_com/fill_spectrum.c +++ b/lib_com/fill_spectrum.c @@ -263,7 +263,7 @@ void ivas_fill_spectrum_fx( } ELSE IF( EQ_16( HQ_mode, HQ_GEN_SWB ) || EQ_16( HQ_mode, HQ_GEN_FB ) ) { - hq_bwe_fx( HQ_mode, L_coeff_out1, hq_generic_fenv, L_coeff_out, hq_generic_offset, prev_L_swb_norm, hq_generic_exc_clas, sfm_end, num_sfm, num_env_bands, R ); + hq_bwe_ivas_fx( HQ_mode, L_coeff_out1, hq_generic_fenv, L_coeff_out, hq_generic_offset, prev_L_swb_norm, hq_generic_exc_clas, sfm_end, num_sfm, num_env_bands, R ); } /*----------------------------------------------------------------* diff --git a/lib_com/frame_ener.c b/lib_com/frame_ener.c index 03e31126aa4322d8e3a86564b535ab5a14f196cd..40e1167e5b142f6660e33b7176ad62f2c44344c7 100644 --- a/lib_com/frame_ener.c +++ b/lib_com/frame_ener.c @@ -202,18 +202,10 @@ Word16 frame_ener_fx( { pos = sub( L_frame, L_frame2 ); } -#ifdef BASOP_NOGLOB Ltmp = L_mult_sat( synth[pos], synth[pos] ); /*2 * Qnew + 1*/ -#else - Ltmp = L_mult( synth[pos], synth[pos] ); -#endif FOR( i = 1; i < L_frame2; i++ ) { -#ifdef BASOP_NOGLOB Ltmp = L_mac_sat( Ltmp, synth[pos + i], synth[pos + i] ); /*2 * Qnew + 1*/ -#else /* BASOP_NOGLOB */ - Ltmp = L_mac( Ltmp, synth[pos + i], synth[pos + i] ); -#endif } test(); IF( EQ_32( Ltmp, MAX_32 ) || enc != 0 ) @@ -296,11 +288,7 @@ Word16 frame_energy_fx( /* o : Frame energy in Q8 /* len = (0.5f * (pitch[2]/64.0 + pitch[3]/64.0) + 0.5f) */ -#ifdef BASOP_NOGLOB len = mult_r( add_o( pitch[2], pitch[3], &Overflow ), 256 ); -#else - len = mult_r( add( pitch[2], pitch[3] ), 256 ); -#endif if ( LT_16( len, L_SUBFR ) ) { @@ -330,30 +318,16 @@ Word16 frame_energy_fx( /* o : Frame energy in Q8 exp1 = sub( 15 + exp1, tmp2 ); /*add ld(2^exp1)=exp1 but check format, first*/ - tmp16 = sub( sub( 15, norm_s( exp1 ) ), 5 ); /*factor to shift Ltmp and exp1 with (shr) to avoid overflows when adding*/ -#ifdef BASOP_NOGLOB - Ltmp = L_shr_o( Ltmp, tmp16, &Overflow ); /*Q25, tmp16*/ -#else - Ltmp = L_shr( Ltmp, tmp16 ); /*Q25, tmp16*/ -#endif - exp2 = shr( exp1, tmp16 ); /*Q0 , tmp16*/ -#ifdef BASOP_NOGLOB + tmp16 = sub( sub( 15, norm_s( exp1 ) ), 5 ); /*factor to shift Ltmp and exp1 with (shr) to avoid overflows when adding*/ + Ltmp = L_shr_o( Ltmp, tmp16, &Overflow ); /*Q25, tmp16*/ + exp2 = shr( exp1, tmp16 ); /*Q0 , tmp16*/ Ltmp = L_add_o( Ltmp, L_shl( L_deposit_l( exp2 ), 25 ), &Overflow ); /*Q25, tmp16, normalized*/ -#else - Ltmp = L_add( Ltmp, L_shl( L_deposit_l( exp2 ), 25 ) ); /*Q25, tmp16, normalized*/ -#endif /*make 10*log10 out of log2*/ - Ltmp = Mpy_32_16_1( Ltmp, LG10 ); /*Q25,tmp16 * Q13 = Q23, tmp16*/ -#ifdef BASOP_NOGLOB + Ltmp = Mpy_32_16_1( Ltmp, LG10 ); /*Q25,tmp16 * Q13 = Q23, tmp16*/ *frame_ener = extract_h( L_shl_o( Ltmp, add( tmp16, 1 ), &Overflow ) ); /*Q8*/ move16(); enern = sub_o( *frame_ener, lp_speech, &Overflow ); /*Q8*/ -#else - *frame_ener = extract_h( L_shl( Ltmp, add( tmp16, 1 ) ) ); /*Q8*/ - move16(); - enern = sub( *frame_ener, lp_speech ); /*Q8*/ -#endif return enern; } diff --git a/lib_com/frame_ener_fx.c b/lib_com/frame_ener_fx.c index e9075a02497f53a2a1858bf29e13a3a85b1b99ef..f89c1264b57461952421afec7104c975488202e3 100644 --- a/lib_com/frame_ener_fx.c +++ b/lib_com/frame_ener_fx.c @@ -161,18 +161,10 @@ Word16 frame_ener_fx( { pos = sub( L_frame, L_frame2 ); } -#ifdef BASOP_NOGLOB Ltmp = L_mult_sat( synth[pos], synth[pos] ); /*2 * Qnew + 1*/ -#else - Ltmp = L_mult( synth[pos], synth[pos] ); -#endif FOR( i = 1; i < L_frame2; i++ ) { -#ifdef BASOP_NOGLOB Ltmp = L_mac_sat( Ltmp, synth[pos + i], synth[pos + i] ); /*2 * Qnew + 1*/ -#else /* BASOP_NOGLOB */ - Ltmp = L_mac( Ltmp, synth[pos + i], synth[pos + i] ); -#endif } test(); IF( EQ_32( Ltmp, MAX_32 ) || enc != 0 ) @@ -255,11 +247,7 @@ Word16 frame_energy_fx( /* o : Frame energy in Q8 /* len = (0.5f * (pitch[2]/64.0 + pitch[3]/64.0) + 0.5f) */ -#ifdef BASOP_NOGLOB len = mult_r( add_o( pitch[2], pitch[3], &Overflow ), 256 ); -#else - len = mult_r( add( pitch[2], pitch[3] ), 256 ); -#endif if ( LT_16( len, L_SUBFR ) ) { @@ -289,30 +277,16 @@ Word16 frame_energy_fx( /* o : Frame energy in Q8 exp1 = sub( 15 + exp1, tmp2 ); /*add ld(2^exp1)=exp1 but check format, first*/ - tmp16 = sub( sub( 15, norm_s( exp1 ) ), 5 ); /*factor to shift Ltmp and exp1 with (shr) to avoid overflows when adding*/ -#ifdef BASOP_NOGLOB - Ltmp = L_shr_o( Ltmp, tmp16, &Overflow ); /*Q25, tmp16*/ -#else - Ltmp = L_shr( Ltmp, tmp16 ); /*Q25, tmp16*/ -#endif - exp2 = shr( exp1, tmp16 ); /*Q0 , tmp16*/ -#ifdef BASOP_NOGLOB + tmp16 = sub( sub( 15, norm_s( exp1 ) ), 5 ); /*factor to shift Ltmp and exp1 with (shr) to avoid overflows when adding*/ + Ltmp = L_shr_o( Ltmp, tmp16, &Overflow ); /*Q25, tmp16*/ + exp2 = shr( exp1, tmp16 ); /*Q0 , tmp16*/ Ltmp = L_add_o( Ltmp, L_shl( L_deposit_l( exp2 ), 25 ), &Overflow ); /*Q25, tmp16, normalized*/ -#else - Ltmp = L_add( Ltmp, L_shl( L_deposit_l( exp2 ), 25 ) ); /*Q25, tmp16, normalized*/ -#endif /*make 10*log10 out of log2*/ - Ltmp = Mpy_32_16_1( Ltmp, LG10 ); /*Q25,tmp16 * Q13 = Q23, tmp16*/ -#ifdef BASOP_NOGLOB + Ltmp = Mpy_32_16_1( Ltmp, LG10 ); /*Q25,tmp16 * Q13 = Q23, tmp16*/ *frame_ener = extract_h( L_shl_o( Ltmp, add( tmp16, 1 ), &Overflow ) ); /*Q8*/ move16(); enern = sub_o( *frame_ener, lp_speech, &Overflow ); /*Q8*/ -#else - *frame_ener = extract_h( L_shl( Ltmp, add( tmp16, 1 ) ) ); /*Q8*/ - move16(); - enern = sub( *frame_ener, lp_speech ); /*Q8*/ -#endif return enern; } diff --git a/lib_com/get_gain.c b/lib_com/get_gain.c index d222bd68d9f64dab5fc2c943f2220092ae65774a..bf4c1adfb23f959a50a7274573a5e38af2e635ce 100644 --- a/lib_com/get_gain.c +++ b/lib_com/get_gain.c @@ -98,13 +98,8 @@ Word32 get_gain( /* output: codebook gain (adaptive or fixed) tcorr = Dot_product16HQ( 0, x, y, n, &exp_c ); tener = Dot_productSq16HQ( 0, y, n, &exp_e ); -#ifdef BASOP_NOGLOB BASOP_Util_Divide_MantExp( round_fx_o( tcorr, &Overflow ), exp_c, s_max( round_fx_o( tener, &Overflow ), 1 ), exp_e, &tmp, &exp ); Lgain = L_shl_o( L_deposit_l( tmp ) /*Q15*/, add( 1, exp ), &Overflow ) /*Q16*/; -#else - BASOP_Util_Divide_MantExp( round_fx( tcorr ), exp_c, s_max( round_fx( tener ), 1 ), exp_e, &tmp, &exp ); - Lgain = L_shl( L_deposit_l( tmp ) /*Q15*/, add( 1, exp ) ) /*Q16*/; -#endif return Lgain; } @@ -163,11 +158,7 @@ Word32 get_gain2( /* output: codebook gain (adaptive or fixed) Q_corr = sub( Q_corr, Q_ener ); -#ifdef BASOP_NOGLOB Lgain = L_shl_o( L_deposit_l( m_corr ), add( Q_corr, 1 ), &Overflow ); /* Lgain in Q16 */ -#else - Lgain = L_shl( L_deposit_l( m_corr ), add( Q_corr, 1 ) ); /* Lgain in Q16 */ -#endif if ( negative != 0 ) { diff --git a/lib_com/get_gain_fx.c b/lib_com/get_gain_fx.c index be4d063e75f103c5905a7d52f8cd3cde6d4eaa9d..66abe96aeb74465a414770580fc32ae99a3e2d73 100644 --- a/lib_com/get_gain_fx.c +++ b/lib_com/get_gain_fx.c @@ -71,13 +71,8 @@ Word32 get_gain( /* output: codebook gain (adaptive or fixed) tcorr = Dot_product16HQ( 0, x, y, n, &exp_c ); tener = Dot_productSq16HQ( 0, y, n, &exp_e ); -#ifdef BASOP_NOGLOB BASOP_Util_Divide_MantExp( round_fx_o( tcorr, &Overflow ), exp_c, s_max( round_fx_o( tener, &Overflow ), 1 ), exp_e, &tmp, &exp ); Lgain = L_shl_o( L_deposit_l( tmp ) /*Q15*/, add( 1, exp ), &Overflow ) /*Q16*/; -#else - BASOP_Util_Divide_MantExp( round_fx( tcorr ), exp_c, s_max( round_fx( tener ), 1 ), exp_e, &tmp, &exp ); - Lgain = L_shl( L_deposit_l( tmp ) /*Q15*/, add( 1, exp ) ) /*Q16*/; -#endif return Lgain; } @@ -136,11 +131,7 @@ Word32 get_gain2( /* output: codebook gain (adaptive or fixed) Q_corr = sub( Q_corr, Q_ener ); -#ifdef BASOP_NOGLOB Lgain = L_shl_o( L_deposit_l( m_corr ), add( Q_corr, 1 ), &Overflow ); /* Lgain in Q16 */ -#else - Lgain = L_shl( L_deposit_l( m_corr ), add( Q_corr, 1 ) ); /* Lgain in Q16 */ -#endif if ( negative != 0 ) { diff --git a/lib_com/gs_bitallocation_fx.c b/lib_com/gs_bitallocation_fx.c index 5bd82fdab724b3e4a871d45e85d42b7ef077c81e..47d3679a8289eff3a9131a3cb23f86eab3c5e7cb 100644 --- a/lib_com/gs_bitallocation_fx.c +++ b/lib_com/gs_bitallocation_fx.c @@ -95,12 +95,8 @@ void bands_and_bit_alloc_fx( set16_fx( out_bits_per_bands, 0, MBANDS_GN_BITALLOC16k ); /* To adapt current energy band to PVQ freq band for sorting*/ -#ifdef BASOP_NOGLOB ener_vec[0] = add_o( Ener_per_bd_iQ[0], Ener_per_bd_iQ[1], &Overflow ); /*Q12 */ -#else /* BASOP_NOGLOB */ - ener_vec[0] = add( Ener_per_bd_iQ[0], Ener_per_bd_iQ[1] ); /*Q12 */ -#endif - Copy( Ener_per_bd_iQ_tmp + 1, ener_vec, MBANDS_GN - 1 ); /*Q12 */ + Copy( Ener_per_bd_iQ_tmp + 1, ener_vec, MBANDS_GN - 1 ); /*Q12 */ ener_vec[MBANDS_GN - 1] = ener_vec[MBANDS_GN - 2]; move16(); IF( EQ_16( L_frame, L_FRAME16k ) ) diff --git a/lib_com/gs_bitallocation_ivas_fx.c b/lib_com/gs_bitallocation_ivas_fx.c index 787d562c74404faf382b0a45929405c3fe75ceed..0ab1670151c5e748105ad5463fa21ba9232e3ed3 100644 --- a/lib_com/gs_bitallocation_ivas_fx.c +++ b/lib_com/gs_bitallocation_ivas_fx.c @@ -122,11 +122,7 @@ void bands_and_bit_alloc_ivas_fx( set16_fx( out_bits_per_bands, 0, MBANDS_GN_BITALLOC16k ); /* To adapt current energy band to PVQ freq band for sorting*/ -#ifdef BASOP_NOGLOB ener_vec[0] = add_o( Ener_per_bd_iQ[0], Ener_per_bd_iQ[1], &Overflow ); /*Q12 */ -#else /* BASOP_NOGLOB */ - ener_vec[0] = add( Ener_per_bd_iQ[0], Ener_per_bd_iQ[1] ); /*Q12 */ -#endif move16(); Copy( Ener_per_bd_iQ + 1, ener_vec, MBANDS_GN - 1 ); /*Q12 */ ener_vec[MBANDS_GN - 1] = ener_vec[MBANDS_GN - 2]; diff --git a/lib_com/gs_gains_fx.c b/lib_com/gs_gains_fx.c index 8e603e15c957782c1dfac68f08c646f84724ac08..d6aee58c535eba68c520ef4a9775314834db8364 100644 --- a/lib_com/gs_gains_fx.c +++ b/lib_com/gs_gains_fx.c @@ -104,13 +104,8 @@ void Comp_and_apply_gain_fx( FOR( i = StartBin; i < NB_Qbins + StartBin; i++ ) { -#ifdef BASOP_NOGLOB L32 = L_shl_o( L_mult( exc_diffQ[i], y_gain ), tmp_exp, &Overflow ); /*Q_exc+16 */ exc_diffQ[i] = round_fx_o( L32, &Overflow ); /*Q_exc */ -#else /* BASOP_NOGLOB */ - L32 = L_shl( L_mult( exc_diffQ[i], y_gain ), tmp_exp ); /*Q_exc+16 */ - exc_diffQ[i] = round_fx( L32 ); /*Q_exc */ -#endif /* BASOP_NOGLOB */ move16(); } } @@ -127,23 +122,15 @@ void Comp_and_apply_gain_fx( y_gain = extract_l( Pow2( 14, frac ) ); /* Put 14 as exponent so that */ /* output of Pow2() will be: */ /* 16384 < Pow2() <= 32767 */ -#ifdef BASOP_NOGLOB Ener_per_bd_yQ[i_band] = shl_o( y_gain, sub( exp1, 13 ), &Overflow ); -#else /* BASOP_NOGLOB */ - Ener_per_bd_yQ[i_band] = shl( y_gain, sub( exp1, 13 ) ); -#endif /* BASOP_NOGLOB */ move16(); /*Q1 */ tmp_exp = add( add( exp1, 1 ), sub( Q_exc, Qexc_diff ) ); FOR( i = StartBin; i < NB_Qbins + StartBin; i++ ) { - L32 = L_mult( exc_diffQ[i], y_gain ); /*Qexc_diff+15 */ -#ifdef BASOP_NOGLOB + L32 = L_mult( exc_diffQ[i], y_gain ); /*Qexc_diff+15 */ exc_diffQ[i] = round_fx_o( L_shl_o( L32, tmp_exp, &Overflow ), &Overflow ); /*Q_exc */ move16(); -#else /* BASOP_NOGLOB */ - exc_diffQ[i] = round_fx( L_shl( L32, tmp_exp ) ); /*Q_exc */ -#endif } } } @@ -190,13 +177,8 @@ void Comp_and_apply_gain_ivas_fx( FOR( i = StartBin; i < NB_Qbins + StartBin; i++ ) { -#ifdef BASOP_NOGLOB L32 = L_mult( exc_diffQ[i], y_gain ); /*Q_exc+16-tmp_exp */ exc_diffQ[i] = round_fx_o( L32, &Overflow ); /*Q_exc-tmp_exp */ -#else /* BASOP_NOGLOB */ - L32 = L_mult( exc_diffQ[i], y_gain ); /*Q_exc+16 */ - exc_diffQ[i] = round_fx( L32 ); /*Q_exc */ -#endif /* BASOP_NOGLOB */ move16(); IF( exc_diffQ[i] ) { @@ -215,29 +197,21 @@ void Comp_and_apply_gain_ivas_fx( * y_gain = pow(10.0, (Ener_per_bd_iQ[i_band]-Ener_per_bd_yQ[i_band])) * = pow(2, 3.321928*(Ener_per_bd_iQ[i_band]-Ener_per_bd_yQ[i_band])) *-----------------------------------------------------------------*/ - L16 = sub_sat( Ener_per_bd_iQ[i_band], Ener_per_bd_yQ[i_band] ); /*Q12 */ - L32 = L_mult( L16, 27213 ); /* 3.321928 in Q13 -> Q26 */ - L32 = L_shr( L32, 10 ); /* From Q26 to Q16 */ - frac = L_Extract_lc( L32, &exp1 ); /* Extract exponent of gcode0 */ - y_gain = extract_l( Pow2( 14, frac ) ); /* Put 14 as exponent so that */ - /* output of Pow2() will be: */ - /* 16384 < Pow2() <= 32767 */ -#ifdef BASOP_NOGLOB + L16 = sub_sat( Ener_per_bd_iQ[i_band], Ener_per_bd_yQ[i_band] ); /*Q12 */ + L32 = L_mult( L16, 27213 ); /* 3.321928 in Q13 -> Q26 */ + L32 = L_shr( L32, 10 ); /* From Q26 to Q16 */ + frac = L_Extract_lc( L32, &exp1 ); /* Extract exponent of gcode0 */ + y_gain = extract_l( Pow2( 14, frac ) ); /* Put 14 as exponent so that */ + /* output of Pow2() will be: */ + /* 16384 < Pow2() <= 32767 */ Ener_per_bd_yQ[i_band] = shl_o( y_gain, sub( exp1, 13 ), &Overflow ); /*Q13*/ -#else /* BASOP_NOGLOB */ - Ener_per_bd_yQ[i_band] = shl( y_gain, sub( exp1, 13 ) ); -#endif /* BASOP_NOGLOB */ move16(); /*Q1 */ tmp_exp = add( add( exp1, 1 ), sub( *Q_exc, Qexc_diff ) ); FOR( i = StartBin; i < NB_Qbins + StartBin; i++ ) { - L32 = L_mult( exc_diffQ[i], y_gain ); /*Qexc_diff+15 */ -#ifdef BASOP_NOGLOB + L32 = L_mult( exc_diffQ[i], y_gain ); /*Qexc_diff+15 */ exc_diffQ[i] = round_fx_o( L32, &Overflow ); /*Q_exc-tmp_exp */ -#else /* BASOP_NOGLOB */ - exc_diffQ[i] = round_fx( L_shl( L32, tmp_exp ) ); /*Q_exc */ -#endif move16(); IF( exc_diffQ[i] ) { diff --git a/lib_com/gs_inact_switching_fx.c b/lib_com/gs_inact_switching_fx.c index 18bff8d43c5a53393d593f2cc7ea841c3e2ad445..c0feb91f53993f4027fe1d1f6818023af94b5e13 100644 --- a/lib_com/gs_inact_switching_fx.c +++ b/lib_com/gs_inact_switching_fx.c @@ -129,14 +129,9 @@ void Inac_swtch_ematch_fx( { FOR( j = 0; j < 8; j++ ) { - L_tmp = L_mult( *pt_exc, ftmp ); /* Q_exc*Q0 -> Q(Q_exc+1) */ -#ifdef BASOP_NOGLOB + L_tmp = L_mult( *pt_exc, ftmp ); /* Q_exc*Q0 -> Q(Q_exc+1) */ L_tmp = L_shl_sat( L_tmp, add( exp, 15 ) ); /* Q(Q_exc+1) -> Q(16+Q_exc)*/ *pt_exc = round_fx_sat( L_tmp ); -#else - L_tmp = L_shl( L_tmp, add( exp, 15 ) ); /* Q(Q_exc+1) -> Q(16+Q_exc)*/ - *pt_exc = round_fx( L_tmp ); -#endif move16(); pt_exc++; } @@ -145,14 +140,9 @@ void Inac_swtch_ematch_fx( { FOR( j = 0; j < 16; j++ ) { - L_tmp = L_mult( *pt_exc, ftmp ); /* Q_exc*Q0 -> Q(Q_exc+1) */ -#ifdef BASOP_NOGLOB + L_tmp = L_mult( *pt_exc, ftmp ); /* Q_exc*Q0 -> Q(Q_exc+1) */ L_tmp = L_shl_sat( L_tmp, add( exp, 15 ) ); /* Q(Q_exc+1) -> Q(16+Q_exc)*/ *pt_exc = round_fx_sat( L_tmp ); /*Q_exc*/ -#else - L_tmp = L_shl( L_tmp, add( exp, 15 ) ); /* Q(Q_exc+1) -> Q(16+Q_exc)*/ - *pt_exc = round_fx( L_tmp ); /*Q_exc*/ -#endif move16(); pt_exc++; } @@ -172,15 +162,17 @@ void Inac_switch_ematch_ivas_fx( 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 L_frame, /* i : Frame lenght */ - const Word32 total_brate, /* i : total bit rate */ - 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 */ - , +#ifdef NONBE_FIX_GSC_BSTR + 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 */ ) @@ -232,7 +224,11 @@ void Inac_switch_ematch_ivas_fx( move16(); } } +#ifdef NONBE_FIX_GSC_BSTR + ELSE IF( ( coder_type == INACTIVE ) && inactive_coder_type_flag ) +#else ELSE IF( ( coder_type == INACTIVE ) && LE_32( total_brate, MAX_GSC_INACTIVE_BRATE ) ) +#endif { /* Find spectrum and energy per band for inactive frames */ edct_16fx( exc2, dct_exc_tmp, L_frame, 5, element_mode ); diff --git a/lib_com/gs_noisefill_fx.c b/lib_com/gs_noisefill_fx.c index 3761debf22ac219f23d2cbff1b1af687065c3554..d2a576dbe94521f4280f2ad50e0b3b6fbdf77a37 100644 --- a/lib_com/gs_noisefill_fx.c +++ b/lib_com/gs_noisefill_fx.c @@ -470,15 +470,11 @@ static void Decreas_freqPeak_fx( { tmp = abs_s( *src ); exp = norm_s( max_val ); - tmp1 = div_s( shl( 1, sub( 14, exp ) ), max_val ); /*Q(29 - exp - Q_exc) */ - L_tmp = L_mult( tmp, tmp1 ); /*Q(30 - exp) */ -#ifdef BASOP_NOGLOB + tmp1 = div_s( shl( 1, sub( 14, exp ) ), max_val ); /*Q(29 - exp - Q_exc) */ + L_tmp = L_mult( tmp, tmp1 ); /*Q(30 - exp) */ tmp = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /*Q14 */ -#else - tmp = round_fx( L_shl( L_tmp, exp ) ); /*Q14 */ -#endif - tmp = sub( 32767, tmp ); /*Q14 */ - L_tmp = L_mult( avrg, tmp ); /*Q_exc +15 */ + tmp = sub( 32767, tmp ); /*Q14 */ + L_tmp = L_mult( avrg, tmp ); /*Q_exc +15 */ tmp = round_fx( L_shl( L_tmp, 1 ) ); tmp1 = negate( tmp ); @@ -569,11 +565,7 @@ static void envelop_modify_fx( /* output of Pow2() will be: */ /* 16384 < Pow2() <= 32767 */ exp = sub( exp, 14 ); -#ifdef BASOP_NOGLOB Ener1_fx = mult_ro( 13107, shl_o( tmp, exp, &Overflow ), &Overflow ); /*Q0 */ -#else /* BASOP_NOGLOB */ - Ener1_fx = mult_r( 13107, shl( tmp, exp ) ); /*Q0 */ -#endif /* BASOP_NOGLOB */ FOR( j = 0; j < 16; j++ ) { @@ -599,11 +591,7 @@ static void envelop_modify_fx( /* output of Pow2() will be: */ /* 16384 < Pow2() <= 32767 */ exp = sub( exp, 14 ); -#ifdef BASOP_NOGLOB Ener1_fx = mult_r( 13107, shl_o( tmp, exp, &Overflow ) ); /*Q0 */ -#else /* BASOP_NOGLOB */ - Ener1_fx = mult_r( 13107, shl( tmp, exp ) ); /*Q0 */ -#endif /* BASOP_NOGLOB */ src_fx = &exc_diffQ_fx[224]; FOR( j = 0; j < 32; j++ ) @@ -720,17 +708,9 @@ void highband_exc_dct_in_fx( /* output of Pow2() will be: */ /* 16384 < Pow2() <= 32767 */ exp = sub( exp, 14 ); -#ifdef BASOP_NOGLOB tmp1 = shl_o( tmp, exp, &Overflow ); -#else /* BASOP_NOGLOB */ - tmp1 = shl( tmp, exp ); -#endif /* BASOP_NOGLOB */ move16(); -#ifdef BASOP_NOGLOB ener = add_o( tmp1, ener, &Overflow ); /*Q0 */ -#else /* BASOP_NOGLOB */ - ener = add( tmp1, ener ); /*Q0 */ -#endif /* BASOP_NOGLOB */ } test(); @@ -1019,14 +999,10 @@ void highband_exc_dct_in_fx( FOR( i = sub( L_FRAME, 16 ); i < L_FRAME; i++ ) { /*exc_dct_in[i] *= (0.067f*i-15.f); */ - tmp = mult_r( 17564, shl( i, 6 ) ); /*0.067 in Q18 and i in Q6= Q9 */ - tmp = sub( tmp, 7680 ); /*15 in Q9 = Q9 */ - L_tmp = L_mult( exc_dct_in[i], tmp ); /*Q(Q_exc+10) */ -#ifdef BASOP_NOGLOB + tmp = mult_r( 17564, shl( i, 6 ) ); /*0.067 in Q18 and i in Q6= Q9 */ + tmp = sub( tmp, 7680 ); /*15 in Q9 = Q9 */ + L_tmp = L_mult( exc_dct_in[i], tmp ); /*Q(Q_exc+10) */ exc_dct_in[i] = round_fx_o( L_shl_o( L_tmp, 6, &Overflow ), &Overflow ); /*Q_exc */ -#else /* BASOP_NOGLOB */ - exc_dct_in[i] = round_fx( L_shl( L_tmp, 6 ) ); /*Q_exc */ -#endif /* BASOP_NOGLOB */ } } @@ -1061,15 +1037,9 @@ void highband_exc_dct_in_fx( IF( GT_16( tmp, abs_s( *dst ) ) ) { tmp2 = *src; -#ifdef BASOP_NOGLOB *src = mult_r( 16384, sub_o( *src, abs_s( *dst ), &Overflow ) ); /*Q_exc */ move16(); tmp = mult_r( 16384, add_o( tmp2, abs_s( *dst ), &Overflow ) ); /*Q_exc */ -#else /* BASOP_NOGLOB */ - *src = mult_r( 16384, sub( *src, abs_s( *dst ) ) ); /*Q_exc */ - move16(); - tmp = mult_r( 16384, add( tmp2, abs_s( *dst ) ) ); /*Q_exc */ -#endif if ( tmp2 > 0 ) { *src = tmp; @@ -1176,17 +1146,9 @@ void highband_exc_dct_in_ivas_fx( /* output of Pow2() will be: */ /* 16384 < Pow2() <= 32767 */ exp = sub( exp, 14 ); -#ifdef BASOP_NOGLOB tmp1 = shl_o( tmp, exp, &Overflow ); -#else /* BASOP_NOGLOB */ - tmp1 = shl( tmp, exp ); -#endif /* BASOP_NOGLOB */ move16(); -#ifdef BASOP_NOGLOB ener = add_o( tmp1, ener, &Overflow ); /*Q0 */ -#else /* BASOP_NOGLOB */ - ener = add( tmp1, ener ); /*Q0 */ -#endif /* BASOP_NOGLOB */ } test(); @@ -1533,14 +1495,10 @@ void highband_exc_dct_in_ivas_fx( FOR( i = sub( L_FRAME, 16 ); i < L_FRAME; i++ ) { /*exc_dct_in[i] *= (0.067f*i-15.f); */ - tmp = mult_r( 17564, shl( i, 6 ) ); /*0.067 in Q18 and i in Q6= Q9 */ - tmp = sub( tmp, 7680 ); /*15 in Q9 = Q9 */ - L_tmp = L_mult( exc_dct_in[i], tmp ); /*Q(Q_exc+10) */ -#ifdef BASOP_NOGLOB + tmp = mult_r( 17564, shl( i, 6 ) ); /*0.067 in Q18 and i in Q6= Q9 */ + tmp = sub( tmp, 7680 ); /*15 in Q9 = Q9 */ + L_tmp = L_mult( exc_dct_in[i], tmp ); /*Q(Q_exc+10) */ exc_dct_in[i] = round_fx_o( L_shl_o( L_tmp, 6, &Overflow ), &Overflow ); /*Q_exc */ -#else /* BASOP_NOGLOB */ - exc_dct_in[i] = round_fx( L_shl( L_tmp, 6 ) ); /*Q_exc */ -#endif /* BASOP_NOGLOB */ } } @@ -1575,15 +1533,9 @@ void highband_exc_dct_in_ivas_fx( IF( GT_16( tmp, abs_s( *dst ) ) ) { tmp2 = *src; -#ifdef BASOP_NOGLOB *src = mult_r( 16384, sub_o( *src, abs_s( *dst ), &Overflow ) ); /*Q_exc */ move16(); tmp = mult_r( 16384, add_o( tmp2, abs_s( *dst ), &Overflow ) ); /*Q_exc */ -#else /* BASOP_NOGLOB */ - *src = mult_r( 16384, sub( *src, abs_s( *dst ) ) ); /*Q_exc */ - move16(); - tmp = mult_r( 16384, add( tmp2, abs_s( *dst ) ) ); /*Q_exc */ -#endif IF( tmp2 > 0 ) { *src = tmp; diff --git a/lib_com/gs_preech.c b/lib_com/gs_preech.c index 092558fb85c4a12571164954832f0eeb71419692..a2b2405dbb2d01d254f03b431be60874bff1260a 100644 --- a/lib_com/gs_preech.c +++ b/lib_com/gs_preech.c @@ -195,11 +195,7 @@ void pre_echo_att_fx( etmp_fx = L_shr( etmp_fx, add( 2 + 1 - 4, shl( Q_new, 1 ) ) ); /*2*Q_new+1 //INV_ATT_SEG_LEN=1/4(=shr(x,2)) -> Q4 */ etmp1_fx = etmp_fx; move32(); -#ifdef BASOP_NOGLOB *Last_frame_ener_fx = L_shl_sat( *Last_frame_ener_fx, 2 ); -#else - *Last_frame_ener_fx = L_shl( *Last_frame_ener_fx, 2 ); -#endif move32(); /*2*Q_new+1 */ /* If the maximum normalized energy > last frame energy + 6dB */ @@ -227,11 +223,7 @@ void pre_echo_att_fx( exp = sub( n1, n2 ); frac1 = round_fx( L_shl( etmp_fx, n1 ) ); -#ifdef BASOP_NOGLOB frac2 = round_fx_sat( L_shl_sat( *Last_frame_ener_fx, n2 ) ); -#else - frac2 = round_fx( L_shl( *Last_frame_ener_fx, n2 ) ); -#endif L_tmp = L_mult0( 128, div_s( frac1, frac2 ) ); /* s = gain_out / gain_in */ L_tmp = L_shr( L_tmp, exp ); /* add exponent */ @@ -320,11 +312,7 @@ void pre_echo_att_ivas_fx( etmp_fx = L_shr( etmp_fx, add( 2 + 1 - 4, shl( Q_new, 1 ) ) ); /*2*Q_new+1 //INV_ATT_SEG_LEN=1/4(=shr(x,2)) -> Q4 */ etmp1_fx = etmp_fx; move32(); -#ifdef BASOP_NOGLOB *Last_frame_ener_fx = L_shl_sat( *Last_frame_ener_fx, 2 ); -#else - *Last_frame_ener_fx = L_shl( *Last_frame_ener_fx, 2 ); -#endif move32(); /*2*Q_new+1 */ /* If the maximum normalized energy > last frame energy + 6dB */ @@ -352,11 +340,7 @@ void pre_echo_att_ivas_fx( exp = sub( n1, n2 ); frac1 = round_fx( L_shl( etmp_fx, n1 ) ); -#ifdef BASOP_NOGLOB frac2 = round_fx_sat( L_shl_sat( *Last_frame_ener_fx, n2 ) ); -#else - frac2 = round_fx( L_shl( *Last_frame_ener_fx, n2 ) ); -#endif L_tmp = L_mult0( 128, div_s( frac1, frac2 ) ); /* s = gain_out / gain_in */ L_tmp = L_shr( L_tmp, exp ); /* add exponent */ diff --git a/lib_com/gs_preech_fx.c b/lib_com/gs_preech_fx.c index 548cba204f55601d6cfc57deb9ea5944478db8bf..a75604a14c0bf3c69e437c7950479962bdf92b7b 100644 --- a/lib_com/gs_preech_fx.c +++ b/lib_com/gs_preech_fx.c @@ -101,11 +101,7 @@ void pre_echo_att_fx( etmp_fx = L_shr( etmp_fx, add( 2 + 1 - 4, shl( Q_new, 1 ) ) ); /*2*Q_new+1 //INV_ATT_SEG_LEN=1/4(=shr(x,2)) -> Q4 */ etmp1_fx = etmp_fx; move32(); -#ifdef BASOP_NOGLOB *Last_frame_ener_fx = L_shl_sat( *Last_frame_ener_fx, 2 ); -#else - *Last_frame_ener_fx = L_shl( *Last_frame_ener_fx, 2 ); -#endif move32(); /*2*Q_new+1 */ /* If the maximum normalized energy > last frame energy + 6dB */ @@ -133,11 +129,7 @@ void pre_echo_att_fx( exp = sub( n1, n2 ); frac1 = round_fx( L_shl( etmp_fx, n1 ) ); -#ifdef BASOP_NOGLOB frac2 = round_fx_sat( L_shl_sat( *Last_frame_ener_fx, n2 ) ); -#else - frac2 = round_fx( L_shl( *Last_frame_ener_fx, n2 ) ); -#endif L_tmp = L_mult0( 128, div_s( frac1, frac2 ) ); /* s = gain_out / gain_in */ L_tmp = L_shr( L_tmp, exp ); /* add exponent */ @@ -226,11 +218,7 @@ void pre_echo_att_ivas_fx( etmp_fx = L_shr( etmp_fx, add( 2 + 1 - 4, shl( Q_new, 1 ) ) ); /*2*Q_new+1 //INV_ATT_SEG_LEN=1/4(=shr(x,2)) -> Q4 */ etmp1_fx = etmp_fx; move32(); -#ifdef BASOP_NOGLOB *Last_frame_ener_fx = L_shl_sat( *Last_frame_ener_fx, 2 ); -#else - *Last_frame_ener_fx = L_shl( *Last_frame_ener_fx, 2 ); -#endif move32(); /*2*Q_new+1 */ /* If the maximum normalized energy > last frame energy + 6dB */ @@ -258,11 +246,7 @@ void pre_echo_att_ivas_fx( exp = sub( n1, n2 ); frac1 = round_fx( L_shl( etmp_fx, n1 ) ); -#ifdef BASOP_NOGLOB frac2 = round_fx_sat( L_shl_sat( *Last_frame_ener_fx, n2 ) ); -#else - frac2 = round_fx( L_shl( *Last_frame_ener_fx, n2 ) ); -#endif L_tmp = L_mult0( 128, div_s( frac1, frac2 ) ); /* s = gain_out / gain_in */ L_tmp = L_shr( L_tmp, exp ); /* add exponent */ diff --git a/lib_com/hp50.c b/lib_com/hp50.c index 02c11ce6cb3427c6706d659f70056eb300c73ef5..cd9ed3e986a90ab62065568ae92afa93092b4c71 100644 --- a/lib_com/hp50.c +++ b/lib_com/hp50.c @@ -199,18 +199,10 @@ static void filter_2nd_order( L_sum = L_add( L_sum, HP50_Mpy_32_32_fix( mem[0], a2 ) ); /* y2*a2 */ L_sum = L_add( L_sum, HP50_Mpy_32_32_fix( mem[1], a1 ) ); /* y1*a1 */ -#ifdef BASOP_NOGLOB L_y2 = L_shl_o( L_sum, HP20_COEFF_SCALE, &Overflow ); -#else - L_y2 = L_shl( L_sum, HP20_COEFF_SCALE ); -#endif BASOP_SATURATE_ERROR_OFF_EVS BASOP_SATURATE_WARNING_OFF_EVS -#ifdef BASOP_NOGLOB signal[0] = round_fx_o( L_shl_o( L_y2, prescale, &Overflow ), &Overflow ); -#else /* BASOP_NOGLOB */ - signal[0] = round_fx( L_shl( L_y2, prescale ) ); -#endif /* BASOP_NOGLOB */ BASOP_SATURATE_WARNING_ON_EVS BASOP_SATURATE_ERROR_ON_EVS @@ -221,18 +213,10 @@ static void filter_2nd_order( L_sum = L_add( L_sum, HP50_Mpy_32_32_fix( mem[1], a2 ) ); /* y2*a2 */ L_sum = L_add( L_sum, HP50_Mpy_32_32_fix( L_y2, a1 ) ); /* y1*a1 */ -#ifdef BASOP_NOGLOB L_y1 = L_shl_o( L_sum, HP20_COEFF_SCALE, &Overflow ); -#else - L_y1 = L_shl( L_sum, HP20_COEFF_SCALE ); -#endif BASOP_SATURATE_ERROR_OFF_EVS BASOP_SATURATE_WARNING_OFF_EVS -#ifdef BASOP_NOGLOB signal[stride] = round_fx_o( L_shl_o( L_y1, prescale, &Overflow ), &Overflow ); -#else /* BASOP_NOGLOB */ - signal[stride] = round_fx( L_shl( L_y1, prescale ) ); -#endif /* BASOP_NOGLOB */ BASOP_SATURATE_WARNING_ON_EVS move16(); @@ -248,19 +232,10 @@ static void filter_2nd_order( L_sum = L_add( L_sum, HP50_Mpy_32_32_fix( L_y2, a2 ) ); L_sum = L_add( L_sum, HP50_Mpy_32_32_fix( L_y1, a1 ) ); -#ifdef BASOP_NOGLOB L_y2 = L_shl_o( L_sum, HP20_COEFF_SCALE, &Overflow ); -#else - L_y2 = L_shl( L_sum, HP20_COEFF_SCALE ); -#endif BASOP_SATURATE_ERROR_OFF_EVS BASOP_SATURATE_WARNING_OFF_EVS -#ifdef BASOP_NOGLOB signal[i_mult( i, stride )] = round_fx_o( L_shl_o( L_y2, prescale, &Overflow ), &Overflow ); -#else /* BASOP_NOGLOB */ - signal[i_mult( i, stride )] = round_fx( L_shl( L_y2, prescale ) ); - move16(); -#endif /* BASOP_NOGLOB */ BASOP_SATURATE_WARNING_ON_EVS /* y[i+1] = b2*x[i-1] + b1*x[i-0] + b2*x[i+1] + a2*y[i-1] + a1*y[i+0]; */ BASOP_SATURATE_ERROR_ON_EVS @@ -271,18 +246,10 @@ static void filter_2nd_order( L_sum = L_add( L_sum, HP50_Mpy_32_32_fix( L_y1, a2 ) ); L_sum = L_add( L_sum, HP50_Mpy_32_32_fix( L_y2, a1 ) ); -#ifdef BASOP_NOGLOB L_y1 = L_shl_o( L_sum, HP20_COEFF_SCALE, &Overflow ); -#else - L_y1 = L_shl( L_sum, HP20_COEFF_SCALE ); -#endif BASOP_SATURATE_ERROR_OFF_EVS BASOP_SATURATE_WARNING_OFF_EVS -#ifdef BASOP_NOGLOB signal[i_mult( add( i, 1 ), stride )] = round_fx_o( L_shl_o( L_y1, prescale, &Overflow ), &Overflow ); -#else /* BASOP_NOGLOB */ - signal[i_mult( add( i, 1 ), stride )] = round_fx( L_shl( L_y1, prescale ) ); -#endif BASOP_SATURATE_WARNING_ON_EVS move16(); } @@ -322,20 +289,12 @@ void hp20( Word16 signal[], /* i/o: signal to filter any * prescale = getScaleFactor16( signal, lg ); prescaleOld = extract_l( mem[4] ); -#ifdef BASOP_NOGLOB diff = norm_l( L_shl_sat( mem[2], prescaleOld ) ); -#else - diff = norm_l( L_shl( mem[2], prescaleOld ) ); -#endif if ( mem[2] != 0 ) { prescale = s_min( prescale, diff ); } -#ifdef BASOP_NOGLOB diff = norm_l( L_shl_o( mem[3], prescaleOld, &Overflow ) ); -#else - diff = norm_l( L_shl( mem[3], prescaleOld ) ); -#endif if ( mem[3] != 0 ) { prescale = s_min( prescale, diff ); @@ -345,7 +304,6 @@ void hp20( Word16 signal[], /* i/o: signal to filter any * IF( prescale != prescaleOld ) { diff = sub( prescale, prescaleOld ); -#ifdef BASOP_NOGLOB mem[0] = L_shr_o( mem[0], diff, &Overflow ); move32(); mem[1] = L_shr_o( mem[1], diff, &Overflow ); @@ -354,16 +312,6 @@ void hp20( Word16 signal[], /* i/o: signal to filter any * move32(); mem[3] = L_shr_o( mem[3], diff, &Overflow ); move32(); -#else - mem[0] = L_shr( mem[0], diff ); - move32(); - mem[1] = L_shr( mem[1], diff ); - move32(); - mem[2] = L_shr( mem[2], diff ); - move32(); - mem[3] = L_shr( mem[3], diff ); - move32(); -#endif mem[4] = L_deposit_l( prescale ); } @@ -447,9 +395,7 @@ void hp20_fx_32( Word32 i; Word32 a1_fx, a2_fx, b1_fx, b2_fx; Word32 diff_pos, diff_neg; -#ifdef BASOP_NOGLOB Flag Overflow = 0; -#endif Word16 prescale, prescaleOld, prescale_current_frame, diff; prescale = getScaleFactor32( signal_fx, lg ); @@ -458,13 +404,8 @@ void hp20_fx_32( prescaleOld = extract_l( mem_fx[4] ); -#ifdef BASOP_NOGLOB diff_pos = norm_l( L_shl_o( L_max( mem_fx[2], mem_fx[3] ), prescaleOld, &Overflow ) ); diff_neg = norm_l( L_shl_o( L_min( mem_fx[2], mem_fx[3] ), prescaleOld, &Overflow ) ); -#else - diff_pos = norm_l( L_shl( L_max( mem_fx[2], mem_fx[3] ), prescaleOld ) ); - diff_neg = norm_l( L_shl( L_min( mem_fx[2], mem_fx[3] ), prescaleOld ) ); -#endif diff = L_max( diff_pos, diff_neg ); @@ -476,7 +417,6 @@ void hp20_fx_32( prescale = s_min( 3, sub( 1 + HP20_COEFF_SCALE, prescale ) ); diff = sub( prescale, prescaleOld ); -#ifdef BASOP_NOGLOB mem_fx[0] = L_shr_o( mem_fx[0], diff, &Overflow ); move32(); mem_fx[1] = L_shr_o( mem_fx[1], diff, &Overflow ); @@ -485,16 +425,6 @@ void hp20_fx_32( move32(); mem_fx[3] = L_shr_o( mem_fx[3], diff, &Overflow ); move32(); -#else - mem_fx[0] = L_shr( mem_fx[0], diff ); - move32(); - mem_fx[1] = L_shr( mem_fx[1], diff ); - move32(); - mem_fx[2] = L_shr( mem_fx[2], diff ); - move32(); - mem_fx[3] = L_shr( mem_fx[3], diff ); - move32(); -#endif mem_fx[4] = L_deposit_l( prescale_current_frame ); move32(); diff --git a/lib_com/hp50_fx.c b/lib_com/hp50_fx.c index 78e358a80881101ca146b9e16c50d2452ec748bf..a1700047ee4b4e8dfe831139bd6c201b222faeb9 100644 --- a/lib_com/hp50_fx.c +++ b/lib_com/hp50_fx.c @@ -118,18 +118,10 @@ static void filter_2nd_order( L_sum = L_add( L_sum, HP50_Mpy_32_32_fix( mem[0], a2 ) ); /* y2*a2 */ L_sum = L_add( L_sum, HP50_Mpy_32_32_fix( mem[1], a1 ) ); /* y1*a1 */ -#ifdef BASOP_NOGLOB L_y2 = L_shl_o( L_sum, HP20_COEFF_SCALE, &Overflow ); -#else - L_y2 = L_shl( L_sum, HP20_COEFF_SCALE ); -#endif BASOP_SATURATE_ERROR_OFF_EVS BASOP_SATURATE_WARNING_OFF_EVS -#ifdef BASOP_NOGLOB signal[0] = round_fx_o( L_shl_o( L_y2, prescale, &Overflow ), &Overflow ); -#else /* BASOP_NOGLOB */ - signal[0] = round_fx( L_shl( L_y2, prescale ) ); -#endif /* BASOP_NOGLOB */ BASOP_SATURATE_WARNING_ON_EVS BASOP_SATURATE_ERROR_ON_EVS @@ -140,18 +132,10 @@ static void filter_2nd_order( L_sum = L_add( L_sum, HP50_Mpy_32_32_fix( mem[1], a2 ) ); /* y2*a2 */ L_sum = L_add( L_sum, HP50_Mpy_32_32_fix( L_y2, a1 ) ); /* y1*a1 */ -#ifdef BASOP_NOGLOB L_y1 = L_shl_o( L_sum, HP20_COEFF_SCALE, &Overflow ); -#else - L_y1 = L_shl( L_sum, HP20_COEFF_SCALE ); -#endif BASOP_SATURATE_ERROR_OFF_EVS BASOP_SATURATE_WARNING_OFF_EVS -#ifdef BASOP_NOGLOB signal[stride] = round_fx_o( L_shl_o( L_y1, prescale, &Overflow ), &Overflow ); -#else /* BASOP_NOGLOB */ - signal[stride] = round_fx( L_shl( L_y1, prescale ) ); -#endif /* BASOP_NOGLOB */ BASOP_SATURATE_WARNING_ON_EVS move16(); @@ -167,19 +151,10 @@ static void filter_2nd_order( L_sum = L_add( L_sum, HP50_Mpy_32_32_fix( L_y2, a2 ) ); L_sum = L_add( L_sum, HP50_Mpy_32_32_fix( L_y1, a1 ) ); -#ifdef BASOP_NOGLOB L_y2 = L_shl_o( L_sum, HP20_COEFF_SCALE, &Overflow ); -#else - L_y2 = L_shl( L_sum, HP20_COEFF_SCALE ); -#endif BASOP_SATURATE_ERROR_OFF_EVS BASOP_SATURATE_WARNING_OFF_EVS -#ifdef BASOP_NOGLOB signal[i_mult( i, stride )] = round_fx_o( L_shl_o( L_y2, prescale, &Overflow ), &Overflow ); -#else /* BASOP_NOGLOB */ - signal[i_mult( i, stride )] = round_fx( L_shl( L_y2, prescale ) ); - move16(); -#endif /* BASOP_NOGLOB */ BASOP_SATURATE_WARNING_ON_EVS /* y[i+1] = b2*x[i-1] + b1*x[i-0] + b2*x[i+1] + a2*y[i-1] + a1*y[i+0]; */ BASOP_SATURATE_ERROR_ON_EVS @@ -190,18 +165,10 @@ static void filter_2nd_order( L_sum = L_add( L_sum, HP50_Mpy_32_32_fix( L_y1, a2 ) ); L_sum = L_add( L_sum, HP50_Mpy_32_32_fix( L_y2, a1 ) ); -#ifdef BASOP_NOGLOB L_y1 = L_shl_o( L_sum, HP20_COEFF_SCALE, &Overflow ); -#else - L_y1 = L_shl( L_sum, HP20_COEFF_SCALE ); -#endif BASOP_SATURATE_ERROR_OFF_EVS BASOP_SATURATE_WARNING_OFF_EVS -#ifdef BASOP_NOGLOB signal[i_mult( add( i, 1 ), stride )] = round_fx_o( L_shl_o( L_y1, prescale, &Overflow ), &Overflow ); -#else /* BASOP_NOGLOB */ - signal[i_mult( add( i, 1 ), stride )] = round_fx( L_shl( L_y1, prescale ) ); -#endif BASOP_SATURATE_WARNING_ON_EVS move16(); } @@ -241,20 +208,12 @@ void hp20( Word16 signal[], /* i/o: signal to filter any * prescale = getScaleFactor16( signal, lg ); prescaleOld = extract_l( mem[4] ); -#ifdef BASOP_NOGLOB diff = norm_l( L_shl_sat( mem[2], prescaleOld ) ); -#else - diff = norm_l( L_shl( mem[2], prescaleOld ) ); -#endif if ( mem[2] != 0 ) { prescale = s_min( prescale, diff ); } -#ifdef BASOP_NOGLOB diff = norm_l( L_shl_o( mem[3], prescaleOld, &Overflow ) ); -#else - diff = norm_l( L_shl( mem[3], prescaleOld ) ); -#endif if ( mem[3] != 0 ) { prescale = s_min( prescale, diff ); @@ -264,7 +223,6 @@ void hp20( Word16 signal[], /* i/o: signal to filter any * IF( prescale != prescaleOld ) { diff = sub( prescale, prescaleOld ); -#ifdef BASOP_NOGLOB mem[0] = L_shr_o( mem[0], diff, &Overflow ); move32(); mem[1] = L_shr_o( mem[1], diff, &Overflow ); @@ -273,16 +231,6 @@ void hp20( Word16 signal[], /* i/o: signal to filter any * move32(); mem[3] = L_shr_o( mem[3], diff, &Overflow ); move32(); -#else - mem[0] = L_shr( mem[0], diff ); - move32(); - mem[1] = L_shr( mem[1], diff ); - move32(); - mem[2] = L_shr( mem[2], diff ); - move32(); - mem[3] = L_shr( mem[3], diff ); - move32(); -#endif mem[4] = L_deposit_l( prescale ); } @@ -366,9 +314,7 @@ void hp20_fx_32( Word32 i; Word32 a1_fx, a2_fx, b1_fx, b2_fx; Word32 diff_pos, diff_neg; -#ifdef BASOP_NOGLOB Flag Overflow = 0; -#endif Word16 prescale, prescaleOld, prescale_current_frame, diff; prescale = getScaleFactor32( signal_fx, lg ); @@ -377,13 +323,8 @@ void hp20_fx_32( prescaleOld = extract_l( mem_fx[4] ); -#ifdef BASOP_NOGLOB diff_pos = norm_l( L_shl_o( L_max( mem_fx[2], mem_fx[3] ), prescaleOld, &Overflow ) ); diff_neg = norm_l( L_shl_o( L_min( mem_fx[2], mem_fx[3] ), prescaleOld, &Overflow ) ); -#else - diff_pos = norm_l( L_shl( L_max( mem_fx[2], mem_fx[3] ), prescaleOld ) ); - diff_neg = norm_l( L_shl( L_min( mem_fx[2], mem_fx[3] ), prescaleOld ) ); -#endif diff = L_max( diff_pos, diff_neg ); @@ -395,7 +336,6 @@ void hp20_fx_32( prescale = s_min( 3, sub( 1 + HP20_COEFF_SCALE, prescale ) ); diff = sub( prescale, prescaleOld ); -#ifdef BASOP_NOGLOB mem_fx[0] = L_shr_o( mem_fx[0], diff, &Overflow ); move32(); mem_fx[1] = L_shr_o( mem_fx[1], diff, &Overflow ); @@ -404,16 +344,6 @@ void hp20_fx_32( move32(); mem_fx[3] = L_shr_o( mem_fx[3], diff, &Overflow ); move32(); -#else - mem_fx[0] = L_shr( mem_fx[0], diff ); - move32(); - mem_fx[1] = L_shr( mem_fx[1], diff ); - move32(); - mem_fx[2] = L_shr( mem_fx[2], diff ); - move32(); - mem_fx[3] = L_shr( mem_fx[3], diff ); - move32(); -#endif mem_fx[4] = L_deposit_l( prescale_current_frame ); move32(); diff --git a/lib_com/hq2_bit_alloc_fx.c b/lib_com/hq2_bit_alloc_fx.c index 395854d5f678aa22df3ce3c5e1113ab17fa6bbda..4742c81c26b4f851c127782edbe52aee28b86375 100644 --- a/lib_com/hq2_bit_alloc_fx.c +++ b/lib_com/hq2_bit_alloc_fx.c @@ -312,11 +312,9 @@ void hq2_bit_alloc_har_fx( Word16 exp_shift; -#ifdef BASOP_NOGLOB Flag Overflow; Overflow = 0; move32(); -#endif L_THR1 = L_shl( L_deposit_l( THR1 ), SWB_BWE_LR_QRk ); L_THR2 = L_shl( L_deposit_l( THR2 ), SWB_BWE_LR_QRk ); @@ -572,13 +570,9 @@ void hq2_bit_alloc_har_fx( L_temp = Mult_32_16( L_Ravg_sub[GRP_SB - 1], sub( GRP_SB, 1 ) ); /* Qbe+0+1 */ L_temp = Mult_32_16( L_temp, Inv_norm_sum_fx ); /* Qbe+1+QIpb+1 */ -#ifdef BASOP_NOGLOB lf_hf_ge_r_fx = round_fx_o( L_shl_o( L_temp, sub( 15 + 16, sub( add( SWB_BWE_LR_Qbe, QIns ), 30 ) ), &Overflow ), &Overflow ); Overflow = 0; /* reset BASOP Overflow */ move32(); -#else - lf_hf_ge_r_fx = round_fx( L_shl( L_temp, sub( 15 + 16, sub( add( SWB_BWE_LR_Qbe, QIns ), 30 ) ) ) ); -#endif exp_normn = norm_s( norm_sum_fx ); exp_normn = sub( exp_normn, 1 ); diff --git a/lib_com/hq2_core_com_fx.c b/lib_com/hq2_core_com_fx.c index a7c71ea9fd1722bec49321c65c6a5d1433740496..86c02fa88d266efecdab5289212dfcb471dd78ab 100644 --- a/lib_com/hq2_core_com_fx.c +++ b/lib_com/hq2_core_com_fx.c @@ -163,11 +163,7 @@ void mdct_spectrum_denorm_fx( pd_fx = div_s( shl( npulses[k], exp_normn ), shl( band_width[k], exp_normd ) ); /* 15 + (exp_norm - exp_normd) */ Qpd = add( sub( exp_normn, exp_normd ), 15 ); -#ifdef BASOP_NOGLOB cond_fx = sub( shl_o( pd_fx, sub( 15, Qpd ), &Overflow ), pd_thresh_fx /*Q15*/ ); /* Q15 */ -#else /* BASOP_NOGLOB */ - cond_fx = sub( shl( pd_fx, sub( 15, Qpd ) ), pd_thresh_fx /*Q15*/ ); -#endif Overflow = 0; move16(); /* allow overflow happen. */ IF( cond_fx < 0 ) @@ -200,11 +196,7 @@ void mdct_spectrum_denorm_fx( /*gamma *= gain_tweak; */ L_tmp = L_mult( gamma_fx, gain_tweak_fx ); /* Qgamma+Qtweak+1 */ exp_norm = norm_l( L_tmp ); -#ifdef BASOP_NOGLOB gamma_fx = round_fx_o( L_shl_o( L_tmp, exp_norm, &Overflow ), &Overflow ); -#else - gamma_fx = round_fx( L_shl( L_tmp, exp_norm ) ); -#endif Qgamma = sub( add( add( Qgamma, Qtweak ), exp_norm ), 15 ); /*Qgamma+Qtweak+1+exp_norm-16; */ } @@ -343,11 +335,7 @@ void mdct_spectrum_denorm_ivas_fx( pd_fx = div_s( shl( npulses[k], exp_normn ), shl( band_width[k], exp_normd ) ); /* 15 + (exp_normn + exp_normd) */ Qpd = add( sub( exp_normn, exp_normd ), 15 ); -#ifdef BASOP_NOGLOB cond_fx = sub( shl_o( pd_fx, sub( 15, Qpd ), &Overflow ), pd_thresh_fx /*Q15*/ ); /* Q15 */ -#else /* BASOP_NOGLOB */ - cond_fx = sub( shl( pd_fx, sub( 15, Qpd ) ), pd_thresh_fx /*Q15*/ ); -#endif Overflow = 0; move16(); /* allow overflow happen. */ IF( cond_fx < 0 ) @@ -380,11 +368,7 @@ void mdct_spectrum_denorm_ivas_fx( /*gamma *= gain_tweak; */ L_tmp = L_mult( gamma_fx, gain_tweak_fx ); /* Qgamma+Qtweak+1 */ exp_norm = norm_l( L_tmp ); -#ifdef BASOP_NOGLOB gamma_fx = round_fx_o( L_shl_o( L_tmp, exp_norm, &Overflow ), &Overflow ); -#else - gamma_fx = round_fx( L_shl( L_tmp, exp_norm ) ); -#endif Qgamma = sub( add( add( Qgamma, Qtweak ), exp_norm ), 15 ); /*Qgamma+Qtweak+1+exp_norm-16; */ } diff --git a/lib_com/hq2_noise_inject_fx.c b/lib_com/hq2_noise_inject_fx.c index c37ae1236e3e30a092fe30396e3aaca1207e1986..b85aaa027b1923cc772a11a953299176b7115d6d 100644 --- a/lib_com/hq2_noise_inject_fx.c +++ b/lib_com/hq2_noise_inject_fx.c @@ -90,13 +90,8 @@ void hq2_noise_inject_fx( FOR( i = 0; i < bands; i++ ) { -#ifdef BASOP_NOGLOB Ep_fx[i] = L_shl_o( Ep_fx[i], 6, &Overflow ); /* Q-6 -> Q0 */ move32(); -#else /* BASOP_NOGLOB */ - Ep_fx[i] = L_shl( Ep_fx[i], 6 ); /* Q-6 -> Q0 */ - move32(); -#endif /* BASOP_NOGLOB */ } tmp = add( band_end[bands - 1], 1 ); @@ -160,11 +155,7 @@ void hq2_noise_inject_fx( Q_env_fx[k] = sub( 31, exp2 ); move16(); tmp = sub( 17, Q_env_fx[k] ); -#ifdef BASOP_NOGLOB env_fx2[k] = extract_h( L_shl_o( env_fx[k], tmp, &Overflow ) ); /*Q1 */ -#else /* BASOP_NOGLOB */ - env_fx2[k] = extract_h( L_shl( env_fx[k], tmp ) ); /*Q1 */ -#endif /* BASOP_NOGLOB */ peak_fx[k] = 0; move16(); count[k] = 0; @@ -175,11 +166,7 @@ void hq2_noise_inject_fx( FOR( i = band_start[k]; i <= band_end[k]; i++ ) { L_tmp = L_mult0( y2hat_fx[i], y2hat_fx[i] ); /* Q0 */ -#ifdef BASOP_NOGLOB Ep_fx[k] = L_sub_o( Ep_fx[k], L_tmp, &Overflow ); -#else /* BASOP_NOGLOB */ - Ep_fx[k] = L_sub( Ep_fx[k], L_tmp ); -#endif /* BASOP_NOGLOB */ move32(); /* Q0 */ IF( GT_16( abs_s( y2hat_fx[i] ), peak_fx[k] ) ) { @@ -399,12 +386,8 @@ void hq2_noise_inject_fx( } ELSE IF( count[k - 1] == 0 && tmp4 > 0 ) { - L_tmp = L_mult( env_fx2[k - 1], tmp ); /* Q(1+Q_speech+1 = Q_speech+2) */ -#ifdef BASOP_NOGLOB + L_tmp = L_mult( env_fx2[k - 1], tmp ); /* Q(1+Q_speech+1 = Q_speech+2) */ fac_fx = extract_h( L_shl_o( L_tmp, sub( 26, Q_speech ), &Overflow ) ); /*Q12 */ -#else - fac_fx = extract_h( L_shl( L_tmp, sub( 26, Q_speech ) ) ); /*Q12 */ -#endif } } @@ -453,11 +436,7 @@ void hq2_noise_inject_fx( tmp = sub( Q_env_fx[k], Q_Ep_fx[k] ); tmp = sub( tmp, Q_speech ); tmp = add( tmp, 25 ); -#ifdef BASOP_NOGLOB - L_tmp = L_shr_sat( L_tmp2, tmp ); /*Q7 */ -#else - L_tmp = L_shr( L_tmp2, tmp ); /*Q7 */ -#endif + L_tmp = L_shr_sat( L_tmp2, tmp ); /*Q7 */ tmp = extract_l( L_min( L_tmp, 192 /* 1.5 in Q7 */ ) ); /* */ fac_fx = extract_h( L_shl( L_mult( fac_fx, tmp ), 8 ) ); /*Q12 */ } @@ -467,11 +446,7 @@ void hq2_noise_inject_fx( L_tmp2 = Mult_32_16( env_fx[k], tmp ); /*Q(Q_env_fx[k]+0-15 = Q_env_fx[k]-15) */ L_tmp2 = Mult_32_16( L_tmp2, 20480 /* 1.25 in Q14 */ ); /*Q(Q_env_fx[k]-15+14-15 = Q_env_fx[k]-16) */ tmp = sub( Q_env_fx[k], 23 ); -#ifdef BASOP_NOGLOB - L_tmp = L_shr_sat( L_tmp2, tmp ); /*Q7 */ -#else - L_tmp = L_shr( L_tmp2, tmp ); /*Q7 */ -#endif + L_tmp = L_shr_sat( L_tmp2, tmp ); /*Q7 */ tmp = extract_l( ( L_min( L_tmp, 192 /* 1.5 in Q7 */ ) ) ); /* Q7 */ fac_fx = extract_h( L_shl( L_mult( fac_fx, tmp ), 8 ) ); /*Q12 */ } @@ -492,11 +467,7 @@ void hq2_noise_inject_fx( } L_tmp = Mult_32_16( Ep_fx[k], fac_fx ); /*Q(Q_Ep_fx[k]+12-15 = Q_Ep_fx[k]-3) */ -#ifdef BASOP_NOGLOB ni_gain_fx[k] = L_shr_o( L_tmp, sub( Q_Ep_fx[k], 20 ), &Overflow ); -#else /* BASOP_NOGLOB */ - ni_gain_fx[k] = L_shr( L_tmp, sub( Q_Ep_fx[k], 20 ) ); -#endif move32(); /*Q17 */ } ELSE @@ -618,22 +589,14 @@ void hq2_noise_inject_fx( L_tmp = Mult_32_16( Ep_fx[k], tmp ); /*Q(Q_Ep_fx[k]+28-Q_speech-15 = Q_Ep_fx[k]+13-Q_speech) */ tmp = sub( Q_Ep_fx[k], Q_speech ); tmp = sub( 15, tmp ); -#ifdef BASOP_NOGLOB tmp = extract_h( L_shl_o( L_tmp, tmp, &Overflow ) ); /*Q12 */ -#else - tmp = extract_h( L_shl( L_tmp, tmp ) ); /*Q12 */ -#endif } ELSE { tmp = 0x7fff; /*Q0 */ L_tmp = Mult_32_16( Ep_fx[k], tmp ); /*Q(Q_Ep_fx[k]+0-15 = Q_Ep_fx[k]-15) */ tmp = sub( 43, Q_Ep_fx[k] ); -#ifdef BASOP_NOGLOB tmp = extract_h( L_shl_o( L_tmp, tmp, &Overflow ) ); /*Q12 */ -#else - tmp = extract_h( L_shl( L_tmp, tmp ) ); /*Q12 */ -#endif } fac_fx = s_max( tmp, 4096 /* 1 in Q12 */ ); /*Q12 */ @@ -645,12 +608,8 @@ void hq2_noise_inject_fx( IF( band_width[k] != 0 ) { Q_speech = norm_s( band_width[k] ); -#ifdef BASOP_NOGLOB tmp = shl_o( band_width[k], Q_speech, &Overflow ); /*Q(Q_speech) */ -#else - tmp = shl( band_width[k], Q_speech ); /*Q(Q_speech) */ -#endif - tmp = div_s( 16384 /* 0.5 in Q15 */, tmp ); /*Q(15+14-Q_speech) */ + tmp = div_s( 16384 /* 0.5 in Q15 */, tmp ); /*Q(15+14-Q_speech) */ } ELSE { @@ -659,16 +618,12 @@ void hq2_noise_inject_fx( move16(); move16(); } - tmp1 = sub( fac_fx, 4096 /* 1 in Q12 */ ); /*Q12 */ - L_tmp = L_mult( tmp1, j ); /*Q13 */ - L_tmp = Mult_32_16( L_tmp, tmp ); /*Q(13+29-Q_speech-15 = 27-Q_speech) */ -#ifdef BASOP_NOGLOB + tmp1 = sub( fac_fx, 4096 /* 1 in Q12 */ ); /*Q12 */ + L_tmp = L_mult( tmp1, j ); /*Q13 */ + L_tmp = Mult_32_16( L_tmp, tmp ); /*Q(13+29-Q_speech-15 = 27-Q_speech) */ tmp = extract_h( L_shl_o( L_tmp, add( 1, Q_speech ), &Overflow ) ); /*Q12 */ -#else - tmp = extract_h( L_shl( L_tmp, add( 1, Q_speech ) ) ); /*Q12 */ -#endif - tmp = sub( fac_fx, tmp ); /*Q12 */ - L_tmp = Mult_32_16( ni_gain_fx[k], tmp ); /*Q(17+12-15=14) */ + tmp = sub( fac_fx, tmp ); /*Q12 */ + L_tmp = Mult_32_16( ni_gain_fx[k], tmp ); /*Q(17+12-15=14) */ L_y2[i] = L_add( L_y2[i], L_shr( Mult_32_16( L_tmp, rand_fx ), 2 ) ); move32(); /*Q12 */ } diff --git a/lib_com/hq_tools_fx.c b/lib_com/hq_tools_fx.c index 468bdd9a52c64a538da9e1909e78c475a657ec43..7b7da27e626cba25fe998fcf4fe5497327fd1212 100644 --- a/lib_com/hq_tools_fx.c +++ b/lib_com/hq_tools_fx.c @@ -84,12 +84,8 @@ void hq_swb_harmonic_calc_norm_envelop_fx( FOR( n_lag = 0; n_lag < n_lag_now; n_lag++ ) { - L_tmp = L_abs( L_SWB_signal[n_lag] ); /*Q12*/ -#ifdef BASOP_NOGLOB + L_tmp = L_abs( L_SWB_signal[n_lag] ); /*Q12*/ L_envelope[env_index] = L_add_sat( L_envelope[env_index], L_tmp ); /*Q12*/ -#else - L_envelope[env_index] = L_add( L_envelope[env_index], L_tmp ); -#endif move32(); } env_index = add( env_index, 1 ); @@ -105,12 +101,8 @@ void hq_swb_harmonic_calc_norm_envelop_fx( move16(); FOR( n_lag = 0; n_lag < n_lag_now; n_lag++ ) { - L_tmp = L_abs( L_SWB_signal[( n_freq + n_lag )] ); /*Q12*/ -#ifdef BASOP_NOGLOB + L_tmp = L_abs( L_SWB_signal[( n_freq + n_lag )] ); /*Q12*/ L_envelope[env_index] = L_add_sat( L_envelope[env_index], L_tmp ); /*Q12*/ -#else - L_envelope[env_index] = L_add( L_envelope[env_index], L_tmp ); -#endif move32(); } env_index = add( env_index, 1 ); @@ -127,12 +119,8 @@ void hq_swb_harmonic_calc_norm_envelop_fx( move32(); FOR( n_lag = 0; n_lag < n_lag_now; n_lag++ ) { - L_tmp = L_abs( L_SWB_signal[( n_freq + n_lag )] ); /*Q12*/ -#ifdef BASOP_NOGLOB + L_tmp = L_abs( L_SWB_signal[( n_freq + n_lag )] ); /*Q12*/ L_envelope[env_index] = L_add_sat( L_envelope[env_index], L_tmp ); /*Q12*/ -#else - L_envelope[env_index] = L_add( L_envelope[env_index], L_tmp ); -#endif move32(); } env_index = add( env_index, 1 ); @@ -560,11 +548,7 @@ void harm_bwe_fine_fx( norm_signal = norm_l( envelope[i] ); enve_lo[i] = L_Extract_lc( L_shl( envelope[i], norm_signal ), &enve_hi[i] ); /*Q12+norm_signal-16*/ L_signal[i] = Div_32( L_signal[i], enve_hi[i], enve_lo[i] ); /*Q31 - norm_signal*/ -#ifdef BASOP_NOGLOB - SWB_signal[i] = round_fx_sat( L_shl_sat( L_signal[i], norm_signal ) ); /*Q15*/ -#else - SWB_signal[i] = round_fx( L_shl( L_signal[i], norm_signal ) ); -#endif + SWB_signal[i] = round_fx_sat( L_shl_sat( L_signal[i], norm_signal ) ); /*Q15*/ move16(); move16(); move32(); @@ -574,11 +558,7 @@ void harm_bwe_fine_fx( norm_signal = norm_l( envelope[i] ); enve_lo[i] = L_Extract_lc( L_shl( envelope[i], norm_signal ), &enve_hi[i] ); /*Q12+norm_signal-16*/ L_signal[i] = L_negate( Div_32( L_negate( L_signal[i] ), enve_hi[i], enve_lo[i] ) ); /*Q31 - norm_signal*/ -#ifdef BASOP_NOGLOB - SWB_signal[i] = round_fx_sat( L_shl_sat( L_signal[i], norm_signal ) ); /*Q15*/ -#else - SWB_signal[i] = round_fx( L_shl( L_signal[i], norm_signal ) ); -#endif + SWB_signal[i] = round_fx_sat( L_shl_sat( L_signal[i], norm_signal ) ); /*Q15*/ move16(); move16(); move32(); @@ -659,11 +639,7 @@ void hvq_bwe_fine_fx( /*SWB_signal[i] = SWB_signal[i] / envelope[i]; */ shift = norm_l( L_envelope[i] ); -#ifdef BASOP_NOGLOB tmp = round_fx_sat( L_shl_sat( L_envelope[i], shift ) ); /* 12+s-16=Q(-4+s) */ -#else - tmp = round_fx( L_shl( L_envelope[i], shift ) ); /* 12+s-16=Q(-4+s) */ -#endif /* Avoid division by zero */ if ( tmp == 0 ) { @@ -962,34 +938,19 @@ void ivas_harm_bwe_fx( L_tmp2 = L_deposit_h( tmp1 ); L_tmp2 = Isqrt_lc( L_tmp2, &exp1 ); /*Q31 - exp1*/ -#ifdef BASOP_NOGLOB beta = round_fx_sat( L_shl_sat( L_tmp2, exp1 ) ); /*Q15 */ beta = shr( beta, 1 ); /*Q15*/ -#else - beta = round_fx( L_shl( L_tmp2, exp1 ) ); - beta = shr( beta, 1 ); /*Q15 */ -#endif FOR( sfm = sfm_start[i]; sfm < sfm_end[i]; sfm++ ) { - L_tmp = Mult_32_16( E_L, coeff_fine[sfm] ); /*Q19 19 + 15 +1-16 */ -#ifdef BASOP_NOGLOB - L_tmp = L_shl_sat( L_tmp, 9 ); /*Q28 */ -#else - L_tmp = L_shl( L_tmp, 9 ); /*Q28 */ -#endif - tmp = Random( bwe_seed ); /*Q15 */ - L_tmp2 = L_shr( L_mult( beta, tmp ), 3 ); /* Q28 31-3 15+15 +1-3 */ -#ifdef BASOP_NOGLOB + L_tmp = Mult_32_16( E_L, coeff_fine[sfm] ); /*Q19 19 + 15 +1-16 */ + L_tmp = L_shl_sat( L_tmp, 9 ); /*Q28 */ + tmp = Random( bwe_seed ); /*Q15 */ + L_tmp2 = L_shr( L_mult( beta, tmp ), 3 ); /* Q28 31-3 15+15 +1-3 */ L_tmp = L_add_sat( L_tmp, L_tmp2 ); /*Q28 */ coeff_out[sfm] = L_shl_sat( Mult_32_32( L_tmp, normq ), 1 ); /*Q12 28 +14 +1 -31 */ move32(); -#else - L_tmp = L_add( L_tmp, L_tmp2 ); /*Q28 */ - coeff_out[sfm] = L_shl( Mult_32_32( L_tmp, normq ), 1 ); /*Q12 28 +14 +1 -31 */ - move32(); -#endif } } @@ -1152,23 +1113,13 @@ void harm_bwe_fx( FOR( sfm = sfm_start[i]; sfm < sfm_end[i]; sfm++ ) { - L_tmp = Mult_32_16( E_L, coeff_fine[sfm] ); /*Q19 19 + 15 +1-16 */ -#ifdef BASOP_NOGLOB - L_tmp = L_shl_sat( L_tmp, 9 ); /*Q28 */ -#else - L_tmp = L_shl( L_tmp, 9 ); /*Q28 */ -#endif - tmp = Random( bwe_seed ); /*Q15 */ - L_tmp2 = L_shr( L_mult( beta, tmp ), 3 ); /* Q28 31-3 15+15 +1-3 */ -#ifdef BASOP_NOGLOB + L_tmp = Mult_32_16( E_L, coeff_fine[sfm] ); /*Q19 19 + 15 +1-16 */ + L_tmp = L_shl_sat( L_tmp, 9 ); /*Q28 */ + tmp = Random( bwe_seed ); /*Q15 */ + L_tmp2 = L_shr( L_mult( beta, tmp ), 3 ); /* Q28 31-3 15+15 +1-3 */ L_tmp = L_add_sat( L_tmp, L_tmp2 ); /*Q28 */ coeff_out[sfm] = L_shl_sat( Mult_32_32( L_tmp, normq ), 1 ); /*Q12 28 +14 +1 -31 */ move32(); -#else - L_tmp = L_add( L_tmp, L_tmp2 ); /*Q28 */ - coeff_out[sfm] = L_shl( Mult_32_32( L_tmp, normq ), 1 ); /*Q12 28 +14 +1 -31 */ - move32(); -#endif } } @@ -2151,6 +2102,36 @@ void hq_bwe_fx( return; } +void hq_bwe_ivas_fx( + const Word16 HQ_mode, /* i : HQ mode Q0*/ + Word32 *coeff_out1, /* i/o: BWE input & temporary buffer Q12*/ + const Word16 *hq_generic_fenv, /* i : SWB frequency envelopes Q1*/ + Word32 *coeff_out, /* o : SWB signal in MDCT domain Q12*/ + const Word16 hq_generic_offset, /* i : frequency offset for representing hq generic Q0*/ + Word16 *prev_L_swb_norm, /* i/o: last normalize length Q0*/ + const Word16 hq_generic_exc_clas, /* i : hq generic hf excitation class Q0*/ + const Word16 *sfm_end, /* i : End of bands Q0*/ + const Word16 num_sfm, /* i : Number of bands Q0*/ + const Word16 num_env_bands, /* i : Number of coded envelope bands Q0*/ + const Word16 *R /* i : Bit allocation Q0*/ +) +{ + Word16 n_swb_overlap_offset, n_swb_overlap; + Word32 hq_swb_overlap_buf_fx[L_FRAME32k]; + + n_swb_overlap_offset = add( swb_bwe_subband[0], hq_generic_offset ); + n_swb_overlap = sub( sfm_end[( num_env_bands - 1 )], n_swb_overlap_offset ); /*Q0*/ + + + Copy32( &coeff_out[n_swb_overlap_offset], hq_swb_overlap_buf_fx, sub( add( n_swb_overlap, sfm_end[( num_sfm - 1 )] ), sfm_end[( num_env_bands - 1 )] ) ); /*Q12*/ + + hq_generic_decoding_ivas_fx( HQ_mode, coeff_out1, hq_generic_fenv, coeff_out, hq_generic_offset, prev_L_swb_norm, hq_generic_exc_clas, R ); + + overlap_hq_bwe_fx( hq_swb_overlap_buf_fx, coeff_out, n_swb_overlap_offset, n_swb_overlap, R, num_env_bands, num_sfm, sfm_end ); + + return; +} + /*--------------------------------------------------------------------------* * hq_wb_nf_bwe() * @@ -2216,14 +2197,10 @@ void hq_wb_nf_bwe_fx( IF( GT_16( last_sfm, 8 ) && total_bit > 0 ) { exp = norm_s( total_bit ); - tmp = shl( total_bit, exp ); /*Q(exp) */ - tmp = div_s( 16384, tmp ); /*Q(15+14-exp) */ - L_tmp = L_mult( tmp, bitalloc_var_fx ); /*Q(29-exp+1) */ -#ifdef BASOP_NOGLOB + tmp = shl( total_bit, exp ); /*Q(exp) */ + tmp = div_s( 16384, tmp ); /*Q(15+14-exp) */ + L_tmp = L_mult( tmp, bitalloc_var_fx ); /*Q(29-exp+1) */ bitalloc_var_fx = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /*Q14 */ -#else - bitalloc_var_fx = round_fx( L_shl( L_tmp, exp ) ); /*Q14 */ -#endif } ELSE { @@ -2239,11 +2216,7 @@ void hq_wb_nf_bwe_fx( { tmp = shl( sfmsize[sfm], 9 ); /*Q9 */ tmp = mult( rat_fx[sfm], tmp ); /*Q(14+9-15=8) */ -#ifdef BASOP_NOGLOB IF( GE_16( shl_sat( R[sfm], 8 ), tmp ) ) -#else - IF( GE_16( shl( R[sfm], 8 ), tmp ) ) -#endif { peak_fx = 0; move16(); @@ -2251,12 +2224,8 @@ void hq_wb_nf_bwe_fx( move16(); FOR( i = sfm_start[sfm]; i < sfm_end[sfm]; i++ ) { - fabs_coeff_out_fx = L_abs( L_coeff_out[i] ); /*Q12*/ -#ifdef BASOP_NOGLOB + fabs_coeff_out_fx = L_abs( L_coeff_out[i] ); /*Q12*/ mean_fx = L_add_sat( mean_fx, fabs_coeff_out_fx ); /*Q12 */ -#else - mean_fx = L_add( mean_fx, fabs_coeff_out_fx ); /*Q12 */ -#endif if ( GT_32( fabs_coeff_out_fx, peak_fx ) ) { peak_fx = fabs_coeff_out_fx; /*Q12 */ @@ -2267,13 +2236,8 @@ void hq_wb_nf_bwe_fx( IF( mean_fx != 0 ) { exp = norm_l( mean_fx ); -#ifdef BASOP_NOGLOB - mean_fx = L_shl_sat( mean_fx, exp ); /*Q(exp+12) */ - tmp = round_fx_sat( mean_fx ); /*Q(exp-4) */ -#else - mean_fx = L_shl( mean_fx, exp ); /*Q(exp+12) */ - tmp = round_fx( mean_fx ); /*Q(exp-4) */ -#endif + mean_fx = L_shl_sat( mean_fx, exp ); /*Q(exp+12) */ + tmp = round_fx_sat( mean_fx ); /*Q(exp-4) */ tmp = div_s( 16384, tmp ); /*Q(15+14-exp+4 = 33-exp) */ L_tmp = Mult_32_16( peak_fx, tmp ); /*Q(12+33-exp-15 = 30-exp) */ tmp = shl( sfmsize[sfm], 9 ); /*Q9 */ @@ -2312,14 +2276,10 @@ void hq_wb_nf_bwe_fx( tmp = div_s( 1, last_sfm ); /*Q15 */ } - L_tmp = L_mult( 5, sharp_fx ); /*Q15 */ - L_tmp = Mult_32_16( L_tmp, tmp ); /*Q15 */ -#ifdef BASOP_NOGLOB + L_tmp = L_mult( 5, sharp_fx ); /*Q15 */ + L_tmp = Mult_32_16( L_tmp, tmp ); /*Q15 */ step_fx = round_fx_sat( L_shl_sat( L_tmp, 16 ) ); /*Q15 */ -#else - step_fx = round_fx( L_shl( L_tmp, 16 ) ); /*Q15 */ -#endif - alfa_fx = 20480; /*Q13 = 2.5 */ + alfa_fx = 20480; /*Q13 = 2.5 */ move16(); /* fill noise for the insaturable subbands */ FOR( sfm = 0; sfm < num_sfm; sfm++ ) @@ -2455,18 +2415,10 @@ void hq_wb_nf_bwe_fx( exp = sub( 45, exp ); } -#ifdef BASOP_NOGLOB sharp_fx = add_sat( sharp_fx, shr( step_fx, 1 ) ); /*Q14*/ -#else - sharp_fx = add( sharp_fx, shr( step_fx, 1 ) ); -#endif } -#ifdef BASOP_NOGLOB IF( GT_32( L_tmp2, L_shl_sat( min_coef_fx, sub( exp, 13 ) ) ) ) /*exp */ -#else - IF( GT_32( L_tmp2, L_shl( min_coef_fx, sub( exp, 13 ) ) ) ) /*exp */ -#endif { L_tmp2 = L_shr( min_coef_fx, 1 ); exp = 12; @@ -2483,11 +2435,7 @@ void hq_wb_nf_bwe_fx( /* smooth the noise magnitudes between inter-frame */ test(); test(); -#ifdef BASOP_NOGLOB IF( GT_32( prev_avrg_norm_fx, L_shr( avrg_norm_fx, 1 ) ) && LT_32( prev_avrg_norm_fx, L_shl_sat( avrg_norm_fx, 1 ) ) && prev_is_transient == 0 ) -#else - IF( GT_32( prev_avrg_norm_fx, L_shr( avrg_norm_fx, 1 ) ) && LT_32( prev_avrg_norm_fx, L_shl( avrg_norm_fx, 1 ) ) && prev_is_transient == 0 ) -#endif { exp1 = norm_l( prev_env_fx[sfm] ); L_tmp1 = L_shl( prev_env_fx[sfm], exp1 ); /* prev_env_Q[sfm] +exp1 */ @@ -2545,11 +2493,7 @@ void hq_wb_nf_bwe_fx( test(); test(); test(); -#ifdef BASOP_NOGLOB IF( EQ_16( sfm, sub( SFM_N_WB, 1 ) ) && prev_is_transient == 0 && GT_32( prev_normq_fx[sfm], L_shr( L_normq_v[sfm], 1 ) ) && LT_32( prev_normq_fx[sfm], L_shl_sat( L_normq_v[sfm], 1 ) ) && LE_16( bitalloc_var_fx, 4915 ) ) -#else - IF( EQ_16( sfm, sub( SFM_N_WB, 1 ) ) && prev_is_transient == 0 && GT_32( prev_normq_fx[sfm], L_shr( L_normq_v[sfm], 1 ) ) && LT_32( prev_normq_fx[sfm], L_shl( L_normq_v[sfm], 1 ) ) && LE_16( bitalloc_var_fx, 4915 ) ) -#endif { Word32 *p_prev_coeff_out = prev_coeff_out_fx; /*Q12*/ FOR( i = add( sfm_start[sfm], 12 ); i < sfm_end[sfm]; i++ ) @@ -2558,17 +2502,9 @@ void hq_wb_nf_bwe_fx( test(); test(); test(); -#ifdef BASOP_NOGLOB IF( GT_32( L_abs( L_coeff_out[i] ), L_shl_sat( L_abs( *p_prev_coeff_out ), 2 ) ) || LT_32( L_abs( L_coeff_out[i] ), L_shr( L_abs( *p_prev_coeff_out ), 2 ) ) || ( ( R[sfm] == 0 || *prev_R == 0 ) && add_sat( R[sfm], *prev_R ) != 0 ) ) -#else - IF( GT_32( L_abs( L_coeff_out[i] ), L_shl( L_abs( *p_prev_coeff_out ), 2 ) ) || LT_32( L_abs( L_coeff_out[i] ), L_shr( L_abs( *p_prev_coeff_out ), 2 ) ) || ( ( R[sfm] == 0 || *prev_R == 0 ) && add( R[sfm], *prev_R ) != 0 ) ) -#endif { -#ifdef BASOP_NOGLOB L_tmp = L_add_sat( L_shr( L_abs( L_coeff_out[i] ), 1 ), L_shr( L_abs( *p_prev_coeff_out ), 1 ) ); /*Q12*/ -#else - L_tmp = L_add( L_shr( L_abs( L_coeff_out[i] ), 1 ), L_shr( L_abs( *p_prev_coeff_out ), 1 ) ); -#endif if ( L_coeff_out[i] <= 0 ) { L_tmp = L_negate( L_tmp ); /*Q12*/ diff --git a/lib_com/ifft_rel.c b/lib_com/ifft_rel.c index 40383cf3c0e76a55f6772d507367959c2c033138..e3b62bdb55ee88c47c4a44ecf465f19143cd2fc7 100644 --- a/lib_com/ifft_rel.c +++ b/lib_com/ifft_rel.c @@ -109,66 +109,28 @@ void ifft_rel_fx( FOR( i = is; i < n; i += id ) { -#ifdef BASOP_NOGLOB t1 = sub_o( *xi1, *xi3, &Overflow ); /*Qx*/ *xi1 = add_o( *xi1, *xi3, &Overflow ); /*Qx*/ -#else /* BASOP_NOGLOB */ - t1 = sub( *xi1, *xi3 ); - *xi1 = add( *xi1, *xi3 ); -#endif /* BASOP_NOGLOB */ move16(); -#ifdef BASOP_NOGLOB *xi2 = shl_o( *xi2, 1, &Overflow ); /*Qx*/ -#else /* BASOP_NOGLOB */ - *xi2 = shl( *xi2, 1 ); -#endif /* BASOP_NOGLOB */ move16(); -#ifdef BASOP_NOGLOB *xi3 = sub_o( t1, shl_o( *xi4, 1, &Overflow ), &Overflow ); /*Qx*/ -#else /* BASOP_NOGLOB */ - *xi3 = sub( t1, shl( *xi4, 1 ) ); -#endif /* BASOP_NOGLOB */ move16(); -#ifdef BASOP_NOGLOB *xi4 = add_o( t1, shl_o( *xi4, 1, &Overflow ), &Overflow ); /*Qx*/ -#else /* BASOP_NOGLOB */ - *xi4 = add( t1, shl( *xi4, 1 ) ); -#endif /* BASOP_NOGLOB */ move16(); IF( NE_16( n4, 1 ) ) { -#ifdef BASOP_NOGLOB t1 = mult_r( sub_o( *( xi2 + n8 ), *( xi1 + n8 ), &Overflow ), INV_SQR2_FX /*Q15*/ ); /*Qx*/ t2 = mult_r( add_o( *( xi4 + n8 ), *( xi3 + n8 ), &Overflow ), INV_SQR2_FX /*Q15*/ ); /*Qx*/ -#else /* BASOP_NOGLOB */ - t1 = mult_r( sub( *( xi2 + n8 ), *( xi1 + n8 ) ), INV_SQR2_FX ); - t2 = mult_r( add( *( xi4 + n8 ), *( xi3 + n8 ) ), INV_SQR2_FX ); -#endif /* BASOP_NOGLOB */ -#ifdef BASOP_NOGLOB *( xi1 + n8 ) = add_o( *( xi1 + n8 ), *( xi2 + n8 ), &Overflow ); /*Qx*/ -#else /* BASOP_NOGLOB */ - *( xi1 + n8 ) = add( *( xi1 + n8 ), *( xi2 + n8 ) ); -#endif /* BASOP_NOGLOB */ move16(); -#ifdef BASOP_NOGLOB *( xi2 + n8 ) = sub_o( *( xi4 + n8 ), *( xi3 + n8 ), &Overflow ); /*Qx*/ -#else /* BASOP_NOGLOB */ - *( xi2 + n8 ) = sub( *( xi4 + n8 ), *( xi3 + n8 ) ); -#endif /* BASOP_NOGLOB */ move16(); -#ifdef BASOP_NOGLOB *( xi3 + n8 ) = negate( shl_o( add_o( t2, t1, &Overflow ), 1, &Overflow ) ); /*Qx*/ -#else /* BASOP_NOGLOB */ - *( xi3 + n8 ) = negate( shl( add( t2, t1 ), 1 ) ); -#endif /* BASOP_NOGLOB */ move16(); -#ifdef BASOP_NOGLOB *( xi4 + n8 ) = shl_o( sub_o( t1, t2, &Overflow ), 1, &Overflow ); /*Qx*/ -#else /* BASOP_NOGLOB */ - *( xi4 + n8 ) = shl( sub( t1, t2 ), 1 ); -#endif /* BASOP_NOGLOB */ move16(); } xi1 += id; @@ -217,82 +179,42 @@ void ifft_rel_fx( FOR( i = is; i < n; i += id ) { -#ifdef BASOP_NOGLOB t1 = sub_o( *xup1, *xdn6, &Overflow ); /*Qx*/ *xup1 = add_o( *xup1, *xdn6, &Overflow ); /*Qx*/ -#else /* BASOP_NOGLOB */ - t1 = sub( *xup1, *xdn6 ); - *xup1 = add( *xup1, *xdn6 ); -#endif /* BASOP_NOGLOB */ move16(); xup1 += n4; xdn6 -= n4; -#ifdef BASOP_NOGLOB t2 = sub_o( *xdn6, *xup1, &Overflow ); /*Qx*/ *xdn6 = add_o( *xup1, *xdn6, &Overflow ); /*Qx*/ -#else /* BASOP_NOGLOB */ - t2 = sub( *xdn6, *xup1 ); - *xdn6 = add( *xup1, *xdn6 ); -#endif /* BASOP_NOGLOB */ move16(); xdn6 += n4; -#ifdef BASOP_NOGLOB t3 = add_o( *xdn8, *xup3, &Overflow ); /*Qx*/ *xdn6 = sub_o( *xdn8, *xup3, &Overflow ); /*Qx*/ -#else /* BASOP_NOGLOB */ - t3 = add( *xdn8, *xup3 ); - *xdn6 = sub( *xdn8, *xup3 ); -#endif /* BASOP_NOGLOB */ move16(); xup3 += n4; xdn8 -= n4; -#ifdef BASOP_NOGLOB t4 = add_o( *xup3, *xdn8, &Overflow ); /*Qx*/ *xup1 = sub_o( *xup3, *xdn8, &Overflow ); /*Qx*/ -#else /* BASOP_NOGLOB */ - t4 = add( *xup3, *xdn8 ); - *xup1 = sub( *xup3, *xdn8 ); -#endif /* BASOP_NOGLOB */ move16(); -#ifdef BASOP_NOGLOB t5 = sub_o( t1, t4, &Overflow ); /*Qx*/ t1 = add_o( t1, t4, &Overflow ); /*Qx*/ t4 = sub_o( t2, t3, &Overflow ); /*Qx*/ t2 = add_o( t2, t3, &Overflow ); /*Qx*/ *xup3 = sub_o( mult_r( t1, cc3 ), mult_r( t2, ss3 ), &Overflow ); /*Qx*/ -#else /* BASOP_NOGLOB */ - t5 = sub( t1, t4 ); - t1 = add( t1, t4 ); - t4 = sub( t2, t3 ); - t2 = add( t2, t3 ); - *xup3 = sub( mult_r( t1, cc3 ), mult_r( t2, ss3 ) ); -#endif /* BASOP_NOGLOB */ move16(); xup3 -= n4; -#ifdef BASOP_NOGLOB *xup3 = add_o( mult_r( t5, cc1 ), mult_r( t4, ss1 ), &Overflow ); /*Qx*/ -#else /* BASOP_NOGLOB */ - *xup3 = add( mult_r( t5, cc1 ), mult_r( t4, ss1 ) ); -#endif /* BASOP_NOGLOB */ move16(); -#ifdef BASOP_NOGLOB *xdn8 = sub_o( mult_r( t5, ss1 ), mult_r( t4, cc1 ), &Overflow ); /*Qx*/ -#else /* BASOP_NOGLOB */ - *xdn8 = sub( mult_r( t5, ss1 ), mult_r( t4, cc1 ) ); -#endif /* BASOP_NOGLOB */ move16(); xdn8 += n4; -#ifdef BASOP_NOGLOB *xdn8 = add_o( mult_r( t2, cc3 ), mult_r( t1, ss3 ), &Overflow ); /*Qx*/ -#else /* BASOP_NOGLOB */ - *xdn8 = add( mult_r( t2, cc3 ), mult_r( t1, ss3 ) ); -#endif /* BASOP_NOGLOB */ move16(); xup1 -= n4; @@ -324,17 +246,9 @@ void ifft_rel_fx( { r1 = *xi0; move16(); -#ifdef BASOP_NOGLOB *xi0 = add_o( r1, *xi1, &Overflow ); /*Qx*/ -#else /* BASOP_NOGLOB */ - *xi0 = add( r1, *xi1 ); -#endif /* BASOP_NOGLOB */ move16(); -#ifdef BASOP_NOGLOB *xi1 = sub_o( r1, *xi1, &Overflow ); /*Qx*/ -#else /* BASOP_NOGLOB */ - *xi1 = sub( r1, *xi1 ); -#endif move16(); xi0 += id; xi1 += id; diff --git a/lib_com/igf_base_fx.c b/lib_com/igf_base_fx.c index 5670088d3caef37e94378d5bd21ee60bdf243362..fbccdb5191fe889c5aab51fa4dd2bc4c9a07c6ed 100644 --- a/lib_com/igf_base_fx.c +++ b/lib_com/igf_base_fx.c @@ -1142,19 +1142,11 @@ void IGFCommonFuncsCalcSfbEnergyPowerSpec( const Word16 startSfb, /**< in { Carry = 0; move16(); -#ifdef BASOP_NOGLOB sfbEnergy[sfb] = L_add_co( sfbEnergy[sfb], pPowerSpectrum[line], &Carry, &Overflow ); -#else /* BASOP_NOGLOB */ - sfbEnergy[sfb] = L_add_c( sfbEnergy[sfb], pPowerSpectrum[line] ); -#endif /* BASOP_NOGLOB */ move32(); Overflow = 0; move16(); -#ifdef BASOP_NOGLOB L_c = L_macNs_co( L_c, 0, 0, &Carry, &Overflow ); -#else /* BASOP_NOGLOB */ - L_c = L_macNs( L_c, 0, 0 ); -#endif } sfbEnergy[sfb] = norm_llQ31( L_c, sfbEnergy[sfb], &( sfbEnergy_exp[sfb] ) ); move32(); @@ -1194,12 +1186,8 @@ void IGFCommonFuncsMDCTSquareSpec( const Word16 sqrtBgn, /**< in FOR( i = sqrtBgn; i < sqrtEnd; i++ ) { -#ifdef BASOP_NOGLOB tmp = round_fx_sat( L_shl_sat( mdctSpec[i], s1 ) ); /*(15 - mdctSpec_e)+ S1*/ -#else - tmp = round_fx( L_shl( mdctSpec[i], s1 ) ); -#endif - mdctSquareSpec[j++] = L_mult0( tmp, tmp ); /*31 - mdctSquareSpec_e*/ + mdctSquareSpec[j++] = L_mult0( tmp, tmp ); /*31 - mdctSquareSpec_e*/ move32(); } } diff --git a/lib_com/interpol.c b/lib_com/interpol.c index 7d74298b1be318e8fec8ef462195714d11760a76..ceafad116a279ee74128ab17dbbc369dcd6aad3c 100644 --- a/lib_com/interpol.c +++ b/lib_com/interpol.c @@ -73,11 +73,7 @@ Word32 Interpol_lc_fx( /* o : interpolated value } L_sum = W_sat_l( L_sum64 ); /*Q14*/ } -#ifdef BASOP_NOGLOB L_sum = L_shl_sat( L_sum, 1 ); /*Q15*/ -#else - L_sum = L_shl( L_sum, 1 ); -#endif return L_sum; } @@ -108,15 +104,7 @@ Word16 Interpol_4( /* Qx o : interpolated value */ } BASOP_SATURATE_WARNING_OFF_EVS /* Here, saturation might occur by intention */ -#ifdef BASOP_NOGLOB L_sum = L_shl_o( L_sum, 1, &Overflow ); /*Qx+14+2*/ -#else /* BASOP_NOGLOB */ - L_sum = L_shl( L_sum, 1 ); -#endif /* BASOP_NOGLOB */ BASOP_SATURATE_WARNING_ON_EVS -#ifdef BASOP_NOGLOB return round_fx_o( L_sum, &Overflow ); /*Qx*/ -#else /* BASOP_NOGLOB */ - return round_fx( L_sum ); -#endif } diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index b440299451557260c33eb4bbae825587dab3d6d0..1fe54d164d6c56450486d840bb33e73efbd159f3 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -150,6 +150,7 @@ typedef enum RENDERER_OSBA_LS } RENDERER_TYPE; +#define MAX_FREQUENCY_BANDS 64 /*----------------------------------------------------------------------------------* * IVAS general constants @@ -765,6 +766,7 @@ enum #define UNCLR_L_ETOT 3 #define UNCLR_L_RELE 10 +#define ONE_BY_UNCLR_L_RELE_Q31 214748365 #define UNCLR_RC_ORDER 20 #define MAX_UV_CNT 100 diff --git a/lib_com/ivas_dirac_com.c b/lib_com/ivas_dirac_com.c index 6aeff8ec548fe8a13aba886d138eebbfb0f3db7d..ebd958e1bc048b3bf303847e41e45fac74076112 100644 --- a/lib_com/ivas_dirac_com.c +++ b/lib_com/ivas_dirac_com.c @@ -636,9 +636,9 @@ void computeDirectionVectors_fixed( #ifdef NONBE_IMPROVE_DIRAC_INTENSITY_PREC IF( i_e_band != NULL ) { - e_x = sub( i_e_band[i - enc_param_start_band], norm_x ); - e_y = sub( i_e_band[i - enc_param_start_band], norm_y ); - e_z = sub( i_e_band[i - enc_param_start_band], norm_z ); + e_x = sub( Q31, add( i_e_band[i - enc_param_start_band], norm_x ) ); + e_y = sub( Q31, add( i_e_band[i - enc_param_start_band], norm_y ) ); + e_z = sub( Q31, add( i_e_band[i - enc_param_start_band], norm_z ) ); } ELSE { @@ -966,38 +966,55 @@ void computeDiffuseness_fixed( p_tmp_c = buffer_energy + i * num_freq_bands; q_tmp = add( q_factor_energy[i], min_q_shift1 ); - FOR( k = 0; k < num_freq_bands; k++ ) + + Word16 shift_q = sub( q_tmp, q_ene ); + IF( shift_q < 0 ) { - tmp = L_shl( p_tmp_c[k], min_q_shift1 ); - IF( LT_16( q_tmp, q_ene ) ) + FOR( k = 0; k < num_freq_bands; k++ ) { - energy_slow[k] = L_add( L_shr( energy_slow[k], sub( q_ene, q_tmp ) ), tmp ); + 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 + } + ELSE + { + FOR( k = 0; k < num_freq_bands; k++ ) { - energy_slow[k] = L_add( energy_slow[k], L_shr( tmp, sub( q_tmp, q_ene ) ) ); + tmp = L_shl( p_tmp_c[k], min_q_shift1 ); + energy_slow[k] = L_add( energy_slow[k], L_shr( tmp, shift_q ) ); move32(); } } + q_ene = s_min( q_ene, q_tmp ); /* Intensity slow */ q_tmp = add( q_factor_intensity[i], min_q_shift2 ); - FOR( j = 0; j < DIRAC_NUM_DIMS; ++j ) + + shift_q = sub( q_tmp, q_intensity ); + IF( shift_q > 0 ) { - p_tmp = buffer_intensity[j][i]; - FOR( k = 0; k < num_freq_bands; k++ ) + FOR( j = 0; j < DIRAC_NUM_DIMS; ++j ) { - tmp = L_shl( p_tmp[k], min_q_shift2 ); - IF( LT_16( q_intensity, q_tmp ) ) + p_tmp = buffer_intensity[j][i]; + FOR( k = 0; k < num_freq_bands; k++ ) { - intensity_slow[j * num_freq_bands + k] = L_add( intensity_slow[j * num_freq_bands + k], L_shr( tmp, sub( q_tmp, q_intensity ) ) ); + 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 + } + } + ELSE + { + FOR( j = 0; j < DIRAC_NUM_DIMS; ++j ) + { + p_tmp = buffer_intensity[j][i]; + FOR( k = 0; k < num_freq_bands; k++ ) { - intensity_slow[j * num_freq_bands + k] = L_add( L_shr( intensity_slow[j * num_freq_bands + k], sub( q_intensity, q_tmp ) ), tmp ); + 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(); } } @@ -1017,9 +1034,7 @@ void computeDiffuseness_fixed( FOR( k = 0; k < num_freq_bands; k++ ) { - p_tmp[k] = Mpy_32_32( p_tmp[k], p_tmp[k] ); - move32(); - intensity_slow_abs[k] = L_add( intensity_slow_abs[k], p_tmp[k] ); + intensity_slow_abs[k] = Madd_32_32( intensity_slow_abs[k], p_tmp[k], p_tmp[k] ); move32(); } } diff --git a/lib_com/ivas_fb_mixer.c b/lib_com/ivas_fb_mixer.c index 78603c1db43c9d913d5cff69c6bcb7fce4d16d27..df8f7d0f54092ae9eeba2b564b3319e773efba21 100644 --- a/lib_com/ivas_fb_mixer.c +++ b/lib_com/ivas_fb_mixer.c @@ -560,7 +560,11 @@ void ivas_fb_mixer_pcm_ingest_fx( move16(); ivas_mdft_fx( ppOut_pcm[fb_cfg->remix_order[i]], hFbMixer->ppFilterbank_inFR_re_fx[fb_cfg->remix_order[i]], hFbMixer->ppFilterbank_inFR_im_fx[fb_cfg->remix_order[i]], shl( frame_len, 1 ), frame_len ); - hFbMixer->q_ppFilterbank_inFR[fb_cfg->remix_order[i]] = q_ppOut_pcm[fb_cfg->remix_order[i]]; + q_shift = L_norm_arr( hFbMixer->ppFilterbank_inFR_re_fx[fb_cfg->remix_order[i]], frame_len ); + q_shift = s_min( q_shift, L_norm_arr( hFbMixer->ppFilterbank_inFR_im_fx[fb_cfg->remix_order[i]], frame_len ) ); + scale_sig32( hFbMixer->ppFilterbank_inFR_re_fx[fb_cfg->remix_order[i]], frame_len, q_shift ); + scale_sig32( hFbMixer->ppFilterbank_inFR_im_fx[fb_cfg->remix_order[i]], frame_len, q_shift ); + hFbMixer->q_ppFilterbank_inFR[fb_cfg->remix_order[i]] = add( q_shift, q_ppOut_pcm[fb_cfg->remix_order[i]] ); move16(); } @@ -915,7 +919,10 @@ static Word16 ivas_calculate_abs_fr_fx( move16(); Word16 idx_short_stride_bin_to_band = 0; move16(); + Word16 quo, tmp, exp_diff; + Word32 temp = Mpy_32_32( sampling_rate, 42949673 /* FRAMES_PER_SEC in Q31 */ ); + frame_len = extract_l( temp ); FOR( i = 0; i < bands; i++ ) { @@ -932,13 +939,11 @@ static Word16 ivas_calculate_abs_fr_fx( Word32 short_stride_pow_spec_fx[MDFT_FB_BANDS_240]; Word32 short_stride_nrg_fx = 0; move16(); - Word16 exp_diff = 0, tmp; + exp_diff = 0; move16(); - Word32 cldfb_nrg_fx = 0; - Word16 cldfb_nrg_e = 0; - move16(); - move16(); + Word64 cldfb_nrg_fx = 0; + move64(); Word16 short_stride = pFb->fb_bin_to_band.short_stride; move16(); Word32 res_dec1, res_frac, res_dec2; @@ -959,38 +964,24 @@ static Word16 ivas_calculate_abs_fr_fx( { Word32 sq_abs_fx; - Word16 sq_abs_e; // Word32 real = L_shr( *long_mdft_ptr_re_fx, 3 ); // Q27 Word32 real = *long_mdft_ptr_re_fx; // Q30 move32(); // Word32 imag = L_shr( *long_mdft_ptr_im_fx, 3 ); // Q27 Word32 imag = *long_mdft_ptr_im_fx; // Q30 - - Word16 real_exp, imag_exp; - move32(); - - Word32 real_sq, imag_sq; - - real_sq = Mpy_32_32( real, real ); // Q30 + Q30 - 31 = Q29 - real_exp = 2; - move32(); - imag_sq = Mpy_32_32( imag, imag ); // Q30 + Q30 - 31 = Q29 - imag_exp = 2; move32(); - - sq_abs_fx = BASOP_Util_Add_Mant32Exp( real_sq, real_exp, imag_sq, imag_exp, &sq_abs_e ); // Q(31 - sq_abs_e) - + Word64 acc = W_mac_32_32( W_mult_32_32( real, real ), imag, imag ); // Q61 + sq_abs_fx = W_extract_h( acc ); // Q28 long_mdft_ptr_re_fx++; long_mdft_ptr_im_fx++; /* accumulate bin energies within a short stride bin */ - short_stride_nrg_fx = L_add( short_stride_nrg_fx, L_shl( sq_abs_fx, sub( Q22, sub( Q31, sq_abs_e ) ) ) ); - short_stride_nrg_fx = L_add( short_stride_nrg_fx, L_shl( sq_abs_fx, sub( Q22, sub( Q31, sq_abs_e ) ) ) ); // Q(31 - sq_abs_e) -> Q22 + short_stride_nrg_fx = L_add( short_stride_nrg_fx, L_shr( sq_abs_fx, 6 ) ); // Q22 move32(); - IF( !( ( j + 1 ) % num_bins_per_short_stride_bin ) ) + IF( !( add( j, 1 ) % num_bins_per_short_stride_bin ) ) { /* new short stride bin */ short_stride_pow_spec_fx[j / num_bins_per_short_stride_bin] = short_stride_nrg_fx; /* energy rather than magnitude works better for covariance weighting*/ @@ -1001,33 +992,38 @@ static Word16 ivas_calculate_abs_fr_fx( } /* accumulate bin energies within a CLDFB band */ - cldfb_nrg_fx = BASOP_Util_Add_Mant32Exp( cldfb_nrg_fx, cldfb_nrg_e, sq_abs_fx, sq_abs_e, &cldfb_nrg_e ); + cldfb_nrg_fx = W_mac_32_32( cldfb_nrg_fx, sq_abs_fx, 1 ); // Q29 - IF( !( ( j + 1 ) % num_bins_per_cldfb_band ) ) + IF( !( add( j, 1 ) % num_bins_per_cldfb_band ) ) { - Word32 temp = Sqrt32( cldfb_nrg_fx, &cldfb_nrg_e ); - temp = L_shl( temp, sub( cldfb_nrg_e, Q9 ) ); // Q22 + Word16 exp = W_norm( cldfb_nrg_fx ); + cldfb_nrg_fx = W_shl( cldfb_nrg_fx, exp ); + exp = sub( 34, exp ); // 31 - (Q29 + exp -32) + temp = Sqrt32( W_extract_h( cldfb_nrg_fx ), &exp ); + temp = L_shl( temp, sub( exp, Q9 ) ); // Q22 pFb->fb_bin_to_band.pp_cldfb_weights_per_spar_band_fx[j / num_bins_per_cldfb_band][i] = temp; // Q22 move32(); cldfb_nrg_fx = 0; move32(); - cldfb_nrg_e = 0; - move16(); } } + quo = BASOP_Util_Divide3232_Scale( ONE_IN_Q30, short_stride_max_per_spar_band_fx, &exp_diff ); + /* Q of quo = Q30 - Q22 + (15 - exp_diff) --> Q23 - exp_diff. + With Mult_32_16, Q23 - exp_diff - 15 --> Q8 - exp_diff */ + exp_diff = sub( Q8, exp_diff ); + /*loop over the short MDFT bins*/ FOR( j = 0; j < short_stride; j++ ) { - tmp = BASOP_Util_Divide3232_Scale( short_stride_pow_spec_fx[j], short_stride_max_per_spar_band_fx, &exp_diff ); - short_stride_pow_spec_fx[j] = L_shl( L_deposit_l( tmp ), add( Q7, exp_diff ) ); // Q22 + short_stride_pow_spec_fx[j] = L_shr( Mult_32_16( short_stride_pow_spec_fx[j], quo ), exp_diff ); // Q22 move32(); short_stride_pow_spec_fx[j] = L_max( L_sub( short_stride_pow_spec_fx[j], 1258291 ), 0 ); // 0.3f * ONE_IN_Q22 move32(); - tmp = BASOP_Util_Divide3232_Scale( short_stride_pow_spec_fx[j], 2936012, &exp_diff ); // 0.7f * ONE_IN_Q22 - short_stride_pow_spec_fx[j] = L_shl( L_deposit_l( tmp ), add( Q7, exp_diff ) ); // Q22 + short_stride_pow_spec_fx[j] = L_shl( Mpy_32_32( short_stride_pow_spec_fx[j], 1533916891 /* 1/0.7 in Q30 */ ), 1 ); // Q22 move32(); + IF( short_stride_pow_spec_fx[j] > 0 ) { assert( idx_short_stride_bin_to_band < 2 * MDFT_FB_BANDS_240 ); /* array size of p_short_stride_bin_to_band */ @@ -1083,6 +1079,13 @@ static Word16 ivas_calculate_abs_fr_fx( sum_over_spar_bands_fx = L_max( sum_over_spar_bands_fx, EPSILON_FX ); // Q22 move32(); + exp_diff = 0; + move16(); + tmp = BASOP_Util_Divide3232_Scale( ONE_IN_Q30, sum_over_spar_bands_fx, &exp_diff ); + /* Q of quo = Q30 - Q22 + (15 - exp_diff) --> Q23 - exp_diff. + With Mult_32_16, Q23 - exp_diff - 15 --> Q8 - exp_diff */ + exp_diff = sub( Q8, exp_diff ); + FOR( i = 0; i < bands; i++ ) { test(); @@ -1096,20 +1099,13 @@ static Word16 ivas_calculate_abs_fr_fx( move16(); } - Word16 exp_diff = 0; - move16(); - Word16 tmp = BASOP_Util_Divide3232_Scale( pFb->fb_bin_to_band.pp_cldfb_weights_per_spar_band_fx[j][i], sum_over_spar_bands_fx, &exp_diff ); - pFb->fb_bin_to_band.pp_cldfb_weights_per_spar_band_fx[j][i] = L_shl( L_deposit_l( tmp ), add( Q7, exp_diff ) ); // Q22 + pFb->fb_bin_to_band.pp_cldfb_weights_per_spar_band_fx[j][i] = L_shr( Mult_32_16( pFb->fb_bin_to_band.pp_cldfb_weights_per_spar_band_fx[j][i], tmp ), exp_diff ); move32(); } pFb->fb_bin_to_band.p_spar_start_bands[j] = spar_start; move16(); } - Word16 exp; - frame_len = BASOP_Util_Divide3232_Scale( sampling_rate, FRAMES_PER_SEC, &exp ); - frame_len = shr( frame_len, sub( 15, exp ) ); - set32_fx( ppFilterbank_FRs_s_fx, 0, frame_len ); /*Commented logic is for calculating number of active bands, can be removed if not needed */ @@ -1136,7 +1132,7 @@ static Word16 ivas_calculate_abs_fr_fx( Word32 temp_fx = 0; move32(); - Word16 exp_diff = 0; + exp_diff = 0; move16(); Word32 real = L_shr( *pFilterbank_bin_to_band_re_fx, 3 ); // Q27 Word32 imag = L_shr( *pFilterbank_bin_to_band_im_fx, 3 ); // Q27 @@ -1195,7 +1191,7 @@ static Word16 ivas_calculate_abs_fr_fx( { Word16 abs_active_bins = pFb->fb_bin_to_band.pFb_active_bins_per_band[j]; Word16 abs_start_offset = pFb->fb_bin_to_band.pFb_start_bin_per_band[j]; - Word16 exp_diff = 0, tmp; + exp_diff = 0; move16(); move16(); diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 03bc3d6e5761cb47156dd15f849625fe99545cea..5ea7b076547372e12d874221962cc368301efabc 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -83,12 +83,6 @@ ivas_error create_sce_enc( const int32_t element_brate /* i : element bitrate */ ); -ivas_error create_evs_sce_enc( - Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ - const int16_t sce_id, /* i : SCE # identifier */ - const int32_t element_brate /* i : element bitrate */ -); - ivas_error create_cpe_enc( Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ const int16_t cpe_id, /* i : CPE # identifier */ @@ -99,15 +93,6 @@ ivas_error create_mct_enc_fx( Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ ); -ivas_error ivas_sba_enc_reconfigure( - Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ -); - -void destroy_sce_enc( - SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */ - Flag is_evs /* i : Flag to indicate EVS encoder */ -); - void destroy_cpe_enc( CPE_ENC_HANDLE hCPE /* i/o: CPE encoder structure */ ); @@ -248,6 +233,9 @@ 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 @@ -1212,41 +1200,6 @@ void add_HB_to_mono_dmx( * Range Coder prototypes *----------------------------------------------------------------------------------*/ -void rc_uni_enc_init( - RangeUniEncState *rc_st_enc /* i/o: RC state handle */ -); - -void rc_uni_enc_encode_fast( - RangeUniEncState *rc_st_enc, /* i/o: RC state handle */ - const uint16_t cum_freq, /* i : Cumulative frequency up to symbol */ - const uint16_t sym_freq, /* i : Symbol frequency */ - const uint16_t tot_shift /* i : Total frequency as a power of 2 */ -); - -void rc_uni_enc_encode_symbol_fastS( - RangeUniEncState *rc_st_enc, /* i/o: Encoder state */ - const uint16_t symbol, /* i : Symbol to encode */ - const uint16_t cum_freq[], /* i : Cumulative frequency up to symbol */ - const uint16_t sym_freq[], /* i : Symbol frequency */ - const uint16_t tot_shift /* i : Total frequency as a power of 2 */ -); - -void rc_uni_enc_encode_bits( - RangeUniEncState *rc_st_enc, /* i/o: RC state handle */ - const uint16_t value, /* i : Value to encode */ - const int16_t bits /* i : Number of bits */ -); - -/*! r: Total number of bits produced */ -int16_t rc_uni_enc_virtual_finish( - RangeUniEncState *rc_st_enc /* i : RC state handle */ -); - -/*! r: Total number of bits produced */ -int16_t rc_uni_enc_finish( - RangeUniEncState *rc_st_enc /* i/o: RC state handle */ -); - void rc_uni_dec_init( RangeUniDecState *rc_st_dec, /* i/o: RC state handle */ uint16_t *bit_buffer, /* i : Bit buffer */ @@ -1400,13 +1353,6 @@ void stereo_icBWE_decproc( * Stereo classifiers prototypes *----------------------------------------------------------------------------------*/ -/*! r: element mode */ -int16_t select_stereo_mode( - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ - const IVAS_FORMAT ivas_format /* i : IVAS format */ -); - - void stereo_classifier_features( STEREO_CLASSIF_HANDLE hStereoClassif, /* i/o: stereo classifier structure */ const int16_t idchan, /* i : channel ID */ diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index dd7191b3f61cfa26bdcae640ff4b286227e79268..5ce037b9a2db1bf16bd7491fda0bc13cd25385e2 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -53,6 +53,17 @@ void ivas_masa_dec_close_fx( MASA_DECODER_HANDLE *hMasa /* i/o: MASA metadata structure */ ); +ivas_error create_evs_sce_enc_fx( + Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ + const Word16 sce_id, /* i : SCE # identifier */ + const Word32 element_brate /* i : element bitrate */ +); + +void destroy_sce_enc_fx( + SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */ + Flag is_evs /* i : Flag to indicate EVS encoder */ +); + void generate_gridEq_fx( SPHERICAL_GRID_DATA *data /* o : data structure for grid */ ); @@ -1868,7 +1879,7 @@ void ivas_wb_tbe_dec_fx( Word16 *synth, /* o : WB synthesis/final synthesis */ Word16 *Q_synth ); -void ivas_GenShapedWBExcitation_fx( +void GenShapedWBExcitation_ivas_fx( Word16 *excSHB, /* o : synthesized shaped shb exctiation Q_bwe_exc*/ const Word16 *lpc_shb, /* i : lpc coefficients Q12*/ Word16 *exc4kWhtnd, /* o : whitened synthesized shb excitation Q_bwe_exc*/ @@ -2226,11 +2237,7 @@ void ivas_mct_side_bits_fx( const Word16 nb_bits_metadata /* i : number of metadata bits */ ); -#ifdef BASOP_NOGLOB /*Critical overflow */ Flag conv_fx_32( -#else -void conv_fx_32( -#endif const Word16 x[], /* i : i vector Q_new*/ const Word16 h[], /* i : impulse response (or second i vector) Q(15)*/ Word32 y[], /* o : output vetor (result of convolution) 12 bits*/ @@ -2805,18 +2812,18 @@ Word16 mdct_classifier_ivas_fx( * Range Coder prototypes *----------------------------------------------------------------------------------*/ -void rc_uni_enc_init( +void rc_uni_enc_init_fx( RangeUniEncState *rc_st_enc /* i/o: RC state handle */ ); -void rc_uni_enc_encode_fast( +void rc_uni_enc_encode_fast_fx( RangeUniEncState *rc_st_enc, /* i/o: RC state handle */ const UWord16 cum_freq, /* i : Cumulative frequency up to symbol */ const UWord16 sym_freq, /* i : Symbol frequency */ const UWord16 tot_shift /* i : Total frequency as a power of 2 */ ); -void rc_uni_enc_encode_symbol_fastS( +void rc_uni_enc_encode_symbol_fastS_fx( RangeUniEncState *rc_st_enc, /* i/o: Encoder state */ const UWord16 symbol, /* i : Symbol to encode */ const UWord16 cum_freq[], /* i : Cumulative frequency up to symbol */ @@ -2825,16 +2832,16 @@ void rc_uni_enc_encode_symbol_fastS( ); /*! r: Total number of bits produced */ -Word16 rc_uni_enc_finish( +Word16 rc_uni_enc_finish_fx( RangeUniEncState *rc_st_enc /* i/o: RC state handle */ ); /*! r: Total number of bits produced */ -Word16 rc_uni_enc_virtual_finish( +Word16 rc_uni_enc_virtual_finish_fx( RangeUniEncState *rc_st_enc /* i : RC state handle */ ); -void rc_uni_enc_encode_bits( +void rc_uni_enc_encode_bits_fx( RangeUniEncState *rc_st_enc, /* i/o: RC state handle */ const UWord16 value, /* i : Value to encode */ const Word16 bits /* i : Number of bits */ @@ -3101,6 +3108,12 @@ void ivas_smc_mode_selection_fx( const Word16 flag_spitch /* i : flag to indicate very short stable pitch*/ ); +/*! r: element mode */ +Word16 select_stereo_mode_fx( + CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ + const IVAS_FORMAT ivas_format /* i : IVAS format */ +); + void stereo_classifier_features_ivas_fx( STEREO_CLASSIF_HANDLE hStereoClassif, /* i/o: stereo classifier structure */ const Word16 idchan, /* i : channel ID */ @@ -4282,7 +4295,7 @@ void stereo_dft_dec_read_BS_fx( const Word16 ivas_format /* i : ivas format Q0*/ ); -Word16 write_bitstream_adapt_GR( +Word16 write_bitstream_adapt_GR_fx( BSTR_ENC_HANDLE hBstr, /* i/o: Encoder bitstream handle */ const Word16 ind, /* i : bitstream index */ const Word16 *in, /* i : values to be written in bitstream */ @@ -4308,7 +4321,7 @@ Word16 adapt_GR_ief_fx( const Word16 try_diff /* i : diff coding allowed 1/0 */ ); -Word16 adapt_GR_rpg1_ief( +Word16 adapt_GR_rpg1_ief_fx( const Word16 *in, /* i : res pred gains input vector */ Word16 *in_diff, /* o : encoded symbols in case of differential encoding */ const Word16 *prev, /* i : previous frame data */ @@ -4322,14 +4335,14 @@ Word16 adapt_GR_rpg1_ief( const Word16 try_diff /* i : diff coding allowed 1/0 */ ); -Word16 write_GR1( +Word16 write_GR1_fx( BSTR_ENC_HANDLE hBstr, /* i/o: Encoder bitstream handle */ const Word16 ind, /* i : bitstream index */ const Word16 *in, /* i : data to be encoded */ const Word16 len /* i : input data length */ ); -Word16 write_bitstream_GR( +Word16 write_bitstream_GR_fx( BSTR_ENC_HANDLE hBstr, /* i/o: Encoder bitstream handle */ const Word16 ind, /* i : bitstream index */ const Word16 *in, /* i : input vector */ @@ -4761,7 +4774,7 @@ void stereo_mdct2dft_update_fx( Word32 synth0_fx[] /* i/o: synthesis @output Fs, ch0 Q11*/ ); -Word16 write_GR0( +Word16 write_GR0_fx( BSTR_ENC_HANDLE hBstr, /* i/o: Encoder bitstream handle */ const Word16 ind, /* i : bitstream index */ const Word16 *in, /* i : data to be encoded */ @@ -4850,7 +4863,8 @@ void ivas_dirac_param_est_enc_fx( const Word16 hodirac_flag, const Word16 nchan_fb_in, Word16 *mono_frame_count, - Word16 *dirac_mono_flag ); + Word16 *dirac_mono_flag, + const Word16 shift ); ivas_error ivas_cldfb_dec_reconfig_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ @@ -4859,6 +4873,10 @@ ivas_error ivas_cldfb_dec_reconfig_fx( const Word16 numCldfbSyntheses_old /* i : number of CLDFB synthesis instances in previous frame */ ); +ivas_error ivas_sba_enc_reconfigure_fx( + Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ +); + Word16 ivas_sba_get_order_fx( const Word16 nb_channels, /* i : Number of ambisonic channels */ const Word16 sba_planar /* i : SBA planar flag */ @@ -5750,8 +5768,8 @@ ivas_error ivas_dirac_enc_fx( const Word16 input_frame, /* i : input frame length */ const Word16 dtx_vad, /* i : DTX vad flag */ const IVAS_FORMAT ivas_format, /* i : ivas format */ - const Word16 hodirac_flag /* i : hodirac flag */ -); + const Word16 hodirac_flag, /* i : hodirac flag */ + const Word16 shift ); ivas_error ivas_spar_md_enc_init_fx( ivas_spar_md_enc_state_t *hMdEnc, /* o : MD encoder handle */ diff --git a/lib_com/ivas_rom_com_fx.c b/lib_com/ivas_rom_com_fx.c index ac47365616ae6dc38b6b80d115ebd47bb02c3e3e..cc138d070b85202a6bd91c580ff908099857281a 100644 --- a/lib_com/ivas_rom_com_fx.c +++ b/lib_com/ivas_rom_com_fx.c @@ -1356,6 +1356,16 @@ const UWord32 tdm_ratio_tabl_fx[TDM_NQ + 1] = { 2147483647, 2147483647, 2147483647 }; +// Q30 +const Word32 tdm_ratio_tabl_fx_Q30[] = { + 0, 0, 11703786, 26306674, 46385648, 71940704, 102542344, 137868448, + 177596896, 221298192, 268435456, 318471840, 370977792, 425201760, 480714208, + 536870912, 593027584, 648540032, 702764032, 755270016, 805306368, 852443648, + 896144896, 935873344, 971199488, 1001801152, 1027356160, 1047435136, + 1062038016, 1073741824, 1073741824, 1073741824 +}; + + // Q24 const Word32 tdm_ratio_tabl_fx_Q24[TDM_NQ + 1] = { 0, 0, 182871, 411041, 724775, 1124073, 1602224, 2154194, diff --git a/lib_com/ivas_rom_com_fx.h b/lib_com/ivas_rom_com_fx.h index 88bbaabbc1ff3dc34004d6192170ae7b2639044d..e1f4d0a6eb9379ced0a934c0b8c98cb714758714 100644 --- a/lib_com/ivas_rom_com_fx.h +++ b/lib_com/ivas_rom_com_fx.h @@ -108,6 +108,7 @@ extern const Word16 pow_10_icbwe_gsMappingDFT_tbl_fx[]; *----------------------------------------------------------------------------------*/ extern const UWord32 tdm_ratio_tabl_fx[TDM_NQ + 1]; +extern const Word32 tdm_ratio_tabl_fx_Q30[TDM_NQ + 1]; extern const Word32 tdm_ratio_tabl_fx_Q24[TDM_NQ + 1]; extern const UWord32 tdm_den_ratio_tabl_fx[]; extern const Word16 icbwe_gsMapping_tbl_fx[]; // Q12 diff --git a/lib_com/ivas_spar_com.c b/lib_com/ivas_spar_com.c index 362c1c9ed71a7328f4184d0f5c73d0fbd563290d..14de6cc1524c2068ce56efcaeb937e48ffac5640 100644 --- a/lib_com/ivas_spar_com.c +++ b/lib_com/ivas_spar_com.c @@ -2636,7 +2636,7 @@ static void ivas_calc_p_coeffs_per_band_enc_fx( #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 + 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 ); @@ -3836,7 +3836,11 @@ 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(); } } @@ -7044,7 +7048,7 @@ void ivas_dirac_dec_get_response_fx( Word16 Q_out ) { Word16 index_azimuth, index_elevation; - Word16 el, e, az; + Word16 el, e, az, q_diff; Word32 cos_1_fx, cos_2_fx, sin_1_fx, cos_az_fx[3]; Word32 sin_az_fx[3]; Word32 f_fx; @@ -7055,49 +7059,39 @@ void ivas_dirac_dec_get_response_fx( index_azimuth = add( azimuth, 180 ) % 360; move16(); index_elevation = add( elevation, 90 ); - IF( GT_16( index_elevation, 90 ) ) + + e = 1; + move16(); + + if ( GT_16( index_elevation, 90 ) ) { e = -1; - move16(); - } - ELSE - { - e = 1; - move16(); } - IF( GT_16( index_elevation, 90 ) ) + el = index_elevation; + move16(); + + if ( GT_16( index_elevation, 90 ) ) { el = sub( 180, index_elevation ); - move16(); - } - ELSE - { - el = index_elevation; - move16(); } - IF( GT_16( index_azimuth, 180 ) ) + az = index_azimuth; + move16(); + + if ( GT_16( index_azimuth, 180 ) ) { az = sub( 360, index_azimuth ); - move16(); - } - ELSE - { - az = index_azimuth; - move16(); } - IF( GT_16( index_azimuth, 180 ) ) + f_fx = 1; + move16(); + + if ( GT_16( index_azimuth, 180 ) ) { f_fx = -1; - move16(); - } - ELSE - { - f_fx = 1; - move16(); } + 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 @@ -7122,54 +7116,54 @@ void ivas_dirac_dec_get_response_fx( response_fx[0] = L_shl_sat( 1, Q_out ); // Q_out move32(); + q_diff = sub( Q_out, 29 ); + FOR( l = 1; l <= ambisonics_order; l++ ) { b_2 = imult1616( l, l ); - b1_2 = add( imult1616( l, l ), shl( l, 1 ) ); + b1_2 = add( b_2, shl( l, 1 ) ); FOR( m = 0; m < l; m += 2 ) { - b = add( b_2, m ); + b = b_2 + m; a = dirac_gains_P_idx[b]; - move16(); + c_fx_better = local_result_table[el][a]; // q30 move32(); - response_fx[b] = L_shl( Mpy_32_32( c_fx_better, sin_az_fx[l - m - 1] ), sub( Q_out, 29 ) ); // Q_out + response_fx[b] = L_shl( Mpy_32_32( c_fx_better, sin_az_fx[l - m - 1] ), q_diff ); // Q_out move32(); - b1 = sub( b1_2, m ); - response_fx[b1] = L_shl( Mpy_32_32( c_fx_better, cos_az_fx[l - m - 1] ), sub( Q_out, 29 ) ); // Q_out + b1 = b1_2 - m; + response_fx[b1] = L_shl( Mpy_32_32( c_fx_better, cos_az_fx[l - m - 1] ), q_diff ); // Q_out move32(); } FOR( m = 1; m < l; m += 2 ) { - b = add( b_2, m ); + b = b_2 + m; a = dirac_gains_P_idx[b]; - move16(); c_fx_better = local_result_table[el][a]; // q30 move32(); if ( EQ_16( e, -1 ) ) { c_fx_better = L_negate( c_fx_better ); // q30 } - response_fx[b] = L_shl( Mpy_32_32( c_fx_better, sin_az_fx[l - m - 1] ), sub( Q_out, 29 ) ); // Q_out + response_fx[b] = L_shl( Mpy_32_32( c_fx_better, sin_az_fx[l - m - 1] ), q_diff ); // Q_out move32(); - b1 = sub( b1_2, m ); - response_fx[b1] = L_shl( Mpy_32_32( c_fx_better, cos_az_fx[l - m - 1] ), sub( Q_out, 29 ) ); // Q_out + + b1 = b1_2 - m; + response_fx[b1] = L_shl( Mpy_32_32( c_fx_better, cos_az_fx[l - m - 1] ), q_diff ); // Q_out move32(); } b = add( b_2, l ); a = dirac_gains_P_idx[b]; - move16(); c_fx_better = local_result_table_2[el][a]; // q30 move32(); - IF( EQ_16( ( l % 2 ), 1 ) ) + IF( EQ_16( s_and( l, 0x01 ), 1 ) ) { if ( EQ_16( e, -1 ) ) { c_fx_better = L_negate( c_fx_better ); // q30 - move32(); } } response_fx[b] = L_shl( c_fx_better, sub( Q_out, 30 ) ); // Q_out diff --git a/lib_com/ivas_stereo_ica_com_fx.c b/lib_com/ivas_stereo_ica_com_fx.c index 3ebfd99c1e065ba93c7f0a8deeee608c1acb3ce0..be9f358683e12cb417e25c2e2a447f9220d4f958 100644 --- a/lib_com/ivas_stereo_ica_com_fx.c +++ b/lib_com/ivas_stereo_ica_com_fx.c @@ -131,17 +131,7 @@ static void interpTargetChannel_fx( Word32 spread_factor2_fx; Word64 tempD1_fx, tempD2_fx; - d = negate( sub( currShift, prevShift ) ); - IF( d >= 0 ) - { - signShift = 1; - move16(); - } - ELSE - { - signShift = -1; - move16(); - } + d = sub( prevShift, currShift ); IF( d == 0 ) { @@ -149,6 +139,15 @@ static void interpTargetChannel_fx( return; } + signShift = 1; + move16(); + + if ( d < 0 ) + { + signShift = -1; + move16(); + } + N = L_shift_adapt; move16(); Word32 *table_pointer = NULL; @@ -207,7 +206,7 @@ static void interpTargetChannel_fx( FOR( j = lim1; j <= lim2; j++ ) { - ptr2_fx[i] = L_add( Mpy_32_32( win_fx[j * INTERP_FACTOR1 - i], ptr1_fx[j] ), ptr2_fx[i] ); // qsynth + ptr2_fx[i] = Madd_32_32( ptr2_fx[i], win_fx[j * INTERP_FACTOR1 - i], ptr1_fx[j] ); // qsynth move32(); } } @@ -225,44 +224,31 @@ static void interpTargetChannel_fx( tempD1_fx = W_deposit32_l( table_D1_pointer[abs( d )] ); // Q35 tempD2_fx = W_mult0_32_32( 3, table_D1_pointer[abs( d )] ); // Q35 - IF( EQ_16( signShift, 1 ) ) + tempF1_fx = -ONE_IN_Q12; // Q12 + move32(); + + if ( EQ_16( signShift, 1 ) ) { tempF1_fx = ONE_IN_Q12; // Q12 move32(); } - ELSE - { - tempF1_fx = -ONE_IN_Q12; // Q12 - move32(); - } + tempF1_fx = L_sub( imult3216( factor_fx, d ), tempF1_fx ); // Q12 - FOR( k = 0; k < sub( N, 1 ); k++ ) + FOR( k = 0; k < N - 1; k++ ) { - Word32 local = L_sub( W_extract_l( W_shr( W_mult0_32_32( tempF1_fx, spread_factor2_fx ), 31 ) ), ONE_IN_Q12 ); // Q12 - Word32 sign_local; - IF( local > 0 ) - { - sign_local = 1; - move32(); - } - ELSE - { - sign_local = -1; - move32(); - } - Word32 local_int = W_extract_l( W_shr( W_abs( local ), 12 ) ); // Q0 + Word32 local = Madd_32_32( -ONE_IN_Q12, tempF1_fx, spread_factor2_fx ); // Q12 + Word32 local_int = L_shr( local, 12 ); // Q0 Word32 res_a1, res_a2, res_a3; Word32 res_b1, res_b2, res_b3; Word32 res_c1, res_c2, res_c3; Word32 res_d1, res_d2, res_d3; - Word64 local_int_scaled; + Word32 local_int_scaled; Word64 res_a, res_b, res_c, res_d; Word64 tempa, tempb; Word64 mult_a_D1, mult_b_D2; - local_int = W_extract_l( W_mult0_32_32( sign_local, local_int ) ); // Q0 - local_int_scaled = W_deposit32_l( L_shl( local_int, 12 ) ); // Q12 - lim1 = extract_l( local_int ); // Q0 - IF( W_sub( local_int_scaled, local ) > 0 ) // Q21 + local_int_scaled = L_shl( local_int, 12 ); // Q12 + lim1 = extract_l( local_int ); // Q0 + if ( L_sub( local_int_scaled, local ) > 0 ) // Q12 { lim1 = sub( lim1, 1 ); // Q0 } @@ -387,7 +373,7 @@ static void targetCh_AlignStereoDFT_fx( } FOR( i = 0; i < L_shift_adapt; i++ ) { - target_fx[i] = L_add( Mpy_32_32( alpha_fx, fadeInBuff_fx[i] ), Mpy_32_32( L_sub( ONE_IN_Q31, alpha_fx ), fadeOutBuff_fx[i] ) ); // qsynth + target_fx[i] = Madd_32_32( Mpy_32_32( alpha_fx, fadeInBuff_fx[i] ), L_sub( ONE_IN_Q31, alpha_fx ), fadeOutBuff_fx[i] ); // qsynth move32(); alpha_fx = L_add_sat( alpha_fx, winSlope_fx ); // Q31 diff --git a/lib_com/ivas_stereo_mdct_bands_com.c b/lib_com/ivas_stereo_mdct_bands_com.c index 153f477b6ebe97ddce6be91ef867060c7f20a456..8c21798b662f2be542098422774c39e9cc64333b 100644 --- a/lib_com/ivas_stereo_mdct_bands_com.c +++ b/lib_com/ivas_stereo_mdct_bands_com.c @@ -46,11 +46,7 @@ * Local union *-------------------------------------------------------------------*/ -#ifndef BASOP_NOGLOB typedef union -#else /* BASOP_NOGLOB */ -typedef union -#endif /* BASOP_NOGLOB */ { MDCTStereoBands_config const *steBands; SpectrumWarping const *lpcBndsParam; diff --git a/lib_com/ivas_tools.c b/lib_com/ivas_tools.c index 8d486df04dd62d69e843008e92faa6cc86770729..d6210dfc7d4b3c050bd77310f010c93922678654 100644 --- a/lib_com/ivas_tools.c +++ b/lib_com/ivas_tools.c @@ -942,6 +942,12 @@ Word16 matrix_product_mant_exp_fx( Word16 *Zp_fx_e = out_e; Word16 row, col; Word16 x_idx, y_idx; + Word64 temp; + Word16 temp_e; + Word16 prod_e = add( X_fx_e, Y_fx_e ); + + Word16 max_exp = -31; + move16(); /* Processing */ test(); @@ -957,17 +963,28 @@ Word16 matrix_product_mant_exp_fx( { FOR( i = 0; i < colsX; ++i ) { - ( *Zp_fx ) = 0; - move32(); - ( *Zp_fx_e ) = 0; - move16(); + temp = 0; + move64(); + FOR( k = 0; k < rowsX; ++k ) { - x_idx = add( k, imult1616( i, rowsX ) ); - y_idx = add( k, imult1616( j, rowsY ) ); - ( *Zp_fx ) = BASOP_Util_Add_Mant32Exp( *Zp_fx, *Zp_fx_e, Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ), add( X_fx_e, Y_fx_e ), Zp_fx_e ); /*Q31 - Zp_fx_e*/ - move32(); + 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 } + /* Maximize accumulated value to 32-bit */ + temp_e = W_norm( temp ); + temp = W_shl( temp, temp_e ); + if ( 0 == temp ) + { + temp_e = prod_e; + move16(); + } + *Zp_fx_e = sub( prod_e, temp_e ); + move16(); + ( *Zp_fx ) = W_extract_h( temp ); + move32(); + max_exp = s_max( max_exp, *Zp_fx_e ); // Find the max exp Zp_fx++; Zp_fx_e++; } @@ -987,17 +1004,27 @@ Word16 matrix_product_mant_exp_fx( { FOR( i = 0; i < rowsX; ++i ) { - ( *Zp_fx ) = 0; - move32(); - ( *Zp_fx_e ) = 0; - move16(); + temp = 0; + move64(); FOR( k = 0; k < colsX; ++k ) { - x_idx = add( i, imult1616( k, rowsX ) ); - y_idx = add( j, imult1616( k, rowsY ) ); - ( *Zp_fx ) = BASOP_Util_Add_Mant32Exp( *Zp_fx, *Zp_fx_e, Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ), add( X_fx_e, Y_fx_e ), Zp_fx_e ); /*Q31 - Zp_fx_e*/ - move32(); + 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 + } + /* Maximize accumulated value to 32-bit */ + temp_e = W_norm( temp ); + temp = W_shl( temp, temp_e ); + if ( 0 == temp ) + { + temp_e = prod_e; + move16(); } + *Zp_fx_e = sub( prod_e, temp_e ); + move16(); + ( *Zp_fx ) = W_extract_h( temp ); + move32(); + max_exp = s_max( max_exp, *Zp_fx_e ); // Find the max exp Zp_fx++; Zp_fx_e++; } @@ -1017,18 +1044,27 @@ Word16 matrix_product_mant_exp_fx( { FOR( i = 0; i < colsX; ++i ) { - ( *Zp_fx ) = 0; - move32(); - ( *Zp_fx_e ) = 0; - move16(); + temp = 0; + move64(); FOR( k = 0; k < colsX; ++k ) { - x_idx = add( k, imult1616( i, rowsX ) ); - y_idx = add( j, imult1616( k, rowsY ) ); - ( *Zp_fx ) = BASOP_Util_Add_Mant32Exp( *Zp_fx, *Zp_fx_e, Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ), add( X_fx_e, Y_fx_e ), Zp_fx_e ); /*Q31 - Zp_fx_e*/ - move32(); + 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 } - + /* Maximize accumulated value to 32-bit */ + temp_e = W_norm( temp ); + temp = W_shl( temp, temp_e ); + if ( 0 == temp ) + { + temp_e = prod_e; + move16(); + } + *Zp_fx_e = sub( prod_e, temp_e ); + move16(); + ( *Zp_fx ) = W_extract_h( temp ); + move32(); + max_exp = s_max( max_exp, *Zp_fx_e ); // Find the max exp Zp_fx++; Zp_fx_e++; } @@ -1049,17 +1085,26 @@ Word16 matrix_product_mant_exp_fx( { FOR( i = 0; i < rowsX; ++i ) { - ( *Zp_fx ) = 0; - move32(); - ( *Zp_fx_e ) = 0; - move16(); + temp = 0; + move64(); FOR( k = 0; k < colsX; ++k ) { - x_idx = add( i, imult1616( k, rowsX ) ); - y_idx = add( k, imult1616( j, rowsY ) ); - ( *Zp_fx ) = BASOP_Util_Add_Mant32Exp( *Zp_fx, *Zp_fx_e, Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ), add( X_fx_e, Y_fx_e ), Zp_fx_e ); /*Q31 - Zp_fx_e*/ - move32(); + 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 + } + /* Maximize accumulated value to 32-bit */ + temp_e = W_norm( temp ); + temp = W_shl( temp, temp_e ); + if ( 0 == temp ) + { + temp_e = prod_e; } + *Zp_fx_e = sub( prod_e, temp_e ); + move16(); + ( *Zp_fx ) = W_extract_h( temp ); + move32(); + max_exp = s_max( max_exp, *Zp_fx_e ); // Find the max exp Zp_fx++; Zp_fx_e++; } @@ -1070,18 +1115,11 @@ Word16 matrix_product_mant_exp_fx( move16(); } Zp_fx = Z_fx; /*Q31 - Zp_fx_e*/ + Zp_fx_e = out_e; - Word16 max_exp = -31; move16(); - FOR( j = 0; j < row; ++j ) - { - FOR( i = 0; i < col; ++i ) - { - max_exp = s_max( max_exp, *Zp_fx_e ); - Zp_fx_e++; - } - } - Zp_fx_e = out_e; + + *Z_fx_e = max_exp; move16(); FOR( j = 0; j < row; ++j ) diff --git a/lib_com/ivas_transient_det.c b/lib_com/ivas_transient_det.c index 8f8905fdd66d59d6dd59589f9519afd9b55f09ec..dccf4db020f8d5f10e87b9f172e5626e5c071c64 100644 --- a/lib_com/ivas_transient_det.c +++ b/lib_com/ivas_transient_det.c @@ -344,26 +344,26 @@ static Word32 ivas_calc_duck_gain_fx( Word32 duck_gain_out, L_tmp; Word16 tmp_e; - duck_gain_out = L_add( L_shl( Mpy_32_32( L_sub( duck_gain, ONE_IN_Q30 ), duck_coeff ), Q1 ), ONE_IN_Q30 ); /*Q30*/ + duck_gain_out = L_add( Mpy_32_32( L_sub( duck_gain, ONE_IN_Q30 ), duck_coeff ), ONE_IN_Q29 ); /*Q29*/ - IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( Mpy_32_32( duck_mult_fac, env_1 ), add( 2, env1_e ), Mpy_32_32( duck_gain_out, env_2 ), add( 1, env2_e ) ), -1 ) ) + IF( LT_64( W_mult0_32_32( duck_mult_fac, env_1 ), W_shr( W_mult0_32_32( duck_gain_out, env_2 ), sub( env1_e, env2_e ) ) ) ) { + + duck_gain_out = 0; + move32(); + test(); - IF( ( env_1 == 0 ) || ( env_2 == 0 ) ) - { - duck_gain_out = 0; - move32(); - } - ELSE + IF( ( env_1 != 0 ) && ( env_2 != 0 ) ) { L_tmp = BASOP_Util_Divide3232_Scale_cadence( env_1, env_2, &tmp_e ); L_tmp = L_shl( L_tmp, add( sub( env1_e, env2_e ), tmp_e ) ); duck_gain_out = Mpy_32_32( duck_mult_fac, L_tmp ); /*Q29*/ - duck_gain_out = L_shl( duck_gain_out, Q1 ); /*Q30*/ } } + duck_gain_out = L_shl( duck_gain_out, Q1 ); /*Q30*/ + return duck_gain_out; /*Q30*/ } /*-----------------------------------------------------------------------------------------* diff --git a/lib_com/lerp.c b/lib_com/lerp.c index ed2ee211c0fb1576f7b6c4a4027e6c01d35acca7..2fd9321be8e69c972faee89bf3405755a82178ab 100644 --- a/lib_com/lerp.c +++ b/lib_com/lerp.c @@ -310,11 +310,7 @@ static void lerp_proc( const Word16 *f /*Qx*/, Word16 *f_out /*Qx*/, Word16 buff diff = shr( extract_l( pos ), 1 ); /*Q15*/ /*buf[0]=f[0]+pos*(f[1]-f[0]);*/ move16(); -#ifdef BASOP_NOGLOB *ptr++ = add_sat( f[0], msu_r( L_mult( diff, f[1] ), diff, f[0] ) ); /*Qx*/ -#else - *ptr++ = add( f[0], msu_r( L_mult( diff, f[1] ), diff, f[0] ) ); -#endif } ELSE { @@ -324,11 +320,7 @@ static void lerp_proc( const Word16 *f /*Qx*/, Word16 *f_out /*Qx*/, Word16 buff diff = lshr( extract_l( pos ), 1 ); /*Q15*/ move16(); -#ifdef BASOP_NOGLOB *ptr++ = add_sat( f[idx], msu_r_sat( L_mult( diff, f[idx + 1] ), diff, f[idx] ) ); /*Qx*/ -#else - *ptr++ = add( f[idx], msu_r( L_mult( diff, f[idx + 1] ), diff, f[idx] ) ); -#endif } pos = L_add( pos, shift ); @@ -343,11 +335,7 @@ static void lerp_proc( const Word16 *f /*Qx*/, Word16 *f_out /*Qx*/, Word16 buff diff = sub( 16384 /*0.5f Q15*/, diff ); /*Q15*/ } move16(); -#ifdef BASOP_NOGLOB *ptr++ = add_sat( f[idx], msu_r_sat( L_mult( diff, f[idx + 1] ), diff, f[idx] ) ); /*Qx*/ -#else - *ptr++ = add( f[idx], msu_r( L_mult( diff, f[idx + 1] ), diff, f[idx] ) ); -#endif pos = L_add( pos, shift ); @@ -366,11 +354,7 @@ static void lerp_proc( const Word16 *f /*Qx*/, Word16 *f_out /*Qx*/, Word16 buff diff = lshr( extract_l( L_shr( L_sub( pos, L_deposit_h( idx ) ), 1 ) ), 1 ); /*Q15*/ move16(); -#ifdef BASOP_NOGLOB *ptr++ = add_sat( f[idx], shl_sat( msu_r_sat( L_mult( diff, f[idx + 1] ), diff, f[idx] ), 1 ) ); /*Qx*/ -#else - *ptr++ = add( f[idx], shl( msu_r( L_mult( diff, f[idx + 1] ), diff, f[idx] ), 1 ) ); -#endif test(); test(); test(); diff --git a/lib_com/log2.c b/lib_com/log2.c index 1fef489e9ab140faae3ba2ce127067af8effd941..3df1a960ec4728e537d09f4aaa9a8eb0a13e1d32 100644 --- a/lib_com/log2.c +++ b/lib_com/log2.c @@ -193,11 +193,7 @@ Word32 pow_10( Word32 x, Word16 *Q ) /*o : Q15, i: Q26*/ { Overflow = 0; move16(); -#ifdef BASOP_NOGLOB /* Critical Overflow */ L_tmp = L_shl_o( L_tmp, i, &Overflow ); -#else - L_tmp = L_shl( L_tmp, i ); -#endif if ( Overflow ) { count = add( count, 1 ); diff --git a/lib_com/low_rate_band_att_fx.c b/lib_com/low_rate_band_att_fx.c index be06b8b0184b1d3cb7730c21276e3827b4915465..9958b9d5fdef77ec8782e1aaf261baa60b7111b0 100644 --- a/lib_com/low_rate_band_att_fx.c +++ b/lib_com/low_rate_band_att_fx.c @@ -82,14 +82,10 @@ void ivas_fine_gain_pred_fx( 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 */ + Mpy_32_16_ss( L_tmp, tmp1, &L_tmp, &lsb ); /*31-exp+11-15=27-exp */ #endif -#ifdef BASOP_NOGLOB gp = round_fx_o( L_shl_o( L_tmp, add( 1, exp ), &Overflow ), &Overflow ); /*27-exp+1+exp-16=12 */ -#else - gp = round_fx( L_shl( L_tmp, add( 1, exp ) ) ); /*27-exp+1+exp-16=12 */ -#endif test(); test(); IF( EQ_16( core, HQ_CORE ) && R != NULL && LE_16( R[i_sort[band]], 256 ) ) /* 256 is 32 in Q3 */ @@ -104,12 +100,8 @@ void ivas_fine_gain_pred_fx( exp = add( exp, exp2 ); /*gp *= 1.0f - 0.05f / accuracy; */ - tmp = div_s( 13107, accuracy ); /* 0.05 in Q18 */ -#ifdef BASOP_NOGLOB + tmp = div_s( 13107, accuracy ); /* 0.05 in Q18 */ tmp = shr_o( tmp, sub( 34, exp ), &Overflow ); /*15+18-exp+16-15=34-exp */ -#else /* BASOP_NOGLOB */ - tmp = shr( tmp, sub( 34, exp ) ); /*15+18-exp+16-15=34-exp */ -#endif tmp = sub( 32767, tmp ); tmp = s_max( 27554, tmp ); /* Limit attenuation to norm quantizer error, 2^-0.25 in Q15 */ gp = mult_r( tmp, gp ); /*15+12+1-16=12 */ @@ -199,13 +191,9 @@ void fine_gain_pred_fx( exp = norm_l( xx ); 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 */ - Mpy_32_16_ss( L_tmp, fine_gain_pred_sqrt_bw[bw_idx], &L_tmp, &lsb ); /*31-exp+11-15=27-exp */ -#ifdef BASOP_NOGLOB + L_tmp = Isqrt_lc( L_tmp, &exp ); /*31 - exp */ + Mpy_32_16_ss( L_tmp, fine_gain_pred_sqrt_bw[bw_idx], &L_tmp, &lsb ); /*31-exp+11-15=27-exp */ gp = round_fx_o( L_shl_o( L_tmp, add( 1, exp ), &Overflow ), &Overflow ); /*27-exp+1+exp-16=12 */ -#else - gp = round_fx( L_shl( L_tmp, add( 1, exp ) ) ); /*27-exp+1+exp-16=12 */ -#endif test(); test(); IF( EQ_16( core, HQ_CORE ) && R != NULL && LE_16( R[i_sort[band]], 256 ) ) /* 256 is 32 in Q3 */ @@ -220,12 +208,8 @@ void fine_gain_pred_fx( exp = add( exp, exp2 ); /*gp *= 1.0f - 0.05f / accuracy; */ - tmp = div_s( 13107, accuracy ); /* 0.05 in Q18 */ -#ifdef BASOP_NOGLOB + tmp = div_s( 13107, accuracy ); /* 0.05 in Q18 */ tmp = shr_o( tmp, sub( 34, exp ), &Overflow ); /*15+18-exp+16-15=34-exp */ -#else /* BASOP_NOGLOB */ - tmp = shr( tmp, sub( 34, exp ) ); /*15+18-exp+16-15=34-exp */ -#endif tmp = sub( 32767, tmp ); tmp = s_max( 27554, tmp ); /* Limit attenuation to norm quantizer error, 2^-0.25 in Q15 */ gp = mult_r( tmp, gp ); /*15+12+1-16=12 */ diff --git a/lib_com/lpc_tools_fx.c b/lib_com/lpc_tools_fx.c index 8f478dde7c7fdb0d863b2221394b262df3dcba21..1c0fb75006c1ba69e2ccec54c3ccd585751a7fc4 100644 --- a/lib_com/lpc_tools_fx.c +++ b/lib_com/lpc_tools_fx.c @@ -427,11 +427,7 @@ static Word32 Div_32_opt( Word32 L_num /*Q31*/, Word16 denom_hi /*Qx -16*/, Word L_32 = Mpy_32_32( L_num, L_32 ); -#ifdef BASOP_NOGLOB L_32 = L_shl_o( L_32, 2, &Overflow ); -#else /* BASOP_NOGLOB */ - L_32 = L_shl( L_32, 2 ); -#endif /* BASOP_NOGLOB */ return ( L_32 ); } @@ -530,21 +526,12 @@ Word16 E_LPC_lev_dur_stab( const Word16 Rh[] /*QR -16*/, const Word16 Rl[] /*QR t0 = Mac_32( t0, Rh[j], Rl[j], Ah[i - j], Al[i - j] ); } -#ifdef BASOP_NOGLOB t0 = L_shl_o( t0, 4, &Overflow ); /* result in Q27 -> convert to Q31 */ -#else /* BASOP_NOGLOB */ - t0 = L_shl( t0, 4 ); /* result in Q27 -> convert to Q31 */ -#endif /* BASOP_NOGLOB */ /* No overflow possible */ /* Compose and add R[i] in Q3 */ -#ifdef BASOP_NOGLOB t0 = L_mac_o( t0, Rl[i], 1, &Overflow ); t0 = L_msu_o( t0, Rh[i], -32768, &Overflow ); -#else /* BASOP_NOGLOB */ - t0 = L_mac( t0, Rl[i], 1 ); - t0 = L_msu( t0, Rh[i], -32768 ); -#endif /* BASOP_NOGLOB */ /* K = -t0 / Alpha */ t1 = L_abs( t0 ); @@ -559,11 +546,7 @@ Word16 E_LPC_lev_dur_stab( const Word16 Rh[] /*QR -16*/, const Word16 Rl[] /*QR { t2 = L_negate( t2 ); /* K =-t0/Alpha */ } -#ifdef BASOP_NOGLOB t2 = L_shl_o( t2, alp_exp, &Overflow ); /* denormalize; compare to Alpha */ -#else /* BASOP_NOGLOB */ - t2 = L_shl( t2, alp_exp ); /* denormalize; compare to Alpha */ -#endif /* BASOP_NOGLOB */ test(); if ( ( mem != NULL ) && ( ( GT_16( abs_s( extract_h( t2 ) ), k_max ) ) ) ) { @@ -602,11 +585,7 @@ Word16 E_LPC_lev_dur_stab( const Word16 Rh[] /*QR -16*/, const Word16 Rl[] /*QR L_Extract( t2, &Ah[i], &Al[i] ); /* An[i] in Q27 */ /* Alpha = Alpha * (1-K**2) */ -#ifdef BASOP_NOGLOB t1 = L_mult_o( Kh, Kh, &Overflow ); /* K*K in Q31 */ -#else /* BASOP_NOGLOB */ - t1 = L_mult( Kh, Kh ); /* K*K in Q31 */ -#endif /* BASOP_NOGLOB */ t0 = L_mac( t1, mult( Kh, Kl ), 2 ); t0 = L_abs( t0 ); /* Some case <0 !! */ t0 = L_sub( (Word32) 0x7fffffffL, t0 ); /* 1 - K*K in Q31 */ @@ -642,11 +621,7 @@ Word16 E_LPC_lev_dur_stab( const Word16 Rh[] /*QR -16*/, const Word16 Rl[] /*QR FOR( i = 1; i <= order; i++ ) { t0 = L_Comp( Ah[i], Al[i] ); -#ifdef BASOP_NOGLOB A[i] = round_fx_o( L_shl_o( t0, k, &Overflow ), &Overflow ); -#else - A[i] = round_fx( L_shl( t0, k ) ); -#endif move16(); } @@ -745,21 +720,12 @@ Word16 E_LPC_lev_dur_stab_ivas_fx( const Word16 Rh[], const Word16 Rl[], Word16 t0 = Mac_32( t0, Rh[j], Rl[j], Ah[i - j], Al[i - j] ); } -#ifdef BASOP_NOGLOB t0 = L_shl_o( t0, 4, &Overflow ); /* result in Q27 -> convert to Q31 */ -#else /* BASOP_NOGLOB */ - t0 = L_shl( t0, 4 ); /* result in Q27 -> convert to Q31 */ -#endif /* BASOP_NOGLOB */ /* No overflow possible */ /* Compose and add R[i] in Q3 */ -#ifdef BASOP_NOGLOB t0 = L_mac_o( t0, Rl[i], 1, &Overflow ); t0 = L_msu_o( t0, Rh[i], -32768, &Overflow ); -#else /* BASOP_NOGLOB */ - t0 = L_mac( t0, Rl[i], 1 ); - t0 = L_msu( t0, Rh[i], -32768 ); -#endif /* BASOP_NOGLOB */ /* K = -t0 / Alpha */ t1 = L_abs( t0 ); @@ -774,11 +740,7 @@ Word16 E_LPC_lev_dur_stab_ivas_fx( const Word16 Rh[], const Word16 Rl[], Word16 { t2 = L_negate( t2 ); /* K =-t0/Alpha */ } -#ifdef BASOP_NOGLOB t2 = L_shl_o( t2, alp_exp, &Overflow ); /* denormalize; compare to Alpha */ -#else /* BASOP_NOGLOB */ - t2 = L_shl( t2, alp_exp ); /* denormalize; compare to Alpha */ -#endif /* BASOP_NOGLOB */ test(); if ( ( mem != NULL ) && ( ( GT_16( abs_s( extract_h( t2 ) ), k_max ) ) ) ) { @@ -817,11 +779,7 @@ Word16 E_LPC_lev_dur_stab_ivas_fx( const Word16 Rh[], const Word16 Rl[], Word16 L_Extract( t2, &Ah[i], &Al[i] ); /* An[i] in Q27 */ /* Alpha = Alpha * (1-K**2) */ -#ifdef BASOP_NOGLOB t1 = L_mult_o( Kh, Kh, &Overflow ); /* K*K in Q31 */ -#else /* BASOP_NOGLOB */ - t1 = L_mult( Kh, Kh ); /* K*K in Q31 */ -#endif /* BASOP_NOGLOB */ t0 = L_mac( t1, mult( Kh, Kl ), 2 ); t0 = L_abs( t0 ); /* Some case <0 !! */ t0 = L_sub( (Word32) 0x7fffffffL, t0 ); /* 1 - K*K in Q31 */ @@ -857,11 +815,7 @@ Word16 E_LPC_lev_dur_stab_ivas_fx( const Word16 Rh[], const Word16 Rl[], Word16 FOR( i = 1; i <= order; i++ ) { t0 = L_Comp( Ah[i], Al[i] ); -#ifdef BASOP_NOGLOB A[i] = round_fx_o( L_shl_o( t0, k, &Overflow ), &Overflow ); -#else - A[i] = round_fx( L_shl( t0, k ) ); -#endif move16(); } @@ -961,21 +915,12 @@ Word16 E_LPC_lev_dur_stab_fx( const Word16 Rh[] /*QR -16*/, const Word16 Rl[] /* t0 = Mac_32( t0, Rh[j], Rl[j], Ah[i - j], Al[i - j] ); } -#ifdef BASOP_NOGLOB t0 = L_shl_o( t0, 4, &Overflow ); /* result in Q27 -> convert to Q31 */ -#else /* BASOP_NOGLOB */ - t0 = L_shl( t0, 4 ); /* result in Q27 -> convert to Q31 */ -#endif /* BASOP_NOGLOB */ /* No overflow possible */ /* Compose and add R[i] in Q3 */ -#ifdef BASOP_NOGLOB t0 = L_mac_o( t0, Rl[i], 1, &Overflow ); t0 = L_msu_o( t0, Rh[i], -32768, &Overflow ); -#else /* BASOP_NOGLOB */ - t0 = L_mac( t0, Rl[i], 1 ); - t0 = L_msu( t0, Rh[i], -32768 ); -#endif /* BASOP_NOGLOB */ /* K = -t0 / Alpha */ t1 = L_abs( t0 ); @@ -990,11 +935,7 @@ Word16 E_LPC_lev_dur_stab_fx( const Word16 Rh[] /*QR -16*/, const Word16 Rl[] /* { t2 = L_negate( t2 ); /* K =-t0/Alpha */ } -#ifdef BASOP_NOGLOB t2 = L_shl_o( t2, alp_exp, &Overflow ); /* denormalize; compare to Alpha */ -#else /* BASOP_NOGLOB */ - t2 = L_shl( t2, alp_exp ); /* denormalize; compare to Alpha */ -#endif /* BASOP_NOGLOB */ test(); if ( ( mem != NULL ) && ( ( GT_16( abs_s( extract_h( t2 ) ), k_max ) ) ) ) { @@ -1033,11 +974,7 @@ Word16 E_LPC_lev_dur_stab_fx( const Word16 Rh[] /*QR -16*/, const Word16 Rl[] /* L_Extract( t2, &Ah[i], &Al[i] ); /* An[i] in Q27 */ /* Alpha = Alpha * (1-K**2) */ -#ifdef BASOP_NOGLOB t1 = L_mult_o( Kh, Kh, &Overflow ); /* K*K in Q31 */ -#else /* BASOP_NOGLOB */ - t1 = L_mult( Kh, Kh ); /* K*K in Q31 */ -#endif /* BASOP_NOGLOB */ t0 = L_mac( t1, mult( Kh, Kl ), 2 ); t0 = L_abs( t0 ); /* Some case <0 !! */ t0 = L_sub( (Word32) 0x7fffffffL, t0 ); /* 1 - K*K in Q31 */ @@ -1073,11 +1010,7 @@ Word16 E_LPC_lev_dur_stab_fx( const Word16 Rh[] /*QR -16*/, const Word16 Rl[] /* FOR( i = 1; i <= order; i++ ) { t0 = L_Comp( Ah[i], Al[i] ); -#ifdef BASOP_NOGLOB A[i] = L_shl_o( t0, k, &Overflow ); -#else - A[i] = L_shl(t0, k)); -#endif move16(); } @@ -1638,30 +1571,20 @@ void E_LPC_a_lsf_isf_conversion( Word16 *lpcCoeffs /*Qx*/, Word16 *lsf /*15Q16*/ Word16 ImAr = extract_h( L_sub( ImagFFT[i], ImagFFT[N / 2 - i] ) ); Word16 ImBr = extract_h( L_add( ImagFFT[i], ImagFFT[N / 2 - i] ) ); BASOP_SATURATE_WARNING_OFF_EVS -#ifdef BASOP_NOGLOB tmpw15.v.re = mac_ro( L_mult( ptwiddle->v.re, pwn17->v.re ), ptwiddle->v.im, pwn17->v.im, &Overflow ); move16(); tmpw15.v.im = msu_ro( L_mult( ptwiddle->v.re, pwn17->v.im ), ptwiddle->v.im, pwn17->v.re, &Overflow ); move16(); -#else /* BASOP_NOGLOB */ - tmpw15.v.re = mac_r( L_mult( ptwiddle->v.re, pwn17->v.re ), ptwiddle->v.im, pwn17->v.im ); - tmpw15.v.im = msu_r( L_mult( ptwiddle->v.re, pwn17->v.im ), ptwiddle->v.im, pwn17->v.re ); -#endif /* BASOP_NOGLOB */ BASOP_SATURATE_WARNING_ON_EVS RealOut[i] = mac_r( L_msu( L_msu( L_mult( ReAr, pwn17->v.re ), ImAr, pwn17->v.im ), ReBr, pwn15->v.im ), ImBr, pwn15->v.re ); move16(); ImagOut[i] = mac_r( L_mac( L_mac( L_mult( ReAr, pwn17->v.im ), ImAr, pwn17->v.re ), ReBr, pwn15->v.re ), ImBr, pwn15->v.im ); move16(); BASOP_SATURATE_WARNING_OFF_EVS -#ifdef BASOP_NOGLOB tmpw15.v.re = msu_ro( L_mult( ptwiddle->v.im, pwn17i->v.im ), ptwiddle->v.re, pwn17i->v.re, &Overflow ); move16(); tmpw15.v.im = mac_ro( L_mult( ptwiddle->v.re, pwn17i->v.im ), ptwiddle->v.im, pwn17i->v.re, &Overflow ); move16(); -#else /* BASOP_NOGLOB */ - tmpw15.v.re = msu_r( L_mult( ptwiddle->v.im, pwn17i->v.im ), ptwiddle->v.re, pwn17i->v.re ); - tmpw15.v.im = mac_r( L_mult( ptwiddle->v.re, pwn17i->v.im ), ptwiddle->v.im, pwn17i->v.re ); -#endif /* BASOP_NOGLOB */ BASOP_SATURATE_WARNING_ON_EVS RealOut[N / 2 - i] = msu_r( L_mac( L_mac( L_mult( ReAr, pwn17i->v.re ), ImAr, pwn17i->v.im ), ImBr, pwn15i->v.re ), ReBr, pwn15i->v.im ); move16(); @@ -1682,30 +1605,20 @@ void E_LPC_a_lsf_isf_conversion( Word16 *lpcCoeffs /*Qx*/, Word16 *lsf /*15Q16*/ Word16 ImAr = extract_h( L_sub( ImagFFT[i], ImagFFT[N / 2 - i] ) ); Word16 ImBr = extract_h( L_add( ImagFFT[i], ImagFFT[N / 2 - i] ) ); BASOP_SATURATE_WARNING_OFF_EVS -#ifdef BASOP_NOGLOB tmpw15.v.re = mac_ro( L_mult( ptwiddle->v.im, pwn17->v.re ), ptwiddle->v.re, pwn17->v.im, &Overflow ); move16(); tmpw15.v.im = msu_ro( L_mult( ptwiddle->v.im, pwn17->v.im ), ptwiddle->v.re, pwn17->v.re, &Overflow ); move16(); -#else /* BASOP_NOGLOB */ - tmpw15.v.re = mac_r( L_mult( ptwiddle->v.im, pwn17->v.re ), ptwiddle->v.re, pwn17->v.im ); - tmpw15.v.im = msu_r( L_mult( ptwiddle->v.im, pwn17->v.im ), ptwiddle->v.re, pwn17->v.re ); -#endif /* BASOP_NOGLOB */ BASOP_SATURATE_WARNING_ON_EVS RealOut[i] = mac_r( L_msu( L_msu( L_mult( ReAr, pwn17->v.re ), ImAr, pwn17->v.im ), ReBr, pwn15->v.im ), ImBr, pwn15->v.re ); move16(); ImagOut[i] = mac_r( L_mac( L_mac( L_mult( ReAr, pwn17->v.im ), ImAr, pwn17->v.re ), ReBr, pwn15->v.re ), ImBr, pwn15->v.im ); move16(); BASOP_SATURATE_WARNING_OFF_EVS -#ifdef BASOP_NOGLOB tmpw15.v.re = msu_ro( L_mult( ptwiddle->v.re, pwn17i->v.im ), ptwiddle->v.im, pwn17i->v.re, &Overflow ); move16(); tmpw15.v.im = mac_ro( L_mult( ptwiddle->v.im, pwn17i->v.im ), ptwiddle->v.re, pwn17i->v.re, &Overflow ); move16(); -#else /* BASOP_NOGLOB */ - tmpw15.v.re = msu_r( L_mult( ptwiddle->v.re, pwn17i->v.im ), ptwiddle->v.im, pwn17i->v.re ); - tmpw15.v.im = mac_r( L_mult( ptwiddle->v.im, pwn17i->v.im ), ptwiddle->v.re, pwn17i->v.re ); -#endif BASOP_SATURATE_WARNING_ON_EVS RealOut[N / 2 - i] = msu_r( L_mac( L_mac( L_mult( ReAr, pwn17i->v.re ), ImAr, pwn17i->v.im ), ImBr, pwn15i->v.re ), ReBr, pwn15i->v.im ); move16(); @@ -1723,15 +1636,10 @@ void E_LPC_a_lsf_isf_conversion( Word16 *lpcCoeffs /*Qx*/, Word16 *lsf /*15Q16*/ Word16 ImAr = extract_h( L_sub( ImagFFT[i], ImagFFT[N / 2 - i] ) ); Word16 ImBr = extract_h( ( L_negate( L_add( ImagFFT[i], ImagFFT[N / 2 - i] ) ) ) ); BASOP_SATURATE_WARNING_OFF_EVS -#ifdef BASOP_NOGLOB tmpw15.v.re = mac_r_sat( L_mult( ptwiddle->v.im, pwn17->v.re ), ptwiddle->v.re, pwn17->v.im ); move16(); tmpw15.v.im = msu_r_sat( L_mult( ptwiddle->v.im, pwn17->v.im ), ptwiddle->v.re, pwn17->v.re ); move16(); -#else - tmpw15.v.re = mac_r( L_mult( ptwiddle->v.im, pwn17->v.re ), ptwiddle->v.re, pwn17->v.im ); - tmpw15.v.im = msu_r( L_mult( ptwiddle->v.im, pwn17->v.im ), ptwiddle->v.re, pwn17->v.re ); -#endif BASOP_SATURATE_WARNING_ON_EVS RealOut[i] = msu_r( L_msu( L_msu( L_mult( ReAr, pwn17->v.re ), ImAr, pwn17->v.im ), ReBr, pwn15->v.im ), ImBr, pwn15->v.re ); move16(); diff --git a/lib_com/lsf_tools_fx.c b/lib_com/lsf_tools_fx.c index 1b8438e84ad7f7266ddef765b5bed495cc7e340d..0a8a86aee07b9f02c0ebdc231a74620231793d82 100644 --- a/lib_com/lsf_tools_fx.c +++ b/lib_com/lsf_tools_fx.c @@ -109,22 +109,14 @@ static Word16 chebyshev( Word16 x, Word32 *f, const Word16 n, const Word16 shift /* i = 5 */ t0 = Mpy_32_16_1( b2, x ); /* t0 = x*b1 */ if ( !cheb ) -#ifdef BASOP_NOGLOB t0 = L_shl_o( t0, 1, &Overflow ); /* t0 = 2*x*b1 */ -#else /* BASOP_NOGLOB */ - t0 = L_shl( t0, 1 ); /* t0 = 2*x*b1 */ -#endif /* BASOP_NOGLOB */ t0 = L_sub( t0, b1 ); /* t0 = 2*x*b1 - b2 */ b1 = L_add( t0, *f++ ); /* b0 = 2*x*b1 - b2 + f[i] */ /* i = 6 */ t0 = Mpy_32_16_1( b1, x ); /* t0 = x*b1 */ if ( !cheb ) -#ifdef BASOP_NOGLOB t0 = L_shl_o( t0, 1, &Overflow ); /* t0 = 2*x*b1 */ -#else /* BASOP_NOGLOB */ - t0 = L_shl( t0, 1 ); /* t0 = 2*x*b1 */ -#endif /* BASOP_NOGLOB */ t0 = L_sub( t0, b2 ); /* t0 = 2*x*b1 - b2 */ } /* IF (sub(n,8) == 0) */ @@ -134,11 +126,7 @@ static Word16 chebyshev( Word16 x, Word32 *f, const Word16 n, const Word16 shift /* i = 7 */ t0 = Mpy_32_16_1( b2, x ); /* t0 = x*b1 */ if ( !cheb ) -#ifdef BASOP_NOGLOB t0 = L_shl_o( t0, 1, &Overflow ); /* t0 = 2*x*b1 */ -#else /* BASOP_NOGLOB */ - t0 = L_shl( t0, 1 ); /* t0 = 2*x*b1 */ -#endif /* BASOP_NOGLOB */ t0 = L_sub( t0, b1 ); /* t0 = 2*x*b1 - b2 */ /*b1 = L_add(b2,0);*/ } @@ -158,13 +146,8 @@ static Word16 chebyshev( Word16 x, Word32 *f, const Word16 n, const Word16 shift BASOP_SATURATE_WARNING_OFF_EVS -#ifdef BASOP_NOGLOB t0 = L_shl_o( t0, shift, &Overflow ); /* Qx to Q30 with saturation */ cheb = round_fx_o( t0, &Overflow ); /* Result in Q14 */ -#else /* BASOP_NOGLOB */ - t0 = L_shl( t0, shift ); /* Qx to Q30 with saturation */ - cheb = round_fx( t0 ); /* Result in Q14 */ -#endif /* BASOP_NOGLOB */ cheb = s_max( -32767, cheb ); /* to avoid saturation */ BASOP_SATURATE_WARNING_ON_EVS return ( cheb ); @@ -303,11 +286,7 @@ void E_LPC_a_isp_conversion( const Word16 a[], Word16 isp[], const Word16 old_is * xint = xlow - ylow*(xhigh-xlow)/(yhigh-ylow) *--------------------------------------------------------*/ -#ifdef BASOP_NOGLOB y = sub_o( yhigh, ylow, &Overflow ); -#else - y = sub( yhigh, ylow ); -#endif IF( y != 0 ) { x = sub( xhigh, xlow ); @@ -466,15 +445,9 @@ void E_LPC_f_isp_a_conversion( const Word16 *isp, Word16 *a, const Word16 m ) BASOP_SATURATE_WARNING_OFF_EVS /*overflow handling in loop expression*/ -#ifdef BASOP_NOGLOB t0 = L_shl_o( t0, q, &Overflow ); t0n = L_sub_o( t0, 0x7FFFFFFF, &Overflow ); /*check for positive overflow*/ t0p = L_sub_o( t0, 0x80000000, &Overflow ); /*check for negative overflow*/ -#else /* BASOP_NOGLOB */ - t0 = L_shl( t0, q ); - t0n = L_sub( t0, 0x7FFFFFFF ); /*check for positive overflow*/ - t0p = L_sub( t0, 0x80000000 ); /*check for negative overflow*/ -#endif /* BASOP_NOGLOB */ BASOP_SATURATE_WARNING_ON_EVS q = sub( q, 1 ); /*decrease q in case of overflow*/ @@ -631,6 +604,153 @@ Word16 lpc2lsp_fx( return ( 1 ); } +#ifdef FIX_ISSUE_1165 +/*===================================================================*/ +/* FUNCTION : lpc2lsp_ivas_fx () */ +/*-------------------------------------------------------------------*/ +/* PURPOSE : Convert LPC coefficients to LSP coefficients */ +/*-------------------------------------------------------------------*/ +/* INPUT ARGUMENTS : */ +/* */ +/* _ (Word32 []) a : LPC coefficients, Q27 */ +/* _ (Word16 []) old_freq: Previous frame LSP coefficients, Q15 */ +/* _ (Word16 []) order: LPC order */ +/*-------------------------------------------------------------------*/ +/* OUTPUT ARGUMENTS : */ +/* _ (Word16 []) freq: LSP coefficients, Q15 */ +/*-------------------------------------------------------------------*/ +/* INPUT/OUTPUT ARGUMENTS : */ +/* _ None */ +/*-------------------------------------------------------------------*/ +/* RETURN ARGUMENTS : */ +/* _ (Word16) flag: 1 means all 10 LSPs are found, 0 otherwise */ +/*===================================================================*/ + +/*NOTE: This function was created to avoid a crash that happens in the*/ +/* first for loop of this function while performing L_shl on a in*/ +/* lpc2lsp_fx, this computation assigns value to Lacc, which is */ +/* kept in Q26 here to avoid L_shl when a has saturated value. */ +Word16 lpc2lsp_ivas_fx( + Word32 *a, + Word16 *freq, + Word16 *old_freq, + Word16 order ) +{ + Word16 i; + Word16 rt, low, high, prev_rt, rc; + Word32 p[11], q[11]; /* Q26 */ + Word32 Ltemp, v_low; + Word32 Lacc; + Word16 tfreq[21]; + + /* First construct the P,Q polynomial */ + /* p[0] = q[0] = 1 */ + /* p[i] = -lpcCoeff[i] - lpcCoeff[11-i] - p[i-1] ( 1<=i<=5)*/ + /* q[i] = -lpcCoeff[i] + lpcCoeff[11-i] + q[i-1] ( 1<=i<=5)*/ + Ltemp = L_deposit_h( 0x400 ); /* Ltemp is 1.0 in Q26 */ + + p[0] = Ltemp; + move32(); + q[0] = Ltemp; + move32(); + + FOR( i = 1; i < ( order / 2 ) + 1; i++ ) + { + Lacc = L_shr( a[order - i], 1 ); + move32(); /* Q26 */ + Lacc = L_sub( Lacc, L_shr( a[i - 1], 1 ) ); /* Lacc=-lpcCoeff[i-1] + lpcCoeff[order-i]//Q26 */ + q[i] = L_add( ( Lacc ), q[i - 1] ); + move32(); /* Q26 */ + + Lacc = L_add( Lacc, a[i - 1] ); /* Lacc=lpcCoeff[i-1] + lpcCoeff[order-i]//Q26 */ + + p[i] = L_sub( L_negate( Lacc ), p[i - 1] ); + move32(); /* Q26 */ + } + + /* Search roots of the P and Q polynomials */ + + v_low = polynomial_eval_fx( 0, p, order ); /* Q25 */ + move16(); + move16(); + move16(); + move16(); + low = 0; + high = 8; + prev_rt = 0; + rc = 0; /* root counter */ + FOR( i = 0; i < 32; i++ ) + { + rt = root_search_fx( low, high, &v_low, p, order ); + low = high; + move16(); + high = add( high, 8 ); + + IF( GE_16( rt, prev_rt ) ) + { + tfreq[rc] = rt; + move16(); + rc = add( rc, 2 ); + } + prev_rt = add( rt, 6 ); + } /* End for P roots */ + + tfreq[rc] = 0x3f80; + move16(); /* Set a high enough value as fake root for Q search */ + + IF( LT_16( rc, order ) ) + { + /* lost P root */ + /* copy from previous LSP and return */ + FOR( i = 0; i < order; i++ ) + { + move16(); + freq[i] = old_freq[i]; + } + return ( 0 ); + } + ELSE + { + /* Search for Q roots between P roots */ + v_low = L_deposit_h( 0x800 ); /* Init a positive value for v_low */ + rc = 1; + move16(); + FOR( i = 0; i < order / 2; i++ ) + { + low = shr( tfreq[rc - 1], 6 ); + high = add( shr( tfreq[rc + 1], 6 ), 1 ); + rt = root_search_fx( low, high, &v_low, q, order ); + + IF( rt < 0 ) + { + /* No Q root in this interval */ + /* copy from previous LSP and return */ + FOR( i = 0; i < order; i++ ) + { + move16(); + freq[i] = old_freq[i]; + } + return ( 0 ); + } + ELSE + { + move16(); + tfreq[rc] = rt; + rc = add( rc, 2 ); + } /* end else, find Q root */ + } /* end for */ + } /* end else */ + + FOR( i = 0; i < order; i++ ) + { + freq[i] = tfreq[i]; + move16(); + } + + return ( 1 ); +} +#endif + /*===================================================================*/ /* FUNCTION : lsp2lpc_fx () */ /*-------------------------------------------------------------------*/ @@ -683,11 +803,7 @@ void lsp2lpc_fx( move16(); FOR( i = 0; i < order / 2; i++ ) { -#ifdef BASOP_NOGLOB /* Critical Overflow */ Ltemp = L_add_o( pq[i], pq[i + 1], &Overflow ); -#else - Ltemp = L_add( pq[i], pq[i + 1] ); -#endif giOverflow = (Word16) Overflow; move16(); IF( EQ_16( giOverflow, 1 ) ) @@ -719,11 +835,7 @@ void lsp2lpc_fx( FOR( i = 0; i < order / 2; i++ ) { -#ifdef BASOP_NOGLOB /* Critical Overflow */ Ltemp = L_sub_o( pq[i + 1], pq[i], &Overflow ); -#else - Ltemp = L_sub( pq[i + 1], pq[i] ); -#endif giOverflow = (Word16) Overflow; move16(); IF( EQ_16( giOverflow, 1 ) ) @@ -749,11 +861,7 @@ void lsp2lpc_fx( { Overflow = 0; move16(); -#ifdef BASOP_NOGLOB /* Critical Overflow */ Lacc = L_add_o( p[i], q[i], &Overflow ); /* p[i], q[i] in Q24 */ -#else - Lacc = L_add( p[i], q[i] ); /* p[i], q[i] in Q24 */ -#endif if ( Overflow ) { giOverflow = 1; @@ -763,11 +871,7 @@ void lsp2lpc_fx( Lacc = L_negate( Lacc ); /* Lacc=-(p[i]-q[i])/2 in Q25 */ Overflow = 0; move16(); -#ifdef BASOP_NOGLOB /* Critical Overflow */ Lacc = L_add_o( L_shl_o( Lacc, 3, &Overflow ), 0x08000, &Overflow ); /* rounding */ -#else - Lacc = L_add( L_shl( Lacc, 3 ), 0x08000 ); /* rounding */ -#endif if ( Overflow ) { giOverflow = 1; @@ -785,11 +889,7 @@ void lsp2lpc_fx( { Overflow = 0; move16(); -#ifdef BASOP_NOGLOB /* Critical Overflow */ Lacc = L_sub_o( q[i], p[i], &Overflow ); /* p[i], q[i] in Q24 */ -#else - Lacc = L_sub( q[i], p[i] ); /* p[i], q[i] in Q24 */ -#endif if ( Overflow ) { giOverflow = 1; @@ -797,11 +897,7 @@ void lsp2lpc_fx( } Overflow = 0; move16(); -#ifdef BASOP_NOGLOB /* Critical Overflow */ Lacc = L_add_o( L_shl_o( Lacc, 3, &Overflow ), 0x08000, &Overflow ); /* rounding */ -#else - Lacc = L_add( L_shl( Lacc, 3 ), 0x08000 ); /* rounding */ -#endif if ( Overflow ) { giOverflow = 1; @@ -890,22 +986,13 @@ Word16 E_LPC_f_lsp_pol_get( const Word16 lsp[], Word32 f[], const Word16 n, cons Overflow = 0; move16(); plsp = lsp; -#ifdef BASOP_NOGLOB /* Critical Overflow and all those below*/ f[0] = L_shl_o( 1, sub( 31, Q_out ), &Overflow ); -#else - f[0] = L_shl( 1, sub( 31, Q_out ) ); -#endif move32(); /*b = -2.0f * *plsp;*/ b = *plsp; move16(); -#ifdef BASOP_NOGLOB /* Critical Overflow */ m2 = shl_o( -2, sub( 15, Q_out ), &Overflow ); f[1] = L_mult_o( b, m2, &Overflow ); -#else - m2 = shl( -2, sub( 15, Q_out ) ); - f[1] = L_mult( b, m2 ); -#endif move32(); FOR( i = 2; i <= n; i++ ) @@ -914,35 +1001,19 @@ Word16 E_LPC_f_lsp_pol_get( const Word16 lsp[], Word32 f[], const Word16 n, cons /*b = 2.0f * *plsp;*/ move16(); b = *plsp; -#ifdef BASOP_NOGLOB /* Critical Overflow */ b32 = L_mult_o( b, m2, &Overflow ); -#else - b32 = L_mult( b, m2 ); -#endif /*f[i] = -b*f[i-1] + 2.0f*f[i-2];*/ move32(); -#ifdef BASOP_NOGLOB /* Critical Overflow */ f[i] = L_shl_o( L_sub_o( f[i - 2], Mpy_32_16_1( f[i - 1], b ), &Overflow ), 1, &Overflow ); -#else - f[i] = L_shl( L_sub( f[i - 2], Mpy_32_16_1( f[i - 1], b ) ), 1 ); -#endif FOR( j = i - 1; j > 1; j-- ) { /*f[j] += b*f[j-1] + f[j-2];*/ move32(); -#ifdef BASOP_NOGLOB /* Critical Overflow */ f[j] = L_add_o( f[j], L_sub_o( f[j - 2], L_shl_o( Mpy_32_16_1( f[j - 1], b ), 1, &Overflow ), &Overflow ), &Overflow ); -#else - f[j] = L_add( f[j], L_sub( f[j - 2], L_shl( Mpy_32_16_1( f[j - 1], b ), 1 ) ) ); -#endif } move32(); -#ifdef BASOP_NOGLOB /* Critical Overflow */ f[1] = L_add_o( f[1], b32, &Overflow ); -#else - f[1] = L_add( f[1], b32 ); -#endif } @@ -1186,11 +1257,7 @@ void E_LPC_f_lsp_a_conversion( const Word16 *lsp, Word16 *a, const Word16 m ) { f1[nc - i] = L_add( f1[nc - i], f1[nc - i - 1] ); move32(); -#ifdef BASOP_NOGLOB f2[nc - i] = L_sub_o( f2[nc - i], f2[nc - i - 1], &Overflow ); -#else - f2[nc - i] = L_sub( f2[nc - i], f2[nc - i - 1] ); -#endif move32(); } @@ -1202,13 +1269,8 @@ void E_LPC_f_lsp_a_conversion( const Word16 *lsp, Word16 *a, const Word16 m ) t0 = L_deposit_l( 0 ); FOR( i = 1; i <= nc; i++ ) { -#ifdef BASOP_NOGLOB t0 = L_max( t0, L_abs( L_add_o( f1[i], f2[i], &Overflow ) ) ); t0 = L_max( t0, L_abs( L_sub_o( f1[i], f2[i], &Overflow ) ) ); -#else - t0 = L_max( t0, L_abs( L_add( f1[i], f2[i] ) ) ); - t0 = L_max( t0, L_abs( L_sub( f1[i], f2[i] ) ) ); -#endif } k = s_min( norm_l( t0 ), 6 ); a[0] = shl( 256, k ); @@ -1223,30 +1285,14 @@ void E_LPC_f_lsp_a_conversion( const Word16 *lsp, Word16 *a, const Word16 m ) FOR( i = 1; i <= nc; i++ ) { /* a[i] = 0.5*(f1[i] + f2[i]) */ -#ifdef BASOP_NOGLOB t0 = L_add_o( f1[i], f2[i], &Overflow ); -#else - t0 = L_add( f1[i], f2[i] ); -#endif t0 = L_shl( t0, k ); -#ifdef BASOP_NOGLOB a[i] = round_fx_o( t0, &Overflow ); /* from Q23 to Qx and * 0.5 */ -#else - a[i] = round_fx( t0 ); /* from Q23 to Qx and * 0.5 */ -#endif /* a[j] = 0.5*(f1[i] - f2[i]) */ -#ifdef BASOP_NOGLOB t0 = L_sub_o( f1[i], f2[i], &Overflow ); -#else - t0 = L_sub( f1[i], f2[i] ); -#endif t0 = L_shl( t0, k ); -#ifdef BASOP_NOGLOB a[j] = round_fx_o( t0, &Overflow ); /* from Q23 to Qx and * 0.5 */ -#else - a[j] = round_fx( t0 ); /* from Q23 to Qx and * 0.5 */ -#endif j--; } @@ -1459,6 +1505,80 @@ void lsp_weights_fx( move16(); } +void lsp_weights_ivas_fx( + Word16 lsp_nq_fx[], + Word16 w[], + Word16 Order, + Word16 *Qout ) +{ + Word16 i; + Word16 q_weight[20]; + Word32 weight[20]; + Word16 delta1, delta2; + Word32 L_tmp; + Word16 q_min; + + delta1 = lsp_nq_fx[0]; // Q15 + move16(); + delta2 = sub( lsp_nq_fx[1], lsp_nq_fx[0] ); // Q15 + + L_tmp = L_mult0( delta1, delta2 ); // Q30 // Q30 + L_tmp = root_a_over_b_ivas_fx( ALPHA_SQ_Q30, Q30, L_tmp, Q30, &q_weight[0] ); // q_weight[0] + + weight[0] = Mpy_32_16_1( L_tmp, 32000 /* 250 in Q7*/ ); // q_weight[0]-8 + q_weight[0] = sub( q_weight[0], 8 ); + move32(); + move16(); + + q_min = q_weight[0]; + move16(); + + FOR( i = 1; i < Order - 1; i++ ) + { + delta1 = sub( lsp_nq_fx[i], lsp_nq_fx[i - 1] ); // Q15 + delta2 = sub( lsp_nq_fx[i + 1], lsp_nq_fx[i] ); // Q15 + + L_tmp = L_mult0( delta1, delta2 ); // Q30 + L_tmp = root_a_over_b_ivas_fx( ALPHA_SQ_Q30, Q30, L_tmp, Q30, &q_weight[i] ); // q_weight[i] + + weight[i] = Mpy_32_16_1( L_tmp, 32000 /* 250 in Q7*/ ); // q_weight[i] + q_weight[i] = sub( q_weight[i], 8 ); + move32(); + move16(); + + q_min = s_min( q_min, q_weight[i] ); + } + delta1 = sub( lsp_nq_fx[i], lsp_nq_fx[i - 1] ); // Q15 + delta2 = sub( 16384 /* 0.5 in Q15*/, lsp_nq_fx[i] ); // Q15 + + L_tmp = L_mult0( delta1, delta2 ); // Q30 + L_tmp = root_a_over_b_ivas_fx( ALPHA_SQ_Q30, Q30, L_tmp, Q30, &q_weight[i] ); // q_weight[i] + + weight[i] = Mpy_32_16_1( L_tmp, 32000 /* 250 in Q7*/ ); // q_weight[i] + q_weight[i] = sub( q_weight[i], 8 ); + move32(); + move16(); + + q_min = s_min( q_min, q_weight[i] ); + + FOR( i = 0; i < Order; i++ ) + { + w[i] = round_fx( L_shl( weight[i], sub( q_min, q_weight[i] ) ) ); /* q_min-16 */ + move16(); + } + + IF( Order != LPC_SHB_ORDER_WB ) + { + w[3] = round_fx( L_shl( L_mult( w[3], 18022 ), 1 ) ); /* q_min-16 */ + w[4] = round_fx( L_shl( L_mult( w[4], 18022 ), 1 ) ); /* q_min-16 */ + move16(); + move16(); + } + + *Qout = sub( q_min, 16 ); + move16(); +} + /* * E_LPC_isf_isp_conversion * @@ -1678,41 +1798,23 @@ void a2rc_fx( const Word16 *a, /* i: can be any Q */ FOR( j = 0; j < m / 2; j++ ) { n = sub( sub( m, (Word16) 1 ), j ); - L_tmp1 = L_mult( denom_mant, f_fx[j] ); /* denom*f[j]. Q15*Q12 = Q28 (floating with exp) */ -#ifdef BASOP_NOGLOB + L_tmp1 = L_mult( denom_mant, f_fx[j] ); /* denom*f[j]. Q15*Q12 = Q28 (floating with exp) */ L_tmp1 = L_mac_o( L_tmp1, tmp, f_fx[n], &Overflow ); /* denom*f[j]+km*denom*f[n] in Q28 (floating with exp) */ -#else - L_tmp1 = L_mac( L_tmp1, tmp, f_fx[n] ); /* denom*f[j]+km*denom*f[n] in Q28 (floating with exp) */ -#endif - L_tmp2 = L_mult( denom_mant, f_fx[n] ); /* denom*f[n]. Q15*Q12 = Q28 (floating with exp) */ -#ifdef BASOP_NOGLOB + L_tmp2 = L_mult( denom_mant, f_fx[n] ); /* denom*f[n]. Q15*Q12 = Q28 (floating with exp) */ L_tmp2 = L_mac_o( L_tmp2, tmp, f_fx[j], &Overflow ); /* denom*f[n]+km*denom*f[j] in Q28 (floating with exp) */ L_tmp1 = L_shr_o( L_tmp1, exp, &Overflow ); /* bringing to true Q28 */ L_tmp2 = L_shr_o( L_tmp2, exp, &Overflow ); /* bringing to true Q28 */ f_fx[j] = round_fx_o( L_tmp1, &Overflow ); /* extracting in q_a */ f_fx[n] = round_fx_o( L_tmp2, &Overflow ); /* extracting in q_a */ -#else - L_tmp2 = L_mac( L_tmp2, tmp, f_fx[j] ); /* denom*f[n]+km*denom*f[j] in Q28 (floating with exp) */ - L_tmp1 = L_shr( L_tmp1, exp ); /* bringing to true Q28 */ - L_tmp2 = L_shr( L_tmp2, exp ); /* bringing to true Q28 */ - f_fx[j] = round_fx( L_tmp1 ); /* extracting in q_a */ - f_fx[n] = round_fx( L_tmp2 ); /* extracting in q_a */ -#endif } IF( m & 1 ) { - L_tmp1 = L_mult( denom_mant, f_fx[j] ); /* denom*f[j]. Q15*Q12 = Q28 (floating with exp) */ -#ifdef BASOP_NOGLOB + L_tmp1 = L_mult( denom_mant, f_fx[j] ); /* denom*f[j]. Q15*Q12 = Q28 (floating with exp) */ L_tmp1 = L_mac_o( L_tmp1, tmp, f_fx[j], &Overflow ); /* denom*f[j]+km*denom*f[j] in Q28 (floating with exp) */ L_tmp1 = L_shr_o( L_tmp1, exp, &Overflow ); /* bringing to true Q28 */ f_fx[j] = round_fx_o( L_tmp1, &Overflow ); /* extracting in q_a */ move16(); -#else - L_tmp1 = L_mac( L_tmp1, tmp, f_fx[j] ); /* denom*f[j]+km*denom*f[j] in Q28 (floating with exp) */ - L_tmp1 = L_shr( L_tmp1, exp ); /* bringing to true Q28 */ - f_fx[j] = round_fx( L_tmp1 ); /* extracting in q_a */ -#endif } } @@ -2211,18 +2313,10 @@ Word16 lsf_stab_fx( /* o : LP filter stability Q15*/ } e = sub( 30 - 21 - 1, e ); -#ifdef BASOP_NOGLOB tmp = round_fx_o( L_shl_o( L_tmp, e, &Overflow ), &Overflow ); /*Q14*/ -#else /* BASOP_NOGLOB */ - tmp = round_fx( L_shl( L_tmp, e ) ); /*Q14*/ -#endif /* BASOP_NOGLOB */ - tmp = sub( 20480, tmp ); /* 1.25 - tmp in Q14 */ -#ifdef BASOP_NOGLOB + tmp = sub( 20480, tmp ); /* 1.25 - tmp in Q14 */ tmp = shl_o( tmp, 1, &Overflow ); /* Q14 -> Q15 with saturation */ -#else /* BASOP_NOGLOB */ - tmp = shl( tmp, 1 ); /* Q14 -> Q15 with saturation */ -#endif tmp = s_max( tmp, 0 ); @@ -2312,20 +2406,12 @@ Word16 lsf_stab_ivas_fx( /* o : LP filter stability } e = sub( 30 - 21 - 1, e ); -#ifdef BASOP_NOGLOB tmp = round_fx_o( L_shl_o( L_tmp, e, &Overflow ), &Overflow ); /*Q12*/ -#else /* BASOP_NOGLOB */ - tmp = round_fx( L_shl( L_tmp, e ) ); /*Q14*/ -#endif /* BASOP_NOGLOB */ // tmp = sub(20480, tmp); /* 1.25 - tmp in Q14 */ tmp = sub( 5120, tmp ); /* 1.25 - tmp in Q12 */ -#ifdef BASOP_NOGLOB // tmp = shl_o(tmcp, 1, &Overflow); /* Q14 -> Q15 with saturation */ tmp = shl_sat( tmp, 3 ); /* Q12 -> Q15 with saturation */ -#else /* BASOP_NOGLOB */ - tmp = shl( tmp, 1 ); /* Q14 -> Q15 with saturation */ -#endif tmp = s_max( tmp, 0 ); @@ -2547,11 +2633,7 @@ void lsf2lsp_fx( { offset = negate( offset ); } -#ifdef BASOP_NOGLOB L_tmp = L_mult( sub_sat( offset, lsf_tmp ), round_fx( L_shl( L_and( L_tmp, 0xFFFF ), 15 ) ) ); -#else - L_tmp = L_mult( sub( offset, lsf_tmp ), round_fx( L_shl( L_and( L_tmp, 0xFFFF ), 15 ) ) ); -#endif L_tmp = L_msu( L_tmp, lsf_tmp, -32768 ); lsp[i] = round_fx( L_tmp ); } @@ -3824,13 +3906,9 @@ Word16 root_search_fx( Word16 low, L_tmp1 = L_shl( L_tmp, exp1 ); tmp = extract_h( L_tmp1 ); exp1 = sub( 30 - 25, exp1 ); - tmp = div_s( 16384, tmp ); /* 15+exp1 */ - Ltmp = Mult_32_16( *v_low, tmp ); /* 15+exp1+25-15 */ -#ifdef BASOP_NOGLOB + tmp = div_s( 16384, tmp ); /* 15+exp1 */ + Ltmp = Mult_32_16( *v_low, tmp ); /* 15+exp1+25-15 */ Ltemp = L_shl_o( Ltmp, ( 6 - exp1 ), &Overflow ); /* Q31 */ -#else - Ltemp = L_shl( Ltmp, ( 6 - exp1 ) ); /* Q31 */ -#endif if ( LT_32( *v_low, vh ) ) { Ltemp = L_negate( Ltemp ); diff --git a/lib_com/lsp_conv_poly_fx.c b/lib_com/lsp_conv_poly_fx.c index 6c2c5552037189d3b9d500cc0d22f1e56dc4dc6e..61ead2bf2a75118ce2399146e065fd243fae0077 100644 --- a/lib_com/lsp_conv_poly_fx.c +++ b/lib_com/lsp_conv_poly_fx.c @@ -346,18 +346,10 @@ static Word32 b_inv_sq( exp_den = add( sub( 30, exp_den ), sub( 16, exp_in ) ); m_den = mult_r( m_den, m_den ); -#ifdef BASOP_NOGLOB exp_den = shl_o( exp_den, 1, &Overflow ); -#else /* BASOP_NOGLOB */ - exp_den = shl( exp_den, 1 ); -#endif /* BASOP_NOGLOB */ div_out = div_s( 8192, m_den ); -#ifdef BASOP_NOGLOB Ltmp = L_shl_o( div_out, add( sub( 30 - 13, exp_den ), 15 ), &Overflow ); /*Q15*/ -#else /* BASOP_NOGLOB */ - Ltmp = L_shl( div_out, add( sub( 30 - 13, exp_den ), 15 ) ); /*Q15*/ -#endif /* BASOP_NOGLOB */ return Ltmp; } @@ -387,11 +379,7 @@ static Word32 inv_pow( { exp1 = norm_l( re ); tmp = extract_h( L_shl( re, exp1 ) ); -#ifdef BASOP_NOGLOB L_tmp = L_shr( L_mult_o( tmp, tmp, &Overflow ), 1 ); -#else /* BASOP_NOGLOB */ - L_tmp = L_shr( L_mult( tmp, tmp ), 1 ); -#endif /* BASOP_NOGLOB */ Mpy_32_16_ss( L_tmp, x, &mh, &ml ); r0 = L_add( L_tmp, mh ); } @@ -406,11 +394,7 @@ static Word32 inv_pow( { exp2 = norm_l( se ); tmp = extract_h( L_shl( se, exp2 ) ); -#ifdef BASOP_NOGLOB L_tmp = L_shr( L_mult_o( tmp, tmp, &Overflow ), 1 ); -#else /* BASOP_NOGLOB */ - L_tmp = L_shr( L_mult( tmp, tmp ), 1 ); -#endif /* BASOP_NOGLOB */ Mpy_32_16_ss( L_tmp, x, &mh, &ml ); s0 = L_sub( L_tmp, mh ); } @@ -440,11 +424,7 @@ static Word32 inv_pow( } tmp = div_s( (Word16) ( ( 1 << 14 ) - 1 ), tmp ); exp1 = add( exp1, exp2 ); -#ifdef BASOP_NOGLOB L_tmp = L_shr_o( tmp, sub( 31, exp1 ), &Overflow ); /* result in Q15 */ -#else /* BASOP_NOGLOB */ - L_tmp = L_shr( tmp, sub( 31, exp1 ) ); /* result in Q15 */ -#endif /* BASOP_NOGLOB */ return ( L_tmp ); } @@ -546,11 +526,7 @@ static void spectautocorr_fx( move32(); FOR( i = 2; i < N - 1; i++ ) { -#ifdef BASOP_NOGLOB r[0] = L_add_o( r[0], G[i], &Overflow ); -#else /* BASOP_NOGLOB */ - r[0] = L_add( r[0], G[i] ); -#endif /* BASOP_NOGLOB */ move32(); } @@ -584,20 +560,12 @@ static void spectautocorr_fx( move16(); /* 1.0 in Q15 */ FOR( i = 1; i < imid; i++ ) { -#ifdef BASOP_NOGLOB gp = L_add_o( G[i], G[N - i - 1], &Overflow ); -#else /* BASOP_NOGLOB */ - gp = L_add( G[i], G[N - i - 1] ); -#endif /* BASOP_NOGLOB */ gn = L_sub( G[i], G[N - i - 1] ); /*r[1] = L_mac(r[1], x[i-1], gn);*/ Mpy_32_16_ss( gn, x[i - 1], &mh, &ml ); -#ifdef BASOP_NOGLOB r[1] = L_add_o( r[1], mh, &Overflow ); -#else - r[1] = L_add( r[1], mh ); -#endif move32(); c[1] = x[i - 1]; move16(); @@ -606,55 +574,31 @@ static void spectautocorr_fx( { c[j] = mult_r( c[j - 1], x[i - 1] ); move16(); -#ifdef BASOP_NOGLOB c[j] = add_o( c[j], sub_o( c[j], c[j - 2], &Overflow ), &Overflow ); -#else /* BASOP_NOGLOB */ - c[j] = add( c[j], sub( c[j], c[j - 2] ) ); -#endif /* BASOP_NOGLOB */ move16(); /*r[j] = L_mac(r[j], c[j], gp);*/ Mpy_32_16_ss( gp, c[j], &mh, &ml ); -#ifdef BASOP_NOGLOB r[j] = L_add_o( r[j], mh, &Overflow ); -#else /* BASOP_NOGLOB */ - r[j] = L_add( r[j], mh ); -#endif /* BASOP_NOGLOB */ move32(); c[j + 1] = mult_r( c[j], x[i - 1] ); move16(); -#ifdef BASOP_NOGLOB c[j + 1] = add_o( c[j + 1], sub_o( c[j + 1], c[j - 1], &Overflow ), &Overflow ); -#else /* BASOP_NOGLOB */ - c[j + 1] = add( c[j + 1], sub( c[j + 1], c[j - 1] ) ); -#endif /* BASOP_NOGLOB */ move16(); /*r[j+1] = L_mac(r[j+1], c[j+1], gn);*/ Mpy_32_16_ss( gn, c[j + 1], &mh, &ml ); -#ifdef BASOP_NOGLOB r[j + 1] = L_add_o( r[j + 1], mh, &Overflow ); -#else /* BASOP_NOGLOB */ - r[j + 1] = L_add( r[j + 1], mh ); -#endif /* BASOP_NOGLOB */ move32(); } c[j] = mult_r( c[j - 1], x[i - 1] ); move16(); -#ifdef BASOP_NOGLOB c[j] = add_o( c[j], sub_o( c[j], c[j - 2], &Overflow ), &Overflow ); -#else /* BASOP_NOGLOB */ - c[j] = add( c[j], sub( c[j], c[j - 2] ) ); -#endif /* BASOP_NOGLOB */ move16(); Mpy_32_16_ss( gp, c[j], &mh, &ml ); -#ifdef BASOP_NOGLOB r[j] = L_add_o( r[j], mh, &Overflow ); -#else /* BASOP_NOGLOB */ - r[j] = L_add( r[j], mh ); -#endif /* BASOP_NOGLOB */ move32(); } @@ -662,31 +606,18 @@ static void spectautocorr_fx( * Add the endpoints x = cos(0) = 1 and x = cos(pi) = -1 as * well as the lower half of the unit circle. *---------------------------------------------------------------------*/ -#ifdef BASOP_NOGLOB gp = L_shr( L_add_o( G[0], G[N - 1], &Overflow ), 1 ); -#else /* BASOP_NOGLOB */ - gp = L_shr( L_add( G[0], G[N - 1] ), 1 ); -#endif /* BASOP_NOGLOB */ gn = L_shr( L_sub( G[0], G[N - 1] ), 1 ); -#ifdef BASOP_NOGLOB r[0] = L_add_o( r[0], gp, &Overflow ); -#else /* BASOP_NOGLOB */ - r[0] = L_add( r[0], gp ); -#endif /* BASOP_NOGLOB */ move32(); exp0 = norm_l( r[0] ); L_Extract( L_shl( r[0], exp0 ), &rh[0], &rl[0] ); FOR( j = 1; j < M; j += 2 ) { -#ifdef BASOP_NOGLOB L_Extract( L_shl( L_add_o( r[j], gn, &Overflow ), exp0 ), &rh[j], &rl[j] ); L_Extract( L_shl( L_add_o( r[j + 1], gp, &Overflow ), exp0 ), &rh[j + 1], &rl[j + 1] ); -#else /* BASOP_NOGLOB */ - L_Extract( L_shl( L_add( r[j], gn ), exp0 ), &rh[j], &rl[j] ); - L_Extract( L_shl( L_add( r[j + 1], gp ), exp0 ), &rh[j + 1], &rl[j + 1] ); -#endif } return; diff --git a/lib_com/math_op.c b/lib_com/math_op.c index ea0a7ef6cbb808a2979725570cd532101007b6b7..7014988b887944d6c9417a15c0d07363e7245c79 100644 --- a/lib_com/math_op.c +++ b/lib_com/math_op.c @@ -169,7 +169,6 @@ Word32 Pow2( /* (o) Q0 : result (range: 0<=val<=0x7fffff |___________________________________________________________________________| */ -#ifdef BASOP_NOGLOB Word32 Dot_product12_o( /* (o) Q31: normalized result (1 < val <= -1) */ const Word16 x[], /* (i) 12bits: x vector */ const Word16 y[], /* (i) 12bits: y vector */ @@ -177,33 +176,15 @@ Word32 Dot_product12_o( /* (o) Q31: normalized result (1 < va Word16 *exp, /* (o) : exponent of result (0..+30) */ Flag *Overflow_out /* o : propagating the Overflow flag to upper level, set to NULL to ignore internal overflows */ ) -#else /* BASOP_NOGLOB */ -Word32 Dot_product12( /* (o) Q31: normalized result (1 < val <= -1) */ - const Word16 x[], /* (i) 12bits: x vector */ - const Word16 y[], /* (i) 12bits: y vector */ - const Word16 lg, /* (i) : vector length */ - Word16 *exp /* (o) : exponent of result (0..+30) */ -) -#endif /* BASOP_NOGLOB */ { Word16 i, sft; Word32 L_sum; -#ifdef BASOP_NOGLOB Flag Overflow_ignored = 0; -#endif /* BASOP_NOGLOB */ -#ifdef BASOP_NOGLOB L_sum = L_mac_o( 1, x[0], y[0], &Overflow_ignored ); -#else - L_sum = L_mac( 1, x[0], y[0] ); -#endif FOR( i = 1; i < lg; i++ ) { -#ifdef BASOP_NOGLOB L_sum = L_mac_o( L_sum, x[i], y[i], Overflow_out ? Overflow_out : &Overflow_ignored ); -#else /* BASOP_NOGLOB */ - L_sum = L_mac( L_sum, x[i], y[i] ); -#endif /* BASOP_NOGLOB */ } /* Normalize acc in Q31 */ @@ -217,7 +198,6 @@ Word32 Dot_product12( /* (o) Q31: normalized result (1 < val < return L_sum; } -#ifdef BASOP_NOGLOB Word32 Dot_product12( /* (o) Q31: normalized result (1 < val <= -1) */ const Word16 x[], /* (i) 12bits: x vector */ const Word16 y[], /* (i) 12bits: y vector */ @@ -228,7 +208,6 @@ Word32 Dot_product12( /* (o) Q31: normalized result (1 < val < /* Ignore internal overflows */ return Dot_product12_o( x, y, lg, exp, NULL ); } -#endif /* BASOP_NOGLOB */ /*___________________________________________________________________________ | | @@ -258,18 +237,10 @@ Word32 Energy_scale( /* (o) : Q31: normalized result (1 < val IF( expi == 0 ) { -#ifdef BASOP_NOGLOB L_sum = L_mac_o( 1, x[0], x[0], &Overflow ); -#else - L_sum = L_mac( 1, x[0], x[0] ); -#endif FOR( i = 1; i < lg; i++ ) { -#ifdef BASOP_NOGLOB L_sum = L_mac_o( L_sum, x[i], x[i], &Overflow ); -#else /* BASOP_NOGLOB */ - L_sum = L_mac( L_sum, x[i], x[i] ); -#endif } } IF( expi < 0 ) @@ -280,16 +251,11 @@ Word32 Energy_scale( /* (o) : Q31: normalized result (1 < val FOR( i = 1; i < lg; i++ ) { tmp = mult_r( x[i], sft ); -#ifdef BASOP_NOGLOB L_sum = L_mac_o( L_sum, tmp, tmp, &Overflow ); -#else - L_sum = L_mac( L_sum, tmp, tmp ); -#endif } } IF( expi > 0 ) { -#ifdef BASOP_NOGLOB tmp = shl_o( x[0], expi, &Overflow ); L_sum = L_mac_o( 1, tmp, tmp, &Overflow ); FOR( i = 1; i < lg; i++ ) @@ -297,15 +263,6 @@ Word32 Energy_scale( /* (o) : Q31: normalized result (1 < val tmp = shl_o( x[i], expi, &Overflow ); L_sum = L_mac_o( L_sum, tmp, tmp, &Overflow ); } -#else - tmp = shl( x[0], expi ); - L_sum = L_mac( 1, tmp, tmp ); - FOR( i = 1; i < lg; i++ ) - { - tmp = shl( x[i], expi ); - L_sum = L_mac( L_sum, tmp, tmp ); - } -#endif } /* Normalize acc in Q31 */ diff --git a/lib_com/modif_fs_fx.c b/lib_com/modif_fs_fx.c index b53bb9d1ca18e0bbfaffa7e90245fcec66a9a64d..6079e5db5a5ef4c1a8b073b8a5c1ac8e450170ce 100644 --- a/lib_com/modif_fs_fx.c +++ b/lib_com/modif_fs_fx.c @@ -206,13 +206,8 @@ Word16 modify_Fs_ivas_fx( /* o : length of output Q { sigPtr = signal_fx + add( lg, add( mem_len, i ) ); L_tmp = syn_kern_16( 0, A_fx, sigPtr ); -#ifdef BASOP_NOGLOB L_tmp = L_shl_sat( L_tmp, 3 ); *sigPtr = round_fx_sat( L_tmp ); /* AZ ringing padding */ -#else - L_tmp = L_shl( L_tmp, 3 ); - *sigPtr = round_fx( L_tmp ); /* AZ ringing padding */ -#endif move16(); } mem_preemph_fx = signal_fx[mem_len + lg - LEN_WIN_SSS - 1]; @@ -238,11 +233,7 @@ Word16 modify_Fs_ivas_fx( /* o : length of output Q Word16 norm_cfg_ptr = norm_s( sub( cfg_ptr_fx->filter_fx[0], 1 ) ); FOR( i = 0; i < lg_out; i++ ) { -#ifdef BASOP_NOGLOB sigOut_fx[i] = round_fx_sat( Interpol_lc_fx( sigIn_ptr, cfg_ptr_fx->filter_fx, frac, fac_num, filt_len_tmp ) ); -#else - sigOut_fx[i] = round_fx( Interpol_lc_fx( sigIn_ptr, cfg_ptr_fx->filter_fx, frac, fac_num, filt_len_tmp ) ); -#endif move16(); frac = add( frac, fracstep ); @@ -282,13 +273,9 @@ Word16 modify_Fs_ivas_fx( /* o : length of output Q test(); IF( GT_32( fin, 16000 ) && ( EQ_16( lg_out, L_FRAME ) || EQ_16( lg_out, L_FRAME16k ) || EQ_16( lg_out, 512 ) ) ) { -#ifdef BASOP_NOGLOB num_den = shl_o( num_den, 1, &Overflow ); *Q_new_inp = add( *Q_new_inp, 1 ); move16(); -#else - num_den = shl( num_den, 1 ); -#endif } FOR( i = 0; i < lg_out; i++ ) { @@ -512,13 +499,8 @@ Word16 modify_Fs_fx( /* o : length of output Q0 */ sigPtr = signal_fx + add( add( lg, mem_len ), i ); move16(); /*+i*/ L_tmp = syn_kern_16( 0, A_fx, sigPtr ); -#ifdef BASOP_NOGLOB L_tmp = L_shl_sat( L_tmp, 3 ); *sigPtr = round_fx_sat( L_tmp ); /* AZ ringing padding */ -#else - L_tmp = L_shl( L_tmp, 3 ); - *sigPtr = round_fx( L_tmp ); /* AZ ringing padding */ -#endif } mem_preemph_fx = signal_fx[mem_len + lg - LEN_WIN_SSS - 1]; move16(); @@ -542,11 +524,7 @@ Word16 modify_Fs_fx( /* o : length of output Q0 */ FOR( i = 0; i < lg_out; i++ ) { -#ifdef BASOP_NOGLOB sigOut_fx[i] = round_fx_sat( Interpol_lc_fx( sigIn_ptr, cfg_ptr_fx->filter_fx, frac, fac_num, filt_len_tmp ) ); -#else - sigOut_fx[i] = round_fx( Interpol_lc_fx( sigIn_ptr, cfg_ptr_fx->filter_fx, frac, fac_num, filt_len_tmp ) ); -#endif move16(); frac = add( frac, fracstep ); @@ -584,12 +562,8 @@ Word16 modify_Fs_fx( /* o : length of output Q0 */ test(); if ( GT_32( fin, 16000 ) && ( EQ_16( lg_out, L_FRAME ) || EQ_16( lg_out, L_FRAME16k ) || EQ_16( lg_out, 512 ) ) ) { -#ifdef BASOP_NOGLOB num_den = shl_o( num_den, 1, &Overflow ); //*Q_new_inp = 2; -#else - num_den = shl( num_den, 1 ); -#endif } FOR( i = 0; i < lg_out; i++ ) { @@ -980,112 +954,63 @@ void Decimate_allpass_steep_fx( FOR( k = 0; k < N / 2; k++ ) { - Lacc = L_deposit_h( mem[0] ); /* Q(16+x) */ -#ifdef BASOP_NOGLOB + Lacc = L_deposit_h( mem[0] ); /* Q(16+x) */ Lacc = L_mac_o( Lacc, AP1_STEEP_FX[0], in_fx[2 * k], &Overflow ); /* Q(16+x) */ -#else - Lacc = L_mac( Lacc, AP1_STEEP_FX[0], in_fx[2 * k] ); /* Q(16+x) */ -#endif - Lacc1 = L_deposit_h( in_fx[2 * k] ); /* Q16+Qx */ - temp1 = extract_h( Lacc ); /* Qx */ -#ifdef BASOP_NOGLOB - Lacc1 = L_msu_o( Lacc1, AP1_STEEP_FX[0], temp1, &Overflow ); /* Q16+Qx */ -#else - Lacc1 = L_msu( Lacc1, AP1_STEEP_FX[0], temp1 ); /* Q16+Qx */ -#endif - mem[0] = extract_h( Lacc1 ); /* Qx */ + Lacc1 = L_deposit_h( in_fx[2 * k] ); /* Q16+Qx */ + temp1 = extract_h( Lacc ); /* Qx */ + Lacc1 = L_msu_o( Lacc1, AP1_STEEP_FX[0], temp1, &Overflow ); /* Q16+Qx */ + mem[0] = extract_h( Lacc1 ); /* Qx */ temp[0] = temp1; move16(); move16(); - Lacc1 = L_deposit_h( mem[1] ); /* Q16+Qx */ -#ifdef BASOP_NOGLOB + Lacc1 = L_deposit_h( mem[1] ); /* Q16+Qx */ Lacc1 = ( L_mac_o( Lacc1, AP1_STEEP_FX[1], temp1, &Overflow ) ); /* Q16+Qx */ -#else - Lacc1 = ( L_mac( Lacc1, AP1_STEEP_FX[1], temp1 ) ); /* Q16+Qx */ -#endif - temp2 = extract_h( Lacc1 ); /* Qx */ -#ifdef BASOP_NOGLOB + temp2 = extract_h( Lacc1 ); /* Qx */ Lacc = L_msu_o( Lacc, AP1_STEEP_FX[1], temp2, &Overflow ); /* Q16+Qx */ -#else - Lacc = L_msu( Lacc, AP1_STEEP_FX[1], temp2 ); /* Q16+Qx */ -#endif - mem[1] = extract_h( Lacc ); /* Qx */ + mem[1] = extract_h( Lacc ); /* Qx */ temp[1] = temp2; move16(); move16(); - Lacc = L_deposit_h( mem[ALLPASSSECTIONS_STEEP - 1] ); /* Q(16+x) */ -#ifdef BASOP_NOGLOB + Lacc = L_deposit_h( mem[ALLPASSSECTIONS_STEEP - 1] ); /* Q(16+x) */ out_fx[k] = extract_h( L_mac_o( Lacc, AP1_STEEP_FX[ALLPASSSECTIONS_STEEP - 1], temp2, &Overflow ) ); /* Qx format */ move16(); mem[ALLPASSSECTIONS_STEEP - 1] = extract_h( L_msu_o( Lacc1, AP1_STEEP_FX[ALLPASSSECTIONS_STEEP - 1], out_fx[k], &Overflow ) ); /* Qx */ move16(); -#else - out_fx[k] = extract_h( L_mac( Lacc, AP1_STEEP_FX[ALLPASSSECTIONS_STEEP - 1], temp2 ) ); /* Qx format */ - mem[ALLPASSSECTIONS_STEEP - 1] = extract_h( L_msu( Lacc1, AP1_STEEP_FX[ALLPASSSECTIONS_STEEP - 1], out_fx[k] ) ); /* Qx */ -#endif } /* lower allpass filter chain */ - Lacc = L_deposit_h( mem[ALLPASSSECTIONS_STEEP] ); /* Q(16+x) */ -#ifdef BASOP_NOGLOB + Lacc = L_deposit_h( mem[ALLPASSSECTIONS_STEEP] ); /* Q(16+x) */ Lacc = L_mac_o( Lacc, AP2_STEEP_FX[0], mem[2 * ALLPASSSECTIONS_STEEP], &Overflow ); /*Q(16+x) */ -#else - Lacc = L_mac( Lacc, AP2_STEEP_FX[0], mem[2 * ALLPASSSECTIONS_STEEP] ); /*Q(16+x) */ -#endif - Lacc1 = L_deposit_h( mem[2 * ALLPASSSECTIONS_STEEP] ); /* Q(16+x) */ - temp1 = extract_h( Lacc ); /* Qx */ -#ifdef BASOP_NOGLOB - Lacc1 = L_msu_o( Lacc1, AP2_STEEP_FX[0], temp1, &Overflow ); /* Q(16+x) */ -#else - Lacc1 = L_msu( Lacc1, AP2_STEEP_FX[0], temp1 ); /* Q(16+x) */ -#endif + Lacc1 = L_deposit_h( mem[2 * ALLPASSSECTIONS_STEEP] ); /* Q(16+x) */ + temp1 = extract_h( Lacc ); /* Qx */ + Lacc1 = L_msu_o( Lacc1, AP2_STEEP_FX[0], temp1, &Overflow ); /* Q(16+x) */ mem[ALLPASSSECTIONS_STEEP] = extract_h( Lacc1 ); temp[0] = temp1; move16(); - Lacc1 = L_deposit_h( mem[ALLPASSSECTIONS_STEEP + 1] ); /* Q(16+x) */ -#ifdef BASOP_NOGLOB + Lacc1 = L_deposit_h( mem[ALLPASSSECTIONS_STEEP + 1] ); /* Q(16+x) */ Lacc1 = L_mac_o( Lacc1, AP2_STEEP_FX[1], temp1, &Overflow ); /* Q(16+x) */ -#else - Lacc1 = L_mac( Lacc1, AP2_STEEP_FX[1], temp1 ); /* Q(16+x) */ -#endif - temp2 = extract_h( Lacc1 ); /* Qx */ + temp2 = extract_h( Lacc1 ); /* Qx */ temp[1] = temp2; move16(); -#ifdef BASOP_NOGLOB Lacc = L_msu_o( Lacc, AP2_STEEP_FX[1], temp2, &Overflow ); /* Q(16+x) */ -#else - Lacc = L_msu( Lacc, AP2_STEEP_FX[1], temp2 ); /* Q(16+x) */ -#endif - mem[ALLPASSSECTIONS_STEEP + 1] = extract_h( Lacc ); /* Qx */ + mem[ALLPASSSECTIONS_STEEP + 1] = extract_h( Lacc ); /* Qx */ move16(); - Lacc = L_deposit_h( mem[2 * ALLPASSSECTIONS_STEEP - 1] ); /* Q(16+x) */ -#ifdef BASOP_NOGLOB + Lacc = L_deposit_h( mem[2 * ALLPASSSECTIONS_STEEP - 1] ); /* Q(16+x) */ Lacc = L_mac_o( Lacc, AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1], temp2, &Overflow ); /* Q(16+x) temp[ALLPASSSECTIONS_STEEP-1] */ -#else - Lacc = L_mac( Lacc, AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1], temp2 ); /* Q(16+x) temp[ALLPASSSECTIONS_STEEP-1] */ -#endif - temp[2] = extract_h( Lacc ); /* temp[2] in Qx */ + temp[2] = extract_h( Lacc ); /* temp[2] in Qx */ move16(); -#ifdef BASOP_NOGLOB Lacc1 = L_msu_o( Lacc1, AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1], temp[2], &Overflow ); /* Q(16+x) */ -#else - Lacc1 = L_msu( Lacc1, AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1], temp[2] ); /* Q(16+x) */ -#endif - mem[2 * ALLPASSSECTIONS_STEEP - 1] = extract_h( Lacc1 ); /* Qx */ + mem[2 * ALLPASSSECTIONS_STEEP - 1] = extract_h( Lacc1 ); /* Qx */ move16(); - sum = mult_r( out_fx[0], 16384 ); /* Qx */ -#ifdef BASOP_NOGLOB + sum = mult_r( out_fx[0], 16384 ); /* Qx */ out_fx[0] = add_sat( sum, mult_r( temp[ALLPASSSECTIONS_STEEP - 1], 16384 ) ); /* Qx */ -#else - out_fx[0] = add( sum, mult_r( temp[ALLPASSSECTIONS_STEEP - 1], 16384 ) ); /* Qx */ -#endif move16(); @@ -1093,19 +1018,11 @@ void Decimate_allpass_steep_fx( { - Lacc = L_deposit_h( mem[ALLPASSSECTIONS_STEEP] ); /* Q(16+x) */ -#ifdef BASOP_NOGLOB + Lacc = L_deposit_h( mem[ALLPASSSECTIONS_STEEP] ); /* Q(16+x) */ Lacc = L_mac_o( Lacc, AP2_STEEP_FX[0], in_fx[2 * k - 1], &Overflow ); /* Q(16+x):temp[0] */ -#else - Lacc = L_mac( Lacc, AP2_STEEP_FX[0], in_fx[2 * k - 1] ); /* Q(16+x):temp[0] */ -#endif - Lacc1 = L_deposit_h( in_fx[2 * k - 1] ); /* Q(16+x) */ - temp1 = extract_h( Lacc ); /* Qx */ -#ifdef BASOP_NOGLOB - Lacc1 = L_msu_o( Lacc1, AP2_STEEP_FX[0], temp1, &Overflow ); /* Q(16+x) */ -#else - Lacc1 = L_msu( Lacc1, AP2_STEEP_FX[0], temp1 ); /* Q(16+x) */ -#endif + Lacc1 = L_deposit_h( in_fx[2 * k - 1] ); /* Q(16+x) */ + temp1 = extract_h( Lacc ); /* Qx */ + Lacc1 = L_msu_o( Lacc1, AP2_STEEP_FX[0], temp1, &Overflow ); /* Q(16+x) */ mem[ALLPASSSECTIONS_STEEP] = extract_h( Lacc1 ); /* Qx */ move16(); @@ -1113,45 +1030,25 @@ void Decimate_allpass_steep_fx( move16(); - Lacc1 = L_deposit_h( mem[ALLPASSSECTIONS_STEEP + 1] ); /* Q(16+x) */ -#ifdef BASOP_NOGLOB + Lacc1 = L_deposit_h( mem[ALLPASSSECTIONS_STEEP + 1] ); /* Q(16+x) */ Lacc1 = L_mac_o( Lacc1, AP2_STEEP_FX[1], temp1, &Overflow ); /* Q(16+x) */ -#else - Lacc1 = L_mac( Lacc1, AP2_STEEP_FX[1], temp1 ); /* Q(16+x) */ -#endif - temp2 = extract_h( Lacc1 ); /* Qx */ + temp2 = extract_h( Lacc1 ); /* Qx */ temp[1] = temp2; move16(); -#ifdef BASOP_NOGLOB Lacc = L_msu_o( Lacc, AP2_STEEP_FX[1], temp2, &Overflow ); /* Q(16+x) */ -#else - Lacc = L_msu( Lacc, AP2_STEEP_FX[1], temp2 ); /* Q(16+x) */ -#endif - mem[ALLPASSSECTIONS_STEEP + 1] = extract_h( Lacc ); /* Qx */ + mem[ALLPASSSECTIONS_STEEP + 1] = extract_h( Lacc ); /* Qx */ - Lacc = L_deposit_h( mem[2 * ALLPASSSECTIONS_STEEP - 1] ); /* Q(16+x) */ -#ifdef BASOP_NOGLOB - Lacc = L_mac_o( Lacc, AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1], temp[1], &Overflow ); /* Q(16+x) temp[ALLPASSSECTIONS_STEEP-1] */ -#else - Lacc = L_mac( Lacc, AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1], temp[1] ); /* Q(16+x) temp[ALLPASSSECTIONS_STEEP-1] */ -#endif - temp[2] = extract_h( Lacc ); /*temp[2] in Qx */ -#ifdef BASOP_NOGLOB + Lacc = L_deposit_h( mem[2 * ALLPASSSECTIONS_STEEP - 1] ); /* Q(16+x) */ + Lacc = L_mac_o( Lacc, AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1], temp[1], &Overflow ); /* Q(16+x) temp[ALLPASSSECTIONS_STEEP-1] */ + temp[2] = extract_h( Lacc ); /*temp[2] in Qx */ Lacc1 = L_msu_o( Lacc1, AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1], temp[2], &Overflow ); /* Q(16+x) */ -#else - Lacc1 = L_msu( Lacc1, AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1], temp[2] ); /* Q(16+x) */ -#endif - mem[2 * ALLPASSSECTIONS_STEEP - 1] = extract_h( Lacc1 ); /* Qx */ + mem[2 * ALLPASSSECTIONS_STEEP - 1] = extract_h( Lacc1 ); /* Qx */ sum = mult_r( out_fx[k], 16384 ); /* Qx */ -#ifdef BASOP_NOGLOB out_fx[k] = add_sat( sum, mult_r( temp[ALLPASSSECTIONS_STEEP - 1], 16384 ) ); move16(); -#else - out_fx[k] = add( sum, mult_r( temp[ALLPASSSECTIONS_STEEP - 1], 16384 ) ); -#endif move16(); /* Qx */ } @@ -1188,109 +1085,56 @@ void Interpolate_allpass_steep_fx( FOR( k = 0; k < N; k++ ) { - Lacc = L_deposit_h( mem[0] ); /* Q(16+x) */ -#ifdef BASOP_NOGLOB + Lacc = L_deposit_h( mem[0] ); /* Q(16+x) */ Lacc = L_mac_o( Lacc, AP2_STEEP_FX[0], in_fx[k], &Overflow ); /* Q(16+x):temp[0] */ -#else - Lacc = L_mac( Lacc, AP2_STEEP_FX[0], in_fx[k] ); /* Q(16+x):temp[0] */ -#endif - Lacc1 = L_deposit_h( in_fx[k] ); /* Q(16+x) */ -#ifdef BASOP_NOGLOB - temp1 = round_fx_o( Lacc, &Overflow ); /* Qx */ - Lacc1 = L_msu_o( Lacc1, AP2_STEEP_FX[0], temp1, &Overflow ); /* Q(16+x) */ + Lacc1 = L_deposit_h( in_fx[k] ); /* Q(16+x) */ + temp1 = round_fx_o( Lacc, &Overflow ); /* Qx */ + Lacc1 = L_msu_o( Lacc1, AP2_STEEP_FX[0], temp1, &Overflow ); /* Q(16+x) */ mem[0] = round_fx_o( Lacc1, &Overflow ); move16(); -#else - temp1 = round_fx( Lacc ); /* Qx */ - Lacc1 = L_msu( Lacc1, AP2_STEEP_FX[0], temp1 ); /* Q(16+x) */ - - mem[0] = round_fx( Lacc1 ); -#endif - Lacc1 = L_deposit_h( mem[1] ); /* Q(16+x) */ -#ifdef BASOP_NOGLOB + Lacc1 = L_deposit_h( mem[1] ); /* Q(16+x) */ Lacc1 = ( L_mac_o( Lacc1, AP2_STEEP_FX[1], temp1, &Overflow ) ); /* Q(16+x):temp[1] */ -#else - Lacc1 = ( L_mac( Lacc1, AP2_STEEP_FX[1], temp1 ) ); /* Q(16+x):temp[1] */ -#endif Lacc = L_deposit_h( temp1 ); -#ifdef BASOP_NOGLOB temp2 = round_fx_o( Lacc1, &Overflow ); /* Qx */ Lacc = L_msu_o( Lacc, AP2_STEEP_FX[1], temp2, &Overflow ); /* Q(16+x) */ mem[1] = round_fx_o( Lacc, &Overflow ); /* Qx */ move16(); -#else - temp2 = round_fx( Lacc1 ); /* Qx */ - Lacc = L_msu( Lacc, AP2_STEEP_FX[1], temp2 ); /* Q(16+x) */ - mem[1] = round_fx( Lacc ); /* Qx */ -#endif Lacc1 = L_deposit_h( temp2 ); - Lacc = L_deposit_h( mem[ALLPASSSECTIONS_STEEP - 1] ); /* Q(16+x) */ -#ifdef BASOP_NOGLOB + Lacc = L_deposit_h( mem[ALLPASSSECTIONS_STEEP - 1] ); /* Q(16+x) */ out_fx[2 * k + 1] = round_fx_o( L_mac_o( Lacc, AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1], temp2, &Overflow ), &Overflow ); /* Qx format */ move16(); mem[ALLPASSSECTIONS_STEEP - 1] = round_fx_o( L_msu_o( Lacc1, AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1], out_fx[2 * k + 1], &Overflow ), &Overflow ); /* Qx */ move16(); -#else - out_fx[2 * k + 1] = round_fx( L_mac( Lacc, AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1], temp2 ) ); /* Qx format */ - mem[ALLPASSSECTIONS_STEEP - 1] = round_fx( L_msu( Lacc1, AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1], out_fx[2 * k + 1] ) ); /* Qx */ -#endif } /* lower allpass filter chain */ FOR( k = 0; k < N; k++ ) { - Lacc = L_deposit_h( mem[ALLPASSSECTIONS_STEEP] ); /* Q(16+x) */ -#ifdef BASOP_NOGLOB + Lacc = L_deposit_h( mem[ALLPASSSECTIONS_STEEP] ); /* Q(16+x) */ Lacc = L_mac_o( Lacc, AP1_STEEP_FX[0], in_fx[k], &Overflow ); /* Q(16+x):temp[0] */ -#else - Lacc = L_mac( Lacc, AP1_STEEP_FX[0], in_fx[k] ); /* Q(16+x):temp[0] */ -#endif - Lacc1 = L_deposit_h( in_fx[k] ); /* Q(16+x) */ -#ifdef BASOP_NOGLOB - temp1 = round_fx_o( Lacc, &Overflow ); /* Qx */ - Lacc1 = L_msu_o( Lacc1, AP1_STEEP_FX[0], temp1, &Overflow ); /* Q(16+x) */ + Lacc1 = L_deposit_h( in_fx[k] ); /* Q(16+x) */ + temp1 = round_fx_o( Lacc, &Overflow ); /* Qx */ + Lacc1 = L_msu_o( Lacc1, AP1_STEEP_FX[0], temp1, &Overflow ); /* Q(16+x) */ mem[ALLPASSSECTIONS_STEEP] = round_fx_o( Lacc1, &Overflow ); -#else - temp1 = round_fx( Lacc ); /* Qx */ - Lacc1 = L_msu( Lacc1, AP1_STEEP_FX[0], temp1 ); /* Q(16+x) */ - - mem[ALLPASSSECTIONS_STEEP] = round_fx( Lacc1 ); -#endif - Lacc1 = L_deposit_h( mem[ALLPASSSECTIONS_STEEP + 1] ); /* Q(16+x) */ -#ifdef BASOP_NOGLOB + Lacc1 = L_deposit_h( mem[ALLPASSSECTIONS_STEEP + 1] ); /* Q(16+x) */ Lacc1 = L_mac_o( Lacc1, AP1_STEEP_FX[1], temp1, &Overflow ); /* Q(16+x):temp[1] */ temp2 = round_fx_o( Lacc1, &Overflow ); /* Qx */ -#else - Lacc1 = L_mac( Lacc1, AP1_STEEP_FX[1], temp1 ); /* Q(16+x):temp[1] */ - - temp2 = round_fx( Lacc1 ); /* Qx */ -#endif Lacc = L_deposit_h( temp1 ); -#ifdef BASOP_NOGLOB Lacc = L_msu_o( Lacc, AP1_STEEP_FX[1], temp2, &Overflow ); /* Q(16+x) */ mem[ALLPASSSECTIONS_STEEP + 1] = round_fx_o( Lacc, &Overflow ); /* Qx */ -#else - Lacc = L_msu( Lacc, AP1_STEEP_FX[1], temp2 ); /* Q(16+x) */ - mem[ALLPASSSECTIONS_STEEP + 1] = round_fx( Lacc ); /* Qx */ -#endif Lacc = L_deposit_h( mem[2 * ALLPASSSECTIONS_STEEP - 1] ); /* Q(16+x) */ Lacc1 = L_deposit_h( temp2 ); -#ifdef BASOP_NOGLOB out_fx[2 * k] = round_fx_o( L_mac_o( Lacc, AP1_STEEP_FX[ALLPASSSECTIONS_STEEP - 1], temp2, &Overflow ), &Overflow ); /* Qx format */ move16(); mem[2 * ALLPASSSECTIONS_STEEP - 1] = round_fx_o( L_msu_o( Lacc1, AP1_STEEP_FX[ALLPASSSECTIONS_STEEP - 1], out_fx[2 * k], &Overflow ), &Overflow ); /* Qx */ move16(); -#else - out_fx[2 * k] = round_fx( L_mac( Lacc, AP1_STEEP_FX[ALLPASSSECTIONS_STEEP - 1], temp2 ) ); /* Qx format */ - mem[2 * ALLPASSSECTIONS_STEEP - 1] = round_fx( L_msu( Lacc1, AP1_STEEP_FX[ALLPASSSECTIONS_STEEP - 1], out_fx[2 * k] ) ); /* Qx */ -#endif } return; @@ -1346,19 +1190,11 @@ void interpolate_3_over_2_allpass_fx( Vu[1] = mem[1] + filt_coeff[1] * ( Vu[0] - mem[2] ); mem[3] = mem[2] + filt_coeff[2] * ( Vu[1] - mem[3] );*/ -#ifdef BASOP_NOGLOB Vu[0] = add_sat( mem_fx[0], mult_r_sat( filt_coeff_fx[0], sub_sat( input_fx_temp[i], mem_fx[1] ) ) ); move16(); /* all Vu's in : Q_current*/ Vu[1] = add_sat( mem_fx[1], mult_r_sat( filt_coeff_fx[1], sub_sat( Vu[0], mem_fx[2] ) ) ); move16(); mem_fx[3] = add_sat( mem_fx[2], mult_r_sat( filt_coeff_fx[2], sub_sat( Vu[1], mem_fx[3] ) ) ); -#else - Vu[0] = add( mem_fx[0], mult_r( filt_coeff_fx[0], sub( input_fx_temp[i], mem_fx[1] ) ) ); - move16(); /* all Vu's in : Q_current*/ - Vu[1] = add( mem_fx[1], mult_r( filt_coeff_fx[1], sub( Vu[0], mem_fx[2] ) ) ); - move16(); - mem_fx[3] = add( mem_fx[2], mult_r( filt_coeff_fx[2], sub( Vu[1], mem_fx[3] ) ) ); -#endif move16(); @@ -1373,21 +1209,12 @@ void interpolate_3_over_2_allpass_fx( /* Vm[0] = mem[0] + filt_coeff[3] * (input[i]-mem[4]); Vm[1] = mem[4] + filt_coeff[4] * (Vm[0]-mem[5]); mem[6] = mem[5] + filt_coeff[5] * (Vm[1]-mem[6]); */ -#ifdef BASOP_NOGLOB Vm[0] = add_sat( mem_fx[0], mult_r_sat( filt_coeff_fx[3], sub_sat( input_fx_temp[i], mem_fx[4] ) ) ); move16(); Vm[1] = add_sat( mem_fx[4], mult_r_sat( filt_coeff_fx[4], sub_sat( Vm[0], mem_fx[5] ) ) ); move16(); mem_fx[6] = add_sat( mem_fx[5], mult_r_sat( filt_coeff_fx[5], sub_sat( Vm[1], mem_fx[6] ) ) ); move16(); -#else - Vm[0] = add( mem_fx[0], mult_r( filt_coeff_fx[3], sub( input_fx_temp[i], mem_fx[4] ) ) ); - move16(); - Vm[1] = add( mem_fx[4], mult_r( filt_coeff_fx[4], sub( Vm[0], mem_fx[5] ) ) ); - move16(); - mem_fx[6] = add( mem_fx[5], mult_r( filt_coeff_fx[5], sub( Vm[1], mem_fx[6] ) ) ); - move16(); -#endif mem_fx[4] = Vm[0]; move16(); mem_fx[5] = Vm[1]; @@ -1399,21 +1226,12 @@ void interpolate_3_over_2_allpass_fx( /* Vl[0] = mem[0] + filt_coeff[6] * (input[i]-mem[7]); Vl[1] = mem[7] + filt_coeff[7] * (Vl[0]-mem[8]); mem[9] = mem[8] + filt_coeff[8] * (Vl[1]-mem[9]); */ -#ifdef BASOP_NOGLOB Vl[0] = add_sat( mem_fx[0], mult_r_sat( filt_coeff_fx[6], sub_sat( input_fx_temp[i], mem_fx[7] ) ) ); move16(); Vl[1] = add_sat( mem_fx[7], mult_r_sat( filt_coeff_fx[7], sub_sat( Vl[0], mem_fx[8] ) ) ); move16(); mem_fx[9] = add_sat( mem_fx[8], mult_r_sat( filt_coeff_fx[8], sub_sat( Vl[1], mem_fx[9] ) ) ); move16(); -#else - Vl[0] = add( mem_fx[0], mult_r( filt_coeff_fx[6], sub( input_fx_temp[i], mem_fx[7] ) ) ); - move16(); - Vl[1] = add( mem_fx[7], mult_r( filt_coeff_fx[7], sub( Vl[0], mem_fx[8] ) ) ); - move16(); - mem_fx[9] = add( mem_fx[8], mult_r( filt_coeff_fx[8], sub( Vl[1], mem_fx[9] ) ) ); - move16(); -#endif mem_fx[0] = input_fx_temp[i]; move16(); mem_fx[7] = Vl[0]; @@ -1432,13 +1250,8 @@ void interpolate_3_over_2_allpass_fx( { mem_temp = out1_buff[shl( i, 1 )]; move16(); -#ifdef BASOP_NOGLOB out_fx[i] = add_sat( mult_r_sat( 1550 /* 0.0473147f Q15*/, add_sat( mem_temp, mem_fx[10] ) ), mult_r_sat( -4965 /*-0.151521f Q15*/, add_sat( mem_fx[11], mem_fx[14] ) ) ); out_fx[i] = add_sat( out_fx[i], mult_r_sat( 20125 /*0.614152f Q15*/, add_sat( mem_fx[12], mem_fx[13] ) ) ); -#else - out_fx[i] = add( mult_r( 1550 /* 0.0473147f Q15*/, add( mem_temp, mem_fx[10] ) ), mult_r( -4965 /*-0.151521f Q15*/, add( mem_fx[11], mem_fx[14] ) ) ); - out_fx[i] = add( out_fx[i], mult_r( 20125 /*0.614152f Q15*/, add( mem_fx[12], mem_fx[13] ) ) ); -#endif mem_fx[10] = mem_fx[11]; move16(); mem_fx[11] = mem_fx[12]; @@ -1581,23 +1394,11 @@ void interpolate_3_over_1_allpass_fx( Vu[1] = mem[1] + filt_coeff[1] * ( Vu[0] - mem[2] ); mem[3] = mem[2] + filt_coeff[2] * ( Vu[1] - mem[3] );*/ -#ifdef BASOP_NOGLOB Vu[0] = add_sat( mem_fx[0], mult_r( filt_coeff_fx[0], sub_sat( input_fx[i], mem_fx[1] ) ) ); -#else - Vu[0] = add( mem_fx[0], mult_r( filt_coeff_fx[0], sub( input_fx[i], mem_fx[1] ) ) ); -#endif move16(); /* all Vu's in : Q_current*/ -#ifdef BASOP_NOGLOB Vu[1] = add_sat( mem_fx[1], mult_r( filt_coeff_fx[1], sub_sat( Vu[0], mem_fx[2] ) ) ); -#else - Vu[1] = add( mem_fx[1], mult_r( filt_coeff_fx[1], sub( Vu[0], mem_fx[2] ) ) ); -#endif move16(); -#ifdef BASOP_NOGLOB mem_fx[3] = add_sat( mem_fx[2], mult_r( filt_coeff_fx[2], sub_sat( Vu[1], mem_fx[3] ) ) ); -#else - mem_fx[3] = add( mem_fx[2], mult_r( filt_coeff_fx[2], sub( Vu[1], mem_fx[3] ) ) ); -#endif move16(); @@ -1612,23 +1413,11 @@ void interpolate_3_over_1_allpass_fx( /* Vm[0] = mem[0] + filt_coeff[3] * (input[i]-mem[4]); Vm[1] = mem[4] + filt_coeff[4] * (Vm[0]-mem[5]); mem[6] = mem[5] + filt_coeff[5] * (Vm[1]-mem[6]); */ -#ifdef BASOP_NOGLOB Vm[0] = add_sat( mem_fx[0], mult_r( filt_coeff_fx[3], sub_sat( input_fx[i], mem_fx[4] ) ) ); -#else - Vm[0] = add( mem_fx[0], mult_r( filt_coeff_fx[3], sub( input_fx[i], mem_fx[4] ) ) ); -#endif move16(); -#ifdef BASOP_NOGLOB Vm[1] = add_sat( mem_fx[4], mult_r( filt_coeff_fx[4], sub_sat( Vm[0], mem_fx[5] ) ) ); -#else - Vm[1] = add( mem_fx[4], mult_r( filt_coeff_fx[4], sub( Vm[0], mem_fx[5] ) ) ); -#endif move16(); -#ifdef BASOP_NOGLOB mem_fx[6] = add_sat( mem_fx[5], mult_r( filt_coeff_fx[5], sub_sat( Vm[1], mem_fx[6] ) ) ); -#else - mem_fx[6] = add( mem_fx[5], mult_r( filt_coeff_fx[5], sub( Vm[1], mem_fx[6] ) ) ); -#endif move16(); mem_fx[4] = Vm[0]; @@ -1642,23 +1431,11 @@ void interpolate_3_over_1_allpass_fx( /* Vl[0] = mem[0] + filt_coeff[6] * (input[i]-mem[7]); Vl[1] = mem[7] + filt_coeff[7] * (Vl[0]-mem[8]); mem[9] = mem[8] + filt_coeff[8] * (Vl[1]-mem[9]); */ -#ifdef BASOP_NOGLOB Vl[0] = add_sat( mem_fx[0], mult_r( filt_coeff_fx[6], sub_sat( input_fx[i], mem_fx[7] ) ) ); -#else - Vl[0] = add( mem_fx[0], mult_r( filt_coeff_fx[6], sub( input_fx[i], mem_fx[7] ) ) ); -#endif move16(); -#ifdef BASOP_NOGLOB Vl[1] = add_sat( mem_fx[7], mult_r( filt_coeff_fx[7], sub_sat( Vl[0], mem_fx[8] ) ) ); -#else - Vl[1] = add( mem_fx[7], mult_r( filt_coeff_fx[7], sub( Vl[0], mem_fx[8] ) ) ); -#endif move16(); -#ifdef BASOP_NOGLOB mem_fx[9] = add_sat( mem_fx[8], mult_r( filt_coeff_fx[8], sub_sat( Vl[1], mem_fx[9] ) ) ); -#else - mem_fx[9] = add( mem_fx[8], mult_r( filt_coeff_fx[8], sub( Vl[1], mem_fx[9] ) ) ); -#endif move16(); mem_fx[0] = input_fx[i]; @@ -1675,11 +1452,7 @@ void interpolate_3_over_1_allpass_fx( { mem_temp = out_fx[i]; move16(); -#ifdef BASOP_NOGLOB out_fx[i] = sub_sat( mult_r( 18768 /*0.57276865021499168f Q15*/, add_sat( mem_fx[12], mem_fx[11] ) ), mult_r( 2425 /*0.074004974641176793f Q15*/, add_sat( mem_temp, mem_fx[10] ) ) ); -#else - out_fx[i] = sub( mult_r( 18768 /*0.57276865021499168f Q15*/, add( mem_fx[12], mem_fx[11] ) ), mult_r( 2425 /*0.074004974641176793f Q15*/, add( mem_temp, mem_fx[10] ) ) ); -#endif mem_fx[10] = mem_fx[11]; move16(); mem_fx[11] = mem_fx[12]; diff --git a/lib_com/oper_32b.c b/lib_com/oper_32b.c index 0b01cf957a32a65b2f5a11f0a5c8f8270b553ed3..be34a12481f96713597bce743c203af7811e3719 100644 --- a/lib_com/oper_32b.c +++ b/lib_com/oper_32b.c @@ -128,15 +128,9 @@ Word32 Mpy_32( Word16 hi1, Word16 lo1, Word16 hi2, Word16 lo2 ) Flag Overflow = 0; #endif -#ifdef BASOP_NOGLOB L_32 = L_mult( hi1, hi2 ); L_32 = L_mac_o( L_32, mult( hi1, lo2 ), 1, &Overflow ); L_32 = L_mac_o( L_32, mult( lo1, hi2 ), 1, &Overflow ); -#else - L_32 = L_mult( hi1, hi2 ); - L_32 = L_mac( L_32, mult( hi1, lo2 ), 1 ); - L_32 = L_mac( L_32, mult( lo1, hi2 ), 1 ); -#endif return ( L_32 ); } @@ -169,15 +163,9 @@ Word32 Mac_32( Word32 L_num, Word16 hi1, Word16 lo1, Word16 hi2, Word16 lo2 ) Flag Overflow = 0; #endif -#ifdef BASOP_NOGLOB L_32 = L_mac_o( L_num, hi1, hi2, &Overflow ); L_32 = L_mac_o( L_32, mult( hi1, lo2 ), 1, &Overflow ); L_32 = L_mac_o( L_32, mult( lo1, hi2 ), 1, &Overflow ); -#else - L_32 = L_mac( L_num, hi1, hi2 ); - L_32 = L_mac( L_32, mult( hi1, lo2 ), 1 ); - L_32 = L_mac( L_32, mult( lo1, hi2 ), 1 ); -#endif return ( L_32 ); } @@ -209,13 +197,8 @@ Word32 Sqr_32( Word16 hi, Word16 lo ) Flag Overflow = 0; #endif -#ifdef BASOP_NOGLOB L_32 = L_mult_o( hi, hi, &Overflow ); L_32 = L_mac_o( L_32, mult( hi, lo ), 2, &Overflow ); -#else - L_32 = L_mult( hi, hi ); - L_32 = L_mac( L_32, mult( hi, lo ), 2 ); -#endif return ( L_32 ); } @@ -402,11 +385,7 @@ Word32 Div_32( Word32 L_num, Word16 denom_hi, Word16 denom_lo ) lo = L_Extract_lc( L_32, &hi ); n_lo = L_Extract_lc( L_num, &n_hi ); L_32 = Mpy_32( n_hi, n_lo, hi, lo ); -#ifdef BASOP_NOGLOB L_32 = L_shl_sat( L_32, 2 ); -#else - L_32 = L_shl( L_32, 2 ); -#endif return ( L_32 ); } diff --git a/lib_com/options.h b/lib_com/options.h old mode 100644 new mode 100755 index 95257e26993c9be5ac58a577c5dc49baf24a1041..46ea18c9d6f1510e28b4232df0327135927b6026 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -52,6 +52,7 @@ #define DEBUG_FORCE_MDCT_STEREO_MODE /* Force stereo mode decision for MDCT stereo: -stereo 3 1 forces L/R coding and -stereo 3 2 forces full M/S coding */ #define DEBUG_FORCE_DIR /* Force modes/parameters by reading from external binary files */ /*#define DBG_WAV_WRITER*/ /* Enable dbgwrite_wav() function for generating ".wav" files */ +#define SUPPORT_FORCE_TCX10_TCX20 /* VA: Enable -force tcx10|tcx20 command-line option */ #endif #define SUPPORT_JBM_TRACEFILE /* Support for JBM tracefile, which is needed for 3GPP objective/subjective testing, but not relevant for real-world implementations */ @@ -66,7 +67,6 @@ /* #################### End DEBUGGING switches ############################ */ -#define BASOP_NOGLOB /* Disable global symbols in BASOPs, Overflow/Carry in BASOPs disabled, additional BASOPs in case of Overflow */ #ifndef BASOP_NOGLOB_DEV_USE_GLOBALS #define BASOP_NOGLOB_DECLARE_LOCAL #endif @@ -90,8 +90,8 @@ #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_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 */ @@ -106,10 +106,12 @@ #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_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*/ @@ -117,4 +119,50 @@ #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_920_IGF_INIT_ERROR /* FhG: issue 920: fix bitrate mismatch in initial IGF config to avoid error message in same cases */ +#define FIX_MINOR_SVD_WMOPS_MR1010X /* FhG: Minor WMOPS tuning, bit-exact to previous version, saves about 8.2 WMOPS for MR1010 */ +#define SVD_WMOPS_OPT /* Ittiam : SVD related optimizations */ +#define NONBE_FIX_1087_OOB_SBA_DTX_RS /* VA: issue 1087: Extend the length of the buffer for MCT decoding to avoid out-of-bound writing in SBA SID bitrate switching decoding */ +#define 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 #endif diff --git a/lib_com/phase_dispersion_fx.c b/lib_com/phase_dispersion_fx.c index 16feab1917e55311b85814a1317c1a21639b6c5c..723d173bcd2bda0a3699a95b67f46997665660f5 100644 --- a/lib_com/phase_dispersion_fx.c +++ b/lib_com/phase_dispersion_fx.c @@ -57,11 +57,7 @@ void phase_dispersion( move16(); prev_gain_pit[0] = gain_pit; -#ifdef BASOP_NOGLOB IF( GT_32( gain_code, L_add_o( *prev_gain_code, L_shl_o( *prev_gain_code, 1, &Overflow ), &Overflow ) ) ) -#else - IF( GT_32( gain_code, L_add( *prev_gain_code, L_shl( *prev_gain_code, 1 ) ) ) ) -#endif { IF( LT_16( state, 2 ) ) { @@ -118,13 +114,8 @@ void phase_dispersion( scale2 = getScaleFactor32( x32, L_subfr ); FOR( i = 0; i < L_subfr / 2 - 1; i++ ) { -#ifdef BASOP_NOGLOB code[i] = round_fx_sat( L_shl_sat( x32[2 * i + 0], scale2 ) ); code[L_subfr - 1 - i] = round_fx_sat( L_shl_sat( x32[2 * i + 3], scale2 ) ); -#else - code[i] = round_fx( L_shl( x32[2 * i + 0], scale2 ) ); - code[L_subfr - 1 - i] = round_fx( L_shl( x32[2 * i + 3], scale2 ) ); -#endif } code[L_subfr / 2 - 1] = round_fx( L_shl( x32[L_subfr - 2], scale2 ) ); @@ -174,12 +165,8 @@ void phase_dispersion( scale2 = getScaleFactor32( x32, L_subfr ); FOR( i = 0; i < L_subfr; i++ ) { -#ifdef BASOP_NOGLOB code[i] = round_fx_o( L_shl_o( x32[i], scale2, &Overflow ), &Overflow ); move16(); -#else - code[i] = round_fx( L_shl( x32[i], scale2 ) ); -#endif } j = sub( j, scale2 ); } diff --git a/lib_com/ppp_fx.c b/lib_com/ppp_fx.c index 92831ce2b7ed3a15c23d47e3a36e2915c3fedc6b..791813dc7d27eaeb8f54920ec6ae1ab3305ace0a 100644 --- a/lib_com/ppp_fx.c +++ b/lib_com/ppp_fx.c @@ -115,11 +115,7 @@ void deemph_lpc_fx( { /* LPC_de_curr[k] = a[0]*b[k] + a[1]*b[k+1]; */ temp = mult( a_fx[0], b_fx[k] ); /* Q12 */ -#ifdef BASOP_NOGLOB LPC_de_curr_fx[k] = add_o( temp, b_fx[k + 1], &Overflow ); -#else - LPC_de_curr_fx[k] = add( temp, b_fx[k + 1] ); -#endif move16(); /* Q12 */ } @@ -141,11 +137,7 @@ void deemph_lpc_fx( { /* LPC_de_old[k] = a[0]*b[k] + a[1]*b[k+1]; */ temp = mult( a_fx[0], b_fx[k] ); /* Q12 */ -#ifdef BASOP_NOGLOB LPC_de_old_fx[k] = add_o( temp, b_fx[k + 1], &Overflow ); -#else - LPC_de_old_fx[k] = add( temp, b_fx[k + 1] ); -#endif move16(); /* Q12 */ } } diff --git a/lib_com/pred_lt4_fx.c b/lib_com/pred_lt4_fx.c index 935e6b33f9348b7cbad105a629eb3c97f22b3481..4f8dd871289b8fc78c85678a24cb737da7378c84 100644 --- a/lib_com/pred_lt4_fx.c +++ b/lib_com/pred_lt4_fx.c @@ -71,19 +71,11 @@ void pred_lt4( s = W_sat_l( s64 ); /* Q_exc + Q14 */ } #if ( INTERP_EXP != -1 ) -#ifdef BASOP_NOGLOB s = L_shl_o( s, INTERP_EXP + 1, &Overflow ); /* Q_exc + Q15 */ -#else /* BASOP_NOGLOB */ - s = L_shl( s, INTERP_EXP + 1 ); -#endif /* BASOP_NOGLOB */ #endif -#ifdef BASOP_NOGLOB excO[j] = round_fx_o( s, &Overflow ); /* Q_exc */ move16(); -#else /* BASOP_NOGLOB */ - excO[j] = round_fx( s ); -#endif } return; } @@ -163,25 +155,15 @@ void pred_lt4_tc_fx( k += UP_SAMP; L_sum = L_mac( L_sum, x0[i], win[k] ); /* Q15 */ } -#ifdef BASOP_NOGLOB L_sum = L_shl_o( L_sum, 1, &Overflow ); /* Q16 */ excO[j] = round_fx_o( L_sum, &Overflow ); /* Q0 */ move16(); -#else - L_sum = L_shl( L_sum, 1 ); /*Q0h */ - - excO[j] = round_fx( L_sum ); -#endif x0++; } FOR( i = T0; i < L_SUBFR; i++ ) { -#ifdef BASOP_NOGLOB exc[i + i_subfr] = add_o( exc[i + i_subfr], mult_r( PIT_SHARP_fx, excO[i] ), &Overflow ); /* Q0 */ -#else - exc[i + i_subfr] = add( exc[i + i_subfr], mult_r( PIT_SHARP_fx, excO[i] ) ); -#endif move16(); } } diff --git a/lib_com/preemph_fx.c b/lib_com/preemph_fx.c index 0864323b41f02ad4a6449df110d23fb1b8b3eeb1..0790f6c3f2c8fdda954347962a335a029e7057f1 100644 --- a/lib_com/preemph_fx.c +++ b/lib_com/preemph_fx.c @@ -26,18 +26,10 @@ void preemph_copy_fx( move16(); FOR( i = lg - 1; i > 0; i-- ) { -#ifdef BASOP_NOGLOB y[i] = msu_ro( L_deposit_h( x[i] ), x[i - 1], mu, &Overflow ); /* Qx */ -#else - y[i] = msu_r( L_deposit_h( x[i] ), x[i - 1], mu ); -#endif move16(); } -#ifdef BASOP_NOGLOB y[0] = msu_ro( L_deposit_h( x[0] ), *mem, mu, &Overflow ); /* Qx */ -#else - y[0] = msu_r( L_deposit_h( x[0] ), *mem, mu ); -#endif move16(); *mem = temp; /* Qx */ @@ -61,18 +53,10 @@ void preemph_copy_32fx( move16(); FOR( i = lg - 1; i > 0; i-- ) { -#ifdef BASOP_NOGLOB y[i] = L_msu_o( L_deposit_h( x[i] ), x[i - 1], mu, &Overflow ); /* Qx+16 */ -#else - y[i] = L_msu( L_deposit_h( x[i] ), x[i - 1], mu ); -#endif move16(); } -#ifdef BASOP_NOGLOB y[0] = L_msu_o( L_deposit_h( x[0] ), *mem, mu, &Overflow ); /* Qx+16 */ -#else - y[0] = L_msu( L_deposit_h( x[0] ), *mem, mu ); -#endif move16(); *mem = temp; /* Qx */ @@ -114,30 +98,18 @@ void E_UTIL_f_preemph2( FOR( i = lg - 1; i > 0; i-- ) { - L_tmp = L_mult( signal[i], 16384 ); /* Qx + 15 */ -#ifdef BASOP_NOGLOB + L_tmp = L_mult( signal[i], 16384 ); /* Qx + 15 */ L_tmp = L_msu0_o( L_tmp, signal[i - 1], mu, &Overflow ); /* Qx + 15 */ L_tmp = L_shl_o( L_tmp, add( shift, 1 ), &Overflow ); /* Qx + shift + 16 */ signal[i] = round_fx_o( L_tmp, &Overflow ); /* Qx + shift */ move16(); -#else - L_tmp = L_msu0( L_tmp, signal[i - 1], mu ); - L_tmp = L_shl( L_tmp, add( shift, 1 ) ); - signal[i] = round_fx( L_tmp ); -#endif } - L_tmp = L_mult( signal[0], 16384 ); /* Qx + 15 */ -#ifdef BASOP_NOGLOB + L_tmp = L_mult( signal[0], 16384 ); /* Qx + 15 */ L_tmp = L_msu0_o( L_tmp, *mem, mu, &Overflow ); /* Qx + 15 */ L_tmp = L_shl_o( L_tmp, add( shift, 1 ), &Overflow ); /* Qx + shift + 16 */ signal[0] = round_fx_o( L_tmp, &Overflow ); /* Qx + shift */ move16(); -#else - L_tmp = L_msu0( L_tmp, *mem, mu ); - L_tmp = L_shl( L_tmp, add( shift, 1 ) ); - signal[0] = round_fx( L_tmp ); -#endif *mem = temp; /* Qx */ move16(); diff --git a/lib_com/prot.h b/lib_com/prot.h index 9985ca978d25841413a23beec53528ddca5ac455..647a18bf127b7e4472d345941cb9f8963df33e74 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -7461,35 +7461,6 @@ int16_t BITS_ALLOC_config_acelp_IVAS( const int16_t nb_subfr /* i : number of subframes */ ); -ivas_error config_acelp1_IVAS( - const int16_t enc_dec, /* i : encoder/decoder flag */ - const int32_t total_brate, /* i : total bitrate */ - const int32_t core_brate_inp, /* i : core bitrate */ - const int16_t core, /* i : core */ - const int16_t extl, /* i : extension layer */ - const int32_t extl_brate, /* i : extension layer bitrate */ - const int16_t L_frame, /* i : frame length at internal Fs */ - const int16_t GSC_noisy_speech, /* i : GSC on SWB noisy speech flag */ - ACELP_config *acelp_cfg, /* i : ACELP bit-allocation */ - const int16_t signaling_bits, /* i : number of signaling bits */ - const int16_t coder_type, /* i : coder type */ - const int16_t tc_subfr, /* i : TC subfr ID */ - const int16_t tc_call, /* i : TC call number (0,1,2) */ - int16_t *nBits_es_Pred, /* o : number of bits for Es_pred Q */ - int16_t *unbits, /* o : number of unused bits */ - const int16_t element_mode, /* i : element mode */ - int16_t *uc_two_stage_flag, /* o : flag undicating two-stage UC */ - const int16_t tdm_lp_reuse_flag, /* i : LPC reuse flag (can be 1 only with secondary channel*/ - const int16_t tdm_low_rate_mode, /* i : secondary channel low rate mode flag*/ - const int16_t idchan, /* i : channel id */ - const int16_t active_cnt, /* i : Active frame counter */ - const int16_t tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ - const int16_t tdm_LRTD_flag, /* i : LRTD stereo mode flag */ - const int16_t GSC_IVAS_mode /* i : GSC IVAS mode */ -); - -/*! r: ACELP16k flag */ - void FEC_clas_estim( const float *syn, @@ -8161,7 +8132,7 @@ void IGFEncApplyStereo( ); -void IGFEncResetTCX10BitCounter( +void IGFEncResetTCX10BitCounter_ivas_fx( const IGF_ENC_INSTANCE_HANDLE hIGFEnc /* i : instance handle of IGF Encoder */ ); diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 0080f41257f0537b1303b9d87237a88abd121e76..cf7072cf573e71726c44b82bb71c30efd502f311 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -218,6 +218,11 @@ Word32 sum2_fx( /* o : sum of all squared vector elements const Word16 lvec /* i : length of i vector */ ); +Word64 sum2_fx_no_sat( /* o : sum of all squared vector elements Q(2x)*/ + const Word16 *vec, /* i : i vector Qx*/ + const Word16 lvec /* i : length of i vector */ +); + Word16 sign_fx( const Word32 x /* i : input value of x */ ); @@ -429,6 +434,16 @@ void hq_generic_decoding_fx( const Word16 hq_generic_exc_clas, /* i : bwe excitation class */ const Word16 *R ); +void hq_generic_decoding_ivas_fx( + const Word16 HQ_mode, /* i : HQ mode */ + Word32 *coeff_out1_fx, /* i/o: BWE i & temporary buffer */ + const Word16 *hq_generic_fenv_fx, /* i : SWB frequency envelopes */ + Word32 *coeff_out_fx, /* o : SWB signal in MDCT domain */ + const Word16 hq_generic_offset, /* i : frequency offset for representing hq generic*/ + Word16 *prev_L_swb_norm, /* i/o: last normalize length */ + const Word16 hq_generic_exc_clas, /* i : bwe excitation class */ + const Word16 *R ); + void save_old_syn_fx( const Word16 L_frame, /* i : frame length */ const Word16 syn[], /* i : ACELP synthesis */ @@ -701,6 +716,19 @@ void hq_bwe_fx( const Word16 num_env_bands, const Word16 *R ); +void hq_bwe_ivas_fx( + const Word16 HQ_mode, /* i : HQ mode */ + Word32 *coeff_out1, /* i/o: BWE i & temporary buffer */ + const Word16 *hq_generic_fenv, /* i : SWB frequency envelopes */ + Word32 *coeff_out, /* o : SWB signal in MDCT domain */ + const Word16 hq_generic_offset, /* i : frequency offset for representing hq generic bwe*/ + Word16 *prev_L_swb_norm, /*i/o : last normalize length */ + const Word16 hq_generic_exc_clas, /* i : bwe excitation class */ + const Word16 *sfm_end, /* i : End of bands */ + const Word16 num_sfm, + const Word16 num_env_bands, + const Word16 *R ); + void hq_wb_nf_bwe_fx( const Word16 *coeff_fx, /* i : coded/noisefilled normalized spectrum */ const Word16 is_transient, @@ -808,6 +836,14 @@ 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, Word16 *freq, @@ -1071,6 +1107,12 @@ void lsp_weights_fx( Word16 Order, Word16 *Qout ); +void lsp_weights_ivas_fx( + Word16 lsp_nq_fx[], + Word16 w[], + Word16 Order, + Word16 *Qout ); + void space_lsfs_fx( Word16 *lsfs, /* i/o: Line spectral frequencies */ const Word16 order /* i : order of LP analysis */ @@ -1459,6 +1501,13 @@ void fft_rel_fx( const Word16 n, /* i : vector length */ const Word16 m /* i : log2 of vector length */ ); +void fft_rel_16_32fx( + Word16 x[], /* i/o: input/output vector Qx */ + Word16 *q_x, /* extra scaling added on speech buffer*/ + Word16 i_subfr, + const Word16 n, /* i : vector length */ + const Word16 m /* i : log2 of vector length */ +); void fft_rel_fx32( Word32 x[], /* i/o: i /output vector */ const Word16 n, /* i : vector length */ @@ -1689,13 +1738,11 @@ Word16 Enr_1_Az_fx( /* o : impulse response energy Q3 const Word16 Aq[], /* i : LP filter coefs Qx based on the fact that Aq[0] == 1.0 */ const Word16 len /* i : impulse response length Q0 */ ); -#ifdef BASOP_NOGLOB Word16 Enr_1_Az_fx_o( /* o : impulse response energy Q3 */ const Word16 Aq[], /* i : LP filter coefs Qx based on the fact that Aq[0] == 1.0 */ const Word16 len, /* i : impulse response length Q0 */ Flag *Overflow_out /* o : propagating the Overflow flag to upper level */ ); -#endif // gs_gains_fx.c void Ener_per_band_comp_fx( @@ -2380,6 +2427,20 @@ void syn_filt_fx( const Word16 update_m /* i : update memory flag Q0 : 0 --> no memory update */ ); /* 1 --> update of memory */ +void syn_filt_fx32( + const Word16 a_e, /* i : exp of LP coeffs Q0 */ + const Word32 a[], /* i : LP filter coefficients Q12 */ + const Word16 m, /* i : order of LP filter Q0 */ + const Word32 x[], /* i : input signal Qx */ + const Word16 x_e, /* i : input signal Qx */ + Word32 y[], /* o : output signal Qx */ + Word16 *y_e, /* o : output signal Qx */ + const Word16 l, /* i : size of filtering Q0 */ + Word32 mem[], /* i/o: initial filter states Qx */ + Word16 *mem_e, /* i/o: initial filter states Qx */ + const Word16 update_m /* i : update memory flag Q0 : 0 --> no memory update */ +); + void E_UTIL_synthesis( const Word16 shift, const Word16 a[], const Word16 x[], Word16 y[], const Word16 lg, Word16 mem[], const Word16 update, const Word16 m ); void E_UTIL_synthesis_fx( const Word16 shift, const Word32 a[], const Word32 x[], Word32 y[], const Word16 lg, Word32 mem[], const Word16 update, const Word16 m ); @@ -2855,6 +2916,11 @@ void Calc_rc0_h( Word16 *rc0 /* o : 1st parcor */ ); +void Calc_rc0_h_ivas_enc_fx( + Word16 *h, /* i : impulse response of composed filter */ + Word16 *rc0 /* o : 1st parcor */ +); + void PostShortTerm_fx( Word16 *sig_in, /* i : i signal (pointer to current subframe */ Word16 *lpccoeff, /* i : LPC coefficients for current subframe */ @@ -2995,15 +3061,18 @@ void GenShapedSHBExcitation_ivas_enc_fx( Word16 prev_Q_bwe_syn, /* i : st_fx->prev_Q_bwe_syn */ const Word32 bitrate, const Word16 prev_bfi -#if 1 // def ADD_IVAS_TBE_CODE - , /* i : previous frame was concealed */ - const Word16 element_mode, /* i : element mode */ - const Word16 flag_ACELP16k, /* i : ACELP@16kHz flag */ - Word16 *nlExc16k, /* i/o: NL exc for IC-BWE */ - Word16 *mixExc16k, /* i/o: exc spreading for IC-BWE */ - const Word32 extl_brate, /* i : extension layer bitarte */ - const Word16 MSFlag, /* i : Multi Source flag */ - Word16 EnvSHBres_4k[], /* i/o: TD envelope of the SHB residual signal */ +#if 1 // def ADD_IVAS_TBE_CODE + , /* i : previous frame was concealed */ + const Word16 element_mode, /* i : element mode */ + const Word16 flag_ACELP16k, /* i : ACELP@16kHz flag */ + Word16 *nlExc16k, /* i/o: NL exc for IC-BWE */ + Word16 *nlExc16k_e, /* i/o: exp of nlExc16k */ + Word16 *mixExc16k, /* i/o: exc spreading for IC-BWE */ + Word16 *mixExc16k_e, /* i/o: exp of mixExc16k_fx */ + const Word32 extl_brate, /* i : extension layer bitarte */ + const Word16 MSFlag, /* i : Multi Source flag */ + Word16 EnvSHBres_4k[], /* i/o: TD envelope of the SHB residual signal */ + Word16 Q_EnvSHBres_4k, Word32 *prev_pow_exc16kWhtnd, /* i/o: power of the LB excitation signal in the previous frame */ Word16 *prev_mix_factor, /* i/o: mixing factor in the previous frame */ Word16 *Env_error, /* o : error in SHB residual envelope modelling*/ @@ -3596,6 +3665,16 @@ Word16 ITF_Detect_fx( Word32 const pSpectrum[], Word16 *curr_order, Word16 Q ); +Word16 ITF_Detect_ivas_fx( Word32 const pSpectrum[], + const Word16 startLine, + const Word16 stopLine, + const Word16 maxOrder, + Word16 *A, + Word16 *Q_A, + Word16 *predictionGain, + Word16 *curr_order, + Word16 Q ); + void ITF_Apply_fx( Word32 spectrum[], Word16 startLine, Word16 stopLine, @@ -4731,17 +4810,20 @@ 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 */ + 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 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 */ @@ -5718,16 +5800,14 @@ void tcx_ltp_post32( // gs_inact_switching_fx.c void Inac_swtch_ematch_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 */ - const Word16 L_frame, /* i : Frame lenght */ - const Word32 core_brate, /* i : Core bit rate */ - const Word16 Q_exc /* i : i and output format of exc2 */ - , - const Word16 bfi /* i : frame lost indicator */ - , + 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 L_frame, /* i : Frame lenght */ + const Word32 core_brate, /* i : Core bit rate */ + const Word16 Q_exc, /* i : i and output format of exc2 */ + const Word16 bfi, /* i : frame lost indicator */ const short last_core, /* i : Last core used */ const short last_codec_mode /* i : Last codec mode */ ); @@ -5737,15 +5817,17 @@ void Inac_switch_ematch_ivas_fx( 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 L_frame, /* i : Frame lenght */ - const Word32 core_brate, /* i : Core bit rate */ - 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 */ - , +#ifdef NONBE_FIX_GSC_BSTR + 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 */ ); @@ -6582,7 +6664,7 @@ void nb_post_filt_fx( const Word16 tmp_noise, /* i : noise energy Q0 */ Word16 *Synth, /* i : 12k8 synthesis Qsyn */ const Word16 *Aq, /* i : LP filter coefficient Q12 */ - const Word16 *Pitch_buf, /* i : Fractionnal subframe pitch buffer Q6 */ + const Word16 *Pitch_buf, /* i : Fractionnal subframe pitch buffer Q0 */ const Word16 coder_type, /* i : coder_type */ const Word16 BER_detect, /* i : BER detect flag */ const Word16 disable_hpf /* i : flag to diabled HPF */ @@ -9999,7 +10081,7 @@ void Scale_sig32( const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ ); -void Copy_Scale_sig_16_32( +void Copy_Scale_sig_16_32_DEPREC( const Word16 x[], /* i : signal to scale i Qx */ Word32 y[], /* o : scaled signal output Qx */ const Word16 lg, /* i : size of x[] Q0 */ @@ -10264,6 +10346,13 @@ Word32 root_a_over_b_fx( Word16 Q_b, Word16 *exp_out ); +Word32 root_a_over_b_ivas_fx( + Word32 a, /* Q(Q_a) */ + Word16 Q_a, + Word32 b, /* Q(Q_b) */ + Word16 Q_b, + Word16 *exp_out ); + void fir_fx( const Word16 x[], /* i : input vector Qx*/ const Word16 h[], /* i : impulse response of the FIR filter Q12*/ Word16 y[], /* o : output vector (result of filtering) Qx*/ @@ -10824,8 +10913,8 @@ void ProcessStereoIGF_fx( Word32 *inv_spectrum_fx[CPE_CHANNELS][NB_DIV], /* i : 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 */ -); + const Word32 element_brate, /* i : element bitrate */ + const Word16 mct_on ); /*igf_enc.c*/ void IGFEncApplyStereo_fx( STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: MDCT stereo encoder structure */ @@ -10838,8 +10927,8 @@ void IGFEncApplyStereo_fx( Word32 *inv_spectrum_fx[CPE_CHANNELS][NB_DIV], /* i : 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 */ -); + const Word32 element_brate, /* i : element bitrate */ + const Word16 mct_on ); void IGFSaveSpectrumForITF_ivas_fx( IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i/o: instance handle of IGF Encoder */ @@ -10854,7 +10943,7 @@ Word16 IGFEncWriteBitstream_ivas_fx( const Word16 isIndepFlag /* i : if 1 frame is independent, 0 = frame is coded with data from previous frame */ ); /*igf_scf_enc.c*/ -Word16 IGFSCFEncoderEncode( +Word16 IGFSCFEncoderEncode_ivas_fx( IGFSCFENC_INSTANCE_HANDLE hPublicData, /* i/o: handle to public data or NULL in case there was no instance created */ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word16 bitCount, /* i : offset to the first bit in bitbuffer which should be readed by iisArithDecoderDecode function */ @@ -10937,17 +11026,20 @@ 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 */ + 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 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 */ @@ -11014,7 +11106,10 @@ void calculate_hangover_attenuation_gain_ivas_fx( void init_coder_ace_plus_ivas_fx( Encoder_State *st, /* i : Encoder state */ const Word32 last_total_brate, /* i : last total bitrate */ - const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) */ +#ifdef FIX_920_IGF_INIT_ERROR + const Word32 igf_brate, /* i : IGF configuration bitrate */ +#endif + const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) */ ); void core_coder_reconfig_ivas_fx( diff --git a/lib_com/pvq_com_fx.c b/lib_com/pvq_com_fx.c index 36fa528b863fe573823b24915d60a7e4ca6e5fb3..ed914f2a159085a0359e1951557f5ff2ffb59e4b 100644 --- a/lib_com/pvq_com_fx.c +++ b/lib_com/pvq_com_fx.c @@ -457,11 +457,7 @@ void NearOppSplitAdjustment_fx( } *qnear = qboth; /* Q3 */ move16(); -#ifdef BASOP_NOGLOB QIb = extract_h( L_shl_o( L_QIb, 16, &Overflow ) ); /* may saturate Q0*/ -#else - QIb = extract_h( L_shl( L_QIb, 16 ) ); /* may saturate */ -#endif if ( LE_16( QIb, qboth ) ) { *qnear = QIb; /* Q0 */ @@ -557,11 +553,7 @@ void fine_gain_quant_ivas_fx( 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 */ -#ifdef BASOP_NOGLOB - gain_db = round_fx_sat( L_shl_o( L_tmp, 17, &Overflow ) ); /* Q14 */ -#else /* BASOP_NOGLOB */ - gain_db = round_fx( L_shl( L_tmp, 17 ) ); -#endif + 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 ); @@ -628,11 +620,7 @@ void fine_gain_quant_fx( 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 */ -#ifdef BASOP_NOGLOB gain_db = round_fx_sat( L_shl_o( L_tmp, 17, &Overflow ) ); -#else /* BASOP_NOGLOB */ - gain_db = round_fx( L_shl( L_tmp, 17 ) ); -#endif 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 ); diff --git a/lib_com/re8_util_fx.c b/lib_com/re8_util_fx.c index 746b7152ba401e6ac47dc6c51966b9cd9dbbc99a..de70279ebf63772e0a2bd841a2c5633ea1e94dca 100644 --- a/lib_com/re8_util_fx.c +++ b/lib_com/re8_util_fx.c @@ -275,11 +275,7 @@ static Word16 re8_identify_absolute_leader_fx( /* o : integer i { Ls = L_mac( Ls, y[i], y[i] ); /* Q1 */ } -#ifdef BASOP_NOGLOB s = extract_h( L_shl_sat( Ls, 16 - ( 3 + 1 ) ) ); /* s can saturate here */ -#else - s = extract_h( L_shl( Ls, 16 - ( 3 + 1 ) ) ); /* s can saturate here */ -#endif /*-----------------------------------------------------------------------* * compute the index 0 <= ka <= NB_LEADER+1 which identifies an absolute leader of Q0, Q2, Q3 or Q4 * diff --git a/lib_com/residu_fx.c b/lib_com/residu_fx.c index 156e81eada140b1322e377afc47e24e24b15efd8..665dbfae622164864d8dd41dce80d9254ed1c263 100644 --- a/lib_com/residu_fx.c +++ b/lib_com/residu_fx.c @@ -73,62 +73,32 @@ void Residu3_lc_fx( { q = add( q, shift ); } -#ifdef BASOP_NOGLOB *y++ = shl_o( x[0], shift, &Overflow ); -#else - *y++ = shl( x[0], shift ); -#endif move16(); FOR( i = 1; i < m; i++ ) { -#ifdef BASOP_NOGLOB s = L_mult_o( x[i], a[0], &Overflow ); -#else - s = L_mult( x[i], a[0] ); -#endif /* Stop at i to Avoid Mults with Zeros */ FOR( j = 1; j <= i; j++ ) { -#ifdef BASOP_NOGLOB s = L_mac_o( s, x[i - j], a[j], &Overflow ); -#else - s = L_mac( s, x[i - j], a[j] ); -#endif } -#ifdef BASOP_NOGLOB s = L_shl_o( s, q, &Overflow ); *y++ = round_fx_o( s, &Overflow ); -#else - s = L_shl( s, q ); - *y++ = round_fx( s ); -#endif } FOR( ; i < lg; i++ ) { -#ifdef BASOP_NOGLOB s = L_mult_o( x[i], a[0], &Overflow ); -#else - s = L_mult( x[i], a[0] ); -#endif FOR( j = 1; j <= m; j++ ) { -#ifdef BASOP_NOGLOB s = L_mac_o( s, x[i - j], a[j], &Overflow ); -#else - s = L_mac( s, x[i - j], a[j] ); -#endif } -#ifdef BASOP_NOGLOB s = L_shl_o( s, q, &Overflow ); *y++ = round_fx_o( s, &Overflow ); -#else - s = L_shl( s, q ); - *y++ = round_fx( s ); -#endif } } @@ -161,11 +131,7 @@ void Residu3_10_fx( s64 = W_mac_16_16( s64, x[i - j], a[j] ); } s = W_shl_sat_l( s64, q ); -#ifdef BASOP_NOGLOB y[i] = round_fx_sat( s ); -#else - y[i] = round_fx( s ); -#endif } } /*--------------------------------------------------------------------* @@ -205,12 +171,8 @@ void Residu3_fx( } s64 = W_mac_16_16( s64, x[i - 16], a[16] ); s32 = W_shl_sat_l( s64, q ); -#ifdef BASOP_NOGLOB y[i] = round_fx_o( s32, &Overflow ); move16(); -#else /* BASOP_NOGLOB */ - y[i] = round_fx( s32 ); -#endif } } /*==========================================================================*/ diff --git a/lib_com/rom_com.c b/lib_com/rom_com.c index 612e30bdf6d5a833984683cc135d7797466c2f83..5e61db76e5a71e7db13dcfc62a05de4ac0bf28cd 100644 --- a/lib_com/rom_com.c +++ b/lib_com/rom_com.c @@ -14271,6 +14271,25 @@ const Word16 win_lpc_hb_wb_fx[(L_LOOK_12k8 + L_SUBFR + L_FRAME) * 5 / 32] = 32611, 32698, 32751 }; +const Word16 win_lpc_hb_wb_ivas_fx[(L_LOOK_12k8 + L_SUBFR + L_FRAME) * 5 / 32] = +{//Q15 + 6, 51, 140, 274, + 453, 675, 940, 1247, + 1596, 1985, 2414, 2882, + 3386, 3926, 4499, 5106, + 5743, 6410, 7104, 7823, + 8566, 9331, 10114, 10915, + 11731, 12559, 13398, 14245, + 15099, 15955, 16813, 17669, + 18523, 19370, 20209, 21037, + 21853, 22654, 23437, 24202, + 24945, 25664, 26358, 27025, + 27662, 28269, 28842, 29382, + 29886, 30354, 30783, 31172, + 31521, 31828, 32093, 32315, + 32494, 32628, 32717, 32762 +}; + const Word16 ola_win_shb_switch_fold_fx[L_SUBFR16k] = {//Q15 diff --git a/lib_com/rom_com.h b/lib_com/rom_com.h index 431c6b7047870558f861250a47cbd42b32b68e73..19447609cb696e3a1b4c49bed8f3abcd7e2efd32 100644 --- a/lib_com/rom_com.h +++ b/lib_com/rom_com.h @@ -612,6 +612,7 @@ extern const Word16 cos_fb_exc_fx[32]; // Q15 extern const Word16 win_lpc_shb_fx[]; // Q15 /* Window for calculating SHB LPC coeffs */ extern const Word16 win_lpc_hb_wb_fx[]; // Q15 +extern const Word16 win_lpc_hb_wb_ivas_fx[]; // Q15 extern const Word16 ola_win_shb_switch_fold_fx[]; // Q15 extern const Word16 win_flatten_fx[]; // Q15 extern const Word16 win_flatten_4k_fx[]; // Q15 diff --git a/lib_com/stab_est_fx.c b/lib_com/stab_est_fx.c index 73d58af44d8490e334a6e8f734a20a43392a6684..15cd254dfb9fbb09fc2dcacf3828682921c94baf 100644 --- a/lib_com/stab_est_fx.c +++ b/lib_com/stab_est_fx.c @@ -73,11 +73,7 @@ Word16 stab_est_fx( { /*fcorr += ftmp_c*ftmp_c;*/ tmp16 = sub( lt_diff_etot[i], mean_diff ); -#ifdef BASOP_NOGLOB L_tmp = L_mac0_sat( L_tmp, tmp16, tmp16 ); -#else - L_tmp = L_mac0( L_tmp, tmp16, tmp16 ); -#endif } /*------------------------------------------------------------------------* * Update @@ -96,22 +92,14 @@ Word16 stab_est_fx( exp1 = norm_l( L_tmp ); L_tmp = L_shl( L_tmp, exp1 ); -#ifdef BASOP_NOGLOB tmp16 = round_fx_sat( L_tmp ); -#else - tmp16 = round_fx( L_tmp ); -#endif exp2 = sub( 31, exp1 ); L_tmp = Isqrt_lc( L_tmp, &exp2 ); L_tmp = Mpy_32_16_1( L_tmp, tmp16 ); /* we now have sqrt(L_corr) Q24 (8+16)*/ exp2 = sub( 31 - 15, sub( exp1, exp2 ) ); /* for Q8 (because of -8^2 from Etot)*/ - L_tmp = L_shl( L_tmp, exp2 ); /* Q8 + Q16*/ -#ifdef BASOP_NOGLOB + L_tmp = L_shl( L_tmp, exp2 ); /* Q8 + Q16*/ dev = extract_h( L_shl_sat( L_tmp, 3 ) ); /* Q(24+3-16) -> Q11 */ -#else /* BASOP_NOGLOB */ - dev = extract_h( L_shl( L_tmp, 3 ) ); /* Q(24+3-16) -> Q11 */ -#endif /*------------------------------------------------------------------------* * State machine to decide level of inter-harmonic noise reduction and diff --git a/lib_com/stat_com.h b/lib_com/stat_com.h index 78d358be577431cdc976dc0c1702b2317a471d24..45a16dc1a5599c0458bbfca530a9fe68926a6f77 100644 --- a/lib_com/stat_com.h +++ b/lib_com/stat_com.h @@ -411,7 +411,7 @@ typedef struct Word16 psize_norm[NPART]; /* Partition sizes, fractional variable Q15-psize_norm_exp*/ Word16 psize_inv[NPART]; /* Inverse of partition sizes Q15*/ // Word16 FFTscalingFactor; /* Squared ratio between core signal analysis FFT and noise estimator FFT */ - Word16 scalingFactor; // Q15 + Word16 scalingFactor; // exp = -15 Word16 invScalingFactor; // Q15 Word16 nCLDFBpart; /* Number of CLDFB spectral partitions */ Word16 CLDFBpart[NPARTCLDFB]; /* CLDFB Partition upper boundaries (band indices starting from 0 above the core coder bands) */ diff --git a/lib_com/stat_noise_uv_mod_fx.c b/lib_com/stat_noise_uv_mod_fx.c index e4771a1834bc6c5bb5d3bdf397e8ad9abc8ff4f3..67ca21cd29c3dd2ffae186785dfcd32794b3201f 100644 --- a/lib_com/stat_noise_uv_mod_fx.c +++ b/lib_com/stat_noise_uv_mod_fx.c @@ -109,11 +109,7 @@ void stat_noise_uv_mod_fx( move16(); tmp_res = div_l( L_tmp_res, tmp_den ); move16(); -#ifdef BASOP_NOGLOB min_alpha = add_o( tmp_res, 16384, &Overflow ); -#else /* BASOP_NOGLOB */ - min_alpha = add( tmp_res, 16384 ); -#endif /* BASOP_NOGLOB */ move16(); /**st_min_alpha = sub(*st_min_alpha, 1638); move16();*/ @@ -164,12 +160,8 @@ void stat_noise_uv_mod_fx( { FOR( i_subfr = 0; i_subfr < L_FRAME; i_subfr += L_SUBFR ) { - exctilt = calc_tilt_fx( &Exc2_local[i_subfr], En_shift, L_SUBFR ); /*Q15 */ -#ifdef BASOP_NOGLOB + exctilt = calc_tilt_fx( &Exc2_local[i_subfr], En_shift, L_SUBFR ); /*Q15 */ exctilt = mult( shl_o( sub( TILT_COMP_LIM_FX, min_alpha ), 2, &Overflow ), exctilt ); /*Q15 */ -#else /* BASOP_NOGLOB */ - exctilt = mult( shl( sub( TILT_COMP_LIM_FX, min_alpha ), 2 ), exctilt ); /*Q15 */ -#endif /* BASOP_NOGLOB */ PREEMPH_FX( &Exc2_local[i_subfr], exctilt, L_SUBFR, exc_pe ); } @@ -194,11 +186,7 @@ void stat_noise_uv_mod_fx( tmp_shift = norm_s( tmp_den ); tmp_den = shl( tmp_den, tmp_shift ); tmp_res = div_s( tmp_nom, tmp_den ); -#ifdef BASOP_NOGLOB tmp_res = shl_o( tmp_res, tmp_shift, &Overflow ); -#else /* BASOP_NOGLOB */ - tmp_res = shl( tmp_res, tmp_shift ); -#endif alpha = add( 32767, mult( tmp_res, sub( min_alpha, 32767 ) ) ); *act_count = 0; @@ -213,11 +201,7 @@ void stat_noise_uv_mod_fx( FOR( i = 1; i < L_FRAME; i++ ) { Tmp = shr( Exc2_local[i], En_shift ); -#ifdef BASOP_NOGLOB vare = L_mac_sat( vare, Tmp, Tmp ); /* positive accumulation only */ -#else - vare = L_mac( vare, Tmp, Tmp ); /* positive accumulation only */ -#endif } /* obtain Ge in Q_local with safety saturation */ @@ -261,20 +245,12 @@ void stat_noise_uv_mod_fx( /* L_Ge might be 0 in unvoiced WB */ L_Ge = L_max( L_Ge, 1 ); tmp_shift = norm_l( L_Ge ); - tmp_den = extract_h( L_shl( L_Ge, tmp_shift ) ); /* Q_local+Q_ge+tmp_shift-16 */ - tmp_res = div_s( 1 << 14, tmp_den ); /* 15+14-Q_local-tmp_shift-Q_ge+16 */ - L_tmp_res = Mult_32_16( *ge_sm, tmp_res ); /* Q_stat_noise_ge+45-Q_local-Q_ge-tmp_shift-15 */ - L_tmp_res = Mult_32_16( L_tmp_res, sub( 32767, beta ) ); /*30-Q_local-tmp_shift+15-15 */ -#ifdef BASOP_NOGLOB + tmp_den = extract_h( L_shl( L_Ge, tmp_shift ) ); /* Q_local+Q_ge+tmp_shift-16 */ + tmp_res = div_s( 1 << 14, tmp_den ); /* 15+14-Q_local-tmp_shift-Q_ge+16 */ + L_tmp_res = Mult_32_16( *ge_sm, tmp_res ); /* Q_stat_noise_ge+45-Q_local-Q_ge-tmp_shift-15 */ + L_tmp_res = Mult_32_16( L_tmp_res, sub( 32767, beta ) ); /*30-Q_local-tmp_shift+15-15 */ L_tmp_res = L_add_sat( L_shl_sat( L_tmp_res, sub( add( Q_local, tmp_shift ), 15 ) ), beta ); /* Q15 */ -#else - L_tmp_res = L_add( L_shl( L_tmp_res, sub( add( Q_local, tmp_shift ), 15 ) ), beta ); /* Q15 */ -#endif -#ifdef BASOP_NOGLOB - tmp_res = extract_h( L_shl_o( L_tmp_res, 15, &Overflow ) ); /* 15+15-16=14 */ -#else - tmp_res = extract_h( L_shl( L_tmp_res, 15 ) ); /* 15+15-16=14 */ -#endif + tmp_res = extract_h( L_shl_o( L_tmp_res, 15, &Overflow ) ); /* 15+15-16=14 */ Noimix_fract = extract_l( Mult_32_16( L_tmp_res, Noimix_fract ) ); /*15+15-15 */ @@ -292,15 +268,11 @@ void stat_noise_uv_mod_fx( randval = mult_r( 28378, randval ); /* Q downscaled by 2 bits ends up in Q14 */ /*sqrt(12.0f) in Q13*/ randval = extract_l( L_shl( Mult_32_16( L_Ge, randval ), 1 - *Q_stat_noise_ge ) ); /*Q_local+Q_ge+14-15+1-Q_ge=Q_local */ - L_tmp = L_mult( Exc2_local[i], alpha ); /* Q_local + 16 */ - L_tmp = L_mac( L_tmp, randval, alpha_m1 ); /* Q_local + 16 */ - L_tmp3 = Mult_32_16( L_tmp, Noimix_fract ); /* Q_local+16+15-15 */ -#ifdef BASOP_NOGLOB + L_tmp = L_mult( Exc2_local[i], alpha ); /* Q_local + 16 */ + L_tmp = L_mac( L_tmp, randval, alpha_m1 ); /* Q_local + 16 */ + L_tmp3 = Mult_32_16( L_tmp, Noimix_fract ); /* Q_local+16+15-15 */ L_tmp = L_add_sat( L_tmp3, L_shl_sat( Mult_32_16( L_tmp, tmp_res ), 1 ) ); /* Q_local+16+14-15+1 */ -#else - L_tmp = L_add( L_tmp3, L_shl( Mult_32_16( L_tmp, tmp_res ), 1 ) ); /* Q_local+16+14-15+1 */ -#endif - Exc2_local[i] = extract_h( L_tmp ); /*Q_local */ + Exc2_local[i] = extract_h( L_tmp ); /*Q_local */ move16(); } *Q_stat_noise = Q_local; /* update for next call, routine can only be called once every frame */ @@ -443,11 +415,7 @@ void stat_noise_uv_mod_ivas_fx( L_tmp_res = L_shl( L_tmp_res, sub( tmp_shift, 1 ) ); tmp_den = shl( tmp_den, tmp_shift ); tmp_res = div_l( L_tmp_res, tmp_den ); -#ifdef BASOP_NOGLOB min_alpha = add_o( tmp_res, 16384, &Overflow ); -#else /* BASOP_NOGLOB */ - min_alpha = add( tmp_res, 16384 ); -#endif /* BASOP_NOGLOB */ /**st_min_alpha = sub(*st_min_alpha, 1638); move16();*/ min_alpha = s_max( min_alpha, sub( *st_min_alpha, 1638 ) ); @@ -497,12 +465,8 @@ void stat_noise_uv_mod_ivas_fx( { FOR( i_subfr = 0; i_subfr < L_FRAME; i_subfr += L_SUBFR ) { - exctilt = calc_tilt_fx( &Exc2_local[i_subfr], En_shift, L_SUBFR ); /*Q15 */ -#ifdef BASOP_NOGLOB + exctilt = calc_tilt_fx( &Exc2_local[i_subfr], En_shift, L_SUBFR ); /*Q15 */ exctilt = mult( shl_o( sub( TILT_COMP_LIM_FX, min_alpha ), 2, &Overflow ), exctilt ); /*Q15 */ -#else /* BASOP_NOGLOB */ - exctilt = mult( shl( sub( TILT_COMP_LIM_FX, min_alpha ), 2 ), exctilt ); /*Q15 */ -#endif /* BASOP_NOGLOB */ PREEMPH_FX( &Exc2_local[i_subfr], exctilt, L_SUBFR, exc_pe ); } @@ -527,11 +491,7 @@ void stat_noise_uv_mod_ivas_fx( tmp_shift = norm_s( tmp_den ); tmp_den = shl( tmp_den, tmp_shift ); tmp_res = div_s( tmp_nom, tmp_den ); -#ifdef BASOP_NOGLOB tmp_res = shl_o( tmp_res, tmp_shift, &Overflow ); -#else /* BASOP_NOGLOB */ - tmp_res = shl( tmp_res, tmp_shift ); -#endif alpha = add( 32767, mult( tmp_res, sub( min_alpha, 32767 ) ) ); *act_count = 0; @@ -546,11 +506,7 @@ void stat_noise_uv_mod_ivas_fx( FOR( i = 1; i < L_FRAME; i++ ) { Tmp = shr( Exc2_local[i], En_shift ); -#ifdef BASOP_NOGLOB vare = L_mac_sat( vare, Tmp, Tmp ); /* positive accumulation only */ -#else - vare = L_mac( vare, Tmp, Tmp ); /* positive accumulation only */ -#endif } /* obtain Ge in Q_local with safety saturation */ @@ -594,20 +550,12 @@ void stat_noise_uv_mod_ivas_fx( /* L_Ge might be 0 in unvoiced WB */ L_Ge = L_max( L_Ge, 1 ); tmp_shift = norm_l( L_Ge ); - tmp_den = extract_h( L_shl( L_Ge, tmp_shift ) ); /* Q_local+Q_ge+tmp_shift-16 */ - tmp_res = div_s( 1 << 14, tmp_den ); /* 15+14-Q_local-tmp_shift-Q_ge+16 */ - L_tmp_res = Mult_32_16( *ge_sm, tmp_res ); /* Q_stat_noise_ge+45-Q_local-Q_ge-tmp_shift-15 */ - L_tmp_res = Mult_32_16( L_tmp_res, sub( 32767, beta ) ); /*30-Q_local-tmp_shift+15-15 */ -#ifdef BASOP_NOGLOB + tmp_den = extract_h( L_shl( L_Ge, tmp_shift ) ); /* Q_local+Q_ge+tmp_shift-16 */ + tmp_res = div_s( 1 << 14, tmp_den ); /* 15+14-Q_local-tmp_shift-Q_ge+16 */ + L_tmp_res = Mult_32_16( *ge_sm, tmp_res ); /* Q_stat_noise_ge+45-Q_local-Q_ge-tmp_shift-15 */ + L_tmp_res = Mult_32_16( L_tmp_res, sub( 32767, beta ) ); /*30-Q_local-tmp_shift+15-15 */ L_tmp_res = L_add_sat( L_shl_sat( L_tmp_res, sub( add( Q_local, tmp_shift ), 15 ) ), beta ); /* Q15 */ -#else - L_tmp_res = L_add( L_shl( L_tmp_res, sub( add( Q_local, tmp_shift ), 15 ) ), beta ); /* Q15 */ -#endif -#ifdef BASOP_NOGLOB - tmp_res = extract_h( L_shl_o( L_tmp_res, 15, &Overflow ) ); /* 15+15-16=14 */ -#else - tmp_res = extract_h( L_shl( L_tmp_res, 15 ) ); /* 15+15-16=14 */ -#endif + tmp_res = extract_h( L_shl_o( L_tmp_res, 15, &Overflow ) ); /* 15+15-16=14 */ Noimix_fract = extract_l( Mult_32_16( L_tmp_res, Noimix_fract ) ); /*15+15-15 */ @@ -625,15 +573,11 @@ void stat_noise_uv_mod_ivas_fx( randval = mult_r( 28378, randval ); /* Q downscaled by 2 bits ends up in Q14 */ /*sqrt(12.0f) in Q13*/ randval = extract_l( L_shl( Mult_32_16( L_Ge, randval ), sub( 1, *Q_stat_noise_ge ) ) ); /*Q_local+Q_ge+14-15+1-Q_ge=Q_local */ - L_tmp = L_mult( Exc2_local[i], alpha ); /* Q_local + 16 */ - L_tmp = L_mac( L_tmp, randval, alpha_m1 ); /* Q_local + 16 */ - L_tmp3 = Mult_32_16( L_tmp, Noimix_fract ); /* Q_local+16+15-15 */ -#ifdef BASOP_NOGLOB + L_tmp = L_mult( Exc2_local[i], alpha ); /* Q_local + 16 */ + L_tmp = L_mac( L_tmp, randval, alpha_m1 ); /* Q_local + 16 */ + L_tmp3 = Mult_32_16( L_tmp, Noimix_fract ); /* Q_local+16+15-15 */ L_tmp = L_add_sat( L_tmp3, L_shl_sat( Mult_32_16( L_tmp, tmp_res ), 1 ) ); /* Q_local+16+14-15+1 */ -#else - L_tmp = L_add( L_tmp3, L_shl( Mult_32_16( L_tmp, tmp_res ), 1 ) ); /* Q_local+16+14-15+1 */ -#endif - Exc2_local[i] = extract_h( L_tmp ); /*Q_local */ + Exc2_local[i] = extract_h( L_tmp ); /*Q_local */ move16(); } *Q_stat_noise = Q_local; /* update for next call, routine can only be called once every frame */ @@ -717,17 +661,9 @@ static Word16 calc_tilt_fx( /* o : Excitation tilt Q15*/ { /* r0 = L_mac(r0,x[i],x[i]) */ /* r1 = L_mac(r1,x[i],x[i+1]) -> correlation loop can be optimized */ -#ifdef BASOP_NOGLOB r0 = L_mac_sat( r0, xi, xi ); -#else - r0 = L_mac( r0, xi, xi ); -#endif xi_p1 = shr( x[i + 1], Q_shift ); -#ifdef BASOP_NOGLOB r1 = L_mac_sat( r1, xi, xi_p1 ); -#else - r1 = L_mac( r1, xi, xi_p1 ); -#endif xi = xi_p1; move16(); } @@ -749,11 +685,7 @@ static Word16 calc_tilt_fx( /* o : Excitation tilt Q15*/ r1 = L_abs( r1 ); L_tmp_res = Div_32( r1, extract_h( r0 ), extract_l( r0 ) ); -#ifdef BASOP_NOGLOB L_tmp_res = L_shl_sat( L_tmp_res, tmp_shift ); /*Q31 */ -#else - L_tmp_res = L_shl( L_tmp_res, tmp_shift ); /*Q31 */ -#endif if ( tmp_sign != 0 ) { L_tmp_res = L_negate( L_tmp_res ); /*Q31 */ diff --git a/lib_com/swb_bwe_com_fx.c b/lib_com/swb_bwe_com_fx.c index 873a7093eb5854f60af59e8863be738da3f33328..09f72b2300a32137f20e63d8063adfeb0b05c621 100644 --- a/lib_com/swb_bwe_com_fx.c +++ b/lib_com/swb_bwe_com_fx.c @@ -99,31 +99,19 @@ Word16 WB_BWE_gain_pred_fx( enerL = L_deposit_l( 0 ); FOR( n_freq = 128; n_freq < 192; n_freq++ ) { -#ifdef BASOP_NOGLOB enerL = L_mac0_sat( enerL, core_dec_freq[n_freq], core_dec_freq[n_freq] ); /*2(Q_syn) */ -#else - enerL = L_mac0( enerL, core_dec_freq[n_freq], core_dec_freq[n_freq] ); /*2(Q_syn) */ -#endif } L_WB_fenv0 = L_deposit_l( 0 ); FOR( n_freq = 192; n_freq < 224; n_freq++ ) { -#ifdef BASOP_NOGLOB L_WB_fenv0 = L_mac0_sat( L_WB_fenv0, core_dec_freq[n_freq], core_dec_freq[n_freq] ); /*2*Q_syn */ -#else - L_WB_fenv0 = L_mac0( L_WB_fenv0, core_dec_freq[n_freq], core_dec_freq[n_freq] ); /*2*Q_syn */ -#endif } L_WB_fenv1 = L_deposit_l( 0 ); FOR( n_freq = 224; n_freq < 256; n_freq++ ) { -#ifdef BASOP_NOGLOB L_WB_fenv1 = L_mac0_sat( L_WB_fenv1, core_dec_freq[n_freq], core_dec_freq[n_freq] ); /*2*Q_syn */ -#else - L_WB_fenv1 = L_mac0( L_WB_fenv1, core_dec_freq[n_freq], core_dec_freq[n_freq] ); /*2*Q_syn */ -#endif } L_tmp = sum16_32_fx( voice_factors, 4 ); @@ -141,11 +129,7 @@ Word16 WB_BWE_gain_pred_fx( } test(); -#ifdef BASOP_NOGLOB IF( GT_32( L_WB_fenv0, L_shl_sat( L_WB_fenv1, 1 ) ) ) -#else - IF( GT_32( L_WB_fenv0, L_shl( L_WB_fenv1, 1 ) ) ) -#endif { exp = norm_l( L_WB_fenv0 ); tmp = extract_h( L_shl( L_WB_fenv0, exp ) ); @@ -156,11 +140,7 @@ Word16 WB_BWE_gain_pred_fx( alfa = s_max( tmp, 3277 /* 0.1 in Q15 */ ); /*Q15 */ L_WB_fenv0 = Mult_32_16( L_WB_fenv0, alfa ); /*2*Q_syn+15-15->2*Q_syn */ } -#ifdef BASOP_NOGLOB ELSE IF( GT_32( L_WB_fenv1, L_shl_sat( L_WB_fenv0, 1 ) ) && NE_16( coder_type, UNVOICED ) ) -#else - ELSE IF( GT_32( L_WB_fenv1, L_shl( L_WB_fenv0, 1 ) ) && NE_16( coder_type, UNVOICED ) ) -#endif { exp = norm_l( L_WB_fenv1 ); tmp = extract_h( L_shl( L_WB_fenv1, exp ) ); @@ -187,11 +167,7 @@ Word16 WB_BWE_gain_pred_fx( enerL = L_deposit_l( 1 ); } -#ifdef BASOP_NOGLOB L_tmp = L_add_sat( L_WB_fenv0, L_WB_fenv1 ); /* In 2*Q_syn */ -#else - L_tmp = L_add( L_WB_fenv0, L_WB_fenv1 ); /* In 2*Q_syn */ -#endif exp = norm_l( L_tmp ); tmp = extract_h( L_shl( L_tmp, exp ) ); /*exp = sub(exp, 30-(2*Q_syn+6)); //+6(/64) */ @@ -201,21 +177,13 @@ Word16 WB_BWE_gain_pred_fx( L_tmp = L_deposit_h( tmp ); L_tmp = Isqrt_lc( L_tmp, &exp ); -#ifdef BASOP_NOGLOB WB_fenv[0] = round_fx_sat( L_shl_sat( L_tmp, sub( exp, 12 ) ) ); /* Q3 */ move16(); -#else - WB_fenv[0] = round_fx( L_shl( L_tmp, sub( exp, 12 ) ) ); /* Q3 */ -#endif test(); test(); IF( NE_16( coder_type, AUDIO ) && NE_16( coder_type, UNVOICED ) && ener_var_flag == 0 ) { -#ifdef BASOP_NOGLOB WB_fenv[0] = add_sat( WB_fenv[0], mult_r_sat( WB_fenv[0], 16384 /* 0.5 in Q15 */ ) ); -#else - WB_fenv[0] = add( WB_fenv[0], mult_r( WB_fenv[0], 16384 /* 0.5 in Q15 */ ) ); -#endif move16(); } @@ -226,12 +194,8 @@ Word16 WB_BWE_gain_pred_fx( tmp = div_s( 16384, tmp ); L_tmp = L_deposit_h( tmp ); L_tmp = Isqrt_lc( L_tmp, &exp ); -#ifdef BASOP_NOGLOB enerL_16 = round_fx_sat( L_shl_sat( L_tmp, sub( exp, 15 ) ) ); /* Q0 */ -#else - enerL_16 = round_fx( L_shl( L_tmp, sub( exp, 15 ) ) ); /* Q0 */ -#endif - enerL_40 = mult_r( 6554 /* 0.2 in Q15 */, enerL_16 ); /*1/40 in Q18 ->Q3 */ + enerL_40 = mult_r( 6554 /* 0.2 in Q15 */, enerL_16 ); /*1/40 in Q18 ->Q3 */ test(); test(); @@ -245,13 +209,9 @@ Word16 WB_BWE_gain_pred_fx( IF( WB_fenv[0] != 0 ) { exp = norm_s( WB_fenv[0] ); - tmp = div_s( shl( 1, sub( 14, exp ) ), WB_fenv[0] ); /*Q(29-exp-3) */ - L_tmp = L_mult( enerL_40, tmp ); /*Q(30-exp) */ -#ifdef BASOP_NOGLOB + tmp = div_s( shl( 1, sub( 14, exp ) ), WB_fenv[0] ); /*Q(29-exp-3) */ + L_tmp = L_mult( enerL_40, tmp ); /*Q(30-exp) */ tmp = round_fx_sat( L_shl_sat( L_tmp, sub( exp, 2 ) ) ); /*Q12 */ -#else - tmp = round_fx( L_shl( L_tmp, sub( exp, 2 ) ) ); /*Q12 */ -#endif tmp = s_min( tmp, 16384 /*4 in Q12*/ ); L_tmp = L_shr( L_mult0( tmp, WB_fenv[0] ), 12 ); /*Q15 */ WB_fenv[0] = extract_l( L_tmp ); /*Q3 */ @@ -270,13 +230,9 @@ Word16 WB_BWE_gain_pred_fx( tmp1 = extract_l( L_shr( L_tmp, 13 ) ); exp = norm_s( pitch ); - tmp = div_s( shl( 1, sub( 14, exp ) ), pitch ); /*Q(29-exp-5) */ - L_tmp = L_mult0( tmp1, tmp ); /*29-exp-5->24-exp */ -#ifdef BASOP_NOGLOB + tmp = div_s( shl( 1, sub( 14, exp ) ), pitch ); /*Q(29-exp-5) */ + L_tmp = L_mult0( tmp1, tmp ); /*29-exp-5->24-exp */ tmp = round_fx_sat( L_shl_sat( L_tmp, add( exp, 6 ) ) ); /*14 */ -#else - tmp = round_fx( L_shl( L_tmp, add( exp, 6 ) ) ); /*14 */ -#endif tmp1 = s_max( tmp, 8192 /* 0.5 in Q14 */ ); alfa = s_min( 24576 /* 1.5 in Q14 */, tmp1 ); /*Q14 */ @@ -285,12 +241,8 @@ Word16 WB_BWE_gain_pred_fx( tmp = extract_l( L_tmp ); enerL = L_deposit_l( enerL_16 ); - enerL = L_shl( enerL, 6 ); /*Q6 */ -#ifdef BASOP_NOGLOB - tmp1 = i_mult_sat( 3, WB_fenv[0] ); /*Q3 */ -#else - tmp1 = i_mult( 3, WB_fenv[0] ); /*Q3 */ -#endif + enerL = L_shl( enerL, 6 ); /*Q6 */ + tmp1 = i_mult_sat( 3, WB_fenv[0] ); /*Q3 */ L_tmp = L_mult0( tmp1, WB_fenv[0] ); /*Q6 */ test(); @@ -303,13 +255,9 @@ Word16 WB_BWE_gain_pred_fx( enerL_64 = mult_r( 4096, enerL_16 ); /* 1/64 in Q18 ->Q3 */ exp = norm_s( WB_fenv[0] ); - tmp = div_s( shl( 1, sub( 14, exp ) ), WB_fenv[0] ); /*Q(29-exp-3) */ - L_tmp = L_mult( enerL_64, tmp ); /*Q(30-exp) */ -#ifdef BASOP_NOGLOB + tmp = div_s( shl( 1, sub( 14, exp ) ), WB_fenv[0] ); /*Q(29-exp-3) */ + L_tmp = L_mult( enerL_64, tmp ); /*Q(30-exp) */ tmp = round_fx_sat( L_shl_sat( L_tmp, sub( exp, 2 ) ) ); /*Q12 */ -#else - tmp = round_fx( L_shl( L_tmp, sub( exp, 2 ) ) ); /*Q12 */ -#endif tmp = s_min( tmp, 16384 /*4 in Q12*/ ); L_tmp = L_shr( L_mult0( tmp, WB_fenv[0] ), 12 ); /*Q3 */ WB_fenv[0] = extract_l( L_tmp ); /*Q3 */ @@ -343,12 +291,8 @@ Word16 WB_BWE_gain_pred_fx( tmp = s_min( s_max( tmp1, 16 /* 0.125 in Q7 */ ), 256 /* 1 in Q7 */ ); /*Q7 */ L_tmp = L_shr( L_mult0( WB_fenv[0], tmp ), 7 ); /*Q3 */ /*WB_fenv[0] = saturate(L_tmp); //Q3 */ -#ifdef BASOP_NOGLOB - WB_fenv[0] = round_fx_sat( L_shl_sat( L_tmp, 16 ) ); /*Q3 */ + WB_fenv[0] = round_fx_sat( L_shl_sat( L_tmp, 16 ) ); /*Q3 */ move16(); -#else - WB_fenv[0] = round_fx( L_shl( L_tmp, 16 ) ); /*Q3 */ -#endif } test(); IF( GT_32( last_core_brate, ACELP_8k00 ) && GT_16( WB_fenv[0], last_wb_bwe_ener ) ) @@ -454,11 +398,7 @@ static void calc_norm_envelop_lf_fx( tmp = add( lookback, n_freq ); FOR( n_lag = 0; n_lag < tmp; n_lag++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_add_sat( L_tmp, L_abs( SWB_signal[n_lag] ) ); -#else - L_tmp = L_add( L_tmp, L_abs( SWB_signal[n_lag] ) ); -#endif } envelope[env_index] = L_tmp; move32(); @@ -471,11 +411,7 @@ static void calc_norm_envelop_lf_fx( Word32 L_tmp = L_deposit_l( 1 ); FOR( n_lag = 0; n_lag < n_lag_now; n_lag++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_add_sat( L_tmp, L_abs( SWB_signal[n_freq - lookback + n_lag] ) ); -#else - L_tmp = L_add( L_tmp, L_abs( SWB_signal[n_freq - lookback + n_lag] ) ); -#endif } envelope[env_index] = L_tmp; @@ -649,30 +585,16 @@ Word32 calc_tilt_bwe_fx( /* o : Tilt in Q24 /* Divide Frame Length by 32 */ FOR( j = shr( N, 5 ); j > 0; j-- ) { -#ifdef BASOP_NOGLOB /* Critical Overflow and all those below*/ tmp1 = mult_ro( *ptr++, 8192 /*0.25 in Q15 */, &Overflow ); /* Divide by 4 */ -#else - tmp1 = mult_r( *ptr++, 8192 /*0.25 in Q15 */ ); /* Divide by 4 */ -#endif L_ener = L_mult0( tmp1, tmp1 ); /* With the shift by 4 and the L_mult0, no overflow possible for 32 samples */ FOR( i = 1; i < 32; i++ ) { -#ifdef BASOP_NOGLOB /* Critical Overflow */ tmp1 = mult_ro( *ptr++, 8192 /*0.25 in Q15 */, &Overflow ); /* Divide by 4 */ L_ener = L_mac0_o( L_ener, tmp1, tmp1, &Overflow ); -#else - tmp1 = mult_r( *ptr++, 8192 ); /* Divide by 4 */ - L_ener = L_mac0( L_ener, tmp1, tmp1 ); -#endif } -#ifdef BASOP_NOGLOB /* Critical Overflow */ L_ener = L_shr_o( L_ener, exp2, &Overflow ); L_temp = L_add_o( L_ener_tot, L_ener, &Overflow ); -#else - L_ener = L_shr( L_ener, exp2 ); - L_temp = L_add( L_ener_tot, L_ener ); -#endif IF( Overflow != 0 ) { L_ener_tot = L_shr( L_ener_tot, 1 ); @@ -682,27 +604,14 @@ Word32 calc_tilt_bwe_fx( /* o : Tilt in Q24 Overflow = 0; move16(); } -#ifdef BASOP_NOGLOB /* Critical Overflow */ L_ener_tot = L_add_o( L_ener_tot, L_ener, &Overflow ); -#else - L_ener_tot = L_add( L_ener_tot, L_ener ); -#endif } -#ifdef BASOP_NOGLOB L_ener = L_deposit_l( abs_s( sub_o( sp[1], sp[0], &Overflow ) ) ); -#else - L_ener = L_deposit_l( abs_s( sub( sp[1], sp[0] ) ) ); -#endif FOR( i = 2; i < N; i++ ) { /* Eq to (sp[i] - sp[i-1]) * (sp[i-1] - sp[i-2]) < 0 */ -#ifdef BASOP_NOGLOB tmp1 = sub_o( sp[i], sp[i - 1], &Overflow ); tmp2 = sub_o( sp[i - 1], sp[i - 2], &Overflow ); -#else - tmp1 = sub( sp[i], sp[i - 1] ); - tmp2 = sub( sp[i - 1], sp[i - 2] ); -#endif tmp2 = mult( tmp1, tmp2 ); tmp1 = abs_s( tmp1 ); /* to Get either 0 or -1 in 'tmp2' */ @@ -725,20 +634,12 @@ Word32 calc_tilt_bwe_fx( /* o : Tilt in Q24 /* *tilt_flt = (float)(r1/sqrt(r0)); */ exp2 = norm_l( L_ener ); -#ifdef BASOP_NOGLOB L_temp = Mult_32_16( L_temp, round_fx_sat( L_shl_sat( L_ener, exp2 ) ) ); -#else - L_temp = Mult_32_16( L_temp, round_fx( L_shl( L_ener, exp2 ) ) ); -#endif exp2 = sub( exp2, tmp1 ); exp2 = add( exp2, exp_sp ); /* Put in Q24 */ -#ifdef BASOP_NOGLOB L_temp = L_shr_sat( L_temp, sub( exp2, 24 ) ); -#else - L_temp = L_shr( L_temp, sub( exp2, 24 ) ); -#endif BASOP_SATURATE_WARNING_ON_EVS return L_temp; @@ -1397,20 +1298,12 @@ void SWB_BWE_decoding_fx( EnergyL = L_deposit_l( 0 ); FOR( n_freq = 224 + st_offset; n_freq < swb_bwe_trans_subband[0] + st_offset; n_freq++ ) { -#ifdef BASOP_NOGLOB fenvL = L_mac0_sat( fenvL, core_dec_freq[n_freq], core_dec_freq[n_freq] ); /*2*Q_syn */ -#else - fenvL = L_mac0( fenvL, core_dec_freq[n_freq], core_dec_freq[n_freq] ); /*2*Q_syn */ -#endif } FOR( n_freq = 16; n_freq < L_FRAME; n_freq++ ) { -#ifdef BASOP_NOGLOB EnergyL = L_mac0_sat( EnergyL, core_dec_freq[n_freq], core_dec_freq[n_freq] ); /*2*Q_syn */ -#else - EnergyL = L_mac0( EnergyL, core_dec_freq[n_freq], core_dec_freq[n_freq] ); /*2*Q_syn */ -#endif } fenvL_16 = 0; @@ -1425,17 +1318,9 @@ void SWB_BWE_decoding_fx( L_tmp = L_deposit_h( tmp ); L_tmp = Isqrt_lc( L_tmp, &exp ); -#ifdef BASOP_NOGLOB fenvL_16 = round_fx_sat( L_shl_sat( L_tmp, sub( exp, 12 ) ) ); /* Q3 */ -#else - fenvL_16 = round_fx( L_shl( L_tmp, sub( exp, 12 ) ) ); /* Q3 */ -#endif } -#ifdef BASOP_NOGLOB IF( GT_16( fenvL_16, shl_sat( SWB_fenv[0], 5 ) ) ) -#else - IF( GT_16( fenvL_16, shl( SWB_fenv[0], 5 ) ) ) -#endif { fenvL_16 = shl( SWB_fenv[0], 2 ); move16(); @@ -1453,11 +1338,7 @@ void SWB_BWE_decoding_fx( L_tmp = L_deposit_h( tmp ); L_tmp = Isqrt_lc( L_tmp, &exp ); -#ifdef BASOP_NOGLOB EnergyL_16 = round_fx_sat( L_shl_sat( L_tmp, sub( exp, 12 ) ) ); /* Q3 */ -#else - EnergyL_16 = round_fx( L_shl( L_tmp, sub( exp, 12 ) ) ); /* Q3 */ -#endif } calc_normal_length_fx( ACELP_CORE, core_dec_freq, mode, extl, &L_swb_norm, prev_L_swb_norm, Q_syn ); @@ -1509,13 +1390,8 @@ void SWB_BWE_decoding_fx( tmp = add( swb_bwe_trans_subband[n_band + 1], st_offset ); FOR( n_freq = add( swb_bwe_trans_subband[n_band], st_offset ); n_freq < tmp; n_freq++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_mult_sat( SWB_signal[n_freq], SWB_signal[n_freq] ); /*Q31 */ energy = L_add_sat( energy, L_shr( L_tmp, 6 ) ); /*Q25 */ -#else - L_tmp = L_mult( SWB_signal[n_freq], SWB_signal[n_freq] ); /*Q31 */ - energy = L_add( energy, L_shr( L_tmp, 6 ) ); /*Q25 */ -#endif } IF( energy == 0 ) @@ -1581,11 +1457,7 @@ void SWB_BWE_decoding_fx( tmp = div_s( shl( 1, sub( 14, exp ) ), SWB_FENV ); /*Q(29-exp) */ L_tmp = Mult_32_16( L_energy, tmp ); /*Q(1+29-exp+1)->Q(15-exp) */ -#ifdef BASOP_NOGLOB Energy_16 = round_fx_sat( L_shl_sat( L_tmp, add( exp, 4 ) ) ); /* Q3 */ -#else - Energy_16 = round_fx( L_shl( L_tmp, add( exp, 4 ) ) ); /*Q3 */ -#endif test(); IF( NE_16( last_extl, SWB_BWE ) && NE_16( last_extl, FB_BWE ) ) @@ -1659,13 +1531,8 @@ void SWB_BWE_decoding_fx( Copy( &core_dec_freq[112], &SWB_signal[368 + st_offset], 128 ); Copy( &core_dec_freq[176], &SWB_signal[496 + st_offset], 64 ); -#ifdef BASOP_NOGLOB tmp1 = add_sat( abs_s( SWB_signal[368 + st_offset] ), abs_s( SWB_signal[369 + st_offset] ) ); /*Q_syn */ tmp2 = add_sat( abs_s( SWB_signal[365 + st_offset] ), abs_s( SWB_signal[366 + st_offset] ) ); /*Q_syn */ -#else - tmp1 = add( abs_s( SWB_signal[368 + st_offset] ), abs_s( SWB_signal[369 + st_offset] ) ); /*Q_syn */ - tmp2 = add( abs_s( SWB_signal[365 + st_offset] ), abs_s( SWB_signal[366 + st_offset] ) ); /*Q_syn */ -#endif pit1 = &SWB_signal[368 + st_offset]; move16(); @@ -1679,32 +1546,20 @@ void SWB_BWE_decoding_fx( *pit1 = mult_r( *pit1, tmp3 ); move16(); /*Q_syn */ pit1++; -#ifdef BASOP_NOGLOB tmp3 = add_sat( tmp3, 3277 /* 0.1 in Q15*/ ); /*Q15 */ -#else - tmp3 = add( tmp3, 3277 /* 0.1 in Q15*/ ); /*Q15 */ -#endif } } ELSE IF( LT_16( tmp2, tmp1 ) ) { exp = norm_s( tmp1 ); - tmp = div_s( shl( 1, sub( 14, exp ) ), tmp1 ); /*Q(29-exp) */ -#ifdef BASOP_NOGLOB + tmp = div_s( shl( 1, sub( 14, exp ) ), tmp1 ); /*Q(29-exp) */ tmp3 = round_fx_sat( L_shl_sat( L_mult( tmp2, tmp ), add( exp, 2 ) ) ); /*Q15 */ -#else - tmp3 = round_fx( L_shl( L_mult( tmp2, tmp ), add( exp, 2 ) ) ); /*Q15 */ -#endif WHILE( LT_16( tmp3, 32767 ) ) { *pit1 = mult_r( *pit1, tmp3 ); move16(); /*Q_syn */ pit1++; -#ifdef BASOP_NOGLOB tmp3 = add_sat( tmp3, 3277 /* 0.1 in Q15*/ ); /*Q15 */ -#else - tmp3 = add( tmp3, 3277 ); /*Q15 */ -#endif } } @@ -1715,23 +1570,14 @@ void SWB_BWE_decoding_fx( /*20480 = 5 in Q12 */ FOR( tmp3 = 20480; tmp3 > 4096; tmp3 -= 2048 ) { -#ifdef BASOP_NOGLOB *pit1 = round_fx_sat( L_shl_sat( L_mult( *pit1, tmp3 ), 3 ) ); /*Q_syn */ -#else - *pit1 = round_fx( L_shl( L_mult( *pit1, tmp3 ), 3 ) ); /*Q_syn */ -#endif move16(); pit1--; } } -#ifdef BASOP_NOGLOB tmp1 = add_sat( abs_s( SWB_signal[496 + st_offset] ), abs_s( SWB_signal[497 + st_offset] ) ); /*Q_syn */ tmp2 = add_sat( add_sat( abs_s( SWB_signal[492 + st_offset] ), abs_s( SWB_signal[493 + st_offset] ) ), add_sat( abs_s( SWB_signal[494 + st_offset] ), abs_s( SWB_signal[495 + st_offset] ) ) ); -#else - tmp1 = add( abs_s( SWB_signal[496 + st_offset] ), abs_s( SWB_signal[497 + st_offset] ) ); /*Q_syn */ - tmp2 = add( add( abs_s( SWB_signal[492 + st_offset] ), abs_s( SWB_signal[493 + st_offset] ) ), add( abs_s( SWB_signal[494 + st_offset] ), abs_s( SWB_signal[495 + st_offset] ) ) ); -#endif pit1 = &SWB_signal[496 + st_offset]; test(); @@ -1744,32 +1590,20 @@ void SWB_BWE_decoding_fx( *pit1 = mult_r( *pit1, tmp3 ); move16(); /*Q_syn */ pit1++; -#ifdef BASOP_NOGLOB tmp3 = add_sat( tmp3, 3277 /* 0.1 in Q15 */ ); /*Q15 */ -#else - tmp3 = add( tmp3, 3277 /* 0.1 in Q15 */ ); /*Q15 */ -#endif } } ELSE IF( LT_16( tmp2, tmp1 ) ) { exp = norm_s( tmp1 ); - tmp = div_s( shl( 1, sub( 14, exp ) ), tmp1 ); /*Q(29-exp) */ -#ifdef BASOP_NOGLOB + tmp = div_s( shl( 1, sub( 14, exp ) ), tmp1 ); /*Q(29-exp) */ tmp3 = round_fx_sat( L_shl_sat( L_mult( tmp2, tmp ), add( exp, 2 ) ) ); /*Q15 */ -#else - tmp3 = round_fx( L_shl( L_mult( tmp2, tmp ), add( exp, 2 ) ) ); /*Q15 */ -#endif WHILE( LT_16( tmp3, 32767 ) ) { *pit1 = mult_r( *pit1, tmp3 ); move16(); /*Q_syn */ pit1++; -#ifdef BASOP_NOGLOB tmp3 = add_sat( tmp3, 3277 /* 0.1 in Q15 */ ); /*Q15 */ -#else - tmp3 = add( tmp3, 3277 /* 0.1 in Q15 */ ); /*Q15 */ -#endif } } pit1 = &SWB_signal[495 + st_offset]; @@ -1967,11 +1801,7 @@ FOR( n_band = 0; n_band < SWB_FENV; n_band += L ) } } -#ifdef BASOP_NOGLOB IF( GT_16( *prev_Energy, add_sat( Energy_16, shr( Energy_16, 2 ) ) ) && Energy_16 > 0 ) -#else -IF( GT_16( *prev_Energy, add( Energy_16, shr( Energy_16, 2 ) ) ) && Energy_16 > 0 ) -#endif { weight = shr( div_s( Energy_16, *prev_Energy ), 1 ); /*Q15 */ } @@ -2005,11 +1835,7 @@ tmp2 = add( add( swb_bwe_subband[0], 8 ), st_offset ); FOR( n_freq = add( swb_bwe_subband[0], st_offset ); n_freq < tmp2; n_freq++ ) { L_tmp1 = Mult_32_16( SWB_signal_32[n_freq], factor ); -#ifdef BASOP_NOGLOB SWB_signal_32[n_freq] = L_shl_sat( L_tmp1, tmp - 1 ); -#else - SWB_signal_32[n_freq] = L_shl( L_tmp1, tmp - 1 ); -#endif move32(); /*15+Qsyn */ factor = add( factor, factor1 ); /*Q3 */ } @@ -2040,17 +1866,9 @@ FOR( n_band = 0; n_band < 12; n_band++ ) FOR( ; n_freq < tmp2; n_freq++ ) { L_tmp1 = Mult_32_16( SWB_signal_32[n_freq], factor ); -#ifdef BASOP_NOGLOB SWB_signal_32[n_freq] = L_shl_sat( L_tmp1, tmp - 1 ); -#else - SWB_signal_32[n_freq] = L_shl( L_tmp1, tmp - 1 ); -#endif - move32(); /*15+Qsyn */ -#ifdef BASOP_NOGLOB + move32(); /*15+Qsyn */ factor = add_sat( factor, factor1 ); /*Q1 */ -#else - factor = add( factor, factor1 ); /*Q1 */ -#endif } } L_tmp = L_mult( weight, prev_SWB_fenv[13] ); /*Q17 */ @@ -2063,11 +1881,7 @@ tmp2 = add( swb_bwe_sm_subband[13], st_offset ); FOR( ; n_freq < tmp2; n_freq++ ) { L_tmp1 = Mult_32_16( SWB_signal_32[n_freq], factor ); -#ifdef BASOP_NOGLOB SWB_signal_32[n_freq] = L_shl_sat( L_tmp1, 13 ); -#else - SWB_signal_32[n_freq] = L_shl( L_tmp1, 13 ); -#endif move32(); /*15+Qsyn */ factor = add( factor, factor1 ); /*Q1 */ } @@ -2081,11 +1895,7 @@ FOR( n_band = 13; n_band < SWB_FENV; n_band++ ) FOR( ; n_freq < tmp2; n_freq++ ) { L_tmp1 = Mult_32_16( SWB_signal_32[n_freq], factor ); -#ifdef BASOP_NOGLOB SWB_signal_32[n_freq] = L_shl_sat( L_tmp1, 13 ); -#else - SWB_signal_32[n_freq] = L_shl( L_tmp1, 13 ); -#endif move32(); /*15+Qsyn */ } } @@ -2148,11 +1958,7 @@ void time_envelop_shaping_fx( Energy = L_deposit_l( 0 ); FOR( j = 0; j < L / 4; j++ ) { -#ifdef BASOP_NOGLOB Energy = L_mac0_sat( Energy, *pit, *pit ); /*(2*Q_synth) */ -#else - Energy = L_mac0( Energy, *pit, *pit ); /*(2*Q_synth) */ -#endif pit++; } Energy = Mult_32_16( Energy, inv_L ); /*Q(29-exp_L-15) -> Q(-exp_L+14+2*Q_synth) */ @@ -2175,11 +1981,7 @@ void time_envelop_shaping_fx( } test(); -#ifdef BASOP_NOGLOB IF( LT_32( SWB_tenv[i], 65536 /* 2 in Q15 */ ) && LT_32( Energy, L_shl_sat( SWB_tenv[i], sub( 16, exp ) ) ) ) -#else - IF( LT_32( SWB_tenv[i], 65536 /* 2 in Q15 */ ) && LT_32( Energy, L_shl( SWB_tenv[i], sub( 16, exp ) ) ) ) -#endif { *Q_synth = add( *Q_synth, 3 ); move16(); @@ -2204,11 +2006,7 @@ void time_envelop_shaping_fx( FOR( j = 0; j < L / 4; j++ ) { -#ifdef BASOP_NOGLOB *pit = round_fx_sat( L_shl_sat( L_mult( tmp, *pit ), sub( exp, 1 ) ) ); /*Q(13-exp+1)->Q(14-exp)->Qsyn-3 */ -#else - *pit = round_fx( L_shl( L_mult( tmp, *pit ), sub( exp, 1 ) ) ); /*Q(13-exp+1)->Q(14-exp)->Qsyn-3 */ -#endif move16(); pit++; } @@ -2267,11 +2065,7 @@ void time_envelop_shaping_ivas_fx( } test(); -#ifdef BASOP_NOGLOB IF( LT_32( SWB_tenv[i], 65536 /* 2 in Q15 */ ) && LT_32( Energy, L_shl_sat( SWB_tenv[i], sub( 16, exp ) ) ) ) -#else - IF( LT_32( SWB_tenv[i], 65536 /* 2 in Q15 */ ) && LT_32( Energy, L_shl( SWB_tenv[i], sub( 16, exp ) ) ) ) -#endif { *Q_synth = add( *Q_synth, 3 ); move16(); @@ -2295,11 +2089,7 @@ void time_envelop_shaping_ivas_fx( FOR( j = 0; j < L / 4; j++ ) { -#ifdef BASOP_NOGLOB *pit = round_fx_sat( L_shl_sat( L_mult( tmp, *pit ), sub( exp, 1 ) ) ); /*Q(13-exp+1)->Q(14-exp)->Qsyn-3 */ -#else - *pit = round_fx( L_shl( L_mult( tmp, *pit ), sub( exp, 1 ) ) ); /*Q(13-exp+1)->Q(14-exp)->Qsyn-3 */ -#endif move16(); pit++; } @@ -2356,11 +2146,7 @@ void time_reduce_pre_echo_fx( L_tmp = L_deposit_l( 0 ); FOR( j = 0; j < L; j++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_mac0_sat( L_tmp, synth[Len + j], synth[Len + j] ); /*2*Q_syn */ -#else - L_tmp = L_mac0( L_tmp, synth[Len + j], synth[Len + j] ); /*2*Q_syn */ -#endif } energyL[i] = Mult_32_16( L_shr( L_tmp, sub( 14, exp_L ) ), inv_L ); move32(); /*Q(2*Q_syn +29-exp_L-15 - (14-exp_L) ) -> Q(2*Q_syn) */ @@ -2400,11 +2186,7 @@ void time_reduce_pre_echo_fx( j = i_mult( L, pos ); FOR( i = 0; i < j; i++ ) { -#ifdef BASOP_NOGLOB energy = L_mac0_sat( energy, error[i], error[i] ); /*Q(2*Q_synth) */ -#else - energy = L_mac0( energy, error[i], error[i] ); /*Q(2*Q_synth) */ -#endif } exp_j = norm_s( j ); @@ -2445,22 +2227,14 @@ void time_reduce_pre_echo_fx( tmp_exp = add( 1, exp ); FOR( i = 0; i < j; i++ ) { -#ifdef BASOP_NOGLOB error[i] = round_fx_sat( L_shl_sat( Mult_32_16( L_tmp, error[i] ), tmp_exp ) ); /*Q(30-exp+1-16)->Q(15-exp)->Q_synth */ -#else - error[i] = round_fx( L_shl( Mult_32_16( L_tmp, error[i] ), tmp_exp ) ); /*Q(30-exp+1-16)->Q(15-exp)->Q_synth */ -#endif move16(); } energy = L_deposit_l( 0 ); FOR( i = j; i < ( j + L ); i++ ) { -#ifdef BASOP_NOGLOB energy = L_mac0_sat( energy, error[i], error[i] ); /*(2*Q_synth) */ -#else - energy = L_mac0( energy, error[i], error[i] ); /*(2*Q_synth) */ -#endif } energy = Mult_32_16( energy, inv_L ); /*Q(29-exp_L+1-16) -> Q(-exp_L+14) */ @@ -2495,15 +2269,11 @@ void time_reduce_pre_echo_fx( move16(); FOR( i = 0; i < L; i++ ) { - tmpi = round_fx( L_shl( L_mult( i, inv_L ), add( 1, exp_L ) ) ); /*Q15 */ - L_tmp = L_sub( L_tmp1, Ltmp_ener ); /*Q(30-exp) */ - L_tmp = Mult_32_16( L_tmp, tmpi ); /*Q(30-exp) */ - L_tmp = L_add( Ltmp_ener, L_tmp ); /*Q(30-exp) */ -#ifdef BASOP_NOGLOB + tmpi = round_fx( L_shl( L_mult( i, inv_L ), add( 1, exp_L ) ) ); /*Q15 */ + L_tmp = L_sub( L_tmp1, Ltmp_ener ); /*Q(30-exp) */ + L_tmp = Mult_32_16( L_tmp, tmpi ); /*Q(30-exp) */ + L_tmp = L_add( Ltmp_ener, L_tmp ); /*Q(30-exp) */ tmp = round_fx_sat( L_shl_sat( Mult_32_16( L_tmp, *pit ), add( 1, exp ) ) ); /*Q0 */ -#else - tmp = round_fx( L_shl( Mult_32_16( L_tmp, *pit ), add( 1, exp ) ) ); /*Q0 */ -#endif *pit++ = tmp; move16(); } @@ -2572,11 +2342,7 @@ void calc_normal_length_fx_32( peak = mag; move16(); } -#ifdef BASOP_NOGLOB mean = L_add_sat( mean, mag ); -#else - mean = L_add( mean, mag ); -#endif pit++; } @@ -2666,11 +2432,7 @@ void calc_norm_envelop_fx_32( move16(); FOR( n_lag = 0; n_lag < n_lag_now; n_lag++ ) { -#ifdef BASOP_NOGLOB envelope_fx[env_index] = L_add_sat( envelope_fx[env_index], L_abs( SWB_signal_fx[n_freq + n_lag] ) ); -#else - envelope_fx[env_index] = L_add( envelope_fx[env_index], L_abs( SWB_signal_fx[n_freq + n_lag] ) ); -#endif move32(); } env_index = add( env_index, 1 ); @@ -2778,12 +2540,8 @@ void hq_generic_decoding_fx( #endif 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 */ -#ifdef BASOP_NOGLOB + 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 */ -#else - fenvL_fx = round_fx( L_shl( L_tmp, sub( exp, 14 ) ) ); /*Q1 */ -#endif } calc_normal_length_fx_32( HQ_CORE, coeff_out1_fx, HQ_GEN_SWB, -1, &L_swb_norm, prev_L_swb_norm ); @@ -3084,12 +2842,564 @@ void hq_generic_decoding_fx( exp2 = sub( norm_l( L_tmp2 ), 1 ); tmp1_fx = extract_h( L_shl( L_tmp1, exp1 ) ); tmp2_fx = extract_h( L_shl( L_tmp2, exp2 ) ); - tmp3_fx = div_s( tmp2_fx, tmp1_fx ); /*15 + exp2 + 15 - (exp1 + 15) */ -#ifdef BASOP_NOGLOB + tmp3_fx = div_s( tmp2_fx, tmp1_fx ); /*15 + exp2 + 15 - (exp1 + 15) */ tmp3_fx = shr_sat( tmp3_fx, add( 5, sub( exp2, exp1 ) ) ); /*10 */ + if ( LT_16( tmp3_fx, 307 /* 0.3 in Q10*/ ) ) + { + tmp3_fx = 307; /* 0.3 in Q10*/ + move16(); + } + FOR( ; tmp3_fx < 1024; tmp3_fx += 102 ) + { + L_tmp = L_shl( Mult_32_16( *pit1_fx, tmp3_fx ), 5 ); /*15 + 5 + 10 -15 */ + *pit1_fx++ = L_tmp; + move32(); + } + + pit1_fx = &coeff_out_fx[HQ_GENERIC_HIGH2 - 1 + hq_generic_offset]; + + exp1 = sub( norm_l( L_tmp1 ), 1 ); + exp2 = norm_l( L_tmp2 ); + tmp1_fx = extract_h( L_shl( L_tmp1, exp1 ) ); + tmp2_fx = extract_h( L_shl( L_tmp2, exp2 ) ); + tmp3_fx = div_s( tmp1_fx, tmp2_fx ); /*15 + exp2 + 15 - (exp1 + 15) */ + tmp3_fx = shr( tmp3_fx, add( 5, sub( exp1, exp2 ) ) ); /*10 */ + tmp3_fx = shr( tmp3_fx, 1 ); + 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 - tmp3_fx = shr( tmp3_fx, add( 5, sub( exp2, exp1 ) ) ); /*10 */ + 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 ); + } + } + + + wfenv_fx = hq_generic_fenv_fx[0]; + move16(); /*1 */ + i = 0; + move16(); + tmp2 = add( add( swb_bwe_subband[0], hq_generic_offset ), 8 ); + FOR( n_freq = add( swb_bwe_subband[0], hq_generic_offset ); n_freq < tmp2; n_freq++ ) + { + factor_fx = shl( i, 12 ); /*15 */ + L_tmp1 = L_mult( sub( 32767, factor_fx ), fenvL_fx ); /*17 */ + L_tmp2 = L_mult( factor_fx, wfenv_fx ); /*17 */ + L_tmp1 = L_add( L_tmp1, L_tmp2 ); /*17 */ + + cs = norm_l( L_tmp1 ); + tmp = extract_h( L_shl( L_tmp1, cs ) ); /*17 + cs - 16 */ + L_tmp = Mult_32_16( coeff_out_fx[n_freq], tmp ); /*12 + 15 + 17 + cs - 16 - 15 */ + coeff_out_fx[n_freq] = L_shr( L_tmp, add( 1, cs ) ); + move32(); /*12 */ + i++; + move16(); + } + + k = sub( nenv, 2 ); + FOR( n_band = 0; n_band < k; n_band++ ) + { + wfenv_fx = hq_generic_fenv_fx[n_band + 1]; + move16(); /*1 */ + + tmp2 = swb_bwe_sm_subband[n_band + 1] + hq_generic_offset; + FOR( i = 0; n_freq < tmp2; i++ ) + { + L_tmp1 = L_mult( sub( wfenv_fx, hq_generic_fenv_fx[n_band] ), smooth_factor_fx[n_band] ); /*17 */ + L_tmp1 = Mult_32_16( L_tmp1, shl( i, 10 ) ); /*17 + 10 - 15 */ + L_tmp1 = L_add( L_tmp1, L_shl( hq_generic_fenv_fx[n_band], 11 ) ); /*12 */ + + cs = norm_l( L_tmp1 ); + tmp = extract_h( L_shl( L_tmp1, cs ) ); /*12 + cs - 16 */ + L_tmp = Mult_32_16( coeff_out_fx[n_freq], tmp ); /*12 + 15 + 12 + cs - 16 - 15 */ + coeff_out_fx[n_freq] = L_shl( L_tmp, sub( 4, cs ) ); + move32(); /*12 */ + n_freq++; + } + } + + wfenv_fx = hq_generic_fenv_fx[nenv - 1]; + move16(); /*1 */ + tmp2 = add( swb_bwe_sm_subband[nenv - 1], hq_generic_offset ); + FOR( i = 0; n_freq < tmp2; i++ ) + { + L_tmp1 = L_mult( sub( wfenv_fx, hq_generic_fenv_fx[nenv - 2] ), smooth_factor_fx[nenv - 2] ); /*17 */ + L_tmp1 = Mult_32_16( L_tmp1, shl( i, 10 ) ); /*17 + 10 - 15 */ + L_tmp1 = L_add( L_tmp1, L_shl( hq_generic_fenv_fx[nenv - 2], 11 ) ); /*12 */ + + cs = norm_l( L_tmp1 ); + tmp = extract_h( L_shl( L_tmp1, cs ) ); /*12 + cs - 16 */ + L_tmp = Mult_32_16( coeff_out_fx[n_freq], tmp ); /*12 + 15 + 12 + cs - 16 - 15 */ + coeff_out_fx[n_freq] = L_shl( L_tmp, sub( 4, cs ) ); + move32(); /*12 */ + n_freq++; + } + + IF( EQ_16( HQ_mode, HQ_GEN_SWB ) ) + { + FOR( n_band = sub( nenv, 1 ); n_band < nenv; ++n_band ) + { + wfenv_fx = hq_generic_fenv_fx[n_band]; + move16(); /*1 */ + tmp2 = add( swb_bwe_subband[n_band + 1], hq_generic_offset ); + FOR( ; n_freq < tmp2; n_freq++ ) + { + L_tmp = Mult_32_16( coeff_out_fx[n_freq], wfenv_fx ); /*15 + 12 + 1 - 15 */ + coeff_out_fx[n_freq] = L_shr( L_tmp, 1 ); + move32(); /*12 */ + } + } + } + ELSE + { + test(); + IF( GT_16( sub( hq_generic_fenv_fx[nenv - 1], hq_generic_fenv_fx[nenv] ), 30 ) || LT_16( hq_generic_fenv_fx[nenv], 10 ) ) + { + wfenv_fx = hq_generic_fenv_fx[nenv - 1]; + move16(); /*1 */ + FOR( i = 0; n_freq < fb_bwe_subband[0]; i++ ) + { + L_tmp = Mult_32_16( coeff_out_fx[n_freq], wfenv_fx ); /*15 + 12 + 1 - 15 */ + coeff_out_fx[n_freq] = L_shr( L_tmp, 1 ); + move32(); /*12 */ + n_freq++; + } + + FOR( n_band = 0; n_band < DIM_FB; n_band++ ) + { + wfenv_fx = hq_generic_fenv_fx[n_band + nenv]; + move16(); /*1 */ + tmp2 = fb_bwe_subband[n_band + 1]; + FOR( i = 0; n_freq < tmp2; i++ ) + { + L_tmp = Mult_32_16( coeff_out_fx[n_freq], wfenv_fx ); /*15 + 12 + 1 - 15 */ + coeff_out_fx[n_freq] = L_shr( L_tmp, 1 ); + move32(); /*12 */ + n_freq++; + } + } + } + ELSE + { + FOR( n_band = 0; n_band < DIM_FB; n_band++ ) + { + wfenv_fx = hq_generic_fenv_fx[n_band + nenv - 1]; + move16(); /*1 */ + + FOR( i = 0; n_freq < fb_bwe_sm_subband[n_band]; i++ ) + { + L_tmp1 = L_mult( sub( wfenv_fx, hq_generic_fenv_fx[n_band + nenv] ), fb_smooth_factor_fx[n_band] ); /*17 */ + L_tmp1 = Mult_32_16( L_tmp1, shl( i, 9 ) ); /*17 + 9 - 15 */ + L_tmp1 = L_add( L_tmp1, L_shl( hq_generic_fenv_fx[n_band + nenv], 10 ) ); /*11 */ + + cs = norm_l( L_tmp1 ); + tmp = extract_h( L_shl( L_tmp1, cs ) ); /*11 + cs - 16 */ + L_tmp = Mult_32_16( coeff_out_fx[n_freq], tmp ); /*12 + 15 + 11 + cs - 16 - 15 */ + coeff_out_fx[n_freq] = L_shl( L_tmp, sub( 5, cs ) ); + move32(); /*12 */ + n_freq = add( n_freq, 1 ); + } + } + + wfenv_fx = hq_generic_fenv_fx[tenv - 1]; + move16(); /*1 */ + + FOR( ; n_freq < fb_bwe_subband[DIM_FB]; n_freq++ ) + { + L_tmp = Mult_32_16( coeff_out_fx[n_freq], wfenv_fx ); /*15 + 12 + 1 - 15 */ + coeff_out_fx[n_freq] = L_shr( L_tmp, 1 ); + move32(); /*12 */ + } + } + } + + return; +} + +void hq_generic_decoding_ivas_fx( + const Word16 HQ_mode, /* i : HQ mode : Q0 */ + Word32 *coeff_out1_fx, /* i/o: BWE input & temporary buffer : Q12 */ + const Word16 *hq_generic_fenv_fx, /* i : SWB frequency envelopes : Q1 */ + Word32 *coeff_out_fx, /* o : SWB signal in MDCT domain : Q12 */ + const Word16 hq_generic_offset, /* i : frequency offset for representing hq generci : Q0 */ + Word16 *prev_L_swb_norm, /* i/o: last normalize length : Q0 */ + const Word16 hq_generic_exc_clas, /* i : bwe excitation class " Q0 */ + const Word16 *R ) +{ + Word16 i, n_freq, n_band, L_swb_norm; + Word16 k; + Word16 nenv; + Word16 tenv; + + Word16 exp, exp1, exp2, frac, tmp, tmp2, cs; + Word32 L_tmp, L_tmp1, L_tmp2, max_coeff_fx; + Word16 fenvL_fx, wfenv_fx, factor_fx; + Word32 *pit1_fx; + Word16 tmp1_fx, tmp2_fx, tmp3_fx, tmp4_fx; + Word32 energy_fx; + + Word32 envelope_fx[L_FRAME16k]; + Word32 mean_vector_fx[20]; + Word16 rn_weight0_fx; + Word16 s; + Word16 blen, nband_lf, sfidx, efidx; + Word16 bwe_seed; + Word16 signum[L_FRAME16k]; + + nenv = sub( SWB_FENV, 2 ); + if ( LE_16( hq_generic_offset, HQ_GENERIC_FOFFSET_24K4 ) ) + { + nenv = SWB_FENV; + move16(); + } + + tenv = nenv; + move16(); + if ( EQ_16( HQ_mode, HQ_GEN_FB ) ) + { + tenv = add( nenv, DIM_FB ); + } + + max_coeff_fx = 0; + move16(); + tmp = add( swb_bwe_subband[0], hq_generic_offset ); + FOR( n_freq = add( HQ_GENERIC_ST_FREQ, hq_generic_offset ); n_freq < tmp; n_freq++ ) + { + max_coeff_fx = L_max( max_coeff_fx, L_abs( coeff_out1_fx[n_freq] ) ); + } + cs = norm_l( max_coeff_fx ); + + L_tmp = 0; + move16(); + tmp2 = add( swb_bwe_subband[0], hq_generic_offset ); + FOR( n_freq = add( HQ_GENERIC_ST_FREQ, hq_generic_offset ); n_freq < tmp2; n_freq++ ) + { + tmp = extract_h( L_shl( coeff_out1_fx[n_freq], cs ) ); /*12 + cs - 16 */ + L_tmp1 = L_mult0( tmp, tmp ); /*2*(cs-2) */ + L_tmp = L_add( L_tmp, L_shr( L_tmp1, 5 ) ); /*2*(cs-2) - 5 */ + } + cs = sub( shl( cs, 1 ), 9 ); + fenvL_fx = 0; + move16(); + 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) */ + 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 */ + } + + calc_normal_length_fx_32( HQ_CORE, coeff_out1_fx, HQ_GEN_SWB, -1, &L_swb_norm, prev_L_swb_norm ); + + calc_norm_envelop_lf_fx( coeff_out1_fx, envelope_fx, &L_swb_norm, HQ_mode, hq_generic_offset, &sfidx, &efidx ); + + blen = 16; + move16(); + + IF( EQ_16( hq_generic_exc_clas, HQ_GENERIC_EXC0 ) ) + { + rn_weight0_fx = 819; + move16(); /* 0.8 Q10 */ + } + ELSE IF( EQ_16( hq_generic_exc_clas, HQ_GENERIC_EXC1 ) ) + { + rn_weight0_fx = 51; + move16(); /* 0.05 Q10*/ + } + ELSE + { + rn_weight0_fx = 205; + move16(); /* 0.02 Q10 */ + } + + tmp = sub( efidx, sfidx ); + IF( tmp == 0 ) + { + nband_lf = 0; + move16(); + } + ELSE + { + exp = norm_s( tmp ); + nband_lf = shl( tmp, sub( exp, 1 ) ); + exp1 = norm_s( blen ); + tmp = shl( blen, exp1 ); + nband_lf = shr( div_s( nband_lf, tmp ), add( sub( 14, exp1 ), exp ) ); /* 15 + exp-1 - exp1, Q0*/ + } + + FOR( n_freq = sfidx; n_freq < efidx; n_freq++ ) + { + IF( coeff_out1_fx[n_freq] < 0 ) + { + signum[n_freq] = -1; + move16(); + coeff_out1_fx[n_freq] = L_negate( coeff_out1_fx[n_freq] ); + move32(); + } + ELSE + { + signum[n_freq] = 1; + move16(); + } + } + + /* applying whitening */ + FOR( n_freq = sfidx; n_freq < efidx; n_freq++ ) + { + exp = norm_l( coeff_out1_fx[n_freq] ) - 1; + exp1 = norm_l( envelope_fx[n_freq] ); + + L_tmp = L_shl( coeff_out1_fx[n_freq], exp ); + L_tmp1 = L_shl( envelope_fx[n_freq], exp1 ); + + logic16(); + coeff_out1_fx[n_freq] = Div_32( L_tmp, extract_h( L_tmp1 ), extract_l( L_shr( L_tmp1, 1 ) ) & 0x00007fff ); + move32(); /*31 + exp1 - exp2*/ + + exp = add( 31, sub( exp, exp1 ) ); + coeff_out1_fx[n_freq] = L_shl( coeff_out1_fx[n_freq], sub( 20, exp ) ); + move32(); /*Q12->Q20*/ + } + + /* mean vector generation for controlling dynamic range */ + FOR( k = 0; k < nband_lf; ++k ) + { + energy_fx = 1; + move16(); + + tmp = add( i_mult2( add( k, 1 ), blen ), sfidx ); + FOR( i = add( i_mult2( k, blen ), sfidx ); i < tmp; ++i ) + { + energy_fx = L_add( energy_fx, coeff_out1_fx[i] ); + } + exp = sub( norm_l( energy_fx ), 1 ); + L_tmp = L_shl( energy_fx, exp ); + exp1 = norm_l( L_and( blen, 0x00007fff ) ); + L_tmp1 = L_shl( blen, exp1 ); + logic16(); + mean_vector_fx[k] = Div_32( L_tmp, extract_h( L_tmp1 ), extract_l( L_shr( L_tmp1, 1 ) ) & 0x00007fff ); + move32(); /*31 + 20 + exp1 - exp2*/ + exp = add( 51, sub( exp, exp1 ) ); + mean_vector_fx[k] = L_shl( mean_vector_fx[k], sub( 20, exp ) ); + move32(); /*Q12->Q20*/ + } + + /* dynamics control */ + FOR( k = 0; k < nband_lf; ++k ) + { + tmp = add( i_mult2( add( k, 1 ), blen ), sfidx ); + FOR( i = add( i_mult2( k, blen ), sfidx ); i < tmp; ++i ) + { + L_tmp = L_sub( coeff_out1_fx[i], mean_vector_fx[k] ); + exp = norm_l( L_tmp ); + L_tmp = L_shl( L_tmp, exp ); /* exp+12*/ + exp1 = norm_l( rn_weight0_fx ); + L_tmp1 = L_shl( rn_weight0_fx, exp1 ); /* exp1+10*/ + L_tmp = L_mult( extract_h( L_tmp ), extract_h( L_tmp1 ) ); + L_tmp = L_shr( L_tmp, add( exp, sub( exp1, 21 ) ) ); /* Q20*/ + coeff_out1_fx[i] = L_sub( coeff_out1_fx[i], L_tmp ); + move32(); + } + } + + IF( EQ_16( hq_generic_exc_clas, HQ_GENERIC_EXC0 ) ) + { + bwe_seed = add( add( shl( R[0], 3 ), shl( R[1], 2 ) ), add( shl( R[2], 1 ), R[3] ) ); + + FOR( n_freq = sfidx; n_freq < efidx; n_freq++ ) + { + IF( signum[n_freq] < 0 ) + { + coeff_out1_fx[n_freq] = L_negate( coeff_out1_fx[n_freq] ); + move32(); + } + + IF( Random( &bwe_seed ) < 0 ) + { + coeff_out1_fx[n_freq] = L_negate( coeff_out1_fx[n_freq] ); + move32(); + } + } + } + ELSE + { + FOR( n_freq = sfidx; n_freq < efidx; n_freq++ ) + { + IF( signum[n_freq] < 0 ) + { + coeff_out1_fx[n_freq] = L_negate( coeff_out1_fx[n_freq] ); + move32(); + } + } + } + + /* normalizing modified low frequency spectrum */ + FOR( k = 0; k < nband_lf; ++k ) + { + energy_fx = 1; + move16(); + tmp = add( i_mult2( add( k, 1 ), blen ), sfidx ); + FOR( i = add( ( i_mult2( k, blen ) ), sfidx ); i < tmp; ++i ) + { + exp = norm_l( coeff_out1_fx[i] ); + L_tmp1 = L_shl( coeff_out1_fx[i], exp ); /* exp + 12*/ + + L_tmp = Mult_32_32( L_tmp1, L_tmp1 ); + L_tmp = L_shr( L_tmp, sub( i_mult2( 2, exp ), 11 ) ); /*Q20 */ + energy_fx = L_add( energy_fx, L_tmp ); + } + + exp = norm_l( energy_fx ); + L_tmp = L_shl( energy_fx, sub( exp, 1 ) ); + exp1 = norm_s( blen ); + L_tmp1 = L_shl( (Word32) blen, add( exp1, 16 ) ); + + L_tmp = Div_32( L_tmp, extract_h( L_tmp1 ), extract_l( L_shr( L_tmp1, 1 ) ) & 0x00007fff ); + exp = sub( add( 34, exp ), exp1 ); + L_tmp = L_shr( L_tmp, sub( exp, 31 ) ); + exp = 31; + move16(); + + exp = sub( 31, exp ); + IF( exp & 0x1 ) + { + L_tmp = L_shr( L_tmp, 1 ); + exp = add( exp, 1 ); + } + L_tmp = Sqrt_l( L_tmp, &exp1 ); + exp = add( 31, sub( shr( exp1, 1 ), shr( exp, 1 ) ) ); + energy_fx = L_shl( L_tmp, sub( 31, exp ) ); /*Q31*/ + + tmp = add( i_mult2( add( k, 1 ), blen ), sfidx ); + FOR( i = add( ( i_mult2( k, blen ) ), sfidx ); i < tmp; ++i ) + { + IF( NE_32( L_abs( coeff_out1_fx[i] ), coeff_out1_fx[i] ) ) + { + s = -1; + move16(); + coeff_out1_fx[i] = L_abs( coeff_out1_fx[i] ); + move32(); + } + ELSE + { + s = 0; + move16(); + } + exp = norm_l( coeff_out1_fx[i] ); + L_tmp = L_shl( coeff_out1_fx[i], sub( exp, 1 ) ); + exp1 = norm_l( energy_fx ); + L_tmp1 = L_shl( (Word32) energy_fx, exp1 ); + logic16(); + L_tmp = Div_32( L_tmp, extract_h( L_tmp1 ), extract_l( L_shr( L_tmp1, 1 ) ) & 0x00007fff ); + exp = add( sub( 19, exp1 ), exp ); + coeff_out1_fx[i] = L_shl( L_tmp, add( sub( 12, exp ), 15 ) ); + move32(); /* Q12 -> Q27 */ + IF( s ) + { + coeff_out1_fx[i] = L_negate( coeff_out1_fx[i] ); + move32(); + } + } + } + + Copy32( &coeff_out1_fx[HQ_GENERIC_OFFSET], &coeff_out_fx[HQ_GENERIC_HIGH0 + hq_generic_offset], HQ_GENERIC_LEN0 ); + Copy32( &coeff_out1_fx[HQ_GENERIC_OFFSET], &coeff_out_fx[HQ_GENERIC_HIGH1 + hq_generic_offset], HQ_GENERIC_LEN0 ); + + IF( LE_16( hq_generic_offset, HQ_GENERIC_FOFFSET_24K4 ) ) + { + Copy32( &coeff_out1_fx[HQ_GENERIC_LOW0], &coeff_out_fx[HQ_GENERIC_HIGH2 + hq_generic_offset], HQ_GENERIC_END_FREQ - HQ_GENERIC_HIGH2 ); + } + + IF( EQ_16( HQ_mode, HQ_GEN_FB ) ) + { + IF( LE_16( hq_generic_offset, HQ_GENERIC_FOFFSET_24K4 ) ) + { + Copy32( &coeff_out1_fx[HQ_GENERIC_LOW0 + HQ_GENERIC_END_FREQ - HQ_GENERIC_HIGH2], &coeff_out_fx[fb_bwe_subband[0]], 160 ); + } + ELSE + { + Copy32( &coeff_out1_fx[HQ_GENERIC_OFFSET + HQ_GENERIC_LEN0], &coeff_out_fx[fb_bwe_subband[0]], 160 ); + } + } + + + L_tmp1 = L_deposit_l( 0 ); + L_tmp2 = L_deposit_l( 0 ); + FOR( i = 0; i < 5; ++i ) + { + L_tmp1 = L_add( L_tmp1, L_shr( L_abs( coeff_out_fx[HQ_GENERIC_HIGH1 + hq_generic_offset + i] ), 3 ) ); // adding guard bits + L_tmp2 = L_add( L_tmp2, L_shr( L_abs( coeff_out_fx[HQ_GENERIC_HIGH1 - 2 + hq_generic_offset - i] ), 3 ) ); // adding guard bits + } + + pit1_fx = &coeff_out_fx[HQ_GENERIC_HIGH1 + hq_generic_offset]; + L_tmp1 = L_max( L_tmp1, 1 ); + L_tmp2 = L_max( L_tmp2, 1 ); + exp1 = norm_l( L_tmp1 ); + exp2 = sub( norm_l( L_tmp2 ), 1 ); + tmp1_fx = extract_h( L_shl( L_tmp1, exp1 ) ); + tmp2_fx = extract_h( L_shl( L_tmp2, exp2 ) ); + tmp3_fx = div_s( tmp2_fx, tmp1_fx ); /*15 + exp2 + 15 - (exp1 + 15) */ + tmp3_fx = shr( tmp3_fx, add( 5, sub( exp2, exp1 ) ) ); /*10 */ + + if ( LT_16( tmp3_fx, 307 /*0.3 in Q10 */ ) ) + { + tmp3_fx = 307 /*0.3 in Q10 */; + move16(); + } + FOR( ; tmp3_fx < 1024; tmp3_fx += 102 ) + { + *pit1_fx = Mult_32_16( *pit1_fx, shl( tmp3_fx, 5 ) ); + move32(); /*15 + 5 + 10 -15 */ + pit1_fx++; + } + + pit1_fx = &coeff_out_fx[HQ_GENERIC_HIGH1 - 1 + hq_generic_offset]; + + exp1 = sub( norm_l( L_tmp1 ), 1 ); + exp2 = norm_l( L_tmp2 ); + tmp1_fx = extract_h( L_shl( L_tmp1, exp1 ) ); + tmp2_fx = extract_h( L_shl( L_tmp2, exp2 ) ); + tmp3_fx = div_s( tmp1_fx, tmp2_fx ); /*15 + exp2 + 15 - (exp1 + 15) */ + tmp3_fx = shr( tmp3_fx, add( 5, sub( exp1, exp2 ) ) ); /*10 */ + + IF( GT_16( tmp3_fx, 5120 ) ) + { + FOR( tmp3_fx = 5120; tmp3_fx > 1024; tmp3_fx -= 512 ) + { + /* Adding saturation suggested as fix for issue #957 */ + L_tmp1 = L_shl_sat( Mult_32_16( *pit1_fx, tmp3_fx ), 5 ); /*15 + 5 + 10 -15 */ + *pit1_fx-- = L_tmp1; + move32(); + } + } + + IF( LE_16( hq_generic_offset, HQ_GENERIC_FOFFSET_24K4 ) ) + { + L_tmp1 = L_add( L_abs( coeff_out_fx[HQ_GENERIC_HIGH2 + hq_generic_offset] ), L_abs( coeff_out_fx[HQ_GENERIC_HIGH2 + 1 + hq_generic_offset] ) ); + L_tmp2 = L_add( L_abs( coeff_out_fx[HQ_GENERIC_HIGH2 - 4 + hq_generic_offset] ), L_add( L_abs( coeff_out_fx[HQ_GENERIC_HIGH2 - 3 + hq_generic_offset] ), + L_add( L_abs( coeff_out_fx[HQ_GENERIC_HIGH2 - 2 + hq_generic_offset] ), L_abs( coeff_out_fx[HQ_GENERIC_HIGH2 - 1 + hq_generic_offset] ) ) ) ); + + pit1_fx = &coeff_out_fx[HQ_GENERIC_HIGH2 + hq_generic_offset]; + + L_tmp1 = L_max( L_tmp1, 1 ); + L_tmp2 = L_max( L_tmp2, 1 ); + exp1 = norm_l( L_tmp1 ); + exp2 = sub( norm_l( L_tmp2 ), 1 ); + tmp1_fx = extract_h( L_shl( L_tmp1, exp1 ) ); + tmp2_fx = extract_h( L_shl( L_tmp2, exp2 ) ); + tmp3_fx = div_s( tmp2_fx, tmp1_fx ); /*15 + exp2 + 15 - (exp1 + 15) */ + tmp3_fx = shr_sat( tmp3_fx, add( 5, sub( exp2, exp1 ) ) ); /*10 */ if ( LT_16( tmp3_fx, 307 /* 0.3 in Q10*/ ) ) { tmp3_fx = 307; /* 0.3 in Q10*/ diff --git a/lib_com/swb_bwe_com_lr_fx.c b/lib_com/swb_bwe_com_lr_fx.c index 1f4fd180198108ce40b1c9d3e3480a79a4808681..7c2c355517de0e64c06eb3eafc90c5d7e55e0c9a 100644 --- a/lib_com/swb_bwe_com_lr_fx.c +++ b/lib_com/swb_bwe_com_lr_fx.c @@ -986,11 +986,7 @@ void SpectrumSmoothing_fx( IF( GT_32( L_max_val[i], 0x1L ) ) { exp_normd = norm_l( L_max_val[i] ); -#ifdef BASOP_NOGLOB max_val_norm_fx = div_s( 0x2800, round_fx_o( L_shl_o( L_max_val[i], exp_normd, &Overflow ), &Overflow ) ); /* Q10-(Qs+exp_normd-16) */ -#else - max_val_norm_fx = div_s( 0x2800, round_fx( L_shl( L_max_val[i], exp_normd ) ) ); /* Q10-(Qs+exp_normd-16) */ -#endif Qmax_val_norm[i] = sub( 10 - 12 + 16 + 15, exp_normd ); move16(); /* 10 - (12+exp_normd-16) +15 */ ; @@ -1016,20 +1012,12 @@ void SpectrumSmoothing_fx( { IF( L_inBuf_pss[j] >= 0 ) { -#ifdef BASOP_NOGLOB outBuf_pss_fx[j] = round_fx_o( L_shl_o( Mpy_32_16_r( L_shl_o( L_inBuf_pss[j], exp_norm, &Overflow ), max_val_norm_fx ), sub( exp_shift, exp_norm ), &Overflow ), &Overflow ); -#else - outBuf_pss_fx[j] = round_fx( L_shl( Mpy_32_16_r( L_shl( L_inBuf_pss[j], exp_norm ), max_val_norm_fx ), sub( exp_shift, exp_norm ) ) ); -#endif move32(); } ELSE { -#ifdef BASOP_NOGLOB outBuf_pss_fx[j] = negate( round_fx_o( L_shl_o( Mpy_32_16_r( L_shl_o( L_abs( L_inBuf_pss[j] ), exp_norm, &Overflow ), max_val_norm_fx ), sub( exp_shift, exp_norm ), &Overflow ), &Overflow ) ); -#else - outBuf_pss_fx[j] = negate( round_fx( L_shl( Mpy_32_16_r( L_shl( L_abs( L_inBuf_pss[j] ), exp_norm ), max_val_norm_fx ), sub( exp_shift, exp_norm ) ) ) ); -#endif move16(); } } @@ -2327,11 +2315,7 @@ void ton_ene_est_fx( exp_pow = sub( 14, temp_hi_fx ); L_band_energy_Linear[i] = Pow2( 14, temp_lo_fx ); move32(); /* Qexp_pow */ -#ifdef BASOP_NOGLOB L_band_energy_Linear[i] = L_shl_sat( L_band_energy_Linear[i], sub( *QbeL, exp_pow ) ); -#else - L_band_energy_Linear[i] = L_shl( L_band_energy_Linear[i], sub( *QbeL, exp_pow ) ); -#endif move32(); /* Div Part */ E_r_fx = 0x7fff; @@ -2354,11 +2338,7 @@ void ton_ene_est_fx( move16(); /* 0.06=15729(Q18) */ exp_shift = sub( 18, QE_r ); -#ifdef BASOP_NOGLOB E_r_shift_fx = shl_o( E_r_fx, exp_shift, &Overflow ); -#else - E_r_shift_fx = shl( E_r_fx, exp_shift ); -#endif IF( LT_16( E_r_shift_fx, 15729 ) ) /* E_r < 0.06 */ { /* avg_pe[k] = (float) sqrt(pow(2.0f,band_energy[i])/band_width[i]); */ @@ -2400,11 +2380,7 @@ void ton_ene_est_fx( L_temp = Mult_32_16( L_temp, E_r_fx ); /* 0.12f: 257698038 (Q31) */ -#ifdef BASOP_NOGLOB if ( GE_32( L_shl_o( L_temp, sub( 31, add( add( shl( Qavg_pe[k], 1 ), QE_r ), 1 - 15 ) ), &Overflow ), 257698038 ) ) -#else - if ( GE_32( L_shl( L_temp, sub( 31, add( add( shl( Qavg_pe[k], 1 ), QE_r ), 1 - 15 ) ) ), 257698038 ) ) -#endif { ni_gain_fx[k] = mult_r( 1638, ni_gain_fx[k] ); /* 0.05 : 1638(Q15) */ move16(); @@ -2430,11 +2406,7 @@ void ton_ene_est_fx( L_E = sum2_fx( &xSynth_har_fx[sub( band_start[i], fLenLow )], band_width[i] ); QE = add( shl( QxSynth_sft, 1 ), 1 ); -#ifdef BASOP_NOGLOB L_E = L_shl_sat( L_E, sub( *QbeL, QE ) ); -#else - L_E = L_shl( L_E, sub( *QbeL, QE ) ); -#endif QE = *QbeL; move16(); } @@ -2644,11 +2616,7 @@ void Gettonl_scalfact_fx( exp_pow = sub( 14, temp_hi_fx ); L_band_energy_Linear[band_pos_fx] = Pow2( 14, temp_lo_fx ); move32(); /* Qexp_pow */ -#ifdef BASOP_NOGLOB L_band_energy_Linear[band_pos_fx] = L_shl_sat( L_band_energy_Linear[band_pos_fx], sub( QbeL, exp_pow ) ); -#else - L_band_energy_Linear[band_pos_fx] = L_shl( L_band_energy_Linear[band_pos_fx], sub( QbeL, exp_pow ) ); -#endif move32(); /* Div Part */ exp_normd = norm_l( L_be_tonal[band_pos_fx] ); @@ -2656,11 +2624,7 @@ void Gettonl_scalfact_fx( exp_normn = norm_l( L_band_energy_Linear[band_pos_fx] ); temp_fx = div_l( L_shl( L_be_tonal[band_pos_fx], exp_normd ), extract_h( L_shl( L_band_energy_Linear[band_pos_fx], exp_normn ) ) ); /* QbeL+exp_normd-(QbeL+exp_normn-16)-1 */ sqrt_32n_16_fx( L_deposit_h( temp_fx ), add( sub( exp_normd, exp_normn ), 31 ), &temp_fx, &Qtemp ); -#ifdef BASOP_NOGLOB enrd_r_fx = extract_h( L_shl_sat( L_mult( enrd_r_fx, temp_fx ), sub( 15, Qtemp ) ) ); -#else - enrd_r_fx = extract_h( L_shl( L_mult( enrd_r_fx, temp_fx ), sub( 15, Qtemp ) ) ); -#endif enrd_r_fx = sub( enrd_r_fx, step_fx ); } ELSE @@ -3271,120 +3235,105 @@ void noiseinj_hf_fx( move32(); IF( p2a_flags_fx[k] == 0 ) { - FOR( i = band_start_fx[k]; i <= band_end_fx[k]; i++ ) - { - IF( LE_32( L_abs( L_xSynth_har[i - fLenLow_fx] ), L_th_g[k - ( BANDS_fx - NB_SWB_SUBBANDS )] ) ) - { - *p_L_En = L_mac( *p_L_En, xSynth_har_fx[i - fLenLow_fx], xSynth_har_fx[i - fLenLow_fx] ); - move32(); - } - ELSE - { - map_pulse_t_fx[i] = 1; - move16(); - } - } -#ifdef BASOP_NOGLOB - *p_L_En = L_shl_sat( *p_L_En, sub( QbeL, QE ) ); -#else - *p_L_En = L_shl( *p_L_En, sub( QbeL, QE ) ); -#endif + FOR( i = band_start_fx[k]; i <= band_end_fx[k]; i++ ){ + IF( LE_32( L_abs( L_xSynth_har[i - fLenLow_fx] ), L_th_g[k - ( BANDS_fx - NB_SWB_SUBBANDS )] ) ){ + *p_L_En = L_mac( *p_L_En, xSynth_har_fx[i - fLenLow_fx], xSynth_har_fx[i - fLenLow_fx] ); move32(); - /**p_L_En = (float)sqrt(*p_En);*/ - sqrt_32n_16_fx( *p_L_En, QbeL, p_sqrt_En_fx, &Qtemp ); -#ifdef BASOP_NOGLOB - *p_sqrt_En_fx = shl_o( *p_sqrt_En_fx, sub( QsEn, Qtemp ), &Overflow ); /* -> Q2 */ - move16(); -#else - *p_sqrt_En_fx = shl( *p_sqrt_En_fx, sub( QsEn, Qtemp ) ); /* -> Q2 */ + } + ELSE + { + map_pulse_t_fx[i] = 1; move16(); -#endif } - p_L_En++; - p_sqrt_En_fx++; } + *p_L_En = L_shl_sat( *p_L_En, sub( QbeL, QE ) ); + move32(); + /**p_L_En = (float)sqrt(*p_En);*/ + sqrt_32n_16_fx( *p_L_En, QbeL, p_sqrt_En_fx, &Qtemp ); + *p_sqrt_En_fx = shl_o( *p_sqrt_En_fx, sub( QsEn, Qtemp ), &Overflow ); /* -> Q2 */ + move16(); +} +p_L_En++; +p_sqrt_En_fx++; +} - p_sqrt_En_fx = sqrt_En_fx; - p_Enn_sm_sb_fx = Enn_sm_sb_fx; - p_prev_En_sb_fx = prev_En_sb_fx; - FOR( k = BANDS_fx - NB_SWB_SUBBANDS; k < BANDS_fx; k++ ) +p_sqrt_En_fx = sqrt_En_fx; +p_Enn_sm_sb_fx = Enn_sm_sb_fx; +p_prev_En_sb_fx = prev_En_sb_fx; +FOR( k = BANDS_fx - NB_SWB_SUBBANDS; k < BANDS_fx; k++ ) +{ + *p_Enn_sm_sb_fx = prev_En_sb_fx[k - ( BANDS_fx - NB_SWB_SUBBANDS )]; + move16(); /* QsEn */ + IF( p2a_flags_fx[k] == 0 ) { - *p_Enn_sm_sb_fx = prev_En_sb_fx[k - ( BANDS_fx - NB_SWB_SUBBANDS )]; - move16(); /* QsEn */ - IF( p2a_flags_fx[k] == 0 ) + L_temp = Mult_32_16( L_band_energy[k], 26214 ); /* 0.8: 26214(Q15) */ + temp_fx = round_fx( L_shl( L_temp, sub( QsEn, sub( Qbe, 16 ) ) ) ); + IF( LT_16( *p_prev_En_sb_fx, temp_fx ) ) { - L_temp = Mult_32_16( L_band_energy[k], 26214 ); /* 0.8: 26214(Q15) */ - temp_fx = round_fx( L_shl( L_temp, sub( QsEn, sub( Qbe, 16 ) ) ) ); - IF( LT_16( *p_prev_En_sb_fx, temp_fx ) ) - { - /**p_Enn_sm_sb = (0.15f*(*p_En)) + (0.85f*prev_En_sb[k-(BANDS-NB_SWB_SUBBANDS)]);*/ - /* 0.15: 4915.2(Q15) 0.85: 27852.80(Q15) */ - *p_Enn_sm_sb_fx = round_fx( L_mac( L_mult( *p_sqrt_En_fx, 4915 ), *p_prev_En_sb_fx, 27853 ) ); - } - ELSE - { - /**p_Enn_sm_sb = (0.8f*(*p_En)) + (0.2f*prev_En_sb[k-(BANDS-NB_SWB_SUBBANDS)]);*/ - /* 0.8: 26214.4(Q15) 0.2:6553.6(Q15) */ - *p_Enn_sm_sb_fx = round_fx( L_mac( L_mult( *p_sqrt_En_fx, 26214 ), *p_prev_En_sb_fx, 6554 ) ); - } - move16(); + /**p_Enn_sm_sb = (0.15f*(*p_En)) + (0.85f*prev_En_sb[k-(BANDS-NB_SWB_SUBBANDS)]);*/ + /* 0.15: 4915.2(Q15) 0.85: 27852.80(Q15) */ + *p_Enn_sm_sb_fx = round_fx( L_mac( L_mult( *p_sqrt_En_fx, 4915 ), *p_prev_En_sb_fx, 27853 ) ); } - - p_Enn_sm_sb_fx++; - p_sqrt_En_fx++; - p_prev_En_sb_fx++; + ELSE + { + /**p_Enn_sm_sb = (0.8f*(*p_En)) + (0.2f*prev_En_sb[k-(BANDS-NB_SWB_SUBBANDS)]);*/ + /* 0.8: 26214.4(Q15) 0.2:6553.6(Q15) */ + *p_Enn_sm_sb_fx = round_fx( L_mac( L_mult( *p_sqrt_En_fx, 26214 ), *p_prev_En_sb_fx, 6554 ) ); + } + move16(); } - p_sqrt_En_fx = sqrt_En_fx; - p_Enn_sm_sb_fx = Enn_sm_sb_fx; - p_prev_En_sb_fx = prev_En_sb_fx; - map_pulse_fx[fLenLow_fx] = ( map_pulse_t_fx[fLenLow_fx] | map_pulse_t_fx[fLenLow_fx + 1] ); + p_Enn_sm_sb_fx++; + p_sqrt_En_fx++; + p_prev_En_sb_fx++; +} + +p_sqrt_En_fx = sqrt_En_fx; +p_Enn_sm_sb_fx = Enn_sm_sb_fx; +p_prev_En_sb_fx = prev_En_sb_fx; +map_pulse_fx[fLenLow_fx] = ( map_pulse_t_fx[fLenLow_fx] | map_pulse_t_fx[fLenLow_fx + 1] ); +logic16(); +move16(); +FOR( i = fLenLow_fx + 1; i < band_end_fx[BANDS_fx - 1]; i++ ) +{ + map_pulse_fx[i] = ( map_pulse_t_fx[i - 1] | map_pulse_t_fx[i] | map_pulse_t_fx[i + 1] ); logic16(); - move16(); - FOR( i = fLenLow_fx + 1; i < band_end_fx[BANDS_fx - 1]; i++ ) - { - map_pulse_fx[i] = ( map_pulse_t_fx[i - 1] | map_pulse_t_fx[i] | map_pulse_t_fx[i + 1] ); - logic16(); - logic16(); - move16(); - } - map_pulse_fx[i] = ( map_pulse_t_fx[i - 1] | map_pulse_t_fx[i] ); logic16(); move16(); +} +map_pulse_fx[i] = ( map_pulse_t_fx[i - 1] | map_pulse_t_fx[i] ); +logic16(); +move16(); - FOR( k = BANDS_fx - NB_SWB_SUBBANDS; k < BANDS_fx; k++ ) +FOR( k = BANDS_fx - NB_SWB_SUBBANDS; k < BANDS_fx; k++ ) +{ + test(); + IF( p2a_flags_fx[k] == 0 && *p_sqrt_En_fx != 0x0 ) { - test(); - IF( p2a_flags_fx[k] == 0 && *p_sqrt_En_fx != 0x0 ) - { - /*ni_scale = sqrt((*p_Enn_sm_sb)/(*p_En));*/ - /* Div Part */ - exp_normn = norm_s( *p_Enn_sm_sb_fx ); - exp_normn = sub( exp_normn, 1 ); - exp_normd = norm_s( *p_sqrt_En_fx ); - div_fx = div_s( shl( *p_Enn_sm_sb_fx, exp_normn ), shl( *p_sqrt_En_fx, exp_normd ) ); - Qdiv = add( sub( exp_normn, exp_normd ), 15 ); - - /* SQRT Part */ - sqrt_32n_16_fx( L_deposit_h( div_fx ), add( Qdiv, 16 ), &ni_scale_fx, &Qtemp ); -#ifdef BASOP_NOGLOB - ni_scale_fx = shl_o( ni_scale_fx, sub( 14, Qtemp ), &Overflow ); -#else - ni_scale_fx = shl( ni_scale_fx, sub( 14, Qtemp ) ); -#endif - ni_scale_fx = s_min( 20408, ni_scale_fx ); /* 1.25=20408.0(Q14) */ - - ni_scale_fx = s_max( 12288, ni_scale_fx ); /* 0.75=12288.0(Q14) */ - - ni_scale_fx = mult_r( ni_scale_fx, 26214 ); /* 0.8=26214.4(Q15) -> Q14 */ - FOR( i = band_start_fx[k]; i <= band_end_fx[k]; i++ ){ - IF( LE_32( L_abs( L_xSynth_har[i - fLenLow_fx] ), L_th_g[k - ( BANDS_fx - NB_SWB_SUBBANDS )] ) ){ - IF( map_pulse_fx[i] == 0 ){ - L_xSynth_har[i - fLenLow_fx] = L_shl( Mult_32_16( L_xSynth_har[i - fLenLow_fx], ni_scale_fx ), 1 ); /* Q12+Q14-15-1 = Q12 */ - move32(); - } + /*ni_scale = sqrt((*p_Enn_sm_sb)/(*p_En));*/ + /* Div Part */ + exp_normn = norm_s( *p_Enn_sm_sb_fx ); + exp_normn = sub( exp_normn, 1 ); + exp_normd = norm_s( *p_sqrt_En_fx ); + div_fx = div_s( shl( *p_Enn_sm_sb_fx, exp_normn ), shl( *p_sqrt_En_fx, exp_normd ) ); + Qdiv = add( sub( exp_normn, exp_normd ), 15 ); + + /* SQRT Part */ + sqrt_32n_16_fx( L_deposit_h( div_fx ), add( Qdiv, 16 ), &ni_scale_fx, &Qtemp ); + ni_scale_fx = shl_o( ni_scale_fx, sub( 14, Qtemp ), &Overflow ); + ni_scale_fx = s_min( 20408, ni_scale_fx ); /* 1.25=20408.0(Q14) */ + + ni_scale_fx = s_max( 12288, ni_scale_fx ); /* 0.75=12288.0(Q14) */ + + ni_scale_fx = mult_r( ni_scale_fx, 26214 ); /* 0.8=26214.4(Q15) -> Q14 */ + FOR( i = band_start_fx[k]; i <= band_end_fx[k]; i++ ){ + IF( LE_32( L_abs( L_xSynth_har[i - fLenLow_fx] ), L_th_g[k - ( BANDS_fx - NB_SWB_SUBBANDS )] ) ){ + IF( map_pulse_fx[i] == 0 ){ + L_xSynth_har[i - fLenLow_fx] = L_shl( Mult_32_16( L_xSynth_har[i - fLenLow_fx], ni_scale_fx ), 1 ); /* Q12+Q14-15-1 = Q12 */ + move32(); } } +} *p_prev_En_sb_fx = *p_Enn_sm_sb_fx; move16(); } diff --git a/lib_com/swb_tbe_com.c b/lib_com/swb_tbe_com.c index 9b20512a24e17ca91b7c39668a07e128894cf01f..105c4db1521a14414ccd68f214f4c2f619475b69 100644 --- a/lib_com/swb_tbe_com.c +++ b/lib_com/swb_tbe_com.c @@ -69,7 +69,45 @@ void GenSHBSynth_fx_32( Word32 speech_buf_32k[L_FRAME32k]; Word16 i; +#ifdef FIX_881_HILBERT_FILTER + Word16 shift = 0; + Word32 maxm32, input_synspeech_temp[L_FRAME16k]; + move16(); + + /* find the maximum value and derive the shift to improve precision of the Hilber filter */ + maxm32 = L_deposit_l( 0 ); + FOR( i = 0; i < L_FRAME16k; i++ ) + { + maxm32 = L_max( maxm32, L_abs( input_synspeech[i] ) ); + } + + FOR( i = 0; i < 2 * ALLPASSSECTIONS_STEEP; i++ ) + { + maxm32 = L_max( maxm32, L_abs( state_lsyn_filt_shb_local[i] ) ); + } + + FOR( i = 0; i < HILBERT_MEM_SIZE; i++ ) + { + maxm32 = L_max( maxm32, L_abs( Hilbert_Mem[i] ) ); + } + + IF( maxm32 != 0 ) + { + shift = sub( norm_l( maxm32 ), 3 ); + + Copy_Scale_sig32( input_synspeech, input_synspeech_temp, L_FRAME16k, shift ); + Scale_sig32( state_lsyn_filt_shb_local, 2 * ALLPASSSECTIONS_STEEP, shift ); + Scale_sig32( Hilbert_Mem, HILBERT_MEM_SIZE, shift ); + } + ELSE + { + Copy32( input_synspeech, input_synspeech_temp, L_FRAME16k ); + } + + Interpolate_allpass_steep_32( input_synspeech_temp, state_lsyn_filt_shb_local, L_FRAME16k, speech_buf_32k ); +#else Interpolate_allpass_steep_32( input_synspeech, state_lsyn_filt_shb_local, L_FRAME16k, speech_buf_32k ); +#endif IF( EQ_16( L_frame, L_FRAME ) ) { @@ -92,6 +130,15 @@ void GenSHBSynth_fx_32( } } +#ifdef FIX_881_HILBERT_FILTER + IF( maxm32 != 0 ) + { + Scale_sig32( shb_syn_speech_32k, L_FRAME32k, negate( shift ) ); + Scale_sig32( state_lsyn_filt_shb_local, 2 * ALLPASSSECTIONS_STEEP, negate( shift ) ); + Scale_sig32( Hilbert_Mem, HILBERT_MEM_SIZE, negate( shift ) ); + } +#endif + return; } void ScaleShapedSHB_32( diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index 7b64a29230c68436548d2a287fc4e0f17a99b7f1..92271c1f1f56d2dd27e163c2190496e0988c4efa 100644 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -810,6 +810,65 @@ void Calc_rc0_h( } } +void Calc_rc0_h_ivas_enc_fx( + Word16 *h, /* i : impulse response of composed filter */ + Word16 *rc0 /* o : 1st parcor */ +) +{ + Word32 L_acc; + Word16 *ptrs; + Word16 acf0, acf1; + Word16 temp, sh_acf, tmp2; + Word16 i; + + /* computation of the autocorrelation function acf */ + L_acc = L_mult( h[0], h[0] ); + FOR( i = 1; i < LONG_H_ST; i++ ) + { + tmp2 = shr( h[i], 2 ); + L_acc = L_mac( L_acc, tmp2, tmp2 ); + } + sh_acf = norm_l( L_acc ); + L_acc = L_shl( L_acc, sh_acf ); + acf0 = extract_h( L_acc ); + + ptrs = h; + + temp = *ptrs++; + move16(); + L_acc = L_mult( temp, *ptrs ); + FOR( i = 1; i < LONG_H_ST - 1; i++ ) + { + temp = shr( *ptrs++, 2 ); + move16(); + L_acc = L_mac( L_acc, temp, shr( *ptrs, 2 ) ); + } + L_acc = L_shl( L_acc, sh_acf ); + acf1 = extract_h( L_acc ); + + /* Compute 1st parcor */ + IF( acf0 == 0 ) + { + *rc0 = 0; + move16(); + return; + } + + IF( LT_16( acf0, abs_s( acf1 ) ) ) + { + *rc0 = 0; + move16(); + return; + } + *rc0 = div_s( abs_s( acf1 ), acf0 ); + move16(); + IF( acf1 > 0 ) + { + *rc0 = negate( *rc0 ); + move16(); + } +} + static void Calc_st_filt_tbe( Word16 *apond2, /* i : coefficients of numerator */ Word16 *apond1, /* i : coefficients of denominator */ @@ -868,7 +927,7 @@ static void Calc_st_filt_tbe_ivas_enc_fx( /* compute i.r. of composed filter apond2 / apond1 */ syn_filt_fx( temp, apond1, LPC_SHB_ORDER, apond2, h, LONG_H_ST, mem_zero, 0 ); /* compute 1st parcor */ - Calc_rc0_h( h, parcor0 ); + Calc_rc0_h_ivas_enc_fx( h, parcor0 ); /* compute g0 */ L_g0 = L_mult0( 1, abs_s( h[0] ) ); @@ -982,7 +1041,11 @@ 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 */ } @@ -1082,13 +1145,8 @@ static void scale_st_swb( temp = mult_r( agc_fac_para_fx, gain_fx ); /*15 +14 -15 =14 */ gain_fx = add( temp, g0_fx ); /* in Q14 */ L_temp = L_mult( gain_fx, sig_out_fx[i] ); /*14 + Q_bwe_exc-1 +1 = 14 + Q_bwe_exc */ -#ifdef BASOP_NOGLOB - L_temp = L_shl_sat( L_temp, 1 ); /*14 + Q_bwe_exc +1 */ - sig_out_fx[i] = round_fx_sat( L_temp ); /*Q_bwe_exc +15 -16 = Q_bwe_exc-1 */ -#else - L_temp = L_shl( L_temp, 1 ); /*14 + Q_bwe_exc +1 */ - sig_out_fx[i] = round_fx( L_temp ); /*Q_bwe_exc +15 -16 = Q_bwe_exc-1 */ -#endif + L_temp = L_shl_sat( L_temp, 1 ); /*14 + Q_bwe_exc +1 */ + sig_out_fx[i] = round_fx_sat( L_temp ); /*Q_bwe_exc +15 -16 = Q_bwe_exc-1 */ move16(); } *gain_prec_fx = gain_fx; @@ -1355,7 +1413,7 @@ void flip_spectrum_and_decimby4_fx( /* CALLED FROM : */ /*==========================================================================*/ -void ivas_GenShapedWBExcitation_fx( +void GenShapedWBExcitation_ivas_fx( Word16 *excSHB, /* o : synthesized shaped shb exctiation Q_bwe_exc*/ const Word16 *lpc_shb, /* i : lpc coefficients Q12*/ Word16 *exc4kWhtnd, /* o : whitened synthesized shb excitation Q_bwe_exc*/ @@ -1487,35 +1545,22 @@ void ivas_GenShapedWBExcitation_fx( n1 = norm_s( max_val ); FOR( i = 0; i < L_FRAME16k / 4; i++ ) { -#ifdef BASOP_NOGLOB excTmp2_frac[i] = shl_o( excTmp2[i], n1, &Overflow ); // Q_bwe_exc + n1 -#else - excTmp2_frac[i] = shl( excTmp2[i], n1 ); -#endif - move16(); /* Q14 */ + move16(); /* Q14 */ } n1 = sub( sub( 14, n1 ), Q_bwe_exc ); pow1 = 1; move32(); FOR( i = 0; i < L_FRAME16k / 4; i++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_mult_o( excTmp2_frac[i], excTmp2_frac[i], &Overflow ); /* Q29 */ pow1 = L_add_o( pow1, L_shr( L_tmp, 10 ), &Overflow ); /* Q22 */ -#else - L_tmp = L_mult( excTmp2_frac[i], excTmp2_frac[i] ); /* Q29 */ - pow1 = L_add( pow1, L_shr( L_tmp, 7 ) ); /* Q22 */ -#endif } } FOR( i = 0; i < L_FRAME16k / 4; i++ ) { -#ifdef BASOP_NOGLOB excNoisyEnv[i] = L_add_o( *mem_csfilt, L_mult_o( csfilt_num2[0], excTmp2[i], &Overflow ), &Overflow ); -#else - excNoisyEnv[i] = L_add( *mem_csfilt, L_mult( csfilt_num2[0], excTmp2[i] ) ); -#endif move32(); /* Q_bwe_exc+16 */ *mem_csfilt = Mult_32_16( excNoisyEnv[i], neg_csfilt_den2[1] ); move32(); /* Q_bwe_exc+16 */ @@ -1545,11 +1590,7 @@ void ivas_GenShapedWBExcitation_fx( n2 = norm_l( Lmax ); FOR( i = 0; i < L_FRAME16k / 4; i++ ) { -#ifdef BASOP_NOGLOB exc4k_frac[i] = extract_h( L_shl_o( exc4k_32[i], n2, &Overflow ) ); /* Q(14-n2) */ -#else - exc4k_frac[i] = extract_h( L_shl( exc4k_32[i], n2 ) ); /* Q(14-n2) */ -#endif move16(); } n2 = 30 - n2 - ( Q_bwe_exc + 6 ); @@ -1557,13 +1598,8 @@ void ivas_GenShapedWBExcitation_fx( move32(); FOR( i = 0; i < L_FRAME16k / 4; i++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_mult_o( exc4k_frac[i], exc4k_frac[i], &Overflow ); /* Q29 */ pow22 = L_add_o( pow22, L_shr( L_tmp, 10 ), &Overflow ); /* Q22 */ -#else - L_tmp = L_mult( exc4k_frac[i], exc4k_frac[i] ); /* Q29 */ - pow22 = L_add( pow22, L_shr( L_tmp, 7 ) ); /* Q22 */ -#endif } } @@ -1572,19 +1608,11 @@ void ivas_GenShapedWBExcitation_fx( IF( EQ_16( coder_type, UNVOICED ) || ( igf_flag != 0 && LT_16( avg_voice_fac, 6654 /* 0.2 in Q15 */ ) ) ) { L_tmp = root_a_over_b_fx( pow1, sub( 19, shl( n1, 1 ) ), pow22, sub( 19, shl( n2, 1 ) ), &exp ); -#ifdef BASOP_NOGLOB scale = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /*Q15 */ -#else - scale = round_fx( L_shl( L_tmp, exp ) ); /*Q15 */ -#endif sc = sub( add( n2, Q_bwe_exc ), 14 ); FOR( i = 0; i < L_FRAME16k / 4; i++ ) { -#ifdef BASOP_NOGLOB exc4kWhtnd[i] = round_fx_o( L_shl_o( L_mult_o( exc4k_frac[i], scale, &Overflow ), sc, &Overflow ), &Overflow ); /* Q_bwe_exc+n2-10+16+ Q_bwe_exc + n2 -14 -16 = //Q_bwe_exc */ -#else - exc4kWhtnd[i] = round_fx( L_shl( L_mult( exc4k_frac[i], scale ), sc ) ); /* Q_bwe_exc+n2-10+16+ Q_bwe_exc + n2 -14 -16 = //Q_bwe_exc */ -#endif move16(); } } @@ -1600,13 +1628,7 @@ void ivas_GenShapedWBExcitation_fx( { /*tmp_vfac = 2*voice_factors[i]; tmp_vfac = min(1, tmp_vfac);*/ -#ifdef BASOP_NOGLOB tmp_vfac = shl_o( voice_factors[i], 1, &Overflow ); -#else - BASOP_SATURATE_WARNING_OFF_EVS - tmp_vfac = shl( voice_factors[i], 1 ); - BASOP_SATURATE_WARNING_ON_EVS -#endif } ELSE { @@ -1615,29 +1637,15 @@ void ivas_GenShapedWBExcitation_fx( } Ltemp1 = root_a_fx( L_deposit_h( tmp_vfac ), 31, &exp ); -#ifdef BASOP_NOGLOB temp1 = round_fx_o( L_shl_o( Ltemp1, exp, &Overflow ), &Overflow ); /* Q15 */ -#else - temp1 = round_fx( L_shl( Ltemp1, exp ) ); /* Q15 */ -#endif - L_tmp = Mult_32_16( pow1, sub( 32767, tmp_vfac ) ); /* Q22*/ + L_tmp = Mult_32_16( pow1, sub( 32767, tmp_vfac ) ); /* Q22*/ Ltemp2 = root_a_over_b_fx( L_tmp, sub( 19, shl( n1, 1 ) ), pow22, sub( 19, shl( n2, 1 ) ), &exp ); -#ifdef BASOP_NOGLOB temp2 = round_fx_o( L_shl_o( Ltemp2, exp, &Overflow ), &Overflow ); /* Q15 */ -#else - temp2 = round_fx( L_shl( Ltemp2, exp ) ); /* Q15 */ -#endif FOR( j = 0; j < L_FRAME16k / 16; j++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_mult_o( temp1, exc4kWhtnd[k], &Overflow ); /* Q(16+Q_bwe_exc) */ L_tmp = L_add_o( L_tmp, L_shl_o( L_mult_o( temp2, exc4k_frac[k], &Overflow ), sc, &Overflow ), &Overflow ); /* Q(16+Q_bwe_exc) */ exc4kWhtnd[k] = round_fx_o( L_tmp, &Overflow ); /* Q_bwe_exc */ -#else - L_tmp = L_mult( temp1, exc4kWhtnd[k] ); /* Q(16+Q_bwe_exc) */ - L_tmp = L_add( L_tmp, L_shl( L_mult( temp2, exc4k_frac[k] ), sc ) ); /* Q(16+Q_bwe_exc) */ - exc4kWhtnd[k] = round_fx( L_tmp ); /* Q_bwe_exc */ -#endif move16(); k++; } @@ -1784,11 +1792,7 @@ void GenShapedWBExcitation_fx( n1 = norm_s( max_val ); FOR( i = 0; i < L_FRAME16k / 4; i++ ) { -#ifdef BASOP_NOGLOB excTmp2_frac[i] = shl_o( excTmp2[i], n1, &Overflow ); -#else - excTmp2_frac[i] = shl( excTmp2[i], n1 ); -#endif move16(); /* Q14 */ } n1 = sub( sub( 14, n1 ), Q_bwe_exc ); @@ -1796,23 +1800,14 @@ void GenShapedWBExcitation_fx( move32(); FOR( i = 0; i < L_FRAME16k / 4; i++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_mult_o( excTmp2_frac[i], excTmp2_frac[i], &Overflow ); /* Q29 */ pow1 = L_add_o( pow1, L_shr( L_tmp, 7 ), &Overflow ); /* Q22 */ -#else - L_tmp = L_mult( excTmp2_frac[i], excTmp2_frac[i] ); /* Q29 */ - pow1 = L_add( pow1, L_shr( L_tmp, 7 ) ); /* Q22 */ -#endif } } FOR( i = 0; i < L_FRAME16k / 4; i++ ) { -#ifdef BASOP_NOGLOB excNoisyEnv[i] = L_add_o( *mem_csfilt, L_mult_o( csfilt_num2[0], excTmp2[i], &Overflow ), &Overflow ); -#else - excNoisyEnv[i] = L_add( *mem_csfilt, L_mult( csfilt_num2[0], excTmp2[i] ) ); -#endif move32(); /* Q_bwe_exc+16 */ *mem_csfilt = Mpy_32_16_1( excNoisyEnv[i], neg_csfilt_den2[1] ); move32(); /* Q_bwe_exc+16 */ @@ -1843,11 +1838,7 @@ void GenShapedWBExcitation_fx( n2 = norm_l( Lmax ); FOR( i = 0; i < L_FRAME16k / 4; i++ ) { -#ifdef BASOP_NOGLOB exc4k_frac[i] = extract_h( L_shl_o( exc4k_32[i], n2, &Overflow ) ); /* Q(14-n2) */ -#else - exc4k_frac[i] = extract_h( L_shl( exc4k_32[i], n2 ) ); /* Q(14-n2) */ -#endif move16(); } n2 = sub( sub( 30, n2 ), add( Q_bwe_exc, 6 ) ); @@ -1855,13 +1846,8 @@ void GenShapedWBExcitation_fx( move32(); FOR( i = 0; i < L_FRAME16k / 4; i++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_mult_o( exc4k_frac[i], exc4k_frac[i], &Overflow ); /* Q29 */ pow22 = L_add_o( pow22, L_shr( L_tmp, 7 ), &Overflow ); /* Q22 */ -#else - L_tmp = L_mult( exc4k_frac[i], exc4k_frac[i] ); /* Q29 */ - pow22 = L_add( pow22, L_shr( L_tmp, 7 ) ); /* Q22 */ -#endif } } @@ -1870,19 +1856,11 @@ void GenShapedWBExcitation_fx( IF( EQ_16( coder_type, UNVOICED ) || ( igf_flag != 0 && LT_16( avg_voice_fac, 6654 /*0.2 in Q15 */ ) ) ) { L_tmp = root_a_over_b_fx( pow1, sub( 22, shl( n1, 1 ) ), pow22, sub( 22, shl( n2, 1 ) ), &exp ); -#ifdef BASOP_NOGLOB scale = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /*Q15 */ -#else - scale = round_fx( L_shl( L_tmp, exp ) ); /*Q15 */ -#endif sc = sub( add( n2, Q_bwe_exc ), 14 ); FOR( i = 0; i < L_FRAME16k / 4; i++ ) { -#ifdef BASOP_NOGLOB exc4kWhtnd[i] = round_fx_o( L_shl_o( L_mult_o( exc4k_frac[i], scale, &Overflow ), sc, &Overflow ), &Overflow ); /* Q_bwe_exc+n2-10+16+ Q_bwe_exc + n2 -14 -16 = //Q_bwe_exc */ -#else - exc4kWhtnd[i] = round_fx( L_shl( L_mult( exc4k_frac[i], scale ), sc ) ); /* Q_bwe_exc+n2-10+16+ Q_bwe_exc + n2 -14 -16 = //Q_bwe_exc */ -#endif move16(); } } @@ -1899,13 +1877,7 @@ void GenShapedWBExcitation_fx( { /*tmp_vfac = 2*voice_factors[i]; tmp_vfac = min(1, tmp_vfac);*/ -#ifdef BASOP_NOGLOB tmp_vfac = shl_o( voice_factors[i], 1, &Overflow ); -#else - BASOP_SATURATE_WARNING_OFF_EVS - tmp_vfac = shl( voice_factors[i], 1 ); - BASOP_SATURATE_WARNING_ON_EVS -#endif } ELSE { @@ -1914,29 +1886,15 @@ void GenShapedWBExcitation_fx( } Ltemp1 = root_a_fx( L_deposit_h( tmp_vfac ), 31, &exp ); -#ifdef BASOP_NOGLOB temp1 = round_fx_o( L_shl_o( Ltemp1, exp, &Overflow ), &Overflow ); /* Q15 */ -#else - temp1 = round_fx( L_shl( Ltemp1, exp ) ); /* Q15 */ -#endif - L_tmp = Mpy_32_16_1( pow1, sub( 32767, tmp_vfac ) ); /* Q22*/ + L_tmp = Mpy_32_16_1( pow1, sub( 32767, tmp_vfac ) ); /* Q22*/ Ltemp2 = root_a_over_b_fx( L_tmp, sub( 22, shl( n1, 1 ) ), pow22, sub( 22, shl( n2, 1 ) ), &exp ); -#ifdef BASOP_NOGLOB temp2 = round_fx_o( L_shl_o( Ltemp2, exp, &Overflow ), &Overflow ); /* Q15 */ -#else - temp2 = round_fx( L_shl( Ltemp2, exp ) ); /* Q15 */ -#endif FOR( j = 0; j < L_FRAME16k / 16; j++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_mult_o( temp1, exc4kWhtnd[k], &Overflow ); /* Q(16+Q_bwe_exc) */ L_tmp = L_add_o( L_tmp, L_shl_o( L_mult_o( temp2, exc4k_frac[k], &Overflow ), sc, &Overflow ), &Overflow ); /* Q(16+Q_bwe_exc) */ exc4kWhtnd[k] = round_fx_o( L_tmp, &Overflow ); /* Q_bwe_exc */ -#else - L_tmp = L_mult( temp1, exc4kWhtnd[k] ); /* Q(16+Q_bwe_exc) */ - L_tmp = L_add( L_tmp, L_shl( L_mult( temp2, exc4k_frac[k] ), sc ) ); /* Q(16+Q_bwe_exc) */ - exc4kWhtnd[k] = round_fx( L_tmp ); /* Q_bwe_exc */ -#endif move16(); k = add( k, 1 ); } @@ -1950,7 +1908,6 @@ void GenShapedWBExcitation_fx( return; } - /*-------------------------------------------------------------------* * GenWBSynth() * @@ -2277,11 +2234,7 @@ void GenShapedSHBExcitation_fx( /* Estimate pow1 associated with Low band nonlinear extended excitation */ /* pow1=0.00001f */ tmp = sub( shl( *Q_bwe_exc, 1 ), 31 ); -#ifdef BASOP_NOGLOB pow1 = L_shl_sat( 21475l /*0.00001f Q31*/, tmp ); /* 0.00001f in 2*(Q_bwe_exc) */ -#else - pow1 = L_shl( 21475l /*0.00001f Q31*/, tmp ); /* 0.00001f in 2*(Q_bwe_exc) */ -#endif FOR( k = 0; k < L_FRAME16k; k++ ) { /*excTmp2[k ] = (float)(fabs(exc16kWhtnd[k]));*/ @@ -2289,11 +2242,7 @@ void GenShapedSHBExcitation_fx( move16(); /* pow1 += exc16kWhtnd[k] * exc16kWhtnd[k]; */ -#ifdef BASOP_NOGLOB pow1 = L_mac0_sat( pow1, exc16kWhtnd[k], exc16kWhtnd[k] ); /* 2*Q_bwe_exc */ -#else - pow1 = L_mac0( pow1, exc16kWhtnd[k], exc16kWhtnd[k] ); /* 2*Q_bwe_exc */ -#endif } Q_pow1 = shl( *Q_bwe_exc, 1 ); @@ -2455,11 +2404,7 @@ void GenShapedSHBExcitation_fx( tmp = add( *Q_bwe_exc, 1 ); FOR( k = 0; k < L_FRAME16k; k++ ) { -#ifdef BASOP_NOGLOB L_tmp4 = L_shl_sat( L_deposit_l( White_exc16k[k] ), tmp ); -#else - L_tmp4 = L_shl( L_deposit_l( White_exc16k[k] ), tmp ); -#endif if ( excNoisyEnv[k] != 0 ) { L_tmp4 = L_mult( excNoisyEnv[k], White_exc16k[k] ); /* (Q_bwe_exc) +5 +1*/ @@ -2491,11 +2436,7 @@ void GenShapedSHBExcitation_fx( /* i: White_exc16k in Q6 */ /* o: White_exc16k in (Q_bwe_exc-NOISE_QADJ) */ /* pow22 += White_exc16k[k] * White_exc16k[k]; */ -#ifdef BASOP_NOGLOB pow22 = L_mac0_sat( pow22, White_exc16k[k], White_exc16k[k] ); /* 2*(Q_bwe_exc-NOISE_QADJ)*/ -#else - pow22 = L_mac0( pow22, White_exc16k[k], White_exc16k[k] ); /* 2*(Q_bwe_exc-NOISE_QADJ)*/ -#endif } /*Q_pow22 = sub( shl(*Q_bwe_exc,1), 18 );*/ Q_pow22 = shl( sub( *Q_bwe_exc, NOISE_QADJ ), 1 ); @@ -2716,11 +2657,7 @@ void GenShapedSHBExcitation_fx( #endif { L_tmp = root_a_over_b_fx( pow1, Q_pow1, pow22, Q_pow22, &exp ); -#ifdef BASOP_NOGLOB scale = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /*Q15 */ -#else - scale = round_fx( L_shl( L_tmp, exp ) ); /*Q15 */ -#endif FOR( k = 0; k < L_FRAME16k; k++ ) { /* White_exc16k: (Q_bwe_exc-NOISE_QADJ), scale: Q15 */ @@ -2768,11 +2705,7 @@ void GenShapedSHBExcitation_fx( temp = sub( MAX_16, temp ); tempQ31 = Mult_32_16( pow1, temp ); L_tmp = root_a_over_b_fx( tempQ31, Q_pow1, pow22, Q_pow22, &exp ); -#ifdef BASOP_NOGLOB temp2 = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q15 whiteEnvShapedExc scale factor */ -#else - temp2 = round_fx( L_shl( L_tmp, exp ) ); /* Q15 whiteEnvShapedExc scale factor */ -#endif } ELSE { @@ -2791,24 +2724,15 @@ void GenShapedSHBExcitation_fx( temp = sub( MAX_16, vf_tmp ); tempQ31 = Mult_32_16( pow1, temp ); L_tmp = root_a_over_b_fx( tempQ31, Q_pow1, pow22, Q_pow22, &exp ); -#ifdef BASOP_NOGLOB temp2 = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q15 whiteEnvShapedExc scale factor */ -#else - temp2 = round_fx( L_shl( L_tmp, exp ) ); /* Q15 whiteEnvShapedExc scale factor */ -#endif } 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)*/ -#ifdef BASOP_NOGLOB - L_tmp = L_shl_sat( L_tmp, NOISE_QADJ ); /* 16+(Q_bwe_exc) */ + L_tmp = L_shl_sat( L_tmp, NOISE_QADJ ); /* 16+(Q_bwe_exc) */ exc16kWhtnd[k + j] = mac_r_sat( L_tmp, temp1, exc16kWhtnd[k + j] ); -#else - L_tmp = L_shl( L_tmp, NOISE_QADJ ); /* 16+(Q_bwe_exc) */ - exc16kWhtnd[k + j] = mac_r( L_tmp, temp1, exc16kWhtnd[k + j] ); -#endif move16(); /* Q_bwe_exc */ } @@ -2977,17 +2901,20 @@ void GenShapedSHBExcitation_ivas_enc_fx( Word16 *Q_bwe_exc, Word16 *Q_bwe_exc_fb, const Word16 Q_shb, - Word16 n_mem2, /* i : n_mem2 scale factor to adjust 24.4/32kbps memories */ - Word16 prev_Q_bwe_syn, /* i : st_fx->prev_Q_bwe_syn */ - const Word32 bitrate, /* i : bitrate */ - const Word16 prev_bfi, /* i : previous frame was concealed */ - const Word16 element_mode, /* i : element mode */ - const Word16 flag_ACELP16k, /* i : ACELP@16kHz flag */ - Word16 *nlExc16k, /* i/o: NL exc for IC-BWE */ - Word16 *mixExc16k, /* i/o: exc spreading for IC-BWE */ - const Word32 extl_brate, /* i : extension layer bitarte */ - const Word16 MSFlag, /* i : Multi Source flag */ - Word16 EnvSHBres_4k[], /* i/o: TD envelope of the SHB residual signal */ + Word16 n_mem2, /* i : n_mem2 scale factor to adjust 24.4/32kbps memories */ + Word16 prev_Q_bwe_syn, /* i : st_fx->prev_Q_bwe_syn */ + const Word32 bitrate, /* i : bitrate */ + const Word16 prev_bfi, /* i : previous frame was concealed */ + const Word16 element_mode, /* i : element mode */ + const Word16 flag_ACELP16k, /* i : ACELP@16kHz flag */ + Word16 *nlExc16k, /* i/o: NL exc for IC-BWE */ + Word16 *nlExc16k_e, /* i/o: exp of nlExc16k */ + Word16 *mixExc16k, /* i/o: exc spreading for IC-BWE */ + Word16 *mixExc16k_e, /* i/o: exp of mixExc16k_fx */ + const Word32 extl_brate, /* i : extension layer bitarte */ + const Word16 MSFlag, /* i : Multi Source flag */ + Word16 EnvSHBres_4k[], /* i/o: TD envelope of the SHB residual signal */ + Word16 Q_EnvSHBres_4k, Word32 *prev_pow_exc16kWhtnd, /* i/o: power of the LB excitation signal in the previous frame */ Word16 *prev_mix_factor, /* i/o: mixing factor in the previous frame */ Word16 *Env_error, /* o : error in SHB residual envelope modelling Q0 */ @@ -3007,6 +2934,7 @@ void GenShapedSHBExcitation_ivas_enc_fx( Word16 excTmp2[L_FRAME16k]; Word16 *White_exc16k; + Word16 Q_White_exc16k; Word16 excNoisyEnv[L_FRAME16k]; Word16 csfilt_num2[1] = { 6554 }; /*0.2 in Q15 */ move16(); @@ -3034,7 +2962,6 @@ void GenShapedSHBExcitation_ivas_enc_fx( Word16 White_exc16k_FB_temp[L_FRAME16k]; Word32 White_exc16k_32[L_FRAME16k]; Word16 White_exc16k_tmp[L_FRAME16k]; - Word16 Q_temp; Word16 prev_Q_bwe_exc_fb; Word16 chk1, chk2; chk1 = 0; @@ -3114,11 +3041,7 @@ void GenShapedSHBExcitation_ivas_enc_fx( /* Estimate pow1 associated with Low band nonlinear extended excitation */ /* pow1=0.00001f */ tmp = sub( shl( *Q_bwe_exc, 1 ), 31 ); -#ifdef BASOP_NOGLOB pow1 = L_shl_sat( 21475l /*0.00001f Q31*/, tmp ); /* 0.00001f in 2*(Q_bwe_exc) */ -#else - pow1 = L_shl( 21475l /*0.00001f Q31*/, tmp ); /* 0.00001f in 2*(Q_bwe_exc) */ -#endif FOR( k = 0; k < L_FRAME16k; k++ ) { /*excTmp2[k ] = (float)(fabs(exc16kWhtnd[k]));*/ @@ -3127,11 +3050,7 @@ void GenShapedSHBExcitation_ivas_enc_fx( chk1 = s_or( chk1, exc16kWhtnd[k] ); /* pow1 += exc16kWhtnd[k] * exc16kWhtnd[k]; */ -#ifdef BASOP_NOGLOB pow1 = L_mac0_sat( pow1, exc16kWhtnd[k], exc16kWhtnd[k] ); /* 2*Q_bwe_exc */ -#else - pow1 = L_mac0( pow1, exc16kWhtnd[k], exc16kWhtnd[k] ); /* 2*Q_bwe_exc */ -#endif } Q_pow1 = shl( *Q_bwe_exc, 1 ); @@ -3232,7 +3151,6 @@ void GenShapedSHBExcitation_ivas_enc_fx( } White_exc16k = exc16k; - move16(); Word16 Q_excTmp2 = add( getScaleFactor16( excTmp2, L_FRAME16k ), *Q_bwe_exc ); IF( *mem_csfilt ) { @@ -3311,12 +3229,12 @@ void GenShapedSHBExcitation_ivas_enc_fx( /* generate gaussian (white) excitation */ FOR( k = 0; k < L_FRAME16k; k++ ) { - White_exc16k[k] = own_random( &bwe_seed[0] ); + White_exc16k[k] = own_random( &bwe_seed[0] ); // Q0 move16(); } /* 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; // Q31 move32(); move32(); pow22 = POW_EXC16k_WHTND_FX; @@ -3332,27 +3250,20 @@ void GenShapedSHBExcitation_ivas_enc_fx( // v_multc_fixed_16_16(White_exc16k, round_fx(temp_pow), White_exc16k, L_FRAME16k); L_tmp = 0; move32(); + Q_White_exc16k = add( getScaleFactor16( White_exc16k, L_FRAME16k ), norm_l( temp_pow ) ); FOR( k = 0; k < L_FRAME16k; k++ ) { - White_exc16k_32[k] = Mpy_32_16_1( temp_pow, White_exc16k[k] ); + White_exc16k_32[k] = Mpy_32_16_1( temp_pow, White_exc16k[k] ); // Q31 + Q0 - Q15 = Q16 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], Q_White_exc16k ) ); // Q16 + Q_White_exc16k - Q16 = Q_White_exc16k move16(); L_tmp = L_max( L_tmp, L_abs( White_exc16k_32[k] ) ); } - Q_temp = norm_l( L_tmp ); - IF( L_tmp == 0 ) - { - Q_temp = 31; - move16(); - } } ELSE #endif { /* create a random excitation - Reuse exc16k memory */ - White_exc16k = exc16k; - move16(); create_random_vector_fx( White_exc16k, L_FRAME, bwe_seed ); // Q5 create_random_vector_fx( White_exc16k + L_FRAME, L_FRAME16k - L_FRAME, bwe_seed ); // Q5 @@ -3365,12 +3276,6 @@ void GenShapedSHBExcitation_ivas_enc_fx( move32(); L_tmp = L_max( L_tmp, L_abs( White_exc16k_32[k] ) ); } - Q_temp = norm_l( L_tmp ); - IF( L_tmp == 0 ) - { - Q_temp = 31; - move16(); - } /*Copy_Scale_sig( White_exc16k, White_exc16k, L_FRAME16k, sub(NOISE_QFAC, 5) );)*/ /* White_exc16k in Q6 */ @@ -3378,22 +3283,23 @@ void GenShapedSHBExcitation_ivas_enc_fx( /* pow22=0.00001f */ tmp = sub( shl( sub( *Q_bwe_exc, NOISE_QADJ ), 1 ), 31 ); 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 + 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 move16(); chk2 = s_or( chk2, White_exc16k[k] ); /* i: excNoisyEnv in (Q_excTmp2) */ /* i: White_exc16k in Q6 */ /* o: White_exc16k in (Q_bwe_exc-NOISE_QADJ) */ /* pow22 += White_exc16k[k] * White_exc16k[k]; */ - sum = W_mac0_16_16( sum, 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)*/ } Q_pow22 = W_norm( sum ); - pow22 = W_extract_h( W_shl( sum, Q_pow22 ) ); // 2*(Q_excTmp2-NOISE_QADJ)+Q_pow22-32 - Q_pow22 = sub( add( Q_pow22, shl( sub( Q_excTmp2, NOISE_QADJ ), 1 ) ), 32 ); - Scale_sig( White_exc16k, L_FRAME16k, sub( *Q_bwe_exc, Q_excTmp2 ) ); + 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 @@ -3415,7 +3321,7 @@ void GenShapedSHBExcitation_ivas_enc_fx( { FOR( k = 0; k < L_FRAME16k; k++ ) { - White_exc16k_tmp[k] = round_fx( L_shl( White_exc16k_32[k], *Q_bwe_exc ) ); + White_exc16k_tmp[k] = shl( White_exc16k[k], sub( *Q_bwe_exc, Q_White_exc16k ) ); move16(); } @@ -3441,8 +3347,8 @@ void GenShapedSHBExcitation_ivas_enc_fx( move32(); temp1 = add( shl( *Q_bwe_exc, 1 ), 1 ); - temp2 = add( add( Q_shb, *Q_bwe_exc ), 1 ); - temp3 = add( shl( Q_shb, 1 ), 1 ); + temp2 = add( add( Q_EnvSHBres_4k, *Q_bwe_exc ), 1 ); + temp3 = add( shl( Q_EnvSHBres_4k, 1 ), 1 ); FOR( i = 0; i < NUM_SHB_SUBGAINS; i++ ) { // c0_part[i] = sum2_f( &EnvExc16kWhtnd_4k[i * L_FRAME4k / NUM_SHB_SUBGAINS], L_FRAME4k / NUM_SHB_SUBGAINS ); @@ -3574,6 +3480,9 @@ void GenShapedSHBExcitation_ivas_enc_fx( { // g = 1.0f; g = MAX16B; /* Q15 */ + move16(); + g_e = 0; + move16(); } // else if ( g < shl( delta, ( 15 - g_e ) - 14 ) ) ELSE IF( BASOP_Util_Cmp_Mant32Exp( g, add( 16, g_e ), delta, 17 ) < 0 ) @@ -3581,8 +3490,12 @@ void GenShapedSHBExcitation_ivas_enc_fx( /* prevent low gains to be quantized to 0 as this is reserved for plosives */ // g = delta; g = shl( delta, 1 ); /* Q15 */ + g_e = 0; + move16(); } + g = shl_sat( g, g_e ); /* Q15 */ + *vf_ind = usquant_fx( g, &mix_factor, 0, delta, cbsize ); move16(); } @@ -3617,7 +3530,7 @@ void GenShapedSHBExcitation_ivas_enc_fx( #endif { Estimate_mix_factors_fx( shb_res, Q_shb, exc16kWhtnd, *Q_bwe_exc, White_exc16k, - ( *Q_bwe_exc - NOISE_QADJ ), pow1, Q_pow1, pow22, Q_pow22, voiceFacEst, vf_ind ); + Q_White_exc16k, pow1, Q_pow1, pow22, Q_pow22, voiceFacEst, vf_ind ); tmp = voiceFacEst[0]; tmp2 = MAX_16; move16(); @@ -3680,13 +3593,16 @@ void GenShapedSHBExcitation_ivas_enc_fx( move16(); } } -#if 1 // def ADD_IVAS_TBE_CODE +#if 1 // def ADD_IVAS_TBE_CODE + Scale_sig( White_exc16k, L_FRAME16k, sub( *Q_bwe_exc, Q_White_exc16k ) ); // Q_bwe_exc test(); IF( GE_16( element_mode, IVAS_CPE_DFT ) && nlExc16k != NULL ) { /* save buffers for IC-BWE */ // mvr2r(exc16kWhtnd, nlExc16k, L_FRAME16k); Copy( exc16kWhtnd, nlExc16k, L_FRAME16k ); + *nlExc16k_e = sub( 15, *Q_bwe_exc ); + move16(); // v_multc(White_exc16k, (float)sqrt(pow1 / pow22), mixExc16k, L_FRAME16k); /*Word16 temp_fac = divide3232(L_shr(pow1, Q_pow1), pow22); Word16 temp_fac_exp = 0; @@ -3696,24 +3612,27 @@ void GenShapedSHBExcitation_ivas_enc_fx( // 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( White_exc16k[k], temp_fac ); // Q_bwe_exc move16(); } + *mixExc16k_e = sub( 15, *Q_bwe_exc ); + 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_bwe_exc */ + move16(); } 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_bwe_exc; move16(); + 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) */ + /* i/o: White_exc16k (Q_bwe_exc) */ + /* i: tbe_demph (Q_bwe_exc) */ #if 1 // def ADD_IVAS_TBE_CODE test(); @@ -3728,34 +3647,39 @@ void GenShapedSHBExcitation_ivas_enc_fx( // old_scale = Sqrt16(old_scale, &old_scale_exp); // old_scale = shl(old_scale, old_scale_exp); //Q15 L_tmp = root_a_over_b_fx( *prev_pow_exc16kWhtnd, 0, pow1, Q_pow1, &exp ); - old_scale = round_fx_sat( L_shl_sat( L_tmp, exp ) ); // Q15 + IF( exp < 0 ) + { + L_tmp = L_shl( L_tmp, exp ); + exp = 0; + move16(); + } + old_scale = round_fx_sat( L_tmp ); // exp // new_scale = 1.0f; - new_scale = 32767; - move16(); + new_scale = shr( 32767, exp ); // exp // step_scale = (new_scale - old_scale) / (L_FRAME16k / 2); - step_scale = mult_r( sub( new_scale, old_scale ), 205 ); - scale = old_scale; + step_scale = mult_r( sub( new_scale, old_scale ), 205 ); // exp + scale = old_scale; // exp move16(); /* interpolate between the old and the new value of the mixing factor */ - old_fact = *prev_mix_factor; + old_fact = *prev_mix_factor; // Q15 move16(); - new_fact = mix_factor; + new_fact = mix_factor; // Q15 move16(); // step = (new_fact - old_fact) / (L_FRAME16k / 2); - step = mult_r( sub( new_fact, old_fact ), 205 ); - fact = old_fact; + step = mult_r( sub( new_fact, old_fact ), 205 ); // Q15 + fact = old_fact; // Q15 move16(); /* 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 ); + L_tmp = L_add_sat( L_shl_sat( L_mult( fact, mult_r( White_exc16k[k], scale ) ), exp ), // Q15 + Q_bwe_exc + (Q15-exp) - Q15 + exp + Q1 + L_mult( sub( 32767, fact ), exc16kWhtnd[k] ) ); // Q_bwe_exc + Q16 + exc16kWhtnd[k] = round_fx_sat( L_tmp ); // Q_bwe_exc move16(); - fact = add_sat( fact, step ); - scale = add_sat( scale, step_scale ); + fact = add_sat( fact, step ); // Q15 + scale = add_sat( scale, step_scale ); // exp } /* mixing of LB and gaussian excitation in the second half of the frame */ @@ -3763,14 +3687,14 @@ void GenShapedSHBExcitation_ivas_enc_fx( { // 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 ); + L_tmp = L_add( L_mult( new_fact, White_exc16k[k] ), + mult_r( sub( 32767, new_fact ), exc16kWhtnd[k] ) ); // Q_bwe_exc + Q15 + Q1 => Q_bwe_exc + Q16 + exc16kWhtnd[k] = round_fx( L_tmp ); // Q_bwe_exc move16(); } } // preemph(exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph); - PREEMPH_FX( exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph ); + PREEMPH_FX( exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph ); // Q_bwe_exc } ELSE #endif @@ -3789,21 +3713,17 @@ void GenShapedSHBExcitation_ivas_enc_fx( L_tmp = 0; move32(); } -#ifdef BASOP_NOGLOB scale = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /*Q15 */ -#else - scale = round_fx( L_shl( L_tmp, exp ) ); /*Q15 */ -#endif 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 = L_mult( White_exc16k[k], scale ); // Q_bwe_exc + Q15 + Q1 => Q_bwe_exc + Q16 /* L_tmp: (Q_bwe_exc-NOISE_QADJ) + 15 + 1 */ - exc16kWhtnd[k] = round_fx_sat( L_shl_sat( L_tmp, NOISE_QADJ ) ); + exc16kWhtnd[k] = round_fx_sat( L_tmp ); // Q_bwe_exc move16(); /* exc16kWhtnd: Q_bwe_exc */ } - PREEMPH_FX( exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph ); + PREEMPH_FX( exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph ); // Q_bwe_exc /* i/o: exc16kWhtnd (Q_bwe_exc) */ /* i/o: tbe_premph (Q_bwe_exc) */ } @@ -3843,11 +3763,7 @@ void GenShapedSHBExcitation_ivas_enc_fx( temp = sub( MAX_16, temp ); tempQ31 = Mult_32_16( pow1, temp ); L_tmp = root_a_over_b_fx( tempQ31, Q_pow1, pow22, Q_pow22, &exp ); -#ifdef BASOP_NOGLOB temp2 = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q15 whiteEnvShapedExc scale factor */ -#else - temp2 = round_fx( L_shl( L_tmp, exp ) ); /* Q15 whiteEnvShapedExc scale factor */ -#endif } ELSE { @@ -3866,24 +3782,14 @@ void GenShapedSHBExcitation_ivas_enc_fx( temp = sub( MAX_16, vf_tmp ); tempQ31 = Mult_32_16( pow1, temp ); L_tmp = root_a_over_b_fx( tempQ31, Q_pow1, pow22, Q_pow22, &exp ); -#ifdef BASOP_NOGLOB temp2 = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q15 whiteEnvShapedExc scale factor */ -#else - temp2 = round_fx( L_shl( L_tmp, exp ) ); /* Q15 whiteEnvShapedExc scale factor */ -#endif } 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)*/ -#ifdef BASOP_NOGLOB - L_tmp = L_shl_sat( L_tmp, NOISE_QADJ ); /* 16+(Q_bwe_exc) */ - exc16kWhtnd[k + j] = mac_r_sat( L_tmp, temp1, exc16kWhtnd[k + j] ); -#else - L_tmp = L_shl( L_tmp, NOISE_QADJ ); /* 16+(Q_bwe_exc) */ - exc16kWhtnd[k + j] = mac_r( L_tmp, temp1, exc16kWhtnd[k + j] ); -#endif + L_tmp = L_mult( temp2, White_exc16k[k + j] ); /* 16+(Q_bwe_exc)*/ + exc16kWhtnd[k + j] = mac_r_sat( L_tmp, temp1, exc16kWhtnd[k + j] ); // Q_bwe_exc move16(); /* Q_bwe_exc */ } @@ -3900,7 +3806,7 @@ void GenShapedSHBExcitation_ivas_enc_fx( temp = div_s( temp, temp2 ); /* Q15 */ temp = mult_r( PREEMPH_FAC, temp ); - PREEMPH_FX( &exc16kWhtnd[i * lSubFr], temp, lSubFr, tbe_premph ); + PREEMPH_FX( &exc16kWhtnd[i * lSubFr], temp, lSubFr, tbe_premph ); // Q_bwe_exc /* exc16kWhtnd: Q_bwe_exc; tbe_premph: Q_bwe_exc*/ } @@ -4214,11 +4120,7 @@ void GenShapedSHBExcitation_ivas_dec_fx( /* Estimate pow1 associated with Low band nonlinear extended excitation */ /* pow1=0.00001f */ tmp = sub( shl( *Q_bwe_exc, 1 ), 31 ); -#ifdef BASOP_NOGLOB pow1 = L_shl_sat( 21475l /*0.00001f Q31*/, tmp ); /* 0.00001f in 2*(Q_bwe_exc) */ -#else - pow1 = L_shl( 21475l /*0.00001f Q31*/, tmp ); /* 0.00001f in 2*(Q_bwe_exc) */ -#endif FOR( k = 0; k < L_FRAME16k; k++ ) { /*excTmp2[k ] = (float)(fabs(exc16kWhtnd[k]));*/ @@ -4227,11 +4129,7 @@ void GenShapedSHBExcitation_ivas_dec_fx( chk1 = s_or( chk1, exc16kWhtnd[k] ); /* pow1 += exc16kWhtnd[k] * exc16kWhtnd[k]; */ -#ifdef BASOP_NOGLOB pow1 = L_mac0_sat( pow1, exc16kWhtnd[k], exc16kWhtnd[k] ); /* 2*Q_bwe_exc */ -#else - pow1 = L_mac0( pow1, exc16kWhtnd[k], exc16kWhtnd[k] ); /* 2*Q_bwe_exc */ -#endif } Q_pow1 = shl( *Q_bwe_exc, 1 ); @@ -4488,11 +4386,7 @@ void GenShapedSHBExcitation_ivas_dec_fx( /* i: White_exc16k in Q6 */ /* o: White_exc16k in (Q_bwe_exc-NOISE_QADJ) */ /* pow22 += White_exc16k[k] * White_exc16k[k]; */ -#ifdef BASOP_NOGLOB pow22 = L_mac0_sat( pow22, White_exc16k[k], White_exc16k[k] ); /* 2*(Q_excTmp2-NOISE_QADJ)*/ -#else - pow22 = L_mac0( pow22, White_exc16k[k], White_exc16k[k] ); /* 2*(Q_bwe_exc-NOISE_QADJ)*/ -#endif } /*Q_pow22 = sub( shl(*Q_bwe_exc,1), 18 );*/ Q_pow22 = shl( sub( Q_excTmp2, NOISE_QADJ ), 1 ); @@ -4892,11 +4786,7 @@ void GenShapedSHBExcitation_ivas_dec_fx( L_tmp = 0; move32(); } -#ifdef BASOP_NOGLOB scale = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /*Q15 */ -#else - scale = round_fx( L_shl( L_tmp, exp ) ); /*Q15 */ -#endif FOR( k = 0; k < L_FRAME16k; k++ ) { /* White_exc16k: (Q_bwe_exc-NOISE_QADJ), scale: Q15 */ @@ -4946,11 +4836,7 @@ void GenShapedSHBExcitation_ivas_dec_fx( temp = sub( MAX_16, temp ); tempQ31 = Mult_32_16( pow1, temp ); L_tmp = root_a_over_b_fx( tempQ31, Q_pow1, pow22, Q_pow22, &exp ); -#ifdef BASOP_NOGLOB temp2 = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q15 whiteEnvShapedExc scale factor */ -#else - temp2 = round_fx( L_shl( L_tmp, exp ) ); /* Q15 whiteEnvShapedExc scale factor */ -#endif } ELSE { @@ -4969,24 +4855,15 @@ void GenShapedSHBExcitation_ivas_dec_fx( temp = sub( MAX_16, vf_tmp ); tempQ31 = Mult_32_16( pow1, temp ); L_tmp = root_a_over_b_fx( tempQ31, Q_pow1, pow22, Q_pow22, &exp ); -#ifdef BASOP_NOGLOB temp2 = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q15 whiteEnvShapedExc scale factor */ -#else - temp2 = round_fx( L_shl( L_tmp, exp ) ); /* Q15 whiteEnvShapedExc scale factor */ -#endif } 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)*/ -#ifdef BASOP_NOGLOB - L_tmp = L_shl_sat( L_tmp, NOISE_QADJ ); /* 16+(Q_bwe_exc) */ + L_tmp = L_shl_sat( L_tmp, NOISE_QADJ ); /* 16+(Q_bwe_exc) */ exc16kWhtnd[k + j] = mac_r_sat( L_tmp, temp1, exc16kWhtnd[k + j] ); -#else - L_tmp = L_shl( L_tmp, NOISE_QADJ ); /* 16+(Q_bwe_exc) */ - exc16kWhtnd[k + j] = mac_r( L_tmp, temp1, exc16kWhtnd[k + j] ); -#endif move16(); /* Q_bwe_exc */ } @@ -5672,42 +5549,27 @@ void ScaleShapedWB_fx( FOR( i = 0; i < l_shb_lahead; i++ ) { /* mod_syn in (16+Q_bwe_exc), frame_gain in Q18 */ - L_tmp = Mult_32_32( mod_syn[i], frame_gain ); /* L_tmp in (Q_bwe_exc+3) */ -#ifdef BASOP_NOGLOB + L_tmp = Mult_32_32( mod_syn[i], frame_gain ); /* L_tmp in (Q_bwe_exc+3) */ synSHB[i] = round_fx_sat( L_shl_sat( Mult_32_16( L_tmp, win[i] ), shift ) ); /* Qx */ move16(); synSHB[i] = add_sat( synSHB[i], overlap[i] ); move16(); /* Qx */ synSHB[i + l_shb_lahead] = round_fx_sat( L_shl_sat( L_tmp, shift ) ); /* Qx */ move16(); -#else - synSHB[i] = round_fx( L_shl( Mult_32_16( L_tmp, win[i] ), shift ) ); /* Qx */ - synSHB[i] = add( synSHB[i], overlap[i] ); - move16(); /* Qx */ - synSHB[i + l_shb_lahead] = round_fx( L_shl( L_tmp, shift ) ); /* Qx */ -#endif } FOR( ; i < l_frame; i++ ) { - L_tmp = Mult_32_32( mod_syn[i], frame_gain ); /* L_tmp in (Q_bwe_exc+3) */ -#ifdef BASOP_NOGLOB + L_tmp = Mult_32_32( mod_syn[i], frame_gain ); /* L_tmp in (Q_bwe_exc+3) */ synSHB[i] = round_fx_sat( L_shl_sat( L_tmp, shift ) ); /* Qx; */ -#else - synSHB[i] = round_fx( L_shl( L_tmp, shift ) ); /* Qx; */ -#endif move16(); } l_frame_tmp = add( l_frame, l_shb_lahead ); FOR( ; i < l_frame_tmp; i++ ) { - L_tmp = Mult_32_32( mod_syn[i], frame_gain ); /* (Q_bwe_exc+3) */ -#ifdef BASOP_NOGLOB + L_tmp = Mult_32_32( mod_syn[i], frame_gain ); /* (Q_bwe_exc+3) */ overlap[i - l_frame] = round_fx_sat( L_shl_sat( Mult_32_16( L_tmp, win[l_frame + l_shb_lahead - 1 - i] ), shift ) ); /* Qx */ -#else - overlap[i - l_frame] = round_fx( L_shl( Mult_32_16( L_tmp, win[l_frame + l_shb_lahead - 1 - i] ), shift ) ); /* Qx */ -#endif move16(); } @@ -5737,12 +5599,8 @@ static Word32 non_linearity_scaled_copy( { FOR( i = 0; i < j; i++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_mult_sat( input[i], input[i] ); /* 2*Q_inp+1 */ -#else - L_tmp = L_mult( input[i], input[i] ); /* 2*Q_inp+1 */ -#endif - L_tmp = Mult_32_32( L_tmp, prev_scale ); /* 2*Q_inp */ + L_tmp = Mult_32_32( L_tmp, prev_scale ); /* 2*Q_inp */ output[i] = L_tmp; move32(); @@ -5751,12 +5609,8 @@ static Word32 non_linearity_scaled_copy( } FOR( ; i < length; i++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_mult_sat( input[i], input[i] ); /* 2*Q_inp+1 */ -#else - L_tmp = L_mult( input[i], input[i] ); /* 2*Q_inp+1 */ -#endif - L_tmp = Mult_32_32( L_tmp, prev_scale ); /* 2*Q_inp */ + L_tmp = Mult_32_32( L_tmp, prev_scale ); /* 2*Q_inp */ output[i] = L_tmp; move32(); } @@ -5765,12 +5619,8 @@ static Word32 non_linearity_scaled_copy( { FOR( i = 0; i < j; i++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_mult_sat( input[i], input[i] ); /* 2*Q_inp+1 */ -#else - L_tmp = L_mult( input[i], input[i] ); /* 2*Q_inp+1 */ -#endif - L_tmp = Mult_32_32( L_tmp, prev_scale ); /* 2*Q_inp */ + L_tmp = Mult_32_32( L_tmp, prev_scale ); /* 2*Q_inp */ if ( input[i] < 0 ) { @@ -5785,11 +5635,7 @@ static Word32 non_linearity_scaled_copy( FOR( ; i < length; i++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_mult_sat( input[i], input[i] ); /* 2*Q_inp+1 */ -#else /* BASOP_NOGLOB */ - L_tmp = L_mult( input[i], input[i] ); /* 2*Q_inp+1 */ -#endif /* BASOP_NOGLOB */ L_tmp = Mult_32_32( L_tmp, prev_scale ); /* 2*Q_inp */ if ( input[i] < 0 ) @@ -5891,11 +5737,7 @@ static Word32 non_linearity_scaled_copy_ivas( FOR( ; i < length; i++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_mult_sat( input[i], input[i] ); /* 2*Q_inp+1 */ -#else /* BASOP_NOGLOB */ - L_tmp = L_mult( input[i], input[i] ); /* 2*Q_inp+1 */ -#endif /* BASOP_NOGLOB */ L_tmp = Mult_32_32( L_tmp, prev_scale ); /* 2*Q_inp */ test(); test(); @@ -6072,20 +5914,12 @@ void non_linearity_fx( tmp = div_s( shl( 1, sub( 14, exp ) ), j ); /* Q(29-exp) */ /* (log2(scale / prev_scale))/length */ -#ifdef BASOP_NOGLOB L_tmp = L_shl_o( Mult_32_16( L_tmp, tmp ), sub( exp, 14 ), &Overflow ); /* Q(16+29-exp+1-16+exp-14)->Q16 */ -#else - L_tmp = L_shl( Mult_32_16( L_tmp, tmp ), sub( exp, 14 ) ); /* Q(16+29-exp+1-16+exp-14)->Q16 */ -#endif frac = L_Extract_lc( L_tmp, &exp ); /* Extract exponent of L_tmp */ tmp = extract_l( Pow2( 14, frac ) ); -#ifdef BASOP_NOGLOB scale_step = shl_o( tmp, exp, &Overflow ); /* Q14 */ -#else - scale_step = shl( tmp, exp ); /* Q14 */ -#endif } } @@ -6108,12 +5942,8 @@ void non_linearity_fx( IF( GT_16( max_val, shl( 1, Q_inp ) ) ) { exp = norm_s( max_val ); - tmp = div_s( shl( 1, sub( 14, exp ) ), max_val ); /* Q(29-exp-Q_inp) */ -#ifdef BASOP_NOGLOB + tmp = div_s( shl( 1, sub( 14, exp ) ), max_val ); /* Q(29-exp-Q_inp) */ scale = L_shl_o( L_mult( 21955 /* 0.67 in Q15 */, tmp ), add( exp, sub( Q_inp, 14 ) ), &Overflow ); /* Q31 */ -#else - scale = L_shl( L_mult( 21955, tmp ), add( exp, sub( Q_inp, 14 ) ) ); /* Q31 */ -#endif } ELSE { @@ -6162,20 +5992,12 @@ void non_linearity_fx( tmp = div_s( shl( 1, sub( 14, exp ) ), tmp ); /* Q(29-exp) */ /* (log2(scale / prev_scale))/length */ -#ifdef BASOP_NOGLOB L_tmp = L_shl_o( Mult_32_16( L_tmp, tmp ), sub( exp, 14 ), &Overflow ); /*Q(16+29-exp+1-16+exp-14)->Q16 */ -#else - L_tmp = L_shl( Mult_32_16( L_tmp, tmp ), sub( exp, 14 ) ); /*Q(16+29-exp+1-16+exp-14)->Q16 */ -#endif frac = L_Extract_lc( L_tmp, &exp ); /* Extract exponent of L_tmp */ tmp = extract_l( Pow2( 14, frac ) ); -#ifdef BASOP_NOGLOB scale_step = shl_o( tmp, exp, &Overflow ); /*Q14 */ -#else - scale_step = shl( tmp, exp ); /*Q14 */ -#endif } } @@ -6344,20 +6166,12 @@ void non_linearity_ivas_fx( tmp = div_s( shl( 1, sub( 14, exp ) ), j ); /* Q(29-exp) */ /* (log2(scale / prev_scale))/length */ -#ifdef BASOP_NOGLOB L_tmp = L_shl_o( Mult_32_16( L_tmp, tmp ), sub( exp, 14 ), &Overflow ); /* Q(16+29-exp+1-16+exp-14)->Q16 */ -#else - L_tmp = L_shl( Mult_32_16( L_tmp, tmp ), sub( exp, 14 ) ); /* Q(16+29-exp+1-16+exp-14)->Q16 */ -#endif frac = L_Extract_lc( L_tmp, &exp ); /* Extract exponent of L_tmp */ tmp = extract_l( Pow2( 14, frac ) ); -#ifdef BASOP_NOGLOB scale_step = shl_o( tmp, exp, &Overflow ); /* Q14 */ -#else - scale_step = shl( tmp, exp ); /* Q14 */ -#endif } } @@ -6380,12 +6194,8 @@ void non_linearity_ivas_fx( IF( GT_16( max_val, shl( 1, Q_inp ) ) ) { exp = norm_s( max_val ); - tmp = div_s( shl( 1, sub( 14, exp ) ), max_val ); /* Q(29-exp-Q_inp) */ -#ifdef BASOP_NOGLOB + tmp = div_s( shl( 1, sub( 14, exp ) ), max_val ); /* Q(29-exp-Q_inp) */ scale = L_shl_o( L_mult( 21955, tmp ), add( exp, sub( Q_inp, 14 ) ), &Overflow ); /* Q31 */ -#else - scale = L_shl( L_mult( 21955, tmp ), add( exp, sub( Q_inp, 14 ) ) ); /* Q31 */ -#endif } ELSE { @@ -6434,20 +6244,12 @@ void non_linearity_ivas_fx( tmp = div_s( shl( 1, sub( 14, exp ) ), tmp ); /* Q(29-exp) */ /* (log2(scale / prev_scale))/length */ -#ifdef BASOP_NOGLOB L_tmp = L_shl_o( Mult_32_16( L_tmp, tmp ), sub( exp, 14 ), &Overflow ); /*Q(16+29-exp+1-16+exp-14)->Q16 */ -#else - L_tmp = L_shl( Mult_32_16( L_tmp, tmp ), sub( exp, 14 ) ); /*Q(16+29-exp+1-16+exp-14)->Q16 */ -#endif frac = L_Extract_lc( L_tmp, &exp ); /* Extract exponent of L_tmp */ tmp = extract_l( Pow2( 14, frac ) ); -#ifdef BASOP_NOGLOB scale_step = shl_o( tmp, exp, &Overflow ); /*Q14 */ -#else - scale_step = shl( tmp, exp ); /*Q14 */ -#endif } } @@ -6725,7 +6527,6 @@ void elliptic_bpf_48k_generic_fx( FOR( i = 0; i < 4; i++ ) { memory_fx0[0][i] = extract_l( memory_fx2[0][i] ); -#ifdef BASOP_NOGLOB memory_fx[0][i] = shl_sat( memory_fx0[0][i], sub( *Q_input_fx, memory_fx_Q[0] ) ); memory2_fx[1][i] = L_shl_sat( memory_fx2[1][i], sub( add( *Q_input_fx, 11 ), memory_fx_Q[1] ) ); memory2_fx[2][i] = L_shl_sat( memory_fx2[2][i], sub( add( *Q_input_fx, 6 ), memory_fx_Q[2] ) ); @@ -6735,91 +6536,52 @@ void elliptic_bpf_48k_generic_fx( move32(); move32(); move32(); -#else - memory_fx[0][i] = shl( memory_fx0[0][i], sub( *Q_input_fx, memory_fx_Q[0] ) ); - memory2_fx[1][i] = L_shl( memory_fx2[1][i], sub( add( *Q_input_fx, 11 ), memory_fx_Q[1] ) ); - memory2_fx[2][i] = L_shl( memory_fx2[2][i], sub( add( *Q_input_fx, 6 ), memory_fx_Q[2] ) ); - memory2_fx[3][i] = L_shl( memory_fx2[3][i], sub( add( *Q_input_fx, 1 ), memory_fx_Q[3] ) ); -#endif } - L_tmpX = L_shr( L_mult( memory_fx[0][0], full_band_bpf_fx[0][4] ), 3 ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_add( L_shr( L_mult( memory_fx[0][1], full_band_bpf_fx[0][3] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_add( L_shr( L_mult( memory_fx[0][2], full_band_bpf_fx[0][2] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_add( L_shr( L_mult( memory_fx[0][3], full_band_bpf_fx[0][1] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_add( L_shr( L_mult( input_fx[0], full_band_bpf_fx[0][0] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ -#ifdef BASOP_NOGLOB + L_tmpX = L_shr( L_mult( memory_fx[0][0], full_band_bpf_fx[0][4] ), 3 ); /*Q_input_fx + 13 + 1 - 3*/ + L_tmpX = L_add( L_shr( L_mult( memory_fx[0][1], full_band_bpf_fx[0][3] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ + L_tmpX = L_add( L_shr( L_mult( memory_fx[0][2], full_band_bpf_fx[0][2] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ + L_tmpX = L_add( L_shr( L_mult( memory_fx[0][3], full_band_bpf_fx[0][1] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ + L_tmpX = L_add( L_shr( L_mult( input_fx[0], full_band_bpf_fx[0][0] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx[1][3], full_band_bpf_fx[3][1] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx[1][2], full_band_bpf_fx[3][2] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx[1][1], full_band_bpf_fx[3][3] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ L_tmp[0] = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx[1][0], full_band_bpf_fx[3][4] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ move32(); -#else - L_tmpX = L_sub( L_tmpX, L_shl( Mult_32_16( memory2_fx[1][3], full_band_bpf_fx[3][1] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ - L_tmpX = L_sub( L_tmpX, L_shl( Mult_32_16( memory2_fx[1][2], full_band_bpf_fx[3][2] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ - L_tmpX = L_sub( L_tmpX, L_shl( Mult_32_16( memory2_fx[1][1], full_band_bpf_fx[3][3] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ - L_tmp[0] = L_sub( L_tmpX, L_shl( Mult_32_16( memory2_fx[1][0], full_band_bpf_fx[3][4] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ - move32(); -#endif - L_tmpX = L_shr( L_mult( memory_fx[0][1], full_band_bpf_fx[0][4] ), 3 ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_add( L_shr( L_mult( memory_fx[0][2], full_band_bpf_fx[0][3] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_add( L_shr( L_mult( memory_fx[0][3], full_band_bpf_fx[0][2] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_add( L_shr( L_mult( input_fx[0], full_band_bpf_fx[0][1] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_add( L_shr( L_mult( input_fx[1], full_band_bpf_fx[0][0] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ -#ifdef BASOP_NOGLOB + L_tmpX = L_shr( L_mult( memory_fx[0][1], full_band_bpf_fx[0][4] ), 3 ); /*Q_input_fx + 13 + 1 - 3*/ + L_tmpX = L_add( L_shr( L_mult( memory_fx[0][2], full_band_bpf_fx[0][3] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ + L_tmpX = L_add( L_shr( L_mult( memory_fx[0][3], full_band_bpf_fx[0][2] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ + L_tmpX = L_add( L_shr( L_mult( input_fx[0], full_band_bpf_fx[0][1] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ + L_tmpX = L_add( L_shr( L_mult( input_fx[1], full_band_bpf_fx[0][0] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp[0], full_band_bpf_fx[3][1] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx[1][3], full_band_bpf_fx[3][2] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx[1][2], full_band_bpf_fx[3][3] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ L_tmp[1] = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx[1][1], full_band_bpf_fx[3][4] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ move32(); -#else - L_tmpX = L_sub( L_tmpX, L_shl( Mult_32_16( L_tmp[0], full_band_bpf_fx[3][1] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ - L_tmpX = L_sub( L_tmpX, L_shl( Mult_32_16( memory2_fx[1][3], full_band_bpf_fx[3][2] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ - L_tmpX = L_sub( L_tmpX, L_shl( Mult_32_16( memory2_fx[1][2], full_band_bpf_fx[3][3] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ - L_tmp[1] = L_sub( L_tmpX, L_shl( Mult_32_16( memory2_fx[1][1], full_band_bpf_fx[3][4] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ - move32(); -#endif - L_tmpX = L_shr( L_mult( memory_fx[0][2], full_band_bpf_fx[0][4] ), 3 ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_add( L_shr( L_mult( memory_fx[0][3], full_band_bpf_fx[0][3] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_add( L_shr( L_mult( input_fx[0], full_band_bpf_fx[0][2] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_add( L_shr( L_mult( input_fx[1], full_band_bpf_fx[0][1] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_add( L_shr( L_mult( input_fx[2], full_band_bpf_fx[0][0] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ -#ifdef BASOP_NOGLOB + L_tmpX = L_shr( L_mult( memory_fx[0][2], full_band_bpf_fx[0][4] ), 3 ); /*Q_input_fx + 13 + 1 - 3*/ + L_tmpX = L_add( L_shr( L_mult( memory_fx[0][3], full_band_bpf_fx[0][3] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ + L_tmpX = L_add( L_shr( L_mult( input_fx[0], full_band_bpf_fx[0][2] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ + L_tmpX = L_add( L_shr( L_mult( input_fx[1], full_band_bpf_fx[0][1] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ + L_tmpX = L_add( L_shr( L_mult( input_fx[2], full_band_bpf_fx[0][0] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp[1], full_band_bpf_fx[3][1] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp[0], full_band_bpf_fx[3][2] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx[1][3], full_band_bpf_fx[3][3] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ L_tmp[2] = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx[1][2], full_band_bpf_fx[3][4] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ move32(); -#else - L_tmpX = L_sub( L_tmpX, L_shl( Mult_32_16( L_tmp[1], full_band_bpf_fx[3][1] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ - L_tmpX = L_sub( L_tmpX, L_shl( Mult_32_16( L_tmp[0], full_band_bpf_fx[3][2] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ - L_tmpX = L_sub( L_tmpX, L_shl( Mult_32_16( memory2_fx[1][3], full_band_bpf_fx[3][3] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ - L_tmp[2] = L_sub( L_tmpX, L_shl( Mult_32_16( memory2_fx[1][2], full_band_bpf_fx[3][4] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ - move32(); -#endif - L_tmpX = L_shr( L_mult( memory_fx[0][3], full_band_bpf_fx[0][4] ), 3 ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_add( L_shr( L_mult( input_fx[0], full_band_bpf_fx[0][3] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_add( L_shr( L_mult( input_fx[1], full_band_bpf_fx[0][2] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_add( L_shr( L_mult( input_fx[2], full_band_bpf_fx[0][1] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_add( L_shr( L_mult( input_fx[3], full_band_bpf_fx[0][0] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ -#ifdef BASOP_NOGLOB + L_tmpX = L_shr( L_mult( memory_fx[0][3], full_band_bpf_fx[0][4] ), 3 ); /*Q_input_fx + 13 + 1 - 3*/ + L_tmpX = L_add( L_shr( L_mult( input_fx[0], full_band_bpf_fx[0][3] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ + L_tmpX = L_add( L_shr( L_mult( input_fx[1], full_band_bpf_fx[0][2] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ + L_tmpX = L_add( L_shr( L_mult( input_fx[2], full_band_bpf_fx[0][1] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ + L_tmpX = L_add( L_shr( L_mult( input_fx[3], full_band_bpf_fx[0][0] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp[2], full_band_bpf_fx[3][1] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp[1], full_band_bpf_fx[3][2] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp[0], full_band_bpf_fx[3][3] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ L_tmp[3] = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx[1][3], full_band_bpf_fx[3][4] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ move32(); -#else - L_tmpX = L_sub( L_tmpX, L_shl( Mult_32_16( L_tmp[2], full_band_bpf_fx[3][1] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ - L_tmpX = L_sub( L_tmpX, L_shl( Mult_32_16( L_tmp[1], full_band_bpf_fx[3][2] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ - L_tmpX = L_sub( L_tmpX, L_shl( Mult_32_16( L_tmp[0], full_band_bpf_fx[3][3] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ - L_tmp[3] = L_sub( L_tmpX, L_shl( Mult_32_16( memory2_fx[1][3], full_band_bpf_fx[3][4] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ - move32(); -#endif FOR( i = 4; i < L_FRAME48k; i++ ) { -#ifdef BASOP_NOGLOB L_tmpX = L_shr( L_mult( input_fx[i - 4], full_band_bpf_fx[0][4] ), 3 ); /*Q_input_fx + 13 + 1 - 3*/ L_tmpX = L_add_sat( L_shr( L_mult( input_fx[i - 3], full_band_bpf_fx[0][3] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp[i - 1], full_band_bpf_fx[3][1] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ @@ -6830,18 +6592,6 @@ void elliptic_bpf_48k_generic_fx( L_tmpX = L_add_sat( L_shr( L_mult( input_fx[i], full_band_bpf_fx[0][0] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ L_tmp[i] = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp[i - 4], full_band_bpf_fx[3][4] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ move32(); -#else - L_tmpX = L_shr( L_mult( input_fx [[i - 4]], full_band_bpf_fx[0][4] ), 3 ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_add( L_shr( L_mult( input_fx[i - 3], full_band_bpf_fx[0][3] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_sub( L_tmpX, L_shl( Mult_32_16( L_tmp[i - 1], full_band_bpf_fx[3][1] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ - L_tmpX = L_add( L_shr( L_mult( input_fx[i - 2], full_band_bpf_fx[0][2] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_sub( L_tmpX, L_shl( Mult_32_16( L_tmp[i - 2], full_band_bpf_fx[3][2] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ - L_tmpX = L_add( L_shr( L_mult( input_fx[i - 1], full_band_bpf_fx[0][1] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_sub( L_tmpX, L_shl( Mult_32_16( L_tmp[i - 3], full_band_bpf_fx[3][3] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ - L_tmpX = L_add( L_shr( L_mult( input_fx[i], full_band_bpf_fx[0][0] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmp[i] = L_sub( L_tmpX, L_shl( Mult_32_16( L_tmp[i - 4], full_band_bpf_fx[3][4] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ - move32(); -#endif } memory_fx2[0][0] = input_fx[L_FRAME48k - 4]; @@ -6853,89 +6603,52 @@ void elliptic_bpf_48k_generic_fx( move32(); move32(); move32(); - L_tmpX = L_shr( Mult_32_16( memory2_fx[1][0], full_band_bpf_fx[1][4] ), 3 ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_add( L_shr( Mult_32_16( memory2_fx[1][1], full_band_bpf_fx[1][3] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_add( L_shr( Mult_32_16( memory2_fx[1][2], full_band_bpf_fx[1][2] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_add( L_shr( Mult_32_16( memory2_fx[1][3], full_band_bpf_fx[1][1] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_add( L_shr( Mult_32_16( L_tmp[0], full_band_bpf_fx[1][0] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ -#ifdef BASOP_NOGLOB + L_tmpX = L_shr( Mult_32_16( memory2_fx[1][0], full_band_bpf_fx[1][4] ), 3 ); /*Q_input_fx + 11 + 13 - 15 -3*/ + L_tmpX = L_add( L_shr( Mult_32_16( memory2_fx[1][1], full_band_bpf_fx[1][3] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ + L_tmpX = L_add( L_shr( Mult_32_16( memory2_fx[1][2], full_band_bpf_fx[1][2] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ + L_tmpX = L_add( L_shr( Mult_32_16( memory2_fx[1][3], full_band_bpf_fx[1][1] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ + L_tmpX = L_add( L_shr( Mult_32_16( L_tmp[0], full_band_bpf_fx[1][0] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx[2][3], full_band_bpf_fx[4][1] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx[2][2], full_band_bpf_fx[4][2] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2*/ L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx[2][1], full_band_bpf_fx[4][3] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2*/ L_tmp2[0] = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx[2][0], full_band_bpf_fx[4][4] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2*/ move32(); L_tmpMax = L_abs( L_tmp2[0] ); -#else - L_tmpX = L_sub( L_tmpX, L_shl( Mult_32_16( memory2_fx[2][3], full_band_bpf_fx[4][1] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ - L_tmpX = L_sub( L_tmpX, L_shl( Mult_32_16( memory2_fx[2][2], full_band_bpf_fx[4][2] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2*/ - L_tmpX = L_sub( L_tmpX, L_shl( Mult_32_16( memory2_fx[2][1], full_band_bpf_fx[4][3] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2*/ - L_tmp2[0] = L_sub( L_tmpX, L_shl( Mult_32_16( memory2_fx[2][0], full_band_bpf_fx[4][4] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2*/ - move32(); - L_tmpMax = L_abs( L_tmp2[0] ); -#endif - L_tmpX = L_shr( Mult_32_16( memory2_fx[1][1], full_band_bpf_fx[1][4] ), 3 ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_add( L_shr( Mult_32_16( memory2_fx[1][2], full_band_bpf_fx[1][3] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_add( L_shr( Mult_32_16( memory2_fx[1][3], full_band_bpf_fx[1][2] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_add( L_shr( Mult_32_16( L_tmp[0], full_band_bpf_fx[1][1] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_add( L_shr( Mult_32_16( L_tmp[1], full_band_bpf_fx[1][0] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ -#ifdef BASOP_NOGLOB + L_tmpX = L_shr( Mult_32_16( memory2_fx[1][1], full_band_bpf_fx[1][4] ), 3 ); /*Q_input_fx + 11 + 13 - 15 -3*/ + L_tmpX = L_add( L_shr( Mult_32_16( memory2_fx[1][2], full_band_bpf_fx[1][3] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ + L_tmpX = L_add( L_shr( Mult_32_16( memory2_fx[1][3], full_band_bpf_fx[1][2] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ + L_tmpX = L_add( L_shr( Mult_32_16( L_tmp[0], full_band_bpf_fx[1][1] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ + L_tmpX = L_add( L_shr( Mult_32_16( L_tmp[1], full_band_bpf_fx[1][0] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp2[0], full_band_bpf_fx[4][1] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx[2][3], full_band_bpf_fx[4][2] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx[2][2], full_band_bpf_fx[4][3] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ L_tmp2[1] = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx[2][1], full_band_bpf_fx[4][4] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ move32(); L_tmpMax = L_max( L_tmpMax, L_abs( L_tmp2[1] ) ); -#else - L_tmpX = L_sub( L_tmpX, L_shl( Mult_32_16( L_tmp2[0], full_band_bpf_fx[4][1] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ - L_tmpX = L_sub( L_tmpX, L_shl( Mult_32_16( memory2_fx[2][3], full_band_bpf_fx[4][2] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ - L_tmpX = L_sub( L_tmpX, L_shl( Mult_32_16( memory2_fx[2][2], full_band_bpf_fx[4][3] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ - L_tmp2[1] = L_sub( L_tmpX, L_shl( Mult_32_16( memory2_fx[2][1], full_band_bpf_fx[4][4] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ - move32(); - L_tmpMax = L_max( L_tmpMax, L_abs( L_tmp2[1] ) ); -#endif - L_tmpX = L_shr( Mult_32_16( memory2_fx[1][2], full_band_bpf_fx[1][4] ), 3 ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_add( L_shr( Mult_32_16( memory2_fx[1][3], full_band_bpf_fx[1][3] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_add( L_shr( Mult_32_16( L_tmp[0], full_band_bpf_fx[1][2] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_add( L_shr( Mult_32_16( L_tmp[1], full_band_bpf_fx[1][1] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_add( L_shr( Mult_32_16( L_tmp[2], full_band_bpf_fx[1][0] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ -#ifdef BASOP_NOGLOB + L_tmpX = L_shr( Mult_32_16( memory2_fx[1][2], full_band_bpf_fx[1][4] ), 3 ); /*Q_input_fx + 11 + 13 - 15 -3*/ + L_tmpX = L_add( L_shr( Mult_32_16( memory2_fx[1][3], full_band_bpf_fx[1][3] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ + L_tmpX = L_add( L_shr( Mult_32_16( L_tmp[0], full_band_bpf_fx[1][2] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ + L_tmpX = L_add( L_shr( Mult_32_16( L_tmp[1], full_band_bpf_fx[1][1] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ + L_tmpX = L_add( L_shr( Mult_32_16( L_tmp[2], full_band_bpf_fx[1][0] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp2[1], full_band_bpf_fx[4][1] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp2[0], full_band_bpf_fx[4][2] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx[2][3], full_band_bpf_fx[4][3] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ L_tmp2[2] = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx[2][2], full_band_bpf_fx[4][4] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ move32(); L_tmpMax = L_max( L_tmpMax, L_abs( L_tmp2[2] ) ); -#else - L_tmpX = L_sub( L_tmpX, L_shl( Mult_32_16( L_tmp2[1], full_band_bpf_fx[4][1] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ - L_tmpX = L_sub( L_tmpX, L_shl( Mult_32_16( L_tmp2[0], full_band_bpf_fx[4][2] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ - L_tmpX = L_sub( L_tmpX, L_shl( Mult_32_16( memory2_fx[2][3], full_band_bpf_fx[4][3] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ - L_tmp2[2] = L_sub( L_tmpX, L_shl( Mult_32_16( memory2_fx[2][2], full_band_bpf_fx[4][4] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ - move32(); - L_tmpMax = L_max( L_tmpMax, L_abs( L_tmp2[2] ) ); -#endif - L_tmpX = L_shr( Mult_32_16( memory2_fx[1][3], full_band_bpf_fx[1][4] ), 3 ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_add( L_shr( Mult_32_16( L_tmp[0], full_band_bpf_fx[1][3] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_add( L_shr( Mult_32_16( L_tmp[1], full_band_bpf_fx[1][2] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_add( L_shr( Mult_32_16( L_tmp[2], full_band_bpf_fx[1][1] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_add( L_shr( Mult_32_16( L_tmp[3], full_band_bpf_fx[1][0] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ -#ifdef BASOP_NOGLOB + L_tmpX = L_shr( Mult_32_16( memory2_fx[1][3], full_band_bpf_fx[1][4] ), 3 ); /*Q_input_fx + 11 + 13 - 15 -3*/ + L_tmpX = L_add( L_shr( Mult_32_16( L_tmp[0], full_band_bpf_fx[1][3] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ + L_tmpX = L_add( L_shr( Mult_32_16( L_tmp[1], full_band_bpf_fx[1][2] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ + L_tmpX = L_add( L_shr( Mult_32_16( L_tmp[2], full_band_bpf_fx[1][1] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ + L_tmpX = L_add( L_shr( Mult_32_16( L_tmp[3], full_band_bpf_fx[1][0] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp2[2], full_band_bpf_fx[4][1] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp2[1], full_band_bpf_fx[4][2] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp2[0], full_band_bpf_fx[4][3] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ L_tmp2[3] = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx[2][3], full_band_bpf_fx[4][4] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ /*14 + Q_input_fx - shift_flag*/ move32(); L_tmpMax = L_max( L_tmpMax, L_abs( L_tmp2[3] ) ); -#else - L_tmpX = L_sub( L_tmpX, L_shl( Mult_32_16( L_tmp2[2], full_band_bpf_fx[4][1] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ - L_tmpX = L_sub( L_tmpX, L_shl( Mult_32_16( L_tmp2[1], full_band_bpf_fx[4][2] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ - L_tmpX = L_sub( L_tmpX, L_shl( Mult_32_16( L_tmp2[0], full_band_bpf_fx[4][3] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ - L_tmp2[3] = L_sub( L_tmpX, L_shl( Mult_32_16( memory2_fx[2][3], full_band_bpf_fx[4][4] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ /*14 + Q_input_fx - shift_flag*/ - move32(); - L_tmpMax = L_max( L_tmpMax, L_abs( L_tmp2[3] ) ); -#endif FOR( i = 4; i < L_FRAME48k; i++ ) { -#ifdef BASOP_NOGLOB L_tmpX = L_shr( Mult_32_16( L_tmp[i - 4], full_band_bpf_fx[1][4] ), 3 ); /*Q_input_fx + 11 + 13 - 15 -3*/ L_tmpX = L_add_sat( L_shr( Mult_32_16( L_tmp[i - 3], full_band_bpf_fx[1][3] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp2[i - 1], full_band_bpf_fx[4][1] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ @@ -6946,18 +6659,6 @@ void elliptic_bpf_48k_generic_fx( L_tmpX = L_add_sat( L_shr( Mult_32_16( L_tmp[i], full_band_bpf_fx[1][0] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ L_tmp2[i] = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp2[i - 4], full_band_bpf_fx[4][4] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ move32(); -#else - L_tmpX = L_shr( Mult_32_16( L_tmp[i - 4], full_band_bpf_fx[1][4] ), 3 ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_add( L_shr( Mult_32_16( L_tmp[i - 3], full_band_bpf_fx[1][3] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_sub( L_tmpX, L_shl( Mult_32_16( L_tmp2[i - 1], full_band_bpf_fx[4][1] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ - L_tmpX = L_add( L_shr( Mult_32_16( L_tmp[i - 2], full_band_bpf_fx[1][2] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_sub( L_tmpX, L_shl( Mult_32_16( L_tmp2[i - 2], full_band_bpf_fx[4][2] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ - L_tmpX = L_add( L_shr( Mult_32_16( L_tmp[i - 1], full_band_bpf_fx[1][1] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_sub( L_tmpX, L_shl( Mult_32_16( L_tmp2[i - 3], full_band_bpf_fx[4][3] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ - L_tmpX = L_add( L_shr( Mult_32_16( L_tmp[i], full_band_bpf_fx[1][0] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmp2[i] = L_sub( L_tmpX, L_shl( Mult_32_16( L_tmp2[i - 4], full_band_bpf_fx[4][4] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ - move32(); -#endif L_tmpMax = L_max( L_tmpMax, L_abs( L_tmp2[i] ) ); } @@ -6976,18 +6677,12 @@ void elliptic_bpf_48k_generic_fx( move32(); FOR( j = 0; j < 4; j++ ) { -#ifdef BASOP_NOGLOB memory2_fx_2[j] = L_shl_sat( memory_fx2[2][j], sub( add( add( *Q_input_fx, 6 ), Q_temp ), memory_fx_Q[2] ) ); memory2_fx_3[j] = L_shl_sat( memory_fx2[3][j], sub( add( add( *Q_input_fx, 1 ), Q_temp ), memory_fx_Q[3] ) ); -#else - memory2_fx_2[j] = L_shl( memory_fx2[2][j], sub( add( add( *Q_input_fx, 6 ), Q_temp ), memory_fx_Q[2] ) ); - memory2_fx_3[j] = L_shl( memory_fx2[3][j], sub( add( add( *Q_input_fx, 1 ), Q_temp ), memory_fx_Q[3] ) ); -#endif move32(); move32(); move32(); } -#ifdef BASOP_NOGLOB L_tmpX = L_shr( Mult_32_16( memory2_fx_2[0], full_band_bpf_fx[2][4] ), 3 ); /* *Q_input_fx+6 +Q_temp +13 -15 -3 */ L_tmpX = L_add_sat( L_shr( Mult_32_16( memory2_fx_2[1], full_band_bpf_fx[2][3] ), 3 ), L_tmpX ); /*Q_input_fx + 6 +Q_temp+13 -15 -3*/ L_tmpX = L_add_sat( L_shr( Mult_32_16( memory2_fx_2[2], full_band_bpf_fx[2][2] ), 3 ), L_tmpX ); /*Q_input_fx + 6 +Q_temp+13 -15 -3*/ @@ -7053,73 +6748,6 @@ void elliptic_bpf_48k_generic_fx( move32(); L_tmpMax = L_max( L_tmpMax, L_abs( L_output[i] ) ); } -#else - L_tmpX = L_shr( Mult_32_16( memory2_fx_2[0], full_band_bpf_fx[2][4] ), 3 ); /* *Q_input_fx+6 +Q_temp +13 -15 -3 */ - L_tmpX = L_add( L_shr( Mult_32_16( memory2_fx_2[1], full_band_bpf_fx[2][3] ), 3 ), L_tmpX ); /*Q_input_fx + 6 +Q_temp+13 -15 -3*/ - L_tmpX = L_add( L_shr( Mult_32_16( memory2_fx_2[2], full_band_bpf_fx[2][2] ), 3 ), L_tmpX ); /*Q_input_fx + 6 +Q_temp+13 -15 -3*/ - L_tmpX = L_add( L_shr( Mult_32_16( memory2_fx_2[3], full_band_bpf_fx[2][1] ), 3 ), L_tmpX ); /*Q_input_fx + 6 +Q_temp+13 -15 -3*/ - L_tmpX = L_add( L_shr( Mult_32_16( L_tmp2[0], full_band_bpf_fx[2][0] ), 3 ), L_tmpX ); /*Q_input_fx + 6 +Q_temp+13 -15 -3*/ - L_tmpX = L_sub( L_tmpX, L_shl( Mult_32_16( memory2_fx_3[3], full_band_bpf_fx[5][1] ), 2 ) ); /*Q_input_fx + 1 +Q_temp+13 -15 + 2 */ - L_tmpX = L_sub( L_tmpX, L_shl( Mult_32_16( memory2_fx_3[2], full_band_bpf_fx[5][2] ), 2 ) ); /*Q_input_fx + 1 +Q_temp+13 -15 + 2 */ - L_tmpX = L_sub( L_tmpX, L_shl( Mult_32_16( memory2_fx_3[1], full_band_bpf_fx[5][3] ), 2 ) ); /*Q_input_fx + 1 +Q_temp+13 -15 + 2 */ - L_output[0] = L_sub( L_tmpX, L_shl( Mult_32_16( memory2_fx_3[0], full_band_bpf_fx[5][4] ), 2 ) ); /*Q_input_fx + 1 +Q_temp+13 -15 + 2 */ - move32(); - L_tmpMax = L_abs( L_output[0] ); - - L_tmpX = L_shr( Mult_32_16( memory2_fx_2[1], full_band_bpf_fx[2][4] ), 3 ); /*Q_input_fx + 6 +Q_temp +13 -15 -3 */ - L_tmpX = L_add( L_shr( Mult_32_16( memory2_fx_2[2], full_band_bpf_fx[2][3] ), 3 ), L_tmpX ); /*Q_input_fx +Q_temp+ 6 +13 -15 -3*/ - L_tmpX = L_add( L_shr( Mult_32_16( memory2_fx_2[3], full_band_bpf_fx[2][2] ), 3 ), L_tmpX ); /*Q_input_fx +Q_temp+ 6 +13 -15 -3*/ - L_tmpX = L_add( L_shr( Mult_32_16( L_tmp2[0], full_band_bpf_fx[2][1] ), 3 ), L_tmpX ); /*Q_input_fx +Q_temp+ 6 +13 -15 -3*/ - L_tmpX = L_add( L_shr( Mult_32_16( L_tmp2[1], full_band_bpf_fx[2][0] ), 3 ), L_tmpX ); /*Q_input_fx+Q_temp + 6 +13 -15 -3*/ - L_tmpX = L_sub( L_tmpX, L_shl( Mult_32_16( L_output[0], full_band_bpf_fx[5][1] ), 2 ) ); /*Q_input_fx + 1 +13 -15 + 2+Q_temp*/ - L_tmpX = L_sub( L_tmpX, L_shl( Mult_32_16( memory2_fx_3[3], full_band_bpf_fx[5][2] ), 2 ) ); /*Q_input_fx + 1 +13 -15 + 2+Q_temp*/ - L_tmpX = L_sub( L_tmpX, L_shl( Mult_32_16( memory2_fx_3[2], full_band_bpf_fx[5][3] ), 2 ) ); /*Q_input_fx + 1 +13 -15 + 2+Q_temp*/ - L_output[1] = L_sub( L_tmpX, L_shl( Mult_32_16( memory2_fx_3[1], full_band_bpf_fx[5][4] ), 2 ) ); /*Q_input_fx + 1 +13 -15 + 2+Q_temp*/ - move32(); - L_tmpMax = L_max( L_tmpMax, L_abs( L_output[1] ) ); - - L_tmpX = L_shr( Mult_32_16( memory2_fx_2[2], full_band_bpf_fx[2][4] ), 3 ); /*Q_input_fx + 6 +Q_temp+13 -15 -3 */ - L_tmpX = L_add( L_shr( Mult_32_16( memory2_fx_2[3], full_band_bpf_fx[2][3] ), 3 ), L_tmpX ); /*Q_input_fx +Q_temp+ 6 +13 -15 -3*/ - L_tmpX = L_add( L_shr( Mult_32_16( L_tmp2[0], full_band_bpf_fx[2][2] ), 3 ), L_tmpX ); /*Q_input_fx +Q_temp+ 6 +13 -15 -3*/ - L_tmpX = L_add( L_shr( Mult_32_16( L_tmp2[1], full_band_bpf_fx[2][1] ), 3 ), L_tmpX ); /*Q_input_fx +Q_temp + 6 +13 -15 -3*/ - L_tmpX = L_add( L_shr( Mult_32_16( L_tmp2[2], full_band_bpf_fx[2][0] ), 3 ), L_tmpX ); /*Q_input_fx +Q_temp + 6 +13 -15 -3*/ - L_tmpX = L_sub( L_tmpX, L_shl( Mult_32_16( L_output[1], full_band_bpf_fx[5][1] ), 2 ) ); /*Q_input_fx + 1 +Q_temp+13 -15 + 2*/ - L_tmpX = L_sub( L_tmpX, L_shl( Mult_32_16( L_output[0], full_band_bpf_fx[5][2] ), 2 ) ); /*Q_input_fx + 1 +Q_temp+13 -15 + 2*/ - L_tmpX = L_sub( L_tmpX, L_shl( Mult_32_16( memory2_fx_3[3], full_band_bpf_fx[5][3] ), 2 ) ); /*Q_input_fx + 1+Q_temp +13 -15 + 2*/ - L_output[2] = L_sub( L_tmpX, L_shl( Mult_32_16( memory2_fx_3[2], full_band_bpf_fx[5][4] ), 2 ) ); /*Q_input_fx + 1 +Q_temp+13 -15 + 2*/ - move32(); - L_tmpMax = L_max( L_tmpMax, L_abs( L_output[2] ) ); - - L_tmpX = L_shr( Mult_32_16( memory2_fx_2[3], full_band_bpf_fx[2][4] ), 3 ); /*Q_input_fx + 6 +Q_temp +13 -15 -3 */ - L_tmpX = L_add( L_shr( Mult_32_16( L_tmp2[0], full_band_bpf_fx[2][3] ), 3 ), L_tmpX ); /*Q_input_fx + 6 +Q_temp+13 -15 -3*/ - L_tmpX = L_add( L_shr( Mult_32_16( L_tmp2[1], full_band_bpf_fx[2][2] ), 3 ), L_tmpX ); /*Q_input_fx + 6 +Q_temp+13 -15 -3*/ - L_tmpX = L_add( L_shr( Mult_32_16( L_tmp2[2], full_band_bpf_fx[2][1] ), 3 ), L_tmpX ); /*Q_input_fx + 6 +Q_temp+13 -15 -3*/ - L_tmpX = L_add( L_shr( Mult_32_16( L_tmp2[3], full_band_bpf_fx[2][0] ), 3 ), L_tmpX ); /*Q_input_fx + 6 +Q_temp+13 -15 -3*/ - L_tmpX = L_sub( L_tmpX, L_shl( Mult_32_16( L_output[2], full_band_bpf_fx[5][1] ), 2 ) ); /*Q_input_fx + 1 +Q_temp+13 -15 + 2*/ - L_tmpX = L_sub( L_tmpX, L_shl( Mult_32_16( L_output[1], full_band_bpf_fx[5][2] ), 2 ) ); /*Q_input_fx + 1 +Q_temp+13 -15 + 2*/ - L_tmpX = L_sub( L_tmpX, L_shl( Mult_32_16( L_output[0], full_band_bpf_fx[5][3] ), 2 ) ); /*Q_input_fx + 1 +Q_temp+13 -15 + 2*/ - L_output[3] = L_sub( L_tmpX, L_shl( Mult_32_16( memory2_fx_3[3], full_band_bpf_fx[5][4] ), 2 ) ); /*Q_input_fx + 1 +Q_temp+13 -15 + 2*/ - move32(); - L_tmpMax = L_max( L_tmpMax, L_abs( L_output[3] ) ); - - FOR( i = 4; i < L_FRAME48k; i++ ) - { - L_tmpX = L_shr( Mult_32_16( L_tmp2[i - 4], full_band_bpf_fx[2][4] ), 3 ); /*Q_input_fx + 6 +Q_temp+13 -15 -3 */ - L_tmpX = L_add( L_shr( Mult_32_16( L_tmp2[i - 3], full_band_bpf_fx[2][3] ), 3 ), L_tmpX ); /*Q_input_fx + 6 +Q_temp +13 -15 -3*/ - L_tmpX = L_sub( L_tmpX, L_shl( Mult_32_16( L_output[i - 1], full_band_bpf_fx[5][1] ), 2 ) ); /*Q_input_fx + 1 +Q_temp+13 -15 + 2*/ - - L_tmpX = L_add( L_shr( Mult_32_16( L_tmp2[i - 2], full_band_bpf_fx[2][2] ), 3 ), L_tmpX ); /*Q_input_fx + 6 +Q_temp+13 -15 -3*/ - L_tmpX = L_sub( L_tmpX, L_shl( Mult_32_16( L_output[i - 2], full_band_bpf_fx[5][2] ), 2 ) ); /*Q_input_fx + 1 +Q_temp+13 -15 + 2*/ - - L_tmpX = L_add( L_shr( Mult_32_16( L_tmp2[i - 1], full_band_bpf_fx[2][1] ), 3 ), L_tmpX ); /*Q_input_fx + 6 +Q_temp +13 -15 -3*/ - L_tmpX = L_sub( L_tmpX, L_shl( Mult_32_16( L_output[i - 3], full_band_bpf_fx[5][3] ), 2 ) ); /*Q_input_fx + 1 +Q_temp+13 -15 + 2*/ - - L_tmpX = L_add( L_shr( Mult_32_16( L_tmp2[i], full_band_bpf_fx[2][0] ), 3 ), L_tmpX ); /*Q_input_fx + 6 +Q_temp +13 -15 -3*/ - L_output[i] = L_sub( L_tmpX, L_shl( Mult_32_16( L_output[i - 4], full_band_bpf_fx[5][4] ), 2 ) ); /*Q_input_fx + 1 +Q_temp+13 -15 + 2*/ - move32(); - L_tmpMax = L_max( L_tmpMax, L_abs( L_output[i] ) ); - } -#endif memory_fx2[2][0] = L_tmp2[L_FRAME48k - 4]; memory_fx2[2][1] = L_tmp2[L_FRAME48k - 3]; memory_fx2[2][2] = L_tmp2[L_FRAME48k - 2]; @@ -7265,21 +6893,13 @@ void synthesise_fb_high_band_fx( L_tmp = Mult_32_16( ratio2, tmp[i] ); /* Q(16-exp+exp_tmp-15 = 1-exp+exp_tmp) */ IF( L_tmp < 0 ) { -#ifdef BASOP_NOGLOB output[i] = negate( extract_h( L_shl_sat( L_negate( L_tmp ), tmp3 ) ) ); /*Qout*/ move16(); -#else - output[i] = negate( extract_h( L_shl( L_negate( L_tmp ), tmp3 ) ) ); /*Qout*/ -#endif } ELSE { -#ifdef BASOP_NOGLOB output[i] = extract_h( L_shl_sat( L_tmp, tmp3 ) ); /*Qout*/ move16(); -#else - output[i] = extract_h( L_shl( L_tmp, tmp3 ) ); /*Qout*/ -#endif } } return; @@ -7348,20 +6968,12 @@ void Estimate_mix_factors_fx( shb_res_local[i] = round_fx( L_tmp2 ); move16(); /* temp_numer1[i] = sub(shb_res_local[i], WN_exc_local[i]); */ -#ifdef BASOP_NOGLOB temp_numer1[i] = round_fx_sat( L_sub_sat( L_shl_sat( L_tmp2, sc2 ), L_shl_sat( L_tmp1, sc1 ) ) ); -#else - temp_numer1[i] = round_fx( L_sub( L_shl( L_tmp2, sc2 ), L_shl( L_tmp1, sc1 ) ) ); -#endif move16(); /* (Q_bwe_exc) */ /* temp_numer2[i] = sub(exc16kWhtnd[i], WN_exc_local[i]); */ -#ifdef BASOP_NOGLOB temp_numer2[i] = sub_sat( exc16kWhtnd[i], round_fx_sat( L_shl_sat( L_tmp1, sc1 ) ) ); -#else - temp_numer2[i] = sub( exc16kWhtnd[i], round_fx( L_shl( L_tmp1, sc1 ) ) ); -#endif move16(); /* (Q_bwe_exc) */ } @@ -7381,11 +6993,7 @@ void Estimate_mix_factors_fx( expa = sub( 30, expa ); expb = norm_l( temp_p1_p2 ); -#ifdef BASOP_NOGLOB fracb = round_fx_o( L_shl_o( temp_p1_p2, expb, &Overflow ), &Overflow ); -#else - fracb = round_fx( L_shl( temp_p1_p2, expb ) ); -#endif expb = sub( 30, expb ); num_flag = 0; @@ -7412,11 +7020,7 @@ void Estimate_mix_factors_fx( tmp = div_s( fracb, fraca ); exp1 = sub( expb, expa ); -#ifdef BASOP_NOGLOB tmp = shl_sat( tmp, exp1 ); -#else - tmp = shl( tmp, exp1 ); -#endif if ( NE_16( num_flag, den_flag ) ) { tmp = negate( tmp ); @@ -7587,11 +7191,7 @@ void prep_tbe_exc_fx( tmp = MAX_16; move16(); -#ifdef BASOP_NOGLOB pitch = shl_o( add( shl_o( T0, 2, &Overflow ), T0_frac ), 5, &Overflow ); /* Q7 */ -#else /* BASOP_NOGLOB */ - pitch = shl( add( shl( T0, 2 ), T0_frac ), 5 ); /* Q7 */ -#endif /* BASOP_NOGLOB */ test(); test(); @@ -7618,29 +7218,15 @@ void prep_tbe_exc_fx( #endif IF( EQ_16( L_frame_fx, L_FRAME ) ) { - interp_code_5over2_fx( code_fx, tmp_code_fx, L_subfr ); /* code: Q9, tmp_code: Q9 */ -#ifdef BASOP_NOGLOB + interp_code_5over2_fx( code_fx, tmp_code_fx, L_subfr ); /* code: Q9, tmp_code: Q9 */ gain_code16 = round_fx_o( L_shl_o( gain_code_fx, Q_exc, &Overflow ), &Overflow ); /*Q_exc */ -#else - gain_code16 = round_fx( L_shl( gain_code_fx, Q_exc ) ); /*Q_exc */ -#endif FOR( i = 0; i < L_subfr * HIBND_ACB_L_FAC; i++ ) { - L_tmp = L_mult( gain_code16, tmp_code_fx[i] ); /* Q9 + Q_exc + 1*/ -#ifdef BASOP_NOGLOB + L_tmp = L_mult( gain_code16, tmp_code_fx[i] ); /* Q9 + Q_exc + 1*/ L_tmp = L_shl_sat( L_tmp, 5 ); /* Q9 + Q_exc + Q6*/ L_tmp = L_mac_sat( L_tmp, gain_pit_fx, bwe_exc_fx[i + i_subfr_fx * HIBND_ACB_L_FAC] ); /*Q15+Q_exc */ -#else - L_tmp = L_shl( L_tmp, 5 ); /* Q9 + Q_exc + Q6*/ - L_tmp = L_mac( L_tmp, gain_pit_fx, bwe_exc_fx[i + i_subfr_fx * HIBND_ACB_L_FAC] ); /*Q15+Q_exc */ -#endif -#ifdef BASOP_NOGLOB - L_tmp = L_shl_o( L_tmp, 1, &Overflow ); /*16+Q_exc */ /* saturation can occur here */ - bwe_exc_fx[i + i_subfr_fx * HIBND_ACB_L_FAC] = round_fx_o( L_tmp, &Overflow ); /*Q_exc */ -#else /* BASOP_NOGLOB */ - L_tmp = L_shl( L_tmp, 1 ); /*16+Q_exc */ /* saturation can occur here */ - bwe_exc_fx[i + i_subfr_fx * HIBND_ACB_L_FAC] = round_fx( L_tmp ); /*Q_exc */ -#endif /* BASOP_NOGLOB */ + L_tmp = L_shl_o( L_tmp, 1, &Overflow ); /*16+Q_exc */ /* saturation can occur here */ + bwe_exc_fx[i + i_subfr_fx * HIBND_ACB_L_FAC] = round_fx_o( L_tmp, &Overflow ); /*Q_exc */ move16(); } } @@ -7654,18 +7240,11 @@ void prep_tbe_exc_fx( Ltemp1 = Mult_32_16( gain_code_fx, code_fx[i] ); /* Q16 + Q9 + 1 - 16 = Q10 */ Ltemp2 = L_mult( gain_preQ_fx, code_preQ_fx[i] ); /*Q2 * Q10 -> Q12 */ -#ifdef BASOP_NOGLOB Ltemp1 = L_shl_o( Ltemp1, add( Q_exc, 6 ) /*Q_exc+16-19*/, &Overflow ); /*Q_exc+16 */ Ltemp2 = L_shl_o( Ltemp2, add( Q_exc, 4 ) /*Q_exc+16-13*/, &Overflow ); /*Q_exc+16 */ tmp_code_preInt_fx[i] = round_fx_o( L_add_o( Ltemp1, Ltemp2, &Overflow ), &Overflow ); /* Q_exc */ move16(); -#else /* BASOP_NOGLOB */ - Ltemp1 = L_shl( Ltemp1, Q_exc + 6 /*Q_exc+16-19*/ ); /*Q_exc+16 */ - Ltemp2 = L_shl( Ltemp2, Q_exc + 4 /*Q_exc+16-13*/ ); /*Q_exc+16 */ - - tmp_code_preInt_fx[i] = round_fx( L_add( Ltemp1, Ltemp2 ) ); /* Q_exc */ -#endif /* BASOP_NOGLOB */ } } ELSE @@ -7673,31 +7252,20 @@ void prep_tbe_exc_fx( FOR( i = 0; i < L_subfr; i++ ) { /*code in the encoder is Q9 and there is no <<1 with Mult_32_16 Q16 * Q9 -> Q9 */ - Ltemp1 = Mult_32_16( gain_code_fx, code_fx[i] ); /* Q16 + Q9 + 1 - 16 = Q10 */ -#ifdef BASOP_NOGLOB + Ltemp1 = Mult_32_16( gain_code_fx, code_fx[i] ); /* Q16 + Q9 + 1 - 16 = Q10 */ Ltemp1 = L_shl_o( Ltemp1, add( Q_exc, 6 ) /*Q_exc+16-19*/, &Overflow ); /*Q_exc+16 */ tmp_code_preInt_fx[i] = round_fx_o( Ltemp1, &Overflow ); /* Q_exc */ move16(); -#else - Ltemp1 = L_shl( Ltemp1, Q_exc + 6 /*Q_exc+16-19*/ ); /*Q_exc+16 */ - tmp_code_preInt_fx[i] = round_fx( Ltemp1 ); /* Q_exc */ -#endif } } interp_code_4over2_fx( tmp_code_preInt_fx, tmp_code_fx, L_subfr ); /* o: tmp_code in Q_exc */ FOR( i = 0; i < L_subfr * 2; i++ ) { - L_tmp = L_mult( gain_pit_fx, bwe_exc_fx[i + i_subfr_fx * 2] ); /*Q14+Q_exc+1 */ -#ifdef BASOP_NOGLOB + L_tmp = L_mult( gain_pit_fx, bwe_exc_fx[i + i_subfr_fx * 2] ); /*Q14+Q_exc+1 */ tmp = round_fx_o( L_shl_o( L_tmp, 1 /* (Q_exc+16)-(14+Q_exc+1)*/, &Overflow ), &Overflow ); /* tmp in Q_exc */ bwe_exc_fx[i + i_subfr_fx * 2] = add_o( tmp, tmp_code_fx[i], &Overflow ); /*Q_exc */ move16(); -#else /* BASOP_NOGLOB */ - tmp = round_fx( L_shl( L_tmp, 1 /* (Q_exc+16)-(14+Q_exc+1)*/ ) ); /* tmp in Q_exc */ - bwe_exc_fx[i + i_subfr_fx * 2] = add( tmp, tmp_code_fx[i] ); /*Q_exc */ - move16(); -#endif } } @@ -7789,11 +7357,7 @@ void prep_tbe_exc_ivas_fx( tmp = MAX_16; move16(); -#ifdef BASOP_NOGLOB pitch = shl_o( add( shl_o( T0, 2, &Overflow ), T0_frac ), 5, &Overflow ); /* Q7 */ -#else /* BASOP_NOGLOB */ - pitch = shl( add( shl( T0, 2 ), T0_frac ), 5 ); /* Q7 */ -#endif /* BASOP_NOGLOB */ test(); test(); @@ -7823,25 +7387,15 @@ void prep_tbe_exc_ivas_fx( #endif IF( EQ_16( L_frame_fx, L_FRAME ) ) { - interp_code_5over2_fx( code_fx, tmp_code_fx, L_subfr ); /* code: Q9, tmp_code: Q9 */ -#ifdef BASOP_NOGLOB + interp_code_5over2_fx( code_fx, tmp_code_fx, L_subfr ); /* code: Q9, tmp_code: Q9 */ gain_code16 = round_fx_o( L_shl_o( gain_code_fx, Q_exc, &Overflow ), &Overflow ); /*Q_exc */ -#else - gain_code16 = round_fx( L_shl( gain_code_fx, Q_exc ) ); /*Q_exc */ -#endif FOR( i = 0; i < L_subfr * HIBND_ACB_L_FAC; i++ ) { - L_tmp = L_mult( gain_code16, tmp_code_fx[i] ); /* Q9 + Q_exc + 1*/ - L_tmp = L_shl( L_tmp, 5 ); /* Q9 + Q_exc + Q6*/ -#ifdef BASOP_NOGLOB + L_tmp = L_mult( gain_code16, tmp_code_fx[i] ); /* Q9 + Q_exc + 1*/ + L_tmp = L_shl( L_tmp, 5 ); /* Q9 + Q_exc + Q6*/ L_tmp = L_mac_o( L_tmp, gain_pit_fx, bwe_exc_fx[i + i_subfr_fx * HIBND_ACB_L_FAC], &Overflow ); /*Q15+Q_exc */ L_tmp = L_shl_o( L_tmp, 1, &Overflow ); /*16+Q_exc */ /* saturation can occur here */ bwe_exc_fx[i + i_subfr_fx * HIBND_ACB_L_FAC] = round_fx_o( L_tmp, &Overflow ); /*Q_exc */ -#else /* BASOP_NOGLOB */ - L_tmp = L_mac( L_tmp, gain_pit_fx, bwe_exc_fx[i + i_subfr_fx * HIBND_ACB_L_FAC] ); /*Q15+Q_exc */ - L_tmp = L_shl( L_tmp, 1 ); /*16+Q_exc */ /* saturation can occur here */ - bwe_exc_fx[i + i_subfr_fx * HIBND_ACB_L_FAC] = round_fx( L_tmp ); /*Q_exc */ -#endif /* BASOP_NOGLOB */ move16(); } } @@ -7857,17 +7411,10 @@ void prep_tbe_exc_ivas_fx( Ltemp1 = Mult_32_16( gain_code_fx, code_fx[i] ); /* Q16 + Q9 + 1 - 16 = Q10 */ Ltemp2 = L_mult( gain_preQ_fx, code_preQ_fx[i] ); /*Q2 * Q10 -> Q12 */ -#ifdef BASOP_NOGLOB Ltemp1 = L_shl_o( Ltemp1, add( Q_exc, 6 ) /*Q_exc+16-19*/, &Overflow ); /*Q_exc+16 */ Ltemp2 = L_shl_o( Ltemp2, add( Q_exc, shift ) /*Q_exc+ 2 + 6 (or) 10 - 13*/, &Overflow ); /*Q_exc+16 */ tmp_code_preInt_fx[i] = round_fx_o( L_add_o( Ltemp1, Ltemp2, &Overflow ), &Overflow ); /* Q_exc */ -#else /* BASOP_NOGLOB */ - Ltemp1 = L_shl( Ltemp1, Q_exc + 6 /*Q_exc+16-19*/ ); /*Q_exc+16 */ - Ltemp2 = L_shl( Ltemp2, Q_exc + 4 /*Q_exc+16-13*/ ); /*Q_exc+16 */ - - tmp_code_preInt_fx[i] = round_fx( L_add( Ltemp1, Ltemp2 ) ); /* Q_exc */ -#endif /* BASOP_NOGLOB */ move16(); } } @@ -7876,14 +7423,9 @@ void prep_tbe_exc_ivas_fx( FOR( i = 0; i < L_subfr; i++ ) { /*code in the encoder is Q9 and there is no <<1 with Mult_32_16 Q16 * Q9 -> Q9 */ - Ltemp1 = Mult_32_16( gain_code_fx, code_fx[i] ); /* Q16 + Q9 + 1 - 16 = Q10 */ -#ifdef BASOP_NOGLOB + Ltemp1 = Mult_32_16( gain_code_fx, code_fx[i] ); /* Q16 + Q9 + 1 - 16 = Q10 */ Ltemp1 = L_shl_o( Ltemp1, add( Q_exc, 6 ) /*Q_exc+16-19*/, &Overflow ); /*Q_exc+16 */ tmp_code_preInt_fx[i] = round_fx_o( Ltemp1, &Overflow ); /* Q_exc */ -#else - Ltemp1 = L_shl( Ltemp1, Q_exc + 6 /*Q_exc+16-19*/ ); /*Q_exc+16 */ - tmp_code_preInt_fx[i] = round_fx( Ltemp1 ); /* Q_exc */ -#endif move16(); } } @@ -7891,16 +7433,10 @@ void prep_tbe_exc_ivas_fx( interp_code_4over2_fx( tmp_code_preInt_fx, tmp_code_fx, L_subfr ); /* o: tmp_code in Q_exc */ FOR( i = 0; i < shl( L_subfr, 1 ); i++ ) { - L_tmp = L_mult( gain_pit_fx, bwe_exc_fx[i + shl( i_subfr_fx, 1 )] ); /*Q14+Q_exc+1 */ -#ifdef BASOP_NOGLOB + L_tmp = L_mult( gain_pit_fx, bwe_exc_fx[i + shl( i_subfr_fx, 1 )] ); /*Q14+Q_exc+1 */ tmp = round_fx_o( L_shl_o( L_tmp, 1 /* (Q_exc+16)-(14+Q_exc+1)*/, &Overflow ), &Overflow ); /* tmp in Q_exc */ bwe_exc_fx[i + shl( i_subfr_fx, 1 )] = add_o( tmp, tmp_code_fx[i], &Overflow ); /*Q_exc */ move16(); -#else /* BASOP_NOGLOB */ - tmp = round_fx( L_shl( L_tmp, 1 /* (Q_exc+16)-(14+Q_exc+1)*/ ) ); /* tmp in Q_exc */ - bwe_exc_fx[i + i_subfr_fx * 2] = add( tmp, tmp_code_fx[i] ); /*Q_exc */ - move16(); -#endif } } @@ -7963,11 +7499,7 @@ Word16 swb_formant_fac_fx( /* o : Formant filter strength /* formant_fac = 1.0f - 0.5f*formant_fac */ tmp = mult_r( 16384, formant_fac ); /* 0.5 in Q15 */ -#ifdef BASOP_NOGLOB formant_fac = shl_o( sub( 4096 /* 1 in Q12 */, tmp ), 3, &Overflow ); -#else - formant_fac = shl( sub( 4096, tmp ), 3 ); -#endif return formant_fac; /*Q15 */ } diff --git a/lib_com/syn_filt_fx.c b/lib_com/syn_filt_fx.c index 082ccb4c85e44f7bd5bb9fc5550641489e1aa183..6e0f7e716fe0805021cb84d32f99f69cb7af69a0 100644 --- a/lib_com/syn_filt_fx.c +++ b/lib_com/syn_filt_fx.c @@ -14,13 +14,8 @@ static Word32 syn_kern_2( Word32 L_tmp, const Word16 a[], const Word16 y[] ) #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; #endif -#ifdef BASOP_NOGLOB L_tmp = L_msu_o( L_tmp, y[-1], a[1], &Overflow ); return L_msu_o( L_tmp, y[-2], a[2], &Overflow ); -#else - L_tmp = L_msu( L_tmp, y[-1], a[1] ); - return L_msu( L_tmp, y[-2], a[2] ); -#endif } static Word32 syn_kern_4( Word32 L_tmp, const Word16 a[], const Word16 y[] ) @@ -135,33 +130,19 @@ void syn_filt_s_lc_fx( /* Stop at i to Avoid Mults with Zeros */ FOR( j = 1; j <= i; j++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_msu_sat( L_tmp, y[-j], a[j] ); -#else - L_tmp = L_msu( L_tmp, y[-j], a[j] ); -#endif } -#ifdef BASOP_NOGLOB L_tmp = L_shl_sat( L_tmp, q ); *y++ = round_fx_sat( L_tmp ); -#else - L_tmp = L_shl( L_tmp, q ); - *y++ = round_fx( L_tmp ); -#endif move16(); } FOR( ; i < lg; i++ ) { L_tmp = syn_kern_16( L_mult( *x++, a0 ), a, y ); -#ifdef BASOP_NOGLOB L_tmp = L_shl_sat( L_tmp, q ); *y++ = round_fx_sat( L_tmp ); -#else - L_tmp = L_shl( L_tmp, q ); - *y++ = round_fx( L_tmp ); -#endif move16(); } } @@ -204,22 +185,17 @@ void syn_filt_fx( { Word16 i, j; Word16 buf[L_FRAME48k + L_FRAME48k / 2 + TCXLTP_LTP_ORDER]; /* temporary synthesis buffer */ - Word16 s, *yy; + Word16 *yy; + Word32 s; Word16 q; -#ifdef BASOP_NOGLOB Flag Overflow = 0; move16(); -#endif Word16 a0; yy = &buf[0]; q = add( norm_s( a[0] ), 1 ); -#ifdef BASOP_NOGLOB a0 = shr_o( a[0], shift, &Overflow ); /* input / 2^shift */ -#else - a0 = shr( a[0], shift ); /* input / 2^shift */ -#endif /*------------------------------------------------------------------* * copy initial filter states into synthesis buffer and do synthesis @@ -237,23 +213,16 @@ void syn_filt_fx( FOR( i = 0; i < l; i++ ) { -#ifdef BASOP_NOGLOB - s = mult_r( shl_o( a0, q, &Overflow ), x[i] ); -#else - s = mult_r( shl( a0, q ), x[i] ); -#endif + s = L_mult( a0, x[i] ); FOR( j = 1; j <= m; j++ ) { -#ifdef BASOP_NOGLOB - s = msu_ro( L_deposit_h( s ), shl_o( a[j], q, &Overflow ), yy[i - j], &Overflow ); -#else - s = msu_r( L_deposit_h( s ), shl( a[j], q ), yy[i - j] ); -#endif + s = L_msu_sat( s, shr( a[j], shift ), yy[i - j] ); } - yy[i] = s; + s = L_shl_sat( s, q ); + yy[i] = extract_h( s ); move16(); - y[i] = s; + y[i] = extract_h( s ); move16(); } @@ -274,6 +243,80 @@ void syn_filt_fx( } +void syn_filt_fx32( + const Word16 a_e, /* i : exp of LP coeffs Q0 */ + const Word32 a[], /* i : LP filter coefficients Q12 */ + const Word16 m, /* i : order of LP filter Q0 */ + const Word32 x[], /* i : input signal Qx */ + const Word16 x_e, /* i : input signal Qx */ + Word32 y[], /* o : output signal Qx */ + Word16 *y_e, /* o : output signal Qx */ + const Word16 l, /* i : size of filtering Q0 */ + Word32 mem[], /* i/o: initial filter states Qx */ + Word16 *mem_e, /* i/o: initial filter states Qx */ + const Word16 update_m /* i : update memory flag Q0 : 0 --> no memory update */ + ) /* 1 --> update of memory */ +{ + Word16 i, j; + Word64 buf[L_FRAME48k + L_FRAME48k / 2 + TCXLTP_LTP_ORDER]; /* temporary synthesis buffer */ + Word64 s, *yy; + + yy = &buf[0]; + + /*------------------------------------------------------------------* + * copy initial filter states into synthesis buffer and do synthesis + *------------------------------------------------------------------*/ + + FOR( i = 0; i < m; i++ ) + { + *yy++ = W_deposit32_l( mem[i] ); + move32(); + } + + /*-----------------------------------------------------------------------* + * Do the filtering + *-----------------------------------------------------------------------*/ + Word64 max_val = 1; + FOR( i = 0; i < l; i++ ) + { + s = W_deposit32_l( x[i] ); + FOR( j = 1; j <= m; j++ ) + { + s = W_sub( s, W_mult0_32_32( a[j], W_extract_l( W_shr( yy[i - j], sub( 31, a_e ) ) ) ) ); + } + + yy[i] = s; + move32(); + if ( GT_64( W_abs( s ), max_val ) ) + { + max_val = W_abs( s ); + } + } + + Word16 norm = W_norm( max_val ); + + FOR( i = 0; i < l; i++ ) + { + y[i] = W_extract_l( W_shr( yy[i], sub( 32, norm ) ) ); + } + *y_e = sub( 31, add( sub( 31, x_e ), sub( norm, 32 ) ) ); + /*------------------------------------------------------------------* + * Update memory if required + *------------------------------------------------------------------*/ + + IF( update_m ) + { + FOR( i = 0; i < m; i++ ) + { + mem[i] = W_extract_l( W_shr( yy[l - m + i], sub( 32, norm ) ) ); + } + *mem_e = sub( 31, add( sub( 31, x_e ), sub( norm, 32 ) ) ); + } + + return; +} + + /* * E_UTIL_synthesis * @@ -330,23 +373,14 @@ void E_UTIL_synthesis( const Word16 shift, const Word16 a[], const Word16 x[], W *-----------------------------------------------------------------------*/ mem += m; /*move16();*/ -#ifdef BASOP_NOGLOB a0 = shr_o( a[0], shift, &Overflow ); /* input / 2^shift */ -#else - a0 = shr( a[0], shift ); /* input / 2^shift */ -#endif /*-----------------------------------------------------------------------* * Do the filtering *-----------------------------------------------------------------------*/ /* Filtering Only from Input + Memory */ L_tmp = syn_kern( L_mult( a0, *x++ ), a, mem ); -#ifdef BASOP_NOGLOB L_tmp = L_shl_o( L_tmp, q, &Overflow ); *y++ = round_fx_o( L_tmp, &Overflow ); -#else - L_tmp = L_shl( L_tmp, q ); - *y++ = round_fx( L_tmp ); -#endif move16(); /* Filtering from Input + Mix of Memory & Output Signal Past */ @@ -356,28 +390,15 @@ void E_UTIL_synthesis( const Word16 shift, const Word16 a[], const Word16 x[], W /* Process Output Signal Past */ FOR( j = 1; j <= i; j++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_msu_o( L_tmp, a[j], y[-j], &Overflow ); -#else - L_tmp = L_msu( L_tmp, a[j], y[-j] ); -#endif } /* Process Memory */ FOR( ; j <= m; j++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_msu_sat( L_tmp, a[j], mem[i - j] ); -#else - L_tmp = L_msu( L_tmp, a[j], mem[i - j] ); -#endif } -#ifdef BASOP_NOGLOB L_tmp = L_shl_o( L_tmp, q, &Overflow ); *y++ = round_fx_o( L_tmp, &Overflow ); -#else - L_tmp = L_shl( L_tmp, q ); - *y++ = round_fx( L_tmp ); -#endif move16(); } @@ -385,13 +406,8 @@ void E_UTIL_synthesis( const Word16 shift, const Word16 a[], const Word16 x[], W FOR( ; i < lg; i++ ) { L_tmp = syn_kern( L_mult( a0, *x++ ), a, y ); -#ifdef BASOP_NOGLOB L_tmp = L_shl_o( L_tmp, q, &Overflow ); *y++ = round_fx_o( L_tmp, &Overflow ); -#else /* BASOP_NOGLOB */ - L_tmp = L_shl( L_tmp, q ); - *y++ = round_fx( L_tmp ); -#endif move16(); } diff --git a/lib_com/tcq_position_arith_fx.c b/lib_com/tcq_position_arith_fx.c index 581ef7395240953b989c8d5f246e8390e08aa09e..0466dc133ffdcfacc31ed63696c9eda864027398 100644 --- a/lib_com/tcq_position_arith_fx.c +++ b/lib_com/tcq_position_arith_fx.c @@ -942,14 +942,9 @@ Word32 GetISCScale_fx( tmp16 = extract_l( t32 ); } } -#ifdef BASOP_NOGLOB tmp32 = L_shl_sat( tmp32, sub( 1, SafeExp ) ); /* *2 */ tmp32 = L_sub_sat( L_shl_sat( L_mult0( g_fx, tmp16 ), sub( Qsxy, exp ) ), tmp32 ); /*Qsxy */ -#else - tmp32 = L_shl( tmp32, 1 - SafeExp ); /* *2 */ - tmp32 = L_sub( L_shl( L_mult0( g_fx, tmp16 ), sub( Qsxy, exp ) ), tmp32 ); /*Qsxy */ -#endif - dist_fx[i] = Mult_32_16( tmp32, g_fx ); /*Qsxy + exp - 15 */ + dist_fx[i] = Mult_32_16( tmp32, g_fx ); /*Qsxy + exp - 15 */ move32(); exp_dist[i] = add( sub( Qsxy, 15 ), exp ); move16(); @@ -1988,7 +1983,11 @@ 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(); @@ -2471,7 +2470,11 @@ void decode_mangitude_tcq_fx( move16(); bits_fx = L_deposit_l( 0 ); +#ifdef IVAS_ISSUE_1188_EVS_CRASH + tcq_bits_fx = L_sub( table_logcum_fx[npulses], L_add( table_logcum_fx[nzpos], table_logcum_fx[npulses - ( nzpos - 1 )] ) ); +#else tcq_bits_fx = L_sub( table_logcum_fx[npulses], L_add( table_logcum_fx[nzpos], table_logcum_fx[npulses - nzpos - 1] ) ); +#endif IF( EQ_16( nzpos, npulses ) ) { diff --git a/lib_com/tcx_ltp_fx.c b/lib_com/tcx_ltp_fx.c index a42272f0b7a5806dbaaf6febb9e62d4544b2891a..55228e0b348b663d3d7c9eba8dd3408c9ef146b7 100644 --- a/lib_com/tcx_ltp_fx.c +++ b/lib_com/tcx_ltp_fx.c @@ -44,12 +44,8 @@ void tcx_ltp_get_lpc( if ( L_tmp > 0 ) r = L_shr( r, 2 ); - tmp = shl( x[j], s ); /* Qx + s */ -#ifdef BASOP_NOGLOB + tmp = shl( x[j], s ); /* Qx + s */ r = L_mac0_sat( r, tmp, tmp ); /* Q30 */ -#else - r = L_mac0( r, tmp, tmp ); -#endif } r = L_max( r, L_shl( 100, shl( s, 1 ) ) ); /* Q30 */ r = Mpy_32_16_1( r, 16386 /*1.0001f Q14*/ ); /* Q29 */ @@ -249,25 +245,15 @@ static void tcx_ltp_get_zir( move16(); FOR( i = 0; i < L; i++ ) { -#ifdef BASOP_NOGLOB s = L_mac_sat( L_mac_sat( s, w0[k], x0[i] ), w1[k], x1[-i] ); /* Qx */ s2 = L_mac_sat( L_mac_sat( s2, v0[k], y0[i] ), v1[k], y1[-i] ); /* Qx */ -#else - s = L_mac( L_mac( s, w0[k], x0[i] ), w1[k], x1[-i] ); - s2 = L_mac( L_mac( s2, v0[k], y0[i] ), v1[k], y1[-i] ); -#endif k = k + pitres; } /* s2 *= ALPHA; buf[j] = ( synth[j] - gain * s2 ) - ( synth_ltp[j] - gain * s ); */ -#ifdef BASOP_NOGLOB i = sub_sat( round_fx_sat( s ), mult_r_sat( round_fx_sat( s2 ), ALPHA ) ); buf[j] = add_sat( sub_sat( synth[j], synth_ltp[j] ), mult_r_sat( gain, i ) ); /* Qx */ -#else - i = sub( round_fx( s ), mult_r( round_fx( s2 ), ALPHA ) ); - buf[j] = add( sub( synth[j], synth_ltp[j] ), mult_r( gain, i ) ); -#endif move16(); x0++; @@ -422,17 +408,10 @@ void predict_signal( FOR( j = 0; j < L_subfr; j++ ) { -#ifdef BASOP_NOGLOB s = L_mult_o( win[0], x0[0], &Overflow ); /* Qx + 16 */ s = L_mac_o( s, win[1], x0[1], &Overflow ); /* Qx + 16 */ s = L_mac_o( s, win[2], x0[2], &Overflow ); /* Qx + 16 */ excO[j] = mac_ro( s, win[3], x0[3], &Overflow ); /* Qx + 16 */ -#else - s = L_mult( win[0], x0[0] ); - s = L_mac( s, win[1], x0[1] ); - s = L_mac( s, win[2], x0[2] ); - excO[j] = mac_r( s, win[3], x0[3] ); -#endif move16(); x0++; @@ -512,13 +491,8 @@ static void tcx_ltp_synth_filter( move16(); FOR( i = 0; i < L; i++ ) { -#ifdef BASOP_NOGLOB s = L_mac_sat( L_mac_sat( s, w0[k], x0[i] ), w1[k], x1[-i] ); /* Qx */ s2 = L_mac_sat( L_mac_sat( s2, v0[k], y0[i] ), v1[k], y1[-i] ); /* Qx */ -#else - s = L_mac( L_mac( s, w0[k], x0[i] ), w1[k], x1[-i] ); - s2 = L_mac( L_mac( s2, v0[k], y0[i] ), v1[k], y1[-i] ); -#endif k = k + pitch_res; } @@ -526,39 +500,24 @@ static void tcx_ltp_synth_filter( normal: synth_ltp[j] = synth[j] - gain * s2 + gain * s; zir: synth_ltp[j] = synth[j] - gain * s2 + gain * s - zir[j]; fade-in/out: synth_ltp[j] = synth[j] - alpha * gain * s2 + alpha * gain * s; */ -#ifdef BASOP_NOGLOB i = sub_sat( round_fx_sat( s ), mult_r_sat( round_fx_sat( s2 ), ALPHA ) ); /* Qx */ -#else - i = sub( round_fx( s ), mult_r( round_fx( s2 ), ALPHA ) ); -#endif - k = mult_r( gain, i ); /* Qx */ + k = mult_r( gain, i ); /* Qx */ if ( fade != 0 ) k = mult_r( k, alpha ); /* Qx */ -#ifdef BASOP_NOGLOB k = add_sat( synth[j], k ); /* Qx */ if ( zir != NULL ) { k = sub_sat( k, zir[j] ); /* Qx */ } -#else - k = add( synth[j], k ); - if ( zir != NULL ) - k = sub( k, zir[j] ); -#endif synth_ltp[j] = k; /* Qx */ move16(); BASOP_SATURATE_WARNING_OFF_EVS; -#ifdef BASOP_NOGLOB if ( fade != 0 ) { alpha = add_sat( alpha, step ); } -#else - if ( fade != 0 ) - alpha = add( alpha, step ); -#endif BASOP_SATURATE_WARNING_ON_EVS; x0++; @@ -646,13 +605,8 @@ static void tcx_ltp_synth_filter32( move16(); FOR( i = 0; i < L; i++ ) { -#ifdef BASOP_NOGLOB s = Madd_32_16_r( Madd_32_16_r( s, x0[i], w0[k] ), x1[-i], w1[k] ); /* Qx */ s2 = Madd_32_16_r( Madd_32_16_r( s2, y0[i], v0[k] ), y1[-i], v1[k] ); /* Qx */ -#else - s = L_mac( L_mac( s, w0[k], x0[i] ), w1[k], x1[-i] ); - s2 = L_mac( L_mac( s2, v0[k], y0[i] ), v1[k], y1[-i] ); -#endif k = k + pitch_res; } @@ -660,39 +614,24 @@ static void tcx_ltp_synth_filter32( normal: synth_ltp[j] = synth[j] - gain * s2 + gain * s; zir: synth_ltp[j] = synth[j] - gain * s2 + gain * s - zir[j]; fade-in/out: synth_ltp[j] = synth[j] - alpha * gain * s2 + alpha * gain * s; */ -#ifdef BASOP_NOGLOB L_tmp = L_sub_sat( s, Mpy_32_16_r( s2, ALPHA ) ); /* Qx */ -#else - i = sub( round_fx( s ), mult_r( round_fx( s2 ), ALPHA ) ); -#endif - L_tmp2 = Mpy_32_16_r( L_tmp, gain ); /* Qx */ + L_tmp2 = Mpy_32_16_r( L_tmp, gain ); /* Qx */ IF( fade != 0 ) - L_tmp2 = Mpy_32_16_r( L_tmp2, alpha ); /* Qx */ -#ifdef BASOP_NOGLOB + L_tmp2 = Mpy_32_16_r( L_tmp2, alpha ); /* Qx */ L_tmp2 = L_add_sat( synth[j], L_tmp2 ); /* Qx */ if ( zir != NULL ) { L_tmp2 = L_sub_sat( L_tmp2, zir[j] ); /* Qx */ } -#else - L_tmp2 = add( synth[j], L_tmp2 ); - if ( zir != NULL ) - L_tmp2 = sub( L_tmp2, zir[j] ); -#endif synth_ltp[j] = L_tmp2; /* Qx */ move16(); BASOP_SATURATE_WARNING_OFF_EVS; -#ifdef BASOP_NOGLOB if ( fade != 0 ) { alpha = add_sat( alpha, step ); } -#else - if ( fade != 0 ) - alpha = add( alpha, step ); -#endif BASOP_SATURATE_WARNING_ON_EVS; x0++; diff --git a/lib_com/tcx_mdct_fx.c b/lib_com/tcx_mdct_fx.c index 26e7e234569154959b5b3f628448f7a1184a7269..1fc57871d4b4a6ab7096c28bc6dda728ee5cbd39 100644 --- a/lib_com/tcx_mdct_fx.c +++ b/lib_com/tcx_mdct_fx.c @@ -128,11 +128,7 @@ void TCX_MDCT( } FOR( i = 0; i < l / 2; i++ ) { -#ifdef BASOP_NOGLOB y[m / 2 + r / 2 + m / 2 + i] = L_msu_o( L_mult( x[i], factor ), x[l - 1 - i], factor, &Overflow ); /* exp(y_e) */ -#else /* BASOP_NOGLOB */ - y[m / 2 + r / 2 + m / 2 + i] = L_msu( L_mult( x[i], factor ), x[l - 1 - i], factor ); -#endif /* BASOP_NOGLOB */ move32(); } FOR( i = 0; i < m / 2; i++ ) @@ -142,11 +138,7 @@ void TCX_MDCT( } FOR( i = 0; i < r / 2; i++ ) { -#ifdef BASOP_NOGLOB y[m / 2 + r / 2 - 1 - m / 2 - i] = L_mac_o( L_mult( x[l + m + i], neg_factor ), x[l + m + r - 1 - i], neg_factor, &Overflow ); /* exp(y_e) */ -#else /* BASOP_NOGLOB */ - y[m / 2 + r / 2 - 1 - m / 2 - i] = L_mac( L_mult( x[l + m + i], neg_factor ), x[l + m + r - 1 - i], neg_factor ); -#endif /* BASOP_NOGLOB */ move32(); } @@ -194,11 +186,7 @@ void TCX_MDST( } FOR( i = 0; i < l / 2; i++ ) { -#ifdef BASOP_NOGLOB y[m / 2 + r / 2 + m / 2 + i] = L_msu_o( L_mult( x[i], neg_factor ), x[l - 1 - i], factor, &Overflow ); /* exp(y_e) */ -#else /* BASOP_NOGLOB */ - y[m / 2 + r / 2 + m / 2 + i] = L_msu( L_mult( x[i], neg_factor ), x[l - 1 - i], factor ); -#endif move32(); } FOR( i = 0; i < m / 2; i++ ) @@ -208,11 +196,7 @@ void TCX_MDST( } FOR( i = 0; i < r / 2; i++ ) { -#ifdef BASOP_NOGLOB y[m / 2 + r / 2 - 1 - m / 2 - i] = L_mac_sat( L_mult( x[l + m + i], neg_factor ), x[l + m + r - 1 - i], factor ); /* exp(y_e) */ -#else - y[m / 2 + r / 2 - 1 - m / 2 - i] = L_mac( L_mult( x[l + m + i], neg_factor ), x[l + m + r - 1 - i], factor ); -#endif move32(); } @@ -262,22 +246,14 @@ void TCX_MDCT_Inverse( FOR( i = 0; i < R2; i++ ) { -#ifdef BASOP_NOGLOB y[l + m + R2 + i] = round_fx_sat( L_shl_sat( Mpy_32_16_1( tmp_buf[L2 + i], negfac ), s ) ); /* fold out right end of DCT exp(fac_e)*/ -#else - y[l + m + R2 + i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[L2 + i], negfac ), s ) ); /* fold out right end of DCT */ -#endif move16(); } FOR( i = 0; i < L2; i++ ) { -#ifdef BASOP_NOGLOB y[i] = round_fx_sat( L_shl_sat( Mpy_32_16_1( tmp_buf[L2 + m + R2 + i], fac ), s ) ); /* negate, fold out left end of DCT exp(fac_e)*/ -#else - y[i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[L2 + m + R2 + i], fac ), s ) ); /* negate, fold out left end of DCT */ -#endif move16(); } @@ -285,13 +261,8 @@ void TCX_MDCT_Inverse( { Word16 f; -#ifdef BASOP_NOGLOB f = round_fx_sat( L_shl_sat( Mpy_32_16_1( tmp_buf[L2 + i], negfac ), s ) ); y[L2 + i] = round_fx_sat( L_shl_sat( Mpy_32_16_1( tmp_buf[l + m + R2 - 1 - i], negfac ), s ) ); /* time-reverse mid of DCT exp(fac_e)*/ -#else - f = round_fx( L_shl( Mpy_32_16_1( tmp_buf[L2 + i], negfac ), s ) ); - y[L2 + i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[l + m + R2 - 1 - i], negfac ), s ) ); /* time-reverse mid of DCT */ -#endif move16(); y[l + m + R2 - 1 - i] = f; move16(); diff --git a/lib_com/tcx_utils_fx.c b/lib_com/tcx_utils_fx.c index 26e29b10423f8562d2fbc0d8e60a3c66d1302e4d..4e40e4ab2d30843044c2c715bb0624e7984d2e37 100644 --- a/lib_com/tcx_utils_fx.c +++ b/lib_com/tcx_utils_fx.c @@ -348,11 +348,7 @@ void tcx_windowing_synthesis_current_frame( } ELSE { -#ifdef BASOP_NOGLOB lerp( acelp_zir, tmp_buf, acelp_zir_len, idiv1616U( shl_sat( acelp_zir_len, LD_FSCALE_DENOM ), fullbandScale ) ); -#else - lerp( acelp_zir, tmp_buf, acelp_zir_len, idiv1616U( shl( acelp_zir_len, LD_FSCALE_DENOM ), fullbandScale ) ); -#endif acelp_zir = tmp_buf; /*Qx*/ } @@ -387,17 +383,10 @@ void tcx_windowing_synthesis_current_frame( tmp2 = mult_r( signal[i + overlap - acelp_mem_len], window_trans[i].v.im ); /*Qx*/ /*Time TDAC: 1)forward part of ACELP*/ -#ifdef BASOP_NOGLOB tmp2 = add_sat( tmp2, mult_r( old_syn[acelp_zir_len - tmp + i], mult_r( window_trans[i].v.re, window_trans[i].v.re ) ) ); /*Qx*/ /*Time TDAC: 1)reward part of ACELP*/ tmp2 = add_sat( tmp2, mult_r( old_syn[acelp_zir_len - i - 1], mult_r( window_trans[i].v.im, window_trans[i].v.re ) ) ); /*Qx*/ -#else - tmp2 = add( tmp2, mult_r( old_syn[acelp_zir_len - tmp + i], mult_r( window_trans[i].v.re, window_trans[i].v.re ) ) ); - - /*Time TDAC: 1)reward part of ACELP*/ - tmp2 = add( tmp2, mult_r( old_syn[acelp_zir_len - i - 1], mult_r( window_trans[i].v.im, window_trans[i].v.re ) ) ); -#endif move16(); signal[i + overlap - acelp_mem_len] = tmp2; /*Qx*/ } @@ -408,17 +397,9 @@ void tcx_windowing_synthesis_current_frame( tmp2 = mult_r( signal[i + overlap - acelp_mem_len], window_trans[tmp - 1 - i].v.re ); /*Qx*/ /*Time TDAC: 1)forward part of ACELP*/ -#ifdef BASOP_NOGLOB tmp2 = add_sat( tmp2, mult_r( old_syn[acelp_zir_len - tmp + i], mult_r( window_trans[tmp - 1 - i].v.im, window_trans[tmp - 1 - i].v.im ) ) ); /*Qx*/ -#else - tmp2 = add( tmp2, mult_r( old_syn[acelp_zir_len - tmp + i], mult_r( window_trans[tmp - 1 - i].v.im, window_trans[tmp - 1 - i].v.im ) ) ); -#endif /*Time TDAC: 1)reward part of ACELP*/ -#ifdef BASOP_NOGLOB tmp2 = add_sat( tmp2, mult_r( old_syn[acelp_zir_len - i - 1], mult_r( window_trans[tmp - 1 - i].v.re, window_trans[tmp - 1 - i].v.im ) ) ); /*Qx*/ -#else - tmp2 = add( tmp2, mult_r( old_syn[acelp_zir_len - i - 1], mult_r( window_trans[tmp - 1 - i].v.re, window_trans[tmp - 1 - i].v.im ) ) ); -#endif move16(); signal[i + overlap - acelp_mem_len] = tmp2; /*Qx*/ } @@ -426,11 +407,7 @@ void tcx_windowing_synthesis_current_frame( FOR( i = 0; i < M; i++ ) { move16(); -#ifdef BASOP_NOGLOB signal[overlap + acelp_mem_len - M + i] = sub_sat( signal[overlap + acelp_mem_len - M + i], old_syn[acelp_zir_len - M + i] ); /*Qx*/ -#else - signal[overlap + acelp_mem_len - M + i] = sub( signal[overlap + acelp_mem_len - M + i], old_syn[acelp_zir_len - M + i] ); -#endif } } /* ZIR at the end of the ACELP frame */ @@ -484,11 +461,7 @@ void tcx_windowing_synthesis_current_frame( { /*remove reconstructed ZIR and add ACELP ZIR*/ move16(); -#ifdef BASOP_NOGLOB signal[i + overlap + acelp_mem_len] = sub_sat( signal[i + overlap + acelp_mem_len], mult_r_sat( acelp_zir[i], div_s( sub_sat( acelp_zir_len, i ), acelp_zir_len ) ) ); /*Qx*/ -#else - signal[i + overlap + acelp_mem_len] = sub( signal[i + overlap + acelp_mem_len], mult_r( acelp_zir[i], div_s( sub( acelp_zir_len, i ), acelp_zir_len ) ) ); -#endif } } /* Rectangular window (past-frame is TCX) */ @@ -1072,11 +1045,7 @@ void mdct_shaping( FOR( l = 0; l < k; l++ ) { -#ifdef BASOP_NOGLOB *x = L_shl_o( Mpy_32_16_r( *x, *gains ), *gains_exp, &Overflow ); /*Qx*/ -#else - *x = L_shl( Mpy_32_16_r( *x, *gains ), *gains_exp ); /*Qx*/ -#endif move32(); x++; } @@ -1095,11 +1064,7 @@ void mdct_shaping( gains_exp = pgainsexp; FOR( i = 0; i < FDNS_NPTS; i++ ) { -#ifdef BASOP_NOGLOB *x = L_shl_o( Mpy_32_16_r( *x, *gains ), *gains_exp, &Overflow ); /*Qx*/ -#else - *x = L_shl( Mpy_32_16_r( *x, *gains ), *gains_exp ); -#endif move32(); x += k; gains++; @@ -1474,12 +1439,8 @@ void PsychAdaptLowFreqDeemph( L_tmp = BASOP_Util_Log2( L_tmp ); /* Q25 */ L_tmp = L_shr( L_tmp, 7 ); /* 0.0078125f = 1.f/(1<<7) */ L_tmp = BASOP_Util_InvLog2( L_tmp ); /* Q31 */ -#ifdef BASOP_NOGLOB - tmp = round_fx_o( L_tmp, &Overflow ); /* Q15 */ -#else /* BASOP_NOGLOB */ - tmp = round_fx( L_tmp ); /* Q15 */ -#endif - fac = tmp; /* Q15 */ + tmp = round_fx_o( L_tmp, &Overflow ); /* Q15 */ + fac = tmp; /* Q15 */ move16(); /* gradual lowering of lowest 32 bins; DC is lowered by (max_val/tmp)^1/4 */ @@ -1714,11 +1675,7 @@ void tcx_noise_filling( tmp32 = BASOP_Util_Log2( L_deposit_h( s_max( 0x3000, tiltCompFactor ) ) ); /* 6Q25 */ tmp32 = L_shr( Mpy_32_16_1( tmp32, tmp1 ), 6 ); /*Q25*/ BASOP_SATURATE_WARNING_OFF_EVS; -#ifdef BASOP_NOGLOB tilt_factor = round_fx_sat( BASOP_Util_InvLog2( tmp32 ) ); /*Q15*/ -#else - tilt_factor = round_fx( BASOP_Util_InvLog2( tmp32 ) ); -#endif BASOP_SATURATE_WARNING_ON_EVS; /* find last nonzero line below iFirstLine, use it as start offset */ @@ -1860,11 +1817,7 @@ void tcx_noise_filling_with_shift( tmp32 = BASOP_Util_Log2( L_deposit_h( s_max( 0x3000, tiltCompFactor ) ) ); /* 6Q25 */ tmp32 = L_shr( Mpy_32_16_1( tmp32, tmp1 ), 6 ); /*Q25*/ BASOP_SATURATE_WARNING_OFF_EVS; -#ifdef BASOP_NOGLOB tilt_factor = round_fx_sat( BASOP_Util_InvLog2( tmp32 ) ); /*Q15*/ -#else - tilt_factor = round_fx( BASOP_Util_InvLog2( tmp32 ) ); -#endif BASOP_SATURATE_WARNING_ON_EVS; /* find last nonzero line below iFirstLine, use it as start offset */ @@ -2177,11 +2130,7 @@ void tcx_get_gain( ener = L_shl( ener, tmp ); /*Q31 - ener_e + tmp*/ ener_e = sub( ener_e, tmp ); -#ifdef BASOP_NOGLOB tmp = div_s( abs_s( round_fx_o( corr, &Overflow ) ), round_fx_o( ener, &Overflow ) ); /*Q15 - (corr_e - ener_e)*/ -#else - tmp = div_s( abs_s( round_fx( corr ) ), round_fx( ener ) ); -#endif if ( corr < 0 ) tmp = negate( tmp ); diff --git a/lib_com/tec_com.c b/lib_com/tec_com.c index c51a2cd02a77f6fe48b61088f16bf245fcc97304..0a37504df957bc577c8fc9eed3c64c0b4fa17de3 100644 --- a/lib_com/tec_com.c +++ b/lib_com/tec_com.c @@ -317,11 +317,7 @@ static void calcHiTempEnv_Fx( FOR( k = lowSubband; k < highSubband; k++ ) { -#ifdef BASOP_NOGLOB nrg = L_add_sat( nrg, L_shr( pCldfbPow[timeIndex][k], s1 ) ); /*Q31 - s1*/ -#else - nrg = L_add( nrg, L_shr( pCldfbPow[timeIndex][k], s1 ) ); -#endif } diff --git a/lib_com/tns_base.c b/lib_com/tns_base.c index 039c7a04226d8e6604b56a5fe41aecfef2d2fee1..af4a87d34a66536ac2c68eeb5b76782e0e1ff259 100644 --- a/lib_com/tns_base.c +++ b/lib_com/tns_base.c @@ -496,11 +496,7 @@ Word16 ITF_Detect_fx( /* Check threshold HLM_MIN_NRG */ BASOP_SATURATE_WARNING_OFF_EVS; -#ifdef BASOP_NOGLOB tmp32 = L_sub( L_shl_o( L_tmp, sub( shift, sub( 24, Q ) ), &Overflow ), 4194304l /*HLM_MIN_NRG Q7*/ ); /*Q7*/ -#else /* BASOP_NOGLOB */ - tmp32 = L_sub( L_shl( L_tmp, sub( shift, 24 - Q ) ), 4194304l /*HLM_MIN_NRG Q7*/ ); -#endif BASOP_SATURATE_WARNING_ON_EVS; /* get pre-shift for autocorrelation */ @@ -531,11 +527,7 @@ Word16 ITF_Detect_fx( L_tmp = L_shl( L_tmp, sub( shift, tmp ) ); /* shift L_tmp to that exponent */ /* calc factor (with 2 bits headroom for sum of 3 subdivisions) */ -#ifdef BASOP_NOGLOB facs[iSubdivisions] = div_s( 0x2000, round_fx_sat( L_tmp ) ); /* L_tmp is >= 0x2000000 Q15*/ -#else - facs[iSubdivisions] = div_s( 0x2000, round_fx( L_tmp ) ); /* L_tmp is >= 0x2000000 */ -#endif move16(); } } @@ -610,6 +602,145 @@ Word16 ITF_Detect_fx( return 1; } + +Word16 ITF_Detect_ivas_fx( + const Word32 pSpectrum[], /*Q*/ + const Word16 startLine, /*Q0*/ + const Word16 stopLine, /*Q0*/ + const Word16 maxOrder, /*Q0*/ + Word16 *A, /*Q_A*/ + Word16 *Q_A, + Word16 *predictionGain, /*Q7*/ + Word16 *curr_order, /*Q0*/ + Word16 Q ) +{ + Word32 norms[MAX_SUBDIVISIONS]; + Word16 num_subdivisions, i, length; + Word16 iStartLine, iEndLine, spectrumLength; + Word32 rxx[ITF_MAX_FILTER_ORDER + 1]; + Word16 q_rxx[ITF_MAX_FILTER_ORDER + 1]; + Word32 temp_spectrum[640]; + const Word16 *pWindow; + const Word32 *ptr_spectrum1, *ptr_spectrum2; + Word16 iSubdivisions, lag; + Word16 headroom, guard_bits, shift, q_min; + Word64 sum; + Word16 fac, q_fac, exp, q_temp; + Word32 temp; + + IF( maxOrder <= 0 ) + { + return 0; + } + pWindow = tnsAcfWindow_fx; + set_zero_fx( norms, MAX_SUBDIVISIONS ); + set_zero_fx( rxx, ITF_MAX_FILTER_ORDER + 1 ); /* This initialization is required */ + set16_fx( q_rxx, Q31, ITF_MAX_FILTER_ORDER + 1 ); /* This initialization is required */ + + spectrumLength = sub( stopLine, startLine ); + num_subdivisions = 0; + move16(); + + /* Calculate norms for each spectrum part */ + FOR( iSubdivisions = 0; iSubdivisions < MAX_SUBDIVISIONS; iSubdivisions++ ) + { + /* iStartLine = startLine + ( stopLine - startLine ) * iSubdivisions / nSubdivisions; */ + iStartLine = add( startLine, mult( imult1616( spectrumLength, iSubdivisions ), 10923 /* 1/MAX_SUBDIVISIONS in Q15 */ ) ); /*Q0*/ + /* iEndLine = startLine + ( stopLine - startLine ) * ( iSubdivisions + 1 ) / nSubdivisions; */ + iEndLine = add( startLine, mult( imult1616( spectrumLength, add( iSubdivisions, 1 ) ), 10923 /* 1/MAX_SUBDIVISIONS in Q15 */ ) ); /*Q0*/ + + + /* Variable initialization */ + /* norms[iSubdivisions] = sum2_f(pSpectrum + iStartLine - IGF_START_MN, iEndLine - iStartLine); */ + + ptr_spectrum1 = pSpectrum + sub( iStartLine, IGF_START_MN ); + length = sub( iEndLine, iStartLine ); + headroom = L_norm_arr( ptr_spectrum1, length ); + guard_bits = find_guarded_bits_fx( length ); + shift = sub( headroom, guard_bits ); + + Copy_Scale_sig32( ptr_spectrum1, temp_spectrum, length, shift ); // Q -> Q+shift + + sum = 0; + move64(); + FOR( i = 0; i < length; i++ ) + { + sum = W_mac_32_32( sum, temp_spectrum[i], temp_spectrum[i] ); // 2(Q+shift)+1 + } + + IF( LE_64( sum, W_shl( 32768 * 2 /* HLM_MIN_NRG in Q1 */, shl( add( Q, shift ), 1 ) ) ) ) + { + BREAK; + } + + /* fac = 1.0f / norms[iSubdivisions]; */ + exp = W_norm( sum ); + sum = W_shl( sum, exp ); // 2(Q+shift)+1+exp + fac = div_s( ONE_IN_Q14, extract_h( W_extract_h( sum ) ) ); // 15+14-(2(Q+shift)+1+exp-48) = 76-(2(Q+shift)+exp) + q_fac = sub( 76, add( shl( add( Q, shift ), 1 ), exp ) ); + pWindow = tnsAcfWindow_fx; + + /* For additional loop condition */ + /* Variable initialization */ + /*for ( lag = 1; lag <= maxOrder; lag++ ) + { + rxx[lag] += fac * ( *pWindow ) * dotp( pSpectrum + iStartLine - IGF_START_MN, pSpectrum + iStartLine - IGF_START_MN + lag, iEndLine - iStartLine - lag ); + pWindow++; + }*/ + + ptr_spectrum1 = temp_spectrum; // pSpectrum + iStartLine - IGF_START_MN; + FOR( lag = 1; lag <= maxOrder; lag++ ) + { + /* dotp( pSpectrum + iStartLine - IGF_START_MN, pSpectrum + iStartLine - IGF_START_MN + lag, iEndLine - iStartLine - lag ) */ + ptr_spectrum2 = temp_spectrum + lag; // pSpectrum + iStartLine - IGF_START_MN + lag; + + sum = 0; + move64(); + FOR( i = 0; i < iEndLine - iStartLine - lag; i++ ) + { + sum = W_mac_32_32( sum, ptr_spectrum1[i], ptr_spectrum2[i] ); // 2(Q+shift)+1 + } + exp = W_norm( sum ); + sum = W_shl( sum, exp ); // 2(Q+shift)+1+exp + temp = Mpy_32_32( L_mult0( fac, *pWindow ), W_extract_h( sum ) ); // (q_fac+15)+(2(Q+shift)+1+exp-32)-31 = q_fac+2(Q+shift)+exp-47 + q_temp = sub( add( q_fac, add( shl( add( Q, shift ), 1 ), exp ) ), 47 ); + + /* rxx[lag] += fac * (*pWindow) * dotp(pSpectrum + iStartLine - IGF_START_MN, pSpectrum + iStartLine - IGF_START_MN + lag, iEndLine - iStartLine - lag); */ + q_min = sub( s_min( q_temp, q_rxx[lag] ), 1 ); + rxx[lag] = L_add( L_shl( rxx[lag], sub( q_min, q_rxx[lag] ) ), L_shl( temp, sub( q_min, q_temp ) ) ); + q_rxx[lag] = q_min; + move32(); + move16(); + + pWindow++; + } + + num_subdivisions = add( num_subdivisions, 1 ); + } + + minimum_s( q_rxx + 1, ITF_MAX_FILTER_ORDER, &q_min ); + q_min = s_min( Q29, q_min ); + + FOR( i = 1; i < ITF_MAX_FILTER_ORDER; i++ ) + { + rxx[i] = L_shl( rxx[i], sub( q_min, q_rxx[i] ) ); + move32(); + } + + IF( EQ_16( iSubdivisions, MAX_SUBDIVISIONS ) ) /* meaning there is no subdivision with low energy */ + { + rxx[0] = L_shl( MAX_SUBDIVISIONS, q_min ); + move32(); + + /* Limit the maximum order to spectrum length/4 */ + ITF_GetFilterParameters_fx( rxx, s_min( maxOrder, shr( spectrumLength, 2 ) ), A, Q_A, predictionGain ); + + *curr_order = maxOrder; /*Q0*/ + move16(); + } + + return 1; +} /* Helper functions for Hufmann table coding */ diff --git a/lib_com/tools.c b/lib_com/tools.c index 7810edb94f46fdf91511d68701e6439f91ae67b6..733e5634aa9f05ec3562648a4e4e71627a34f052 100644 --- a/lib_com/tools.c +++ b/lib_com/tools.c @@ -2200,11 +2200,7 @@ double anint( int16_t is_numeric_float( float x ) { -#ifndef BASOP_NOGLOB union float_int -#else /* BASOP_NOGLOB */ - union float_int -#endif /* BASOP_NOGLOB */ { float float_val; int32_t int_val; diff --git a/lib_com/tools_fx.c b/lib_com/tools_fx.c index 746c2564afe5ebebe4c1c343159bf15e6e0cb56a..063f49fc4e226c2b6dbc5bf7d53dfbcefe2c5bfc 100644 --- a/lib_com/tools_fx.c +++ b/lib_com/tools_fx.c @@ -279,13 +279,9 @@ Word16 usdequant_fx( /* Qx*/ Word32 L_tmp; /*g = idx * delta + qlow;*/ - L_tmp = L_deposit_l( qlow ); /*Qx */ - L_tmp = L_mac( L_tmp, idx, delta ); /*Qx */ -#ifdef BASOP_NOGLOB + L_tmp = L_deposit_l( qlow ); /*Qx */ + L_tmp = L_mac( L_tmp, idx, delta ); /*Qx */ g = round_fx_sat( L_shl_sat( L_tmp, 16 ) ); /*Qx */ -#else - g = round_fx( L_shl( L_tmp, 16 ) ); /*Qx */ -#endif return ( g ); } @@ -316,26 +312,17 @@ Word16 usquant_fx( /* o: index of the winning codeword */ /* idx = (short)( (x - qlow)/delta + 0.5f); */ exp = norm_s( delta ); - tmp = div_s( shl( 1, sub( 14, exp ) ), delta ); /*Q(29-exp-(Qx-1))->Q(30-exp-Qx) */ -#ifdef BASOP_NOGLOB + tmp = div_s( shl( 1, sub( 14, exp ) ), delta ); /*Q(29-exp-(Qx-1))->Q(30-exp-Qx) */ L_tmp = L_mult( sub_o( x, qlow, &Overflow ), tmp ); /*Q(31-exp) */ idx = extract_l( L_shr_r( L_add( L_tmp, shl_o( 1, sub( 30, exp ), &Overflow ) ), sub( 31, exp ) ) ); /*Q0 */ -#else /* BASOP_NOGLOB */ - L_tmp = L_mult( sub( x, qlow ), tmp ); /*Q(31-exp) */ - idx = extract_l( L_shr_r( L_add( L_tmp, shl( 1, sub( 30, exp ) ) ), sub( 31, exp ) ) ); /*Q0 */ -#endif /* BASOP_NOGLOB */ idx = s_min( idx, sub( cbsize, 1 ) ); idx = s_max( idx, 0 ); /* *xq = idx*delta + qlow; */ - L_tmp = L_deposit_l( qlow ); /*Qx */ - L_tmp = L_mac( L_tmp, idx, delta ); /*Qx */ -#ifdef BASOP_NOGLOB + L_tmp = L_deposit_l( qlow ); /*Qx */ + L_tmp = L_mac( L_tmp, idx, delta ); /*Qx */ *xq = round_fx_o( L_shl_o( L_tmp, 16, &Overflow ), &Overflow ); /*Qx */ -#else - *xq = round_fx( L_shl( L_tmp, 16 ) ); /*Qx */ -#endif return idx; } /*-------------------------------------------------------------------* @@ -408,16 +395,30 @@ Word32 sum2_fx( /* o : sum of all squared vector elements L_tmp = L_deposit_l( 0 ); FOR( i = 0; i < lvec; i++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_mac_o( L_tmp, vec[i], vec[i], &Overflow ); /*Q(2x+1) */ -#else /* BASOP_NOGLOB */ - L_tmp = L_mac( L_tmp, vec[i], vec[i] ); /*Q(2x+1) */ -#endif /* BASOP_NOGLOB */ } return L_tmp; } +Word64 sum2_fx_no_sat( /* o : sum of all squared vector elements Q(2*Qx)*/ + const Word16 *vec, /* i : input vector Qx*/ + const Word16 lvec /* i : length of input vector */ +) +{ + Word16 i; + Word64 sum; + + sum = 0; + move64(); + FOR( i = 0; i < lvec; i++ ) + { + sum = W_mac0_16_16( sum, vec[i], vec[i] ); // 2*Qx + } + + return sum; +} + Word32 sum_32_fx( const Word32 *vec, /* i : input vector */ const Word16 lvec, /* i : length of input vector */ @@ -456,11 +457,7 @@ Word32 sum2_fx_mod( /* o : sum of all squared vector element L_tmp = L_deposit_l( 0 ); FOR( i = 0; i < lvec; i++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_add_o( L_tmp, L_shr( L_mult_o( vec[i], vec[i], &Overflow ), 9 ), &Overflow ); -#else - L_tmp = L_add( L_tmp, L_shr( L_mult( vec[i], vec[i] ), 9 ) ); -#endif } return L_tmp; @@ -762,11 +759,7 @@ void Copy_Scale_sig( } FOR( i = 0; i < lg; i++ ) { -#ifdef BASOP_NOGLOB y[i] = shl_o( x[i], exp0, &Overflow ); -#else - y[i] = shl( x[i], exp0 ); -#endif move16(); /* saturation can occur here */ } } @@ -775,7 +768,7 @@ void Copy_Scale_sig( * * Up/down scale a 16 bits vector x and move it into y *-------------------------------------------------------------------*/ -void Copy_Scale_sig_16_32( +void Copy_Scale_sig_16_32_DEPREC( const Word16 x[], /* i : signal to scale input Qx */ Word32 y[], /* o : scaled signal output Qx */ const Word16 lg, /* i : size of x[] Q0 */ @@ -804,20 +797,22 @@ void Copy_Scale_sig_16_32( /*Should not happen */ FOR( i = 0; i < lg; i++ ) { -#ifdef BASOP_NOGLOB y[i] = L_deposit_l( shl_o( x[i], exp0, &Overflow ) ); -#else - y[i] = L_deposit_l( shl( x[i], exp0 ) ); -#endif move32(); } return; } -#ifdef BASOP_NOGLOB - tmp = shl_o( 1, exp0, &Overflow ); +#ifdef FIX_ISSUE_1237 +#ifdef DEBUGGING + if ( exp0 >= 16 ) + { + printf( "Issue in Copy_Scale_sig_16_32_DEPREC\n" ); + } #else - tmp = shl( 1, exp0 ); + assert( exp0 < 16 ); #endif +#endif + tmp = shl_o( 1, exp0, &Overflow ); FOR( i = 0; i < lg; i++ ) { y[i] = L_mult0( x[i], tmp ); @@ -854,20 +849,12 @@ void Copy_Scale_sig_16_32_no_sat( /*Should not happen */ FOR( i = 0; i < lg; i++ ) { -#ifdef BASOP_NOGLOB y[i] = L_deposit_l( shl_o( x[i], exp0, &Overflow ) ); -#else - y[i] = L_deposit_l( shl( x[i], exp0 ) ); -#endif move32(); } return; } -#ifdef BASOP_NOGLOB L_tmp = L_shl_o( 1, exp0 - 1, &Overflow ); -#else - tmp = shl( 1, exp0 ); -#endif FOR( i = 0; i < lg; i++ ) { // y[i] = L_mult0(x[i], L_tmp); @@ -895,11 +882,7 @@ void Copy_Scale_sig_32_16( { FOR( i = 0; i < lg; i++ ) { -#ifdef BASOP_NOGLOB y[i] = round_fx_o( L_shl_o( x[i], tmp, &Overflow ), &Overflow ); -#else - y[i] = round_fx( L_shl( x[i], tmp ) ); -#endif move16(); } } @@ -907,11 +890,7 @@ void Copy_Scale_sig_32_16( { FOR( i = 0; i < lg; i++ ) { -#ifdef BASOP_NOGLOB y[i] = round_fx_o( x[i], &Overflow ); -#else - y[i] = round_fx( x[i] ); -#endif move16(); } } @@ -933,14 +912,14 @@ void Scale_sig32( Flag Overflow = 0; move32(); #endif + IF( 0 == exp0 ) + { + return; + } FOR( i = 0; i < lg; i++ ) { -#ifdef BASOP_NOGLOB x[i] = L_shl_o( x[i], exp0, &Overflow ); -#else - x[i] = L_shl( x[i], exp0 ); -#endif move32(); /* saturation can occur here */ } } @@ -990,31 +969,17 @@ void Scale_sig( { FOR( i = 0; i < lg; i++ ) { -#ifdef BASOP_NOGLOB x[i] = shl_sat( x[i], exp0 ); -#else /* BASOP_NOGLOB */ - x[i] = shl( x[i], exp0 ); -#endif /* BASOP_NOGLOB */ move16(); /* saturation can occur here */ } return; } IF( exp0 < 0 ) { -#ifdef BASOP_NOGLOB tmp = shl_sat( -32768, exp0 ); /* we use negative to correctly represent 1.0 */ -#else - BASOP_SATURATE_WARNING_OFF_EVS - tmp = shl( -32768, exp0 ); /* we use negative to correctly represent 1.0 */ - BASOP_SATURATE_WARNING_ON_EVS -#endif FOR( i = 0; i < lg; i++ ) { -#ifdef BASOP_NOGLOB x[i] = msu_r_sat( 0, x[i], tmp ); -#else - x[i] = msu_r( 0, x[i], tmp ); -#endif move16(); /* msu instead of mac because factor is negative */ } return; @@ -1108,11 +1073,7 @@ void Vr_add( FOR( i = 0; i < Len; i++ ) { -#ifdef BASOP_NOGLOB out[i] = add_sat( in1[i], in2[i] ); -#else /* BASOP_NOGLOB */ - out[i] = add( in1[i], in2[i] ); -#endif /* BASOP_NOGLOB */ move16(); } } @@ -1552,12 +1513,8 @@ Word32 var_fx_32( /* o: variance of vector Q v = L_deposit_l( 0 ); FOR( i = 0; i < len; i++ ) { - tmp = sub( x[i], m ); /*Qx */ -#ifdef BASOP_NOGLOB + tmp = sub( x[i], m ); /*Qx */ v = L_mac0_sat( v, tmp, tmp ); /*(Qx+Qx) */ -#else /* BASOP_NOGLOB */ - v = L_mac0( v, tmp, tmp ); /*(Qx+Qx) */ -#endif /* BASOP_NOGLOB */ } L_tmp = Mult_32_16( v, inv_len ); /*Q(14-exp+Qx+Qx) */ v = L_shl( L_tmp, add( exp, sub( 2, Qx ) ) ); /*Qx+16 */ @@ -1598,11 +1555,7 @@ Word32 var_fx_32in_32out( /* o: variance of vector * convolution are considered. *-------------------------------------------------------------------*/ -#ifdef BASOP_NOGLOB /*Critical overflow */ Flag conv_fx( -#else -void conv_fx( -#endif const Word16 x[], /* i : input vector Q_new*/ const Word16 h[], /* i : impulse response (or second input vector) Q(15)*/ Word16 y[], /* o : output vetor (result of convolution) 12 bits*/ @@ -1623,22 +1576,12 @@ void conv_fx( L_sum = L_mult( x[0], h[n] ); FOR( i = 1; i < n; i++ ) { -#ifdef BASOP_NOGLOB L_sum = L_mac_o( L_sum, x[i], h[n - i], &Overflow ); -#else - L_sum = L_mac( L_sum, x[i], h[n - i] ); -#endif } -#ifdef BASOP_NOGLOB y[n] = mac_ro( L_sum, x[i], h[0], &Overflow ); -#else - y[n] = mac_r( L_sum, x[i], h[0] ); -#endif move16(); } -#ifdef BASOP_NOGLOB return Overflow; -#endif } /*-------------------------------------------------------------------* @@ -1648,11 +1591,7 @@ void conv_fx( * All vectors are of length L. Only the first L samples of the * convolution are considered. *-------------------------------------------------------------------*/ -#ifdef BASOP_NOGLOB /*Critical overflow */ Flag conv_fx_32( -#else -void conv_fx_32( -#endif const Word16 x[], /* i : input vector Q_new*/ const Word16 h[], /* i : impulse response (or second input vector) Q(15)*/ Word32 y[], /* o : output vetor (result of convolution) 12 bits*/ @@ -1675,9 +1614,7 @@ void conv_fx_32( y[n] = L_mac_o( L_sum, x[i], h[0], &Overflow ); move32(); } -#ifdef BASOP_NOGLOB return Overflow; -#endif } Word16 var_fx( /* o: variance of vector Qx*/ const Word16 *x, /* i: input vector Qx*/ @@ -1706,20 +1643,11 @@ Word16 var_fx( /* o: variance of vector Qx*/ v = L_deposit_l( 0 ); FOR( i = 0; i < len; i++ ) { -#ifdef BASOP_NOGLOB tmp = sub_sat( x[i], m ); /*Qx */ v = L_mac0_sat( v, tmp, tmp ); /*(Qx+Qx) */ -#else - tmp = sub( x[i], m ); /*Qx */ - v = L_mac0( v, tmp, tmp ); /*(Qx+Qx) */ -#endif } - L_tmp = Mult_32_16( v, inv_len ); /*Q(14-exp+Qx+Qx) */ -#ifdef BASOP_NOGLOB + L_tmp = Mult_32_16( v, inv_len ); /*Q(14-exp+Qx+Qx) */ v_16 = round_fx_sat( L_shl_sat( L_tmp, add( exp, sub( 2, Qx ) ) ) ); /*Qx */ -#else /* BASOP_NOGLOB */ - v_16 = round_fx( L_shl( L_tmp, add( exp, sub( 2, Qx ) ) ) ); /*Qx */ -#endif /* BASOP_NOGLOB */ return v_16; } @@ -1811,11 +1739,7 @@ void Vr_subt( FOR( i = 0; i < N; i++ ) { -#ifdef BASOP_NOGLOB y[i] = sub_sat( x1[i], x2[i] ); -#else /* BASOP_NOGLOB */ - y[i] = sub( x1[i], x2[i] ); -#endif /* BASOP_NOGLOB */ move16(); } } @@ -2010,7 +1934,6 @@ Word16 w_vquant_fx( { dist = L_deposit_l( 0 ); -#ifdef BASOP_NOGLOB tmp = sub_o( x[3], shr( cb[j++], Qx ), &Overflow ); if ( weights[3] != 0 ) { @@ -2031,28 +1954,6 @@ Word16 w_vquant_fx( { dist = L_mac0_o( dist, tmp, tmp, &Overflow ); } -#else - tmp = sub( x[3], shr( cb[j++], Qx ) ); - if ( weights[3] != 0 ) - { - dist = L_mac0( dist, tmp, tmp ); - } - tmp = sub( x[2], shr( cb[j++], Qx ) ); - if ( weights[2] != 0 ) - { - dist = L_mac0( dist, tmp, tmp ); - } - tmp = sub( x[1], shr( cb[j++], Qx ) ); - if ( weights[1] != 0 ) - { - dist = L_mac0( dist, tmp, tmp ); - } - tmp = sub( x[0], shr( cb[j++], Qx ) ); - if ( weights[0] != 0 ) - { - dist = L_mac0( dist, tmp, tmp ); - } -#endif if ( LT_32( dist, minDist ) ) { idx = c; @@ -2082,7 +1983,6 @@ Word16 w_vquant_fx( { dist = L_deposit_l( 0 ); -#ifdef BASOP_NOGLOB tmp = sub_o( x[0], shr( cb[j++], Qx ), &Overflow ); if ( weights[0] != 0 ) { @@ -2103,28 +2003,6 @@ Word16 w_vquant_fx( { dist = L_mac0_o( dist, tmp, tmp, &Overflow ); } -#else - tmp = sub( x[0], shr( cb[j++], Qx ) ); - if ( weights[0] != 0 ) - { - dist = L_mac0( dist, tmp, tmp ); - } - tmp = sub( x[1], shr( cb[j++], Qx ) ); - if ( weights[1] != 0 ) - { - dist = L_mac0( dist, tmp, tmp ); - } - tmp = sub( x[2], shr( cb[j++], Qx ) ); - if ( weights[2] != 0 ) - { - dist = L_mac0( dist, tmp, tmp ); - } - tmp = sub( x[3], shr( cb[j++], Qx ) ); - if ( weights[3] != 0 ) - { - dist = L_mac0( dist, tmp, tmp ); - } -#endif if ( LT_32( dist, minDist ) ) { idx = c; @@ -2183,11 +2061,7 @@ Word16 emaximum_fx( /* o : return index with max energy valu emax = L_max( emax, L_tmp ); } -#ifdef BASOP_NOGLOB *ener_max = L_shr_sat( emax, add( Qvec, Qvec ) ); -#else /* BASOP_NOGLOB */ - *ener_max = L_shr( emax, add( Qvec, Qvec ) ); -#endif /* BASOP_NOGLOB */ move32(); return ind; @@ -2224,11 +2098,7 @@ Word16 emaximum_32fx( /* o : return index with max energy va } } -#ifdef BASOP_NOGLOB *ener_max = W_extract_l( W_shr( emax, add( Qvec, Qvec ) ) ); -#else /* BASOP_NOGLOB */ - *ener_max = L_shr( emax, add( Qvec, Qvec ) ); -#endif /* BASOP_NOGLOB */ move32(); return ind; @@ -2272,11 +2142,7 @@ Word32 sum32_fx( /* o : sum of all vector elements tmp = L_deposit_l( 0 ); FOR( i = 0; i < lvec; i++ ) { -#ifdef BASOP_NOGLOB tmp = L_add_sat( tmp, vec[i] ); /*Qx */ -#else /* BASOP_NOGLOB */ - tmp = L_add( tmp, vec[i] ); /*Qx */ -#endif /* BASOP_NOGLOB */ } return tmp; @@ -2292,11 +2158,7 @@ Word16 sum16_fx( /* o : sum of all vector elements move16(); FOR( i = 0; i < lvec; i++ ) { -#ifdef BASOP_NOGLOB tmp = add_sat( tmp, vec[i] ); /*Qx */ -#else - tmp = add( tmp, vec[i] ); /*Qx */ -#endif } return tmp; @@ -2539,30 +2401,17 @@ void pz_filter_sp_fx( Lacc = L_deposit_h( x[i] ); /* Lacc in Q(16+Qn)*/ Lacc = L_shl( Lacc, s ); /* Lacc=x[i] in Q(16+Qn-2Qa+1)*/ FOR( j = PDR - 1; j >= 0; j-- ) -#ifdef BASOP_NOGLOB Lacc = L_msu_sat( Lacc, buf[j], a[j + 1] ); /*Q(16+Qn-2Qa+1)*/ -#else - Lacc = L_msu( Lacc, buf[j], a[j + 1] ); /*Q(16+Qn-2Qa+1)*/ -#endif Lacc = L_shr( Lacc, 1 ); -#ifdef BASOP_NOGLOB Ltemp1 = L_add_sat( L_shl_sat( Lacc, Qa ), 0x08000 ); -#else - Ltemp1 = L_add( L_shl( Lacc, Qa ), 0x08000 ); -#endif s_mem = extract_h( Ltemp1 ); Lacc = L_deposit_l( 0 ); FOR( j = PNR - 1; j >= 0; j-- ) -#ifdef BASOP_NOGLOB Lacc = L_mac_sat( Lacc, buf[j], b[j + 1] ); Lacc = L_mac_sat( Lacc, s_mem, b[0] ); -#else - Lacc = L_mac( Lacc, buf[j], b[j + 1] ); - Lacc = L_mac( Lacc, s_mem, b[0] ); -#endif /* Lacc in Q(1+Qc+Qn-Qa)*/ FOR( j = s_max( PDR, PNR ) - 1; j > 0; j-- ) @@ -2574,12 +2423,8 @@ void pz_filter_sp_fx( buf[0] = s_mem; move16(); -#ifdef BASOP_NOGLOB Ltemp1 = L_add_sat( L_shr_sat( Lacc, s ), 0x08000 ); /* Ltemp1 in Qc+Qa+Qn=Q(Qn) */ -#else - Ltemp1 = L_add( L_shr( Lacc, s ), 0x08000 ); /* Ltemp1 in Qc+Qa+Qn=Q(Qn) */ -#endif - y[i] = extract_h( Ltemp1 ); /* y[i] in Qn */ + y[i] = extract_h( Ltemp1 ); /* y[i] in Qn */ move16(); } } @@ -2637,27 +2482,15 @@ Word32 root_a_over_b_fx( } exp_num = norm_l( b ); -#ifdef BASOP_NOGLOB num = round_fx_o( L_shl_o( b, exp_num, &Overflow ), &Overflow ); -#else - num = round_fx( L_shl( b, exp_num ) ); -#endif exp_num = sub( sub( 30, exp_num ), Q_b ); exp_den = norm_l( a ); -#ifdef BASOP_NOGLOB den = round_fx_o( L_shl_o( a, exp_den, &Overflow ), &Overflow ); -#else /* BASOP_NOGLOB */ - den = round_fx( L_shl( a, exp_den ) ); -#endif /* BASOP_NOGLOB */ exp_den = sub( sub( 30, exp_den ), Q_a ); scale = shr( sub( den, num ), 15 ); -#ifdef BASOP_NOGLOB num = shl_o( num, scale, &Overflow ); -#else - num = shl( num, scale ); -#endif exp_num = sub( exp_num, scale ); tmp = div_s( num, den ); @@ -2672,6 +2505,109 @@ Word32 root_a_over_b_fx( return L_tmp; } +Word32 root_a_over_b_ivas_fx( + Word32 a, /* Q(Q_a) */ + Word16 Q_a, + Word32 b, /* Q(Q_b) */ + Word16 Q_b, + Word16 *q_out ) +{ + Word16 shift_a, shift_b, shift; + Word32 mod_a, mod_b, one_in_Q_a, one_in_Q_b, half_in_Q_a, half_in_Q_b; + Word32 a_sqr, b_sqr, p0, p1, p2, approx; + Word16 exp; + + test(); + IF( ( a <= 0 ) || ( b <= 0 ) ) + { + *q_out = 0; + move16(); + return 0; + } + + one_in_Q_a = L_shl( 1, Q_a ); // 1.0f in Q_a + one_in_Q_b = L_shl( 1, Q_b ); // 1.0f in Q_b + half_in_Q_a = L_shr( one_in_Q_a, 1 ); // 0.5f in Q_a + half_in_Q_b = L_shr( one_in_Q_b, 1 ); // 0.5f in Q_b + + a = L_add( a, one_in_Q_a ); + b = L_add( b, one_in_Q_b ); + + /* This next piece of code implements a "norm" function */ + /* and returns the shift needed to scale "a" to have a */ + /* 1 in the (MSB-1) position. This is equivalent to */ + /* giving a value between 0.5 & 1.0. */ + + mod_a = a; + move32(); + + shift_a = 0; + move16(); + WHILE( GT_32( mod_a, one_in_Q_a ) ) + { + mod_a = L_shr( mod_a, 1 ); + shift_a = sub( shift_a, 1 ); + } + + WHILE( LT_32( mod_a, half_in_Q_a ) ) + { + mod_a = L_shl( mod_a, 1 ); + shift_a = add( shift_a, 1 ); + } + + shift_a = s_and( shift_a, -2 ); + mod_a = L_shl( a, shift_a ); // Q_a + + /* This next piece of code implements a "norm" function */ + /* and returns the shift needed to scale "b" to have a */ + /* 1 in the (MSB-1) position. This is equivalent to */ + /* giving a value between 0.5 & 1.0. */ + mod_b = b; + move32(); + + shift_b = 0; + move16(); + WHILE( GT_32( mod_b, one_in_Q_b ) ) + { + mod_b = L_shr( mod_b, 1 ); + shift_b = sub( shift_b, 1 ); + } + + WHILE( LT_32( mod_b, half_in_Q_b ) ) + { + mod_b = L_shl( mod_b, 1 ); + shift_b = add( shift_b, 1 ); + } + + shift_b = s_and( shift_b, -2 ); + mod_b = L_shl( b, shift_b ); // Q_b + + shift = shr( sub( shift_b, shift_a ), 1 ); + + a_sqr = W_extract_h( W_shl( W_mult0_32_32( mod_a, mod_a ), sub( 32, Q_a ) ) ); // Q_a + b_sqr = W_extract_h( W_shl( W_mult0_32_32( mod_b, mod_b ), sub( 32, Q_b ) ) ); // Q_b + + p2 = L_shl( -408505077 /* -0.7609f in Q29 */, sub( Q_b, 31 ) ); // Qb-2 + p1 = L_shl( 1444612250 /* 2.6908f in Q29 */, sub( Q_b, 31 ) ); // Qb-2 + p0 = L_shl( 385258566 /* 0.7176f in Q29 */, sub( Q_b, 31 ) ); // Qb-2 + + p2 = Madd_32_32( Madd_32_32( p2, 501759554 /* 0.9346f in Q29*/, mod_b ), -252060893 /* -0.4695f in Q29 */, b_sqr ); // Q_b-2 + p1 = Madd_32_32( Madd_32_32( p1, -1774680487 /* -3.3056f in Q29 */, mod_b ), 891635211 /* 1.6608f in Q29 */, b_sqr ); // Q_b-2 + p0 = Madd_32_32( Madd_32_32( p0, -473251709 /* -0.8815f in Q29 */, mod_b ), 237780127 /* 0.4429f in Q29 */, b_sqr ); // Q_b-2 + + /* approx = p0 + p1 * mod_a + p2 * mod_a * mod_a; */ + approx = Madd_32_32( Mpy_32_32( p1, mod_a ), p2, a_sqr ); // Q_a+Q_b-33 + approx = L_add( approx, L_shl( p0, sub( Q_a, 31 ) ) ); // Q_a+Q_b-33 + + exp = sub( norm_l( approx ), 1 ); + approx = L_shl( approx, exp ); // // Q_a+Q_b-33+exp + + *q_out = sub( add( sub( add( Q_a, Q_b ), 33 ), exp ), shift ); + move16(); + + return approx; +} + /*===================================================================*/ /* FUNCTION : fir_fx () */ /*-------------------------------------------------------------------*/ @@ -2725,7 +2661,6 @@ void fir_fx( const Word16 x[], /* i : input vector /* do the filtering */ FOR( i = 0; i < L; i++ ) { -#ifdef BASOP_NOGLOB s = L_mult_o( buf_in[K + i], h[0], &Overflow ); FOR( j = 1; j <= K; j++ ) @@ -2734,16 +2669,6 @@ void fir_fx( const Word16 x[], /* i : input vector } s = L_shl_o( s, shift, &Overflow ); y[i] = round_fx_o( s, &Overflow ); /*Qx */ -#else - s = L_mult( buf_in[K + i], h[0] ); - - FOR( j = 1; j <= K; j++ ) - { - s = L_mac( s, h[j], buf_in[K + i - j] ); - } - s = L_shl( s, shift ); - y[i] = round_fx( s ); /*Qx */ -#endif move16(); } } @@ -2891,18 +2816,10 @@ Word16 squant_fx( /* o: index of the winning codeword */ FOR( c = 0; c < cbsize; c++ ) { L_dist = L_deposit_l( 0 ); -#ifdef BASOP_NOGLOB tmp = sub_o( x, cb[c], &Overflow ); -#else /* BASOP_NOGLOB */ - tmp = sub( x, cb[c] ); -#endif /* BASOP_NOGLOB */ /*dist += tmp*tmp; */ -#ifdef BASOP_NOGLOB L_dist = L_mac_o( L_dist, tmp, tmp, &Overflow ); -#else /* BASOP_NOGLOB */ - L_dist = L_mac( L_dist, tmp, tmp ); -#endif /* BASOP_NOGLOB */ if ( LT_32( L_dist, L_mindist ) ) { @@ -3003,11 +2920,7 @@ void pz_filter_dp_fx( FOR( j = PDR - 1; j >= 0; j-- ) Lacc = Msub_32_16( Lacc, buf[j], a[j + 1] ); /*Q(16+Qn-2Qa+1)*/ -#ifdef BASOP_NOGLOB s_mem = L_shl_sat( Lacc, sub( Qa, 1 ) ); /*Qn-Qa+16=Qn+Qc*/ -#else - s_mem = L_shl( Lacc, sub( Qa, 1 ) ); /*Qn-Qa+16=Qn+Qc*/ -#endif Lacc = L_deposit_l( 0 ); FOR( j = PNR - 1; j >= 0; j-- ) Lacc = Madd_32_16( Lacc, buf[j], b[j + 1] ); @@ -3023,12 +2936,8 @@ void pz_filter_dp_fx( buf[0] = s_mem; move16(); -#ifdef BASOP_NOGLOB Ltemp1 = L_shr_sat( Lacc, s ); /* Ltemp1 in Qc+Qa+Qn=Q(16+Qn) */ -#else - Ltemp1 = L_shr( Lacc, s ); /* Ltemp1 in Qc+Qa+Qn=Q(16+Qn) */ -#endif - y[i] = extract_h( Ltemp1 ); /* y[i] in Qn */ + y[i] = extract_h( Ltemp1 ); /* y[i] in Qn */ move16(); } } @@ -3065,20 +2974,12 @@ void Copy_Scale_sig32( { FOR( i = 0; i < lg; i++ ) { -#ifdef BASOP_NOGLOB y[i] = L_shl_o( x[i], tmp, &Overflow ); -#else - y[i] = L_shl( x[i], tmp ); -#endif move16(); } return; } -#ifdef BASOP_NOGLOB L_tmp = L_shl_o( 1, exp0 - 1, &Overflow ); -#else - tmp = shl( 1, exp0 ); -#endif FOR( i = 0; i < lg; i++ ) { y[i] = W_extract_l( W_mult_32_32( L_tmp, x[i] ) ); @@ -3105,11 +3006,7 @@ void Copy_Scale_sig32_16( { FOR( i = 0; i < len; i++ ) { -#ifdef BASOP_NOGLOB *dst++ = round_fx_sat( *src++ ); -#else - *dst++ = round_fx( *src++ ); -#endif move16(); } return; @@ -3117,15 +3014,9 @@ void Copy_Scale_sig32_16( FOR( i = 0; i < len; i++ ) { -#ifdef BASOP_NOGLOB L_temp = L_shl_sat( *src++, exp0 ); *dst++ = round_fx_sat( L_temp ); -#else - L_temp = L_shl( *src++, exp0 ); - - *dst++ = round_fx( L_temp ); -#endif move16(); } } @@ -3275,11 +3166,7 @@ void add_vec_fx( { FOR( i = 0; i < N; i++ ) { -#ifdef BASOP_NOGLOB y[i] = add_o( x1[i], shr_ro( x2[i], Qyx2, &Overflow ), &Overflow ); -#else - y[i] = add( x1[i], shr_r( x2[i], Qyx2 ) ); -#endif move16(); } } @@ -3287,11 +3174,7 @@ void add_vec_fx( { FOR( i = 0; i < N; i++ ) { -#ifdef BASOP_NOGLOB y[i] = add_o( shr_ro( x1[i], Qyx1, &Overflow ), shr_ro( x2[i], Qyx2, &Overflow ), &Overflow ); -#else - y[i] = add( shr_r( x1[i], Qyx1 ), shr_r( x2[i], Qyx2 ) ); -#endif move16(); } } @@ -3418,39 +3301,21 @@ Word32 Calc_Energy_Autoscaled( /* o: Result (Energy) FOR( i = 0; i < j; i++ ) { /* divide by 2 so energy will be divided by 4 */ -#ifdef BASOP_NOGLOB /* Critical Overflow and all those below*/ temp = mult_ro( *signal++, 16384, &Overflow ); L_Energy = L_mac0_o( L_Energy, temp, temp, &Overflow ); -#else - temp = mult_r( *signal++, 16384 ); - L_Energy = L_mac0( L_Energy, temp, temp ); -#endif } FOR( i = j; i < len; i += 8 ) /* Process 8 Samples at a time */ { /* divide by 2 so energy will be divided by 4 */ -#ifdef BASOP_NOGLOB /* Critical Overflow */ temp = mult_ro( *signal++, 16384, &Overflow ); -#else - temp = mult_r( *signal++, 16384 ); -#endif L_temp = L_mult0( temp, temp ); FOR( j = 1; j < 8; j++ ) { -#ifdef BASOP_NOGLOB /* Critical Overflow */ temp = mult_ro( *signal++, 16384, &Overflow ); L_temp = L_mac0_o( L_temp, temp, temp, &Overflow ); -#else - temp = mult_r( *signal++, 16384 ); - L_temp = L_mac0( L_temp, temp, temp ); -#endif } -#ifdef BASOP_NOGLOB /* Critical Overflow */ L_temp = L_shr_o( L_temp, temp2, &Overflow ); -#else - L_temp = L_shr( L_temp, temp2 ); -#endif /* Here we try the addition just to check if we can sum the energy of the small (8 Iterations) loop with the total energy calculated so far without an overflow. @@ -3458,11 +3323,7 @@ Word32 Calc_Energy_Autoscaled( /* o: Result (Energy) energies are div by 2. Otherwise, nothing is done. After the 'IF', the sum is done again and will always be without an overflow. */ -#ifdef BASOP_NOGLOB /* Critical Overflow */ L_add_o( L_Energy, L_temp, &Overflow ); -#else - L_add( L_Energy, L_temp ); -#endif IF( Overflow != 0 ) { L_Energy = L_shr( L_Energy, 1 ); @@ -3471,11 +3332,7 @@ Word32 Calc_Energy_Autoscaled( /* o: Result (Energy) Overflow = 0; move16(); } -#ifdef BASOP_NOGLOB /* Critical Overflow */ L_Energy = L_add_o( L_Energy, L_temp, &Overflow ); -#else - L_Energy = L_add( L_Energy, L_temp ); -#endif } /* Calc Final Exponent (sub 2 because of the mult_r by 16384 that already divs the ener by 4) */ temp2 = sub( sub( shl( signal_exp, 1 ), temp2 ), 2 ); @@ -3547,11 +3404,7 @@ Word32 Sqrt_Ratio32( /* o: Result in Q31 exp2 = add( exp2, temp ); /* Prepare for Inverse */ -#ifdef BASOP_NOGLOB temp = round_fx_sat( L_val1 ); -#else - temp = round_fx( L_val1 ); -#endif temp = div_s( 16384, temp ); /* Mult Now */ L_val2 = Mult_32_16( L_val2, temp ); @@ -3849,17 +3702,10 @@ void Acelp_dec_total_exc( FOR( i = 0; i < L_subfr; i++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_shl_sat( L_mult( gain_pit_fx, exc_fx[i + i_subfr] ), 1 ); /*Q16+Q_exc*/ exc2_fx[i + i_subfr] = round_fx_sat( L_tmp ); /*Q_exc*/ L_tmp = L_add_sat( L_tmp, L_shl_sat( L_mult( gain_code16, code_fx[i] ), 6 ) ); /*Q16+Q_exc*/ exc_fx[i + i_subfr] = round_fx_sat( L_tmp ); /*Q_exc*/ -#else - L_tmp = L_shl( L_mult( gain_pit_fx, exc_fx[i + i_subfr] ), 1 ); /*Q16+Q_exc*/ - exc2_fx[i + i_subfr] = round_fx( L_tmp ); /*Q_exc*/ - L_tmp = L_add( L_tmp, L_shl( L_mult( gain_code16, code_fx[i] ), 6 ) ); /*Q16+Q_exc*/ - exc_fx[i + i_subfr] = round_fx( L_tmp ); /*Q_exc*/ -#endif move16(); move16(); } @@ -4053,20 +3899,12 @@ Word16 dot_prod_satcontr( const Word16 *x, const Word16 *y, Word16 qx, Word16 qy { Overflow = 0; move16(); -#ifdef BASOP_NOGLOB /* Critical Overflow and all those below*/ L_tmp = L_shl_o( 1, s_max( sub( add( add( qx, qy ), 7 ), shift ), 0 ), &Overflow ); -#else /* BASOP_NOGLOB */ - L_tmp = L_shl( 1, s_max( sub( add( add( qx, qy ), 7 ), shift ), 0 ) ); -#endif /* BASOP_NOGLOB */ pt1 = tmp_tab_x; pt2 = tmp_tab_y; FOR( i = 0; i < len; i++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_mac0_o( L_tmp, *pt1++, *pt2++, &Overflow ); /*Q(qx+qy-shift) */ -#else /* BASOP_NOGLOB */ - L_tmp = L_mac0( L_tmp, *pt1++, *pt2++ ); /*Q(qx+qy-shift) */ -#endif } IF( Overflow != 0 ) @@ -4514,10 +4352,11 @@ UWord32 mvl2s_r( IF( (void *) y <= (const void *) x ) { + Word32 tempd = L_shl( 1, sub( q_x, 1 ) ); FOR( i = 0; i < n; i++ ) { - temp = L_shr( x[i], sub( q_x, 1 ) ); - temp = L_shr( L_add( temp, 1 ), 1 ); + temp = L_add( x[i], tempd ); + temp = L_shr( temp, q_x ); IF( GT_32( temp, MAX16B ) ) { @@ -4538,10 +4377,11 @@ UWord32 mvl2s_r( } ELSE { + Word32 tempd = L_shl( 1, sub( q_x, 1 ) ); FOR( i = n - 1; i >= 0; i-- ) { - temp = L_shr( x[i], sub( q_x, 1 ) ); - temp = L_shr( L_add( temp, 1 ), 1 ); + temp = L_add( x[i], tempd ); + temp = L_shr( temp, q_x ); IF( GT_32( temp, MAX16B ) ) { diff --git a/lib_com/trans_inv_fx.c b/lib_com/trans_inv_fx.c index cc562c8999d960dc77257c30b538430068a4d1c3..fbe0f0d6ddd6910eabb38ed912be67dad0d819a3 100644 --- a/lib_com/trans_inv_fx.c +++ b/lib_com/trans_inv_fx.c @@ -93,11 +93,7 @@ void preecho_sb_fx( { mean_prev_fx_loc = L_add( *mean_prev_fx, 0 ); -#ifdef BASOP_NOGLOB mean_prev_hb_fx_loc = L_shl_sat( *mean_prev_hb_fx, shl( q_sig16, 1 ) ); /*Q0 to q_sig16*/ -#else - mean_prev_hb_fx_loc = L_shl( *mean_prev_hb_fx, shl( q_sig16, 1 ) ); /*Q0 to q_sig16*/ -#endif mean_prev_nc_fx_loc = L_add( *mean_prev_nc_fx, 0 ); framelength_m1 = sub( framelength, 1 ); nb_flag = 0; @@ -144,21 +140,13 @@ void preecho_sb_fx( fx32ptr1 = wtda_audio_fx + len3xLp20 - 1; /*q_sig32*/ FOR( i = 0; i < len3xLp20; i++ ) { -#ifdef BASOP_NOGLOB *fxptr1++ = negate( extract_h( L_shl_sat( *fx32ptr1--, sub( 15, q_sig32 ) ) ) ); /*Q-1*/ -#else - *fxptr1++ = negate( extract_h( L_shl( *fx32ptr1--, 15 - q_sig32 ) ) ); -#endif - move16(); /*convert to Word16 Q-1 with saturation (saturation not a problem here) */ + move16(); /*convert to Word16 Q-1 with saturation (saturation not a problem here) */ } FOR( i = 0; i < L_shr( framelength, 1 ); i++ ) { -#ifdef BASOP_NOGLOB *fxptr1++ = negate( extract_h( L_shl_sat( wtda_audio_fx[i], sub( 15, q_sig32 ) ) ) ); /*Q-1*/ -#else - *fxptr1++ = negate( extract_h( L_shl( wtda_audio_fx[i], 15 - q_sig32 ) ) ); -#endif - move16(); /*convert to Word16 Q-1 with saturation (saturation not a problem here) */ + move16(); /*convert to Word16 Q-1 with saturation (saturation not a problem here) */ } qmemp1 = 0; /*already in q-1*/ @@ -195,13 +183,9 @@ void preecho_sb_fx( fxptr3 = rec_sig_fx + 1; /*q_sig16*/ fxptr4 = rec_sig_fx + 2; /*q_sig16*/ -#ifdef BASOP_NOGLOB tmp_fxL1 = L_mult( shl_sat( *memfilt_lb_fx, q_sig16 ), 8192 ); /* *memfilt_lb_fx in q0 */ -#else - tmp_fxL1 = L_mult( shl( *memfilt_lb_fx, q_sig16 ), 8192 ); /* *memfilt_lb_fx in q0 */ -#endif - tmp_fxL1 = L_mac( tmp_fxL1, *fxptr3, 8192 /*Q15*/ ); /*Q16*/ - *fxptr1 = mac_r( tmp_fxL1, *fxptr2, 16384 /*Q15*/ ); /*Q0*/ + tmp_fxL1 = L_mac( tmp_fxL1, *fxptr3, 8192 /*Q15*/ ); /*Q16*/ + *fxptr1 = mac_r( tmp_fxL1, *fxptr2, 16384 /*Q15*/ ); /*Q0*/ move16(); fxptr1++; @@ -234,12 +218,8 @@ void preecho_sb_fx( } fxptr2--; -#ifdef BASOP_NOGLOB *memfilt_lb_fx = shr_sat( *fxptr2, q_sig16 ); /*Q0*/ -#else - *memfilt_lb_fx = shr( *fxptr2, q_sig16 ); -#endif - move16(); /* *memfilt_lb_fx in q0 */ + move16(); /* *memfilt_lb_fx in q0 */ /* energy of low bands 8 present and 1 future sub-frames */ sptr1 = zcr; /*Q0*/ @@ -258,16 +238,9 @@ void preecho_sb_fx( FOR( j = 0; j < NUMSF; j++ ) /* 8 present subframes */ { tmp_fx2 = sub( j, 1 ); -#ifdef BASOP_NOGLOB tmp_fx1 = shr_sat( *fxptr2, q16p1 ); /*q-1 to avoisd saturation in energy*/ tmp_fxL1 = L_mac0_sat( 25, tmp_fx1, tmp_fx1 ); /*2*(Q-1)*/ tmp_fxL2 = L_mac0_sat( 100, *fxptr3, *fxptr3 ); /*2*(q_sig16)*/ -#else - tmp_fx1 = shr( *fxptr2, q16p1 ); /*q-1 to avoisd saturation in energy*/ - tmp_fxL1 = L_mac0( 25, tmp_fx1, tmp_fx1 ); - - tmp_fxL2 = L_mac0( 100, *fxptr3, *fxptr3 ); -#endif sptr2_loc = 0; move16(); @@ -287,15 +260,9 @@ void preecho_sb_fx( *fx32ptr6 = tmp_fxL1; /*2*(Q-1)*/ move32(); } -#ifdef BASOP_NOGLOB tmp_fx1 = shr_sat( *fxptr2, q16p1 ); /*q-1 to avoisd saturation in energy*/ tmp_fxL1 = L_mac0_sat( tmp_fxL1, tmp_fx1, tmp_fx1 ); /*2*(Q-1)*/ tmp_fxL2 = L_mac0_sat( tmp_fxL2, *fxptr3, *fxptr3 ); /*2*(q_sig16)*/ -#else - tmp_fx1 = shr( *fxptr2, q16p1 ); /*q-1 to avoisd saturation in energy*/ - tmp_fxL1 = L_mac0( tmp_fxL1, tmp_fx1, tmp_fx1 ); - tmp_fxL2 = L_mac0( tmp_fxL2, *fxptr3, *fxptr3 ); -#endif cntnzcr = add( cntnzcr, 1 ); IF( L_mult0( *fxptr2, *( fxptr2 - 1 ) ) <= 0 ) { @@ -357,11 +324,7 @@ void preecho_sb_fx( move32(); if ( LT_32( *fx32ptr5, L_shr( *fx32ptr1, 1 ) ) ) { -#ifdef BASOP_NOGLOB tmp_fxL1 = L_shl_sat( L_sub_sat( *fx32ptr1, *fx32ptr5 ), 1 ); /*2*(Q-1)*/ -#else - tmp_fxL1 = L_shl( L_sub( *fx32ptr1, *fx32ptr5 ), 1 ); -#endif } *fx32ptr5 = tmp_fxL1; /*2*(Q-1)*/ move32(); @@ -383,12 +346,8 @@ void preecho_sb_fx( tmp_fx3 = sub( len3xLp20, 1 ); FOR( i = 1; i < len3xLp20; i++ ) { - tmp_fx1 = shr( *fxptr2, qmemp1 ); /*q-1 to avoisd saturation in energy*/ -#ifdef BASOP_NOGLOB + tmp_fx1 = shr( *fxptr2, qmemp1 ); /*q-1 to avoisd saturation in energy*/ tmp_fxL1 = L_mac0_sat( tmp_fxL1, tmp_fx1, tmp_fx1 ); /*2*(Q-1)*/ -#else - tmp_fxL1 = L_mac0( tmp_fxL1, tmp_fx1, tmp_fx1 ); -#endif if ( *fxptr2 * *( fxptr2 - 1 ) <= 0 ) { sptr1_loc = add( sptr1_loc, 1 ); @@ -411,31 +370,19 @@ void preecho_sb_fx( FOR( j = 1; j < tmp_fx3; j++ ) /* tmp_fx3 still contains subframelength*1.2-1 */ { - tmp_fxL1 = L_mult( *fxptr2, -8192 /*Q15*/ ); /*q_sig16+Q16*/ -#ifdef BASOP_NOGLOB + tmp_fxL1 = L_mult( *fxptr2, -8192 /*Q15*/ ); /*q_sig16+Q16*/ tmp_fxL1 = L_mac_sat( tmp_fxL1, *fxptr4, -8192 ); /*q_sig16+Q16*/ tmp_fx1 = mac_r_sat( tmp_fxL1, *fxptr3, 16384 /*Q15*/ ); /*q_sig16*/ tmp_fxL2 = L_mac0_sat( tmp_fxL2, tmp_fx1, tmp_fx1 ); /*2*(q_sig16)*/ -#else - tmp_fxL1 = L_mac( tmp_fxL1, *fxptr4, -8192 ); - tmp_fx1 = mac_r( tmp_fxL1, *fxptr3, 16384 ); - - tmp_fxL2 = L_mac0( tmp_fxL2, tmp_fx1, tmp_fx1 ); -#endif fxptr2++; fxptr3++; fxptr4++; } - tmp_fxL1 = L_mult( *fxptr2, -8192 /*Q15*/ ); /*q_sig16+Q16*/ -#ifdef BASOP_NOGLOB + tmp_fxL1 = L_mult( *fxptr2, -8192 /*Q15*/ ); /*q_sig16+Q16*/ tmp_fx1 = mac_r_sat( tmp_fxL1, *fxptr3, 16384 /*Q15*/ ); /*q_sig16*/ es_mdct_hb_fx[NUMSF] = L_mac0_sat( tmp_fxL2, tmp_fx1, tmp_fx1 ); /*2*(q_sig16)*/ -#else - tmp_fx1 = mac_r( tmp_fxL1, *fxptr3, 16384 ); - es_mdct_hb_fx[NUMSF] = L_mac0( tmp_fxL2, tmp_fx1, tmp_fx1 ); -#endif move32(); max_es_hb_fx = L_add( es_mdct_hb_fx[0], 0 ); /* for memorising the max energy */ @@ -467,11 +414,7 @@ void preecho_sb_fx( move16(); } -#ifdef BASOP_NOGLOB if ( LT_32( max_es_fx, L_shl_sat( mean_prev_fx_loc, 2 ) ) ) /*OK if saturated*/ -#else - if ( LT_32( max_es_fx, L_shl( mean_prev_fx_loc, 2 ) ) ) /*OK if saturated*/ -#endif { maxind = 0; move16(); @@ -708,12 +651,8 @@ void preecho_sb_fx( FOR( i = 0; i < subsubframelength; i++ ) { - tmp_fx1 = shr( *ptr_fx, qtmp ); /* q-1, to have same shift as es_mdct_.. */ -#ifdef BASOP_NOGLOB + tmp_fx1 = shr( *ptr_fx, qtmp ); /* q-1, to have same shift as es_mdct_.. */ tmp_fxL1 = L_mac0_sat( tmp_fxL1, tmp_fx1, tmp_fx1 ); /*2*(Q-1)*/ -#else - tmp_fxL1 = L_mac0( tmp_fxL1, tmp_fx1, tmp_fx1 ); -#endif ptr_fx++; } if ( GT_32( tmp_fxL1, max_plus_es_mdct_fx ) ) @@ -721,12 +660,8 @@ void preecho_sb_fx( max_plus_es_mdct_fx = L_add( tmp_fxL1, 0 ); } -#ifdef BASOP_NOGLOB sum_plus_es_fx = L_add_sat( sum_plus_es_fx, L_shl_sat( tmp_fxL1, 2 ) ); /*2*(Q-1)*/ -#else - sum_plus_es_fx = L_add( sum_plus_es_fx, L_shl( tmp_fxL1, 2 ) ); -#endif - *fx32ptr1 = tmp_fxL1; /*2*(Q-1)*/ + *fx32ptr1 = tmp_fxL1; /*2*(Q-1)*/ fx32ptr1++; Mpy_32_16_ss( sum_plus_es_fx, inv_jp2[j], fx32ptr4, &tmp_u16 ); /* 410 for 1/80*/ if ( LT_32( *fx32ptr4, maxcrit_fx ) ) @@ -899,11 +834,7 @@ void preecho_sb_fx( fxptr1 = preechogain_fx + tmp_fx2; /*Q15*/ FOR( j = 0; j < smooth_len; j++ ) { -#ifdef BASOP_NOGLOB *fxptr1 = add_sat( *fxptr1, tmp_fx1 ); /*Q15*/ -#else - *fxptr1 = add( *fxptr1, tmp_fx1 ); -#endif move16(); tmp_fx1 = add( tmp_fx1, tmp_fx3 ); /*Q15*/ fxptr1++; @@ -941,20 +872,12 @@ void preecho_sb_fx( { savehalfe_fx = L_add( mean_prev_nc_fx_loc, 0 ); /*2*(Q-1)*/ } -#ifdef BASOP_NOGLOB mean_prev_nc_fx_loc = L_add_sat( mean_prev_nc_fx_loc, es_mdct_fx[i] ); /*2*(Q-1)*/ -#else - mean_prev_nc_fx_loc = L_add( mean_prev_nc_fx_loc, es_mdct_fx[i] ); -#endif } if ( LT_32( savehalfe_fx, L_shr( mean_prev_nc_fx_loc, 1 ) ) ) { -#ifdef BASOP_NOGLOB mean_prev_nc_fx_loc = L_shl_sat( L_sub_sat( mean_prev_nc_fx_loc, savehalfe_fx ), 1 ); /*2*(Q-1)*/ -#else - mean_prev_nc_fx_loc = L_shl( L_sub( mean_prev_nc_fx_loc, savehalfe_fx ), 1 ); -#endif } mean_prev_nc_fx_loc = L_shr( mean_prev_nc_fx_loc, 3 ); /* >> LOG2_NUMSF in fixpoint 2*(Q-1)*/ @@ -994,13 +917,8 @@ void preecho_sb_fx( mean_prev_hb_fx_loc = L_shl( tmp_fxL1, 1 ); /*2*(q_sig16)*/ } -#ifdef BASOP_NOGLOB last2_fx = L_shr( L_add_sat( es_mdct_fx[NUMSF_M1], es_mdct_fx[NUMSF_M2] ), 1 ); /*q_sig16*/ last2_hb_fx = L_shr( L_add_sat( es_mdct_hb_fx[NUMSF_M1], es_mdct_hb_fx[NUMSF_M2] ), 1 ); /*q_sig16*/ -#else - last2_fx = L_shr( L_add( es_mdct_fx[NUMSF_M1], es_mdct_fx[NUMSF_M2] ), 1 ); - last2_hb_fx = L_shr( L_add( es_mdct_hb_fx[NUMSF_M1], es_mdct_hb_fx[NUMSF_M2] ), 1 ); -#endif if ( GT_32( last2_fx, mean_prev_fx_loc ) ) { mean_prev_fx_loc = L_add( last2_fx, 0 ); @@ -1012,13 +930,9 @@ void preecho_sb_fx( } *mean_prev_fx = mean_prev_fx_loc; /*2*(Q-1)*/ move32(); -#ifdef BASOP_NOGLOB *mean_prev_hb_fx = L_shr_sat( mean_prev_hb_fx_loc, shl_sat( q_sig16, 1 ) ); /*Q0*/ -#else - *mean_prev_hb_fx = L_shr( mean_prev_hb_fx_loc, shl( q_sig16, 1 ) ); -#endif - move32(); /*save in Q0*/ - *mean_prev_nc_fx = mean_prev_nc_fx_loc; /*2*(Q-1)*/ + move32(); /*save in Q0*/ + *mean_prev_nc_fx = mean_prev_nc_fx_loc; /*2*(Q-1)*/ move32(); } diff --git a/lib_com/weight_a_fx.c b/lib_com/weight_a_fx.c index 78297923648004976ea8e1110f24d853272c04af..7bea66ea0b0f2194210a0a06fdcc932f7660841c 100644 --- a/lib_com/weight_a_fx.c +++ b/lib_com/weight_a_fx.c @@ -122,11 +122,7 @@ void weight_a_fx( move16(); FOR( i = 1; i < m; i++ ) { -#ifdef BASOP_NOGLOB ap[i] = round_fx_o( L_shl( L_mult0( a[i], fac ), shift ), &Overflow ); /* Q11 + shift */ -#else /* BASOP_NOGLOB */ - ap[i] = round_fx( L_shl( L_mult0( a[i], fac ), shift ) ); -#endif move16(); fac = mult_r( fac, gamma ); /* Q15 */ } diff --git a/lib_com/wi_fx.c b/lib_com/wi_fx.c index 19788dc0af989d21ec12d29937e457a4e4050c7c..7df4cb3f04098dfa42ec0d36e8885daab0e2326c 100644 --- a/lib_com/wi_fx.c +++ b/lib_com/wi_fx.c @@ -320,13 +320,8 @@ static Word16 DTFS_alignment_weight_fx( FOR( k = 0; k <= HalfLag; k++ ) { -#ifdef BASOP_NOGLOB ab1[k] = round_fx_o( L_mac0_o( L_mult0( X1.a_fx[k], X2.a_fx[k] ), X1.b_fx[k], X2.b_fx[k], &Overflow ), &Overflow ); /* Q(-15) */ ab2[k] = round_fx_o( L_msu0_o( L_mult0( X1.a_fx[k], X2.b_fx[k] ), X1.b_fx[k], X2.a_fx[k], &Overflow ), &Overflow ); /* Q(-15) */ -#else - ab1[k] = round_fx( L_mac0( L_mult0( X1.a_fx[k], X2.a_fx[k] ), X1.b_fx[k], X2.b_fx[k] ) ); /* Q(-15) */ - ab2[k] = round_fx( L_msu0( L_mult0( X1.a_fx[k], X2.b_fx[k] ), X1.b_fx[k], X2.a_fx[k] ) ); /* Q(-15) */ -#endif move16(); move16(); } @@ -349,13 +344,8 @@ static Word16 DTFS_alignment_weight_fx( FOR( k = 0; k <= HalfLag; k++ ) { -#ifdef BASOP_NOGLOB corr_fx = L_mac0_o( corr_fx, ab1[k], cos_table[s_and( temp, 511 )], &Overflow ); corr_fx = L_mac0_o( corr_fx, ab2[k], cos_table[s_and( add( temp, 128 ), 511 )], &Overflow ); -#else - corr_fx = L_mac0( corr_fx, ab1[k], cos_table[s_and( temp, 511 )] ); - corr_fx = L_mac0( corr_fx, ab2[k], cos_table[s_and( add( temp, 128 ), 511 )] ); -#endif move32(); move32(); temp = add( temp, temp1 ); @@ -368,28 +358,15 @@ static Word16 DTFS_alignment_weight_fx( move16(); } -#ifdef BASOP_NOGLOB temp1 = round_fx_o( (Word32) L_shl_o( corr_fx, Qcorr, &Overflow ), &Overflow ); /* Q(Qcorr-16) */ wcorr_fx = L_mult_o( temp1, shl_o( temp, 2, &Overflow ), &Overflow ); /* Q(Qcorr-16+13+2+1)=Q(Qcorr) */ -#else - temp1 = round_fx( (Word32) L_shl( corr_fx, Qcorr ) ); /* Q(Qcorr-16) */ - wcorr_fx = L_mult( temp1, shl( temp, 2 ) ); /* Q(Qcorr-16+13+2+1)=Q(Qcorr) */ -#endif IF( GE_16( Qmaxcorr, Qcorr ) ) { -#ifdef BASOP_NOGLOB diff_corr = L_sub_o( wcorr_fx, L_shl_o( maxcorr_fx, sub( Qcorr, Qmaxcorr ), &Overflow ), &Overflow ); /* Qcorr */ -#else - diff_corr = L_sub( wcorr_fx, L_shl( maxcorr_fx, sub( Qcorr, Qmaxcorr ) ) ); /* Qcorr */ -#endif } ELSE { -#ifdef BASOP_NOGLOB diff_corr = L_sub_o( L_shl_o( wcorr_fx, sub( Qmaxcorr, Qcorr ), &Overflow ), maxcorr_fx, &Overflow ); /* Qmaxcorr */ -#else - diff_corr = L_sub( L_shl( wcorr_fx, sub( Qmaxcorr, Qcorr ) ), maxcorr_fx ); /* Qmaxcorr */ -#endif } IF( diff_corr > 0 ) @@ -448,18 +425,10 @@ Word16 DTFS_alignment_full_fx( /* Calculating the expected alignment shift */ Eshift = mult_r( ph_offset_fx, shl( X2_DTFS_fx.lag_fx, 7 ) ); /* confirmed I<2 by smv12.org, Q7 */ find_rem( (Word16) L_FRAME, shr( add( X2_DTFS_fx.lag_fx, X1_DTFS_fx.lag_fx ), 1 ), &temp ); -#ifdef BASOP_NOGLOB temp = add_sat( shl( temp, 7 ), Eshift ); /* Q7 */ -#else - temp = add( shl( temp, 7 ), Eshift ); /* Q7 */ -#endif IF( temp < 0 ) { -#ifdef BASOP_NOGLOB temp = add_sat( temp, shl_sat( X1_DTFS_fx.lag_fx, 7 ) ); /* Q7 */ -#else - temp = add( temp, shl( X1_DTFS_fx.lag_fx, 7 ) ); /* Q7 */ -#endif } find_rem( temp, shl( X1_DTFS_fx.lag_fx, 7 ), &Eshift ); /* Q7 */ Eshift = shl( shr( Eshift, 7 ), 1 ); /* Q1 but integer */ @@ -484,13 +453,8 @@ Word16 DTFS_alignment_full_fx( FOR( k = 0; k <= HalfLag; k++ ) { -#ifdef BASOP_NOGLOB ab1[k] = round_fx_o( L_mac_o( L_mult_o( X1_DTFS_fx.a_fx[k], X2_DTFS_fx.a_fx[k], &Overflow ), X1_DTFS_fx.b_fx[k], X2_DTFS_fx.b_fx[k], &Overflow ), &Overflow ); /* Q(-15); */ ab2[k] = round_fx_o( L_msu_o( L_mult_o( X1_DTFS_fx.b_fx[k], X2_DTFS_fx.a_fx[k], &Overflow ), X1_DTFS_fx.a_fx[k], X2_DTFS_fx.b_fx[k], &Overflow ), &Overflow ); /* Q(-15); */ -#else - ab1[k] = round_fx( L_mac( L_mult( X1_DTFS_fx.a_fx[k], X2_DTFS_fx.a_fx[k] ), X1_DTFS_fx.b_fx[k], X2_DTFS_fx.b_fx[k] ) ); /* Q(-15); */ - ab2[k] = round_fx( L_msu( L_mult( X1_DTFS_fx.b_fx[k], X2_DTFS_fx.a_fx[k] ), X1_DTFS_fx.a_fx[k], X2_DTFS_fx.b_fx[k] ) ); /* Q(-15); */ -#endif } IF( FR_flag == 0 ) { @@ -520,15 +484,9 @@ Word16 DTFS_alignment_full_fx( temp1 = add( n, shl( X2_DTFS_fx.lag_fx, 1 ) ); /* add lag_fx in Q1to make positive */ FOR( k = 0; k <= HalfLag; k++ ) { -#ifdef BASOP_NOGLOB corr_fx = L_mac_o( corr_fx, ab1[k], C_fx[( 2 * temp ) % ( 4 * X2_DTFS_fx.lag_fx )], &Overflow ); corr_fx = L_mac_o( corr_fx, ab2[k], S_fx[( 2 * temp ) % ( 4 * X2_DTFS_fx.lag_fx )], &Overflow ); temp = add_o( temp, temp1, &Overflow ); -#else - corr_fx = L_mac( corr_fx, ab1[k], C_fx[( 2 * temp ) % ( 4 * X2_DTFS_fx.lag_fx )] ); - corr_fx = L_mac( corr_fx, ab2[k], S_fx[( 2 * temp ) % ( 4 * X2_DTFS_fx.lag_fx )] ); - temp = add( temp, temp1 ); -#endif } IF( GT_32( corr_fx, maxcorr_fx ) ) @@ -648,15 +606,9 @@ void Q2phaseShift_fx( FOR( k = 0; k <= HalfLag; k++ ) { temp = X_fx->a_fx[k]; -#ifdef BASOP_NOGLOB X_fx->a_fx[k] = round_fx_o( L_msu_o( L_mult_o( temp, C_fx[temp2 % ( 4 * Lag )], &Overflow ), X_fx->b_fx[k], S_fx[temp2 % ( 4 * Lag )], &Overflow ), &Overflow ); /* X.Q */ X_fx->b_fx[k] = round_fx_o( L_mac_o( L_mult_o( X_fx->b_fx[k], C_fx[temp2 % ( 4 * Lag )], &Overflow ), temp, S_fx[temp2 % ( 4 * Lag )], &Overflow ), &Overflow ); temp2 = L_add_o( temp2, (Word32) ph, &Overflow ); -#else - X_fx->a_fx[k] = round_fx( L_msu( L_mult( temp, C_fx[temp2 % ( 4 * Lag )] ), X_fx->b_fx[k], S_fx[temp2 % ( 4 * Lag )] ) ); /* X.Q */ - X_fx->b_fx[k] = round_fx( L_mac( L_mult( X_fx->b_fx[k], C_fx[temp2 % ( 4 * Lag )] ), temp, S_fx[temp2 % ( 4 * Lag )] ) ); - temp2 = L_add( temp2, (Word32) ph ); -#endif move16(); move16(); } @@ -668,15 +620,9 @@ void Q2phaseShift_fx( FOR( k = 0; k <= HalfLag; k++ ) { temp = X_fx->a_fx[k]; -#ifdef BASOP_NOGLOB X_fx->a_fx[k] = round_fx_o( L_mac_o( L_mult_o( temp, C_fx[temp2 % ( 4 * Lag )], &Overflow ), X_fx->b_fx[k], S_fx[temp2 % ( 4 * Lag )], &Overflow ), &Overflow ); /* X.Q */ X_fx->b_fx[k] = round_fx_o( L_msu_o( L_mult_o( X_fx->b_fx[k], C_fx[temp2 % ( 4 * Lag )], &Overflow ), temp, S_fx[temp2 % ( 4 * Lag )], &Overflow ), &Overflow ); temp2 = add_o( (Word16) temp2, negate( ph ), &Overflow ); -#else - X_fx->a_fx[k] = round_fx( L_mac( L_mult( temp, C_fx[temp2 % ( 4 * Lag )] ), X_fx->b_fx[k], S_fx[temp2 % ( 4 * Lag )] ) ); /* X.Q */ - X_fx->b_fx[k] = round_fx( L_msu( L_mult( X_fx->b_fx[k], C_fx[temp2 % ( 4 * Lag )] ), temp, S_fx[temp2 % ( 4 * Lag )] ) ); - temp2 = add( (Word16) temp2, negate( ph ) ); -#endif move16(); move16(); } @@ -819,25 +765,15 @@ void DTFS_to_fs_fx( move16(); exp = norm_s( X_fx->lag_fx ); - tmp = div_s( shl( 1, sub( 14, exp ) ), X_fx->lag_fx ); /* Q29-exp */ -#ifdef BASOP_NOGLOB + tmp = div_s( shl( 1, sub( 14, exp ) ), X_fx->lag_fx ); /* Q29-exp */ L_tmp1 = L_mult_o( 12800, tmp, &Overflow ); /* Q(30-exp) */ diff_fx = extract_h( L_shl_o( L_tmp1, sub( exp, 14 ), &Overflow ) ); /* Q0 */ -#else - L_tmp1 = L_mult( 12800, tmp ); /* Q(30-exp) */ - diff_fx = extract_h( L_shl( L_tmp1, sub( exp, 14 ) ) ); /* Q0 */ -#endif exp = norm_s( diff_fx ); - tmp = div_s( shl( 1, sub( 14, exp ) ), diff_fx ); /* Q29-exp */ -#ifdef BASOP_NOGLOB + tmp = div_s( shl( 1, sub( 14, exp ) ), diff_fx ); /* Q29-exp */ L_tmp1 = L_mult_o( X_fx->upper_cut_off_freq_fx, tmp, &Overflow ); /* Q(30-exp) */ nH_band = extract_h( L_shl_o( L_tmp1, sub( exp, 14 ), &Overflow ) ); /* Q0 */ -#else - L_tmp1 = L_mult( X_fx->upper_cut_off_freq_fx, tmp ); /* Q(30-exp) */ - nH_band = extract_h( L_shl( L_tmp1, sub( exp, 14 ) ) ); /* Q0 */ -#endif - nH_4kHz = mult( 10240, ( X_fx->lag_fx ) ); /* 4000/12800 in Q15 */ + nH_4kHz = mult( 10240, ( X_fx->lag_fx ) ); /* 4000/12800 in Q15 */ if ( GE_16( sub( X_fx->upper_cut_off_freq_fx, shr( (Word16) L_mult( diff_fx, nH_band ), 1 ) ), diff_fx ) ) { @@ -860,13 +796,8 @@ void DTFS_to_fs_fx( exp = norm_s( N ); tmp = div_s( shl( 1, ( sub( 14, exp ) ) ), N ); -#ifdef BASOP_NOGLOB L_tmp = L_shl_o( tmp, add( exp, 6 ), &Overflow ); inv_lag = round_fx_o( L_tmp, &Overflow ); -#else - L_tmp = L_shl( tmp, add( exp, 6 ) ); - inv_lag = round_fx( L_tmp ); -#endif Lx0 = L_deposit_h( x[0] ); Labmax = L_deposit_l( 0 ); FOR( k = 1; k <= nH; k++ ) @@ -880,13 +811,8 @@ void DTFS_to_fs_fx( move16(); FOR( n = 1; n < N; n++ ) { -#ifdef BASOP_NOGLOB L_a = L_mac0_o( L_a, x[n], C_fx[( 4 * sum ) % ( 4 * N )], &Overflow ); /* Q16 of x[n]*cos(sum) */ L_b = L_mac0_o( L_b, x[n], S_fx[( 4 * sum ) % ( 4 * N )], &Overflow ); /* Q16 of x[n]*sin(sum) */ -#else - L_a = L_mac0( L_a, x[n], C_fx[( 4 * sum ) % ( 4 * N )] ); /* Q16 of x[n]*cos(sum) */ - L_b = L_mac0( L_b, x[n], S_fx[( 4 * sum ) % ( 4 * N )] ); /* Q16 of x[n]*sin(sum) */ -#endif sum = add( sum, temp ); } La[k] = L_shr( L_a, 6 ); /* Q8 of a[k]*2.0 */ @@ -923,22 +849,13 @@ void DTFS_to_fs_fx( temp_neg = negate( temp ); FOR( n = 0; n < N - 1; n += 2 ) { -#ifdef BASOP_NOGLOB L_a = L_mac_o( L_a, x[n], temp, &Overflow ); /* Q1 */ L_a = L_mac_o( L_a, x[n + 1], temp_neg, &Overflow ); -#else - L_a = L_mac( L_a, x[n], temp ); /* Q1 */ - L_a = L_mac( L_a, x[n + 1], temp_neg ); -#endif /*temp= negate(temp); */ } if ( s_and( N, 1 ) ) /*if N is odd we need to calculate last */ { -#ifdef BASOP_NOGLOB L_a = L_mac_o( L_a, x[n], temp, &Overflow ); /* Q1 */ -#else - L_a = L_mac( L_a, x[n], temp ); /* Q1 */ -#endif } La[k] = L_shl( L_a, 7 ); @@ -965,7 +882,6 @@ void DTFS_to_fs_fx( FOR( k = 1; k <= nH; k++ ) { -#ifdef BASOP_NOGLOB X_fx->a_fx[k] = round_fx_o( L_shl_o( La[k], temp, &Overflow ), &Overflow ); /* Q(8+temp-16)=Q(temp-8) */ move16(); X_fx->a_fx[k] = mult_ro( X_fx->a_fx[k], inv_lag, &Overflow ); @@ -974,28 +890,13 @@ void DTFS_to_fs_fx( move16(); X_fx->b_fx[k] = mult_ro( X_fx->b_fx[k], inv_lag, &Overflow ); move16(); /* Q(temp-8+19+1-16)=Q(temp-4) of b[k]*2.0/N */ -#else - X_fx->a_fx[k] = round_fx( L_shl( La[k], temp ) ); /* Q(8+temp-16)=Q(temp-8) */ - move16(); - X_fx->a_fx[k] = mult_r( X_fx->a_fx[k], inv_lag ); - move16(); /* Q(temp-8+19+1-16)=Q(temp-4) of a[k]*2.0/N */ - X_fx->b_fx[k] = round_fx( L_shl( Lb[k], temp ) ); /* Q(8+temp-16)=Q(temp-8) */ - move16(); - X_fx->b_fx[k] = mult_r( X_fx->b_fx[k], inv_lag ); - move16(); /* Q(temp-8+19+1-16)=Q(temp-4) of b[k]*2.0/N */ -#endif } /* IF ( N%2 == 0 ) */ IF( s_and( N, 1 ) == 0 ) { -#ifdef BASOP_NOGLOB X_fx->a_fx[k] = round_fx_o( L_shl_o( La[k], temp, &Overflow ), &Overflow ); /* Q(8+temp-16)=Q(temp-8) */ X_fx->a_fx[k] = mult_ro( X_fx->a_fx[k], inv_lag, &Overflow ); -#else - X_fx->a_fx[k] = round_fx( L_shl( La[k], temp ) ); /* Q(8+temp-16)=Q(temp-8) */ - X_fx->a_fx[k] = mult_r( X_fx->a_fx[k], inv_lag ); -#endif move16(); move16(); /* Q(temp-8+19+1-16)=Q(temp-4) of a[k]*1.0/N */ X_fx->b_fx[k] = 0; @@ -1249,11 +1150,7 @@ static void DTFS_transform_fx( m = L_add( 1000 * LL - OSLENGTH / 2, add( l1, j ) ) % LL; /* use circular addressing */ tmptmp3_40_fx = L_add( tmptmp3_40_fx, Mult_32_16( x_r_fx[m], sinc_fx[k][j] ) ); } -#ifdef BASOP_NOGLOB out_fx[i] = round_fx_sat( L_shl_sat( tmptmp3_40_fx, 2 ) ); -#else - out_fx[i] = round_fx( L_shl( tmptmp3_40_fx, 2 ) ); -#endif move16(); } @@ -1320,17 +1217,11 @@ void DTFS_zeroFilter_fx( FOR( n = 0; n < N; n++ ) { -#ifdef BASOP_NOGLOB sum1_fx = L_mac_o( sum1_fx, LPC[n], C_fx[( 4 * temp2 ) % ( 4 * X_fx->lag_fx )], &Overflow ); /* Q(12+15+1) */ sum2_fx = L_mac_o( sum2_fx, LPC[n], S_fx[( 4 * temp2 ) % ( 4 * X_fx->lag_fx )], &Overflow ); -#else - sum1_fx = L_mac( sum1_fx, LPC[n], C_fx[i_mult( 4, temp2 ) % i_mult( 4, X_fx->lag_fx )] ); /* Q(12+15+1) */ - sum2_fx = L_mac( sum2_fx, LPC[n], S_fx[i_mult( 4, temp2 ) % i_mult( 4, X_fx->lag_fx )] ); -#endif temp2 = add( temp2, temp ); } -#ifdef BASOP_NOGLOB temp1 = round_fx_o( sum1_fx, &Overflow ); /* Q(12+15+1-16)=Q(12) */ temp2 = round_fx_o( sum2_fx, &Overflow ); /* Q(12) */ @@ -1339,16 +1230,6 @@ void DTFS_zeroFilter_fx( L_temp1 = L_msu_o( L_temp1, temp2, X_fx->b_fx[k], &Overflow ); /* Q(12+Q+1) */ L_temp2 = L_mult_o( temp1, X_fx->b_fx[k], &Overflow ); L_temp2 = L_mac_o( L_temp2, temp2, X_fx->a_fx[k], &Overflow ); /* Q(12+Q+1) */ -#else - temp1 = round_fx( sum1_fx ); /* Q(12+15+1-16)=Q(12) */ - temp2 = round_fx( sum2_fx ); /* Q(12) */ - - /* Calculate the circular convolution */ - L_temp1 = L_mult( temp1, X_fx->a_fx[k] ); - L_temp1 = L_msu( L_temp1, temp2, X_fx->b_fx[k] ); /* Q(12+Q+1) */ - L_temp2 = L_mult( temp1, X_fx->b_fx[k] ); - L_temp2 = L_mac( L_temp2, temp2, X_fx->a_fx[k] ); /* Q(12+Q+1) */ -#endif /* normalization */ na = norm_l( L_temp1 ); if ( L_temp1 == 0 ) @@ -1368,13 +1249,8 @@ void DTFS_zeroFilter_fx( nb = na; move16(); } -#ifdef BASOP_NOGLOB X_fx->a_fx[k] = round_fx_o( (Word32) L_shl_o( L_temp1, nb, &Overflow ), &Overflow ); /* Q(13+Q+nb-16)=Q(Q+nb-3) */ X_fx->b_fx[k] = round_fx_o( (Word32) L_shl_o( L_temp2, nb, &Overflow ), &Overflow ); /* Q(Q+nb-3) */ -#else - X_fx->a_fx[k] = round_fx( (Word32) L_shl( L_temp1, nb ) ); /* Q(13+Q+nb-16)=Q(Q+nb-3) */ - X_fx->b_fx[k] = round_fx( (Word32) L_shl( L_temp2, nb ) ); /* Q(Q+nb-3) */ -#endif move32(); move32(); @@ -1390,17 +1266,10 @@ void DTFS_zeroFilter_fx( /* bring to the same Q */ FOR( k = 0; k <= HalfLag; k++ ) { -#ifdef BASOP_NOGLOB X_fx->a_fx[k] = shl_o( X_fx->a_fx[k], sub( Qmin, Qab[k] ), &Overflow ); move16(); /* Q(Q+Qab[k]+Qmin-Qab[k]=Q(Q+Qmin) */ X_fx->b_fx[k] = shl_o( X_fx->b_fx[k], sub( Qmin, Qab[k] ), &Overflow ); move16(); /* Q(Q+Qmin) */ -#else - X_fx->a_fx[k] = shl( X_fx->a_fx[k], sub( Qmin, Qab[k] ) ); - move16(); /* Q(Q+Qab[k]+Qmin-Qab[k]=Q(Q+Qmin) */ - X_fx->b_fx[k] = shl( X_fx->b_fx[k], sub( Qmin, Qab[k] ) ); - move16(); /* Q(Q+Qmin) */ -#endif } X_fx->Q = add( X_fx->Q, Qmin ); @@ -1657,23 +1526,14 @@ Word32 DTFS_getEngy_fx( temp_b_fx = X_fx->b_fx[k]; move16(); -#ifdef BASOP_NOGLOB en_fx = L_mac0_o( en_fx, temp_a_fx, temp_a_fx, &Overflow ); en_fx = L_mac0_o( en_fx, temp_b_fx, temp_b_fx, &Overflow ); -#else - en_fx = L_mac0( en_fx, temp_a_fx, temp_a_fx ); - en_fx = L_mac0( en_fx, temp_b_fx, temp_b_fx ); -#endif } en_fx = L_shr( en_fx, 1 ); temp_a_fx = X_fx->a_fx[0]; move16(); -#ifdef BASOP_NOGLOB en_fx = L_mac0_o( en_fx, temp_a_fx, temp_a_fx, &Overflow ); -#else - en_fx = L_mac0( en_fx, temp_a_fx, temp_a_fx ); -#endif /* IF (X_fx->lag_fx%2 == 0) */ IF( s_and( X_fx->lag_fx, 1 ) == 0 ) { @@ -1682,13 +1542,8 @@ Word32 DTFS_getEngy_fx( temp_b_fx = X_fx->b_fx[k]; move16(); -#ifdef BASOP_NOGLOB en_fx = L_mac0_o( en_fx, temp_a_fx, temp_a_fx, &Overflow ); en_fx = L_mac0_o( en_fx, temp_b_fx, temp_b_fx, &Overflow ); -#else - en_fx = L_mac0( en_fx, temp_a_fx, temp_a_fx ); - en_fx = L_mac0( en_fx, temp_b_fx, temp_b_fx ); -#endif } return en_fx; /* 2*X1.Q+1=Q13 */ @@ -1727,30 +1582,16 @@ Word32 DTFS_getEngy_P2A_fx( HalfLag_fx = s_min( HalfLag_fx, X_fx->nH_fx ); FOR( k = 1; k <= HalfLag_fx; k++ ) { -#ifdef BASOP_NOGLOB en_fx = L_mac0_o( en_fx, X_fx->a_fx[k], X_fx->a_fx[k], &Overflow ); en_fx = L_mac0_o( en_fx, X_fx->b_fx[k], X_fx->b_fx[k], &Overflow ); -#else - en_fx = L_mac0( en_fx, X_fx->a_fx[k], X_fx->a_fx[k] ); - en_fx = L_mac0( en_fx, X_fx->b_fx[k], X_fx->b_fx[k] ); -#endif } en_fx = L_shr( en_fx, 1 ); -#ifdef BASOP_NOGLOB en_fx = L_mac0_o( en_fx, X_fx->a_fx[0], X_fx->a_fx[0], &Overflow ); -#else - en_fx = L_mac0( en_fx, X_fx->a_fx[0], X_fx->a_fx[0] ); -#endif /* IF (X_fx->lag_fx%2 == 0) */ IF( s_and( X_fx->lag_fx, 1 ) == 0 ) { -#ifdef BASOP_NOGLOB en_fx = L_mac0_o( en_fx, X_fx->a_fx[k], X_fx->a_fx[k], &Overflow ); en_fx = L_mac0_o( en_fx, X_fx->b_fx[k], X_fx->b_fx[k], &Overflow ); -#else - en_fx = L_mac0( en_fx, X_fx->a_fx[k], X_fx->a_fx[k] ); - en_fx = L_mac0( en_fx, X_fx->b_fx[k], X_fx->b_fx[k] ); -#endif } return en_fx; /* 2*X1.Q */ @@ -1810,11 +1651,7 @@ static Word32 DTFS_setEngy_fx( expb = norm_l( en1_fx ); -#ifdef BASOP_NOGLOB fracb = round_fx_sat( L_shl_sat( en1_fx, expb ) ); -#else - fracb = round_fx( L_shl( en1_fx, expb ) ); -#endif expb = sub( 30, add( expb, shl( X_DTFS_FX->Q, 1 ) ) ); @@ -1891,13 +1728,9 @@ void DTFS_car2pol_fx( FOR( k = 1; k <= HalfLag_fx; k++ ) { - Lacc_fx = L_mult( X_fx->a_fx[k], X_fx->a_fx[k] ); /* a[k]^2, 2Q+1 */ -#ifdef BASOP_NOGLOB + Lacc_fx = L_mult( X_fx->a_fx[k], X_fx->a_fx[k] ); /* a[k]^2, 2Q+1 */ Lacc_fx = L_mac_o( Lacc_fx, X_fx->b_fx[k], X_fx->b_fx[k], &Overflow ); /* a[k]^2+b[k]^2, 2Q+1 */ -#else - Lacc_fx = L_mac( Lacc_fx, X_fx->b_fx[k], X_fx->b_fx[k] ); /* a[k]^2+b[k]^2, 2Q+1 */ -#endif - Lacc_fx = L_shr( Lacc_fx, 3 ); /* Lacc=(a[k]^2+b[k]^2)/4, 2Q */ + Lacc_fx = L_shr( Lacc_fx, 3 ); /* Lacc=(a[k]^2+b[k]^2)/4, 2Q */ IF( Lacc_fx ) { @@ -2019,11 +1852,7 @@ Word32 DTFS_setEngyHarm_fx( Lacc = L_deposit_l( 0 ); FOR( k = f_low_fx + 1; k <= HalfLag_fx; k++ ) { -#ifdef BASOP_NOGLOB Lacc = L_mac0_o( Lacc, X_fx->a_fx[k], X_fx->a_fx[k], &Overflow ); /* 2*X1.Q */ -#else - Lacc = L_mac0( Lacc, X_fx->a_fx[k], X_fx->a_fx[k] ); /* 2*X1.Q */ -#endif Lacc_max = L_max( Lacc_max, Lacc ); count = add( count, 1 ); @@ -2038,13 +1867,8 @@ Word32 DTFS_setEngyHarm_fx( Lacc = L_deposit_l( 0 ); FOR( k = f_low_fx + 1; k <= HalfLag_fx; k++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_mult_o( X_fx->a_fx[k], X_fx->a_fx[k], &Overflow ); Lacc = L_add_o( Lacc, L_shr( L_tmp, expp ), &Overflow ); /* 2*X1.Q-expp */ -#else - L_tmp = L_mult( X_fx->a_fx[k], X_fx->a_fx[k] ); - Lacc = L_add( Lacc, L_shr( L_tmp, expp ) ); /* 2*X1.Q-expp */ -#endif count = add( count, 1 ); } } @@ -2057,11 +1881,7 @@ Word32 DTFS_setEngyHarm_fx( exp = norm_s( count ); tmp = div_s( shl( 1, sub( 14, exp ) ), count ); /* 29 - exp */ -#ifdef BASOP_NOGLOB en1_fx = L_shl_o( Mult_32_16( Lacc, tmp ), sub( exp, 14 ), &Overflow ); -#else - en1_fx = L_shl( Mult_32_16( Lacc, tmp ), sub( exp, 14 ) ); -#endif test(); IF( en1_fx > 0 && en2_fx > 0 ) { @@ -2072,11 +1892,7 @@ Word32 DTFS_setEngyHarm_fx( expb = norm_l( en1_fx ); -#ifdef BASOP_NOGLOB fracb = round_fx_o( L_shl_o( en1_fx, expb, &Overflow ), &Overflow ); -#else - fracb = round_fx( L_shl( en1_fx, expb ) ); -#endif IF( GE_32( Lacc_max, 2147483647 /*1.Q31*/ ) ) { expb = sub( 30, add( expb, sub( shl( X_fx->Q, 1 ), expp ) ) ); @@ -2114,11 +1930,7 @@ Word32 DTFS_setEngyHarm_fx( { /*L_temp_fx =(Word32)Mpy_32_16(extract_h(factor_fx),extract_l(factor_fx), X_fx->a_fx[k]); move32(); */ /* Q(temp+X1.Q-15) */ L_temp_fx = Mult_32_16( factor_fx, X_fx->a_fx[k] ); /* Q(temp+X1.Q-15) */ -#ifdef BASOP_NOGLOB - X_fx->a_fx[k] = round_fx_o( L_temp_fx, &Overflow ); /* Q(temp+X1.Q-15-16)=Q(temp+X1.Q-31); */ -#else - X_fx->a_fx[k] = round_fx( L_temp_fx ); /* Q(temp+X1.Q-15-16)=Q(temp+X1.Q-31); */ -#endif + X_fx->a_fx[k] = round_fx_o( L_temp_fx, &Overflow ); /* Q(temp+X1.Q-15-16)=Q(temp+X1.Q-31); */ move16(); } @@ -2254,11 +2066,7 @@ static void cubicPhase_fx( Ltemp3 = L_sub( Ltemp3, L_shl( Ltemp1, 1 ) ); /* Ltemp3=N*c1-2*Ltemp1, Q20 */ -#ifdef BASOP_NOGLOB IF( GE_32( L_abs( Ltemp3 ), L_shl_o( Ltemp2, 8, &Overflow ) ) ) -#else - IF( GE_32( L_abs( Ltemp3 ), L_shl( Ltemp2, 8 ) ) ) -#endif { Lacc = L_add( MIN_32, 0 ); if ( Ltemp3 > 0 ) @@ -2271,11 +2079,7 @@ static void cubicPhase_fx( ELSE { expa = norm_l( Ltemp3 ); -#ifdef BASOP_NOGLOB fraca = extract_h( L_shl_o( Ltemp3, expa, &Overflow ) ); -#else - fraca = extract_h( L_shl( Ltemp3, expa ) ); -#endif expa = sub( 30, add( expa, 20 ) ); if ( fraca < 0 ) { @@ -2284,11 +2088,7 @@ static void cubicPhase_fx( } expb = norm_l( Ltemp2 ); -#ifdef BASOP_NOGLOB fracb = extract_h( L_shl_o( Ltemp2, expb, &Overflow ) ); -#else - fracb = extract_h( L_shl( Ltemp2, expb ) ); -#endif expb = sub( 30, expb ); if ( fracb < 0 ) { @@ -2305,11 +2105,7 @@ static void cubicPhase_fx( fracb = negate( fracb ); } scale = shr( sub( fracb, fraca ), 15 ); -#ifdef BASOP_NOGLOB fraca = shl_o( fraca, scale, &Overflow ); -#else - fraca = shl( fraca, scale ); -#endif expa = sub( expa, scale ); tmp = div_s( fraca, fracb ); /* 15-exp */ @@ -2325,13 +2121,8 @@ static void cubicPhase_fx( tmp = negate( tmp ); } -#ifdef BASOP_NOGLOB Lacc = L_shl_o( tmp, add( exp, 34 ), &Overflow ); Lacc = L_add_o( Lacc, 0x08000, &Overflow ); -#else - Lacc = L_shl( tmp, add( exp, 34 ) ); - Lacc = L_add( Lacc, 0x08000 ); -#endif c0 = extract_h( Lacc ); /* c0 in Q33 */ } @@ -2457,11 +2248,7 @@ static void cubicPhase_fx( Ltemp3 = L_add( Ltemp3, 1 ); } -#ifdef BASOP_NOGLOB Ltemp3 = L_shl_o( Mult_32_16( L_shl_o( Ltemp3, 7, &Overflow ), c0 ), 2, &Overflow ); /* Ltemp3=c0*n^3, Q27 */ -#else - Ltemp3 = L_shl( Mult_32_16( L_shl( Ltemp3, 7 ), c0 ), 2 ); /* Ltemp3=c0*n^3, Q27 */ -#endif Ltemp2 = L_shl( Mult_32_16( N2, c1 ), 1 ); /* Ltemp2 = (Word32)L_mult_su(c1,(UNS_Word16)n2); : Ltemp2=c1*n^2, Q27 */ Ltemp1 = L_shl( L_mult( c2, n ), 7 ); /* Ltemp1=c2*n, Q27 */ @@ -2587,12 +2374,8 @@ void DTFS_to_erb_fx( FOR( i = 0; i < num_erb_fx; i++ ) { -#ifdef BASOP_NOGLOB out_fx[i] = round_fx_o( L_shl_o( sum_a_fx[i], n, &Overflow ), &Overflow ); /* Q13 */ move16(); -#else - out_fx[i] = round_fx( L_shl( sum_a_fx[i], n ) ); /* Q13 */ -#endif IF( GT_16( count[i], 1 ) ) { IF( sum_a_fx[i] < 0 ) @@ -2619,14 +2402,8 @@ void DTFS_to_erb_fx( tmp = div_s( fracb, fraca ); exp = sub( expb, expa ); -#ifdef BASOP_NOGLOB L_tmp = L_shl_sat( tmp, add( exp, 14 ) ); out_fx[i] = round_fx_sat( L_tmp ); -#else - L_tmp = L_shl( tmp, add( exp, 14 ) ); - - out_fx[i] = round_fx( L_tmp ); -#endif move16(); } } @@ -2754,29 +2531,17 @@ void erb_slot_fx( } FOR( j = 0; j < num_erb_fx; j++ ) { -#ifdef BASOP_NOGLOB mfreq_fx[j] = round_fx_o( L_shl_o( mf_fx[j], 11, &Overflow ), &Overflow ); /* Q15 */ -#else - mfreq_fx[j] = round_fx( L_shl( mf_fx[j], 11 ) ); /* Q15 */ -#endif move16(); IF( GT_16( out_fx[j], 1 ) ) { expb = norm_l( mf_fx[j] ); -#ifdef BASOP_NOGLOB fracb = round_fx_o( L_shl_o( mf_fx[j], expb, &Overflow ), &Overflow ); -#else - fracb = round_fx( L_shl( mf_fx[j], expb ) ); -#endif expb = sub( 30, add( expb, 20 ) ); expa = norm_l( out_fx[j] ); -#ifdef BASOP_NOGLOB fraca = extract_h( L_shl_o( out_fx[j], expa, &Overflow ) ); -#else - fraca = extract_h( L_shl( out_fx[j], expa ) ); -#endif expa = sub( 30, expa ); scale = shr( sub( fraca, fracb ), 15 ); @@ -2785,16 +2550,10 @@ void erb_slot_fx( tmp = div_s( fracb, fraca ); exp = sub( expb, expa ); -#ifdef BASOP_NOGLOB L_tmp = L_shl_o( tmp, add( exp, 16 ), &Overflow ); mfreq_fx[j] = round_fx_o( L_tmp, &Overflow ); move16(); -#else - L_tmp = L_shl( tmp, add( exp, 16 ) ); - - mfreq_fx[j] = round_fx( L_tmp ); -#endif } } return; @@ -2933,11 +2692,7 @@ void DTFS_erb_inv_fx( d2h = 31; move16(); } -#ifdef BASOP_NOGLOB X_fx->a_fx[i] = round_fx_o( L_shl_o( Ltemp_fx, d2h, &Overflow ), &Overflow ); /* Q(28-n+d2h) */ -#else - X_fx->a_fx[i] = round_fx( L_shl( Ltemp_fx, d2h ) ); /* Q(28-n+d2h) */ -#endif move16(); q[i] = add( sub( 28, n ), d2h ); move16(); @@ -3481,11 +3236,7 @@ Word16 ppp_extract_pitch_period_fx( spike = i; move16(); } -#ifdef BASOP_NOGLOB en1 = L_mac0_sat( en1, ptr[i], ptr[i] ); /* Q0 */ -#else - en1 = L_mac0( en1, ptr[i], ptr[i] ); /* Q0 */ -#endif } IF( ptr[spike] > 0 ) @@ -3618,11 +3369,7 @@ Word16 ppp_extract_pitch_period_fx( Lacc = L_deposit_l( 0 ); FOR( i = 0; i < l; i++ ) { -#ifdef BASOP_NOGLOB Lacc = L_mac0_sat( Lacc, out[i], out[i] ); /* Q0 */ -#else - Lacc = L_mac0( Lacc, out[i], out[i] ); /* Q0 */ -#endif } @@ -3636,11 +3383,7 @@ Word16 ppp_extract_pitch_period_fx( expb = norm_l( Lacc ); -#ifdef BASOP_NOGLOB fracb = round_fx_sat( L_shl_sat( Lacc, expb ) ); -#else - fracb = round_fx( L_shl( Lacc, expb ) ); -#endif expb = sub( 30, add( expb, Qres ) ); scale1 = shr( sub( fraca, fracb ), 15 ); @@ -3700,11 +3443,7 @@ void DTFS_peaktoaverage_fx( DTFS_STRUCTURE X_fx, Word32 *pos_fx, Word16 *Qpos, W FOR( i = 0; i < 256; i++ ) { -#ifdef BASOP_NOGLOB L_temp = L_mult_sat( time_fx[i], time_fx[i] ); /* Q(1) */ -#else - L_temp = L_mult( time_fx[i], time_fx[i] ); /* Q(1) */ -#endif IF( time_fx[i] >= 0 ) { if ( GT_32( L_temp, maxPosEn_fx ) ) @@ -3742,29 +3481,17 @@ void DTFS_peaktoaverage_fx( DTFS_STRUCTURE X_fx, Word32 *pos_fx, Word16 *Qpos, W ELSE { expa = norm_l( maxPosEn_fx ); -#ifdef BASOP_NOGLOB fraca = extract_h( L_shl_o( maxPosEn_fx, expa, &Overflow ) ); -#else - fraca = extract_h( L_shl( maxPosEn_fx, expa ) ); -#endif expa = sub( 30, add( expa, 1 ) ); expb = norm_l( L_sum ); -#ifdef BASOP_NOGLOB fracb = round_fx_o( L_shl_o( L_sum, expb, &Overflow ), &Overflow ); -#else - fracb = round_fx( L_shl( L_sum, expb ) ); -#endif expb = sub( 30, add( expb, shl( X_fx.Q, 1 ) ) ); scale = shr( sub( fraca, fracb ), 15 ); -#ifdef BASOP_NOGLOB fracb = shl_o( fracb, scale, &Overflow ); -#else - fracb = shl( fracb, scale ); -#endif expb = sub( expb, scale ); tmp = div_s( fracb, fraca ); @@ -3788,29 +3515,17 @@ void DTFS_peaktoaverage_fx( DTFS_STRUCTURE X_fx, Word32 *pos_fx, Word16 *Qpos, W { expa = norm_l( maxNegEn_fx ); -#ifdef BASOP_NOGLOB fraca = extract_h( L_shl_o( maxNegEn_fx, expa, &Overflow ) ); -#else - fraca = extract_h( L_shl( maxNegEn_fx, expa ) ); -#endif expa = sub( Q29, expa ); // 30 - expa - 1; expb = norm_l( L_sum ); -#ifdef BASOP_NOGLOB fracb = round_fx_o( L_shl_o( L_sum, expb, &Overflow ), &Overflow ); -#else - fracb = round_fx( L_shl( L_sum, expb ) ); -#endif expb = sub( 30, add( expb, shl( X_fx.Q, 1 ) ) ); scale = shr( sub( fraca, fracb ), 15 ); -#ifdef BASOP_NOGLOB fracb = shl_o( fracb, scale, &Overflow ); -#else - fracb = shl( fracb, scale ); -#endif expb = sub( expb, scale ); tmp = div_s( fracb, fraca ); @@ -4109,7 +3824,6 @@ static void c_fft_wi_fx( Word16 *farray_ptr_fx, Word16 size, Word16 stage, Word1 tmp1 = round_fx( ftmp_real_fx ); tmp2 = round_fx( ftmp_imag_fx ); -#ifdef BASOP_NOGLOB *( farray_ptr_fx + kj ) = sub_sat( *( farray_ptr_fx + k ), tmp1 ); move16(); *( farray_ptr_fx + kj + 1 ) = sub_sat( *( farray_ptr_fx + k + 1 ), tmp2 ); @@ -4118,16 +3832,6 @@ static void c_fft_wi_fx( Word16 *farray_ptr_fx, Word16 size, Word16 stage, Word1 move16(); *( farray_ptr_fx + k + 1 ) = add_sat( *( farray_ptr_fx + k + 1 ), tmp2 ); move16(); -#else - *( farray_ptr_fx + kj ) = sub( *( farray_ptr_fx + k ), tmp1 ); - move16(); - *( farray_ptr_fx + kj + 1 ) = sub( *( farray_ptr_fx + k + 1 ), tmp2 ); - move16(); - *( farray_ptr_fx + k ) = add( *( farray_ptr_fx + k ), tmp1 ); - move16(); - *( farray_ptr_fx + k + 1 ) = add( *( farray_ptr_fx + k + 1 ), tmp2 ); - move16(); -#endif } } } @@ -4314,13 +4018,8 @@ void copy_phase_fx( DTFS_STRUCTURE *X1_fx, DTFS_STRUCTURE X2_fx, DTFS_STRUCTURE FOR( k = 1; k <= HalfLag; k++ ) { -#ifdef BASOP_NOGLOB Lacc_fx = L_mult_o( X1_fx->a_fx[k], X1_fx->a_fx[k], &Overflow ); Lacc_fx = L_mac_o( Lacc_fx, X1_fx->b_fx[k], X1_fx->b_fx[k], &Overflow ); /* 2*Q+1 */ -#else - Lacc_fx = L_mult( X1_fx->a_fx[k], X1_fx->a_fx[k] ); - Lacc_fx = L_mac( Lacc_fx, X1_fx->b_fx[k], X1_fx->b_fx[k] ); /* 2*Q+1 */ -#endif exp = norm_l( Lacc_fx ); tmp = extract_h( L_shl( Lacc_fx, exp ) ); @@ -4361,7 +4060,6 @@ void copy_phase_fx( DTFS_STRUCTURE *X1_fx, DTFS_STRUCTURE X2_fx, DTFS_STRUCTURE d1h = extract_h( Ltemp_fx ); d1l = extract_l( Ltemp_fx ); -#ifdef BASOP_NOGLOB Ltemp_fx = L_mult0( X1_fx->b_fx[k], d1l ); Ltemp_fx = L_add_o( L_shr( Ltemp_fx, 15 ), L_mult_o( X1_fx->b_fx[k], d1h, &Overflow ), &Overflow ); /* sin(w) in Q(q+16+Q-15) */ sn = round_fx_o( L_shl_o( Ltemp_fx, sub( 30, add( q, X1_fx->Q ) ), &Overflow ), &Overflow ); /* Q15 */ @@ -4373,19 +4071,6 @@ void copy_phase_fx( DTFS_STRUCTURE *X1_fx, DTFS_STRUCTURE X2_fx, DTFS_STRUCTURE cn = round_fx_o( L_shl_o( Ltemp_fx, sub( 30, add( q, X1_fx->Q ) ), &Overflow ), &Overflow ); /* Q15 */ retX_fx->a_fx[k] = mult_ro( X2_fx.a_fx[k], cn, &Overflow ); /* X2_fx.Q */ move16(); -#else - Ltemp_fx = L_mult0( X1_fx->b_fx[k], d1l ); - Ltemp_fx = L_add( L_shr( Ltemp_fx, 15 ), L_mult( X1_fx->b_fx[k], d1h ) ); /* sin(w) in Q(q+16+Q-15) */ - sn = round_fx( L_shl( Ltemp_fx, sub( 30, add( q, X1_fx->Q ) ) ) ); /* Q15 */ - retX_fx->b_fx[k] = mult_r( X2_fx.a_fx[k], sn ); /* X2_fx.Q */ - move16(); - - Ltemp_fx = L_mult0( X1_fx->a_fx[k], d1l ); - Ltemp_fx = L_add( L_shr( Ltemp_fx, 15 ), L_mult( X1_fx->a_fx[k], d1h ) ); /* cos(w) in Q(q+Q+1) */ - cn = round_fx( L_shl( Ltemp_fx, sub( 30, add( q, X1_fx->Q ) ) ) ); /* Q15 */ - retX_fx->a_fx[k] = mult_r( X2_fx.a_fx[k], cn ); /* X2_fx.Q */ - move16(); -#endif } k = sub( k, 1 ); @@ -4476,12 +4161,8 @@ Word32 getSpEngyFromResAmp_fx( DTFS_STRUCTURE *X_fx, Word16 lband, Word16 hband, FOR( i = 0; i < M + 1; i++ ) { /* Compute Re */ -#ifdef BASOP_NOGLOB Lacc = L_mac_o( Lacc, curr_lpc[i], cos_tab[n % M_fx], &Overflow ); /* Q28 */ -#else - Lacc = L_mac( Lacc, curr_lpc[i], cos_tab[n % M_fx] ); /* Q28 */ -#endif - n = add( n, k4 ); /* n=4*i*k */ + n = add( n, k4 ); /* n=4*i*k */ } Re = L_shr( Lacc, 1 ); /* Q27 */ @@ -4491,21 +4172,13 @@ Word32 getSpEngyFromResAmp_fx( DTFS_STRUCTURE *X_fx, Word16 lband, Word16 hband, FOR( i = 0; i < M + 1; i++ ) { /* Compute Im */ -#ifdef BASOP_NOGLOB Lacc = L_msu_o( Lacc, curr_lpc[i], sin_tab[n % M_fx], &Overflow ); /* Q28 */ -#else - Lacc = L_msu( Lacc, curr_lpc[i], sin_tab[n % M_fx] ); /* Q28 */ -#endif - n = add( n, k4 ); /* n=4*i*k */ + n = add( n, k4 ); /* n=4*i*k */ } - Im = L_shr( Lacc, 1 ); /* Q27 */ - /* Lacc=L_add(L_mult_ll(Re,Re),(Word32)L_mult_ll(Im,Im)); : Lacc=Re^2+Im^2 in Q23 */ -#ifdef BASOP_NOGLOB + Im = L_shr( Lacc, 1 ); /* Q27 */ + /* Lacc=L_add(L_mult_ll(Re,Re),(Word32)L_mult_ll(Im,Im)); : Lacc=Re^2+Im^2 in Q23 */ Lacc = L_add_o( Mult_32_32( Re, Re ), Mult_32_32( Im, Im ), &Overflow ); /* Lacc=Re^2+Im^2 in Q23 */ -#else - Lacc = L_add( Mult_32_32( Re, Re ), Mult_32_32( Im, Im ) ); /* Lacc=Re^2+Im^2 in Q23 */ -#endif - Ltemp = L_mult0( X_fx->a_fx[k], X_fx->a_fx[k] ); /* 2*a[k]^2 in 2Q */ + Ltemp = L_mult0( X_fx->a_fx[k], X_fx->a_fx[k] ); /* 2*a[k]^2 in 2Q */ /* Ltemp=(Word32)L_sat32_40(divide_dp(Ltemp,Lacc,-19,1)); : Ltemp in Q(2Q-13) */ if ( Lacc < 0 ) @@ -4531,11 +4204,7 @@ Word32 getSpEngyFromResAmp_fx( DTFS_STRUCTURE *X_fx, Word16 lband, Word16 hband, tmp = div_s( fracb, fraca ); /* 15-exp */ exp = sub( expb, expa ); -#ifdef BASOP_NOGLOB Ltemp = L_shl_o( tmp, sub( add( shl( X_fx->Q, 1 ), exp ), 27 ), &Overflow ); -#else - Ltemp = L_shl( tmp, sub( add( shl( X_fx->Q, 1 ), exp ), 27 ) ); -#endif } ELSE { @@ -4601,41 +4270,21 @@ void DTFS_poleFilter_fx( DTFS_STRUCTURE *X_fx, Word16 *LPC, Word16 N, Word16 *S_ sum2_fx = L_deposit_l( 0 ); FOR( n = 0; n < N; n++ ) { -#ifdef BASOP_NOGLOB sum1_fx = L_mac_o( sum1_fx, LPC[n], C_fx[shl( temp2, 2 ) % shl( X_fx->lag_fx, 2 )], &Overflow ); /* Q(12+15+1) */ sum2_fx = L_mac_o( sum2_fx, LPC[n], S_fx[shl( temp2, 2 ) % shl( X_fx->lag_fx, 2 )], &Overflow ); /* Q(12+15+1) */ -#else - sum1_fx = L_mac( sum1_fx, LPC[n], C_fx[( 4 * temp2 ) % ( 4 * X_fx->lag_fx )] ); /* Q(12+15+1) */ - sum2_fx = L_mac( sum2_fx, LPC[n], S_fx[( 4 * temp2 ) % ( 4 * X_fx->lag_fx )] ); /* Q(12+15+1) */ -#endif temp2 = add( temp2, k ); } -#ifdef BASOP_NOGLOB temp1 = round_fx_o( sum1_fx, &Overflow ); /* Q(12+15+1-16)=Q(12) */ temp2 = round_fx_o( sum2_fx, &Overflow ); /* Q(12) */ /* Calculate the circular convolution */ sum = L_mac_o( L_mult_o( temp1, temp1, &Overflow ), temp2, temp2, &Overflow ); /* Q(12+12+1)=Q(25) */ -#else - temp1 = round_fx( sum1_fx ); /* Q(12+15+1-16)=Q(12) */ - temp2 = round_fx( sum2_fx ); /* Q(12) */ - /* Calculate the circular convolution */ - sum = L_mac( L_mult( temp1, temp1 ), temp2, temp2 ); /* Q(12+12+1)=Q(25) */ -#endif L_temp1 = L_mult( temp1, X_fx->a_fx[k] ); -#ifdef BASOP_NOGLOB L_temp1 = L_mac_o( L_temp1, temp2, X_fx->b_fx[k], &Overflow ); /* Q(12+Q+1)=Q(13+Q) */ -#else - L_temp1 = L_mac( L_temp1, temp2, X_fx->b_fx[k] ); /* Q(12+Q+1)=Q(13+Q) */ -#endif L_temp2 = L_mult( temp1, X_fx->b_fx[k] ); -#ifdef BASOP_NOGLOB L_temp2 = L_msu_o( L_temp2, temp2, X_fx->a_fx[k], &Overflow ); /* Q(12+Q+1)=Q(13+Q) */ -#else - L_temp2 = L_msu( L_temp2, temp2, X_fx->a_fx[k] ); /* Q(12+Q+1)=Q(13+Q) */ -#endif IF( sum ) { exp = norm_l( sum ); @@ -4750,13 +4399,8 @@ void poleFilter_setup_fx( const Word16 *LPC, Word16 N, DTFS_STRUCTURE X_fx, Word sum2_fx = L_deposit_l( 0 ); FOR( n = 0; n < N; n++ ) { -#ifdef BASOP_NOGLOB sum1_fx = L_mac_o( sum1_fx, LPC[n], C_fx[( 4 * temp2 ) % ( 4 * X_fx.lag_fx )], &Overflow ); /* Q(12+15+1) */ sum2_fx = L_mac_o( sum2_fx, LPC[n], S_fx[( 4 * temp2 ) % ( 4 * X_fx.lag_fx )], &Overflow ); /* Q(12+15+1) */ -#else - sum1_fx = L_mac( sum1_fx, LPC[n], C_fx[( 4 * temp2 ) % ( 4 * X_fx.lag_fx )] ); /* Q(12+15+1) */ - sum2_fx = L_mac( sum2_fx, LPC[n], S_fx[( 4 * temp2 ) % ( 4 * X_fx.lag_fx )] ); /* Q(12+15+1) */ -#endif temp2 = add( temp2, k ); } diff --git a/lib_com/window_fx.c b/lib_com/window_fx.c index 2b3c50ac6749ca1a74fed4bd80ad51a09e5f3d76..a1ff625b08f2328fac98ec8066afed188f7e453d 100644 --- a/lib_com/window_fx.c +++ b/lib_com/window_fx.c @@ -46,13 +46,8 @@ void ham_cos_window( { /* fh_f[i] = 0.54f - 0.46f * (Float32)cos(cc); */ BASOP_SATURATE_WARNING_OFF_EVS -#ifdef BASOP_NOGLOB fh[i] = sub_o( P54_0Q15, mult_r( getCosWord16( round_fx_o( L_shl_o( cc, 9, &Overflow ), &Overflow ) ), P92_0Q15 ), &Overflow ); /*0Q15*/ move16(); -#else - fh[i] = sub( P54_0Q15, mult_r( getCosWord16( round_fx( L_shl( cc, 9 ) ) ), P92_0Q15 ) ); /*0Q15*/ - move16(); -#endif BASOP_SATURATE_WARNING_ON_EVS cc = L_add( cc, cte ); /*0Q15*/ } @@ -68,13 +63,8 @@ void ham_cos_window( FOR( i = n1; i < n1 + n2; i++ ) { /* fh_f[i] = (Float32)cos(cc); */ -#ifdef BASOP_NOGLOB fh[i] = shl_o( getCosWord16( round_fx( L_shl( cc, 10 ) ) ), 1, &Overflow ); /*0Q15*/ move16(); -#else - fh[i] = shl( getCosWord16( round_fx( L_shl( cc, 10 ) ) ), 1 ); /*0Q15*/ - move16(); -#endif cc = L_add( cc, cte ); } BASOP_SATURATE_WARNING_ON_EVS diff --git a/lib_com/window_ola_fx.c b/lib_com/window_ola_fx.c index 40763be995bdd9a8d5664f33fcc19c2409891084..19725735ae1d549aecbf4640c6f70f9747a88525 100644 --- a/lib_com/window_ola_fx.c +++ b/lib_com/window_ola_fx.c @@ -27,16 +27,12 @@ void sinq_fx( L_tmp = Mult_32_16( L_tmp, 5461 ); /*Q31; division by 6 */ tmp2 = round_fx( L_tmp ); /*Q15 */ x[1] = sub( tmp1, tmp2 ); - move16(); /* sin(x) approximated by (x-x^3/3!); Q15 */ -#ifdef BASOP_NOGLOB + move16(); /* sin(x) approximated by (x-x^3/3!); Q15 */ tmp1 = add_sat( shl_sat( tmp, 1 ), phi ); /*Q15 */ -#else - tmp1 = add( shl( tmp, 1 ), phi ); /*Q15 */ -#endif - L_tmp = L_mult( tmp1, tmp1 ); /*Q31 */ - L_tmp = Mult_32_16( L_tmp, tmp1 ); /*Q31 */ - L_tmp = Mult_32_16( L_tmp, 5461 ); /*Q31; division by 6 */ - tmp2 = round_fx( L_tmp ); /*Q15 */ + L_tmp = L_mult( tmp1, tmp1 ); /*Q31 */ + L_tmp = Mult_32_16( L_tmp, tmp1 ); /*Q31 */ + L_tmp = Mult_32_16( L_tmp, 5461 ); /*Q31; division by 6 */ + tmp2 = round_fx( L_tmp ); /*Q15 */ x[2] = sub( tmp1, tmp2 ); move16(); /* sin(x) approximated by (x-x^3/3!); Q15 */ @@ -62,13 +58,8 @@ void sinq_fx( L_tmp = Mult_32_32( A32, tmp_old ); /*Q30 */ L_tmp = L_sub( L_tmp, L_shr( tmp_old_old, 1 ) ); /*Q30 */ tmp_old_old = L_add( tmp_old, 0 ); /*Q31 */ -#ifdef BASOP_NOGLOB - tmp_old = L_shl_sat( L_tmp, 1 ); /*Q31 */ - x[i] = round_fx_sat( tmp_old ); /*Q15 */ -#else - tmp_old = L_shl( L_tmp, 1 ); /*Q31 */ - x[i] = round_fx( tmp_old ); /*Q15 */ -#endif + tmp_old = L_shl_sat( L_tmp, 1 ); /*Q31 */ + x[i] = round_fx_sat( tmp_old ); /*Q15 */ move16(); } @@ -328,11 +319,7 @@ void window_ola_fx( p4 = OldauOut + n; FOR( i = 0; i < temp; i++ ) { -#ifdef BASOP_NOGLOB *p1 = add_sat( mult( *p1, *p2 ), shl_sat( mult( *p4, *p3 ), 5 ) ); /*auOut[i]*SS2[i]+ OldauOut[i+n]*(SS2[L-n-i-1])/(wret2[i]+0.01f);;*/ -#else - *p1 = add( mult( *p1, *p2 ), shl( mult( *p4, *p3 ), 5 ) ); /*auOut[i]*SS2[i]+ OldauOut[i+n]*(SS2[L-n-i-1])/(wret2[i]+0.01f);;*/ -#endif move16(); p1++; p2++; @@ -359,15 +346,9 @@ void window_ola_fx( temp_len = sub( shr( L, 1 ), n ); FOR( i = 0; i < temp_len; i += 2 ) { -#ifdef BASOP_NOGLOB *p1++ = round_fx_sat( L_add_sat( L_shl_sat( Mult_32_16( *pa++, *p3 ), 1 ), L_deposit_h( *p4++ ) ) ); /* (( Qin + Q15 -15)+1 + ( Qin - 15 + 16))-1 */ p3 -= decimate; *p1++ = round_fx_sat( L_add_sat( L_shl_sat( Mult_32_16( *pa++, *p5-- ), 1 ), L_deposit_h( *p4++ ) ) ); /* (( Qin + Q15 -15)+1 + ( Qin - 15 + 16))-1 */ -#else - *p1++ = round_fx( L_add( L_shl( Mult_32_16( *pa++, *p3 ), 1 ), L_deposit_h( *p4++ ) ) ); /* (( Qin + Q15 -15)+1 + ( Qin - 15 + 16))-1 */ - p3 -= decimate; - *p1++ = round_fx( L_add( L_shl( Mult_32_16( *pa++, *p5-- ), 1 ), L_deposit_h( *p4++ ) ) ); /* (( Qin + Q15 -15)+1 + ( Qin - 15 + 16))-1 */ -#endif move16(); /* paout[i] = ImdctOut[L/2 + i] * win_right[(2*L_FRAME16k-(n16+(i-n)/2))*decimate-1-decay-windecay48]+OldauOut[i]; paout[i+1] = ImdctOut[L/2 + i +1] * win_int_right[2*L_FRAME16k-(n16+(i-n)/2)-1-windecay16]+OldauOut[i+1];*/ @@ -380,13 +361,8 @@ void window_ola_fx( temp_len = sub( shr( L, 1 ), n ); FOR( i = 0; i < temp_len; i += 2 ) { -#ifdef BASOP_NOGLOB *p1++ = round_fx_sat( L_sub_sat( L_deposit_h( *p4++ ), L_shl_sat( Mult_32_16( *pa--, *p5-- ), 1 ) ) ); /* (( Qin + Q15 -15)+1 + ( Qin - 15 + 16))-1 */ *p1++ = round_fx_sat( L_sub_sat( L_deposit_h( *p4++ ), L_shl_sat( Mult_32_16( *pa--, *p3 ), 1 ) ) ); /* (( Qin + Q15 -15)+1 + ( Qin - 15 + 16))-1 */ -#else - *p1++ = round_fx( L_sub( L_deposit_h( *p4++ ), L_shl( Mult_32_16( *pa--, *p5-- ), 1 ) ) ); /* (( Qin + Q15 -15)+1 + ( Qin - 15 + 16))-1 */ - *p1++ = round_fx( L_sub( L_deposit_h( *p4++ ), L_shl( Mult_32_16( *pa--, *p3 ), 1 ) ) ); /* (( Qin + Q15 -15)+1 + ( Qin - 15 + 16))-1 */ -#endif move16(); p3 -= decimate; /* paout[L/2 + i ] = -ImdctOut[L - 1 - i] * win_int_right[(3*L_FRAME16k/2-1-i/2)-windecay16]+OldauOut[i+L/2]; @@ -450,11 +426,7 @@ void window_ola_fx( temp_len = sub( shr( L, 1 ), n ); FOR( i = 0; i < temp_len; i++ ) { -#ifdef BASOP_NOGLOB *p1++ = round_fx_sat( L_add_sat( L_shl( Mult_32_16( *pa++, *p3 ), 1 ), L_deposit_h( *p4++ ) ) ); /* (( Qin + Q15 -15)+1 + ( Qin - 15 + 16))-1 */ -#else - *p1++ = round_fx( L_add( L_shl( Mult_32_16( *pa++, *p3 ), 1 ), L_deposit_h( *p4++ ) ) ); /* (( Qin + Q15 -15)+1 + ( Qin - 15 + 16))-1 */ -#endif move16(); p3 -= decimate; /*paout[i] = ImdctOut[L/2 + i] * win_right[(2*L-i)*decimate-1-decay-windecay48]+OldauOut[i];*/ @@ -466,11 +438,7 @@ void window_ola_fx( temp_len = sub( shr( L, 1 ), n ); FOR( i = 0; i < temp_len; i++ ) { -#ifdef BASOP_NOGLOB *p1++ = round_fx_sat( L_sub_sat( L_deposit_h( *p4++ ), L_shl_sat( Mult_32_16( *pa--, *p3 ), 1 ) ) ); /* (( Qin + Q15 -15)+1 + ( Qin - 15 + 16))-1 */ -#else - *p1++ = round_fx( L_sub( L_deposit_h( *p4++ ), L_shl( Mult_32_16( *pa--, *p3 ), 1 ) ) ); /* (( Qin + Q15 -15)+1 + ( Qin - 15 + 16))-1 */ -#endif move16(); p3 -= decimate; /* paout[L/2 + i] = -ImdctOut[L - 1 - i] * win_right[(3*L/2-1-i)*decimate+decay-windecay48]+OldauOut[i+L/2]; */ @@ -930,15 +898,9 @@ void core_switching_OLA_fx( temp_len = i_mult2( ( R2_16 >> 2 ), delta ); FOR( i = 0; i < temp_len; i += 2 ) { -#ifdef BASOP_NOGLOB *pt = shl_sat( mult_r_sat( *pt, *pt5 ), 1 ); move16(); /* // Q14* Q15 + shl ==> Q15 */ *pt2 = shl_sat( mult_r_sat( *pt2, *pt4 ), 1 ); -#else - *pt = shl( mult_r( *pt, *pt5 ), 1 ); - move16(); /* // Q14* Q15 + shl ==> Q15 */ - *pt2 = shl( mult_r( *pt2, *pt4 ), 1 ); -#endif move16(); /*/= win[(3*L_FRAME16k/2-1-i/2)*decimate+decay-L_FRAME48k*14/20]; */ pt += 2; pt2 += 2; @@ -954,11 +916,7 @@ void core_switching_OLA_fx( temp_len = i_mult2( ( R2_16 >> 2 ), delta ); FOR( i = 0; i < temp_len; i++ ) { -#ifdef BASOP_NOGLOB *pt = shl_sat( mult_r_sat( *pt, *pt5 ), 1 ); -#else - *pt = shl( mult_r( *pt, *pt5 ), 1 ); -#endif move16(); /* /= win[(3*output_frame/2-1-i)*decimate+decay-L_FRAME48k*14/20]; */ pt++; pt5 -= decimate; @@ -1007,11 +965,7 @@ void core_switching_OLA_fx( temp_len = sub( L, tmp ); FOR( i = 0; i < temp_len; i++ ) { -#ifdef BASOP_NOGLOB *pt = add_sat( add_sat( *pt, *pt2++ ), *pt3++ ); -#else - *pt = add( add( *pt, *pt2++ ), *pt3++ ); -#endif move16(); pt++; } diff --git a/lib_com/wtda_fx.c b/lib_com/wtda_fx.c index 5f35a3c299fc9aff890d85c361be94182f978ff5..e060984dff14eb316ed1d965e06830487eb1624b 100644 --- a/lib_com/wtda_fx.c +++ b/lib_com/wtda_fx.c @@ -572,7 +572,7 @@ void wtda_ivas_fx( void wtda_ext_fx( const Word16 *new_audio, /* i : input audio (Q_in) */ - Word16 *wtda_audio, /* o : windowed audio (Q_in) */ + Word16 *wtda_audio, /* o : windowed audio (Q_in - 1) */ const Word16 left_mode, /* i : window overlap of previous frame (0: full, 2: none, or 3: half) */ const Word16 right_mode, /* i : window overlap of current frame (0: full, 2: none, or 3: half) */ const Word16 L, /* i : length */ @@ -628,10 +628,10 @@ void wtda_ext_fx( FOR( i = 0; i < L / 2 - n; i += 2 ) { wtda_audio[i] = round_fx( L_mac0( L_mult0( negate( allsig_r[L / 2 - i - 1] ), win_int_right[3 * L_FRAME16k / 2 - i / 2 - 1 - windecay16] ), - allsig_r[L / 2 + i], win_int_right[3 * L_FRAME16k / 2 + i / 2 - windecay16] ) ); // q_in + allsig_r[L / 2 + i], win_int_right[3 * L_FRAME16k / 2 + i / 2 - windecay16] ) ); // q_in - 1 move16(); wtda_audio[i + 1] = round_fx( L_mac0( L_mult0( negate( allsig_r[L / 2 - ( i + 1 ) - 1] ), win_right[( 3 * L_FRAME16k / 2 - i / 2 - 1 ) * decimate + decay - windecay48] ), - allsig_r[L / 2 + i + 1], win_right[( 3 * L_FRAME16k / 2 + 1 + i / 2 ) * decimate - decay - 1 - windecay48] ) ); // q_in + allsig_r[L / 2 + i + 1], win_right[( 3 * L_FRAME16k / 2 + 1 + i / 2 ) * decimate - decay - 1 - windecay48] ) ); // q_in - 1 move16(); } } @@ -640,19 +640,19 @@ void wtda_ext_fx( FOR( i = 0; i < L / 2 - n; i += 2 ) { wtda_audio[i] = round_fx( L_msu0( L_mult0( negate( allsig_r[L / 2 - i - 1] ), win_int_right[3 * L_FRAME16k / 2 - i / 2 - 1 - windecay16] ), - allsig_r[L / 2 + i], win_int_right[3 * L_FRAME16k / 2 + i / 2 - windecay16] ) ); // q_in + allsig_r[L / 2 + i], win_int_right[3 * L_FRAME16k / 2 + i / 2 - windecay16] ) ); // q_in - 1 move16(); wtda_audio[i + 1] = round_fx( L_msu0( L_mult0( negate( allsig_r[L / 2 - ( i + 1 ) - 1] ), win_right[( 3 * L_FRAME16k / 2 - i / 2 - 1 ) * decimate + decay - windecay48] ), - allsig_r[L / 2 + i + 1], win_right[( 3 * L_FRAME16k / 2 + 1 + i / 2 ) * decimate - decay - 1 - windecay48] ) ); // q_in + allsig_r[L / 2 + i + 1], win_right[( 3 * L_FRAME16k / 2 + 1 + i / 2 ) * decimate - decay - 1 - windecay48] ) ); // q_in - 1 move16(); } } FOR( i = L / 2 - n; i < L / 2; i += 2 ) { - wtda_audio[i] = shr( negate( allsig_r[L / 2 - i - 1] ), 1 ); // q_in + wtda_audio[i] = shr( negate( allsig_r[L / 2 - i - 1] ), 1 ); // q_in - 1 move16(); - wtda_audio[i + 1] = shr( negate( allsig_r[L / 2 - ( i + 1 ) - 1] ), 1 ); // q_in + wtda_audio[i + 1] = shr( negate( allsig_r[L / 2 - ( i + 1 ) - 1] ), 1 ); // q_in - 1 move16(); } @@ -661,20 +661,20 @@ void wtda_ext_fx( FOR( i = 0; i < n; i += 2 ) { wtda_audio[i + L / 2] = round_fx( L_msu0( L_mult0( negate( allsig_l[i] ), win_left[( i / 2 ) * decimate + decay] ), - new_audio[n - i - 1], MAX16B ) ); // q_in + new_audio[n - i - 1], MAX16B ) ); // q_in - 1 move16(); wtda_audio[i + L / 2 + 1] = round_fx( L_msu0( L_mult0( negate( allsig_l[i + 1] ), win_int_left[i / 2] ), - new_audio[n - ( i + 1 ) - 1], MAX16B ) ); // q_in + new_audio[n - ( i + 1 ) - 1], MAX16B ) ); // q_in - 1 move16(); } FOR( i = n; i < L / 2; i += 2 ) { wtda_audio[i + L / 2] = round_fx( L_msu0( L_mult0( negate( allsig_l[i] ), win_left[( i / 2 ) * decimate + decay] ), - allsig_l[L - i - 1], win_left[( L / 2 - i / 2 ) * decimate - 1 - decay] ) ); // q_in + allsig_l[L - i - 1], win_left[( L / 2 - i / 2 ) * decimate - 1 - decay] ) ); // q_in - 1 move16(); wtda_audio[i + L / 2 + 1] = round_fx( L_msu0( L_mult0( negate( allsig_l[i + 1] ), win_int_left[i / 2] ), - allsig_l[L - ( i + 1 ) - 1], win_int_left[L / 2 - i / 2 - 1] ) ); // q_in + allsig_l[L - ( i + 1 ) - 1], win_int_left[L / 2 - i / 2 - 1] ) ); // q_in - 1 move16(); } } @@ -683,20 +683,20 @@ void wtda_ext_fx( FOR( i = 0; i < n; i += 2 ) { wtda_audio[i + L / 2] = round_fx( L_msu0( L_mult0( allsig_l[i], win_left[( i / 2 ) * decimate + decay] ), - new_audio[n - i - 1], MAX16B ) ); // q_in + new_audio[n - i - 1], MAX16B ) ); // q_in - 1 move16(); wtda_audio[i + L / 2 + 1] = round_fx( L_msu0( L_mult0( allsig_l[i + 1], win_int_left[i / 2] ), - new_audio[n - ( i + 1 ) - 1], MAX16B ) ); // q_in + new_audio[n - ( i + 1 ) - 1], MAX16B ) ); // q_in - 1 move16(); } FOR( i = n; i < L / 2; i += 2 ) { wtda_audio[i + L / 2] = round_fx( L_msu0( L_mult0( allsig_l[i], win_left[( i / 2 ) * decimate + decay] ), - allsig_l[L - i - 1], win_left[( L / 2 - i / 2 ) * decimate - 1 - decay] ) ); // q_in + allsig_l[L - i - 1], win_left[( L / 2 - i / 2 ) * decimate - 1 - decay] ) ); // q_in - 1 move16(); wtda_audio[i + L / 2 + 1] = round_fx( L_msu0( L_mult0( allsig_l[i + 1], win_int_left[i / 2] ), - allsig_l[L - ( i + 1 ) - 1], win_int_left[L / 2 - i / 2 - 1] ) ); // q_in + allsig_l[L - ( i + 1 ) - 1], win_int_left[L / 2 - i / 2 - 1] ) ); // q_in - 1 move16(); } } @@ -708,7 +708,7 @@ void wtda_ext_fx( FOR( i = 0; i < L / 2 - n; i++ ) { wtda_audio[i] = round_fx( L_mac0( L_mult0( negate( allsig_r[L / 2 - i - 1] ), win_right[3 * L / 2 * decimate - ( i + 1 ) * decimate + decay - windecay48] ), - allsig_r[L / 2 + i], win_right[3 * L / 2 * decimate - 1 + ( i + 1 ) * decimate - decay - windecay48] ) ); // q_in + allsig_r[L / 2 + i], win_right[3 * L / 2 * decimate - 1 + ( i + 1 ) * decimate - decay - windecay48] ) ); // q_in - 1 move16(); } } @@ -717,14 +717,14 @@ void wtda_ext_fx( FOR( i = 0; i < L / 2 - n; i++ ) { wtda_audio[i] = round_fx( L_msu0( L_mult0( negate( allsig_r[L / 2 - i - 1] ), win_right[3 * L / 2 * decimate - ( i + 1 ) * decimate + decay - windecay48] ), - allsig_r[L / 2 + i], win_right[3 * L / 2 * decimate - 1 + ( i + 1 ) * decimate - decay - windecay48] ) ); // q_in + allsig_r[L / 2 + i], win_right[3 * L / 2 * decimate - 1 + ( i + 1 ) * decimate - decay - windecay48] ) ); // q_in - 1 move16(); } } FOR( i = L / 2 - n; i < L / 2; i++ ) { - wtda_audio[i] = shr( negate( allsig_r[L / 2 - i - 1] ), 1 ); // q_in + wtda_audio[i] = shr( negate( allsig_r[L / 2 - i - 1] ), 1 ); // q_in - 1 move16(); } @@ -733,14 +733,14 @@ void wtda_ext_fx( FOR( i = 0; i < n; i++ ) { wtda_audio[i + L / 2] = round_fx( L_msu0( L_mult0( negate( allsig_l[i] ), win_left[i * decimate + decay] ), - new_audio[n - i - 1], MAX16B ) ); // q_in + new_audio[n - i - 1], MAX16B ) ); // q_in - 1 move16(); } FOR( i = n; i < L / 2; i++ ) { wtda_audio[i + L / 2] = round_fx( L_msu0( L_mult0( negate( allsig_l[i] ), win_left[i * decimate + decay] ), - allsig_l[L - i - 1], win_left[L * decimate - i * decimate - 1 - decay] ) ); // q_in + allsig_l[L - i - 1], win_left[L * decimate - i * decimate - 1 - decay] ) ); // q_in - 1 move16(); } } @@ -749,14 +749,14 @@ void wtda_ext_fx( FOR( i = 0; i < n; i++ ) { wtda_audio[i + L / 2] = round_fx( L_msu0( L_mult0( allsig_l[i], win_left[i * decimate + decay] ), - new_audio[n - i - 1], MAX16B ) ); // q_in + new_audio[n - i - 1], MAX16B ) ); // q_in - 1 move16(); } FOR( i = n; i < L / 2; i++ ) { wtda_audio[i + L / 2] = round_fx( L_msu0( L_mult0( allsig_l[i], win_left[i * decimate + decay] ), - allsig_l[L - i - 1], win_left[L * decimate - i * decimate - 1 - decay] ) ); // q_in + allsig_l[L - i - 1], win_left[L * decimate - i * decimate - 1 - decay] ) ); // q_in - 1 move16(); } } diff --git a/lib_debug/debug.c b/lib_debug/debug.c index 8053a7cd91a73963ff5f669d39bd359430320906..e939edddc0dd85033bf64dbbf660b0bb365fcf7f 100644 --- a/lib_debug/debug.c +++ b/lib_debug/debug.c @@ -39,6 +39,7 @@ #include "options.h" #ifdef DEBUGGING #include "debug.h" +#include #ifdef DEBUG_MODE_INFO #ifdef DEBUG_MODE_INFO_TWEAK #include @@ -778,14 +779,14 @@ char *fname( const int16_t id, const int16_t enc_dec ) { - char idd[5] = ".idX"; - idd[3] = (char) ( id + '0' ); -#ifdef DEBUG_FORCE_DIR - size_t len; -#endif + char idd[6]; + + assert( id < 100 ); + sprintf( idd, ".id%d", id ); strcpy( tmp_fname, dir ); #ifdef DEBUG_FORCE_DIR + size_t len; len = strlen( tmp_fname ); if (tmp_fname[len - 1] != '/' && tmp_fname[len - 1] != '\\' ) { diff --git a/lib_dec/FEC_HQ_core_fx.c b/lib_dec/FEC_HQ_core_fx.c index 01002b56b665bd15f18fc5908b93b9006a00dff5..f88927ee50f3d5ee6c7d6a412805ee7e9fe9151e 100644 --- a/lib_dec/FEC_HQ_core_fx.c +++ b/lib_dec/FEC_HQ_core_fx.c @@ -78,13 +78,8 @@ static void Regression_Anal_fx( { b_p_fx[0] = L_add( b_p_fx[0], L_shr( values_fx[i], 2 ) ); /*10 */ move32(); -#ifdef BASOP_NOGLOB b_p_fx[1] = L_add( b_p_fx[1], Mult_32_16( values_fx[i], shl_o( sub( num_pgf, i ), 13, &Overflow ) ) ); /*10 */ move32(); -#else - b_p_fx[1] = L_add( b_p_fx[1], Mult_32_16( values_fx[i], shl( sub( num_pgf, i ), 13 ) ) ); /*10 */ - move32(); -#endif } tmp = sub( i_mult( aindex_fx[0], aindex_fx[2] ), i_mult( aindex_fx[1], aindex_fx[1] ) ); @@ -378,11 +373,7 @@ void HQ_FEC_processing_fx( exp2 = norm_l( norm_values_fx[0] ); tmp_fx = div_s( extract_h( L_shl( norm_p_fx[i], exp1 ) ), extract_h( L_shl( norm_values_fx[0], exp2 ) ) ); /*15 + (5 + exp1 - 16) - (12 + exp2 - 16)*/ -#ifdef BASOP_NOGLOB - tmp_fx = shl_sat( tmp_fx, add( 6, sub( exp2, exp1 ) ) ); /*14*/ -#else - tmp_fx = shl( tmp_fx, add( 6, sub( exp2, exp1 ) ) ); /*14*/ -#endif + tmp_fx = shl_sat( tmp_fx, add( 6, sub( exp2, exp1 ) ) ); /*14*/ if ( GT_16( tmp_fx, 16384 ) ) { tmp_fx = 16384; @@ -391,14 +382,9 @@ void HQ_FEC_processing_fx( FOR( j = 0; j < Num_bands_p[i]; j++ ) { -#ifdef BASOP_NOGLOB hHQ_nbfec->Norm_gain_fx[k] = shl_o( tmp_fx, 1, &Overflow ); move16(); k = add( k, 1 ); -#else - hHQ_nbfec->Norm_gain_fx[k++] = shl( tmp_fx, 1 ); - move16(); -#endif } } ELSE @@ -532,12 +518,8 @@ void ivas_HQ_FEC_Mem_update_fx( L_tmp = L_add( L_tmp, L_shr( normq_fx[k], 3 ) ); /*11*/ k = add( k, 1 ); } -#ifdef BASOP_NOGLOB tmp_fx = shl_o( inv_tbl_fx[Num_bands_p[i]], 1, &Overflow ); /*16*/ -#else - tmp_fx = shl( inv_tbl_fx[Num_bands_p[i]], 1 ); /*16*/ -#endif - norm_values_fx[0] = Mult_32_16( L_tmp, tmp_fx ); /*11 + 16 - 15*/ + norm_values_fx[0] = Mult_32_16( L_tmp, tmp_fx ); /*11 + 16 - 15*/ move32(); tmp_energy_fx = L_add( tmp_energy_fx, L_shr( L_tmp, 3 ) ); /*8*/ } @@ -656,11 +638,7 @@ void ivas_HQ_FEC_Mem_update_fx( exp2 = norm_l( hHQ_nbfec->ynrm_values_fx[i][0] ); tmp_fx = div_s( extract_h( L_shl( en_high_fx[i], exp1 ) ), extract_h( L_shl( hHQ_nbfec->ynrm_values_fx[i][0], exp2 ) ) ); exp = add( 15, sub( exp1, exp2 ) ); -#ifdef BASOP_NOGLOB *mean_en_high_fx = add_o( *mean_en_high_fx, shr_o( tmp_fx, sub( exp, 5 ), &Overflow ), &Overflow ); -#else - *mean_en_high_fx = add( *mean_en_high_fx, shr( tmp_fx, sub( exp, 5 ) ) ); -#endif move16(); } *mean_en_high_fx = mult( *mean_en_high_fx, inv_tbl_fx[sub( num_Sb, k )] ); @@ -829,12 +807,8 @@ void HQ_FEC_Mem_update_fx( L_tmp = L_add( L_tmp, L_shr( normq_fx[k], 3 ) ); /*11*/ k = add( k, 1 ); } -#ifdef BASOP_NOGLOB tmp_fx = shl_o( inv_tbl_fx[Num_bands_p[i]], 1, &Overflow ); /*16*/ -#else - tmp_fx = shl( inv_tbl_fx[Num_bands_p[i]], 1 ); /*16*/ -#endif - norm_values_fx[0] = Mult_32_16( L_tmp, tmp_fx ); /*11 + 16 - 15*/ + norm_values_fx[0] = Mult_32_16( L_tmp, tmp_fx ); /*11 + 16 - 15*/ move32(); tmp_energy_fx = L_add( tmp_energy_fx, L_shr( L_tmp, 3 ) ); /*8*/ } @@ -857,12 +831,8 @@ void HQ_FEC_Mem_update_fx( move16(); /*15*/ L_tmp = Mult_32_16( tmp_energy_fx, tmp_fx ); /*8 + 15 - 15*/ -#ifdef BASOP_NOGLOB hHQ_nbfec->energy_MA_Curr_fx[1] = extract_h( L_shl_sat( L_tmp, 16 - 8 ) ); move16(); -#else - hHQ_nbfec->energy_MA_Curr_fx[1] = extract_h( L_shl( L_tmp, 16 - 8 ) ); -#endif /* Moving Average */ hHQ_nbfec->energy_MA_Curr_fx[0] = s_max( 1, add( mult_r( 26214, hHQ_nbfec->energy_MA_Curr_fx[0] ), mult_r( 6554, hHQ_nbfec->energy_MA_Curr_fx[1] ) ) ); move16(); @@ -958,11 +928,7 @@ void HQ_FEC_Mem_update_fx( exp2 = norm_l( hHQ_nbfec->ynrm_values_fx[i][0] ); tmp_fx = div_s( extract_h( L_shl( en_high_fx[i], exp1 ) ), extract_h( L_shl( hHQ_nbfec->ynrm_values_fx[i][0], exp2 ) ) ); exp = add( 15, sub( exp1, exp2 ) ); -#ifdef BASOP_NOGLOB *mean_en_high_fx = add_o( *mean_en_high_fx, shr_o( tmp_fx, sub( exp, 5 ), &Overflow ), &Overflow ); -#else - *mean_en_high_fx = add( *mean_en_high_fx, shr( tmp_fx, sub( exp, 5 ) ) ); -#endif move16(); } *mean_en_high_fx = mult( *mean_en_high_fx, inv_tbl_fx[sub( num_Sb, k )] ); @@ -1049,13 +1015,8 @@ static Word16 find_best_delay_fx( accB_fx = L_deposit_l( 0 ); FOR( i = 0; i < lin; i += delta ) { -#ifdef BASOP_NOGLOB accA_fx = L_add_sat( accA_fx, L_shr( L_mult_sat( mu_o_fx[d1 + i], mu_o_fx[d1 + i] ), 2 ) ); accB_fx = L_add_sat( accB_fx, L_shr( L_mult_sat( mu_o_fx[d1 + i], in_fx[i] ), 2 ) ); -#else - accA_fx = L_add( accA_fx, L_shr( L_mult( mu_o_fx[d1 + i], mu_o_fx[d1 + i] ), 2 ) ); - accB_fx = L_add( accB_fx, L_shr( L_mult( mu_o_fx[d1 + i], in_fx[i] ), 2 ) ); -#endif } Rxy_fx[k] = accB_fx; @@ -1107,12 +1068,8 @@ static Word16 find_best_delay_fx( exp2 = norm_l( min_corr_fx ); L_tmp1 = L_shl( min_sq_cross_fx, exp1 ); L_tmp2 = L_shl( min_corr_fx, exp2 ); - tmp = div_s( extract_h( L_tmp1 ), extract_h( L_tmp2 ) ); /*15 + exp1 - exp2 */ -#ifdef BASOP_NOGLOB + tmp = div_s( extract_h( L_tmp1 ), extract_h( L_tmp2 ) ); /*15 + exp1 - exp2 */ tmp = shl_o( tmp, sub( exp2, add( exp1, 1 ) ), &Overflow ); /*14 */ -#else - tmp = shl( tmp, sub( exp2, add( exp1, 1 ) ) ); /*14 */ -#endif } *false_flag = 0; @@ -1306,11 +1263,7 @@ static Word16 FEC_phase_matching_fx( tmp = shl( tmp, sub( sub( exp2, exp1 ), 1 ) ); /*14*/ FOR( i = N_ZERO_NB; i < L * 2; i++ ) { -#ifdef BASOP_NOGLOB ImdctOutWin_fx[i] = shl_sat( mult( ImdctOutWin_fx[i], tmp ), 1 ); -#else - ImdctOutWin_fx[i] = shl( mult( ImdctOutWin_fx[i], tmp ), 1 ); -#endif move16(); } } @@ -1582,11 +1535,7 @@ static void Repetition_smoothing_nextgood_fx( /*mvr2r(&ImdctOutWin[L], OldauOut, L);*/ FOR( i = 0; i < L; i++ ) { -#ifdef BASOP_NOGLOB auOut_fx[i] = add_sat( ImdctOutWin_fx[N_ZERO_NB + i], OldauOut_fx[i] ); // Q0 -#else - auOut_fx[i] = add( ImdctOutWin_fx[N_ZERO_NB + i], OldauOut_fx[i] ); -#endif move16(); } Copy( &ImdctOutWin_fx[L], OldauOut_fx, L ); @@ -1678,11 +1627,7 @@ static void common_overlapping_fx( FOR( i = 0; i < end1; i++ ) { /*auOut_fx[i] = L_add(ImdctOutWin_fx[i+7*L/20], OldauOut_fx[i+offset1]);*/ -#ifdef BASOP_NOGLOB auOut_fx[i] = add_sat( ImdctOutWin_fx[i + N_ZERO_NB], OldauOut_fx[i + offset1] ); -#else - auOut_fx[i] = add( ImdctOutWin_fx[i + N_ZERO_NB], OldauOut_fx[i + offset1] ); -#endif move16(); } FOR( i = start2; i < end2; i++ ) diff --git a/lib_dec/FEC_HQ_phase_ecu_fx.c b/lib_dec/FEC_HQ_phase_ecu_fx.c index f31f20af5e6b633270f0244618bbc1ed75055802..708fc39e6544f87830590ccc9a2c584121938d50 100644 --- a/lib_dec/FEC_HQ_phase_ecu_fx.c +++ b/lib_dec/FEC_HQ_phase_ecu_fx.c @@ -491,23 +491,15 @@ static void trans_ana_fx( tr_dec[k] = 0; move16(); Mpy_32_16_ss( *pGrPowLeft, THRESH_TR_LIN_BY2_FX, &acc, &lsb ); /* To facilitate fixed-point implementation, divide threshold by 2. */ -#ifdef BASOP_NOGLOB - acc = L_or( L_shl_sat( acc, 16 ), L_and( 0xffffL, lsb ) ); /* Equivalent to concatenate acc and lsb, and then down shift by 16 bits. */ -#else - acc = L_or( L_shl( acc, 16 ), L_and( 0xffffL, lsb ) ); /* Equivalent to concatenate acc and lsb, and then down shift by 16 bits. */ -#endif - if ( GT_32( *pGrPowRight, acc ) ) /* gr_pow_right > thres_tr_lin*gr_pow_left */ + acc = L_or( L_shl_sat( acc, 16 ), L_and( 0xffffL, lsb ) ); /* Equivalent to concatenate acc and lsb, and then down shift by 16 bits. */ + if ( GT_32( *pGrPowRight, acc ) ) /* gr_pow_right > thres_tr_lin*gr_pow_left */ { tr_dec[k] = 1; move16(); } Mpy_32_16_ss( *pGrPowRight, THRESH_TR_LIN_BY2_FX, &acc, &lsb ); -#ifdef BASOP_NOGLOB acc = L_or( L_shl_sat( acc, 16 ), L_and( 0xffffL, lsb ) ); /* Equivalent to concatenate acc and lsb, and then down shift by 16 bits. */ -#else - acc = L_or( L_shl( acc, 16 ), L_and( 0xffffL, lsb ) ); /* Equivalent to concatenate acc and lsb, and then down shift by 16 bits. */ -#endif - if ( GT_32( *pGrPowLeft, acc ) ) /* gr_pow_left > thres_tr_lin*gr_pow_right */ + if ( GT_32( *pGrPowLeft, acc ) ) /* gr_pow_left > thres_tr_lin*gr_pow_right */ { tr_dec[k] = 1; move16(); @@ -1274,13 +1266,9 @@ static Word16 imax_fx( /* o: The location, relative to the } /* Although the output of ratio() is in Q14, adding the missing factor of 2 (See above) * in the denominator, the output is now considered to be in Q15. */ - man = ratio( numer, denom, &expo ); /* The mantissa is considered in Q15 */ -#ifdef BASOP_NOGLOB + man = ratio( numer, denom, &expo ); /* The mantissa is considered in Q15 */ posi = shr_o( man, expo, &Overflow ); /* in Q15 (Due to saturation, it is automatically bound inside [-1.0,1.0].) */ -#else - posi = shr( man, expo ); /* in Q15 (Due to saturation, it is automatically bound inside [-1.0,1.0].) */ -#endif - if ( sign < 0 ) /* Restore the sign. */ + if ( sign < 0 ) /* Restore the sign. */ { posi = negate( posi ); } @@ -1602,7 +1590,11 @@ 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. */ { - Copy_Scale_sig_16_32( &xfp[*pPlocs], xfp_32, 3, Q16 ); // Q + 16 +#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 acc = L_deposit_h( *pPlocs ); // Q16 *pPlocsi++ = L_add( acc, L_shl( imax_pos_fx( xfp_32 ) /* Q15 */, 1 ) ); // Q16 move32(); @@ -1613,7 +1605,11 @@ static void ivas_spec_ana_fx( test(); IF( n > 0 && EQ_16( *pPlocs, 1 ) ) /* Also 2nd peak position uses DC which makes jacobsen unsuitable. */ { - Copy_Scale_sig_16_32( &xfp[*pPlocs - 1], xfp_32, 3, Q16 ); // Q + 16 +#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 acc = L_deposit_h( sub( *pPlocs, 1 ) ); // Q16 *pPlocsi++ = L_add( acc, L_shl( imax_pos_fx( xfp_32 ) /* Q15 */, 1 ) ); // Q16 move32(); @@ -1659,7 +1655,11 @@ 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. */ { - Copy_Scale_sig_16_32( &xfp[currPlocs - 1], xfp_32, 3, Q16 ); // Q + 16 +#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 acc = L_deposit_h( sub( currPlocs, 1 ) ); // Q16 *pPlocsi++ = L_add( acc, L_shl( imax_pos_fx( xfp_32 ) /* Q15 */, 1 ) ); // Q16 move32(); @@ -1673,7 +1673,11 @@ static void ivas_spec_ana_fx( * whould point */ IF( n > 0 ) /* fs/2 which makes special case . */ { - Copy_Scale_sig_16_32( &xfp[currPlocs - 2], xfp_32, 3, Q16 ); // Q + 16 +#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 acc = L_deposit_h( sub( currPlocs, 2 ) ); // Q16 *pPlocsi++ = L_add( acc, L_shl( imax_pos_fx( xfp_32 ) /* Q15 */, 1 ) ); // Q16 move32(); @@ -1884,11 +1888,7 @@ static void spec_ana_fx( man = mult_r( man, FEC_HQ_ECU_ROOT2 ); /* FEC_HQ_ECU_ROOT2 is sqrt(2) in Q14 */ expoBy2 = sub( expoBy2, 1 ); } -#ifdef BASOP_NOGLOB *pXfp++ = shr_sat( man, expoBy2 ); -#else - *pXfp++ = shr( man, expoBy2 ); -#endif move16(); /* Denormalize the mantissa back to Q0. */ } } @@ -2786,13 +2786,8 @@ static void subst_spec_fx( IF( EQ_16( element_mode, EVS_MONO ) ) #endif { -#ifdef BASOP_NOGLOB tmp = sub_sat( mult_r( re, cos_F ), mult_r( im, sin_F ) ); im = add_sat( mult_r( re, sin_F ), mult_r( im, cos_F ) ); -#else - tmp = sub( mult_r( re, cos_F ), mult_r( im, sin_F ) ); - im = add( mult_r( re, sin_F ), mult_r( im, cos_F ) ); -#endif } #ifdef IVAS_FEC_ECU_TO_COMPLETE ELSE @@ -3322,11 +3317,7 @@ static Word32 mult_32_32_q( const Word32 a, const Word32 b, const Word16 q ) #endif Mpy_32_32_ss( a, b, &hi, &lo ); -#ifdef BASOP_NOGLOB return L_or( L_shl_o( hi, sub( 32 - 1, q ), &Overflow ), L_lshr( (Word32) lo, add( q, 1 ) ) ); -#else - return L_or( L_shl( hi, 32 - q - 1 ), L_lshr( lo, q + 1 ) ); -#endif } static void fir_dwn_fx( @@ -3360,19 +3351,11 @@ static void fir_dwn_fx( FOR( j = 1; j <= i; j++ ) { -#ifdef BASOP_NOGLOB s = L_mac0_sat( s, *ptr_h++, *ptr_x-- ); // Q(h_Q) + Q(x_q) -#else - s = L_mac0( s, *ptr_h++, *ptr_x-- ); -#endif } -#ifdef BASOP_NOGLOB *ptr_y++ = extract_h( L_shl_sat( s, centering ) ); move16(); -#else - *ptr_y++ = extract_h( L_shl( s, centering ) ); -#endif } FOR( i = K; i < L; i += decimation ) { @@ -3383,19 +3366,11 @@ static void fir_dwn_fx( FOR( j = 1; j <= K; j++ ) { -#ifdef BASOP_NOGLOB s = L_mac0_sat( s, *ptr_h++, *ptr_x-- ); // Q(h_Q) + Q(x_q) -#else - s = L_mac0( s, *ptr_h++, *ptr_x-- ); -#endif } -#ifdef BASOP_NOGLOB *ptr_y++ = extract_h( L_shl_sat( s, centering ) ); move16(); -#else - *ptr_y++ = extract_h( L_shl( s, centering ) ); -#endif } tmp = add( L, Kdiv2 ); FOR( i = i; i < tmp; i += decimation ) @@ -3408,19 +3383,11 @@ static void fir_dwn_fx( FOR( j = i - L + 1; j <= K; j++ ) { -#ifdef BASOP_NOGLOB s = L_mac0_sat( s, *ptr_h++, *ptr_x-- ); -#else - s = L_mac0( s, *ptr_h++, *ptr_x-- ); -#endif } -#ifdef BASOP_NOGLOB *ptr_y++ = extract_h( L_shl_sat( s, centering ) ); move16(); -#else - *ptr_y++ = extract_h( L_shl( s, centering ) ); -#endif } return; @@ -3896,20 +3863,11 @@ static void sin_cos_est_fx( Word32 phi, Word16 *cosfreq, Word16 *sinfreq ) tmp = L_shl( Mult_32_16( delta, cosb ), 1 ); /*Q31 */ sinv = L_add( L_deposit_h( sinb ), tmp ); tmp = L_shl( Mult_32_16( delta, sinb ), 1 ); /*Q31 */ -#ifdef BASOP_NOGLOB cosv = L_sub_sat( L_deposit_h( cosb ), tmp ); -#else - cosv = L_sub( L_deposit_h( cosb ), tmp ); -#endif -#ifdef BASOP_NOGLOB *sinfreq = round_fx_sat( sinv ); move16(); *cosfreq = round_fx_sat( cosv ); move16(); -#else - *sinfreq = round_fx( sinv ); - *cosfreq = round_fx( cosv ); -#endif return; } @@ -3963,11 +3921,7 @@ static Word16 abs_iter_fx( Word16 re /*Qx*/, Word16 im /*Qx*/, Word16 N ) i = s_min( sub( i, 1 ), 9 ); tmp = abs_s( re ); /*A = round_fx(L_shr(L_mult(tmp, cor[i]), exp)); //this can be ommited, if we don't need the exact abs value */ -#ifdef BASOP_NOGLOB A = shr_sat( tmp, exp ); -#else - A = shr( tmp, exp ); -#endif return A; } /*-------------------------------------------------------------------------- @@ -4039,13 +3993,8 @@ static void ivas_fec_ecu_dft_fx( { tmp_short = extract_l( L_shr( Tmp, 15 ) ); tmp = extract_l( L_msu( Tmp, tmp_short, 16384 ) ); -#ifdef BASOP_NOGLOB L_tmp = L_mult( sub_sat( target[tmp_short + 1], target[tmp_short] ), tmp ); /*Qin+16 */ Tfr16[i] = add_sat( target[tmp_short], round_fx_sat( L_tmp ) ); -#else - L_tmp = L_mult( sub( target[tmp_short + 1], target[tmp_short] ), tmp ); /*Qin+16 */ - Tfr16[i] = add( target[tmp_short], round_fx( L_tmp ) ); -#endif move16(); /*Qin */ Tmp = L_add( Tmp, fac ); } @@ -4056,7 +4005,11 @@ static void ivas_fec_ecu_dft_fx( tmp = Exp16Array( *Nfft, Tfr16 ); *exp = add( tmp, add( 2, norm_s( *Nfft ) ) ); move16(); - Copy_Scale_sig_16_32( Tfr16, Tfr32, *Nfft, *exp ); /*Qin+exp; */ +#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 ); @@ -4160,13 +4113,8 @@ static void fec_ecu_dft_fx( { tmp_short = extract_l( L_shr( Tmp, 15 ) ); tmp = extract_l( L_msu( Tmp, tmp_short, 16384 ) ); -#ifdef BASOP_NOGLOB L_tmp = L_mult( sub_sat( target[tmp_short + 1], target[tmp_short] ), tmp ); /*Qin+16 */ Tfr16[i] = add_sat( target[tmp_short], round_fx_sat( L_tmp ) ); -#else - L_tmp = L_mult( sub( target[tmp_short + 1], target[tmp_short] ), tmp ); /*Qin+16 */ - Tfr16[i] = add( target[tmp_short], round_fx( L_tmp ) ); -#endif move16(); /*Qin */ Tmp = L_add( Tmp, fac ); } @@ -4177,7 +4125,20 @@ static void fec_ecu_dft_fx( tmp = Exp16Array( *Nfft, Tfr16 ); *exp = add( tmp, add( 2, norm_s( *Nfft ) ) ); move16(); - Copy_Scale_sig_16_32( Tfr16, Tfr32, *Nfft, *exp ); /*Qin+exp; */ +#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 ); @@ -4235,11 +4196,7 @@ static void singenerator_fx( ptr = xx; -#ifdef BASOP_NOGLOB *ptr = L_add_sat( *ptr, L_C0 ); -#else - *ptr = L_add( *ptr, L_C0 ); -#endif move32(); ptr++; @@ -4250,11 +4207,7 @@ static void singenerator_fx( L_C1 = L_msu( L_C1, S0, sinfreq ); /*Qin+16 */ L_S1 = L_mult( C0, sinfreq ); S1 = mac_r( L_S1, S0, cosfreq ); -#ifdef BASOP_NOGLOB *ptr = L_add_sat( *ptr, L_C1 ); -#else - *ptr = L_add( *ptr, L_C1 ); -#endif move32(); /*Qin+16 */ ptr++; @@ -4263,11 +4216,7 @@ static void singenerator_fx( L_C0 = L_msu( L_C0, S1, sinfreq ); L_S0 = L_mult( C1, sinfreq ); S0 = mac_r( L_S0, S1, cosfreq ); -#ifdef BASOP_NOGLOB *ptr = L_add_sat( *ptr, L_C0 ); -#else - *ptr = L_add( *ptr, L_C0 ); -#endif move32(); ptr++; } @@ -4276,11 +4225,7 @@ static void singenerator_fx( S0 = extract_h( L_S0 ); L_C1 = L_mult( C0, cosfreq ); L_C1 = L_msu( L_C1, S0, sinfreq ); -#ifdef BASOP_NOGLOB *ptr = L_add_sat( *ptr, L_C1 ); -#else - *ptr = L_add( *ptr, L_C1 ); -#endif move32(); ptr++; @@ -4574,11 +4519,7 @@ static void ivas_fec_noise_filling_fx( move16(); FOR( k = 0; k < tmp_fx; k++ ) { -#ifdef BASOP_NOGLOB ( *pt1++ ) = sub_sat( ( *pt2++ ), ( *pt3++ ) ); -#else - ( *pt1++ ) = sub( ( *pt2++ ), ( *pt3++ ) ); -#endif move16(); } @@ -4625,14 +4566,9 @@ static void ivas_fec_noise_filling_fx( tmp_fx = s_min( Rnd_N_noise, flag ); FOR( i = 0; i < tmp_fx; i++ ) { - L_tmp = L_mult( ( *pt1++ ), ( *pt3++ ) ); /*Qsynth+16 */ -#ifdef BASOP_NOGLOB + L_tmp = L_mult( ( *pt1++ ), ( *pt3++ ) ); /*Qsynth+16 */ L_tmp = L_mac_sat( L_tmp, ( *pt2++ ), ( *pt4-- ) ); /*Qsynth+16 */ *pt5 = add_sat( *pt5, round_fx_sat( L_tmp ) ); -#else - L_tmp = L_mac( L_tmp, ( *pt2++ ), ( *pt4-- ) ); /*Qsynth+16 */ - *pt5 = add( *pt5, round_fx( L_tmp ) ); -#endif move16(); /*Qsynth */ pt5++; } @@ -4748,11 +4684,7 @@ static void fec_noise_filling_fx( move16(); FOR( k = 0; k < tmp_fx; k++ ) { -#ifdef BASOP_NOGLOB ( *pt1++ ) = sub_sat( ( *pt2++ ), ( *pt3++ ) ); -#else - ( *pt1++ ) = sub( ( *pt2++ ), ( *pt3++ ) ); -#endif move16(); } @@ -4787,12 +4719,8 @@ static void fec_noise_filling_fx( Rnd_N_noise = extract_h( L_mult( N_noise, tmp_fx ) ); /*Q0 */ - tmp_fx = div_s( 1, Rnd_N_noise ); /*Q15 */ -#ifdef BASOP_NOGLOB + tmp_fx = div_s( 1, Rnd_N_noise ); /*Q15 */ tmp_fx = round_fx_sat( L_shl_sat( L_mult( tmp_fx, 25736 ), 2 ) ); /*Q15 */ -#else - tmp_fx = round_fx( L_shl( L_mult( tmp_fx, 25736 ), 2 ) ); /*Q15 */ -#endif #ifdef IVAS_FEC_ECU_TO_COMPLETE if ( element_mode == EVS_MONO ) { @@ -4815,14 +4743,9 @@ static void fec_noise_filling_fx( tmp_fx = s_min( Rnd_N_noise, flag ); FOR( i = 0; i < tmp_fx; i++ ) { - L_tmp = L_mult( ( *pt1++ ), ( *pt3++ ) ); /*Qsynth+16 */ -#ifdef BASOP_NOGLOB + L_tmp = L_mult( ( *pt1++ ), ( *pt3++ ) ); /*Qsynth+16 */ L_tmp = L_mac_sat( L_tmp, ( *pt2++ ), ( *pt4-- ) ); /*Qsynth+16 */ *pt5 = add_sat( *pt5, round_fx_sat( L_tmp ) ); -#else - L_tmp = L_mac( L_tmp, ( *pt2++ ), ( *pt4-- ) ); /*Qsynth+16 */ - *pt5 = add( *pt5, round_fx( L_tmp ) ); -#endif move16(); /*Qsynth */ pt5++; } @@ -5623,11 +5546,7 @@ static void windowing_ROM_optimized( FOR( i = 0; i < quarterLen; i++ ) { acc = L_deposit_h( FEC_HQ_WIN_A0 ); -#ifdef BASOP_NOGLOB hamm = mac_r_sat( acc, *pSine, FEC_HQ_WIN_A1 ); -#else - hamm = mac_r( acc, *pSine, FEC_HQ_WIN_A1 ); -#endif *pY++ = mult_r( hamm, *pX++ ); move16(); pSine += downSamples; /* Increment address counter */ @@ -5643,13 +5562,9 @@ static void windowing_ROM_optimized( /* 1st half of the right half of the Hamming window. */ FOR( i = 0; i < quarterLen; i++ ) { - pSine -= downSamples; /* Decrement address counter */ - acc = L_deposit_h( FEC_HQ_WIN_A0 ); // Q31 -#ifdef BASOP_NOGLOB + pSine -= downSamples; /* Decrement address counter */ + acc = L_deposit_h( FEC_HQ_WIN_A0 ); // Q31 hamm = mac_r_sat( acc, *pSine, FEC_HQ_WIN_A1 ); // Q15 -#else - hamm = mac_r( acc, *pSine, FEC_HQ_WIN_A1 ); -#endif *pY++ = mult_r( hamm, *pX++ ); move16(); } diff --git a/lib_dec/FEC_clas_estim_fx.c b/lib_dec/FEC_clas_estim_fx.c index 4c268186d8851b3a0f05a69385a6160f8f787bc0..9b58084e36ef1cb0d935be70990bb95aa18d485a 100644 --- a/lib_dec/FEC_clas_estim_fx.c +++ b/lib_dec/FEC_clas_estim_fx.c @@ -285,11 +285,7 @@ void FEC_clas_estim_fx( Corre( &pt1[pos], &pt1[pos - T0], T0, &cor_max[0] ); -#ifdef BASOP_NOGLOB T0 = mult_r_sat( add_sat( pitch[2], pitch[3] ), 256 ); -#else - T0 = mult_r( add( pitch[2], pitch[3] ), 256 ); -#endif pos_limit = sub( L_frame, L_SUBFR ); j = s_min( 1, s_max( 0, sub( pos, pos_limit ) ) ); Ltmp = L_deposit_l( cor_max[0] ); @@ -334,11 +330,7 @@ void FEC_clas_estim_fx( test(); IF( EQ_16( codec_mode, MODE1 ) || !( NE_16( LTP_Gain, -32768 /*-1.f Q15*/ ) && EQ_16( mode, CLASSIFIER_TCX ) ) ) { -#ifdef BASOP_NOGLOB pc = shr( abs_s( sub( add_sat( pitch[3], sub( pitch[2], pitch[1] ) ), pitch[0] ) ), 6 ); -#else - pc = shr( abs_s( sub( add( pitch[3], sub( pitch[2], pitch[1] ) ), pitch[0] ) ), 6 ); -#endif IF( EQ_16( L_frame, L_FRAME16k ) ) { @@ -359,13 +351,8 @@ void FEC_clas_estim_fx( { pt1++; pt2++; -#ifdef BASOP_NOGLOB Ltmp = L_mac0_sat( Ltmp, *pt1, *pt1 ); Ltmp1 = L_mac0_sat( Ltmp1, *pt1, *pt2 ); -#else - Ltmp = L_mac0( Ltmp, *pt1, *pt1 ); - Ltmp1 = L_mac0( Ltmp1, *pt1, *pt2 ); -#endif } tilt = 0; move16(); @@ -383,21 +370,13 @@ void FEC_clas_estim_fx( tmp_x = extract_h( L_shl( Ltmp, exp2 ) ); exp2 = sub( 31 - 1 + 3, exp2 ); BASOP_SATURATE_WARNING_OFF_EVS -#ifdef BASOP_NOGLOB tmpS = shr( sub_sat( tmp_x, tmp_y ), 16 ); /* if tmp_x >= tmp_y tmpS = 0, -1 otherwise */ -#else - tmpS = shr( sub( tmp_x, tmp_y ), 16 ); /* if tmp_x >= tmp_y tmpS = 0, -1 otherwise */ -#endif BASOP_SATURATE_WARNING_ON_EVS tmp_y = shl( tmp_y, tmpS ); exp1 = sub( exp1, tmpS ); tilt = div_s( tmp_y, tmp_x ); -#ifdef BASOP_NOGLOB tilt = shl_sat( tilt, sub( exp1, exp2 ) ); /* saturate to 1.0 */ -#else - tilt = shl( tilt, sub( exp1, exp2 ) ); /* saturate to 1.0 */ -#endif tilt = i_mult2( tilt, tmp16 ); } @@ -420,11 +399,7 @@ void FEC_clas_estim_fx( zcn = extract_h( L_shl( L_mac( C_ZC_FX, K_ZC_FX, zc_frame ), 4 ) ); /* Q4 -> Q8*/ BASOP_SATURATE_WARNING_OFF_EVS -#ifdef BASOP_NOGLOB tmp16 = sub_sat( LTP_Gain, -32768 /*-1.f Q15*/ ); -#else - tmp16 = sub( LTP_Gain, -32768 /*-1.f Q15*/ ); -#endif BASOP_SATURATE_WARNING_ON_EVS test(); test(); @@ -446,11 +421,7 @@ void FEC_clas_estim_fx( Ltmp = L_mac( Ltmp, pcn, UNS6 ); Ltmp = L_mac( Ltmp, enern, UNS6 ); BASOP_SATURATE_WARNING_OFF_EVS -#ifdef BASOP_NOGLOB fmerit1 = round_fx_sat( L_shl_sat( Ltmp, 15 - 8 ) ); /*Q15 can saturate to 1.0 */ -#else - fmerit1 = round_fx( L_shl( Ltmp, 15 - 8 ) ); /*Q15 can saturate to 1.0 */ -#endif BASOP_SATURATE_WARNING_ON_EVS test(); IF( EQ_16( codec_mode, MODE2 ) && narrowBand != 0 ) @@ -938,11 +909,7 @@ static void Corre( /* keep Q15 normalized result */ cor = extract_h( Dot_product12( x, y, l, &cor_exp ) ); -#ifdef BASOP_NOGLOB den = add_sat( extract_h( Dot_product12( y, y, l, &den_exp ) ), 1 ); -#else - den = add( extract_h( Dot_product12( y, y, l, &den_exp ) ), 1 ); -#endif den2 = extract_h( Dot_product12( x, x, l, &den2_exp ) ); /* keep Q31 normalized result */ @@ -953,10 +920,6 @@ static void Corre( tmp = Isqrt_lc( tmp, &tmp_exp ); /* keep Q15 result */ -#ifdef BASOP_NOGLOB gain[0] = shl_sat( mult_r( cor, extract_h( tmp ) ), add( cor_exp, tmp_exp ) ); -#else - gain[0] = shl( mult_r( cor, extract_h( tmp ) ), add( cor_exp, tmp_exp ) ); -#endif move16(); } diff --git a/lib_dec/FEC_fx.c b/lib_dec/FEC_fx.c index c0976e68a0764e9ed958564472fa481fdd8de8ba..35bb254af835011d3ec461752e47c43ee3c7b2f3 100644 --- a/lib_dec/FEC_fx.c +++ b/lib_dec/FEC_fx.c @@ -126,11 +126,7 @@ void FEC_exc_estim_fx( gainCNG = round_fx( L_shl( L_tmp, sub( exp, 12 ) ) ); /* In Q3 */ } -#ifdef BASOP_NOGLOB tmp1 = shl_o( st_fx->lp_gainc_fx, 1, &Overflow ); -#else - tmp1 = shl( st_fx->lp_gainc_fx, 1 ); -#endif gainCNG = s_min( gainCNG, tmp1 ); set16_fx( exc_dct_in, 0, L_FRAME16k ); @@ -191,15 +187,9 @@ void FEC_exc_estim_fx( { test(); test(); -#ifdef BASOP_NOGLOB IF( ( LT_16( round_fx( L_shl( st_fx->old_pitch_buf_fx[2 * NB_SUBFR - 1], 6 ) ), shl_o( mult( 29491, st_fx->bfi_pitch_fx ), 1, &Overflow ) ) && GT_16( round_fx( L_shl( st_fx->old_pitch_buf_fx[2 * NB_SUBFR - 1], 6 ) ), mult( 19661, st_fx->bfi_pitch_fx ) ) ) || /* last pitch coherent with the past */ GE_16( st_fx->upd_cnt, MAX_UPD_CNT ) ) /* or last update too far in the past */ -#else - IF( ( LT_16( round_fx( L_shl( st_fx->old_pitch_buf_fx[2 * NB_SUBFR - 1], 6 ) ), shl( mult( 29491, st_fx->bfi_pitch_fx ), 1 ) ) && - GT_16( round_fx( L_shl( st_fx->old_pitch_buf_fx[2 * NB_SUBFR - 1], 6 ) ), mult( 19661, st_fx->bfi_pitch_fx ) ) ) || /* last pitch coherent with the past */ - GE_16( st_fx->upd_cnt, MAX_UPD_CNT ) ) /* or last update too far in the past */ -#endif { /* take the pitch value of last subframe of the previous frame */ *tmp_tc = round_fx( L_shl( st_fx->old_pitch_buf_fx[2 * NB_SUBFR - 1], 6 ) ); @@ -210,15 +200,9 @@ void FEC_exc_estim_fx( { test(); test(); -#ifdef BASOP_NOGLOB IF( ( LT_16( round_fx( L_shl( st_fx->old_pitch_buf_fx[2 * NB_SUBFR16k - 1], 6 ) ), shl_o( mult( 29491, st_fx->bfi_pitch_fx ), 1, &Overflow ) ) && GT_16( round_fx( L_shl( st_fx->old_pitch_buf_fx[2 * NB_SUBFR16k - 1], 6 ) ), mult( 19661, st_fx->bfi_pitch_fx ) ) ) || /* last pitch coherent with the past */ GE_16( st_fx->upd_cnt, MAX_UPD_CNT ) ) /* or last update too far in the past */ -#else - IF( ( LT_16( round_fx( L_shl( st_fx->old_pitch_buf_fx[2 * NB_SUBFR16k - 1], 6 ) ), shl( mult( 29491, st_fx->bfi_pitch_fx ), 1 ) ) && - GT_16( round_fx( L_shl( st_fx->old_pitch_buf_fx[2 * NB_SUBFR16k - 1], 6 ) ), mult( 19661, st_fx->bfi_pitch_fx ) ) ) || /* last pitch coherent with the past */ - GE_16( st_fx->upd_cnt, MAX_UPD_CNT ) ) /* or last update too far in the past */ -#endif { /* take the pitch value of last subframe of the previous frame */ *tmp_tc = round_fx( L_shl( st_fx->old_pitch_buf_fx[2 * NB_SUBFR16k - 1], 6 ) ); @@ -312,11 +296,7 @@ void FEC_exc_estim_fx( IF( LE_16( st_fx->nbLostCmpt, 1 ) ) { /* if stable, do not decrease the energy, pitch_gain = 0 */ -#ifdef BASOP_NOGLOB alpha = mac_ro( ( 1L << 16 ) * 2 * _ALPHA_U_FX, st_fx->stab_fac_fx, 32768 - 2 * _ALPHA_U_FX, &Overflow ); /*st_fx->stab_fac_fx in Q15*/ -#else - alpha = mac_r( ( 1L << 16 ) * 2 * _ALPHA_U_FX, st_fx->stab_fac_fx, 32768 - 2 * _ALPHA_U_FX ); /*st_fx->stab_fac_fx in Q15*/ -#endif } ELSE IF( EQ_16( st_fx->nbLostCmpt, 2 ) ) { @@ -365,11 +345,7 @@ void FEC_exc_estim_fx( L_tmp = L_deposit_h( tmp ); L_tmp = Isqrt_lc( L_tmp, &exp ); -#ifdef BASOP_NOGLOB gain = extract_h( L_shl_o( L_tmp, exp, &Overflow ) ); -#else - gain = extract_h( L_shl( L_tmp, exp ) ); -#endif gain = s_min( gain, 32113 ); /*0.98 */ gain = s_max( gain, 27853 ); /*0.85 */ @@ -528,7 +504,11 @@ 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(); @@ -658,11 +638,7 @@ void FEC_exc_estim_fx( /* non-causal ringing of the FIR filter */ /**pt_exc++ *= (gain_inov * gain);*/ L_tmp = L_mult( tmp, *pt_exc ); /* Q_exc+18 * Q-3 -> Q_exc+16 */ -#ifdef BASOP_NOGLOB *pt_exc++ = round_fx_sat( L_shl_sat( L_tmp, exp ) ); -#else - *pt_exc++ = round_fx( L_shl( L_tmp, exp ) ); -#endif move16(); } @@ -671,11 +647,7 @@ void FEC_exc_estim_fx( /* the inner part of the FIR filter */ /* *pt_exc++ *= (gain_inov * gain); */ L_tmp = L_mult( tmp, *pt_exc ); -#ifdef BASOP_NOGLOB *pt_exc++ = round_fx_sat( L_shl_sat( L_tmp, exp ) ); -#else - *pt_exc++ = round_fx( L_shl( L_tmp, exp ) ); -#endif move16(); /* gain -= step; */ L_tmp2 = L_sub( L_tmp2, L_step ); @@ -686,11 +658,7 @@ void FEC_exc_estim_fx( { /* *pt_exc++ *= (gain_inov * gain) */ L_tmp = L_mult( tmp, *pt_exc ); -#ifdef BASOP_NOGLOB *pt_exc++ = round_fx_sat( L_shl_sat( L_tmp, exp ) ); -#else - *pt_exc++ = round_fx( L_shl( L_tmp, exp ) ); -#endif move16(); } } @@ -702,7 +670,11 @@ 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 ); @@ -726,17 +698,9 @@ void FEC_exc_estim_fx( L_tmp = L_mult( hp_filt[0], pt_exc[0] ); FOR( j = 1; j < MODE1_L_FIR_FER; j++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_mac_sat( L_tmp, hp_filt[j], pt_exc[j] ); -#else - L_tmp = L_mac( L_tmp, hp_filt[j], pt_exc[j] ); -#endif } -#ifdef BASOP_NOGLOB exc2[i] = msu_r_sat( L_tmp, -32768, exc[i] ); -#else - exc2[i] = msu_r( L_tmp, -32768, exc[i] ); -#endif move16(); pt_exc++; } @@ -812,11 +776,7 @@ static void pulseRes_preCalc( Word16 *cond1, Word16 *cond2, Word32 *cond3, Word1 tmp_frame = sub( 32767 /*1.f Q15*/, tmp_frame ); /*Q15*/ BASOP_SATURATE_WARNING_OFF_EVS /*To calc Q15 threshold, overflow may happen - do negation and compare with negated value to check also highest possible value*/ -#ifdef BASOP_NOGLOB tmp_pit = shl_o( negate( tmp_pit ), tmp_pit_e, &Overflow ); -#else - tmp_pit = shl( negate( tmp_pit ), tmp_pit_e ); -#endif BASOP_SATURATE_WARNING_ON_EVS *cond1 = sub( tmp_pit, negate( tmp_frame ) ); move16(); @@ -829,11 +789,7 @@ static void pulseRes_preCalc( Word16 *cond1, Word16 *cond2, Word32 *cond3, Word1 tmp_pit2 = L_mult( Tc, 4915 /*0.15f Q15*/ ); /*Q16*/ BASOP_SATURATE_WARNING_OFF_EVS /*To calc Q15 threshold, overflow may happen - do negation and compare with negated value to check also highest possible value*/ -#ifdef BASOP_NOGLOB tmp_pit2 = L_shl_sat( L_negate( tmp_pit2 ), sub( 15 - 16, tmp_pit_e ) ); -#else - tmp_pit2 = L_shl( L_negate( tmp_pit2 ), sub( 15 - 16, tmp_pit_e ) ); -#endif BASOP_SATURATE_WARNING_ON_EVS *cond3 = L_sub( L_mult0( -1, tmp_pit ), tmp_pit2 ); move32(); diff --git a/lib_dec/FEC_pitch_estim_fx.c b/lib_dec/FEC_pitch_estim_fx.c index 45304a94cebb2fae2cf31d7140947e525b4d0f1f..b7ad94f8931293ef25288170d9be242c4e0fabc8 100644 --- a/lib_dec/FEC_pitch_estim_fx.c +++ b/lib_dec/FEC_pitch_estim_fx.c @@ -59,11 +59,7 @@ void FEC_pitch_estim_fx( tmp3 = shl_sat( tmp2, 1 ); /*Q6 (1.4f * old_pitch_buf[2*NB_SUBFR-1])*/ tmp16k1 = round_fx( L_shl( Mpy_32_16_1( old_pitch_buf[2 * NB_SUBFR16k - 1], 22938 ), 6 ) ); /*Q6 0.7f * old_pitch_buf[2*NB_SUBFR16k-1]*/ -#ifdef BASOP_NOGLOB - tmp16k2 = shl_sat( tmp16k1, 1 ); /*Q6 1.4f * old_pitch_buf[2*NB_SUBFR16k-1]*/ -#else - tmp16k2 = shl( tmp16k1, 1 ); /*Q6 1.4f * old_pitch_buf[2*NB_SUBFR16k-1]*/ -#endif + tmp16k2 = shl_sat( tmp16k1, 1 ); /*Q6 1.4f * old_pitch_buf[2*NB_SUBFR16k-1]*/ test(); test(); diff --git a/lib_dec/FEC_scale_syn_fx.c b/lib_dec/FEC_scale_syn_fx.c index f8f3d834688235c542a60f170d5df435a4672f13..d664aa9fbb2ea39a35ea23477c0ec2e3517e40c9 100644 --- a/lib_dec/FEC_scale_syn_fx.c +++ b/lib_dec/FEC_scale_syn_fx.c @@ -188,11 +188,7 @@ void FEC_scale_syn_fx( { /* gain2 = (float)sqrt( enr_old / enr2 );*/ L_tmp = Sqrt_Ratio32( L_enr_old, 0, L_enr2, 0, &exp2 ); -#ifdef BASOP_NOGLOB gain2 = round_fx_sat( L_shl_sat( L_tmp, sub( exp2, 1 ) ) ); /* in Q14 */ -#else - gain2 = round_fx( L_shl( L_tmp, sub( exp2, 1 ) ) ); /* in Q14 */ -#endif /*if( gain2 > 1.0f )gain2 = 1.0f;*/ gain2 = s_min( gain2, 16384 ); @@ -205,11 +201,7 @@ void FEC_scale_syn_fx( /*gain1 = (float)sqrt( enr_old / enr1 );*/ L_tmp = Sqrt_Ratio32( L_enr_old, 0, L_enr1, 0, &exp2 ); -#ifdef BASOP_NOGLOB gain1 = round_fx_sat( L_shl_sat( L_tmp, sub( exp2, 1 ) ) ); /* in Q14 */ -#else - gain1 = round_fx( L_shl( L_tmp, sub( exp2, 1 ) ) ); /* in Q14 */ -#endif /*if( gain1 > 1.0f )gain1 = 1.0f;*/ gain1 = s_min( gain1, 16384 ); /*Q14*/ @@ -229,11 +221,7 @@ void FEC_scale_syn_fx( /*rr0 = dotp( h1, h1, L_FRAME/2-1 ) + 0.1f;*/ /*rr1 = dotp( h1, h1+1, L_FRAME/2-1 );*/ /*tilt = rr1 / rr0;*/ -#ifdef BASOP_NOGLOB tilt = extract_h( L_shl_sat( get_gain( h1 + 1, h1, L_FRAME / 2 - 1 ), 15 ) ); /*Q15*/ -#else - tilt = extract_h( L_shl( get_gain( h1 + 1, h1, L_FRAME / 2 - 1 ), 15 ) ); -#endif pitch_dist = 0; move16(); L_mean_pitch = L_mult( pitch[0], 8192 /*1.0f in Q13*/ ); /*Q14*/ @@ -259,11 +247,7 @@ void FEC_scale_syn_fx( ( ( prev_bfi ) || ( ( EQ_16( coder_type, GENERIC ) ) && ( EQ_16( LSF_Q_prediction, AUTO_REGRESSIVE ) ) ) ) ) { /*if( enr_q > scaling * enr_old ){enr_q = scaling * enr_old;}*/ -#ifdef BASOP_NOGLOB L_enr_q = L_min( L_enr_q, L_shl_sat( Mult_32_16( L_enr_old, scaling ), 1 ) ); /* scaling in Q14*/ -#else - L_enr_q = L_min( L_enr_q, L_shl( Mult_32_16( L_enr_old, scaling ), 1 ) ); /* scaling in Q14*/ -#endif } ELSE { @@ -279,11 +263,7 @@ void FEC_scale_syn_fx( ener_max = L_max( ener_max, L_enr_old ); /*if( enr_q > scaling * ener_max ){enr_q = scaling * ener_max;}*/ -#ifdef BASOP_NOGLOB L_enr_q = L_min( L_enr_q, L_shl_sat( Mult_32_16( ener_max, scaling ), 1 ) ); /* scaling in Q14*/ -#else - L_enr_q = L_min( L_enr_q, L_shl( Mult_32_16( ener_max, scaling ), 1 ) ); /* scaling in Q14*/ -#endif } } /*gain2 = (float)sqrt( enr_q / enr2 );*/ @@ -320,11 +300,7 @@ void FEC_scale_syn_fx( /*gain1 = (float)sqrt( enr_old / enr1 );*/ L_tmp = Sqrt_Ratio32( L_enr_old, 0, L_enr1, 0, &exp2 ); -#ifdef BASOP_NOGLOB gain1 = round_fx_sat( L_shl_sat( L_tmp, sub( exp2, 1 ) ) ); /* in Q14 */ -#else - gain1 = round_fx( L_shl( L_tmp, sub( exp2, 1 ) ) ); /* in Q14 */ -#endif /*if( gain1 > 1.2f )gain1 = 1.2f;*/ /* prevent clipping */ @@ -358,11 +334,7 @@ void FEC_scale_syn_fx( exc[i] = mac_r( L_mult( exc[i], gain1 ), exc[i], gain1 ); move16(); /*exc2[i] *= gain1;*/ -#ifdef BASOP_NOGLOB exc2[i] = mac_r_sat( L_mult( exc2[i], gain1 ), exc2[i], gain1 ); -#else - exc2[i] = mac_r( L_mult( exc2[i], gain1 ), exc2[i], gain1 ); -#endif move16(); } /* smoothing is done in excitation domain, so redo synthesis */ @@ -390,11 +362,7 @@ void FEC_scale_syn_fx( /*rr0 = dotp( h1, h1, L_FRAME/2-1 ) + 0.1f;*/ /*rr1 = dotp( h1, h1+1, L_FRAME/2-1 );*/ /*tilt = rr1 / rr0;*/ -#ifdef BASOP_NOGLOB tilt = extract_h( L_shl_sat( get_gain( h1 + 1, h1, L_FRAME / 2 - 1 ), 15 ) ); /*Q15*/ -#else - tilt = extract_h( L_shl( get_gain( h1 + 1, h1, L_FRAME / 2 - 1 ), 15 ) ); -#endif test(); test(); test(); @@ -409,21 +377,13 @@ void FEC_scale_syn_fx( ( ( ( clas == UNVOICED_CLAS ) ) || ( EQ_16( clas, INACTIVE_CLAS ) ) ) ) ) /* unvoiced classification */ { /*if( enr_q > scaling * enr_old )enr_q = scaling * enr_old;*/ -#ifdef BASOP_NOGLOB L_enr_q = L_min( L_enr_q, L_shl_sat( Mult_32_16( L_enr_old, scaling ), 1 ) ); /* scaling in Q14*/ -#else - L_enr_q = L_min( L_enr_q, L_shl( Mult_32_16( L_enr_old, scaling ), 1 ) ); /* scaling in Q14*/ -#endif } ELSE IF( GE_16( last_good, VOICED_TRANSITION ) && LT_16( last_good, INACTIVE_CLAS ) && GE_16( clas, VOICED_TRANSITION ) && LT_16( clas, INACTIVE_CLAS ) ) { /* Voiced-voiced recovery */ test(); -#ifdef BASOP_NOGLOB IF( *old_enr_LP != 0 && GT_16( enr_LP, shl_sat( *old_enr_LP, 1 ) ) ) -#else - IF( *old_enr_LP != 0 && GT_16( enr_LP, shl( *old_enr_LP, 1 ) ) ) -#endif { /* enr_q /= enr_LP */ exp = norm_l( L_enr_q ); @@ -508,11 +468,7 @@ void FEC_scale_syn_fx( L_tmp = L_deposit_h( tmp ); L_tmp = Isqrt_lc( L_tmp, &exp2 ); -#ifdef BASOP_NOGLOB gain2 = round_fx_sat( L_shl_sat( L_tmp, sub( exp2, 1 ) ) ); /* in Q14 */ -#else - gain2 = round_fx( L_shl( L_tmp, sub( exp2, 1 ) ) ); /* in Q14 */ -#endif /*-----------------------------------------------------------------* * Clipping of the smoothing gain at the frame end *-----------------------------------------------------------------*/ @@ -573,11 +529,7 @@ void FEC_scale_syn_fx( L_tmp = L_deposit_h( tmp ); L_tmp = Isqrt_lc( L_tmp, &exp2 ); -#ifdef BASOP_NOGLOB gain1 = round_fx_sat( L_shl_sat( L_tmp, sub( exp2, 1 ) ) ); /* in Q14 */ -#else - gain1 = round_fx( L_shl( L_tmp, sub( exp2, 1 ) ) ); /* in Q14 */ -#endif /* exp2 is always <= 1 */ gain1 = s_min( gain1, 19661 /*1.2F in Q14*/ ); @@ -609,15 +561,9 @@ void FEC_scale_syn_fx( FOR( i = 0; i < L_frame; i++ ) { gain1 = mac_r( L_tmp, gain1, AGC_FX ); /* in Q14 */ -#ifdef BASOP_NOGLOB exc[i] = mac_r_sat( L_mult_sat( exc[i], gain1 ), exc[i], gain1 ); move16(); exc2[i] = mac_r_sat( L_mult_sat( exc2[i], gain1 ), exc2[i], gain1 ); -#else - exc[i] = mac_r( L_mult( exc[i], gain1 ), exc[i], gain1 ); - move16(); - exc2[i] = mac_r( L_mult( exc2[i], gain1 ), exc2[i], gain1 ); -#endif move16(); } @@ -815,11 +761,7 @@ void FEC_scale_syn_ivas_fx( { /* gain2 = (float)sqrt( enr_old / enr2 );*/ L_tmp = Sqrt_Ratio32( L_enr_old, 0, L_enr2, 0, &exp2 ); -#ifdef BASOP_NOGLOB gain2 = round_fx_sat( L_shl_sat( L_tmp, sub( exp2, 1 ) ) ); /* in Q14 */ -#else - gain2 = round_fx( L_shl( L_tmp, sub( exp2, 1 ) ) ); /* in Q14 */ -#endif /*if( gain2 > 1.0f )gain2 = 1.0f;*/ gain2 = s_min( gain2, 16384 /*1.0f in Q14*/ ); /*Q14*/ @@ -832,11 +774,7 @@ void FEC_scale_syn_ivas_fx( /*gain1 = (float)sqrt( enr_old / enr1 );*/ L_tmp = Sqrt_Ratio32( L_enr_old, 0, L_enr1, 0, &exp2 ); -#ifdef BASOP_NOGLOB gain1 = round_fx_sat( L_shl_sat( L_tmp, sub( exp2, 1 ) ) ); /* in Q14 */ -#else - gain1 = round_fx( L_shl( L_tmp, sub( exp2, 1 ) ) ); /* in Q14 */ -#endif /*if( gain1 > 1.0f )gain1 = 1.0f;*/ gain1 = s_min( gain1, 16384 /*1.0f in Q14*/ ); /*Q14*/ @@ -856,11 +794,7 @@ void FEC_scale_syn_ivas_fx( /*rr0 = dotp( h1, h1, L_FRAME/2-1 ) + 0.1f;*/ /*rr1 = dotp( h1, h1+1, L_FRAME/2-1 );*/ /*tilt = rr1 / rr0;*/ -#ifdef BASOP_NOGLOB tilt = extract_h( L_shl_sat( get_gain( h1 + 1, h1, L_FRAME / 2 - 1 ), 15 ) ); /*Q15*/ -#else - tilt = extract_h( L_shl( get_gain( h1 + 1, h1, L_FRAME / 2 - 1 ), 15 ) ); -#endif pitch_dist = 0; move16(); L_mean_pitch = L_mult( pitch[0], 8192 ); /*Q14*/ @@ -886,11 +820,7 @@ void FEC_scale_syn_ivas_fx( ( ( prev_bfi ) || ( ( EQ_16( coder_type, GENERIC ) ) && ( EQ_16( LSF_Q_prediction, AUTO_REGRESSIVE ) ) ) ) ) { /*if( enr_q > scaling * enr_old ){enr_q = scaling * enr_old;}*/ -#ifdef BASOP_NOGLOB L_enr_q = L_min( L_enr_q, L_shl_sat( Mult_32_16( L_enr_old, scaling ), 1 ) ); /* scaling in Q14*/ -#else - L_enr_q = L_min( L_enr_q, L_shl( Mult_32_16( L_enr_old, scaling ), 1 ) ); /* scaling in Q14*/ -#endif } ELSE { @@ -906,11 +836,7 @@ void FEC_scale_syn_ivas_fx( ener_max = L_max( ener_max, L_enr_old ); /*if( enr_q > scaling * ener_max ){enr_q = scaling * ener_max;}*/ -#ifdef BASOP_NOGLOB L_enr_q = L_min( L_enr_q, L_shl_sat( Mult_32_16( ener_max, scaling ), 1 ) ); /* scaling in Q14*/ -#else - L_enr_q = L_min( L_enr_q, L_shl( Mult_32_16( ener_max, scaling ), 1 ) ); /* scaling in Q14*/ -#endif } } /*gain2 = (float)sqrt( enr_q / enr2 );*/ @@ -947,11 +873,7 @@ void FEC_scale_syn_ivas_fx( /*gain1 = (float)sqrt( enr_old / enr1 );*/ L_tmp = Sqrt_Ratio32( L_enr_old, 0, L_enr1, 0, &exp2 ); -#ifdef BASOP_NOGLOB gain1 = round_fx_sat( L_shl_sat( L_tmp, sub( exp2, 1 ) ) ); /* in Q14 */ -#else - gain1 = round_fx( L_shl( L_tmp, sub( exp2, 1 ) ) ); /* in Q14 */ -#endif /*if( gain1 > 1.2f )gain1 = 1.2f;*/ /* prevent clipping */ @@ -985,11 +907,7 @@ void FEC_scale_syn_ivas_fx( exc[i] = mac_r( L_mult( exc[i], gain1 ), exc[i], gain1 ); move16(); /*exc2[i] *= gain1;*/ -#ifdef BASOP_NOGLOB exc2[i] = mac_r_sat( L_mult( exc2[i], gain1 ), exc2[i], gain1 ); -#else - exc2[i] = mac_r( L_mult( exc2[i], gain1 ), exc2[i], gain1 ); -#endif move16(); } /* smoothing is done in excitation domain, so redo synthesis */ @@ -1017,11 +935,7 @@ void FEC_scale_syn_ivas_fx( /*rr0 = dotp( h1, h1, L_FRAME/2-1 ) + 0.1f;*/ /*rr1 = dotp( h1, h1+1, L_FRAME/2-1 );*/ /*tilt = rr1 / rr0;*/ -#ifdef BASOP_NOGLOB tilt = extract_h( L_shl_sat( get_gain( h1 + 1, h1, L_FRAME / 2 - 1 ), 15 ) ); /*Q15*/ -#else - tilt = extract_h( L_shl( get_gain( h1 + 1, h1, L_FRAME / 2 - 1 ), 15 ) ); -#endif test(); test(); test(); @@ -1036,21 +950,13 @@ void FEC_scale_syn_ivas_fx( ( ( ( clas == UNVOICED_CLAS ) ) || ( EQ_16( clas, INACTIVE_CLAS ) ) ) ) ) /* unvoiced classification */ { /*if( enr_q > scaling * enr_old )enr_q = scaling * enr_old;*/ -#ifdef BASOP_NOGLOB L_enr_q = L_min( L_enr_q, L_shl_sat( Mult_32_16( L_enr_old, scaling ), 1 ) ); /* scaling in Q14*/ -#else - L_enr_q = L_min( L_enr_q, L_shl( Mult_32_16( L_enr_old, scaling ), 1 ) ); /* scaling in Q14*/ -#endif } ELSE IF( GE_16( last_good, VOICED_TRANSITION ) && LT_16( last_good, INACTIVE_CLAS ) && GE_16( clas, VOICED_TRANSITION ) && LT_16( clas, INACTIVE_CLAS ) ) { /* Voiced-voiced recovery */ test(); -#ifdef BASOP_NOGLOB IF( *old_enr_LP != 0 && GT_16( enr_LP, shl_sat( *old_enr_LP, 1 ) ) ) -#else - IF( *old_enr_LP != 0 && GT_16( enr_LP, shl( *old_enr_LP, 1 ) ) ) -#endif { /* enr_q /= enr_LP */ exp = norm_l( L_enr_q ); @@ -1135,11 +1041,7 @@ void FEC_scale_syn_ivas_fx( L_tmp = L_deposit_h( tmp ); L_tmp = Isqrt_lc( L_tmp, &exp2 ); -#ifdef BASOP_NOGLOB gain2 = round_fx_sat( L_shl_sat( L_tmp, sub( exp2, 1 ) ) ); /* in Q14 */ -#else - gain2 = round_fx( L_shl( L_tmp, sub( exp2, 1 ) ) ); /* in Q14 */ -#endif /*-----------------------------------------------------------------* * Clipping of the smoothing gain at the frame end *-----------------------------------------------------------------*/ @@ -1200,11 +1102,7 @@ void FEC_scale_syn_ivas_fx( L_tmp = L_deposit_h( tmp ); L_tmp = Isqrt_lc( L_tmp, &exp2 ); -#ifdef BASOP_NOGLOB gain1 = round_fx_sat( L_shl_sat( L_tmp, sub( exp2, 1 ) ) ); /* in Q14 */ -#else - gain1 = round_fx( L_shl( L_tmp, sub( exp2, 1 ) ) ); /* in Q14 */ -#endif /* exp2 is always <= 1 */ gain1 = s_min( gain1, 19661 /*1.2f in Q14*/ ); /*Q14*/ @@ -1236,15 +1134,9 @@ void FEC_scale_syn_ivas_fx( FOR( i = 0; i < L_frame; i++ ) { gain1 = mac_r( L_tmp, gain1, AGC_FX ); /* in Q14 */ -#ifdef BASOP_NOGLOB exc[i] = mac_r_sat( L_mult_sat( exc[i], gain1 ), exc[i], gain1 ); move16(); exc2[i] = mac_r_sat( L_mult_sat( exc2[i], gain1 ), exc2[i], gain1 ); -#else - exc[i] = mac_r( L_mult( exc[i], gain1 ), exc[i], gain1 ); - move16(); - exc2[i] = mac_r( L_mult( exc2[i], gain1 ), exc2[i], gain1 ); -#endif move16(); } diff --git a/lib_dec/LD_music_post_filter_fx.c b/lib_dec/LD_music_post_filter_fx.c index 04252087049f01e5d53724775d022d625c1d856c..5b48ab47225f7355d8f46111c86dd939b2fc7461 100644 --- a/lib_dec/LD_music_post_filter_fx.c +++ b/lib_dec/LD_music_post_filter_fx.c @@ -186,11 +186,7 @@ void LD_music_post_filter_fx( FOR( k = j; k < mfreq_bindiv_LD[i] + j; k++ ) { /*m_ave += lf_E[k];*/ -#ifdef BASOP_NOGLOB Ltmp = L_add_o( lf_E[k], Ltmp, &Overflow ); /*2*Qdct+10*/ -#else - Ltmp = L_add( lf_E[k], Ltmp ); -#endif max_val = L_max( max_val, lf_E[k] ); } Ltmp_max = L_max( Ltmp_max, max_val ); /*2*Qdct+10*/ @@ -364,27 +360,19 @@ void LD_music_post_filter_fx( FOR( ; i < BIN_2KHZ; i++ ) { - tmp16 = s_min( max_ovf_2k, hMusicPF->filt_lfE_fx[i] ); /*Q12*/ - tmp16 = s_max( min_g_2k, tmp16 ); /*Q12*/ - /*DCT_buf[i] *= ftmp;*/ -#ifdef BASOP_NOGLOB + tmp16 = s_min( max_ovf_2k, hMusicPF->filt_lfE_fx[i] ); /*Q12*/ + tmp16 = s_max( min_g_2k, tmp16 ); /*Q12*/ + /*DCT_buf[i] *= ftmp;*/ dtc_out[i] = round_fx_sat( L_shl_sat( L_mult( dtc_out[i], tmp16 ), 3 ) ); /*Q15*/ -#else - dtc_out[i] = round_fx( L_shl( L_mult( dtc_out[i], tmp16 ), 3 ) ); -#endif move16(); } FOR( ; i < BIN_4KHZ; i++ ) { - tmp16 = s_min( max_ovf_4k, hMusicPF->filt_lfE_fx[i] ); /*Q12*/ - tmp16 = s_max( min_g_4k, tmp16 ); /*Q12*/ - /*DCT_buf[i] *= ftmp;*/ -#ifdef BASOP_NOGLOB + tmp16 = s_min( max_ovf_4k, hMusicPF->filt_lfE_fx[i] ); /*Q12*/ + tmp16 = s_max( min_g_4k, tmp16 ); /*Q12*/ + /*DCT_buf[i] *= ftmp;*/ dtc_out[i] = round_fx_sat( L_shl_sat( L_mult_sat( dtc_out[i], tmp16 ), 3 ) ); /*Q15*/ -#else - dtc_out[i] = round_fx( L_shl( L_mult( dtc_out[i], tmp16 ), 3 ) ); -#endif move16(); } @@ -394,14 +382,10 @@ void LD_music_post_filter_fx( /* Do not modify HF when coded with GSC at LR, because the spectrum is just noise */ FOR( ; i < DCT_L_POST; i++ ) { - tmp16 = s_min( max_ovf_6k, hMusicPF->filt_lfE_fx[i] ); /*Q12*/ - tmp16 = s_max( min_g_6k, tmp16 ); /*Q12*/ - /*DCT_buf[i] *= ftmp;*/ -#ifdef BASOP_NOGLOB + tmp16 = s_min( max_ovf_6k, hMusicPF->filt_lfE_fx[i] ); /*Q12*/ + tmp16 = s_max( min_g_6k, tmp16 ); /*Q12*/ + /*DCT_buf[i] *= ftmp;*/ dtc_out[i] = round_fx_sat( L_shl_sat( L_mult_sat( dtc_out[i], tmp16 ), 3 ) ); /*Q15*/ -#else - dtc_out[i] = round_fx( L_shl( L_mult( dtc_out[i], tmp16 ), 3 ) ); -#endif move16(); } } @@ -411,13 +395,9 @@ void LD_music_post_filter_fx( /* When unsure on content type only slight clean-up allowed, no overshoot allowed */ FOR( ; i < DCT_L_POST; i++ ) { - tmp16 = s_min( 4096 /*1.0f in Q12*/, hMusicPF->filt_lfE_fx[i] ); /*Q12*/ - /*DCT_buf[i] *= ftmp;*/ -#ifdef BASOP_NOGLOB + tmp16 = s_min( 4096 /*1.0f in Q12*/, hMusicPF->filt_lfE_fx[i] ); /*Q12*/ + /*DCT_buf[i] *= ftmp;*/ dtc_out[i] = round_fx_sat( L_shl_sat( L_mult_sat( dtc_out[i], tmp16 ), 3 ) ); /*Q15*/ -#else - dtc_out[i] = round_fx( L_shl( L_mult( dtc_out[i], tmp16 ), 3 ) ); -#endif move16(); } } @@ -543,11 +523,7 @@ static void spectrum_mod_dct_fx( IF( music_flag != 0 ) /* prevent subtraction on clean speech */ { -#ifdef BASOP_NOGLOB IF( LE_32( maxNoise, L_shl_o( 10, scaling, &Overflow ) ) ) -#else - IF( LE_32( maxNoise, L_shl( 10, scaling ) ) ) -#endif { minE = 18432 / 2; /*Q14*/ move16(); @@ -623,21 +599,12 @@ static void spectrum_mod_dct_fx( Ltmp = L_mult( tmpN, m_binE ); /*2*Qdct+e_binE+9*/ e_binE = sub( add( e_tmp, e_binE ), 15 ); -#ifdef BASOP_NOGLOB Ltmp = L_shr_o( Ltmp, e_binE, &Overflow ); /*2*Qdct+9*/ Lgain = L_add_o( Ltmp, Lshift, &Overflow ); /*Saturation can occure here result in Q30*/ -#else - Ltmp = L_shr( Ltmp, e_binE ); - Lgain = L_add( Ltmp, Lshift ); /*Saturation can occure here result in Q30*/ -#endif } Lpt2++; -#ifdef BASOP_NOGLOB gain = round_fx_o( Lgain, &Overflow ); /*gain in Q30-16 = Q14*/ -#else - gain = round_fx( Lgain ); /*gain in Q30-16 = Q14*/ -#endif /*if (gain < minE)gain = minE;*/ gain = s_max( gain, minE ); /*Q14*/ /*if (gain > 1.0f+MAX_GN)gain = 1.0f+MAX_GN;*/ @@ -661,14 +628,10 @@ static void spectrum_mod_dct_fx( alpha = shl( sub( 16384 /*Q14*/, sqrt_gain ), 1 ); /*Q15*/ /**pt_gbin = gain + alpha * *pt_gbin;*/ - Ltmp = L_mult( gain, 32767 /*Q15*/ ); /*Q30*/ - *pt_gbin = round_fx( L_mac( Ltmp, alpha, *pt_gbin ) ); /*Q14*/ - /**pt++ *= *pt_gbin;*/ -#ifdef BASOP_NOGLOB + Ltmp = L_mult( gain, 32767 /*Q15*/ ); /*Q30*/ + *pt_gbin = round_fx( L_mac( Ltmp, alpha, *pt_gbin ) ); /*Q14*/ + /**pt++ *= *pt_gbin;*/ *pt = round_fx_sat( L_shl_sat( L_mult( *pt, *pt_gbin ), 1 ) ); /*Qdct*/ -#else - *pt = round_fx( L_shl( L_mult( *pt, *pt_gbin ), 1 ) ); -#endif move16(); move16(); pt++; @@ -774,11 +737,7 @@ static void find_enr_dct_fx( { /* energy */ /**ptE = *ptR * *ptR; */ -#ifdef BASOP_NOGLOB Ltmp = L_mult_sat( *ptR, *ptR ); /*2*Qdct+1*/ -#else - Ltmp = L_mult( *ptR, *ptR ); -#endif /* normalization */ /**ptE *= 1.0f / (DCT_L_POST);*/ Ltmp = Mult_32_16( Ltmp, 26214 ); /*26214 = 1.0/640 ->Q15+9 --> 2*Q_dct + 10*/ @@ -787,11 +746,7 @@ static void find_enr_dct_fx( move32(); /*band[i] += *ptE++;*/ -#ifdef BASOP_NOGLOB Ltmp1 = L_add_sat( Ltmp, Ltmp1 ); /*2*Q_dct + 10*/ -#else - Ltmp1 = L_add( Ltmp, Ltmp1 ); -#endif ptE++; ptR++; @@ -812,11 +767,7 @@ static void find_enr_dct_fx( FOR( i = min_band; i <= NB_LIMIT_BAND; i++ ) { /* total channel energy */ -#ifdef BASOP_NOGLOB Ltmp = L_add_sat( band[i], Ltmp ); /* 2*Q_dct + 10*/ -#else - Ltmp = L_add( band[i], Ltmp ); -#endif } *Etot = Ltmp; /* 2*Q_dct + 10*/ @@ -965,11 +916,7 @@ static Word16 norm_lfe( exp3 = sub( exp2, 12 + 16 - 3 ); /* if exp2 < 31, means that tmp >= 1.0 */ /* Need to shl by 3 to take into account the 3 multiplications */ } -#ifdef BASOP_NOGLOB tmp16 = shl_o( tmp16, exp3, &Overflow ); /* Result in Q12 */ -#else - tmp16 = shl( tmp16, exp3 ); /* Result in Q12 */ -#endif return tmp16; } diff --git a/lib_dec/TonalComponentDetection_fx.c b/lib_dec/TonalComponentDetection_fx.c index b555eff8e7ae98691f576fd38dc9927c192562e8..ca7bec1408a10c55203b4a1990f6a7cc95bb71c8 100644 --- a/lib_dec/TonalComponentDetection_fx.c +++ b/lib_dec/TonalComponentDetection_fx.c @@ -20,12 +20,15 @@ static void calcPseudoSpec( const Word32 *mdctSpec, const Word16 mdctSpec_exp, const Word16 nSamples, Word16 floorPowerSpectrum, Word32 *powerSpec, Word16 *powerSpec_exp ); static void getEnvelope( const Word16 nSamples, const Word32 *powerSpec, Word16 F0, Word32 *envelope, Word32 *smoothedSpectrum ); static void GetF0( Word16 const nSamples, Word16 const nSamplesCore, Word32 const *const powerSpectrum, Word32 const pitchLag, Word16 *const pOrigF0, Word16 *const pF0 ); +static void ivas_GetF0_fx( Word16 const nSamples, Word16 const nSamplesCore, Word32 const *const powerSpectrum, Word32 const pitchLag, Word16 *const pOrigF0, Word16 *const pF0 ); static void findStrongestHarmonics( const Word16 nSamples, const Word32 *powerSpectrum, const Word16 F0, const Word16 nTotalHarmonics, Word16 *pHarmonicIndexes, Word16 *pnHarmonics ); static void CorrectF0( const Word16 *pHarmonicIndexes, const Word16 nHarmonics, Word16 *pF0 ); +static void ivas_CorrectF0_fx( const Word16 *pHarmonicIndexes, const Word16 nHarmonics, Word16 *pF0 ); static void findCandidates( const Word16 nSamples, const Word32 *MDCTSpectrum, const Word16 MDCTSpectrum_exp, Word16 *thresholdModificationNew, Word16 floorPowerSpectrum ); static void modifyThreshold( Word16 i, Word16 F0, Word16 threshold, Word16 *thresholdModification ); static void modifyThresholds( Word16 F0, Word16 origF0, Word16 *thresholdModification ); static void RefineThresholdsUsingPitch( const Word16 nSamples, const Word16 nSamplesCore, const Word32 powerSpectrum[], const Word32 lastPitchLag, const Word32 currentPitchLag, Word16 *pF0, Word16 *thresholdModification ); +static void ivas_RefineThresholdsUsingPitch_fx( const Word16 nSamples, const Word16 nSamplesCore, const Word32 powerSpectrum[], const Word32 lastPitchLag, const Word32 currentPitchLag, Word16 *pF0, Word16 *thresholdModification ); static void findTonalComponents( Word16 *indexOfTonalPeak, Word16 *lowerIndex, Word16 *upperIndex, Word16 *numIndexes, Word16 nSamples, const Word32 *powerSpectrum, Word16 F0, Word16 *thresholdModification, Word16 element_mode ); /*-------------------------------------------------------------------* @@ -121,7 +124,7 @@ void ivas_DetectTonalComponents_fx( findCandidates( nSamples, pScaledMdctSpectrum, lastMDCTSpect_exp, thresholdModification, floorPowerSpectrum ); /* Refine peak candidates using the pitch information */ - RefineThresholdsUsingPitch( nSamples, nSamplesCore, secondLastPowerSpectrum, lastPitchLag, currentPitchLag, &F0, thresholdModification ); + ivas_RefineThresholdsUsingPitch_fx( nSamples, nSamplesCore, secondLastPowerSpectrum, lastPitchLag, currentPitchLag, &F0, thresholdModification ); /* Find peaks in the second last frame */ findTonalComponents( indexOfTonalPeak, lowerIndex, upperIndex, pNumIndexes, nSamples, secondLastPowerSpectrum, F0, thresholdModification, element_mode ); @@ -491,11 +494,7 @@ static void getEnvelope( /* No need for PTR_INIT for powerSpec[i+n2] as we continue from the previous loop */ FOR( i = 0; i < n1; i++ ) { -#ifdef BASOP_NOGLOB - sum = L_add_sat( sum, powerSpec[i + n2] ); /*powerSpec_exp*/ -#else - sum = L_add( sum, powerSpec[i + n2] ); -#endif + sum = L_add_sat( sum, powerSpec[i + n2] ); /*powerSpec_exp*/ tmp = Mpy_32_16_1( sum /*Q31,powerSpec_exp*/, level /*Q12*/ ); /*Q28,powerSpec_exp*/ envelope[i] /*Q28,powerSpec_exp*/ = Mpy_32_16_1( tmp /*Q28,powerSpec_exp*/, InvIntTable[i + nSecondHalfFilterLength] /*Q15*/ ); move32(); @@ -504,12 +503,8 @@ static void getEnvelope( inv_len = mult_r( level, InvIntTable[nFilterLength] ); /*Q12*/ FOR( i = n1; i < nSamples - n2; i++ ) { -#ifdef BASOP_NOGLOB sum = L_add_sat( sum, L_sub( powerSpec[i + n2], powerSpec[i - n1] ) ); /*powerSpec_exp*/ -#else - sum = L_add( sum, L_sub( powerSpec[i + n2], powerSpec[i - n1] ) ); -#endif - envelope[i] = Mpy_32_16_1( sum, inv_len ); /*Q28*/ + envelope[i] = Mpy_32_16_1( sum, inv_len ); /*Q28*/ move32(); } @@ -593,6 +588,65 @@ static void GetF0( return; } +static void ivas_GetF0_fx( + Word16 /*short*/ const nSamples, /*i - Q0 */ + Word16 /*short*/ const nSamplesCore, /*i - Q0 */ + Word32 /*int*/ const *const powerSpectrum, + /*i - Qx */ /*is justed handed over and given back*/ + Word32 /*int*/ const pitchLag, /*i - Q16*/ + Word16 /*short*/ *const pOrigF0, /*o - Q10*/ + Word16 /*short*/ *const pF0 ) /*o - Q10*/ +{ + Word16 /*short*/ tmpPitchLag; + Word16 /*short*/ rgiStrongHarmonics[MAX_PEAKS_FROM_PITCH]; /*Q0*/ + Word16 /*short*/ nTotalHarmonics, nStrongHarmonics; + Word16 tmp; + + + assert( LAST_HARMONIC_POS_TO_CHECK <= nSamplesCore ); + + /* Use only F0 >= 100 Hz */ + test(); + IF( ( pitchLag > 0 ) && ( LE_16( round_fx( pitchLag ), shr( nSamplesCore, 1 ) ) ) ) + { + + tmpPitchLag /*"halfPitchLag" in FLC - read as Q5 for comparison to halfpitchlag Q4*/ + = round_fx( L_shl( pitchLag, 4 ) ); /*no division by 2, will be done in following division - + furthermore, do a leftshift before rounding, to preserve more accuracy - + will be accommodated also in following division*/ + + /**pF0 = nSamplesCore/tmpPitchLag;*/ + BASOP_Util_Divide_MantExp( nSamplesCore, 0, tmpPitchLag, -( 1 /*division by 2*/ + 4 /*accommodate accuracy-prevention-leftshift*/ ), pF0, &tmp ); /*pF0 is Q15*/ + move16(); + *pF0 = shr_sat( *pF0, sub( 5, tmp ) ); /*Q10 without scalingfactor*/ + move16(); + *pOrigF0 = *pF0; /*Q10*/ + move16(); + tmp = 2 * LAST_HARMONIC_POS_TO_CHECK; + if ( LT_16( nSamples, 2 * LAST_HARMONIC_POS_TO_CHECK ) ) + { + move16(); + tmp = nSamples; + } + BASOP_Util_Divide_MantExp( tmp, 15, *pF0, 5, &nTotalHarmonics, &tmp ); + nTotalHarmonics = shl( nTotalHarmonics, sub( tmp, 15 ) ); + + + /* Get in rgiStrongHarmonics all i for which i*F0 are the strongest harmonics */ + findStrongestHarmonics( nSamples, powerSpectrum, *pF0, nTotalHarmonics, rgiStrongHarmonics, &nStrongHarmonics ); + + ivas_CorrectF0_fx( rgiStrongHarmonics, nStrongHarmonics, pF0 ); + } + ELSE + { + move16(); + move16(); + *pF0 = 0; + *pOrigF0 = 0; + } + return; +} + static void findStrongestHarmonics( const Word16 nSamples, @@ -833,6 +887,159 @@ static void CorrectF0( return; } +static void ivas_CorrectF0_fx( + const Word16 /*short*/ *pHarmonicIndexes, /*I - Q0 */ + const Word16 /*short*/ nHarmonics, /*I - Q0 */ + Word16 /*short*/ *pF0 ) /*I/O - Q10 range: {0}, [4..18) */ +{ + Word16 /*short*/ i; + Word16 /*short*/ F0; + Word16 /*short*/ diff[MAX_PEAKS_FROM_PITCH - 1], sortedDiff[MAX_PEAKS_FROM_PITCH - 1]; /*Q0*/ + Word16 /*short*/ iMostCommonDiff, nMostCommonDiff, nSameDiff, iMult; /*Q0*/ + + Word16 tmp; + + FOR( i = 0; i < MAX_PEAKS_FROM_PITCH - 1; i++ ) + { + diff[i] = 0; + sortedDiff[i] = 0; + move16(); + move16(); + } + + F0 = *pF0; /*Q10*/ + + test(); + IF( F0 > 0 && nHarmonics != 0 ) + { + tmp = sub( nHarmonics, 1 ); + FOR( i = 0; i < tmp; i++ ) + { + diff[i] = sub( pHarmonicIndexes[i + 1], pHarmonicIndexes[i] ); /*Q0*/ + move16(); + sortedDiff[i] = diff[i]; /*Q0*/ + move16(); + } + sort_fx( sortedDiff, 0, sub( nHarmonics, 1 + 1 ) ); + iMostCommonDiff = sortedDiff[0]; /*Q0*/ + move16(); + nSameDiff = 1; + move16(); + i = 1; + move16(); + IF( EQ_16( imult1616( sortedDiff[0], pHarmonicIndexes[0] ), 1 ) ) + { + /* Find how many distances between peaks have length 1 */ + FOR( ; i < tmp; i++ ) + { + if ( EQ_16( sortedDiff[i], 1 ) ) + { + nSameDiff = add( nSameDiff, 1 ); + } + } + } + nMostCommonDiff = nSameDiff; /*Q0*/ + move16(); + + /* If there are at least 3 distances between peaks with length 1 and if the 1st harmonic is in pHarmonicIndexes then keep the original F0 */ + /* Otherwise find the most common distance between peaks */ + IF( LT_16( nSameDiff, 3 ) ) + { + /* Find the most common difference */ + FOR( i = nSameDiff; i < tmp; i++ ) + { + IF( EQ_16( sortedDiff[i], sortedDiff[i - 1] ) ) + { + nSameDiff = add( nSameDiff, 1 ); + } + ELSE + { + IF( GT_16( nSameDiff, nMostCommonDiff ) ) + { + nMostCommonDiff = nSameDiff; /*Q0*/ + move16(); + iMostCommonDiff = sortedDiff[i - 1]; /*Q0*/ + move16(); + } + ELSE + { + test(); + IF( EQ_16( nSameDiff, nMostCommonDiff ) && GT_16( abs_s( sub( iMostCommonDiff, pHarmonicIndexes[0] ) ), abs_s( sub( sortedDiff[i - 1], pHarmonicIndexes[0] ) ) ) ) + { + nMostCommonDiff = nSameDiff; /*Q0*/ + move16(); + iMostCommonDiff = sortedDiff[i - 1]; /*Q0*/ + move16(); + } + } + nSameDiff = 1; + move16(); + } + } + IF( GT_16( nSameDiff, nMostCommonDiff ) ) + { + nMostCommonDiff = nSameDiff; /*Q0*/ + move16(); + iMostCommonDiff = sortedDiff[nHarmonics - 2]; /*Q0*/ + move16(); + } + } + + /* If there are enough peaks at the same distance */ + IF( GE_16( nMostCommonDiff, MAX_PEAKS_FROM_PITCH / 2 ) ) + { + iMult = 1; + move16(); + FOR( i = 0; i < tmp; i++ ) + { + IF( EQ_16( diff[i], iMostCommonDiff ) ) + { + iMult = pHarmonicIndexes[i]; /*Q0*/ + move16(); + BREAK; + } + /* for rare cases of octave mismatch or missing harmonics */ + test(); + test(); + IF( GT_16( sub( nHarmonics, 2 ), i ) && ( EQ_16( diff[i], diff[i + 1] ) ) && ( EQ_16( add( diff[i], diff[i + 1] ), iMostCommonDiff ) ) ) + { + iMult = pHarmonicIndexes[i]; /*Q0*/ + move16(); + BREAK; + } + } + + /* If the real F0 is much higher than the original F0 from the pitch */ + + IF( LE_16( iMult, 3 ) ) + { + /* Use iMostCommonDiff, because the lowest pHarmonicIndexes[i] (which is equal to iMult) may not correspond to the new F0, but to it's multiple */ + F0 = round_fx_sat( L_shl_sat( L_mult( iMostCommonDiff /*Q0*/, F0 /*Q10*/ ), 15 ) ); /*Q10*/ + } + ELSE + { + F0 = 0; + move16(); + } + } + /* Otherwise if there are at least 3 distances between peaks with length 1 and if the 1st harmonic is in pHarmonicIndexes then keep the original F0 */ + /* Otherwise don't use F0 */ + ELSE + { + test(); + if ( ( GT_16( iMostCommonDiff, 1 ) ) || ( LT_16( nMostCommonDiff, 3 ) ) ) + { + /* Not enough peaks at the same distance => don't use the pitch. */ + F0 = 0; + move16(); + } + } + *pF0 = F0; + move16(); + } + return; +} + static void modifyThreshold( Word16 /*short*/ i, /*I - Q0 */ Word16 /*short*/ F0, /*I - Q10*/ @@ -1073,6 +1280,45 @@ static void RefineThresholdsUsingPitch( return; } +static void ivas_RefineThresholdsUsingPitch_fx( + const Word16 nSamples, + const Word16 nSamplesCore, + const Word32 powerSpectrum[], /*Qx*/ + const Word32 lastPitchLag, /*Qx*/ + const Word32 currentPitchLag, /*Qx*/ + Word16 *pF0, /*Q10*/ + Word16 *thresholdModification /*Q10*/ +) +{ + Word16 pitchIsStable; + Word16 origF0; + Word32 L_tmp; + + /*pitchIsStable = (fabs(lastPitchLag-currentPitchLag) < 0.25f);*/ + pitchIsStable = 0; + move16(); + L_tmp = L_abs( L_sub( lastPitchLag, currentPitchLag ) ); + if ( LT_32( L_tmp, 16384l /*0.25f Q16*/ ) ) + { + pitchIsStable = 1; + move16(); + } + + IF( pitchIsStable ) + { + ivas_GetF0_fx( nSamples, + nSamplesCore, + powerSpectrum, lastPitchLag, &origF0, pF0 ); + + modifyThresholds( *pF0, origF0, thresholdModification ); + } + ELSE + { + *pF0 = 0; + move16(); + } + return; +} static void findTonalComponents( Word16 *indexOfTonalPeak, /* OUT Q0*/ Word16 *lowerIndex, /* OUT Q0*/ diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index a41a0c813ebf50cb2a41d9fa92dcc0e33e414b91..1b2207491020bd08416ac1c78f69aeef75ab491c 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -777,14 +777,21 @@ 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 49b3297836a70ff42e2b69e68ed4471fea852703..e804b87555439d0f085e03aeb26f2f14a94bf4b0 100644 --- a/lib_dec/acelp_core_dec_ivas_fx.c +++ b/lib_dec/acelp_core_dec_ivas_fx.c @@ -180,7 +180,19 @@ 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 ); + + Word16 common_e = s_max( sub( old_NoiseEstExp, n2 ), sub( st->hFdCngDec->hFdCngCom->sidNoiseEstExp, n1 ) ); + scale_sig32( st->hFdCngDec->hFdCngCom->sidNoiseEst, NPART, sub( st->hFdCngDec->hFdCngCom->sidNoiseEstExp, common_e ) ); + 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++ ) { @@ -611,7 +623,11 @@ 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(); @@ -786,7 +802,11 @@ 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 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 } } @@ -826,12 +846,21 @@ 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 } } @@ -1102,7 +1131,11 @@ 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 @@ -1218,7 +1251,7 @@ ivas_error acelp_core_dec_ivas_fx( *------------------------------------------------------------*/ - Copy_Scale_sig( pitch_buf_fx, pitch_buf_tmp, NB_SUBFR16k, -Q6 ); // Q0 + Copy_Scale_sig( pitch_buf_fx, pitch_buf_tmp, st->nb_subfr, -Q6 ); // Q0 FEC_scale_syn_ivas_fx( st->L_frame, &update_flg, st->clas_dec, st->last_good, psyn_fx, pitch_buf_tmp, st->enr_old_fx, enr_q_fx, st->coder_type, LSF_Q_prediction, &st->scaling_flag, &st->lp_ener_FEC_av, &st->lp_ener_FEC_max, st->bfi, st->total_brate, st->prev_bfi, st->last_core_brate, exc_fx, exc2_fx, Aq_fx, &st->old_enr_LP, mem_tmp_fx, st->mem_syn2_fx, st->Q_exc, st->Q_syn, avoid_lpc_burst_on_recovery, 0 ); @@ -1309,7 +1342,11 @@ 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 ) @@ -1372,7 +1409,7 @@ ivas_error acelp_core_dec_ivas_fx( test(); IF( EQ_32( st->total_brate, ACELP_7k20 ) || EQ_32( st->total_brate, ACELP_8k00 ) ) { - Copy_Scale_sig( pitch_buf_fx, pitch_buf_tmp, NB_SUBFR16k, -Q6 ); // Q0 + Copy_Scale_sig( pitch_buf_fx, pitch_buf_tmp, st->nb_subfr, -Q6 ); // Q0 FEC_scale_syn_ivas_fx( st->L_frame, &update_flg, st->clas_dec, st->last_good, psyn_fx, pitch_buf_tmp, st->enr_old_fx, enr_q_fx, st->coder_type, LSF_Q_prediction, &st->scaling_flag, &st->lp_ener_FEC_av, &st->lp_ener_FEC_max, st->bfi, st->total_brate, st->prev_bfi, st->last_core_brate, @@ -1409,7 +1446,7 @@ ivas_error acelp_core_dec_ivas_fx( test(); IF( st->last_bwidth == NB && st->hPFstat != NULL ) { - Copy( pitch_buf_fx, pitch_buf_tmp, NB_SUBFR16k ); + Copy_Scale_sig( pitch_buf_fx, pitch_buf_tmp, st->nb_subfr, -Q6 ); // Q0 IF( st->bwidth == NB ) { st->hPFstat->on = 1; @@ -1731,12 +1768,12 @@ ivas_error acelp_core_dec_ivas_fx( pImagSave_fx[i] = imagBufferSave_fx[i]; } #ifndef MSAN_FIX - Copy_Scale_sig_16_32( bpf_error_signal_16fx, bpf_error_signal_fx, st->L_frame, -1 ); // Q_syn-1 + 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( bpf_error_signal_16fx, bpf_error_signal_fx, st->L_frame, -1 ); // Q_syn-1 + 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 @@ -1768,9 +1805,13 @@ ivas_error acelp_core_dec_ivas_fx( q_bpf_error_signal = Q6; move16(); #ifdef MSAN_FIX - Copy_Scale_sig_16_32( bpf_error_signal_16fx, tmp_bpf_error_signal_fx, st->L_frame, sub( q_bpf_error_signal, st->Q_syn ) ); // Q6 +#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( bpf_error_signal_16fx, tmp_bpf_error_signal_fx, L_FRAME16k, q_bpf_error_signal - st->Q_syn ); // Q6 + 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++ ) { @@ -1866,7 +1907,9 @@ ivas_error acelp_core_dec_ivas_fx( scale_sig32_r( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); // (Q_real-1) 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 FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) { @@ -1995,7 +2038,11 @@ ivas_error acelp_core_dec_ivas_fx( // Get Q-factor q_bpf_error_signal = Q6; move16(); - Copy_Scale_sig_16_32( bpf_error_signal_16fx, tmp_bpf_error_signal_fx, L_FRAME16k, sub( q_bpf_error_signal, st->Q_syn ) ); // Q6 +#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 @@ -2062,7 +2109,7 @@ ivas_error acelp_core_dec_ivas_fx( move16(); IF( st->p_bpf_noise_buf_32 ) { - Copy_Scale_sig_16_32( bpf_error_signal_16fx, bpf_error_signal_fx, st->L_frame, -1 ); // Q_syn-1 + Copy_Scale_sig_16_32_DEPREC( bpf_error_signal_16fx, bpf_error_signal_fx, st->L_frame, -1 ); // Q_syn-1 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 @@ -2108,9 +2155,9 @@ ivas_error acelp_core_dec_ivas_fx( psyn_fx, synth_fx16, st->Q_exc, st->Q_syn2, st->hBWE_zero->delay_syn_hf_fx, &st->hBWE_zero->memExp1, st->hBWE_zero->mem_hp_interp_fx, st->extl, st->CNG_mode ); #ifdef MSAN_FIX - Copy_Scale_sig_16_32( synth_fx16, synth_fx, output_frame, 0 ); + Copy_Scale_sig_16_32_DEPREC( synth_fx16, synth_fx, output_frame, 0 ); #else - Copy_Scale_sig_16_32( synth_fx16, synth_fx, L_FRAME48k, 0 ); + Copy_Scale_sig_16_32_DEPREC( synth_fx16, synth_fx, L_FRAME48k, 0 ); #endif } ELSE @@ -2153,7 +2200,11 @@ 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 ) ) ) { - Copy_Scale_sig_16_32( 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 +#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 } diff --git a/lib_dec/acelp_core_switch_dec_fx.c b/lib_dec/acelp_core_switch_dec_fx.c index 8224a74eb5ada3306a55839662d9a103e8038ea7..3875339571c907267d06ede6126a3022dc03d558 100644 --- a/lib_dec/acelp_core_switch_dec_fx.c +++ b/lib_dec/acelp_core_switch_dec_fx.c @@ -128,7 +128,13 @@ 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 ); /*----------------------------------------------------------------* @@ -332,12 +338,8 @@ ivas_error acelp_core_switch_dec_fx( pt2 = &hb_synth_tmp[tmp]; FOR( i = 0; i < gapsize; i++ ) { -#ifdef BASOP_NOGLOB *pt1++ = round_fx_sat( L_shl_sat( L_mult_sat( ( *pt2++ ), gain ), 2 ) ); move16(); -#else - *pt1++ = round_fx( L_shl( L_mult( ( *pt2++ ), gain ), 2 ) ); -#endif } } ELSE @@ -820,7 +822,11 @@ 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 ); - Copy_Scale_sig_16_32( syn, syn32, L_FRAME16k, Qtmp ); // Q(11) +#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,7 +846,7 @@ ivas_error acelp_core_switch_dec_bfi_ivas_fx( 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( synth_out, synth32, L_FRAME48k, 5 ); /*11-5-1*/ + Copy_Scale_sig_16_32_DEPREC( synth_out, synth32, L_FRAME48k, 5 ); /*11-5-1*/ // cldfbSynthesis_ivas_fx(realBuffer, imagBuffer, synth_out, (int16_t)(st_fx->output_Fs * 0.01f), st_fx->cldfbSyn); cldfbSynthesis_ivas_fx( realBuffer, imagBuffer, synth32, extract_l( Mpy_32_16_1( st_fx->output_Fs, 328 ) ), st_fx->cldfbSyn ); @@ -973,11 +979,7 @@ static void decod_gen_voic_core_switch_fx( IF( st_fx->prev_bfi ) { /*gain_code = min(gain_code, 0.5f*gain_code+0.5f*st->lp_gainc);*/ -#ifdef BASOP_NOGLOB gain_code16 = s_min( gain_code16, mac_r( L_mult( 16384, gain_code16 ), shl_o( 16384 >> 3, st_fx->Q_exc, &Overflow ), st_fx->lp_gainc_fx ) ); /* st_fx->lp_gainc_fx in Q3 >>3 to bring it to Q0 as gain_code16 */ -#else - gain_code16 = s_min( gain_code16, mac_r( L_mult( 16384, gain_code16 ), shl( 16384 >> 3, st_fx->Q_exc ), st_fx->lp_gainc_fx ) ); /* st_fx->lp_gainc_fx in Q3 >>3 to bring it to Q0 as gain_code16 */ -#endif } FOR( i = 0; i < L_SUBFR; i++ ) diff --git a/lib_dec/amr_wb_dec_fx.c b/lib_dec/amr_wb_dec_fx.c index 72ceb6cd3155a6e56df40e72df0c3a6a323f7ded..d45655903fb6f8f427e3d28ea4f7e91cbd2be7a2 100644 --- a/lib_dec/amr_wb_dec_fx.c +++ b/lib_dec/amr_wb_dec_fx.c @@ -1046,11 +1046,7 @@ ivas_error amr_wb_dec_fx( FOR( i = 0; i < tmps; i++ ) { -#ifdef BASOP_NOGLOB synth_out_fx[( i + delay_comp )] = msu_r_sat( L_mult( synth_out_fx[( i + delay_comp )], alpha ), hHQ_core->old_out_fx[( i + nz )], add( alpha, -32768 ) ); -#else - synth_out_fx[i + delay_comp] = msu_r( L_mult( synth_out_fx[i + delay_comp], alpha ), hHQ_core->old_out_fx[i + nz], add( alpha, -32768 ) ); -#endif move16(); alpha = add( alpha, step ); } diff --git a/lib_dec/arith_coder_dec_fx.c b/lib_dec/arith_coder_dec_fx.c index 68736867d887d10af7e0c4f1e6e26110e50c1e62..4a18f64f9af7a503a0e66756353605e7e5d03b07 100644 --- a/lib_dec/arith_coder_dec_fx.c +++ b/lib_dec/arith_coder_dec_fx.c @@ -61,11 +61,7 @@ static Word16 tcx_arith_decode_fx( { bp = ari_decode_14bits_sign_fx( prm, bp, target_bits, &s, &as ); -#ifdef BASOP_NOGLOB L_tmp = L_macNs_co( L_tmp, q, k, &Carry, &Overflow ); -#else - L_tmp = L_macNs( L_tmp, q, k ); -#endif Q = L_mult( q, negate( shl( 1, sub( 30, SPEC_EXP_DEC ) ) ) ); IF( EQ_16( s, 0 ) ) diff --git a/lib_dec/bass_psfilter_fx.c b/lib_dec/bass_psfilter_fx.c index 0f290fc8f5dd770c37bab21d27fd2440614ed8ce..c11e30c93af6770d9f053cd177f56482d43484d1 100644 --- a/lib_dec/bass_psfilter_fx.c +++ b/lib_dec/bass_psfilter_fx.c @@ -192,12 +192,8 @@ void bass_psfilter_fx( } tmp = sum16_fx( hBPF->Track_on_hist, L_TRACK_HIST ); -#ifdef BASOP_NOGLOB TrackOnR = round_fx_sat( L_shl_sat( L_mult0( tmp, 3277 ), 16 ) ); /*Q15 */ -#else - TrackOnR = round_fx( L_shl( L_mult0( tmp, 3277 ), 16 ) ); /*Q15 */ -#endif - vibratR = sum16_fx( hBPF->vibrato_hist, L_TRACK_HIST ); /*Q0 */ + vibratR = sum16_fx( hBPF->vibrato_hist, L_TRACK_HIST ); /*Q0 */ alp_tmp = sub( 32767, TrackOnR ); /*Q15 */ @@ -328,21 +324,13 @@ void bass_psfilter_fx( because it is a signed sum. */ FOR( j = 0; j < subfr_len; j += 2 ) { - Lcorr0 = L_mult0( syn_fx[j], syn2_fx[j] ); /* Q31 */ - Lener0 = L_mult0( syn2_fx[j], syn2_fx[j] ); /* Q31 */ -#ifdef BASOP_NOGLOB + Lcorr0 = L_mult0( syn_fx[j], syn2_fx[j] ); /* Q31 */ + Lener0 = L_mult0( syn2_fx[j], syn2_fx[j] ); /* Q31 */ Lcorr0 = L_mac0_sat( Lcorr0, syn_fx[j + 1], syn2_fx[j + 1] ); /* Q31 */ Lener0 = L_mac0_sat( Lener0, syn2_fx[j + 1], syn2_fx[j + 1] ); /* Q31 */ Lcorr = L_add_sat( Lcorr, L_shr( Lcorr0, 4 ) ); Lener = L_add_sat( Lener, L_shr( Lener0, 4 ) ); -#else - Lcorr0 = L_mac0( Lcorr0, syn_fx[j + 1], syn2_fx[j + 1] ); - Lener0 = L_mac0( Lener0, syn2_fx[j + 1], syn2_fx[j + 1] ); - - Lcorr = L_add( Lcorr, L_shr( Lcorr0, 4 ) ); - Lener = L_add( Lener, L_shr( Lener0, 4 ) ); -#endif /* this loop is not efficient but it provide a respectable precision while avoiding overflow. */ } @@ -354,24 +342,16 @@ void bass_psfilter_fx( Ltmp = L_abs( Lcorr ); exp = norm_l( Ltmp ); -#ifdef BASOP_NOGLOB tmp = round_fx_sat( L_shl_sat( Ltmp, exp ) ); -#else - tmp = round_fx( L_shl( Ltmp, exp ) ); -#endif exp2 = norm_l( Lener ); -#ifdef BASOP_NOGLOB tmp2 = round_fx_sat( L_shl( Lener, exp2 ) ); -#else - tmp2 = round_fx( L_shl( Lener, exp2 ) ); -#endif if ( GT_16( tmp, tmp2 ) ) { exp = sub( exp, 1 ); } exp2 = sub( exp, exp2 ); /* exponent num - exponent denom */ /* gain = corr / ener */ - gain = div_s( round_fx( L_shl( Ltmp, exp ) ), tmp2 ); + gain = div_s( round_fx_sat( L_shl( Ltmp, exp ) ), tmp2 ); if ( Lcorr < 0 ) { gain = sub( 0, gain ); @@ -381,11 +361,7 @@ void bass_psfilter_fx( FOR( i = 0; i < subfr_len; i++ ) { /* err[i] = syn_fx[i] - gain*syn2_fx[i] */ -#ifdef BASOP_NOGLOB err[i] = msu_r_sat( L_shr_sat( L_mult0( gain, syn2_fx[i] ), exp2 ), syn_fx[i], 16384 ); /* Q15 */ -#else - err[i] = msu_r( L_shr( L_mult0( gain, syn2_fx[i] ), exp2 ), syn_fx[i], 16384 ); -#endif move16(); /* the sign is inverted but it is not important because we calculate energy with 'err[i]' x 'err[i]' @@ -404,28 +380,16 @@ void bass_psfilter_fx( tmp2 = sub( tmp2, 1 + 4 ); /* substract 1 because 'Lener' is divided by two */ tmp2 = add( tmp2, Q_syn2x ); tmp2 = s_max( 0, s_min( 30, tmp2 ) ); -#ifdef BASOP_NOGLOB Lener = L_add_sat( Lener, Pow2( tmp2, exp2 ) ); -#else - Lener = L_add( Lener, Pow2( tmp2, exp2 ) ); -#endif exp2 = norm_l( Lener ); -#ifdef BASOP_NOGLOB tmp2 = round_fx_sat( L_shl( Lener, exp2 ) ); -#else - tmp2 = round_fx( L_shl( Lener, exp2 ) ); -#endif if ( GT_16( tmp, tmp2 ) ) { exp = sub( exp, 1 ); } - exp2 = sub( exp, exp2 ); /* exponent num - exponent denom */ - /* alpha = corr / ener */ -#ifdef BASOP_NOGLOB + exp2 = sub( exp, exp2 ); /* exponent num - exponent denom */ + /* alpha = corr / ener */ alpha = shr_sat( div_s( round_fx_sat( L_shl_sat( Ltmp, exp ) ), tmp2 ), exp2 ); /*Q15 */ -#else - alpha = shr( div_s( round_fx( L_shl( Ltmp, exp ) ), tmp2 ), exp2 ); /*Q15 */ -#endif if ( Lcorr < 0 ) { alpha = sub( 0, alpha ); @@ -471,13 +435,8 @@ void bass_psfilter_fx( FOR( i = 0; i < subfr_len; i++ ) { /*syn2_fx[i] = alpha*(syn_fx[i]-syn2_fx[i]); */ -#ifdef BASOP_NOGLOB tmp = sub_sat( syn_fx[i], syn2_fx[i] ); syn2_fx[i] = mult_sat( alpha, shl_sat( tmp, 1 ) ); -#else - tmp = sub( syn_fx[i], syn2_fx[i] ); - syn2_fx[i] = mult( alpha, shl( tmp, 1 ) ); -#endif move16(); /*Q_syn2 */ } @@ -490,11 +449,7 @@ void bass_psfilter_fx( This sum is divided by 4 */ FOR( i = 0; i < subfr_len; i++ ) { -#ifdef BASOP_NOGLOB Lener = L_mac0_sat( Lener, err[i], err[i] ); /* Q31 */ -#else - Lener = L_mac0( Lener, err[i], err[i] ); -#endif } exp2 = -1 - 2; move16(); @@ -506,11 +461,7 @@ void bass_psfilter_fx( FOR( i = 0; i < shr( subfr_len, 1 ); i++ ) { Lener0 = L_mult0( sigPtr[i], sigPtr[i] ); /* Q31 */ -#ifdef BASOP_NOGLOB Lener = L_add( Lener, L_shr( L_mac0_sat( Lener0, err[i], err[i] ), 5 ) ); -#else - Lener = L_add( Lener, L_shr( L_mac0( Lener0, err[i], err[i] ), 5 ) ); -#endif } exp2 = sub( exp2, 5 ); } @@ -563,21 +514,13 @@ void bass_psfilter_fx( sigPtr1 = syn2_fx + 1; FOR( j = 0; j < subfr_len; j += 2 ) { - Lcorr0 = L_mult0( syn_fx[j], syn2_fx[j] ); /* Q31 */ - Lener0 = L_mult0( syn2_fx[j], syn2_fx[j] ); /* Q31 */ -#ifdef BASOP_NOGLOB + Lcorr0 = L_mult0( syn_fx[j], syn2_fx[j] ); /* Q31 */ + Lener0 = L_mult0( syn2_fx[j], syn2_fx[j] ); /* Q31 */ Lcorr0 = L_mac0_sat( Lcorr0, sigPtr[j], sigPtr1[j] ); /* Q31 */ Lener0 = L_mac0_sat( Lener0, sigPtr1[j], sigPtr1[j] ); /* Q31 */ Lcorr = L_add_sat( Lcorr, L_shr( Lcorr0, 4 ) ); Lener = L_add_sat( Lener, L_shr( Lener0, 4 ) ); -#else - Lcorr0 = L_mac0( Lcorr0, sigPtr[j], sigPtr1[j] ); - Lener0 = L_mac0( Lener0, sigPtr1[j], sigPtr1[j] ); - - Lcorr = L_add( Lcorr, L_shr( Lcorr0, 4 ) ); - Lener = L_add( Lener, L_shr( Lener0, 4 ) ); -#endif /* this loop is not efficient but it provide a respectable precision while avoiding overflow. */ } @@ -589,15 +532,9 @@ void bass_psfilter_fx( Ltmp = L_abs( Lcorr ); exp = norm_l( Ltmp ); -#ifdef BASOP_NOGLOB tmp = round_fx_sat( L_shl_sat( Ltmp, exp ) ); exp2 = norm_l( Lener ); tmp2 = round_fx_sat( L_shl_sat( Lener, exp2 ) ); -#else - tmp = round_fx( L_shl( Ltmp, exp ) ); - exp2 = norm_l( Lener ); - tmp2 = round_fx( L_shl( Lener, exp2 ) ); -#endif if ( GT_16( tmp, tmp2 ) ) { exp = sub( exp, 1 ); @@ -633,17 +570,9 @@ void bass_psfilter_fx( tmp2 = sub( tmp2, 1 + 4 ); /* substract 1 because 'Lener' is divided by two */ tmp2 = add( tmp2, Q_syn2x ); tmp2 = s_max( 0, s_min( 30, tmp2 ) ); -#ifdef BASOP_NOGLOB Lener = L_add_sat( Lener, Pow2( tmp2, exp2 ) ); -#else - Lener = L_add( Lener, Pow2( tmp2, exp2 ) ); -#endif exp2 = norm_l( Lener ); -#ifdef BASOP_NOGLOB tmp2 = round_fx_sat( L_shl( Lener, exp2 ) ); -#else - tmp2 = round_fx( L_shl( Lener, exp2 ) ); -#endif if ( GT_16( tmp, tmp2 ) ) { exp = sub( exp, 1 ); @@ -675,11 +604,7 @@ void bass_psfilter_fx( This sum is divided by 4 */ FOR( i = 0; i < subfr_len; i++ ) { -#ifdef BASOP_NOGLOB Lener = L_mac0_sat( Lener, err[i], err[i] ); /* Q31 */ -#else - Lener = L_mac0( Lener, err[i], err[i] ); -#endif } exp2 = -1 - 2; move16(); @@ -691,11 +616,7 @@ void bass_psfilter_fx( FOR( i = 0; i < subfr_len / 2; i++ ) { Lener0 = L_mult0( sigPtr[i], sigPtr[i] ); /* Q31 */ -#ifdef BASOP_NOGLOB Lener = L_add_sat( Lener, L_shr( L_mac0_sat( Lener0, err[i], err[i] ), 5 ) ); -#else - Lener = L_add( Lener, L_shr( L_mac0( Lener0, err[i], err[i] ), 5 ) ); -#endif } exp2 = sub( exp2, 5 ); } @@ -798,15 +719,9 @@ static Word16 Pit_track_fx( /* o : Pitch */ Lcorr0 = L_mult0( *v1++, *v2++ ); /* Q31 */ FOR( i = 1; i < ( ( L_HALFR16k + NBPSF_L_EXTRA ) / 14 ); i++ ) { -#ifdef BASOP_NOGLOB Lener0 = L_mac0_sat( Lener0, *v1, *v1 ); /* Q31 */ Ltmp0 = L_mac0_sat( Ltmp0, *v2, *v2 ); /* Q31 */ Lcorr0 = L_mac0_sat( Lcorr0, *v1++, *v2++ ); /* Q31 */ -#else - Lener0 = L_mac0( Lener0, *v1, *v1 ); - Ltmp0 = L_mac0( Ltmp0, *v2, *v2 ); - Lcorr0 = L_mac0( Lcorr0, *v1++, *v2++ ); -#endif } BASOP_SATURATE_WARNING_ON_EVS test(); @@ -846,11 +761,7 @@ static Word16 Pit_track_fx( /* o : Pitch */ exp1 = norm_l( Lener ); exp2 = norm_l( Ltmp ); /* Multiply the Most Significant 16 bits */ -#ifdef BASOP_NOGLOB Ltmp = L_mult0( round_fx_sat( L_shl_sat( Lener, exp1 ) ), round_fx_sat( L_shl_sat( Ltmp, exp2 ) ) ); /* Q31 */ -#else - Ltmp = L_mult0( round_fx( L_shl( Lener, exp1 ) ), round_fx( L_shl( Ltmp, exp2 ) ) ); -#endif exp1 = add( exp1, exp2 ); /* Correct if Odd # of Shifts */ exp2 = s_and( exp1, 1 ); @@ -868,11 +779,7 @@ static Word16 Pit_track_fx( /* o : Pitch */ exp1 = sub( exp1, exp2 ); Ltmp = Mpy_32_16_1( Lcorr, round_fx( Ltmp ) ); /* Go to Q31 */ -#ifdef BASOP_NOGLOB Ltmp = L_shl_sat( Ltmp, exp1 ); -#else - Ltmp = L_shl( Ltmp, exp1 ); -#endif /* cn = normalized correlation of pitch/2 */ if ( GT_32( Ltmp, 2040109466L ) ) /* 0.95f in Q31 */ { diff --git a/lib_dec/cng_dec_fx.c b/lib_dec/cng_dec_fx.c index 1ca8f8ac3e10d50b7a0038defbcbcc27f9196aba..3590dae71f9caf434f47e419f4ffcb37e4d4d672 100644 --- a/lib_dec/cng_dec_fx.c +++ b/lib_dec/cng_dec_fx.c @@ -524,11 +524,7 @@ void CNG_dec_fx( FOR( i = 0; i < M; i++ ) { dev = abs_s( sub( lsp_tmp[i], lsp_new[i] ) ); /*Q15*/ -#ifdef BASOP_NOGLOB - dist = add_o( dist, dev, &Overflow ); /*Q15*/ -#else - dist = add( dist, dev ); /*Q15*/ -#endif + dist = add_o( dist, dev, &Overflow ); /*Q15*/ if ( GT_16( dev, max_dev ) ) { max_dev = dev; @@ -562,31 +558,19 @@ void CNG_dec_fx( FOR( j = 0; j < m1; j++ ) { /* env[i] += tmp_env[j*NUM_ENV_CNG+i];*/ -#ifdef BASOP_NOGLOB L_tmp = L_add_sat( L_tmp, tmp_env[j * NUM_ENV_CNG + i] ); -#else - L_tmp = L_add( L_tmp, tmp_env[j * NUM_ENV_CNG + i] ); -#endif } /* env[i] /= (float)m1; */ /* env[i] = env[i] - 2*st_fx->lp_ener_fx; */ IF( EQ_16( m1, 1 ) ) { -#ifdef BASOP_NOGLOB L_tmp = L_sub_sat( L_tmp, L_add_sat( st_fx->lp_ener_fx, st_fx->lp_ener_fx ) ); /* Q6 */ -#else - L_tmp = L_sub( L_tmp, L_add( st_fx->lp_ener_fx, st_fx->lp_ener_fx ) ); -#endif } ELSE { tmp1 = div_s( 1, m1 ); - L_tmp = Mult_32_16( L_tmp, tmp1 ); /* Q6 */ -#ifdef BASOP_NOGLOB + L_tmp = Mult_32_16( L_tmp, tmp1 ); /* Q6 */ L_tmp = L_sub_sat( L_tmp, L_add_sat( st_fx->lp_ener_fx, st_fx->lp_ener_fx ) ); /* Q6 */ -#else - L_tmp = L_sub( L_tmp, L_add( st_fx->lp_ener_fx, st_fx->lp_ener_fx ) ); -#endif } env[i] = L_tmp; /* Q6 */ move32(); @@ -606,11 +590,7 @@ void CNG_dec_fx( { /* Update hangover memory during CNG */ test(); -#ifdef BASOP_NOGLOB IF( ( *allow_cn_step == 0 ) && LT_32( hTdCngDec->Enew_fx, L_add_sat( st_fx->lp_ener_fx, L_shr( st_fx->lp_ener_fx, 1 ) ) ) ) -#else - IF( *allow_cn_step == 0 && LT_32( hTdCngDec->Enew_fx, L_add( st_fx->lp_ener_fx, L_shr( st_fx->lp_ener_fx, 1 ) ) ) ) -#endif { /* update the pointer to circular buffer of old LSP vectors */ hTdCngDec->ho_hist_ptr++; @@ -634,11 +614,7 @@ void CNG_dec_fx( exp = norm_l( hTdCngDec->Enew_fx ); L_tmp = L_shl( hTdCngDec->Enew_fx, exp ); /*Q(exp+6)*/ L_tmp = Mult_32_16( L_tmp, shl( st_fx->L_frame, 5 ) ); /*Q(exp+6+5-15=exp-4)*/ -#ifdef BASOP_NOGLOB - L_tmp = L_shr_sat( L_tmp, sub( exp, 10 ) ); /*Q6*/ -#else - L_tmp = L_shr( L_tmp, sub( exp, 10 ) ); /*Q6*/ -#endif + L_tmp = L_shr_sat( L_tmp, sub( exp, 10 ) ); /*Q6*/ exp = norm_l( L_tmp ); fra = Log2_norm_lc( L_shl( L_tmp, exp ) ); exp = sub( sub( 30, exp ), 6 ); @@ -1219,11 +1195,7 @@ void CNG_dec_ivas_fx( FOR( i = 0; i < M; i++ ) { dev = abs_s( sub( lsp_tmp[i], lsp_new[i] ) ); /*Q15*/ -#ifdef BASOP_NOGLOB - dist = add_o( dist, dev, &Overflow ); /*Q15*/ -#else - dist = add( dist, dev ); /*Q15*/ -#endif + dist = add_o( dist, dev, &Overflow ); /*Q15*/ if ( GT_16( dev, max_dev ) ) { max_dev = dev; @@ -1257,31 +1229,19 @@ void CNG_dec_ivas_fx( FOR( j = 0; j < m1; j++ ) { /* env[i] += tmp_env[j*NUM_ENV_CNG+i];*/ -#ifdef BASOP_NOGLOB L_tmp = L_add_sat( L_tmp, tmp_env[j * NUM_ENV_CNG + i] ); -#else - L_tmp = L_add( L_tmp, tmp_env[j * NUM_ENV_CNG + i] ); -#endif } /* env[i] /= (float)m1; */ /* env[i] = env[i] - 2*st_fx->lp_ener_fx; */ IF( EQ_16( m1, 1 ) ) { -#ifdef BASOP_NOGLOB L_tmp = L_sub_sat( L_tmp, L_add_sat( st_fx->lp_ener_fx, st_fx->lp_ener_fx ) ); /* Q6 */ -#else - L_tmp = L_sub( L_tmp, L_add( st_fx->lp_ener_fx, st_fx->lp_ener_fx ) ); -#endif } ELSE { tmp1 = div_s( 1, m1 ); - L_tmp = Mult_32_16( L_tmp, tmp1 ); /* Q6 */ -#ifdef BASOP_NOGLOB + L_tmp = Mult_32_16( L_tmp, tmp1 ); /* Q6 */ L_tmp = L_sub_sat( L_tmp, L_add_sat( st_fx->lp_ener_fx, st_fx->lp_ener_fx ) ); /* Q6 */ -#else - L_tmp = L_sub( L_tmp, L_add( st_fx->lp_ener_fx, st_fx->lp_ener_fx ) ); -#endif } env[i] = L_tmp; /* Q6 */ move32(); @@ -1301,11 +1261,7 @@ void CNG_dec_ivas_fx( { /* Update hangover memory during CNG */ test(); -#ifdef BASOP_NOGLOB IF( ( *allow_cn_step == 0 ) && LT_32( hTdCngDec->Enew_fx, L_add_sat( st_fx->lp_ener_fx, L_shr( st_fx->lp_ener_fx, 1 ) ) ) ) -#else - IF( *allow_cn_step == 0 && LT_32( hTdCngDec->Enew_fx, L_add( st_fx->lp_ener_fx, L_shr( st_fx->lp_ener_fx, 1 ) ) ) ) -#endif { /* update the pointer to circular buffer of old LSP vectors */ hTdCngDec->ho_hist_ptr++; @@ -1329,11 +1285,7 @@ void CNG_dec_ivas_fx( exp = norm_l( hTdCngDec->Enew_fx ); L_tmp = L_shl( hTdCngDec->Enew_fx, exp ); /*Q(exp+6)*/ L_tmp = Mult_32_16( L_tmp, shl( st_fx->L_frame, 5 ) ); /*Q(exp+6+5-15=exp-4)*/ -#ifdef BASOP_NOGLOB - L_tmp = L_shr_sat( L_tmp, sub( exp, 10 ) ); /*Q6*/ -#else - L_tmp = L_shr( L_tmp, sub( exp, 10 ) ); /*Q6*/ -#endif + L_tmp = L_shr_sat( L_tmp, sub( exp, 10 ) ); /*Q6*/ exp = norm_l( L_tmp ); fra = Log2_norm_lc( L_shl( L_tmp, exp ) ); exp = sub( sub( 30, exp ), 6 ); @@ -1575,11 +1527,7 @@ static void shb_CNG_decod_fx( interp_fx = s_min( st_fx->shb_dtx_count_fx, 32 ); -#ifdef BASOP_NOGLOB interp_fx = shl_sat( interp_fx, 10 ); /*Q15*/ -#else - interp_fx = shl( interp_fx, 10 ); /*Q15*/ -#endif FOR( i = 0; i < LPC_SHB_ORDER; i++ ) { tmp2 = mult( interp_fx, st_fx->lsp_shb_prev_fx[i] ); /*Q14*/ @@ -1708,12 +1656,8 @@ static void shb_CNG_decod_fx( move16(); /*Q8 */ IF( st_fx->trans_cnt_fx > 0 ) { - i = extract_l( L_mult0( st_fx->trans_cnt_fx, 17 ) ); /*Q0 */ -#ifdef BASOP_NOGLOB + i = extract_l( L_mult0( st_fx->trans_cnt_fx, 17 ) ); /*Q0 */ ener_fx = add_sat( st_fx->shb_cng_ener_fx, mult( sin_table256_fx[i], sub_sat( st_fx->last_shb_ener_fx, st_fx->shb_cng_ener_fx ) ) ); /*Q8 */ -#else - ener_fx = add( st_fx->shb_cng_ener_fx, mult( sin_table256_fx[i], sub( st_fx->last_shb_ener_fx, st_fx->shb_cng_ener_fx ) ) ); /*Q8 */ -#endif st_fx->trans_cnt_fx = sub( st_fx->trans_cnt_fx, 1 ); move16(); } @@ -1728,11 +1672,7 @@ static void shb_CNG_decod_fx( move32(); } fra = L_Extract_lc( L_tmp, &exp ); -#ifdef BASOP_NOGLOB L_tmp = L_shl_sat( Pow2( exp, fra ), 5 ); /*Q5 */ -#else - L_tmp = L_shl( Pow2( exp, fra ), 5 ); /*Q5 */ -#endif L_tmp = L_shr( L_tmp, 10 ); if ( !L_tmp ) { @@ -1858,11 +1798,7 @@ static void shb_CNG_decod_ivas_fx( /* SHB spectrum estimation */ interp_fx = s_min( st->hTdCngDec->shb_dtx_count, 32 ); -#ifdef BASOP_NOGLOB interp_fx = shl_sat( interp_fx, 10 ); /*Q15*/ -#else - interp_fx = shl( interp_fx, 10 ); /*Q15*/ -#endif FOR( i = 0; i < LPC_SHB_ORDER; i++ ) { diff --git a/lib_dec/core_switching_dec.c b/lib_dec/core_switching_dec.c index 323deae0ac32506e8208d09fcd45eb92f04fa50b..a8041cd53d90e77276e4552ba953b5201f907f9d 100644 --- a/lib_dec/core_switching_dec.c +++ b/lib_dec/core_switching_dec.c @@ -233,8 +233,8 @@ ivas_error core_switching_pre_dec_ivas_fx( Word32 realBufferTmp_fx[CLDFB_NO_COL_MAX_SWITCH][CLDFB_NO_CHANNELS_MAX], imagBufferTmp_fx[CLDFB_NO_COL_MAX_SWITCH][CLDFB_NO_CHANNELS_MAX]; Word32 syn_Overl_fx[320]; Word32 fer_samples_fx[960]; - Copy_Scale_sig_16_32( st->hTcxDec->syn_Overl, syn_Overl_fx, 320, 15 ); - Copy_Scale_sig_16_32( st->hHQ_core->fer_samples_fx, fer_samples_fx, 960, 15 ); + Copy_Scale_sig_16_32_DEPREC( st->hTcxDec->syn_Overl, syn_Overl_fx, 320, 15 ); + Copy_Scale_sig_16_32_DEPREC( st->hHQ_core->fer_samples_fx, fer_samples_fx, 960, 15 ); FOR( i = 0; i < CLDFB_NO_COL_MAX_SWITCH; i++ ) @@ -539,7 +539,11 @@ 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" ) ); } - Copy_Scale_sig_16_32( st->hTcxDec->old_synthFB_fx, old_synthFB_fx, st->hTcxDec->old_synth_lenFB, sub( Q10, Q_old_synthFB ) ); // Q10 +#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/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index bd7d53bc66a32206b5d4f9104111c346526e6289..17df8b5ca95b3054abcf4109bb92b63cd55ad32a 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -221,12 +221,8 @@ void bw_switching_pre_proc_fx( * Calculate tilt of the ACELP core synthesis *----------------------------------------------------------------------*/ -#ifdef BASOP_NOGLOB st_fx->tilt_wb_fx = round_fx_o( L_shl_o( calc_tilt_bwe_fx( old_syn_12k8_16k_fx, -1, st_fx->L_frame ), 3, &Overflow ), &Overflow ); /* Q11 */ move16(); -#else - st_fx->tilt_wb_fx = round_fx( L_shl( calc_tilt_bwe_fx( old_syn_12k8_16k_fx, -1, st_fx->L_frame ), 3 ) ); -#endif /*-------------------------------------------------------------------------------* * Calculate frequency energy of 0~3.2kHz and 3.2~6.4kHz the ACELP core synthesis *-------------------------------------------------------------------------------*/ @@ -236,11 +232,7 @@ void bw_switching_pre_proc_fx( L_tmp = L_deposit_l( 0 ); FOR( i = 0; i < L_FRAME / 2; i++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_mac0_o( L_tmp, syn_dct_fx[i], syn_dct_fx[i], &Overflow ); /* (2 * Q_syn2) */ -#else - L_tmp = L_mac0( L_tmp, syn_dct_fx[i], syn_dct_fx[i] ); -#endif } L_tmp = L_shr( L_tmp, 7 ); /* 2 * Q_syn2 */ st_fx->enerLL_fx = Calc_freq_ener_fx( L_tmp, shl( st_fx->Q_syn2, 1 ) ); /* Q_syn2 */ @@ -248,11 +240,7 @@ void bw_switching_pre_proc_fx( L_tmp = L_deposit_l( 0 ); FOR( ; i < L_FRAME; i++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_mac0_o( L_tmp, syn_dct_fx[i], syn_dct_fx[i], &Overflow ); -#else - L_tmp = L_mac0( L_tmp, syn_dct_fx[i], syn_dct_fx[i] ); -#endif } L_tmp = L_shr( L_tmp, 7 ); /* 2 * Q_syn2 */ st_fx->enerLH_fx = Calc_freq_ener_fx( L_tmp, shl( st_fx->Q_syn2, 1 ) ); /* Q_syn2 */ @@ -265,11 +253,7 @@ void bw_switching_pre_proc_fx( L_tmp = L_deposit_l( 0 ); FOR( i = 0; i < 32; i++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_mac0_o( L_tmp, st_fx->t_audio_q_fx[i], st_fx->t_audio_q_fx[i], &Overflow ); /* 2 * Q_syn2 */ -#else - L_tmp = L_mac0( L_tmp, st_fx->t_audio_q_fx[i], st_fx->t_audio_q_fx[i] ); -#endif } L_tmp = L_shr( L_tmp, 5 ); /* 2 * Q_syn2 */ st_fx->enerLL_fx = Calc_freq_ener_fx( L_tmp, shl( st_fx->Q_syn2, 1 ) ); /* Q_syn2 */ @@ -277,11 +261,7 @@ void bw_switching_pre_proc_fx( L_tmp = L_deposit_l( 0 ); FOR( ; i < 64; i++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_mac0_o( L_tmp, st_fx->t_audio_q_fx[i], st_fx->t_audio_q_fx[i], &Overflow ); /* 2 * Q_syn2 */ -#else - L_tmp = L_mac0( L_tmp, st_fx->t_audio_q_fx[i], st_fx->t_audio_q_fx[i] ); -#endif } L_tmp = L_shr( L_tmp, 5 ); /* 2 * Q_syn2 */ st_fx->enerLH_fx = Calc_freq_ener_fx( L_tmp, shl( st_fx->Q_syn2, 1 ) ); /* Q_syn2 */ @@ -292,11 +272,7 @@ void bw_switching_pre_proc_fx( L_tmp = L_deposit_l( 0 ); FOR( i = 0; i < L_FRAME / 2; i++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_mac0_o( L_tmp, st_fx->t_audio_q_fx[i], st_fx->t_audio_q_fx[i], &Overflow ); /* 2 * Q_syn2 */ -#else - L_tmp = L_mac0( L_tmp, st_fx->t_audio_q_fx[i], st_fx->t_audio_q_fx[i] ); -#endif } L_tmp = L_shr( L_tmp, 7 ); /* 2 * Q_syn2 */ st_fx->enerLL_fx = Calc_freq_ener_fx( L_tmp, shl( st_fx->Q_syn2, 1 ) ); /* Q_syn2 */ @@ -304,11 +280,7 @@ void bw_switching_pre_proc_fx( L_tmp = L_deposit_l( 0 ); FOR( ; i < L_FRAME; i++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_mac0_o( L_tmp, st_fx->t_audio_q_fx[i], st_fx->t_audio_q_fx[i], &Overflow ); /* 2 * Q_syn2 */ -#else - L_tmp = L_mac0( L_tmp, st_fx->t_audio_q_fx[i], st_fx->t_audio_q_fx[i] ); -#endif } L_tmp = L_shr( L_tmp, 7 ); /* 2 * Q_syn2 */ st_fx->enerLH_fx = Calc_freq_ener_fx( L_tmp, shl( st_fx->Q_syn2, 1 ) ); /* Q_syn2 */ @@ -1301,12 +1273,8 @@ ivas_error core_switching_post_dec_fx( FOR( i = 0; i < shift; i++ ) { - L_tmp = L_mult( ( *ptmp1 ), tmpF ); /*Qsynth + 16*/ -#ifdef BASOP_NOGLOB + L_tmp = L_mult( ( *ptmp1 ), tmpF ); /*Qsynth + 16*/ *ptmp1 = round_fx_sat( L_mac_sat( L_tmp, add_sat( sub( 24576, tmpF ), 8192 ), ( *ptmp2 ) ) ); /*Qsynth*/ -#else - *ptmp1 = round_fx( L_mac( L_tmp, add( sub( 24576, tmpF ), 8192 ), ( *ptmp2 ) ) ); /*Qsynth*/ -#endif ptmp1++; ptmp2++; tmpF = add( tmpF, tmp ); @@ -1325,12 +1293,8 @@ ivas_error core_switching_post_dec_fx( ptmp2 = hHQ_core->fer_samples_fx; FOR( i = 0; i < shift; i++ ) { - L_tmp = L_mult( ( *ptmp1 ), tmpF ); /*Qsynth + 16*/ -#ifdef BASOP_NOGLOB + L_tmp = L_mult( ( *ptmp1 ), tmpF ); /*Qsynth + 16*/ *ptmp1 = round_fx_sat( L_mac_sat( L_tmp, add_sat( sub( 24576, tmpF ), 8192 ), ( *ptmp2 ) ) ); /*Qsynth*/ -#else - *ptmp1 = round_fx( L_mac( L_tmp, add( sub( 24576, tmpF ), 8192 ), ( *ptmp2 ) ) ); /*Qsynth*/ -#endif move16(); tmpF = add( tmpF, tmp ); ptmp1++; @@ -1753,12 +1717,8 @@ ivas_error core_switching_post_dec_ivas_fx( FOR( i = 0; i < shift; i++ ) { - L_tmp = L_mult( ( *ptmp1 ), tmpF ); /*Qsynth + 16*/ -#ifdef BASOP_NOGLOB + L_tmp = L_mult( ( *ptmp1 ), tmpF ); /*Qsynth + 16*/ *ptmp1 = round_fx_sat( L_mac_sat( L_tmp, add_sat( sub( 24576, tmpF ), 8192 ), ( *ptmp2 ) ) ); /*Qsynth*/ -#else - *ptmp1 = round_fx( L_mac( L_tmp, add( sub( 24576, tmpF ), 8192 ), ( *ptmp2 ) ) ); /*Qsynth*/ -#endif ptmp1++; ptmp2++; tmpF = add( tmpF, tmp ); @@ -1777,12 +1737,8 @@ ivas_error core_switching_post_dec_ivas_fx( ptmp2 = hHQ_core->fer_samples_fx; FOR( i = 0; i < shift; i++ ) { - L_tmp = L_mult( ( *ptmp1 ), tmpF ); /*Qsynth + 16*/ -#ifdef BASOP_NOGLOB + L_tmp = L_mult( ( *ptmp1 ), tmpF ); /*Qsynth + 16*/ *ptmp1 = round_fx_sat( L_mac_sat( L_tmp, add_sat( sub( 24576, tmpF ), 8192 ), ( *ptmp2 ) ) ); /*Qsynth*/ -#else - *ptmp1 = round_fx( L_mac( L_tmp, add( sub( 24576, tmpF ), 8192 ), ( *ptmp2 ) ) ); /*Qsynth*/ -#endif move16(); tmpF = add( tmpF, tmp ); ptmp1++; diff --git a/lib_dec/d_gain2p_fx.c b/lib_dec/d_gain2p_fx.c index 3af3affc3e792c8ee82c453d53181a0e24574b24..4d1c101c05441b731f8d866b3d1b8e5cc92c40e3 100644 --- a/lib_dec/d_gain2p_fx.c +++ b/lib_dec/d_gain2p_fx.c @@ -43,11 +43,7 @@ static Word32 calc_gain_code_fx( Word16 g_code, Word16 gcode0, Word16 exp_gcode0 L_tmp = L_mult( g_code, gcode0 ); /* Q11*Q15 -> Q27 */ exp_gcode0 = add( exp_gcode0, -11 ); -#ifdef BASOP_NOGLOB L_tmp = L_shl_sat( L_tmp, exp_gcode0 ); /* Q27 -> Q16 */ -#else - L_tmp = L_shl( L_tmp, exp_gcode0 ); /* Q27 -> Q16 */ -#endif return L_tmp; } @@ -81,11 +77,7 @@ static void Mode2_gain_dec_mless_fx( /**gain_inov = 1.0f / (float)sqrt( ( dot_product( code, code, lcode ) + 0.01f ) / lcode);*/ L_tmp = calc_gain_inov( code, lcode, &L_tmp1, &exp_L_tmp1 ); -#ifdef BASOP_NOGLOB *gain_inov = round_fx_sat( L_shl_sat( L_tmp, 15 - 3 ) ); /* gain_inov in Q12 */ -#else - *gain_inov = round_fx( L_shl( L_tmp, 15 - 3 ) ); /* gain_inov in Q12 */ -#endif move16(); /*-----------------------------------------------------------------* * Select the gains quantization table @@ -203,11 +195,7 @@ static void gain_dec_uv_fx( move16(); *past_gcode = L_tmp; move32(); -#ifdef BASOP_NOGLOB L_tmp = L_shl_sat( Mpy_32_16_1( L_tmp, *gain_inov ), 3 ); /* Q16*Q12 -> Q13 -> Q16 */ -#else - L_tmp = L_shl( Mpy_32_16_1( L_tmp, *gain_inov ), 3 ); /* Q16*Q12 -> Q13 -> Q16 */ -#endif *gain_code = L_tmp; move32(); @@ -269,11 +257,7 @@ static void gain_dec_gacelp_uv_fx( /* g_code2 = pred_nrg_frame * norm_code2; */ L_tmp = Mpy_32_16_1( pred_nrg_frame, norm_code2 ); /* 18Q13 */ i = norm_l( L_tmp ); -#ifdef BASOP_NOGLOB g_code2 = round_fx_sat( L_shl_sat( L_tmp, i ) ); -#else - g_code2 = round_fx( L_shl( L_tmp, i ) ); -#endif exp_gcode2 = sub( 18, i ); /*-----------------------------------------------------------------* @@ -313,11 +297,7 @@ static void gain_dec_gacelp_uv_fx( *past_gcode = L_shl( L_tmp1, sub( exp_L_tmp1, 15 ) ); /* Q16 */ move32(); -#ifdef BASOP_NOGLOB *gain_code = L_shl_sat( Mpy_32_16_1( *past_gcode, *gain_inov ), 3 ); -#else - *gain_code = L_shl( Mpy_32_16_1( *past_gcode, *gain_inov ), 3 ); -#endif move32(); diff --git a/lib_dec/dec_ace_fx.c b/lib_dec/dec_ace_fx.c index df518a39549fff9de4220971f06d99556c8a9ec9..e327d4cfb958cacf783da1add249812e3336ceab 100644 --- a/lib_dec/dec_ace_fx.c +++ b/lib_dec/dec_ace_fx.c @@ -508,27 +508,15 @@ void decoder_acelp_fx( Ltmp = Mpy_32_16_1( gain_code2, code2[i] ); Ltmp = L_shl( Ltmp, add( 5, st->Q_exc ) ); Ltmp = L_mac( Ltmp, gain_pit, exc[i + i_subfr] ); -#ifdef BASOP_NOGLOB exc2[( i + i_subfr )] = round_fx_sat( L_shl_sat( Ltmp, 1 ) ); -#else - exc2[i + i_subfr] = round_fx( L_shl( Ltmp, 1 ) ); -#endif move16(); Ltmp2 = Mpy_32_16_1( gain_code, code[i] ); Ltmp2 = L_shl( Ltmp2, add( 5, st->Q_exc ) ); Ltmp = L_add( Ltmp, Ltmp2 ); BASOP_SATURATE_WARNING_OFF_EVS -#ifdef BASOP_NOGLOB Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here */ -#else - Ltmp = L_shl( Ltmp, 1 ); /* saturation can occur here */ -#endif BASOP_SATURATE_WARNING_ON_EVS -#ifdef BASOP_NOGLOB exc[( i + i_subfr )] = round_fx_sat( Ltmp ); -#else - exc[i + i_subfr] = round_fx( Ltmp ); -#endif move16(); } tmp2 = L_SUBFR; @@ -641,12 +629,8 @@ void decoder_acelp_fx( Ltmp = Dot_productSq16HQ( 0, h1, L_SUBFR, &st->last_gain_syn_deemph_e ); st->last_gain_syn_deemph_e = add( st->last_gain_syn_deemph_e, 10 /*scaling of h1[0] and E_UTIL_synthesis * 2*/ ); move16(); -#ifdef BASOP_NOGLOB st->last_gain_syn_deemph = round_fx_sat( Sqrt32( Ltmp, &st->last_gain_syn_deemph_e ) ); // Q(15-last_gain_syn_deemph_e - (16)) move16(); -#else - st->last_gain_syn_deemph = round_fx( Sqrt32( Ltmp, &st->last_gain_syn_deemph_e ) ); -#endif /* Do the classification */ { diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index 1cfff9b84f68904f57bd8e5d3122d5fcec91af38..bdfac224f45b0efbfee46ebfe92a8acf010a9f0f 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -263,30 +263,17 @@ ivas_error decod_gen_voic_fx( Ltmp1 = L_shl_sat( Ltmp1, tmp1_fx ); /* Q16 + Q_exc */ /* Compute exc2 */ -#ifdef BASOP_NOGLOB L_tmp = L_shl_sat( L_mult( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 1 ); // Q_exc+Q14+1+1 exc2_fx[i + i_subfr_fx] = round_fx_sat( L_add_sat( L_tmp, Ltmp1 ) ); // Q_exc -#else - L_tmp = L_shl( L_mult( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 1 ); - exc2_fx[i + i_subfr_fx] = round_fx( L_add( L_tmp, Ltmp1 ) ); -#endif move16(); /* gain_pit in Q14 */ - L_tmp = L_mult( gain_code16, code_fx[i] ); // Q_exc+Q9+1 -#ifdef BASOP_NOGLOB + L_tmp = L_mult( gain_code16, code_fx[i] ); // Q_exc+Q9+1 L_tmp = L_shl_sat( L_tmp, 5 ); // Q_exc+Q9+1+5 L_tmp = L_mac_sat( L_tmp, exc_fx[i + i_subfr_fx], gain_pit_fx ); // Q_exc+Q15 +1 L_tmp = L_shl_sat( L_tmp, 1 ); /* saturation can occur here */ exc_fx[i + i_subfr_fx] = round_fx_sat( L_add_sat( L_tmp, Ltmp1 ) ); // Q_exc move16(); -#else - L_tmp = L_shl( L_tmp, 5 ); - L_tmp = L_mac( L_tmp, exc_fx[i + i_subfr_fx], gain_pit_fx ); - L_tmp = L_shl( L_tmp, 1 ); /* saturation can occur here */ - - exc_fx[i + i_subfr_fx] = round_fx( L_add( L_tmp, Ltmp1 ) ); -#endif } } ELSE @@ -349,13 +336,8 @@ ivas_error decod_gen_voic_fx( prev_spch_nrg = L_deposit_l( 1 ); FOR( i = 0; i < rint_bfi_pitch; i++ ) { -#ifdef BASOP_NOGLOB prev_res_nrg = L_mac0_sat( prev_res_nrg, *p_exc, *p_exc ); /* 2*st_fx->prev_Q_exc_fr */ prev_spch_nrg = L_mac0_sat( prev_spch_nrg, *p_syn, *p_syn ); /* 2*st_fx->prev_Q_syn_fr */ -#else - prev_res_nrg = L_mac0( prev_res_nrg, *p_exc, *p_exc ); /* 2*st_fx->prev_Q_exc_fr */ - prev_spch_nrg = L_mac0( prev_spch_nrg, *p_syn, *p_syn ); /* 2*st_fx->prev_Q_syn_fr */ -#endif p_exc++; p_syn++; } @@ -375,13 +357,8 @@ ivas_error decod_gen_voic_fx( curr_spch_nrg = L_deposit_l( 1 ); FOR( i = 0; i < rint_pitch; i++ ) { -#ifdef BASOP_NOGLOB curr_res_nrg = L_mac0_sat( curr_res_nrg, *p_exc, *p_exc ); /* 2*st_fx->Q_exc */ curr_spch_nrg = L_mac0_sat( curr_spch_nrg, *p_syn, *p_syn ); /* 2*st_fx->Q_syn */ -#else - curr_res_nrg = L_mac0( curr_res_nrg, *p_exc, *p_exc ); /* 2*st_fx->Q_exc */ - curr_spch_nrg = L_mac0( curr_spch_nrg, *p_syn, *p_syn ); /* 2*st_fx->Q_syn */ -#endif p_exc++; p_syn++; } @@ -394,11 +371,7 @@ ivas_error decod_gen_voic_fx( expa = sub( 30, add( expa, ( shl( st_fx->prev_Q_exc_fr, 1 ) ) ) ); expb = norm_l( curr_res_nrg ); -#ifdef BASOP_NOGLOB fracb = round_fx_sat( L_shl_sat( curr_res_nrg, expb ) ); /* 2*st_fx->Q_exc +expb+1 -16*/ -#else - fracb = round_fx( L_shl( curr_res_nrg, expb ) ); -#endif expb = sub( 30, add( expb, shl( st_fx->Q_exc, 1 ) ) ); scale = shr( sub( fraca, fracb ), 15 ); @@ -425,11 +398,7 @@ ivas_error decod_gen_voic_fx( expa = sub( 30, add( expa, shl( st_fx->prev_Q_syn_fr, 1 ) ) ); expb = norm_l( curr_spch_nrg ); -#ifdef BASOP_NOGLOB fracb = round_fx_sat( L_shl_sat( curr_spch_nrg, expb ) ); /* 2*st_fx->Q_syn +expb-16 */ -#else - fracb = round_fx( L_shl( curr_spch_nrg, expb ) ); -#endif expb = sub( 30, add( expb, shl( st_fx->Q_syn, 1 ) ) ); scale = shr( sub( fraca, fracb ), 15 ); @@ -452,19 +421,11 @@ ivas_error decod_gen_voic_fx( test(); test(); test(); -#ifdef BASOP_NOGLOB IF( GT_16( shl_ro( enratio, sub( 15, Qenratio ), &Overflow ), 8192 ) && /*compare with 0.25 in Q15*/ LT_16( shl_ro( enratio, sub( 10, Qenratio ), &Overflow ), 15360 ) && /*compare with 15.0 in Q10*/ GT_16( shl_ro( sp_enratio, sub( 15, Qsp_enratio ), &Overflow ), 4915 ) && /*compare with 0.15 in Q15*/ LT_16( st_fx->bfi_pitch_fx, 9600 ) && /*Q6*/ LT_16( pitch_buf_fx[NB_SUBFR16k - 1], 9600 ) ) /*Q6*/ -#else - IF( GT_16( shl_r( enratio, 15 - Qenratio ), 8192 ) && /*compare with 0.25 in Q15*/ - LT_16( shl_r( enratio, 10 - Qenratio ), 15360 ) && /*compare with 15.0 in Q10*/ - GT_16( shl_r( sp_enratio, 15 - Qsp_enratio ), 4915 ) && /*compare with 0.15 in Q15*/ - st_fx->bfi_pitch_fx < 9600 && /*Q6*/ - pitch_buf_fx[sub( NB_SUBFR16k, 1 )] < 9600 ) /*Q6*/ -#endif { IF( NE_32( ( error = DTFS_new_fx( &PREVP ) ), IVAS_ERR_OK ) ) { @@ -732,7 +693,11 @@ 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 ); } @@ -794,37 +759,20 @@ ivas_error decod_gen_voic_ivas_fx( Word32 Ltmp1; /* Contribution from AVQ layer */ Ltmp1 = L_mult( gain_preQ_fx, code_preQ_fx[i] ); /* Q2 + Q6 -> Q9*/ -#ifdef BASOP_NOGLOB - Ltmp1 = L_shl_sat( Ltmp1, tmp1_fx ); /* Q16 + Q_exc */ -#else - Ltmp1 = L_shl( Ltmp1, tmp1_fx ); /* Q16 + Q_exc */ -#endif + Ltmp1 = L_shl_sat( Ltmp1, tmp1_fx ); /* Q16 + Q_exc */ /* Compute exc2 */ -#ifdef BASOP_NOGLOB L_tmp = L_shl_sat( L_mult( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 1 ); exc2_fx[i + i_subfr_fx] = round_fx_sat( L_add_sat( L_tmp, Ltmp1 ) ); // Q_exc -#else - L_tmp = L_shl( L_mult( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 1 ); - exc2_fx[i + i_subfr_fx] = round_fx( L_add( L_tmp, Ltmp1 ) ); -#endif move16(); /* gain_pit in Q14 */ - L_tmp = L_mult( gain_code16, code_fx[i] ); // Q_exc+Q9+1 -#ifdef BASOP_NOGLOB + L_tmp = L_mult( gain_code16, code_fx[i] ); // Q_exc+Q9+1 L_tmp = L_shl_sat( L_tmp, 5 ); // Q_exc+Q9+1+5 L_tmp = L_mac_sat( L_tmp, exc_fx[i + i_subfr_fx], gain_pit_fx ); // Q_exc+16 L_tmp = L_shl_sat( L_tmp, 1 ); /* saturation can occur here */ exc_fx[i + i_subfr_fx] = round_fx_sat( L_add_sat( L_tmp, Ltmp1 ) ); // Q_exc move16(); -#else - L_tmp = L_shl( L_tmp, 5 ); - L_tmp = L_mac( L_tmp, exc_fx[i + i_subfr_fx], gain_pit_fx ); - L_tmp = L_shl( L_tmp, 1 ); /* saturation can occur here */ - - exc_fx[i + i_subfr_fx] = round_fx( L_add( L_tmp, Ltmp1 ) ); -#endif } } ELSE @@ -894,13 +842,8 @@ ivas_error decod_gen_voic_ivas_fx( move32(); FOR( i = 0; i < rint_bfi_pitch; i++ ) { -#ifdef BASOP_NOGLOB prev_res_nrg = L_mac0_sat( prev_res_nrg, *p_exc, *p_exc ); /* 2*st_fx->prev_Q_exc_fr */ prev_spch_nrg = L_mac0_sat( prev_spch_nrg, *p_syn, *p_syn ); /* 2*st_fx->prev_Q_syn_fr */ -#else - prev_res_nrg = L_mac0( prev_res_nrg, *p_exc, *p_exc ); /* 2*st_fx->prev_Q_exc_fr */ - prev_spch_nrg = L_mac0( prev_spch_nrg, *p_syn, *p_syn ); /* 2*st_fx->prev_Q_syn_fr */ -#endif p_exc++; p_syn++; } @@ -986,19 +929,11 @@ ivas_error decod_gen_voic_ivas_fx( test(); test(); test(); -#ifdef BASOP_NOGLOB IF( GT_16( shl_ro( enratio, sub( 15, Qenratio ), &Overflow ), 8192 ) && /*compare with 0.25 in Q15*/ LT_16( shl_ro( enratio, sub( 10, Qenratio ), &Overflow ), 15360 ) && /*compare with 15.0 in Q10*/ GT_16( shl_ro( sp_enratio, sub( 15, Qsp_enratio ), &Overflow ), 4915 ) && /*compare with 0.15 in Q15*/ LT_16( st_fx->bfi_pitch_fx, 9600 ) && /*Q6*/ LT_16( pitch_buf_fx[( NB_SUBFR16k - 1 )], 9600 ) ) /*Q6*/ -#else - IF( GT_16( shl_r( enratio, 15 - Qenratio ), 8192 ) && /*compare with 0.25 in Q15*/ - LT_16( shl_r( enratio, 10 - Qenratio ), 15360 ) && /*compare with 15.0 in Q10*/ - GT_16( shl_r( sp_enratio, 15 - Qsp_enratio ), 4915 ) && /*compare with 0.15 in Q15*/ - st_fx->bfi_pitch_fx < 9600 && /*Q6*/ - pitch_buf_fx[sub( NB_SUBFR16k, 1 )] < 9600 ) /*Q6*/ -#endif { IF( NE_32( ( error = DTFS_new_fx( &PREVP ) ), IVAS_ERR_OK ) ) { diff --git a/lib_dec/dec_higher_acelp_fx.c b/lib_dec/dec_higher_acelp_fx.c index 49789732cb37758d0b8c36fa349732df765fb49c..b1cb2b5161aee7a69f1a9f8c2f141baeb6af73d3 100644 --- a/lib_dec/dec_higher_acelp_fx.c +++ b/lib_dec/dec_higher_acelp_fx.c @@ -83,13 +83,8 @@ void transf_cdbk_dec_fx( } L_tmp = Mult_32_16( gain_code, gain16 ); /* Q16 * Q12 - 15 -> Q13*/ -#ifdef BASOP_NOGLOB - L_tmp = L_shl_sat( L_tmp, 5 ); /* Q13 -> Q18*/ - *gain_preQ = round_fx_sat( L_tmp ); /* Q2*/ -#else - L_tmp = L_shl( L_tmp, 5 ); /* Q13 -> Q18*/ - *gain_preQ = round_fx( L_tmp ); /* Q2*/ -#endif + L_tmp = L_shl_sat( L_tmp, 5 ); /* Q13 -> Q18*/ + *gain_preQ = round_fx_sat( L_tmp ); /* Q2*/ move16(); } ELSE @@ -154,11 +149,7 @@ void transf_cdbk_dec_fx( #endif FOR( i = 0; i < L_SUBFR; i++ ) { -#ifdef BASOP_NOGLOB code_preQ[i] = shl_o( code_preQ[i], q_Code_preQ, &Overflow ); -#else - code_preQ[i] = shl( code_preQ[i], q_Code_preQ ); -#endif move16(); /* code_preQ in Q6*/ } diff --git a/lib_dec/dec_pit_exc_fx.c b/lib_dec/dec_pit_exc_fx.c index f3bb07aef0387a63838dd1ed88806984ee88d6e0..4e18eebce4bfc689e7c6fd9e9fc04aa1796636dd 100644 --- a/lib_dec/dec_pit_exc_fx.c +++ b/lib_dec/dec_pit_exc_fx.c @@ -258,11 +258,7 @@ void dec_pit_exc_fx( gain_pit_fx = st_fx->lp_gainp_fx; move16(); } -#ifdef BASOP_NOGLOB gain_code_fx = L_mult0( s_max( sub( 32767, shl_o( gain_pit_fx, 1, &Overflow ) ), 16384 ), st_fx->lp_gainc_fx ); /* Use gain pitch and past gain code as an indicator to help finding the best scaling value. gain_code_fx used a temp var*/ -#else - gain_code_fx = L_mult0( s_max( sub( 32767, shl( gain_pit_fx, 1 ) ), 16384 ), st_fx->lp_gainc_fx ); /* Use gain pitch and past gain code as an indicator to help finding the best scaling value. gain_code_fx used a temp var*/ -#endif } /*----------------------------------------------------------------------* @@ -284,13 +280,8 @@ void dec_pit_exc_fx( { FOR( i = 0; i < L_subfr_fx; i++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_shl_sat( L_mult( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 1 ); /*Q16+Q_exc*/ exc_fx[i + i_subfr_fx] = round_fx_sat( L_tmp ); /*Q_exc*/ -#else - L_tmp = L_shl( L_mult( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 1 ); /*Q16+Q_exc*/ - exc_fx[i + i_subfr_fx] = round_fx( L_tmp ); /*Q_exc*/ -#endif move16(); } } @@ -301,11 +292,7 @@ void dec_pit_exc_fx( FOR( i = 0; i < L_subfr_fx; i++ ) { L_tmp = L_mult( gain_pitx2, exc_fx[i + i_subfr_fx] ); /*Q16+Q_exc*/ -#ifdef BASOP_NOGLOB - exc_fx[i + i_subfr_fx] = round_fx_sat( L_tmp ); /*Q_exc*/ -#else - exc_fx[i + i_subfr_fx] = round_fx( L_tmp ); /*Q_exc*/ -#endif + exc_fx[i + i_subfr_fx] = round_fx_sat( L_tmp ); /*Q_exc*/ move16(); } } @@ -694,11 +681,7 @@ void dec_pit_exc_ivas_fx( gain_pit_fx = st_fx->lp_gainp_fx; move16(); } -#ifdef BASOP_NOGLOB gain_code_fx = L_mult0( s_max( sub( 32767, shl_o( gain_pit_fx, 1, &Overflow ) ), 16384 /*0.5.Q15*/ ), st_fx->lp_gainc_fx ); /* Use gain pitch and past gain code as an indicator to help finding the best scaling value. gain_code_fx used a temp var*/ -#else - gain_code_fx = L_mult0( s_max( sub( 32767, shl( gain_pit_fx, 1 ) ), 16384 ), st_fx->lp_gainc_fx ); /* Use gain pitch and past gain code as an indicator to help finding the best scaling value. gain_code_fx used a temp var*/ -#endif } /*----------------------------------------------------------------------* diff --git a/lib_dec/dec_post_fx.c b/lib_dec/dec_post_fx.c index 27abd7b2d416e2e029a0e6aa18e187431164b579..a4f618a3fd751dec1eeea852d8e26230a86f39c8 100644 --- a/lib_dec/dec_post_fx.c +++ b/lib_dec/dec_post_fx.c @@ -86,7 +86,7 @@ void nb_post_filt_fx( const Word16 tmp_noise, /* i : noise energy Q0 */ Word16 *Synth, /* i : 12k8 synthesis Qsyn */ const Word16 *Aq, /* i : LP filter coefficient Q12 */ - const Word16 *Pitch_buf, /* i : Fractionnal subframe pitch buffer Q6 */ + const Word16 *Pitch_buf, /* i : Fractionnal subframe pitch buffer Q0 */ const Word16 coder_type, /* i : coder_type */ const Word16 BER_detect, /* i : BER detect flag */ const Word16 disable_hpf /* i : flag to diabled HPF */ @@ -142,7 +142,7 @@ void nb_post_filt_fx( move16(); FOR( i = 0; i < L_frame; i += L_SUBFR ) { - T0_first = Pitch_buf[j]; // Q6 + T0_first = Pitch_buf[j]; // Q0 move16(); Dec_postfilt_fx( hPFstat, T0_first, &Pf_in[i], p_Aq, &Synth[i], Post_G1, Post_G2, Gain_factor, disable_hpf ); @@ -179,7 +179,7 @@ void nb_post_filt_fx( *----------------------------------------------------------------------------*/ static void Dec_postfilt_fx( PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */ - const Word16 t0, /* i : pitch delay given by coder Q6 */ + const Word16 t0, /* i : pitch delay given by coder Q0 */ const Word16 *signal_ptr, /* i : input signal (pointer to current subframe Q0 */ const Word16 *coeff, /* i : LPC coefficients for current subframe Q12 */ Word16 *sig_out, /* o : postfiltered output Q15*/ @@ -703,11 +703,7 @@ static void modify_pst_param_fx( test(); IF( NE_16( coder_type, INACTIVE ) && LT_16( lp_noise, LP_NOISE_THR_FX ) ) { -#ifdef BASOP_NOGLOB lp_noiseQ12 = shl_o( lp_noise, 4, &Overflow ); /* to go from Q8 to Q12 */ -#else - lp_noiseQ12 = shl( lp_noise, 4 ); /* to go from Q8 to Q12 */ -#endif /* ftmp = lp_noise*BG1_FX + CG1_FX */ tmp = mac_r( CG1_FX * 65536L, lp_noiseQ12, BG1_FX * 8 ); /* x8 to go from Q12 to Q15 */ @@ -753,7 +749,7 @@ static void modify_pst_param_fx( * Perform harmonic postfilter *----------------------------------------------------------------------------*/ static void pst_ltp_fx( - Word16 t0, /* i : pitch delay given by coder Q6 */ + Word16 t0, /* i : pitch delay given by coder Q0 */ Word16 *ptr_sig_in, /* i : postfilter i filter (residu2) Qx */ Word16 *ptr_sig_pst0, /* o : harmonic postfilter o Qx */ Word16 gain_factor /* i : Gain Factor (Q15) */ @@ -846,11 +842,7 @@ static void pst_ltp_fx( FOR( i = 0; i < L_SUBFR; i++ ) { /* nb_sh_sig may be >0, <0 or =0 */ -#ifdef BASOP_NOGLOB ptr_y_up[i] = shl_sat( ptr_y_up[i], nb_sh_sig ); -#else - ptr_y_up[i] = shl( ptr_y_up[i], nb_sh_sig ); -#endif move16(); } } @@ -884,11 +876,7 @@ static void pst_ltp_fx( /* decrease gain in noisy condition */ /* gain_plt += (1.0f-gain_plt) * gain_factor */ /* gain_plt = gain_plt + gain_factor - gain_plt*gain_factor */ -#ifdef BASOP_NOGLOB gain_plt = msu_ro( L_msu( L_deposit_h( gain_plt ), gain_plt, gain_factor ), -32768, gain_factor, &Overflow ); // Q15 -#else - gain_plt = msu_r( L_msu( L_deposit_h( gain_plt ), gain_plt, gain_factor ), -32768, gain_factor ); -#endif /** filtering by H0(z) = harmonic filter **/ filt_plt_fx( ptr_sig_in, ptr_y_up, ptr_sig_pst0, gain_plt ); @@ -944,11 +932,7 @@ static void search_del_fx( L_acc = L_mult( ptr_sig_in[0], ptr_sig_in[0] ); FOR( i = 1; i < L_SUBFR; i++ ) { -#ifdef BASOP_NOGLOB L_acc = L_mac_sat( L_acc, ptr_sig_in[i], ptr_sig_in[i] ); -#else - L_acc = L_mac( L_acc, ptr_sig_in[i], ptr_sig_in[i] ); -#endif } IF( L_acc == 0 ) { @@ -985,20 +969,12 @@ static void search_del_fx( L_acc = L_mult( ptr_sig_in[0], ptr_sig_past[0] ); FOR( n = 1; n < L_SUBFR; n++ ) { -#ifdef BASOP_NOGLOB L_acc = L_mac_sat( L_acc, ptr_sig_in[n], ptr_sig_past[n] ); -#else - L_acc = L_mac( L_acc, ptr_sig_in[n], ptr_sig_past[n] ); -#endif } L_acc = L_max( L_acc, 0 ); -#ifdef BASOP_NOGLOB L_temp = L_sub_sat( L_acc, L_num_int ); -#else - L_temp = L_sub( L_acc, L_num_int ); -#endif if ( L_temp > 0L ) { i_max = (Word16) i; @@ -1032,11 +1008,7 @@ static void search_del_fx( { temp = *ptr_sig_past++; move16(); -#ifdef BASOP_NOGLOB L_acc = L_mac_sat( L_acc, temp, temp ); -#else - L_acc = L_mac( L_acc, temp, temp ); -#endif } IF( L_acc == 0L ) { @@ -1094,30 +1066,18 @@ static void search_del_fx( L_acc = L_mult( ptr_y_up[1], ptr_y_up[1] ); FOR( n = 2; n < L_SUBFR; n++ ) { -#ifdef BASOP_NOGLOB L_acc = L_mac_sat( L_acc, ptr_y_up[n], ptr_y_up[n] ); -#else - L_acc = L_mac( L_acc, ptr_y_up[n], ptr_y_up[n] ); -#endif } L_temp0 = L_acc; /* sets to 'L_acc' in 1 clock (saved for den1) */ move32(); /* den0 */ -#ifdef BASOP_NOGLOB L_acc = L_mac_sat( L_acc, ptr_y_up[0], ptr_y_up[0] ); -#else - L_acc = L_mac( L_acc, ptr_y_up[0], ptr_y_up[0] ); -#endif *ptr_L_den0 = L_acc; move32(); /* den1 */ -#ifdef BASOP_NOGLOB L_acc = L_mac_sat( L_temp0, ptr_y_up[L_SUBFR], ptr_y_up[L_SUBFR] ); -#else - L_acc = L_mac( L_temp0, ptr_y_up[L_SUBFR], ptr_y_up[L_SUBFR] ); -#endif *ptr_L_den1 = L_acc; move32(); @@ -1208,11 +1168,7 @@ static void search_del_fx( L_acc = L_mult( ptr_sig_in[0], ptr_y_up[0] ); FOR( n = 1; n < L_SUBFR; n++ ) { -#ifdef BASOP_NOGLOB L_acc = L_mac_sat( L_acc, ptr_sig_in[n], ptr_y_up[n] ); -#else - L_acc = L_mac( L_acc, ptr_sig_in[n], ptr_y_up[n] ); -#endif } L_acc = L_shr( L_acc, sh_num ); /* sh_num > 0 */ L_acc = L_max( 0, L_acc ); @@ -1245,11 +1201,7 @@ static void search_del_fx( L_acc = L_mult( ptr_sig_in[0], ptr_y_up[0] ); FOR( n = 1; n < L_SUBFR; n++ ) { -#ifdef BASOP_NOGLOB L_acc = L_mac_sat( L_acc, ptr_sig_in[n], ptr_y_up[n] ); -#else - L_acc = L_mac( L_acc, ptr_sig_in[n], ptr_y_up[n] ); -#endif } L_acc = L_shr( L_acc, sh_num ); /* sh_num > 0 */ L_acc = L_max( 0, L_acc ); @@ -1461,11 +1413,7 @@ static void compute_ltp_l_fx( L_acc = L_mult( y_up[0], y_up[0] ); FOR( n = 1; n < L_SUBFR; n++ ) { -#ifdef BASOP_NOGLOB L_acc = L_mac_sat( L_acc, y_up[n], y_up[n] ); -#else - L_acc = L_mac( L_acc, y_up[n], y_up[n] ); -#endif } temp = sub( 16, norm_l( L_acc ) ); temp = s_max( temp, 0 ); @@ -1701,11 +1649,7 @@ void Filt_mu_fx( temp = sub( 1, abs_s( mu ) ); BASOP_SATURATE_WARNING_OFF_EVS; -#ifdef BASOP_NOGLOB mu2 = add_o( 32767, temp, &Overflow ); /* Q15 (1 - |mu|) */ -#else - mu2 = add( 32767, temp ); /* 2**15 (1 - |mu|) */ -#endif BASOP_SATURATE_WARNING_ON_EVS; ga = div_s( fact, mu2 ); /* Q(sh_fact) / (1 - |mu|) */ @@ -1719,19 +1663,11 @@ void Filt_mu_fx( L_temp = L_mac( L_acc, 16384, *ptrs ); /* sig_in(n) * 2**15 */ L_temp = Madd_32_16( L_fact, L_temp, ga ); -#ifdef BASOP_NOGLOB L_temp = L_shr_sat( L_temp, sh_fact ); /* mult. temp x ga */ -#else - L_temp = L_shr( L_temp, sh_fact ); /* mult. temp x ga */ -#endif BASOP_SATURATE_WARNING_OFF_EVS; /*sig_out[n] = saturate(L_temp); move16();*/ -#ifdef BASOP_NOGLOB sig_out[n] = round_fx_sat( L_temp ); move16(); -#else - sig_out[n] = round_fx( L_temp ); -#endif BASOP_SATURATE_WARNING_ON_EVS; } @@ -1807,11 +1743,7 @@ void Filt_mu_ivas_fx( temp = sub( 1, abs_s( mu ) ); BASOP_SATURATE_WARNING_OFF_EVS; -#ifdef BASOP_NOGLOB mu2 = add_o( 32767, temp, &Overflow ); /* Q15 (1 - |mu|) */ -#else - mu2 = add( 32767, temp ); /* 2**15 (1 - |mu|) */ -#endif BASOP_SATURATE_WARNING_ON_EVS; ga = div_s( fact, mu2 ); /* Q(sh_fact) / (1 - |mu|) */ @@ -1829,11 +1761,7 @@ void Filt_mu_ivas_fx( BASOP_SATURATE_WARNING_OFF_EVS; /*sig_out[n] = saturate(L_temp); move16();*/ -#ifdef BASOP_NOGLOB sig_out[n] = round_fx_sat( L_temp ); -#else - sig_out[n] = round_fx( L_temp ); -#endif BASOP_SATURATE_WARNING_ON_EVS; } @@ -1917,11 +1845,7 @@ void scale_st_fx( } /* L_gain_in/L_gain_out in Q14 */ /* overflows if L_gain_in > 2 * L_gain_out */ -#ifdef BASOP_NOGLOB - g0 = shr_sat( g0, sh_g0 ); /* sh_g0 may be >0, <0, or =0 */ -#else - g0 = shr( g0, sh_g0 ); /* sh_g0 may be >0, <0, or =0 */ -#endif + g0 = shr_sat( g0, sh_g0 ); /* sh_g0 may be >0, <0, or =0 */ g0 = mult_r( g0, AGC_FAC1_FX ); /* L_gain_in/L_gain_out * AGC_FAC1_FX */ } @@ -1934,13 +1858,8 @@ void scale_st_fx( temp = mult_r( AGC_FAC_FX, gain ); gain = add( temp, g0 ); /* in Q14 */ L_temp = L_mult( gain, sig_out[i] ); -#ifdef BASOP_NOGLOB L_temp = L_shl_sat( L_temp, 1 ); sig_out[i] = round_fx_sat( L_temp ); -#else - L_temp = L_shl( L_temp, 1 ); - sig_out[i] = round_fx( L_temp ); -#endif move16(); } *gain_prec = gain; @@ -1975,15 +1894,9 @@ void blend_subfr2_fx( move16(); FOR( i = 0; i < L_SUBFR / 2; i++ ) { -#ifdef BASOP_NOGLOB sigOut[i] = mac_ro( L_mult_o( fac1, sigIn1[i], &Overflow ), fac2, sigIn2[i], &Overflow ); // Qx fac1 = sub_o( fac1, step, &Overflow ); fac2 = add_o( fac2, step, &Overflow ); -#else - sigOut[i] = mac_r( L_mult( fac1, sigIn1[i] ), fac2, sigIn2[i] ); - fac1 = sub( fac1, step ); - fac2 = add( fac2, step ); -#endif move16(); } diff --git a/lib_dec/dec_tcx.c b/lib_dec/dec_tcx.c index ae0474f3d987d452a00f59905bd09924038a8e21..708527df5fa21a97b807fd13f934b06c56d1cac1 100644 --- a/lib_dec/dec_tcx.c +++ b/lib_dec/dec_tcx.c @@ -237,6 +237,7 @@ void decoder_tcx_imdct_fx( Word16 q_a_itf = 15; Word16 x_e = sub( 31, q_x ); move16(); + Word16 shift_q = sub( q_x, q_win ); /*-----------------------------------------------------------------* * Initializations @@ -364,9 +365,10 @@ void decoder_tcx_imdct_fx( IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) { + Word16 copy_len = s_min( L_FRAME48k, s_max( L_spec, s_max( L_frame, L_frameTCX ) ) ); set32_fx( x_tmp_fx, 0, L_FRAME_PLUS ); - Copy32( x_fx, x_tmp_fx, s_min( L_FRAME48k, s_max( L_spec, s_max( L_frame, L_frameTCX ) ) ) ); // q_x - Copy32( x_fx, xn_bufFB_fx, s_min( L_FRAME48k, s_max( L_spec, s_max( L_frame, L_frameTCX ) ) ) ); // q_x + Copy32( x_fx, x_tmp_fx, copy_len ); // q_x + Copy32( x_fx, xn_bufFB_fx, copy_len ); // q_x } ELSE IF( ( st->element_mode == EVS_MONO ) ) { @@ -374,8 +376,9 @@ void decoder_tcx_imdct_fx( } ELSE { - Copy32( x_fx, x_tmp_fx, s_max( L_spec, s_max( L_frame, L_frameTCX ) ) ); // q_x - Copy32( x_fx, xn_bufFB_fx, s_max( L_spec, s_max( L_frame, L_frameTCX ) ) ); // q_x + Word16 copy_len = s_max( L_spec, s_max( L_frame, L_frameTCX ) ); + Copy32( x_fx, x_tmp_fx, copy_len ); // q_x + Copy32( x_fx, xn_bufFB_fx, copy_len ); // q_x } IF( ( st->igf != 0 ) ) @@ -416,24 +419,29 @@ void decoder_tcx_imdct_fx( FOR( Word16 ind = 0; ind < L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX; ind++ ) { - xn_bufFB_fx_16[ind] = extract_l( L_shr( xn_bufFB_fx[ind], sub( q_x, q_win ) ) ); // q_x + xn_bufFB_fx_16[ind] = extract_l( L_shr( xn_bufFB_fx[ind], shift_q ) ); // q_x move16(); } + + Word16 ratio_e; + Word16 ratio = BASOP_Util_Divide1616_Scale( L_frameTCX_glob, L_frame_glob, &ratio_e ); // Q = 15-ratio_e. * FSCALE_DENOM is (1 << 9) + ratio = shr( ratio, sub( 6, ratio_e ) ); + IF( st->element_mode != EVS_MONO ) { IMDCT_ivas_fx( x_tmp_fx, q_x, hTcxDec->syn_OverlFB, hTcxDec->syn_Overl_TDACFB, xn_bufFB_fx_16, hTcxCfg->tcx_aldo_window_1_FB, hTcxCfg->tcx_aldo_window_1_FB_trunc, hTcxCfg->tcx_aldo_window_2_FB, hTcxCfg->tcx_mdct_window_halfFB, hTcxCfg->tcx_mdct_window_minimumFB, hTcxCfg->tcx_mdct_window_transFB, hTcxCfg->tcx_mdct_window_half_lengthFB, hTcxCfg->tcx_mdct_window_min_lengthFB, index, - kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, max( L_frameTCX, L_spec ) >> 1, L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, 1, st, FSCALE_DENOM * L_frameTCX_glob / L_frame_glob, acelp_zir_fx, q_win ); + kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, 1, st, ratio, acelp_zir_fx, q_win ); } ELSE { IMDCT_ivas_fx( x_fx, q_x, hTcxDec->syn_OverlFB, hTcxDec->syn_Overl_TDACFB, xn_bufFB_fx_16, hTcxCfg->tcx_aldo_window_1_FB, hTcxCfg->tcx_aldo_window_1_FB_trunc, hTcxCfg->tcx_aldo_window_2_FB, hTcxCfg->tcx_mdct_window_halfFB, hTcxCfg->tcx_mdct_window_minimumFB, hTcxCfg->tcx_mdct_window_transFB, hTcxCfg->tcx_mdct_window_half_lengthFB, hTcxCfg->tcx_mdct_window_min_lengthFB, index, - kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, 1, st, FSCALE_DENOM * L_frameTCX_glob / L_frame_glob, acelp_zir_fx, q_win ); + kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, 1, st, ratio, acelp_zir_fx, q_win ); } FOR( Word16 ind = 0; ind < L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX; ind++ ) { - xn_bufFB_fx[ind] = L_shl( xn_bufFB_fx_16[ind], sub( q_x, q_win ) ); // Q_x + xn_bufFB_fx[ind] = L_shl( L_deposit_l( xn_bufFB_fx_16[ind] ), shift_q ); // Q_x } IF( ( bfi == 0 ) ) @@ -453,19 +461,22 @@ void decoder_tcx_imdct_fx( IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) { - res_m = BASOP_Util_Divide1616_Scale( L_frame_glob, L_FRAME, &res_e ); - st->old_fpitch = L_shl( Mpy_32_16_1( st->old_fpitch, res_m ), res_e ); + // Using sat as a single instruction shifts and extracts + st->old_fpitch = W_shl_sat_l( W_mult0_32_32( st->old_fpitch, L_frame_glob ), -8 ); // Divide by 256 ==> SHR by 8 + move32(); } IF( GT_16( st->element_mode, EVS_MONO ) ) { res_m = BASOP_Util_Divide1616_Scale( L_frameTCX_glob, L_frame_glob, &res_e ); st->old_fpitchFB = L_shl( Mpy_32_16_1( st->old_fpitch, res_m ), res_e ); + move32(); } ELSE { res_m = BASOP_Util_Divide1616_Scale( L_frameTCX, L_frame, &res_e ); st->old_fpitchFB = L_shl( Mpy_32_16_1( st->old_fpitch, res_m ), res_e ); + move32(); } } @@ -475,7 +486,7 @@ void decoder_tcx_imdct_fx( Copy( xn_buf_fx + L_frame, hTcxDec->syn_Overl, overlap ); // Q(-2) FOR( Word16 ind = 0; ind < overlapFB; ind++ ) { - hTcxDec->syn_OverlFB[ind] = (Word16) L_shr( xn_bufFB_fx[( ind + L_frameTCX )], sub( q_x, q_win ) ); // q_x + hTcxDec->syn_OverlFB[ind] = extract_l( L_shr( xn_bufFB_fx[( ind + L_frameTCX )], shift_q ) ); // q_x } } @@ -483,7 +494,7 @@ void decoder_tcx_imdct_fx( Copy( xn_buf_fx + sub( shr( overlap, 1 ), tcx_offset ), synth_fx, L_frame_glob ); // Q(-2) FOR( Word16 ind = 0; ind < L_frameTCX_glob; ind++ ) { - synthFB_fx[ind] = (Word16) L_shr( xn_bufFB_fx[( ind + ( ( overlapFB >> 1 ) - tcx_offsetFB ) )], sub( q_x, q_win ) ); // q_x + synthFB_fx[ind] = extract_l( L_shr( xn_bufFB_fx[( ind + ( ( overlapFB >> 1 ) - tcx_offsetFB ) )], shift_q ) ); // q_x } diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 20f7d297d739e3030ff5c8bdb468b1b7c12a6097..a0556437dbdba05954c2ae8cef80c71761abf197 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -434,11 +434,7 @@ void decoder_tcx_fx( gain_tcx_e = add( extract_l( L_shr( tmp32, 25 ) ), 1 ); /* get exponent */ gain_tcx = round_fx( BASOP_Util_InvLog2( L_or( tmp32, (Word32) 0xFE000000 ) ) ); -#ifdef BASOP_NOGLOB tmp1 = mult_r( shl_sat( L_spec, 5 ), 26214 /*128.f/NORM_MDCT_FACTOR Q15*/ ); -#else - tmp1 = mult_r( shl( L_spec, 5 ), 26214 /*128.f/NORM_MDCT_FACTOR Q15*/ ); -#endif s = 15 - 5 - 7; move16(); IF( GE_16( L_spec, 1024 ) ) /*reduce precision for avoiding overflow*/ @@ -553,11 +549,7 @@ void decoder_tcx_fx( st->last_gain_syn_deemph_e = add( st->last_gain_syn_deemph_e, 10 /*scaling of h1[0] and E_UTIL_synthesis * 2*/ ); move16(); tmp32 = Sqrt32( tmp32, &st->last_gain_syn_deemph_e ); -#ifdef BASOP_NOGLOB st->last_gain_syn_deemph = round_fx_o( tmp32, &Overflow ); -#else - st->last_gain_syn_deemph = round_fx( tmp32 ); -#endif move16(); /*for avoiding compiler warnings*/ hTcxDec->gainHelper = 32768 / 2; @@ -575,11 +567,7 @@ void decoder_tcx_fx( /* gainCompensate = st->last_gain_syn_deemph/(float)sqrt(dot_product( h1, h1, L_SUBFR)); */ tmp32 = Dot_productSq16HQ( 0, h1, L_SUBFR, &gainCompensate_e ) /*Q15, gainCompensate_e*/; gainCompensate_e = add( gainCompensate_e, 10 /*scaling of h1[0] and E_UTIL:synthesis*/ ); -#ifdef BASOP_NOGLOB gainCompensate = round_fx_sat( Sqrt32( tmp32, &gainCompensate_e ) ) /*Q15, gainCompensate_e*/; -#else - gainCompensate = round_fx( Sqrt32( tmp32, &gainCompensate_e ) ) /*Q15, gainCompensate_e*/; -#endif BASOP_Util_Divide_MantExp( st->last_gain_syn_deemph, st->last_gain_syn_deemph_e, gainCompensate, @@ -752,11 +740,7 @@ void decoder_tcx_fx( tmp32 = L_deposit_l( 0 ); FOR( i = 0; i < L_spec; i++ ) { -#ifdef BASOP_NOGLOB tmp32 = L_macNs_co( tmp32, abs_s( prm_sqQ[i] ), i, &Carry, &Overflow ); -#else - tmp32 = L_macNs( tmp32, abs_s( prm_sqQ[i] ), i ); -#endif } nf_seed = extract_l( tmp32 ); } @@ -876,11 +860,7 @@ void decoder_tcx_fx( BASOP_Util_Divide_MantExp( extract_h( E_2ndlast ), exp2, extract_h( E_last ), exp1, &tmp1, &tmp2 ); tmp1 = shr( tmp1, 2 ); /*Q13*/ -#ifdef BASOP_NOGLOB tmp1 = shl_sat( tmp1, tmp2 ); -#else - tmp1 = shl( tmp1, tmp2 ); -#endif /* replace higher energy TCX5 frame by lower one to avoid energy fluctuation */ IF( GT_16( tmp1, 16384 /*2 in Q13*/ ) ) { @@ -1345,11 +1325,7 @@ void decoder_tcx_post_fx( Decoder_State *st_fx, FOR( i = 0; i < hTcxDec->L_frameTCX; i++ ) { tmp32 = L_shl( tmp32_1 /*Q28*/, -( 28 - 15 ) ); /*16Q15*/ -#ifdef BASOP_NOGLOB synthFB[i] = round_fx_sat( L_shl_sat( Mpy_32_16_1( tmp32, synthFB[i] ), 16 ) ); -#else - synthFB[i] = round_fx( L_shl( Mpy_32_16_1( tmp32, synthFB[i] ), 16 ) ); -#endif move16(); tmp32_1 = L_sub( tmp32_1, tmp32_2 ); } @@ -1383,11 +1359,7 @@ void decoder_tcx_post_fx( Decoder_State *st_fx, } tmp32 = Mpy_32_16_1( tmp32, getInvFrameLen( hTcxDec->L_frameTCX ) ); tmp2 = norm_l( tmp32 ); -#ifdef BASOP_NOGLOB tmp1 = round_fx_o( L_shl( tmp32, tmp2 ), &Overflow ); -#else - tmp1 = round_fx( L_shl( tmp32, tmp2 ) ); -#endif s = sub( sub( sub( 1, shl( s, 1 ) ), 6 /*table lookup for inverse framelength*/ ), tmp2 ); tmp1 = Sqrt16( tmp1, &s ); move16(); @@ -1480,71 +1452,36 @@ void decoder_tcx_post_fx( Decoder_State *st_fx, &tmp1 ); tmp2 = BASOP_Util_Add_MantExp( hTcxDec->conceal_eof_gain, 15 - 14, negate( tmp1 ), tmp2, &tmp1 ); -#ifdef BASOP_NOGLOB step = L_shl_o( L_mult( tmp1, getInvFrameLen( st_fx->L_frame ) ), sub( tmp2, 6 /*scaling from table lookup*/ + 1 /*go to Q30*/ ), &Overflow ); /*Q30*/ -#else - step = L_shl( L_mult( tmp1, getInvFrameLen( st_fx->L_frame ) ), sub( tmp2, 6 /*scaling from table lookup*/ + 1 /*go to Q30*/ ) ); /*Q30*/ -#endif { Word32 stepFB; UWord32 dmy; conceal_eof_gainFB = L_deposit_h( hTcxDec->conceal_eof_gain ); /*Q30*/ Mpy_32_32_ss( step, L_shl( L_mult0( st_fx->L_frame, getInvFrameLen( hTcxDec->L_frameTCX ) ), 8 ), &stepFB, &dmy ); -#ifdef BASOP_NOGLOB stepFB = L_shl_o( stepFB, 3 - 1, &Overflow ); /*Q30*/ -#else - stepFB = L_shl( stepFB, 3 - 1 ); /*Q30*/ -#endif FOR( i = 0; i < hTcxDec->L_frameTCX; i++ ) { -#ifdef BASOP_NOGLOB synthFB[i] = round_fx_sat( L_shl_sat( Mpy_32_16_1( conceal_eof_gainFB, synthFB[i] ), 1 ) ); -#else - synthFB[i] = round_fx( L_shl( Mpy_32_16_1( conceal_eof_gainFB, synthFB[i] ), 1 ) ); -#endif move16(); -#ifdef BASOP_NOGLOB conceal_eof_gainFB = L_sub_o( conceal_eof_gainFB, stepFB, &Overflow ); -#else - conceal_eof_gainFB = L_sub( conceal_eof_gainFB, stepFB ); -#endif } } conceal_eof_gain32 = L_deposit_h( hTcxDec->conceal_eof_gain ); /*Q30*/ FOR( i = 0; i < st_fx->L_frame; i++ ) { -#ifdef BASOP_NOGLOB xn_buf[i] = round_fx_sat( L_shl_sat( Mpy_32_16_1( conceal_eof_gain32 /*Q30*/, xn_buf[i] ), 1 ) ); -#else - xn_buf[i] = round_fx( L_shl( Mpy_32_16_1( conceal_eof_gain32 /*Q30*/, xn_buf[i] ), 1 ) ); -#endif move16(); -#ifdef BASOP_NOGLOB conceal_eof_gain32 = L_sub_o( conceal_eof_gain32, step, &Overflow ); -#else - conceal_eof_gain32 = L_sub( conceal_eof_gain32, step ); -#endif } -#ifdef BASOP_NOGLOB hTcxDec->conceal_eof_gain = round_fx_o( conceal_eof_gain32, &Overflow ); /*Q14*/ move16(); -#else - hTcxDec->conceal_eof_gain = round_fx( conceal_eof_gain32 ); /*Q14*/ - move16(); -#endif /* run lpc gain compensation not for waveform adjustment */ test(); IF( 0 == st_fx->enablePlcWaveadjust || EQ_16( st_fx->plcInfo.concealment_method, TCX_TONAL ) ) { -#ifdef BASOP_NOGLOB st_fx->plcInfo.recovery_gain = extract_h( L_shl_o( Mpy_32_16_1( conceal_eof_gainFB, st_fx->last_concealed_gain_syn_deemph ), st_fx->last_concealed_gain_syn_deemph_e, &Overflow ) ); /*Q30->Q14*/ -#else - st_fx->plcInfo.recovery_gain = extract_h( L_shl( Mpy_32_16_1( conceal_eof_gainFB, - st_fx->last_concealed_gain_syn_deemph ), - st_fx->last_concealed_gain_syn_deemph_e ) ); /*Q30->Q14*/ -#endif move16(); } ELSE @@ -1553,14 +1490,7 @@ void decoder_tcx_post_fx( Decoder_State *st_fx, move16(); } st_fx->plcInfo.step_concealgain_fx = -#ifdef BASOP_NOGLOB round_fx_sat( L_shl_sat( L_mult0( round_fx_sat( step ), round_fx_sat( L_shl_sat( L_mult0( st_fx->L_frame, getInvFrameLen( hTcxDec->L_frameTCX ) ), 8 ) ) ), 3 ) ); /*Q15*/ -#else - round_fx( L_shl( L_mult0( - round_fx( step ), - round_fx( L_shl( L_mult0( st_fx->L_frame, getInvFrameLen( hTcxDec->L_frameTCX ) ), 8 ) ) ), - 3 ) ); /*Q15*/ -#endif move16(); } @@ -1584,11 +1514,7 @@ void decoder_tcx_post_fx( Decoder_State *st_fx, move32(); Copy32( &st_fx->old_pitch_buf_fx[st_fx->nb_subfr + 2], &st_fx->old_pitch_buf_fx[2], st_fx->nb_subfr ); set32_fx( &st_fx->old_pitch_buf_fx[st_fx->nb_subfr + 2], st_fx->old_fpitch, st_fx->nb_subfr ); -#ifdef BASOP_NOGLOB /*TBV st_fx->old_fpitch seems to have an odd value for this bitstream stv48n1_dtx_sw_164_1280_48kHz.f06.COD at frame 10 */ st_fx->bfi_pitch_fx = shl_sat( round_fx( st_fx->old_fpitch ), 6 ); -#else - st_fx->bfi_pitch_fx = shl( round_fx( st_fx->old_fpitch ), 6 ); -#endif move16(); st_fx->bfi_pitch_frame = st_fx->L_frame; move16(); @@ -1678,12 +1604,8 @@ void decoder_tcx_post_ivas_fx( Decoder_State *st_fx, FOR( i = 0; i < hTcxDec->L_frameTCX; i++ ) { - tmp32 = L_shl( tmp32_1 /*Q28*/, -( 28 - 15 ) ); /*16Q15*/ -#ifdef BASOP_NOGLOB + tmp32 = L_shl( tmp32_1 /*Q28*/, -( 28 - 15 ) ); /*16Q15*/ synthFB[i] = round_fx_sat( L_shl_sat( Mpy_32_16_1( tmp32, synthFB[i] ), 16 ) ); // Q_syn -#else - synthFB[i] = round_fx( L_shl( Mpy_32_16_1( tmp32, synthFB[i] ), 16 ) ); -#endif move16(); tmp32_1 = L_sub( tmp32_1, tmp32_2 ); } @@ -1716,11 +1638,7 @@ void decoder_tcx_post_ivas_fx( Decoder_State *st_fx, } tmp32 = Mpy_32_16_1( tmp32, getInvFrameLen( hTcxDec->L_frameTCX ) ); tmp2 = norm_l( tmp32 ); -#ifdef BASOP_NOGLOB tmp1 = round_fx_o( L_shl( tmp32, tmp2 ), &Overflow ); -#else - tmp1 = round_fx( L_shl( tmp32, tmp2 ) ); -#endif // s = sub(sub(sub(1, shl(s, 1)), 6/*table lookup for inverse framelength*/), tmp2); s = sub( 25, add( shl( add( Q_syn, s ), 1 ), tmp2 ) ); tmp1 = Sqrt16( tmp1, &s ); @@ -1891,15 +1809,9 @@ void decoder_tcx_post_ivas_fx( Decoder_State *st_fx, test(); IF( 0 == st_fx->enablePlcWaveadjust || EQ_16( st_fx->plcInfo.concealment_method, TCX_TONAL ) ) { -#ifdef BASOP_NOGLOB st_fx->plcInfo.recovery_gain = extract_h( L_shl_o( Mpy_32_16_1( conceal_eof_gainFB, st_fx->last_concealed_gain_syn_deemph ), st_fx->last_concealed_gain_syn_deemph_e, &Overflow ) ); /*Q30->Q14*/ -#else - st_fx->plcInfo.recovery_gain = extract_h( L_shl( Mpy_32_16_1( conceal_eof_gainFB, - st_fx->last_concealed_gain_syn_deemph ), - st_fx->last_concealed_gain_syn_deemph_e ) ); /*Q30->Q14*/ -#endif move16(); } ELSE @@ -1908,14 +1820,7 @@ void decoder_tcx_post_ivas_fx( Decoder_State *st_fx, move16(); } st_fx->plcInfo.step_concealgain_fx = -#ifdef BASOP_NOGLOB round_fx_sat( L_shl_sat( L_mult0( round_fx_sat( L_shr_sat( step, sub( 1, step_e ) ) ), round_fx_sat( L_shl_sat( L_mult0( st_fx->L_frame, getInvFrameLen( hTcxDec->L_frameTCX ) ), 8 ) ) ), 4 ) ); /*Q15*/ -#else - round_fx( L_shl( L_mult0( - round_fx( L_shr( step, sub( 1, step_e ) ), - round_fx( L_shl( L_mult0( st_fx->L_frame, getInvFrameLen( hTcxDec->L_frameTCX ) ), 8 ) ) ), - 4 ) ); /*Q15*/ -#endif move16(); } @@ -1939,11 +1844,7 @@ void decoder_tcx_post_ivas_fx( Decoder_State *st_fx, move32(); Copy32( &st_fx->old_pitch_buf_fx[st_fx->nb_subfr + 2], &st_fx->old_pitch_buf_fx[2], st_fx->nb_subfr ); set32_fx( &st_fx->old_pitch_buf_fx[st_fx->nb_subfr + 2], st_fx->old_fpitch, st_fx->nb_subfr ); -#ifdef BASOP_NOGLOB /*TBV st_fx->old_fpitch seems to have an odd value for this bitstream stv48n1_dtx_sw_164_1280_48kHz.f06.COD at frame 10 */ st_fx->bfi_pitch_fx = shl_sat( round_fx( st_fx->old_fpitch ), 6 ); -#else - st_fx->bfi_pitch_fx = shl( round_fx( st_fx->old_fpitch ), 6 ); -#endif st_fx->bfi_pitch_frame = st_fx->L_frame; move16(); @@ -1980,7 +1881,6 @@ static Word32 CalculateAbsEnergy_fx( /* o : normalized resul move32(); L_c = 0; move32(); -#ifdef BASOP_NOGLOB /* Critical Overflow/Carry */ L_sum = L_macNs_co( L_off, 0, 0, &Carry, &Overflow ); IF( L_sum > 0 ) { @@ -1990,31 +1890,16 @@ static Word32 CalculateAbsEnergy_fx( /* o : normalized resul { L_c = L_msuNs_co( L_c, 0, 0, &Carry, &Overflow ); } -#else - L_sum = L_macNs( L_off, 0, 0 ); - if ( L_sum > 0 ) - L_c = L_macNs( L_c, 0, 0 ); - if ( L_sum < 0 ) - L_c = L_msuNs( L_c, 0, 0 ); -#endif FOR( i = 0; i < lg; i += 2 ) { Carry = 0; move32(); BASOP_SATURATE_WARNING_OFF_EVS /*multiplication of -32768 * -32768 throws an overflow, but is not critical*/ -#ifdef BASOP_NOGLOB /* Critical Overflow/Carry */ L_sum = L_macNs_co( L_sum, x[i], x[i], &Carry, &Overflow ); -#else - L_sum = L_macNs( L_sum, x[i], x[i] ); -#endif BASOP_SATURATE_WARNING_ON_EVS Overflow = 0; /* to avoid useless warning in L_macNs calling L_mult */ move32(); -#ifdef BASOP_NOGLOB /* Critical Overflow/Carry */ L_c = L_macNs_co( L_c, 0, 0, &Carry, &Overflow ); -#else - L_c = L_macNs( L_c, 0, 0 ); -#endif } L_sum = norm_llQ31( L_c, L_sum, exp ); return L_sum; @@ -2371,11 +2256,7 @@ void IMDCT_fx( Word32 *x, Word16 x_e, Word16 *old_syn_overl, Word16 *syn_Overl_T { FOR( i = 0; i < L_frame; i++ ) { -#ifdef BASOP_NOGLOB xn_buf[i] = shr_sat( xn_buf[i], Q ); -#else - xn_buf[i] = shr( xn_buf[i], Q ); -#endif move16(); } } @@ -2467,11 +2348,7 @@ void IMDCT_fx( Word32 *x, Word16 x_e, Word16 *old_syn_overl, Word16 *syn_Overl_T tmp1 = sub( overlap, tcx_mdct_window_min_length ); FOR( i = 0; i < tmp1; i++ ) { -#ifdef BASOP_NOGLOB xn_buf[i + tmp4] = shl_sat( add_sat( xn_buf[i + tmp4], shr_sat( old_out[i + nz], tmp2 ) ), TCX_IMDCT_HEADROOM ); -#else - xn_buf[i + tmp4] = shl( add( xn_buf[i + tmp4], shr( old_out[i + nz], tmp2 ) ), TCX_IMDCT_HEADROOM ); -#endif move16(); } @@ -2480,31 +2357,19 @@ void IMDCT_fx( Word32 *x, Word16 x_e, Word16 *old_syn_overl, Word16 *syn_Overl_T FOR( ; i < tmp1; i++ ) { tmp3 = mult_r( shr( old_out[i + nz], tmp2 ), tcx_mdct_window_minimum[i - overlap + tcx_mdct_window_min_length].v.re ); -#ifdef BASOP_NOGLOB xn_buf[i + tmp4] = shl_sat( add_sat( xn_buf[i + tmp4], tmp3 ), TCX_IMDCT_HEADROOM ); -#else - xn_buf[i + tmp4] = shl( add( xn_buf[i + tmp4], tmp3 ), TCX_IMDCT_HEADROOM ); -#endif move16(); } FOR( ; i < overlap; i++ ) { tmp3 = mult_r( shr( old_out[i + nz], tmp2 ), tcx_mdct_window_minimum[overlap - 1 - i].v.im ); -#ifdef BASOP_NOGLOB xn_buf[i + tmp4] = shl_sat( add_sat( xn_buf[i + tmp4], tmp3 ), TCX_IMDCT_HEADROOM ); -#else - xn_buf[i + tmp4] = shl( add( xn_buf[i + tmp4], tmp3 ), TCX_IMDCT_HEADROOM ); -#endif move16(); } FOR( i = add( i, tmp4 ); i < L_frame; i++ ) { -#ifdef BASOP_NOGLOB xn_buf[i] = shl_sat( xn_buf[i], TCX_IMDCT_HEADROOM ); -#else - xn_buf[i] = shl( xn_buf[i], TCX_IMDCT_HEADROOM ); -#endif move16(); } } @@ -2535,43 +2400,26 @@ void IMDCT_fx( Word32 *x, Word16 x_e, Word16 *old_syn_overl, Word16 *syn_Overl_T tmp3 = shr( tcx_mdct_window_half_length, 1 ); FOR( i = 0; i < tmp1; i++ ) { -#ifdef BASOP_NOGLOB xn_buf[i] = shl_sat( xn_buf[i], TCX_IMDCT_HEADROOM ); -#else - xn_buf[i] = shl( xn_buf[i], TCX_IMDCT_HEADROOM ); -#endif move16(); } FOR( i = 0; i < tmp3; i++ ) { -#ifdef BASOP_NOGLOB tmp2 = add_sat( xn_buf[i + tmp1], mult_r( old_syn_overl[i], tcx_mdct_window_half[i].v.re ) ); xn_buf[i + tmp1] = shl_sat( tmp2, TCX_IMDCT_HEADROOM ); -#else - tmp2 = add( xn_buf[i + tmp1], mult_r( old_syn_overl[i], tcx_mdct_window_half[i].v.re ) ); - xn_buf[i + tmp1] = shl( tmp2, TCX_IMDCT_HEADROOM ); -#endif move16(); } FOR( ; i < tcx_mdct_window_half_length; i++ ) { tmp2 = add( xn_buf[i + tmp1], mult_r( old_syn_overl[i], tcx_mdct_window_half[tcx_mdct_window_half_length - 1 - i].v.im ) ); -#ifdef BASOP_NOGLOB xn_buf[i + tmp1] = shl_sat( tmp2, TCX_IMDCT_HEADROOM ); -#else - xn_buf[i + tmp1] = shl( tmp2, TCX_IMDCT_HEADROOM ); -#endif move16(); } IF( LT_16( add( i, tmp1 ), L_frame ) ) { FOR( i = add( i, tmp1 ); i < L_frame; i++ ) { -#ifdef BASOP_NOGLOB xn_buf[i] = shl_sat( xn_buf[i], TCX_IMDCT_HEADROOM ); -#else - xn_buf[i] = shl( xn_buf[i], TCX_IMDCT_HEADROOM ); -#endif move16(); } } @@ -2581,11 +2429,7 @@ void IMDCT_fx( Word32 *x, Word16 x_e, Word16 *old_syn_overl, Word16 *syn_Overl_T FOR( i = 0; i < overlap; i++ ) { -#ifdef BASOP_NOGLOB xn_buf[i] = shl_sat( add_sat( xn_buf[i], old_syn_overl[i] ), TCX_IMDCT_HEADROOM ); -#else - xn_buf[i] = shl( add( xn_buf[i], old_syn_overl[i] ), TCX_IMDCT_HEADROOM ); -#endif move16(); } @@ -2593,11 +2437,7 @@ void IMDCT_fx( Word32 *x, Word16 x_e, Word16 *old_syn_overl, Word16 *syn_Overl_T { FOR( ; i < L_frame; i++ ) { -#ifdef BASOP_NOGLOB xn_buf[i] = shl_sat( xn_buf[i], TCX_IMDCT_HEADROOM ); -#else - xn_buf[i] = shl( xn_buf[i], TCX_IMDCT_HEADROOM ); -#endif move16(); } } @@ -2607,22 +2447,14 @@ void IMDCT_fx( Word32 *x, Word16 x_e, Word16 *old_syn_overl, Word16 *syn_Overl_T tmp1 = shr( overlap, 1 ); FOR( i = 0; i < tmp1; i++ ) { -#ifdef BASOP_NOGLOB xn_buf[i] = shl_sat( xn_buf[i], TCX_IMDCT_HEADROOM ); -#else - xn_buf[i] = shl( xn_buf[i], TCX_IMDCT_HEADROOM ); -#endif move16(); } tmpP16 = xn_buf + tmp1; FOR( i = 0; i < overlap; i++ ) { -#ifdef BASOP_NOGLOB tmpP16[i] = shl_sat( add( tmpP16[i], old_syn_overl[i] ), TCX_IMDCT_HEADROOM ); -#else - tmpP16[i] = shl( add( tmpP16[i], old_syn_overl[i] ), TCX_IMDCT_HEADROOM ); -#endif move16(); } @@ -2630,11 +2462,7 @@ void IMDCT_fx( Word32 *x, Word16 x_e, Word16 *old_syn_overl, Word16 *syn_Overl_T { FOR( i = add( i, tmp1 ); i < L_frame; i++ ) { -#ifdef BASOP_NOGLOB xn_buf[i] = shl_sat( xn_buf[i], TCX_IMDCT_HEADROOM ); -#else - xn_buf[i] = shl( xn_buf[i], TCX_IMDCT_HEADROOM ); -#endif move16(); } } @@ -2652,11 +2480,7 @@ void IMDCT_fx( Word32 *x, Word16 x_e, Word16 *old_syn_overl, Word16 *syn_Overl_T BASOP_SATURATE_WARNING_OFF_EVS; FOR( i = 0; i < L_frame; i++ ) { -#ifdef BASOP_NOGLOB xn_buf[i] = shl_sat( xn_buf[i], TCX_IMDCT_HEADROOM ); -#else - xn_buf[i] = shl( xn_buf[i], TCX_IMDCT_HEADROOM ); -#endif move16(); } BASOP_SATURATE_WARNING_ON_EVS; @@ -2722,25 +2546,15 @@ void IMDCT_fx( Word32 *x, Word16 x_e, Word16 *old_syn_overl, Word16 *syn_Overl_T tmp3 = shr( tcx_mdct_window_half_length, 1 ); FOR( i = 0; i < tmp3; i++ ) { -#ifdef BASOP_NOGLOB xn_buf[i + tmp1] = mult_r_sat( xn_buf[i + tmp1], tcx_mdct_window_half[i].v.im ); xn_buf[i + tmp1] = add_sat( xn_buf[i + tmp1], mult_r_sat( hTcxDec->syn_OverlFB[i], mult_r_sat( tcx_mdct_window_half[i].v.re, tcx_mdct_window_half[i].v.re ) ) ); -#else - xn_buf[i + tmp1] = mult_r( xn_buf[i + tmp1], tcx_mdct_window_half[i].v.im ); - xn_buf[i + tmp1] = add( xn_buf[i + tmp1], mult_r( hTcxDec->syn_OverlFB[i], mult_r( tcx_mdct_window_half[i].v.re, tcx_mdct_window_half[i].v.re ) ) ); -#endif move16(); move16(); } FOR( ; i < tcx_mdct_window_half_length; i++ ) { -#ifdef BASOP_NOGLOB xn_buf[i + tmp1] = mult_r_sat( xn_buf[i + tmp1], tcx_mdct_window_half[( ( tcx_mdct_window_half_length - 1 ) - i )].v.re ); xn_buf[i + tmp1] = add_sat( xn_buf[i + tmp1], mult_r_sat( hTcxDec->syn_OverlFB[i], mult_r_sat( tcx_mdct_window_half[( ( tcx_mdct_window_half_length - 1 ) - i )].v.im, tcx_mdct_window_half[tcx_mdct_window_half_length - 1 - i].v.im ) ) ); -#else - xn_buf[i + tmp1] = mult_r( xn_buf[i + tmp1], tcx_mdct_window_half[tcx_mdct_window_half_length - 1 - i].v.re ); - xn_buf[i + tmp1] = add( xn_buf[i + tmp1], mult_r( hTcxDec->syn_OverlFB[i], mult_r( tcx_mdct_window_half[tcx_mdct_window_half_length - 1 - i].v.im, tcx_mdct_window_half[tcx_mdct_window_half_length - 1 - i].v.im ) ) ); -#endif move16(); move16(); } @@ -2751,25 +2565,15 @@ void IMDCT_fx( Word32 *x, Word16 x_e, Word16 *old_syn_overl, Word16 *syn_Overl_T tmp3 = shr( tcx_mdct_window_half_length, 1 ); FOR( i = 0; i < tmp3; i++ ) { -#ifdef BASOP_NOGLOB xn_buf[i + tmp1] = mult_r_sat( xn_buf[i + tmp1], tcx_mdct_window_half[i].v.im ); xn_buf[i + tmp1] = add_sat( xn_buf[i + tmp1], mult_r_sat( hTcxDec->syn_Overl[i], mult_r_sat( tcx_mdct_window_half[i].v.re, tcx_mdct_window_half[i].v.re ) ) ); -#else - xn_buf[i + tmp1] = mult_r( xn_buf[i + tmp1], tcx_mdct_window_half[i].v.im ); - xn_buf[i + tmp1] = add( xn_buf[i + tmp1], mult_r( hTcxDec->syn_Overl[i], mult_r( tcx_mdct_window_half[i].v.re, tcx_mdct_window_half[i].v.re ) ) ); -#endif move16(); move16(); } FOR( ; i < tcx_mdct_window_half_length; i++ ) { -#ifdef BASOP_NOGLOB xn_buf[i + tmp1] = mult_r_sat( xn_buf[i + tmp1], tcx_mdct_window_half[tcx_mdct_window_half_length - 1 - i].v.re ); xn_buf[i + tmp1] = add_sat( xn_buf[i + tmp1], mult_r_sat( hTcxDec->syn_Overl[i], mult_r_sat( tcx_mdct_window_half[tcx_mdct_window_half_length - 1 - i].v.im, tcx_mdct_window_half[tcx_mdct_window_half_length - 1 - i].v.im ) ) ); -#else - xn_buf[i + tmp1] = mult_r( xn_buf[i + tmp1], tcx_mdct_window_half[tcx_mdct_window_half_length - 1 - i].v.re ); - xn_buf[i + tmp1] = add( xn_buf[i + tmp1], mult_r( hTcxDec->syn_Overl[i], mult_r( tcx_mdct_window_half[tcx_mdct_window_half_length - 1 - i].v.im, tcx_mdct_window_half[tcx_mdct_window_half_length - 1 - i].v.im ) ) ); -#endif move16(); move16(); } @@ -3203,11 +3007,7 @@ void IMDCT_ivas_fx( { FOR( i = 0; i < sub( overlap, tcx_mdct_window_min_length ); i++ ) { -#ifdef BASOP_NOGLOB xn_buf_fx[( i + ( ( overlap / 2 ) - tcx_offset ) )] = add_sat( xn_buf_fx[( i + ( ( overlap / 2 ) - tcx_offset ) )], old_out_fx[( i + nz )] ); // Q(-2) -#else - xn_buf_fx[( i + ( ( overlap / 2 ) - tcx_offset ) )] = add( xn_buf_fx[( i + ( ( overlap / 2 ) - tcx_offset ) )], old_out_fx[( i + nz )] ); -#endif move16(); } @@ -3220,30 +3020,17 @@ void IMDCT_ivas_fx( // tested FOR( ; i < overlap; i++ ) /* perfectly reconstructing ALDO shortening */ { -#ifdef BASOP_NOGLOB xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], old_out_fx[( i + nz )] ); // Q(-2) -#else - xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], old_out_fx[( i + nz )] ); // Q(-2) - -#endif move16(); } FOR( i = 0; i < ( tcx_mdct_window_min_length / 2 ); i++ ) { -#ifdef BASOP_NOGLOB xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )] = add_sat( xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )], mult_r( old_out_fx[( ( i + nz ) + overlap )], tcx_mdct_window_minimum_fx[i].v.re ) ); // Q(-2) -#else - xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )] = add( xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )], mult_r( old_out_fx[( ( i + nz ) + overlap )], tcx_mdct_window_minimum_fx[i].v.re ) ); -#endif move16(); } FOR( ; i < tcx_mdct_window_min_length; i++ ) { -#ifdef BASOP_NOGLOB xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )] = add_sat( xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )], mult_r( old_out_fx[( ( i + nz ) + overlap )], tcx_mdct_window_minimum_fx[( tcx_mdct_window_min_length - ( 1 + i ) )].v.im ) ); // Q(-2) -#else - xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )] = add( xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )], mult_r( old_out_fx[( ( i + nz ) + overlap )], tcx_mdct_window_minimum_fx[( tcx_mdct_window_min_length - ( 1 + i ) )].v.im ) ); -#endif move16(); } } @@ -3251,20 +3038,12 @@ void IMDCT_ivas_fx( { FOR( ; i < ( overlap - ( tcx_mdct_window_min_length / 2 ) ); i++ ) { -#ifdef BASOP_NOGLOB xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( old_out_fx[( i + nz )], tcx_mdct_window_minimum_fx[( ( tcx_mdct_window_min_length - overlap ) + i )].v.re ) ); // Q(-2) -#else - xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( old_out_fx[( i + nz )], tcx_mdct_window_minimum_fx[( ( tcx_mdct_window_min_length - overlap ) + i )].v.re ) ); -#endif move16(); } FOR( ; i < overlap; i++ ) { -#ifdef BASOP_NOGLOB xn_buf_fx[( i + ( ( overlap / 2 ) - tcx_offset ) )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( old_out_fx[( i + nz )], tcx_mdct_window_minimum_fx[( overlap - ( 1 + i ) )].v.im ) ); // Q(-2) -#else - xn_buf_fx[( i + ( ( overlap / 2 ) - tcx_offset ) )] = add( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( old_out_fx[( i + nz )], tcx_mdct_window_minimum_fx[( overlap - ( 1 + i ) )].v.im ) ); -#endif move16(); } } @@ -3277,21 +3056,12 @@ void IMDCT_ivas_fx( { FOR( i = 0; i < ( tcx_mdct_window_half_length / 2 ); i++ ) { -#ifdef BASOP_NOGLOB xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( old_syn_overl_fx[i], tcx_mdct_window_half_fx[i].v.re ) ); // Q(-2) -#else - xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( old_syn_overl_fx[i], tcx_mdct_window_half_fx[i].v.re ) ); - -#endif move16(); } FOR( ; i < tcx_mdct_window_half_length; i++ ) { -#ifdef BASOP_NOGLOB xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( old_syn_overl_fx[i], tcx_mdct_window_half_fx[( tcx_mdct_window_half_length - ( 1 + i ) )].v.im ) ); // Q(-2) -#else - xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( old_syn_overl_fx[i], tcx_mdct_window_half_fx[( tcx_mdct_window_half_length - ( 1 + i ) )].v.im ) ); -#endif move16(); } } @@ -3307,11 +3077,7 @@ void IMDCT_ivas_fx( { FOR( i = 0; i < overlap; i++ ) { -#ifdef BASOP_NOGLOB xn_buf_fx[( i + ( overlap / 2 ) )] = add_sat( xn_buf_fx[( i + ( overlap / 2 ) )], old_syn_overl_fx[i] ); // Q(-2) -#else - xn_buf_fx[( i + ( overlap / 2 ) )] = add( xn_buf_fx[( i + ( overlap / 2 ) )], old_syn_overl_fx[i] ); -#endif move16(); } } @@ -3387,22 +3153,14 @@ void IMDCT_ivas_fx( FOR( i = 0; i < ( tcx_mdct_window_half_length / 2 ); i++ ) { xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = mult_r( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], tcx_mdct_window_half_fx[i].v.im ); -#ifdef BASOP_NOGLOB xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( mult_r( hTcxDec->syn_Overl[i], tcx_mdct_window_half_fx[i].v.re ), tcx_mdct_window_half_fx[i].v.re ) ); // Q(-2) -#else - xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( mult_r( hTcxDec->syn_Overl[i], tcx_mdct_window_half_fx[i].v.re ), tcx_mdct_window_half_fx[i].v.re ) ); -#endif move16(); move16(); } FOR( ; i < tcx_mdct_window_half_length; i++ ) { xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = mult_r( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], tcx_mdct_window_half_fx[( tcx_mdct_window_half_length - ( 1 + i ) )].v.re ); -#ifdef BASOP_NOGLOB xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( mult_r( hTcxDec->syn_Overl[i], tcx_mdct_window_half_fx[( tcx_mdct_window_half_length - ( 1 + i ) )].v.im ), tcx_mdct_window_half_fx[( tcx_mdct_window_half_length - ( 1 + i ) )].v.im ) ); // Q(-2) -#else - xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( mult_r( hTcxDec->syn_Overl[i], tcx_mdct_window_half_fx[( tcx_mdct_window_half_length - ( 1 + i ) )].v.im ), tcx_mdct_window_half_fx[( tcx_mdct_window_half_length - ( 1 + i ) )].v.im ) ); -#endif move16(); move16(); } @@ -4050,11 +3808,7 @@ void decoder_tcx_invQ_fx( FOR( i = 0; i < noiseFillingSize; ++i ) { tmp32 = L_shr( x[i], sub( 31, *x_e ) ); -#ifdef BASOP_NOGLOB *nf_seed = add_o( *nf_seed, (Word16) abs( tmp32 ) * i * 2, &Overflow ); -#else - *nf_seed = add( *nf_seed, (Word16) abs( tmp32 ) * i * 2 ); -#endif move16(); } } @@ -4149,11 +3903,7 @@ void decoder_tcx_invQ_fx( move16(); move16(); -#ifdef BASOP_NOGLOB tmp1 = mult_r( shl_sat( L_spec, 5 ), 26214 /*128.f/NORM_MDCT_FACTOR Q15*/ ); -#else - tmp1 = mult_r( shl( L_spec, 5 ), 26214 /*128.f/NORM_MDCT_FACTOR Q15*/ ); -#endif s = 15 - 5 - 7; move16(); IF( GE_16( L_spec, 1024 ) ) /*reduce precision for avoiding overflow*/ @@ -4297,11 +4047,7 @@ void decoder_tcx_invQ_fx( st->last_gain_syn_deemph_e = add( st->last_gain_syn_deemph_e, 10 /*scaling of h1[0] and E_UTIL_synthesis * 2*/ ); move16(); tmp32 = Sqrt32( tmp32, &st->last_gain_syn_deemph_e ); -#ifdef BASOP_NOGLOB st->last_gain_syn_deemph = round_fx_o( tmp32, &Overflow ); // Q15 -#else - last_gain_syn_deemph_fx = round_fx( tmp32 ); -#endif move16(); } @@ -4594,11 +4340,7 @@ void decoder_tcx_noisefilling_fx( tmp32 = L_deposit_l( 0 ); FOR( i = 0; i < L_spec; i++ ) { -#ifdef BASOP_NOGLOB tmp32 = L_macNs_co( tmp32, abs_s( prm_sqQ[i] ), i, &Carry, &Overflow ); -#else - tmp32 = L_macNs( tmp32, abs_s( prm_sqQ[i] ), i ); -#endif } nf_seed = extract_l( tmp32 ); } @@ -4749,11 +4491,7 @@ void decoder_tcx_noisefilling_fx( tmp1 = BASOP_Util_Divide3232_Scale( W_extract_h( E_2ndlast ), W_extract_h( E_last ), &tmp2 ); tmp2 = add( tmp2, sub( exp2, exp1 ) ); -#ifdef BASOP_NOGLOB tmp1 = shl_sat( tmp1, sub( tmp2, 2 ) ); -#else - tmp1 = shl( tmp1, tmp2 ); -#endif /* replace higher energy TCX5 frame by lower one to avoid energy fluctuation */ IF( st->element_mode > EVS_MONO ) diff --git a/lib_dec/dec_tran_fx.c b/lib_dec/dec_tran_fx.c index d21109dce767cb8d9a39949efdea4901b90e628d..e886fd33770a60b034c992b92348e9fdc33bb9e6 100644 --- a/lib_dec/dec_tran_fx.c +++ b/lib_dec/dec_tran_fx.c @@ -234,21 +234,12 @@ void decod_tran_fx( FOR( i = 0; i < L_SUBFR; i++ ) { L_tmp = L_mult( gain_preQ_fx, code_preQ_fx[i] ); /* Q2 + Q10 -> Q13*/ -#ifdef BASOP_NOGLOB - L_tmp = L_shl_sat( L_tmp, tmp1_fx ); /* Q16 + Q_exc */ + L_tmp = L_shl_sat( L_tmp, tmp1_fx ); /* Q16 + Q_exc */ tmp_fx = round_fx_sat( L_tmp ); exc2_fx[i + i_subfr] = add_sat( exc2_fx[i + i_subfr], tmp_fx ); move16(); exc_fx[i + i_subfr] = add_sat( exc_fx[i + i_subfr], tmp_fx ); move16(); -#else - L_tmp = L_shl( L_tmp, tmp1_fx ); /* Q16 + Q_exc */ - tmp_fx = round_fx( L_tmp ); - exc2_fx[i + i_subfr] = add( exc2_fx[i + i_subfr], tmp_fx ); - move16(); - exc_fx[i + i_subfr] = add( exc_fx[i + i_subfr], tmp_fx ); - move16(); -#endif } } diff --git a/lib_dec/dec_uv_fx.c b/lib_dec/dec_uv_fx.c index 352738d5f524a16ecebeaf947766054f147f5475..aa898956a106198302bdc046458327e8f84766cf 100644 --- a/lib_dec/dec_uv_fx.c +++ b/lib_dec/dec_uv_fx.c @@ -255,9 +255,9 @@ void decod_unvoiced_ivas_fx( Word16 tmp_idx; tmp_idx = 0; move16(); - if ( i_subfr_fx != 0 ) + IF( i_subfr_fx != 0 ) { - idiv1616( i_subfr_fx, L_SUBFR ); + tmp_idx = idiv1616( i_subfr_fx, L_SUBFR ); } voice_factors_fx[tmp_idx] = 0; move16(); @@ -372,11 +372,7 @@ static void gain_dec_gacelp_uv_fx( *past_gcode = L_shl( L_tmp1, sub( exp_L_tmp1, 15 ) ); /* Q16 */ move32(); -#ifdef BASOP_NOGLOB *gain_code = L_shl_sat( Mpy_32_16_1( *past_gcode, *gain_inov ), 3 ); -#else - *gain_code = L_shl( Mpy_32_16_1( *past_gcode, *gain_inov ), 3 ); -#endif move32(); diff --git a/lib_dec/decision_matrix_dec_fx.c b/lib_dec/decision_matrix_dec_fx.c index 9c0020223150cbb48adcfa4f6497e23fbe600359..a83de038afe2e1fa2a92923f65ca270fec68b461 100644 --- a/lib_dec/decision_matrix_dec_fx.c +++ b/lib_dec/decision_matrix_dec_fx.c @@ -713,5 +713,20 @@ void decision_matrix_dec_fx( move16(); } +#ifdef NONBE_FIX_GSC_BSTR + /*-----------------------------------------------------------------* + * set inactive coder_type flag in ACELP core + *-----------------------------------------------------------------*/ + + st->inactive_coder_type_flag = 0; /* AVQ by default */ + move16(); + + if ( LE_32( st->total_brate, MAX_GSC_INACTIVE_BRATE ) ) + { + st->inactive_coder_type_flag = 1; /* GSC */ + move16(); + } + +#endif return; } diff --git a/lib_dec/er_dec_acelp_fx.c b/lib_dec/er_dec_acelp_fx.c index f61e782e342baee1480fbf6b0e2eefa0f8aadfb9..7c3ecaa0a96c3bec1e70c9ddfea1a4d8891862dd 100644 --- a/lib_dec/er_dec_acelp_fx.c +++ b/lib_dec/er_dec_acelp_fx.c @@ -202,11 +202,7 @@ void con_acelp_fx( Tc = round_fx( tmp_tc ); /* Q0 */ BASOP_SATURATE_WARNING_OFF_EVS /*if this ever saturates, it doesn't matter*/ -#ifdef BASOP_NOGLOB tmp = sub( shl_sat( abs_s( sub( T0, Tc ) ), 6 ), mult( 19661 /*0.15f Q17*/, shl_sat( Tc, 4 ) ) /*Q6*/ ); -#else - tmp = sub( shl( abs_s( sub( T0, Tc ) ), 6 ), mult( 19661 /*0.15f Q17*/, shl( Tc, 4 ) ) /*Q6*/ ); -#endif BASOP_SATURATE_WARNING_ON_EVS test(); test(); @@ -419,11 +415,7 @@ void con_acelp_fx( FOR( ; i < l; i++ ) { BASOP_SATURATE_WARNING_OFF_EVS -#ifdef BASOP_NOGLOB exc[i] = mult_r( exc[i], shl_sat( gain, 1 ) ); /*overflow is first iteration because gain may be 1 after shift*/ /*Qf_exc*/ -#else - exc[i] = mult_r( exc[i], shl( gain, 1 ) ); /*overflow is first iteration because gain may be 1 after shift*/ /*Qf_exc*/ -#endif BASOP_SATURATE_WARNING_ON_EVS move16(); gain = sub( gain, step ); @@ -434,11 +426,7 @@ void con_acelp_fx( FOR( ; i < l; i++ ) { BASOP_SATURATE_WARNING_OFF_EVS -#ifdef BASOP_NOGLOB exc[i] = mult_r( exc[i], shl_sat( gain, 1 ) ); /*overflow is first iteration because gain may become 1 due to shift*/ /*Qf_exc*/ -#else - exc[i] = mult_r( exc[i], shl( gain, 1 ) ); /*overflow is first iteration because gain may become 1 due to shift*/ /*Qf_exc*/ -#endif BASOP_SATURATE_WARNING_ON_EVS move16(); gain = sub( gain, step ); @@ -541,24 +529,12 @@ void con_acelp_fx( gain_32 = st->Mode2_lp_gainc; /*15Q16 */ /* start-of-the-frame gain */ move32(); -#ifdef BASOP_NOGLOB ftmp = round_fx_sat( L_shl_sat( gain_32, 1 ) ); /*Q0*/ -#else - ftmp = round_fx( L_shl( gain_32, 1 ) ); /*Q0*/ -#endif BASOP_SATURATE_WARNING_OFF_EVS -#ifdef BASOP_NOGLOB tmp_16 = sub( shl_sat( gainCNG, sub( gainCNG_e, 5 /*Q5*/ ) ), ftmp ); /*Q0*/ -#else - tmp_16 = sub( shl( gainCNG, sub( gainCNG_e, 5 /*Q5*/ ) ), ftmp ); -#endif /*in case of overflow:*/ test(); -#ifdef BASOP_NOGLOB if ( ( EQ_16( shl_sat( ftmp, sub( gainCNG_e, 1 ) ), MAXVAL_WORD16 ) ) && EQ_16( gainCNG, MAXVAL_WORD16 ) ) -#else - if ( ( EQ_16( shl( ftmp, sub( gainCNG_e, 1 ) ), MAXVAL_WORD16 ) ) && EQ_16( gainCNG, MAXVAL_WORD16 ) ) -#endif { tmp_16 = 1; move16(); @@ -670,24 +646,15 @@ void con_acelp_fx( /* non-causal ringing of the FIR filter */ /* gain_16 = gain_32 = gain_inov * gain */ - gain_32 = Mpy_32_16_1( gain_32, gain_inov ); /* 15Q16 * Q15 * 2^s_gain_inov */ -#ifdef BASOP_NOGLOB + gain_32 = Mpy_32_16_1( gain_32, gain_inov ); /* 15Q16 * Q15 * 2^s_gain_inov */ gain_32 = L_shl_sat( gain_32, add( 15, s_gain_inov ) ); /* Q31 */ gain_16 = round_fx_sat( gain_32 ); /* Q15 */ -#else - gain_32 = L_shl( gain_32, add( 15, s_gain_inov ) ); /* Q31 */ - gain_16 = round_fx( gain_32 ); /* Q15 */ -#endif /* step_32 = gain_inov * step */ step_32 = Mpy_32_16_1( step_32, gain_inov ); /* 15Q16 * Q15 * 2^s_gain_inov */ step_32 = L_shl( step_32, add( 15, s_gain_inov ) ); /* Q31 */ -#ifdef BASOP_NOGLOB g_e = norm_s( round_fx_sat( L_shl_sat( Mpy_32_16_1( st->Mode2_lp_gainc, gain_inov ), add( 15, s_gain_inov ) ) ) ); /* norm_s for gain*gain_inov at the end of the following loops */ -#else - g_e = norm_s( round_fx( L_shl( Mpy_32_16_1( st->Mode2_lp_gainc, gain_inov ), add( 15, s_gain_inov ) ) ) ); /* norm_s for gain*gain_inov at the end of the following loops */ -#endif g_e = s_min( norm_s( gain_16 ), g_e ); gain_16 = shl( gain_16, g_e ); /*Q15 + g_e*/ gain_32 = L_shl( gain_32, g_e ); /*Q31 + g_e*/ @@ -826,13 +793,8 @@ void con_acelp_fx( /* i_subfr / L_SUBFR */ tmp_16 = shr( i_subfr, Q6 ); g = mult_r( st->last_gain_syn_deemph, gain_lpc[tmp_16] ); /* Q15 - gain_lpc_e[tmp_16] */ -#ifdef BASOP_NOGLOB g_e = add_sat( st->last_gain_syn_deemph_e, gain_lpc_e[tmp_16] ); g = shl_sat( g, g_e ); /* Q15 */ -#else - g_e = add( st->last_gain_syn_deemph_e, gain_lpc_e[tmp_16] ); - g = shl( g, g_e ); -#endif FOR( i = 0; i < L_SUBFR; i++ ) { @@ -917,11 +879,7 @@ void con_acelp_fx( tmp_16 = shr( i_subfr, Q6 ); g = mult_r( st->last_gain_syn_deemph, gain_lpc[tmp_16] ); /* Q15 - gain_lpc_e[tmp_16] */ g_e = add( st->last_gain_syn_deemph_e, gain_lpc_e[tmp_16] ); -#ifdef BASOP_NOGLOB g = shl_sat( g, g_e ); /*Q15*/ -#else - g = shl( g, g_e ); -#endif FOR( i = 0; i < L_SUBFR; i++ ) { /* exc[i_subfr + i] *= st->last_gain_syn_deemph*gain_lpc[j]; */ @@ -990,11 +948,7 @@ void con_acelp_fx( { FOR( i = 0; i < st->L_frame; i++ ) { -#ifdef BASOP_NOGLOB syn[i] = add_sat( syn[i], syn_unv[i] ); /*Qf_syn*/ -#else - syn[i] = add( syn[i], syn_unv[i] ); -#endif move16(); } } @@ -1048,11 +1002,7 @@ void con_acelp_fx( /*updating enr_old parameters*/ frame_ener_fx( st->L_frame, st->last_good, syn, round_fx( tmp_tc ), &( st->enr_old_fx ), 1, 0, 0, 0 ); -#ifdef BASOP_NOGLOB st->enr_old_fx = L_shl_sat( st->enr_old_fx, shl( negate( Qf_syn ), 1 ) ); /*Q0*/ -#else - st->enr_old_fx = L_shl( st->enr_old_fx, shl( negate( Qf_syn ), 1 ) ); -#endif move32(); /* update ACELP synthesis memory */ Copy( mem_syn, st->mem_syn2_fx, M ); /*Qf_syn*/ @@ -1187,11 +1137,7 @@ static void memsynPrecission_fx( Word16 nbLostCmpt, Word16 *mem_syn /*Qx*/, Word { /*saturation doesn't matter*/ BASOP_SATURATE_WARNING_OFF_EVS -#ifdef BASOP_NOGLOB tmp = add_sat( tmp, abs_s( mem_syn[i] ) ); -#else - tmp = add( tmp, abs_s( mem_syn[i] ) ); -#endif BASOP_SATURATE_WARNING_ON_EVS } /*if there is energy in scale_syn, then increase precision*/ diff --git a/lib_dec/er_dec_tcx_fx.c b/lib_dec/er_dec_tcx_fx.c index 352c46ad63048ce8e6c30f33b38de9e964391e24..8c10e5f810542410d079e27227e72046a05c7921 100644 --- a/lib_dec/er_dec_tcx_fx.c +++ b/lib_dec/er_dec_tcx_fx.c @@ -36,34 +36,18 @@ static void calcGainc_fx( Word16 *exc, Word16 Q_exc, Word32 old_fpitch /*Q16*/, tmp16 = round_fx( old_fpitch ); /*Q0*/ tmp_loop = shl( L_subfr, 1 ); BASOP_SATURATE_WARNING_OFF_EVS -#ifdef BASOP_NOGLOB tmp16_2 = round_fx_o( L_shl_o( lp_gainp, 2, &Overflow ), &Overflow ); /*Q31->Q15, no severe saturation, because st->lp_gainp here is [0,1]*/ -#else - tmp16_2 = round_fx( L_shl( lp_gainp, 2 ) ); /*Q31->Q15, no severe saturation, because st->lp_gainp here is [0,1]*/ -#endif BASOP_SATURATE_WARNING_ON_EVS FOR( i = 0; i < tmp_loop; i++ ) { /*st->lp_gainc += ( exc[i-2*L_subfr] - st->Mode2_lp_gainp * exc[i-2*L_subfr-(int)(st->old_fpitch+0.5f)] ) * ( exc[i-2*L_subfr] - st->Mode2_lp_gainp * exc[i-2*L_subfr-(int)(st->old_fpitch+0.5f)] );*/ -#ifdef BASOP_NOGLOB tmp16_3 = sub_o( exc[( i - ( L_subfr * 2 ) )] /*Q1*/, mult_r( tmp16_2 /*Q15*/, exc[( ( i - ( L_subfr * 2 ) ) - tmp16 )] /*Q1*/ ) /*Q1*/, &Overflow ); -#else - tmp16_3 = sub( exc[sub( i, shl( L_subfr, 1 ) )] /*Q1*/, mult_r( tmp16_2 /*Q15*/, exc[sub( sub( i, shl( L_subfr, 1 ) ), tmp16 )] /*Q1*/ ) /*Q1*/ ); -#endif -#ifdef BASOP_NOGLOB L_acc = L_macNs_co( L_acc, tmp16_3, tmp16_3, &Carry, &Overflow ); /*Q3*/ -#else - L_acc = L_macNs( L_acc, tmp16_3, tmp16_3 ); /*Q3*/ -#endif Overflow = 0; move16(); -#ifdef BASOP_NOGLOB L_c = L_macNs_co( L_c, 0, 0, &Carry, &Overflow ); /*Accumulate Carrys Q-1*/ -#else - L_c = L_macNs( L_c, 0, 0 ); /*Accumulate Carrys*/ -#endif Carry = 0; move16(); } @@ -105,18 +89,10 @@ static void calcGainc2_fx( Word16 *exc, Word16 Q_exc, Word16 L_subfr /*Q0*/, Wor FOR( i = 0; i < cnt; i++ ) { /* *gainc += ( exc[i-2*L_subfr] ) * ( exc[i-2*L_subfr]); */ -#ifdef BASOP_NOGLOB /* Critical Carry/Overflow */ L_acc = L_macNs_co( L_acc, exc[( i - ( L_subfr * 2 ) )] /*Q1*/, exc[( i - ( L_subfr * 2 ) )] /*Q1*/, &Carry, &Overflow ); /*Q3*/ -#else - L_acc = L_macNs( L_acc, exc[sub( i, shl( L_subfr, 1 ) )] /*Q1*/, exc[sub( i, shl( L_subfr, 1 ) )] /*Q1*/ ); /*Q3*/ -#endif Overflow = 0; move16(); -#ifdef BASOP_NOGLOB /* Critical Carry/Overflow */ L_c = L_macNs_co( L_c, 0, 0, &Carry, &Overflow ); /* Accumulate Carrys Q-1*/ -#else - L_c = L_macNs( L_c, 0, 0 ); /* Accumulate Carrys */ -#endif Carry = 0; move16(); } @@ -401,7 +377,6 @@ void con_tcx_fx( { FOR( i = 0; i < Tc; i++ ) { -#ifdef BASOP_NOGLOB *pt_exc++ = mac_r_sat( L_mac_sat( L_mac_sat( L_mac_sat( L_mac_sat( L_mac_sat( L_mac_sat( L_mac_sat( L_mac_sat( L_mac_sat( L_mult( 174 /* 0.0053f Q15*/, pt1_exc[-5] ), 0 /* 0.0000f Q15*/, pt1_exc[-4] ), @@ -414,20 +389,6 @@ void con_tcx_fx( -1442 /*-0.0440f Q15*/, pt1_exc[3] ), 0 /* 0.0000f Q15*/, pt1_exc[4] ), 174 /* 0.0053f Q15*/, pt1_exc[5] ); /*Q_exc*/ -#else - *pt_exc++ = mac_r( L_mac( L_mac( L_mac( L_mac( L_mac( L_mac( L_mac( L_mac( L_mac( - L_mult( 174 /* 0.0053f Q15*/, pt1_exc[-5] ), - 0 /* 0.0000f Q15*/, pt1_exc[-4] ), - -1442 /*-0.0440f Q15*/, pt1_exc[-3] ), - 0 /* 0.0000f Q15*/, pt1_exc[-2] ), - 8641 /* 0.2637f Q15*/, pt1_exc[-1] ), - 18022 /* 0.5500f Q15*/, pt1_exc[0] ), - 8641 /* 0.2637f Q15*/, pt1_exc[1] ), - 0 /* 0.0000f Q15*/, pt1_exc[2] ), - -1442 /*-0.0440f Q15*/, pt1_exc[3] ), - 0 /* 0.0000f Q15*/, pt1_exc[4] ), - 174 /* 0.0053f Q15*/, pt1_exc[5] ); -#endif move16(); pt1_exc++; } @@ -436,7 +397,6 @@ void con_tcx_fx( { FOR( i = 0; i < Tc; i++ ) { -#ifdef BASOP_NOGLOB *pt_exc++ = mac_r_sat( L_mac_sat( L_mac_sat( L_mac_sat( L_mac_sat( L_mac_sat( L_mac_sat( L_mac_sat( L_mac_sat( L_mac_sat( L_mult( -174 /*-0.0053f Q15*/, pt1_exc[-5] ), -121 /*-0.0037f Q15*/, pt1_exc[-4] ), @@ -449,20 +409,6 @@ void con_tcx_fx( -459 /*-0.0140f Q15*/, pt1_exc[3] ), -121 /*-0.0037f Q15*/, pt1_exc[4] ), -174 /*-0.0053f Q15*/, pt1_exc[5] ); /*Q_exc*/ -#else - *pt_exc++ = mac_r( L_mac( L_mac( L_mac( L_mac( L_mac( L_mac( L_mac( L_mac( L_mac( - L_mult( -174 /*-0.0053f Q15*/, pt1_exc[-5] ), - -121 /*-0.0037f Q15*/, pt1_exc[-4] ), - -459 /*-0.0140f Q15*/, pt1_exc[-3] ), - 590 /* 0.0180f Q15*/, pt1_exc[-2] ), - 8743 /* 0.2668f Q15*/, pt1_exc[-1] ), - 16355 /* 0.4991f Q15*/, pt1_exc[0] ), - 8743 /* 0.2668f Q15*/, pt1_exc[1] ), - 590 /* 0.0180f Q15*/, pt1_exc[2] ), - -459 /*-0.0140f Q15*/, pt1_exc[3] ), - -121 /*-0.0037f Q15*/, pt1_exc[4] ), - -174 /*-0.0053f Q15*/, pt1_exc[5] ); -#endif move16(); pt1_exc++; } @@ -563,11 +509,7 @@ void con_tcx_fx( } ELSE { -#ifdef BASOP_NOGLOB st->cummulative_damping = shl_sat( mult_r_sat( st->cummulative_damping /*Q15*/, alpha /*Q14*/ ), 1 ) /*Q15*/; -#else - st->cummulative_damping = shl( mult_r( st->cummulative_damping /*Q15*/, alpha /*Q14*/ ), 1 ) /*Q15*/; -#endif move16(); } @@ -595,15 +537,9 @@ void con_tcx_fx( tmp_loop = shr( imult1616( L_frame, 3 ), 1 ); FOR( i = offset; i < tmp_loop; i++ ) { -#ifdef BASOP_NOGLOB exc[i] = mult_r( exc[i], round_fx_sat( gain32 ) ) /*Q1*/; move16(); gain32 = L_sub_sat( gain32, step32 ); /*Q31*/ -#else - exc[i] = mult_r( exc[i], round_fx( gain32 ) ) /*Q1*/; - move16(); - gain32 = L_sub( gain32, step32 ); -#endif } /* update old exc without random part */ @@ -783,7 +719,7 @@ void con_tcx_fx( #else tmp16 = 32767; move16(); - gainSynthDeemph = getLevelSynDeemph_fx( &( tmp16 ), A_local, M, shr( L_frame, 2 ), st->preemph_fac, 1, &gainSynthDeemph_e ); /*Q5*/ + gainSynthDeemph = getLevelSynDeemph_fx( &( tmp16 ), A_local, M, shr( L_frame, 2 ), st->preemph_fac, 1, &gainSynthDeemph_e ); /*Q5*/ #endif IF( st->tcxonly != 0 ) { @@ -821,11 +757,7 @@ void con_tcx_fx( { gain32 = Mpy_32_16_1( gain32, 22938 /*0.7f Q15*/ ); /*Q16*/ } -#ifdef BASOP_NOGLOB /* Critical Overflow */ L_tmp = L_shl_sat( gain32, 1 ); /*Q16*/ -#else - L_tmp = L_shl( gain32, 1 ); -#endif IF( GT_32( L_shl( L_deposit_h( gainCNG ), sub( gainCNG_e, 31 - 16 ) /*Q16*/ ), L_tmp ) ) { gainCNG_e = sub( 15 + 1, norm_l( L_tmp ) ); @@ -872,11 +804,7 @@ void con_tcx_fx( tmp_e = norm_l( L_tmp ); L_tmp = L_shl( L_tmp, tmp_e ); gain_inov_e = add( sub( gain_inov_e, tmp_e ), 31 - 29 ); /*->Q31*/ -#ifdef BASOP_NOGLOB /* Critical Overflow */ gain_inov = round_fx_sat( L_tmp ); /*Q15,gain_inov_e*/ -#else - gain_inov = round_fx( L_tmp ); /*Q15,gain_inov_e*/ -#endif } st->Mode2_lp_gainp = L_shr( L_deposit_h( alpha /*Q14*/ ) /*Q14+16*/, 1 ); /*Q29*/ @@ -925,13 +853,8 @@ void con_tcx_fx( tmp16 = add( L_frame, shr( L_frame, 1 ) ); FOR( i = 0; i < tmp16; i++ ) { -#ifdef BASOP_NOGLOB exc[i] = add_sat( exc[i], shl_sat( noise[i + ( L_FIR_FER2 / 2 )], add( Q_exc, noise_e ) ) ); /*Q1*/ move16(); -#else - exc[i] = add( exc[i], shl( noise[i + ( L_FIR_FER2 / 2 )], add( Q_exc, noise_e ) ) ); /*Q1*/ - move16(); -#endif } } ELSE @@ -978,11 +901,7 @@ void con_tcx_fx( Copy_Scale_sig( buf, mem_syn, M, exp_scale ); /*Q: tmp16*/ -#ifdef BASOP_NOGLOB tmp_deemph = shl_sat( tmp_deemph, Q_syn ); /*Q_syn*/ -#else - tmp_deemph = shl( tmp_deemph, Q_syn ); -#endif st->Q_syn = Q_syn; move16(); @@ -1080,11 +999,7 @@ void con_tcx_fx( lerp( syn, st->hWIDec->old_syn2_fx, L_EXC_MEM, L_frame ); } -#ifdef BASOP_NOGLOB st->bfi_pitch_fx /*Q6*/ = round_fx_sat( L_shl_sat( pitch_buf[( st->nb_subfr - 1 )] /*15Q16*/, 6 /*Q6*/ ) ); -#else - st->bfi_pitch_fx /*Q6*/ = round_fx( L_shl( pitch_buf[sub( st->nb_subfr, 1 )] /*15Q16*/, 6 /*Q6*/ ) ); -#endif move16(); st->bfi_pitch_frame = st->L_frame; move16(); @@ -1108,21 +1023,13 @@ void con_tcx_fx( FOR( i = 0; i < W2; i++ ) { -#ifdef BASOP_NOGLOB hTcxDec->syn_Overl_TDACFB[i] = add_sat( buf[i], buf[( ( W1 - 1 ) - i )] ); /*hTcxDec->Q_syn_Overl_TDACFB*/ -#else - hTcxDec->syn_Overl_TDACFB[i] = add( buf[i], buf[sub( sub( W1, 1 ), i )] ); -#endif move16(); } FOR( i = 0; i < W2; i++ ) { -#ifdef BASOP_NOGLOB hTcxDec->syn_Overl_TDACFB[( W2 + i )] = add_sat( buf[( W2 + i )], buf[( ( ( W1 - 1 ) - W2 ) - i )] ); /*hTcxDec->Q_syn_Overl_TDACFB*/ -#else - hTcxDec->syn_Overl_TDACFB[add( W2, i )] = add( buf[add( W2, i )], buf[sub( sub( sub( W1, 1 ), W2 ), i )] ); -#endif move16(); } @@ -1547,11 +1454,7 @@ void con_tcx_ivas_fx( } ELSE { -#ifdef BASOP_NOGLOB st->cummulative_damping = shl_sat( mult_r_sat( st->cummulative_damping /*Q15*/, alpha /*Q14*/ ), 1 ) /*Q15*/; -#else - st->cummulative_damping = shl( mult_r( st->cummulative_damping /*Q15*/, alpha /*Q14*/ ), 1 ) /*Q15*/; -#endif move16(); } @@ -1579,15 +1482,9 @@ void con_tcx_ivas_fx( tmp_loop = shr( imult1616( L_frame, 3 ), 1 ); FOR( i = offset; i < tmp_loop; i++ ) { -#ifdef BASOP_NOGLOB exc[i] = mult_r( exc[i], round_fx_sat( gain32 ) ) /*Q1*/; move16(); gain32 = L_sub_sat( gain32, step32 ); /*Q31*/ -#else - exc[i] = mult_r( exc[i], round_fx( gain32 ) ) /*Q1*/; - move16(); - gain32 = L_sub( gain32, step32 ); -#endif } /* update old exc without random part */ @@ -1930,13 +1827,8 @@ void con_tcx_ivas_fx( tmp16 = add( L_frame, shr( L_frame, 1 ) ); FOR( i = 0; i < tmp16; i++ ) { -#ifdef BASOP_NOGLOB exc[i] = add_sat( exc[i], shl_sat( noise[i + ( L_FIR_FER2 / 2 )], add( Q_exc, noise_e ) ) ); /*Q1*/ move16(); -#else - exc[i] = add( exc[i], shl( noise[i + ( L_FIR_FER2 / 2 )], add( Q_exc, noise_e ) ) ); /*Q1*/ - move16(); -#endif } } ELSE @@ -1984,11 +1876,7 @@ void con_tcx_ivas_fx( Copy_Scale_sig( buf, mem_syn, M, exp_scale ); /* Q: tmp16 */ -#ifdef BASOP_NOGLOB tmp_deemph = shl_sat( tmp_deemph, Q_syn ); -#else - tmp_deemph = shl( tmp_deemph, Q_syn ); -#endif st->Q_syn = Q_syn; move16(); @@ -2092,11 +1980,7 @@ void con_tcx_ivas_fx( lerp( syn, st->hWIDec->old_syn2_fx, L_EXC_MEM, L_frame ); } -#ifdef BASOP_NOGLOB st->bfi_pitch_fx /*Q6*/ = round_fx_sat( L_shl_sat( pitch_buf[sub( st->nb_subfr, 1 )] /*15Q16*/, 6 /*Q6*/ ) ); -#else - st->bfi_pitch_fx /*Q6*/ = round_fx( L_shl( pitch_buf[sub( st->nb_subfr, 1 )] /*15Q16*/, 6 /*Q6*/ ) ); -#endif move16(); st->bfi_pitch_frame = st->L_frame; move16(); diff --git a/lib_dec/er_scale_syn_fx.c b/lib_dec/er_scale_syn_fx.c index 6061ac0992ffde683144b2a39520f16980ee3147..35ad826486d758fbbaa190df3afa1374320fc238 100644 --- a/lib_dec/er_scale_syn_fx.c +++ b/lib_dec/er_scale_syn_fx.c @@ -97,14 +97,10 @@ Word16 Damping_fact_fx( /* o : damping factor move16(); gain32 = Sqrt32( lp_tmp, &s_gainp ); /*Q31-s_gainp*/ -#ifdef BASOP_NOGLOB gain = round_fx_o( L_shl_o( gain32, s_gainp, &Overflow ), &Overflow ); /* Q15*/ -#else - gain = round_fx( L_shl( gain32, s_gainp ) ); /* Q15*/ -#endif - gain = s_min( gain, 32113 /*0.98f Q15*/ ); /*Q15*/ - gain = s_max( gain, 27853 /*0.85f Q15*/ ); /*Q15*/ - alpha = mult_r( alpha, gain ); /*Q14*/ + gain = s_min( gain, 32113 /*0.98f Q15*/ ); /*Q15*/ + gain = s_max( gain, 27853 /*0.85f Q15*/ ); /*Q15*/ + alpha = mult_r( alpha, gain ); /*Q14*/ } ELSE IF( EQ_16( nbLostCmpt, 2 ) ) { diff --git a/lib_dec/er_sync_exc_fx.c b/lib_dec/er_sync_exc_fx.c index 19ae2edcccf2d48656a9fd4354652ef664519607..48be80d43cecd12d70b57d6f2d4d8a47c93cbe3a 100644 --- a/lib_dec/er_sync_exc_fx.c +++ b/lib_dec/er_sync_exc_fx.c @@ -52,28 +52,16 @@ static Word16 GetMinimumPosition_fx( move16(); FOR( i = 0; i < cnt; i++ ) { - tmp16 = shr( x[i], tmp_e ); /*Qx*/ -#ifdef BASOP_NOGLOB + tmp16 = shr( x[i], tmp_e ); /*Qx*/ energy = L_msu_sat( energy_old, tmp16, tmp16 ); /*2Qx+1*/ -#else - energy = L_msu( energy_old, tmp16, tmp16 ); -#endif - tmp16 = shr( x[( i + filterLength )], tmp_e ); /*Qx*/ - BASOP_SATURATE_WARNING_OFF_EVS /*Saturation will be handled*/ -#ifdef BASOP_NOGLOB + tmp16 = shr( x[( i + filterLength )], tmp_e ); /*Qx*/ + BASOP_SATURATE_WARNING_OFF_EVS /*Saturation will be handled*/ energy = L_mac_sat( energy, tmp16, tmp16 ); /*2Qx+1*/ -#else - energy = L_mac( energy, tmp16, tmp16 ); -#endif BASOP_SATURATE_WARNING_ON_EVS /*if (energy == MAXVAL_WORD32)*/ - BASOP_SATURATE_WARNING_OFF_EVS /*saturates if energy < 0*/ -#ifdef BASOP_NOGLOB + BASOP_SATURATE_WARNING_OFF_EVS /*saturates if energy < 0*/ tmptest = L_sub_o( energy, MAXVAL_WORD32, &Overflow ); /*Q31*/ -#else - tmptest = L_sub( energy, MAXVAL_WORD32 ); -#endif BASOP_SATURATE_WARNING_ON_EVS IF( tmptest == 0 ) { @@ -307,11 +295,7 @@ void PulseResynchronization_fx( tmp3_e = tmp2_e; move16(); tmp32_a = L_negate( tmp32_a ); -#ifdef BASOP_NOGLOB tmp32_a = L_add( L_shl_o( 1, sub( 31, tmp3_e ), &Overflow ), tmp32_a ); /*Q31,tmp3_e*/ /*tmp32_a= 1.0f-pitchStart*freqStart*/ -#else - tmp32_a = L_add( L_shl( 1, sub( 31, tmp3_e ) ), tmp32_a ); /*Q31,tmp3_e*/ /*tmp32_a= 1.0f-pitchStart*freqStart*/ -#endif tmp2_e = norm_s( nFrameLength ); tmp16_a = shl( nFrameLength, tmp2_e ); /*Q0+tmp2_e*/ tmp32_a = Mpy_32_16_1( tmp32_a /*Q31,tmp3_e*/, tmp16_a /*Q0,-tmp2_e*/ ); /*Q16,tmp3_e-tmp2_e*/ /*tmp32_a= nFrameLength*(1.0f-pitchStart*freqStart)*/ @@ -376,12 +360,8 @@ void PulseResynchronization_fx( fractionalLeft = lshr( extract_l( tmp32_a ), 1 ); /*Q15*/ tmp_e = sub( 15, norm_l( tmp32 ) ); cycleDelta_e = add( cycleDelta_e, tmp_e ); - tmp32 = L_shr( tmp32, sub( tmp_e, 15 ) ); /*Q31 frac, cycleDelta_e*/ -#ifdef BASOP_NOGLOB + tmp32 = L_shr( tmp32, sub( tmp_e, 15 ) ); /*Q31 frac, cycleDelta_e*/ cycleDelta = round_fx_o( tmp32, &Overflow ); /*Q15, cycleDelta_e*/ -#else - cycleDelta = round_fx( tmp32 ); /*Q15, cycleDelta_e*/ -#endif if ( cycleDelta == 0 ) { cycleDelta_e = 0; diff --git a/lib_dec/er_util_fx.c b/lib_dec/er_util_fx.c index 7452e9bf69e7c92528e70eaec8adf7f46574d194..8c94ecf987e1152e94d8c19b63da37c8bdaee5cf 100644 --- a/lib_dec/er_util_fx.c +++ b/lib_dec/er_util_fx.c @@ -53,11 +53,7 @@ void minimumStatistics_fx( BASOP_SATURATE_WARNING_OFF_EVS -#ifdef BASOP_NOGLOB IF( LT_16( shl_o( currentFrameLevel, currentFrameLevel_e, &Overflow ), PLC_MIN_CNG_LEV ) ) -#else - IF( LT_16( shl( currentFrameLevel, currentFrameLevel_e ), PLC_MIN_CNG_LEV ) ) -#endif { BASOP_SATURATE_WARNING_ON_EVS currentFrameLevel = PLC_MIN_CNG_LEV; /*Q15*/ @@ -271,11 +267,7 @@ Word16 getLevelSynDeemph_fx( /*10Q5*/ *Exp = sub( 10, s16 ); /*Set exponent in order to transform returnvalue to Q15*/ move16(); -#ifdef BASOP_NOGLOB return round_fx_sat( levelSynDeemph ); /*Q15*/ -#else - return round_fx( levelSynDeemph ); /*Q15*/ -#endif } /* BASOP version: up to date with rev 7422 */ diff --git a/lib_dec/evs_dec_fx.c b/lib_dec/evs_dec_fx.c index 5e027e6526be1198ea66f6415065115823a4768f..de644843362064518ad334eee93afa097fb7a7f3 100644 --- a/lib_dec/evs_dec_fx.c +++ b/lib_dec/evs_dec_fx.c @@ -163,20 +163,12 @@ ivas_error evs_dec_fx( /* st_fx->old_out_fx, st_fx->L_frameTCX); */ FOR( i = 0; i < hTcxDec->L_frameTCX; i++ ) { -#ifdef BASOP_NOGLOB hHQ_core->old_out_fx[i] = shl_sat( mult_r( hHQ_core->old_out_fx[i], st_fx->plcInfo.recovery_gain ), 1 ); /*hHQ_core->exp_old_out*/ -#else - hHQ_core->old_out_fx[i] = shl( mult_r( hHQ_core->old_out_fx[i], st_fx->plcInfo.recovery_gain ), 1 ); -#endif move16(); } FOR( i = 0; i < st_fx->L_frame; i++ ) { -#ifdef BASOP_NOGLOB hHQ_core->old_out_LB_fx[i] = shl_sat( mult_r( hHQ_core->old_out_LB_fx[i], st_fx->plcInfo.recovery_gain ), 1 ); /*hHQ_core->exp_old_out*/ -#else - hHQ_core->old_out_LB_fx[i] = shl( mult_r( hHQ_core->old_out_LB_fx[i], st_fx->plcInfo.recovery_gain ), 1 ); -#endif move16(); } /* attenuate PLC buffers, if no aldo window @@ -192,11 +184,7 @@ ivas_error evs_dec_fx( tmp1 = extract_l( L_shr_r( f, s ) ); /*Q14 - s*/ FOR( i = 0; i < st_fx->hTcxCfg->tcx_mdct_window_lengthFB; i++ ) { -#ifdef BASOP_NOGLOB hTcxDec->syn_OverlFB[i] = shl_sat( mult_sat( tmp1, hTcxDec->syn_OverlFB[i] ), add( s, 1 ) ); /*hTcxDec->Q_syn_Overl*/ -#else - hTcxDec->syn_OverlFB[i] = shl( mult( tmp1, hTcxDec->syn_OverlFB[i] ), add( s, 1 ) ); -#endif move16(); } s = norm_l( f ); @@ -204,11 +192,7 @@ ivas_error evs_dec_fx( tmp1 = extract_l( L_shr_r( f, s ) ); /*Q14 - s*/ FOR( i = 0; i < st_fx->hTcxCfg->tcx_mdct_window_length; i++ ) { -#ifdef BASOP_NOGLOB hTcxDec->syn_Overl[i] = shl_sat( mult_sat( tmp1, hTcxDec->syn_Overl[i] ), s ); /*hTcxDec->Q_syn_Overl*/ -#else - hTcxDec->syn_Overl[i] = shl( mult( tmp1, hTcxDec->syn_Overl[i] ), s ); -#endif move16(); } } @@ -504,11 +488,7 @@ ivas_error evs_dec_fx( /*hb_synth[i] *= (i*tmp);*/ hb_synth_fx[i] = mult_r( hb_synth_fx[i], tmp16_2 ); /*hb_synth_fx_exp*/ move16(); -#ifdef BASOP_NOGLOB tmp16_2 = add_o( tmp16_2, tmp16, &Overflow ); -#else - tmp16_2 = add( tmp16_2, tmp16 ); -#endif } } @@ -757,11 +737,7 @@ ivas_error evs_dec_fx( fra = Log2_norm_lc( L_shl( L_tmp, exp ) ); exp = sub( sub( 30, shl( hb_synth_fx_exp, 1 ) ), exp ); L_tmp = Mpy_32_16( exp, fra, LG10 ); -#ifdef BASOP_NOGLOB st_fx->last_shb_ener_fx = round_fx_sat( L_shl_sat( L_tmp, 10 ) ); /*Q8*/ -#else - st_fx->last_shb_ener_fx = round_fx( L_shl( L_tmp, 10 ) ); /*Q8*/ -#endif } } hBWE_TD->prev_hb_synth_fx_exp = hb_synth_fx_exp; @@ -1044,11 +1020,7 @@ ivas_error evs_dec_fx( { FOR( i = 0; i < st_fx->L_frame / 2; i++ ) { -#ifdef BASOP_NOGLOB output_sp[i] = add_sat( output_sp[i], st_fx->hFdCngDec->hFdCngCom->olapBufferSynth2[i + 5 * st_fx->L_frame / 4] ); /*Q0*/ -#else - output_sp[i] = add( output_sp[i], st_fx->hFdCngDec->hFdCngCom->olapBufferSynth2[i + 5 * st_fx->L_frame / 4] ); -#endif move16(); } } @@ -1218,11 +1190,7 @@ ivas_error evs_dec_fx( FOR( i = 0; i < tmps; i++ ) { -#ifdef BASOP_NOGLOB output_sp[i + delay_comp] = msu_r_sat( L_mult_sat( output_sp[i + delay_comp], alpha ), shr( hHQ_core->old_out_fx[i + nz], timeIn_e ), add( alpha, -32768 ) ); /*timeIn_e*/ -#else - output_sp[i + delay_comp] = msu_r( L_mult( output_sp[i + delay_comp], alpha ), shr( hHQ_core->old_out_fx[i + nz], timeIn_e ), add( alpha, -32768 ) ); -#endif move16(); alpha = add( alpha, step ); } @@ -1345,11 +1313,7 @@ ivas_error evs_dec_fx( FOR( i = 0; i < tmps; i++ ) { -#ifdef BASOP_NOGLOB output_sp[i + tmps] = msu_r_sat( L_mult_sat( shr( pcmbufFB[i], timeIn_e ), alpha ), output_sp[i + tmps], add( alpha, -32768 ) ); /*Q0*/ -#else - output_sp[i + tmps] = msu_r( L_mult( shr( pcmbufFB[i], timeIn_e ), alpha ), output_sp[i + tmps], add( alpha, -32768 ) ); -#endif move16(); alpha = add( alpha, step ); } @@ -1387,17 +1351,9 @@ ivas_error evs_dec_fx( FOR( i = delta; i < tmps; i++ ) { -#ifdef BASOP_NOGLOB output_sp[i] = msu_r_sat( L_mult( output_sp[i], alpha ), shr_sat( hTcxDec->FBTCXdelayBuf[i], timeIn_e ), add( alpha, -32768 ) ); /*Q0*/ -#else - output_sp[i] = msu_r( L_mult( output_sp[i], alpha ), shr( hTcxDec->FBTCXdelayBuf[i], timeIn_e ), add( alpha, -32768 ) ); -#endif move16(); -#ifdef BASOP_NOGLOB alpha = add_sat( alpha, step ); -#else - alpha = add( alpha, step ); -#endif } } diff --git a/lib_dec/fd_cng_dec.c b/lib_dec/fd_cng_dec.c index ea716c8670066173ec98d3213e4fdada2bf2d310..51ae2d59f2967b59170be50a2c0f8ed602a01515 100644 --- a/lib_dec/fd_cng_dec.c +++ b/lib_dec/fd_cng_dec.c @@ -666,16 +666,23 @@ void generate_stereo_masking_noise_fx( IF( st->idchan == 0 ) { hFdCngCom = st->hFdCngDec->hFdCngCom; - Copy_Scale_sig_16_32( hStereoCng->olapBufferSynth22_fx, Ns_fx, shr( hFdCngCom->frameSize, 1 ), sub( Q6, st->Q_syn ) ); /*Q6*/ - Copy32( hFdCngCom->olapBufferSynth2_fx, Np_fx, shr( hFdCngCom->frameSize, 1 ) ); /*st->Q_syn*/ +#ifdef FIX_ISSUE_1237 + Copy_Scale_sig_16_32_no_sat( hStereoCng->olapBufferSynth22_fx, Ns_fx, shr( hFdCngCom->frameSize, 1 ), sub( Q6, st->Q_syn ) ); /*Q6*/ +#else + Copy_Scale_sig_16_32_DEPREC( hStereoCng->olapBufferSynth22_fx, Ns_fx, shr( hFdCngCom->frameSize, 1 ), sub( Q6, st->Q_syn ) ); /*Q6*/ +#endif + Copy32( hFdCngCom->olapBufferSynth2_fx, Np_fx, shr( hFdCngCom->frameSize, 1 ) ); /*st->Q_syn*/ set32_fx( &Np_fx[( hFdCngCom->frameSize / 2 )], 0, shr( hFdCngCom->frameSize, 1 ) ); set32_fx( &Ns_fx[( hFdCngCom->frameSize / 2 )], 0, shr( hFdCngCom->frameSize, 1 ) ); IF( !fadeOut ) { - Copy_Scale_sig_16_32( hStereoCng->olapBufferSynth22_fx, hStereoCng->olapBufferSynth22_32fx, hFdCngCom->fftlen, sub( Q15, st->Q_syn ) ); /*Q15*/ - +#ifdef FIX_ISSUE_1237 + Copy_Scale_sig_16_32_no_sat( hStereoCng->olapBufferSynth22_fx, hStereoCng->olapBufferSynth22_32fx, hFdCngCom->fftlen, sub( Q15, st->Q_syn ) ); /*Q15*/ +#else + Copy_Scale_sig_16_32_DEPREC( hStereoCng->olapBufferSynth22_fx, hStereoCng->olapBufferSynth22_32fx, hFdCngCom->fftlen, sub( Q15, st->Q_syn ) ); /*Q15*/ +#endif generate_masking_noise_ivas_fx( N1_fx, &N1_fx_exp, hFdCngCom, hFdCngCom->frameSize, 0, 1, 0, st->element_mode, hStereoCng, nchan_out ); // N1_fx Q6 /* Generate masking noise for secondary channel */ IF( flag_sec_CNA ) diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index 2bb2a39ec3184f06b3bda44d11079d0c3afa0ebf..fa7e602a54da5179a26696905633c5077bfef264 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -825,11 +825,7 @@ Word16 ApplyFdCng_fx( Carry = 0; move16(); -#ifdef BASOP_NOGLOB L_tmp = L_add_co( L_tmp, *( cngNoiseLevel + j ), &Carry, &Overflow ); /*Q31*/ -#else - L_tmp = L_add_c( L_tmp, *( cngNoiseLevel + j ) ); -#endif Overflow = 0; move16(); @@ -839,11 +835,7 @@ Word16 ApplyFdCng_fx( } IF( *( cngNoiseLevel + j ) >= 0 ) { -#ifdef BASOP_NOGLOB L_c = L_macNs_co( L_c, 0, 0, &Carry, &Overflow ); /*Q-1*/ -#else - L_c = L_macNs( L_c, 0, 0 ); -#endif } } L_tmp = norm_llQ31( L_c, L_tmp, &L_tmp_exp ); /*Q31 - L_tmp_exp*/ @@ -855,11 +847,7 @@ Word16 ApplyFdCng_fx( L_tmp_exp = add( L_tmp_exp, -7 ); /*->Q16, L_tmp_exp */ L_tmp_exp = add( L_tmp_exp, 31 - 16 ); /*->Q31, L_tmp_exp*/ -#ifdef BASOP_NOGLOB st->cngTDLevel = round_fx_sat( Sqrt32( L_tmp, &L_tmp_exp ) ); /*Q15 - L_tmp_exp*/ -#else - st->cngTDLevel = round_fx( Sqrt32( L_tmp, &L_tmp_exp ) ); -#endif st->cngTDLevel_e = L_tmp_exp; move16(); } @@ -885,11 +873,7 @@ Word16 ApplyFdCng_fx( L_tmp_exp = add( *cngNoiseLevel_exp, 16 ); test(); test(); -#ifdef BASOP_NOGLOB IF( EQ_16( concealWholeFrame, 1 ) && EQ_16( st->nbLostCmpt, 1 ) && ( GT_32( L_shl_o( L_tmp, L_tmp_exp, &Overflow ), 21474836 ) /*0.01f Q31*/ ) ) -#else - IF( EQ_16( concealWholeFrame, 1 ) && EQ_16( st->nbLostCmpt, 1 ) && ( L_shl( L_tmp, L_tmp_exp ) > 21474836 /*0.01f Q31*/ ) ) -#endif { /* update isf cng estimate for concealment. Do that during concealment, in order to avoid addition clean channel complexity*/ #ifndef IVAS_CODE_CNG_FIX185_PLC_FADEOUT @@ -991,7 +975,6 @@ Word16 ApplyFdCng_fx( Carry = 0; move16(); -#ifdef BASOP_NOGLOB /* Critical Carry/Overflow */ L_tmp = L_add_co( L_tmp, *( cngNoiseLevel + j ), &Carry, &Overflow ); /*Q31*/ Overflow = 0; move16(); @@ -1004,19 +987,6 @@ Word16 ApplyFdCng_fx( { L_c = L_macNs_co( L_c, 0, 0, &Carry, &Overflow ); /*Q-1*/ } -#else - L_tmp = L_add_c( L_tmp, *( cngNoiseLevel + j ) ); - Overflow = 0; - - if ( *( cngNoiseLevel + j ) < 0 ) - { - L_c = L_msuNs( L_c, 0, 0 ); - } - if ( *( cngNoiseLevel + j ) >= 0 ) - { - L_c = L_macNs( L_c, 0, 0 ); - } -#endif } L_tmp = norm_llQ31( L_c, L_tmp, &L_tmp_exp ); /*Q31 - L_tmp_exp*/ L_tmp_exp = sub( add( L_tmp_exp, *cngNoiseLevel_exp ), 1 ); @@ -1027,12 +997,8 @@ Word16 ApplyFdCng_fx( L_tmp_exp = add( L_tmp_exp, -7 ); /*->Q16, L_tmp_exp */ L_tmp_exp = add( L_tmp_exp, 31 - 16 ); /*->Q31, L_tmp_exp*/ -#ifdef BASOP_NOGLOB /* Critical Carry/Overflow */ - st->cngTDLevel = round_fx_o( Sqrt32( L_tmp, &L_tmp_exp ), &Overflow ); /*Q15 - L_tmp_exp*/ + st->cngTDLevel = round_fx_o( Sqrt32( L_tmp, &L_tmp_exp ), &Overflow ); /*Q15 - L_tmp_exp*/ move16(); -#else - st->cngTDLevel = round_fx( Sqrt32( L_tmp, &L_tmp_exp ) ); -#endif st->cngTDLevel_e = L_tmp_exp; move16(); #endif @@ -1434,11 +1400,7 @@ Word16 ApplyFdCng_ivas_fx( Carry = 0; move16(); -#ifdef BASOP_NOGLOB L_tmp = L_add_co( L_tmp, *( cngNoiseLevel + j ), &Carry, &Overflow ); /*Q31*/ -#else - L_tmp = L_add_c( L_tmp, *( cngNoiseLevel + j ) ); -#endif Overflow = 0; move16(); @@ -1448,11 +1410,7 @@ Word16 ApplyFdCng_ivas_fx( } IF( *( cngNoiseLevel + j ) >= 0 ) { -#ifdef BASOP_NOGLOB L_c = L_macNs_co( L_c, 0, 0, &Carry, &Overflow ); /*Q-1*/ -#else - L_c = L_macNs( L_c, 0, 0 ); -#endif } } L_tmp = norm_llQ31( L_c, L_tmp, &L_tmp_exp ); /*Q31 - L_tmp_exp*/ @@ -1464,11 +1422,7 @@ Word16 ApplyFdCng_ivas_fx( L_tmp_exp = add( L_tmp_exp, -7 ); /*->Q16, L_tmp_exp */ L_tmp_exp = add( L_tmp_exp, 31 - 16 ); /*->Q31, L_tmp_exp*/ -#ifdef BASOP_NOGLOB st->hTcxDec->conCngLevelBackgroundTrace = round_fx_sat( Sqrt32( L_tmp, &L_tmp_exp ) ); /*Q15 - L_tmp_exp*/ -#else - st->hTcxDec->conCngLevelBackgroundTrace = round_fx( Sqrt32( L_tmp, &L_tmp_exp ) ); -#endif move16(); L_tmp_exp = add( L_tmp_exp, 1 ); st->hTcxDec->conCngLevelBackgroundTrace_e = L_tmp_exp; @@ -1485,11 +1439,7 @@ Word16 ApplyFdCng_ivas_fx( Carry = 0; move16(); -#ifdef BASOP_NOGLOB L_tmp = L_add_co( L_tmp, *( cngNoiseLevel + j ), &Carry, &Overflow ); /*Q31 - L_tmp_exp*/ -#else - L_tmp = L_add_c( L_tmp, *( cngNoiseLevel + j ) ); -#endif Overflow = 0; move16(); @@ -1499,11 +1449,7 @@ Word16 ApplyFdCng_ivas_fx( } IF( *( cngNoiseLevel + j ) >= 0 ) { -#ifdef BASOP_NOGLOB L_c = L_macNs_co( L_c, 0, 0, &Carry, &Overflow ); /*Q-1*/ -#else - L_c = L_macNs( L_c, 0, 0 ); -#endif } } L_tmp = norm_llQ31( L_c, L_tmp, &L_tmp_exp ); /*Q31 - L_tmp_exp*/ @@ -1515,13 +1461,8 @@ Word16 ApplyFdCng_ivas_fx( L_tmp_exp = add( L_tmp_exp, -7 ); /*->Q16, L_tmp_exp */ L_tmp_exp = add( L_tmp_exp, 31 - 16 ); /*->Q31, L_tmp_exp*/ -#ifdef BASOP_NOGLOB st->hTcxDec->conCngLevelBackgroundTrace = round_fx_sat( Sqrt32( L_tmp, &L_tmp_exp ) ); /*Q15 - L_tmp_exp*/ move16(); -#else - st->hTcxDec->conCngLevelBackgroundTrace = round_fx( Sqrt32( L_tmp, &L_tmp_exp ) ); - st->hTcxDec->CngLevelBackgroundTrace_bfi_fx = ( Sqrt32( L_tmp, &L_tmp_exp ) ); -#endif st->hTcxDec->conCngLevelBackgroundTrace_e = L_tmp_exp; move16(); } @@ -1534,11 +1475,7 @@ Word16 ApplyFdCng_ivas_fx( Carry = 0; move16(); -#ifdef BASOP_NOGLOB L_tmp = L_add_co( L_tmp, *( cngNoiseLevel + j ), &Carry, &Overflow ); /*Q31 - L_tmp_exp*/ -#else - L_tmp = L_add_c( L_tmp, *( cngNoiseLevel + j ) ); -#endif Overflow = 0; move16(); @@ -1548,11 +1485,7 @@ Word16 ApplyFdCng_ivas_fx( } IF( *( cngNoiseLevel + j ) >= 0 ) { -#ifdef BASOP_NOGLOB L_c = L_macNs_co( L_c, 0, 0, &Carry, &Overflow ); /*Q-1*/ -#else - L_c = L_macNs( L_c, 0, 0 ); -#endif } } L_tmp = norm_llQ31( L_c, L_tmp, &L_tmp_exp ); /*Q31 - L_tmp_exp*/ @@ -1564,11 +1497,7 @@ Word16 ApplyFdCng_ivas_fx( L_tmp_exp = add( L_tmp_exp, -7 ); /*->Q16, L_tmp_exp */ L_tmp_exp = add( L_tmp_exp, 31 - 16 ); /*->Q31, L_tmp_exp*/ -#ifdef BASOP_NOGLOB st->cngTDLevel = round_fx_sat( Sqrt32( L_tmp, &L_tmp_exp ) ); /*Q15 - L_tmp_exp*/ -#else - st->cngTDLevel = round_fx( Sqrt32( L_tmp, &L_tmp_exp ) ); -#endif move16(); st->cngTDLevel_e = L_tmp_exp; move16(); @@ -1601,11 +1530,7 @@ Word16 ApplyFdCng_ivas_fx( } L_tmp_exp = 0; move16(); -#ifdef BASOP_NOGLOB IF( GT_32( L_shl_o( L_tmp, L_tmp_exp, &Overflow ), 21474836 ) /*0.01f Q31*/ ) -#else - IF( L_shl( L_tmp, L_tmp_exp ) > 21474836 /*0.01f Q31*/ ) -#endif { test(); test(); @@ -1665,7 +1590,6 @@ Word16 ApplyFdCng_ivas_fx( Carry = 0; move16(); -#ifdef BASOP_NOGLOB /* Critical Carry/Overflow */ L_tmp = L_add_co( L_tmp, *( cngNoiseLevel + j ), &Carry, &Overflow ); /*Q31 - L_tmp_exp*/ Overflow = 0; move16(); @@ -1678,19 +1602,6 @@ Word16 ApplyFdCng_ivas_fx( { L_c = L_macNs_co( L_c, 0, 0, &Carry, &Overflow ); /*Q-1*/ } -#else - L_tmp = L_add_c( L_tmp, *( cngNoiseLevel + j ) ); - Overflow = 0; - - if ( *( cngNoiseLevel + j ) < 0 ) - { - L_c = L_msuNs( L_c, 0, 0 ); - } - if ( *( cngNoiseLevel + j ) >= 0 ) - { - L_c = L_macNs( L_c, 0, 0 ); - } -#endif } L_tmp = norm_llQ31( L_c, L_tmp, &L_tmp_exp ); /*Q31 - L_tmp_exp*/ L_tmp_exp = sub( add( L_tmp_exp, *cngNoiseLevel_exp ), 1 ); @@ -1701,11 +1612,7 @@ Word16 ApplyFdCng_ivas_fx( L_tmp_exp = add( L_tmp_exp, -7 ); /*->Q16, L_tmp_exp */ L_tmp_exp = add( L_tmp_exp, 31 - 16 ); /*->Q31, L_tmp_exp*/ -#ifdef BASOP_NOGLOB /* Critical Carry/Overflow */ st->cngTDLevel = round_fx_o( Sqrt32( L_tmp, &L_tmp_exp ), &Overflow ); /*Q15 - L_tmp_exp*/ -#else - st->cngTDLevel = round_fx( Sqrt32( L_tmp, &L_tmp_exp ) ); -#endif move16(); st->cngTDLevel_e = L_tmp_exp; move16(); @@ -1900,7 +1807,12 @@ Word16 ApplyFdCng_ivas_fx( { 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(); } } @@ -2783,10 +2695,9 @@ void perform_noise_estimation_dec_ivas_fx( } ELSE { - Word16 tmp = s_max( sub( hFdCngDec->msPeriodog_exp, getScaleFactor32( msPeriodog, npart ) ), sub( hFdCngDec->msNoiseEst_exp, getScaleFactor32( &msNoiseEst[npart], sub( NPART_SHAPING, npart ) ) ) ); - Copy_Scale_sig32( msPeriodog, msNoiseEst, npart, sub( hFdCngDec->msPeriodog_exp, tmp ) ); /*Q31 - tmp*/ - scale_sig32( &msNoiseEst[npart], sub( NPART_SHAPING, npart ), sub( hFdCngDec->msNoiseEst_exp, tmp ) ); /*Q31 - tmp*/ - hFdCngDec->msNoiseEst_exp = tmp; + Copy32( msPeriodog, msNoiseEst, npart ); + scale_sig32( &msNoiseEst[npart], sub( NPART_SHAPING, npart ), sub( hFdCngDec->msNoiseEst_exp, hFdCngDec->msPeriodog_exp ) ); + hFdCngDec->msNoiseEst_exp = hFdCngDec->msPeriodog_exp; move16(); } @@ -3812,11 +3723,7 @@ void generate_comfort_noise_dec_fx( s = sub( 15 - NOISE_HEADROOM, noiseExp ); FOR( i = 0; i < N; i++ ) { -#ifdef BASOP_NOGLOB noise[i] = shr_sat( mult( noise[i], gain16 ), s ); /*Q15 - noiseExp*/ -#else - noise[i] = shr( mult( noise[i], gain16 ), s ); -#endif move16(); } @@ -3825,11 +3732,7 @@ void generate_comfort_noise_dec_fx( s = sub( 15 - NOISE_HEADROOM, ( sub( 15, Q_syn ) ) ); FOR( i = 0; i < lpcorder; i++ ) { -#ifdef BASOP_NOGLOB old_syn_pe_tmp[i] = shr_sat( old_syn_pe[i], s ); /*Q0*/ -#else - old_syn_pe_tmp[i] = shr( old_syn_pe[i], s ); -#endif move16(); } @@ -4359,11 +4262,7 @@ void generate_comfort_noise_dec_ivas_fx( s = sub( 15 - NOISE_HEADROOM, noiseExp ); FOR( i = 0; i < N; i++ ) { -#ifdef BASOP_NOGLOB noise[i] = shr_sat( mult( noise[i], gain16 ), s ); /*Q15 - noiseExp*/ -#else - noise[i] = shr( mult( noise[i], gain16 ), s ); -#endif move16(); } @@ -4372,11 +4271,7 @@ void generate_comfort_noise_dec_ivas_fx( s = sub( 15 - NOISE_HEADROOM, ( sub( 15, Q_syn ) ) ); FOR( i = 0; i < lpcorder; i++ ) { -#ifdef BASOP_NOGLOB old_syn_pe_tmp[i] = shr_sat( old_syn_pe[i], s ); /*Q0*/ -#else - old_syn_pe_tmp[i] = shr( old_syn_pe[i], s ); -#endif move16(); } @@ -4798,11 +4693,7 @@ void generate_masking_noise_fx( { FOR( i = 0; i < hFdCngCom->frameSize; i++ ) { -#ifdef BASOP_NOGLOB timeDomainBuffer[i] = add_sat( timeDomainBuffer[i], shr_r_sat( maskingNoise[i], -Q ) ); /*Q0*/ -#else - timeDomainBuffer[i] = add( timeDomainBuffer[i], shr_r( maskingNoise[i], -Q ) ); -#endif move16(); } } diff --git a/lib_dec/gain_dec_fx.c b/lib_dec/gain_dec_fx.c index 210fae39e36c330676b8d77c97dbf67bb36fed0b..5e17122311bc97e7495aa9840fa7036d069b3c24 100644 --- a/lib_dec/gain_dec_fx.c +++ b/lib_dec/gain_dec_fx.c @@ -169,11 +169,7 @@ void gain_dec_tc_fx( IF( GT_16( nBits, 3 ) ) { wgain_code = gain_dequant_fx( index, G_CODE_MIN_TC_Q15, G_CODE_MAX_TC_Q0, nBits, &expg ); -#ifdef BASOP_NOGLOB wgain_code = shl_sat( wgain_code, add( expg, 13 ) ); /* wgain_code in Q13*/ -#else - wgain_code = shl( wgain_code, add( expg, 13 ) ); /* wgain_code in Q13*/ -#endif } ELSE /* nBits == 3 */ { @@ -186,12 +182,8 @@ void gain_dec_tc_fx( *-----------------------------------------------------------------*/ /* *gain_code *= gcode0;*/ - L_tmp = L_mult( wgain_code, gcode0_fx ); /* Q13*Q0 -> Q14 */ -#ifdef BASOP_NOGLOB + L_tmp = L_mult( wgain_code, gcode0_fx ); /* Q13*Q0 -> Q14 */ *gain_code_fx = L_shl_sat( L_tmp, add( exp_gcode0, 2 ) ); /*Q16*/ -#else - *gain_code_fx = L_shl( L_tmp, add( exp_gcode0, 2 ) ); -#endif move32(); /**norm_gain_code = *gain_code / *gain_inov;*/ @@ -461,12 +453,8 @@ void gain_dec_mless_fx( gain_code16 = gain_dequant_fx( index, G_CODE_MIN_TC192_Q15, G_CODE_MAX_TC192_Q0, shr( add( nBits, 1 ), 1 ), &expg ); /**gain_code *= gcode0;*/ - L_tmp = L_mult( gain_code16, gcode0_fx ); /*Q0*Q0 -> Q1*/ -#ifdef BASOP_NOGLOB + L_tmp = L_mult( gain_code16, gcode0_fx ); /*Q0*Q0 -> Q1*/ *gain_code_fx = L_shl_sat( L_tmp, add( add( expg, exp_gcode0 ), 15 ) ); /*Q16*/ -#else - *gain_code_fx = L_shl( L_tmp, add( add( expg, exp_gcode0 ), 15 ) ); -#endif move32(); } ELSE @@ -517,22 +505,34 @@ void gain_dec_mless_fx( L_tmp = Dot_product12( code_fx, code_fx, L_SUBFR, &expg ); /*Q31 - expg*/ expg = sub( expg, 18 + 6 ); /* exp: -18 (code in Q9), -6 (/L_SUBFR) */ - expg2 = expg; - move16(); - L_tmp1 = L_tmp; /* sets to 'L_tmp' in 1 clock */ - move32(); - L_tmp = Isqrt_lc( L_tmp, &expg ); /*Q31 - expg*/ - - *gain_inov_fx = extract_h( L_shl( L_tmp, sub( expg, 3 ) ) ); /* gain_inov in Q12 */ - move16(); - - /*Ei = 10 * (float)log10( Ecode );*/ - e_tmp = norm_l( L_tmp1 ); - f_tmp = Log2_norm_lc( L_shl( L_tmp1, e_tmp ) ); /*Q15*/ - e_tmp = sub( expg2, add( 1, e_tmp ) ); - L_tmp1 = Mpy_32_16( e_tmp, f_tmp, 12330 ); /* Q13 */ /* 10*log10(2) in Q12*/ - Ei_fx = round_fx( L_shl( L_tmp1, 11 ) ); /* Q8 */ + // To avoid crash in case code value is 0 + IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( L_tmp, expg, 21474836, 0 ), -1 ) ) + { + // setting values to avoid extra computation + *gain_inov_fx = 32767; /*8(max value gain_inov can hold) in Q12*/ + Ei_fx = -9743; /* -38 in Q8*/ + move16(); + move16(); + } + ELSE + { + expg2 = expg; + move16(); + L_tmp1 = L_tmp; /* sets to 'L_tmp' in 1 clock */ + move32(); + L_tmp = Isqrt_lc( L_tmp, &expg ); /*Q31 - expg*/ + + *gain_inov_fx = extract_h( L_shl( L_tmp, sub( expg, 3 ) ) ); /* gain_inov in Q12 */ + move16(); + + /*Ei = 10 * (float)log10( Ecode );*/ + e_tmp = norm_l( L_tmp1 ); + f_tmp = Log2_norm_lc( L_shl( L_tmp1, e_tmp ) ); /*Q15*/ + e_tmp = sub( expg2, add( 1, e_tmp ) ); + L_tmp1 = Mpy_32_16( e_tmp, f_tmp, 12330 ); /* Q13 */ /* 10*log10(2) in Q12*/ + Ei_fx = round_fx( L_shl( L_tmp1, 11 ) ); /* Q8 */ + } /*-----------------------------------------------------------------* * calculate the predicted gain code *-----------------------------------------------------------------*/ @@ -560,11 +560,7 @@ void gain_dec_mless_fx( /**gain_code = qua_table[index * 2 + 1] * gcode0;*/ L_tmp = L_mult( qua_table_fx[( ( index * 2 ) + 1 )], gcode0_fx ); /* Q9*Q0 -> Q10 */ -#ifdef BASOP_NOGLOB - *gain_code_fx = L_shl_sat( L_tmp, add( exp_gcode0, 6 ) ); /*Q16*/ -#else - *gain_code_fx = L_shl( L_tmp, add( exp_gcode0, 6 ) ); -#endif + *gain_code_fx = L_shl_sat( L_tmp, add( exp_gcode0, 6 ) ); /*Q16*/ move32(); } @@ -731,11 +727,7 @@ void gain_dec_lbr_fx( move16(); L_tmp = L_mult( cdbk_fx[( ( index * 2 ) + 1 )], gcode0_fx ); /* Q9*Q0 -> Q10 */ -#ifdef BASOP_NOGLOB - *gain_code_fx = L_shl_sat( L_tmp, add( exp_gcode0, 6 ) ); /* Q10 -> Q16*/ -#else - *gain_code_fx = L_shl( L_tmp, add( exp_gcode0, 6 ) ); -#endif + *gain_code_fx = L_shl_sat( L_tmp, add( exp_gcode0, 6 ) ); /* Q10 -> Q16*/ move16(); gc_mem[0] = *gain_code_fx; /*Q16*/ @@ -805,11 +797,7 @@ void gain_dec_lbr_fx( move16(); L_tmp = L_mult( cdbk_fx[( ( index * 2 ) + 1 )], gcode0_fx ); /* Q9*Q0 -> Q10 */ -#ifdef BASOP_NOGLOB - *gain_code_fx = L_shl_sat( L_tmp, add( exp_gcode0, 6 ) ); /*Q16*/ -#else - *gain_code_fx = L_shl( L_tmp, add( exp_gcode0, 6 ) ); -#endif + *gain_code_fx = L_shl_sat( L_tmp, add( exp_gcode0, 6 ) ); /*Q16*/ move16(); gc_mem[1] = *gain_code_fx; /*Q16*/ @@ -883,11 +871,7 @@ void gain_dec_lbr_fx( move16(); L_tmp = L_mult( cdbk_fx[( ( index * 2 ) + 1 )], gcode0_fx ); /* Q9*Q0 -> Q10 */ -#ifdef BASOP_NOGLOB - *gain_code_fx = L_shl_sat( L_tmp, add( exp_gcode0, 6 ) ); /* Q10 -> Q16*/ -#else - *gain_code_fx = L_shl( L_tmp, add( exp_gcode0, 6 ) ); /* Q10 -> Q16*/ -#endif + *gain_code_fx = L_shl_sat( L_tmp, add( exp_gcode0, 6 ) ); /* Q10 -> Q16*/ move32(); gc_mem[2] = *gain_code_fx; /*Q16*/ move32(); @@ -971,11 +955,7 @@ void gain_dec_lbr_fx( move16(); L_tmp = L_mult( cdbk_fx[( ( index * 2 ) + 1 )], gcode0_fx ); /* Q9*Q0 -> Q10 */ -#ifdef BASOP_NOGLOB - *gain_code_fx = L_shl_sat( L_tmp, add( exp_gcode0, 6 ) ); /*Q16*/ -#else - *gain_code_fx = L_shl( L_tmp, add( exp_gcode0, 6 ) ); -#endif + *gain_code_fx = L_shl_sat( L_tmp, add( exp_gcode0, 6 ) ); /*Q16*/ move32(); } @@ -1117,11 +1097,7 @@ void gain_dec_lbr_ivas_fx( move16(); L_tmp = L_mult( cdbk_fx[( ( index * 2 ) + 1 )], gcode0_fx ); /* Q9*Q0 -> Q10 */ -#ifdef BASOP_NOGLOB - *gain_code_fx = L_shl_sat( L_tmp, add( exp_gcode0, 6 ) ); /*Q16*/ -#else - *gain_code_fx = L_shl( L_tmp, add( exp_gcode0, 6 ) ); -#endif + *gain_code_fx = L_shl_sat( L_tmp, add( exp_gcode0, 6 ) ); /*Q16*/ move16(); gc_mem[0] = *gain_code_fx; /*Q16*/ @@ -1191,11 +1167,7 @@ void gain_dec_lbr_ivas_fx( move16(); L_tmp = L_mult( cdbk_fx[( ( index * 2 ) + 1 )], gcode0_fx ); /* Q9*Q0 -> Q10 */ -#ifdef BASOP_NOGLOB - *gain_code_fx = L_shl_sat( L_tmp, add( exp_gcode0, 6 ) ); /*Q16*/ -#else - *gain_code_fx = L_shl( L_tmp, add( exp_gcode0, 6 ) ); -#endif + *gain_code_fx = L_shl_sat( L_tmp, add( exp_gcode0, 6 ) ); /*Q16*/ move16(); gc_mem[1] = *gain_code_fx; /*Q16*/ @@ -1269,11 +1241,7 @@ void gain_dec_lbr_ivas_fx( move16(); L_tmp = L_mult( cdbk_fx[( ( index * 2 ) + 1 )], gcode0_fx ); /* Q9*Q0 -> Q10 */ -#ifdef BASOP_NOGLOB - *gain_code_fx = L_shl_sat( L_tmp, add( exp_gcode0, 6 ) ); /* Q10 -> Q16*/ -#else - *gain_code_fx = L_shl( L_tmp, add( exp_gcode0, 6 ) ); /* Q10 -> Q16*/ -#endif + *gain_code_fx = L_shl_sat( L_tmp, add( exp_gcode0, 6 ) ); /* Q10 -> Q16*/ move32(); gc_mem[2] = *gain_code_fx; /*Q16*/ move32(); @@ -1356,11 +1324,7 @@ void gain_dec_lbr_ivas_fx( move16(); L_tmp = L_mult( cdbk_fx[( ( index * 2 ) + 1 )], gcode0_fx ); /* Q9*Q0 -> Q10 */ -#ifdef BASOP_NOGLOB - *gain_code_fx = L_shl_sat( L_tmp, add( exp_gcode0, 6 ) ); /*Q16*/ -#else - *gain_code_fx = L_shl( L_tmp, add( exp_gcode0, 6 ) ); -#endif + *gain_code_fx = L_shl_sat( L_tmp, add( exp_gcode0, 6 ) ); /*Q16*/ move32(); } @@ -1414,11 +1378,7 @@ void lp_gain_updt_fx( { Word16 tmp; -#ifdef BASOP_NOGLOB tmp = extract_h( L_shl_sat( norm_gain_code, 3 ) ); /*(16+3)-16 -> Q3*/ -#else - tmp = extract_h( L_shl( norm_gain_code, 3 ) ); /*(16+3)-16 -> Q3*/ -#endif IF( EQ_16( L_frame, L_FRAME ) ) { IF( EQ_16( i_subfr, 0 ) ) @@ -1446,11 +1406,7 @@ void lp_gain_updt_fx( { *lp_gainp = add( *lp_gainp, mult( 13107, gain_pit ) ); move16(); /*Q14 (0.4 in Q15 = 13107)*/ -#ifdef BASOP_NOGLOB *lp_gainc = mac_r_sat( L_deposit_h( *lp_gainc ), 13107, tmp ); -#else - *lp_gainc = mac_r( L_deposit_h( *lp_gainc ), 13107, tmp ); -#endif move16(); /*Q3*/ } } @@ -1488,11 +1444,7 @@ void lp_gain_updt_fx( { *lp_gainp = add( *lp_gainp, mult( 10923, gain_pit ) ); move16(); /*Q14 (5.0/15.0 in Q15 = 10923)*/ -#ifdef BASOP_NOGLOB *lp_gainc = mac_r_sat( L_deposit_h( *lp_gainc ), 10923, tmp ); -#else - *lp_gainc = mac_r( L_deposit_h( *lp_gainc ), 10923, tmp ); -#endif move16(); /*Q3*/ } } @@ -1538,11 +1490,7 @@ void lp_gain_updt_ivas_fx( { Word16 tmp; -#ifdef BASOP_NOGLOB tmp = extract_h( L_shl_sat( norm_gain_code, 3 ) ); /*(16+3)-16 -> Q3*/ -#else - tmp = extract_h( L_shl( norm_gain_code, 3 ) ); /*(16+3)-16 -> Q3*/ -#endif /* To handle extremely low values */ test(); if ( norm_gain_code != 0 && tmp == 0 ) @@ -1578,11 +1526,7 @@ void lp_gain_updt_ivas_fx( { *lp_gainp = add( *lp_gainp, mult( 13107, gain_pit ) ); move16(); /*Q14 (0.4 in Q15 = 13107)*/ -#ifdef BASOP_NOGLOB *lp_gainc = mac_r_sat( L_deposit_h( *lp_gainc ), 13107, tmp ); -#else - *lp_gainc = mac_r( L_deposit_h( *lp_gainc ), 13107, tmp ); -#endif move16(); /*Q3*/ } } @@ -1620,11 +1564,7 @@ void lp_gain_updt_ivas_fx( { *lp_gainp = add( *lp_gainp, mult( 10923, gain_pit ) ); move16(); /*Q14 (5.0/15.0 in Q15 = 10923)*/ -#ifdef BASOP_NOGLOB *lp_gainc = mac_r_sat( L_deposit_h( *lp_gainc ), 10923, tmp ); -#else - *lp_gainc = mac_r( L_deposit_h( *lp_gainc ), 10923, tmp ); -#endif move16(); /*Q3*/ } } @@ -1691,24 +1631,14 @@ Word32 gain_dec_gaus_fx( /* o : quantized codebook expg = add( expg, 16 - 30 ); /* output of Pow2() will be */ /* Normalized, set result in Q16 */ gain = round_fx( L_gain ); -#ifdef BASOP_NOGLOB L_gain = L_shl_sat( L_gain, expg ); /* In Q16*/ -#else - L_gain = L_shl( L_gain, expg ); /* In Q16*/ -#endif /* *norm_gain_code = gain / *inv_gain_inov;*/ expi = norm_s( inv_gain_inov ); tmp_igi = shl( inv_gain_inov, expi ); L_tmp = div_s( shr( gain, 1 ), tmp_igi ); -#ifdef BASOP_NOGLOB L_tmp = L_shl_sat( L_tmp, add( 1, expi ) ); *L_norm_gain_code = L_shl_sat( L_tmp, add( expg, 13 ) ); /* Q16 */ move32(); -#else - L_tmp = L_shl( L_tmp, add( 1, expi ) ); - *L_norm_gain_code = L_shl( L_tmp, add( expg, 13 ) ); /* Q16 */ - move32(); -#endif return L_gain; } @@ -1805,11 +1735,7 @@ void gain_dec_SQ_fx( /**gain_code *= gcode0;*/ L_tmp = L_mult( tmp16, gcode0 ); /* Q0*Q0 -> Q1*/ /**gain_code = L_shl(L_tmp,add(expg,15)); Q16*/ -#ifdef BASOP_NOGLOB *gain_code = L_shl_sat( L_tmp, add( add( expg, exp_gcode0 ), 15 ) ); /*Q16*/ -#else - *gain_code = L_shl( L_tmp, add( add( expg, exp_gcode0 ), 15 ) ); -#endif move32(); /**norm_gain_code = *gain_code / *gain_inov;*/ @@ -1934,11 +1860,7 @@ void gain_dec_amr_wb_fx( /* adjust gain according to energy of code */ L_tmp = Mult_32_16( *gain_code, *gain_inov ); -#ifdef BASOP_NOGLOB *gain_code = L_shl_o( L_tmp, 3, &Overflow ); /* gcode_inov in Q12*/ -#else - *gain_code = L_shl( L_tmp, 3 ); -#endif move32(); /*-----------------------------------------------------------------* diff --git a/lib_dec/gs_dec_amr_wb_fx.c b/lib_dec/gs_dec_amr_wb_fx.c index a4aef88dd698f73733008dd01196d465b25b9c76..65e9eaa87c777a89fa575441dfc820f571d521d5 100644 --- a/lib_dec/gs_dec_amr_wb_fx.c +++ b/lib_dec/gs_dec_amr_wb_fx.c @@ -111,11 +111,7 @@ static void Ener_per_band_fx( IF( L_temp != 0 ) /* avoid executing sqrt of 0 (because a div_s is used to invert and then call inv_sqrt) */ { L_temp2 = Sqrt_Ratio32( L_temp, exp, 1, 0, &i ); -#ifdef BASOP_NOGLOB L_temp2 = L_shr_sat( L_temp2, sub( 15 - ENER_FX_Q_GUARD, i ) ); /* Q16 */ -#else - L_temp2 = L_shr( L_temp2, sub( 15 - ENER_FX_Q_GUARD, i ) ); -#endif } y_gain4_fx[j] = L_temp2; /* Q16 */ move32(); @@ -155,12 +151,8 @@ static void Apply_gain_fx( { EndBin = add( CurBin, crit_bins[i_band] ); /* Q0 */ y_gain_exp = norm_l( L_Ener_per_bd_yQ[i_band] ); - exp3 = norm_l( L_Ener_per_bd_iQ[i_band] ); /* use 'exp3' as temporary exponent of 'L_Ener_per_bd_iQ[]' */ -#ifdef BASOP_NOGLOB + exp3 = norm_l( L_Ener_per_bd_iQ[i_band] ); /* use 'exp3' as temporary exponent of 'L_Ener_per_bd_iQ[]' */ y_gain_fx = round_fx_sat( Div_flt32_flt32( L_shl_sat( L_Ener_per_bd_iQ[i_band], exp3 ), exp3, L_shl_sat( L_Ener_per_bd_yQ[i_band], y_gain_exp ), y_gain_exp, &y_gain_exp ) ); /* y_gain_exp - 31 + Q_out */ -#else - y_gain_fx = round_fx( Div_flt32_flt32( L_shl( L_Ener_per_bd_iQ[i_band], exp3 ), exp3, L_shl( L_Ener_per_bd_yQ[i_band], y_gain_exp ), y_gain_exp, &y_gain_exp ) ); -#endif y_gain_exp = add( sub( y_gain_exp, 31 ), Q_out ); exp3 = sub( y_gain_exp, 16 - 1 ); @@ -204,11 +196,7 @@ static void normalize_spec_fx( temp = Invert16( abs_s( fy_norm_fx[idx] ), &exp ); /* Q15 + exp */ L_temp = L_mult( temp, fac_up_fx ); /* Q15 + exp + Q8 + 1 */ exp = sub( 15, exp ); -#ifdef BASOP_NOGLOB L_temp = L_shl_sat( L_temp, exp ); /* Q24 + Q_out */ -#else - L_temp = L_shl( L_temp, exp ); -#endif FOR( j = 0; j < L_frame; j++ ) { fy_norm_fx[j] = round_fx( Mult_32_16( L_temp, fy_norm_fx[j] ) ); /* Q_out */ @@ -264,11 +252,7 @@ static void gs_dec_amr_wb_fx( move16(); FOR( i = 0; i < CRIT_NOIS_BAND; i++ ) { -#ifdef BASOP_NOGLOB temp = s_max( round_fx_sat( Ener_per_bd_iQ_fx[i] ), temp ); /* Q0 */ -#else - temp = s_max( round_fx( Ener_per_bd_iQ_fx[i] ), temp ); -#endif } test(); @@ -487,11 +471,7 @@ void improv_amr_wb_gs_fx( FOR( i = 0; i < NB_SUBFR; i++ ) { -#ifdef BASOP_NOGLOB enr_LP_new = Enr_1_Az_fx_o( Aq_fx + imult1616( i, ( M + 1 ) ), L_SUBFR, &Overflow ); /* Q3 */ -#else - enr_LP_new = Enr_1_Az_fx( Aq_fx + i * ( M + 1 ), L_SUBFR ); -#endif test(); IF( GT_16( shr( enr_LP_new, 7 ), enr_LP_old ) || Overflow ) { diff --git a/lib_dec/gs_dec_fx.c b/lib_dec/gs_dec_fx.c index bbf06741957530167cd6f9a2c69a92ac3991c050..3a39f9e3312ee58ab31739545e069199f2d2accb 100644 --- a/lib_dec/gs_dec_fx.c +++ b/lib_dec/gs_dec_fx.c @@ -96,12 +96,22 @@ void decod_audio_fx( st_fx->GSC_noisy_speech = 0; /* Q0 */ move16(); } + /* set bit-allocation */ #ifdef ADD_LRTD +#ifdef NONBE_FIX_GSC_BSTR + config_acelp1( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, st_fx->inactive_coder_type_flag, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); +#else config_acelp1( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); +#endif +#else +#ifdef NONBE_FIX_GSC_BSTR + config_acelp1( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, st_fx->inactive_coder_type_flag, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, 0, 0, st_fx->idchan, st_fx->active_cnt, 0, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); #else config_acelp1( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, 0, 0, st_fx->idchan, st_fx->active_cnt, 0, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); #endif +#endif + /*---------------------------------------------------------------* * Decode energy dynamics *---------------------------------------------------------------*/ @@ -600,12 +610,18 @@ void decod_audio_ivas_fx( st_fx->GSC_noisy_speech = 0; move16(); } + /* set bit-allocation */ #if 1 // def ADD_LRTD +#ifdef NONBE_FIX_GSC_BSTR + config_acelp1_IVAS( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, st_fx->inactive_coder_type_flag, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); +#else config_acelp1_IVAS( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); +#endif #else config_acelp1( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, 0, 0, st_fx->idchan, st_fx->active_cnt, 0, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); #endif + /*---------------------------------------------------------------* * Decode energy dynamics *---------------------------------------------------------------*/ @@ -1586,7 +1602,14 @@ void gsc_dec_ivas_fx( #endif { pvq_core_dec_fx( st_fx, gsc_sfm_start, gsc_sfm_end, gsc_sfm_size, concat_out, &Q_tmp, bit, nb_subbands, bits_per_bands, NULL, inpulses_fx, imaxpulse_fx, ACELP_CORE ); +#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(); diff --git a/lib_dec/hf_synth_fx.c b/lib_dec/hf_synth_fx.c index e931ae229eafdbb14229cc16da6c2620fa4ba92e..c61bf95ce2298f39e258b4d8f1a0e63a8ee639fd 100644 --- a/lib_dec/hf_synth_fx.c +++ b/lib_dec/hf_synth_fx.c @@ -209,11 +209,7 @@ static void hf_synthesis_fx( L_tmp = L_mac( 1L, synth[0], synth[0] ); /* 2*(Q_syn-3)+1 */ FOR( i = 1; i < L_SUBFR; i++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_mac_sat( L_tmp, synth[i], synth[i] ); /* 2*(Q_syn-3)+1 */ -#else - L_tmp = L_mac( L_tmp, synth[i], synth[i] ); -#endif } tmp = norm_l( L_tmp ); ener = extract_h( L_shl( L_tmp, tmp ) ); /* ener = r[0] */ @@ -222,11 +218,7 @@ static void hf_synthesis_fx( L_tmp = L_mac( 1L, synth[1], synth[0] ); /* 2*(Q_syn-3)+1 */ FOR( i = 2; i < L_SUBFR; i++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_mac_sat( L_tmp, synth[i], synth[i - 1] ); /* 2*(Q_syn-3)+1 */ -#else - L_tmp = L_mac( L_tmp, synth[i], synth[i - 1] ); -#endif } tmp = extract_h( L_shl( L_tmp, tmp ) ); /* tmp = r[1] */ /*tmp in Q = 2*(Q_syn-3)+1 = Q-5 when Q_syn=0 */ @@ -245,21 +237,13 @@ static void hf_synthesis_fx( *-----------------------------------------------------------------*/ /* tmp = 1.0 - fac */ -#ifdef BASOP_NOGLOB tmp = add_o( 1, sub( 32767 /* 1 in Q15 */, tmp ), &Overflow ); -#else - tmp = add( 1, sub( 32767, tmp ) ); -#endif test(); if ( core_brate == FRAME_NO_DATA || EQ_32( core_brate, SID_2k40 ) ) { /* emphasize HF noise in CNG */ /*fac *= 2.0f;*/ -#ifdef BASOP_NOGLOB tmp = add_o( tmp, tmp, &Overflow ); /* Q15 */ -#else - tmp = add( tmp, tmp ); -#endif } tmp = s_max( tmp, 3277 ); /* 0.1 in Q15 */ @@ -380,19 +364,11 @@ static void filt_6k_7k_scale_fx( move32(); FOR( j = 0; j < 31; j++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_mac_o( L_tmp, x[i + j], fir_6k_7k_fx[j], &Overflow ); /* Q16 */ -#else - L_tmp = L_mac( L_tmp, x[i + j], fir_6k_7k_fx[j] ); -#endif } -#ifdef BASOP_NOGLOB signal[i] = round_fx_o( L_tmp, &Overflow ); /* Q0 */ move16(); -#else - signal[i] = round_fx( L_tmp ); -#endif } Copy( x + lg, mem, L_FIR - 1 ); /* Qx - 2 */ } @@ -630,12 +606,8 @@ void hf_synth_amr_wb_fx( fmerit_w = shr( fmerit_w, 1 ); /* Q14 */ } -#ifdef BASOP_NOGLOB L_tmp = L_mult( fmerit_w, add_sat( 16384, voice_fac ) ); /* Q14 */ -#else - L_tmp = L_mult( fmerit_w, add( 16384, voice_fac ) ); -#endif - fmerit_w = extract_l( L_shr( L_tmp, 15 ) ); /*Q14 */ + fmerit_w = extract_l( L_shr( L_tmp, 15 ) ); /*Q14 */ /**fmerit_w_sm = add(mult_r(*fmerit_w_sm, 29491), mult_r(fmerit_w, 3277)); //Q14 */ hAmrwb_IO->fmerit_w_sm_fx = round_fx( L_mac( L_mult( hAmrwb_IO->fmerit_w_sm_fx, 29491 ), fmerit_w, 3277 ) ); /*Q14 */ move16(); @@ -702,7 +674,7 @@ void hf_synth_amr_wb_fx( q_tmp = Exp16Array( L_FRAME, exc ); qdct = sub( q_tmp, 1 ); - Copy_Scale_sig_16_32( exc, exc32, L_FRAME, qdct ); /* Qexc + qdct */ + Copy_Scale_sig_16_32_DEPREC( exc, exc32, L_FRAME, qdct ); /* Qexc + qdct */ qdct = add( qdct, Q_exc ); edct_fx( exc32, dct_exc32, L_FRAME, &qdct ); @@ -775,11 +747,7 @@ void hf_synth_amr_wb_fx( pt4 = &dct_hb[240]; FOR( j = 0; j < fn; j++ ) { -#ifdef BASOP_NOGLOB tmp = add_sat( tmp, shr( *pt4++, 2 ) ); /*qdct-2 */ -#else - tmp = add( tmp, shr( *pt4++, 2 ) ); /*qdct-2 */ -#endif } *pt1 = round_fx( L_shl( L_mult( tmp, tmp1 ), 2 ) ); /*qdct */ move16(); @@ -802,11 +770,7 @@ void hf_synth_amr_wb_fx( pt4 = &dct_hb[fb + 240]; FOR( j = fb; j < fn; j++ ) { -#ifdef BASOP_NOGLOB tmp = add_sat( tmp, shr( *pt4++, 2 ) ); /*qdct-2 */ -#else - tmp = add( tmp, shr( *pt4++, 2 ) ); /*qdct-2 */ -#endif } *pt1 = mult_r( tmp, 8738 ); move16(); /* 8738 = 1/15 in Q17 qdct */ @@ -814,11 +778,7 @@ void hf_synth_amr_wb_fx( move16(); IF( *pt2 > 0 ) { -#ifdef BASOP_NOGLOB L_tmp = L_mac0_sat( L_tmp, shr( *pt2, 1 ), shr( *pt2, 1 ) ); /*2*qdct-2 */ -#else - L_tmp = L_mac0( L_tmp, shr( *pt2, 1 ), shr( *pt2, 1 ) ); -#endif } pt1++; pt2++; @@ -834,11 +794,7 @@ void hf_synth_amr_wb_fx( pt4 = &dct_hb[fb + 240]; FOR( j = fb; j < L_SUBFR16k; j++ ) { -#ifdef BASOP_NOGLOB tmp = add_sat( tmp, shr( *pt4++, 2 ) ); /*qdct-2 */ -#else - tmp = add( tmp, shr( *pt4++, 2 ) ); /*qdct-2 */ -#endif } *pt1 = round_fx( L_shl( L_mult( tmp, tmp1 ), 2 ) ); /*qdct */ move16(); @@ -846,11 +802,7 @@ void hf_synth_amr_wb_fx( move16(); IF( *pt2 > 0 ) { -#ifdef BASOP_NOGLOB L_tmp = L_mac0_sat( L_tmp, shr( *pt2, 1 ), shr( *pt2, 1 ) ); /*2*qdct-2 */ -#else - L_tmp = L_mac0( L_tmp, shr( *pt2, 1 ), shr( *pt2, 1 ) ); /*2*qdct-2 */ -#endif } pt1++; pt2++; @@ -878,15 +830,10 @@ void hf_synth_amr_wb_fx( *pt1 = mult_r( *pt1, g ); /*qdct */ move16(); } -#ifdef BASOP_NOGLOB *pt2 = round_fx_sat( L_shl_sat( L_mult( *pt2, inv_g ), 3 ) ); /*qdct */ move16(); *pt3 = add_sat( *pt1, *pt2 ); move16(); -#else - *pt2 = round_fx( L_shl( L_mult( *pt2, inv_g ), 3 ) ); /*qdct */ - *pt3 = add( *pt1, *pt2 ); -#endif *pt3 = extract_l( L_mult0( *pt3, *pt4 ) ); /*qdct */ move16(); pt1++; @@ -900,11 +847,7 @@ void hf_synth_amr_wb_fx( L_tmp = L_mult( ener, scale ); /*30-q1+q2 */ q2 = sub( q1, q2 ); /*30-q2 */ scale = round_fx( Isqrt( L_shl( L_tmp, sub( q2, 24 ) ) ) ); /*Q12 */ -#ifdef BASOP_NOGLOB - scale = round_fx_sat( L_shl_sat( L_mult( scale, gamma ), 4 ) ); /*Q15 */ -#else - scale = round_fx( L_shl( L_mult( scale, gamma ), 4 ) ); /*Q15 */ -#endif + scale = round_fx_sat( L_shl_sat( L_mult( scale, gamma ), 4 ) ); /*Q15 */ } ELSE { @@ -1017,7 +960,7 @@ void hf_synth_amr_wb_fx( q_tmp = Exp16Array( L_FRAME16k, dct_hb ); qhf = sub( q_tmp, 1 ); - Copy_Scale_sig_16_32( dct_hb, dct_hb32, L_FRAME16k, qhf ); /* qhf + qdct */ + Copy_Scale_sig_16_32_DEPREC( dct_hb, dct_hb32, L_FRAME16k, qhf ); /* qhf + qdct */ qhf = add( qhf, qdct ); edct_fx( dct_hb32, exc16k32, L_FRAME16k, &qhf ); q_tmp = Exp32Array( L_FRAME16k, exc16k32 ); @@ -1041,40 +984,24 @@ void hf_synth_amr_wb_fx( shift = norm_l( L_tmp ); L_tmp = L_shl( L_tmp, shift ); /*Q(q3+shift); */ q3 = add( q3, shift ); -#ifdef BASOP_NOGLOB scale = round_fx_sat( L_tmp ); /*Q(q3-16); */ -#else - scale = round_fx( L_tmp ); /*Q(q3-16); */ -#endif q3 = sub( q3, 16 ); scale = div_s( shl( 1, 14 ), scale ); /*Q(29-q3) */ L_tmp = L_mult( scale, ener ); /*Q(29-q3+q1+1) */ shift = norm_l( L_tmp ); - L_tmp = L_shl( L_tmp, shift ); /*Q(29-q3+q1+1+shift) */ -#ifdef BASOP_NOGLOB - scale = round_fx_sat( L_tmp ); /*Q(29-q3+q1+1+shift-16) */ -#else - scale = round_fx( L_tmp ); /*Q(29-q3+q1+1+shift-16) */ -#endif + L_tmp = L_shl( L_tmp, shift ); /*Q(29-q3+q1+1+shift) */ + scale = round_fx_sat( L_tmp ); /*Q(29-q3+q1+1+shift-16) */ L_tmp = L_mult( scale, e_subfr2 ); /*Q(29-q3+q1+1+shift-16+q4+1)=Q(15+q1-q3+q4+shift) */ q3 = sub( 15, q3 ); q3 = add( q3, q1 ); q3 = add( q3, shift ); q3 = add( q3, q4 ); -#ifdef BASOP_NOGLOB scale = round_fx_sat( Isqrt( L_shl_sat( L_tmp, sub( 6, q3 ) ) ) ); /*Q12 */ -#else - scale = round_fx( Isqrt( L_shl( L_tmp, sub( 6, q3 ) ) ) ); /*Q12 */ -#endif pt6 += L_SUBFR; FOR( j = 0; j < L_SUBFR16k; j++ ) { -#ifdef BASOP_NOGLOB *pt2 = round_fx_sat( L_shl_sat( L_mult( *pt2, scale ), 2 ) ); /*qhf-1 */ move16(); -#else - *pt2 = round_fx( L_shl( L_mult( *pt2, scale ), 2 ) ); /*qhf-1 */ -#endif pt2++; } } @@ -1141,14 +1068,10 @@ static void hf_synthesis_amr_wb_fx( ener = extract_h( L_tmp ); /*Q(q1+q3); */ q1 = add( q1, q3 ); - scale = div_s( shl( 1, 14 ), ener ); /*Q(29-q1) */ - L_tmp = L_mult( tmp, scale ); /*30-q1+q2 */ - q2 = sub( q1, q2 ); /*30-q2 */ -#ifdef BASOP_NOGLOB + scale = div_s( shl( 1, 14 ), ener ); /*Q(29-q1) */ + L_tmp = L_mult( tmp, scale ); /*30-q1+q2 */ + q2 = sub( q1, q2 ); /*30-q2 */ scale = round_fx_sat( Isqrt( L_shl_sat( L_tmp, sub( q2, 24 ) ) ) ); /*Q12 */ -#else - scale = round_fx( Isqrt( L_shl( L_tmp, sub( q2, 24 ) ) ) ); /*Q12 */ -#endif pt1 = exc16k; pt2 = exc2385; FOR( i = 0; i < L_SUBFR16k; i++ ) @@ -1177,14 +1100,10 @@ static void hf_synthesis_amr_wb_fx( ener = extract_h( L_tmp ); /*Q(q1+q3); */ q1 = add( q1, q3 ); - scale = div_s( shl( 1, 14 ), ener ); /*Q(29-q1) */ - L_tmp = L_mult( tmp, scale ); /*30-q1+q2 */ - q2 = sub( q1, q2 ); /*30-q2 */ -#ifdef BASOP_NOGLOB + scale = div_s( shl( 1, 14 ), ener ); /*Q(29-q1) */ + L_tmp = L_mult( tmp, scale ); /*30-q1+q2 */ + q2 = sub( q1, q2 ); /*30-q2 */ scale = round_fx_sat( Isqrt( L_shl_sat( L_tmp, sub( q2, 24 ) ) ) ); /*Q12 */ -#else - scale = round_fx( Isqrt( L_shl( L_tmp, sub( q2, 24 ) ) ) ); /*Q12 */ -#endif flag = negate( s_and( til, -0x8000 ) ); if ( GT_16( scale, 4096 /* 1.0f in Q12 */ ) ) { @@ -1287,9 +1206,7 @@ static Word16 EnhanceClass_fx( Word16 unvoicing_tmp_fx; Word16 tmp, tmp1; Word32 L_tmp; -#ifdef BASOP_NOGLOB Flag Overflow; -#endif /* Decide (*unvoicing_flag) to allow BWE enhancement when qq>pp */ @@ -1327,21 +1244,13 @@ static Word16 EnhanceClass_fx( move16(); } -#ifdef BASOP_NOGLOB if ( GT_16( sub_o( *unvoicing_fx, *unvoicing_sm_fx, &Overflow ), 3277 /* 0.1 in Q15 */ ) ) -#else - if ( GT_16( sub( *unvoicing_fx, *unvoicing_sm_fx ), 3277 ) ) -#endif { *unvoicing_flag = 1; move16(); } -#ifdef BASOP_NOGLOB if ( LT_16( sub_o( *unvoicing_fx, *unvoicing_sm_fx, &Overflow ), 1638 /* 0.05 in Q15 */ ) ) -#else - if ( LT_16( sub( *unvoicing_fx, *unvoicing_sm_fx ), 1638 ) ) -#endif { *unvoicing_flag = 0; move16(); @@ -1437,11 +1346,7 @@ static void envelope_fx( pt3 = exp_tab_q_fx; /* Q14 */ FOR( i = 0; i <= M; i++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_mac_sat( L_tmp, *pt2++, *pt3++ ); /* Q27 */ -#else - L_tmp = L_mac( L_tmp, *pt2++, *pt3++ ); -#endif } q2 = norm_l( L_tmp ); L_tmp = L_shl( L_tmp, q2 ); /*Q(27+q2)*/ @@ -1452,11 +1357,7 @@ static void envelope_fx( pt3 = exp_tab_q_fx + 33; /* Q14 */ FOR( i = 0; i <= M; i++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_mac_sat( L_tmp, *pt2++, *pt3-- ); /* Q14 */ -#else - L_tmp = L_mac( L_tmp, *pt2++, *pt3-- ); -#endif } q3 = norm_l( L_tmp ); shift = sub( q2, q3 ); @@ -1474,19 +1375,11 @@ static void envelope_fx( ry = round_fx( L_shr( L_tmp, 1 ) ); /*Q(10+q2)*/ L_tmp = L_mult( px, px ); - L_tmp = L_mac( L_tmp, py, py ); /*Q(21+2*q1)*/ -#ifdef BASOP_NOGLOB + L_tmp = L_mac( L_tmp, py, py ); /*Q(21+2*q1)*/ pp = round_fx_sat( Isqrt( L_shr( L_tmp, add( 11, shl( q1, 1 ) ) ) ) ); /*Q10*/ -#else - pp = round_fx( Isqrt( L_shr( L_tmp, add( 11, shl( q1, 1 ) ) ) ) ); /*Q10*/ -#endif L_tmp = L_mult( rx, rx ); - L_tmp = L_mac( L_tmp, ry, ry ); /*Q(21+2*q1)*/ -#ifdef BASOP_NOGLOB + L_tmp = L_mac( L_tmp, ry, ry ); /*Q(21+2*q1)*/ rr = round_fx_sat( Isqrt( L_shr( L_tmp, add( 11, shl( q2, 1 ) ) ) ) ); /*Q10*/ -#else - rr = round_fx( Isqrt( L_shr( L_tmp, add( 11, shl( q2, 1 ) ) ) ) ); /*Q10*/ -#endif Copy( Aq, As, 3 ); IF( EQ_16( shr( As[2], 1 ), -2048 /* -1.0f in Q11 */ ) ) { @@ -1517,11 +1410,7 @@ static void envelope_fx( L_tmp = L_mult( As[1], tmp ); /*Q(42-q1) */ q1 = sub( q1, 14 ); -#ifdef BASOP_NOGLOB k1 = round_fx_sat( L_shl_sat( L_tmp, q1 ) ); /*Q12 */ -#else - k1 = round_fx( L_shl( L_tmp, q1 ) ); /*Q12 */ -#endif k2 = As[2]; move16(); /*Q12 */ if ( GT_16( k2, 2458 /* 0.6f in Q12 */ ) ) @@ -1599,11 +1488,7 @@ static void envelope_fx( { IF( GT_16( rr, ( hAmrwb_IO->prev_r_fx ) ) ) { -#ifdef BASOP_NOGLOB rr = shr( add_sat( rr, ( hAmrwb_IO->prev_r_fx ) ), 1 ); -#else - rr = shr( add( rr, ( hAmrwb_IO->prev_r_fx ) ), 1 ); -#endif } hAmrwb_IO->prev_r_fx = rr; @@ -1617,14 +1502,10 @@ static void envelope_fx( rr = round_fx( L_shl( L_tmp, 3 ) ); /*Q10*/ L_tmp = L_mult( tilt, sub( 26214 /* 1.6f in Q14 */, shr( voice_factor, 1 ) ) ); /*Q28*/ L_tmp = L_max( L_tmp, 268435456 /* 1 in Q28 */ ); - L_tmp = Mult_32_16( L_tmp, qq ); /*Q23*/ -#ifdef BASOP_NOGLOB + L_tmp = Mult_32_16( L_tmp, qq ); /*Q23*/ qq = round_fx_sat( L_shl_sat( L_tmp, 3 ) ); /*Q10*/ -#else - qq = round_fx( L_shl( L_tmp, 3 ) ); /*Q10*/ -#endif - rr = s_min( rr, qq ); /* Q10 */ - rr = s_max( rr, pp ); /* Q10 */ + rr = s_min( rr, qq ); /* Q10 */ + rr = s_max( rr, pp ); /* Q10 */ } ELSE { @@ -1637,11 +1518,7 @@ static void envelope_fx( alpha = round_fx( L_shl( L_tmp, 9 ) ); /*Q14*/ L_tmp = L_mult( alpha, ( hAmrwb_IO->prev_r_fx ) ); /*Q25*/ L_tmp = L_mac( L_tmp, tmp, rr ); /*Q25*/ -#ifdef BASOP_NOGLOB - rr = round_fx_sat( L_shl_sat( L_tmp, 1 ) ); /*Q10*/ -#else - rr = round_fx( L_shl( L_tmp, 1 ) ); /*Q10*/ -#endif + rr = round_fx_sat( L_shl_sat( L_tmp, 1 ) ); /*Q10*/ } hAmrwb_IO->prev_r_fx = rr; @@ -1671,12 +1548,8 @@ static void envelope_fx( tmp = div_s( shl( 1, sub( 14, q1 ) ), pp ); /*Q(29-q1-10) */ L_tmp = L_mult( rr, tmp ); /*Q(30-q1-10+10) */ -#ifdef BASOP_NOGLOB *sub_gain = s_min( 20480 /* 5.0f in Q12 */, round_fx_sat( L_shl_sat( L_tmp, sub( q1, 2 ) ) ) ); /*Q12 */ move16(); -#else - *sub_gain = s_min( 20480, round_fx( L_shl( L_tmp, sub( q1, 2 ) ) ) ); /*Q12 */ -#endif return; } diff --git a/lib_dec/hq_core_dec_fx.c b/lib_dec/hq_core_dec_fx.c index daa8804d7c15f77ac5b20c688896fa0a611d4fe4..626f25ef4861d56dfdc4a97bf817b3929084e0a2 100644 --- a/lib_dec/hq_core_dec_fx.c +++ b/lib_dec/hq_core_dec_fx.c @@ -257,11 +257,7 @@ void hq_core_dec_fx( { /*t_audio_q[i] *= ener_match;*/ Mpy_32_16_ss( t_audio_q[i], ener_match, &L_tmp, &lsb ); /*12+13-15=10 */ -#ifdef BASOP_NOGLOB t_audio_q[i] = L_add_sat( L_shl_sat( L_tmp, 2 ), L_shr( lsb, 14 ) ); -#else - t_audio_q[i] = L_add( L_shl( L_tmp, 2 ), lshr( lsb, 14 ) ); -#endif move16(); /* Q12 */ } } @@ -497,13 +493,8 @@ void hq_core_dec_fx( test(); IF( !st_fx->bfi && st_fx->prev_bfi && GE_32( st_fx->last_total_brate, HQ_48k ) && EQ_16( st_fx->last_codec_mode, MODE2 ) && ( EQ_16( st_fx->last_core_bfi, TCX_20_CORE ) || EQ_16( st_fx->last_core_bfi, TCX_10_CORE ) ) && st_fx->plcInfo.concealment_method == TCX_NONTONAL && LT_32( st_fx->plcInfo.nbLostCmpt, 4 ) ) { -#ifdef BASOP_NOGLOB st_fx->plcInfo.recovery_gain = shl_sat( st_fx->plcInfo.recovery_gain, *Q_synth ); /* Q14 + Q_synth */ move16(); -#else - st_fx->plcInfo.recovery_gain = shl( st_fx->plcInfo.recovery_gain, *Q_synth ); - move16(); -#endif IF( st_fx->tonalMDCTconceal.q_lastPcmOut != 0 ) { Scale_sig( st_fx->tonalMDCTconceal.secondLastPcmOut, shr( st_fx->plcInfo.FrameSize, 1 ), negate( st_fx->tonalMDCTconceal.q_lastPcmOut ) ); @@ -649,6 +640,9 @@ 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; @@ -856,11 +850,7 @@ void ivas_hq_core_dec_fx( { /*t_audio_q[i] *= ener_match;*/ Mpy_32_16_ss( t_audio_q[i], ener_match, &L_tmp, &lsb ); /*12+13-15=10 */ -#ifdef BASOP_NOGLOB t_audio_q[i] = L_add_sat( L_shl_sat( L_tmp, 2 ), lshr( (Word16) lsb, 14 ) ); -#else - t_audio_q[i] = L_add( L_shl( L_tmp, 2 ), lshr( (Word16) lsb, 14 ) ); -#endif move16(); /* Q12 */ } } @@ -998,7 +988,7 @@ void ivas_hq_core_dec_fx( Copy( wtda_audio_16 + sub( shr( overlapFB, 1 ), tcx_offsetFB ), synth, L_frameTCX_glob ); /* q_wtda */ - Copy_Scale_sig_16_32( wtda_audio_16, wtda_audio, 2 * L_FRAME48k, 12 ); /* q_wtda + 12 */ + Copy_Scale_sig_16_32_DEPREC( wtda_audio_16, wtda_audio, 2 * L_FRAME48k, 12 ); /* q_wtda + 12 */ IF( !core_switching_flag ) { st_fx->last_core = ACELP_CORE; /* Restore last core Q0*/ @@ -1135,11 +1125,7 @@ void ivas_hq_core_dec_fx( test(); IF( !st_fx->bfi && st_fx->prev_bfi && GE_32( st_fx->last_total_brate, HQ_48k ) && EQ_16( st_fx->last_codec_mode, MODE2 ) && ( EQ_16( st_fx->last_core_bfi, TCX_20_CORE ) || EQ_16( st_fx->last_core_bfi, TCX_10_CORE ) ) && EQ_16( st_fx->plcInfo.concealment_method, TCX_NONTONAL ) && LT_32( st_fx->plcInfo.nbLostCmpt, 4 ) ) { -#ifdef BASOP_NOGLOB st_fx->plcInfo.recovery_gain = shl_sat( st_fx->plcInfo.recovery_gain, *Q_synth ); /* Q15 */ -#else - st_fx->plcInfo.recovery_gain = shl( st_fx->plcInfo.recovery_gain, *Q_synth ); -#endif move16(); IF( st_fx->tonalMDCTconceal.q_lastPcmOut != 0 ) { diff --git a/lib_dec/hq_hr_dec_fx.c b/lib_dec/hq_hr_dec_fx.c index 02d58f7bf5144d98500f963dd14725df4b0e8c2c..f96b8f59787008b5a1eb5bee0f584f417e4563c6 100644 --- a/lib_dec/hq_hr_dec_fx.c +++ b/lib_dec/hq_hr_dec_fx.c @@ -90,11 +90,7 @@ void hq_pred_hb_bws_fx( L_tmp = L_deposit_l( 0 ); FOR( i = 25; i < SFM_N_HARM; i++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_add_sat( L_tmp, dicn_fx[ynrm[i]] ); /*Q14*/ -#else - L_tmp = L_add( L_tmp, dicn_fx[ynrm[i]] ); /*Q14*/ -#endif } L_tmp = L_min( 8191, L_shr( L_tmp, 13 ) ); /* Q1 */ st_fx->prev_ener_shb_fx = extract_l( L_tmp ); /*Q1*/ diff --git a/lib_dec/hq_lr_dec_fx.c b/lib_dec/hq_lr_dec_fx.c index cf7aee8f013f179c82c0fb4c6c948b84d71981fb..61c1d0938eef3222ee6e0366fbdcb2f284aa9f85 100644 --- a/lib_dec/hq_lr_dec_fx.c +++ b/lib_dec/hq_lr_dec_fx.c @@ -343,12 +343,8 @@ void hq_lr_dec_fx( frac1 = L_Extract_lc( L_tmp, &exp ); /* Extract exponent of L_tmp */ L_tmp = Pow2( 30, frac1 ); exp = sub( exp, 30 ); -#ifdef BASOP_NOGLOB Ep_fx[i] = L_shl_sat( L_tmp, s_max( sub( exp, 6 ), -31 ) ); /* Q -6 */ move32(); -#else - Ep_fx[i] = L_shl( L_tmp, s_max( sub( exp, 6 ), -31 ) ); /* Q -6 */ -#endif } FOR( i = 0; i < bands_fx; i++ ) @@ -428,21 +424,12 @@ void hq_lr_dec_fx( { IF( GE_16( i, lowband ) ) { -#ifdef BASOP_NOGLOB Ep_vari_fx = L_add_sat( Ep_vari_fx, L_abs( L_sub_sat( Ep_tmp_fx[i], Ep_tmp_fx[i - 1] ) ) ); /*Q15 */ Ep_avrg_fx = L_add_sat( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ -#else - Ep_vari_fx = L_add( Ep_vari_fx, L_abs( L_sub( Ep_tmp_fx[i], Ep_tmp_fx[i - 1] ) ) ); /*Q15 */ - Ep_avrg_fx = L_add( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ -#endif } ELSE { -#ifdef BASOP_NOGLOB Ep_avrgL_fx = L_add_sat( Ep_avrgL_fx, Ep_tmp_fx[i] ); /*Q15 */ -#else - Ep_avrgL_fx = L_add( Ep_avrgL_fx, Ep_tmp_fx[i] ); /*Q15 */ -#endif if ( GT_32( Ep_tmp_fx[i], Ep_peak_fx ) ) { Ep_peak_fx = L_add( Ep_tmp_fx[i], 0 ); /*Q15 */ @@ -515,16 +502,11 @@ void hq_lr_dec_fx( IF( EQ_16( last_bitalloc_max_band[j++], 1 ) ) { L_tmp = Mult_32_16( Ep_tmp_fx[i], sub( bands_fx, lowband ) ); /*Q(13+0-15 = -2) */ -#ifdef BASOP_NOGLOB tmp = Calc_inv( L_shl_sat( L_tmp, 14 ), &exp ); L_tmp = L_shl_sat( Mult_32_16( Ep_avrg_fx, tmp ), sub( 14, exp ) ); /*Q(13+exp-15 +14-exp+2 = 14) */ -#else - tmp = Calc_inv( L_shl( L_tmp, 14 ), &exp ); - L_tmp = L_shl( Mult_32_16( Ep_avrg_fx, tmp ), sub( 14, exp ) ); /*Q(13+exp-15 +14-exp+2 = 14) */ -#endif - L_tmp = L_max( L_tmp, 16384 ); /*14 */ - tmp = extract_l( L_min( L_tmp, beta_fx ) ); /*14 */ - alpha_fx = shl( mult( alpha_fx, tmp ), 1 ); /*14+14-15 +1=14 */ + L_tmp = L_max( L_tmp, 16384 ); /*14 */ + tmp = extract_l( L_min( L_tmp, beta_fx ) ); /*14 */ + alpha_fx = shl( mult( alpha_fx, tmp ), 1 ); /*14+14-15 +1=14 */ } ELSE { @@ -563,11 +545,7 @@ void hq_lr_dec_fx( { IF( GE_16( i, lowband ) ) { -#ifdef BASOP_NOGLOB Ep_avrg_fx = L_add_sat( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ -#else - Ep_avrg_fx = L_add( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ -#endif } ELSE { @@ -614,11 +592,7 @@ void hq_lr_dec_fx( } FOR( i = 0; i < bands_fx; i++ ) { -#ifdef BASOP_NOGLOB Ep_tmp_fx[i] = L_shl_sat( Ep_tmp_fx[i], 2 ); /* Q15 */ -#else - Ep_tmp_fx[i] = L_shl( Ep_tmp_fx[i], 2 ); -#endif move32(); } IF( EQ_32( st_fx->core_brate, ACELP_13k20 ) ) @@ -649,30 +623,17 @@ void hq_lr_dec_fx( test(); IF( GE_16( i, lowband ) && add( sub( i, bands_fx ), p2a_bands_fx ) < 0 ) { -#ifdef BASOP_NOGLOB Ep_vari_fx = L_add_sat( Ep_vari_fx, L_abs( L_sub( Ep_tmp_fx[i], Ep_tmp_fx[i - 1] ) ) ); /*Q15 */ Ep_avrg_fx = L_add_sat( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ -#else - Ep_vari_fx = L_add( Ep_vari_fx, L_abs( L_sub( Ep_tmp_fx[i], Ep_tmp_fx[i - 1] ) ) ); /*Q15 */ - Ep_avrg_fx = L_add( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ -#endif } IF( GE_16( i, highband ) ) { -#ifdef BASOP_NOGLOB enerH_fx = L_add_sat( enerH_fx, L_shl_sat( Ep_fx[i], 2 ) ); /*Q0 */ -#else - enerH_fx = L_add( enerH_fx, L_shl( Ep_fx[i], 2 ) ); /*Q0 */ -#endif } ELSE IF( GE_16( i, lowband ) ) { -#ifdef BASOP_NOGLOB enerL_fx = L_add_sat( enerL_fx, L_shl_sat( Ep_fx[i], 2 ) ); /*Q0 */ -#else - enerL_fx = L_add( enerL_fx, L_shl( Ep_fx[i], 2 ) ); /*Q0 */ -#endif } } @@ -693,11 +654,7 @@ void hq_lr_dec_fx( tmp = sub( bands_fx, p2a_bands_fx ); tmp = sub( tmp, lowband ); /*Q0 */ -#ifdef BASOP_NOGLOB tmp1 = extract_h( L_shl_sat( Ep_avrg_fx, 1 ) ); /*Q0 */ -#else - tmp1 = extract_h( L_shl( Ep_avrg_fx, 1 ) ); /*Q0 */ -#endif IF( tmp1 != 0 ) { exp = norm_s( tmp1 ); @@ -738,11 +695,7 @@ void hq_lr_dec_fx( { tmp = sub( tmp, lowband ); L_tmp = Mult_32_16( Ep_tmp_fx[i], tmp ); /*Q(15+0-15 = 0) */ -#ifdef BASOP_NOGLOB tmp = Calc_inv( L_shl_sat( L_tmp, 16 ), &exp ); -#else - tmp = Calc_inv( L_shl( L_tmp, 16 ), &exp ); -#endif L_tmp = Mult_32_16( Ep_avrg_fx, tmp ); /*Q(15+exp-15 = exp) */ L_tmp = L_shl( L_tmp, sub( 14, exp ) ); /*Q14 */ tmp = extract_l( L_min( L_max( L_tmp, 16384 ), 20480 ) ); /*Q14 */ @@ -753,11 +706,7 @@ void hq_lr_dec_fx( { tmp = sub( tmp, lowband ); -#ifdef BASOP_NOGLOB tmp1 = extract_h( L_shl_sat( Ep_avrg_fx, 1 ) ); /*Q0 */ -#else - tmp1 = extract_h( L_shl( Ep_avrg_fx, 1 ) ); /*Q0 */ -#endif IF( tmp1 != 0 ) { exp = norm_s( tmp1 ); @@ -794,19 +743,11 @@ void hq_lr_dec_fx( { IF( GE_16( i, lowband ) ) { -#ifdef BASOP_NOGLOB Ep_avrg_fx = L_add_sat( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ -#else - Ep_avrg_fx = L_add( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ -#endif } ELSE { -#ifdef BASOP_NOGLOB Ep_avrgL_fx = L_add_sat( Ep_avrgL_fx, Ep_tmp_fx[i] ); /*Q15 */ -#else - Ep_avrgL_fx = L_add( Ep_avrgL_fx, Ep_tmp_fx[i] ); /*Q15 */ -#endif if ( GT_32( Ep_tmp_fx[i], Ep_peak_fx ) ) { Ep_peak_fx = L_add( Ep_tmp_fx[i], 0 ); /*Q15 */ @@ -831,11 +772,7 @@ void hq_lr_dec_fx( move16(); FOR( i = 0; i < lowband; i++ ) { -#ifdef BASOP_NOGLOB tmp = Calc_inv( L_shl_sat( Ep_avrgL_fx, 1 ), &exp ); -#else - tmp = Calc_inv( L_shl( Ep_avrgL_fx, 1 ), &exp ); -#endif L_tmp = Mult_32_16( Ep_peak_fx, tmp ); /*Q(15+exp-15 = exp) */ L_tmp = Mult_32_16( L_tmp, lowband ); /*Q(exp+0-15 = exp-15) */ L_tmp = L_shl( L_tmp, sub( 28, exp ) ); /*Q14 0.5 */ diff --git a/lib_dec/igf_dec_fx.c b/lib_dec/igf_dec_fx.c index 7dd389164151197fe8c9a61d8fabb161354d5419..4f74c31ca8f1484fb0b9066555abc59658062070 100644 --- a/lib_dec/igf_dec_fx.c +++ b/lib_dec/igf_dec_fx.c @@ -1570,16 +1570,10 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in { Carry = 0; move16(); -#ifdef BASOP_NOGLOB /* Critical Carry/Overflow*/ L_tmp = L_add_co( L_tmp, energyTmp[tb], &Carry, &Overflow ); // Q31 - dE_e Overflow = 0; move16(); L_c = L_macNs_co( L_c, 0, 0, &Carry, &Overflow ); -#else - L_tmp = L_add_c( L_tmp, energyTmp[tb] ); - Overflow = 0; - L_c = L_macNs( L_c, 0, 0 ); -#endif } L_tmp = norm_llQ31( L_c, L_tmp, &shift ); // Q31 /* float: dE = (float)sqrt(dE / 24.f); basop: */ @@ -1679,13 +1673,8 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in /* Build a threshold and compare with L_tmp. Build negated threshold and compare with negated L_tmp to cover also fullscale L_tmp case */ BASOP_SATURATE_WARNING_OFF_EVS -#ifdef BASOP_NOGLOB L_tmp2 = L_shl_sat( L_negate( Mpy_32_16_1( sNlocal, 33 /*0.001f Q15*/ ) ), sub( sNlocal_e, L_tmp_e ) ); L_tmp2 = L_sub_sat( L_tmp2, L_negate( L_tmp ) ); -#else - L_tmp2 = L_shl( L_negate( Mpy_32_16_1( sNlocal, 33 /*0.001f Q15*/ ) ), sub( sNlocal_e, L_tmp_e ) ); - L_tmp2 = L_sub( L_tmp2, L_negate( L_tmp ) ); -#endif BASOP_SATURATE_WARNING_ON_EVS IF( L_tmp2 < 0 ) @@ -1697,13 +1686,8 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in /* calc square root of L_tmp and store result in dN */ L_tmp = Sqrt32( L_tmp, &L_tmp_e ); -#ifdef BASOP_NOGLOB dN[sfb] = round_fx_sat( L_tmp ); move16(); -#else - dN[sfb] = round_fx( L_tmp ); - move16(); -#endif dN_e[sfb] = L_tmp_e; move16(); dN[sfb + 1] = dN[sfb]; @@ -1759,13 +1743,8 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in /* Build a threshold and compare with L_tmp. Build negated threshold and compare with negated L_tmp to cover also fullscale L_tmp case */ BASOP_SATURATE_WARNING_OFF_EVS -#ifdef BASOP_NOGLOB L_tmp2 = L_shl_sat( L_negate( Mpy_32_16_1( sNlocal, 33 /*0.001f Q15*/ ) ), sub( sNlocal_e, L_tmp_e ) ); L_tmp2 = L_sub_sat( L_tmp2, L_negate( L_tmp ) ); -#else - L_tmp2 = L_shl( L_negate( Mpy_32_16_1( sNlocal, 33 /*0.001f Q15*/ ) ), sub( sNlocal_e, L_tmp_e ) ); - L_tmp2 = L_sub( L_tmp2, L_negate( L_tmp ) ); -#endif BASOP_SATURATE_WARNING_ON_EVS IF( L_tmp2 < 0 ) @@ -1904,12 +1883,8 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in sum = shl( sum, shift ); /* exponent of sum: sub(15, shift) */ /* divide E by sum */ -#ifdef BASOP_NOGLOB /* Critical Carry/Overflow*/ tmp = div_s( shr( round_fx_o( E, &Overflow ), 1 ), sum ); /* shift E 1 bit to the right in order to make it smaller than sum */ -#else - tmp = div_s( shr( round_fx( E ), 1 ), sum ); /* shift E 1 bit to the right in order to make it smaller than sum */ -#endif - tmp_e = sub( add( E_e, 1 ), sub( 15, shift ) ); /* 15Q0 | sum is 15Q0 */ + tmp_e = sub( add( E_e, 1 ), sub( 15, shift ) ); /* 15Q0 | sum is 15Q0 */ /* multiply the result by the hopsize */ L_tmp = L_mult( tmp, hopsize ); @@ -2040,12 +2015,8 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in move16(); /* gain[sfb] = min(gain[sfb], 12.f); */ - BASOP_SATURATE_WARNING_OFF_EVS /* threshold, may overflow */ -#ifdef BASOP_NOGLOB + BASOP_SATURATE_WARNING_OFF_EVS /* threshold, may overflow */ tmp = shl_sat( gain[sfb], sub( gain_e[sfb], 15 - 5 ) ); /* 10Q5 | tmp is in 10Q5 */ -#else - tmp = shl( gain[sfb], sub( gain_e[sfb], 15 - 5 ) ); /* 10Q5 | tmp is in 10Q5 */ -#endif BASOP_SATURATE_WARNING_ON_EVS IF( tmp > 384 ) /* 10Q5 | 384 = 12 in 10Q5 */ @@ -2288,15 +2259,9 @@ static void IGF_appl_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in { Carry = 0; move16(); -#ifdef BASOP_NOGLOB /* Critical Carry/Overflow*/ L_tmp = L_add_co( L_tmp, energyTmp[tb], &Carry, &Overflow ); // Q31 - dE_e Overflow = 0; L_c = L_macNs_co( L_c, 0, 0, &Carry, &Overflow ); -#else - L_tmp = L_add_c( L_tmp, energyTmp[tb] ); - Overflow = 0; - L_c = L_macNs( L_c, 0, 0 ); -#endif } L_tmp = norm_llQ31( L_c, L_tmp, &shift ); // Q31 /* float: dE = (float)sqrt(dE / 24.f); basop: */ @@ -2399,13 +2364,8 @@ static void IGF_appl_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in /* Build a threshold and compare with L_tmp. Build negated threshold and compare with negated L_tmp to cover also fullscale L_tmp case */ BASOP_SATURATE_WARNING_OFF_EVS -#ifdef BASOP_NOGLOB L_tmp2 = L_shl_sat( L_negate( Mpy_32_16_1( sNlocal, 33 /*0.001f Q15*/ ) ), sub( sNlocal_e, L_tmp_e ) ); L_tmp2 = L_sub_sat( L_tmp2, L_negate( L_tmp ) ); -#else - L_tmp2 = L_shl( L_negate( Mpy_32_16_1( sNlocal, 33 /*0.001f Q15*/ ) ), sub( sNlocal_e, L_tmp_e ) ); - L_tmp2 = L_sub( L_tmp2, L_negate( L_tmp ) ); -#endif BASOP_SATURATE_WARNING_ON_EVS IF( L_tmp2 < 0 ) @@ -2610,12 +2570,8 @@ static void IGF_appl_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in sum = shl( sum, shift ); /* exponent of sum: sub(15, shift) */ /* divide E by sum */ -#ifdef BASOP_NOGLOB /* Critical Carry/Overflow*/ tmp = div_s( shr( round_fx_o( E, &Overflow ), 1 ), sum ); /* shift E 1 bit to the right in order to make it smaller than sum */ -#else - tmp = div_s( shr( round_fx( E ), 1 ), sum ); /* shift E 1 bit to the right in order to make it smaller than sum */ -#endif - tmp_e = sub( add( E_e, 1 ), sub( 15, shift ) ); /* 15Q0 | sum is 15Q0 */ + tmp_e = sub( add( E_e, 1 ), sub( 15, shift ) ); /* 15Q0 | sum is 15Q0 */ /* multiply the result by the hopsize */ L_tmp = L_mult( tmp, hopsize ); @@ -2702,12 +2658,8 @@ static void IGF_appl_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in move16(); /* gain[sfb] = min(gain[sfb], 12.f); */ - BASOP_SATURATE_WARNING_OFF_EVS /* threshold, may overflow */ -#ifdef BASOP_NOGLOB + BASOP_SATURATE_WARNING_OFF_EVS /* threshold, may overflow */ tmp = shl_sat( gain[sfb], sub( gain_e[sfb], 15 - 5 ) ); /* 10Q5 | tmp is in 10Q5 */ -#else - tmp = shl( gain[sfb], sub( gain_e[sfb], 15 - 5 ) ); /* 10Q5 | tmp is in 10Q5 */ -#endif BASOP_SATURATE_WARNING_ON_EVS IF( tmp > 384 ) /* 10Q5 | 384 = 12 in 10Q5 */ @@ -2952,19 +2904,22 @@ 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 ); + 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 FOR( i = start; i < stop - level; i++ ) { ak = 0; move32(); - ak_e = 0; 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 = L_deposit_h( BASOP_Util_Divide3216_Scale( ak, add( shl( level, 1 ), 1 ), &tmp_e ) ); - ak_e = add( tmp_e, sub( shl( sub( in_e, s_l ), 1 ), 15 ) ); // tmp_e + 2 * (in_e - s_l) - 15 + 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 ); @@ -2977,7 +2932,6 @@ static void IGF_getWhiteSpectralData_ivas( FOR( ; i < stop; i++ ) { ak = 0; - ak_e = 0; move32(); move16(); @@ -2986,8 +2940,7 @@ static void IGF_getWhiteSpectralData_ivas( 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 + ak = Mult_32_16( ak, quo ); n = sub( 30, add( norm_l( ak ), sub( 31, ak_e ) ) ); n = shr( n, 1 ); @@ -3036,11 +2989,7 @@ static void IGF_RefineGrid( H_IGF_GRID hGrid /**< in move16(); tmp = add( tmp, 1 ); delta = sub( hGrid->swb_offset[sfb + 1], hGrid->swb_offset[sfb] ); -#ifdef BASOP_NOGLOB /* TBV for 16 kHz, 9.6kbps dtx condition, hGrid->swb_offset[sfb+1] points to an uninit value */ delta = mac_r( 0x00195000, 29491 /*0.45f Q16*/, shl_o( delta, 5, &Overflow ) ); -#else - delta = mac_r( 0x00195000, 29491 /*0.45f Q16*/, shl( delta, 5 ) ); -#endif a[tmp] = add( hGrid->swb_offset[sfb], shr( delta, 6 ) ); move16(); IF( s_and( a[tmp], 1 ) != 0 ) @@ -3088,11 +3037,7 @@ static void IGF_RefineGrid_ivas_fx( H_IGF_GRID hGrid /**< in/out: | IGF grid han move16(); tmp = add( tmp, 1 ); delta = sub( hGrid->swb_offset[sfb + 1], hGrid->swb_offset[sfb] ); -#ifdef BASOP_NOGLOB /* TBV for 16 kHz, 9.6kbps dtx condition, hGrid->swb_offset[sfb+1] points to an uninit value */ delta = mac_r( 0x00195000, 29491 /*0.45f Q16*/, shl_o( delta, 5, &Overflow ) ); -#else - delta = mac_r( 0x00195000, 29491 /*0.45f Q16*/, shl( delta, 5 ) ); -#endif a[tmp] = add( hGrid->swb_offset[sfb], shr( delta, 6 ) ); move16(); // Rounding off delta values >=t+0.5 to t+1 diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index 36246f73923c7b643e2709a7b7fc6faa71ace490..f23c0b7106036dbd7f90b8539e4b9e28c027e5f5 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -70,6 +70,7 @@ static void ivas_binRenderer_filterModule_fx( Word32 *filterStatesLeftRealPtr_fx, *filterStatesLeftImagPtr_fx; Word16 *Q_filterStates; const Word32 *filterTapsLeftRealPtr_fx, *filterTapsLeftImagPtr_fx, *filterTapsRightRealPtr_fx, *filterTapsRightImagPtr_fx; + Word16 shift_q; FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) { @@ -87,11 +88,6 @@ static void ivas_binRenderer_filterModule_fx( FOR( k = 0; k < numTimeSlots; k++ ) { Word64 outRealLeft_fx = 0, outRealRight_fx = 0, outImagLeft_fx = 0, outImagRight_fx = 0; - Word64 W_sub1 = 0, W_add1 = 0, W_sub2 = 0, W_add2 = 0; - move64(); - move64(); - move64(); - move64(); move64(); move64(); move64(); @@ -104,31 +100,32 @@ static void ivas_binRenderer_filterModule_fx( filterStatesLeftImagPtr_fx[tapIdx] = filterStatesLeftImagPtr_fx[tapIdx - 1]; move32(); - W_sub1 = W_sub( W_mult0_32_32( filterStatesLeftRealPtr_fx[tapIdx], filterTapsLeftRealPtr_fx[tapIdx] ), - W_mult0_32_32( filterStatesLeftImagPtr_fx[tapIdx], filterTapsLeftImagPtr_fx[tapIdx] ) ); // Q29 + Q_filterStates[tapIdx - 1] - W_add1 = W_add( W_mult0_32_32( filterStatesLeftRealPtr_fx[tapIdx], filterTapsLeftImagPtr_fx[tapIdx] ), - W_mult0_32_32( filterStatesLeftImagPtr_fx[tapIdx], filterTapsLeftRealPtr_fx[tapIdx] ) ); // Q29 + Q_filterStates[tapIdx - 1] - W_sub2 = W_sub( W_mult0_32_32( filterStatesLeftRealPtr_fx[tapIdx], filterTapsRightRealPtr_fx[tapIdx] ), - W_mult0_32_32( filterStatesLeftImagPtr_fx[tapIdx], filterTapsRightImagPtr_fx[tapIdx] ) ); // Q29 + Q_filterStates[tapIdx - 1] - W_add2 = W_add( W_mult0_32_32( filterStatesLeftRealPtr_fx[tapIdx], filterTapsRightImagPtr_fx[tapIdx] ), - W_mult0_32_32( filterStatesLeftImagPtr_fx[tapIdx], filterTapsRightRealPtr_fx[tapIdx] ) ); // Q29 + Q_filterStates[tapIdx - 1] + 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 ); - outRealLeft_fx = W_shr( outRealLeft_fx, sub( Q_filterStates[tapIdx], Q_filterStates[tapIdx - 1] ) ); - outImagLeft_fx = W_shr( outImagLeft_fx, sub( Q_filterStates[tapIdx], Q_filterStates[tapIdx - 1] ) ); - outRealRight_fx = W_shr( outRealRight_fx, sub( Q_filterStates[tapIdx], Q_filterStates[tapIdx - 1] ) ); - outImagRight_fx = W_shr( outImagRight_fx, sub( Q_filterStates[tapIdx], Q_filterStates[tapIdx - 1] ) ); + outRealLeft_fx = W_mac_32_32( outRealLeft_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsLeftRealPtr_fx[tapIdx] ); + outRealLeft_fx = W_mac_32_32( outRealLeft_fx, L_negate( filterStatesLeftImagPtr_fx[tapIdx] ), filterTapsLeftImagPtr_fx[tapIdx] ); // Q30 + Q_filterStates[tapIdx - 1] - Q_filterStates[tapIdx] = Q_filterStates[tapIdx - 1]; - move16(); + outImagLeft_fx = W_mac_32_32( outImagLeft_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsLeftImagPtr_fx[tapIdx] ); + outImagLeft_fx = W_mac_32_32( outImagLeft_fx, filterStatesLeftImagPtr_fx[tapIdx], filterTapsLeftRealPtr_fx[tapIdx] ); + + outRealRight_fx = W_mac_32_32( outRealRight_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsRightRealPtr_fx[tapIdx] ); + outRealRight_fx = W_mac_32_32( outRealRight_fx, L_negate( filterStatesLeftImagPtr_fx[tapIdx] ), filterTapsRightImagPtr_fx[tapIdx] ); - /* Left Real and Imag */ - outRealLeft_fx = W_add( outRealLeft_fx, W_sub1 ); // Q29 + Q_filterStates[1] - outImagLeft_fx = W_add( outImagLeft_fx, W_add1 ); // Q29 + Q_filterStates[1] + outImagRight_fx = W_mac_32_32( outImagRight_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsRightImagPtr_fx[tapIdx] ); + outImagRight_fx = W_mac_32_32( outImagRight_fx, filterStatesLeftImagPtr_fx[tapIdx], filterTapsRightRealPtr_fx[tapIdx] ); - /* Right Real and Imag*/ - outRealRight_fx = W_add( outRealRight_fx, W_sub2 ); // Q29 + Q_filterStates[1] - outImagRight_fx = W_add( outImagRight_fx, W_add2 ); // Q29 + Q_filterStates[1] + Q_filterStates[tapIdx] = Q_filterStates[tapIdx - 1]; + move16(); } + shift_q = add( sub( Q_filterStates[1], Q_curr ), 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 ); filterStatesLeftRealPtr_fx[0] = CLDFB_real[chIdx][k][bandIdx]; move32(); @@ -141,27 +138,29 @@ static void ivas_binRenderer_filterModule_fx( /* Left Real and Imag */ // Q29 + Q_curr - out_Conv_CLDFB_real[0][k][bandIdx] = W_add( out_Conv_CLDFB_real[0][k][bandIdx], - W_add( W_shr( outRealLeft_fx, sub( Q_filterStates[1], Q_curr ) ), - W_sub( W_mult0_32_32( filterStatesLeftRealPtr_fx[0], filterTapsLeftRealPtr_fx[0] ), - W_mult0_32_32( filterStatesLeftImagPtr_fx[0], filterTapsLeftImagPtr_fx[0] ) ) ) ); // Q29 + Word32 temp1 = L_shr( filterStatesLeftRealPtr_fx[0], 1 ); + Word32 temp2 = L_shr( filterStatesLeftImagPtr_fx[0], 1 ); + + + outRealLeft_fx = W_mac_32_32( outRealLeft_fx, temp1, filterTapsLeftRealPtr_fx[0] ); + outRealLeft_fx = W_mac_32_32( outRealLeft_fx, L_negate( temp2 ), filterTapsLeftImagPtr_fx[0] ); + out_Conv_CLDFB_real[0][k][bandIdx] = W_add( out_Conv_CLDFB_real[0][k][bandIdx], outRealLeft_fx ); // Q29 move64(); - out_Conv_CLDFB_imag[0][k][bandIdx] = W_add( out_Conv_CLDFB_imag[0][k][bandIdx], - W_add( W_shr( outImagLeft_fx, sub( Q_filterStates[1], Q_curr ) ), - W_add( W_mult0_32_32( filterStatesLeftRealPtr_fx[0], filterTapsLeftImagPtr_fx[0] ), - W_mult0_32_32( filterStatesLeftImagPtr_fx[0], filterTapsLeftRealPtr_fx[0] ) ) ) ); // Q29 + + outImagLeft_fx = W_mac_32_32( outImagLeft_fx, temp1, filterTapsLeftImagPtr_fx[0] ); + outImagLeft_fx = W_mac_32_32( outImagLeft_fx, temp2, filterTapsLeftRealPtr_fx[0] ); + out_Conv_CLDFB_imag[0][k][bandIdx] = W_add( out_Conv_CLDFB_imag[0][k][bandIdx], outImagLeft_fx ); // Q29 move64(); /* Right Real and Imag */ - out_Conv_CLDFB_real[1][k][bandIdx] = W_add( out_Conv_CLDFB_real[1][k][bandIdx], - W_add( W_shr( outRealRight_fx, sub( Q_filterStates[1], Q_curr ) ), - W_sub( W_mult0_32_32( filterStatesLeftRealPtr_fx[0], filterTapsRightRealPtr_fx[0] ), - W_mult0_32_32( filterStatesLeftImagPtr_fx[0], filterTapsRightImagPtr_fx[0] ) ) ) ); // Q29 + outRealRight_fx = W_mac_32_32( outRealRight_fx, temp1, filterTapsRightRealPtr_fx[0] ); + outRealRight_fx = W_mac_32_32( outRealRight_fx, L_negate( temp2 ), filterTapsRightImagPtr_fx[0] ); + out_Conv_CLDFB_real[1][k][bandIdx] = W_add( out_Conv_CLDFB_real[1][k][bandIdx], outRealRight_fx ); // Q29 move64(); - out_Conv_CLDFB_imag[1][k][bandIdx] = W_add( out_Conv_CLDFB_imag[1][k][bandIdx], - W_add( W_shr( outImagRight_fx, sub( Q_filterStates[1], Q_curr ) ), - W_add( W_mult0_32_32( filterStatesLeftRealPtr_fx[0], filterTapsRightImagPtr_fx[0] ), - W_mult0_32_32( filterStatesLeftImagPtr_fx[0], filterTapsRightRealPtr_fx[0] ) ) ) ); // Q29 + + outImagRight_fx = W_mac_32_32( outImagRight_fx, temp1, filterTapsRightImagPtr_fx[0] ); + outImagRight_fx = W_mac_32_32( outImagRight_fx, temp2, filterTapsRightRealPtr_fx[0] ); + out_Conv_CLDFB_imag[1][k][bandIdx] = W_add( out_Conv_CLDFB_imag[1][k][bandIdx], outImagRight_fx ); // Q29 move64(); } } diff --git a/lib_dec/ivas_core_dec.c b/lib_dec/ivas_core_dec.c index e7708a747520a7675af7f515f362ec4a001d0c8f..8d88074a835df6e35864fd37d80a0641b7551910 100644 --- a/lib_dec/ivas_core_dec.c +++ b/lib_dec/ivas_core_dec.c @@ -120,9 +120,7 @@ ivas_error ivas_core_dec_fx( Word16 tdm_lsfQ_PCh_fx[M], tdm_lspQ_PCh_fx[M]; Word32 conceal_eof_gain32; -#ifdef BASOP_NOGLOB Flag Overflow; -#endif error = IVAS_ERR_OK; move32(); @@ -355,7 +353,11 @@ ivas_error ivas_core_dec_fx( Word16 ovl, fade_len; IF( NE_16( sts[0]->L_frame, sts[0]->last_L_frame ) ) { - Copy_Scale_sig_16_32( sts[0]->hHQ_core->old_out_LB_fx, sts[0]->hHQ_core->old_outLB_fx, L_FRAME32k, sub( Q11, sts[0]->hHQ_core->Q_old_wtda_LB ) ); // Q11 +#ifdef FIX_ISSUE_1237 + Copy_Scale_sig_16_32_no_sat( sts[0]->hHQ_core->old_out_LB_fx, sts[0]->hHQ_core->old_outLB_fx, 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_outLB_fx, L_FRAME32k, sub( Q11, sts[0]->hHQ_core->Q_old_wtda_LB ) ); // Q11 +#endif L_lerp_fx_q11( sts[0]->hHQ_core->old_outLB_fx, sts[0]->hHQ_core->old_outLB_fx, sts[0]->L_frame, sts[0]->last_L_frame ); Copy_Scale_sig_32_16( sts[0]->hHQ_core->old_outLB_fx, sts[0]->hHQ_core->old_out_LB_fx, L_FRAME32k, sub( sts[0]->hHQ_core->Q_old_wtda_LB, Q11 ) ); // Q_old_wtda_LB } @@ -474,7 +476,7 @@ ivas_error ivas_core_dec_fx( move16(); move16(); - Copy_Scale_sig_16_32( st->previoussynth_fx, st->previoussynth_fx_32, L_FRAME48k, 0 ); // Q0 + Copy_Scale_sig_16_32_DEPREC( st->previoussynth_fx, st->previoussynth_fx_32, L_FRAME48k, 0 ); // Q0 IF( NE_32( ( error = core_switching_pre_dec_ivas_fx( st, output_frame, sts[0]->last_core_brate, nchan_out, last_element_mode, last_element_brate, st->Q_syn, &Q_olapBufferSynth, &Q_olapBufferSynth2 ) ), IVAS_ERR_OK ) ) { @@ -548,9 +550,12 @@ ivas_error ivas_core_dec_fx( return error; } } - - Copy_Scale_sig_16_32( output_16_fx[n], output_32_fx[n], L_FRAME48k, sub( Q11, st->Q_syn2 ) ); // Q_syn2->Q11 - Scale_sig( output_16_fx[n], L_FRAME48k, negate( st->Q_syn2 ) ); // Q0 +#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 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 */ @@ -569,17 +574,19 @@ 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 ) { - Copy_Scale_sig_16_32( save_hb_synth_16_fx, save_hb_synth_32_fx, output_frame, Q11 ); // Q11 + Copy_Scale_sig_16_32_DEPREC( save_hb_synth_16_fx, save_hb_synth_32_fx, output_frame, Q11 ); // Q11 hSCE->q_save_hb_synth_fx = Q11; move16(); } - Copy_Scale_sig_16_32( old_syn_12k8_16k_fx_16, old_syn_12k8_16k_fx[n], L_FRAME16k, Q11 - ( -Q1 ) ); // Q(11 - (-1)) + Copy_Scale_sig_16_32_DEPREC( old_syn_12k8_16k_fx_16, old_syn_12k8_16k_fx[n], L_FRAME16k, Q11 - ( -Q1 ) ); // Q(11 - (-1)) } Copy_Scale_sig_32_16( st->previoussynth_fx_32, st->previoussynth_fx, L_FRAME48k, 0 ); // Q0 @@ -636,7 +643,7 @@ ivas_error ivas_core_dec_fx( stereo_tcx_core_dec_fx( st, frameMode[n], output_16_fx[n], synth_16_fx[n], pitch_buf_fx[n], sba_dirac_stereo_flag, hStereoTD, last_element_mode, flag_sec_CNA, hStereoCng, nchan_out, ivas_format ); st->hHQ_core->Q_old_wtda_LB = st->hHQ_core->Q_old_wtda; move16(); - Copy_Scale_sig_16_32( output_16_fx[n], output_32_fx[n], L_FRAME48k, Q11 ); // Q11 + Copy_Scale_sig_16_32_DEPREC( output_16_fx[n], output_32_fx[n], L_FRAME48k, Q11 ); // Q11 IF( st->hTcxDec ) { @@ -663,7 +670,7 @@ 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( output_16_fx[n], output_32_fx[n], L_FRAME48k, sub( Q11, Q_output ) ); // Q11 + 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 @@ -683,8 +690,11 @@ 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 ); - - Copy_Scale_sig_16_32( hCPE->hCoreCoder[0]->old_pitch_buf_16_fx, hCPE->hCoreCoder[0]->old_pitch_buf_fx, add( imult1616( 2, NB_SUBFR16k ), 2 ), Q10 ); // Q16 +#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 */ @@ -915,11 +925,19 @@ ivas_error ivas_core_dec_fx( /* Memories Re-Scaling */ IF( st->hBWE_TD != NULL ) { - Copy_Scale_sig_16_32( st->hBWE_TD->syn_overlap_fx, st->hBWE_TD->syn_overlap_fx_32, L_SHB_LAHEAD, sub( Q11, st->prev_Q_bwe_syn2 ) ); // Q11 - Copy_Scale_sig_16_32( st->hBWE_TD->old_tbe_synth_fx, st->hBWE_TD->old_tbe_synth_fx_32, L_SHB_TRANSITION_LENGTH, sub( Q11, st->prev_Qx ) ); // Q11 - Copy_Scale_sig_16_32( st->hBWE_TD->state_lsyn_filt_dwn_shb_fx, st->hBWE_TD->state_lsyn_filt_dwn_shb_fx_32, ALLPASSSECTIONS_STEEP * 2, sub( Q11, st->prev_Qx ) ); // Q11 - Copy_Scale_sig_16_32( st->hBWE_TD->state_lsyn_filt_shb_fx, st->hBWE_TD->state_lsyn_filt_shb_fx_32, ALLPASSSECTIONS_STEEP * 2, sub( Q11, st->prev_Qx ) ); // Q11 - Copy_Scale_sig_16_32( st->hBWE_TD->mem_resamp_HB_fx, st->hBWE_TD->mem_resamp_HB_fx_32, INTERP_3_1_MEM_LEN, sub( Q11, st->prev_Qx ) ); // Q11 +#ifdef FIX_ISSUE_1237 + Copy_Scale_sig_16_32_no_sat( st->hBWE_TD->syn_overlap_fx, st->hBWE_TD->syn_overlap_fx_32, L_SHB_LAHEAD, sub( Q11, st->prev_Q_bwe_syn2 ) ); // Q11 + Copy_Scale_sig_16_32_no_sat( st->hBWE_TD->old_tbe_synth_fx, st->hBWE_TD->old_tbe_synth_fx_32, L_SHB_TRANSITION_LENGTH, sub( Q11, st->prev_Qx ) ); // Q11 + Copy_Scale_sig_16_32_no_sat( st->hBWE_TD->state_lsyn_filt_dwn_shb_fx, st->hBWE_TD->state_lsyn_filt_dwn_shb_fx_32, ALLPASSSECTIONS_STEEP * 2, sub( Q11, st->prev_Qx ) ); // Q11 + Copy_Scale_sig_16_32_no_sat( st->hBWE_TD->state_lsyn_filt_shb_fx, st->hBWE_TD->state_lsyn_filt_shb_fx_32, ALLPASSSECTIONS_STEEP * 2, sub( Q11, st->prev_Qx ) ); // Q11 + Copy_Scale_sig_16_32_no_sat( st->hBWE_TD->mem_resamp_HB_fx, st->hBWE_TD->mem_resamp_HB_fx_32, INTERP_3_1_MEM_LEN, sub( Q11, st->prev_Qx ) ); // Q11 +#else + Copy_Scale_sig_16_32_DEPREC( st->hBWE_TD->syn_overlap_fx, st->hBWE_TD->syn_overlap_fx_32, L_SHB_LAHEAD, sub( Q11, st->prev_Q_bwe_syn2 ) ); // Q11 + Copy_Scale_sig_16_32_DEPREC( st->hBWE_TD->old_tbe_synth_fx, st->hBWE_TD->old_tbe_synth_fx_32, L_SHB_TRANSITION_LENGTH, sub( Q11, st->prev_Qx ) ); // Q11 + Copy_Scale_sig_16_32_DEPREC( st->hBWE_TD->state_lsyn_filt_dwn_shb_fx, st->hBWE_TD->state_lsyn_filt_dwn_shb_fx_32, ALLPASSSECTIONS_STEEP * 2, sub( Q11, st->prev_Qx ) ); // Q11 + Copy_Scale_sig_16_32_DEPREC( st->hBWE_TD->state_lsyn_filt_shb_fx, st->hBWE_TD->state_lsyn_filt_shb_fx_32, ALLPASSSECTIONS_STEEP * 2, sub( Q11, st->prev_Qx ) ); // Q11 + Copy_Scale_sig_16_32_DEPREC( st->hBWE_TD->mem_resamp_HB_fx, st->hBWE_TD->mem_resamp_HB_fx_32, INTERP_3_1_MEM_LEN, sub( Q11, st->prev_Qx ) ); // Q11 +#endif Copy( st->hBWE_TD->mem_resamp_HB_fx, st->hBWE_TD->state_32and48k_WB_upsample_fx, ( 2 * ALLPASSSECTIONS_STEEP ) ); } /*---------------------------------------------------------------------* @@ -932,7 +950,11 @@ 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 ) ) ) { - Copy_Scale_sig_16_32( synth_16_fx[n], hSCE->save_synth_fx, output_frame, sub( hSCE->q_save_synth_fx, Q_synth ) ); // q_save_synth_fx +#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 } IVAS_FORMAT ivas_format; @@ -967,7 +989,11 @@ 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 ) ) { - Copy_Scale_sig_16_32( synth_16_fx[n], hSCE->save_synth_fx, output_frame, sub( hSCE->q_save_synth_fx, Q_synth ) ); // q_save_synth_fx +#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 */ @@ -989,11 +1015,15 @@ ivas_error ivas_core_dec_fx( IF( st->hHQ_core == NULL ) { - Copy_Scale_sig_16_32( st->delay_buf_out_fx, st->delay_buf_out32_fx, ( HQ_DELTA_MAX * HQ_DELAY_COMP ), Q11 ); // Q11 + Copy_Scale_sig_16_32_DEPREC( st->delay_buf_out_fx, st->delay_buf_out32_fx, ( HQ_DELTA_MAX * HQ_DELAY_COMP ), Q11 ); // Q11 } ELSE { - Copy_Scale_sig_16_32( 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 +#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 @@ -1085,17 +1115,31 @@ ivas_error ivas_core_dec_fx( } /* Memories Re-Scaling */ - Copy_Scale_sig_16_32( hb_synth_16_fx[n], hb_synth_32_fx[n], L_FRAME48k, sub( Q11, Q_hb_synth_fx ) ); // Q11 - Copy_Scale_sig_16_32( output_16_fx[n], output_32_fx[n], L_FRAME48k, sub( Q11, Q_input ) ); // Q11 - Copy_Scale_sig_16_32( synth_16_fx[n], synth_32_fx[n], L_FRAME48k, sub( Q11, Q_synth_fx ) ); // Q11 +#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 ) { - Copy_Scale_sig_16_32( 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 +#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( st->hBWE_TD != NULL ) { - Copy_Scale_sig_16_32( st->hBWE_TD->old_tbe_synth_fx, st->hBWE_TD->old_tbe_synth_fx_32, L_SHB_TRANSITION_LENGTH, sub( Q11, st->prev_Qx ) ); // Q11 +#ifdef FIX_ISSUE_1237 + Copy_Scale_sig_16_32_no_sat( st->hBWE_TD->old_tbe_synth_fx, st->hBWE_TD->old_tbe_synth_fx_32, L_SHB_TRANSITION_LENGTH, sub( Q11, st->prev_Qx ) ); // Q11 +#else + Copy_Scale_sig_16_32_DEPREC( st->hBWE_TD->old_tbe_synth_fx, st->hBWE_TD->old_tbe_synth_fx_32, L_SHB_TRANSITION_LENGTH, sub( Q11, st->prev_Qx ) ); // Q11 +#endif } /*---------------------------------------------------------------------* @@ -1175,11 +1219,7 @@ ivas_error ivas_core_dec_fx( { hb_synth_32_fx[n][i] = Mpy_32_16_1( hb_synth_32_fx[n][i], tmp16_2 ); /* Q11 */ move32(); -#ifdef BASOP_NOGLOB tmp16_2 = add_o( tmp16_2, tmp16, &Overflow ); /* Q15 */ -#else - tmp16_2 = add( tmp16_2, tmp16 ); -#endif } } @@ -1213,7 +1253,7 @@ ivas_error ivas_core_dec_fx( test(); IF( st->core_brate == FRAME_NO_DATA || EQ_32( st->core_brate, SID_2k40 ) ) { - Copy_Scale_sig_16_32( hb_synth_16_fx[n], hb_synth_32_fx[n], L_FRAME48k, ( Q11 ) ); // Q11 + Copy_Scale_sig_16_32_DEPREC( hb_synth_16_fx[n], hb_synth_32_fx[n], L_FRAME48k, ( Q11 ) ); // Q11 } Scale_sig( st->hBWE_TD->state_lpc_syn_fx, LPC_SHB_ORDER, negate( sub( Q8, st->prev_Q_bwe_syn ) ) ); // Q0 @@ -1399,7 +1439,7 @@ ivas_error ivas_core_dec_fx( /* Delay hb_synth */ Word32 hb_prev_synth_buffer_fx_32[111]; - Copy_Scale_sig_16_32( st->hb_prev_synth_buffer_fx, hb_prev_synth_buffer_fx_32, 111, 11 ); // Q11 + Copy_Scale_sig_16_32_DEPREC( st->hb_prev_synth_buffer_fx, hb_prev_synth_buffer_fx_32, 111, 11 ); // Q11 delay_signal_fx( hb_synth_32_fx[n], output_frame, hb_prev_synth_buffer_fx_32, tmps ); Copy_Scale_sig_32_16( hb_prev_synth_buffer_fx_32, st->hb_prev_synth_buffer_fx, 111, -( 11 ) ); // Q0 } @@ -1484,8 +1524,14 @@ ivas_error ivas_core_dec_fx( { IF( hCPE->hCoreCoder[ch_ind]->hHQ_core != NULL ) { - Copy_Scale_sig_16_32( hCPE->hCoreCoder[ch_ind]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[ch_ind]->hHQ_core->old_outLB_fx, L_FRAME32k, sub( Q11, hCPE->hCoreCoder[ch_ind]->hHQ_core->Q_old_wtda_LB ) ); // Q11 - Copy_Scale_sig_16_32( hCPE->hCoreCoder[ch_ind]->hHQ_core->old_out_fx, hCPE->hCoreCoder[ch_ind]->hHQ_core->oldOut_fx, L_FRAME48k, sub( Q11, hCPE->hCoreCoder[ch_ind]->hHQ_core->Q_old_wtda ) ); // Q11 +#ifdef FIX_ISSUE_1237 + Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[ch_ind]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[ch_ind]->hHQ_core->old_outLB_fx, L_FRAME32k, sub( Q11, hCPE->hCoreCoder[ch_ind]->hHQ_core->Q_old_wtda_LB ) ); // Q11 + Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[ch_ind]->hHQ_core->old_out_fx, hCPE->hCoreCoder[ch_ind]->hHQ_core->oldOut_fx, L_FRAME48k, sub( Q11, hCPE->hCoreCoder[ch_ind]->hHQ_core->Q_old_wtda ) ); // Q11 + +#else + Copy_Scale_sig_16_32_DEPREC( hCPE->hCoreCoder[ch_ind]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[ch_ind]->hHQ_core->old_outLB_fx, L_FRAME32k, sub( Q11, hCPE->hCoreCoder[ch_ind]->hHQ_core->Q_old_wtda_LB ) ); // Q11 + Copy_Scale_sig_16_32_DEPREC( hCPE->hCoreCoder[ch_ind]->hHQ_core->old_out_fx, hCPE->hCoreCoder[ch_ind]->hHQ_core->oldOut_fx, L_FRAME48k, sub( Q11, hCPE->hCoreCoder[ch_ind]->hHQ_core->Q_old_wtda ) ); // Q11 +#endif } } } @@ -1496,8 +1542,13 @@ ivas_error ivas_core_dec_fx( { IF( hSCE->hCoreCoder[0]->hHQ_core != NULL ) { - Copy_Scale_sig_16_32( hSCE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, hSCE->hCoreCoder[0]->hHQ_core->old_outLB_fx, L_FRAME32k, sub( Q11, hSCE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB ) ); // Q11 - Copy_Scale_sig_16_32( hSCE->hCoreCoder[0]->hHQ_core->old_out_fx, hSCE->hCoreCoder[0]->hHQ_core->oldOut_fx, L_FRAME48k, sub( Q11, hSCE->hCoreCoder[0]->hHQ_core->Q_old_wtda ) ); // Q11 +#ifdef FIX_ISSUE_1237 + Copy_Scale_sig_16_32_no_sat( hSCE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, hSCE->hCoreCoder[0]->hHQ_core->old_outLB_fx, L_FRAME32k, sub( Q11, hSCE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB ) ); // Q11 + Copy_Scale_sig_16_32_no_sat( hSCE->hCoreCoder[0]->hHQ_core->old_out_fx, hSCE->hCoreCoder[0]->hHQ_core->oldOut_fx, L_FRAME48k, sub( Q11, hSCE->hCoreCoder[0]->hHQ_core->Q_old_wtda ) ); // Q11 +#else + Copy_Scale_sig_16_32_DEPREC( hSCE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, hSCE->hCoreCoder[0]->hHQ_core->old_outLB_fx, L_FRAME32k, sub( Q11, hSCE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB ) ); // Q11 + Copy_Scale_sig_16_32_DEPREC( hSCE->hCoreCoder[0]->hHQ_core->old_out_fx, hSCE->hCoreCoder[0]->hHQ_core->oldOut_fx, L_FRAME48k, sub( Q11, hSCE->hCoreCoder[0]->hHQ_core->Q_old_wtda ) ); // Q11 +#endif } } } diff --git a/lib_dec/ivas_cpe_dec_fx.c b/lib_dec/ivas_cpe_dec_fx.c index d8ebe8d4b1f8bd7e306eb97b2c9e7ffab2cc82fb..f36a227b32970760a0b83b0e0d053df624245c9f 100644 --- a/lib_dec/ivas_cpe_dec_fx.c +++ b/lib_dec/ivas_cpe_dec_fx.c @@ -126,14 +126,22 @@ ivas_error ivas_cpe_dec_fx( test(); IF( hCPE->hCoreCoder[ind1] && hCPE->hCoreCoder[ind1]->hHQ_core ) { - Copy_Scale_sig_16_32( hCPE->hCoreCoder[ind1]->hHQ_core->old_out_fx, hCPE->hCoreCoder[ind1]->hHQ_core->oldOut_fx, L_FRAME48k, sub( Q11, hCPE->hCoreCoder[ind1]->hHQ_core->Q_old_wtda ) ); // Q11 +#ifdef FIX_ISSUE_1237 + Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[ind1]->hHQ_core->old_out_fx, hCPE->hCoreCoder[ind1]->hHQ_core->oldOut_fx, 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->oldOut_fx, 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 ) { - Copy_Scale_sig_16_32( hCPE->hCoreCoder[ind1]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[ind1]->hHQ_core->old_outLB_fx, L_FRAME32k, sub( Q11, hCPE->hCoreCoder[ind1]->hHQ_core->Q_old_wtda_LB ) ); // Q11 +#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_outLB_fx, 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_outLB_fx, 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(); } @@ -346,6 +354,10 @@ ivas_error ivas_cpe_dec_fx( { sts[0]->total_brate = hCPE->element_brate; /* Only mono downmix was transmitted in this case */ move32(); +#ifdef MSAN_FIX + hCPE->hStereoDft->frame_sid_nodata = 0; + move16(); +#endif } ELSE { @@ -680,7 +692,7 @@ ivas_error ivas_cpe_dec_fx( stereo_dft_dec_res_fx( hCPE, res_buf_fx, q_res_buf, output[1] ); - Copy_Scale_sig_16_32( hCPE->hCoreCoder[0]->old_pitch_buf_16_fx, hCPE->hCoreCoder[0]->old_pitch_buf_fx, ( ( 2 * NB_SUBFR16k ) + 2 ), 10 ); // Q6->Q16 + Copy_Scale_sig_16_32_DEPREC( hCPE->hCoreCoder[0]->old_pitch_buf_16_fx, hCPE->hCoreCoder[0]->old_pitch_buf_fx, ( ( 2 * NB_SUBFR16k ) + 2 ), 10 ); // Q6->Q16 Scale_sig32( output[1], L_FRAME8k, ( Q11 - Q15 ) ); // Q15 -> Q11 diff --git a/lib_dec/ivas_dirac_output_synthesis_cov.c b/lib_dec/ivas_dirac_output_synthesis_cov.c index 5aa649ecda5e1fe8388321724dac753b47b0d351..fd039fe965fd2a8f87867d037f31f73ec8267f3a 100644 --- a/lib_dec/ivas_dirac_output_synthesis_cov.c +++ b/lib_dec/ivas_dirac_output_synthesis_cov.c @@ -410,8 +410,6 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot_fx( const Word16 nchan_in /* i : number of input channels */ ) { - Word16 cx_init_e; - Word16 cx_init_imag_e; Word16 band_idx, ch_idx; Word16 brange[2]; Word32 real_in_buffer_fx[PARAM_MC_MAX_BANDS_IN_PARAMETER_BAND * MAX_TRANSPORT_CHANNELS]; @@ -421,10 +419,9 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot_fx( Word32 real_buffer_fx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; Word32 imag_buffer_fx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; Word16 output_e; - Word16 i, j, tmp1, tmp2, tmp1_e, tmp2_e, shift_imag, shift_real; - Word32 L_tmp; + Word16 tmp1_e, tmp2_e, shift_imag, shift_real; Word16 band, num_bands; - + Word16 cx_fx_norm, cx_imag_fx_norm; /* estimate input covariance */ /* Already stack here instead of in the process_subframe */ @@ -451,8 +448,11 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot_fx( move16(); imag_in_e = ImagBuffer_e; move16(); - shift_real = sub( L_norm_arr( real_in_buffer_fx, imult1616( num_bands, nchan_in ) ), find_guarded_bits_fx( add( num_bands, 1 ) ) ); - shift_imag = sub( L_norm_arr( imag_in_buffer_fx, imult1616( num_bands, nchan_in ) ), find_guarded_bits_fx( add( num_bands, 1 ) ) ); + + Word16 buf_len = imult1616( num_bands, nchan_in ); + + shift_real = sub( L_norm_arr( real_in_buffer_fx, buf_len ), find_guarded_bits_fx( add( num_bands, 1 ) ) ); + shift_imag = sub( L_norm_arr( imag_in_buffer_fx, buf_len ), find_guarded_bits_fx( add( num_bands, 1 ) ) ); real_in_e = sub( real_in_e, shift_real ); imag_in_e = sub( imag_in_e, shift_imag ); @@ -460,50 +460,23 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot_fx( output_e = s_max( real_in_e, imag_in_e ); - FOR( i = 0; i < num_bands * nchan_in; ++i ) - { - real_in_buffer_fx[i] = L_shr( real_in_buffer_fx[i], sub( output_e, RealBuffer_e ) ); // Q(31-output_e) - move32(); - imag_in_buffer_fx[i] = L_shr( imag_in_buffer_fx[i], sub( output_e, ImagBuffer_e ) ); // Q(31-output_e) - move32(); - } + scale_sig32( real_in_buffer_fx, buf_len, sub( RealBuffer_e, output_e ) ); + scale_sig32( imag_in_buffer_fx, buf_len, sub( ImagBuffer_e, output_e ) ); cmplx_matrix_square_fx( real_in_buffer_fx, imag_in_buffer_fx, num_bands, nchan_in, real_buffer_fx, imag_buffer_fx, output_e, &output_e ); v_add_fixed_me( cx_fx, *cx_e, real_buffer_fx, output_e, cx_fx, &tmp1_e, imult1616( nchan_in, nchan_in ), 1 ); v_add_fixed_me( cx_imag_fx, *cx_imag_e, imag_buffer_fx, output_e, cx_imag_fx, &tmp2_e, imult1616( nchan_in, nchan_in ), 1 ); - cx_init_e = tmp1_e; - move16(); - cx_init_imag_e = tmp2_e; - move16(); - // normalizing both the matrices to a common exponent for a better precision - tmp1 = 0; - move16(); - tmp2 = 0; - move16(); - - FOR( j = 0; j < PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS; j++ ) - { - L_tmp = BASOP_Util_Add_Mant32Exp( cx_fx[j], cx_init_e, 0, 0, &tmp1_e ); - L_tmp = BASOP_Util_Add_Mant32Exp( cx_imag_fx[j], cx_init_imag_e, 0, 0, &tmp2_e ); - tmp1 = s_max( tmp1, tmp1_e ); - tmp2 = s_max( tmp2, tmp2_e ); - } + cx_fx_norm = L_norm_arr( cx_fx, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); + cx_imag_fx_norm = L_norm_arr( cx_imag_fx, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); - FOR( j = 0; j < PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS; j++ ) - { - L_tmp = BASOP_Util_Add_Mant32Exp( cx_fx[j], cx_init_e, 0, 0, &tmp1_e ); - cx_fx[j] = L_shr( L_tmp, sub( tmp1, tmp1_e ) ); // Q(31-tmp1) - move32(); - L_tmp = BASOP_Util_Add_Mant32Exp( cx_imag_fx[j], cx_init_imag_e, 0, 0, &tmp2_e ); - cx_imag_fx[j] = L_shr( L_tmp, sub( tmp2, tmp2_e ) ); // Q(31-tmp2) - move32(); - } + scale_sig32( cx_fx, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS, cx_fx_norm ); + scale_sig32( cx_imag_fx, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS, cx_imag_fx_norm ); - *cx_e = tmp1; + *cx_e = sub( tmp1_e, cx_fx_norm ); move16(); - *cx_imag_e = tmp2; + *cx_imag_e = sub( tmp2_e, cx_imag_fx_norm ); move16(); return; diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index d69fa852593acbfeb82f9af47792f4ad2fb6cd19..427959388143e37d7c43de44e36cfdc42cd146eb 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -436,8 +436,13 @@ ivas_error ivas_jbm_dec_tc_fx( } IF( hCPE->hCoreCoder[0] != NULL ) { - Copy_Scale_sig_16_32( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[0]->hHQ_core->old_outLB_fx, L_FRAME32k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB ); // q - Copy_Scale_sig_16_32( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, hCPE->hCoreCoder[0]->hHQ_core->oldOut_fx, L_FRAME48k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda ); // q +#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_outLB_fx, 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->oldOut_fx, 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_outLB_fx, 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->oldOut_fx, L_FRAME48k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda ); // q +#endif hCPE->hCoreCoder[0]->hHQ_core->q_old_outLB_fx = q; move16(); } @@ -601,7 +606,7 @@ 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 + 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; @@ -968,8 +973,13 @@ ivas_error ivas_jbm_dec_tc_fx( } IF( hCPE->hCoreCoder[0] != NULL ) { - Copy_Scale_sig_16_32( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[0]->hHQ_core->old_outLB_fx, L_FRAME32k, sub( q, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB ) ); // q - Copy_Scale_sig_16_32( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, hCPE->hCoreCoder[0]->hHQ_core->oldOut_fx, L_FRAME48k, sub( q, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda ) ); // q +#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_outLB_fx, 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->oldOut_fx, 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_outLB_fx, 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->oldOut_fx, 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(); } @@ -1423,8 +1433,13 @@ ivas_error ivas_jbm_dec_tc_fx( IF( hCPE->hCoreCoder[0] != NULL ) { - Copy_Scale_sig_16_32( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[0]->hHQ_core->old_outLB_fx, L_FRAME32k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB ); // q - Copy_Scale_sig_16_32( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, hCPE->hCoreCoder[0]->hHQ_core->oldOut_fx, L_FRAME48k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda ); // q +#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_outLB_fx, 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->oldOut_fx, 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_outLB_fx, 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->oldOut_fx, L_FRAME48k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda ); // q +#endif hCPE->hCoreCoder[0]->hHQ_core->q_old_outLB_fx = q; move16(); } diff --git a/lib_dec/ivas_lfe_plc_fx.c b/lib_dec/ivas_lfe_plc_fx.c index 6e3969255e36c9094dcd4f8ec13cd7217c4b0308..2c2b5d5ebc8515cf341ca98bc7dad841220c59cd 100644 --- a/lib_dec/ivas_lfe_plc_fx.c +++ b/lib_dec/ivas_lfe_plc_fx.c @@ -1027,7 +1027,7 @@ void ivas_lfe_tdplc_fx( } } - Copy_Scale_sig_16_32( rec_frame_us_16_fx, rec_frame_us_fx, LFE_PLC_RECLEN_48K, 10 ); // Q10 = rec_frame_q + 5 + Copy_Scale_sig_16_32_DEPREC( rec_frame_us_16_fx, rec_frame_us_fx, LFE_PLC_RECLEN_48K, 10 ); // Q10 = rec_frame_q + 5 FOR( i = 0; i < 2; i++ ) { diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index f3afead8fe1b8c7a8c86783f0c498986ebff91c5..a8cda4e586b1a8beb122949a36bc295b0787810b 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -86,6 +86,10 @@ 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; @@ -162,6 +166,18 @@ 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 ) + { + FOR( n = 0; n < CPE_CHANNELS; n++ ) + { + p_output_orig_fx[n] = output_fx[n]; + output_fx[n] = synth_32_fx[n]; + } + } +#endif + FOR( cpe_id = 0; cpe_id < nCPE; cpe_id++ ) { st_ivas->hCPE[cpe_id]->hCoreCoder[0]->BER_detect = s_or( st_ivas->hCPE[cpe_id]->hCoreCoder[0]->BER_detect, st_ivas->BER_detect ); @@ -250,9 +266,9 @@ ivas_error ivas_mct_dec_fx( FOR( n = 0; n < CPE_CHANNELS; n++ ) { - Copy_Scale_sig_16_32( Aq_fx[cpe_id][n], Aq_fx_32[cpe_id][n], 102, Q16 - Q12 ); // Q16 - 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 + Copy_Scale_sig_16_32_DEPREC( Aq_fx[cpe_id][n], Aq_fx_32[cpe_id][n], 102, Q16 - Q12 ); // Q16 + 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 x_e[n][0] = 20; move16(); move16(); @@ -334,10 +350,13 @@ 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 } - - Copy_Scale_sig_16_32( 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( 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 ) ) ) ); - +#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; @@ -368,6 +387,18 @@ 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 ) + { + FOR( n = 0; n < CPE_CHANNELS; n++ ) + { + output_fx[n] = p_output_orig_fx[n]; + } + } + +#endif /*----------------------------------------------------------------* * CoreCoder Post-processing and updates @@ -380,9 +411,13 @@ 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 ) ) ) ) { - - Copy_Scale_sig_16_32( synth_fx[n], synth_fx_32[n], L_FRAME48k, sub( Q11, ( sub( 15, e_sig[n] ) ) ) ); // Q11 - Copy_Scale_sig_16_32( hCPE->hCoreCoder[n]->hHQ_core->old_out_fx, hCPE->hCoreCoder[n]->hHQ_core->oldOut_fx, output_frame, sub( Q11, hCPE->hCoreCoder[n]->hHQ_core->Q_old_wtda ) ); +#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->oldOut_fx, 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->oldOut_fx, 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 @@ -419,9 +454,11 @@ ivas_error ivas_mct_dec_fx( { return error; } - - Copy_Scale_sig_16_32( synth_fx[n], output_fx[( cpe_id * CPE_CHANNELS ) + n], output_frame, sub( Q11, Q_synth ) ); // Q11 - +#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 @@ -441,7 +478,11 @@ ivas_error ivas_mct_dec_fx( { IF( hCPE->hCoreCoder[n] ) { - Copy_Scale_sig_16_32( hCPE->hCoreCoder[n]->delay_buf_out_fx, hCPE->hCoreCoder[n]->delay_buf_out32_fx, HQ_DELTA_MAX * HQ_DELAY_COMP, Q11 ); // Q0 -> Q11 +#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 } } diff --git a/lib_dec/ivas_mdct_core_dec.c b/lib_dec/ivas_mdct_core_dec.c index b80bff932e923b09a077d4bad722d61314b63c07..9c189e6a151d2c4fe27a4665c2e763ef67ef8c25 100644 --- a/lib_dec/ivas_mdct_core_dec.c +++ b/lib_dec/ivas_mdct_core_dec.c @@ -731,11 +731,16 @@ 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 - Copy_Scale_sig_16_32( 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( 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 +#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( 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( sts[1]->hTonalMDCTConc->lastBlockData.spectralData, spectralData_tmp[1], L_FRAME_MAX, 15 - ( common_exp - sts[1]->hTonalMDCTConc->lastBlockData.spectralData_exp ) ); // 30 - spectral_exp2 + 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; @@ -1399,8 +1404,11 @@ void ivas_mdct_core_reconstruct_fx( move16(); st->last_coder_type = st->coder_type; move16(); - - Copy_Scale_sig_16_32( x_fx_16, x_fx[ch][0], st->L_frame, sub( q_x, q_syn ) ); // q_syn -> Q_x +#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] ) ) @@ -1504,6 +1512,9 @@ 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 */ diff --git a/lib_dec/ivas_post_proc.c b/lib_dec/ivas_post_proc.c index ce361c8944e774d6b7cb85ae67db39b31de58a8d..b961b6dbb6173b0a1abb9aeaef709f013460e730 100644 --- a/lib_dec/ivas_post_proc.c +++ b/lib_dec/ivas_post_proc.c @@ -296,7 +296,11 @@ 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 ); diff --git a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c index 216888fbe0a87dbe439801dfacb57441400b2bad..5867a44b329a51b5356927c330fc8339ca9886a8 100644 --- a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c @@ -1241,6 +1241,13 @@ 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]; hStereoDft = hCPE->hStereoDft; diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index fdace42d822ae5e85b084285873d70df63bad336..0bdc62756cab45407c59c830e401153464d0557f 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -1160,6 +1160,10 @@ 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++ ) @@ -1174,9 +1178,13 @@ 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 @@ -1193,7 +1201,12 @@ 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(); } } @@ -1353,10 +1366,17 @@ 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 + 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 */ @@ -1687,8 +1707,9 @@ void ivas_spar_dec_upmixer_sf_fx( SPAR_DEC_HANDLE hSpar; Word16 num_md_sub_frames; Word16 q1 = 30; + Word16 prod; move16(); - push_wmops( "ivas_spar_dec_upmixer_sf" ); + push_wmops( "ivas_spar_dec_upmixer_sf_fx" ); hSpar = st_ivas->hSpar; hDecoderConfig = st_ivas->hDecoderConfig; nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; /*Q0*/ @@ -1706,6 +1727,8 @@ void ivas_spar_dec_upmixer_sf_fx( slot_idx_start = hSpar->slots_rendered; /*Q0*/ move16(); + prod = i_mult( slot_idx_start, slot_size ); + test(); IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) { @@ -1716,7 +1739,7 @@ void ivas_spar_dec_upmixer_sf_fx( FOR( i = 0; i < nchan_internal; i++ ) { - p_tc_fx[i] = st_ivas->hTcBuffer->tc_fx[( i + nchan_ism )] + i_mult( slot_idx_start, slot_size ); /*Q11*/ + p_tc_fx[i] = st_ivas->hTcBuffer->tc_fx[( i + nchan_ism )] + prod; /*Q11*/ } test(); @@ -1725,7 +1748,7 @@ void ivas_spar_dec_upmixer_sf_fx( { FOR( i = 0; i < nchan_ism; i++ ) { - p_tc_fx[( i + nchan_internal )] = st_ivas->hTcBuffer->tc_fx[i] + i_mult( slot_idx_start, slot_size ); /*Q11*/ + p_tc_fx[( i + nchan_internal )] = st_ivas->hTcBuffer->tc_fx[i] + prod; /*Q11*/ } } } @@ -1733,7 +1756,7 @@ void ivas_spar_dec_upmixer_sf_fx( { FOR( i = 0; i < nchan_internal; i++ ) { - p_tc_fx[i] = st_ivas->hTcBuffer->tc_fx[i] + i_mult( slot_idx_start, slot_size ); /*Q11*/ + p_tc_fx[i] = st_ivas->hTcBuffer->tc_fx[i] + prod; /*Q11*/ } } @@ -1843,6 +1866,9 @@ 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*/ @@ -1870,7 +1896,7 @@ 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]; @@ -1897,14 +1923,14 @@ void ivas_spar_dec_upmixer_sf_fx( } ELSE { - cldfb_par_fx = 0; - move32(); + 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 */ - Word16 tmp = extract_l( L_shr( bin2band->pp_cldfb_weights_per_spar_band_fx[cldfb_band][spar_band], 7 ) ); /*Q15*/ - cldfb_par_fx = L_add_sat( cldfb_par_fx, Mpy_32_16_1( mixer_mat_fx[out_ch][in_ch][spar_band], tmp ) ); /*q1*/ + 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*/ @@ -1918,13 +1944,116 @@ 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 + } + } +#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]; + 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; + + /* First loop from cldfb_band=0 till min_cldf_band (CLDFB_PAR_WEIGHT_START_BAND) */ + FOR( cldfb_band = 0; cldfb_band < min_cldf_band; cldfb_band++ ) + { + spar_band = bin2band->p_cldfb_map_to_spar_band[cldfb_band]; /*Q0*/ + move16(); + 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 ) + { + cldfb_par_fx = mixer_mat_fx[out_ch][in_ch][spar_band]; /*q1*/ + move32(); + 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 } } + + /* Second loop from min_cldf_band (CLDFB_PAR_WEIGHT_START_BAND) till num_cldfb_bands */ + FOR( ; cldfb_band < num_cldfb_bands; cldfb_band++ ) + { + FOR( out_ch = 0; out_ch < numch_out; out_ch++ ) + { + Word32 Out_re_fx = L_add( 0, 0 ); + Word32 Out_im_fx = L_add( 0, 0 ); + FOR( in_ch = 0; in_ch < numch_in; in_ch++ ) + { + IF( b_skip_mat[out_ch][in_ch] == 0 ) + { + Word64 acc = 0; + move64(); + + cldfb_par_fx = 0; + move32(); + 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 = Madd_32_32( Out_re_fx, cldfb_in_ts_re_fx[in_ch][ts][cldfb_band], cldfb_par_fx ); /*q1-25*/ + Out_im_fx = Madd_32_32( Out_im_fx, cldfb_in_ts_im_fx[in_ch][ts][cldfb_band], cldfb_par_fx ); /*q1-25*/ + } + } + out_re_fx[out_ch] = Out_re_fx; + out_im_fx[out_ch] = Out_im_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*/ ) ) ) ) { diff --git a/lib_dec/ivas_stereo_cng_dec.c b/lib_dec/ivas_stereo_cng_dec.c index f8d6f6086edf0308a7d11134905dfccbc6700c5b..2ad6085cacc8d56c3d07595aecc3c4c6605599f4 100644 --- a/lib_dec/ivas_stereo_cng_dec.c +++ b/lib_dec/ivas_stereo_cng_dec.c @@ -357,7 +357,7 @@ static void stereo_dft_generate_comfort_noise_fx( { /* Transform shb LP spectrum */ set32_fx( shb_shape, 0, L_FRAME16k ); - Copy_Scale_sig_16_32( st->hTdCngDec->shb_lpcCNG_fx, shb_shape, LPC_SHB_ORDER + 1, Q15 ); // Q30 + Copy_Scale_sig_16_32_DEPREC( st->hTdCngDec->shb_lpcCNG_fx, shb_shape, LPC_SHB_ORDER + 1, Q15 ); // Q30 IF( NE_16( st->L_frame, L_FRAME16k ) ) { @@ -683,7 +683,12 @@ 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_fx.c b/lib_dec/ivas_stereo_dft_dec_fx.c index 3ee0f8e8c7a041648d0ade0266b758032e78a0d1..961120073d25142d61818737ae2b52c5d4e939b5 100644 --- a/lib_dec/ivas_stereo_dft_dec_fx.c +++ b/lib_dec/ivas_stereo_dft_dec_fx.c @@ -124,13 +124,25 @@ 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 ); @@ -249,6 +261,19 @@ void stereo_dft_dec_reset_fx( hStereoDft->ipd_xfade_prev_fx = 0; move32(); +#ifdef MSAN_FIX + FOR( b = 0; b < 2 * IVAS_MAX_NUM_BANDS; b++ ) + { + FOR( i = 0; i < 2; i++ ) + { + FOR( j = 0; j < 4; j++ ) + { + hStereoDft->mixer_mat_smooth_fx[i][j][b] = 0; + move32(); + } + } + } +#else FOR( b = 0; b < hStereoDft->nbands; b++ ) { FOR( i = 0; i < 2; i++ ) @@ -260,6 +285,7 @@ void stereo_dft_dec_reset_fx( } } } +#endif hStereoDft->first_frame = 1; move16(); hStereoDft->g_L_prev_fx = 0; @@ -1388,7 +1414,7 @@ void stereo_dft_dec_res_fx( /* bass post-filter */ bass_psfilter_fx( hCPE->hStereoDft->hBpf, hCPE->hCoreCoder[0]->Opt_AMR_WB, out_16, L_FRAME8k, hCPE->hCoreCoder[0]->old_pitch_buf_16_fx + ( L_FRAME8k / STEREO_DFT_L_SUBFR_8k ), hCPE->hCoreCoder[0]->bpf_off, hCPE->hCoreCoder[0]->stab_fac_fx, &hCPE->hStereoDft->stab_fac_smooth_res_fx, hCPE->hCoreCoder[0]->last_coder_type, 0, bpf_error_signal_8k_16 ); - Copy_Scale_sig_16_32( bpf_error_signal_8k_16, bpf_error_signal_8k, L_FRAME8k, Q15 ); /* Q15 */ + Copy_Scale_sig_16_32_DEPREC( bpf_error_signal_8k_16, bpf_error_signal_8k, L_FRAME8k, Q15 ); /* Q15 */ res_bpf_flag = res_bpf_adapt_ivas_fx( hCPE->hStereoDft, bpf_error_signal_8k, res_buf, q_res ); IF( prev_bfi ) @@ -1404,7 +1430,11 @@ void stereo_dft_dec_res_fx( move32(); } } - Copy_Scale_sig_16_32( out_16, output, L_FRAME8k, 16 ); /* Q16 */ +#ifdef FIX_ISSUE_1237 + Copy_Scale_sig_16_32_no_sat( out_16, output, L_FRAME8k, 15 ); /* 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 ); @@ -1415,12 +1445,20 @@ 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(); - Copy_Scale_sig_16_32( out_16, output, L_FRAME8k, 16 ); /* Q16 */ +#ifdef FIX_ISSUE_1237 + Copy_Scale_sig_16_32_no_sat( out_16, output, L_FRAME8k, 15 ); /* 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*/ - Copy_Scale_sig_16_32( out_16, output, L_FRAME8k, 16 ); /* Q16 */ +#ifdef FIX_ISSUE_1237 + Copy_Scale_sig_16_32_no_sat( out_16, output, L_FRAME8k, 15 ); /* Q15 */ +#else + Copy_Scale_sig_16_32_DEPREC( out_16, output, L_FRAME8k, 16 ); /* Q16 */ +#endif } return; diff --git a/lib_dec/ivas_stereo_mdct_core_dec_fx.c b/lib_dec/ivas_stereo_mdct_core_dec_fx.c index 79b88b88c159b8abd89d124905291c75ed722512..3014dba06971afa80909ec046bd93187939fbfc9 100644 --- a/lib_dec/ivas_stereo_mdct_core_dec_fx.c +++ b/lib_dec/ivas_stereo_mdct_core_dec_fx.c @@ -403,7 +403,7 @@ void stereo_mdct_core_dec_fx( FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) { - Copy_Scale_sig_16_32( Aq_fx[ch], Aq_fx_32[ch], ( NB_SUBFR16k + 1 ) * ( M + 1 ), sub( Q16, Q12 ) ); /* Q16 */ + Copy_Scale_sig_16_32_DEPREC( Aq_fx[ch], Aq_fx_32[ch], ( NB_SUBFR16k + 1 ) * ( M + 1 ), sub( Q16, Q12 ) ); /* Q16 */ } /*--------------------------------------------------------------------------------* @@ -542,10 +542,13 @@ void stereo_mdct_core_dec_fx( move16(); } } - - Copy_Scale_sig_16_32( 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( 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 */ - +#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 */ @@ -987,7 +990,7 @@ static void run_min_stats_fx( { Word16 ch, will_estimate_noise_on_channel[CPE_CHANNELS], save_VAD[CPE_CHANNELS]; Word32 power_spec[L_FRAME16k]; - Word16 power_spec_e = 0; + Word16 power_spec_q = 0; move16(); Word32 *spec_in; Word16 spec_e; @@ -1043,25 +1046,27 @@ static void run_min_stats_fx( IF( ( EQ_16( will_estimate_noise_on_channel[0], will_estimate_noise_on_channel[1] ) ) || EQ_16( ch, 0 ) ) { Word16 tmp16 = getScaleFactor32( spec_in, L_FRAME16k ); - + Word64 spec_power; Word32 power_spec_scale_fac; /* calculate power spectrum from MDCT coefficients and estimated MDST coeffs */ power_spec_scale_fac = 20792; // 1.f / ( L_FRAME16k * L_FRAME16k ) in Q31 move32(); - power_spec[0] = Mpy_32_32( W_extract_h( W_shl( W_mult_32_32( spec_in[0], spec_in[0] ), sub( tmp16, 4 ) ) ), power_spec_scale_fac ); /* 2 * (Q31 - x_e) + tmp16 - Q4 - Q31 */ + spec_power = W_shl( W_mult_32_32( spec_in[0], spec_in[0] ), shl( tmp16, 1 ) ); + power_spec[0] = W_extract_l( W_shr( W_mult_32_32( W_extract_h( spec_power ), power_spec_scale_fac ), 16 ) ); /* 2 * (Q31 - x_e + tmp16) + 1 - Q16 */ move32(); - power_spec[L_FRAME16k - 1] = Mpy_32_32( W_extract_h( W_shl( W_mult_32_32( spec_in[L_FRAME16k - 1], spec_in[L_FRAME16k - 1] ), sub( tmp16, 4 ) ) ), power_spec_scale_fac ); /* 2 * (Q31 - x_e) + tmp16 - Q4 - Q31 */ + spec_power = W_shl( W_mult_32_32( spec_in[L_FRAME16k - 1], spec_in[L_FRAME16k - 1] ), shl( tmp16, 1 ) ); + power_spec[L_FRAME16k - 1] = W_extract_l( W_shr( W_mult_32_32( W_extract_h( spec_power ), power_spec_scale_fac ), 16 ) ); /* 2 * (Q31 - x_e + tmp16) + 1 - Q16 */ move32(); FOR( Word16 i = 1; i < L_FRAME16k - 1; i++ ) { Word32 mdst; mdst = L_sub( spec_in[i + 1], spec_in[i - 1] ); /* Q31 - x_e */ - - power_spec[i] = Mpy_32_32( L_add( W_extract_h( W_shl( W_mult_32_32( spec_in[i], spec_in[i] ), sub( tmp16, 4 ) ) ), W_extract_h( W_shl( W_mult_32_32( mdst, mdst ), sub( tmp16, 4 ) ) ) ), power_spec_scale_fac ); /* 2 * (Q31 - x_e) + tmp16 - Q4 - Q31*/ + spec_power = W_shl( W_add( W_mult_32_32( spec_in[i], spec_in[i] ), W_mult_32_32( mdst, mdst ) ), shl( tmp16, 1 ) ); + power_spec[i] = W_extract_l( W_shr( W_mult_32_32( W_extract_h( spec_power ), power_spec_scale_fac ), 16 ) ); /* 2 * (Q31 - x_e + tmp16) + 1 - Q16 */ move32(); } - power_spec_e = sub( add( 4, shl( spec_e, 1 ) ), tmp16 ); + power_spec_q = add( shl( add( sub( 31, spec_e ), tmp16 ), 1 ), 1 - 16 ); } } @@ -1091,7 +1096,7 @@ static void run_min_stats_fx( { arr_tmp = power_spec; } - ApplyFdCng_ivas_fx( NULL, 0, arr_tmp, sub( 31, power_spec_e ), NULL, NULL, NULL, st, st->bfi, 0 ); + ApplyFdCng_ivas_fx( NULL, 0, arr_tmp, power_spec_q, NULL, NULL, NULL, st, st->bfi, 0 ); /*=================================================*/ } diff --git a/lib_dec/ivas_stereo_mdct_stereo_dec.c b/lib_dec/ivas_stereo_mdct_stereo_dec.c index 44dcda09b00bfe421e5ea67b352ccd6dec1363d3..829173da02bd00970748f7329a57c2a3c567b6ab 100644 --- a/lib_dec/ivas_stereo_mdct_stereo_dec.c +++ b/lib_dec/ivas_stereo_mdct_stereo_dec.c @@ -906,9 +906,13 @@ void updateBuffersForDmxMdctStereo_fx( move16(); sts[0]->hTcxLtpDec->exp_tcxltp_mem_out = add( sts[0]->hTcxLtpDec->exp_tcxltp_mem_out, 1 ); move16(); - - Copy_Scale_sig_16_32( &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( &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 +#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.c b/lib_dec/ivas_stereo_switching_dec.c index 5d5b38d4dfdc1cb85b342be846f66093d087bf84..ad6d58ebf5b981554a089a2a5023544c0dfda4bb 100644 --- a/lib_dec/ivas_stereo_switching_dec.c +++ b/lib_dec/ivas_stereo_switching_dec.c @@ -503,7 +503,7 @@ ivas_error stereo_memory_dec_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX/TD CNG\n" ) ); } - td_cng_dec_init_fx( st ); + td_cng_dec_init_ivas_fx( st ); } } diff --git a/lib_dec/ivas_svd_dec.c b/lib_dec/ivas_svd_dec.c index 3b8a90a4c87bd969a3359b24a3ee577266a1b55e..77cf192c27a8fe3711b310e79523641be58fe99f 100644 --- a/lib_dec/ivas_svd_dec.c +++ b/lib_dec/ivas_svd_dec.c @@ -50,6 +50,7 @@ #define SVD_MINIMUM_VALUE_FX ( 2 ) /* minimum value */ #define SVD_ZERO_FLUSH_THRESHOLD_FX ( 0 ) #define CONVERGENCE_FACTOR_FX 214748 /* factor for SVD convergence (as per latest float code: 1.0e-04f) */ + /*-----------------------------------------------------------------------* * Local function prototypes *-----------------------------------------------------------------------*/ @@ -71,7 +72,11 @@ 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 */ @@ -85,7 +90,11 @@ 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 */ @@ -98,7 +107,11 @@ 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 */ @@ -108,8 +121,16 @@ 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 */ ); @@ -149,6 +170,18 @@ 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, + const Word32 z, /* exp(z_e) */ + const Word16 z_e, + Word32 *result, + Word32 *resultInv, + Word16 *out_e, + Word16 *outInv_e ); +#endif + static Word32 GivensRotation_fx( const Word32 x, /* exp(x_e) */ const Word16 x_e, @@ -276,7 +309,11 @@ Word16 svd_fx( Word16 errorMessage, condition; // int16_t max_length = ((nChannelsL > nChannelsC) ? nChannelsL : nChannelsC); 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(); @@ -285,7 +322,11 @@ Word16 svd_fx( Word16 temp_fx_e; 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++ ) @@ -297,19 +338,23 @@ Word16 svd_fx( } } - set16_fx( singularValues_fx_e, 0, MAX_OUTPUT_CHANNELS ); - /* 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 */ @@ -381,11 +426,15 @@ 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) */ - Word16 *secDiag_fx_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 : */ +#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 kCh, nCh, iCh, jCh, split; @@ -395,6 +444,9 @@ 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; @@ -402,9 +454,15 @@ static Word16 BidagonalDiagonalisation_fx( Word16 convergence, iteration, found_split; Word16 error = 0; move16(); - Word16 singularValues_new_e[MAX_OUTPUT_CHANNELS], secDiag_new_e[MAX_OUTPUT_CHANNELS]; - Copy( singularValues_fx_e, singularValues_new_e, MAX_OUTPUT_CHANNELS ); +#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 */ { @@ -472,24 +530,46 @@ static Word16 BidagonalDiagonalisation_fx( c = singularValues_fx[kCh]; /* exp(singularValues_new_e) */ c_e = singularValues_new_e[kCh]; - 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)) */ +#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 */ } } @@ -540,6 +620,7 @@ 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++ ) @@ -556,6 +637,7 @@ static Word16 BidagonalDiagonalisation_fx( 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 ); } @@ -579,6 +661,13 @@ 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(); @@ -681,25 +770,47 @@ 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) */ @@ -713,30 +824,48 @@ 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(); - IF( GT_32( L_abs( singularValues[ch] ), Mpy_32_32( CONVERGENCE_FACTOR_FX, L_abs( singularValues[ch] ) ) ) ) +#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); @@ -783,13 +912,56 @@ static void ApplyRotation_fx( ) { Word16 ch; - Word16 temp_exp; *d = BASOP_Util_Add_Mant32Exp( Mpy_32_32( c, x11 ), add( c_e, x11_e ), Mpy_32_32( s, x12 ), add( s_e, x12_e ), d_e ); /* exp(d_e) */ move32(); *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; + Word16 op_e; + + // Bring c and s to same Q + IF( GT_16( c_q, s_q ) ) + { + op1 = L_shr( c, sub( c_q, s_q ) ); + op2 = s; + move32(); + op_e = s_q; + move16(); + } + ELSE + { + op1 = c; + move32(); + op2 = L_shr( s, sub( s_q, c_q ) ); + op_e = c_q; + move16(); + } + op_e = add( op_e, 1 ); // 64 bit mac -> +1 + + FOR( ch = 0; ch < nChannels; ch++ ) + { + x11 = singularVector[ch][currentIndex2]; + move32(); + x12 = singularVector[ch][currentIndex1]; + move32(); + + Word64 temp = W_mac_32_32( W_mult_32_32( op1, x11 ), op2, x12 ); // Q(singularVector) + op_e + temp = W_shr( temp, op_e ); // Q(singularVector) + singularVector[ch][currentIndex2] = W_sat_l( temp ); // Q(singularVector) + move32(); + + temp = W_mac_32_32( W_mult_32_32( op1, x12 ), L_negate( op2 ), x11 ); // Q(singularVector) + op_e + temp = W_shr( temp, op_e ); // Q(singularVector) + 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]; @@ -805,6 +977,25 @@ static void ApplyRotation_fx( 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; } @@ -836,14 +1027,36 @@ 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++ ) + { + FOR( iCh = 0; iCh < nChannelsC; iCh++ ) + { + singularVectors_Left_fx_e[jCh][iCh] = singularVectors_Left_e; + 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) */ @@ -854,9 +1067,19 @@ 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; } @@ -871,7 +1094,11 @@ 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 */ @@ -885,17 +1112,20 @@ static void biDiagonalReductionLeft_fx( Word16 iCh, jCh, idx; Word32 norm_x, f, r; Word16 norm_x_e, f_e, r_e; - Word16 sing_exp[MAX_OUTPUT_CHANNELS]; - Word16 sing_exp2[MAX_OUTPUT_CHANNELS][MAX_OUTPUT_CHANNELS] = { 0 }; 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 ) ) { @@ -913,6 +1143,10 @@ 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; @@ -927,22 +1161,54 @@ IF( LT_16( currChannel, nChannelsL ) ) /* i <= m */ 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 } IF( ( *sig_x ) ) /*(fabsf(*sig_x) > EPSILON * fabsf(*sig_x)) { */ { +#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; 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) */ + move32(); + singularVectors2_e[jCh][currChannel] = add( L_temp_e, sub( singularVectors2_e[jCh][currChannel], *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( singularVectors2_e[jCh][currChannel], 1 ), &norm_x_e ); /* exp(norm_x_e) */ +#endif +#else + 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 ) ) { @@ -955,7 +1221,8 @@ IF( LT_16( currChannel, nChannelsL ) ) /* i <= m */ 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 ) ); + //( *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 ); @@ -966,11 +1233,28 @@ IF( LT_16( currChannel, nChannelsL ) ) /* i <= m */ ( *g ) = L_negate( L_negate( L_temp ) ); move32(); } +#else + 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; @@ -979,15 +1263,28 @@ IF( LT_16( currChannel, nChannelsL ) ) /* i <= m */ move16(); FOR( jCh = idx; jCh < nChannelsL; jCh++ ) /* nChannelsL */ { +#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 = 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_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 + 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(); } } @@ -997,10 +1294,15 @@ IF( LT_16( currChannel, nChannelsL ) ) /* i <= m */ { 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(); @@ -1022,6 +1324,7 @@ IF( LT_16( currChannel, nChannelsL ) ) /* i <= m */ } *singularVectors_e = exp_max; move16(); +#endif } // rescaling block @@ -1042,9 +1345,17 @@ return; static void biDiagonalReductionRight_fx( Word32 singularVectors[][MAX_OUTPUT_CHANNELS], /* exp(singularVectors_e) */ - Word32 secDiag[MAX_OUTPUT_CHANNELS], /* exp(secDiag_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 */ @@ -1056,16 +1367,22 @@ static void biDiagonalReductionRight_fx( Word16 iCh, jCh, idx; Word32 norm_x, r; Word16 norm_x_e, r_e; - Word16 sing_exp[MAX_OUTPUT_CHANNELS]; +#ifndef FIX_1010_OPT_SEC_SINGLE_RESCALE Word16 secDiag_exp[MAX_OUTPUT_CHANNELS]; - Word16 sing_exp2[MAX_OUTPUT_CHANNELS][MAX_OUTPUT_CHANNELS] = { 0 }; +#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; @@ -1079,7 +1396,11 @@ 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)) { */ @@ -1089,13 +1410,41 @@ 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 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 ) ) { @@ -1119,16 +1468,44 @@ 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 + 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 */ @@ -1139,12 +1516,20 @@ 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 move32(); } } @@ -1153,10 +1538,15 @@ 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(); @@ -1169,8 +1559,12 @@ static void biDiagonalReductionRight_fx( 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++ ) @@ -1191,6 +1585,7 @@ static void biDiagonalReductionRight_fx( } *singularVectors_e = exp_max; move16(); +#endif } } @@ -1204,9 +1599,13 @@ static void biDiagonalReductionRight_fx( *-------------------------------------------------------------------------*/ static void singularVectorsAccumulationLeft_fx( - Word32 singularVectors_Left[][MAX_OUTPUT_CHANNELS], /* exp(singularVectors_e) as Input, Q31 as output */ + 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 */ @@ -1216,11 +1615,13 @@ 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*/ @@ -1240,25 +1641,58 @@ 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_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 ); + 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 */ { - norm_y = 0; - move32(); - norm_y_e = 0; + Word64 acc = 0; + move64(); + Word64 prod[16]; + Word16 prod_e[16]; + Word16 max_e = -31; 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 } - t_jj = BASOP_Util_Divide3232_Scale_cadence( Mpy_32_32( t_ii, norm_y ), maxWithSign_fx( singularVectors_Left[nCh][nCh] ), &temp_exp ); // t_ii_e+norm_y_e-*singularVectors_e, - t_jj_e = add( temp_exp, sub( add( t_ii_e, norm_y_e ), sing_exp2[nCh][nCh] ) ); + FOR( k = nCh + 1; k < nChannelsL; k++ ) /* nChannelsL */ + { + acc = W_add( acc, W_shr( prod[k], sub( max_e, prod_e[k] ) ) ); + } + Word16 acc_e = W_norm( acc ); + acc = W_shl( acc, acc_e ); + + 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(); } } @@ -1267,7 +1701,11 @@ 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(); } } @@ -1279,8 +1717,11 @@ 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); @@ -1288,7 +1729,11 @@ 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 move32(); } } @@ -1303,11 +1748,19 @@ static void singularVectorsAccumulationLeft_fx( *-------------------------------------------------------------------------*/ static void singularVectorsAccumulationRight_fx( - Word32 singularVectors_Left[][MAX_OUTPUT_CHANNELS], /* exp(singularVectors_e) */ - Word32 singularVectors_Right[][MAX_OUTPUT_CHANNELS], /* exp(singularVectors_e) */ + 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 */ ) { @@ -1320,7 +1773,7 @@ static void singularVectorsAccumulationRight_fx( nChannels = nChannelsC; /* nChannelsC Q0*/ /* avoid compiler warning */ - t_ii = secDiag[nChannels - 1]; /* exp(secDiag_e) */ + t_ii = secDiag[nChannels - 1]; /* exp(secDiag_e[nChannels - 1]) */ move32(); FOR( nCh = nChannels - 1; nCh >= 0; nCh-- ) /* nChannelsC, min(nChannelsLmnChannelsC) otherwise */ @@ -1333,10 +1786,22 @@ 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 ); } @@ -1350,7 +1815,11 @@ 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 */ @@ -1374,7 +1843,7 @@ static void singularVectorsAccumulationRight_fx( } singularVectors_Right[nCh][nCh] = MAX_32; move32(); - t_ii = secDiag[nCh]; /* exp(secDiag_e) */ + t_ii = secDiag[nCh]; /* exp(secDiag_e[nCh]) */ move32(); } return; @@ -1386,6 +1855,31 @@ static void singularVectorsAccumulationRight_fx( * *-------------------------------------------------------------------------*/ + +#ifdef FIX_1010_OPT_GIVENS_INV +static void GivensRotation2_fx( + const Word32 x, /* exp(x_e) */ + const Word16 x_e, + const Word32 z, /* exp(z_e) */ + const Word16 z_e, + Word32 *result, + Word32 *resultInv, + Word16 *out_e, + Word16 *outInv_e ) +{ + Word32 r; + 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 = L_max( r, 1 ); + *outInv_e = *out_e; + move16(); + *result = Sqrt32( r, out_e ); + move32(); + + *resultInv = ISqrt32( r, outInv_e ); + move32(); +} +#endif + static Word32 GivensRotation_fx( const Word32 x, /* exp(x_e) */ const Word16 x_e, @@ -1393,10 +1887,19 @@ 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(); @@ -1439,7 +1942,7 @@ static Word32 GivensRotation_fx( *out_e = add( z_e, temp_exp ); } } - +#endif return ( r ); } @@ -1453,6 +1956,7 @@ 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; @@ -1465,6 +1969,18 @@ static Word32 maxWithSign_fx( { return SVD_MINIMUM_VALUE_FX; } +#else + Word32 result; + IF( a >= 0 ) + { + result = L_max( a, SVD_MINIMUM_VALUE_FX ); + } + ELSE + { + result = L_min( a, -SVD_MINIMUM_VALUE_FX ); + } + return result; +#endif } /*------------------------------------------------------------------------- diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index b63668b3874d3c812333b36f1af70fcba5691a06..7e2e69ec4afd209012db6f12fcd7a429fe03f929 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -44,6 +44,11 @@ #include "jbm_jb4sb.h" #include "jbm_pcmdsp_apa.h" #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*/ @@ -3058,7 +3063,7 @@ const char *IVAS_DEC_GetErrorMessage( return ivas_error_to_string( error ); } - +#ifndef FIX_DISCLAIMER /*---------------------------------------------------------------------* * get_channel_config() * @@ -3136,7 +3141,7 @@ static ivas_error get_channel_config( return IVAS_ERR_OK; } - +#endif /*---------------------------------------------------------------------* * printConfigInfo_dec( ) diff --git a/lib_dec/nelp_dec_fx.c b/lib_dec/nelp_dec_fx.c index 9eb7ab2031758be2a889c082213e64889fde0498..c088dd82663b8faa30514363b931ccd27ba39001 100644 --- a/lib_dec/nelp_dec_fx.c +++ b/lib_dec/nelp_dec_fx.c @@ -336,11 +336,7 @@ void nelp_decoder_fx( E3 = L_deposit_l( 1 ); FOR( i = 0; i < L_FRAME; i++ ) { -#ifdef BASOP_NOGLOB E3 = L_mac0_sat( E3, ptr[i], ptr[i] ); /*2*Q_exc */ -#else - E3 = L_mac0( E3, ptr[i], ptr[i] ); /*2*Q_exc */ -#endif } @@ -391,11 +387,7 @@ void nelp_decoder_fx( E2 = L_deposit_l( 1 ); FOR( i = 0; i < L_FRAME; i++ ) { -#ifdef BASOP_NOGLOB E2 = L_mac0_sat( E2, ptr[i], ptr[i] ); /*2*Q_exc */ -#else - E2 = L_mac0( E2, ptr[i], ptr[i] ); /*2*Q_exc */ -#endif } exp_E3 = norm_l( E3 ); @@ -403,11 +395,7 @@ void nelp_decoder_fx( exp_E3 = sub( 30, add( exp_E3, 2 * ( *Q_exc ) ) ); exp_E2 = norm_l( E2 ); -#ifdef BASOP_NOGLOB frac_E2 = round_fx_sat( L_shl_sat( E2, exp_E2 ) ); -#else - frac_E2 = round_fx( L_shl( E2, exp_E2 ) ); -#endif exp_E2 = sub( 30, add( exp_E2, shl( ( *Q_exc ), 1 ) ) ); scale = shr( sub( frac_E3, frac_E2 ), 15 ); diff --git a/lib_dec/pitch_extr_fx.c b/lib_dec/pitch_extr_fx.c index 6f5bcc535237e6140c40ed310ecf9c52870c3de2..73e9623f5da99fc082caae28ff4ce9c12a27bd20 100644 --- a/lib_dec/pitch_extr_fx.c +++ b/lib_dec/pitch_extr_fx.c @@ -157,9 +157,7 @@ void pitch_pred_linear_fit( { Word32 t1, t2, t3, t4, t5, t6, t7; Word16 e1, e2, e3, e4, e5, e6, e7; -#ifdef BASOP_NOGLOB Flag Overflow; -#endif t1 = L_mult0( pg[4], pg[3] ); /*Q24*/ /* t1 = pg[4]*pg[3] */ e1 = 7; move16(); @@ -182,12 +180,8 @@ void pitch_pred_linear_fit( t6 = BASOP_Util_Add_Mant32Exp( t3, e3, t4, e4, &e6 ); t7 = BASOP_Util_Add_Mant32Exp( t5, e5, t6, e6, &e7 ); /*Q31,e7*/ sum0_q = norm_l( t7 ); -#ifdef BASOP_NOGLOB sum0 = round_fx_o( L_shl( t7, sum0_q ), &Overflow ); /*Q15,e7-sum0_q*/ -#else - sum0 = round_fx( L_shl( t7, sum0_q ) ); /*Q15,e7-sum0_q*/ -#endif - sum0_q = add( 15, sub( sum0_q, e7 ) ); /* sum0 is now Qsum0_q*/ + sum0_q = add( 15, sub( sum0_q, e7 ) ); /* sum0 is now Qsum0_q*/ } pit = 0; diff --git a/lib_dec/post_dec_fx.c b/lib_dec/post_dec_fx.c index 8d3e03321b4d3b9082ba36fcb9cb2c138bcbb17a..d581f810a7dd724424e19f9651b0a5c4a11e930c 100644 --- a/lib_dec/post_dec_fx.c +++ b/lib_dec/post_dec_fx.c @@ -439,11 +439,7 @@ static void bass_pf_1sf_delay( /* gain = tmp/nrg; */ gain = BASOP_Util_Divide3232_Scale( tmp, nrg, &tmp16 ); BASOP_SATURATE_WARNING_OFF_EVS; -#ifdef BASOP_NOGLOB gain = shl_sat( gain, tmp16 ); /* Q15 */ -#else - gain = shl( gain, tmp16 ); /* Q15 */ -#endif BASOP_SATURATE_WARNING_ON_EVS; if ( gain < 0 ) @@ -471,20 +467,10 @@ static void bass_pf_1sf_delay( { tmp32 = L_msu0( 0, gain, syn[( i + i_subfr ) - T] ); tmp32 = L_msu0( tmp32, gain, syn[( i + i_subfr ) + T] ); -#ifdef BASOP_NOGLOB tmp16 = mac_r_sat( tmp32, gain, syn[i + i_subfr] ); /* Q0 */ -#else - tmp16 = mac_r( tmp32, gain, syn[i + i_subfr] ); /* Q0 */ -#endif lp_error = Mpy_32_16_1( lp_error, 29491 /*0.9f Q15*/ ); -#ifdef BASOP_NOGLOB lp_error = L_mac_sat( lp_error, tmp16, 0x1000 ); /* Q13 */ tmp16 = round_fx_sat( L_shl_sat( lp_error, s1 ) ); /* Q0+s1-3 */ -#else - lp_error = L_mac( lp_error, tmp16, 0x1000 ); /* Q13 */ - - tmp16 = round_fx( L_shl( lp_error, s1 ) ); /* Q0+s1-3 */ -#endif ener2_64 = W_mac0_16_16( ener2_64, tmp16, tmp16 ); /* Q0+(s1-3)*2 */ } ener2 = W_sat_l( ener2_64 ); @@ -498,7 +484,6 @@ static void bass_pf_1sf_delay( Word64 ener2_64 = W_deposit32_l( ener2 ); FOR( i = lg; i < l_subfr; i++ ) { -#ifdef BASOP_NOGLOB tmp32 = L_mult0( gain, syn[i + i_subfr] ); tmp32 = L_msu0_sat( tmp32, gain, syn[( i + i_subfr ) - T] ); /* Q0 */ tmp16 = round_fx_sat( tmp32 ); @@ -507,16 +492,6 @@ static void bass_pf_1sf_delay( lp_error = L_mac_sat( lp_error, tmp16, 0x1000 ); /* Q13 */ tmp16 = round_fx_sat( L_shl_sat( lp_error, s1 ) ); /* Q0+s1-3 */ -#else - tmp32 = L_mult0( gain, syn[i + i_subfr] ); - tmp32 = L_msu0( tmp32, gain, syn[i + i_subfr - T] ); /* Q0 */ - tmp16 = round_fx( tmp32 ); - - lp_error = Mpy_32_16_1( lp_error, 29491 /*0.9f Q15*/ ); - lp_error = L_mac( lp_error, tmp16, 0x1000 ); /* Q13 */ - - tmp16 = round_fx( L_shl( lp_error, s1 ) ); /* Q0+s1-3 */ -#endif ener2_64 = W_mac0_16_16( ener2_64, tmp16, tmp16 ); /* Q0+(s1-3)*2 */ } ener2 = W_sat_l( ener2_64 ); @@ -554,11 +529,7 @@ static void bass_pf_1sf_delay( tmp32 = L_deposit_l( 1 ); tmp16 = BASOP_Util_Divide3232_Scale( tmp, tmp32, &st ); BASOP_SATURATE_WARNING_OFF_EVS; -#ifdef BASOP_NOGLOB tmp16 = shl_sat( tmp16, sub( st, 2 ) ); /* Q15 */ -#else - tmp16 = shl( tmp16, sub( st, 2 ) ); /* Q15 */ -#endif if ( GT_16( tmp16, 16384 /*0.5f Q15*/ ) ) { @@ -584,16 +555,10 @@ static void bass_pf_1sf_delay( FOR( i = 0; i < lg; i++ ) { tmp32 = L_msu0( 0, tmp16, syn[( i + i_subfr ) - T] ); -#ifdef BASOP_NOGLOB tmp32 = L_msu0_sat( tmp32, tmp16, syn[( i + i_subfr ) + T] ); tmp32 = L_mac_sat( tmp32, tmp16, syn[i + i_subfr] ); bpf_noise_buf[i + i_subfr] = round_fx_sat( tmp32 ); /* Q0 */ move16(); -#else - tmp32 = L_msu0( tmp32, tmp16, syn[i + i_subfr + T] ); - tmp32 = L_mac( tmp32, tmp16, syn[i + i_subfr] ); - bpf_noise_buf[i + i_subfr] = round_fx( tmp32 ); /* Q0 */ -#endif } } @@ -602,14 +567,9 @@ static void bass_pf_1sf_delay( FOR( i = lg; i < l_subfr; i++ ) { tmp32 = L_mult0( tmp16, syn[i + i_subfr] ); -#ifdef BASOP_NOGLOB tmp32 = L_msu0_sat( tmp32, tmp16, syn[i + i_subfr - T] ); bpf_noise_buf[i + i_subfr] = round_fx_sat( tmp32 ); /* Q0 */ move16(); -#else - tmp32 = L_msu0( tmp32, tmp16, syn[i + i_subfr - T] ); - bpf_noise_buf[i + i_subfr] = round_fx( tmp32 ); /* Q0 */ -#endif } } } @@ -696,13 +656,8 @@ void cldfb_synth_set_bandsToZero( /* use 16-bit precision of real and imag buffers */ realQ1 = extract_l( L_shr( rAnalysis[k][i], sub( 31 + 3 - 15, scaleFactor.lb_scale ) ) ); /*31 - (15 + scaleFactor.lb_scale) + 3 )*/ imagQ1 = extract_l( L_shr( iAnalysis[k][i], sub( 31 + 3 - 15, scaleFactor.lb_scale ) ) ); /* Q(-3), headroom */ -#ifdef BASOP_NOGLOB nrgQ31 = L_mac0_o( nrgQ31, realQ1, realQ1, &Overflow ); nrgQ31 = L_mac0_o( nrgQ31, imagQ1, imagQ1, &Overflow ); /* keep in Q(-6) */ -#else - nrgQ31 = L_mac0( nrgQ31, realQ1, realQ1 ); - nrgQ31 = L_mac0( nrgQ31, imagQ1, imagQ1 ); /* keep in Q(-6) */ -#endif } nrg_band[i] = ( nrgQ31 ); move16(); diff --git a/lib_dec/ppp_dec_fx.c b/lib_dec/ppp_dec_fx.c index 201d2cce6442081c47869f8514409c71720eef4a..00a333798ef26d9645b5c3a480cbe7c0dc267443 100644 --- a/lib_dec/ppp_dec_fx.c +++ b/lib_dec/ppp_dec_fx.c @@ -113,14 +113,9 @@ static void DTFS_dequant_cw_fx( /* Power Dequantization */ - tmp_fx = shl( POWER_IDX_fx, 1 ); /* tmp=2*POWER_IDX */ -#ifdef BASOP_NOGLOB + tmp_fx = shl( POWER_IDX_fx, 1 ); /* tmp=2*POWER_IDX */ *lastLgainD_fx = add_sat( *lastLgainD_fx, PowerCB_fx[tmp_fx] ); /* Q11 */ *lastHgainD_fx = add_sat( *lastHgainD_fx, PowerCB_fx[tmp_fx + 1] ); /* Q11 */ -#else - *lastLgainD_fx = add( *lastLgainD_fx, PowerCB_fx[tmp_fx] ); /* Q11 */ - *lastHgainD_fx = add( *lastHgainD_fx, PowerCB_fx[tmp_fx + 1] ); /* Q11 */ -#endif move16(); move16(); L_tmp = L_deposit_h( X_fx->lag_fx ); /* Q16 */ @@ -143,11 +138,7 @@ static void DTFS_dequant_cw_fx( frac = L_Extract_lc( L_tmp, &exp1 ); /* Extract exponent */ L_tmp = Pow2( 14, frac ); exp1 = sub( exp1, 14 ); -#ifdef BASOP_NOGLOB L_temp = L_shl_sat( L_tmp, add( exp1, 15 ) ); /* Q15 */ -#else - L_temp = L_shl( L_tmp, add( exp1, 15 ) ); /* Q15 */ -#endif L_tmp2 = L_temp; if ( GE_32( L_temp, 2147483647 ) ) { @@ -173,11 +164,7 @@ static void DTFS_dequant_cw_fx( frac = L_Extract_lc( L_tmp, &exp1 ); /* Extract exponent */ L_tmp = Pow2( 14, frac ); exp1 = sub( exp1, 14 ); -#ifdef BASOP_NOGLOB L_temp = L_shl_sat( L_tmp, exp1 + 15 ); /* Q15 */ -#else - L_temp = L_shl( L_tmp, exp1 + 15 ); /* Q15 */ -#endif L_tmp2 = L_temp; move32(); if ( GE_32( L_temp, 2147483647 ) ) diff --git a/lib_dec/pvq_core_dec_fx.c b/lib_dec/pvq_core_dec_fx.c index 6d3e24dadf3721f07adf9324312813d940d2d8ca..93da9c77a8a0ec9dc80d47a98cd2b5910c1b67e4 100644 --- a/lib_dec/pvq_core_dec_fx.c +++ b/lib_dec/pvq_core_dec_fx.c @@ -492,11 +492,7 @@ static void densitySymbolIndexDecode_fx( sym_freq = L_deposit_l( 1 ); angle = atan2_fx( SQRT_DIM_fx[opp_sz], SQRT_DIM_fx[near_sz] ); // Q13 -#ifdef BASOP_NOGLOB angle = shl_o( angle, 1, &Overflow ); -#else - angle = shl( angle, 1 ); -#endif angle = mult_r( angle, 20861 ); c = mult_r( density, angle ); density_c = sub( density, c ); diff --git a/lib_dec/pvq_decode_fx.c b/lib_dec/pvq_decode_fx.c index 870ea25a900519019a0398f9fa36ef920748932f..649840f55ce2f942b1a2a5acfbfe16c21a456f4c 100644 --- a/lib_dec/pvq_decode_fx.c +++ b/lib_dec/pvq_decode_fx.c @@ -103,14 +103,9 @@ void pvq_decode_fx( Mpy_32_16_ss( L_isqrt, shl( y[i], shift_num ), &L_tmp, &u16_tmp ); /* Q31*Q(0+x) *2*/ Mpy_32_16_ss( L_tmp, neg_gain_norm, &L_tmp, &u16_tmp ); /* Q31*Q(0+x) *Q15 *2*/ -#ifdef BASOP_NOGLOB L_tmp = L_shr_o( L_tmp, shift_tot, &Overflow ); xq[i] = round_fx_o( L_tmp, &Overflow ); /* Q15 , array move */ move16(); -#else - L_tmp = L_shr( L_tmp, shift_tot ); - xq[i] = round_fx( L_tmp ); /* Q15 , array move */ -#endif } } diff --git a/lib_dec/rst_dec_fx.c b/lib_dec/rst_dec_fx.c index 339d828544de63bd55a07f2e493322c3469b012d..c226d8b9a68830300eec9c433d781875fde11569 100644 --- a/lib_dec/rst_dec_fx.c +++ b/lib_dec/rst_dec_fx.c @@ -61,11 +61,7 @@ void CNG_reset_dec_fx( L_tmp = L_deposit_h( tmp ); L_tmp = Isqrt_lc( L_tmp, &exp ); -#ifdef BASOP_NOGLOB st_fx->lp_gainc_fx = round_fx_sat( L_shl_sat( L_tmp, sub( exp, 12 ) ) ); /* In Q3 */ -#else - st_fx->lp_gainc_fx = round_fx( L_shl( L_tmp, sub( exp, 12 ) ) ); /* In Q3 */ -#endif move16(); } /* reset the pitch buffer in case of FRAME_NO_DATA or SID frames */ diff --git a/lib_dec/swb_bwe_dec_fx.c b/lib_dec/swb_bwe_dec_fx.c index cd30df7c3fdb908afabc134c83b9814da2cfaabf..7a6abb79001d34faf376c75c56a7b40d5af65d1a 100644 --- a/lib_dec/swb_bwe_dec_fx.c +++ b/lib_dec/swb_bwe_dec_fx.c @@ -582,11 +582,7 @@ Word16 wb_bwe_dec_fx( { /* de-quantization */ mode = WB_BWE_gain_deq_fx( st_fx, WB_fenv_fx ); -#ifdef BASOP_NOGLOB st_fx->last_wb_bwe_ener_fx = mult_r( add_sat( WB_fenv_fx[0], WB_fenv_fx[1] ), 16384 ); // this would not saturate if written like : rounf_fx(L_mac(L_mult(WB_fenv_fx[0], 16384), WB_fenv_fx[1], 16384)) -#else - st_fx->last_wb_bwe_ener_fx = mult_r( add( WB_fenv_fx[0], WB_fenv_fx[1] ), 16384 ); -#endif move16(); } ELSE @@ -737,13 +733,9 @@ Word16 swb_bwe_gain_deq_fx( /* o : BWE class /*tmp = indice[1]*DIM_TR2*/ tmp = shl( indice[1], 1 ); -#ifdef BASOP_NOGLOB quant_tmp[1] = add_sat( shr( add_sat( quant_tmp[0], quant_tmp[2] ), 1 ), Env_TR_Cdbk2_fx[tmp] ); /* To prevent an unnecessary saturation, it would be better to write the code as below, but might have an impact on EVS bit exactness */ /* quant_tmp[1] = add( extract_h( L_mac( L_mult( quant_tmp[0], 16384 ), quant_tmp[2], 16384 ) ), Env_TR_Cdbk2_fx[tmp] ); */ -#else - quant_tmp[1] = add( shr( add( quant_tmp[0], quant_tmp[2] ), 1 ), Env_TR_Cdbk2_fx[tmp] ); -#endif move16(); /*Q8 */ quant_tmp[3] = add( quant_tmp[2], Env_TR_Cdbk2_fx[tmp + 1] ); move16(); /*Q8 */ @@ -844,11 +836,7 @@ Word16 swb_bwe_gain_deq_fx( /* o : BWE class FOR( n_band = 0; n_band < 5; n_band++ ) { -#ifdef BASOP_NOGLOB SWB_fenv[n_band * 2 + 1] = add_sat( shr( add_sat( quant_tmp[n_band], quant_tmp[n_band + 1] ), 1 ), quant_tmp2[n_band + 1] ); -#else - SWB_fenv[add( shl( n_band, 1 ), 1 )] = add( shr( add( quant_tmp[n_band], quant_tmp[n_band + 1] ), 1 ), quant_tmp2[n_band + 1] ); -#endif move16(); /*Q8 */ } @@ -867,11 +855,7 @@ Word16 swb_bwe_gain_deq_fx( /* o : BWE class FOR( n_band = 0; n_band < DIM12 - 1; n_band++ ) { -#ifdef BASOP_NOGLOB SWB_fenv[n_band * 2 + 1] = add_sat( shr( add_sat( quant_tmp[n_band], quant_tmp[n_band + 1] ), 1 ), quant_tmp2[n_band] ); -#else - SWB_fenv[add( shl( n_band, 1 ), 1 )] = add( shr( add( quant_tmp[n_band], quant_tmp[n_band + 1] ), 1 ), quant_tmp2[n_band] ); -#endif move16(); /*Q8 */ } @@ -891,11 +875,7 @@ Word16 swb_bwe_gain_deq_fx( /* o : BWE class /* output of Pow2() will be: */ /* 16384 < Pow2() <= 32767 */ exp = sub( exp, 13 ); -#ifdef BASOP_NOGLOB SWB_fenv[n_band] = shl_sat( tmp, add( exp, 1 ) ); -#else - SWB_fenv[n_band] = shl( tmp, add( exp, 1 ) ); -#endif move16(); /*Q1 */ } @@ -1121,12 +1101,8 @@ Word16 swb_bwe_dec_fx( /*o :Q_syn_hb*/ IF( SWB_fenv_fx[7] != 0 ) { tmp = div_s( 1, SWB_fenv_fx[7] ); - move16(); /*Q14*/ -#ifdef BASOP_NOGLOB + move16(); /*Q14*/ ener_adjust_quan_fx = s_min( shr( i_mult_sat( SWB_fenv_fx[13], tmp ), 2 ), 32767 ); /*Q13*/ -#else - ener_adjust_quan_fx = s_min( shr( i_mult( SWB_fenv_fx[13], tmp ), 2 ), 32767 ); -#endif } ELSE { @@ -1198,11 +1174,7 @@ Word16 swb_bwe_dec_fx( /*o :Q_syn_hb*/ L_tmp = L_deposit_l( 0 ); FOR( i = 0; i < l_subfr; i++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_mac0_sat( L_tmp, hb_synth_fx[add( tmp, i )], hb_synth_fx[add( tmp, i )] ); /*(2*Q_syn_hb) */ -#else - L_tmp = L_mac0( L_tmp, hb_synth_fx[tmp + i], hb_synth_fx[tmp + i] ); /*(2*Q_syn_hb) */ -#endif } L_tmp = Mult_32_16( L_tmp, div_s( 1, l_subfr ) ); /*(2*Q_syn_hb) */ diff --git a/lib_dec/swb_bwe_dec_hr_fx.c b/lib_dec/swb_bwe_dec_hr_fx.c index b5f8641dc0525f609a90b9f37735f19c16e5d82e..18867ce40bcd5d9ad0bb09e12c67b1212a9b31d0 100644 --- a/lib_dec/swb_bwe_dec_hr_fx.c +++ b/lib_dec/swb_bwe_dec_hr_fx.c @@ -185,13 +185,8 @@ static Word16 TD_Postprocess( /* o : gain in Q15 L_Energy = Sqrt_Ratio32( L_Energy, temp1, L_Energy2, temp2, &temp ); /* Put Back to Q31 (Let it saturate to 0.99999 in fx because we wanted to limit the gain to 1.0 anyways) */ -#ifdef BASOP_NOGLOB L_Energy = L_shl_sat( L_Energy, temp ); temp = round_fx_sat( L_Energy ); -#else - L_Energy = L_shl( L_Energy, temp ); - temp = round_fx( L_Energy ); -#endif test(); IF( EQ_16( last_extl, SWB_BWE ) || EQ_16( last_extl, FB_BWE ) ) @@ -229,15 +224,9 @@ static Word16 TD_Postprocess( /* o : gain in Q15 FOR( i = ind2; i < input_frame; i++ ) { -#ifdef BASOP_NOGLOB hb_synth_fx[i] = mult_r_sat( round_fx_sat( L_Energy ), hb_synth_fx[i] ); move16(); L_Energy = L_add_sat( L_Energy, L_Energy2 ); -#else - hb_synth_fx[i] = mult_r( round_fx( L_Energy ), hb_synth_fx[i] ); - move16(); - L_Energy = L_add( L_Energy, L_Energy2 ); -#endif } } } @@ -489,11 +478,7 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB temp = div_s( 16384, frac ); L_temp = L_deposit_h( temp ); L_temp = Isqrt_lc( L_temp, &exp1 ); -#ifdef BASOP_NOGLOB gain_fx = extract_l( L_shl_sat( L_temp, sub( exp1, 2 ) ) ); /*Q(31-exp + (exp-3)) -> Q13*/ -#else - gain_fx = extract_l( L_shl( L_temp, sub( exp1, 2 ) ) ); /*Q(31-exp + (exp-3)) -> Q13*/ -#endif } env = 512; @@ -626,13 +611,8 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB } /* apply noise-fill */ -#ifdef BASOP_NOGLOB swb_hr_noise_fill_fx( is_transient, NUM_TRANS_START_FREQ_COEF, NUM_TRANS_END_FREQ_COEF, round_fx_sat( L_shl_sat( L_tilt_wb, 3 ) ), /* Q(24+3-16) -> Q11 */ pitch, nq, Nsv, &hBWE_FD_HR->bwe_highrate_seed_fx, t_audio + temp, t_audio_exp ); -#else - swb_hr_noise_fill_fx( is_transient, NUM_TRANS_START_FREQ_COEF, NUM_TRANS_END_FREQ_COEF, round_fx( L_shl( L_tilt_wb, 3 ) ), /* Q(24+3-16) -> Q11 */ - pitch, nq, Nsv, &hBWE_FD_HR->bwe_highrate_seed_fx, t_audio + temp, t_audio_exp ); -#endif /* Go from Q't_audio_exp' on 16 Bits to 'Q_32_BITS' on 32 bits */ temp2 = i_mult2( WIDTH_BAND, Nsv ); ptr16 = &t_audio[temp]; @@ -925,11 +905,7 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB move16(); FOR( i = 0; i < i_mult( Nsv, WIDTH_BAND ); i++ ) { -#ifdef BASOP_NOGLOB t_audio_tmp[i] = shl_sat( x_norm[i], t_audio_exp ); -#else - t_audio_tmp[i] = shl( x_norm[i], t_audio_exp ); -#endif move16(); } @@ -1054,11 +1030,7 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB IF( LT_16( nBits, 200 ) ) { swb_hr_noise_fill_fx( is_transient, NUM_NONTRANS_START_FREQ_COEF, NUM_NONTRANS_END_FREQ_COEF, -#ifdef BASOP_NOGLOB round_fx_sat( L_shl_sat( L_tilt_wb, 3 ) ), /* Q(24+3-16) -> Q11 */ -#else - round_fx( L_shl( L_tilt_wb, 3 ) ), /* Q(24+3-16) -> Q11 */ -#endif pitch, nq, Nsv, &hBWE_FD_HR->bwe_highrate_seed_fx, t_audio + NUM_NONTRANS_START_FREQ_COEF, t_audio_exp ); } @@ -1185,11 +1157,7 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB /* tmpF = max_env / min_env; */ temp = BASOP_Util_Divide1616_Scale( max_env, min_env, &temp2 ); test(); -#ifdef BASOP_NOGLOB IF( EQ_16( st_fx->extl, SWB_BWE_HIGHRATE ) || LT_16( temp, shl_sat( 18022, sub( 15 - 13, temp2 ) ) ) ) /* 2.2 in Q13 == 18022 */ -#else - IF( EQ_16( st_fx->extl, SWB_BWE_HIGHRATE ) || LT_16( temp, shl( 18022, sub( 15 - 13, temp2 ) ) ) ) /* 2.2 in Q13 == 18022 */ -#endif { /* (en_band_flt[3] - j*(en_band_flt[3]/WIDTH_BAND - en_noncoded_flt/WIDTH_BAND)) */ @@ -1281,11 +1249,7 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB FOR( i = 0; i < temp2; i++ ) { L_temp = Mult_32_16( *ptr32, gain_fx ); -#ifdef BASOP_NOGLOB L_temp = L_shl_sat( L_temp, temp ); -#else - L_temp = L_shl( L_temp, temp ); -#endif *ptr32++ = L_temp; move32(); } diff --git a/lib_dec/swb_tbe_dec.c b/lib_dec/swb_tbe_dec.c index 8c2387e53497fe35ad9061d5a68c03210e98c75d..6035e402d9e24cdb7c848add872dd73b595eb2fa 100644 --- a/lib_dec/swb_tbe_dec.c +++ b/lib_dec/swb_tbe_dec.c @@ -996,11 +996,7 @@ void ivas_swb_tbe_dec_fx( { scale_fx = div_s( tmp1, tmp ); /* Q15 - Q(15-exp) + Qi = Qexp+i */ scale_fx = s_max( scale_fx, 0 ); -#ifdef BASOP_NOGLOB tmp = shl_sat( scale_fx, sub( sub( 15, exp ), i ) ); /*Q15*/ -#else - tmp = shl( scale, 15 - exp - i ); /*Q15*/ -#endif } scale_fx = mult_r( hBWE_TD->prev_res_shb_gshape_fx, tmp ); /* Q14 */ test(); @@ -1340,11 +1336,7 @@ void ivas_swb_tbe_dec_fx( FOR( cnt = 0; cnt < L_FRAME32k; cnt++ ) { -#ifdef BASOP_NOGLOB bwe_exc_extended_16[cnt] = round_fx_sat( L_shl_sat( bwe_exc_extended_fx[cnt], sc ) ); -#else - bwe_exc_extended_16[cnt + NL_BUFF_OFFSET] = round_fx( L_shl( bwe_exc_extended[cnt], sc ) ); -#endif move16(); } @@ -1421,22 +1413,12 @@ void ivas_swb_tbe_dec_fx( Copy( shaped_shb_excitationTemp_fx, &shaped_shb_excitation_fx[L_SHB_LAHEAD], L_FRAME16k ); /* Q_bwe_exc */ tmp = sub( shl( Q_bwe_exc, 1 ), 31 + 16 ); -#ifdef BASOP_NOGLOB prev_pow_fx = L_shl_sat( 1407374848l /*0.00001f Q47*/, tmp ); /* 2*(Q_bwe_exc) */ curr_pow_fx = L_shl_sat( 1407374848l /*0.00001f Q47*/, tmp ); /* 2*(Q_bwe_exc) */ -#else - prev_pow_fx = L_shl( 1407374848l /*0.00001f Q47*/, tmp ); /* 2*(Q_bwe_exc) */ - curr_pow_fx = L_shl( 1407374848l /*0.00001f Q47*/, tmp ); /* 2*(Q_bwe_exc) */ -#endif FOR( i = 0; i < L_SHB_LAHEAD + 10; i++ ) { -#ifdef BASOP_NOGLOB prev_pow_fx = L_mac0_sat( prev_pow_fx, shaped_shb_excitation_fx[i], shaped_shb_excitation_fx[i] ); /*2*Q_bwe_exc*/ curr_pow_fx = L_mac0_sat( curr_pow_fx, shaped_shb_excitation_fx[i + L_SHB_LAHEAD + 10], shaped_shb_excitation_fx[i + L_SHB_LAHEAD + 10] ); /* 2*Q_bwe_exc */ -#else - prev_pow_fx = L_mac0( prev_pow_fx, shaped_shb_excitation_fx[i], shaped_shb_excitation_fx[i] ); /*2*Q_bwe_exc*/ - curr_pow_fx = L_mac0( curr_pow_fx, shaped_shb_excitation_fx[i + L_SHB_LAHEAD + 10], shaped_shb_excitation_fx[i + L_SHB_LAHEAD + 10] ); /* 2*Q_bwe_exc */ -#endif } if ( GT_16( voice_factors_fx[0], 24576 /*0.75f Q15*/ ) ) @@ -1464,13 +1446,8 @@ void ivas_swb_tbe_dec_fx( } FOR( ; i < L_SHB_LAHEAD + 10; i++ ) { -#ifdef BASOP_NOGLOB temp_fx = i_mult_sat( sub( i, 19 ), 3277 /*0.1f Q15*/ ); /* Q15 */ L_tmp1 = Mult_32_16( L_shl_sat( 1, sub( 31, exp ) ), temp_fx ); /* Q31-exp */ -#else - temp_fx = i_mult( sub( i, 19 ), 3277 /*0.1f Q15*/ ); /* Q15 */ - L_tmp1 = Mult_32_16( L_shl( 1, sub( 31, exp ) ), temp_fx ); /* Q31-exp */ -#endif temp_fx = sub( 32767 /*1.0f Q15*/, temp_fx ); Lscale = L_add( Mult_32_16( Lscale, temp_fx ), L_tmp1 ); L_tmp = Mult_32_16( Lscale, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ @@ -1519,22 +1496,12 @@ void ivas_swb_tbe_dec_fx( tmp = div_s( 16384, tmp ); L_tmp = L_deposit_h( tmp ); L_tmp = Isqrt_lc( L_tmp, &exp ); -#ifdef BASOP_NOGLOB ener_tmp_fx[i] = L_shl_sat( L_tmp, sub( add( exp, shl( Q_bwe_exc, 1 ) ), 31 ) ); /*2 * Q_bwe_exc: Q31 -exp +exp +2 * Q_bwe_exc -31 */ move32(); L_ener = L_add_sat( L_ener, L_shr( ener_tmp_fx[i], 2 ) ); /* 2*Q_bwe_exc */ -#else - ener_tmp_fx[i] = L_shl( L_tmp, sub( add( exp, shl( Q_bwe_exc, 1 ) ), 31 ) ); /*2 * Q_bwe_exc: Q31 -exp +exp +2 * Q_bwe_exc -31 */ - move32(); - L_ener = L_add( L_ener, L_shr( ener_tmp_fx[i], 2 ) ); /* 2*Q_bwe_exc */ -#endif } } -#ifdef BASOP_NOGLOB /* Saturation fix taken from EVS*/ ener_fx = s_max( 1, round_fx_sat( L_shl_sat( L_ener, sub( 18, shl( Q_bwe_exc, 1 ) ) ) ) ); /* Q2: 2*Q_bwe_exc+18-2*Q_bwe_exc-16 */ -#else - ener_fx = s_max( 1, round_fx( L_shl( L_ener, sub( 18, shl( Q_bwe_exc, 1 ) ) ) ) ); /* Q2: 2*Q_bwe_exc+18-2*Q_bwe_exc-16 */ -#endif /* WB/SWB bandwidth switching */ IF( st->bws_cnt > 0 ) { @@ -1589,21 +1556,13 @@ void ivas_swb_tbe_dec_fx( test(); IF( GT_32( L_tmp, st->enerLH_fx ) ) /*st->Q_syn2*/ { -#ifdef BASOP_NOGLOB st->tilt_wb_fx = extract_h( L_shr_sat( Mult_32_16( st->enerLH_fx, inv_ener ), sub( sub( st->Q_syn2, exp_ener ), 16 ) ) ); /*Q11*/ -#else - st->tilt_wb_fx = extract_h( L_shr( Mult_32_16( st->enerLH_fx, inv_ener ), sub( sub( st->Q_syn2, exp_ener ), 16 ) ) ); /*Q11*/ -#endif move16(); /*st->Q_syn2 -1 + 26- exp_ener -15 -(st->Q_syn2 -exp_ener -16 ) -16 +1 -1 = (11) *0.5*/ } ELSE IF( LT_32( L_tmp, Mult_32_16( st->enerLH_fx, 1638 ) ) && EQ_16( is_fractive, 1 ) ) { -#ifdef BASOP_NOGLOB st->tilt_wb_fx = extract_h( L_shr_sat( Mult_32_16( st->enerLH_fx, inv_ener ), sub( sub( st->Q_syn2, exp_ener ), 15 ) ) ); /*Q11*/ -#else - st->tilt_wb_fx = extract_h( L_shr( Mult_32_16( st->enerLH_fx, inv_ener ), sub( sub( st->Q_syn2, exp_ener ), 15 ) ) ); /*Q11*/ -#endif move16(); /*st->Q_syn2 -1 + 26- exp_ener -15 -(st->Q_syn2 -exp_ener -15 ) -16 = (11) 0.25*/ } @@ -1803,11 +1762,7 @@ void ivas_swb_tbe_dec_fx( L_tmp1 = Mult_32_16( ener_tmp_fx[i], GainShape_tmp_fx[i] ); /* (2*Q_bwe_exc) */ L_tmp2 = Mult_32_16( hBWE_TD->prev_ener_fx, hBWE_TD->prev_GainShape_fx ); /* (2*st->prev_ener_fx_Q) */ tmp = sub( shl( Q_bwe_exc, 1 ), shl( st->prev_ener_fx_Q, 1 ) ); -#ifdef BASOP_NOGLOB L_tmp2 = L_shl_sat( L_tmp2, tmp ); /* new Q = (2*Q_bwe_exc) */ -#else - L_tmp2 = L_shl( L_tmp2, tmp ); /* new Q = (2*Q_bwe_exc) */ -#endif IF( GT_32( L_tmp1, L_tmp2 ) ) { L_tmp = L_tmp2; @@ -1818,11 +1773,7 @@ void ivas_swb_tbe_dec_fx( } expb = norm_l( L_tmp ); -#ifdef BASOP_NOGLOB fracb = round_fx_sat( L_shl_sat( L_tmp, expb ) ); -#else - fracb = round_fx( L_shl( L_tmp, expb ) ); -#endif expb = sub( 30, expb ); /* - (2*Q_bwe_exc_ext); */ expa = norm_l( ener_tmp_fx[i] ); @@ -1935,7 +1886,7 @@ void ivas_swb_tbe_dec_fx( IF( hStereoICBWE != NULL ) { - Copy_Scale_sig_16_32( lpc_shb_fx, hStereoICBWE->lpSHBRef_fx, LPC_SHB_ORDER + 1, 0 ); + Copy_Scale_sig_16_32_DEPREC( lpc_shb_fx, hStereoICBWE->lpSHBRef_fx, LPC_SHB_ORDER + 1, 0 ); Copy( GainShape_fx, hStereoICBWE->gshapeRef_fx, NUM_SHB_SUBFR ); hStereoICBWE->gFrameRef_fx = GainFrame_fx; move32(); @@ -1963,13 +1914,8 @@ void ivas_swb_tbe_dec_fx( move16(); FOR( i = 0; i < L_FRAME16k; i++ ) { -#ifdef BASOP_NOGLOB shaped_shb_excitation_frac[i] = shl_sat( shaped_shb_excitation_fx[i], n ); /*Q_bwe_exc+n*/ move16(); -#else - shaped_shb_excitation_frac[i] = shl( shaped_shb_excitation_fx[i], n ); /*Q_bwe_exc+n*/ - move16(); -#endif } curr_frame_pow_fx = 0; @@ -2098,11 +2044,7 @@ void ivas_swb_tbe_dec_fx( ( EQ_16( st->prev_coder_type, UNVOICED ) || ( st->last_good == UNVOICED_CLAS ) || GT_16( hBWE_TD->tilt_swb_fec_fx, 10240 ) ) ) { L_tmp = root_a_over_b_fx( hBWE_TD->prev_swb_bwe_frame_pow_fx, curr_frame_pow_exp, curr_frame_pow_fx, curr_frame_pow_exp, &exp ); -#ifdef BASOP_NOGLOB scale_fx = round_fx_sat( L_shl_sat( L_tmp, sub( exp, 3 ) ) ); /*Q12*/ -#else - scale_fx = round_fx( L_shl( L_tmp, sub( exp, 3 ) ) ); /*Q12*/ -#endif L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); @@ -2123,23 +2065,15 @@ void ivas_swb_tbe_dec_fx( L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); -#ifdef BASOP_NOGLOB temp_fx = round_fx_sat( L_shl_sat( L_tmp, sub( exp, 3 ) ) ); /*Q12*/ -#else - temp_fx = round_fx( L_shl( L_tmp, sub( exp, 3 ) ) ); /*Q12*/ -#endif } ELSE IF( LT_32( curr_frame_pow_fx, L_shr( hBWE_TD->prev_swb_bwe_frame_pow_fx, 1 ) ) && ( GT_32( st->enerLL_fx, L_shr( st->prev_enerLL_fx, 1 ) ) || GT_32( st->enerLH_fx, L_shr( st->prev_enerLH_fx, 1 ) ) ) && ( EQ_16( st->prev_coder_type, UNVOICED ) || ( st->last_good == UNVOICED_CLAS ) || GT_16( hBWE_TD->tilt_swb_fec_fx, 10240 ) ) ) { L_tmp = root_a_over_b_fx( hBWE_TD->prev_swb_bwe_frame_pow_fx, curr_frame_pow_exp, curr_frame_pow_fx, curr_frame_pow_exp, &exp ); -#ifdef BASOP_NOGLOB L_tmp = L_min( L_tmp, L_shl_sat( 2, sub( 31, exp ) ) ); /*31 - exp*/ -#else - L_tmp = L_min( L_tmp, L_shl( 2, ( 31 - exp ) ) ); /*31 - exp*/ -#endif - scale_fx = round_fx( L_shl( L_tmp, sub( exp, 3 ) ) ); /*Q12*/ + scale_fx = round_fx( L_shl( L_tmp, sub( exp, 3 ) ) ); /*Q12*/ L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); @@ -2149,17 +2083,9 @@ void ivas_swb_tbe_dec_fx( FOR( j = 0; j < 8; j++ ) { -#ifdef BASOP_NOGLOB GainShape_fx[2 * j] = shl_sat( mult_r( GainShape_fx[2 * j], scale_fx ), 3 ); -#else - GainShape_fx[2 * j] = shl( mult_r( GainShape_fx[2 * j], scale_fx ), 3 ); -#endif move16(); /* 15 +12 +3-15 =15*/ -#ifdef BASOP_NOGLOB GainShape_fx[add( 2 * j, 1 )] = shl_sat( mult_r( GainShape_fx[add( 2 * j, 1 )], scale_fx ), 3 ); -#else - GainShape_fx[2 * j + 1] = shl( mult_r( GainShape_fx[2 * j + 1], scale_fx ), 3 ); -#endif move16(); FOR( i = 0; i < 40; i++ ) { @@ -2214,11 +2140,7 @@ void ivas_swb_tbe_dec_fx( tmp = div_s( 16384, tmp ); L_tmp = L_deposit_h( tmp ); L_tmp = Isqrt_lc( L_tmp, &exp ); -#ifdef BASOP_NOGLOB /* Saturation fix taken from EVS*/ st->prev_ener_shb_fx = round_fx_sat( L_shl_sat( L_tmp, sub( exp, 14 ) ) ); /* Q1 */ -#else - st->prev_ener_shb_fx = round_fx( L_shl( L_tmp, sub( exp, 14 ) ) ); /* Q1 */ -#endif move16(); } @@ -2236,11 +2158,7 @@ void ivas_swb_tbe_dec_fx( tmp = div_s( 16384, tmp ); L_tmp = L_deposit_h( tmp ); L_tmp = Isqrt_lc( L_tmp, &exp ); -#ifdef BASOP_NOGLOB /* Saturation fix taken from EVS*/ tmp = round_fx_sat( L_shl_sat( L_tmp, sub( exp, 14 ) ) ); /* Q1 */ -#else - tmp = round_fx( L_shl( L_tmp, sub( exp, 14 ) ) ); /* Q1 */ -#endif } set16_fx( st->prev_SWB_fenv_fx, tmp, SWB_FENV ); /* Q1 */ } diff --git a/lib_dec/swb_tbe_dec_fx.c b/lib_dec/swb_tbe_dec_fx.c index 54a8127c97ff8ac7c5152e7c96dfcff8a9d16136..28ac016711566fe8063b8cbd586dd718ab271df4 100644 --- a/lib_dec/swb_tbe_dec_fx.c +++ b/lib_dec/swb_tbe_dec_fx.c @@ -906,11 +906,7 @@ void ivas_wb_tbe_dec_fx( IF( st_fx->element_mode > EVS_MONO ) { tmp = sub( shl( sub( st_fx->prev_Q_bwe_exc, 16 ), 1 ), 31 + 16 ); -#ifdef BASOP_NOGLOB prev_pow = L_shl_sat( 1407374848l /*0.00001f Q47*/, tmp ); /*Q(2*(st_fx->prev_Q_bwe_exc-16))*/ -#else - prev_pow = L_shl( 1407374848l /*0.00001f Q47*/, tmp ); /*Q(2*(st_fx->prev_Q_bwe_exc-16))*/ -#endif } FOR( i = 0; i < L_SHB_LAHEAD / 4; i++ ) { @@ -930,7 +926,7 @@ void ivas_wb_tbe_dec_fx( Q_bwe_exc_ext = sub( Q_bwe_exc, 16 ); - ivas_GenShapedWBExcitation_fx( shaped_wb_excitation + L_SHB_LAHEAD / 4, lpc_wb, exc4kWhtnd, hBWE_TD->mem_csfilt_fx, + GenShapedWBExcitation_ivas_fx( shaped_wb_excitation + L_SHB_LAHEAD / 4, lpc_wb, exc4kWhtnd, hBWE_TD->mem_csfilt_fx, hBWE_TD->mem_genSHBexc_filt_down_shb_fx, hBWE_TD->mem_genSHBexc_filt_down_wb2_fx, hBWE_TD->mem_genSHBexc_filt_down_wb3_fx, hBWE_TD->state_lpc_syn_fx, coder_type, bwe_exc_extended_16, Q_bwe_exc_ext, hBWE_TD->bwe_seed, vf_modified, uv_flag, st_fx->igf ); @@ -940,19 +936,11 @@ void ivas_wb_tbe_dec_fx( IF( st_fx->element_mode > EVS_MONO ) { tmp = sub( shl( Q_bwe_exc_ext, 1 ), 31 + 16 ); -#ifdef BASOP_NOGLOB curr_pow = L_shl_sat( 1407374848l /*0.00001f Q47*/, tmp ); /*Q(2*(Q_bwe_exc_ext))*/ -#else - curr_pow = L_shl( 1407374848l /*0.00001f Q47*/, tmp ); /* 2*(Q_bwe_exc_ext) */ -#endif } FOR( i = 0; i < L_SHB_LAHEAD / 4; i++ ) { -#ifdef BASOP_NOGLOB curr_pow = L_mac0_sat( curr_pow, shaped_wb_excitation[i + L_SHB_LAHEAD / 4], shaped_wb_excitation[i + L_SHB_LAHEAD / 4] ); /* Q(2*Q_bwe_exc_ext) */ -#else - curr_pow = L_mac0( curr_pow, shaped_wb_excitation[i + L_SHB_LAHEAD / 4], shaped_wb_excitation[i + L_SHB_LAHEAD / 4] ); /* Q(2*Q_bwe_exc_ext) */ -#endif } if ( GT_16( voice_factors[0], 24576 ) ) @@ -965,12 +953,8 @@ void ivas_wb_tbe_dec_fx( FOR( i = 0; i < L_SHB_LAHEAD / 4 - 1; i++ ) { - L_tmp = Mult_32_16( Lscale, shaped_wb_excitation[i] ); /* Q(16-exp+Q_bwe_exc_ext) */ -#ifdef BASOP_NOGLOB + L_tmp = Mult_32_16( Lscale, shaped_wb_excitation[i] ); /* Q(16-exp+Q_bwe_exc_ext) */ shaped_wb_excitation[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc_ext */ -#else - shaped_wb_excitation[i] = round_fx( L_shl( L_tmp, exp ) ); /* Q_bwe_exc_ext */ -#endif move16(); } Lscale = root_a_fx( Lscale, sub( 31, exp ), &exp ); @@ -1007,26 +991,16 @@ void ivas_wb_tbe_dec_fx( n = norm_s( max ); FOR( i = 0; i < L_FRAME16k / 4; i++ ) { -#ifdef BASOP_NOGLOB shaped_wb_excitation_frac[i] = shl_o( shaped_wb_excitation[i], n, &Overflow ); /*Q14*/ move16(); -#else - shaped_wb_excitation_frac[i] = shl( shaped_wb_excitation[i], n ); /*Q14*/ - move16(); -#endif } n = sub( 14, n ); curr_frame_pow = 1; move32(); FOR( i = 0; i < L_FRAME16k / 4; i++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_mult_o( shaped_wb_excitation_frac[i], shaped_wb_excitation_frac[i], &Overflow ); /*Q29*/ curr_frame_pow = L_add_o( curr_frame_pow, L_shr( L_tmp, 7 ), &Overflow ); /*Q22*/ -#else - L_tmp = L_mult( shaped_wb_excitation_frac[i], shaped_wb_excitation_frac[i] ); /*Q29*/ - curr_frame_pow = L_add( curr_frame_pow, L_shr( L_tmp, 7 ) ); /*Q22*/ -#endif } } curr_frame_pow_exp = add( n, n ); @@ -1216,19 +1190,11 @@ void ivas_wb_tbe_dec_fx( L_tmp = Mult_32_16( Lacc, 102 ); /* Q22 */ exp = norm_l( L_tmp ); -#ifdef BASOP_NOGLOB tmp = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); -#else - tmp = round_fx( L_shl( L_tmp, exp ) ); -#endif exp = sub( add( exp, 22 ), 30 ); tmp = div_s( 16384, tmp ); - L_tmp = Isqrt_lc( L_deposit_h( tmp ), &exp ); /* Q(31-exp) */ -#ifdef BASOP_NOGLOB + L_tmp = Isqrt_lc( L_deposit_h( tmp ), &exp ); /* Q(31-exp) */ st_fx->last_wb_bwe_ener_fx = round_fx_sat( L_shl_sat( L_tmp, add( exp, sub( n, 12 ) ) ) ); /* Q3 */ -#else - st_fx->last_wb_bwe_ener_fx = round_fx( L_shl( L_tmp, add( exp, sub( n, 12 ) ) ) ); /* Q3 */ -#endif move16(); } @@ -1256,11 +1222,7 @@ void ivas_wb_tbe_dec_fx( { lsf_wb[i] = f; move16(); /*Q15*/ -#ifdef BASOP_NOGLOB f = add_sat( f, inc ); -#else - f = add( f, inc ); -#endif move16(); } GainFrame = 0; /* Q18 */ @@ -1582,19 +1544,11 @@ void wb_tbe_dec_fx( IF( st_fx->element_mode > EVS_MONO ) { tmp = sub( shl( sub( st_fx->prev_Q_bwe_exc, 16 ), 1 ), 31 + 16 ); -#ifdef BASOP_NOGLOB prev_pow = L_shl_sat( 1407374848l /*0.00001f Q47*/, tmp ); /*Q(2*(st_fx->prev_Q_bwe_exc-16))*/ -#else - prev_pow = L_shl( 1407374848l /*0.00001f Q47*/, tmp ); /*Q(2*(st_fx->prev_Q_bwe_exc-16))*/ -#endif } FOR( i = 0; i < L_SHB_LAHEAD / 4; i++ ) { -#ifdef BASOP_NOGLOB prev_pow = L_mac0_sat( prev_pow, hBWE_TD->state_syn_shbexc_fx[i], hBWE_TD->state_syn_shbexc_fx[i] ); /*Q(2*(st_fx->prev_Q_bwe_exc-16))*/ -#else - prev_pow = L_mac0( prev_pow, hBWE_TD->state_syn_shbexc_fx[i], hBWE_TD->state_syn_shbexc_fx[i] ); /*Q(2*(st_fx->prev_Q_bwe_exc-16))*/ -#endif } rescale_genWB_mem( st_fx, sub( Q_bwe_exc, st_fx->prev_Q_bwe_exc ) ); @@ -1603,11 +1557,7 @@ void wb_tbe_dec_fx( sc = sub( Q_bwe_exc, add( Q_exc, Q_exc ) ); FOR( cnt = 0; cnt < L_FRAME32k; cnt++ ) { -#ifdef BASOP_NOGLOB bwe_exc_extended_16[cnt + NL_BUFF_OFFSET] = round_fx_sat( L_shl_sat( bwe_exc_extended[cnt], sc ) ); -#else - bwe_exc_extended_16[cnt + NL_BUFF_OFFSET] = round_fx( L_shl( bwe_exc_extended[cnt], sc ) ); -#endif } Copy( bwe_exc_extended_16 + L_FRAME32k, hBWE_TD->old_bwe_exc_extended_fx, NL_BUFF_OFFSET ); @@ -1625,19 +1575,11 @@ void wb_tbe_dec_fx( IF( st_fx->element_mode > EVS_MONO ) { tmp = sub( shl( Q_bwe_exc_ext, 1 ), 31 + 16 ); -#ifdef BASOP_NOGLOB curr_pow = L_shl_sat( 1407374848l /*0.00001f Q47*/, tmp ); /*Q(2*(Q_bwe_exc_ext))*/ -#else - curr_pow = L_shl( 1407374848l /*0.00001f Q47*/, tmp ); /* 2*(Q_bwe_exc_ext) */ -#endif } FOR( i = 0; i < L_SHB_LAHEAD / 4; i++ ) { -#ifdef BASOP_NOGLOB curr_pow = L_mac0_sat( curr_pow, shaped_wb_excitation[i + L_SHB_LAHEAD / 4], shaped_wb_excitation[i + L_SHB_LAHEAD / 4] ); /* Q(2*Q_bwe_exc_ext) */ -#else - curr_pow = L_mac0( curr_pow, shaped_wb_excitation[i + L_SHB_LAHEAD / 4], shaped_wb_excitation[i + L_SHB_LAHEAD / 4] ); /* Q(2*Q_bwe_exc_ext) */ -#endif } if ( GT_16( voice_factors[0], 24576 ) ) @@ -1650,12 +1592,8 @@ void wb_tbe_dec_fx( FOR( i = 0; i < L_SHB_LAHEAD / 4 - 1; i++ ) { - L_tmp = Mult_32_16( Lscale, shaped_wb_excitation[i] ); /* Q(16-exp+Q_bwe_exc_ext) */ -#ifdef BASOP_NOGLOB + L_tmp = Mult_32_16( Lscale, shaped_wb_excitation[i] ); /* Q(16-exp+Q_bwe_exc_ext) */ shaped_wb_excitation[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc_ext */ -#else - shaped_wb_excitation[i] = round_fx( L_shl( L_tmp, exp ) ); /* Q_bwe_exc_ext */ -#endif move16(); } Lscale = root_a_fx( Lscale, sub( 31, exp ), &exp ); @@ -1691,26 +1629,16 @@ void wb_tbe_dec_fx( n = norm_s( max ); FOR( i = 0; i < L_FRAME16k / 4; i++ ) { -#ifdef BASOP_NOGLOB shaped_wb_excitation_frac[i] = shl_o( shaped_wb_excitation[i], n, &Overflow ); /*Q14*/ move16(); -#else - shaped_wb_excitation_frac[i] = shl( shaped_wb_excitation[i], n ); /*Q14*/ - move16(); -#endif } n = sub( 14, n ); curr_frame_pow = 1; move32(); FOR( i = 0; i < L_FRAME16k / 4; i++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_mult_o( shaped_wb_excitation_frac[i], shaped_wb_excitation_frac[i], &Overflow ); /*Q29*/ curr_frame_pow = L_add_o( curr_frame_pow, L_shr( L_tmp, 7 ), &Overflow ); /*Q22*/ -#else - L_tmp = L_mult( shaped_wb_excitation_frac[i], shaped_wb_excitation_frac[i] ); /*Q29*/ - curr_frame_pow = L_add( curr_frame_pow, L_shr( L_tmp, 7 ) ); /*Q22*/ -#endif } } curr_frame_pow_exp = add( n, n ); @@ -1898,19 +1826,11 @@ void wb_tbe_dec_fx( L_tmp = Mult_32_16( Lacc, 102 ); /* Q22 */ exp = norm_l( L_tmp ); -#ifdef BASOP_NOGLOB tmp = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); -#else - tmp = round_fx( L_shl( L_tmp, exp ) ); -#endif exp = sub( add( exp, 22 ), 30 ); tmp = div_s( 16384, tmp ); - L_tmp = Isqrt_lc( L_deposit_h( tmp ), &exp ); /* Q(31-exp) */ -#ifdef BASOP_NOGLOB + L_tmp = Isqrt_lc( L_deposit_h( tmp ), &exp ); /* Q(31-exp) */ st_fx->last_wb_bwe_ener_fx = round_fx_sat( L_shl_sat( L_tmp, add( exp, sub( n, 12 ) ) ) ); /* Q3 */ -#else - st_fx->last_wb_bwe_ener_fx = round_fx( L_shl( L_tmp, add( exp, n - 12 ) ) ); /* Q3 */ -#endif move16(); } @@ -1938,11 +1858,7 @@ void wb_tbe_dec_fx( { lsf_wb[i] = f; move16(); /*Q15*/ -#ifdef BASOP_NOGLOB f = add_sat( f, inc ); -#else - f = add( f, inc ); -#endif move16(); } GainFrame = 0; /* Q18 */ @@ -2101,11 +2017,7 @@ void swb_tbe_dec_fx( Q_shb = 0; /* high band target Q factor set to zero */ move16(); L_tmp = calc_tilt_bwe_fx( old_syn_12k8_16k, st_fx->Q_syn2, st_fx->L_frame ); -#ifdef BASOP_NOGLOB tilt_swb_fec = round_fx_sat( L_shl_sat( L_tmp, 3 ) ); -#else - tilt_swb_fec = round_fx( L_shl( L_tmp, 3 ) ); -#endif /* i: old_syn_12k8_16k in st_fx->Q_syn2 */ /* o: tilt_swb_fec in Q11 */ test(); @@ -2401,11 +2313,7 @@ void swb_tbe_dec_fx( scale = div_s( tmp1, tmp ); /* Q15 - Q(15-exp) + Qi = Qexp+i */ scale = s_max( scale, 0 ); /*scale = st->prev_res_shb_gshape * min(scale, 1.0f); */ -#ifdef BASOP_NOGLOB tmp = shl_sat( scale, sub( sub( 15, exp ), i ) ); /*Q15*/ -#else - tmp = shl( scale, 15 - exp - i ); /*Q15*/ -#endif } scale = mult_r( hBWE_TD->prev_res_shb_gshape_fx, tmp ); /* Q14 */ @@ -2738,11 +2646,7 @@ void swb_tbe_dec_fx( FOR( cnt = 0; cnt < L_FRAME32k; cnt++ ) { -#ifdef BASOP_NOGLOB bwe_exc_extended_16[cnt + NL_BUFF_OFFSET] = round_fx_sat( L_shl_sat( bwe_exc_extended[cnt], sc ) ); -#else - bwe_exc_extended_16[cnt + NL_BUFF_OFFSET] = round_fx( L_shl( bwe_exc_extended[cnt], sc ) ); -#endif } Copy( bwe_exc_extended_16 + L_FRAME32k, hBWE_TD->old_bwe_exc_extended_fx, NL_BUFF_OFFSET ); @@ -2805,22 +2709,12 @@ void swb_tbe_dec_fx( Copy( shaped_shb_excitationTemp, &shaped_shb_excitation[L_SHB_LAHEAD], L_FRAME16k ); /* Q_bwe_exc */ tmp = sub( shl( Q_bwe_exc, 1 ), 31 + 16 ); -#ifdef BASOP_NOGLOB prev_pow = L_shl_sat( 1407374848l /*0.00001f Q47*/, tmp ); /* 2*(Q_bwe_exc) */ curr_pow = L_shl_sat( 1407374848l /*0.00001f Q47*/, tmp ); /* 2*(Q_bwe_exc) */ -#else - prev_pow = L_shl( 1407374848l /*0.00001f Q47*/, tmp ); /* 2*(Q_bwe_exc) */ - curr_pow = L_shl( 1407374848l /*0.00001f Q47*/, tmp ); /* 2*(Q_bwe_exc) */ -#endif FOR( i = 0; i < L_SHB_LAHEAD + 10; i++ ) { -#ifdef BASOP_NOGLOB prev_pow = L_mac0_sat( prev_pow, shaped_shb_excitation[i], shaped_shb_excitation[i] ); /*2*Q_bwe_exc*/ curr_pow = L_mac0_sat( curr_pow, shaped_shb_excitation[i + L_SHB_LAHEAD + 10], shaped_shb_excitation[i + L_SHB_LAHEAD + 10] ); /* 2*Q_bwe_exc */ -#else - prev_pow = L_mac0( prev_pow, shaped_shb_excitation[i], shaped_shb_excitation[i] ); /*2*Q_bwe_exc*/ - curr_pow = L_mac0( curr_pow, shaped_shb_excitation[i + L_SHB_LAHEAD + 10], shaped_shb_excitation[i + L_SHB_LAHEAD + 10] ); /* 2*Q_bwe_exc */ -#endif } if ( GT_16( voice_factors[0], 24576 /*0.75f Q15*/ ) ) @@ -2848,13 +2742,8 @@ void swb_tbe_dec_fx( } FOR( ; i < L_SHB_LAHEAD + 10; i++ ) { -#ifdef BASOP_NOGLOB temp = i_mult_sat( sub( i, 19 ), 3277 /*0.1f Q15*/ ); /* Q15 */ L_tmp1 = Mult_32_16( L_shl_sat( 1, sub( 31, exp ) ), temp ); /* Q31-exp */ -#else - temp = i_mult( sub( i, 19 ), 3277 /*0.1f Q15*/ ); /* Q15 */ - L_tmp1 = Mult_32_16( L_shl( 1, sub( 31, exp ) ), temp ); /* Q31-exp */ -#endif temp = sub( 32767 /*1.0f Q15*/, temp ); Lscale = L_add( Mult_32_16( Lscale, temp ), L_tmp1 ); L_tmp = Mult_32_16( Lscale, shaped_shb_excitation[i] ); /* Q_bwe_exc + (31-exp) - 15 */ @@ -2894,22 +2783,12 @@ void swb_tbe_dec_fx( tmp = div_s( 16384, tmp ); L_tmp = L_deposit_h( tmp ); L_tmp = Isqrt_lc( L_tmp, &exp ); -#ifdef BASOP_NOGLOB ener_tmp[i] = L_shl_sat( L_tmp, sub( add( exp, shl( Q_bwe_exc, 1 ) ), 31 ) ); /*2 * Q_bwe_exc: Q31 -exp +exp +2 * Q_bwe_exc -31 */ move32(); L_ener = L_add_sat( L_ener, L_shr( ener_tmp[i], 2 ) ); /* 2*Q_bwe_exc */ -#else - ener_tmp[i] = L_shl( L_tmp, sub( add( exp, shl( Q_bwe_exc, 1 ) ), 31 ) ); /*2 * Q_bwe_exc: Q31 -exp +exp +2 * Q_bwe_exc -31 */ - move32(); - L_ener = L_add( L_ener, L_shr( ener_tmp[i], 2 ) ); /* 2*Q_bwe_exc */ -#endif } } -#ifdef BASOP_NOGLOB ener = s_max( 1, round_fx_sat( L_shl_sat( L_ener, sub( 19, shl( Q_bwe_exc, 1 ) ) ) ) ); /* Q3: 2*Q_bwe_exc+19-2*Q_bwe_exc-16 */ -#else - ener = s_max( 1, round_fx( L_shl( L_ener, sub( 19, shl( Q_bwe_exc, 1 ) ) ) ) ); /* Q3: 2*Q_bwe_exc+19-2*Q_bwe_exc-16 */ -#endif /* WB/SWB bandwidth switching */ IF( st_fx->bws_cnt > 0 ) { @@ -2972,30 +2851,18 @@ void swb_tbe_dec_fx( test(); IF( GT_32( L_tmp, st_fx->enerLH_fx ) ) /*st_fx->Q_syn2*/ { -#ifdef BASOP_NOGLOB st_fx->tilt_wb_fx = extract_h( L_shr_sat( Mult_32_16( st_fx->enerLH_fx, inv_ener ), sub( sub( st_fx->Q_syn2, exp_ener ), 16 ) ) ); /*Q11*/ -#else - st_fx->tilt_wb_fx = extract_h( L_shr( Mult_32_16( st_fx->enerLH_fx, inv_ener ), sub( sub( st_fx->Q_syn2, exp_ener ), 16 ) ) ); /*Q11*/ -#endif move16(); /*st_fx->Q_syn2 -1 + 26- exp_ener -15 -(st_fx->Q_syn2 -exp_ener -16 ) -16 +1 -1 = (11) *0.5*/ } ELSE IF( LT_32( L_tmp, Mult_32_16( st_fx->enerLH_fx, 1638 ) ) && EQ_16( is_fractive, 1 ) ) { -#ifdef BASOP_NOGLOB st_fx->tilt_wb_fx = extract_h( L_shr_sat( Mult_32_16( st_fx->enerLH_fx, inv_ener ), sub( sub( st_fx->Q_syn2, exp_ener ), 15 ) ) ); /*Q11*/ -#else - st_fx->tilt_wb_fx = extract_h( L_shr( Mult_32_16( st_fx->enerLH_fx, inv_ener ), sub( sub( st_fx->Q_syn2, exp_ener ), 15 ) ) ); /*Q11*/ -#endif move16(); /*st_fx->Q_syn2 -1 + 26- exp_ener -15 -(st_fx->Q_syn2 -exp_ener -15 ) -16 = (11) 0.25*/ } - L_tmp = L_mult0( st_fx->prev_ener_shb_fx, inv_ener ); /*Q(1+15+14-3-exp_ener) = 27 -exp_ener*/ -#ifdef BASOP_NOGLOB + L_tmp = L_mult0( st_fx->prev_ener_shb_fx, inv_ener ); /*Q(1+15+14-3-exp_ener) = 27 -exp_ener*/ GainFrame_prevfrm_fx = L_shr_sat( L_tmp, sub( 9, exp_ener ) ); /*27 -exp_ener -(9-exp_ener )= Q18*/ -#else - GainFrame_prevfrm_fx = L_shr( L_tmp, sub( 9, exp_ener ) ); /*27 -exp_ener -(9-exp_ener )= Q18*/ -#endif } ELSE { @@ -3055,13 +2922,9 @@ void swb_tbe_dec_fx( { ener = s_max( 1, ener ); exp_ener = norm_s( ener ); - tmp = shl( ener, exp_ener ); /*Q(3+exp)*/ - inv_ener = div_s( 16384, tmp ); /*Q(15+14-3-exp)*/ -#ifdef BASOP_NOGLOB + tmp = shl( ener, exp_ener ); /*Q(3+exp)*/ + inv_ener = div_s( 16384, tmp ); /*Q(15+14-3-exp)*/ prev_ener_ratio_fx = L_shr_sat( L_mult0( st_fx->prev_ener_shb_fx, inv_ener ), sub( 9, exp_ener ) ); /*Q: 1+26-exp-9+exp = 18 */ -#else - prev_ener_ratio_fx = L_shr( L_mult0( st_fx->prev_ener_shb_fx, inv_ener ), sub( 9, exp_ener ) ); /*Q: 1+26-exp-9+exp = 18 */ -#endif } IF( EQ_16( st_fx->nbLostCmpt, 1 ) ) @@ -3193,11 +3056,7 @@ void swb_tbe_dec_fx( L_tmp1 = Mult_32_16( ener_tmp[i], GainShape_tmp[i] ); /* (2*Q_bwe_exc) */ L_tmp2 = Mult_32_16( hBWE_TD->prev_ener_fx, hBWE_TD->prev_GainShape_fx ); /* (2*st_fx->prev_ener_fx_Q) */ tmp = sub( shl( Q_bwe_exc, 1 ), shl( st_fx->prev_ener_fx_Q, 1 ) ); -#ifdef BASOP_NOGLOB L_tmp2 = L_shl_sat( L_tmp2, tmp ); /* new Q = (2*Q_bwe_exc) */ -#else - L_tmp2 = L_shl( L_tmp2, tmp ); /* new Q = (2*Q_bwe_exc) */ -#endif IF( GT_32( L_tmp1, L_tmp2 ) ) { /*GainShape_tmp_fx[i] = 0.5f*(L_tmp2/ener_tmp_fx[i] + GainShape_tmp_fx[i]);*/ @@ -3210,11 +3069,7 @@ void swb_tbe_dec_fx( } expb = norm_l( L_tmp ); -#ifdef BASOP_NOGLOB fracb = round_fx_sat( L_shl_sat( L_tmp, expb ) ); -#else - fracb = round_fx( L_shl( L_tmp, expb ) ); -#endif expb = sub( 30, expb ); /* - (2*Q_bwe_exc_ext); */ expa = norm_l( ener_tmp[i] ); @@ -3299,13 +3154,8 @@ void swb_tbe_dec_fx( move16(); FOR( i = 0; i < L_FRAME16k; i++ ) { -#ifdef BASOP_NOGLOB shaped_shb_excitation_frac[i] = shl_sat( shaped_shb_excitation[i], n ); /*Q_bwe_exc+n*/ move16(); -#else - shaped_shb_excitation_frac[i] = shl( shaped_shb_excitation[i], n ); /*Q_bwe_exc+n*/ - move16(); -#endif } curr_frame_pow = 0; @@ -3436,11 +3286,7 @@ void swb_tbe_dec_fx( ( EQ_16( st_fx->prev_coder_type, UNVOICED ) || ( st_fx->last_good == UNVOICED_CLAS ) || GT_16( hBWE_TD->tilt_swb_fec_fx, 10240 ) ) ) { L_tmp = root_a_over_b_fx( hBWE_TD->prev_swb_bwe_frame_pow_fx, curr_frame_pow_exp, curr_frame_pow, curr_frame_pow_exp, &exp ); -#ifdef BASOP_NOGLOB scale = round_fx_sat( L_shl_sat( L_tmp, sub( exp, 3 ) ) ); /*Q12*/ -#else - scale = round_fx( L_shl( L_tmp, sub( exp, 3 ) ) ); /*Q12*/ -#endif L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); @@ -3461,23 +3307,15 @@ void swb_tbe_dec_fx( L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); -#ifdef BASOP_NOGLOB temp = round_fx_sat( L_shl_sat( L_tmp, sub( exp, 3 ) ) ); /*Q12*/ -#else - temp = round_fx( L_shl( L_tmp, sub( exp, 3 ) ) ); /*Q12*/ -#endif } ELSE IF( LT_32( curr_frame_pow, L_shr( hBWE_TD->prev_swb_bwe_frame_pow_fx, 1 ) ) && ( GT_32( st_fx->enerLL_fx, L_shr( st_fx->prev_enerLL_fx, 1 ) ) || GT_32( st_fx->enerLH_fx, L_shr( st_fx->prev_enerLH_fx, 1 ) ) ) && ( EQ_16( st_fx->prev_coder_type, UNVOICED ) || ( st_fx->last_good == UNVOICED_CLAS ) || GT_16( hBWE_TD->tilt_swb_fec_fx, 10240 ) ) ) { L_tmp = root_a_over_b_fx( hBWE_TD->prev_swb_bwe_frame_pow_fx, curr_frame_pow_exp, curr_frame_pow, curr_frame_pow_exp, &exp ); -#ifdef BASOP_NOGLOB L_tmp = L_min( L_tmp, L_shl_sat( 2, sub( 31, exp ) ) ); /*31 - exp*/ -#else - L_tmp = L_min( L_tmp, L_shl( 2, ( 31 - exp ) ) ); /*31 - exp*/ -#endif - scale = round_fx( L_shl( L_tmp, sub( exp, 3 ) ) ); /*Q12*/ + scale = round_fx( L_shl( L_tmp, sub( exp, 3 ) ) ); /*Q12*/ L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); @@ -3486,25 +3324,13 @@ void swb_tbe_dec_fx( } FOR( j = 0; j < 8; j++ ) { -#ifdef BASOP_NOGLOB GainShape[2 * j] = shl_sat( mult_r( GainShape[2 * j], scale ), 3 ); -#else - GainShape[2 * j] = shl( mult_r( GainShape[2 * j], scale ), 3 ); -#endif move16(); /* 15 +12 +3-15 =15*/ -#ifdef BASOP_NOGLOB GainShape[add( 2 * j, 1 )] = shl_sat( mult_r( GainShape[add( 2 * j, 1 )], scale ), 3 ); -#else - GainShape[2 * j + 1] = shl( mult_r( GainShape[2 * j + 1], scale ), 3 ); -#endif move16(); FOR( i = 0; i < 40; i++ ) { -#ifdef BASOP_NOGLOB shaped_shb_excitation[add( i, j * 40 )] = shl_sat( mult_r( shaped_shb_excitation[add( i, j * 40 )], scale ), 3 ); -#else - shaped_shb_excitation[add( i, i_mult( j, 40 ) )] = shl( mult_r( shaped_shb_excitation[add( i, i_mult( j, 40 ) )], scale ), 3 ); -#endif move16(); /* Q_bwe_exc +12+3 -15 =Q_bwe_exc*/ } @@ -3561,11 +3387,7 @@ void swb_tbe_dec_fx( tmp = div_s( 16384, tmp ); L_tmp = L_deposit_h( tmp ); L_tmp = Isqrt_lc( L_tmp, &exp ); -#ifdef BASOP_NOGLOB st_fx->prev_ener_shb_fx = round_fx_sat( L_shl_sat( L_tmp, sub( exp, 14 ) ) ); /* Q1 */ -#else - st_fx->prev_ener_shb_fx = round_fx( L_shl( L_tmp, sub( exp, 14 ) ) ); /* Q1 */ -#endif move16(); } /* st->prev_SWB_fenv[i] = sqrt(curr_frame_pow/L_FRAME16k); */ @@ -3581,11 +3403,7 @@ void swb_tbe_dec_fx( tmp = div_s( 16384, tmp ); L_tmp = L_deposit_h( tmp ); L_tmp = Isqrt_lc( L_tmp, &exp ); -#ifdef BASOP_NOGLOB tmp = round_fx_sat( L_shl_sat( L_tmp, sub( exp, 14 ) ) ); /* Q1 */ -#else - tmp = round_fx( L_shl( L_tmp, sub( exp, 14 ) ) ); /* Q1 */ -#endif } set16_fx( st_fx->prev_SWB_fenv_fx, tmp, SWB_FENV ); /* Q1 */ @@ -4859,11 +4677,7 @@ void fb_tbe_dec_fx( { i = (Word16) get_next_indice_fx( st, 4 ); } -#ifdef BASOP_NOGLOB ratio = shl_sat( 1, i ); -#else - ratio = shl( 1, i ); -#endif } ELSE IF( EQ_16( st->extl, FB_TBE ) && st->bfi ) { @@ -4879,11 +4693,7 @@ void fb_tbe_dec_fx( /* v_add_fx( hb_synth, fb_synth, hb_synth, L_FRAME48k );*/ FOR( i = 0; i < L_FRAME48k; i++ ) { -#ifdef BASOP_NOGLOB hb_synth[i] = add_sat( hb_synth[i], fb_synth[i] ); -#else - hb_synth[i] = add( hb_synth[i], fb_synth[i] ); -#endif move16(); } return; @@ -4925,11 +4735,7 @@ void fb_tbe_dec_ivas_fx( { i = (Word16) get_next_indice_fx( st, 4 ); } -#ifdef BASOP_NOGLOB ratio = shl_sat( 1, i ); -#else - ratio = shl( 1, i ); -#endif } ELSE IF( EQ_16( st->extl, FB_TBE ) && st->bfi ) { diff --git a/lib_dec/syn_outp_fx.c b/lib_dec/syn_outp_fx.c index 0d70524bedab22da24bf6cfda428734479423843..133ff17b44e2f40ac846c88353ebfb4d97092a56 100644 --- a/lib_dec/syn_outp_fx.c +++ b/lib_dec/syn_outp_fx.c @@ -40,11 +40,7 @@ void syn_output_fx( FOR( i = 0; i < output_frame; i++ ) { L_tmp = L_deposit_h( synth[i] ); -#ifdef BASOP_NOGLOB synth_out[i] = round_fx_sat( L_shr_sat( L_tmp, tmp ) ); -#else - synth_out[i] = round_fx( L_shr( L_tmp, tmp ) ); -#endif move16(); } } @@ -86,11 +82,7 @@ void unscale_AGC( max_val = s_max( max_val, abs_s( x[i] ) ); } BASOP_SATURATE_WARNING_OFF_EVS -#ifdef BASOP_NOGLOB tmp = shl_o( 30000, Qx, &Overflow ); /* saturation can occur here */ -#else - tmp = shl( 30000, Qx ); /* saturation can occurs here */ -#endif BASOP_SATURATE_WARNING_ON_EVS frame_fac = 0; move16(); diff --git a/lib_dec/tonalMDCTconcealment.c b/lib_dec/tonalMDCTconcealment.c index c865dbe745ffc54da6b4c0908544a85ce25e5727..0ac8774500dc03c635e5f50a00772d82a7788da6 100644 --- a/lib_dec/tonalMDCTconcealment.c +++ b/lib_dec/tonalMDCTconcealment.c @@ -345,6 +345,10 @@ 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 ) ) { IF( GT_16( st->core, TCX_20_CORE ) ) @@ -377,7 +381,6 @@ void TonalMdctConceal_whiten_noise_shape_ivas_fx( noiseLevelPtr_exp = hFdCngCom->cngNoiseLevelExp; move16(); - set32_fx( whitenend_noise_shape, 0, start_idx ); FOR( Word16 j = start_idx; j < stop_idx; j++ ) { whitenend_noise_shape[j] = L_shr( *noiseLevelPtr, 3 ); diff --git a/lib_dec/tonalMDCTconcealment_fx.c b/lib_dec/tonalMDCTconcealment_fx.c index 15ce08803e3f53618cab0aee33dc4fd515293403..a4aa23e7fbf69a6ca9283e8be81993209c0c8edb 100644 --- a/lib_dec/tonalMDCTconcealment_fx.c +++ b/lib_dec/tonalMDCTconcealment_fx.c @@ -885,11 +885,7 @@ static void ivas_CalcPowerSpecAndDetectTonalComponents_fx( powerSpectrum_exp = add( powerSpectrum_exp, 3 ); FOR( i = hTonalMDCTConc->nSamplesCore; i < nSamples; i++ ) { -#ifdef BASOP_NOGLOB powerSpectrum[i] = L_shl_sat( Mpy_32_16_1( powerSpectrum[i], invScaleFactors[nBands - 1] ), invScaleFactors_exp[nBands - 1] ); // Q(31 - powerSpectrum_exp) -#else - powerSpectrum[i] = L_shl( Mpy_32_16_1( powerSpectrum[i], invScaleFactors[nBands - 1] ), invScaleFactors_exp[nBands - 1] ); -#endif move32(); } @@ -900,11 +896,7 @@ static void ivas_CalcPowerSpecAndDetectTonalComponents_fx( /* 16 bits are now enough for storing the power spectrum */ FOR( i = 0; i < nSamples; i++ ) { -#ifdef BASOP_NOGLOB hTonalMDCTConc->secondLastPowerSpectrum[i] = round_fx_o( powerSpectrum[i], &Overflow ); // Q31 - powerSpectrum_exp -#else - hTonalMDCTConc->secondLastPowerSpectrum[i] = round_fx( powerSpectrum[i] ); -#endif move32(); } @@ -1031,22 +1023,14 @@ static void CalcPowerSpecAndDetectTonalComponents( #endif FOR( i = hTonalMDCTConc->nSamplesCore; i < nSamples; i++ ) { -#ifdef BASOP_NOGLOB powerSpectrum[i] = L_shl_sat( Mpy_32_16_1( powerSpectrum[i], invScaleFactors[FDNS_NPTS - 1] ), invScaleFactors_exp[FDNS_NPTS - 1] ); // powerSpectrum_exp+ 2*invScaleFactors_exp -15 -#else - powerSpectrum[i] = L_shl( Mpy_32_16_1( powerSpectrum[i], invScaleFactors[FDNS_NPTS - 1] ), invScaleFactors_exp[FDNS_NPTS - 1] ); -#endif move32(); } /* 16 bits are now enough for storing the power spectrum */ FOR( i = 0; i < nSamples; i++ ) { -#ifdef BASOP_NOGLOB hTonalMDCTConc->secondLastPowerSpectrum[i] = round_fx_o( powerSpectrum[i], &Overflow ); // Q31-powerSpectrum_exp -#else - hTonalMDCTConc->secondLastPowerSpectrum[i] = round_fx( powerSpectrum[i] ); -#endif move32(); } @@ -1318,7 +1302,7 @@ void TonalMDCTConceal_Detect_ivas_fx( #endif nSamples = hTonalMDCTConc->nNonZeroSamples; move16(); - Copy_Scale_sig_16_32( hTonalMDCTConc->secondLastPowerSpectrum, powerSpectrum, nSamples, Q15 ); + Copy_Scale_sig_16_32_DEPREC( hTonalMDCTConc->secondLastPowerSpectrum, powerSpectrum, nSamples, Q15 ); temp_power_spectrum_q = add( Q15, sub( 15, hTonalMDCTConc->secondLastPowerSpectrum_exp ) ); IF( psychParamsCurrent == NULL ) { @@ -1444,11 +1428,7 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( inv_samples = Inv16( hTonalMDCTConc->lastBlockData.nSamples, &inv_exp ); // Q31-inv_exp tiltFactor = round_fx( BASOP_Util_fPow( L_max( L_tmp, L_deposit_h( tiltCompFactor ) ), 0, L_deposit_h( inv_samples ), inv_exp, &exp ) ); // Q15 - exp BASOP_SATURATE_WARNING_OFF_EVS /*next op may result in 32768*/ -#ifdef BASOP_NOGLOB - tiltFactor = shl_sat( tiltFactor, exp ); // Q15 -#else - tiltFactor = shl( tiltFactor, exp ); -#endif + tiltFactor = shl_sat( tiltFactor, exp ); // Q15 BASOP_SATURATE_WARNING_ON_EVS tilt = MAX16B; move16(); @@ -1521,11 +1501,7 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( num = L_shr( num, 1 ); // Q31-exp -1 exp = add( exp, 1 ); } -#ifdef BASOP_NOGLOB tmp = div_l( num, round_fx_sat( den ) ); -#else - tmp = div_l( num, round_fx( den ) ); -#endif tmp = Sqrt16( tmp, &exp ); g = mult_r( g, tmp ); // exponent of g = exp @@ -2056,11 +2032,7 @@ ELSE tmp = round_fx( BASOP_Util_fPow( L_deposit_h( tiltFactor ), 0, L_deposit_h( extract_l( L_add( L_sub( hTonalMDCTConc->pTCI->upperIndex[hTonalMDCTConc->pTCI->numIndexes - 1], hTonalMDCTConc->pTCI->lowerIndex[hTonalMDCTConc->pTCI->numIndexes - 1] ), 1 ) ) ), 15, &exp ) ); BASOP_SATURATE_WARNING_OFF_EVS /*next op may result in 32768*/ -#ifdef BASOP_NOGLOB tmp = shl_sat( tmp, exp ); -#else - tmp = shl( tmp, exp ); -#endif BASOP_SATURATE_WARNING_ON_EVS tilt = mult_r( tilt, tmp ); @@ -2485,12 +2457,8 @@ void TonalMDCTConceal_InsertNoise( move16(); inv_samples = Inv16( hTonalMDCTConc->lastBlockData.nSamples, &inv_exp ); tiltFactor = round_fx( BASOP_Util_fPow( L_max( L_tmp, L_deposit_h( tiltCompFactor ) ), 0, L_deposit_h( inv_samples ), inv_exp, &exp ) ); - BASOP_SATURATE_WARNING_OFF_EVS /*next op may result in 32768*/ -#ifdef BASOP_NOGLOB + BASOP_SATURATE_WARNING_OFF_EVS /*next op may result in 32768*/ tiltFactor = shl_sat( tiltFactor, exp ); // Q15- 2*exp -#else - tiltFactor = shl( tiltFactor, exp ); -#endif BASOP_SATURATE_WARNING_ON_EVS tilt = 32767 /*1.0f Q15*/; @@ -2679,11 +2647,7 @@ void TonalMDCTConceal_InsertNoise( tmp = round_fx( BASOP_Util_fPow( L_deposit_h( tiltFactor ), 0, L_deposit_h( (UWord16) L_add( L_sub( hTonalMDCTConc->pTCI->upperIndex[hTonalMDCTConc->pTCI->numIndexes - 1], hTonalMDCTConc->pTCI->lowerIndex[hTonalMDCTConc->pTCI->numIndexes - 1] ), 1 ) ), 15, &exp ) ); BASOP_SATURATE_WARNING_OFF_EVS /*next op may result in 32768*/ -#ifdef BASOP_NOGLOB tmp = shl_sat( tmp, exp ); // Q15 - 2*exp -#else - tmp = shl( tmp, exp ); -#endif BASOP_SATURATE_WARNING_ON_EVS tilt = mult_r( tilt, tmp ); diff --git a/lib_dec/transition_dec_fx.c b/lib_dec/transition_dec_fx.c index c7c5b5ab81a540568170bc6fa4da59957abfede2..b82378198604518d2b6ea4a15a4417d0a306a15e 100644 --- a/lib_dec/transition_dec_fx.c +++ b/lib_dec/transition_dec_fx.c @@ -789,11 +789,7 @@ static void tc_dec_fx( j = s_min( L_SUBFR, add( imp_pos, L_IMPULSE2 ) ); FOR( ; i <= j; i++ ) { -#ifdef BASOP_NOGLOB exc[i + i_subfr] = round_fx_o( L_shl_o( L_mult_o( pt_shape[i], gain_trans, &Overflow ), sc, &Overflow ), &Overflow ); /* (Qx * Q14 ) */ -#else - exc[i + i_subfr] = round_fx( L_shl( L_mult( pt_shape[i], gain_trans ), sc ) ); /* (Qx * Q14 ) */ -#endif move16(); } FOR( ; i < L_SUBFR; i++ ) diff --git a/lib_dec/updt_dec_fx.c b/lib_dec/updt_dec_fx.c index a7341ddc9f79a13c1b32f605697c32edfe1a216d..67621c442f24536792690208ac8915c5649d0846 100644 --- a/lib_dec/updt_dec_fx.c +++ b/lib_dec/updt_dec_fx.c @@ -401,11 +401,7 @@ void updt_bw_switching_fx( test(); IF( EQ_32( st_fx->output_Fs, 32000 ) && EQ_16( st_fx->bwidth, SWB ) ) { -#ifdef BASOP_NOGLOB st_fx->tilt_swb_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( synth, Qpost, L_FRAME32k ), 3 ) ); // Q27 - 16 = Q11 -#else - st_fx->tilt_swb_fx = round_fx( L_shl( calc_tilt_bwe_fx( synth, Qpost, L_FRAME32k ), 3 ) ); -#endif } st_fx->prev_enerLH_fx = st_fx->enerLH_fx; // enerLH_fx_Q @@ -775,11 +771,7 @@ static void ivas_updt_bw_switching_fx( test(); IF( EQ_32( st_fx->output_Fs, 32000 ) && EQ_16( st_fx->bwidth, SWB ) ) { -#ifdef BASOP_NOGLOB st_fx->tilt_swb_fx = ivas_calc_tilt_bwe_fx( synth, Qpost, L_FRAME32k ); -#else - st_fx->tilt_swb_fx = round_fx( L_shl( calc_tilt_bwe_fx( synth, Qpost, L_FRAME32k ), 3 ) ); -#endif } st_fx->prev_enerLH_fx = st_fx->enerLH_fx; // enerLH_fx_Q diff --git a/lib_dec/voiced_dec_fx.c b/lib_dec/voiced_dec_fx.c index d7ec44e9267ac3e488f3e3ba8fb531c567f21f8e..c937a3b2b6c032bb139c98919a65ae6af4f29f9f 100644 --- a/lib_dec/voiced_dec_fx.c +++ b/lib_dec/voiced_dec_fx.c @@ -242,30 +242,20 @@ ivas_error ppp_voiced_decoder_fx( /* Compensate for Q factor of energy to get log10(lag*eng) */ - Ltemp = log10_fx( Ltemp ); /* Ltemp=10log10(eng), Q23 */ -#ifdef BASOP_NOGLOB + Ltemp = log10_fx( Ltemp ); /* Ltemp=10log10(eng), Q23 */ Ltemp = L_add_sat( L_sub_sat( Ltemp, Ltemp_q ), logLag ); /* Ltemp=10*log10(lag*eng), Q23 */ hSC_VBR->lastLgainD_fx = round_fx_sat( L_shl_sat( (Word32) Mpy_32_16( extract_h( Ltemp ), extract_l( Ltemp ), 0x6666 ), 1 ) ); /* Q11 */ move16(); -#else - Ltemp = L_add( L_sub( Ltemp, Ltemp_q ), logLag ); /* Ltemp=10*log10(lag*eng), Q23 */ - hSC_VBR->lastLgainD_fx = round_fx( L_shl( (Word32) Mpy_32_16( extract_h( Ltemp ), extract_l( Ltemp ), 0x6666 ), 1 ) ); /* Q11 */ -#endif /* Process high band */ Ltemp = DTFS_setEngyHarm_fx( 2828, upper_cut_off_freq_of_interest, 2828, upper_cut_off_freq, 1, 0, &Qh, TMPDTFS_FX ); - Ltemp = log10_fx( Ltemp ); // Q23 -#ifdef BASOP_NOGLOB + Ltemp = log10_fx( Ltemp ); // Q23 Ltemp = L_add_sat( L_sub_sat( Ltemp, Ltemp_q ), logLag ); /* Ltemp=10*log10(lag*eng), Q23 */ hSC_VBR->lastHgainD_fx = round_fx_sat( L_shl_sat( (Word32) Mpy_32_16( extract_h( Ltemp ), extract_l( Ltemp ), 0x6666 ), 1 ) ); /* Q11 */ move16(); -#else - Ltemp = L_add( L_sub( Ltemp, Ltemp_q ), logLag ); /* Ltemp=10*log10(lag*eng), Q23 */ - hSC_VBR->lastHgainD_fx = round_fx( L_shl( (Word32) Mpy_32_16( extract_h( Ltemp ), extract_l( Ltemp ), 0x6666 ), 1 ) ); /* Q11 */ -#endif /* Need to unify the Q factors of both bands */ @@ -324,13 +314,8 @@ ivas_error ppp_voiced_decoder_fx( /* temp32_fx = (Word32)divide_dp((Word40)819200,(Word40)L_shl((Word32)CURRP_Q_D_FX->lag_fx,6),-23,1);//Q6 */ exp = norm_s( CURRP_Q_D_FX->lag_fx ); tmp = div_s( shl( 1, sub( 14, exp ) ), CURRP_Q_D_FX->lag_fx ); /*29-exp */ -#ifdef BASOP_NOGLOB L_tmp = L_shl_sat( L_mult0( tmp, 12800 ), sub( exp, 7 ) ); temp32_fx = round_fx_sat( L_tmp ); -#else - L_tmp = L_shl( L_mult0( tmp, 12800 ), sub( exp, 7 ) ); - temp32_fx = round_fx( L_tmp ); -#endif diff = round_fx( L_shl( temp32_fx, 16 - 6 ) ); /*Q0 */ CURRP_Q_D_FX->nH_fx = find_rem( upper_cut_off_freq, diff, &rem_fx ); /*Q0 */ diff --git a/lib_dec/waveadjust_fec_dec_fx.c b/lib_dec/waveadjust_fec_dec_fx.c index 0f7a45eb04d4cc5be0c54b7bf25ce2bbac0cb85e..80241a24c9f79d528f9c4e7004e9ab7a54348e6a 100644 --- a/lib_dec/waveadjust_fec_dec_fx.c +++ b/lib_dec/waveadjust_fec_dec_fx.c @@ -476,13 +476,8 @@ void pitch_modify_x( Word16 *s_LP /*Qx*/, Word16 *voicing /*Q15*/, Word16 *pitch eng1 = L_mult0( eng1_w, eng2_w ); norm = norm_l( eng1 ); -#ifdef BASOP_NOGLOB eng1_w = extract_h( L_shl_sat( eng1, norm ) ); eng2_w = extract_h( L_shl_sat( eng3, norm ) ); -#else - eng1_w = extract_h( L_shl( eng1, norm ) ); - eng2_w = extract_h( L_shl( eng3, norm ) ); -#endif IF( GE_32( eng3, eng1 ) ) { @@ -1246,32 +1241,18 @@ static void add_noise( Word16 *const sbuf, /*Qsbuf*/ IF( !firstFrame ) { -#ifdef BASOP_NOGLOB temp_OUT = sub_sat( noise_seg[0], mult( ( *outx_new_n1 ), 22282 /* 0.68 Q15 */ ) ); sbuf[0] = add_sat( sbuf[0], mult( ( temp_OUT ), *gain ) ); move16(); *gain = mac_r_sat( L_mult_sat( 32439 /* 0.99 Q15 */, *gain ), 328 /* 0.01 Q15 */, *gain_n ); -#else - temp_OUT = sub( noise_seg[0], mult( ( *outx_new_n1 ), 22282 /* 0.68 Q15 */ ) ); - sbuf[0] = add( sbuf[0], mult( ( temp_OUT ), *gain ) ); - move16(); - *gain = mac_r( L_mult( 32439 /* 0.99 Q15 */, *gain ), 328 /* 0.01 Q15 */, *gain_n ); -#endif } FOR( i = 1; i < Len; i++ ) { -#ifdef BASOP_NOGLOB temp_OUT = sub_sat( noise_seg[i], mult( ( noise_seg[i - 1] ), 22282 /* 0.68 Q15 */ ) ); sbuf[i] = add_sat( sbuf[i], mult( ( temp_OUT ), *gain ) ); move16(); *gain = mac_r_sat( L_mult( 32439 /* 0.99 Q15 */, *gain ), 328 /* 0.01 Q15 */, *gain_n ); -#else - temp_OUT = sub( noise_seg[i], mult( ( noise_seg[i - 1] ), 22282 /* 0.68 Q15 */ ) ); - sbuf[i] = add( sbuf[i], mult( ( temp_OUT ), *gain ) ); - move16(); - *gain = mac_r( L_mult( 32439 /* 0.99 Q15 */, *gain ), 328 /* 0.01 Q15 */, *gain_n ); -#endif } *outx_new_n1 = noise_seg[i - 1]; /*q0*/ @@ -1387,11 +1368,7 @@ static Word16 waveform_adj_fix( Word16 *overlapbuf, /*Qoverlapbuf*/ } FOR( i = 0; i < pitch125; i++ ) { -#ifdef BASOP_NOGLOB pitch125_data[i] = round_fx_sat( L_shr_sat( L_add_sat( ( L_mult( p_tmp[i], 20972 ) ), L_mac_sat( L_mult( p_tmp[i - 1], 5898 ), p_tmp[i + 1], 5898 ) ), s16MaxCoefNorm ) ); -#else - pitch125_data[i] = round_fx( L_shr( L_add( ( L_mult( p_tmp[i], 20972 ) ), L_mac( L_mult( p_tmp[i - 1], 5898 ), p_tmp[i + 1], 5898 ) ), s16MaxCoefNorm ) ); -#endif move16(); } } @@ -1553,26 +1530,14 @@ void waveform_adj2_fix( Word16 *overlapbuf, /*Qoverlapbuf*/ ratio = extract_l( L_shr( L_mult( i, ptable ), tablescale ) ); dat = shl( sbuf[i], s16MaxCoefNorm ); temp_OUT = mult( *recovery_gain, sub( 32767, ratio ) ); -#ifdef BASOP_NOGLOB outx_new[i] = round_fx_sat( L_add_sat( L_shr_sat( L_mult( temp_OUT, dat ), sub( s16MaxCoefNorm, 1 ) ), L_shr_sat( L_mult( shl( outx_new[i], s16MaxCoefNorm2 ), ratio ), s16MaxCoefNorm2 ) ) ); -#else - outx_new[i] = round_fx( L_add( L_shr( L_mult( temp_OUT, dat ), sub( s16MaxCoefNorm, 1 ) ), L_shr( L_mult( shl( outx_new[i], s16MaxCoefNorm2 ), ratio ), s16MaxCoefNorm2 ) ) ); -#endif move16(); -#ifdef BASOP_NOGLOB *recovery_gain = sub_sat( *recovery_gain, shr_r( step_concealgain, 1 ) ); /* q14 */ -#else - *recovery_gain = sub( *recovery_gain, shr_r( step_concealgain, 1 ) ); /* q14 */ -#endif } FOR( i = gain_zero_start; i < Framesize; i++ ) { ratio = extract_l( L_shr( L_mult( i, ptable ), tablescale ) ); -#ifdef BASOP_NOGLOB outx_new[i] = round_fx_sat( L_shr_sat( L_mult( shl( outx_new[i], s16MaxCoefNorm2 ), ratio ), s16MaxCoefNorm2 ) ); -#else - outx_new[i] = round_fx( L_shr( L_mult( shl( outx_new[i], s16MaxCoefNorm2 ), ratio ), s16MaxCoefNorm2 ) ); -#endif move16(); } diff --git a/lib_enc/ACcontextMapping_enc_fx.c b/lib_enc/ACcontextMapping_enc_fx.c index bae26790190447ebef64e2a6b592056991fff8d6..08baa4f3d23dcbd61f5d030b675c9afdaed50180 100644 --- a/lib_enc/ACcontextMapping_enc_fx.c +++ b/lib_enc/ACcontextMapping_enc_fx.c @@ -841,7 +841,7 @@ void RCcontextMapping_encode2_no_mem_s17_LCS_fx( /*Start Encoding*/ /* Initialize range encoder */ - rc_uni_enc_init( &rc_st_enc ); + rc_uni_enc_init_fx( &rc_st_enc ); /*Main Loop through the 2-tuples*/ b1_i = -1; @@ -909,7 +909,7 @@ void RCcontextMapping_encode2_no_mem_s17_LCS_fx( { pki = ari_lookup_s17_LC[t + ( ( lev1 + 1 ) << ( NBITS_CONTEXT + NBITS_RATEQ ) )]; /* Q0 */ move16(); - rc_uni_enc_encode_symbol_fastS( &rc_st_enc, VAL_ESC, cum_freq_ari_pk_s17_LC_ext[pki], sym_freq_ari_pk_s17_LC_ext[pki], 14 ); /* Encode ESC symbol */ + rc_uni_enc_encode_symbol_fastS_fx( &rc_st_enc, VAL_ESC, cum_freq_ari_pk_s17_LC_ext[pki], sym_freq_ari_pk_s17_LC_ext[pki], 14 ); /* Encode ESC symbol */ *lsbs_bits-- = s_and( a1, 1 ); *lsbs_bits-- = s_and( b1, 1 ); @@ -927,7 +927,7 @@ void RCcontextMapping_encode2_no_mem_s17_LCS_fx( pki = ari_lookup_s17_LC[t + ( ( lev1 + 1 ) << ( NBITS_CONTEXT + NBITS_RATEQ ) )]; /* Q0 */ move16(); - rc_uni_enc_encode_symbol_fastS( &rc_st_enc, a1 + A_THRES * b1, cum_freq_ari_pk_s17_LC_ext[pki], sym_freq_ari_pk_s17_LC_ext[pki], 14 ); /* Encode MSB symbol */ + rc_uni_enc_encode_symbol_fastS_fx( &rc_st_enc, a1 + A_THRES * b1, cum_freq_ari_pk_s17_LC_ext[pki], sym_freq_ari_pk_s17_LC_ext[pki], 14 ); /* Encode MSB symbol */ /*Confirm that there is no overflow, i.e. bit-budget has not exceeded */ @@ -1009,7 +1009,7 @@ void RCcontextMapping_encode2_no_mem_s17_LCS_fx( /*Start Encoding*/ /* Initialize range encoder */ - rc_uni_enc_init( &rc_st_enc ); + rc_uni_enc_init_fx( &rc_st_enc ); /*Main Loop through the 2-tuples*/ FOR( k = 0; k < lastnz; k += 2 ) @@ -1064,7 +1064,7 @@ void RCcontextMapping_encode2_no_mem_s17_LCS_fx( { pki = ari_lookup_s17_LC[t + ( ( rateQ ) << NBITS_CONTEXT ) + ( esc_nb << ( NBITS_CONTEXT + NBITS_RATEQ ) )]; move16(); - rc_uni_enc_encode_symbol_fastS( &rc_st_enc, VAL_ESC, cum_freq_ari_pk_s17_LC_ext[pki], sym_freq_ari_pk_s17_LC_ext[pki], 14 ); /* Encode ESC symbol */ + rc_uni_enc_encode_symbol_fastS_fx( &rc_st_enc, VAL_ESC, cum_freq_ari_pk_s17_LC_ext[pki], sym_freq_ari_pk_s17_LC_ext[pki], 14 ); /* Encode ESC symbol */ *lsbs_bits-- = s_and( a1, 1 ); *lsbs_bits-- = s_and( b1, 1 ); @@ -1082,8 +1082,9 @@ void RCcontextMapping_encode2_no_mem_s17_LCS_fx( } move16(); - pki = ari_lookup_s17_LC[t + ( ( rateQ ) << NBITS_CONTEXT ) + ( esc_nb << ( NBITS_CONTEXT + NBITS_RATEQ ) )]; /* Q0 */ - rc_uni_enc_encode_symbol_fastS( &rc_st_enc, a1 + A_THRES * b1, cum_freq_ari_pk_s17_LC_ext[pki], sym_freq_ari_pk_s17_LC_ext[pki], 14 ); /* Encode MSB symbol */ + + pki = ari_lookup_s17_LC[t + ( ( rateQ ) << NBITS_CONTEXT ) + ( esc_nb << ( NBITS_CONTEXT + NBITS_RATEQ ) )]; /* Q0 */ + rc_uni_enc_encode_symbol_fastS_fx( &rc_st_enc, a1 + A_THRES * b1, cum_freq_ari_pk_s17_LC_ext[pki], sym_freq_ari_pk_s17_LC_ext[pki], 14 ); /* Encode MSB symbol */ /*Confirm that there is no overflow, i.e. bit-budget has not exceeded */ @@ -1105,8 +1106,8 @@ void RCcontextMapping_encode2_no_mem_s17_LCS_fx( } /* Finish range encoder */ - rc_tot_bits = rc_uni_enc_finish( &rc_st_enc ); /* No. of bits consumed by range coder Q0*/ - bp = add( rc_tot_bits, nbbits_ntuples ); /* Update bitstream pointer Q0*/ + rc_tot_bits = rc_uni_enc_finish_fx( &rc_st_enc ); /* No. of bits consumed by range coder Q0*/ + bp = add( rc_tot_bits, nbbits_ntuples ); /* Update bitstream pointer Q0*/ /* Cross-check that there is no overflow */ diff --git a/lib_enc/FEC_enc_fx.c b/lib_enc/FEC_enc_fx.c index 20dced8d7f939e6fed40a47960b823873307fd2e..9106e23e70eeb8e67b6eaa8cd1be674973598811 100644 --- a/lib_enc/FEC_enc_fx.c +++ b/lib_enc/FEC_enc_fx.c @@ -367,7 +367,7 @@ void FEC_encode_ivas_fx( /* frame energy (maximum energy per pitch period for voiced frames or mean energy per sample over 2nd halframe for unvoiced frames) */ /*frame_ener( L_frame, clas, synth, fpit[(L_frame>>6)-1], &enr_q, 0 );*/ Word32 synth32[L_FRAME16k]; - Copy_Scale_sig_16_32( synth, synth32, L_FRAME16k, 0 ); /* Qsynth */ + Copy_Scale_sig_16_32_DEPREC( synth, synth32, L_FRAME16k, 0 ); /* Qsynth */ fer_energy_fx( L_frame, clas, synth32, Q_synth, shr_r( fpit[( L_frame >> 6 ) - 1], 6 ), &enr_q, L_frame ); exp_enrq = sub( 31, shl( Q_synth, 1 ) ); diff --git a/lib_enc/SNR_calc_fx.c b/lib_enc/SNR_calc_fx.c index 1213a6b320fbd2ea3ee38d2096fb8d866ecb7b89..f44530c849cf8108fea348eef9dc8eb888cf2795 100644 --- a/lib_enc/SNR_calc_fx.c +++ b/lib_enc/SNR_calc_fx.c @@ -325,11 +325,7 @@ void snr_calc( } *tsnr = VAD_Log2( tmp, minscale2 ); move32(); -#ifdef BASOP_NOGLOB *tsnr = L_add_sat( *tsnr, MUL_F( *tsnr, 6226 ) ); /* *tsnr *= 1.2; Q25*/ -#else - *tsnr = L_add( *tsnr, MUL_F( *tsnr, 6226 ) ); /* *tsnr *= 1.2; */ -#endif move32(); } ELSE diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index 55d440912ec0d92fa4e384fcfe6e1a91b8a70979..a294d12da8764c3177b6097a5d046fa52f84734c 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -156,7 +156,7 @@ ivas_error acelp_core_enc_fx( st_fx->Nb_ACELP_frames = 0; move16(); } - st_fx->Nb_ACELP_frames = add( st_fx->Nb_ACELP_frames, 1 ); // Q0 + st_fx->Nb_ACELP_frames = add_sat( st_fx->Nb_ACELP_frames, 1 ); // Q0 move16(); int_fs_fx = INT_FS_16k_FX; @@ -402,7 +402,11 @@ 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 ); } @@ -538,7 +542,11 @@ 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 ); } @@ -605,7 +613,11 @@ 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 */ @@ -867,6 +879,7 @@ ivas_error acelp_core_enc_ivas_fx( 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]; @@ -966,7 +979,7 @@ ivas_error acelp_core_enc_ivas_fx( st->Nb_ACELP_frames = 0; move16(); } - st->Nb_ACELP_frames = add( st->Nb_ACELP_frames, 1 ); + st->Nb_ACELP_frames = add_sat( st->Nb_ACELP_frames, 1 ); move16(); IF( EQ_16( st->L_frame, L_FRAME ) ) @@ -1101,15 +1114,6 @@ ivas_error acelp_core_enc_ivas_fx( /* update Aw[] coefficients */ weight_a_subfr_fx( shr( st->L_frame, 6 ), A, Aw, st->gamma, M ); } - IF( st->hLPDmem ) - { - st->hLPDmem->q_mem_syn = sub( Q_new, 1 ); - move16(); - st->hLPDmem->q_lpd_old_exc = Q_new; - move16(); - st->hLPDmem->q_lpd_syn = Q_new; - move16(); - } test(); test(); @@ -1275,7 +1279,11 @@ 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 } /*-----------------------------------------------------------------* @@ -1369,6 +1377,7 @@ ivas_error acelp_core_enc_ivas_fx( move16(); PREEMPH_FX( hLPDmem->old_exc, st->preemph_fac, st->L_frame, &tmpF_fx ); Copy( hLPDmem->old_exc + sub( st->L_frame, M ), hLPDmem->mem_syn, M ); /* Q_new */ + Scale_sig( st->hLPDmem->mem_syn, M, sub( st->hLPDmem->q_mem_syn, Q_new ) ); Residu3_fx( Aq, hLPDmem->old_exc, old_exc_fx, st->L_frame, 0 ); } @@ -1398,6 +1407,12 @@ ivas_error acelp_core_enc_ivas_fx( v_multc_fixed_16_16( res_fx, att_fx, res_fx, st->L_frame ); } + // Scaling Aq and Aw to Q12 + FOR( Word16 k = 0; k < NB_SUBFR16k; k++ ) + { + Scale_sig( &Aq[( M + 1 ) * k], M + 1, sub( norm_s( Aq[( M + 1 ) * k] ), 2 ) ); + Scale_sig( &Aw[( M + 1 ) * k], M + 1, sub( norm_s( Aw[( M + 1 ) * k] ), 2 ) ); + } /*-----------------------------------------------------------------* * Determine TC subframe classification *-----------------------------------------------------------------*/ @@ -1406,7 +1421,11 @@ 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 } /*---------------------------------------------------------------* @@ -1463,8 +1482,13 @@ ivas_error acelp_core_enc_ivas_fx( { /* restore memories of LSF quantizer and synthesis filter */ 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 ); @@ -1629,7 +1653,11 @@ 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 */ - Copy_Scale_sig_16_32( 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 +#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 b09f2396642259fa5a12b049819003c2491b40e4..47c735a856876adf49d14f4a286e4a2dfded2bf6 100644 --- a/lib_enc/acelp_core_switch_enc_fx.c +++ b/lib_enc/acelp_core_switch_enc_fx.c @@ -148,8 +148,13 @@ void acelp_core_switch_enc_fx( /*----------------------------------------------------------------* * Excitation encoding *----------------------------------------------------------------*/ + 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 ); @@ -271,8 +276,13 @@ void acelp_core_switch_enc_ivas_fx( /*----------------------------------------------------------------* * Excitation encoding *----------------------------------------------------------------*/ + 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 ); @@ -492,17 +502,10 @@ static void encod_gen_voic_core_switch_fx( { /* code in Q9, gain_pit in Q14 */ L_tmp = L_mult( gcode16, code[i] ); /* Q10 */ -#ifdef BASOP_NOGLOB - L_tmp = L_shl_sat( L_tmp, 5 ); /* Q15 */ + L_tmp = L_shl_sat( L_tmp, 5 ); /* Q15 */ L_tmp = L_mac_sat( L_tmp, exc[i], gain_pit ); L_tmp = L_shl_sat( L_tmp, 1 ); /* saturation can occur here */ exc[i] = round_fx_sat( L_tmp ); /* Q_exc */ -#else - L_tmp = L_shl( L_tmp, 5 ); - L_tmp = L_mac( L_tmp, exc[i], gain_pit ); - L_tmp = L_shl( L_tmp, 1 ); /* saturation can occur here */ - exc[i] = round_fx( L_tmp ); -#endif } /* write reserved bits */ @@ -519,11 +522,7 @@ static void encod_gen_voic_core_switch_fx( FOR( i = L_SUBFR; i < 2 * L_SUBFR; i++ ) { -#ifdef BASOP_NOGLOB exc[i] = round_fx_sat( L_shl_sat( L_mult_sat( exc[i], gain_pit ), 1 ) ); /* Q_exc */ -#else - exc[i] = round_fx( L_shl( L_mult( exc[i], gain_pit ), 1 ) ); -#endif } return; @@ -712,17 +711,10 @@ static void encod_gen_voic_core_switch_ivas_fx( { /* code in Q9, gain_pit in Q14 */ L_tmp = L_mult( gcode16, code[i] ); /* Q10 */ -#ifdef BASOP_NOGLOB - L_tmp = L_shl_sat( L_tmp, 5 ); /* Q15 */ + L_tmp = L_shl_sat( L_tmp, 5 ); /* Q15 */ L_tmp = L_mac_sat( L_tmp, exc[i], gain_pit ); L_tmp = L_shl_sat( L_tmp, 1 ); /* saturation can occur here */ exc[i] = round_fx_sat( L_tmp ); /* Q_exc */ -#else - L_tmp = L_shl( L_tmp, 5 ); - L_tmp = L_mac( L_tmp, exc[i], gain_pit ); - L_tmp = L_shl( L_tmp, 1 ); /* saturation can occur here */ - exc[i] = round_fx( L_tmp ); -#endif move16(); } @@ -740,11 +732,7 @@ static void encod_gen_voic_core_switch_ivas_fx( FOR( i = L_SUBFR; i < 2 * L_SUBFR; i++ ) { -#ifdef BASOP_NOGLOB exc[i] = round_fx_sat( L_shl_sat( L_mult_sat( exc[i], gain_pit ), 1 ) ); /* Q_exc */ -#else - exc[i] = round_fx( L_shl( L_mult( exc[i], gain_pit ), 1 ) ); -#endif move16(); } @@ -897,11 +885,7 @@ static void bwe_switch_enc_fx( L_tmp1 = L_mult( tmp, E2_fx ); /*30-q_tmp1+q_tmp2 */ q_tmp2 = sub( q_tmp1, q_tmp2 ); /*30-q_tmp2 */ L_tmp1 = L_shl( L_tmp1, sub( q_tmp2, 24 ) ); -#ifdef BASOP_NOGLOB - gain_fx = round_fx_o( Isqrt( L_tmp1 ), &Overflow ); /*Q12 */ -#else - gain_fx = round_fx( Isqrt( L_tmp1 ) ); /*Q12 */ -#endif + 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 ); @@ -1044,11 +1028,7 @@ static void bwe_switch_enc_ivas_fx( L_tmp1 = L_mult( tmp, E2_fx ); /*30-q_tmp1+q_tmp2 */ q_tmp2 = sub( q_tmp1, q_tmp2 ); /*30-q_tmp2 */ L_tmp1 = L_shl( L_tmp1, sub( q_tmp2, 24 ) ); -#ifdef BASOP_NOGLOB gain_fx = round_fx_o( Isqrt( L_tmp1 ), &Overflow ); /*Q12 */ -#else - gain_fx = round_fx( Isqrt( L_tmp1 ) ); /*Q12 */ -#endif ind1_fx = usquant_fx( gain_fx, &gain_fx, shr( MINVALUEOFFIRSTGAIN_FX, 1 ), shr( DELTAOFFIRSTGAIN_FX, 4 ), ( 1 << NOOFGAINBITS1 ) ); push_indice( hBstr, IND_CORE_SWITCHING_AUDIO_GAIN, ind1_fx, NOOFGAINBITS1 ); @@ -1084,11 +1064,7 @@ static Word16 dotprod_satcont( move16(); FOR( i = 0; i < len; i += delta ) { -#ifdef BASOP_NOGLOB /* Critical Overflow*/ L_tmp = L_mac0_o( L_tmp, tmp_tabx[i], tmp_taby[i], &Overflow ); /*Q(qx+qy-shift) */ -#else /* BASOP_NOGLOB */ - L_tmp = L_mac0( L_tmp, tmp_tabx[i], tmp_taby[i] ); /*Q(qx+qy-shift) */ -#endif } IF( Overflow != 0 ) diff --git a/lib_enc/acelp_enc_util_fx.c b/lib_enc/acelp_enc_util_fx.c index 9992ce6ad1a3b10d6524f2e4219b29da9238b935..181583e91d23686fd8a753128ec344665e4e27a2 100644 --- a/lib_enc/acelp_enc_util_fx.c +++ b/lib_enc/acelp_enc_util_fx.c @@ -77,7 +77,6 @@ Word16 E_ACELP_toeplitz_mul_fx( L_maxloc = L_shr( L_maxloc, 2 ); /* Do not warn saturation of L_tot, since its for headroom estimation. */ BASOP_SATURATE_WARNING_OFF_EVS -#ifdef BASOP_NOGLOB L_tot = L_add_sat( L_tot, L_maxloc ); /* +max/4 */ L_maxloc = L_shr( L_maxloc, 1 ); L_tot = L_add_sat( L_tot, L_maxloc ); /* +max/8 */ @@ -90,20 +89,6 @@ Word16 E_ACELP_toeplitz_mul_fx( { L_tot = L_add_sat( L_tot, L_maxloc ); /* +max/16 */ } -#else - L_tot = L_add( L_tot, L_maxloc ); /* +max/4 */ - L_maxloc = L_shr( L_maxloc, 1 ); - L_tot = L_add( L_tot, L_maxloc ); /* +max/8 */ - if ( highrate ) - { - L_tot = L_add( L_tot, L_maxloc ); /* +max/8 */ - } - L_maxloc = L_shr( L_maxloc, 1 ); - if ( highrate ) - { - L_tot = L_add( L_tot, L_maxloc ); /* +max/16 */ - } -#endif BASOP_SATURATE_WARNING_ON_EVS } @@ -189,12 +174,8 @@ void E_ACELP_conv( /*cn2[k]-=cn2[i]*h2[k-i];*/ L_tmp_64 = W_msu0_16_16( L_tmp_64, cn2[i], h2[k - i] ); /*h2 4Q11*/ } - L_tmp = W_sat_l( L_tmp_64 ); /* 4Q11 */ -#ifdef BASOP_NOGLOB + L_tmp = W_sat_l( L_tmp_64 ); /* 4Q11 */ cn2[k] = round_fx_o( L_shl_o( L_tmp, 5, &Overflow ), &Overflow ); /* Q0 */ -#else - cn2[k] = round_fx( L_shl( L_tmp, 5 ) ); -#endif } } @@ -219,12 +200,8 @@ void E_ACELP_conv_ivas_fx( /*cn2[k]-=cn2[i]*h2[k-i];*/ L_tmp_64 = W_msu0_16_16( L_tmp_64, cn2[i], h2[k - i] ); /*h2 4Q11*/ } - L_tmp = W_sat_l( L_tmp_64 ); /* 4Q11 */ -#ifdef BASOP_NOGLOB + L_tmp = W_sat_l( L_tmp_64 ); /* 4Q11 */ cn2[k] = round_fx_o( L_shl_o( L_tmp, 5, &Overflow ), &Overflow ); /* Q0*/ -#else - cn2[k] = round_fx( L_shl( L_tmp, 5 ) ); -#endif move16(); } } diff --git a/lib_enc/amr_wb_enc_fx.c b/lib_enc/amr_wb_enc_fx.c index 69c356b5ddb3e9055f0384bf43cdc91174a83ae6..d5bbfab29888b70eed940eb118b5ec21c260fc27 100644 --- a/lib_enc/amr_wb_enc_fx.c +++ b/lib_enc/amr_wb_enc_fx.c @@ -367,12 +367,8 @@ void amr_wb_enc_fx( { lp_bckr = Mean32( hNoiseEst->bckr_fx + 1, 9 ); /* q_bckr */ } -#ifdef BASOP_NOGLOB hp_bckr = L_shr( L_add_sat( hNoiseEst->bckr_fx[st->max_band - 1], hNoiseEst->bckr_fx[st->max_band] ), 1 ); /* q_bckr */ -#else - hp_bckr = L_shr( L_add( hNoiseEst->bckr_fx[st->max_band - 1], hNoiseEst->bckr_fx[st->max_band] ), 1 ); -#endif - if ( hp_bckr == 0 ) /* Avoid division by zero. */ + if ( hp_bckr == 0 ) /* Avoid division by zero. */ { hp_bckr = L_deposit_l( 1 ); } diff --git a/lib_enc/analy_sp_fx.c b/lib_enc/analy_sp_fx.c index 594bcfbabaa51d6368676e33ad6a9d94287873ab..c0d1a8bcae8997c2e8e67c3ac7cb7464efad5dcc 100644 --- a/lib_enc/analy_sp_fx.c +++ b/lib_enc/analy_sp_fx.c @@ -476,6 +476,8 @@ void ivas_analy_sp_fx( Word32 Ltmp; Word16 *pt_fft; Word16 exp, tmp; + Word16 resultant_q; + Word16 exp2; Word64 LEtot; LEtot = 0; move64(); @@ -508,9 +510,7 @@ void ivas_analy_sp_fx( } ELSE { - Word16 scale = norm_arr( speech + 3 * ( L_SUBFR / 2 ) - L_FFT / 2, L_FFT + 4 * ( L_SUBFR / 2 ) ); - scale = sub( scale, LOG2_L_FFT ); // guard_bits - *q_fft_buff = add( Q_new, scale ); + Word16 scale = 0; move16(); FOR( i_subfr = 0; i_subfr <= 1; i_subfr++ ) @@ -541,11 +541,25 @@ void ivas_analy_sp_fx( move16(); } - scale_sig( pt_fft, L_FFT, scale ); - /* compute the spectrum */ - fft_rel_fx( pt_fft, L_FFT, LOG2_L_FFT ); - + 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 + move16(); + IF( EQ_16( i_subfr, 1 ) ) + { + Word16 new_q_lf_E = add( shl( *q_fft_buff, 1 ), 14 ); + Word16 new_q_bands = new_q_lf_E; + IF( GT_16( new_q_bands, 39 ) ) + { + new_q_bands = 39; + move16(); + } + scale_sig32( fr_bands, NB_BANDS, sub( new_q_bands, *q_fr_bands ) ); + scale_sig32( lf_E, VOIC_BINS, sub( new_q_lf_E, *q_lf_E ) ); + LEtot = W_shl( LEtot, sub( new_q_bands, *q_fr_bands ) ); + scale_sig32( Bin_E, L_FFT / 2, sub( new_q_lf_E, *q_lf_E ) ); + scale_sig32( band_energies, NB_BANDS, sub( new_q_bands, *q_fr_bands ) ); + } /* find energy per critical band */ ivas_find_enr( pt_fft, *q_fft_buff, pt_bands, q_fr_bands, lf_E + i_subfr * VOIC_BINS, q_lf_E, &LEtot, min_band, max_band, &Bin_E[i_subfr * L_FFT / 2], BIN, band_energies + i_subfr * NB_BANDS ); @@ -679,16 +693,12 @@ void ivas_analy_sp_fx( } exp = L_norm_arr( Bin_E, L_FFT / 2 ); - IF( GE_16( exp, sub( *q_Bin_E, Q22 ) ) ) - { - scale_sig32( Bin_E, L_FFT / 2, sub( *q_Bin_E, Q22 ) ); // *q_Bin_E - } - ELSE - { - scale_sig32( Bin_E + L_FFT / 2, L_FFT / 2, sub( Q22, *q_Bin_E ) ); // Q22 - *q_Bin_E = Q22; - move16(); - } + exp2 = L_norm_arr( Bin_E + L_FFT / 2, L_FFT / 2 ); + resultant_q = s_min( Q22, s_min( add( *q_Bin_E, exp2 ), add( exp, Q22 ) ) ); // calculating resultant q after scaling + scale_sig32( Bin_E, L_FFT / 2, sub( resultant_q, Q22 ) ); // Q22=>resultant_q + scale_sig32( Bin_E + L_FFT / 2, L_FFT / 2, sub( resultant_q, *q_Bin_E ) ); // q_Bin_E=>resultant_q + *q_Bin_E = resultant_q; + move16(); return; } @@ -952,12 +962,8 @@ static void find_enr( /* *ptE *= 4.0 / (L_FFT*L_FFT) */ /* normalization - corresponds to FFT normalization by 2/L_FFT */ - BASOP_SATURATE_WARNING_OFF_EVS; /* saturation seems to have no effect (tested by simulation) */ -#ifdef BASOP_NOGLOB + BASOP_SATURATE_WARNING_OFF_EVS; /* saturation seems to have no effect (tested by simulation) */ *ptE = L_shl_o( Ltmp, diff_scaleM2, &Overflow ); /* Q_new + QSCALE - 2 */ -#else /* BASOP_NOGLOB */ - *ptE = L_shl( Ltmp, diff_scaleM2 ); -#endif /* BASOP_NOGLOB */ move32(); /* scaled by Q_new + QSCALE - 2 */ BASOP_SATURATE_WARNING_ON_EVS; /*band[i] += *ptE++;*/ @@ -982,12 +988,8 @@ static void find_enr( exp_band = sub( exp_band, shift_to_norm ); exp_band = sub( diff_scaleP1, exp_band ); - BASOP_SATURATE_WARNING_OFF_EVS; /* saturation seems to have no effect (tested by simulation) */ -#ifdef BASOP_NOGLOB + BASOP_SATURATE_WARNING_OFF_EVS; /* saturation seems to have no effect (tested by simulation) */ band[i] = L_shl_o( Ltmp1, exp_band, &Overflow ); /* Q15 + exp_band */ -#else /* BASOP_NOGLOB */ - band[i] = L_shl( Ltmp1, exp_band ); -#endif /* BASOP_NOGLOB */ move32(); /* band scaled by Q_new + QSCALE */ BASOP_SATURATE_WARNING_ON_EVS; @@ -1037,12 +1039,8 @@ static void find_enr( /* *ptE *= 4.0 / (L_FFT*L_FFT) */ /* normalization - corresponds to FFT normalization by 2/L_FFT */ - BASOP_SATURATE_WARNING_OFF_EVS; /* saturation seems to have no effect (tested by simulation) */ -#ifdef BASOP_NOGLOB + BASOP_SATURATE_WARNING_OFF_EVS; /* saturation seems to have no effect (tested by simulation) */ *Bin_E = L_shl_o( Ltmp, diff_scaleM2, &Overflow ); /* Q_new + QSCALE */ -#else /* BASOP_NOGLOB */ - *Bin_E = L_shl( Ltmp, diff_scaleM2 ); -#endif /* BASOP_NOGLOB */ move32(); /* scaled by Q_new + QSCALE - 2 */ BASOP_SATURATE_WARNING_ON_EVS; Bin_E++; @@ -1064,11 +1062,7 @@ static void find_enr( exp_band = sub( exp_band, shift_to_norm ); exp_band = sub( diff_scaleP1, exp_band ); BASOP_SATURATE_WARNING_OFF_EVS; /* saturation seems to have no effect (tested by simulation) */ -#ifdef BASOP_NOGLOB band[i] = L_shl_o( Ltmp1, exp_band, &Overflow ); -#else /* BASOP_NOGLOB */ - band[i] = L_shl( Ltmp1, exp_band ); -#endif move32(); /* band scaled by Q_new + QSCALE */ BASOP_SATURATE_WARNING_ON_EVS; @@ -1104,11 +1098,7 @@ static void find_enr( * Find the total energy over the input bandwidth *-----------------------------------------------------------------*/ -#ifdef BASOP_NOGLOB etot = L_add_sat( *LEtot, L_shl_sat( etot, sub( exp_etot, 4 ) ) ); -#else - etot = L_add( *LEtot, L_shl( etot, sub( exp_etot, 4 ) ) ); -#endif *LEtot = etot; move32(); diff --git a/lib_enc/ari_hm_enc_fx.c b/lib_enc/ari_hm_enc_fx.c index 66b53bc6de886a29c6408454101990cdea9d85ac..a94f45528ec7e3d57470eb6e72b2aace5aa198ff 100644 --- a/lib_enc/ari_hm_enc_fx.c +++ b/lib_enc/ari_hm_enc_fx.c @@ -459,17 +459,9 @@ Word16 SearchPeriodicityIndex_fx( tmp32 = L_mult0( Score, NumToConsider ); /* -> 16Q15 */ tmp = sub( norm_l( tmp32 ), 1 ); tmp2 = norm_l( AbsTotal ); -#ifdef BASOP_NOGLOB tmp3 = div_s( round_fx_o( L_shl_o( tmp32, tmp, &Overflow ), &Overflow ), round_fx_o( L_shl_o( AbsTotal, tmp2, &Overflow ), &Overflow ) ); *RelativeScore = shr_o( tmp3, add( sub( tmp, tmp2 ), 2 ), &Overflow ); /* -> 2Q13 */ move16(); -#else - tmp3 = div_s( round_fx( L_shl( tmp32, tmp ) ), round_fx( L_shl( AbsTotal, tmp2 ) ) ); - BASOP_SATURATE_WARNING_OFF_EVS - *RelativeScore = shr( tmp3, add( sub( tmp, tmp2 ), 2 ) ); /* -> 2Q13 */ - move16(); - BASOP_SATURATE_WARNING_ON_EVS -#endif } ELSE { diff --git a/lib_enc/arith_coder_enc_fx.c b/lib_enc/arith_coder_enc_fx.c index 40c1c6b7b73893959e64e400f7325072f4534f47..98a5173f592f6f5c41fd26316bd5ec30b4d72ede 100644 --- a/lib_enc/arith_coder_enc_fx.c +++ b/lib_enc/arith_coder_enc_fx.c @@ -72,11 +72,7 @@ static Word16 tcx_arith_estimate_scale( s1 = norm_l( abs_spectrum[k] ); } -#ifdef BASOP_NOGLOB tmp = mult_r( round_fx_o( L_shl( abs_spectrum[k], s1 ), &Overflow ), envelope[k] ); -#else /* BASOP_NOGLOB */ - tmp = mult_r( round_fx( L_shl( abs_spectrum[k], s1 ) ), envelope[k] ); -#endif /* BASOP_NOGLOB */ L_tmp = L_mult0( tmp, tmp ); tmp = sub( shl( s1, 1 ), 1 ); @@ -93,11 +89,7 @@ static Word16 tcx_arith_estimate_scale( /* scale and accumulate */ BASOP_SATURATE_WARNING_OFF_EVS; -#ifdef BASOP_NOGLOB accu = L_add_sat( accu, L_shr( L_tmp, sub( tmp, s ) ) ); -#else - accu = L_add( accu, L_shr( L_tmp, sub( tmp, s ) ) ); -#endif BASOP_SATURATE_WARNING_ON_EVS; } s = sub( shl( add( abs_spectrum_e, envelope_e ), 1 ), s ); @@ -387,13 +379,7 @@ static Word16 tcx_arith_rateloop( scale_max = tcx_arith_find_max_scale( abs_spectrum, abs_spectrum_e, L_frame, envelope, envelope_e, exps, deadzone, scale_e ); -#ifdef BASOP_NOGLOB scale = shl_o( scale, sub( tmp, *scale_e ), &Overflow ); -#else - BASOP_SATURATE_WARNING_OFF_EVS; - scale = shl( scale, sub( tmp, *scale_e ) ); - BASOP_SATURATE_WARNING_ON_EVS; -#endif scale = s_min( scale, scale_max ); scale_best = scale; @@ -454,13 +440,7 @@ static Word16 tcx_arith_rateloop( { /* Update estimator temporal compensation factor */ tmp = BASOP_Util_Divide3232_Scale( L_mult0( target_bits, 1 << 9 ), bits, &s ); -#ifdef BASOP_NOGLOB tmp = shl_o( mult_r( *target_bits_fac, tmp ), s, &Overflow ); -#else - BASOP_SATURATE_WARNING_OFF_EVS; - tmp = shl( mult_r( *target_bits_fac, tmp ), s ); - BASOP_SATURATE_WARNING_ON_EVS; -#endif tmp = s_min( tmp, 20480 /*1.25f Q14*/ ); tmp = s_max( tmp, 12288 /*0.75f Q14*/ ); *target_bits_fac = tmp; @@ -490,15 +470,8 @@ static Word16 tcx_arith_rateloop( { /* adjust = 1.25f * target_bits / (float)bits; */ tmp = BASOP_Util_Divide3232_Scale( L_mult0( target_bits, 0x280 ), bits, &s ); -#ifdef BASOP_NOGLOB adjust = shl_o( tmp, sub( s, 1 ), &Overflow ); /* Q14 */ scale = shl_o( mult_r( scale, adjust ), 1, &Overflow ); -#else - BASOP_SATURATE_WARNING_OFF_EVS; /* adjust limited to <= 2.0, scale to <= scale_max */ - adjust = shl( tmp, sub( s, 1 ) ); /* Q14 */ - scale = shl( mult_r( scale, adjust ), 1 ); - BASOP_SATURATE_WARNING_ON_EVS; -#endif scale = s_min( scale, scale_max ); } } @@ -802,11 +775,7 @@ void tcx_arith_encode_envelope_fx( L_tmp2 = L_deposit_l( 0 ); FOR( k = 0; k <= kMax; k++ ) { -#ifdef BASOP_NOGLOB L_tmp2 = L_macNs_co( L_tmp2, q_spectrum[k], k, &Carry, &Overflow ); -#else /* BASOP_NOGLOB */ - L_tmp2 = L_macNs( L_tmp2, q_spectrum[k], k ); -#endif if ( signs[k] != 0 ) L_tmp = L_mult( q_spectrum[k], -( 1 << ( 30 - SPEC_EXP_DEC ) ) ); @@ -823,3 +792,134 @@ void tcx_arith_encode_envelope_fx( *nf_seed = extract_l( L_tmp2 ); move16(); } + +void tcx_arith_encode_envelope_ivas_fx( + Word32 spectrum[], /* i/o: MDCT coefficients Q31-e */ + Word16 *spectrum_e, /* i/o: MDCT exponent Q0 */ + Word16 signs[], /* o: signs (spectrum[.]<0) Q0 */ + const Word16 L_frame, /* i: frame or MDCT length Q0 */ + const Word16 L_spec, /* i: frame or MDCT length Q0 */ + Encoder_State *st, /* i/o: coder state */ + const Word16 A_ind[], /* i: quantised LPC coefficients Q12 */ + Word16 target_bits, /* i: number of available bits Q0 */ + Word16 prm[], /* o: bitstream parameters Q0 */ + const Word8 use_hm, /* i: use HM in current frame? */ + Word16 prm_hm[], /* o: HM parameter area Q0 */ + const Word16 tcxltp_pitch, /* i: TCX LTP pitch in FD, -1 if n/a Q0*/ + Word16 *arith_bits, /* o: bits used for ari. coding Q0 */ + Word16 *signaling_bits, /* o: bits used for signaling Q0 */ + const Word16 low_complexity /* i: low-complexity flag Q0 */ +) +{ + Word32 env[N_MAX_ARI]; /* unscaled envelope (Q16) */ + Word16 *envelope; /* scaled envelope (Q15-e) */ + Word16 envelope_e; + Word16 exponents[N_MAX_ARI]; /* Q15 */ + Word16 L_spec_core; + Word16 *q_spectrum; + TCX_CONFIG_HANDLE hTcxCfg; + Word16 scale, scale_e; + Word16 k, kMax; + Word16 deadzone; + const Word8 *deadzone_flags; + Word16 gamma_w, gamma_uw; + Word16 hm_bits; + Word32 L_tmp; + Word16 tmp; + TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; + + assert( L_spec <= N_MAX_ARI ); + + hTcxCfg = st->hTcxCfg; + deadzone = hTcxCfg->sq_rounding; + move16(); + deadzone_flags = hTcxEnc->memQuantZeros; + *signaling_bits = 0; + move16(); + + assert( st->enableTcxLpc ); + gamma_w = 32767 /*1.0f Q15*/; + move16(); + gamma_uw = st->inv_gamma; + move16(); + + tcx_arith_render_envelope( A_ind, L_frame, L_spec, hTcxCfg->preemph_fac, gamma_w, gamma_uw, env ); + + FOR( k = 0; k < L_spec; k++ ) + { + signs[k] = extract_l( L_lshr( spectrum[k], 31 ) ); + move16(); + if ( spectrum[k] < 0 ) + { + spectrum[k] = L_abs( spectrum[k] ); + move32(); + } + } + + IF( use_hm != 0 ) + { + tcx_hm_analyse_fx( spectrum, spectrum_e, L_spec, env, target_bits, hTcxCfg->coder_type, prm_hm, tcxltp_pitch, hTcxEnc->tcxltp_gain, &hm_bits ); + + target_bits = sub( target_bits, hm_bits ); + *signaling_bits = add( *signaling_bits, hm_bits ); + move16(); + } + ELSE + { + prm_hm[0] = 0; /* just to be sure */ + move16(); + hm_bits = 0; + move16(); + } + + L_spec_core = L_spec; + move16(); + if ( st->igf ) + { + L_spec_core = s_min( L_spec_core, st->hIGFEnc->infoStartLine ); + } + envelope = (Word16 *) env; + + tcx_arith_scale_envelope( L_spec, L_spec_core, env, target_bits, low_complexity, envelope, &envelope_e ); + + tmp = sub( envelope_e, 1 + 15 ); + FOR( k = 0; k < L_spec; k++ ) + { + exponents[k] = round_fx( expfp( envelope[k], tmp ) ); + move16(); + } + + scale = tcx_arith_rateloop( spectrum, *spectrum_e, L_spec, envelope, envelope_e, exponents, target_bits, deadzone, deadzone_flags, &( hTcxEnc->tcx_target_bits_fac ), &scale_e ); + + /* Final quantization */ + kMax = tcx_arith_find_kMax( spectrum, *spectrum_e, L_spec, scale, scale_e, deadzone, deadzone_flags ); + + q_spectrum = (Word16 *) env; /* Reuse buffer */ + + L_tmp = L_mult( deadzone, 1 ); /* Q16 */ + tmp = add( sub( *spectrum_e, 15 ), scale_e ); + FOR( k = 0; k <= kMax; k++ ) + { + /* quantise using dead-zone */ + q_spectrum[k] = extract_h( L_add( L_shl( Mpy_32_16_1( spectrum[k], scale ), tmp ), L_tmp ) ); + move16(); + } + + /* Final encoding */ + *arith_bits = tcx_arith_encode( q_spectrum, signs, kMax, L_spec, exponents, target_bits, prm ); + move16(); + + /* Multiply back the signs */ + FOR( k = 0; k <= kMax; k++ ) + { + if ( signs[k] != 0 ) + L_tmp = L_mult( q_spectrum[k], -( 1 << ( 30 - SPEC_EXP_DEC ) ) ); + if ( signs[k] == 0 ) + L_tmp = L_mult( q_spectrum[k], 1 << ( 30 - SPEC_EXP_DEC ) ); + spectrum[k] = L_tmp; + move32(); + } + *spectrum_e = SPEC_EXP_DEC; + move16(); + set32_fx( spectrum + k, 0, sub( s_max( L_frame, L_spec ), k ) ); +} diff --git a/lib_enc/avq_cod_fx.c b/lib_enc/avq_cod_fx.c index c5a10198185b879db16dbafdbf9168682e7e173f..202d60e51dd8e9c72ef431928b3ad14fefafaef8 100644 --- a/lib_enc/avq_cod_fx.c +++ b/lib_enc/avq_cod_fx.c @@ -55,11 +55,7 @@ void AVQ_cod_fx( /* o: comfort noise gain factor Lener = L_shl( 4, shl( Q_in, 1 ) ); /* to set ebits >= 0 */ FOR( i = 0; i < 8; i++ ) { -#ifdef BASOP_NOGLOB Lener = L_mac_o( Lener, xri[l * 8 + i], xri[l * 8 + i], &Overflow ); -#else - Lener = L_mac( Lener, xri[l * 8 + i], xri[l * 8 + i] ); -#endif } /* estimated bit consumption when gain=1 */ /* ebits[l] = 5.0 * FAC_LOG2 * (Word16)log10(ener * 0.5) */ @@ -124,11 +120,7 @@ void AVQ_cod_fx( /* o: comfort noise gain factor /* estimated gain (when offset=0, estimated gain=1) */ f_tmp = L_Extract_lc( Ltmp, &e_tmp ); tmp16 = extract_l( Pow2( 14, f_tmp ) ); -#ifdef BASOP_NOGLOB Lgain = L_shl_sat( tmp16, e_tmp ); -#else - Lgain = L_shl( tmp16, e_tmp ); -#endif /* gain_inv = 1.0f / gain */ e_tmp = norm_l( Lgain ); tmp16 = extract_h( L_shl( Lgain, e_tmp ) ); diff --git a/lib_enc/bass_psfilter_enc_fx.c b/lib_enc/bass_psfilter_enc_fx.c index e43fa6bc6354df3ea507a887d5e635d903dbf21e..a1d672fe0059f3a6971fa0fb7f6bb6800745d88a 100644 --- a/lib_enc/bass_psfilter_enc_fx.c +++ b/lib_enc/bass_psfilter_enc_fx.c @@ -129,11 +129,7 @@ Word16 bass_pf_enc_fx( /* gain = tmp/nrg; */ gain = BASOP_Util_Divide3232_Scale( tmp, nrg, &tmp16 ); BASOP_SATURATE_WARNING_OFF_EVS; -#ifdef BASOP_NOGLOB gain = shl_o( gain, tmp16, &Overflow ); /* Q15 */ -#else /* BASOP_NOGLOB */ - gain = shl( gain, tmp16 ); /* Q15 */ -#endif /* BASOP_NOGLOB */ BASOP_SATURATE_WARNING_ON_EVS; if ( gain < 0 ) @@ -157,26 +153,14 @@ Word16 bass_pf_enc_fx( FOR( i = 0; i < lg; i++ ) { tmp32 = L_msu0( 0, gain, syn[i + i_subfr - T] ); -#ifdef BASOP_NOGLOB tmp32 = L_msu0_o( tmp32, gain, syn[i + i_subfr + T], &Overflow ); tmp16 = mac_ro( tmp32, gain, syn[i + i_subfr], &Overflow ); /* Q0 */ -#else - tmp32 = L_msu0( tmp32, gain, syn[i + i_subfr + T] ); - tmp16 = mac_r( tmp32, gain, syn[i + i_subfr] ); /* Q0 */ -#endif lp_error = Mpy_32_16_1( lp_error, 29491 /*0.9f Q15*/ ); -#ifdef BASOP_NOGLOB lp_error = L_mac_o( lp_error, tmp16, 0x1000, &Overflow ); /* Q13 */ tmp16 = round_fx_o( L_shl_o( lp_error, s1, &Overflow ), &Overflow ); /* Q0+s1-3 */ ener2 = L_mac0_o( ener2, tmp16, tmp16, &Overflow ); /* Q0+(s1-3)*2 */ -#else - lp_error = L_mac( lp_error, tmp16, 0x1000 ); /* Q13 */ - - tmp16 = round_fx( L_shl( lp_error, s1 ) ); /* Q0+s1-3 */ - ener2 = L_mac0( ener2, tmp16, tmp16 ); /* Q0+(s1-3)*2 */ -#endif } } @@ -185,25 +169,13 @@ Word16 bass_pf_enc_fx( FOR( i = lg; i < l_subfr; i++ ) { tmp32 = L_mult0( gain, syn[i + i_subfr] ); -#ifdef BASOP_NOGLOB tmp32 = L_msu0_o( tmp32, gain, syn[i + i_subfr - T], &Overflow ); /* Q0 */ tmp16 = round_fx_o( tmp32, &Overflow ); -#else - tmp32 = L_msu0( tmp32, gain, syn[i + i_subfr - T] ); /* Q0 */ - tmp16 = round_fx( tmp32 ); -#endif lp_error = Mpy_32_16_1( lp_error, 29491 /*0.9f Q15*/ ); -#ifdef BASOP_NOGLOB lp_error = L_mac_o( lp_error, tmp16, 0x1000, &Overflow ); /* Q13 */ tmp16 = round_fx_o( L_shl_o( lp_error, s1, &Overflow ), &Overflow ); /* Q0+s1-3 */ ener2 = L_mac0_o( ener2, tmp16, tmp16, &Overflow ); /* Q0+(s1-3)*2 */ -#else - lp_error = L_mac( lp_error, tmp16, 0x1000 ); /* Q13 */ - - tmp16 = round_fx( L_shl( lp_error, s1 ) ); /* Q0+s1-3 */ - ener2 = L_mac0( ener2, tmp16, tmp16 ); /* Q0+(s1-3)*2 */ -#endif } } @@ -238,11 +210,7 @@ Word16 bass_pf_enc_fx( tmp32 = L_deposit_l( 1 ); tmp16 = BASOP_Util_Divide3232_Scale( tmp, tmp32, &st ); BASOP_SATURATE_WARNING_OFF_EVS; -#ifdef BASOP_NOGLOB tmp16 = shl_o( tmp16, sub( st, 2 ), &Overflow ); /* Q15 */ -#else /* BASOP_NOGLOB */ - tmp16 = shl( tmp16, sub( st, 2 ) ); /* Q15 */ -#endif /* BASOP_NOGLOB */ if ( GT_16( tmp16, 16384 /*0.5f Q15*/ ) ) { @@ -268,13 +236,8 @@ Word16 bass_pf_enc_fx( tmp32 = L_mac( tmp32, tmp16, syn[i + i_subfr] ); noise_in[i] = round_fx( L_shl( tmp32, s2 ) ); /* Q0+s2 */ -#ifdef BASOP_NOGLOB error_in[i] = sub_o( orig[i + i_subfr], syn[i + i_subfr], &Overflow ); /*Q0*/ move16(); -#else - error_in[i] = sub( orig[i + i_subfr], syn[i + i_subfr] ); /*Q0*/ - move16(); -#endif } } @@ -287,13 +250,8 @@ Word16 bass_pf_enc_fx( noise_in[i] = round_fx( L_shl( tmp32, s2 ) ); /* Q0+s2 */ move16(); -#ifdef BASOP_NOGLOB error_in[i] = sub_o( orig[i + i_subfr], syn[i + i_subfr], &Overflow ); /*Q0*/ move16(); -#else - error_in[i] = sub( orig[i + i_subfr], syn[i + i_subfr] ); /*Q0*/ - move16(); -#endif } } } @@ -311,7 +269,11 @@ 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 ); @@ -407,13 +369,8 @@ Word16 bass_pf_enc_fx( /* *gain_factor_param = (int)(-2.f*(cross_n_d/nrg_n)+0.5f); */ tmp16 = BASOP_Util_Divide3232_Scale( cross_n_d, nrg_n, &st ); /* Q15-st-s3+s4 */ BASOP_SATURATE_WARNING_OFF_EVS; -#ifdef BASOP_NOGLOB tmp16 = shl_sat( negate( tmp16 ), add( sub( add( st, s3 ), s4 ), 1 - 14 ) ); /* Q1 */ tmp16 = shr( add_sat( tmp16, 1 ), 1 ); /* Q0 */ -#else - tmp16 = shl( negate( tmp16 ), add( sub( add( st, s3 ), s4 ), 1 - 14 ) ); /* Q1 */ - tmp16 = shr( add( tmp16, 1 ), 1 ); /* Q0 */ -#endif BASOP_SATURATE_WARNING_ON_EVS; *gain_factor_param = tmp16; diff --git a/lib_enc/bw_detect_fx.c b/lib_enc/bw_detect_fx.c index 6d2df38cdc103623c8e4da59ad49a61738b8fe81..931b175ffcbcb81b781ceca892d01c8d71a9c16c 100644 --- a/lib_enc/bw_detect_fx.c +++ b/lib_enc/bw_detect_fx.c @@ -132,12 +132,8 @@ void bw_detect_fx( cldfb_bin[i] = L_deposit_l( 1 ); move32(); } - L_tmp = BASOP_Util_Log2( cldfb_bin[0] ); /*(log2(660423549*2^(-31))/64)*2^31*/ -#ifdef BASOP_NOGLOB + L_tmp = BASOP_Util_Log2( cldfb_bin[0] ); /*(log2(660423549*2^(-31))/64)*2^31*/ L_tmp = L_add_o( L_tmp, L_shl( L_deposit_l( cldfb_bin_Exp[0] ), 31 - LD_DATA_SCALE ), &Overflow ); /* Q25 */ -#else /* BASOP_NOGLOB */ - L_tmp = L_add( L_tmp, L_shl( L_deposit_l( cldfb_bin_Exp[0] ), 31 - LD_DATA_SCALE ) ); /* Q25 */ -#endif /* BASOP_NOGLOB */ cldfb_bin[0] = Mpy_32_16_1( L_tmp, 9864 /*1.0f/3.3219280948873623478703194294894f Q15*/ ); move32(); /* 1/log2(10) */ /* Q25 */ @@ -306,11 +302,7 @@ void bw_detect_fx( FOR( i = 0; i < BWD_TOTAL_WIDTH; i++ ) { -#ifdef BASOP_NOGLOB spect[i] = round_fx_o( L_shr_o( spect32[i], Q_dct, &Overflow ), &Overflow ); -#else /* BASOP_NOGLOB */ - spect[i] = round_fx( L_shr( spect32[i], Q_dct ) ); -#endif move16(); } Q_dct = -2; @@ -342,11 +334,7 @@ void bw_detect_fx( pt1 = &spect[i_mult2( i, bin_width )]; FOR( j = 0; j < bin_width; j++ ) { -#ifdef BASOP_NOGLOB sum32 = L_mac0_o( sum32, *pt1, *pt1, &Overflow ); -#else - sum32 = L_mac0( sum32, *pt1, *pt1 ); -#endif pt1++; } diff --git a/lib_enc/cng_enc.c b/lib_enc/cng_enc.c index ea957da8c51d3508ab6446de4df77ebbc2867ff9..15dc89516be41e8fe8f976d302826a5ffe2a0827 100644 --- a/lib_enc/cng_enc.c +++ b/lib_enc/cng_enc.c @@ -265,11 +265,7 @@ static Word16 shb_DTX_ivas_fx( shb_ener_fx = L_deposit_l( 0 ); FOR( i = 0; i < L_FRAME16k; i++ ) { -#ifdef BASOP_NOGLOB shb_ener_fx = L_mac_sat( shb_ener_fx, shb_old_speech_fx[i], shb_old_speech_fx[i] ); // ( Q0 + Q0 + Q1 ) --> Q1 due to left shift in L_mac -#else - shb_ener_fx = L_mac( shb_ener_fx, shb_old_speech_fx[i], shb_old_speech_fx[i] ); -#endif } shb_ener_fx = L_add( Mpy_32_16_1( shb_ener_fx, 102 ), 1 ); /* ( 1 / L_FRAME16K ) -> 102 in Q15, shb_ener_fx in Q1 */ @@ -277,11 +273,7 @@ static Word16 shb_DTX_ivas_fx( wb_ener_fx = L_deposit_l( 0 ); FOR( i = 0; i < st->L_frame; i++ ) { -#ifdef BASOP_NOGLOB wb_ener_fx = L_mac_o( wb_ener_fx, syn_12k8_16k_fx[i], syn_12k8_16k_fx[i], &Overflow ); // ( Q0 + Q0 + Q1 ) --> Q1 due to left shift in L_mac -#else - wb_ener_fx = L_mac( wb_ener_fx, syn_12k8_16k[i], syn_12k8_16k[i] ); -#endif } wb_ener_fx = L_add( Mpy_32_16_1( wb_ener_fx, 128 ), 1 ); /* 128 in Q15, wb_ener_fx in Q1 */ @@ -291,11 +283,7 @@ static Word16 shb_DTX_ivas_fx( exp = sub( 30 - 1, exp ); wb_ener_fx = Mpy_32_16( exp, fra, LG10 ); -#ifdef BASOP_NOGLOB log_wb_ener_fx = round_fx_o( L_shl_o( wb_ener_fx, 10, &Overflow ), &Overflow ); /* log_wb_ener_fx in Q8 */ -#else - log_wb_ener_fx = round_fx( L_shl( wb_ener_fx, 10 ) ); /* log_wb_ener_fx in Q8 */ -#endif exp = norm_l( shb_ener_fx ); fra = Log2_norm_lc( L_shl( shb_ener_fx, exp ) ); exp = sub( 30 - 1, exp ); @@ -320,11 +308,7 @@ static Word16 shb_DTX_ivas_fx( } -#ifdef BASOP_NOGLOB log_shb_ener_fx = sub_o( round_fx_o( L_shl_o( shb_ener_fx, 10, &Overflow ), &Overflow ), att_fx, &Overflow ); /* log_shb_ener_fx in Q8 */ -#else - log_shb_ener_fx = sub( round_fx( L_shl( shb_ener_fx, 10 ) ), att_fx ); /* log_shb_ener_fx in Q8 */ -#endif IF( st->hDtxEnc->first_CNG == 0 ) { diff --git a/lib_enc/cng_enc_fx.c b/lib_enc/cng_enc_fx.c index e2c81a8d11eb1f4bc9eb3d13c786d5a02d515829..4cfc193ecc5785ac74d5b4e0bc75405f86d11176 100644 --- a/lib_enc/cng_enc_fx.c +++ b/lib_enc/cng_enc_fx.c @@ -644,11 +644,7 @@ void CNG_enc_fx( FOR( i = 0; i < M; i++ ) { dev = abs_s( sub( lsp_tmp[i], lsp_new[i] ) ); /*Q15 */ -#ifdef BASOP_NOGLOB - dist = add_o( dist, dev, &Overflow ); /*Q15 */ -#else - dist = add( dist, dev ); /*Q15 */ -#endif + dist = add_o( dist, dev, &Overflow ); /*Q15 */ if ( GT_16( dev, max_dev ) ) { max_dev = dev; @@ -682,31 +678,19 @@ void CNG_enc_fx( FOR( j = 0; j < m1; j++ ) { /* env[i] += tmp_env[j*NUM_ENV_CNG+i]; */ -#ifdef BASOP_NOGLOB L_tmp = L_add_sat( L_tmp, tmp_env[j * NUM_ENV_CNG + i] ); -#else - L_tmp = L_add( L_tmp, tmp_env[j * NUM_ENV_CNG + i] ); -#endif } /* env[i] /= (float)m1; */ /* env[i] = env[i] - 2*hTdCngEnc->lp_ener_fx; */ IF( EQ_16( m1, 1 ) ) { -#ifdef BASOP_NOGLOB L_tmp = L_sub_sat( L_tmp, L_add_sat( hTdCngEnc->lp_ener_fx, hTdCngEnc->lp_ener_fx ) ); -#else - L_tmp = L_sub( L_tmp, L_add( hTdCngEnc->lp_ener_fx, hTdCngEnc->lp_ener_fx ) ); -#endif } ELSE { tmp1 = div_s( 1, m1 ); L_tmp = Mult_32_16( L_tmp, tmp1 ); -#ifdef BASOP_NOGLOB L_tmp = L_sub_sat( L_tmp, L_add_sat( hTdCngEnc->lp_ener_fx, hTdCngEnc->lp_ener_fx ) ); -#else - L_tmp = L_sub( L_tmp, L_add( hTdCngEnc->lp_ener_fx, hTdCngEnc->lp_ener_fx ) ); -#endif } env[i] = L_tmp; @@ -796,15 +780,9 @@ void CNG_enc_fx( FOR( i = 0; i < NUM_ENV_CNG; i++ ) { /* env[i] = 2.0f*(*ptR * *ptR + *ptI * *ptI)/L_FFT; */ -#ifdef BASOP_NOGLOB L_tmp = L_mult_o( *ptR, *ptR, &Overflow ); /* 2*Q_new+1 */ L_tmp = L_add_o( L_tmp, L_mult_o( *ptI, *ptI, &Overflow ), &Overflow ); /* 2*Q_new+1 */ L_tmp = L_add_o( L_tmp, L_tmp, &Overflow ); /* 2*Q_new+1 */ -#else /* BASOP_NOGLOB */ - L_tmp = L_mult( *ptR, *ptR ); /* 2*Q_new+1 */ - L_tmp = L_add( L_tmp, L_mult( *ptI, *ptI ) ); /* 2*Q_new+1 */ - L_tmp = L_add( L_tmp, L_tmp ); /* 2*Q_new+1 */ -#endif /* BASOP_NOGLOB */ L_tmp = Mult_32_16( L_tmp, 128 ); /* 2*Q_new+1 */ tmp1 = add( add( Q_new, Q_new ), 1 ); env[i] = L_shr( L_tmp, sub( tmp1, 6 ) ); @@ -834,15 +812,9 @@ void CNG_enc_fx( L_tmp = L_mult0( tmpv, tmpv ); pt_res++; tmpv = shl( *pt_res, scale ); -#ifdef BASOP_NOGLOB L_tmp = L_mac0_sat( L_tmp, tmpv, tmpv ); /* 2*(Q_new+scale) */ pt_res++; L_ener = L_add_sat( L_ener, L_shr( L_tmp, 7 ) ); /* 2*(Q_new+scale)+1, divide by L_frame done here */ -#else - L_tmp = L_mac0( L_tmp, tmpv, tmpv ); /* 2*(Q_new+scale) */ - pt_res++; - L_ener = L_add( L_ener, L_shr( L_tmp, 7 ) ); /* 2*(Q_new+scale)+1, divide by L_frame done here */ -#endif } } ELSE /* L_FRAME16k */ @@ -853,15 +825,9 @@ void CNG_enc_fx( L_tmp = L_mult0( tmpv, tmpv ); pt_res++; tmpv = shl( *pt_res, scale ); -#ifdef BASOP_NOGLOB L_tmp = L_mac0_sat( L_tmp, tmpv, tmpv ); /* 2*(Q_new+scale) */ pt_res++; L_ener = L_add_sat( 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 */ -#else - L_tmp = L_mac0( L_tmp, tmpv, tmpv ); /* 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 */ -#endif } } /* convert log2 of residual signal energy */ @@ -891,11 +857,7 @@ void CNG_enc_fx( L_tmp1 = L_add( env[i], 0 ); FOR( j = 0; j < hDtxEnc->cng_hist_size; j++ ) { -#ifdef BASOP_NOGLOB L_tmp1 = L_add_sat( L_tmp1, hTdCngEnc->cng_res_env_fx[j * NUM_ENV_CNG + i] ); -#else - L_tmp1 = L_add( L_tmp1, hTdCngEnc->cng_res_env_fx[j * NUM_ENV_CNG + i] ); -#endif } L_tmp = L_add( hTdCngEnc->cng_res_env_fx[max_idx1[0] * NUM_ENV_CNG + i], hTdCngEnc->cng_res_env_fx[max_idx1[1] * NUM_ENV_CNG + i] ); L_tmp1 = L_sub( L_tmp1, L_tmp ); @@ -1047,11 +1009,7 @@ void CNG_enc_fx( L_tmp = L_shl( hTdCngEnc->Enew_fx, exp ); /*Q(exp+6) */ L_tmp = Mult_32_16( L_tmp, shl( st_fx->L_frame, 5 ) ); /* Q(exp+6+5-15=exp-4) */ -#ifdef BASOP_NOGLOB L_tmp = L_shr_sat( L_tmp, sub( exp, 10 ) ); /* Q6 */ -#else - L_tmp = L_shr( L_tmp, sub( exp, 10 ) ); /* Q6 */ -#endif exp = norm_l( L_tmp ); fra = Log2_norm_lc( L_shl( L_tmp, exp ) ); @@ -1104,13 +1062,9 @@ void CNG_enc_fx( /* d += (env[j] - CNG_details_codebook_fx[i][j]) * (env[j] - CNG_details_codebook_fx[i][j]);*/ L_tmp = L_sub( env[j], L_deposit_l( CNG_details_codebook_fx[i][j] ) ); /* Q6 */ exp = norm_l( L_tmp ); - L_tmp = L_shl( L_tmp, exp ); /*Q(exp+6)*/ - tmp1 = extract_h( L_tmp ); /*Q(exp+6-16)=exp-10*/ -#ifdef BASOP_NOGLOB - L_tmp = L_mult_o( tmp1, tmp1, &Overflow ); /*Q(2*exp - 19)*/ -#else /* BASOP_NOGLOB */ - L_tmp = L_mult( tmp1, tmp1 ); /*Q(2*exp - 19)*/ -#endif + L_tmp = L_shl( L_tmp, exp ); /*Q(exp+6)*/ + tmp1 = extract_h( L_tmp ); /*Q(exp+6-16)=exp-10*/ + L_tmp = L_mult_o( tmp1, tmp1, &Overflow ); /*Q(2*exp - 19)*/ L_tmp = L_shr( L_tmp, sub( add( exp, exp ), 36 ) ); /* Q17 */ d = L_add( d, L_tmp ); } @@ -1901,31 +1855,19 @@ void CNG_enc_ivas_fx( FOR( j = 0; j < m1; j++ ) { /* env[i] += tmp_env[j*NUM_ENV_CNG+i]; */ -#ifdef BASOP_NOGLOB L_tmp = L_add_sat( L_tmp, tmp_env[j * NUM_ENV_CNG + i] ); -#else - L_tmp = L_add( L_tmp, tmp_env[j * NUM_ENV_CNG + i] ); -#endif } /* env[i] /= (float)m1; */ /* env[i] = env[i] - 2*hTdCngEnc->lp_ener_fx; */ IF( EQ_16( m1, 1 ) ) { -#ifdef BASOP_NOGLOB L_tmp = L_sub_sat( L_tmp, L_add_sat( hTdCngEnc->lp_ener_fx, hTdCngEnc->lp_ener_fx ) ); -#else - L_tmp = L_sub( L_tmp, L_add( hTdCngEnc->lp_ener_fx, hTdCngEnc->lp_ener_fx ) ); -#endif } ELSE { tmp1 = div_s( 1, m1 ); L_tmp = Mult_32_16( L_tmp, tmp1 ); -#ifdef BASOP_NOGLOB L_tmp = L_sub_sat( L_tmp, L_add_sat( hTdCngEnc->lp_ener_fx, hTdCngEnc->lp_ener_fx ) ); -#else - L_tmp = L_sub( L_tmp, L_add( hTdCngEnc->lp_ener_fx, hTdCngEnc->lp_ener_fx ) ); -#endif } env[i] = L_tmp; /* Q6*/ @@ -2016,15 +1958,9 @@ void CNG_enc_ivas_fx( FOR( i = 0; i < NUM_ENV_CNG; i++ ) { /* env[i] = 2.0f*(*ptR * *ptR + *ptI * *ptI)/L_FFT; */ -#ifdef BASOP_NOGLOB L_tmp = L_mult_o( *ptR, *ptR, &Overflow ); /* 2*Q_new+1 */ L_tmp = L_add_o( L_tmp, L_mult_o( *ptI, *ptI, &Overflow ), &Overflow ); /* 2*Q_new+1 */ L_tmp = L_add_o( L_tmp, L_tmp, &Overflow ); /* 2*Q_new+1 */ -#else /* BASOP_NOGLOB */ - L_tmp = L_mult( *ptR, *ptR ); /* 2*Q_new+1 */ - L_tmp = L_add( L_tmp, L_mult( *ptI, *ptI ) ); /* 2*Q_new+1 */ - L_tmp = L_add( L_tmp, L_tmp ); /* 2*Q_new+1 */ -#endif /* BASOP_NOGLOB */ L_tmp = Mult_32_16( L_tmp, 128 ); /* 2*Q_new+1 */ tmp1 = add( add( Q_new, Q_new ), 1 ); env[i] = L_shr( L_tmp, sub( tmp1, 6 ) ); @@ -2088,13 +2024,23 @@ void CNG_enc_ivas_fx( /* convert log2 of residual signal energy */ /*enr = (float)log10( enr + 0.1f ) / (float)log10( 2.0f ); */ - hi = norm_l( L_ener ); - lo = Log2_norm_lc( L_shl( L_ener, hi ) ); - hi = sub( 29, hi ); /* log2 exp in Q2*Q_new */ - hi = sub( hi, shl( Q_new, 1 ) ); /* Q0 */ - L_tmp = L_Comp( hi, lo ); /* Q16 */ - enr = round_fx( L_shl( L_tmp, 8 ) ); /* Q8 (16+8-16) */ +#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 ) ); + hi = sub( 29, hi ); /* log2 exp in Q2*Q_new */ + hi = sub( hi, shl( Q_new, 1 ) ); /* Q0 */ + L_tmp = L_Comp( hi, lo ); /* Q16 */ + enr = round_fx( L_shl( L_tmp, 8 ) ); /* Q8 (16+8-16) */ + } /* update the circular buffer of old energies */ hTdCngEnc->cng_ener_hist_fx[hTdCngEnc->cng_hist_ptr] = enr; move16(); /* Q8 */ @@ -2113,11 +2059,7 @@ void CNG_enc_ivas_fx( L_tmp1 = L_add( env[i], 0 ); FOR( j = 0; j < hDtxEnc->cng_hist_size; j++ ) { -#ifdef BASOP_NOGLOB L_tmp1 = L_add_sat( L_tmp1, hTdCngEnc->cng_res_env_fx[j * NUM_ENV_CNG + i] ); -#else - L_tmp1 = L_add( L_tmp1, hTdCngEnc->cng_res_env_fx[j * NUM_ENV_CNG + i] ); -#endif } L_tmp = L_add( hTdCngEnc->cng_res_env_fx[max_idx1[0] * NUM_ENV_CNG + i], hTdCngEnc->cng_res_env_fx[max_idx1[1] * NUM_ENV_CNG + i] ); L_tmp1 = L_sub( L_tmp1, L_tmp ); @@ -2267,11 +2209,7 @@ void CNG_enc_ivas_fx( L_tmp = L_shl( hTdCngEnc->Enew_fx, exp ); /*Q(exp+6) */ L_tmp = Mult_32_16( L_tmp, shl( st_fx->L_frame, 5 ) ); /* Q(exp+6+5-15=exp-4) */ -#ifdef BASOP_NOGLOB L_tmp = L_shr_sat( L_tmp, sub( exp, 10 ) ); /* Q6 */ -#else - L_tmp = L_shr( L_tmp, sub( exp, 10 ) ); /* Q6 */ -#endif exp = norm_l( L_tmp ); fra = Log2_norm_lc( L_shl( L_tmp, exp ) ); @@ -2325,13 +2263,9 @@ void CNG_enc_ivas_fx( /* d += (env[j] - CNG_details_codebook_fx[i][j]) * (env[j] - CNG_details_codebook_fx[i][j]);*/ L_tmp = L_sub( env[j], L_deposit_l( CNG_details_codebook_fx[i][j] ) ); /* Q6 */ exp = norm_l( L_tmp ); - L_tmp = L_shl( L_tmp, exp ); /*Q(exp+6)*/ - tmp1 = extract_h( L_tmp ); /*Q(exp+6-16)=exp-10*/ -#ifdef BASOP_NOGLOB - L_tmp = L_mult_o( tmp1, tmp1, &Overflow ); /*Q(2*exp - 19)*/ -#else /* BASOP_NOGLOB */ - L_tmp = L_mult( tmp1, tmp1 ); /*Q(2*exp - 19)*/ -#endif + L_tmp = L_shl( L_tmp, exp ); /*Q(exp+6)*/ + tmp1 = extract_h( L_tmp ); /*Q(exp+6-16)=exp-10*/ + L_tmp = L_mult_o( tmp1, tmp1, &Overflow ); /*Q(2*exp - 19)*/ L_tmp = L_shr( L_tmp, sub( add( exp, exp ), 36 ) ); /* Q17 */ d = L_add( d, L_tmp ); /* Q17 */ } @@ -2647,11 +2581,7 @@ static Word16 shb_DTX_fx( shb_ener_fx = L_deposit_l( 0 ); FOR( i = 0; i < L_FRAME16k; i++ ) { -#ifdef BASOP_NOGLOB shb_ener_fx = L_mac_sat( shb_ener_fx, shb_old_speech_fx[i], shb_old_speech_fx[i] ); -#else - shb_ener_fx = L_mac( shb_ener_fx, shb_old_speech_fx[i], shb_old_speech_fx[i] ); -#endif } shb_ener_fx = L_add( Mpy_32_16_1( shb_ener_fx, 102 ), 1 ); /* 102 in Q15, shb_ener_fx in Q1 */ @@ -2659,11 +2589,7 @@ static Word16 shb_DTX_fx( wb_ener_fx = L_deposit_l( 0 ); FOR( i = 0; i < st_fx->L_frame; i++ ) { -#ifdef BASOP_NOGLOB wb_ener_fx = L_mac_o( wb_ener_fx, syn_12k8_16k[i], syn_12k8_16k[i], &Overflow ); -#else - wb_ener_fx = L_mac( wb_ener_fx, syn_12k8_16k[i], syn_12k8_16k[i] ); -#endif } wb_ener_fx = L_add( Mpy_32_16_1( wb_ener_fx, 128 ), 1 ); /* 128 in Q15, wb_ener_fx in Q1 */ @@ -2672,11 +2598,7 @@ static Word16 shb_DTX_fx( fra = Log2_norm_lc( L_shl( wb_ener_fx, exp ) ); exp = sub( 30 - 1, exp ); wb_ener_fx = Mpy_32_16( exp, fra, LG10 ); -#ifdef BASOP_NOGLOB log_wb_ener_fx = round_fx_o( L_shl_o( wb_ener_fx, 10, &Overflow ), &Overflow ); /* log_wb_ener_fx in Q8 */ -#else - log_wb_ener_fx = round_fx( L_shl( wb_ener_fx, 10 ) ); /* log_wb_ener_fx in Q8 */ -#endif exp = norm_l( shb_ener_fx ); fra = Log2_norm_lc( L_shl( shb_ener_fx, exp ) ); exp = sub( 30 - 1, exp ); @@ -2695,11 +2617,7 @@ static Word16 shb_DTX_fx( move16(); } -#ifdef BASOP_NOGLOB log_shb_ener_fx = sub_o( round_fx_o( L_shl_o( shb_ener_fx, 10, &Overflow ), &Overflow ), att, &Overflow ); /* log_shb_ener_fx in Q8 */ -#else - log_shb_ener_fx = sub( round_fx( L_shl( shb_ener_fx, 10 ) ), att ); /* log_shb_ener_fx in Q8 */ -#endif IF( hDtxEnc->first_CNG == 0 ) { hTdCngEnc->mov_wb_cng_ener_fx = log_wb_ener_fx; diff --git a/lib_enc/cod2t32_fx.c b/lib_enc/cod2t32_fx.c index cbe006f5360f7186fdc9750cbb41ce72978ff63d..c9bbe5f30954307fb392712240508edeca860d56 100644 --- a/lib_enc/cod2t32_fx.c +++ b/lib_enc/cod2t32_fx.c @@ -64,19 +64,11 @@ void acelp_2t32_fx( L_cor = L_deposit_h( 1 ); FOR( i = 0; i < NB_POS_FCB_2T; i++ ) { -#ifdef BASOP_NOGLOB L_cor = L_mac_o( L_cor, *ptr_h1, *ptr_h1, &Overflow ); -#else - L_cor = L_mac( L_cor, *ptr_h1, *ptr_h1 ); -#endif ptr_h1++; *p1-- = extract_h( L_cor ); move16(); /*Q9 Q7*/ -#ifdef BASOP_NOGLOB L_cor = L_mac_o( L_cor, *ptr_h1, *ptr_h1, &Overflow ); -#else - L_cor = L_mac( L_cor, *ptr_h1, *ptr_h1 ); -#endif ptr_h1++; *p0-- = extract_h( L_cor ); move16(); /*Q9 Q7*/ @@ -117,31 +109,17 @@ void acelp_2t32_fx( L_cor = L_mult( *ptr_h1++, *ptr_h2++ ); // Q(12+12+1) FOR( i = k; i < NB_POS_FCB_2T - 1; i++ ) { -#ifdef BASOP_NOGLOB *p1 = round_fx_o( L_cor, &Overflow ); // Q(25-16) L_cor = L_mac_o( L_cor, *ptr_h1++, *ptr_h2++, &Overflow ); -#else - *p1 = round_fx( L_cor ); - L_cor = L_mac( L_cor, *ptr_h1++, *ptr_h2++ ); -#endif -#ifdef BASOP_NOGLOB *p0 = round_fx_o( L_cor, &Overflow ); // Q(9) L_cor = L_mac_o( L_cor, *ptr_h1++, *ptr_h2++, &Overflow ); -#else - *p0 = round_fx( L_cor ); - L_cor = L_mac( L_cor, *ptr_h1++, *ptr_h2++ ); -#endif move16(); move16(); p1 -= ( NB_POS_FCB_2T + 1 ); p0 -= ( NB_POS_FCB_2T + 1 ); } -#ifdef BASOP_NOGLOB *p1 = round_fx_o( L_cor, &Overflow ); // Q9 -#else - *p1 = round_fx( L_cor ); -#endif pos -= NB_POS_FCB_2T; move16(); pos2--; @@ -244,17 +222,9 @@ void acelp_2t32_fx( FOR( i1 = 1; i1 < L_SUBFR; i1 += STEP ) { ps2 = add( ps1, dn_p[i1] ); -#ifdef BASOP_NOGLOB alp2 = add_o( alp1, add_o( *p1++, *p2++, &Overflow ), &Overflow ); -#else - alp2 = add( alp1, add( *p1++, *p2++ ) ); -#endif sq = mult( ps2, ps2 ); -#ifdef BASOP_NOGLOB s = L_msu_o( L_mult( alpk, sq ), psk, alp2, &Overflow ); -#else - s = L_msu( L_mult( alpk, sq ), psk, alp2 ); -#endif IF( s > 0 ) { psk = sq; @@ -365,19 +335,11 @@ void acelp_2t32_ivas_fx( L_cor = L_deposit_h( 1 ); FOR( i = 0; i < NB_POS_FCB_2T; i++ ) { -#ifdef BASOP_NOGLOB L_cor = L_mac_o( L_cor, *ptr_h1, *ptr_h1, &Overflow ); -#else - L_cor = L_mac( L_cor, *ptr_h1, *ptr_h1 ); -#endif ptr_h1++; *p1-- = extract_h( L_cor ); move16(); /*Q9 Q7*/ -#ifdef BASOP_NOGLOB L_cor = L_mac_o( L_cor, *ptr_h1, *ptr_h1, &Overflow ); -#else - L_cor = L_mac( L_cor, *ptr_h1, *ptr_h1 ); -#endif ptr_h1++; *p0-- = extract_h( L_cor ); move16(); /*Q9 Q7*/ @@ -418,31 +380,17 @@ void acelp_2t32_ivas_fx( L_cor = L_mult( *ptr_h1++, *ptr_h2++ ); // Q25 FOR( i = k; i < NB_POS_FCB_2T - 1; i++ ) { -#ifdef BASOP_NOGLOB *p1 = round_fx_o( L_cor, &Overflow ); // Q9 L_cor = L_mac_o( L_cor, *ptr_h1++, *ptr_h2++, &Overflow ); -#else - *p1 = round_fx( L_cor ); - L_cor = L_mac( L_cor, *ptr_h1++, *ptr_h2++ ); -#endif -#ifdef BASOP_NOGLOB *p0 = round_fx_o( L_cor, &Overflow ); // Q9 L_cor = L_mac_o( L_cor, *ptr_h1++, *ptr_h2++, &Overflow ); -#else - *p0 = round_fx( L_cor ); - L_cor = L_mac( L_cor, *ptr_h1++, *ptr_h2++ ); -#endif move16(); move16(); p1 -= ( NB_POS_FCB_2T + 1 ); p0 -= ( NB_POS_FCB_2T + 1 ); } -#ifdef BASOP_NOGLOB *p1 = round_fx_o( L_cor, &Overflow ); -#else - *p1 = round_fx( L_cor ); -#endif pos -= NB_POS_FCB_2T; move16(); pos2 = sub( pos2, 1 ); @@ -546,17 +494,9 @@ void acelp_2t32_ivas_fx( FOR( i1 = 1; i1 < L_SUBFR; i1 += STEP ) { ps2 = add( ps1, dn_p[i1] ); -#ifdef BASOP_NOGLOB alp2 = add_o( alp1, add_o( *p1++, *p2++, &Overflow ), &Overflow ); -#else - alp2 = add( alp1, add( *p1++, *p2++ ) ); -#endif sq = mult( ps2, ps2 ); -#ifdef BASOP_NOGLOB s = L_msu_o( L_mult( alpk, sq ), psk, alp2, &Overflow ); -#else - s = L_msu( L_mult( alpk, sq ), psk, alp2 ); -#endif IF( s > 0 ) { psk = sq; diff --git a/lib_enc/cod4t64_fast.c b/lib_enc/cod4t64_fast.c index 93bcc1ce3ffe44ca66128e467dbf5cf03d4c98ac..e4c8124e66180c47e61f9515c82824ba5968f208 100644 --- a/lib_enc/cod4t64_fast.c +++ b/lib_enc/cod4t64_fast.c @@ -901,7 +901,7 @@ void acelp_fast_fx( move16(); } - Copy( y_tmp, y, L_subfr ); // q_H + Copy_Scale_sig( y_tmp, y, L_subfr, sub( 9, q_H ) ); // y in Q9 skip_track_max = skip_track[q]; move16(); } diff --git a/lib_enc/cod_ace_fx.c b/lib_enc/cod_ace_fx.c index bea89f5116e8d52f17b82f8a096f21f546042360..e701b8e466b946d9c4c6cbc739f4a77476e558ca 100644 --- a/lib_enc/cod_ace_fx.c +++ b/lib_enc/cod_ace_fx.c @@ -354,11 +354,7 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision * hLPDmem->mem_w0 = sub( xn[L_SUBFR - 1], round_fx( L_shl( Ltmp, 1 ) ) ); move16(); BASOP_SATURATE_WARNING_OFF_EVS; -#ifdef BASOP_NOGLOB hLPDmem->mem_w0 = shr_sat( hLPDmem->mem_w0, shift ); /*Qnew-1*/ -#else - hLPDmem->mem_w0 = shr( hLPDmem->mem_w0, shift ); /*Qnew-1*/ -#endif move16(); BASOP_SATURATE_WARNING_ON_EVS; @@ -397,31 +393,13 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision * 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] ); -#ifdef BASOP_NOGLOB exc2[i] = round_fx_sat( L_shl_o( Ltmp, 1, &Overflow ) ); -#else - BASOP_SATURATE_WARNING_OFF_EVS - exc2[i] = round_fx( L_shl( Ltmp, 1 ) ); - BASOP_SATURATE_WARNING_ON_EVS -#endif move16(); Ltmp2 = Mpy_32_16_1( gain_code, code[i] ); -#ifdef BASOP_NOGLOB Ltmp2 = L_shl_sat( Ltmp2, Q_new_p5 ); Ltmp = L_add_sat( Ltmp, Ltmp2 ); -#else - Ltmp2 = L_shl( Ltmp2, Q_new_p5 ); - Ltmp = L_add( Ltmp, Ltmp2 ); -#endif -#ifdef BASOP_NOGLOB Ltmp = L_shl_o( Ltmp, 1, &Overflow ); /* saturation can occur here */ exc[i + i_subfr] = round_fx_o( Ltmp, &Overflow ); -#else - 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 ); -#endif move16(); } #endif diff --git a/lib_enc/cod_tcx.c b/lib_enc/cod_tcx.c index aaa7e4e2e13f01ee0207daa1bad4b3d412ba7824..963cc16506ba70549c08e644f989d7c1d85d9421 100644 --- a/lib_enc/cod_tcx.c +++ b/lib_enc/cod_tcx.c @@ -290,7 +290,7 @@ void TNSAnalysisStereo_fx( Word16 maxEnergyChange_fx; maxEnergyChange_fx = mac_r( L_mult( GetTCXMaxenergyChange_ivas_fx( sts[0]->hTranDet, isTCX10, NSUBBLOCKS, 3 ), 16384 ), GetTCXMaxenergyChange_ivas_fx( sts[1]->hTranDet, isTCX10, NSUBBLOCKS, 3 ), 16384 ); - IF( GE_16( maxEnergyChange_fx, pTnsParameters[0]->minEnergyChange ) ) + IF( GE_16( maxEnergyChange_fx, shl( pTnsParameters[0]->minEnergyChange, Q3 - Q7 ) ) ) { sts[0]->hTcxEnc->tnsData[k].nFilters = add( sts[0]->hTcxEnc->tnsData[k].nFilters, 1 ); move16(); @@ -552,7 +552,7 @@ void TNSAnalysisStereo_fx( { Word16 maxEnergyChange_fx = GetTCXMaxenergyChange_ivas_fx( sts[ch]->hTranDet, isTCX10, NSUBBLOCKS, 3 ); - IF( GE_16( maxEnergyChange_fx, pTnsParameters->minEnergyChange ) ) + IF( GE_16( maxEnergyChange_fx, shl( pTnsParameters->minEnergyChange, Q3 - Q7 ) ) ) { sts[ch]->hTcxEnc->tnsData[k].nFilters = add( sts[ch]->hTcxEnc->tnsData[k].nFilters, 1 ); move16(); diff --git a/lib_enc/cod_tcx_fx.c b/lib_enc/cod_tcx_fx.c index ea0468587fe90c936f4a5f3acc203d2befc2b087..b2fe04ce13f5fcb65f8a7abd6a47bba15f06a1c1 100644 --- a/lib_enc/cod_tcx_fx.c +++ b/lib_enc/cod_tcx_fx.c @@ -69,11 +69,7 @@ void HBAutocorrelation_fx( FOR( i = 0; i < len; i += 1 ) { /* Test Addition */ -#ifdef BASOP_NOGLOB /* Critical Overflow, all operations below needs to check for Overflow if we want to ensure bit exactness */ L_mac0_o( L_sum, y[i], y[i], &Overflow ); -#else /* BASOP_NOGLOB */ - L_mac0( L_sum, y[i], y[i] ); -#endif /* BASOP_NOGLOB */ IF( Overflow ) { Overflow = 0; @@ -82,53 +78,29 @@ void HBAutocorrelation_fx( move16(); L_tmp = L_msu0( 0, y[i], y[i] ); L_tmp = L_shr( L_tmp, 1 ); -#ifdef BASOP_NOGLOB /* Only the sub can overflow if the current L_sum is negative and already close to MIN */ L_sum = L_add( L_shr( L_sub_o( L_sum, 1, &Overflow ), 1 ), 1 ); -#else - L_sum = L_add( L_shr( L_sub( L_sum, 1 ), 1 ), 1 ); -#endif -#ifdef BASOP_NOGLOB /* Critical Overflow */ L_sum = L_sub_o( L_sum, L_tmp, &Overflow ); -#else - L_sum = L_sub( L_sum, L_tmp ); -#endif FOR( j = i + 1; j < len; j++ ) { L_tmp = L_msu0( 0, y[j], y[j] ); L_tmp = L_shr( L_tmp, shift ); /* Test Addition */ -#ifdef BASOP_NOGLOB /* Critical Overflow */ L_sub_o( L_sum, L_tmp, &Overflow ); -#else /* BASOP_NOGLOB */ - L_sub( L_sum, L_tmp ); -#endif /* BASOP_NOGLOB */ IF( Overflow ) { Overflow = 0; move32(); shift = add( shift, 1 ); L_tmp = L_shr( L_tmp, 1 ); -#ifdef BASOP_NOGLOB /* Critical Overflow */ L_sum = L_add( L_shr( L_sub_o( L_sum, 1, &Overflow ), 1 ), 1 ); -#else - L_sum = L_add( L_shr( L_sub( L_sum, 1 ), 1 ), 1 ); -#endif } -#ifdef BASOP_NOGLOB /* Critical Overflow */ L_sum = L_sub_o( L_sum, L_tmp, &Overflow ); -#else - L_sum = L_sub( L_sum, L_tmp ); -#endif } BREAK; } /* Perform Addition */ -#ifdef BASOP_NOGLOB /* Critical Overflow */ L_sum = L_mac0_o( L_sum, y[i], y[i], &Overflow ); -#else - L_sum = L_mac0( L_sum, y[i], y[i] ); -#endif } /* scale signal to avoid overflow in autocorrelation */ @@ -1745,6 +1717,10 @@ 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++ ) { Encoder_State *st = sts[ch]; @@ -2313,11 +2289,7 @@ void QuantizeSpectrum_fx( tmp1 = BASOP_Util_Divide1616_Scale( sqTargetBits, tmp1, &tmp2 ); BASOP_SATURATE_WARNING_OFF_EVS -#ifdef BASOP_NOGLOB hTcxEnc->tcx_target_bits_fac = shl_o( mult( hTcxEnc->tcx_target_bits_fac, tmp1 ), tmp2, &Overflow ); -#else /* BASOP_NOGLOB */ - hTcxEnc->tcx_target_bits_fac = shl( mult( hTcxEnc->tcx_target_bits_fac, tmp1 ), tmp2 ); -#endif /* BASOP_NOGLOB */ move16(); BASOP_SATURATE_WARNING_ON_EVS @@ -2437,11 +2409,7 @@ void QuantizeSpectrum_fx( } /* Limit low sqGain for avoiding saturation of the gain quantizer*/ -#ifdef BASOP_NOGLOB tmp1 = mult_r( shl_o( L_spec, 5, &Overflow ), 26214 /*128.f/NORM_MDCT_FACTOR Q15*/ ); -#else - tmp1 = mult_r( shl( L_spec, 5 ), 26214 /*128.f/NORM_MDCT_FACTOR Q15*/ ); -#endif s = 15 - 5 - 7; IF( L_spec >= 1024 ) { @@ -2455,11 +2423,7 @@ void QuantizeSpectrum_fx( IF( tmp2 >= 0 ) { BASOP_SATURATE_WARNING_OFF_EVS; -#ifdef BASOP_NOGLOB tmp2 = sub_sat( sqGain, shr_sat( tmp1, tmp2 ) ); -#else - tmp2 = sub( sqGain, shr( tmp1, tmp2 ) ); -#endif BASOP_SATURATE_WARNING_ON_EVS; } ELSE @@ -2512,11 +2476,7 @@ void QuantizeSpectrum_fx( spectrum[i] = L_mult( sqQ[i], 1 << ( 30 - SPEC_EXP_DEC ) ); move32(); /* noise filling seed */ -#ifdef BASOP_NOGLOB tmp32 = L_macNs_co( tmp32, abs_s( sqQ[i] ), i, &Carry, &Overflow ); -#else /* BASOP_NOGLOB */ - tmp32 = L_macNs( tmp32, abs_s( sqQ[i] ), i ); -#endif /* BASOP_NOGLOB */ } *spectrum_e = SPEC_EXP_DEC; move16(); @@ -3072,11 +3032,7 @@ void QuantizeSpectrum_fx( /* add part of current sub-window overlapping with previous window */ FOR( i = 0; i < L_ola; i++ ) { -#ifdef BASOP_NOGLOB tmpP16[i] = add_sat( tmpP16[i], win[i] ); -#else - tmpP16[i] = add( tmpP16[i], win[i] ); -#endif move16(); } /* copy new sub-window region not overlapping with previous window */ @@ -3154,11 +3110,7 @@ void QuantizeSpectrum_fx( /* add part of current sub-window overlapping with previous window */ FOR( i = 0; i < L_ola; i++ ) { -#ifdef BASOP_NOGLOB tmpP16[i] = add_sat( tmpP16[i], win[i] ); -#else - tmpP16[i] = add( tmpP16[i], win[i] ); -#endif move16(); } @@ -3284,11 +3236,7 @@ void QuantizeSpectrum_fx( /* scale output */ FOR( i = 0; i < L_frame; i++ ) { -#ifdef BASOP_NOGLOB xn_buf16[i] = shr_o( xn_buf16[i], Q, &Overflow ); -#else /* BASOP_NOGLOB */ - xn_buf16[i] = shr( xn_buf16[i], Q ); -#endif /* BASOP_NOGLOB */ move16(); } @@ -3348,11 +3296,7 @@ void QuantizeSpectrum_fx( tmp1 = sub( overlap, hTcxCfg->tcx_mdct_window_min_length ); FOR( i = 0; i < tmp1; i++ ) { -#ifdef BASOP_NOGLOB xn_buf16[i] = shl_sat( add_sat( xn_buf16[i], shr_sat( hTcxEnc->old_out_fx[i + nz], tmp2 ) ), TCX_IMDCT_HEADROOM ); -#else - xn_buf16[i] = shl( add( xn_buf16[i], shr( hTcxEnc->old_out_fx[i + nz], tmp2 ) ), TCX_IMDCT_HEADROOM ); -#endif move16(); } @@ -3361,31 +3305,19 @@ void QuantizeSpectrum_fx( FOR( ; i < tmp1; i++ ) { tmp3 = mult_r( shr( hTcxEnc->old_out_fx[i + nz], tmp2 ), hTcxCfg->tcx_mdct_window_minimum[i - overlap + hTcxCfg->tcx_mdct_window_min_length].v.re ); -#ifdef BASOP_NOGLOB xn_buf16[i] = shl_sat( add_sat( xn_buf16[i], tmp3 ), TCX_IMDCT_HEADROOM ); -#else - xn_buf16[i] = shl( add( xn_buf16[i], tmp3 ), TCX_IMDCT_HEADROOM ); -#endif move16(); } FOR( ; i < overlap; i++ ) { tmp3 = mult_r( shr( hTcxEnc->old_out_fx[i + nz], tmp2 ), hTcxCfg->tcx_mdct_window_minimum[overlap - 1 - i].v.im ); -#ifdef BASOP_NOGLOB xn_buf16[i] = shl_sat( add_sat( xn_buf16[i], tmp3 ), TCX_IMDCT_HEADROOM ); -#else - xn_buf16[i] = shl( add( xn_buf16[i], tmp3 ), TCX_IMDCT_HEADROOM ); -#endif move16(); } FOR( ; i < L_frame; i++ ) { -#ifdef BASOP_NOGLOB xn_buf16[i] = shl_sat( xn_buf16[i], TCX_IMDCT_HEADROOM ); -#else - xn_buf16[i] = shl( xn_buf16[i], TCX_IMDCT_HEADROOM ); -#endif move16(); } } @@ -3415,11 +3347,7 @@ void QuantizeSpectrum_fx( BASOP_SATURATE_WARNING_OFF_EVS; FOR( i = 0; i < overlap; i++ ) { -#ifdef BASOP_NOGLOB xn_buf16[i] = shl_sat( add( xn_buf16[i], hTcxEnc->Txnq[i] ), TCX_IMDCT_HEADROOM ); -#else - xn_buf16[i] = shl( add( xn_buf16[i], hTcxEnc->Txnq[i] ), TCX_IMDCT_HEADROOM ); -#endif move16(); } @@ -3427,11 +3355,7 @@ void QuantizeSpectrum_fx( { FOR( ; i < L_frame; i++ ) { -#ifdef BASOP_NOGLOB xn_buf16[i] = shl_sat( xn_buf16[i], TCX_IMDCT_HEADROOM ); -#else - xn_buf16[i] = shl( xn_buf16[i], TCX_IMDCT_HEADROOM ); -#endif move16(); } } @@ -3445,11 +3369,7 @@ void QuantizeSpectrum_fx( BASOP_SATURATE_WARNING_OFF_EVS; FOR( i = 0; i < L_frame; i++ ) { -#ifdef BASOP_NOGLOB xn_buf16[i] = shl_o( xn_buf16[i], TCX_IMDCT_HEADROOM, &Overflow ); -#else /* BASOP_NOGLOB */ - xn_buf16[i] = shl( xn_buf16[i], TCX_IMDCT_HEADROOM ); -#endif move16(); } BASOP_SATURATE_WARNING_ON_EVS; @@ -3953,11 +3873,7 @@ void QuantizeTCXSpectrum_fx( tmp1 = BASOP_Util_Divide1616_Scale( sqTargetBits, tmp1, &tmp2 ); BASOP_SATURATE_WARNING_OFF_EVS -#ifdef BASOP_NOGLOB hTcxEnc->tcx_target_bits_fac = shl_o( mult( hTcxEnc->tcx_target_bits_fac, tmp1 ), tmp2, &Overflow ); -#else /* BASOP_NOGLOB */ - hTcxEnc->tcx_target_bits_fac = shl( mult( hTcxEnc->tcx_target_bits_fac, tmp1 ), tmp2 ); -#endif /* BASOP_NOGLOB */ BASOP_SATURATE_WARNING_ON_EVS if ( GT_16( hTcxEnc->tcx_target_bits_fac, 20480 /*1.25 in Q14*/ ) ) @@ -4240,11 +4156,7 @@ void QuantizeTCXSpectrum_fx( spectrum_fx[i] = L_mult( sqQ[i], 1 << ( 30 - SPEC_EXP_DEC ) ); move32(); /* noise filling seed */ -#ifdef BASOP_NOGLOB tmp32 = L_macNs_co( tmp32, abs_s( sqQ[i] ), i, &Carry, &Overflow ); -#else /* BASOP_NOGLOB */ - tmp32 = L_macNs( tmp32, abs_s( sqQ[i] ), i ); -#endif /* BASOP_NOGLOB */ } *spectrum_e = SPEC_EXP_DEC; move16(); @@ -4284,13 +4196,22 @@ void QuantizeTCXSpectrum_fx( low_complexiety = 1; move16(); } - tcx_arith_encode_envelope_fx( spectrum_fx, spectrum_e, hm_cfg->indexBuffer, L_frame, L_spec, st, Aqind, sqTargetBits, sqQ, tmp8, prm_hm, /* HM parameter area */ LtpPitchLag, &sqBits, &signaling_bits, nf_seed, low_complexiety ); + tcx_arith_encode_envelope_ivas_fx( spectrum_fx, spectrum_e, hm_cfg->indexBuffer, L_frame, L_spec, st, Aqind, sqTargetBits, sqQ, tmp8, prm_hm, /* HM parameter area */ LtpPitchLag, &sqBits, &signaling_bits, low_complexiety ); sqTargetBits = sub( sqTargetBits, signaling_bits ); *prm_target = sqTargetBits; move16(); /* Noise filling seed */ + Word64 seed = 0; + move64(); + FOR( i = 0; i < noiseFillingBorder; ++i ) + { + /* *nf_seed += (int16_t) ( abs( (int16_t) spectrum[i] ) * i * 2 ); */ + seed = W_mac_32_32( seed, L_abs( spectrum_fx[i] ), i ); // exp: spectrum_e + } + *nf_seed = extract_l( W_extract_l( W_shr( seed, sub( 31, *spectrum_e ) ) ) ); // Q0 + move16(); } *hm_active = prm_hm[0]; @@ -4799,7 +4720,7 @@ void InternalTCXDecoder_fx( IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) { - Copy_Scale_sig_16_32( A_fx, A_fx32, M + 1, add( norm_s( A_fx[0] ), 2 ) ); // Copying the Word16 A_fx buffer to a temporary Word32 buffer in Q16 + Copy_Scale_sig_16_32_DEPREC( A_fx, A_fx32, M + 1, add( norm_s( A_fx[0] ), 2 ) ); // Copying the Word16 A_fx buffer to a temporary Word32 buffer in Q16 q_spec = sub( 31, *spectrum_e ); sns_interpolate_scalefactors_fx( sns_interpolated_scalefactors_fx, A_fx32, DEC ); @@ -5038,11 +4959,7 @@ void InternalTCXDecoder_fx( /* add part of current sub-window overlapping with previous window */ FOR( i = 0; i < L_ola; i++ ) { -#ifdef BASOP_NOGLOB tmpP16[i] = add_sat( tmpP16[i], win[i] ); -#else - tmpP16[i] = add( tmpP16[i], win[i] ); -#endif move16(); } /* copy new sub-window region not overlapping with previous window */ @@ -5120,11 +5037,7 @@ void InternalTCXDecoder_fx( /* add part of current sub-window overlapping with previous window */ FOR( i = 0; i < L_ola; i++ ) { -#ifdef BASOP_NOGLOB tmpP16[i] = add_sat( tmpP16[i], win[i] ); -#else - tmpP16[i] = add( tmpP16[i], win[i] ); -#endif move16(); } @@ -5250,11 +5163,7 @@ void InternalTCXDecoder_fx( /* scale output */ FOR( i = 0; i < L_frame; i++ ) { -#ifdef BASOP_NOGLOB xn_buf16[i] = shr_o( xn_buf16[i], Q, &Overflow ); -#else /* BASOP_NOGLOB */ - xn_buf16[i] = shr( xn_buf16[i], Q ); -#endif /* BASOP_NOGLOB */ move16(); } @@ -5314,11 +5223,7 @@ void InternalTCXDecoder_fx( tmp1 = sub( overlap, st->hTcxCfg->tcx_mdct_window_min_length ); FOR( i = 0; i < tmp1; i++ ) { -#ifdef BASOP_NOGLOB xn_buf16[i] = shl_sat( add_sat( xn_buf16[i], shr_sat( hTcxEnc->old_out_fx[i + nz], tmp2 ) ), TCX_IMDCT_HEADROOM ); -#else - xn_buf16[i] = shl( add( xn_buf16[i], shr( hTcxEnc->old_out_fx[i + nz], tmp2 ) ), TCX_IMDCT_HEADROOM ); -#endif move16(); } @@ -5327,31 +5232,19 @@ void InternalTCXDecoder_fx( FOR( ; i < tmp1; i++ ) { tmp3 = mult_r( shr( hTcxEnc->old_out_fx[i + nz], tmp2 ), st->hTcxCfg->tcx_mdct_window_minimum[i - overlap + st->hTcxCfg->tcx_mdct_window_min_length].v.re ); -#ifdef BASOP_NOGLOB xn_buf16[i] = shl_sat( add_sat( xn_buf16[i], tmp3 ), TCX_IMDCT_HEADROOM ); -#else - xn_buf16[i] = shl( add( xn_buf16[i], tmp3 ), TCX_IMDCT_HEADROOM ); -#endif move16(); } FOR( ; i < overlap; i++ ) { tmp3 = mult_r( shr( hTcxEnc->old_out_fx[i + nz], tmp2 ), st->hTcxCfg->tcx_mdct_window_minimum[overlap - 1 - i].v.im ); -#ifdef BASOP_NOGLOB xn_buf16[i] = shl_sat( add_sat( xn_buf16[i], tmp3 ), TCX_IMDCT_HEADROOM ); -#else - xn_buf16[i] = shl( add( xn_buf16[i], tmp3 ), TCX_IMDCT_HEADROOM ); -#endif move16(); } FOR( ; i < L_frame; i++ ) { -#ifdef BASOP_NOGLOB xn_buf16[i] = shl_sat( xn_buf16[i], TCX_IMDCT_HEADROOM ); -#else - xn_buf16[i] = shl( xn_buf16[i], TCX_IMDCT_HEADROOM ); -#endif move16(); } } @@ -5381,11 +5274,7 @@ void InternalTCXDecoder_fx( BASOP_SATURATE_WARNING_OFF_EVS; FOR( i = 0; i < overlap; i++ ) { -#ifdef BASOP_NOGLOB xn_buf16[i] = shl_sat( add( xn_buf16[i], hTcxEnc->Txnq[i] ), TCX_IMDCT_HEADROOM ); -#else - xn_buf16[i] = shl( add( xn_buf16[i], hTcxEnc->Txnq[i] ), TCX_IMDCT_HEADROOM ); -#endif move16(); } @@ -5393,11 +5282,7 @@ void InternalTCXDecoder_fx( { FOR( ; i < L_frame; i++ ) { -#ifdef BASOP_NOGLOB xn_buf16[i] = shl_sat( xn_buf16[i], TCX_IMDCT_HEADROOM ); -#else - xn_buf16[i] = shl( xn_buf16[i], TCX_IMDCT_HEADROOM ); -#endif move16(); } } @@ -5411,11 +5296,7 @@ void InternalTCXDecoder_fx( BASOP_SATURATE_WARNING_OFF_EVS; FOR( i = 0; i < L_frame; i++ ) { -#ifdef BASOP_NOGLOB xn_buf16[i] = shl_o( xn_buf16[i], TCX_IMDCT_HEADROOM, &Overflow ); -#else /* BASOP_NOGLOB */ - xn_buf16[i] = shl( xn_buf16[i], TCX_IMDCT_HEADROOM ); -#endif move16(); } BASOP_SATURATE_WARNING_ON_EVS; diff --git a/lib_enc/cod_uv_fx.c b/lib_enc/cod_uv_fx.c index 22b51541755628ab629d9f73f3ca25292aa64637..8eccddc0b822eb5eaba77b68f5eba4f6f1cc3411 100644 --- a/lib_enc/cod_uv_fx.c +++ b/lib_enc/cod_uv_fx.c @@ -76,21 +76,13 @@ void gauss_L2_fx( } tmp16 = norm_l( tmp32 ); -#ifdef BASOP_NOGLOB g_corr->y1y1 = round_fx_sat( L_shl( tmp32, tmp16 ) ); -#else - g_corr->y1y1 = round_fx( L_shl( tmp32, tmp16 ) ); -#endif g_corr->y1y1_e = sub( 31 - 18, tmp16 ); move16(); move16(); tmp16 = norm_l( tmp32_2 ); -#ifdef BASOP_NOGLOB g_corr->y1y2 = round_fx_sat( L_shl( tmp32_2, tmp16 ) ); -#else - g_corr->y1y2 = round_fx( L_shl( tmp32_2, tmp16 ) ); -#endif g_corr->y1y2_e = sub( 31 - 18, tmp16 ); move16(); move16(); @@ -143,29 +135,43 @@ 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++ ) + { + tmp16 = shr( y11[i], 1 ); + 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 -#ifdef BASOP_NOGLOB 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 = round_fx( L_shl( tmp32, tmp16 ) ); -#endif 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/cor_shif_fx.c b/lib_enc/cor_shif_fx.c index 1120235052e6863cee83f1794f0cc5697929428a..28e837f486cc10b95f9852599f2b98002369c087 100644 --- a/lib_enc/cor_shif_fx.c +++ b/lib_enc/cor_shif_fx.c @@ -40,13 +40,9 @@ Word16 correlation_shift_fx( /* o : noise dependent f_Noise = L_Extract_lc( Ltmp, &e_Noise ); wtmp = extract_l( Pow2( 14, f_Noise ) ); /* Put 14 as exponent */ - e_Noise = sub( e_Noise, 14 ); /* Retreive exponent of wtmp */ - Ltmp = Mpy_32_16( 8, 837, wtmp ); /* 2.4492e-4(Q31) * exp(0.1596*totalNoise) */ -#ifdef BASOP_NOGLOB - Ltmp = L_shl_sat( Ltmp, add( e_Noise, 15 ) ); /* Result in Q31 */ -#else - Ltmp = L_shl( Ltmp, add( e_Noise, 15 ) ); /* Result in Q31 */ -#endif + e_Noise = sub( e_Noise, 14 ); /* Retreive exponent of wtmp */ + Ltmp = Mpy_32_16( 8, 837, wtmp ); /* 2.4492e-4(Q31) * exp(0.1596*totalNoise) */ + Ltmp = L_shl_sat( Ltmp, add( e_Noise, 15 ) ); /* Result in Q31 */ corr_shift_fx = round_fx( L_sub( Ltmp, 47244640 ) ); /* Represents corr_shift in Q15 */ } corr_shift_fx = s_min( corr_shift_fx, 16384 ); /* limit to 0.5 */ diff --git a/lib_enc/core_enc_init.c b/lib_enc/core_enc_init.c index e09166f8a2f6ec504872d09f44fce67d336c3608..e98956efeec2bcc8ace521c9862022011d4384f1 100644 --- a/lib_enc/core_enc_init.c +++ b/lib_enc/core_enc_init.c @@ -63,7 +63,10 @@ static void init_acelp_ivas_fx( Encoder_State *st, Word16 L_frame_old, Word16 sh void init_coder_ace_plus_ivas_fx( Encoder_State *st, /* i : Encoder state */ const Word32 last_total_brate, /* i : last total bitrate */ - const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) */ +#ifdef FIX_920_IGF_INIT_ERROR + const Word32 igf_brate, /* i : IGF configuration bitrate */ +#endif + const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) */ ) { TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; @@ -195,7 +198,11 @@ void init_coder_ace_plus_ivas_fx( test(); IF( st->igf && st->hIGFEnc != NULL ) { +#ifdef FIX_920_IGF_INIT_ERROR + IGFEncSetMode_ivas_fx( st->hIGFEnc, igf_brate, st->bwidth, st->element_mode, st->rf_mode ); +#else IGFEncSetMode_ivas_fx( st->hIGFEnc, st->total_brate, st->bwidth, st->element_mode, st->rf_mode ); +#endif } ELSE IF( st->hIGFEnc != NULL ) { @@ -412,13 +419,9 @@ static void init_tcx_ivas_fx( move16(); } -#ifdef BASOP_NOGLOB /*pit = pit_old * (float)st->L_frame/(float)L_frame_old;*/ pit = shl_sat( mult_r( pit_old, div_s( st->L_frame, shl( L_frame_old, 2 ) ) ), 2 ); /* Note : the saturation here that can happens when FS == 32kHz*/ -#else - pit = shl( mult_r( pit_old, div_s( st->L_frame, shl( L_frame_old, 2 ) ) ), 2 ); -#endif /* assert(pit <= st->L_frame);*/ hTcxEnc->tcxltp_pitch_int_past = pit; @@ -532,8 +535,8 @@ static void init_sig_buffers_ivas_fx( Encoder_State *st, const Word16 L_frame_ol Copy( st->old_wsp_fx, st->buf_wspeech_enc + st->L_frame + L_SUBFR - L_WSP_MEM, L_WSP_MEM ); // Copy_Scale_sig( st->old_wsp_fx, st->buf_wspeech_enc + st->L_frame + L_SUBFR - L_WSP_MEM, L_WSP_MEM, sub( st->prev_Q_new, st->prev_Q_old ) ); - - /*Resamp buffers needed only for ACELP*/ + st->exp_buf_wspeech_enc = st->exp_old_wsp; + move16(); /*Resamp buffers needed only for ACELP*/ IF( EQ_16( st->L_frame, L_FRAME16k ) ) { lerp( st->buf_wspeech_enc + st->L_frame + L_SUBFR - L_WSP_MEM, st->buf_wspeech_enc + st->L_frame + L_SUBFR - 310, 310, L_WSP_MEM ); @@ -822,12 +825,8 @@ static void init_acelp_ivas_fx( Encoder_State *st, Word16 L_frame_old, Word16 sh Copy( hLPDmem->mem_syn2, tmp_buf + 1, M ); deemph_fx( tmp_buf + 1, st->preemph_fac, M, &tmp ); Residu3_fx( Ap, tmp_buf + M, &tmp, 1, 1 ); -#ifdef BASOP_NOGLOB hLPDmem->mem_w0 = sub_sat( shr_sat( st->wspeech_enc[-1], shift ), tmp ); move16(); -#else - hLPDmem->mem_w0 = sub( shr( st->wspeech_enc[-1], shift ), tmp ); -#endif } } ELSE IF( ( NE_16( st->L_frame, L_frame_old ) ) ) @@ -989,7 +988,6 @@ static void init_modes_ivas_fx( move16(); } - /* TCX mode (TCX20 TCX10_10 or NO_TCX) */ if ( st->hTcxEnc != NULL ) { diff --git a/lib_enc/core_enc_init_fx.c b/lib_enc/core_enc_init_fx.c index 6638b4c338510d41eb2d2c62333841d05413fb79..f6b5b5984d61e51db4559eaf62c1f4ec2a63b8ae 100644 --- a/lib_enc/core_enc_init_fx.c +++ b/lib_enc/core_enc_init_fx.c @@ -420,13 +420,9 @@ static void init_tcx_fx( move16(); } -#ifdef BASOP_NOGLOB /*pit = pit_old * (float)st->L_frame/(float)L_frame_old;*/ pit = shl_sat( mult_r( pit_old, div_s( st->L_frame, shl( L_frame_old, 2 ) ) ), 2 ); -/* Note : the saturation here that can happens when FS == 32kHz*/ -#else - pit = shl( mult_r( pit_old, div_s( st->L_frame, shl( L_frame_old, 2 ) ) ), 2 ); -#endif + /* Note : the saturation here that can happens when FS == 32kHz*/ /* assert(pit <= st->L_frame);*/ hTcxEnc->tcxltp_pitch_int_past = pit; @@ -746,11 +742,7 @@ static void init_acelp_fx( Encoder_State *st, Word16 L_frame_old, const Word16 s Copy( hLPDmem->mem_syn2, tmp_buf + 1, M ); deemph_fx( tmp_buf + 1, st->preemph_fac, M, &tmp ); Residu3_fx( Ap, tmp_buf + M, &tmp, 1, 1 ); -#ifdef BASOP_NOGLOB hLPDmem->mem_w0 = sub_sat( shr_sat( st->wspeech_enc[-1], shift ), tmp ); -#else - hLPDmem->mem_w0 = sub( shr( st->wspeech_enc[-1], shift ), tmp ); -#endif move16(); } } diff --git a/lib_enc/core_enc_ol_fx.c b/lib_enc/core_enc_ol_fx.c index ee347543b87cf940ce5ed8b04041e788558d1f91..04857c334d7130aa8b298baaa0bdb78f8cd5e82e 100644 --- a/lib_enc/core_enc_ol_fx.c +++ b/lib_enc/core_enc_ol_fx.c @@ -554,11 +554,7 @@ void core_encode_openloop_fx( /*v_sub(lsf_uq_rf, lsf_q_1st_rf, lsf_q_d_rf, M);*/ FOR( i = 0; i < M; i++ ) { -#ifdef BASOP_NOGLOB lsf_q_d_rf[i] = shl_o( mult_r( sub_o( lsf_uq_rf[i], lsf_q_1st_rf[i], &Overflow ), 25600 ), 5, &Overflow ); -#else - lsf_q_d_rf[i] = shl( mult_r( sub( lsf_uq_rf[i], lsf_q_1st_rf[i] ), 25600 ), 5 ); -#endif move16(); /*input value is in Qx2.56, convert to Q6 to match table, quantizer table kept at Q6 to avoid losing precision */ /*Assume this difference data max range can be represented by Q6*/ @@ -777,13 +773,8 @@ static void closest_centroid_rf( tmpL = i_mult2( i, length ); FOR( j = 0; j < length; j++ ) { -#ifdef BASOP_NOGLOB tmp = sub_o( data[j], quantizer[tmpL + j], &Overflow ); L_tmp = L_mult_o( tmp, tmp, &Overflow ); -#else - tmp = sub( data[j], quantizer[tmpL + j] ); - L_tmp = L_mult( tmp, tmp ); -#endif werr_64 = W_mac_32_16( werr_64, L_tmp, weights[j] ); } werr = W_sat_m( werr_64 ); @@ -1114,11 +1105,7 @@ void core_acelp_tcx20_switching_fx( FOR( j = 0; j < L_SUBFR; j++ ) { -#ifdef BASOP_NOGLOB tmp32 = L_mac0_o( tmp32, st->wspeech_enc[i + j], st->wspeech_enc[i + j], &Overflow ); -#else - tmp32 = L_mac0( tmp32, st->wspeech_enc[i + j], st->wspeech_enc[i + j] ); -#endif } tmp32 = L_shr( BASOP_Util_Log2( tmp32 ), 9 ); /* 15Q16 */ tmp32 = L_add( tmp32, L_sub( 0x1F0000, L_shl( L_deposit_h( add( Q_new, sub( shift, 1 ) ) ), 1 ) ) ); /* wspeech_enc scaling */ @@ -1136,11 +1123,7 @@ void core_acelp_tcx20_switching_fx( tcx_snr = L_shl( Mpy_32_16_1( tcx_snr, 0x6054 ), 2 ); /* 0x6054 -> 10/log2(10) (2Q13) */ BASOP_SATURATE_WARNING_OFF_EVS -#ifdef BASOP_NOGLOB snr_tcx = round_fx_o( L_shl_o( tcx_snr, 8, &Overflow ), &Overflow ); /* 7Q8 */ -#else /* BASOP_NOGLOB */ - snr_tcx = round_fx( L_shl( tcx_snr, 8 ) ); /* 7Q8 */ -#endif /* BASOP_NOGLOB */ BASOP_SATURATE_WARNING_ON_EVS /*--------------------------------------------------------------* @@ -1174,19 +1157,11 @@ void core_acelp_tcx20_switching_fx( FOR( j = 0; j < L_SUBFR; j++ ) { -#ifdef BASOP_NOGLOB signal = L_mac0_o( signal, st->wspeech_enc[i + j], st->wspeech_enc[i + j], &Overflow ); tmp16 = round_fx_o( L_shl_o( Mpy_32_16_r( gain, st->wspeech_enc[i + j - T0] ), 15, &Overflow ), &Overflow ); tmp16 = sub_o( st->wspeech_enc[i + j], tmp16, &Overflow ); noise = L_mac0_o( noise, tmp16, tmp16, &Overflow ); -#else - signal = L_mac0( signal, st->wspeech_enc[i + j], st->wspeech_enc[i + j] ); - - tmp16 = round_fx( L_shl( Mpy_32_16_r( gain, st->wspeech_enc[i + j - T0] ), 15 ) ); - tmp16 = sub( st->wspeech_enc[i + j], tmp16 ); - noise = L_mac0( noise, tmp16, tmp16 ); -#endif } /* Assume always 4 sub frames. */ /*assert( (st->L_frame / L_SUBFR) == 4);*/ @@ -1239,16 +1214,8 @@ void core_acelp_tcx20_switching_fx( test(); if ( ( GT_16( snr_acelp, snr_tcx ) ) && ( LT_16( snr_acelp, add( snr_tcx, 512 /*2.0f Q8*/ ) ) ) && -#ifdef BASOP_NOGLOB ( LT_16( add_o( st->prevTempFlatness_fx, currFlatness, &Overflow ), 416 /*3.25f Q7*/ ) || EQ_16( stab_fac, 0x7fff /*1 Q15*/ ) || -#else /* BASOP_NOGLOB */ - ( LT_16( add( st->prevTempFlatness_fx, currFlatness ), 416 /*3.25f Q7*/ ) || EQ_16( stab_fac, 0x7fff ) || -#endif -#ifdef BASOP_NOGLOB ( EQ_32( st->sr_core, INT_FS_12k8 ) && EQ_16( st->sp_aud_decision0, 1 ) && LT_16( add_sat( st->prevTempFlatness_fx, currFlatness ), 2560 /*20.f Q7*/ ) ) ) && -#else - ( EQ_32( st->sr_core, INT_FS_12k8 ) && EQ_16( st->sp_aud_decision0, 1 ) && LT_16( add( st->prevTempFlatness_fx, currFlatness ), 2560 /*20.f Q7*/ ) ) ) && -#endif ( LE_16( st->acelpFramesCount, 6 ) ) ) { dsnr = -512 /*-2.0f Q8*/; @@ -1261,11 +1228,7 @@ void core_acelp_tcx20_switching_fx( test(); if ( ( LT_16( snr_acelp, snr_tcx ) ) && ( GT_16( snr_acelp, sub( snr_tcx, 512 /*2.0f Q8*/ ) ) ) && -#ifdef BASOP_NOGLOB ( GT_16( add_sat( st->prevTempFlatness_fx, currFlatness ), 416 /*3.25f Q7*/ ) ) && -#else - ( GT_16( add( st->prevTempFlatness_fx, currFlatness ), 416 /*3.25f Q7*/ ) ) && -#endif ( GE_16( st->acelpFramesCount, 6 ) ) ) { dsnr = 512 /*2.0f Q8*/; diff --git a/lib_enc/core_enc_switch.c b/lib_enc/core_enc_switch.c index e5c3903a1789031ba9481c8f483235735965d117..b6f723c2b7dc540a1c204eb613842d4be99b98d7 100644 --- a/lib_enc/core_enc_switch.c +++ b/lib_enc/core_enc_switch.c @@ -229,7 +229,11 @@ void core_coder_mode_switch_ivas_fx( Scale_sig( st->old_inp_12k8_fx, L_INP_MEM, shift ); st->exp_old_inp_12k8 = sub( st->exp_old_inp_12k8, shift ); move16(); +#ifdef FIX_920_IGF_INIT_ERROR + init_coder_ace_plus_ivas_fx( st, last_total_brate, st->total_brate, MCT_flag ); +#else init_coder_ace_plus_ivas_fx( st, last_total_brate, MCT_flag ); +#endif if ( st->hLPDmem != NULL ) { st->hLPDmem->q_lpd_old_exc = st->prev_Q_new; diff --git a/lib_enc/core_switching_enc.c b/lib_enc/core_switching_enc.c index 1b69de26d8a6fcfbcc65d8b07999bf079d6e867d..67c7a552fe18003cab02873410d4dd97b35b78b5 100644 --- a/lib_enc/core_switching_enc.c +++ b/lib_enc/core_switching_enc.c @@ -418,6 +418,10 @@ 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 ) ) { @@ -427,7 +431,9 @@ void core_switching_pre_enc_ivas_fx( move16(); } hBWE_FD->EnergyLF_fx = 0; + hBWE_FD->EnergyLF_exp = 0; move32(); + move16(); hBWE_FD->prev_L_swb_norm1 = 8; move16(); /*8.0 in Q0 */ st_fx->EnergyLT_fx_exp = 30; diff --git a/lib_enc/corr_xh_fx.c b/lib_enc/corr_xh_fx.c index 8a1c8c483903fcce7a46e09de2ab947077822b88..51165d141e93973a92e5c45de7c4a803f7c80075 100644 --- a/lib_enc/corr_xh_fx.c +++ b/lib_enc/corr_xh_fx.c @@ -47,11 +47,7 @@ void corr_xh_fx( L_tmp = L_mac( 1L, x[i], h[0] ); /* 1 -> to avoid null dn[] Qx+15*/ FOR( j = i; j < L_SUBFR - 1; j++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_mac_o( L_tmp, x[j + 1], h[j + 1 - i], &Overflow ); /*Qx+15*/ -#else - L_tmp = L_mac( L_tmp, x[j + 1], h[j + 1 - i] ); -#endif } y32[i] = L_tmp; /*Qx+15*/ @@ -61,13 +57,8 @@ void corr_xh_fx( } /* tot += 3*max / 8 */ L_maxloc = L_shr( L_maxloc, 2 ); -#ifdef BASOP_NOGLOB L_tot = L_add_o( L_tot, L_maxloc, &Overflow ); /* +max/4 */ L_tot = L_add_o( L_tot, L_shr( L_maxloc, 1 ), &Overflow ); /* +max/8 */ -#else - L_tot = L_add( L_tot, L_maxloc ); /* +max/4 */ - L_tot = L_add( L_tot, L_shr( L_maxloc, 1 ) ); /* +max/8 */ -#endif } /* Find the number of right shifts to do on y32[] so that */ @@ -107,11 +98,7 @@ void corr_hh_ivas_fx( L_tmp = L_mac( 1L, shr( h[i], 3 ), shr( h[0], 3 ) ); /* 1 -> to avoid null dn[] */ // 2*(15 - norm_s(h[0]) -3) - 1 FOR( j = i; j < L_subfr - 1; j++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_mac_o( L_tmp, shr( h[j + 1], 3 ), shr( h[j + 1 - i], 3 ), &Overflow ); // 2*(15 - norm_s(h[0]) -3) - 1 -#else - L_tmp = L_mac( L_tmp, x[j + 1], h[j + 1 - i] ); -#endif } y32[i] = L_tmp; // 2*(15 - norm_s(h[0]) -3) - 1 @@ -121,13 +108,8 @@ void corr_hh_ivas_fx( } /* tot += 3*max / 8 */ L_maxloc = L_shr( L_maxloc, 2 ); -#ifdef BASOP_NOGLOB L_tot = L_add_o( L_tot, L_maxloc, &Overflow ); /* +max/4 */ L_tot = L_add_o( L_tot, L_shr( L_maxloc, 1 ), &Overflow ); /* +max/8 */ -#else - L_tot = L_add( L_tot, L_maxloc ); /* +max/4 */ - L_tot = L_add( L_tot, L_shr( L_maxloc, 1 ) ); /* +max/8 */ -#endif } /* Find the number of right shifts to do on y32[] so that */ @@ -173,11 +155,7 @@ void corr_xh_ivas_fx( L_tmp = L_mac( 0, x[i], h[0] ); // Qx+(15 - norm_s(h[0])) FOR( j = i; j < L_subfr - 1; j++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_mac_o( L_tmp, x[j + 1], h[j + 1 - i], &Overflow ); // Qx+(15 - norm_s(h[0])) -#else - L_tmp = L_mac( L_tmp, x[j + 1], h[j + 1 - i] ); -#endif } y32[i] = L_tmp; // Qx+(15 - norm_s(h[0])) @@ -187,13 +165,8 @@ void corr_xh_ivas_fx( } /* tot += 3*max / 8 */ L_maxloc = L_shr( L_maxloc, 2 ); -#ifdef BASOP_NOGLOB L_tot = L_add_o( L_tot, L_maxloc, &Overflow ); /* +max/4 */ L_tot = L_add_o( L_tot, L_shr( L_maxloc, 1 ), &Overflow ); /* +max/8 */ -#else - L_tot = L_add( L_tot, L_maxloc ); /* +max/4 */ - L_tot = L_add( L_tot, L_shr( L_maxloc, 1 ) ); /* +max/8 */ -#endif } /* Find the number of right shifts to do on y32[] so that */ diff --git a/lib_enc/decision_matrix_enc_fx.c b/lib_enc/decision_matrix_enc_fx.c index 2ebb7289a2196a79839f2a2021cec8d13b32f608..3624cf37463b4f56b24b40fb5660b567a406ced2 100644 --- a/lib_enc/decision_matrix_enc_fx.c +++ b/lib_enc/decision_matrix_enc_fx.c @@ -386,6 +386,21 @@ void decision_matrix_enc_fx( move16(); } +#ifdef NONBE_FIX_GSC_BSTR + /*-----------------------------------------------------------------* + * set inactive coder_type flag in ACELP core + *-----------------------------------------------------------------*/ + + st_fx->inactive_coder_type_flag = 0; /* AVQ by default */ + move16(); + + if ( LE_32( st_fx->total_brate, MAX_GSC_INACTIVE_BRATE ) ) + { + st_fx->inactive_coder_type_flag = 1; /* GSC */ + move16(); + } + +#endif return; } diff --git a/lib_enc/detect_transient_fx.c b/lib_enc/detect_transient_fx.c index c4dbc6fe71357024ffcb49b4659f0b10cee8c14c..a3dba9d2773017ce219ccea36bd01c66a3d7751b 100644 --- a/lib_enc/detect_transient_fx.c +++ b/lib_enc/detect_transient_fx.c @@ -69,30 +69,15 @@ static void hp_filter_fx( /*y[0] = 0.4931f * *oldy + 0.7466f*(x[0] - *oldx); */ -#ifdef BASOP_NOGLOB L_tmp = L_mult( sub_o( x[0], *oldx, &Overflow ), 24465 /*0.7466f in Q15*/ ); /*Q_new+16 */ -#else /* BASOP_NOGLOB */ - L_tmp = L_mult( sub( x[0], *oldx ), 24465 ); /*Q_new+16 */ -#endif /* BASOP_NOGLOB */ -#ifdef BASOP_NOGLOB - L_tmp = L_mac_sat( L_tmp, *oldy, 16158 /*0.4931f in Q15*/ ); /*Q_new+16 */ - y[0] = round_fx_sat( L_tmp ); /*Q_new */ -#else - L_tmp = L_mac( L_tmp, *oldy, 16158 ); /*Q_new+16 */ - y[0] = round_fx( L_tmp ); /*Q_new */ -#endif + L_tmp = L_mac_sat( L_tmp, *oldy, 16158 /*0.4931f in Q15*/ ); /*Q_new+16 */ + y[0] = round_fx_sat( L_tmp ); /*Q_new */ FOR( i = 1; i < L; i++ ) { /*y[i] = 0.4931f*y[i-1] + 0.7466f*(x[i] - x[i-1]); */ -#ifdef BASOP_NOGLOB L_tmp = L_mult( sub_o( x[i], x[i - 1], &Overflow ), 24465 /*0.7466f in Q15*/ ); /*Q_new+16 */ L_tmp = L_mac_o( L_tmp, y[i - 1], 16158 /*0.4931f in Q15*/, &Overflow ); /*Q_new+16 */ y[i] = round_fx_o( L_tmp, &Overflow ); /*Q_new */ -#else /* BASOP_NOGLOB */ - L_tmp = L_mult( sub( x[i], x[i - 1] ), 24465 ); /*Q_new+16 */ - L_tmp = L_mac( L_tmp, y[i - 1], 16158 ); /*Q_new+16 */ - y[i] = round_fx( L_tmp ); /*Q_new */ -#endif /* BASOP_NOGLOB */ } *oldx = x[L - 1]; @@ -166,11 +151,7 @@ Word16 detect_transient_fx( FOR( i = 0; i < L / 4; i++ ) { /*EnergyLT += out_filt[i] * out_filt[i]; */ -#ifdef BASOP_NOGLOB EnergyLT = L_mac0_o( EnergyLT, out_filt_fx[i], out_filt_fx[i], &Overflow ); /*2Q_new */ -#else - EnergyLT = L_mac0( EnergyLT, out_filt_fx[i], out_filt_fx[i] ); /*2Q_new */ -#endif } } ELSE @@ -189,27 +170,14 @@ Word16 detect_transient_fx( FOR( i = 0; i < L / 4; i++ ) { temp16 = extract_l( L_shr( out_filt_fx[i + blk * ( L / 4 )], 12 ) ); -#ifdef BASOP_NOGLOB Energy_fx = L_add_o( Energy_fx, L_mult0( temp16, temp16 ), &Overflow ); -#else - Energy_fx = L_add( Energy_fx, L_mult0( temp16, temp16 ) ); -#endif - temp16 = shr( in_fx[i + blk * ( L / 4 )], Q_new ); /*Q0*/ -#ifdef BASOP_NOGLOB + temp16 = shr( in_fx[i + blk * ( L / 4 )], Q_new ); /*Q0*/ Energy_in_fx[blk + 1] = L_add_o( Energy_in_fx[blk + 1], L_mult0( temp16, temp16 ), &Overflow ); /*Q0*/ -#else - Energy_in_fx[blk + 1] = L_add( Energy_in_fx[blk + 1], L_mult0( temp16, temp16 ) ); -#endif move32(); } -#ifdef BASOP_NOGLOB E_in_fx = L_add_o( E_in_fx, Energy_in_fx[blk + 1], &Overflow ); /*Q0*/ E_out_fx = L_add_o( E_out_fx, Energy_fx, &Overflow ); /*Q0*/ -#else - E_in_fx = L_add( E_in_fx, Energy_in_fx[blk + 1] ); - E_out_fx = L_add( E_out_fx, Energy_fx ); -#endif Thres_fx = 2185; /*1 /15 Q15*/ move16(); @@ -233,29 +201,17 @@ Word16 detect_transient_fx( FOR( i = 0; i < L / 8; i++ ) { /*Energy += out_filt_fx[i + blk*(L/4)] * out_filt_fx[i + blk*(L/4)]; */ -#ifdef BASOP_NOGLOB L_tmp = L_mac0_o( L_tmp, out_filt_fx[i + blk * ( L / 4 )], out_filt_fx[i + blk * ( L / 4 )], &Overflow ); /*2Q_new */ -#else - L_tmp = L_mac0( L_tmp, out_filt_fx[i + blk * ( L / 4 )], out_filt_fx[i + blk * ( L / 4 )] ); /*2Q_new */ -#endif } L_tmp2 = L_deposit_l( 0 ); FOR( ; i < L / 4; i++ ) { /*Energy += out_filt_fx[i + blk*(L/4)] * out_filt_fx[i + blk*(L/4)]; */ -#ifdef BASOP_NOGLOB L_tmp2 = L_mac0_o( L_tmp2, out_filt_fx[i + blk * ( L / 4 )], out_filt_fx[i + blk * ( L / 4 )], &Overflow ); /*2Q_new */ -#else - L_tmp2 = L_mac0( L_tmp2, out_filt_fx[i + blk * ( L / 4 )], out_filt_fx[i + blk * ( L / 4 )] ); /*2Q_new */ -#endif } Overflow = 0; move16(); -#ifdef BASOP_NOGLOB /* Critical Overflow */ Energy = L_add_o( L_tmp, L_tmp2, &Overflow ); /*2Q_new */ -#else - Energy = L_add( L_tmp, L_tmp2 ); -#endif shift = 0; if ( Overflow != 0 ) { @@ -265,11 +221,7 @@ Word16 detect_transient_fx( Overflow = 0; move16(); -#ifdef BASOP_NOGLOB /* shift is >= 0, not overflow possible for shr */ Energy = L_add_o( L_shr( L_tmp, shift ), L_shr( L_tmp2, shift ), &Overflow ); /*2Q_new - shift*/ -#else - Energy = L_add( L_shr( L_tmp, shift ), L_shr( L_tmp2, shift ) ); -#endif test(); IF( EQ_16( st_fx->extl, SWB_BWE ) || EQ_16( st_fx->extl, FB_BWE ) ) { @@ -310,11 +262,7 @@ Word16 detect_transient_fx( } /*EnergyLT = 0.75f*EnergyLT + 0.25f*Energy; */ /*0.75f*EnergyLT in Q0 //0.25f*Energy in Q0 */ -#ifdef BASOP_NOGLOB EnergyLT = L_add_o( Mult_32_16( EnergyLT, 24576 /*0.75f in Q15*/ ), Mult_32_16( Energy, shl( 8192 /*0.25 in Q15*/, shift ) ), &Overflow ); /*2Q_new */ -#else /* BASOP_NOGLOB */ - EnergyLT = L_add( Mult_32_16( EnergyLT, 24576 ), Mult_32_16( Energy, shl( 8192, shift ) ) ); /*2Q_new */ -#endif } } st_fx->EnergyLT_fx = EnergyLT; @@ -342,11 +290,7 @@ Word16 detect_transient_fx( { /*blk++; */ blk = add( blk, 1 ); -#ifdef BASOP_NOGLOB E_low_fx = L_add_sat( E_low_fx, Energy_in_fx[i] ); /*Q0*/ -#else - E_low_fx = L_add( E_low_fx, Energy_in_fx[i] ); -#endif } exp = norm_s( blk ); @@ -362,11 +306,7 @@ Word16 detect_transient_fx( { /*blk++; */ blk = add( blk, 1 ); -#ifdef BASOP_NOGLOB E_high_fx = L_add_sat( E_high_fx, Energy_in_fx[i] ); /*Q0*/ -#else - E_high_fx = L_add( E_high_fx, Energy_in_fx[i] ); -#endif } exp = norm_s( blk ); diff --git a/lib_enc/dtx_fx.c b/lib_enc/dtx_fx.c index a8978c49717a631fe207a39ac9cbf7eab95126b6..17965e99eae9fa29ee8c2ad4db0cdc3347dc25f4 100644 --- a/lib_enc/dtx_fx.c +++ b/lib_enc/dtx_fx.c @@ -64,7 +64,10 @@ 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 */ + Encoder_State *st_fx, /* i/o: encoder state structure */ +#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 Q0*/ const Word16 vad, /* i : vad flag for DTX Q0*/ const Word16 speech[], /* i : Pointer to the speech frame Q_speech*/ @@ -81,13 +84,21 @@ 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(); } @@ -102,10 +113,18 @@ void dtx_ivas_fx( test(); 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, LP_NOISE_LV * 256 ); +#else last_br_flag = LE_32( st_fx->last_total_brate, ACELP_24k40 ) || LT_16( st_fx->lp_noise_fx, LP_NOISE_LV * 256 ) || ( EQ_16( st_fx->element_mode, IVAS_SCE ) && LE_32( st_fx->last_total_brate, ACELP_32k ) ); br_dtx_flag = 0; move16(); +#endif } + /* Initialization */ IF( st_fx->ini_frame == 0 ) { @@ -199,6 +218,12 @@ 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 ) { test(); @@ -325,6 +350,13 @@ void dtx_ivas_fx( reset_indices_enc( 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) @@ -452,11 +484,7 @@ void dtx_ivas_fx( speech++; FOR( i = 1; i < L_FRAME / 16; i++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_mac0_o( L_tmp, *speech, *speech, &Overflow ); /*2*Q_speech*/ -#else /* BASOP_NOGLOB */ - L_tmp = L_mac0( L_tmp, *speech, *speech ); -#endif /* BASOP_NOGLOB */ speech++; } hDtxEnc->frame_ener_fx = L_add( hDtxEnc->frame_ener_fx, L_shr( L_tmp, Q_speech2 ) ); /* Q(-7) */ @@ -977,11 +1005,7 @@ void dtx_fx( speech++; FOR( i = 1; i < L_FRAME / 16; i++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_mac0_o( L_tmp, *speech, *speech, &Overflow ); /*2*Q_speech*/ -#else /* BASOP_NOGLOB */ - L_tmp = L_mac0( L_tmp, *speech, *speech ); -#endif /* BASOP_NOGLOB */ speech++; } hDtxEnc->frame_ener_fx = L_add( hDtxEnc->frame_ener_fx, L_shr( L_tmp, Q_speech2 ) ); /*Q(-7) */ @@ -1347,11 +1371,7 @@ void dtx_hangover_control_fx( } exp = norm_l( enr_est ); -#ifdef BASOP_NOGLOB fra = round_fx_sat( L_shl_sat( enr_est, exp ) ); /*Q6+exp-16*/ -#else - fra = round_fx( L_shl( enr_est, exp ) ); -#endif exp2 = norm_s( weights ); fra2 = shl( weights, exp2 ); /*Q15+exp2*/ exp = sub( sub( exp, 16 ), exp2 ); @@ -1461,11 +1481,7 @@ void dtx_hangover_control_fx( move16(); FOR( j = 0; j < m; j++ ) { -#ifdef BASOP_NOGLOB lsp_est[i] = add_o( lsp_est[i], tmp[j * M + i], &Overflow ); /*Q15 */ -#else /* BASOP_NOGLOB */ - lsp_est[i] = add( lsp_est[i], tmp[j * M + i] ); /*Q15 */ -#endif /* BASOP_NOGLOB */ } lsp_est[i] = sub( lsp_est[i], tmp[max_idx[0] * M + i] ); /*Q15 */ @@ -1481,20 +1497,12 @@ void dtx_hangover_control_fx( move16(); FOR( j = 0; j < m; j++ ) { -#ifdef BASOP_NOGLOB lsp_est[i] = add_o( lsp_est[i], tmp[j * M + i], &Overflow ); /*Q15 */ -#else - lsp_est[i] = add( lsp_est[i], tmp[j * M + i] ); /*Q15 */ -#endif } -#ifdef BASOP_NOGLOB lsp_est[i] = sub_o( lsp_est[i], add_o( tmp[max_idx[0] * M + i], tmp[max_idx[1] * M + i], &Overflow ), &Overflow ); /*Q15 */ -#else - lsp_est[i] = sub( lsp_est[i], add( tmp[max_idx[0] * M + i], tmp[max_idx[1] * M + i] ) ); /*Q15 */ -#endif - S_tmp = div_s( 1, sub( m, 2 ) ); /*Q15 */ - lsp_est[i] = mult_r( lsp_est[i], S_tmp ); /*Q15 */ + S_tmp = div_s( 1, sub( m, 2 ) ); /*Q15 */ + lsp_est[i] = mult_r( lsp_est[i], S_tmp ); /*Q15 */ } } @@ -1502,11 +1510,7 @@ void dtx_hangover_control_fx( move16(); FOR( i = 0; i < M; i++ ) { -#ifdef BASOP_NOGLOB Dlsp_n2e = add_o( Dlsp_n2e, abs_s( sub( lsp_new_fx[i], lsp_est[i] ) ), &Overflow ); /*Q15 */ -#else /* BASOP_NOGLOB */ - Dlsp_n2e = add( Dlsp_n2e, abs_s( sub( lsp_new_fx[i], lsp_est[i] ) ) ); /*Q15 */ -#endif /* BASOP_NOGLOB */ lsp_est[i] = add( mult_r( 26214, lsp_est[i] ), mult_r( 6554, lsp_new_fx[i] ) ); /*Q15 */ } @@ -1519,11 +1523,7 @@ void dtx_hangover_control_fx( FOR( i = 0; i < M; i++ ) { S_tmp = abs_s( sub( hDtxEnc->lspCNG_fx[i], lsp_est[i] ) ); /*Q15 */ -#ifdef BASOP_NOGLOB - Dlsp = add_o( Dlsp, S_tmp, &Overflow ); /*Q15 */ -#else /* BASOP_NOGLOB */ - Dlsp = add( Dlsp, S_tmp ); /*Q15 */ -#endif + Dlsp = add_o( Dlsp, S_tmp, &Overflow ); /*Q15 */ IF( GT_16( S_tmp, S_max ) ) { S_max = S_tmp; /*Q15 */ diff --git a/lib_enc/enc_acelp_fx.c b/lib_enc/enc_acelp_fx.c index 0826880458f9a802528c4cdb2843932f7fa204a7..7dd342318b37a54d1208764c72b0d19dfe36d390 100644 --- a/lib_enc/enc_acelp_fx.c +++ b/lib_enc/enc_acelp_fx.c @@ -75,36 +75,20 @@ void E_ACELP_h_vec_corr1_fx( Word16 h[] /*Qx*/, Word16 vec[] /*Qx*/, UWord8 trac p2 = &vec[dn]; /*Qx*/ FOR( j = dn; j < L_SUBFR - 1; j++ ) { -#ifdef BASOP_NOGLOB L_sum = L_mac_o( L_sum, *p1++, *p2++, &Overflow ); /*2*Qx+1*/ -#else - L_sum = L_mac( L_sum, *p1++, *p2++ ); -#endif } -#ifdef BASOP_NOGLOB corr = mac_ro( L_sum, *p1++, *p2++, &Overflow ); /*Q9*/ -#else /* BASOP_NOGLOB */ - corr = mac_r( L_sum, *p1++, *p2++ ); /*Q9*/ -#endif /* BASOP_NOGLOB */ /*cor[dn >> 2] = sign[dn] * s + p0[dn >> 2];*/ j = shr( dn, 2 ); if ( sign[dn] > 0 ) { -#ifdef BASOP_NOGLOB corr = add_o( p0[j], corr, &Overflow ); /*Q9*/ -#else - corr = add( p0[j], corr ); -#endif } if ( sign[dn] < 0 ) { -#ifdef BASOP_NOGLOB corr = sub_o( p0[j], corr, &Overflow ); /*Q9*/ -#else /* BASOP_NOGLOB */ - corr = sub( p0[j], corr ); -#endif /* BASOP_NOGLOB */ } cor[j] = corr; /*Q9*/ @@ -134,35 +118,19 @@ void E_ACELP_h_vec_corr2_fx( Word16 h[] /*Qx*/, Word16 vec[] /*Qx*/, UWord8 trac p2 = &vec[pos]; /*Qx*/ FOR( j = pos; j < L_SUBFR - 1; j++ ) { -#ifdef BASOP_NOGLOB L_sum = L_mac_o( L_sum, *p1++, *p2++, &Overflow ); /* 2*Qx+1 */ -#else - L_sum = L_mac( L_sum, *p1++, *p2++ ); -#endif } -#ifdef BASOP_NOGLOB corr = mac_ro( L_sum, *p1++, *p2++, &Overflow ); /*Q9*/ -#else /* BASOP_NOGLOB */ - corr = mac_r( L_sum, *p1++, *p2++ ); /*Q9*/ -#endif /* BASOP_NOGLOB */ /*cor[i] = s * sign[track] + p0[i];*/ if ( sign[pos] > 0 ) { -#ifdef BASOP_NOGLOB corr = add_o( *p0++, corr, &Overflow ); /*Q9*/ -#else - corr = add( *p0++, corr ); -#endif } if ( sign[pos] < 0 ) { -#ifdef BASOP_NOGLOB corr = sub_o( *p0++, corr, &Overflow ); /*Q9*/ -#else - corr = sub( *p0++, corr ); -#endif } cor[i] = corr; /*Q9*/ move16(); @@ -227,11 +195,7 @@ static void E_ACELP_2pulse_search( Word16 nb_pos_ix /*Q0*/, UWord8 track_x /*Q0* sqk[0] = -1; move16(); x2 = shr( pos_x[0], 2 ); /*Qdn*/ -#ifdef BASOP_NOGLOB if ( mac_ro( L_mac_o( L_mac_o( alp0, cor_x[x2], _1_, &Overflow ), cor_y[0], _1_, &Overflow ), rrixiy[track_x][( x2 * 16 )], _1_, &Overflow ) < 0 ) -#else /* BASOP_NOGLOB */ - if ( mac_r( L_mac( L_mac( alp0, cor_x[x2], _1_ ), cor_y[0], _1_ ), rrixiy[track_x][shl( x2, 4 )], _1_ ) < 0 ) -#endif /* BASOP_NOGLOB */ { sqk[0] = 1; move16(); @@ -251,11 +215,7 @@ static void E_ACELP_2pulse_search( Word16 nb_pos_ix /*Q0*/, UWord8 track_x /*Q0* ps1 = add( ps0, dn[x] ); /*Qdn*/ /*alp1 = alp0 + cor_x[x2];*/ -#ifdef BASOP_NOGLOB alp1 = L_mac_o( alp0, cor_x[x2], _1_, &Overflow ); /*Q22*/ -#else /* BASOP_NOGLOB */ - alp1 = L_mac( alp0, cor_x[x2], _1_ ); /*Q22*/ -#endif /* BASOP_NOGLOB */ p1 = cor_y; /*Qx*/ p2 = &rrixiy[track_x][( x2 * 16 )]; /*Q9*/ @@ -267,13 +227,8 @@ static void E_ACELP_2pulse_search( Word16 nb_pos_ix /*Q0*/, UWord8 track_x /*Q0* move16(); /*alp2 = alp1 + (*p1++) + (*p2++);*/ -#ifdef BASOP_NOGLOB alp2 = L_mac_o( alp1, *p1++, _1_, &Overflow ); /*Qx+12+1*/ alp2_16 = mac_ro( alp2, *p2++, _1_, &Overflow ); /*Q6*/ -#else /* BASOP_NOGLOB */ - alp2 = L_mac( alp1, *p1++, _1_ ); - alp2_16 = mac_r( alp2, *p2++, _1_ ); /*Q6*/ -#endif /* BASOP_NOGLOB */ alpk[1 - ik] = alp2_16; /*Q6*/ move16(); @@ -475,13 +430,8 @@ static void E_ACELP_xh_corr( Word16 *x /*Qx*/, Word16 *y /*Qy*/, Word16 *h /*Q12 L_maxloc = L_shr( L_maxloc, 2 ); /* Do not warn saturation of L_tot, since its for headroom estimation. */ BASOP_SATURATE_WARNING_OFF_EVS -#ifdef BASOP_NOGLOB L_tot = L_add_sat( L_tot, L_maxloc ); /* +max/4 */ L_tot = L_add_sat( L_tot, L_shr( L_maxloc, 1 ) ); /* +max/8 */ -#else - L_tot = L_add( L_tot, L_maxloc ); /* +max/4 */ - L_tot = L_add( L_tot, L_shr( L_maxloc, 1 ) ); /* +max/8 */ -#endif BASOP_SATURATE_WARNING_ON_EVS } @@ -581,19 +531,11 @@ Word16 E_ACELP_xy1_corr_fx( Word16 xn[] /*Q15-exp_xn*/, Word16 y1[] /*Q15-exp_xn L_off = L_shr( 10737418l /*0.01f/2.0f Q31*/, s_min( add( exp_xn, exp_xn ), 31 ) ); L_off = L_max( 1, L_off ); /* ensure at least a '1' */ -#ifdef BASOP_NOGLOB /* Compute scalar product t1: */ yy = round_fx_o( Dot_product15_offs( y1, y1, L_subfr, &exp_yy, L_off ), &Overflow ); /*Q15 - exp_yy*/ /* Compute scalar product t0: */ xy = round_fx_o( Dot_product12_offs( xn, y1, L_subfr, &exp_xy, L_off ), &Overflow ); /*Q15 - exp_xy*/ -#else - /* Compute scalar product t1: */ - yy = round_fx( Dot_product15_offs( y1, y1, L_subfr, &exp_yy, L_off ) ); - - /* Compute scalar product t0: */ - xy = round_fx( Dot_product12_offs( xn, y1, L_subfr, &exp_xy, L_off ) ); -#endif /* Compute doubled format out of the exponent */ Q_xn = shl( sub( 15, exp_xn ), 1 ); g_corr->y1y1 = yy; @@ -621,11 +563,7 @@ Word16 E_ACELP_xy1_corr_fx( Word16 xn[] /*Q15-exp_xn*/, Word16 y1[] /*Q15-exp_xn i = add( exp_xy, 1 - 1 ); /* -1 -> gain in Q14 */ i = sub( i, exp_yy ); BASOP_SATURATE_WARNING_OFF_EVS -#ifdef BASOP_NOGLOB gain = shl_o( gain, i, &Overflow ); /* saturation can occur here */ -#else /* BASOP_NOGLOB */ - gain = shl( gain, i ); /* saturation can occur here */ -#endif /* BASOP_NOGLOB */ BASOP_SATURATE_WARNING_ON_EVS /* gain = s_max(0, gain); */ /* see above xy < 0. */ @@ -639,11 +577,7 @@ Word16 E_ACELP_xy1_corr_fx( Word16 xn[] /*Q15-exp_xn*/, Word16 y1[] /*Q15-exp_xn Word16 tmp, exp_tmp, exp_div; /* Compute scalar product */ -#ifdef BASOP_NOGLOB tmp = round_fx_o( Dot_product12_offs( xn, xn, L_subfr, &exp_tmp, 1 ), &Overflow ); /*Q15 - exp_tmp*/ -#else - tmp = round_fx( Dot_product12_offs( xn, xn, L_subfr, &exp_tmp, 1 ) ); -#endif /* gain_p_snr = sqrt(/) */ tmp = BASOP_Util_Divide1616_Scale( tmp, yy, &exp_div ); exp_tmp = add( sub( exp_tmp, exp_yy ), exp_div ); @@ -653,11 +587,7 @@ Word16 E_ACELP_xy1_corr_fx( Word16 xn[] /*Q15-exp_xn*/, Word16 y1[] /*Q15-exp_xn /* Note: shl works as shl or shr. */ exp_tmp = sub( exp_tmp, 1 ); BASOP_SATURATE_WARNING_OFF_EVS -#ifdef BASOP_NOGLOB tmp = round_fx_o( L_shl_o( Mpy_32_16_1( 1717986944l /*ACELP_GAINS_CONST Q31*/, tmp ), exp_tmp, &Overflow ), &Overflow ); /*Q14*/ -#else /* BASOP_NOGLOB */ - tmp = round_fx( L_shl( Mpy_32_16_1( 1717986944l /*ACELP_GAINS_CONST Q31*/, tmp ), exp_tmp ) ); -#endif /* BASOP_NOGLOB */ BASOP_SATURATE_WARNING_ON_EVS gain = s_min( gain, tmp ); /*Q14*/ @@ -774,17 +704,9 @@ void E_ACELP_codebook_target_update_fx( Word16 *x /*Q_xn*/, Word16 *x2 /*Q_xn*/, L_tmp = L_deposit_h( x[i] ); /*Q_xn+16*/ if ( Q15_flag == 0 ) { -#ifdef BASOP_NOGLOB L_tmp = L_msu_o( L_tmp, y[i], gain, &Overflow ); /*Q_xn+15*/ -#else - L_tmp = L_msu( L_tmp, y[i], gain ); -#endif } -#ifdef BASOP_NOGLOB x2[i] = msu_ro( L_tmp, y[i], gain, &Overflow ); /*Q_xn*/ -#else - x2[i] = msu_r( L_tmp, y[i], gain ); -#endif move16(); } } @@ -830,11 +752,7 @@ void E_ACELP_pulsesign( const Word16 cn[] /*Q_xn*/, Word16 dn[] /*Qdn*/, Word16 FOR( i = 1; i < L_subfr; i++ ) { -#ifdef BASOP_NOGLOB Lval = L_mac0_o( Lval, cn[i], cn[i], &Overflow ); /*2*Q_xn*/ -#else /* BASOP_NOGLOB */ - Lval = L_mac0( Lval, cn[i], cn[i] ); -#endif /* BASOP_NOGLOB */ Lcor = L_mac0( Lcor, dn[i], dn[i] ); /*2*Qdn*/ } @@ -851,13 +769,8 @@ void E_ACELP_pulsesign( const Word16 cn[] /*Q_xn*/, Word16 dn[] /*Qdn*/, Word16 if ( i > 0 ) Lcor = L_shr( Lcor, i ); -#ifdef BASOP_NOGLOB k_dn = round_fx_o( Lval, &Overflow ); /*Q15 - e_dn*/ k_cn = round_fx_o( Lcor, &Overflow ); /*Q15 - e_cn*/ -#else /* BASOP_NOGLOB */ - k_dn = round_fx( Lval ); - k_cn = round_fx( Lcor ); -#endif /* BASOP_NOGLOB */ k_cn = mult_r( 0x2000, k_cn ); /* 1 in Q13 */ k_dn = mult_r( alp, k_dn ); /* alp in Q13 */ @@ -875,13 +788,9 @@ void E_ACELP_pulsesign( const Word16 cn[] /*Q_xn*/, Word16 dn[] /*Qdn*/, Word16 FOR( i = 0; i < L_subfr; i++ ) { /*cor = (s * cn[i]) + (alp * dn[i]); MULT(1);MAC(1);*/ - Lcor = L_mult( cn[i], k_cn ); /*Q_xn + Q15 - e_cn + 1*/ - Lcor = L_mac( Lcor, dn[i], k_dn ); /*Qdn + Q15 - e_dn + 1*/ -#ifdef BASOP_NOGLOB + Lcor = L_mult( cn[i], k_cn ); /*Q_xn + Q15 - e_cn + 1*/ + Lcor = L_mac( Lcor, dn[i], k_dn ); /*Qdn + Q15 - e_dn + 1*/ val = round_fx_o( L_shl_o( Lcor, 4, &Overflow ), &Overflow ); /*shifting by 4 may overflow but improves accuracy Qdn + 4 - e_dn*/ -#else - val = round_fx( L_shl( Lcor, 4 ) ); /*shifting by 4 may overflow but improves accuracy*/ -#endif index = shr( val, 15 ); sign[i] = ptr16[index]; /*Q15*/ @@ -1219,11 +1128,7 @@ void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const BASOP_SATURATE_WARNING_OFF_EVS FOR( i = 0; i < L_SUBFR; i++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_mac_o( L_tmp, H[i], H[i], &Overflow ); /*Q25*/ -#else - L_tmp = L_mac( L_tmp, H[i], H[i] ); -#endif } val = extract_h( L_tmp ); /*Q9*/ BASOP_SATURATE_WARNING_ON_EVS @@ -1368,11 +1273,7 @@ void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const L_tmp = L_mult( vec[0], vec[0] ); /*Q25+2*scale*/ FOR( i = 1; i < L_SUBFR; i++ ) -#ifdef BASOP_NOGLOB L_tmp = L_mac_o( L_tmp, vec[i], vec[i], &Overflow ); /*Q25+2*scale*/ -#else - L_tmp = L_mac( L_tmp, vec[i], vec[i] ); -#endif alp = round_fx( L_shr( L_tmp, 3 ) ); /*Q6+2*scale*/ @@ -1429,13 +1330,8 @@ void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const FOR( i = 0; i < L_SUBFR; i++ ) { tmp = add( *p0++, *p1++ ); -#ifdef BASOP_NOGLOB vec[i] = add_o( vec[i], tmp, &Overflow ); /* can saturate here. */ move16(); -#else - vec[i] = add( vec[i], tmp ); /* can saturate here. */ - move16(); -#endif } } st = add( st, 1 ); @@ -1484,17 +1380,339 @@ void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const } FOR( i = 0; i < L_SUBFR; i++ ) { -#ifdef BASOP_NOGLOB y[i] = add_o( y[i], *p0++, &Overflow ); /*Q12+scale*/ -#else - y[i] = add( y[i], *p0++ ); -#endif move16(); } } 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]; + Word16 cor_x[16], cor_y[16], h_buf[4 * L_SUBFR]; + Word16 rrixix[4][16]; + Word16 rrixiy[4][256]; + Word16 dn2[L_SUBFR]; + Word16 psk, ps, alpk, alp = 0; + Word16 codvec[NB_PULSE_MAX]; + Word16 pos_max[4]; + Word16 dn2_pos[8 * 4]; + UWord8 ipos[NB_PULSE_MAX]; + Word16 *p0, *p1, *p2, *p3; + Word16 *h, *h_inv; + Word16 i, j, k, l, st, pos; + Word16 val, tmp, scale; + Word32 s, L_tmp; + Word16 nb_pulse, nb_pulse_m2; + Word16 check = 0; /* debug code not instrumented */ +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; + move32(); +#endif + + + alp = config->alp; /* Q13 */ /* initial value for energy of all fixed pulses */ + move16(); + nb_pulse = config->nb_pulse; + move16(); + nb_pulse_m2 = sub( nb_pulse, 2 ); + + set16_fx( codvec, 0, nb_pulse ); + + /* + * Find sign for each pulse position. + */ + + E_ACELP_pulsesign( cn, dn, dn2, sign, vec, alp, 0x7fff, L_SUBFR ); + + /* + * Select the most important 8 position per track according to dn2[]. + */ + E_ACELP_findcandidates( dn2, dn2_pos, pos_max ); + + /* + * Compute h_inv[i]. + */ + set16_fx( h_buf, 0, L_SUBFR ); + + set16_fx( h_buf + ( 2 * L_SUBFR ), 0, L_SUBFR ); + + h = h_buf + L_SUBFR; + h_inv = h_buf + ( 3 * L_SUBFR ); + + /*Check the energy if it is too high then scale to prevent an overflow*/ + scale = 0; + move16(); + L_tmp = L_deposit_l( 0 ); + BASOP_SATURATE_WARNING_OFF_EVS + FOR( i = 0; i < L_SUBFR; i++ ) + { + L_tmp = L_mac_o( L_tmp, H[i], H[i], &Overflow ); /*Q25*/ + } + val = extract_h( L_tmp ); /*Q9*/ + BASOP_SATURATE_WARNING_ON_EVS + + if ( GT_16( val, 0x2000 ) ) + { + scale = -1; + move16(); + } + if ( GT_16( val, 0x7000 ) ) + { + scale = -2; + move16(); + } + if ( EQ_16( val, 32767 ) ) + { + scale = -3; + move16(); + } + + Copy_Scale_sig( H, h, L_SUBFR, scale ); /*Q12+scale*/ + + E_ACELP_vec_neg_fx( h, h_inv, L_SUBFR ); + + + /* + * Compute correlation matrices needed for the codebook search. + */ + E_ACELP_corrmatrix_fx( h, sign, vec, rrixix, rrixiy ); + + + /* + * Deep first search: + * ------------------ + * 20 bits (4p): 4 iter x ((4x16)+(8x16)) = 768 tests + * 36 bits (8p): 4 iter x ((1x1)+(4x16)+(8x16)+(8x16)) = 1280 tests + * 52 bits (12p): 3 iter x ((1x1)+(1x1)+(4x16)+(6x16) + * +(8x16)+(8x16)) = 1248 tests + * 64 bits (16p): 2 iter x ((1x1)+(1x1)+(4x16)+(6x16) + * +(6x16)+(8x16)+(8x16)+(8x16)) = 1280 tests + */ + psk = -1; + move16(); + alpk = 1; + move16(); + + /*Number of iterations*/ + FOR( k = 0; k < config->nbiter; k++ ) + { + E_ACELP_setup_pulse_search_pos( config, k, ipos ); + + /* format of alp changes to Q(15-ALP2_E) */ + + pos = config->fixedpulses; + move16(); + + IF( config->fixedpulses == 0 ) /* 1100, 11, 1110, 1111, 2211 */ + { + ps = 0; + move16(); + alp = 0; + move16(); + set16_fx( vec, 0, L_SUBFR ); + } + ELSE IF( EQ_16( config->fixedpulses, 2 ) ) /* 2222 and 3322 */ + { + /* first stage: fix 2 pulses */ + ind[0] = pos_max[ipos[0]]; + move16(); + ind[1] = pos_max[ipos[1]]; + move16(); + ps = add( dn[ind[0]], dn[ind[1]] ); + + /*alp = rrixix[ipos[0]][ind[0] >> 2] + rrixix[ipos[1]][ind[1] >> 2] + + rrixiy[ipos[0]][((ind[0] >> 2) << 4) + (ind[1] >> 2)];*/ + + i = shr( ind[0], 2 ); + j = shr( ind[1], 2 ); + l = add( shl( i, 4 ), j ); + s = L_mult( rrixix[ipos[0]][i], _1_ ); /* Q9+Q12+1 */ + s = L_mac( s, rrixix[ipos[1]][j], _1_ ); /* Q9+Q12+1 */ + alp = mac_r( s, rrixiy[ipos[0]][l], _1_ ); /* Q9+Q12+1-16 */ + + p0 = h - ind[0]; /*Q12+scale*/ + IF( sign[ind[0]] < 0 ) + { + p0 = h_inv - ind[0]; /*Q12+scale*/ + } + + p1 = h - ind[1]; /*Q12+scale*/ + IF( sign[ind[1]] < 0 ) + { + p1 = h_inv - ind[1]; /*Q12+scale*/ + } + + FOR( i = 0; i < L_SUBFR; i++ ) + { + vec[i] = add( *p0++, *p1++ ); /*Q12+scale*/ + move16(); + } + } + ELSE /* 3333 and above */ + { + /* first stage: fix 4 pulses */ + + ind[0] = pos_max[ipos[0]]; /*Q0*/ + move16(); + ind[1] = pos_max[ipos[1]]; /*Q0*/ + move16(); + ind[2] = pos_max[ipos[2]]; /*Q0*/ + move16(); + ind[3] = pos_max[ipos[3]]; /*Q0*/ + move16(); + + /*ps = dn[ind[0]] + dn[ind[1]] + dn[ind[2]] + dn[ind[3]];*/ + ps = add( add( add( dn[ind[0]], dn[ind[1]] ), dn[ind[2]] ), dn[ind[3]] ); + + p0 = h - ind[0]; /*Q12+scale*/ + IF( sign[ind[0]] < 0 ) + { + p0 = h_inv - ind[0]; /*Q12+scale*/ + } + + p1 = h - ind[1]; /*Q12+scale*/ + IF( sign[ind[1]] < 0 ) + { + p1 = h_inv - ind[1]; /*Q12+scale*/ + } + + p2 = h - ind[2]; /*Q12+scale*/ + IF( sign[ind[2]] < 0 ) + { + p2 = h_inv - ind[2]; /*Q12+scale*/ + } + + p3 = h - ind[3]; /*Q12+scale*/ + IF( sign[ind[3]] < 0 ) + { + p3 = h_inv - ind[3]; /*Q12+scale*/ + } + + FOR( i = 0; i < L_SUBFR; i++ ) + { + vec[i] = add( add( add( *p0++, *p1++ ), *p2++ ), *p3++ ); /*Q12+scale*/ + move16(); + } + + L_tmp = L_mult( vec[0], vec[0] ); /*Q25+2*scale*/ + FOR( i = 1; i < L_SUBFR; i++ ) + L_tmp = L_mac_o( L_tmp, vec[i], vec[i], &Overflow ); /*Q25+2*scale*/ + + alp = round_fx( L_shr( L_tmp, 3 ) ); /*Q6+2*scale*/ + + /*alp *= 0.5F; */ + } + + /* other stages of 2 pulses */ + st = 0; + move16(); + FOR( j = pos; j < nb_pulse; j += 2 ) + { + IF( GE_16( nb_pulse_m2, j ) ) /* pair-wise search */ + { + /* + * Calculate correlation of all possible positions + * of the next 2 pulses with previous fixed pulses. + * Each pulse can have 16 possible positions. + */ + E_ACELP_h_vec_corr1_fx( h, vec, ipos[j], sign, rrixix, cor_x, dn2_pos, config->nbpos[st] ); + + E_ACELP_h_vec_corr2_fx( h, vec, ipos[j + 1], sign, rrixix, cor_y ); + + /* + * Find best positions of 2 pulses. + */ + E_ACELP_2pulse_search( config->nbpos[st], ipos[j], ipos[j + 1], &ps, &alp, + &ind[j], &ind[j + 1], dn, dn2_pos, cor_x, cor_y, rrixiy ); + } + ELSE /* single pulse search */ + { + E_ACELP_h_vec_corr2_fx( h, vec, ipos[j], sign, rrixix, cor_x ); + + E_ACELP_h_vec_corr2_fx( h, vec, ipos[j + 1], sign, rrixix, cor_y ); + + E_ACELP_1pulse_search( &ipos[j], &ps, &alp, + &ind[j], dn, cor_x, cor_y ); + } + + IF( GT_16( nb_pulse_m2, j ) ) + { + p0 = h - ind[j]; /*Q12+scale*/ + IF( sign[ind[j]] < 0 ) + { + p0 = h_inv - ind[j]; /*Q12+scale*/ + } + + p1 = h - ind[j + 1]; /*Q12+scale*/ + IF( sign[ind[j + 1]] < 0 ) + { + p1 = h_inv - ind[j + 1]; /*Q12+scale*/ + } + + + FOR( i = 0; i < L_SUBFR; i++ ) + { + tmp = add( *p0++, *p1++ ); + vec[i] = add_o( vec[i], tmp, &Overflow ); /* can saturate here. */ + move16(); + } + } + st = add( st, 1 ); + } + + /* memorise the best codevector */ + + /*ps = ps * ps; MULT(1);*/ + ps = mult( ps, ps ); + /*s = (alpk * ps) - (psk * alp); MULT(2);ADD(1);*/ + s = L_msu( L_mult( alpk, ps ), psk, alp ); /*Q9+Q6+1=Q16*/ + + if ( psk < 0 ) + { + s = 1; + move32(); + } + IF( s > 0 ) + { + psk = ps; + move16(); + alpk = alp; + move16(); + Copy( ind, codvec, nb_pulse ); /*Q0*/ + check = 1; /* debug code not instrumented */ + } + } + + assert( check ); /* debug code not instrumented */ + + /* + * Build the codeword, the filtered codeword and index of codevector, as well as store weighted correlations. + */ + + E_ACELP_build_code( nb_pulse, codvec, sign, code, ind ); + + set16_fx( y, 0, L_SUBFR ); + FOR( k = 0; k < nb_pulse; ++k ) + { + i = codvec[k]; /*Q0*/ + move16(); + p0 = h_inv - i; /*Q12+scale*/ + IF( sign[i] > 0 ) + { + p0 -= 2 * L_SUBFR; + } + FOR( i = 0; i < L_SUBFR; i++ ) + { + y[i] = add_o( y[i], *p0++, &Overflow ); /*Q12+scale*/ + move16(); + } + } + return; +} +#endif /* * E_ACELP_4t_fx @@ -1651,7 +1869,11 @@ 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; @@ -2155,11 +2377,7 @@ static void E_ACELP_codearithp_fx( const Word16 v[] /*Q9*/, UWord32 *n /*Q0*/, U { Carry = 0; move32(); -#ifdef BASOP_NOGLOB s = L_add_co( s, pulsestostates[pos[k]][t], &Carry, &Overflow ); -#else /* BASOP_NOGLOB */ - s = L_add_c( s, pulsestostates[pos[k]][t] ); -#endif /* BASOP_NOGLOB */ t = add( t, 1 ); if ( sub( t, NPMAXPT ) > 0 ) { @@ -2175,21 +2393,13 @@ static void E_ACELP_codearithp_fx( const Word16 v[] /*Q9*/, UWord32 *n /*Q0*/, U s = L_lshl( s, 1 ); if ( sign < 0 ) { -#ifdef BASOP_NOGLOB s = L_add_co( s, 1, &Carry, &Overflow ); -#else /* BASOP_NOGLOB */ - s = L_add_c( s, 1 ); -#endif /* BASOP_NOGLOB */ } /* Code last pulse */ Carry = 0; move32(); -#ifdef BASOP_NOGLOB s = L_add_co( s, pulsestostates[pos[k]][t], &Carry, &Overflow ); -#else /* BASOP_NOGLOB */ - s = L_add_c( s, pulsestostates[pos[k]][t] ); -#endif t = add( t, 1 ); } diff --git a/lib_enc/enc_acelpx_fx.c b/lib_enc/enc_acelpx_fx.c index 99c9568ebfc47d055d81a3d9444bf5b7a4d30321..f18da2ef27024789870875f55f2b3f04c1b01b1c 100644 --- a/lib_enc/enc_acelpx_fx.c +++ b/lib_enc/enc_acelpx_fx.c @@ -151,12 +151,8 @@ static void E_ACELP_2pulse_searchx_fx( ps0 = *ps; /*Qdn*/ move16(); /*alp0 = *alp + 2.0f*R[0]; move16();*/ - alp0 = L_deposit_h( *alp ); /* Qalp = Q_R*Q_signval */ -#ifdef BASOP_NOGLOB + alp0 = L_deposit_h( *alp ); /* Qalp = Q_R*Q_signval */ alp0 = L_mac_sat( alp0, R[0], sign_val_2 ); /*Q9+scale+Q15*/ -#else - alp0 = L_mac( alp0, R[0], sign_val_2 ); -#endif /* Ensure that in the loop below s > 0 in the first iteration, the actual values do not matter. */ sqk[0] = -1; @@ -171,11 +167,7 @@ static void E_ACELP_2pulse_searchx_fx( { sgnx = negate( sgnx ); } -#ifdef BASOP_NOGLOB if ( mac_ro( L_mac_o( L_mac_o( alp0, cor[x], sign[x], &Overflow ), cor[track_y], sign[track_y], &Overflow ), R[track_y - x], sgnx, &Overflow ) < 0 ) -#else - if ( mac_r( L_mac( L_mac( alp0, cor[x], sign[x] ), cor[track_y], sign[track_y] ), R[track_y - x], sgnx ) < 0 ) -#endif { sqk[0] = 1; @@ -195,27 +187,15 @@ static void E_ACELP_2pulse_searchx_fx( move16(); /* dn[x] has only nb_pos_ix positions saved */ /*ps1 = ps0 + dn[x]; INDIRECT(1);ADD(1);*/ -#ifdef BASOP_NOGLOB ps1 = add_sat( ps0, dn[x] ); /*Qdn*/ -#else - ps1 = add( ps0, dn[x] ); -#endif /*alp1 = alp0 + 2*sgnx*cor[x]; INDIRECT(1);MULT(1); MAC(1);*/ -#ifdef BASOP_NOGLOB alp1 = L_mac_o( alp0, cor[x], sgnx, &Overflow ); /* Qalp = (Q_R=Q_cor)*Q_signval */ -#else - alp1 = L_mac( alp0, cor[x], sgnx ); /* Qalp = (Q_R=Q_cor)*Q_signval */ -#endif - pR = R - x; /*Q9+scale*/ + pR = R - x; /*Q9+scale*/ FOR( y = track_y; y < L_SUBFR; y += 4 ) { /*ps2 = ps1 + dn[y]; ADD(1);*/ -#ifdef BASOP_NOGLOB ps2 = add_sat( ps1, dn[y] ); /*Qdn*/ -#else - ps2 = add( ps1, dn[y] ); -#endif /*alp2 = alp1 + 2.0f*sign[y]*(cor[y] + sgnx*pR[y]); MULT(1); MAC(2);*/ /*alp2 = alp1 + 2.0f*sign[y]*cor[y] + 2.0f*sign[y]*sgnx*pR[y]; MULT(1); MAC(2);*/ assert( sign[y] == sign_val_2 || sign[y] == -sign_val_2 ); @@ -224,26 +204,14 @@ static void E_ACELP_2pulse_searchx_fx( assert( sgnx != 0 ); alp2_16 = 0; -#ifdef BASOP_NOGLOB alp2 = L_mac_o( alp1, cor[y], sign[y], &Overflow ); /* Qalp = (Q_R=Q_cor)*Q_signval */ -#else - alp2 = L_mac( alp1, cor[y], sign[y] ); /* Qalp = (Q_R=Q_cor)*Q_signval */ -#endif if ( sgnx > 0 ) { -#ifdef BASOP_NOGLOB alp2_16 = mac_ro( alp2, pR[y], sign[y], &Overflow ); /* Qalp = (Q_R=Q_cor)*Q_signval */ -#else - alp2_16 = mac_r( alp2, pR[y], sign[y] ); /* Qalp = (Q_R=Q_cor)*Q_signval */ -#endif } if ( sgnx < 0 ) { -#ifdef BASOP_NOGLOB alp2_16 = msu_ro( alp2, pR[y], sign[y], &Overflow ); /* Qalp = (Q_R=Q_cor)*Q_signval */ -#else - alp2_16 = msu_r( alp2, pR[y], sign[y] ); /* Qalp = (Q_R=Q_cor)*Q_signval */ -#endif } alpk[1 - ik] = alp2_16; /* Qalp */ move16(); @@ -255,11 +223,7 @@ static void E_ACELP_2pulse_searchx_fx( /*s = (alpk * sq) - (sqk * alp2); MULT(1);MAC(1);*/ -#ifdef BASOP_NOGLOB s = L_msu_o( L_mult( alpk[ik], sq ), sqk[ik], alp2_16, &Overflow ); /* Q_sq = Q_sqk, Q_alpk = Q_alp */ -#else - s = L_msu( L_mult( alpk[ik], sq ), sqk[ik], alp2_16 ); /* Q_sq = Q_sqk, Q_alpk = Q_alp */ -#endif if ( s > 0 ) { ik = sub( 1, ik ); @@ -335,11 +299,7 @@ static void E_ACELP_1pulse_searchx_fx( sqk[0] = -1; ik = 0; move16(); -#ifdef BASOP_NOGLOB if ( mac_ro( alp0, cor[tracks[0]], sign[tracks[0]], &Overflow ) < 0 ) -#else - if ( mac_r( alp0, cor[tracks[0]], sign[tracks[0]] ) < 0 ) -#endif { sqk[0] = 1; move16(); @@ -363,12 +323,8 @@ static void E_ACELP_1pulse_searchx_fx( ps1 = add( ps0, dn[x] ); /* alp1 = alp0 + 2*sign[x]*cor[x]; MAC(1); MULT(1);*/ assert( sign[x] == sign_val_1 << 1 || sign[x] == -( sign_val_1 << 1 ) ); -#ifdef BASOP_NOGLOB alp1 = mac_ro( alp0, cor[x], sign[x], &Overflow ); /* Qalp = (Q_R=Q_cor)*Q_signval */ -#else - alp1 = mac_r( alp0, cor[x], sign[x] ); /* Qalp = (Q_R=Q_cor)*Q_signval */ -#endif - alpk[1 - ik] = alp1; /* Qalp */ + alpk[1 - ik] = alp1; /* Qalp */ move16(); @@ -378,11 +334,7 @@ static void E_ACELP_1pulse_searchx_fx( move16(); /*s = (alpk[ik] * sq) - (sqk[ik] * alp1); MULT(1);MAC(1);*/ -#ifdef BASOP_NOGLOB s = L_msu_o( L_mult_o( alpk[ik], sq, &Overflow ), sqk[ik], alp1, &Overflow ); /* Q9+Qalp+1 */ -#else - s = L_msu( L_mult( alpk[ik], sq ), sqk[ik], alp1 ); -#endif if ( s > 0 ) { ik = sub( 1, ik ); diff --git a/lib_enc/enc_amr_wb_fx.c b/lib_enc/enc_amr_wb_fx.c index edc04bc832fa4f64ef737883f5d9c6ed83b0e5ef..08a20bbb9b8effbccc2227ae263e1c7a0d32ba4d 100644 --- a/lib_enc/enc_amr_wb_fx.c +++ b/lib_enc/enc_amr_wb_fx.c @@ -187,24 +187,15 @@ void encod_amr_wb_fx( &gain_inov, &norm_gain_code, g_corr, clip_gain, hAmrwb_IO->past_qua_en_fx ); gp_clip_test_gain_pit_fx( st->element_mode, st->core_brate, gain_pit, st->clip_var_fx ); -#ifdef BASOP_NOGLOB Lgcode = L_shl_o( gain_code, Q_new, &Overflow ); /* scaled gain_code with Qnew -> Q16*/ gcode16 = round_fx_o( Lgcode, &Overflow ); /*Q0*/ -#else /* BASOP_NOGLOB */ - Lgcode = L_shl( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/ - gcode16 = round_fx( Lgcode ); -#endif /* BASOP_NOGLOB */ hLPDmem->tilt_code = Est_tilt2( exc + i_subfr, gain_pit, code, Lgcode, &voice_fac, shift ); /*Q15*/ FOR( i = 0; i < L_SUBFR; i++ ) { -#ifdef BASOP_NOGLOB exc2[i + i_subfr] = round_fx_o( L_shl_o( L_mult( gain_pit, exc[i + i_subfr] ), 1, &Overflow ), &Overflow ); /*Q_new*/ move16(); -#else /* BASOP_NOGLOB */ - exc2[i + i_subfr] = round_fx( L_shl( L_mult( gain_pit, exc[i + i_subfr] ), 1 ) ); -#endif /* BASOP_NOGLOB */ } /*-----------------------------------------------------------------* @@ -217,35 +208,20 @@ void encod_amr_wb_fx( Ltmp = L_negate( Ltmp ); Ltmp = L_mac( Ltmp, xn[L_SUBFR - 1], 16384 /*Q14*/ ); /* Q_new-1+shift+14+1 */ Ltmp = L_msu( Ltmp, y1[L_SUBFR - 1], gain_pit /*Q14*/ ); /* Q_new-1+shift+14+1 */ -#ifdef BASOP_NOGLOB - Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); /* Q_new+15 */ - hLPDmem->mem_w0 = round_fx_sat( Ltmp ); /*Q_new-1 */ + Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); /* Q_new+15 */ + hLPDmem->mem_w0 = round_fx_sat( Ltmp ); /*Q_new-1 */ move16(); -#else - Ltmp = L_shl( Ltmp, sub( 1, shift ) ); - hLPDmem->mem_w0 = round_fx( Ltmp ); /*Q_new-1 */ -#endif /*-----------------------------------------------------------------* * Find the total excitation *-----------------------------------------------------------------*/ FOR( i = 0; i < L_SUBFR; i++ ) { - L_tmp = L_mult( gcode16, code[i] ); /*Q10*/ -#ifdef BASOP_NOGLOB + L_tmp = L_mult( gcode16, code[i] ); /*Q10*/ L_tmp = L_shl_sat( L_tmp, 5 ); /*Q15*/ L_tmp = L_mac_sat( L_tmp, exc[i + i_subfr], gain_pit ); /* Q_new+15 */ -#else - L_tmp = L_shl( L_tmp, 5 ); - L_tmp = L_mac( L_tmp, exc[i + i_subfr], gain_pit ); -#endif -#ifdef BASOP_NOGLOB - L_tmp = L_shl_o( L_tmp, 1, &Overflow ); /* saturation can occur here Q_new+15*/ - exc[i + i_subfr] = round_fx_o( L_tmp, &Overflow ); /*Q_new*/ + L_tmp = L_shl_o( L_tmp, 1, &Overflow ); /* saturation can occur here Q_new+15*/ + exc[i + i_subfr] = round_fx_o( L_tmp, &Overflow ); /*Q_new*/ move16(); -#else /* BASOP_NOGLOB */ - L_tmp = L_shl( L_tmp, 1 ); /* saturation can occur here */ - exc[i + i_subfr] = round_fx( L_tmp ); -#endif } /*-----------------------------------------------------------------* diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index 243b9f0490e6d58847c2b4b4de4daf7f46733798..96e7e274cbbda2bf53cbb7082b1f9fe126778db6 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -244,11 +244,7 @@ void encod_gen_voic_fx( } /*st_fx->lowrate_pitchGain = 0.9f * st_fx->lowrate_pitchGain + 0.1f * gain_pit_fx;*/ -#ifdef BASOP_NOGLOB hSpMusClas->lowrate_pitchGain = round_fx_o( L_mac_o( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 6554, gain_pit_fx, &Overflow ), &Overflow ); /*Q14*Q16(0.1) + Q15 -> Q15*/ -#else - hSpMusClas->lowrate_pitchGain = round_fx( L_mac( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 6554, gain_pit_fx ) ); /*Q14*Q16(0.1) + Q15 -> Q15*/ -#endif /*-----------------------------------------------------------------* * Transform domain contribution encoding - active frames @@ -299,13 +295,8 @@ void encod_gen_voic_fx( } gp_clip_test_gain_pit_fx( st_fx->element_mode, st_fx->core_brate, gain_pit_fx, st_fx->clip_var_fx ); -#ifdef BASOP_NOGLOB Lgcode = L_shl_o( gain_code_fx, Q_new, &Overflow ); /* scaled gain_code with Qnew -> Q16*/ gcode16 = round_fx_o( Lgcode, &Overflow ); /*Q0*/ -#else - Lgcode = L_shl( gain_code_fx, Q_new ); /* scaled gain_code with Qnew -> Q16*/ - gcode16 = round_fx( Lgcode ); -#endif hLPDmem->tilt_code = Est_tilt2( &exc_fx[i_subfr_fx], gain_pit_fx, code_fx, Lgcode, &voice_fac_fx, shift ); /* Q15 */ move16(); @@ -331,21 +322,15 @@ void encod_gen_voic_fx( Ltmp = L_negate( Ltmp ); Ltmp = L_mac( Ltmp, xn_fx[L_SUBFR - 1], 16384 /*Q14*/ ); /* Q_new-1+shift+14+1 */ Ltmp = L_msu( Ltmp, y1_fx[L_SUBFR - 1], gain_pit_fx /*Q14*/ ); /* Q_new-1+shift+14+1 */ -#ifdef BASOP_NOGLOB - Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); /* 15 + Q_new */ - hLPDmem->mem_w0 = round_fx_sat( Ltmp ); /*Q_new-1 */ + Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); /* 15 + Q_new */ + hLPDmem->mem_w0 = round_fx_sat( Ltmp ); /*Q_new-1 */ move16(); -#else - Ltmp = L_shl( Ltmp, sub( 1, shift ) ); - hLPDmem->mem_w0 = round_fx( Ltmp ); /*Q_new-1 */ -#endif IF( gain_preQ_fx != 0 ) { tmp1_fx = add( 16 - ( 2 + Q_AVQ_OUT_DEC + 1 ), Q_new ); FOR( i = 0; i < L_SUBFR; i++ ) { -#ifdef BASOP_NOGLOB /* 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 */ @@ -354,28 +339,13 @@ void encod_gen_voic_fx( Ltmp = L_shl_o( L_mult( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 1, &Overflow ); /* Q16 */ exc2_fx[i + i_subfr_fx] = round_fx_o( L_add_o( Ltmp, Ltmp1, &Overflow ), &Overflow ); /* Q0 */ move16(); -#else - /* Contribution from AVQ layer */ - Ltmp1 = L_mult( gain_preQ_fx, code_preQ_fx[i] ); /* Q2 + Q6 -> Q9*/ - Ltmp1 = L_shl( Ltmp1, tmp1_fx ); /* Q16 + Q_exc */ - - /* Compute exc2 */ - Ltmp = L_shl( L_mult( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 1 ); - exc2_fx[i + i_subfr_fx] = round_fx( L_add( Ltmp, Ltmp1 ) ); -#endif /* 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 */ -#ifdef BASOP_NOGLOB + 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 */ -#else - Ltmp = L_shl( Ltmp, 1 ); /* saturation can occur here */ - - exc_fx[i + i_subfr_fx] = round_fx( L_add( Ltmp, Ltmp1 ) ); -#endif } } ELSE @@ -387,18 +357,11 @@ void encod_gen_voic_fx( FOR( i = 0; i < L_SUBFR; i++ ) { /* code in Q9, gain_pit in Q14 */ - Ltmp = L_mult( gcode16, code_fx[i] ); /* Q10 */ -#ifdef BASOP_NOGLOB + 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 */ -#else - Ltmp = L_shl( Ltmp, 5 ); - Ltmp = L_mac( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx ); - Ltmp = L_shl( Ltmp, 1 ); /* saturation can occur here */ - exc_fx[i + i_subfr_fx] = round_fx( Ltmp ); -#endif } } /*-----------------------------------------------------------------* @@ -635,12 +598,8 @@ void encod_gen_voic_ivas_fx( } /*st_fx->lowrate_pitchGain = 0.9f * st_fx->lowrate_pitchGain + 0.1f * gain_pit_fx;*/ -#ifdef BASOP_NOGLOB hSpMusClas->lowrate_pitchGain = round_fx_o( L_mac_o( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 6554, gain_pit_fx, &Overflow ), &Overflow ); /* Q14 */ move16(); -#else - hSpMusClas->lowrate_pitchGain = round_fx( L_mac( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 6554, gain_pit_fx ) ); /*Q14*Q16(0.1) + Q15 -> Q15*/ -#endif /*-----------------------------------------------------------------* * Transform domain contribution encoding - active frames @@ -691,13 +650,8 @@ 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 ); -#ifdef BASOP_NOGLOB Lgcode = L_shl_o( gain_code_fx, Q_new, &Overflow ); /* scaled gain_code with Qnew -> Q16*/ gcode16 = round_fx_o( Lgcode, &Overflow ); /* Q0 */ -#else - Lgcode = L_shl( gain_code_fx, Q_new ); /* scaled gain_code with Qnew -> Q16*/ - gcode16 = round_fx( Lgcode ); -#endif 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(); @@ -707,7 +661,11 @@ 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 ); @@ -723,21 +681,15 @@ void encod_gen_voic_ivas_fx( 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 -#ifdef BASOP_NOGLOB - Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); // Q_new+15 - hLPDmem->mem_w0 = round_fx_sat( Ltmp ); /*Q_new-1 */ + Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); // Q_new+15 + hLPDmem->mem_w0 = round_fx_sat( Ltmp ); /*Q_new-1 */ move16(); -#else - Ltmp = L_shl( Ltmp, sub( 1, shift ) ); - hLPDmem->mem_w0 = round_fx( Ltmp ); /*Q_new-1 */ -#endif IF( gain_preQ_fx != 0 ) { tmp1_fx = add( 16 - ( 2 + Q_AVQ_OUT_DEC + 1 ), Q_new ); FOR( i = 0; i < L_SUBFR; i++ ) { -#ifdef BASOP_NOGLOB /* 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 */ @@ -746,29 +698,14 @@ void encod_gen_voic_ivas_fx( 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 */ move16(); -#else - /* Contribution from AVQ layer */ - Ltmp1 = L_mult( gain_preQ_fx, code_preQ_fx[i] ); /* Q2 + Q6 -> Q9*/ - Ltmp1 = L_shl( Ltmp1, tmp1_fx ); /* Q16 + Q_exc */ - - /* Compute exc2 */ - Ltmp = L_shl( L_mult( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 1 ); - exc2_fx[i + i_subfr_fx] = round_fx( L_add( Ltmp, Ltmp1 ) ); -#endif /* 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 */ -#ifdef BASOP_NOGLOB + 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 */ move16(); -#else - Ltmp = L_shl( Ltmp, 1 ); /* saturation can occur here */ - - exc_fx[i + i_subfr_fx] = round_fx( L_add( Ltmp, Ltmp1 ) ); -#endif } } ELSE @@ -780,18 +717,11 @@ 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 */ -#ifdef BASOP_NOGLOB + 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 */ -#else - Ltmp = L_shl( Ltmp, 5 ); - Ltmp = L_mac( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx ); - Ltmp = L_shl( Ltmp, 1 ); /* saturation can occur here */ - exc_fx[i + i_subfr_fx] = round_fx( Ltmp ); -#endif } } /*-----------------------------------------------------------------* diff --git a/lib_enc/enc_gen_voic_rf_fx.c b/lib_enc/enc_gen_voic_rf_fx.c index 7d1aac5af606d013baa03454f41609eb5e4d025b..e9c9d87f74bfa057d719079170b1496c85b61887 100644 --- a/lib_enc/enc_gen_voic_rf_fx.c +++ b/lib_enc/enc_gen_voic_rf_fx.c @@ -440,31 +440,16 @@ void coder_acelp_rf_fx( * Update memory of the weighting filter *-----------------------------------------------------------------*/ /* st_fx->_rf_mem_w0 = xn[L_SUBFR-1] - (gain_pit*y1[L_SUBFR-1]) - (gain_code*y2[L_SUBFR-1]); */ - Ltmp = Mpy_32_16_1( gain_code, y2[L_SUBFR - 1] ); /* Q10 */ -#ifdef BASOP_NOGLOB + Ltmp = Mpy_32_16_1( gain_code, y2[L_SUBFR - 1] ); /* Q10 */ Ltmp = L_shl_o( Ltmp, add( 5, Q_xn ), &Overflow ); /* Q15 + Q_xn */ Ltmp = L_mac_o( Ltmp, y1[L_SUBFR - 1], gain_pit, &Overflow ); /* Q15 + Q_xn */ -#else - Ltmp = L_shl( Ltmp, add( 5, Q_xn ) ); - Ltmp = L_mac( Ltmp, y1[L_SUBFR - 1], gain_pit ); -#endif /* Add Gaussian contribution*/ - Ltmp2 = Mpy_32_16_1( gain_code2, y22[L_SUBFR - 1] ); /* Q10 */ -#ifdef BASOP_NOGLOB + Ltmp2 = Mpy_32_16_1( gain_code2, y22[L_SUBFR - 1] ); /* Q10 */ Ltmp2 = L_shl_o( Ltmp2, add( 5, Q_xn ), &Overflow ); /* Q15 + Q_xn */ Ltmp = L_add_o( Ltmp, Ltmp2, &Overflow ); /* Q15 + Q_xn */ hRF->rf_mem_w0 = sub_o( xn[L_SUBFR - 1], round_fx_o( L_shl_o( Ltmp, 1, &Overflow ), &Overflow ), &Overflow ); /* Q_xn */ move16(); hRF->rf_mem_w0 = shr_o( hRF->rf_mem_w0, shift, &Overflow ); /*Qnew-1*/ -#else - Ltmp2 = L_shl( Ltmp2, add( 5, Q_xn ) ); - Ltmp = L_add( Ltmp, Ltmp2 ); - hRF->rf_mem_w0 = sub( xn[L_SUBFR - 1], round_fx( L_shl( Ltmp, 1 ) ) ); - move16(); - BASOP_SATURATE_WARNING_OFF_EVS; - hRF->rf_mem_w0 = shr( hRF->rf_mem_w0, shift ); /*Qnew-1*/ - BASOP_SATURATE_WARNING_ON_EVS; -#endif /*-------------------------------------------------------* @@ -477,34 +462,17 @@ void coder_acelp_rf_fx( 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] ); /* Q10 */ -#ifdef BASOP_NOGLOB + Ltmp = Mpy_32_16_1( gain_code2, code2[i] ); /* Q10 */ Ltmp = L_shl_o( Ltmp, Q_new_p5, &Overflow ); /* Q15 + Q_new */ Ltmp = L_mac_o( Ltmp, gain_pit, exc_rf[i + i_subfr], &Overflow ); /* Q15 + Q_new */ exc2[i] = round_fx_o( L_shl_o( Ltmp, 1, &Overflow ), &Overflow ); /* Q_new */ move16(); -#else - Ltmp = L_shl( Ltmp, Q_new_p5 ); - Ltmp = L_mac( Ltmp, gain_pit, exc_rf[i + i_subfr] ); - BASOP_SATURATE_WARNING_OFF_EVS - exc2[i] = round_fx( L_shl( Ltmp, 1 ) ); - BASOP_SATURATE_WARNING_ON_EVS -#endif - Ltmp2 = Mpy_32_16_1( gain_code_vect[j], code[i] ); /* Q10 */ -#ifdef BASOP_NOGLOB + Ltmp2 = Mpy_32_16_1( gain_code_vect[j], code[i] ); /* Q10 */ Ltmp2 = L_shl_o( Ltmp2, Q_new_p5, &Overflow ); /* Q15 + Q_new */ Ltmp = L_add_o( Ltmp, Ltmp2, &Overflow ); /* Q15 + Q_new */ Ltmp = L_shl_o( Ltmp, 1, &Overflow ); /* saturation can occur here Q16 + Q_new*/ exc_rf[i + i_subfr] = round_fx_o( Ltmp, &Overflow ); /* Q_new */ move16(); -#else - 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_rf[i + i_subfr] = round_fx( Ltmp ); -#endif } tmp2 = L_SUBFR; move16(); diff --git a/lib_enc/enc_higher_acelp_fx.c b/lib_enc/enc_higher_acelp_fx.c index 3630be38e58ed97d2c08a750cdab36562b500cf2..c4c5444696d0efcd6603c75867f336f1d0973426 100644 --- a/lib_enc/enc_higher_acelp_fx.c +++ b/lib_enc/enc_higher_acelp_fx.c @@ -86,11 +86,7 @@ void transf_cdbk_enc_fx( *--------------------------------------------------------------*/ IF( EQ_16( st_fx->coder_type, INACTIVE ) ) { -#ifdef BASOP_NOGLOB gcode16 = round_fx_o( L_shl_o( gain_code, Q_new, &Overflow ), &Overflow ); -#else - gcode16 = round_fx( L_shl( gain_code, Q_new ) ); -#endif FOR( i = 0; i < L_SUBFR; i++ ) { /*x_tran[i] = xn[i] - *gain_pit * y1[i] - gain_code * y2[i];*/ @@ -98,15 +94,10 @@ void transf_cdbk_enc_fx( Ltmp = L_shl( Ltmp, add( 5, shift ) ); Ltmp = L_negate( Ltmp ); Ltmp = L_mac( Ltmp, xn[i], 16384 ); - Ltmp = L_msu( Ltmp, y1[i], *gain_pit ); /* Q_new + 14 + shift */ -#ifdef BASOP_NOGLOB + Ltmp = L_msu( Ltmp, y1[i], *gain_pit ); /* Q_new + 14 + shift */ Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); /* Q_new + 15 */ x_tran[i] = round_fx_sat( Ltmp ); /*Q_new-1 */ move16(); -#else - Ltmp = L_shl( Ltmp, sub( 1, shift ) ); - x_tran[i] = round_fx( Ltmp ); /*Q_new-1 */ -#endif } find_cn_fx( x_tran, Ap, p_Aq, x_in ); } @@ -154,15 +145,9 @@ void transf_cdbk_enc_fx( { /*fcorr += fx_tran[i]*(float)ix_norm[i];*/ /*fener += (float)ix_norm[i]*(float)ix_norm[i];*/ -#ifdef BASOP_NOGLOB stmp = shl_sat( x_norm[i], Q_AVQ_OUT ); L_corr = L_mac_sat( L_corr, x_tran[i], stmp ); L_ener = L_mac_sat( L_ener, stmp, stmp ); -#else - stmp = shl( x_norm[i], Q_AVQ_OUT ); - L_corr = L_mac( L_corr, x_tran[i], stmp ); - L_ener = L_mac( L_ener, stmp, stmp ); -#endif } L_ener = L_max( L_ener, 1 ); @@ -183,32 +168,20 @@ void transf_cdbk_enc_fx( } m_corr = div_s( m_corr, m_ener ); /* e_corr - e_ener */ e_corr = sub( e_corr, e_ener ); -#ifdef BASOP_NOGLOB Ltmp = L_shl_sat( m_corr, s_min( add( e_corr, 1 ), 31 ) ); /* Lgain in Q16 */ -#else - Ltmp = L_shl( m_corr, s_min( add( e_corr, 1 ), 31 ) ); /* Lgain in Q16 */ -#endif IF( EQ_16( st_fx->coder_type, INACTIVE ) ) { Ltmp1 = L_max( gain_code, 1 ); e_den = norm_l( Ltmp1 ); -#ifdef BASOP_NOGLOB m_den = extract_h( L_shl_sat( Ltmp1, e_den ) ); -#else - m_den = extract_h( L_shl( Ltmp1, e_den ) ); -#endif /* ensure m_corr < m_den */ test(); IF( m_corr > 0 && m_den > 0 ) { m_corr = div_s( 16384, m_den ); e_corr = sub( 14 + 4, e_den ); - Ltmp = L_shr( Mult_32_16( Ltmp, m_corr ), e_corr ); /*Q12*/ -#ifdef BASOP_NOGLOB + Ltmp = L_shr( Mult_32_16( Ltmp, m_corr ), e_corr ); /*Q12*/ stmp = round_fx_o( L_shl_o( Ltmp, 16, &Overflow ), &Overflow ); /* Q12 */ -#else - stmp = round_fx( L_shl( Ltmp, 16 ) ); -#endif } ELSE { @@ -228,13 +201,8 @@ void transf_cdbk_enc_fx( index = usquant_fx( stmp, &stmp, G_AVQ_MIN_INACT_Q12, G_AVQ_DELTA_INACT_Q12 >> 1, ( 1 << G_AVQ_BITS ) ); /* Q0 */ } Ltmp = Mult_32_16( gain_code, stmp ); /* Q16 * Q12 - 15 -> Q13*/ -#ifdef BASOP_NOGLOB - Ltmp = L_shl_sat( Ltmp, 5 ); /* Q13 -> Q18*/ - *gain_preQ = round_fx_sat( Ltmp ); /* Q2*/ -#else - Ltmp = L_shl( Ltmp, 5 ); /* Q13 -> Q18*/ - *gain_preQ = round_fx( Ltmp ); /* Q2*/ -#endif + Ltmp = L_shl_sat( Ltmp, 5 ); /* Q13 -> Q18*/ + *gain_preQ = round_fx_sat( Ltmp ); /* Q2*/ } ELSE { @@ -320,11 +288,7 @@ void transf_cdbk_enc_fx( FOR( i = 0; i < Nsv * WIDTH_BAND; i++ ) { -#ifdef BASOP_NOGLOB x_tran[i] = shl_o( x_norm[i], Q_AVQ_OUT_DEC, &Overflow ); -#else - x_tran[i] = shl( x_norm[i], Q_AVQ_OUT_DEC ); -#endif move16(); } set16_fx( x_tran + Nsv * WIDTH_BAND, 0, sub( L_SUBFR, i_mult2( WIDTH_BAND, Nsv ) ) ); @@ -405,11 +369,7 @@ void transf_cdbk_enc_fx( updt_tar_HR_fx( cn, cn, code_preQ, *gain_preQ, sub( Q_new, add( -15 + 2, Q_AVQ_OUT_DEC ) ), L_SUBFR ); updt_tar_HR_fx( xn, xn, x_tran, *gain_preQ, sub( Q_new, add( -15 + 2, Q_AVQ_OUT_DEC ) ), L_SUBFR ); -#ifdef BASOP_NOGLOB *gain_pit = corr_xy1_fx( xn, y1, g_corr, L_SUBFR, 0, &Overflow ); /* Q14 */ -#else - *gain_pit = corr_xy1_fx( xn, y1, g_corr, L_SUBFR, 0 ); -#endif /* clip gain if necessary to avoid problems at decoder */ test(); if ( EQ_16( clip_gain, 1 ) && GT_16( *gain_pit, 15565 ) ) @@ -492,11 +452,7 @@ void transf_cdbk_enc_ivas_fx( *--------------------------------------------------------------*/ IF( EQ_16( st_fx->coder_type, INACTIVE ) ) { -#ifdef BASOP_NOGLOB gcode16 = round_fx_o( L_shl_o( gain_code, Q_new, &Overflow ), &Overflow ); -#else - gcode16 = round_fx( L_shl( gain_code, Q_new ) ); -#endif FOR( i = 0; i < L_SUBFR; i++ ) { /*x_tran[i] = xn[i] - *gain_pit * y1[i] - gain_code * y2[i];*/ @@ -504,14 +460,9 @@ void transf_cdbk_enc_ivas_fx( Ltmp = L_shl( Ltmp, add( 5, shift ) ); Ltmp = L_negate( Ltmp ); Ltmp = L_mac( Ltmp, xn[i], 16384 ); - Ltmp = L_msu( Ltmp, y1[i], *gain_pit ); /* Q_new + 14 + shift */ -#ifdef BASOP_NOGLOB + Ltmp = L_msu( Ltmp, y1[i], *gain_pit ); /* Q_new + 14 + shift */ Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); /* Q_new + 15 */ x_tran[i] = round_fx_sat( Ltmp ); /*Q_new-1 */ -#else - Ltmp = L_shl( Ltmp, sub( 1, shift ) ); - x_tran[i] = round_fx( Ltmp ); /*Q_new-1 */ -#endif } find_cn_fx( x_tran, Ap, p_Aq, x_in ); } @@ -559,15 +510,9 @@ void transf_cdbk_enc_ivas_fx( { /*fcorr += fx_tran[i]*(float)ix_norm[i];*/ /*fener += (float)ix_norm[i]*(float)ix_norm[i];*/ -#ifdef BASOP_NOGLOB stmp = shl_sat( x_norm[i], Q_AVQ_OUT ); L_corr = L_mac_sat( L_corr, x_tran[i], stmp ); L_ener = L_mac_sat( L_ener, stmp, stmp ); -#else - stmp = shl( x_norm[i], Q_AVQ_OUT ); - L_corr = L_mac( L_corr, x_tran[i], stmp ); - L_ener = L_mac( L_ener, stmp, stmp ); -#endif } L_ener = L_max( L_ener, 1 ); @@ -588,32 +533,20 @@ void transf_cdbk_enc_ivas_fx( } m_corr = div_s( m_corr, m_ener ); /* e_corr - e_ener */ e_corr = sub( e_corr, e_ener ); -#ifdef BASOP_NOGLOB Ltmp = L_shl_sat( m_corr, s_min( add( e_corr, 1 ), 31 ) ); /* Lgain in Q16 */ -#else - Ltmp = L_shl( m_corr, s_min( add( e_corr, 1 ), 31 ) ); /* Lgain in Q16 */ -#endif IF( EQ_16( st_fx->coder_type, INACTIVE ) ) { Ltmp1 = L_max( gain_code, 1 ); e_den = norm_l( Ltmp1 ); -#ifdef BASOP_NOGLOB m_den = extract_h( L_shl_sat( Ltmp1, e_den ) ); -#else - m_den = extract_h( L_shl( Ltmp1, e_den ) ); -#endif /* ensure m_corr < m_den */ test(); IF( m_corr > 0 && m_den > 0 ) { m_corr = div_s( 16384, m_den ); e_corr = sub( 14 + 4, e_den ); - Ltmp = L_shr( Mult_32_16( Ltmp, m_corr ), e_corr ); /*Q12*/ -#ifdef BASOP_NOGLOB + Ltmp = L_shr( Mult_32_16( Ltmp, m_corr ), e_corr ); /*Q12*/ stmp = round_fx_o( L_shl_o( Ltmp, 16, &Overflow ), &Overflow ); /* Q12 */ -#else - stmp = round_fx( L_shl( Ltmp, 16 ) ); -#endif } ELSE { @@ -633,14 +566,9 @@ void transf_cdbk_enc_ivas_fx( index = usquant_fx( stmp, &stmp, G_AVQ_MIN_INACT_Q12, G_AVQ_DELTA_INACT_Q12 >> 1, ( 1 << G_AVQ_BITS ) ); /* Q0 */ } Ltmp = Mult_32_16( gain_code, stmp ); /* Q16 * Q12 - 15 -> Q13*/ -#ifdef BASOP_NOGLOB - Ltmp = L_shl_sat( Ltmp, 5 ); /* Q13 -> Q18*/ - *gain_preQ = round_fx_sat( Ltmp ); /* Q2*/ + Ltmp = L_shl_sat( Ltmp, 5 ); /* Q13 -> Q18*/ + *gain_preQ = round_fx_sat( Ltmp ); /* Q2*/ move16(); -#else - Ltmp = L_shl( Ltmp, 5 ); /* Q13 -> Q18*/ - *gain_preQ = round_fx( Ltmp ); /* Q2*/ -#endif } ELSE { @@ -728,11 +656,7 @@ void transf_cdbk_enc_ivas_fx( FOR( i = 0; i < Nsv * WIDTH_BAND; i++ ) { -#ifdef BASOP_NOGLOB x_tran[i] = shl_o( x_norm[i], Q_AVQ_OUT_DEC, &Overflow ); -#else - x_tran[i] = shl( x_norm[i], Q_AVQ_OUT_DEC ); -#endif move16(); } set16_fx( x_tran + Nsv * WIDTH_BAND, 0, sub( L_SUBFR, i_mult2( WIDTH_BAND, Nsv ) ) ); @@ -821,12 +745,8 @@ void transf_cdbk_enc_ivas_fx( updt_tar_HR_fx( cn, cn, code_preQ, *gain_preQ, sub( Q_new, add( -15 + 2, Q_AVQ_OUT_DEC ) ), L_SUBFR ); updt_tar_HR_fx( xn, xn, x_tran, *gain_preQ, sub( Q_new, add( -15 + 2, Q_AVQ_OUT_DEC ) ), L_SUBFR ); -#ifdef BASOP_NOGLOB *gain_pit = corr_xy1_fx( xn, y1, g_corr, L_SUBFR, 0, &Overflow ); /* Q14 */ move16(); -#else - *gain_pit = corr_xy1_fx( xn, y1, g_corr, L_SUBFR, 0 ); -#endif /* clip gain if necessary to avoid problems at decoder */ test(); if ( EQ_16( clip_gain, 1 ) && GT_16( *gain_pit, 15565 ) ) @@ -908,13 +828,8 @@ Word16 gain_quant_fx( /* o: quantization index Q0*/ /*tmp1 = sub(c_max,c_min); Q14*/ /*tmp2 = sub(c_gain,c_min); Q14*/ -#ifdef BASOP_NOGLOB tmp1 = msu_r_sat( L_deposit_h( c_max /*in Q13 already*/ ), c_min, 16384 ); /*Q13*/ tmp2 = msu_r_sat( L_deposit_h( c_gain /*in Q13 already*/ ), c_min, 16384 ); /*Q13*/ -#else - tmp1 = msu_r( L_deposit_h( c_max /*in Q13 already*/ ), c_min, 16384 ); /*Q13*/ - tmp2 = msu_r( L_deposit_h( c_gain /*in Q13 already*/ ), c_min, 16384 ); /*Q13*/ -#endif IF( tmp1 != 0 ) { exp = norm_s( tmp1 ); diff --git a/lib_enc/enc_nelp_fx.c b/lib_enc/enc_nelp_fx.c index aedb1d2c2efda7795e84356d24d205564498b5e4..c3eb2ae189911eb524d0ed32b015b0a58959554d 100644 --- a/lib_enc/enc_nelp_fx.c +++ b/lib_enc/enc_nelp_fx.c @@ -145,11 +145,7 @@ void encod_nelp_fx( * Updates: last value of new target is stored in mem_w0 *-----------------------------------------------------------------*/ -#ifdef BASOP_NOGLOB hLPDmem->mem_w0 = sub_sat( shr_sat( xn_fx[L_SUBFR - 1], shift ), shr( exc_fx[L_FRAME - 1], 1 ) ); -#else - hLPDmem->mem_w0 = sub( shr( xn_fx[L_SUBFR - 1], shift ), shr( exc_fx[L_FRAME - 1], 1 ) ); -#endif move16(); /*Q_new-1 */ hLPDmem->tilt_code = 0; move16(); /* purely unvoiced */ @@ -289,11 +285,7 @@ void encod_nelp_ivas_fx( * Updates: last value of new target is stored in mem_w0 *-----------------------------------------------------------------*/ -#ifdef BASOP_NOGLOB hLPDmem->mem_w0 = sub_sat( shr_sat( xn_fx[L_SUBFR - 1], shift ), shr( exc_fx[L_FRAME - 1], 1 ) ); -#else - hLPDmem->mem_w0 = sub( shr( xn_fx[L_SUBFR - 1], shift ), shr( exc_fx[L_FRAME - 1], 1 ) ); -#endif move16(); /*Q_new-1 */ hLPDmem->tilt_code = 0; move16(); /* purely unvoiced */ diff --git a/lib_enc/enc_pit_exc_fx.c b/lib_enc/enc_pit_exc_fx.c index 54674da1e884ace3f39577d89a47d6c2a62cb795..e0d4f50163ee4f433de12fe5b2f507ebc8ec7eb8 100644 --- a/lib_enc/enc_pit_exc_fx.c +++ b/lib_enc/enc_pit_exc_fx.c @@ -296,11 +296,7 @@ void enc_pit_exc_fx( } /*st_fx->lowrate_pitchGain = 0.9f * st_fx->lowrate_pitchGain + 0.1f * gain_pit;*/ -#ifdef BASOP_NOGLOB hSpMusClas->lowrate_pitchGain = round_fx_o( L_mac_o( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 6554, gain_pit, &Overflow ), &Overflow ); /*Q14*Q16(0.1) + Q15 -> Q15*/ -#else - hSpMusClas->lowrate_pitchGain = round_fx( L_mac( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 6554, gain_pit ) ); /*Q14*Q16(0.1) + Q15 -> Q15*/ -#endif gpit_tmp = gain_pit; move16(); /*Q14*/ @@ -356,13 +352,8 @@ void enc_pit_exc_fx( } gp_clip_test_gain_pit_fx( st_fx->element_mode, st_fx->core_brate, gain_pit, st_fx->clip_var_fx ); -#ifdef BASOP_NOGLOB Lgcode = L_shl_sat( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/ gcode16 = round_fx_sat( Lgcode ); -#else - Lgcode = L_shl( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/ - gcode16 = round_fx( Lgcode ); -#endif IF( use_fcb != 0 ) { hLPDmem->tilt_code = Est_tilt2( &exc[i_subfr], gain_pit, code, Lgcode, &voice_fac, shift ); /* Q15 */ @@ -378,8 +369,7 @@ void enc_pit_exc_fx( *-----------------------------------------------------------------*/ IF( use_fcb != 0 ) { - Ltmp = L_mult( gcode16, y2[L_subfr - 1] ); /* Q10 + Q_new */ -#ifdef BASOP_NOGLOB + Ltmp = L_mult( gcode16, y2[L_subfr - 1] ); /* Q10 + Q_new */ Ltmp = L_shl_o( Ltmp, add( 5, shift ), &Overflow ); /* Q15 + Q_new + shift */ Ltmp = L_negate( Ltmp ); Ltmp = L_mac_o( Ltmp, xn[L_subfr - 1], 16384, &Overflow ); /* Q_new + Q15 + shift */ @@ -387,29 +377,14 @@ void enc_pit_exc_fx( Ltmp = L_shl_o( Ltmp, sub( 1, shift ), &Overflow ); /* Q_new + 15 */ hLPDmem->mem_w0 = round_fx_o( Ltmp, &Overflow ); /*Q_new-1 */ move16(); -#else - Ltmp = L_mult( gcode16, y2[L_subfr - 1] ); - Ltmp = L_shl( Ltmp, add( 5, shift ) ); - Ltmp = L_negate( Ltmp ); - Ltmp = L_mac( Ltmp, xn[L_subfr - 1], 16384 ); - Ltmp = L_msu( Ltmp, y1[L_subfr - 1], gain_pit ); - Ltmp = L_shl( Ltmp, sub( 1, shift ) ); - hLPDmem->mem_w0 = round_fx( Ltmp ); /*Q_new-1 */ -#endif } ELSE { - Ltmp = L_mult( xn[L_subfr - 1], 16384 ); /* Q_new + 14 -shift */ -#ifdef BASOP_NOGLOB + Ltmp = L_mult( xn[L_subfr - 1], 16384 ); /* Q_new + 14 -shift */ Ltmp = L_msu_sat( Ltmp, y1[L_subfr - 1], gain_pit ); /* Q_new + 14 -shift */ Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); /* Q_new + 15 */ hLPDmem->mem_w0 = round_fx_sat( Ltmp ); /*Q_new-1 */ move16(); -#else - Ltmp = L_msu( Ltmp, y1[L_subfr - 1], gain_pit ); - Ltmp = L_shl( Ltmp, sub( 1, shift ) ); - hLPDmem->mem_w0 = round_fx( Ltmp ); /*Q_new-1 */ -#endif } /*-----------------------------------------------------------------* @@ -421,20 +396,12 @@ void enc_pit_exc_fx( FOR( i = 0; i < L_subfr; i++ ) { /* code in Q9, gain_pit in Q14 */ - Ltmp = L_mult( gcode16, code[i] ); /* Q10 + Q_new */ -#ifdef BASOP_NOGLOB + Ltmp = L_mult( gcode16, code[i] ); /* Q10 + Q_new */ Ltmp = L_shl_o( Ltmp, 5, &Overflow ); /* Q15 + Q_new */ Ltmp = L_mac_o( Ltmp, exc[i + i_subfr], gain_pit, &Overflow ); /* Q15 + Q_new */ Ltmp = L_shl_o( Ltmp, 1, &Overflow ); /* saturation can occur here Q_new + Q16*/ exc[i + i_subfr] = round_fx_o( Ltmp, &Overflow ); /* Q_new */ move16(); -#else - Ltmp = L_mult( gcode16, code[i] ); - Ltmp = L_shl( Ltmp, 5 ); - Ltmp = L_mac( Ltmp, exc[i + i_subfr], gain_pit ); - Ltmp = L_shl( Ltmp, 1 ); /* saturation can occur here */ - exc[i + i_subfr] = round_fx( Ltmp ); -#endif } } ELSE @@ -443,13 +410,8 @@ void enc_pit_exc_fx( { Ltmp = L_mult( exc[i + i_subfr], gain_pit ); /* Q15 + Q_new */ -#ifdef BASOP_NOGLOB - Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q16 + Q_new */ - exc[i + i_subfr] = round_fx_sat( Ltmp ); /* Q_new */ -#else - Ltmp = L_shl( Ltmp, 1 ); /* saturation can occur here */ - exc[i + i_subfr] = round_fx( Ltmp ); -#endif + Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q16 + Q_new */ + exc[i + i_subfr] = round_fx_sat( Ltmp ); /* Q_new */ } } @@ -561,11 +523,7 @@ void enc_pit_exc_fx( } } -#ifdef BASOP_NOGLOB - cum_gpit = shl_o( cum_gpit, 1, &Overflow ); /*Q15*/ -#else /* BASOP_NOGLOB */ - cum_gpit = shl( cum_gpit, 1 ); /*Q15*/ -#endif + cum_gpit = shl_o( cum_gpit, 1, &Overflow ); /*Q15*/ *gpit = round_fx( L_mac( L_mult( 3277, *gpit ), 29491, cum_gpit ) ); /*Q15*/ } @@ -621,6 +579,7 @@ 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*/ + Word16 h1_q15[PIT_EXC_L_SUBFR + ( M + 1 )]; SP_MUS_CLAS_HANDLE hSpMusClas = st_fx->hSpMusClas; BSTR_ENC_HANDLE hBstr = st_fx->hBstr; GSC_ENC_HANDLE hGSCEnc = st_fx->hGSCEnc; @@ -810,8 +769,9 @@ void enc_pit_exc_ivas_fx( * Codebook target computation * (No LP filtering of the adaptive excitation) *-----------------------------------------------------------------*/ + 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, + 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 */ IF( EQ_16( lp_flag, NORMAL_OPERATION ) ) @@ -820,11 +780,7 @@ void enc_pit_exc_ivas_fx( } /*st_fx->lowrate_pitchGain = 0.9f * st_fx->lowrate_pitchGain + 0.1f * gain_pit;*/ -#ifdef BASOP_NOGLOB hSpMusClas->lowrate_pitchGain = round_fx_o( L_mac_o( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 6554, gain_pit, &Overflow ), &Overflow ); /*Q14*Q16(0.1) + Q15 -> Q15*/ -#else - hSpMusClas->lowrate_pitchGain = round_fx( L_mac( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 6554, gain_pit ) ); /*Q14*Q16(0.1) + Q15 -> Q15*/ -#endif gpit_tmp = gain_pit; move16(); /*Q14*/ @@ -881,13 +837,8 @@ void enc_pit_exc_ivas_fx( } gp_clip_test_gain_pit_fx( st_fx->element_mode, st_fx->core_brate, gain_pit, st_fx->clip_var_fx ); -#ifdef BASOP_NOGLOB Lgcode = L_shl_sat( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/ gcode16 = round_fx_sat( Lgcode ); -#else - Lgcode = L_shl( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/ - gcode16 = round_fx( Lgcode ); -#endif IF( use_fcb != 0 ) { hLPDmem->tilt_code = est_tilt_ivas_fx( &exc[i_subfr], gain_pit, code, gain_code, &voice_fac, Q_new, L_SUBFR, 0 ); // Q15 @@ -904,35 +855,19 @@ void enc_pit_exc_ivas_fx( IF( use_fcb != 0 ) { Ltmp = L_mult0( gcode16, y2[L_subfr - 1] ); -#ifdef BASOP_NOGLOB Ltmp = L_shl_o( Ltmp, add( 5, shift ), &Overflow ); // Q_new+14+shift Ltmp = L_negate( Ltmp ); Ltmp = L_mac_o( Ltmp, xn[L_subfr - 1], 16384, &Overflow ); // Q_new-1+15+shift Ltmp = L_msu_o( Ltmp, y1[L_subfr - 1], gain_pit, &Overflow ); // Q_new-1+15+shift Ltmp = L_shl_o( Ltmp, sub( 1, shift ), &Overflow ); // Q_new+15 hGSCEnc->mem_w0_tmp_fx = round_fx_o( Ltmp, &Overflow ); /*Q_new-1 */ -#else - Ltmp = L_mult( gcode16, y2[L_subfr - 1] ); - Ltmp = L_shl( Ltmp, add( 5, shift ) ); - Ltmp = L_negate( Ltmp ); - Ltmp = L_mac( Ltmp, xn[L_subfr - 1], 16384 ); - Ltmp = L_msu( Ltmp, y1[L_subfr - 1], gain_pit ); - Ltmp = L_shl( Ltmp, sub( 1, shift ) ); - hGSCEnc->mem_w0_tmp_fx = round_fx( Ltmp ); /*Q_new-1 */ -#endif } ELSE { - Ltmp = L_mult( xn[L_subfr - 1], 16384 ); // Q_new-1+15+shift -#ifdef BASOP_NOGLOB + Ltmp = L_mult( xn[L_subfr - 1], 16384 ); // Q_new-1+15+shift Ltmp = L_msu_sat( Ltmp, y1[L_subfr - 1], gain_pit ); // Q_new-1+15+shift Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); // Q_new+15 hGSCEnc->mem_w0_tmp_fx = round_fx_sat( Ltmp ); /*Q_new-1 */ -#else - Ltmp = L_msu( Ltmp, y1[L_subfr - 1], gain_pit ); - Ltmp = L_shl( Ltmp, sub( 1, shift ) ); - hGSCEnc->mem_w0_tmp_fx = round_fx( Ltmp ); /*Q_new-1 */ -#endif } /*-----------------------------------------------------------------* @@ -944,20 +879,12 @@ void enc_pit_exc_ivas_fx( FOR( i = 0; i < L_subfr; i++ ) { /* code in Q9, gain_pit in Q14 */ - Ltmp = L_mult( gcode16, code[i] ); /* Q10 + Q_new */ -#ifdef BASOP_NOGLOB + Ltmp = L_mult( gcode16, code[i] ); /* Q10 + Q_new */ Ltmp = L_shl_o( Ltmp, 5, &Overflow ); /* Q15 + Q_new */ Ltmp = L_mac_o( Ltmp, exc[i + i_subfr], gain_pit, &Overflow ); /* Q15 + Q_new */ Ltmp = L_shl_o( Ltmp, 1, &Overflow ); /* saturation can occur here Q16 + Q_new */ exc[i + i_subfr] = round_fx_o( Ltmp, &Overflow ); /* Q_new */ move16(); -#else - Ltmp = L_mult( gcode16, code[i] ); - Ltmp = L_shl( Ltmp, 5 ); - Ltmp = L_mac( Ltmp, exc[i + i_subfr], gain_pit ); - Ltmp = L_shl( Ltmp, 1 ); /* saturation can occur here */ - exc[i + i_subfr] = round_fx( Ltmp ); -#endif } } ELSE @@ -966,14 +893,9 @@ void enc_pit_exc_ivas_fx( { Ltmp = L_mult( exc[i + i_subfr], gain_pit ); /* Q15 + Q_new */ -#ifdef BASOP_NOGLOB - Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q16 + Q_new */ - exc[i + i_subfr] = round_fx_sat( Ltmp ); /* Q_new */ + Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q16 + Q_new */ + exc[i + i_subfr] = round_fx_sat( Ltmp ); /* Q_new */ move16(); -#else - Ltmp = L_shl( Ltmp, 1 ); /* saturation can occur here */ - exc[i + i_subfr] = round_fx( Ltmp ); -#endif } } @@ -1085,10 +1007,6 @@ void enc_pit_exc_ivas_fx( } } -#ifdef BASOP_NOGLOB - cum_gpit = shl_o( cum_gpit, 1, &Overflow ); /*Q15*/ -#else /* BASOP_NOGLOB */ - cum_gpit = shl( cum_gpit, 1 ); /*Q15*/ -#endif + cum_gpit = shl_o( cum_gpit, 1, &Overflow ); /*Q15*/ *gpit = round_fx( L_mac( L_mult( 3277, *gpit ), 29491, cum_gpit ) ); /*Q15*/ } diff --git a/lib_enc/enc_tran_fx.c b/lib_enc/enc_tran_fx.c index 71e8b9e3b3253f984c4b6825d838e148c8c3624c..b4495d4ff0e878833da3769ebae82085cc01fdd2 100644 --- a/lib_enc/enc_tran_fx.c +++ b/lib_enc/enc_tran_fx.c @@ -4,7 +4,7 @@ #include #include "options.h" /* Compilation switches */ #include "cnst.h" /* Compilation switches */ -//#include "prot_fx.h" /* Function prototypes */ +// #include "prot_fx.h" /* Function prototypes */ #include "rom_com_fx.h" /* Static table prototypes */ #include "rom_com.h" /* Static table prototypes */ #include "prot.h" /* Function prototypes */ @@ -229,13 +229,8 @@ Word16 encod_tran_fx( } gp_clip_test_gain_pit_fx( st_fx->element_mode, st_fx->core_brate, gain_pit, st_fx->clip_var_fx ); -#ifdef BASOP_NOGLOB Lgcode = L_shl_o( gain_code, Q_new, &Overflow ); /* scaled gain_code with Qnew -> Q16*/ gcode16 = round_fx_o( Lgcode, &Overflow ); -#else - Lgcode = L_shl( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/ - gcode16 = round_fx( Lgcode ); -#endif hLPDmem->tilt_code = Est_tilt2( &exc_fx[i_subfr], gain_pit, code, Lgcode, &voice_fac, shift ); /* Q15 */ /*-----------------------------------------------------------------* * Update memory of the weighting filter @@ -247,13 +242,8 @@ Word16 encod_tran_fx( L_tmp = L_negate( L_tmp ); L_tmp = L_mac( L_tmp, xn[L_SUBFR - 1], 16384 ); L_tmp = L_msu( L_tmp, y1[L_SUBFR - 1], gain_pit ); -#ifdef BASOP_NOGLOB L_tmp = L_shl_sat( L_tmp, sub( 1, shift ) ); /* Q_new + 15 */ hLPDmem->mem_w0 = round_fx_sat( L_tmp ); /*Q_new-1*/ -#else - L_tmp = L_shl( L_tmp, sub( 1, shift ) ); - hLPDmem->mem_w0 = round_fx( L_tmp ); /*Q_new-1*/ -#endif /*-----------------------------------------------------------------* * Construct adaptive part of the excitation * Save the non-enhanced excitation for FEC_exc @@ -269,11 +259,7 @@ Word16 encod_tran_fx( { FOR( i = 0; i < L_SUBFR; i++ ) { -#ifdef BASOP_NOGLOB exc2_fx[i + i_subfr] = round_fx_sat( L_shl_sat( L_mult_sat( gain_pit, exc_fx[i + i_subfr] ), 1 ) ); /* Q_new */ -#else - exc2_fx[i + i_subfr] = round_fx( L_shl( L_mult( gain_pit, exc_fx[i + i_subfr] ), 1 ) ); -#endif } } ELSE @@ -292,18 +278,11 @@ Word16 encod_tran_fx( FOR( i = 0; i < L_SUBFR; i++ ) { /* code in Q9, gain_pit in Q14 */ - L_tmp = L_mult( gcode16, code[i] ); /* Q10 + Q_new */ -#ifdef BASOP_NOGLOB + L_tmp = L_mult( gcode16, code[i] ); /* Q10 + Q_new */ L_tmp = L_shl_o( L_tmp, 5, &Overflow ); /* Q15 + Q_new */ L_tmp = L_mac_o( L_tmp, exc_fx[i + i_subfr], gain_pit, &Overflow ); /* Q15 + Q_new */ L_tmp = L_shl_o( L_tmp, 1, &Overflow ); /* saturation can occur here Q16 + Q_new */ exc_fx[i + i_subfr] = round_fx_o( L_tmp, &Overflow ); /* Q_new */ -#else - L_tmp = L_shl( L_tmp, 5 ); - L_tmp = L_mac( L_tmp, exc_fx[i + i_subfr], gain_pit ); - L_tmp = L_shl( L_tmp, 1 ); /* saturation can occur here */ - exc_fx[i + i_subfr] = round_fx( L_tmp ); -#endif } /*-----------------------------------------------------------------* @@ -315,8 +294,7 @@ Word16 encod_tran_fx( tmp1_fx = add( 16 - ( 2 + Q_AVQ_OUT_DEC + 1 ), Q_new ); FOR( i = 0; i < L_SUBFR; i++ ) { - L_tmp = L_mult( gain_preQ, code_preQ[i] ); /* Q2 + Q10 -> Q13*/ -#ifdef BASOP_NOGLOB + L_tmp = L_mult( gain_preQ, code_preQ[i] ); /* Q2 + Q10 -> Q13*/ L_tmp = L_shl_o( L_tmp, tmp1_fx, &Overflow ); /* Q16 + Q_exc */ tmp_fx = round_fx_o( L_tmp, &Overflow ); @@ -324,15 +302,6 @@ Word16 encod_tran_fx( move16(); exc_fx[i + i_subfr] = add_o( exc_fx[i + i_subfr], tmp_fx, &Overflow ); /* Q_exc */ move16(); -#else - L_tmp = L_shl( L_tmp, tmp1_fx ); /* Q16 + Q_exc */ - tmp_fx = round_fx( L_tmp ); - - exc2_fx[i + i_subfr] = add( exc2_fx[i + i_subfr], tmp_fx ); - move16(); - exc_fx[i + i_subfr] = add( exc_fx[i + i_subfr], tmp_fx ); - move16(); -#endif } } @@ -508,6 +477,11 @@ 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 *------------------------------------------------------------------*/ @@ -567,7 +541,6 @@ Word16 encod_tran_ivas_fx( res_fx, L_SUBFR, p_Aw, st_fx->preemph_fac, xn, cn, h1 ); Copy_Scale_sig( h1, h2_fx, L_SUBFR, -2 ); - Scale_sig( h1, L_SUBFR, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution */ /* scaling of xn[] to limit dynamic at 12 bits */ Scale_sig( xn, L_SUBFR, shift ); @@ -586,6 +559,7 @@ Word16 encod_tran_ivas_fx( IF( GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) ) { + Scale_sig( h1, L_SUBFR, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution */ transf_cdbk_enc_ivas_fx( st_fx, 0, i_subfr, cn, exc_fx, p_Aq, Aw_fx, h1, xn, xn2, y1, y2, Es_pred_fx, &gain_pit, gain_code, g_corr, clip_gain, &gain_preQ, code_preQ, unbits, Q_new, shift ); } @@ -633,13 +607,8 @@ Word16 encod_tran_ivas_fx( } gp_clip_test_gain_pit_fx( st_fx->element_mode, st_fx->core_brate, gain_pit, st_fx->clip_var_fx ); -#ifdef BASOP_NOGLOB Lgcode = L_shl_o( gain_code, Q_new, &Overflow ); /* scaled gain_code with Qnew -> Q16*/ gcode16 = round_fx_o( Lgcode, &Overflow ); -#else - Lgcode = L_shl( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/ - gcode16 = round_fx( Lgcode ); -#endif hLPDmem->tilt_code = est_tilt_ivas_fx( &exc_fx[i_subfr], gain_pit, code, gain_code, &voice_fac, Q_new, L_SUBFR, 0 ); // Q15 /*-----------------------------------------------------------------* * Update memory of the weighting filter @@ -651,13 +620,8 @@ Word16 encod_tran_ivas_fx( L_tmp = L_negate( L_tmp ); L_tmp = L_mac( L_tmp, xn[L_SUBFR - 1], 16384 ); // Q_new-1+15+shift L_tmp = L_msu( L_tmp, y1[L_SUBFR - 1], gain_pit ); // Q_new-1+15+shift -#ifdef BASOP_NOGLOB - L_tmp = L_shl_sat( L_tmp, sub( 1, shift ) ); // Q_new+15 - hLPDmem->mem_w0 = round_fx_sat( L_tmp ); /*Q_new-1*/ -#else - L_tmp = L_shl( L_tmp, sub( 1, shift ) ); - hLPDmem->mem_w0 = round_fx( L_tmp ); /*Q_new-1*/ -#endif + L_tmp = L_shl_sat( L_tmp, sub( 1, shift ) ); // Q_new+15 + hLPDmem->mem_w0 = round_fx_sat( L_tmp ); /*Q_new-1*/ /*-----------------------------------------------------------------* * Construct adaptive part of the excitation * Save the non-enhanced excitation for FEC_exc @@ -673,11 +637,7 @@ Word16 encod_tran_ivas_fx( { FOR( i = 0; i < L_SUBFR; i++ ) { -#ifdef BASOP_NOGLOB exc2_fx[i + i_subfr] = round_fx_sat( L_shl_sat( L_mult_sat( gain_pit, exc_fx[i + i_subfr] ), 1 ) ); /* Q_exc */ -#else - exc2_fx[i + i_subfr] = round_fx( L_shl( L_mult( gain_pit, exc_fx[i + i_subfr] ), 1 ) ); -#endif } } ELSE @@ -696,18 +656,11 @@ Word16 encod_tran_ivas_fx( FOR( i = 0; i < L_SUBFR; i++ ) { /* code in Q9, gain_pit in Q14 */ - L_tmp = L_mult( gcode16, code[i] ); /* Q10 + Q_new */ -#ifdef BASOP_NOGLOB + L_tmp = L_mult( gcode16, code[i] ); /* Q10 + Q_new */ L_tmp = L_shl_o( L_tmp, 5, &Overflow ); /* Q15 + Q_new */ L_tmp = L_mac_o( L_tmp, exc_fx[i + i_subfr], gain_pit, &Overflow ); /* Q15 + Q_new */ L_tmp = L_shl_o( L_tmp, 1, &Overflow ); /* saturation can occur here Q16 + Q_new */ exc_fx[i + i_subfr] = round_fx_o( L_tmp, &Overflow ); /* Q_new */ -#else - L_tmp = L_shl( L_tmp, 5 ); - L_tmp = L_mac( L_tmp, exc_fx[i + i_subfr], gain_pit ); - L_tmp = L_shl( L_tmp, 1 ); /* saturation can occur here */ - exc_fx[i + i_subfr] = round_fx( L_tmp ); -#endif } /*-----------------------------------------------------------------* @@ -719,8 +672,7 @@ Word16 encod_tran_ivas_fx( tmp1_fx = add( 16 - ( 2 + Q_AVQ_OUT_DEC + 1 ), Q_new ); FOR( i = 0; i < L_SUBFR; i++ ) { - L_tmp = L_mult( gain_preQ, code_preQ[i] ); /* Q2 + Q10 -> Q13*/ -#ifdef BASOP_NOGLOB + L_tmp = L_mult( gain_preQ, code_preQ[i] ); /* Q2 + Q10 -> Q13*/ L_tmp = L_shl_o( L_tmp, tmp1_fx, &Overflow ); /* Q16 + Q_exc */ tmp_fx = round_fx_o( L_tmp, &Overflow ); @@ -728,15 +680,6 @@ Word16 encod_tran_ivas_fx( move16(); exc_fx[i + i_subfr] = add_o( exc_fx[i + i_subfr], tmp_fx, &Overflow ); /* Q_exc */ move16(); -#else - L_tmp = L_shl( L_tmp, tmp1_fx ); /* Q16 + Q_exc */ - tmp_fx = round_fx( L_tmp ); - - exc2_fx[i + i_subfr] = add( exc2_fx[i + i_subfr], tmp_fx ); - move16(); - exc_fx[i + i_subfr] = add( exc_fx[i + i_subfr], tmp_fx ); - move16(); -#endif } } diff --git a/lib_enc/enc_uv_fx.c b/lib_enc/enc_uv_fx.c index cd147c6ce20bb60ae4e67cff1c902e6513884707..32c397613d81fc1637b5bba217ba854d731f755f 100644 --- a/lib_enc/enc_uv_fx.c +++ b/lib_enc/enc_uv_fx.c @@ -185,11 +185,7 @@ void encod_unvoiced_fx( hLPDmem->mem_w0 = sub( xn_fx[L_SUBFR - 1], round_fx( L_shl( Ltmp, 1 ) ) ); /* Q_xn */ move16(); BASOP_SATURATE_WARNING_OFF_EVS; -#ifdef BASOP_NOGLOB hLPDmem->mem_w0 = shr_sat( hLPDmem->mem_w0, shift ); /*Qnew-1*/ -#else - hLPDmem->mem_w0 = shr( hLPDmem->mem_w0, shift ); /*Qnew-1*/ -#endif BASOP_SATURATE_WARNING_ON_EVS; /*-------------------------------------------------------* @@ -208,15 +204,8 @@ void encod_unvoiced_fx( Ltmp2 = Mpy_32_16_1( gain_code_vect[j], code_fx[i] ); /* Q10 */ Ltmp2 = L_shl( Ltmp2, Q_new_p5 ); /* Q15 + Q_new */ Ltmp = L_add( Ltmp, Ltmp2 ); /* Q15 + Q_new */ -#ifdef BASOP_NOGLOB - Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q16 + Q_new */ - exc_fx[i + i_subfr] = round_fx_sat( Ltmp ); /* Q_new */ -#else - BASOP_SATURATE_WARNING_OFF_EVS - Ltmp = L_shl( Ltmp, 1 ); /* saturation can occur here */ - BASOP_SATURATE_WARNING_ON_EVS - exc_fx[i + i_subfr] = round_fx( Ltmp ); -#endif + Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q16 + Q_new */ + exc_fx[i + i_subfr] = round_fx_sat( Ltmp ); /* Q_new */ } tmp2 = L_SUBFR; move16(); @@ -428,11 +417,7 @@ void encod_unvoiced_ivas_fx( hLPDmem->mem_w0 = sub( xn_fx[L_SUBFR - 1], round_fx( L_shl( Ltmp, 1 ) ) ); // Q_xn move16(); BASOP_SATURATE_WARNING_OFF_EVS; -#ifdef BASOP_NOGLOB hLPDmem->mem_w0 = shr_sat( hLPDmem->mem_w0, shift ); /*Qnew-1*/ -#else - hLPDmem->mem_w0 = shr( hLPDmem->mem_w0, shift ); /*Qnew-1*/ -#endif move16(); BASOP_SATURATE_WARNING_ON_EVS; @@ -446,28 +431,14 @@ void encod_unvoiced_ivas_fx( 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] ); /* Q10 */ -#ifdef BASOP_NOGLOB + Ltmp = Mpy_32_16_1( gain_code2, code2[i] ); /* Q10 */ Ltmp = L_shl_sat( Ltmp, Q_new_p5 ); /* Q15 + Q_new */ Ltmp = L_mac_sat( Ltmp, gain_pit_fx, exc_fx[i + i_subfr] ); /* Q15 + Q_new */ -#else - Ltmp = L_shl( Ltmp, Q_new_p5 ); - Ltmp = L_mac( Ltmp, gain_pit_fx, exc_fx[i + i_subfr] ); -#endif - Ltmp2 = Mpy_32_16_1( gain_code_vect[j], code_fx[i] ); /* Q10 */ -#ifdef BASOP_NOGLOB - Ltmp2 = L_shl_sat( Ltmp2, Q_new_p5 ); /* Q15 + Q_new */ - Ltmp = L_add_sat( Ltmp, Ltmp2 ); /* Q15 + Q_new */ - Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q16 + Q_new */ - exc_fx[i + i_subfr] = round_fx_sat( Ltmp ); /* Q_new */ -#else - BASOP_SATURATE_WARNING_OFF_EVS - Ltmp2 = L_shl( Ltmp2, Q_new_p5 ); - Ltmp = L_add( Ltmp, Ltmp2 ); - Ltmp = L_shl( Ltmp, 1 ); /* saturation can occur here */ - BASOP_SATURATE_WARNING_ON_EVS - exc_fx[i + i_subfr] = round_fx( Ltmp ); -#endif + Ltmp2 = Mpy_32_16_1( gain_code_vect[j], code_fx[i] ); /* Q10 */ + Ltmp2 = L_shl_sat( Ltmp2, Q_new_p5 ); /* Q15 + Q_new */ + Ltmp = L_add_sat( Ltmp, Ltmp2 ); /* Q15 + Q_new */ + Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q16 + Q_new */ + exc_fx[i + i_subfr] = round_fx_sat( Ltmp ); /* Q_new */ move16(); } tmp2 = L_SUBFR; diff --git a/lib_enc/energy_fx.c b/lib_enc/energy_fx.c index e645395f1aabcce56c261b367d4be78c82e7204a..7dc96a4e31a73fa401bb5170f05035510b58de02 100644 --- a/lib_enc/energy_fx.c +++ b/lib_enc/energy_fx.c @@ -60,16 +60,10 @@ void est_energy_fx( HB_Power = L_shr( sb_power[6], shr_tmp ); /* 31 - enerBuffer_exp - shr_tmp */ FOR( i = 2; i < BandNum; i++ ) { - Ltmp32 = L_shr( sb_power[i], shr_tmp ); /* 31 - enerBuffer_exp - shr_tmp */ -#ifdef BASOP_NOGLOB + Ltmp32 = L_shr( sb_power[i], shr_tmp ); /* 31 - enerBuffer_exp - shr_tmp */ frame_energy2 = L_add_sat( frame_energy2, Ltmp32 ); /* 31 - enerBuffer_exp - shr_tmp */ if ( i > 6 ) HB_Power = L_add_sat( HB_Power, Ltmp32 ); -#else - frame_energy2 = L_add( frame_energy2, Ltmp32 ); - if ( i > 6 ) - HB_Power = L_add( HB_Power, Ltmp32 ); -#endif } frame_energy2 = L_sub( frame_energy2, Ltmp32 ); /* 31 - enerBuffer_exp - shr_tmp */ @@ -131,11 +125,7 @@ void est_energy_fx( tmpspec_amp = L_shl( sb_power[j], s16MaxCoefNorm ); /* sb_power_Q + s16MaxCoefNorm */ s32CopyPower = L_add( s32CopyPower, tmpspec_amp ); } -#ifdef BASOP_NOGLOB frame_sb_energy[i] = L_shr_o( s32CopyPower, s16MaxCoefNorm, &Overflow ); /* sb_power_Q */ -#else /* BASOP_NOGLOB */ - frame_sb_energy[i] = L_shr( s32CopyPower, s16MaxCoefNorm ); -#endif move32(); } @@ -194,7 +184,7 @@ static void update_sb_bg_energy( Word32 sb_bg_energy_ti, tmp; Word16 tmpQ, i; - *tbg_energy_count = add( *tbg_energy_count, 1 ); /* Q0 */ + *tbg_energy_count = add_sat( *tbg_energy_count, 1 ); /* Q0 */ move16(); tmpQ = add( tmp_Q_add, frame_sb_energy_scale ); @@ -461,7 +451,11 @@ 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/ext_sig_ana_fx.c b/lib_enc/ext_sig_ana_fx.c index af9c2dbc4e01340ab6a85d450b1cbefed000fce3..fc4a1889a8d7c78b2c8420ec9ef7c6848a5800c9 100644 --- a/lib_enc/ext_sig_ana_fx.c +++ b/lib_enc/ext_sig_ana_fx.c @@ -318,11 +318,7 @@ void core_signal_analysis_high_bitrate_fx( /* Outter left folding */ FOR( i = 0; i < folding_offset; i++ ) { -#ifdef BASOP_NOGLOB tcx20Win[folding_offset + i] = sub_sat( tcx20Win[folding_offset + i], tcx20Win[folding_offset - 1 - i] ); // Q0 -#else - tcx20Win[folding_offset + i] = sub( tcx20Win[folding_offset + i], tcx20Win[folding_offset - 1 - i] ); -#endif move16(); } #ifdef IVAS_CODE @@ -338,11 +334,7 @@ void core_signal_analysis_high_bitrate_fx( tmp = shr( right_overlap, 1 ); FOR( i = 0; i < tmp; i++ ) { -#ifdef BASOP_NOGLOB tcx20Win[L_subframe + folding_offset - 1 - i] = add_sat( tcx20Win[L_subframe + folding_offset - 1 - i], tcx20Win[L_subframe + folding_offset + i] ); // Q0 -#else - tcx20Win[L_subframe + folding_offset - 1 - i] = add( tcx20Win[L_subframe + folding_offset - 1 - i], tcx20Win[L_subframe + folding_offset + i] ); -#endif move16(); } /* 2xTCX5 */ @@ -693,13 +685,13 @@ void core_signal_analysis_high_bitrate_ivas_fx( 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; move16(); - Word16 win_len = 0; + Word16 win_len[2]; move16(); set32_fx( buf_powerSPec, 0, N_MAX + L_MDCT_OVLP_MAX ); set16_fx( buf_powerSPec_exp, 0, N_MAX + L_MDCT_OVLP_MAX ); @@ -926,6 +918,8 @@ void core_signal_analysis_high_bitrate_ivas_fx( assert( frameno == 0 ); windowed_samples[0] = L_deposit_l( overlap_mode[frameno] ); // Q0 windowed_samples[1] = L_deposit_l( overlap_mode[frameno + 1] ); // Q0 + *q_win = 0; + move16(); } IF( NE_16( st->element_mode, IVAS_CPE_MDCT ) ) { @@ -961,15 +955,26 @@ void core_signal_analysis_high_bitrate_ivas_fx( IF( windowed_samples != NULL ) /* save windowed speech_TCX samples */ { assert( L_subframe + ( left_overlap + right_overlap ) / 2 < 2 * L_FRAME_MAX / nSubframes - L_FRAME_MAX / 8 ); - win_len = add( L_subframe, shr( add( left_overlap, right_overlap ), 1 ) ); - windowed_samples[frameno * L_FRAME_MAX + 0] = L_deposit_l( overlap_mode[frameno] ); // Q0 + win_len[frameno] = add( L_subframe, shr( add( left_overlap, right_overlap ), 1 ) ); + move16(); + windowed_samples[frameno * L_FRAME_MAX + 0] = L_deposit_l( overlap_mode[frameno] ); // Q0 + move32(); windowed_samples[frameno * L_FRAME_MAX + 1] = L_deposit_l( overlap_mode[frameno + 1] ); // Q0 - Copy_Scale_sig_16_32( tcx20Win, windowed_samples + add( imult1616( frameno, L_FRAME_MAX ), 2 ), add( L_subframe, shr( add( left_overlap, right_overlap ), 1 ) ), 0 ); + 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 ); *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, *q_win ); // q_win + 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 + } } } @@ -980,11 +985,7 @@ void core_signal_analysis_high_bitrate_ivas_fx( /* Outter left folding */ FOR( i = 0; i < folding_offset; i++ ) { -#ifdef BASOP_NOGLOB tcx20Win[folding_offset + i] = sub_sat( tcx20Win[folding_offset + i], tcx20Win[folding_offset - 1 - i] ); // Q0 -#else - tcx20Win[folding_offset + i] = sub( tcx20Win[folding_offset + i], tcx20Win[folding_offset - 1 - i] ); -#endif move16(); } @@ -1000,11 +1001,7 @@ void core_signal_analysis_high_bitrate_ivas_fx( 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 -#ifdef BASOP_NOGLOB - tcx20Win[left_overlap + i] = sub_sat( tcx20Win[left_overlap + i], extract_l( L_tmp ) ); // Q0 -#else - tcx20Win[left_overlap + i] = sub( tcx20Win[left_overlap + i], extract_l( L_tmp ) ); // Q0 -#endif + tcx20Win[left_overlap + i] = sub_sat( tcx20Win[left_overlap + i], extract_l( L_tmp ) ); // Q0 move32(); } FOR( i = tmp - 1; i >= 0; i-- ) /* outer left folding of shortened long ALDO slope */ @@ -1012,11 +1009,7 @@ void core_signal_analysis_high_bitrate_ivas_fx( 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 -#ifdef BASOP_NOGLOB - tcx20Win[left_overlap + i] = sub_sat( tcx20Win[left_overlap + i], extract_l( L_tmp ) ); // Q0 -#else - tcx20Win[left_overlap + i] = sub( tcx20Win[left_overlap + i], extract_l( L_tmp ) ); // Q0 -#endif + tcx20Win[left_overlap + i] = sub_sat( tcx20Win[left_overlap + i], extract_l( L_tmp ) ); // Q0 move32(); } } @@ -1025,11 +1018,7 @@ void core_signal_analysis_high_bitrate_ivas_fx( tmp = shr( right_overlap, 1 ); FOR( i = 0; i < tmp; i++ ) { -#ifdef BASOP_NOGLOB tcx20Win[L_subframe + folding_offset - 1 - i] = add_sat( tcx20Win[L_subframe + folding_offset - 1 - i], tcx20Win[L_subframe + folding_offset + i] ); // Q0 -#else - tcx20Win[L_subframe + folding_offset - 1 - i] = add( tcx20Win[L_subframe + folding_offset - 1 - i], tcx20Win[L_subframe + folding_offset + i] ); -#endif move16(); } @@ -1121,11 +1110,7 @@ void core_signal_analysis_high_bitrate_ivas_fx( 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 -#ifdef BASOP_NOGLOB - tcx20Win[left_overlap + i] = sub_sat( tcx20Win[left_overlap + i], extract_l( L_tmp ) ); // Q0 -#else - tcx20Win[left_overlap + i] = sub( tcx20Win[left_overlap + i], extract_l( L_tmp ) ); // Q0 -#endif + tcx20Win[left_overlap + i] = sub_sat( tcx20Win[left_overlap + i], extract_l( L_tmp ) ); // Q0 move32(); } FOR( i = tmp - 1; i >= 0; i-- ) /* outer left folding of shortened long ALDO slope */ @@ -1133,11 +1118,7 @@ void core_signal_analysis_high_bitrate_ivas_fx( 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 -#ifdef BASOP_NOGLOB - tcx20Win[left_overlap + i] = sub_sat( tcx20Win[left_overlap + i], extract_l( L_tmp ) ); // Q0 -#else - tcx20Win[left_overlap + i] = sub( tcx20Win[left_overlap + i], extract_l( L_tmp ) ); // Q0 -#endif + tcx20Win[left_overlap + i] = sub_sat( tcx20Win[left_overlap + i], extract_l( L_tmp ) ); // Q0 move32(); } } @@ -1203,11 +1184,7 @@ void core_signal_analysis_high_bitrate_ivas_fx( /* Outer left folding */ FOR( i = 0; i < left_overlap / 2; i++ ) { -#ifdef BASOP_NOGLOB mdstWin[left_overlap / 2 + i] = add_sat( mdstWin[left_overlap / 2 + i], mdstWin[left_overlap / 2 - 1 - i] ); // Q0 -#else - mdstWin[left_overlap / 2 + i] = add( mdstWin[left_overlap / 2 + i], mdstWin[left_overlap / 2 - 1 - i] ); -#endif } test(); @@ -1221,11 +1198,7 @@ void core_signal_analysis_high_bitrate_ivas_fx( 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 -#ifdef BASOP_NOGLOB - mdstWin[left_overlap + i] = add_sat( mdstWin[left_overlap + i], extract_l( L_tmp ) ); // Q0 -#else - mdstWin[left_overlap + i] = add( mdstWin[left_overlap + i], extract_l( L_tmp ) ); // Q0 -#endif + mdstWin[left_overlap + i] = add_sat( mdstWin[left_overlap + i], extract_l( L_tmp ) ); // Q0 move32(); } FOR( i = tmp - 1; i >= 0; i-- ) /* outer left folding of shortened long ALDO slope */ @@ -1233,11 +1206,7 @@ void core_signal_analysis_high_bitrate_ivas_fx( 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 -#ifdef BASOP_NOGLOB - mdstWin[left_overlap + i] = add_sat( mdstWin[left_overlap + i], extract_l( L_tmp ) ); // Q0 -#else - mdstWin[left_overlap + i] = add( mdstWin[left_overlap + i], extract_l( L_tmp ) ); // Q0 -#endif + mdstWin[left_overlap + i] = add_sat( mdstWin[left_overlap + i], extract_l( L_tmp ) ); // Q0 move32(); } } @@ -1245,11 +1214,7 @@ void core_signal_analysis_high_bitrate_ivas_fx( /* Outer right folding */ FOR( i = 0; i < right_overlap / 2; i++ ) { -#ifdef BASOP_NOGLOB mdstWin[L_subframe + left_overlap / 2 - 1 - i] = sub_sat( mdstWin[L_subframe + left_overlap / 2 - 1 - i], mdstWin[L_subframe + left_overlap / 2 + i] ); // Q0 -#else - mdstWin[L_subframe + left_overlap / 2 - 1 - i] = sub( mdstWin[L_subframe + left_overlap / 2 - 1 - i], mdstWin[L_subframe + left_overlap / 2 + i] ); -#endif move16(); } @@ -1320,11 +1285,7 @@ void core_signal_analysis_high_bitrate_ivas_fx( 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 -#ifdef BASOP_NOGLOB - mdstWin[left_overlap + i] = add_sat( mdstWin[left_overlap + i], extract_l( L_tmp ) ); // Q0 -#else - mdstWin[left_overlap + i] = add( mdstWin[left_overlap + i], extract_l( L_tmp ) ); // Q0 -#endif + mdstWin[left_overlap + i] = add_sat( mdstWin[left_overlap + i], extract_l( L_tmp ) ); // Q0 move32(); } FOR( i = tmp - 1; i >= 0; i-- ) /* outer left folding of shortened long ALDO slope */ @@ -1332,11 +1293,7 @@ void core_signal_analysis_high_bitrate_ivas_fx( 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 -#ifdef BASOP_NOGLOB - mdstWin[left_overlap + i] = add_sat( mdstWin[left_overlap + i], extract_l( L_tmp ) ); // Q0 -#else - mdstWin[left_overlap + i] = add( mdstWin[left_overlap + i], extract_l( L_tmp ) ); // Q0 -#endif + mdstWin[left_overlap + i] = add_sat( mdstWin[left_overlap + i], extract_l( L_tmp ) ); // Q0 move32(); } } diff --git a/lib_enc/fd_cng_enc.c b/lib_enc/fd_cng_enc.c index 5c493876bab2caeb84ae0a6f9db36e2bcd1c5371..5fdc5e6f00283c841bd3af4d251f1515c1b5b790 100644 --- a/lib_enc/fd_cng_enc.c +++ b/lib_enc/fd_cng_enc.c @@ -92,10 +92,12 @@ void perform_noise_estimation_enc_ivas_fx( move16(); assert( numSlots == 16 ); - Word32 numSlots_inv_fx = 134217728; + Word32 numSlots_inv_fx = 1073741824; // Q34 of .0625 move32(); Word32 *periodog = hFdCngEnc->hFdCngCom->periodog; /* exp(peridog_exp) */ Word32 *ptr_per_fx = periodog; + Word64 periodog_64; + Word16 periodog_exp[PERIODOGLEN]; Word16 npart = hFdCngEnc->hFdCngCom->npart; /* Q0 */ move16(); Word16 nFFTpart = hFdCngEnc->hFdCngCom->nFFTpart; /* Q0 */ @@ -130,19 +132,19 @@ void perform_noise_estimation_enc_ivas_fx( SWITCH( input_Fs ) { case 8000: - scaleEB_fx = 62912; + scaleEB_fx = 251648; // Q35 move32(); BREAK; case 16000: - scaleEB_fx = 15728; + scaleEB_fx = 62912; // Q35 move32(); BREAK; case 32000: - scaleEB_fx = 3928; + scaleEB_fx = 15728; // Q35 move32(); BREAK; case 48000: - scaleEB_fx = 1744; + scaleEB_fx = 6991; // Q35 move32(); BREAK; default: @@ -151,8 +153,8 @@ void perform_noise_estimation_enc_ivas_fx( } ELSE { - scaleEB_fx = Mpy_32_16_1( numSlots_inv_fx, hFdCngEnc->hFdCngCom->scalingFactor ); - scaleEB_fx = L_shl( scaleEB_fx, 4 ); + scaleEB_fx = Mpy_32_32( numSlots_inv_fx, L_deposit_l( hFdCngEnc->hFdCngCom->scalingFactor ) ); // Q34 + Q30 - Q31 = Q33 + scaleEB_fx = L_shl( scaleEB_fx, 2 ); // Q35 } /* preemphasis compensation and grouping of per bin energies into msPeriodog */ @@ -167,22 +169,38 @@ void perform_noise_estimation_enc_ivas_fx( hFdCngEnc->msPeriodog_fx_exp_fft = add( band_energies_exp, PREEMPH_COMPENSATION_EXP ); move16(); + Word16 max_exp = -31; + move16(); + i = 0; + move16(); /* Adjust to the desired time resolution by averaging the periodograms over the time slots */ FOR( j = numCoreBands; j < regularStopBand; j++ ) { - *ptr_per_fx = Mpy_32_32( enerBuffer[j], scaleEB_fx ); /* exp(enerBuffer_exp) */ + periodog_64 = W_mult_32_32( enerBuffer[j], scaleEB_fx ); + Word16 scale = W_norm( periodog_64 ); + *ptr_per_fx = W_extract_h( W_shl( periodog_64, scale ) ); 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] ); ptr_per_fx++; - move16(); + i++; } - /* exponent for cldfb part of msPeriodog */ - hFdCngEnc->hFdCngCom->exp_cldfb_periodog = add( sub( enerBuffer_exp, 4 ), CLDFBscalingFactor_EXP ); - move16(); + // hFdCngEnc->hFdCngCom->exp_cldfb_periodog = add( sub( enerBuffer_exp, 4 ), CLDFBscalingFactor_EXP ); + // move16(); numBands = sub( regularStopBand, numCoreBands ); /* Q0 */ + FOR( i = 0; i < numBands; i++ ) + { + + periodog[i] = L_shr( periodog[i], sub( max_exp, periodog_exp[i] ) ); + move16(); + } + hFdCngEnc->hFdCngCom->exp_cldfb_periodog = max_exp; + move16(); IF( numBands > 0 ) { ///* Adjust CLDFB filterbank to the desired frequency resolution by averaging over spectral partitions for SID transmission */ diff --git a/lib_enc/fd_cng_enc_fx.c b/lib_enc/fd_cng_enc_fx.c index 8591f2627520c77121199284c3c78f349c58c059..d5be64f77daaf026dd2c967b1a30830764634c6f 100644 --- a/lib_enc/fd_cng_enc_fx.c +++ b/lib_enc/fd_cng_enc_fx.c @@ -951,11 +951,7 @@ static void msvq_encoder( const Word16 *const cb[], /* i : Codebook (indexed cb tmp = L_add( dist[0][c], L_sub( en, L_shl( t1, 1 ) ) ); BASOP_SATURATE_WARNING_OFF_EVS -#ifdef BASOP_NOGLOB t1 = L_sub_sat( tmp, dist[1][p_max] ); -#else - t1 = L_sub( tmp, dist[1][p_max] ); -#endif BASOP_SATURATE_WARNING_ON_EVS IF( t1 <= 0 ) /* IF (L_sub(L_shr(tmp,1), L_shr(dist[1][p_max],1) ) <= 0 ) */ @@ -1638,11 +1634,7 @@ void generate_comfort_noise_enc_fx( Encoder_State *stcod, s = sub( 15 - NOISE_HEADROOM, noiseExp ); FOR( i = 0; i < N; i++ ) { -#ifdef BASOP_NOGLOB noise[i] = shr_sat( mult( noise[i], gain16 ), s ); -#else - noise[i] = shr( mult( noise[i], gain16 ), s ); -#endif move16(); } @@ -1651,11 +1643,7 @@ void generate_comfort_noise_enc_fx( Encoder_State *stcod, s = sub( 15 - NOISE_HEADROOM, ( sub( 15, Q_syn ) ) ); FOR( i = 0; i < lpcorder; i++ ) { -#ifdef BASOP_NOGLOB old_syn_pe_tmp[i] = shr_sat( old_syn_pe[i], s ); -#else - old_syn_pe_tmp[i] = shr( old_syn_pe[i], s ); -#endif move16(); } @@ -2034,11 +2022,7 @@ void generate_comfort_noise_enc_ivas_fx( Encoder_State *stcod, s = sub( 15 - NOISE_HEADROOM, noiseExp ); FOR( i = 0; i < N; i++ ) { -#ifdef BASOP_NOGLOB noise[i] = shr_sat( mult( noise[i], gain16 ), s ); -#else - noise[i] = shr( mult( noise[i], gain16 ), s ); -#endif move16(); } @@ -2047,11 +2031,7 @@ void generate_comfort_noise_enc_ivas_fx( Encoder_State *stcod, s = sub( 15 - NOISE_HEADROOM, ( sub( 15, Q_syn ) ) ); FOR( i = 0; i < lpcorder; i++ ) { -#ifdef BASOP_NOGLOB old_syn_pe_tmp[i] = shr_sat( old_syn_pe[i], s ); -#else - old_syn_pe_tmp[i] = shr( old_syn_pe[i], s ); -#endif move16(); } diff --git a/lib_enc/find_tar_fx.c b/lib_enc/find_tar_fx.c index 0c138308b5e25c0edc71f12620c0a543ac76d921..c758db8f33e893b6552b6914c9dc77c0f56023aa 100644 --- a/lib_enc/find_tar_fx.c +++ b/lib_enc/find_tar_fx.c @@ -50,11 +50,7 @@ void find_targets_fx( *-----------------------------------------------------------------------*/ FOR( i = 0; i < M; i++ ) { -#ifdef BASOP_NOGLOB temp[i] = sub_sat( speech[i + i_subfr - M], mem_syn[i] ); /* Q_new - 1 */ -#else - temp[i] = sub( speech[i + i_subfr - M], mem_syn[i] ); -#endif move16(); } Syn_filt_s( 1, p_Aq, M, &res[i_subfr], temp + M, L_subfr, temp, 0 ); /* error in Q_new -1 */ @@ -107,32 +103,16 @@ void find_targets_fx( Ltmp = L_mult( Ap[i], s2 ); /* Q27 */ FOR( j = 1; j <= i; j++ ) { -#ifdef BASOP_NOGLOB /* Critical Overflow , as well as those below*/ Ltmp = L_msu_o( Ltmp, Aqs[j], h1[i - j], &Overflow ); /* Q27 */ -#else - Ltmp = L_msu( Ltmp, Aqs[j], h1[i - j] ); -#endif } -#ifdef BASOP_NOGLOB /* Critical Overflow */ h1[i] = round_fx_o( L_shl_o( Ltmp, s, &Overflow ), &Overflow ); /* Q11 + s */ -#else - h1[i] = round_fx( L_shl( Ltmp, s ) ); -#endif } Ltmp = L_mult( Ap[i], s2 ); /* Q27 */ FOR( j = 1; j <= M; j++ ) { -#ifdef BASOP_NOGLOB /* Critical Overflow */ Ltmp = L_msu_o( Ltmp, Aqs[j], h1[i - j], &Overflow ); /* Q27 */ -#else - Ltmp = L_msu( Ltmp, Aqs[j], h1[i - j] ); -#endif } -#ifdef BASOP_NOGLOB /* Critical Overflow */ h1[M] = round_fx_o( L_shl_o( Ltmp, s, &Overflow ), &Overflow ); /* Q11 + s */ -#else - h1[M] = round_fx( L_shl( Ltmp, s ) ); -#endif // PMT("should we used extended basop here for when the L_subfr > L_SUBFR, to prevent saturation/overflow and the subsequent loop\n") FOR( i = M + 1; i < L_subfr; i++ ) @@ -140,17 +120,9 @@ void find_targets_fx( Ltmp = L_msu( 0, Aqs[1], h1[i - 1] ); /* Q27 */ FOR( j = 2; j <= M; j++ ) { -#ifdef BASOP_NOGLOB /* Critical Overflow */ Ltmp = L_msu_o( Ltmp, Aqs[j], h1[i - j], &Overflow ); /* Q27 */ -#else - Ltmp = L_msu( Ltmp, Aqs[j], h1[i - j] ); -#endif } -#ifdef BASOP_NOGLOB /* Critical Overflow */ h1[i] = round_fx_o( L_shl_o( Ltmp, s, &Overflow ), &Overflow ); /* Q11 + s */ -#else - h1[i] = round_fx( L_shl( Ltmp, s ) ); -#endif } IF( Overflow ) { @@ -162,11 +134,7 @@ void find_targets_fx( { Ltmp = L_msu( Ltmp, Aqs[j], h1[i - j] ); /* Q27 */ } -#ifdef BASOP_NOGLOB h1[i] = round_fx( L_shl_o( Ltmp, s, &Overflow ) ); /* Q11 + s */ -#else - h1[i] = round_fx( L_shl( Ltmp, s ) ); -#endif } Ltmp = L_mult( Ap[i], s2 ); /* Q27 */ FOR( j = 1; j <= M; j++ ) @@ -229,11 +197,7 @@ void find_targets_ivas_fx( *-----------------------------------------------------------------------*/ FOR( i = 0; i < M; i++ ) { -#ifdef BASOP_NOGLOB temp[i] = sub_sat( speech[i + i_subfr - M], mem_syn[i] ); /* Q_new - 1 */ -#else - temp[i] = sub( speech[i + i_subfr - M], mem_syn[i] ); -#endif move16(); } Syn_filt_s( 1, p_Aq, M, &res[i_subfr], temp + M, L_subfr, temp, 0 ); @@ -287,32 +251,16 @@ void find_targets_ivas_fx( Ltmp = L_mult( Ap[i], s2 ); /* Q27 */ FOR( j = 1; j <= i; j++ ) { -#ifdef BASOP_NOGLOB /* Critical Overflow , as well as those below*/ Ltmp = L_msu_o( Ltmp, Aqs[j], h1[i - j], &Overflow ); /* Q27 */ -#else - Ltmp = L_msu( Ltmp, Aqs[j], h1[i - j] ); -#endif } -#ifdef BASOP_NOGLOB /* Critical Overflow */ h1[i] = round_fx_o( L_shl_o( Ltmp, s, &Overflow ), &Overflow ); /* Q11 + s */ -#else - h1[i] = round_fx( L_shl( Ltmp, s ) ); -#endif } Ltmp = L_mult( Ap[i], s2 ); /* Q27 */ FOR( j = 1; j <= M; j++ ) { -#ifdef BASOP_NOGLOB /* Critical Overflow */ Ltmp = L_msu_o( Ltmp, Aqs[j], h1[i - j], &Overflow ); /* Q27 */ -#else - Ltmp = L_msu( Ltmp, Aqs[j], h1[i - j] ); -#endif } -#ifdef BASOP_NOGLOB /* Critical Overflow */ h1[M] = round_fx_o( L_shl_o( Ltmp, s, &Overflow ), &Overflow ); /* Q11 + s */ -#else - h1[M] = round_fx( L_shl( Ltmp, s ) ); -#endif // PMT("should we used extended basop here for when the L_subfr > L_SUBFR, to prevent saturation/overflow and the subsequent loop\n") FOR( i = M + 1; i < L_subfr; i++ ) @@ -320,17 +268,9 @@ void find_targets_ivas_fx( Ltmp = L_msu( 0, Aqs[1], h1[i - 1] ); /* Q27 */ FOR( j = 2; j <= M; j++ ) { -#ifdef BASOP_NOGLOB /* Critical Overflow */ Ltmp = L_msu_o( Ltmp, Aqs[j], h1[i - j], &Overflow ); /* Q27 */ -#else - Ltmp = L_msu( Ltmp, Aqs[j], h1[i - j] ); -#endif } -#ifdef BASOP_NOGLOB /* Critical Overflow */ h1[i] = round_fx_o( L_shl_o( Ltmp, s, &Overflow ), &Overflow ); /* Q11 + s */ -#else - h1[i] = round_fx( L_shl( Ltmp, s ) ); -#endif } IF( Overflow ) { @@ -342,11 +282,7 @@ void find_targets_ivas_fx( { Ltmp = L_msu( Ltmp, Aqs[j], h1[i - j] ); /* Q27 */ } -#ifdef BASOP_NOGLOB h1[i] = round_fx( L_shl_o( Ltmp, s, &Overflow ) ); /* Q11 + s */ -#else - h1[i] = round_fx( L_shl( Ltmp, s ) ); -#endif } Ltmp = L_mult( Ap[i], s2 ); /* Q27 */ FOR( j = 1; j <= M; j++ ) diff --git a/lib_enc/find_tilt.c b/lib_enc/find_tilt.c index 0c07d03a12d5419a992f0e39693b45bb27cea13e..952805169e2281289bab083b96c5c4186e853a47 100644 --- a/lib_enc/find_tilt.c +++ b/lib_enc/find_tilt.c @@ -153,24 +153,14 @@ void find_tilt_ivas_fx( { /*lp_bckr *= FACT;*/ /*hp_bckr *= FACT;*/ -#ifdef BASOP_NOGLOB lp_bckr = L_add_sat( L_shl_sat( lp_bckr, 1 ), lp_bckr ); /* Q_new */ hp_bckr = L_add_sat( L_shl_sat( hp_bckr, 1 ), hp_bckr ); /* Q_new */ -#else - lp_bckr = L_add( L_shl( lp_bckr, 1 ), lp_bckr ); - hp_bckr = L_add( L_shl( hp_bckr, 1 ), hp_bckr ); -#endif } /*mean_voi = 0.5f * (voicing[1] + voicing[2]) + corr_shift;*/ - Ltmp = L_mult( voicing[1], 16384 /* 0.5 in Q15 */ ); // Q31 - Ltmp = L_mac( Ltmp, voicing[2], 16384 /* 0.5 in Q15 */ ); // Q31 -#ifdef BASOP_NOGLOB + Ltmp = L_mult( voicing[1], 16384 /* 0.5 in Q15 */ ); // Q31 + Ltmp = L_mac( Ltmp, voicing[2], 16384 /* 0.5 in Q15 */ ); // Q31 Ltmp = L_mac_o( Ltmp, corr_shift, 32767 /* 1.0f in Q15 */, &Overflow ); // Q31 mean_voi = round_fx_o( Ltmp, &Overflow ); // Q15 -#else - Ltmp = L_mac( Ltmp, corr_shift, 32767 ); - mean_voi = round_fx( Ltmp ); -#endif /*f0 = INT_FS_FX / pitch[2];*/ e_tmp = norm_s( pitch[2] ); @@ -222,13 +212,8 @@ void find_tilt_ivas_fx( } pt_E++; } -#ifdef BASOP_NOGLOB f1 = add_o( f1, f0, &Overflow ); f2 = add_o( f2, f0, &Overflow ); -#else - f1 = add( f1, f0 ); - f2 = add( f2, f0 ); -#endif } /*lp_E = lp_E / (float)cnt - lp_bckr;*/ e_tmp = sub( W_norm( sum ), 1 ); @@ -290,30 +275,18 @@ void find_tilt_ivas_fx( m_hpE = extract_h( L_shl( hp_E[i], e_hpE ) ); // e_hpE+q_bckr-16 m_tmp = div_s( m_tmp, m_hpE ); // Q15+(e_tmp+q_lp_E)-(e_hpE+q_bckr) e_tmp = sub( add( e_tmp, q_lp_E ), add( e_hpE, q_bckr ) ); -#ifdef BASOP_NOGLOB ee[i] = L_shr_o( m_tmp, add( e_tmp, 15 - 6 ), &Overflow ); /* ee in Q6 */ -#else /* BASOP_NOGLOB */ - ee[i] = L_shr( m_tmp, add( e_tmp, 15 - 6 ) ); /* ee in Q6 */ -#endif move32(); } IF( bwidth == NB ) /* For NB input, compensate for the missing bands */ { -#ifdef BASOP_NOGLOB Ltmp = L_shl_o( ee[i], 3, &Overflow ); /* Q6 */ -#else - Ltmp = L_shl( ee[i], 3 ); -#endif - IF( EQ_32( Ltmp, MAX_32 ) ) /* if Overflow: Compute with less precision */ + IF( EQ_32( Ltmp, MAX_32 ) ) /* if Overflow: Compute with less precision */ { Ltmp = Mult_32_16( ee[i], 24576 /* 0.75 in Q15 */ ); /* 6/8 Q6*/ -#ifdef BASOP_NOGLOB - ee[i] = L_shl_sat( Ltmp, 3 ); /* Q6 */ -#else - ee[i] = L_shl( Ltmp, 3 ); -#endif - move32(); /* x8 */ + ee[i] = L_shl_sat( Ltmp, 3 ); /* Q6 */ + move32(); /* x8 */ } ELSE { diff --git a/lib_enc/find_tilt_fx.c b/lib_enc/find_tilt_fx.c index d63585a398f97002aa6e340320efbb21dbe36b5b..44ad404e379b1ba6cc234b1b013d9d6e7e2942c2 100644 --- a/lib_enc/find_tilt_fx.c +++ b/lib_enc/find_tilt_fx.c @@ -85,24 +85,16 @@ void find_tilt_fx( /* bckr + voicing */ /*lp_bckr = mean( pt_bckr, nb_bands );*/ /* estimated noise E in first critical bands, up to 1270 Hz */ lp_bckr = Mean32( pt_bckr, nb_bands ); - /*hp_bckr = 0.5f * (bckr[max_band-1] + bckr[max_band]);*/ /* estimated noise E in last 2 critical bands */ -#ifdef BASOP_NOGLOB + /*hp_bckr = 0.5f * (bckr[max_band-1] + bckr[max_band]);*/ /* estimated noise E in last 2 critical bands */ hp_bckr = L_shr( L_add_sat( bckr[max_band - 1], bckr[max_band] ), 1 ); /* Q_new + QSCALE - 1 */ -#else - hp_bckr = L_shr( L_add( bckr[max_band - 1], bckr[max_band] ), 1 ); -#endif - if ( hp_bckr == 0 ) /* Avoid division by zero. */ + if ( hp_bckr == 0 ) /* Avoid division by zero. */ { hp_bckr = L_deposit_l( 1 ); } tmp = BASOP_Util_Divide3232_Scale( lp_bckr, hp_bckr, &e_tmp ); #ifdef FIX_ISSUE_1152 -#ifdef BASOP_NOGLOB 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 #else Ltmp = L_shr_r( L_deposit_h( tmp ), sub( 15, e_tmp ) ); #endif @@ -114,24 +106,14 @@ void find_tilt_fx( { /*lp_bckr *= FACT;*/ /*hp_bckr *= FACT;*/ -#ifdef BASOP_NOGLOB lp_bckr = L_add_sat( L_shl_sat( lp_bckr, 1 ), lp_bckr ); /* Q_new + QSCALE */ hp_bckr = L_add_sat( L_shl_sat( hp_bckr, 1 ), hp_bckr ); -#else - lp_bckr = L_add( L_shl( lp_bckr, 1 ), lp_bckr ); - hp_bckr = L_add( L_shl( hp_bckr, 1 ), hp_bckr ); -#endif } /*mean_voi = 0.5f * (voicing[1] + voicing[2]) + corr_shift;*/ Ltmp = L_mult( voicing[1], 16384 /* 0.5 in Q15 */ ); /* Q31 */ Ltmp = L_mac( Ltmp, voicing[2], 16384 /* 0.5 in Q15 */ ); /* Q31 */ -#ifdef BASOP_NOGLOB - Ltmp = L_mac_o( Ltmp, corr_shift, 32767, &Overflow ); /* Q31 */ - mean_voi = round_fx_o( Ltmp, &Overflow ); /* Q15 */ -#else - Ltmp = L_mac( Ltmp, corr_shift, 32767 ); - mean_voi = round_fx( Ltmp ); -#endif + Ltmp = L_mac_o( Ltmp, corr_shift, 32767, &Overflow ); /* Q31 */ + mean_voi = round_fx_o( Ltmp, &Overflow ); /* Q15 */ /*f0 = INT_FS_FX / pitch[2];*/ e_tmp = norm_s( pitch[2] ); @@ -177,22 +159,13 @@ void find_tilt_fx( tmp = sub( freq, f2 ); IF( L_mac0( -(Word32) TH_D_FX * TH_D_FX, tmp, tmp ) < 0 ) { -#ifdef BASOP_NOGLOB lp_E = L_add_o( *pt_E, lp_E, &Overflow ); /* Q_new + QSCALE - 2 */ -#else - lp_E = L_add( *pt_E, lp_E ); -#endif - m_cnt = add( m_cnt, 1 ); /* Q0 */ + m_cnt = add( m_cnt, 1 ); /* Q0 */ } pt_E++; } -#ifdef BASOP_NOGLOB f1 = add_o( f1, f0, &Overflow ); f2 = add_o( f2, f0, &Overflow ); -#else - f1 = add( f1, f0 ); - f2 = add( f2, f0 ); -#endif } /*lp_E = lp_E / (float)cnt - lp_bckr;*/ e_tmp = sub( norm_l( lp_E ), 1 ); @@ -206,11 +179,7 @@ void find_tilt_fx( m_tmp = div_s( m_tmp, m_cnt ); /* exp(e_tmp + e_cnt) */ e_tmp = sub( e_tmp, e_cnt ); -#ifdef BASOP_NOGLOB lp_E = L_sub_o( L_shr_o( m_tmp, sub( e_tmp, 1 ), &Overflow ), lp_bckr, &Overflow ); /* Q_new + QSCALE */ -#else - lp_E = L_sub( L_shr( m_tmp, sub( e_tmp, 1 ) ), lp_bckr ); -#endif pt_E = tmp_E + VOIC_BINS; /* Update for next half-frame */ } @@ -238,11 +207,7 @@ void find_tilt_fx( m_tmp = div_s( m_tmp, m_hpE ); /* exp(e_tmp + e_hpE) */ e_tmp = sub( e_tmp, e_hpE ); -#ifdef BASOP_NOGLOB ee[i] = L_shr_o( m_tmp, add( e_tmp, 15 - 6 ), &Overflow ); /* ee in Q6 */ -#else /* BASOP_NOGLOB */ - ee[i] = L_shr( m_tmp, add( e_tmp, 15 - 6 ) ); /* ee in Q6 */ -#endif } ELSE IF( lp_E == 0 ) { @@ -255,19 +220,11 @@ void find_tilt_fx( IF( EQ_16( bwidth, NB ) ) /* For NB input, compensate for the missing bands */ { -#ifdef BASOP_NOGLOB Ltmp = L_shl_o( ee[i], 3, &Overflow ); -#else - Ltmp = L_shl( ee[i], 3 ); -#endif IF( EQ_32( Ltmp, MAX_32 ) ) /* if Overflow: Compute with less precision */ { Ltmp = Mult_32_16( ee[i], 24576 /* 0.75 in Q15 */ ); /* 6/8 Q6*/ -#ifdef BASOP_NOGLOB ee[i] = L_shl_sat( Ltmp, 3 ); -#else - ee[i] = L_shl( Ltmp, 3 ); -#endif move32(); /* x8 */ } ELSE diff --git a/lib_enc/find_uv.c b/lib_enc/find_uv.c index 4196b9cb63f8ff3e0acf25bac42e2d71c9646549..2e14972c7b3f9a671f2ac37ca04b5039ca67df0c 100644 --- a/lib_enc/find_uv.c +++ b/lib_enc/find_uv.c @@ -104,21 +104,13 @@ static Word16 find_ener_decrease_fx( /* o : maximum } -#ifdef BASOP_NOGLOB minEnr = L_add_sat( minEnr, 100000 ); -#else - minEnr = L_add( minEnr, 100000 ); -#endif exp0 = norm_l( minEnr ); wtmp0 = extract_h( L_shl( minEnr, exp0 ) ); exp1 = sub( norm_l( maxEnr ), 1 ); wtmp1 = extract_h( L_shl( maxEnr, exp1 ) ); wtmp1 = div_s( wtmp1, wtmp0 ); -#ifdef BASOP_NOGLOB dE2 = shr_ro( wtmp1, add( sub( exp1, exp0 ), 15 - 10 ), &Overflow ); /*Q10*/ -#else - dE2 = shr_r( wtmp1, add( sub( exp1, exp0 ), 15 - 10 ) ); /*Q10*/ -#endif return dE2; } @@ -221,11 +213,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ exp1 = sub( norm_l( *pt_enr_ssf1 ), 1 ); wtmp1 = extract_h( L_shl( *pt_enr_ssf1, exp1 ) ); fac = div_s( wtmp1, wtmp0 ); -#ifdef BASOP_NOGLOB fac_32 = L_shr_o( L_deposit_l( fac ), add( sub( exp1, exp0 ), 15 - 13 ), &Overflow ); /* fac32 in Q13*/ -#else /* BASOP_NOGLOB */ - fac_32 = L_shr( L_deposit_l( fac ), add( sub( exp1, exp0 ), 15 - 13 ) ); /* fac32 in Q13*/ -#endif /* BASOP_NOGLOB */ if ( GT_32( fac_32, dE1 ) ) { @@ -268,22 +256,14 @@ Word16 find_uv_ivas_fx( /* o : coding typ * Average voicing (normalized correlation) *-----------------------------------------------------------------*/ - /*mean_ee = 1.0f/3.0f * (st->ee_old + ee[0] + ee[1]); */ /* coefficients take into account the position of the window */ -#ifdef BASOP_NOGLOB + /*mean_ee = 1.0f/3.0f * (st->ee_old + ee[0] + ee[1]); */ /* coefficients take into account the position of the window */ mean_ee = L_add_o( L_add_o( st_fx->ee_old_fx, ee[0], &Overflow ), ee[1], &Overflow ); /* Q6 */ -#else /* BASOP_NOGLOB */ - mean_ee = L_add( L_add( st_fx->ee_old_fx, ee[0] ), ee[1] ); -#endif /* BASOP_NOGLOB */ mean_ee = Mult_32_16( mean_ee, 10923 ); /*Q6*/ /* mean_voi3 = 1.0f/3.0f * (voicing[0] + voicing[1] + voicing[2]);*/ Ltmp0 = L_mult( st_fx->voicing_fx[0], 10923 /* 1/3 in Q15 */ ); /* Q31 */ Ltmp0 = L_mac( Ltmp0, st_fx->voicing_fx[1], 10923 /* 1/3 in Q15 */ ); /* Q31 */ -#ifdef BASOP_NOGLOB // -dtx 12650 amrwb\Dtx3.INP mean_voi3 = mac_r_sat( Ltmp0, st_fx->voicing_fx[2], 10923 /* 1/3 in Q15 */ ); /*Q15*/ -#else - mean_voi3 = mac_r( Ltmp0, st_fx->voicing_fx[2], 10923 ); /*Q15*/ -#endif /*-----------------------------------------------------------------* * Total frame energy difference (dE3) *-----------------------------------------------------------------*/ @@ -303,11 +283,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ { dE2_th = 21 << 10; move32(); -#ifdef BASOP_NOGLOB if ( GE_16( add_o( mean_voi3, corr_shift, &Overflow ), 22282 ) ) /*( mean_voi3 + corr_shift ) >= 0.68f*/ -#else - if ( GE_16( add( mean_voi3, corr_shift ), 22282 ) ) /*( mean_voi3 + corr_shift ) >= 0.68f*/ -#endif { nb_cond = 0; move16(); @@ -381,20 +357,14 @@ Word16 find_uv_ivas_fx( /* o : coding typ move16(); } - E_min_th = L_shl( E_MIN_IVAS_FX, sub( q_hp_E, Q19 ) ); + E_min_th = L_shl( E_MIN_IVAS_FX_Q31, sub( q_hp_E, Q31 ) ); test(); test(); test(); -#ifdef BASOP_NOGLOB IF( ( EQ_16( st_fx->last_coder_type_raw, UNVOICED ) ) || /* previous frame was unvoiced */ ( ( LT_32( ee[0], ee0_th ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy is concentrated in high frequencies provided that some energy is present in HF */ ( LT_16( add_o( st_fx->voicing_fx[0], corr_shift, &Overflow ), voi_th ) ) ) ) /* normalized correlation is low */ -#else /* BASOP_NOGLOB */ - if ( ( EQ_16( st_fx->last_coder_type_raw, UNVOICED ) ) || /* previous frame was unvoiced */ - ( ( LT_32( ee[0], ee0_th ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy is concentrated in high frequencies provided that some energy is present in HF */ - ( LT_16( add( st_fx->voicing_fx[0], corr_shift ), voi_th ) ) ) ) /* normalized correlation is low */ -#endif /* BASOP_NOGLOB */ { tmp_offset_flag = 0; move16(); @@ -470,7 +440,6 @@ Word16 find_uv_ivas_fx( /* o : coding typ test(); test(); test(); -#ifdef BASOP_NOGLOB IF( ( ( LT_16( add_o( mean_voi3, corr_shift, &Overflow ), add( 22282 /* 0.68 in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ ( LT_16( add_o( st_fx->voicing_fx[2], corr_shift, &Overflow ), 25887 /* 0.79 in Q15 */ ) ) && /* normalized correlation low on look-ahead - onset detection */ ( LT_32( ee[0], 640 /* 10.0f in Q6 */ ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */ @@ -481,18 +450,6 @@ Word16 find_uv_ivas_fx( /* o : coding typ ( LE_32( st_fx->old_dE1_fx, 237568 /* 29.0f in Q13 */ ) ) && /* + one frame hysteresis */ ( st_fx->spike_hyst < 0 ) ) || /* Avoid after sharp energy spikes followed by decay (e.g. castanets) */ flag_low_relE ) /* low relative frame energy (only for SC-VBR) */ -#else - if ( ( ( LT_16( add( mean_voi3, corr_shift ), add( 22282, mean_voi3_offset ) ) ) && /* normalized correlation low */ - ( LT_16( add( st_fx->voicing_fx[2], corr_shift ), 25887 ) ) && /* normalized correlation low on look-ahead - onset detection */ - ( LT_32( ee[0], 640 ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */ - ( LT_32( ee[1], ee1_th ) ) && ( GT_32( hp_E[1], E_min_th ) ) && /* ... biased towards look-ahead to detect onsets */ - ( tmp_offset_flag == 0 ) && /* Take care of voiced offsets */ - /*( st_fx->music_hysteresis_fx == 0 ) &&*/ /* ... and in segment after AUDIO frames */ - ( LE_32( dE1, 237568 ) ) && /* Avoid on sharp energy spikes */ - ( LE_32( st_fx->old_dE1_fx, 237568 ) ) && /* + one frame hysteresis */ - ( st_fx->spike_hyst < 0 ) ) || /* Avoid after sharp energy spikes followed by decay (e.g. castanets) */ - flag_low_relE ) /* low relative frame energy (only for SC-VBR) */ -#endif { coder_type = UNVOICED; move16(); @@ -509,7 +466,6 @@ Word16 find_uv_ivas_fx( /* o : coding typ test(); test(); test(); -#ifdef BASOP_NOGLOB if ( ( ( LT_16( add_o( mean_voi3, corr_shift, &Overflow ), add( 22774 /* 0.695f in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ /*( LT_16( add_o( st_fx->voicing_fx[2], corr_shift, &Overflow ), 25887 ) ) && */ /* normalized correlation low on look-ahead - onset detection */ ( LT_32( ee[0], 397 /* 6.2f in Q6 */ ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */ @@ -520,18 +476,6 @@ Word16 find_uv_ivas_fx( /* o : coding typ ( LE_32( st_fx->old_dE1_fx, 245760 /* 30.0f in Q13 */ ) ) && /* + one frame hysteresis */ ( st_fx->spike_hyst < 0 ) ) /* Avoid after sharp energy spikes followed by decay (e.g. castanets) */ || ( flag_low_relE && ( LE_32( st_fx->old_dE1_fx, 245760 /* 30.0f in Q13 */ ) ) ) ) /* low relative frame energy (only for SC-VBR) */ -#else - if ( ( ( LT_16( add( mean_voi3, corr_shift ), add( 22774, mean_voi3_offset ) ) ) && /* normalized correlation low */ - /* ( LT_16( add( st_fx->voicing_fx[2], corr_shift ), 25887 ) ) && */ /* normalized correlation low on look-ahead - onset detection */ - ( LT_32( ee[0], 397 ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */ - ( LT_32( ee[1], 397 ) ) && ( GT_32( hp_E[1], E_min_th ) ) && /* ... biased towards look-ahead to detect onsets */ - ( tmp_offset_flag == 0 ) && /* Take care of voiced offsets */ - /*( st_fx->music_hysteresis_fx == 0 ) && */ /* ... and in segment after AUDIO frames */ - ( LE_32( dE1, 245760 ) ) && /* Avoid on sharp energy spikes */ - ( LE_32( st_fx->old_dE1_fx, 245760 ) ) && /* + one frame hysteresis */ - ( st_fx->spike_hyst < 0 ) ) /* Avoid after sharp energy spikes followed by decay (e.g. castanets) */ - || ( flag_low_relE && ( LE_32( st_fx->old_dE1_fx, 245760 ) ) ) ) /* low relative frame energy (only for SC-VBR) */ -#endif { coder_type = UNVOICED; move16(); @@ -690,12 +634,8 @@ Word16 find_uv_ivas_fx( /* o : coding typ test(); test(); if ( ( GT_16( st_fx->spike_hyst, 1 ) ) && - ( GT_16( dE3, 5 << 8 ) || /* energy increases */ -#ifdef BASOP_NOGLOB + ( GT_16( dE3, 5 << 8 ) || /* energy increases */ ( GT_16( relE, -3328 /* 13 in Q8 */ ) && ( GT_16( add_sat( mean_voi3, corr_shift ), 22774 /* 0.695 in Q15 */ ) ) ) ) ) /* normalized correlation is high */ -#else - ( GT_16( relE, -3328 ) && ( GT_16( add( mean_voi3, corr_shift ), 22774 ) ) ) ) ) /* normalized correlation is high */ -#endif { st_fx->spike_hyst = -1; move16(); diff --git a/lib_enc/find_uv_fx.c b/lib_enc/find_uv_fx.c index 5cd9db2797f8e7b8da3f9a2f3326c8056ac8967e..3f4c8abc7103221d0b9558cfe49d893e531b23ce 100644 --- a/lib_enc/find_uv_fx.c +++ b/lib_enc/find_uv_fx.c @@ -70,21 +70,13 @@ static Word16 find_ener_decrease_fx( /* o : maximum } -#ifdef BASOP_NOGLOB minEnr = L_add_sat( minEnr, 100000 ); -#else - minEnr = L_add( minEnr, 100000 ); -#endif exp0 = norm_l( minEnr ); wtmp0 = extract_h( L_shl( minEnr, exp0 ) ); exp1 = sub( norm_l( maxEnr ), 1 ); wtmp1 = extract_h( L_shl( maxEnr, exp1 ) ); wtmp1 = div_s( wtmp1, wtmp0 ); -#ifdef BASOP_NOGLOB dE2 = shr_ro( wtmp1, add( sub( exp1, exp0 ), 15 - 10 ), &Overflow ); /*Q10*/ -#else - dE2 = shr_r( wtmp1, add( sub( exp1, exp0 ), 15 - 10 ) ); /*Q10*/ -#endif return dE2; } @@ -197,11 +189,7 @@ Word16 find_uv_fx( /* o : coding type */ exp1 = sub( norm_l( *pt_enr_ssf1 ), 1 ); wtmp1 = extract_h( L_shl( *pt_enr_ssf1, exp1 ) ); fac = div_s( wtmp1, wtmp0 ); -#ifdef BASOP_NOGLOB fac_32 = L_shr_o( L_deposit_l( fac ), add( sub( exp1, exp0 ), 15 - 13 ), &Overflow ); /* fac32 in Q13*/ -#else /* BASOP_NOGLOB */ - fac_32 = L_shr( L_deposit_l( fac ), add( sub( exp1, exp0 ), 15 - 13 ) ); /* fac32 in Q13*/ -#endif /* BASOP_NOGLOB */ if ( GT_32( fac_32, dE1 ) ) { @@ -238,22 +226,14 @@ Word16 find_uv_fx( /* o : coding type */ * Average voicing (normalized correlation) *-----------------------------------------------------------------*/ - /*mean_ee = 1.0f/3.0f * (st->ee_old + ee[0] + ee[1]); */ /* coefficients take into account the position of the window */ -#ifdef BASOP_NOGLOB + /*mean_ee = 1.0f/3.0f * (st->ee_old + ee[0] + ee[1]); */ /* coefficients take into account the position of the window */ mean_ee = L_add_o( L_add_o( st_fx->ee_old_fx, ee[0], &Overflow ), ee[1], &Overflow ); /* Q6 */ -#else /* BASOP_NOGLOB */ - mean_ee = L_add( L_add( st_fx->ee_old_fx, ee[0] ), ee[1] ); -#endif /* BASOP_NOGLOB */ mean_ee = Mult_32_16( mean_ee, 10923 /* 1/3 in Q15 */ ); /*Q6*/ /* mean_voi3 = 1.0f/3.0f * (voicing[0] + voicing[1] + voicing[2]);*/ Ltmp0 = L_mult( st_fx->voicing_fx[0], 10923 /* 1/3 in Q15 */ ); /* Q31 */ Ltmp0 = L_mac( Ltmp0, st_fx->voicing_fx[1], 10923 /* 1/3 in Q15 */ ); /* Q31 */ -#ifdef BASOP_NOGLOB // -dtx 12650 amrwb\Dtx3.INP mean_voi3 = mac_r_sat( Ltmp0, st_fx->voicing_fx[2], 10923 /* 1/3 in Q15 */ ); /*Q15*/ -#else - mean_voi3 = mac_r( Ltmp0, st_fx->voicing_fx[2], 10923 ); /*Q15*/ -#endif /*-----------------------------------------------------------------* * Total frame energy difference (dE3) *-----------------------------------------------------------------*/ @@ -273,11 +253,7 @@ Word16 find_uv_fx( /* o : coding type */ { dE2_th = 21 << 10; move32(); -#ifdef BASOP_NOGLOB if ( GE_16( add_o( mean_voi3, corr_shift, &Overflow ), 22282 /* 0.68 in Q15 */ ) ) /*( mean_voi3 + corr_shift ) >= 0.68f*/ -#else - if ( GE_16( add( mean_voi3, corr_shift ), 22282 ) ) /*( mean_voi3 + corr_shift ) >= 0.68f*/ -#endif { nb_cond = 0; move16(); @@ -354,15 +330,9 @@ Word16 find_uv_fx( /* o : coding type */ test(); test(); test(); -#ifdef BASOP_NOGLOB if ( ( EQ_16( st_fx->last_coder_type_raw, UNVOICED ) ) || /* previous frame was unvoiced */ ( ( LT_32( ee[0], ee0_th ) ) && ( GT_32( hp_E[0], L_shl( E_MIN_FX, Q_new ) ) ) && /* energy is concentrated in high frequencies provided that some energy is present in HF */ ( LT_16( add_o( st_fx->voicing_fx[0], corr_shift, &Overflow ), voi_th ) ) ) ) /* normalized correlation is low */ -#else /* BASOP_NOGLOB */ - if ( ( EQ_16( st_fx->last_coder_type_raw, UNVOICED ) ) || /* previous frame was unvoiced */ - ( ( LT_32( ee[0], ee0_th ) ) && ( GT_32( hp_E[0], L_shl( E_MIN_FX, Q_new ) ) ) && /* energy is concentrated in high frequencies provided that some energy is present in HF */ - ( LT_16( add( st_fx->voicing_fx[0], corr_shift ), voi_th ) ) ) ) /* normalized correlation is low */ -#endif /* BASOP_NOGLOB */ { tmp_offset_flag = 0; move16(); @@ -438,7 +408,6 @@ Word16 find_uv_fx( /* o : coding type */ test(); test(); test(); -#ifdef BASOP_NOGLOB if ( ( ( LT_16( add_o( mean_voi3, corr_shift, &Overflow ), add( 22282 /* 0.68 in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ ( LT_16( add_o( st_fx->voicing_fx[2], corr_shift, &Overflow ), 25887 /* 0.79 in Q15 */ ) ) && /* normalized correlation low on look-ahead - onset detection */ ( LT_32( ee[0], 640 /* 10.0f in Q6 */ ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */ @@ -449,18 +418,6 @@ Word16 find_uv_fx( /* o : coding type */ ( LE_32( st_fx->old_dE1_fx, 237568 /* 29.0f in Q13 */ ) ) && /* + one frame hysteresis */ ( st_fx->spike_hyst < 0 ) ) || /* Avoid after sharp energy spikes followed by decay (e.g. castanets) */ flag_low_relE ) /* low relative frame energy (only for SC-VBR) */ -#else - if ( ( ( LT_16( add( mean_voi3, corr_shift ), add( 22282, mean_voi3_offset ) ) ) && /* normalized correlation low */ - ( LT_16( add( st_fx->voicing_fx[2], corr_shift ), 25887 ) ) && /* normalized correlation low on look-ahead - onset detection */ - ( LT_32( ee[0], 640 ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */ - ( LT_32( ee[1], ee1_th ) ) && ( GT_32( hp_E[1], E_min_th ) ) && /* ... biased towards look-ahead to detect onsets */ - ( tmp_offset_flag == 0 ) && /* Take care of voiced offsets */ - /*( st_fx->music_hysteresis_fx == 0 ) &&*/ /* ... and in segment after AUDIO frames */ - ( LE_32( dE1, 237568 ) ) && /* Avoid on sharp energy spikes */ - ( LE_32( st_fx->old_dE1_fx, 237568 ) ) && /* + one frame hysteresis */ - ( st_fx->spike_hyst < 0 ) ) || /* Avoid after sharp energy spikes followed by decay (e.g. castanets) */ - flag_low_relE ) /* low relative frame energy (only for SC-VBR) */ -#endif { coder_type = UNVOICED; move16(); @@ -480,7 +437,6 @@ Word16 find_uv_fx( /* o : coding type */ test(); test(); test(); -#ifdef BASOP_NOGLOB if ( ( ( LT_16( add_o( mean_voi3, corr_shift, &Overflow ), add( 22774 /* 0.695f in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ ( LT_16( add_sat( st_fx->voicing_fx[2], corr_shift ), 25887 /* 0.8 in Q15 */ ) ) && /* normalized correlation low on look-ahead - onset detection */ ( LT_32( ee[0], 397 /* 6.2f in Q6 */ ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */ @@ -491,18 +447,6 @@ Word16 find_uv_fx( /* o : coding type */ ( LE_32( st_fx->old_dE1_fx, 245760 /* 30.0f in Q13 */ ) ) && /* + one frame hysteresis */ ( st_fx->spike_hyst < 0 ) ) /* Avoid after sharp energy spikes followed by decay (e.g. castanets) */ || ( flag_low_relE && ( LE_32( st_fx->old_dE1_fx, 245760 /* 30.0f in Q13 */ ) ) ) ) /* low relative frame energy (only for SC-VBR) */ -#else - if ( ( ( LT_16( add( mean_voi3, corr_shift ), add( 22774, mean_voi3_offset ) ) ) && /* normalized correlation low */ - ( LT_16( add( st_fx->voicing_fx[2], corr_shift ), 25887 ) ) && /* normalized correlation low on look-ahead - onset detection */ - ( LT_32( ee[0], 397 ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */ - ( LT_32( ee[1], 397 ) ) && ( GT_32( hp_E[1], E_min_th ) ) && /* ... biased towards look-ahead to detect onsets */ - ( tmp_offset_flag == 0 ) && /* Take care of voiced offsets */ - /*( st_fx->music_hysteresis_fx == 0 ) && */ /* ... and in segment after AUDIO frames */ - ( LE_32( dE1, 245760 ) ) && /* Avoid on sharp energy spikes */ - ( LE_32( st_fx->old_dE1_fx, 245760 ) ) && /* + one frame hysteresis */ - ( st_fx->spike_hyst < 0 ) ) /* Avoid after sharp energy spikes followed by decay (e.g. castanets) */ - || ( flag_low_relE && ( LE_32( st_fx->old_dE1_fx, 245760 ) ) ) ) /* low relative frame energy (only for SC-VBR) */ -#endif { coder_type = UNVOICED; move16(); @@ -655,12 +599,8 @@ Word16 find_uv_fx( /* o : coding type */ test(); test(); if ( ( GT_16( st_fx->spike_hyst, 1 ) ) && - ( GT_16( dE3, 5 << 8 ) || /* energy increases */ -#ifdef BASOP_NOGLOB + ( GT_16( dE3, 5 << 8 ) || /* energy increases */ ( GT_16( relE, -3328 ) && ( GT_16( add_sat( mean_voi3, corr_shift ), 22774 ) ) ) ) ) /* normalized correlation is high */ -#else - ( GT_16( relE, -3328 ) && ( GT_16( add( mean_voi3, corr_shift ), 22774 ) ) ) ) ) /* normalized correlation is high */ -#endif { st_fx->spike_hyst = -1; move16(); diff --git a/lib_enc/gain_enc_fx.c b/lib_enc/gain_enc_fx.c index 1d330ac49a8a08bbdbad58155b603f78d4caa5c6..162fc41fa62738ea3379513ff32d59279984efc9 100644 --- a/lib_enc/gain_enc_fx.c +++ b/lib_enc/gain_enc_fx.c @@ -96,11 +96,7 @@ void Es_pred_enc_fx( FOR( i = 1; i < L_SUBFR; i++ ) { tmp16 = mult_r( res[i_subfr + i], 8192 /* 1 in Q13 */ ); /* remove 2bits Q_new - 2*/ -#ifdef BASOP_NOGLOB ener_fx = L_mac_o( ener_fx, tmp16, tmp16, &Overflow ); -#else - ener_fx = L_mac( ener_fx, tmp16, tmp16 ); -#endif } /* ener = 10 * (float)log10(ener / (float)L_SUBFR) */ @@ -182,11 +178,7 @@ void Es_pred_enc_fx( FOR( i = 1; i < size; i++ ) { -#ifdef BASOP_NOGLOB tmp16_2 = abs_s( sub_o( mean_ener_code16, qua_table[i], &Overflow ) ); -#else /* BASOP_NOGLOB */ - tmp16_2 = abs_s( sub( mean_ener_code16, qua_table[i] ) ); -#endif /* BASOP_NOGLOB */ IF( LT_16( tmp16_2, tmp16 ) ) { tmp16 = tmp16_2; @@ -397,11 +389,7 @@ void gain_enc_mless_fx( L_div = Mult_32_16( L_frac_num, tmp ); /*Q(30-exp)*/ exp_div = sub( exp_num, exp_den ); -#ifdef BASOP_NOGLOB *gain_pit = round_fx_o( L_shl_o( L_div, add( exp, exp_div ), &Overflow ), &Overflow ); /*Q14*/ -#else - *gain_pit = round_fx( L_shl( L_div, add( exp, exp_div ) ) ); /*Q14*/ -#endif L_tmp1 = L_shr( L_mult( coeff[1], coeff[4] ), 2 ); /*Q31*/ exp1 = add( exp_coeff[1], exp_coeff[4] ); @@ -426,11 +414,7 @@ void gain_enc_mless_fx( L_div = Mult_32_16( L_frac_num, tmp ); /*Q(30-exp)*/ exp_div = sub( exp_num, exp_den ); -#ifdef BASOP_NOGLOB *gain_code = L_shl_o( L_div, sub( add( exp, exp_div ), 14 ), &Overflow ); -#else - *gain_code = L_shl( L_div, sub( add( exp, exp_div ), 14 ) ); -#endif move32(); /*Q16*/ *gain_pit = s_max( G_PITCH_MIN_TC192_Q14, s_min( *gain_pit, G_PITCH_MAX_TC192_Q14 ) ); @@ -459,12 +443,8 @@ 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 ); - L_tmp = L_mult( gain_code16, gcode0 ); /*Q0*Q0 -> Q1*/ -#ifdef BASOP_NOGLOB + 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*/ -#else - *gain_code = L_shl( L_tmp, add( add( expg, exp_gcode0 ), 15 ) ); /*Q16*/ -#endif } ELSE { @@ -490,7 +470,7 @@ void gain_enc_mless_fx( #ifdef IVAS_CODE qua_table = gain_qua_mless_6b_stereo; #else - // PMTE() + // PMTE() #endif } move16(); @@ -623,40 +603,43 @@ void gain_enc_mless_ivas_fx( L_tmp = Dot_product12( code, code, L_SUBFR, &exp_code ); exp_inov = sub( exp_code, 18 + 6 ); - // To avoid crash in case code value is 0 + // To avoid crash in case code value is 0, IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( L_tmp, exp_inov, 21474836, 0 ), -1 ) ) { - L_tmp = 21474836; - exp_inov = 0; - move32(); + // setting values to avoid extra computation + *gain_inov = 32767; /*8(max value gain_inov can hold) in Q12*/ + Ei = -9743; /* -38 in Q8*/ + move16(); move16(); } + ELSE + { + exp_code = sub( exp_code, 30 ); - exp_code = sub( exp_code, 30 ); - - /*Ei = 10 * log10((dot_product(code, code, L_SUBFR) + 0.01) / L_SUBFR) */ + /*Ei = 10 * log10((dot_product(code, code, L_SUBFR) + 0.01) / L_SUBFR) */ - /*----------------------------------------------------------------* - * calculate the predicted gain code - *----------------------------------------------------------------*/ - tmp = norm_l( L_tmp ); - frac = Log2_norm_lc( L_shl( L_tmp, tmp ) ); - tmp = add( 30 - 18 - 6 - 1, sub( exp_code, tmp ) ); /* exp: -18 (code in Q9), -6 (/L_SUBFR) */ - L_tmp1 = Mpy_32_16( tmp, frac, 12330 ); /* Q13 */ - Ei = round_fx( L_shl( L_tmp1, 11 ) ); /* Q8 */ + /*----------------------------------------------------------------* + * calculate the predicted gain code + *----------------------------------------------------------------*/ + tmp = norm_l( L_tmp ); + frac = Log2_norm_lc( L_shl( L_tmp, tmp ) ); + tmp = add( 30 - 18 - 6 - 1, sub( exp_code, tmp ) ); /* exp: -18 (code in Q9), -6 (/L_SUBFR) */ + L_tmp1 = Mpy_32_16( tmp, frac, 12330 ); /* Q13 */ + Ei = round_fx( L_shl( L_tmp1, 11 ) ); /* Q8 */ + + /*---------------------------------------------------------------* + * Decode codebook gain and the adaptive excitation low-pass + * filtering factor (Finalize computation ) + *---------------------------------------------------------------*/ + /* gain_inov = 1.0f / sqrt((dot_product(code, code, L_SUBFR) + 0.01) / L_SUBFR) */ + L_tmp = Isqrt_lc( L_tmp, &exp_inov ); + *gain_inov = extract_h( L_shl( L_tmp, sub( exp_inov, 3 ) ) ); /* gain_inov in Q12 */ + move16(); + } /* predicted codebook gain */ gcode0 = sub( Es_pred, Ei ); /* Q8 */ - /*---------------------------------------------------------------* - * Decode codebook gain and the adaptive excitation low-pass - * filtering factor (Finalize computation ) - *---------------------------------------------------------------*/ - /* gain_inov = 1.0f / sqrt((dot_product(code, code, L_SUBFR) + 0.01) / L_SUBFR) */ - L_tmp = Isqrt_lc( L_tmp, &exp_inov ); - *gain_inov = extract_h( L_shl( L_tmp, sub( exp_inov, 3 ) ) ); /* gain_inov in Q12 */ - move16(); - /* gcode0 = pow(10, 0.05 * (Es_pred - Ei)) */ /*----------------------------------------------------------------* * gcode0 = pow(10.0, gcode0/20) @@ -745,11 +728,7 @@ void gain_enc_mless_ivas_fx( L_div = Mult_32_16( L_frac_num, tmp ); /*Q(30-exp)*/ exp_div = sub( exp_num, exp_den ); -#ifdef BASOP_NOGLOB *gain_pit = round_fx_o( L_shl_o( L_div, add( exp, exp_div ), &Overflow ), &Overflow ); /*Q14*/ -#else - *gain_pit = round_fx( L_shl( L_div, add( exp, exp_div ) ) ); /*Q14*/ -#endif L_tmp1 = L_shr( L_mult( coeff[1], coeff[4] ), 2 ); /*Q31*/ exp1 = add( exp_coeff[1], exp_coeff[4] ); @@ -774,11 +753,7 @@ void gain_enc_mless_ivas_fx( L_div = Mult_32_16( L_frac_num, tmp ); /*Q(30-exp)*/ exp_div = sub( exp_num, exp_den ); -#ifdef BASOP_NOGLOB *gain_code = L_shl_o( L_div, sub( add( exp, exp_div ), 14 ), &Overflow ); -#else - *gain_code = L_shl( L_div, sub( add( exp, exp_div ), 14 ) ); -#endif move32(); /*Q16*/ *gain_pit = s_max( G_PITCH_MIN_TC192_Q14, s_min( *gain_pit, G_PITCH_MAX_TC192_Q14 ) ); @@ -806,12 +781,8 @@ void gain_enc_mless_ivas_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( hBstr, IND_GAIN_CODE, index, nBits2 ); - L_tmp = L_mult( gain_code16, gcode0 ); /*Q0*Q0 -> Q1*/ -#ifdef BASOP_NOGLOB + 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*/ -#else - *gain_code = L_shl( L_tmp, add( add( expg, exp_gcode0 ), 15 ) ); /*Q16*/ -#endif } ELSE { @@ -1033,11 +1004,7 @@ void gain_enc_SQ_fx( L_tmp1 = L_mult( coeff[0], coeff[2] ); /*Q31*/ exp1 = add( exp_coeff[0], exp_coeff[2] ); -#ifdef BASOP_NOGLOB L_tmp2 = L_mult_o( coeff[4], coeff[4], &Overflow ); /*Q31*/ -#else - L_tmp2 = L_mult( coeff[4], coeff[4] ); /*Q31*/ -#endif exp2 = add( exp_coeff[4], exp_coeff[4] ); IF( GT_16( exp1, exp2 ) ) @@ -1079,20 +1046,12 @@ void gain_enc_SQ_fx( exp_num = exp2; move16(); } -#ifdef BASOP_NOGLOB L_frac_num = L_sub_o( L_tmp2, L_tmp1, &Overflow ); /*Q31*/ -#else /* BASOP_NOGLOB */ - L_frac_num = L_sub( L_tmp2, L_tmp1 ); /*Q31*/ -#endif /* BASOP_NOGLOB */ L_div = Mult_32_16( L_frac_num, tmp ); /*Q(30-exp)*/ exp_div = sub( exp_num, exp_den ); -#ifdef BASOP_NOGLOB *gain_pit = round_fx_o( L_shl_o( L_div, add( exp, exp_div ), &Overflow ), &Overflow ); /*Q14*/ -#else /* BASOP_NOGLOB */ - *gain_pit = round_fx( L_shl( L_div, add( exp, exp_div ) ) ); /*Q14*/ -#endif /* BASOP_NOGLOB */ L_tmp1 = L_mult( coeff[1], coeff[4] ); /*Q31*/ exp1 = add( exp_coeff[1], exp_coeff[4] ); @@ -1112,20 +1071,12 @@ void gain_enc_SQ_fx( exp_num = exp2; move16(); } -#ifdef BASOP_NOGLOB L_frac_num = L_sub_o( L_tmp2, L_tmp1, &Overflow ); /*Q31*/ -#else /* BASOP_NOGLOB */ - L_frac_num = L_sub( L_tmp2, L_tmp1 ); /*Q31*/ -#endif /* BASOP_NOGLOB */ L_div = Mult_32_16( L_frac_num, tmp ); /*Q(30-exp)*/ exp_div = sub( exp_num, exp_den ); -#ifdef BASOP_NOGLOB *gain_code = L_shl_sat( L_div, s_max( -31, sub( add( exp, exp_div ), 14 ) ) ); -#else - *gain_code = L_shl( L_div, s_max( -31, sub( add( exp, exp_div ), 14 ) ) ); -#endif move32(); /*Q16*/ *gain_pit = s_max( G_PITCH_MIN_Q14, s_min( *gain_pit, G_PITCH_MAX_Q14 ) ); @@ -1178,11 +1129,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 ); L_tmp = L_mult( gain_code16, gcode0 ); /*Q0*Q0 -> Q1*/ -#ifdef BASOP_NOGLOB *gain_code = L_shl_sat( L_tmp, add( add( expg, exp_gcode0 ), 15 ) ); -#else - *gain_code = L_shl( L_tmp, add( add( expg, exp_gcode0 ), 15 ) ); -#endif move32(); /*Q16*/ /* *norm_gain_code = *gain_code / *gain_inov; */ @@ -1331,11 +1278,7 @@ void gain_enc_SQ_ivas_fx( L_tmp1 = L_mult( coeff[0], coeff[2] ); /*Q31*/ exp1 = add( exp_coeff[0], exp_coeff[2] ); -#ifdef BASOP_NOGLOB L_tmp2 = L_mult_o( coeff[4], coeff[4], &Overflow ); /*Q31*/ -#else - L_tmp2 = L_mult( coeff[4], coeff[4] ); /*Q31*/ -#endif exp2 = add( exp_coeff[4], exp_coeff[4] ); IF( GT_16( exp1, exp2 ) ) @@ -1377,29 +1320,16 @@ void gain_enc_SQ_ivas_fx( exp_num = exp2; move16(); } -#ifdef BASOP_NOGLOB L_frac_num = L_sub_o( L_tmp2, L_tmp1, &Overflow ); /*Q31*/ -#else /* BASOP_NOGLOB */ - L_frac_num = L_sub( L_tmp2, L_tmp1 ); /*Q31*/ -#endif /* BASOP_NOGLOB */ L_div = Mult_32_16( L_frac_num, tmp ); /*Q(30-exp)*/ exp_div = sub( exp_num, exp_den ); -#ifdef BASOP_NOGLOB *gain_pit = round_fx_o( L_shl_o( L_div, add( exp, exp_div ), &Overflow ), &Overflow ); /*Q14*/ move16(); -#else /* BASOP_NOGLOB */ - *gain_pit = round_fx( L_shl( L_div, add( exp, exp_div ) ) ); /*Q14*/ - move16(); -#endif /* BASOP_NOGLOB */ // To be checked -#ifdef BASOP_NOGLOB L_tmp1 = L_mult_o( coeff[1], coeff[4], &Overflow ); /*Q31*/ -#else /* BASOP_NOGLOB */ - L_tmp1 = L_mult( coeff[1], coeff[4] ); /*Q31*/ -#endif /* BASOP_NOGLOB */ exp1 = add( exp_coeff[1], exp_coeff[4] ); L_tmp2 = L_mult( coeff[0], coeff[3] ); /*Q31*/ @@ -1417,20 +1347,12 @@ void gain_enc_SQ_ivas_fx( exp_num = exp2; move16(); } -#ifdef BASOP_NOGLOB L_frac_num = L_sub_o( L_tmp2, L_tmp1, &Overflow ); /*Q31*/ -#else /* BASOP_NOGLOB */ - L_frac_num = L_sub( L_tmp2, L_tmp1 ); /*Q31*/ -#endif /* BASOP_NOGLOB */ L_div = Mult_32_16( L_frac_num, tmp ); /*Q(30-exp)*/ exp_div = sub( exp_num, exp_den ); -#ifdef BASOP_NOGLOB *gain_code = L_shl_sat( L_div, s_max( -31, sub( add( exp, exp_div ), 14 ) ) ); -#else - *gain_code = L_shl( L_div, s_max( -31, sub( add( exp, exp_div ), 14 ) ) ); -#endif move32(); /*Q16*/ *gain_pit = s_max( G_PITCH_MIN_Q14, s_min( *gain_pit, G_PITCH_MAX_Q14 ) ); @@ -1483,11 +1405,7 @@ void gain_enc_SQ_ivas_fx( index = gain_quant_fx( gain_code, &gain_code16, LG10_G_CODE_MIN_Q14, LG10_G_CODE_MAX_Q13, nBits_code, &expg ); push_indice( hBstr, IND_GAIN_CODE, index, nBits_code ); L_tmp = L_mult( gain_code16, gcode0 ); /*Q0*Q0 -> Q1*/ -#ifdef BASOP_NOGLOB *gain_code = L_shl_sat( L_tmp, add( add( expg, exp_gcode0 ), 15 ) ); -#else - *gain_code = L_shl( L_tmp, add( add( expg, exp_gcode0 ), 15 ) ); -#endif move32(); /*Q16*/ /* *norm_gain_code = *gain_code / *gain_inov; */ @@ -1551,11 +1469,7 @@ Word16 gain_enc_gaus_fx( /* o : Return index of quant Ltmp = Pow2( 14, frac_gain ); /* Put 14 as exponent */ exp_gain = sub( exp_gain, 14 ); /* Retreive exponent of wtmp */ -#ifdef BASOP_NOGLOB *gain = L_shl_o( Ltmp, add( 16, exp_gain ), &Overflow ); -#else - *gain = L_shl( Ltmp, add( 16, exp_gain ) ); -#endif move32(); /*Q16*/ return index; @@ -1626,11 +1540,7 @@ void gain_enc_tc_fx( i = sub( exp_num, exp_den ); /* Gain_trans in Q7 */ g_code_fx = i_mult2( g_code_fx, tmp16 ); /* apply sign */ -#ifdef BASOP_NOGLOB *gain_code_fx = L_shr_sat( L_deposit_l( g_code_fx ), i ); -#else - *gain_code_fx = L_shr( L_deposit_l( g_code_fx ), i ); -#endif move32(); /*----------------------------------------------------------------* @@ -1736,11 +1646,7 @@ void gain_enc_tc_fx( move16(); /**gain_code *= gcode0;*/ L_tmp = L_mult( wgain_code, gcode0_fx ); /* Q13*Q0 -> Q14 */ -#ifdef BASOP_NOGLOB *gain_code_fx = L_shl_sat( L_tmp, add( exp_gcode0, 2 ) ); -#else - *gain_code_fx = L_shl( L_tmp, add( exp_gcode0, 2 ) ); -#endif move32(); /* Q14 -> Q16 */ push_indice_fx( hBstr, IND_GAIN_CODE, index, nBits ); } @@ -1815,13 +1721,9 @@ void gain_enc_tc_ivas_fx( *----------------------------------------------------------------*/ g_code_fx = div_s( num, den ); - i = sub( exp_num, exp_den ); /* Gain_trans in Q7 */ - g_code_fx = i_mult2( g_code_fx, tmp16 ); /* apply sign */ -#ifdef BASOP_NOGLOB + i = sub( exp_num, exp_den ); /* Gain_trans in Q7 */ + g_code_fx = i_mult2( g_code_fx, tmp16 ); /* apply sign */ *gain_code_fx = L_shr_sat( L_deposit_l( g_code_fx ), i ); /* Q16 */ -#else - *gain_code_fx = L_shr( L_deposit_l( g_code_fx ), i ); -#endif move32(); /*----------------------------------------------------------------* @@ -1927,11 +1829,7 @@ void gain_enc_tc_ivas_fx( move16(); /**gain_code *= gcode0;*/ L_tmp = L_mult( wgain_code, gcode0_fx ); /* Q13*Q0 -> Q14 */ -#ifdef BASOP_NOGLOB *gain_code_fx = L_shl_sat( L_tmp, add( exp_gcode0, 2 ) ); -#else - *gain_code_fx = L_shl( L_tmp, add( exp_gcode0, 2 ) ); -#endif move32(); /* Q14 -> Q16 */ push_indice( hBstr, IND_GAIN_CODE, index, nBits ); } @@ -2071,11 +1969,7 @@ static Word16 Find_Opt_gainQ_fx( L_tmp = L_mac( L_tmp, coeff[3], g_code ); /* 15 - coeff_exp + 13 - 1 */ L_tmp = L_mac( L_tmp, coeff[4], g_pit_cod ); /* 15 - coeff_exp + 13 - 1 */ -#ifdef BASOP_NOGLOB L_tmp1 = L_sub_o( L_tmp, dist_min, &Overflow ); -#else /* BASOP_NOGLOB */ - L_tmp1 = L_sub( L_tmp, dist_min ); -#endif /* BASOP_NOGLOB */ if ( L_tmp1 < 0 ) { index = i; @@ -2092,13 +1986,9 @@ static Word16 Find_Opt_gainQ_fx( g_code = *p++; /* selected code gain in Q9 */ move16(); - L_tmp = L_mult( g_code, gcode0 ); /* Q9*Q0 -> Q10 */ -#ifdef BASOP_NOGLOB + L_tmp = L_mult( g_code, gcode0 ); /* Q9*Q0 -> Q10 */ L_tmp = L_shl_sat( L_tmp, add( exp_gcode0, 6 ) ); /* Q10 -> Q16 */ -#else - L_tmp = L_shl( L_tmp, add( exp_gcode0, 6 ) ); /* Q10 -> Q16 */ -#endif - *gain_code = L_tmp; /* gain of code in Q16 */ + *gain_code = L_tmp; /* gain of code in Q16 */ move16(); return index; } @@ -3292,11 +3182,7 @@ void gain_enc_amr_wb_fx( L_tmp = L_mac( L_tmp, coeff[3], g_code ); /* 15 - coeff_exp + 13 - 1 */ L_tmp = L_mac( L_tmp, coeff[4], g_pit_cod ); /* 15 - coeff_exp + 13 - 1 */ -#ifdef BASOP_NOGLOB L_tmp1 = L_sub_o( L_tmp, dist_min, &Overflow ); -#else /* BASOP_NOGLOB */ - L_tmp1 = L_sub( L_tmp, dist_min ); -#endif /* BASOP_NOGLOB */ /* splitting the if cost half the complexity of using IF macro */ if ( L_tmp1 < 0 ) { @@ -3318,12 +3204,8 @@ void gain_enc_amr_wb_fx( g_code = *p++; /* selected code gain in Q11 */ move16(); - L_tmp = L_mult( g_code, gcode0 ); /* Q11*Q0 -> Q12 */ -#ifdef BASOP_NOGLOB + L_tmp = L_mult( g_code, gcode0 ); /* Q11*Q0 -> Q12 */ L_tmp = L_shl_o( L_tmp, add( exp_gcode0, 4 ), &Overflow ); /* Q12 -> Q16 */ -#else /* BASOP_NOGLOB */ - L_tmp = L_shl( L_tmp, add( exp_gcode0, 4 ) ); /* Q12 -> Q16 */ -#endif *gain_code = L_tmp; /* gain of code in Q16 */ move16(); diff --git a/lib_enc/gaus_enc_fx.c b/lib_enc/gaus_enc_fx.c index 1f91a5d95c4936688f898ecefaf3d362d5259b08..a9add7ea809f9c8fcd1541cb85f10011adc96ef1 100644 --- a/lib_enc/gaus_enc_fx.c +++ b/lib_enc/gaus_enc_fx.c @@ -102,11 +102,7 @@ Word16 gaus_encode_fx( /*----------------------------------------------------------------* * Total excitation for Unvoiced coders *----------------------------------------------------------------*/ -#ifdef BASOP_NOGLOB gcode = round_fx_o( L_shl_o( *gain_code, Q_new, &Overflow ), &Overflow ); /* scaled gain_code with Qnew */ -#else /* BASOP_NOGLOB */ - gcode = round_fx( L_shl( *gain_code, Q_new ) ); /* scaled gain_code with Qnew */ -#endif /* BASOP_NOGLOB */ FOR( i = 0; i < L_SUBFR; i++ ) { exc[i + i_subfr] = round_fx( L_shl( L_mult( gcode, code[i] ), 15 - 9 ) ); /* Q_new */ @@ -120,14 +116,9 @@ Word16 gaus_encode_fx( Ltmp = L_shl( Ltmp, add( 5, shift ) ); /* Q_new + 15 + shift */ Ltmp = L_negate( Ltmp ); Ltmp = L_mac( Ltmp, xn[L_SUBFR - 1], 16384 ); /* Q_new + 15 + shift */ -#ifdef BASOP_NOGLOB - Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); /* Q_new + 16 */ - *mem_w0 = round_fx_sat( Ltmp ); /* Q_new */ + Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); /* Q_new + 16 */ + *mem_w0 = round_fx_sat( Ltmp ); /* Q_new */ move16(); -#else - Ltmp = L_shl( Ltmp, sub( 1, shift ) ); - *mem_w0 = round_fx( Ltmp ); -#endif init_gp_clip_fx( clip_gain ); /* reset pitch clipping parameters */ *gain_pit = 0; @@ -209,11 +200,7 @@ Word16 gaus_encode_ivas_fx( /*----------------------------------------------------------------* * Total excitation for Unvoiced coders *----------------------------------------------------------------*/ -#ifdef BASOP_NOGLOB gcode = round_fx_o( L_shl_o( *gain_code, Q_new, &Overflow ), &Overflow ); /* scaled gain_code with Qnew */ -#else /* BASOP_NOGLOB */ - gcode = round_fx( L_shl( *gain_code, Q_new ) ); /* scaled gain_code with Qnew */ -#endif /* BASOP_NOGLOB */ FOR( i = 0; i < L_SUBFR; i++ ) { exc[i + i_subfr] = round_fx( L_shl( L_mult( gcode, code[i] ), 15 - 9 ) ); /* Q_new */ @@ -227,14 +214,9 @@ Word16 gaus_encode_ivas_fx( Ltmp = L_shl( Ltmp, add( 5, shift ) ); /* Q_new + 15 + shift */ Ltmp = L_negate( Ltmp ); Ltmp = L_mac( Ltmp, xn[L_SUBFR - 1], 16384 ); /* Q_new + 15 + shift */ -#ifdef BASOP_NOGLOB - Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); /* Q_new + 16 */ - *mem_w0 = round_fx_sat( Ltmp ); /* Q_new */ + Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); /* Q_new + 16 */ + *mem_w0 = round_fx_sat( Ltmp ); /* Q_new */ move16(); -#else - Ltmp = L_shl( Ltmp, sub( 1, shift ) ); - *mem_w0 = round_fx( Ltmp ); -#endif init_gp_clip_fx( clip_gain ); /* reset pitch clipping parameters */ *gain_pit = 0; @@ -327,13 +309,8 @@ void gauss2v_fx( { /* fc0 += xn[i]*xn[i] */ /* fc1 += xn[i]*xn[i-1] */ -#ifdef BASOP_NOGLOB Lc0 = L_mac_sat( Lc0, xn[i], xn[i] ); /* Q25 */ Lc1 = L_mac_sat( Lc1, xn[i], xn[i - 1] ); /* Q25 */ -#else - Lc0 = L_mac( Lc0, xn[i], xn[i] ); - Lc1 = L_mac( Lc1, xn[i], xn[i - 1] ); -#endif } /* fgxx = fc1/fc0 */ exp_num = sub( norm_l( Lc1 ), 1 ); @@ -386,12 +363,8 @@ void gauss2v_fx( exp_den = norm_l( Lden ); Den = extract_h( L_shl( Lden, exp_den ) ); -#ifdef BASOP_NOGLOB delta = shr_o( div_s( Num, Den ), sub( exp_num, exp_den ), &Overflow ); /* Q15 */ -#else /* BASOP_NOGLOB */ - delta = shr( div_s( Num, Den ), sub( exp_num, exp_den ) ); /* Q15 */ -#endif - delta = i_mult2( delta, m_sign ); /* Apply sign Q0*/ + delta = i_mult2( delta, m_sign ); /* Apply sign Q0*/ /* index_delta = (short)(FAC_DELTA * fdelta) */ index_delta = shr( delta, SFAC_DELTA ); @@ -553,13 +526,8 @@ void gauss2v_fx( cor2_norm = norm_l( cor2 ); eneri_norm = norm_l( eneri ); -#ifdef BASOP_NOGLOB cor2_mantissa = round_fx_o( L_shl_o( cor2, cor2_norm, &Overflow ), &Overflow ); eneri_mantissa = round_fx_o( L_shl_o( eneri, eneri_norm, &Overflow ), &Overflow ); -#else - cor2_mantissa = round_fx( L_shl( cor2, cor2_norm ) ); - eneri_mantissa = round_fx( L_shl( eneri, eneri_norm ) ); -#endif difference_norm = sub( add( cor2_norm, enerw_norm ), add( cor2w_norm, eneri_norm ) ); update_best = 0; @@ -710,41 +678,25 @@ void gauss2v_fx( exp_num = sub( norm_s( enerw ), 1 ); exp_den = norm_l( ener1 ); Num = shl( enerw, exp_num ); -#ifdef BASOP_NOGLOB Den = round_fx_sat( L_shl_sat( ener1, exp_den ) ); -#else - Den = round_fx( L_shl( ener1, exp_den ) ); -#endif GainPortion2 = L_deposit_l( 0 ); /* Unexpected division by zero. Eliminate this gain contribution */ IF( Den != 0 ) /* Protection against division by zero */ { div_result = div_s( Num, Den ); /* Q15 */ /* Re-scale to compensate for normalization*/ -#ifdef BASOP_NOGLOB GainPortion2 = L_shr_sat( L_deposit_l( div_result ), sub( exp_num, exp_den ) ); -#else - GainPortion2 = L_shr( L_deposit_l( div_result ), sub( exp_num, exp_den ) ); -#endif } -#ifdef BASOP_NOGLOB ener_sqrt = Isqrt( L_shl_sat( GainPortion2, 1 ) ); /* Make value a Q16 prior to division (align on power of 4) */ -#else - ener_sqrt = Isqrt( L_shl( GainPortion2, 1 ) ); /* Make value a Q16 prior to division (align on power of 4) */ -#endif - ener_sqrt = L_shr( ener_sqrt, 8 ); /* Left-shift Q23 result to make a Q15 result */ + ener_sqrt = L_shr( ener_sqrt, 8 ); /* Left-shift Q23 result to make a Q15 result */ Portion = Mult_32_16( GainPortion1, 19661 ); /* Performs GainPortion1*.6 */ Portion = Madd_32_16( Portion, ener_sqrt, 13107 ); /* Performs ener_sqrt*.4 */ /* Gain must be output in a 32-bit variable as a Q16 */ /* Compensate for Q_new */ -#ifdef BASOP_NOGLOB *gain = L_shl_o( Portion, sub( 13, Q_new ), &Overflow ); /* Q16 */ -#else - *gain = L_shl( Portion, sub( 13, Q_new ) ); -#endif move32(); return; @@ -818,13 +770,8 @@ void gauss2v_ivas_fx( { /* fc0 += xn[i]*xn[i] */ /* fc1 += xn[i]*xn[i-1] */ -#ifdef BASOP_NOGLOB Lc0 = L_mac_sat( Lc0, xn[i], xn[i] ); Lc1 = L_mac_sat( Lc1, xn[i], xn[i - 1] ); -#else - Lc0 = L_mac( Lc0, xn[i], xn[i] ); - Lc1 = L_mac( Lc1, xn[i], xn[i - 1] ); -#endif } /* fgxx = fc1/fc0 */ exp_num = sub( norm_l( Lc1 ), 1 ); @@ -877,12 +824,8 @@ void gauss2v_ivas_fx( exp_den = norm_l( Lden ); Den = extract_h( L_shl( Lden, exp_den ) ); -#ifdef BASOP_NOGLOB delta = shr_o( div_s( Num, Den ), sub( exp_num, exp_den ), &Overflow ); /* Q15 */ -#else /* BASOP_NOGLOB */ - delta = shr( div_s( Num, Den ), sub( exp_num, exp_den ) ); /* Q15 */ -#endif - delta = i_mult2( delta, m_sign ); /* Apply sign */ + delta = i_mult2( delta, m_sign ); /* Apply sign */ /* index_delta = (short)(FAC_DELTA * fdelta) */ index_delta = shr( delta, SFAC_DELTA ); @@ -1045,13 +988,8 @@ void gauss2v_ivas_fx( cor2_norm = norm_l( cor2 ); eneri_norm = norm_l( eneri ); -#ifdef BASOP_NOGLOB cor2_mantissa = round_fx_o( L_shl_o( cor2, cor2_norm, &Overflow ), &Overflow ); eneri_mantissa = round_fx_o( L_shl_o( eneri, eneri_norm, &Overflow ), &Overflow ); -#else - cor2_mantissa = round_fx( L_shl( cor2, cor2_norm ) ); - eneri_mantissa = round_fx( L_shl( eneri, eneri_norm ) ); -#endif difference_norm = sub( add( cor2_norm, enerw_norm ), add( cor2w_norm, eneri_norm ) ); update_best = 0; @@ -1202,41 +1140,25 @@ void gauss2v_ivas_fx( exp_num = sub( norm_s( enerw ), 1 ); exp_den = norm_l( ener1 ); Num = shl( enerw, exp_num ); -#ifdef BASOP_NOGLOB Den = round_fx_sat( L_shl_sat( ener1, exp_den ) ); -#else - Den = round_fx( L_shl( ener1, exp_den ) ); -#endif GainPortion2 = L_deposit_l( 0 ); /* Unexpected division by zero. Eliminate this gain contribution */ IF( Den != 0 ) /* Protection against division by zero */ { div_result = div_s( Num, Den ); /* Q15 */ /* Re-scale to compensate for normalization*/ -#ifdef BASOP_NOGLOB GainPortion2 = L_shr_sat( L_deposit_l( div_result ), sub( exp_num, exp_den ) ); -#else - GainPortion2 = L_shr( L_deposit_l( div_result ), sub( exp_num, exp_den ) ); -#endif } -#ifdef BASOP_NOGLOB ener_sqrt = Isqrt( L_shl_sat( GainPortion2, 1 ) ); /* Make value a Q16 prior to division (align on power of 4) */ -#else - ener_sqrt = Isqrt( L_shl( GainPortion2, 1 ) ); /* Make value a Q16 prior to division (align on power of 4) */ -#endif - ener_sqrt = L_shr( ener_sqrt, 8 ); /* Left-shift Q23 result to make a Q15 result */ + ener_sqrt = L_shr( ener_sqrt, 8 ); /* Left-shift Q23 result to make a Q15 result */ Portion = Mult_32_16( GainPortion1, 19661 ); /* Performs GainPortion1*.6 */ Portion = Madd_32_16( Portion, ener_sqrt, 13107 ); /* Performs ener_sqrt*.4 */ /* Gain must be output in a 32-bit variable as a Q16 */ /* Compensate for Q_new */ -#ifdef BASOP_NOGLOB *gain = L_shl_o( Portion, sub( 13, Q_new ), &Overflow ); -#else - *gain = L_shl( Portion, sub( 13, Q_new ) ); -#endif move32(); return; diff --git a/lib_enc/gp_clip_fx.c b/lib_enc/gp_clip_fx.c index 4ca86a09cbd191637cf4340ec52a0a8bb5dd75d2..b4845a1a43dae07f4e10cc615258262fd586f0fa 100644 --- a/lib_enc/gp_clip_fx.c +++ b/lib_enc/gp_clip_fx.c @@ -142,18 +142,10 @@ Word16 gp_clip_fx( } } -#ifdef BASOP_NOGLOB ener = L_mac_o( 1L, xn[0], xn[0], &Overflow ); -#else - ener = L_mac( 1L, xn[0], xn[0] ); -#endif FOR( i = 1; i < L_SUBFR; i++ ) { -#ifdef BASOP_NOGLOB ener = L_mac_o( ener, xn[i], xn[i], &Overflow ); -#else /* BASOP_NOGLOB */ - ener = L_mac( ener, xn[i], xn[i] ); -#endif } /* ener = 10.0f*(float)log10(ener) */ @@ -363,11 +355,7 @@ Word16 Mode2_gp_clip_fx( FOR( i = 0; i < L_subfr; i++ ) { -#ifdef BASOP_NOGLOB wener = L_mac0_o( wener, xn[i], xn[i], &Overflow ); -#else - wener = L_mac0( wener, xn[i], xn[i] ); -#endif } /*wener = 10.0f*(float)log10(wener);*/ diff --git a/lib_enc/gs_enc_fx.c b/lib_enc/gs_enc_fx.c index bc2e2a09108b62e5bfc391af6cc99c5f14dd5ffe..357e88410c5a5de7383e37462f8a1b8eb44ea993 100644 --- a/lib_enc/gs_enc_fx.c +++ b/lib_enc/gs_enc_fx.c @@ -1328,11 +1328,7 @@ static Word16 edyn_fx( /* o : ratio of max to mean */ { L_tmp = L_mult0( vec[j], vec[j] ); /*2*Qnew*/ ener_max = L_max( ener_max, L_tmp ); -#ifdef BASOP_NOGLOB ener_mean = L_add_o( ener_mean, L_tmp, &Overflow ); -#else /* BASOP_NOGLOB */ - ener_mean = L_add( ener_mean, L_tmp ); -#endif /* BASOP_NOGLOB */ } /*dyn = 10.0f * (ener_max / ener_mean);*/ ener_mean = Mult_32_16( ener_mean, div_s( 1, lvec ) ); /*2*Qnew*/ @@ -1340,11 +1336,7 @@ static Word16 edyn_fx( /* o : ratio of max to mean */ IF( ener_mean > 0 ) { exp1 = norm_l( ener_mean ); -#ifdef BASOP_NOGLOB tmp1 = round_fx_o( L_shl( ener_mean, exp1 ), &Overflow ); -#else /* BASOP_NOGLOB */ - tmp1 = round_fx( L_shl( ener_mean, exp1 ) ); -#endif exp1 = sub( 30, exp1 ); exp2 = norm_l( ener_max ); diff --git a/lib_enc/guided_plc_enc_fx.c b/lib_enc/guided_plc_enc_fx.c index 6470e0a3c88fa8bcf420af79d496ecb0f73d570b..9aa2ecb65550f4be98ba9615395e56d73888cd2b 100644 --- a/lib_enc/guided_plc_enc_fx.c +++ b/lib_enc/guided_plc_enc_fx.c @@ -161,11 +161,7 @@ static void coderLookAheadInnovation( ps_e = add( alp_e, ps_e ); BASOP_SATURATE_WARNING_OFF_EVS -#ifdef BASOP_NOGLOB max_ps_tmp = L_shl_o( max_ps, sub( max_ps_e, ps_e ), &Overflow ); -#else /* BASOP_NOGLOB */ - max_ps_tmp = L_shl( max_ps, sub( max_ps_e, ps_e ) ); -#endif /* BASOP_NOGLOB */ BASOP_SATURATE_WARNING_ON_EVS @@ -452,21 +448,13 @@ void updateSpecPowDiffuseIdx_fx( FOR( k = 1; k < 4; k++ ) { -#ifdef BASOP_NOGLOB st->mean_gc[1] = L_add_o( st->mean_gc[1], st->gain_code[k], &Overflow ); -#else /* BASOP_NOGLOB */ - st->mean_gc[1] = L_add( st->mean_gc[1], st->gain_code[k] ); -#endif min_gp = s_min( min_gp, st->bpf_gainT[k] ); } /* Suppress saturation warning in threshold comparison. */ test(); -#ifdef BASOP_NOGLOB if ( LT_32( st->mean_gc[1], L_add_o( st->mean_gc[0], Mpy_32_16_r( st->mean_gc[0], 3211 /*0.098 Q15*/ ), &Overflow ) ) || GT_16( min_gp, 13435 /*0.82 Q14*/ ) ) -#else - if ( LT_32( st->mean_gc[1], L_add( st->mean_gc[0], Mpy_32_16_r( st->mean_gc[0], 3211 /*0.098 Q15*/ ) ) ) || GT_16( min_gp, 13435 /*0.82 Q14*/ ) ) -#endif { move16(); st->glr_idx[0] = 0; diff --git a/lib_enc/hf_cod_amrwb_fx.c b/lib_enc/hf_cod_amrwb_fx.c index 7c2060fa8663df927207db78e0a59227df997424..e21a8bd677e665f1e9d36c61d1311074ee56c165 100644 --- a/lib_enc/hf_cod_amrwb_fx.c +++ b/lib_enc/hf_cod_amrwb_fx.c @@ -107,14 +107,10 @@ void hf_cod_fx( ener_exc_fx = dot_prod_satcontr( exc_fx, exc_fx, Q_exc, Q_exc, &q1, L_SUBFR ); ener_hf_fx = dot_prod_satcontr( HF_fx, HF_fx, -3, -3, &q2, L_SUBFR16k ); - scale_fx = div_s( shl( 1, 14 ), ener_exc_fx ); /*Q(29-q1) */ - L_tmp = L_mult( ener_hf_fx, scale_fx ); /*30-q1+q2 */ - q2 = sub( q1, q2 ); /*30-q2 */ -#ifdef BASOP_NOGLOB + scale_fx = div_s( shl( 1, 14 ), ener_exc_fx ); /*Q(29-q1) */ + L_tmp = L_mult( ener_hf_fx, scale_fx ); /*30-q1+q2 */ + q2 = sub( q1, q2 ); /*30-q2 */ scale_fx = round_fx( Isqrt( L_shl_o( L_tmp, sub( q2, 26 ), &Overflow ) ) ); /*Q13 */ -#else /* BASOP_NOGLOB */ - scale_fx = round_fx( Isqrt( L_shl( L_tmp, sub( q2, 26 ) ) ) ); /*Q13 */ -#endif /* BASOP_NOGLOB */ pt1 = HF_fx; @@ -187,14 +183,10 @@ void hf_cod_fx( ener_hf_fx = dot_prod_satcontr( HF_syn_fx, HF_syn_fx, 0, 0, &q2, L_SUBFR16k ); ener_input_fx = dot_prod_satcontr( HF_SP_fx, HF_SP_fx, 0, 0, &q1, L_SUBFR16k ); - HF_calc_gain_fx = div_s( shl( 1, 14 ), ener_input_fx ); /*Q(29-q1) */ - L_tmp = L_mult( ener_hf_fx, HF_calc_gain_fx ); /*30-q1+q2 */ - q2 = sub( q1, q2 ); /*30-q2 */ -#ifdef BASOP_NOGLOB + HF_calc_gain_fx = div_s( shl( 1, 14 ), ener_input_fx ); /*Q(29-q1) */ + L_tmp = L_mult( ener_hf_fx, HF_calc_gain_fx ); /*30-q1+q2 */ + q2 = sub( q1, q2 ); /*30-q2 */ HF_calc_gain_fx = round_fx_o( Isqrt( L_shl_sat( L_tmp, sub( q2, 20 ) ) ), &Overflow ); /*Q10 */ -#else /* BASOP_NOGLOB */ - HF_calc_gain_fx = round_fx( Isqrt( L_shl( L_tmp, sub( q2, 20 ) ) ) ); /*Q10 */ -#endif /* set energy of HF synthesis to energy of original HF: diff --git a/lib_enc/hq_classifier_enc_fx.c b/lib_enc/hq_classifier_enc_fx.c index 0259ef9ffdbe151f2896304f54cfedd2e2dafcff..53ad3dbb20a352a0240f4cdeb6957c30dea10d1c 100644 --- a/lib_enc/hq_classifier_enc_fx.c +++ b/lib_enc/hq_classifier_enc_fx.c @@ -847,13 +847,8 @@ void hvq_classifier_ivas_fx( L_pe = L_add( L_pe, L_tmp ); /*Q12 */ } -#ifdef BASOP_NOGLOB L_nf_mean[i] = L_add_sat( L_nf_mean[i], L_nf ); /*Q12 */ L_pe_mean[i] = L_add_sat( L_pe_mean[i], L_pe ); /*Q12 */ -#else - L_nf_mean[i] = L_add( L_nf_mean[i], L_nf ); - L_pe_mean[i] = L_add( L_pe_mean[i], L_pe ); -#endif move32(); move32(); IF( GT_32( L_d, L_peak ) ) @@ -903,11 +898,7 @@ void hvq_classifier_ivas_fx( sharp[i] = extract_h( L_shl( L_tmp, shift ) ); /* 30-s+s-8-16 -> Q6 */ move16(); /*sharp_dist += (sharp[i]-HVQ_SHARP_THRES); */ -#ifdef BASOP_NOGLOB sharp_dist = add_o( sharp_dist, sub( sharp[i], HVQ_SHARP_THRES_FX ), &Overflow ); /* Q6 */ -#else - sharp_dist = add( sharp_dist, sub( sharp[i], HVQ_SHARP_THRES_FX ) ); -#endif if ( GT_16( sharp[i], HVQ_SHARP_THRES_FX ) ) { num_sharp_bands = add( num_sharp_bands, 1 ); @@ -1290,15 +1281,10 @@ void hvq_classifier_fx( L_pe = L_add( L_pe, L_tmp ); /*Q12 */ } -#ifdef BASOP_NOGLOB L_nf_mean[i] = L_add_sat( L_nf_mean[i], L_nf ); /*Q12 */ L_pe_mean[i] = L_add_sat( L_pe_mean[i], L_pe ); /*Q12 */ move32(); move32(); -#else - L_nf_mean[i] = L_add( L_nf_mean[i], L_nf ); - L_pe_mean[i] = L_add( L_pe_mean[i], L_pe ); -#endif IF( GT_32( L_d, L_peak ) ) { L_peak = L_add( L_d, 0 ); @@ -1348,11 +1334,7 @@ void hvq_classifier_fx( move16(); /*sharp_dist += (sharp[i]-HVQ_SHARP_THRES); */ -#ifdef BASOP_NOGLOB sharp_dist = add_o( sharp_dist, sub( sharp[i], HVQ_SHARP_THRES_FX ), &Overflow ); -#else - sharp_dist = add( sharp_dist, sub( sharp[i], HVQ_SHARP_THRES_FX ) ); -#endif IF( GT_16( sharp[i], HVQ_SHARP_THRES_FX ) ) { num_sharp_bands = add( num_sharp_bands, 1 ); diff --git a/lib_enc/hq_core_enc.c b/lib_enc/hq_core_enc.c index 07928e84dfd0a15b495d02e44f2505086504b9ec..dc29b801b61b26856aded3b3da62be97f6cf0cdb 100644 --- a/lib_enc/hq_core_enc.c +++ b/lib_enc/hq_core_enc.c @@ -145,8 +145,11 @@ 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 ); - Copy_Scale_sig_16_32( wtda_audio_fx16, wtda_audio_fx32, 2 * L_FRAME48k, sub( Q_audio, q ) ); /* 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 */ is_transient = 0; diff --git a/lib_enc/hq_lr_enc_fx.c b/lib_enc/hq_lr_enc_fx.c index 3e70bc42ec238369b5561cdc95af18c60f5f8738..424689804d665f7b3bd8325169cf647bc4627d9b 100644 --- a/lib_enc/hq_lr_enc_fx.c +++ b/lib_enc/hq_lr_enc_fx.c @@ -455,11 +455,7 @@ void hq_lr_enc_fx( frac1 = L_Extract_lc( L_tmp, &exp ); /* Extract exponent of L_tmp */ L_tmp = Pow2( 30, frac1 ); exp = sub( exp, 30 ); -#ifdef BASOP_NOGLOB Ep_fx[i] = L_shl_sat( L_tmp, s_max( sub( exp, 6 ), -31 ) ); /* Q -6 */ -#else - Ep_fx[i] = L_shl( L_tmp, s_max( sub( exp, 6 ), -31 ) ); /* Q -6 */ -#endif } FOR( i = 0; i < bands_fx; i++ ) @@ -528,22 +524,13 @@ void hq_lr_enc_fx( { IF( GE_16( i, lowband ) ) { -#ifdef BASOP_NOGLOB Ep_vari_fx = L_add_sat( Ep_vari_fx, L_abs( L_sub( Ep_tmp_fx[i], Ep_tmp_fx[sub( i, 1 )] ) ) ); /*Q15 */ Ep_avrg_fx = L_add_sat( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ move32(); -#else - Ep_vari_fx = L_add( Ep_vari_fx, L_abs( L_sub( Ep_tmp_fx[i], Ep_tmp_fx[sub( i, 1 )] ) ) ); /*Q15 */ - Ep_avrg_fx = L_add( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ -#endif } ELSE { -#ifdef BASOP_NOGLOB Ep_avrgL_fx = L_add_sat( Ep_avrgL_fx, Ep_tmp_fx[i] ); /*Q15 */ -#else - Ep_avrgL_fx = L_add( Ep_avrgL_fx, Ep_tmp_fx[i] ); /*Q15 */ -#endif IF( GT_32( Ep_tmp_fx[i], Ep_peak_fx ) ) { Ep_peak_fx = L_add( Ep_tmp_fx[i], 0 ); /*Q15 */ @@ -620,13 +607,9 @@ void hq_lr_enc_fx( exp = 0; move16(); } - L_tmp = Mult_32_16( Ep_vari_fx, 3277 ); /*13+15-15=13 */ -#ifdef BASOP_NOGLOB + L_tmp = Mult_32_16( Ep_vari_fx, 3277 ); /*13+15-15=13 */ L_tmp = L_shl_o( Mult_32_16( L_tmp, tmp ), sub( 12, exp ), &Overflow ); /*Q(13+exp-15 +12-exp +4 = 14) */ -#else - L_tmp = L_shl( Mult_32_16( L_tmp, tmp ), sub( 12, exp ) ); /*Q(13+exp-15 +12-exp +4 = 14) */ -#endif - tmp2 = extract_h( Ep_avrg_fx ); /*Q13-16=-3 */ + tmp2 = extract_h( Ep_avrg_fx ); /*Q13-16=-3 */ IF( tmp2 != 0 ) { exp = norm_s( tmp2 ); @@ -641,24 +624,16 @@ void hq_lr_enc_fx( exp = 0; move16(); } - L_tmp2 = Mult_32_16( Ep_vari_fx, 6554 ); /*13+15-15=13 */ -#ifdef BASOP_NOGLOB + L_tmp2 = Mult_32_16( Ep_vari_fx, 6554 ); /*13+15-15=13 */ L_tmp2 = L_shl_o( Mult_32_16( L_tmp2, tmp2 ), sub( 13, exp ), &Overflow ); /*Q(13+exp-15 +13-exp +3 = 14) */ -#else - L_tmp2 = L_shl( Mult_32_16( L_tmp2, tmp2 ), sub( 13, exp ) ); /*Q(13+exp-15 +13-exp +3 = 14) */ -#endif - L_tmp = L_min( L_tmp, L_tmp2 ); /*Q14 */ - tmp = extract_l( L_min( L_tmp, 13107 ) ); /*Q14 */ + L_tmp = L_min( L_tmp, L_tmp2 ); /*Q14 */ + tmp = extract_l( L_min( L_tmp, 13107 ) ); /*Q14 */ alpha_fx = add( 16384, tmp ); } IF( EQ_16( hHQ_core->last_bitalloc_max_band[j++], 1 ) ) { L_tmp = Mult_32_16( Ep_tmp_fx[i], sub( bands_fx, lowband ) ); /*Q(13+0-15 = -2) */ -#ifdef BASOP_NOGLOB - tmp = extract_h( L_shl_sat( L_tmp, 14 ) ); /*Q-4 */ -#else - tmp = extract_h( L_shl( L_tmp, 14 ) ); /*Q-2 */ -#endif + tmp = extract_h( L_shl_sat( L_tmp, 14 ) ); /*Q-4 */ IF( tmp != 0 ) { exp = norm_s( tmp ); @@ -673,14 +648,10 @@ void hq_lr_enc_fx( exp = 0; move16(); } -#ifdef BASOP_NOGLOB L_tmp = L_shl_o( Mult_32_16( Ep_avrg_fx, tmp ), sub( 14, exp ), &Overflow ); /*Q(13+exp-15 +14-exp+2 = 14) */ -#else - L_tmp = L_shl( Mult_32_16( Ep_avrg_fx, tmp ), sub( 14, exp ) ); /*Q(13+exp-15 +14-exp+2 = 14) */ -#endif - L_tmp = L_max( L_tmp, 16384 ); /*Q14 */ - tmp = extract_l( L_min( L_tmp, beta_fx ) ); /*Q14 */ - alpha_fx = shl( mult( alpha_fx, tmp ), 1 ); /*14+14-15 +1=Q14 */ + L_tmp = L_max( L_tmp, 16384 ); /*Q14 */ + tmp = extract_l( L_min( L_tmp, beta_fx ) ); /*Q14 */ + alpha_fx = shl( mult( alpha_fx, tmp ), 1 ); /*14+14-15 +1=Q14 */ } ELSE { @@ -700,15 +671,11 @@ void hq_lr_enc_fx( exp = 0; move16(); } -#ifdef BASOP_NOGLOB L_tmp = L_shl_o( Mult_32_16( Ep_tmp_fx[i], tmp2 ), sub( 19, exp ), &Overflow ); /*Q(13+exp-15 +19-exp +3 = 20) */ -#else - L_tmp = L_shl( Mult_32_16( Ep_tmp_fx[i], tmp2 ), sub( 19, exp ) ); /*Q(13+exp-15 +19-exp +3 = 20) */ -#endif - L_tmp = Mult_32_16( L_tmp, shl( sub( bands_fx, lowband ), 9 ) ); /*20 +9 -15 =Q14 */ - L_tmp = L_max( L_tmp, 13926 ); /*Q14 */ - tmp2 = extract_l( L_min( L_tmp, 16384 ) ); /*Q14 */ - alpha_fx = shl( mult( alpha_fx, tmp2 ), 1 ); /*14+14-15+1 =Q14 */ + L_tmp = Mult_32_16( L_tmp, shl( sub( bands_fx, lowband ), 9 ) ); /*20 +9 -15 =Q14 */ + L_tmp = L_max( L_tmp, 13926 ); /*Q14 */ + tmp2 = extract_l( L_min( L_tmp, 16384 ) ); /*Q14 */ + alpha_fx = shl( mult( alpha_fx, tmp2 ), 1 ); /*14+14-15+1 =Q14 */ } L_band_energy_tmp[i] = L_shl( Mult_32_16( L_band_energy_tmp[i], alpha_fx ), 1 ); /*Q(Q_band_energy+14-15 +1= Q_band_energy) */ move32(); @@ -723,19 +690,11 @@ void hq_lr_enc_fx( { IF( GE_16( i, lowband ) ) { -#ifdef BASOP_NOGLOB Ep_avrg_fx = L_add_sat( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ -#else - Ep_avrg_fx = L_add( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ -#endif } ELSE { -#ifdef BASOP_NOGLOB Ep_avrgL_fx = L_add_sat( Ep_avrgL_fx, L_shr( Ep_tmp_fx[i], 1 ) ); /*Q12 */ -#else - Ep_avrgL_fx = L_add( Ep_avrgL_fx, L_shr( Ep_tmp_fx[i], 1 ) ); /*Q12 */ -#endif IF( GT_32( Ep_tmp_fx[i], Ep_peak_fx ) ) { Ep_peak_fx = L_add( Ep_tmp_fx[i], 0 ); /*Q13 */ @@ -791,12 +750,8 @@ void hq_lr_enc_fx( bit_budget_fx = sub( bit_budget_fx, 2 ); /* bits in high bands to indicate the last 2 subbands is allocated bits or not Q0*/ FOR( i = 0; i < bands_fx; i++ ) { -#ifdef BASOP_NOGLOB Ep_tmp_fx[i] = L_shl_o( Ep_tmp_fx[i], 2, &Overflow ); /* Q15 */ move32(); -#else /* BASOP_NOGLOB */ - Ep_tmp_fx[i] = L_shl( Ep_tmp_fx[i], 2 ); -#endif /* BASOP_NOGLOB */ } IF( EQ_32( st_fx->core_brate, ACELP_13k20 ) ) { @@ -826,33 +781,17 @@ void hq_lr_enc_fx( test(); IF( GE_16( i, lowband ) && add( sub( i, bands_fx ), p2a_bands_fx ) < 0 ) { -#ifdef BASOP_NOGLOB Ep_vari_fx = L_add_sat( Ep_vari_fx, L_abs( L_sub_sat( Ep_tmp_fx[i], Ep_tmp_fx[( i - 1 )] ) ) ); /*Q15 */ -#else - Ep_vari_fx = L_add( Ep_vari_fx, L_abs( L_sub( Ep_tmp_fx[i], Ep_tmp_fx[sub( i, 1 )] ) ) ); /*Q15 */ -#endif -#ifdef BASOP_NOGLOB - Ep_avrg_fx = L_add_o( Ep_avrg_fx, Ep_tmp_fx[i], &Overflow ); /*Q15 */ -#else /* BASOP_NOGLOB */ - Ep_avrg_fx = L_add( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ -#endif /* BASOP_NOGLOB */ + Ep_avrg_fx = L_add_o( Ep_avrg_fx, Ep_tmp_fx[i], &Overflow ); /*Q15 */ } IF( GE_16( i, highband ) ) { -#ifdef BASOP_NOGLOB enerH_fx = L_add_sat( enerH_fx, L_shl_sat( Ep_fx[i], 2 ) ); /*Q0 */ -#else - enerH_fx = L_add( enerH_fx, L_shl( Ep_fx[i], 2 ) ); /*Q0 */ -#endif } ELSE IF( GE_16( i, lowband ) ) { -#ifdef BASOP_NOGLOB enerL_fx = L_add_sat( enerL_fx, L_shl_sat( Ep_fx[i], 2 ) ); /*Q0 */ -#else - enerL_fx = L_add( enerL_fx, L_shl( Ep_fx[i], 2 ) ); /*Q0 */ -#endif } } @@ -873,11 +812,7 @@ void hq_lr_enc_fx( tmp = sub( bands_fx, p2a_bands_fx ); tmp = sub( tmp, lowband ); /*Q0 */ -#ifdef BASOP_NOGLOB tmp1 = extract_h( L_shl_sat( Ep_avrg_fx, 1 ) ); /*Q0 */ -#else - tmp1 = extract_h( L_shl( Ep_avrg_fx, 1 ) ); /*Q0 */ -#endif IF( tmp1 != 0 ) { exp = norm_s( tmp1 ); @@ -915,12 +850,8 @@ void hq_lr_enc_fx( IF( EQ_16( hHQ_core->last_bitalloc_max_band[sub( i, add( tmp, 1 ) )], 1 ) ) { tmp = sub( tmp, lowband ); - L_tmp = Mult_32_16( Ep_tmp_fx[i], tmp ); /*Q(15+0-15 = 0) */ -#ifdef BASOP_NOGLOB + L_tmp = Mult_32_16( Ep_tmp_fx[i], tmp ); /*Q(15+0-15 = 0) */ tmp = extract_h( L_shl_o( L_tmp, 16, &Overflow ) ); /*Q0 */ -#else /* BASOP_NOGLOB */ - tmp = extract_h( L_shl( L_tmp, 16 ) ); /*Q0 */ -#endif /* BASOP_NOGLOB */ IF( tmp != 0 ) { exp = norm_s( tmp ); @@ -945,11 +876,7 @@ void hq_lr_enc_fx( { tmp = sub( tmp, lowband ); -#ifdef BASOP_NOGLOB tmp1 = extract_h( L_shl_sat( Ep_avrg_fx, 1 ) ); /*Q0 */ -#else - tmp1 = extract_h( L_shl( Ep_avrg_fx, 1 ) ); /*Q0 */ -#endif IF( tmp1 != 0 ) { exp = norm_s( tmp1 ); @@ -985,19 +912,11 @@ void hq_lr_enc_fx( { IF( GE_16( i, lowband ) ) { -#ifdef BASOP_NOGLOB Ep_avrg_fx = L_add_o( Ep_avrg_fx, Ep_tmp_fx[i], &Overflow ); /*Q15 */ -#else /* BASOP_NOGLOB */ - Ep_avrg_fx = L_add( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ -#endif /* BASOP_NOGLOB */ } ELSE { -#ifdef BASOP_NOGLOB Ep_avrgL_fx = L_add_o( Ep_avrgL_fx, Ep_tmp_fx[i], &Overflow ); /*Q15 */ -#else /* BASOP_NOGLOB */ - Ep_avrgL_fx = L_add( Ep_avrgL_fx, Ep_tmp_fx[i] ); /*Q15 */ -#endif IF( GT_32( Ep_tmp_fx[i], Ep_peak_fx ) ) { Ep_peak_fx = L_add( Ep_tmp_fx[i], 0 ); /*Q15 */ @@ -1021,11 +940,7 @@ void hq_lr_enc_fx( move16(); FOR( i = 0; i < lowband; i++ ) { -#ifdef BASOP_NOGLOB tmp = extract_h( L_shl_sat( Ep_avrgL_fx, 1 ) ); /*Q0 */ -#else - tmp = extract_h( L_shl( Ep_avrgL_fx, 1 ) ); /*Q0 */ -#endif IF( tmp != 0 ) { exp = norm_s( tmp ); @@ -1265,10 +1180,8 @@ void hq_lr_enc_ivas_fx( Word32 L_band_energy_tmp[BANDS_MAX]; UWord16 lo; Word16 Q_band_energy; -#ifdef BASOP_NOGLOB Flag Overflow; move32(); -#endif /* BASOP_NOGLOB */ BSTR_ENC_HANDLE hBstr = st->hBstr; HQ_ENC_HANDLE hHQ_core = st->hHQ_core; @@ -1536,11 +1449,7 @@ void hq_lr_enc_ivas_fx( } ELSE { -#ifdef BASOP_NOGLOB Ep_avrgL_fx = L_add_o( Ep_avrgL_fx, Ep_tmp_fx[i], &Overflow ); /*Q15 */ -#else - Ep_avrgL_fx = L_add( Ep_avrgL_fx, Ep_tmp_fx[i] ); /*Q15 */ -#endif IF( L_sub( Ep_tmp_fx[i], Ep_peak_fx ) > 0 ) { Ep_peak_fx = Ep_tmp_fx[i]; /*Q15 */ @@ -1664,17 +1573,10 @@ void hq_lr_enc_ivas_fx( move16(); } Mpy_32_16_ss( Ep_avrg_fx, tmp, &L_tmp, &lo ); -#ifndef BASOP_NOGLOB - L_tmp = L_shl( L_tmp, sub( 14, exp ) ); /*Q(13+exp-15 +14-exp+2 = 14) */ - L_tmp = L_max( L_tmp, 16384 ); /*14 */ - tmp = extract_l( L_min( L_tmp, beta_fx ) ); /*14 */ - alpha_fx = shl( mult( alpha_fx, tmp ), 1 ); /*14+14-15 +1=14 */ -#else /* BASOP_NOGLOB */ - L_tmp = L_shl_o( L_tmp, sub( 14, exp ), &Overflow ); /*Q(13+exp-15 +14-exp+2 = 14) */ - L_tmp = L_max( L_tmp, 16384 ); /*14 */ - tmp = extract_l( L_min( L_tmp, beta_fx ) ); /*14 */ - alpha_fx = shl( mult( alpha_fx, tmp ), 1 ); /*14+14-15 +1=14 */ -#endif /* BASOP_NOGLOB */ + L_tmp = L_shl_o( L_tmp, sub( 14, exp ), &Overflow ); /*Q(13+exp-15 +14-exp+2 = 14) */ + L_tmp = L_max( L_tmp, 16384 ); /*14 */ + tmp = extract_l( L_min( L_tmp, beta_fx ) ); /*14 */ + alpha_fx = shl( mult( alpha_fx, tmp ), 1 ); /*14+14-15 +1=14 */ } ELSE { @@ -1718,11 +1620,7 @@ void hq_lr_enc_ivas_fx( { IF( sub( i, lowband ) >= 0 ) { -#ifdef BASOP_NOGLOB Ep_avrg_fx = L_add_o( Ep_avrg_fx, Ep_tmp_fx[i], &Overflow ); /*Q15 */ -#else - Ep_avrg_fx = L_add( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ -#endif } ELSE { @@ -1764,13 +1662,8 @@ void hq_lr_enc_ivas_fx( Mpy_32_16_ss( Ep_peak_fx, tmp, &L_tmp, &lo ); Mpy_32_16_ss( L_tmp, lowband, &L_tmp, &lo ); Mpy_32_16_ss( L_tmp, 18842, &L_tmp, &lo ); -#ifndef BASOP_NOGLOB - L_tmp = L_shl( L_tmp, sub( 27, exp ) ); /*Q14 0.5 */ - tmp2 = extract_l( L_min( L_tmp, 19661 ) ); /*14 */ -#else /* BASOP_NOGLOB */ - L_tmp = L_shl_o( L_tmp, sub( 27, exp ), &Overflow ); /*Q14 0.5 */ - tmp2 = extract_l( L_min( L_tmp, 19661 ) ); /*14 */ -#endif /* BASOP_NOGLOB */ + L_tmp = L_shl_o( L_tmp, sub( 27, exp ), &Overflow ); /*Q14 0.5 */ + tmp2 = extract_l( L_min( L_tmp, 19661 ) ); /*14 */ Mpy_32_16_ss( L_band_energy_tmp[i], tmp2, &L_tmp, &lo ); L_band_energy_tmp[i] = L_shl( L_tmp, 1 ); /*Q_band_energy */ move32(); @@ -1793,12 +1686,8 @@ void hq_lr_enc_ivas_fx( bit_budget = sub( bit_budget, 2 ); /* bits in high bands to indicate the last 2 subbands is allocated bits or not */ FOR( i = 0; i < bands; i++ ) { -#ifndef BASOP_NOGLOB - Ep_tmp_fx[i] = L_shl( Ep_tmp_fx[i], 2 ); -#else /* BASOP_NOGLOB */ - Ep_tmp_fx[i] = L_shl_o( Ep_tmp_fx[i], 2, &Overflow ); /* Q15 */ + Ep_tmp_fx[i] = L_shl_o( Ep_tmp_fx[i], 2, &Overflow ); /* Q15 */ move32(); -#endif /* BASOP_NOGLOB */ } IF( EQ_32( st->core_brate, ACELP_13k20 ) ) { @@ -1833,11 +1722,7 @@ void hq_lr_enc_ivas_fx( IF( sub( i, lowband ) >= 0 && add( sub( i, bands ), p2a_bands ) < 0 ) { Ep_vari_fx = L_add( Ep_vari_fx, L_abs( L_sub( Ep_tmp_fx[i], Ep_tmp_fx[sub( i, 1 )] ) ) ); /*Q15 */ -#ifndef BASOP_NOGLOB - Ep_avrg_fx = L_add( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ -#else /* BASOP_NOGLOB */ - Ep_avrg_fx = L_add_o( Ep_avrg_fx, Ep_tmp_fx[i], &Overflow ); /*Q15 */ -#endif /* BASOP_NOGLOB */ + Ep_avrg_fx = L_add_o( Ep_avrg_fx, Ep_tmp_fx[i], &Overflow ); /*Q15 */ } IF( sub( i, highband ) >= 0 ) @@ -1870,11 +1755,7 @@ void hq_lr_enc_ivas_fx( tmp = sub( bands, p2a_bands ); tmp = sub( tmp, lowband ); /*Q0 */ -#ifndef BASOP_NOGLOB - tmp1 = extract_h( L_shl( Ep_avrg_fx, 1 ) ); /*Q0 */ -#else - tmp1 = extract_h( L_shl_o( Ep_avrg_fx, 1, &Overflow ) ); /*Q0 */ -#endif + tmp1 = extract_h( L_shl_o( Ep_avrg_fx, 1, &Overflow ) ); /*Q0 */ IF( tmp1 != 0 ) { exp = norm_s( tmp1 ); @@ -1913,11 +1794,7 @@ void hq_lr_enc_ivas_fx( { tmp = sub( tmp, lowband ); Mpy_32_16_ss( Ep_tmp_fx[i], tmp, &L_tmp, &lo ); -#ifndef BASOP_NOGLOB - tmp = extract_h( L_shl( L_tmp, 16 ) ); /*Q0 */ -#else /* BASOP_NOGLOB */ - tmp = extract_h( L_shl_o( L_tmp, 16, &Overflow ) ); /*Q0 */ -#endif /* BASOP_NOGLOB */ + tmp = extract_h( L_shl_o( L_tmp, 16, &Overflow ) ); /*Q0 */ IF( tmp != 0 ) { exp = norm_s( tmp ); @@ -1942,11 +1819,7 @@ void hq_lr_enc_ivas_fx( { tmp = sub( tmp, lowband ); -#ifndef BASOP_NOGLOB - tmp1 = extract_h( L_shl( Ep_avrg_fx, 1 ) ); /*Q0 */ -#else - tmp1 = extract_h( L_shl_o( Ep_avrg_fx, 1, &Overflow ) ); /*Q0 */ -#endif + tmp1 = extract_h( L_shl_o( Ep_avrg_fx, 1, &Overflow ) ); /*Q0 */ IF( tmp1 != 0 ) { exp = norm_s( tmp1 ); @@ -1985,19 +1858,11 @@ void hq_lr_enc_ivas_fx( { IF( sub( i, lowband ) >= 0 ) { -#ifndef BASOP_NOGLOB - Ep_avrg_fx = L_add( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ -#else /* BASOP_NOGLOB */ - Ep_avrg_fx = L_add_o( Ep_avrg_fx, Ep_tmp_fx[i], &Overflow ); /*Q15 */ -#endif /* BASOP_NOGLOB */ + Ep_avrg_fx = L_add_o( Ep_avrg_fx, Ep_tmp_fx[i], &Overflow ); /*Q15 */ } ELSE { -#ifndef BASOP_NOGLOB - Ep_avrgL_fx = L_add( Ep_avrgL_fx, Ep_tmp_fx[i] ); /*Q15 */ -#else /* BASOP_NOGLOB */ Ep_avrgL_fx = L_add_o( Ep_avrgL_fx, Ep_tmp_fx[i], &Overflow ); /*Q15 */ -#endif /* BASOP_NOGLOB */ IF( L_sub( Ep_tmp_fx[i], Ep_peak_fx ) > 0 ) { Ep_peak_fx = Ep_tmp_fx[i]; /* Q15 */ @@ -2022,11 +1887,7 @@ void hq_lr_enc_ivas_fx( move16(); FOR( i = 0; i < lowband; i++ ) { -#ifndef BASOP_NOGLOB - tmp = extract_h( L_shl( Ep_avrgL_fx, 1 ) ); /*Q0 */ -#else - tmp = extract_h( L_shl_o( Ep_avrgL_fx, 1, &Overflow ) ); /*Q0 */ -#endif + tmp = extract_h( L_shl_o( Ep_avrgL_fx, 1, &Overflow ) ); /*Q0 */ IF( tmp != 0 ) { exp = norm_s( tmp ); @@ -3604,11 +3465,7 @@ static Word16 p2a_threshold_quant_fx( /* 10/( log(10)/log(2) ) = 3.01029995663981195211 24660(Q13) */ L_p2a = Mpy_32_16_1( L_tmp, 24660 ); /* 16+13-15 -> Q14 */ -#ifdef BASOP_NOGLOB p2a_fx = round_fx_o( L_shl_o( L_p2a, 13, &Overflow ), &Overflow ); /* 27 -16 -> 11 */ -#else - p2a_fx = round_fx( L_shl( L_p2a, 13 ) ); /* 27 -16 -> 11 */ -#endif } IF( LE_16( p2a_fx, p2a_th_fx ) ) @@ -3727,11 +3584,7 @@ static Word16 p2a_threshold_quant_ivas_fx( /* 10/( log(10)/log(2) ) = 3.01029995663981195211 24660(Q13) */ L_p2a = Mpy_32_16_1( L_tmp, 24660 ); /* 16+13-15 -> Q14 */ -#ifdef BASOP_NOGLOB p2a_fx = round_fx_o( L_shl_o( L_p2a, 13, &Overflow ), &Overflow ); /* 27 -16 -> 11 */ -#else - p2a_fx = round_fx( L_shl( L_p2a, 13 ) ); /* 27 -16 -> 11 */ -#endif } IF( LE_16( p2a_fx, p2a_th_fx ) ) @@ -3871,13 +3724,9 @@ static void mdct_spectrum_fine_gain_enc_fx( exp_normn = norm_l( L_Exy ); exp_normn = sub( exp_normn, 1 ); exp_normd = norm_l( L_Eyy ); -#ifdef BASOP_NOGLOB gamma_fx = div_l( L_shl_o( L_Exy, exp_normn, &Overflow ), round_fx_o( L_shl_o( L_Eyy, exp_normd, &Overflow ), &Overflow ) ); /* Qgamma */ -#else - gamma_fx = div_l( L_shl( L_Exy, exp_normn ), round_fx( L_shl( L_Eyy, exp_normd ) ) ); -#endif - Qgamma = add( sub( exp_normn, exp_normd ), 15 ); /* exp_normn - (exp_normd-16) - 1; */ - gamma_fx = shl( gamma_fx, sub( 14, Qgamma ) ); /* Qgamma -> Q14 */ + Qgamma = add( sub( exp_normn, exp_normd ), 15 ); /* exp_normn - (exp_normd-16) - 1; */ + gamma_fx = shl( gamma_fx, sub( 14, Qgamma ) ); /* Qgamma -> Q14 */ dmin_fx = 32767; move16(); @@ -4037,13 +3886,9 @@ static void mdct_spectrum_fine_gain_enc_ivas_fx( exp_normn = norm_l( L_Exy ); exp_normn = sub( exp_normn, 1 ); exp_normd = norm_l( L_Eyy ); -#ifdef BASOP_NOGLOB gamma_fx = div_l( L_shl_o( L_Exy, exp_normn, &Overflow ), round_fx_o( L_shl_o( L_Eyy, exp_normd, &Overflow ), &Overflow ) ); /* Qgamma */ -#else - gamma_fx = div_l( L_shl( L_Exy, exp_normn ), round_fx( L_shl( L_Eyy, exp_normd ) ) ); -#endif - Qgamma = add( sub( exp_normn, exp_normd ), 15 ); /* exp_normn - (exp_normd-16) - 1; */ - gamma_fx = shl( gamma_fx, sub( 14, Qgamma ) ); /* Qgamma -> Q14 */ + Qgamma = add( sub( exp_normn, exp_normd ), 15 ); /* exp_normn - (exp_normd-16) - 1; */ + gamma_fx = shl( gamma_fx, sub( 14, Qgamma ) ); /* Qgamma -> Q14 */ dmin_fx = 32767; move16(); diff --git a/lib_enc/hvq_enc_fx.c b/lib_enc/hvq_enc_fx.c index aae437c01c68bfdc0b68272e2d7a9c66da6077cb..54bc4fb5822896ff14f9e077477c4dd20dbb0f25 100644 --- a/lib_enc/hvq_enc_fx.c +++ b/lib_enc/hvq_enc_fx.c @@ -13,7 +13,7 @@ #define HVQ_ENC_NOISE_DELTA ( (Word16) 3277 ) /* 0.1 in Q15 */ -static Word16 quant_lc( const Word16, Word16 * ); +static Word16 quant_lc_fx( const Word16, Word16 * ); /*--------------------------------------------------------------------------* @@ -119,11 +119,7 @@ Word16 hvq_enc_ivas_fx( /*o : Consumed bits nf_cnt = add( nf_cnt, 1 ); /* Q0 */ } -#ifdef BASOP_NOGLOB pe_mean = L_add_o( pe_mean, pe, &Overflow ); /* in Q12 and always positive */ -#else - pe_mean = L_add( pe_mean, pe ); /* in Q12 and always positive */ -#endif } IF( pe_mean > 0 ) @@ -150,14 +146,10 @@ Word16 hvq_enc_ivas_fx( /*o : Consumed bits acc = L_mult( tmp16, HVQ_NFPE_FACTOR_CUBE_FX ); /* in Q(12+6+1) = Q19 */ expNfpe3 = extract_l( L_mult0( expNfpe, 3 ) ); /* Cube operation */ /* Number of bits required to adjust to Q15 */ - adjust = add( 19 - ( 15 + 16 ), expNfpe3 ); /* +16 is due to the following extract_h(). */ -#ifdef BASOP_NOGLOB + adjust = add( 19 - ( 15 + 16 ), expNfpe3 ); /* +16 is due to the following extract_h(). */ noise_level[i] = extract_h( L_shr_o( acc, adjust, &Overflow ) ); /* noise_level[] in Q15 */ move16(); -#else - noise_level[i] = extract_h( L_shr( acc, adjust ) ); /* noise_level[] in Q15 */ -#endif - q_noise_level_idx[i] = quant_lc( noise_level[i], &q_noise_level[i] ); + q_noise_level_idx[i] = quant_lc_fx( noise_level[i], &q_noise_level[i] ); move16(); } ELSE @@ -185,22 +177,14 @@ Word16 hvq_enc_ivas_fx( /*o : Consumed bits acc = L_mult( tmp16, HVQ_LB_NFPE_FACTOR_CUBE_FX ); /* in Q(12+9+1) = Q22 */ expo3 = extract_l( L_mult0( expo, 3 ) ); /* Cube operation. */ /* Number of bits required to adjust to Q15 */ - adjust = add( 22 - ( 15 + 16 ), expo3 ); /* +16 is due to the following extract_h(). */ -#ifdef BASOP_NOGLOB + adjust = add( 22 - ( 15 + 16 ), expo3 ); /* +16 is due to the following extract_h(). */ lb_nfpe = extract_h( L_shr_o( acc, adjust, &Overflow ) ); /* noise_level[] in Q15 */ -#else - lb_nfpe = extract_h( L_shr( acc, adjust ) ); /* noise_level[] in Q15 */ -#endif - IF( GT_16( lb_nfpe, 16384 ) ) /* in Q15 */ + IF( GT_16( lb_nfpe, 16384 ) ) /* in Q15 */ { lb_nfpe = 16384; move16(); } -#ifdef BASOP_NOGLOB Mpy_32_16_ss( nf_gains[i], shl_o( lb_nfpe, 1, &Overflow ), &nf_gains[i], &dontCare ); /* nf_gains[] in Q12 */ -#else - Mpy_32_16_ss( nf_gains[i], shl( lb_nfpe, 1 ), &nf_gains[i], &dontCare ); /* nf_gains[] in Q12 */ -#endif } ELSE { @@ -245,6 +229,7 @@ Word16 hvq_enc_fx( /*o : Consumed bits Word16 tmp16, adjust; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif bits_used = 0; move16(); @@ -311,11 +296,7 @@ Word16 hvq_enc_fx( /*o : Consumed bits nf_cnt = add( nf_cnt, 1 ); /* Q0 */ } -#ifdef BASOP_NOGLOB pe_mean = L_add_o( pe_mean, pe, &Overflow ); /* in Q12 and always positive */ -#else - pe_mean = L_add( pe_mean, pe ); /* in Q12 and always positive */ -#endif } IF( pe_mean > 0 ) @@ -342,13 +323,11 @@ Word16 hvq_enc_fx( /*o : Consumed bits acc = L_mult( tmp16, HVQ_NFPE_FACTOR_CUBE_FX ); /* in Q(12+6+1) = Q19 */ expNfpe3 = extract_l( L_mult0( expNfpe, 3 ) ); /* Cube operation */ /* Number of bits required to adjust to Q15 */ - adjust = add( 19 - ( 15 + 16 ), expNfpe3 ); /* +16 is due to the following extract_h(). */ -#ifdef BASOP_NOGLOB + adjust = add( 19 - ( 15 + 16 ), expNfpe3 ); /* +16 is due to the following extract_h(). */ noise_level[i] = extract_h( L_shr_o( acc, adjust, &Overflow ) ); /* noise_level[] in Q15 */ -#else - noise_level[i] = extract_h( L_shr( acc, adjust ) ); /* noise_level[] in Q15 */ -#endif - q_noise_level_idx[i] = quant_lc( noise_level[i], &q_noise_level[i] ); + move16(); + q_noise_level_idx[i] = quant_lc_fx( noise_level[i], &q_noise_level[i] ); + move16(); } ELSE { @@ -361,6 +340,7 @@ Word16 hvq_enc_fx( /*o : Consumed bits bits_used = add( bits_used, 2 ); noise_level[i] = q_noise_level[i]; /* in Q15 */ + move16(); } FOR( i = 0; i < HVQ_NF_GROUPS; i++ ) @@ -374,22 +354,14 @@ Word16 hvq_enc_fx( /*o : Consumed bits acc = L_mult( tmp16, HVQ_LB_NFPE_FACTOR_CUBE_FX ); /* in Q(12+9+1) = Q22 */ expo3 = extract_l( L_mult0( expo, 3 ) ); /* Cube operation. */ /* Number of bits required to adjust to Q15 */ - adjust = add( 22 - ( 15 + 16 ), expo3 ); /* +16 is due to the following extract_h(). */ -#ifdef BASOP_NOGLOB + adjust = add( 22 - ( 15 + 16 ), expo3 ); /* +16 is due to the following extract_h(). */ lb_nfpe = extract_h( L_shr_o( acc, adjust, &Overflow ) ); /* noise_level[] in Q15 */ -#else - lb_nfpe = extract_h( L_shr( acc, adjust ) ); /* noise_level[] in Q15 */ -#endif - IF( lb_nfpe > 16384 ) /* in Q15 */ + IF( lb_nfpe > 16384 ) /* in Q15 */ { lb_nfpe = 16384; move16(); } -#ifdef BASOP_NOGLOB Mpy_32_16_ss( nf_gains[i], shl_o( lb_nfpe, 1, &Overflow ), &nf_gains[i], &dontCare ); /* nf_gains[] in Q12 */ -#else - Mpy_32_16_ss( nf_gains[i], shl( lb_nfpe, 1 ), &nf_gains[i], &dontCare ); /* nf_gains[] in Q12 */ -#endif } ELSE { @@ -399,6 +371,7 @@ Word16 hvq_enc_fx( /*o : Consumed bits } nBits = peak_vq_enc_fx( st_fx->hBstr, st_fx->bwidth, coefs, coefs_out, core_brate, sub( hvq_bits, bits_used ), Npeaks, ynrm, R, peaks, &nf_gains[0] ); + move16(); bits_used = add( bits_used, nBits ); return bits_used; } @@ -408,7 +381,7 @@ Word16 hvq_enc_fx( /*o : Consumed bits * * Quantize the noise to one of the levels in {0, 0.1, 0.2, 0.3} *----------------------------------------------------------------------------*/ -static Word16 quant_lc( const Word16 x, Word16 *qx ) +static Word16 quant_lc_fx( const Word16 x, Word16 *qx ) { Word16 indx; diff --git a/lib_enc/igf_enc.c b/lib_enc/igf_enc.c index 9ca1cd5fc529e32ae8dd845d85a26bbd4349c4ff..d20169e73002d69c8cb78e00026c3e61cae2eed9 100644 --- a/lib_enc/igf_enc.c +++ b/lib_enc/igf_enc.c @@ -51,11 +51,11 @@ #define INV_Log2_10_Q12 1233 /*1/log2(10) in Q12*/ #define INV_Log2_e_Q15 22713 /*1/log2(e) in Q15*/ /*-------------------------------------------------------------------* - * IGF_write_bit() + * IGF_write_bit_fx() * * write single bit to stream *-------------------------------------------------------------------*/ -static void IGF_write_bit( +static void IGF_write_bit_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ Word16 *bitCount, /* i/o: bit counter */ const Word16 value /* i : value */ @@ -88,11 +88,11 @@ static void IGF_write_bits( { IF( s_and( value, shl( 1, bits ) ) == 0 ) { - IGF_write_bit( hBstr, bitCount, 0 ); + IGF_write_bit_fx( hBstr, bitCount, 0 ); } ELSE { - IGF_write_bit( hBstr, bitCount, 1 ); + IGF_write_bit_fx( hBstr, bitCount, 1 ); } } @@ -290,27 +290,27 @@ static Word32 IGF_getTNR_fx( width = sub( stop, start ); FOR( i = start; i < stop; i++ ) { - rootSpec_e[sub( i, start )] = e_ps; + rootSpec_e[i - start] = e_ps; move16(); - rootSpec[sub( i, start )] = Sqrt32( powerSpectrum[i], &rootSpec_e[sub( i, start )] ); /*rootSpec[i - start] = sqrtf( powerSpectrum[i] );*/ + rootSpec[i - start] = Sqrt32( powerSpectrum[i], &rootSpec_e[i - start] ); /*rootSpec[i - start] = sqrtf( powerSpectrum[i] );*/ move32(); - avg = BASOP_Util_Add_Mant32Exp( avg, avg_e, rootSpec[sub( i, start )], rootSpec_e[sub( i, start )], &avg_e ); /*avg += rootSpec[i - start];resultant exponent is avg_e*/ + avg = BASOP_Util_Add_Mant32Exp( avg, avg_e, rootSpec[i - start], rootSpec_e[i - start], &avg_e ); /*avg += rootSpec[i - start];resultant exponent is avg_e*/ } avg = BASOP_Util_Divide3216_Scale( avg, width, &tmp_e ); /*avg /= width;*/ avg_e = add( 16, sub( add( avg_e, tmp_e ), 15 ) ); FOR( i = start; i < stop; i++ ) { - Word16 normSpec_e; /*stores resultant exponent for normSpec*/ - Word16 normSpec = BASOP_Util_Divide3232_Scale( rootSpec[sub( i, start )], avg, &normSpec_e ); /*rootSpec[i - start] / avg;*/ - normSpec_e = add( normSpec_e, sub( rootSpec_e[sub( i, start )], avg_e ) ); + Word16 normSpec_e; /*stores resultant exponent for normSpec*/ + Word16 normSpec = BASOP_Util_Divide3232_Scale( rootSpec[i - start], avg, &normSpec_e ); /*rootSpec[i - start] / avg;*/ + normSpec_e = add( normSpec_e, sub( rootSpec_e[i - start], avg_e ) ); IF( GT_32( normSpec, L_add( L_shl( 1, sub( 15, normSpec_e ) ), L_shl( adap, sub( e_adap, normSpec_e ) ) ) ) ) { - tonal = BASOP_Util_Add_Mant32Exp( tonal, tonal_e, rootSpec[sub( i, start )], rootSpec_e[sub( i, start )], &tonal_e ); /*tonal += rootSpec[i - start];*/ + tonal = BASOP_Util_Add_Mant32Exp( tonal, tonal_e, rootSpec[i - start], rootSpec_e[i - start], &tonal_e ); /*tonal += rootSpec[i - start];*/ } ELSE IF( LT_32( normSpec, L_shl( 1, sub( 15, normSpec_e ) ) ) ) { - noise = BASOP_Util_Add_Mant32Exp( noise, noise_e, rootSpec[sub( i, start )], rootSpec_e[sub( i, start )], &noise_e ); /*noise += rootSpec[i - start];*/ + noise = BASOP_Util_Add_Mant32Exp( noise, noise_e, rootSpec[i - start], rootSpec_e[i - start], &noise_e ); /*noise += rootSpec[i - start];*/ } } @@ -318,7 +318,6 @@ static Word32 IGF_getTNR_fx( IF( noise == 0 ) // To handle condition if denom = 0 { tonalToNoise = imult3216( L_shr( L_add( L_shl( 18 /* log10f(1e-018f) */, Q25 ), Mpy_32_16_1( L_add( BASOP_Util_Log2( tonal ), L_shl( tonal_e, Q25 ) ) /*Q25*/, INV_Log2_10_Q15 ) /*25+15-15*/ ), 3 ) /*Q22*/, 20 ); - move32(); } ELSE { @@ -482,7 +481,7 @@ static void IGF_CalculateEnvelope_ivas_fx( Word16 tmp_e; hPrivateData = &hIGFEnc->igfData; - hGrid = &hPrivateData->igfInfo.grid[(int16_t) igfGridIdx]; + hGrid = &hPrivateData->igfInfo.grid[(Word16) igfGridIdx]; swb_offset = hGrid->swb_offset; IF( element_mode > EVS_MONO ) @@ -555,7 +554,6 @@ static void IGF_CalculateEnvelope_ivas_fx( move16(); move16(); move16(); - move16(); IF( pPowerSpectrum_fx != NULL ) { @@ -577,8 +575,8 @@ static void IGF_CalculateEnvelope_ivas_fx( strt_cpy = add( strt_cpy, 1 ); } - sfbEnergyTileR = L_deposit_l( BASOP_Util_Divide3232_Scale( sfbEnergyTileR, width, &tmp_e ) ); - sfbEnergyTileR_e = add( sub( sfbEnergyTileR_e, Q15 ), tmp_e ); + sfbEnergyTileR = L_deposit_h( BASOP_Util_Divide3232_Scale( sfbEnergyTileR, width, &tmp_e ) ); + sfbEnergyTileR_e = add( sub( sfbEnergyTileR_e, Q31 ), tmp_e ); IF( sfbEnergyTileR == 0 ) { @@ -613,7 +611,6 @@ static void IGF_CalculateEnvelope_ivas_fx( gain = Mult_32_16( sfbEnergyTileR, temp ); // gain_e gain_e = add( tmp_e, sfbEnergyTileR_e ); - test(); IF( element_mode > EVS_MONO ) { test(); @@ -664,14 +661,17 @@ static void IGF_CalculateEnvelope_ivas_fx( Word16 tmp0, tmp2, tmp3, tmp4; Word16 tmp0_e, tmp2_e, tmp3_e, tmp4_e; tmp0 = shr( hPrivateData->prevSFM_FIR_SFB_TB_fx[sfb], 2 ); - tmp0_e = hPrivateData->prevSFB_FIR_TB_e[sfb] + 2; + tmp0_e = add( hPrivateData->prevSFB_FIR_TB_e[sfb], 2 ); + move16(); tmp2 = shr( hPrivateData->prevSFM_IIR_SFB_TB_fx[sfb], 2 ); - tmp2_e = hPrivateData->prevSFB_IIR_TB_e[sfb] + 2; + tmp2_e = add( hPrivateData->prevSFB_IIR_TB_e[sfb], 2 ); + move16(); tmp3 = shr( hPrivateData->prevSFM_FIR_SFB_SB_fx[sfb], 2 ); - tmp3_e = hPrivateData->prevSFB_FIR_SB_e[sfb] + 2; + tmp3_e = add( hPrivateData->prevSFB_FIR_SB_e[sfb], 2 ); + move16(); tmp4 = shr( hPrivateData->prevSFM_IIR_SFB_SB_fx[sfb], 2 ); - tmp4_e = hPrivateData->prevSFB_IIR_SB_e[sfb] + 2; - + tmp4_e = add( hPrivateData->prevSFB_IIR_SB_e[sfb], 2 ); + move16(); Word16 x1, x2; Word16 x1_e = BASOP_Util_Add_MantExp( tmp0, tmp0_e, tmp2, tmp2_e - 1, &x1 ); @@ -703,7 +703,7 @@ static void IGF_CalculateEnvelope_ivas_fx( BASOP_Util_Add_MantExp( hPrivateData->SFM_sb_fx[sfb], hPrivateData->sfb_sb_e[sfb], negate( hPrivateData->SFM_tb_fx[sfb] ), hPrivateData->sfb_tb_e[sfb], &diffSFM ); test(); - IF( diffSFM > 0 && LT_32( hPrivateData->SFM_tb_fx[sfb], L_shr( 3277 /*0.1 Q15*/, tmp_tb_e ) ) ) /* check whether target SFB is more tonal than source SFB */ + IF( diffSFM > 0 && LT_32( hPrivateData->SFM_tb_fx[sfb], L_shr( 3277 /*0.1 Q15*/, hPrivateData->sfb_tb_e[sfb] ) ) ) /* check whether target SFB is more tonal than source SFB */ { Word16 currDampingFactor, dampingFactor; Word16 slope, threshold; @@ -718,8 +718,13 @@ 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(); @@ -730,18 +735,26 @@ static void IGF_CalculateEnvelope_ivas_fx( move16(); move16(); - test(); FOR( sb = swb_offset[sfb]; sb < swb_offset[sfb + 1]; sb++ ) { mean_x_fx = add( mean_x_fx, x ); /*Q0*/ mean_x2_fx = L_add( mean_x2_fx, L_mult0( x, x ) ); /*Q0*/ - test(); +#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*/ @@ -864,8 +877,7 @@ static void IGF_CalculateEnvelope_ivas_fx( move16(); hPrivateData->prevDampingFactor_IIR_e[sfb] = dampingFactor_e; move16(); - test(); - IF( hPrivateData->dampingFactorSmoothing[sfb] > 0 ) + if ( hPrivateData->dampingFactorSmoothing[sfb] > 0 ) { hPrivateData->dampingFactorSmoothing[sfb] = sub( hPrivateData->dampingFactorSmoothing[sfb], 1 ); move16(); @@ -928,6 +940,7 @@ static void IGF_CalculateEnvelope_ivas_fx( ELSE { tmp_e = e_mdct; + move16(); sfbEnergyR = add_sat( EPSILON_FX, BASOP_Util_Divide3216_Scale( sum2_32_fx( pMDCTSpectrum_fx + swb_offset[sfb], width, &tmp_e ) /*exp: tmp_e*/, width, &sfbEnergyR_e ) ); // sfbEnergyR_e sfbEnergyR_e = add( sfbEnergyR_e, add( tmp_e, -15 ) ); gain = sfbEnergyR; // gain_e @@ -1056,7 +1069,7 @@ static void IGF_CalculateStereoEnvelope_fx( swb_offset = hGrid->swb_offset; move16(); - IF( NE_16( igfGridIdx, IGF_GRID_LB_NORM ) ) + IF( igfGridIdx != IGF_GRID_LB_NORM ) { FOR( sfbCnt = 0; sfbCnt < sub( hGrid->sfbWrap[hGrid->nTiles], hGrid->sfbWrap[0] ); sfbCnt++ ) { @@ -1084,7 +1097,7 @@ static void IGF_CalculateStereoEnvelope_fx( { FOR( sb = hGrid->sbWrap[0]; sb < swb_offset[hGrid->sfbWrap[hGrid->nTiles]]; sb++ ) { - /*hPrivateData->logSpec[sb] = max( 0, (int16_t) ( logf( max( FLT_MIN, pPowerSpectrum[sb] ) ) * INV_LOG_2 ) );*/ + /*hPrivateData->logSpec[sb] = max( 0, (Word16) ( logf( max( FLT_MIN, pPowerSpectrum[sb] ) ) * INV_LOG_2 ) );*/ IF( LE_32( 1, pPowerSpectrum_fx[sb] ) ) { hPrivateData->logSpec[sb] = s_max( 0, (Word16) L_shr( L_add( BASOP_Util_Log2( pPowerSpectrum_fx[sb] ), L_shl( pPowerSpectrum_e, Q25 ) ), 25 ) ); @@ -1150,6 +1163,7 @@ static void IGF_CalculateStereoEnvelope_fx( tileSrcSpec_e = pPowerSpectrum_e; } move32(); + move16(); strt_cpy = add( strt_cpy, 1 ); } @@ -1221,10 +1235,10 @@ static void IGF_CalculateStereoEnvelope_fx( { hPrivateData->prevSFM_FIR_SFB_TB_fx[sfb] = shr( hPrivateData->prevSFM_FIR_SFB_TB_fx[sfb], diff_tb_e ); hPrivateData->prevSFM_IIR_SFB_TB_fx[sfb] = shr( hPrivateData->prevSFM_IIR_SFB_TB_fx[sfb], diff_tb_e ); - hPrivateData->prevSFB_FIR_TB_e[sfb] = tmp_tb_e; - hPrivateData->prevSFB_IIR_TB_e[sfb] = tmp_tb_e; move16(); move16(); + hPrivateData->prevSFB_FIR_TB_e[sfb] = tmp_tb_e; + hPrivateData->prevSFB_IIR_TB_e[sfb] = tmp_tb_e; move16(); move16(); } @@ -1238,35 +1252,42 @@ static void IGF_CalculateStereoEnvelope_fx( { hPrivateData->prevSFM_FIR_SFB_SB_fx[sfb] = shr( hPrivateData->prevSFM_FIR_SFB_SB_fx[sfb], diff_sb_e ); hPrivateData->prevSFM_IIR_SFB_SB_fx[sfb] = shr( hPrivateData->prevSFM_IIR_SFB_SB_fx[sfb], diff_sb_e ); - hPrivateData->prevSFB_FIR_SB_e[sfb] = tmp_sb_e; - hPrivateData->prevSFB_IIR_SB_e[sfb] = tmp_sb_e; move16(); move16(); + hPrivateData->prevSFB_FIR_SB_e[sfb] = tmp_sb_e; + hPrivateData->prevSFB_IIR_SB_e[sfb] = tmp_sb_e; move16(); move16(); } } - 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 */ - +#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]*/ - hPrivateData->sfb_sb_e[sfb] = 2; - hPrivateData->sfb_tb_e[sfb] = 2; - move16(); - move16(); +#endif move16(); move16(); move16(); move16(); + hPrivateData->sfb_sb_e[sfb] = 2; + hPrivateData->sfb_tb_e[sfb] = 2; move16(); move16(); - BASOP_Util_Add_MantExp( hPrivateData->SFM_sb_fx[sfb], tmp_sb_e, negate( hPrivateData->SFM_tb_fx[sfb] ), tmp_tb_e, &diffSFM_fx ); /*stores the resultant exponent for diffSFM_fx*/ + diffSFM_fx = sub( hPrivateData->SFM_sb_fx[sfb], hPrivateData->SFM_tb_fx[sfb] ); /*Q13*/ - IF( diffSFM_fx > 0 && LT_32( hPrivateData->SFM_tb_fx[sfb], L_shr( 3277 /*0.1 Q15*/, tmp_tb_e ) ) ) /* check whether target SFB is more tonal than source SFB */ + test(); + IF( diffSFM_fx > 0 && LT_16( hPrivateData->SFM_tb_fx[sfb], 819 /*0.1 Q13*/ ) ) /* check whether target SFB is more tonal than source SFB */ { Word16 currDampingFactor_fx, dampingFactor_fx, alpha_fx; Word16 threshold_e, threshold_fx, alpha_e, currDampingFactor_e, dampingFactor_e; @@ -1290,10 +1311,11 @@ static void IGF_CalculateStereoEnvelope_fx( mean_x_fx = add( mean_x_fx, x ); /*Q0*/ mean_x2_fx = L_add( mean_x2_fx, L_mult0( x, x ) ); /*Q0*/ - /*y = 20 * (int16_t) log10f( max( 1e-018f, pPowerSpectrum[sb] ) );*/ + /*y = 20 * (Word16) log10f( max( 1e-018f, pPowerSpectrum[sb] ) );*/ IF( LT_32( pPowerSpectrum_fx[sb], 1 ) ) { y = 20 * ( -18 ); + move16(); } ELSE { @@ -1320,7 +1342,7 @@ static void IGF_CalculateStereoEnvelope_fx( /* determine whether strong tilt is due to a step in the spectrum (e.g. band limitation, no damping) or a tonal component close the band border (apply damping) by calculating SFM for a shift of 1/2 SFB width*/ threshold_fx = BASOP_Util_Divide1616_Scale( 60, width, &threshold_e ); /*stores resultant exponent for threshold_fx*/ - + test(); IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( slope_fx, add( slope_e, 16 ), negate( threshold_fx ), add( threshold_e, 16 ) ), -1 ) ) { Word16 shift = shr( width, 1 ); @@ -1338,7 +1360,10 @@ static void IGF_CalculateStereoEnvelope_fx( crest = IGF_getCrest( &crest_exp, pPowerSpectrum_fx, pPowerSpectrum_e, add( swb_offset[sfb], shift ), add( swb_offset[sfb + 1], shift ) ); shiftedSFM_fx = BASOP_Util_Divide1616_Scale( sfm, crest, &shiftedSFM_e ); } - shiftedSFM_e = add( shiftedSFM_e, sub( sfm_exp, crest_exp ) ); /* stores resultant exponent for shiftedSFM_fx*/ + IF( shiftedSFM_fx ) + { + shiftedSFM_e = add( shiftedSFM_e, sub( sfm_exp, crest_exp ) ); /* stores resultant exponent for shiftedSFM_fx*/ + } // alpha = min( 320.f / (float) swb_offset[sfb + 1], 1.25f ); temp = BASOP_Util_Divide1616_Scale( 320, swb_offset[sfb + 1], &alpha_e ); @@ -1356,7 +1381,8 @@ static void IGF_CalculateStereoEnvelope_fx( move16(); move16(); } - + test(); + test(); IF( last_core_acelp || hPrivateData->wasTransient || EQ_32( hPrivateData->prevDampingFactor_IIR_fx[sfb], L_shl( -1, sub( 15, hPrivateData->prevDampingFactor_IIR_e[sfb] ) ) ) ) { tmp = BASOP_Util_Cmp_Mant32Exp( currDampingFactor_fx, currDampingFactor_e, 3277, 0 ); @@ -1388,7 +1414,7 @@ static void IGF_CalculateStereoEnvelope_fx( { // currDampingFactor += 0.1f * ( ( 10 + adap ) - tonalToNoise ); Word32 temp2 = BASOP_Util_Add_Mant32Exp( L_add( L_shl( 10, sub( 15, adap_e ) ) /*exp:adap_e*/, adap ), add( adap_e, 16 ), L_negate( tonalToNoise ), tonalToNoise_e, &tmp_e ); /* resultant exp is tmp_e*/ - currDampingFactor_e = BASOP_Util_Add_MantExp( currDampingFactor_fx, currDampingFactor_e, extract_l( Mult_32_32( 3277 /*0.1f Q15*/, temp2 ) ), tmp_e, &currDampingFactor_fx ); /*stores resultant exp for currDampingFactor_fx*/ + currDampingFactor_e = BASOP_Util_Add_MantExp( currDampingFactor_fx, currDampingFactor_e, extract_l( Mult_32_16( temp2, 3277 /*0.1f Q15*/ ) ), tmp_e, &currDampingFactor_fx ); /*stores resultant exp for currDampingFactor_fx*/ } } @@ -1500,11 +1526,15 @@ static void IGF_CalculateStereoEnvelope_fx( } /*gain=0.5f+log2f(gain)*2+16 becuase 2.885390081777927f=2*1/loge(2) so 2*1/loge(2)*loge(x) can be written as 2*log2(x)*/ gain_fx = L_add( ONE_IN_Q22, L_add( L_add( L_shr( BASOP_Util_Log2( gain_fx ), 1 ), L_shl( gain_e, Q24 ) ), L_shl( 16, Q23 ) ) ); /*Q23*/ - IF( !isTransient && ( EQ_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_SWB_48000_CPE ) || EQ_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_FB_48000_CPE ) ) ) + test(); + test(); + if ( !isTransient && ( EQ_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_SWB_48000_CPE ) || EQ_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_FB_48000_CPE ) ) ) { gain_fx = L_add( gain_fx, ONE_IN_Q21 ); /* better preservation of original HF band energy */ } - IF( !isTransient && ( EQ_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_SWB_64000_CPE ) || EQ_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_FB_64000_CPE ) ) ) + test(); + test(); + if ( !isTransient && ( EQ_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_SWB_64000_CPE ) || EQ_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_FB_64000_CPE ) ) ) { gain_fx = L_add( gain_fx, ONE_IN_Q20 ); } @@ -1563,33 +1593,33 @@ static Word16 IGF_WriteEnvelope( IF( *igfAllZero != 0 ) { - IGF_write_bit( hBstr, pBitOffset, 1 ); + IGF_write_bit_fx( hBstr, pBitOffset, 1 ); - IF( NULL == hBstr ) + if ( NULL == hBstr ) { IGFSCFEncoderSaveContextState_fx( &hPrivateData->hIGFSCFArithEnc, igfGridIdx ); } IGFSCFEncoderReset_fx( &hPrivateData->hIGFSCFArithEnc ); - IF( NULL == hBstr ) + if ( NULL == hBstr ) { IGFSCFEncoderRestoreContextState_fx( &hPrivateData->hIGFSCFArithEnc, igfGridIdx ); } } ELSE { - IGF_write_bit( hBstr, pBitOffset, 0 ); + IGF_write_bit_fx( hBstr, pBitOffset, 0 ); - IF( NULL == hBstr ) + if ( NULL == hBstr ) { IGFSCFEncoderSaveContextState_fx( &hPrivateData->hIGFSCFArithEnc, igfGridIdx ); } - *pBitOffset = IGFSCFEncoderEncode( &hPrivateData->hIGFSCFArithEnc, hBstr, *pBitOffset, &hPrivateData->igfScfQuantized[hGrid->startSfb], igfGridIdx, isIndepFlag ); + *pBitOffset = IGFSCFEncoderEncode_ivas_fx( &hPrivateData->hIGFSCFArithEnc, hBstr, *pBitOffset, &hPrivateData->igfScfQuantized[hGrid->startSfb], igfGridIdx, isIndepFlag ); move16(); - IF( NULL == hBstr ) + if ( NULL == hBstr ) { IGFSCFEncoderRestoreContextState_fx( &hPrivateData->hIGFSCFArithEnc, igfGridIdx ); } @@ -1685,7 +1715,7 @@ static void IGF_Whitening_ivas_fx( /* if current tile contains only a single SFB, reuse already computed SFM values */ test(); - IF( GT_16( element_mode, EVS_MONO ) && EQ_16( sub( hGrid->sfbWrap[p + 1], hGrid->sfbWrap[p] ), 1 ) ) + IF( element_mode > EVS_MONO && EQ_16( sub( hGrid->sfbWrap[p + 1], hGrid->sfbWrap[p] ), 1 ) ) { tmp = hPrivateData->SFM_tb_fx[p]; tmp_e = hPrivateData->sfb_tb_e[p]; @@ -1818,7 +1848,7 @@ static void IGF_Whitening_ivas_fx( ELSE { test(); - IF( GT_16( element_mode, EVS_MONO ) && EQ_16( sub( hGrid->sfbWrap[p + 1], hGrid->sfbWrap[p] ), 1 ) ) + IF( element_mode > EVS_MONO && EQ_16( sub( hGrid->sfbWrap[p + 1], hGrid->sfbWrap[p] ), 1 ) ) { SFM = shl( tmp, sub( tmp_e, 2 ) ); /*2Q13*/ } @@ -1850,7 +1880,7 @@ static void IGF_Whitening_ivas_fx( } } - IF( GT_16( element_mode, EVS_MONO ) ) + IF( element_mode > EVS_MONO ) { IF( last_core_acelp ) /* reset */ { @@ -1957,7 +1987,7 @@ static void IGF_Whitening_ivas_fx( } } - IF( GT_16( element_mode, EVS_MONO ) ) + IF( element_mode > EVS_MONO ) { IF( EQ_16( SFM, -ONE_IN_Q13 /*1.0f 2Q13*/ ) ) /* reset */ { @@ -2004,7 +2034,10 @@ static void IGF_Whitening_ivas_fx( break; } } - + test(); + test(); + test(); + test(); /* if tonality oscillates between two tiles, turn whitening off in both */ IF( ( ( pastSfmDiffSum_a > 0 && pastSfmDiffSum_b < 0 ) || ( pastSfmDiffSum_a < 0 && pastSfmDiffSum_b > 0 ) ) && @@ -2053,16 +2086,16 @@ static void IGF_Whitening_ivas_fx( /*-------------------------------------------------------------------* - * IGF_WriteWhiteningTile() + * IGF_WriteWhiteningTile_fx() * * write whitening levels into bitstream *-------------------------------------------------------------------*/ /*! r: number of bits written */ -static Word16 IGF_WriteWhiteningTile( /**< out: Q0 | number of bits written */ - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - Word16 *pBitOffset, /**< in: | ptr to bitOffset counter */ - Word16 whiteningLevel /**< in: Q0 | whitening levels to write */ +static Word16 IGF_WriteWhiteningTile_fx( /**< out: Q0 | number of bits written */ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + Word16 *pBitOffset, /**< in: | ptr to bitOffset counter */ + Word16 whiteningLevel /**< in: Q0 | whitening levels to write */ ) { Word16 totBitCount; @@ -2096,17 +2129,17 @@ static Word16 IGF_WriteWhiteningTile( /**< out: Q0 | numb /*-------------------------------------------------------------------* - * IGF_WriteWhiteningLevels() + * IGF_WriteWhiteningLevels_fx() * * writes the whitening levels *-------------------------------------------------------------------*/ -static Word16 IGF_WriteWhiteningLevels( /**< out: Q0 | total number of bits written */ - const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF encoder */ - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - Word16 *pBitOffset, /**< in: | ptr to bitOffset counter */ - const Word16 igfGridIdx, /**< in: Q0 | igf grid index see declaration of IGF_GRID_IDX for details */ - const Word16 isIndepFlag /**< in: Q0 | if 1 frame is independent, 0 = frame is coded with data from previous frame */ +static Word16 IGF_WriteWhiteningLevels_fx( /**< out: Q0 | total number of bits written */ + const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF encoder */ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + Word16 *pBitOffset, /**< in: | ptr to bitOffset counter */ + const Word16 igfGridIdx, /**< in: Q0 | igf grid index see declaration of IGF_GRID_IDX for details */ + const Word16 isIndepFlag /**< in: Q0 | if 1 frame is independent, 0 = frame is coded with data from previous frame */ ) { IGF_ENC_PRIVATE_DATA_HANDLE hPrivateData; @@ -2140,7 +2173,7 @@ static Word16 IGF_WriteWhiteningLevels( move16(); tmp32 = 0; move32(); - + test(); WHILE( ( LT_16( p, nTiles ) ) && ( tmp32 == 0 ) ) { test(); @@ -2163,11 +2196,12 @@ static Word16 IGF_WriteWhiteningLevels( { IGF_write_bits( hBstr, pBitOffset, 0, 1 ); } - IGF_WriteWhiteningTile( hBstr, pBitOffset, hPrivateData->igfCurrWhiteningLevel[0] ); + IGF_WriteWhiteningTile_fx( hBstr, pBitOffset, hPrivateData->igfCurrWhiteningLevel[0] ); p = 1; move16(); tmp32 = 0; move32(); + test(); IF( EQ_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_SWB_48000_CPE ) || EQ_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_FB_48000_CPE ) ) { isSame = 1; @@ -2180,7 +2214,7 @@ static Word16 IGF_WriteWhiteningLevels( isSame = 1; move16(); } - + test(); WHILE( ( LT_16( p, nTiles ) ) && ( tmp32 == 0 ) ) { test(); @@ -2199,7 +2233,7 @@ static Word16 IGF_WriteWhiteningLevels( IGF_write_bits( hBstr, pBitOffset, 1, 1 ); FOR( p = 1; p < nTiles; p++ ) { - IGF_WriteWhiteningTile( hBstr, pBitOffset, hPrivateData->igfCurrWhiteningLevel[p] ); + IGF_WriteWhiteningTile_fx( hBstr, pBitOffset, hPrivateData->igfCurrWhiteningLevel[p] ); } } ELSE IF( NE_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_SWB_48000_CPE ) && NE_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_FB_48000_CPE ) ) @@ -2215,16 +2249,16 @@ static Word16 IGF_WriteWhiteningLevels( /*-------------------------------------------------------------------* - * IGF_WriteFlatteningTrigger() + * IGF_WriteFlatteningTrigger_fx() * * write flattening trigger *-------------------------------------------------------------------*/ /*! r: number of bits written */ -static Word16 IGF_WriteFlatteningTrigger( /**< out: | number of bits written */ - const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Encoder */ - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - Word16 *pBitOffset /**< in: | ptr to bitOffset counter */ +static Word16 IGF_WriteFlatteningTrigger_fx( /**< out: | number of bits written */ + const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Encoder */ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + Word16 *pBitOffset /**< in: | ptr to bitOffset counter */ ) { Word16 flatteningTrigger; @@ -2287,15 +2321,15 @@ Word16 IGFEncWriteBitstream_ivas_fx( isIndepFlag, /* i: if 1 frame is independent, 0 = frame is coded with data from previous frame */ &igfAllZero ); /* o: *igfAllZero */ - IGF_WriteWhiteningLevels( hIGFEnc, /* i: instance handle of IGF Encoder */ - hBstr, /* i: encoder state */ - pBitOffset, /* i: ptr to bitOffset counter */ - igfGridIdx, /* i: igf grid index see definition of IGF_GRID_IDX for details */ - isIndepFlag ); /* i: if 1 frame is independent, 0 = frame is coded with data from previous frame */ + IGF_WriteWhiteningLevels_fx( hIGFEnc, /* i: instance handle of IGF Encoder */ + hBstr, /* i: encoder state */ + pBitOffset, /* i: ptr to bitOffset counter */ + igfGridIdx, /* i: igf grid index see definition of IGF_GRID_IDX for details */ + isIndepFlag ); /* i: if 1 frame is independent, 0 = frame is coded with data from previous frame */ - IGF_WriteFlatteningTrigger( hIGFEnc, /* i: instance handle of IGF Encoder */ - hBstr, /* i: encoder state */ - pBitOffset ); /* i: ptr to bitOffset counter */ + IGF_WriteFlatteningTrigger_fx( hIGFEnc, /* i: instance handle of IGF Encoder */ + hBstr, /* i: encoder state */ + pBitOffset ); /* i: ptr to bitOffset counter */ hIGFEnc->infoTotalBitsPerFrameWritten = sub( *pBitOffset, startBitCount ); hIGFEnc->infoTotalBitsWritten = add( hIGFEnc->infoTotalBitsWritten, hIGFEnc->infoTotalBitsPerFrameWritten ); @@ -2304,34 +2338,6 @@ Word16 IGFEncWriteBitstream_ivas_fx( return hIGFEnc->infoTotalBitsPerFrameWritten; } -int16_t IGFEncWriteBitstream( - const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : instance handle of IGF Encoder */ - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - int16_t *pBitOffset, /* i : ptr to bitOffset counter */ - const int16_t igfGridIdx, /* i : igf grid index see declaration of IGF_GRID_IDX for details */ - const int16_t isIndepFlag /* i : if 1 frame is independent, 0 = frame is coded with data from previous frame */ -) -{ - int16_t igfAllZero; - int16_t startBitCount = *pBitOffset; - - hIGFEnc->infoTotalBitsPerFrameWritten = 0; - if ( isIndepFlag ) - { - hIGFEnc->infoTotalBitsWritten = 0; - } - - IGF_WriteEnvelope( hIGFEnc, hBstr, pBitOffset, igfGridIdx, isIndepFlag, &igfAllZero ); - - IGF_WriteWhiteningLevels( hIGFEnc, hBstr, pBitOffset, igfGridIdx, isIndepFlag ); - - IGF_WriteFlatteningTrigger( hIGFEnc, hBstr, pBitOffset ); - - hIGFEnc->infoTotalBitsPerFrameWritten = ( *pBitOffset - startBitCount ); - hIGFEnc->infoTotalBitsWritten += hIGFEnc->infoTotalBitsPerFrameWritten; - - return hIGFEnc->infoTotalBitsPerFrameWritten; -} /*-------------------------------------------------------------------* @@ -2509,12 +2515,12 @@ return; /*-------------------------------------------------------------------* - * IGFEncResetTCX10BitCounter() + * IGFEncResetTCX10BitCounter_ivas_fx() * * IGF reset bitstream bit counter for TCX10 modes *-------------------------------------------------------------------*/ -void IGFEncResetTCX10BitCounter( +void IGFEncResetTCX10BitCounter_ivas_fx( const IGF_ENC_INSTANCE_HANDLE hIGFEnc /* i : instance handle of IGF Encoder */ ) { @@ -2523,7 +2529,8 @@ void IGFEncResetTCX10BitCounter( hPrivateData = &hIGFEnc->igfData; hPrivateData->igfBitstreamBits = 0; hIGFEnc->infoTotalBitsWritten = 0; - + move16(); + move16(); return; } @@ -2535,14 +2542,14 @@ void IGFEncResetTCX10BitCounter( *-------------------------------------------------------------------*/ /*! r: total number of bits written */ -int16_t IGFEncWriteConcatenatedBitstream( +Word16 IGFEncWriteConcatenatedBitstream( const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : instance handle of IGF Encoder */ BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ ) { IGF_ENC_PRIVATE_DATA_HANDLE hPrivateData; - int16_t i; - int16_t bitsLeft; + Word16 i; + Word16 bitsLeft; UWord8 *pBitstream; hPrivateData = &hIGFEnc->igfData; @@ -2556,7 +2563,7 @@ int16_t IGFEncWriteConcatenatedBitstream( bitsLeft = hPrivateData->igfBitstreamBits & 0x7; if ( bitsLeft > 0 ) { - push_next_indice( hBstr, pBitstream[i] >> ( 8 - bitsLeft ), bitsLeft ); + push_next_indice( hBstr, shr( pBitstream[i], sub( 8, bitsLeft ) ), bitsLeft ); } return hIGFEnc->infoTotalBitsWritten; @@ -2586,13 +2593,16 @@ void IGFEncApplyMono_ivas_fx( Word16 *pPowerSpectrumParameter_exp; Word16 att_fx = MAX16B; Word16 last_core_acelp; - Word16 highPassEner_exp; move16(); 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(); - test(); IF( st->last_core == ACELP_CORE ) { last_core_acelp = 1; @@ -2626,7 +2636,6 @@ void IGFEncApplyMono_ivas_fx( IGF_CalculateEnvelope_ivas_fx( st->hIGFEnc, pMDCTSpectrum_fx, e_mdct, pPowerSpectrumParameter_fx, pPowerSpectrumParameter_exp, igfGridIdx, st->hTranDet->transientDetector.bIsAttackPresent, last_core_acelp, st->element_mode, att_fx ); - test(); IF( isTCX20 ) { pPowerSpectrumParameter_fx = pPowerSpectrum_fx; @@ -2660,7 +2669,7 @@ void IGFEncApplyMono_ivas_fx( move16(); } } - IGF_ErodeSpectrum( &highPassEner_exp, st->hIGFEnc, pMDCTSpectrum_fx, pPowerSpectrumParameter_fx, common_pPowerSpectrum_exp, igfGridIdx ); + IGF_ErodeSpectrum_ivas_fx( st->hIGFEnc, pMDCTSpectrum_fx, pPowerSpectrumParameter_fx, common_pPowerSpectrum_exp, igfGridIdx, 0 ); } @@ -2681,10 +2690,9 @@ void IGFEncApplyStereo_fx( Word32 *inv_spectrum_fx[CPE_CHANNELS][NB_DIV], /* i : 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 */ -) + const Word32 element_brate, /* i : element bitrate */ + const Word16 mct_on ) { - Word16 highPassEner_exp; Word32 *pPowerSpectrumParameter_fx[NB_DIV]; /* If it is NULL it informs a function that specific handling is needed */ Word32 *pPowerSpectrumParameterMsInv_fx[NB_DIV]; Word16 coreMsMask[N_MAX]; @@ -2710,7 +2718,7 @@ void IGFEncApplyStereo_fx( { sfbConf = &hStereoMdct->stbParamsTCX10; } - if ( EQ_16( sts[0]->last_core, ACELP_CORE ) ) + if ( sts[0]->last_core == ACELP_CORE ) { sfbConf = &hStereoMdct->stbParamsTCX20afterACELP; } @@ -2758,7 +2766,7 @@ void IGFEncApplyStereo_fx( 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( &highPassEner_exp, hIGFEnc[ch], sts[ch]->hTcxEnc->spectrum_fx[frameno], pPowerSpectrumParameter_fx[ch], sts[ch]->hTcxEnc->spectrum_e[frameno], igfGridIdx ); + IGF_ErodeSpectrum_ivas_fx( hIGFEnc[ch], sts[ch]->hTcxEnc->spectrum_fx[frameno], pPowerSpectrumParameter_fx[ch], sts[ch]->hTcxEnc->spectrum_e[frameno], igfGridIdx, mct_on ); } return; } diff --git a/lib_enc/igf_enc_fx.c b/lib_enc/igf_enc_fx.c index f0d83e41638f29ab714154ca905d259a68a90acf..ca1759c89aa6215136f84a024d11028930f4fd0e 100644 --- a/lib_enc/igf_enc_fx.c +++ b/lib_enc/igf_enc_fx.c @@ -17,7 +17,7 @@ /**********************************************************************/ /* write single bit to stream **************************************************************************/ -static void IGF_write_bit( +static void IGF_write_bit_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ Word16 *bitCount, /**< in/out: | bit counter */ Word16 bit /**< in: | value of bit */ @@ -44,11 +44,11 @@ static void IGF_write_bits( tmp = s_and( value, shl( 1, bits ) ); IF( tmp == 0 ) { - IGF_write_bit( hBstr, bitCount, 0 ); + IGF_write_bit_fx( hBstr, bitCount, 0 ); } ELSE { - IGF_write_bit( hBstr, bitCount, 1 ); + IGF_write_bit_fx( hBstr, bitCount, 1 ); } } @@ -96,6 +96,7 @@ static void IGF_CalculateEnvelope( const IGF_ENC_INSTANCE_HANDLE hInstance, /**< Word16 shift; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif /* initialize variables */ @@ -218,23 +219,8 @@ static void IGF_CalculateEnvelope( const IGF_ENC_INSTANCE_HANDLE hInstance, /**< move16(); } -#ifdef BASOP_NOGLOB BASOP_Util_Divide_MantExp( round_fx_o( sfbEnergyTileR[sfb], &Overflow ), sfbEnergyTileR_exp[sfb], width, 15, &gain, &gain_exp ); BASOP_Util_Divide_MantExp( round_fx_o( sfbEnergyC[sfb], &Overflow ), sfbEnergyC_exp[sfb], round_fx_o( sfbEnergyTileC[sfb], &Overflow ), sfbEnergyTileC_exp[sfb], &tmp, &tmp_exp ); -#else - BASOP_Util_Divide_MantExp( round_fx( sfbEnergyTileR[sfb] ), - sfbEnergyTileR_exp[sfb], - width, - 15, - &gain, - &gain_exp ); - BASOP_Util_Divide_MantExp( round_fx( sfbEnergyC[sfb] ), - sfbEnergyC_exp[sfb], - round_fx( sfbEnergyTileC[sfb] ), - sfbEnergyTileC_exp[sfb], - &tmp, - &tmp_exp ); -#endif L_tmp = L_mult( gain, tmp ); gain_exp = add( gain_exp, tmp_exp ); } @@ -249,21 +235,12 @@ static void IGF_CalculateEnvelope( const IGF_ENC_INSTANCE_HANDLE hInstance, /**< zeroNrg = 1; move16(); } -#ifdef BASOP_NOGLOB BASOP_Util_Divide_MantExp( round_fx_sat( sfbEnergyR[sfb] ), sfbEnergyR_exp[sfb], width, 15, &gain, &gain_exp ); -#else - BASOP_Util_Divide_MantExp( round_fx( sfbEnergyR[sfb] ), - sfbEnergyR_exp[sfb], - width, - 15, - &gain, - &gain_exp ); -#endif L_tmp = L_deposit_h( gain ); } @@ -271,11 +248,7 @@ static void IGF_CalculateEnvelope( const IGF_ENC_INSTANCE_HANDLE hInstance, /**< L_tmp = BASOP_Util_Log2( L_tmp ); L_tmp = L_add( L_tmp, L_deposit_h( shl( gain_exp, 15 - 6 ) ) ); shift = norm_l( L_tmp ); -#ifdef BASOP_NOGLOB gain = round_fx_o( L_shl_o( L_tmp, shift, &Overflow ), &Overflow ); -#else - gain = round_fx( L_shl( L_tmp, shift ) ); -#endif gain_exp = sub( 7, shift ); gain_exp = BASOP_Util_Add_MantExp( gain, gain_exp, 32767 /*16 Q11*/, 4, &gain ); gain_exp = BASOP_Util_Add_MantExp( gain, gain_exp, 0x4000, 0, &gain ); @@ -338,21 +311,21 @@ static void IGF_WriteEnvelope( /**< ou IF( *igfAllZero != 0 ) { - IGF_write_bit( hBstr, pBitOffset, 1 ); - IF( NULL == hBstr ) + IGF_write_bit_fx( hBstr, pBitOffset, 1 ); + if ( NULL == hBstr ) { IGFSCFEncoderSaveContextState_fx( &hPrivateData->hIGFSCFArithEnc, igfGridIdx ); } IGFSCFEncoderReset_fx( &hPrivateData->hIGFSCFArithEnc ); - IF( NULL == hBstr ) + if ( NULL == hBstr ) { IGFSCFEncoderRestoreContextState_fx( &hPrivateData->hIGFSCFArithEnc, igfGridIdx ); } } ELSE { - IGF_write_bit( hBstr, pBitOffset, 0 ); - IF( NULL == hBstr ) + IGF_write_bit_fx( hBstr, pBitOffset, 0 ); + if ( NULL == hBstr ) { IGFSCFEncoderSaveContextState_fx( &hPrivateData->hIGFSCFArithEnc, igfGridIdx ); } @@ -360,7 +333,7 @@ static void IGF_WriteEnvelope( /**< ou *pBitOffset = IGFSCFEncoderEncode_fx( &hPrivateData->hIGFSCFArithEnc, hBstr, *pBitOffset, &hPrivateData->igfScfQuantized[hGrid->startSfb], igfGridIdx, isIndepFlag ); move16(); - IF( NULL == hBstr ) + if ( NULL == hBstr ) { IGFSCFEncoderRestoreContextState_fx( &hPrivateData->hIGFSCFArithEnc, igfGridIdx ); } @@ -403,6 +376,8 @@ void IGF_ErodeSpectrum( Word16 *highPassEner_exp, /**< ou #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; Flag Carry = 0; + move32(); + move32(); #endif hPrivateData = &hInstance->igfData; @@ -440,21 +415,16 @@ void IGF_ErodeSpectrum( Word16 *highPassEner_exp, /**< ou FOR( i = 0; i < igfBgn; i++ ) { Carry = 0; -#ifdef BASOP_NOGLOB + move32(); highPassEner = L_add_co( highPassEner, Mpy_32_16_1( pPowerSpectrum[i], shl( i, 4 ) /*Q4*/ ) /*Q20, pPowerSpectrum_exp*/, &Carry, &Overflow ); -#else /* BASOP_NOGLOB */ - highPassEner = L_add_c( highPassEner, Mpy_32_16_1( pPowerSpectrum[i], shl( i, 4 ) /*Q4*/ ) /*Q20, pPowerSpectrum_exp*/ ); -#endif /* BASOP_NOGLOB */ Overflow = 0; -#ifdef BASOP_NOGLOB + move32(); L_c = L_macNs_co( L_c, 0, 0, &Carry, &Overflow ); -#else /* BASOP_NOGLOB */ - L_c = L_macNs( L_c, 0, 0 ); -#endif /* BASOP_NOGLOB */ } highPassEner = norm_llQ31( L_c, highPassEner, highPassEner_exp ); /*Q20, highPassEner_exp*/ *highPassEner_exp = add( *highPassEner_exp, pPowerSpectrum_exp ); + move16(); test(); test(); if ( NE_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_SWB_9600 ) && @@ -473,15 +443,8 @@ void IGF_ErodeSpectrum( Word16 *highPassEner_exp, /**< ou /* May overflow - just for threshold comparison */ /* negate because the negated may be 1 larger in abs, */ /* so whenever compared to the negation of a maximum possible pPowerspectrum, it is still larger */ -#ifdef BASOP_NOGLOB highPassEner_Ovfl = L_shl_o( L_negate( highPassEner ), sub( *highPassEner_exp, pPowerSpectrum_exp ), &Overflow ); L_tmp = L_add_o( pPowerSpectrum[i - 1], highPassEner_Ovfl, &Overflow ); -#else - BASOP_SATURATE_WARNING_OFF_EVS - highPassEner_Ovfl = L_shl( L_negate( highPassEner ), sub( *highPassEner_exp, pPowerSpectrum_exp ) ); - L_tmp = L_add( pPowerSpectrum[i - 1], highPassEner_Ovfl ); - BASOP_SATURATE_WARNING_ON_EVS -#endif if ( L_tmp >= 0 ) { @@ -493,11 +456,7 @@ void IGF_ErodeSpectrum( Word16 *highPassEner_exp, /**< ou { /* May overflow - just for threshold comparison */ BASOP_SATURATE_WARNING_OFF_EVS -#ifdef BASOP_NOGLOB L_tmp = L_add_sat( pPowerSpectrum[i], highPassEner_Ovfl ); -#else - L_tmp = L_add( pPowerSpectrum[i], highPassEner_Ovfl ); -#endif BASOP_SATURATE_WARNING_ON_EVS; IF( L_tmp < 0 ) @@ -522,15 +481,12 @@ void IGF_ErodeSpectrum( Word16 *highPassEner_exp, /**< ou /* May overflow - just for threshold comparison */ BASOP_SATURATE_WARNING_OFF_EVS -#ifdef BASOP_NOGLOB L_tmp = L_add_sat( pPowerSpectrum[i], highPassEner_Ovfl ); -#else - L_tmp = L_add( pPowerSpectrum[i], highPassEner_Ovfl ); -#endif BASOP_SATURATE_WARNING_ON_EVS - IF( L_tmp < 0 ) + if ( L_tmp < 0 ) { pSpectrum[i] = L_deposit_l( 0 ); + move32(); } } @@ -538,7 +494,9 @@ void IGF_ErodeSpectrum( Word16 *highPassEner_exp, /**< ou FOR( i = igfEnd; i < hGrid->infoGranuleLen; i++ ) { pSpectrum[i] = L_deposit_l( 0 ); + move32(); pPowerSpectrum[i] = L_deposit_l( 0 ); + move32(); } FOR( sfb = startSfb; sfb < stopSfb; sfb++ ) @@ -567,6 +525,179 @@ void IGF_ErodeSpectrum( Word16 *highPassEner_exp, /**< ou } } +void IGF_ErodeSpectrum_ivas_fx( const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Encoder */ + Word32 *pSpectrum, /**< in/out: | MDCT spectrum Qx*/ + Word32 *pPowerSpectrum, /**< in/out: | power spectrum */ + Word16 pPowerSpectrum_exp, /**< in: | exponent of power spectrum */ + const Word16 igfGridIdx, /**< in: Q0 | IGF grid index */ + const Word16 mct_on ) +{ + IGF_ENC_PRIVATE_DATA_HANDLE hPrivateData; + H_IGF_GRID hGrid; + Word16 i; + Word16 igfBgn; + Word16 igfEnd; + Word32 highPassEner; /* Q31 */ + Word32 lastLine; + Word32 nextLine; + Word16 *swb_offset; + Word16 sfb; + Word16 startSfb; + Word16 stopSfb; + Word16 line; + Word16 *igfScaleF; + Word16 tmp; + Word16 factor; + Word16 exp1, exp2; + Word16 num, den; + Word32 temp; + + hPrivateData = &hInstance->igfData; + hGrid = &hPrivateData->igfInfo.grid[igfGridIdx]; + igfBgn = hGrid->startLine; + move16(); + igfEnd = hGrid->stopLine; + move16(); + swb_offset = hGrid->swb_offset; + move16(); + startSfb = hGrid->startSfb; + move16(); + stopSfb = hGrid->stopSfb; + move16(); + igfScaleF = hPrivateData->igfScfQuantized; + move16(); + + IF( NULL == pPowerSpectrum ) + { + FOR( i = igfBgn; i < hGrid->infoGranuleLen; i++ ) + { + pSpectrum[i] = 0; + move32(); + } + return; + } + + IF( igfBgn > 0 ) + { + Word64 sum = 0; + move64(); + FOR( i = 0; i < igfBgn; i++ ) + { + sum = W_mac_32_16( sum, pPowerSpectrum[i], i ); // Q: 31-pPowerSpectrum_exp+1 + } + exp1 = W_norm( sum ); + sum = W_shl( sum, sub( exp1, 1 ) ); // Q: 31-pPowerSpectrum_exp+1+exp1-1 + num = extract_h( W_extract_h( sum ) ); // Q: 31-pPowerSpectrum_exp+exp1-48 = -pPowerSpectrum_exp+exp1-17 + exp1 = add( 32, sub( pPowerSpectrum_exp, exp1 ) ); // exp: 32+pPowerSpectrum_exp-exp1 + + IF( EQ_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_SWB_9600 ) || + EQ_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_RF_SWB_13200 ) || + EQ_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_SWB_13200 ) || + EQ_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_SWB_16400_CPE ) ) + { + factor = ONE_IN_Q14; // Q14 + move16(); + } + ELSE IF( mct_on && ( EQ_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_SWB_48000_CPE ) || EQ_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_SWB_64000_CPE ) ) ) + { + factor = 11469; // 0.7f in Q14 + move16(); + } + ELSE + { + factor = 32767; // 2.f in Q14 + move16(); + } + + temp = L_mult( igfBgn, factor ); // exp: 16 + exp2 = norm_l( temp ); + den = extract_h( L_shl( temp, exp2 ) ); // exp: 16-exp2 + exp2 = sub( 16, exp2 ); + + highPassEner = L_deposit_h( div_s( num, den ) ); // exp: exp1-exp2 + + /* highPassEner is used only for comparison, saturation doesn't effect the outcome */ + highPassEner = L_shl_sat( highPassEner, sub( sub( exp1, exp2 ), pPowerSpectrum_exp ) ); // exp: pPowerSpectrum_exp + + lastLine = pSpectrum[i - 1]; // Qx + move32(); + nextLine = pSpectrum[i]; // Qx + move32(); + + if ( LT_32( pPowerSpectrum[i - 1], highPassEner ) ) + { + nextLine = 0; + move32(); + } + + FOR( /*i*/; i < igfEnd - 1; i++ ) + { + /* May overflow - just for threshold comparison */ + IF( LT_32( pPowerSpectrum[i], highPassEner ) ) + { + lastLine = pSpectrum[i]; // Qx + move32(); + pSpectrum[i] = nextLine; // Qx + move32(); + nextLine = 0; + move32(); + } + ELSE + { + pSpectrum[i - 1] = lastLine; // Qx + move32(); + lastLine = pSpectrum[i]; // Qx + move32(); + nextLine = pSpectrum[i + 1]; // Qx + move32(); + } + } + + /* May overflow - just for threshold comparison */ + if ( LT_32( pPowerSpectrum[i], highPassEner ) ) + { + pSpectrum[i] = 0; + move32(); + } + } + + /* delete spectrum above igfEnd: */ + FOR( i = igfEnd; i < hGrid->infoGranuleLen; i++ ) + { + pSpectrum[i] = 0; + pPowerSpectrum[i] = 0; + move32(); + move32(); + } + + // Below check is present at the beginning of the function and is not required here + /* IF( NULL != pPowerSpectrum ) */ + { + FOR( sfb = startSfb; sfb < stopSfb; sfb++ ) + { + tmp = 0; + move16(); + FOR( line = swb_offset[sfb]; line < swb_offset[sfb + 1]; line++ ) + { + if ( pSpectrum[line] != 0 ) + { + tmp = add( tmp, 1 ); + } + } + + Word16 igfScaleF_cnt = igfScaleF[sfb]; + move16(); + test(); + if ( tmp && igfScaleF[sfb] ) + { + igfScaleF_cnt = sub( igfScaleF[sfb], 1 ); + } + igfScaleF[sfb] = igfScaleF_cnt; + move16(); + } + } +} + /**********************************************************************/ /* crest factor calculation **************************************************************************/ @@ -630,16 +761,11 @@ Word16 IGF_getCrest( /**< ou tmp32 = L_shl( tmp32, i ); /*Q31, s-i+15*/ crest = extract_h( tmp32 ); *crest_exp = add( sub( s, i ), 15 ); - + move16(); /* limit crest factor to a lower bound of 1, may overflow */ BASOP_SATURATE_WARNING_OFF_EVS -#ifdef BASOP_NOGLOB tmp = shl_sat( -1, sub( 15, *crest_exp ) ); /* build negative threshold */ tmp = add_sat( crest, tmp ); -#else - tmp = shl( -1, sub( 15, *crest_exp ) ); /* build negative threshold */ - tmp = add( crest, tmp ); -#endif BASOP_SATURATE_WARNING_ON_EVS if ( tmp < 0 ) { @@ -679,6 +805,8 @@ Word16 IGF_getSFM( /**< out: Q15| SFM value #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; Flag Carry = 0; + move32(); + move32(); #endif L_c = 0; @@ -712,18 +840,11 @@ Word16 IGF_getSFM( /**< out: Q15| SFM value num = L_add( num, L_deposit_l( n ) ); /*Q0*/ Carry = 0; -#ifdef BASOP_NOGLOB + move32(); denom = L_add_co( energy[i], denom, &Carry, &Overflow ); -#else /* BASOP_NOGLOB */ - denom = L_add_c( energy[i], denom ); -#endif /* BASOP_NOGLOB */ Overflow = 0; - -#ifdef BASOP_NOGLOB + move32(); L_c = L_macNs_co( L_c, 0, 0, &Carry, &Overflow ); -#else /* BASOP_NOGLOB */ - L_c = L_macNs( L_c, 0, 0 ); -#endif } denom = norm_llQ31( L_c, denom, &denom_exp ); /*Q31*/ @@ -759,13 +880,9 @@ Word16 IGF_getSFM( /**< out: Q15| SFM value /*Transform to Q15*/ s = norm_l( SFM32 ); -#ifdef BASOP_NOGLOB SFM = round_fx_sat( L_shl_sat( SFM32, s ) ); -#else - SFM = round_fx( L_shl( SFM32, s ) ); -#endif *SFM_exp = sub( *SFM_exp, s ); - + move16(); /**SFM_exp = s_min(*SFM_exp, 0);*/ IF( *SFM_exp > 0 ) { @@ -811,6 +928,7 @@ static void IGF_Whitening( const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in { /* reset filter */ hPrivateData->prevSFM_FIR[p] = L_deposit_l( 0 ); + move32(); hPrivateData->prevSFM_IIR[p] = 0; move16(); @@ -834,6 +952,7 @@ static void IGF_Whitening( const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in IF( powerSpectrum ) { Word16 nT = hGrid->nTiles; + move16(); SWITCH( hPrivateData->igfInfo.bitRateIndex ) { case IGF_BITRATE_WB_9600: @@ -875,13 +994,8 @@ static void IGF_Whitening( const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in BASOP_SATURATE_WARNING_OFF_EVS /*SFM = min(2.7f, SFM);*/ /*Overflow possible in shift, intended*/ -#ifdef BASOP_NOGLOB tmp = add_sat( crest, tmp ); SFM = s_min( 22118 /*2.7f Q13*/, extract_h( L_shr_sat( SFM32, 16 - 29 ) /*->Q29*/ ) /*->Q13*/ ); -#else - tmp = add( crest, tmp ); - SFM = s_min( 22118 /*2.7f Q13*/, extract_h( L_shr( SFM32, 16 - 29 ) /*->Q29*/ ) /*->Q13*/ ); -#endif BASOP_SATURATE_WARNING_ON_EVS hPrivateData->prevSFM_FIR[p] = tmp32; /*15Q16*/ @@ -934,6 +1048,7 @@ static void IGF_Whitening( const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in FOR( p = 0; p < IGF_MAX_TILES; p++ ) { hPrivateData->prevSFM_FIR[p] = L_deposit_l( 0 ); + move32(); hPrivateData->prevSFM_IIR[p] = 0; move16(); } @@ -945,10 +1060,10 @@ static void IGF_Whitening( const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in /**********************************************************************/ /* write whitening levels into bitstream **************************************************************************/ -static void IGF_WriteWhiteningTile( /**< out: Q0 | number of bits written */ - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - Word16 *pBitOffset, /**< in: | ptr to bitOffset counter */ - Word16 whiteningLevel /**< in: Q0 | whitening levels to write */ +static void IGF_WriteWhiteningTile_fx( /**< out: Q0 | number of bits written */ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + Word16 *pBitOffset, /**< in: | ptr to bitOffset counter */ + Word16 whiteningLevel /**< in: Q0 | whitening levels to write */ ) { IF( EQ_32( whiteningLevel, IGF_WHITENING_MID ) ) @@ -969,15 +1084,15 @@ static void IGF_WriteWhiteningTile( /**< ou } } -/**********************************************************************/ /* - writes the whitening levels - **************************************************************************/ -static void IGF_WriteWhiteningLevels( /**< out: Q0 | total number of bits written */ - const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF encoder */ - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - Word16 *pBitOffset, /**< in: | ptr to bitOffset counter */ - const Word16 igfGridIdx, /**< in: Q0 | igf grid index see declaration of IGF_GRID_IDX for details */ - const Word16 isIndepFlag /**< in: Q0 | if 1 frame is independent, 0 = frame is coded with data from previous frame */ +/**********************************************************************/ /* + writes the whitening levels + **************************************************************************/ +static void IGF_WriteWhiteningLevels_fx( /**< out: Q0 | total number of bits written */ + const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF encoder */ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + Word16 *pBitOffset, /**< in: | ptr to bitOffset counter */ + const Word16 igfGridIdx, /**< in: Q0 | igf grid index see declaration of IGF_GRID_IDX for details */ + const Word16 isIndepFlag /**< in: Q0 | if 1 frame is independent, 0 = frame is coded with data from previous frame */ ) { IGF_ENC_PRIVATE_DATA_HANDLE hPrivateData; @@ -1006,7 +1121,7 @@ static void IGF_WriteWhiteningLevels( / move16(); tmp32 = 0; move32(); - + test(); WHILE( ( LT_16( p, nTiles ) ) && ( tmp32 == 0 ) ) { test(); @@ -1029,7 +1144,7 @@ static void IGF_WriteWhiteningLevels( / { IGF_write_bits( hBstr, pBitOffset, 0, 1 ); } - IGF_WriteWhiteningTile( hBstr, pBitOffset, hPrivateData->igfCurrWhiteningLevel[0] ); + IGF_WriteWhiteningTile_fx( hBstr, pBitOffset, hPrivateData->igfCurrWhiteningLevel[0] ); p = 1; move16(); tmp32 = 0; @@ -1039,7 +1154,7 @@ static void IGF_WriteWhiteningLevels( / isSame = 1; move16(); } - + test(); WHILE( ( LT_16( p, nTiles ) ) && ( tmp32 == 0 ) ) { test(); @@ -1057,7 +1172,7 @@ static void IGF_WriteWhiteningLevels( / IGF_write_bits( hBstr, pBitOffset, 1, 1 ); FOR( p = 1; p < nTiles; p++ ) { - IGF_WriteWhiteningTile( hBstr, pBitOffset, hPrivateData->igfCurrWhiteningLevel[p] ); + IGF_WriteWhiteningTile_fx( hBstr, pBitOffset, hPrivateData->igfCurrWhiteningLevel[p] ); } } ELSE @@ -1067,13 +1182,13 @@ static void IGF_WriteWhiteningLevels( / } } -/**********************************************************************/ /* - write flattening trigger - **************************************************************************/ -static void IGF_WriteFlatteningTrigger( /**< out: | number of bits written */ - const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Encoder */ - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - Word16 *pBitOffset /**< in: | ptr to bitOffset counter */ +/**********************************************************************/ /* + write flattening trigger + **************************************************************************/ +static void IGF_WriteFlatteningTrigger_fx( /**< out: | number of bits written */ + const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Encoder */ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + Word16 *pBitOffset /**< in: | ptr to bitOffset counter */ ) { Word16 flatteningTrigger; @@ -1143,19 +1258,20 @@ Word16 IGFEncWriteBitstream_fx( /**< ou isIndepFlag, /* i: if 1 frame is independent, 0 = frame is coded with data from previous frame */ &igfAllZero ); /* o: *igfAllZero */ - IGF_WriteWhiteningLevels( hInstance, /* i: instance handle of IGF Encoder */ - hBstr, /* i: encoder state */ - pBitOffset, /* i: ptr to bitOffset counter */ - igfGridIdx, /* i: igf grid index see definition of IGF_GRID_IDX for details */ - isIndepFlag ); /* i: if 1 frame is independent, 0 = frame is coded with data from previous frame */ + IGF_WriteWhiteningLevels_fx( hInstance, /* i: instance handle of IGF Encoder */ + hBstr, /* i: encoder state */ + pBitOffset, /* i: ptr to bitOffset counter */ + igfGridIdx, /* i: igf grid index see definition of IGF_GRID_IDX for details */ + isIndepFlag ); /* i: if 1 frame is independent, 0 = frame is coded with data from previous frame */ - IGF_WriteFlatteningTrigger( hInstance, /* i: instance handle of IGF Encoder */ - hBstr, /* i: encoder state */ - pBitOffset ); /* i: ptr to bitOffset counter */ + IGF_WriteFlatteningTrigger_fx( hInstance, /* i: instance handle of IGF Encoder */ + hBstr, /* i: encoder state */ + pBitOffset ); /* i: ptr to bitOffset counter */ hInstance->infoTotalBitsPerFrameWritten = sub( *pBitOffset, startBitCount ); hInstance->infoTotalBitsWritten = add( hInstance->infoTotalBitsWritten, hInstance->infoTotalBitsPerFrameWritten ); - + move16(); + move16(); return hInstance->infoTotalBitsPerFrameWritten; } @@ -1253,7 +1369,7 @@ static void pack_bit_ivas_fx( move16(); } - IF( bit != 0 ) + if ( bit != 0 ) { **pt = (UWord8) s_or( **pt, *omask ); move16(); @@ -1302,6 +1418,7 @@ void IGFEncConcatenateBitstream_ivas_fx( const IGF_ENC_INSTANCE_HANDLE hIGFEnc, move16(); omask = (UWord8) UL_lshr( 0x80, s_and( *pFrame_size, 0x7 ) ); + move16(); pFrame += *pFrame_size >> 3; /* bitstream packing (conversion of individual indices into a serial stream) */ @@ -1348,7 +1465,7 @@ void IGFEncConcatenateBitstream_fx( const IGF_ENC_INSTANCE_HANDLE hInstance, /** hPrivateData = &hInstance->igfData; *next_ind = *next_ind - bsBits; - + move16(); indices_to_serial_generic( &ind_list_fx[*next_ind], bsBits, @@ -1356,7 +1473,7 @@ void IGFEncConcatenateBitstream_fx( const IGF_ENC_INSTANCE_HANDLE hInstance, /** &hPrivateData->igfBitstreamBits ); *nb_bits = sub( *nb_bits, bsBits ); - + move16(); return; } diff --git a/lib_enc/igf_scf_enc.c b/lib_enc/igf_scf_enc.c index 04ca67979f1eb2a809bf66b850d15804691b9c61..e9ef96e1a1b92580927e833e480097616817912d 100644 --- a/lib_enc/igf_scf_enc.c +++ b/lib_enc/igf_scf_enc.c @@ -98,6 +98,7 @@ static void arith_encode_bits( 32767, /* disable the bit count limitation */ &hPrivateData->acState, bit ); + move16(); } } @@ -133,7 +134,7 @@ static void arith_encode_residual( &hPrivateData->acState, x, cumulativeFrequencyTable ); - + move16(); return; } @@ -146,6 +147,7 @@ static void arith_encode_residual( &hPrivateData->acState, 0, cumulativeFrequencyTable ); + move16(); } ELSE /* x > IGF_MAX_ENC_SEPARATE */ { @@ -156,6 +158,7 @@ static void arith_encode_residual( &hPrivateData->acState, IGF_SYMBOLS_IN_TABLE - 1, cumulativeFrequencyTable ); + move16(); } /* encode one of the tails of the distribution */ @@ -226,17 +229,20 @@ static void encode_sfe_vector( &hPrivateData->acState, shr( x[f], 2 ), (const UWord16 *) hPrivateData->cf_se00 ); + move16(); arith_encode_bits( hPrivateData, ptr, x[f] & 3, 2 ); /* LSBs as 2 bit raw */ } ELSE IF( EQ_16( f, 1 ) ) { pred = x[f - 1]; /* pred = b */ + move16(); arith_encode_residual( hPrivateData, ptr, x[f] - pred, hPrivateData->cf_se01, hPrivateData->cf_off_se01 ); } ELSE { /* f >= 2 */ - pred = x[f - 1]; /* pred = b */ + pred = x[f - 1]; /* pred = b */ + move16(); ctx = quant_ctx( sub( x[f - 1], x[f - 2] ) ); /* Q(b - e) */ arith_encode_residual( hPrivateData, ptr, sub( x[f], pred ), &hPrivateData->cf_se02[( IGF_SYMBOLS_IN_TABLE + 1 ) * ( IGF_CTX_OFFSET + ctx )], hPrivateData->cf_off_se02[IGF_CTX_OFFSET + ctx] ); } @@ -267,11 +273,11 @@ static void encode_sfe_vector( /*---------------------------------------------------------------------* - * IGFSCFEncoderEncode() + * IGFSCFEncoderEncode_ivas_fx() * * main IGF encoder function *---------------------------------------------------------------------*/ -Word16 IGFSCFEncoderEncode( +Word16 IGFSCFEncoderEncode_ivas_fx( IGFSCFENC_INSTANCE_HANDLE hPublicData, /* i/o: handle to public data or NULL in case there was no instance created */ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word16 bitCount, /* i : offset to the first bit in bitbuffer which should be readed by iisArithDecoderDecode function */ diff --git a/lib_enc/igf_scf_enc_fx.c b/lib_enc/igf_scf_enc_fx.c index b8125cbd6d408bd4de4d065d72e3fb8e5769580f..8659d53a166cb2a6f155bb85c4f3025c780424a7 100644 --- a/lib_enc/igf_scf_enc_fx.c +++ b/lib_enc/igf_scf_enc_fx.c @@ -45,8 +45,11 @@ void IGFSCFEncoderOpen_fx( set16_fx( hPublicData->prevSave, 0, 64 ); hPublicData->scfCountLongBlock[0] = sub( hIgfInfo->grid[0].swb_offset_len, 1 ); + move16(); hPublicData->scfCountLongBlock[1] = sub( hIgfInfo->grid[1].swb_offset_len, 1 ); + move16(); hPublicData->scfCountLongBlock[2] = sub( hIgfInfo->grid[2].swb_offset_len, 1 ); + move16(); hPublicData->t = 0; move16(); /* protect against the invalid request of starting encoding with a dependent block */ @@ -124,7 +127,7 @@ static void arith_encode_residual( &hPrivateData->acState_fx, x, cumulativeFrequencyTable ); - + move16(); return; } @@ -137,6 +140,7 @@ static void arith_encode_residual( &hPrivateData->acState_fx, 0, cumulativeFrequencyTable ); + move16(); } ELSE /* x > IGF_MAX_ENC_SEPARATE */ { @@ -147,6 +151,7 @@ static void arith_encode_residual( &hPrivateData->acState_fx, IGF_SYMBOLS_IN_TABLE - 1, cumulativeFrequencyTable ); + move16(); } /* encode one of the tails of the distribution */ @@ -216,6 +221,7 @@ static void encode_sfe_vector( &hPrivateData->acState_fx, shr( x[f], 2 ), (const UWord16 *) hPrivateData->cf_se00 ); + move16(); arith_encode_bits( hPrivateData, ptr, s_and( x[f], 3 ), 2 ); /* LSBs as 2 bit raw */ } ELSE IF( EQ_16( f, 1 ) ) @@ -233,7 +239,6 @@ static void encode_sfe_vector( /* (t == 0) && (f >= 2) */ prev_offset = sub( f, 1 ); res = sub( x[f], x[prev_offset] ); - move16(); /* pred = b */ ctx = quant_ctx( sub( x[prev_offset], x[sub( prev_offset, 1 )] ) ); /* Q(b - e) */ /* index1 is (IGF_SYMBOLS_IN_TABLE + 1) * (CTX_OFFSET + ctx) */ index1 = L_mac0( ( IGF_SYMBOLS_IN_TABLE + 1 ) * IGF_CTX_OFFSET, ( IGF_SYMBOLS_IN_TABLE + 1 ), ctx ); @@ -340,12 +345,13 @@ Word16 IGFSCFEncoderEncode_fx( hPublicData->ptrBitIndex, &hPublicData->acState_fx ); /* finish AC encoding */ hPublicData->bitCount = add( hPublicData->bitCount, hPublicData->ptrBitIndex ); - + move16(); + move16(); /* advance history */ Copy( sfe, hPublicData->prev, hPublicData->scfCountLongBlock[igfGridIdx] ); hPublicData->t = add( hPublicData->t, 1 ); - + move16(); /* copy the bits from the temporary bit buffer, if doRealEncoding is enabled */ IF( hBstr ) diff --git a/lib_enc/init_enc.c b/lib_enc/init_enc.c index 7d046db5ff8c5601d00294cdb54ad60dd53717d3..7ce9f8ff5a3e285df92080b672cf3cb7c179e4b2 100644 --- a/lib_enc/init_enc.c +++ b/lib_enc/init_enc.c @@ -196,6 +196,7 @@ ivas_error init_encoder_ivas_fx( #if 1 // TODO: Float Initializations. To be removed later st->active_cnt = 0; + move16(); #endif st->pst_mem_deemp_err_fx = 0; @@ -387,6 +388,7 @@ ivas_error init_encoder_ivas_fx( set32_fx( st->Bin_E_old_fx, 0, L_FFT / 2 ); st->q_Bin_E_old = Q31; + move16(); set16_fx( st->hSignalBuf->buf_speech_enc, 0, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); st->exp_buf_speech_enc = 0; move16(); @@ -929,10 +931,12 @@ ivas_error init_encoder_ivas_fx( } set32_fx( st->hTcxEnc->spectrum_long_fx, 0, N_MAX ); st->hTcxEnc->spectrum_long_e = 0; - + move16(); /* Share the memories for 2xTCX10/4xTCX5 and for TCX20 */ st->hTcxEnc->spectrum_fx[0] = st->hTcxEnc->spectrum_long_fx; st->hTcxEnc->spectrum_fx[1] = st->hTcxEnc->spectrum_long_fx + N_TCX10_MAX; + move32(); + move32(); st->hTcxEnc->spectrum_e[0] = st->hTcxEnc->spectrum_e[1] = 0; move16(); move16(); @@ -1010,7 +1014,7 @@ ivas_error init_encoder_ivas_fx( igf_brate = element_brate; } move32(); - + test(); IF( EQ_16( st->codec_mode, MODE2 ) || GT_16( st->element_mode, EVS_MONO ) ) { st->igf = getIgfPresent_fx( st->element_mode, igf_brate, st->max_bwidth, st->rf_mode ); @@ -1092,7 +1096,11 @@ ivas_error init_encoder_ivas_fx( move16(); /* Initialize ACELP */ #endif +#ifdef FIX_920_IGF_INIT_ERROR + init_coder_ace_plus_ivas_fx( st, st->last_total_brate, igf_brate, 0 ); +#else init_coder_ace_plus_ivas_fx( st, st->last_total_brate, 0 ); +#endif IF( st->hLPDmem != NULL ) { diff --git a/lib_enc/init_enc_fx.c b/lib_enc/init_enc_fx.c index 73cade783bee614191653c6063f6cec8754593e6..89bbdc898e3e7a666aba90721a645f5f557d1d57 100644 --- a/lib_enc/init_enc_fx.c +++ b/lib_enc/init_enc_fx.c @@ -1,4 +1,4 @@ -/*==================================================================================== +/*==================================================================================== EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0 ====================================================================================*/ @@ -29,6 +29,8 @@ ivas_error init_encoder_fx( Word16 idchan = 0; /* i : channel ID */ Word16 vad_only_flag = 0; /* i : channel ID */ + move16(); + move16(); ISM_MODE ism_mode = ISM_MODE_NONE; ivas_error error; // PMT("ism_mode, idchan, vad_only_flag to be move to function header") @@ -97,7 +99,7 @@ ivas_error init_encoder_fx( st_fx->last_core = -1; move16(); - IF( st_fx->Opt_AMR_WB ) + if ( st_fx->Opt_AMR_WB ) { st_fx->last_core = AMR_WB_CORE; move16(); @@ -141,7 +143,9 @@ ivas_error init_encoder_fx( st->hBstr->ivas_ind_list_zero = &st_ivas->ind_list; st->hBstr->ivas_max_num_indices = &st_ivas->ivas_max_num_indices; st->hBstr->nb_ind_tot = 0; + move16(); st->hBstr->nb_bits_tot = 0; + move16(); st->hBstr->st_ivas = st_ivas; #endif } @@ -157,7 +161,7 @@ ivas_error init_encoder_fx( Copy( GEWB_Ave_fx, st_fx->lsf_adaptive_mean_fx, M ); init_lvq_fx( st_fx->offset_scale1_fx, st_fx->offset_scale2_fx, st_fx->offset_scale1_p_fx, st_fx->offset_scale2_p_fx, st_fx->no_scales_fx, st_fx->no_scales_p_fx ); st_fx->next_force_safety_net = 0; - + move16(); st_fx->pstreaklen = 0; move16(); st_fx->streaklimit_fx = 32767; @@ -297,7 +301,7 @@ ivas_error init_encoder_fx( // st_fx->GSC_noisy_speech = 0; st_fx->GSC_IVAS_mode = 0; - + move16(); test(); test(); IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) @@ -350,7 +354,7 @@ ivas_error init_encoder_fx( test(); test(); test(); - IF( ( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) || EQ_16( st_fx->element_mode, EVS_MONO ) ) && ( !vad_only_flag ) ) + IF( ( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) || st_fx->element_mode == EVS_MONO ) && ( !vad_only_flag ) ) { if ( ( st_fx->hVAD = (VAD_HANDLE) malloc( sizeof( VAD_DATA ) ) ) == NULL ) { @@ -386,7 +390,7 @@ ivas_error init_encoder_fx( st_fx->hVAD->L_snr_sum_vad_fx = 0; move32(); } - else + ELSE { st_fx->hVAD = NULL; } @@ -404,7 +408,9 @@ ivas_error init_encoder_fx( * Noise estimator *-----------------------------------------------------------------*/ // PMT("deal with idchan ") - IF( /*idchan == 0 ||*/ EQ_16( st_fx->element_mode, IVAS_CPE_TD ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) || EQ_16( st_fx->element_mode, EVS_MONO ) ) + test(); + test(); + IF( /*idchan == 0 ||*/ EQ_16( st_fx->element_mode, IVAS_CPE_TD ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) || st_fx->element_mode == EVS_MONO ) { if ( ( st_fx->hNoiseEst = (NOISE_EST_HANDLE) malloc( sizeof( NOISE_EST_DATA ) ) ) == NULL ) { @@ -422,7 +428,8 @@ ivas_error init_encoder_fx( *-----------------------------------------------------------------*/ test(); test(); - IF( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) || EQ_16( st_fx->element_mode, EVS_MONO ) ) + test(); + IF( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) || st_fx->element_mode == EVS_MONO ) { IF( ( st_fx->hSpMusClas = (SP_MUS_CLAS_HANDLE) malloc( sizeof( SP_MUS_CLAS_DATA ) ) ) == NULL ) { @@ -472,7 +479,7 @@ ivas_error init_encoder_fx( move16(); st_fx->coder_type_raw = VOICED; st_fx->last_coder_type_raw = st_fx->coder_type_raw; - + move16(); st_fx->is_ism_format = 0; move16(); if ( NE_16( ism_mode, ISM_MODE_NONE ) ) @@ -531,6 +538,8 @@ ivas_error init_encoder_fx( * LP-CNG *-----------------------------------------------------------------*/ + test(); + test(); test(); test(); test(); @@ -622,7 +631,7 @@ ivas_error init_encoder_fx( * SC-VBR parameters *-----------------------------------------------------------------*/ test(); - IF( st_fx->Opt_SC_VBR || EQ_16( st_fx->element_mode, EVS_MONO ) ) + IF( st_fx->Opt_SC_VBR || st_fx->element_mode == EVS_MONO ) { IF( ( st_fx->hSC_VBR = (SC_VBR_ENC_HANDLE) malloc( sizeof( SC_VBR_ENC_DATA ) ) ) == NULL ) { @@ -636,7 +645,7 @@ ivas_error init_encoder_fx( st_fx->hSC_VBR = NULL; } /* PLC encoder */ - IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) + IF( st_fx->element_mode == EVS_MONO ) { IF( ( st_fx->hPlcExt = (PLC_ENC_EVS_HANDLE) malloc( sizeof( PLC_ENC_EVS ) ) ) == NULL ) { @@ -710,8 +719,8 @@ ivas_error init_encoder_fx( // st_fx->cldfbSynTd = NULL; } - - IF( st_fx->Opt_RF_ON || EQ_16( st_fx->element_mode, EVS_MONO ) ) + test(); + IF( st_fx->Opt_RF_ON || st_fx->element_mode == EVS_MONO ) { IF( ( st_fx->hRF = (RF_ENC_HANDLE) malloc( sizeof( RF_ENC_DATA ) ) ) == NULL ) { @@ -752,6 +761,7 @@ ivas_error init_encoder_fx( *-----------------------------------------------------------------*/ // VE: reduction possible for MCT_CHAN_MODE_LFE channel - see I1-172 + test(); IF( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) { IF( ( st_fx->hTcxEnc = (TCX_ENC_HANDLE) malloc( sizeof( TCX_ENC_DATA ) ) ) == NULL ) @@ -768,7 +778,7 @@ ivas_error init_encoder_fx( set16_fx( st_fx->hTcxEnc->old_out_fx, 0, L_FRAME32k ); st_fx->hTcxEnc->Q_old_out = 0; - + move16(); /* MDCT selector */ MDCT_selector_reset_fx( st_fx->hTcxEnc ); st_fx->hTcxEnc->Q_old_out = 0; @@ -782,7 +792,7 @@ ivas_error init_encoder_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hTcxCfg\n" ) ); } } - else + ELSE { st_fx->hTcxEnc = NULL; // st_fx->hTcxCfg = NULL; @@ -838,7 +848,7 @@ ivas_error init_encoder_fx( move16(); } st_fx->rf_mode_last = st_fx->rf_mode; - + move16(); /* initialize RF indice buffers */ reset_rf_indices_fx( st_fx ); @@ -847,12 +857,11 @@ ivas_error init_encoder_fx( *-----------------------------------------------------------------*/ st_fx->last_sr_core = i_mult2( st_fx->last_L_frame, 50 ); - + move16(); /*-----------------------------------------------------------------* * IGF *-----------------------------------------------------------------*/ - test(); test(); IF( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) { @@ -919,15 +928,23 @@ ivas_error init_encoder_fx( st_fx->sharpFlag = 0; move16(); - st_fx->tdm_LRTD_flag = 0; /* LRTD stereo mode flag */ - st_fx->cna_dirac_flag = 0; /* CNA in DirAC flag */ - st_fx->cng_sba_flag = 0; /* CNG in SBA flag */ - st_fx->GSC_IVAS_mode = 0; /* CNG in SBA flag */ - st_fx->element_mode = EVS_MONO; /* element mode */ + st_fx->tdm_LRTD_flag = 0; /* LRTD stereo mode flag */ + move16(); + st_fx->cna_dirac_flag = 0; /* CNA in DirAC flag */ + move16(); + st_fx->cng_sba_flag = 0; /* CNG in SBA flag */ + move16(); + st_fx->GSC_IVAS_mode = 0; /* CNG in SBA flag */ + move16(); + st_fx->element_mode = EVS_MONO; /* element mode */ + move16(); st_fx->last_element_mode = st_fx->element_mode; /* element mode */ - st_fx->element_brate = -1; /* element bitrate */ - // PMT("element_mode and element_brate should be initialized at a proper place in ivas_dec_init eventually") - st_fx->low_rate_mode = 0; /* low-rate mode flag */ + move16(); + st_fx->element_brate = -1; /* element bitrate */ + move32(); + // PMT("element_mode and element_brate should be initialized at a proper place in ivas_dec_init eventually") + st_fx->low_rate_mode = 0; /* low-rate mode flag */ + move16(); // st_fx->coder_type = GENERIC; /* low-rate mode flag */ set16_fx( st_fx->pitch, L_SUBFR, 3 ); @@ -936,10 +953,12 @@ ivas_error init_encoder_fx( #ifdef DEBUGGING st_fx->id_element = -1; /* element ID */ + move16(); #endif - st_fx->extl_orig = -1; /* extension layer */ + st_fx->extl_orig = -1; /* extension layer */ + move16(); st_fx->extl_brate_orig = 0; /* extension layer bitrate */ - + move32(); return error; } /*-----------------------------------------------------------------------* diff --git a/lib_enc/inov_enc_fx.c b/lib_enc/inov_enc_fx.c index a2567535209f5e6777477e7da66811aa8bc78e3e..7964df4a8a55a1260460dfece8705614ceae8a2c 100644 --- a/lib_enc/inov_enc_fx.c +++ b/lib_enc/inov_enc_fx.c @@ -155,6 +155,7 @@ Word16 inov_encode_fx( IF( st_fx->acelp_cfg.fcb_mode ) { /* set number of iterations in TD stereo, secondary channel */ + test(); if ( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) && EQ_16( st_fx->idchan, 1 ) ) { cmpl_flag = 1; @@ -245,7 +246,7 @@ Word16 inov_encode_fx( } } - if ( EQ_16( coder_type, INACTIVE ) ) + if ( coder_type == INACTIVE ) { cmpl_flag = 4; move16(); @@ -708,9 +709,7 @@ Word16 inov_encode_ivas_fx( E_ACELP_4t_ivas_fx( dn, cn, h2, Rw, (Word8) acelpautoc, code, st_fx->acelp_cfg.fixed_cdk_index[idx2], prm, L_frame, last_L_frame, st_fx->total_brate, i_subfr, cmpl_flag, st_fx->element_mode ); wordcnt = shr( ACELP_FIXED_CDK_BITS( st_fx->acelp_cfg.fixed_cdk_index[idx2] ), 4 ); - move16(); bitcnt = s_and( ACELP_FIXED_CDK_BITS( st_fx->acelp_cfg.fixed_cdk_index[idx2] ), 15 ); - move16(); FOR( i = 0; i < wordcnt; i++ ) { diff --git a/lib_enc/isf_enc_amr_wb_fx.c b/lib_enc/isf_enc_amr_wb_fx.c index 505d3f2903eb9f1ea7156dc154357103dd07d8be..047a7409c35816d9c97af4eccfecb538364eb055 100644 --- a/lib_enc/isf_enc_amr_wb_fx.c +++ b/lib_enc/isf_enc_amr_wb_fx.c @@ -122,7 +122,7 @@ void isf_enc_amr_wb_fx( * A(z) calculation *-------------------------------------------------------------------------------------*/ - if ( st->rate_switching_reset ) + IF( st->rate_switching_reset ) { Copy( isf_new, st->lsf_old_fx, M ); Copy( isp_new, st->lsp_old_fx, M ); @@ -171,7 +171,7 @@ static void qisf_ns_28b_fx( indice[3] = sub_VQ_fx( &isf[8], dico4_ns_28b_fx, 4, DICO4_NS_28b, &tmp ); move16(); 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 ); @@ -241,9 +241,11 @@ static void qisf_2s_36b_fx( } tmp_ind[0] = sub_VQ_fx( &isf2[0], dico21_isf_36b_fx, 5, SIZE_BK21_36b, &min_err ); + move16(); temp = L_add( min_err, 0 ); tmp_ind[1] = sub_VQ_fx( &isf2[5], dico22_isf_36b_fx, 4, SIZE_BK22_36b, &min_err ); + move16(); temp = L_add( temp, min_err ); IF( LT_32( temp, distance ) ) @@ -369,10 +371,13 @@ static void qisf_2s_46b_fx( } tmp_ind[0] = sub_VQ_fx( &isf2[0], dico21_isf_46b_fx, 3, SIZE_BK21, &min_err ); + move16(); temp = L_add( min_err, 0 ); tmp_ind[1] = sub_VQ_fx( &isf2[3], dico22_isf_46b_fx, 3, SIZE_BK22, &min_err ); + move16(); temp = L_add( temp, min_err ); tmp_ind[2] = sub_VQ_fx( &isf2[6], dico23_isf_46b_fx, 3, SIZE_BK23, &min_err ); + move16(); temp = L_add( temp, min_err ); IF( LT_32( temp, distance ) ) { diff --git a/lib_enc/ivas_core_enc.c b/lib_enc/ivas_core_enc.c index a691405329f4a1b880546efa9ec988965d03ddac..0c7fe9094e8c56cebde21ea2e61465923802eec0 100644 --- a/lib_enc/ivas_core_enc.c +++ b/lib_enc/ivas_core_enc.c @@ -328,7 +328,6 @@ ivas_error ivas_core_enc_fx( /*---------------------------------------------------------------------* * Preprocessing (preparing) for ACELP/HQ core switching *---------------------------------------------------------------------*/ - core_switching_pre_enc_ivas_fx( st, old_inp_12k8_fx[n], sub( Q_new[n], 1 ), old_inp_16k_fx[n], sub( Q_new[n], 1 ), sts[0]->active_cnt, last_element_mode ); /*---------------------------------------------------------------------* @@ -499,14 +498,14 @@ ivas_error ivas_core_enc_fx( IF( EQ_16( nSubframes, NB_DIV ) ) { Word16 max_e = s_max( orig_spectrum_e[i][0], orig_spectrum_e[i][1] ); - Scale_sig32( hMCT->p_orig_spectrum_long_fx[cpe_id][i], N_TCX10_MAX, sub( orig_spectrum_e[i][0], max_e ) ); // exp(max_e) - Scale_sig32( hMCT->p_orig_spectrum_long_fx[cpe_id][i] + N_TCX10_MAX, N_TCX10_MAX, sub( orig_spectrum_e[i][1], max_e ) ); // exp(max_e) - hMCT->q_orig_spectrum_long_fx[cpe_id][i] = max_e; + scale_sig32( hMCT->p_orig_spectrum_long_fx[cpe_id][i], N_TCX10_MAX, sub( orig_spectrum_e[i][0], max_e ) ); // exp(max_e) + scale_sig32( hMCT->p_orig_spectrum_long_fx[cpe_id][i] + N_TCX10_MAX, N_TCX10_MAX, sub( orig_spectrum_e[i][1], max_e ) ); // exp(max_e) + hMCT->q_orig_spectrum_long_fx[cpe_id][i] = sub( Q31, max_e ); move16(); } ELSE { - hMCT->q_orig_spectrum_long_fx[cpe_id][i] = orig_spectrum_e[i][0]; + hMCT->q_orig_spectrum_long_fx[cpe_id][i] = sub( Q31, orig_spectrum_e[i][0] ); move16(); } @@ -794,8 +793,8 @@ ivas_error ivas_core_enc_fx( stereo_icBWE_preproc_fx( hCPE, input_frame, new_swb_speech_buffer_fx_16 /*tmp buffer*/, q_new_swb_speech_buffer ); q_new_swb_speech_buffer = add( q_new_swb_speech_buffer, 16 ); - Copy_Scale_sig_16_32( new_swb_speech_buffer_fx_16, new_swb_speech_buffer_fx, input_frame, Q16 ); // q_new_swb_speech_buffer - Copy_Scale_sig_16_32( voice_factors_fx[0], voice_factors_fx32[0], NB_SUBFR16k, Q16 ); // Q31 + Copy_Scale_sig_16_32_no_sat( new_swb_speech_buffer_fx_16, new_swb_speech_buffer_fx, input_frame, Q16 ); // q_new_swb_speech_buffer + Copy_Scale_sig_16_32_no_sat( voice_factors_fx[0], voice_factors_fx32[0], NB_SUBFR16k, Q16 ); // Q31 stereo_icBWE_enc_ivas_fx( hCPE, shb_speech_fx32, sub( Q31, Q_shb_spch ), new_swb_speech_buffer_fx, sub( Q31, q_new_swb_speech_buffer ), voice_factors_fx32[0] ); diff --git a/lib_enc/ivas_core_pre_proc.c b/lib_enc/ivas_core_pre_proc.c index 8c2c31adb023e7ded5165a82b24593b48b56e3dd..31b14ed10354f25428d2cfbddc813cef66e91005 100644 --- a/lib_enc/ivas_core_pre_proc.c +++ b/lib_enc/ivas_core_pre_proc.c @@ -284,7 +284,11 @@ 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(); } @@ -571,6 +575,8 @@ ivas_error pre_proc_ivas_fx( st->q_inp = -1; move16(); Scale_sig( st->buf_wspeech_enc, L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320, sub( Q_old_inp_16k, sub( Q15, st->exp_buf_wspeech_enc ) ) ); /* Q15 - Q_old_inp_16k */ + st->mem_wsp_enc = shl( st->mem_wsp_enc, sub( Q_old_inp_16k, sub( Q15, st->exp_buf_wspeech_enc ) ) ); // Q_old_inp_16k + move16(); st->exp_buf_wspeech_enc = sub( Q15, Q_old_inp_16k ); move16(); Word16 Q_old_inp_128k = *Q_new; @@ -585,8 +591,13 @@ ivas_error pre_proc_ivas_fx( { return error; } - *epsP_fx_q = add( Q_r[0], 1 ); - move16(); + + test(); + IF( EQ_16( st->L_frame, L_FRAME16k ) && NE_16( element_mode, IVAS_CPE_MDCT ) ) + { + *epsP_fx_q = add( Q_r[0], 1 ); + move16(); + } } test(); IF( !( EQ_16( st->L_frame, L_FRAME16k ) && NE_16( element_mode, IVAS_CPE_MDCT ) ) ) diff --git a/lib_enc/ivas_core_pre_proc_front.c b/lib_enc/ivas_core_pre_proc_front.c index c06c437ffb1560beef60dfa36589312063652429..9fc530fa4fb5a0e7d5acb1dea14c20b6849a16e2 100644 --- a/lib_enc/ivas_core_pre_proc_front.c +++ b/lib_enc/ivas_core_pre_proc_front.c @@ -134,7 +134,10 @@ 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*/ - const Word32 ivas_total_brate, /* i : IVAS total bitrate - for setting the DTX 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 , @@ -259,8 +262,13 @@ ivas_error pre_proc_front_ivas_fx( IF( hSCE != NULL ) { - Copy_Scale_sig_16_32( 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( 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 */ +#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) */ @@ -277,8 +285,13 @@ ivas_error pre_proc_front_ivas_fx( } ELSE { - Copy_Scale_sig_16_32( 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( 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 */ +#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) */ @@ -294,7 +307,9 @@ ivas_error pre_proc_front_ivas_fx( } #ifdef DEBUG_MODE_INFO + if ( !( hCPE != NULL && hCPE->hStereoTD != NULL && ch_idx > 0 ) ) { + /* for TD stereo only write out first channel. The existence of a second channel can vary, this is just easier to handle */ int16_t tmpF[L_FRAME48k]; for ( int16_t isample = 0; isample < input_frame; isample++ ) { @@ -849,7 +864,7 @@ ivas_error pre_proc_front_ivas_fx( test(); IF( ( hCPE != NULL && !( lr_vad_enabled && st->idchan == 0 ) ) || hSCE != NULL ) { - *vad_flag_dtx = dtx_hangover_addition_fx( st, st->vad_flag, sub( st->lp_speech_fx, st->lp_noise_fx ), 0, vad_hover_flag, NULL, NULL ); /* Q0 */ + *vad_flag_dtx = ivas_dtx_hangover_addition_fx( st, st->vad_flag, sub( st->lp_speech_fx, st->lp_noise_fx ), 0, vad_hover_flag, NULL, NULL, NULL ); /* Q0 */ move16(); } ELSE @@ -1085,7 +1100,12 @@ ivas_error pre_proc_front_ivas_fx( st->cng_type = LP_CNG; 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(); @@ -1224,7 +1244,7 @@ ivas_error pre_proc_front_ivas_fx( * to reuse the primary channel LP coefficients in the secondary channel *----------------------------------------------------------------*/ Word32 speech_buff[L_FRAME + M]; - Copy_Scale_sig_16_32( inp_12k8_fx - M, speech_buff, L_FRAME + M, Q12 ); /* Q_new + 12 */ + Copy_Scale_sig_16_32_DEPREC( inp_12k8_fx - M, speech_buff, L_FRAME + M, Q12 ); /* Q_new + 12 */ hCPE->hStereoTD->tdm_lp_reuse_flag = tdm_lp_comparison_fx( hCPE->hStereoTD, hCPE->hStereoClassif, st, &speech_buff[0], tdm_A_PCh_fx, A_fx, M, tdm_lsp_new_PCh_fx, lsp_new_fx, L_FRAME, L_sub( element_brate, imult3216( FRAMES_PER_SEC, nb_bits_metadata ) ), add( *Q_new, 12 ) ); /* Q0 */ move16(); } @@ -1453,8 +1473,11 @@ 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 - - Copy_Scale_sig_16_32( st->lgBin_E_fx, st->Bin_E_fx, L_FFT / 2, sub( st->q_Bin_E, Q7 ) ); +#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' ) @@ -1514,7 +1537,7 @@ ivas_error pre_proc_front_ivas_fx( move16(); stereo_classifier_features_ivas_fx( hStereoClassif, st->idchan, element_mode, localVAD_HE_SAD, lsf_new_fx, epsP_fx, st->pitch, st->voicing_fx, *cor_map_sum_fx, non_staX_fx, sp_div_fx, - st->clas, sub( 31, *epsP_fx_q ), ( 15 - Q8 ) /* exp of cor_map_sum */, ( 15 - Q8 ) /* exp of non_staX_fx */, sub( 15, q_sp_div ) ); + st->clas, sub( 31, *epsP_fx_q ), ( 31 - Q8 ) /* exp of cor_map_sum */, ( 31 - Q8 ) /* exp of non_staX_fx */, sub( 15, q_sp_div ) ); } /*----------------------------------------------------------------* @@ -1668,6 +1691,8 @@ ivas_error pre_proc_front_ivas_fx( st->exp_mem_preemph_enc = sub( Q15, Q_old_inp_16k ); move16(); Scale_sig( st->buf_wspeech_enc, L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320, sub( Q_old_inp_16k, sub( Q15, st->exp_buf_wspeech_enc ) ) ); /* Q15 - Q_old_inp_16k */ + st->mem_wsp_enc = shl( st->mem_wsp_enc, sub( Q_old_inp_16k, sub( Q15, st->exp_buf_wspeech_enc ) ) ); // Q_old_inp_16k + move16(); st->exp_buf_wspeech_enc = sub( Q15, Q_old_inp_16k ); move16(); Scale_sig( st->buf_speech_enc_pe, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, sub( Q_old_inp_16k, sub( Q15, st->exp_buf_speech_enc_pe ) ) ); /* Q15 - Q_old_inp_16k */ @@ -1691,7 +1716,7 @@ ivas_error pre_proc_front_ivas_fx( *epsP_fx_q = add( Q_r[0], 1 ); move16(); - st->mem_wsp_enc = shr_r( st->mem_wsp_enc, *Q_new ); // Q_new - 1 -> Q-1 + 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 @@ -1701,6 +1726,9 @@ ivas_error pre_proc_front_ivas_fx( Scale_sig( st->buf_speech_enc, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, sub( 0, sub( Q15, st->exp_buf_speech_enc ) ) ); /* Q0 */ st->exp_buf_speech_enc = Q15; move16(); + Scale_sig( st->buf_wspeech_enc, L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320, sub( 0, sub( Q15, st->exp_buf_wspeech_enc ) ) ); /* Q0 */ + st->exp_buf_wspeech_enc = Q15; + move16(); smc_dec = ivas_acelp_tcx20_switching_fx( st, st->speech_enc, 0, st->wspeech_enc, non_staX_fx, pitch_fr_fx, voicing_fr_fx, currFlatness_fx, lsp_mid_fx, stab_fac_fx, res_cod_SNR_M_fx, res_cod_SNR_M_fx_e, flag_16k_smc ); /* Q0 */ } ELSE diff --git a/lib_enc/ivas_corecoder_enc_reconfig.c b/lib_enc/ivas_corecoder_enc_reconfig.c index 887dc12139735af0647c28cebd5c7ea8df8be0cc..847cdd0f633a14a5a2a3e0b7714924f64a3a4e55 100644 --- a/lib_enc/ivas_corecoder_enc_reconfig.c +++ b/lib_enc/ivas_corecoder_enc_reconfig.c @@ -267,7 +267,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx( Scale_sig( st_ivas->hSCE[k]->hCoreCoder[0]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), sub( q_com, st_ivas->hSCE[k]->hCoreCoder[0]->q_inp ) ); /* q_com */ st_ivas->hSCE[k]->hCoreCoder[0]->q_inp = q_com; move16(); - Copy_Scale_sig_16_32( st_ivas->hSCE[k]->hCoreCoder[0]->input_buff_fx, st_ivas->hSCE[k]->hCoreCoder[0]->input_buff32_fx, L_FRAME48k + NS2SA( 48000, IVAS_FB_ENC_DELAY_NS ) + L_FRAME48k, Q6 ); /* Q6 + q_com */ + Copy_Scale_sig_16_32_DEPREC( st_ivas->hSCE[k]->hCoreCoder[0]->input_buff_fx, st_ivas->hSCE[k]->hCoreCoder[0]->input_buff32_fx, L_FRAME48k + NS2SA( 48000, IVAS_FB_ENC_DELAY_NS ) + L_FRAME48k, Q6 ); /* Q6 + q_com */ st_ivas->hSCE[k]->hCoreCoder[0]->q_inp32 = add( Q6, q_com ); move16(); } @@ -285,7 +285,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx( Scale_sig( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), sub( q_com, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp ) ); /* q_com */ st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp = q_com; move16(); - Copy_Scale_sig_16_32( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_buff_fx, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_buff32_fx, L_FRAME48k + NS2SA( 48000, IVAS_FB_ENC_DELAY_NS ) + L_FRAME48k, Q6 ); /* Q6 + q_com */ + Copy_Scale_sig_16_32_DEPREC( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_buff_fx, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_buff32_fx, L_FRAME48k + NS2SA( 48000, IVAS_FB_ENC_DELAY_NS ) + L_FRAME48k, Q6 ); /* Q6 + q_com */ st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp32 = add( Q6, q_com ); move16(); } @@ -339,7 +339,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx( q_input_buff[sce_id] = st_ivas->hSCE[sce_id]->hCoreCoder[0]->q_inp32; move16(); } - destroy_sce_enc( st_ivas->hSCE[sce_id], ( EQ_16( st_ivas->hEncoderConfig->element_mode_init, EVS_MONO ) && !st_ivas->hEncoderConfig->stereo_dmx_evs ) ); + destroy_sce_enc_fx( st_ivas->hSCE[sce_id], ( EQ_16( st_ivas->hEncoderConfig->element_mode_init, EVS_MONO ) && !st_ivas->hEncoderConfig->stereo_dmx_evs ) ); st_ivas->hSCE[sce_id] = NULL; } diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index 4f8926eba0c9c20ef00004067da66f599052c4cd..7db5476e821897e310a3d02759ed530403fbd33e 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -80,6 +80,9 @@ 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 */ @@ -182,6 +185,7 @@ ivas_error ivas_cpe_enc_fx( set16_zero_fx( old_inp_16k_16fx[i], L_INP ); set_zero_fx( old_inp_16k_fx[i], L_INP ); set16_zero_fx( old_inp_12k8_16fx[i], L_INP_12k8 ); + set_zero_fx( old_inp_12k8_fx[i], L_INP_12k8 ); } #endif /*------------------------------------------------------------------* @@ -261,7 +265,7 @@ ivas_error ivas_cpe_enc_fx( test(); IF( sts[0]->ini_frame > 0 && st_ivas->hMCT == NULL ) { - hCPE->element_mode = select_stereo_mode( hCPE, ivas_format ); /* Q0 */ + hCPE->element_mode = select_stereo_mode_fx( hCPE, ivas_format ); } #ifdef DEBUG_FORCE_DIR else @@ -373,10 +377,13 @@ ivas_error ivas_cpe_enc_fx( /*----------------------------------------------------------------* * Set TD stereo parameters *----------------------------------------------------------------*/ - - Copy_Scale_sig_16_32( sts[1]->input_fx, sts[1]->input32_fx, input_frame, sub( Q11, sts[1]->q_inp ) ); /* Q11 */ - Copy_Scale_sig_16_32( sts[0]->input_fx, sts[0]->input32_fx, input_frame, sub( Q11, sts[0]->q_inp ) ); /* Q11 */ - +#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 ); @@ -403,6 +410,25 @@ 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 ); + 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 = norm_arr( 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 = norm_arr( 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 = norm_arr( 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(); +#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 ); @@ -420,6 +446,7 @@ 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(); +#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 ) ); @@ -445,10 +472,10 @@ ivas_error ivas_cpe_enc_fx( * Temporal inter-channel alignment, stereo adjustment *----------------------------------------------------------------*/ - Copy_Scale_sig_16_32( sts[0]->input_buff_fx, sts[0]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), Q6 ); /* Q6 + sts[0]->q_inp */ + Copy_Scale_sig_16_32_DEPREC( sts[0]->input_buff_fx, sts[0]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), Q6 ); /* Q6 + sts[0]->q_inp */ sts[0]->q_inp32 = add( Q6, sts[0]->q_inp ); move16(); - Copy_Scale_sig_16_32( sts[1]->input_buff_fx, sts[1]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), Q6 ); /* Q6 + sts[0]->q_inp */ + Copy_Scale_sig_16_32_DEPREC( sts[1]->input_buff_fx, sts[1]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), Q6 ); /* Q6 + sts[0]->q_inp */ sts[1]->q_inp32 = add( Q6, sts[1]->q_inp ); move16(); @@ -784,36 +811,32 @@ ivas_error ivas_cpe_enc_fx( test(); IF( hCPE->hStereoMdct != NULL && hCPE->hStereoMdct->hItd != NULL ) { - - 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_inp, sts[1]->q_old_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; + Word16 q_min; + q_min = sts[1]->q_old_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 ); + q_min = s_min( q_min, sts[1]->q_inp ); + q_min = s_min( q_min, sts[0]->q_old_inp ); + q_min = s_min( q_min, sts[0]->q_inp ); + + shift = norm_arr( sts[1]->old_input_signal_fx, input_frame ); + shift = s_min( shift, norm_arr( sts[1]->input_fx, input_frame ) ); + shift = s_min( shift, norm_arr( sts[0]->old_input_signal_fx, input_frame ) ); + shift = s_min( shift, norm_arr( sts[0]->input_fx, input_frame ) ); + + q_min = add( q_min, shift ); + + scale_sig( sts[1]->input_fx, input_frame, sub( q_min, sts[1]->q_inp ) ); /* q_min */ + scale_sig( sts[1]->old_input_signal_fx, input_frame, sub( q_min, sts[1]->q_old_inp ) ); /* q_min */ + scale_sig( sts[0]->input_fx, input_frame, sub( q_min, sts[0]->q_inp ) ); /* q_min */ + scale_sig( sts[0]->old_input_signal_fx, input_frame, sub( q_min, sts[0]->q_old_inp ) ); /* q_min */ + + sts[1]->q_old_inp = q_min; + sts[0]->q_old_inp = q_min; + sts[1]->q_inp = q_min; + sts[0]->q_inp = q_min; move16(); 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[0]->q_inp, sts[0]->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[0]->q_inp, sts[0]->q_old_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(); } @@ -823,7 +846,6 @@ ivas_error ivas_cpe_enc_fx( /*----------------------------------------------------------------* * DFT stereo: iDFT and resampling on both channels *----------------------------------------------------------------*/ - IF( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) ) { Word32 internal_Fs; @@ -846,8 +868,34 @@ ivas_error ivas_cpe_enc_fx( 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 ); +#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 ) ); + q_inp32 = add( Q15, input_norm ); + fir_delay_len = NS2SA( sts[0]->input_Fs, DELAY_FIR_RESAMPL_NS ); + move16(); + + // Find common Q-factor between { q_inp, q_old_inp and q_inp32-16 } + common_q = s_min( s_min( sub( q_inp32, 16 ), sts[0]->q_inp ), sts[0]->q_old_inp ); + + // Rescale the old input, input and FIR delay section of input buffer + scale_sig( sts[0]->old_input_signal_fx, input_frame, sub( common_q, sts[0]->q_old_inp ) ); // q_old_inp -> common_q + 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, common_q ), Q15 ) ); // Q15 -> common_q + scale_sig( sts[0]->input_fx + out_end_ind, add( sub( input_frame, out_end_ind ), fir_delay_len ), sub( common_q, sts[0]->q_inp ) ); // q_inp -> common_q + + // Update the Q-factors + sts[0]->q_inp = common_q; + 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 ); + Copy_Scale_sig_32_16( old_inp_12k8_fx[0], old_inp_12k8_16fx[0], L_INP_12k8, -Q16 ); // Q-1 /* iDFT & resampling to 16kHz internal sampling rate for M channel */ IF( EQ_32( input_Fs, internal_Fs ) ) @@ -862,6 +910,7 @@ ivas_error ivas_cpe_enc_fx( { stereo_dft_enc_synthesize_fx( hCPE->hStereoDft, old_inp_16k_fx[0] + L_INP_MEM, &out_16k_start_ind, &out_16k_end_ind, 0, input_Fs, internal_Fs, 0, NULL ); } + Copy_Scale_sig32_16( old_inp_16k_fx[0], old_inp_16k_16fx[0], L_INP, 0 ); // Q15->Q-1 /* DFT Stereo: iDFT of residual signal at 8kHz sampling rate */ test(); @@ -872,18 +921,9 @@ ivas_error ivas_cpe_enc_fx( /* update old input signal buffer */ Copy_Scale_sig_32_16( old_inp_12k8_fx[1] + L_FRAME8k, sts[1]->old_inp_12k8_fx, L_INP_MEM, 0 - 15 ); // Q0 - } - 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 - - Copy_Scale_sig32_16( old_inp_16k_fx[0], old_inp_16k_16fx[0], L_INP, 0 ); // Q15->Q-1 - /*local fix2flt*/ - /*fix2flt: dft_synthesize*/ - Copy_Scale_sig_32_16( old_inp_12k8_fx[0] + L_INP_MEM + out_12k8_start_ind[0], old_inp_12k8_16fx[0] + L_INP_MEM + out_12k8_start_ind[0], out_12k8_end_ind[0] - out_12k8_start_ind[0], -Q16 ); // Q-1 - if ( hCPE->element_mode == IVAS_CPE_DFT && hCPE->hStereoDft->res_cod_mode[STEREO_DFT_OFFSET] ) - { sts[1]->exp_old_inp_12k8 = Q15; move16(); - Copy_Scale_sig_32_16( old_inp_12k8_fx[1] + L_INP_MEM + out_12k8_start_ind[1], old_inp_12k8_16fx[1] + L_INP_MEM + out_12k8_start_ind[1], out_12k8_end_ind[1] - out_12k8_start_ind[1], -Q16 ); // Q-1 + Copy_Scale_sig_32_16( old_inp_12k8_fx[1], old_inp_12k8_16fx[1], L_INP_12k8, -Q16 ); // Q-1 } /* no iDFT at input sampling rate for Side channel -> reset the buffer */ @@ -899,13 +939,8 @@ ivas_error ivas_cpe_enc_fx( /*----------------------------------------------------------------* * Front Pre-processing *----------------------------------------------------------------*/ - FOR( n = 0; n < n_CoreChannels; n++ ) { - FOR( Word16 i = 0; i < hCPE->hCoreCoder[n]->nb_subfr; i++ ) - { - Scale_sig( &A_fx[n][i * ( M + 1 )], M + 1, sub( norm_s( A_fx[n][i * ( M + 1 )] ), 2 ) ); // scaling to Q12 - } set16_fx( old_wsp_fx[n], 0, L_WSP ); q_old_wsp = Q15; move16(); @@ -918,11 +953,16 @@ ivas_error ivas_cpe_enc_fx( { front_vad_flag = 0; } + error = pre_proc_front_ivas_fx( NULL, hCPE, hCPE->element_brate, nb_bits_metadata, input_frame, n, old_inp_12k8_16fx[n], old_inp_16k_16fx[n], &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 ) @@ -1154,7 +1194,7 @@ ivas_error ivas_cpe_enc_fx( test(); IF( !( ( EQ_16( ivas_format, MASA_FORMAT ) || EQ_16( ivas_format, MASA_ISM_FORMAT ) ) && ( EQ_32( sts[0]->core_brate, SID_2k40 ) || sts[0]->core_brate == FRAME_NO_DATA ) ) ) { - Word16 max_bits = extract_l( L_sub( Mpy_32_32_r( hCPE->element_brate, ONE_BY_FRAMES_PER_SEC_Q31 ), Mult_32_16( sts[0]->bits_frame_nominal, 26214 /* 0.8f in Q15 */ ) ) ); + Word16 max_bits = extract_l( W_extract_h( W_sub( W_mult_32_32( hCPE->element_brate, ONE_BY_FRAMES_PER_SEC_Q31 ), W_mult_32_32( L_deposit_l( sts[0]->bits_frame_nominal ), 1717986918 /* 0.8f in Q31 */ ) ) ) ); test(); IF( EQ_16( ivas_format, MASA_FORMAT ) || EQ_16( ivas_format, MASA_ISM_FORMAT ) ) { @@ -1167,7 +1207,7 @@ ivas_error ivas_cpe_enc_fx( FOR( Word16 i = 0; i < CPE_CHANNELS; i++ ) { - Copy_Scale_sig_16_32( old_inp_12k8_16fx[i], old_inp_12k8_fx[i], L_INP_12k8, Q16 + Q1 ); + Copy_Scale_sig_16_32_no_sat( old_inp_12k8_16fx[i], old_inp_12k8_fx[i], L_INP_12k8, Q16 + Q1 ); } stereo_dft_enc_res_fx( hCPE->hStereoDft, old_inp_12k8_fx[1] + L_INP_MEM - STEREO_DFT_OVL_8k, hCPE->hMetaData, &nb_bits, max_bits ); } diff --git a/lib_enc/ivas_decision_matrix_enc.c b/lib_enc/ivas_decision_matrix_enc.c index e668641dcd077ab7d75e2656bc040bbe2a44db17..b2a218620b5ebba75e5ba005e95ca0212e4245eb 100644 --- a/lib_enc/ivas_decision_matrix_enc.c +++ b/lib_enc/ivas_decision_matrix_enc.c @@ -255,10 +255,17 @@ void ivas_decision_matrix_enc_fx( { st->core = ACELP_CORE; } +#ifdef SUPPORT_FORCE_TCX10_TCX20 + else if ( st->force == FORCE_TCX20 || st->force == FORCE_TCX10 ) /* Initalizations should always happen with TCX20*/ + { + st->core = TCX_20_CORE; + } +#else else if ( st->force == FORCE_TCX ) { st->core = TCX_20_CORE; } +#endif else if ( st->force == FORCE_HQ && st->element_mode != IVAS_CPE_MDCT && element_brate >= IVAS_24k4 ) { st->core = HQ_CORE; diff --git a/lib_enc/ivas_dirac_enc.c b/lib_enc/ivas_dirac_enc.c index 58a916858f789a241ff886158dd6951e3e79d27b..017aa2904815a042a5e6b6452151b9ac661b390a 100644 --- a/lib_enc/ivas_dirac_enc.c +++ b/lib_enc/ivas_dirac_enc.c @@ -327,8 +327,8 @@ ivas_error ivas_dirac_enc_fx( const Word16 input_frame, /* i : input frame length Q0*/ const Word16 dtx_vad, /* i : DTX vad flag Q0*/ const IVAS_FORMAT ivas_format, /* i : ivas format */ - const Word16 hodirac_flag /* i : hodirac flag Q0*/ -) + const Word16 hodirac_flag, /* i : hodirac flag Q0*/ + const Word16 shift ) { Word16 orig_dirac_bands; Word32 dir_fx[3], avg_dir_fx[3]; @@ -338,18 +338,18 @@ ivas_error ivas_dirac_enc_fx( Word16 nchan_fb_in; - if ( hodirac_flag ) + IF( hodirac_flag ) { nchan_fb_in = HOA2_CHANNELS; move16(); } - else + ELSE { nchan_fb_in = FOA_CHANNELS; move16(); } - ivas_dirac_param_est_enc_fx( hDirAC, hQMetaData->q_direction, hQMetaData->useLowerRes, data_f_fx, pp_fr_real_fx, pp_fr_imag_fx, pp_fr_q, input_frame, ivas_format, hodirac_flag, nchan_fb_in, &( hDirAC->mono_frame_count ), &( hQMetaData->dirac_mono_flag ) ); + ivas_dirac_param_est_enc_fx( hDirAC, hQMetaData->q_direction, hQMetaData->useLowerRes, data_f_fx, pp_fr_real_fx, pp_fr_imag_fx, pp_fr_q, input_frame, ivas_format, hodirac_flag, nchan_fb_in, &( hDirAC->mono_frame_count ), &( hQMetaData->dirac_mono_flag ), shift ); IF( hQMetaData->q_direction->cfg.nbands > 0 ) { @@ -585,29 +585,33 @@ static Word16 ivas_dirac_get_mono_flag_fx( move16(); move16(); + Word16 gb = find_guarded_bits_fx( sub( brange[1], brange[0] ) ); + /* Loop over the W channel bins to calculate the power in the band */ FOR( j = brange[0]; j < brange[1]; j++ ) { - acc = W_mac_32_32( acc, Cldfb_RealBuffer[0][j], Cldfb_RealBuffer[0][j] ); /* exp(2 * e_Cldfb) */ - acc = W_mac_32_32( acc, Cldfb_ImagBuffer[0][j], Cldfb_ImagBuffer[0][j] ); /* exp(2 * e_Cldfb) */ - shift1 = W_norm( acc ); - W_band_power = W_extract_h( W_shl( acc, shift1 ) ); /* exp(2 * e_Cldfb - shift1) */ - W_band_power_e = sub( imult1616( (Word16) 2, e_Cldfb ), shift1 ); + acc = W_mac_32_32( acc, L_shr( Cldfb_RealBuffer[0][j], gb ), L_shr( Cldfb_RealBuffer[0][j], gb ) ); /*Q:(2*(31-e_Cldfb-gb)+1*/ + acc = W_mac_32_32( acc, L_shr( Cldfb_ImagBuffer[0][j], gb ), L_shr( Cldfb_ImagBuffer[0][j], gb ) ); /*Q:(2*(31-e_Cldfb-gb)+1*/ } + shift1 = W_norm( acc ); + W_band_power = W_extract_h( W_shl( acc, shift1 ) ); /*Q:(2*(31-e_Cldfb-gb)+1+shift1-32*/ + W_band_power_e = sub( shl( add( e_Cldfb, gb ), 1 ), shift1 ); + gb = find_guarded_bits_fx( imult1616( sub( brange[1], brange[0] ), sub( nchan_ana, 1 ) ) ); /* Loop over the other channels and bins to calculate the power in the band */ FOR( ch_idx = 1; ch_idx < nchan_ana; ch_idx++ ) { /* abs()^2 */ FOR( j = brange[0]; j < brange[1]; j++ ) { - acc1 = W_mac_32_32( acc1, Cldfb_RealBuffer[ch_idx][j], Cldfb_RealBuffer[ch_idx][j] ); /* exp(2 * e_Cldfb) */ - acc1 = W_mac_32_32( acc1, Cldfb_ImagBuffer[ch_idx][j], Cldfb_ImagBuffer[ch_idx][j] ); /* exp(2 * e_Cldfb) */ - shift2 = W_norm( acc1 ); - other_ch_band_power = W_extract_h( W_shl( acc1, shift2 ) ); /* exp(2 * e_Cldfb - shift2) */ - other_ch_band_power_e = sub( imult1616( (Word16) 2, e_Cldfb ), shift2 ); + acc1 = W_mac_32_32( acc1, L_shr( Cldfb_RealBuffer[ch_idx][j], gb ), L_shr( Cldfb_RealBuffer[ch_idx][j], gb ) ); /*Q:(2*(31-e_Cldfb-gb)+1*/ + acc1 = W_mac_32_32( acc1, L_shr( Cldfb_ImagBuffer[ch_idx][j], gb ), L_shr( Cldfb_ImagBuffer[ch_idx][j], gb ) ); /*Q:(2*(31-e_Cldfb-gb)+1*/ } } + shift2 = W_norm( acc1 ); + other_ch_band_power = W_extract_h( W_shl( acc1, shift2 ) ); /*Q:(2*(31-e_Cldfb-gb)+1+shift2-32*/ + other_ch_band_power_e = sub( shl( add( e_Cldfb, gb ), 1 ), shift2 ); + IF( BASOP_Util_Cmp_Mant32Exp( other_ch_band_power, other_ch_band_power_e, EPSILON_FX_M, EPSILON_FX_E ) < 0 ) { if ( BASOP_Util_Cmp_Mant32Exp( W_band_power, W_band_power_e, DIRAC_MONO_THRESH_SILENCE_FX, 31 ) > 0 ) @@ -841,22 +845,14 @@ void computeReferencePower_enc_fx_dirac( } } - min_norm = W_norm( reference_power_temp[0] ); - FOR( i = 0; i < num_freq_bands; i++ ) - { - min_norm = s_min( min_norm, W_norm( reference_power_temp[i] ) ); // Finding minimum norm for the right shifting of entire buffer - } - FOR( i = 0; i < num_freq_bands; i++ ) { + min_norm = W_norm( reference_power_temp[i] ); reference_power[i] = W_extract_h( W_shl( reference_power_temp[i], min_norm ) ); // Right shift with min_norm and extract high bits move32(); + e_reference[i] = sub( 31, sub( add( sub( 31, e_reference_temp ), min_norm ), 32 ) ); + move16(); } -#ifdef FIX_1127_IMPROVE_SBA_MLD - *e_reference = sub( 31, sub( add( sub( 31, e_reference_temp ), min_norm ), 32 ) ); -#else - *e_reference = sub( e_reference_temp, min_norm ); -#endif move16(); return; @@ -967,8 +963,8 @@ void ivas_dirac_param_est_enc_fx( const Word16 hodirac_flag, /* Q0 */ const Word16 nchan_fb_in, /* Q0 */ Word16 *mono_frame_count, /* Q0 */ - Word16 *dirac_mono_flag /* Q0 */ -) + Word16 *dirac_mono_flag, /* Q0 */ + const Word16 shift ) { Word16 i, j, k, d, ts, index, l_ts, num_freq_bands; Word16 band_m_idx, block_m_idx; @@ -990,7 +986,7 @@ void ivas_dirac_param_est_enc_fx( Word32 diffuseness_vector_fx[DIRAC_MAX_NBANDS]; Word16 diffuseness_vector_q; Word32 renormalization_factor_fx[DIRAC_MAX_NBANDS]; - Word16 renormalization_factor_exp; + Word16 renormalization_factor_exp[DIRAC_MAX_NBANDS]; Word32 renormalization_factor_diff_fx[DIRAC_MAX_NBANDS]; Word16 renormalization_factor_diff_exp[DIRAC_MAX_NBANDS]; Word32 norm_tmp_fx; @@ -998,7 +994,7 @@ void ivas_dirac_param_est_enc_fx( Word16 mrange[2]; Word16 num_blocks; Word32 reference_power_fx[CLDFB_NO_COL_MAX][DIRAC_NO_FB_BANDS_MAX]; - Word16 reference_power_exp; + Word16 reference_power_exp[CLDFB_NO_COL_MAX][DIRAC_NO_FB_BANDS_MAX]; Word32 azi_secs_fx[2 * DIRAC_MAX_ANA_CHANS * DIRAC_MAX_NBANDS]; Word32 ele_secs_fx[2 * DIRAC_MAX_ANA_CHANS * DIRAC_MAX_NBANDS]; Word32 diff_secs_fx[2 * DIRAC_MAX_ANA_CHANS * DIRAC_MAX_NBANDS]; @@ -1045,8 +1041,10 @@ void ivas_dirac_param_est_enc_fx( set16_zero_fx( hDirAC->diffuseness_m_exp, hDirAC->hConfig->nbands ); set_zero_fx( renormalization_factor_diff_fx, hDirAC->hConfig->nbands ); set16_zero_fx( renormalization_factor_diff_exp, hDirAC->hConfig->nbands ); - reference_power_exp = 0; - move16(); + FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) + { + set16_zero_fx( reference_power_exp[i], DIRAC_NO_FB_BANDS_MAX ); + } set_zero_fx( azi_secs_fx, 2 * DIRAC_MAX_ANA_CHANS * DIRAC_MAX_NBANDS ); set_zero_fx( ele_secs_fx, 2 * DIRAC_MAX_ANA_CHANS * DIRAC_MAX_NBANDS ); @@ -1072,11 +1070,20 @@ void ivas_dirac_param_est_enc_fx( move16(); set32_fx( renormalization_factor_fx, EPSILON_FX, hDirAC->hConfig->nbands ); - renormalization_factor_exp = 0; - move16(); + set16_fx( renormalization_factor_exp, 0, hDirAC->hConfig->nbands ); set_zero_fx( hDirAC->direction_vector_m_fx[0][block_m_idx], hDirAC->hConfig->nbands ); set_zero_fx( hDirAC->direction_vector_m_fx[1][block_m_idx], hDirAC->hConfig->nbands ); set_zero_fx( hDirAC->direction_vector_m_fx[2][block_m_idx], hDirAC->hConfig->nbands ); + Word64 dir[DIRAC_NUM_DIMS][DIRAC_MAX_NBANDS]; + Word16 direction_vector_exp_tmp[DIRAC_NUM_DIMS][MAX_PARAM_SPATIAL_SUBFRAMES][DIRAC_MAX_NBANDS] = { 0 }; + FOR( i = 0; i < DIRAC_NUM_DIMS; i++ ) + { + set64_fx( dir[i], 0, DIRAC_MAX_NBANDS ); + FOR( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) + { + set16_fx( direction_vector_exp_tmp[i][j], 0, DIRAC_MAX_NBANDS ); + } + } hDirAC->direction_vector_m_exp[block_m_idx] = 0; move16(); @@ -1084,8 +1091,17 @@ void ivas_dirac_param_est_enc_fx( { IF( hDirAC->hFbMixer ) { + FOR( i = 0; i < nchan_fb_in; i++ ) + { + scale_sig32( pcm_in_fx[i], input_frame, shift ); // Q:Qx+shift + scale_sig32( hDirAC->hFbMixer->ppFilterbank_prior_input_fx[i], hDirAC->hFbMixer->fb_cfg->prior_input_length, shift ); // Q:Qx+shift + } ivas_fb_mixer_get_windowed_fr_fx( hDirAC->hFbMixer, pcm_in_fx, p_Cldfb_RealBuffer_fx, p_Cldfb_ImagBuffer_fx, l_ts, l_ts, hDirAC->hFbMixer->fb_cfg->num_in_chans, 0 ); - + FOR( i = 0; i < nchan_fb_in; i++ ) + { + scale_sig32( pcm_in_fx[i], input_frame, negate( shift ) ); // Q:Qx + scale_sig32( hDirAC->hFbMixer->ppFilterbank_prior_input_fx[i], hDirAC->hFbMixer->fb_cfg->prior_input_length, negate( shift ) ); // Q:Qx + } ivas_fb_mixer_update_prior_input_fx( hDirAC->hFbMixer, pcm_in_fx, l_ts, hDirAC->hFbMixer->fb_cfg->num_in_chans ); FOR( i = 0; i < nchan_fb_in; i++ ) @@ -1118,7 +1134,7 @@ void ivas_dirac_param_est_enc_fx( Cldfb_ImagBuffer_fx, sub( 31, cldfb_q ), reference_power_fx[ts], - &reference_power_exp, + reference_power_exp[ts], hDirAC->hConfig->enc_param_start_band, num_freq_bands, ivas_format, @@ -1183,7 +1199,11 @@ void ivas_dirac_param_est_enc_fx( #endif } Copy32( reference_power_fx[ts], &( hDirAC->buffer_energy_fx[( index - 1 ) * num_freq_bands] ), num_freq_bands ); /* exp(reference_power_exp) */ - set16_fx( &hDirAC->buffer_energy_q[( index - 1 ) * num_freq_bands], sub( 31, reference_power_exp ), num_freq_bands ); + FOR( i = 0; i < num_freq_bands; i++ ) + { + hDirAC->buffer_energy_q[( index - 1 ) * num_freq_bands + i] = sub( 31, reference_power_exp[ts][i] ); + move16(); + } Word16 buffer_intensity_real_single_q; buffer_intensity_real_single_q = hDirAC->buffer_intensity_real_q[0][0][0]; @@ -1251,17 +1271,15 @@ void ivas_dirac_param_est_enc_fx( ene_secs_exp ); } - const Word16 gbits = 4; // 4 guard bits - move16(); IF( hodirac_flag ) { FOR( band_m_idx = 0; band_m_idx < hDirAC->hConfig->nbands; band_m_idx++ ) { Word32 tmp_diff = L_shr( diffuseness_vector_fx[band_m_idx], sub( diffuseness_vector_q, 30 ) ); // diffueseness_vector_q -> Q30 hDirAC->diffuseness_m_fx[band_m_idx] = BASOP_Util_Add_Mant32Exp( hDirAC->diffuseness_m_fx[band_m_idx], hDirAC->diffuseness_m_exp[band_m_idx], - Mpy_32_32( reference_power_fx[ts][band_m_idx], tmp_diff ), add( reference_power_exp, 1 ), &hDirAC->diffuseness_m_exp[band_m_idx] ); /* exp(hDirAC->diffuseness_m_exp) */ + Mpy_32_32( reference_power_fx[ts][band_m_idx], tmp_diff ), add( reference_power_exp[ts][band_m_idx], 1 ), &hDirAC->diffuseness_m_exp[band_m_idx] ); /* exp(hDirAC->diffuseness_m_exp) */ move32(); - renormalization_factor_diff_fx[band_m_idx] = BASOP_Util_Add_Mant32Exp( renormalization_factor_diff_fx[band_m_idx], renormalization_factor_diff_exp[band_m_idx], reference_power_fx[ts][band_m_idx], reference_power_exp, &renormalization_factor_diff_exp[band_m_idx] ); /* exp(renormalization_factor_diff_exp) */ + renormalization_factor_diff_fx[band_m_idx] = BASOP_Util_Add_Mant32Exp( renormalization_factor_diff_fx[band_m_idx], renormalization_factor_diff_exp[band_m_idx], reference_power_fx[ts][band_m_idx], reference_power_exp[ts][band_m_idx], &renormalization_factor_diff_exp[band_m_idx] ); /* exp(renormalization_factor_diff_exp) */ move32(); } } @@ -1270,27 +1288,48 @@ void ivas_dirac_param_est_enc_fx( FOR( band_m_idx = 0; band_m_idx < hDirAC->hConfig->nbands; band_m_idx++ ) { Word32 tmp_diff = L_shr( diffuseness_vector_fx[band_m_idx], sub( diffuseness_vector_q, 30 ) ); // diffueseness_vector_q -> Q30 + norm_tmp_exp = add( reference_power_exp[ts][band_m_idx], 1 ); norm_tmp_fx = Mpy_32_32( reference_power_fx[ts][band_m_idx], L_sub( ONE_IN_Q30, tmp_diff ) ); - hDirAC->direction_vector_m_fx[0][block_m_idx][band_m_idx] = L_add( hDirAC->direction_vector_m_fx[0][block_m_idx][band_m_idx], L_shr( Mpy_32_32( norm_tmp_fx, direction_vector_fx[0][band_m_idx] ), gbits ) ); /* norm_tmp_exp + ( 31 - direction_vector_q ) + gbits */ + dir[0][band_m_idx] = W_mult_32_32( norm_tmp_fx, direction_vector_fx[0][band_m_idx] ); + move64(); + dir[1][band_m_idx] = W_mult_32_32( norm_tmp_fx, direction_vector_fx[1][band_m_idx] ); + move64(); + dir[2][band_m_idx] = W_mult_32_32( norm_tmp_fx, direction_vector_fx[2][band_m_idx] ); + move64(); + Word16 norm = 62; + move16(); + IF( dir[0][band_m_idx] != 0 ) + { + norm = W_norm( dir[0][band_m_idx] ); + } + IF( dir[1][band_m_idx] != 0 ) + { + norm = s_min( norm, W_norm( dir[1][band_m_idx] ) ); + } + IF( dir[2][band_m_idx] != 0 ) + { + norm = s_min( norm, W_norm( dir[2][band_m_idx] ) ); + } + Word32 tmp = W_extract_h( W_shl( dir[0][band_m_idx], norm ) ); + Word16 tmp_e = sub( Q31, add( sub( direction_vector_q, norm_tmp_exp ), sub( norm, 0 ) ) ); + hDirAC->direction_vector_m_fx[0][block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hDirAC->direction_vector_m_fx[0][block_m_idx][band_m_idx], direction_vector_exp_tmp[0][block_m_idx][band_m_idx], tmp, tmp_e, &direction_vector_exp_tmp[0][block_m_idx][band_m_idx] ); move32(); - hDirAC->direction_vector_m_fx[1][block_m_idx][band_m_idx] = L_add( hDirAC->direction_vector_m_fx[1][block_m_idx][band_m_idx], L_shr( Mpy_32_32( norm_tmp_fx, direction_vector_fx[1][band_m_idx] ), gbits ) ); /* norm_tmp_exp + ( 31 - direction_vector_q ) + gbits */ + tmp = W_extract_h( W_shl( dir[1][band_m_idx], norm ) ); + hDirAC->direction_vector_m_fx[1][block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hDirAC->direction_vector_m_fx[1][block_m_idx][band_m_idx], direction_vector_exp_tmp[1][block_m_idx][band_m_idx], tmp, tmp_e, &direction_vector_exp_tmp[1][block_m_idx][band_m_idx] ); move32(); - hDirAC->direction_vector_m_fx[2][block_m_idx][band_m_idx] = L_add( hDirAC->direction_vector_m_fx[2][block_m_idx][band_m_idx], L_shr( Mpy_32_32( norm_tmp_fx, direction_vector_fx[2][band_m_idx] ), gbits ) ); /* norm_tmp_exp + ( 31 - direction_vector_q ) + gbits */ + tmp = W_extract_h( W_shl( dir[2][band_m_idx], norm ) ); + hDirAC->direction_vector_m_fx[2][block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hDirAC->direction_vector_m_fx[2][block_m_idx][band_m_idx], direction_vector_exp_tmp[2][block_m_idx][band_m_idx], tmp, tmp_e, &direction_vector_exp_tmp[2][block_m_idx][band_m_idx] ); move32(); - renormalization_factor_fx[band_m_idx] = L_add( renormalization_factor_fx[band_m_idx], L_shr( norm_tmp_fx, gbits ) ); /* exp(norm_tmp_exp + gbits) */ + renormalization_factor_fx[band_m_idx] = BASOP_Util_Add_Mant32Exp( renormalization_factor_fx[band_m_idx], renormalization_factor_exp[band_m_idx], norm_tmp_fx, norm_tmp_exp, &renormalization_factor_exp[band_m_idx] ); /* exp(norm_tmp_exp + gbits) */ move32(); hDirAC->diffuseness_m_fx[band_m_idx] = BASOP_Util_Add_Mant32Exp( hDirAC->diffuseness_m_fx[band_m_idx], hDirAC->diffuseness_m_exp[band_m_idx], - Mpy_32_32( reference_power_fx[ts][band_m_idx], tmp_diff ), add( reference_power_exp, 1 ), &hDirAC->diffuseness_m_exp[band_m_idx] ); /* exp(hDirAC->diffuseness_m_exp) */ + Mpy_32_32( reference_power_fx[ts][band_m_idx], tmp_diff ), add( reference_power_exp[ts][band_m_idx], 1 ), &hDirAC->diffuseness_m_exp[band_m_idx] ); /* exp(hDirAC->diffuseness_m_exp) */ move32(); renormalization_factor_diff_fx[band_m_idx] = BASOP_Util_Add_Mant32Exp( renormalization_factor_diff_fx[band_m_idx], renormalization_factor_diff_exp[band_m_idx], - reference_power_fx[ts][band_m_idx], reference_power_exp, &renormalization_factor_diff_exp[band_m_idx] ); /* exp(renormalization_factor_diff_exp) */ + reference_power_fx[ts][band_m_idx], reference_power_exp[ts][band_m_idx], &renormalization_factor_diff_exp[band_m_idx] ); /* exp(renormalization_factor_diff_exp) */ move32(); } - norm_tmp_exp = add( reference_power_exp, 1 ); - hDirAC->direction_vector_m_exp[block_m_idx] = add( norm_tmp_exp, add( sub( 31, direction_vector_q ), gbits ) ); - move32(); - renormalization_factor_exp = add( norm_tmp_exp, gbits ); } } @@ -1300,40 +1339,50 @@ void ivas_dirac_param_est_enc_fx( { renormalization_factor_fx[band_m_idx] = EPSILON_FX; move32(); - renormalization_factor_fx[band_m_idx] = L_add( renormalization_factor_fx[band_m_idx], Mpy_32_32( hDirAC->direction_vector_m_fx[0][block_m_idx][band_m_idx], hDirAC->direction_vector_m_fx[0][block_m_idx][band_m_idx] ) ); /* norm_tmp_exp + ( 31 - direction_vector_q ) + gbits */ + renormalization_factor_exp[band_m_idx] = 0; + move16(); + Word16 tmp_e = shl( direction_vector_exp_tmp[0][block_m_idx][band_m_idx], 1 ); + renormalization_factor_fx[band_m_idx] = BASOP_Util_Add_Mant32Exp( renormalization_factor_fx[band_m_idx], renormalization_factor_exp[band_m_idx], Mpy_32_32( hDirAC->direction_vector_m_fx[0][block_m_idx][band_m_idx], hDirAC->direction_vector_m_fx[0][block_m_idx][band_m_idx] ), tmp_e, &renormalization_factor_exp[band_m_idx] ); /* norm_tmp_exp + ( 31 - direction_vector_q ) + gbits */ move32(); - renormalization_factor_fx[band_m_idx] = L_add( renormalization_factor_fx[band_m_idx], Mpy_32_32( hDirAC->direction_vector_m_fx[1][block_m_idx][band_m_idx], hDirAC->direction_vector_m_fx[1][block_m_idx][band_m_idx] ) ); /* norm_tmp_exp + ( 31 - direction_vector_q ) + gbits */ + tmp_e = shl( direction_vector_exp_tmp[1][block_m_idx][band_m_idx], 1 ); + renormalization_factor_fx[band_m_idx] = BASOP_Util_Add_Mant32Exp( renormalization_factor_fx[band_m_idx], renormalization_factor_exp[band_m_idx], Mpy_32_32( hDirAC->direction_vector_m_fx[1][block_m_idx][band_m_idx], hDirAC->direction_vector_m_fx[1][block_m_idx][band_m_idx] ), tmp_e, &renormalization_factor_exp[band_m_idx] ); /* norm_tmp_exp + ( 31 - direction_vector_q ) + gbits */ move32(); - renormalization_factor_fx[band_m_idx] = L_add( renormalization_factor_fx[band_m_idx], Mpy_32_32( hDirAC->direction_vector_m_fx[2][block_m_idx][band_m_idx], hDirAC->direction_vector_m_fx[2][block_m_idx][band_m_idx] ) ); /* norm_tmp_exp + ( 31 - direction_vector_q ) + gbits */ + tmp_e = shl( direction_vector_exp_tmp[2][block_m_idx][band_m_idx], 1 ); + renormalization_factor_fx[band_m_idx] = BASOP_Util_Add_Mant32Exp( renormalization_factor_fx[band_m_idx], renormalization_factor_exp[band_m_idx], Mpy_32_32( hDirAC->direction_vector_m_fx[2][block_m_idx][band_m_idx], hDirAC->direction_vector_m_fx[2][block_m_idx][band_m_idx] ), tmp_e, &renormalization_factor_exp[band_m_idx] ); /* norm_tmp_exp + ( 31 - direction_vector_q ) + gbits */ move32(); - renormalization_factor_exp = shl( hDirAC->direction_vector_m_exp[block_m_idx], 1 ); // 2 * direction_vector_m_exp - renormalization_factor_fx[band_m_idx] = Sqrt32( renormalization_factor_fx[band_m_idx], &renormalization_factor_exp ); + IF( renormalization_factor_fx[band_m_idx] == 0 ) + { + renormalization_factor_fx[band_m_idx] = EPSILON_FX; + move32(); + renormalization_factor_exp[band_m_idx] = 0; + move16(); + } + renormalization_factor_fx[band_m_idx] = Sqrt32( renormalization_factor_fx[band_m_idx], &renormalization_factor_exp[band_m_idx] ); move32(); IF( GT_32( renormalization_factor_fx[band_m_idx], EPSILON_FX ) ) { - Word16 tmp_e; Word32 tmp32; tmp32 = hDirAC->direction_vector_m_fx[0][block_m_idx][band_m_idx]; move32(); tmp32 = L_deposit_h( BASOP_Util_Divide3232_Scale( tmp32, renormalization_factor_fx[band_m_idx], &tmp_e ) ); /* exp(tmp_e + ( hDirAC->direction_vector_m_exp[block_m_idx] - renormalization_factor_exp)) */ - tmp_e = add( tmp_e, sub( hDirAC->direction_vector_m_exp[block_m_idx], renormalization_factor_exp ) ); - hDirAC->direction_vector_m_fx[0][block_m_idx][band_m_idx] = L_shr( tmp32, sub( 1, tmp_e ) ); // Q30 + tmp_e = add( tmp_e, sub( direction_vector_exp_tmp[0][block_m_idx][band_m_idx], renormalization_factor_exp[band_m_idx] ) ); + hDirAC->direction_vector_m_fx[0][block_m_idx][band_m_idx] = L_shr_sat( tmp32, sub( 1, tmp_e ) ); // Q30 saturation needs to check move32(); tmp32 = hDirAC->direction_vector_m_fx[1][block_m_idx][band_m_idx]; // Q30 move32(); tmp32 = L_deposit_h( BASOP_Util_Divide3232_Scale( tmp32, renormalization_factor_fx[band_m_idx], &tmp_e ) ); /* exp(tmp_e + ( hDirAC->direction_vector_m_exp[block_m_idx] - renormalization_factor_exp)) */ - tmp_e = add( tmp_e, sub( hDirAC->direction_vector_m_exp[block_m_idx], renormalization_factor_exp ) ); - hDirAC->direction_vector_m_fx[1][block_m_idx][band_m_idx] = L_shr( tmp32, sub( 1, tmp_e ) ); // Q30 + tmp_e = add( tmp_e, sub( direction_vector_exp_tmp[1][block_m_idx][band_m_idx], renormalization_factor_exp[band_m_idx] ) ); + hDirAC->direction_vector_m_fx[1][block_m_idx][band_m_idx] = L_shr_sat( tmp32, sub( 1, tmp_e ) ); // Q30 saturation needs to check move32(); tmp32 = hDirAC->direction_vector_m_fx[2][block_m_idx][band_m_idx]; // Q30 move32(); tmp32 = L_deposit_h( BASOP_Util_Divide3232_Scale( tmp32, renormalization_factor_fx[band_m_idx], &tmp_e ) ); /* exp(tmp_e + ( hDirAC->direction_vector_m_exp[block_m_idx] - renormalization_factor_exp)) */ - tmp_e = add( tmp_e, sub( hDirAC->direction_vector_m_exp[block_m_idx], renormalization_factor_exp ) ); - hDirAC->direction_vector_m_fx[2][block_m_idx][band_m_idx] = L_shr( tmp32, sub( 1, tmp_e ) ); // Q30 + tmp_e = add( tmp_e, sub( direction_vector_exp_tmp[2][block_m_idx][band_m_idx], renormalization_factor_exp[band_m_idx] ) ); + hDirAC->direction_vector_m_fx[2][block_m_idx][band_m_idx] = L_shr_sat( tmp32, sub( 1, tmp_e ) ); // Q30 saturation needs to check move32(); } ELSE @@ -1345,8 +1394,6 @@ void ivas_dirac_param_est_enc_fx( hDirAC->direction_vector_m_fx[2][block_m_idx][band_m_idx] = 0; move32(); } - hDirAC->direction_vector_m_exp[block_m_idx] = 1; - move16(); /* save the elevation and azimuth values to be used later by the ivas_dirac_QuantizeParameters function */ FOR( d = 0; d < DIRAC_NUM_DIMS; d++ ) @@ -1367,6 +1414,8 @@ void ivas_dirac_param_est_enc_fx( &q_direction->band_data[band_m_idx].azimuth_fx[block_m_idx], &q_direction->band_data[band_m_idx].elevation_fx[block_m_idx] ); } + hDirAC->direction_vector_m_exp[block_m_idx] = 1; + move16(); } /* Sectors */ diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c index 95cafd8ff37212c36822565bdd641c9296d56731..a7fb7146130327a5c8b98fd6cc89395c60faa857 100644 --- a/lib_enc/ivas_enc.c +++ b/lib_enc/ivas_enc.c @@ -135,7 +135,7 @@ ivas_error ivas_enc_fx( IF( EQ_32( ivas_format, SBA_FORMAT ) ) { - IF( ( error = ivas_sba_enc_reconfigure( st_ivas ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_sba_enc_reconfigure_fx( st_ivas ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_enc/ivas_enc_cov_handler.c b/lib_enc/ivas_enc_cov_handler.c index 7f08778781cb9a3d5d14867f087b6751b8aaa312..5c19d8e02de9052305c9c3746018a113f903b0a8 100644 --- a/lib_enc/ivas_enc_cov_handler.c +++ b/lib_enc/ivas_enc_cov_handler.c @@ -513,9 +513,11 @@ static void ivas_band_cov_fx( Word32 pV_re[L_FRAME48k]; Word64 pV_re_64bit[L_FRAME48k]; Word64 cov_real_64bit[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH][IVAS_MAX_NUM_BANDS]; - Word16 q_shift; + Word16 q_shift, q_shift_tmp; Word16 m, start_bin, active_bins; + Word16 num_blocks; + num_blocks = idiv1616( num_bins, stride ); /* Q0 */ FOR( i = 0; i < num_chans; i++ ) { FOR( j = i; j < num_chans; j++ ) @@ -536,17 +538,19 @@ static void ivas_band_cov_fx( move16(); FOR( k = 0; k < num_bins; k++ ) { - IF( pV_re_64bit[k] != 0 ) + q_shift_tmp = W_norm( pV_re_64bit[k] ); + if ( pV_re_64bit[k] != 0 ) { - q_shift = s_min( q_shift, W_norm( pV_re_64bit[k] ) ); + q_shift = s_min( q_shift, q_shift_tmp ); } } + q_shift_tmp = sub( q_shift, 32 ); FOR( k = 0; k < num_bins; k++ ) { - pV_re[k] = W_extract_l( W_shl_nosat( pV_re_64bit[k], sub( q_shift, 32 ) ) ); //(q_In_FR[i1] + q_In_FR[j1]) + (q_shift - 32) + pV_re[k] = W_extract_l( W_shl_nosat( pV_re_64bit[k], q_shift_tmp ) ); //(q_In_FR[i1] + q_In_FR[j1]) + (q_shift - 32) move32(); /* perform rounding towards lower value for negative results */ - IF( pV_re[k] < 0 ) + if ( pV_re[k] < 0 ) { pV_re[k] = L_add( pV_re[k], 1 ); } @@ -556,31 +560,32 @@ static void ivas_band_cov_fx( { Word64 temp; const Word32 *p_bin_to_band = pFb_bin_to_band[k]; // Q22 - Word32 *cov_ptr = pV_re; - Word16 num_blocks; + Word32 *cov_ptr; Word16 blk; temp = 0; move64(); - num_blocks = idiv1616( num_bins, stride ); /* Q0 */ - move16(); start_bin = pFb_start_bin_per_band[k]; /* Q0 */ move16(); active_bins = pFb_active_bins_per_band[k]; /* Q0 */ move16(); + cov_ptr = &pV_re[start_bin]; + move16(); FOR( blk = 0; blk < num_blocks; blk++ ) { /* optional: add temporal weight here */ - FOR( m = start_bin; m < add( start_bin, active_bins ); m++ ) + FOR( m = 0; m < active_bins; m++ ) { - temp = W_add( temp, W_mult0_32_32( cov_ptr[m], p_bin_to_band[sub( m, start_bin )] ) ); // ((q_In_FR[i1] + q_In_FR[j1]) + (q_shift - 32), Q22) -> (q_In_FR[i1] + q_In_FR[j1] + (q_shift - 10) + temp = W_add( temp, W_mult0_32_32( cov_ptr[m], p_bin_to_band[m] ) ); // ((q_In_FR[i1] + q_In_FR[j1]) + (q_shift - 32), Q22) -> (q_In_FR[i1] + q_In_FR[j1] + (q_shift - 10) } cov_ptr += stride; + move16(); } // What basop to add below???? cov_real_64bit[i][j][k] = temp * (Word64) ( num_blocks ); // (q_In_FR[i1] + q_In_FR[j1] + (q_shift - 10) - guard_bits move64(); + move64(); // conservative estimation of a 64 bit multiplication } q_cov_real[i][j] = add( add( q_In_FR, q_In_FR ), sub( q_shift, Q10 ) ); move16(); @@ -595,17 +600,19 @@ static void ivas_band_cov_fx( move16(); FOR( k = start_band; k < end_band; k++ ) { - IF( cov_real_64bit[i][j][k] != 0 ) + q_shift_tmp = W_norm( cov_real_64bit[i][j][k] ); + if ( cov_real_64bit[i][j][k] != 0 ) { - q_shift = s_min( q_shift, W_norm( cov_real_64bit[i][j][k] ) ); + q_shift = s_min( q_shift, q_shift_tmp ); } } + q_shift_tmp = sub( q_shift, 32 ); FOR( k = start_band; k < end_band; k++ ) { - cov_real[i][j][k] = W_extract_l( W_shl_nosat( cov_real_64bit[i][j][k], sub( q_shift, 32 ) ) ); /* q_cov_real[i][j] + q_shift - 32 */ + cov_real[i][j][k] = W_extract_l( W_shl_nosat( cov_real_64bit[i][j][k], q_shift_tmp ) ); /* q_cov_real[i][j] + q_shift - 32 */ move32(); } - q_cov_real[i][j] = add( q_cov_real[i][j], sub( q_shift, 32 ) ); + q_cov_real[i][j] = add( q_cov_real[i][j], q_shift_tmp ); move16(); } } diff --git a/lib_enc/ivas_front_vad.c b/lib_enc/ivas_front_vad.c index d5be6f0605c17cce4b431384e2978b65e8a4f3de..f52bdadb460c4bca9fedea4aab0ca732f65a2455 100644 --- a/lib_enc/ivas_front_vad.c +++ b/lib_enc/ivas_front_vad.c @@ -282,13 +282,7 @@ ivas_error front_vad_fx( noise_est_pre_32fx( Etot_fx, hFrontVads[0]->ini_frame, hFrontVad->hNoiseEst, 0, 0, 0 ); /* wb_vad */ - Word16 scale = add( hFrontVads[n]->hNoiseEst->q_bckr, L_norm_arr( hFrontVads[n]->hNoiseEst->bckr_fx, NB_BANDS ) ); - scale = s_min( scale, add( hFrontVads[n]->hNoiseEst->q_enrO, L_norm_arr( hFrontVads[n]->hNoiseEst->enrO_fx, NB_BANDS ) ) ); - scale = s_min( q_fr_bands[n], scale ); - - scale_sig32( hFrontVads[n]->hNoiseEst->bckr_fx, NB_BANDS, sub( scale, hFrontVads[n]->hNoiseEst->q_bckr ) ); // scale - hFrontVads[n]->hNoiseEst->q_bckr = scale; - move16(); + Word16 scale = s_min( q_fr_bands[n], add( hFrontVads[n]->hNoiseEst->q_enrO, L_norm_arr( hFrontVads[n]->hNoiseEst->enrO_fx, NB_BANDS ) ) ); scale_sig32( hFrontVads[n]->hNoiseEst->enrO_fx, NB_BANDS, sub( scale, hFrontVads[n]->hNoiseEst->q_enrO ) ); // scale hFrontVads[n]->hNoiseEst->q_enrO = scale; @@ -652,7 +646,12 @@ ivas_error front_vad_spar_fx( &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 */ diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index 02219c4e3273fc1566050cc7cf44c363c166ea16..c87fe7fc0191a9089124853c2347e675d07fb510 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -36,6 +36,7 @@ #include "ivas_cnst.h" #include "prot.h" #include "ivas_prot.h" +#include "ivas_prot_fx.h" #include "ivas_stat_enc.h" #include "ivas_rom_com.h" #include "wmc_auto.h" @@ -611,7 +612,7 @@ ivas_error ivas_init_encoder( } ELSE { - IF( ( error = create_evs_sce_enc( 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; } @@ -1212,7 +1213,7 @@ ivas_error ivas_init_encoder_fx( test(); IF( st_ivas->hEncoderConfig->element_mode_init == EVS_MONO ) { - IF( ( error = create_evs_sce_enc( 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; } @@ -2013,7 +2014,7 @@ void ivas_destroy_enc_fx( { if ( st_ivas->hSCE[i] != NULL ) { - destroy_sce_enc( st_ivas->hSCE[i], EQ_16( st_ivas->hEncoderConfig->element_mode_init, EVS_MONO ) ); + destroy_sce_enc_fx( st_ivas->hSCE[i], EQ_16( st_ivas->hEncoderConfig->element_mode_init, EVS_MONO ) ); st_ivas->hSCE[i] = NULL; } } diff --git a/lib_enc/ivas_ism_dtx_enc.c b/lib_enc/ivas_ism_dtx_enc.c index 68325273e092f1c9608c867abaef91c9e31f293c..f098dc0e4aa3a1f449e23ea3918334ff0aaea699 100644 --- a/lib_enc/ivas_ism_dtx_enc.c +++ b/lib_enc/ivas_ism_dtx_enc.c @@ -417,7 +417,7 @@ void ivas_ism_get_sce_id_dtx_fx( move16(); FOR( j = 1; j < nchan_transport; j++ ) { - if ( BASOP_Util_Cmp_Mant32Exp( tmp_energy[j], tmp_energy_e[j], tmp_energy[hISMDTX->sce_id_dtx], tmp_energy_e[hISMDTX->sce_id_dtx] ) ) + IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( tmp_energy[j], tmp_energy_e[j], tmp_energy[hISMDTX->sce_id_dtx], tmp_energy_e[hISMDTX->sce_id_dtx] ), 1 ) ) { hISMDTX->sce_id_dtx = j; move16(); diff --git a/lib_enc/ivas_ism_enc.c b/lib_enc/ivas_ism_enc.c index 70b049ba89110576b55a554c26615c3f1a0038c3..a8956fd012d29a86d7a128ab79b9591871c38548 100644 --- a/lib_enc/ivas_ism_enc.c +++ b/lib_enc/ivas_ism_enc.c @@ -249,7 +249,11 @@ 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 @@ -284,7 +288,11 @@ ivas_error ivas_ism_enc_fx( test(); IF( st_ivas->hSCE[j] && st_ivas->hSCE[j]->hCoreCoder[0] ) { - Copy_Scale_sig_16_32( 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 */ +#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(); } diff --git a/lib_enc/ivas_ism_metadata_enc.c b/lib_enc/ivas_ism_metadata_enc.c index ef410b59c9ebb1b65c96129b78d95c8f552b1367..3d18bb5ec99a9c650e288fa0b2ef4412c0b42250 100644 --- a/lib_enc/ivas_ism_metadata_enc.c +++ b/lib_enc/ivas_ism_metadata_enc.c @@ -317,7 +317,10 @@ 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,6 +653,10 @@ 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 { @@ -817,6 +824,10 @@ 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_ism_param_enc.c b/lib_enc/ivas_ism_param_enc.c index 3169962f50970a32ff501b135766ea6da13223fd..1430607d63c1a7d7f103bf877c38327641aae61a 100644 --- a/lib_enc/ivas_ism_param_enc.c +++ b/lib_enc/ivas_ism_param_enc.c @@ -374,8 +374,8 @@ void ivas_param_ism_stereo_dmx_fx( tmp_1 = W_norm( ene_data ); tmp_2 = W_norm( ene_dmx ); ene_data = W_shl( ene_data, tmp_1 ); - ene_dmx = W_add( W_shl( ene_dmx, tmp_2 ), 1 ); - dmx_gain = BASOP_Util_Divide3232_Scale( W_extract_h( ene_data ), W_extract_h( ene_dmx ), &dmx_gain_e ); + ene_dmx = W_shl( ene_dmx, tmp_2 ); + dmx_gain = BASOP_Util_Divide3232_Scale( W_extract_h( ene_data ), L_add_sat( W_extract_h( ene_dmx ), 1 ), &dmx_gain_e ); dmx_gain_e = sub( dmx_gain_e, sub( tmp_1, tmp_2 ) ); dmx_gain = Sqrt16( dmx_gain, &dmx_gain_e ); diff --git a/lib_enc/ivas_masa_enc.c b/lib_enc/ivas_masa_enc.c index 543897b8542fc9365bc5a48b127ea9427ef03c4d..583a37006e814324e8f3a3755f02ed83051b76a8 100644 --- a/lib_enc/ivas_masa_enc.c +++ b/lib_enc/ivas_masa_enc.c @@ -2364,7 +2364,16 @@ static void reduce_metadata_further_fx( } } - tmp2 = W_norm( W_tmp ); + IF( W_tmp != 0 ) + { + tmp2 = sub( W_norm( W_tmp ), 1 ); // Usage of guard bits to avoid the large values of onset_detector in multiplication + } + ELSE + { + tmp2 = 0; + move16(); + } + tmp2 = s_min( 32, tmp2 ); totalEnergySum = W_extract_h( W_shl( W_tmp, tmp2 ) ); tmp2 = sub( tmp2, 32 ); @@ -2500,6 +2509,8 @@ static void reduce_metadata_further_fx( Word32 x, y, z; Word32 veclen, L_tmp; + W_tmp = 0; + move64(); FOR( band = 0; band < numCodingBands; band++ ) { xSum = 0; @@ -2528,9 +2539,14 @@ static void reduce_metadata_further_fx( ySum = L_add( ySum, y ); zSum = L_add( zSum, z ); - bandSumEnergy = L_add( bandSumEnergy, energy[sf][band] ); + W_tmp = W_add( W_tmp, energy[sf][band] ); } + tmp2 = W_norm( W_tmp ); + tmp2 = s_min( 32, tmp2 ); + bandSumEnergy = W_extract_h( W_shl( W_tmp, tmp2 ) ); + tmp2 = sub( add( hMasa->data.q_energy, tmp2 ), 32 ); + aziRad = BASOP_util_atan2( ySum, xSum, 0 ); // Q13 W_xSum_sq = W_mult0_32_32( xSum, xSum ); // 2 * hMasa->data.q_energy - Q6 W_ySum_sq = W_mult0_32_32( ySum, ySum ); // 2 * hMasa->data.q_energy - Q6 @@ -2558,6 +2574,7 @@ static void reduce_metadata_further_fx( } // hqmetadata->q_direction[0].coherence_band_data[band].spread_coherence[0] = (uint8_t) roundf( spreadCohSum / ( bandSumEnergy + EPSILON ) * 255.0f ); tmp = BASOP_Util_Divide3232_Scale( spreadCohSum, bandSumEnergy, &exp ); + exp = add( exp, sub( tmp2, hMasa->data.q_energy ) ); tmp = mult_r( tmp, 32640 /* 255 in Q7 */ ); // 15 - exp + 7 - 15 => 7 - exp hqmetadata->q_direction[0].coherence_band_data[band].spread_coherence[0] = (UWord8) shr( tmp, sub( 7, exp ) ); // Q0 move16(); diff --git a/lib_enc/ivas_mc_param_enc.c b/lib_enc/ivas_mc_param_enc.c index 63b5862ca32240041ab0f9fa191c62ac33633175..43162f6debf18e4b89df36f7f56fdd7b1da31980 100644 --- a/lib_enc/ivas_mc_param_enc.c +++ b/lib_enc/ivas_mc_param_enc.c @@ -1011,8 +1011,6 @@ static void ivas_param_mc_param_est_enc_fx( move16(); ref_ener_fx = BASOP_Util_Add_Mant32Exp( ref_ener_fx, ref_ener_e, Cx_sum_fx[cur_param_band][ref_channel_idx][ref_channel_idx], // ref_ener_e Cx_sum_e[cur_param_band][ref_channel_idx][ref_channel_idx], &ref_ener_e ); - ref_ener_e = Cx_sum_e[cur_param_band][ref_channel_idx][ref_channel_idx]; - move16(); } L_tmp = Mpy_32_16_1( ref_ener_fx, hParamMC->hMetadataPMC.ild_factors_fx[k] ); #ifdef FIX_ISSUE_1154 @@ -1979,14 +1977,14 @@ static void ivas_param_mc_range_encoder_fx( UWord16 *bits; /* Initialize range encoder */ - rc_uni_enc_init( &rc_st_enc ); + rc_uni_enc_init_fx( &rc_st_enc ); /* Main loop over the length of the sequence */ FOR( i = 0; i < num_symbols; ++i ) { - rc_uni_enc_encode_symbol_fastS( &rc_st_enc, (UWord16) seq_in[i], cum_freq, sym_freq, tot_shift ); + rc_uni_enc_encode_symbol_fastS_fx( &rc_st_enc, (UWord16) seq_in[i], cum_freq, sym_freq, tot_shift ); - IF( GT_16( rc_uni_enc_virtual_finish( &rc_st_enc ), max_nb_bits ) ) + IF( GT_16( rc_uni_enc_virtual_finish_fx( &rc_st_enc ), max_nb_bits ) ) { /* we alread have exceeded the maximum number of bits allowed, i.e. the uniform fallback */ *bit_pos = MAX_BITS_PER_FRAME; @@ -1995,7 +1993,7 @@ static void ivas_param_mc_range_encoder_fx( } /* Finish range encoder */ - rc_tot_bits = rc_uni_enc_finish( &rc_st_enc ); /* No. of bits consumed by range coder */ + rc_tot_bits = rc_uni_enc_finish_fx( &rc_st_enc ); /* No. of bits consumed by range coder */ /* Push range coded bits from byte_buffer to bitstream */ diff --git a/lib_enc/ivas_mcmasa_enc.c b/lib_enc/ivas_mcmasa_enc.c index 34d43d366023159a03d6568fc82bd376e248623d..ad52915d1d7acffdaa2ff5d9f39d5b3a1708d15c 100644 --- a/lib_enc/ivas_mcmasa_enc.c +++ b/lib_enc/ivas_mcmasa_enc.c @@ -437,20 +437,20 @@ ivas_error ivas_mcmasa_enc_open_fx( { hMcMasa->chnlToFoaMtx_fx[0][i] = ONE_IN_Q31; move32(); - hMcMasa->chnlToFoaMtx_fx[1][i] = L_mult( getSineWord16R2( extract_l( L_shr( Mult_32_16( ls_azimuth[i], 91 /*32767/360*/ ), 7 ) ) ), getCosWord16R2( extract_l( L_shr( Mult_32_16( ls_elevation[i], 91 ), 7 ) ) ) ); // Q31 + hMcMasa->chnlToFoaMtx_fx[1][i] = L_mult( getSineWord16R2( extract_l( Mpy_32_32( ls_azimuth[i], 46603 /*32767/360*/ ) /*Q22+Q24-31=>Q15*/ ) ), getCosWord16R2( extract_l( Mpy_32_32( ls_elevation[i], 46603 /*2^24/360*/ ) ) ) ); // Q31 move32(); - hMcMasa->chnlToFoaMtx_fx[2][i] = L_shl( getSineWord16R2( extract_l( L_shr( Mult_32_16( ls_elevation[i], 91 ), 7 ) ) ), 16 ); // Q31 + hMcMasa->chnlToFoaMtx_fx[2][i] = L_shl( getSineWord16R2( extract_l( Mpy_32_32( ls_elevation[i], 46603 /*2^24/360*/ ) ) ), 16 ); // Q31 move32(); - hMcMasa->chnlToFoaMtx_fx[3][i] = L_mult( getCosWord16R2( extract_l( L_shr( Mult_32_16( ls_azimuth[i], 91 ), 7 ) ) ), getCosWord16R2( extract_l( L_shr( Mult_32_16( ls_elevation[i], 91 ), 7 ) ) ) ); // Q31 + hMcMasa->chnlToFoaMtx_fx[3][i] = L_mult( getCosWord16R2( extract_l( Mpy_32_32( ls_azimuth[i], 46603 /*2^24/360*/ ) ) ), getCosWord16R2( extract_l( Mpy_32_32( ls_elevation[i], 46603 /*2^24/360*/ ) ) ) ); // Q31 move32(); hMcMasa->chnlToFoaEvenMtx_fx[0][i] = ONE_IN_Q31; move32(); - hMcMasa->chnlToFoaEvenMtx_fx[1][i] = L_shl( getSineWord16R2( extract_l( L_shr( Mult_32_16( ls_azimuth_even[i], 91 ), 7 ) ) ), 16 ); // Q31 + hMcMasa->chnlToFoaEvenMtx_fx[1][i] = L_shl( getSineWord16R2( extract_l( Mpy_32_32( ls_azimuth_even[i], 46603 /*2^24/360*/ ) ) ), 16 ); // Q31 move32(); hMcMasa->chnlToFoaEvenMtx_fx[2][i] = 0; move32(); - hMcMasa->chnlToFoaEvenMtx_fx[3][i] = L_shl( getCosWord16R2( extract_l( L_shr( Mult_32_16( ls_azimuth_even[i], 91 ), 7 ) ) ), 16 ); + hMcMasa->chnlToFoaEvenMtx_fx[3][i] = L_shl( getCosWord16R2( extract_l( Mpy_32_32( ls_azimuth_even[i], 46603 /*2^24/360*/ ) ) ), 16 ); move32(); } diff --git a/lib_enc/ivas_mct_enc.c b/lib_enc/ivas_mct_enc.c index 4d032cee87854a5cfce40268a34bff9b2700ab87..8c194bed19057993fb0cd12f0e8f4419bf8bc201 100644 --- a/lib_enc/ivas_mct_enc.c +++ b/lib_enc/ivas_mct_enc.c @@ -284,9 +284,6 @@ ivas_error ivas_mct_enc_fx( Word16 q_spec = Q31; Word16 q_origSpec = Q31; - Word16 q_com = Q31, q_com_spec = Q31; - move16(); - move16(); move16(); move16(); Word16 length, ch, nCPE; @@ -303,6 +300,7 @@ ivas_error ivas_mct_enc_fx( { FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) { + Word16 norm; IF( EQ_32( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) ) { CONTINUE; @@ -324,24 +322,14 @@ ivas_error ivas_mct_enc_fx( { length = add( length, idiv1616( length, 4 ) ); } - - FOR( Word16 k = 0; k <= ( ( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->core == TCX_20_CORE ) ? 1 : NB_DIV ) - 1; k++ ) - { - IF( hMCT->p_mdst_spectrum_long_fx[cpe_id][ch] ) - { - q_spec = s_min( q_spec, hMCT->q_mdst_spectrum_long_fx[cpe_id][ch][k] ); - q_com_spec = s_min( q_com_spec, L_norm_arr( &hMCT->p_mdst_spectrum_long_fx[cpe_id][ch][k * N_TCX10_MAX], length ) ); - } - } IF( hMCT->p_orig_spectrum_long_fx[cpe_id][ch] ) { - q_origSpec = s_min( q_origSpec, hMCT->q_orig_spectrum_long_fx[cpe_id][ch] ); - q_com = s_min( q_com, L_norm_arr( hMCT->p_orig_spectrum_long_fx[cpe_id][ch], L_FRAME48k ) ); + norm = L_norm_arr( hMCT->p_orig_spectrum_long_fx[cpe_id][ch], L_FRAME48k ); + q_origSpec = s_min( q_origSpec, add( norm, hMCT->q_orig_spectrum_long_fx[cpe_id][ch] ) ); } } } - q_spec = sub( add( q_spec, q_com_spec ), 1 ); - q_origSpec = sub( add( q_origSpec, q_com ), 1 ); + q_origSpec = sub( q_origSpec, 1 ); FOR( cpe_id = 0; cpe_id < nCPE; cpe_id++ ) { @@ -361,73 +349,39 @@ ivas_error ivas_mct_enc_fx( } hMCT->q_orig_spectrum_long_com = q_origSpec; move16(); + FOR( cpe_id = 0; cpe_id < nCPE; cpe_id++ ) { FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) { - // length = st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->L_frameTCX / ( ( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->tcxMode == TCX_20 ) ? 1 : NB_DIV ); - - IF( EQ_16( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->tcxMode, TCX_20 ) ) + IF( EQ_16( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->core, TCX_20 ) ) { length = st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->L_frameTCX; move16(); } ELSE { - length = idiv1616( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->L_frameTCX, NB_DIV ); // st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->L_frameTCX / NB_DIV + length = idiv1616( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->L_frameTCX, NB_DIV ); } - IF( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->last_core == ACELP_CORE ) { length = add( length, idiv1616( length, 4 ) ); } + Word16 norm = L_norm_arr( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_long_fx, N_MAX ); + q_spec = s_min( q_spec, add( sub( 31, st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_long_e ), norm ) ); + q_spec = s_min( q_spec, add( sub( 31, st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_long_e ), norm ) ); FOR( Word16 k = 0; k <= ( ( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->core == TCX_20_CORE ) ? 1 : NB_DIV ) - 1; k++ ) { IF( hMCT->p_mdst_spectrum_long_fx[cpe_id][ch] ) { - Scale_sig32( &hMCT->p_mdst_spectrum_long_fx[cpe_id][ch][k * N_TCX10_MAX], length, sub( q_spec, hMCT->q_mdst_spectrum_long_fx[cpe_id][ch][k] ) ); // q_spec - hMCT->q_mdst_spectrum_long_fx[cpe_id][ch][k] = q_spec; - move16(); + norm = L_norm_arr( &hMCT->p_mdst_spectrum_long_fx[cpe_id][ch][k * N_TCX10_MAX], length ); + q_spec = s_min( q_spec, add( norm, hMCT->q_mdst_spectrum_long_fx[cpe_id][ch][k] ) ); } } } } - Encoder_State *sts_tmp[MCT_MAX_CHANNELS]; - Encoder_State *st; - Word16 i; - nCPE = shr( hMCT->nchan_out_woLFE, 1 ); // nChannels / CPE_CHANNELS - - /*in case of odd number of channels*/ - IF( NE_16( ( nCPE * CPE_CHANNELS ), hMCT->nchan_out_woLFE ) ) - { - nCPE = add( nCPE, 1 ); - } - FOR( ( cpe_id = 0, i = 0 ); cpe_id < nCPE; cpe_id++ ) - { - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - sts_tmp[i] = st_ivas->hCPE[cpe_id]->hCoreCoder[ch]; - IF( EQ_32( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) ) - { - i = add( i, 1 ); - CONTINUE; - } - i = add( i, 1 ); - } - } - - FOR( cpe_id = 0; cpe_id < nCPE; cpe_id++ ) - { - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - Word16 norm = L_norm_arr( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_long_fx, N_MAX ); - q_spec = s_min( q_spec, add( sub( 31, st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_long_e ), norm ) ); - q_spec = s_min( q_spec, add( sub( 31, st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_long_e ), norm ) ); - } - } - FOR( cpe_id = 0; cpe_id < nCPE; cpe_id++ ) { FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) @@ -447,6 +401,21 @@ ivas_error ivas_mct_enc_fx( move16(); st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_e[1] = sub( 31, q_spec ); move16(); + + IF( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->last_core == ACELP_CORE ) + { + length = add( length, idiv1616( length, 4 ) ); + } + + FOR( Word16 k = 0; k <= ( ( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->core == TCX_20_CORE ) ? 1 : NB_DIV ) - 1; k++ ) + { + IF( hMCT->p_mdst_spectrum_long_fx[cpe_id][ch] ) + { + Scale_sig32( &hMCT->p_mdst_spectrum_long_fx[cpe_id][ch][k * N_TCX10_MAX], length, sub( q_spec, hMCT->q_mdst_spectrum_long_fx[cpe_id][ch][k] ) ); // q_spec + hMCT->q_mdst_spectrum_long_fx[cpe_id][ch][k] = q_spec; + move16(); + } + } } } @@ -496,26 +465,6 @@ ivas_error ivas_mct_enc_fx( q_spec = 31; move16(); - FOR( ch = 0; ch < hMCT->nchan_out_woLFE; ch++ ) - { - // length = sts_tmp[ch]->hTcxEnc->L_frameTCX / ( ( sts_tmp[ch]->hTcxEnc->tcxMode == TCX_20 ) ? 1 : NB_DIV ); - - IF( EQ_16( sts_tmp[ch]->hTcxEnc->tcxMode, TCX_20 ) ) - { - length = sts_tmp[ch]->hTcxEnc->L_frameTCX; - move16(); - } - ELSE - { - length = idiv1616( sts_tmp[ch]->hTcxEnc->L_frameTCX, NB_DIV ); // st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->L_frameTCX / NB_DIV - } - - IF( sts_tmp[ch]->last_core == ACELP_CORE ) - { - length = add( length, idiv1616( length, 4 ) ); - } - } - /* Spectrum quantization and coding */ FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) @@ -527,21 +476,8 @@ ivas_error ivas_mct_enc_fx( hCPE->hCoreCoder[0]->hBstr->ind_list = st_ivas->hCPE[cpe_id - 1]->hCoreCoder[1]->hBstr->ind_list + st_ivas->hCPE[cpe_id - 1]->hCoreCoder[1]->hBstr->nb_ind_tot; } - Encoder_State /**st,*/ **sts; - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - sts = hCPE->hCoreCoder; - st = sts[ch]; - } - ivas_mdct_quant_coder_fx( hCPE, hMCT->tnsBits[cpe_id], hMCT->tnsSize[cpe_id], hMCT->p_param[cpe_id], 1 ); - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - sts = hCPE->hCoreCoder; - st = sts[ch]; - } - /* update input samples buffer (as done in ivas_cpe_enc() for other than MCT coding) */ FOR( n = 0; n < CPE_CHANNELS; n++ ) { @@ -550,8 +486,7 @@ ivas_error ivas_mct_enc_fx( move16(); /* common encoder updates */ - st = hCPE->hCoreCoder[n]; - updt_enc_common_ivas_fx( st, Q_new_out[cpe_id][n] ); + updt_enc_common_ivas_fx( hCPE->hCoreCoder[n], Q_new_out[cpe_id][n] ); } } diff --git a/lib_enc/ivas_mct_enc_mct.c b/lib_enc/ivas_mct_enc_mct.c index 7729bbff5b2d88eb5517f4f3a1dc2bbc21ea4c3c..4b84ea9cb607b05c7e6cd50ab7a198d9f8795b11 100644 --- a/lib_enc/ivas_mct_enc_mct.c +++ b/lib_enc/ivas_mct_enc_mct.c @@ -601,6 +601,11 @@ static void getGlobalILD_fx( { sts[ch]->hTcxEnc->spectrum_e[k] = add( sts[ch]->hTcxEnc->spectrum_e[k], 4 ); // Updating exponent of spectrum as q_ratio is in Q11 } + IF( GT_16( nSubframes, 1 ) ) + { + sts[ch]->hTcxEnc->spectrum_long_e = add( sts[ch]->hTcxEnc->spectrum_long_e, 4 ); + move16(); + } FOR( k = 0; k < nSubframes; k++ ) { @@ -877,10 +882,12 @@ void apply_MCT_enc_fx( } sts[ch]->hTcxEnc->spectrum_e[1] = add( sts[ch]->hTcxEnc->spectrum_e[0], exp ); sts[ch]->hTcxEnc->spectrum_e[0] = add( sts[ch]->hTcxEnc->spectrum_e[0], exp ); + sts[ch]->hTcxEnc->spectrum_long_e = add( sts[ch]->hTcxEnc->spectrum_long_e, exp ); hMCT->mc_global_ild[ch] = 0; move16(); move16(); move16(); + move16(); } } } @@ -1088,7 +1095,7 @@ void mctStereoIGF_enc_fx( 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 ); + p_powerSpec_fx, p_powerSpecMsInv_fx, p_inv_spectrum_fx, n, sp_aud_decision0[ch1], p_st[0]->total_brate, 1 ); } ELSE { diff --git a/lib_enc/ivas_mdct_core_enc.c b/lib_enc/ivas_mdct_core_enc.c index a64cf60b3c9ecba13952cca09725e100798cb8b5..18bee6777ee6ba6961bb2f7c5733b831cf25ee93 100644 --- a/lib_enc/ivas_mdct_core_enc.c +++ b/lib_enc/ivas_mdct_core_enc.c @@ -436,24 +436,24 @@ static void kernel_switch_update_transforms_fx( #else Scale_sig( &tcxTimeSignal[n - s], shl( s, 1 ), -Q1 ); // Q0 -> Q-1 #endif - wtda_ext_fx( tcxTimeSignal, windowedTimeSignal_16, extract_l( windowedTimeSignal[0] ), extract_l( windowedTimeSignal[1] ), s, kernelType ); // 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, windowedTimeSignal, s, Q16 ); // Q15 - scale_sig32( windowedTimeSignal, s, -Q8 /* guard bits */ ); // Q7 + 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 ); tmp = Sqrt16( tmp, &exp_tmp ); factor = L_shl( L_deposit_h( tmp ), sub( exp_tmp, Q1 ) ); // Q30 - v_multc_fixed( sigR, factor, sigR, s ); // (Q7, Q30) -> Q6 + v_multc_fixed( sigR, factor, sigR, s ); // (Q6, Q30) -> Q5 q_com = L_norm_arr( sigR, s ); - q_com = s_min( add( q_com, Q6 ), *q_sig ); - scale_sig32( sigR, s, sub( q_com, Q6 ) ); // q_com + q_com = s_min( add( q_com, Q5 ), *q_sig ); + scale_sig32( sigR, s, sub( q_com, Q5 ) ); // q_com scale_sig32( sigI, s, sub( q_com, *q_sig ) ); // q_com *q_sig = q_com; move16(); @@ -520,7 +520,7 @@ static void kernel_switch_update_transforms_fx( Word16 tcx5Win[N_TCX10_MAX / 2 + L_MDCT_OVLP_MAX]; /* temporary buffer for TCX5 windowing */ Word32 tcx5Win_32[N_TCX10_MAX / 2 + L_MDCT_OVLP_MAX]; /* temporary buffer for TCX5 windowing */ Word16 windowedTimeSignal_16[2 + L_FRAME48k]; - Word16 q_shift, q_com; + Word16 q_shift, q_com, q_temp; assert( L_subframe == nSubframes * hTcxCfg->tcx5SizeFB ); @@ -557,7 +557,8 @@ static void kernel_switch_update_transforms_fx( kernel_switch_trafo_fx( tcx5Win_32, sigR, leftOverlap, sub( s /* L_subfr. */, shr( add( leftOverlap, rightOverlap ), 1 ) ), rightOverlap, kernelType ); // *q_windowedTimeSignal + q_shift /* Move both sigR and sigI to common Q */ - q_com = s_min( *q_sig, sub( add( *q_windowedTimeSignal, q_shift ), Q1 ) ); + q_temp = add( sub( add( *q_windowedTimeSignal, q_shift ), Q1 ), L_norm_arr( sigR, L_subframe ) ); + q_com = s_min( *q_sig, q_temp ); scale_sig32( sigR, s, sub( q_com, sub( add( *q_windowedTimeSignal, q_shift ), Q1 ) ) ); scale_sig32( sigR + s, sub( L_subframe, s ), sub( q_com, *q_sig ) ); scale_sig32( sigI, L_subframe, sub( q_com, *q_sig ) ); @@ -579,7 +580,7 @@ static void kernel_switch_update_transforms_fx( } ELSE /* tcxTransType != TCX_5 */ { - Word16 q_shift, q_com; + Word16 q_shift, q_com, q_temp; #ifdef FIX_ISSUE_1157 q_shift = -Q8; #else @@ -590,7 +591,8 @@ static void kernel_switch_update_transforms_fx( kernel_switch_trafo_fx( windowedTimeSignal + 2, sigR, leftOverlap, sub( s /* L_subfr. */, shr( add( leftOverlap, rightOverlap ), 1 ) ), rightOverlap, kernelType ); // *q_windowedTimeSignal + q_shift /* Move both sigR and sigI to common Q */ - q_com = s_min( *q_sig, sub( add( *q_windowedTimeSignal, q_shift ), Q1 ) ); + q_temp = add( sub( add( *q_windowedTimeSignal, q_shift ), Q1 ), L_norm_arr( sigR, L_subframe ) ); + q_com = s_min( *q_sig, q_temp ); scale_sig32( sigR, s, sub( q_com, sub( add( *q_windowedTimeSignal, q_shift ), Q1 ) ) ); scale_sig32( sigR + s, sub( L_subframe, s ), sub( q_com, *q_sig ) ); scale_sig32( sigI, L_subframe, sub( q_com, *q_sig ) ); @@ -1626,10 +1628,14 @@ void ivas_mdct_core_whitening_enc_fx( Scale_sig32( mdst_spectrum_fx[0][n], tcx5SizeFB, scale ); // q_com Scale_sig32( mdst_spectrum_fx[1][n], tcx5SizeFB, scale ); // q_com - Scale_sig32( hTcxEnc0->spectrum_fx[n] + offset1, offset2, scale ); // q_com - Scale_sig32( hTcxEnc1->spectrum_fx[n] + offset1, offset2, scale ); // q_com - Scale_sig32( mdst_spectrum_fx[0][n] + offset1, offset2, scale ); // q_com - Scale_sig32( mdst_spectrum_fx[1][n] + offset1, offset2, scale ); // q_com + offset2 = sub( idiv1616( hTcxEnc0->L_frameTCX, nSubframes ), offset1 ); + IF( offset2 > 0 ) + { + Scale_sig32( hTcxEnc0->spectrum_fx[n] + offset1, offset2, scale ); // q_com + Scale_sig32( hTcxEnc1->spectrum_fx[n] + offset1, offset2, scale ); // q_com + Scale_sig32( mdst_spectrum_fx[0][n] + offset1, offset2, scale ); // q_com + Scale_sig32( mdst_spectrum_fx[1][n] + offset1, offset2, scale ); // q_com + } } mdst_spectrum_e[0][n] = sub( Q31, q_com ); hTcxEnc0->spectrum_e[n] = sub( Q31, q_com ); @@ -2102,8 +2108,13 @@ void ivas_mdct_core_whitening_enc_fx( st->hTcxEnc->spectrum_e[n] = sub( st->hTcxEnc->spectrum_e[n], q_com ); move16(); + Word16 exp_tmp = st->hTcxEnc->spectrum_e[n]; + move16(); + /* Shape spectrum */ ShapeSpectrum_ivas_fx( st->hTcxCfg, A_q_fx[ch][n], NULL, NULL, L_subframe, tcx_subframe_coded_lines, st->hTcxEnc->spectrum_fx[n], &st->hTcxEnc->spectrum_e[n], st->hTcxEnc->fUseTns[n], st, scf_q_fx[ch][n] ); + + Scale_sig32( st->hTcxEnc->spectrum_fx[n] + L_subframe, sub( L_subframeTCX, L_subframe ), sub( exp_tmp, st->hTcxEnc->spectrum_e[n] ) ); } } /*--------------------------------------------------------------* @@ -2237,8 +2248,13 @@ void ivas_mdct_core_whitening_enc_fx( mdst_spectrum_e[ch][n] = sub( mdst_spectrum_e[ch][n], q_com ); move16(); + Word16 exp_tmp = mdst_spectrum_e[ch][n]; + move16(); + /* Shape spectrum */ ShapeSpectrum_ivas_fx( st->hTcxCfg, A_q_fx[ch][n], NULL, NULL, L_subframe, tcx_subframe_coded_lines, mdst_spectrum_fx[ch][n], &mdst_spectrum_e[ch][n], st->hTcxEnc->fUseTns[n], st, scf_q_fx[ch][n] ); + + Scale_sig32( mdst_spectrum_fx[ch][n] + L_subframe, sub( L_subframeTCX, L_subframe ), sub( exp_tmp, mdst_spectrum_e[ch][n] ) ); } } } diff --git a/lib_enc/ivas_range_uni_enc.c b/lib_enc/ivas_range_uni_enc.c index 5bb5118a102040eff4a9a324e90fc71dcfb6b9f4..a93f470f5e291df1e7a6726fa30af6c5572c670a 100644 --- a/lib_enc/ivas_range_uni_enc.c +++ b/lib_enc/ivas_range_uni_enc.c @@ -32,6 +32,7 @@ #include #include "ivas_prot.h" +#include "ivas_prot_fx.h" #include "ivas_cnst.h" #include "ivas_stat_enc.h" #include "cnst.h" @@ -55,15 +56,15 @@ * Local function prototypes *-------------------------------------------------------------------*/ -static void rc_uni_enc_shift( RangeUniEncState *rc_st_enc ); +static void rc_uni_enc_shift_fx( RangeUniEncState *rc_st_enc ); /*-------------------------------------------------------------------* - * rc_uni_enc_init() + * rc_uni_enc_init_fx() * * Initalize the range encoder *-------------------------------------------------------------------*/ -void rc_uni_enc_init( +void rc_uni_enc_init_fx( RangeUniEncState *rc_st_enc /* i/o: RC state handle */ ) { @@ -91,7 +92,7 @@ void rc_uni_enc_init( * * Encode given cumulative frequency and frequency when total frequency is a power of 2 *-------------------------------------------------------------------*/ -void rc_uni_enc_encode_fast( +void rc_uni_enc_encode_fast_fx( RangeUniEncState *rc_st_enc, /* i/o: RC state handle */ const UWord16 cum_freq, /* i : Cumulative frequency up to symbol */ const UWord16 sym_freq, /* i : Symbol frequency */ @@ -119,12 +120,12 @@ void rc_uni_enc_encode_fast( { rc_st_enc->rc_range = UL_lshl( rc_st_enc->rc_range, 8 ); move32(); - rc_uni_enc_shift( rc_st_enc ); + rc_uni_enc_shift_fx( rc_st_enc ); IF( LT_64( rc_st_enc->rc_range, 0x01000000 ) ) { rc_st_enc->rc_range = UL_lshl( rc_st_enc->rc_range, 8 ); move32(); - rc_uni_enc_shift( rc_st_enc ); + rc_uni_enc_shift_fx( rc_st_enc ); } } @@ -133,11 +134,11 @@ void rc_uni_enc_encode_fast( /*-------------------------------------------------------------------* - * rc_uni_enc_encode_symbol_fastS() + * rc_uni_enc_encode_symbol_fastS_fx() * * Encode an alphabet symbol when total frequency is a power of 2 *-------------------------------------------------------------------*/ -void rc_uni_enc_encode_symbol_fastS( +void rc_uni_enc_encode_symbol_fastS_fx( RangeUniEncState *rc_st_enc, /* i/o: Encoder state */ const UWord16 symbol, /* i : Symbol to encode */ const UWord16 cum_freq[], /* i : Cumulative frequency up to symbol */ @@ -145,18 +146,18 @@ void rc_uni_enc_encode_symbol_fastS( const UWord16 tot_shift /* i : Total frequency as a power of 2 */ ) { - rc_uni_enc_encode_fast( rc_st_enc, cum_freq[symbol], sym_freq[symbol], tot_shift ); + rc_uni_enc_encode_fast_fx( rc_st_enc, cum_freq[symbol], sym_freq[symbol], tot_shift ); return; } /*-------------------------------------------------------------------* - * rc_uni_enc_finish() + * rc_uni_enc_finish_fx() * * Finalize the range encoder *-------------------------------------------------------------------*/ /*! r: Total number of bits produced */ -Word16 rc_uni_enc_finish( +Word16 rc_uni_enc_finish_fx( RangeUniEncState *rc_st_enc /* i/o: RC state handle */ ) { @@ -186,7 +187,7 @@ Word16 rc_uni_enc_finish( WHILE( bits > 0 ) { - rc_uni_enc_shift( rc_st_enc ); + rc_uni_enc_shift_fx( rc_st_enc ); bits = sub( bits, 8 ); } @@ -245,7 +246,7 @@ Word16 rc_uni_enc_finish( * Get the total number of bits that would be produced by finalization *-------------------------------------------------------------------*/ /*! r: Total number of bits produced */ -Word16 rc_uni_enc_virtual_finish( +Word16 rc_uni_enc_virtual_finish_fx( RangeUniEncState *rc_st_enc /* i : RC state handle */ ) { @@ -278,11 +279,11 @@ Word16 rc_uni_enc_virtual_finish( /*-------------------------------------------------------------------* - * rc_uni_enc_shift() + * rc_uni_enc_shift_fx() * * Shift a byte out to bitstream (internal function) *-------------------------------------------------------------------*/ -static void rc_uni_enc_shift( +static void rc_uni_enc_shift_fx( RangeUniEncState *rc_st_enc /* i/o: RC state handle */ ) { @@ -326,11 +327,11 @@ static void rc_uni_enc_shift( /*-------------------------------------------------------------------* - * rc_uni_enc_encode_bits() + * rc_uni_enc_encode_bits_fx() * * Encode up to 16 bits with uniform probability *-------------------------------------------------------------------*/ -void rc_uni_enc_encode_bits( +void rc_uni_enc_encode_bits_fx( RangeUniEncState *rc_st_enc, /* i/o: RC state handle */ const UWord16 value, /* i : Value to encode */ const Word16 bits /* i : Number of bits */ @@ -355,12 +356,12 @@ void rc_uni_enc_encode_bits( { rc_st_enc->rc_range = UL_lshl( rc_st_enc->rc_range, 8 ); move32(); - rc_uni_enc_shift( rc_st_enc ); + rc_uni_enc_shift_fx( rc_st_enc ); IF( LT_64( rc_st_enc->rc_range, 0x01000000 ) ) { rc_st_enc->rc_range = UL_lshl( rc_st_enc->rc_range, 8 ); move32(); - rc_uni_enc_shift( rc_st_enc ); + rc_uni_enc_shift_fx( rc_st_enc ); } } diff --git a/lib_enc/ivas_sba_enc.c b/lib_enc/ivas_sba_enc.c index 0fe07179a9fdfc85ad770bc33485c78b98f82c26..ef76d67c952228ce40185b28a849c50d8681e732 100644 --- a/lib_enc/ivas_sba_enc.c +++ b/lib_enc/ivas_sba_enc.c @@ -38,6 +38,7 @@ #include "ivas_cnst.h" #include "rom_com.h" #include "prot.h" +#include "ivas_prot_fx.h" #include "ivas_prot.h" #include "ivas_rom_com.h" #include "wmc_auto.h" @@ -86,12 +87,12 @@ void ivas_sba_getTCs_fx( } /*-------------------------------------------------------------------* - * ivas_sba_enc_reconfigure() + * ivas_sba_enc_reconfigure_fx() * * Reconfigure IVAS SBA encoder *-------------------------------------------------------------------*/ -/* To be renamed as ivas_sba_enc_reconfigure_fx later */ -ivas_error ivas_sba_enc_reconfigure( + +ivas_error ivas_sba_enc_reconfigure_fx( Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ ) { diff --git a/lib_enc/ivas_sce_enc.c b/lib_enc/ivas_sce_enc.c index 7d76b2fd59fbb4a2ab380003650a5eb0659d0366..5fdd8b75ff13aa5e2dc9d2cb18dc1dfda5e3e93a 100644 --- a/lib_enc/ivas_sce_enc.c +++ b/lib_enc/ivas_sce_enc.c @@ -180,8 +180,6 @@ ivas_error ivas_sce_enc_fx( IF( NE_32( ivas_format, MC_FORMAT ) || NE_32( st_ivas->mc_mode, MC_MODE_PARAMMC ) ) { RunTransientDetection_ivas_fx( st->input_fx, input_frame, st->hTranDet, q_input ); - move16(); - move16(); } currFlatness_fx[0] = GetTCXAvgTemporalFlatnessMeasure_ivas_fx( (const TransientDetection *) st->hTranDet, NSUBBLOCKS, 0 ); // Q7 @@ -257,7 +255,11 @@ 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 @@ -265,7 +267,7 @@ ivas_error ivas_sce_enc_fx( ); e_old_wsp[0] = sub( Q15, q_old_wsp ); move16(); - IF( error != IVAS_ERR_OK ) + IF( NE_32( error, IVAS_ERR_OK ) ) { return error; } @@ -318,7 +320,7 @@ ivas_error ivas_sce_enc_fx( /* IGF reconfiguration */ test(); - IF( hSCE->last_element_brate != hSCE->element_brate || st->last_bwidth != st->bwidth ) + IF( NE_32( hSCE->last_element_brate, hSCE->element_brate ) || NE_16( st->last_bwidth, st->bwidth ) ) { Word16 igf; igf = getIgfPresent_fx( st->element_mode, L_mult0( st->bits_frame_nominal, FRAMES_PER_SEC ), st->max_bwidth, st->rf_mode ); @@ -331,7 +333,7 @@ ivas_error ivas_sce_enc_fx( /* set ACELP@12k8 / ACELP@16k flag for flexible ACELP core */ test(); test(); - IF( st->core_brate == SID_2k40 || st->core_brate == FRAME_NO_DATA ) + IF( EQ_32( st->core_brate, SID_2k40 ) || st->core_brate == FRAME_NO_DATA ) { st->flag_ACELP16k = set_ACELP_flag_IVAS( IVAS_SCE, hSCE->element_brate, st->core_brate, 0, 0, -1, -1 ); } @@ -352,10 +354,10 @@ ivas_error ivas_sce_enc_fx( * Encoder *----------------------------------------------------------------*/ - Scale_sig( old_wsp_fx[0], L_WSP, sub( e_old_wsp[0], Q16 ) ); + Scale_sig( old_wsp_fx[0], L_WSP, sub( e_old_wsp[0], Q16 ) ); // Q(15-16) e_old_wsp[0] = 16; move16(); - IF( ( error = ivas_core_enc_fx( hSCE, NULL, NULL, 1, old_inp_12k8_fx, old_inp_16k_fx, Q_new, ener_fx, A_fx, Aw_fx, epsP_fx, epsP_fx_q, lsp_new_fx, lsp_mid_fx, vad_hover_flag, attack_flag, realBuffer_fx, imagBuffer_fx, &q_re_im_buf, old_wsp_fx, e_old_wsp, loc_harm, cor_map_sum_fx, vad_flag_dtx, enerBuffer_fx, enerBuffer_fx_exp, fft_buff_fx, 0, ivas_format, flag_16k_smc ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_core_enc_fx( hSCE, NULL, NULL, 1, old_inp_12k8_fx, old_inp_16k_fx, Q_new, ener_fx, A_fx, Aw_fx, epsP_fx, epsP_fx_q, lsp_new_fx, lsp_mid_fx, vad_hover_flag, attack_flag, realBuffer_fx, imagBuffer_fx, &q_re_im_buf, old_wsp_fx, e_old_wsp, loc_harm, cor_map_sum_fx, vad_flag_dtx, enerBuffer_fx, enerBuffer_fx_exp, fft_buff_fx, 0, ivas_format, flag_16k_smc ) ), IVAS_ERR_OK ) ) { return error; } @@ -433,7 +435,7 @@ ivas_error create_sce_enc_fx( test(); IF( NE_16( st_ivas->hEncoderConfig->ivas_format, MONO_FORMAT ) && EQ_16( sce_id, sub( st_ivas->nSCE, 1 ) ) ) { - IF( ( error = ivas_initialize_MD_bstr_enc_fx( &( hSCE->hMetaData ), st_ivas ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_initialize_MD_bstr_enc_fx( &( hSCE->hMetaData ), st_ivas ) ), IVAS_ERR_OK ) ) { return error; } @@ -468,7 +470,7 @@ ivas_error create_sce_enc_fx( move32(); move32(); - IF( ( 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 ) + 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 ) ) { return error; } @@ -480,12 +482,12 @@ ivas_error create_sce_enc_fx( } /*------------------------------------------------------------------------- - * create_evs_sce_enc() + * create_evs_sce_enc_fx() * * Create, allocate and initialize EVS encoder SCE handle *-------------------------------------------------------------------------*/ -ivas_error create_evs_sce_enc( +ivas_error create_evs_sce_enc_fx( Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ const Word16 sce_id, /* i : SCE # identifier */ const Word32 element_brate /* i : element bitrate */ @@ -617,12 +619,12 @@ ivas_error create_evs_sce_enc( } /*------------------------------------------------------------------------- - * destroy_sce_enc() + * destroy_sce_enc_fx() * * Destroy and deallocate IVAS encoder SCE handle *-------------------------------------------------------------------------*/ -void destroy_sce_enc( +void destroy_sce_enc_fx( SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */ Flag is_evs /* i : Flag to indicate EVS encoder*/ ) diff --git a/lib_enc/ivas_sns_enc.c b/lib_enc/ivas_sns_enc.c index d36fcaaa5d9c54b4a3a13443ec3b2245d728e5e8..5566c15479996f17b7c4303e881559d18a4823b4 100644 --- a/lib_enc/ivas_sns_enc.c +++ b/lib_enc/ivas_sns_enc.c @@ -235,6 +235,7 @@ static Word16 sns_2st_cod_fx( FOR( i = 0; i < 2; i++ ) { nq = indx[i]; + move16(); nbits = add( nbits, ( add( 2, ( shl( nq, 2 ) ) ) ) ); /* 2 bits to specify Q2,Q3,Q4,ext */ IF( GT_16( nq, 6 ) ) @@ -393,7 +394,7 @@ void sns_avq_cod_stereo_fx( side_fx[i] = BASOP_Util_Add_Mant32Exp( snsl_fx[i], exp_snl, L_negate( snsr_fx[i] ), exp_snr, &exp_side_buffer[i] ); move32(); Word32 tmp = Mpy_32_32( side_fx[i], side_fx[i] ); // exp_side[i] * 2 - ener_side_fx = BASOP_Util_Add_Mant32Exp( ener_side_fx, exp_ener_side, tmp, exp_side_buffer[i] * 2, &exp_ener_side ); + ener_side_fx = BASOP_Util_Add_Mant32Exp( ener_side_fx, exp_ener_side, tmp, shl( exp_side_buffer[i], 1 ), &exp_ener_side ); } FOR( i = 0; i < M; i++ ) { @@ -697,7 +698,7 @@ Word16 quantize_sns_fx( } Word16 shift = find_guarded_bits_fx( M ); sns_e_tmp[ch][k] = sub( 31, sub( 20, shift ) ); - + move16(); idxIndices = add( idxIndices, nStages ); FOR( i = 0; i < nStages; ++i ) @@ -721,7 +722,7 @@ Word16 quantize_sns_fx( #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 ) ); + 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 ) ); diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index a366d86fba24b7fb7e3ac041f02f6e4f7344d7be..e1b3905c257f6cca1984477ed4407deee53c7b59 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -130,14 +130,14 @@ ivas_error ivas_spar_enc_open_fx( /* set FB config. */ active_w_mixing = ivas_spar_br_table_consts[table_idx].active_w; move16(); - IF( ( error = ivas_fb_set_cfg( &fb_cfg, SBA_FORMAT, nchan_inp, nchan_transport, active_w_mixing, input_Fs, nchan_fb_in ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_fb_set_cfg( &fb_cfg, SBA_FORMAT, nchan_inp, nchan_transport, active_w_mixing, input_Fs, nchan_fb_in ) ), IVAS_ERR_OK ) ) { return error; } fb_cfg->remix_order = remix_order_set[hSpar->hMdEnc->spar_md_cfg.remix_unmix_order]; /* FB mixer handle */ - IF( ( error = ivas_FB_mixer_open_fx( &( hSpar->hFbMixer ), input_Fs, fb_cfg, spar_reconfig_flag ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_FB_mixer_open_fx( &( hSpar->hFbMixer ), input_Fs, fb_cfg, spar_reconfig_flag ) ), IVAS_ERR_OK ) ) { return error; } @@ -150,7 +150,7 @@ ivas_error ivas_spar_enc_open_fx( IF( !spar_reconfig_flag ) { /* Transient Detector handle */ - IF( ( error = ivas_transient_det_open_fx( &( hSpar->hTranDet ), input_Fs ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_transient_det_open_fx( &( hSpar->hTranDet ), input_Fs ) ), IVAS_ERR_OK ) ) { return error; } @@ -165,7 +165,7 @@ ivas_error ivas_spar_enc_open_fx( hSpar->hAgcEnc = NULL; IF( hSpar->AGC_Enable ) { - IF( ( error = ivas_spar_agc_enc_open_fx( &hSpar->hAgcEnc, input_Fs, nchan_inp ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_spar_agc_enc_open_fx( &hSpar->hAgcEnc, input_Fs, nchan_inp ) ), IVAS_ERR_OK ) ) { return error; } @@ -214,7 +214,7 @@ ivas_error ivas_spar_enc_open_fx( move16(); IF( hEncoderConfig->Opt_DTX_ON ) { - IF( ( error = front_vad_create_fx( &( hSpar->hFrontVad ), hEncoderConfig ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = front_vad_create_fx( &( hSpar->hFrontVad ), hEncoderConfig ) ), IVAS_ERR_OK ) ) { return error; } @@ -230,7 +230,7 @@ ivas_error ivas_spar_enc_open_fx( hSpar->hCoreCoderVAD->mct_chan_mode = MCT_CHAN_MODE_IGNORE; move32(); move32(); - IF( ( error = init_encoder_ivas_fx( hSpar->hCoreCoderVAD, st_ivas, 0, hEncoderConfig->var_SID_rate_flag, hEncoderConfig->interval_SID, 1, st_ivas->ism_mode, hSpar->hCoreCoderVAD->total_brate ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = init_encoder_ivas_fx( hSpar->hCoreCoderVAD, st_ivas, 0, hEncoderConfig->var_SID_rate_flag, hEncoderConfig->interval_SID, 1, st_ivas->ism_mode, hSpar->hCoreCoderVAD->total_brate ) ), IVAS_ERR_OK ) ) { return error; } @@ -343,10 +343,20 @@ ivas_error ivas_spar_enc_fx( error = IVAS_ERR_OK; move32(); hEncoderConfig = st_ivas->hEncoderConfig; - st0 = ( st_ivas->nSCE > 0 ) ? st_ivas->hSCE[0]->hCoreCoder[0] : st_ivas->hCPE[0]->hCoreCoder[0]; + IF( st_ivas->nSCE > 0 ) + { + st0 = st_ivas->hSCE[0]->hCoreCoder[0]; + } + ELSE + { + st0 = st_ivas->hCPE[0]->hCoreCoder[0]; + } + + test(); + test(); /* Write SBA signaling bits */ - if ( hEncoderConfig->ivas_format == SBA_FORMAT || ( hEncoderConfig->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) ) + IF( EQ_32( hEncoderConfig->ivas_format, SBA_FORMAT ) || ( EQ_32( hEncoderConfig->ivas_format, SBA_ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) ) { /* Write SBA planar flag */ push_indice( st0->hBstr, IND_SMODE, hEncoderConfig->sba_planar, SBA_PLANAR_BITS ); @@ -354,9 +364,9 @@ ivas_error ivas_spar_enc_fx( /* Write SBA order */ push_indice( st0->hBstr, IND_SMODE, hEncoderConfig->sba_order, SBA_ORDER_BITS ); } - else /* ism_mode == ISM_MODE_NONE */ + ELSE /* ism_mode == ISM_MODE_NONE */ { - if ( hEncoderConfig->ivas_total_brate < IVAS_24k4 ) + IF( LT_32( hEncoderConfig->ivas_total_brate, IVAS_24k4 ) ) { /* Write SBA planar flag */ push_indice( st0->hBstr, IND_SMODE, hEncoderConfig->sba_planar, SBA_PLANAR_BITS ); @@ -364,20 +374,20 @@ ivas_error ivas_spar_enc_fx( /* hack to indicate OSBA bitstream at VLBR */ push_indice( st0->hBstr, IND_SMODE, 0, SBA_ORDER_BITS ); } - else + ELSE { /* Write SBA order */ push_indice( st0->hBstr, IND_SMODE, hEncoderConfig->sba_order, SBA_ORDER_BITS ); } } - if ( hEncoderConfig->ivas_format == SBA_ISM_FORMAT ) + IF( EQ_32( hEncoderConfig->ivas_format, SBA_ISM_FORMAT ) ) { /* write the number of objects in ISM_SBA format*/ push_indice( hMetaData, IND_ISM_NUM_OBJECTS, hEncoderConfig->nchan_ism - 1, NO_BITS_MASA_ISM_NO_OBJ ); } /* front VAD */ - IF( ( error = front_vad_spar_fx( st_ivas->hSpar, data_fx[0], hEncoderConfig, input_frame ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = front_vad_spar_fx( st_ivas->hSpar, data_fx[0], hEncoderConfig, input_frame ) ), IVAS_ERR_OK ) ) { return error; } @@ -394,11 +404,14 @@ ivas_error ivas_spar_enc_fx( } *nb_bits_metadata = hMetaData->nb_bits_tot; + move16(); + test(); /* Force IVAS front pre-proc decision for higher bitrates */ - if ( hEncoderConfig->ivas_total_brate > SBA_DTX_BITRATE_THRESHOLD || hEncoderConfig->Opt_DTX_ON == 0 ) + if ( GT_32( hEncoderConfig->ivas_total_brate, SBA_DTX_BITRATE_THRESHOLD ) || hEncoderConfig->Opt_DTX_ON == 0 ) { st_ivas->hSpar->front_vad_flag = 0; + move16(); } return error; @@ -418,8 +431,8 @@ static ivas_error ivas_spar_cov_md_process_fx( BSTR_ENC_HANDLE hMetaData, const Word16 nchan_inp, const Word16 sba_order, - Word32 *ppIn_FR_real_fx[IVAS_SPAR_MAX_CH], - Word32 *ppIn_FR_imag_fx[IVAS_SPAR_MAX_CH], + Word32 *ppIn_FR_real_fx[IVAS_SPAR_MAX_CH], // q_ppIn_FR + Word32 *ppIn_FR_imag_fx[IVAS_SPAR_MAX_CH], // q_ppIn_FR const Word16 transient_det[2], const Word16 dtx_vad, const Word16 nchan_transport, @@ -659,7 +672,7 @@ static ivas_error ivas_spar_enc_process_fx( const ENCODER_CONFIG_HANDLE hEncoderConfig, /* i : configuration structure */ BSTR_ENC_HANDLE hMetaData, /* i/o: MetaData handle */ const Word16 front_vad_flag, /* i : front-VAD decision */ - Word32 *data_fx[], /* i/o: input/transport audio channels */ + Word32 *data_fx[], /* i/o: input/transport audio channels Q(q_data) */ const Word16 q_data ) { Word32 pcm_tmp_fx[DIRAC_MAX_ANA_CHANS][L_FRAME48k * 2]; @@ -762,15 +775,19 @@ static ivas_error ivas_spar_enc_process_fx( FOR( i = 0; i < hSpar->hFbMixer->fb_cfg->num_in_chans; i++ ) { /* changing q format to q_data*/ - scale_sig32( p_pcm_tmp_fx[i], shl( input_frame, 1 ), sub( q_data, q_p_pcm_tmp_fx[i] ) ); + scale_sig32( p_pcm_tmp_fx[i], shl( input_frame, 1 ), sub( q_data, q_p_pcm_tmp_fx[i] ) ); // q_data } /* prepare Parameter MDFT analysis */ + Word16 shift = Q31; + move16(); FOR( i = 0; i < nchan_fb_in; i++ ) { ppIn_FR_real_fx[i] = p_pcm_tmp_fx[i]; ppIn_FR_imag_fx[i] = p_pcm_tmp_fx[i] + input_frame; p_pcm_tmp_fx[i] = data_fx[i]; + shift = s_min( shift, L_norm_arr( hSpar->hFbMixer->ppFilterbank_prior_input_fx[i], hSpar->hFbMixer->fb_cfg->prior_input_length ) ); + shift = s_min( shift, L_norm_arr( data_fx[i], input_frame ) ); } l_ts = idiv1616( input_frame, MAX_PARAM_SPATIAL_SUBFRAMES ); @@ -778,8 +795,17 @@ static ivas_error ivas_spar_enc_process_fx( Word16 gb = find_guarded_bits_fx( l_ts ); FOR( ts = 0; ts < MAX_PARAM_SPATIAL_SUBFRAMES; ts++ ) { + FOR( i = 0; i < nchan_fb_in; i++ ) + { + scale_sig32( data_fx[i], input_frame, shift ); // Q:q_data+shift + scale_sig32( hSpar->hFbMixer->ppFilterbank_prior_input_fx[i], hSpar->hFbMixer->fb_cfg->prior_input_length, shift ); // Q:q_data+shift + } ivas_fb_mixer_get_windowed_fr_fx( hSpar->hFbMixer, p_pcm_tmp_fx, ppIn_FR_real_fx, ppIn_FR_imag_fx, l_ts, l_ts, nchan_fb_in, gb ); - + FOR( i = 0; i < nchan_fb_in; i++ ) + { + scale_sig32( data_fx[i], input_frame, negate( shift ) ); // Q:q_data + scale_sig32( hSpar->hFbMixer->ppFilterbank_prior_input_fx[i], hSpar->hFbMixer->fb_cfg->prior_input_length, negate( shift ) ); // Q:q_data + } ivas_fb_mixer_update_prior_input_fx( hSpar->hFbMixer, p_pcm_tmp_fx, l_ts, nchan_fb_in ); FOR( i = 0; i < nchan_fb_in; i++ ) @@ -818,7 +844,7 @@ static ivas_error ivas_spar_enc_process_fx( /*Finding max possible q*/ Word16 pp_fr_q; - pp_fr_q = sub( q_data, gb ); + pp_fr_q = sub( add( q_data, shift ), gb ); Word16 re_q = MAX_16, im_q = MAX_16, FR_q; move16(); move16(); @@ -830,12 +856,12 @@ static ivas_error ivas_spar_enc_process_fx( FR_q = s_min( re_q, im_q ); FOR( i = 0; i < nchan_fb_in; i++ ) { - scale_sig32( ppIn_FR_real_fx[i], input_frame, FR_q ); - scale_sig32( ppIn_FR_imag_fx[i], input_frame, FR_q ); + scale_sig32( ppIn_FR_real_fx[i], input_frame, FR_q ); // Q(FR_q+pp_fr_q) + scale_sig32( ppIn_FR_imag_fx[i], input_frame, FR_q ); // Q(FR_q+pp_fr_q) } pp_fr_q = add( FR_q, pp_fr_q ); - IF( NE_32( ( error = ivas_dirac_enc_fx( st_ivas->hDirAC, hQMetaData, hMetaData, data_fx, ppIn_FR_real_fx, ppIn_FR_imag_fx, pp_fr_q, input_frame, dtx_vad, hEncoderConfig->ivas_format, hodirac_flag ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_dirac_enc_fx( st_ivas->hDirAC, hQMetaData, hMetaData, data_fx, ppIn_FR_real_fx, ppIn_FR_imag_fx, pp_fr_q, input_frame, dtx_vad, hEncoderConfig->ivas_format, hodirac_flag, shift ) ), IVAS_ERR_OK ) ) { return error; } @@ -892,7 +918,7 @@ static ivas_error ivas_spar_enc_process_fx( FOR( Word32 ch = ( hSpar->hFbMixer->fb_cfg->active_w_mixing == 0 ); ch < hSpar->hFbMixer->fb_cfg->num_out_chans; ch++ ) { /* changing q format to q_data*/ - scale_sig32( p_pcm_tmp_fx[ch], input_frame, sub( q_data, q_p_pcm_tmp_fx[ch] ) ); + scale_sig32( p_pcm_tmp_fx[ch], input_frame, sub( q_data, q_p_pcm_tmp_fx[ch] ) ); // q_data q_p_pcm_tmp_fx[ch] = q_data; move16(); } @@ -982,7 +1008,7 @@ static ivas_error ivas_spar_enc_process_fx( FOR( i = 0; i < hSpar->hFbMixer->fb_cfg->num_out_chans; i++ ) { - scale_sig32( p_pcm_tmp_fx[i], input_frame, sub( q_data, q_pcm_fx[i] ) ); + scale_sig32( p_pcm_tmp_fx[i], input_frame, sub( q_data, q_pcm_fx[i] ) ); // q_data q_pcm_fx[i] = q_data; move16(); } diff --git a/lib_enc/ivas_spar_md_enc.c b/lib_enc/ivas_spar_md_enc.c index ca209c66bfb548ad08aef2ebf26a63df125b16b7..1d367dd52b4f26adfd0feebf65310a9e8481bd8a 100644 --- a/lib_enc/ivas_spar_md_enc.c +++ b/lib_enc/ivas_spar_md_enc.c @@ -48,7 +48,7 @@ * PreProcessor *------------------------------------------------------------------------------------------*/ /*Q28*/ -static const Word32 pr_boost_range_fx[2] = { 26843546, 107374182 }; +static const Word32 pr_boost_range_fx[2] = { 26843546 /*.1f in Q28*/, 107374182 /*.4f in Q28*/ }; typedef enum ivas_strats_t { @@ -141,8 +141,8 @@ ivas_error ivas_spar_md_enc_open_fx( } } hMdEnc->q_mixer_mat_fx = 0; - - IF( ( error = ivas_spar_md_enc_init_fx( hMdEnc, hEncoderConfig, sba_order ) ) != IVAS_ERR_OK ) + move16(); + IF( NE_32( ( error = ivas_spar_md_enc_init_fx( hMdEnc, hEncoderConfig, sba_order ) ), IVAS_ERR_OK ) ) { return error; } @@ -455,17 +455,17 @@ static void write_metadata_buffer_fx( *-----------------------------------------------------------------------------------------*/ ivas_error ivas_spar_md_enc_process_fx( - ivas_spar_md_enc_state_t *hMdEnc, /* i/o: SPAR MD encoder handle */ - const ENCODER_CONFIG_HANDLE hEncoderConfig, /* i : configuration structure */ - Word32 *cov_real_fx[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], + ivas_spar_md_enc_state_t *hMdEnc, /* i/o: SPAR MD encoder handle */ + const ENCODER_CONFIG_HANDLE hEncoderConfig, /* i : configuration structure */ + Word32 *cov_real_fx[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], /*Q(cov_real_q)*/ Word16 *cov_real_q[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], - Word32 *cov_dtx_real_fx[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], + Word32 *cov_dtx_real_fx[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], /*Q(cov_dtx_real_q)*/ Word16 *cov_dtx_real_q[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], BSTR_ENC_HANDLE hMetaData, /* i/o: MetaData handle */ const Word16 dtx_vad, const Word16 nchan_inp, const Word16 sba_order, /* i : Ambisonic (SBA) order */ - Word32 *prior_mixer[IVAS_MAX_FB_MIXER_OUT_CH][IVAS_MAX_SPAR_FB_MIXER_IN_CH], /* i : prior mixer_matrix */ + Word32 *prior_mixer[IVAS_MAX_FB_MIXER_OUT_CH][IVAS_MAX_SPAR_FB_MIXER_IN_CH], /* i : prior mixer_matrix Q(q_prior_mixer) */ Word16 *q_prior_mixer, /* i/o : q for prior mixer_matrix */ const Word16 dyn_active_w_flag, /* i : flag to indicate dynamic active W */ const Word16 dirac_mono_flag, /* i : flag to indicate mono only mode in SBA */ @@ -479,6 +479,7 @@ ivas_error ivas_spar_md_enc_process_fx( Word16 k, bwidth, num_bands, num_bands_full, num_bands_bw; Word16 active_w, nchan_transport, dmx_switch, strat; Word16 nB, bands_bw, packed_ok = 0; + move16(); ivas_strats_t cs[MAX_CODING_STRATS]; Word16 code_strat; Word16 bit_pos_start, next_ind_start; @@ -711,7 +712,7 @@ ivas_error ivas_spar_md_enc_process_fx( PR_step_e = sub( PR_step_e, Q12 ); Word16 PR_sign; - PR_sign = sub( (Word16) ( GT_32( PR_uq, 0 ) ), (Word16) ( LT_32( PR_uq, 0 ) ) ); + PR_sign = sub( extract_l( GT_32( PR_uq, 0 ) ), extract_l( LT_32( PR_uq, 0 ) ) ); hMdEnc->spar_md.band_coeffs_idx[b].pred_index_re[i] = PR_sign; move16(); @@ -989,7 +990,7 @@ ivas_error ivas_spar_md_enc_process_fx( *-----------------------------------------------------------------------------------------*/ static void ivas_band_mixer_fx( - Word32 *cov_real_fx[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], + Word32 *cov_real_fx[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], // Q(cov_real_q) Word16 *cov_real_q[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], const Word16 num_ch, Word16 *num_bands, @@ -1141,7 +1142,7 @@ static void ivas_write_spar_md_bitstream_fx( push_next_indice( hMetaData, 5, SPAR_NUM_CODING_STRAT_BITS ); FOR( i = 0; i < nB; i++ ) { - do_diff[i] = (Word16) ( NE_16( ( s_and( ( add( i, 1 ) ), 3 ) ), 1 ) ); + do_diff[i] = extract_l( NE_16( ( s_and( ( add( i, 1 ) ), 3 ) ), 1 ) ); move16(); } ivas_map_prior_coeffs_quant( &hMdEnc->spar_md_prior, &hMdEnc->spar_md_cfg, qsi, nB ); @@ -1150,7 +1151,7 @@ static void ivas_write_spar_md_bitstream_fx( push_next_indice( hMetaData, 6, SPAR_NUM_CODING_STRAT_BITS ); FOR( i = 0; i < nB; i++ ) { - do_diff[i] = (Word16) ( NE_16( ( s_and( ( add( i, 1 ) ), 3 ) ), 2 ) ); + do_diff[i] = extract_l( NE_16( ( s_and( ( add( i, 1 ) ), 3 ) ), 2 ) ); move16(); } ivas_map_prior_coeffs_quant( &hMdEnc->spar_md_prior, &hMdEnc->spar_md_cfg, qsi, nB ); @@ -1159,7 +1160,7 @@ static void ivas_write_spar_md_bitstream_fx( push_next_indice( hMetaData, 7, SPAR_NUM_CODING_STRAT_BITS ); FOR( i = 0; i < nB; i++ ) { - do_diff[i] = (Word16) ( NE_16( ( s_and( ( add( i, 1 ) ), 3 ) ), 3 ) ); + do_diff[i] = extract_l( NE_16( ( s_and( ( add( i, 1 ) ), 3 ) ), 3 ) ); move16(); } ivas_map_prior_coeffs_quant( &hMdEnc->spar_md_prior, &hMdEnc->spar_md_cfg, qsi, nB ); @@ -1327,6 +1328,7 @@ static Word16 ivas_get_arith_coded_bs_fx( { pred_cell_dims[i].dim1 = sub( add( ndm, ndec ), 1 ); move16(); + test(); IF( hMdEnc->spar_hoa_md_flag && hMdEnc->spar_hoa_dirac2spar_md_flag ) { IF( GE_16( i, SPAR_DIRAC_SPLIT_START_BAND ) ) @@ -1752,7 +1754,7 @@ static void ivas_write_parameter_bitstream_dtx_fx( zero_pad_bits = sub( zero_pad_bits, 1 ); } - WHILE( GT_16( zero_pad_bits, 0 ) ) + WHILE( zero_pad_bits > 0 ) { j = s_min( zero_pad_bits, 16 ); push_next_indice( hMetaData, 0, j ); @@ -1803,7 +1805,7 @@ static void ivas_quant_c_per_band_fx( { C_re[k] = pband_coeffs->C_re_fx[i][j]; move32(); - k = add( k, 1 ); + k++; } } ivas_quantise_real_values_enc_fx_varq( C_re, pQs->C.q_levels[0], pQs->C.min_fx, pQs->C.max_fx, pBand_coeffs_idx->drct_index_re, C_re, ndec * ( ndm - 1 ), q_C ); @@ -1815,7 +1817,7 @@ static void ivas_quant_c_per_band_fx( { pband_coeffs->C_quant_re_fx[i][j] = C_re[k]; move32(); - k = add( k, 1 ); + k++; } } diff --git a/lib_enc/ivas_stat_enc.h b/lib_enc/ivas_stat_enc.h index 9accffc8a18b84872801e3bac4959424047f5fc1..880d27bfe471822782453aa82f8094744a83baed 100644 --- a/lib_enc/ivas_stat_enc.h +++ b/lib_enc/ivas_stat_enc.h @@ -579,6 +579,7 @@ typedef struct ivas_stereo_classifier_data_structure Word32 non_sta_ch1_fx; Word16 non_sta_ch1_e; Word16 sp_div_ch1_fx; + Word16 sp_div_ch1_e; Word32 ps_sta_ch1_fx, ps_sta_ch2_fx; Word16 ps_sta_ch1_e, ps_sta_ch2_e; Word32 prev_g_IPD_fx; // Q29 diff --git a/lib_enc/ivas_stereo_adapt_GR_enc.c b/lib_enc/ivas_stereo_adapt_GR_enc.c index e5cd1da07ca953b8f15c89e553af153176f38e30..a47029be41d29591a9adbe15337d892ceeae4fa3 100644 --- a/lib_enc/ivas_stereo_adapt_GR_enc.c +++ b/lib_enc/ivas_stereo_adapt_GR_enc.c @@ -44,16 +44,16 @@ * Local function prototypes *---------------------------------------------------------------------*/ -static int16_t adapt_GR_sg( const int16_t *in, const int16_t len, const int16_t no_symb, int16_t *nbits, int16_t *in_enc, const int16_t *map0, const int16_t no_GR_ord ); +static Word16 adapt_GR_sg_fx( const Word16 *in, const Word16 len, const Word16 no_symb, Word16 *nbits, Word16 *in_enc, const Word16 *map0, const Word16 no_GR_ord ); /*---------------------------------------------------------------------* - * calculate_diff() + * calculate_diff_fx() * * calculate difference wrt previous frame and maps it to positive integer *---------------------------------------------------------------------*/ -static void calculate_diff( +static void calculate_diff_fx( const Word16 *in, /* i : current frame values */ const Word16 *prev, /* i : previous frmae values */ Word16 *in_diff, /* o : difference values */ @@ -90,14 +90,14 @@ static void calculate_diff( /*---------------------------------------------------------------------* - * calculate_bit_diff() + * calculate_bit_diff_fx() * * estimates the GR number of bits for encoding differential values * selects between GR order 0 or 1 *---------------------------------------------------------------------*/ /*! r: number of bits */ -static Word16 calculate_bit_diff( +static Word16 calculate_bit_diff_fx( Word16 *in_diff, /* i : values to be encoded */ Word16 len, /* i : number of params */ Word16 *flag_diff /* o : selected GR order */ @@ -153,7 +153,7 @@ Word16 adapt_GR_ief_fx( const Word16 no_GR_ord, /* i : number of GR order to try 2: 0,1; 3:0,1,2 */ Word16 *nbits_diff, /* o : number bits in diff encoding */ const Word16 side_gain_counter, /* i : number of frames since last abs coding */ - Word16 *side_gain_bitdiff_lp, /* i/o: LP-filtered bit difference between abs/diff */ + Word16 *side_gain_bitdiff_lp, /* i/o: LP-filtered bit difference between abs/diff Q(q_side_gain_bitdiff_lp) */ Word16 *q_side_gain_bitdiff_lp, /* i/o: Q of LP-filtered bit difference between abs/diff */ const Word16 try_diff /* i : diff coding allowed 1/0 */ ) @@ -163,12 +163,12 @@ Word16 adapt_GR_ief_fx( Word32 L_tmp, L_tmp1; Word16 exp_diff; - flag = adapt_GR_sg( in, len, no_symb, nbits, in_enc, map0, no_GR_ord ); + flag = adapt_GR_sg_fx( in, len, no_symb, nbits, in_enc, map0, no_GR_ord ); IF( try_diff ) /* inter-frame prediction allowed */ { - calculate_diff( in, prev, in_diff, len ); - nb_diff = calculate_bit_diff( in_diff, len, &flag_diff ); + calculate_diff_fx( in, prev, in_diff, len ); + nb_diff = calculate_bit_diff_fx( in_diff, len, &flag_diff ); *nbits_diff = nb_diff; move16(); @@ -202,13 +202,13 @@ Word16 adapt_GR_ief_fx( /*---------------------------------------------------------------------* - * adapt_GR_rpg1_ief() + * adapt_GR_rpg1_ief_fx() * * use adaptive GR for RPG's considering also the differential case *---------------------------------------------------------------------*/ /*! r: used GR order */ -Word16 adapt_GR_rpg1_ief( +Word16 adapt_GR_rpg1_ief_fx( const Word16 *in, /* i : res pred gains input vector */ Word16 *in_diff, /* o : encoded symbols in case of differential encoding */ const Word16 *prev, /* i : previous frame data */ @@ -254,13 +254,13 @@ Word16 adapt_GR_rpg1_ief( } ELSE { - GR_ord = adapt_GR_sg( in, len, no_symb, nbits, in_enc, maps, no_GR_ord ); + GR_ord = adapt_GR_sg_fx( in, len, no_symb, nbits, in_enc, maps, no_GR_ord ); } IF( try_diff ) { - calculate_diff( in, prev, in_diff, len ); - nb_diff = calculate_bit_diff( in_diff, len, &flag_diff ); + calculate_diff_fx( in, prev, in_diff, len ); + nb_diff = calculate_bit_diff_fx( in_diff, len, &flag_diff ); *nbits_diff = nb_diff; move16(); @@ -283,13 +283,13 @@ Word16 adapt_GR_rpg1_ief( /*---------------------------------------------------------------------* - * adapt_GR_sg() + * adapt_GR_sg_fx() * * adaptive GR coding *---------------------------------------------------------------------*/ /*! r: GR order */ -static Word16 adapt_GR_sg( +static Word16 adapt_GR_sg_fx( const Word16 *in, /* i : data to be encoded */ const Word16 len, /* i : number of params to be encoded */ const Word16 no_symb, /* i : max number of symbols */ @@ -411,13 +411,13 @@ static Word16 adapt_GR_sg( /*---------------------------------------------------------------------* - * write_GR0() + * write_GR0_fx() * * write data with GR order 0 *---------------------------------------------------------------------*/ /*! r: number of bits written */ -Word16 write_GR0( +Word16 write_GR0_fx( BSTR_ENC_HANDLE hBstr, /* i/o: Encoder bitstream handle */ const Word16 ind, /* i : bitstream index */ const Word16 *in, /* i : data to be encoded */ @@ -452,13 +452,13 @@ Word16 write_GR0( /*---------------------------------------------------------------------* - * write_GR1() + * write_GR1_fx() * * write data with GR order 1 *---------------------------------------------------------------------*/ /*! r: number of bits written */ -Word16 write_GR1( +Word16 write_GR1_fx( BSTR_ENC_HANDLE hBstr, /* i/o: Encoder bitstream handle */ const Word16 ind, /* i : bitstream index */ const Word16 *in, /* i : data to be encoded */ @@ -496,13 +496,13 @@ Word16 write_GR1( /*---------------------------------------------------------------------* - * write_GR2() + * write_GR2_fx() * * write data with GR order 2 *---------------------------------------------------------------------*/ /*! r: number of bits written */ -static Word16 write_GR2( +static Word16 write_GR2_fx( BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ const Word16 ind, /* i : bitstream index */ const Word16 *in, /* i : data to be encoded */ @@ -543,13 +543,13 @@ static Word16 write_GR2( /*---------------------------------------------------------------------* - * write_bitstream_GR() + * write_bitstream_GR_fx() * * generic GR encoder for GR order 0 or 1 *---------------------------------------------------------------------*/ /*! r: number of bits written */ -Word16 write_bitstream_GR( +Word16 write_bitstream_GR_fx( BSTR_ENC_HANDLE hBstr, /* i/o: Encoder bitstream handle */ const Word16 ind, /* i : bitstream index */ const Word16 *in, /* i : input vector */ @@ -566,11 +566,11 @@ Word16 write_bitstream_GR( IF( GR_ord == 0 ) { - nb = add( nb, write_GR0( hBstr, ind, in, len ) ); + nb = add( nb, write_GR0_fx( hBstr, ind, in, len ) ); } ELSE { - nb = add( nb, write_GR1( hBstr, ind, in, len ) ); + nb = add( nb, write_GR1_fx( hBstr, ind, in, len ) ); } return nb; @@ -578,13 +578,13 @@ Word16 write_bitstream_GR( /*---------------------------------------------------------------------* - * write_bitstream_adapt_GR() + * write_bitstream_adapt_GR_fx() * * write encoded data using adaptive GR *---------------------------------------------------------------------*/ /*! r: number of bits written */ -Word16 write_bitstream_adapt_GR( +Word16 write_bitstream_adapt_GR_fx( BSTR_ENC_HANDLE hBstr, /* i/o: Encoder bitstream handle */ const Word16 ind, /* i : bitstream index */ const Word16 *in, /* i : values to be written in bitstream */ @@ -596,8 +596,9 @@ Word16 write_bitstream_adapt_GR( Word16 nb; nb = 0; + move16(); /* first component first */ - nb = add( nb, write_GR1( hBstr, ind, in, 1 ) ); + nb = add( nb, write_GR1_fx( hBstr, ind, in, 1 ) ); /* write the GR order */ IF( EQ_16( no_GR_ord, 2 ) ) @@ -622,17 +623,17 @@ Word16 write_bitstream_adapt_GR( IF( GR_ord == 0 ) { - nb = add( nb, write_GR0( hBstr, ind, &in[1], sub( len, 1 ) ) ); + nb = add( nb, write_GR0_fx( hBstr, ind, &in[1], sub( len, 1 ) ) ); } ELSE { IF( EQ_16( GR_ord, 1 ) ) { - nb = add( nb, write_GR1( hBstr, ind, &in[1], sub( len, 1 ) ) ); + nb = add( nb, write_GR1_fx( hBstr, ind, &in[1], sub( len, 1 ) ) ); } ELSE { - nb = add( nb, write_GR2( hBstr, ind, &in[1], sub( len, 1 ) ) ); + nb = add( nb, write_GR2_fx( hBstr, ind, &in[1], sub( len, 1 ) ) ); } } diff --git a/lib_enc/ivas_stereo_classifier.c b/lib_enc/ivas_stereo_classifier.c index bf8f74b14aa5a9f2d23a7ec1d1d430ef40a284d4..3a015c77e3183eeb524d043fb9375871516125f2 100644 --- a/lib_enc/ivas_stereo_classifier.c +++ b/lib_enc/ivas_stereo_classifier.c @@ -86,18 +86,18 @@ * Local function prototypes *-------------------------------------------------------------------*/ static void rc_filter_fx( const Word32 x, Word32 *y, const Word16 order, const Word32 tau ); -static void edge_detect( const Word32 *inp, const Word16 len, const Word32 inp_min, const Word32 inp_max, Word16 *edge_str, Word16 *edge_type ); +static void edge_detect_fx( const Word32 *inp, const Word16 len, const Word32 inp_min, const Word32 inp_max, Word16 *edge_str, Word16 *edge_type ); static Word32 redge_detect_fx( const Word32 *inp, const Word16 len, const Word32 inp_min, const Word32 inp_max, Word16 *edge_min_e ); /*-------------------------------------------------------------------* - * Function select_stereo_mode() + * Function select_stereo_mode_fx() * * Select stereo technology based on output of stereo classifiers *-------------------------------------------------------------------*/ /*! r: element mode */ -Word16 select_stereo_mode( +Word16 select_stereo_mode_fx( CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ const IVAS_FORMAT ivas_format /* i : IVAS format */ ) @@ -130,11 +130,12 @@ Word16 select_stereo_mode( test(); test(); + test(); #ifdef DEBUGGING IF( GE_32( hCPE->element_brate, MIN_BRATE_MDCT_STEREO ) || ( ( ( EQ_16( ivas_format, MASA_FORMAT ) || EQ_16( ivas_format, MASA_ISM_FORMAT ) ) && LT_32( hCPE->element_brate, MASA_STEREO_MIN_BITRATE ) ) ) || ( hCPE->stereo_mode_cmdl == IVAS_CPE_DFT || hCPE->stereo_mode_cmdl == IVAS_CPE_TD ) ) #else - IF( GE_32( hCPE->element_brate, MIN_BRATE_MDCT_STEREO ) || ( ( ( EQ_16( ivas_format, MASA_FORMAT ) || EQ_16( ivas_format, MASA_ISM_FORMAT ) ) && - LT_32( hCPE->element_brate, MASA_STEREO_MIN_BITRATE ) ) ) ) + if ( GE_32( hCPE->element_brate, MIN_BRATE_MDCT_STEREO ) || ( ( ( EQ_16( ivas_format, MASA_FORMAT ) || EQ_16( ivas_format, MASA_ISM_FORMAT ) ) && + LT_32( hCPE->element_brate, MASA_STEREO_MIN_BITRATE ) ) ) ) #endif { stereo_switching_flag = 0; @@ -161,6 +162,7 @@ Word16 select_stereo_mode( test(); test(); test(); + test(); IF( EQ_16( stereo_switching_flag, 1 ) && GT_32( hCPE->element_brate, IVAS_13k2 ) && LT_16( hCPE->hCoreCoder[0]->hSpMusClas->past_dlp_fx[0], ONE_IN_Q9 ) && LT_32( hCPE->hCoreCoder[0]->hSpMusClas->wdlp_xtalk_fx, -335544 /* -0.01 in Q25 */ ) && EQ_16( hCPE->hCoreCoder[0]->vad_flag, 1 ) && ( hCPE->hStereoMdct->sw_uncorr || hStereoClassif->xtalk_decision ) ) { hStereoClassif->lrtd_mode = 1; @@ -183,7 +185,7 @@ Word16 select_stereo_mode( { test(); test(); - IF( ( EQ_16( ivas_format, MASA_FORMAT ) || EQ_16( ivas_format, MASA_ISM_FORMAT ) ) && LT_32( hCPE->element_brate, MASA_STEREO_MIN_BITRATE ) ) + if ( ( EQ_16( ivas_format, MASA_FORMAT ) || EQ_16( ivas_format, MASA_ISM_FORMAT ) ) && LT_32( hCPE->element_brate, MASA_STEREO_MIN_BITRATE ) ) { element_mode = IVAS_CPE_DFT; move16(); @@ -229,7 +231,7 @@ Word16 select_stereo_mode( test(); IF( hCPE->hStereoTD->prev_fr_LRTD_TD_dec == 0 && GT_16( hCPE->hStereoTD->tdm_FD2LRTD_SW_cnt, 15 ) && GT_16( hCPE->hStereoTD->tdm_last_LRTD_frame_cnt, 3 ) && LT_16( hCPE->hCoreCoder[0]->clas, VOICED_CLAS ) && ( GE_32( hCPE->element_brate, IVAS_16k4 ) || LT_32( hStereoClassif->xtalk_wscore_fx, 21474836 /*0.01f in Q31*/ ) ) ) { - IF( EQ_16( stereo_switching_flag, 1 ) ) + if ( EQ_16( stereo_switching_flag, 1 ) ) { element_mode = IVAS_CPE_DFT; move16(); @@ -461,9 +463,9 @@ void stereo_classifier_features_ivas_fx( Word32 epsP_fx[], /* i : LP analysis residual energies for each iteration*/ Word16 pitch[], /* i : open-loop pitch values for quantiz. Q0 */ Word16 voicing_fx[], /* i : OL maximum normalized correlation Q15 */ - Word32 cor_map_sum_fx, /* i : speech/music clasif. parameter */ - Word32 non_staX_fx, /* i : unbound non-stationarity for sp/mu clas. */ - Word16 sp_div_fx, /* i : spectral diversity feature */ + Word32 cor_map_sum_fx, /* i : speech/music clasif. parameter Q(31-cor_map_sum_e) */ + Word32 non_staX_fx, /* i : unbound non-stationarity for sp/mu clas. Q(31-non_staX_e) */ + Word16 sp_div_fx, /* i : spectral diversity feature Q(15-sp_div_e) */ const Word16 clas, /* i : signal class */ Word16 epsP_e, /*exponent for epsP_fx */ Word16 cor_map_sum_e, /*exponent for cor_map_sum_fx */ @@ -475,6 +477,8 @@ void stereo_classifier_features_ivas_fx( Word16 ener_e; Word32 lepsP_ch2_fx, ener_l_fx, ener_r_fx; + Word32 L_tmp; + Word16 exp; /* combine VAD flags from both channels */ IF( idchan == 0 ) { @@ -505,12 +509,38 @@ void stereo_classifier_features_ivas_fx( move32(); move16(); /* update Etot_up and Etot_dn based on aEn */ + exp = norm_l( hStereoClassif->ave_ener_L_fx ); + if ( sub( hStereoClassif->ave_ener_L_fx_e, exp ) < 0 ) + { + exp = hStereoClassif->ave_ener_L_fx_e; + move16(); + } + hStereoClassif->ave_ener_L_fx = L_shl( hStereoClassif->ave_ener_L_fx, exp ); + move32(); + hStereoClassif->ave_ener_L_fx_e = sub( hStereoClassif->ave_ener_L_fx_e, exp ); + move16(); + exp = norm_l( hStereoClassif->ave_ener_R_fx ); + if ( sub( hStereoClassif->ave_ener_R_fx_e, exp ) < 0 ) + { + exp = hStereoClassif->ave_ener_R_fx_e; + move16(); + } + hStereoClassif->ave_ener_R_fx = L_shl( hStereoClassif->ave_ener_R_fx, exp ); + move32(); + hStereoClassif->ave_ener_R_fx_e = sub( hStereoClassif->ave_ener_R_fx_e, exp ); + move16(); ener_l_fx = Mpy_32_16_1( BASOP_Util_Log10( L_add( L_shr( hStereoClassif->ave_ener_L_fx, 1 ), L_shr( ONE_IN_Q30, hStereoClassif->ave_ener_L_fx_e ) ), hStereoClassif->ave_ener_L_fx_e + 1 ), 10 << 11 ); /*q21*/ ener_r_fx = Mpy_32_16_1( BASOP_Util_Log10( L_add( L_shr( hStereoClassif->ave_ener_R_fx, 1 ), L_shr( ONE_IN_Q30, hStereoClassif->ave_ener_R_fx_e ) ), hStereoClassif->ave_ener_R_fx_e + 1 ), 10 << 11 ); /*q21*/ ener_e = 10; move16(); + + /*scaling Etot_buf_fx,Etot_up_fx and Etot_dn_fx to exponent ener_e*/ + exp = L_norm_arr( hStereoClassif->Etot_buf_fx, 3 ); + exp = s_min( exp, L_norm_arr( &hStereoClassif->Etot_up_fx, 1 ) ); + exp = s_min( exp, L_norm_arr( &hStereoClassif->Etot_dn_fx, 1 ) ); + Copy32( &hStereoClassif->Etot_buf_fx[0], &hStereoClassif->Etot_buf_fx[1], UNCLR_L_ETOT - 1 ); - IF( GE_16( hStereoClassif->e_Etot_buf_fx, ener_e ) ) + IF( GE_16( sub( hStereoClassif->e_Etot_buf_fx, exp ), ener_e ) ) { hStereoClassif->Etot_buf_fx[0] = L_shl( L_max( 0, L_max( ener_l_fx, ener_r_fx ) ), sub( ener_e, hStereoClassif->e_Etot_buf_fx ) ); /*scaling from q25 to 31-e_Etot_buf_fx*/ move32(); @@ -581,7 +611,7 @@ void stereo_classifier_features_ivas_fx( IF( LT_32( L_shr( hStereoClassif->Etot_up_fx, 1 ), L_add( L_shr( hStereoClassif->Etot_dn_fx, 1 ), L_shl( 20, sub( 30, hStereoClassif->e_Etot_buf_fx ) ) ) ) ) /*right shifted by 1 to avoid avoid overflow in addition*/ { hStereoClassif->Etot_dn_fx = L_shr( hStereoClassif->Etot_dn_fx, 1 ); - scale_sig32( hStereoClassif->Etot_buf_fx, 3, -1 ); + scale_sig32( hStereoClassif->Etot_buf_fx, 3, -1 ); // Q(31-(e_Etot_buf_fx+1)) hStereoClassif->e_Etot_buf_fx = add( hStereoClassif->e_Etot_buf_fx, 1 ); hStereoClassif->Etot_up_fx = L_add( hStereoClassif->Etot_dn_fx, L_shl( 20, sub( 31, hStereoClassif->e_Etot_buf_fx ) ) ); move32(); @@ -609,6 +639,7 @@ void stereo_classifier_features_ivas_fx( move32(); /* estimate VAD flag based on relative energy */ + IF( LT_32( hStereoClassif->relE_0_1_LT_fx, 214748365 /* 0.1f in Q31 */ ) ) { hStereoClassif->vad_relE = 0; @@ -629,7 +660,6 @@ void stereo_classifier_features_ivas_fx( Copy( lsf_new_fx, hStereoClassif->lsf_ch1_fx, M ); hStereoClassif->lepsP_ch1_fx = L_shr( L_sub( BASOP_Util_Loge( L_add( epsP_fx[13], L_shr( 21474 /*1e-5*2^31*/, epsP_e ) ), epsP_e ), BASOP_Util_Loge( L_add( epsP_fx[0], L_shr( 21474 /*1e-5*2^31*/, epsP_e ) ), epsP_e ) ), 10 ); /*q15*/ move32(); - move16(); hStereoClassif->xtalk_fv_fx[E_lsf_1] = Mpy_32_16_1( 419430400 /* 1/2.56f in Q30 */, lsf_new_fx[0] ); /*q15*/ hStereoClassif->xtalk_fv_fx[E_lsf_4] = Mpy_32_16_1( 419430400 /* 1/2.56f in Q30 */, lsf_new_fx[3] ); /*q15*/ @@ -721,11 +751,12 @@ void stereo_classifier_features_ivas_fx( hStereoClassif->non_sta_ch1_fx = non_staX_fx; hStereoClassif->non_sta_ch1_e = non_staX_e; hStereoClassif->sp_div_ch1_fx = sp_div_fx; + hStereoClassif->sp_div_ch1_e = sp_div_e; hStereoClassif->xtalk_fv_fx[E_cor_map_sum] = L_shr( cor_map_sum_fx, sub( 16, cor_map_sum_e ) ); /*q15*/ hStereoClassif->xtalk_fv_fx[E_nchar] = L_shr( BASOP_Util_Loge( L_add( L_shr( hStereoClassif->nchar_ch1_fx, 1 ), L_shl( 1, sub( 30, hStereoClassif->nchar_ch1_e ) ) ), add( hStereoClassif->nchar_ch1_e, 1 ) ) /*q25*/, 10 ); /*q15*/ hStereoClassif->xtalk_fv_fx[E_non_sta] = L_shr( non_staX_fx, sub( 16, non_staX_e ) ); /*q15*/ - hStereoClassif->xtalk_fv_fx[E_sp_div] = L_shr( BASOP_Util_Loge( L_deposit_h( add( shr( sp_div_fx, 1 ), shl( 1, sub( 15 - 1, sp_div_e ) ) ) ), add( sp_div_e, 1 ) ), 10 ); /*q15*/ - move32(); + L_tmp = BASOP_Util_Add_Mant32Exp( L_deposit_h( sp_div_fx ), sp_div_e, ONE_IN_Q31, 0, &exp ); + hStereoClassif->xtalk_fv_fx[E_sp_div] = L_shr( BASOP_Util_Loge( L_tmp, exp ), 10 ); /*q15*/ move32(); move32(); move32(); @@ -735,13 +766,19 @@ void stereo_classifier_features_ivas_fx( move16(); move16(); move16(); + move16(); } ELSE { hStereoClassif->xtalk_fv_fx[E_d_cor_map_sum] = L_abs( L_sub( L_shr( hStereoClassif->cor_map_sum_ch1_fx, sub( 16, hStereoClassif->cor_map_sum_ch1_e ) ) /*q15*/, L_shr( cor_map_sum_fx, sub( 16, cor_map_sum_e ) ) /*q15*/ ) ); /*q15*/ hStereoClassif->xtalk_fv_fx[E_d_nchar] = L_abs( L_shr( L_sub( BASOP_Util_Loge( L_add( L_shr( hStereoClassif->nchar_ch1_fx, 1 ), L_shl( 1, sub( 30, hStereoClassif->nchar_ch1_e ) ) ), add( hStereoClassif->nchar_ch1_e, 1 ) ), BASOP_Util_Loge( L_add( L_shr( hStereoClassif->nchar_ch2_fx, 1 ), L_shl( 1, sub( 30, hStereoClassif->nchar_ch2_e ) ) ), add( hStereoClassif->nchar_ch2_e, 1 ) ) ) /*q25*/, 10 ) ); /*q15*/ hStereoClassif->xtalk_fv_fx[E_d_non_sta] = L_abs( L_sub( L_shr( hStereoClassif->non_sta_ch1_fx, sub( 16, hStereoClassif->non_sta_ch1_e ) ) /*q15*/, L_shr( non_staX_fx, sub( 16, non_staX_e ) ) /*q15*/ ) ); /*q15*/ - hStereoClassif->xtalk_fv_fx[E_d_sp_div] = L_abs( L_shr( L_sub( BASOP_Util_Loge( L_deposit_h( add( shr( hStereoClassif->sp_div_ch1_fx, 1 ), shl( 1, sub( 15 - 1, sp_div_e ) ) ) ), add( sp_div_e, 1 ) ), BASOP_Util_Loge( L_deposit_h( add( shr( sp_div_fx, 1 ), shl( 1, sub( 15 - 1, sp_div_e ) ) ) ), add( sp_div_e, 1 ) ) ) /*q25*/, 10 ) ); /*q15*/ + L_tmp = BASOP_Util_Add_Mant32Exp( L_deposit_h( sp_div_fx ), sp_div_e, ONE_IN_Q31, 0, &exp ); + hStereoClassif->xtalk_fv_fx[E_d_sp_div] = L_shr( BASOP_Util_Loge( L_tmp, exp ), 10 ); /*q15*/ + L_tmp = BASOP_Util_Add_Mant32Exp( L_deposit_h( hStereoClassif->sp_div_ch1_fx ), hStereoClassif->sp_div_ch1_e, ONE_IN_Q31, 0, &exp ); + hStereoClassif->xtalk_fv_fx[E_d_sp_div] = L_abs( L_sub( L_shr( BASOP_Util_Loge( L_tmp, exp ), 10 ), hStereoClassif->xtalk_fv_fx[E_d_sp_div] ) ); /*q15*/ + // hStereoClassif->xtalk_fv_fx[E_d_sp_div] = L_abs( L_shr( L_sub( BASOP_Util_Loge( L_deposit_h( add( shr( hStereoClassif->sp_div_ch1_fx, 1 ), shl( 1, sub( 15 - 1, hStereoClassif->sp_div_ch1_e ) ) ) ), add( hStereoClassif->sp_div_ch1_e, 1 ) ), BASOP_Util_Loge( L_deposit_h( add( shr( sp_div_fx, 1 ), shl( 1, sub( 15 - 1, sp_div_e ) ) ) ), add( sp_div_e, 1 ) ) ) /*q25*/, 10 ) ); /*q15*/ + move32(); move32(); move32(); move32(); @@ -884,7 +921,31 @@ void unclr_classifier_td_fx( score = Mpy_32_32( score, hStereoClassif->relE_0_1_fx ); // Q31 /* rising edge detection on relE */ - relE_ST = Mean32( hStereoClassif->relE_buf_fx, UNCLR_L_RELE ); // Q31 + Word32 L_tmp = 0, tmp32; + move32(); + Word16 L_tmp_e = 0, flag = 0; + move16(); + move16(); + tmp32 = hStereoClassif->relE_buf_fx[0]; + FOR( i = 0; i < UNCLR_L_RELE; i++ ) + { + L_tmp = BASOP_Util_Add_Mant32Exp( L_tmp, L_tmp_e, hStereoClassif->relE_buf_fx[i], 0, &L_tmp_e ); + IF( NE_32( tmp32, hStereoClassif->relE_buf_fx[i] ) ) + { + flag = 1; + move16(); + } + } + IF( EQ_16( flag, 1 ) ) + { + relE_ST = L_shl( Mpy_32_32( L_tmp, ONE_BY_UNCLR_L_RELE_Q31 ), L_tmp_e ); // Q31 + } + ELSE + { + relE_ST = hStereoClassif->relE_buf_fx[0]; + move16(); + } + IF( hStereoClassif->relE_0_1_fx > relE_ST ) { rc_filter_fx( hStereoClassif->relE_0_1_fx, hStereoClassif->unclr_relE_0_1_LT_fx, UNCLR_RC_ORDER, RC_FACT_UP_Q31 ); @@ -996,7 +1057,32 @@ void unclr_classifier_dft_fx( /* rising edge detector on relE */ // relE_ST = mean(hStereoClassif->relE_buf, UNCLR_L_RELE); - relE_ST = Mean32( hStereoClassif->relE_buf_fx, UNCLR_L_RELE ); // Q31 + Word32 L_tmp = 0, tmp32; + move32(); + Word16 L_tmp_e = 0, flag = 0; + move16(); + move16(); + tmp32 = hStereoClassif->relE_buf_fx[0]; + move32(); + FOR( i = 0; i < UNCLR_L_RELE; i++ ) + { + L_tmp = BASOP_Util_Add_Mant32Exp( L_tmp, L_tmp_e, hStereoClassif->relE_buf_fx[i], 0, &L_tmp_e ); + IF( NE_32( tmp32, hStereoClassif->relE_buf_fx[i] ) ) + { + flag = 1; + move16(); + } + } + IF( EQ_16( flag, 1 ) ) + { + relE_ST = L_shl( Mpy_32_32( L_tmp, ONE_BY_UNCLR_L_RELE_Q31 ), L_tmp_e ); // Q31 + } + ELSE + { + relE_ST = hStereoClassif->relE_buf_fx[0]; + move16(); + } + IF( GT_32( hStereoClassif->relE_0_1_fx, relE_ST ) ) { // rc_filter(hStereoClassif->relE_0_1, hStereoClassif->unclr_relE_0_1_LT, UNCLR_RC_ORDER, RC_FACT_UP); @@ -1147,7 +1233,7 @@ void xtalk_classifier_td_fx( /* test rising edge (use 0 as edge_type because of newer->older buffer samples ordering) */ edge_type = 0; move16(); - edge_detect( hStereoClassif->xtalk_score_buf_fx, XTALK_SCORE_BUF_LEN, -53687091 /*-0.2f Q28*/, ONE_IN_Q28, &edge, &edge_type ); + edge_detect_fx( hStereoClassif->xtalk_score_buf_fx, XTALK_SCORE_BUF_LEN, -53687091 /*-0.2f Q28*/, ONE_IN_Q28, &edge, &edge_type ); test(); IF( edge_type == 0 && LT_16( edge, 9830 /*0.3f Q15*/ ) ) @@ -1182,6 +1268,8 @@ void xtalk_classifier_td_fx( /* binary decision w. hysteresis (switch the decision only when coder_type is GC, UC or IC) */ test(); test(); + test(); + test(); if ( ( hStereoClassif->unclr_decision == 0 && hStereoClassif->xtalk_decision == 0 && GT_32( hStereoClassif->xtalk_wscore_fx, 64424509 /*0.03f Q31*/ ) ) /*|| (hStereoClassif->xtalk_decision == 1 && hStereoClassif->xtalk_wscore < 0.00f)*/ && ( hStereoClassif->unclr_sw_enable_cnt[0] > 0 || hStereoClassif->unclr_sw_enable_cnt[1] > 0 ) ) { /* let's switch the binary decision */ @@ -1227,7 +1315,14 @@ void xtalk_classifier_dft_fx( Word64 W_tmp; hStereoClassif = hCPE->hStereoClassif; - hItd = ( hCPE->hStereoDft != NULL ) ? hCPE->hStereoDft->hItd : hCPE->hStereoMdct->hItd; + IF( hCPE->hStereoDft != NULL ) + { + hItd = hCPE->hStereoDft->hItd; + } + ELSE + { + hItd = hCPE->hStereoMdct->hItd; + } m1 = 0; move32(); @@ -1253,7 +1348,7 @@ void xtalk_classifier_dft_fx( m2 = L_abs( gcc_phat[0] ); itd2 = -XTALK_PHAT_LEN; move16(); - FOR( i = 1; i < sub( XTALK_PHAT_LEN, thr ); i++ ) + FOR( i = 1; i < ( XTALK_PHAT_LEN - thr ); i++ ) { IF( GT_32( L_abs( gcc_phat[i] ), m2 ) ) { @@ -1267,7 +1362,7 @@ void xtalk_classifier_dft_fx( m1 = L_abs( gcc_phat[itd + XTALK_PHAT_LEN] ); m2 = L_abs( gcc_phat[XTALK_PHAT_LEN + thr + 1] ); itd2 = add( thr, 1 ); - FOR( i = add( XTALK_PHAT_LEN + 2, thr ); i < 2 * XTALK_PHAT_LEN + 1; i++ ) + FOR( i = ( XTALK_PHAT_LEN + 2 + thr ); i < 2 * XTALK_PHAT_LEN + 1; i++ ) { IF( GT_32( L_abs( gcc_phat[i] ), m2 ) ) { @@ -1355,7 +1450,7 @@ void xtalk_classifier_dft_fx( /* rising edge detector on raw score -> yields 1 if strong rising edge is detected in the given buffer */ Copy32( &hStereoClassif->xtalk_score_buf_fx[0], &hStereoClassif->xtalk_score_buf_fx[1], XTALK_SCORE_BUF_LEN - 1 ); hStereoClassif->xtalk_score_buf_fx[0] = score; - + move32(); minimum_l( hStereoClassif->xtalk_score_buf_fx, XTALK_SCORE_BUF_LEN, &scr_min ); maximum_l( hStereoClassif->xtalk_score_buf_fx, XTALK_SCORE_BUF_LEN, &scr_max ); @@ -1469,14 +1564,14 @@ static void rc_filter_fx( } /*-------------------------------------------------------------------* - * Function edge_detect() + * Function edge_detect_fx() * * Rising/falling edge detection algorithm * Analyzes the input buffer and outputs strength and type of the detected edge (rising or falling) * Set edge_type to 0/1/2 when calling this function to specify the edge type you want to detect. The returned value will be modified * according to the edge type detected (-1 indicates that no edge has been detected) *-------------------------------------------------------------------*/ -static void edge_detect( +static void edge_detect_fx( const Word32 *inp, /* i : input buffer Q31*/ const Word16 len, /* i : length of the input buffer Q0*/ const Word32 inp_min, /* i : minimum value for edge detection Q28*/ @@ -1621,10 +1716,10 @@ static void edge_detect( /*! r: rising edge strength normalized to 0-1 */ static Word32 redge_detect_fx( - const Word32 *inp, /* i : input buffer (ordered from newest to oldest values)*/ + const Word32 *inp, /* i : input buffer (ordered from newest to oldest values) Q31*/ const Word16 len, /* i : length of the input buffer */ - const Word32 inp_min, /* i : minimum value for edge detection */ - const Word32 inp_max, /* i : maximum value for edge detection */ + const Word32 inp_min, /* i : minimum value for edge detection Q31 */ + const Word32 inp_max, /* i : maximum value for edge detection Q31 */ Word16 *edge_min_e ) { Word16 i, j; diff --git a/lib_enc/ivas_stereo_cng_enc.c b/lib_enc/ivas_stereo_cng_enc.c index 059eb5b8ece1f40cdb757fd7ed2e23afbea72f35..92add6cddc5169bdd1cd123455b234ca740e0fa2 100644 --- a/lib_enc/ivas_stereo_cng_enc.c +++ b/lib_enc/ivas_stereo_cng_enc.c @@ -411,7 +411,7 @@ void stereo_dft_enc_sid_coh_fx( /* Write residual index to bitstream */ IF( LE_16( add( add( res_index, 1 ), *nb_bits ), nr_of_sid_stereo_bits ) ) /* If the bit limit is reached, res_index = 0 is assumed for remaining indices */ { - *nb_bits = add( *nb_bits, write_GR0( hBstr, IND_STEREO_DFT_SID_COH, &res_index, 1 ) ); + *nb_bits = add( *nb_bits, write_GR0_fx( hBstr, IND_STEREO_DFT_SID_COH, &res_index, 1 ) ); move16(); } diff --git a/lib_enc/ivas_stereo_dft_enc.c b/lib_enc/ivas_stereo_dft_enc.c index 119dfc31349edcceace0e2edd33ccefdb55900c9..d532a9af18fc13b40ce2c44cacc16ef3c6356c5d 100644 --- a/lib_enc/ivas_stereo_dft_enc.c +++ b/lib_enc/ivas_stereo_dft_enc.c @@ -886,7 +886,7 @@ void stereo_dft_enc_update_fx( // hStereoDft->res_cod_line_max = (int16_t) ( 0.5f + ( hStereoDft->band_limits[hStereoDft->res_cod_band_max] - 1 ) * 2.f * hStereoDft->N / (float) ( hStereoDft->NFFT ) ); Word32 tmp = L_shl( L_mult0( sub( hStereoDft->band_limits[hStereoDft->res_cod_band_max], 1 ), hStereoDft->N ), 1 ); Word16 exp; - tmp = BASOP_Util_Divide3232_Scale_cadence( tmp, hStereoDft->N, &exp ); + tmp = BASOP_Util_Divide3232_Scale_cadence( tmp, hStereoDft->NFFT, &exp ); hStereoDft->res_cod_line_max = extract_l( L_shr( tmp, sub( 31, exp ) ) ); move16(); // hStereoDft->res_cod_line_max = 8 * (hStereoDft->res_cod_line_max / 8); @@ -1632,7 +1632,7 @@ void stereo_dft_enc_process_fx( // hStereoDft->res_cod_line_max = (int16_t) ( 0.5f + ( hStereoDft->band_limits[hStereoDft->res_cod_band_max] - 1 ) * 2.f * input_frame / (float) ( hStereoDft->NFFT ) ); tmp_32fx = L_shl( L_mult0( sub( hStereoDft->band_limits[hStereoDft->res_cod_band_max], 1 ), input_frame ), 1 ); tmp_32fx = BASOP_Util_Divide3216_Scale( tmp_32fx, hStereoDft->NFFT, &tmp_e ); - hStereoDft->res_cod_line_max = extract_l( L_shr_r( tmp_32fx, sub( 31, tmp_e ) ) ); + hStereoDft->res_cod_line_max = extract_l( L_shr_r( tmp_32fx, sub( -1, tmp_e ) ) ); // 15 - (31 - 15 + tmp_e) = -1 - tmp_e move16(); // hStereoDft->res_cod_line_max = 8 * (hStereoDft->res_cod_line_max / 8); hStereoDft->res_cod_line_max = shl( shr( hStereoDft->res_cod_line_max, 3 ), 3 ); @@ -1706,20 +1706,22 @@ void stereo_dft_enc_process_fx( IF( alpha_fx >= 0 ) { + c_fx = shr( c_fx, 1 ); + s_fx = shr( s_fx, 1 ); FOR( i = 1; i < hStereoDft->NFFT / 2; i++ ) { // tmp = s * c1 + c * s1; - tmp_fx = add_sat( mult_r( s_fx, c1_fx ), mult_r( c_fx, s1_fx ) ); // saturation expected + tmp_fx = add( mult_r( s_fx, c1_fx ), mult_r( c_fx, s1_fx ) ); // c = c * c1 - s * s1; - c_fx = sub_sat( mult_r( c_fx, c1_fx ), mult_r( s_fx, s1_fx ) ); // saturation expected + c_fx = sub( mult_r( c_fx, c1_fx ), mult_r( s_fx, s1_fx ) ); s_fx = tmp_fx; move16(); /*time shift of L*/ // tmp = pDFT_L[2 * i] * c - pDFT_L[2 * i + 1] * s; - tmp_32fx = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( pDFT_L_fx[2 * i], c_fx ), DFT_L_e_tmp[2 * i], L_negate( Mpy_32_16_1( pDFT_L_fx[2 * i + 1], s_fx ) ), DFT_L_e_tmp[2 * i + 1], &tmp_e ); + tmp_32fx = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( pDFT_L_fx[2 * i], c_fx ), add( DFT_L_e_tmp[2 * i], 1 ), L_negate( Mpy_32_16_1( pDFT_L_fx[2 * i + 1], s_fx ) ), add( DFT_L_e_tmp[2 * i + 1], 1 ), &tmp_e ); // pDFT_L[2 * i + 1] = pDFT_L[2 * i] * s + pDFT_L[2 * i + 1] * c; - pDFT_L_fx[2 * i + 1] = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( pDFT_L_fx[2 * i], s_fx ), DFT_L_e_tmp[2 * i], Mpy_32_16_1( pDFT_L_fx[2 * i + 1], c_fx ), DFT_L_e_tmp[2 * i + 1], &DFT_L_e_tmp[2 * i + 1] ); + pDFT_L_fx[2 * i + 1] = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( pDFT_L_fx[2 * i], s_fx ), add( DFT_L_e_tmp[2 * i], 1 ), Mpy_32_16_1( pDFT_L_fx[2 * i + 1], c_fx ), add( DFT_L_e_tmp[2 * i + 1], 1 ), &DFT_L_e_tmp[2 * i + 1] ); move32(); // pDFT_L[2 * i] = tmp; pDFT_L_fx[2 * i] = tmp_32fx; @@ -1862,8 +1864,28 @@ void stereo_dft_enc_process_fx( IF( pgIpd[0] != 0 ) { - c_fx = shl_sat( getCosWord16( extract_l( pgIpd[0] ) ), 1 ); // Q15 saturation expected - s_fx = getSinWord16( extract_l( pgIpd[0] ) ); // Q15 + Word32 theta = pgIpd[0]; + WHILE( GT_32( theta, EVS_2PI_FX ) ) + { + theta = L_sub( theta, EVS_2PI_FX ); /* Q13 */ + } + WHILE( LT_32( theta, -EVS_2PI_FX ) ) + { + theta = L_add( theta, EVS_2PI_FX ); /* Q13 */ + } + + IF( GT_32( theta, MAX_16 ) ) + { + theta = L_sub( theta, EVS_2PI_FX ); /* Q13 */ + } + ELSE IF( LT_32( theta, MIN_16 ) ) + { + theta = L_add( theta, EVS_2PI_FX ); /* Q13 */ + } + + c_fx = shl_sat( getCosWord16( extract_l( theta ) ), 1 ); + s_fx = getSinWord16( extract_l( theta ) ); + FOR( i = hStereoDft->band_limits_dmx[b]; i < hStereoDft->band_limits_dmx[b + 1]; i++ ) { /*rotate L*/ @@ -2749,7 +2771,7 @@ void stereo_dft_enc_res_fx( // in_phase_ratio = check_bounds(in_phase_ratio, 0, 1); // res_cod_gain[b] = in_phase_ratio * STEREO_DFT_RES_COD_SNR_MIN + ( 1 - in_phase_ratio ) * STEREO_DFT_RES_COD_SNR_MAX; - res_cod_gain[b] = L_add( Mpy_32_32( in_phase_ratio, STEREO_DFT_RES_COD_SNR_MIN_Q25 ), Mpy_32_32( L_sub( MAX_32, in_phase_ratio ), STEREO_DFT_RES_COD_SNR_MAX ) ); // Q25 + res_cod_gain[b] = L_add( Mpy_32_32( in_phase_ratio, STEREO_DFT_RES_COD_SNR_MIN_Q25 ), Mpy_32_32( L_sub( MAX_32, in_phase_ratio ), STEREO_DFT_RES_COD_SNR_MAX_Q25 ) ); // Q25 move32(); /*get the maximum through bands*/ @@ -2775,7 +2797,7 @@ void stereo_dft_enc_res_fx( push_wmops( "residual_encode" ); /* residual encoding */ ECSQ_init_instance_fx( &ecsq_inst, 0 /*dummy index*/, &range_uni_enc_state ); - rc_uni_enc_init( &range_uni_enc_state ); + rc_uni_enc_init_fx( &range_uni_enc_state ); ecsq_inst.bit_count_estimate = 0; move32(); @@ -2786,7 +2808,7 @@ void stereo_dft_enc_res_fx( ECSQ_encode_target_SNR_fx( &ecsq_inst, MDCT_RES, MDCT_RES_e, hStereoDft->res_cod_line_max, max_snr, max_bits - ( *nb_bits ) - STEREO_DFT_RES_GLOBAL_GAIN_BITS - 2 - 8, NULL, &global_gain_index ); IF( NE_16( global_gain_index, ECSQ_GLOBAL_GAIN_INDEX_ALL_ZERO ) ) { - total_bit_count = rc_uni_enc_finish( &range_uni_enc_state ); + total_bit_count = rc_uni_enc_finish_fx( &range_uni_enc_state ); IF( LE_16( total_bit_count, sub( sub( max_bits, *nb_bits ), STEREO_DFT_RES_GLOBAL_GAIN_BITS ) ) ) { @@ -3038,11 +3060,11 @@ void stereo_dft_enc_write_BS_fx( IF( hStereoDft->side_gain_flag_1 == 0 ) { - nb = add( nb, write_bitstream_adapt_GR( hBstr, IND_STEREO_DFT_SIDEGAINS, encoded_ind_GR, hStereoDft->nbands, hStereoDft->side_gain_flag_2, no_GR_ord ) ); + nb = add( nb, write_bitstream_adapt_GR_fx( hBstr, IND_STEREO_DFT_SIDEGAINS, encoded_ind_GR, hStereoDft->nbands, hStereoDft->side_gain_flag_2, no_GR_ord ) ); } ELSE{ IF( EQ_16( hStereoDft->side_gain_flag_1, 2 ) ){ - nb = add( nb, write_bitstream_GR( hBstr, IND_STEREO_DFT_SIDEGAINS, hStereoDft->side_gain_index_ECDiff, hStereoDft->nbands, hStereoDft->side_gain_flag_2 - no_GR_ord ) ); + nb = add( nb, write_bitstream_GR_fx( hBstr, IND_STEREO_DFT_SIDEGAINS, hStereoDft->side_gain_index_ECDiff, hStereoDft->nbands, hStereoDft->side_gain_flag_2 - no_GR_ord ) ); } ELSE { @@ -3211,18 +3233,18 @@ IF( hStereoDft->res_pred_mode[k_offset] ) { IF( EQ_16( encoded_ind_pred_GR[0], dft_maps_rpg[8 * NO_SYMB_GR_PRED_G] ) ) { - nb = add( nb, write_GR1( hBstr, IND_STEREO_DFT_PRED_GAIN_COD, encoded_ind_pred_GR, 1 ) ); + nb = add( nb, write_GR1_fx( hBstr, IND_STEREO_DFT_PRED_GAIN_COD, encoded_ind_pred_GR, 1 ) ); } ELSE { - nb = add( nb, write_bitstream_adapt_GR( hBstr, IND_STEREO_DFT_PRED_GAIN_COD, encoded_ind_pred_GR, nbands - hStereoDft->res_pred_band_min, hStereoDft->res_pred_flag_2, 2 ) ); + nb = add( nb, write_bitstream_adapt_GR_fx( hBstr, IND_STEREO_DFT_PRED_GAIN_COD, encoded_ind_pred_GR, nbands - hStereoDft->res_pred_band_min, hStereoDft->res_pred_flag_2, 2 ) ); } } ELSE { IF( EQ_16( hStereoDft->res_pred_flag_1, 2 ) ) { - nb = add( nb, write_bitstream_GR( hBstr, IND_STEREO_DFT_PRED_GAIN_COD, &hStereoDft->res_pred_index_ECDiff[hStereoDft->res_pred_band_min], nbands - hStereoDft->res_pred_band_min, hStereoDft->res_pred_flag_2 - no_GR_ord ) ); + nb = add( nb, write_bitstream_GR_fx( hBstr, IND_STEREO_DFT_PRED_GAIN_COD, &hStereoDft->res_pred_index_ECDiff[hStereoDft->res_pred_band_min], nbands - hStereoDft->res_pred_band_min, hStereoDft->res_pred_flag_2 - no_GR_ord ) ); } ELSE { @@ -4176,7 +4198,7 @@ static void res_pred_gain_mode_decision_fx( no_GR_ord = 2; move16(); - hStereoDft->res_pred_flag_2 = adapt_GR_rpg1_ief( &hStereoDft->res_pred_index_EC[hStereoDft->res_pred_band_min], &hStereoDft->res_pred_index_ECDiff[hStereoDft->res_pred_band_min], &hStereoDft->res_pred_index_ECprevious[hStereoDft->res_pred_band_min], nbands - hStereoDft->res_pred_band_min, NO_SYMB_GR_PRED_G, &n_bits, encoded_ind_pred_GR, dft_maps_rpg, &nb_diff, no_GR_ord, try_diff ); + hStereoDft->res_pred_flag_2 = adapt_GR_rpg1_ief_fx( &hStereoDft->res_pred_index_EC[hStereoDft->res_pred_band_min], &hStereoDft->res_pred_index_ECDiff[hStereoDft->res_pred_band_min], &hStereoDft->res_pred_index_ECprevious[hStereoDft->res_pred_band_min], nbands - hStereoDft->res_pred_band_min, NO_SYMB_GR_PRED_G, &n_bits, encoded_ind_pred_GR, dft_maps_rpg, &nb_diff, no_GR_ord, try_diff ); move16(); FOR( i = 0; i < nbands; i++ ) diff --git a/lib_enc/ivas_stereo_dft_enc_itd.c b/lib_enc/ivas_stereo_dft_enc_itd.c index d2873bdfe7e88bf25eb5895f58d9c713df02adc6..f65b5114cfe01a24da5fcf8d22bf6b2e8db51154 100644 --- a/lib_enc/ivas_stereo_dft_enc_itd.c +++ b/lib_enc/ivas_stereo_dft_enc_itd.c @@ -109,7 +109,7 @@ static void set_band_limits_fx( move16(); *nbands = 0; move16(); - WHILE( LT_16( band_limits[( *nbands )++], shr( NFFT, 1 ) ) ) + WHILE( band_limits[( *nbands )++] < ( NFFT / 2 ) ) { band_limits[*nbands] = extract_l( Mpy_32_32_r( shl( dft_band_limits_erb4[*nbands], 1 ), 1717986918 /*( (float) ( STEREO_DFT_N_NS_ENC ) / STEREO_DFT_N_NS ) in Q 30*/ ) ); move16(); @@ -166,7 +166,7 @@ void stereo_dft_hybrid_ITD_flag_fx( static void stereo_dft_quantize_itd_fx( const Word16 in, - Word32 *out, + Word32 *out, // Q16 const Word32 input_Fs, Word16 *ind ) { @@ -211,9 +211,9 @@ static Word32 itd_vad_ms_snr_calc_fx( #else Word32 E_band_n[STEREO_DFT_ITD_VAD_BAND_NUM], // Q0 #endif - Word32 *Spd, + Word32 *Spd, // Q(31-Spd_e) Word16 *Spd_e, - Word32 *E_band, + Word32 *E_band, // Q(31-E_band_e) Word16 *E_band_e, Word16 *ms_snr_e ) { @@ -300,9 +300,9 @@ static void itd_vad_background_update_fx( Word32 E_band_n[STEREO_DFT_ITD_VAD_BAND_NUM], // Q0 #endif Word16 *vad_frm_cnt, - const Word32 ms_snr, + const Word32 ms_snr, // Q(31-ms_snr_e) const Word16 ms_snr_e, - Word32 *E_band, + Word32 *E_band, // Q(31-E_band_e) Word16 *E_band_e ) { Word16 i; @@ -411,11 +411,11 @@ static Word16 stereo_dft_enc_itd_vad_fx( Word32 E_band_n[STEREO_DFT_ITD_VAD_BAND_NUM], // Q0 #endif Word16 *vad_frm_cnt, - Word32 *Spd_L, + Word32 *Spd_L, // Q(31-Spd_L_e) Word16 *Spd_L_e, - Word32 *Spd_R, + Word32 *Spd_R, // Q(31-Spd_R_e) Word16 *Spd_R_e, - Word32 *mssnr, + Word32 *mssnr, // Q(31-mssnr_e) Word16 *mssnr_e ) { Word16 i; @@ -472,12 +472,12 @@ static Word32 calc_mean_E_ratio_fx( ITD_DATA_HANDLE hItd, Word16 nbands, Word16 band_limits[], - const Word32 sfm, - const Word32 nrg_L[STEREO_DFT_N_32k_ENC / 2], + const Word32 sfm, // Q31 + const Word32 nrg_L[STEREO_DFT_N_32k_ENC / 2], // Q(31-nrg_L_e) const Word16 nrg_L_e[STEREO_DFT_N_32k_ENC / 2], - const Word32 nrg_R[STEREO_DFT_N_32k_ENC / 2], + const Word32 nrg_R[STEREO_DFT_N_32k_ENC / 2], // Q(31-nrg_R_e) const Word16 nrg_R_e[STEREO_DFT_N_32k_ENC / 2], - Word32 *total_mEr, + Word32 *total_mEr, // Q(31-total_mEr_e) Word16 *total_mEr_e, Word16 *sum_Er_e ) { @@ -522,7 +522,7 @@ static Word32 calc_mean_E_ratio_fx( move16(); /*take bands up to 32kHz bandwidth as ITD is always calculated at 32kHz sampling rate*/ - nbands -= ( band_limits[nbands] > STEREO_DFT_N_32k_ENC / 2 ); + nbands = sub( nbands, ( band_limits[nbands] > STEREO_DFT_N_32k_ENC / 2 ) ); sum_Er = 0; move32(); @@ -610,6 +610,8 @@ static Word32 calc_mean_E_ratio_fx( } hItd->acorr_L_fx_e = max_exp1; hItd->acorr_R_fx_e = max_exp2; + move16(); + move16(); FOR( b = 0; b < nbands; b++ ) { hItd->acorr_L_fx[b] = L_shr_r( hItd->acorr_L_fx[b], sub( hItd->acorr_L_fx_e, acorr_L_fx_tmp_e[b] ) ); @@ -656,7 +658,7 @@ static void resetEstimates_fx( set32_fx( hItd->acorr_R_fx, 0, STEREO_DFT_BAND_MAX ); hItd->acorr_R_fx_e = 0; move16(); - hItd->cohSNR_fx = 983040; + hItd->cohSNR_fx = 983040; // 15.0f in Q16 move32(); return; @@ -667,8 +669,8 @@ static void resetEstimates_fx( * time-domain smoothing filter for smoothing the cross-correlation vector *-------------------------------------------------------------------------*/ static void td_sm_filter_fx( - Word32 *x, - Word32 *y, + Word32 *x, // Q0 + Word32 *y, // Q0 const Word16 L ) { Word16 i; @@ -708,12 +710,12 @@ static Word32 peak_detect_fx( const Word16 vad, Word32 *second_max, Word16 *second_max_lag, - const Word16 prev_itd, + const Word16 prev_itd, // Q0 const Word16 flag_noisy_speech_snr, const Word16 detected_itd_flag, Word32 *prev_max, // Q31 Word16 *prev_index, - Word32 *prev_avg_max, + Word32 *prev_avg_max, // Q(31-prev_avg_max) Word16 *prev_avg_max_e, Word32 *total_max, // xcorr_itd_e Word16 *out_e ) @@ -764,7 +766,7 @@ static Word32 peak_detect_fx( /*if maximum is out of boundaries signal zero itd OR maximum value is negative*/ test(); - *zero_itd_flag = ( L_sub( *max_max, 4294968 ) < max_low || *max_max < max_high ); + *zero_itd_flag = ( L_sub( *max_max, 4294968 /*.002 Q31*/ ) < max_low || *max_max < max_high ); move16(); // adjustment is done for matching processing path with float code (differing due to precision loss) @@ -870,7 +872,7 @@ static Word32 peak_detect_fx( test(); test(); test(); - if ( vad && thres_diff > 0 && ( ( BASOP_Util_Cmp_Mant32Exp( thres_diff, thres_diff_e, 107374182, 0 ) < 0 && ( BASOP_Util_Cmp_Mant32Exp( snr, 15, 15, 31 ) <= 0 && BASOP_Util_Cmp_Mant32Exp( snr, 15, 7, 31 ) > 0 ) ) || ( BASOP_Util_Cmp_Mant32Exp( thres_diff, thres_diff_e, 21474836, 0 ) < 0 && ( BASOP_Util_Cmp_Mant32Exp( snr, 15, 15, 31 ) > 0 && BASOP_Util_Cmp_Mant32Exp( snr, 15, 30, 31 ) < 0 ) ) ) ) + if ( vad && thres_diff > 0 && ( ( BASOP_Util_Cmp_Mant32Exp( thres_diff, thres_diff_e, 107374182 /*.05 in Q31*/, 0 ) < 0 && ( BASOP_Util_Cmp_Mant32Exp( snr, 15, 15, 31 ) <= 0 && BASOP_Util_Cmp_Mant32Exp( snr, 15, 7, 31 ) > 0 ) ) || ( BASOP_Util_Cmp_Mant32Exp( thres_diff, thres_diff_e, 21474836 /* 0.01f in Q31*/, 0 ) < 0 && ( BASOP_Util_Cmp_Mant32Exp( snr, 15, 15, 31 ) > 0 && BASOP_Util_Cmp_Mant32Exp( snr, 15, 30, 31 ) < 0 ) ) ) ) { wfac = ONE_IN_Q30; // 2.0f move32(); @@ -887,7 +889,7 @@ static Word32 peak_detect_fx( move32(); } // else if ( detected_itd_flag == 0 && *max_max > 1.5f * avg_max && *prev_max > 1.5f * *prev_avg_max && abs( *index - *prev_index ) <= 2 ) - ELSE IF( detected_itd_flag == 0 && BASOP_Util_Cmp_Mant32Exp( *max_max, 0, Mpy_32_32( 1610612736, avg_max ), add( sum_max_e, 1 ) ) > 0 && BASOP_Util_Cmp_Mant32Exp( *prev_max, 0, Mpy_32_32( 1610612736, *prev_avg_max ), add( *prev_avg_max_e, 1 ) ) > 0 && LE_16( abs_s( sub( *index, *prev_index ) ), 2 ) ) + ELSE IF( detected_itd_flag == 0 && BASOP_Util_Cmp_Mant32Exp( *max_max, 0, Mpy_32_32( 1610612736 /*1.5f in Q29*/, avg_max ), add( sum_max_e, 1 ) ) > 0 && BASOP_Util_Cmp_Mant32Exp( *prev_max, 0, Mpy_32_32( 1610612736 /*1.5f in Q29*/, *prev_avg_max ), add( *prev_avg_max_e, 1 ) ) > 0 && LE_16( abs_s( sub( *index, *prev_index ) ), 2 ) ) { wfac = 805306368; // 1.5f in Q29 move32(); @@ -1122,13 +1124,13 @@ void stereo_dft_enc_compute_itd_fx( move32(); prod_R_e = 0; move16(); - sum_nrg_L = Mpy_32_32( pDFT_L[0], pDFT_L[0] ) /*+ FLT_MIN*/; + sum_nrg_L = Mpy_32_32( pDFT_L[0], pDFT_L[0] ) /*+ FLT_MIN Q(31-(2*DFT_L_e))*/; sum_nrg_L_e = shl( DFT_L_e[0], 1 ); - sum_nrg_R = Mpy_32_32( pDFT_R[0], pDFT_R[0] ) /*+ FLT_MIN*/; + sum_nrg_R = Mpy_32_32( pDFT_R[0], pDFT_R[0] ) /*+ FLT_MIN //Q(31-(2*DFT_L_e))*/; sum_nrg_R_e = shl( DFT_R_e[0], 1 ); sum_abs_L = BASOP_Util_Add_Mant32Exp( L_abs( pDFT_L[0] ), DFT_L_e[0], EPSILON_FX_M, EPSILON_FX_E, &sum_abs_L_e ) /*+ EPSILON*/; sum_abs_R = BASOP_Util_Add_Mant32Exp( L_abs( pDFT_R[0] ), DFT_R_e[0], EPSILON_FX_M, EPSILON_FX_E, &sum_abs_R_e ) /*+ EPSILON*/; - xcorr_lb[0] = Mpy_32_32( pDFT_L[0], pDFT_L[0] ); + xcorr_lb[0] = Mpy_32_32( pDFT_L[0], pDFT_L[0] ); // Q(31-(2*DFT_L_e)) move32(); xcorr_lb_e[0] = shl( DFT_L_e[0], 1 ); move16(); @@ -1160,6 +1162,7 @@ void stereo_dft_enc_compute_itd_fx( set16_fx( Spd_R_e, 0, STEREO_DFT_N_32k_ENC / 2 + 1 ); j = 0; // for loop statement + move16(); FOR( i = 1; i < NFFT_mid; i++ ) { /*if ( i == 121 ) @@ -1319,7 +1322,7 @@ void stereo_dft_enc_compute_itd_fx( j = 0; move16(); } - j++; // for loop statement + j = add( j, 1 ); // for loop statement } /* collect UNCLR classifier parameters */ @@ -1494,7 +1497,7 @@ void stereo_dft_enc_compute_itd_fx( // sfm_L = expf( log_prod_L / ( NFFT_mid ) ) / ( sum_abs_L / ( NFFT_mid ) ); L_temp = BASOP_Util_Divide3232_Scale_cadence( log_prod_L, NFFT_mid, &L_temp_e ); L_temp_e = add( L_temp_e, sub( log_prod_L_e, 31 ) ); - L_temp = BASOP_Util_fPow( 1459366444, 2, L_temp, L_temp_e, &L_temp_e ); + L_temp = BASOP_Util_fPow( 1459366444 /*2.718 in Q29*/, 2, L_temp, L_temp_e, &L_temp_e ); q_temp = norm_l( NFFT_mid ); L_temp2 = L_shl( NFFT_mid, q_temp ); L_temp2_e = sub( 31, q_temp ); @@ -1518,7 +1521,7 @@ void stereo_dft_enc_compute_itd_fx( // sfm_R = expf( log_prod_R / ( NFFT_mid ) ) / ( sum_abs_R / ( NFFT_mid ) ); L_temp = BASOP_Util_Divide3232_Scale_cadence( log_prod_R, NFFT_mid, &L_temp_e ); L_temp_e = add( L_temp_e, sub( log_prod_R_e, 31 ) ); - L_temp = BASOP_Util_fPow( 1459366444, 2, L_temp, L_temp_e, &L_temp_e ); + L_temp = BASOP_Util_fPow( 1459366444 /*2.718 in Q29*/, 2, L_temp, L_temp_e, &L_temp_e ); q_temp = norm_l( NFFT_mid ); L_temp2 = L_shl( NFFT_mid, q_temp ); L_temp2_e = sub( 31, q_temp ); @@ -1718,7 +1721,7 @@ void stereo_dft_enc_compute_itd_fx( hStereoDft->currentNumUpdates = add( hStereoDft->currentNumUpdates, 1 ); move16(); - FOR( i = 1; i < shr( NFFT, 2 ); i++ ) + FOR( i = 1; i < NFFT / 4; i++ ) { /* Low pass filter cross L/R power spectrum */ // hStereoDft->xspec_smooth[2 * i] = ( 1.f - cng_xcorr_filt ) * hStereoDft->xspec_smooth[2 * i] + cng_xcorr_filt * xcorr[2 * i]; @@ -1761,6 +1764,10 @@ void stereo_dft_enc_compute_itd_fx( } } } + test(); + test(); + test(); + test(); IF( ( vad_flag_dtx[0] == 0 ) || ( hCPE->hFrontVad[0] == NULL && ( EQ_32( hCPE->hCoreCoder[0]->last_core_brate, SID_2k40 ) || EQ_32( hCPE->hCoreCoder[0]->last_core_brate, FRAME_NO_DATA ) ) ) || hCPE->hStereoCng->first_SID_after_TD ) { IF( vad_flag_dtx[0] == 0 ) @@ -1824,7 +1831,9 @@ void stereo_dft_enc_compute_itd_fx( // tmpf1 += EPSILON; tmpf1 = BASOP_Util_Add_Mant32Exp( L_temp, L_temp_e, EPSILON_FX_M, EPSILON_FX_E, &tmpf1_e ); tmpf2 = tmpf1; + move32(); tmpf2_e = tmpf1_e; + move16(); // tmpf1 = powf( tmpf1, alpha ); tmpf1 = BASOP_Util_fPow( tmpf1, tmpf1_e, alpha, 0, &tmpf1_e ); // tmpf3 += tmpf2 * tmpf1; @@ -1871,7 +1880,9 @@ void stereo_dft_enc_compute_itd_fx( // tmpf1 += EPSILON; tmpf1 = BASOP_Util_Add_Mant32Exp( L_temp, L_temp_e, EPSILON_FX_M, EPSILON_FX_E, &tmpf1_e ); tmpf2 = tmpf1; + move32(); tmpf2_e = tmpf1_e; + move16(); // tmpf1 = powf( tmpf1, alpha ); tmpf1 = BASOP_Util_fPow( tmpf1, tmpf1_e, alpha, 0, &tmpf1_e ); // tmpf3 += tmpf2 * tmpf1; @@ -1937,7 +1948,9 @@ void stereo_dft_enc_compute_itd_fx( // tmpf1 += EPSILON; tmpf1 = BASOP_Util_Add_Mant32Exp( L_temp, L_temp_e, EPSILON_FX_M, EPSILON_FX_E, &tmpf1_e ); tmpf2 = tmpf1; + move32(); tmpf2_e = tmpf1_e; + move16(); // tmpf1 = powf( tmpf1, alpha ); tmpf1 = BASOP_Util_fPow( tmpf1, tmpf1_e, alpha, 0, &tmpf1_e ); // tmpf3 += tmpf2 * tmpf1; @@ -2080,7 +2093,7 @@ void stereo_dft_enc_compute_itd_fx( move32(); sum_xcorr_e = 0; move16(); - for ( i = 1; i < NFFT_mid; i++ ) + FOR( i = 1; i < NFFT_mid; i++ ) { // xcorr_abs[i] = logf( xcorr_abs[i] / ( sum_nrg_L + sum_nrg_R + 1e-5f ) + 1e-5f ); L_temp = BASOP_Util_Add_Mant32Exp( sum_nrg_L, sum_nrg_L_e, sum_nrg_R, sum_nrg_R_e, &L_temp_e ); @@ -2112,7 +2125,7 @@ void stereo_dft_enc_compute_itd_fx( /*smooth cohSNR with time */ // if ( ( hItd->cohSNR - cohSNR ) < 10.0f ) - IF( LT_32( L_sub( hItd->cohSNR_fx, cohSNR ), 655360 ) ) + IF( LT_32( L_sub( hItd->cohSNR_fx, cohSNR ), 655360 /*10 in Q16*/ ) ) { // tmpf1 = max( 0.05f, min( 0.25f, sfm_L * 0.5f ) ); tmpf1 = L_max( 107374182, L_min( ONE_IN_Q29, L_shr( sfm_L, 1 ) ) ); @@ -2123,7 +2136,7 @@ void stereo_dft_enc_compute_itd_fx( ELSE { // hItd->cohSNR = hItd->cohSNR - 0.05f; - hItd->cohSNR_fx = L_sub( hItd->cohSNR_fx, 3277 ); + hItd->cohSNR_fx = L_sub( hItd->cohSNR_fx, 3277 /*.05 in Q16*/ ); move32(); } @@ -2180,7 +2193,7 @@ void stereo_dft_enc_compute_itd_fx( test(); test(); test(); - IF( hCPE->hCoreCoder[0]->sp_aud_decision0 && sub( index, STEREO_DFT_ITD_MAX_ANA ) != hItd->prev_itd && !flag_noisy_speech_snr && hCPE->hCoreCoder[0]->vad_flag && LT_32( tmpf1, 644245094 ) ) + IF( hCPE->hCoreCoder[0]->sp_aud_decision0 && NE_16( sub( index, STEREO_DFT_ITD_MAX_ANA ), hItd->prev_itd ) && !flag_noisy_speech_snr && hCPE->hCoreCoder[0]->vad_flag && LT_32( tmpf1, 644245094 ) ) { // thres *= 1.0f + 1.f * min( 1.f, max( 0.f, ( -1.0f * sfm_L + 0.5f ) / ( 0.5f - 0.2f ) ) ); L_temp = BASOP_Util_Add_Mant32Exp( L_negate( sfm_L ), 0, ONE_IN_Q30, 0, &L_temp_e ); @@ -2188,6 +2201,7 @@ void stereo_dft_enc_compute_itd_fx( L_temp2_e = add( L_temp2_e, L_temp_e - 0 ); L_temp2 = L_shl_sat( L_temp2, sub( L_temp2_e, 1 ) ); // Q30 L_temp2_e = 1; + move16(); L_temp2 = L_min( ONE_IN_Q30, L_max( 0, L_temp2 ) ); L_temp2 = L_add_sat( ONE_IN_Q30, L_temp2 ); // Q30 thres = Mpy_32_32( thres, L_temp2 ); @@ -2203,7 +2217,7 @@ void stereo_dft_enc_compute_itd_fx( test(); test(); test(); - IF( hCPE->hCoreCoder[0]->ini_frame == 0 || hCPE->last_element_mode != IVAS_CPE_DFT || !hCPE->hCoreCoder[0]->sp_aud_decision0 || flag_noisy_speech_snr || BASOP_Util_Cmp_Mant32Exp( cohSNR, 15, 20, 31 ) < 0 ) + IF( hCPE->hCoreCoder[0]->ini_frame == 0 || NE_16( hCPE->last_element_mode, IVAS_CPE_DFT ) || !hCPE->hCoreCoder[0]->sp_aud_decision0 || flag_noisy_speech_snr || BASOP_Util_Cmp_Mant32Exp( cohSNR, 15, 20, 31 ) < 0 ) { hItd->itd_thres_fx = thres; move32(); @@ -2220,7 +2234,7 @@ void stereo_dft_enc_compute_itd_fx( test(); test(); test(); - IF( flag_noisy_speech_snr == 0 && hCPE->hCoreCoder[0]->vad_flag == 1 && hItd->detected_itd_flag == 0 && ( LT_16( hItd->currFlatness_fx, 192 ) /* 1.5 in Q7*/ || hCPE->hCoreCoder[0]->sp_aud_decision0 == 1 ) ) + IF( flag_noisy_speech_snr == 0 && EQ_16( hCPE->hCoreCoder[0]->vad_flag, 1 ) && hItd->detected_itd_flag == 0 && ( LT_16( hItd->currFlatness_fx, 192 ) /* 1.5 in Q7*/ || EQ_16( hCPE->hCoreCoder[0]->sp_aud_decision0, 1 ) ) ) { // hItd->itd_thres *= 1.5f; hItd->itd_thres_fx = L_shl_sat( Mpy_32_32( hItd->itd_thres_fx, 1610612736 ), 1 ); /* Saturation added to avoid assertions (this needs to be investigated) */ @@ -2241,7 +2255,7 @@ void stereo_dft_enc_compute_itd_fx( // if ( hItd->itd_tracking == 1 && ( second_max > hItd->itd_thres || tmpf1 - second_max < min( tmpf1 * 0.5f, 0.2f ) ) ) test(); test(); - if ( EQ_16( hItd->itd_tracking, 1 ) && ( GT_32( second_max, hItd->itd_thres_fx ) || LT_32( L_sub( tmpf1, second_max ), L_min( L_shr( tmpf1, 1 ), 429496730 ) ) ) ) + if ( EQ_16( hItd->itd_tracking, 1 ) && ( GT_32( second_max, hItd->itd_thres_fx ) || LT_32( L_sub( tmpf1, second_max ), L_min( L_shr( tmpf1, 1 ), 429496730 /*.2f in Q31*/ ) ) ) ) { index = second_max_lag; move16(); @@ -2249,7 +2263,7 @@ void stereo_dft_enc_compute_itd_fx( // if ( hItd->itd_tracking == 1 && abs( hItd->prev_itd - ( index - STEREO_DFT_ITD_MAX_ANA ) ) <= max( 2, (int16_t) round_f( abs( hItd->prev_itd ) / 16.f ) ) ) test(); - if ( hItd->itd_tracking == 1 && abs_s( sub( hItd->prev_itd, sub( index, STEREO_DFT_ITD_MAX_ANA ) ) ) <= s_max( 2, shr_r( abs_s( hItd->prev_itd ), 4 ) ) ) + IF( EQ_16( hItd->itd_tracking, 1 ) && LE_16( abs_s( sub( hItd->prev_itd, sub( index, STEREO_DFT_ITD_MAX_ANA ) ) ), s_max( 2, shr_r( abs_s( hItd->prev_itd ), 4 ) ) ) ) { // hItd->itd_thres *= 0.75f; hItd->itd_thres_fx = Mpy_32_32( hItd->itd_thres_fx, 1610612736 ); @@ -2435,24 +2449,33 @@ void stereo_dft_enc_compute_itd_fx( /*Breakdown of fine-control conditions */ // fc_condition_1 = abs( hItd->prev_itd ) > 0.2f * abs( itd ); - fc_condition_1 = (Word16) GT_16( abs_s( hItd->prev_itd ), mult( 6554 /*0.2f*/, abs_s( itd ) ) ); + fc_condition_1 = extract_l( GT_16( abs_s( hItd->prev_itd ), mult( 6554 /*0.2f*/, abs_s( itd ) ) ) ); // fc_condition_2 = cor_lb_avrg > 0.85f; - fc_condition_2 = (Word16) GT_32( cor_lb_avrg, 1825361101 /*0.85f*/ ); + fc_condition_2 = extract_l( GT_32( cor_lb_avrg, 1825361101 /*0.85f*/ ) ); // fc_condition_3 = ( cor_lb_avrg > 0.7f && ( cor_lb[0] > 0.9f || cor_lb[1] > 0.9f || cor_lb[2] > 0.9f ) && hItd->prev_sum_nrg_L_lb > 0.5f * sum_nrg_L_lb && hItd->prev_sum_nrg_L_lb < 2.0f * sum_nrg_L_lb ); test(); test(); test(); test(); test(); - fc_condition_3 = (Word16) ( GT_32( cor_lb_avrg, 1503238554 /*0.7f*/ ) && ( GT_32( cor_lb[0], 1932735283 /*0.9f*/ ) || GT_32( cor_lb[1], 1932735283 /*0.9f*/ ) || GT_32( cor_lb[2], 1932735283 /*0.9f*/ ) ) && + fc_condition_3 = extract_l( GT_32( cor_lb_avrg, 1503238554 /*0.7f*/ ) && ( GT_32( cor_lb[0], 1932735283 /*0.9f*/ ) || GT_32( cor_lb[1], 1932735283 /*0.9f*/ ) || GT_32( cor_lb[2], 1932735283 /*0.9f*/ ) ) && BASOP_Util_Cmp_Mant32Exp( hItd->prev_sum_nrg_L_lb_fx, hItd->prev_sum_nrg_L_lb_fx_e, sum_nrg_L_lb, sub( sum_nrg_L_lb_e, 1 ) ) > 0 && BASOP_Util_Cmp_Mant32Exp( hItd->prev_sum_nrg_L_lb_fx, hItd->prev_sum_nrg_L_lb_fx_e, sum_nrg_L_lb, add( sum_nrg_L_lb_e, 1 ) ) < 0 ); // fc_condition_4 = par_L_avrg > 0.6f; - fc_condition_4 = (Word16) GT_32( par_L_avrg, 1288490189 /*0.6f*/ ); + fc_condition_4 = extract_l( GT_32( par_L_avrg, 1288490189 /*0.6f*/ ) ); fc_condition_5 = hItd->prev_itd != 0; fc_condition_6_a = L_mult0( itd, hItd->prev_itd ) < 0; /* ITD sign change */ fc_condition_6_b = L_mult0( itd, hItd->prev_itd ) == 0; /* ITD jump to zero */ // fc_condition_6_c = abs( itd - hItd->prev_itd ) > 0.5f * ( ( abs( itd ) > abs( hItd->prev_itd ) ) ? abs( itd ) : abs( hItd->prev_itd ) ); /* Magnitude of the ITD jump */ - fc_condition_6_c = (Word16) GT_16( abs_s( sub( itd, hItd->prev_itd ) ), shr( ( ( abs_s( itd ) > abs_s( hItd->prev_itd ) ) ? abs_s( itd ) : abs_s( hItd->prev_itd ) ), 1 ) ); /* Magnitude of the ITD jump */ + fc_condition_6_c = extract_l( GT_16( abs_s( sub( itd, hItd->prev_itd ) ), shr( ( ( abs_s( itd ) > abs_s( hItd->prev_itd ) ) ? abs_s( itd ) : abs_s( hItd->prev_itd ) ), 1 ) ) ); /* Magnitude of the ITD jump */ + + IF( GT_16( abs_s( itd ), abs_s( hItd->prev_itd ) ) ) + { + fc_condition_6_c = extract_l( GT_16( abs_s( sub( itd, hItd->prev_itd ) ), shr( ( abs_s( itd ) ), 1 ) ) ); /* Magnitude of the ITD jump */ + } + ELSE + { + fc_condition_6_c = extract_l( GT_16( abs_s( sub( itd, hItd->prev_itd ) ), shr( ( abs_s( hItd->prev_itd ) ), 1 ) ) ); /* Magnitude of the ITD jump */ + } /* Combining conditions 1,2,3,4 */ test(); diff --git a/lib_enc/ivas_stereo_dft_td_itd.c b/lib_enc/ivas_stereo_dft_td_itd.c index b997495be50c065ab637383c80e992e112cdd5c5..e64e5a1ec6faa1f7359d3787ad411c5b563dda59 100644 --- a/lib_enc/ivas_stereo_dft_td_itd.c +++ b/lib_enc/ivas_stereo_dft_td_itd.c @@ -54,7 +54,7 @@ #define STEREO_DFT_CHANNEL_EXTR_LPC_VEC_LIMIT 320 #define FLR_FX 16384 // Q15 #define ONE_HALF 24576 // Q14 -const Word16 wac_swb_h_fx[LPC_SHB_ORDER + 1] = { +const Word16 wac_swb_h_fx[LPC_SHB_ORDER + 1] = { // Q15 32767, 32758, 32731, @@ -68,7 +68,7 @@ const Word16 wac_swb_h_fx[LPC_SHB_ORDER + 1] = { 31870 }; -const Word16 wac_swb_l_fx[LPC_SHB_ORDER + 1] = { +const Word16 wac_swb_l_fx[LPC_SHB_ORDER + 1] = { // Q15 32767, 29696, 20864, @@ -90,7 +90,7 @@ const Word16 wac_swb_l_fx[LPC_SHB_ORDER + 1] = { static void stereo_td_get_td_itd_fx( Word16 *td_itd, /* o : td_itd in samples at sampling frequency */ Word16 *td_itd_32, /* o : td_itd in samples at 32kHz */ - const Word32 itd, /* i : itd in samples at sampling frequency */ + const Word32 itd, /* i : itd in samples at sampling frequency q_itd */ Word16 q_itd, const Word32 input_Fs /* i : sampling frequency */ ) @@ -114,7 +114,14 @@ static void stereo_td_get_td_itd_fx( temp_e = add( temp_e, sub( sub( 31, q_itd ), d_e ) ); // e+(e1-e2)// temp_add = add_sat( temp_div, shr_sat( FLR_FX, temp_e ) ); - *td_itd_32 = shl( shr( temp_add, sub( 15, temp_e ) ), 1 ); + IF( itd != 0 ) + { + *td_itd_32 = extract_l( L_shl( L_shr( L_add( temp_add, EPSILON_FX ), sub( 15, temp_e ) ), 1 ) ); + } + ELSE + { + *td_itd_32 = shl( shr( temp_add, sub( 15, temp_e ) ), 1 ); + } move16(); *td_itd = i_mult( shr( *td_itd_32, 1 ), shr( d, sub( 15, d_e ) ) ); @@ -133,13 +140,13 @@ static void stereo_td_get_td_itd_fx( static void stereo_td_channel_extrapolate_fx( Encoder_State **sts, const Word16 dft_ovl, - const Word16 shift_mem[], + const Word16 shift_mem[], // q_shift Word16 q_shift, - Word16 shift_input[], + Word16 shift_input[], // q_shift const Word16 input_frame, const Word16 itd_shift, const Word16 lagging_channel, - Word16 *input_mem[CPE_CHANNELS], /* i/o: input buffer memory */ + Word16 *input_mem[CPE_CHANNELS], /* i/o: input buffer memory q_input_mem */ Word16 *q_input_mem, Word16 *q_new_shift ) { @@ -165,7 +172,7 @@ static void stereo_td_channel_extrapolate_fx( set16_fx( shift_combined, 0, add( L_FRAME48k, L_FRAME48k ) ); set16_fx( residual, 0, STEREO_DFT_CHANNEL_EXTR_LPC_VEC_LIMIT + ( STEREO_DFT_ITD_MAX * input_frame ) / L_FRAME32k ); - leading_channel = add( lagging_channel, 1 ) & 1; + leading_channel = s_and( add( lagging_channel, 1 ), 1 ); IF( EQ_16( sts[0]->element_mode, IVAS_CPE_DFT ) ) { size_ovl = dft_ovl; @@ -176,6 +183,8 @@ static void stereo_td_channel_extrapolate_fx( size_ovl = input_frame; pitch0 = sts[lagging_channel]->pitch[0]; } + move16(); + move16(); pred_ovlp = idiv1616( input_frame, 10 ); @@ -192,9 +201,16 @@ static void stereo_td_channel_extrapolate_fx( dot_lead_lag_1 = EPSILON_FX; dot_lead_lead_1 = EPSILON_FX; dot_lag_lag_1 = EPSILON_FX; + move64(); + move64(); + move64(); + move32(); + move32(); + move32(); FOR( i = 0; i < size_ovl; i++ ) { shift_combined[i] = shift_mem[i]; // q_shift + move16(); // q_shift_combined = q_shift; dot_lead_lag = W_mac0_16_16( dot_lead_lag, input_mem[leading_channel][i], shift_mem[i] ); dot_lead_lead = W_mac0_16_16( dot_lead_lead, input_mem[leading_channel][i], input_mem[leading_channel][i] ); @@ -202,19 +218,20 @@ static void stereo_td_channel_extrapolate_fx( } FOR( i = 0; i < input_frame - itd_shift; i++ ) { - shift_combined[add( i, size_ovl )] = shift_input[i]; // q_shift + shift_combined[i + size_ovl] = shift_input[i]; // q_shift + move16(); dot_lead_lag = W_mac0_16_16( dot_lead_lag, sts[leading_channel]->input_fx[i], shift_input[i] ); dot_lead_lead = W_mac0_16_16( dot_lead_lead, sts[leading_channel]->input_fx[i], sts[leading_channel]->input_fx[i] ); dot_lag_lag = W_mac0_16_16( dot_lag_lag, shift_input[i], shift_input[i] ); } q_dot_lead_lag = q_shift + q_input_mem[leading_channel]; // q_input_mem = q_input q_dot_lead_lead = q_input_mem[leading_channel] + q_input_mem[leading_channel]; - q_dot_lag_lag = q_shift + q_shift; + q_dot_lag_lag = add( q_shift, q_shift ); - q_dot_lead_lag = q_dot_lead_lag + W_norm( dot_lead_lag ) - 32; - q_dot_lead_lead = q_dot_lead_lead + W_norm( dot_lead_lead ) - 32; - q_dot_lag_lag = q_dot_lag_lag + W_norm( dot_lag_lag ) - 32; + q_dot_lead_lag = sub( add( q_dot_lead_lag, W_norm( dot_lead_lag ) ), 32 ); + q_dot_lead_lead = sub( add( q_dot_lead_lead, W_norm( dot_lead_lead ) ), 32 ); + q_dot_lag_lag = sub( add( q_dot_lag_lag, W_norm( dot_lag_lag ) ), 32 ); dot_lead_lag_1 = W_extract_h( W_shl( dot_lead_lag, W_norm( dot_lead_lag ) ) ); dot_lead_lead_1 = W_extract_h( W_shl( dot_lead_lead, W_norm( dot_lead_lead ) ) ); dot_lag_lag_1 = W_extract_h( W_shl( dot_lag_lag, W_norm( dot_lag_lag ) ) ); @@ -222,13 +239,13 @@ static void stereo_td_channel_extrapolate_fx( Word16 g_e, f, f_e, g_lpc_e, nsr_e; g = BASOP_Util_Divide3232_Scale( dot_lead_lag_1, dot_lead_lead_1, &g_e ); - g_e = g_e + ( q_dot_lead_lead - q_dot_lead_lag ); + g_e = add( g_e, sub( q_dot_lead_lead, q_dot_lead_lag ) ); f = BASOP_Util_Divide3232_Scale( dot_lead_lag_1, dot_lag_lag_1, &f_e ); - f_e = f_e + ( q_dot_lag_lag - q_dot_lead_lag ); + f_e = add( f_e, sub( q_dot_lag_lag, q_dot_lead_lag ) ); nsr = mult( g, f ); - nsr_e = BASOP_Util_Add_MantExp( ONE_IN_Q14, 1, negate( nsr ), g_e + f_e, &nsr ); + nsr_e = BASOP_Util_Add_MantExp( ONE_IN_Q14, 1, negate( nsr ), add( g_e, f_e ), &nsr ); IF( g_e > 0 ) { g = check_bounds_s_fx( g, negate( shl( 1, sub( 15, g_e ) ) ), shl( ONE_HALF, sub( 1, g_e ) ) ); @@ -237,11 +254,12 @@ static void stereo_td_channel_extrapolate_fx( { nsr = check_bounds_s_fx( nsr, 0, shl( 1, sub( 15, nsr_e ) ) ); } - g = shl( g, g_e - 1 ); // q14 - nsr = shl( nsr, nsr_e ); // Q15 + g = shl( g, sub( g_e, 1 ) ); // q14 + nsr = shl( nsr, nsr_e ); // Q15 g_lpc_e = 0; + move16(); g_lpc = Sqrt16( nsr, &g_lpc_e ); - g_lpc = shl( g_lpc, g_lpc_e - 1 ); // Q14 + g_lpc = shl( g_lpc, sub( g_lpc_e, 1 ) ); // Q14 /* rectangular window */ set16_fx( window, 32767, STEREO_DFT_CHANNEL_EXTR_LPC_VEC_LIMIT ); set16_zero_fx( mem_zero, STEREO_DFT_CHANNEL_EXTR_LPC_ORDER ); @@ -250,19 +268,20 @@ static void stereo_td_channel_extrapolate_fx( autocorr_ivas_fx( shift_combined + input_frame + size_ovl - itd_shift - STEREO_DFT_CHANNEL_EXTR_LPC_VEC_LIMIT, q_shift, STEREO_DFT_CHANNEL_EXTR_LPC_ORDER, r_h, r_l, &Q_r, STEREO_DFT_CHANNEL_EXTR_LPC_VEC_LIMIT, window, 0, 0, 0 ); /* Ensure R[0] isn't zero when entering Levinson-Durbin */ r_l[0] = s_max( r_l[0], 1 ); + move16(); FOR( i = 0; i <= STEREO_DFT_CHANNEL_EXTR_LPC_ORDER; i++ ) { L_tmp = Mpy_32( r_h[i], r_l[i], wac_swb_h_fx[i], wac_swb_l_fx[i] ); L_Extract( L_tmp, &r_h[i], &r_l[i] ); } r_l[0] = s_max( r_l[0], 1 ); - - + move16(); flag = E_LPC_lev_dur( r_h, r_l, A, NULL, STEREO_DFT_CHANNEL_EXTR_LPC_ORDER, NULL ); Copy_Scale_sig( A, A, STEREO_DFT_CHANNEL_EXTR_LPC_ORDER + 1, sub( norm_s( A[0] ), 2 ) ); IF( EQ_16( flag, 1 ) ) { g_lpc = 0; + move16(); } ELSE { @@ -271,15 +290,25 @@ static void stereo_td_channel_extrapolate_fx( /* extend the residual */ /* to prevent out of bound reading */ - res_shift = ( pitch_lag < PIT_MAX ? pitch_lag : itd_shift ); + IF( LT_16( pitch_lag, PIT_MAX ) ) + { + res_shift = pitch_lag; + move16(); + } + ELSE + { + res_shift = itd_shift; + move16(); + } FOR( i = STEREO_DFT_CHANNEL_EXTR_LPC_VEC_LIMIT; i < STEREO_DFT_CHANNEL_EXTR_LPC_VEC_LIMIT + itd_shift; i++ ) { residual[i] = residual[i - res_shift]; + move16(); } /* perform sythesis */ - E_UTIL_synthesis( 0, A, residual, shift_combined + input_frame + size_ovl - STEREO_DFT_CHANNEL_EXTR_LPC_VEC_LIMIT - itd_shift, STEREO_DFT_CHANNEL_EXTR_LPC_VEC_LIMIT + itd_shift, mem_zero, 0, STEREO_DFT_CHANNEL_EXTR_LPC_ORDER ); + E_UTIL_synthesis( 0, A, residual, shift_combined + sub( add( input_frame, size_ovl ), add( STEREO_DFT_CHANNEL_EXTR_LPC_VEC_LIMIT, itd_shift ) ), STEREO_DFT_CHANNEL_EXTR_LPC_VEC_LIMIT + itd_shift, mem_zero, 0, STEREO_DFT_CHANNEL_EXTR_LPC_ORDER ); } Copy( shift_combined + size_ovl, shift_input, input_frame ); // q_shift @@ -329,13 +358,13 @@ static void stereo_td_channel_extrapolate_fx( void stereo_td_itd_fx( ITD_DATA *hITD, /* i/o: ITD data structure */ - Word16 input_mem_itd[CPE_CHANNELS][STEREO_DFT_OVL_MAX], /* o : ITD memory (only used in DFT Stereo) */ + Word16 input_mem_itd[CPE_CHANNELS][STEREO_DFT_OVL_MAX], /* o : ITD memory (only used in DFT Stereo) q_input_mem_itd*/ Word16 *q_input_mem_itd, const Word16 hybrid_itd_flag, /* i : flag for hybrid TD/FD ITD processing */ const Word16 dft_ovl, /* i : size of DFT overlap */ Encoder_State **sts, /* i/o: Encoder state structure */ const Word16 input_frame, /* i : input frame length */ - Word16 *input_mem[CPE_CHANNELS], /* i/o: input buffer memory */ + Word16 *input_mem[CPE_CHANNELS], /* i/o: input buffer memory q_input_mem */ Word16 *q_input_mem ) { Word16 i, ch, n; @@ -356,23 +385,18 @@ void stereo_td_itd_fx( FOR( n = 0; n < CPE_CHANNELS; n++ ) { - Scale_sig( &input_mem[n][0], dft_ovl, sts[n]->q_inp - q_input_mem[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(); - } // check this block once + } IF( EQ_16( sts[0]->element_mode, IVAS_CPE_MDCT ) ) { - /*FOR(n = 0; n < CPE_CHANNELS; n++) - { - 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; - }*/ - // check this block onc FOR( n = 0; n < CPE_CHANNELS; n++ ) { mdct_mem[n] = sts[n]->old_input_signal_fx; + move16(); // q_mdct_mem[n] = sts[n]->q_old_inp; } } @@ -410,8 +434,8 @@ void stereo_td_itd_fx( move16(); itd_max = shr( input_frame, 2 ); - Word16 comp_flag1 = (Word16) LE_16( extract_l( L_shr( hITD->itd_fx[k_offset], Q16 ) ), itd_max ); - Word16 comp_flag2 = (Word16) LE_16( extract_l( L_shr( hITD->itd_fx[sub( k_offset, 1 )], Q16 ) ), itd_max ); + Word16 comp_flag1 = extract_l( LE_16( extract_l( L_shr( hITD->itd_fx[k_offset], Q16 ) ), itd_max ) ); + Word16 comp_flag2 = extract_l( LE_16( extract_l( L_shr( hITD->itd_fx[sub( k_offset, 1 )], Q16 ) ), itd_max ) ); assert( ( comp_flag1 ) && "ITD value is too high!" ); assert( ( comp_flag2 ) && "ITD value is too high!" ); @@ -451,7 +475,7 @@ void stereo_td_itd_fx( } /*shift past part*/ - Copy( input_mem[ch] + shift[ch], shift_mem, size_ovl - shift[ch] ); + Copy( input_mem[ch] + shift[ch], shift_mem, sub( size_ovl, shift[ch] ) ); Copy( sts[ch]->input_fx, shift_mem + size_ovl - shift[ch], shift[ch] ); q_shift_mem = sts[ch]->q_inp; move16(); @@ -465,7 +489,7 @@ void stereo_td_itd_fx( move16(); } /*shift current part*/ - Copy( sts[ch]->input_fx + shift[ch], shift_input, input_frame - shift[ch] ); + Copy( sts[ch]->input_fx + shift[ch], shift_input, sub( input_frame, shift[ch] ) ); q_shift = sts[ch]->q_inp; move16(); @@ -498,7 +522,7 @@ void stereo_td_itd_fx( Copy( shift_mem, mdct_mem[ch], input_frame ); sts[ch]->q_old_inp = q_new_shift; move16(); - Scale_sig( mdct_mem[ch], input_frame, sub( sts[ch]->q_inp, q_shift_mem ) ); + Scale_sig( mdct_mem[ch], input_frame, sub( sts[ch]->q_inp, q_shift_mem ) ); // Q(sts[ch]->q_inp) } } } @@ -528,6 +552,7 @@ void stereo_td_itd_mdct_stereo_fx( Word16 DFT_tmp_e[CPE_CHANNELS][STEREO_DFT_N_MAX_ENC]; STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct; + test(); IF( hCPE->hStereoMdct != NULL && hCPE->hStereoMdct->hItd != NULL ) { hStereoMdct = hCPE->hStereoMdct; diff --git a/lib_enc/ivas_stereo_dmx_evs.c b/lib_enc/ivas_stereo_dmx_evs.c index 4ef16ce9f9478c3996a549eb09447a7715e51be3..be470e2cfb2dda91d097b2709d576a3d362c3e27 100644 --- a/lib_enc/ivas_stereo_dmx_evs.c +++ b/lib_enc/ivas_stereo_dmx_evs.c @@ -55,54 +55,33 @@ #define STEREO_DMX_EVS_FIND_POC_PEAK_TAU 4 #define STEREO_DMX_EVS_FIND_POC_PEAK_TAU2 8 -#define STEREO_DMX_EVS_POC_GAMMA 0.75f -#define STEREO_DMX_EVS_POC_SMOOTH 1.25f #define STEREO_DMX_EVS_POC_SMOOTH_Q30 1342177280 -#define STEREO_DMX_EVS_POC_FORGETTING 0.78f #define STEREO_DMX_EVS_POC_FORGETTING_Q31 1675037245 -#define STEREO_DMX_EVS_TARGET_POC_FORGETTING 0.79f #define STEREO_DMX_EVS_TARGET_POC_FORGETTING_Q31 1696512082 -#define STEREO_DMX_EVS_POC_W_FORGETTING 0.875f -#define STEREO_DMX_EVS_SHIFT_LIMIT 5.625f /* ms */ -#define STEREO_DMX_EVS_SHIFT_LIMIT_Q12 23040 /* ms */ +#define STEREO_DMX_EVS_SHIFT_LIMIT_Q12 23040 /* ms */ -#define STEREO_DMX_EVS_DMX_EGY_FORGETTING 0.25f #define STEREO_DMX_EVS_DMX_EGY_FORGETTING_FX 536870912 // 0.25f in Q31 -#define STEREO_DMX_EVS_CORR_FORGETTING 0.78f #define STEREO_DMX_EVS_CORR_FORGETTING_FX 1610612736 /*Q31*/ #define STEREO_DMX_EVS_POC_W_FORGETTING_FX 1879048192 /*Q31*/ -#define Q_BAND 0.25f #define Q_BAND_FX 536870912 /*Q31*/ -#define STEREO_DMX_EVS_ISD_FORGETTING 0.95f #define STEREO_DMX_EVS_ISD_FORGETTING_Q15 31129 -#define STEREO_DMX_EVS_ISD_THRES_H 1.69f -#define STEREO_DMX_EVS_ISD_THRES_L 0.9f #define STEREO_DMX_EVS_ISD_THRES_L_Q31 1932735283 -#define STEREO_DMX_EVS_ISD_DIST_THRES_IPD 0.5f #define STEREO_DMX_EVS_ISD_DIST_THRES_IPD_Q15 ONE_IN_Q14 -#define STEREO_DMX_EVS_ISD_DIST_HYST_L 0.36f #define STEREO_DMX_EVS_ISD_DIST_HYST_L_Q15 11796 -#define STEREO_DMX_EVS_ISD_DIST_HYST_H 0.43f #define STEREO_DMX_EVS_ISD_DIST_HYST_H_Q15 14090 -#define STEREO_DMX_EVS_ICCR_FORGETTING 0.7f #define STEREO_DMX_EVS_ICCR_FORGETTING_Q31 1503238554 -#define STEREO_DMX_EVS_ICCR_HYST_L 0.75f #define STEREO_DMX_EVS_ICCR_HYST_L_Q31 1610612736 -#define STEREO_DMX_EVS_ICCR_HYST_H 0.85f #define STEREO_DMX_EVS_ICCR_HYST_H_Q31 1825361101 #define STEREO_DMX_EVS_SWTCH_HYS_THRES 1 -#define STEREO_DMX_EVS_LR_EGY 15.0f #define STEREO_DMX_EVS_LR_EGY_Q27 2013265920 -#define STEREO_DMX_EVS_ILDS_EGY 10000.0f #define STEREO_DMX_EVS_ILDS_EGY_Q17 1310720000 -#define STEREO_DMX_EVS_ILD_PRC 0.1f #define STEREO_DMX_EVS_ILD_PRC_Q15 3277 #define STEREO_DMX_EVS_SWTCH_PRC_THRES_16 55 @@ -110,15 +89,14 @@ #define STEREO_DMX_EVS_SWTCH_PRC_THRES_48 29 #define STEREO_DMX_EVS_SWTCH_PRC_HYS_THRES 1 -#define STEREO_DMX_EVS_FADE_LEN_PRC 20.0f +#define STEREO_DMX_EVS_FADE_LEN_PRC_Q0 20 -#define STEREO_DMX_EVS_NB_SBFRM 5 -#define STEREO_DMX_EVS_TRNS_DTC_INST 75.0f -#define STEREO_DMX_EVS_CRST_FCTR_16 80.0f -#define STEREO_DMX_EVS_CRST_FCTR_32 40.0f -#define STEREO_DMX_EVS_CRST_FCTR_48 35.0f +#define STEREO_DMX_EVS_NB_SBFRM 5 +#define STEREO_DMX_EVS_TRNS_DTC_INST_Q0 75 +#define STEREO_DMX_EVS_CRST_FCTR_16_Q0 80 +#define STEREO_DMX_EVS_CRST_FCTR_32_Q0 40 +#define STEREO_DMX_EVS_CRST_FCTR_48_Q0 35 -#define STEREO_DMX_EVS_TRNS_EGY_FORGETTING 0.75f #define STEREO_DMX_EVS_TRNS_EGY_FORGETTING_Q15 24576 const Word32 ipd_ff_Q31[STEREO_DMX_EVS_NB_SUBBAND_MAX] = { @@ -270,7 +248,7 @@ void estimate_itd_wnd_fft_fx( } rshift = sub( getScaleFactor32( rfft_buf, input_frame ), find_guarded_bits_fx( input_frame ) ); - scale_sig32( rfft_buf, input_frame, rshift ); + scale_sig32( rfft_buf, input_frame, rshift ); // Q(16+rshift) *spec_e = sub( 15, rshift ); move16(); rfft_fx( rfft_buf, rfft_coef, input_frame, -1 ); @@ -362,22 +340,22 @@ static void calc_poc_fx( // igamma = STEREO_DMX_EVS_POC_GAMMA * iN; IF( EQ_16( input_frame, L_FRAME16k ) ) { - igamma = 5033165; + igamma = 5033165; //(STEREO_DMX_EVS_POC_GAMMA/input_frame) in Q31 move16(); } ELSE IF( EQ_16( input_frame, L_FRAME32k ) ) { - igamma = 3355444; + igamma = 3355444; //(STEREO_DMX_EVS_POC_GAMMA/input_frame) in Q31 move16(); } ELSE IF( EQ_16( input_frame, L_FRAME48k ) ) { - igamma = 1677722; + igamma = 1677722; //(STEREO_DMX_EVS_POC_GAMMA/input_frame) in Q31 move16(); } ELSE { - igamma = 1677722; + igamma = 1677722; //(STEREO_DMX_EVS_POC_GAMMA/input_frame) in Q31 move16(); IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "invalid sample rate\n" ); } @@ -518,41 +496,41 @@ static void calc_poc_fx( FOR( ; i < n0 >> 3; i++ ) /* binary search from 8 angles */ { - tmp1 = Mpy_32_32_r( wnd[i * step + bias], gamma ); + tmp1 = Mpy_32_32_r( wnd[i * step + bias], gamma ); // Q31 IF( W_mult0_32_32( L_sub( specPOr[i], specPOi[i] ), L_add( specPOr[i], specPOi[i] ) ) > 0 ) { - specPOr[i] = Mpy_32_16_1( tmp1, imult1616( sign_fx( specPOr[i] ), /*0.923880f*/ s[120 * mult_angle] ) ); /* cos(PI/8)*/ + specPOr[i] = Mpy_32_16_1( tmp1, imult1616( sign_fx( specPOr[i] ), /*0.923880f*/ s[120 * mult_angle] ) ); /* cos(PI/8) Q31*/ move32(); - specPOi[i] = Mpy_32_16_1( tmp1, imult1616( sign_fx( specPOi[i] ), /*0.382683f*/ s[40 * mult_angle] ) ); + specPOi[i] = Mpy_32_16_1( tmp1, imult1616( sign_fx( specPOi[i] ), /*0.382683f*/ s[40 * mult_angle] ) ); // Q31 move32(); } ELSE { - specPOr[i] = Mpy_32_16_1( tmp1, imult1616( sign_fx( specPOr[i] ), /*0.382683f*/ s[40 * mult_angle] ) ); /* cos(PI*3/8)*/ + specPOr[i] = Mpy_32_16_1( tmp1, imult1616( sign_fx( specPOr[i] ), /*0.382683f*/ s[40 * mult_angle] ) ); /* cos(PI*3/8) Q31*/ move32(); - specPOi[i] = Mpy_32_16_1( tmp1, imult1616( sign_fx( specPOi[i] ), /*0.923880f*/ s[120 * mult_angle] ) ); + specPOi[i] = Mpy_32_16_1( tmp1, imult1616( sign_fx( specPOi[i] ), /*0.923880f*/ s[120 * mult_angle] ) ); // Q31 move32(); } gamma = L_sub( gamma, igamma ); } FOR( ; i < end; i++ ) /* binary search from 16 angles */ { - tmp1 = Mpy_32_32_r( wnd[i * step + bias], gamma ); + tmp1 = Mpy_32_32_r( wnd[i * step + bias], gamma ); // Q31 IF( W_mult0_32_32( L_sub( specPOr[i], specPOi[i] ), L_add( specPOr[i], specPOi[i] ) ) > 0 ) { IF( W_mult0_32_32( L_sub( Mpy_32_16_1( specPOr[i], 13573 /*0.414213f*/ ), specPOi[i] ), L_add( Mpy_32_16_1( specPOr[i], 13573 /*0.414213f*/ ), specPOi[i] ) ) > 0 ) /*tan(PI/8)*/ { - specPOr[i] = Mpy_32_16_1( tmp1 /*0.980785f */, imult1616( sign_fx( specPOr[i] ), s[140 * mult_angle] ) ); /* cos(PI/16)*/ + specPOr[i] = Mpy_32_16_1( tmp1 /*0.980785f */, imult1616( sign_fx( specPOr[i] ), s[140 * mult_angle] ) ); /* cos(PI/16) Q31*/ move32(); - specPOi[i] = Mpy_32_16_1( tmp1 /*0.195090f */, imult1616( sign_fx( specPOi[i] ), s[20 * mult_angle] ) ); + specPOi[i] = Mpy_32_16_1( tmp1 /*0.195090f */, imult1616( sign_fx( specPOi[i] ), s[20 * mult_angle] ) ); // Q31 move32(); } ELSE { - specPOr[i] = Mpy_32_16_1( tmp1 /* 0.831470f */, imult1616( sign_fx( specPOr[i] ), s[100 * mult_angle] ) ); /*cos(PI*3/16)*/ + specPOr[i] = Mpy_32_16_1( tmp1 /* 0.831470f */, imult1616( sign_fx( specPOr[i] ), s[100 * mult_angle] ) ); /*cos(PI*3/16) Q31*/ move32(); - specPOi[i] = Mpy_32_16_1( tmp1 /* 0.555570f*/, imult1616( sign_fx( specPOi[i] ), s[60 * mult_angle] ) ); + specPOi[i] = Mpy_32_16_1( tmp1 /* 0.555570f*/, imult1616( sign_fx( specPOi[i] ), s[60 * mult_angle] ) ); // Q31 move32(); } } @@ -560,16 +538,16 @@ static void calc_poc_fx( { IF( W_mult0_32_32( L_sub( specPOr[i], Mpy_32_16_1( specPOi[i], 13573 /*0.414213f*/ ) ), L_add( specPOr[i], Mpy_32_16_1( specPOi[i], 13573 /*0.414213f*/ ) ) ) > 0 ) /*tan(PI/8)*/ { - specPOr[i] = Mpy_32_16_1( tmp1 /** 0.555570f*/, imult1616( sign_fx( specPOr[i] ), s[60 * mult_angle] ) ); /*cos(PI*5/16)*/ + specPOr[i] = Mpy_32_16_1( tmp1 /** 0.555570f*/, imult1616( sign_fx( specPOr[i] ), s[60 * mult_angle] ) ); /*cos(PI*5/16) Q31*/ move32(); - specPOi[i] = Mpy_32_16_1( tmp1 /** 0.831470f*/, imult1616( sign_fx( specPOi[i] ), s[100 * mult_angle] ) ); + specPOi[i] = Mpy_32_16_1( tmp1 /** 0.831470f*/, imult1616( sign_fx( specPOi[i] ), s[100 * mult_angle] ) ); // Q31 move32(); } ELSE { - specPOr[i] = Mpy_32_16_1( tmp1 /** 0.195090f*/, imult1616( sign_fx( specPOr[i] ), s[20 * mult_angle] ) ); /*cos(PI*7/16)*/ + specPOr[i] = Mpy_32_16_1( tmp1 /** 0.195090f*/, imult1616( sign_fx( specPOr[i] ), s[20 * mult_angle] ) ); /*cos(PI*7/16) Q31*/ move32(); - specPOi[i] = Mpy_32_16_1( tmp1 /** 0.980785f*/, imult1616( sign_fx( specPOi[i] ), s[140 * mult_angle] ) ); + specPOi[i] = Mpy_32_16_1( tmp1 /** 0.980785f*/, imult1616( sign_fx( specPOi[i] ), s[140 * mult_angle] ) ); // Q31 move32(); } } @@ -587,11 +565,12 @@ static void calc_poc_fx( specPOi[i] = 0; move32(); } - specPOr[n0] = imult3216( Mpy_32_32_r( wnd[i * step + bias], gamma ), sign_fx( Mpy_32_32_r( specLr[n0], specRr[n0] ) ) ); + specPOr[n0] = imult3216( Mpy_32_32_r( wnd[i * step + bias], gamma ), sign_fx( Mpy_32_32_r( specLr[n0], specRr[n0] ) ) ); // Q31 move32(); hPHA->init_frmCntr = sub( hPHA->init_frmCntr, 1 ); + move16(); if ( hPHA->init_frmCntr < 0 ) { hPHA->init_frmCntr = 0; @@ -629,11 +608,11 @@ static void calc_poc_fx( 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 ), L_add( Mpy_32_32_r( Dr, Dr ), Mpy_32_32_r( 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 ) ) ) ) { 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 ) ) ) ) ) + 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 ) ) ) ) ) { isd_cnt_l = add( isd_cnt_l, 1 ); } @@ -826,8 +805,8 @@ static void calc_poc_fx( ICCr = L_shl_sat( ICCr, L_tmp_e ); // Q31 // hPHA->iccr_s = STEREO_DMX_EVS_ICCR_FORGETTING * hPHA->iccr_s + ( 1.0f - STEREO_DMX_EVS_ICCR_FORGETTING ) * ICCr; - hPHA->iccr_s_fx = L_add( Mpy_32_32_r( STEREO_DMX_EVS_ICCR_FORGETTING_Q31, hPHA->iccr_s_fx ), Mpy_32_32_r( MAX_32 - STEREO_DMX_EVS_ICCR_FORGETTING_Q31, ICCr ) ); - move16(); + hPHA->iccr_s_fx = L_add( Mpy_32_32_r( STEREO_DMX_EVS_ICCR_FORGETTING_Q31, hPHA->iccr_s_fx ), Mpy_32_32_r( MAX_32 - STEREO_DMX_EVS_ICCR_FORGETTING_Q31, ICCr ) ); // Q31 + move32(); IF( EQ_32( hPHA->curr_pha, STEREO_DMX_EVS_PHA_IPD ) ) { @@ -935,7 +914,7 @@ static void calc_poc_fx( rfft_pha_buf[i * 2 + 1] = imult3216( L_shl_r( L_tmp, sub( L_tmp_e, 9 ) ), sign_fx( rfft_pha_buf[i * 2 + 1] ) ); // Q22 move32(); // rfft_pha_buf[i * 2] = (float) sqrt( ( 1.0f + rfft_pha_buf[i * 2] ) / 2.0f ); - L_tmp = L_add( ONE_IN_Q21, L_shr( rfft_pha_buf[i * 2], 1 ) ); + L_tmp = L_add( ONE_IN_Q21, L_shr( rfft_pha_buf[i * 2], 1 ) ); // Q22 L_tmp_e = 9; move16(); L_tmp = Sqrt32( L_tmp, &L_tmp_e ); @@ -1082,7 +1061,7 @@ static void calc_poc_fx( move32(); } - tmp1 = L_shl( Mpy_32_32_r( STEREO_DMX_EVS_POC_SMOOTH_Q30, tmpPOC1[n0] ) + Mpy_32_32_r( -ONE_IN_Q28 /*0.5f * ( 1.0f - STEREO_DMX_EVS_POC_SMOOTH )*/, L_add( L_shr( tmpPOC1[n0 - 1], 1 ), L_shr( tmpPOC1[n0 + 1], 1 ) ) ), 1 ); // Q31 + tmp1 = L_shl( L_add( Mpy_32_32_r( STEREO_DMX_EVS_POC_SMOOTH_Q30, tmpPOC1[n0] ), Mpy_32_32_r( -ONE_IN_Q28 /*0.5f * ( 1.0f - STEREO_DMX_EVS_POC_SMOOTH )*/, L_add( L_shr( tmpPOC1[n0 - 1], 1 ), L_shr( tmpPOC1[n0 + 1], 1 ) ) ) ), 1 ); // Q31 tmpPOC2[n0] = L_max( tmp1, 0 ); move32(); @@ -1142,9 +1121,9 @@ 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 */ + Word32 itd_fx[], /* o : estimated itd Q16 */ const Word16 input_frame, /* i : input frame length per channel */ - const Word32 ratio_fixed /* i : adapting ratio */ + const Word32 ratio_fixed /* i : adapting ratio Q31 */ ) { Word16 itd_cand[CPE_CHANNELS], i, n, cnt[CPE_CHANNELS], Lh, peak_range, *on, *itdLR, prev_off[CPE_CHANNELS], eps_fx; @@ -1161,16 +1140,13 @@ static Word32 find_poc_peak_fx( itd_cand[0] = itd_cand[1] = 0; move16(); move16(); - move16(); - move16(); width_fx = 816043776; /*0.38f in Q31*/ eps_fx = Inv16( input_frame, &eps_e ); peak_width_fx = hPOC->peak_width_fx; peakQ_fx = hPOC->peakQ_fx; // Q16 move16(); - move16(); - move16(); + set16_fx( peakQ_e, 31 - Q16, CPE_CHANNELS ); Q_fx[0] = hPOC->P_fx[Lh]; // Q31 Q_fx[1] = 0; @@ -1203,6 +1179,7 @@ static Word32 find_poc_peak_fx( } Word16 tmp1, tmp11, tmp_var1, tmp12 = 0, tmp13; + move16(); Word32 tmp4, tmp5, tmp6, tmp7, tmp8, tmp9, tmp10, tmp14, tmp15, tmp16; Word16 tmp8_e, tmp9_e, tmp10_e, tmp11_e, tmp12_e, tmp13_e, tmp15_e; @@ -1228,7 +1205,7 @@ static Word32 find_poc_peak_fx( /*compute peak_range*/ tmp1 = idiv1616( hPOC->shift_limit, STEREO_DMX_EVS_FIND_POC_PEAK_TAU ); - peak_range = idiv1616( add( (Word16) abs( itd_cand[n] ), tmp1 ), STEREO_DMX_EVS_FIND_POC_PEAK_TAU2 ); // Q0 + peak_range = idiv1616( add( extract_l( abs( itd_cand[n] ) ), tmp1 ), STEREO_DMX_EVS_FIND_POC_PEAK_TAU2 ); // Q0 FOR( i = 1; i <= peak_range; i++ ) { @@ -1236,7 +1213,7 @@ static Word32 find_poc_peak_fx( tmp4 = L_add( P_fx[Lh - itd_cand[n] + i], P_fx[Lh - itd_cand[n] - i] ); // Q31 cQ_fx[n] = L_add( cQ_fx[n], tmp4 ); move16(); - move16(); + move32(); } /*compute eps2_fx*/ @@ -1374,9 +1351,17 @@ static Word32 find_poc_peak_fx( test(); test(); test(); + test(); IF( ( on[0] && prev_off[0] ) && ( on[1] && prev_off[1] ) ) /*if both channels have newly detected as active (possibility of preceding), select channel by peakness Q[] of POC */ { - *itd_fx = ( GT_32( Q_fx[0], Q_fx[1] ) ) ? itdLR[0] : itdLR[1]; + IF( GT_32( Q_fx[0], Q_fx[1] ) ) + { + *itd_fx = itdLR[0]; + } + ELSE + { + *itd_fx = itdLR[1]; + } } ELSE IF( ( on[0] && prev_off[0] ) && ( EQ_16( var0_flag, 1 ) ) ) /* if channel 0 becomes active, select channel 0*/ { @@ -1400,7 +1385,14 @@ static Word32 find_poc_peak_fx( } ELSE /*follow the status of the previous frame*/ { - *itd_fx = ( *itd_fx > 0 ) ? itdLR[0] : itdLR[1]; + IF( *itd_fx > 0 ) + { + *itd_fx = itdLR[0]; + } + ELSE + { + *itd_fx = itdLR[1]; + } } move32(); @@ -1420,12 +1412,12 @@ static Word32 find_poc_peak_fx( Word32 Q_sub_sqrt = Sqrt32( L_abs( L_sub( Q_fx[0], Q_fx[1] ) ), &Q_sub_sqrt_e ); cconfidence_fx = Q_sub_sqrt; move16(); - move16(); + move32(); Word32 cconfidence_var1 = Mpy_32_32( hPOC->confidence_fx, STEREO_DMX_EVS_CORR_FORGETTING_FX ); // Q31 Word32 cconfidence_var2 = Mpy_32_32( L_shr( cconfidence_fx, negate( Q_sub_sqrt_e ) ) /*Q31*/, L_sub( ONE_IN_Q30, L_shr( STEREO_DMX_EVS_CORR_FORGETTING_FX, 1 ) ) ); // Q30 hPOC->confidence_fx = L_add( cconfidence_var1, L_shl( cconfidence_var2, 1 ) ); // Q31 - move16(); + move32(); return hPOC->confidence_fx; } @@ -1497,11 +1489,11 @@ static ivas_error estimate_itd_fx( spec_e = s_max( sub( specL_e, s_min( getScaleFactor32( specLr, input_frame / 2 + 1 ), getScaleFactor32( specLi, input_frame / 2 + 1 ) ) ), sub( specR_e, s_min( getScaleFactor32( specRr, input_frame / 2 + 1 ), getScaleFactor32( specRi, input_frame / 2 + 1 ) ) ) ); - spec_e = add( spec_e, 2 ); // guard bits - scale_sig32( specLr, input_frame / 2 + 1, sub( specL_e, spec_e ) ); - scale_sig32( specLi, input_frame / 2 + 1, sub( specL_e, spec_e ) ); - scale_sig32( specRr, input_frame / 2 + 1, sub( specR_e, spec_e ) ); - scale_sig32( specRi, input_frame / 2 + 1, sub( specR_e, spec_e ) ); + spec_e = add( spec_e, 2 ); // guard bits + scale_sig32( specLr, add( shr( input_frame, 1 ), 1 ), sub( specL_e, spec_e ) ); // Q(31-(specL_e-spec_e)) + scale_sig32( specLi, add( shr( input_frame, 1 ), 1 ), sub( specL_e, spec_e ) ); // Q(31-(specL_e-spec_e)) + scale_sig32( specRr, add( shr( input_frame, 1 ), 1 ), sub( specR_e, spec_e ) ); // Q(31-(specR_e-spec_e)) + scale_sig32( specRi, add( shr( input_frame, 1 ), 1 ), sub( specR_e, spec_e ) ); // Q(31-(specR_e-spec_e)) calc_poc_fx( hPOC, hPHA, hPOC->wnd_fx, rfft_coef, specLr, specLi, specRr, specRi, spec_e, input_frame ); @@ -1571,20 +1563,20 @@ static void calc_energy_fx( move32(); wnd_diff_fx = 107374182; // initialising for L_FRAME16k =( 1.0f /20) in Q31; move32(); - switch ( input_frame ) + SWITCH( input_frame ) { case L_FRAME16k: wnd_fx = 53687091; // wnd = 0.5f / (float) adaptlen; adaptlen= 20;in Q31 wnd_diff_fx = 107374182; // wnd = 1.0f / (float) adaptlen;adaptlen= 20;in Q31 - break; + BREAK; case L_FRAME32k: wnd_fx = 26843545; // wnd = 0.5f / (float) adaptlen; adaptlen= 40;in Q31 wnd_diff_fx = 53687091; // wnd = 1.0f / (float) adaptlen;adaptlen= 40;in Q31 - break; + BREAK; case L_FRAME48k: wnd_fx = 17895697; // wnd = 0.5f / (float) adaptlen; adaptlen= 60;in Q31 wnd_diff_fx = 35791394; // wnd = 1.0f / (float) adaptlen;adaptlen= 60;in Q31 - break; + BREAK; } move32(); move32(); @@ -1622,7 +1614,7 @@ static void calc_energy_fx( q_temp32 = add( add( q_E, sub( 15, temp_e ) ), 16 ); // *energy = *energy * ratio_float + ( E / (float) input_frame ) * ( 1.0f - ratio_float ); *energy_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_32( *energy_fx, ratio_float_fx ), *energy_fx_e, Mpy_32_32( temp32, L_sub( MAX_32, ratio_float_fx ) ), sub( 31, q_temp32 ), energy_fx_e ); - + move32(); return; } @@ -1633,7 +1625,7 @@ static void calc_energy_fx( *-------------------------------------------------------------------*/ static void adapt_gain_fx( const Word32 src_fx[], /* i : input signal Q16 */ - Word32 dst_fx[], /* o : output signal */ + Word32 dst_fx[], /* o : output signal Q16 */ const Word32 gain_fx, /* i : adapting gain Q31*/ const Word32 old_gain_fx, /* i : adapting prev gain Q31*/ const Word16 input_frame, /* i : input frame length per channel */ @@ -1877,7 +1869,7 @@ void stereo_dmx_evs_enc_fx( W_tmp = W_mult_32_32( p_sub_frame[n], p_sub_frame[n] ); W_tmp_q = W_norm( W_tmp ); W_tmp = W_shl( W_tmp, W_tmp_q ); - L_tmp1 = W_extract_h( W_tmp ); + L_tmp1 = W_extract_h( W_tmp ); // Q(31-(30-W_tmp_q)) L_tmp1_e = sub( 15 * 2, W_tmp_q ); subframe_energy[m] = BASOP_Util_Add_Mant32Exp( subframe_energy[m], subframe_energy_e[m], L_tmp1, L_tmp1_e, &subframe_energy_e[m] ); move32(); @@ -1915,7 +1907,7 @@ void stereo_dmx_evs_enc_fx( L_tmp2 = BASOP_Util_Divide3232_Scale_cadence( subframe_energy[m], L_tmp1, &L_tmp2_e ); L_tmp2_e = add( L_tmp2_e, sub( subframe_energy_e[m], L_tmp1_e ) ); // if ( subframe_energy[m] / ( subframe_energy[m - 1] + EPSILON ) > STEREO_DMX_EVS_TRNS_DTC_INST ) - if ( BASOP_Util_Cmp_Mant32Exp( L_tmp2, L_tmp2_e, (Word16) STEREO_DMX_EVS_TRNS_DTC_INST, 31 ) > 0 ) + if ( BASOP_Util_Cmp_Mant32Exp( L_tmp2, L_tmp2_e, STEREO_DMX_EVS_TRNS_DTC_INST_Q0, 31 ) > 0 ) { is_transient = 1; move16(); @@ -1945,7 +1937,7 @@ void stereo_dmx_evs_enc_fx( move16(); } - create_M_signal_fx( data_fx[0], data_fx[1], dmx_poc_data, dmx_weight, input_frame, hStereoDmxEVS->s_wnd_fx, + create_M_signal_fx( data_fx[0], data_fx[1], dmx_poc_data, L_deposit_h( dmx_weight ), input_frame, hStereoDmxEVS->s_wnd_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 @@ -2101,7 +2093,7 @@ void stereo_dmx_evs_enc_fx( move16(); } - IF( hStereoDmxEVS->hPHA->curr_prc == STEREO_DMX_EVS_PRC_POC ) + IF( EQ_32( hStereoDmxEVS->hPHA->curr_prc, STEREO_DMX_EVS_PRC_POC ) ) { p_dmx_data = dmx_poc_data; @@ -2140,7 +2132,7 @@ void stereo_dmx_evs_enc_fx( } } - Copy_Scale_sig32_16( p_dmx_data, data, n_samples, 5 ); + Copy_Scale_sig32_16( p_dmx_data, data, n_samples, 5 ); // Q11->Q0 return; @@ -2293,16 +2285,16 @@ ivas_error stereo_dmx_evs_init_encoder_fx( SWITCH( input_frame ) { case 160: - hStereoDmxEVS->hPOC->eps_fx = 84331486; + hStereoDmxEVS->hPOC->eps_fx = 84331486; // (2.0f * EVS_PI / (160)) in Q31 BREAK; case 320: - hStereoDmxEVS->hPOC->eps_fx = 42165743; + hStereoDmxEVS->hPOC->eps_fx = 42165743; // (2.0f * EVS_PI / (160)) in Q31 BREAK; case 640: - hStereoDmxEVS->hPOC->eps_fx = 21082871; + hStereoDmxEVS->hPOC->eps_fx = 21082871; // (2.0f * EVS_PI / (160)) in Q31 BREAK; case 960: - hStereoDmxEVS->hPOC->eps_fx = 14055248; + hStereoDmxEVS->hPOC->eps_fx = 14055248; // (2.0f * EVS_PI / (160)) in Q31 BREAK; } move32(); @@ -2350,7 +2342,7 @@ ivas_error stereo_dmx_evs_init_encoder_fx( move16(); hStereoDmxEVS->hPHA->prc_thres = STEREO_DMX_EVS_SWTCH_PRC_THRES_16; move16(); - hStereoDmxEVS->hPHA->crst_fctr_fx = (Word16) STEREO_DMX_EVS_CRST_FCTR_16; + hStereoDmxEVS->hPHA->crst_fctr_fx = STEREO_DMX_EVS_CRST_FCTR_16_Q0; move32(); } ELSE IF( EQ_32( input_Fs, 32000 ) ) @@ -2361,7 +2353,7 @@ ivas_error stereo_dmx_evs_init_encoder_fx( move16(); hStereoDmxEVS->hPHA->prc_thres = STEREO_DMX_EVS_SWTCH_PRC_THRES_32; move16(); - hStereoDmxEVS->hPHA->crst_fctr_fx = (Word16) STEREO_DMX_EVS_CRST_FCTR_32; + hStereoDmxEVS->hPHA->crst_fctr_fx = STEREO_DMX_EVS_CRST_FCTR_32_Q0; move32(); } ELSE IF( EQ_32( input_Fs, 48000 ) ) @@ -2372,7 +2364,7 @@ ivas_error stereo_dmx_evs_init_encoder_fx( move16(); hStereoDmxEVS->hPHA->prc_thres = STEREO_DMX_EVS_SWTCH_PRC_THRES_48; move16(); - hStereoDmxEVS->hPHA->crst_fctr_fx = (Word16) STEREO_DMX_EVS_CRST_FCTR_48; + hStereoDmxEVS->hPHA->crst_fctr_fx = STEREO_DMX_EVS_CRST_FCTR_48_Q0; move32(); } ELSE @@ -2397,14 +2389,15 @@ ivas_error stereo_dmx_evs_init_encoder_fx( trans_len = idiv1616( pha_len, 20 ); set16_fx( hStereoDmxEVS->hPHA->win_fx, 29491 /*1.8f in Q15*/, sub( pha_len, trans_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++ ) { // 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 ); - move32(); + win[n] = mult_r( add( ONE_IN_Q14, getCosWord16R2( imult1616( add( n, 1 ), tmp_r ) ) ), 29491 /*1.8/2 in Q15*/ ); + move16(); } fad_g = hStereoDmxEVS->hPHA->fad_g_fx; @@ -2412,7 +2405,7 @@ ivas_error stereo_dmx_evs_init_encoder_fx( fad_r = BASOP_Util_Divide3232_Scale_cadence( 1, add( fad_len, 1 ), &tmp_e ); fad_r = L_shl_r( fad_r, tmp_e ); fad_len2 = shr( fad_len, 1 ); - FOR( ( n = 0, m = sub( fad_len, 1 ) ); n < fad_len2; ( n++, m-- ) ) + FOR( ( n = 0, m = ( fad_len - 1 ) ); n < fad_len2; ( n++, m-- ) ) { fad_g[n] = imult3216( fad_r, add( n, 1 ) ); move32(); @@ -2504,19 +2497,19 @@ ivas_error stereo_dmx_evs_init_encoder_fx( SWITCH( input_Fs ) { case 8000: - hStereoDmxEVS->hPHA->fad_len_prc = (Word16) STEREO_DMX_EVS_FADE_LEN_PRC * 8; + hStereoDmxEVS->hPHA->fad_len_prc = STEREO_DMX_EVS_FADE_LEN_PRC_Q0 * 8; move16(); BREAK; case 16000: - hStereoDmxEVS->hPHA->fad_len_prc = (Word16) STEREO_DMX_EVS_FADE_LEN_PRC * 16; + hStereoDmxEVS->hPHA->fad_len_prc = STEREO_DMX_EVS_FADE_LEN_PRC_Q0 * 16; move16(); BREAK; case 32000: - hStereoDmxEVS->hPHA->fad_len_prc = (Word16) STEREO_DMX_EVS_FADE_LEN_PRC * 32; + hStereoDmxEVS->hPHA->fad_len_prc = STEREO_DMX_EVS_FADE_LEN_PRC_Q0 * 32; move16(); BREAK; case 48000: - hStereoDmxEVS->hPHA->fad_len_prc = (Word16) STEREO_DMX_EVS_FADE_LEN_PRC * 48; + hStereoDmxEVS->hPHA->fad_len_prc = STEREO_DMX_EVS_FADE_LEN_PRC_Q0 * 48; move16(); BREAK; default: @@ -2530,7 +2523,7 @@ ivas_error stereo_dmx_evs_init_encoder_fx( fad_r = BASOP_Util_Divide3232_Scale_cadence( 1, add( fad_len, 1 ), &tmp_e ); fad_r = L_shl_r( fad_r, tmp_e ); fad_len2 = shr( fad_len, 1 ); - FOR( ( n = 0, m = sub( fad_len, 1 ) ); n < fad_len2; ( n++, m-- ) ) + FOR( ( n = 0, m = ( fad_len - 1 ) ); n < fad_len2; ( n++, m-- ) ) { fad_g[n] = imult3216( fad_r, add( n, 1 ) ); move32(); diff --git a/lib_enc/ivas_stereo_eclvq_enc.c b/lib_enc/ivas_stereo_eclvq_enc.c index d108e3add54804aea7d3c317911eadb24f69084d..118baaa69dc2e699544dea1f38a9be36fea0f335 100644 --- a/lib_enc/ivas_stereo_eclvq_enc.c +++ b/lib_enc/ivas_stereo_eclvq_enc.c @@ -69,7 +69,7 @@ static Word16 get_sign_fx( Word16 n ) * * ---------------------------------------------------------------*/ void ECSQ_quantize_vector_fx( - const Word32 *input, + const Word32 *input, // Q(31-input_e) const Word16 input_e, const Word32 global_gain, // Q15 const Word16 N, @@ -80,13 +80,25 @@ void ECSQ_quantize_vector_fx( Word16 inv_global_gain_e; // inv_global_gain = 1.0f / global_gain; - inv_global_gain = BASOP_Util_Divide3232_Scale_cadence( ONE_IN_Q15, global_gain, &inv_global_gain_e ); - inv_global_gain = L_shl( inv_global_gain, inv_global_gain_e ); // Q31 - FOR( i = 0; i < N; ++i ) + IF( EQ_32( global_gain, ONE_IN_Q15 ) ) { - // output[i] = (int16_t) round_f( input[i] * inv_global_gain ); - output[i] = extract_l( L_shr_r( Mpy_32_32( input[i], inv_global_gain ), sub( 31, input_e ) ) ); - move16(); + FOR( i = 0; i < N; ++i ) + { + // output[i] = (int16_t) round_f( input[i] * inv_global_gain ); + output[i] = extract_l( L_shr_r( input[i], sub( 31, input_e ) ) ); + move16(); + } + } + ELSE + { + inv_global_gain = BASOP_Util_Divide3232_Scale_cadence( ONE_IN_Q15, global_gain, &inv_global_gain_e ); + inv_global_gain = L_shl( inv_global_gain, inv_global_gain_e ); // Q31 + FOR( i = 0; i < N; ++i ) + { + // output[i] = (int16_t) round_f( input[i] * inv_global_gain ); + output[i] = extract_l( L_shr_r( Mpy_32_32( input[i], inv_global_gain ), sub( 31, input_e ) ) ); + move16(); + } } return; @@ -99,7 +111,7 @@ void ECSQ_quantize_vector_fx( * if all the values in output are zero, it returns 0 * ---------------------------------------------------------------*/ Word32 ECSQ_compute_optimal_gain_fx( // Q15 - const Word32 *input, + const Word32 *input, // Q(31-input_e) const Word16 input_e, const Word16 N, const Word16 *output ) @@ -107,6 +119,7 @@ Word32 ECSQ_compute_optimal_gain_fx( // Q15 Word16 i; Word32 sum_sq_output; Word32 sum_input_output; + Word16 sum_input_output_e; Word32 optimal_global_gain; Word16 optimal_global_gain_e; @@ -114,12 +127,14 @@ Word32 ECSQ_compute_optimal_gain_fx( // Q15 move32(); sum_input_output = 0; move32(); + sum_input_output_e = 0; + move16(); FOR( i = 0; i < N; ++i ) { // sum_sq_output += (float) output[i] * (float) output[i]; - sum_sq_output = L_add( sum_sq_output, L_shl( L_mult0( output[i], output[i] ), 15 ) ); // Q15 + sum_sq_output = L_add( sum_sq_output, L_mult0( output[i], output[i] ) ); // sum_input_output += input[i] * (float) output[i]; - sum_input_output = L_add( sum_input_output, L_shr( W_extract_l( W_mult0_32_32( input[i], output[i] ) ), sub( 16, input_e ) ) ); // Q15 + sum_input_output = BASOP_Util_Add_Mant32Exp( sum_input_output, sum_input_output_e, W_extract_l( W_mult0_32_32( input[i], output[i] ) ), input_e, &sum_input_output_e ); } optimal_global_gain = 0; @@ -127,8 +142,8 @@ Word32 ECSQ_compute_optimal_gain_fx( // Q15 IF( sum_sq_output != 0 ) { // optimal_global_gain = sum_input_output / sum_sq_output; - optimal_global_gain = BASOP_Util_Divide3232_Scale_cadence( sum_input_output, sum_sq_output, &optimal_global_gain_e ); - optimal_global_gain = L_shr( optimal_global_gain, sub( 16, optimal_global_gain_e ) ); // Q15 + optimal_global_gain = BASOP_Util_Divide3232_Scale_cadence( sum_input_output, sum_sq_output, &optimal_global_gain_e ); // 31 - ( sum_input_output_e - 31 + optimal_global_gain_e ) = 62 - ( sum_input_output_e + optimal_global_gain_e ) + optimal_global_gain = L_shr( optimal_global_gain, sub( sub( 62, add( sum_input_output_e, optimal_global_gain_e ) ), 15 ) ); // Q15 } return optimal_global_gain; @@ -182,7 +197,7 @@ static void arith_encode_bit_fx( IF( ecsq_inst->encoding_active ) { /* call to the actual AC */ - rc_uni_enc_encode_bits( rc_st_enc, bit, 1 ); + rc_uni_enc_encode_bits_fx( rc_st_enc, bit, 1 ); } return; @@ -206,7 +221,7 @@ static void arith_encode_bits_fx( IF( ecsq_inst->encoding_active ) { - rc_uni_enc_encode_bits( rc_st_enc, n, size ); + rc_uni_enc_encode_bits_fx( rc_st_enc, n, size ); } return; @@ -267,7 +282,7 @@ static void arith_encode_bit_prob_fx( IF( ecsq_inst->encoding_active ) { /* call to the actual AC */ - rc_uni_enc_encode_fast( rc_st_enc, bit * count0, count, 14 ); + rc_uni_enc_encode_fast_fx( rc_st_enc, u_extract_l( L_mult0( bit, count0 ) ), count, 14 ); } return; @@ -299,7 +314,7 @@ static void arith_encode_prob_fx( IF( ecsq_inst->encoding_active ) { /* call to the actual AC */ - rc_uni_enc_encode_fast( rc_st_enc, ECSQ_PROB_TOTAL - table[symbol], count, 14 ); + rc_uni_enc_encode_fast_fx( rc_st_enc, u_extract_l( UL_subNsD( ECSQ_PROB_TOTAL, table[symbol] ) ), count, 14 ); } return; @@ -336,7 +351,7 @@ static void arith_encode_elias_mod_fx( arith_encode_bit_fx( ecsq_inst, 1 ); /* encode the n_bits data bits at once */ - arith_encode_bits_fx( ecsq_inst, n - ( 1 << n_bits ), n_bits ); + arith_encode_bits_fx( ecsq_inst, u_extract_l( L_sub( n, ( shl( 1, n_bits ) ) ) ), n_bits ); } return; @@ -404,8 +419,7 @@ static Word16 get_best_param_fx( sum_abs = L_add( sum_abs, L_shl( abs_s( val ), 10 ) ); // Q10 IF( val == 0 ) { - ++count0; - move16(); + count0 = add( count0, 1 ); } } @@ -435,8 +449,7 @@ static Word16 get_best_param_fx( /* the best Laplace integer parameter is floor(log2(avg_abs_sum) + log2(offset)) */ // param = (int16_t) floor( log_base2( *avg_abs_sum * offset ) ); - param = sub( 31, norm_l( L_sub( L_shr( Mpy_32_16_1( *avg_abs_sum, offset ), 10 - 1 ), 1 ) ) ); - // sub( 31, norm_l( L_sub( n, 1 ) ) ) + param = extract_l( L_shr( L_add( BASOP_Util_Log2( Mpy_32_16_1( *avg_abs_sum, offset ) ), 738197504 /* (31-(10+14-15)) <<25 */ ), 25 ) ); /* limit param value to the available exponent range */ param = s_max( ECSQ_ALL_ZERO_PARAM + 1, param ); @@ -536,7 +549,7 @@ static Word32 ECSQ_encode_raw_fx( Word16 *input, const Word16 N ) { - int32_t bit_count_estimate_initial; + Word32 bit_count_estimate_initial; Word32 total_size; // Q10 Word16 segment_count; @@ -556,7 +569,7 @@ static Word32 ECSQ_encode_raw_fx( const UWord16 *tab_vals, *tab_abs_lsbs; bit_count_estimate_initial = ecsq_inst->bit_count_estimate; - + move32(); total_size = 0; move32(); @@ -595,7 +608,7 @@ static Word32 ECSQ_encode_raw_fx( FOR( param = first_param; param <= last_param; ++param ) { param_zb = sub( param, ECSQ_ALL_ZERO_PARAM ); - count = ECSQ_tab_param[ecsq_inst->config_index][param_zb] - ECSQ_tab_param[ecsq_inst->config_index][param_zb + 1]; + count = sub( ECSQ_tab_param[ecsq_inst->config_index][param_zb], ECSQ_tab_param[ecsq_inst->config_index][param_zb + 1] ); // test_size = scale_Q10 * code_length_from_count( count ); test_size = code_length_from_count_fx( count ); // Q10 @@ -611,6 +624,7 @@ static Word32 ECSQ_encode_raw_fx( } best_params[segment] = best_param; + move16(); total_size = L_add( total_size, best_size ); } @@ -629,6 +643,7 @@ static Word32 ECSQ_encode_raw_fx( seg_start = imult1616( segment, ECSQ_SEGMENT_SIZE ); seg_stop = add( seg_start, ECSQ_SEGMENT_SIZE - 1 ); seg_length = ECSQ_SEGMENT_SIZE; + move16(); IF( EQ_16( segment, sub( segment_count, 1 ) ) ) { seg_stop = sub( N, 1 ); @@ -744,7 +759,7 @@ static Word32 ECSQ_encode_raw_fx( Word32 ECSQ_encode_target_SNR_fx( ECSQ_instance *ecsq_inst, - const Word32 *input, + const Word32 *input, // Q(31-input_e) const Word16 input_e, const Word16 N, const Word32 target_SNR, // Q25 @@ -767,6 +782,8 @@ Word32 ECSQ_encode_target_SNR_fx( // const Word32 global_gain_step = 1165018877; // powf( 10.0f, ECLVQ_INV_GLOBAL_GAIN_FACTOR ) in Q30 Word32 L_tmp1; Word16 L_tmp1_e; + Word64 W_tmp1; + Word16 shift; // max_bits_fixpt = max_bits * 1024; /* max_bits_fixpt is in 22Q10 fixed-point representation */ max_bits_fixpt = L_shl( max_bits, 10 ); /* max_bits_fixpt is in 22Q10 fixed-point representation */ @@ -775,6 +792,7 @@ Word32 ECSQ_encode_target_SNR_fx( { /* a target SNR of 0.0 dB is already achieved by quantizing all values in the vector to zero */ *global_gain_index_output = ECSQ_GLOBAL_GAIN_INDEX_ALL_ZERO; + move16(); IF( output != NULL ) { set32_fx( output, 0, N ); @@ -787,10 +805,24 @@ Word32 ECSQ_encode_target_SNR_fx( move32(); sum_squared_e = 0; move16(); + FOR( i = 0; i < N; ++i ) { // sum_squared += input[i] * input[i]; - sum_squared = BASOP_Util_Add_Mant32Exp( sum_squared, sum_squared_e, Mpy_32_32( input[i], input[i] ), shl( input_e, 1 ), &sum_squared_e ); + W_tmp1 = W_mult0_32_32( input[i], input[i] ); // 2(31-input_e) + IF( W_tmp1 == 0 ) + { + shift = 32; + move16(); + } + ELSE + { + shift = W_norm( W_tmp1 ); + } + shift = sub( 32, shift ); + L_tmp1 = W_extract_l( W_shr( W_tmp1, shift ) ); // 2(31-input_e) - shift = 62 - 2input_e - shift + L_tmp1_e = sub( add( shl( input_e, 1 ), shift ), 31 ); // 31 - (62 - 2input_e - shift) = 2input_e + shift - 31 + sum_squared = BASOP_Util_Add_Mant32Exp( sum_squared, sum_squared_e, L_tmp1, L_tmp1_e, &sum_squared_e ); } // if ( sum_squared < 0.25f ) /* all the values in the input vector will always be quantized to zero */ @@ -830,6 +862,7 @@ Word32 ECSQ_encode_target_SNR_fx( // global_gain = sqrtf( target_sum_squared_error / ( 0.0833f * (float) N ) ); global_gain = BASOP_Util_Divide3232_Scale_cadence( target_sum_squared_error, L_mult0( 5459 /*0.0833f in Q16*/, N ), &global_gain_e ); global_gain_e = add( global_gain_e, sub( target_sum_squared_error_e, 15 ) ); + global_gain = Sqrt32( global_gain, &global_gain_e ); global_gain = L_shr( global_gain, sub( 16, global_gain_e ) ); // Q15 /* quantize the estimated global_gain */ global_gain_index = ECSQ_quantize_gain_fx( global_gain ); @@ -845,9 +878,9 @@ Word32 ECSQ_encode_target_SNR_fx( test_size = ECSQ_encode_raw_fx( ecsq_inst, quantized_input, N ); - ++iteration; - move16(); + iteration = add( iteration, 1 ); Word16 tmp_e; + test(); WHILE( GT_32( test_size, max_bits_fixpt ) && LT_16( iteration, ECSQ_MAX_BITS_ITERATIONS ) ) { test(); @@ -856,7 +889,13 @@ Word32 ECSQ_encode_target_SNR_fx( // adjust_global_gain_index = (int16_t) ceil( adjust_size / ( 1024.0f * N * log_base2( global_gain_step ) ) ); adjust_global_gain_index = BASOP_Util_Divide3232_Scale_cadence( adjust_size, N, &tmp_e ); adjust_global_gain_index = Mpy_32_32( adjust_global_gain_index, 17816838 /*/ ( 1024.0f * log_base2( global_gain_step ) )*/ ); - adjust_global_gain_index = extract_l( L_shr( L_add( adjust_global_gain_index, L_shl( 1, sub( 31, tmp_e ) ) ), sub( 31, tmp_e ) ) ); + IF( NE_32( adjust_global_gain_index, L_shl( L_shr( adjust_global_gain_index, sub( 31, tmp_e ) ), sub( 31, tmp_e ) ) ) ) + { + adjust_global_gain_index = BASOP_Util_Add_Mant32Exp( adjust_global_gain_index, tmp_e, ONE_IN_Q30, 1, &tmp_e ); + } + + adjust_global_gain_index = extract_l( L_shr( adjust_global_gain_index, sub( 31, tmp_e ) ) ); + global_gain_index = s_min( add( global_gain_index, (Word16) adjust_global_gain_index ), 126 ); global_gain = ECSQ_dequantize_gain_fx( global_gain_index ); // Q15 @@ -866,8 +905,7 @@ Word32 ECSQ_encode_target_SNR_fx( test_size = ECSQ_encode_raw_fx( ecsq_inst, quantized_input, N ); - ++iteration; - move16(); + iteration = add( iteration, 1 ); } IF( GT_32( test_size, max_bits_fixpt ) ) @@ -885,7 +923,7 @@ Word32 ECSQ_encode_target_SNR_fx( /* do the quantization with the dequantized final global_gain_index found */ global_gain = ECSQ_dequantize_gain_fx( global_gain_index ); // Q15 - IF( global_gain_index != global_gain_index_last ) + IF( NE_16( global_gain_index, global_gain_index_last ) ) { ECSQ_quantize_vector_fx( input, input_e, global_gain, N, quantized_input ); } diff --git a/lib_enc/ivas_stereo_ica_enc.c b/lib_enc/ivas_stereo_ica_enc.c index f7cf971efb50e946c9f84a0ad41a0993b4f184f9..9d06a5523c8ce03a109f8aa85c19c67008243b3d 100644 --- a/lib_enc/ivas_stereo_ica_enc.c +++ b/lib_enc/ivas_stereo_ica_enc.c @@ -935,6 +935,8 @@ static void corrStatsEst_fx( alpha_reg_fx = BASOP_Util_Add_Mant32Exp( Y_hat_fx, Y_hat_exp, L_negate( Mpy_32_32( X_hat_fx, beta_reg_fx ) ), add( X_hat_exp, beta_reg_exp ), &alpha_reg_exp ); /* Q31-alpha_reg_exp */ reg_prv_corr_fx = BASOP_Util_Add_Mant32Exp( alpha_reg_fx, alpha_reg_exp, Mpy_32_32( beta_reg_fx, L_shl( MAX_DELAYREGLEN, 27 ) ), add( 4, beta_reg_exp ), ®_prv_corr_exp ); /* Q31-reg_prv_corr_exp */ + reg_prv_corr_fx = L_shr( reg_prv_corr_fx, 1 ); + reg_prv_corr_exp = add( reg_prv_corr_exp, 1 ); IF( LE_16( TRUNC_FX( reg_prv_corr_fx, reg_prv_corr_exp ), -L_NCSHIFT_DS ) ) { reg_prv_corr_fx = -L_NCSHIFT_DS + 1; @@ -1127,7 +1129,9 @@ static void corrStatsEst_fx( test(); IF( vad_flag1 == 0 || vad_flag2 == 0 ) { - corrLagStats[0] = TRUNC_FX( hStereoTCA->delay_0_mem_fx[MAX_DELAYREGLEN - 1], hStereoTCA->delay_0_mem_exp ); /* Q0 */ + Word32 tmp_delay = L_shr( hStereoTCA->delay_0_mem_fx[MAX_DELAYREGLEN - 1], 1 ); + Word16 tmp_delay_e = add( hStereoTCA->delay_0_mem_exp, 1 ); + corrLagStats[0] = TRUNC_FX( tmp_delay, tmp_delay_e ); /* Q0 */ move32(); } @@ -1333,17 +1337,10 @@ static void estDownmixGain_fx( } ELSE IF( GT_16( hStereoTCA->LRTD_G_ATT_cnt, 1 ) ) /* lrtd_mode == 1 but tdm_LRTD_flag still 0 */ { - currentGain = BASOP_Util_Divide1616_Scale( currentGain, hStereoTCA->LRTD_G_ATT_cnt, ¤tGain_e ); // Q = 15 + 0 - (15 - exp) - /* Division result Q has to be got back to the Q of initial currentGain hence the shift operation below */ - IF( currentGain_e != 0 ) - { - currentGain = shr( currentGain, sub( Q15, currentGain_e ) ); /* Q15 */ - currentGain_e = 0; - move16(); - } + currentGain = BASOP_Util_Divide1616_Scale( currentGain, hStereoTCA->LRTD_G_ATT_cnt, &exp ); + currentGain_e = add( exp, sub( currentGain_e, 15 ) ); } - IF( GE_16( norm_s( currentGain ), sub( currentGain_e, 1 ) ) ) { /* convert currentGain into Q14 */ @@ -1888,7 +1885,7 @@ void stereo_tca_enc_fx( ELSE { v_multc_fixed( bufChanL_fx, ONE_IN_Q29, bufChanL_fx, L_MEM_RECALC_48K + L_MEM_RECALC_48k_SCH + L_FRAME48k + L_NCSHIFTMAX ); /* TO make in common Q bufChan_q -2*/ - Copy32( ptrChanL_fx + add( prevNCShift, sub( lMemRecalc, lMemRecalc_SCh ) ), input_mem_loc_fx[0], add( lMemRecalc, lMemRecalc_SCh ) ); // bufChan_q -2 + Copy32( ptrChanL_fx + sub( prevNCShift, add( lMemRecalc, lMemRecalc_SCh ) ), input_mem_loc_fx[0], add( lMemRecalc, lMemRecalc_SCh ) ); // bufChan_q -2 v_multc_fixed( ptrChanR_fx - add( lMemRecalc, lMemRecalc_SCh ), hStereoTCA->prevTargetGain_fx, input_mem_loc_fx[1], add( lMemRecalc, lMemRecalc_SCh ) ); // bufChan_q -2 v_multc_fixed( bufChanR_fx, ONE_IN_Q29, bufChanR_fx, L_MEM_RECALC_48K + L_MEM_RECALC_48k_SCH + L_FRAME48k + L_NCSHIFTMAX ); /* TO make in common Q bufChan_q -2*/ } @@ -2254,9 +2251,22 @@ static void unclr_calc_corr_features_fx( corrR = BASOP_Util_Add_Mant32Exp( corrR, corrR_exp, Mpy_32_32( buf2[i], mono_i ), add( sub( 31, q_com ), exp ), &corrR_exp ); /* Q31-corrR_exp */ ener = BASOP_Util_Add_Mant32Exp( ener, ener_exp, Mpy_32_32( mono_i, mono_i ), shl( exp, 1 ), &ener_exp ); - 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 */ + 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] ); + n2 = norm_l( buf2[i] ); + x = L_shl( buf1[i], n1 ); // q: q_com + n1 + y = L_shl( buf2[i], n2 ); // q: q_com + n2 + 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 */ @@ -2355,7 +2365,7 @@ static void unclr_calc_corr_features_fx( m_corrL_corrR = L_sub( L_max( L_abs( L_shl( ic_Lm, sub( exp1, s_max( exp1, exp2 ) ) ) ), L_abs( L_shl( ic_Rm, sub( exp2, s_max( exp1, exp2 ) ) ) ) ), L_min( L_abs( L_shl( ic_Lm, sub( exp1, s_max( exp1, exp2 ) ) ) ), L_abs( L_shl( ic_Rm, sub( exp2, s_max( exp1, exp2 ) ) ) ) ) ); // s_max(exp1, exp2) - inp1 = BASOP_Util_Add_Mant32Exp( corrL, corrL_exp, corrR, corrR_exp, &exp ); /* Q31-exp */ + inp1 = BASOP_Util_Add_Mant32Exp( corrL, corrL_exp, L_negate( corrR ), corrR_exp, &exp ); /* Q31-exp */ IF( inp1 ) { d_corrL_corrR = BASOP_Util_Log10( L_abs( inp1 ), exp ); // Q25 diff --git a/lib_enc/ivas_stereo_icbwe_enc.c b/lib_enc/ivas_stereo_icbwe_enc.c index f21cf35313ab055afb5b42b41286e8d1aeab7c74..9cf899bcbe9adf56c579a6cbc76a1111c84e1f26 100644 --- a/lib_enc/ivas_stereo_icbwe_enc.c +++ b/lib_enc/ivas_stereo_icbwe_enc.c @@ -219,8 +219,11 @@ static Word16 ic_bwe_enc_specMapping_ivas_fx( u_fx = extract_l( *specMapping_fx ); - tmp = mult( b_fx, b_fx ); // b_e + b_e; - tmp1 = mult( a_fx, c_fx ); // a_e + c_e + 2 + + /* while performing (-32768)*(-32768), overflow occurs because the result comes out as 32768 after mult. This is the only case for mult where overflow happens. In order to avoid this scenario mult_sat is used */ + + tmp = mult_sat( b_fx, b_fx ); // b_e + b_e; + tmp1 = mult_sat( a_fx, c_fx ); // a_e + c_e + 2 exp = BASOP_Util_Add_MantExp( tmp, add( b_e, b_e ), tmp1, add( a_e, add( c_e, 2 ) ), &temp_fx ); /* Q15-exp */ test(); @@ -286,7 +289,7 @@ static Word16 ic_bwe_enc_specMapping_ivas_fx( /* Quantize spec. mapping **/ Word16 specMapping16; - idx = usquant_fx( shr( u_fx, sub( 0, u_e ) ), &specMapping16, -19660, 6553, ( 1 << STEREO_ICBWE_SPBITS ) ); // -0.6 in in Q15 -> -19660, 0.2 in Q15 -> 6553 + idx = usquant_fx( shr( u_fx, sub( 0, u_e ) ), &specMapping16, -19660, 6553 >> 1, ( 1 << STEREO_ICBWE_SPBITS ) ); // -0.6 in in Q15 -> -19660, 0.2 in Q15 -> 6553 *specMapping_fx = L_deposit_h( specMapping16 ); move32(); @@ -347,15 +350,13 @@ static Word16 ic_bwe_enc_gsMapping_ivas_fx( temp2_fx32 = BASOP_Util_Add_Mant32Exp( temp2_fx32, temp2_exp, L_abs( synthSHB_nonref_fx[i] ), exp2, &temp2_exp ); /* Q31-temp2_exp */ } - - memEner_fx[0] = temp1_fx32; /* Q31-temp1_exp */ - memEner_fx[1] = L_shr( temp2_fx32, abs_s( sub( temp1_exp, temp2_exp ) ) ); /* Q31-temp1_exp */ + memEner_fx[0] = L_shr( temp1_fx32, sub( s_max( temp1_exp, temp2_exp ), temp1_exp ) ); + memEner_fx[1] = L_shr( temp2_fx32, sub( s_max( temp1_exp, temp2_exp ), temp2_exp ) ); move32(); move32(); *memEner_e = s_max( temp1_exp, temp2_exp ); move16(); - IF( temp2_fx32 == 0 ) { *gsMapping_fx = *gsMapping_fx; @@ -364,7 +365,7 @@ static Word16 ic_bwe_enc_gsMapping_ivas_fx( ELSE { L_mult = Mpy_32_32( relG_targ_fx, temp1_fx32 ); // relG_targ_e + temp1_e - temp1 = BASOP_Util_Divide3232_Scale( L_mult, temp1_fx32, &exp ); // exp = exp - ( relG_targ_e + temp1_e + temp2_e ) + temp1 = BASOP_Util_Divide3232_Scale( L_mult, temp2_fx32, &exp ); // exp = exp - ( relG_targ_e + temp1_e - temp2_e ) exp = add( exp, sub( add( relG_targ_e, temp1_exp ), temp2_exp ) ); *gsMapping_fx = L_deposit_h( temp1 ); // exp move32(); @@ -374,23 +375,44 @@ static Word16 ic_bwe_enc_gsMapping_ivas_fx( /* quantize the IC-BWE GS mapping*/ IF( EQ_16( element_mode, IVAS_CPE_TD ) ) { - temp2_fx = extract_l( L_shr( temp2_fx32, Q10 ) ); // Q15 + IF( LT_32( temp2_fx32, -( 2 << 25 ) ) ) + { + temp2_fx = -( 2 << 12 ); // Q12 + move16(); + } + ELSE IF( GT_32( temp2_fx32, 1 << 25 ) ) + { + temp2_fx = 1 << 12; // Q12 + move16(); + } + + temp2_fx = extract_h( L_shl_sat( temp2_fx32, Q3 ) ); // Q12 gsMapping_fx16 = 0; move16(); idx = squant_fx( temp2_fx, &gsMapping_fx16, icbwe_gsMapping_tbl_fx, ( 1 << STEREO_ICBWE_GSBITS ) ); // Q12 - // idx = squant_fx( temp2, gsMapping, icbwe_gsMapping_tbl_fx, 1 << STEREO_ICBWE_GSBITS ); } ELSE { - temp2_fx = extract_l( L_shr( temp2_fx32, Q10 ) ); // Q15 + IF( LT_32( temp2_fx32, -( 5 << 25 ) ) ) + { + temp2_fx = -( 5 << 12 ); // Q12 + move16(); + } + ELSE IF( GT_32( temp2_fx32, 1 << 25 ) ) + { + temp2_fx = 1 << 12; // Q12 + move16(); + } + + temp2_fx = extract_h( L_shl_sat( temp2_fx32, Q3 ) ); // Q12 gsMapping_fx16 = 0; move16(); - idx = squant_fx( temp2_fx, &gsMapping_fx16, icbwe_gsMappingDFT_tbl_fx, ( 1 << STEREO_ICBWE_GSBITS ) ); // Q12 + idx = squant_fx( temp2_fx, &gsMapping_fx16, icbwe_gsMappingDFT_tbl_fx, ( 1 << STEREO_ICBWE_GSBITS_DFT ) ); // Q12 } *gsMapping_fx = L_deposit_h( gsMapping_fx16 ); // Q28 move32(); Word16 e; - L_mult = Mult_32_16( *gsMapping_fx, 27213 /*=log2(10)*2^13*/ ); // Q27 + Q13 - Q15 -> Q26 + L_mult = Mult_32_16( *gsMapping_fx, 27213 /*=log2(10)*2^13*/ ); // Q28 + Q13 - Q15 -> Q26 *gsMapping_fx = BASOP_util_Pow2( L_mult, 5, &e ); /* Q31-e */ move32(); @@ -429,25 +451,24 @@ static void icbwe_dft_stereo_param_ivas_fx( nrg_R_fx = hStereoDft->nrg_R_fx; nrg_DMX_fx = hStereoDft->nrg_DMX_fx; - - hStereoICBWE->mem_nrg_L_fx[0] = nrg_L_fx[0]; // hStereoICBWE->nrg_L_fx_e[0] - hStereoICBWE->mem_nrg_R_fx[0] = nrg_R_fx[0]; // hStereoICBWE->nrg_R_fx_e[0] - hStereoICBWE->mem_nrg_DMX_fx[0] = nrg_DMX_fx[0]; // hStereoICBWE->nrg_DMX_fx_e[0] - hStereoICBWE->mem_nrg_L_fx[1] = L_shr( nrg_L_fx[1], abs_s( sub( hStereoDft->nrg_L_fx_e[0], hStereoDft->nrg_L_fx_e[1] ) ) ); // hStereoICBWE->nrg_L_fx_e[1] - hStereoICBWE->mem_nrg_R_fx[1] = L_shr( nrg_R_fx[1], abs_s( sub( hStereoDft->nrg_R_fx_e[0], hStereoDft->nrg_R_fx_e[1] ) ) ); // hStereoICBWE-> nrg_R_fx_e[1] - hStereoICBWE->mem_nrg_DMX_fx[1] = L_shr( nrg_DMX_fx[1], abs_s( sub( hStereoDft->nrg_DMX_fx_e[0], hStereoDft->nrg_DMX_fx_e[1] ) ) ); // hStereoICBWE->nrg_DMX_fx_e[1] - move32(); - move32(); - move32(); - move32(); - move32(); - move32(); hStereoICBWE->mem_nrg_L_fx_e = s_max( hStereoDft->nrg_L_fx_e[0], hStereoDft->nrg_L_fx_e[1] ); hStereoICBWE->mem_nrg_R_fx_e = s_max( hStereoDft->nrg_R_fx_e[0], hStereoDft->nrg_R_fx_e[1] ); hStereoICBWE->mem_nrg_DMX_fx_e = s_max( hStereoDft->nrg_DMX_fx_e[0], hStereoDft->nrg_DMX_fx_e[1] ); move16(); move16(); move16(); + hStereoICBWE->mem_nrg_L_fx[0] = L_shr( nrg_L_fx[0], sub( hStereoICBWE->mem_nrg_L_fx_e, hStereoDft->nrg_L_fx_e[0] ) ); + hStereoICBWE->mem_nrg_R_fx[0] = L_shr( nrg_R_fx[0], sub( hStereoICBWE->mem_nrg_R_fx_e, hStereoDft->nrg_R_fx_e[0] ) ); + hStereoICBWE->mem_nrg_DMX_fx[0] = L_shr( nrg_DMX_fx[0], sub( hStereoICBWE->mem_nrg_DMX_fx_e, hStereoDft->nrg_DMX_fx_e[0] ) ); + hStereoICBWE->mem_nrg_L_fx[1] = L_shr( nrg_L_fx[1], sub( hStereoICBWE->mem_nrg_L_fx_e, hStereoDft->nrg_L_fx_e[1] ) ); + hStereoICBWE->mem_nrg_R_fx[1] = L_shr( nrg_R_fx[1], sub( hStereoICBWE->mem_nrg_R_fx_e, hStereoDft->nrg_R_fx_e[1] ) ); + hStereoICBWE->mem_nrg_DMX_fx[1] = L_shr( nrg_DMX_fx[1], sub( hStereoICBWE->mem_nrg_DMX_fx_e, hStereoDft->nrg_DMX_fx_e[1] ) ); + move32(); + move32(); + move32(); + move32(); + move32(); + move32(); Word16 sum_nrg_L_e = hStereoICBWE->mem_nrg_L_fx_e, sum_nrg_R_e = hStereoICBWE->mem_nrg_R_fx_e, sum_nrg_DMX_e = hStereoICBWE->mem_nrg_DMX_fx_e; sum_nrg_L_fx = sum_32_fx( hStereoICBWE->mem_nrg_L_fx, 2, &sum_nrg_L_e ); // hStereoICBWE->mem_nrg_L_fx_e @@ -510,9 +531,13 @@ 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; + move16(); } ELSE { + hStereoICBWE->memShbSpecMapping_e = 0; + move16(); hStereoICBWE->memShbSpecMapping_fx = 0; hStereoICBWE->prevSpecMapping_fx = 0; move32(); @@ -664,7 +689,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 ); - Copy_Scale_sig_16_32( hStereoICBWE->mem_shb_speech_ref_fx, shb_frame_ref_fx, L_LOOK_16k, 0 ); // Q = 15 - mem_shb_speech_ref_e + Copy_Scale_sig_16_32_DEPREC( hStereoICBWE->mem_shb_speech_ref_fx, shb_frame_ref_fx, L_LOOK_16k, 0 ); // Q = 15 - mem_shb_speech_ref_e scale_sig32( shb_frame_ref_fx, L_LOOK_16k, add( negate( sub( max_e, hStereoICBWE->mem_shb_speech_ref_e ) ), Q16 ) ); // Q = 31 - mem_shb_speech_ref_e hStereoICBWE->mem_shb_speech_ref_e = max_e; @@ -692,6 +717,8 @@ void stereo_icBWE_enc_ivas_fx( v_multc_fixed( voice_factors_fx, 1073741824, nlMixFac_fx, NB_SUBFR16k ); // Q31, 0.5 in Q31 -> 1073741824 } + Word16 L_FRAME16k_by_nbSubFr = L_FRAME16k / NB_SUBFR; + move16(); IF( st->flag_ACELP16k == 0 ) { nbSubFr = NB_SUBFR; @@ -701,6 +728,8 @@ void stereo_icBWE_enc_ivas_fx( { nbSubFr = NB_SUBFR16k; move16(); + L_FRAME16k_by_nbSubFr = L_FRAME16k / NB_SUBFR16k; + move16(); } Word16 exp_buf[L_FRAME16k]; @@ -728,11 +757,9 @@ void stereo_icBWE_enc_ivas_fx( temp2_fx = Sqrt32( L_sub( ONE_IN_Q31, nlMixFac_fx[i] ), &temp2_e ); /* Q31-temp2_e */ } - tmp = BASOP_Util_Divide1616_Scale( L_FRAME16k, nbSubFr, &exp ); /* Q15-exp */ - tmp = shr( tmp, sub( Q15, exp ) ); /* Q0 */ - FOR( j = 0; j < tmp; ( j++, k++ ) ) + FOR( j = 0; j < L_FRAME16k_by_nbSubFr; ( j++, k++ ) ) { - excSHB_nonref_fx[k] = extract_l( BASOP_Util_Add_Mant32Exp( Mpy_32_32( temp1_fx, hStereoICBWE->nlExc16k_fx[k] ), add( temp1_e, hStereoICBWE->nlExc16k_e ), Mpy_32_32( temp2_fx, hStereoICBWE->mixExc16k_fx[k] ), add( temp2_e, hStereoICBWE->mixExc16k_e ), &exp_buf[k] ) ); /* Q31-exp_buf */ + excSHB_nonref_fx[k] = BASOP_Util_Add_Mant32Exp( Mpy_32_32( temp1_fx, L_deposit_h( hStereoICBWE->nlExc16k_fx[k] ) ), add( temp1_e, hStereoICBWE->nlExc16k_e ), Mpy_32_32( temp2_fx, L_deposit_h( hStereoICBWE->mixExc16k_fx[k] ) ), add( temp2_e, hStereoICBWE->mixExc16k_e ), &exp_buf[k] ); /* Q31-exp_buf */ move32(); } } @@ -754,19 +781,13 @@ void stereo_icBWE_enc_ivas_fx( move32(); } /* LP synthesis */ - Word16 tmp_e = s_max( hCPE->hStereoICBWE->lpSHBRef_e, max_e ); - Word32 lpSHBRef_fx32[LPC_SHB_ORDER + 1]; + Copy_Scale_sig32( hStereoICBWE->mem_lpc_shbsynth_nonref_fx, hStereoICBWE->mem_lpc_shbsynth_nonref_fx, LPC_SHB_ORDER, sub( hStereoICBWE->mem_lpc_shbsynth_nonref_e, s_max( hStereoICBWE->mem_lpc_shbsynth_nonref_e, max_e ) ) ); /* Q31-tmp_e */ + Copy_Scale_sig32( excSHB_nonref_fx, excSHB_nonref_fx, L_FRAME16k, sub( max_e, s_max( hStereoICBWE->mem_lpc_shbsynth_nonref_e, max_e ) ) ); /* Q31-tmp_e */ + max_e = s_max( hStereoICBWE->mem_lpc_shbsynth_nonref_e, max_e ); + hStereoICBWE->mem_lpc_shbsynth_nonref_e = s_max( hStereoICBWE->mem_lpc_shbsynth_nonref_e, max_e ); - Copy_Scale_sig32( hCPE->hStereoICBWE->lpSHBRef_fx, lpSHBRef_fx32, LPC_SHB_ORDER + 1, negate( sub( tmp_e, hCPE->hStereoICBWE->lpSHBRef_e ) ) ); /* Q31-tmp_e */ - Copy_Scale_sig32( excSHB_nonref_fx, excSHB_nonref_fx, L_FRAME16k, negate( sub( tmp_e, max_e ) ) ); /* Q31-tmp_e */ - // set32_fx( hStereoICBWE->mem_lpc_shbsynth_nonref_fx, 0, LPC_SHB_ORDER ); - E_UTIL_synthesis_fx( 0, lpSHBRef_fx32, excSHB_nonref_fx, shb_synth_nonref_fx, L_FRAME16k, hStereoICBWE->mem_lpc_shbsynth_nonref_fx, 1, LPC_SHB_ORDER ); - - shb_synth_nonref_e = tmp_e; - hStereoICBWE->mem_lpc_shbsynth_nonref_e = tmp_e; - move16(); - move16(); + syn_filt_fx32( hStereoICBWE->lpSHBRef_e, hStereoICBWE->lpSHBRef_fx, LPC_SHB_ORDER, excSHB_nonref_fx, max_e, shb_synth_nonref_fx, &shb_synth_nonref_e, L_FRAME16k, hStereoICBWE->mem_lpc_shbsynth_nonref_fx, &hStereoICBWE->mem_lpc_shbsynth_nonref_e, 1 ); } ELSE { @@ -777,11 +798,11 @@ void stereo_icBWE_enc_ivas_fx( shb_synth_nonref_e = shb_frame_ref_e; move16(); set32_fx( hStereoICBWE->mem_lpc_shbsynth_nonref_fx, 0, 10 ); + hStereoICBWE->mem_lpc_shbsynth_nonref_e = 0; + move16(); } icbwe_dft_stereo_param_ivas_fx( hStereoICBWE, hStereoDft, st, shb_synth_nonref_fx, shb_synth_nonref_e ); - hStereoICBWE->memShbSpecMapping_e = shb_synth_nonref_e; - move16(); } ELSE { @@ -790,8 +811,11 @@ 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 ); - Copy_Scale_sig_16_32( 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 - +#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(); @@ -805,9 +829,11 @@ void stereo_icBWE_enc_ivas_fx( 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 - - Copy_Scale_sig_16_32( 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 - +#ifdef FIX_ISSUE_1237 + 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(); @@ -842,6 +868,8 @@ void stereo_icBWE_enc_ivas_fx( IF( ( NE_16( hStereoICBWE->prev_refChanIndx_bwe, hStereoICBWE->refChanIndx_bwe ) ) || NE_16( st->last_extl, st->extl ) || NE_16( st->flag_ACELP16k, 1 ) ) { hStereoICBWE->prevSpecMapping_fx = 0; + hStereoICBWE->memShbSpecMapping_e = 0; + move16(); hStereoICBWE->memShbSpecMapping_fx = 0; move32(); move32(); @@ -911,6 +939,8 @@ void stereo_icBWE_enc_ivas_fx( v_multc_fixed( voice_factors_fx, 1073741824 /*0.5 in Q31*/, nlMixFac_fx, NB_SUBFR16k ); /* Q31 */ } + Word16 L_FRAME16k_by_nbSubFr = L_FRAME16k / NB_SUBFR; + move16(); IF( st->flag_ACELP16k == 0 ) { nbSubFr = NB_SUBFR; @@ -920,6 +950,8 @@ void stereo_icBWE_enc_ivas_fx( { nbSubFr = NB_SUBFR16k; move16(); + L_FRAME16k_by_nbSubFr = L_FRAME16k / NB_SUBFR16k; + move16(); } Word16 exp_buf[L_FRAME16k]; @@ -944,13 +976,13 @@ void stereo_icBWE_enc_ivas_fx( temp1_e = 0, temp2_e = 0; temp1_fx = Sqrt32( nlMixFac_fx[i], &temp1_e ); /* Q31-temp1_e */ temp2_fx = Sqrt32( L_sub( ONE_IN_Q31, nlMixFac_fx[i] ), &temp2_e ); /* Q31 */ - move32(); + move16(); move16(); } - FOR( j = 0; j < ( L_FRAME16k / nbSubFr ); ( j++, k++ ) ) + FOR( j = 0; j < L_FRAME16k_by_nbSubFr; ( j++, k++ ) ) { - excSHB_nonref_fx[k] = extract_l( BASOP_Util_Add_Mant32Exp( Mpy_32_32( temp1_fx, hStereoICBWE->nlExc16k_fx[k] ), temp1_e + hStereoICBWE->nlExc16k_e, Mpy_32_32( temp2_fx, hStereoICBWE->mixExc16k_fx[k] ), temp2_e + hStereoICBWE->mixExc16k_e, &exp_buf[k] ) ); /* Q31-exp_buf */ + excSHB_nonref_fx[k] = BASOP_Util_Add_Mant32Exp( Mpy_32_32( temp1_fx, L_deposit_h( hStereoICBWE->nlExc16k_fx[k] ) ), add( temp1_e, hStereoICBWE->nlExc16k_e ), Mpy_32_32( temp2_fx, L_deposit_h( hStereoICBWE->mixExc16k_fx[k] ) ), add( temp2_e, hStereoICBWE->mixExc16k_e ), &exp_buf[k] ); /* Q31-exp_buf */ move32(); } } @@ -972,18 +1004,12 @@ void stereo_icBWE_enc_ivas_fx( move32(); } /* LP synthesis */ + Copy_Scale_sig32( hStereoICBWE->mem_lpc_shbsynth_nonref_fx, hStereoICBWE->mem_lpc_shbsynth_nonref_fx, LPC_SHB_ORDER, sub( hStereoICBWE->mem_lpc_shbsynth_nonref_e, s_max( hStereoICBWE->mem_lpc_shbsynth_nonref_e, max_e ) ) ); /* Q31-tmp_e */ + Copy_Scale_sig32( excSHB_nonref_fx, excSHB_nonref_fx, L_FRAME16k, sub( max_e, s_max( hStereoICBWE->mem_lpc_shbsynth_nonref_e, max_e ) ) ); /* Q31-tmp_e */ + max_e = s_max( hStereoICBWE->mem_lpc_shbsynth_nonref_e, max_e ); + hStereoICBWE->mem_lpc_shbsynth_nonref_e = s_max( hStereoICBWE->mem_lpc_shbsynth_nonref_e, max_e ); - Word16 tmp_e = s_max( hCPE->hStereoICBWE->lpSHBRef_e, max_e ); - - Word32 lpSHBRef_fx32[LPC_SHB_ORDER + 1]; - - Copy_Scale_sig32( hCPE->hStereoICBWE->lpSHBRef_fx, lpSHBRef_fx32, LPC_SHB_ORDER + 1, negate( sub( tmp_e, hCPE->hStereoICBWE->lpSHBRef_e ) ) ); /* Q31-tmp_e */ - Copy_Scale_sig32( excSHB_nonref_fx, excSHB_nonref_fx, L_FRAME16k, negate( sub( tmp_e, max_e ) ) ); /* Q31-tmp_e */ - - E_UTIL_synthesis_fx( 0, hStereoICBWE->lpSHBRef_fx, excSHB_nonref_fx, shb_synth_nonref_fx, L_FRAME16k, hStereoICBWE->mem_lpc_shbsynth_nonref_fx, 1, LPC_SHB_ORDER ); - shb_synth_nonref_e = sub( 31, tmp_e ); - hStereoICBWE->mem_lpc_shbsynth_nonref_e = shb_synth_nonref_e; - move16(); + syn_filt_fx32( hStereoICBWE->lpSHBRef_e, hStereoICBWE->lpSHBRef_fx, LPC_SHB_ORDER, excSHB_nonref_fx, max_e, shb_synth_nonref_fx, &shb_synth_nonref_e, L_FRAME16k, hStereoICBWE->mem_lpc_shbsynth_nonref_fx, &hStereoICBWE->mem_lpc_shbsynth_nonref_e, 1 ); } ELSE { @@ -994,6 +1020,8 @@ void stereo_icBWE_enc_ivas_fx( shb_synth_nonref_e = shb_frame_ref_e; move16(); set32_fx( hStereoICBWE->mem_lpc_shbsynth_nonref_fx, 0, 10 ); + hStereoICBWE->mem_lpc_shbsynth_nonref_e = 0; + move16(); } test(); @@ -1002,6 +1030,13 @@ 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 */ } ELSE @@ -1067,6 +1102,8 @@ void stereo_icBWE_init_enc_fx( /* unscaled & scaled SHB synthesis memory */ set32_fx( hStereoICBWE->mem_lpc_shbsynth_nonref_fx, 0, LPC_SHB_ORDER ); + hStereoICBWE->mem_lpc_shbsynth_nonref_e = 0; + move16(); /* inter-channel BWE spectral shape adj. */ hStereoICBWE->prevSpecMapping_fx = 0; @@ -1198,6 +1235,10 @@ 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 */ hStereoICBWE = hCPE->hStereoICBWE; /* Stereo IC BWE encoder handle */ diff --git a/lib_enc/ivas_stereo_mdct_core_enc.c b/lib_enc/ivas_stereo_mdct_core_enc.c index d8dcf5653430c771654e855065d55cd9dc0c799e..ffc671d4126704f6d9128b99a18e21b723b79856 100644 --- a/lib_enc/ivas_stereo_mdct_core_enc.c +++ b/lib_enc/ivas_stereo_mdct_core_enc.c @@ -138,6 +138,7 @@ 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]; Word32 powerSpecMsInv_long_fx[CPE_CHANNELS][N_MAX]; /* MS inv power spectrum, also inverse MDST spectrum */ @@ -154,7 +155,7 @@ 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_spec, tmp_s; + 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]; Word64 W_tmp; Encoder_State *st, **sts; @@ -187,10 +188,13 @@ void stereo_mdct_core_enc_fx( 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( tmp_q_powSpecInv, 63, L_FRAME48k ); - set16_fx( tmp_q_powSpec, 63, L_FRAME48k ); + 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]; @@ -265,6 +269,7 @@ void stereo_mdct_core_enc_fx( 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(); @@ -416,7 +421,7 @@ void stereo_mdct_core_enc_fx( 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 = sub( W_norm( W_tmp ), 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 @@ -424,7 +429,7 @@ void stereo_mdct_core_enc_fx( 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 = sub( W_norm( W_tmp ), 1 ); + tmp_s = W_norm( W_tmp ); W_tmp = W_shl( W_tmp, tmp_s ); /* 2*q_spec+1+tmp_s */ powerSpecMsInv_fx[ch][n][i] = W_extract_h( W_tmp ); /* 2*q_spec+1+tmp_s-32 */ tmp_q_psi[n][i] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32 @@ -438,7 +443,7 @@ void stereo_mdct_core_enc_fx( { /* power spectrum: MDCT^2 + MDST^2 */ W_tmp = W_mult_32_32( inv_spectrum_fx[ch][n][0], inv_spectrum_fx[ch][n][0] ); /* 2*q_spec+1 */ - tmp_s = sub( W_norm( W_tmp ), 1 ); + tmp_s = W_norm( W_tmp ); W_tmp = W_shl( W_tmp, tmp_s ); /* 2*q_spec+1+tmp_s */ powerSpecMsInv_fx[ch][n][0] = W_extract_h( W_tmp ); /* 2*q_spec+1+tmp_s-32 */ tmp_q_psi[n][0] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32 @@ -450,7 +455,7 @@ void stereo_mdct_core_enc_fx( Word32 mdst_fx = L_sub( inv_spectrum_fx[ch][n][i + 1], inv_spectrum_fx[ch][n][i - 1] ); /* An MDST estimate q_spec*/ W_tmp = W_mac_32_32( W_mult_32_32( mdst_fx, mdst_fx ), inv_spectrum_fx[ch][n][i], inv_spectrum_fx[ch][n][i] ); /* 2*q_spec+1 */ - tmp_s = sub( W_norm( W_tmp ), 1 ); + tmp_s = W_norm( W_tmp ); W_tmp = W_shl( W_tmp, tmp_s ); /* 2*q_spec+1+tmp_s */ powerSpecMsInv_fx[ch][n][i] = W_extract_h( W_tmp ); /* 2*q_spec+1+tmp_s-32 */ tmp_q_psi[n][i] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32 @@ -459,7 +464,7 @@ void stereo_mdct_core_enc_fx( } W_tmp = W_mult_32_32( inv_spectrum_fx[ch][n][L_subframeTCX - 1], inv_spectrum_fx[ch][n][L_subframeTCX - 1] ); /* 2*q_spec+1 */ - tmp_s = sub( W_norm( W_tmp ), 1 ); + tmp_s = W_norm( W_tmp ); W_tmp = W_shl( W_tmp, tmp_s ); /* 2*q_spec+1+tmp_s */ powerSpecMsInv_fx[ch][n][L_subframeTCX - 1] = W_extract_h( W_tmp ); /* 2*q_spec+1+tmp_s-32 */ tmp_q_psi[n][L_subframeTCX - 1] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32 @@ -469,7 +474,7 @@ 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 = sub( W_norm( W_tmp ), 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 @@ -481,7 +486,7 @@ void stereo_mdct_core_enc_fx( 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 = sub( W_norm( W_tmp ), 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 @@ -490,7 +495,7 @@ void stereo_mdct_core_enc_fx( } 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 = sub( W_norm( W_tmp ), 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 @@ -501,30 +506,40 @@ void stereo_mdct_core_enc_fx( /* Aligning the Q-factors */ { + q_powSpec[ch] = Q31; + q_powSpecMsInv[ch] = Q31; + move16(); + move16(); FOR( i = 0; i < N_MAX; i++ ) { - if ( powerSpec_fx[ch][i] == 0 ) + IF( powerSpec_fx[ch][i] != 0 ) { - tmp_q_powSpec[i] = 63; + q_powSpec[ch] = s_min( q_powSpec[ch], tmp_q_powSpec[i] ); + move16(); + exp_powerSpec[ch][i] = sub( Q31, tmp_q_powSpec[i] ); move16(); } - if ( powerSpecMsInv_fx[ch][0][i] == 0 ) + } + FOR( n = 0; n < nSubframes; n++ ) + { + FOR( i = 0; i < L_subframeTCX; i++ ) { - tmp_q_powSpecInv[i] = 63; - move16(); + IF( powerSpecMsInv_fx[ch][n][i] != 0 ) + { + q_powSpecMsInv[ch] = s_min( q_powSpecMsInv[ch], tmp_q_psi[n][i] ); + move16(); + } } } - minimum_s( tmp_q_powSpec, N_MAX, &q_powSpec[ch] ); - minimum_s( tmp_q_powSpecInv, N_MAX, &tmp_s ); - q_powSpec[ch] = s_min( q_powSpec[ch], tmp_s ); - move16(); FOR( n = 0; n < nSubframes; n++ ) { FOR( i = 0; i < L_subframeTCX; i++ ) { - powerSpecMsInv_fx[ch][n][i] = L_shr( powerSpecMsInv_fx[ch][n][i], sub( tmp_q_psi[n][i], q_powSpec[ch] ) ); /* q_powSpec */ - powerSpec_fx[ch][( i + ( n * L_subframeTCX ) )] = L_shr( powerSpec_fx[ch][( i + ( n * L_subframeTCX ) )], sub( tmp_q_powSpec[i], q_powSpec[ch] ) ); /* q_powSpec */ + 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(); move32(); } @@ -561,7 +576,7 @@ void stereo_mdct_core_enc_fx( * and quantization (0: tonal, 1: noise-like). * * Detect low pass if present. * *-----------------------------------------------------------*/ - ComputeSpectrumNoiseMeasure_fx( powerSpec_fx[ch], L_subframeTCX, i_mult( st->hTcxEnc->nmStartLine, idiv1616( L_subframeTCX, st->hTcxEnc->L_frameTCX ) ), + 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 ); } @@ -595,14 +610,15 @@ 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[0]; - p_powerSpec_fx[1] = powerSpec_fx[1]; + 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++ ) { 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 ) ) @@ -611,17 +627,24 @@ void stereo_mdct_core_enc_fx( move16(); } length = idiv1616( sts[ch]->hTcxEnc->L_frameTCX, n_sb ); /* Q0 */ - IF( GT_16( q_spec, q_powSpec[ch] ) ) + IF( NE_16( q_spec, q_comm ) ) { - Scale_sig32( sts[ch]->hTcxEnc->spectrum_fx[n], length, sub( q_powSpec[ch], q_spec ) ); /* q_powSpec */ - Scale_sig32( inv_spectrum_fx[ch][n], length, sub( q_powSpec[ch], q_spec ) ); /* q_powSpec */ - sts[ch]->hTcxEnc->spectrum_e[n] = sub( Q31, q_powSpec[ch] ); + 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(); } - ELSE + IF( NE_16( q_powSpec[ch], q_comm ) ) { - Scale_sig32( &p_powerSpec_fx[ch][0], L_subframeTCX, sub( q_spec, q_powSpec[ch] ) ); /* q_spec */ - Scale_sig32( powerSpecMsInv_fx[ch][0], L_subframeTCX, sub( q_spec, q_powSpec[ch] ) ); /* q_spec */ + 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; + move16(); } } hIGFEnc[0]->spec_be_igf_e = p_orig_spectrum_e[0]; @@ -630,7 +653,7 @@ void stereo_mdct_core_enc_fx( 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 ); + p_powerSpec_fx, powerSpecMsInv_fx, inv_spectrum_fx, n, hCPE->hCoreCoder[0]->sp_aud_decision0, hCPE->hCoreCoder[0]->element_brate, 0 ); } ELSE { @@ -649,10 +672,10 @@ void stereo_mdct_core_enc_fx( { q_spectrum = s_min( q_spectrum, sub( Q31, st->hIGFEnc->spec_be_igf_e ) ); } - Scale_sig32( orig_spectrum_fx[ch][n], N_TCX10_MAX, sub( q_spectrum, sub( Q31, p_orig_spectrum_e[ch] ) ) ); /* q_spectrum */ q_spectrum = sub( Q31, st->hTcxEnc->spectrum_e[n] ); - set16_fx( exp_powerSpec[ch], sub( Q31, q_powSpec[ch] ), N_MAX + L_MDCT_OVLP_MAX ); + + Scale_sig32( orig_spectrum_fx[ch][n], st->hIGFEnc->infoStopLine, sub( q_spectrum, sub( Q31, p_orig_spectrum_e[ch] ) ) ); /* q_spectrum */ 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 ); } @@ -690,10 +713,10 @@ void stereo_mdct_core_enc_fx( { q_spectrum = s_min( q_spectrum, sub( Q31, st->hIGFEnc->spec_be_igf_e ) ); } - Scale_sig32( orig_spectrum_fx[ch][n], N_TCX10_MAX, sub( q_spectrum, sub( Q31, p_orig_spectrum_e[ch] ) ) ); /* q_spectrum */ q_spectrum = sub( Q31, st->hTcxEnc->spectrum_e[n] ); - set16_fx( exp_powerSpec[ch], sub( Q31, q_powSpec[ch] ), N_MAX + L_MDCT_OVLP_MAX ); + + Scale_sig32( orig_spectrum_fx[ch][n], st->hIGFEnc->infoStopLine, sub( q_spectrum, sub( Q31, p_orig_spectrum_e[ch] ) ) ); /* q_spectrum */ 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 ); } diff --git a/lib_enc/ivas_stereo_td_analysis.c b/lib_enc/ivas_stereo_td_analysis.c index 58e72c91e38992ca05fab77506bbfdfa492344d5..49ac895ef311482c64b080c6271dc01daa9abd8b 100644 --- a/lib_enc/ivas_stereo_td_analysis.c +++ b/lib_enc/ivas_stereo_td_analysis.c @@ -635,14 +635,23 @@ Word16 stereo_tdm_ener_analysis_fx( hStereoTD->tdm_last_LRTD_PriCh_cnt = add( hStereoTD->tdm_last_LRTD_PriCh_cnt, 1 ); move16(); } - ratio_L_fx = tdm_ratio_tabl_fx[idx]; // Q31 + +#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(); } @@ -731,8 +740,12 @@ Word16 stereo_tdm_ener_analysis_fx( move16(); } - hCPE->hStereoClassif->ratio_L_fx = ratio_L_fx; /* Q15 */ + 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; } @@ -1709,7 +1722,6 @@ Word16 tdm_lp_comparison_fx( Word32 dist_fx, ftmp_fx; Word16 i; Word32 res_fx[L_FRAME16k]; - Word16 gb1 = find_guarded_bits_fx( M ); Word16 Q_A_SCh; Word32 *speech_fx = &speech_buff[M]; @@ -1720,8 +1732,8 @@ Word16 tdm_lp_comparison_fx( // residu( A_SCh, m, speech, res, L_frame ); Word16 gb = find_guarded_bits_fx( L_frame ); - scale_sig32( speech_buff, L_FRAME + M, gb1 ); /* Q_speech + gb1 */ - Word16 exp = sub( 31, Q_speech ); + scale_sig32( speech_buff, L_FRAME + M, Q4 ); /* Q_speech + 4 */ + Word16 exp = sub( Q27, Q_speech ); Word32 sum2_value = sum2_32_exp_fx( speech_fx, L_frame, &exp, gb ); // 2*Q_speech -31-gb IF( LT_16( exp, -5 ) ) /*maximum q to prevent 0.01 from saturating is 37, since we are adding it headroom of 1 is required*/ { @@ -1733,7 +1745,7 @@ Word16 tdm_lp_comparison_fx( Word32 temp32_log = L_add( BASOP_Util_Log2( sum2_value ), L_shl( sub( Q31, sub( 31, exp ) ), Q25 ) ); /* Q25 */ ener_sig_fx = Mpy_32_32( temp32_log, 646456623 ); // Q25 // ener_sig = log10f( sum2_f( speech, L_frame ) + 0.01f ); - exp = sub( 31, sub( Q_speech, gb1 ) ); + exp = sub( Q31, Q_speech ); sum2_value = sum2_32_exp_fx( res_fx, L_frame, &exp, gb ); // 2*Q_speech -31-gb sum2_value = BASOP_Util_Add_Mant32Exp( sum2_value, exp, 328, Q16, &exp ); /* Q31-exp */ temp32_log = L_add( BASOP_Util_Log2( sum2_value ), L_shl( sub( Q31, sub( 31, exp ) ), Q25 ) ); /* Q25 */ @@ -1744,9 +1756,9 @@ Word16 tdm_lp_comparison_fx( /* Find prediction gain when resuing the Primary Channel LP filter */ // residu( A_PCh, m, speech, res, L_frame ); - scale_sig32( speech_buff, L_FRAME + M, negate( gb1 ) ); /* Q_speech */ + scale_sig32( speech_buff, L_FRAME + M, -4 ); /* Q_speech */ residu_ivas_fx( A_PCh_fx, sub( 14, norm_s( A_PCh_fx[0] ) ), m, speech_fx, res_fx, L_frame ); - exp = sub( 31, sub( Q_speech, gb1 ) ); + exp = sub( Q31, Q_speech ); sum2_value = sum2_32_exp_fx( res_fx, L_frame, &exp, gb ); // 2*Q_speech -31-gb sum2_value = BASOP_Util_Add_Mant32Exp( sum2_value, exp, 328, Q16, &exp ); temp32_log = L_add( BASOP_Util_Log2( sum2_value ), L_shl( sub( Q31, sub( 31, exp ) ), Q25 ) ); /* Q25 */ @@ -1758,7 +1770,8 @@ Word16 tdm_lp_comparison_fx( /* Find Euclidian distance between the 2 filters */ dist_fx = 0; move16(); - gb = find_guarded_bits_fx( M ); + gb = 4; + move16(); FOR( i = 0; i < m; i++ ) { // ftmp = isp_SCh[i] - isp_PCh[i]; diff --git a/lib_enc/ivas_stereo_td_enc.c b/lib_enc/ivas_stereo_td_enc.c index a06c30301f01b177e5479575a7f2a72e33203533..02bdd15613093d4aea1f1b8bb6e51fd00be4db50 100644 --- a/lib_enc/ivas_stereo_td_enc.c +++ b/lib_enc/ivas_stereo_td_enc.c @@ -473,7 +473,7 @@ void tdm_configure_enc_fx( } } ELSE IF( ( LT_16( sts[1]->coder_type, AUDIO ) && NE_16( sts[1]->coder_type, UNVOICED ) ) || /* TC and VC are not supported in secondary channel */ - ( ( EQ_16( sts[1]->coder_type, AUDIO ) && LE_32( hCPE->element_brate, IVAS_24k4 ) ) || ( EQ_16( sts[0]->sp_aud_decision1, 1 ) && GE_32( hCPE->element_brate, IVAS_16k4 ) ) || ( EQ_16( sts[1]->sp_aud_decision0, 1 ) && GE_32( hCPE->element_brate, IVAS_13k2 ) ) ) ) + ( ( EQ_16( sts[1]->coder_type, AUDIO ) && LE_32( hCPE->element_brate, IVAS_24k4 ) ) || ( EQ_16( sts[0]->sp_aud_decision1, 1 ) && GE_32( hCPE->element_brate, IVAS_16k4 ) ) || ( EQ_16( sts[1]->sp_aud_decision0, 1 ) && GT_32( hCPE->element_brate, IVAS_13k2 ) ) ) ) { sts[1]->coder_type = GENERIC; move16(); @@ -485,7 +485,7 @@ void tdm_configure_enc_fx( } test(); - IF( GE_32( hCPE->element_brate, IVAS_24k4 ) && EQ_16( hCPE->hStereoClassif->lrtd_mode, 1 ) ) + IF( GT_32( hCPE->element_brate, IVAS_24k4 ) && EQ_16( hCPE->hStereoClassif->lrtd_mode, 1 ) ) { if ( EQ_16( sts[1]->coder_type, UNVOICED ) ) { diff --git a/lib_enc/ivas_tcx_core_enc.c b/lib_enc/ivas_tcx_core_enc.c index e8a81147a844e71cf9b809d1772a2017861d388e..f072e54364465ce48d77825d301bc11afae1fa52 100644 --- a/lib_enc/ivas_tcx_core_enc.c +++ b/lib_enc/ivas_tcx_core_enc.c @@ -466,7 +466,7 @@ void stereo_tcx_core_enc( E_LPC_lsp_lsf_conversion( lsp_fx, lsf_fx, M ); /* Quantize */ - Q_lsf_tcxlpc_fx( lsf_fx, lsf_tcx_q_fx, lspq_ind, param_lpc, M, st->narrowBand, tcx_lpc_cdk, st->mem_MA_fx, st->hTcxCfg->coder_type, st->Bin_E_fx, Q_ener ); + Q_lsf_tcxlpc_ivas_fx( lsf_fx, lsf_tcx_q_fx, lspq_ind, param_lpc, M, st->narrowBand, tcx_lpc_cdk, st->mem_MA_fx, st->hTcxCfg->coder_type, st->Bin_E_fx, st->q_Bin_E ); /* Account for consumed bits */ nbits_lpc[0] = TCXLPC_NUMBITS; @@ -557,8 +557,8 @@ void stereo_tcx_core_enc( st->hTcxCfg->tcx_last_overlap_mode = st->hTcxCfg->tcx_curr_overlap_mode; move16(); - s = sub( getScaleFactor16( st->synth, st->L_frame ), 2 ); - s = s_min( s, getScaleFactor16( st->hLPDmem->syn, M ) ); + s = sub( norm_arr( st->synth, st->L_frame ), 2 ); + s = s_min( s, norm_arr( st->hLPDmem->syn, M ) ); IF( st->tcxonly == 0 ) { s = s_min( s, norm_s( st->wspeech_enc[st->L_frame - 1] ) ); @@ -579,7 +579,7 @@ void stereo_tcx_core_enc( coder_tcx_post_ivas_fx( st, st->hLPDmem, st->hTcxCfg, st->synth, A_q_fx, Aw_fx, st->wspeech_enc, Q_new ); /* Upscaling old_exc buffer */ - s = getScaleFactor16( st->hLPDmem->old_exc, L_EXC_MEM ) - 1; + s = norm_arr( st->hLPDmem->old_exc, L_EXC_MEM ) - 1; Scale_sig( st->hLPDmem->old_exc, L_EXC_MEM, s ); IF( st->hTdCngEnc != NULL ) { @@ -727,10 +727,6 @@ void stereo_tcx_core_enc( move16(); } } - st->q_Bin_E = Q_new + Q_SCALE - 2; - move16(); - st->q_Bin_E_old = Q_new + Q_SCALE - 2; - move16(); Scale_sig( st->synth, st->L_frame, -Q_new ); IF( st->tcxonly == 0 ) { @@ -810,6 +806,13 @@ Word16 ivas_acelp_tcx20_switching_fx( #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++ ) + { + window_p_fx[i].v.re = 0; + move16(); + window_p_fx[i].v.im = 0; + move16(); + } #endif L_frame_tmp = L_frame; @@ -865,6 +868,15 @@ 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 + move16(); + 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 @@ -872,6 +884,7 @@ Word16 ivas_acelp_tcx20_switching_fx( window_fx[i] = st->hTcxCfg->tcx_mdct_window[i].v.im; // Q15 move16(); } +#endif } ELSE { diff --git a/lib_enc/ivas_td_low_rate_enc.c b/lib_enc/ivas_td_low_rate_enc.c index 22ce9b6e9d0f2b825bf0ccf7dc42f4d48833c4b2..95762fa296a63cfcc9d29666eae38654b62754fd 100644 --- a/lib_enc/ivas_td_low_rate_enc.c +++ b/lib_enc/ivas_td_low_rate_enc.c @@ -222,6 +222,10 @@ void encod_gen_2sbfr( LPD_state_HANDLE hLPDmem = st->hLPDmem; +#ifdef MSAN_FIX + set16_fx( cn, 0, 2 * L_SUBFR ); /* Target vector in residual domain */ +#endif + /*------------------------------------------------------------------* * Initializations *------------------------------------------------------------------*/ diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index 631f7bf3889559fd1137970f33ed1c610527a1c4..e743f6f608569997731d726939896a9e6925705a 100644 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -1749,6 +1749,9 @@ ivas_error IVAS_ENC_EncodeFrameToSerial( } ELSE { +#ifdef DEBUG_MODE_INFO + dbgwrite( inputBuffer, sizeof( int16_t ), inputBufferSize, 1, strcat( fname( debug_dir, "ivas_input_dmx", 0, 1, ENC ), ".pcm" ) ); +#endif hCoreCoder->input_frame_fx = inputBufferSize; move32(); IF( NE_32( ( error = evs_enc_fx( hCoreCoder, inputBuffer, hCoreCoder->mem_hp20_in_fx, inputBufferSize ) ), IVAS_ERR_OK ) ) @@ -2716,9 +2719,18 @@ static ivas_error forcedModeApiToInternal( case IVAS_ENC_FORCE_GSC: *forcedModeInternal = FORCE_GSC; break; +#ifdef SUPPORT_FORCE_TCX10_TCX20 + case IVAS_ENC_FORCE_TCX10: + *forcedModeInternal = FORCE_TCX10; + break; + case IVAS_ENC_FORCE_TCX20: + *forcedModeInternal = FORCE_TCX20; + break; +#else case IVAS_ENC_FORCE_TCX: *forcedModeInternal = FORCE_TCX; break; +#endif case IVAS_ENC_FORCE_HQ: *forcedModeInternal = FORCE_HQ; break; diff --git a/lib_enc/lib_enc.h b/lib_enc/lib_enc.h index 69f794b69f7b6797f7892facda9078d8c7c0510f..9962986455eb14b9a80ef3918471d39048a8d5ad 100644 --- a/lib_enc/lib_enc.h +++ b/lib_enc/lib_enc.h @@ -127,7 +127,12 @@ typedef enum _IVAS_ENC_FORCED_MODE IVAS_ENC_FORCE_MUSIC, IVAS_ENC_FORCE_ACELP, IVAS_ENC_FORCE_GSC, +#ifdef SUPPORT_FORCE_TCX10_TCX20 + IVAS_ENC_FORCE_TCX10, + IVAS_ENC_FORCE_TCX20, +#else IVAS_ENC_FORCE_TCX, +#endif IVAS_ENC_FORCE_HQ, #ifdef DEBUG_FORCE_DIR IVAS_ENC_FORCE_FILE, diff --git a/lib_enc/lp_exc_e_fx.c b/lib_enc/lp_exc_e_fx.c index 8b9cb113e98d08f0eafbf693ab39722cc3d25917..0887698f78c49dc6579835076bfe83d5af9a5aac 100644 --- a/lib_enc/lp_exc_e_fx.c +++ b/lib_enc/lp_exc_e_fx.c @@ -175,7 +175,7 @@ Word16 lp_filt_exc_enc_ivas_fx( const Word16 coder_type, /* i : coding type Q0 */ const Word16 i_subfr, /* i : subframe index Q0 */ Word16 *exc, /* i/o: pointer to excitation signal frame Q_new */ - const Word16 *h1, /* i : weighted filter input response Q(14+shift) */ + const Word16 *h1, /* i : weighted filter input response Q(15) */ const Word16 *xn, /* i : target vector Q_new-1+shift */ Word16 *y1, /* o : zero-memory filtered adaptive excitation Q_new-1+shift */ Word16 *xn2, /* o : target vector for innovation search Q_new-1+shift */ @@ -260,7 +260,7 @@ Word16 lp_filt_exc_enc_ivas_fx( } IF( use_prev_sf_pit_gain == 1 ) { - wtmp1 = adpt_enr_fx( codec_mode, exc_tmp, h1, y1_tmp, L_subfr, &gain2, gain_pit, clip_gain, xn, xn2_tmp, &exp_ener1, use_prev_sf_pit_gain ); + wtmp1 = adpt_enr_fx( codec_mode, exc_tmp, h1, y1_tmp, L_subfr, gain_pit, g_corr2, clip_gain, xn, xn2_tmp, &exp_ener1, use_prev_sf_pit_gain ); } ELSE { @@ -354,18 +354,12 @@ static Word16 adpt_enr_fx( /* o : adaptive excitation Overflow = 0; move16(); -#ifdef BASOP_NOGLOB /* Critical Overflow */ Overflow = -#endif conv_fx( exc, h1, y1, L_subfr ); IF( use_prev_sf_pit_gain == 0 ) { -#ifdef BASOP_NOGLOB /* Critical Overflow */ *gain = corr_xy1_fx( xn, y1, g_corr, L_subfr, codec_mode == MODE2, &Overflow ); -#else - *gain = corr_xy1_fx( xn, y1, g_corr, L_subfr, codec_mode == MODE2 ); -#endif move16(); test(); @@ -381,11 +375,7 @@ static Word16 adpt_enr_fx( /* o : adaptive excitation Overflow = 0; conv_fx( exc_tmp, h1, y1, L_subfr ); -#ifdef BASOP_NOGLOB *gain = corr_xy1_fx( xn_tmp, y1, g_corr, L_subfr, codec_mode == MODE2, &Overflow ); -#else - *gain = corr_xy1_fx( xn_tmp, y1, g_corr, L_subfr, codec_mode == MODE2 ); -#endif move16(); } @@ -439,10 +429,8 @@ Word16 corr_xy1_fx( /* o : pitch gain (0..GAIN_PIT_MAX) Word16 g_corr[], /* o : correlations and -2 */ const Word16 L_subfr, /* i : vector length */ const Word16 norm_flag /* i : flag for constraining pitch contribution */ -#ifdef BASOP_NOGLOB , Flag *Overflow_out /* o : propagating the Overflow flag to upper level */ -#endif ) { Word16 i; @@ -462,13 +450,9 @@ Word16 corr_xy1_fx( /* o : pitch gain (0..GAIN_PIT_MAX) Copy( y1_1, y1, L_subfr ); Overflow = 0; move16(); -#ifdef BASOP_NOGLOB /* Critical Overflow */ Ltmp1 = Dot_product12_o( y1, y1, L_subfr, &exp_yy, &Overflow ); *Overflow_out |= Overflow; move16(); -#else - Ltmp1 = Dot_product12( y1, y1, L_subfr, &exp_yy ); -#endif IF( Overflow ) { FOR( i = 0; i < L_subfr; i++ ) @@ -504,13 +488,9 @@ Word16 corr_xy1_fx( /* o : pitch gain (0..GAIN_PIT_MAX) /* Ltmp1 = L_shr(Ltmp1, sub(30, exp_yy));*/ /* Compute scalar product */ -#ifdef BASOP_NOGLOB Ltmp2 = Dot_product12_o( xn, y1, L_subfr, &exp_xy, &Overflow ); *Overflow_out |= Overflow; move16(); -#else - Ltmp2 = Dot_product12( xn, y1, L_subfr, &exp_xy ); -#endif xy = extract_h( Ltmp2 ); /* Ltmp2 = L_shr(Ltmp2, sub(30, exp_xy));*/ @@ -533,13 +513,9 @@ Word16 corr_xy1_fx( /* o : pitch gain (0..GAIN_PIT_MAX) xy = shr( xy, 1 ); /* be sure that xy < yy */ gain = div_s( xy, yy ); i = sub( exp_xy, exp_yy ); -#ifdef BASOP_NOGLOB gain = shl_o( gain, i, &Overflow ); /* saturation can occur here */ *Overflow_out |= Overflow; move16(); -#else /* BASOP_NOGLOB */ - gain = shl( gain, i ); /* saturation can occur here */ -#endif gain = s_max( gain, 0 ); gain = s_min( gain, GAIN_PIT_MAX ); /* 1.2 in Q14 */ @@ -553,9 +529,7 @@ Word16 corr_xy1_fx( /* o : pitch gain (0..GAIN_PIT_MAX) /* Limit the energy of pitch contribution */ IF( norm_flag ) { -#ifdef BASOP_NOGLOB /*that part of code seems never used*/ -#endif /* Compute scalar product */ xx = round_fx( Dot_product12_offs( xn, xn, L_subfr, &exp_xx, 1 ) ); @@ -567,11 +541,7 @@ Word16 corr_xy1_fx( /* o : pitch gain (0..GAIN_PIT_MAX) /* Note: shl works as shl or shr. */ exp_xx = sub( exp_xx, 1 ); BASOP_SATURATE_WARNING_OFF_EVS -#ifdef BASOP_NOGLOB gain_p_snr = round_fx_sat( L_shl_sat( Mpy_32_16_1( 1717986944l /*ACELP_GAINS_CONST Q31*/, tmp ), exp_xx ) ); -#else - gain_p_snr = round_fx( L_shl( Mpy_32_16_1( 1717986944l /*ACELP_GAINS_CONST Q31*/, tmp ), exp_xx ) ); -#endif BASOP_SATURATE_WARNING_ON_EVS gain = s_min( gain, gain_p_snr ); diff --git a/lib_enc/lsf_enc_fx.c b/lib_enc/lsf_enc_fx.c index af1dbd1bd72aa737403b148eb9fba04620c69740..3f3f913925771ce9883915484dcce8e18d61575b 100644 --- a/lib_enc/lsf_enc_fx.c +++ b/lib_enc/lsf_enc_fx.c @@ -807,11 +807,7 @@ static Word16 qlsf_Mode_Select_fx( { pred_pow2[i] = shl( pred1[i], cs ); move16(); -#ifdef BASOP_NOGLOB En = L_mac_o( En, mult( pred_pow2[i], shl_o( w[i], 2, &Overflow ) ), pred_pow2[i], &Overflow ); /* 2.56*2.56 at Q-4 */ -#else /* BASOP_NOGLOB */ - En = L_mac( En, mult( pred_pow2[i], shl( w[i], 2 ) ), pred_pow2[i] ); /* 2.56*2.56 at Q-4 */ -#endif /* BASOP_NOGLOB */ } cs = shl( cs, 1 ); @@ -2133,11 +2129,7 @@ static void first_VQstages( L_tmp = L_deposit_l( 0 ); FOR( j = 0; j < N; j++ ) { -#ifdef BASOP_NOGLOB L_tmp1 = L_shl_o( L_mult0( u[j], w[j] ), 7, &Overflow ); /*x2.56 + Q8 + Q7 */ -#else /* BASOP_NOGLOB */ - L_tmp1 = L_shl( L_mult0( u[j], w[j] ), 7 ); /*x2.56 + Q8 + Q7 */ -#endif /* BASOP_NOGLOB */ L_tmp1 = Mult_32_16( L_tmp1, u[j] ); /*x2.56 + Q15 + x2.56 -Q15 */ L_tmp = L_add( L_tmp, L_tmp1 ); /*Q0 + x2.56 +x2.56 */ } @@ -2374,25 +2366,13 @@ static Word32 vq_lvq_lsf_enc( Vr_subt( cand[i], lsf, diff, M ); FOR( j = 0; j < M; j++ ) { -#ifdef BASOP_NOGLOB diff[j] = shl_o( diff[j], 4, &Overflow ); -#else /* BASOP_NOGLOB */ - diff[j] = shl( diff[j], 4 ); -#endif /* BASOP_NOGLOB */ move16(); } -#ifdef BASOP_NOGLOB L_tmp = L_mult( mult( diff[0], shl_o( w[0], 1, &Overflow ) ), diff[0] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q6 */ -#else - L_tmp = L_mult( mult( diff[0], shl( w[0], 1 ) ), diff[0] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q6 */ -#endif FOR( j = 1; j < M; j++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_mac( L_tmp, mult( diff[j], shl_o( w[j], 1, &Overflow ) ), diff[j] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q6 */ -#else - L_tmp = L_mac( L_tmp, mult( diff[j], shl( w[j], 1 ) ), diff[j] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q6 */ -#endif } e[i] = L_tmp; move32(); @@ -2509,25 +2489,13 @@ static Word32 vq_lvq_lsf_enc_ivas_fx( Vr_subt( cand[i], lsf, diff, M ); FOR( j = 0; j < M; j++ ) { -#ifdef BASOP_NOGLOB diff[j] = shl_o( diff[j], 4, &Overflow ); -#else /* BASOP_NOGLOB */ - diff[j] = shl( diff[j], 4 ); -#endif /* BASOP_NOGLOB */ move16(); } -#ifdef BASOP_NOGLOB L_tmp = L_mult( mult( diff[0], shl_o( w[0], 1, &Overflow ) ), diff[0] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q6 */ -#else - L_tmp = L_mult( mult( diff[0], shl( w[0], 1 ) ), diff[0] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q6 */ -#endif FOR( j = 1; j < M; j++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_mac( L_tmp, mult( diff[j], shl_o( w[j], 1, &Overflow ) ), diff[j] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q6 */ -#else - L_tmp = L_mac( L_tmp, mult( diff[j], shl( w[j], 1 ) ), diff[j] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q6 */ -#endif } e[i] = L_tmp; move32(); @@ -3375,11 +3343,7 @@ Word32 qlsf_ARSN_tcvq_Enc_16k_fx( { yy_fx[i] = shl( yy_fx[i], cs ); move16(); -#ifdef BASOP_NOGLOB temp_l = L_mac_o( temp_l, mult( yy_fx[i], shl_o( w_fx[i], 2, &Overflow ) ), yy_fx[i], &Overflow ); -#else /* BASOP_NOGLOB */ - temp_l = L_mac( temp_l, mult( yy_fx[i], shl( w_fx[i], 2 ) ), yy_fx[i] ); -#endif /* BASOP_NOGLOB */ } cs = shl( cs, 1 ); temp_l = L_shr( temp_l, cs ); @@ -3405,11 +3369,7 @@ static void FFT_Mid_Interpol_16k_fx( FOR( i = 0; i < L_FFT / 2; i++ ) { /* Interpolation */ -#ifdef BASOP_NOGLOB Bin_Ener_mid[i] = L_shr( L_add_o( Bin_Ener_old[i], Bin_Ener[i], &Overflow ), 1 ); -#else /* BASOP_NOGLOB */ - Bin_Ener_mid[i] = L_shr( L_add( Bin_Ener_old[i], Bin_Ener[i] ), 1 ); -#endif /* BASOP_NOGLOB */ /* Memory update */ Bin_Ener_old[i] = Bin_Ener[i]; @@ -3603,15 +3563,9 @@ static void lsf_mid_enc_fx( tmp = sub( lsf[j], qlsf[j] ); /* err += wghts[j] * ftemp * ftemp; */ /* tmp is usually very small, we can have some extra precision with very rare saturation */ -#ifdef BASOP_NOGLOB tmp = shl_o( tmp, 4, &Overflow ); tmp = mult_ro( tmp, tmp, &Overflow ); err = L_mac_o( err, tmp, shl_o( wghts[j], 2, &Overflow ), &Overflow ); -#else /* BASOP_NOGLOB */ - tmp = shl( tmp, 4 ); - tmp = mult_r( tmp, tmp ); - err = L_mac( err, tmp, shl( wghts[j], 2 ) ); -#endif } /* err = L_shl(err,Wscale); */ err = Mult_32_16( err, LSF_1_OVER_256SQ ); @@ -3795,15 +3749,9 @@ static void lsf_mid_enc_ivas_fx( tmp = sub( lsf[j], qlsf[j] ); /* err += wghts[j] * ftemp * ftemp; */ /* tmp is usually very small, we can have some extra precision with very rare saturation */ -#ifdef BASOP_NOGLOB tmp = shl_o( tmp, 4, &Overflow ); tmp = mult_ro( tmp, tmp, &Overflow ); err = L_mac_o( err, tmp, shl_o( wghts[j], 2, &Overflow ), &Overflow ); -#else /* BASOP_NOGLOB */ - tmp = shl( tmp, 4 ); - tmp = mult_r( tmp, tmp ); - err = L_mac( err, tmp, shl( wghts[j], 2 ) ); -#endif } /* err = L_shl(err,Wscale); */ err = Mult_32_16( err, LSF_1_OVER_256SQ ); diff --git a/lib_enc/lsf_msvq_ma_enc.c b/lib_enc/lsf_msvq_ma_enc.c index 2af64bf141f2009b2ddf9be421f6ba25f0f3011f..6ee7bb9c3aff691dd248a4831b2b75419fb137d2 100644 --- a/lib_enc/lsf_msvq_ma_enc.c +++ b/lib_enc/lsf_msvq_ma_enc.c @@ -737,7 +737,7 @@ void msvq_enc_ivas_fx( IF( cb_stage != NULL ) { // p2 = cb_stage + ( indices[1][c * stages + s] ) * maxn; /* regular ptr init */ - Copy_Scale_sig_16_32( cb_stage + ( indices[1][c * stages + s] ) * maxn, Tmp, N, 0 ); + Copy_Scale_sig_16_32_DEPREC( cb_stage + ( indices[1][c * stages + s] ) * maxn, Tmp, N, 0 ); scale_sig32( Tmp, N, sub( sub( Q31, Q_cb ), resid_e ) ); p2 = Tmp; } diff --git a/lib_enc/lsf_msvq_ma_enc_fx.c b/lib_enc/lsf_msvq_ma_enc_fx.c index 5e65218e5df99d3d8c6efb483cc49a740151f011..b81cc18e8486f5abdacdad2104ae288f8a0e08a4 100644 --- a/lib_enc/lsf_msvq_ma_enc_fx.c +++ b/lib_enc/lsf_msvq_ma_enc_fx.c @@ -49,7 +49,6 @@ static Word32 depack_mul_values( Word16 *Tmp, const Word16 *w, const Word16 *cbp FOR( i = 0; i < N; i += 4 ) { depack_4_values( cbp + i_mult( shr( i, 2 ), 3 ), val0, val1, val2, val3 ) -#ifdef BASOP_NOGLOB Tmp[i + 0] = mult_r( shl_sat( w[i + 0], 2 ), val0 ); move16(); en = L_mac_sat( en, val0, Tmp[i + 0] ); @@ -62,20 +61,6 @@ static Word32 depack_mul_values( Word16 *Tmp, const Word16 *w, const Word16 *cbp Tmp[i + 3] = mult_r( shl_sat( w[i + 3], 2 ), val3 ); move16(); en = L_mac_sat( en, val3, Tmp[i + 3] ); -#else - Tmp[i + 0] = mult_r( shl( w[i + 0], 2 ), val0 ); - move16(); - en = L_mac( en, val0, Tmp[i + 0] ); - Tmp[i + 1] = mult_r( shl( w[i + 1], 2 ), val1 ); - move16(); - en = L_mac( en, val1, Tmp[i + 1] ); - Tmp[i + 2] = mult_r( shl( w[i + 2], 2 ), val2 ); - move16(); - en = L_mac( en, val2, Tmp[i + 2] ); - Tmp[i + 3] = mult_r( shl( w[i + 3], 2 ), val3 ); - move16(); - en = L_mac( en, val3, Tmp[i + 3] ); -#endif } return en; @@ -263,11 +248,7 @@ void msvq_enc_fx( move16(); FOR( j = 1; j < N; j++ ) { -#ifdef BASOP_NOGLOB ss2 = L_mac_sat( ss2, mult( u[j], shl_sat( w[j], 2 ) ), u[j] ); -#else - ss2 = L_mac( ss2, mult( u[j], shl( w[j], 2 ) ), u[j] ); -#endif } /* Set up inital error (residual) vectors */ @@ -363,13 +344,8 @@ void msvq_enc_fx( BASOP_SATURATE_WARNING_OFF_EVS /*NOTE: as long as a shorter distance is found, saturation can be accepted.*/ -#ifdef BASOP_NOGLOB tmp = L_add_sat( dist[0][c], L_sub_sat( en, L_shl( t1, 1 ) ) ); t1 = L_sub_sat( tmp, dist[1][p_max] ); -#else - tmp = L_add( dist[0][c], L_sub( en, L_shl( t1, 1 ) ) ); - t1 = L_sub( tmp, dist[1][p_max] ); -#endif BASOP_SATURATE_WARNING_ON_EVS IF( t1 <= 0 ) @@ -497,20 +473,11 @@ void midlsf_enc_fx( tmp = sub( lsf[j], qlsf[j] ); /* err += wghts[j] * ftemp * ftemp; */ /* tmp is usually very small, we can have some extra precision with very rare saturation */ -#ifdef BASOP_NOGLOB tmp = shl_o( tmp, 4, &Overflow ); tmp = mult_ro( tmp, tmp, &Overflow ); -#else /* BASOP_NOGLOB */ - tmp = shl( tmp, 4 ); - tmp = mult_r( tmp, tmp ); -#endif /* BASOP_NOGLOB */ err = L_mac( err, tmp, wghts[j] ); } -#ifdef BASOP_NOGLOB err = L_shl_o( err, 2, &Overflow ); -#else /* BASOP_NOGLOB */ - err = L_shl( err, 2 ); -#endif /* err = L_shl(err,Wscale); */ err = Mult_32_16( err, LSF_1_OVER_256SQ ); @@ -685,6 +652,165 @@ Word16 Q_lsf_tcxlpc_fx( return NumIndices; } + +Word16 Q_lsf_tcxlpc_ivas_fx( + /* const */ Word16 lsf[], /* i : original lsf */ + Word16 lsf_q[], /* o : quantized lsf */ + Word16 lsp_q_ind[], /* o : quantized lsp (w/o MA prediction) */ + Word16 indices[], /* o : VQ indices */ + const Word16 lpcorder, /* i : LPC order */ + const Word16 narrowband, /* i : narrowband flag */ + const Word16 cdk, /* i : codebook selector */ + const Word16 mem_MA[], /* i : MA memory */ + const Word16 coder_type, + const Word32 *Bin_Ener, + const Word16 Q_ener ) +{ + Word16 weights[M + 1]; + Word16 pred[M16k]; + Word16 i; + Word16 NumIndices; + Word16 lsf_q_ind[M16k]; + const Word16 *means; + Word16 lsf_rem[M]; + Word16 lsf_rem_q_ind[M]; + + Unified_weighting_fx( &Bin_Ener[L_FFT / 2], Q_ener, lsf, weights, narrowband, (Word16) EQ_16( coder_type, UNVOICED ), 12800, M ); + + move16(); + NumIndices = 0; + + /* Put disabled flag */ + indices[NumIndices] = 0; + move16(); + NumIndices = add( NumIndices, 1 ); + + /* Inter-frame prediction */ + + means = lsf_means[narrowband]; /* 14Q1 * 1.28 */ + + FOR( i = 0; i < lpcorder; ++i ) + { + pred[i] = add( means[i], mult_r( MU_MA_FX, mem_MA[i] ) ); /* 14Q1 * 1.28 + ( 14Q1 * 1.28 * Q15 ) = 14Q1 * 1.28*/ + move16(); + } + + /* Subtract prediction */ + + FOR( i = 0; i < lpcorder; ++i ) + { + lsf[i] = sub( lsf[i], pred[i] ); /* 14Q1 * 1.28 */ + move16(); + } + + + msvq_enc_fx( + lsf_codebook[narrowband][cdk], + lsf_dims, + lsf_offs, + lsf, + lsf_numlevels, + kMaxC, + TCXLPC_NUMSTAGES, + weights, + lpcorder, + lpcorder, + indices + NumIndices ); + msvq_dec( + lsf_codebook[narrowband][cdk], + lsf_dims, + lsf_offs, + TCXLPC_NUMSTAGES, + lpcorder, + lpcorder, + indices + NumIndices, +#ifdef IVAS_MSVQ + 0, NULL, +#endif + lsf_q ); + NumIndices = add( NumIndices, TCXLPC_NUMSTAGES ); + + FOR( i = 0; i < lpcorder; ++i ) + { + lsf_q_ind[i] = lsf_q[i]; + move16(); + } + + /* Update flag */ + indices[0] = lsf_ind_is_active( lsf_q_ind, lsf_means[narrowband], narrowband, cdk ); + move16(); + + /* Get residual vector */ + FOR( i = 0; i < lpcorder; ++i ) + { + lsf_rem[i] = add( sub( pred[i], lsf_means[narrowband][i] ), sub( lsf[i], lsf_q_ind[i] ) ); + move16(); + } + + /* Quantize using extra stage(s) */ + msvq_enc_fx( + lsf_ind_codebook[narrowband][cdk], + lsf_ind_dims, + lsf_ind_offs, + lsf_rem, + lsf_ind_numlevels, + kMaxC, + TCXLPC_IND_NUMSTAGES, + weights, + lpcorder, + lpcorder, + indices + NumIndices ); + /* Only add contribution if flag is enabled */ + IF( indices[0] ) + { + /* Decode */ + msvq_dec( + lsf_ind_codebook[narrowband][cdk], + lsf_ind_dims, + lsf_ind_offs, + TCXLPC_IND_NUMSTAGES, + lpcorder, + lpcorder, + indices + NumIndices, +#ifdef IVAS_MSVQ + 0, NULL, +#endif + lsf_rem_q_ind ); + NumIndices = add( NumIndices, TCXLPC_IND_NUMSTAGES ); + + /* Add to MA-removed vector */ + FOR( i = 0; i < lpcorder; ++i ) + { + lsf_q_ind[i] = add( lsf_q_ind[i], lsf_rem_q_ind[i] ); + move16(); + } + } + + /* Add inter-frame prediction */ + FOR( i = 0; i < lpcorder; ++i ) + { + lsf_q[i] = add( lsf_q[i], pred[i] ); + lsf[i] = add( lsf[i], pred[i] ); + move16(); + move16(); + } + + reorder_lsf_fx( lsf_q, TCXLPC_LSF_GAP, lpcorder, INT_FS_FX ); + + FOR( i = 0; i < lpcorder; ++i ) + { + lsf_q_ind[i] = add( lsf_q_ind[i], lsf_means[narrowband][i] ); + move16(); + } + reorder_lsf_fx( lsf_q_ind, TCXLPC_LSF_GAP, lpcorder, INT_FS_FX ); + + IF( lsp_q_ind ) + { + E_LPC_lsf_lsp_conversion /*lsf2lsp*/ ( lsf_q_ind, lsp_q_ind, lpcorder ); + } + + return NumIndices; +} /*--------------------------------------------------------------------------* * enc_lsf_tcxlpc_fx() * diff --git a/lib_enc/ltd_stable_fx.c b/lib_enc/ltd_stable_fx.c index 63ade58a8ce9eddacd3fb3d852aa0415ca57b67b..a6e3ae1cc0909cffc40469b308b5d13e95580573 100644 --- a/lib_enc/ltd_stable_fx.c +++ b/lib_enc/ltd_stable_fx.c @@ -199,11 +199,7 @@ void ltd_stable_fx( FOR( i = 0; i < 20; i++ ) { -#ifdef BASOP_NOGLOB tmp_mul = L_mult_sat( tmp16[i], tmp16[i] ); -#else - tmp_mul = L_mult( tmp16[i], tmp16[i] ); -#endif tmp_mul = L_shr( tmp_mul, 5 ); dif32 = L_add( dif32, tmp_mul ); @@ -295,11 +291,7 @@ void ltd_stable_fx( FOR( i = 0; i < 14; i++ ) { tmp = extract_h( tmp32[i] ); -#ifdef BASOP_NOGLOB tmp_mul = L_mult_sat( tmp, tmp ); -#else - tmp_mul = L_mult( tmp, tmp ); -#endif tmp_mul = L_shr( tmp_mul, 4 ); dif32 = L_add( dif32, tmp_mul ); @@ -423,20 +415,12 @@ void ltd_stable_fx( FOR( i = 0; i < 8; i++ ) { tmp = extract_h( tmp32[i] ); -#ifdef BASOP_NOGLOB tmp_mul = L_mult_sat( tmp, tmp ); -#else - tmp_mul = L_mult( tmp, tmp ); -#endif tmp_mul = L_shr( tmp_mul, 3 ); dif32 = L_add( dif32, tmp_mul ); tmp = extract_h( mid_frame_amp32[i] ); -#ifdef BASOP_NOGLOB mid_frame_amp_mul = L_mult_sat( tmp, tmp ); -#else - mid_frame_amp_mul = L_mult( tmp, tmp ); -#endif mid_frame_amp_mul = L_shr( mid_frame_amp_mul, 3 ); apow32 = L_add( apow32, mid_frame_amp_mul ); } diff --git a/lib_enc/mdct_classifier_fx.c b/lib_enc/mdct_classifier_fx.c index 51fe086df0a7fd3d7931e10beb8daa5d01f20c0c..265fce7f2362eac89d7fa7a1cf033cb433b2f059 100644 --- a/lib_enc/mdct_classifier_fx.c +++ b/lib_enc/mdct_classifier_fx.c @@ -433,11 +433,7 @@ Word16 mdct_classifier_fx( /* o: MDCT A/B decision test(); test(); test(); -#ifdef BASOP_NOGLOB IF( GT_32( Mult_32_16( gain3, 27307 ), gain2 ) || ( GE_32( gain3, Mult_32_16( gain2, 26214 ) ) && GT_32( peak_H1, L_shl_o( avrg_H1, 1, &Overflow ) ) ) || ( LT_32( Mult_32_32( L_shl_o( peak_l, exp, &Overflow ), L_shl_o( avrg_h, exp1, &Overflow ) ), Mult_32_32( L_shl_o( L_tmp, exp, &Overflow ), L_shl_o( avrg_l, exp1, &Overflow ) ) ) || GT_32( Mult_32_32( L_shl_o( L_tmp1, exp2, &Overflow ), L_shl_o( avrg_h, exp1, &Overflow ) ), Mult_32_32( L_shl_o( peak_h, exp2, &Overflow ), L_shl_o( avrg_l, exp1, &Overflow ) ) ) ) ) -#else - IF( GT_32( Mult_32_16( gain3, 27307 ), gain2 ) || ( GE_32( gain3, Mult_32_16( gain2, 26214 ) ) && GT_32( peak_H1, L_shl( avrg_H1, 1 ) ) ) || ( LT_32( Mult_32_32( L_shl( peak_l, exp ), L_shl( avrg_h, exp1 ) ), Mult_32_32( L_shl( L_tmp, exp ), L_shl( avrg_l, exp1 ) ) ) || GT_32( Mult_32_32( L_shl( L_tmp1, exp2 ), L_shl( avrg_h, exp1 ) ), Mult_32_32( L_shl( peak_h, exp2 ), L_shl( avrg_l, exp1 ) ) ) ) ) -#endif { condition3 = 1; move16(); @@ -531,11 +527,7 @@ Word16 mdct_classifier_fx( /* o: MDCT A/B decision test(); test(); test(); -#ifdef BASOP_NOGLOB IF( ( EQ_16( hTcxEnc->clas_final_old, HQ_CORE ) || EQ_16( hTcxEnc->clas_final_old, TCX_20_CORE ) ) && ( ( GT_32( hTcxEnc->last_gain1, L_shr( gain1_tmp, 1 ) ) && LT_32( hTcxEnc->last_gain1, L_shl_o( gain1_tmp, 1, &Overflow ) ) ) && ( GT_32( hTcxEnc->last_gain2, L_shr( gain2_tmp, 1 ) ) && LT_32( hTcxEnc->last_gain2, L_shl_o( gain2_tmp, 1, &Overflow ) ) ) ) ) -#else - IF( ( EQ_16( hTcxEnc->clas_final_old, HQ_CORE ) || EQ_16( hTcxEnc->clas_final_old, TCX_20_CORE ) ) && ( ( GT_32( hTcxEnc->last_gain1, L_shr( gain1_tmp, 1 ) ) && LT_32( hTcxEnc->last_gain1, L_shl( gain1_tmp, 1 ) ) ) && ( GT_32( hTcxEnc->last_gain2, L_shr( gain2_tmp, 1 ) ) && LT_32( hTcxEnc->last_gain2, L_shl( gain2_tmp, 1 ) ) ) ) ) -#endif { clas_final = hTcxEnc->clas_final_old; move16(); @@ -972,11 +964,7 @@ Word16 mdct_classifier_ivas_fx( test(); test(); test(); -#ifdef BASOP_NOGLOB IF( GT_32( Mult_32_16( gain3, 27307 ), gain2 ) || ( GE_32( gain3, Mult_32_16( gain2, 26214 ) ) && GT_32( peak_H1, L_shl_o( avrg_H1, 1, &Overflow ) ) ) || ( LT_32( Mult_32_32( L_shl_o( peak_l, exp, &Overflow ), L_shl_o( avrg_h, exp1, &Overflow ) ), Mult_32_32( L_shl_o( L_tmp, exp, &Overflow ), L_shl_o( avrg_l, exp1, &Overflow ) ) ) || GT_32( Mult_32_32( L_shl_o( L_tmp1, exp2, &Overflow ), L_shl_o( avrg_h, exp1, &Overflow ) ), Mult_32_32( L_shl_o( peak_h, exp2, &Overflow ), L_shl_o( avrg_l, exp1, &Overflow ) ) ) ) ) -#else - IF( GT_32( Mult_32_16( gain3, 27307 ), gain2 ) || ( GE_32( gain3, Mult_32_16( gain2, 26214 ) ) && GT_32( peak_H1, L_shl( avrg_H1, 1 ) ) ) || ( LT_32( Mult_32_32( L_shl( peak_l, exp ), L_shl( avrg_h, exp1 ) ), Mult_32_32( L_shl( L_tmp, exp ), L_shl( avrg_l, exp1 ) ) ) || GT_32( Mult_32_32( L_shl( L_tmp1, exp2 ), L_shl( avrg_h, exp1 ) ), Mult_32_32( L_shl( peak_h, exp2 ), L_shl( avrg_l, exp1 ) ) ) ) ) -#endif { condition3 = 1; move16(); @@ -1077,11 +1065,7 @@ Word16 mdct_classifier_ivas_fx( test(); test(); -#ifdef BASOP_NOGLOB IF( ( EQ_16( hTcxEnc->clas_final_old, HQ_CORE ) || EQ_16( hTcxEnc->clas_final_old, TCX_20_CORE ) ) && ( ( GT_32( hTcxEnc->last_gain1, L_shr( gain1_tmp, 1 ) ) && LT_32( hTcxEnc->last_gain1, L_shl_o( gain1_tmp, 1, &Overflow ) ) ) && ( GT_32( hTcxEnc->last_gain2, L_shr( gain2_tmp, 1 ) ) && LT_32( hTcxEnc->last_gain2, L_shl_o( gain2_tmp, 1, &Overflow ) ) ) ) ) -#else - IF( ( EQ_16( hTcxEnc->clas_final_old, HQ_CORE ) || EQ_16( hTcxEnc->clas_final_old, TCX_20_CORE ) ) && ( ( GT_32( hTcxEnc->last_gain1, L_shr( gain1_tmp, 1 ) ) && LT_32( hTcxEnc->last_gain1, L_shl( gain1_tmp, 1 ) ) ) && ( GT_32( hTcxEnc->last_gain2, L_shr( gain2_tmp, 1 ) ) && LT_32( hTcxEnc->last_gain2, L_shl( gain2_tmp, 1 ) ) ) ) ) -#endif { clas_final = hTcxEnc->clas_final_old; move16(); diff --git a/lib_enc/multi_harm_fx.c b/lib_enc/multi_harm_fx.c index 92666570c892508d994b40f50663f7fa1ded24c7..86fe541bb3b062c6f7f15737b3249a4b6374bdf1 100644 --- a/lib_enc/multi_harm_fx.c +++ b/lib_enc/multi_harm_fx.c @@ -212,11 +212,7 @@ Word16 multi_harm_fx( /* o : frame multi-harmonicity IF( EQ_16( i, ind_mins[k] ) ) { /* include the last peak point (new minimum) to the corr. sum */ -#ifdef BASOP_NOGLOB Lcory2 = L_mac_o( Lcory2, old_S[i], old_S[i], &Overflow ); -#else /* BASOP_NOGLOB */ - Lcory2 = L_mac( Lcory2, old_S[i], old_S[i] ); -#endif /* BASOP_NOGLOB */ /* calculation of the norm. peak correlation */ test(); @@ -242,11 +238,7 @@ Word16 multi_harm_fx( /* o : frame multi-harmonicity corxy = shl( corxy, cor ); /* cor = corxy * corxy / (corx2 * cory2) */ corxy = div_s( corxy, corx2 ); -#ifdef BASOP_NOGLOB cor = shr_o( corxy, sub( shl( tmp16, 1 ), Expx2 ), &Overflow ); /* Q15 */ -#else /* BASOP_NOGLOB */ - cor = shr( corxy, sub( shl( tmp16, 1 ), Expx2 ) ); /* Q15 */ -#endif /* BASOP_NOGLOB */ } ELSE { @@ -271,15 +263,9 @@ Word16 multi_harm_fx( /* o : frame multi-harmonicity k++; } -#ifdef BASOP_NOGLOB Lcorx2 = L_mac_o( Lcorx2, S[i], S[i], &Overflow ); Lcory2 = L_mac_o( Lcory2, old_S[i], old_S[i], &Overflow ); Lcorxy = L_mac_o( Lcorxy, S[i], old_S[i], &Overflow ); -#else /* BASOP_NOGLOB */ - Lcorx2 = L_mac( Lcorx2, S[i], S[i] ); - Lcory2 = L_mac( Lcory2, old_S[i], old_S[i] ); - Lcorxy = L_mac( Lcorxy, S[i], old_S[i] ); -#endif } Copy( S, old_S, ind_mins[0] ); @@ -393,6 +379,7 @@ Word16 multi_harm_ivas_fx( /* o : frame multi-harmoni { Word16 i, j, k, L, stemp, N_mins, ind_mins[L_FFT / 4], *pt_mins, harm; Word16 S[L_FFT / 2], flor, step, tmp16, tmp2, Expx2, Expy2; + Word32 tmp2_32; Word16 corx2, cory2, corxy, cor, cor_map[L_FFT / 2], *pt1, *pt2, cor_strong; Word32 L_acc; Word32 Lcorx2, Lcory2, Lcorxy, Lcor_map_LT_sum; @@ -562,11 +549,7 @@ Word16 multi_harm_ivas_fx( /* o : frame multi-harmoni IF( EQ_16( i, ind_mins[k] ) ) { /* include the last peak point (new minimum) to the corr. sum */ -#ifdef BASOP_NOGLOB Lcory2 = L_mac_o( Lcory2, old_S[i], old_S[i], &Overflow ); -#else /* BASOP_NOGLOB */ - Lcory2 = L_mac( Lcory2, old_S[i], old_S[i] ); -#endif /* BASOP_NOGLOB */ /* calculation of the norm. peak correlation */ test(); @@ -592,11 +575,7 @@ Word16 multi_harm_ivas_fx( /* o : frame multi-harmoni corxy = shl( corxy, cor ); /* cor = corxy * corxy / (corx2 * cory2) */ corxy = div_s( corxy, corx2 ); -#ifdef BASOP_NOGLOB cor = shr_o( corxy, sub( shl( tmp16, 1 ), Expx2 ), &Overflow ); /* Q15 */ -#else /* BASOP_NOGLOB */ - cor = shr( corxy, sub( shl( tmp16, 1 ), Expx2 ) ); /* Q15 */ -#endif /* BASOP_NOGLOB */ } ELSE { @@ -621,15 +600,9 @@ Word16 multi_harm_ivas_fx( /* o : frame multi-harmoni k++; } -#ifdef BASOP_NOGLOB Lcorx2 = L_mac_o( Lcorx2, S[i], S[i], &Overflow ); Lcory2 = L_mac_o( Lcory2, old_S[i], old_S[i], &Overflow ); Lcorxy = L_mac_o( Lcorxy, S[i], old_S[i], &Overflow ); -#else /* BASOP_NOGLOB */ - Lcorx2 = L_mac( Lcorx2, S[i], S[i] ); - Lcory2 = L_mac( Lcory2, old_S[i], old_S[i] ); - Lcorxy = L_mac( Lcorxy, S[i], old_S[i] ); -#endif } Copy( S, old_S, ind_mins[0] ); @@ -649,7 +622,7 @@ Word16 multi_harm_ivas_fx( /* o : frame multi-harmoni *------------------------------------------------------------------*/ Lcor_map_LT_sum = L_deposit_l( 0 ); - tmp2 = 0; + tmp2_32 = 0; move16(); cor_strong = 0; @@ -661,7 +634,7 @@ Word16 multi_harm_ivas_fx( /* o : frame multi-harmoni FOR( i = 0; i < L; i++ ) { /* tmp2 += S[i]; */ - tmp2 = add( tmp2, shl( S[i], 1 ) ); /* tmp2 in Q8; max value is 128) */ + tmp2_32 = L_add( tmp2_32, cor_map[i] ); /* tmp2_32 in Q15; max value is 128) */ /* *pt1 = M_ALPHA_FX * *pt1 + (1-M_ALPHA_FX) * *pt2++ */ *pt1 = mac_r( L_mult( ONE_MINUS_M_ALPHA, *pt2 ), M_ALPHA_FX, *pt1 ); @@ -679,6 +652,7 @@ Word16 multi_harm_ivas_fx( /* o : frame multi-harmoni pt1++; pt2++; } + tmp2 = L_shr_sat( tmp2_32, 7 ); // q15-> q8 IF( EQ_16( bwidth, NB ) ) { diff --git a/lib_enc/nelp_enc_fx.c b/lib_enc/nelp_enc_fx.c index 259987bba43611a9f4c89041ea1a1ce51cc65533..a0ed2f523419729ebcdff1983b435b4eb7f59403 100644 --- a/lib_enc/nelp_enc_fx.c +++ b/lib_enc/nelp_enc_fx.c @@ -115,6 +115,7 @@ void quantize_uvg_fx( Word16 *G, Word16 *iG1, Word16 *iG2, Word16 *quantG, Word1 move16(); /*(+1)=/2 in log */ L_tmp = Mpy_32_16( exp, frac, 4932 ); /*Q16 ; 0.5*log10(2) in Q15 */ G1[i] = round_fx( L_shl( L_tmp, 13 ) ); /*Q13 */ + move16(); } ELSE { @@ -129,13 +130,8 @@ void quantize_uvg_fx( Word16 *G, Word16 *iG1, Word16 *iG2, Word16 *quantG, Word1 move16(); FOR( i = 0; i < UVG1_CBSIZE; i++ ) { -#ifdef BASOP_NOGLOB L16 = shr( sub_sat( G1[0], UVG1CB_fx[i][0] ), 1 ); /* Q12 */ L16_1 = shr( sub_sat( G1[1], UVG1CB_fx[i][1] ), 1 ); /* Q12 */ -#else - L16 = shr( sub( G1[0], UVG1CB_fx[i][0] ), 1 ); /* Q12 */ - L16_1 = shr( sub( G1[1], UVG1CB_fx[i][1] ), 1 ); /* Q12 */ -#endif Lacc = 0; Lacc = L_mac0( Lacc, L16, L16 ); /*Q24 */ Lacc = L_mac0( Lacc, L16_1, L16_1 ); /*Q24 */ @@ -152,9 +148,10 @@ void quantize_uvg_fx( Word16 *G, Word16 *iG1, Word16 *iG2, Word16 *quantG, Word1 L_tmp = L_shr( L_tmp, 10 ); /* From Q26 to Q16 */ frac = L_Extract_lc( L_tmp, &exp ); /* Extract exponent of L_tmp */ L_tmp = Pow2( 30, frac ); - exp = exp - 30; /*move16(); */ + exp = exp - 30; + move16(); Lexp[0] = L_shl( L_tmp, exp + 15 ); - + move32(); L_tmp = L_mult0( UVG1CB_fx[*iG1][1], 27213 ); /*Q26 */ L_tmp = L_shr( L_tmp, 10 ); /* From Q26 to Q16 */ @@ -162,7 +159,7 @@ void quantize_uvg_fx( Word16 *G, Word16 *iG1, Word16 *iG2, Word16 *quantG, Word1 L_tmp = Pow2( 30, frac ); exp = exp - 30; /*move16(); */ Lexp[1] = L_shl( L_tmp, exp + 15 ); - + move32(); FOR( i = 0; i < 2; i++ ) { @@ -174,6 +171,7 @@ void quantize_uvg_fx( Word16 *G, Word16 *iG1, Word16 *iG2, Word16 *quantG, Word1 tmp = div_s( 16384, tmp ); /*Q(15+exp) */ L_tmp = L_shr( L_mult0( G[i * 5 + j], tmp ), exp + 3 ); /*Q12 */ G2[i * 5 + j] = extract_l( L_tmp ); /*Q12 */ + move16(); } } @@ -191,25 +189,15 @@ void quantize_uvg_fx( Word16 *G, Word16 *iG1, Word16 *iG2, Word16 *quantG, Word1 { /*mse += SQR(G2[i*5+k]-UVG2CB1[j][k]); */ ind = add( shr( extract_l( L_mult( i, 5 ) ), 1 ), k ); -#ifdef BASOP_NOGLOB temp = sub_sat( G2[ind], UVG2CB1_fx[j][k] ); Lacc = L_mac0_sat( Lacc, temp, temp ); /*Q24 */ -#else - temp = sub( G2[ind], UVG2CB1_fx[j][k] ); - Lacc = L_mac0( Lacc, temp, temp ); /*Q24 */ -#endif } - ELSE IF( i == 1 ) + ELSE IF( EQ_16( i, 1 ) ) { /*mse += SQR(G2[i*5+k]-UVG2CB2[j][k]); */ ind = add( shr( extract_l( L_mult( i, 5 ) ), 1 ), k ); -#ifdef BASOP_NOGLOB temp = sub_sat( G2[ind], UVG2CB2_fx[j][k] ); Lacc = L_mac0_sat( Lacc, temp, temp ); /*Q24 */ -#else - temp = sub( G2[ind], UVG2CB2_fx[j][k] ); - Lacc = L_mac0( Lacc, temp, temp ); /*Q24 */ -#endif } } @@ -256,6 +244,7 @@ static void normalize_arr( Word16 *arr, Word16 *qf, Word16 size, Word16 hdr ) } *qf = norm_s( (Word16) max_s ); + move16(); test(); IF( ( *qf == 0 ) && ( ( (Word16) max_s ) == 0 ) ) { @@ -264,7 +253,7 @@ static void normalize_arr( Word16 *arr, Word16 *qf, Word16 size, Word16 hdr ) } *qf = *qf - hdr; - + move16(); FOR( i = 0; i < size; i++ ) { arr[i] = shl( arr[i], *qf ); @@ -314,41 +303,72 @@ void nelp_encoder_fx( { Word16 i, j; Word16 *ptr_fx = exc_fx; - Word16 lag = 25; /* to cover 25*9 + 31 */ - Word16 sqrt_inv_lag = 6554; /* sqrt(1/lag) in Q15 */ + Word16 lag = 25; /* to cover 25*9 + 31 */ + move16(); + Word16 sqrt_inv_lag = 6554; /* sqrt(1/lag) in Q15 */ + move16(); Word16 sqrt_inv_lframe_lag = 5885; /* sqrt(1/(L_FRAME-lag*9)) */ + move16(); Word16 Gains_fx[10], gain_fac_fx; Word16 iG1_fx, iG2_fx[2]; Word16 fid; Word16 fdbck_fx; Word32 var_dB_fx; Word32 E1_fx = 0, EL1_fx = 0, EH1_fx = 0, E2_fx = 0, E3_fx = 0, EL2_fx = 0, EH2_fx = 0; + move32(); /*E1_fx*/ + move32(); /*EL1_fx*/ + move32(); /*EH1_fx*/ + move32(); /*E2_fx*/ + move32(); /*E3_fx*/ + move32(); /*EL2_fx*/ + move32(); /*EH2_fx*/ Word32 RL_fx = 0, RH_fx = 0; + move32(); /*RL_fx*/ + move32(); /*RH_fx*/ Word16 R_fx = 0; + move16(); Word16 filtRes_fx[L_FRAME]; Word16 ptr_tmp_fx[L_FRAME]; Word16 qE1 = 0, qE2 = 0, qE3 = 0, qEL1 = 0, qEL2 = 0, qEH1 = 0, qEH2 = 0; + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); Word16 qIn = 0, qGain = 0, qf = 0, qf1 = 0, qNelpGain = 0; + move16(); + move16(); + move16(); + move16(); + move16(); Word16 exp1, exp2, tmp1, tmp2; Word16 f_Noise, etmp, e_Noise; Word16 max1 = 0; + move16(); Word32 l_nelp_gain_mem; Word32 Ltemp = 0, Ltemp1 = 0, L_tmp = 0, L_const_1; + move32(); + move32(); + move32(); Word16 BP1_ORDER; Word16 rf_flag; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR; BSTR_ENC_HANDLE hBstr = st_fx->hBstr; RF_ENC_HANDLE hRF = st_fx->hRF; rf_flag = st_fx->rf_mode; - + move16(); if ( EQ_16( hSC_VBR->last_nelp_mode, 1 ) && NE_16( st_fx->bwidth, st_fx->last_bwidth ) ) { hSC_VBR->last_nelp_mode = 0; + move16(); } qIn = *qIn1; @@ -403,11 +423,7 @@ void nelp_encoder_fx( E1_fx = L_deposit_l( 0 ); FOR( i = 0; i < L_FRAME; i++ ) { -#ifdef BASOP_NOGLOB E1_fx = L_mac0_o( E1_fx, in_fx[i], in_fx[i], &Overflow ); /*Q(qE1+qE1) */ -#else - E1_fx = L_mac0( E1_fx, in_fx[i], in_fx[i] ); /*Q(qE1+qE1) */ -#endif } qE1 = shl( qE1, 1 ); @@ -423,11 +439,7 @@ void nelp_encoder_fx( EL1_fx = L_deposit_l( 0 ); FOR( i = 0; i < L_FRAME; i++ ) { -#ifdef BASOP_NOGLOB EL1_fx = L_mac0_o( EL1_fx, filtRes_fx[i], filtRes_fx[i], &Overflow ); /*Q(2*qIn) */ -#else - EL1_fx = L_mac0( EL1_fx, filtRes_fx[i], filtRes_fx[i] ); /*Q(2*qIn) */ -#endif } qEL1 = shl( qEL1, 1 ); @@ -443,11 +455,7 @@ void nelp_encoder_fx( EH1_fx = L_deposit_l( 0 ); FOR( i = 0; i < L_FRAME; i++ ) { -#ifdef BASOP_NOGLOB EH1_fx = L_mac0_o( EH1_fx, filtRes_fx[i], filtRes_fx[i], &Overflow ); /*Q(2*qEH1) */ -#else - EH1_fx = L_mac0( EH1_fx, filtRes_fx[i], filtRes_fx[i] ); /*Q(2*qEH1) */ -#endif } qEH1 = 2 * qEH1; move16(); @@ -463,11 +471,7 @@ void nelp_encoder_fx( Ltemp = L_deposit_l( 0 ); FOR( j = (Word16) ( i * lag ); j < (Word16) ( ( i + 1 ) * lag ); j++ ) { -#ifdef BASOP_NOGLOB Ltemp = L_mac0_o( Ltemp, in_fx[j], in_fx[j], &Overflow ); /*Q(2*qGain) */ -#else - Ltemp = L_mac0( Ltemp, in_fx[j], in_fx[j] ); /*Q(2*qGain) */ -#endif } /*Gains[i] = (float) sqrt(Gains[i]/lag); */ @@ -481,28 +485,17 @@ void nelp_encoder_fx( L_tmp = L_deposit_h( tmp1 ); L_tmp = Isqrt_lc( L_tmp, &exp1 ); L_tmp = Mult_32_16( L_tmp, sqrt_inv_lag ); -#ifdef BASOP_NOGLOB Ltemp = L_shl_sat( L_tmp, sub( exp1, 12 ) ); /*Q3 */ -#else - Ltemp = L_shl( L_tmp, sub( exp1, 12 ) ); /*Q3 */ -#endif } -#ifdef BASOP_NOGLOB Gains_fx[i] = round_fx_sat( Ltemp ); -#else - Gains_fx[i] = round_fx( Ltemp ); -#endif + move16(); } Ltemp = L_deposit_l( 0 ); FOR( j = (Word16) ( i * lag ); j < L_FRAME; j++ ) { -#ifdef BASOP_NOGLOB Ltemp = L_mac0_o( Ltemp, in_fx[j], in_fx[j], &Overflow ); /*Q(2*qGain) */ -#else - Ltemp = L_mac0( Ltemp, in_fx[j], in_fx[j] ); /*Q(2*qGain) */ -#endif } /*Gains[i] = (float) sqrt(Gains[i]/(L_FRAME-(lag*i))); */ @@ -516,23 +509,17 @@ void nelp_encoder_fx( L_tmp = L_deposit_h( tmp1 ); L_tmp = Isqrt_lc( L_tmp, &exp1 ); L_tmp = Mult_32_16( L_tmp, sqrt_inv_lframe_lag ); -#ifdef BASOP_NOGLOB Ltemp = L_shl_sat( L_tmp, sub( exp1, 12 ) ); -#else - Ltemp = L_shl( L_tmp, sub( exp1, 12 ) ); -#endif } -#ifdef BASOP_NOGLOB Gains_fx[i] = round_fx_sat( Ltemp ); -#else - Gains_fx[i] = round_fx( Ltemp ); -#endif + move16(); IF( EQ_16( reduce_gains, 1 ) ) { FOR( i = 0; i < 10; i++ ) { Gains_fx[i] = mult( Gains_fx[i], 19661 ); + move16(); } } @@ -563,8 +550,7 @@ void nelp_encoder_fx( L_tmp = L_max( L_tmp, 1 ); exp2 = norm_l( L_tmp ); L_tmp = L_shl( L_tmp, exp2 ); /*15+qEL1-qEL2-exp1+exp2 */ - exp2 = 30 - exp2 - qNelpGain; - move16(); + exp2 = sub( 30, add( exp2, qNelpGain ) ); tmp2 = Log2_norm_lc( L_tmp ); Ltemp1 = Mpy_32_16( exp2, tmp2, 9864 ); /*log(2) in Q13 format = Q0 format */ Ltemp1 = L_sub( Ltemp, Ltemp1 ); /*Q16 */ @@ -587,8 +573,7 @@ void nelp_encoder_fx( L_tmp = L_max( L_tmp, 1 ); exp2 = norm_l( L_tmp ); L_tmp = L_shl( L_tmp, exp2 ); /*15+qEL1-qEL2-exp1+exp2 */ - exp2 = 30 - exp2 - qGain; - move16(); + exp2 = sub( 30, add( exp2, qGain ) ); tmp2 = Log2_norm_lc( L_tmp ); Ltemp1 = Mpy_32_16( exp2, tmp2, 9864 ); /*log(2) in Q13 format = Q0 format */ Ltemp1 = L_sub( Ltemp, Ltemp1 ); /*Q16 */ @@ -641,13 +626,8 @@ void nelp_encoder_fx( IF( e_Noise > 0 ) { -#ifdef BASOP_NOGLOB L_tmp = L_shl_sat( etmp, e_Noise ); /* Result in Q30 */ L_tmp = L_add_sat( 1, L_tmp ); -#else - L_tmp = L_shl( etmp, e_Noise ); /* Result in Q30 */ - L_tmp = L_add( 1, L_tmp ); -#endif exp1 = norm_l( L_tmp ); @@ -670,7 +650,7 @@ void nelp_encoder_fx( } } - IF( exp1 == 31 ) + IF( EQ_16( exp1, 31 ) ) { L_const_1 = 0x7fffffff; move32(); @@ -694,17 +674,13 @@ void nelp_encoder_fx( Ltemp1 = Mult_32_16( l_nelp_gain_mem, fdbck_fx ); /*exp1+qGain-15 */ L_tmp = L_add( L_tmp, Ltemp1 ); L_tmp = L_shr_r( L_tmp, ( exp1 - 15 ) ); -#ifdef BASOP_NOGLOB Gains_fx[i] = round_fx_sat( L_shl_sat( L_tmp, 16 ) ); -#else - Gains_fx[i] = round_fx( L_shl( L_tmp, 16 ) ); -#endif move16(); l_nelp_gain_mem = L_tmp; } hSC_VBR->nelp_gain_mem_fx = round_fx( L_shl( l_nelp_gain_mem, 16 ) ); - + move16(); Scale_sig( &hSC_VBR->nelp_gain_mem_fx, 1, -qGain ); Scale_sig( Gains_fx, 10, -qGain ); qGain = 0; @@ -715,8 +691,11 @@ void nelp_encoder_fx( IF( EQ_16( rf_flag, 1 ) ) { hRF->rf_indx_nelp_iG1[0] = iG1_fx; + move16(); hRF->rf_indx_nelp_iG2[0][0] = iG2_fx[0]; + move16(); hRF->rf_indx_nelp_iG2[0][1] = iG2_fx[1]; + move16(); } ELSE { @@ -746,6 +725,7 @@ void nelp_encoder_fx( IF( EQ_16( st_fx->bwidth, WB ) || EQ_16( st_fx->bwidth, SWB ) ) { BP1_ORDER = 4; + move16(); Scale_sig( hSC_VBR->bp1_filt_mem_wb_fx, BP1_ORDER * 2, qGain - hSC_VBR->qprevGain_fx ); /*qf-qAdj */ pz_filter_sp_fx( bp1_num_coef_wb_fx, bp1_den_coef_wb_fx, ptr_fx, ptr_tmp_fx, hSC_VBR->bp1_filt_mem_wb_fx, BP1_ORDER, BP1_ORDER, L_FRAME, 2 ); Copy( ptr_tmp_fx, ptr_fx, L_FRAME ); @@ -760,21 +740,18 @@ void nelp_encoder_fx( Scale_sig( ptr_fx, L_FRAME, -1 ); /* bring exc to qgain-1 */ *qIn1 = qGain - 1; /* use this temp only in the parent */ + move16(); } E3_fx = L_deposit_l( 0 ); FOR( i = 0; i < L_FRAME; i++ ) { -#ifdef BASOP_NOGLOB E3_fx = L_mac_sat( E3_fx, ptr_fx[i], ptr_fx[i] ); /*Q1 */ -#else - E3_fx = L_mac( E3_fx, ptr_fx[i], ptr_fx[i] ); /*Q1 */ -#endif } qE3 = 2 * qGain + 1; move16(); test(); - IF( st_fx->bwidth == WB || EQ_16( st_fx->bwidth, SWB ) ) + IF( EQ_16( st_fx->bwidth, WB ) || EQ_16( st_fx->bwidth, SWB ) ) { Scale_sig( hSC_VBR->shape1_filt_mem_fx, 10, ( qGain - hSC_VBR->qprevGain_fx ) ); pz_filter_sp_fx( shape1_num_coef_fx, shape1_den_coef_fx, ptr_fx, ptr_tmp_fx, hSC_VBR->shape1_filt_mem_fx, 10, 10, L_FRAME, 1 ); /*1 = (16-qformat of shape1 cofficient) */ @@ -831,11 +808,8 @@ void nelp_encoder_fx( { Ltemp = L_mult0( R_fx, ptr_fx[i] ); Ltemp = L_shr_r( Ltemp, exp1 ); -#ifdef BASOP_NOGLOB filtRes_fx[i] = round_fx_sat( L_shl_sat( Ltemp, 16 ) ); -#else - filtRes_fx[i] = round_fx( L_shl( Ltemp, 16 ) ); -#endif + move16(); } qf1 = qGain; @@ -850,11 +824,7 @@ void nelp_encoder_fx( EL2_fx = L_deposit_l( 0 ); FOR( i = 0; i < L_FRAME; i++ ) { -#ifdef BASOP_NOGLOB EL2_fx = L_mac0_sat( EL2_fx, filtRes_fx[i], filtRes_fx[i] ); /*Q(2*qEL2) */ -#else - EL2_fx = L_mac0( EL2_fx, filtRes_fx[i], filtRes_fx[i] ); /*Q(2*qEL2) */ -#endif } qEL2 = 2 * qEL2; move16(); @@ -863,11 +833,8 @@ void nelp_encoder_fx( { Ltemp = L_mult0( R_fx, ptr_fx[i] ); Ltemp = L_shr_r( Ltemp, exp1 ); -#ifdef BASOP_NOGLOB filtRes_fx[i] = round_fx_sat( L_shl_sat( Ltemp, 16 ) ); -#else - filtRes_fx[i] = round_fx( L_shl( Ltemp, 16 ) ); -#endif + move16(); } qf = qGain; @@ -882,11 +849,7 @@ void nelp_encoder_fx( EH2_fx = L_deposit_l( 0 ); FOR( i = 0; i < L_FRAME; i++ ) { -#ifdef BASOP_NOGLOB EH2_fx = L_mac0_sat( EH2_fx, filtRes_fx[i], filtRes_fx[i] ); /*Q(2*qEH2) */ -#else - EH2_fx = L_mac0( EH2_fx, filtRes_fx[i], filtRes_fx[i] ); /*Q(2*qEH2) */ -#endif } qEH2 = 2 * qEH2; move16(); @@ -894,15 +857,10 @@ void nelp_encoder_fx( { exp2 = norm_l( EL1_fx ); L_tmp = L_shl( EL1_fx, exp2 ); - exp2 = 30 - exp2 - qEL1; - move16(); + exp2 = sub( 30, add( exp2, qEL1 ) ); tmp1 = Log2_norm_lc( L_tmp ); - Ltemp = Mpy_32_16( exp2, tmp1, 9864 ); /*10*log(2) in Q15 format = Q0 format */ -#ifdef BASOP_NOGLOB + Ltemp = Mpy_32_16( exp2, tmp1, 9864 ); /*10*log(2) in Q15 format = Q0 format */ tmp1 = round_fx_sat( L_shl_sat( Ltemp, 12 ) ); /* Q12 */ -#else - tmp1 = round_fx( L_shl( Ltemp, 12 ) ); /* Q12 */ -#endif RL_fx = L_mult0( tmp1, 10 ); } ELSE @@ -913,16 +871,11 @@ void nelp_encoder_fx( L_tmp = Mult_32_16( EL1_fx, tmp1 ); /*qEL1+30-qEL2-exp1-15=>15+qE1-qEL2-exp1 */ exp2 = norm_l( L_tmp ); - L_tmp = L_shl( L_tmp, exp2 ); /*15+qEL1-qEL2-exp1+exp2 */ - exp2 = 30 - ( 30 + qEL1 - qEL2 - exp1 + exp2 ); - move16(); + L_tmp = L_shl( L_tmp, exp2 ); /*15+qEL1-qEL2-exp1+exp2 */ + exp2 = sub( add( qEL2, exp1 ), add( qEL1, exp2 ) ); /*30 - ( 30 + qEL1 - qEL2 - exp1 + exp2 )*/ tmp1 = Log2_norm_lc( L_tmp ); - Ltemp = Mpy_32_16( exp2, tmp1, 9864 ); /*10*log(2) in Q15 format = Q0 format */ -#ifdef BASOP_NOGLOB + Ltemp = Mpy_32_16( exp2, tmp1, 9864 ); /*10*log(2) in Q15 format = Q0 format */ tmp1 = round_fx_sat( L_shl_sat( Ltemp, 12 ) ); /* Q12 */ -#else - tmp1 = round_fx( L_shl( Ltemp, 12 ) ); /* Q12 */ -#endif RL_fx = L_mult0( tmp1, 10 ); } @@ -930,15 +883,10 @@ void nelp_encoder_fx( { exp2 = norm_l( EH2_fx ); L_tmp = L_shl( EH2_fx, exp2 ); - exp2 = 30 - exp2 - qEH2; - move16(); + exp2 = sub( 30, add( exp2, qEH2 ) ); tmp1 = Log2_norm_lc( L_tmp ); - Ltemp = Mpy_32_16( exp2, tmp1, 9864 ); /*10*log(2) in Q13 format = Q0 format */ -#ifdef BASOP_NOGLOB + Ltemp = Mpy_32_16( exp2, tmp1, 9864 ); /*10*log(2) in Q13 format = Q0 format */ tmp1 = round_fx_sat( L_shl_sat( Ltemp, 12 ) ); /* Q12 */ -#else - tmp1 = round_fx( L_shl( Ltemp, 12 ) ); /* Q12 */ -#endif RH_fx = L_mult0( tmp1, 10 ); } ELSE @@ -949,16 +897,11 @@ void nelp_encoder_fx( L_tmp = Mult_32_16( EH1_fx, tmp1 ); /*15+qEH1-qEH2-exp1 */ exp2 = norm_l( L_tmp ); - L_tmp = L_shl( L_tmp, exp2 ); /*15+qEH1-qEH2-exp1+exp2 */ - exp2 = 30 - ( 30 + qEH1 - qEH2 - exp1 + exp2 ); - move16(); + L_tmp = L_shl( L_tmp, exp2 ); /*15+qEH1-qEH2-exp1+exp2 */ + exp2 = sub( add( qEH2, exp1 ), add( qEH1, exp2 ) ); /*30 - ( 30 + qEH1 - qEH2 - exp1 + exp2 )*/ tmp1 = Log2_norm_lc( L_tmp ); - Ltemp = Mpy_32_16( exp2, tmp1, 9864 ); /*10*log(2) in Q13 format = Q0 format */ -#ifdef BASOP_NOGLOB + Ltemp = Mpy_32_16( exp2, tmp1, 9864 ); /*10*log(2) in Q13 format = Q0 format */ tmp1 = round_fx_sat( L_shl_sat( Ltemp, 12 ) ); /* Q12 */ -#else - tmp1 = round_fx( L_shl( Ltemp, 12 ) ); /* Q12 */ -#endif RH_fx = L_mult0( tmp1, 10 ); } @@ -1051,12 +994,11 @@ void nelp_encoder_fx( L_tmp = Mult_32_16( E2_fx, tmp1 ); /*qE2+30-qE3-exp1-15=>15+qE2-qE3-exp1 */ exp2 = norm_l( L_tmp ); - L_tmp = L_shl( L_tmp, exp2 ); /*15+qE2-qE3-exp1+exp2 */ - exp2 = 30 - ( 15 + qE2 - qE3 - exp1 + exp2 ); - move16(); - L_tmp = Isqrt_lc( L_tmp, &exp2 ); /*Q(31+exp2) */ + L_tmp = L_shl( L_tmp, exp2 ); /*15+qE2-qE3-exp1+exp2 */ + exp2 = add( 15, sub( add( qE3, exp1 ), add( qE2, exp2 ) ) ); /*30 - ( 15 + qE2 - qE3 - exp1 + exp2 )*/ + L_tmp = Isqrt_lc( L_tmp, &exp2 ); /*Q(31+exp2) */ R_fx = round_fx( L_tmp ); - exp1 = 31 - exp2 - 16 - 7; + exp1 = sub( 8, exp2 ); /*31 - exp2 - 16 - 7*/ move16(); } @@ -1065,6 +1007,7 @@ void nelp_encoder_fx( L_tmp = L_mult0( R_fx, ptr_fx[i] ); L_tmp = L_shr_r( L_tmp, exp1 + 1 ); ptr_fx[i] = round_fx( L_shl( L_tmp, 16 ) ); + move16(); } *qIn1 = qGain - 1; move16(); @@ -1202,7 +1145,7 @@ void nelp_encoder_ivas_fx( IF( NE_16( hSC_VBR->last_nelp_mode, 1 ) ) { test(); - IF( st_fx->bwidth == WB || EQ_16( st_fx->bwidth, SWB ) ) + IF( EQ_16( st_fx->bwidth, WB ) || EQ_16( st_fx->bwidth, SWB ) ) { set16_fx( hSC_VBR->shape1_filt_mem_fx, 0, 10 ); set16_fx( hSC_VBR->shape2_filt_mem_fx, 0, 10 ); @@ -1227,11 +1170,7 @@ void nelp_encoder_ivas_fx( E1_fx = L_deposit_l( 0 ); FOR( i = 0; i < L_FRAME; i++ ) { -#ifdef BASOP_NOGLOB E1_fx = L_mac0_o( E1_fx, in_fx[i], in_fx[i], &Overflow ); /*Q(qE1+qE1) */ -#else - E1_fx = L_mac0( E1_fx, in_fx[i], in_fx[i] ); /*Q(qE1+qE1) */ -#endif } qE1 = shl( qE1, 1 ); @@ -1246,11 +1185,7 @@ void nelp_encoder_ivas_fx( EL1_fx = L_deposit_l( 0 ); FOR( i = 0; i < L_FRAME; i++ ) { -#ifdef BASOP_NOGLOB EL1_fx = L_mac0_o( EL1_fx, filtRes_fx[i], filtRes_fx[i], &Overflow ); /*Q(2*qIn) */ -#else - EL1_fx = L_mac0( EL1_fx, filtRes_fx[i], filtRes_fx[i] ); /*Q(2*qIn) */ -#endif } qEL1 = shl( qEL1, 1 ); @@ -1266,11 +1201,7 @@ void nelp_encoder_ivas_fx( EH1_fx = L_deposit_l( 0 ); FOR( i = 0; i < L_FRAME; i++ ) { -#ifdef BASOP_NOGLOB EH1_fx = L_mac0_o( EH1_fx, filtRes_fx[i], filtRes_fx[i], &Overflow ); /*Q(2*qEH1) */ -#else - EH1_fx = L_mac0( EH1_fx, filtRes_fx[i], filtRes_fx[i] ); /*Q(2*qEH1) */ -#endif } qEH1 = shl( qEH1, 1 ); move16(); @@ -1279,18 +1210,13 @@ void nelp_encoder_ivas_fx( qGain = qIn; move16(); qGain = shl( qGain, 1 ); - move16(); FOR( i = 0; i < 9; i++ ) { Ltemp = L_deposit_l( 0 ); FOR( j = (Word16) ( i * lag ); j < (Word16) ( ( i + 1 ) * lag ); j++ ) { -#ifdef BASOP_NOGLOB Ltemp = L_mac0_o( Ltemp, in_fx[j], in_fx[j], &Overflow ); /*Q(2*qGain) */ -#else - Ltemp = L_mac0( Ltemp, in_fx[j], in_fx[j] ); /*Q(2*qGain) */ -#endif } /*Gains[i] = (float) sqrt(Gains[i]/lag); */ @@ -1304,17 +1230,9 @@ void nelp_encoder_ivas_fx( L_tmp = L_deposit_h( tmp1 ); L_tmp = Isqrt_lc( L_tmp, &exp1 ); L_tmp = Mult_32_16( L_tmp, sqrt_inv_lag ); -#ifdef BASOP_NOGLOB Ltemp = L_shl_sat( L_tmp, sub( exp1, 12 ) ); /*Q3 */ -#else - Ltemp = L_shl( L_tmp, sub( exp1, 12 ) ); /*Q3 */ -#endif } -#ifdef BASOP_NOGLOB Gains_fx[i] = round_fx_sat( Ltemp ); -#else - Gains_fx[i] = round_fx( Ltemp ); -#endif move16(); } @@ -1322,11 +1240,7 @@ void nelp_encoder_ivas_fx( Ltemp = L_deposit_l( 0 ); FOR( j = i_mult( i, lag ); j < L_FRAME; j++ ) { -#ifdef BASOP_NOGLOB Ltemp = L_mac0_o( Ltemp, in_fx[j], in_fx[j], &Overflow ); /*Q(2*qGain) */ -#else - Ltemp = L_mac0( Ltemp, in_fx[j], in_fx[j] ); /*Q(2*qGain) */ -#endif } /*Gains[i] = (float) sqrt(Gains[i]/(L_FRAME-(lag*i))); */ @@ -1340,18 +1254,10 @@ void nelp_encoder_ivas_fx( L_tmp = L_deposit_h( tmp1 ); L_tmp = Isqrt_lc( L_tmp, &exp1 ); L_tmp = Mult_32_16( L_tmp, sqrt_inv_lframe_lag ); -#ifdef BASOP_NOGLOB Ltemp = L_shl_sat( L_tmp, sub( exp1, 12 ) ); -#else - Ltemp = L_shl( L_tmp, sub( exp1, 12 ) ); -#endif } -#ifdef BASOP_NOGLOB Gains_fx[i] = round_fx_sat( Ltemp ); -#else - Gains_fx[i] = round_fx( Ltemp ); -#endif move16(); IF( EQ_16( reduce_gains, 1 ) ) @@ -1464,13 +1370,8 @@ void nelp_encoder_ivas_fx( IF( e_Noise > 0 ) { -#ifdef BASOP_NOGLOB L_tmp = L_shl_sat( etmp, e_Noise ); /* Result in Q30 */ L_tmp = L_add_sat( 1, L_tmp ); -#else - L_tmp = L_shl( etmp, e_Noise ); /* Result in Q30 */ - L_tmp = L_add( 1, L_tmp ); -#endif exp1 = norm_l( L_tmp ); @@ -1517,11 +1418,7 @@ void nelp_encoder_ivas_fx( Ltemp1 = Mult_32_16( l_nelp_gain_mem, fdbck_fx ); /*exp1+qGain-15 */ L_tmp = L_add( L_tmp, Ltemp1 ); L_tmp = L_shr_r( L_tmp, ( exp1 - 15 ) ); -#ifdef BASOP_NOGLOB Gains_fx[i] = round_fx_sat( L_shl_sat( L_tmp, 16 ) ); -#else - Gains_fx[i] = round_fx( L_shl( L_tmp, 16 ) ); -#endif move16(); l_nelp_gain_mem = L_tmp; } @@ -1593,11 +1490,7 @@ void nelp_encoder_ivas_fx( E3_fx = L_deposit_l( 0 ); FOR( i = 0; i < L_FRAME; i++ ) { -#ifdef BASOP_NOGLOB E3_fx = L_mac_sat( E3_fx, ptr_fx[i], ptr_fx[i] ); /*Q1 */ -#else - E3_fx = L_mac( E3_fx, ptr_fx[i], ptr_fx[i] ); /*Q1 */ -#endif } qE3 = add( shl( qGain, 1 ), 1 ); @@ -1656,11 +1549,7 @@ void nelp_encoder_ivas_fx( { Ltemp = L_mult0( R_fx, ptr_fx[i] ); Ltemp = L_shr_r( Ltemp, exp1 ); -#ifdef BASOP_NOGLOB filtRes_fx[i] = round_fx_sat( L_shl_sat( Ltemp, 16 ) ); -#else - filtRes_fx[i] = round_fx( L_shl( Ltemp, 16 ) ); -#endif move16(); } @@ -1676,11 +1565,7 @@ void nelp_encoder_ivas_fx( EL2_fx = L_deposit_l( 0 ); FOR( i = 0; i < L_FRAME; i++ ) { -#ifdef BASOP_NOGLOB EL2_fx = L_mac0_sat( EL2_fx, filtRes_fx[i], filtRes_fx[i] ); /*Q(2*qEL2) */ -#else - EL2_fx = L_mac0( EL2_fx, filtRes_fx[i], filtRes_fx[i] ); /*Q(2*qEL2) */ -#endif } qEL2 = shl( qEL2, 1 ); @@ -1688,11 +1573,7 @@ void nelp_encoder_ivas_fx( { Ltemp = L_mult0( R_fx, ptr_fx[i] ); Ltemp = L_shr_r( Ltemp, exp1 ); -#ifdef BASOP_NOGLOB filtRes_fx[i] = round_fx_sat( L_shl_sat( Ltemp, 16 ) ); -#else - filtRes_fx[i] = round_fx( L_shl( Ltemp, 16 ) ); -#endif move16(); } @@ -1708,11 +1589,7 @@ void nelp_encoder_ivas_fx( EH2_fx = L_deposit_l( 0 ); FOR( i = 0; i < L_FRAME; i++ ) { -#ifdef BASOP_NOGLOB EH2_fx = L_mac0_sat( EH2_fx, filtRes_fx[i], filtRes_fx[i] ); /*Q(2*qEH2) */ -#else - EH2_fx = L_mac0( EH2_fx, filtRes_fx[i], filtRes_fx[i] ); /*Q(2*qEH2) */ -#endif } qEH2 = shl( qEH2, 1 ); IF( EL2_fx == 0 ) @@ -1721,12 +1598,8 @@ void nelp_encoder_ivas_fx( L_tmp = L_shl( EL1_fx, exp2 ); exp2 = sub( sub( 30, exp2 ), qEL1 ); tmp1 = Log2_norm_lc( L_tmp ); - Ltemp = Mpy_32_16( exp2, tmp1, 9864 ); /*10*log(2) in Q15 format = Q0 format */ -#ifdef BASOP_NOGLOB + Ltemp = Mpy_32_16( exp2, tmp1, 9864 ); /*10*log(2) in Q15 format = Q0 format */ tmp1 = round_fx_sat( L_shl_sat( Ltemp, 12 ) ); /* Q12 */ -#else - tmp1 = round_fx( L_shl( Ltemp, 12 ) ); /* Q12 */ -#endif RL_fx = L_mult0( tmp1, 10 ); } ELSE @@ -1740,12 +1613,8 @@ void nelp_encoder_ivas_fx( L_tmp = L_shl( L_tmp, exp2 ); /*15+qEL1-qEL2-exp1+exp2 */ exp2 = sub( 30, add( sub( sub( add( 30, qEL1 ), qEL2 ), exp1 ), exp2 ) ); tmp1 = Log2_norm_lc( L_tmp ); - Ltemp = Mpy_32_16( exp2, tmp1, 9864 ); /*10*log(2) in Q15 format = Q0 format */ -#ifdef BASOP_NOGLOB + Ltemp = Mpy_32_16( exp2, tmp1, 9864 ); /*10*log(2) in Q15 format = Q0 format */ tmp1 = round_fx_sat( L_shl_sat( Ltemp, 12 ) ); /* Q12 */ -#else - tmp1 = round_fx( L_shl( Ltemp, 12 ) ); /* Q12 */ -#endif RL_fx = L_mult0( tmp1, 10 ); } @@ -1755,12 +1624,8 @@ void nelp_encoder_ivas_fx( L_tmp = L_shl( EH2_fx, exp2 ); exp2 = sub( sub( 30, exp2 ), qEH2 ); tmp1 = Log2_norm_lc( L_tmp ); - Ltemp = Mpy_32_16( exp2, tmp1, 9864 ); /*10*log(2) in Q13 format = Q0 format */ -#ifdef BASOP_NOGLOB + Ltemp = Mpy_32_16( exp2, tmp1, 9864 ); /*10*log(2) in Q13 format = Q0 format */ tmp1 = round_fx_sat( L_shl_sat( Ltemp, 12 ) ); /* Q12 */ -#else - tmp1 = round_fx( L_shl( Ltemp, 12 ) ); /* Q12 */ -#endif RH_fx = L_mult0( tmp1, 10 ); } ELSE @@ -1774,12 +1639,8 @@ void nelp_encoder_ivas_fx( L_tmp = L_shl( L_tmp, exp2 ); /*15+qEH1-qEH2-exp1+exp2 */ exp2 = sub( 30, add( 30, add( sub( sub( qEH1, qEH2 ), exp1 ), exp2 ) ) ); tmp1 = Log2_norm_lc( L_tmp ); - Ltemp = Mpy_32_16( exp2, tmp1, 9864 ); /*10*log(2) in Q13 format = Q0 format */ -#ifdef BASOP_NOGLOB + Ltemp = Mpy_32_16( exp2, tmp1, 9864 ); /*10*log(2) in Q13 format = Q0 format */ tmp1 = round_fx_sat( L_shl_sat( Ltemp, 12 ) ); /* Q12 */ -#else - tmp1 = round_fx( L_shl( Ltemp, 12 ) ); /* Q12 */ -#endif RH_fx = L_mult0( tmp1, 10 ); } @@ -1884,8 +1745,10 @@ void nelp_encoder_ivas_fx( L_tmp = L_mult0( R_fx, ptr_fx[i] ); L_tmp = L_shr_r( L_tmp, exp1 + 1 ); ptr_fx[i] = round_fx( L_shl( L_tmp, 16 ) ); + move16(); } *qIn1 = sub( qGain, 1 ); + move16(); } IF( EQ_16( rf_flag, 1 ) ) diff --git a/lib_enc/nois_est.c b/lib_enc/nois_est.c deleted file mode 100644 index 370e0aeef76d707062c56fbeca491edfb15a05aa..0000000000000000000000000000000000000000 --- a/lib_enc/nois_est.c +++ /dev/null @@ -1,46 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "prot.h" -#include "wmc_auto.h" - -/*-----------------------------------------------------------------* - * Local constants - *-----------------------------------------------------------------*/ diff --git a/lib_enc/nois_est_fx.c b/lib_enc/nois_est_fx.c index baf825e711e0d58d716e417c672083b5a9705f31..27a48652a07dcd277d616cfc00505ccc8f88bbbf 100644 --- a/lib_enc/nois_est_fx.c +++ b/lib_enc/nois_est_fx.c @@ -90,13 +90,10 @@ static Word16 noise_est_ln_q8_fx( Word32 L_tmp; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif -#ifdef BASOP_NOGLOB L_tmp = L_add_o( L_enr, L_shl( (Word32) 1L, q_new_plus_q_scale ), &Overflow ); /* +1.0f */ -#else /* BASOP_NOGLOB */ - L_tmp = L_add( L_enr, L_shl( (Word32) 1L, q_new_plus_q_scale ) ); /* +1.0f */ -#endif /* BASOP_NOGLOB */ if ( flag_add1p0 == 0 ) { L_tmp = L_add( L_enr, 0 ); /* +0 , no offset */ @@ -192,7 +189,6 @@ void noise_est_init_fx( hNoiseEst->ave_enr_q = Q7; move16(); - move16(); hNoiseEst->totalNoise_fx = 0; move16(); hNoiseEst->first_noise_updt = 0; @@ -221,7 +217,8 @@ void noise_est_init_fx( hNoiseEst->Etot_st_est_fx = 5120; /* 20.0f in Q8 */ hNoiseEst->Etot_sq_st_est_fx = 1600; /* 400 in Q2 */ - //### + move16(); + move16(); hNoiseEst->epsP_0_2_lp_fx = 4096; /*1.0 Q12*/ move16(); @@ -248,7 +245,7 @@ void noise_est_init_fx( hNoiseEst->noise_char_fx = 0; move16(); hNoiseEst->multi_harm_limit_fx = THR_CORR_INIT_FX; - + move16(); hNoiseEst->Etot_lp_fx = 0; hNoiseEst->Etot_h_fx = 0; hNoiseEst->Etot_l_fx = 0; @@ -275,12 +272,17 @@ void noise_est_init_ivas_fx( #ifdef IVAS_FLOAT_FIXED_CONVERSIONS hNoiseEst->first_noise_updt = 0; hNoiseEst->first_noise_updt_cnt = 0; - + move16(); + move16(); hNoiseEst->aEn = 6; hNoiseEst->aEn_inac_cnt = 0; hNoiseEst->harm_cor_cnt = 0; hNoiseEst->bg_cnt = 0; hNoiseEst->low_tn_track_cnt = 0; + move16(); + move16(); + move16(); + move16(); #endif FOR( i = 0; i < NB_BANDS; i++ ) { @@ -335,8 +337,8 @@ void noise_est_init_ivas_fx( hNoiseEst->Etot_st_est_fx = 5120; /* 20.0f in Q8 */ hNoiseEst->Etot_sq_st_est_fx = 1600; /* 400 in Q2 */ - //### - + move16(); + move16(); hNoiseEst->epsP_0_2_lp_fx = 4096; /*1.0 Q12*/ move16(); hNoiseEst->epsP_0_2_ad_lp_fx = 0; @@ -362,7 +364,7 @@ void noise_est_init_ivas_fx( hNoiseEst->noise_char_fx = 0; move16(); hNoiseEst->multi_harm_limit_fx = THR_CORR_INIT_FX; - + move16(); hNoiseEst->Etot_lp_fx = 0; hNoiseEst->Etot_h_fx = 0; hNoiseEst->Etot_l_fx = 0; @@ -387,12 +389,12 @@ void noise_est_init_ivas_fx( *-----------------------------------------------------------------*/ void noise_est_pre_fx( - const Word16 Etot, /* i : Energy of current frame */ - const Word16 ini_frame_fx, /* i : Frame number (init) */ - NOISE_EST_HANDLE hNoiseEst, /* i/o: Noise estimation handle */ - const int16_t idchan, /* i : channel ID */ - const int16_t element_mode, /* i : element mode */ - const int16_t last_element_mode /* i : last element mode */ + const Word16 Etot, /* i : Energy of current frame */ + const Word16 ini_frame_fx, /* i : Frame number (init) */ + NOISE_EST_HANDLE hNoiseEst, /* i/o: Noise estimation handle */ + const Word16 idchan, /* i : channel ID */ + const Word16 element_mode, /* i : element mode */ + const Word16 last_element_mode /* i : last element mode */ ) { Word16 tmp; @@ -459,7 +461,8 @@ void noise_est_pre_fx( } hNoiseEst->Etot_l_fx = s_min( hNoiseEst->Etot_l_fx, Etot ); - + move16(); + test(); IF( LT_16( ini_frame_fx, 100 ) && LT_16( hNoiseEst->Etot_l_fx, hNoiseEst->Etot_l_lp_fx ) ) { /**Etot_l_lp = 0.1f * *Etot_l + (1.0f - 0.1) * *Etot_l_lp; */ @@ -482,10 +485,12 @@ void noise_est_pre_fx( { /* *Etot_l_lp = 0.02f * *Etot_l + (1.0f - 0.02f) * *Etot_l_lp; */ hNoiseEst->Etot_l_lp_fx = round_fx( L_mac( L_mult( 655, hNoiseEst->Etot_l_fx ), 32113, hNoiseEst->Etot_l_lp_fx ) ); + move16(); } } /**sign_dyn_lp = 0.1f * (*Etot_h - *Etot_l) + (1.0f - 0.1f) * *sign_dyn_lp;*/ hNoiseEst->sign_dyn_lp_fx = round_fx( L_mac( L_mult( 3277, sub_sat( hNoiseEst->Etot_h_fx, hNoiseEst->Etot_l_fx ) ), 29491, hNoiseEst->sign_dyn_lp_fx ) ); + move16(); } return; @@ -671,11 +676,7 @@ void noise_est_down_fx( totalNoise_temp = L_deposit_l( 0 ); FOR( i = min_band; i <= max_band; i++ ) { -#ifdef BASOP_NOGLOB totalNoise_temp = L_add_o( totalNoise_temp, bckr[i], &Overflow ); /*Q_new+QSCALE*/ -#else - totalNoise_temp = L_add( totalNoise_temp, bckr[i] ); /*Q_new+QSCALE*/ -#endif } totalNoise_temp = L_max( totalNoise_temp, L_shl( e_min, 4 ) ); @@ -689,7 +690,7 @@ void noise_est_down_fx( e_Noise = sub( e_Noise, scale ); Ltmp = Mpy_32_16( e_Noise, f_Noise, LG10 ); *totalNoise = round_fx( L_shl( Ltmp, 10 ) ); /*Q8*/ - + move16(); /*-----------------------------------------------------------------* * Average energy per frame for each frequency band *-----------------------------------------------------------------*/ @@ -699,11 +700,7 @@ void noise_est_down_fx( FOR( i = 0; i < NB_BANDS; i++ ) { -#ifdef BASOP_NOGLOB Ltmp = L_add_o( L_shr_r( *pt1, 1 ), L_shr_r( *pt2, 1 ), &Overflow ); -#else /* BASOP_NOGLOB */ - Ltmp = L_add( L_shr_r( *pt1, 1 ), L_shr_r( *pt2, 1 ) ); -#endif /* BASOP_NOGLOB */ /*Ltmp = L_shr_r(L_add(*pt1,*pt2),1);*/ enr[i] = Ltmp; move32(); /*Q_new+QSCALE*/ @@ -722,7 +719,7 @@ void noise_est_down_fx( tmpN[i] = Madd_32_16( L_tmp, bckr[i], ALPHAM1_FX ); move32(); /*Q_new+QSCALE*/ tmpN[i] = L_max( tmpN[i], e_min ); /* handle div by zero in find_tilt_fx */ - + 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 ); @@ -741,10 +738,10 @@ void noise_est_down_fx( L_tmp = Mult_32_16( L_Etot_v, 655 ); /*.02 in Q15 , Q24+Q15+1 -16 ==> Q24 ) */ *Etot_v_h2 = round_fx( L_add( L_Etot_v_h2, L_tmp ) ); /*Q24->Q8*/ - + move16(); /* if (*Etot_v_h2 < 0.1f) { *Etot_v_h2 = 0.1f; } */ *Etot_v_h2 = s_max( *Etot_v_h2, 26 ); /* 0.1 in Q8*/ - + move16(); return; } @@ -957,6 +954,7 @@ void noise_est_fx( GSC_ENC_HANDLE hGSCEnc = st_fx->hGSCEnc; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif /*-----------------------------------------------------------------* @@ -970,7 +968,7 @@ void noise_est_fx( IF( hFrontVad == NULL ) #endif { - if ( hSpMusClas != NULL ) + IF( hSpMusClas != NULL ) { Ltmp = L_shr( lf_E[0], 3 ); FOR( i = 1; i < 8; i++ ) @@ -980,6 +978,7 @@ void noise_est_fx( IF( LT_32( Ltmp, L_shl( 1, add( Q_new, Q_SCALE - 2 ) ) ) ) { hSpMusClas->ener_RAT_fx = 0; + move16(); // PMT("hSpMusClas->ener_RAT_fx = 0, that should be validated") } ELSE @@ -1001,9 +1000,10 @@ void noise_est_fx( { hSpMusClas->ener_RAT_fx = 32767; move16(); /*Q15*/ - if ( GE_16( wtmp1, wtmp ) ) + IF( GE_16( wtmp1, wtmp ) ) { hSpMusClas->ener_RAT_fx = div_s( wtmp, wtmp1 ); /*Q15*/ /* wtmp1 gte than wtmp */ + move16(); } } } @@ -1017,7 +1017,7 @@ void noise_est_fx( * order" spectral envelope => the epsP ratio is much less effective. *-----------------------------------------------------------------*/ - IF( NE_16( vad_bwidth_fx, NB ) ) /* WB input */ + IF( vad_bwidth_fx != NB ) /* WB input */ { th_eps = TH_EPS16_FX; move16(); /*Q11*/ @@ -1053,13 +1053,8 @@ void noise_est_fx( Ltmp = L_deposit_h( corr_shift ); Ltmp = L_mac( Ltmp, st_fx->voicing_fx[0], 10923 ); -#ifdef BASOP_NOGLOB Ltmp = L_mac_o( Ltmp, st_fx->voicing_fx[1], 10923, &Overflow ); wtmp = mac_ro( Ltmp, st_fx->voicing_fx[2], 10923, &Overflow ); -#else /* BASOP_NOGLOB */ - Ltmp = L_mac( Ltmp, st_fx->voicing_fx[1], 10923 ); - wtmp = mac_r( Ltmp, st_fx->voicing_fx[2], 10923 ); -#endif /* BASOP_NOGLOB */ tmp_pc = pc; move16(); @@ -1069,7 +1064,7 @@ void noise_est_fx( move16(); /* low correlation -> probably inactive signal */ } - move16(); /* Update */ + /* Update */ /*-----------------------------------------------------------------* * Multi-harmonic analysis @@ -1084,6 +1079,7 @@ void noise_est_fx( move16(); *loc_harm = multi_harm_fx( EspecdB, hNoiseEst->old_S_fx, hNoiseEst->cor_map_fx, &hNoiseEst->multi_harm_limit_fx, st_fx->total_brate, st_fx->bwidth, ( st_fx->hGSCEnc != NULL ) ? &hGSCEnc->cor_strong_limit : &i, &hSpMusClas->mean_avr_dyn_fx, &hSpMusClas->last_sw_dyn_fx, cor_map_sum, sp_floor, S_map ); + move16(); } } /*-----------------------------------------------------------------* @@ -1113,11 +1109,7 @@ void noise_est_fx( FOR( i = 10; i <= st_fx->max_band; i++ ) { Lnum = L_max( *pt1, *pt2 ); /* Don't need if anymore */ -#ifdef BASOP_NOGLOB Lsum_den = L_add_o( Lsum_den, Lnum, &Overflow ); -#else /* BASOP_NOGLOB */ - Lsum_den = L_add( Lsum_den, Lnum ); -#endif /* BASOP_NOGLOB */ Ltmpden = L_min( *pt1, *pt2 ); if ( Ltmpden == 0 ) { @@ -1173,11 +1165,7 @@ void noise_est_fx( /* calculation of energy in the rest of bands */ Ltmp2 = sum32_fx( &fr_bands[10], sub( st_fx->max_band, 9 ) ); -#ifdef BASOP_NOGLOB wtmp = shl_o( 1, sub( add( Q_new, QSCALE ), 1 ), &Overflow ); -#else /* BASOP_NOGLOB */ - wtmp = shl( 1, sub( add( Q_new, QSCALE ), 1 ) ); -#endif /* BASOP_NOGLOB */ #ifdef IVAS_CODE IF( ncharX != NULL ) { @@ -1199,11 +1187,7 @@ void noise_est_fx( ExpDen = norm_l( Ltmp ); den = extract_h( L_shl( Ltmp, ExpDen ) ); num = div_s( num, den ); -#ifdef BASOP_NOGLOB noise_chartmp = extract_h( L_shr_o( num, add( sub( ExpNum, ExpDen ), 4 - 16 ), &Overflow ) ); /* Q11 */ -#else /* BASOP_NOGLOB */ - noise_chartmp = extract_h( L_shr( num, add( sub( ExpNum, ExpDen ), 4 - 16 ) ) ); /* Q11 */ -#endif /* BASOP_NOGLOB */ } noise_chartmp = s_min( noise_chartmp, (Word16) 10 << 11 ); /* Q11 */ @@ -1215,7 +1199,7 @@ void noise_est_fx( nchar_thr = THR_NCHAR_WB_FX; move16(); /* 1.0 Q11 */ - if ( EQ_16( vad_bwidth_fx, NB ) ) + if ( vad_bwidth_fx == NB ) { nchar_thr = THR_NCHAR_NB_FX; move16(); /* 1.0 Q11 */ @@ -1244,13 +1228,9 @@ void noise_est_fx( tmp = s_max( relE, 0 ); /* Q8 */ /* alpha = 0.064f * ftemp + 0.75f; */ - Ltmp = Mult_32_16( (Word32) 137438953L, tmp ); /* Q31(.064)+Q8+1-16 --> Q24 */ - Ltmp = L_mac( Ltmp, 256, 24576 ); /* Q8+Q15(.75)+1 --> Q24 */ -#ifdef BASOP_NOGLOB + Ltmp = Mult_32_16( (Word32) 137438953L, tmp ); /* Q31(.064)+Q8+1-16 --> Q24 */ + Ltmp = L_mac( Ltmp, 256, 24576 ); /* Q8+Q15(.75)+1 --> Q24 */ alpha = round_fx_o( L_shl_o( Ltmp, 7, &Overflow ), &Overflow ); /*Q24 +7 --> Q31 Q15*/ -#else /* BASOP_NOGLOB */ - alpha = round_fx( L_shl( Ltmp, 7 ) ); /*Q24 +7 --> Q31 Q15*/ -#endif /* BASOP_NOGLOB */ /*if( alpha > 0.999f { alpha = 0.999f;} */ alpha = s_min( alpha, 32735 ); /*.999 in Q15*/ @@ -1285,14 +1265,9 @@ void noise_est_fx( /* + 1.0f added to reduce sensitivity to non stationarity in low energies */ /* tmp_enr = enr[i] + 1.0f; */ tmp_Q = add( Q_new, Q_SCALE ); - Ltmp = L_shl( (Word32) 1L, tmp_Q ); /* 1.0 added in the right dynamic domain */ -#ifdef BASOP_NOGLOB + Ltmp = L_shl( (Word32) 1L, tmp_Q ); /* 1.0 added in the right dynamic domain */ L_tmp_enr = L_add_o( enr[i], Ltmp, &Overflow ); /* enr scale dynamic */ L_tmp_ave_enr = L_add_o( hNoiseEst->ave_enr_fx[i], Ltmp, &Overflow ); /* ave__enr scale dynamic */ -#else /* BASOP_NOGLOB */ - L_tmp_enr = L_add( enr[i], Ltmp ); /* enr scale dynamic */ - L_tmp_ave_enr = L_add( hNoiseEst->ave_enr_fx[i], Ltmp ); /* ave__enr scale dynamic */ -#endif /* BASOP_NOGLOB */ IF( LE_32( non_sta, th_sta ) ) /* Just to limit the saturation */ { @@ -1311,11 +1286,7 @@ void noise_est_fx( den = extract_h( L_shl( Lden, ExpDen ) ); num = div_s( num, den ); Ltmp = Mult_32_16( non_sta, num ); -#ifdef BASOP_NOGLOB non_sta = L_shr_o( Ltmp, sub( ExpNum, ExpDen ), &Overflow ); /* Q10 */ -#else /* BASOP_NOGLOB */ - non_sta = L_shr( Ltmp, sub( ExpNum, ExpDen ) ); /* Q10 */ -#endif /* BASOP_NOGLOB */ } /* st->ave_enr[i] = alpha * st->ave_enr[i] + (1-alpha) * enr[i];*/ /* update long-term average */ @@ -1335,14 +1306,10 @@ void noise_est_fx( } */ /* ave_enr2:: calculation of another non-stationarity measure (following attacks) */ - Ltmp = L_shl( (Word32) 1L, tmp_Q ); /* 1.0 added in the right dynamic domain */ - /*L_tmp_enr = L_add(enr[i] , Ltmp );*/ /* enr scale dynamic , done above */ -#ifdef BASOP_NOGLOB + Ltmp = L_shl( (Word32) 1L, tmp_Q ); /* 1.0 added in the right dynamic domain */ + /*L_tmp_enr = L_add(enr[i] , Ltmp );*/ /* enr scale dynamic , done above */ L_tmp_ave_enr2 = L_add_o( hNoiseEst->ave_enr2_fx[i], Ltmp, &Overflow ); /* ave__enr scale dynamic */ -#else - L_tmp_ave_enr2 = L_add( hNoiseEst->ave_enr2_fx[i], Ltmp ); /* ave__enr scale dynamic */ -#endif - IF( LE_32( Lnon_sta2, th_sta ) ) /* Just to limit the saturation */ + IF( LE_32( Lnon_sta2, th_sta ) ) /* Just to limit the saturation */ { Lnum = L_max( L_tmp_enr, L_tmp_ave_enr2 ); Lden = L_min( L_tmp_enr, L_tmp_ave_enr2 ); @@ -1354,11 +1321,7 @@ void noise_est_fx( den = extract_h( L_shl( Lden, ExpDen ) ); num = div_s( num, den ); Ltmp1 = Mult_32_16( Lnon_sta2, num ); -#ifdef BASOP_NOGLOB Lnon_sta2 = L_shr_o( Ltmp1, sub( ExpNum, ExpDen ), &Overflow ); /* Q10 */ -#else /* BASOP_NOGLOB */ - Lnon_sta2 = L_shr( Ltmp1, sub( ExpNum, ExpDen ) ); /* Q10 */ -#endif /* BASOP_NOGLOB */ } /* st_ave_enr2[i] = (float)alpha2 * st_ave_enr2[i] @@ -1380,16 +1343,13 @@ void noise_est_fx( /* log_enr = (float)ln_fx(enr[i]); */ log_enr16 = noise_est_ln_q8_fx( enr[i], 0, tmp_Q ); wtmp = abs_s( sub( log_enr16, hSpMusClas->past_log_enr_fx[i - START_BAND_SPMUS] ) ); -#ifdef BASOP_NOGLOB *non_staX = add_o( *non_staX, wtmp, &Overflow ); -#else /* BASOP_NOGLOB */ - *non_staX = add( *non_staX, wtmp ); -#endif /* BASOP_NOGLOB */ move16(); /* Q8 */ hSpMusClas->past_log_enr_fx[i - START_BAND_SPMUS] = log_enr16; move16(); } } + test(); IF( GE_16( i, 2 ) && LE_16( i, 16 ) ) { IF( GE_16( ini_frame, 100 ) ) @@ -1399,11 +1359,7 @@ void noise_est_fx( tmp_floor = LN_E_MIN_PLUS_ONE_FX; move16(); /* non dynamic init constant in Q8 */ tmp_floor = noise_est_ln_q8_fx( hNoiseEst->bckr_fx[i], 1, tmp_Q ); -#ifdef BASOP_NOGLOB non_staB = add_o( non_staB, abs_s( sub( tmp_enr, tmp_floor ) ), &Overflow ); /* Q8 */ -#else /* BASOP_NOGLOB */ - non_staB = add( non_staB, abs_s( sub( tmp_enr, tmp_floor ) ) ); /* Q8 */ -#endif /* BASOP_NOGLOB */ } ELSE /*ini_frame < 100*/ { @@ -1412,11 +1368,7 @@ void noise_est_fx( tmp_floor = LN_E_MIN_PLUS_ONE_FX; move16(); /* non dynamic init constant in Q8 */ tmp_floor = noise_est_ln_q8_fx( E_MIN_FX, 1, tmp_Q ); -#ifdef BASOP_NOGLOB non_staB = add_o( non_staB, abs_s( sub( tmp_enr, tmp_floor ) ), &Overflow ); /* Q8 */ -#else /* BASOP_NOGLOB */ - non_staB = add( non_staB, abs_s( sub( tmp_enr, tmp_floor ) ) ); /* Q8 */ -#endif /* BASOP_NOGLOB */ } } @@ -1431,7 +1383,7 @@ void noise_est_fx( lim_Etot_fx = s_max( 5120, Etot ); /* 20.0f Q8 */ lim_Etot_sq_fx = extract_h( L_shl_r( L_mult( lim_Etot_fx, lim_Etot_fx ), 1 ) ); /* Q2 */ - if ( st_fx->ini_frame < 150 ) + IF( LT_16( st_fx->ini_frame, 150 ) ) { /* Allow use of quicker filter during init - if needed */ /* st->Etot_st_est = 0.25f * lim_Etot + (1.0f-0.25F) * st->Etot_st_est; */ @@ -1441,7 +1393,7 @@ void noise_est_fx( hNoiseEst->Etot_sq_st_est_fx = mac_r( L_mult( 8192, lim_Etot_sq_fx ), 24576, hNoiseEst->Etot_sq_st_est_fx ); move16(); } - else + ELSE { /* st->Etot_st_est = 0.25f * lim_Etot + (1.0f-0.25F) * st->Etot_st_est; */ hNoiseEst->Etot_st_est_fx = mac_r( L_mult( 8192, lim_Etot_fx ), 24576, hNoiseEst->Etot_st_est_fx ); @@ -1464,20 +1416,24 @@ void noise_est_fx( test(); test(); *st_harm_cor_cnt = add( *st_harm_cor_cnt, 1 ); + move16(); if ( ( Etot > 0 ) && ( ( *loc_harm > 0 ) || ( GT_16( round_fx( Ltmp ), COR_MAX_NNE_FX ) ) ) ) { *st_harm_cor_cnt = 0; move16(); } - - IF( ( GT_16( *st_harm_cor_cnt, 1 ) ) && ( ( LT_16( Etot, 3840 ) ) || /* 15 in Q8 */ - ( GT_16( st_fx->ini_frame, 10 ) && - GT_16( sub( Etot, hNoiseEst->Etot_lp_fx ), 1792 ) ) ) /* 7 in Q8 */ + test(); + test(); + test(); + if ( ( GT_16( *st_harm_cor_cnt, 1 ) ) && ( ( LT_16( Etot, 3840 ) ) || /* 15 in Q8 */ + ( GT_16( st_fx->ini_frame, 10 ) && + GT_16( sub( Etot, hNoiseEst->Etot_lp_fx ), 1792 ) ) ) /* 7 in Q8 */ ) { *st_harm_cor_cnt = 1; } - + test(); + test(); if ( GT_16( *st_harm_cor_cnt, 1 ) && GT_16( Etot, 7680 ) && /* 30.0f in Q8 */ GT_16( st_E_var_est_fx, 32 ) /* 8.0f in Q2 */ @@ -1486,6 +1442,7 @@ void noise_est_fx( /* st->harm_cor_cnt = max(1, (short) round_f( (float) st->harm_cor_cnt / 4.0f )) ; */ *st_harm_cor_cnt = s_max( 1, shr( add( *st_harm_cor_cnt, 2 ), 1 ) ); + move16(); } @@ -1521,13 +1478,9 @@ void noise_est_fx( /*epsP_0_2 = max(0 , min(8, epsP[0] / epsP[2])); */ Ltmp = eps_quota_fx( epsP_h[0], epsP_l[0], - epsP_h[2], epsP_l[2], 12 ); /* Word32 Q12 */ - BASOP_SATURATE_WARNING_OFF_EVS /* may saturate*/ -#ifdef BASOP_NOGLOB + epsP_h[2], epsP_l[2], 12 ); /* Word32 Q12 */ + BASOP_SATURATE_WARNING_OFF_EVS /* may saturate*/ epsP_0_2 = round_fx_o( L_shl_o( Ltmp, 16, &Overflow ), &Overflow ); /* Q12+16 -16 -> Q12 , NB saturation in Q12 sets max value to 7,999 */ -#else /* BASOP_NOGLOB */ - epsP_0_2 = round_fx( L_shl( Ltmp, 16 ) ); /* Q12+16 -16 -> Q12 , NB saturation in Q12 sets max value to 7,999 */ -#endif /* BASOP_NOGLOB */ BASOP_SATURATE_WARNING_ON_EVS epsP_0_2 = s_max( 0, epsP_0_2 ); /* min value is 0 , Q12 */ @@ -1537,7 +1490,7 @@ void noise_est_fx( alpha = 4915; move16(); /*0.15 in Q15 */ hNoiseEst->epsP_0_2_lp_fx = noise_est_AR1_Qx( epsP_0_2, hNoiseEst->epsP_0_2_lp_fx, alpha ); - + move16(); /* epsP_0_2_ad = (float) fabs(epsP_0_2 - st->epsP_0_2_lp ); */ epsP_0_2_ad = abs_s( sub( epsP_0_2, hNoiseEst->epsP_0_2_lp_fx ) ); /* Q12 */ @@ -1553,7 +1506,7 @@ void noise_est_fx( alpha = shr( alpha, 1 ); /* 0.1 Q15 */ } hNoiseEst->epsP_0_2_ad_lp_fx = noise_est_AR1_Qx( epsP_0_2_ad, hNoiseEst->epsP_0_2_ad_lp_fx, alpha ); - + move16(); /* epsP_0_2_ad_lp_max = max(epsP_0_2_ad,st->epsP_0_2_ad_lp);*/ epsP_0_2_ad_lp_max = s_max( epsP_0_2_ad, hNoiseEst->epsP_0_2_ad_lp_fx ); /* Q12 */ @@ -1564,15 +1517,10 @@ void noise_est_fx( /* epsP_2_16 = max(0 , min(8, epsP[2] / epsP[16])); */ Ltmp = eps_quota_fx( epsP_h[2], epsP_l[2], - epsP_h[16], epsP_l[16], 12 ); /* Word32 Q12 */ - BASOP_SATURATE_WARNING_OFF_EVS /* may saturate*/ -#ifdef BASOP_NOGLOB + epsP_h[16], epsP_l[16], 12 ); /* Word32 Q12 */ + BASOP_SATURATE_WARNING_OFF_EVS /* may saturate*/ epsP_2_16 = round_fx_o( L_shl_o( Ltmp, 16, &Overflow ), &Overflow ); /* Q12+16 -16 -> Q12 , NB saturation in Q12 sets max value to 7,999 */ -#else /* BASOP_NOGLOB */ - epsP_2_16 = round_fx( L_shl( Ltmp, 16 ) ); /* Q12+16 -16 -> Q12 , - NB saturation in Q12 sets max value to 7,999 */ -#endif /* BASOP_NOGLOB */ BASOP_SATURATE_WARNING_ON_EVS epsP_2_16 = s_max( 0, epsP_2_16 ); /* min value is 0 , Q12 */ @@ -1594,9 +1542,9 @@ void noise_est_fx( move16(); /* 0.2 Q15 */ } hNoiseEst->epsP_2_16_lp_fx = noise_est_AR1_Qx( epsP_2_16, hNoiseEst->epsP_2_16_lp_fx, alpha ); - + move16(); hNoiseEst->epsP_2_16_lp2_fx = noise_est_AR1_Qx( epsP_2_16, hNoiseEst->epsP_2_16_lp2_fx, 655 ); /* 0.02 */ - + move16(); epsP_2_16_dlp = sub( hNoiseEst->epsP_2_16_lp_fx, hNoiseEst->epsP_2_16_lp2_fx ); @@ -1613,7 +1561,7 @@ void noise_est_fx( move16(); /* 0.02 Q15 */ } hNoiseEst->epsP_2_16_dlp_lp2_fx = noise_est_AR1_Qx( epsP_2_16_dlp, hNoiseEst->epsP_2_16_dlp_lp2_fx, alpha ); - + move16(); /* epsP_2_16_dlp_max = max(epsP_2_16_dlp,st->epsP_2_16_dlp_lp2); */ epsP_2_16_dlp_max = s_max( epsP_2_16_dlp, hNoiseEst->epsP_2_16_dlp_lp2_fx ); @@ -1631,14 +1579,14 @@ void noise_est_fx( move16(); } hNoiseEst->lt_tn_track_fx = noise_est_AR1_Qx( tmp2, hNoiseEst->lt_tn_track_fx, 983 ); /*0.03 in Q15 ,Q15 state*/ - + move16(); /* st->lt_tn_dist = 0.03f* (Etot - st->totalNoise) + 0.97f*st->lt_tn_dist; */ hNoiseEst->lt_tn_dist_fx = noise_est_AR1_Qx( tmp, hNoiseEst->lt_tn_dist_fx, 983 ); /*0.03 in Q15 ,Q8 state*/ - + move16(); /* st->lt_Ellp_dist = 0.03f* (Etot - st->Etot_l_lp) + 0.97f*st->lt_Ellp_dist;*/ tmp = sub( Etot, hNoiseEst->Etot_l_lp_fx ); /* Q8 */ hNoiseEst->lt_Ellp_dist_fx = noise_est_AR1_Qx( tmp, hNoiseEst->lt_Ellp_dist_fx, 983 ); /*0.03 in Q15 ,Q8 state*/ - + move16(); /* if (st->harm_cor_cnt == 0) { st->lt_haco_ev = 0.03f*1.0 + 0.97f*st->lt_haco_ev; @@ -1653,7 +1601,7 @@ void noise_est_fx( { hNoiseEst->lt_haco_ev_fx = mult_r( 32440, hNoiseEst->lt_haco_ev_fx ); /*.99 in Q15 , Q15 state */ } - + move16(); /* if (st->lt_tn_track < 0.05f) { st->low_tn_track_cnt++; @@ -1694,11 +1642,7 @@ void noise_est_fx( *-----------------------------------------------------------------*/ Ltmp = L_mult( st_fx->voicing_fx[0], 16384 ); Ltmp = L_mac( Ltmp, st_fx->voicing_fx[1], 16384 ); -#ifdef BASOP_NOGLOB cor_tmp = mac_ro( Ltmp, corr_shift, MAX_16, &Overflow ); -#else /* BASOP_NOGLOB */ - cor_tmp = mac_r( Ltmp, corr_shift, MAX_16 ); -#endif LepsP = eps_quota_fx( epsP_h[2], epsP_l[2], epsP_h[16], epsP_l[16], 11 ); /* L_epsP in Q11 */ @@ -1777,15 +1721,15 @@ void noise_est_fx( ( ( hNoiseEst->act_pred > 0.8f ) && ( non_sta2 > th_sta ) ) ) { /* active signal present - increment counter */ - hStereoClassif->aEn_raw[st->idchan] = hStereoClassif->aEn_raw[st->idchan] + 2; + hStereoClassif->aEn_raw[st->idchan] = add( hStereoClassif->aEn_raw[st->idchan], 2 ); } else { /* background noise present - decrement counter */ - hStereoClassif->aEn_raw[st->idchan] = hStereoClassif->aEn_raw[st->idchan] - 1; + hStereoClassif->aEn_raw[st->idchan] = sub( hStereoClassif->aEn_raw[st->idchan], 1 ); } - if ( hStereoClassif->aEn_raw[st->idchan] > 6 ) + if ( GT_16( hStereoClassif->aEn_raw[st->idchan], 6 ) ) { hStereoClassif->aEn_raw[st->idchan] = 6; } @@ -2031,13 +1975,20 @@ void noise_est_fx( test(); test(); test(); - if ( ( ( LT_16( hNoiseEst->act_pred_fx, 19333 ) ) && ( LT_16( hNoiseEst->lt_haco_ev_fx, 7537 ) ) ) /* .59 in Q15 .23 in Q15 */ - || ( LT_16( hNoiseEst->act_pred_fx, 12452 ) ) /* .38 in Q15 */ - || ( ( EQ_16( st_fx->element_mode, EVS_MONO ) && LT_16( hNoiseEst->lt_haco_ev_fx, 4915 ) ) || ( GT_16( st_fx->element_mode, EVS_MONO ) && LT_16( hNoiseEst->lt_haco_ev_fx, 2621 ) ) ) /* .15 in Q15 || 0.08 */ - || ( LT_16( non_staB, 50 * 256 ) ) /* 50.0 in Q8 */ - || aE_bgd != 0 || ( ( LT_16( Etot, 10752 ) ) /* 42 in Q8 */ - && ( GT_16( hNoiseEst->harm_cor_cnt, 10 ) ) && ( LT_16( hNoiseEst->lt_haco_ev_fx, 11469 ) ) /* 0.35 in Q15 */ - && ( LT_16( hNoiseEst->act_pred_fx, 26214 ) ) /* 0.80 in Q15 */ + test(); + test(); + test(); + test(); + test(); + test(); + test(); + if ( ( ( LT_16( hNoiseEst->act_pred_fx, 19333 ) ) && ( LT_16( hNoiseEst->lt_haco_ev_fx, 7537 ) ) ) /* .59 in Q15 .23 in Q15 */ + || ( LT_16( hNoiseEst->act_pred_fx, 12452 ) ) /* .38 in Q15 */ + || ( ( st_fx->element_mode == EVS_MONO && LT_16( hNoiseEst->lt_haco_ev_fx, 4915 ) ) || ( st_fx->element_mode > EVS_MONO && LT_16( hNoiseEst->lt_haco_ev_fx, 2621 ) ) ) /* .15 in Q15 || 0.08 */ + || ( LT_16( non_staB, 50 * 256 ) ) /* 50.0 in Q8 */ + || aE_bgd != 0 || ( ( LT_16( Etot, 10752 ) ) /* 42 in Q8 */ + && ( GT_16( hNoiseEst->harm_cor_cnt, 10 ) ) && ( LT_16( hNoiseEst->lt_haco_ev_fx, 11469 ) ) /* 0.35 in Q15 */ + && ( LT_16( hNoiseEst->act_pred_fx, 26214 ) ) /* 0.80 in Q15 */ ) ) { tmp = 1; @@ -2048,6 +1999,7 @@ void noise_est_fx( move16(); test(); test(); + test(); if ( ( LT_16( st_fx->ini_frame, HE_LT_CNT_INIT_FX ) ) && ( GT_16( hNoiseEst->harm_cor_cnt, 5 ) ) /* > 5 Q0 */ && ( LT_16( sub( Etot, hNoiseEst->Etot_lp_fx ), 1792 ) ) /* 7 in Q8 */ && ( NE_16( tmp, 0 ) ) ) @@ -2120,8 +2072,6 @@ void noise_est_fx( test(); test(); test(); - test(); - test(); IF( ( ( LT_16( hNoiseEst->act_pred_fx, 27853 ) ) /* 0.85 in Q15 */ && ( NE_16( aE_bgd, 0 ) ) && ( ( LT_16( hNoiseEst->lt_Ellp_dist_fx, 10 * 256 ) ) || ( NE_16( sd1_bgd, 0 ) ) ) /* 10.0 in Q8*/ && ( LT_16( hNoiseEst->lt_tn_dist_fx, 40 * 256 ) ) /* 40.0 in Q8*/ @@ -2136,6 +2086,7 @@ void noise_est_fx( updt_step = 32767; move16(); hNoiseEst->first_noise_updt = 1; + move16(); FOR( i = 0; i < NB_BANDS; i++ ) { hNoiseEst->bckr_fx[i] = tmpN[i]; @@ -2205,6 +2156,7 @@ void noise_est_fx( ELSE IF( ( aE_bgd != 0 ) || ( GT_16( hNoiseEst->harm_cor_cnt, 100 ) ) ) { hNoiseEst->first_noise_updt = add( hNoiseEst->first_noise_updt, 1 ); + move16(); } } ELSE @@ -2237,15 +2189,17 @@ void noise_est_fx( move16(); } hNoiseEst->lt_aEn_zero_fx = noise_est_AR1_Qx( tmp, hNoiseEst->lt_aEn_zero_fx, 6554 ); /* alpha=0.2 , Q15 */ + move16(); } #ifdef IVAS_CODE - IF( GT_16( st_fx->element_mode, EVS_MONO ) ) + IF( st_fx->element_mode > EVS_MONO ) { test(); - if ( hNoiseEst->first_noise_updt_cnt_fx > 0 && LT_16( hNoiseEst->first_noise_updt_cnt_fx, 100 ) ) + IF( hNoiseEst->first_noise_updt_cnt_fx > 0 && LT_16( hNoiseEst->first_noise_updt_cnt_fx, 100 ) ) { hNoiseEst->first_noise_updt_cnt_fx = add( hNoiseEst->first_noise_updt_cnt_fx, 1 ); + move16(); } } #endif @@ -2453,13 +2407,8 @@ void noise_est_ivas_fx( Ltmp = L_deposit_h( corr_shift ); Ltmp = L_mac( Ltmp, st_fx->voicing_fx[0], 10923 ); -#ifdef BASOP_NOGLOB Ltmp = L_mac_o( Ltmp, st_fx->voicing_fx[1], 10923, &Overflow ); wtmp = mac_ro( Ltmp, st_fx->voicing_fx[2], 10923, &Overflow ); -#else /* BASOP_NOGLOB */ - Ltmp = L_mac( Ltmp, st_fx->voicing_fx[1], 10923 ); - wtmp = mac_r( Ltmp, st_fx->voicing_fx[2], 10923 ); -#endif /* BASOP_NOGLOB */ tmp_pc = pc; move16(); @@ -2469,7 +2418,7 @@ void noise_est_ivas_fx( move16(); /* low correlation -> probably inactive signal */ } - move16(); /* Update */ + /* Update */ /*-----------------------------------------------------------------* * Multi-harmonic analysis @@ -2604,12 +2553,8 @@ void noise_est_ivas_fx( ELSE { /* ftemp2 /= ftemp */ - num = div_s( extract_h( Ltmp2 ), extract_h( Ltmp ) ); // 15+exp2-exp -#ifdef BASOP_NOGLOB + num = div_s( extract_h( Ltmp2 ), extract_h( Ltmp ) ); // 15+exp2-exp noise_chartmp = shl_o( num, sub( sub( exp, exp2 ), 4 ), &Overflow ); // 15+exp2-exp1 -> Q11 -#else - noise_chartmp = shl( num, sub( sub( exp, exp2 ), 4 ) ); // 15+exp2-exp1 -> Q11 -#endif } if ( ncharX != NULL ) @@ -2675,11 +2620,7 @@ void noise_est_ivas_fx( /* alpha = 0.064f * ftemp + 0.75f; */ Ltmp = Madd_32_16( 12582912 /* 0.75 in Q24*/, 137438953, tmp ); // Q24 -#ifdef BASOP_NOGLOB alpha = round_fx_o( L_shl_o( Ltmp, 7, &Overflow ), &Overflow ); /*Q24 +7 --> Q31 Q15*/ -#else /* BASOP_NOGLOB */ - alpha = round_fx( L_shl( Ltmp, 7 ) ); /*Q24 +7 --> Q31 Q15*/ -#endif /* BASOP_NOGLOB */ /*if( alpha > 0.999f { alpha = 0.999f;} */ alpha = s_min( alpha, 32735 ); /*.999 in Q15*/ @@ -2741,13 +2682,9 @@ void noise_est_ivas_fx( ExpDen = norm_l( Lden ); den = extract_h( L_shl( Lden, ExpDen ) ); // q_enr+ExpDen-16 - num = div_s( num, den ); // 15+ExpNum-ExpDen - Ltmp1 = Mult_32_16( non_sta, num ); // 15+ExpNum-ExpDen+10-15 -#ifdef BASOP_NOGLOB + num = div_s( num, den ); // 15+ExpNum-ExpDen + Ltmp1 = Mult_32_16( non_sta, num ); // 15+ExpNum-ExpDen+10-15 non_sta = L_shr_o( Ltmp1, sub( ExpNum, ExpDen ), &Overflow ); /* Q10 */ -#else /* BASOP_NOGLOB */ - non_sta = L_shr( Ltmp1, sub( ExpNum, ExpDen ) ); /* Q10 */ -#endif /* BASOP_NOGLOB */ } /* st->ave_enr[i] = alpha * st->ave_enr[i] + (1-alpha) * enr[i];*/ /* update long-term average */ @@ -2784,13 +2721,9 @@ void noise_est_ivas_fx( ExpDen = norm_l( Lden ); den = extract_h( L_shl( Lden, ExpDen ) ); // q_enr+ExpDen-16 - num = div_s( num, den ); // 15+ExpNum-ExpDen - Ltmp1 = Mult_32_16( Lnon_sta2, num ); // 15+ExpNum-ExpDen+10-15 -#ifdef BASOP_NOGLOB + num = div_s( num, den ); // 15+ExpNum-ExpDen + Ltmp1 = Mult_32_16( Lnon_sta2, num ); // 15+ExpNum-ExpDen+10-15 Lnon_sta2 = L_shr_o( Ltmp1, sub( ExpNum, ExpDen ), &Overflow ); /* Q10 */ -#else /* BASOP_NOGLOB */ - Lnon_sta2 = L_shr( Ltmp1, sub( ExpNum, ExpDen ) ); /* Q10 */ -#endif /* BASOP_NOGLOB */ } /* st_ave_enr2[i] = (float)alpha2 * st_ave_enr2[i] + (1.0f - alpha2) * (enr[i]) */ @@ -2815,11 +2748,7 @@ void noise_est_ivas_fx( Ltmp1 = Mpy_32_16_1( Ltmp1, 22713 ); // Q15 log_enr16 = round_fx( L_shl( Ltmp1, 9 ) ); /* Q8 */ wtmp = abs_s( sub( log_enr16, hSpMusClas->past_log_enr_fx[i - START_BAND_SPMUS] ) ); -#ifdef BASOP_NOGLOB *non_staX = add_o( *non_staX, wtmp, &Overflow ); -#else /* BASOP_NOGLOB */ - *non_staX = add( *non_staX, wtmp ); -#endif /* BASOP_NOGLOB */ move16(); /* Q8 */ hSpMusClas->past_log_enr_fx[i - START_BAND_SPMUS] = log_enr16; move16(); @@ -2844,11 +2773,7 @@ void noise_est_ivas_fx( IF( LT_16( ini_frame, 100 ) ) { -#ifdef BASOP_NOGLOB non_staB = add_o( non_staB, abs_s( sub( tmp_enr, LN_E_MIN_PLUS_ONE_FX ) ), &Overflow ); /* Q8 */ -#else /* BASOP_NOGLOB */ - non_staB = add( non_staB, abs_s( sub( tmp_enr, tmp_floor ) ) ); /* Q8 */ -#endif } ELSE /*ini_frame < 100*/ { @@ -2864,11 +2789,7 @@ void noise_est_ivas_fx( Ltmp1 = Mpy_32_16_1( Ltmp1, 22713 ); // Q15 tmp_floor = round_fx( L_shl( Ltmp1, 9 ) ); /* Q8 */ } -#ifdef BASOP_NOGLOB non_staB = add_o( non_staB, abs_s( sub( tmp_enr, tmp_floor ) ), &Overflow ); /* Q8 */ -#else /* BASOP_NOGLOB */ - non_staB = add( non_staB, abs_s( sub( tmp_enr, tmp_floor ) ) ); /* Q8 */ -#endif } } @@ -2883,7 +2804,7 @@ void noise_est_ivas_fx( lim_Etot_fx = s_max( 5120, Etot ); /* 20.0f Q8 */ lim_Etot_sq_fx = extract_h( L_shl_r( L_mult( lim_Etot_fx, lim_Etot_fx ), 1 ) ); /* Q2 */ - IF( LT_16( st_fx->ini_frame, 150 ) ) + IF( LT_16( ini_frame, 150 ) ) { /* Allow use of quicker filter during init - if needed */ /* st->Etot_st_est = 0.25f * lim_Etot + (1.0f-0.25F) * st->Etot_st_est; */ @@ -2927,13 +2848,14 @@ void noise_est_ivas_fx( test(); test(); if ( ( GT_16( *st_harm_cor_cnt, 1 ) ) && ( ( LT_16( Etot, 3840 /* 15 in Q8 */ ) ) || - ( GT_16( st_fx->ini_frame, 10 ) && + ( GT_16( ini_frame, 10 ) && GT_16( sub( Etot, hNoiseEst->Etot_lp_fx ), 1792 /* 7 in Q8 */ ) ) ) ) { *st_harm_cor_cnt = 1; move16(); } - + test(); + test(); IF( GT_16( *st_harm_cor_cnt, 1 ) && GT_16( Etot, 7680 /* 30.0f in Q8 */ ) && GT_16( st_E_var_est_fx, 32 /* 8.0f in Q2 */ ) ) { /* st->harm_cor_cnt = max(1, (short) round_f( (float) st->harm_cor_cnt / 4.0f )) ; */ @@ -3191,7 +3113,7 @@ void noise_est_ivas_fx( test(); test(); IF( ( ( LT_16( *st_harm_cor_cnt, ( 3 * HC_CNT_SLOW_FX ) ) ) && ( ( GT_32( non_sta, th_sta ) ) || ( LT_16( tmp_pc, TH_PC_FX ) ) || ( noise_char > 0 ) ) ) || - ( ( GT_16( st_fx->ini_frame, HE_LT_CNT_INIT_FX ) ) && ( GT_16( sub( Etot, Etot_l_lp ), 2560 ) ) ) || + ( ( GT_16( ini_frame, HE_LT_CNT_INIT_FX ) ) && ( GT_16( sub( Etot, Etot_l_lp ), 2560 ) ) ) || ( GT_16( cor_tmp, cor_max ) ) || /* Q15 */ ( GT_32( LepsP, th_eps ) ) || /* Q11 */ ( GT_16( *loc_harm, 0 ) ) || @@ -3497,7 +3419,7 @@ void noise_est_ivas_fx( test(); test(); test(); - if ( LT_16( st_fx->ini_frame, HE_LT_CNT_INIT_FX ) && GT_16( hNoiseEst->harm_cor_cnt, 5 ) && LT_16( sub( Etot, hNoiseEst->Etot_lp_fx ), 1792 /* 7 in Q8 */ ) && + if ( LT_16( ini_frame, HE_LT_CNT_INIT_FX ) && GT_16( hNoiseEst->harm_cor_cnt, 5 ) && LT_16( sub( Etot, hNoiseEst->Etot_lp_fx ), 1792 /* 7 in Q8 */ ) && ( ( LT_16( hNoiseEst->act_pred_fx, 19333 /* 0.59 in Q15 */ ) && LT_16( hNoiseEst->lt_haco_ev_fx, 7537 /* 0.23 in Q15 */ ) ) || LT_16( hNoiseEst->act_pred_fx, 12452 /* 0.38 in Q15 */ ) || ( ( ( st_fx->element_mode == EVS_MONO ) && LT_16( hNoiseEst->lt_haco_ev_fx, 4915 /* 0.15 in Q15 */ ) ) || ( ( st_fx->element_mode > EVS_MONO ) && LT_16( hNoiseEst->lt_haco_ev_fx, 2621 /* 0.08 in Q15 */ ) ) ) || LT_16( non_staB, 50 * 256 /* 50 in Q8 */ ) || ( aE_bgd != 0 ) || ( LT_16( Etot, 10752 /* 42.0 in Q8 */ ) && GT_16( hNoiseEst->harm_cor_cnt, 10 ) && LT_16( hNoiseEst->lt_haco_ev_fx, 11469 /* 0.35 in Q8 */ ) && LT_16( hNoiseEst->act_pred_fx, 26214 /* 0.8 in Q8 */ ) ) ) ) @@ -3672,7 +3594,7 @@ void noise_est_ivas_fx( IF( st_fx->element_mode > EVS_MONO ) { test(); - if ( hNoiseEst->first_noise_updt > 0 && LT_16( hNoiseEst->first_noise_updt_cnt, 100 ) ) + IF( hNoiseEst->first_noise_updt > 0 && LT_16( hNoiseEst->first_noise_updt_cnt, 100 ) ) { hNoiseEst->first_noise_updt_cnt = add( hNoiseEst->first_noise_updt_cnt, 1 ); move16(); diff --git a/lib_enc/noise_adjust.c b/lib_enc/noise_adjust.c deleted file mode 100644 index d441f6ead49ddcb3a6a1ffab0962633db8157cd0..0000000000000000000000000000000000000000 --- a/lib_enc/noise_adjust.c +++ /dev/null @@ -1,43 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "rom_com.h" -#include "prot.h" -#include "wmc_auto.h" diff --git a/lib_enc/normalizecoefs.c b/lib_enc/normalizecoefs.c deleted file mode 100644 index 8f0950fbae8f9f2c626e0122b0369502d15bcff1..0000000000000000000000000000000000000000 --- a/lib_enc/normalizecoefs.c +++ /dev/null @@ -1,47 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "rom_com.h" -#include "prot.h" -#include "wmc_auto.h" - -/*-------------------------------------------------------------------------- - * normalizecoefs() - * - * Normalize MDCT coefficients with quantized norms - *--------------------------------------------------------------------------*/ diff --git a/lib_enc/normalizecoefs_fx.c b/lib_enc/normalizecoefs_fx.c index f6f5eedee7a031fce359b4471da4a17cf0aa892c..ea394f54bd29ca2e04f9320d4a5196335a727b69 100644 --- a/lib_enc/normalizecoefs_fx.c +++ b/lib_enc/normalizecoefs_fx.c @@ -31,6 +31,7 @@ void normalizecoefs_fx( Word16 subvec_start, subvec_end, num_coefs; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move16(); #endif pcoefs = coefs; pcoefs16 = coefs_norm; @@ -54,13 +55,8 @@ void normalizecoefs_fx( *pcoefs = Mpy_32_16_1( *pcoefs, INV2POWHALF ); move32(); } -#ifdef BASOP_NOGLOB *pcoefs16++ = round_fx_o( L_shl_o( *pcoefs++, 16 - k, &Overflow ), &Overflow ); /* Q12 */ -#else - BASOP_SATURATE_WARNING_OFF_EVS /* May saturate for strong peaks in a high band, in which case saturation is desirable */ - *pcoefs16++ = round_fx( L_shl( *pcoefs++, 16 - k ) ); /* Q12 */ - BASOP_SATURATE_WARNING_ON_EVS -#endif + move16(); } } diff --git a/lib_enc/peak_vq_enc.c b/lib_enc/peak_vq_enc.c deleted file mode 100644 index 867e40cdc445406ceb1dc5e53245e971abe03b05..0000000000000000000000000000000000000000 --- a/lib_enc/peak_vq_enc.c +++ /dev/null @@ -1,44 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "prot.h" -#include "rom_com.h" -#include "wmc_auto.h" -#include diff --git a/lib_enc/pit_enc_fx.c b/lib_enc/pit_enc_fx.c index c91f34e96c680ae91e98b812a76ea1a192ff8898..3793ee00d82899ddec7774fd6371e670a13bd84a 100644 --- a/lib_enc/pit_enc_fx.c +++ b/lib_enc/pit_enc_fx.c @@ -1572,18 +1572,10 @@ void norm_corr_ivas_fx( conv_fx( &exc[k], h, excf, L_subfr ); /* Compute rounded down 1/sqrt(energy of xn[]) */ -#ifdef BASOP_NOGLOB L_tmp = L_mac_o( 1, xn[0], xn[0], &Overflow ); -#else - L_tmp = L_mac( 1, xn[0], xn[0] ); -#endif FOR( i = 1; i < L_subfr; i++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_mac_o( L_tmp, xn[i], xn[i], &Overflow ); -#else /* BASOP_NOGLOB */ - L_tmp = L_mac( L_tmp, xn[i], xn[i] ); -#endif } exp = norm_l( L_tmp ); exp = sub( 30, exp ); @@ -1602,11 +1594,7 @@ void norm_corr_ivas_fx( L_tmp = L_mac( 1, xn[0], excf[0] ); FOR( i = 1; i < L_subfr; i++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_mac_o( L_tmp, xn[i], excf[i], &Overflow ); -#else - L_tmp = L_mac( L_tmp, xn[i], excf[i] ); -#endif } exp = norm_l( L_tmp ); L_tmp = L_shl( L_tmp, exp ); @@ -1629,13 +1617,8 @@ void norm_corr_ivas_fx( /* Normalize correlation = correlation * (1/sqrt(energy)) */ L_tmp = L_mult( corr, norm ); -#ifdef BASOP_NOGLOB L_tmp = L_shl_sat( L_tmp, add( add( exp_corr, exp_norm ), scale ) ); ncorr[t] = round_fx_sat( L_tmp ); -#else - L_tmp = L_shl( L_tmp, add( add( exp_corr, exp_norm ), scale ) ); - ncorr[t] = round_fx( L_tmp ); -#endif /* update the filtered excitation excf[] for the next iteration */ IF( NE_16( t, t_max ) ) @@ -1645,11 +1628,7 @@ void norm_corr_ivas_fx( { /* saturation can occur in add() */ /*excf[i] = add(mult(exc[k], h[i]), excf[i - 1]); move16(); */ -#ifdef BASOP_NOGLOB excf[i] = round_fx_sat( L_mac_sat( L_mult( excf[i - 1], 32767 ), exc[k], h[i] ) ); -#else - excf[i] = round_fx( L_mac( L_mult( excf[i - 1], 32767 ), exc[k], h[i] ) ); -#endif } excf[0] = mult_r( exc[k], h[0] ); move16(); @@ -1687,18 +1666,10 @@ void norm_corr_fx( conv_fx( &exc[k], h, excf, L_subfr ); /* Compute rounded down 1/sqrt(energy of xn[]) */ -#ifdef BASOP_NOGLOB L_tmp = L_mac_o( 1, xn[0], xn[0], &Overflow ); -#else - L_tmp = L_mac( 1, xn[0], xn[0] ); -#endif FOR( i = 1; i < L_subfr; i++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_mac_o( L_tmp, xn[i], xn[i], &Overflow ); -#else /* BASOP_NOGLOB */ - L_tmp = L_mac( L_tmp, xn[i], xn[i] ); -#endif } exp = norm_l( L_tmp ); exp = sub( 30, exp ); @@ -1717,11 +1688,7 @@ void norm_corr_fx( L_tmp = L_mac( 1, xn[0], excf[0] ); FOR( i = 1; i < L_subfr; i++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_mac_o( L_tmp, xn[i], excf[i], &Overflow ); -#else - L_tmp = L_mac( L_tmp, xn[i], excf[i] ); -#endif } exp = norm_l( L_tmp ); L_tmp = L_shl( L_tmp, exp ); @@ -1732,11 +1699,7 @@ void norm_corr_fx( L_tmp = L_mac( 1, excf[0], excf[0] ); FOR( i = 1; i < L_subfr; i++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_mac_o( L_tmp, excf[i], excf[i], &Overflow ); -#else - L_tmp = L_mac( L_tmp, excf[i], excf[i] ); -#endif } exp = norm_l( L_tmp ); @@ -1748,13 +1711,8 @@ void norm_corr_fx( /* Normalize correlation = correlation * (1/sqrt(energy)) */ L_tmp = L_mult( corr, norm ); -#ifdef BASOP_NOGLOB L_tmp = L_shl_sat( L_tmp, add( add( exp_corr, exp_norm ), scale ) ); ncorr[t] = round_fx_sat( L_tmp ); -#else - L_tmp = L_shl( L_tmp, add( add( exp_corr, exp_norm ), scale ) ); - ncorr[t] = round_fx( L_tmp ); -#endif /* update the filtered excitation excf[] for the next iteration */ IF( NE_16( t, t_max ) ) @@ -1764,11 +1722,7 @@ void norm_corr_fx( { /* saturation can occur in add() */ /*excf[i] = add(mult(exc[k], h[i]), excf[i - 1]); move16(); */ -#ifdef BASOP_NOGLOB excf[i] = round_fx_sat( L_mac_sat( L_mult( excf[i - 1], 32767 ), exc[k], h[i] ) ); -#else - excf[i] = round_fx( L_mac( L_mult( excf[i - 1], 32767 ), exc[k], h[i] ) ); -#endif move16(); } excf[0] = mult_r( exc[k], h[0] ); diff --git a/lib_enc/pitch_ol2.c b/lib_enc/pitch_ol2.c index 05b32c716f172c695f7bc36fc4297784f39c48f3..1ce646476840c491bc6205d31d3cc110101aa032 100644 --- a/lib_enc/pitch_ol2.c +++ b/lib_enc/pitch_ol2.c @@ -96,11 +96,7 @@ void StableHighPitchDetect_ivas_fx( L_tmp = L_mult( voicing[0], 10923 /*1/3 in Q15*/ ); L_tmp = L_mac( L_tmp, voicing[1], 10923 /*1/3 in Q15*/ ); L_tmp = L_mac( L_tmp, voicing[2], 10923 /*1/3 in Q15*/ ); -#ifdef BASOP_NOGLOB voicing_m = round_fx_sat( L_tmp ); -#else - voicing_m = round_fx( L_tmp ); -#endif /**voicing_sm = 0.75f*(*voicing_sm) + 0.25f*voicing;*/ *voicing_sm = round_fx( L_mac( L_mult( *voicing_sm, 24576 /*0.75f Q15*/ ), voicing_m, 8192 /*0.25f Q15*/ ) ); move16(); @@ -149,42 +145,22 @@ void StableHighPitchDetect_ivas_fx( tmp = abs_s( tmp ); tmp = div_s( 16384, tmp ); /*Q(15+exp)*/ BASOP_SATURATE_WARNING_OFF_EVS -#ifdef BASOP_NOGLOB diff = L_negate( L_shr_o( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ), &Overflow ) ); -#else /* BASOP_NOGLOB */ - diff = L_negate( L_shr( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ) ) ); -#endif /* BASOP_NOGLOB */ BASOP_SATURATE_WARNING_ON_EVS -#ifdef BASOP_NOGLOB diff16 = round_fx_o( diff, &Overflow ); -#else /* BASOP_NOGLOB */ - diff16 = round_fx( diff ); -#endif /* BASOP_NOGLOB */ } ELSE { tmp = div_s( 16384, tmp ); /*Q(15+exp)*/ BASOP_SATURATE_WARNING_OFF_EVS -#ifdef BASOP_NOGLOB diff = L_shr_o( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ), &Overflow ); -#else /* BASOP_NOGLOB */ - diff = L_shr( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ) ); -#endif /* BASOP_NOGLOB */ BASOP_SATURATE_WARNING_ON_EVS -#ifdef BASOP_NOGLOB diff16 = round_fx_o( diff, &Overflow ); -#else /* BASOP_NOGLOB */ - diff16 = round_fx( diff ); -#endif /* BASOP_NOGLOB */ } } ELSE { -#ifdef BASOP_NOGLOB diff16 = round_fx_o( L_shl_o( diff, 25, &Overflow ), &Overflow ); -#else - diff16 = round_fx( L_shl( diff, 25 ) ); -#endif } test(); test(); @@ -270,11 +246,7 @@ void StableHighPitchDetect_ivas_fx( L_tmp1 = Isqrt_lc( L_tmp1, &exp ); /*Q(31-exp)*/ cor_max = Mult_32_32( cor_max, L_tmp1 ); exp = add( sub( sub( 31, add( shl( Q_new, 1 ), 1 ) ), sub( 31, exp ) ), 31 ); -#ifdef BASOP_NOGLOB cor_max16 = round_fx_o( L_shl_o( cor_max, exp, &Overflow ), &Overflow ); /*Q15*/ -#else /* BASOP_NOGLOB */ - cor_max16 = round_fx( L_shl( cor_max, exp ) ); /*Q15*/ -#endif /**voicing0_sm = add(mult_r(24576 ,(*voicing0_sm)) , mult_r(8192 , cor_max16));*/ *voicing0_sm = round_fx( L_mac( L_mult( 24576 /*.75f Q15*/, *voicing0_sm ), 8192 /*.25f Q15*/, cor_max16 ) ); move16(); diff --git a/lib_enc/pitch_ol2_fx.c b/lib_enc/pitch_ol2_fx.c index 83ea36b176275ced8b30b9596aac27069f09f4e7..5d68216c934793aa5e0cc6c1d9835d10358e0ec3 100644 --- a/lib_enc/pitch_ol2_fx.c +++ b/lib_enc/pitch_ol2_fx.c @@ -81,13 +81,8 @@ void pitch_ol2_fx( pt_cor_fx = cor_fx; FOR( t = t_min; t <= t_max; t++ ) { -#ifdef BASOP_NOGLOB t0 = L_shl_o( *pt_cor_32++, exp3, &Overflow ); *pt_cor_fx++ = round_fx_o( t0, &Overflow ); -#else - t0 = L_shl( *pt_cor_32++, exp3 ); - *pt_cor_fx++ = round_fx( t0 ); -#endif move16(); } @@ -171,13 +166,8 @@ void pitch_ol2_fx( R2 = L_mult( wsp_fr_fx[0], wsp_fr_fx[0] ); FOR( j = 1; j < L_SUBFR; j++ ) { -#ifdef BASOP_NOGLOB R1 = L_mac_sat( R1, pt_wsp_fx[j], pt_wsp_fx[j] ); R2 = L_mac_sat( R2, wsp_fr_fx[j], wsp_fr_fx[j] ); -#else - R1 = L_mac( R1, pt_wsp_fx[j], pt_wsp_fx[j] ); - R2 = L_mac( R2, wsp_fr_fx[j], wsp_fr_fx[j] ); -#endif } /* *voicing_fr = cor_max * inv_sqrt(enr_wsp * enr_old) */ @@ -191,11 +181,7 @@ void pitch_ol2_fx( exp_R2 = norm_l( R2 ); R2 = L_shl( R2, exp_R2 ); -#ifdef BASOP_NOGLOB R1 = L_mult_o( round_fx_o( R1, &Overflow ), round_fx_o( R2, &Overflow ), &Overflow ); -#else - R1 = L_mult( round_fx( R1 ), round_fx( R2 ) ); -#endif i = norm_l( R1 ); R1 = L_shl( R1, i ); @@ -205,19 +191,11 @@ void pitch_ol2_fx( R1 = Isqrt_lc( R1, &exp_R1 ); -#ifdef BASOP_NOGLOB R1 = L_mult( R0, round_fx_o( R1, &Overflow ) ); -#else - R1 = L_mult( R0, round_fx( R1 ) ); -#endif exp_R0 = sub( 31, exp_R0 ); exp_R0 = sub( add( exp_R0, exp_R1 ), exp3 ); -#ifdef BASOP_NOGLOB *voicing_fr_fx = round_fx_o( L_shl_o( R1, exp_R0, &Overflow ), &Overflow ); /*Q15*/ -#else /* BASOP_NOGLOB */ - *voicing_fr_fx = round_fx( L_shl( R1, exp_R0 ) ); /*Q15*/ -#endif /* BASOP_NOGLOB */ move16(); } ELSE @@ -266,11 +244,7 @@ void StableHighPitchDetect_fx( L_tmp = L_mult( voicing[0], 10923 /*1/3 in Q15*/ ); L_tmp = L_mac( L_tmp, voicing[1], 10923 /*1/3 in Q15*/ ); L_tmp = L_mac( L_tmp, voicing[2], 10923 /*1/3 in Q15*/ ); -#ifdef BASOP_NOGLOB voicing_m = round_fx_sat( L_tmp ); -#else - voicing_m = round_fx( L_tmp ); -#endif /**voicing_sm = 0.75f*(*voicing_sm) + 0.25f*voicing;*/ *voicing_sm = round_fx( L_mac( L_mult( *voicing_sm, 24576 /*0.75f Q15*/ ), voicing_m, 8192 /*0.25f Q15*/ ) ); move16(); @@ -312,42 +286,22 @@ void StableHighPitchDetect_fx( tmp = abs_s( tmp ); tmp = div_s( 16384, tmp ); /*Q(15+exp)*/ BASOP_SATURATE_WARNING_OFF_EVS -#ifdef BASOP_NOGLOB diff = L_negate( L_shr_o( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ), &Overflow ) ); -#else /* BASOP_NOGLOB */ - diff = L_negate( L_shr( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ) ) ); -#endif /* BASOP_NOGLOB */ BASOP_SATURATE_WARNING_ON_EVS -#ifdef BASOP_NOGLOB diff16 = round_fx_o( diff, &Overflow ); -#else /* BASOP_NOGLOB */ - diff16 = round_fx( diff ); -#endif /* BASOP_NOGLOB */ } ELSE { tmp = div_s( 16384, tmp ); /*Q(15+exp)*/ BASOP_SATURATE_WARNING_OFF_EVS -#ifdef BASOP_NOGLOB diff = L_shr_o( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ), &Overflow ); -#else /* BASOP_NOGLOB */ - diff = L_shr( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ) ); -#endif /* BASOP_NOGLOB */ BASOP_SATURATE_WARNING_ON_EVS -#ifdef BASOP_NOGLOB diff16 = round_fx_o( diff, &Overflow ); -#else /* BASOP_NOGLOB */ - diff16 = round_fx( diff ); -#endif /* BASOP_NOGLOB */ } } ELSE { -#ifdef BASOP_NOGLOB diff16 = round_fx_o( L_shl_o( diff, 25, &Overflow ), &Overflow ); -#else - diff16 = round_fx( L_shl( diff, 25 ) ); -#endif } test(); test(); @@ -424,11 +378,7 @@ void StableHighPitchDetect_fx( L_tmp1 = Isqrt_lc( L_tmp1, &exp ); /*Q(31-exp)*/ cor_max = Mult_32_32( cor_max, L_tmp1 ); exp = 31 - ( shl( Q_new, 1 ) + 1 ) - ( 31 - exp ) + 31; -#ifdef BASOP_NOGLOB cor_max16 = round_fx_o( L_shl_o( cor_max, exp, &Overflow ), &Overflow ); /*Q15*/ -#else /* BASOP_NOGLOB */ - cor_max16 = round_fx( L_shl( cor_max, exp ) ); /*Q15*/ -#endif /**voicing0_sm = add(mult_r(24576 ,(*voicing0_sm)) , mult_r(8192 , cor_max16));*/ *voicing0_sm = round_fx( L_mac( L_mult( 24576 /*.75f Q15*/, *voicing0_sm ), 8192 /*.25f Q15*/, cor_max16 ) ); move16(); diff --git a/lib_enc/pitch_ol_fx.c b/lib_enc/pitch_ol_fx.c index 52cd3ad5d93007dc1ff0cca8a09a261bace769fc..91181714af9242f49697b8f221c167f31d525faf 100644 --- a/lib_enc/pitch_ol_fx.c +++ b/lib_enc/pitch_ol_fx.c @@ -737,11 +737,7 @@ void pitch_ol_fx( enr1_exp = 0; move16(); -#ifdef BASOP_NOGLOB enr1 = add_o( extract_h( dotp_fx( pt2, pt2, len[j], &enr1_exp ) ), 1, &Overflow ); -#else - enr1 = add( extract_h( dotp_fx( pt2, pt2, len[j], &enr1_exp ) ), 1 ); -#endif enr2 = L_mult( enr0[j], enr1 ); enr2_exp = norm_l( enr2 ); @@ -755,11 +751,7 @@ void pitch_ol_fx( Ltmp = L_mult0( cor_buf[ind], enr1 ); qCorX = add( sub( 15, enr1_exp ), sub( 14, pt_exp1[ind] ) ); -#ifdef BASOP_NOGLOB corX[i][j] = extract_h( L_shr_o( Ltmp, sub( qCorX, 31 ), &Overflow ) ); -#else /* BASOP_NOGLOB */ - corX[i][j] = extract_h( L_shr( Ltmp, sub( qCorX, 31 ) ) ); -#endif /* BASOP_NOGLOB */ qCorX = 31; move16(); @@ -781,11 +773,7 @@ void pitch_ol_fx( move16(); /* selected moving vector */ enr1_exp = 0; move16(); -#ifdef BASOP_NOGLOB enr1 = add_o( extract_h( dotp_fx( pt4, pt4, len1[j], &enr1_exp ) ), 1, &Overflow ); -#else - enr1 = add( extract_h( dotp_fx( pt4, pt4, len1[j], &enr1_exp ) ), 1 ); -#endif enr2 = L_mult( enr0_1[j], enr1 ); enr2_exp = norm_l( enr2 ); @@ -800,11 +788,7 @@ void pitch_ol_fx( Ltmp = L_mult0( cor_buf[ind1 + len_x], enr1 ); qCorX = add( sub( 15, enr1_exp ), sub( 14, pt_exp3[ind1] ) ); -#ifdef BASOP_NOGLOB corX[i][j + NSECT] = extract_h( L_shr_o( Ltmp, qCorX - 31, &Overflow ) ); -#else /* BASOP_NOGLOB */ - corX[i][j + NSECT] = extract_h( L_shr( Ltmp, qCorX - 31 ) ); -#endif /* BASOP_NOGLOB */ qCorX = 31; move16(); @@ -884,11 +868,7 @@ void pitch_ol_fx( move16(); pitch_tmp[i] = pitchX[i][ind]; move16(); -#ifdef BASOP_NOGLOB cor_tmp[i] = add_o( corX[i][ind], corr_shift, &Overflow ); -#else /* BASOP_NOGLOB */ - cor_tmp[i] = add( corX[i][ind], corr_shift ); -#endif /* BASOP_NOGLOB */ move16(); /* Higher is the neighbour's correlation, higher is the weighting */ @@ -902,11 +882,7 @@ void pitch_ol_fx( move16(); pitch_tmp[i + NHFR] = pitchX[i][ind1]; move16(); -#ifdef BASOP_NOGLOB cor_tmp[i + NHFR] = add_o( corX[i][ind1], corr_shift, &Overflow ); -#else /* BASOP_NOGLOB */ - cor_tmp[i + NHFR] = add( corX[i][ind1], corr_shift ); -#endif move16(); /* Higher is the neighbour's correlation, higher is the weighting */ @@ -1727,11 +1703,7 @@ void pitch_ol_ivas_fx( enr1 = ISqrt32( enr1, &enr1_exp ); /* 1/sqrt(energy) */ /*31-enr2_exp*/ Ltmp = Mpy_32_16_1( enr1, cor_buf[ind] ); -#ifdef BASOP_NOGLOB corX[i][j] = extract_h( L_shl_o( Ltmp, add( enr1_exp, cor_buf_exp[ind] ), &Overflow ) ); // Q15 -#else /* BASOP_NOGLOB */ - corX[i][j] = extract_h( L_shl( Ltmp, add( enr1_exp, cor_buf_exp[ind] ) ) ); -#endif /* BASOP_NOGLOB */ move16(); Ltmp = Mpy_32_16_1( enr1, pt_cor0[ind] ); @@ -1769,11 +1741,7 @@ void pitch_ol_ivas_fx( enr1 = ISqrt32( enr1, &enr1_exp ); /* 1/sqrt(energy) */ /*31-enr1_exp*/ Ltmp = Mpy_32_16_1( enr1, cor_buf[ind1 + len_x] ); -#ifdef BASOP_NOGLOB corX[i][j + NSECT] = extract_h( L_shl_o( Ltmp, add( enr1_exp, cor_buf_exp[ind1 + len_x] ), &Overflow ) ); // Q15 -#else /* BASOP_NOGLOB */ - corX[i][j + NSECT] = extract_h( L_shl( Ltmp, add( enr1_exp, cor_buf_exp_len_x1[ind1] ) ) ); -#endif /* BASOP_NOGLOB */ move16(); Ltmp = Mpy_32_16_1( enr1, pt_cor0[ind1 + ( DELTA_COH - 1 ) + len_x] ); @@ -1850,11 +1818,7 @@ void pitch_ol_ivas_fx( move16(); pitch_tmp[i] = pitchX[i][ind]; move16(); -#ifdef BASOP_NOGLOB cor_tmp[i] = add_o( corX[i][ind], corr_shift, &Overflow ); -#else /* BASOP_NOGLOB */ - cor_tmp[i] = add( corX[i][ind], corr_shift ); -#endif /* BASOP_NOGLOB */ move16(); /* Higher is the neighbour's correlation, higher is the weighting */ @@ -1868,11 +1832,7 @@ void pitch_ol_ivas_fx( move16(); pitch_tmp[i + NHFR] = pitchX[i][ind1]; move16(); -#ifdef BASOP_NOGLOB cor_tmp[i + NHFR] = add_o( corX[i][ind1], corr_shift, &Overflow ); -#else /* BASOP_NOGLOB */ - cor_tmp[i + NHFR] = add( corX[i][ind1], corr_shift ); -#endif move16(); /* Higher is the neighbour's correlation, higher is the weighting */ diff --git a/lib_enc/ppp_enc.c b/lib_enc/ppp_enc.c deleted file mode 100644 index d1de09bc73bcde0f9193c0b1d468183cb122cda9..0000000000000000000000000000000000000000 --- a/lib_enc/ppp_enc.c +++ /dev/null @@ -1,43 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "prot.h" -#include "rom_com.h" -#include "wmc_auto.h" diff --git a/lib_enc/ppp_enc_fx.c b/lib_enc/ppp_enc_fx.c index 3e5de17fa033d09164281b096fe1819354c3d15e..9afb27065559b4746745352c09b11dace1f3ed88 100644 --- a/lib_enc/ppp_enc_fx.c +++ b/lib_enc/ppp_enc_fx.c @@ -5,7 +5,6 @@ #include #include "options.h" #include "cnst.h" -//#include "prot_fx.h" #include "rom_com_fx.h" #include "rom_com.h" /* Common constants */ #include "prot_fx.h" /* Function prototypes */ @@ -153,10 +152,12 @@ ivas_error ppp_quarter_encoder_fx( /*As the upper cut of freqencies are normalized to 12800, we have to multiply upper cut off freq by 2.56(1/12800 in Q15) */ - Ltempn = L_mult( CURRCW_Q_FX->upper_cut_off_freq_fx, 10486 ); /* Q0+Q27 = Q28 */ - CURRCW_Q_FX->upper_cut_off_freq_fx = (Word16) L_shr( Ltempn, 13 ); /*Q15 */ + Ltempn = L_mult( CURRCW_Q_FX->upper_cut_off_freq_fx, 10486 ); /* Q0+Q27 = Q28 */ + CURRCW_Q_FX->upper_cut_off_freq_fx = (Word16) L_shr( Ltempn, 13 ); /*Q15 */ + move16(); Ltempn = L_mult( CURRCW_Q_FX->upper_cut_off_freq_of_interest_fx, 10486 ); /* Q0+Q27 = Q28 */ CURRCW_Q_FX->upper_cut_off_freq_of_interest_fx = (Word16) L_shr( Ltempn, 13 ); /*Q15 */ + move16(); *returnFlag = DTFS_quant_cw_fx( CURRCW_Q_FX, prevCW_lag, curr_lpc_fx, &POWER_IDX_FX, AMP_IDX_fx, lastLgainE_fx, lastHgainE_fx, lasterbE_fx, S_fx, C_fx ); @@ -168,6 +169,7 @@ ivas_error ppp_quarter_encoder_fx( move16(); Ltempn = L_shl( (Word32) CURRCW_Q_FX->upper_cut_off_freq_of_interest_fx, 13 ); /*Q28 */ 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 ); @@ -184,10 +186,9 @@ ivas_error ppp_quarter_encoder_fx( /*DTFS_pol2car(TARGETCW); */ tmp_fx = DTFS_alignment_fine_new_fx( *TARGETCW_FX, *CURRCW_Q_FX, S_fx, C_fx ); - move16(); test(); - IF( GT_16( add( tmp_fx, 12 ), 28 ) || LT_16( tmp_fx, -12 ) ) + IF( GT_16( tmp_fx, 28 - 12 ) || LT_16( tmp_fx, -12 ) ) { tmp_fx = 0; move16(); @@ -227,9 +228,9 @@ void set_ppp_mode_fx( test(); test(); - IF( EQ_16( st_fx->vad_flag, 1 ) && - ( EQ_16( noisy_speech_HO, 1 ) || EQ_16( clean_speech_HO, 1 ) || EQ_16( NB_speech_HO, 1 ) ) && - ( st_fx->localVAD == 0 || localVAD_he == 0 ) ) + if ( EQ_16( st_fx->vad_flag, 1 ) && + ( EQ_16( noisy_speech_HO, 1 ) || EQ_16( clean_speech_HO, 1 ) || EQ_16( NB_speech_HO, 1 ) ) && + ( st_fx->localVAD == 0 || localVAD_he == 0 ) ) { st_fx->coder_type = UNVOICED; @@ -238,7 +239,7 @@ void set_ppp_mode_fx( test(); test(); - IF( EQ_16( st_fx->coder_type, INACTIVE ) && ( st_fx->vad_flag == 0 ) && EQ_16( hSC_VBR->last_nelp_mode, 1 ) ) /* avoid HO frame go to GSC */ + if ( EQ_16( st_fx->coder_type, INACTIVE ) && ( st_fx->vad_flag == 0 ) && EQ_16( hSC_VBR->last_nelp_mode, 1 ) ) /* avoid HO frame go to GSC */ { st_fx->coder_type = UNVOICED; move16(); @@ -315,7 +316,7 @@ void set_ppp_mode_fx( move16(); } - IF( st_fx->last_core == HQ_CORE ) + IF( EQ_16( st_fx->last_core, HQ_CORE ) ) { hSC_VBR->ppp_mode = 0; move16(); @@ -329,7 +330,7 @@ void set_ppp_mode_fx( test(); test(); test(); - IF( ( hSC_VBR->last_ppp_mode != 0 ) && ( hSC_VBR->ppp_mode == 0 ) && ( st_fx->sp_aud_decision1 != 0 ) && EQ_16( st_fx->bwidth, NB ) && st_fx->Opt_SC_VBR != 0 ) /*if it were about to go from ppp->HQ*/ + IF( ( hSC_VBR->last_ppp_mode != 0 ) && ( hSC_VBR->ppp_mode == 0 ) && ( st_fx->sp_aud_decision1 != 0 ) && ( st_fx->bwidth == NB ) && ( st_fx->Opt_SC_VBR != 0 ) ) /*if it were about to go from ppp->HQ*/ { hSC_VBR->avoid_HQ_VBR_NB = 1; move16(); @@ -340,7 +341,7 @@ void set_ppp_mode_fx( test(); test(); test(); - IF( ( hSC_VBR->last_nelp_mode != 0 ) && ( st_fx->sp_aud_decision1 != 0 ) && EQ_16( st_fx->bwidth, NB ) && ( st_fx->Opt_SC_VBR != 0 ) ) /*if it were about to go from nelp->HQ*/ + IF( ( hSC_VBR->last_nelp_mode != 0 ) && ( st_fx->sp_aud_decision1 != 0 ) && ( st_fx->bwidth == NB ) && ( st_fx->Opt_SC_VBR != 0 ) ) /*if it were about to go from nelp->HQ*/ { hSC_VBR->avoid_HQ_VBR_NB = 1; move16(); @@ -412,6 +413,7 @@ static Word16 DTFS_quant_cw_fx( { Word16 num_erb = 0; + move16(); const Word16 *PowerCB_fx = NULL; Word16 tmp, w[2], target[2], j, slot[NUM_ERB_WB], flag; Word16 n, d1, d2, exp; @@ -439,7 +441,6 @@ static Word16 DTFS_quant_cw_fx( num_erb = NUM_ERB_WB; move16(); PowerCB_fx = PowerCB_WB_fx; - move16(); } /* Get weighting and target */ @@ -500,10 +501,10 @@ static Word16 DTFS_quant_cw_fx( erb_add_fx( curr_erb_fx, X_fx->lag_fx, lasterbE_fx, pl, AMP_IDX, num_erb ); curr_erb_fx[0] = mult_r( curr_erb_fx[1], 9830 ); - move16(); /* 0.3 inQ15 leaves curr_erb in Q13 */ - curr_erb_fx[sub( num_erb, 2 )] = mult_r( curr_erb_fx[sub( num_erb, 3 )], 9830 ); /* Q13 */ + move16(); /* 0.3 inQ15 leaves curr_erb in Q13 */ + curr_erb_fx[num_erb - 2] = mult_r( curr_erb_fx[num_erb - 3], 9830 ); /* Q13 */ - curr_erb_fx[sub( num_erb, 1 )] = 0; + curr_erb_fx[num_erb - 1] = 0; move16(); flag = 1; move16(); @@ -553,9 +554,11 @@ static Word16 DTFS_quant_cw_fx( ELSE IF( n > 0 ) rshiftHarmBand_fx( X_fx, 0, 2828, sub( Qh, Ql ) ); - tmp = shl( *POWER_IDX, 1 ); /* tmp=2*POWER_IDX */ - *lastLgainE_fx = add( *lastLgainE_fx, PowerCB_fx[tmp] ); /* Q11 */ + tmp = shl( *POWER_IDX, 1 ); /* tmp=2*POWER_IDX */ + *lastLgainE_fx = add( *lastLgainE_fx, PowerCB_fx[tmp] ); /* Q11 */ + move16(); *lastHgainE_fx = add( *lastHgainE_fx, PowerCB_fx[tmp + 1] ); /* Q11 */ + move16(); Ltemp = log10_fx( X_fx->lag_fx ); /* Ltemp=10*log10(lag), Q23 */ logLag_fx = Mult_32_16( Ltemp, 0x6666 ); /* logLag=log10(lag), Q26 */ @@ -621,6 +624,7 @@ static Word16 DTFS_alignment_fine_new_fx( DTFS_STRUCTURE X1_fx, DTFS_STRUCTURE X Word32 maxcorr_fx, wcorr_fx, diff_corr; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move16(); #endif IF( LT_16( X1_fx.lag_fx, X2_fx.lag_fx ) ) { @@ -635,7 +639,9 @@ static Word16 DTFS_alignment_fine_new_fx( DTFS_STRUCTURE X1_fx, DTFS_STRUCTURE X FOR( k = 0; k <= HalfLag; k++ ) { ab1[k] = round_fx( L_mac( L_mult( X1_fx.a_fx[k], X2_fx.a_fx[k] ), X1_fx.b_fx[k], X2_fx.b_fx[k] ) ); + move16(); ab2[k] = round_fx( L_msu( L_mult( X1_fx.b_fx[k], X2_fx.a_fx[k] ), X1_fx.a_fx[k], X2_fx.b_fx[k] ) ); + move16(); } @@ -657,15 +663,9 @@ static Word16 DTFS_alignment_fine_new_fx( DTFS_STRUCTURE X1_fx, DTFS_STRUCTURE X FOR( k = 0; k <= HalfLag; k++ ) { -#ifdef BASOP_NOGLOB corr_fx = L_mac_o( corr_fx, ab1[k], C_fx[temp % ( 4 * X2_fx.lag_fx )], &Overflow ); corr_fx = L_mac_o( corr_fx, ab2[k], S_fx[temp % ( 4 * X2_fx.lag_fx )], &Overflow ); temp = add_o( temp, temp1, &Overflow ); -#else - corr_fx = L_mac( corr_fx, ab1[k], C_fx[temp % ( 4 * X2_fx.lag_fx )] ); - corr_fx = L_mac( corr_fx, ab2[k], S_fx[temp % ( 4 * X2_fx.lag_fx )] ); - temp = add( temp, temp1 ); -#endif } temp = sub( 32767, extract_l( L_shr( L_mult( 82, abs_s( n ) ), 1 ) ) ); /* Q15 */ Qcorr = norm_l( corr_fx ); @@ -675,40 +675,23 @@ static Word16 DTFS_alignment_fine_new_fx( DTFS_STRUCTURE X1_fx, DTFS_STRUCTURE X move16(); } -#ifdef BASOP_NOGLOB temp1 = round_fx_o( (Word32) L_shl_o( corr_fx, Qcorr, &Overflow ), &Overflow ); /* Q(Qcorr-16) */ wcorr_fx = L_mult_o( temp1, temp, &Overflow ); /* Q(Qcorr-16+15+1)=Q(Qcorr) */ -#else - temp1 = round_fx( (Word32) L_shl( corr_fx, Qcorr ) ); /* Q(Qcorr-16) */ - wcorr_fx = L_mult( temp1, temp ); /* Q(Qcorr-16+15+1)=Q(Qcorr) */ -#endif IF( GE_16( Qmaxcorr, Qcorr ) ) { -#ifdef BASOP_NOGLOB diff_corr = L_sub_o( wcorr_fx, L_shl_o( maxcorr_fx, sub( Qcorr, Qmaxcorr ), &Overflow ), &Overflow ); /* Qcorr */ -#else - diff_corr = L_sub( wcorr_fx, L_shl( maxcorr_fx, sub( Qcorr, Qmaxcorr ) ) ); /* Qcorr */ -#endif } ELSE { -#ifdef BASOP_NOGLOB diff_corr = L_sub_o( L_shl_o( wcorr_fx, sub( Qmaxcorr, Qcorr ), &Overflow ), maxcorr_fx, &Overflow ); /* Qmaxcorr */ -#else - diff_corr = L_sub( L_shl( wcorr_fx, sub( Qmaxcorr, Qcorr ) ), maxcorr_fx ); /* Qmaxcorr */ -#endif } if ( diff_corr > 0 ) { fshift_fx = n; move16(); -#ifdef BASOP_NOGLOB maxcorr_fx = (Word32) L_shl_o( corr_fx, Qcorr, &Overflow ); /* Qcorr */ -#else - maxcorr_fx = (Word32) L_shl( corr_fx, Qcorr ); /* Qcorr */ -#endif Qmaxcorr = Qcorr; move16(); } @@ -758,6 +741,7 @@ static void LPCPowSpect_fx( Word16 tmp, exp; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move16(); #endif FOR( k = 0; k < Nf; k++ ) { @@ -789,17 +773,11 @@ static void LPCPowSpect_fx( t1 = add( t1, (Word16) L_shr( Ltemp, 16 ) ); /* t1 is interpolated cos(w) */ Ltemp = L_shr( L_mult( LPC[i], t1 ), 1 ); /* Ltemp in Q27 */ -#ifdef BASOP_NOGLOB - Re = L_add_o( Re, Ltemp, &Overflow ); /* Re=1-sum(LPC[i]*cos(Lw)); */ - Ltemp = L_add_o( Lw, 0x6000, &Overflow ); /* add 0.75, which is 3pi/2 to convert sin to cos */ - Ltemp = L_shl_o( Ltemp, 10, &Overflow ); /* Q25 */ -#else - Re = L_add( Re, Ltemp ); /* Re=1-sum(LPC[i]*cos(Lw)); */ - Ltemp = L_add( Lw, 0x6000 ); /* add 0.75, which is 3pi/2 to convert sin to cos */ - Ltemp = L_shl( Ltemp, 10 ); /* Q25 */ -#endif - w = extract_h( Ltemp ); /* w is equivalent cos index */ - dl = extract_l( Ltemp ); /* dl is 6 bit left-over for interpolation */ + Re = L_add_o( Re, Ltemp, &Overflow ); /* Re=1-sum(LPC[i]*cos(Lw)); */ + Ltemp = L_add_o( Lw, 0x6000, &Overflow ); /* add 0.75, which is 3pi/2 to convert sin to cos */ + Ltemp = L_shl_o( Ltemp, 10, &Overflow ); /* Q25 */ + w = extract_h( Ltemp ); /* w is equivalent cos index */ + dl = extract_l( Ltemp ); /* dl is 6 bit left-over for interpolation */ w = s_and( w, 511 ); t1 = cos_table[w]; /*t2=cos_table[s_and(add(w,1),511)]; */ @@ -819,13 +797,8 @@ static void LPCPowSpect_fx( t1 = add( t1, (Word16) L_shr( Ltemp, 16 ) ); /* t1 is interpolated cos(w) */ Ltemp = L_shr( L_mult( LPC[i], t1 ), 1 ); /* Ltemp in Q27 */ -#ifdef BASOP_NOGLOB - Im = L_sub_o( Im, Ltemp, &Overflow ); /* Im=sum(LPC[i]*sin(Lw)) */ - Lw = L_add_o( Lw, freq[k], &Overflow ); /* Lw=(i+1)*freq[k] */ -#else - Im = L_sub( Im, Ltemp ); /* Im=sum(LPC[i]*sin(Lw)) */ - Lw = L_add( Lw, freq[k] ); /* Lw=(i+1)*freq[k] */ -#endif + Im = L_sub_o( Im, Ltemp, &Overflow ); /* Im=sum(LPC[i]*sin(Lw)) */ + Lw = L_add_o( Lw, freq[k], &Overflow ); /* Lw=(i+1)*freq[k] */ } /* If necessary, we can block-normalize Re and Im to improve precision */ dh = extract_h( Re ); @@ -840,11 +813,7 @@ static void LPCPowSpect_fx( ELSE Lacc = L_mult0( dh, dl ); -#ifdef BASOP_NOGLOB Lacc = L_add_o( L_shr( Lacc, 15 ), L_shr( L_mult_o( dh, dh, &Overflow ), 1 ), &Overflow ); /* Lacc=Re*Re */ -#else - Lacc = L_add( L_shr( Lacc, 15 ), L_shr( L_mult( dh, dh ), 1 ) ); /* Lacc=Re*Re */ -#endif dh = extract_h( Im ); dl = extract_l( Im ); @@ -875,11 +844,8 @@ static void LPCPowSpect_fx( move16(); } Ltemp = L_deposit_h( tmp ); -#ifdef BASOP_NOGLOB out[k] = round_fx_o( L_shl_o( Ltemp, negate( add( exp, 8 ) ), &Overflow ), &Overflow ); -#else - out[k] = round_fx( L_shl( Ltemp, negate( add( exp, 8 ) ) ) ); -#endif + move16(); /* out[k] = shl(tmp,-exp-8); in Q7 */ } @@ -981,7 +947,7 @@ static void erb_diff_fx( tmp = t_prev_erb[num_erb - 1]; move16(); - FOR( i = sub( num_erb, 1 ); i >= 0; i-- ) + FOR( i = num_erb - 1; i >= 0; i-- ) { IF( pslot[i] != 0 ) { diff --git a/lib_enc/pre_proc.c b/lib_enc/pre_proc.c deleted file mode 100644 index dc0d098987194e4ae0ac1c7dc0b7b2d50ec319d2..0000000000000000000000000000000000000000 --- a/lib_enc/pre_proc.c +++ /dev/null @@ -1,46 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "cnst.h" -#include "rom_enc.h" -#include "rom_com.h" -#include "prot.h" -#include "wmc_auto.h" - -#include "prot_fx.h" -#include "prot_fx_enc.h" diff --git a/lib_enc/pre_proc_fx.c b/lib_enc/pre_proc_fx.c index 12b09c9ebc1a4425ce6af05c4b2dafafae6786b1..bd3d4cb340b9f3d6f00f5fa4f182c7a9de9702fe 100644 --- a/lib_enc/pre_proc_fx.c +++ b/lib_enc/pre_proc_fx.c @@ -6,7 +6,6 @@ #include "options.h" #include "cnst.h" #include "rom_com_fx.h" -//#include "prot_fx.h" #include "rom_com.h" /* Common constants */ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ @@ -106,6 +105,8 @@ void pre_proc_fx( Word16 fft_buff[2 * L_FFT]; Word16 sp_floor; Word16 freqTable_local[2] = { 20, 40 }; + move16(); + move16(); Word16 last_core_orig; Word16 headroom; Word16 cldfb_addition = 0; @@ -127,6 +128,7 @@ void pre_proc_fx( #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move16(); #endif /*------------------------------------------------------------------* @@ -206,6 +208,7 @@ void pre_proc_fx( analysisCldfbEncoder_fx( st, signal_in, realBuffer, imagBuffer, realBuffer16, imagBuffer16, enerBuffer, &enerBuffer_exp, cldfbScale ); cldfbScale->hb_scale = cldfbScale->lb_scale; + move16(); /*----------------------------------------------------------------* * Change the sampling frequency to 12.8 kHz @@ -227,7 +230,7 @@ void pre_proc_fx( test(); /* reserve an extra bit of headroom in case of NB coding and if there is a chance of energy above 4 kHz */ /* st->bwidth refers to the coded bandwidth of the previous frame */ - if ( ( ( EQ_16( st->bwidth, NB ) ) || ( EQ_16( st->max_bwidth, NB ) ) ) && ( GT_32( st->input_Fs, 8000 ) ) ) + if ( ( ( st->bwidth == NB ) || ( st->max_bwidth == NB ) ) && ( GT_32( st->input_Fs, 8000 ) ) ) { headroom = add( headroom, 1 ); } @@ -277,7 +280,7 @@ void pre_proc_fx( { /* Combine decisions from SADS */ test(); - IF( EQ_16( st->vad_flag, 1 ) && vad_flag_cldfb == 0 ) + if ( EQ_16( st->vad_flag, 1 ) && vad_flag_cldfb == 0 ) { st->localVAD = 0; move16(); @@ -486,7 +489,6 @@ void pre_proc_fx( move16(); } - move16(); /*------------------------------------------------------------------* * Update estimated noise energy and voicing cut-off frequency @@ -529,28 +531,36 @@ void pre_proc_fx( *-----------------------------------------------------------------*/ test(); test(); - test(); IF( !st->Opt_RF_ON ) { st->rf_mode = 0; + move16(); st->rf_target_bits_write = 0; + move16(); } - ELSE IF( st->rf_mode && NE_32( st->core_brate, FRAME_NO_DATA ) && NE_32( st->core_brate, SID_2k40 ) ) + ELSE IF( st->rf_mode && st->core_brate != FRAME_NO_DATA && NE_32( st->core_brate, SID_2k40 ) ) { /* the RF config is for (n- fec_offset)th frame that will be packed along with the n-th frame bitstream */ st->rf_mode = 1; + move16(); st->codec_mode = MODE2; + move16(); st->rf_target_bits_write = hRF->rf_targetbits_buff[st->rf_fec_offset]; + move16(); } ELSE { st->rf_mode = 0; + move16(); st->codec_mode = MODE1; + move16(); IF( st->Opt_RF_ON ) { hRF->rf_indx_frametype[0] = RF_NO_DATA; + move16(); hRF->rf_targetbits_buff[0] = 6; /* rf_mode: 1, rf_frame_type: 3, and fec_offset: 2 */ + move16(); } } @@ -625,7 +635,7 @@ void pre_proc_fx( test(); test(); test(); - IF( EQ_32( st->core_brate, FRAME_NO_DATA ) ) + IF( st->core_brate == FRAME_NO_DATA ) { /* prevent "L_frame" changes in CNG segments */ st->L_frame = st->last_L_frame; @@ -672,9 +682,11 @@ void pre_proc_fx( } st->sr_core = L_mult0( FRAMES_PER_SEC, st->L_frame ); + move32(); st->encoderLookahead_enc = NS2SA_FX2( st->sr_core, ACELP_LOOK_NS ); move16(); st->encoderPastSamples_enc = shr( imult1616( st->L_frame, 9 ), 4 ); + move16(); } /*-----------------------------------------------------------------* @@ -699,7 +711,7 @@ void pre_proc_fx( test(); test(); test(); - IF( NE_16( st->last_L_frame, st->L_frame ) && NE_32( st->core_brate, FRAME_NO_DATA ) && NE_32( st->core_brate, SID_2k40 ) && ( NE_16( st->coder_type_raw, VOICED ) ) ) + IF( NE_16( st->last_L_frame, st->L_frame ) && st->core_brate != FRAME_NO_DATA && NE_32( st->core_brate, SID_2k40 ) && ( NE_16( st->coder_type_raw, VOICED ) ) ) { /* enforce TC frame in case of ACELP@12k8 <-> ACELP@16k core switching */ st->coder_type = TRANSITION; @@ -826,12 +838,14 @@ void pre_proc_fx( { SetModeIndex_fx( st, st->last_total_brate, EVS_MONO, 0, *shift ); st->sr_core = getCoreSamplerateMode2( st->element_mode, st->total_brate, st->bwidth, st->flag_ACELP16k, st->rf_mode, 0 ); - + move32(); Mpy_32_16_ss( st->sr_core, 5243, &L_tmp, &lsb ); /* 5243 is 1/50 in Q18. (0+18-15=3) */ st->L_frame = extract_l( L_shr( L_tmp, 3 ) ); /* Q0 */ + move16(); st->encoderLookahead_enc = NS2SA_FX2( st->sr_core, ACELP_LOOK_NS ); move16(); st->encoderPastSamples_enc = shr( imult1616( st->L_frame, 9 ), 4 ); + move16(); assert( st->L_frame == st->sr_core / 50 ); IF( EQ_32( st->sr_core, INT_FS_12k8 ) ) @@ -882,7 +896,9 @@ void pre_proc_fx( IF( EQ_32( st->total_brate, ACELP_32k ) && EQ_16( loc_harm, 1 ) && GT_16( cor_map_sum, 50 << 8 ) && EQ_16( st->clas, VOICED_CLAS ) && EQ_16( st->coder_type, GENERIC ) ) { st->last_harm_flag_acelp = add( st->last_harm_flag_acelp, 1 ); + move16(); st->last_harm_flag_acelp = s_min( st->last_harm_flag_acelp, 10 ); + move16(); } ELSE { @@ -897,14 +913,18 @@ void pre_proc_fx( IF( EQ_16( st->coder_type, AUDIO ) ) { st->audio_frame_cnt = add( st->audio_frame_cnt, AUDIO_COUNTER_STEP ); + move16(); } - ELSE IF( NE_16( st->coder_type, INACTIVE ) ) + ELSE IF( st->coder_type != INACTIVE ) { st->audio_frame_cnt = sub( st->audio_frame_cnt, 1 ); + move16(); } st->audio_frame_cnt = s_min( st->audio_frame_cnt, AUDIO_COUNTER_MAX ); + move16(); st->audio_frame_cnt = s_max( st->audio_frame_cnt, 0 ); + move16(); /*-----------------------------------------------------------------* * Set formant sharpening flag @@ -959,9 +979,10 @@ void pre_proc_fx( /* channel-aware mode - due to lack of signalling bit, sharpFlag is 1 always in RF mode */ test(); test(); - IF( EQ_16( st->rf_mode, 1 ) && ( EQ_16( st->coder_type, VOICED ) || EQ_16( st->coder_type, GENERIC ) ) ) + if ( EQ_16( st->rf_mode, 1 ) && ( EQ_16( st->coder_type, VOICED ) || EQ_16( st->coder_type, GENERIC ) ) ) { st->sharpFlag = 1; + move16(); } /*-----------------------------------------------------------------* @@ -995,8 +1016,7 @@ void pre_proc_fx( L_frame_tmp = L_FRAME16k; move16(); } - L_look = NS2SA_FX2( sr_core_tmp, ACELP_LOOK_NS ); - move16(); /* lookahead at other sampling rate (16kHz, 25.5kHz, 32kHz) */ + L_look = NS2SA_FX2( sr_core_tmp, ACELP_LOOK_NS ); /* lookahead at other sampling rate (16kHz, 25.5kHz, 32kHz) */ new_inp_16k = old_inp_16k + L_INP_MEM; /* pointer to new samples of the input signal in 16kHz core */ inp_16k = new_inp_16k - L_look; /* pointer to the current frame of input signal in 16kHz core */ @@ -1047,11 +1067,8 @@ void pre_proc_fx( test(); IF( ( ( st->tcxonly == 0 ) || ( EQ_16( st->codec_mode, MODE1 ) ) ) && GT_32( st->input_Fs, 8000 ) ) { -#ifdef BASOP_NOGLOB st->mem_preemph_enc = shl_o( new_inp_16k[sub( L_frame_tmp, 1 )], 1, &Overflow ); -#else /* BASOP_NOGLOB */ - st->mem_preemph_enc = shl( new_inp_16k[sub( L_frame_tmp, 1 )], 1 ); -#endif + move16(); } test(); @@ -1061,7 +1078,7 @@ void pre_proc_fx( } ELSE IF( GT_32( st->input_Fs, 8000 ) ) /* keep memory up-to-date in case of bit-rate switching */ { - st->mem_preemph16k_fx = new_inp_16k[sub( L_frame_tmp, 1 )]; + st->mem_preemph16k_fx = new_inp_16k[L_frame_tmp - 1]; move16(); } @@ -1075,7 +1092,7 @@ void pre_proc_fx( test(); test(); test(); - IF( ( ( ( st->tcxonly == 0 ) || !( NE_32( 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 ) ) || + 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 ) ) ) { *Q_new = Q_new_16k; @@ -1092,7 +1109,6 @@ void pre_proc_fx( /* Above computed Q_new is used to scale primary copy exc and memory here by (Q_new, st->prev_Q_new) */ Q_exp = sub( *Q_new, st->prev_Q_new ); - move16(); Q_wsp_exp = add( Q_exp, shift_exp ); Scale_mem_enc( Q_exp, old_inp_16k, old_exc, hBWE_TD->old_bwe_exc_fx, &( hLPDmem->mem_w0 ), hLPDmem->mem_syn, @@ -1110,9 +1126,9 @@ void pre_proc_fx( test(); test(); #ifndef CR_2109_to_2112_cd0_ce0 - IF( ( ( ( st->tcxonly == 0 ) || !( NE_32( 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 ) ) ) + 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 ) || !( NE_32( 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 ) ) ) + 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 */ @@ -1221,7 +1237,7 @@ void pre_proc_fx( { test(); test(); - IF( ( NE_32( st->core_brate, FRAME_NO_DATA ) && NE_32( st->core_brate, SID_2k40 ) && st->tcxonly == 0 ) ) + IF( ( st->core_brate != FRAME_NO_DATA && NE_32( st->core_brate, SID_2k40 ) && st->tcxonly == 0 ) ) { core_acelp_tcx20_switching_fx( st, non_staX, pitch_fr, voicing_fr, currFlatness, lsp_mid, stab_fac, *Q_new, *shift ); } @@ -1318,16 +1334,18 @@ void pre_proc_fx( } /* Update vAD hangover frame counter in active frames */ - if ( ( NE_16( st->core, HQ_CORE ) && st->tcxonly == 0 ) || EQ_16( st->core, ACELP_CORE ) ) + if ( ( NE_16( st->core, HQ_CORE ) && st->tcxonly == 0 ) || st->core == ACELP_CORE ) { - IF( !( EQ_32( st->core_brate, SID_2k40 ) || EQ_32( st->core_brate, FRAME_NO_DATA ) ) ) + IF( !( EQ_32( st->core_brate, SID_2k40 ) || st->core_brate == FRAME_NO_DATA ) ) { test(); IF( st->Opt_DTX_ON != 0 && *vad_hover_flag != 0 ) { hTdCngEnc->burst_ho_cnt = add( hTdCngEnc->burst_ho_cnt, 1 ); + move16(); hTdCngEnc->burst_ho_cnt = s_min( hTdCngEnc->burst_ho_cnt, HO_HIST_SIZE ); + move16(); } ELSE { diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index c96678a7a5dfee59c304f367629094b6e16159ef..711d7069a55548319a63bc7918323da3574027e6 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -178,7 +178,10 @@ void dtx_fx( ); void dtx_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ + Encoder_State *st_fx, /* i/o: encoder state structure */ +#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 Q0*/ const Word16 vad, /* i : vad flag for DTX Q0*/ const Word16 speech[], /* i : Pointer to the speech frame Q_speech*/ @@ -845,10 +848,8 @@ Word16 corr_xy1_fx( /* o : pitch gain (0..GAIN_PIT_MAX) Word16 g_corr[], /* o : correlations and -2 */ const Word16 L_subfr, /* i : vector length */ const Word16 norm_flag /* i : flag for constraining pitch contribution */ -#ifdef BASOP_NOGLOB , Flag *Overflow_out /* o : propagating the Overflow flag to upper level */ -#endif ); Word16 E_ACELP_indexing_fx( const Word16 code[] /*Q9*/, const PulseConfig *config, Word16 num_tracks /*Q0*/, Word16 prm[] /*Q(shift_bits)*/ ); @@ -1559,6 +1560,10 @@ 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 */ Word16 cn[] /* Q_xn */, @@ -2427,6 +2432,24 @@ void tcx_arith_encode_envelope_fx( const Word16 low_complexity /* i: low-complexity flag Q0 */ ); +void tcx_arith_encode_envelope_ivas_fx( + Word32 spectrum[], /* i/o: MDCT coefficients Q31-e */ + Word16 *spectrum_e, /* i/o: MDCT exponent Q0 */ + Word16 signs[], /* o: signs (spectrum[.]<0) Q0 */ + const Word16 L_frame, /* i: frame or MDCT length Q0 */ + const Word16 L_spec, /* i: frame or MDCT length Q0 */ + Encoder_State *st, /* i/o: coder state */ + const Word16 A_ind[], /* i: quantised LPC coefficients Q12 */ + Word16 target_bits, /* i: number of available bits Q0 */ + Word16 prm[], /* o: bitstream parameters Q0 */ + const Word8 use_hm, /* i: use HM in current frame? */ + Word16 prm_hm[], /* o: HM parameter area Q0 */ + const Word16 tcxltp_pitch, /* i: TCX LTP pitch in FD, -1 if n/a Q0*/ + Word16 *arith_bits, /* o: bits used for ari. coding Q0 */ + Word16 *signaling_bits, /* o: bits used for signaling Q0 */ + const Word16 low_complexity /* i: low-complexity flag Q0 */ +); + /** Quantize gain. * Quantize gain in range [0..127], * @param n Length of the spectrum. @@ -2647,6 +2670,19 @@ Word16 Q_lsf_tcxlpc_fx( const Word32 *Bin_Ener, const Word16 Q_ener ); +Word16 Q_lsf_tcxlpc_ivas_fx( + /* const */ Word16 lsf[], /* i : original lsf */ + Word16 lsf_q[], /* o : quantized lsf */ + Word16 lsp_q_ind[], /* o : quantized lsp (w/o MA prediction) */ + Word16 indices[], /* o : VQ indices */ + const Word16 lpcorder, /* i : LPC order */ + const Word16 narrowband, /* i : narrowband flag */ + const Word16 cdk, /* i : codebook selector */ + const Word16 mem_MA[], /* i : MA memory */ + const Word16 coder_type, + const Word32 *Bin_Ener, + const Word16 Q_ener ); + Word16 signalling_mode1_tcx20_enc_fx( Encoder_State *st, /* i : encoder state structure */ Word16 push /*Q0*/ ); @@ -3031,6 +3067,14 @@ void IGF_ErodeSpectrum( Word16 *highPassEner_exp, /**< out: | Word16 pPowerSpectrum_exp, /**< in: | exponent of power spectrum */ const Word16 igfGridIdx /**< in: Q0 | IGF grid index */ ); + +void IGF_ErodeSpectrum_ivas_fx( const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Encoder */ + Word32 *pSpectrum, /**< in/out: | MDCT spectrum */ + Word32 *pPowerSpectrum, /**< in/out: | power spectrum */ + Word16 pPowerSpectrum_exp, /**< in: | exponent of power spectrum */ + const Word16 igfGridIdx, /**< in: Q0 | IGF grid index */ + const Word16 mct_on ); + void IGFEncApplyMono_fx( const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Encoder */ const Word16 igfGridIdx, /**< in: Q0 | IGF grid index */ Encoder_State *st, /**< in: | Encoder state */ @@ -3424,7 +3468,7 @@ Word16 lp_filt_exc_enc_ivas_fx( const Word16 coder_type, /* i : coding type Q0 */ const Word16 i_subfr, /* i : subframe index Q0 */ Word16 *exc, /* i/o: pointer to excitation signal frame Q_new */ - const Word16 *h1, /* i : weighted filter i response Q(14+shift) */ + const Word16 *h1, /* i : weighted filter i response Q(15) */ const Word16 *xn, /* i : target vector Q_new-1+shift */ Word16 *y1, /* o : zero-memory filtered adaptive excitation Q_new-1+shift */ Word16 *xn2, /* o : target vector for innovation search Q_new-1+shift */ @@ -3777,11 +3821,7 @@ void updt_tar_HR_fx( const Word16 L /* i : subframe size */ ); -#ifdef BASOP_NOGLOB Flag conv_fx( -#else -void conv_fx( -#endif const Word16 x[], /* i : i vector Q_new*/ const Word16 h[], /* i : impulse response (or second i vector) Q(15)*/ Word16 y[], /* o : output vetor (result of convolution) 12 bits*/ diff --git a/lib_enc/pvq_core_enc.c b/lib_enc/pvq_core_enc.c deleted file mode 100644 index ce12347234733459bf08743ee7fa4381e3c076ce..0000000000000000000000000000000000000000 --- a/lib_enc/pvq_core_enc.c +++ /dev/null @@ -1,44 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "rom_com.h" -#include "prot.h" -#include "prot.h" -#include "stl.h" -#include "wmc_auto.h" diff --git a/lib_enc/pvq_core_enc_fx.c b/lib_enc/pvq_core_enc_fx.c index 3b20e82c3aad5b0c7abcdae17e93d3a7bc53cf73..214522126120348426c0f9a7d5bc2569f584a903 100644 --- a/lib_enc/pvq_core_enc_fx.c +++ b/lib_enc/pvq_core_enc_fx.c @@ -5,9 +5,8 @@ #include #include "options.h" /* Compilation switches */ #include "cnst.h" -#include "rom_com_fx.h" /* Static table prototypes */ -#include "rom_com.h" /* Static table prototypes */ -//#include "prot_fx.h" /* Function prototypes */ +#include "rom_com_fx.h" /* Static table prototypes */ +#include "rom_com.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ #include "ivas_prot_fx.h" @@ -202,12 +201,15 @@ static void pvq_encode_band_fx( move16(); } - pool_tot = 0; /* Word16 */ + pool_tot = 0; /* Word16 */ + move16(); pool_part = 0; /* Word16 */ + move16(); FOR( j = 0; j < Np; j++ ) { g_part[j] = negate( g_part_neg[j] ); + move16(); } srt_vec_ind16_fx( g_part, sg_part, idx_sort, Np ); FOR( j = 0; j < Np; j++ ) @@ -215,6 +217,7 @@ static void pvq_encode_band_fx( js = idx_sort[Np - 1 - j]; pool_part = shrtCDivSignedApprox( pool_tot, sub( Np, j ) ); bits_part[js] = s_max( 0, s_min( add( bits_part[js], pool_part ), 256 ) ); + move16(); conservativeL1Norm_fx( dim_part[js], bits_part[js], strict_bits, *bits_left, pool_tot, *npulses, /* inputs */ &K_val, bits_left, &pool_tot, npulses ); /* outputs */ @@ -266,7 +269,7 @@ void pvq_encode_frame_ivas_fx( PVQ_ENC_HANDLE hPVQ = &pvq_enc; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; - move32(); + move16(); #endif rc_enc_init_fx( hPVQ, pvq_bits ); @@ -310,8 +313,8 @@ void pvq_encode_frame_ivas_fx( move16(); IF( R[is] > 0 ) { - bandBitsAdjustment_fx( hPVQ->rc_num_bits, hPVQ->rc_range, bits, bands_to_code, bands_to_code - coded_bands, sfmsize[is], R[is], bit_pool, /* inputs */ - &band_bits, &bits_left, &bit_pool ); /* outputs */ + bandBitsAdjustment_fx( hPVQ->rc_num_bits, hPVQ->rc_range, bits, bands_to_code, sub( bands_to_code, coded_bands ), sfmsize[is], R[is], bit_pool, /* inputs */ + &band_bits, &bits_left, &bit_pool ); /* outputs */ pvq_encode_band_ivas_fx( hBstr, hPVQ, &coefs_norm[sfm_start[is]], Q_coefs, &pulse_vector[sfm_start[is]], &npulses[is], &coefs_quant[sfm_start[is]], sfmsize[is], band_bits, &bits_left, strict_bits ); @@ -328,12 +331,8 @@ void pvq_encode_frame_ivas_fx( } tmp = ratio( xy_corr, yy_corr, &exp ); -#ifdef BASOP_NOGLOB gopt[is] = shl_o( tmp, sub( sub( sub( 14, Q_coefs ), shift ), exp ), &Overflow ); move16(); -#else /* BASOP_NOGLOB */ - gopt[is] = shl( tmp, sub( sub( sub( 14, Q_coefs ), shift ), exp ) ); -#endif if ( gopt[is] == 0 ) { @@ -382,6 +381,7 @@ void pvq_encode_frame_fx( Word16 band_bits, bits_left; Word16 bit_pool = 0; + move16(); Word16 coded_bands, bands_to_code; Word16 bits; Word16 R_sort[NB_SFM]; @@ -393,6 +393,7 @@ void pvq_encode_frame_fx( PVQ_ENC_HANDLE hPVQ = &pvq_enc; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move16(); #endif rc_enc_init_fx( hPVQ, pvq_bits ); @@ -436,15 +437,15 @@ void pvq_encode_frame_fx( move16(); IF( R[is] > 0 ) { - bandBitsAdjustment_fx( hPVQ->rc_num_bits, hPVQ->rc_range, bits, bands_to_code, bands_to_code - coded_bands, sfmsize[is], R[is], bit_pool, /* inputs */ - &band_bits, &bits_left, &bit_pool ); /* outputs */ + bandBitsAdjustment_fx( hPVQ->rc_num_bits, hPVQ->rc_range, bits, bands_to_code, sub( bands_to_code, coded_bands ), sfmsize[is], R[is], bit_pool, /* inputs */ + &band_bits, &bits_left, &bit_pool ); /* outputs */ pvq_encode_band_fx( hBstr, hPVQ, &coefs_norm[sfm_start[is]], Q_coefs, &pulse_vector[sfm_start[is]], &npulses[is], &coefs_quant[sfm_start[is]], sfmsize[is], band_bits, &bits_left, strict_bits ); xy_corr = L_deposit_l( 0 ); yy_corr = L_deposit_l( 1 ); - shift = band_len_ener_shift[band_len_idx[shr( sfmsize[is], 3 )]]; + shift = band_len_ener_shift[band_len_idx[sfmsize[is] >> 3]]; move16(); FOR( j = 0; j < sfmsize[i]; j++ ) { @@ -454,12 +455,8 @@ void pvq_encode_frame_fx( } tmp = ratio( xy_corr, yy_corr, &exp ); -#ifdef BASOP_NOGLOB gopt[is] = shl_o( tmp, sub( sub( sub( 14, Q_coefs ), shift ), exp ), &Overflow ); -#else /* BASOP_NOGLOB */ - gopt[is] = shl( tmp, sub( sub( sub( 14, Q_coefs ), shift ), exp ) ); -#endif - + move16(); if ( gopt[is] == 0 ) { gopt[is] = 1; @@ -664,6 +661,7 @@ static void encode_energies_fx( Word16 density; Word16 phi; Word16 index_phi = -1; + move16(); Word16 oppRQ3, qzero; Word16 angle; Word32 sqrt_r_enr, sqrt_l_enr; @@ -739,11 +737,13 @@ static void encode_energies_fx( FOR( i = 0; i < l_Np; i++ ) { g_part[i] = mult_r( l_gain, g_part[i] ); + move16(); } FOR( i = l_Np; i < Np; i++ ) { g_part[i] = mult_r( r_gain, g_part[i] ); + move16(); } NearOppSplitAdjustment_fx( qband, qzero, hPVQ->rc_num_bits, hPVQ->rc_range, *bits_left, @@ -933,7 +933,7 @@ static void densityIndexSymbolEncode_ivas_fx( UWord16 lsb; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; - move32(); + move16(); #endif sym_freq = L_deposit_l( 1 ); @@ -941,11 +941,7 @@ static void densityIndexSymbolEncode_ivas_fx( IF( s_and( (Word16) 0xFFFE, density ) != 0 ) /* even */ { angle = atan2_fx( SQRT_DIM_fx[r_dim], SQRT_DIM_fx[l_dim] ); -#ifdef BASOP_NOGLOB angle = shl_o( angle, 1, &Overflow ); -#else - angle = shl( angle, 1 ); -#endif angle = mult_r( angle, 20861 ); c = mult_r( density, angle ); @@ -1014,6 +1010,7 @@ static void densityIndexSymbolEncode_fx( UWord16 lsb; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move16(); #endif sym_freq = L_deposit_l( 1 ); @@ -1021,11 +1018,7 @@ static void densityIndexSymbolEncode_fx( IF( s_and( (Word16) 0xFFFE, density ) != 0 ) /* even */ { angle = atan2_fx( SQRT_DIM_fx[r_dim], SQRT_DIM_fx[l_dim] ); -#ifdef BASOP_NOGLOB angle = shl_o( angle, 1, &Overflow ); -#else - angle = shl( angle, 1 ); -#endif angle = mult_r( angle, 20861 ); c = mult_r( density, angle ); @@ -1247,6 +1240,7 @@ static Word16 calc_pvq_splits_fx( /* o : Number of segm acc = L_shr( acc, qPoint ); E[i] = sub( 30, norm_l( L_max( 1L, acc ) ) ); /* L_max needed to handle low subvector levels */ + move16(); eTotal = add( eTotal, E[i] ); } diff --git a/lib_enc/pvq_encode.c b/lib_enc/pvq_encode.c deleted file mode 100644 index 23468cbe8bbfdcb2b56d900848a3cac1fc090edf..0000000000000000000000000000000000000000 --- a/lib_enc/pvq_encode.c +++ /dev/null @@ -1,43 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "prot.h" -#include "rom_com.h" -#include "prot.h" -#include "wmc_auto.h" diff --git a/lib_enc/pvq_encode_fx.c b/lib_enc/pvq_encode_fx.c index b09d77802a6d84480e095e00b09d156204420887..749a39ed91243268b64f71275ce5106e00cf9749 100644 --- a/lib_enc/pvq_encode_fx.c +++ b/lib_enc/pvq_encode_fx.c @@ -4,7 +4,6 @@ #include #include "options.h" /* Compilation switches */ #include "cnst.h" -//#include "prot_fx.h" #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ #include "rom_com_fx.h" @@ -63,6 +62,7 @@ static Word16 one_pulse_search( UWord16 u_sgn; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move16(); #endif en_tmp = en_dn_shift; /* dummy assignment to avoid compiler warning for unused parameter */ @@ -77,21 +77,17 @@ static Word16 one_pulse_search( IF( high_prec_active == 0 ) { - en_max_den = 0; /*move16()*/ + en_max_den = 0; /*move16()*/ + move16(); ; /* OPT: move saved by using high_prec_active as en_max_den */ /* 1 op */ cmax_num = -1; move16(); /* req. to force a 1st update for n==0 */ /* 1 op */ FOR( i = 0; i < dim; i++ ) /* FOR 3 ops */ { -#ifdef BASOP_NOGLOB L_tmp_corr = L_shl_o( L_mac_o( *L_xy_ptr, 1, x_abs[i], &Overflow ), corr_up_shift, &Overflow ); /* actual in-loop target value, 2 ops */ corr_tmp = round_fx_o( L_tmp_corr, &Overflow ); /* 1 op */ -#else - L_tmp_corr = L_shl( L_mac( *L_xy_ptr, 1, x_abs[i] ), corr_up_shift ); /* actual in-loop target value, 2 ops */ - corr_tmp = round_fx( L_tmp_corr ); /* 1 op */ -#endif - corr_sq_tmp = mult( corr_tmp, corr_tmp ); /* CorrSq, is a 16bit for low compelxity cross multiplication 1 op */ + corr_sq_tmp = mult( corr_tmp, corr_tmp ); /* CorrSq, is a 16bit for low compelxity cross multiplication 1 op */ L_tmp_en_lc = L_mac( *L_yy_ptr, 1, y[i] ); /*Q1 result , energy may span up to ~14+1(Q1)+1(sign)=16 bits, 1 op */ /* extract_l without shift can always be used for this section as energy is guaranteed to stay in the lower word, 1 op */ @@ -167,6 +163,7 @@ static Word16 one_pulse_search( y[imax] = add( y[imax], 1 ); move16(); /* Q0 added pulse */ ( *pulse_tot_ptr ) = add( ( *pulse_tot_ptr ), 1 ); /* increment total pulse sum */ + move16(); return imax; } @@ -207,7 +204,7 @@ void pvq_encode_ivas_fx( PvqEntry entry; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; - move32(); + move16(); #endif L_proj_fac = 4096; @@ -262,11 +259,7 @@ void pvq_encode_ivas_fx( proj_fac = div_l( L_num, den ); /* L_num always has to be less than den<<16 */ shift_delta = sub( shift_num, shift_den ); -#ifdef BASOP_NOGLOB L_proj_fac = L_shl_sat( L_deposit_l( proj_fac ), sub( 9, shift_delta ) ); /* bring to a fixed Q12 */ -#else - L_proj_fac = L_shl( L_deposit_l( proj_fac ), sub( 9, shift_delta ) ); /* bring to a fixed Q12 */ -#endif } pulse_tot = 0; @@ -366,14 +359,9 @@ void pvq_encode_ivas_fx( } Mpy_32_16_ss( L_isqrt, tmp, &L_tmp, &u16_tmp ); /* Q31*Q(0+x) +1 */ Mpy_32_16_ss( L_tmp, neg_gain_norm, &L_tmp, &u16_tmp ); /* Q31*Q(0+x) *Q15 +1 */ -#ifdef BASOP_NOGLOB - L_tmp = L_shr_o( L_tmp, shift_tot, &Overflow ); /* Q31+x */ - xq[i] = round_fx_o( L_tmp, &Overflow ); /* Q15, array move */ + L_tmp = L_shr_o( L_tmp, shift_tot, &Overflow ); /* Q31+x */ + xq[i] = round_fx_o( L_tmp, &Overflow ); /* Q15, array move */ move16(); -#else - L_tmp = L_shr( L_tmp, shift_tot ); /* Q31+x */ - xq[i] = round_fx( L_tmp ); /* Q15, array move */ -#endif L_xq[i] = L_tmp; /* Q31 currently unused */ move32(); } @@ -424,9 +412,11 @@ void pvq_encode_fx( PvqEntry entry; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move16(); #endif L_proj_fac = 4096; + move32(); L_xsum = L_deposit_h( 0 ); max_xabs = -1; move16(); @@ -477,11 +467,7 @@ void pvq_encode_fx( proj_fac = div_l( L_num, den ); /* L_num always has to be less than den<<16 */ shift_delta = sub( shift_num, shift_den ); -#ifdef BASOP_NOGLOB L_proj_fac = L_shl_sat( L_deposit_l( proj_fac ), sub( 9, shift_delta ) ); /* bring to a fixed Q12 */ -#else - L_proj_fac = L_shl( L_deposit_l( proj_fac ), sub( 9, shift_delta ) ); /* bring to a fixed Q12 */ -#endif } pulse_tot = 0; @@ -581,14 +567,11 @@ void pvq_encode_fx( } Mpy_32_16_ss( L_isqrt, tmp, &L_tmp, &u16_tmp ); /* Q31*Q(0+x) +1 */ Mpy_32_16_ss( L_tmp, neg_gain_norm, &L_tmp, &u16_tmp ); /* Q31*Q(0+x) *Q15 +1 */ -#ifdef BASOP_NOGLOB - L_tmp = L_shr_o( L_tmp, shift_tot, &Overflow ); /* Q31+x */ - xq[i] = round_fx_o( L_tmp, &Overflow ); /* Q15, array move */ -#else - L_tmp = L_shr( L_tmp, shift_tot ); /* Q31+x */ - xq[i] = round_fx( L_tmp ); /* Q15, array move */ -#endif + L_tmp = L_shr_o( L_tmp, shift_tot, &Overflow ); /* Q31+x */ + xq[i] = round_fx_o( L_tmp, &Overflow ); /* Q15, array move */ + move16(); L_xq[i] = L_tmp; /* Q31 currently unused */ + move32(); } /* index the found PVQ vector into short codewords */ diff --git a/lib_enc/q_gain2p.c b/lib_enc/q_gain2p.c deleted file mode 100644 index bcdeaa0415b3291cebf3e4463a6e123980ab180f..0000000000000000000000000000000000000000 --- a/lib_enc/q_gain2p.c +++ /dev/null @@ -1,43 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "prot.h" -#include "cnst.h" -#include "rom_com.h" -#include "wmc_auto.h" diff --git a/lib_enc/q_gain2p_fx.c b/lib_enc/q_gain2p_fx.c index 14d6d59073c50a91706cdc99b96a4763f66ba5ff..4618483d26b649a5e066f1dc307655f4bec5c505 100644 --- a/lib_enc/q_gain2p_fx.c +++ b/lib_enc/q_gain2p_fx.c @@ -6,7 +6,6 @@ #include #include "options.h" #include "cnst.h" /* Common constants */ -//#include "prot_fx.h" #include "basop_util.h" #include "rom_com_fx.h" #include "rom_com.h" /* Common constants */ @@ -57,6 +56,8 @@ void encode_acelp_gains_fx( ) { Word16 index = 0, func_type = 0; + move16(); + move16(); BASOP_SATURATE_ERROR_ON_EVS; @@ -146,6 +147,7 @@ static Word16 gain_enc( /* o : quantization pitch index Word32 L_tmp, dist_min, L_tmp1; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move16(); #endif @@ -163,11 +165,8 @@ static Word16 gain_enc( /* o : quantization pitch index /* gain_inov = 1.0f / sqrt((dot_product(code, code, L_SUBFR) + 0.01) / L_SUBFR) */ L_tmp = calc_gain_inov( code, lcode, &L_tmp1, &exp_L_tmp1 ); move16(); -#ifdef BASOP_NOGLOB *gain_inov = round_fx_o( L_shl_o( L_tmp, 15 - 3, &Overflow ), &Overflow ); /* gain_inov in Q12 */ -#else - *gain_inov = round_fx( L_shl( L_tmp, 15 - 3 ) ); /* gain_inov in Q12 */ -#endif + move16(); /*----------------------------------------------------------------* * calculate the predicted gain code *----------------------------------------------------------------*/ @@ -325,6 +324,8 @@ static Word16 gain_enc( /* o : quantization pitch index size_clip = 21; size = NB_QUA_GAIN7B; } + move16(); + move16(); if ( EQ_16( clip_gain, 1 ) ) { @@ -333,7 +334,6 @@ static Word16 gain_enc( /* o : quantization pitch index gcode0_gi = gcode0; move16(); } - move16(); p = t_qua_gain; index = 0; @@ -377,11 +377,7 @@ static Word16 gain_enc( /* o : quantization pitch index /* Here, we use L_mult0 to compensate the factor 0.5 applied to coeff[1..4] before */ L_tmp = L_add( L_tmp, L_shr( L_mult0( p[2 * i + 0], p[2 * i + 0] ), shr_coeff0 ) ); L_tmp = L_sub( L_tmp, L_shr( L_mult( p[2 * i + 0], coeff1 ), shr_coeff1 ) ); -#ifdef BASOP_NOGLOB L_tmp1 = L_sub_o( L_tmp, dist_min, &Overflow ); -#else /* BASOP_NOGLOB */ - L_tmp1 = L_sub( L_tmp, dist_min ); -#endif BASOP_SATURATE_WARNING_ON_EVS if ( L_tmp1 < 0 ) { @@ -401,21 +397,14 @@ static Word16 gain_enc( /* o : quantization pitch index L_tmp = L_mult( g_code, gcode0 ); /* Q11*Q15 -> Q27 */ exp_gcode0 = add( exp_gcode0, -11 ); -#ifdef BASOP_NOGLOB L_tmp = L_shl_o( L_tmp, exp_gcode0, &Overflow ); /* Q27 -> Q16 */ -#else - L_tmp = L_shl( L_tmp, exp_gcode0 ); /* Q27 -> Q16 */ -#endif *gain_code = L_tmp; move32(); /* Q16/Q12 => Q5 */ L_tmp = L_deposit_h( BASOP_Util_Divide3216_Scale( L_tmp, *gain_inov, &i ) ); -#ifdef BASOP_NOGLOB *past_gcode = L_shl_o( L_tmp, sub( i, 15 - 12 ), &Overflow ); -#else - *past_gcode = L_shl( L_tmp, sub( i, 15 - 12 ) ); -#endif + move16(); return index; } @@ -446,12 +435,17 @@ Word16 gain_enc_uv_fx( /* o : quantization pitch ind Word16 s, tmp1, s1; Word16 index2; const Word16 log2_scale = 16; + move16(); #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move16(); #endif pred_nrg_frame = 0; /* to suppress compilation warnings */ g_code2 = 0; /* to suppress compilation warnings */ exp_gcode2 = 0; /* to suppress compilation warnings */ + move32(); + move16(); + move16(); assert( ( func_type != FUNC_GAIN_ENC_MLESS ) ); @@ -476,6 +470,7 @@ Word16 gain_enc_uv_fx( /* o : quantization pitch ind /* gain_inov = 1.0f / sqrt((dot_product(code, code, L_SUBFR) + 0.01) / L_SUBFR) */ L_tmp = calc_gain_inov( code, lcode, NULL, NULL ); *gain_inov = round_fx( L_shl( L_tmp, 15 - 3 ) ); /* gain_inov in Q12 */ + move16(); /*----------------------------------------------------------------* * calculate the predicted gain code @@ -489,7 +484,7 @@ Word16 gain_enc_uv_fx( /* o : quantization pitch ind /* gcode = pred_nrg_frame * (*gain_inov); */ L_tmp = Mpy_32_16_1( pred_nrg_frame, *gain_inov ); /* 18Q13 */ i = norm_l( L_tmp ); - g_code = round_fx( L_shl( L_tmp, i ) ); + g_code = round_fx_sat( L_shl( L_tmp, i ) ); exp_gcode = sub( 18, i ); /* norm_code2 = 1.0f / sqrt((dot_product(code2, code2, lcode) + 0.01f) / lcode); */ @@ -499,11 +494,7 @@ Word16 gain_enc_uv_fx( /* o : quantization pitch ind /* g_code2 = pred_nrg_frame * norm_code2; */ L_tmp = Mpy_32_16_1( pred_nrg_frame, norm_code2 ); /* 18Q13 */ i = norm_l( L_tmp ); -#ifdef BASOP_NOGLOB g_code2 = round_fx_sat( L_shl_sat( L_tmp, i ) ); -#else - g_code2 = round_fx( L_shl( L_tmp, i ) ); -#endif exp_gcode2 = sub( 18, i ); } ELSE @@ -563,7 +554,7 @@ Word16 gain_enc_uv_fx( /* o : quantization pitch ind L_tmp = L_and( 0x7FFFFFFF, L_tmp ); L_tmp = Pow2( 30, round_fx( L_tmp ) ); - L_tmp = L_shl( L_tmp, i - ( 31 - 16 ) ); /* Q16 */ + L_tmp = L_shl( L_tmp, sub( i, ( 31 - 16 ) ) ); /* Q16 */ IF( gacelp_uv != 0 ) { @@ -586,11 +577,7 @@ Word16 gain_enc_uv_fx( /* o : quantization pitch ind } -#ifdef BASOP_NOGLOB *gain_code = L_shl_sat( Mpy_32_16_1( *past_gcode, *gain_inov ), 3 ); -#else - *gain_code = L_shl( Mpy_32_16_1( *past_gcode, *gain_inov ), 3 ); -#endif move32(); *gain_pit = 0; @@ -608,11 +595,7 @@ Word16 gain_enc_uv_fx( /* o : quantization pitch ind } s1 = norm_l( *gain_code ); -#ifdef BASOP_NOGLOB tmp1 = round_fx_o( L_shl_o( *gain_code, s1, &Overflow ), &Overflow ); -#else - tmp1 = round_fx( L_shl( *gain_code, s1 ) ); -#endif s1 = sub( 15, s1 ); tmp1 = mult_r( mult_r( tmp1, tmp1 ), g_coeff->y2y2 ); @@ -625,11 +608,7 @@ Word16 gain_enc_uv_fx( /* o : quantization pitch ind L_tmp1 = L_add( L_tmp, 0 ); s1 = norm_l( *gain_code ); -#ifdef BASOP_NOGLOB tmp1 = round_fx_o( L_shl_o( *gain_code, s1, &Overflow ), &Overflow ); -#else - tmp1 = round_fx( L_shl( *gain_code, s1 ) ); -#endif s1 = sub( 15, s1 ); c_index2 = 0x7FFF; @@ -640,11 +619,7 @@ Word16 gain_enc_uv_fx( /* o : quantization pitch ind { /* c = c_first - L_tmp1 * (L_tmp1 * g_coeff->y1y1 + 2 * (*gain_code) * g_coeff->y1y2); */ s = norm_l( L_tmp1 ); -#ifdef BASOP_NOGLOB tmp = round_fx_sat( L_shl_sat( L_tmp1, s ) ); -#else - tmp = round_fx( L_shl( L_tmp1, s ) ); -#endif s = sub( 15, s ); c_e = BASOP_Util_Add_MantExp( mult_r( tmp, g_coeff->y1y1 ), add( s, g_coeff->y1y1_e ), diff --git a/lib_enc/qlpc_avq.c b/lib_enc/qlpc_avq.c deleted file mode 100644 index 24f06eafe31fb859892ef40e5947576a60ab5108..0000000000000000000000000000000000000000 --- a/lib_enc/qlpc_avq.c +++ /dev/null @@ -1,41 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "prot.h" -#include "ivas_prot.h" -#include "wmc_auto.h" diff --git a/lib_enc/qlpc_stoch_fx.c b/lib_enc/qlpc_stoch_fx.c index 5a98fb328b8735f6f86be5ebb7e1bfa888f874c9..d6f0b504f8f2c5ebc0aea689ff87b5eaac0a7ad0 100644 --- a/lib_enc/qlpc_stoch_fx.c +++ b/lib_enc/qlpc_stoch_fx.c @@ -441,11 +441,7 @@ void Unified_weighting_fx( L_tmp = L_deposit_l( 0 ); FOR( i = 95; i < 127; i++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_add_o( L_tmp, Bin_Ener_160_fx[i], &Overflow ); /* Q_ener */ -#else - L_tmp = L_add( L_tmp, Bin_Ener_160_fx[i] ); -#endif } L_tmp = L_shr( L_tmp, 5 ); @@ -526,11 +522,7 @@ void Unified_weighting_fx( } ELSE { -#ifdef BASOP_NOGLOB L_tmp = L_shl_o( L_deposit_l( sub_o( w_fft_fx[i], min_fx, &Overflow ) ), 13, &Overflow ); /* Q21 */ -#else - L_tmp = L_shl( L_deposit_l( sub( w_fft_fx[i], min_fx ) ), 13 ); /* Q21 */ -#endif exp = norm_l( L_tmp ); frac = round_fx( L_shl( L_tmp, exp ) ); exp = sub( add( exp, 21 ), 30 ); diff --git a/lib_enc/scale_enc_fx.c b/lib_enc/scale_enc_fx.c index a7119b41f797ca4c9e5b386ba407610c1eed41d7..76eae22b7b1f21cc40f7593b1cf4e5fcff81da16 100644 --- a/lib_enc/scale_enc_fx.c +++ b/lib_enc/scale_enc_fx.c @@ -97,12 +97,8 @@ void Preemph_scaled( *---------------------------------------------------------------*/ BASOP_SATURATE_WARNING_OFF_EVS -#ifdef BASOP_NOGLOB Overflow = 0; QVal = shl_o( 1, sub( 15, bits ), &Overflow ); -#else /* BASOP_NOGLOB */ - QVal = shl( 1, sub( 15, bits ) ); -#endif /* BASOP_NOGLOB */ BASOP_SATURATE_WARNING_ON_EVS mu = shr( Preemph_factor, bits ); /* Q15 --> Q(15-bits) */ @@ -111,11 +107,7 @@ void Preemph_scaled( /* get max of new preemphased samples (L_FRAME+L_FILT) */ L_tmp = L_mult( new_speech[0], QVal ); -#ifdef BASOP_NOGLOB L_tmp = L_msu_sat( L_tmp, *mem_preemph, mu ); -#else - L_tmp = L_msu( L_tmp, *mem_preemph, mu ); -#endif L_maxloc = L_abs( L_tmp ); FOR( i = 1; i < Lframe; i++ ) @@ -123,11 +115,7 @@ void Preemph_scaled( /* Equivalent to tmp = max((abs(x[i] - mu*x[i-1]),tmp) * finds the max of preemphasized signal */ L_tmp = L_mult( new_speech[i], QVal ); -#ifdef BASOP_NOGLOB L_tmp = L_msu_o( L_tmp, new_speech[i - 1], mu, &Overflow ); -#else /* BASOP_NOGLOB */ - L_tmp = L_msu( L_tmp, new_speech[i - 1], mu ); -#endif /* BASOP_NOGLOB */ L_tmp = L_abs( L_tmp ); L_maxloc = L_max( L_tmp, L_maxloc ); } @@ -177,29 +165,15 @@ void Preemph_scaled( FOR( i = sub( Lframe, 1 ); i > 0; i-- ) { L_tmp = L_mult( new_speech[i], QVal ); -#ifdef BASOP_NOGLOB L_tmp = L_msu_o( L_tmp, new_speech[i - 1], mu, &Overflow ); -#else /* BASOP_NOGLOB */ - L_tmp = L_msu( L_tmp, new_speech[i - 1], mu ); -#endif /* BASOP_NOGLOB */ L_tmp = L_shl( L_tmp, *Q_new ); -#ifdef BASOP_NOGLOB new_speech[i] = round_fx_sat( L_tmp ); // Q_new -#else - new_speech[i] = round_fx( L_tmp ); -#endif } L_tmp = L_mult( new_speech[0], QVal ); -#ifdef BASOP_NOGLOB L_tmp = L_msu_sat( L_tmp, *mem_preemph, mu ); L_tmp = L_shl_sat( L_tmp, *Q_new ); new_speech[0] = round_fx_sat( L_tmp ); -#else - L_tmp = L_msu( L_tmp, *mem_preemph, mu ); - L_tmp = L_shl( L_tmp, *Q_new ); - new_speech[0] = round_fx( L_tmp ); -#endif *mem_preemph = tmp_fixed; move16(); } @@ -255,21 +229,12 @@ Word32 Scale_mem_pre_proc( /* o : Min energy scaled /* Do scaling and valide minimum energy value */ FOR( i = 0; i < NB_BANDS; i++ ) { -#ifdef BASOP_NOGLOB enrO[i] = L_max( L_shl_o( enrO[i], Q_exp, &Overflow ), e_min_scaled ); bckr[i] = L_max( L_shl_o( bckr[i], Q_exp, &Overflow ), e_min_scaled ); ave_enr[i] = L_max( L_shl_o( ave_enr[i], Q_exp, &Overflow ), e_min_scaled ); ave_enr2[i] = L_max( L_shl_o( ave_enr2[i], Q_exp, &Overflow ), e_min_scaled ); st_fr_bands1[i] = L_max( L_shl_o( st_fr_bands1[i], Q_exp, &Overflow ), e_min_scaled ); st_fr_bands2[i] = L_max( L_shl_o( st_fr_bands2[i], Q_exp, &Overflow ), e_min_scaled ); -#else - enrO[i] = L_max( L_shl( enrO[i], Q_exp ), e_min_scaled ); - bckr[i] = L_max( L_shl( bckr[i], Q_exp ), e_min_scaled ); - ave_enr[i] = L_max( L_shl( ave_enr[i], Q_exp ), e_min_scaled ); - ave_enr2[i] = L_max( L_shl( ave_enr2[i], Q_exp ), e_min_scaled ); - st_fr_bands1[i] = L_max( L_shl( st_fr_bands1[i], Q_exp ), e_min_scaled ); - st_fr_bands2[i] = L_max( L_shl( st_fr_bands2[i], Q_exp ), e_min_scaled ); -#endif move32(); move32(); move32(); diff --git a/lib_enc/set_impulse_fx.c b/lib_enc/set_impulse_fx.c index 90a405d7cf70b49279cdf803f1c28b9df0329d1a..9ad5f4a2cdb9a4bab773a1008a6b70cb948771af 100644 --- a/lib_enc/set_impulse_fx.c +++ b/lib_enc/set_impulse_fx.c @@ -119,21 +119,12 @@ void set_impulse_fx( /* nominator & DEnominator row <0> */ FOR( i = 0; i < L_SUBFR; i++ ) { -#ifdef BASOP_NOGLOB Lrr = L_mac_o( Lrr, gh_fx[i], gh_fx[i], &Overflow ); // Q27 Ldd = L_mac_o( Ldd, gh_fx[i], xn_fx[i], &Overflow ); // Q27 -#else - Lrr = L_mac( Lrr, gh_fx[i], gh_fx[i] ); - Ldd = L_mac( Ldd, gh_fx[i], xn_fx[i] ); -#endif } rr_fx[start1] = Lrr; move32(); -#ifdef BASOP_NOGLOB dd_fx[start1] = round_fx_o( Ldd, &Overflow ); // Q11 -#else - dd_fx[start1] = round_fx( Ldd ); -#endif rr_fx[start1] = L_max( rr_fx[start1], 1 ); FOR( i = add( start1, 1 ); i < L_IMPULSE2; i++ ) @@ -147,26 +138,15 @@ void set_impulse_fx( gh_fx[j] = mac_r( L_deposit_h( gh_fx[j - 1] ), Glottal_cdbk_fx[m * L_IMPULSE + L_IMPULSE2 - i], h_orig_fx[j] ); // Q13 move16(); -#ifdef BASOP_NOGLOB Lrr = L_mac_o( Lrr, gh_fx[j], gh_fx[j], &Overflow ); // Q27 Ldd = L_mac_o( Ldd, gh_fx[j], xn_fx[j], &Overflow ); // Q27 -#else /* BASOP_NOGLOB */ - Lrr = L_mac( Lrr, gh_fx[j], gh_fx[j] ); - Ldd = L_mac( Ldd, gh_fx[j], xn_fx[j] ); -#endif /* BASOP_NOGLOB */ } gh_fx[0] = mult_r( Glottal_cdbk_fx[m * L_IMPULSE + L_IMPULSE2 - i], h_orig_fx[0] ); // Q13 move16(); -#ifdef BASOP_NOGLOB Lrr = L_mac_o( Lrr, gh_fx[0], gh_fx[0], &Overflow ); // Q27 Ldd = L_mac_o( Ldd, gh_fx[0], xn_fx[0], &Overflow ); // Q27 dd_fx[i] = round_fx_sat( Ldd ); // Q11 -#else /* BASOP_NOGLOB */ - Lrr = L_mac( Lrr, gh_fx[0], gh_fx[0] ); - Ldd = L_mac( Ldd, gh_fx[0], xn_fx[0] ); - dd_fx[i] = round_fx( Ldd ); -#endif rr_fx[i] = L_max( Lrr, 1 ); move32(); /* move rr and dd into rr[i] and dd[i] */ @@ -191,11 +171,7 @@ void set_impulse_fx( FOR( j = 1; j <= L_IMPULSE2; j++ ) { /*rr[L_SUBFR-1] += gh[j]*gh[j];*/ -#ifdef BASOP_NOGLOB Lrr = L_mac_sat( Lrr, gh_fx[j], gh_fx[j] ); // Q27 -#else - Lrr = L_mac( Lrr, gh_fx[j], gh_fx[j] ); -#endif } rr_fx[L_SUBFR - 1] = Lrr; move32(); @@ -203,13 +179,8 @@ void set_impulse_fx( FOR( i = L_SUBFR - 2; i >= start2; i-- ) { /*rr[i] = rr[i+1] + gh[L_SUBFR+L_IMPULSE2-1-i]*gh[L_SUBFR+L_IMPULSE2-1-i];*/ -#ifdef BASOP_NOGLOB rr_fx[i] = L_mac_o( rr_fx[i + 1], gh_fx[L_SUBFR + L_IMPULSE2 - 1 - i], gh_fx[L_SUBFR + L_IMPULSE2 - 1 - i], &Overflow ); // Q27 -#else - rr_fx[i] = L_mac( rr_fx[i + 1], gh_fx[L_SUBFR + L_IMPULSE2 - 1 - i], - gh_fx[L_SUBFR + L_IMPULSE2 - 1 - i] ); -#endif move32(); } /* nominator rows */ @@ -230,11 +201,7 @@ void set_impulse_fx( den = extract_h( L_shl( rr_fx[i], exp_den ) ); num = div_s( num, den ); -#ifdef BASOP_NOGLOB krit_fx = shr_o( num, sub( sub( shl_o( exp_num, 1, &Overflow ), exp_den ), 2 ), &Overflow ); /* Q18 */ -#else - krit_fx = shr( num, sub( sub( shl( exp_num, 1 ), exp_den ), 2 ) ); /* Q18 */ -#endif IF( GT_16( krit_fx, krit_max_fx ) ) { @@ -380,16 +347,8 @@ static void correlate_tc_fx( s = L_deposit_l( 0 ); FOR( j = i; j < L_1; j++ ) { -#ifdef BASOP_NOGLOB s = L_mac_sat( s, x[j], h[j - i] ); /* Qx + 16 */ -#else - s = L_mac( s, x[j], h[j - i] ); -#endif } -#ifdef BASOP_NOGLOB y[i] = round_fx_sat( s ); /* Qx */ -#else - y[i] = round_fx( s ); -#endif } } diff --git a/lib_enc/sig_clas_fx.c b/lib_enc/sig_clas_fx.c index 501f907b60aa73eb2126df1d8cdedee46325b026..cf5d31d22001c277a70040332e8c73383e4be02a 100644 --- a/lib_enc/sig_clas_fx.c +++ b/lib_enc/sig_clas_fx.c @@ -44,9 +44,9 @@ Word16 signal_clas_fx( /* o : classification for current frames */ Encoder_State *st, /* i/o: encoder state structure */ - const Word16 *speech, /* i : pointer to speech signal for E computation */ - const Word32 *ee, /* i : lf/hf E ration for 2 half-frames */ - const Word16 relE, /* i : frame relative E to the long term average */ + const Word16 *speech, /* i : pointer to speech signal for E computation in Qx */ + const Word32 *ee, /* i : lf/hf E ration for 2 half-frames in Q6 */ + const Word16 relE, /* i : frame relative E to the long term average in Q8 */ const Word16 L_look, /* i : look-ahead */ Word16 *clas_mod /* o : class flag for NOOP detection */ ) @@ -58,6 +58,7 @@ Word16 signal_clas_fx( /* o : classification for current const Word16 *pt1; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif /*----------------------------------------------------------------* @@ -68,7 +69,7 @@ Word16 signal_clas_fx( /* o : classification for current *----------------------------------------------------------------*/ /* average voicing on second half-frame and look-ahead */ - Ltmp = L_mult( st->voicing_fx[1], 16384 ); + Ltmp = L_mult( st->voicing_fx[1], 16384 ); /* Q15*Q14->Q30 */ mean_voi2 = mac_r( Ltmp, st->voicing_fx[2], 16384 ); /* average spectral tilt in dB */ @@ -101,7 +102,7 @@ Word16 signal_clas_fx( /* o : classification for current } /* compute zero crossing rate */ - pt1 = speech + L_look - 1; + pt1 = speech + sub( L_look, 1 ); tmpS = shr( *pt1, 15 ); /* sets 'tmpS to -1 if *pt1 < 0 */ Ltmp = L_deposit_l( 0 ); FOR( i = 0; i < L_FRAME; i++ ) @@ -116,7 +117,7 @@ Word16 signal_clas_fx( /* o : classification for current /* compute pitch stability */ pc = add( abs_s( sub( st->pitch[1], st->pitch[0] ) ), abs_s( sub( st->pitch[2], st->pitch[1] ) ) ); st->tdm_pc = pc; - + move16(); /*-----------------------------------------------------------------* * Transform parameters to the range <0:1> * Compute the merit function @@ -135,7 +136,7 @@ Word16 signal_clas_fx( /* o : classification for current zcn = s_max( zcn, 0 ); zcn = s_min( zcn, 512 ); - Ltmp = L_mult( C_RELE_FX, 256 ); /*Q15 ->Q24*/ + Ltmp = L_mult( C_RELE_FX, 256 ); /*Q15*Q8 ->Q24*/ relEn = round_fx( L_shl( L_mac( Ltmp, relE, K_RELE_FX ), 1 ) ); /*relE in Q8 but relEn in Q9*/ /* Limit [0.5, 1] */ relEn = s_max( relEn, 256 ); @@ -153,17 +154,14 @@ Word16 signal_clas_fx( /* o : classification for current Ltmp = L_mac( Ltmp, relEn, 10923 ); Ltmp = L_mac( Ltmp, pcn, 10923 ); -#ifdef BASOP_NOGLOB fmerit1 = round_fx_o( L_shl_o( Ltmp, 16 - 10 - 1, &Overflow ), &Overflow ); /* fmerit1 ->Q15 */ -#else - fmerit1 = round_fx( L_shl( Ltmp, 16 - 10 - 1 ) ); /* fmerit1 ->Q15 */ -#endif /*-----------------------------------------------------------------* * FEC classification *-----------------------------------------------------------------*/ - st->fmerit_dt = sub( st->prev_fmerit, fmerit1 ); + st->fmerit_dt = sub( st->prev_fmerit, fmerit1 ); /*Q15*/ + move16(); st->prev_fmerit = fmerit1; move16(); @@ -254,14 +252,14 @@ Word16 signal_clas_fx( /* o : classification for current /* tc_cnt == 1: onset/transition frame, coded by GC coder type */ /* tc_cnt == 2: frame after onset/transition frame, coded by TC coder type */ - if ( EQ_16( clas, UNVOICED_CLAS ) ) + if ( clas == 0 ) { st->tc_cnt = 0; move16(); } test(); - if ( GE_16( clas, VOICED_TRANSITION ) && st->tc_cnt >= 0 ) + IF( GE_16( clas, VOICED_TRANSITION ) && st->tc_cnt >= 0 ) { st->tc_cnt = add( st->tc_cnt, 1 ); move16(); @@ -323,7 +321,7 @@ void select_TC_fx( void coder_type_modif_fx( Encoder_State *st, /* i/o: encoder state structure */ - const Word16 relE /* i : frame relative E to the long term average */ + const Word16 relE /* i : frame relative E to the long term average Q8*/ ) { Word16 unmod_coder_type, vbr_generic_ho; @@ -354,8 +352,12 @@ void coder_type_modif_fx( /* At higher rates, use GC coding instead of UC coding to improve quality */ test(); - if ( ( EQ_16( st->element_mode, EVS_MONO ) && GT_32( st->total_brate, ACELP_9k60 ) && EQ_16( st->coder_type, UNVOICED ) ) || - ( GT_16( st->element_mode, EVS_MONO ) && GT_32( st->total_brate, MAX_UNVOICED_BRATE ) && EQ_16( st->coder_type, UNVOICED ) ) ) + test(); + test(); + test(); + test(); + if ( ( st->element_mode == 0 && GT_32( st->total_brate, ACELP_9k60 ) && EQ_16( st->coder_type, UNVOICED ) ) || + ( st->element_mode > 0 && GT_32( st->total_brate, MAX_UNVOICED_BRATE ) && EQ_16( st->coder_type, UNVOICED ) ) ) { st->coder_type = GENERIC; move16(); @@ -395,13 +397,13 @@ void coder_type_modif_fx( test(); IF( EQ_16( st->Opt_SC_VBR, 1 ) ) { + test(); if ( EQ_16( st->coder_type, GENERIC ) && EQ_16( unmod_coder_type, UNVOICED ) ) { hSC_VBR->vbr_generic_ho = 1; move16(); } - test(); if ( GT_16( st->coder_type, UNVOICED ) ) { hSC_VBR->vbr_generic_ho = 0; @@ -419,12 +421,12 @@ void coder_type_modif_fx( } //} closing bracket here in IVAS float, but not in EVS float. currently affects BE for switching bitrate on Linux 20220929 _DIFF_FLOAT_FIX_ !! - IF( EQ_16( st->element_mode, EVS_MONO ) ) + IF( st->element_mode == 0 ) { /* At higher rates and with 16kHz core, allow only GC and TC coder type */ test(); test(); - test(); + // test(); if ( GT_32( st->total_brate, ACELP_16k40 ) && NE_16( st->coder_type, GENERIC ) && NE_16( st->coder_type, TRANSITION ) ) { /* onset/transition frame is always coded using GC mode */ @@ -435,6 +437,9 @@ void coder_type_modif_fx( ELSE /*IVAS*/ { /* At higher bitrates, disable UC and VC coder type; note that IC coder type is classified later */ + test(); + test(); + test(); if ( ( GT_32( st->total_brate, MAX_VOICED_BRATE ) && EQ_16( st->coder_type, VOICED ) ) || ( GT_32( st->total_brate, MAX_UNVOICED_BRATE ) && EQ_16( st->coder_type, UNVOICED ) ) ) { @@ -447,7 +452,7 @@ void coder_type_modif_fx( test(); test(); test(); - if ( EQ_16( st->coder_type, VOICED ) && EQ_16( st->input_bwidth, NB ) && LT_16( relE, -2560 ) && LE_32( st->total_brate, ACELP_8k00 ) ) + if ( EQ_16( st->coder_type, VOICED ) && st->input_bwidth == 0 && LT_16( relE, -2560 ) && LE_32( st->total_brate, ACELP_8k00 ) ) { st->coder_type = GENERIC; move16(); @@ -493,8 +498,8 @@ void coder_type_modif_ivas_fx( test(); test(); test(); - if ( ( EQ_16( st->element_mode, EVS_MONO ) && GT_32( st->total_brate, ACELP_9k60 ) && EQ_16( st->coder_type, UNVOICED ) ) || - ( GT_16( st->element_mode, EVS_MONO ) && GT_32( st->total_brate, MAX_UNVOICED_BRATE ) && EQ_16( st->coder_type, UNVOICED ) ) ) + if ( ( st->element_mode == 0 && GT_32( st->total_brate, ACELP_9k60 ) && EQ_16( st->coder_type, UNVOICED ) ) || + ( st->element_mode > 0 && GT_32( st->total_brate, MAX_UNVOICED_BRATE ) && EQ_16( st->coder_type, UNVOICED ) ) ) { st->coder_type = GENERIC; move16(); @@ -530,7 +535,7 @@ void coder_type_modif_ivas_fx( move16(); } - IF( EQ_16( st->Opt_SC_VBR, 1 ) ) + if ( EQ_16( st->Opt_SC_VBR, 1 ) ) { test(); if ( EQ_16( st->coder_type, GENERIC ) && EQ_16( unmod_coder_type, UNVOICED ) ) @@ -555,7 +560,7 @@ void coder_type_modif_ivas_fx( } } - IF( EQ_16( st->element_mode, EVS_MONO ) ) + IF( st->element_mode == 0 ) { /* At higher rates and with 16kHz core, allow only GC and TC coder type */ test(); diff --git a/lib_enc/spec_center.c b/lib_enc/spec_center.c deleted file mode 100644 index 5cd8e2875deb519346d7148c847ad9a672078b2a..0000000000000000000000000000000000000000 --- a/lib_enc/spec_center.c +++ /dev/null @@ -1,42 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "prot.h" -#include "rom_enc.h" -#include "cnst.h" -#include "wmc_auto.h" diff --git a/lib_enc/spec_center_fx.c b/lib_enc/spec_center_fx.c index 920da568d721927e05f5e795583fbd17c7efefc4..1e908d0c388682b49e1d71d6807d6deb2e3be89e 100644 --- a/lib_enc/spec_center_fx.c +++ b/lib_enc/spec_center_fx.c @@ -18,9 +18,9 @@ *-------------------------------------------------------------------*/ void spec_center_fx( - Word32 *sb_power, /* i : energy of sub-band divided uniformly*/ - Word16 *sp_center, /* o : spectral center*/ - const Word32 bw_index, /* i : band width*/ + Word32 *sb_power, /* i : energy of sub-band divided uniformly Q31 */ + Word16 *sp_center, /* o : spectral center Q10 */ + const Word32 bw_index, /* i : band width Q0 */ const Word16 Q_sb_p /* i : the Scaling of sb_power*/ ) { @@ -48,15 +48,15 @@ void spec_center_fx( FOR( i = 0; i < 10; i++ ) { - sb_power_shr[i] = L_shr( sb_power[i], 5 ); + sb_power_shr[i] = L_shr( sb_power[i], 5 ); /* Q26 */ move32(); } FOR( i = 0; i < 10; i++ ) { - sb_power_mlt = Mpy_32_16_1( sb_power[i], i_t_1[i] ); - t_sp_center = L_add( L_shr( sb_power_mlt, 6 ), t_sp_center ); - frame_power = L_add( sb_power_shr[i], frame_power ); /*0-9 */ + sb_power_mlt = Mpy_32_16_1( sb_power[i], i_t_1[i] ); /* Q16 + QB */ + t_sp_center = L_add( L_shr( sb_power_mlt, 6 ), t_sp_center ); /* Q11 + QB */ + frame_power = L_add( sb_power_shr[i], frame_power ); /*0-9 */ /* Q26 */ } t_sp_center_nb = t_sp_center; @@ -68,16 +68,17 @@ void spec_center_fx( Q_t_sc = sub( Q_sb_p, 10 ); IF( GE_16( Q_t_sc, 34 ) ) { - t_sp_center = L_shr( t_sp_center, sub( Q_t_sc, 33 ) ); - zerop1 = L_shr( CNT0P1, 1 ); + t_sp_center = L_shr( t_sp_center, sub( Q_t_sc, 33 ) ); /* Q44 + QB - Q_t_sc)*/ + zerop1 = CNT0P1 >> 1; /* Q33 */ + move32(); Q_t_sc = 33; move16(); } ELSE { - Q_t_sc = sub( Q_t_sc, 1 ); - t_sp_center = L_shr( t_sp_center, 1 ); - zerop1 = L_shr( CNT0P1, sub( 34, Q_t_sc ) ); + Q_t_sc = sub( Q_t_sc, 1 ); /* Q_t_sc - 1 */ + t_sp_center = L_shr( t_sp_center, 1 ); /* Q10 + QB */ + zerop1 = L_shr( CNT0P1, sub( 34, Q_t_sc ) ); /* Q_t_sc */ } t_sp_center_num = L_add( t_sp_center, zerop1 ); @@ -85,7 +86,8 @@ void spec_center_fx( IF( GE_16( Q_f_p, 34 ) ) { frame_power = L_shr( frame_power, sub( Q_f_p, 33 ) ); - zerop1 = L_shr( CNT0P1, 1 ); + zerop1 = ( CNT0P1 >> 1 ); + move32(); Q_f_p = 33; move16(); } @@ -120,9 +122,9 @@ void spec_center_fx( d_t_sp_center = shr( d_t_sp_center, d_t_sp_center_Qtmp ); sp_center[0] = add( mult( sp_center[0], 0x5999 ), mult( d_t_sp_center, 0x2666 ) ); - move16(); sp_center[2] = d_t_sp_center; move16(); + move16(); t_sp_center = 0; move32(); @@ -148,7 +150,8 @@ void spec_center_fx( IF( GE_16( Q_t_sc, 34 ) ) { t_sp_center = L_shr( t_sp_center, sub( Q_t_sc, 33 ) ); - zerop1 = L_shr( CNT0P1, 1 ); + zerop1 = ( CNT0P1 >> 1 ); + move32(); Q_t_sc = 33; move16(); } @@ -221,7 +224,8 @@ void spec_center_fx( IF( GE_16( Q_t_sc, 34 ) ) { t_sp_center = L_shr( t_sp_center, limitScale32( sub( Q_t_sc, 33 ) ) ); - zerop1 = L_shr( CNT0P1, 1 ); + zerop1 = ( CNT0P1 >> 1 ); + move32(); Q_t_sc = 33; move16(); } @@ -237,7 +241,8 @@ void spec_center_fx( IF( GE_16( Q_f_p, 34 ) ) { frame_power = L_shr( frame_power, sub( Q_f_p, 33 ) ); - zerop1 = L_shr( CNT0P1, 1 ); + zerop1 = ( CNT0P1 >> 1 ); + move32(); Q_f_p = 33; move16(); } diff --git a/lib_enc/spec_flatness.c b/lib_enc/spec_flatness.c deleted file mode 100644 index 68731d8f1702d45c4fc58916c47fef083afa1903..0000000000000000000000000000000000000000 --- a/lib_enc/spec_flatness.c +++ /dev/null @@ -1,42 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include -#include "options.h" -#include -#include "prot.h" -#include "wmc_auto.h" diff --git a/lib_enc/spec_flatness_fx.c b/lib_enc/spec_flatness_fx.c index 2ee10bf068b1469a7a2e455367b9d106b52b8123..c2451886dac977208e677dc5ca833459b53afa5e 100644 --- a/lib_enc/spec_flatness_fx.c +++ b/lib_enc/spec_flatness_fx.c @@ -104,7 +104,8 @@ void spec_flatness_fx( IF( GE_16( prods_Q, 34 ) ) { prods = L_shr( prods, sub( prods_Q, 33 ) ); - zerop1 = L_shr( CNT0P1, 1 ); + zerop1 = CNT0P1 >> 1; + move32(); prods_Q = 33; move16(); } @@ -116,7 +117,8 @@ void spec_flatness_fx( } prods = L_add( prods, zerop1 ); - zerop1 = L_shr( CNT0P1, 20 ); + zerop1 = CNT0P1 >> 20; + move32(); sums = L_add( sums, zerop1 ); /*div*/ @@ -188,7 +190,8 @@ void spec_flatness_fx( IF( GE_16( prods_Q, 34 ) ) { prods = L_shr( prods, sub( prods_Q, 33 ) ); - zerop1 = L_shr( CNT0P1, 1 ); + zerop1 = CNT0P1 >> 1; + move32(); prods_Q = 33; move16(); } @@ -200,7 +203,8 @@ void spec_flatness_fx( } prods = L_add( prods, zerop1 ); - zerop1 = L_shr( CNT0P1, 20 ); + zerop1 = CNT0P1 >> 20; + move32(); sums = L_add( sums, zerop1 ); /*div*/ @@ -217,7 +221,12 @@ 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*/ sums = 0; @@ -271,7 +280,8 @@ void spec_flatness_fx( IF( GE_16( prods_Q, 34 ) ) { prods = L_shr( prods, sub( prods_Q, 33 ) ); - zerop1 = L_shr( CNT0P1, 1 ); + zerop1 = CNT0P1 >> 1; + move32(); prods_Q = 33; move16(); } @@ -283,7 +293,8 @@ void spec_flatness_fx( } prods = L_add( prods, zerop1 ); - zerop1 = L_shr( CNT0P1, 20 ); + zerop1 = CNT0P1 >> 20; + move32(); sums = L_add( sums, zerop1 ); /*div*/ @@ -300,10 +311,6 @@ void spec_flatness_fx( SFM_Qtmp = sub( SFM_Qtmp, SPEC_AMP_Q ); SFM_Qtmp = sub( SFM_Qtmp, SFM_Q ); -#ifdef BASOP_NOGLOB sSFM[2] = add_sat( mult( sSFM[2], 0x6ccc ), shr_sat( mult( SFM, 0x1333 ), SFM_Qtmp ) ); -#else - sSFM[2] = add( mult( sSFM[2], 0x6ccc ), shr( mult( SFM, 0x1333 ), SFM_Qtmp ) ); -#endif move16(); } diff --git a/lib_enc/speech_music_classif.c b/lib_enc/speech_music_classif.c deleted file mode 100644 index 514f654cb83eceb9d6adabce02e9bf97f1ccc6fc..0000000000000000000000000000000000000000 --- a/lib_enc/speech_music_classif.c +++ /dev/null @@ -1,46 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include -#include "options.h" -#include -#include "cnst.h" -#include "prot.h" -#include "ivas_prot.h" -#include "rom_enc.h" -#include "rom_com.h" /* Common static table prototypes */ -#include "wmc_auto.h" diff --git a/lib_enc/speech_music_classif_fx.c b/lib_enc/speech_music_classif_fx.c index b088e6efd0570dff4fca9ad48b2d51c7d9592d9a..32b521ef46060a8c68b6bdcc932f9220f458847f 100644 --- a/lib_enc/speech_music_classif_fx.c +++ b/lib_enc/speech_music_classif_fx.c @@ -89,7 +89,7 @@ void speech_music_clas_init_fx( SP_MUS_CLAS_HANDLE hSpMusClas /* i/o: speech/music classifier handle */ ) { - int16_t i; + Word16 i; hSpMusClas->inact_cnt = 0; @@ -203,11 +203,14 @@ void speech_music_clas_init_fx( hSpMusClas->lt_dec_thres_fx = 5120; move16(); /*10 in Q9 */ hSpMusClas->ener_RAT_fx = 0; + move16(); /* speech/music classification */ set16_fx( hSpMusClas->lt_old_mode, 1, 3 ); hSpMusClas->lt_voicing = 16384 /*0.5f Q15*/; + move16(); hSpMusClas->lt_corr = 16384 /*0.5f Q15*/; + move16(); hSpMusClas->lt_tonality = 0; move32(); set16_fx( hSpMusClas->lt_corr_pitch, 0, 3 ); @@ -268,8 +271,8 @@ void speech_music_clas_init_ivas_fx( hSpMusClas->sp_mus_state = -8; move16(); - hSpMusClas->wdrop_fx = 0; - move16(); + hSpMusClas->wdrop_32fx = 0; + move32(); hSpMusClas->wrise_fx = 0; move16(); hSpMusClas->wdlp_0_95_sp_fx = 0; @@ -389,6 +392,8 @@ void speech_music_clas_init_ivas_fx( move16(); set32_fx( hSpMusClas->finc_prev_fx, 0, ATT_NSEG ); + hSpMusClas->q_finc_prev = Q31; + move16(); hSpMusClas->lt_finc_fx = 0; move32(); hSpMusClas->Q_lt_finc = Q31; @@ -510,13 +515,13 @@ void speech_music_classif_fx( } st->sp_aud_decision0 = st->sp_aud_decision1; - + move16(); /* 2nd stage speech/music classifier (rewrite music to speech in onsets) */ st->sp_aud_decision2 = st->sp_aud_decision1; move16(); - IF( GT_16( st->bwidth, NB ) ) + IF( st->bwidth > NB ) { sp_mus_classif_2nd_fx( st, Etot, attack_flag, inp, Q_inp - 1 ); @@ -582,8 +587,6 @@ void speech_music_classif_fx( /* Select AUDIO frames */ test(); test(); - test(); - test(); #ifdef DEBUGGING if ( st->codec_mode == MODE1 && ( st->force == 1 || ( st->force == -1 && ( st->sp_aud_decision2 || st->GSC_noisy_speech ) ) ) ) #else @@ -599,6 +602,7 @@ void speech_music_classif_fx( ELSE { st->sp_aud_decision0 = st->sp_aud_decision1; + move16(); } @@ -649,14 +653,29 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis Word32 dPS[128], PS_norm[128]; Word32 lepsP1; Word32 max_s = 0, max_m = 0, py_s, py_m; + move32(); + move32(); Word32 max_n, py_n; /* pyn */ Word16 ishift[12] = { 8, 0, 2, 2, 2, 2, 2, 1, 0, 2, 2, 1 }; + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); Word16 tmp; Word16 tmp1, tmp2, exp2, scale, exp3; SP_MUS_CLAS_HANDLE hSpMusClas = st_fx->hSpMusClas; HQ_ENC_HANDLE hHQ_core = st_fx->hHQ_core; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move16(); #endif /*------------------------------------------------------------------* @@ -685,6 +704,7 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis ELSE { *pFV++ = round_fx( L_tmp ); + move16(); } /* [1] voicing Q15 */ @@ -700,11 +720,8 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis L_tmp = L_mult( st_fx->voicing_fx[0], 10923 ); L_tmp = L_mac( L_tmp, st_fx->voicing_fx[1], 10923 ); L_tmp = L_mac( L_tmp, st_fx->voicing_fx[2], 10923 ); -#ifdef BASOP_NOGLOB *pFV++ = round_fx_sat( L_tmp ); -#else - *pFV++ = round_fx( L_tmp ); -#endif + move16(); } /* [2,3,4,5,6] LSFs Q15*/ @@ -727,11 +744,13 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis /* [7] cor_map_sum Q8 */ *pFV++ = round_fx( L_mac( L_mult( cor_map_sum, 16384 ), hSpMusClas->last_cor_map_sum_fx, 16384 ) ); /* Q8 ->Q7*/ + move16(); hSpMusClas->last_cor_map_sum_fx = cor_map_sum; move16(); /* [8] non_sta Q8*/ *pFV++ = round_fx( L_mac( L_mult( non_sta, 16384 ), hSpMusClas->last_non_sta_fx, 16384 ) ); /* Q8 -> Q7 */ + move16(); hSpMusClas->last_non_sta_fx = non_sta; move16(); @@ -786,18 +805,10 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis sum_PS = L_deposit_l( 0 ); FOR( i = LOWEST_FBIN; i < HIGHEST_FBIN; i++ ) { -#ifdef BASOP_NOGLOB sum_PS = L_add_o( sum_PS, PS[i], &Overflow ); -#else /* BASOP_NOGLOB */ - sum_PS = L_add( sum_PS, PS[i] ); -#endif /* BASOP_NOGLOB */ } exp1 = norm_l( sum_PS ); -#ifdef BASOP_NOGLOB tmp1 = round_fx_o( L_shl( sum_PS, exp1 ), &Overflow ); -#else /* BASOP_NOGLOB */ - tmp1 = round_fx( L_shl( sum_PS, exp1 ) ); -#endif /* BASOP_NOGLOB */ exp1 = sub( 30, exp1 ); FOR( i = LOWEST_FBIN; i < HIGHEST_FBIN; i++ ) @@ -805,11 +816,7 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis /*PS_norm[i] = PS[i] / sum_PS;*/ /*dPS[i] = (float)fabs(PS_norm[i] - st->past_PS[i]);*/ exp2 = norm_l( PS[i] ); -#ifdef BASOP_NOGLOB tmp2 = round_fx_o( L_shl( PS[i], exp2 ), &Overflow ); -#else /* BASOP_NOGLOB */ - tmp2 = round_fx( L_shl( PS[i], exp2 ) ); -#endif /* BASOP_NOGLOB */ exp2 = sub( 30, exp2 ); scale = shr( sub( tmp1, tmp2 ), 15 ); @@ -879,11 +886,7 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis ELSE { exp1 = norm_l( L_add( dPS[i], 336 ) ); -#ifdef BASOP_NOGLOB tmp1 = round_fx_o( L_shl_o( L_add( dPS[i], 336 ), exp1, &Overflow ), &Overflow ); -#else - tmp1 = round_fx( L_shl( L_add( dPS[i], 336 ), exp1 ) ); -#endif exp1 = sub( 30, exp1 ); exp2 = norm_l( mx ); @@ -895,16 +898,11 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis exp2 = sub( exp2, scale ); exp3 = sub( exp1, exp2 ); - move16(); tmp = div_s( tmp2, tmp1 ); /*Q(15+exp3) */ L_tmp = L_shl( tmp, sub( 1, exp3 ) ); /*Q16 */ #ifdef FIX_ISSUE_1151 -#ifdef BASOP_NOGLOB ps_sta = L_add_sat( ps_sta, L_tmp ); /*Q16 */ -#else - ps_sta = L_add( ps_sta, L_tmp ); /*Q16 */ -#endif #else ps_sta = L_add( ps_sta, L_tmp ); /*Q16 */ #endif @@ -913,11 +911,7 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis /**pFV++ = (float)log(ps_sta + 1e-5f);*/ #ifdef FIX_ISSUE_1151 -#ifdef BASOP_NOGLOB ps_sta = L_add_sat( ps_sta, 336 ); -#else - ps_sta = L_add( ps_sta, 336 ); -#endif #else ps_sta = L_add( ps_sta, 336 ); #endif @@ -926,6 +920,7 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis e_tmp = sub( 30 - 16, e_tmp ); L_tmp = Mpy_32_16( e_tmp, f_tmp, 22713 ); /* Q16 */ /* 22713 = ln(2) in Q15 */ *pFV++ = round_fx( L_shl( L_tmp, 11 ) ); /*Q11 */ + move16(); /* update PS vector */ Copy32( &PS_norm[LOWEST_FBIN], hSpMusClas->past_PS_fx, HIGHEST_FBIN - LOWEST_FBIN ); @@ -942,7 +937,6 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis pFV = FV; - move16(); IF( EQ_16( st_fx->bwidth, NB ) ) { pSF_m = SF_8k_mult_fx; @@ -957,11 +951,8 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis FOR( i = 0; i < N_FEATURES; i++ ) { /**pFV = pSF[0] * *pFV + pSF[1];*/ -#ifdef BASOP_NOGLOB *pFV = round_fx_o( L_shl_o( L_mac( pSF_a[i], *pFV, pSF_m[i] ), ishift[i], &Overflow ), &Overflow ); -#else /* BASOP_NOGLOB */ - *pFV = round_fx( L_shl( L_mac( pSF_a[i], *pFV, pSF_m[i] ), ishift[i] ) ); -#endif /* BASOP_NOGLOB */ + move16(); pFV++; } @@ -991,11 +982,7 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis FOR( p = 0; p < N_FEATURES; p++ ) { /* xm[p] = FV[p] - m_speech[k*N_FEATURES+p];*/ -#ifdef BASOP_NOGLOB xm[p] = sub_o( FV[p], m_speech_fx[k * N_FEATURES + p], &Overflow ); -#else /* BASOP_NOGLOB */ - xm[p] = sub( FV[p], m_speech_fx[k * N_FEATURES + p] ); -#endif /* BASOP_NOGLOB */ move16(); /*Q15 */ } @@ -1011,11 +998,7 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis FOR( p = 0; p < N_FEATURES; p++ ) { /*xm[p] = FV[p] - m_noise[k*N_FEATURES+p];*/ -#ifdef BASOP_NOGLOB xm[p] = sub_o( FV[p], m_noise_fx[k * N_FEATURES + p], &Overflow ); -#else /* BASOP_NOGLOB */ - xm[p] = sub( FV[p], m_noise_fx[k * N_FEATURES + p] ); -#endif /* BASOP_NOGLOB */ move16(); /*Q15 */ } @@ -1030,11 +1013,7 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis FOR( p = 0; p < N_FEATURES; p++ ) { /*xm[p] = FV[p] - m_music[k*N_FEATURES+p];*/ -#ifdef BASOP_NOGLOB xm[p] = sub_o( FV[p], m_music_fx[k * N_FEATURES + p], &Overflow ); -#else /* BASOP_NOGLOB */ - xm[p] = sub( FV[p], m_music_fx[k * N_FEATURES + p] ); -#endif /* BASOP_NOGLOB */ move16(); /*Q15 */ } @@ -1048,11 +1027,7 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis /* calculate log-probability */ /*log(0.0001)-0.5f * N_FEATURES * LOG_PI2 in Q9 */ -#ifdef BASOP_NOGLOB lps = extract_h( L_shl_o( L_sub( max_s, LOG_PROB_CONST ), 16 - 1, &Overflow ) ); /*Q9 */ -#else /* BASOP_NOGLOB */ - lps = extract_h( L_shl( L_sub( max_s, LOG_PROB_CONST ), 16 - 1 ) ); /*Q9 */ -#endif /* BASOP_NOGLOB */ lps = s_max( lps, -10832 ); lpm = extract_h( L_shl( L_sub( max_m, LOG_PROB_CONST ), 16 - 1 ) ); /*Q9 */ @@ -1060,11 +1035,7 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis /* lpn = (float)log(pyn) - 0.5f * N_FEATURES * (float)log(2*PI); */ -#ifdef BASOP_NOGLOB lpn = extract_h( L_shl_o( L_sub( max_n, LOG_PROB_CONST ), 16 - 1, &Overflow ) ); /*Q9 */ -#else /* BASOP_NOGLOB */ - lpn = extract_h( L_shl( L_sub( max_n, LOG_PROB_CONST ), 16 - 1 ) ); /*Q9 */ -#endif /* BASOP_NOGLOB */ lpn = s_max( lpn, -10832 ); *high_lpn_flag_ptr = 0; @@ -1396,7 +1367,7 @@ static void sp_mus_classif_2nd_fx( move16(); test(); - IF( EQ_16( st->codec_mode, MODE1 ) && EQ_16( st->coder_type, TRANSITION ) ) + if ( EQ_16( st->codec_mode, MODE1 ) && EQ_16( st->coder_type, TRANSITION ) ) { st->coder_type = GENERIC; move16(); @@ -1410,7 +1381,7 @@ static void sp_mus_classif_2nd_fx( st->sp_aud_decision2 = 0; move16(); - IF( EQ_16( st->codec_mode, MODE1 ) ) + if ( EQ_16( st->codec_mode, MODE1 ) ) { st->coder_type = TRANSITION; move16(); @@ -1425,19 +1396,19 @@ static void sp_mus_classif_2nd_fx( move16(); *attack_flag = add( attack, 1 ); move16(); - IF( EQ_16( st->codec_mode, MODE1 ) ) + if ( EQ_16( st->codec_mode, MODE1 ) ) { st->coder_type = TRANSITION; move16(); } } - ELSE IF( GE_16( attack, ATT_SEG_LEN / 2 ) ) + ELSE IF( GE_16( attack, ATT_SEG_LEN >> 1 ) ) { /* do GSC coding if attack is located after the first quarter of the first subframe */ /* (pre-echo will be treated at the decoder side) */ st->sp_aud_decision2 = 1; - *attack_flag = 31; move16(); + *attack_flag = 31; move16(); } } @@ -1450,7 +1421,7 @@ static void sp_mus_classif_2nd_fx( /* do TC coding if attack is located in the last subframe */ *attack_flag = add( attack, 1 ); move16(); - IF( EQ_16( st->codec_mode, MODE1 ) ) + if ( EQ_16( st->codec_mode, MODE1 ) ) { st->coder_type = TRANSITION; move16(); @@ -1490,7 +1461,7 @@ static void var_cor_calc_fx( *high_stable_cor = 0; move16(); test(); - IF( GT_16( *mold_corr, 26214 ) && LT_16( var_cor, 2 ) ) + if ( GT_16( *mold_corr, 26214 ) && LT_16( var_cor, 2 ) ) { *high_stable_cor = 1; move16(); @@ -1534,6 +1505,7 @@ static Word16 attack_det_fx( /* o : attack flag #endif #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move16(); #endif att_3lsub_pos = ATT_3LSUB_POS; @@ -1551,11 +1523,7 @@ static Word16 attack_det_fx( /* o : attack flag FOR( j = 1; j < ATT_SEG_LEN; j++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_mac0_o( L_tmp, inp[i * ATT_SEG_LEN + j], inp[i * ATT_SEG_LEN + j], &Overflow ); /*2*Qx */ -#else /* BASOP_NOGLOB */ - L_tmp = L_mac0( L_tmp, inp[i * ATT_SEG_LEN + j], inp[i * ATT_SEG_LEN + j] ); /*2*Qx */ -#endif /* BASOP_NOGLOB */ } finc[i] = L_tmp; @@ -1565,6 +1533,7 @@ static Word16 attack_det_fx( /* o : attack flag attack = maximum_32_fx( finc, ATT_NSEG, &etmp ); #ifdef IVAS_CODE attack1 = attack; + move16(); #endif move16(); test(); @@ -1579,19 +1548,11 @@ static Word16 attack_det_fx( /* o : attack flag exp1 = norm_s( att_3lsub_pos ); tmp = div_s( shl( 1, sub( 14, exp1 ) ), att_3lsub_pos ); /*Q(29-exp1) */ -#ifdef BASOP_NOGLOB L_tmp = L_shr_o( finc[0], Qx, &Overflow ); /*Qx */ -#else /* BASOP_NOGLOB */ - L_tmp = L_shr( finc[0], Qx ); /*Qx */ -#endif /* BASOP_NOGLOB */ FOR( i = 1; i < att_3lsub_pos; i++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_add_o( L_tmp, L_shr_o( finc[i], Qx, &Overflow ), &Overflow ); /*Qx */ -#else /* BASOP_NOGLOB */ - L_tmp = L_add( L_tmp, L_shr( finc[i], Qx ) ); /*Qx */ -#endif /* BASOP_NOGLOB */ } L_tmp = Mult_32_16( L_tmp, tmp ); /*Q(14-exp1+Qx) */ etmp = L_shl( L_tmp, sub( exp1, 14 ) ); /*Qx */ @@ -1600,18 +1561,10 @@ static Word16 attack_det_fx( /* o : attack flag exp1 = norm_s( tmp1 ); tmp = div_s( shl( 1, sub( 14, exp1 ) ), tmp1 ); /*Q(29-exp1) */ -#ifdef BASOP_NOGLOB L_tmp = L_shr_o( finc[attack], Qx, &Overflow ); /*Qx */ -#else /* BASOP_NOGLOB */ - L_tmp = L_shr( finc[attack], Qx ); /*Qx */ -#endif /* BASOP_NOGLOB */ FOR( i = 1; i < tmp1; i++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_add_o( L_tmp, L_shr_o( finc[i + attack], Qx, &Overflow ), &Overflow ); /*Qx */ -#else /* BASOP_NOGLOB */ - L_tmp = L_add( L_tmp, L_shr( finc[i + attack], Qx ) ); /*Qx */ -#endif /* BASOP_NOGLOB */ } L_tmp = Mult_32_16( L_tmp, tmp ); /*Q(14-exp1+Qx) */ etmp2 = L_shl( L_tmp, sub( exp1, 14 ) ); /*Qx */ @@ -1696,8 +1649,8 @@ static Word16 attack_det_fx( /* o : attack flag } #ifdef IVAS_CODE *last_strong_attack = 0; -#endif move16(); +#endif } return attack; @@ -1756,6 +1709,7 @@ Word16 ivas_smc_gmm_fx( Word32 temp32_log1, temp32_log2; Word16 temp16; Word16 dotp_exp = 0; + move16(); /*------------------------------------------------------------------* * Initialization *------------------------------------------------------------------*/ @@ -1814,14 +1768,15 @@ Word16 ivas_smc_gmm_fx( hSpMusClas->sp_mus_state = add( hSpMusClas->sp_mus_state, 1 ); } + test(); IF( hSpMusClas->sp_mus_state < 0 && hSpMusClas->inact_cnt > 0 ) { hSpMusClas->inact_cnt = sub( hSpMusClas->inact_cnt, 1 ); + move16(); } } ELSE { - test(); test(); IF( hSpMusClas->sp_mus_state > 0 && LT_16( hSpMusClas->sp_mus_state, HANG_LEN ) ) { @@ -1833,6 +1788,7 @@ Word16 ivas_smc_gmm_fx( hSpMusClas->inact_cnt = sub( hSpMusClas->inact_cnt, 1 ); } + test(); IF( hSpMusClas->sp_mus_state > 0 && LT_16( hSpMusClas->sp_mus_state, HANG_LEN ) ) { hSpMusClas->sp_mus_state = -HANG_LEN; @@ -1903,8 +1859,8 @@ Word16 ivas_smc_gmm_fx( ELSE { hSpMusClas->relE_attack_cnt = 0; - relE_attack_flag = 0; move16(); + relE_attack_flag = 0; move16(); } @@ -1948,42 +1904,53 @@ Word16 ivas_smc_gmm_fx( move16(); temp16 = lsp_new_fx[2]; move16(); + temp32 = L_sub( ONE_IN_Q30, L_mult0( temp16, temp16 ) ); // Q30 temp_sqrt = Sqrt32( temp32, &temp_exp ); temp_acos = BASOP_util_atan2( temp_sqrt, L_deposit_h( temp16 ), temp_exp ); *pFV_fx++ = L_shl( temp_acos, Q7 ); // Q20 + move32(); temp_exp = 1; move16(); temp16 = lsp_new_fx[3]; move16(); + temp32 = L_sub( ONE_IN_Q30, L_mult0( temp16, temp16 ) ); // Q30 temp_sqrt = Sqrt32( temp32, &temp_exp ); temp_acos = BASOP_util_atan2( temp_sqrt, L_deposit_h( temp16 ), temp_exp ); *pFV_fx++ = L_shl( temp_acos, Q7 ); // Q20 + move32(); temp_exp = 1; move16(); temp16 = lsp_new_fx[4]; move16(); + temp32 = L_sub( ONE_IN_Q30, L_mult0( temp16, temp16 ) ); // Q30 temp_sqrt = Sqrt32( temp32, &temp_exp ); temp_acos = BASOP_util_atan2( temp_sqrt, L_deposit_h( temp16 ), temp_exp ); *pFV_fx++ = L_shl( temp_acos, Q7 ); // Q20 + move32(); temp_exp = 1; move16(); temp16 = lsp_new_fx[5]; move16(); + temp32 = L_sub( ONE_IN_Q30, L_mult0( temp16, temp16 ) ); // Q30 temp_sqrt = Sqrt32( temp32, &temp_exp ); temp_acos = BASOP_util_atan2( temp_sqrt, L_deposit_h( temp16 ), temp_exp ); *pFV_fx++ = L_shl( temp_acos, Q7 ); // Q20 + move32(); temp_exp = 1; move16(); temp16 = lsp_new_fx[6]; move16(); + + temp32 = L_sub( ONE_IN_Q30, L_mult0( temp16, temp16 ) ); // Q30 temp_sqrt = Sqrt32( temp32, &temp_exp ); temp_acos = BASOP_util_atan2( temp_sqrt, L_deposit_h( temp16 ), temp_exp ); *pFV_fx++ = L_shl( temp_acos, Q7 ); // Q20 + move32(); // temf = acosf( lsp_new[2] ); /* [2,3,4,5,6] LSFs */ /* *pFV++ = acosf( lsp_new[2] ); @@ -2002,12 +1969,10 @@ Word16 ivas_smc_gmm_fx( /* [9] epsP */ temp32 = L_add( epsP_fx[14], L_shr( 21475, sub( 31, Q_esp ) ) ); - move32(); temp32_log = L_add( BASOP_Util_Log2( temp32 ), L_shl( sub( Q31, Q_esp ), Q25 ) ); temp32_log1 = Mpy_32_32( temp32_log, 1488522239 ); /*logf(x) = log2(x)*logf(2)*/ temp32 = L_add( epsP_fx[0], L_shr( 21475, sub( 31, Q_esp ) ) ); - move32(); temp32_log = L_add( BASOP_Util_Log2( temp32 ), L_shl( sub( Q31, Q_esp ), Q25 ) ); temp32_log2 = Mpy_32_32( temp32_log, 1488522239 ); /*logf(x) = log2(x)*logf(2)*/ @@ -2019,7 +1984,6 @@ Word16 ivas_smc_gmm_fx( set_zero_fx( melS_fx, NB_MEL_BANDS ); pt_mel_fb_fx = mel_fb_fx; - move32(); FOR( i = 0; i < NB_MEL_BANDS; i++ ) { @@ -2043,18 +2007,22 @@ Word16 ivas_smc_gmm_fx( } Word16 guard_bits = find_guarded_bits_fx( NB_MEL_BANDS ); + move16(); v_mult_mat_fixed( mfcc_fx, melS_fx, dct_mtx_fx, NB_MEL_BANDS, NB_MEL_COEF, guard_bits ); // Q19 *pFV_fx++ = L_shl( mfcc_fx[2], 1 ); // Q20 + move32(); *pFV_fx++ = L_shl( mfcc_fx[6], 1 ); + move32(); *pFV_fx++ = L_shl( mfcc_fx[12], 1 ); + move32(); /* *pFV++ = mfcc[2]; *pFV++ = mfcc[6]; *pFV++ = mfcc[12];*/ /* calculation of differential normalized power spectrum */ sum_PS_fx = 0; - Word16 sum_PS_e = 0; move32(); + Word16 sum_PS_e = 0; move16(); Word64 sum = W_shl( 21475 /* 1e-5 in Q31 */, sub( Qfact_PS, 30 ) ); // Qfact_PS+1 move64(); @@ -2106,13 +2074,14 @@ Word16 ivas_smc_gmm_fx( 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 - move32(); ps_sta_fx = BASOP_Util_Add_Mant32Exp( temp32, temp_exp, ps_sta_fx, ps_sta_exp, &ps_sta_exp ); } } @@ -2141,8 +2110,8 @@ Word16 ivas_smc_gmm_fx( hStereoClassif->ps_sta_ch2_e = 6; // logf( ps_sta + 1e-5f );Q25 } move32(); - move32(); move16(); + move32(); move16(); } @@ -2160,6 +2129,7 @@ Word16 ivas_smc_gmm_fx( move16(); FOR( i = 0; i < N_SMC_FEATURES; i++ ) { + test(); IF( LT_32( *pFV_fx, pODV_fx[0] ) || GT_32( *pFV_fx, pODV_fx[1] ) ) { *p_out++ = i; @@ -2197,6 +2167,8 @@ Word16 ivas_smc_gmm_fx( { //*pFV_st = smc_st_mean_fact * ( *pFV_st ) + ( 1 - smc_st_mean_fact ) * ( *pFV ); *pFV_st_fx = L_add( L_shr( *pFV_st_fx, smc_st_mean_fact_fx ), L_shr( *pFV_fx, 1 ) ); + move32(); + test(); test(); test(); @@ -2218,6 +2190,7 @@ Word16 ivas_smc_gmm_fx( ELSE { *pFV_fx++ = *pFV_st_fx++; + move32(); } } @@ -2232,15 +2205,17 @@ Word16 ivas_smc_gmm_fx( IF( bcox_lmbd_fx[i] != 0 ) { *pFV_fx = L_sub( *pFV_fx, L_shr( bcox_add_cnst_fx[i], sub( 31, Qfact_FV ) ) ); + move32(); IF( LT_32( *pFV_fx, L_shl( 1, Qfact_FV ) ) ) { *pFV_fx = L_shl( 1, Qfact_FV ); + move32(); } Word16 pow_e = 0; move32(); temp32_log = L_add( BASOP_Util_Log2( *pFV_fx ), L_shl( sub( 31, Qfact_FV ), Q25 ) ); // Q25 temp32 = Mpy_32_32( temp32_log, bcox_lmbd_fx[i] ); // Q25 - Word32 pow_temp = BASOP_util_Pow2( temp32, sub( 31, Q25 ), &pow_e ); + Word32 pow_temp = BASOP_util_Pow2( temp32, 31 - Q25, &pow_e ); IF( pow_e <= 0 ) { pow_temp = L_shr( pow_temp, sub( 1, pow_e ) ); @@ -2251,6 +2226,7 @@ Word16 ivas_smc_gmm_fx( move32(); temp32 = L_deposit_h( BASOP_Util_Divide3232_Scale( temp32, bcox_lmbd_fx[i], &temp_exp ) ); *pFV_fx = L_shl( temp32, sub( Qfact_FV, sub( 31, add( temp_exp, pow_e ) ) ) ); + move32(); // float temp = powf( *pFV, bcox_lmbd[i] ); // *pFV = ( powf( *pFV, bcox_lmbd[i] ) - 1 ) / bcox_lmbd[i]; } @@ -2270,8 +2246,11 @@ Word16 ivas_smc_gmm_fx( // *pFV = ( *pFV - sm_means[i] ) / sm_scale[i]; temp32 = L_sub( *pFV_fx, sm_means_fx[i] ); temp_exp = 0; + move16(); temp32 = L_deposit_h( BASOP_Util_Divide3232_Scale( temp32, sm_scale_fx[i], &temp_exp ) ); - *pFV_fx = L_shl( temp32, Qfact_FV - ( 31 - temp_exp ) ); + // *pFV_fx = L_shl( temp32, Qfact_FV - ( 31 - temp_exp ) ); + *pFV_fx = L_shl( temp32, sub( Qfact_FV, sub( 31, temp_exp ) ) ); + move32(); pFV_fx++; /* MinMax sclaer - mean and variance normalization */ /**pFV = *pFV * sm_scale[i] + sm_min[i];*/ @@ -2314,9 +2293,9 @@ Word16 ivas_smc_gmm_fx( move32(); } - lps_fx = logsumexp_fx( ps_fx, sub( 31, Q18 ), N_SMC_MIXTURES ); - lpm_fx = logsumexp_fx( pm_fx, sub( 31, Q18 ), N_SMC_MIXTURES ); - lpn_fx = logsumexp_fx( pn_fx, sub( 31, Q18 ), N_SMC_MIXTURES ); + lps_fx = logsumexp_fx( ps_fx, 31 - Q18, N_SMC_MIXTURES ); + lpm_fx = logsumexp_fx( pm_fx, 31 - Q18, N_SMC_MIXTURES ); + lpn_fx = logsumexp_fx( pn_fx, 31 - Q18, N_SMC_MIXTURES ); *high_lpn_flag = 0; move16(); if ( GT_32( lpn_fx, lps_fx ) && GT_32( lpn_fx, lpm_fx ) ) @@ -2326,10 +2305,10 @@ Word16 ivas_smc_gmm_fx( } hSpMusClas->lpm_fx = extract_l( L_shr( lpm_fx, 11 ) ); // Q7 - hSpMusClas->lps_fx = extract_l( L_shr( lps_fx, 11 ) ); // Q7 - hSpMusClas->lpn_fx = extract_l( L_shr( lpn_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(); /* determine HQ Generic speech class */ @@ -2378,6 +2357,7 @@ Word16 ivas_smc_gmm_fx( } dec = (Word16) GT_32( dlp_fx, 0 ); + move16(); /* calculate weight based on relE (higher relE -> lower weight, lower relE -> higher weight) */ wrelE_fx = lin_interp32_fx( L_deposit_h( relE_fx ), 15 << 24, 1932735283 /*0.9 in Q31*/, -( 15 << 24 ), 2126008812 /*0.99 in Q31*/, 1 ); // Q31 @@ -2390,23 +2370,27 @@ Word16 ivas_smc_gmm_fx( { IF( hSpMusClas->dlp_mean_ST_fx > 0 ) { - hSpMusClas->wdrop_fx = -extract_l( L_shr( dlp_fx, 10 ) ); // Q9 + hSpMusClas->wdrop_32fx = L_negate( dlp_fx ); // Q19 + move32(); } - ELSE IF( hSpMusClas->wdrop_fx > 0 ) + ELSE IF( hSpMusClas->wdrop_32fx > 0 ) { - hSpMusClas->wdrop_fx = extract_l( L_shr( L_sub( hSpMusClas->dlp_mean_ST_fx, dlp_fx ), 10 ) ); + hSpMusClas->wdrop_32fx = L_add( hSpMusClas->wdrop_32fx, L_sub( hSpMusClas->dlp_mean_ST_fx, dlp_fx ) ); + move32(); } + move16(); } ELSE { - hSpMusClas->wdrop_fx = 0; - move16(); + hSpMusClas->wdrop_32fx = 0; + move32(); } - wdrop_fx = lin_interp32_fx( L_deposit_h( hSpMusClas->wdrop_fx ), 503316480, 1503238554 /* 0.7 in Q31 */, 0, ONE_IN_Q31 /* 1.0f in Q31 */, 1 ); /* Q31 */ + wdrop_fx = lin_interp32_fx( hSpMusClas->wdrop_32fx, 7864320, 1503238554 /* 0.7 in Q31 */, 0, ONE_IN_Q31 /* 1.0f in Q31 */, 1 ); /* Q31 */ + test(); test(); /* calculate weight based on rises of dlp (close to 1 during sudden rise of dlp, close to 0 otherwise) */ - IF( EQ_16( hSpMusClas->sp_mus_state, HANG_LEN ) && hSpMusClas->dlp_mean_ST_fx > 0 && hSpMusClas->dlp_mean_ST_fx > hSpMusClas->past_dlp_mean_ST_fx[0] ) + IF( EQ_16( hSpMusClas->sp_mus_state, HANG_LEN ) && hSpMusClas->dlp_mean_ST_fx > 0 && GT_32( hSpMusClas->dlp_mean_ST_fx, hSpMusClas->past_dlp_mean_ST_fx[0] ) ) { IF( hSpMusClas->past_dlp_mean_ST_fx[0] < 0 ) { @@ -2416,6 +2400,7 @@ Word16 ivas_smc_gmm_fx( { hSpMusClas->wrise_fx = add( hSpMusClas->wrise_fx, extract_l( L_shr( L_sub( hSpMusClas->dlp_mean_ST_fx, hSpMusClas->past_dlp_mean_ST_fx[0] ), 10 ) ) ); } + move16(); } ELSE { @@ -2434,8 +2419,8 @@ Word16 ivas_smc_gmm_fx( { hSpMusClas->dlp_mean_LT_fx = dlp_fx; - hSpMusClas->dlp_var_LT_fx = 0; move32(); + hSpMusClas->dlp_var_LT_fx = 0; move32(); } @@ -2446,11 +2431,11 @@ Word16 ivas_smc_gmm_fx( hSpMusClas->dlp_var_LT_fx = L_add( Mpy_32_32( 1932735283, hSpMusClas->dlp_var_LT_fx ), Mpy_32_32( 214748365, temp32 ) ); test(); - IF( hSpMusClas->sp_mus_state > 0 && hSpMusClas->sp_mus_state < HANG_LEN ) + IF( hSpMusClas->sp_mus_state > 0 && LT_16( hSpMusClas->sp_mus_state, HANG_LEN ) ) { dlp_mean2var_fx = 0; - dlp_mean2var_q = 0; move16(); + dlp_mean2var_q = 0; move16(); } ELSE @@ -2522,6 +2507,7 @@ Word16 ivas_smc_gmm_fx( ELSE IF( hSpMusClas->flag_spitch_cnt > 0 ) { hSpMusClas->flag_spitch_cnt = sub( hSpMusClas->flag_spitch_cnt, 1 ); + move16(); } test(); IF( Etot_fx < 2560 ) @@ -2534,7 +2520,6 @@ Word16 ivas_smc_gmm_fx( { temp32 = L_mult( w_spmus_fx[hSpMusClas->sp_mus_state - 1][0], (Word16) L_shr( dlp_fx, 10 ) ); /*Q25 */ temp32 = L_add( temp32, Dot_product( &w_spmus_fx[hSpMusClas->sp_mus_state - 1][1], hSpMusClas->past_dlp_fx, sub( HANG_LEN, 1 ) ) ); - move16(); /* entry state -> final decision is calculated based on weighted average of past non-binary decisions */ IF( GT_32( temp32, 2 << 25 ) ) { @@ -2672,7 +2657,7 @@ static void var_cor_calc_ivas_fx( *high_stable_cor = 0; move16(); test(); - IF( GT_16( *mold_corr, 26214 ) && LT_16( var_cor, 1 ) ) + if ( GT_16( *mold_corr, 26214 ) && LT_16( var_cor, 1 ) ) { *high_stable_cor = 1; move16(); @@ -2701,8 +2686,10 @@ static Word16 attack_det_ivas_fx( /* o : attack flag const Word32 total_brate, /* i : total bitrate */ const Word16 element_mode, /* i : IVAS element mode */ const Word16 clas, /* i : signal class */ - Word32 finc_prev[], /* i/o: previous finc, (2 * Qx) */ - Word32 *lt_finc, /* i/o: long-term mean finc, (2 * Qx) */ + Word32 finc_prev[], /* i/o: previous finc, (q_finc_prev) */ + Word16 *q_finc_prev, /* i/o: Q of previous finc */ + Word32 *lt_finc, /* i/o: long-term mean finc, (q_lt_finc) */ + Word16 *q_lt_finc, /* i/o: Q of lt_finc */ Word16 *last_strong_attack /* i/o: last strong attack flag */ ) { @@ -2710,8 +2697,8 @@ static Word16 attack_det_ivas_fx( /* o : attack flag Word32 L_tmp, etmp, etmp2, finc[ATT_NSEG], mean_finc; Word16 att_3lsub_pos; Word16 attack1; - Word64 W_tmp = 0; - move64(); + Word64 W_tmp; + Word16 q_diff; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; @@ -2733,11 +2720,7 @@ static Word16 attack_det_ivas_fx( /* o : attack flag FOR( j = 1; j < ATT_SEG_LEN; j++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_mac0_o( L_tmp, inp[i * ATT_SEG_LEN + j], inp[i * ATT_SEG_LEN + j], &Overflow ); /*2*Qx */ -#else /* BASOP_NOGLOB */ - L_tmp = L_mac0( L_tmp, inp[i * ATT_SEG_LEN + j], inp[i * ATT_SEG_LEN + j] ); /*2*Qx */ -#endif /* BASOP_NOGLOB */ } finc[i] = L_tmp; @@ -2748,6 +2731,9 @@ static Word16 attack_det_ivas_fx( /* o : attack flag attack1 = attack; move16(); + *q_finc_prev = shl( Qx, 1 ); // Q of finc + move16(); + q_diff = sub( *q_finc_prev, *q_lt_finc ); test(); IF( EQ_16( localVAD, 1 ) && EQ_16( coder_type, GENERIC ) ) { @@ -2760,19 +2746,11 @@ static Word16 attack_det_ivas_fx( /* o : attack flag exp1 = norm_s( att_3lsub_pos ); tmp = div_s( shl( 1, sub( 14, exp1 ) ), att_3lsub_pos ); /*Q(29-exp1) */ -#ifdef BASOP_NOGLOB L_tmp = L_shr_o( finc[0], Qx, &Overflow ); /*Qx */ -#else /* BASOP_NOGLOB */ - L_tmp = L_shr( finc[0], Qx ); /*Qx */ -#endif /* BASOP_NOGLOB */ FOR( i = 1; i < att_3lsub_pos; i++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_add_o( L_tmp, L_shr_o( finc[i], Qx, &Overflow ), &Overflow ); /*Qx */ -#else /* BASOP_NOGLOB */ - L_tmp = L_add( L_tmp, L_shr( finc[i], Qx ) ); /*Qx */ -#endif /* BASOP_NOGLOB */ } L_tmp = Mult_32_16( L_tmp, tmp ); /*Q(14-exp1+Qx) */ etmp = L_shl( L_tmp, sub( exp1, 14 ) ); /*Qx */ @@ -2781,18 +2759,10 @@ static Word16 attack_det_ivas_fx( /* o : attack flag exp1 = norm_s( tmp1 ); tmp = div_s( shl( 1, sub( 14, exp1 ) ), tmp1 ); /*Q(29-exp1) */ -#ifdef BASOP_NOGLOB L_tmp = L_shr_o( finc[attack], Qx, &Overflow ); /*Qx */ -#else /* BASOP_NOGLOB */ - L_tmp = L_shr( finc[attack], Qx ); /*Qx */ -#endif /* BASOP_NOGLOB */ FOR( i = 1; i < tmp1; i++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_add_o( L_tmp, L_shr_o( finc[i + attack], Qx, &Overflow ), &Overflow ); /*Qx */ -#else /* BASOP_NOGLOB */ - L_tmp = L_add( L_tmp, L_shr( finc[i + attack], Qx ) ); /*Qx */ -#endif /* BASOP_NOGLOB */ } L_tmp = Mult_32_16( L_tmp, tmp ); /*Q(14-exp1+Qx) */ etmp2 = L_shl( L_tmp, sub( exp1, 14 ) ); /*Qx */ @@ -2854,7 +2824,7 @@ static Word16 attack_det_ivas_fx( /* o : attack flag move16(); } test(); - if ( GT_32( *lt_finc, Mpy_32_32( etmp2, 107374182 /* 1.f/20 in Q31 */ ) ) || *last_strong_attack ) + if ( GT_32( L_shl_sat( *lt_finc, q_diff ), Mpy_32_32( etmp2, 107374182 /* 1.f/20 in Q31 */ ) ) || *last_strong_attack ) { attack = 0; move16(); @@ -2886,15 +2856,29 @@ static Word16 attack_det_ivas_fx( /* o : attack flag Copy32( finc, finc_prev, ATT_NSEG ); /* Calculating mean of finc */ - FOR( i = 0; i < ATT_NSEG; i++ ) + W_tmp = W_mult_32_16( finc[0], 1 ); // q_finc_prev+1 + FOR( i = 1; i < ATT_NSEG; i++ ) { - W_tmp = W_add( W_tmp, (Word64) finc[i] ); + W_tmp = W_mac_32_16( W_tmp, finc[i], 1 ); // q_finc_prev+1 } - mean_finc = W_extract_l( W_shr( W_tmp, 5 ) ); + /* mean = W_tmp / 32 and change the Q from q_finc_prev+1 to q_finc_prev + Mean value doesn't saturate, W_shl_sat_l is used only considering complexity */ + mean_finc = W_shl_sat_l( W_tmp, -Q6 ); // q_finc_prev+1 -> q_finc_prev //*lt_finc = 0.95f * *lt_finc + 0.05f * mean( finc, ATT_NSEG ); - *lt_finc = L_add( Mpy_32_32( *lt_finc, 2040109466 /* 0.95 in Q31 */ ), Mpy_32_32( mean_finc, 107374182 /* 0.05f in Q31 */ ) ); - move32(); + IF( q_diff > 0 ) /* q_finc_prev > q_lt_finc */ + { + mean_finc = L_shr( mean_finc, q_diff ); // q_lt_finc + *lt_finc = Madd_32_32( Mpy_32_32( *lt_finc, 2040109466 /* 0.95 in Q31 */ ), mean_finc, 107374182 /* 0.05f in Q31 */ ); // q_lt_finc + move32(); + } + ELSE + { + *lt_finc = Madd_32_32( Mpy_32_32( L_shl( *lt_finc, q_diff ), 2040109466 /* 0.95 in Q31 */ ), mean_finc, 107374182 /* 0.05f in Q31 */ ); // q_finc_prev + move32(); + *q_lt_finc = *q_finc_prev; + move16(); + } return attack; } @@ -2951,43 +2935,41 @@ static Word32 tonal_det_fx( IF( GT_32( S_mass, *tod_S_mass_prev ) ) { alpha = 1503238554; /* 0.7f in Q31 */ - move16(); } ELSE { alpha = 644245094; /* 0.3f in Q31 */ - move16(); } + move16(); + *tod_S_mass_prev = S_mass; + move32(); *tod_S_mass_lt = L_add( Mpy_32_32( alpha, *tod_S_mass_lt ), Mpy_32_32( L_sub( ONE_IN_Q31, alpha ), S_mass ) ); // Q22 + move32(); S_mass = *tod_S_mass_lt; - move16(); - move16(); - move16(); + move32(); /* updating adaptive decision threshold */ IF( GT_32( S_mass, *tod_thr_lt ) ) { *tod_thr_lt = L_sub( *tod_thr_lt, THR_MASS_STEP_DN_FX ); - move16(); } ELSE { *tod_thr_lt = L_add( *tod_thr_lt, THR_MASS_STEP_UP_FX ); - move16(); } + move16(); if ( GT_32( *tod_thr_lt, THR_MASS_MAX_FX ) ) { *tod_thr_lt = THR_MASS_MAX_FX; - move16(); } if ( LT_32( *tod_thr_lt, THR_MASS_MIN_FX ) ) { *tod_thr_lt = THR_MASS_MIN_FX; - move16(); } + move16(); return S_mass; /* Q22 */ } @@ -3020,15 +3002,15 @@ void ivas_smc_mode_selection_fx( Word32 ton; Word16 i; Word32 S_p2a, S_max, S_ave = 0; - Word32 thr_sp2a; move32(); + Word32 thr_sp2a; SP_MUS_CLAS_HANDLE hSpMusClas = st->hSpMusClas; /* initialization */ *attack_flag = 0; - st->sp_aud_decision2 = 0; move16(); + st->sp_aud_decision2 = 0; move16(); /* signal stability estimation */ @@ -3038,14 +3020,14 @@ void ivas_smc_mode_selection_fx( var_cor_calc_ivas_fx( st->old_corr_fx, &hSpMusClas->mold_corr_fx, hSpMusClas->var_cor_t_fx, &hSpMusClas->high_stable_cor ); /* attack detection */ - IF( NE_16( shl( Q_new, 1 ), hSpMusClas->Q_lt_finc ) ) + IF( NE_16( shl( Q_new, 1 ), hSpMusClas->q_finc_prev ) ) { - Scale_sig32( &hSpMusClas->lt_finc_fx, 1, sub( shl( Q_new, 1 ), hSpMusClas->Q_lt_finc ) ); - Scale_sig32( hSpMusClas->finc_prev_fx, ATT_NSEG, sub( shl( Q_new, 1 ), hSpMusClas->Q_lt_finc ) ); - hSpMusClas->Q_lt_finc = shl( Q_new, 1 ); + Scale_sig32( hSpMusClas->finc_prev_fx, ATT_NSEG, sub( shl( Q_new, 1 ), hSpMusClas->q_finc_prev ) ); + hSpMusClas->q_finc_prev = shl( Q_new, 1 ); move16(); } - attack = attack_det_ivas_fx( inp, Q_new, st->clas, st->localVAD, st->coder_type, 0, st->element_mode, st->clas, hSpMusClas->finc_prev_fx, &hSpMusClas->lt_finc_fx, &hSpMusClas->last_strong_attack ); + attack = attack_det_ivas_fx( inp, Q_new, st->clas, st->localVAD, st->coder_type, 0, st->element_mode, st->clas, hSpMusClas->finc_prev_fx, + &hSpMusClas->q_finc_prev, &hSpMusClas->lt_finc_fx, &hSpMusClas->Q_lt_finc, &hSpMusClas->last_strong_attack ); /* tonal detector */ 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 @@ -3087,33 +3069,27 @@ void ivas_smc_mode_selection_fx( /* select TCX to encode extremely peaky signals or strongly tonal signals */ st->sp_aud_decision1 = 1; st->sp_aud_decision2 = 1; - move16(); - move16(); } ELSE IF( smc_dec == SPEECH ) { /* select ACELP to encode speech */ st->sp_aud_decision1 = 0; st->sp_aud_decision2 = 0; - move16(); - move16(); } ELSE IF( EQ_16( smc_dec, SPEECH_OR_MUSIC ) ) { /* select GSC to encode "unclear" segments (classifier's score on the borderline) */ st->sp_aud_decision1 = 1; st->sp_aud_decision2 = 0; - move16(); - move16(); } ELSE { /* select TCX to encode music */ st->sp_aud_decision1 = 1; st->sp_aud_decision2 = 1; - move16(); - move16(); } + move16(); + move16(); /* change decision from GSC to ACELP/TCX in some special cases */ test(); @@ -3164,8 +3140,8 @@ void ivas_smc_mode_selection_fx( { /* do ACELP TC coding instead of GC/VC if onset has been already declared before */ st->sp_aud_decision1 = 0; - st->coder_type = TRANSITION; move16(); + st->coder_type = TRANSITION; move16(); } ELSE @@ -3174,10 +3150,10 @@ void ivas_smc_mode_selection_fx( { /* do ACELP TC coding also if attack is located in the last subframe */ st->sp_aud_decision1 = 0; - *attack_flag = add( attack, 1 ); - st->coder_type = TRANSITION; move16(); + *attack_flag = add( attack, 1 ); move16(); + st->coder_type = TRANSITION; move16(); } ELSE IF( GE_16( attack, ATT_SEG_LEN / 2 ) ) @@ -3185,8 +3161,8 @@ void ivas_smc_mode_selection_fx( /* do GSC coding if attack is located after the first quarter of the first subframe */ /* (pre-echo will be treated at the decoder side) */ *attack_flag = 31; - *attack_flag = add( attack, 1 ); move16(); + *attack_flag = add( attack, 1 ); move16(); } } @@ -3201,13 +3177,13 @@ void ivas_smc_mode_selection_fx( { /* change ACELP coder_type to TC if attack has been detected */ st->sp_aud_decision1 = 0; + move16(); st->sp_aud_decision2 = 0; + move16(); st->coder_type = TRANSITION; - *attack_flag = add( attack, 1 ); - move16(); - move16(); move16(); + *attack_flag = add( attack, 1 ); move16(); } @@ -3270,26 +3246,24 @@ void ivas_smc_mode_selection_fx( { /* music-like content */ st->GSC_IVAS_mode = 3; - move16(); } ELSE IF( st->tc_cnt > 0 ) { /* likely presence of an onset, GSC bit allocation will be more focused on LF */ st->GSC_IVAS_mode = 2; - move16(); } + move16(); test(); IF( EQ_16( st->coder_type_raw, UNVOICED ) && st->sp_aud_decision0 == 0 /*&& st->GSC_IVAS_mode < 3*/ ) { st->GSC_noisy_speech = 1; - move16(); } ELSE { st->GSC_noisy_speech = 0; - move16(); } + move16(); } /* set coder_type to AUDIO when GSC is selected (st->core will be set later in the decision matrix) */ @@ -3425,6 +3399,7 @@ static Word16 mode_decision_fx( } inv_len = 3277; /*Q15 */ + move16(); L_tmp = L_deposit_l( 0 ); FOR( i = 0; i < 10; i++ ) @@ -3700,11 +3675,7 @@ static void flux_fx( { IF( p2v_map[i] != 0 ) { -#ifdef BASOP_NOGLOB L_flux = L_add_sat( L_flux, abs_s( sub_sat( Bin_E[i], old_Bin_E[i] ) ) ); /*Q7 */ -#else - L_flux = L_add( L_flux, abs_s( sub( Bin_E[i], old_Bin_E[i] ) ) ); /*Q7 */ -#endif } if ( p2v_map[i] != 0 ) { @@ -3778,6 +3749,7 @@ static void spec_analysis_fx( Word16 p2v[65]; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif /* find spectral peaks */ @@ -3861,11 +3833,8 @@ static void spec_analysis_fx( test(); IF( GT_16( peak_idx[k], valey_idx[i] ) && LT_16( peak_idx[k], valey_idx[i + 1] ) ) { -#ifdef BASOP_NOGLOB p2v[k] = sub_o( shl_o( peak[k], 1, &Overflow ), add_o( valley[i], valley[i + 1], &Overflow ), &Overflow ); -#else /* BASOP_NOGLOB */ - p2v[k] = sub( shl( peak[k], 1 ), add( valley[i], valley[i + 1] ) ); -#endif /* BASOP_NOGLOB */ + move16(); k = add( k, 1 ); } } @@ -3897,6 +3866,7 @@ static void music_mixed_classif_improv_fx( Word16 exp, frac, expn, fracn, expd, fracd, scale; Word16 tmp; Word32 L_tmp, ftmp, ftmp1, epsP_max = MIN_32; + move32(); SP_MUS_CLAS_HANDLE hSpMusClas = st->hSpMusClas; /* find sample with maximum absolute amplitude */ @@ -3988,7 +3958,7 @@ static void music_mixed_classif_improv_fx( test(); test(); test(); - IF( LT_16( old_cor, 24576 ) && LT_16( st->voicing_fx[0], 24576 ) && LT_16( st->voicing_fx[1], 24576 ) && GT_16( hSpMusClas->old_lt_diff_fx[0], 1280 ) ) + if ( LT_16( old_cor, 24576 ) && LT_16( st->voicing_fx[0], 24576 ) && LT_16( st->voicing_fx[1], 24576 ) && GT_16( hSpMusClas->old_lt_diff_fx[0], 1280 ) ) { percus_flag = 1; move16(); @@ -4001,7 +3971,7 @@ static void music_mixed_classif_improv_fx( test(); test(); test(); - IF( GT_16( sub( hSpMusClas->buf_etot_fx[3], hSpMusClas->buf_etot_fx[2] ), 1536 ) && GT_16( hSpMusClas->dec_mov_fx, 29491 ) && GT_16( sub( etot, st->lp_speech_fx ), 1280 ) && GT_16( hSpMusClas->old_lt_diff_fx[0], 640 ) ) + if ( GT_16( sub( hSpMusClas->buf_etot_fx[3], hSpMusClas->buf_etot_fx[2] ), 1536 ) && GT_16( hSpMusClas->dec_mov_fx, 29491 ) && GT_16( sub( etot, st->lp_speech_fx ), 1280 ) && GT_16( hSpMusClas->old_lt_diff_fx[0], 640 ) ) { hSpMusClas->attack_hangover = 3; move16(); @@ -4031,7 +4001,9 @@ static void music_mixed_classif_improv_fx( flux_fx( st->lgBin_E_fx, p2v_map, hSpMusClas->old_Bin_E_fx, hSpMusClas->buf_flux_fx, hSpMusClas->attack_hangover, hSpMusClas->dec_mov_fx ); hSpMusClas->attack_hangover = sub( hSpMusClas->attack_hangover, 1 ); + move16(); hSpMusClas->attack_hangover = s_max( hSpMusClas->attack_hangover, 0 ); + move16(); /* identify flux buffer buffering status */ len = 0; @@ -4137,11 +4109,7 @@ static void music_mixed_classif_improv_fx( expn = sub( sub( 30, expn ), Q_epsP - 4 ); expd = norm_l( ftmp ); -#ifdef BASOP_NOGLOB fracd = round_fx_sat( L_shl( ftmp, expd ) ); -#else - fracd = round_fx( L_shl( ftmp, expd ) ); -#endif expd = sub( sub( 30, expd ), sub( Q_epsP, 4 ) ); scale = shr( sub( fracd, fracn ), 15 ); @@ -4200,6 +4168,8 @@ static void music_mixed_classif_improv_fx( hSpMusClas->dec_mov_fx = add( mult_r( 31785, hSpMusClas->dec_mov_fx ), 983 ); /*Q15 */ hSpMusClas->dec_mov1_fx = add( mult_r( 31785, hSpMusClas->dec_mov1_fx ), 983 ); /*Q15 */ } + move16(); + move16(); } /* update long term unvoiced counter */ @@ -4215,24 +4185,27 @@ static void music_mixed_classif_improv_fx( { hSpMusClas->UV_cnt1 = add( hSpMusClas->UV_cnt1, 1 ); } + move16(); hSpMusClas->UV_cnt1 = s_min( hSpMusClas->UV_cnt1, 300 ); + move16(); hSpMusClas->UV_cnt1 = s_max( hSpMusClas->UV_cnt1, 0 ); + move16(); /**LT_UV_cnt1 = add(mult_r(29491,*LT_UV_cnt1),mult_r(3277,shl(*UV_cnt1,6)));*/ /* Q6 */ hSpMusClas->LT_UV_cnt1_fx = round_fx( L_mac( L_mult( 29491, hSpMusClas->LT_UV_cnt1_fx ), 3277, shl( hSpMusClas->UV_cnt1, 6 ) ) ); /*Q6 */ - + move16(); /* revert classification decision due to long-term unvoiced counter */ test(); test(); - IF( EQ_16( dec, 1 ) && LT_16( hSpMusClas->dec_mov1_fx, 6554 ) && LT_16( hSpMusClas->LT_UV_cnt1_fx, 12800 ) ) + if ( EQ_16( dec, 1 ) && LT_16( hSpMusClas->dec_mov1_fx, 6554 ) && LT_16( hSpMusClas->LT_UV_cnt1_fx, 12800 ) ) { dec = 0; move16(); } /* overwrite 1st stage speech/music decision to music */ - IF( EQ_16( dec, 1 ) ) + if ( EQ_16( dec, 1 ) ) { st->sp_aud_decision1 = 1; move16(); @@ -4264,6 +4237,7 @@ static void tonal_context_improv_fx( SP_MUS_CLAS_HANDLE hSpMusClas = st_fx->hSpMusClas; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move16(); #endif IF( EQ_16( st_fx->last_codec_mode, MODE2 ) ) @@ -4307,11 +4281,7 @@ static void tonal_context_improv_fx( tmp = div_s( fraca, fracb ); exp1 = sub( expa, expb ); -#ifdef BASOP_NOGLOB tonality1 = L_shl_o( tmp, exp1, &Overflow ); -#else /* BASOP_NOGLOB */ - tonality1 = L_shl( tmp, exp1 ); -#endif } ELSE { @@ -4342,11 +4312,7 @@ static void tonal_context_improv_fx( tmp = div_s( fraca, fracb ); exp2 = sub( expa, expb ); -#ifdef BASOP_NOGLOB tonality2 = L_shl_o( tmp, exp2, &Overflow ); -#else - tonality2 = L_shl( tmp, exp2 ); -#endif } ELSE { @@ -4376,11 +4342,7 @@ static void tonal_context_improv_fx( tmp = div_s( fraca, fracb ); exp3 = sub( expa, expb ); -#ifdef BASOP_NOGLOB tonality3 = L_shl_o( tmp, exp3, &Overflow ); -#else - tonality3 = L_shl( tmp, exp3 ); -#endif } ELSE { @@ -4392,11 +4354,7 @@ static void tonal_context_improv_fx( /* voi_mean = 0.33f * (st->voicing_fx[0] + voicing[1] + voicing[2]); */ L_tmp = L_mult( st_fx->voicing_fx[0], 10923 ); L_tmp = L_mac( L_tmp, st_fx->voicing_fx[1], 10923 ); -#ifdef BASOP_NOGLOB // -dtx 12650 amrwb\Dtx3.INP voi_mean = mac_r_sat( L_tmp, st_fx->voicing_fx[2], 10923 ); /* Q15 */ -#else - voi_mean = mac_r( L_tmp, st_fx->voicing_fx[2], 10923 ); /* Q15 */ -#endif test(); IF( EQ_16( hVAD->hangover_cnt, 10 ) && EQ_16( st_fx->vad_flag, 1 ) ) { @@ -4420,6 +4378,9 @@ static void tonal_context_improv_fx( /* long-term tonality measure */ hSpMusClas->lt_tonality = L_add( Mult_32_16( hSpMusClas->lt_tonality, 16384 ), Mult_32_16( tonality, 16384 ) ); } + move16(); + move16(); + move16(); /* Pitch difference w.r.t to past 3 frames */ lt_pitch_diff = abs_s( sub( hSpMusClas->lt_corr_pitch[0], st_fx->pitch[0] ) ); @@ -4497,6 +4458,7 @@ static void tonal_context_improv_fx( exp = sub( 30, add( exp, 16 ) ); L_tmp = Mpy_32_16( exp, tmp, 15783 ); /*19 //3945, 0.2*log10(2), Q18 */ hSpMusClas->tonality2_buf_fx[HANG_LEN_INIT - 1] = round_fx( L_shl( L_tmp, 11 ) ); /*14 */ + move16(); /* t2 = std( st->tonality2_buf, HANG_LEN_INIT ); */ t2_fx = std_fx( hSpMusClas->tonality2_buf_fx, HANG_LEN_INIT ); /*14 */ @@ -4508,6 +4470,7 @@ static void tonal_context_improv_fx( L_tmp = Mpy_32_16( exp, tmp, 15783 ); /*19 //3945, 0.2*log10(2), Q18 */ hSpMusClas->tonality3_buf_fx[HANG_LEN_INIT - 1] = round_fx( L_shl( L_tmp, 11 ) ); /*14 */ t3_fx = std_fx( hSpMusClas->tonality3_buf_fx, HANG_LEN_INIT ); /*14 */ + move16(); /* tL = 0.2f*(float)log10(st->lt_tonality); */ exp = norm_l( hSpMusClas->lt_tonality ); @@ -4519,6 +4482,7 @@ static void tonal_context_improv_fx( /* calculate standard deviation of residual LP energy */ Copy( hSpMusClas->LPCErr_buf_fx + 1, hSpMusClas->LPCErr_buf_fx, HANG_LEN_INIT - 1 ); hSpMusClas->LPCErr_buf_fx[HANG_LEN_INIT - 1] = LPCErr; + move16(); /* err = std( st->LPCErr_buf, HANG_LEN_INIT ); */ err_fx = std_fx( hSpMusClas->LPCErr_buf_fx, HANG_LEN_INIT ); @@ -4559,6 +4523,7 @@ static void tonal_context_improv_fx( IF( hSpMusClas->lt_music_hangover > 0 ) { hSpMusClas->lt_music_hangover = sub( hSpMusClas->lt_music_hangover, 1 ); + move16(); } /* state machine for strong speech */ @@ -4596,6 +4561,7 @@ static void tonal_context_improv_fx( IF( hSpMusClas->lt_speech_hangover > 0 ) { hSpMusClas->lt_speech_hangover = sub( hSpMusClas->lt_speech_hangover, 1 ); + move16(); } /* final decision */ @@ -4642,10 +4608,14 @@ static void detect_sparseness_fx( Word16 S1[128]; Word16 i, j; Word16 hb_sp_high_flag = 0; + move16(); Word16 lb_sp_high_flag = 0; + move16(); Word16 sparse; Word16 tmp_buf[4]; Word16 Mlpe = 0, Mv = 0, Msp; + move16(); + move16(); SP_MUS_CLAS_HANDLE hSpMusClas = st_fx->hSpMusClas; Copy( st_fx->lgBin_E_fx, S1, 128 ); @@ -4777,12 +4747,12 @@ static void detect_sparseness_fx( IF( tmp == 0 ) { hSpMusClas->hf_spar_buf_fx[HANG_LEN_INIT - 1] = 0; - move16(); } ELSE { hSpMusClas->hf_spar_buf_fx[HANG_LEN_INIT - 1] = div_s( tmp, sumh ); } + move16(); tmp = 0; move16(); @@ -4877,6 +4847,7 @@ static void detect_sparseness_fx( if ( EQ_16( st_fx->bwidth, WB ) ) { tmp = 90; + move16(); } IF( GT_16( sparse, tmp ) ) @@ -4939,7 +4910,7 @@ static void detect_sparseness_fx( hSpMusClas->gsc_hangover = 1; move16(); } - ELSE IF( EQ_16( hSpMusClas->gsc_hangover, 1 ) && !( st_fx->sp_aud_decision1 == 0 && st_fx->sp_aud_decision2 == 1 ) ) + ELSE IF( EQ_16( hSpMusClas->gsc_hangover, 1 ) && !( st_fx->sp_aud_decision1 == 0 && EQ_16( st_fx->sp_aud_decision2, 1 ) ) ) { IF( LT_16( abs_s( sub( sparse, mean_fx( &hSpMusClas->sparse_buf_fx[HANG_LEN_INIT - 1 - hSpMusClas->gsc_cnt], hSpMusClas->gsc_cnt ) ) ), 7 ) ) { diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h index 1af993a8a8c1186ea083589725118db8d4f7b3f2..c0b5418ce823c0c8e0df5d00590b313b8d1cd39f 100644 --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -585,6 +585,7 @@ typedef struct sp_mus_clas_structure Word16 past_epsP2_fx; /* Q10 */ Word16 inact_cnt; Word16 wdrop_fx; /* Q9 */ + Word32 wdrop_32fx; /* Q19 */ Word16 wrise_fx; /* Q9 */ Word16 wdlp_0_95_sp_fx; /* EVS - Q8 */ Word32 wdlp_0_95_sp_32fx; /* IVAS - Q24 */ @@ -640,8 +641,9 @@ typedef struct sp_mus_clas_structure Word16 UV_cnt1; Word16 LT_UV_cnt1_fx; /* Q6 */ - Word32 finc_prev_fx[ATT_NSEG]; /* strong attack detection - previous finc, (Q_new * 2) */ - Word32 lt_finc_fx; /* strong attack detection - long-term finc energy, Q_lt_finc (Q_new * 2) */ + Word32 finc_prev_fx[ATT_NSEG]; /* strong attack detection - previous finc, (q_finc_prev) */ + Word16 q_finc_prev; + Word32 lt_finc_fx; /* strong attack detection - long-term finc energy, Q_lt_finc */ Word16 Q_lt_finc; Word16 last_strong_attack; /* strong attack detection - last strong attack flag */ Word32 tod_lt_Bin_E_fx[TOD_NSPEC]; /* tonal detector - long-term energy spectrum, Q_tod_lt_Bin_E */ @@ -1006,11 +1008,14 @@ 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 )]; // q0 - 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 - Word16 old_syn_12k8_16k_fx[NS2SA( 16000, DELAY_FD_BWE_ENC_NS )]; // st->Q_syn + 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 + Word16 old_syn_12k8_16k_fx[NS2SA( 16000, DELAY_FD_BWE_ENC_NS )]; // st->Q_syn Word16 old_fdbwe_speech_fx[L_FRAME48k]; Word16 mem_deemph_old_syn_fx; Word16 q_mem_deemph_old_syn; @@ -1021,6 +1026,7 @@ typedef struct fd_bwe_enc_structure Word32 prev_global_gain_fx; /* Q(2 * prev_Q_shb) */ Word16 modeCount; Word32 EnergyLF_fx; + Word16 EnergyLF_exp; Word16 mem_old_wtda_swb_fx; /* Q(-1) */ } FD_BWE_ENC_DATA, *FD_BWE_ENC_HANDLE; diff --git a/lib_enc/stat_noise_uv_enc.c b/lib_enc/stat_noise_uv_enc.c deleted file mode 100644 index fc894ba6cc3b0f6891e5522d7bdaa893786ada84..0000000000000000000000000000000000000000 --- a/lib_enc/stat_noise_uv_enc.c +++ /dev/null @@ -1,41 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "prot.h" -#include "rom_com.h" -#include "wmc_auto.h" diff --git a/lib_enc/stat_noise_uv_enc_fx.c b/lib_enc/stat_noise_uv_enc_fx.c index 1045d8efd8c45b22973cc66673b87d16928ad0cb..91dca8d63ff14510d6f3273d9e01b12f89321144 100644 --- a/lib_enc/stat_noise_uv_enc_fx.c +++ b/lib_enc/stat_noise_uv_enc_fx.c @@ -49,10 +49,13 @@ void stat_noise_uv_enc_fx( Word16 Q_new ) { Word16 noisiness = 0; + move16(); Word16 num, den, expn, expd; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move16(); #endif + test(); test(); test(); IF( ( EQ_16( st_fx->coder_type, UNVOICED ) && uc_two_stage_flag == 0 ) || ( EQ_16( st_fx->coder_type, INACTIVE ) && LE_32( st_fx->core_brate, ACELP_9k60 ) ) ) @@ -63,24 +66,12 @@ void stat_noise_uv_enc_fx( *-----------------------------------------------------------------*/ /* epsP[2] is located in LepsP[0] and epsP[16] in LepsP[1] */ expn = sub( norm_l( LepsP[0] ), 1 ); -#ifdef BASOP_NOGLOB num = extract_h( L_shl_o( LepsP[0], expn, &Overflow ) ); /*expn-16*/ -#else - num = extract_h( L_shl( LepsP[0], expn ) ); /*expn-16*/ -#endif expd = norm_l( LepsP[1] ); -#ifdef BASOP_NOGLOB - den = extract_h( L_shl_o( LepsP[1], expd, &Overflow ) ); /*expd-16*/ -#else - den = extract_h( L_shl( LepsP[1], expd ) ); /*expd-16*/ -#endif - num = div_s( num, den ); /*expn-expd+15*/ -#ifdef BASOP_NOGLOB + den = extract_h( L_shl_o( LepsP[1], expd, &Overflow ) ); /*expd-16*/ + num = div_s( num, den ); /*expn-expd+15*/ num = shr_o( num, add( sub( expn, expd ), 5 ), &Overflow ); /*Q10*/ -#else - num = shr( num, add( sub( expn, expd ), 5 ) ); /*Q10*/ -#endif - num = sub( num, 1024 ); /*num - 1*/ + num = sub( num, 1024 ); /*num - 1*/ test(); IF( NE_16( st_fx->bwidth, NB ) ) @@ -148,24 +139,12 @@ void stat_noise_uv_enc_ivas_fx( *-----------------------------------------------------------------*/ /* epsP[2] is located in LepsP[0] and epsP[16] in LepsP[1] */ expn = sub( norm_l( LepsP[0] ), 1 ); -#ifdef BASOP_NOGLOB num = extract_h( L_shl_o( LepsP[0], expn, &Overflow ) ); /*expn-16*/ -#else - num = extract_h( L_shl( LepsP[0], expn ) ); /*expn-16*/ -#endif expd = norm_l( LepsP[1] ); -#ifdef BASOP_NOGLOB - den = extract_h( L_shl_o( LepsP[1], expd, &Overflow ) ); /*expd-16*/ -#else - den = extract_h( L_shl( LepsP[1], expd ) ); /*expd-16*/ -#endif - num = div_s( num, den ); /*expn-expd+15*/ -#ifdef BASOP_NOGLOB + den = extract_h( L_shl_o( LepsP[1], expd, &Overflow ) ); /*expd-16*/ + num = div_s( num, den ); /*expn-expd+15*/ num = shr_o( num, add( sub( expn, expd ), 5 ), &Overflow ); /*Q10*/ -#else - num = shr( num, add( sub( expn, expd ), 5 ) ); /*Q10*/ -#endif - num = sub( num, 1024 ); /*num - 1*/ + num = sub( num, 1024 ); /*num - 1*/ test(); IF( NE_16( st_fx->bwidth, NB ) ) diff --git a/lib_enc/subband_fft.c b/lib_enc/subband_fft.c deleted file mode 100644 index 8d4adb219f2e97f01fc9e529ffbc94de34a8fde5..0000000000000000000000000000000000000000 --- a/lib_enc/subband_fft.c +++ /dev/null @@ -1,42 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "prot.h" -#include "rom_enc.h" -#include "wmc_auto.h" diff --git a/lib_enc/subband_fft_fx.c b/lib_enc/subband_fft_fx.c index 83a1b41dd1dc30fe79f5b36f00f8f584d2ead612..10de09fe95e85e1dbbbc7ef6f6686115770cbbc6 100644 --- a/lib_enc/subband_fft_fx.c +++ b/lib_enc/subband_fft_fx.c @@ -107,7 +107,7 @@ static void passf4_1_16( UWord16 i; - for ( i = 0; i < 4; i++ ) + FOR( i = 0; i < 4; i++ ) { cmplx_s c2, c3, c4, t1, t2, t3, t4; @@ -142,7 +142,7 @@ static void passf4_2_16( Word16 k; - for ( k = 0; k < 4; k++ ) + FOR( k = 0; k < 4; k++ ) { cmplx_s t1, t2, t3, t4; diff --git a/lib_enc/swb_bwe_enc.c b/lib_enc/swb_bwe_enc.c deleted file mode 100644 index f633228119386e13dda4efacbed7ef242c8cb4c2..0000000000000000000000000000000000000000 --- a/lib_enc/swb_bwe_enc.c +++ /dev/null @@ -1,54 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "prot.h" -#include "rom_com.h" -#include "rom_enc.h" -#include "basop_util.h" -#include "basop_proto_func.h" -#include "wmc_auto.h" -#include "prot_fx.h" - - -/*-------------------------------------------------------------------* - * fd_bwe_enc_init() - * - * Initialize FD BWE state structure at the encoder - *-------------------------------------------------------------------*/ diff --git a/lib_enc/swb_bwe_enc_fx.c b/lib_enc/swb_bwe_enc_fx.c index 355246ec8960b09b083d0a655077e1d90bfefdc8..c7d99cc699ab43d0b8f5dbfacc96c3ea70c6b138 100644 --- a/lib_enc/swb_bwe_enc_fx.c +++ b/lib_enc/swb_bwe_enc_fx.c @@ -130,6 +130,7 @@ void wb_bwe_enc_fx( ) { Word16 mode = 0; + move16(); Word16 Sample_Delay_WB_BWE; Word16 old_input_fx[NS2SA( 16000, DELAY_FD_BWE_ENC_NS + DELAY_FIR_RESAMPL_NS ) + L_FRAME16k]; Word32 yorig_32[L_FRAME16k]; @@ -183,13 +184,14 @@ void wb_bwe_enc_fx( scl = s_min( Q_synth, scl ); } Copy_Scale_sig32_16( yorig_32, yorig_fx, L_FRAME16k, scl ); - Q_synth = add( sub( new_input_fx_exp, 16 ), scl ) - 1; + 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, mode - 2, 1 ); + push_indice_fx( st_fx->hBstr, IND_WB_CLASS, sub( mode, 2 ), 1 ); } hBWE_FD->prev_mode = mode; + move16(); return; } @@ -206,6 +208,7 @@ void wb_bwe_enc_ivas_fx( ) { Word16 mode = 0; + move16(); Word16 Sample_Delay_WB_BWE; Word16 old_input_fx[NS2SA( 16000, DELAY_FD_BWE_ENC_NS + DELAY_FIR_RESAMPL_NS ) + L_FRAME16k]; Word32 yorig_32[L_FRAME16k]; @@ -216,9 +219,8 @@ void wb_bwe_enc_ivas_fx( Word16 Q_synth; FD_BWE_ENC_HANDLE hBWE_FD = st_fx->hBWE_FD; Word16 WB_fenv_fx[SWB_FENV]; - move16(); - IF( GT_32( st_fx->extl_brate, 0 ) ) + IF( st_fx->extl_brate > 0 ) { /*---------------------------------------------------------------------* * Delay the original input signal to be synchronized with ACELP core synthesis @@ -261,10 +263,11 @@ void wb_bwe_enc_ivas_fx( scl = s_min( Q_synth, scl ); } Copy_Scale_sig32_16( yorig_32, yorig_fx, L_FRAME16k, scl ); - Q_synth = add( sub( new_input_fx_exp, 16 ), scl ) - 1; + Q_synth = sub( add( sub( new_input_fx_exp, 16 ), scl ), 1 ); mode = WB_BWE_encoding_ivas_fx( st_fx, yorig_fx, WB_fenv_fx, Q_synth, Q_synth ); - push_indice( st_fx->hBstr, IND_WB_CLASS, mode - 2, 1 ); + move16(); + push_indice( st_fx->hBstr, IND_WB_CLASS, sub( mode, 2 ), 1 ); } hBWE_FD->prev_mode = mode; @@ -322,6 +325,9 @@ 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; @@ -335,27 +341,27 @@ void swb_bwe_enc_ivas_fx( inner_frame = L_FRAME48k; move16(); inner_Fs = 48000; - move16(); + move32(); } ELSE { inner_frame = L_FRAME32k; move16(); inner_Fs = 32000; - move16(); + move32(); } set16_fx( old_input_fx, 0, add( NS2SA( inner_Fs, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ), inner_frame ) ); IF( EQ_16( st_fx->L_frame, L_FRAME ) ) { - Sample_Delay_SWB_BWE = NS2SA( inner_Fs, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ); - Sample_Delay_HP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS ); + Sample_Delay_SWB_BWE = NS2SA_FX2( inner_Fs, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ); + Sample_Delay_HP = NS2SA_FX2( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS ); IF( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) { - Sample_Delay_HP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS - L_MEM_RECALC_TBE_NS ); + Sample_Delay_HP = NS2SA_FX2( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS - L_MEM_RECALC_TBE_NS ); } - Sample_Delay_LP = NS2SA( 12800, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS ); + Sample_Delay_LP = NS2SA_FX2( 12800, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS ); IF( st_fx->element_mode > EVS_MONO ) { @@ -374,13 +380,13 @@ void swb_bwe_enc_ivas_fx( } ELSE { - Sample_Delay_SWB_BWE = NS2SA( inner_Fs, DELAY_FD_BWE_ENC_16k_NS + DELAY_FIR_RESAMPL_NS ); - Sample_Delay_HP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_16k_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS ); + Sample_Delay_SWB_BWE = NS2SA_FX2( inner_Fs, DELAY_FD_BWE_ENC_16k_NS + DELAY_FIR_RESAMPL_NS ); + Sample_Delay_HP = NS2SA_FX2( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_16k_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS ); IF( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) { - Sample_Delay_HP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_16k_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS - L_MEM_RECALC_TBE_NS ); + Sample_Delay_HP = NS2SA_FX2( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_16k_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS - L_MEM_RECALC_TBE_NS ); } - Sample_Delay_LP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_16k_NS ); + Sample_Delay_LP = NS2SA_FX2( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_16k_NS ); IF( st_fx->element_mode > EVS_MONO ) { Sample_Delay_SWB_BWE = sub( Sample_Delay_SWB_BWE, NS2SA( inner_Fs, DELAY_FIR_RESAMPL_NS ) ); @@ -397,8 +403,25 @@ 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 ) ) + { + Copy_Scale_sig( hBWE_FD->new_input_hp_fx, new_input_hp_fx, Sample_Delay_HP, sub( Q_shb_speech, hBWE_FD->Q_new_input_hp ) ); // Q_shb_speech + Copy( shb_speech_fx, &new_input_hp_fx[Sample_Delay_HP], L_FRAME16k - Sample_Delay_HP ); // Q_shb_speech + } + ELSE + { + Copy( hBWE_FD->new_input_hp_fx, new_input_hp_fx, Sample_Delay_HP ); // hBWE_FD->Q_new_input_hp + Copy_Scale_sig( shb_speech_fx, &new_input_hp_fx[Sample_Delay_HP], L_FRAME16k - Sample_Delay_HP, sub( hBWE_FD->Q_new_input_hp, Q_shb_speech ) ); // hBWE_FD->Q_new_input_hp + } + + 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 ); @@ -409,11 +432,7 @@ void swb_bwe_enc_ivas_fx( *----------------------------------------------------------------------*/ /* tilt returned in Q24 goto to Q11 */ -#ifdef BASOP_NOGLOB tilt_nb_fx = round_fx_o( L_shl_o( calc_tilt_bwe_fx( old_input_lp_fx, Q_slb_speech, st_fx->L_frame ), 3, &Overflow ), &Overflow ); -#else - tilt_nb_fx = round_fx( L_shl( calc_tilt_bwe_fx( old_input_lp_fx, Q_slb_speech, st_fx->L_frame ), 3 ) ); -#endif /*---------------------------------------------------------------------* * SWB BWE encoding * FB BWE encoding @@ -486,6 +505,7 @@ void swb_bwe_enc_ivas_fx( } Copy_Scale_sig( &yorig_fx[scl], &yorig_fx[scl], sub( inner_frame, scl ), exp ); Q_synth_hf = add( exp, Q_synth ); + test(); IF( EQ_16( st_fx->last_extl, SWB_BWE ) || EQ_16( st_fx->last_extl, FB_BWE ) ) { @@ -499,7 +519,7 @@ void swb_bwe_enc_ivas_fx( ELSE { Q_shb = shr( add( st_fx->EnergyLT_fx_exp, exp ), 1 ); - IF( EQ_16( s_and( exp, 0x0001 ), 1 ) ) + if ( EQ_16( s_and( exp, 0x0001 ), 1 ) ) { exp = sub( exp, 1 ); } @@ -511,14 +531,18 @@ 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 ) ) { fb_band_begin = FB_BAND_BEGIN; move16(); - IF( EQ_16( st_fx->L_frame, L_FRAME ) ) + if ( EQ_16( st_fx->L_frame, L_FRAME ) ) { fb_band_begin = FB_BAND_BEGIN_12k8; move16(); @@ -546,12 +570,8 @@ void swb_bwe_enc_ivas_fx( exp1 = norm_l( L_tmp ); L_tmp = L_shl( L_tmp, exp1 ); exp = sub( sub( 31, exp1 ), sub( 30, exp ) ); - L_tmp = Isqrt_lc( L_tmp, &exp ); /*31-exp */ -#ifdef BASOP_NOGLOB + L_tmp = Isqrt_lc( L_tmp, &exp ); /*31-exp */ fb_ener_adjust_fx = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /*Q15 */ -#else - fb_ener_adjust_fx = round_fx( L_shl( L_tmp, exp ) ); /*Q15 */ -#endif } ELSE { @@ -620,16 +640,20 @@ void swb_bwe_enc_fx( Word16 Sample_Delay_HP; Word16 Sample_Delay_LP; Word16 idxGain = 0; + move16(); Word16 Q_synth_hf, Q_synth, Q_shb; Word16 tilt_nb_fx; Word16 SWB_fenv_fx[SWB_FENV]; Word32 ener_low_fx; Word32 energy_fbe_fb_fx = 0; + move32(); Word16 fb_ener_adjust_fx; Word16 ener_adjust_quan_fx = 0; + move16(); #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif FD_BWE_ENC_HANDLE hBWE_FD = st_fx->hBWE_FD; @@ -641,12 +665,16 @@ void swb_bwe_enc_fx( IF( EQ_16( st_fx->extl, FB_BWE ) ) { inner_frame = L_FRAME48k; + move16(); inner_Fs = 48000; + move32(); } ELSE { inner_frame = L_FRAME32k; + move16(); inner_Fs = 32000; + move32(); } set16_fx( old_input_fx, 0, add( NS2SA( inner_Fs, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ), inner_frame ) ); @@ -667,6 +695,9 @@ void swb_bwe_enc_fx( delay_input_signal_fx( hBWE_FD->old_input_lp_fx, old_input_lp_fx, &old_input_16k_fx[L_INP_MEM], Sample_Delay_LP, L_FRAME16k, &hBWE_FD->prev_Q_input_lp, &Q_slb_speech ); } + move16(); + move16(); + move16(); 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 ); @@ -680,16 +711,13 @@ void swb_bwe_enc_fx( *----------------------------------------------------------------------*/ /* tilt returned in Q24 goto to Q11 */ -#ifdef BASOP_NOGLOB tilt_nb_fx = round_fx_o( L_shl_o( calc_tilt_bwe_fx( old_input_lp_fx, Q_slb_speech, st_fx->L_frame ), 3, &Overflow ), &Overflow ); -#else - tilt_nb_fx = round_fx( L_shl( calc_tilt_bwe_fx( old_input_lp_fx, Q_slb_speech, st_fx->L_frame ), 3 ) ); -#endif /*---------------------------------------------------------------------* * SWB BWE encoding * FB BWE encoding *---------------------------------------------------------------------*/ new_input_fx_exp = 0; + move16(); /* MDCT of the core synthesis signal */ wtda_fx( old_input_fx, &new_input_fx_exp, L_old_input_fx, hBWE_FD->L_old_wtda_swb_fx, &st_fx->Q_old_wtda, ALDO_WINDOW, ALDO_WINDOW, /* window overlap of current frame (0: full, 2: none, or 3: half) */ @@ -719,13 +747,12 @@ void swb_bwe_enc_fx( IF( EQ_16( st_fx->L_frame, L_FRAME16k ) ) { scl = 300; - move16(); } ELSE { scl = 240; - move16(); } + move16(); FOR( i = scl; i < inner_frame; i++ ) { max = s_max( max, abs_s( yorig_fx[i] ) ); @@ -754,11 +781,12 @@ void swb_bwe_enc_fx( ELSE { Q_shb = shr( add( st_fx->EnergyLT_fx_exp, exp ), 1 ); - IF( s_and( exp, 0x0001 ) == 1 ) + if ( EQ_16( s_and( exp, 0x0001 ), 1 ) ) { exp = sub( exp, 1 ); } st_fx->EnergyLT_fx = L_shl( st_fx->EnergyLT_fx, exp ); + move32(); } } ELSE @@ -803,13 +831,10 @@ void swb_bwe_enc_fx( L_tmp = Mult_32_16( ener_low_fx, tmp ); /*45-(exp+2*(Q_synth_hf-4)) + 2*(Q_synth_hf-4) - 15 = 30-exp */ exp1 = norm_l( L_tmp ); L_tmp = L_shl( L_tmp, exp1 ); - exp = 31 - exp1 - ( 30 - exp ); - L_tmp = Isqrt_lc( L_tmp, &exp ); /*31-exp */ -#ifdef BASOP_NOGLOB + // exp = 31 - exp1 - ( 30 - exp ); + exp = add( 31 - 30, sub( exp, exp1 ) ); + L_tmp = Isqrt_lc( L_tmp, &exp ); /*31-exp */ fb_ener_adjust_fx = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /*Q15 */ -#else - fb_ener_adjust_fx = round_fx( L_shl( L_tmp, exp ) ); /*Q15 */ -#endif } ELSE { @@ -857,6 +882,7 @@ static Word16 WB_BWE_fenv_q_fx( /* o: quantized gain i ) { Word16 i, j, indx = 0; + move16(); Word32 dist, min_dist; const Word16 *pit = cb; /*Q10 */ Word16 tmp; @@ -869,15 +895,9 @@ static Word16 WB_BWE_fenv_q_fx( /* o: quantized gain i dist = L_deposit_l( 0 ); FOR( j = 0; j < cb_dim; j++ ) { -#ifdef BASOP_NOGLOB tmp = sub_sat( x[j], *pit ); /*Q10 */ L_tmp = L_mult0( tmp, tmp ); /*Q(10+10)->Q20 */ dist = L_add_sat( dist, L_tmp ); -#else - tmp = sub( x[j], *pit ); /*Q10 */ - L_tmp = L_mult0( tmp, tmp ); /*Q(10+10)->Q20 */ - dist = L_add( dist, L_tmp ); -#endif pit++; } @@ -919,6 +939,7 @@ static void get_normalize_spec_fx( set16_fx( SWB_signal, 0, add( HQ_GENERIC_HIGH0, offset ) ); calc_normal_length_fx( core, org_fx, mode, extl, &L_swb_norm, prev_L_swb_norm, Q_new_lf ); + test(); IF( EQ_16( extl, SWB_BWE ) || EQ_16( extl, FB_BWE ) ) { @@ -1001,12 +1022,14 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class ) { Word16 i, j, k, noise, sharpMod = 0; + move16(); Word16 peak, mag; Word32 mean[20]; Word16 sharpPeak; const Word16 *input_hi = 0; Word16 sharp; Word16 gain_tmp = 0; + move16(); Word16 mode; Word32 L_meanH, L_mean_d, L_tmp; Word16 sharplimit; @@ -1014,9 +1037,8 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class Word16 numharmonic, tmp, expn, expd, scale; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; - move32(); -#endif move16(); +#endif FD_BWE_ENC_HANDLE hBWE_FD = st_fx->hBWE_FD; @@ -1042,7 +1064,6 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class IF( EQ_16( st_fx->extl, SWB_BWE ) || EQ_16( st_fx->extl, FB_BWE ) ) { input_hi = &fSpectrum[256]; - move16(); numsharp = NUM_SHARP; move16(); @@ -1053,52 +1074,32 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class { IF( hBWE_FD->prev_global_gain_fx == 0 ) { -#ifdef BASOP_NOGLOB gain_tmp = round_fx_o( L_shl_o( fGain, 30, &Overflow ), &Overflow ); /*Q14 */ -#else - gain_tmp = round_fx( L_shl( fGain, 30 ) ); /*Q14 */ -#endif } ELSE { expn = norm_l( fGain ); -#ifdef BASOP_NOGLOB num = extract_h( L_shl_o( fGain, expn, &Overflow ) ); -#else - num = extract_h( L_shl( fGain, expn ) ); -#endif expn = sub( sub( 30, expn ), shl( Q_shb, 1 ) ); expd = norm_l( hBWE_FD->prev_global_gain_fx ); -#ifdef BASOP_NOGLOB den = extract_h( L_shl_o( hBWE_FD->prev_global_gain_fx, expd, &Overflow ) ); -#else - den = extract_h( L_shl( hBWE_FD->prev_global_gain_fx, expd ) ); -#endif expd = sub( sub( 30, expd ), shl( st_fx->prev_Q_shb, 1 ) ); scale = shr( sub( den, num ), 15 ); -#ifdef BASOP_NOGLOB num = shl_o( num, scale, &Overflow ); -#else - num = shl( num, scale ); -#endif expn = sub( expn, scale ); tmp = div_s( num, den ); expn = sub( expn, expd ); -#ifdef BASOP_NOGLOB gain_tmp = shl_o( tmp, sub( expn, 1 ), &Overflow ); /*Q14 */ -#else - gain_tmp = shl( tmp, sub( expn, 1 ) ); /*Q14 */ -#endif } test(); IF( EQ_16( hBWE_FD->prev_mode, TRANSIENT ) ) { numharmonic = shl( numharmonic, 1 ); } - ELSE IF( EQ_16( hBWE_FD->prev_mode, NORMAL ) || EQ_16( hBWE_FD->prev_mode, NOISE ) ) + ELSE IF( EQ_16( hBWE_FD->prev_mode, NORMAL ) || hBWE_FD->prev_mode == NOISE ) { numharmonic = add( shr( numharmonic, 1 ), numharmonic ); } @@ -1122,7 +1123,6 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class ELSE IF( EQ_16( st_fx->extl, WB_BWE ) ) { input_hi = &fSpectrum[224]; - move16(); numsharp = 3; move16(); @@ -1158,7 +1158,7 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class FOR( j = 0; j < SHARP_WIDTH; j++ ) { mag = abs_s( *input_hi ); - IF( GT_16( mag, peak ) ) + if ( GT_16( mag, peak ) ) { peak = mag; move16(); /*Q_syn */ @@ -1175,19 +1175,15 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class L_tmp = L_sub( mean[i], peak ); /*Q_syn */ L_tmp = Mpy_32_16_1( L_tmp, 16913 ); /* 1/31->Q19 -> Q_syn+19-15 */ den = extract_l( L_shr( L_tmp, 4 ) ); /*Q_syn */ - IF( den == 0 ) + if ( den == 0 ) { den = 1; move16(); } expd = norm_s( den ); - tmp = div_s( shl( 1, sub( 14, expd ) ), den ); /*Q(29-expd-Q_syn) */ - L_tmp = L_mult( tmp, peak ); /*Q(30-expd) */ -#ifdef BASOP_NOGLOB + tmp = div_s( shl( 1, sub( 14, expd ) ), den ); /*Q(29-expd-Q_syn) */ + L_tmp = L_mult( tmp, peak ); /*Q(30-expd) */ sharp = round_fx_o( L_shl_o( L_tmp, sub( expd, 4 ), &Overflow ), &Overflow ); /*Q10 */ -#else - sharp = round_fx( L_shl( L_tmp, sub( expd, 4 ) ) ); /*Q10 */ -#endif } ELSE { @@ -1196,11 +1192,7 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class } test(); -#ifdef BASOP_NOGLOB IF( GT_16( sharp, 4608 ) && GT_16( peak, shl_o( 1, add( Q_syn, 3 ), &Overflow ) ) ) -#else - IF( GT_16( sharp, 4608 ) && GT_16( peak, shl( 1, add( Q_syn, 3 ) ) ) ) -#endif { k = add( k, 1 ); move16(); @@ -1211,12 +1203,13 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class move16(); } - IF( GT_16( sharp, sharpPeak ) ) + if ( GT_16( sharp, sharpPeak ) ) { sharpPeak = sharp; move16(); } } + test(); IF( EQ_16( st_fx->extl, SWB_BWE ) || EQ_16( st_fx->extl, FB_BWE ) ) { @@ -1226,13 +1219,12 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class IF( GE_16( k, numharmonic ) && GT_16( gain_tmp, 8192 ) && LT_16( gain_tmp, 29491 ) && GT_16( sharpPeak, shl( sharplimit, 10 ) ) ) { sharpMod = 1; - move16(); } ELSE { sharpMod = 0; - move16(); } + move16(); L_meanH = Mpy_32_16_1( L_meanH, 29127 ); /*Q_syn+8 */ L_mean_d = 0; @@ -1249,13 +1241,12 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class IF( GE_16( k, numharmonic ) && GT_16( sharpPeak, shl( sharplimit, 10 ) ) ) { sharpMod = 1; - move16(); } ELSE { sharpMod = 0; - move16(); } + move16(); } test(); @@ -1271,7 +1262,7 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class move16(); } - IF( GE_16( hBWE_FD->modeCount, 2 ) ) + if ( GE_16( hBWE_FD->modeCount, 2 ) ) { sharpMod = 1; move16(); @@ -1290,7 +1281,7 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class test(); test(); test(); - IF( GT_16( noise, 4 ) && ( LT_32( L_tmp, L_meanH ) || L_meanH == 0 ) && LT_16( tilt_nb, 10240 ) ) + if ( GT_16( noise, 4 ) && ( LT_32( L_tmp, L_meanH ) || L_meanH == 0 ) && LT_16( tilt_nb, 10240 ) ) { mode = NOISE; move16(); @@ -1343,11 +1334,7 @@ static void freq_weights_fx( { exp = norm_s( tmp ); tmp = div_s( shl( 1, sub( 14, exp ) ), tmp ); /*(21-exp) */ -#ifdef BASOP_NOGLOB - tmp = shl_sat( tmp, sub( exp, 6 ) ); /*Q15 */ -#else - tmp = shl( tmp, sub( exp, 6 ) ); /*Q15 */ -#endif + tmp = shl_sat( tmp, sub( exp, 6 ) ); /*Q15 */ } ELSE { @@ -1411,22 +1398,14 @@ static void vqWithCand_w_fx( FOR( i = 0; i < E_ROM_dico_size; i++ ) { -#ifdef BASOP_NOGLOB dist = sub_o( x[0], *p_E_ROM_dico++, &Overflow ); /*Q8 */ -#else - dist = sub( x[0], *p_E_ROM_dico++ ); /*Q8 */ -#endif - L_dist = L_mult( dist, w[0] ); /*Q22 */ - L_dist = Mult_32_16( L_dist, dist ); /*Q15 */ - L_dist = L_shr( L_dist, 10 ); /*Q5 */ + L_dist = L_mult( dist, w[0] ); /*Q22 */ + L_dist = Mult_32_16( L_dist, dist ); /*Q15 */ + L_dist = L_shr( L_dist, 10 ); /*Q5 */ FOR( j = 1; j < dim; j++ ) { -#ifdef BASOP_NOGLOB temp1 = sub_o( x[j], *p_E_ROM_dico++, &Overflow ); -#else - temp1 = sub( x[j], *p_E_ROM_dico++ ); -#endif L_tmp = L_mult( temp1, w[j] ); /*Q22 */ L_tmp = Mult_32_16( L_tmp, temp1 ); /*Q15 */ L_dist = L_add( L_dist, L_shr( L_tmp, 10 ) ); /*Q5 */ @@ -1467,13 +1446,9 @@ static void vqWithCand_w_fx( FOR( i = 0; i < E_ROM_dico_size; i++ ) { -#ifdef BASOP_NOGLOB dist = sub_sat( x[0], *p_E_ROM_dico++ ); /*Q8 */ -#else - dist = sub( x[0], *p_E_ROM_dico++ ); /*Q8 */ -#endif - L_dist = L_mult( dist, dist ); /*Q17 */ - L_dist = L_shr( L_dist, 12 ); /*Q5 */ + L_dist = L_mult_sat( dist, dist ); /*Q17 */ + L_dist = L_shr( L_dist, 12 ); /*Q5 */ FOR( j = 1; j < dim; j++ ) { @@ -1588,7 +1563,7 @@ static Word16 vqSimple_w_fx( /* Reading the selected vector */ - Copy( &cb[i_mult( index, dim )], y, dim ); + Copy( &cb[index * dim], y, dim ); return ( index ); } @@ -1741,26 +1716,20 @@ static void msvq_interpol_fx( } ind_tmp[0] = vqSimple_w_fx( quant_tmp2, quant_tmp2, EnvCdbk1st_fx, w_env11, DIM1ST, N_CB1ST, 1 ); + move16(); ind_tmp[1] = vqSimple_w_fx( quant_tmp2 + DIM1ST, quant_tmp2 + DIM1ST, EnvCdbk2nd_fx, w_env11 + DIM1ST, DIM2ND, N_CB2ND, 1 ); + move16(); /* Extract vector for odd position */ FOR( n_band = 0; n_band < DIM11; n_band++ ) { -#ifdef BASOP_NOGLOB quant_tmp[n_band] = add_o( quant_tmp1[n_band], quant_tmp2[n_band], &Overflow ); -#else - quant_tmp[n_band] = add( quant_tmp1[n_band], quant_tmp2[n_band] ); -#endif move16(); } FOR( n_band = 0; n_band < DIM12 - 1; n_band++ ) { -#ifdef BASOP_NOGLOB tmp = add_o( quant_tmp[n_band], quant_tmp[n_band + 1], &Overflow ); /*Q8 */ -#else - tmp = add( quant_tmp[n_band], quant_tmp[n_band + 1] ); /*Q8 */ -#endif tmp = shr( tmp, 1 ); quant_tmp2[n_band] = sub( env_temp12[n_band], tmp ); move16(); /*Q8 */ @@ -1783,16 +1752,12 @@ static void msvq_interpol_fx( FOR( n_band = 0; n_band < DIM12 - 1; n_band++ ) { -#ifdef BASOP_NOGLOB tmp = add_o( quant_tmp[n_band], quant_tmp[n_band + 1], &Overflow ); -#else - tmp = add( quant_tmp[n_band], quant_tmp[n_band + 1] ); -#endif tmp = shr( tmp, 1 ); - quant_select[add( shl( n_band, 1 ), 1 )] = add( tmp, quant_tmp2[n_band] ); + quant_select[( n_band << 1 ) + 1] = add( tmp, quant_tmp2[n_band] ); move16(); /*Q8 */ } - quant_select[add( shl( n_band, 1 ), 1 )] = add( quant_tmp[n_band], quant_tmp2[n_band] ); + quant_select[( n_band << 1 ) + 1] = add( quant_tmp[n_band], quant_tmp2[n_band] ); move16(); /*Q8 */ L_dist = L_deposit_l( 0 ); @@ -1907,15 +1872,9 @@ static void msvq_interpol_2_fx( move16(); FOR( n_band = 1; n_band < DIM12 - 1; n_band++ ) { -#ifdef BASOP_NOGLOB tmp_q = add_o( quant_tmp[n_band - 1], quant_tmp[n_band], &Overflow ); tmp_q = shr( tmp_q, 1 ); quant_tmp2[n_band] = sub_o( env_temp12[n_band], tmp_q, &Overflow ); -#else - tmp_q = add( quant_tmp[n_band - 1], quant_tmp[n_band] ); - tmp_q = shr( tmp_q, 1 ); - quant_tmp2[n_band] = sub( env_temp12[n_band], tmp_q ); -#endif move16(); } @@ -1936,15 +1895,9 @@ static void msvq_interpol_2_fx( move16(); /*Q8 */ FOR( n_band = 1; n_band < DIM12 - 1; n_band++ ) { -#ifdef BASOP_NOGLOB tmp_q = add_o( quant_tmp[n_band - 1], quant_tmp[n_band], &Overflow ); tmp_q = shr( tmp_q, 1 ); - quant_select[sub( shl( n_band, 1 ), 1 )] = add_o( quant_tmp2[n_band], tmp_q, &Overflow ); -#else - tmp_q = add( quant_tmp[n_band - 1], quant_tmp[n_band] ); - tmp_q = shr( tmp_q, 1 ); - quant_select[sub( shl( n_band, 1 ), 1 )] = add( quant_tmp2[n_band], tmp_q ); -#endif + quant_select[( n_band << 1 ) - 1] = add_o( quant_tmp2[n_band], tmp_q, &Overflow ); } L_dist = L_deposit_l( 0 ); @@ -1957,7 +1910,7 @@ static void msvq_interpol_2_fx( } /* Check optimal candidate */ - IF( L_dist < L_minDist ) + IF( LT_32( L_dist, L_minDist ) ) { L_minDist = L_add( L_dist, 0 ); Copy( quant_select, synth_energy, SWB_FENV - 2 ); @@ -2053,11 +2006,7 @@ static void calculate_Tonality_fx( l_shift = norm_s( max ); FOR( n_coeff = 0; n_coeff < length; n_coeff++ ) { -#ifdef BASOP_NOGLOB gen_spec[n_coeff] = shl_sat( gen_spec[n_coeff], l_shift ); -#else - gen_spec[n_coeff] = shl( gen_spec[n_coeff], l_shift ); -#endif move16(); IF( gen_spec[n_coeff] == 0 ) { @@ -2118,11 +2067,7 @@ static void calculate_Tonality_fx( L_tmp2 = Mpy_32_16_1( L_log_gm_org, inv_len ); /* Q14 */ L_tmp = L_sub( L_tmp1, L_tmp2 ); -#ifdef BASOP_NOGLOB *SFM_org = round_fx_o( L_shl_o( L_tmp, 14, &Overflow ), &Overflow ); /*Q12 */ -#else - *SFM_org = round_fx( L_shl( L_tmp, 14 ) ); /*Q12 */ -#endif move16(); *SFM_org = s_max( 0, s_min( *SFM_org, 24547 ) ); move16(); /*0.0001 and 5.993 in Q12 */ @@ -2143,11 +2088,7 @@ static void calculate_Tonality_fx( L_tmp2 = Mpy_32_16_1( L_log_gm_gen, inv_len ); /* Q14 */ L_tmp = L_sub( L_tmp1, L_tmp2 ); -#ifdef BASOP_NOGLOB *SFM_gen = round_fx_o( L_shl_o( L_tmp, 14, &Overflow ), &Overflow ); /*Q12 */ -#else - *SFM_gen = round_fx( L_shl( L_tmp, 14 ) ); /*Q12 */ -#endif move16(); *SFM_gen = s_max( 0, s_min( *SFM_gen, 24547 ) ); move16(); /*0.0001 and 5.993 in Q12 */ @@ -2223,11 +2164,7 @@ static void calculate_Tonality_ivas_fx( l_shift = norm_s( max ); FOR( n_coeff = 0; n_coeff < length; n_coeff++ ) { -#ifdef BASOP_NOGLOB gen_spec[n_coeff] = shl_sat( gen_spec[n_coeff], l_shift ); -#else - gen_spec[n_coeff] = shl( gen_spec[n_coeff], l_shift ); -#endif move16(); IF( gen_spec[n_coeff] == 0 ) { @@ -2288,11 +2225,7 @@ static void calculate_Tonality_ivas_fx( L_tmp2 = Mpy_32_16_1( L_log_gm_org, inv_len ); /* Q14 */ L_tmp = L_sub( L_tmp1, L_tmp2 ); -#ifdef BASOP_NOGLOB *SFM_org = round_fx_o( L_shl_o( L_tmp, 14, &Overflow ), &Overflow ); /*Q12 */ -#else - *SFM_org = round_fx( L_shl( L_tmp, 14 ) ); /*Q12 */ -#endif move16(); *SFM_org = s_max( 0, s_min( *SFM_org, 24547 ) ); move16(); /*0.0001 and 5.993 in Q12 */ @@ -2313,11 +2246,7 @@ static void calculate_Tonality_ivas_fx( L_tmp2 = Mpy_32_16_1( L_log_gm_gen, inv_len ); /* Q14 */ L_tmp = L_sub( L_tmp1, L_tmp2 ); -#ifdef BASOP_NOGLOB *SFM_gen = round_fx_o( L_shl_o( L_tmp, 14, &Overflow ), &Overflow ); /*Q12 */ -#else - *SFM_gen = round_fx( L_shl( L_tmp, 14 ) ); /*Q12 */ -#endif move16(); *SFM_gen = s_max( 0, s_min( *SFM_gen, 24547 ) ); move16(); /*0.0001 and 5.993 in Q12 */ @@ -2353,29 +2282,26 @@ static void energy_control_fx( IF( NE_16( coder_type, AUDIO ) && LT_32( st_fx->total_brate, ACELP_8k85 ) ) { core_type = 0; - move16(); } ELSE { core_type = 1; - move16(); } + move16(); get_normalize_spec_fx( core, st_fx->extl, mode, core_type, org_fx, SWB_signal_fx, &( hBWE_FD->prev_L_swb_norm1 ), offset, Q_new_lf ); IF( EQ_16( st_fx->extl, WB_BWE ) ) { max_band = 4; - move16(); band_step = 2; - move16(); } ELSE { max_band = SWB_FENV; - move16(); band_step = 1; - move16(); } + move16(); + move16(); } ELSE /* HQ core */ { @@ -2388,13 +2314,12 @@ static void energy_control_fx( IF( EQ_16( offset, HQ_GENERIC_FOFFSET_32K ) ) { max_band = 12; - move16(); } ELSE { max_band = SWB_FENV; - move16(); } + move16(); } FOR( n_band = 0; n_band < max_band; ) @@ -2405,7 +2330,7 @@ static void energy_control_fx( IF( LT_16( SFM_gen_fx[n_band], mult_r( 24576, SFM_org_fx[n_band] ) ) ) { energy_factor_fx[n_band] = div_s( SFM_gen_fx[n_band], SFM_org_fx[n_band] ); /*Q15 */ - IF( LT_16( energy_factor_fx[n_band], gamma_fx ) ) + if ( LT_16( energy_factor_fx[n_band], gamma_fx ) ) { energy_factor_fx[n_band] = gamma_fx; move16(); @@ -2449,29 +2374,26 @@ static void energy_control_ivas_fx( IF( NE_16( coder_type, AUDIO ) && LE_32( st_fx->total_brate, ACELP_8k00 ) ) { core_type = 0; - move16(); } ELSE { core_type = 1; - move16(); } + move16(); get_normalize_spec_fx( core, st_fx->extl, mode, core_type, org_fx, SWB_signal_fx, &( hBWE_FD->prev_L_swb_norm1 ), offset, Q_new_lf ); IF( EQ_16( st_fx->extl, WB_BWE ) ) { max_band = 4; - move16(); band_step = 2; - move16(); } ELSE { max_band = SWB_FENV; - move16(); band_step = 1; - move16(); } + move16(); + move16(); } ELSE /* HQ core */ { @@ -2484,13 +2406,12 @@ static void energy_control_ivas_fx( IF( EQ_16( offset, HQ_GENERIC_FOFFSET_32K ) ) { max_band = 12; - move16(); } ELSE { max_band = SWB_FENV; - move16(); } + move16(); } FOR( n_band = 0; n_band < max_band; ) @@ -2502,7 +2423,7 @@ static void energy_control_ivas_fx( { energy_factor_fx[n_band] = div_s( SFM_gen_fx[n_band], SFM_org_fx[n_band] ); /*Q15 */ move16(); - IF( LT_16( energy_factor_fx[n_band], gamma_fx ) ) + if ( LT_16( energy_factor_fx[n_band], gamma_fx ) ) { energy_factor_fx[n_band] = gamma_fx; move16(); @@ -2573,6 +2494,7 @@ Word16 WB_BWE_encoding_fx( /* o : classification of wb exp = sub( sub( 30, exp ), ( sub( shl( Q_synth, 1 ), 2 ) ) ); L_tmp = Mpy_32_16( exp, tmp, 32767 ); /* Q16 */ WB_fenv_fx[i] = round_fx( L_shl( L_tmp, 10 ) ); /*Q10 */ + move16(); } ELSE { @@ -2701,6 +2623,7 @@ static Word16 SWB_BWE_encoding_fx( Word16 energy_factor_fx[SWB_FENV], w_env_fx[SWB_FENV]; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move16(); #endif FD_BWE_ENC_HANDLE hBWE_FD = st_fx->hBWE_FD; @@ -2709,13 +2632,12 @@ static Word16 SWB_BWE_encoding_fx( IF( EQ_16( st_fx->L_frame, L_FRAME ) ) { L = L_SUBFR; - move16(); } ELSE { L = L_SUBFR16k; - move16(); } + move16(); /* HF transient detect */ IsTransient = detect_transient_fx( insig_hp_fx, L_FRAME16k, Q_shb, st_fx ); @@ -2733,7 +2655,7 @@ static Word16 SWB_BWE_encoding_fx( energy_fx = L_add( energy_fx, L_shr( L_mult0( insig_lp_fx[i + tmp], insig_lp_fx[i + tmp] ), 7 ) ); /*2*Q_slb_speech - 7 */ } - IF( GT_32( Mult_32_16( energy_fx, 5958 ), hBWE_FD->EnergyLF_fx ) ) + if ( GT_32( Mult_32_16( energy_fx, 5958 ), hBWE_FD->EnergyLF_fx ) ) { IsTransient_LF = 1; move16(); @@ -2744,11 +2666,7 @@ static Word16 SWB_BWE_encoding_fx( } /* tilt returned in Q24 go to Q11 */ -#ifdef BASOP_NOGLOB tilt_fx = round_fx_o( L_shl_o( calc_tilt_bwe_fx( insig_fx, 0, L_FRAME32k ), 3, &Overflow ), &Overflow ); -#else - tilt_fx = round_fx( L_shl( calc_tilt_bwe_fx( insig_fx, 0, L_FRAME32k ), 3 ) ); -#endif test(); test(); IF( EQ_16( IsTransient, 1 ) && ( GT_16( tilt_fx, 16384 ) || GT_16( st_fx->clas, 1 ) ) ) @@ -2788,7 +2706,6 @@ static Word16 SWB_BWE_encoding_fx( L_tmp = Mult_32_16( L_SWB_fenv_fx[n_band], tmp ); /*2*Q_synth-7+29-expd - 15 */ exp = norm_l( L_tmp ); tmp = Log2_norm_lc( L_shl( L_tmp, exp ) ); - move16(); exp = sub( sub( 30, exp ), sub( add( shl( Q_synth, 1 ), 7 ), expd ) ); L_tmp = Mpy_32_16( exp, tmp, 24660 ); /* Q14 */ /*10log10(2) in Q13 */ tmp = round_fx( L_shl( L_tmp, 10 ) ); /* Q8 */ @@ -2805,11 +2722,7 @@ static Word16 SWB_BWE_encoding_fx( L_SWB_tenv = L_deposit_l( 0 ); FOR( i = 0; i < L_SUBFR16k; i++ ) { -#ifdef BASOP_NOGLOB L_SWB_tenv = L_add_sat( L_SWB_tenv, L_mult0( insig_hp_fx[i + tmp], insig_hp_fx[i + tmp] ) ); /*2*Q_shb */ -#else - L_SWB_tenv = L_add( L_SWB_tenv, L_mult0( insig_hp_fx[i + tmp], insig_hp_fx[i + tmp] ) ); /*2*Q_shb */ -#endif } tmp = i_mult2( n_band, L ); @@ -2832,11 +2745,8 @@ static Word16 SWB_BWE_encoding_fx( L_tmp = L_deposit_h( tmp ); L_tmp = Isqrt_lc( L_tmp, &exp ); /*Q(31-exp) */ -#ifdef BASOP_NOGLOB - SWB_tenv_fx[n_band] = round_fx_sat( L_shl_sat( L_tmp, sub( exp, 12 ) ) ); /*Q3 */ -#else - SWB_tenv_fx[n_band] = round_fx( L_shl( L_tmp, sub( exp, 12 ) ) ); /*Q3 */ -#endif + SWB_tenv_fx[n_band] = round_fx_sat( L_shl_sat( L_tmp, sub( exp, 12 ) ) ); /*Q3*/ + move16(); } } @@ -2860,11 +2770,7 @@ static Word16 SWB_BWE_encoding_fx( L_tmp = L_deposit_h( tmp ); L_tmp = Isqrt_lc( L_tmp, &expn ); /*31-expn */ -#ifdef BASOP_NOGLOB Rat_tenv_fx = round_fx_o( L_shl_o( L_tmp, sub( expn, 1 ), &Overflow ), &Overflow ); /*Q14 */ -#else - Rat_tenv_fx = round_fx( L_shl( L_tmp, sub( expn, 1 ) ) ); /*Q14 */ -#endif } ELSE { @@ -2875,11 +2781,8 @@ static Word16 SWB_BWE_encoding_fx( IF( LT_16( Rat_tenv_fx, 8192 ) ) { L_tmp = L_mult( Rat_tenv_fx, 19661 ); /*Q29 */ -#ifdef BASOP_NOGLOB + Rat_tenv_fx = round_fx_o( L_shl_o( L_tmp, 2, &Overflow ), &Overflow ); /*Q15 */ -#else - Rat_tenv_fx = round_fx( L_shl( L_tmp, 2 ) ); /*Q15 */ -#endif } ELSE IF( GT_16( Rat_tenv_fx, 16384 ) ) { @@ -2945,11 +2848,8 @@ static Word16 SWB_BWE_encoding_fx( } /*SWB_tenv_fx[pos] = add(SWB_tenv_fx[pos], mult_r(SWB_tenv_fx[pos], 164)); move16();//Q3 */ -#ifdef BASOP_NOGLOB SWB_tenv_fx[pos] = round_fx_sat( L_mac_sat( L_mult_sat( SWB_tenv_fx[pos], 32767 ), SWB_tenv_fx[pos], 164 ) ); /*Q3 */ -#else - SWB_tenv_fx[pos] = round_fx( L_mac( L_mult( SWB_tenv_fx[pos], 32767 ), SWB_tenv_fx[pos], 164 ) ); /*Q3 */ -#endif + move16(); IF( LT_32( energy_fx, SWB_tenv_fx[pos] ) ) { @@ -2967,21 +2867,14 @@ static Word16 SWB_BWE_encoding_fx( IF( GT_16( SWB_tenv_fx[n_band - 1], SWB_tenv_fx[n_band] ) ) { /*SWB_tenv_fx[n_band-1] = add(mult_r(SWB_tenv_fx[n_band-1], 16384), mult_r(SWB_tenv_fx[n_band], 16384)); move16();//Q3 */ -#ifdef BASOP_NOGLOB SWB_tenv_fx[n_band - 1] = round_fx_sat( L_mac_sat( L_mult( SWB_tenv_fx[n_band - 1], 16384 ), SWB_tenv_fx[n_band], 16384 ) ); /*Q3 */ -#else - SWB_tenv_fx[n_band - 1] = round_fx( L_mac( L_mult( SWB_tenv_fx[n_band - 1], 16384 ), SWB_tenv_fx[n_band], 16384 ) ); /*Q3 */ -#endif } ELSE { /*SWB_tenv_fx[n_band] = add(mult_r(SWB_tenv_fx[n_band-1], 16384), mult_r(SWB_tenv_fx[n_band], 16384)); move16();//Q3 */ -#ifdef BASOP_NOGLOB SWB_tenv_fx[n_band] = round_fx_sat( L_mac_sat( L_mult( SWB_tenv_fx[n_band - 1], 16384 ), SWB_tenv_fx[n_band], 16384 ) ); /*Q3 */ -#else - SWB_tenv_fx[n_band] = round_fx( L_mac( L_mult( SWB_tenv_fx[n_band - 1], 16384 ), SWB_tenv_fx[n_band], 16384 ) ); /*Q3 */ -#endif } + move16(); } FOR( n_band = 0; n_band < SWB_TENV; n_band++ ) @@ -3029,6 +2922,7 @@ static Word16 SWB_BWE_encoding_fx( expn = sub( sub( 30, expn ), 19 ); L_tmp = Mpy_32_16( expn, tmp, 32767 ); /* Q16 */ /*1 in Q15 */ SWB_tenv_tmp_fx[n_band] = round_fx( L_shl( L_tmp, 11 ) ); /* Q11 */ + move16(); } IF( GT_16( SWB_tenv_tmp_fx[n_band], 30720 ) ) @@ -3093,6 +2987,7 @@ static Word16 SWB_BWE_encoding_fx( expn = sub( 30, add( expn, sub( shl( Q_synth, 1 ), 5 ) ) ); L_tmp = Mpy_32_16( expn, tmp, 24660 ); /* Q14 */ /*10log10(2) in Q13 */ SWB_fenv_fx[n_band] = round_fx( L_shl( L_tmp, 10 ) ); /* Q8 */ + move16(); } ELSE { @@ -3218,25 +3113,23 @@ static Word16 SWB_BWE_encoding_ivas_fx( energy_fx = L_deposit_l( 0 ); FOR( i = 0; i < L; i++ ) { - energy_fx = L_add( energy_fx, L_shr( L_mult0( insig_lp_fx[i + tmp], insig_lp_fx[i + tmp] ), 7 ) ); /*2*Q_slb_speech - 7 */ + energy_fx = L_add( energy_fx, L_shr( L_mult0( insig_lp_fx[i + tmp], insig_lp_fx[i + tmp] ), 7 ) ); /*Q = 2 * Q_insig_lp - 7 */ } - IF( GT_32( Mult_32_16( energy_fx, 5958 ), hBWE_FD->EnergyLF_fx ) ) + if ( BASOP_Util_Cmp_Mant32Exp( Mpy_32_16_1( energy_fx, 5958 /* 1/5.5f in Q15 */ ), sub( 31 + 7, shl( Q_insig_lp, 1 ) ), hBWE_FD->EnergyLF_fx, hBWE_FD->EnergyLF_exp ) > 0 ) { IsTransient_LF = 1; move16(); } hBWE_FD->EnergyLF_fx = energy_fx; + hBWE_FD->EnergyLF_exp = sub( 31 + 7, shl( Q_insig_lp, 1 ) ); move32(); + move16(); } /* tilt returned in Q24 go to Q11 */ -#ifdef BASOP_NOGLOB tilt_fx = round_fx_o( L_shl_o( calc_tilt_bwe_fx( insig_fx, 0, L_FRAME32k ), 3, &Overflow ), &Overflow ); -#else - tilt_fx = round_fx( L_shl( calc_tilt_bwe_fx( insig_fx, 0, L_FRAME32k ), 3 ) ); -#endif test(); test(); IF( EQ_16( IsTransient, 1 ) && ( GT_16( tilt_fx, 16384 ) || GT_16( st_fx->clas, 1 ) ) ) @@ -3306,11 +3199,7 @@ static Word16 SWB_BWE_encoding_ivas_fx( L_SWB_tenv = L_deposit_l( 0 ); FOR( i = 0; i < L_SUBFR16k; i++ ) { -#ifdef BASOP_NOGLOB L_SWB_tenv = L_add_sat( L_SWB_tenv, L_mult0( insig_hp_fx[i + tmp], insig_hp_fx[i + tmp] ) ); /*2*Q_shb */ -#else - L_SWB_tenv = L_add( L_SWB_tenv, L_mult0( insig_hp_fx[i + tmp], insig_hp_fx[i + tmp] ) ); /*2*Q_shb */ -#endif } tmp = i_mult2( n_band, L ); @@ -3333,11 +3222,7 @@ static Word16 SWB_BWE_encoding_ivas_fx( L_tmp = L_deposit_h( tmp ); L_tmp = Isqrt_lc( L_tmp, &exp ); /*Q(31-exp) */ -#ifdef BASOP_NOGLOB SWB_tenv_fx[n_band] = round_fx_sat( L_shl_sat( L_tmp, sub( exp, 12 ) ) ); /*Q3 */ -#else - SWB_tenv_fx[n_band] = round_fx( L_shl( L_tmp, sub( exp, 12 ) ) ); /*Q3 */ -#endif move16(); } } @@ -3350,11 +3235,7 @@ static Word16 SWB_BWE_encoding_ivas_fx( expd = norm_l( WB_tenv_syn_fx ); #ifdef FIX_ISSUE_1156 -#ifdef BASOP_NOGLOB den = round_fx_o( L_shl( WB_tenv_syn_fx, expd ), &Overflow ); -#else - den = round_fx( L_shl( WB_tenv_syn_fx, expd ) ); -#endif #else den = round_fx( L_shl( WB_tenv_syn_fx, expd ) ); #endif @@ -3370,11 +3251,7 @@ static Word16 SWB_BWE_encoding_ivas_fx( L_tmp = L_deposit_h( tmp ); L_tmp = Isqrt_lc( L_tmp, &expn ); /*31-expn */ -#ifdef BASOP_NOGLOB Rat_tenv_fx = round_fx_o( L_shl_o( L_tmp, sub( expn, 1 ), &Overflow ), &Overflow ); /*Q14 */ -#else - Rat_tenv_fx = round_fx( L_shl( L_tmp, sub( expn, 1 ) ) ); /*Q14 */ -#endif } ELSE { @@ -3384,12 +3261,8 @@ static Word16 SWB_BWE_encoding_ivas_fx( IF( LT_16( Rat_tenv_fx, 8192 ) ) { - L_tmp = L_mult( Rat_tenv_fx, 19661 ); /*Q29 */ -#ifdef BASOP_NOGLOB + L_tmp = L_mult( Rat_tenv_fx, 19661 ); /*Q29 */ Rat_tenv_fx = round_fx_o( L_shl_o( L_tmp, 2, &Overflow ), &Overflow ); /*Q15 */ -#else - Rat_tenv_fx = round_fx( L_shl( L_tmp, 2 ) ); /*Q15 */ -#endif } ELSE IF( GT_16( Rat_tenv_fx, 16384 ) ) { @@ -3455,11 +3328,7 @@ static Word16 SWB_BWE_encoding_ivas_fx( } /*SWB_tenv_fx[pos] = add(SWB_tenv_fx[pos], mult_r(SWB_tenv_fx[pos], 164)); move16();//Q3 */ -#ifdef BASOP_NOGLOB SWB_tenv_fx[pos] = round_fx_sat( L_mac_sat( L_mult_sat( SWB_tenv_fx[pos], 32767 ), SWB_tenv_fx[pos], 164 ) ); /*Q3 */ -#else - SWB_tenv_fx[pos] = round_fx( L_mac( L_mult( SWB_tenv_fx[pos], 32767 ), SWB_tenv_fx[pos], 164 ) ); /*Q3 */ -#endif move16(); IF( LT_32( energy_fx, SWB_tenv_fx[pos] ) ) @@ -3478,21 +3347,13 @@ static Word16 SWB_BWE_encoding_ivas_fx( IF( GT_16( SWB_tenv_fx[n_band - 1], SWB_tenv_fx[n_band] ) ) { /*SWB_tenv_fx[n_band-1] = add(mult_r(SWB_tenv_fx[n_band-1], 16384), mult_r(SWB_tenv_fx[n_band], 16384)); move16();//Q3 */ -#ifdef BASOP_NOGLOB SWB_tenv_fx[n_band - 1] = round_fx_sat( L_mac_sat( L_mult( SWB_tenv_fx[n_band - 1], 16384 ), SWB_tenv_fx[n_band], 16384 ) ); /*Q3 */ -#else - SWB_tenv_fx[n_band - 1] = round_fx( L_mac( L_mult( SWB_tenv_fx[n_band - 1], 16384 ), SWB_tenv_fx[n_band], 16384 ) ); /*Q3 */ -#endif move16(); } ELSE { /*SWB_tenv_fx[n_band] = add(mult_r(SWB_tenv_fx[n_band-1], 16384), mult_r(SWB_tenv_fx[n_band], 16384)); move16();//Q3 */ -#ifdef BASOP_NOGLOB SWB_tenv_fx[n_band] = round_fx_sat( L_mac_sat( L_mult( SWB_tenv_fx[n_band - 1], 16384 ), SWB_tenv_fx[n_band], 16384 ) ); /*Q3 */ -#else - SWB_tenv_fx[n_band] = round_fx( L_mac( L_mult( SWB_tenv_fx[n_band - 1], 16384 ), SWB_tenv_fx[n_band], 16384 ) ); /*Q3 */ -#endif move16(); } } @@ -3801,13 +3662,8 @@ static void calculate_tonality_fx_32( FOR( n_coeff = 0; n_coeff < length; n_coeff++ ) { -#ifdef BASOP_NOGLOB am_org_fx = L_add_sat( am_org_fx, org_spec_fx[n_coeff] ); am_gen_fx = L_add_sat( am_gen_fx, gen_spec_fx[n_coeff] ); -#else - am_org_fx = L_add( am_org_fx, org_spec_fx[n_coeff] ); - am_gen_fx = L_add( am_gen_fx, gen_spec_fx[n_coeff] ); -#endif IF( org_spec_fx[n_coeff] != 0 ) { exp = norm_l( org_spec_fx[n_coeff] ); @@ -4017,26 +3873,18 @@ static Word16 decision_hq_generic_class_fx_32( { a_fx = L_deposit_l( 0 ); p_fx = L_deposit_l( 0 ); - tmp2 = add( swb_bwe_subband[add( k, 1 )], hq_generic_offset ); + tmp2 = add( swb_bwe_subband[k + 1], hq_generic_offset ); FOR( i = add( swb_bwe_subband[k], hq_generic_offset ); i < tmp2; i++ ) { exp = norm_l( coefs_fx[i] ); - tmp = extract_h( L_shl( coefs_fx[i], exp ) ); /*12 + exp - 16 */ - L_tmp = L_mult0( tmp, tmp ); /*2 * exp - 8 */ -#ifdef BASOP_NOGLOB + tmp = extract_h( L_shl( coefs_fx[i], exp ) ); /*12 + exp - 16 */ + L_tmp = L_mult0( tmp, tmp ); /*2 * exp - 8 */ L_tmp = L_shl_sat( L_tmp, sub( 14, shl( exp, 1 ) ) ); /*6 */ -#else - L_tmp = L_shl( L_tmp, sub( 14, shl( exp, 1 ) ) ); /*6 */ -#endif IF( GT_32( L_tmp, p_fx ) ) { p_fx = L_add( L_tmp, 0 ); /*6 */ } -#ifdef BASOP_NOGLOB a_fx = L_add_sat( a_fx, L_tmp ); /*6 */ -#else - a_fx = L_add( a_fx, L_tmp ); /*6 */ -#endif } IF( a_fx > 0 ) @@ -4084,7 +3932,7 @@ void hq_generic_encoding_fx( Word16 indice[HQ_GENERIC_NVQIDX]; Word16 nenv; - Word16 energy_factor_fx[SWB_FENV] = { 0 }; + Word16 energy_factor_fx[SWB_FENV]; Word16 cs, exp, tmp, tmp2; Word32 energy_fx; Word32 L_tmp, max_coefs_fx; @@ -4092,6 +3940,7 @@ void hq_generic_encoding_fx( HQ_ENC_HANDLE hHQ_core = st_fx->hHQ_core; BSTR_ENC_HANDLE hBstr = st_fx->hBstr; + set16_fx( energy_factor_fx, 0, SWB_FENV ); IF( LE_16( hq_generic_offset, HQ_GENERIC_FOFFSET_24K4 ) ) { @@ -4116,6 +3965,7 @@ void hq_generic_encoding_fx( ELSE { *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 ); } @@ -4125,7 +3975,7 @@ void hq_generic_encoding_fx( energy_fx = L_deposit_l( 0 ); max_coefs_fx = L_deposit_l( 0 ); tmp2 = add( swb_bwe_subband[n_band + 1], hq_generic_offset ); - FOR( n_coeff = add( swb_bwe_subband[n_band], hq_generic_offset ); n_coeff < tmp2; n_coeff++ ) + FOR( n_coeff = swb_bwe_subband[n_band] + hq_generic_offset; n_coeff < tmp2; n_coeff++ ) { IF( LT_32( max_coefs_fx, L_abs( coefs_fx[n_coeff] ) ) ) { @@ -4134,7 +3984,7 @@ void hq_generic_encoding_fx( } cs = norm_l( max_coefs_fx ); tmp2 = add( swb_bwe_subband[n_band + 1], hq_generic_offset ); - FOR( n_coeff = add( swb_bwe_subband[n_band], hq_generic_offset ); n_coeff < tmp2; n_coeff++ ) + FOR( n_coeff = swb_bwe_subband[n_band] + hq_generic_offset; n_coeff < tmp2; n_coeff++ ) { tmp = extract_h( L_shl( coefs_fx[n_coeff], cs ) ); /*12 + cs - 16 */ L_tmp = L_mult0( tmp, tmp ); /*2*cs - 8 */ @@ -4152,6 +4002,7 @@ void hq_generic_encoding_fx( L_tmp = Mpy_32_16( exp, tmp, 24660 ); /* Q14 */ /*10log10(2) in Q13 */ hq_generic_fenv_fx[n_band] = round_fx( L_shl( L_tmp, 10 ) ); /*Q8 */ + move16(); } ELSE { @@ -4175,7 +4026,7 @@ void hq_generic_encoding_fx( } } cs = norm_l( max_coefs_fx ); - tmp2 = fb_bwe_subband[add( n_band, 1 )]; + tmp2 = fb_bwe_subband[n_band + 1]; FOR( n_coeff = fb_bwe_subband[n_band]; n_coeff < tmp2; n_coeff++ ) { tmp = extract_h( L_shl( coefs_fx[n_coeff], cs ) ); /*12 + cs - 16 */ @@ -4191,12 +4042,13 @@ void hq_generic_encoding_fx( tmp = Log2_norm_lc( L_shl( L_tmp, exp ) ); exp = sub( 30, add( exp, 2 * cs - 13 ) ); - L_tmp = Mpy_32_16( exp, tmp, 24660 ); /* Q14 */ /*10log10(2) in Q13 */ - hq_generic_fenv_fx[add( n_band, nenv )] = round_fx( L_shl( L_tmp, 10 ) ); /*Q8 */ + L_tmp = Mpy_32_16( exp, tmp, 24660 ); /* Q14 */ /*10log10(2) in Q13 */ + hq_generic_fenv_fx[n_band + nenv] = round_fx( L_shl( L_tmp, 10 ) ); /*Q8 */ + move16(); } ELSE { - hq_generic_fenv_fx[add( n_band, nenv )] = -24576; + hq_generic_fenv_fx[n_band + nenv] = -24576; move16(); } } @@ -4207,13 +4059,15 @@ void hq_generic_encoding_fx( FOR( n_band = 0; n_band < nenv; n_band++ ) { hq_generic_fenv_fx[n_band] = sub( hq_generic_fenv_fx[n_band], Mean_env_fx[n_band] ); + move16(); } IF( st_fx->bwidth == FB ) { FOR( n_band = 0; n_band < DIM_FB; n_band++ ) { - hq_generic_fenv_fx[add( n_band, nenv )] = sub( shr( hq_generic_fenv_fx[add( n_band, nenv )], 1 ), Mean_env_fb_fx[n_band] ); + hq_generic_fenv_fx[n_band + nenv] = sub( shr( hq_generic_fenv_fx[n_band + nenv], 1 ), Mean_env_fb_fx[n_band] ); + move16(); } } @@ -4231,6 +4085,7 @@ void hq_generic_encoding_fx( IF( EQ_16( st_fx->bwidth, FB ) ) { indice[5] = vqSimple_w_fx( hq_generic_fenv_fx + nenv, hq_generic_fenv_fx + nenv, EnvCdbkFB_fx, NULL, DIM_FB, N_CB_FB, 0 ); + move16(); } push_indice_fx( hBstr, IND_SWB_FENV_HQ, indice[0], 5 ); @@ -4260,11 +4115,8 @@ void hq_generic_encoding_fx( L_Extract( L_tmp, &exp, &tmp ); /* */ tmp = extract_l( Pow2( 13, tmp ) ); exp = sub( exp, 13 ); -#ifdef BASOP_NOGLOB hq_generic_fenv_fx[n_band] = shl_sat( tmp, add( exp, 1 ) ); /*1 */ -#else - hq_generic_fenv_fx[n_band] = shl( tmp, add( exp, 1 ) ); /*1 */ -#endif + move16(); } @@ -4272,13 +4124,14 @@ void hq_generic_encoding_fx( { FOR( n_band = 0; n_band < DIM_FB; n_band++ ) { - tmp = add( hq_generic_fenv_fx[add( n_band, nenv )], Mean_env_fb_fx[n_band] ); /*7 */ - L_tmp = L_mult( tmp, 21771 ); /*25 */ - L_tmp = L_shr( L_tmp, 9 ); /*16 */ + tmp = add( hq_generic_fenv_fx[n_band + nenv], Mean_env_fb_fx[n_band] ); /*7 */ + L_tmp = L_mult( tmp, 21771 ); /*25 */ + L_tmp = L_shr( L_tmp, 9 ); /*16 */ L_Extract( L_tmp, &exp, &tmp ); tmp = extract_l( Pow2( 13, tmp ) ); exp = sub( exp, 13 ); - hq_generic_fenv_fx[add( n_band, nenv )] = shl( tmp, add( exp, 1 ) ); /*2 */ + hq_generic_fenv_fx[n_band + nenv] = shl( tmp, add( exp, 1 ) ); /*2 */ + move16(); } } @@ -4296,6 +4149,10 @@ 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 @@ -4314,8 +4171,10 @@ void fd_bwe_enc_init_fx( hBWE_FD->modeCount = 0; move16(); hBWE_FD->EnergyLF_fx = 0; + hBWE_FD->EnergyLF_exp = 0; hBWE_FD->mem_old_wtda_swb_fx = 0; move32(); + move16(); move32(); hBWE_FD->prev_Q_input_lp = 0; @@ -4418,6 +4277,7 @@ void hq_generic_hf_encoding_fx( L_tmp = Mpy_32_16( exp, tmp, 24660 ); /* Q14 */ /*10log10(2) in Q13 */ hq_generic_fenv_fx[n_band] = round_fx( L_shl( L_tmp, 10 ) ); /*Q8 */ + move16(); } ELSE { @@ -4457,13 +4317,13 @@ void hq_generic_hf_encoding_fx( tmp = Log2_norm_lc( L_shl( L_tmp, exp ) ); exp = sub( 30, add( exp, sub( shl( cs, 1 ), 13 ) ) ); - L_tmp = Mpy_32_16( exp, tmp, 24660 ); /* Q14 */ /*10log10(2) in Q13 */ - hq_generic_fenv_fx[add( n_band, nenv )] = round_fx( L_shl( L_tmp, 10 ) ); /*Q8 */ + L_tmp = Mpy_32_16( exp, tmp, 24660 ); /* Q14 */ /*10log10(2) in Q13 */ + hq_generic_fenv_fx[n_band + nenv] = round_fx( L_shl( L_tmp, 10 ) ); /*Q8 */ move16(); } ELSE { - hq_generic_fenv_fx[add( n_band, nenv )] = -24576; + hq_generic_fenv_fx[n_band + nenv] = -24576; move16(); } } @@ -4481,7 +4341,7 @@ void hq_generic_hf_encoding_fx( { FOR( n_band = 0; n_band < DIM_FB; n_band++ ) { - hq_generic_fenv_fx[add( n_band, nenv )] = sub( shr( hq_generic_fenv_fx[add( n_band, nenv )], 1 ), Mean_env_fb_fx[n_band] ); + hq_generic_fenv_fx[n_band + nenv] = sub( shr( hq_generic_fenv_fx[n_band + nenv], 1 ), Mean_env_fb_fx[n_band] ); move16(); } } @@ -4499,15 +4359,15 @@ void hq_generic_hf_encoding_fx( IF( EQ_16( length, L_SPEC48k ) ) { - Word16 sf = getScaleFactor16( hq_generic_fenv_fx, DIM_FB + nenv ); - Scale_sig( hq_generic_fenv_fx, DIM_FB + nenv, negate( sf ) ); + Word16 sf = getScaleFactor16( hq_generic_fenv_fx, add( DIM_FB, nenv ) ); + Scale_sig( hq_generic_fenv_fx, add( DIM_FB, nenv ), negate( sf ) ); Copy_Scale_sig( EnvCdbkFB_fx, EnvCdbkFB_fx_loc, N_CB_FB * DIM_FB, negate( sf ) ); // Scaling done to handel overflow inside vqSimple_w_fx indice[5] = vqSimple_w_fx( hq_generic_fenv_fx + nenv, hq_generic_fenv_fx + nenv, EnvCdbkFB_fx_loc, NULL, DIM_FB, N_CB_FB, 0 ); move16(); - Scale_sig( hq_generic_fenv_fx, DIM_FB + nenv, sf ); + Scale_sig( hq_generic_fenv_fx, add( DIM_FB, nenv ), sf ); } push_indice( hBstr, IND_SWB_FENV_HQ, indice[0], 5 ); @@ -4537,11 +4397,7 @@ void hq_generic_hf_encoding_fx( L_Extract( L_tmp, &exp, &tmp ); /* */ tmp = extract_l( Pow2( 13, tmp ) ); exp = sub( exp, 13 ); -#ifdef BASOP_NOGLOB hq_generic_fenv_fx[n_band] = shl_sat( tmp, add( exp, 1 ) ); /*1 */ -#else - hq_generic_fenv_fx[n_band] = shl( tmp, add( exp, 1 ) ); /*1 */ -#endif move16(); } @@ -4550,13 +4406,13 @@ void hq_generic_hf_encoding_fx( { FOR( n_band = 0; n_band < DIM_FB; n_band++ ) { - tmp = add( hq_generic_fenv_fx[add( n_band, nenv )], Mean_env_fb_fx[n_band] ); /*7 */ - L_tmp = L_mult( tmp, 21771 ); /*25 */ - L_tmp = L_shr( L_tmp, 9 ); /*16 */ + tmp = add( hq_generic_fenv_fx[n_band + nenv], Mean_env_fb_fx[n_band] ); /*7 */ + L_tmp = L_mult( tmp, 21771 ); /*25 */ + L_tmp = L_shr( L_tmp, 9 ); /*16 */ L_Extract( L_tmp, &exp, &tmp ); tmp = extract_l( Pow2( 13, tmp ) ); exp = sub( exp, 13 ); - hq_generic_fenv_fx[add( n_band, nenv )] = shl( tmp, add( exp, 1 ) ); /*1 */ + hq_generic_fenv_fx[n_band + nenv] = shl( tmp, add( exp, 1 ) ); /*1 */ move16(); } } diff --git a/lib_enc/swb_bwe_enc_hr.c b/lib_enc/swb_bwe_enc_hr.c deleted file mode 100644 index 8e752f0ac516550ba25f4c9dcce588dfd9e16b42..0000000000000000000000000000000000000000 --- a/lib_enc/swb_bwe_enc_hr.c +++ /dev/null @@ -1,42 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "prot.h" -#include "rom_com.h" -#include "wmc_auto.h" diff --git a/lib_enc/swb_bwe_enc_hr_fx.c b/lib_enc/swb_bwe_enc_hr_fx.c index 094ad37fa96e5d3e5371e3b7e55ff76d6cd87dc2..fd4a9f1259669e751e5164a7814c623739939c11 100644 --- a/lib_enc/swb_bwe_enc_hr_fx.c +++ b/lib_enc/swb_bwe_enc_hr_fx.c @@ -4,10 +4,9 @@ #include #include #include "options.h" -#include "cnst.h" /* Common constants */ -#include "rom_enc.h" /* Encoder static table prototypes */ -#include "rom_com_fx.h" /* Static table prototypes */ -//#include "prot_fx.h" /* Function prototypes */ +#include "cnst.h" /* Common constants */ +#include "rom_enc.h" /* Encoder static table prototypes */ +#include "rom_com_fx.h" /* Static table prototypes */ #include "rom_com.h" /* Common constants */ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ @@ -120,6 +119,7 @@ void swb_bwe_enc_hr_fx( #endif #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move16(); #endif FD_BWE_ENC_HANDLE hBWE_FD = st_fx->hBWE_FD; BSTR_ENC_HANDLE hBstr = st_fx->hBstr; @@ -132,9 +132,7 @@ void swb_bwe_enc_hr_fx( /* Use 32 Bits Buffer to Store Two 16 Bits Vectors in Order to Save Stack Space */ t_audio_fx = (Word16 *) &t_audio32[0]; - move16(); t_audio_tmp_fx = (Word16 *) &t_audio32[L_FRAME48k / 2]; - move16(); ind2 = 0; move16(); /* only to suppress warnings */ @@ -185,6 +183,7 @@ void swb_bwe_enc_hr_fx( Copy_Scale_sig( new_input_fx, t_audio_fx, input_frame, temp ); /* Bring Energy in 2*Q'exp1' */ st_fx->EnergyLT_fx = L_shl( st_fx->EnergyLT_fx, shl( sub( exp1, st_fx->EnergyLT_fx_exp ), 1 ) ); + move32(); is_transient = detect_transient_fx( t_audio_fx, input_frame, exp1, st_fx ); st_fx->EnergyLT_fx_exp = exp1; @@ -201,6 +200,7 @@ void swb_bwe_enc_hr_fx( st_fx->Q_old_wtda = new_input_fx_exp; move16(); new_input_fx_exp = 0; + move16(); wtda_fx( new_input_fx, &new_input_fx_exp, L_t_audio_tmp_fx, hBWE_FD->L_old_wtda_swb_fx, &st_fx->Q_old_wtda, ALDO_WINDOW, ALDO_WINDOW, input_frame ); @@ -246,7 +246,6 @@ void swb_bwe_enc_hr_fx( scl = 99; move16(); ptr16 = &t_audio_fx[NUM_TRANS_START_FREQ_COEF]; - move16(); FOR( k = 0; k < input_frame; k += temp ) { /* from t_audio_fx[k..NUM_TRANS_START_FREQ_COEF+k-1] will be zeroed out */ @@ -314,8 +313,7 @@ void swb_bwe_enc_hr_fx( nBits = sub( nBits, NBITS_GLOB_GAIN_BWE_HR ); /* normalization with global gain */ - ptr16 = &t_audio_fx[add( NUM_TRANS_START_FREQ_COEF, temp )]; - move16(); + ptr16 = &t_audio_fx[NUM_TRANS_START_FREQ_COEF + temp]; temp2 = negate( exp1 ); gain2_fx = Invert16( gain1_fx, &temp2 ); @@ -326,6 +324,7 @@ void swb_bwe_enc_hr_fx( L_temp = L_mult( *ptr16, gain2_fx ); L_temp = L_shr( L_temp, temp2 ); *ptr16++ = round_fx( L_temp ); + move16(); } FOR( ; i < L_FRAME32k / NUM_TIME_SWITCHING_BLOCKS - NUM_TRANS_START_FREQ_COEF; i++ ) { @@ -339,18 +338,14 @@ void swb_bwe_enc_hr_fx( *---------------------------------------------------------------------*/ /* compute energy per band */ - ptr16 = &t_audio_fx[add( temp, NUM_TRANS_START_FREQ_COEF )]; - move16(); + ptr16 = &t_audio_fx[temp + NUM_TRANS_START_FREQ_COEF]; FOR( i = 0; i < N_BANDS_TRANS_BWE_HR; i++ ) { L_temp = Calc_Energy_Autoscaled( ptr16, t_audio_fx_exp, WIDTH_TRANS_FREQ_COEF, &temp2 ); ptr16 += WIDTH_TRANS_FREQ_COEF; L_temp = Sqrt_Ratio32( L_temp, temp2, WIDTH_TRANS_FREQ_COEF, /*WIDTH_TRANS_FREQ_COEF is in Q0*/ 0, &temp2 ); -#ifdef BASOP_NOGLOB en_band_fx[i] = round_fx_sat( L_shr_sat( L_temp, sub( 15 - 9, temp2 ) ) ); -#else - en_band_fx[i] = round_fx( L_shr( L_temp, sub( 15 - 9, temp2 ) ) ); -#endif + move16(); } /* Q energy per band */ @@ -368,12 +363,10 @@ void swb_bwe_enc_hr_fx( IF( LT_16( ind2, NUM_ENVLOPE_CODE_HR_TR2 ) ) { ind1 = en_band_quant_fx( en_band_fx, swb_hr_env_code3_fx, NUM_ENVLOPE_CODE_HR_TR2 ); - move16(); } ELSE { ind1 = en_band_quant_fx( en_band_fx, swb_hr_env_code3_fx + ( NUM_ENVLOPE_CODE_HR_TR2 * 2 ), NUM_ENVLOPE_CODE_HR_TR2 ); - move16(); } push_indice_fx( hBstr, IND_HR_ENVELOPE, ind1, NBITS_ENVELOPE_BWE_HR_TR - 1 ); @@ -381,8 +374,7 @@ void swb_bwe_enc_hr_fx( } /* normalize spectrum per bands */ - ptr16 = &t_audio_fx[add( temp, NUM_TRANS_START_FREQ_COEF )]; - move16(); + ptr16 = &t_audio_fx[temp + NUM_TRANS_START_FREQ_COEF]; FOR( i = 0; i < N_BANDS_TRANS_BWE_HR; i++ ) { temp2 = 9; @@ -394,6 +386,7 @@ void swb_bwe_enc_hr_fx( L_temp = L_mult( *ptr16, gain2_fx ); L_temp = L_shr( L_temp, temp2 ); *ptr16++ = round_fx( L_temp ); + move16(); } } @@ -519,7 +512,6 @@ void swb_bwe_enc_hr_fx( /* normalization with global gain */ ptr16 = &t_audio_fx[NUM_NONTRANS_START_FREQ_COEF]; - move16(); /* Find Max Scaling on Remaining Frequencies */ temp2 = Find_Max_Norm16( ptr16, NUM_NONTRANS_END_FREQ_COEF - NUM_NONTRANS_START_FREQ_COEF ); temp2 = s_max( 0, sub( temp2, NON_TRANSIENT_RESCALE_Q_GUARD ) ); @@ -533,6 +525,7 @@ void swb_bwe_enc_hr_fx( L_temp = L_mult( *ptr16, temp ); L_temp = L_shr( L_temp, temp2 ); *ptr16++ = round_fx( L_temp ); + move16(); } /*---------------------------------------------------------------------* @@ -541,17 +534,13 @@ void swb_bwe_enc_hr_fx( /* compute energy per band */ ptr16 = &t_audio_fx[NUM_NONTRANS_START_FREQ_COEF]; - move16(); FOR( i = 0; i < N_BANDS_BWE_HR; i++ ) { L_temp = Calc_Energy_Autoscaled( ptr16, t_audio_fx_exp, WIDTH_NONTRANS_FREQ_COEF, &temp2 ); ptr16 += WIDTH_NONTRANS_FREQ_COEF; L_temp = Sqrt_Ratio32( L_temp, temp2, WIDTH_NONTRANS_FREQ_COEF, /*WIDTH_TRANS_FREQ_COEF is in Q0*/ 0, &temp2 ); -#ifdef BASOP_NOGLOB en_band_fx[i] = round_fx_sat( L_shr_sat( L_temp, sub( 15 - 9, temp2 ) ) ); /* Put in Q9 */ -#else - en_band_fx[i] = round_fx( L_shr( L_temp, sub( 15 - 9, temp2 ) ) ); /* Put in Q9 */ -#endif + move16(); } /* Q energy per band */ @@ -566,7 +555,6 @@ void swb_bwe_enc_hr_fx( /* normalize spectrum per bands */ ptr32 = &L_t_audio_tmp_fx[0]; ptr16 = &t_audio_fx[NUM_NONTRANS_START_FREQ_COEF]; - move16(); FOR( i = 0; i < N_BANDS_BWE_HR; i++ ) { temp2 = 9; @@ -712,7 +700,6 @@ void swb_bwe_enc_hr_fx( { /* select spectrum of the second stage coding */ ptr16 = &t_audio_fx[0]; - move16(); FOR( i = 0; i < Nsv; i++ ) { IF( nq[i] == 0 ) @@ -734,6 +721,7 @@ void swb_bwe_enc_hr_fx( L_temp = L_deposit_l( t_audio_tmp_fx[i * WIDTH_BAND + j] ); L_temp = L_msu0( L_temp, temp2, x_norm_fx[i * WIDTH_BAND + j] ); *ptr16++ = extract_l( L_temp ); + move16(); } } } @@ -755,10 +743,10 @@ void swb_bwe_enc_hr_fx( /* Nsv2 * 12 <= nBits (Nsv2 is not too high) AND */ /* nBits - Nsv2 * 12 < 12 (Nsv2 is the highest divisor) */ L_temp = L_msu0( L_deposit_l( nBits ), 12, Nsv2 ); - if ( GE_32( L_temp, 12L ) ) - Nsv2 = add( Nsv2, 1 ); - if ( L_temp < 0 ) - Nsv2 = sub( Nsv2, 1 ); + IF( GE_32( L_temp, 12L ) ) + Nsv2 = add( Nsv2, 1 ); + IF( L_temp < 0 ) + Nsv2 = sub( Nsv2, 1 ); } /* second stage global gain estimation and coding */ @@ -779,13 +767,9 @@ void swb_bwe_enc_hr_fx( FOR( i = 0; i < Nsv2 * WIDTH_BAND; i++ ) { L_tmp = L_mult( temp, t_audio_fx[i] ); -#ifdef BASOP_NOGLOB L_tmp = L_shr_o( L_tmp, temp2, &Overflow ); t_audio_fx[i] = round_fx_o( L_tmp, &Overflow ); -#else - L_tmp = L_shr( L_tmp, temp2 ); - t_audio_fx[i] = round_fx( L_tmp ); -#endif + move16(); } set16_fx( nq2, 0, Nsv ); diff --git a/lib_enc/swb_bwe_enc_lr.c b/lib_enc/swb_bwe_enc_lr.c deleted file mode 100644 index 5bd24db09d3a0629cf156dd436c5f5a401b21bd5..0000000000000000000000000000000000000000 --- a/lib_enc/swb_bwe_enc_lr.c +++ /dev/null @@ -1,44 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "prot.h" -#include "rom_com.h" -#include "stat_com.h" -#include "wmc_auto.h" diff --git a/lib_enc/swb_bwe_enc_lr_fx.c b/lib_enc/swb_bwe_enc_lr_fx.c index 23137a24a48d79090f986e4b546f3852ffe6feed..c324b9ac9f4a95b180b9b1f756c709f85a934404 100644 --- a/lib_enc/swb_bwe_enc_lr_fx.c +++ b/lib_enc/swb_bwe_enc_lr_fx.c @@ -92,9 +92,11 @@ static Word16 GetSubbandCorrIndex2_har_fx( /* o : #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move16(); #endif exp_safe_e = 4; + move16(); L_tmp = L_deposit_l( 0 ); FOR( i = 0; i < fLen; i++ ) @@ -107,6 +109,7 @@ static Word16 GetSubbandCorrIndex2_har_fx( /* o : FOR( i = 0; i < fLen; i++ ) { ibuf_fx[i] = extract_h( L_shl( L_inBuf[i], exp_shift ) ); /* Qi+exp_shift-16 */ + move16(); } FOR( i = 0; i < predBufLen; i++ ) @@ -148,11 +151,7 @@ static Word16 GetSubbandCorrIndex2_har_fx( /* o : FOR( j = 0; j < fLen; j++ ) { /*energy += *predBuf * *predBuf; */ -#ifdef BASOP_NOGLOB /* Critical Overflow , as well as those below*/ L_energy = L_mac_o( L_energy, *ptr_pbuf, *ptr_pbuf, &Overflow ); /* Q*2-1; */ -#else - L_energy = L_mac( L_energy, *ptr_pbuf, *ptr_pbuf ); /* Q*2-1; */ -#endif ptr_pbuf++; } @@ -165,11 +164,7 @@ static Word16 GetSubbandCorrIndex2_har_fx( /* o : FOR( j = 0; j < nZero_fx; j++ ) { /*corr += inBuf[G_item[j].gainIndex]* predBuf[G_item[j].gainIndex]; */ -#ifdef BASOP_NOGLOB /* Critical Overflow */ L_corr = L_mac_o( L_corr, ibuf_fx[G_item_fx[j].gainIndex_fx], ptr_pbuf[G_item_fx[j].gainIndex_fx], &Overflow ); /* Q*2-1 */ -#else - L_corr = L_mac( L_corr, ibuf_fx[G_item_fx[j].gainIndex_fx], ptr_pbuf[G_item_fx[j].gainIndex_fx] ); /* Q*2-1 */ -#endif } /*corr_sq = corr*corr; */ @@ -178,13 +173,8 @@ static Word16 GetSubbandCorrIndex2_har_fx( /* o : L_corr_sq = L_shl( L_corr, exp_norm ); corr_sq_hi_fx = extract_h( L_corr_sq ); -#ifdef BASOP_NOGLOB /* Critical Overflow */ L_corr_sq = L_mult_o( corr_sq_hi_fx, corr_sq_hi_fx, &Overflow ); /* (((Qhi:Qsh+exp_norm_hi-16)+Qss+1)+exp_norm-16)*2+1 */ L_corr_sq = L_shr_o( L_corr_sq, s_min( shl( exp_norm, 1 ), 31 ), &Overflow ); /* (QCorr-16)*2+1 */ -#else - L_corr_sq = L_mult( corr_sq_hi_fx, corr_sq_hi_fx ); /* (((Qhi:Qsh+exp_norm_hi-16)+Qss+1)+exp_norm-16)*2+1 */ - L_corr_sq = L_shr( L_corr_sq, s_min( shl( exp_norm, 1 ), 31 ) ); /* (QCorr-16)*2+1 */ -#endif IF( Overflow != 0 ) { L_corr_sq = 0x0L; @@ -279,6 +269,7 @@ static void getswbindices_har_fx( { /*nlags[sb] = (short)pow(2, bits_lagIndices_mode0_Har[sb]); */ nlags_fx[sb] = shl( 1, bits_lagIndices_mode0_Har[sb] ); + move16(); } j = 0; @@ -290,6 +281,7 @@ static void getswbindices_har_fx( sbWidth_fx[sb], &n_nbiggestsearch_fx[sb], N_NBIGGEST_PULSEARCH ); search_offset_fx[sb] = subband_search_offset_fx[sb]; + move16(); j = add( j, N_NBIGGEST_PULSEARCH ); } @@ -316,7 +308,8 @@ static void getswbindices_har_fx( FOR( j = add( search_offset_fx[sb], shr( nlags_fx[sb], 1 ) ); j > tmp; j-- ) { low_freqsgnl_fx[k] = y2_fx[j]; - k = add( k, 1 ); + move16(); + k++; } } /* correlation b/w HF spectrum Group1 of length sbLen and decoded LF spectrum */ @@ -326,6 +319,7 @@ static void getswbindices_har_fx( add( sbWidth_fx[sb], nlags_fx[sb] ), nlags_fx[sb], Nbiggest_fx + ( sb * N_NBIGGEST_PULSEARCH ), n_nbiggestsearch_fx[sb], &prev_frame_bstindx_fx[sb] ); + move16(); } return; @@ -429,8 +423,10 @@ static Word16 GetSubbandCorrIndex2_pulsestep_fx( } /* Get the initial energy for zero lag */ + test(); WHILE( *ptr_predBuf == 0 && LT_16( absPos_fx, ssearch_buflim ) ) { + test(); ptr_predBuf++; absPos_fx = add( absPos_fx, 1 ); } @@ -523,9 +519,10 @@ static Word16 GetSubbandCorrIndex2_pulsestep_fx( ptr_predBuf++; ptr_ssBuf_ni_fx++; absPos_fx++; - + test(); WHILE( *ptr_predBuf == 0 && LT_16( absPos_fx, ssearch_buflim ) ) { + test(); ptr_predBuf++; ptr_ssBuf_ni_fx++; absPos_fx = add( absPos_fx, 1 ); @@ -543,7 +540,7 @@ static Word16 GetSubbandCorrIndex2_pulsestep_fx( } } - IF( EQ_16( ib_flag_fx, 1 ) ) + if ( EQ_16( ib_flag_fx, 1 ) ) { bestIdx_fx = 0; move16(); @@ -611,6 +608,7 @@ static void GetSWBIndices_fx( } sspectra_ma_fx[0] = add( shr( predBuf_ni_fx[0], 1 ), shr( predBuf_ni_fx[1], 1 ) ); + move16(); tmp = sub( predBufLen, 1 ); FOR( sb = 1; sb < tmp; sb++ ) { @@ -619,8 +617,10 @@ static void GetSWBIndices_fx( L_temp = L_add( L_temp, L_mult( predBuf_ni_fx[sb - 1], 10922 ) ); L_temp = L_add( L_temp, L_mult( predBuf_ni_fx[sb + 1], 10922 ) ); /* Qss+15+1 */ sspectra_ma_fx[sb] = round_fx( L_temp ); + move16(); } sspectra_ma_fx[sb] = add( shr( predBuf_ni_fx[sb - 1], 1 ), shr( predBuf_ni_fx[sb], 1 ) ); + move16(); /* Partial search for rest of subbands except the last which is fixed */ FOR( sb = 0; sb < nBands_search; sb++ ) @@ -634,6 +634,7 @@ static void GetSWBIndices_fx( sbLen, nlags_fx[sb], gi_fx + ( sb * N_NBIGGEST_PULSEARCH ), n_nbiggestsearch_fx[sb], ssearch_buflim_fx, predBuf_ni_fx + search_offset_fx[sb] ); + move16(); } } /*--------------------------------------------------------------------------* @@ -699,6 +700,7 @@ static void gethar_noisegn_fx( Word16 Qg; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move16(); #endif /*Generate HF noise*/ genhf_noise_fx( noise_flr_fx, Qss, L_xSynth_har, QsL, sspectra_fx, bands, har_bands, har_freq_est2, pos_max_hfe2, pul_res_fx, pk_sf_fx, fLenLow, @@ -713,6 +715,7 @@ static void gethar_noisegn_fx( } L_temp = 0x0; + move32(); FOR( i = 0; i < fLenHigh; i++ ) { L_temp = L_or( L_temp, L_abs( L_hfspec[i] ) ); @@ -721,9 +724,11 @@ static void gethar_noisegn_fx( FOR( i = 0; i < fLenHigh; i++ ) { L_hfspec_sft[i] = L_shl( L_hfspec[i], exp_norm_g1 ); + move32(); } L_temp = 0x0; + move32(); FOR( i = 0; i < fLenHigh; i++ ) { L_temp = L_or( L_temp, L_abs( L_xSynth_har[i] ) ); @@ -732,6 +737,7 @@ static void gethar_noisegn_fx( FOR( i = 0; i < fLenHigh; i++ ) { L_xSynth_har_sft[i] = L_shl( L_xSynth_har[i], exp_norm_g2 ); + move32(); } exp_safe = 4; @@ -776,14 +782,9 @@ static void gethar_noisegn_fx( exp = sub( exp, Qsqrt ); L_temp = L_Comp( exp, frac ); - L_temp = Mpy_32_16_1( L_temp, 19728 ); /* log(2)/log(10)=.30102999566398119521 = 19728.3(Q16) Q(0+16+1)=Q17 */ -#ifdef BASOP_NOGLOB + L_temp = Mpy_32_16_1( L_temp, 19728 ); /* log(2)/log(10)=.30102999566398119521 = 19728.3(Q16) Q(0+16+1)=Q17 */ L_temp = L_shl_o( L_temp, 13, &Overflow ); /* Q17+13=30 30-16=14 */ g_fx = round_fx_o( L_temp, &Overflow ); -#else - L_temp = L_shl( L_temp, 13 ); /* Q17+13=30 30-16=14 */ - g_fx = round_fx( L_temp ); -#endif } gqlevs_fx = 4; @@ -915,7 +916,7 @@ static void EncodeSWBSubbands_fx( IF( flag_dis == 0 ) { test(); - if ( NE_16( har_freq_est2, SWB_HAR_RAN1 ) || NE_16( har_freq_est2, *prev_frm_hfe2 ) ) + IF( NE_16( har_freq_est2, SWB_HAR_RAN1 ) || NE_16( har_freq_est2, *prev_frm_hfe2 ) ) { har_freq_est2 = add( har_freq_est2, lagIndices_fx[0] ); move16(); @@ -984,14 +985,17 @@ static void EncodeSWBSubbands_fx( FOR( k = 0; k < NB_SWB_SUBBANDS; k++ ) { lagGains_fx[k] = mult_r( lagGains_fx[k], 29491 ); /* lagGains[k]*0.9f; */ + move16(); } FOR( k = 0; k < NB_SWB_SUBBANDS; k++ ) { L_th_g[k] = L_deposit_l( 0 ); + move32(); IF( p2a_flags_fx[BANDS_fx - NB_SWB_SUBBANDS + k] == 0 ) { L_th_g[k] = L_shl( L_mult( lagGains_fx[k], ss_min_fx ), sub( QsL, add( add( QlagGains[k], Qss ), 1 ) ) ); /* QlagGain+Qss -> QsL */ + move32(); } } @@ -1110,7 +1114,7 @@ static void EncodeSWBSubbands_ivas_fx( IF( flag_dis == 0 ) { test(); - if ( NE_16( har_freq_est2, SWB_HAR_RAN1 ) || NE_16( har_freq_est2, *prev_frm_hfe2 ) ) + IF( NE_16( har_freq_est2, SWB_HAR_RAN1 ) || NE_16( har_freq_est2, *prev_frm_hfe2 ) ) { har_freq_est2 = add( har_freq_est2, lagIndices_fx[0] ); move16(); @@ -1179,14 +1183,17 @@ static void EncodeSWBSubbands_ivas_fx( FOR( k = 0; k < NB_SWB_SUBBANDS; k++ ) { lagGains_fx[k] = mult_r( lagGains_fx[k], 29491 ); /* lagGains[k]*0.9f; */ + move16(); } FOR( k = 0; k < NB_SWB_SUBBANDS; k++ ) { L_th_g[k] = L_deposit_l( 0 ); + move32(); IF( p2a_flags_fx[BANDS_fx - NB_SWB_SUBBANDS + k] == 0 ) { L_th_g[k] = L_shl( L_mult( lagGains_fx[k], ss_min_fx ), sub( QsL, add( add( QlagGains[k], Qss ), 1 ) ) ); /* QlagGain+Qss -> QsL */ + move32(); } } @@ -1302,6 +1309,7 @@ void swb_bwe_enc_lr_fx( FOR( k = 0; k < swb_lowband_fx; k++ ) { L_m[k] = L_deposit_l( 0 ); + move32(); } return; @@ -1385,6 +1393,7 @@ void swb_bwe_enc_lr_ivas_fx( FOR( k = 0; k < swb_lowband_fx; k++ ) { L_m[k] = L_deposit_l( 0 ); + move32(); } return; diff --git a/lib_enc/swb_pre_proc.c b/lib_enc/swb_pre_proc.c deleted file mode 100644 index 2f76fa5f4393f88f25c9ead25d77c40789c9b26c..0000000000000000000000000000000000000000 --- a/lib_enc/swb_pre_proc.c +++ /dev/null @@ -1,750 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "prot.h" -#include "rom_com.h" -#include "rom_enc.h" -#include "wmc_auto.h" -#include "ivas_prot.h" -#include "ivas_rom_enc.h" -#include "ivas_prot_fx.h" -#include "prot_fx.h" -#include "prot_fx_enc.h" - - -/*-------------------------------------------------------------------* - * swb_pre_proc() - * - * - Calculate the 6 to 14 kHz (or 7.5 - 15.5 kHz) SHB target signal - * for SWB TBE or SWB BWE coding - * - Common SWB TBE and SWB BWE pre-processing - *-------------------------------------------------------------------*/ - -/*full implementation pending*/ -void swb_pre_proc_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - Word16 *new_swb_speech, /* o : original input signal at 32kHz - Q0 */ - Word32 *new_swb_speech_fx, /* o : original input signal at 32kHz - Q - q_reImBuffer */ - Word16 *shb_speech, /* o : SHB target signal (6-14kHz) at 16kHz- Q(Q_shb_spch) */ - Word16 *Q_shb_spch, - Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : real buffer Q - q_reImbuffer */ - Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : imag buffer Q - q_reImbuffer */ - Word16 q_reImBuffer, /* i : scale data of real and imag CLDFB buffers */ - CPE_ENC_HANDLE hCPE /* i/o: CPE encoder structure */ -) -{ - Word16 Sample_Delay_SWB_BWE, inner_frame, delay; - TD_BWE_ENC_HANDLE hBWE_TD; - FD_BWE_ENC_HANDLE hBWE_FD; - Word32 inner_Fs, input_Fs; - Word16 old_input_fx[NS2SA( 48000, DELAY_FD_BWE_ENC_NS + DELAY_FIR_RESAMPL_NS ) + L_FRAME48k]; // fixed counterpart - Word32 old_input_fx_32[NS2SA( 48000, DELAY_FD_BWE_ENC_NS + DELAY_FIR_RESAMPL_NS ) + L_FRAME48k]; // fixed counterpart - Word16 spchTmp[L_FRAME32k], spchTmp2[L_FRAME32k]; - Word16 i, j, L_resamp; - Word16 startB, endB; - Word32 *realBufferFlipped[CLDFB_NO_COL_MAX]; - Word32 *imagBufferFlipped[CLDFB_NO_COL_MAX]; - Word32 realBufferTmp[CLDFB_NO_COL_MAX][20]; - Word32 imagBufferTmp[CLDFB_NO_COL_MAX][20]; - Word32 shb_speech_fx_32[L_FRAME16k]; - Word16 ts, nB, uB; - Word32 v, t, regression; - Word16 t_16; - const Word32 *thr, *regV; - Word32 lbEner; - Word16 exp_lbEner = 0; - Word16 Sample_Delay_SWB_BWE32k, lMemRecalc32k, dft_ovl32k; - Word32 one_by_50_Q31 = 42949673; - - lMemRecalc32k = NS2SA_FX2( 32000, L_MEM_RECALC_NS ); - move16(); // exp_lbEner - move16(); // lMemRecalc32k - move32(); // one_by_50_Q31 - - /* initialization */ - hBWE_TD = st->hBWE_TD; - hBWE_FD = st->hBWE_FD; - input_Fs = st->input_Fs; - - FOR( j = 0; j < CLDFB_NO_COL_MAX; j++ ) - { - set32_fx( realBufferTmp[j], 0, 20 ); - set32_fx( imagBufferTmp[j], 0, 20 ); - realBufferFlipped[j] = realBufferTmp[j]; - imagBufferFlipped[j] = imagBufferTmp[j]; - } - - set16_fx( old_input_fx, 0, NS2SA_FX2( 48000, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ) + L_FRAME48k ); - - IF( EQ_32( st->input_Fs, 32000 ) ) - { - IF( st->element_mode > EVS_MONO ) - { - Sample_Delay_SWB_BWE = NS2SA_FX2( 32000, DELAY_FD_BWE_ENC_12k8_NS ); - move16(); - IF( EQ_16( st->L_frame, L_FRAME16k ) ) - { - Sample_Delay_SWB_BWE = NS2SA_FX2( 32000, DELAY_FD_BWE_ENC_16k_NS ); - move16(); - } - - Copy( st->input_fx - Sample_Delay_SWB_BWE, hBWE_FD->old_input_fx, Sample_Delay_SWB_BWE ); - Copy( st->input_fx - L_FRAME32k, hBWE_FD->old_fdbwe_speech_fx, L_FRAME32k ); - - test(); - test(); - IF( EQ_16( st->element_mode, IVAS_CPE_TD ) && GE_16( st->bwidth, SWB ) ) - { - Copy( st->input_fx - hCPE->hStereoTCA->lMemRecalc, hBWE_FD->L_old_wtda_swb_fx + L_FRAME32k - sub( hCPE->hStereoTCA->lMemRecalc, Sample_Delay_SWB_BWE ), sub( hCPE->hStereoTCA->lMemRecalc, Sample_Delay_SWB_BWE ) ); - } - ELSE IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) && GE_16( st->bwidth, SWB ) ) - { - Copy( st->input_fx - hCPE->hStereoDft->dft_ovl, hBWE_FD->L_old_wtda_swb_fx + L_FRAME32k - sub( hCPE->hStereoDft->dft_ovl, Sample_Delay_SWB_BWE ), sub( hCPE->hStereoDft->dft_ovl, Sample_Delay_SWB_BWE ) ); - } - } - - Copy( st->input_fx, new_swb_speech, L_FRAME32k ); - - test(); - test(); - IF( NE_16( st->last_extl, SWB_BWE ) && NE_16( st->last_extl, FB_BWE ) && NE_16( st->extl, SWB_BWE_HIGHRATE ) ) - { - Sample_Delay_SWB_BWE = NS2SA_FX2( 32000, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ); - move16(); - test(); - IF( st->element_mode > EVS_MONO && EQ_16( st->L_frame, L_FRAME16k ) ) - { - Sample_Delay_SWB_BWE = NS2SA_FX2( 32000, DELAY_FD_BWE_ENC_16k_NS + DELAY_FIR_RESAMPL_NS ); - move16(); - } - IF( st->element_mode > EVS_MONO ) - { - Sample_Delay_SWB_BWE = sub( Sample_Delay_SWB_BWE, NS2SA_FX2( 32000, DELAY_FIR_RESAMPL_NS ) ); - } - - Copy( hBWE_FD->old_fdbwe_speech_fx, &old_input_fx[Sample_Delay_SWB_BWE], L_FRAME32k ); - - set16_fx( old_input_fx, 0, Sample_Delay_SWB_BWE ); - Copy( hBWE_FD->old_fdbwe_speech_fx + L_FRAME32k - Sample_Delay_SWB_BWE, hBWE_FD->old_input_fx, Sample_Delay_SWB_BWE ); - IF( NE_16( st->extl, WB_BWE ) ) - { - Copy( old_input_fx, hBWE_FD->L_old_wtda_swb_fx, L_FRAME32k ); - } - } - - test(); - IF( NE_16( st->extl, SWB_BWE ) && NE_16( st->extl, FB_BWE ) ) - { - Copy( st->input_fx, hBWE_FD->old_fdbwe_speech_fx, L_FRAME32k ); - } - } - ELSE /* 48 kHz */ - { - - Sample_Delay_SWB_BWE32k = NS2SA_FX2( 32000, DELAY_FD_BWE_ENC_12k8_NS ); - move16(); - Sample_Delay_SWB_BWE = NS2SA_FX2( 48000, DELAY_FD_BWE_ENC_12k8_NS ); - move16(); - IF( EQ_16( st->L_frame, L_FRAME16k ) ) - { - Sample_Delay_SWB_BWE32k = NS2SA_FX2( 32000, DELAY_FD_BWE_ENC_16k_NS ); - move16(); - Sample_Delay_SWB_BWE = NS2SA_FX2( 48000, DELAY_FD_BWE_ENC_16k_NS ); - move16(); - } - - dft_ovl32k = 0; - move16(); - IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) ) - { - dft_ovl32k = (Word16) ( STEREO_DFT_OVL_MAX * 32000 / 48000 ); - move16(); - } - - IF( EQ_16( st->codec_mode, MODE1 ) ) - { - IF( st->element_mode > EVS_MONO ) - { - - IF( EQ_16( st->element_mode, IVAS_CPE_TD ) ) - { - } - ELSE IF( EQ_16( st->bwidth, FB ) ) - { - Copy( st->input_fx - Sample_Delay_SWB_BWE, hBWE_FD->old_input_fx, Sample_Delay_SWB_BWE ); - } - - Copy( st->input_fx - L_FRAME48k, hBWE_FD->old_fdbwe_speech_fx, L_FRAME48k ); - - test(); - test(); - IF( EQ_16( st->element_mode, IVAS_CPE_TD ) && GE_16( st->bwidth, SWB ) ) - { - IF( EQ_16( st->bwidth, SWB ) ) - { - /* buffers hBWE_FD->old_input[] and hBWE_FD->old_wtda_swb[] need to be at 32 kHz (inner) sampling rate */ - - decimate_2_over_3_allpass_fx( st->input_fx - hCPE->hStereoTCA->lMemRecalc, hCPE->hStereoTCA->lMemRecalc, spchTmp, hBWE_TD->dec_2_over_3_mem_fx, - allpass_poles_3_ov_2, decimate_3_ov_2_lowpass_num_fx, decimate_3_ov_2_lowpass_den_fx, hBWE_TD->dec_2_over_3_mem_lp_fx ); - - Copy( spchTmp, hBWE_FD->L_old_wtda_swb_fx + L_FRAME32k - sub( lMemRecalc32k, Sample_Delay_SWB_BWE32k ), sub( lMemRecalc32k, Sample_Delay_SWB_BWE32k ) ); - Copy( spchTmp + lMemRecalc32k - Sample_Delay_SWB_BWE32k, hBWE_FD->old_input_fx, Sample_Delay_SWB_BWE32k ); - } - ELSE /* FB_BWE */ - { - Copy( st->input_fx - hCPE->hStereoTCA->lMemRecalc, hBWE_FD->L_old_wtda_swb_fx + L_FRAME48k - sub( hCPE->hStereoTCA->lMemRecalc, Sample_Delay_SWB_BWE ), sub( hCPE->hStereoTCA->lMemRecalc, Sample_Delay_SWB_BWE ) ); - Copy( st->input_fx - Sample_Delay_SWB_BWE, hBWE_FD->old_input_fx, Sample_Delay_SWB_BWE ); - } - } - ELSE IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) && GE_16( st->bwidth, SWB ) ) - { - IF( EQ_16( st->bwidth, SWB ) ) - { - lerp( st->input_fx - hCPE->hStereoDft->dft_ovl, spchTmp, dft_ovl32k - Sample_Delay_SWB_BWE32k, hCPE->hStereoDft->dft_ovl - Sample_Delay_SWB_BWE ); - - Copy( spchTmp, hBWE_FD->L_old_wtda_swb_fx + L_FRAME32k - ( dft_ovl32k - Sample_Delay_SWB_BWE32k ), dft_ovl32k - Sample_Delay_SWB_BWE32k ); - } - ELSE - { - Copy( st->input_fx - hCPE->hStereoDft->dft_ovl, hBWE_FD->L_old_wtda_swb_fx + L_FRAME48k - ( hCPE->hStereoDft->dft_ovl - Sample_Delay_SWB_BWE ), hCPE->hStereoDft->dft_ovl - Sample_Delay_SWB_BWE ); - } - } - } - - test(); - test(); - test(); - test(); - IF( ( NE_16( st->extl, SWB_BWE ) && NE_16( st->extl, FB_BWE ) && ( st->core == ACELP_CORE ) ) || ( EQ_16( st->element_mode, IVAS_CPE_DFT ) && ( st->core != ACELP_CORE ) ) /*resampling not needed for MDCT cores*/ ) - { - /* move the resampling out of the TDBWE path as new_swb_speech is not needed for TDBWE. */ - Copy( st->input_fx, hBWE_FD->old_fdbwe_speech_fx, L_FRAME48k ); - } - ELSE - { - test(); - IF( NE_16( st->last_extl, SWB_BWE ) && NE_16( st->last_extl, FB_BWE ) ) - { - /* resample 48 kHz to 32kHz */ - IF( EQ_16( st->last_bwidth, FB ) ) - { - inner_frame = L_FRAME48k; - move16(); - inner_Fs = 48000; - move32(); - Copy( hBWE_FD->old_fdbwe_speech_fx, new_swb_speech, L_FRAME48k ); - } - ELSE - { - inner_frame = L_FRAME32k; - move16(); - inner_Fs = 32000; - move32(); - - IF( NE_16( st->element_mode, IVAS_CPE_DFT ) ) - { - decimate_2_over_3_allpass_fx( hBWE_FD->old_fdbwe_speech_fx, L_FRAME48k, new_swb_speech, hBWE_TD->dec_2_over_3_mem_fx, allpass_poles_3_ov_2, decimate_3_ov_2_lowpass_num_fx, decimate_3_ov_2_lowpass_den_fx, hBWE_TD->dec_2_over_3_mem_lp_fx ); - } - ELSE - { - lerp( hBWE_FD->old_fdbwe_speech_fx, new_swb_speech, inner_frame, L_FRAME48k ); - } - - test(); - IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) && st->idchan == 0 ) - { - FOR( i = 0; i < STEREO_DFT_OVL_32k; i++ ) - { - hCPE->hStereoDft->output_mem_dmx_32k_fx[i] = L_shr( Mpy_32_16_1( hCPE->hStereoDft->win_32k_fx[STEREO_DFT_OVL_32k - 1 - i], new_swb_speech[( ( inner_frame + i ) - STEREO_DFT_OVL_32k )] ), 1 ); // Q15 - move32(); - } - } - } - - Sample_Delay_SWB_BWE = NS2SA_FX2( inner_Fs, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ); - move16(); - test(); - IF( st->element_mode > EVS_MONO && EQ_16( st->L_frame, L_FRAME16k ) ) - { - Sample_Delay_SWB_BWE = NS2SA_FX2( inner_Fs, DELAY_FD_BWE_ENC_16k_NS + DELAY_FIR_RESAMPL_NS ); - move16(); - } - IF( st->element_mode > EVS_MONO ) - { - Sample_Delay_SWB_BWE = sub( Sample_Delay_SWB_BWE, NS2SA_FX2( inner_Fs, DELAY_FIR_RESAMPL_NS ) ); - } - - Copy( new_swb_speech, &old_input_fx[Sample_Delay_SWB_BWE], inner_frame ); - set16_fx( old_input_fx, 0, Sample_Delay_SWB_BWE ); - Copy( new_swb_speech + inner_frame - Sample_Delay_SWB_BWE, hBWE_FD->old_input_fx, Sample_Delay_SWB_BWE ); - Copy( old_input_fx, hBWE_FD->L_old_wtda_swb_fx, inner_frame ); - } - - /* resample 48 kHz to 32kHz */ - IF( EQ_16( st->bwidth, FB ) ) - { - Copy( st->input_fx, new_swb_speech, L_FRAME48k ); - } - ELSE - { - IF( EQ_16( st->element_mode, IVAS_CPE_TD ) ) - { - Word16 dec_2_over_3_mem_tmp[L_FILT_2OVER3], dec_2_over_3_mem_lp_tmp[L_FILT_2OVER3_LP]; - - decimate_2_over_3_allpass_fx( st->input_fx, L_FRAME48k - hCPE->hStereoTCA->lMemRecalc, new_swb_speech, hBWE_TD->dec_2_over_3_mem_fx, allpass_poles_3_ov_2, decimate_3_ov_2_lowpass_num_fx, decimate_3_ov_2_lowpass_den_fx, hBWE_TD->dec_2_over_3_mem_lp_fx ); - - Copy( hBWE_TD->dec_2_over_3_mem_fx, dec_2_over_3_mem_tmp, L_FILT_2OVER3 ); - Copy( hBWE_TD->dec_2_over_3_mem_lp_fx, dec_2_over_3_mem_lp_tmp, L_FILT_2OVER3_LP ); - - decimate_2_over_3_allpass_fx( st->input_fx + L_FRAME48k - hCPE->hStereoTCA->lMemRecalc, hCPE->hStereoTCA->lMemRecalc, new_swb_speech + L_FRAME32k - lMemRecalc32k, dec_2_over_3_mem_tmp, allpass_poles_3_ov_2, decimate_3_ov_2_lowpass_num_fx, decimate_3_ov_2_lowpass_den_fx, dec_2_over_3_mem_lp_tmp ); - } - ELSE IF( NE_16( st->element_mode, IVAS_CPE_DFT ) ) - { - decimate_2_over_3_allpass_fx( st->input_fx, L_FRAME48k, new_swb_speech, hBWE_TD->dec_2_over_3_mem_fx, allpass_poles_3_ov_2, decimate_3_ov_2_lowpass_num_fx, decimate_3_ov_2_lowpass_den_fx, hBWE_TD->dec_2_over_3_mem_lp_fx ); - } - ELSE /* IVAS_CPE_DFT */ - { - Word16 out_start_ind, out_end_ind; - stereo_dft_enc_synthesize_fx( hCPE->hStereoDft, new_swb_speech_fx, &out_start_ind, &out_end_ind, st->idchan, input_Fs, 32000, 0, NULL ); - Copy_Scale_sig32_16( new_swb_speech_fx - STEREO_DFT_OVL_MAX, new_swb_speech - STEREO_DFT_OVL_MAX, L_FRAME48k + STEREO_DFT_OVL_MAX, add( q_reImBuffer, 1 ) ); // Q0 - Copy( new_swb_speech - Sample_Delay_SWB_BWE32k, hBWE_FD->old_input_fx, Sample_Delay_SWB_BWE32k ); // Q0 - } - } - } - } - ELSE - { - /* resample 48 kHz to 32kHz */ - IF( EQ_16( st->bwidth, FB ) ) - { - Copy( st->input_fx, new_swb_speech, L_FRAME48k ); - } - ELSE - { - decimate_2_over_3_allpass_fx( st->input_fx, L_FRAME48k, new_swb_speech, hBWE_TD->dec_2_over_3_mem_fx, allpass_poles_3_ov_2, decimate_3_ov_2_lowpass_num_fx, decimate_3_ov_2_lowpass_den_fx, hBWE_TD->dec_2_over_3_mem_lp_fx ); - } - } - } - - test(); - test(); - test(); - test(); - test(); - test(); - IF( ( ( st->core == ACELP_CORE ) && NE_16( st->extl, SWB_BWE_HIGHRATE ) && NE_16( st->extl, FB_BWE_HIGHRATE ) ) || - ( ( EQ_32( st->total_brate, ACELP_9k60 ) || st->rf_mode ) && EQ_16( st->bwidth, SWB ) && ( st->element_mode == EVS_MONO ) ) ) - { - Word32 CldfbHB_fx = 0; // fixed counterpart - Word16 CldfbHB_fx_e = 0; // fixed counterpart -#ifdef BASOP_NOGLOB_DECLARE_LOCAL - Flag Overflow = 0; -#endif - Word16 realQ_neg1, imagQ_neg1, exp = 0, Cldfbtemp1; - move32(); - move16(); - move16(); - - IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) ) - { - Word16 out_start_ind, out_end_ind; - Word16 exp_icbweRefEner_fx; - Copy_Scale_sig_16_32( (const Word16 *) &old_input_fx[0], &old_input_fx_32[0], NS2SA( 48000, DELAY_FD_BWE_ENC_NS + DELAY_FIR_RESAMPL_NS ) + L_FRAME48k, Q15 ); // Q15 - CldfbHB_fx = stereo_dft_enc_synthesize_fx( hCPE->hStereoDft, old_input_fx_32 + STEREO_DFT_OVL_16k, &out_start_ind, &out_end_ind, st->idchan, input_Fs, 16000, st->L_frame, &CldfbHB_fx_e ); - Copy_Scale_sig_32_16( (const Word32 *) &old_input_fx_32[0], &old_input_fx[0], NS2SA( 48000, DELAY_FD_BWE_ENC_NS + DELAY_FIR_RESAMPL_NS ) + L_FRAME48k, -Q15 ); // Q0 - - /* delay corresponding to CLDFB delay */ - Copy( old_input_fx + STEREO_DFT_OVL_16k - 20, shb_speech, L_FRAME16k ); - Copy( old_input_fx, hBWE_TD->old_speech_shb_fx + L_LOOK_16k + L_SUBFR16k - ( STEREO_DFT_OVL_16k - 20 ), STEREO_DFT_OVL_16k - 20 ); - Copy( old_input_fx, hCPE->hStereoICBWE->mem_shb_speech_ref_fx, STEREO_DFT_OVL_16k - 20 ); // Q0 - hCPE->hStereoICBWE->mem_shb_speech_ref_e = 15; - move16(); - - IF( LE_32( CldfbHB_fx, 0 ) ) - { - CldfbHB_fx = EPSILON_FX; - move32(); - } - CldfbHB_fx = L_shl( CldfbHB_fx, exp ); /* CldfbHB_ener = CldfbHB_fl*2^(exp) */ - Cldfbtemp1 = Log2_norm_lc( CldfbHB_fx ); /* Log2_norm_lc(t) = 2^15*(log2(t/2^30)) */ - Cldfbtemp1 = sub( shr( Cldfbtemp1, 6 ), shl( add( sub( Q31 - Q30, CldfbHB_fx_e ), exp ), 9 ) ); - CldfbHB_fx = L_mult( Cldfbtemp1, 9864 ); /* Q9 + Q15 + Q1 = Q25 */ - CldfbHB_fx = Mpy_32_16_1( L_sub( CldfbHB_fx, 1 << Q25 ), 11611 /* 0.1 * 0.221462 in Q19 */ ); - /* Resulting Q = Q25 + Q19 - Q15 = Q29 */ - hBWE_TD->cldfbHBLT = mac_r( CldfbHB_fx, 29491 /*0.9 Q15*/, hBWE_TD->cldfbHBLT ); /* cldfbHBLT is in Q13 */ - move16(); - - exp_lbEner = hCPE->hStereoDft->lbEner_fx_e; - move32(); - lbEner = Mpy_32_16_1( Sqrt32( hCPE->hStereoDft->lbEner_fx, &exp_lbEner ), 1638 /* 0.05 in Q15 */ ); - exp_icbweRefEner_fx = hCPE->hStereoDft->icbweRefEner_fx_e; - move16(); - hCPE->hStereoICBWE->icbweRefEner_fx = Mpy_32_16_1( Sqrt32( hCPE->hStereoDft->icbweRefEner_fx, &exp_icbweRefEner_fx ), 1638 /* 0.05 in Q15 */ ); - move32(); - hCPE->hStereoICBWE->icbweRefEner_fx_e = exp_icbweRefEner_fx; - move16(); - // lbEner = 0.05f * (float) sqrt( hCPE->hStereoDft->lbEner ); - thr = icbwe_thr_DFT_fx; - regV = icbwe_regressionValuesDFT_fx; - } - ELSE - { - IF( EQ_16( st->L_frame, L_FRAME ) ) - { - startB = 34; - move16(); - endB = 14; - move16(); - FOR( ts = 0; ts < CLDFB_NO_COL_MAX; ts++ ) - { - uB = 0; - move16(); - FOR( nB = startB; nB > endB; nB-- ) - { - realBufferFlipped[ts][uB] = realBuffer[ts][nB]; - move32(); - if ( s_and( ts, 1 ) != 0 ) - { - realBufferFlipped[ts][uB] = L_negate( realBufferFlipped[ts][uB] ); - move32(); - } - imagBufferFlipped[ts][uB] = imagBuffer[ts][nB]; - move32(); - if ( s_and( ts, 1 ) == 0 ) - { - imagBufferFlipped[ts][uB] = L_negate( imagBufferFlipped[ts][uB] ); - move32(); - } - uB = add( uB, 1 ); /* uB ++ */ - } - } - } - ELSE - { - startB = 39; - move16(); - endB = 19; - move16(); - FOR( ts = 0; ts < CLDFB_NO_COL_MAX; ts++ ) - { - uB = 0; - move16(); - FOR( nB = startB; nB > endB; nB-- ) - { - realBufferFlipped[ts][uB] = L_negate( realBuffer[ts][nB] ); - move32(); - imagBufferFlipped[ts][uB] = imagBuffer[ts][nB]; - move32(); - uB = add( uB, 1 ); /* uB ++ */ - } - } - } - - FOR( nB = 0; nB < 10; nB++ ) - { - FOR( ts = 0; ts < CLDFB_NO_COL_MAX; ts++ ) - { - realQ_neg1 = extract_l( L_shr( realBufferFlipped[ts][nB], 16 ) ); - imagQ_neg1 = extract_l( L_shr( imagBufferFlipped[ts][nB], 16 ) ); /* Q(-1), headroom needed */ - -#ifdef BASOP_NOGLOB - CldfbHB_fx = L_mac0_o( CldfbHB_fx, realQ_neg1, realQ_neg1, &Overflow ); - CldfbHB_fx = L_mac0_o( CldfbHB_fx, imagQ_neg1, imagQ_neg1, &Overflow ); /* Q(-2) */ -#else - CldfbHB_fx = L_mac0( CldfbHB_fx, realQ_neg1, realQ_neg1 ); - CldfbHB_fx = L_mac0( CldfbHB_fx, imagQ_neg1, imagQ_neg1 ); /* Q(-2) */ -#endif - } - } - CldfbHB_fx_e = sub( Q31, shl( sub( q_reImBuffer, Q16 ), 1 ) ); - exp = norm_l( CldfbHB_fx ); - CldfbHB_fx = L_shl( CldfbHB_fx, exp ); /* CldfbHB_ener = CldfbHB_fl*2^(exp) */ - Cldfbtemp1 = Log2_norm_lc( CldfbHB_fx ); /* Log2_norm_lc(t) = 2^15*(log2(t/2^30)) */ - Cldfbtemp1 = sub( shr( Cldfbtemp1, 6 ), shl( add( sub( Q31 - Q30, CldfbHB_fx_e ), exp ), 9 ) ); - CldfbHB_fx = L_mult( Cldfbtemp1, 9864 ); /* Q9 + Q15 + Q1 = Q25 */ - CldfbHB_fx = Mpy_32_16_1( L_sub( CldfbHB_fx, 1 << Q25 ), 11611 /* 0.1 * 0.221462 in Q19 */ ); - /* Resulting Q = Q25 + Q19 - Q15 = Q29 */ - hBWE_TD->cldfbHBLT = mac_r( CldfbHB_fx, 29491 /*0.9 Q15*/, hBWE_TD->cldfbHBLT ); /* cldfbHBLT is in Q13 */ - move32(); - - IF( CldfbHB_fx == 0 ) - { - CldfbHB_fx = EPSILLON_FX; - move32(); - } - - test(); - IF( GE_16( st->element_mode, IVAS_CPE_DFT ) && hCPE->hStereoICBWE != NULL ) - { - Word32 icbweRefEner_fx = EPSILON_FX; - Word16 exp_icbweRefEner_fx = 0; - - move32(); - move16(); - FOR( nB = 20; nB < 40; nB++ ) - { - FOR( ts = 0; ts < CLDFB_NO_COL_MAX; ts++ ) - { - realQ_neg1 = extract_l( L_shr( realBuffer[ts][nB], 16 ) ); - imagQ_neg1 = extract_l( L_shr( imagBuffer[ts][nB], 16 ) ); /* Q(-1), headroom needed */ - icbweRefEner_fx = L_mac0_o( icbweRefEner_fx, realQ_neg1, realQ_neg1, &Overflow ); - icbweRefEner_fx = L_mac0_o( icbweRefEner_fx, imagQ_neg1, imagQ_neg1, &Overflow ); /* Q(-2) */ - } - } - exp_icbweRefEner_fx = sub( Q31, shl( sub( q_reImBuffer, Q16 ), 1 ) ); - hCPE->hStereoICBWE->icbweRefEner_fx = Mpy_32_16_1( Sqrt32( icbweRefEner_fx, &exp_icbweRefEner_fx ), 1638 /* 0.05 in Q15 */ ); - move32(); - hCPE->hStereoICBWE->icbweRefEner_fx_e = exp_icbweRefEner_fx; - move16(); - } - - lbEner = EPSILON_FX; - move32(); - FOR( nB = 0; nB < 20; nB++ ) - { - FOR( ts = 0; ts < CLDFB_NO_COL_MAX; ts++ ) - { - realQ_neg1 = extract_l( L_shr( realBuffer[ts][nB], 16 ) ); - imagQ_neg1 = extract_l( L_shr( imagBuffer[ts][nB], 16 ) ); /* Q(-1), headroom needed */ - - lbEner = L_mac0_o( lbEner, realQ_neg1, realQ_neg1, &Overflow ); - lbEner = L_mac0_o( lbEner, imagQ_neg1, imagQ_neg1, &Overflow ); /* Q(-2) */ - } - } - exp_lbEner = sub( Q31, shl( sub( q_reImBuffer, Q16 ), 1 ) ); - lbEner = Mpy_32_16_1( Sqrt32( lbEner, &exp_lbEner ), 1638 /* 0.05 in Q15 */ ); - thr = icbwe_thr_TDM_fx; - regV = icbwe_regressionValuesTDM_fx; - - cldfbSynthesis_ivas_fx( realBufferFlipped, imagBufferFlipped, shb_speech_fx_32, -1, st->cldfbSynTd ); - Copy_Scale_sig_32_16( shb_speech_fx_32, shb_speech, L_FRAME16k, negate( sub( q_reImBuffer, 1 ) ) ); - *Q_shb_spch = 0; - move16(); - } - - IF( GE_16( st->element_mode, IVAS_CPE_DFT ) && hCPE->hStereoICBWE != NULL ) - { - Word16 exp_t; - hCPE->hStereoICBWE->MSFlag = 0; /* Init the multi-source flag */ - move16(); - v = Mpy_32_16_1( sum16_fx( st->voicing_fx, 3 ), 10923 /* 0.33333 in Q15 */ ); - - // t = log10f( ( hCPE->hStereoICBWE->icbweRefEner + 1e-6f ) / ( lbEner + 1e-6f ) ); - t = L_deposit_h( BASOP_Util_Divide3232_Scale( L_add( hCPE->hStereoICBWE->icbweRefEner_fx, EPSILON_FX ), L_add( lbEner, EPSILON_FX ), &exp_t ) ); - exp_t = add( exp_t, sub( hCPE->hStereoICBWE->icbweRefEner_fx_e, exp_lbEner ) ); - exp = norm_l( t ); - t = L_shl( t, exp ); - t_16 = Log2_norm_lc( t ); /* Log2_norm_lc(t) = 2^15*(log2(t/2^30)) */ - t_16 = sub( shr( t_16, 6 ), shl( add( sub( Q31 - Q30, exp_t ), exp ), 9 ) ); - t = L_mult( t_16, 9864 ); /* Q9 + Q15 + Q1 = Q25 */ - /* Three Level Decision Tree to calculate a regression value first */ - IF( LT_32( t, thr[0] ) ) /* level 1 */ - { - IF( LT_32( t, thr[1] ) ) /* level 2 */ - { - IF( LT_32( v, thr[3] ) ) - { - regression = regV[0]; /* level 3 */ - move32(); - } - ELSE - { - regression = regV[1]; - move32(); - } - } - ELSE - { - IF( LT_32( v, thr[4] ) ) - { - regression = regV[2]; /* level 3 */ - move32(); - } - ELSE - { - regression = regV[3]; - move32(); - } - } - } - ELSE - { - IF( LT_32( t, thr[2] ) ) /* level 2 */ - { - IF( LT_32( v, thr[5] ) ) - { - regression = regV[4]; /* level 3 */ - move32(); - } - ELSE - { - regression = regV[5]; - move32(); - } - } - ELSE - { - IF( LT_32( v, thr[6] ) ) - { - regression = regV[6]; /* level 3 */ - move32(); - } - ELSE - { - regression = regV[7]; - move32(); - } - } - } - - test(); - test(); - /* Convert the regression to a hard decision (classification) */ - IF( GT_32( regression, 1696512081 /* 0.79f in Q31*/ ) && !( LT_16( st->bwidth, SWB ) || hCPE->hCoreCoder[0]->vad_flag == 0 ) ) - { - hCPE->hStereoICBWE->MSFlag = 1; - move16(); - } - } - - test(); - test(); - IF( NE_16( st->extl, WB_TBE ) && NE_16( st->extl, SWB_TBE ) && NE_16( st->extl, FB_TBE ) ) - { - /* Update the previous superwideband speech buffer in case of a SWB_BWE frame - this code is in swb_tbe_enc */ - delay = L_LOOK_16k + L_SUBFR16k; - move16(); - Copy( shb_speech + sub( L_FRAME16k, delay ), hBWE_TD->old_speech_shb_fx, delay ); - } - } - ELSE - { - test(); - test(); - IF( ( EQ_16( st->bwidth, FB ) || st->core == ACELP_CORE ) && ( st->element_mode == EVS_MONO ) ) - { - InitSWBencBufferStates_fx( st->hBWE_TD, shb_speech ); - } - ELSE - { - IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) ) - { - IF( EQ_16( st->L_frame, L_FRAME ) ) - { - L_resamp = 560; /* 6.4 kHz core -> 6 - 14 kHz SHB target. 20 ms is 560 samples in 28 kHz sample rate */ - move16(); - } - ELSE - { - L_resamp = 620; /* 8 kHz core -> 7.5 - 15.5 kHz SHB target. 20 ms is 620 samples in 31 kHz sample rate */ - move16(); - } - - /* Dirty downsampling to match Nyquist to upper frequency limit of target */ - lerp( st->input_fx, new_swb_speech, L_resamp, (int16_t) Mpy_32_32( input_Fs, one_by_50_Q31 ) ); - - /* flip the spectrum */ - Copy( new_swb_speech, spchTmp, L_resamp ); - FOR( i = 0; i < L_resamp; i = i + 2 ) - { - spchTmp[i] = negate( spchTmp[i] ); - move16(); - } - - /* Dirty upsampling to match Nyquist/2 to lower frequency limit of target (reversed spectrum)*/ - lerp( spchTmp, spchTmp2, L_FRAME32k, L_resamp ); - Copy( spchTmp2, spchTmp, L_FRAME32k ); - } - ELSE - { - /* flip the spectrum */ - Copy( new_swb_speech, spchTmp, L_FRAME32k ); - - FOR( i = 0; i < L_FRAME32k; i = i + 2 ) - { - spchTmp[i] = negate( spchTmp[i] ); - move16(); - } - } - - Decimate_allpass_steep_fx( spchTmp, hBWE_TD->state_ana_filt_shb_fx, L_FRAME32k, shb_speech ); - - Copy( shb_speech + L_FRAME16k - ( L_LOOK_16k + L_SUBFR16k ), hBWE_TD->old_speech_shb_fx, L_LOOK_16k + L_SUBFR16k ); - - /*Compute the past overlap for potential next iDFTs SHB*/ - IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) ) - { - FOR( i = 0; i < STEREO_DFT_OVL_16k; i++ ) - { - hCPE->hStereoDft->output_mem_dmx_16k_shb_fx[i] = L_mult0( shb_speech[20 + i], mult_r( hCPE->hStereoDft->win_ana_16k_fx[STEREO_DFT_OVL_16k - 1 - i], hCPE->hStereoDft->win_ana_16k_fx[STEREO_DFT_OVL_16k - 1 - i] ) ); // Q15 - move32(); - } - } - } - - IF( NE_16( st->element_mode, IVAS_CPE_DFT ) ) - { - /* Reset CLDFB synthesis buffer */ - set32_fx( st->cldfbSynTd->cldfb_state_fx, 0, st->cldfbSynTd->p_filter_length ); - } - ELSE - { - hCPE->hStereoDft->flip_sign = negate( hCPE->hStereoDft->flip_sign ); /* Make sure sign is updated even if DFT SHB target is not generated */ - move16(); - } - } - - /* Memory reset to compensate for 0.9375 ms offset when transitioning from IO to SWB */ - /* When switching from n >1 to n = 1, we keep the enc/dec delay as 8.75/3.25 and below code not needed; - only when n = 1 start, it will be 9.6875/2.3125 in that case this reset is needed for IO->BWE.*/ - test(); - IF( EQ_16( st->last_extl, -1 ) && ( st->element_mode == EVS_MONO ) ) - { - delay = NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS ); - move16(); - FOR( i = 0; i < delay; i++ ) - { - shb_speech[i] = mult_r( mult_r( i, 983 /*0.03f Q15*/ ), shb_speech[2 * delay - 1 - i] ); - move16(); - } - } - - return; -} diff --git a/lib_enc/swb_pre_proc_fx.c b/lib_enc/swb_pre_proc_fx.c index 79ca9555d5d7c4e1f33c1be489595cdc5041da37..3e9c07c230458cf42dbe330b423f6d01167e3c44 100644 --- a/lib_enc/swb_pre_proc_fx.c +++ b/lib_enc/swb_pre_proc_fx.c @@ -9,9 +9,12 @@ #include "rom_com_fx.h" #include "rom_com.h" #include "stl.h" -#include "prot_fx.h" /* Function prototypes */ -#include "prot_fx_enc.h" /* Function prototypes */ +#include "prot_fx.h" /* Function prototypes */ +#include "ivas_prot.h" /* Function prototypes */ +#include "ivas_prot_fx.h" /* Function prototypes */ +#include "prot_fx_enc.h" /* Function prototypes */ #include "basop_util.h" +#include "ivas_rom_enc.h" #include @@ -52,8 +55,11 @@ void wb_pre_proc_fx( Word16 temp_buf[320]; Word16 Q_wb_sp, i, max_wb; Word16 fSwitchFromIO = 0; + move16(); Word32 temp1 = 0; + move32(); Word32 temp2 = 0; + move32(); SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR; TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD; FD_BWE_ENC_HANDLE hBWE_FD = st_fx->hBWE_FD; @@ -93,7 +99,7 @@ void wb_pre_proc_fx( temp2 = L_mac0( temp2, temp_buf[i - 1], temp_buf[i] ); } - if ( temp2 < Mult_32_16( temp1, 31129 /*0.95f*/ ) ) + IF( temp2 < Mult_32_16( temp1, 31129 /*0.95f*/ ) ) { Q_wb_sp = sub( Q_wb_sp, 3 ); /* leave 3 bit headroom */ } @@ -107,15 +113,17 @@ void wb_pre_proc_fx( IF( EQ_16( st_fx->extl, WB_BWE ) || EQ_16( st_fx->extl, WB_TBE ) || st_fx->igf != 0 ) { ramp_flag = 0; + move16(); test(); test(); test(); test(); - IF( ( NE_16( st_fx->last_extl, WB_TBE ) && NE_16( st_fx->last_extl, WB_BWE ) && st_fx->igf == 0 ) || - ( st_fx->igf != 0 && fSwitchFromIO != 0 ) ) + if ( ( NE_16( st_fx->last_extl, WB_TBE ) && NE_16( st_fx->last_extl, WB_BWE ) && st_fx->igf == 0 ) || + ( st_fx->igf != 0 && fSwitchFromIO != 0 ) ) { ramp_flag = 1; + move16(); } IF( !hSC_VBR->ppp_mode ) @@ -235,15 +243,15 @@ void wb_pre_proc_ivas_fx( test(); test(); test(); - IF( ( EQ_32( st_fx->last_total_brate, ACELP_6k60 ) ) || - ( EQ_32( st_fx->last_total_brate, ACELP_8k85 ) ) || - ( EQ_32( st_fx->last_total_brate, ACELP_12k65 ) ) || - ( EQ_32( st_fx->last_total_brate, ACELP_14k25 ) ) || - ( EQ_32( st_fx->last_total_brate, ACELP_15k85 ) ) || - ( EQ_32( st_fx->last_total_brate, ACELP_18k25 ) ) || - ( EQ_32( st_fx->last_total_brate, ACELP_19k85 ) ) || - ( EQ_32( st_fx->last_total_brate, ACELP_23k05 ) ) || - ( EQ_32( st_fx->last_total_brate, ACELP_23k85 ) ) ) + if ( ( EQ_32( st_fx->last_total_brate, ACELP_6k60 ) ) || + ( EQ_32( st_fx->last_total_brate, ACELP_8k85 ) ) || + ( EQ_32( st_fx->last_total_brate, ACELP_12k65 ) ) || + ( EQ_32( st_fx->last_total_brate, ACELP_14k25 ) ) || + ( EQ_32( st_fx->last_total_brate, ACELP_15k85 ) ) || + ( EQ_32( st_fx->last_total_brate, ACELP_18k25 ) ) || + ( EQ_32( st_fx->last_total_brate, ACELP_19k85 ) ) || + ( EQ_32( st_fx->last_total_brate, ACELP_23k05 ) ) || + ( EQ_32( st_fx->last_total_brate, ACELP_23k85 ) ) ) { fSwitchFromIO = 1; move16(); @@ -303,8 +311,7 @@ void wb_pre_proc_ivas_fx( hb_speech and the two decimator memories are in Q_wb_sp */ IF( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) ) { - Sample_Delay_WB_BWE = NS2SA( 16000, DELAY_FD_BWE_ENC_12k8_NS ); - move16(); + Sample_Delay_WB_BWE = NS2SA_FX2( 16000, DELAY_FD_BWE_ENC_12k8_NS ); IF( EQ_16( last_element_mode, IVAS_CPE_TD ) ) { @@ -337,8 +344,10 @@ void wb_pre_proc_ivas_fx( ELSE IF( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) { Word16 l_recalc_16k = L_MEM_RECALC_16K + L_FILT16k + 1; /* Note: "+1" is used because L_FILT16k is not divisible by 4 */ + move16(); Word16 l_recalc_4k = ( L_MEM_RECALC_16K + L_FILT16k + 1 ) / 4; - Sample_Delay_WB_BWE = NS2SA( 16000, DELAY_FD_BWE_ENC_12k8_NS ); + move16(); + Sample_Delay_WB_BWE = NS2SA_FX2( 16000, DELAY_FD_BWE_ENC_12k8_NS ); IF( EQ_16( last_element_mode, IVAS_CPE_DFT ) ) { @@ -375,14 +384,14 @@ void wb_pre_proc_ivas_fx( { IF( EQ_32( st_fx->input_Fs, 16000 ) ) { - flip_spectrum_and_decimby4_fx( new_inp_resamp16k, hb_speech, L_FRAME16k, hBWE_TD->decim_state1_fx, hBWE_TD->decim_state2_fx, ramp_flag ); + flip_spectrum_and_decimby4_fx( temp_buf, hb_speech, L_FRAME16k, hBWE_TD->decim_state1_fx, hBWE_TD->decim_state2_fx, ramp_flag ); } ELSE { Word16 l_recalc_16k = L_FILT16k + 1; /* Note: "+1" is used because L_FILT16k is not divisible by 4 */ Word16 l_recalc_4k = ( L_FILT16k + 1 ) / 4; - Sample_Delay_WB_BWE = NS2SA( 16000, DELAY_FD_BWE_ENC_12k8_NS ); + Sample_Delay_WB_BWE = NS2SA_FX2( 16000, DELAY_FD_BWE_ENC_12k8_NS ); /*Get past signal*/ Copy_Scale_sig( hBWE_FD->L_old_wtda_swb_fx + L_FRAME16k - l_recalc_16k, old_input, l_recalc_16k, Q_wb_sp ); @@ -517,6 +526,7 @@ void swb_pre_proc_fx( Word32 CldfbHB_ener; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move16(); #endif Word16 realQ_neg1, imagQ_neg1, exp, Cldfbtemp1; TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD; @@ -587,6 +597,8 @@ void swb_pre_proc_fx( decimate_2_over_3_allpass_fx( hBWE_FD->old_fdbwe_speech_fx, L_FRAME48k, new_swb_speech_fx, hBWE_TD->dec_2_over_3_mem_fx, allpass_poles_3_ov_2, decimate_3_ov_2_lowpass_num_fx, decimate_3_ov_2_lowpass_den_fx, hBWE_TD->dec_2_over_3_mem_lp_fx ); } + move16(); + move16(); Sample_Delay_SWB_BWE = NS2SA_FX2( inner_Fs, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ); Copy( new_swb_speech_fx, &old_input_fx[Sample_Delay_SWB_BWE], inner_frame ); @@ -628,27 +640,33 @@ void swb_pre_proc_fx( test(); test(); test(); - IF( ( EQ_16( st_fx->core, ACELP_CORE ) && NE_16( st_fx->extl, SWB_BWE_HIGHRATE ) && NE_16( st_fx->extl, FB_BWE_HIGHRATE ) ) || ( ( EQ_32( st_fx->total_brate, 9600 ) || st_fx->rf_mode != 0 ) && EQ_16( st_fx->bwidth, SWB ) ) ) + IF( ( st_fx->core == ACELP_CORE && NE_16( st_fx->extl, SWB_BWE_HIGHRATE ) && NE_16( st_fx->extl, FB_BWE_HIGHRATE ) ) || ( ( EQ_32( st_fx->total_brate, 9600 ) || st_fx->rf_mode != 0 ) && EQ_16( st_fx->bwidth, SWB ) ) ) { IF( EQ_16( st_fx->L_frame, L_FRAME ) ) { startB = 34; + move16(); endB = 14; + move16(); FOR( ts = 0; ts < CLDFB_NO_COL_MAX; ts++ ) { uB = 0; + move16(); FOR( nB = startB; nB > endB; nB-- ) { - move16(); realBufferFlipped[ts][uB] = realBuffer[ts][nB]; + move32(); if ( s_and( ts, 1 ) != 0 ) { realBufferFlipped[ts][uB] = L_negate( realBufferFlipped[ts][uB] ); + move32(); } imagBufferFlipped[ts][uB] = imagBuffer[ts][nB]; + move32(); if ( s_and( ts, 1 ) == 0 ) { imagBufferFlipped[ts][uB] = L_negate( imagBufferFlipped[ts][uB] ); + move32(); } uB = add( uB, 1 ); /* uB ++ */ } @@ -657,14 +675,19 @@ void swb_pre_proc_fx( ELSE { startB = 39; + move16(); endB = 19; + move16(); FOR( ts = 0; ts < CLDFB_NO_COL_MAX; ts++ ) { uB = 0; + move16(); FOR( nB = startB; nB > endB; nB-- ) { realBufferFlipped[ts][uB] = L_negate( realBuffer[ts][nB] ); + move32(); imagBufferFlipped[ts][uB] = imagBuffer[ts][nB]; + move32(); uB = add( uB, 1 ); /* uB ++ */ } } @@ -673,6 +696,7 @@ void swb_pre_proc_fx( /* Highband energy computation for gain shape control in case of bandwidth switching fix*/ { CldfbHB_ener = 0; + move32(); FOR( nB = 0; nB < 10; nB++ ) { FOR( ts = 0; ts < CLDFB_NO_COL_MAX; ts++ ) @@ -680,13 +704,8 @@ void swb_pre_proc_fx( realQ_neg1 = extract_l( L_shr( realBufferFlipped[ts][nB], 31 - ( 15 + cldfbScale->hb_scale ) + 1 ) ); imagQ_neg1 = extract_l( L_shr( imagBufferFlipped[ts][nB], 31 - ( 15 + cldfbScale->hb_scale ) + 1 ) ); /* Q(-1), headroom needed */ -#ifdef BASOP_NOGLOB CldfbHB_ener = L_mac0_o( CldfbHB_ener, realQ_neg1, realQ_neg1, &Overflow ); CldfbHB_ener = L_mac0_o( CldfbHB_ener, imagQ_neg1, imagQ_neg1, &Overflow ); /* Q(-2) */ -#else - CldfbHB_ener = L_mac0( CldfbHB_ener, realQ_neg1, realQ_neg1 ); - CldfbHB_ener = L_mac0( CldfbHB_ener, imagQ_neg1, imagQ_neg1 ); /* Q(-2) */ -#endif } } @@ -700,6 +719,7 @@ void swb_pre_proc_fx( cldfbSynthesisFiltering( st_fx->cldfbSynTd, realBufferFlipped, imagBufferFlipped, cldfbScale, shb_speech_fx, 0, CLDFB_NO_COL_MAX, cldfbWorkBuffer ); *Q_shb_spch = 0; /*shb_speech_fx : Q0*/ + move16(); test(); test(); @@ -712,6 +732,7 @@ void swb_pre_proc_fx( } ELSE { + test(); IF( EQ_16( st_fx->bwidth, FB ) || EQ_16( st_fx->core, ACELP_CORE ) ) { set16_fx( hBWE_TD->old_speech_shb_fx, 0, L_LOOK_16k + L_SUBFR16k ); @@ -725,6 +746,7 @@ void swb_pre_proc_fx( FOR( i = 0; i < L_FRAME32k; i = i + 2 ) { spchTmp_fx[i] = negate( spchTmp_fx[i] ); + move16(); } Decimate_allpass_steep_fx( spchTmp_fx, hBWE_TD->state_ana_filt_shb_fx, L_FRAME32k, shb_speech_fx ); @@ -740,6 +762,699 @@ void swb_pre_proc_fx( FOR( i = 0; i < delay; i++ ) { shb_speech_fx[i] = mult_r( mult_r( i, 983 /*0.03f Q15*/ ), shb_speech_fx[2 * delay - 1 - i] ); + move16(); + } + } + + return; +} + +/*-------------------------------------------------------------------* + * swb_pre_proc() + * + * - Calculate the 6 to 14 kHz (or 7.5 - 15.5 kHz) SHB target signal + * for SWB TBE or SWB BWE coding + * - Common SWB TBE and SWB BWE pre-processing + *-------------------------------------------------------------------*/ + +/*full implementation pending*/ +void swb_pre_proc_ivas_fx( + Encoder_State *st, /* i/o: encoder state structure */ + Word16 *new_swb_speech, /* o : original input signal at 32kHz - Q0 */ + Word32 *new_swb_speech_fx, /* o : original input signal at 32kHz - Q - q_reImBuffer */ + Word16 *shb_speech, /* o : SHB target signal (6-14kHz) at 16kHz- Q(Q_shb_spch) */ + Word16 *Q_shb_spch, + Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : real buffer Q - q_reImbuffer */ + Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : imag buffer Q - q_reImbuffer */ + Word16 q_reImBuffer, /* i : scale data of real and imag CLDFB buffers */ + CPE_ENC_HANDLE hCPE /* i/o: CPE encoder structure */ +) +{ + Word16 Sample_Delay_SWB_BWE, inner_frame, delay; + TD_BWE_ENC_HANDLE hBWE_TD; + FD_BWE_ENC_HANDLE hBWE_FD; + Word32 inner_Fs, input_Fs; + Word16 old_input_fx[NS2SA( 48000, DELAY_FD_BWE_ENC_NS + DELAY_FIR_RESAMPL_NS ) + L_FRAME48k]; // fixed counterpart + Word32 old_input_fx_32[NS2SA( 48000, DELAY_FD_BWE_ENC_NS + DELAY_FIR_RESAMPL_NS ) + L_FRAME48k]; // fixed counterpart + Word16 spchTmp[L_FRAME32k], spchTmp2[L_FRAME32k]; + Word16 i, j, L_resamp; + Word16 startB, endB; + Word32 *realBufferFlipped[CLDFB_NO_COL_MAX]; + Word32 *imagBufferFlipped[CLDFB_NO_COL_MAX]; + Word32 realBufferTmp[CLDFB_NO_COL_MAX][20]; + Word32 imagBufferTmp[CLDFB_NO_COL_MAX][20]; + Word32 shb_speech_fx_32[L_FRAME16k]; + Word16 ts, nB, uB; + Word32 v, t, regression; + Word16 t_16; + const Word32 *thr, *regV; + Word32 lbEner; + Word16 exp_lbEner = 0; + Word16 Sample_Delay_SWB_BWE32k, lMemRecalc32k, dft_ovl32k; + Word32 one_by_50_Q31 = 42949673; + + lMemRecalc32k = NS2SA_FX2( 32000, L_MEM_RECALC_NS ); + move16(); // exp_lbEner + move16(); // lMemRecalc32k + move32(); // one_by_50_Q31 + + /* initialization */ + hBWE_TD = st->hBWE_TD; + hBWE_FD = st->hBWE_FD; + input_Fs = st->input_Fs; + + FOR( j = 0; j < CLDFB_NO_COL_MAX; j++ ) + { + set32_fx( realBufferTmp[j], 0, 20 ); + set32_fx( imagBufferTmp[j], 0, 20 ); + realBufferFlipped[j] = realBufferTmp[j]; + imagBufferFlipped[j] = imagBufferTmp[j]; + } + + set16_fx( old_input_fx, 0, NS2SA_FX2( 48000, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ) + L_FRAME48k ); + + IF( EQ_32( st->input_Fs, 32000 ) ) + { + IF( st->element_mode > EVS_MONO ) + { + Sample_Delay_SWB_BWE = NS2SA_FX2( 32000, DELAY_FD_BWE_ENC_12k8_NS ); + IF( EQ_16( st->L_frame, L_FRAME16k ) ) + { + Sample_Delay_SWB_BWE = NS2SA_FX2( 32000, DELAY_FD_BWE_ENC_16k_NS ); + } + + Copy( st->input_fx - Sample_Delay_SWB_BWE, hBWE_FD->old_input_fx, Sample_Delay_SWB_BWE ); + Copy( st->input_fx - L_FRAME32k, hBWE_FD->old_fdbwe_speech_fx, L_FRAME32k ); + + test(); + test(); + IF( EQ_16( st->element_mode, IVAS_CPE_TD ) && GE_16( st->bwidth, SWB ) ) + { + Copy( st->input_fx - hCPE->hStereoTCA->lMemRecalc, hBWE_FD->L_old_wtda_swb_fx + L_FRAME32k - sub( hCPE->hStereoTCA->lMemRecalc, Sample_Delay_SWB_BWE ), sub( hCPE->hStereoTCA->lMemRecalc, Sample_Delay_SWB_BWE ) ); + } + ELSE IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) && GE_16( st->bwidth, SWB ) ) + { + Copy( st->input_fx - hCPE->hStereoDft->dft_ovl, hBWE_FD->L_old_wtda_swb_fx + L_FRAME32k - sub( hCPE->hStereoDft->dft_ovl, Sample_Delay_SWB_BWE ), sub( hCPE->hStereoDft->dft_ovl, Sample_Delay_SWB_BWE ) ); + } + } + + Copy( st->input_fx, new_swb_speech, L_FRAME32k ); + + test(); + test(); + IF( NE_16( st->last_extl, SWB_BWE ) && NE_16( st->last_extl, FB_BWE ) && NE_16( st->extl, SWB_BWE_HIGHRATE ) ) + { + Sample_Delay_SWB_BWE = NS2SA_FX2( 32000, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ); + test(); + IF( st->element_mode > EVS_MONO && EQ_16( st->L_frame, L_FRAME16k ) ) + { + Sample_Delay_SWB_BWE = NS2SA_FX2( 32000, DELAY_FD_BWE_ENC_16k_NS + DELAY_FIR_RESAMPL_NS ); + } + IF( st->element_mode > EVS_MONO ) + { + Sample_Delay_SWB_BWE = sub( Sample_Delay_SWB_BWE, NS2SA_FX2( 32000, DELAY_FIR_RESAMPL_NS ) ); + } + + Copy( hBWE_FD->old_fdbwe_speech_fx, &old_input_fx[Sample_Delay_SWB_BWE], L_FRAME32k ); + + set16_fx( old_input_fx, 0, Sample_Delay_SWB_BWE ); + Copy( hBWE_FD->old_fdbwe_speech_fx + L_FRAME32k - Sample_Delay_SWB_BWE, hBWE_FD->old_input_fx, Sample_Delay_SWB_BWE ); + IF( NE_16( st->extl, WB_BWE ) ) + { + Copy( old_input_fx, hBWE_FD->L_old_wtda_swb_fx, L_FRAME32k ); + } + } + + test(); + IF( NE_16( st->extl, SWB_BWE ) && NE_16( st->extl, FB_BWE ) ) + { + Copy( st->input_fx, hBWE_FD->old_fdbwe_speech_fx, L_FRAME32k ); + } + } + ELSE /* 48 kHz */ + { + + Sample_Delay_SWB_BWE32k = NS2SA_FX2( 32000, DELAY_FD_BWE_ENC_12k8_NS ); + move16(); + Sample_Delay_SWB_BWE = NS2SA_FX2( 48000, DELAY_FD_BWE_ENC_12k8_NS ); + move16(); + IF( EQ_16( st->L_frame, L_FRAME16k ) ) + { + Sample_Delay_SWB_BWE32k = NS2SA_FX2( 32000, DELAY_FD_BWE_ENC_16k_NS ); + move16(); + Sample_Delay_SWB_BWE = NS2SA_FX2( 48000, DELAY_FD_BWE_ENC_16k_NS ); + move16(); + } + + dft_ovl32k = 0; + move16(); + IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) ) + { + dft_ovl32k = (Word16) ( STEREO_DFT_OVL_MAX * 32000 / 48000 ); + move16(); + } + + IF( EQ_16( st->codec_mode, MODE1 ) ) + { + IF( st->element_mode > EVS_MONO ) + { + + IF( EQ_16( st->element_mode, IVAS_CPE_TD ) ) + { + } + ELSE IF( EQ_16( st->bwidth, FB ) ) + { + Copy( st->input_fx - Sample_Delay_SWB_BWE, hBWE_FD->old_input_fx, Sample_Delay_SWB_BWE ); + } + + Copy( st->input_fx - L_FRAME48k, hBWE_FD->old_fdbwe_speech_fx, L_FRAME48k ); + + test(); + test(); + IF( EQ_16( st->element_mode, IVAS_CPE_TD ) && GE_16( st->bwidth, SWB ) ) + { + IF( EQ_16( st->bwidth, SWB ) ) + { + /* buffers hBWE_FD->old_input[] and hBWE_FD->old_wtda_swb[] need to be at 32 kHz (inner) sampling rate */ + + decimate_2_over_3_allpass_fx( st->input_fx - hCPE->hStereoTCA->lMemRecalc, hCPE->hStereoTCA->lMemRecalc, spchTmp, hBWE_TD->dec_2_over_3_mem_fx, + allpass_poles_3_ov_2, decimate_3_ov_2_lowpass_num_fx, decimate_3_ov_2_lowpass_den_fx, hBWE_TD->dec_2_over_3_mem_lp_fx ); + + Copy( spchTmp, hBWE_FD->L_old_wtda_swb_fx + L_FRAME32k - sub( lMemRecalc32k, Sample_Delay_SWB_BWE32k ), sub( lMemRecalc32k, Sample_Delay_SWB_BWE32k ) ); + Copy( spchTmp + lMemRecalc32k - Sample_Delay_SWB_BWE32k, hBWE_FD->old_input_fx, Sample_Delay_SWB_BWE32k ); + } + ELSE /* FB_BWE */ + { + Copy( st->input_fx - hCPE->hStereoTCA->lMemRecalc, hBWE_FD->L_old_wtda_swb_fx + L_FRAME48k - sub( hCPE->hStereoTCA->lMemRecalc, Sample_Delay_SWB_BWE ), sub( hCPE->hStereoTCA->lMemRecalc, Sample_Delay_SWB_BWE ) ); + Copy( st->input_fx - Sample_Delay_SWB_BWE, hBWE_FD->old_input_fx, Sample_Delay_SWB_BWE ); + } + } + ELSE IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) && GE_16( st->bwidth, SWB ) ) + { + IF( EQ_16( st->bwidth, SWB ) ) + { + lerp( st->input_fx - hCPE->hStereoDft->dft_ovl, spchTmp, dft_ovl32k - Sample_Delay_SWB_BWE32k, hCPE->hStereoDft->dft_ovl - Sample_Delay_SWB_BWE ); + + Copy( spchTmp, hBWE_FD->L_old_wtda_swb_fx + L_FRAME32k - ( dft_ovl32k - Sample_Delay_SWB_BWE32k ), dft_ovl32k - Sample_Delay_SWB_BWE32k ); + } + ELSE + { + Copy( st->input_fx - hCPE->hStereoDft->dft_ovl, hBWE_FD->L_old_wtda_swb_fx + L_FRAME48k - ( hCPE->hStereoDft->dft_ovl - Sample_Delay_SWB_BWE ), hCPE->hStereoDft->dft_ovl - Sample_Delay_SWB_BWE ); + } + } + } + + test(); + test(); + test(); + test(); + IF( ( NE_16( st->extl, SWB_BWE ) && NE_16( st->extl, FB_BWE ) && ( st->core == ACELP_CORE ) ) || ( EQ_16( st->element_mode, IVAS_CPE_DFT ) && ( st->core != ACELP_CORE ) ) /*resampling not needed for MDCT cores*/ ) + { + /* move the resampling out of the TDBWE path as new_swb_speech is not needed for TDBWE. */ + Copy( st->input_fx, hBWE_FD->old_fdbwe_speech_fx, L_FRAME48k ); + } + ELSE + { + test(); + IF( NE_16( st->last_extl, SWB_BWE ) && NE_16( st->last_extl, FB_BWE ) ) + { + /* resample 48 kHz to 32kHz */ + IF( EQ_16( st->last_bwidth, FB ) ) + { + inner_frame = L_FRAME48k; + move16(); + inner_Fs = 48000; + move32(); + Copy( hBWE_FD->old_fdbwe_speech_fx, new_swb_speech, L_FRAME48k ); + } + ELSE + { + inner_frame = L_FRAME32k; + move16(); + inner_Fs = 32000; + move32(); + + IF( NE_16( st->element_mode, IVAS_CPE_DFT ) ) + { + decimate_2_over_3_allpass_fx( hBWE_FD->old_fdbwe_speech_fx, L_FRAME48k, new_swb_speech, hBWE_TD->dec_2_over_3_mem_fx, allpass_poles_3_ov_2, decimate_3_ov_2_lowpass_num_fx, decimate_3_ov_2_lowpass_den_fx, hBWE_TD->dec_2_over_3_mem_lp_fx ); + } + ELSE + { + lerp( hBWE_FD->old_fdbwe_speech_fx, new_swb_speech, inner_frame, L_FRAME48k ); + } + + test(); + IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) && st->idchan == 0 ) + { + FOR( i = 0; i < STEREO_DFT_OVL_32k; i++ ) + { + hCPE->hStereoDft->output_mem_dmx_32k_fx[i] = L_shr( Mpy_32_16_1( hCPE->hStereoDft->win_32k_fx[STEREO_DFT_OVL_32k - 1 - i], new_swb_speech[( ( inner_frame + i ) - STEREO_DFT_OVL_32k )] ), 1 ); // Q15 + move32(); + } + } + } + + Sample_Delay_SWB_BWE = NS2SA_FX2( inner_Fs, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ); + move16(); + test(); + IF( st->element_mode > EVS_MONO && EQ_16( st->L_frame, L_FRAME16k ) ) + { + Sample_Delay_SWB_BWE = NS2SA_FX2( inner_Fs, DELAY_FD_BWE_ENC_16k_NS + DELAY_FIR_RESAMPL_NS ); + move16(); + } + IF( st->element_mode > EVS_MONO ) + { + Sample_Delay_SWB_BWE = sub( Sample_Delay_SWB_BWE, NS2SA_FX2( inner_Fs, DELAY_FIR_RESAMPL_NS ) ); + } + + Copy( new_swb_speech, &old_input_fx[Sample_Delay_SWB_BWE], inner_frame ); + set16_fx( old_input_fx, 0, Sample_Delay_SWB_BWE ); + Copy( new_swb_speech + inner_frame - Sample_Delay_SWB_BWE, hBWE_FD->old_input_fx, Sample_Delay_SWB_BWE ); + Copy( old_input_fx, hBWE_FD->L_old_wtda_swb_fx, inner_frame ); + } + + /* resample 48 kHz to 32kHz */ + IF( EQ_16( st->bwidth, FB ) ) + { + Copy( st->input_fx, new_swb_speech, L_FRAME48k ); + } + ELSE + { + IF( EQ_16( st->element_mode, IVAS_CPE_TD ) ) + { + Word16 dec_2_over_3_mem_tmp[L_FILT_2OVER3], dec_2_over_3_mem_lp_tmp[L_FILT_2OVER3_LP]; + + decimate_2_over_3_allpass_fx( st->input_fx, L_FRAME48k - hCPE->hStereoTCA->lMemRecalc, new_swb_speech, hBWE_TD->dec_2_over_3_mem_fx, allpass_poles_3_ov_2, decimate_3_ov_2_lowpass_num_fx, decimate_3_ov_2_lowpass_den_fx, hBWE_TD->dec_2_over_3_mem_lp_fx ); + + Copy( hBWE_TD->dec_2_over_3_mem_fx, dec_2_over_3_mem_tmp, L_FILT_2OVER3 ); + Copy( hBWE_TD->dec_2_over_3_mem_lp_fx, dec_2_over_3_mem_lp_tmp, L_FILT_2OVER3_LP ); + + decimate_2_over_3_allpass_fx( st->input_fx + L_FRAME48k - hCPE->hStereoTCA->lMemRecalc, hCPE->hStereoTCA->lMemRecalc, new_swb_speech + L_FRAME32k - lMemRecalc32k, dec_2_over_3_mem_tmp, allpass_poles_3_ov_2, decimate_3_ov_2_lowpass_num_fx, decimate_3_ov_2_lowpass_den_fx, dec_2_over_3_mem_lp_tmp ); + } + ELSE IF( NE_16( st->element_mode, IVAS_CPE_DFT ) ) + { + decimate_2_over_3_allpass_fx( st->input_fx, L_FRAME48k, new_swb_speech, hBWE_TD->dec_2_over_3_mem_fx, allpass_poles_3_ov_2, decimate_3_ov_2_lowpass_num_fx, decimate_3_ov_2_lowpass_den_fx, hBWE_TD->dec_2_over_3_mem_lp_fx ); + } + ELSE /* IVAS_CPE_DFT */ + { + Word16 out_start_ind, out_end_ind; + stereo_dft_enc_synthesize_fx( hCPE->hStereoDft, new_swb_speech_fx, &out_start_ind, &out_end_ind, st->idchan, input_Fs, 32000, 0, NULL ); + Copy_Scale_sig32_16( new_swb_speech_fx - STEREO_DFT_OVL_MAX, new_swb_speech - STEREO_DFT_OVL_MAX, L_FRAME48k + STEREO_DFT_OVL_MAX, add( q_reImBuffer, 1 ) ); // Q0 + Copy( new_swb_speech - Sample_Delay_SWB_BWE32k, hBWE_FD->old_input_fx, Sample_Delay_SWB_BWE32k ); // Q0 + } + } + } + } + ELSE + { + /* resample 48 kHz to 32kHz */ + IF( EQ_16( st->bwidth, FB ) ) + { + Copy( st->input_fx, new_swb_speech, L_FRAME48k ); + } + ELSE + { + decimate_2_over_3_allpass_fx( st->input_fx, L_FRAME48k, new_swb_speech, hBWE_TD->dec_2_over_3_mem_fx, allpass_poles_3_ov_2, decimate_3_ov_2_lowpass_num_fx, decimate_3_ov_2_lowpass_den_fx, hBWE_TD->dec_2_over_3_mem_lp_fx ); + } + } + } + + test(); + test(); + test(); + test(); + test(); + test(); + IF( ( ( st->core == ACELP_CORE ) && NE_16( st->extl, SWB_BWE_HIGHRATE ) && NE_16( st->extl, FB_BWE_HIGHRATE ) ) || + ( ( EQ_32( st->total_brate, ACELP_9k60 ) || st->rf_mode ) && EQ_16( st->bwidth, SWB ) && ( st->element_mode == EVS_MONO ) ) ) + { + Word32 CldfbHB_fx = 0; // fixed counterpart + Word16 CldfbHB_fx_e = 0; // fixed counterpart +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; + move16(); +#endif + Word16 realQ_neg1, imagQ_neg1, exp = 0, Cldfbtemp1; + move32(); + move16(); + move16(); + + IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) ) + { + Word16 out_start_ind, out_end_ind; + Word16 exp_icbweRefEner_fx; + Copy_Scale_sig_16_32_DEPREC( (const Word16 *) &old_input_fx[0], &old_input_fx_32[0], NS2SA( 48000, DELAY_FD_BWE_ENC_NS + DELAY_FIR_RESAMPL_NS ) + L_FRAME48k, Q15 ); // Q15 + CldfbHB_fx = stereo_dft_enc_synthesize_fx( hCPE->hStereoDft, old_input_fx_32 + STEREO_DFT_OVL_16k, &out_start_ind, &out_end_ind, st->idchan, input_Fs, 16000, st->L_frame, &CldfbHB_fx_e ); + Copy_Scale_sig_32_16( (const Word32 *) &old_input_fx_32[0], &old_input_fx[0], NS2SA( 48000, DELAY_FD_BWE_ENC_NS + DELAY_FIR_RESAMPL_NS ) + L_FRAME48k, -Q15 ); // Q0 + + /* delay corresponding to CLDFB delay */ + Copy( old_input_fx + STEREO_DFT_OVL_16k - 20, shb_speech, L_FRAME16k ); + Copy( old_input_fx, hBWE_TD->old_speech_shb_fx + L_LOOK_16k + L_SUBFR16k - ( STEREO_DFT_OVL_16k - 20 ), STEREO_DFT_OVL_16k - 20 ); + Copy( old_input_fx, hCPE->hStereoICBWE->mem_shb_speech_ref_fx, STEREO_DFT_OVL_16k - 20 ); // Q0 + hCPE->hStereoICBWE->mem_shb_speech_ref_e = 15; + move16(); + + IF( LE_32( CldfbHB_fx, 0 ) ) + { + CldfbHB_fx = EPSILON_FX; + move32(); + } + CldfbHB_fx = L_shl( CldfbHB_fx, exp ); /* CldfbHB_ener = CldfbHB_fl*2^(exp) */ + Cldfbtemp1 = Log2_norm_lc( CldfbHB_fx ); /* Log2_norm_lc(t) = 2^15*(log2(t/2^30)) */ + Cldfbtemp1 = sub( shr( Cldfbtemp1, 6 ), shl( add( sub( Q31 - Q30, CldfbHB_fx_e ), exp ), 9 ) ); + CldfbHB_fx = L_mult( Cldfbtemp1, 9864 ); /* Q9 + Q15 + Q1 = Q25 */ + CldfbHB_fx = Mpy_32_16_1( L_sub( CldfbHB_fx, 1 << Q25 ), 11611 /* 0.1 * 0.221462 in Q19 */ ); + /* Resulting Q = Q25 + Q19 - Q15 = Q29 */ + hBWE_TD->cldfbHBLT = mac_r( CldfbHB_fx, 29491 /*0.9 Q15*/, hBWE_TD->cldfbHBLT ); /* cldfbHBLT is in Q13 */ + move16(); + + exp_lbEner = hCPE->hStereoDft->lbEner_fx_e; + move32(); + lbEner = Mpy_32_16_1( Sqrt32( hCPE->hStereoDft->lbEner_fx, &exp_lbEner ), 1638 /* 0.05 in Q15 */ ); + exp_icbweRefEner_fx = hCPE->hStereoDft->icbweRefEner_fx_e; + move16(); + hCPE->hStereoICBWE->icbweRefEner_fx = Mpy_32_16_1( Sqrt32( hCPE->hStereoDft->icbweRefEner_fx, &exp_icbweRefEner_fx ), 1638 /* 0.05 in Q15 */ ); + move32(); + hCPE->hStereoICBWE->icbweRefEner_fx_e = exp_icbweRefEner_fx; + move16(); + // lbEner = 0.05f * (float) sqrt( hCPE->hStereoDft->lbEner ); + thr = icbwe_thr_DFT_fx; + regV = icbwe_regressionValuesDFT_fx; + } + ELSE + { + IF( EQ_16( st->L_frame, L_FRAME ) ) + { + startB = 34; + move16(); + endB = 14; + move16(); + FOR( ts = 0; ts < CLDFB_NO_COL_MAX; ts++ ) + { + uB = 0; + move16(); + FOR( nB = startB; nB > endB; nB-- ) + { + realBufferFlipped[ts][uB] = realBuffer[ts][nB]; + move32(); + if ( s_and( ts, 1 ) != 0 ) + { + realBufferFlipped[ts][uB] = L_negate( realBufferFlipped[ts][uB] ); + move32(); + } + imagBufferFlipped[ts][uB] = imagBuffer[ts][nB]; + move32(); + if ( s_and( ts, 1 ) == 0 ) + { + imagBufferFlipped[ts][uB] = L_negate( imagBufferFlipped[ts][uB] ); + move32(); + } + uB = add( uB, 1 ); /* uB ++ */ + } + } + } + ELSE + { + startB = 39; + move16(); + endB = 19; + move16(); + FOR( ts = 0; ts < CLDFB_NO_COL_MAX; ts++ ) + { + uB = 0; + move16(); + FOR( nB = startB; nB > endB; nB-- ) + { + realBufferFlipped[ts][uB] = L_negate( realBuffer[ts][nB] ); + move32(); + imagBufferFlipped[ts][uB] = imagBuffer[ts][nB]; + move32(); + uB = add( uB, 1 ); /* uB ++ */ + } + } + } + + FOR( nB = 0; nB < 10; nB++ ) + { + FOR( ts = 0; ts < CLDFB_NO_COL_MAX; ts++ ) + { + realQ_neg1 = extract_l( L_shr( realBufferFlipped[ts][nB], 16 ) ); + imagQ_neg1 = extract_l( L_shr( imagBufferFlipped[ts][nB], 16 ) ); /* Q(-1), headroom needed */ + + CldfbHB_fx = L_mac0_o( CldfbHB_fx, realQ_neg1, realQ_neg1, &Overflow ); + CldfbHB_fx = L_mac0_o( CldfbHB_fx, imagQ_neg1, imagQ_neg1, &Overflow ); /* Q(-2) */ + } + } + CldfbHB_fx_e = sub( Q31, shl( sub( q_reImBuffer, Q16 ), 1 ) ); + exp = norm_l( CldfbHB_fx ); + CldfbHB_fx = L_shl( CldfbHB_fx, exp ); /* CldfbHB_ener = CldfbHB_fl*2^(exp) */ + Cldfbtemp1 = Log2_norm_lc( CldfbHB_fx ); /* Log2_norm_lc(t) = 2^15*(log2(t/2^30)) */ + Cldfbtemp1 = sub( shr( Cldfbtemp1, 6 ), shl( add( sub( Q31 - Q30, CldfbHB_fx_e ), exp ), 9 ) ); + CldfbHB_fx = L_mult( Cldfbtemp1, 9864 ); /* Q9 + Q15 + Q1 = Q25 */ + CldfbHB_fx = Mpy_32_16_1( L_sub( CldfbHB_fx, 1 << Q25 ), 11611 /* 0.1 * 0.221462 in Q19 */ ); + /* Resulting Q = Q25 + Q19 - Q15 = Q29 */ + hBWE_TD->cldfbHBLT = mac_r( CldfbHB_fx, 29491 /*0.9 Q15*/, hBWE_TD->cldfbHBLT ); /* cldfbHBLT is in Q13 */ + move32(); + + IF( CldfbHB_fx == 0 ) + { + CldfbHB_fx = EPSILLON_FX; + move32(); + } + + test(); + IF( GE_16( st->element_mode, IVAS_CPE_DFT ) && hCPE->hStereoICBWE != NULL ) + { + Word32 icbweRefEner_fx = EPSILON_FX; + Word16 exp_icbweRefEner_fx = 0; + + move32(); + move16(); + FOR( nB = 20; nB < 40; nB++ ) + { + FOR( ts = 0; ts < CLDFB_NO_COL_MAX; ts++ ) + { + realQ_neg1 = extract_l( L_shr( realBuffer[ts][nB], 16 ) ); + imagQ_neg1 = extract_l( L_shr( imagBuffer[ts][nB], 16 ) ); /* Q(-1), headroom needed */ + icbweRefEner_fx = L_mac0_o( icbweRefEner_fx, realQ_neg1, realQ_neg1, &Overflow ); + icbweRefEner_fx = L_mac0_o( icbweRefEner_fx, imagQ_neg1, imagQ_neg1, &Overflow ); /* Q(-2) */ + } + } + exp_icbweRefEner_fx = sub( Q31, shl( sub( q_reImBuffer, Q16 ), 1 ) ); + hCPE->hStereoICBWE->icbweRefEner_fx = Mpy_32_16_1( Sqrt32( icbweRefEner_fx, &exp_icbweRefEner_fx ), 1638 /* 0.05 in Q15 */ ); + move32(); + hCPE->hStereoICBWE->icbweRefEner_fx_e = exp_icbweRefEner_fx; + move16(); + } + + lbEner = EPSILON_FX; + move32(); + FOR( nB = 0; nB < 20; nB++ ) + { + FOR( ts = 0; ts < CLDFB_NO_COL_MAX; ts++ ) + { + realQ_neg1 = extract_l( L_shr( realBuffer[ts][nB], 16 ) ); + imagQ_neg1 = extract_l( L_shr( imagBuffer[ts][nB], 16 ) ); /* Q(-1), headroom needed */ + + lbEner = L_mac0_o( lbEner, realQ_neg1, realQ_neg1, &Overflow ); + lbEner = L_mac0_o( lbEner, imagQ_neg1, imagQ_neg1, &Overflow ); /* Q(-2) */ + } + } + exp_lbEner = sub( Q31, shl( sub( q_reImBuffer, Q16 ), 1 ) ); + lbEner = Mpy_32_16_1( Sqrt32( lbEner, &exp_lbEner ), 1638 /* 0.05 in Q15 */ ); + thr = icbwe_thr_TDM_fx; + regV = icbwe_regressionValuesTDM_fx; + + cldfbSynthesis_ivas_fx( realBufferFlipped, imagBufferFlipped, shb_speech_fx_32, -1, st->cldfbSynTd ); + Copy_Scale_sig_32_16( shb_speech_fx_32, shb_speech, L_FRAME16k, negate( sub( q_reImBuffer, 1 ) ) ); + *Q_shb_spch = 0; + move16(); + } + + IF( GE_16( st->element_mode, IVAS_CPE_DFT ) && hCPE->hStereoICBWE != NULL ) + { + Word16 exp_t; + hCPE->hStereoICBWE->MSFlag = 0; /* Init the multi-source flag */ + move16(); + v = Mpy_32_16_1( L_add( L_deposit_l( st->voicing_fx[0] ), L_add( L_deposit_l( st->voicing_fx[1] ), L_deposit_l( st->voicing_fx[2] ) ) ), 10923 /* 0.33333 in Q15 */ ); + + // t = log10f( ( hCPE->hStereoICBWE->icbweRefEner + 1e-6f ) / ( lbEner + 1e-6f ) ); + t = L_deposit_h( BASOP_Util_Divide3232_Scale( L_add( hCPE->hStereoICBWE->icbweRefEner_fx, EPSILON_FX ), L_add( lbEner, EPSILON_FX ), &exp_t ) ); + exp_t = add( exp_t, sub( hCPE->hStereoICBWE->icbweRefEner_fx_e, exp_lbEner ) ); + exp = norm_l( t ); + t = L_shl( t, exp ); + t_16 = Log2_norm_lc( t ); /* Log2_norm_lc(t) = 2^15*(log2(t/2^30)) */ + t_16 = sub( shr( t_16, 6 ), shl( add( sub( Q31 - Q30, exp_t ), exp ), 9 ) ); + t = L_mult( t_16, 9864 ); /* Q9 + Q15 + Q1 = Q25 */ + /* Three Level Decision Tree to calculate a regression value first */ + IF( LT_32( t, thr[0] ) ) /* level 1 */ + { + IF( LT_32( t, thr[1] ) ) /* level 2 */ + { + IF( LT_32( v, thr[3] ) ) + { + regression = regV[0]; /* level 3 */ + move32(); + } + ELSE + { + regression = regV[1]; + move32(); + } + } + ELSE + { + IF( LT_32( v, thr[4] ) ) + { + regression = regV[2]; /* level 3 */ + move32(); + } + ELSE + { + regression = regV[3]; + move32(); + } + } + } + ELSE + { + IF( LT_32( t, thr[2] ) ) /* level 2 */ + { + IF( LT_32( v, thr[5] ) ) + { + regression = regV[4]; /* level 3 */ + move32(); + } + ELSE + { + regression = regV[5]; + move32(); + } + } + ELSE + { + IF( LT_32( v, thr[6] ) ) + { + regression = regV[6]; /* level 3 */ + move32(); + } + ELSE + { + regression = regV[7]; + move32(); + } + } + } + + test(); + test(); + /* Convert the regression to a hard decision (classification) */ + IF( GT_32( regression, 1696512081 /* 0.79f in Q31*/ ) && !( LT_16( st->bwidth, SWB ) || hCPE->hCoreCoder[0]->vad_flag == 0 ) ) + { + hCPE->hStereoICBWE->MSFlag = 1; + move16(); + } + } + + test(); + test(); + IF( NE_16( st->extl, WB_TBE ) && NE_16( st->extl, SWB_TBE ) && NE_16( st->extl, FB_TBE ) ) + { + /* Update the previous superwideband speech buffer in case of a SWB_BWE frame - this code is in swb_tbe_enc */ + delay = L_LOOK_16k + L_SUBFR16k; + move16(); + Copy( shb_speech + sub( L_FRAME16k, delay ), hBWE_TD->old_speech_shb_fx, delay ); + } + } + ELSE + { + test(); + test(); + IF( ( EQ_16( st->bwidth, FB ) || st->core == ACELP_CORE ) && ( st->element_mode == EVS_MONO ) ) + { + InitSWBencBufferStates_fx( st->hBWE_TD, shb_speech ); + } + ELSE + { + IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) ) + { + IF( EQ_16( st->L_frame, L_FRAME ) ) + { + L_resamp = 560; /* 6.4 kHz core -> 6 - 14 kHz SHB target. 20 ms is 560 samples in 28 kHz sample rate */ + move16(); + } + ELSE + { + L_resamp = 620; /* 8 kHz core -> 7.5 - 15.5 kHz SHB target. 20 ms is 620 samples in 31 kHz sample rate */ + move16(); + } + + /* Dirty downsampling to match Nyquist to upper frequency limit of target */ + lerp( st->input_fx, new_swb_speech, L_resamp, (int16_t) Mpy_32_32( input_Fs, one_by_50_Q31 ) ); + + /* flip the spectrum */ + Copy( new_swb_speech, spchTmp, L_resamp ); + FOR( i = 0; i < L_resamp; i = i + 2 ) + { + spchTmp[i] = negate( spchTmp[i] ); + move16(); + } + + /* Dirty upsampling to match Nyquist/2 to lower frequency limit of target (reversed spectrum)*/ + lerp( spchTmp, spchTmp2, L_FRAME32k, L_resamp ); + Copy( spchTmp2, spchTmp, L_FRAME32k ); + } + ELSE + { + /* flip the spectrum */ + Copy( new_swb_speech, spchTmp, L_FRAME32k ); + + FOR( i = 0; i < L_FRAME32k; i = i + 2 ) + { + spchTmp[i] = negate( spchTmp[i] ); + move16(); + } + } + + Decimate_allpass_steep_fx( spchTmp, hBWE_TD->state_ana_filt_shb_fx, L_FRAME32k, shb_speech ); + + Copy( shb_speech + L_FRAME16k - ( L_LOOK_16k + L_SUBFR16k ), hBWE_TD->old_speech_shb_fx, L_LOOK_16k + L_SUBFR16k ); + + /*Compute the past overlap for potential next iDFTs SHB*/ + IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) ) + { + FOR( i = 0; i < STEREO_DFT_OVL_16k; i++ ) + { + hCPE->hStereoDft->output_mem_dmx_16k_shb_fx[i] = L_mult0( shb_speech[20 + i], mult_r( hCPE->hStereoDft->win_ana_16k_fx[STEREO_DFT_OVL_16k - 1 - i], hCPE->hStereoDft->win_ana_16k_fx[STEREO_DFT_OVL_16k - 1 - i] ) ); // Q15 + move32(); + } + } + } + + IF( NE_16( st->element_mode, IVAS_CPE_DFT ) ) + { + /* Reset CLDFB synthesis buffer */ + set32_fx( st->cldfbSynTd->cldfb_state_fx, 0, st->cldfbSynTd->p_filter_length ); + } + ELSE + { + hCPE->hStereoDft->flip_sign = negate( hCPE->hStereoDft->flip_sign ); /* Make sure sign is updated even if DFT SHB target is not generated */ + move16(); + } + } + + /* Memory reset to compensate for 0.9375 ms offset when transitioning from IO to SWB */ + /* When switching from n >1 to n = 1, we keep the enc/dec delay as 8.75/3.25 and below code not needed; + only when n = 1 start, it will be 9.6875/2.3125 in that case this reset is needed for IO->BWE.*/ + test(); + IF( EQ_16( st->last_extl, -1 ) && ( st->element_mode == EVS_MONO ) ) + { + delay = NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS ); + move16(); + FOR( i = 0; i < delay; i++ ) + { + shb_speech[i] = mult_r( mult_r( i, 983 /*0.03f Q15*/ ), shb_speech[2 * delay - 1 - i] ); + move16(); } } diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index 3dfb552e6024ad70002462a4a96c5f4f2bc9726d..f67d81c7132e58062b7ee282a686c76fbb31fd7a 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -6,7 +6,6 @@ #include #include "options.h" #include "cnst.h" -//#include "prot_fx.h" #include "rom_com_fx.h" #include "rom_com.h" #include "prot.h" /* Function prototypes */ @@ -63,6 +62,16 @@ static void EstimateSHBFrameGain_fx( const Word16 length, const Word16 *subwin_shb, const Word16 n_subfr_saturation ); +static void EstimateSHBFrameGain_ivas_fx( const Word16 length, + const Word16 *oriSHB, + const Word16 Q_oriSHB, + const Word16 *synSHB, + const Word16 Q_synSHB, + Word16 *subgain, + Word32 *GainFrame, + const Word16 *win_shb, + const Word16 *subwin_shb, + const Word16 n_subfr_saturation ); static void EstimateSHBGainShape_fx( const Word16 length, const Word16 *oriSHB, @@ -132,8 +141,11 @@ void find_max_mem_enc( Word16 i; Word16 n_mem_32; Word16 max = 0; + move16(); Word32 Lmax = 0; + move32(); Word16 tempQ15, max2 = 0; + move16(); TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD; /* old BWE exc max */ @@ -175,9 +187,13 @@ void find_max_mem_enc( /* for total_brate > 16.4kbps, use n_mem2; else account for the max2 for n_mem calculation */ *n_mem2 = norm_s( max2 ); + move16(); if ( max2 == 0 ) + { *n_mem2 = 15; - if ( LT_32( st_fx->total_brate, ACELP_24k40 ) ) + move16(); + } + IF( LT_32( st_fx->total_brate, ACELP_24k40 ) ) { max = s_max( max, max2 ); } @@ -202,9 +218,11 @@ void find_max_mem_enc( } /* estimate the norm for 16-bit memories */ *n_mem = norm_s( max ); + move16(); if ( max == 0 ) { *n_mem = 15; + move16(); } /* estimate the norm for 32-bit memories */ @@ -214,10 +232,12 @@ void find_max_mem_enc( if ( Lmax == 0 ) { n_mem_32 = 31; + move16(); } tempQ15 = sub( s_min( *n_mem, n_mem_32 ), 1 ); *n_mem = s_max( tempQ15, 0 ); + move16(); } @@ -587,9 +607,9 @@ void InitSWBencBuffer_ivas_fx( // TV2TV IVAS_CODE -> To be verify if it has to be moved to hBWE_TD - st_fx->prev_Q_bwe_exc = 31; + st_fx->prev_Q_bwe_exc = 15; move16(); - st_fx->prev_Q_bwe_syn = 31; + st_fx->prev_Q_bwe_syn = 15; move16(); set16_fx( st_fx->prev_lsp_wb_fx, 0, 6 ); set16_fx( st_fx->prev_lsp_wb_temp_fx, 0, 6 ); @@ -696,6 +716,8 @@ void wb_tbe_enc_fx( Word16 lpc_wb[LPC_SHB_ORDER_WB + 1]; Word32 lpc_wb_32_fx[LPC_SHB_ORDER_WB + 1]; Word16 lsp_wb[LPC_SHB_ORDER_WB], weights_lsp[LPC_SHB_ORDER_WB] = { 32767, 32767 }; + move16(); + move16(); Word16 *hb_new_speech, *hb_frame /*, hb_speech[ L_FRAME16k ]*/; Word16 R_h[LPC_SHB_ORDER_WB + 2], R_l[LPC_SHB_ORDER_WB + 2]; Word16 Q_R; @@ -710,6 +732,7 @@ void wb_tbe_enc_fx( Word32 L_tmp, Lmax; Word16 tmp, exp, Q_out, sc; Word16 Q_ns = -1; + move16(); Word16 pitBufAvg_fx, voicingBufAvg_fx; Word16 vf_modified_fx[NB_SUBFR16k]; @@ -720,11 +743,13 @@ void wb_tbe_enc_fx( Word16 frac, exp1; Word16 uv_flag; Word16 dummy = 0; + move16(); Word16 avg_voice_fac; TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD; RF_ENC_HANDLE hRF = st_fx->hRF; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move16(); #endif /*Word16 att = 32767;*/ @@ -742,7 +767,7 @@ void wb_tbe_enc_fx( test(); test(); test(); - IF( ( NE_16( st_fx->last_extl, WB_TBE ) && NE_16( st_fx->last_extl, WB_BWE ) ) && ( EQ_16( st_fx->clas, UNVOICED_CLAS ) || ( LT_16( voicing_fx[0], 16384 ) && LT_16( voicing_fx[1], 16384 ) && LT_16( voicing_fx[2], 16384 ) ) ) && st_fx->igf == 0 ) + IF( ( NE_16( st_fx->last_extl, WB_TBE ) && NE_16( st_fx->last_extl, WB_BWE ) ) && ( st_fx->clas == UNVOICED_CLAS || ( LT_16( voicing_fx[0], 16384 ) && LT_16( voicing_fx[1], 16384 ) && LT_16( voicing_fx[2], 16384 ) ) ) && st_fx->igf == 0 ) { /* In case of unvoiced signals after switching cores, back-propagate the target signal */ Copy( hb_speech, hb_old_speech, WBTBE_LOOK_LSUFBR_5_OVER_16 ); @@ -958,6 +983,7 @@ void wb_tbe_enc_fx( } Q_bwe_exc = 31; + move16(); if ( Lmax != 0 ) { Q_bwe_exc = norm_l( Lmax ); @@ -967,7 +993,7 @@ void wb_tbe_enc_fx( find_max_mem_wb_enc( st_fx, &n_mem ); - if ( GT_16( sub( Q_bwe_exc, st_fx->prev_Q_bwe_exc ), n_mem ) ) + IF( GT_16( sub( Q_bwe_exc, st_fx->prev_Q_bwe_exc ), n_mem ) ) { Q_bwe_exc = add( st_fx->prev_Q_bwe_exc, n_mem ); } @@ -986,11 +1012,7 @@ void wb_tbe_enc_fx( IF( st_fx->element_mode > EVS_MONO ) { tmp = sub( shl( sub( st_fx->prev_Q_bwe_exc, 16 ), 1 ), 31 + 16 ); -#ifdef BASOP_NOGLOB prev_pow = L_shl_sat( 1407374848l /*0.00001f Q47*/, tmp ); /*Q(2*(st_fx->prev_Q_bwe_exc-16))*/ -#else - prev_pow = L_shl( 1407374848l /*0.00001f Q47*/, tmp ); /*Q(2*(st_fx->prev_Q_bwe_exc-16))*/ -#endif } FOR( i = 0; i < L_SHB_LAHEAD / 4; i++ ) { @@ -1004,6 +1026,7 @@ void wb_tbe_enc_fx( FOR( i = 0; i < L_FRAME32k; i++ ) { bwe_exc_extended_16[i + NL_BUFF_OFFSET] = round_fx( L_shl( bwe_exc_extended[i], sc ) ); + move16(); } Copy( bwe_exc_extended_16 + L_FRAME32k, hBWE_TD->old_bwe_exc_extended_fx, NL_BUFF_OFFSET ); @@ -1022,11 +1045,7 @@ void wb_tbe_enc_fx( IF( st_fx->element_mode > EVS_MONO ) { tmp = sub( shl( Q_bwe_exc_ext, 1 ), 31 + 16 ); -#ifdef BASOP_NOGLOB curr_pow = L_shl_sat( 1407374848l /*0.00001f Q47*/, tmp ); /*Q(2*(Q_bwe_exc_ext))*/ -#else - curr_pow = L_shl( 1407374848l /*0.00001f Q47*/, tmp ); /* 2*(Q_bwe_exc_ext) */ -#endif } FOR( i = 0; i < L_SHB_LAHEAD / 4; i++ ) { @@ -1043,18 +1062,15 @@ void wb_tbe_enc_fx( FOR( i = 0; i < L_SHB_LAHEAD / 4 - 1; i++ ) { - L_tmp = Mult_32_16( Lscale, shaped_wb_excitation[i] ); /* Q(16-exp+Q_bwe_exc_ext) */ -#ifdef BASOP_NOGLOB + L_tmp = Mult_32_16( Lscale, shaped_wb_excitation[i] ); /* Q(16-exp+Q_bwe_exc_ext) */ shaped_wb_excitation[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc_ext */ -#else - shaped_wb_excitation[i] = round_fx( L_shl( L_tmp, exp ) ); /* Q_bwe_exc_ext */ -#endif + move16(); } Lscale = root_a_fx( Lscale, 31 - exp, &exp ); L_tmp = Mult_32_16( Lscale, shaped_wb_excitation[L_SHB_LAHEAD / 4 - 1] ); /* Q(16-exp+Q_bwe_exc_ext) */ shaped_wb_excitation[L_SHB_LAHEAD / 4 - 1] = round_fx( L_shl( L_tmp, exp ) ); /* Q_bwe_exc_ext */ - + move16(); /* Update WB excitation */ Copy( shaped_wb_excitation + L_FRAME16k / 4, hBWE_TD->state_syn_shbexc_fx, L_SHB_LAHEAD / 4 ); @@ -1193,18 +1209,14 @@ void wb_tbe_enc_fx( exp = norm_s( voicingBufAvg_fx ); tmp = div_s( shl( 1, sub( 14, exp ) ), voicingBufAvg_fx ); /* (14-exp) */ L_tmp = L_mult( pitBufAvg_fx, tmp ); /* (21-exp) */ -#ifdef BASOP_NOGLOB L_tmp = L_shl_o( L_tmp, add( exp, 10 ), &Overflow ); tmp = round_fx_o( L_tmp, &Overflow ); /* Q15 */ -#else /* BASOP_NOGLOB */ - L_tmp = L_shl( L_tmp, add( exp, 10 ) ); - tmp = round_fx( L_tmp ); /* Q15 */ -#endif } tmp = s_max( s_min( tmp, 32767 ), 22938 ); /* Q15 */ GainFrame = Mult_32_16( GainFrame, tmp ); /* Q18 */ + test(); IF( LT_16( lsp_spacing_fx, 328 ) && lsp_spacing_fx ) { GainFrame = Mult_32_16( GainFrame, 21299 ); /* Q18 */ @@ -1243,6 +1255,7 @@ void wb_tbe_enc_fx( /* Adjust the subframe and frame gain of the synthesized SHB signal */ /* Scale the shaped excitation*/ + ScaleShapedSHB_fx( SHB_OVERLAP_LEN / 2, shaped_wb_excitation, hBWE_TD->syn_overlap_fx, GainShape, GainFrame, window_wb_fx, subwin_wb_fx, &Q_bwe_exc_ext, &dummy, dummy, dummy ); @@ -1298,19 +1311,19 @@ void wb_tbe_enc_ivas_fx( Word16 lpc_wb[LPC_SHB_ORDER_WB + 1]; Word32 lpc_wb_32_fx[LPC_SHB_ORDER_WB + 1]; Word16 lsp_wb[LPC_SHB_ORDER_WB], weights_lsp[LPC_SHB_ORDER_WB] = { 32767, 32767 }; + move16(); + move16(); Word16 *hb_new_speech, *hb_frame /*, hb_speech[ L_FRAME16k ]*/; Word16 R_h[LPC_SHB_ORDER_WB + 2], R_l[LPC_SHB_ORDER_WB + 2]; Word16 Q_R; Word32 LepsP[LPC_SHB_ORDER_WB + 1]; - move16(); - move16(); Word32 prev_pow, curr_pow, Lscale; /* Word16 scale; */ /*Word16 ramp_flag;*/ Word32 p2m_in, p2m_out; /*Word16 cnt, max =0;*/ - Word16 n_mem, Q_bwe_exc, Q_bwe_exc_ext, exp_out, Q_pow; /* Q_hb_frame; */ + Word16 n_mem, Q_bwe_exc, Q_bwe_exc_ext, exp_out, Q_cur_pow, Q_prev_pow; /* Q_hb_frame; */ Word32 L_tmp, Lmax; Word16 tmp, exp, Q_out, sc; Word16 Q_ns = -1; @@ -1329,12 +1342,12 @@ void wb_tbe_enc_ivas_fx( TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; - move32(); + move16(); #endif move16(); /*Word16 att = 32767;*/ - + set16_fx( bwe_exc_extended_16, 0, L_FRAME32k + NL_BUFF_OFFSET ); hb_new_speech = hb_old_speech + WBTBE_LOOK_LSUFBR_5_OVER_16; hb_frame = hb_old_speech + WBTBE_LSUBFR_5_OVER_16 + WBTBE_ANA_ALIGNDELAY; @@ -1348,7 +1361,7 @@ void wb_tbe_enc_ivas_fx( test(); test(); test(); - IF( ( NE_16( st_fx->last_extl, WB_TBE ) && NE_16( st_fx->last_extl, WB_BWE ) ) && ( EQ_16( st_fx->clas, UNVOICED_CLAS ) || ( LT_16( st_fx->voicing_fx[0], 16384 ) && LT_16( st_fx->voicing_fx[1], 16384 ) && LT_16( st_fx->voicing_fx[2], 16384 ) ) ) && !st_fx->igf ) + IF( ( NE_16( st_fx->last_extl, WB_TBE ) && NE_16( st_fx->last_extl, WB_BWE ) ) && ( st_fx->clas == UNVOICED_CLAS || ( LT_16( st_fx->voicing_fx[0], 16384 ) && LT_16( st_fx->voicing_fx[1], 16384 ) && LT_16( st_fx->voicing_fx[2], 16384 ) ) ) && !st_fx->igf ) { /* In case of unvoiced signals after switching cores, back-propagate the target signal */ Copy( hb_speech, hb_old_speech, WBTBE_LOOK_LSUFBR_5_OVER_16 ); @@ -1363,25 +1376,29 @@ void wb_tbe_enc_ivas_fx( L_tmp = L_mult( hb_old_speech[i], ola_win_shb_switch_fold_fx[j] ); hb_old_speech[i] = mac_ro( L_tmp, hb_speech[k], ola_win_shb_switch_fold_fx[L_SUBFR16k - 4 - j], &Overflow ); move16(); - i = sub( i, 1 ); - k = add( k, 1 ); + i--; + k++; } } - autocorr_fx( hb_old_speech, LPC_SHB_ORDER_WB + 1, R_h, R_l, &Q_R, ( ( NS2SA( INT_FS_12k8, 5000000L ) + L_SUBFR + L_FRAME ) * 5 / 16 ), win_lpc_hb_wb_fx, 0, 1 ); + autocorr_fx( hb_old_speech, LPC_SHB_ORDER_WB + 1, R_h, R_l, &Q_R, ( ( NS2SA( INT_FS_12k8, 5000000L ) + L_SUBFR + L_FRAME ) * 5 / 16 ), win_lpc_hb_wb_ivas_fx, 0, 1 ); - E_LPC_lev_dur( R_h, R_l, lpc_wb_temp_fx, LepsP, LPC_SHB_ORDER_WB, NULL ); + E_LPC_lev_dur( R_h, R_l, lpc_wb_temp_fx, LepsP, LPC_SHB_ORDER_WB, NULL ); // Since 0th index will be 1 in floating point buffer, in fixed point one has to take norm of 0th index to identify the Q-factor - Copy_Scale_sig( lpc_wb_temp_fx, lpc_wb_temp_fx, LPC_SHB_ORDER_WB + 1, sub( norm_s( lpc_wb_temp_fx[0] ), 2 ) ); + Copy_Scale_sig( lpc_wb_temp_fx, lpc_wb_temp_fx, LPC_SHB_ORDER_WB + 1, sub( norm_s( lpc_wb_temp_fx[0] ), 2 ) ); // Q12 /* convert into lsps and calculate weights */ FOR( i = 0; i <= LPC_SHB_ORDER_WB; i++ ) { - lpc_wb_32_fx[i] = L_negate( L_shr( L_deposit_h( lpc_wb_temp_fx[i] ), 1 ) ); + lpc_wb_32_fx[i] = L_negate( L_deposit_h( shr( lpc_wb_temp_fx[i], 1 ) ) ); // Q27 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++ ) { @@ -1570,7 +1587,7 @@ void wb_tbe_enc_ivas_fx( find_max_mem_wb_enc( st_fx, &n_mem ); - if ( GT_16( sub( Q_bwe_exc, st_fx->prev_Q_bwe_exc ), n_mem ) ) + IF( GT_16( sub( Q_bwe_exc, st_fx->prev_Q_bwe_exc ), n_mem ) ) { Q_bwe_exc = add( st_fx->prev_Q_bwe_exc, n_mem ); } @@ -1586,77 +1603,92 @@ void wb_tbe_enc_ivas_fx( prev_pow = 0; move32(); + Q_prev_pow = norm_arr( hBWE_TD->state_syn_shbexc_fx, L_SHB_LAHEAD / 4 ); + /* Compare with the guard bits needed in the subsequent operations. + * Guard bits for L_SHB_LAHEAD / 4 (expression evaluates to 5) is 3. + */ + IF( LT_16( Q_prev_pow, 3 ) ) + { + FOR( i = 0; i < L_SHB_LAHEAD / 4; i++ ) + { + shaped_wb_exc_scale[i] = shr( hBWE_TD->state_syn_shbexc_fx[i], 3 ); + move16(); + } + Q_prev_pow = shl_r( sub( sub( st_fx->prev_Q_bwe_exc, 16 ), 3 ), 1 ); + move16(); + } + ELSE + { + FOR( i = 0; i < L_SHB_LAHEAD / 4; i++ ) + { + shaped_wb_exc_scale[i] = hBWE_TD->state_syn_shbexc_fx[i]; + move16(); + } + Q_prev_pow = shl_r( sub( st_fx->prev_Q_bwe_exc, 16 ), 1 ); + move16(); + } + IF( st_fx->element_mode > EVS_MONO ) { - tmp = sub( shl( sub( st_fx->prev_Q_bwe_exc, 16 ), 1 ), 31 + 16 ); -#ifdef BASOP_NOGLOB - prev_pow = L_shl_sat( 1407374848l /*0.00001f Q47*/, tmp ); /*Q(2*(st_fx->prev_Q_bwe_exc-16))*/ -#else - prev_pow = L_shl( 1407374848l /*0.00001f Q47*/, tmp ); /*Q(2*(st_fx->prev_Q_bwe_exc-16))*/ -#endif + tmp = sub( Q_prev_pow, 31 + 16 ); + prev_pow = L_shl_sat( 1407374848l /*0.00001f Q47*/, tmp ); /*Q_prev_pow*/ } FOR( i = 0; i < L_SHB_LAHEAD / 4; i++ ) { - prev_pow = L_mac0( prev_pow, hBWE_TD->state_syn_shbexc_fx[i], hBWE_TD->state_syn_shbexc_fx[i] ); /* Q(2*st_fx->prev_Q_bwe_exc) */ + prev_pow = L_mac0( prev_pow, shaped_wb_exc_scale[i], shaped_wb_exc_scale[i] ); /* Q_prev_pow */ } rescale_genWB_mem_enc( st_fx, sub( Q_bwe_exc, st_fx->prev_Q_bwe_exc ) ); - Copy( hBWE_TD->old_bwe_exc_extended_fx, bwe_exc_extended_16, NL_BUFF_OFFSET ); sc = sub( Q_bwe_exc, add( Q_new, Q_new ) ); FOR( i = 0; i < L_FRAME32k; i++ ) { bwe_exc_extended_16[i + NL_BUFF_OFFSET] = round_fx( L_shl( bwe_exc_extended[i], sc ) ); move16(); } - Copy( bwe_exc_extended_16 + L_FRAME32k, hBWE_TD->old_bwe_exc_extended_fx, NL_BUFF_OFFSET ); Copy( hBWE_TD->state_syn_shbexc_fx, shaped_wb_excitation, L_SHB_LAHEAD / 4 ); Q_bwe_exc_ext = sub( Q_bwe_exc, 16 ); - GenShapedWBExcitation_fx( shaped_wb_excitation + L_SHB_LAHEAD / 4, lpc_wb, exc4kWhtnd, hBWE_TD->mem_csfilt_fx, - hBWE_TD->mem_genSHBexc_filt_down_shb_fx, hBWE_TD->mem_genSHBexc_filt_down_wb2_fx, hBWE_TD->mem_genSHBexc_filt_down_wb3_fx, - hBWE_TD->state_lpc_syn_fx, st_fx->coder_type, bwe_exc_extended_16, Q_bwe_exc_ext, hBWE_TD->bwe_seed, - vf_modified_fx, uv_flag, st_fx->igf ); + GenShapedWBExcitation_ivas_fx( shaped_wb_excitation + L_SHB_LAHEAD / 4, lpc_wb, exc4kWhtnd, hBWE_TD->mem_csfilt_fx, + hBWE_TD->mem_genSHBexc_filt_down_shb_fx, hBWE_TD->mem_genSHBexc_filt_down_wb2_fx, hBWE_TD->mem_genSHBexc_filt_down_wb3_fx, + hBWE_TD->state_lpc_syn_fx, st_fx->coder_type, bwe_exc_extended_16, Q_bwe_exc_ext, hBWE_TD->bwe_seed, + vf_modified_fx, uv_flag, st_fx->igf ); curr_pow = 0; move32(); - Q_pow = norm_arr( &shaped_wb_excitation[L_SHB_LAHEAD / 4], L_SHB_LAHEAD / 4 ); + Q_cur_pow = norm_arr( &shaped_wb_excitation[L_SHB_LAHEAD / 4], L_SHB_LAHEAD / 4 ); /* Compare with the guard bits needed in the subsequent operations. * Guard bits for L_SHB_LAHEAD / 4 (expression evaluates to 5) is 3. */ - IF( LT_16( Q_pow, 3 ) ) + IF( LT_16( Q_cur_pow, 3 ) ) { FOR( i = 0; i < L_SHB_LAHEAD / 4; i++ ) { - shaped_wb_exc_scale[i] = shr( shaped_wb_excitation[i], 3 ); + shaped_wb_exc_scale[i] = shr( shaped_wb_excitation[i + L_SHB_LAHEAD / 4], 3 ); move16(); } - Q_pow = shl_r( sub( Q_bwe_exc_ext, 3 ), 1 ); + Q_cur_pow = shl_r( sub( Q_bwe_exc_ext, 3 ), 1 ); move16(); } ELSE { FOR( i = 0; i < L_SHB_LAHEAD / 4; i++ ) { - shaped_wb_exc_scale[i] = shaped_wb_excitation[i]; + shaped_wb_exc_scale[i] = shaped_wb_excitation[i + L_SHB_LAHEAD / 4]; move16(); } - Q_pow = shl_r( Q_bwe_exc_ext, 1 ); + Q_cur_pow = shl_r( Q_bwe_exc_ext, 1 ); move16(); } IF( st_fx->element_mode > EVS_MONO ) { - tmp = sub( Q_pow, 31 + 16 ); -#ifdef BASOP_NOGLOB - curr_pow = L_shl_sat( 1407374848l /*0.00001f Q47*/, tmp ); /*Q(Q_pow)*/ -#else - curr_pow = L_shl( 1407374848l /*0.00001f Q47*/, tmp ); /* 2*(Q_bwe_exc_ext) */ -#endif + tmp = sub( Q_cur_pow, 31 + 16 ); + curr_pow = L_shl_sat( 1407374848l /*0.00001f Q47*/, tmp ); /*Q(Q_cur_pow)*/ } FOR( i = 0; i < L_SHB_LAHEAD / 4; i++ ) { - curr_pow = L_mac0( curr_pow, shaped_wb_exc_scale[i], shaped_wb_exc_scale[i] ); /* Q(Q_pow) */ + curr_pow = L_mac0( curr_pow, shaped_wb_exc_scale[i], shaped_wb_exc_scale[i] ); /* Q(Q_cur_pow) */ } IF( GT_16( voice_factors[0], 24576 ) ) @@ -1664,22 +1696,18 @@ void wb_tbe_enc_ivas_fx( curr_pow = L_shr( curr_pow, 2 ); /* Q(Q_pow) */ } - Lscale = root_a_over_b_fx( curr_pow, Q_pow, prev_pow, shl_r( sub( st_fx->prev_Q_bwe_exc, 16 ), 1 ), &exp ); + Lscale = root_a_over_b_fx( curr_pow, Q_cur_pow, prev_pow, Q_prev_pow, &exp ); FOR( i = 0; i < L_SHB_LAHEAD / 4 - 1; i++ ) { - L_tmp = Mpy_32_16_1( Lscale, shaped_wb_excitation[i] ); /* Q(16-exp+Q_bwe_exc_ext) */ -#ifdef BASOP_NOGLOB + L_tmp = Mpy_32_16_1( Lscale, shaped_wb_excitation[i] ); /* Q(16-exp+Q_bwe_exc_ext) */ shaped_wb_excitation[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc_ext */ -#else - shaped_wb_excitation[i] = round_fx( L_shl( L_tmp, exp ) ); /* Q_bwe_exc_ext */ -#endif move16(); } Lscale = root_a_fx( Lscale, sub( 31, exp ), &exp ); - L_tmp = Mpy_32_16_1( Lscale, shaped_wb_excitation[L_SHB_LAHEAD / 4 - 1] ); /* Q(16-exp+Q_bwe_exc_ext) */ - shaped_wb_excitation[L_SHB_LAHEAD / 4 - 1] = round_fx( L_shl( L_tmp, exp ) ); /* Q_bwe_exc_ext */ + L_tmp = Mpy_32_16_1( Lscale, shaped_wb_excitation[L_SHB_LAHEAD / 4 - 1] ); /* Q(16-exp+Q_bwe_exc_ext) */ + shaped_wb_excitation[L_SHB_LAHEAD / 4 - 1] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc_ext */ move16(); /* Update WB excitation */ @@ -1760,7 +1788,7 @@ void wb_tbe_enc_ivas_fx( move16(); } - hBWE_TD->prev_wb_GainShape = GainShape[sub( shr( NUM_SHB_SUBFR, 2 ), 1 )]; + hBWE_TD->prev_wb_GainShape = GainShape[( NUM_SHB_SUBFR >> 2 ) - 1]; move16(); /* Compute the power of gains away from the peak gain prior to quantization */ @@ -1800,8 +1828,8 @@ void wb_tbe_enc_ivas_fx( } /* Estimate the gain parameter */ - EstimateSHBFrameGain_fx( SHB_OVERLAP_LEN / 2, hb_frame, Q_ns, shaped_wb_excitation, Q_bwe_exc_ext, GainShape, - &GainFrame, window_wb_fx, subwin_wb_fx, 0 ); + EstimateSHBFrameGain_ivas_fx( SHB_OVERLAP_LEN / 2, hb_frame, Q_ns, shaped_wb_excitation, Q_bwe_exc_ext, GainShape, + &GainFrame, window_wb_fx, subwin_wb_fx, 0 ); /* If there's a big difference in the power of gains away from the peak gain */ @@ -1834,13 +1862,8 @@ void wb_tbe_enc_ivas_fx( exp = norm_s( voicingBufAvg_fx ); tmp = div_s( shl( 1, sub( 14, exp ) ), voicingBufAvg_fx ); /* (14-exp) */ L_tmp = L_mult( pitBufAvg_fx, tmp ); /* (21-exp) */ -#ifdef BASOP_NOGLOB L_tmp = L_shl_o( L_tmp, add( exp, 10 ), &Overflow ); tmp = round_fx_o( L_tmp, &Overflow ); /* Q15 */ -#else /* BASOP_NOGLOB */ - L_tmp = L_shl( L_tmp, add( exp, 10 ) ); - tmp = round_fx( L_tmp ); /* Q15 */ -#endif } tmp = s_max( s_min( tmp, 32767 ), 22938 ); /* Q15 */ @@ -1884,9 +1907,14 @@ void wb_tbe_enc_ivas_fx( /* Adjust the subframe and frame gain of the synthesized SHB signal */ /* Scale the shaped excitation*/ + + scale_sig( shaped_wb_excitation, ( L_FRAME16k + L_SHB_LAHEAD ) / 4, -1 ); + scale_sig( hBWE_TD->syn_overlap_fx, L_SHB_LAHEAD, -1 ); + Q_bwe_exc_ext = sub( Q_bwe_exc_ext, 1 ); ScaleShapedSHB_fx( SHB_OVERLAP_LEN / 2, shaped_wb_excitation, hBWE_TD->syn_overlap_fx, GainShape, GainFrame, window_wb_fx, subwin_wb_fx, &Q_bwe_exc_ext, &dummy, dummy, dummy ); + Scale_sig( hBWE_TD->syn_overlap_fx, L_SHB_LAHEAD, 1 ); st_fx->prev_Q_bwe_exc = Q_bwe_exc; move16(); @@ -1971,6 +1999,8 @@ void swb_tbe_enc_fx( Word32 LepsP[LPC_SHB_ORDER + 1]; Word16 ana_align_delay[2] = { -L_SHB_LAHEAD - ( NL_BUFF_OFFSET / 2 ), -L_SHB_LAHEAD - ( NL_BUFF_OFFSET / 2 ) }; + move16(); + move16(); Word32 prev_pow_fx, curr_pow_fx, Lscale; Word32 p2m_in_fx, p2m_out_fx; @@ -2016,6 +2046,7 @@ void swb_tbe_enc_fx( Word16 n_subfr_saturation; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move16(); #endif TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD; RF_ENC_HANDLE hRF = st_fx->hRF; @@ -2091,6 +2122,7 @@ void swb_tbe_enc_fx( FOR( i = 1; i <= LPC_SHB_ORDER; i++ ) { lpc_shb_fx[i] = mult_r( lpc_shb_fx[i], lpc_weights_fx[i] ); + move16(); } } @@ -2117,7 +2149,9 @@ void swb_tbe_enc_fx( /* to compensate for the 1.1* weighting done inside the function lsp_weights */ /*weights_lsp[3]*=0.909091f; weights_lsp[4]*=0.909091f; */ weights_lsp[3] = mult_r( weights_lsp[3], 29789 /*0.909091f Q15*/ ); + move16(); weights_lsp[4] = mult_r( weights_lsp[4], 29789 /*0.909091f Q15*/ ); + move16(); /* 8-bit VQ, 10 dimension */ i = closest_centroid_fx( lsf_shb_fx, weights_lsp, swb_tbe_lsfvq_cbook_8b, 256, LPC_SHB_ORDER ); @@ -2125,6 +2159,7 @@ void swb_tbe_enc_fx( set16_fx( hBWE_TD->lsf_idx, 0, NUM_Q_LSF ); hBWE_TD->lsf_idx[0] = i; + move16(); } ELSE { @@ -2187,10 +2222,12 @@ void swb_tbe_enc_fx( Copy( lsp_shb_2_fx, lsp_shb_1_fx, LPC_SHB_ORDER ); } - lsf_diff[0] = lsf_diff[sub( LPC_SHB_ORDER, 1 )] = 16384; /*Q15*/ + lsf_diff[0] = lsf_diff[LPC_SHB_ORDER - 1] = 16384; /*Q15*/ + move16(); FOR( i = 1; i < LPC_SHB_ORDER - 1; i++ ) { - lsf_diff[i] = sub( lsf_shb_fx[i], lsf_shb_fx[sub( i, 1 )] ); + lsf_diff[i] = sub( lsf_shb_fx[i], lsf_shb_fx[i - 1] ); + move16(); } a2rc_fx( hBWE_TD->cur_sub_Aq_fx + 1, refl, M ); @@ -2209,6 +2246,7 @@ void swb_tbe_enc_fx( FOR( i = 1; i < LPC_SHB_ORDER - 1; i++ ) { hBWE_TD->prev_lsf_diff_fx[i - 1] = mult( lsf_diff[i], 16384 ); /*Q15*/ + move16(); } } @@ -2230,6 +2268,7 @@ void swb_tbe_enc_fx( tmp = div_s( tmp, hBWE_TD->prev_lsf_diff_fx[i - 1] ); tmp = s_max( tmp, 16384 ); w[i] = s_min( tmp, 32767 ); + move16(); } ELSE { @@ -2237,16 +2276,20 @@ void swb_tbe_enc_fx( tmp = div_s( tmp, lsf_diff[i] ); tmp = s_max( tmp, 16384 ); w[i] = s_min( tmp, 32767 ); + move16(); } } w[0] = w[1]; - w[sub( LPC_SHB_ORDER, 1 )] = w[sub( LPC_SHB_ORDER, 2 )]; + move16(); + w[LPC_SHB_ORDER - 1] = w[LPC_SHB_ORDER - 2]; + move16(); FOR( i = 0; i < LPC_SHB_ORDER; i++ ) { tmp1 = mult( lsp_shb_1_fx[i], sub( 32767, w[i] ) ); tmp2 = mult( lsp_shb_2_fx[i], w[i] ); lsp_temp_fx[i] = add( tmp1, tmp2 ); + move16(); } } ELSE @@ -2257,6 +2300,7 @@ void swb_tbe_enc_fx( Copy( lsf_diff + 1, hBWE_TD->prev_lsf_diff_fx, LPC_SHB_ORDER - 2 ); hBWE_TD->prev_tilt_para_fx = tilt_para; + move16(); shb_ener_sf_Q31 = 0; move16(); @@ -2289,11 +2333,7 @@ void swb_tbe_enc_fx( FOR( i = L_SHB_LAHEAD; i < L_FRAME16k + L_SHB_LAHEAD; i++ ) { /* shbEner = shbEner + in[i] * in[i] */ -#ifdef BASOP_NOGLOB shb_ener_sf_Q31 = L_mac0_sat( shb_ener_sf_Q31, shb_frame_fx[i], shb_frame_fx[i] ); -#else - shb_ener_sf_Q31 = L_mac0( shb_ener_sf_Q31, shb_frame_fx[i], shb_frame_fx[i] ); -#endif /* o: shb_ener_sf_Q31 in (2*Q_shb) */ } shb_ener_sf_Q31 = Mult_32_16( shb_ener_sf_Q31, 102 /*0.003125f Q15*/ ); @@ -2313,6 +2353,7 @@ void swb_tbe_enc_fx( FOR( i = 0; i < NB_SUBFR16k; i++ ) { shb_res_gshape_fx_32[i] = sum2_fx( shb_res_fx + i * 64, 64 ); + move32(); } /* o: shb_res_gshape_fx_32 in (2*Q_shb+1) */ @@ -2330,14 +2371,17 @@ void swb_tbe_enc_fx( exp = norm_l( L_tmp ); tmp = extract_h( L_shl( L_tmp, exp ) ); recip = div_s( 16384, tmp ); - Q_recip = 31 - ( exp - 14 ); /* = 31-(exp+2*Q_shb+1-14), but adjusted by (2*Q_shb+1) for use at Mult_32_16 below */ + // Q_recip = 31 - ( exp - 14 ); /* = 31-(exp+2*Q_shb+1-14), but adjusted by (2*Q_shb+1) for use at Mult_32_16 below */ + Q_recip = sub( 31 + 14, exp ); /* = 31-(exp+2*Q_shb+1-14), but adjusted by (2*Q_shb+1) for use at Mult_32_16 below */ + move16(); } FOR( i = 0; i < NB_SUBFR16k; i++ ) { L_tmp1 = Mult_32_16( shb_res_gshape_fx_32[i], recip ); /*Q = Q_recip+1-16*/ - L_tmp = root_a_fx( L_tmp1, Q_recip + 1 - 16, &exp ); - shb_res_gshape_fx[i] = round_fx( L_shl( L_tmp, exp - 1 ) ); /* Q14 */ + L_tmp = root_a_fx( L_tmp1, add( Q_recip, 1 - 16 ), &exp ); + shb_res_gshape_fx[i] = round_fx( L_shl( L_tmp, sub( exp, 1 ) ) ); /* Q14 */ + move16(); } Quant_shb_res_gshape_fx( st_fx, shb_res_gshape_fx ); @@ -2361,6 +2405,7 @@ void swb_tbe_enc_fx( if ( Lmax == 0 ) { Q_bwe_exc = 31; + move16(); } Q_bwe_exc = add( Q_bwe_exc, add( Q_new, Q_new ) ); @@ -2371,6 +2416,7 @@ void swb_tbe_enc_fx( if ( GT_16( Q_bwe_exc, tmp2 ) ) { Q_bwe_exc = tmp2; + move16(); } /* rescale the memories if Q_bwe_exc is different from previous frame */ @@ -2386,11 +2432,8 @@ void swb_tbe_enc_fx( FOR( cnt = 0; cnt < L_FRAME32k; cnt++ ) { -#ifdef BASOP_NOGLOB bwe_exc_extended_16[cnt + NL_BUFF_OFFSET] = round_fx_sat( L_shl_sat( bwe_exc_extended[cnt], sc ) ); -#else - bwe_exc_extended_16[cnt + NL_BUFF_OFFSET] = round_fx( L_shl( bwe_exc_extended[cnt], sc ) ); -#endif + move16(); } Copy( bwe_exc_extended_16 + L_FRAME32k, hBWE_TD->old_bwe_exc_extended_fx, NL_BUFF_OFFSET ); @@ -2422,9 +2465,11 @@ void swb_tbe_enc_fx( &( hBWE_TD->fb_tbe_demph_fx ), &Q_bwe_exc, &Q_bwe_exc_fb, Q_shb, n_mem2, st_fx->prev_Q_bwe_syn, st_fx->total_brate, 0 ); *Q_white_exc = Q_bwe_exc_fb; + move16(); IF( EQ_16( st_fx->extl, FB_TBE ) ) { hBWE_TD->prev_Q_bwe_exc_fb = Q_bwe_exc_fb; + move16(); } ELSE { @@ -2451,6 +2496,7 @@ void swb_tbe_enc_fx( FOR( i = 0; i < LPC_SHB_ORDER; i++ ) { hBWE_TD->mem_stp_swb_fx[i] = shl( hBWE_TD->mem_stp_swb_fx[i], sub( Q_bwe_exc, st_fx->prev_Q_bwe_syn ) ); + move16(); } FOR( i = 0; i < L_FRAME16k; i += L_SUBFR16k ) @@ -2468,13 +2514,8 @@ void swb_tbe_enc_fx( curr_pow_fx = L_shl( 21475l /*0.00001f Q31*/, tmp ); /* 2*(Q_bwe_exc) */ FOR( i = 0; i < L_SHB_LAHEAD + 10; i++ ) { -#ifdef BASOP_NOGLOB prev_pow_fx = L_mac0_o( prev_pow_fx, shaped_shb_excitation_fx[i], shaped_shb_excitation_fx[i], &Overflow ); /* 2*Q_bwe_exc */ curr_pow_fx = L_mac0_o( curr_pow_fx, shaped_shb_excitation_fx[i + L_SHB_LAHEAD + 10], shaped_shb_excitation_fx[i + L_SHB_LAHEAD + 10], &Overflow ); /* 2*Q_bwe_exc */ -#else - prev_pow_fx = L_mac0( prev_pow_fx, shaped_shb_excitation_fx[i], shaped_shb_excitation_fx[i] ); /* 2*Q_bwe_exc */ - curr_pow_fx = L_mac0( curr_pow_fx, shaped_shb_excitation_fx[i + L_SHB_LAHEAD + 10], shaped_shb_excitation_fx[i + L_SHB_LAHEAD + 10] ); /* 2*Q_bwe_exc */ -#endif } if ( GT_16( voice_factors_fx[0], 24576 /*0.75f Q15*/ ) ) @@ -2490,35 +2531,25 @@ void swb_tbe_enc_fx( &exp ); FOR( i = 0; i < L_SHB_LAHEAD; i++ ) { - L_tmp = Mult_32_16( Lscale, shaped_shb_excitation_fx[i] ); /* Q(16-exp+Q_bwe_exc) */ -#ifdef BASOP_NOGLOB + L_tmp = Mult_32_16( Lscale, shaped_shb_excitation_fx[i] ); /* Q(16-exp+Q_bwe_exc) */ shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ -#else - shaped_shb_excitation_fx[i] = round_fx( L_shl( L_tmp, exp ) ); /* Q_bwe_exc */ -#endif + move16(); } IF( exp < 0 ) { Lscale = L_shl( Lscale, exp ); exp = 0; + move16(); } FOR( ; i < L_SHB_LAHEAD + 10; i++ ) { -#ifdef BASOP_NOGLOB 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 */ -#else - tmp = i_mult( sub( i, 19 ), 3277 /*0.1f Q15*/ ); /* Q15 */ - L_tmp1 = Mult_32_16( L_shl( 1, sub( 31, exp ) ), tmp ); /* Q31-exp */ -#endif 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 */ -#ifdef BASOP_NOGLOB + L_tmp = Mult_32_16( Lscale, 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 */ -#else - shaped_shb_excitation_fx[i] = round_fx( L_shl( L_tmp, exp ) ); /* Q_bwe_exc */ -#endif + move16(); } /* Update SHB excitation */ @@ -2539,6 +2570,7 @@ void swb_tbe_enc_fx( /* 0.35f +/- delta variation; delta = 0.1*(GS-0.35)*/ /* GainShape[i] = 0.315f + 0.1f * GainShape[i]; */ GainShape_fx[i] = mac_r( 676457349l /*0.315 Q31*/, 3277 /*0.1 Q15*/, GainShape_fx[i] ); + move16(); } } @@ -2627,10 +2659,12 @@ void swb_tbe_enc_fx( { temp_swb_fac = hBWE_TD->prev_swb_GainShape_fx; + move16(); FOR( i = 0; i < NUM_SHB_SUBGAINS; i++ ) { /*GainShape_fx[i] = (1 - feedback) * GainShape[i] + feedback * temp_swb_fac; */ GainShape_fx[i] = round_fx( L_mac( L_mult( sub( 32767, feedback ), GainShape_fx[i] ), feedback, temp_swb_fac ) ); + move16(); temp_swb_fac = GainShape_fx[i]; move16(); } @@ -2670,6 +2704,7 @@ void swb_tbe_enc_fx( GainFrame_fx = L_add( L_shr( hBWE_TD->prev_gainFr_SHB_fx, 1 ), L_shr( GainFrame_fx, 1 ) ); /* Q18 */ } + test(); test(); IF( EQ_16( frGainAttenuate, 1 ) && LE_16( MA_lsp_shb_spacing, 79 /*0.0024f Q15*/ ) ) { @@ -2680,7 +2715,7 @@ void swb_tbe_enc_fx( frac = L_Extract_lc( L_tmp, &exp ); GainFrame_fx = Pow2( 30, frac ); exp = sub( exp, 30 ); - GainFrame_fx = L_shl( GainFrame_fx, exp + 18 ); /* Q18 */ + GainFrame_fx = L_shl( GainFrame_fx, add( exp, 18 ) ); /* Q18 */ } ELSE IF( EQ_16( hBWE_TD->prev_frGainAtten, 1 ) && GT_32( Mult_32_16( GainFrame_fx, 10923 ), hBWE_TD->prev_gainFr_SHB_fx ) ) { @@ -2720,9 +2755,11 @@ void swb_tbe_enc_fx( /* voicingBufAvg = (sum_f(voice_factors, 4)=sum2 > 0.6f) ? 0.333f : 0.1667f; */ tmp2 = 5462 /*0.1667f Q15*/; + move16(); if ( GT_16( sum2, 4915 /*0.6f Q13*/ ) ) { tmp2 = 10912 /*0.333f Q15*/; /* Q15 */ + move16(); } voicingBufAvg_fx = shl( mult( tmp2, sum1 ), 2 ); /* Q15 */ @@ -2739,13 +2776,9 @@ void swb_tbe_enc_fx( tmp = div_s( shl( 1, sub( 14, exp ) ), voicingBufAvg_fx ); /* (14-exp) */ /* sd_uq_q*pitBufAvg */ - L_tmp = Mult_32_16( L_tmp, pitBufAvg_fx ); /* Q13 * Q10 + 1 -16 => Q8 */ - L_tmp = Mult_32_16( L_tmp, tmp ); /* Q8 + (14 - exp) - 15 => Q7 - exp */ -#ifdef BASOP_NOGLOB + L_tmp = Mult_32_16( L_tmp, pitBufAvg_fx ); /* Q13 * Q10 + 1 -16 => Q8 */ + L_tmp = Mult_32_16( L_tmp, tmp ); /* Q8 + (14 - exp) - 15 => Q7 - exp */ tmp = round_fx_o( L_shl_o( L_tmp, 31 - ( 7 - exp ), &Overflow ), &Overflow ); /* Q15 */ -#else - tmp = round_fx( L_shl( L_tmp, 31 - ( 7 - exp ) ) ); /* Q15 */ -#endif } tmp = s_min( tmp, 32767 /*1.0f Q15*/ ); @@ -2770,16 +2803,19 @@ void swb_tbe_enc_fx( if ( GainFrame_fx == 0 ) { tmp = 31; + move16(); } L_tmp = L_shl( GainFrame_fx, tmp ); /* 18 + tmp */ tmp1 = 0; + move16(); FOR( i = 0; i < L_FRAME16k; i++ ) { L_tmp1 = Mult_32_16( L_tmp, GainShape_fx[NUM_SHB_SUBFR * i / L_FRAME16k] ); /* Q : 18 + tmp +15 -15*/ /*White_exc16k_fx[i] = round_fx( L_shl(Mult_32_16( L_tmp1, White_exc16k_fx[i]),(23 - tmp -*Q_white_exc)) );*/ /*18 + tmp +*Q_white_exc -15 + 23 - tmp -*Q_white_exc -16 = 10*/ White_exc16k_fx[i] = round_fx( Mult_32_16( L_tmp1, White_exc16k_fx[i] ) ); /* 18 + tmp +*Q_white_exc -15 -16 */ + move16(); /*Lmax = L_max(Lmax,White_exc16k_fx[i]);*/ tmp1 = s_max( tmp1, abs_s( White_exc16k_fx[i] ) ); /*White_exc16k_fx[i] =32767;*/ @@ -2790,6 +2826,7 @@ void swb_tbe_enc_fx( if ( tmp1 == 0 ) { tmp = 15; + move16(); } FOR( i = 0; i < L_FRAME16k; i++ ) @@ -2903,7 +2940,7 @@ void swb_tbe_enc_ivas_fx( Word16 formant_fac_fx; // int16_t stab_check = 1; Word16 MSFlag; - Word16 *nlExc16k_fx, *mixExc16k_fx; + Word16 *nlExc16k_fx, *nlExc16k_e, *mixExc16k_fx, *mixExc16k_e; Word16 shaped_shb_excitationTemp_fx[L_FRAME16k]; @@ -2911,6 +2948,9 @@ void swb_tbe_enc_ivas_fx( Word16 acorr_EnvSHBres[ENVSHBRES_ACORR_MAX - ENVSHBRES_ACORR_MIN], *p_acorr, shb_env_tilt_fx; Word16 buf_EnvSHBres_fx[2 * L_FRAME4k], *p_buf, EnvSHBres_fx[L_FRAME16k], EnvSHBres_4k_fx[L_FRAME4k], EnvSHBres_4k_norm_fx[L_FRAME4k], env_mean_normf_fx[L_FRAME4k]; + Word32 tmp_buf[L_FRAME4k]; + Word16 Q_EnvSHBres_4k_norm = Q31; + move16(); Word16 GainShape_Interp_fx[NUM_SHB_SUBGAINS], GainShape_tilt_fx; /* Q15 */ Word16 seg_mean[4], den_seg_mean[4], *p_env, step; Word16 temp, scale_fx, scale_e, pow_e, tmp_e, tmp1_e; @@ -2928,7 +2968,7 @@ void swb_tbe_enc_ivas_fx( Word16 n_subfr_saturation; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; - move32(); + move16(); #endif Env_error_fx = 0; @@ -2953,17 +2993,22 @@ void swb_tbe_enc_ivas_fx( exp1 = 0; /* to avoid compilation warnings */ move16(); + test(); IF( st_fx->element_mode >= IVAS_CPE_DFT && hStereoICBWE != NULL ) { nlExc16k_fx = hStereoICBWE->nlExc16k_fx; + nlExc16k_e = &hStereoICBWE->nlExc16k_e; mixExc16k_fx = hStereoICBWE->mixExc16k_fx; + mixExc16k_e = &hStereoICBWE->mixExc16k_e; MSFlag = hStereoICBWE->MSFlag; move16(); } ELSE { nlExc16k_fx = NULL; + nlExc16k_e = NULL; mixExc16k_fx = NULL; + mixExc16k_e = NULL; MSFlag = 0; move16(); } @@ -3103,7 +3148,7 @@ void swb_tbe_enc_ivas_fx( test(); IF( st_fx->rf_mode || EQ_32( st_fx->extl_brate, SWB_TBE_0k95 ) || EQ_32( st_fx->extl_brate, SWB_TBE_1k10 ) ) { - lsp_weights_fx( lsf_shb_fx, weights_lsp, LPC_SHB_ORDER, &Q_out ); + lsp_weights_ivas_fx( lsf_shb_fx, weights_lsp, LPC_SHB_ORDER, &Q_out ); /* to compensate for the 1.1* weighting done inside the function lsp_weights */ /*weights_lsp[3]*=0.909091f; weights_lsp[4]*=0.909091f; */ @@ -3248,7 +3293,7 @@ void swb_tbe_enc_ivas_fx( } w_fx[0] = w_fx[1]; move16(); - w_fx[sub( LPC_SHB_ORDER, 1 )] = w_fx[sub( LPC_SHB_ORDER, 2 )]; + w_fx[LPC_SHB_ORDER - 1] = w_fx[LPC_SHB_ORDER - 2]; move16(); FOR( i = 0; i < LPC_SHB_ORDER; i++ ) @@ -3300,11 +3345,7 @@ void swb_tbe_enc_ivas_fx( FOR( i = L_SHB_LAHEAD; i < L_FRAME16k + L_SHB_LAHEAD; i++ ) { /* shbEner = shbEner + in[i] * in[i] */ -#ifdef BASOP_NOGLOB shb_ener_sf_Q31 = L_mac0_sat( shb_ener_sf_Q31, shb_frame_fx[i], shb_frame_fx[i] ); -#else - shb_ener_sf_Q31 = L_mac0( shb_ener_sf_Q31, shb_frame_fx[i], shb_frame_fx[i] ); -#endif /* o: shb_ener_sf_Q31 in (2*Q_shb) */ } shb_ener_sf_Q31 = Mult_32_16( shb_ener_sf_Q31, 102 /*0.003125f Q15*/ ); @@ -3344,7 +3385,8 @@ void swb_tbe_enc_ivas_fx( exp = norm_l( L_tmp ); tmp = extract_h( L_shl( L_tmp, exp ) ); recip = div_s( 16384, tmp ); - Q_recip = sub( 31, sub( exp, 14 ) ); /* = 31-(exp+2*Q_shb+1-14), but adjusted by (2*Q_shb+1) for use at Mult_32_16 below */ + // Q_recip = sub( 31, sub( exp, 14 ) ); /* = 31-(exp+2*Q_shb+1-14), but adjusted by (2*Q_shb+1) for use at Mult_32_16 below */ + Q_recip = sub( 31 + 14, exp ); /* = 31-(exp+2*Q_shb+1-14), but adjusted by (2*Q_shb+1) for use at Mult_32_16 below */ } FOR( i = 0; i < NB_SUBFR16k; i++ ) @@ -3403,6 +3445,7 @@ void swb_tbe_enc_ivas_fx( FOR( k = 0; k < L_FRAME4k; k++ ) { EnvSHBres_4k_fx[k] = EnvSHBres_fx[4 * k]; /* Q_shb */ + move16(); } /* calculate long-term mean envelope over four consecutive segments using linear interpolation */ @@ -3449,7 +3492,7 @@ void swb_tbe_enc_ivas_fx( FOR( k = 1; k < 4; k++ ) { // step = ( den_seg_mean[k] - den_seg_mean[k - 1] ) * den_seg_len; - step = mult( den_seg_mean[k] - den_seg_mean[k - 1], den_seg_len ); + step = mult( sub( den_seg_mean[k], den_seg_mean[k - 1] ), den_seg_len ); FOR( i = 0; i < seg_len; i++ ) { *p_env = add_sat( *( p_env - 1 ), step ); @@ -3467,7 +3510,13 @@ void swb_tbe_enc_ivas_fx( /* normalize residual SHB envelope with its long-term mean envelope */ FOR( k = 0; k < L_FRAME4k; k++ ) { - EnvSHBres_4k_norm_fx[k] = mult( EnvSHBres_4k_fx[k], env_mean_normf_fx[k] ); + tmp_buf[k] = L_mult( EnvSHBres_4k_fx[k], env_mean_normf_fx[k] ); // Q_shb + Q15 + Q1 => Q_shb + Q16 + move32(); + } + Q_EnvSHBres_4k_norm = sub( getScaleFactor32( tmp_buf, L_FRAME4k ), 1 /* Guard bit */ ); + FOR( k = 0; k < L_FRAME4k; k++ ) + { + EnvSHBres_4k_norm_fx[k] = extract_h( L_shl( tmp_buf[k], Q_EnvSHBres_4k_norm ) ); // Q_shb + Q16 + Q_EnvSHBres_4k_norm - Q16 => Q_EnvSHBres_4k_norm + Q_shb move16(); } @@ -3479,15 +3528,16 @@ void swb_tbe_enc_ivas_fx( /* subtract mean value from the normalized SHB residual envelope */ p_buf = &buf_EnvSHBres_fx[L_FRAME4k]; - temp = mean_no_sat_fx( EnvSHBres_4k_norm_fx, L_FRAME4k ); + temp = mean_no_sat_fx( EnvSHBres_4k_norm_fx, L_FRAME4k ); // Q_EnvSHBres_4k_norm + Q_shb FOR( k = 0; k < L_FRAME4k; k++ ) { - *p_buf++ = sub( EnvSHBres_4k_norm_fx[k], temp ); + *p_buf++ = shr( sub( EnvSHBres_4k_norm_fx[k], temp ), Q_EnvSHBres_4k_norm ); // Q_shb move16(); } + Q_EnvSHBres_4k_norm = add( Q_EnvSHBres_4k_norm, Q_shb ); /* update memory */ - Copy( &buf_EnvSHBres_fx[L_FRAME4k], hBWE_TD->old_EnvSHBres_fx, L_FRAME4k ); + Copy( &buf_EnvSHBres_fx[L_FRAME4k], hBWE_TD->old_EnvSHBres_fx, L_FRAME4k ); // Q_shb /* calculate energy normalization factor for the auto-correlation function */ // pow0 = sum2_f( &buf_EnvSHBres[L_FRAME4k], L_FRAME4k ) + 1.0f; @@ -3637,13 +3687,9 @@ void swb_tbe_enc_ivas_fx( sc = sub( Q_bwe_exc, add( Q_new, Q_new ) ); /* rescale the bwe_exc_extended and bring it to 16-bit single precision with dynamic norm */ - FOR( cnt = 0; cnt < L_FRAME32k; cnt++ ) + FOR( cnt = 0; cnt < L_FRAME32k + NL_BUFF_OFFSET; cnt++ ) { -#ifdef BASOP_NOGLOB bwe_exc_extended_16[cnt] = round_fx_sat( L_shl_sat( bwe_exc_extended[cnt], sc ) ); -#else - bwe_exc_extended_16[cnt] = round_fx( L_shl( bwe_exc_extended[cnt], sc ) ); -#endif move16(); } @@ -3660,14 +3706,13 @@ void swb_tbe_enc_ivas_fx( Q_bwe_exc_fb = hBWE_TD->prev_Q_bwe_exc_fb; move16(); - // Replace with IVAS equivalent GenShapedSHBExcitation_ivas_enc_fx( shaped_shb_excitation_fx + L_SHB_LAHEAD, lpc_shb_fx, White_exc16k_fx, hBWE_TD->mem_csfilt_fx, hBWE_TD->mem_genSHBexc_filt_down_shb_fx, hBWE_TD->state_lpc_syn_fx, st_fx->coder_type, bwe_exc_extended_16, hBWE_TD->bwe_seed, vf_modified_fx, st_fx->extl, &( hBWE_TD->tbe_demph_fx ), &( hBWE_TD->tbe_premph_fx ), lpc_shb_sf_fx, shb_ener_sf_Q31, shb_res_gshape_fx, shb_res_fx, &vf_ind_fx, formant_fac_fx, hBWE_TD->fb_state_lpc_syn_fx, - &( hBWE_TD->fb_tbe_demph_fx ), &Q_bwe_exc, &Q_bwe_exc_fb, Q_shb, n_mem2, st_fx->prev_Q_bwe_syn, st_fx->total_brate, 0, st_fx->element_mode, st_fx->flag_ACELP16k, nlExc16k_fx, mixExc16k_fx, st_fx->extl_brate, MSFlag, - EnvSHBres_4k_norm_fx, &( hBWE_TD->prev_pow_exc16kWhtnd_fx32 ), &( hBWE_TD->prev_mix_factor_fx ), &Env_error_fx, Env_error_part_fx ); + &( hBWE_TD->fb_tbe_demph_fx ), &Q_bwe_exc, &Q_bwe_exc_fb, Q_shb, n_mem2, st_fx->prev_Q_bwe_syn, st_fx->total_brate, 0, st_fx->element_mode, st_fx->flag_ACELP16k, nlExc16k_fx, nlExc16k_e, mixExc16k_fx, mixExc16k_e, st_fx->extl_brate, MSFlag, + EnvSHBres_4k_norm_fx, Q_EnvSHBres_4k_norm, &( hBWE_TD->prev_pow_exc16kWhtnd_fx32 ), &( hBWE_TD->prev_mix_factor_fx ), &Env_error_fx, Env_error_part_fx ); *Q_white_exc = Q_bwe_exc_fb; move16(); @@ -3697,6 +3742,7 @@ void swb_tbe_enc_ivas_fx( { Copy( shaped_shb_excitation_fx + L_SHB_LAHEAD, hStereoICBWE->shbSynthRef_fx, L_FRAME16k ); hStereoICBWE->shbSynthRef_e = sub( 15, Q_bwe_exc ); + move16(); } test(); @@ -3760,7 +3806,7 @@ void swb_tbe_enc_ivas_fx( curr_pow_64fx = W_mac0_16_16( curr_pow_64fx, shaped_shb_excitation_fx[i + L_SHB_LAHEAD + 10], shaped_shb_excitation_fx[i + L_SHB_LAHEAD + 10] ); /* 2*Q_bwe_exc */ } - if ( GT_16( voice_factors_fx[0], 24576 /*0.75f Q15*/ ) ) + IF( GT_16( voice_factors_fx[0], 24576 /*0.75f Q15*/ ) ) { /*curr_pow_fx = Mult_32_16( curr_pow_fx, 8192);*/ /* Q(2*Q_bwe_exc) */ curr_pow_64fx = W_shr( curr_pow_64fx, 2 ); /* scale by 0.25 */ @@ -3780,12 +3826,8 @@ void swb_tbe_enc_ivas_fx( FOR( i = 0; i < L_SHB_LAHEAD; i++ ) { - L_tmp = Mult_32_16( Lscale, shaped_shb_excitation_fx[i] ); /* Q(16-exp+Q_bwe_exc) */ -#ifdef BASOP_NOGLOB + L_tmp = Mult_32_16( Lscale, shaped_shb_excitation_fx[i] ); /* Q(16-exp+Q_bwe_exc) */ shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ -#else - shaped_shb_excitation_fx[i] = round_fx( L_shl( L_tmp, exp ) ); /* Q_bwe_exc */ -#endif move16(); } IF( exp < 0 ) @@ -3796,21 +3838,12 @@ void swb_tbe_enc_ivas_fx( } FOR( ; i < L_SHB_LAHEAD + 10; i++ ) { -#ifdef BASOP_NOGLOB 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 */ -#else - tmp = i_mult( sub( i, 19 ), 3277 /*0.1f Q15*/ ); /* Q15 */ - L_tmp1 = Mult_32_16( L_shl( 1, sub( 31, exp ) ), tmp ); /* Q31-exp */ -#endif 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 */ -#ifdef BASOP_NOGLOB + L_tmp = Mult_32_16( Lscale, 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 */ -#else - shaped_shb_excitation_fx[i] = round_fx( L_shl( L_tmp, exp ) ); /* Q_bwe_exc */ -#endif move16(); } } @@ -3885,47 +3918,48 @@ void swb_tbe_enc_ivas_fx( /* Gain frame adjustment factor */ /* log( (GainShape[0]) / (st->prev_wb_GainShape) )*/ - test(); - IF( GainShape_fx[0] && hBWE_TD->prev_swb_GainShape_fx ) + IF( hBWE_TD->prev_swb_GainShape_fx == 0 ) { - exp = norm_s( hBWE_TD->prev_swb_GainShape_fx ); - tmp = div_s( shl( 1, sub( 14, exp ) ), hBWE_TD->prev_swb_GainShape_fx ); - L_tmp = L_mult( GainShape_fx[0], tmp ); /*Q(30 - exp) */ - - exp1 = norm_l( L_tmp ); - frac = Log2_norm_lc( L_shl( L_tmp, exp1 ) ); /*move16(); */ - exp1 = sub( exp, exp1 ); /*move16(); */ - L_tmp = Mpy_32_16( exp1, frac, 22713 ); - temp_swb_fac = round_fx( L_shl( L_tmp, 10 ) ); + exp = 13 /* norm_s(3) */; + tmp = 21845 /* div_s( shl(1, sub(14, exp)), 3 /\* 0.0001 in Q15 *\/ ) */; } ELSE { - temp_swb_fac = 0; - move16(); + exp = norm_s( hBWE_TD->prev_swb_GainShape_fx ); + tmp = div_s( shl( 1, sub( 14, exp ) ), hBWE_TD->prev_swb_GainShape_fx ); } - L_feedback = L_mult0( temp_swb_fac, temp_swb_fac ); + + L_tmp = L_mult( GainShape_fx[0], tmp ); /*Q(30 - exp) */ + + exp1 = norm_l( L_tmp ); + frac = Log2_norm_lc( L_shl( L_tmp, exp1 ) ); /*move16(); */ + exp1 = sub( exp, exp1 ); /*move16(); */ + L_tmp = Mpy_32_16( exp1, frac, 22713 ); + temp_swb_fac = round_fx( L_shl( L_tmp, 10 ) ); + + L_feedback = L_mult( temp_swb_fac, temp_swb_fac ); FOR( i = 1; i < NUM_SHB_SUBGAINS; i++ ) { test(); - IF( GainShape_fx[i] && GainShape_fx[i - 1] ) + IF( GainShape_fx[i - 1] == 0 ) { - exp = norm_s( GainShape_fx[i - 1] ); - tmp = div_s( shl( 1, sub( 14, exp ) ), GainShape_fx[i - 1] ); - L_tmp = L_mult( GainShape_fx[i], tmp ); /* Q(30 - exp) */ - - exp1 = norm_l( L_tmp ); - frac = Log2_norm_lc( L_shl( L_tmp, exp1 ) ); - exp1 = sub( exp, exp1 ); - L_tmp = Mpy_32_16( exp1, frac, 22713 ); - temp_swb_fac = round_fx( L_shl( L_tmp, 10 ) ); + exp = 13 /* norm_s(3) */; + tmp = 21845 /* div_s( shl(1, sub(14, exp)), 3 /\* 0.0001 in Q15 *\/ ) */; } ELSE { - temp_swb_fac = 0; - move16(); + exp = norm_s( GainShape_fx[i - 1] ); + tmp = div_s( shl( 1, sub( 14, exp ) ), GainShape_fx[i - 1] ); } + L_tmp = L_mult( GainShape_fx[i], tmp ); /* Q(30 - exp) */ + + exp1 = norm_l( L_tmp ); + frac = Log2_norm_lc( L_shl( L_tmp, exp1 ) ); + exp1 = sub( exp, exp1 ); + L_tmp = Mpy_32_16( exp1, frac, 22713 ); + temp_swb_fac = round_fx( L_shl( L_tmp, 10 ) ); L_feedback = L_mac( L_feedback, temp_swb_fac, temp_swb_fac ); } @@ -3951,6 +3985,7 @@ void swb_tbe_enc_ivas_fx( Copy( GainShape_fx, GainShape_Interp_fx, NUM_SHB_SUBGAINS ); lls_interp_n_fx( GainShape_Interp_fx, NUM_SHB_SUBGAINS, &GainShape_tilt_fx, &temp, 1 ); + test(); IF( EQ_32( st_fx->extl_brate, SWB_TBE_1k10 ) || EQ_32( st_fx->extl_brate, SWB_TBE_1k75 ) ) { // if (acorr_v2a < 0.4f && vf_ind >= 5 && fabs(GainShape_tilt) < 0.2f && shb_env_tilt < 500.0f && hBWE_TD->prev_shb_env_tilt < 500.0f) @@ -4002,6 +4037,7 @@ void swb_tbe_enc_ivas_fx( { /*GainShape_fx[i] = (1 - feedback) * GainShape[i] + feedback * temp_swb_fac; */ GainShape_fx[i] = round_fx( L_mac( L_mult( sub( 32767, feedback ), GainShape_fx[i] ), feedback, temp_swb_fac ) ); + move16(); temp_swb_fac = GainShape_fx[i]; move16(); } @@ -4013,7 +4049,9 @@ void swb_tbe_enc_ivas_fx( { /* Re-normalize gain shape before quantization */ // sum_gain = sum2_f(GainShape, NUM_SHB_SUBGAINS); - sum_gain_fx = sum16_32_fx( GainShape_fx, NUM_SHB_SUBGAINS ); + tmp = 0; + move16(); + sum_gain_fx = sum2_16_exp_fx( GainShape_fx, NUM_SHB_SUBGAINS, &tmp, 2 ); IF( sum_gain_fx == 0 ) { normFact_fx = 0; @@ -4022,8 +4060,6 @@ void swb_tbe_enc_ivas_fx( ELSE { // normFact = (float) sqrt( 1.0f / sum_gain ); - tmp = Q16; - move16(); normFact_fx = ISqrt32( sum_gain_fx, &tmp ); } @@ -4097,8 +4133,8 @@ void swb_tbe_enc_ivas_fx( } /* Estimate the gain parameter */ - EstimateSHBFrameGain_fx( SHB_OVERLAP_LEN, shb_frame_fx, Q_shb, shaped_shb_excitation_fx, Q_bwe_exc, - GainShape_fx, &GainFrame_fx, window_shb_fx, subwin_shb_fx, n_subfr_saturation ); + EstimateSHBFrameGain_ivas_fx( SHB_OVERLAP_LEN, shb_frame_fx, Q_shb, shaped_shb_excitation_fx, Q_bwe_exc, + GainShape_fx, &GainFrame_fx, window_shb_fx, subwin_shb_fx, n_subfr_saturation ); IF( EQ_16( st_fx->tec_tfa, 1 ) ) { @@ -4190,7 +4226,7 @@ void swb_tbe_enc_ivas_fx( frac = L_Extract_lc( L_tmp, &exp ); GainFrame_fx = Pow2( 30, frac ); exp = sub( exp, 30 ); - GainFrame_fx = L_shl( GainFrame_fx, exp + 18 ); /* Q18 */ + GainFrame_fx = L_shl( GainFrame_fx, add( exp, 18 ) ); /* Q18 */ } ELSE IF( EQ_16( hBWE_TD->prev_frGainAtten, 1 ) && GT_32( Mult_32_16( GainFrame_fx, 10923 ), hBWE_TD->prev_gainFr_SHB_fx ) ) { @@ -4313,13 +4349,9 @@ void swb_tbe_enc_ivas_fx( tmp = div_s( shl( 1, sub( 14, exp ) ), voicingBufAvg_fx ); /* (14-exp) */ /* sd_uq_q*pitBufAvg */ - L_tmp = Mult_32_16( L_tmp, pitBufAvg_fx ); /* Q13 * Q10 + 1 -16 => Q8 */ - L_tmp = Mult_32_16( L_tmp, tmp ); /* Q8 + (14 - exp) - 15 => Q7 - exp */ -#ifdef BASOP_NOGLOB + L_tmp = Mult_32_16( L_tmp, pitBufAvg_fx ); /* Q13 * Q10 + 1 -16 => Q8 */ + L_tmp = Mult_32_16( L_tmp, tmp ); /* Q8 + (14 - exp) - 15 => Q7 - exp */ tmp = round_fx_o( L_shl_o( L_tmp, 31 - ( 7 - exp ), &Overflow ), &Overflow ); /* Q15 */ -#else - tmp = round_fx( L_shl( L_tmp, 31 - ( 7 - exp ) ) ); /* Q15 */ -#endif } tmp = s_min( tmp, 32767 /*1.0f Q15*/ ); tmp = s_max( tmp, 19661 /*0.6f Q15*/ ); @@ -4366,7 +4398,7 @@ void swb_tbe_enc_ivas_fx( IF( GE_16( st_fx->element_mode, IVAS_CPE_DFT ) && hStereoICBWE != NULL ) { // Check Qs - Copy_Scale_sig_16_32( lpc_shb_fx, hStereoICBWE->lpSHBRef_fx, LPC_SHB_ORDER + 1, 0 ); + Copy_Scale_sig_16_32_DEPREC( lpc_shb_fx, hStereoICBWE->lpSHBRef_fx, LPC_SHB_ORDER + 1, 0 ); hStereoICBWE->lpSHBRef_e = 31 - Q12; move16(); } @@ -4450,7 +4482,6 @@ void swb_tbe_enc_ivas_fx( /* RETURN ARGUMENTS : */ /* _ None */ /*--------------------------------------------------------------------------*/ - static void EstimateSHBFrameGain_fx( const Word16 length, /* i : SHB overlap length */ const Word16 *oriSHB, /* i : target original SHB frame Q(Q_oriSHB) */ @@ -4477,7 +4508,7 @@ static void EstimateSHBFrameGain_fx( Word16 scaling = 0; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; - move32(); + move16(); #endif move16(); @@ -4548,7 +4579,7 @@ static void EstimateSHBFrameGain_fx( sum_gain = mult_r( subwin_shb_local[k + 1], subgain[0] ); /* Q15 */ mod_syn[j] = L_mult( synSHB[j], sum_gain ); move32(); /* Q(16+Q_synSHB) */ - j = add( j, 1 ); + j++; } FOR( i = 0; i < NUM_SHB_SUBGAINS - 1; i++ ) { @@ -4556,7 +4587,7 @@ static void EstimateSHBFrameGain_fx( { mod_syn[j] = L_mult( synSHB[j], subgain[i * num_join] ); move32(); /* Q(16+Q_synSHB) */ - j = add( j, 1 ); + j++; } FOR( k = 0; k < length; k++ ) @@ -4565,21 +4596,21 @@ static void EstimateSHBFrameGain_fx( tmp = round_fx( L_mac0( L_tmp, subwin_shb_local[k + 1], subgain[( i + 1 ) * num_join] ) ); /* Q14 */ mod_syn[j] = L_shl( L_mult( tmp, synSHB[j] ), 1 ); move32(); /* Q(16+Q_synSHB) */ - j = add( j, 1 ); + j++; } } FOR( k = 0; k < join_length - length; k++ ) { mod_syn[j] = L_mult( synSHB[j], subgain[( NUM_SHB_SUBGAINS - 1 ) * num_join] ); move32(); /* Q(16+Q_synSHB)*/ - j = add( j, 1 ); + j++; } FOR( k = 0; k < length; k++ ) { tmp = mult_r( subwin_shb_local[length - k - 1], subgain[( NUM_SHB_SUBGAINS - 1 ) * num_join] ); /* Q15 */ mod_syn[j] = L_mult( tmp, synSHB[j] ); move32(); /* Q(16+Q_synSHB ) */ - j = add( j, 1 ); + j++; } } /* adjust frame energy */ @@ -4588,48 +4619,27 @@ static void EstimateSHBFrameGain_fx( FOR( i = 0; i < l_shb_lahead; i++ ) { -#ifdef BASOP_NOGLOB sig = mult_ro( oriSHB[i], win_shb[i], &Overflow ); /* Q_oriSHB */ oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_orisHB*/ sig = round_fx_o( Mult_32_16( mod_syn[i], win_shb[i] ), &Overflow ); /*Q_synSHB */ synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_synSHB */ -#else - sig = mult_r( oriSHB[i], win_shb[i] ); /* Q_oriSHB */ - oriNrg = L_mac0( oriNrg, sig, sig ); /* 2*Q_orisHB*/ - sig = round_fx( Mult_32_16( mod_syn[i], win_shb[i] ) ); /*Q_synSHB */ - synNrg = L_mac0( synNrg, sig, sig ); /* 2*Q_synSHB */ -#endif } FOR( ; i < l_frame; i++ ) { -#ifdef BASOP_NOGLOB oriNrg = L_mac0_o( oriNrg, oriSHB[i], oriSHB[i], &Overflow ); /* 2*Q_oriSHB */ sig = round_fx_o( mod_syn[i], &Overflow ); /* Q_oriSHB */ synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB */ -#else - oriNrg = L_mac0( oriNrg, oriSHB[i], oriSHB[i] ); /* 2*Q_oriSHB */ - sig = round_fx( mod_syn[i] ); /* Q_oriSHB */ - synNrg = L_mac0( synNrg, sig, sig ); /* 2*Q_oriSHB */ -#endif } tmp = add( l_frame, l_shb_lahead ); FOR( ; i < tmp; i++ ) { -#ifdef BASOP_NOGLOB sig = mult_ro( oriSHB[i], win_shb[l_frame + l_shb_lahead - 1 - i], &Overflow ); /* Q_oriSHB */ oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB */ sig = round_fx_o( Mult_32_16( mod_syn[i], win_shb[l_frame + l_shb_lahead - 1 - i] ), &Overflow ); /* Q_oriSHB */ synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB */ -#else - sig = mult_r( oriSHB[i], win_shb[l_frame + l_shb_lahead - 1 - i] ); /* Q_oriSHB */ - oriNrg = L_mac0( oriNrg, sig, sig ); /* 2*Q_oriSHB */ - - sig = round_fx( Mult_32_16( mod_syn[i], win_shb[l_frame + l_shb_lahead - 1 - i] ) ); /* Q_oriSHB */ - synNrg = L_mac0( synNrg, sig, sig ); /* 2*Q_oriSHB */ -#endif } IF( EQ_32( oriNrg, MAX_32 ) ) { @@ -4638,68 +4648,238 @@ static void EstimateSHBFrameGain_fx( move32(); FOR( i = 0; i < l_shb_lahead; i++ ) { -#ifdef BASOP_NOGLOB sig = mult_r( shl_o( oriSHB[i], scaling, &Overflow ), win_shb[i] ); oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB + 2*scaling */ -#else - sig = mult_r( shl( oriSHB[i], scaling ), win_shb[i] ); - oriNrg = L_mac0( oriNrg, sig, sig ); /* 2*Q_oriSHB + 2*scaling */ -#endif } FOR( ; i < l_frame; i++ ) { -#ifdef BASOP_NOGLOB sig = shl_o( oriSHB[i], scaling, &Overflow ); oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB + 2*scaling */ -#else - sig = shl( oriSHB[i], scaling ); - oriNrg = L_mac0( oriNrg, sig, sig ); /* 2*Q_oriSHB + 2*scaling */ -#endif } FOR( ; i < tmp; i++ ) { -#ifdef BASOP_NOGLOB sig = mult_r( shl_o( oriSHB[i], scaling, &Overflow ), win_shb[l_frame + l_shb_lahead - 1 - i] ); oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB + 2*scaling */ -#else - sig = mult_r( shl( oriSHB[i], scaling ), win_shb[l_frame + l_shb_lahead - 1 - i] ); - oriNrg = L_mac0( oriNrg, sig, sig ); /* 2*Q_oriSHB + 2*scaling */ -#endif } } L_tmp = root_a_over_b_fx( oriNrg, 2 * Q_oriSHB, synNrg, 2 * Q_synSHB, &exp_out ); exp_out = sub( exp_out, scaling ); -#ifdef BASOP_NOGLOB frame_gain = L_shl_sat( L_tmp, sub( exp_out, 13 ) ); /* Q18 */ -#else - frame_gain = L_shl( L_tmp, sub( exp_out, 13 ) ); /* Q18 */ -#endif *GainFrame = frame_gain; move32(); return; } - -static Word32 pow_off_pk_fx( Word16 a[], Word16 len, Word16 step ) +static void EstimateSHBFrameGain_ivas_fx( + const Word16 length, /* i : SHB overlap length */ + const Word16 *oriSHB, /* i : target original SHB frame Q(Q_oriSHB) */ + const Word16 Q_oriSHB, /* i : Q of arget original SHB frame */ + const Word16 *synSHB, /* i : shaped SHB excitation Q(Q_synSHB) */ + const Word16 Q_synSHB, /* i : Q of shaped SHB excitation */ + Word16 *subgain, /* i : estimate of gain shape Q15 */ + Word32 *GainFrame, /* o : estimat of gain frame Q18 */ + const Word16 *win_shb, /* i : SHB window Q15 */ + const Word16 *subwin_shb_local, /* i : SHB subframe window Q15 */ + const Word16 n_subfr_saturation /* i : Number of subframes which saturated in GainShape oriNrg calculation */ +) { - Word16 i, j; - Word32 sum, L_tmp; - - sum = L_shr( L_mult0( a[0], a[0] ), 1 ); /* Q29 */ - - j = 0; - move16(); - FOR( i = 1; i < len; i += step ) - { - L_tmp = L_shr( L_mult0( a[i], a[i] ), 1 ); /* Q29 */ - sum = L_add( sum, L_tmp ); /* Q29 */ - if ( GT_16( a[i], a[j] ) ) - { - j = i; - move16(); - } - } + const Word16 *skip; + Word16 i, j, k, l_shb_lahead, l_frame; + Word16 join_length, num_join, sig; + Word32 mod_syn[L_FRAME16k + L_SHB_LAHEAD]; + Word32 oriNrg, synNrg; + Word16 sum_gain; + Word32 frame_gain; + Word32 L_tmp; + Word16 exp_out; + Word16 tmp; + Word16 scaling = 0; +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; + move32(); +#endif + move16(); + + /* initilaization */ + l_frame = L_FRAME16k; + move16(); + l_shb_lahead = L_SHB_LAHEAD; + move16(); + skip = skip_bands_SWB_TBE; + + IF( EQ_16( length, SHB_OVERLAP_LEN / 2 ) ) + { + skip = skip_bands_WB_TBE; + l_frame = L_FRAME16k / 4; + move16(); + l_shb_lahead = L_SHB_LAHEAD / 4; + move16(); + } + + /* apply gain for each subframe, and store noise output signal using overlap-add*/ + set32_fx( mod_syn, 0, l_frame + l_shb_lahead ); + + IF( EQ_16( length, SHB_OVERLAP_LEN / 2 ) ) + { + sum_gain = 0; + move16(); + j = skip[0]; + move16(); + FOR( k = 0; k < length / 2; k++ ) + { + sum_gain = mult_r( subwin_shb_local[2 * k + 2], subgain[0] ); /* Q15 */ + mod_syn[j + k] = L_mult0( synSHB[j + k], sum_gain ); + move32(); /* Q(16+Q_synSHB) */ + mod_syn[j + k + length / 2] = L_mult0( synSHB[j + k + length / 2], subgain[0] ); + move32(); /* Q(16+Q_synSHB) */ + } + + FOR( i = 1; i < NUM_SHB_SUBFR / 2; i++ ) + { + j = skip[i]; + move16(); + FOR( k = 0; k < length; k++ ) + { + L_tmp = L_mult0( subwin_shb_local[k + 1], subgain[i] ); /* Q30 */ + sum_gain = round_fx( L_mac0( L_tmp, subwin_shb_local[length - k - 1], subgain[i - 1] ) ); /* Q14 */ + mod_syn[j + k] = L_mult( sum_gain, synSHB[j + k] ); + move32(); /* Q(16+Q_synSHB) */ + } + } + FOR( k = 0; k < length / 2; k++ ) + { + j = skip[i]; + move16(); + sum_gain = mult_r( subwin_shb_fx[length - 2 * k - 2], subgain[i - 1] ); /* Q15 */ + mod_syn[j + k] = L_mult0( synSHB[j + k], sum_gain ); + move32(); /* Q(16+Q_synSHB) */ + } + } + ELSE + { + num_join = NUM_SHB_SUBFR / NUM_SHB_SUBGAINS; + move16(); + join_length = i_mult2( num_join, length ); + j = 0; + move16(); + FOR( k = 0; k < length; k++ ) + { + sum_gain = mult_r( subwin_shb_local[k + 1], subgain[0] ); /* Q15 */ + mod_syn[j] = L_mult0( synSHB[j], sum_gain ); + move32(); /* Q(16+Q_synSHB) */ + j++; + } + FOR( i = 0; i < NUM_SHB_SUBGAINS - 1; i++ ) + { + FOR( k = 0; k < join_length - length; k++ ) + { + mod_syn[j] = L_mult0( synSHB[j], subgain[i * num_join] ); + move32(); /* Q(16+Q_synSHB) */ + j++; + } + + FOR( k = 0; k < length; k++ ) + { + L_tmp = L_mult0( subwin_shb_local[length - k - 1], subgain[i * num_join] ); + tmp = round_fx( L_mac0( L_tmp, subwin_shb_local[k + 1], subgain[( i + 1 ) * num_join] ) ); /* Q14 */ + mod_syn[j] = L_mult( tmp, synSHB[j] ); + move32(); /* Q(16+Q_synSHB) */ + j++; + } + } + FOR( k = 0; k < join_length - length; k++ ) + { + mod_syn[j] = L_mult0( synSHB[j], subgain[( NUM_SHB_SUBGAINS - 1 ) * num_join] ); + move32(); /* Q(16+Q_synSHB)*/ + j++; + } + FOR( k = 0; k < length; k++ ) + { + tmp = mult_r( subwin_shb_local[length - k - 1], subgain[( NUM_SHB_SUBGAINS - 1 ) * num_join] ); /* Q15 */ + mod_syn[j] = L_mult0( tmp, synSHB[j] ); + move32(); /* Q(16+Q_synSHB ) */ + j++; + } + } + /* adjust frame energy */ + oriNrg = L_deposit_l( 0 ); + synNrg = L_deposit_l( 0 ); + + FOR( i = 0; i < l_shb_lahead; i++ ) + { + sig = mult_ro( oriSHB[i], win_shb[i], &Overflow ); /* Q_oriSHB */ + oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_orisHB*/ + sig = round_fx_o( Mult_32_16( mod_syn[i], win_shb[i] ), &Overflow ); /*Q_synSHB */ + synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_synSHB - 2*/ + } + + FOR( ; i < l_frame; i++ ) + { + oriNrg = L_mac0_o( oriNrg, oriSHB[i], oriSHB[i], &Overflow ); /* 2*Q_oriSHB */ + sig = round_fx_o( mod_syn[i], &Overflow ); /* Q_oriSHB */ + synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB - 2*/ + } + + tmp = add( l_frame, l_shb_lahead ); + FOR( ; i < tmp; i++ ) + { + sig = mult_ro( oriSHB[i], win_shb[l_frame + l_shb_lahead - 1 - i], &Overflow ); /* Q_oriSHB */ + oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB */ + + sig = round_fx_o( Mult_32_16( mod_syn[i], win_shb[l_frame + l_shb_lahead - 1 - i] ), &Overflow ); /* Q_oriSHB */ + synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB - 2*/ + } + IF( EQ_32( oriNrg, MAX_32 ) ) + { + scaling = negate( add( shr( n_subfr_saturation, 1 ), 1 ) ); + oriNrg = 0; + move32(); + FOR( i = 0; i < l_shb_lahead; i++ ) + { + sig = mult_r( shl_o( oriSHB[i], scaling, &Overflow ), win_shb[i] ); + oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB + 2*scaling */ + } + FOR( ; i < l_frame; i++ ) + { + sig = shl_o( oriSHB[i], scaling, &Overflow ); + oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB + 2*scaling */ + } + FOR( ; i < tmp; i++ ) + { + sig = mult_r( shl_o( oriSHB[i], scaling, &Overflow ), win_shb[l_frame + l_shb_lahead - 1 - i] ); + oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB + 2*scaling */ + } + } + L_tmp = root_a_over_b_fx( oriNrg, shl( Q_oriSHB, 1 ), synNrg, sub( shl( Q_synSHB, 1 ), 2 ), &exp_out ); + exp_out = sub( exp_out, scaling ); + frame_gain = L_shl_sat( L_tmp, sub( exp_out, 13 ) ); /* Q18 */ + *GainFrame = frame_gain; + move32(); + + return; +} + + +static Word32 pow_off_pk_fx( Word16 a[], Word16 len, Word16 step ) +{ + Word16 i, j; + Word32 sum, L_tmp; + + sum = L_shr( L_mult0( a[0], a[0] ), 1 ); /* Q29 */ + + j = 0; + move16(); + FOR( i = 1; i < len; i += step ) + { + L_tmp = L_shr( L_mult0( a[i], a[i] ), 1 ); /* Q29 */ + sum = L_add( sum, L_tmp ); /* Q29 */ + if ( GT_16( a[i], a[j] ) ) + { + j = i; + move16(); + } + } L_tmp = L_shr( L_mult0( a[j], a[j] ), 1 ); /* Q29 */ sum = L_sub( sum, L_tmp ); /* Q29 */ @@ -4812,7 +4992,7 @@ static void EstimateSHBGainShape_fx( FOR( i = 0; i < NUM_SHB_SUBFR / 2; i++ ) { logic16(); - IF( ( i & 0x1 ) == 0 ) + IF( s_and( i, 0x1 ) == 0 ) { oriNrg = 0; move32(); @@ -4826,31 +5006,18 @@ static void EstimateSHBGainShape_fx( FOR( k = 0; k < length / 2; k++ ) { sig = mult_r( oriSHB[j + k], subwin[2 * k + 2] ); /* Q_oriSHB */ -#ifdef BASOP_NOGLOB oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2* Q_oriSHB */ sig = mult_r( synSHB[j + k], subwin[2 * k + 2] ); /* Q_synSHB */ synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2* Q_synSHB */ -#else - oriNrg = L_mac0( oriNrg, sig, sig ); /* 2* Q_oriSHB */ - sig = mult_r( synSHB[j + k], subwin[2 * k + 2] ); /* Q_synSHB */ - synNrg = L_mac0( synNrg, sig, sig ); /* 2* Q_synSHB */ -#endif } FOR( k = length / 2; k < length; k++ ) { sig = oriSHB[j + k]; move16(); -#ifdef BASOP_NOGLOB oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2* Q_oriSHB */ sig = synSHB[j + k]; move16(); synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2* Q_synSHB */ -#else - oriNrg = L_mac0( oriNrg, sig, sig ); /* 2* Q_oriSHB */ - sig = synSHB[j + k]; - move16(); - synNrg = L_mac0( synNrg, sig, sig ); /* 2* Q_synSHB */ -#endif } } ELSE @@ -4858,17 +5025,9 @@ static void EstimateSHBGainShape_fx( FOR( k = 0; k < length; k++ ) { sig = mult_r( oriSHB[j + k], subwin[k + 1] ); /* Q_oriSHB */ -#ifdef BASOP_NOGLOB - oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2* Q_oriSHB */ -#else - oriNrg = L_mac0( oriNrg, sig, sig ); /* 2* Q_oriSHB */ -#endif + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2* Q_oriSHB */ sig = mult_r( synSHB[j + k], subwin[k + 1] ); /* Q_synSHB */ -#ifdef BASOP_NOGLOB - synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2* Q_synSHB */ -#else - synNrg = L_mac0( synNrg, sig, sig ); /* 2* Q_synSHB */ -#endif + synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2* Q_synSHB */ } } IF( EQ_16( i, NUM_SHB_SUBFR / 2 - 1 ) ) @@ -4877,18 +5036,10 @@ static void EstimateSHBGainShape_fx( FOR( ; k < length_tmp; k++ ) { sig = mult_r( oriSHB[j + k], subwin[3 * length - 2 * k - 2] ); /* Q_oriSHB */ -#ifdef BASOP_NOGLOB - oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2* Q_oriSHB */ -#else - oriNrg = L_mac0( oriNrg, sig, sig ); /* 2* Q_oriSHB */ -#endif + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2* Q_oriSHB */ sig = mult_r( synSHB[j + k], subwin[3 * length - 2 * k - 2] ); /* Q_synSHB */ -#ifdef BASOP_NOGLOB - synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2* Q_synSHB */ -#else - synNrg = L_mac0( synNrg, sig, sig ); /* 2* Q_synSHB */ -#endif + synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2* Q_synSHB */ } } ELSE @@ -4896,28 +5047,20 @@ static void EstimateSHBGainShape_fx( FOR( ; k < length2; k++ ) { sig = mult_r( oriSHB[j + k], subwin[2 * length - k - 1] ); /* Q_oriSHB */ -#ifdef BASOP_NOGLOB - oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2* Q_oriSHB */ -#else - oriNrg = L_mac0( oriNrg, sig, sig ); /* 2* Q_oriSHB */ -#endif + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2* Q_oriSHB */ sig = mult_r( synSHB[j + k], subwin[2 * length - k - 1] ); /* Q_synSHB */ -#ifdef BASOP_NOGLOB - synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2* Q_synSHB */ -#else - synNrg = L_mac0( synNrg, sig, sig ); /* 2* Q_synSHB */ -#endif + synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2* Q_synSHB */ } } logic16(); - IF( EQ_16( ( i & 0x1 ), 1 ) ) + IF( EQ_16( s_and( i, 0x1 ), 1 ) ) { L_subgain[i / 2] = root_a_over_b_fx( oriNrg, shl( Q_oriSHB, 1 ), synNrg, shl( Q_synSHB, 1 ), &n ); move16(); /* Q(31-n) */ norm[i / 2] = n; move16(); - IF( GT_16( norm[i / 2], n_max ) ) + if ( GT_16( norm[i / 2], n_max ) ) { n_max = norm[i / 2]; move16(); @@ -4938,50 +5081,26 @@ static void EstimateSHBGainShape_fx( j = i_mult2( join_length, i ); FOR( k = 0; k < length; k++ ) { - sig = mult_r( oriSHB[j + k], subwin[k + 1] ); /* Q_oriSHB */ -#ifdef BASOP_NOGLOB + sig = mult_r( oriSHB[j + k], subwin[k + 1] ); /* Q_oriSHB */ oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ -#else - oriNrg = L_mac0( oriNrg, sig, sig ); /* 2* Q_oriSHB */ -#endif - sig = mult_r( synSHB[j + k], subwin[k + 1] ); /* Q_oriSHB */ -#ifdef BASOP_NOGLOB + sig = mult_r( synSHB[j + k], subwin[k + 1] ); /* Q_oriSHB */ synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ -#else - synNrg = L_mac0( synNrg, sig, sig ); /* 2* Q_oriSHB */ -#endif } FOR( k = 0; k < ( join_length - length ); k++ ) { - sig = mult_r( oriSHB[length + j + k], 32767 ); /* Q_oriSHB */ -#ifdef BASOP_NOGLOB + sig = mult_r( oriSHB[length + j + k], 32767 ); /* Q_oriSHB */ oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ -#else - oriNrg = L_mac0( oriNrg, sig, sig ); /* 2* Q_oriSHB */ -#endif - sig = mult_r( synSHB[length + j + k], 32767 ); /* Q_oriSHB */ -#ifdef BASOP_NOGLOB + sig = mult_r( synSHB[length + j + k], 32767 ); /* Q_oriSHB */ synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ -#else - synNrg = L_mac0( synNrg, sig, sig ); /* 2* Q_oriSHB */ -#endif } FOR( k = 0; k < length; k++ ) { sig = mult_r( oriSHB[j + join_length + k], subwin[length - k - 1] ); /* Q_oriSHB */ -#ifdef BASOP_NOGLOB - oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ -#else - oriNrg = L_mac0( oriNrg, sig, sig ); /* 2* Q_oriSHB */ -#endif + oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ sig = mult_r( synSHB[j + join_length + k], subwin[length - k - 1] ); /* Q_oriSHB */ -#ifdef BASOP_NOGLOB - synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ -#else - synNrg = L_mac0( synNrg, sig, sig ); /* 2* Q_oriSHB */ -#endif + synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ } /* Only implemented in SWB because the length of samples in SWB frame is longer, more likely to saturate */ scaling = 0; @@ -5000,29 +5119,17 @@ static void EstimateSHBGainShape_fx( FOR( k = 0; k < length; k++ ) { sig = mult_r( oriSHB[j + k], subwin[k + 1] ); -#ifdef BASOP_NOGLOB oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB - 2*/ -#else - oriNrg = L_mac0( oriNrg, sig, sig ); /* 2*Q_oriSHB - 2*/ -#endif } FOR( k = 0; k < ( join_length - length ); k++ ) { sig = shr( oriSHB[length + j + k], 1 ); -#ifdef BASOP_NOGLOB oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB - 2*/ -#else - oriNrg = L_mac0( oriNrg, sig, sig ); /* 2*Q_oriSHB - 2*/ -#endif } FOR( k = 0; k < length; k++ ) { sig = mult_r( shr( oriSHB[j + join_length + k], 1 ), subwin[length - k - 1] ); /* Q_oriSHB - 1(scaling) */ -#ifdef BASOP_NOGLOB - oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB - 2 */ -#else - oriNrg = L_mac0( oriNrg, sig, sig ); /* 2*Q_oriSHB - 2 */ -#endif + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB - 2 */ } } L_subgain[i] = root_a_over_b_fx( oriNrg, shl( Q_oriSHB, 1 ), synNrg, shl( Q_synSHB, 1 ), &n ); @@ -5030,7 +5137,7 @@ static void EstimateSHBGainShape_fx( n = sub( n, scaling ); norm[i] = n; move16(); - IF( GT_16( norm[i], n_max ) ) + if ( GT_16( norm[i], n_max ) ) { n_max = norm[i]; move16(); @@ -5040,13 +5147,8 @@ static void EstimateSHBGainShape_fx( FOR( i = 0; i < num_gains; i++ ) { -#ifdef BASOP_NOGLOB subgain[i] = round_fx_o( L_shl_o( L_subgain[i], sub( norm[i], n_max + 1 ), &Overflow ), &Overflow ); /* Q(14-n_max) */ L_sum_gain = L_mac0_o( L_sum_gain, subgain[i], subgain[i], &Overflow ); /* Q(28-2*n_max) */ -#else - subgain[i] = round_fx( L_shl( L_subgain[i], sub( norm[i], n_max + 1 ) ) ); /* Q(14-n_max) */ - L_sum_gain = L_mac0( L_sum_gain, subgain[i], subgain[i] ); /* Q(28-2*n_max) */ -#endif move16(); } @@ -5058,12 +5160,8 @@ static void EstimateSHBGainShape_fx( FOR( i = 0; i < num_gains; i++ ) { - L_tmp = Mpy_32_16_1( normFact, subgain[i] ); /*Q(31-n) * Q(31-norm[i]) */ /* Q(30-n-n_max) */ -#ifdef BASOP_NOGLOB + L_tmp = Mpy_32_16_1( normFact, subgain[i] ); /*Q(31-n) * Q(31-norm[i]) */ /* Q(30-n-n_max) */ subgain[i] = s_max( round_fx_o( L_shl_o( L_tmp, add( n, n_max + 1 ), &Overflow ), &Overflow ), 3277 /*0.1f Q15*/ ); /* Q15 */ -#else - subgain[i] = s_max( round_fx( L_shl( L_tmp, add( n, n_max + 1 ) ) ), 3277 /*0.1f Q15*/ ); /* Q15 */ -#endif move16(); } @@ -5232,6 +5330,7 @@ static void QuantizeSHBsubgains_fx( exp = sub( -1, exp ); L_tmp = Mpy_32_16( exp, frac, 24660 ); /* Q13 ; 20.0 * log10(2) in Q12*/ subgains[i + NUM_SHB_SUBFR / 4] = round_fx( L_shl( L_tmp, 11 ) ); /* Q8 */ + move16(); } } idxSubGain = closest_centroid_lc_fx( subgains + NUM_SHB_SUBFR / 4, HBCB_SubGain5bit_fx, 1 << NUM_BITS_SHB_SUBGAINS ); @@ -5245,10 +5344,11 @@ static void QuantizeSHBsubgains_fx( L_tmp = L_shr( L_tmp, 10 ); /* From Q26 to Q16 */ frac = L_Extract_lc( L_tmp, &exp ); subgains[i] = extract_l( Pow2( 14, frac ) ); + move16(); /* Put 14 as exponent so that */ /* output of Pow2() will be: */ /* 16384 < Pow2() <= 32767 */ - subgains[i] = shl( subgains[i], exp + 1 ); + subgains[i] = shl( subgains[i], add( exp, 1 ) ); move16(); /*Q15 */ } @@ -5277,6 +5377,7 @@ static void QuantizeSHBsubgains_fx( L_tmp = Mpy_32_16( exp, frac, 9864 ); /*move32(); // Q16 ; log10(2) in Q15 */ subgains[i] = round_fx( L_shl( L_tmp, 12 ) ); /*Q12 */ + move16(); } } @@ -5288,10 +5389,11 @@ static void QuantizeSHBsubgains_fx( L_tmp = L_shr( L_tmp, 10 ); /* From Q26 to Q16 */ frac = L_Extract_lc( L_tmp, &exp ); subgains[i] = extract_l( Pow2( 14, frac ) ); + move16(); /* Put 14 as exponent so that */ /* output of Pow2() will be: */ /* 16384 < Pow2() <= 32767 */ - subgains[i] = shl( subgains[i], exp + 1 ); + subgains[i] = shl( subgains[i], add( exp, 1 ) ); move16(); /*Q15 */ } @@ -5381,7 +5483,7 @@ static void QuantizeSHBsubgains_ivas_fx( /* Put 14 as exponent so that */ /* output of Pow2() will be: */ /* 16384 < Pow2() <= 32767 */ - subgains[i] = shl( subgains[i], exp + 1 ); + subgains[i] = shl( subgains[i], add( exp, 1 ) ); move16(); /*Q15 */ } @@ -5426,7 +5528,7 @@ static void QuantizeSHBsubgains_ivas_fx( /* Put 14 as exponent so that */ /* output of Pow2() will be: */ /* 16384 < Pow2() <= 32767 */ - subgains[i] = shl( subgains[i], exp + 1 ); + subgains[i] = shl( subgains[i], add( exp, 1 ) ); move16(); /*Q15 */ } @@ -5472,6 +5574,7 @@ static void Quant_shb_ener_sf_fx( /* shb_ener_sf_fx[0] = log10(0.003125*shb_ener_sf[0:319]); */ sum = *shb_ener_sf_Q31; /* L_tmp in Q_ener = (2*Q_shb+1) */ + move32(); exp = norm_l( sum ); frac = Log2_norm_lc( L_shl( sum, exp ) ); @@ -5491,7 +5594,9 @@ static void Quant_shb_ener_sf_fx( L_tmp = L_shl( L_tmp, -10 ); /* bring L_tmp from Q26 to Q16 */ frac = L_Extract_lc( L_tmp, &exp ); /* Extract exponent */ L_tmp = Pow2( 14, frac ); - *shb_ener_sf_Q31 = L_shl( L_tmp, exp - 14 + Q_ener ); /* In Q_ener */ + // *shb_ener_sf_Q31 = L_shl( L_tmp, exp - 14 + Q_ener ); /* In Q_ener */ + *shb_ener_sf_Q31 = L_shl( L_tmp, add( sub( exp, 14 ), Q_ener ) ); /* In Q_ener */ + move32(); hBWE_TD->idx_shb_fr_gain = idxSubEner_fx; move16(); @@ -5535,7 +5640,7 @@ static void Quant_shb_ener_sf_ivas_fx( temp_shb_ener_sf_fx = 0; move16(); - idxSubEner_fx = usquant_fx( tmp, &temp_shb_ener_sf_fx, 0, 43, shl( 1, NUM_BITS_SHB_ENER_SF ) ); /* 43 = 0.042f in Q10 = Qin-1 */ + idxSubEner_fx = usquant_fx( tmp, &temp_shb_ener_sf_fx, 0, 43, 1 << NUM_BITS_SHB_ENER_SF ); /* 43 = 0.042f in Q10 = Qin-1 */ /* o: temp_shb_ener_sf_fx in Q11 */ /* shb_ener_sf_fx[0] = pow(10.0, temp_shb_ener_sf_fx ); */ @@ -5578,8 +5683,10 @@ static void Quant_shb_res_gshape_fx( 2048 /*0.125f Q14*/, /*2048 = 0.125 in Q14 */ 1024 /*0.125f Q13*/, /*1024 = 0.125 in Q13 */ shl( 1, NUM_BITS_SHB_RES_GS ) ); + move16(); hBWE_TD->idx_res_gs[i] = idxSubGain_fx[i]; + 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 ); @@ -5611,7 +5718,7 @@ static void Quant_shb_res_gshape_ivas_fx( shl( 1, NUM_BITS_SHB_RES_GS ) ); move16(); - IF( st->codec_mode == MODE2 ) + IF( EQ_16( st->codec_mode, MODE2 ) ) { hBWE_TD->idx_res_gs[i] = idxSubGain_fx[i]; move16(); @@ -5655,6 +5762,7 @@ static void QuantizeSHBframegain_fx( Word16 idxFrameGain; Word32 Q_GainFrame; Word16 Unit_weights1 = 1; + move16(); Word16 exp, frac, tmp; Word32 L_tmp; Word32 GainFrameLog; @@ -5701,7 +5809,8 @@ static void QuantizeSHBframegain_fx( { exp = norm_l( *GainFrame ); frac = Log2_norm_lc( L_shl( *GainFrame, exp ) ); - exp = ( 30 - exp - 18 ); + // exp = ( 30 - exp - 18 ); + exp = sub( 30 - 18, exp ); GainFrameLog = Mpy_32_16( exp, frac, 9864 ); /*GainFrameLog= round_fx(L_shl(L_tmp,12)); //Q12 */ } @@ -5712,7 +5821,8 @@ static void QuantizeSHBframegain_fx( idxFrameGain = extract_l( L_shr( L_add( L_tmp, shl( 1, sub( 14, exp ) ) ), sub( 15, exp ) ) ); /*Q0*/ IF( GT_16( idxFrameGain, ( 1 << NUM_BITS_SHB_FRAMEGAIN ) - 1 ) ) { - idxFrameGain = sub( ( 1 << NUM_BITS_SHB_FRAMEGAIN ), 1 ); + idxFrameGain = ( 1 << NUM_BITS_SHB_FRAMEGAIN ) - 1; + move16(); } ELSE { @@ -5726,9 +5836,11 @@ static void QuantizeSHBframegain_fx( L_tmp = SHB_GAIN_QLOW_FX_16; Q_GainFrame = L_mac( L_tmp, idxFrameGain, SHB_GAIN_QDELTA_FX_15 ); + test(); WHILE( GT_32( Q_GainFrame, L_add( GainFrameLog, 4866 ) ) && idxFrameGain != 0 ) { + test(); idxFrameGain = sub( idxFrameGain, 1 ); Q_GainFrame = L_mac0( SHB_GAIN_QLOW_FX_16, idxFrameGain, SHB_GAIN_QDELTA_FX_16 ); } @@ -5740,7 +5852,7 @@ static void QuantizeSHBframegain_fx( frac = L_Extract_lc( L_tmp, &exp ); Q_GainFrame = Pow2( 30, frac ); exp = sub( exp, 30 ); - Q_GainFrame = L_shl( Q_GainFrame, exp + 18 ); /* Q18 */ + Q_GainFrame = L_shl( Q_GainFrame, add( exp, 18 ) ); /* Q18 */ hBWE_TD->idxFrameGain = idxFrameGain; move16(); @@ -5749,12 +5861,14 @@ static void QuantizeSHBframegain_fx( push_indice_fx( st_fx->hBstr, IND_SHB_FRAMEGAIN, idxFrameGain, NUM_BITS_SHB_FRAMEGAIN ); } *rf_gainFrame_ind = idxFrameGain; + move16(); } IF( EQ_16( st_fx->rf_mode, 1 ) ){ /*Currently intended for SWB only. Modify for WB is needed later!*/ IF( EQ_16( hRF->rf_frame_type, RF_NELP ) ){ *rf_gainFrame_ind = idxFrameGain; /* NELP Frame uses full 5 bits */ + move16(); } ELSE /*RF_ALLPRED, RF_GENPRED, RF_NOPRED modes*/ { @@ -5774,6 +5888,7 @@ ELSE /*RF_ALLPRED, RF_GENPRED, RF_NOPRED modes*/ { *rf_gainFrame_ind = 3; } + move16(); } } @@ -5834,7 +5949,7 @@ static void QuantizeSHBframegain_ivas_fx( 1 << NUM_BITS_SHB_FrameGain_LBR_WB, &idxFrameGain, &Q_GainFrame, SHBCB_FrameGain16_fx ); test(); - IF( GT_32( Q_GainFrame, L_shl( Mult_32_16( *GainFrame, 17367 ), 1 ) ) && idxFrameGain > 0 ) /* 1.06 = +0.5 dB */ + IF( GT_64( W_deposit32_l( Q_GainFrame ), W_shl( W_mult_32_16( *GainFrame, 17367 ), 15 ) ) && idxFrameGain > 0 ) /* 1.06 = +0.5 dB */ { idxFrameGain--; Q_GainFrame = L_add( SHBCB_FrameGain16_fx[idxFrameGain], 0 ); /* Q18 */ @@ -5882,7 +5997,7 @@ static void QuantizeSHBframegain_ivas_fx( { exp = norm_l( *GainFrame ); frac = Log2_norm_lc( L_shl( *GainFrame, exp ) ); - exp = ( 30 - exp - 18 ); + exp = sub( 30 - 18, exp ); GainFrameLog = Mpy_32_16( exp, frac, 9864 ); /*GainFrameLog= round_fx(L_shl(L_tmp,12)); //Q12 */ } @@ -5936,10 +6051,11 @@ static void QuantizeSHBframegain_ivas_fx( Q_GainFrame = L_mac( L_tmp, idxFrameGain, SHB_GAIN_QDELTA_FX_15 ); } - + test(); WHILE( GT_32( Q_GainFrame, L_add( GainFrameLog, 4866 ) ) && idxFrameGain != 0 ) { + test(); idxFrameGain = sub( idxFrameGain, 1 ); Q_GainFrame = L_mac0( SHB_GAIN_QLOW_FX_16, idxFrameGain, SHB_GAIN_QDELTA_FX_16 ); } @@ -5960,7 +6076,7 @@ static void QuantizeSHBframegain_ivas_fx( frac = L_Extract_lc( L_tmp, &exp ); Q_GainFrame = Pow2( 30, frac ); exp = sub( exp, 30 ); - Q_GainFrame = L_shl( Q_GainFrame, exp + 18 ); /* Q18 */ + Q_GainFrame = L_shl( Q_GainFrame, add( exp, 18 ) ); /* Q18 */ IF( EQ_16( st_fx->codec_mode, MODE2 ) ) { @@ -6052,6 +6168,7 @@ static void determine_gain_weights_fx( Word32 L_tmp; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move16(); #endif FOR( j = 0; j < dims; j++ ) @@ -6062,22 +6179,18 @@ static void determine_gain_weights_fx( exp1 = norm_l( gain[j] ); frac = Log2_norm_lc( L_shl( gain[j], exp1 ) ); move16(); - exp = 30 - exp1 - 18; + exp = sub( 30 - 18, exp1 ); move16(); L_tmp = Mpy_32_16( exp, frac, -29491 ); /* Q16 */ frac = L_Extract_lc( L_tmp, &exp ); tmp = extract_l( Pow2( 14, frac ) ); /* Q14 */ exp2 = sub( exp, 8 ); - if ( LE_16( exp1, 21 ) ) + IF( LE_16( exp1, 21 ) ) { exp2 = sub( exp, 2 ); } -#ifdef BASOP_NOGLOB weights[j] = shl_o( tmp, exp2, &Overflow ); -#else - weights[j] = shl( tmp, exp2 ); -#endif move16(); /* Q12 */ } ELSE @@ -6353,7 +6466,7 @@ static Word16 Find_LSF_grid_fx( exp = norm_s( m ); tmp = div_s( shl( 1, sub( 14, exp ) ), m ); L_tmp = L_mult( sub( MAX_LSF_FX, m ), tmp ); - scale = round_fx( L_shl( L_tmp, exp + 1 ) ); + scale = round_fx( L_shl( L_tmp, add( exp, 1 ) ) ); FOR( i = 0; i < NUM_MAP_LSF; i++ ) { @@ -6498,6 +6611,7 @@ static void gainFrSmooth_En_fx( Encoder_State *st_fx, tempQ31 = L_mac( tempQ31, hBWE_TD->lsp_shb_spacing_fx[1], 6553 ); /* 0.2f */ tempQ31 = L_mac( tempQ31, hBWE_TD->lsp_shb_spacing_fx[2], 9830 ); /* 0.3f */ *MA_lsp_shb_spacing = mac_r( tempQ31, lsp_spacing, 13107 ); /* 0.4f */ + move16(); hBWE_TD->lsp_shb_spacing_fx[0] = hBWE_TD->lsp_shb_spacing_fx[1]; move16(); @@ -6525,7 +6639,7 @@ static void gainFrSmooth_En_fx( Encoder_State *st_fx, } test(); - IF( LT_32( lsp_slow_evol_rate, 2147484l /*0.001f Q31*/ ) && LT_32( lsp_fast_evol_rate, 2147484l /*0.001f Q31*/ ) ) + if ( LT_32( lsp_slow_evol_rate, 2147484l /*0.001f Q31*/ ) && LT_32( lsp_fast_evol_rate, 2147484l /*0.001f Q31*/ ) ) { *frGainSmoothEn = 1; move16(); @@ -6624,6 +6738,7 @@ static void gainFrSmooth_En_ivas_fx( Encoder_State *st_fx, tempQ31 = L_mac( tempQ31, hBWE_TD->lsp_shb_spacing_fx[1], 6553 ); /* 0.2f in Q15 */ tempQ31 = L_mac( tempQ31, hBWE_TD->lsp_shb_spacing_fx[2], 9830 ); /* 0.3f in Q15 */ *MA_lsp_shb_spacing = mac_r( tempQ31, lsp_spacing, 13107 ); /* 0.4f in Q15 */ + move16(); hBWE_TD->lsp_shb_spacing_fx[0] = hBWE_TD->lsp_shb_spacing_fx[1]; move16(); @@ -6651,7 +6766,7 @@ static void gainFrSmooth_En_ivas_fx( Encoder_State *st_fx, } test(); - IF( ( BASOP_Util_Cmp_Mant32Exp( lsp_slow_evol_rate, lsp_slow_evol_rate_e, 2147484l /*0.001f in Q31*/, 0 ) < 0 ) && ( BASOP_Util_Cmp_Mant32Exp( lsp_fast_evol_rate, lsp_fast_evol_rate_e, 2147484l /*0.001f in Q31*/, 0 ) < 0 ) ) + if ( ( BASOP_Util_Cmp_Mant32Exp( lsp_slow_evol_rate, lsp_slow_evol_rate_e, 2147484l /*0.001f in Q31*/, 0 ) < 0 ) && ( BASOP_Util_Cmp_Mant32Exp( lsp_fast_evol_rate, lsp_fast_evol_rate_e, 2147484l /*0.001f in Q31*/, 0 ) < 0 ) ) { *frGainSmoothEn = 1; move16(); @@ -6708,11 +6823,7 @@ static void first_VQstages_fx( L_tmp = L_deposit_l( 0 ); FOR( j = 0; j < N; j++ ) { -#ifdef BASOP_NOGLOB L_tmp1 = L_shl_o( L_mult0( u[j], w[j] ), 7, &Overflow ); /*x2.56 + Q8 + Q7 */ -#else /* BASOP_NOGLOB */ - L_tmp1 = L_shl( L_mult0( u[j], w[j] ), 7 ); /*x2.56 + Q8 + Q7 */ -#endif /* BASOP_NOGLOB */ L_tmp1 = Mult_32_16( L_tmp1, u[j] ); /*x2.56 + Q15 + x2.56 -Q15 */ L_tmp = L_add( L_tmp, L_tmp1 ); /*Q0 + x2.56 +x2.56 */ } @@ -6720,7 +6831,6 @@ static void first_VQstages_fx( /* Set up initial error (residual) vectors */ pTmp = resid[1]; - move16(); FOR( c = 0; c < maxC; c++ ) { Copy( u, pTmp, N ); @@ -6745,21 +6855,15 @@ static void first_VQstages_fx( /* swap pointers to parent and current nodes */ pTmp_short = indices[0]; indices[0] = indices[1]; - move16(); indices[1] = pTmp_short; - move16(); pTmp = resid[0]; resid[0] = resid[1]; - move16(); resid[1] = pTmp; - move16(); pTmp32 = dist[0]; dist[0] = dist[1]; - move32(); dist[1] = pTmp32; - move32(); /* p_max points to maximum distortion node (worst of best) */ p_max = 0; @@ -6790,7 +6894,6 @@ static void first_VQstages_fx( FOR( c = 0; c < m; c++ ) { pTmp = &resid[0][c * N]; - move16(); L_tmp = L_mult( pTmp[0], Tmp[0] ); FOR( c2 = 1; c2 < N; c2++ ) { @@ -6837,7 +6940,7 @@ static void first_VQstages_fx( { /* subtract codebook entry from the residual vector of the parent node */ pTmp = resid[1] + c * N; - move16(); + Copy( resid[0] + parents[c] * N, pTmp, N ); Vr_subt( pTmp, cb_stage + ( indices[1][cs + s] ) * N, pTmp, N ); @@ -6910,15 +7013,11 @@ static void LVQQuant_BWE_LSF_fx( empty_bits = 0; /* This is the difference to 21 bits, if we want lower number of bits */ move16(); nbits = sub( nbits, empty_bits ); /* THIS IS TO SIMULATE DIFFERENT NUMBER OF input BITS - should be removed */ - move16(); c2 = sub( NUM_BITS_SHB_MSLVQ, nbits ); - move16(); numbits_VQ = config_LSF_BWE[c2 * 3]; - move16(); levels[0] = config_LSF_BWE[c2 * 3 + 1]; move16(); predictor_bits = config_LSF_BWE[c2 * 3 + 2]; - move16(); IF( LT_16( nbits, 19 ) ) { cb_stage_fx = cb_LSF_BWE_fx[1]; @@ -7215,6 +7314,7 @@ void fb_tbe_enc_fx( TD_BWE_ENC_HANDLE hBWE_TD = st->hBWE_TD; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move16(); #endif s_max_value = 0; FOR( i = 0; i < L_FRAME48k; i++ ) @@ -7225,13 +7325,14 @@ void fb_tbe_enc_fx( if ( s_max_value == 0 ) { exp_temp = 15; + move16(); } exp_temp = sub( exp_temp, 1 ); Copy_Scale_sig( new_input, input_fhb, L_FRAME48k, exp_temp ); elliptic_bpf_48k_generic_fx( input_fhb, &exp_temp, tmp_vec, hBWE_TD->elliptic_bpf_2_48k_mem_fx, hBWE_TD->elliptic_bpf_2_48k_mem_fx_Q, full_band_bpf_2_fx ); - Sample_Delay_HP = NS2SA( 48000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ) - L_FRAME48k / 2; + Sample_Delay_HP = NS2SA_FX2( 48000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ) - L_FRAME48k / 2; IF( NE_16( st->last_extl, FB_TBE ) ) { @@ -7245,13 +7346,9 @@ void fb_tbe_enc_fx( Copy( hBWE_TD->old_input_fhb_fx, input_fhb, Sample_Delay_HP ); Copy( tmp_vec, input_fhb + Sample_Delay_HP, L_FRAME48k - Sample_Delay_HP ); Copy( tmp_vec + L_FRAME48k - Sample_Delay_HP, hBWE_TD->old_input_fhb_fx, Sample_Delay_HP ); - temp2 = sum2_fx_mod( input_fhb, L_FRAME48k / 2 ); /* Q11 */ -#ifdef BASOP_NOGLOB + temp2 = sum2_fx_mod( input_fhb, L_FRAME48k / 2 ); /* Q11 */ temp2 = L_add_o( temp2, L_shl_o( hBWE_TD->prev_fb_energy_fx, sub( sub( add( exp_temp, exp_temp ), 6 ), hBWE_TD->prev_fb_energy_fx_Q ), &Overflow ), &Overflow ); /* Q11 */ -#else - temp2 = L_add( temp2, L_shl( hBWE_TD->prev_fb_energy_fx, sub( sub( add( exp_temp, exp_temp ), 6 ), hBWE_TD->prev_fb_energy_fx_Q ) ) ); /* Q11 */ -#endif - hBWE_TD->prev_fb_energy_fx = sum2_fx_mod( input_fhb + L_FRAME48k / 2, L_FRAME48k / 2 ); /*Q11*/ + hBWE_TD->prev_fb_energy_fx = sum2_fx_mod( input_fhb + L_FRAME48k / 2, L_FRAME48k / 2 ); /*Q11*/ hBWE_TD->prev_fb_energy_fx_Q = sub( add( exp_temp, exp_temp ), 6 ); fb_exc_energy = sum2_fx_mod( fb_exc, L_FRAME16k ); /* Q(2*Q_fb_exc+1 -7) */ @@ -7276,12 +7373,8 @@ void fb_tbe_enc_fx( { tmp = div_s( tmp2, tmp ); L_tmp = L_deposit_h( tmp ); - L_tmp = Isqrt_lc( L_tmp, &exp ); /*Q(31-exp)*/ -#ifdef BASOP_NOGLOB + L_tmp = Isqrt_lc( L_tmp, &exp ); /*Q(31-exp)*/ L_tmp = L_max( L_shr_o( L_tmp, sub( 31, exp ), &Overflow ), 0x1 ); /* Q0 */ -#else - L_tmp = L_max( L_shr( L_tmp, sub( 31, exp ) ), 0x1 ); /* Q0 */ -#endif } ELSE { @@ -7291,9 +7384,11 @@ void fb_tbe_enc_fx( /* idxGain = (short)( log2_f ((float)ratio) + 0.5f ); idxGain = max( 0, min(15,idxGain) ); */ ratio = 0; + move16(); IF( GE_32( L_tmp, 32768 ) ) { idxGain = 15; + move16(); } ELSE { @@ -7302,6 +7397,9 @@ void fb_tbe_enc_fx( idxGain = sub( 14, exp_norm ); idxGain = s_max( 0, idxGain ); } + + test(); + test(); IF( GT_16( idxGain, 2 ) && LT_16( idxGain, 15 ) && GT_16( ratio, add( shl( 2, sub( idxGain, 1 ) ), shl( 2, sub( idxGain, 2 ) ) ) ) ) { idxGain = add( idxGain, 1 ); @@ -7311,6 +7409,7 @@ void fb_tbe_enc_fx( IF( st->codec_mode == MODE2 ) { hBWE_TD->idxGain = idxGain; + move16(); } ELSE { @@ -7332,15 +7431,13 @@ void fb_tbe_enc_ivas_fx( Word16 input_fhb_new[L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS )]; Word16 input_fhb[L_FRAME48k]; Word16 Sample_Delay_HP; - Word32 fb_exc_energy, temp2; - Word32 L_tmp; - Word16 tmp, tmp1, tmp2, exp, exp2, exp_norm; + Word64 fb_exc_energy; + Word16 tmp, tmp2, exp, exp2; Word16 s_max_value, exp_temp, i; TD_BWE_ENC_HANDLE hBWE_TD = st->hBWE_TD; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL - Flag Overflow = 0; - move32(); -#endif + Word16 q_diff, q_input_fhb; + Word64 temp1, temp2; + s_max_value = 0; move16(); FOR( i = 0; i < L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ); i++ ) @@ -7371,19 +7468,16 @@ void fb_tbe_enc_ivas_fx( IF( EQ_16( st->L_frame, L_FRAME ) ) { - Sample_Delay_HP = NS2SA( 48000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS ) - L_FRAME48k / 2; - move16(); + Sample_Delay_HP = NS2SA_FX2( 48000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS ) - L_FRAME48k / 2; } ELSE { - Sample_Delay_HP = NS2SA( 48000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_16k_NS ) - L_FRAME48k / 2; - move16(); + Sample_Delay_HP = NS2SA_FX2( 48000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_16k_NS ) - L_FRAME48k / 2; } } ELSE { - Sample_Delay_HP = NS2SA( 48000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ) - L_FRAME48k / 2; - move16(); + Sample_Delay_HP = NS2SA_FX2( 48000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ) - L_FRAME48k / 2; } IF( NE_16( st->last_extl, FB_TBE ) ) @@ -7393,79 +7487,72 @@ void fb_tbe_enc_ivas_fx( move16(); set16_fx( tmp_vec, 0, L_FRAME16k ); } - Copy_Scale_sig( hBWE_TD->old_input_fhb_fx, hBWE_TD->old_input_fhb_fx, Sample_Delay_HP, sub( exp_temp, hBWE_TD->old_input_fhb_fx_Q ) ); + + q_diff = sub( exp_temp, hBWE_TD->old_input_fhb_fx_Q ); + Copy( hBWE_TD->old_input_fhb_fx, input_fhb, Sample_Delay_HP ); // hBWE_TD->old_input_fhb_fx_Q + Copy( tmp_vec, input_fhb + Sample_Delay_HP, sub( L_FRAME48k, Sample_Delay_HP ) ); // exp_temp + IF( q_diff > 0 ) + { + scale_sig( input_fhb + Sample_Delay_HP, sub( L_FRAME48k, Sample_Delay_HP ), negate( q_diff ) ); // hBWE_TD->old_input_fhb_fx_Q + q_input_fhb = hBWE_TD->old_input_fhb_fx_Q; + move16(); + } + ELSE + { + scale_sig( input_fhb, Sample_Delay_HP, q_diff ); // exp_temp + q_input_fhb = exp_temp; + move16(); + } + Copy( tmp_vec + L_FRAME48k - Sample_Delay_HP, hBWE_TD->old_input_fhb_fx, Sample_Delay_HP ); hBWE_TD->old_input_fhb_fx_Q = exp_temp; move16(); - Copy( hBWE_TD->old_input_fhb_fx, input_fhb, Sample_Delay_HP ); - Copy( tmp_vec, input_fhb + Sample_Delay_HP, sub( L_FRAME48k, Sample_Delay_HP ) ); - Copy( tmp_vec + L_FRAME48k - Sample_Delay_HP, hBWE_TD->old_input_fhb_fx, Sample_Delay_HP ); - temp2 = sum2_fx_mod( input_fhb, L_FRAME48k / 2 ); /* Q(2*Q_input_fhb-8) */ -#ifdef BASOP_NOGLOB - temp2 = L_add_o( temp2, L_shl_o( hBWE_TD->prev_fb_energy_fx, sub( sub( add( exp_temp, exp_temp ), 8 ), hBWE_TD->prev_fb_energy_fx_Q ), &Overflow ), &Overflow ); /* Q(2*(exp_temp)-8) */ -#else - temp2 = L_add( temp2, L_shl( hBWE_TD->prev_fb_energy_fx, sub( sub( add( exp_temp, exp_temp ), 8 ), hBWE_TD->prev_fb_energy_fx_Q ) ) ); /* Q(2*(exp_temp)-8) */ -#endif - hBWE_TD->prev_fb_energy_fx = sum2_fx_mod( input_fhb + L_FRAME48k / 2, L_FRAME48k / 2 ); /*Q(2*(Q_input_fhb)-8) */ + + temp2 = sum2_fx_no_sat( input_fhb, L_FRAME48k / 2 ); // 2*q_input_fhb /* Q(2*Q_input_fhb-8) */ + temp2 = W_add( temp2, W_shl( hBWE_TD->prev_fb_energy_fx, sub( q_input_fhb, hBWE_TD->prev_fb_energy_fx_Q ) ) ); // 2*q_input_fhb + + temp1 = sum2_fx_no_sat( input_fhb + L_FRAME48k / 2, L_FRAME48k / 2 ); // 2*q_input_fhb + exp = W_norm( temp1 ); + temp1 = W_shl( temp1, exp ); // 2*q_input_fhb+exp + hBWE_TD->prev_fb_energy_fx = W_extract_h( temp1 ); // 2*q_input_fhb+exp-32 move32(); - hBWE_TD->prev_fb_energy_fx_Q = sub( add( exp_temp, exp_temp ), 8 ); + hBWE_TD->prev_fb_energy_fx_Q = sub( add( shl( q_input_fhb, 1 ), exp ), 32 ); move16(); - fb_exc_energy = sum2_fx_mod( fb_exc, L_FRAME16k ); /* Q(2*Q_fb_exc-8) */ - /*ratio = (float) sqrt( temp2 / fb_exc_energy );*/ - L_tmp = L_max( 1, temp2 ); /*Q(2*(exp_temp)-8)*/ - exp = norm_l( L_tmp ); - tmp = extract_h( L_shl( L_tmp, exp ) ); - exp = sub( sub( 31, sub( add( exp_temp, exp_temp ), 8 ) ), exp ); /* (L_tmp in Q(2*(exp_temp)-8))*/ + fb_exc_energy = sum2_fx_no_sat( fb_exc, L_FRAME16k ); // 2*Q_fb_exc - exp2 = norm_l( fb_exc_energy ); - tmp2 = extract_h( L_shl( fb_exc_energy, exp2 ) ); - tmp1 = sub( add( Q_fb_exc, Q_fb_exc ), 8 ); /*1 - 9*/ - exp2 = sub( sub( 31, tmp1 ), exp2 ); /* (L_tmp in Q(2*(exp_temp)-8))*/ + /*ratio = (float) sqrt( temp2 / fb_exc_energy );*/ + exp = sub( W_norm( temp2 ), 1 ); + tmp = extract_h( W_extract_h( W_shl( temp2, exp ) ) ); // 2*q_input_fhb+exp-48 + exp = sub( 63, add( shl( q_input_fhb, 1 ), exp ) ); // 15-(2*q_input_fhb+exp-48) - exp = sub( exp2, exp ); /* Denormalize and substract */ - IF( GT_16( tmp2, tmp ) ) - { - tmp2 = shr( tmp2, 1 ); - exp = add( exp, 1 ); - } - IF( 0 != tmp ) - { - tmp = div_s( tmp2, tmp ); - L_tmp = L_deposit_h( tmp ); - L_tmp = Isqrt_lc( L_tmp, &exp ); /*Q(31-exp)*/ -#ifdef BASOP_NOGLOB - L_tmp = L_max( L_shr_o( L_tmp, sub( 31, exp ), &Overflow ), 0x1 ); /* Q0 */ -#else - L_tmp = L_max( L_shr( L_tmp, sub( 31, exp ) ), 0x1 ); /* Q0 */ -#endif - } - ELSE - { - L_tmp = 0; - move32(); - } + exp2 = W_norm( fb_exc_energy ); + tmp2 = extract_h( W_extract_h( W_shl( fb_exc_energy, exp2 ) ) ); // 2*Q_fb_exc+exp2-48 + exp2 = sub( 63, add( shl( Q_fb_exc, 1 ), exp2 ) ); // 15-(2*Q_fb_exc+exp2-48) - /* idxGain = (short)( log2_f ((float)ratio) + 0.5f ); - idxGain = max( 0, min(15,idxGain) ); */ ratio = 0; + idxGain = 0; + move16(); move16(); - IF( GE_32( L_tmp, 32768 ) ) - { - idxGain = 15; - move16(); - } - ELSE - { - ratio = extract_l( L_tmp ); - exp_norm = norm_s( ratio ); - idxGain = sub( 14, exp_norm ); - idxGain = s_max( 0, idxGain ); - } - test(); test(); - IF( GT_16( idxGain, 2 ) && LT_16( idxGain, 15 ) && GT_16( ratio, add( shl( 2, sub( idxGain, 1 ) ), shl( 2, sub( idxGain, 2 ) ) ) ) ) - { - idxGain = add( idxGain, 1 ); + IF( tmp != 0 && tmp2 != 0 ) + { + ratio = div_s( tmp, tmp2 ); // exp: exp-exp2 + exp = sub( exp, exp2 ); + /* ratio = (float) sqrt( temp2 / fb_exc_energy ); + idxGain = (short)( log2_f ((float)ratio) + 0.5f ); + + => idxGain = (short)( log2_f (sqrt( temp2 / fb_exc_energy )) + 0.5f ) + = (short)(log2f(sqrt(temp2 / fb_exc_energy)) + log2f(sqrt(2))) + = (short)log2f(sqrt(2 * (temp2 / fb_exc_energy))) + increase the exp of division result by one, two accommodate the multiplication with 2 in sqrt + */ + exp = add( exp, 1 ); + ratio = Sqrt16( ratio, &exp ); + /* Since ratio always lie betwwen 16384 and 32767, subtract the Q of sqrt result from 14 to get the integral part of log value */ + idxGain = sub( exp, 1 ); // 14 - (15-exp) + + /* idxGain = max( 0, min( 15, idxGain ) ); */ + idxGain = s_max( 0, s_min( 15, idxGain ) ); } /* ratio = (float)(1 << idxGain);*/ @@ -7573,6 +7660,7 @@ void TBEreset_enc_fx( { set16_fx( hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 ); hBWE_TD->bwe_non_lin_prev_scale_fx = L_deposit_l( 0 ); + move32(); st_fx->prev_Q_bwe_exc = 31; move16(); } diff --git a/lib_enc/tcq_core_enc.c b/lib_enc/tcq_core_enc.c deleted file mode 100644 index d54084f0bc6c24a06147b1d7ab2b249bc7ca568d..0000000000000000000000000000000000000000 --- a/lib_enc/tcq_core_enc.c +++ /dev/null @@ -1,50 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "rom_com.h" -#include "prot.h" -#include "cnst.h" -#include "basop_util.h" -#include "basop_proto_func.h" -#include "wmc_auto.h" - -/*---------------------------------------------------------------------* - * tcq_core_LR_enc() - * - * Main Generic Audio Encoder Routine for LR-MDCT - *---------------------------------------------------------------------*/ diff --git a/lib_enc/tcq_core_enc_fx.c b/lib_enc/tcq_core_enc_fx.c index 7ff5a9637a1fa02501ee46d79b99fab7d3b9f4db..fbd9775c4e8a31aba8c0b02a9b8e91b786ca7c3d 100644 --- a/lib_enc/tcq_core_enc_fx.c +++ b/lib_enc/tcq_core_enc_fx.c @@ -57,6 +57,13 @@ ivas_error tcq_core_LR_enc_fx( Word32 Rk_sort_fx[NB_SFM]; Word32 step_scale_fx[NB_SFM]; Word16 pulses_fx, nzp_fx; + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move32(); Word32 gain_fx, crosscorr_fx, selfcorr_fx; Word16 hi, lo, exp; @@ -66,6 +73,9 @@ ivas_error tcq_core_LR_enc_fx( Word32 sepbits = 0; Word32 divider = 0; ivas_error error; + move32(); + move32(); + move32(); error = IVAS_ERR_OK; move16(); @@ -82,7 +92,7 @@ ivas_error tcq_core_LR_enc_fx( test(); test(); - IF( input_frame <= L_FRAME16k && adjustFlag == 0 && is_transient == 0 ) + IF( LE_16( input_frame, L_FRAME16k ) && adjustFlag == 0 && is_transient == 0 ) { flag_wbnb = 1; move16(); @@ -100,6 +110,8 @@ ivas_error tcq_core_LR_enc_fx( move16(); pbs_fx->numbits = L_deposit_l( 0 ); pbs_fx->numByte = L_deposit_l( 0 ); + move32(); + move32(); FOR( i = 0; i < MAX_SIZEBUF_PBITSTREAM; i++ ) { pbs_fx->buf[i] = 0; @@ -134,7 +146,7 @@ ivas_error tcq_core_LR_enc_fx( { IF( R_fx[j] > 0 ) { - nzb++; + nzb = add( nzb, 1 ); } } @@ -148,11 +160,13 @@ ivas_error tcq_core_LR_enc_fx( IF( R_fx[j] > 0 ) { R_fx[j] = L_sub( R_fx[j], ar_div( bsub_fx, nzb ) ); + move32(); IF( R_fx[j] < 0 ) { bsub_fx = L_sub( bsub_fx, L_add( ar_div( bsub_fx, nzb ), R_fx[j] ) ); R_fx[j] = L_deposit_l( 0 ); + move32(); } ELSE { @@ -186,10 +200,11 @@ ivas_error tcq_core_LR_enc_fx( move16(); FOR( j = 0; j < BANDS; j++ ) { + test(); IF( NE_16( j, k_num[0] ) && NE_16( j, k_num[1] ) ) { leftbits = L_add( leftbits, R_fx[k_sort[j]] ); - if ( R_fx[k_sort[j]] > 0 ) + IF( R_fx[k_sort[j]] > 0 ) { nzbands = add( nzbands, 1 ); } @@ -226,7 +241,7 @@ ivas_error tcq_core_LR_enc_fx( encode_position_ari_fx( parenc_fx, &coefs_norm_dec_fx[sfm_start[k_sort[k]]], size, &est_frame_bits_fx ); encode_magnitude_tcq_fx( parenc_fx, &coefs_norm_dec_fx[sfm_start[k_sort[k]]], size, npulses[k_sort[k]], nzp_fx, savedstates, &est_frame_bits_fx ); encode_signs_fx( parenc_fx, &coefs_norm_dec_fx[sfm_start[k_sort[k]]], size, nzp_fx, &est_frame_bits_fx ); - nzbands--; + nzbands = sub( nzbands, 1 ); } /* Have USQ coded band */ ELSE IF( R_fx[k_sort[k]] > 0 && EQ_16( USQ_TCQ[k_sort[k]], 1 ) ) @@ -245,7 +260,7 @@ ivas_error tcq_core_LR_enc_fx( encode_position_ari_fx( parenc_fx, &coefs_norm_dec_fx[sfm_start[k_sort[k]]], size, &est_frame_bits_fx ); encode_magnitude_usq_fx( parenc_fx, &coefs_norm_dec_fx[sfm_start[k_sort[k]]], size, npulses[k_sort[k]], nzp_fx, &est_frame_bits_fx ); encode_signs_fx( parenc_fx, &coefs_norm_dec_fx[sfm_start[k_sort[k]]], size, nzp_fx, &est_frame_bits_fx ); - nzbands--; + nzbands = sub( nzbands, 1 ); } ELSE /* Then have zero block */ { @@ -260,13 +275,15 @@ ivas_error tcq_core_LR_enc_fx( IF( R_fx[k_sort[k]] > 0 && surplus_fx < 0 ) { /* delta_fx = L_deposit_h( div_l( surplus_fx, nzbands ) ); */ - IF( nzbands <= 1 ) + IF( LE_16( nzbands, 1 ) ) { divider = 0; + move32(); } ELSE { divider = 2; + move32(); } IF( L_add( L_add( surplus_fx, sepbits ), ar_div( leftbits, divider ) ) < 0 ) @@ -274,7 +291,7 @@ ivas_error tcq_core_LR_enc_fx( /* Overflow possible => start to distribute negative surplus */ delta_fx = ar_div( surplus_fx + sepbits, nzbands ); } - else + ELSE { delta_fx = 0; } @@ -290,12 +307,15 @@ ivas_error tcq_core_LR_enc_fx( { bit_surplus_fx[0] = Mult_32_16( surplus_fx, 24576 ); /* Q16 */ bit_surplus_fx[1] = Mult_32_16( surplus_fx, 8192 ); /* Q16 */ + move32(); + move32(); } ELSE { bit_surplus_fx[0] = surplus_fx; move32(); bit_surplus_fx[1] = L_deposit_l( 0 ); + move32(); } FOR( k = 0; k < BANDS; k++ ) @@ -305,6 +325,7 @@ ivas_error tcq_core_LR_enc_fx( IF( EQ_16( k, k_num[j] ) ) { R_fx[k_sort[k]] = L_add( R_fx[k_sort[k]], bit_surplus_fx[j] ); + move32(); test(); test(); @@ -409,7 +430,9 @@ ivas_error tcq_core_LR_enc_fx( FOR( i = 0; i < L_FRAME32k; i++ ) { coefs_norm_dec_fx[i] = extract_l( L_mult0( coefs_norm_dec_fx[i], 5 ) ); + move16(); } + IF( !flag_wbnb ) { FOR( k = 0; k < BANDS; k++ ) @@ -454,11 +477,7 @@ ivas_error tcq_core_LR_enc_fx( exp = sub( norm_l( crosscorr_fx ), 1 ); gain_fx = ar_div( L_shl( crosscorr_fx, exp ), selfcorr_fx ); /* 1 + exp */ -#ifdef BASOP_NOGLOB - gain_fx = L_shl_sat( gain_fx, sub( 16, 1 + exp ) + 2 ); /* 0.2 * Q16 */ -#else - gain_fx = L_shl( gain_fx, sub( 16, 1 + exp ) + 2 ); /* 0.2 * Q16 */ -#endif + gain_fx = L_shl_sat( gain_fx, sub( 16, 1 + exp ) + 2 ); /* 0.2 * Q16 */ lo = L_Extract_lc( gain_fx, &hi ); /* Use optimal gain */ FOR( j = 0; j < sfmsize[k_sort[i]]; j++ ) @@ -467,6 +486,7 @@ ivas_error tcq_core_LR_enc_fx( move16(); coefs_quant_fx[sfm_start[k_sort[i]] + j] = L_add( L_shl( L_mult0( hi, coefs_norm_dec_fx[sfm_start[k_sort[i]] + j] ), 12 ), L_shr( L_mult0( lo, coefs_norm_dec_fx[sfm_start[k_sort[i]] + j] ), 3 ) ); /* Q12 */ + move32(); } } } @@ -518,7 +538,7 @@ ivas_error tcq_core_LR_enc_ivas_fx( move16(); move16(); move16(); - move16(); + move32(); Word32 abuffer_fx[MAX_PULSES]; Word16 mbuffer_fx[MAX_PULSES]; Word32 sbuffer_fx[MAX_PULSES]; @@ -534,9 +554,9 @@ ivas_error tcq_core_LR_enc_ivas_fx( Word32 leftbits = 0; Word32 sepbits = 0; Word32 divider = 0; - move16(); - move16(); - move16(); + move32(); + move32(); + move32(); ivas_error error; error = IVAS_ERR_OK; @@ -622,11 +642,13 @@ ivas_error tcq_core_LR_enc_ivas_fx( IF( R_fx[j] > 0 ) { R_fx[j] = L_sub( R_fx[j], ar_div( bsub_fx, nzb ) ); + move32(); IF( R_fx[j] < 0 ) { bsub_fx = L_sub( bsub_fx, L_add( ar_div( bsub_fx, nzb ), R_fx[j] ) ); R_fx[j] = L_deposit_l( 0 ); + move32(); } ELSE { @@ -660,10 +682,11 @@ ivas_error tcq_core_LR_enc_ivas_fx( move16(); FOR( j = 0; j < BANDS; j++ ) { + test(); IF( NE_16( j, k_num[0] ) && NE_16( j, k_num[1] ) ) { leftbits = L_add( leftbits, R_fx[k_sort[j]] ); - if ( R_fx[k_sort[j]] > 0 ) + IF( R_fx[k_sort[j]] > 0 ) { nzbands = add( nzbands, 1 ); } @@ -734,13 +757,15 @@ ivas_error tcq_core_LR_enc_ivas_fx( IF( R_fx[k_sort[k]] > 0 && surplus_fx < 0 ) { /* delta_fx = L_deposit_h( div_l( surplus_fx, nzbands ) ); */ - IF( nzbands <= 1 ) + IF( LE_16( nzbands, 1 ) ) { divider = 0; + move32(); } ELSE { divider = 2; + move32(); } IF( L_add( L_add( surplus_fx, sepbits ), ar_div( leftbits, divider ) ) < 0 ) @@ -888,7 +913,9 @@ ivas_error tcq_core_LR_enc_ivas_fx( FOR( i = 0; i < L_FRAME32k; i++ ) { coefs_norm_dec_fx[i] = extract_l( L_mult0( coefs_norm_dec_fx[i], 5 ) ); + move16(); } + IF( !flag_wbnb ) { FOR( k = 0; k < BANDS; k++ ) @@ -903,6 +930,7 @@ ivas_error tcq_core_LR_enc_ivas_fx( } nb_bytes = shr( bit_budget, 3 ); + j = sub( bit_budget, shl( nb_bytes, 3 ) ); FOR( i = 0; i < nb_bytes; i++ ) { @@ -933,11 +961,7 @@ ivas_error tcq_core_LR_enc_ivas_fx( exp = sub( norm_l( crosscorr_fx ), 1 ); gain_fx = ar_div( L_shl( crosscorr_fx, exp ), selfcorr_fx ); /* 1 + exp */ -#ifdef BASOP_NOGLOB - gain_fx = L_shl_sat( gain_fx, sub( 16, 1 + exp ) + 2 ); /* 0.2 * Q16 */ -#else - gain_fx = L_shl( gain_fx, sub( 16, 1 + exp ) + 2 ); /* 0.2 * Q16 */ -#endif + gain_fx = L_shl_sat( gain_fx, sub( 16, 1 + exp ) + 2 ); /* 0.2 * Q16 */ lo = L_Extract_lc( gain_fx, &hi ); /* Use optimal gain */ FOR( j = 0; j < sfmsize[k_sort[i]]; j++ ) diff --git a/lib_enc/tcx_ltp_enc.c b/lib_enc/tcx_ltp_enc.c deleted file mode 100644 index 8c3c60e18ff0099bcd3230c9c2514dc481606cc6..0000000000000000000000000000000000000000 --- a/lib_enc/tcx_ltp_enc.c +++ /dev/null @@ -1,43 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "prot.h" -#include "rom_enc.h" -#include "rom_com.h" -#include "wmc_auto.h" diff --git a/lib_enc/tcx_ltp_enc_fx.c b/lib_enc/tcx_ltp_enc_fx.c index a37e8ec7783932a06b1f147e0b666fd83c10abdf..e1d478e954f3c24e06f61037b353e87727f1e15d 100644 --- a/lib_enc/tcx_ltp_enc_fx.c +++ b/lib_enc/tcx_ltp_enc_fx.c @@ -88,6 +88,7 @@ static void tcx_ltp_pitch_search( Word16 wsp2[L_FRAME_PLUS + PIT_MAX_MAX + L_INTERPOL1]; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif @@ -129,12 +130,15 @@ static void tcx_ltp_pitch_search( move16(); } wsp = wsp2 + t_max; + move16(); pt_cor = cor; + move32(); FOR( t = t_min; t <= t_max; t++ ) { *pt_cor = dot( wsp, wsp - t, len ); + move32(); pt_cor++; } @@ -142,13 +146,16 @@ static void tcx_ltp_pitch_search( cor_max = L_add( *pt_cor++, 0 ); t1 = t0_min; move16(); + move32(); - FOR( t = add( t0_min, 1 ); t <= t0_max; t++ ) + FOR( t = t0_min + 1; t <= t0_max; t++ ) { - IF( *pt_cor > cor_max ) + IF( GT_32( *pt_cor, cor_max ) ) { cor_max = *pt_cor; + move32(); t1 = t; + move16(); } pt_cor++; } @@ -174,13 +181,7 @@ static void tcx_ltp_pitch_search( temp_m = divide1616( extract_h( L_shl( cor_max, s ) ), temp_m ); temp_e = sub( negate( s ), temp_e ); -#ifdef BASOP_NOGLOB *norm_corr = shl_o( temp_m, temp_e, &Overflow ); -#else - BASOP_SATURATE_WARNING_OFF_EVS - *norm_corr = shl( temp_m, temp_e ); - BASOP_SATURATE_WARNING_ON_EVS -#endif IF( GE_16( t1, pitfr1 ) ) { @@ -227,7 +228,7 @@ static void tcx_ltp_pitch_search( t0 = sub( t0, 1 ); cor_max = interpolate_corr( &pt_cor[t0], fraction, pitres ); - FOR( i = add( fraction, step ); i < pitres; i += step ) + FOR( i = fraction + step; i < pitres; i += step ) { temp = interpolate_corr( &pt_cor[t0], i, pitres ); @@ -241,6 +242,7 @@ static void tcx_ltp_pitch_search( } i = 0; + move16(); FOR( i = 0; i < pitres; i += step ) /* Process positive fractions */ { temp = interpolate_corr( &pt_cor[t1], i, pitres ); @@ -341,6 +343,7 @@ static void tcx_ltp_pitch_search_ivas_fx( FOR( t = t_min; t <= t_max; t++ ) { *pt_cor = dot( wsp, wsp - t, len ); // 2*(x + s_wsp) + move32(); pt_cor++; } @@ -349,7 +352,7 @@ static void tcx_ltp_pitch_search_ivas_fx( t1 = t0_min; move16(); - FOR( t = add( t0_min, 1 ); t <= t0_max; t++ ) + FOR( t = t0_min + 1; t <= t0_max; t++ ) { IF( GT_32( *pt_cor, cor_max ) ) { @@ -382,13 +385,7 @@ static void tcx_ltp_pitch_search_ivas_fx( temp_m = divide1616( extract_h( L_shl( cor_max, s ) ), temp_m ); temp_e = sub( negate( s ), temp_e ); -#ifdef BASOP_NOGLOB *norm_corr = shl_o( temp_m, temp_e, &Overflow ); -#else - BASOP_SATURATE_WARNING_OFF_EVS - *norm_corr = shl( temp_m, temp_e ); - BASOP_SATURATE_WARNING_ON_EVS -#endif test(); IF( check_border_case && EQ_16( t1, t0_min ) ) @@ -415,6 +412,7 @@ static void tcx_ltp_pitch_search_ivas_fx( *index = add( sub( t1, pitfr1 ), extract_l( L_mac0( L_mult0( sub( pitfr2, pitmin ), pitres ), sub( pitfr1, pitfr2 ), shr( pitres, 1 ) ) ) ); + move16(); return; } @@ -450,7 +448,7 @@ static void tcx_ltp_pitch_search_ivas_fx( t0 = sub( t0, 1 ); cor_max = interpolate_corr( &pt_cor[t0], fraction, pitres ); - FOR( i = add( fraction, step ); i < pitres; i += step ) + FOR( i = fraction + step; i < pitres; i += step ) { temp = interpolate_corr( &pt_cor[t0], i, pitres ); @@ -487,10 +485,12 @@ static void tcx_ltp_pitch_search_ivas_fx( *index = add( extract_l( L_mac0( L_mult0( sub( t0, pitfr2 ), shr( pitres, 1 ) ), sub( pitfr2, pitmin ), pitres ) ), shr( fraction, 1 ) ); + move16(); } ELSE { *index = add( imult1616( sub( t0, pitmin ), pitres ), fraction ); + move16(); } } @@ -501,6 +501,7 @@ static void tcx_ltp_find_gain( Word16 *speech, Word16 *pred_speech, Word16 L_fra Word16 i, g, s1, s2, tmp; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif @@ -513,15 +514,9 @@ static void tcx_ltp_find_gain( Word16 *speech, Word16 *pred_speech, Word16 L_fra FOR( i = 0; i < L_frame; i++ ) { -#ifdef BASOP_NOGLOB tmp = shl_sat( pred_speech[i], s2 ); corr = L_mac0_sat( corr, shl( speech[i], s1 ), tmp ); ener = L_mac0_sat( ener, tmp, tmp ); -#else - tmp = shl( pred_speech[i], s2 ); - corr = L_mac0( corr, shl( speech[i], s1 ), tmp ); - ener = L_mac0( ener, tmp, tmp ); -#endif } s1 = sub( 1, add( s1, s2 ) ); @@ -535,26 +530,14 @@ static void tcx_ltp_find_gain( Word16 *speech, Word16 *pred_speech, Word16 L_fra ener = L_shl( ener, tmp ); s2 = sub( s2, tmp ); -#ifdef BASOP_NOGLOB g = divide1616( round_fx_o( corr, &Overflow ), round_fx_o( ener, &Overflow ) ); -#else - g = divide1616( round_fx( corr ), round_fx( ener ) ); -#endif BASOP_SATURATE_WARNING_OFF_EVS -#ifdef BASOP_NOGLOB g = shl_o( g, sub( s1, s2 ), &Overflow ); -#else /* BASOP_NOGLOB */ - g = shl( g, sub( s1, s2 ) ); -#endif /* BASOP_NOGLOB */ BASOP_SATURATE_WARNING_ON_EVS /* Quantize gain */ #ifdef FIX_ISSUE_1150 -#ifdef BASOP_NOGLOB g = shr( sub_o( g, 0x1000, &Overflow ), 13 ); -#else - g = shr( sub( g, 0x1000 ), 13 ); -#endif #else g = shr( sub( g, 0x1000 ), 13 ); #endif @@ -586,15 +569,9 @@ static void tcx_ltp_find_gain_ivas_fx( Word16 *speech /*Qx*/, Word16 *pred_speec FOR( i = 0; i < L_frame; i++ ) { -#ifdef BASOP_NOGLOB tmp = shl_sat( pred_speech[i], s2 ); // Qx + s2 corr = L_mac0_sat( corr, shl( speech[i], s1 ), tmp ); // 2*Qx + s1 + s2 ener = L_mac0_sat( ener, tmp, tmp ); // 2*(Qx+s2) -#else - tmp = shl( pred_speech[i], s2 ); - corr = L_mac0( corr, shl( speech[i], s1 ), tmp ); - ener = L_mac0( ener, tmp, tmp ); -#endif } s1 = sub( 1, add( s1, s2 ) ); @@ -608,17 +585,9 @@ static void tcx_ltp_find_gain_ivas_fx( Word16 *speech /*Qx*/, Word16 *pred_speec ener = L_shl( ener, tmp ); s2 = sub( s2, tmp ); -#ifdef BASOP_NOGLOB g = divide1616( round_fx_o( corr, &Overflow ), round_fx_o( ener, &Overflow ) ); -#else - g = divide1616( round_fx( corr ), round_fx( ener ) ); -#endif BASOP_SATURATE_WARNING_OFF_EVS -#ifdef BASOP_NOGLOB g = shl_o( g, sub( s1, s2 ), &Overflow ); /*Q15*/ -#else /* BASOP_NOGLOB */ - g = shl( g, sub( s1, s2 ) ); -#endif /* BASOP_NOGLOB */ BASOP_SATURATE_WARNING_ON_EVS /* Quantize gain */ @@ -672,6 +641,7 @@ void tcx_ltp_encode_fx( Word16 tcxltp_on, Word16 alpha, step; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif @@ -801,14 +771,14 @@ void tcx_ltp_encode_fx( Word16 tcxltp_on, *ltp_bits = 0; move16(); test(); - if ( tcxltp_on != 0 || SideInfoOnly != 0 ) + IF( tcxltp_on != 0 || SideInfoOnly != 0 ) { *ltp_bits = 1; move16(); } } - if ( SideInfoOnly != 0 ) + IF( SideInfoOnly != 0 ) { *gain = 0; move16(); @@ -826,25 +796,17 @@ void tcx_ltp_encode_fx( Word16 tcxltp_on, /* step = 1.f/(float)(L_subfr); */ step = shl( 2, norm_s( L_subfr ) ); - if ( s_and( L_subfr, sub( L_subfr, 1 ) ) != 0 ) + IF( s_and( L_subfr, sub( L_subfr, 1 ) ) != 0 ) { step = mult_r( step, 26214 /*64.f/80.f Q15*/ ); } FOR( n = 0; n < L_subfr; n++ ) { -#ifdef BASOP_NOGLOB speech_ltp[n] = sub_o( speech[n], mult_ro( *gain, mult_ro( alpha, pred_speech[n], &Overflow ), &Overflow ), &Overflow ); -#else - speech_ltp[n] = sub( speech[n], mult_r( *gain, mult_r( alpha, pred_speech[n] ) ) ); -#endif move16(); BASOP_SATURATE_WARNING_OFF_EVS; -#ifdef BASOP_NOGLOB alpha = add_o( alpha, step, &Overflow ); -#else /* BASOP_NOGLOB */ - alpha = add( alpha, step ); -#endif BASOP_SATURATE_WARNING_ON_EVS; } } @@ -867,11 +829,7 @@ void tcx_ltp_encode_fx( Word16 tcxltp_on, FOR( n = 0; n < lpcorder; n++ ) { -#ifdef BASOP_NOGLOB buf_zir[n] = add_sat( sub_sat( speech_ltp[n - lpcorder], speech[n - lpcorder] ), mult_r( *gain, buf_zir[n] ) ); -#else - buf_zir[n] = add( sub( speech_ltp[n - lpcorder], speech[n - lpcorder] ), mult_r( *gain, buf_zir[n] ) ); -#endif move16(); } @@ -882,14 +840,15 @@ void tcx_ltp_encode_fx( Word16 tcxltp_on, E_UTIL_synthesis( 0, A, zir, zir, L_subfr, buf_zir, 0, lpcorder ); alpha = 0x7FFF; + move16(); /* step = 1.f/(float)(L_subfr/2); */ step = shl( 4, norm_s( L_subfr ) ); - if ( s_and( L_subfr, sub( L_subfr, 1 ) ) != 0 ) + IF( s_and( L_subfr, sub( L_subfr, 1 ) ) != 0 ) { step = mult_r( step, 26214 /*64.f/80.f Q15*/ ); } - FOR( n = shr( L_subfr, 1 ); n < L_subfr; n++ ) + FOR( n = ( L_subfr >> 1 ); n < L_subfr; n++ ) { zir[n] = mult_r( zir[n], alpha ); move16(); @@ -898,11 +857,7 @@ void tcx_ltp_encode_fx( Word16 tcxltp_on, FOR( n = 0; n < L_subfr; n++ ) { -#ifdef BASOP_NOGLOB speech_ltp[n] = add_o( sub_o( speech[n], mult_ro( *gain, pred_speech[n], &Overflow ), &Overflow ), zir[n], &Overflow ); -#else - speech_ltp[n] = add( sub( speech[n], mult_r( *gain, pred_speech[n] ) ), zir[n] ); -#endif move16(); } } @@ -920,11 +875,7 @@ void tcx_ltp_encode_fx( Word16 tcxltp_on, { FOR( n = L_subfr; n < L_frame; n++ ) { -#ifdef BASOP_NOGLOB speech_ltp[n] = sub_o( speech[n], mult( *gain, pred_speech[n] ), &Overflow ); -#else - speech_ltp[n] = sub( speech[n], mult( *gain, pred_speech[n] ) ); -#endif move16(); } } @@ -1040,13 +991,12 @@ void tcx_ltp_encode_ivas_fx( IF( GT_16( norm_corr_2_fx[1], norm_corr_2_fx[0] ) ) { i = 1; - move16(); } ELSE { i = 0; - move16(); } + move16(); hTcxEnc->tcxltp_pitch_int = pitch_int_2[i]; move16(); @@ -1055,6 +1005,7 @@ void tcx_ltp_encode_ivas_fx( ltp_param[1] = pit_param_2[i]; move16(); norm_corr_fx = norm_corr_2_fx[i]; + move16(); } } ELSE @@ -1304,7 +1255,7 @@ void tcx_ltp_encode_ivas_fx( step_fx = mult_r( step_fx, 26214 /*64.f/80.f Q15*/ ); } - FOR( n = shr( L_subfr, 1 ); n < L_subfr; n++ ) + FOR( n = L_subfr >> 1; n < L_subfr; n++ ) { zir_fx[n] = mult_r( zir_fx[n], alpha_fx ); move16(); diff --git a/lib_enc/tcx_utils_enc.c b/lib_enc/tcx_utils_enc.c deleted file mode 100644 index cf330dfa2b09c5952b84e5bdd8a907070bc65201..0000000000000000000000000000000000000000 --- a/lib_enc/tcx_utils_enc.c +++ /dev/null @@ -1,259 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include -#include "options.h" -#include -#include "prot.h" -#include "prot_fx.h" -#include "prot_fx_enc.h" -#include "rom_com.h" -#include "cnst.h" -#include "wmc_auto.h" -#include "ivas_prot.h" - -#define ONE_POINT_ONE_FIVE_Q7 147 -#define ONE_POINT_ONE_FIVE_Q23 9646899 - - -/*---------------------------------------------------------------------* - * AdaptLowFreqEmph() - * - * - *---------------------------------------------------------------------*/ - - -/*---------------------------------------------------------------------* - * ProcessIGF_ivas_fx() - * - * - *---------------------------------------------------------------------*/ -void ProcessIGF_ivas_fx( - Encoder_State *st, /* i : Encoder state */ - Word32 *pMDCTSpectrum, /* i : MDCT spectrum (*q_spectrum) */ - const Word32 *pITFMDCTSpectrum, /* i : MDCT spectrum fir ITF */ - Word16 *q_spectrum, /* i/o: Q of spectrum */ - Word32 *pPowerSpectrum, /* i : MDCT^2 + MDST^2 spectrum, or estimate (*q_powerSpec) */ - Word16 *exp_powerSpec, /* i/o: Q of power spectrum */ - const Word16 isTCX20, /* i : flag indicating if the input is TCX20 or TCX10/2xTCX5 */ - const Word16 frameno, /* i : flag indicating index of current subframe */ - const Word16 sp_aud_decision0, /* i : first stage switching decision */ - const Word16 vad_hover_flag /* i : VAD hangover flag */ -) -{ - Word16 igfGridIdx, isIndepFlag, bsBits, pBsStart, curr_order; - Word16 predictionGain; - Word16 A[ITF_MAX_FILTER_ORDER + 1]; - Word16 q_A; - - IGF_ENC_INSTANCE_HANDLE hIGFEnc = st->hIGFEnc; - BSTR_ENC_HANDLE hBstr = st->hBstr; - - isIndepFlag = 1; - move16(); - test(); - IF( st->last_core == ACELP_CORE && isTCX20 ) - { - igfGridIdx = IGF_GRID_LB_TRAN; - move16(); - } - ELSE IF( isTCX20 ) - { - igfGridIdx = IGF_GRID_LB_NORM; - move16(); - } - ELSE - { - /* It is short block */ - igfGridIdx = IGF_GRID_LB_SHORT; - move16(); - if ( EQ_16( frameno, 1 ) ) - { - isIndepFlag = 0; - move16(); - } - } - - IGFSaveSpectrumForITF_ivas_fx( hIGFEnc, igfGridIdx, pITFMDCTSpectrum, sub( Q31, *q_spectrum ) ); - - IGFEncApplyMono_ivas_fx( st, igfGridIdx, pMDCTSpectrum, sub( Q31, *q_spectrum ), pPowerSpectrum, exp_powerSpec, isTCX20, st->hTcxEnc->fUseTns[frameno], sp_aud_decision0, vad_hover_flag ); - - curr_order = 0; - move16(); - predictionGain = 0; - move16(); - q_A = 0; - move16(); - - ITF_Detect_fx( hIGFEnc->spec_be_igf, hIGFEnc->infoStartLine, hIGFEnc->infoStopLine, 8 /*maxOrder*/, A, &q_A, &predictionGain, &curr_order, sub( 31, hIGFEnc->spec_be_igf_e ) ); - - test(); - IF( LT_32( L_deposit_l( hIGFEnc->tns_predictionGain ), 9646899 /* 1.15 in Q23 */ ) && LT_32( L_deposit_l( predictionGain ), 9646899 /* 1.15 in Q23 */ ) ) - { - hIGFEnc->flatteningTrigger = 1; - move16(); - } - ELSE - { - hIGFEnc->flatteningTrigger = 0; - move16(); - } - - hIGFEnc->infoTotalBitsPerFrameWritten = 0; - move16(); - - IF( isTCX20 ) - { - IGFEncWriteBitstream_ivas_fx( hIGFEnc, NULL, &hIGFEnc->infoTotalBitsPerFrameWritten, igfGridIdx, isIndepFlag ); - } - ELSE - { - pBsStart = hBstr->nb_ind_tot; - move16(); - - IGFEncWriteBitstream_ivas_fx( hIGFEnc, hBstr, &hIGFEnc->infoTotalBitsPerFrameWritten, igfGridIdx, isIndepFlag ); - - bsBits = sub( hBstr->nb_ind_tot, pBsStart ); - IGFEncConcatenateBitstream( hIGFEnc, bsBits, hBstr ); - } - - return; -} - -/*---------------------------------------------------------------------* - * ProcessStereoIGF() - * - * - *---------------------------------------------------------------------*/ - -void ProcessStereoIGF_fx( - STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, - Encoder_State *sts[CPE_CHANNELS], /* i : Encoder state */ - Word16 ms_mask[2][MAX_SFB], /* i : bandwise MS mask */ - Word32 *pITFMDCTSpectrum_fx[CPE_CHANNELS][NB_DIV], /* i : MDCT spectrum fir ITF */ - Word16 q_pITFMDCTSpectrum_1, - Word16 q_pITFMDCTSpectrum_2, - Word32 *pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */ - Word32 *pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i : inverse power spectrum */ - Word32 *inv_spectrum_fx[CPE_CHANNELS][NB_DIV], /* i : 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 */ -) -{ - Word16 ch, igfGridIdx, isIndepFlag, bsBits, pBsStart, curr_order; - Word16 predictionGain; - Word16 A[ITF_MAX_FILTER_ORDER + 1]; - Word16 Q_A; - IGF_ENC_INSTANCE_HANDLE hIGFEnc[CPE_CHANNELS]; - BSTR_ENC_HANDLE hBstr; - hIGFEnc[0] = sts[0]->hIGFEnc; - hIGFEnc[1] = sts[1]->hIGFEnc; - - isIndepFlag = 1; - move16(); - - test(); - IF( sts[0]->last_core == ACELP_CORE && EQ_16( sts[0]->core, TCX_20_CORE ) ) - { - igfGridIdx = IGF_GRID_LB_TRAN; - } - ELSE IF( EQ_16( sts[0]->core, TCX_20_CORE ) ) - { - igfGridIdx = IGF_GRID_LB_NORM; - } - ELSE - { - /* It is short block */ - igfGridIdx = IGF_GRID_LB_SHORT; - if ( EQ_16( frameno, 1 ) ) - { - isIndepFlag = 0; - move16(); - } - } - move16(); - - IGFSaveSpectrumForITF_ivas_fx( hIGFEnc[0], igfGridIdx, pITFMDCTSpectrum_fx[0][frameno], sub( Q31, q_pITFMDCTSpectrum_1 ) ); - - 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 ); - - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - curr_order = 0; - move16(); - - Q_A = 0; - move16(); - - predictionGain = 0; - move16(); - - ITF_Detect_fx( hIGFEnc[ch]->spec_be_igf, hIGFEnc[ch]->infoStartLine, hIGFEnc[ch]->infoStopLine, 8 /*maxOrder*/, A, &Q_A, &predictionGain, &curr_order, sub( 31, hIGFEnc[ch]->spec_be_igf_e ) ); - - test(); - hIGFEnc[ch]->flatteningTrigger = LT_32( hIGFEnc[ch]->tns_predictionGain, ONE_POINT_ONE_FIVE_Q23 ) && LT_32( predictionGain, ONE_POINT_ONE_FIVE_Q7 ); - move16(); - - hIGFEnc[ch]->infoTotalBitsPerFrameWritten = 0; - move16(); - - IF( EQ_16( sts[ch]->core, TCX_20_CORE ) ) - { - IGFEncWriteBitstream_ivas_fx( hIGFEnc[ch], NULL, &hIGFEnc[ch]->infoTotalBitsPerFrameWritten, igfGridIdx, isIndepFlag ); - } - ELSE - { - hBstr = sts[ch]->hBstr; - pBsStart = hBstr->nb_ind_tot; - move16(); - - if ( ch > 0 ) - { - hBstr->ind_list = sts[0]->hBstr->ind_list + sts[0]->hBstr->nb_ind_tot; - } - IGFEncWriteBitstream_ivas_fx( hIGFEnc[ch], hBstr, &hIGFEnc[ch]->infoTotalBitsPerFrameWritten, igfGridIdx, isIndepFlag ); - - bsBits = sub( hBstr->nb_ind_tot, pBsStart ); - IGFEncConcatenateBitstream( hIGFEnc[ch], bsBits, hBstr ); - } - } - return; -} diff --git a/lib_enc/tcx_utils_enc_fx.c b/lib_enc/tcx_utils_enc_fx.c index 7098e4502c1311f8ef380b390cae106204e5c93b..1e35c78c4c590651080c7e4bb8877217efafdb25 100644 --- a/lib_enc/tcx_utils_enc_fx.c +++ b/lib_enc/tcx_utils_enc_fx.c @@ -15,10 +15,14 @@ #include "rom_com.h" #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ +#include "ivas_prot_fx.h" #define inv_int InvIntTable extern const Word16 int_sqr[17]; +#define ONE_POINT_ONE_FIVE_Q7 147 +#define ONE_POINT_ONE_FIVE_Q23 9646899 + static Word16 quantize( Word32 x, Word16 invGain, Word16 shift, Word32 offset ) { Word16 tmp16; @@ -28,8 +32,10 @@ static Word16 quantize( Word32 x, Word16 invGain, Word16 shift, Word32 offset ) tmp32 = L_shl( tmp32, shift ); /* convert to 15Q16 */ tmp32 = L_add( tmp32, offset ); /* add offset */ tmp16 = extract_h( tmp32 ); /* truncate */ - if ( x < 0 ) + IF( x < 0 ) + { tmp16 = negate( tmp16 ); /* restore sign */ + } return tmp16; } @@ -46,6 +52,7 @@ void ComputeSpectrumNoiseMeasure_fx( const Word32 *powerSpec, Word32 s, c; Word16 tmp16; Word32 tmp1, tmp2 = 0; /* initialization only to avoid compiler warning, not counted */ + move32(); int j; @@ -79,7 +86,7 @@ void ComputeSpectrumNoiseMeasure_fx( const Word32 *powerSpec, s = L_add( s, L_shr( powerSpec[i + j], 4 ) ); } tmp16 = sub( lowpassLine, 7 ); - FOR( i = add( i, 1 ); i < tmp16; i++ ) + FOR( i = i + 1; i < tmp16; i++ ) { c = L_shr( powerSpec[i - 1], 4 ); c = L_add( c, L_shr( powerSpec[i], 4 ) ); @@ -89,12 +96,18 @@ void ComputeSpectrumNoiseMeasure_fx( const Word32 *powerSpec, s = L_add( s, L_shr( powerSpec[i + 7], 4 ) ); tmp1 = L_shr( c, 2 ); - if ( noiseFlags[i] == 0 ) + IF( noiseFlags[i] == 0 ) + { c = L_shl( c, 1 ); - if ( noiseFlags[i] == 0 ) + } + IF( noiseFlags[i] == 0 ) + { tmp2 = L_sub( c, tmp1 ); /* 1.75 * c */ - if ( noiseFlags[i] != 0 ) + } + IF( noiseFlags[i] != 0 ) + { tmp2 = L_add( c, tmp1 ); /* 1.25 * c */ + } tmp2 = L_sub( s, tmp2 ); if ( tmp2 >= 0 ) @@ -123,12 +136,18 @@ void ComputeSpectrumNoiseMeasure_fx( const Word32 *powerSpec, c = L_add( c, L_shr( powerSpec[i + 1], 4 ) ); tmp1 = L_shr( c, 2 ); - if ( noiseFlags[i] == 0 ) + IF( noiseFlags[i] == 0 ) + { c = L_shl( c, 1 ); - if ( noiseFlags[i] == 0 ) + } + IF( noiseFlags[i] == 0 ) + { tmp2 = L_sub( c, tmp1 ); /* 1.75 * c */ - if ( noiseFlags[i] != 0 ) + } + IF( noiseFlags[i] != 0 ) + { tmp2 = L_add( c, tmp1 ); /* 1.25 * c */ + } /* running sum can't be updated any more, just use the latest one */ tmp2 = L_sub( s, tmp2 ); @@ -161,30 +180,24 @@ static void detectLowpassFac( const Word32 *powerSpec, Word16 powerSpec_e, Word1 Word32 threshold; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif threshold = 256l /*0.1f * 2*NORM_MDCT_FACTOR Q3*/; /* Q3 */ - BASOP_SATURATE_WARNING_OFF_EVS /* Allow saturation, because threshold is being compared to powerSpec[i] below. */ -#ifdef BASOP_NOGLOB + move32(); + BASOP_SATURATE_WARNING_OFF_EVS /* Allow saturation, because threshold is being compared to powerSpec[i] below. */ threshold = L_shl_o( threshold, sub( 28, powerSpec_e ), &Overflow ); -#else /* BASOP_NOGLOB */ - threshold = L_shl( threshold, sub( 28, powerSpec_e ) ); -#endif /* BASOP_NOGLOB */ - if ( rectWin != 0 ) + IF( rectWin != 0 ) { /* compensate for bad side-lobe attenuation with asymmetric windows */ -#ifdef BASOP_NOGLOB threshold = L_shl_o( threshold, 1, &Overflow ); -#else - threshold = L_shl( threshold, 1 ); -#endif } BASOP_SATURATE_WARNING_ON_EVS tmp = shr( lowpassLine, 1 ); - FOR( i = sub( lowpassLine, 1 ); i >= tmp; i-- ) + FOR( i = lowpassLine - 1; i >= tmp; i-- ) { IF( GT_32( powerSpec[i], threshold ) ) { @@ -245,7 +258,7 @@ void AnalyzePowerSpectrum_fx( s2 = 0; move16(); tmp = sub( mdctSpectrum_e, *powerSpec_e ); - if ( tmp > 0 ) + IF( tmp > 0 ) { s2 = negate( tmp ); } @@ -264,18 +277,10 @@ void AnalyzePowerSpectrum_fx( /* power spectrum: MDCT^2 + MDST^2 */ FOR( i = iStart; i < iEnd; i++ ) { -#ifdef BASOP_NOGLOB tmp = round_fx_sat( L_shl_sat( mdctSpectrum[i], s1 ) ); -#else - tmp = round_fx( L_shl( mdctSpectrum[i], s1 ) ); -#endif tmp32 = L_mult0( tmp, tmp ); -#ifdef BASOP_NOGLOB tmp = round_fx_sat( L_shl_sat( powerSpec[i], s2 ) ); -#else - tmp = round_fx( L_shl( powerSpec[i], s2 ) ); -#endif tmp32 = L_mac0( tmp32, tmp, tmp ); powerSpec[i] = tmp32; @@ -305,7 +310,6 @@ void AnalyzePowerSpectrum_fx( { lowpassLine = shl( mult( st->hTcxCfg->bandwidth, L_frame ), 1 ); - test(); detectLowpassFac( powerSpec, *powerSpec_e, L_frame, sub( st->last_core, ACELP_CORE ) == 0, @@ -405,7 +409,6 @@ void AnalyzePowerSpectrum_ivas_fx( { lowpassLine = shl( mult( st->hTcxCfg->bandwidth, L_frame ), 1 ); - test(); detectLowpassFac( common_powerSpec, temp_powerSpec_e, L_frame, sub( st->last_core, ACELP_CORE ) == 0, @@ -453,6 +456,7 @@ void AdaptLowFreqEmph_fx( Word32 x[], /* Debug initialization to catch illegal cases of xq[i] */ tmp16 = 0; + move16(); if ( xq[i] > 0 ) { @@ -506,6 +510,7 @@ void AdaptLowFreqEmph_fx( Word32 x[], /* Debug initialization to catch illegal cases of xq[i] */ tmp16 = 0; + move16(); if ( xq[i] > 0 ) { @@ -559,6 +564,7 @@ void AdaptLowFreqEmph_fx( Word32 x[], /* Debug initialization to catch illegal cases of xq[i] */ tmp16 = 0; + move16(); if ( xq[i] > 0 ) { @@ -591,6 +597,7 @@ void AdaptLowFreqEmph_fx( Word32 x[], /* Debug initialization to catch illegal cases of xq[i] */ tmp16 = 0; + move16(); if ( xq[i] > 0 ) { @@ -709,20 +716,27 @@ Word16 SQ_gain_fx( /* output: SQ gain */ move16(); tmp16 = norm_l( x[0] ); - if ( x[0] != 0 ) + IF( x[0] != 0 ) + { s = s_min( s, tmp16 ); + } tmp16 = norm_l( x[1] ); - if ( x[1] != 0 ) + IF( x[1] != 0 ) + { s = s_min( s, tmp16 ); + } tmp16 = norm_l( x[2] ); - if ( x[2] != 0 ) + IF( x[2] != 0 ) + { s = s_min( s, tmp16 ); - + } tmp16 = norm_l( x[3] ); - if ( x[3] != 0 ) + IF( x[3] != 0 ) + { s = s_min( s, tmp16 ); + } s = sub( s, 2 ); /* 2 bits headroom */ @@ -767,7 +781,7 @@ Word16 SQ_gain_fx( /* output: SQ gain */ tmp32 = L_sub( en[i], offset ); /* avoid SV with 1 bin of amp < 0.5f */ - if ( GT_32( tmp32, 0xFF20 ) ) /* 0xFF20 -> 0.3*log2(10); */ + IF( GT_32( tmp32, 0xFF20 ) ) /* 0xFF20 -> 0.3*log2(10); */ { ener = L_add( ener, tmp32 ); } @@ -816,20 +830,28 @@ Word16 SQ_gain_ivas_fx( /* output: SQ gain */ move16(); tmp16 = norm_l( x[0] ); - if ( x[0] != 0 ) + IF( x[0] != 0 ) + { s = s_min( s, tmp16 ); + } tmp16 = norm_l( x[1] ); - if ( x[1] != 0 ) + IF( x[1] != 0 ) + { s = s_min( s, tmp16 ); + } tmp16 = norm_l( x[2] ); - if ( x[2] != 0 ) + IF( x[2] != 0 ) + { s = s_min( s, tmp16 ); + } tmp16 = norm_l( x[3] ); - if ( x[3] != 0 ) + IF( x[3] != 0 ) + { s = s_min( s, tmp16 ); + } s = sub( s, 2 ); /* 2 bits headroom */ @@ -882,7 +904,7 @@ Word16 SQ_gain_ivas_fx( /* output: SQ gain */ tmp32 = L_sub( en[i], offset ); /* avoid SV with 1 bin of amp < 0.5f */ - if ( GT_32( tmp32, 0xFF20 ) ) /* 0xFF20 -> 0.3*log2(10); */ + IF( GT_32( tmp32, 0xFF20 ) ) /* 0xFF20 -> 0.3*log2(10); */ { ener = L_add( ener, tmp32 ); } @@ -943,6 +965,7 @@ Word16 SQ_gain_estimate_fx( /* output: SQ gain tmp = 204644; tmpp = 0; move32(); + move32(); BREAK; case 200: tmp = 215192; @@ -1042,20 +1065,28 @@ Word16 SQ_gain_estimate_fx( /* output: SQ gain move16(); tmp16 = norm_l( x[0] ); - if ( x[0] != 0 ) + IF( x[0] != 0 ) + { s = s_min( s, tmp16 ); + } tmp16 = norm_l( x[1] ); - if ( x[1] != 0 ) + IF( x[1] != 0 ) + { s = s_min( s, tmp16 ); + } tmp16 = norm_l( x[2] ); - if ( x[2] != 0 ) + IF( x[2] != 0 ) + { s = s_min( s, tmp16 ); + } tmp16 = norm_l( x[3] ); - if ( x[3] != 0 ) + IF( x[3] != 0 ) + { s = s_min( s, tmp16 ); + } s = sub( s, 2 ); /* 2 bits headroom */ @@ -1148,6 +1179,8 @@ void tcx_scalar_quantization_fx( tmp16 = negate( s_max( tmp16, 0 ) ); i = sub( L_frame, 1 ); + + test(); WHILE( ( memQuantZeros_fx[i] != 0 ) && ( LT_32( L_abs( L_shl( x[i], tmp16 ) ), tmp32 ) ) ) { test(); @@ -1167,6 +1200,8 @@ void tcx_scalar_quantization_fx( /* Limit the inverse gain to maximal possible value=sqrtL_spec/NORM_MDCT_FACTOR)*/ gain = 22435; /*sqrt(1200/NORM_MDCT_FACTOR) in 2Q13*/ gain_e = 2; + move16(); + move16(); s = sub( add( x_e, gain_e ), 15 ); } @@ -1179,15 +1214,12 @@ void tcx_scalar_quantization_fx( FOR( ; i >= 0; i-- ) { offs32 = Mpy_32_16_1( L_abs( x[i] ), gain ); /* multiply */ -#ifdef BASOP_NOGLOB - offs32 = L_shl_sat( offs32, s ); /* convert to 15Q16 */ - tmp16 = mac_r_sat( offs32, offset, 1 ); /* add offset and truncate */ -#else - offs32 = L_shl( offs32, s ); /* convert to 15Q16 */ - tmp16 = mac_r( offs32, offset, 1 ); /* add offset and truncate */ -#endif - if ( x[i] < 0 ) + offs32 = L_shl_sat( offs32, s ); /* convert to 15Q16 */ + tmp16 = mac_r_sat( offs32, offset, 1 ); /* add offset and truncate */ + IF( x[i] < 0 ) + { tmp16 = negate( tmp16 ); /* restore sign */ + } xq[i] = tmp16; move16(); @@ -1244,7 +1276,9 @@ void tcx_scalar_quantization_ivas_fx( { /* Limit the inverse gain to maximal possible value=sqrtL_spec/NORM_MDCT_FACTOR)*/ gain = 22435; /*sqrt(1200/NORM_MDCT_FACTOR) in 2Q13*/ + move16(); gain_e = 2; + move16(); s = sub( add( x_e, gain_e ), 15 ); } @@ -1257,15 +1291,12 @@ void tcx_scalar_quantization_ivas_fx( FOR( ; i >= 0; i-- ) { offs32 = Mpy_32_16_1( L_abs( x[i] ), gain ); /* multiply */ -#ifdef BASOP_NOGLOB - offs32 = L_shl_sat( offs32, s ); /* convert to 15Q16 */ - tmp16 = mac_r_sat( offs32, offset, 1 ); /* add offset and truncate */ -#else - offs32 = L_shl( offs32, s ); /* convert to 15Q16 */ - tmp16 = mac_r( offs32, offset, 1 ); /* add offset and truncate */ -#endif - if ( x[i] < 0 ) + offs32 = L_shl_sat( offs32, s ); /* convert to 15Q16 */ + tmp16 = mac_r_sat( offs32, offset, 1 ); /* add offset and truncate */ + IF( x[i] < 0 ) + { tmp16 = negate( tmp16 ); /* restore sign */ + } xq[i] = tmp16; move16(); @@ -1319,6 +1350,10 @@ Word16 tcx_scalar_quantization_rateloop_fx( Word16 tmp, fac1, fac2; Word32 tmp32; Word16 lastnz; + move16(); + move16(); + move16(); + move16(); /* Init */ @@ -1393,11 +1428,7 @@ Word16 tcx_scalar_quantization_rateloop_fx( /* convert to normalized 16 bit */ tmp = norm_l( tmp32 ); -#ifdef BASOP_NOGLOB sqGain = round_fx_sat( L_shl( tmp32, tmp ) ); -#else - sqGain = round_fx( L_shl( tmp32, tmp ) ); -#endif sqGain_e = sub( sqGain_e, tmp ); /* divide */ @@ -1433,11 +1464,7 @@ Word16 tcx_scalar_quantization_rateloop_fx( /* convert to normalized 16 bit */ tmp = norm_l( tmp32 ); -#ifdef BASOP_NOGLOB sqGain = round_fx_sat( L_shl_sat( tmp32, tmp ) ); -#else - sqGain = round_fx( L_shl( tmp32, tmp ) ); -#endif sqGain_e = sub( sqGain_e, tmp ); /* divide */ @@ -1761,11 +1788,7 @@ Word16 tcx_scalar_quantization_rateloop_ivas_fx( /* convert to normalized 16 bit */ tmp = norm_l( tmp32 ); -#ifdef BASOP_NOGLOB sqGain = round_fx_sat( L_shl( tmp32, tmp ) ); -#else - sqGain = round_fx( L_shl( tmp32, tmp ) ); -#endif sqGain_e = sub( sqGain_e, tmp ); /* divide */ @@ -1801,11 +1824,7 @@ Word16 tcx_scalar_quantization_rateloop_ivas_fx( /* convert to normalized 16 bit */ tmp = norm_l( tmp32 ); -#ifdef BASOP_NOGLOB sqGain = round_fx_sat( L_shl_sat( tmp32, tmp ) ); -#else - sqGain = round_fx( L_shl( tmp32, tmp ) ); -#endif sqGain_e = sub( sqGain_e, tmp ); /* divide */ @@ -1820,6 +1839,7 @@ Word16 tcx_scalar_quantization_rateloop_ivas_fx( } Word16 shift_tmp = s_max( sqGain_e, 1 ); + move16(); test(); IF( LT_16( shl( sqGain, sub( sqGain_e, shift_tmp ) ), shl( minSqGain, sub( 1, shift_tmp ) ) ) && EQ_16( tcxRateLoopOpt, 3 ) ) { @@ -1983,11 +2003,7 @@ void QuantizeGain( Word16 n, Word16 *pGain, Word16 *pGain_e, Word16 *pQuantizedG move32(); #endif -#ifdef BASOP_NOGLOB ener = mult_r( shl_o( n, 5, &Overflow ), 26214 /*128.f/NORM_MDCT_FACTOR Q15*/ ); -#else - ener = mult_r( shl( n, 5 ), 26214 /*128.f/NORM_MDCT_FACTOR Q15*/ ); -#endif ener_e = 15 - 5 - 7; move16(); IF( GE_16( n, 1024 ) ) @@ -2059,6 +2075,7 @@ void tcx_noise_factor_fx( Word32 xMax; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif @@ -2143,19 +2160,19 @@ void tcx_noise_factor_fx( k = 0; move16(); - if ( accu1 == 0 ) + IF( accu1 == 0 ) + { accu1 = L_deposit_l( 1 ); - if ( accu2 == 0 ) + } + IF( accu2 == 0 ) + { accu2 = L_deposit_l( 1 ); + } att = BASOP_Util_Divide3232_Scale( L_shl( L_min( accu1, accu2 ), 1 ), L_add( accu1, accu2 ), &s ); att = Sqrt16( att, &s ); BASOP_SATURATE_WARNING_OFF_EVS; /* att is always <= 1.0 */ -#ifdef BASOP_NOGLOB att = shl_o( att, s, &Overflow ); -#else - att = shl( att, s ); -#endif BASOP_SATURATE_WARNING_ON_EVS; } ELSE @@ -2180,22 +2197,34 @@ void tcx_noise_factor_fx( IF( LE_16( nTransWidth, 3 ) ) { tmp2 = sub( k, c1 ); - if ( tmp2 > 0 ) + IF( tmp2 > 0 ) + { n = L_msu( n, k, (Word16) 0x8000 ); - if ( tmp2 > 0 ) + } + IF( tmp2 > 0 ) + { n = L_mac( n, nTransWidth_1, (Word16) 0x8000 ); - if ( tmp2 <= 0 ) + } + IF( tmp2 <= 0 ) + { n = L_mac( n, int_sqr[k], c2 ); + } } ELSE { tmp2 = sub( k, 12 ); - if ( tmp2 > 0 ) + IF( tmp2 > 0 ) + { n = L_msu( n, k, (Word16) 0x8000 ); - if ( tmp2 > 0 ) + } + IF( tmp2 > 0 ) + { n = L_sub( n, 0x70000 ); - if ( tmp2 <= 0 ) + } + IF( tmp2 <= 0 ) + { n = L_mac( n, int_sqr[k], 1152 /*0.03515625f Q15*/ ); + } } sqErrorNrg = L_add( sqErrorNrg, accu1 ); accu1 = L_deposit_l( 0 ); /* segment ended here, so reset segment sum */ @@ -2214,19 +2243,19 @@ void tcx_noise_factor_fx( } ELSE /* current line is zero, so update pointers & segment sum */ { - if ( LT_16( k, nTransWidth ) ) + IF( LT_16( k, nTransWidth ) ) { k = add( k, 1 ); } tmp2 = sub( maxK, nTransWidth ); - if ( tmp2 < 0 ) + IF( tmp2 < 0 ) { maxK = sub( maxK, 1 ); } test(); - if ( ( tmp2 >= 0 ) && ( sqQ[i + sub( nTransWidth, 1 )] != 0 ) ) + IF( ( tmp2 >= 0 ) && ( sqQ[i + sub( nTransWidth, 1 )] != 0 ) ) { maxK = sub( nTransWidth, 1 ); } @@ -2251,22 +2280,34 @@ void tcx_noise_factor_fx( IF( LE_16( nTransWidth, 3 ) ) { tmp2 = sub( k, c1 ); - if ( tmp2 > 0 ) + IF( tmp2 > 0 ) + { n = L_msu( n, k, (Word16) 0x8000 ); - if ( tmp2 > 0 ) + } + IF( tmp2 > 0 ) + { n = L_mac( n, nTransWidth_1, (Word16) 0x8000 ); - if ( tmp2 <= 0 ) + } + IF( tmp2 <= 0 ) + { n = L_mac( n, int_sqr[k], c2 ); + } } ELSE { tmp2 = sub( k, 12 ); - if ( tmp2 > 0 ) + IF( tmp2 > 0 ) + { n = L_msu( n, k, (Word16) 0x8000 ); - if ( tmp2 > 0 ) + } + IF( tmp2 > 0 ) + { n = L_sub( n, 0x70000 ); - if ( tmp2 <= 0 ) + } + IF( tmp2 <= 0 ) + { n = L_mac( n, int_sqr[k], 1152 /*0.03515625f Q15*/ ); + } } sqErrorNrg = L_add( sqErrorNrg, accu1 ); } @@ -2274,11 +2315,11 @@ void tcx_noise_factor_fx( } ELSE /* current line is zero, so update pointers & energy sum */ { - if ( LT_16( k, nTransWidth ) ) + IF( LT_16( k, nTransWidth ) ) { k = add( k, 1 ); } - if ( LT_16( maxK, nTransWidth ) ) + IF( LT_16( maxK, nTransWidth ) ) { maxK = sub( maxK, 1 ); } @@ -2296,22 +2337,34 @@ void tcx_noise_factor_fx( IF( LE_16( nTransWidth, 3 ) ) { tmp2 = sub( k, c1 ); - if ( tmp2 > 0 ) + IF( tmp2 > 0 ) + { n = L_msu( n, k, (Word16) 0x8000 ); - if ( tmp2 > 0 ) + } + IF( tmp2 > 0 ) + { n = L_mac( n, nTransWidth_1, (Word16) 0x8000 ); - if ( tmp2 <= 0 ) + } + IF( tmp2 <= 0 ) + { n = L_mac( n, int_sqr[k], c2 ); + } } ELSE { tmp2 = sub( k, 12 ); - if ( tmp2 > 0 ) + IF( tmp2 > 0 ) + { n = L_msu( n, k, (Word16) 0x8000 ); - if ( tmp2 > 0 ) + } + IF( tmp2 > 0 ) + { n = L_sub( n, 0x70000 ); - if ( tmp2 <= 0 ) + } + IF( tmp2 <= 0 ) + { n = L_mac( n, int_sqr[k], 1152 /*0.03515625f Q15*/ ); + } } sqErrorNrg = L_add( sqErrorNrg, accu1 ); } @@ -2322,11 +2375,7 @@ void tcx_noise_factor_fx( tmp1 = BASOP_Util_Divide3232_Scale( Mpy_32_16_1( sqErrorNrg, att ), n, &s ); s = add( add( add( s, x_orig_e ), inv_gain2_e ), 7 - 15 ); BASOP_SATURATE_WARNING_OFF_EVS; -#ifdef BASOP_NOGLOB tmp1 = shl_o( tmp1, s, &Overflow ); -#else /* BASOP_NOGLOB */ - tmp1 = shl( tmp1, s ); -#endif BASOP_SATURATE_WARNING_ON_EVS; } ELSE @@ -2350,6 +2399,7 @@ void tcx_noise_factor_fx( *fac_ns = extract_l( L_mult0( *quantized_fac_ns, shr( 24576 /*0.75f Q15*/, NBITS_NOISE_FILL_LEVEL ) ) ); } + void tcx_noise_factor_ivas_fx( Word32 *x_orig, /* i: unquantized mdct coefficients */ Word16 x_orig_e, /* i: exponent */ @@ -2366,29 +2416,32 @@ void tcx_noise_factor_ivas_fx( Word16 element_mode /* i: element mode */ ) { - Word16 i, k = 0, maxK, segmentOffset; - Word32 sqErrorNrg, n; - Word16 inv_gain2, inv_gain2_e, tilt_factor, nTransWidth_1; + Word16 i, k, win, segmentOffset, j; + Word32 sqErrorNrg = 0, n; + move32(); + Word16 inv_gain2, inv_gain2_e, tilt_factor, nTransWidth_1, exp_sqErrorNrg = 0; + move16(); Word32 accu1, accu2, tmp32; Word16 tmp1, tmp2, s; Word16 c1, c2; Word16 att; /* noise level attenuation factor for transient windows */ Word32 xMax; + Word16 exp_spQ[N_MAX]; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); #endif - move16(); assert( nTransWidth <= 16 ); + set16_fx( exp_spQ, x_orig_e, N_MAX ); c1 = sub( shl( nTransWidth, 1 ), 4 ); c2 = mult( 9216 /*0.28125f Q15*/, inv_int[nTransWidth] ); nTransWidth_1 = sub( nTransWidth, 1 ); /*Adjust noise filling level*/ - sqErrorNrg = L_deposit_l( 0 ); - n = L_deposit_l( 0 ); + n = 0; + move32(); /* get inverse frame length */ tmp1 = getInvFrameLen( L_frame ); @@ -2400,10 +2453,8 @@ void tcx_noise_factor_ivas_fx( /* inv_gain2 = 1.0f / ((float)(nTransWidth * nTransWidth) * gain_tcx); */ tmp32 = L_mult( imult1616( nTransWidth, nTransWidth ), gain_tcx ); /* 15Q16 */ - tmp1 = norm_l( tmp32 ); - inv_gain2 = round_fx( L_shl( tmp32, tmp1 ) ); - inv_gain2_e = add( sub( 15, tmp1 ), gain_tcx_e ); - inv_gain2 = Inv16( inv_gain2, &inv_gain2_e ); + inv_gain2 = BASOP_Util_Divide3232_Scale( MAX_32, tmp32, &inv_gain2_e ); + inv_gain2_e = add( inv_gain2_e, sub( 0, add( 15, gain_tcx_e ) ) ); inv_gain2 = shr( inv_gain2, 2 ); /* 2 bits headroom */ inv_gain2_e = add( inv_gain2_e, 2 ); @@ -2414,15 +2465,13 @@ void tcx_noise_factor_ivas_fx( IF( EQ_16( element_mode, IVAS_CPE_MDCT ) ) /* ... but only in mono or parametric stereo since it may cause binaural unmasking in discrete stereo */ { segmentOffset = i; - maxK = 1; - move16(); move16(); } ELSE { /* find last nonzero line below iFirstLine, use it as start offset */ tmp1 = shr( iFirstLine, 1 ); - FOR( i = iFirstLine; i > tmp1; i-- ) + FOR( ; i > tmp1; i-- ) { IF( sqQ[i] != 0 ) { @@ -2435,16 +2484,6 @@ void tcx_noise_factor_ivas_fx( inv_gain2 = shl( mult( inv_gain2, tilt_factor ), 1 ); } - /* initialize left (k) and right (maxK) non-zero neighbor pointers */ - k = 0; - move16(); - FOR( maxK = 1; maxK < nTransWidth; maxK++ ) - { - IF( sqQ[i + maxK] != 0 ) - { - BREAK; - } - } i = add( i, 1 ); segmentOffset = i; move16(); @@ -2452,17 +2491,20 @@ void tcx_noise_factor_ivas_fx( IF( LE_16( nTransWidth, 3 ) ) { - accu1 = L_deposit_l( 0 ); - accu2 = L_deposit_l( 0 ); - xMax = L_deposit_l( 0 ); + accu1 = 0; + move32(); + accu2 = 0; + move32(); + xMax = 0; + move32(); - FOR( k = s_and( i, (Word16) 0xFFFE ); k < lowpassLine; k++ ) + FOR( k = i & 0xFFFE; k < lowpassLine; k++ ) { xMax = L_max( xMax, L_abs( x_orig[k] ) ); } s = sub( norm_l( xMax ), 4 ); - FOR( k = s_and( i, (Word16) 0xFFFE ); k < lowpassLine; k += 2 ) + FOR( k = i & 0xFFFE; k < lowpassLine; k += 2 ) { /* even-index bins, left sub-win */ tmp1 = round_fx( L_shl( x_orig[k], s ) ); @@ -2476,18 +2518,20 @@ void tcx_noise_factor_ivas_fx( move16(); if ( accu1 == 0 ) - accu1 = L_deposit_l( 1 ); + { + accu1 = 1; + move32(); + } if ( accu2 == 0 ) - accu2 = L_deposit_l( 1 ); + { + accu2 = 1; + move32(); + } att = BASOP_Util_Divide3232_Scale( L_shl( L_min( accu1, accu2 ), 1 ), L_add( accu1, accu2 ), &s ); att = Sqrt16( att, &s ); BASOP_SATURATE_WARNING_OFF_EVS; /* att is always <= 1.0 */ -#ifdef BASOP_NOGLOB att = shl_o( att, s, &Overflow ); -#else - att = shl( att, s ); -#endif BASOP_SATURATE_WARNING_ON_EVS; } ELSE @@ -2496,181 +2540,161 @@ void tcx_noise_factor_ivas_fx( move16(); } - accu1 = L_deposit_l( 0 ); + win = 0; + move16(); - tmp1 = sub( lowpassLine, nTransWidth ); - FOR( ; i <= tmp1; i++ ) + FOR( ; i < lowpassLine; i++ ) { inv_gain2 = shl( mult( inv_gain2, tilt_factor ), 1 ); - IF( EQ_16( maxK, 1 ) ) /* current line is not zero, so reset pointers */ + IF( sqQ[i] != 0 ) /* current line is not zero, so reset pointers */ { - k = sub( i, segmentOffset ); - - IF( k > 0 ) /* add segment sum to sum of segment magnitudes */ + IF( win > 0 ) { + k = sub( i, segmentOffset ); + IF( LE_16( nTransWidth, 3 ) ) { tmp2 = sub( k, c1 ); - if ( tmp2 > 0 ) + IF( tmp2 > 0 ) + { n = L_msu( n, k, (Word16) 0x8000 ); - if ( tmp2 > 0 ) + } + IF( tmp2 > 0 ) + { n = L_mac( n, nTransWidth_1, (Word16) 0x8000 ); - if ( tmp2 <= 0 ) + } + IF( tmp2 <= 0 ) + { n = L_mac( n, int_sqr[k], c2 ); + } } ELSE { tmp2 = sub( k, 12 ); - if ( tmp2 > 0 ) + IF( tmp2 > 0 ) + { n = L_msu( n, k, (Word16) 0x8000 ); - if ( tmp2 > 0 ) + } + IF( tmp2 > 0 ) + { n = L_sub( n, 0x70000 ); - if ( tmp2 <= 0 ) + } + IF( tmp2 <= 0 ) + { n = L_mac( n, int_sqr[k], 1152 /*0.03515625f Q15*/ ); + } } - sqErrorNrg = L_add( sqErrorNrg, accu1 ); - accu1 = L_deposit_l( 0 ); /* segment ended here, so reset segment sum */ - k = 0; - move16(); - } - - FOR( ; maxK < nTransWidth; maxK++ ) - { - IF( sqQ[i + maxK] != 0 ) + FOR( k = segmentOffset; k < i - win; k++ ) { - BREAK; + tmp1 = norm_l( sqQ[k] ); + sqErrorNrg = BASOP_Util_Add_Mant32Exp( sqErrorNrg, exp_sqErrorNrg, Mpy_32_16_1( L_shl( sqQ[k], tmp1 ), nTransWidth ), add( 15, sub( exp_spQ[k], tmp1 ) ), &exp_sqErrorNrg ); + sqQ[k] = 0; + move32(); + exp_spQ[k] = 0; + move16(); + } + FOR( ; win > 0; win-- ) + { + tmp1 = norm_l( sqQ[k] ); + sqErrorNrg = BASOP_Util_Add_Mant32Exp( sqErrorNrg, exp_sqErrorNrg, Mpy_32_16_1( L_shl( sqQ[k], tmp1 ), win ), add( 15, sub( exp_spQ[k], tmp1 ) ), &exp_sqErrorNrg ); + exp_spQ[k] = 0; + move16(); + sqQ[k++] = 0; + move32(); } } segmentOffset = add( i, 1 ); /* new segment might start at next line */ } ELSE /* current line is zero, so update pointers & segment sum */ { - if ( LT_16( k, nTransWidth ) ) - { - k = add( k, 1 ); - } - - tmp2 = sub( maxK, nTransWidth ); - test(); - if ( tmp2 < 0 && NE_16( element_mode, IVAS_CPE_MDCT ) ) + IF( LT_16( win, nTransWidth ) ) { - maxK = sub( maxK, 1 ); - } - - test(); - if ( ( tmp2 >= 0 ) && ( sqQ[i + sub( nTransWidth, 1 )] != 0 ) ) - { - maxK = sub( nTransWidth, 1 ); + win = add( win, 1 ); } - /* update segment sum: magnitudes scaled by smoothing function */ - /*accu1 += (float)fabs(x_orig[i]) * inv_gain2 * (float)(k * maxK);*/ - tmp2 = mult( inv_gain2, shl( imult1616( k, maxK ), 8 ) ); - accu1 = L_add( accu1, L_abs( Mpy_32_16_1( x_orig[i], tmp2 ) ) ); + sqQ[i] = Mpy_32_16_1( imult3216( L_abs( x_orig[i] ), win ), inv_gain2 ); + move32(); + exp_spQ[i] = add( x_orig_e, inv_gain2_e ); + move16(); } } - - FOR( ; i < lowpassLine; i++ ) + IF( win > 0 ) /* add last segment sum to sum of segment magnitudes */ { - inv_gain2 = shl( mult( inv_gain2, tilt_factor ), 1 ); - - IF( EQ_16( maxK, 1 ) ) /* current line is not zero, so reset pointers */ + k = sub( i, segmentOffset ); + IF( LE_16( nTransWidth, 3 ) ) { - k = sub( i, segmentOffset ); - - IF( k > 0 ) /* add segment sum to sum of segment magnitudes */ + tmp2 = sub( k, c1 ); + IF( tmp2 > 0 ) { - IF( LE_16( nTransWidth, 3 ) ) - { - tmp2 = sub( k, c1 ); - if ( tmp2 > 0 ) - n = L_msu( n, k, (Word16) 0x8000 ); - if ( tmp2 > 0 ) - n = L_mac( n, nTransWidth_1, (Word16) 0x8000 ); - if ( tmp2 <= 0 ) - n = L_mac( n, int_sqr[k], c2 ); - } - ELSE - { - tmp2 = sub( k, 12 ); - if ( tmp2 > 0 ) - n = L_msu( n, k, (Word16) 0x8000 ); - if ( tmp2 > 0 ) - n = L_sub( n, 0x70000 ); - if ( tmp2 <= 0 ) - n = L_mac( n, int_sqr[k], 1152 /*0.03515625f Q15*/ ); - } - sqErrorNrg = L_add( sqErrorNrg, accu1 ); + n = L_msu( n, k, (Word16) 0x8000 ); } - segmentOffset = add( i, 1 ); /* no new segments since maxK remains 1 */ - } - ELSE /* current line is zero, so update pointers & energy sum */ - { - if ( LT_16( k, nTransWidth ) ) + IF( tmp2 > 0 ) { - k = add( k, 1 ); + n = L_mac( n, nTransWidth_1, (Word16) 0x8000 ); } - if ( LT_16( maxK, nTransWidth ) ) + IF( tmp2 <= 0 ) { - maxK = sub( maxK, 1 ); - } - - /* update segment sum: magnitudes scaled by smoothing function */ - /*accu1 += (float)fabs(x_orig[i]) * inv_gain2 * (float)(k * maxK);*/ - tmp2 = mult( inv_gain2, shl( imult1616( k, maxK ), 8 ) ); - accu1 = L_add( accu1, L_abs( Mpy_32_16_1( x_orig[i], tmp2 ) ) ); - } - } - - k = sub( i, segmentOffset ); - IF( k > 0 ) /* add last segment sum to sum of segment magnitudes */ - { - IF( LE_16( nTransWidth, 3 ) ) - { - tmp2 = sub( k, c1 ); - if ( tmp2 > 0 ) - n = L_msu( n, k, (Word16) 0x8000 ); - if ( tmp2 > 0 ) - n = L_mac( n, nTransWidth_1, (Word16) 0x8000 ); - if ( tmp2 <= 0 ) n = L_mac( n, int_sqr[k], c2 ); + } } ELSE { tmp2 = sub( k, 12 ); - if ( tmp2 > 0 ) + IF( tmp2 > 0 ) + { n = L_msu( n, k, (Word16) 0x8000 ); - if ( tmp2 > 0 ) + } + IF( tmp2 > 0 ) + { n = L_sub( n, 0x70000 ); - if ( tmp2 <= 0 ) + } + IF( tmp2 <= 0 ) + { n = L_mac( n, int_sqr[k], 1152 /*0.03515625f Q15*/ ); + } + } + FOR( k = segmentOffset; k < i - win; k++ ) + { + tmp1 = norm_l( sqQ[k] ); + sqErrorNrg = BASOP_Util_Add_Mant32Exp( sqErrorNrg, exp_sqErrorNrg, Mpy_32_16_1( L_shl( sqQ[k], tmp1 ), nTransWidth ), add( 15, sub( exp_spQ[k], tmp1 ) ), &exp_sqErrorNrg ); + exp_spQ[k] = 0; + move16(); + sqQ[k] = 0; + move32(); + } + FOR( ; win > 0; win-- ) + { + tmp1 = norm_l( sqQ[k] ); + sqErrorNrg = BASOP_Util_Add_Mant32Exp( sqErrorNrg, exp_sqErrorNrg, Mpy_32_16_1( L_shl( sqQ[k], tmp1 ), win ), add( 15, sub( exp_spQ[k], tmp1 ) ), &exp_sqErrorNrg ); + exp_spQ[k] = 0; + move16(); + sqQ[k++] = 0; + move32(); } - sqErrorNrg = L_add( sqErrorNrg, accu1 ); } - + Word32 tmp4; /* noise level factor: average of segment magnitudes of noise bins */ IF( n > 0 ) { - tmp1 = BASOP_Util_Divide3232_Scale( Mpy_32_16_1( sqErrorNrg, att ), n, &s ); - s = add( add( add( s, x_orig_e ), inv_gain2_e ), 7 - 15 ); + tmp4 = BASOP_Util_Divide3232_Scale_cadence( Mpy_32_16_1( sqErrorNrg, att ), n, &s ); + s = add( add( exp_sqErrorNrg, -15 ), s ); BASOP_SATURATE_WARNING_OFF_EVS; -#ifdef BASOP_NOGLOB - tmp1 = shl_o( tmp1, s, &Overflow ); -#else /* BASOP_NOGLOB */ - tmp1 = shl( tmp1, s ); -#endif + tmp4 = L_shl_o( tmp4, s, &Overflow ); BASOP_SATURATE_WARNING_ON_EVS; } ELSE { - tmp1 = 0; + tmp4 = 0; move16(); } - + FOR( j = 0; j < N_MAX; j++ ) + { + sqQ[j] = L_shl( sqQ[j], sub( x_orig_e, exp_spQ[j] ) ); + move32(); + } /* quantize, dequantize noise level factor (range 0.09375 - 0.65625) */ - tmp2 = round_fx( L_shr( L_mult( tmp1, 22016 /*1.34375f Q14*/ ), 14 - NBITS_NOISE_FILL_LEVEL ) ); - + tmp2 = round_fx( L_shr( Mpy_32_16_1( tmp4, 22016 /*1.34375f Q14*/ ), 14 - NBITS_NOISE_FILL_LEVEL ) ); if ( GT_16( tmp2, ( 1 << NBITS_NOISE_FILL_LEVEL ) - 1 ) ) { tmp2 = ( 1 << NBITS_NOISE_FILL_LEVEL ) - 1; @@ -2681,8 +2705,10 @@ void tcx_noise_factor_ivas_fx( move16(); *fac_ns = extract_l( L_mult0( *quantized_fac_ns, shr( 24576 /*0.75f Q15*/, NBITS_NOISE_FILL_LEVEL ) ) ); + move16(); } + void tcx_encoder_memory_update_fx( Word16 *wsig, /* i : target weighted signal */ Word16 *xn_buf, /* i/o: mdct output buffer/time domain weigthed synthesis */ @@ -2718,11 +2744,8 @@ void tcx_encoder_memory_update_fx( Residu3_fx( Ai + ( st->nb_subfr - 1 ) * ( M + 1 ), synth + sub( L_frame_glob, 1 ), &tmp, 1, Q_new + shift - 1 ); LPDmem->mem_w0 = sub( wsig[sub( L_frame_glob, 1 )], tmp ); move16(); -#ifdef BASOP_NOGLOB LPDmem->mem_w0 = shr_sat( LPDmem->mem_w0, shift ); /*Qnew-1*/ -#else - LPDmem->mem_w0 = shr( LPDmem->mem_w0, shift ); /*Qnew-1*/ -#endif + move16(); } @@ -2797,6 +2820,7 @@ void tcx_encoder_memory_update_ivas_fx( 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 ); LPDmem->q_mem_syn = sub( shl( Q_new, 1 ), 1 ); // resultant q of synth after E_UTIL_f_preemph2 + move16(); test(); IF( st->tcxonly == 0 || LE_16( L_frame_glob, L_FRAME16k ) ) @@ -2867,8 +2891,10 @@ Word16 tcx_ari_res_Q_spec_fx( { sign = x_fac[i]; move16(); - if ( signs[i] != 0 ) + IF( signs[i] != 0 ) + { sign = negate( sign ); + } /* x_Q_m = x_Q[i] - sign*fac_m; x_Q_p = x_Q[i] + sign*fac_p; */ @@ -2936,8 +2962,10 @@ Word16 tcx_ari_res_Q_spec_fx( bits = add( bits, 1 ); L_tmp = L_shr( thres, s2 ); - if ( signs[i] ) + IF( signs[i] ) + { L_tmp = L_negate( L_tmp ); + } x_Q[i] = L_tmp; move32(); } @@ -3067,8 +3095,10 @@ Word16 tcx_ari_res_Q_spec_ivas_fx( bits = add( bits, 1 ); L_tmp = L_shr( thres, s2 ); - if ( signs[i] ) + IF( signs[i] ) + { L_tmp = L_negate( L_tmp ); + } x_Q[i] = L_tmp; move32(); } @@ -3095,8 +3125,10 @@ Word16 tcx_ari_res_Q_spec_ivas_fx( { sign = x_fac[i]; move16(); - if ( signs[i] != 0 ) + IF( signs[i] != 0 ) + { sign = negate( sign ); + } /* x_Q_m = x_Q[i] - sign*fac_m; x_Q_p = x_Q[i] + sign*fac_p; */ @@ -3164,8 +3196,10 @@ Word16 tcx_ari_res_Q_spec_ivas_fx( bits = add( bits, 1 ); L_tmp = L_shr( thres, s2 ); - if ( signs[i] ) + IF( signs[i] ) + { L_tmp = L_negate( L_tmp ); + } x_Q[i] = L_tmp; move32(); } @@ -3210,11 +3244,7 @@ Word16 tcx_res_Q_gain_fx( } /* bring sqGain to same exponent */ -#ifdef BASOP_NOGLOB sqGain = shr_sat( sqGain, sub( gain_reQ_e, sqGain_e ) ); -#else - sqGain = shr( sqGain, sub( gain_reQ_e, sqGain_e ) ); -#endif FOR( bits = 0; bits < TCX_RES_Q_BITS_GAIN; bits++ ) { IF( LT_16( sqGain, gain_reQ ) ) @@ -3301,10 +3331,14 @@ Word16 tcx_res_Q_spec_fx( { tmp1 = L_add( x_orig[i], 0 ); tmp2 = Mpy_32_16_1( x_Q[i], sqGain ); - if ( s > 0 ) + IF( s > 0 ) + { tmp2 = L_shr( tmp2, s ); - if ( s < 0 ) + } + IF( s < 0 ) + { tmp1 = L_shl( tmp1, s ); + } if ( lf_deemph_factors != NULL ) { @@ -3318,10 +3352,14 @@ Word16 tcx_res_Q_spec_fx( move16(); bits = add( bits, 1 ); - if ( x_Q[i] > 0 ) + IF( x_Q[i] > 0 ) + { tmp1 = L_mult( fac_m, lf_deemph_factor ); - if ( x_Q[i] < 0 ) + } + IF( x_Q[i] < 0 ) + { tmp1 = L_mult( fac_p, lf_deemph_factor ); + } x_Q[i] = L_sub( x_Q[i], L_shr( tmp1, s2 ) ); move32(); } @@ -3331,10 +3369,14 @@ Word16 tcx_res_Q_spec_fx( move16(); bits = add( bits, 1 ); - if ( x_Q[i] > 0 ) + IF( x_Q[i] > 0 ) + { tmp1 = L_mult( fac_p, lf_deemph_factor ); - if ( x_Q[i] < 0 ) + } + IF( x_Q[i] < 0 ) + { tmp1 = L_mult( fac_m, lf_deemph_factor ); + } x_Q[i] = L_add( x_Q[i], L_shr( tmp1, s2 ) ); move32(); } @@ -3468,10 +3510,14 @@ Word16 tcx_res_Q_spec_ivas_fx( { tmp1 = L_add( x_orig[i], 0 ); tmp2 = Mpy_32_16_1( x_Q[i], sqGain ); - if ( s > 0 ) + IF( s > 0 ) + { tmp2 = L_shr( tmp2, s ); - if ( s < 0 ) + } + IF( s < 0 ) + { tmp1 = L_shl( tmp1, s ); + } if ( lf_deemph_factors != NULL ) { @@ -3485,10 +3531,14 @@ Word16 tcx_res_Q_spec_ivas_fx( move16(); bits = add( bits, 1 ); - if ( x_Q[i] > 0 ) + IF( x_Q[i] > 0 ) + { tmp1 = L_mult( fac_m, lf_deemph_factor ); - if ( x_Q[i] < 0 ) + } + IF( x_Q[i] < 0 ) + { tmp1 = L_mult( fac_p, lf_deemph_factor ); + } x_Q[i] = L_sub( x_Q[i], L_shr( tmp1, s2 ) ); move32(); } @@ -3498,10 +3548,14 @@ Word16 tcx_res_Q_spec_ivas_fx( move16(); bits = add( bits, 1 ); - if ( x_Q[i] > 0 ) + IF( x_Q[i] > 0 ) + { tmp1 = L_mult( fac_p, lf_deemph_factor ); - if ( x_Q[i] < 0 ) + } + IF( x_Q[i] < 0 ) + { tmp1 = L_mult( fac_m, lf_deemph_factor ); + } x_Q[i] = L_add( x_Q[i], L_shr( tmp1, s2 ) ); move32(); } @@ -3648,14 +3702,23 @@ void ProcessIGF_fx( Word16 Q_A; Word16 predictionGain = 0; Word16 *flatteningTrigger = &( st->hIGFEnc->flatteningTrigger ); + move32(); + move16(); + move16(); + move16(); + move32(); + move16(); + move16(); ITF_Detect_fx( spec_before, startLine, endLine, maxOrder, A, &Q_A, &predictionGain, &curr_order, shl( st->hIGFEnc->spec_be_igf_e, 1 ) ); *flatteningTrigger = 0; + move16(); test(); IF( LT_32( tns_predictionGain, 9646899l /*1.15 Q23*/ ) && LT_16( predictionGain, 147 /*1.15 Q7*/ ) ) { *flatteningTrigger = 1; + move16(); } } @@ -3713,3 +3776,204 @@ void attenuateNbSpectrum_fx( Word16 L_frame, Word32 *spectrum ) att = mult_r( att, att ); } } + +/*---------------------------------------------------------------------* + * ProcessIGF_ivas_fx() + * + * + *---------------------------------------------------------------------*/ +void ProcessIGF_ivas_fx( + Encoder_State *st, /* i : Encoder state */ + Word32 *pMDCTSpectrum, /* i : MDCT spectrum (*q_spectrum) */ + const Word32 *pITFMDCTSpectrum, /* i : MDCT spectrum fir ITF */ + Word16 *q_spectrum, /* i/o: Q of spectrum */ + Word32 *pPowerSpectrum, /* i : MDCT^2 + MDST^2 spectrum, or estimate (*q_powerSpec) */ + Word16 *exp_powerSpec, /* i/o: Q of power spectrum */ + const Word16 isTCX20, /* i : flag indicating if the input is TCX20 or TCX10/2xTCX5 */ + const Word16 frameno, /* i : flag indicating index of current subframe */ + const Word16 sp_aud_decision0, /* i : first stage switching decision */ + const Word16 vad_hover_flag /* i : VAD hangover flag */ +) +{ + Word16 igfGridIdx, isIndepFlag, bsBits, pBsStart, curr_order; + Word16 predictionGain; + Word16 A[ITF_MAX_FILTER_ORDER + 1]; + Word16 q_A; + + IGF_ENC_INSTANCE_HANDLE hIGFEnc = st->hIGFEnc; + BSTR_ENC_HANDLE hBstr = st->hBstr; + + isIndepFlag = 1; + move16(); + test(); + IF( st->last_core == ACELP_CORE && isTCX20 ) + { + igfGridIdx = IGF_GRID_LB_TRAN; + move16(); + } + ELSE IF( isTCX20 ) + { + igfGridIdx = IGF_GRID_LB_NORM; + move16(); + } + ELSE + { + /* It is short block */ + igfGridIdx = IGF_GRID_LB_SHORT; + move16(); + if ( EQ_16( frameno, 1 ) ) + { + isIndepFlag = 0; + move16(); + } + } + + IGFSaveSpectrumForITF_ivas_fx( hIGFEnc, igfGridIdx, pITFMDCTSpectrum, sub( Q31, *q_spectrum ) ); + + IGFEncApplyMono_ivas_fx( st, igfGridIdx, pMDCTSpectrum, sub( Q31, *q_spectrum ), pPowerSpectrum, exp_powerSpec, isTCX20, st->hTcxEnc->fUseTns[frameno], sp_aud_decision0, vad_hover_flag ); + + curr_order = 0; + move16(); + predictionGain = 0; + move16(); + q_A = 0; + move16(); + + ITF_Detect_ivas_fx( hIGFEnc->spec_be_igf, hIGFEnc->infoStartLine, hIGFEnc->infoStopLine, 8 /*maxOrder*/, A, &q_A, &predictionGain, &curr_order, sub( 31, hIGFEnc->spec_be_igf_e ) ); + + test(); + IF( LT_32( L_deposit_l( hIGFEnc->tns_predictionGain ), 9646899 /* 1.15 in Q23 */ ) && LT_32( L_deposit_l( predictionGain ), 9646899 /* 1.15 in Q23 */ ) ) + { + hIGFEnc->flatteningTrigger = 1; + move16(); + } + ELSE + { + hIGFEnc->flatteningTrigger = 0; + move16(); + } + + hIGFEnc->infoTotalBitsPerFrameWritten = 0; + move16(); + + IF( isTCX20 ) + { + IGFEncWriteBitstream_ivas_fx( hIGFEnc, NULL, &hIGFEnc->infoTotalBitsPerFrameWritten, igfGridIdx, isIndepFlag ); + } + ELSE + { + pBsStart = hBstr->nb_ind_tot; + move16(); + + IGFEncWriteBitstream_ivas_fx( hIGFEnc, hBstr, &hIGFEnc->infoTotalBitsPerFrameWritten, igfGridIdx, isIndepFlag ); + + bsBits = sub( hBstr->nb_ind_tot, pBsStart ); + IGFEncConcatenateBitstream( hIGFEnc, bsBits, hBstr ); + } + + return; +} + +/*---------------------------------------------------------------------* + * ProcessStereoIGF() + * + * + *---------------------------------------------------------------------*/ + +void ProcessStereoIGF_fx( + STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, + Encoder_State *sts[CPE_CHANNELS], /* i : Encoder state */ + Word16 ms_mask[2][MAX_SFB], /* i : bandwise MS mask */ + Word32 *pITFMDCTSpectrum_fx[CPE_CHANNELS][NB_DIV], /* i : MDCT spectrum fir ITF */ + Word16 q_pITFMDCTSpectrum_1, + Word16 q_pITFMDCTSpectrum_2, + Word32 *pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */ + Word32 *pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i : inverse power spectrum */ + Word32 *inv_spectrum_fx[CPE_CHANNELS][NB_DIV], /* i : 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 */ + const Word16 mct_on ) +{ + Word16 ch, igfGridIdx, isIndepFlag, bsBits, pBsStart, curr_order; + Word16 predictionGain; + Word16 A[ITF_MAX_FILTER_ORDER + 1]; + Word16 Q_A; + IGF_ENC_INSTANCE_HANDLE hIGFEnc[CPE_CHANNELS]; + BSTR_ENC_HANDLE hBstr; + hIGFEnc[0] = sts[0]->hIGFEnc; + hIGFEnc[1] = sts[1]->hIGFEnc; + + isIndepFlag = 1; + move16(); + + test(); + IF( sts[0]->last_core == ACELP_CORE && EQ_16( sts[0]->core, TCX_20_CORE ) ) + { + igfGridIdx = IGF_GRID_LB_TRAN; + } + ELSE IF( EQ_16( sts[0]->core, TCX_20_CORE ) ) + { + igfGridIdx = IGF_GRID_LB_NORM; + } + ELSE + { + /* It is short block */ + igfGridIdx = IGF_GRID_LB_SHORT; + if ( EQ_16( frameno, 1 ) ) + { + isIndepFlag = 0; + move16(); + } + } + move16(); + + IGFSaveSpectrumForITF_ivas_fx( hIGFEnc[0], igfGridIdx, pITFMDCTSpectrum_fx[0][frameno], sub( Q31, q_pITFMDCTSpectrum_1 ) ); + + 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 ); + + FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) + { + curr_order = 0; + move16(); + + Q_A = 0; + move16(); + + predictionGain = 0; + move16(); + + ITF_Detect_ivas_fx( hIGFEnc[ch]->spec_be_igf, hIGFEnc[ch]->infoStartLine, hIGFEnc[ch]->infoStopLine, 8 /*maxOrder*/, A, &Q_A, &predictionGain, &curr_order, sub( 31, hIGFEnc[ch]->spec_be_igf_e ) ); + + test(); + hIGFEnc[ch]->flatteningTrigger = LT_32( hIGFEnc[ch]->tns_predictionGain, ONE_POINT_ONE_FIVE_Q23 ) && LT_32( predictionGain, ONE_POINT_ONE_FIVE_Q7 ); + move16(); + + hIGFEnc[ch]->infoTotalBitsPerFrameWritten = 0; + move16(); + + IF( EQ_16( sts[ch]->core, TCX_20_CORE ) ) + { + IGFEncWriteBitstream_ivas_fx( hIGFEnc[ch], NULL, &hIGFEnc[ch]->infoTotalBitsPerFrameWritten, igfGridIdx, isIndepFlag ); + } + ELSE + { + hBstr = sts[ch]->hBstr; + pBsStart = hBstr->nb_ind_tot; + move16(); + + if ( ch > 0 ) + { + hBstr->ind_list = sts[0]->hBstr->ind_list + sts[0]->hBstr->nb_ind_tot; + } + IGFEncWriteBitstream_ivas_fx( hIGFEnc[ch], hBstr, &hIGFEnc[ch]->infoTotalBitsPerFrameWritten, igfGridIdx, isIndepFlag ); + + bsBits = sub( hBstr->nb_ind_tot, pBsStart ); + IGFEncConcatenateBitstream( hIGFEnc[ch], bsBits, hBstr ); + } + } + return; +} diff --git a/lib_enc/tfa_enc.c b/lib_enc/tfa_enc.c deleted file mode 100644 index 825401325748d89d4db5894372ff8dd2e53d76ec..0000000000000000000000000000000000000000 --- a/lib_enc/tfa_enc.c +++ /dev/null @@ -1,41 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "prot.h" -#include "wmc_auto.h" diff --git a/lib_enc/tfa_enc_fx.c b/lib_enc/tfa_enc_fx.c index cfb48aaeca8a479efd03489958158bead7ccedbb..a6a1eaa8501e54e4fca18402b1ee6c759fbd53da 100644 --- a/lib_enc/tfa_enc_fx.c +++ b/lib_enc/tfa_enc_fx.c @@ -27,13 +27,11 @@ void tfaCalcEnv_fx( FOR( i = 0; i < N_TEC_TFA_SUBFR; i++ ) { enr[i] = L_deposit_l( 0 ); + move32(); FOR( j = 0; j < L_TEC_TFA_SUBFR16k; j++ ) { -#ifdef BASOP_NOGLOB enr[i] = L_mac0_sat( enr[i], shb_speech[k], shb_speech[k] ); -#else - enr[i] = L_mac0( enr[i], shb_speech[k], shb_speech[k] ); -#endif + move32(); k = add( k, 1 ); } } @@ -104,8 +102,8 @@ Word16 tfaEnc_TBE_fx( test(); test(); test(); - IF( ( GT_32( m_g, L_tmp ) && GT_16( pitch_buf_sum, 7040 /*110 Q6*/ ) && GT_16( voicing_sum, 22938 /*0.70 Q15*/ ) ) || - ( EQ_16( last_core, TCX_20_CORE ) && GT_32( m_g, L_tmp1 ) && LT_16( voicing_sum, 22938 /*0.70 Q15*/ ) ) ) + if ( ( GT_32( m_g, L_tmp ) && GT_16( pitch_buf_sum, 7040 /*110 Q6*/ ) && GT_16( voicing_sum, 22938 /*0.70 Q15*/ ) ) || + ( EQ_16( last_core, TCX_20_CORE ) && GT_32( m_g, L_tmp1 ) && LT_16( voicing_sum, 22938 /*0.70 Q15*/ ) ) ) { tfa_flag = 1; move16(); diff --git a/lib_enc/tns_base_enc.c b/lib_enc/tns_base_enc.c deleted file mode 100644 index b3f3a90b7702920cfd9566005e7f7d543a794b94..0000000000000000000000000000000000000000 --- a/lib_enc/tns_base_enc.c +++ /dev/null @@ -1,103 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include -#include "options.h" -#include "wmc_auto.h" -#include "cnst.h" -#include "rom_com.h" -#include "prot.h" -#include "stat_com.h" - -/*---------------------------------------------------------------------------- - * Local constants - *---------------------------------------------------------------------------*/ - -#define HLM_MIN_NRG ( PCM16_TO_FLT_FAC * 2 * NORM_MDCT_FACTOR / ( 640 * 640 ) ) - -#define MAX_SUBDIVISIONS 3 - - -/*---------------------------------------------------------------------* - * EncodeTnsData() - * - * - *---------------------------------------------------------------------*/ - -void EncodeTnsData( - STnsConfig const *pTnsConfig, /* i : TNS Configuration struct */ - STnsData const *pTnsData, /* i : TNS data struct (quantized param) */ - int16_t *stream, /* o : internal data stream */ - int16_t *pnSize, /* o : number of written parameters */ - int16_t *pnBits /* o : number of written bits */ -) -{ - *pnSize = 0; - *pnBits = 0; - - if ( pTnsConfig->nMaxFilters > 1 ) - { - if ( pTnsConfig->allowTnsOnWhite ) - { - if ( pTnsConfig->iFilterBorders[0] < 512 ) - { - GetParameters( &tnsEnabledOnWhiteSWBTCX10BitMap, 1, pTnsData, &stream, pnSize, pnBits ); - } - else - { - GetParameters( &tnsEnabledOnWhiteSWBTCX20BitMap, 1, pTnsData, &stream, pnSize, pnBits ); - } - } - else - { - if ( pTnsConfig->iFilterBorders[0] < 512 ) - { - GetParameters( &tnsEnabledSWBTCX10BitMap, 1, pTnsData, &stream, pnSize, pnBits ); - } - else - { - GetParameters( &tnsEnabledSWBTCX20BitMap, 1, pTnsData, &stream, pnSize, pnBits ); - } - } - } - else - { - GetParameters( &tnsEnabledWBTCX20BitMap, 1, pTnsData, &stream, pnSize, pnBits ); - } - - return; -} diff --git a/lib_enc/tns_base_enc_fx.c b/lib_enc/tns_base_enc_fx.c index 2f1762e435858dfbee8bee8b2791c5a8ff47312d..d1763e039fc96f6e36d1e442fb510c57d1b16332 100644 --- a/lib_enc/tns_base_enc_fx.c +++ b/lib_enc/tns_base_enc_fx.c @@ -59,6 +59,7 @@ Word16 DetectTnsFilt_fx( STnsConfig const *pTnsConfig, Word16 facs_e[TNS_MAX_NUM_OF_FILTERS][MAX_SUBDIVISIONS]; /* exponents of facs[][] */ Word16 shifts[TNS_MAX_NUM_OF_FILTERS][MAX_SUBDIVISIONS]; Word16 iFilter = 0; + move16(); ResetTnsData( pTnsData ); @@ -76,6 +77,7 @@ Word16 DetectTnsFilt_fx( STnsConfig const *pTnsConfig, Word16 iSubdivisions; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif move16(); @@ -102,12 +104,16 @@ Word16 DetectTnsFilt_fx( STnsConfig const *pTnsConfig, iStartLine = imult1616( tmp, iSubdivisions ); iEndLine = add( iStartLine, tmp ); - if ( EQ_16( nSubdivisions, 3 ) ) + IF( EQ_16( nSubdivisions, 3 ) ) + { iStartLine = mult( iStartLine, 0x2AAB ); + } iStartLine = add( iStartLine, idx0 ); - if ( EQ_16( nSubdivisions, 3 ) ) + IF( EQ_16( nSubdivisions, 3 ) ) + { iEndLine = mult( iEndLine, 0x2AAB ); + } iEndLine = add( iEndLine, idx0 ); /*norms[iFilter][iSubdivisions] = norm2FLOAT(pSpectrum+iStartLine, iEndLine-iStartLine);*/ @@ -118,11 +124,7 @@ Word16 DetectTnsFilt_fx( STnsConfig const *pTnsConfig, /* Check threshold HLM_MIN_NRG */ BASOP_SATURATE_WARNING_OFF_EVS; -#ifdef BASOP_NOGLOB tmp32 = L_sub( L_shl_o( L_tmp, s_min( 31, sub( shift, 24 - 31 * 2 ) ), &Overflow ), 3277l /*HLM_MIN_NRG Q7*/ ); -#else /* BASOP_NOGLOB */ - tmp32 = L_sub( L_shl( L_tmp, s_min( 31, sub( shift, 24 - 31 * 2 ) ) ), 3277l /*HLM_MIN_NRG Q7*/ ); -#endif BASOP_SATURATE_WARNING_ON_EVS; /* get pre-shift for autocorrelation */ @@ -149,20 +151,12 @@ Word16 DetectTnsFilt_fx( STnsConfig const *pTnsConfig, move16(); facs_e[iFilter][iSubdivisions] = shl( sub( tmp, shifts[iFilter][iSubdivisions] ), 1 ); - tmp = sub( 1, shl( tmp, 1 ) ); /* exponent of autocorrelation */ -#ifdef BASOP_NOGLOB + tmp = sub( 1, shl( tmp, 1 ) ); /* exponent of autocorrelation */ L_tmp = L_shl_sat( L_tmp, sub( shift, tmp ) ); /* shift L_tmp to that exponent */ /* calc factor (with 2 bits headroom for sum of 3 subdivisions) */ move16(); facs[iFilter][iSubdivisions] = div_s( 0x2000, round_fx_sat( L_tmp ) ); /* L_tmp is >= 0x2000000 */ -#else - L_tmp = L_shl( L_tmp, sub( shift, tmp ) ); /* shift L_tmp to that exponent */ - - /* calc factor (with 2 bits headroom for sum of 3 subdivisions) */ - move16(); - facs[iFilter][iSubdivisions] = div_s( 0x2000, round_fx( L_tmp ) ); /* L_tmp is >= 0x2000000 */ -#endif } } } @@ -211,12 +205,16 @@ Word16 DetectTnsFilt_fx( STnsConfig const *pTnsConfig, iStartLine = imult1616( spectrumLength, iSubdivisions ); iEndLine = add( iStartLine, spectrumLength ); - if ( EQ_16( nSubdivisions, 3 ) ) + IF( EQ_16( nSubdivisions, 3 ) ) + { iStartLine = mult( iStartLine, 0x2AAB ); + } iStartLine = add( iStartLine, idx0 ); - if ( EQ_16( nSubdivisions, 3 ) ) + IF( EQ_16( nSubdivisions, 3 ) ) + { iEndLine = mult( iEndLine, 0x2AAB ); + } iEndLine = add( iEndLine, idx0 ); @@ -235,6 +233,7 @@ Word16 DetectTnsFilt_fx( STnsConfig const *pTnsConfig, #else tmpbuf[i] = round_fx( L_shl( pSpectrum[iStartLine + i], shift ) ); #endif + move16(); } FOR( lag = 0; lag <= pTnsConfig->maxOrder; lag++ ) @@ -244,15 +243,11 @@ Word16 DetectTnsFilt_fx( STnsConfig const *pTnsConfig, L_tmp = L_deposit_l( 0 ); FOR( i = 0; i < n; i++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_mac0_sat( L_tmp, tmpbuf[i], tmpbuf[i + lag] ); -#else - L_tmp = L_mac0( L_tmp, tmpbuf[i], tmpbuf[i + lag] ); -#endif } - if ( lag != 0 ) - L_tmp = Mpy_32_16_1( L_tmp, *pWindow++ ); + IF( lag != 0 ) + L_tmp = Mpy_32_16_1( L_tmp, *pWindow++ ); L_tmp = Mpy_32_16_1( L_tmp, facs[iFilter][iSubdivisions] ); L_tmp = L_shl( L_tmp, facs_e[iFilter][iSubdivisions] ); @@ -311,7 +306,6 @@ Word16 DetectTnsFilt_fx( STnsConfig const *pTnsConfig, } - test(); return ( pTnsData->nFilters > 0 ); } @@ -460,6 +454,7 @@ Word16 DetectTnsFilt_ivas_fx( STnsConfig const *pTnsConfig, /* i : TNS Configur Word16 iSubdivisions; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif move16(); @@ -486,12 +481,16 @@ Word16 DetectTnsFilt_ivas_fx( STnsConfig const *pTnsConfig, /* i : TNS Configur iStartLine = imult1616( tmp, iSubdivisions ); iEndLine = add( iStartLine, tmp ); - if ( EQ_16( nSubdivisions, 3 ) ) + IF( EQ_16( nSubdivisions, 3 ) ) + { iStartLine = mult( iStartLine, 0x2AAB ); + } iStartLine = add( iStartLine, idx0 ); - if ( EQ_16( nSubdivisions, 3 ) ) + IF( EQ_16( nSubdivisions, 3 ) ) + { iEndLine = mult( iEndLine, 0x2AAB ); + } iEndLine = add( iEndLine, idx0 ); /*norms[iFilter][iSubdivisions] = norm2FLOAT(pSpectrum+iStartLine, iEndLine-iStartLine);*/ @@ -502,11 +501,7 @@ Word16 DetectTnsFilt_ivas_fx( STnsConfig const *pTnsConfig, /* i : TNS Configur /* Check threshold HLM_MIN_NRG */ BASOP_SATURATE_WARNING_OFF_EVS; -#ifdef BASOP_NOGLOB tmp32 = L_sub( L_shl_o( L_tmp, s_min( 31, sub( shift, 24 - 31 * 2 ) ), &Overflow ), 3277l /*HLM_MIN_NRG Q7*/ ); -#else /* BASOP_NOGLOB */ - tmp32 = L_sub( L_shl( L_tmp, s_min( 31, sub( shift, 24 - 31 * 2 ) ) ), 3277l /*HLM_MIN_NRG Q7*/ ); -#endif BASOP_SATURATE_WARNING_ON_EVS; /* get pre-shift for autocorrelation */ @@ -533,20 +528,12 @@ Word16 DetectTnsFilt_ivas_fx( STnsConfig const *pTnsConfig, /* i : TNS Configur move16(); facs_e[iFilter][iSubdivisions] = shl( sub( tmp, shifts[iFilter][iSubdivisions] ), 1 ); - tmp = sub( 1, shl( tmp, 1 ) ); /* exponent of autocorrelation */ -#ifdef BASOP_NOGLOB + tmp = sub( 1, shl( tmp, 1 ) ); /* exponent of autocorrelation */ L_tmp = L_shl_sat( L_tmp, sub( shift, tmp ) ); /* shift L_tmp to that exponent */ /* calc factor (with 2 bits headroom for sum of 3 subdivisions) */ move16(); facs[iFilter][iSubdivisions] = div_s( 0x2000, round_fx_sat( L_tmp ) ); /* L_tmp is >= 0x2000000 */ -#else - L_tmp = L_shl( L_tmp, sub( shift, tmp ) ); /* shift L_tmp to that exponent */ - - /* calc factor (with 2 bits headroom for sum of 3 subdivisions) */ - move16(); - facs[iFilter][iSubdivisions] = div_s( 0x2000, round_fx( L_tmp ) ); /* L_tmp is >= 0x2000000 */ -#endif } } } @@ -595,12 +582,16 @@ Word16 DetectTnsFilt_ivas_fx( STnsConfig const *pTnsConfig, /* i : TNS Configur iStartLine = imult1616( spectrumLength, iSubdivisions ); iEndLine = add( iStartLine, spectrumLength ); - if ( EQ_16( nSubdivisions, 3 ) ) + IF( EQ_16( nSubdivisions, 3 ) ) + { iStartLine = mult( iStartLine, 0x2AAB ); + } iStartLine = add( iStartLine, idx0 ); - if ( EQ_16( nSubdivisions, 3 ) ) + IF( EQ_16( nSubdivisions, 3 ) ) + { iEndLine = mult( iEndLine, 0x2AAB ); + } iEndLine = add( iEndLine, idx0 ); @@ -625,15 +616,13 @@ Word16 DetectTnsFilt_ivas_fx( STnsConfig const *pTnsConfig, /* i : TNS Configur L_tmp = L_deposit_l( 0 ); FOR( i = 0; i < n; i++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_mac0_sat( L_tmp, tmpbuf[i], tmpbuf[i + lag] ); -#else - L_tmp = L_mac0( L_tmp, tmpbuf[i], tmpbuf[i + lag] ); -#endif } - if ( lag != 0 ) + IF( lag != 0 ) + { L_tmp = Mpy_32_16_1( L_tmp, *pWindow++ ); + } L_tmp = Mpy_32_16_1( L_tmp, facs[iFilter][iSubdivisions] ); L_tmp = L_shl( L_tmp, facs_e[iFilter][iSubdivisions] ); @@ -652,7 +641,7 @@ Word16 DetectTnsFilt_ivas_fx( STnsConfig const *pTnsConfig, /* i : TNS Configur } } - if ( predictionGain ) + IF( predictionGain ) { assert( pTnsConfig->nMaxFilters == 1 ); move16(); @@ -660,7 +649,7 @@ Word16 DetectTnsFilt_ivas_fx( STnsConfig const *pTnsConfig, /* i : TNS Configur } /* We check the filter's decisions in the opposite direction */ - FOR( iFilter = sub( pTnsConfig->nMaxFilters, 1 ); iFilter >= 0; iFilter-- ) + FOR( iFilter = ( pTnsConfig->nMaxFilters - 1 ); iFilter >= 0; iFilter-- ) { STnsFilter *pFilter; struct TnsParameters const *pTnsParameters; @@ -673,7 +662,6 @@ Word16 DetectTnsFilt_ivas_fx( STnsConfig const *pTnsConfig, /* i : TNS Configur IF( s_or( (Word16) GT_16( pFilter->predictionGain, pTnsParameters->minPredictionGain ), sub( pFilter->avgSqrCoef, pTnsParameters->minAvgSqrCoef ) > 0 ) ) { - move16(); // pTnsData->nFilters > 0 || isTCX10 || ltp_gain < 0.6f || hTranDet == NULL // .6f = 19660, Q=15 test(); @@ -687,7 +675,7 @@ Word16 DetectTnsFilt_ivas_fx( STnsConfig const *pTnsConfig, /* i : TNS Configur ELSE { maxEnergyChange = GetTCXMaxenergyChange_ivas_fx( hTranDet, isTCX10, NSUBBLOCKS, 3 ); - IF( sub( maxEnergyChange, pTnsParameters->minEnergyChange ) >= 0 ) + IF( sub( maxEnergyChange, shl( pTnsParameters->minEnergyChange, Q3 - Q7 ) ) >= 0 ) { pTnsData->nFilters = add( pTnsData->nFilters, 1 ); @@ -884,8 +872,10 @@ static void GetFilterParameters( Word32 rxx[], Word16 maxOrder, STnsFilter *pTns /* reduce filter order by truncating trailing zeros */ i = sub( maxOrder, 1 ); + test(); WHILE( ( i >= 0 ) && ( indexes[i] == 0 ) ) { + test(); i = sub( i, 1 ); } @@ -899,10 +889,8 @@ static void GetFilterParameters( Word32 rxx[], Word16 maxOrder, STnsFilter *pTns { Word16 value; - move16(); value = shr( values[indexes[i] + INDEX_SHIFT], 1 ); - move16(); L_tmp = L_mac0( L_tmp, value, value ); } move16(); @@ -921,7 +909,6 @@ static void Parcor2Index( const Word16 parCoeff[] /*Q15*/, Word16 index[], Word1 Word16 x; - move16(); move16(); nValues = 1 << TNS_COEF_RES; #if TNS_COEF_RES == 5 @@ -942,10 +929,13 @@ static void Parcor2Index( const Word16 parCoeff[] /*Q15*/, Word16 index[], Word1 /* parCoeff is in the range of -1.0 ... 1.0 by definition */ /* assert((x >= FL2WORD16(-1.0f)) && (x <= FL2WORD16(1.0f))); */ + test(); WHILE( ( iIndex < nValues ) && ( x > add( shr( values[iIndex - 1], 1 ), shr( values[iIndex], 1 ) ) ) ) { + test(); iIndex = add( iIndex, 1 ); } index[i] = sub( iIndex, 1 + INDEX_SHIFT ); + move16(); } } diff --git a/lib_enc/transient_detection.c b/lib_enc/transient_detection.c deleted file mode 100644 index 8e87e5685392d3f3d073201ea23f756e0c7592f3..0000000000000000000000000000000000000000 --- a/lib_enc/transient_detection.c +++ /dev/null @@ -1,183 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "stat_enc.h" -#include "cnst.h" -#include "prot.h" -#include "ivas_prot.h" -#include -#include "wmc_auto.h" - -#include "prot_fx.h" -#include "ivas_prot_fx.h" -/*---------------------------------------------------------------* - * Local constants - *---------------------------------------------------------------*/ - -#define MIN_BLOCK_ENERGY 107.37f - -#define THR_HIGH 8.5f -#define THR_NORM_HIGH 8.0f -#define THR_NORM_LOW 4.5f -#define THR_LOW 4.25f -#define THR_LOW_STEP 1.0f - -/*---------------------------------------------------------------* - * Local function prototypes - *---------------------------------------------------------------*/ - - -/*-------------------------------------------------------------------* - * InitTransientDetection() - * - * - *-------------------------------------------------------------------*/ - - -/*-------------------------------------------------------------------* - * GetTCXAvgTemporalFlatnessMeasure() - * - * - *-------------------------------------------------------------------*/ - - -/*-------------------------------------------------------------------* - * GetTCXMaxenergyChange() - * - * - *-------------------------------------------------------------------*/ - - -/*---------------------------------------------------------------* - * Local functions - *---------------------------------------------------------------*/ - -/** TCX decision. - * Check if there is an attack in a subblock. Version for TCX Long/Short decision. - * See TCheckSubblocksForAttack for definition of parameters. - * It is assumed that the delay of MDCT overlap was not taken into account, so that the last subblock corresponds to the newest input subblock. - */ - - -/** Init transient detector. - * Fills TransientDetector structure with sensible content and enable it. - * @param pSubblockEnergies Subblock energies used in this transient detector. - * @param nDelay Delay for this transient detector. - * @param nSubblocksToCheck Number of subblocks to check in this transient detector. - * @param pCheckSubblockForAttack Attack detection function for this transient detector. - * @param pSetAttackPosition Function for finalizing this transient detector. - * @param attackRatioThreshold Attack ratio threshold. - * @param pTransientDetector Structure to be initialized. - */ - - -/*-------------------------------------------------------------------* - * set_transient_stereo() - * - * - *-------------------------------------------------------------------*/ -void set_transient_stereo_fx( - CPE_ENC_HANDLE hCPE, /* i : CPE structure */ - Word16 currFlatness[] /* i/o: current flatness */ -) -{ - Word16 n, attackIsPresent; - Word16 currFlatnessMax; - Encoder_State **sts; - - sts = hCPE->hCoreCoder; - - /* for DFT/TD based stereo ,map avg. flatness to individual stereo channels (M/S or X/Y) */ - maximum_fx( currFlatness, CPE_CHANNELS, &currFlatnessMax ); - attackIsPresent = 0; - move16(); - - FOR( n = 0; n < CPE_CHANNELS; n++ ) - { - attackIsPresent = s_max( attackIsPresent, sts[n]->hTranDet->transientDetector.bIsAttackPresent ); - } - - set16_fx( currFlatness, currFlatnessMax, CPE_CHANNELS ); - - FOR( n = 0; n < CPE_CHANNELS; n++ ) - { - sts[n]->hTranDet->transientDetector.bIsAttackPresent = attackIsPresent; - move16(); - } - - IF( hCPE->hStereoDft != NULL ) - { - IF( hCPE->hStereoDft->attackPresent ) - { - hCPE->hStereoDft->wasTransient = 1; - move16(); - } - ELSE IF( hCPE->hStereoDft->wasTransient ) - { - hCPE->hStereoDft->wasTransient = 0; - move16(); - } - - hCPE->hStereoDft->attackPresent = attackIsPresent; - move16(); - - hCPE->hStereoDft->hItd->currFlatness_fx = 0; - move16(); - FOR( n = 0; n < CPE_CHANNELS; n++ ) - { - hCPE->hStereoDft->hItd->currFlatness_fx = s_max( hCPE->hStereoDft->hItd->currFlatness_fx, currFlatness[n] ); - } - } - - IF( hCPE->hStereoMdct != NULL ) - { - hCPE->hStereoMdct->hItd->currFlatness_fx = 0; - move16(); - FOR( n = 0; n < CPE_CHANNELS; n++ ) - { - hCPE->hStereoMdct->hItd->currFlatness_fx = s_max( hCPE->hStereoMdct->hItd->currFlatness_fx, currFlatness[n] ); - } - } - - return; -} -/*-------------------------------------------------------------------* - * transient_analysis() - * - * - *-------------------------------------------------------------------*/ diff --git a/lib_enc/transient_detection_fx.c b/lib_enc/transient_detection_fx.c index bb977b432ecc2b0a6bc72f5775a7f9227452a986..d9859a1a10ddc4685c86875295e168d118ee1ff8 100644 --- a/lib_enc/transient_detection_fx.c +++ b/lib_enc/transient_detection_fx.c @@ -16,6 +16,7 @@ #include "ivas_prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ + /* Exponent of attack threshold. Picked according to current threshold values. */ #define ATTACKTHRESHOLD_E 4 /* Exponent of subblock energies and accumulated subblock energies. @@ -141,6 +142,107 @@ static void GetAttackForTCXDecision( Word32 const *pSubblockNrg, Word32 const *p *pbIsAttackPresent = bIsAttackPresent; } +static void GetAttackForTCXDecision_ivas_fx( Word32 const *pSubblockNrg, Word32 const *pAccSubblockNrg, Word16 nSubblocks, Word16 nPastSubblocks, Word16 attackRatioThreshold, Word16 *pbIsAttackPresent, Word16 *pAttackIndex ) +{ + Word16 i; + Word16 bIsAttackPresent, attackIndex; + Word16 attackRatioThreshold_1_5; + Word64 W_tmp1, W_tmp2, W_tmp3; + + (void) nPastSubblocks; + (void) nSubblocks; + assert( nSubblocks >= NSUBBLOCKS ); + assert( nPastSubblocks >= 2 ); + + /* attackRatioThreshold_1_5 = attackRatioThreshold * 1.5, exponent is ATTACKTHRESHOLD_E+1 */ + attackRatioThreshold_1_5 = add( shr( attackRatioThreshold, 2 ), shr( attackRatioThreshold, 1 ) ); + + move16(); + move16(); + bIsAttackPresent = FALSE; + attackIndex = -1; + /* Search for the last attack in the subblocks */ + IF( s_or( (Word16) GT_32( L_shr( pSubblockNrg[-1], ATTACKTHRESHOLD_E ), Mpy_32_16_1( pAccSubblockNrg[-1], attackRatioThreshold ) ), + L_sub( L_shr( pSubblockNrg[-2], ATTACKTHRESHOLD_E ), Mpy_32_16_1( pAccSubblockNrg[-2], attackRatioThreshold ) ) > 0 ) ) + { + move16(); + bIsAttackPresent = TRUE; + attackIndex = 0; + move16(); + } + + FOR( i = 0; i < NSUBBLOCKS; i++ ) + { + W_tmp2 = W_shr( W_mult_32_16( pAccSubblockNrg[i], attackRatioThreshold ), 1 ); + W_tmp1 = W_shl( pSubblockNrg[i], ( 15 - ATTACKTHRESHOLD_E ) ); + + IF( GT_64( W_tmp1, W_tmp2 ) ) + { + if ( i < 6 ) + { + move16(); + bIsAttackPresent = TRUE; + } + + IF( s_and( (Word16) NE_16( attackIndex, 2 ), (Word16) NE_16( attackIndex, 6 ) ) ) + { + move16(); + attackIndex = i; + W_tmp2 = W_shr( W_mult_32_16( pAccSubblockNrg[i], attackRatioThreshold ), 1 ); + W_tmp2 = W_add( W_tmp2, W_shr( W_tmp2, 3 ) ); // pAccSubblockNrg[i] * 1.125f + W_tmp1 = W_shl( pSubblockNrg[i], ( 15 - ATTACKTHRESHOLD_E ) ); + if ( s_and( (Word16) LT_64( W_tmp1, W_tmp2 ), s_or( (Word16) EQ_16( i, 2 ), (Word16) EQ_16( i, 6 ) ) ) ) + { + attackIndex = add( attackIndex, 1 ); /* avoid minimum overlap to prevent clicks */ + } + } + } + ELSE /* no attack, but set index anyway in case of strong energy increase */ + { + W_tmp2 = W_shr( W_mult_32_16( pSubblockNrg[i - 1], attackRatioThreshold_1_5 ), 1 ); + W_tmp1 = W_shl( pSubblockNrg[i], ( 15 - ( ATTACKTHRESHOLD_E + 1 ) ) ); + W_tmp3 = W_shr( W_mult_32_16( pSubblockNrg[i - 2], attackRatioThreshold_1_5 ), 1 ); + + IF( s_and( ( (Word16) GT_64( W_tmp1, W_tmp2 ) ), + ( W_sub( W_tmp1, W_tmp3 ) > 0 ) ) ) + { + + IF( s_and( (Word16) NE_16( attackIndex, 2 ), (Word16) NE_16( attackIndex, 6 ) ) ) + { + move16(); + attackIndex = i; + + W_tmp2 = W_mult_32_16( pSubblockNrg[i - 1], attackRatioThreshold ); + W_tmp3 = W_mult_32_16( pSubblockNrg[i - 2], attackRatioThreshold ); + W_tmp1 = W_shl( pSubblockNrg[i], ( 15 - ATTACKTHRESHOLD_E ) ); + + if ( s_and( (Word16) s_or( (Word16) LT_64( W_tmp1, W_tmp2 ), (Word16) + LT_64( W_tmp1, W_tmp3 ) ), + s_or( (Word16) EQ_16( i, 2 ), (Word16) EQ_16( i, 6 ) ) ) ) + { + attackIndex = add( attackIndex, 1 ); /* avoid minimum overlap to prevent clicks */ + } + } + } + } + } + /* avoid post-echos on click sounds (very short transients) due to TNS aliasing */ + if ( EQ_16( attackIndex, 4 ) ) + { + move16(); + attackIndex = 7; + } + if ( EQ_16( attackIndex, 5 ) ) + { + move16(); + attackIndex = 6; + } + + move16(); + move16(); + *pAttackIndex = attackIndex; + *pbIsAttackPresent = bIsAttackPresent; +} void GetAttackForTCXDecision_fx( Word32 const *pSubblockNrg, Word32 const *pAccSubblockNrg, Word16 nSubblocks, Word16 nPastSubblocks, Word16 attackRatioThreshold, Word16 *pbIsAttackPresent, Word16 *pAttackIndex ) { @@ -256,7 +358,7 @@ void InitTransientDetection_ivas_fx( Word16 nFrameLength, /* Init a subblock energies buffer used for the TCX Short/Long decision. */ InitSubblockEnergies_ivas_fx( nFrameLength, nTCXDelay, &pTransientDetection->delayBuffer, &pTransientDetection->subblockEnergies ); /* Init the TCX Short/Long transient detector. */ - InitTransientDetector_ivas_fx( &pTransientDetection->subblockEnergies, nTCXDelay, NSUBBLOCKS, GetAttackForTCXDecision, 17408 /*8.5f/(1<transientDetector ); + InitTransientDetector_ivas_fx( &pTransientDetection->subblockEnergies, nTCXDelay, NSUBBLOCKS, GetAttackForTCXDecision_ivas_fx, 17408 /*8.5f/(1<transientDetector ); /* We need two past subblocks for the TCX TD and NSUBBLOCKS+1 for the temporal flatness measure FOR the TCX LTP. */ IF( ext_mem_flag ) { @@ -377,9 +479,11 @@ Word16 GetTCXMaxenergyChange_fx( struct TransientDetection const *pTransientDete nRelativeDelay = sub( pSubblockEnergies->nDelay, nDelay ); pSubblockNrgChange = NULL; nTotBlocks = nCurrentSubblocks + nPrevSubblocks; + move16(); assert( nTotBlocks > 0 ); maxEnergyChange = 0 /*0.0f Q7*/; + move16(); assert( ( nPrevSubblocks <= nRelativeDelay ) && ( nCurrentSubblocks <= NSUBBLOCKS + nDelay ) ); pSubblockNrgChange = &pSubblockEnergies->subblockNrgChange[nRelativeDelay - nPrevSubblocks]; @@ -565,13 +669,18 @@ 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 - pSubblockEnergies->firState1 = shl( pSubblockEnergies->firState1, 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 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,6 +824,20 @@ void SetTCXModeInfo_ivas_fx( move16(); } } + +#ifdef SUPPORT_FORCE_TCX10_TCX20 +#ifdef DEBUGGING + if ( st->force == FORCE_TCX10 ) + { + hTcxEnc->tcxMode = TCX_10; + } + else if ( st->force == FORCE_TCX20 ) + { + hTcxEnc->tcxMode = TCX_20; + } +#endif +#endif + /* set the left window overlap */ test(); test(); @@ -758,7 +881,7 @@ void SetTCXModeInfo_ivas_fx( IF( isLongTermTransient_fx( L_deposit_h( tmp ), &hTcxEnc->tfm_mem_fx ) && EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) { test(); - if ( NE_16( *tcxModeOverlap, MIN_OVERLAP ) && LT_16( hTcxEnc->tcxltp_norm_corr_past, 18432 /* 0.5625f in Q15 */ ) ) + IF( NE_16( *tcxModeOverlap, MIN_OVERLAP ) && LT_16( hTcxEnc->tcxltp_norm_corr_past, 18432 /* 0.5625f in Q15 */ ) ) { *tcxModeOverlap = HALF_OVERLAP; move16(); @@ -809,7 +932,7 @@ void SetTCXModeInfo_ivas_fx( /* for the ACELP -> TCX transition frames use full right window overlap */ test(); - if ( ( EQ_16( st->hTcxCfg->tcx_last_overlap_mode, TRANSITION_OVERLAP ) ) && ( EQ_16( *tcxModeOverlap, ALDO_WINDOW ) ) ) + IF( ( EQ_16( st->hTcxCfg->tcx_last_overlap_mode, TRANSITION_OVERLAP ) ) && ( EQ_16( *tcxModeOverlap, ALDO_WINDOW ) ) ) { *tcxModeOverlap = FULL_OVERLAP; move16(); @@ -967,6 +1090,7 @@ static void InitDelayBuffer( Word16 nFrameLength, Word16 nDelay, DelayBuffer *pD static void InitSubblockEnergies( Word16 nFrameLength, Word16 nDelay, DelayBuffer *pDelayBuffer, SubblockEnergies *pSubblockEnergies ) { Word16 const nMaxBuffSize = sizeof( pSubblockEnergies->subblockNrg ) / sizeof( pSubblockEnergies->subblockNrg[0] ); + move16(); (void) nFrameLength; @@ -975,12 +1099,17 @@ static void InitSubblockEnergies( Word16 nFrameLength, Word16 nDelay, DelayBuffe set32_fx( pSubblockEnergies->subblockNrg, MIN_BLOCK_ENERGY, nMaxBuffSize ); set32_fx( pSubblockEnergies->accSubblockNrg, MIN_BLOCK_ENERGY, nMaxBuffSize + 1 ); set16_fx( pSubblockEnergies->subblockNrgChange, 0x7fff, nMaxBuffSize ); - pSubblockEnergies->nDelay = nDelay / pDelayBuffer->nSubblockSize; + pSubblockEnergies->nDelay = idiv1616_1( nDelay, pDelayBuffer->nSubblockSize ); assert( pSubblockEnergies->nDelay < nMaxBuffSize ); pSubblockEnergies->nPartialDelay = nDelay % pDelayBuffer->nSubblockSize; pSubblockEnergies->facAccSubblockNrg = 26624 /*0.8125f Q15*/; /* Energy accumulation factor */ pSubblockEnergies->firState1 = 0; pSubblockEnergies->firState2 = 0; + move16(); + move16(); + move16(); + move16(); + move16(); pSubblockEnergies->pDelayBuffer = pDelayBuffer; pDelayBuffer->nDelay = s_max( pDelayBuffer->nDelay, pSubblockEnergies->nPartialDelay ); @@ -1043,16 +1172,22 @@ static void InitTransientDetector_fx( SubblockEnergies *pSubblockEnergies, Word1 assert( ( pSubblockEnergies != NULL ) && ( pSubblockEnergies->pDelayBuffer != NULL ) && ( pTransientDetector != NULL ) && ( pSubblockEnergies->pDelayBuffer->nSubblockSize != 0 ) ); pTransientDetector->pSubblockEnergies = pSubblockEnergies; pTransientDetector->nDelay = ( nDelay - pSubblockEnergies->nPartialDelay ) / pSubblockEnergies->pDelayBuffer->nSubblockSize; + move16(); assert( nDelay == pTransientDetector->nDelay * pSubblockEnergies->pDelayBuffer->nSubblockSize + pSubblockEnergies->nPartialDelay ); assert( pTransientDetector->nDelay < nMaxBuffSize ); pSubblockEnergies->nDelay = s_max( pSubblockEnergies->nDelay, pTransientDetector->nDelay ); assert( nSubblocksToCheck <= NSUBBLOCKS + pTransientDetector->nDelay ); pTransientDetector->nSubblocksToCheck = nSubblocksToCheck; + move16(); pTransientDetector->CheckSubblocksForAttack_fx = pCheckSubblocksForAttack; pTransientDetector->attackRatioThreshold = attackRatioThreshold; + move16(); pTransientDetector->prev_bIsAttackPresent = FALSE; + move16(); pTransientDetector->bIsAttackPresent = FALSE; + move16(); pTransientDetector->attackIndex = -1; + move16(); } static void InitTransientDetector_ivas_fx( SubblockEnergies *pSubblockEnergies, Word16 nDelay, Word16 nSubblocksToCheck, TCheckSubblocksForAttack_fx pCheckSubblocksForAttack, Word16 attackRatioThreshold, TransientDetector *pTransientDetector ) @@ -1156,7 +1291,7 @@ static void UpdateDelayBuffer( Word16 const *input, Word16 nSamplesAvailable, De assert( ( nDelay >= 0 ) && ( nDelay <= (int) sizeof( pDelayBuffer->buffer ) / (int) sizeof( pDelayBuffer->buffer[0] ) ) ); assert( nSamplesAvailable <= NSUBBLOCKS * pDelayBuffer->nSubblockSize ); /* If this is not the last frame */ - IF( nSamplesAvailable == NSUBBLOCKS * pDelayBuffer->nSubblockSize ) + IF( EQ_16( nSamplesAvailable, imult1616( NSUBBLOCKS, pDelayBuffer->nSubblockSize ) ) ) { /* Store the newest samples into the delay buffer */ FOR( i = 0; i < nDelay; i++ ) @@ -1292,11 +1427,7 @@ static void CalculateSubblockEnergies( Word16 const *input, Word16 nSamplesAvail FOR( k = 0; k < w; k++ ) { tmp = shr( input[k], SUBBLOCK_NRG_E / 2 ); -#ifdef BASOP_NOGLOB accu = L_mac0_sat( accu, tmp, tmp ); -#else - accu = L_mac0( accu, tmp, tmp ); -#endif } move32(); @@ -1313,11 +1444,7 @@ static void CalculateSubblockEnergies( Word16 const *input, Word16 nSamplesAvail FOR( ; k < k2; k++ ) { tmp = shr( input[k], SUBBLOCK_NRG_E / 2 ); -#ifdef BASOP_NOGLOB accu = L_mac0_sat( accu, tmp, tmp ); -#else - accu = L_mac0( accu, tmp, tmp ); -#endif } move32(); pSubblockNrg[w] = accu; @@ -1412,11 +1539,7 @@ static void CalculateSubblockEnergies_ivas_fx( Word16 const *input, Word16 nSamp { tmp = input[k]; // Q0 move16(); -#ifdef BASOP_NOGLOB accu = L_mac0_sat( accu, tmp, tmp ); // Q0 -#else - accu = L_mac0( accu, tmp, tmp ); -#endif } pSubblockNrg[0] = accu; // Q0 @@ -1435,11 +1558,7 @@ static void CalculateSubblockEnergies_ivas_fx( Word16 const *input, Word16 nSamp { tmp = input[k]; // Q0 move16(); -#ifdef BASOP_NOGLOB accu = L_mac0_sat( accu, tmp, tmp ); // Q0 -#else - accu = L_mac0( accu, tmp, tmp ); -#endif } pSubblockNrg[w] = accu; // Q0 move32(); @@ -1561,7 +1680,7 @@ Word16 transient_analysis_ivas_fx( const Word16 nRelativeDelay = sub( hTranDet->subblockEnergies.nDelay, hTranDet->transientDetector.nDelay ); Word16 prel_force_td; Word32 cor_map_LT_sum = 0; - move16(); + move32(); /* Set pointer to the reverse accumulator buffer */ pTmp_fx = &accSubblockNrgRev_fx[NSUBBLOCKS - 1]; @@ -1686,3 +1805,76 @@ Word16 transient_analysis_ivas_fx( return prel_force_td != 0; } + +/*-------------------------------------------------------------------* + * set_transient_stereo() + * + * + *-------------------------------------------------------------------*/ +void set_transient_stereo_fx( + CPE_ENC_HANDLE hCPE, /* i : CPE structure */ + Word16 currFlatness[] /* i/o: current flatness */ +) +{ + Word16 n, attackIsPresent; + Word16 currFlatnessMax; + Encoder_State **sts; + + sts = hCPE->hCoreCoder; + + /* for DFT/TD based stereo ,map avg. flatness to individual stereo channels (M/S or X/Y) */ + maximum_fx( currFlatness, CPE_CHANNELS, &currFlatnessMax ); + attackIsPresent = 0; + move16(); + + FOR( n = 0; n < CPE_CHANNELS; n++ ) + { + attackIsPresent = s_max( attackIsPresent, sts[n]->hTranDet->transientDetector.bIsAttackPresent ); + } + + set16_fx( currFlatness, currFlatnessMax, CPE_CHANNELS ); + + FOR( n = 0; n < CPE_CHANNELS; n++ ) + { + sts[n]->hTranDet->transientDetector.bIsAttackPresent = attackIsPresent; + move16(); + } + + IF( hCPE->hStereoDft != NULL ) + { + IF( hCPE->hStereoDft->attackPresent ) + { + hCPE->hStereoDft->wasTransient = 1; + move16(); + } + ELSE IF( hCPE->hStereoDft->wasTransient ) + { + hCPE->hStereoDft->wasTransient = 0; + move16(); + } + + hCPE->hStereoDft->attackPresent = attackIsPresent; + move16(); + + hCPE->hStereoDft->hItd->currFlatness_fx = 0; + move16(); + FOR( n = 0; n < CPE_CHANNELS; n++ ) + { + hCPE->hStereoDft->hItd->currFlatness_fx = s_max( hCPE->hStereoDft->hItd->currFlatness_fx, currFlatness[n] ); + move16(); + } + } + + IF( hCPE->hStereoMdct != NULL ) + { + hCPE->hStereoMdct->hItd->currFlatness_fx = 0; + move16(); + FOR( n = 0; n < CPE_CHANNELS; n++ ) + { + hCPE->hStereoMdct->hItd->currFlatness_fx = s_max( hCPE->hStereoMdct->hItd->currFlatness_fx, currFlatness[n] ); + move16(); + } + } + + return; +} diff --git a/lib_enc/transition_enc.c b/lib_enc/transition_enc.c deleted file mode 100644 index 5f6981ef6a10eb4df6842d5c37d90c5468adf943..0000000000000000000000000000000000000000 --- a/lib_enc/transition_enc.c +++ /dev/null @@ -1,44 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "rom_com.h" -#include "prot.h" -#include "wmc_auto.h" -#include "prot_fx.h" diff --git a/lib_enc/transition_enc_fx.c b/lib_enc/transition_enc_fx.c index b4f9b2681bf0ce1e263ec4f8af2d9d33081f80af..0089fc745e46d2fb7a92aac9126e0ed66083faff 100644 --- a/lib_enc/transition_enc_fx.c +++ b/lib_enc/transition_enc_fx.c @@ -114,6 +114,8 @@ void transition_enc_fx( T_op[1] = (int16_t)(pitch[1] * 1.25f + 0.5f);*/ T_op[0] = add( st_fx->pitch[0], mult_r( st_fx->pitch[0], 8192 /*0.25f Q15*/ ) ); T_op[1] = add( st_fx->pitch[1], mult_r( st_fx->pitch[1], 8192 /*0.25f Q15*/ ) ); + move16(); + move16(); } shift_wsp = add( Q_new, shift ); @@ -132,6 +134,7 @@ void transition_enc_fx( IF( i_subfr == 0 ) { mult_Top = 1; + move16(); IF( limit_flag == 0 ) { test(); @@ -166,6 +169,7 @@ void transition_enc_fx( g_corr_fx[2] = -16384; move16(); g_corr_fx[3] = shl( sub( shift_wsp, 1 ), 1 ); + move16(); set16_fx( &exc_fx[i_subfr], 0, L_SUBFR ); /* set excitation for current subrame to 0 */ @@ -210,11 +214,16 @@ 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*/ ); } *clip_gain = gp_clip_fx( st_fx->element_mode, st_fx->core_brate, st_fx->voicing_fx, i_subfr, TRANSITION, xn_fx, gp_cl_fx, sub( shift_wsp, 1 ) ); + move16(); updt_tar_fx( xn_fx, xn2_fx, y1_fx, *gain_pit_fx, L_SUBFR ); **pt_pitch_fx = shl( add( shl( *T0, 2 ), *T0_frac ), 4 ); @@ -282,6 +291,7 @@ void transition_enc_fx( /* Find the closed loop pitch period */ *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, pit_flag, limit_flag, pit_start, pit_limit, L_FRAME, L_SUBFR ); + move16(); offset = tbe_celp_exc_offset( *T0, *T0_frac, st_fx->L_frame ); @@ -289,6 +299,7 @@ void transition_enc_fx( FOR( i = 0; i < L_SUBFR * HIBND_ACB_L_FAC; i++ ) { bwe_exc_fx[i + i_subfr * HIBND_ACB_L_FAC] = bwe_exc_fx[i + i_subfr * HIBND_ACB_L_FAC - offset]; + move16(); } @@ -319,7 +330,11 @@ 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*/ ); } /*-----------------------------------------------------------------* @@ -394,6 +409,7 @@ void transition_enc_fx( FOR( i = 0; i < L_SUBFR * HIBND_ACB_L_FAC; i++ ) { bwe_exc_fx[i + i_subfr * HIBND_ACB_L_FAC] = bwe_exc_fx[i + i_subfr * HIBND_ACB_L_FAC - offset]; + move16(); } } ELSE IF( ( EQ_16( i_subfr, 2 * L_SUBFR ) ) && ( EQ_16( *tc_subfr, TC_0_128 ) ) ) @@ -408,6 +424,7 @@ void transition_enc_fx( move16(); *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, pit_flag, limit_flag, pit_start, 3 * L_SUBFR, L_FRAME, L_SUBFR ); + move16(); IF( LT_16( add( ( *T0 ), ( *position ) ), 2 * L_SUBFR ) ) { @@ -441,6 +458,7 @@ void transition_enc_fx( FOR( i = 0; i < L_SUBFR * HIBND_ACB_L_FAC; i++ ) { bwe_exc_fx[i + i_subfr * HIBND_ACB_L_FAC] = bwe_exc_fx[i + i_subfr * HIBND_ACB_L_FAC - offset]; + move16(); } } ELSE IF( ( EQ_16( i_subfr, 2 * L_SUBFR ) ) && ( EQ_16( *tc_subfr, TC_0_192 ) ) ) @@ -469,6 +487,7 @@ void transition_enc_fx( move16(); *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(); IF( LT_16( add( *T0, *position ), 3 * L_SUBFR ) ) { @@ -514,6 +533,7 @@ void transition_enc_fx( pit_flag = L_SUBFR; move16(); *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 ); @@ -526,6 +546,7 @@ void transition_enc_fx( FOR( i = 0; i < L_SUBFR * HIBND_ACB_L_FAC; i++ ) { bwe_exc_fx[i + i_subfr * HIBND_ACB_L_FAC] = bwe_exc_fx[i + i_subfr * HIBND_ACB_L_FAC - offset]; + move16(); } } @@ -538,15 +559,18 @@ void transition_enc_fx( test(); IF( EQ_16( nBits, 8 ) || EQ_16( nBits, 5 ) ) { + test(); test(); IF( !( ( *tc_subfr == 0 ) && ( EQ_16( i_subfr, L_SUBFR ) ) ) ) { *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(); } } ELSE { *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, pit_flag, limit_flag, PIT_FR2_9b, PIT_FR1_9b, L_FRAME, L_SUBFR ); + move16(); } pit_Q_enc_fx( hBstr, 0, nBits, 8, pit_flag, limit_flag, *T0, *T0_frac, T0_min, T0_max ); @@ -558,6 +582,7 @@ void transition_enc_fx( FOR( i = 0; i < L_SUBFR * HIBND_ACB_L_FAC; i++ ) { bwe_exc_fx[i + i_subfr * HIBND_ACB_L_FAC] = bwe_exc_fx[i + i_subfr * HIBND_ACB_L_FAC - offset]; + move16(); } } @@ -584,6 +609,7 @@ void transition_enc_fx( ELSE { *clip_gain = gp_clip_fx( st_fx->element_mode, st_fx->core_brate, st_fx->voicing_fx, i_subfr, TRANSITION, xn_fx, gp_cl_fx, ( Q_new + shift - 1 ) ); + move16(); lp_select = lp_filt_exc_enc_fx( MODE1, TRANSITION, i_subfr, exc_fx, h1_fx, xn_fx, y1_fx, xn2_fx, L_SUBFR, st_fx->L_frame, g_corr_fx, *clip_gain, gain_pit_fx, &lp_flag ); @@ -604,7 +630,7 @@ void transition_enc_fx( test(); test(); test(); - IF( ( *tc_subfr >= 2 * L_SUBFR ) && ( i_subfr == 3 * L_SUBFR ) ) + IF( ( GE_16( *tc_subfr, 2 * L_SUBFR ) ) && ( EQ_16( i_subfr, 3 * L_SUBFR ) ) ) { tmp = shl( add( shl( *T0, 2 ), *T0_frac ), 4 ); ( *pt_pitch_fx ) -= 3; @@ -620,8 +646,9 @@ void transition_enc_fx( **pt_pitch_fx = tmp; move16(); ( *pt_pitch_fx )++; + move16(); } - ELSE IF( ( *tc_subfr == L_SUBFR ) && ( i_subfr == 2 * L_SUBFR ) ) + ELSE IF( ( EQ_16( *tc_subfr, L_SUBFR ) ) && ( EQ_16( i_subfr, 2 * L_SUBFR ) ) ) { tmp = shl( add( shl( *T0, 2 ), *T0_frac ), 4 ); ( *pt_pitch_fx ) -= 2; @@ -635,7 +662,7 @@ void transition_enc_fx( ( *pt_pitch_fx )++; move16(); } - ELSE IF( ( *tc_subfr == TC_0_64 ) && ( i_subfr == L_SUBFR ) ) + ELSE IF( ( EQ_16( *tc_subfr, TC_0_64 ) ) && ( EQ_16( i_subfr, L_SUBFR ) ) ) { tmp = shl( add( shl( *T0, 2 ), *T0_frac ), 4 ); ( *pt_pitch_fx ) -= 1; @@ -645,7 +672,7 @@ void transition_enc_fx( ( *pt_pitch_fx )++; move16(); } - ELSE IF( ( *tc_subfr == TC_0_128 ) && ( i_subfr == 2 * L_SUBFR ) ) + ELSE IF( ( EQ_16( *tc_subfr, TC_0_128 ) ) && ( EQ_16( i_subfr, 2 * L_SUBFR ) ) ) { tmp = shl( add( shl( *T0, 2 ), *T0_frac ), 4 ); ( *pt_pitch_fx ) -= 2; @@ -659,7 +686,7 @@ void transition_enc_fx( ( *pt_pitch_fx )++; move16(); } - ELSE IF( ( *tc_subfr == TC_0_192 ) && ( i_subfr == 3 * L_SUBFR ) ) + ELSE IF( ( EQ_16( *tc_subfr, TC_0_192 ) ) && ( EQ_16( i_subfr, 3 * L_SUBFR ) ) ) { tmp = shl( add( shl( *T0, 2 ), *T0_frac ), 4 ); ( *pt_pitch_fx ) -= 3; @@ -719,6 +746,7 @@ void transition_enc_fx( IF( EQ_16( nBits, 10 ) ) { *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, 0, limit_flag, PIT16k_FR2_EXTEND_10b, PIT16k_MAX, st_fx->L_frame, L_SUBFR ); + move16(); pit16k_Q_enc_fx( hBstr, nBits, limit_flag, *T0, *T0_frac, T0_min, T0_max ); } ELSE IF( EQ_16( nBits, 8 ) ) /* tc_subfr==0 && i_subfr==L_SUBFR */ @@ -729,6 +757,7 @@ void transition_enc_fx( * PIT16k_FR2_TC0_2SUBFR to 2*L_SUBFR resolution 1/2 (frac = 0 or 2) *-----------------------------------------------------------------------------*/ *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, 0, limit_flag, PIT16k_FR2_TC0_2SUBFR, 2 * L_SUBFR, st_fx->L_frame, L_SUBFR ); + move16(); IF( GT_16( *T0_max, 2 * L_SUBFR ) ) { @@ -754,6 +783,7 @@ void transition_enc_fx( { /* delta search */ *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, L_SUBFR, limit_flag, PIT16k_FR2_EXTEND_9b, PIT16k_FR1_EXTEND_9b, st_fx->L_frame, L_SUBFR ); + move16(); index = delta_pit_enc_fx( 4, *T0, *T0_frac, *T0_min ); push_indice_fx( hBstr, IND_PITCH, index, nBits ); @@ -807,9 +837,11 @@ void transition_enc_fx( { /* bwe_exc_fx[i + i_subfr * 2] = bwe_exc_fx[i + i_subfr * 2 - *T0 * 2 - (int) ((float) *T0_frac * 0.5f + 4 + 0.5f) + 4];move16();*/ bwe_exc_fx[i + i_subfr * 2] = bwe_exc_fx[i + i_subfr * 2 - offset + 4]; + move16(); } *clip_gain = gp_clip_fx( st_fx->element_mode, st_fx->core_brate, st_fx->voicing_fx, i_subfr, TRANSITION, xn_fx, gp_cl_fx, Q_new ); + move16(); lp_select = lp_filt_exc_enc_fx( MODE1, TRANSITION, i_subfr, exc_fx, h1_fx, xn_fx, y1_fx, xn2_fx, L_SUBFR, st_fx->L_frame, g_corr_fx, *clip_gain, gain_pit_fx, &lp_flag ); @@ -845,6 +877,7 @@ void transition_enc_fx( **pt_pitch_fx = tmp; move16(); ( *pt_pitch_fx )++; + move16(); } } } @@ -891,7 +924,8 @@ void transition_enc_ivas_fx( /* set limit_flag to 0 for restrained limits, and 1 for extended limits */ limit_flag = 0; move16(); - + Word16 h1_fx_q15[L_SUBFR + ( M + 1 )]; + Copy_Scale_sig( h1_fx, h1_fx_q15, L_SUBFR + ( M + 1 ), 0 ); pit_start = PIT_MIN; move16(); @@ -908,7 +942,9 @@ void transition_enc_ivas_fx( /*T_op[0] = (int16_t)(pitch[0] * 1.25f + 0.5f); T_op[1] = (int16_t)(pitch[1] * 1.25f + 0.5f);*/ T_op[0] = add( st_fx->pitch[0], mult_r( st_fx->pitch[0], 8192 /*0.25f Q15*/ ) ); + move16(); T_op[1] = add( st_fx->pitch[1], mult_r( st_fx->pitch[1], 8192 /*0.25f Q15*/ ) ); + move16(); } shift_wsp = add( Q_new, shift ); @@ -927,6 +963,7 @@ void transition_enc_ivas_fx( IF( i_subfr == 0 ) { mult_Top = 1; + move16(); IF( limit_flag == 0 ) { test(); @@ -956,7 +993,6 @@ void transition_enc_ivas_fx( move16(); g_corr_fx[0] = MAX16B /* 1.0f in Q15 */; move16(); - move16(); g_corr_fx[1] = 0; move16(); g_corr_fx[2] = MAX16B /* 1.0f in Q15 */; @@ -1007,11 +1043,16 @@ 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*/ ); } *clip_gain = gp_clip_fx( st_fx->element_mode, st_fx->core_brate, st_fx->voicing_fx, i_subfr, TRANSITION, xn_fx, gp_cl_fx, sub( shift_wsp, 1 ) ); + move16(); updt_tar_fx( xn_fx, xn2_fx, y1_fx, *gain_pit_fx, L_SUBFR ); **pt_pitch_fx = shl( add( shl( *T0, 2 ), *T0_frac ), 4 ); @@ -1079,6 +1120,7 @@ void transition_enc_ivas_fx( /* Find the closed loop pitch period */ *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, pit_flag, limit_flag, pit_start, pit_limit, L_FRAME, L_SUBFR ); + move16(); offset = tbe_celp_exc_offset( *T0, *T0_frac, st_fx->L_frame ); @@ -1086,6 +1128,7 @@ void transition_enc_ivas_fx( FOR( i = 0; i < L_SUBFR * HIBND_ACB_L_FAC; i++ ) { bwe_exc_fx[i + i_subfr * HIBND_ACB_L_FAC] = bwe_exc_fx[i + i_subfr * HIBND_ACB_L_FAC - offset]; + move16(); } @@ -1116,7 +1159,11 @@ 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*/ ); } /*-----------------------------------------------------------------* @@ -1191,6 +1238,7 @@ void transition_enc_ivas_fx( FOR( i = 0; i < L_SUBFR * HIBND_ACB_L_FAC; i++ ) { bwe_exc_fx[i + i_subfr * HIBND_ACB_L_FAC] = bwe_exc_fx[i + i_subfr * HIBND_ACB_L_FAC - offset]; + move16(); } } ELSE IF( ( EQ_16( i_subfr, 2 * L_SUBFR ) ) && ( EQ_16( *tc_subfr, TC_0_128 ) ) ) @@ -1205,6 +1253,7 @@ void transition_enc_ivas_fx( move16(); *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, pit_flag, limit_flag, pit_start, 3 * L_SUBFR, L_FRAME, L_SUBFR ); + move16(); IF( LT_16( add( ( *T0 ), ( *position ) ), 2 * L_SUBFR ) ) { @@ -1238,6 +1287,7 @@ void transition_enc_ivas_fx( FOR( i = 0; i < L_SUBFR * HIBND_ACB_L_FAC; i++ ) { bwe_exc_fx[i + i_subfr * HIBND_ACB_L_FAC] = bwe_exc_fx[i + i_subfr * HIBND_ACB_L_FAC - offset]; + move16(); } } ELSE IF( ( EQ_16( i_subfr, 2 * L_SUBFR ) ) && ( EQ_16( *tc_subfr, TC_0_192 ) ) ) @@ -1266,6 +1316,7 @@ void transition_enc_ivas_fx( move16(); *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(); IF( LT_16( add( *T0, *position ), 3 * L_SUBFR ) ) { @@ -1310,7 +1361,9 @@ void transition_enc_ivas_fx( *--------------------------------------------------------*/ pit_flag = L_SUBFR; move16(); + *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( hBstr, IND_PITCH, index, nBits ); @@ -1323,6 +1376,7 @@ void transition_enc_ivas_fx( FOR( i = 0; i < L_SUBFR * HIBND_ACB_L_FAC; i++ ) { bwe_exc_fx[i + i_subfr * HIBND_ACB_L_FAC] = bwe_exc_fx[i + i_subfr * HIBND_ACB_L_FAC - offset]; + move16(); } } @@ -1339,11 +1393,13 @@ void transition_enc_ivas_fx( IF( !( ( *tc_subfr == 0 ) && ( EQ_16( i_subfr, L_SUBFR ) ) ) ) { *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(); } } ELSE { *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, pit_flag, limit_flag, PIT_FR2_9b, PIT_FR1_9b, L_FRAME, L_SUBFR ); + move16(); } pit_Q_enc_ivas_fx( hBstr, 0, nBits, 8, pit_flag, limit_flag, *T0, *T0_frac, T0_min, T0_max ); @@ -1355,6 +1411,7 @@ void transition_enc_ivas_fx( FOR( i = 0; i < L_SUBFR * HIBND_ACB_L_FAC; i++ ) { bwe_exc_fx[i + i_subfr * HIBND_ACB_L_FAC] = bwe_exc_fx[i + i_subfr * HIBND_ACB_L_FAC - offset]; + move16(); } } @@ -1381,8 +1438,10 @@ void transition_enc_ivas_fx( ELSE { *clip_gain = gp_clip_fx( st_fx->element_mode, st_fx->core_brate, st_fx->voicing_fx, i_subfr, TRANSITION, xn_fx, gp_cl_fx, ( Q_new + shift - 1 ) ); + move16(); - lp_select = lp_filt_exc_enc_ivas_fx( MODE1, TRANSITION, i_subfr, exc_fx, h1_fx, + Copy_Scale_sig( h1_fx, h1_fx_q15, L_SUBFR + ( M + 1 ), 1 ); + lp_select = lp_filt_exc_enc_ivas_fx( MODE1, TRANSITION, i_subfr, exc_fx, h1_fx_q15, xn_fx, y1_fx, xn2_fx, L_SUBFR, st_fx->L_frame, g_corr_fx, *clip_gain, gain_pit_fx, &lp_flag ); IF( EQ_16( lp_flag, NORMAL_OPERATION ) ) @@ -1417,6 +1476,7 @@ void transition_enc_ivas_fx( **pt_pitch_fx = tmp; move16(); ( *pt_pitch_fx )++; + move16(); } ELSE IF( ( *tc_subfr == L_SUBFR ) && ( i_subfr == 2 * L_SUBFR ) ) { @@ -1516,6 +1576,7 @@ void transition_enc_ivas_fx( IF( EQ_16( nBits, 10 ) ) { *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, 0, limit_flag, PIT16k_FR2_EXTEND_10b, PIT16k_MAX, st_fx->L_frame, L_SUBFR ); + move16(); pit16k_Q_enc_ivas_fx( hBstr, nBits, limit_flag, *T0, *T0_frac, T0_min, T0_max ); } ELSE IF( EQ_16( nBits, 8 ) ) /* tc_subfr==0 && i_subfr==L_SUBFR */ @@ -1526,6 +1587,7 @@ void transition_enc_ivas_fx( * PIT16k_FR2_TC0_2SUBFR to 2*L_SUBFR resolution 1/2 (frac = 0 or 2) *-----------------------------------------------------------------------------*/ *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, 0, limit_flag, PIT16k_FR2_TC0_2SUBFR, 2 * L_SUBFR, st_fx->L_frame, L_SUBFR ); + move16(); IF( GT_16( *T0_max, 2 * L_SUBFR ) ) { @@ -1551,6 +1613,7 @@ void transition_enc_ivas_fx( { /* delta search */ *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, L_SUBFR, limit_flag, PIT16k_FR2_EXTEND_9b, PIT16k_FR1_EXTEND_9b, st_fx->L_frame, L_SUBFR ); + move16(); index = delta_pit_enc_fx( 4, *T0, *T0_frac, *T0_min ); push_indice( hBstr, IND_PITCH, index, nBits ); @@ -1608,13 +1671,15 @@ void transition_enc_ivas_fx( { /* bwe_exc_fx[i + i_subfr * 2] = bwe_exc_fx[i + i_subfr * 2 - *T0 * 2 - (int) ((float) *T0_frac * 0.5f + 4 + 0.5f) + 4];move16();*/ bwe_exc_fx[i + i_subfr * 2] = bwe_exc_fx[i + i_subfr * 2 - offset + 4]; + move16(); } *clip_gain = gp_clip_fx( st_fx->element_mode, st_fx->core_brate, st_fx->voicing_fx, i_subfr, TRANSITION, xn_fx, gp_cl_fx, Q_new ); + move16(); - lp_select = lp_filt_exc_enc_ivas_fx( MODE1, TRANSITION, i_subfr, exc_fx, h1_fx, + Copy_Scale_sig( h1_fx, h1_fx_q15, L_SUBFR + ( M + 1 ), 1 ); + lp_select = lp_filt_exc_enc_ivas_fx( MODE1, TRANSITION, i_subfr, exc_fx, h1_fx_q15, xn_fx, y1_fx, xn2_fx, L_SUBFR, st_fx->L_frame, g_corr_fx, *clip_gain, gain_pit_fx, &lp_flag ); - IF( EQ_16( lp_flag, NORMAL_OPERATION ) ) { push_indice( hBstr, IND_LP_FILT_SELECT, lp_select, 1 ); @@ -1646,6 +1711,7 @@ void transition_enc_ivas_fx( **pt_pitch_fx = tmp; move16(); ( *pt_pitch_fx )++; + move16(); } } } @@ -1695,6 +1761,7 @@ static void tc_enc_fx( BSTR_ENC_HANDLE hBstr = st_fx->hBstr; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif imp_pos = sub( *position, i_subfr ); FOR( i = 0; i < L_SUBFR; i++ ) @@ -1707,6 +1774,7 @@ static void tc_enc_fx( *-----------------------------------------------------------------*/ nBits = st_fx->acelp_cfg.pitch_bits[shr( i_subfr, 6 )]; + move16(); /*--------------------------------------------------------------* * Closed loop pitch search @@ -1723,14 +1791,17 @@ static void tc_enc_fx( IF( EQ_16( nBits, 9 ) ) { *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, 0, 0, PIT_FR2_9b, PIT_FR1_9b, L_FRAME, L_SUBFR ); + move16(); } ELSE IF( EQ_16( nBits, 6 ) ) { *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, 0, 0, PIT_MIN, L_SUBFR, L_FRAME, L_SUBFR ); + move16(); } ELSE { *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, 0, 0, PIT_MAX, PIT_MIN, L_FRAME, L_SUBFR ); + move16(); } } ELSE @@ -1750,11 +1821,13 @@ static void tc_enc_fx( IF( EQ_16( nBits, 10 ) ) { *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, 0, 1, PIT16k_FR2_EXTEND_10b, PIT16k_MAX, L_FRAME16k, L_SUBFR ); + move16(); } ELSE IF( EQ_16( nBits, 6 ) ) { /* T0_frac with 1/2 sample resolution */ *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, 0, 0, PIT16k_MIN, L_SUBFR, L_FRAME16k, L_SUBFR ); + move16(); IF( *T0 > L_SUBFR ) { *T0 = L_SUBFR; @@ -1815,11 +1888,8 @@ static void tc_enc_fx( conv_fx( &exc_fx[i_subfr], h1_fx, yy1_fx, L_SUBFR ); /* gain_pit computation */ -#ifdef BASOP_NOGLOB *gain_pit_fx = corr_xy1_fx( xn_fx, yy1_fx, g_corr_fx, L_SUBFR, 0, &Overflow ); -#else - *gain_pit_fx = corr_xy1_fx( xn_fx, yy1_fx, g_corr_fx, L_SUBFR, 0 ); -#endif + move16(); /*--------------------------------------------------------------* * Encode parameters and write indices *--------------------------------------------------------------*/ @@ -1891,7 +1961,7 @@ static void tc_enc_ivas_fx( const Word16 i_subfr, /* i : subrame index */ Word16 *tc_subfr, /* i/o: TC subframe index */ Word16 *position, /* i/o: index of the residual signal maximum */ - const Word16 *h1_fx, /* i : weighted filter input response Q(14+shift)*/ + const Word16 *h1, /* i : weighted filter input response Q(14+shift)*/ const Word16 *xn_fx, /* i : target signal Q_new-1+shift*/ Word16 *exc_fx, /* o : glottal codebook contribution Q_new*/ Word16 *yy1_fx, /* o : filtered glottal codebook contribution */ @@ -1905,24 +1975,23 @@ static void tc_enc_ivas_fx( Word16 Q_new /* i : input scaling */ ) { - Word16 i, imp_shape, imp_pos, index, nBits, h1_tmp_fx[L_SUBFR]; + + Word16 h1_fx[L_SUBFR + ( M + 1 )]; + Word16 imp_shape, imp_pos, index, nBits; Word16 pitch_index, pitch_sign_fx; Word32 gain_trans32; BSTR_ENC_HANDLE hBstr = st_fx->hBstr; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif imp_pos = sub( *position, i_subfr ); - FOR( i = 0; i < L_SUBFR; i++ ) - { - h1_tmp_fx[i] = h1_fx[i]; - move16(); - } /*-----------------------------------------------------------------* * get number of bits for pitch encoding *-----------------------------------------------------------------*/ nBits = st_fx->acelp_cfg.pitch_bits[shr( i_subfr, 6 )]; + move16(); /*--------------------------------------------------------------* * Closed loop pitch search @@ -1938,15 +2007,18 @@ static void tc_enc_ivas_fx( { IF( EQ_16( nBits, 9 ) ) { - *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, 0, 0, PIT_FR2_9b, PIT_FR1_9b, L_FRAME, L_SUBFR ); + *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1, *T0_min, *T0_max, T0_frac, 0, 0, PIT_FR2_9b, PIT_FR1_9b, L_FRAME, L_SUBFR ); + move16(); } ELSE IF( EQ_16( nBits, 6 ) ) { - *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, 0, 0, PIT_MIN, L_SUBFR, L_FRAME, L_SUBFR ); + *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1, *T0_min, *T0_max, T0_frac, 0, 0, PIT_MIN, L_SUBFR, L_FRAME, L_SUBFR ); + move16(); } ELSE { - *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, 0, 0, PIT_MAX, PIT_MIN, L_FRAME, L_SUBFR ); + *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1, *T0_min, *T0_max, T0_frac, 0, 0, PIT_MAX, PIT_MIN, L_FRAME, L_SUBFR ); + move16(); } } ELSE @@ -1965,12 +2037,13 @@ static void tc_enc_ivas_fx( { IF( EQ_16( nBits, 10 ) ) { - *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, 0, 1, PIT16k_FR2_EXTEND_10b, PIT16k_MAX, L_FRAME16k, L_SUBFR ); + *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1, *T0_min, *T0_max, T0_frac, 0, 1, PIT16k_FR2_EXTEND_10b, PIT16k_MAX, L_FRAME16k, L_SUBFR ); + move16(); } ELSE IF( EQ_16( nBits, 6 ) ) { /* T0_frac with 1/2 sample resolution */ - *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, 0, 0, PIT16k_MIN, L_SUBFR, L_FRAME16k, L_SUBFR ); + *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1, *T0_min, *T0_max, T0_frac, 0, 0, PIT16k_MIN, L_SUBFR, L_FRAME16k, L_SUBFR ); IF( *T0 > L_SUBFR ) { *T0 = L_SUBFR; @@ -1996,7 +2069,7 @@ static void tc_enc_ivas_fx( * Builds glottal codebook contribution *--------------------------------------------------------------*/ - set_impulse_fx( xn_fx, h1_tmp_fx, &exc_fx[i_subfr], yy1_fx, &imp_shape, &imp_pos, &gain_trans32, Q_new ); /*chk h1_tmp_fx*/ + set_impulse_fx( xn_fx, h1, &exc_fx[i_subfr], yy1_fx, &imp_shape, &imp_pos, &gain_trans32, Q_new ); /*--------------------------------------------------------------* * quantize gain_trans and scale glottal codebook contribution @@ -2026,16 +2099,13 @@ static void tc_enc_ivas_fx( /*--------------------------------------------------------------* * compute glottal-shape codebook excitation *--------------------------------------------------------------*/ - + Copy_Scale_sig( h1, h1_fx, L_SUBFR + ( M + 1 ), 1 ); /* create filtered glottal codebook contribution */ conv_fx( &exc_fx[i_subfr], h1_fx, yy1_fx, L_SUBFR ); /* gain_pit computation */ -#ifdef BASOP_NOGLOB *gain_pit_fx = corr_xy1_fx( xn_fx, yy1_fx, g_corr_fx, L_SUBFR, 0, &Overflow ); -#else - *gain_pit_fx = corr_xy1_fx( xn_fx, yy1_fx, g_corr_fx, L_SUBFR, 0 ); -#endif + move16(); /*--------------------------------------------------------------* * Encode parameters and write indices *--------------------------------------------------------------*/ @@ -2121,6 +2191,7 @@ static void gain_trans_enc_fx( Word16 i, imax, istart, tmp16, gain_trans, gscale; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif istart = 0; @@ -2129,19 +2200,11 @@ static void gain_trans_enc_fx( move16(); gscale = 7; move16(); -#ifdef BASOP_NOGLOB gain_trans = extract_h( L_shl_o( gain_trans32, 16, &Overflow ) ); /* Q7 */ -#else /* BASOP_NOGLOB */ - gain_trans = extract_h( L_shl( gain_trans32, 16 ) ); /* Q7 */ -#endif /* BASOP_NOGLOB */ IF( GT_32( L_abs( gain_trans32 ), 29862L ) ) { -#ifdef BASOP_NOGLOB gain_trans = extract_h( L_shl_o( gain_trans32, 16 - 3, &Overflow ) ); /* Q4 */ -#else /* BASOP_NOGLOB */ - gain_trans = extract_h( L_shl( gain_trans32, 16 - 3 ) ); /* Q4 */ -#endif /* BASOP_NOGLOB */ istart = 4; move16(); imax = N_GAIN_TC - 1; @@ -2174,11 +2237,8 @@ static void gain_trans_enc_fx( FOR( i = 0; i < L_SUBFR; i++ ) { /*exc[i] *= (*gain_trans);*/ -#ifdef BASOP_NOGLOB exc[i] = round_fx_o( L_shl_o( L_mult( exc[i], gain_trans ), tmp16, &Overflow ), &Overflow ); -#else - exc[i] = round_fx( L_shl( L_mult( exc[i], gain_trans ), tmp16 ) ); -#endif + move16(); } } @@ -2202,6 +2262,7 @@ void tc_classif_enc_fx( Word16 T_op, i; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif T_op = pitch; @@ -2258,6 +2319,7 @@ void tc_classif_enc_fx( ELSE { *position = emaximum_fx( Q_new, res, add( T_op, 2 ), &temp ); + move16(); /* correction in case of possibly wrong T_op (double-pitch values) */ test(); @@ -2266,24 +2328,20 @@ void tc_classif_enc_fx( IF( ( EQ_16( L_frame, L_FRAME ) && GT_16( T_op, 2 * PIT_MIN ) ) || ( EQ_16( L_frame, L_FRAME16k ) && GT_16( T_op, 2 * PIT16k_MIN ) ) ) { Word16 position_tmp, len, exp_aver = 0, exp = 0, exp2 = 0; + move16(); + move16(); + move16(); Word32 aver, temp2, L_sum, L_temp1, L_temp2; len = add( shr( T_op, 1 ), 2 ); position_tmp = emaximum_fx( Q_new, res, len, &temp2 ); -#ifdef BASOP_NOGLOB L_sum = L_mac_sat( 1L, res[0], res[0] ); -#else - L_sum = L_mac( 1L, res[0], res[0] ); -#endif FOR( i = 1; i < len; i++ ) { -#ifdef BASOP_NOGLOB L_sum = L_mac0_o( L_sum, res[i], res[i], &Overflow ); -#else /* BASOP_NOGLOB */ - L_sum = L_mac0( L_sum, res[i], res[i] ); -#endif /* BASOP_NOGLOB */ } - aver = L_sum; /*Q = 2*Q_new */ + aver = L_sum; /*Q = 2*Q_new */ + move32(); aver = root_a_over_b_fx( aver, 2 * Q_new, L_shl( len, 15 ), 15, &exp_aver ); /*Q = 31-exp_aver*/ temp = root_a_fx( temp, 0, &exp ); /* Q=31-exp */ @@ -2293,15 +2351,11 @@ void tc_classif_enc_fx( L_temp1 = Mult_32_16( temp, 8192 ); /* Q=31-exp */ test(); -#ifdef BASOP_NOGLOB IF( GT_32( temp2, L_shl_o( L_temp2, ( 31 - exp2 ) - ( 31 - exp ), &Overflow ) ) && LT_32( aver, L_shl_o( L_temp1, ( 31 - exp_aver ) - ( 31 - exp ), &Overflow ) ) ) -#else /* BASOP_NOGLOB */ - IF( GT_32( temp2, L_shl( L_temp2, ( 31 - exp2 ) - ( 31 - exp ) ) ) && - LT_32( aver, L_shl( L_temp1, ( 31 - exp_aver ) - ( 31 - exp ) ) ) ) -#endif { *position = position_tmp; + move16(); } } *tc_subfr = s_and( *position, 0x7FC0 ); diff --git a/lib_enc/update_decision.c b/lib_enc/update_decision.c deleted file mode 100644 index 825401325748d89d4db5894372ff8dd2e53d76ec..0000000000000000000000000000000000000000 --- a/lib_enc/update_decision.c +++ /dev/null @@ -1,41 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "prot.h" -#include "wmc_auto.h" diff --git a/lib_enc/update_decision_fx.c b/lib_enc/update_decision_fx.c index 7fda8e5d2047fbc60d3bccab140d6b336b54c85c..315adcf819d9061691879a2b3c4c3f4752bdba94 100644 --- a/lib_enc/update_decision_fx.c +++ b/lib_enc/update_decision_fx.c @@ -253,7 +253,7 @@ Word16 update_decision_fx( hVAD_CLDFB->tonality_rate3 = mult( hVAD_CLDFB->tonality_rate3, 32211 ); move16(); - if ( tonality_flag ) + IF( tonality_flag ) { hVAD_CLDFB->tonality_rate3 = add( mult( hVAD_CLDFB->tonality_rate3, 32211 ), 557 ); move16(); @@ -274,8 +274,7 @@ Word16 update_decision_fx( test(); test(); - IF( ( GT_16( f_tonality_rate[1], 7536 /* 0.46 Q14 */ ) ) && ( ( GT_16( sSFM[1], 30473 /* 0.93 Q15 */ ) ) || ( GT_16( ltd_stable_rate[0], 2949 /* 0.09 Q15 */ ) ) ) ) - + if ( ( GT_16( f_tonality_rate[1], 7536 /* 0.46 Q14 */ ) ) && ( ( GT_16( sSFM[1], 30473 /* 0.93 Q15 */ ) ) || ( GT_16( ltd_stable_rate[0], 2949 /* 0.09 Q15 */ ) ) ) ) { update_flag = 0; move16(); @@ -284,7 +283,7 @@ Word16 update_decision_fx( test(); test(); test(); - IF( ( LT_16( sSFM[1], 30473 /* 0.93 Q15 */ ) && LT_16( sSFM[0], 30146 /* 0.92 Q15 */ ) && LT_16( sSFM[2], 31784 /* 0.97 Q15 */ ) ) && ( GT_16( f_tonality_rate[1], 8192 /* 0.5 Q14 */ ) ) ) + if ( ( LT_16( sSFM[1], 30473 /* 0.93 Q15 */ ) && LT_16( sSFM[0], 30146 /* 0.92 Q15 */ ) && LT_16( sSFM[2], 31784 /* 0.97 Q15 */ ) ) && ( GT_16( f_tonality_rate[1], 8192 /* 0.5 Q14 */ ) ) ) { update_flag = 0; move16(); @@ -292,7 +291,7 @@ Word16 update_decision_fx( test(); test(); - IF( ( f_tonality_rate[1] > 7045 /* 0.43 Q14 */ ) && ( sSFM[0] < 31129 /* 0.95 Q15 */ ) && ( sp_center[1] > 1985 /* 1.94 Q10 */ ) ) + if ( ( f_tonality_rate[1] > 7045 /* 0.43 Q14 */ ) && ( sSFM[0] < 31129 /* 0.95 Q15 */ ) && ( sp_center[1] > 1985 /* 1.94 Q10 */ ) ) { update_flag = 0; move16(); @@ -300,9 +299,10 @@ Word16 update_decision_fx( IF( EQ_16( update_flag, 1 ) ) { - if ( LT_16( hVAD_CLDFB->update_count, 1000 ) ) + IF( LT_16( hVAD_CLDFB->update_count, 1000 ) ) { hVAD_CLDFB->update_count = add( hVAD_CLDFB->update_count, 1 ); + move16(); } } @@ -342,23 +342,26 @@ Word16 update_decision_fx( test(); test(); test(); - IF( vad_flag && GT_32( snr, 33554431 /* 1.0 Q25 */ ) && EQ_16( bw, CLDFBVAD_SWB_ID ) && tmpout > 0 ) + if ( vad_flag && GT_32( snr, 33554431 /* 1.0 Q25 */ ) && EQ_16( bw, CLDFBVAD_SWB_ID ) && tmpout > 0 ) { update_flag = 0; + move16(); } test(); test(); test(); - IF( vad_flag && GT_32( snr, 50331647 /* 1.5 Q25 */ ) && NE_16( bw, CLDFBVAD_SWB_ID ) && tmpout > 0 ) + if ( vad_flag && GT_32( snr, 50331647 /* 1.5 Q25 */ ) && NE_16( bw, CLDFBVAD_SWB_ID ) && tmpout > 0 ) { update_flag = 0; + move16(); } IF( update_flag == 0 ) { hVAD_CLDFB->update_num_with_snr = 0; + move16(); } ELSE { @@ -369,6 +372,7 @@ Word16 update_decision_fx( update_flag = 0; move16(); hVAD_CLDFB->update_num_with_snr = add( hVAD_CLDFB->update_num_with_snr, 1 ); + move16(); } } @@ -397,8 +401,6 @@ Word16 update_decision_fx( move32(); } - move16(); - move16(); IF( GT_16( (Word16) abs_s( sub( hVAD_CLDFB->sp_center[0], hVAD_CLDFB->lt_noise_sp_center0 ) ), 2455 /* 2.4 Q10 */ ) ) { hVAD_CLDFB->lt_noise_sp_center0 = add( mult( hVAD_CLDFB->lt_noise_sp_center0, 32637 ), mult( hVAD_CLDFB->sp_center[0], 131 ) ); diff --git a/lib_enc/updt_enc.c b/lib_enc/updt_enc.c deleted file mode 100644 index cb36dd4b04c94cce04cb194654b8bf337ab9c5cd..0000000000000000000000000000000000000000 --- a/lib_enc/updt_enc.c +++ /dev/null @@ -1,274 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "cnst.h" -#include "rom_com.h" -#include "prot.h" -#include "prot_fx.h" -#include "prot_fx_enc.h" -#include "ivas_prot_fx.h" -#include "wmc_auto.h" - -/*-------------------------------------------------------------------* - * updt_enc() - * - * Common updates (all frame types) - *-------------------------------------------------------------------*/ - - -void updt_enc_common_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - const Word16 Q_new /* i : CUrrent frame scaling */ -) -{ - /*---------------------------------------------------------------------* - * Updates - main main codec parameters - *---------------------------------------------------------------------*/ - st->last_sr_core = st->sr_core; - move32(); - st->last_codec_mode = st->codec_mode; - move16(); - st->last_L_frame = st->L_frame; - move16(); - st->last_core = st->core; - move16(); - - st->last_total_brate = st->total_brate; - move32(); - st->last_bits_frame_nominal = st->bits_frame_nominal; - move16(); - st->last_core_brate = st->core_brate; - move32(); - st->last_extl = st->extl; - move16(); - st->last_input_bwidth = st->input_bwidth; - move16(); - st->last_bwidth = st->bwidth; - move16(); - st->last_coder_type_raw = st->coder_type_raw; - move16(); - st->prev_Q_new = Q_new; - move16(); - - test(); - IF( GT_32( st->core_brate, SID_2k40 ) && st->hDtxEnc != NULL ) - { - st->hDtxEnc->last_active_brate = st->total_brate; - move32(); - } - - IF( st->hBWE_TD != NULL ) - { - IF( EQ_16( st->core, HQ_CORE ) ) - { - /* in the HQ core, coder_type is not used so it could have been set to anything */ - st->hBWE_TD->prev_coder_type = GENERIC; - move16(); - } - ELSE - { - st->hBWE_TD->prev_coder_type = st->coder_type; - move16(); - } - } - - test(); - IF( st->Opt_DTX_ON && st->hTdCngEnc != NULL ) - { - IF( GT_32( st->core_brate, SID_2k40 ) ) - { - IF( EQ_16( st->hDtxEnc->first_CNG, 1 ) ) - { - IF( GE_16( st->hTdCngEnc->act_cnt, BUF_DEC_RATE ) ) - { - st->hTdCngEnc->act_cnt = 0; - move16(); - } - st->hTdCngEnc->act_cnt = add( st->hTdCngEnc->act_cnt, 1 ); - move16(); - - test(); - IF( EQ_16( st->hTdCngEnc->act_cnt, BUF_DEC_RATE ) && st->hTdCngEnc->ho_hist_size > 0 ) - { - st->hTdCngEnc->ho_hist_size = sub( st->hTdCngEnc->ho_hist_size, 1 ); - move16(); - } - } - - test(); - test(); - test(); - IF( EQ_16( st->element_mode, IVAS_SCE ) || EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) || EQ_16( st->hDtxEnc->first_CNG, 1 ) ) - { - IF( GE_16( ++( st->hTdCngEnc->act_cnt2 ), MIN_ACT_CNG_UPD ) ) - { - st->hTdCngEnc->act_cnt2 = MIN_ACT_CNG_UPD; - move16(); - } - - test(); - test(); - test(); - test(); - IF( ( EQ_16( st->element_mode, IVAS_SCE ) || EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) && GE_16( st->hTdCngEnc->act_cnt2, MIN_ACT_CNG_UPD ) ) - { - Word32 cng_att_fx32 = 0; - - apply_scale( &cng_att_fx32, st->hFdCngEnc->hFdCngCom->CngBandwidth, st->hFdCngEnc->hFdCngCom->CngBitrate, scaleTableStereo, SIZE_SCALE_TABLE_STEREO ); - - st->hTdCngEnc->CNG_att_fx = extract_l( L_shr( cng_att_fx32, Q16 ) ); // Q23 - } - } - } - - test(); - test(); - test(); - IF( ( EQ_32( st->core_brate, SID_2k40 ) || EQ_32( st->core_brate, FRAME_NO_DATA ) ) && st->hDtxEnc->first_CNG == 0 && EQ_16( st->cng_type, LP_CNG ) ) - { - st->hDtxEnc->first_CNG = 1; - move16(); - } - } - - /*-----------------------------------------------------------------* - * Increase the counter of initialization frames - * Limit the max number of init. frames - *-----------------------------------------------------------------*/ - - IF( LT_16( st->ini_frame, MAX_FRAME_COUNTER ) ) - { - st->ini_frame = add( st->ini_frame, 1 ); - } - - /* synchronisation of CNG seeds */ - test(); - test(); - IF( st->hTdCngEnc != NULL && NE_32( st->core_brate, FRAME_NO_DATA ) && NE_32( st->core_brate, SID_2k40 ) && NE_16( st->core, AMR_WB_CORE ) ) - { - Random( &( st->hTdCngEnc->cng_seed ) ); - Random( &( st->hTdCngEnc->cng_ener_seed ) ); - } - - /*---------------------------------------------------------------------* - * Updates - MODE2 - *---------------------------------------------------------------------*/ - - test(); - IF( EQ_16( st->element_mode, EVS_MONO ) && EQ_16( st->mdct_sw, MODE2 ) ) - { - st->codec_mode = MODE2; - move16(); - - st->sr_core = getCoreSamplerateMode2( EVS_MONO, st->total_brate, st->bwidth, st->flag_ACELP16k, st->rf_mode, 0 ); - move16(); - - Word16 exp; - st->L_frame = BASOP_Util_Divide3232_Scale( st->sr_core, FRAMES_PER_SEC, &exp ); - st->L_frame = shr( st->L_frame, sub( 15, exp ) ); - move16(); - - IF( EQ_32( st->sr_core, INT_FS_12k8 ) ) - { - st->preemph_fac = PREEMPH_FAC; - st->gamma = GAMMA1; - } - ELSE - { - - st->preemph_fac = PREEMPH_FAC_16k; - st->gamma = GAMMA16k; - } - - st->igf = getIgfPresent_fx( EVS_MONO, st->total_brate, st->bwidth, st->rf_mode ); - } - - /* update FER clas */ - IF( NE_16( st->core, AMR_WB_CORE ) ) - { - st->last_clas = st->clas; - move16(); - } - - /* Update Core */ - core_encode_update_ivas_fx( st ); - - /*---------------------------------------------------------------------* - * RF mode updates - *---------------------------------------------------------------------*/ - - IF( st->rf_mode ) - { - IF( st->hSC_VBR != NULL ) - { - IF( st->hRF->rf_frame_type == RF_NELP ) - { - st->hSC_VBR->last_nelp_mode = 1; - move16(); - } - ELSE - { - st->hSC_VBR->last_nelp_mode = 0; - move16(); - } - } - } - - st->rf_mode_last = st->rf_mode; - move16(); - - IF( st->Opt_RF_ON ) - { - st->L_frame = L_FRAME; - st->rf_mode = 1; - move16(); - move16(); - } - - /*---------------------------------------------------------------------* - * Other updates - *---------------------------------------------------------------------*/ - - test(); - IF( st->element_mode > EVS_MONO && st->hTcxEnc != NULL ) - { - st->hTcxEnc->tcxltp_norm_corr_mem = st->hTcxEnc->tcxltp_norm_corr_past; - } - - return; -} diff --git a/lib_enc/updt_enc_fx.c b/lib_enc/updt_enc_fx.c index 6a3202a1595650cd87d2d6cc049bafe6db557b4e..77d7f538ff3c5d97f9715eb80b15cd25ff363d5d 100644 --- a/lib_enc/updt_enc_fx.c +++ b/lib_enc/updt_enc_fx.c @@ -10,6 +10,7 @@ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ #include "basop_util.h" /* Function prototypes */ +#include "ivas_prot_fx.h" /*-------------------------------------------------------------------* * updt_enc() @@ -37,6 +38,7 @@ void updt_enc_fx( /* update old excitation buffer */ Copy( &old_exc[st->L_frame], hLPDmem->old_exc, L_EXC_MEM ); test(); + test(); IF( !st->Opt_AMR_WB && st->hBWE_TD != NULL ) { Copy( &old_bwe_exc[L_FRAME32k], hBWE_TD->old_bwe_exc_fx, PIT16k_MAX * 2 ); @@ -89,6 +91,7 @@ void updt_enc_fx( move16(); /* tends to speech */ /*st->mid_dyn_fx = 40.0f * 0.5f + st->mid_dyn * 0.5f;*/ hGSCEnc->mid_dyn_fx = add( 20 * 128, mult_r( hGSCEnc->mid_dyn_fx, 16384 ) ); /*Q7*/ + move16(); } /* convert old LSP vector from 12kHz domain to 16kHz domain (needed in case of ACELP@12k8 <-> ACELP@16kHz switching) */ @@ -96,6 +99,7 @@ void updt_enc_fx( { Copy( st->lsp_old_fx, st->lsp_old16k_fx, M ); st->rate_switching_reset_16kHz = lsp_convert_poly_fx( st->lsp_old16k_fx, L_FRAME16k, st->Opt_AMR_WB ); + move16(); } /* update buffer of old subframe pitch values */ @@ -139,6 +143,7 @@ void updt_enc_fx( /* core switching updates */ Copy( &Aq[( st->L_frame / L_SUBFR - 1 ) * ( M + 1 )], st->old_Aq_12_8_fx, M + 1 ); st->old_Es_pred_fx = Es_pred; + move16(); return; } @@ -167,6 +172,7 @@ void updt_IO_switch_enc_fx( { /* reset onset detection counter */ st->tc_cnt = -1; + move16(); /* force safety-net LSFQ in the first frames after the switching */ st->Nb_ACELP_frames = 0; @@ -186,6 +192,7 @@ void updt_IO_switch_enc_fx( { /* old index is initialized to -1, and may only be updated after it has been calculated properly at least once once */ hTdCngEnc->old_enr_index = s_min( mult( shl( hTdCngEnc->old_enr_index, 1 ), 32459 ), 127 ); /*32459 = 2/(STEP_SID/STEP_AMR_WB_SID)*/ + move16(); } /* Perform preemphasis of the old input signal @16kHz */ st->mem_preemph16k_fx = 0; @@ -367,7 +374,7 @@ void updt_enc_common_fx( move16(); test(); - if ( GT_32( st->core_brate, SID_2k40 ) && st->hDtxEnc != NULL ) + IF( GT_32( st->core_brate, SID_2k40 ) && st->hDtxEnc != NULL ) { st->hDtxEnc->last_active_brate = st->total_brate; move32(); @@ -377,7 +384,7 @@ void updt_enc_common_fx( { st->hBWE_TD->prev_coder_type = st->coder_type; move16(); - if ( EQ_16( st->core, HQ_CORE ) ) + IF( EQ_16( st->core, HQ_CORE ) ) { /* in the HQ core, coder_type is not used so it could have been set to anything */ st->hBWE_TD->prev_coder_type = GENERIC; @@ -392,17 +399,19 @@ void updt_enc_common_fx( { IF( EQ_16( st->hDtxEnc->first_CNG, 1 ) ) { - if ( GE_16( st->hTdCngEnc->act_cnt, BUF_DEC_RATE ) ) + IF( GE_16( st->hTdCngEnc->act_cnt, BUF_DEC_RATE ) ) { st->hTdCngEnc->act_cnt = 0; move16(); } st->hTdCngEnc->act_cnt = add( st->hTdCngEnc->act_cnt, 1 ); + move16(); test(); - if ( EQ_16( st->hTdCngEnc->act_cnt, BUF_DEC_RATE ) && st->hTdCngEnc->ho_hist_size > 0 ) + IF( EQ_16( st->hTdCngEnc->act_cnt, BUF_DEC_RATE ) && st->hTdCngEnc->ho_hist_size > 0 ) { st->hTdCngEnc->ho_hist_size = sub( st->hTdCngEnc->ho_hist_size, 1 ); + move16(); } } @@ -413,6 +422,8 @@ void updt_enc_common_fx( { st->hTdCngEnc->act_cnt2 = add( st->hTdCngEnc->act_cnt2, 1 ); st->hTdCngEnc->act_cnt2 = s_min( st->hTdCngEnc->act_cnt2, MIN_ACT_CNG_UPD ); + move16(); + move16(); #ifdef IVAS_CODE test(); @@ -432,7 +443,7 @@ void updt_enc_common_fx( test(); test(); test(); - if ( ( EQ_32( st->core_brate, SID_2k40 ) || EQ_32( st->core_brate, FRAME_NO_DATA ) ) && st->hDtxEnc->first_CNG == 0 && EQ_16( st->cng_type, LP_CNG ) ) + IF( ( EQ_32( st->core_brate, SID_2k40 ) || EQ_32( st->core_brate, FRAME_NO_DATA ) ) && st->hDtxEnc->first_CNG == 0 && EQ_16( st->cng_type, LP_CNG ) ) { st->hDtxEnc->first_CNG = 1; move16(); @@ -447,6 +458,7 @@ void updt_enc_common_fx( if ( LT_16( st->ini_frame, MAX_FRAME_COUNTER ) ) { st->ini_frame = add( st->ini_frame, 1 ); + move16(); } /* synchronisation of CNG seeds */ @@ -469,6 +481,7 @@ void updt_enc_common_fx( move16(); st->sr_core = getCoreSamplerateMode2( EVS_MONO, st->total_brate, st->bwidth, st->flag_ACELP16k, st->rf_mode, 0 ); + move32(); // st->L_frame = extract_l(Mult_32_16(st->sr_core, 0x0290)); /*(int16_t)(st->sr_core / FRAMES_PER_SEC);*/ @@ -492,10 +505,11 @@ void updt_enc_common_fx( } st->igf = getIgfPresent_fx( EVS_MONO, st->total_brate, st->bwidth, st->rf_mode ); + move16(); } /* update FER clas */ - if ( NE_16( st->core, AMR_WB_CORE ) ) + IF( NE_16( st->core, AMR_WB_CORE ) ) { st->last_clas = st->clas; move16(); @@ -514,7 +528,7 @@ void updt_enc_common_fx( { st->hSC_VBR->last_nelp_mode = 0; move16(); - if ( EQ_16( st->hRF->rf_frame_type, RF_NELP ) ) + IF( EQ_16( st->hRF->rf_frame_type, RF_NELP ) ) { st->hSC_VBR->last_nelp_mode = 1; move16(); @@ -538,7 +552,7 @@ void updt_enc_common_fx( *---------------------------------------------------------------------*/ #ifdef IVAS_CODE test(); - if ( GT_16( st->element_mode, EVS_MONO ) && st->hTcxEnc != NULL ) + IF( GT_16( st->element_mode, EVS_MONO ) && st->hTcxEnc != NULL ) { st->hTcxEnc->tcxltp_norm_corr_mem = st->hTcxEnc->tcxltp_norm_corr_past; move16(); @@ -547,3 +561,232 @@ void updt_enc_common_fx( return; } #endif + +void updt_enc_common_ivas_fx( + Encoder_State *st, /* i/o: encoder state structure */ + const Word16 Q_new /* i : CUrrent frame scaling */ +) +{ + /*---------------------------------------------------------------------* + * Updates - main main codec parameters + *---------------------------------------------------------------------*/ + st->last_sr_core = st->sr_core; + move32(); + st->last_codec_mode = st->codec_mode; + move16(); + st->last_L_frame = st->L_frame; + move16(); + st->last_core = st->core; + move16(); + + st->last_total_brate = st->total_brate; + move32(); + st->last_bits_frame_nominal = st->bits_frame_nominal; + move16(); + st->last_core_brate = st->core_brate; + move32(); + st->last_extl = st->extl; + move16(); + st->last_input_bwidth = st->input_bwidth; + move16(); + st->last_bwidth = st->bwidth; + move16(); + st->last_coder_type_raw = st->coder_type_raw; + move16(); + st->prev_Q_new = Q_new; + move16(); + + test(); + if ( GT_32( st->core_brate, SID_2k40 ) && st->hDtxEnc != NULL ) + { + st->hDtxEnc->last_active_brate = st->total_brate; + move32(); + } + + IF( st->hBWE_TD != NULL ) + { + IF( EQ_16( st->core, HQ_CORE ) ) + { + /* in the HQ core, coder_type is not used so it could have been set to anything */ + st->hBWE_TD->prev_coder_type = GENERIC; + move16(); + } + ELSE + { + st->hBWE_TD->prev_coder_type = st->coder_type; + move16(); + } + } + + test(); + IF( st->Opt_DTX_ON && st->hTdCngEnc != NULL ) + { + IF( GT_32( st->core_brate, SID_2k40 ) ) + { + IF( EQ_16( st->hDtxEnc->first_CNG, 1 ) ) + { + if ( GE_16( st->hTdCngEnc->act_cnt, BUF_DEC_RATE ) ) + { + st->hTdCngEnc->act_cnt = 0; + move16(); + } + st->hTdCngEnc->act_cnt = add( st->hTdCngEnc->act_cnt, 1 ); + move16(); + + test(); + IF( EQ_16( st->hTdCngEnc->act_cnt, BUF_DEC_RATE ) && st->hTdCngEnc->ho_hist_size > 0 ) + { + st->hTdCngEnc->ho_hist_size = sub( st->hTdCngEnc->ho_hist_size, 1 ); + move16(); + } + } + + test(); + test(); + test(); + IF( EQ_16( st->element_mode, IVAS_SCE ) || EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) || EQ_16( st->hDtxEnc->first_CNG, 1 ) ) + { + if ( GE_16( ++( st->hTdCngEnc->act_cnt2 ), MIN_ACT_CNG_UPD ) ) + { + st->hTdCngEnc->act_cnt2 = MIN_ACT_CNG_UPD; + move16(); + } + + test(); + test(); + test(); + IF( ( EQ_16( st->element_mode, IVAS_SCE ) || EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) && GE_16( st->hTdCngEnc->act_cnt2, MIN_ACT_CNG_UPD ) ) + { + Word32 cng_att_fx32 = 0; + move32(); + + apply_scale( &cng_att_fx32, st->hFdCngEnc->hFdCngCom->CngBandwidth, st->hFdCngEnc->hFdCngCom->CngBitrate, scaleTableStereo, SIZE_SCALE_TABLE_STEREO ); + + st->hTdCngEnc->CNG_att_fx = extract_l( L_shr( cng_att_fx32, Q16 ) ); // Q23 + move16(); + } + } + } + + test(); + test(); + test(); + if ( ( EQ_32( st->core_brate, SID_2k40 ) || EQ_32( st->core_brate, FRAME_NO_DATA ) ) && st->hDtxEnc->first_CNG == 0 && EQ_16( st->cng_type, LP_CNG ) ) + { + st->hDtxEnc->first_CNG = 1; + move16(); + } + } + + /*-----------------------------------------------------------------* + * Increase the counter of initialization frames + * Limit the max number of init. frames + *-----------------------------------------------------------------*/ + + IF( LT_16( st->ini_frame, MAX_FRAME_COUNTER ) ) + { + st->ini_frame = add( st->ini_frame, 1 ); + } + + /* synchronisation of CNG seeds */ + test(); + test(); + test(); + IF( st->hTdCngEnc != NULL && ( st->core_brate != FRAME_NO_DATA ) && NE_32( st->core_brate, SID_2k40 ) && NE_16( st->core, AMR_WB_CORE ) ) + { + Random( &( st->hTdCngEnc->cng_seed ) ); + Random( &( st->hTdCngEnc->cng_ener_seed ) ); + } + + /*---------------------------------------------------------------------* + * Updates - MODE2 + *---------------------------------------------------------------------*/ + + test(); + IF( ( st->element_mode == EVS_MONO ) && EQ_16( st->mdct_sw, MODE2 ) ) + { + st->codec_mode = MODE2; + move16(); + + st->sr_core = getCoreSamplerateMode2( EVS_MONO, st->total_brate, st->bwidth, st->flag_ACELP16k, st->rf_mode, 0 ); + move16(); + + Word16 exp; + st->L_frame = BASOP_Util_Divide3232_Scale( st->sr_core, FRAMES_PER_SEC, &exp ); + move16(); + st->L_frame = shr( st->L_frame, sub( 15, exp ) ); + move16(); + + IF( EQ_32( st->sr_core, INT_FS_12k8 ) ) + { + st->preemph_fac = PREEMPH_FAC; + st->gamma = GAMMA1; + } + ELSE + { + + st->preemph_fac = PREEMPH_FAC_16k; + st->gamma = GAMMA16k; + } + move16(); + move16(); + + st->igf = getIgfPresent_fx( EVS_MONO, st->total_brate, st->bwidth, st->rf_mode ); + move16(); + } + + /* update FER clas */ + if ( NE_16( st->core, AMR_WB_CORE ) ) + { + st->last_clas = st->clas; + move16(); + } + + /* Update Core */ + core_encode_update_ivas_fx( st ); + + /*---------------------------------------------------------------------* + * RF mode updates + *---------------------------------------------------------------------*/ + + IF( st->rf_mode ) + { + IF( st->hSC_VBR != NULL ) + { + IF( EQ_16( st->hRF->rf_frame_type, RF_NELP ) ) + { + st->hSC_VBR->last_nelp_mode = 1; + move16(); + } + ELSE + { + st->hSC_VBR->last_nelp_mode = 0; + move16(); + } + } + } + + st->rf_mode_last = st->rf_mode; + move16(); + + IF( st->Opt_RF_ON ) + { + st->L_frame = L_FRAME; + st->rf_mode = 1; + move16(); + move16(); + } + + /*---------------------------------------------------------------------* + * Other updates + *---------------------------------------------------------------------*/ + + test(); + if ( st->element_mode > EVS_MONO && st->hTcxEnc != NULL ) + { + st->hTcxEnc->tcxltp_norm_corr_mem = st->hTcxEnc->tcxltp_norm_corr_past; + move16(); + } + + return; +} diff --git a/lib_enc/updt_tar.c b/lib_enc/updt_tar.c deleted file mode 100644 index e748899a9667996f0776eb65127752b66796a660..0000000000000000000000000000000000000000 --- a/lib_enc/updt_tar.c +++ /dev/null @@ -1,40 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "prot.h" -#include "wmc_auto.h" diff --git a/lib_enc/updt_tar_fx.c b/lib_enc/updt_tar_fx.c index d62daff20038c9207323d924910626d50d587404..9d6b5d2d6751c852216a6801f7aa9d4af97801d2 100644 --- a/lib_enc/updt_tar_fx.c +++ b/lib_enc/updt_tar_fx.c @@ -14,10 +14,10 @@ * Update the target vector for codebook search. *----------------------------------------------------------------------------------*/ void updt_tar_fx( - const Word16 *x, /* i : old target (for pitch search) */ - Word16 *x2, /* o : new target (for codebook search) */ - const Word16 *y, /* i : filtered adaptive codebook vector */ - const Word16 gain, /* i : adaptive codebook gain */ + const Word16 *x, /* i : old target (for pitch search) Qz */ + Word16 *x2, /* o : new target (for codebook search) Qz */ + const Word16 *y, /* i : filtered adaptive codebook vector Qz */ + const Word16 gain, /* i : adaptive codebook gain Q14 */ const Word16 L /* i : subframe size */ ) { @@ -25,20 +25,17 @@ void updt_tar_fx( Word32 L_tmp; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif FOR( i = 0; i < L; i++ ) { /*x2[i] = x[i] - gain*y[i];*/ - L_tmp = L_mult( x[i], 16384 ); -#ifdef BASOP_NOGLOB + L_tmp = L_mult( x[i], 16384 ); /* (Qz*Q14) -> (Qz+15) */ L_tmp = L_msu_sat( L_tmp, y[i], gain ); x2[i] = extract_h( L_shl_o( L_tmp, 1, &Overflow ) ); -#else /* BASOP_NOGLOB */ - L_tmp = L_msu( L_tmp, y[i], gain ); - x2[i] = extract_h( L_shl( L_tmp, 1 ) ); -#endif + move16(); } return; } @@ -48,9 +45,9 @@ void updt_tar_fx( * Update the target vector for codebook search. *----------------------------------------------------------------------------------*/ void updt_tar_HR_fx( - const Word16 *x, /* i : old target (for pitch search) */ - Word16 *x2, /* o : new target (for codebook search) */ - const Word16 *y, /* i : filtered adaptive codebook vector */ + const Word16 *x, /* i : old target (for pitch search) Qz */ + Word16 *x2, /* o : new target (for codebook search) Qz */ + const Word16 *y, /* i : filtered adaptive codebook vector Qz */ const Word16 gain, /* i : adaptive codebook gain Q2 */ const Word16 Qx, /* i : Scaling factor to adapt output to input */ const Word16 L /* i : subframe size */ @@ -60,20 +57,17 @@ void updt_tar_HR_fx( Word32 L_tmp, L_tmp1; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif FOR( i = 0; i < L; i++ ) { /*x2[i] = x[i] - gain*y[i];*/ - L_tmp = L_mult( x[i], 32767 ); -#ifdef BASOP_NOGLOB - L_tmp1 = L_shl_o( L_mult_o( y[i], gain, &Overflow ), Qx, &Overflow ); + L_tmp = L_mult( x[i], 32767 ); /* (Qz*Q15) = (Qz+16) */ + L_tmp1 = L_shl_o( L_mult_o( y[i], gain, &Overflow ), Qx, &Overflow ); /* ((Qz+2+1)< -#include "options.h" -#include -#include "cnst.h" -#include "prot.h" -#include "rom_enc.h" -#include "wmc_auto.h" -#include "ivas_prot.h" - -/*-----------------------------------------------------------------* - * Local constants - *-----------------------------------------------------------------*/ - -#define HANGOVER_LONG 10 /* Hangover for CNG */ -#define HANGOVER_LONG_HE 20 /* Hangover of CNG */ -#define HANGOVER_LONG_MUSIC 20 /* Hangover of CNG */ -#define HANGOVER_LONG_NB 8 /* Hangover for CNG */ -#define ACTIVE_FRAMES 3 /* Number of consecutive active SPEECH frames necessary to trigger HO */ - -#define TH16_2 35.0f /* long-term SNR that separates the curves for clean speech and noisy speech */ -#define TH8_1 20.0f /* long-term SNR that separates the curves for clean speech and noisy speech */ -#define TH16_2_NFLAG 35.0f -#define TH8_1_NFLAG 35.0f - - -#define SNR_OUTLIER_WGHT_1 1.00f -#define SNR_OUTLIER_WGHT_2 1.01f -#define SNR_OUTLIER_WGHT_3 1.02f -#define OUTLIER_THR_1 10.0f -#define OUTLIER_THR_2 6.0f -#define MAX_SNR_OUTLIER_IND 17 -#define MAX_SNR_OUTLIER_1 10.0f -#define MAX_SNR_OUTLIER_2 25.0f -#define MAX_SNR_OUTLIER_3 50.0f - -/*---------------------------------------------------------------------* - * wb_vad_init() - * - * VAD initializations - *---------------------------------------------------------------------*/ -/*-----------------------------------------------------------------* - * sing_thr_snr_acc() - * - * accumulate snr_sum with significance thresholds - *-----------------------------------------------------------------*/ -/*-----------------------------------------------------------------* - * dtx_hangover_addition() - * - * accumulate snr_sum with significance thresholds - *-----------------------------------------------------------------*/ - -/*-----------------------------------------------------------------* - * wb_vad() - * - * Voice Activity Detector - *-----------------------------------------------------------------*/ diff --git a/lib_enc/vad_basop_fx.c b/lib_enc/vad_basop_fx.c index f8f528c0e512c75cb9568d47512aae54374ed686..d6d0783105621e70b314ab8a971be27bd4d60434 100644 --- a/lib_enc/vad_basop_fx.c +++ b/lib_enc/vad_basop_fx.c @@ -114,11 +114,7 @@ Word16 FixSqrt( Word32 i_s32Val, Word16 *io_s16Q ) Word16 result, exp; exp = sub( 31, *io_s16Q ); -#ifdef BASOP_NOGLOB result = round_fx_sat( Sqrt32( i_s32Val, &exp ) ); -#else - result = round_fx( Sqrt32( i_s32Val, &exp ) ); -#endif move16(); *io_s16Q = sub( 15, exp ); diff --git a/lib_enc/vad_fx.c b/lib_enc/vad_fx.c index 6ab97954bb4ab3c809fef58d82acad554c713548..12ec319331a96478406ffe166a5b2e7a1906b949 100644 --- a/lib_enc/vad_fx.c +++ b/lib_enc/vad_fx.c @@ -102,8 +102,11 @@ void wb_vad_init_fx( /* is set to max (-> start with hangover) */ hVAD->vad_flag_reg_H = L_deposit_l( 0 ); + move32(); hVAD->vad_flag_reg_L = L_deposit_l( 0 ); + move32(); hVAD->vad_prim_reg = L_deposit_l( 0 ); + move32(); hVAD->vad_flag_cnt_50 = 0; move16(); hVAD->vad_prim_cnt_16 = 0; @@ -221,19 +224,17 @@ static void sign_thr_snr_acc_fx( Word32 L_tmp; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif L_tmp = L_deposit_l( min_snr ); - if ( GE_32( L_snr, L_deposit_l( sign_thr ) ) ) + IF( GE_32( L_snr, L_deposit_l( sign_thr ) ) ) { - L_tmp = L_add( L_snr, 0 ); + L_tmp = L_add( L_snr, 0 ); /* Q4 */ } - BASOP_SATURATE_WARNING_OFF_EVS /* may saturate in BASOP */ -#ifdef BASOP_NOGLOB + BASOP_SATURATE_WARNING_OFF_EVS /* may saturate in BASOP */ *L_snr_sum = L_add_o( *L_snr_sum, L_tmp, &Overflow ); /* Q4 */ -#else /* BASOP_NOGLOB */ - *L_snr_sum = L_add( *L_snr_sum, L_tmp ); /* Q4 */ -#endif /* BASOP_NOGLOB */ + move32(); BASOP_SATURATE_WARNING_ON_EVS } @@ -252,9 +253,9 @@ Word16 dtx_hangover_addition_fx( NOISE_EST_HANDLE hNoiseEst /* i : Noise estimation handle */ ) { - Word16 hangover_short_dtx; - Word16 flag_dtx; - Word16 tmp; + Word16 hangover_short_dtx; /* Q0 */ + Word16 flag_dtx; /* Q0 */ + Word16 tmp; /* Q0 */ if ( hNoiseEst == NULL ) { hNoiseEst = st_fx->hNoiseEst; @@ -277,19 +278,19 @@ Word16 dtx_hangover_addition_fx( test(); test(); - if ( ( ( LT_16( lp_snr, ( 16 * 256 ) ) ) && ( NE_16( st_fx->input_bwidth, NB ) ) ) || ( GT_16( hVAD->prim_act_he_fx, 31130 ) ) ) /*.95*Q15*/ + if ( ( ( LT_16( lp_snr, ( 16 * 256 ) ) ) && ( st_fx->input_bwidth != NB ) ) || ( GT_16( hVAD->prim_act_he_fx, 31130 ) ) ) /*.95*Q15*/ { hangover_short_dtx = 3; move16(); } /* Adjust hangover according to activity history */ - if ( GT_16( hVAD->vad_prim_cnt_16, 12 ) ) /* 12 requires roughly > 80% primary activity */ + IF( GT_16( hVAD->vad_prim_cnt_16, 12 ) ) /* 12 requires roughly > 80% primary activity */ { hangover_short_dtx = add( hangover_short_dtx, 2 ); } - if ( GT_16( hVAD->vad_flag_cnt_50, 40 ) ) /* 40 requires roughtly > 80% flag activity */ + IF( GT_16( hVAD->vad_flag_cnt_50, 40 ) ) /* 40 requires roughtly > 80% flag activity */ { hangover_short_dtx = add( hangover_short_dtx, 5 ); } @@ -339,7 +340,7 @@ Word16 dtx_hangover_addition_fx( /* hangover adjustment from combined FFT+CLDFBVAD */ IF( NE_16( st_fx->core, AMR_WB_CORE ) ) { - hangover_short_dtx = sub( hangover_short_dtx, cldfb_subtraction ); + hangover_short_dtx = sub( hangover_short_dtx, cldfb_subtraction ); /* Q0 */ hangover_short_dtx = s_max( hangover_short_dtx, 0 ); } @@ -358,9 +359,10 @@ Word16 dtx_hangover_addition_fx( /* inside HO period */ test(); - if ( ( LT_16( hVAD->hangover_cnt_dtx, HANGOVER_LONG_FX ) ) && ( hVAD->hangover_cnt_dtx != 0 ) ) + IF( ( LT_16( hVAD->hangover_cnt_dtx, HANGOVER_LONG_FX ) ) && ( hVAD->hangover_cnt_dtx != 0 ) ) { - hVAD->hangover_cnt_dtx = add( hVAD->hangover_cnt_dtx, 1 ); + hVAD->hangover_cnt_dtx = add( hVAD->hangover_cnt_dtx, 1 ); /* Q0 */ + move16(); } hVAD->hangover_terminate_flag = 0; move16(); /* float fix FIX_HO_TERMINATE */ @@ -377,21 +379,24 @@ Word16 dtx_hangover_addition_fx( /* inside Music HO period */ test(); - if ( ( LT_16( hVAD->hangover_cnt_music, HANGOVER_LONG_MUSIC_FX ) ) && ( hVAD->hangover_cnt_music != 0 ) ) + IF( ( LT_16( hVAD->hangover_cnt_music, HANGOVER_LONG_MUSIC_FX ) ) && ( hVAD->hangover_cnt_music != 0 ) ) { hVAD->hangover_cnt_music = add( hVAD->hangover_cnt_music, 1 ); + move16(); } } ELSE { /* Reset the counter of speech frames necessary to start hangover algorithm */ - if ( LT_16( hVAD->hangover_cnt_dtx, HANGOVER_LONG_FX ) ) /* inside HO period */ + IF( LT_16( hVAD->hangover_cnt_dtx, HANGOVER_LONG_FX ) ) /* inside HO period */ { hVAD->hangover_cnt_dtx = add( hVAD->hangover_cnt_dtx, 1 ); + move16(); } - if ( LT_16( hVAD->hangover_cnt_music, HANGOVER_LONG_MUSIC_FX ) ) /* inside HO period */ + IF( LT_16( hVAD->hangover_cnt_music, HANGOVER_LONG_MUSIC_FX ) ) /* inside HO period */ { hVAD->hangover_cnt_music = add( hVAD->hangover_cnt_music, 1 ); + move16(); } /* fast terminate DTX hangover if st->hangover_terminate_flag is set */ @@ -444,9 +449,9 @@ Word16 ivas_dtx_hangover_addition_fx( NOISE_EST_HANDLE hNoiseEst, /* i : Noise estimation handle */ Word16 *rem_dtx_ho ) { - Word16 hangover_short_dtx; - Word16 flag_dtx; - Word16 tmp; + Word16 hangover_short_dtx; /* Q0 */ + Word16 flag_dtx; /* Q0 */ + Word16 tmp; /* Q0 */ if ( hNoiseEst == NULL ) { hNoiseEst = st_fx->hNoiseEst; @@ -476,12 +481,12 @@ Word16 ivas_dtx_hangover_addition_fx( } /* Adjust hangover according to activity history */ - if ( GT_16( hVAD->vad_prim_cnt_16, 12 ) ) /* 12 requires roughly > 80% primary activity */ + IF( GT_16( hVAD->vad_prim_cnt_16, 12 ) ) /* 12 requires roughly > 80% primary activity */ { hangover_short_dtx = add( hangover_short_dtx, 2 ); } - if ( GT_16( hVAD->vad_flag_cnt_50, 40 ) ) /* 40 requires roughtly > 80% flag activity */ + IF( GT_16( hVAD->vad_flag_cnt_50, 40 ) ) /* 40 requires roughtly > 80% flag activity */ { hangover_short_dtx = add( hangover_short_dtx, 5 ); } @@ -506,7 +511,7 @@ Word16 ivas_dtx_hangover_addition_fx( /* need to be a bit stricter with the DTXHO in very clean WB, SWB cond for EVS12k8VAD section */ test(); test(); - if ( ( NE_16( st_fx->input_bwidth, NB ) ) /* WB or SWB or FB */ + if ( ( st_fx->input_bwidth != NB ) /* WB or SWB or FB */ && ( NE_16( st_fx->core, AMR_WB_CORE ) ) && ( GT_16( lp_snr, 25 * 256 ) ) ) { tmp = 2; @@ -531,7 +536,7 @@ Word16 ivas_dtx_hangover_addition_fx( /* hangover adjustment from combined FFT+CLDFBVAD */ IF( NE_16( st_fx->core, AMR_WB_CORE ) ) { - hangover_short_dtx = sub( hangover_short_dtx, cldfb_subtraction ); + hangover_short_dtx = sub( hangover_short_dtx, cldfb_subtraction ); /*Q0*/ hangover_short_dtx = s_max( hangover_short_dtx, 0 ); } IF( vad_flag != 0 ) /* Speech present */ @@ -549,9 +554,10 @@ Word16 ivas_dtx_hangover_addition_fx( /* inside HO period */ test(); - if ( ( LT_16( hVAD->hangover_cnt_dtx, HANGOVER_LONG_FX ) ) && ( hVAD->hangover_cnt_dtx != 0 ) ) + IF( ( LT_16( hVAD->hangover_cnt_dtx, HANGOVER_LONG_FX ) ) && ( hVAD->hangover_cnt_dtx != 0 ) ) { - hVAD->hangover_cnt_dtx = add( hVAD->hangover_cnt_dtx, 1 ); + hVAD->hangover_cnt_dtx = add( hVAD->hangover_cnt_dtx, 1 ); /*Q0*/ + move16(); } hVAD->hangover_terminate_flag = 0; move16(); /* float fix FIX_HO_TERMINATE */ @@ -560,7 +566,7 @@ Word16 ivas_dtx_hangover_addition_fx( test(); test(); test(); - if ( ( GT_16( hVAD->prim_act_he_fx, 31129 ) ) && ( GT_16( hNoiseEst->Etot_lp_fx, 40 * 256 ) ) && ( GT_16( hVAD->vad_prim_cnt_16, 14 ) ) && ( GT_16( hVAD->vad_flag_cnt_50, 48 ) ) ) /* 45 requires roughly > 95% flag activity */ + if ( ( GT_16( hVAD->prim_act_he_fx, 32113 ) ) && ( GT_16( hNoiseEst->Etot_lp_fx, 40 * 256 ) ) && ( GT_16( hVAD->vad_prim_cnt_16, 14 ) ) && ( GT_16( hVAD->vad_flag_cnt_50, 48 ) ) ) /* 45 requires roughly > 95% flag activity */ { hVAD->hangover_cnt_music = 0; move16(); @@ -568,7 +574,7 @@ Word16 ivas_dtx_hangover_addition_fx( /* inside Music HO period */ test(); - if ( ( LT_16( hVAD->hangover_cnt_music, HANGOVER_LONG_MUSIC_FX ) ) && ( hVAD->hangover_cnt_music != 0 ) ) + IF( ( LT_16( hVAD->hangover_cnt_music, HANGOVER_LONG_MUSIC_FX ) ) && ( hVAD->hangover_cnt_music != 0 ) ) { hVAD->hangover_cnt_music = add( hVAD->hangover_cnt_music, 1 ); move16(); @@ -577,12 +583,12 @@ Word16 ivas_dtx_hangover_addition_fx( ELSE { /* Reset the counter of speech frames necessary to start hangover algorithm */ - if ( LT_16( hVAD->hangover_cnt_dtx, HANGOVER_LONG_FX ) ) /* inside HO period */ + IF( LT_16( hVAD->hangover_cnt_dtx, HANGOVER_LONG_FX ) ) /* inside HO period */ { hVAD->hangover_cnt_dtx = add( hVAD->hangover_cnt_dtx, 1 ); move16(); } - if ( LT_16( hVAD->hangover_cnt_music, HANGOVER_LONG_MUSIC_FX ) ) /* inside HO period */ + IF( LT_16( hVAD->hangover_cnt_music, HANGOVER_LONG_MUSIC_FX ) ) /* inside HO period */ { hVAD->hangover_cnt_music = add( hVAD->hangover_cnt_music, 1 ); move16(); @@ -652,8 +658,8 @@ Word16 wb_vad_fx( const Word16 Q_new, /* i : scaling factor Q0 */ VAD_HANDLE hVAD, /* i/o: VAD data handle */ NOISE_EST_HANDLE hNoiseEst, /* i : Noise estimation handle */ - Word16 lp_speech_fx, /* i : long term active speech energy average */ - Word16 lp_noise_fx /* i : long term noise energy */ + Word16 lp_speech_fx, /* i : long term active speech energy average Q8 */ + Word16 lp_noise_fx /* i : long term noise energy Q8 */ ) { Word16 i, flag = 0, hangover_short; @@ -705,6 +711,7 @@ Word16 wb_vad_fx( Word16 last_7k2_coder_type; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif if ( hNoiseEst == NULL ) @@ -738,14 +745,12 @@ Word16 wb_vad_fx( move16(); L_accum_ener_L = L_deposit_l( 0 ); L_accum_ener_H = L_deposit_l( 0 ); - L_snr18 = L_deposit_l( 0 ); /* Q4*/ L_snr19 = L_deposit_l( 0 ); /* Q4 */ L_msnr18 = L_deposit_l( 8192 ); /* 1.0 Q13*/ L_msnr19 = L_deposit_l( 8192 ); /* 1.0 Q13 */ - - IF( EQ_16( vad_bwidth_fx, NB ) ) + IF( vad_bwidth_fx == NB ) { st_fx->min_band = 1; move16(); @@ -978,19 +983,13 @@ Word16 wb_vad_fx( { e_num = norm_l( L_tmp1 ); m_num = extract_h( L_shl( L_tmp1, e_num ) ); - e_noise = norm_l( ftmp2 ); m_noise_local = extract_h( L_shl( ftmp2, e_noise ) ); m_num = shr( m_num, 1 ); shift_snr = add( sub( e_num, e_noise ), 15 - 4 ); - snr_tmp = div_s( m_num, m_noise_local ); -#ifdef BASOP_NOGLOB L_snr = L_shr_o( snr_tmp, shift_snr, &Overflow ); /* L_snr in Q4 */ -#else /* BASOP_NOGLOB */ - L_snr = L_shr( snr_tmp, shift_snr ); /* L_snr in Q4 */ -#endif /* BASOP_NOGLOB */ } ELSE { @@ -1023,11 +1022,7 @@ Word16 wb_vad_fx( shift_snr = add( sub( e_num, e_noise ), 15 - 4 ); snr_tmp = div_s( m_num, m_noise_local ); -#ifdef BASOP_NOGLOB L_snr = L_shr_o( snr_tmp, shift_snr, &Overflow ); /* L_snr in Q4 */ -#else /* BASOP_NOGLOB */ - L_snr = L_shr( snr_tmp, shift_snr ); /* L_snr in Q4 */ -#endif /* BASOP_NOGLOB */ } ELSE { @@ -1059,54 +1054,30 @@ Word16 wb_vad_fx( snr_sumt = add( snr_sumt, shr( snr, 4 ) ); /*Q4 */ -#ifdef BASOP_NOGLOB tmp = shl_o( snr, 5, &Overflow ); /* Q8 -> Q13 */ -#else /* BASOP_NOGLOB */ - tmp = shl( snr, 5 ); /* Q8 -> Q13 */ -#endif /* BASOP_NOGLOB */ IF( LT_16( i, 2 ) ) { -#ifdef BASOP_NOGLOB tmp = add_o( tmp, delta1, &Overflow ); /*Q13 */ -#else /* BASOP_NOGLOB */ - tmp = add( tmp, delta1 ); /*Q13 */ -#endif /* BASOP_NOGLOB */ } ELSE IF( LT_16( i, 7 ) ) { -#ifdef BASOP_NOGLOB tmp = add_o( tmp, delta2, &Overflow ); /*Q13 */ -#else /* BASOP_NOGLOB */ - tmp = add( tmp, delta2 ); /*Q13 */ -#endif /* BASOP_NOGLOB */ } ELSE IF( LT_16( i, 18 ) ) { -#ifdef BASOP_NOGLOB tmp = add_o( tmp, delta3, &Overflow ); /*Q13 */ -#else /* BASOP_NOGLOB */ - tmp = add( tmp, delta3 ); /*Q13 */ -#endif /* BASOP_NOGLOB */ } ELSE { -#ifdef BASOP_NOGLOB tmp = add_o( tmp, delta4, &Overflow ); /*Q13 */ -#else /* BASOP_NOGLOB */ - tmp = add( tmp, delta4 ); /*Q13 */ -#endif /* BASOP_NOGLOB */ } tmp1 = tmp; move16(); /* ftmp1 = ftmp; */ sub( 0, 0 ); - if ( i < 7 ) + if ( LT_16( i, 7 ) ) { -#ifdef BASOP_NOGLOB tmp1 = add_o( tmp, 3277, &Overflow ); /*.4 in Q13 ftmp1 = ftmp + 0.4f; */ -#else /* BASOP_NOGLOB */ - tmp1 = add( tmp, 3277 ); /*.4 in Q13 ftmp1 = ftmp + 0.4f; */ -#endif /* BASOP_NOGLOB */ } tmp = s_min( tmp, 16384 ); /* Q13, ftmp = min(ftmp, 2.0f); */ @@ -1152,11 +1123,7 @@ Word16 wb_vad_fx( shift_snr = add( sub( e_num, e_noise ), 15 - 4 ); snr_tmp = div_s( m_num, m_noise_local ); -#ifdef BASOP_NOGLOB L_snr = L_shr_o( snr_tmp, shift_snr, &Overflow ); /* L_snr in Q4 */ -#else /* BASOP_NOGLOB */ - L_snr = L_shr( snr_tmp, shift_snr ); /* L_snr in Q4 */ -#endif /* BASOP_NOGLOB */ } ELSE { @@ -1194,19 +1161,11 @@ Word16 wb_vad_fx( /* accumulate background noise energy in bands [0-2] and in bands [3-19]*/ IF( LT_16( i, 3 ) ) { -#ifdef BASOP_NOGLOB L_accum_ener_L = L_add_o( L_accum_ener_L, hNoiseEst->bckr_fx[i], &Overflow ); /*Q_new+QSCALE */ -#else - L_accum_ener_L = L_add( L_accum_ener_L, hNoiseEst->bckr_fx[i] ); /*Q_new+QSCALE */ -#endif } ELSE { -#ifdef BASOP_NOGLOB L_accum_ener_H = L_add_o( L_accum_ener_H, hNoiseEst->bckr_fx[i], &Overflow ); /*Q_new+QSCALE */ -#else - L_accum_ener_H = L_add( L_accum_ener_H, hNoiseEst->bckr_fx[i] ); /*Q_new+QSCALE */ -#endif } /* Identify the outlier band */ @@ -1230,7 +1189,7 @@ Word16 wb_vad_fx( L_tmp = L_add( L_tmp1, L_tmp ); if ( GT_32( L_tmp, L_mssnr ) ) { - L_mssnr = L_tmp; + L_mssnr = L_tmp; /*Q13*/ } } ELSE IF( ( snr_idx != 0 ) && GT_16( nb_sig_snr, 13 ) ) @@ -1300,11 +1259,8 @@ Word16 wb_vad_fx( } } /*st_fx->snr_sum_vad_fx = 0.5f * st->snr_sum_vad + 0.5f * snr_sum_ol;*/ -#ifdef BASOP_NOGLOB hVAD->L_snr_sum_vad_fx = L_shr( L_add_o( hVAD->L_snr_sum_vad_fx, L_snr_sum_ol, &Overflow ), 1 ); /*Q4*/ -#else /* BASOP_NOGLOB */ - hVAD->L_snr_sum_vad_fx = L_shr( L_add( hVAD->L_snr_sum_vad_fx, L_snr_sum_ol ), 1 ); /*Q4*/ -#endif /* BASOP_NOGLOB */ + move32(); /* snr_sum_ol = 10.0f * (float)log10( snr_sum_ol ); */ snr_sum_ol = vad_snr_log_fx( L_snr_sum_ol, LG10 ); @@ -1341,7 +1297,7 @@ Word16 wb_vad_fx( L_tmp = L_mac( L_tmp, nc, (Word16) 32767 ); /* Q8+Q15+1 = Q24 */ thr1 = mac_r( L_tmp, lp_snr, nk ); /* Q8+Q15+1 - 16 --> Q8 */ #ifdef IVAS_CODE - if ( st->element_mode > EVS_MONO && hNoiseEst->first_noise_updt_cnt < 100 ) + IF( st->element_mode > EVS_MONO && LT_16( hNoiseEst->first_noise_updt_cnt, 100 ) ) { /* lower threshold during warmup time */ thr1 -= 10.0f; @@ -1351,7 +1307,7 @@ Word16 wb_vad_fx( IF( GT_16( lp_snr, (Word16) 20 * ( 1 << 8 ) ) ) /* if (lp_snr > 20.0f )*/ { #ifdef IVAS_CODE - if ( st->element_mode == EVS_MONO || hNoiseEst->first_noise_updt_cnt >= 100 ) + IF( st->element_mode == EVS_MONO || GT_16( hNoiseEst->first_noise_updt_cnt, 100 ) ) #endif { /* thr1 = thr1 + 0.3f * (lp_snr - 20.0f); */ @@ -1363,6 +1319,7 @@ Word16 wb_vad_fx( if ( EQ_16( st_fx->max_band, 16 ) && GT_16( lp_snr, 40 * 256 ) && GT_16( thr1, 6600 ) && LT_16( lp_speech_fx, 11520 ) ) { thr1 = 6600; + move16(); } } } @@ -1401,7 +1358,7 @@ Word16 wb_vad_fx( test(); test(); /*_DIFF_FLOAT_FIX_ -> the conditions around Opt_SC_VBR_fx are invertered compared to float ### st_fx->Opt_SC_VBR!=0 vs !st_fx->Opt_SC_VBR #####*/ - test(); + // test(); IF( LE_16( snr_outlier_index, 4 ) && ( ( GT_16( st_fx->last_coder_type, UNVOICED ) && ( st_fx->Opt_SC_VBR != 0 ) ) || ( GT_16( last_7k2_coder_type, UNVOICED ) && ( st_fx->Opt_SC_VBR == 0 ) ) ) ) @@ -1426,12 +1383,8 @@ Word16 wb_vad_fx( thr1_ol = thr1; move16(); L_tmp2 = Msub_32_16( (Word32) 614, L_snr_outlier, 20972 ); /* .6*1024= */ /* 0.6 Q26(Q10 in high word) - Q4*Q21+1 */ -#ifdef BASOP_NOGLOB - tmp2 = round_fx( L_shl_o( L_tmp2, 14, &Overflow ) ); /* Q10(high word)+ 14 -16 --> Q8*/ -#else /* BASOP_NOGLOB */ - tmp2 = round_fx( L_shl( L_tmp2, 14 ) ); /* Q10(high word)+ 14 -16 --> Q8*/ -#endif - if ( L_tmp2 > 0 ) + tmp2 = round_fx( L_shl_o( L_tmp2, 14, &Overflow ) ); /* Q10(high word)+ 14 -16 --> Q8*/ + IF( L_tmp2 > 0 ) { thr1_ol = add( thr1_ol, tmp2 ); /* Q24 >>16 + Q8 */ } @@ -1453,7 +1406,7 @@ Word16 wb_vad_fx( flag_he1 = 1; move16(); /* he1 primary decision */ hVAD->nb_active_frames_he1 = add( hVAD->nb_active_frames_he1, 1 ); /* Counter of consecutive active speech frames */ - + move16(); IF( GE_16( hVAD->nb_active_frames_he1, ACTIVE_FRAMES_FX ) ) { hVAD->nb_active_frames_he1 = ACTIVE_FRAMES_FX; @@ -1464,14 +1417,16 @@ Word16 wb_vad_fx( /* inside HO period */ test(); - if ( sub( hVAD->hangover_cnt_he1, HANGOVER_LONG_HE_FX ) < 0 && hVAD->hangover_cnt_he1 != 0 ) + IF( sub( hVAD->hangover_cnt_he1, HANGOVER_LONG_HE_FX ) < 0 && hVAD->hangover_cnt_he1 != 0 ) { hVAD->hangover_cnt_he1 = add( hVAD->hangover_cnt_he1, 1 ); + move16(); } - if ( hVAD->soft_hangover > 0 ) + IF( hVAD->soft_hangover > 0 ) { hVAD->soft_hangover = sub( hVAD->soft_hangover, 1 ); + move16(); } } ELSE @@ -1503,7 +1458,7 @@ Word16 wb_vad_fx( IF( LT_16( hVAD->bcg_flux_fx, 640 ) ) { hangover_hd = add( shr( hangover_hd, 1 ), 1 ); - move16(); + // move16(); } /* VAD hangover for he1 */ @@ -1515,6 +1470,7 @@ Word16 wb_vad_fx( flag_he1 = 1; move16(); hVAD->soft_hangover = sub( hVAD->soft_hangover, 1 ); + move16(); } ELSE { @@ -1536,6 +1492,7 @@ Word16 wb_vad_fx( flag_he1 = 1; move16(); hVAD->hangover_cnt_he1 = add( hVAD->hangover_cnt_he1, 1 ); + move16(); } @@ -1551,11 +1508,13 @@ Word16 wb_vad_fx( { /*st->bcg_flux = 0.9f * st->bcg_flux + (1-0.9f)*(st->bcg_flux+50);*/ hVAD->bcg_flux_fx = mac_r( L_mult( hVAD->bcg_flux_fx, 29491 ), add( hVAD->bcg_flux_fx, 800 ), 3277 ); /*Q4 */ + move16(); } ELSE { /*st->bcg_flux = 0.9f * st->bcg_flux + (1-0.9f)*snr_sumt*/ hVAD->bcg_flux_fx = mac_r( L_mult( hVAD->bcg_flux_fx, 29491 ), snr_sumt, 3277 ); /*Q4 */ + move16(); } } ELSE @@ -1564,11 +1523,13 @@ Word16 wb_vad_fx( { /*st->bcg_flux = 0.99f * st->bcg_flux + (1-0.99f)*(st->bcg_flux+10);*/ hVAD->bcg_flux_fx = mac_r( L_mult( hVAD->bcg_flux_fx, 32440 ), add( hVAD->bcg_flux_fx, 160 ), 328 ); /*Q4 */ + move16(); } ELSE { /*st->bcg_flux = 0.99f * st->bcg_flux + (1-0.99f)*snr_sumt;*/ hVAD->bcg_flux_fx = mac_r( L_mult( hVAD->bcg_flux_fx, 32440 ), snr_sumt, 328 ); /*Q4 */ + move16(); } } } @@ -1580,11 +1541,13 @@ Word16 wb_vad_fx( { /*st->bcg_flux = 0.95f * st->bcg_flux + (1-0.95f)*(st->bcg_flux-30);*/ hVAD->bcg_flux_fx = mac_r( L_mult( hVAD->bcg_flux_fx, 31130 ), sub( hVAD->bcg_flux_fx, 480 ), 1638 ); /*Q4 */ + move16(); } ELSE { /*st->bcg_flux = 0.95f * st->bcg_flux + (1-0.95f)*snr_sumt;*/ hVAD->bcg_flux_fx = mac_r( L_mult( hVAD->bcg_flux_fx, 31130 ), snr_sumt, 1638 ); /*Q4 */ + move16(); } } ELSE @@ -1593,16 +1556,19 @@ Word16 wb_vad_fx( { /*st->bcg_flux = 0.9992f * st->bcg_flux + (1-0.9992f)*(st->bcg_flux-10);*/ hVAD->bcg_flux_fx = mac_r( L_mult( hVAD->bcg_flux_fx, 32742 ), sub( hVAD->bcg_flux_fx, 160 ), 26 ); /*Q4 */ + move16(); } ELSE { /*st->bcg_flux = 0.9992f * st->bcg_flux + (1-0.9992f)*snr_sumt;*/ hVAD->bcg_flux_fx = mac_r( L_mult( hVAD->bcg_flux_fx, 32742 ), snr_sumt, 26 ); /*Q4 */ + move16(); } } } - hVAD->bcg_flux_init = s_max( hVAD->bcg_flux_init, 0 ); + hVAD->bcg_flux_init = s_max( hVAD->bcg_flux_init, 0 ); /*Q0*/ + move16(); } flag = 0; @@ -1620,6 +1586,7 @@ Word16 wb_vad_fx( move16(); hVAD->nb_active_frames = add( hVAD->nb_active_frames, 1 ); /* Counter of consecutive active speech frames */ + move16(); IF( GE_16( hVAD->nb_active_frames, ACTIVE_FRAMES_FX ) ) { @@ -1631,9 +1598,10 @@ Word16 wb_vad_fx( /* inside HO period */ test(); - if ( LT_16( hVAD->hangover_cnt, HANGOVER_LONG_FX ) && hVAD->hangover_cnt != 0 ) + IF( LT_16( hVAD->hangover_cnt, HANGOVER_LONG_FX ) && hVAD->hangover_cnt != 0 ) { hVAD->hangover_cnt = add( hVAD->hangover_cnt, 1 ); + move16(); } } ELSE @@ -1642,9 +1610,10 @@ Word16 wb_vad_fx( hVAD->nb_active_frames = 0; move16(); - if ( LT_16( hVAD->hangover_cnt, HANGOVER_LONG_FX ) ) /* inside HO period */ + IF( LT_16( hVAD->hangover_cnt, HANGOVER_LONG_FX ) ) /* inside HO period */ { hVAD->hangover_cnt = add( hVAD->hangover_cnt, 1 ); + move16(); } @@ -1652,14 +1621,16 @@ Word16 wb_vad_fx( { test(); test(); - if ( EQ_16( st_fx->element_mode, EVS_MONO ) && ( LT_16( lp_snr, th_clean ) ) && ( st_fx->Opt_SC_VBR != 0 ) && ( GE_16( hVAD->hangover_cnt, 2 ) ) ) + test(); + if ( st_fx->element_mode == EVS_MONO && ( LT_16( lp_snr, th_clean ) ) && ( st_fx->Opt_SC_VBR != 0 ) && ( GE_16( hVAD->hangover_cnt, 2 ) ) ) { *noisy_speech_HO = 1; move16(); } test(); test(); - if ( EQ_16( st_fx->element_mode, EVS_MONO ) && ( GE_16( lp_snr, th_clean ) ) && ( st_fx->Opt_SC_VBR != 0 ) && ( GE_16( hVAD->hangover_cnt, 2 ) ) ) + test(); + if ( st_fx->element_mode == EVS_MONO && ( GE_16( lp_snr, th_clean ) ) && ( st_fx->Opt_SC_VBR != 0 ) && ( GE_16( hVAD->hangover_cnt, 2 ) ) ) { *clean_speech_HO = 1; move16(); @@ -1706,6 +1677,7 @@ Word16 wb_vad_fx( IF( GT_16( snr_sum, thr1 ) ) /* Speech present, possibly in hangover */ { hVAD->nb_active_frames = add( hVAD->nb_active_frames, 1 ); /* Counter of consecutive active speech frames */ + move16(); IF( GE_16( hVAD->nb_active_frames, ACTIVE_FRAMES_FX ) ) { hVAD->nb_active_frames = ACTIVE_FRAMES_FX; @@ -1729,7 +1701,7 @@ Word16 wb_vad_fx( IF( LT_16( hVAD->hangover_cnt, HANGOVER_LONG_NB_FX ) ) { hVAD->hangover_cnt = add( hVAD->hangover_cnt, 1 ); - + move16(); IF( LT_16( lp_snr, 4864 ) ) /*19.0f Q8*/ /* very low SNR */ { @@ -1752,7 +1724,7 @@ Word16 wb_vad_fx( tmp = 282; move16(); /* 1.10f; */ } - if ( LT_16( lp_snr, th_clean ) ) + IF( LT_16( lp_snr, th_clean ) ) { thr2 = sub( thr1_nb_mod, tmp ); /*thr2 = thr1 - [ 1.10 || 1.3 ];*/ } @@ -1760,7 +1732,7 @@ Word16 wb_vad_fx( flag = 0; move16(); - IF( GT_16( snr_sum, thr1_nb_mod ) ) /* Speech assumed present, even though lowered thr1 */ + if ( GT_16( snr_sum, thr1_nb_mod ) ) /* Speech assumed present, even though lowered thr1 */ { flag = 1; move16(); @@ -1778,8 +1750,8 @@ Word16 wb_vad_fx( if ( EQ_16( st_fx->element_mode, EVS_MONO ) ) { *NB_speech_HO = 1; + move16(); } - move16(); } thr1 = thr1_nb_mod; move16(); /* needed for st_fx->vadnoise_fx update below */ @@ -1806,7 +1778,7 @@ Word16 wb_vad_fx( } } - if ( st_fx->hSC_VBR != NULL ) + IF( st_fx->hSC_VBR != NULL ) { /* SC-VBR */ st_fx->hSC_VBR->vadsnr_fx = snr_sum; @@ -1817,20 +1789,23 @@ Word16 wb_vad_fx( /* Updates */ hVAD->prim_act_quick_fx = mult_r( 26214, hVAD->prim_act_quick_fx ); /*Q15 */ - - if ( st_fx->localVAD != 0 ) + move16(); + IF( st_fx->localVAD != 0 ) { hVAD->prim_act_quick_fx = add( 6554, hVAD->prim_act_quick_fx ); /*Q15 */ + move16(); } hVAD->prim_act_slow_fx = mult_r( 32440, hVAD->prim_act_slow_fx ); /*Q15 */ + move16(); - if ( st_fx->localVAD != 0 ) + IF( st_fx->localVAD != 0 ) { hVAD->prim_act_slow_fx = add( 328, hVAD->prim_act_slow_fx ); /*Q15 */ + move16(); } - tmp = hVAD->prim_act_slow_fx; + tmp = hVAD->prim_act_slow_fx; /*Q15*/ move16(); if ( LE_16( hVAD->prim_act_quick_fx, hVAD->prim_act_slow_fx ) ) { @@ -1838,19 +1813,23 @@ Word16 wb_vad_fx( move16(); } /*st->prim_act = 0.1f * tmp + (1.0f-0.1f)* st->prim_act;*/ - hVAD->prim_act_fx = mac_r( L_mult( 3277, tmp ), 29491, hVAD->prim_act_fx ); - + hVAD->prim_act_fx = mac_r( L_mult( 3277, tmp ), 29491, hVAD->prim_act_fx ); /*Q15 */ + move16(); hVAD->prim_act_quick_he_fx = mult_r( 26214, hVAD->prim_act_quick_he_fx ); /*Q15 */ - if ( *localVAD_HE_SAD != 0 ) + move16(); + IF( *localVAD_HE_SAD != 0 ) { hVAD->prim_act_quick_he_fx = add( 6554, hVAD->prim_act_quick_he_fx ); /*Q15 */ + move16(); } hVAD->prim_act_slow_he_fx = mult_r( 32440, hVAD->prim_act_slow_he_fx ); /*Q15 */ - if ( *localVAD_HE_SAD != 0 ) + move16(); + IF( *localVAD_HE_SAD != 0 ) { hVAD->prim_act_slow_he_fx = add( 328, hVAD->prim_act_slow_he_fx ); /*Q15 */ + move16(); } tmp = hVAD->prim_act_slow_he_fx; @@ -1861,42 +1840,49 @@ Word16 wb_vad_fx( move16(); } hVAD->prim_act_he_fx = mac_r( L_mult( 3277, tmp ), 29491, hVAD->prim_act_he_fx ); + move16(); - - if ( L_and( hVAD->vad_flag_reg_H, (Word32) 0x40000L ) != 0 ) /* 0x4000L = 0x01L << 18 */ + IF( L_and( hVAD->vad_flag_reg_H, (Word32) 0x40000L ) != 0 ) /* 0x4000L = 0x01L << 18 */ { hVAD->vad_flag_cnt_50 = sub( hVAD->vad_flag_cnt_50, 1 ); + move16(); } hVAD->vad_flag_reg_H = L_shl( L_and( hVAD->vad_flag_reg_H, (Word32) 0x3fffffffL ), 1 ); + move32(); - - if ( L_and( hVAD->vad_flag_reg_L, (Word32) 0x40000000L ) != 0 ) + IF( L_and( hVAD->vad_flag_reg_L, (Word32) 0x40000000L ) != 0 ) { hVAD->vad_flag_reg_H = L_or( hVAD->vad_flag_reg_H, 0x01L ); + move32(); } hVAD->vad_flag_reg_L = L_shl( L_and( hVAD->vad_flag_reg_L, (Word32) 0x3fffffffL ), 1 ); - + move32(); IF( flag != 0 ) /* should not include the extra DTX hangover */ { hVAD->vad_flag_reg_L = L_or( hVAD->vad_flag_reg_L, 0x01L ); + move32(); hVAD->vad_flag_cnt_50 = add( hVAD->vad_flag_cnt_50, 1 ); + move16(); } - if ( L_and( hVAD->vad_prim_reg, (Word32) 0x8000L ) != 0 ) /* 0x8000L = 1L << 15 */ + IF( L_and( hVAD->vad_prim_reg, (Word32) 0x8000L ) != 0 ) /* 0x8000L = 1L << 15 */ { hVAD->vad_prim_cnt_16 = sub( hVAD->vad_prim_cnt_16, 1 ); + move16(); } hVAD->vad_prim_reg = L_shl( L_and( hVAD->vad_prim_reg, (Word32) 0x3fffffffL ), 1 ); - + move32(); IF( st_fx->localVAD != 0 ) { hVAD->vad_prim_reg = L_or( hVAD->vad_prim_reg, 0x01L ); + move32(); hVAD->vad_prim_cnt_16 = add( hVAD->vad_prim_cnt_16, 1 ); + move16(); } return flag; @@ -1904,7 +1890,7 @@ Word16 wb_vad_fx( Word16 wb_vad_ivas_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word32 fr_bands[], /* i : per band i energy (contains 2 vectors) q_fr_bands*/ + const Word32 fr_bands[], /* i : per band i energy (contains 2 vectors) Qx + QSCALE */ const Word16 q_fr_bands, /* i : Q of fr_bands */ Word16 *noisy_speech_HO, /* o : SC-VBR noisy speech HO flag */ Word16 *clean_speech_HO, /* o : SC-VBR clean speech HO flag */ @@ -1914,12 +1900,11 @@ Word16 wb_vad_ivas_fx( Word16 *flag_noisy_speech_snr, /* o : */ VAD_HANDLE hVAD, /* i/o: VAD data handle */ NOISE_EST_HANDLE hNoiseEst, /* i : Noise estimation handle */ - Word16 lp_speech_fx, /* i : long term active speech energy average */ - Word16 lp_noise_fx /* i : long term noise energy */ + Word16 lp_speech_fx, /* i : long term active speech energy average Q8 */ + Word16 lp_noise_fx /* i : long term noise energy Q8 */ ) { Word16 i, flag = 0, hangover_short; - Word16 snr_sum, thr1 = 0, thr1_nb_mod, thr2 = 0, nk = 0, nc = 0, th_clean = 0; Word16 lp_snr; /* Q8 */ const Word32 *pt1; @@ -1930,18 +1915,18 @@ Word16 wb_vad_ivas_fx( Word32 L_snr, L_snr_sum; Word32 ftmp, ftmp1, ftmp2; - Word16 m_noise_local, e_noise, e_num, m_num, snr, snr_tmp, shift_snr; - + Word16 m_noise_local, e_noise, e_num, m_num, snr_tmp, shift_snr, q_snr_tmp, q_snr; + Word32 L_snr_tmp; Word16 snr_sumt; Word32 L_vad_thr; Word16 hangover_hd; Word16 snr_idx; - Word16 delta1, delta2, delta3, delta4; + Word32 delta1, delta2, delta3, delta4; Word16 flag_he1; Word16 stmp; Word32 L_msnr, L_mssnr = 0, L_mssnr_hov; - Word16 j, tmp, tmp1, tmp2; + Word16 j, tmp, tmp2; Word32 L_tmp, L_tmp1, L_tmp2; Word32 L_snr18, L_snr19; /* Q4 */ @@ -1953,7 +1938,7 @@ Word16 wb_vad_ivas_fx( Word32 L_snr_sum_HE_SAD; /* Q4 */ Word16 snr_sum_HE_SAD; /*Q8 log */ Word16 sign_thr_HE_SAD, min_snr_HE_SAD; - + Word32 L_snr_sumt; Word16 thr1_ol; Word32 L_snr_sum_ol; @@ -1965,8 +1950,10 @@ Word16 wb_vad_ivas_fx( Word32 L_accum_ener_H; Word16 vad_bwidth_fx; Word16 last_7k2_coder_type; + Word16 q_shift; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif Word16 L_msnr_e = 0, L_mssnr_e = 0, L_mssnr_hov_e = 0, L_msnr18_e = 0, L_msnr19_e = 0; move16(); /*L_msnr_e*/ @@ -1974,7 +1961,6 @@ Word16 wb_vad_ivas_fx( move16(); /*L_mssnr_hov_e*/ move16(); /*L_msnr18_e*/ move16(); /*L_msnr19_e*/ - move16(); /*Overflow*/ move32(); /*L_mssnr*/ move16(); /*thr1*/ move16(); /*thr2*/ @@ -1994,13 +1980,13 @@ Word16 wb_vad_ivas_fx( } if ( LT_16( lp_speech_fx, -100 * 256 ) ) { - lp_speech_fx = st_fx->lp_speech_fx; + lp_speech_fx = st_fx->lp_speech_fx; /*Q8*/ move16(); } if ( LT_16( lp_noise_fx, -100 * 256 ) ) { - lp_noise_fx = st_fx->lp_noise_fx; + lp_noise_fx = st_fx->lp_noise_fx; /*Q8*/ move16(); } @@ -2083,7 +2069,7 @@ Word16 wb_vad_ivas_fx( } ELSE /* NB input */ { - move16(); + // move16(); nk = 3277; move16(); /* 0.1 Q15 */ nc = 4096; @@ -2140,15 +2126,15 @@ Word16 wb_vad_ivas_fx( IF( snr_idx == 0 ) { stmp = 6; - move16(); + move32(); delta1 = 0; - move16(); /*0.0f in Q13 */ + move32(); /*0.0f in Q16 */ delta2 = 0; - move16(); /*0.0f in Q13 */ + move32(); /*0.0f in Q16 */ delta3 = 0; - move16(); /*0.0f in Q13 */ + move32(); /*0.0f in Q16 */ delta4 = 0; - move16(); + move32(); /*0.0f in Q16 */ /*vad_thr = 2.4f*lp_snr - 42.2f; @@ -2162,15 +2148,15 @@ Word16 wb_vad_ivas_fx( ELSE IF( EQ_16( snr_idx, 1 ) ) { stmp = 6; - move16(); - delta1 = 819; - move16(); /*0.1f in Q13 */ - delta2 = 1638; - move16(); /*0.2f in Q13 */ - delta3 = 1638; - move16(); /*0.2f in Q13 */ - delta4 = 1638; - move16(); /*0.2f in Q13 */ + move32(); + delta1 = 6554; + move32(); /*0.1f in Q16 */ + delta2 = 13107; + move32(); /*0.2f in Q16 */ + delta3 = 13107; + move32(); /*0.2f in Q16 */ + delta4 = 13107; + move32(); /*0.2f in Q16 */ /* vad_thr = 2.4f*lp_snr - 40.2f; vad_thr = min(vad_thr, 80); @@ -2183,15 +2169,15 @@ Word16 wb_vad_ivas_fx( ELSE { stmp = 9; - move16(); - delta1 = 1638; - move16(); /*0.2f in Q13 */ - delta2 = 3277; - move16(); /*0.4f in Q13 */ - delta3 = 2458; - move16(); /*0.3f in Q13 */ - delta4 = 3277; - move16(); /*0.4f in Q13 */ + move32(); + delta1 = 13107; + move32(); /*0.2f in Q16 */ + delta2 = 26214; + move32(); /*0.4f in Q16 */ + delta3 = 19661; + move32(); /*0.3f in Q16 */ + delta4 = 26214; + move32(); /*0.4f in Q16 */ /* vad_thr = 2.5f*lp_snr - 10.0f; vad_thr = max(vad_thr, 1); */ @@ -2218,7 +2204,12 @@ Word16 wb_vad_ivas_fx( snr_sum_HE_SAD = 0; move16(); - + L_snr_sumt = 0; + move32(); + q_snr = 0; + move16(); + move16(); + q_shift = add( sub( q_fr_bands, hNoiseEst->q_bckr ), 15 - 4 ); FOR( i = st_fx->min_band; i <= st_fx->max_band; i++ ) { ftmp = L_add( *pt1++, 0 ); @@ -2240,20 +2231,16 @@ Word16 wb_vad_ivas_fx( IF( ftmp2 != 0 ) { e_num = norm_l( L_tmp1 ); - m_num = extract_h( L_shl( L_tmp1, e_num ) ); + m_num = extract_h( L_shl( L_tmp1, e_num ) ); // q_fr_bands+1+e_num-16 e_noise = norm_l( ftmp2 ); - m_noise_local = extract_h( L_shl( ftmp2, e_noise ) ); + m_noise_local = extract_h( L_shl( ftmp2, e_noise ) ); // hNoiseEst->q_bckr+e_noise-16 - m_num = shr( m_num, 1 ); - shift_snr = add( sub( e_num, e_noise ), 15 - 4 ); + m_num = shr( m_num, 1 ); // q_fr_bands+e_num-16 + shift_snr = add( sub( e_num, e_noise ), q_shift ); - snr_tmp = div_s( m_num, m_noise_local ); -#ifdef BASOP_NOGLOB + snr_tmp = div_s( m_num, m_noise_local ); // q_fr_bands+e_num-hNoiseEst->q_bckr-e_noise L_snr = L_shr_o( snr_tmp, shift_snr, &Overflow ); /* L_snr in Q4 */ -#else /* BASOP_NOGLOB */ - L_snr = L_shr( snr_tmp, shift_snr ); /* L_snr in Q4 */ -#endif /* BASOP_NOGLOB */ } ELSE { @@ -2267,20 +2254,16 @@ Word16 wb_vad_ivas_fx( IF( ftmp2 != 0 ) { e_num = norm_l( L_tmp2 ); - m_num = extract_h( L_shl( L_tmp2, e_num ) ); + m_num = extract_h( L_shl( L_tmp2, e_num ) ); // q_fr_bands+1+e_num-16 e_noise = norm_l( ftmp2 ); - m_noise_local = extract_h( L_shl( ftmp2, e_noise ) ); + m_noise_local = extract_h( L_shl( ftmp2, e_noise ) ); // hNoiseEst->q_bckr+e_noise-16 - m_num = shr( m_num, 1 ); - shift_snr = add( sub( e_num, e_noise ), 15 - 4 ); + m_num = shr( m_num, 1 ); // q_fr_bands+e_num-16 + shift_snr = add( sub( e_num, e_noise ), q_shift ); - snr_tmp = div_s( m_num, m_noise_local ); -#ifdef BASOP_NOGLOB + snr_tmp = div_s( m_num, m_noise_local ); // q_fr_bands+e_num-hNoiseEst->q_bckr-e_noise L_snr = L_shr_o( snr_tmp, shift_snr, &Overflow ); /* L_snr in Q4 */ -#else /* BASOP_NOGLOB */ - L_snr = L_shr( snr_tmp, shift_snr ); /* L_snr in Q4 */ -#endif /* BASOP_NOGLOB */ } ELSE { @@ -2296,70 +2279,48 @@ Word16 wb_vad_ivas_fx( /* snr[i] = (float)log10(snr[i]); */ - snr = vad_snr_log_fx( L_snr, ONE_LG10 ); + Word16 exp = norm_l( L_snr ); + Word16 val = Log2_norm_lc( L_shl( L_snr, exp ) ); + exp = sub( sub( 30, exp ), Q4 ); + L_snr = L_mac( L_deposit_h( exp ), val, 1 ); // Q16 + L_snr = Mpy_32_16_1( L_snr, 9864 /* log2 in Q15 */ ); // Q16 /* snr_sumt += snr[i];*/ - snr_sumt = add( snr_sumt, shr( snr, 4 ) ); /*Q4 */ + L_snr_sumt = L_add( L_snr_sumt, L_snr ); // Q16 - -#ifdef BASOP_NOGLOB - tmp = shl_o( snr, 5, &Overflow ); /* Q8 -> Q13 */ -#else /* BASOP_NOGLOB */ - tmp = shl( snr, 5 ); /* Q8 -> Q13 */ -#endif /* BASOP_NOGLOB */ IF( LT_16( i, 2 ) ) { -#ifdef BASOP_NOGLOB - tmp = add_o( tmp, delta1, &Overflow ); /*Q13 */ -#else /* BASOP_NOGLOB */ - tmp = add( tmp, delta1 ); /*Q13 */ -#endif /* BASOP_NOGLOB */ + ftmp = L_add( L_snr, delta1 ); // Q16 } ELSE IF( LT_16( i, 7 ) ) { -#ifdef BASOP_NOGLOB - tmp = add_o( tmp, delta2, &Overflow ); /*Q13 */ -#else /* BASOP_NOGLOB */ - tmp = add( tmp, delta2 ); /*Q13 */ -#endif /* BASOP_NOGLOB */ + ftmp = L_add( L_snr, delta2 ); // Q16 } ELSE IF( LT_16( i, 18 ) ) { -#ifdef BASOP_NOGLOB - tmp = add_o( tmp, delta3, &Overflow ); /*Q13 */ -#else /* BASOP_NOGLOB */ - tmp = add( tmp, delta3 ); /*Q13 */ -#endif /* BASOP_NOGLOB */ + ftmp = L_add( L_snr, delta3 ); // Q16 } ELSE { -#ifdef BASOP_NOGLOB - tmp = add_o( tmp, delta4, &Overflow ); /*Q13 */ -#else /* BASOP_NOGLOB */ - tmp = add( tmp, delta4 ); /*Q13 */ -#endif /* BASOP_NOGLOB */ + ftmp = L_add( L_snr, delta4 ); // Q16 } - tmp1 = tmp; - move16(); /* ftmp1 = ftmp; */ - sub( 0, 0 ); - IF( i < 7 ) + ftmp1 = ftmp; // Q16 + move32(); + + if ( LT_16( i, 7 ) ) { -#ifdef BASOP_NOGLOB - tmp1 = add_o( tmp, 3277, &Overflow ); /*.4 in Q13 ftmp1 = ftmp + 0.4f; */ -#else /* BASOP_NOGLOB */ - tmp1 = add( tmp, 3277 ); /*.4 in Q13 ftmp1 = ftmp + 0.4f; */ -#endif /* BASOP_NOGLOB */ + ftmp1 = L_add( ftmp, 26214 /*0.4 in Q16*/ ); // Q16 } - tmp = s_min( tmp, 16384 ); /* Q13, ftmp = min(ftmp, 2.0f); */ - tmp1 = s_min( tmp1, 16384 ); /* Q13, ftmp1 = min(ftmp1, 2.0f); */ + ftmp = L_min( ftmp, 2 << 16 ); // Q16 + ftmp1 = L_min( ftmp1, 2 << 16 ); // Q16 - Word16 norm_tmp = norm_l( tmp ); - Word32 scaled_tmp = L_shl( tmp, norm_tmp ); /*13+norm_tmp*/ + Word16 norm_tmp = norm_l( ftmp ); + Word32 scaled_tmp = L_shl( ftmp, norm_tmp ); /*16+norm_tmp*/ L_msnr = scaled_tmp; move32(); - L_msnr_e = sub( 18, norm_tmp ); + L_msnr_e = sub( 15, norm_tmp ); FOR( j = 1; j < stmp; j++ ) { /* Q13*Q13 +1 -16 +2 = Q13 */ @@ -2382,8 +2343,8 @@ Word16 wb_vad_ivas_fx( move16(); } - norm_tmp = norm_l( tmp1 ); - scaled_tmp = L_shl( tmp1, norm_tmp ); /*13+norm_tmp*/ + norm_tmp = norm_l( ftmp1 ); + scaled_tmp = L_shl( ftmp1, norm_tmp ); /*13+norm_tmp*/ L_msnr = scaled_tmp; move32(); L_msnr_e = sub( 18, norm_tmp ); @@ -2398,72 +2359,74 @@ Word16 wb_vad_ivas_fx( /* snr[i] = fr_enr / st->bckr[i] = L_tmp1/st->bckr[i];*/ IF( hNoiseEst->bckr_fx[i] != 0 ) { - e_num = norm_l( L_tmp1 ); - m_num = extract_h( L_shl( L_tmp1, e_num ) ); + e_num = sub( norm_l( L_tmp1 ), 1 ); + m_num = extract_h( L_shl( L_tmp1, e_num ) ); // q_fr_bands+1+e_num-16 e_noise = norm_l( hNoiseEst->bckr_fx[i] ); - m_noise_local = extract_h( L_shl( hNoiseEst->bckr_fx[i], e_noise ) ); - - m_num = shr( m_num, 1 ); - shift_snr = add( sub( e_num, e_noise ), 15 - 4 ); + m_noise_local = extract_h( L_shl( hNoiseEst->bckr_fx[i], e_noise ) ); // hNoiseEst->q_bckr+e_noise-16 - snr_tmp = div_s( m_num, m_noise_local ); -#ifdef BASOP_NOGLOB - L_snr = L_shr_o( snr_tmp, shift_snr, &Overflow ); /* L_snr in Q4 */ -#else /* BASOP_NOGLOB */ - L_snr = L_shr( snr_tmp, shift_snr ); /* L_snr in Q4 */ -#endif /* BASOP_NOGLOB */ + L_snr_tmp = L_deposit_h( div_s( m_num, m_noise_local ) ); // 32+q_fr_bands+e_num-hNoiseEst->q_bckr-e_noise + q_snr_tmp = add( 32, sub( add( q_fr_bands, e_num ), add( hNoiseEst->q_bckr, e_noise ) ) ); } ELSE { - L_snr = L_shr_o( L_tmp1, sub( Q3, q_fr_bands ), &Overflow ); // q_fr_bands+1 -> Q4 + L_snr_tmp = Mpy_32_16_1( L_tmp1, 18286 /* 1/E_MIN in Q6 */ ); // q_fr_bands-8 + q_snr_tmp = sub( q_fr_bands, 8 ); } - /* conditional snrsum, snr_sum = snr_sum + snr[i];*/ + exp = sub( Q4, q_snr_tmp ); + L_snr = L_shl_sat( L_snr_tmp, exp ); // Q4 sign_thr_snr_acc_fx( &L_snr_sum_HE_SAD, L_snr, sign_thr_HE_SAD, min_snr_HE_SAD ); sign_thr_snr_acc_fx( &L_snr_sum, L_snr, sign_thr, min_snr ); - L_snr = L_max( L_snr, 16 ); /*Q4, if( snr[i] < 1.0f ) { snr[i] = 1.0f;} */ + /* if( snr[i] < 1.0f ) { snr[i] = 1.0f;} */ + IF( LT_32( L_snr, 16 /* 1.0 in Q4 */ ) ) + { + L_snr_tmp = 16; + q_snr_tmp = Q4; + move32(); + move16(); + exp = 0; + move16(); + } /* float saves all snrs in an snr[] vector , in fix we only save two bands */ - IF( EQ_16( i, 18 ) ) + if ( EQ_16( i, 18 ) ) { - L_snr18 = L_add( L_snr, 0 ); /*Q4 */ + L_snr18 = L_shl_sat( L_snr_tmp, exp ); /*Q4 */ } - IF( EQ_16( i, 19 ) ) + if ( EQ_16( i, 19 ) ) { - L_snr19 = L_add( L_snr, 0 ); /* Q4 */ + L_snr19 = L_shl_sat( L_snr_tmp, exp ); /* Q4 */ } /* accumulate background noise energy in bands [0-2] and in bands [3-19]*/ IF( LT_16( i, 3 ) ) { -#ifdef BASOP_NOGLOB L_accum_ener_L = L_add_o( L_accum_ener_L, hNoiseEst->bckr_fx[i], &Overflow ); /* hNoiseEst->q_bckr */ -#else - L_accum_ener_L = L_add( L_accum_ener_L, hNoiseEst->bckr_fx[i] ); /*hNoiseEst->q_bckr */ -#endif } ELSE { -#ifdef BASOP_NOGLOB L_accum_ener_H = L_add_o( L_accum_ener_H, hNoiseEst->bckr_fx[i], &Overflow ); /*hNoiseEst->q_bckr */ -#else - L_accum_ener_H = L_add( L_accum_ener_H, hNoiseEst->bckr_fx[i] ); /*hNoiseEst->q_bckr */ -#endif } /* Identify the outlier band */ - IF( GT_32( L_snr, L_snr_outlier ) ) + IF( GT_32( L_snr_tmp, L_shl_sat( L_snr_outlier, sub( q_snr_tmp, q_snr ) ) ) ) { - L_snr_outlier = L_add( L_snr, 0 ); /*Q4*/ + L_snr_outlier = L_snr_tmp; + q_snr = q_snr_tmp; snr_outlier_index = i; + move32(); + move16(); move16(); } } /* end of band loop */ + L_snr_outlier = L_shl_sat( L_snr_outlier, sub( Q4, q_snr ) ); // q_snr -> Q4 + snr_sumt = extract_h( L_shl( L_snr_sumt, Q4 ) ); // Q16 -> Q4 + test(); test(); test(); /* one additional test for ELSE IF */ @@ -2534,11 +2497,8 @@ Word16 wb_vad_ivas_fx( } } /*st_fx->snr_sum_vad_fx = 0.5f * st->snr_sum_vad + 0.5f * snr_sum_ol;*/ -#ifdef BASOP_NOGLOB hVAD->L_snr_sum_vad_fx = L_shr( L_add_o( hVAD->L_snr_sum_vad_fx, L_snr_sum_ol, &Overflow ), 1 ); /*Q4*/ -#else /* BASOP_NOGLOB */ - hVAD->L_snr_sum_vad_fx = L_shr( L_add( hVAD->L_snr_sum_vad_fx, L_snr_sum_ol ), 1 ); /*Q4*/ -#endif /* BASOP_NOGLOB */ + move32(); /* snr_sum_ol = 10.0f * (float)log10( snr_sum_ol ); */ snr_sum_ol = vad_snr_log_fx( L_snr_sum_ol, LG10 ); @@ -2575,7 +2535,7 @@ Word16 wb_vad_ivas_fx( thr1 = mac_r( L_tmp, lp_snr, nk ); /* Q8+Q15+1 - 16 --> Q8 */ test(); - IF( st_fx->element_mode > EVS_MONO && hNoiseEst->first_noise_updt_cnt < 100 ) + IF( st_fx->element_mode > EVS_MONO && LT_16( hNoiseEst->first_noise_updt_cnt, 100 ) ) { /* lower threshold during warmup time */ thr1 = sub( thr1, 2560 ); @@ -2609,7 +2569,7 @@ Word16 wb_vad_ivas_fx( * Hangover control & final VAD decision *---------------------------------------------------------------------*/ - IF( NE_16( vad_bwidth_fx, NB ) ) + IF( vad_bwidth_fx != NB ) { /* Outlier Detection first calculates thr1_ol and snr_sum_ol instead of @@ -2661,11 +2621,7 @@ Word16 wb_vad_ivas_fx( thr1_ol = thr1; move16(); L_tmp2 = Msub_32_16( (Word32) 614, L_snr_outlier, 20972 ); /* .6*1024= */ /* 0.6 Q26(Q10 in high word) - Q4*Q21+1 */ -#ifdef BASOP_NOGLOB - tmp2 = round_fx( L_shl_o( L_tmp2, 14, &Overflow ) ); /* Q10(high word)+ 14 -16 --> Q8*/ -#else /* BASOP_NOGLOB */ - tmp2 = round_fx( L_shl( L_tmp2, 14 ) ); /* Q10(high word)+ 14 -16 --> Q8*/ -#endif + tmp2 = round_fx( L_shl_o( L_tmp2, 14, &Overflow ) ); /* Q10(high word)+ 14 -16 --> Q8*/ IF( L_tmp2 > 0 ) { thr1_ol = add( thr1_ol, tmp2 ); /* Q24 >>16 + Q8 */ @@ -2682,11 +2638,15 @@ Word16 wb_vad_ivas_fx( /* DTX HANGOVER is in pre_proc_fx() */ flag_he1 = 0; move16(); - + st_fx->localVAD = 0; + move16(); IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( L_mssnr, L_mssnr_e, L_vad_thr, 18 ), 1 ) ) { flag_he1 = 1; - move16(); /* he1 primary decision */ + move16(); + st_fx->localVAD = 1; + move16(); + /* he1 primary decision */ hVAD->nb_active_frames_he1 = add( hVAD->nb_active_frames_he1, 1 ); /* Counter of consecutive active speech frames */ move16(); @@ -3074,7 +3034,7 @@ Word16 wb_vad_ivas_fx( hVAD->prim_act_quick_fx = mult_r( 26214, hVAD->prim_act_quick_fx ); /*Q15 */ move16(); - if ( st_fx->localVAD != 0 ) + IF( st_fx->localVAD != 0 ) { hVAD->prim_act_quick_fx = add( 6554, hVAD->prim_act_quick_fx ); /*Q15 */ move16(); @@ -3083,13 +3043,13 @@ Word16 wb_vad_ivas_fx( hVAD->prim_act_slow_fx = mult_r( 32440, hVAD->prim_act_slow_fx ); /*Q15 */ move16(); - if ( st_fx->localVAD != 0 ) + IF( st_fx->localVAD != 0 ) { hVAD->prim_act_slow_fx = add( 328, hVAD->prim_act_slow_fx ); /*Q15 */ move16(); } - tmp = hVAD->prim_act_slow_fx; + tmp = hVAD->prim_act_slow_fx; /*Q15*/ move16(); if ( LE_16( hVAD->prim_act_quick_fx, hVAD->prim_act_slow_fx ) ) { @@ -3102,7 +3062,7 @@ Word16 wb_vad_ivas_fx( hVAD->prim_act_quick_he_fx = mult_r( 26214, hVAD->prim_act_quick_he_fx ); /*Q15 */ move16(); - if ( *localVAD_HE_SAD != 0 ) + IF( *localVAD_HE_SAD != 0 ) { hVAD->prim_act_quick_he_fx = add( 6554, hVAD->prim_act_quick_he_fx ); /*Q15 */ move16(); @@ -3110,7 +3070,7 @@ Word16 wb_vad_ivas_fx( hVAD->prim_act_slow_he_fx = mult_r( 32440, hVAD->prim_act_slow_he_fx ); /*Q15 */ move16(); - if ( *localVAD_HE_SAD != 0 ) + IF( *localVAD_HE_SAD != 0 ) { hVAD->prim_act_slow_he_fx = add( 328, hVAD->prim_act_slow_he_fx ); /*Q15 */ move16(); @@ -3126,7 +3086,7 @@ Word16 wb_vad_ivas_fx( hVAD->prim_act_he_fx = mac_r( L_mult( 3277, tmp ), 29491, hVAD->prim_act_he_fx ); move16(); - if ( L_and( hVAD->vad_flag_reg_H, (Word32) 0x40000L ) != 0 ) /* 0x4000L = 0x01L << 18 */ + IF( L_and( hVAD->vad_flag_reg_H, (Word32) 0x40000L ) != 0 ) /* 0x4000L = 0x01L << 18 */ { hVAD->vad_flag_cnt_50 = sub( hVAD->vad_flag_cnt_50, 1 ); move16(); @@ -3135,7 +3095,7 @@ Word16 wb_vad_ivas_fx( hVAD->vad_flag_reg_H = L_shl( L_and( hVAD->vad_flag_reg_H, (Word32) 0x3fffffffL ), 1 ); move32(); - if ( L_and( hVAD->vad_flag_reg_L, (Word32) 0x40000000L ) != 0 ) + IF( L_and( hVAD->vad_flag_reg_L, (Word32) 0x40000000L ) != 0 ) { hVAD->vad_flag_reg_H = L_or( hVAD->vad_flag_reg_H, 0x01L ); move32(); @@ -3153,9 +3113,9 @@ Word16 wb_vad_ivas_fx( } - if ( L_and( hVAD->vad_prim_reg, (Word32) 0x8000L ) != 0 ) /* 0x8000L = 1L << 15 */ + IF( L_and( hVAD->vad_prim_reg, (Word32) 0x8000L ) != 0 ) /* 0x8000L = 1L << 15 */ { - hVAD->vad_prim_cnt_16 = sub( hVAD->vad_prim_cnt_16, 1 ); + hVAD->vad_prim_cnt_16 = sub( hVAD->vad_prim_cnt_16, 1 ); /*Q0*/ move16(); } @@ -3164,9 +3124,9 @@ Word16 wb_vad_ivas_fx( IF( st_fx->localVAD != 0 ) { - hVAD->vad_prim_reg = L_or( hVAD->vad_prim_reg, 0x01L ); + hVAD->vad_prim_reg = L_or( hVAD->vad_prim_reg, 0x01L ); /*Q0*/ move32(); - hVAD->vad_prim_cnt_16 = add( hVAD->vad_prim_cnt_16, 1 ); + hVAD->vad_prim_cnt_16 = add( hVAD->vad_prim_cnt_16, 1 ); /*Q0*/ move16(); } diff --git a/lib_enc/vad_param_updt.c b/lib_enc/vad_param_updt.c deleted file mode 100644 index e82b4595f4c7202482ab5eee40ff59257442ab77..0000000000000000000000000000000000000000 --- a/lib_enc/vad_param_updt.c +++ /dev/null @@ -1,48 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "prot.h" -#include "wmc_auto.h" - -/*-------------------------------------------------------------------* - * vad_param_updt() - * - * Update parameters used by the VAD or DTX - *--------------------------------------------------------------------*/ diff --git a/lib_enc/vad_param_updt_fx.c b/lib_enc/vad_param_updt_fx.c index e0b607c5a68015d07f0af5774686659f67f828c4..464903a03a6b45a7e9e241b4c900901bd290b801 100644 --- a/lib_enc/vad_param_updt_fx.c +++ b/lib_enc/vad_param_updt_fx.c @@ -17,10 +17,10 @@ *--------------------------------------------------------------------*/ void vad_param_updt_fx( - Encoder_State *st_fx, /* i/o: state structure */ - const Word16 old_pitch1, /* i : OL pitch value from last frame */ - const Word16 corr_shift, /* i : correlation shift Q15*/ - const Word16 corr_shiftR, /* i : correlation shift */ + Encoder_State *st_fx, /* i/o: state structure */ + const Word16 old_pitch1, /* i : OL pitch value from last frame Q0 */ + const Word16 corr_shift, /* i : correlation shift Q15*/ + const Word16 corr_shiftR, /* i : correlation shift Q15 */ const Word16 Az[], /* i: a coeffs Q12 */ FRONT_VAD_ENC_HANDLE hFrontVad[], /* i/o: front-VAD handles */ const Word16 n_channels /* i : number of channels */ @@ -36,31 +36,29 @@ void vad_param_updt_fx( DTX_ENC_HANDLE hDtxEnc = st_fx->hDtxEnc; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif - corr_shift_temp[0] = corr_shift; - corr_shift_temp[1] = corr_shiftR; + corr_shift_temp[0] = corr_shift; /*Q15*/ + corr_shift_temp[1] = corr_shiftR; /*Q15*/ move16(); move16(); hVAD = st_fx->hVAD; ini_frame = st_fx->ini_frame; move16(); - move16(); IF( hFrontVad != NULL ) { hVAD = hFrontVad[0]->hVAD; ini_frame = hFrontVad[0]->ini_frame; move16(); - move16(); } FOR( i = 0; i < n_channels; i++ ) { if ( EQ_16( i, 1 ) ) { hVAD = hFrontVad[1]->hVAD; - move16(); } IF( !st_fx->Opt_AMR_WB ) { @@ -85,7 +83,8 @@ void vad_param_updt_fx( { /* update the counter of consecutive inactive frames in DTX */ hVAD->consec_inactive = add( hVAD->consec_inactive, 1 ); - IF( GT_16( hVAD->consec_inactive, 5 ) ) + move16(); + if ( GT_16( hVAD->consec_inactive, 5 ) ) { hVAD->consec_inactive = 5; move16(); @@ -115,7 +114,7 @@ void vad_param_updt_fx( hVAD->ra_deltasum_fx = add( hVAD->ra_deltasum_fx, sub( tmp2, tmp1 ) ); move16(); - tmp1 = mult( 26214, hVAD->running_avg_fx ); + tmp1 = mult( 26214, hVAD->running_avg_fx ); /* (0.8 in Q15 * Q15) = Q(30 - 15)*/ hVAD->running_avg_fx = add( tmp1, tmp2 ); move16(); @@ -148,7 +147,7 @@ void vad_param_updt_fx( hDtxEnc->cnt_SID = 1; move16(); st_fx->core_brate = SID_2k40; - move16(); + move32(); hVAD->trigger_SID = 0; move16(); } @@ -165,14 +164,9 @@ void vad_param_updt_fx( /* (voicing[0] + voicing[1] + voicing[2]) / 3 + corr_shift */ L_tmp = L_mult( st_fx->voicing_fx[0], 10923 ); L_tmp = L_mac( L_tmp, st_fx->voicing_fx[1], 10923 ); - L_tmp = L_mac( L_tmp, st_fx->voicing_fx[2], 10923 ); /*Q15 */ -#ifdef BASOP_NOGLOB + L_tmp = L_mac( L_tmp, st_fx->voicing_fx[2], 10923 ); /*Q15 */ L_tmp = L_mac_o( L_tmp, corr_shift_temp[i], 32767, &Overflow ); /*Q15 */ voice_tmp = round_fx_o( L_tmp, &Overflow ); /*Q15 */ -#else /* BASOP_NOGLOB */ - L_tmp = L_mac( L_tmp, corr_shift_temp[i], 32767 ); /*Q15 */ - voice_tmp = round_fx( L_tmp ); /*Q15 */ -#endif /* abs(pitch[0] - *pitO) + abs(pitch[1] - pitch[0]) + abs(pitch[2] - pitch[1]) */ pitch_tmp = abs_s( sub( st_fx->pitch[0], old_pitch1 ) ); /*Q0 */ diff --git a/lib_enc/vad_proc.c b/lib_enc/vad_proc.c deleted file mode 100644 index 661cc4b7b44a35c09c0ee29a47f1b5d01df6c3fe..0000000000000000000000000000000000000000 --- a/lib_enc/vad_proc.c +++ /dev/null @@ -1,42 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include -#include "options.h" -#include "prot.h" -#include "rom_enc.h" -#include "wmc_auto.h" diff --git a/lib_enc/vad_proc_fx.c b/lib_enc/vad_proc_fx.c index 2c12ec9963d302a67c8be4af01c4e3d35b1563cd..2c9273ff54824969fec1d5297c9bf322fd20cee4 100644 --- a/lib_enc/vad_proc_fx.c +++ b/lib_enc/vad_proc_fx.c @@ -25,8 +25,8 @@ Word16 vad_init_fx( ) { Word16 i = 0; - - IF( hVAD_CLDFB == NULL ) + move16(); + if ( hVAD_CLDFB == NULL ) { return -1; } @@ -177,7 +177,7 @@ Word16 vad_init_fx( return 0; } -static void UpdateState( +static void UpdateState_fx( VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */ Word16 vad_flag, /* i : VAD flag */ Word32 frame_energy, /* i : current frame energy */ @@ -205,7 +205,7 @@ static void UpdateState( hVAD_CLDFB->lt_bg_highf_eng = L_add( MUL_F( hVAD_CLDFB->lt_bg_highf_eng, 31130 ), L_shr( MUL_F( HB_Power, 1638 ), sub( HB_Power_Q, lt_bg_highf_eng_Q ) ) ); } - if ( LT_16( hVAD_CLDFB->frameloop, 1000 ) ) + IF( LT_16( hVAD_CLDFB->frameloop, 1000 ) ) { hVAD_CLDFB->frameloop = add( hVAD_CLDFB->frameloop, 1 ); move16(); @@ -242,7 +242,9 @@ static void UpdateState( move16(); hVAD_CLDFB->continuous_speech_num2 = add( hVAD_CLDFB->continuous_speech_num2, 1 ); + move16(); hVAD_CLDFB->continuous_speech_num = add( hVAD_CLDFB->continuous_speech_num, 1 ); + move16(); if ( GT_16( hVAD_CLDFB->continuous_speech_num, 2048 ) ) { hVAD_CLDFB->continuous_speech_num = 2048; @@ -357,7 +359,7 @@ Word16 vad_proc_fx( HB_Power_Q, snr, tsnr, hVAD_CLDFB->vad_flag_for_bk_update, music_backgound_f ); - UpdateState( hVAD_CLDFB, hVAD_CLDFB->vad_flag_for_bk_update, frame_energy2, frame_energy2_Q, update_flag, music_backgound_f, HB_Power, HB_Power_Q, snr ); + UpdateState_fx( hVAD_CLDFB, hVAD_CLDFB->vad_flag_for_bk_update, frame_energy2, frame_energy2_Q, update_flag, music_backgound_f, HB_Power, HB_Power_Q, snr ); return vad_flag; diff --git a/lib_enc/vbr_average_rate.c b/lib_enc/vbr_average_rate.c deleted file mode 100644 index ee4d0477acb81ddd3b7e06486a85b5a601a73d2a..0000000000000000000000000000000000000000 --- a/lib_enc/vbr_average_rate.c +++ /dev/null @@ -1,54 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "cnst.h" -#include "prot.h" -#include "rom_com.h" -#include "wmc_auto.h" - -/*------------------------------------------------------------------* - * Local constants - *------------------------------------------------------------------*/ - -#define RATEWIN 600 /* length of the rate control window. This is 600 active speech frames. This equals roughly 12s of active speech */ - -/*------------------------------------------------------------------* - * update_average_rate() - * - * SC-VBR update average data rate - *------------------------------------------------------------------*/ diff --git a/lib_enc/vbr_average_rate_fx.c b/lib_enc/vbr_average_rate_fx.c index 931333ebe264c01ecdf50d5a276127413b5ad34f..28371b2d716d2cd26f8cba81e5bdc40929ed02cb 100644 --- a/lib_enc/vbr_average_rate_fx.c +++ b/lib_enc/vbr_average_rate_fx.c @@ -41,7 +41,7 @@ /*=================================================================================*/ void update_average_rate_fx( SC_VBR_ENC_HANDLE hSC_VBR, /* i/o: SC-VBR state structure */ - const Word32 core_brate_fx /* i : core bitrate */ + const Word32 core_brate_fx /* i : core bitrate Q0 */ ) { Word32 avratetarg_fx; /* target rate for next RATEWIN active frames */ @@ -69,7 +69,7 @@ void update_average_rate_fx( /*st->global_avr_rate = (st->global_avr_rate * (st->global_frame_cnt-1) + st->sum_of_rates) / st->global_frame_cnt; */ exp = norm_s( hSC_VBR->global_frame_cnt ); - tmp = shl( hSC_VBR->global_frame_cnt, exp ); + tmp = shl( hSC_VBR->global_frame_cnt, exp ); /*Q0 + exp = exp*/ recip = div_s( 16384, tmp ); Qrecip = sub( 15, sub( exp, 14 ) ); @@ -218,11 +218,11 @@ void update_average_rate_fx( st->pattern_m=100 . Later this value is used in voiced.enc to bump up 10% of PPP frames to F frames. */ /* st->pattern_m = (short)(1000 * (avratetarg - 6.15f * RATEWIN * 10)/(10 * RATEWIN * 0.1f) ); */ - L_tmp = L_mult0( RATEWIN, VBR_ADR_MAX_TARGET_x10_Q1 ); - L_tmp = L_shl( L_tmp, 12 ); + L_tmp = RATEWIN * VBR_ADR_MAX_TARGET_x10_Q1; /* Q0 * Q1 = Q1 */ + L_tmp = L_shl( L_tmp, 12 ); /* Q1<<12 = Q13*/ L_tmp = L_sub( avratetarg_fx, L_tmp ); /*27307=(1000/(RATEWIN))Q14 */ - tmp = extract_h( L_shl( Mult_32_16( L_tmp, 27307 ), 4 ) ); + tmp = extract_h( L_shl( Mult_32_16( L_tmp, 27307 ), 4 ) ); /*(((Q13*Q0)<<4)>>16) = Q18>>16 = Q2*/ hSC_VBR->pattern_m = tmp; move16(); @@ -257,12 +257,8 @@ void update_average_rate_fx( move16(); /* sum the total number of bits (in kbytes) * 10 here */ /*st->sum_of_rates += (hSC_VBR->core_brate / 1000.0f) * 10; */ - L_tmp = L_shl( Mult_32_16( core_brate_fx, 20972 ), 7 ); -#ifdef BASOP_NOGLOB + L_tmp = L_shl( Mult_32_16( core_brate_fx, 20972 ), 7 ); /*Q13*/ hSC_VBR->sum_of_rates_fx = L_add_o( hSC_VBR->sum_of_rates_fx, L_tmp, &Overflow ); -#else - hSC_VBR->sum_of_rates_fx = L_add( hSC_VBR->sum_of_rates_fx, L_tmp ); -#endif move32(); return; } diff --git a/lib_enc/vlpc_1st_cod.c b/lib_enc/vlpc_1st_cod.c deleted file mode 100644 index 0fe8682daace6673130ca2ca05de2a188e8e2ae0..0000000000000000000000000000000000000000 --- a/lib_enc/vlpc_1st_cod.c +++ /dev/null @@ -1,42 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "cnst.h" -#include "prot.h" -#include "rom_com.h" -#include "wmc_auto.h" diff --git a/lib_enc/vlpc_1st_cod_fx.c b/lib_enc/vlpc_1st_cod_fx.c index deddb5023f050e318989567a1101cc9c99a90c54..9bfe0d8ae90c59aa69f96b024678e1fbd341760a 100644 --- a/lib_enc/vlpc_1st_cod_fx.c +++ b/lib_enc/vlpc_1st_cod_fx.c @@ -14,12 +14,12 @@ #define ISF_ONE 3 /*1.0f*1.28f Q1*/ /*=1.0f in 14Q1*1.28*/ /*------------------------------------------------------------------* - * lsf_weight() + * lsf_weight_fx() * * outputs only the weightings, doesn't do anything with the lsfq *------------------------------------------------------------------*/ /*outputs only the weightings, doesn't do anything with the lsfq*/ -static void lsf_weight( +static void lsf_weight_fx( const Word16 *lsfq, /* i : quantized lsf coefficients (14Q1*1.28)*/ Word16 *w /* o : lsf weighting vector (0Q15) */ ) @@ -31,7 +31,7 @@ static void lsf_weight( /* weighting function */ /*use the second element as the base to avoid the following division by 0*/ /*this happens when the ac function is nearly flat*/ - i = lsfq[0]; + i = lsfq[0]; /* (14Q1*1.28)*/ move16(); if ( lsfq[0] == 0 ) { @@ -40,7 +40,7 @@ static void lsf_weight( } inv_di0 = 0x7fff; move16(); - if ( GT_16( i, ISF_ONE ) ) + IF( GT_16( i, ISF_ONE ) ) { inv_di0 = div_s( ISF_ONE, i ); /*0Q15*/ /*inv_di0 = 1.0f / lsfq[0];*/ } @@ -52,33 +52,17 @@ static void lsf_weight( FOR( i = 1; i < ( M - 2 ); i += 2 ) /*for (i=1; i<(M-2); i+=2)*/ { inv_di1 = div_s( ISF_ONE, s_max( ISF_ONE, sub( lsfq[i], lsfq[i - 1] ) ) ); /*0Q15*/ /*inv_di1 = 1.0f / (lsfq[i] - lsfq[i-1]);*/ -#ifdef BASOP_NOGLOB w[i - 1] = add_sat( inv_di0, inv_di1 ); -#else - w[i - 1] = add( inv_di0, inv_di1 ); -#endif move16(); /*0Q15*/ /*w[i-1] = inv_di0 + inv_di1;*/ inv_di0 = div_s( ISF_ONE, s_max( ISF_ONE, sub( lsfq[i + 1], lsfq[i] ) ) ); /*0Q15*/ /*inv_di0 = 1.0f / (lsfq[i+1] - lsfq[i]);*/ -#ifdef BASOP_NOGLOB w[i] = add_sat( inv_di1, inv_di0 ); -#else - w[i] = add( inv_di1, inv_di0 ); -#endif move16(); /*0Q15*/ /*w[i] = inv_di1 + inv_di0;*/ } inv_di1 = div_s( ISF_ONE, s_max( ISF_ONE, sub( lsfq[i], lsfq[i - 1] ) ) ); /*inv_di1 = 1.0f / (lsfq[i] - lsfq[i-1]);*/ -#ifdef BASOP_NOGLOB w[i - 1] = add_sat( inv_di0, inv_di1 ); -#else - w[i - 1] = add( inv_di0, inv_di1 ); -#endif move16(); /*w[i-1] = inv_di0 + inv_di1;*/ inv_di0 = div_s( ISF_ONE, s_max( ISF_ONE, sub( FREQ_MAX, lsfq[i] ) ) ); /*inv_di0 = 1.0f / (FREQ_MAX - lsfq[i]);*/ -#ifdef BASOP_NOGLOB w[i] = add_sat( inv_di1, inv_di0 ); -#else - w[i] = add( inv_di1, inv_di0 ); -#endif move16(); /*w[i] = inv_di1 + inv_di0;*/ BASOP_SATURATE_WARNING_ON_EVS @@ -104,7 +88,7 @@ Word16 vlpc_1st_cod_fx( /* o : codebook index /* weighting */ - lsf_weight( lsf, w ); /*lsf:14Q1*1.28=>w:0Q15*/ + lsf_weight_fx( lsf, w ); /*lsf:14Q1*1.28=>w:0Q15*/ IF( EQ_16( rf_mode, 1 ) ) { Word16 s; diff --git a/lib_enc/vlpc_2st_cod.c b/lib_enc/vlpc_2st_cod.c deleted file mode 100644 index e7a8ca967132cf8896fc4a231dbaf74eed596840..0000000000000000000000000000000000000000 --- a/lib_enc/vlpc_2st_cod.c +++ /dev/null @@ -1,41 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "cnst.h" -#include "prot.h" -#include "wmc_auto.h" diff --git a/lib_enc/vlpc_2st_cod_fx.c b/lib_enc/vlpc_2st_cod_fx.c index 6334684d25f9fb78871a516aaa4d94fb537afb8d..2ea4df5a991b85e437dfbd9b55c4367637077a2d 100644 --- a/lib_enc/vlpc_2st_cod_fx.c +++ b/lib_enc/vlpc_2st_cod_fx.c @@ -18,9 +18,9 @@ *------------------------------------------------------------------*/ Word16 vlpc_2st_cod_fx( /* output: number of allocated bits */ - const Word16 *lsf, /* i : normalized vector to quantize */ - Word16 *lsfq, /* i/o: i:1st stage o:1st+2nd stage */ - Word16 *indx, /* o : index[] (4 bits per words) */ + const Word16 *lsf, /* i : normalized vector to quantize (14Q1*1.28) */ + Word16 *lsfq, /* i/o: i:1st stage o:1st+2nd stage (14Q1*1.28) */ + Word16 *indx, /* o : index[] (4 bits per words) Q0 */ const Word16 mode, /* i : 0=abs, >0=rel */ const Word32 sr_core /* i : internal sampling rate */ ) @@ -32,6 +32,7 @@ Word16 vlpc_2st_cod_fx( /* output: number of allocated bits Word16 gap; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif @@ -56,11 +57,7 @@ Word16 vlpc_2st_cod_fx( /* output: number of allocated bits BASOP_SATURATE_WARNING_OFF_EVS /* Allow saturate because we only need to know if the result is smaller than 8.0f */ FOR( i = 1; i < M; i++ ) { -#ifdef BASOP_NOGLOB L_tmp = L_mac_o( L_tmp, x[i], x[i], &Overflow ); /*10Q21*/ -#else /* BASOP_NOGLOB */ - L_tmp = L_mac( L_tmp, x[i], x[i] ); /*10Q21*/ -#endif } BASOP_SATURATE_WARNING_ON_EVS @@ -158,6 +155,7 @@ Word16 vlpc_2st_cod_fx( /* output: number of allocated bits { gap = 34; } + move16(); reorder_lsf_fx( lsfq, gap, M, INT_FS_FX ); diff --git a/lib_enc/voiced_enc.c b/lib_enc/voiced_enc.c deleted file mode 100644 index 5bfe6bfc099df4c4d4931c3c31b6c94162a7f88d..0000000000000000000000000000000000000000 --- a/lib_enc/voiced_enc.c +++ /dev/null @@ -1,44 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "prot.h" -#include "cnst.h" -#include "rom_com.h" -#include "wmc_auto.h" -#include "prot_fx.h" diff --git a/lib_enc/voiced_enc_fx.c b/lib_enc/voiced_enc_fx.c index cf08ebe5af47d25336b81e8abc4dc077fc654f87..b0dba61de4752b160164a6ad70f5612adcc6a100 100644 --- a/lib_enc/voiced_enc_fx.c +++ b/lib_enc/voiced_enc_fx.c @@ -74,15 +74,21 @@ ivas_error ppp_voiced_encoder_fx( { Word16 i; Word16 spike_near_edge = 0; + move16(); Word16 flag; Word16 delta_lag_E = 0, PPP_MODE_E, Q_delta_lag = 0; + move16(); /*delta_lag_E*/ + move16(); /*Q_delta_lag*/ Word16 out_of_bound = 0; + move16(); Word16 tmp, tmptmp, tmptmp1; Word16 pl, l; Word16 interp_delay[3], temp_pl, temp_l; Word16 upper_cut_off_freq_of_interest_fx = 0; + move16(); /*upper_cut_off_freq_of_interest_fx*/ Word16 upper_cut_off_freq_of_interest_norm_fx = 0, upper_cut_off_freq_norm_fx = 0; - + move16(); /*upper_cut_off_freq_of_interest_norm_fx*/ + move16(); /*upper_cut_off_freq_norm_fx*/ Word16 S_fx[PIT_MAX * 4 + 1], C_fx[PIT_MAX * 4 + 1]; Word16 Qtmpres; Word32 Ltemp, logLag, Ltemp_q; @@ -101,18 +107,24 @@ ivas_error ppp_voiced_encoder_fx( Word16 exp_ee, frac_ee; Word16 Qtmp; Word32 res_enratio_fx = 0; + move32(); Word16 mem_fx[10]; Word32 energy_impz_fx = 0, tmpres_fx; + move32(); /*energy_impz_fx*/ Word32 pos_nq0_fx, neg_nq0_fx, Ltmp; Word32 Ltmp_32, Ltmp1_32, Ltemp1, Ltemp2, Ltemp_fx; Word16 Qadj; Word32 tmp_fx = 0, sp_hb_enratio_fx = 0, sp_enratio_fx = 0; + move32(); /*tmp_fx*/ + move32(); /*sp_hb_enratio_fx*/ + move32(); /*sp_enratio_fx*/ Word32 low_band_en_fx; Word32 curr_Engy, prev_Engy; Word16 temp_Fs; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif DTFS_STRUCTURE *CURRP_NQ_FX; DTFS_STRUCTURE *TMPDTFS_FX; @@ -171,7 +183,7 @@ ivas_error ppp_voiced_encoder_fx( upper_cut_off_freq_norm_fx = 16384; move16(); /*value normalized by 12800 */ } - ELSE IF( EQ_16( bwidth_fx, NB ) ) + ELSE IF( bwidth_fx == NB ) { upper_cut_off_freq_of_interest_fx = 3300; move16(); @@ -219,19 +231,20 @@ ivas_error ppp_voiced_encoder_fx( if ( hSC_VBR->last_ppp_mode == 1 ) { hSC_VBR->rate_control = 0; + move16(); } PPP_MODE_E = 'Q'; move16(); pl = s_min( MAX_LAG_PIT, rint_new_fx( L_shl( old_pitch_buf[( 2 * NB_SUBFR ) - 1], 10 ) ) ); - move16(); l = s_min( MAX_LAG_PIT, rint_new_fx( L_deposit_h( delay_fx ) ) ); - move16(); /* old_pitch_buf in Q6*/ /* Bump up if the lag is out_fx of range */ test(); + test(); + test(); IF( GT_16( sub( l, pl ), 13 ) || LT_16( sub( l, pl ), -11 ) || LT_16( l, 19 ) || LT_16( pl, 19 ) ) { hSC_VBR->bump_up = 1; @@ -259,7 +272,7 @@ ivas_error ppp_voiced_encoder_fx( } /* Use the out_fx array as a temp storage for currp */ - spike_near_edge = ppp_extract_pitch_period_fx( in_fx, out_fx, l, &out_of_bound, Qres ); + spike_near_edge = ppp_extract_pitch_period_fx( in_fx, out_fx, l, &out_of_bound, Qres ); /*Q0*/ move16(); /* out_fx in Qres */ @@ -310,7 +323,7 @@ ivas_error ppp_voiced_encoder_fx( move16(); /* pitch_fx in Q6 */ } curr_Engy = DTFS_getEngy_P2A_fx( CURRP_NQ_FX ); /*2Q where Q=CURRP_NQ_FX->Q */ - + move32(); /* Restoring PPP memories when the last frame is non-PPP */ IF( NE_16( hSC_VBR->last_ppp_mode, 1 ) ) { @@ -325,7 +338,7 @@ ivas_error ppp_voiced_encoder_fx( prev_Engy = L_add( Lacc, 0 ); hSC_VBR->Q_prev_cw_en_fx = norm_l( Lacc ); /* = K = headroom */ - + move16(); /*hSC_VBR->Q_prev_cw_en_fx = (Lacc==0)?31: hSC_VBR->Q_prev_cw_en_fx; */ if ( Lacc == 0 ) { @@ -334,7 +347,9 @@ ivas_error ppp_voiced_encoder_fx( } hSC_VBR->prev_cw_en_fx = (Word32) L_shl( Lacc, hSC_VBR->Q_prev_cw_en_fx ); /*2Q+K */ + move32(); hSC_VBR->Q_prev_cw_en_fx = add( hSC_VBR->Q_prev_cw_en_fx, shl( dtfs_temp_fx->Q, 1 ) ); + move16(); /* hSC_VBR->Q_prev_cw_en_fx = 2*(dtfs_temp_fx->Q) + K */ DTFS_copy_fx( TMPDTFS_FX, *dtfs_temp_fx ); /* output = TMPDTFS_FX */ @@ -346,19 +361,21 @@ ivas_error ppp_voiced_encoder_fx( /* Process low band */ Ltemp = DTFS_setEngyHarm_fx( 236, 2828, 0, 2828, 1, 0, &Ql, TMPDTFS_FX ); /* Q of Ltemp = 2*(TMPDTFS_FX->Q) = Ql ? */ + move32(); /* Compensate for Q factor of energy to get log10(lag*eng) */ Ltemp = log10_fx( Ltemp ); /* Ltemp=10log10(eng), Q23 */ Ltemp = L_add( L_sub( Ltemp, Ltemp_q ), logLag ); /* Ltemp=10*log10(lag*eng), Q23 */ /*hSC_VBR->lastLgainE_fx=round_fx(L_shl((Word32)Mpy_32_16(extract_h(Ltemp),extract_l(Ltemp),0x6666),1)); // Q11, 0x6666 = 0.1 in Q18 */ hSC_VBR->lastLgainE_fx = round_fx( L_shl( Mult_32_16( Ltemp, 0x6666 ), 1 ) ); /* Q11, 0x6666 = 0.1 in Q18 */ - + move16(); /* Process high band */ Ltemp = DTFS_setEngyHarm_fx( 2828, upper_cut_off_freq_of_interest_norm_fx, 2828, upper_cut_off_freq_norm_fx, 1, 0, &Qh, TMPDTFS_FX ); + move32(); Ltemp = log10_fx( Ltemp ); Ltemp = L_add( L_sub( Ltemp, Ltemp_q ), logLag ); /* Ltemp=10*log10(lag*eng), Q23 */ hSC_VBR->lastHgainE_fx = round_fx( L_shl( Mult_32_16( Ltemp, 0x6666 ), 1 ) ); /* Q11 */ - + move16(); /* Need to unify the Q factors of both bands */ TMPDTFS_FX->Q = s_min( Ql, Qh ); move16(); /* set Q factor to be the smaller one of Ql and Qh */ @@ -380,11 +397,11 @@ ivas_error ppp_voiced_encoder_fx( { /* Copy DTFS related parameters from 'st_fx' to 'dtfs_temp' structure */ dtfs_temp_fx->lag_fx = hSC_VBR->dtfs_enc_lag; - move16(); + move16(); /*Q0*/ dtfs_temp_fx->nH_fx = hSC_VBR->dtfs_enc_nH; - move16(); + move16(); /*Q0*/ dtfs_temp_fx->nH_4kHz_fx = hSC_VBR->dtfs_enc_nH_4kHz; - move16(); + move16(); /*Q0*/ dtfs_temp_fx->upper_cut_off_freq_of_interest_fx = hSC_VBR->dtfs_enc_upper_cut_off_freq_of_interest_fx; move16(); dtfs_temp_fx->upper_cut_off_freq_fx = hSC_VBR->dtfs_enc_upper_cut_off_freq_fx; @@ -396,6 +413,7 @@ ivas_error ppp_voiced_encoder_fx( dtfs_temp_fx->Q = hSC_VBR->dtfs_enc_Q; move16(); Lacc1 = DTFS_getEngy_P2A_fx( dtfs_temp_fx ); + move32(); prev_Engy = L_add( Lacc1, 0 ); } @@ -457,14 +475,14 @@ ivas_error ppp_voiced_encoder_fx( DTFS_copy_fx( TMPDTFS2_FX, *dtfs_temp_fx ); /* output = TMPDTFS2_FX with Q = dtfs_temp_fx->Q */ tmptmp = DTFS_alignment_full_fx( *TMPDTFS2_FX, *TMPDTFS_FX, hSC_VBR->ph_offset_E_fx, S_fx, C_fx, 0 ); - + move16(); tmptmp1 = sub( shl( TMPDTFS_FX->lag_fx, 1 ), tmptmp ); /* (C_l-tmptmp) , Q1 */ Q2phaseShift_fx( TMPDTFS_FX, negate( shl( tmptmp1, 1 ) ), TMPDTFS_FX->lag_fx, S_fx, C_fx ); /* fixed bug , phase shift by tmp computed in_fx TMP.lag domain (above) */ /*tmpres = (float)(DTFS_freq_corr(*TMPDTFS, *TMPDTFS2, 100.0f, 3700.0f));*/ tmpres_fx = DTFS_freq_corr_fx( *TMPDTFS_FX, *TMPDTFS2_FX, 100, 3700, &Qtmpres ); /* tmpres_fx has Q factor tmpres */ - + move32(); poleFilter_setup_fx( lpc2_fx, M + 1, *TMPDTFS_FX, S_fx, C_fx, pf_temp1, pf_temp2, pf_temp, pf_n2 ); DTFS_poleFilter_fx_9( TMPDTFS_FX, pf_temp1, pf_temp2, pf_temp, pf_n2 ); @@ -475,6 +493,7 @@ ivas_error ppp_voiced_encoder_fx( DTFS_poleFilter_fx( TMPDTFS2_FX, lpc1_fx, M + 1, S_fx, C_fx ); /* lpc1_fx in Q12 */ tmp_fx = DTFS_freq_corr_fx( *TMPDTFS_FX, *TMPDTFS2_FX, 100, 3700, &Qtmp ); + move32(); /* tmp_fx Q = Qtmp */ @@ -489,11 +508,14 @@ ivas_error ppp_voiced_encoder_fx( } *******************************************************************************/ Ltmp_32 = ( DTFS_getEngy_fx( TMPDTFS2_FX ) ); /* Output Q=2*(TMPDTFS2_FX->Q) */ + move32(); IF( Ltmp_32 > 0 ) { /*sp_enratio = DTFS_getEngy(*TMPDTFS)/DTFS_getEngy(*TMPDTFS2); in Q15 */ Lacc = DTFS_getEngy_P2A_fx( TMPDTFS_FX ); + move32(); Lacc1 = Ltmp_32; + move32(); /* IF (L_sub(sp_enratio_fx,0x7FFF)!=0) */ { expb = norm_l( Lacc ); @@ -512,11 +534,7 @@ ivas_error ppp_voiced_encoder_fx( tmp = div_s( fracb, fraca ); exp = sub( expb, expa ); -#ifdef BASOP_NOGLOB sp_enratio_fx = L_shl_sat( tmp, exp ); /* Q15 */ -#else - sp_enratio_fx = L_shl( tmp, exp ); /* Q15 */ -#endif } } ELSE @@ -540,20 +558,12 @@ ivas_error ppp_voiced_encoder_fx( } /* Bump up if big change between the previous and the current CWs */ -#ifdef BASOP_NOGLOB IF( LT_16( shl_o( hSC_VBR->vadsnr_fx, 1, &Overflow ), hSC_VBR->SNR_THLD_fx ) ) /*Q8 */ -#else - IF( LT_16( shl( hSC_VBR->vadsnr_fx, 1 ), hSC_VBR->SNR_THLD_fx ) ) /*Q8 */ -#endif { /*if ( res_enratio > 5.0 && tmp < 0.65 ) */ /* 5 in Q11, 0.65 in Q15 // L_shl(tmp_fx,sub(31,Qtmp)) makes tmp_fx FIXED Q31 */ test(); -#ifdef BASOP_NOGLOB - IF( ( GT_32( res_enratio_fx, 10240 ) ) && ( LT_16( extract_h( L_shl_o( tmp_fx, sub( 31, Qtmp ), &Overflow ) ), 21299 ) ) ) -#else - IF( ( GT_32( res_enratio_fx, 10240 ) ) && ( LT_16( extract_h( L_shl( tmp_fx, sub( 31, Qtmp ) ) ), 21299 ) ) ) -#endif + if ( ( GT_32( res_enratio_fx, 10240 ) ) && ( LT_16( extract_h( L_shl_o( tmp_fx, sub( 31, Qtmp ), &Overflow ) ), 21299 ) ) ) { PPP_MODE_E = 'B'; move16(); @@ -564,11 +574,7 @@ ivas_error ppp_voiced_encoder_fx( /* if ( res_enratio > 3.0 && tmp < 1.2 ) */ /*3 in Q11, 1.2 in Q14 // L_shl(tmp_fx,sub(31,Qtmp)) makes tmp_fx FIXED Q14 */ test(); -#ifdef BASOP_NOGLOB - IF( ( GT_32( res_enratio_fx, 6144 ) ) && ( LT_16( extract_h( L_shl_o( tmp_fx, sub( 30, Qtmp ), &Overflow ) ), 19661 ) ) ) -#else - IF( ( GT_32( res_enratio_fx, 6144 ) ) && ( LT_16( extract_h( L_shl( tmp_fx, sub( 30, Qtmp ) ) ), 19661 ) ) ) -#endif + if ( ( GT_32( res_enratio_fx, 6144 ) ) && ( LT_16( extract_h( L_shl_o( tmp_fx, sub( 30, Qtmp ), &Overflow ) ), 19661 ) ) ) { PPP_MODE_E = 'B'; move16(); @@ -579,18 +585,10 @@ ivas_error ppp_voiced_encoder_fx( /* Rapid rampdown frame where time resolution is important */ /* Not a suitable PPP frame -> Bump to CELP */ -#ifdef BASOP_NOGLOB IF( LT_16( shl_o( hSC_VBR->vadsnr_fx, 1, &Overflow ), hSC_VBR->SNR_THLD_fx ) ) /*Q8 */ -#else - IF( LT_16( shl( hSC_VBR->vadsnr_fx, 1 ), hSC_VBR->SNR_THLD_fx ) ) /*Q8 */ -#endif { /* if (res_enratio < 0.025) */ -#ifdef BASOP_NOGLOB IF( LT_32( L_shl_o( res_enratio_fx, 4, &Overflow ), 819 ) ) /*0x0333 = 0.025 in Q15, res_enratio_fx in Q15 after shl 4 */ -#else - IF( LT_32( L_shl( res_enratio_fx, 4 ), 819 ) ) /*0x0333 = 0.025 in Q15, res_enratio_fx in Q15 after shl 4 */ -#endif { hSC_VBR->bump_up = 1; move16(); @@ -606,11 +604,7 @@ ivas_error ppp_voiced_encoder_fx( ELSE { /* if ( res_enratio < 0.092f) */ -#ifdef BASOP_NOGLOB if ( LT_32( L_shl_o( res_enratio_fx, 4, &Overflow ), 3015 ) ) /*3015 = 0.092 in Q15, res_enratio_fx in Q15 after shl 4 */ -#else - if ( LT_32( L_shl( res_enratio_fx, 4 ), 3015 ) ) /*3015 = 0.092 in Q15, res_enratio_fx in Q15 after shl 4 */ -#endif { hSC_VBR->bump_up = 1; move16(); @@ -619,11 +613,7 @@ ivas_error ppp_voiced_encoder_fx( /* if (min(res_enratio, sp_enratio) < 0.075 && tmp < -0.5f)) : 2458 = 0.075 in Q15 */ test(); -#ifdef BASOP_NOGLOB if ( LT_32( L_min( L_shl_o( res_enratio_fx, 4, &Overflow ), sp_enratio_fx ), 2458 ) && LT_32( tmp_fx, shl_o( -1, sub( Qtmp, 1 ), &Overflow ) ) ) -#else - if ( LT_32( L_min( L_shl( res_enratio_fx, 4 ), sp_enratio_fx ), 2458 ) && LT_32( tmp_fx, shl( -1, sub( Qtmp, 1 ) ) ) ) -#endif { hSC_VBR->bump_up = 1; move16(); @@ -631,11 +621,7 @@ ivas_error ppp_voiced_encoder_fx( /* Rapid rampup frame where time resolution is important */ /* Not a suitable PPP frame -> Bump to CELP */ -#ifdef BASOP_NOGLOB IF( LT_16( shl_o( hSC_VBR->vadsnr_fx, 1, &Overflow ), hSC_VBR->SNR_THLD_fx ) ) /*Q8 */ -#else - IF( LT_16( shl( hSC_VBR->vadsnr_fx, 1 ), hSC_VBR->SNR_THLD_fx ) ) /*Q8 */ -#endif { IF( GT_32( res_enratio_fx, 29696 ) ) /*14.5 in Q11 */ { @@ -659,7 +645,7 @@ ivas_error ppp_voiced_encoder_fx( } } - IF( hSC_VBR->bump_up == 1 ) + IF( EQ_16( hSC_VBR->bump_up, 1 ) ) { free( CURRP_NQ_FX ); free( TMPDTFS_FX ); @@ -692,7 +678,7 @@ ivas_error ppp_voiced_encoder_fx( move16(); IF( EQ_16( PPP_MODE_E, 'Q' ) ) { - if ( ( error = ppp_quarter_encoder_fx( &flag, CURRP_Q_E_FX, TMPDTFS_FX, dtfs_temp_fx->lag_fx, *CURRP_NQ_FX, lpc2_fx, &hSC_VBR->lastLgainE_fx, &hSC_VBR->lastHgainE_fx, hSC_VBR->lasterbE_fx, *dtfs_temp_fx, S_fx, C_fx, hBstr ) ) != IVAS_ERR_OK ) + IF( ( error = ppp_quarter_encoder_fx( &flag, CURRP_Q_E_FX, TMPDTFS_FX, dtfs_temp_fx->lag_fx, *CURRP_NQ_FX, lpc2_fx, &hSC_VBR->lastLgainE_fx, &hSC_VBR->lastHgainE_fx, hSC_VBR->lasterbE_fx, *dtfs_temp_fx, S_fx, C_fx, hBstr ) ) != IVAS_ERR_OK ) { free( CURRP_NQ_FX ); free( TMPDTFS_FX ); @@ -728,11 +714,13 @@ ivas_error ppp_voiced_encoder_fx( IF( GT_16( CURRP_Q_E_FX->upper_cut_off_freq_fx, 4000 ) ) { Ltemp2 = DTFS_getEngy_band_wb_fx( *CURRP_Q_E_FX, 0, 2000 ); + move32(); /* Use this bump-up only for WB signals */ IF( Ltemp2 > 0 ) { /* sp_hb_enratio = DTFS_getEngy_band_wb(*CURRP_Q_E, 2000.0, 6400.0)/DTFS_getEngy_band_wb(*CURRP_Q_E, 0.0, 2000.0); */ Ltemp1 = DTFS_getEngy_band_wb_fx( *CURRP_Q_E_FX, 2000, 6400 ); /*Q13 */ + move32(); /*sp_hb_enratio_fx = divide_dp(Ltemp1,Ltemp2,0, 1);//Q29 */ Qadj = 0; move16(); @@ -744,11 +732,7 @@ ivas_error ppp_voiced_encoder_fx( Ltemp1 = L_negate( Ltemp1 ); } expa = norm_l( Ltemp2 ); -#ifdef BASOP_NOGLOB fraca = extract_h( L_shl_o( Ltemp2, expa, &Overflow ) ); -#else - fraca = extract_h( L_shl( Ltemp2, expa ) ); -#endif expa = sub( 30, expa ); expb = norm_l( Ltemp1 ); @@ -756,20 +740,12 @@ ivas_error ppp_voiced_encoder_fx( expb = sub( 30, add( expb, Qadj ) ); scale = shr( sub( fraca, fracb ), 15 ); -#ifdef BASOP_NOGLOB fracb = shl_o( fracb, scale, &Overflow ); -#else - fracb = shl( fracb, scale ); -#endif expb = sub( expb, scale ); tmp = div_s( fracb, fraca ); exp = sub( expb, expa ); -#ifdef BASOP_NOGLOB Ltemp_fx = L_shl_o( tmp, add( exp, 14 ), &Overflow ); -#else - Ltemp_fx = L_shl( tmp, add( exp, 14 ) ); -#endif /*-------------------------------------------*/ sp_hb_enratio_fx = L_add( Ltemp_fx, 0 ); /* Q29 */ } @@ -778,11 +754,11 @@ ivas_error ppp_voiced_encoder_fx( sp_hb_enratio_fx = L_deposit_l( 0 ); } low_band_en_fx = Ltemp2; /*Q13 */ - + move32(); /* if ( low_band_en < 25.0f && sp_hb_enratio < 1.6f ) */ /* 25.0 in Q13 = 204800, 1.6 in Q29 = 858993459 */ test(); - IF( LT_32( low_band_en_fx, 204800 ) && LT_32( sp_hb_enratio_fx, 858993459 ) ) + if ( LT_32( low_band_en_fx, 204800 ) && LT_32( sp_hb_enratio_fx, 858993459 ) ) { PPP_MODE_E = 'B'; move16(); @@ -790,21 +766,14 @@ ivas_error ppp_voiced_encoder_fx( } Ltmp_32 = DTFS_getEngy_fx( CURRP_NQ_FX ); /*Q = 2*(CURRP_NQ_FX->Q) */ + move32(); Qadj = sub( hSC_VBR->Q_prev_cw_en_fx, shl( CURRP_NQ_FX->Q, 1 ) ); -#ifdef BASOP_NOGLOB Ltmp_32 = L_shl_o( Ltmp_32, Qadj, &Overflow ); /* shift left required to adjust Q of CURRP_NQ_FX = Q_prev_cw_en_fx */ -#else - Ltmp_32 = L_shl( Ltmp_32, Qadj ); /* shift left required to adjust Q of CURRP_NQ_FX = Q_prev_cw_en_fx */ -#endif /* Ltmp1_32 = 0.8f * st->prev_cw_en */ Ltmp1_32 = Mult_32_16( hSC_VBR->prev_cw_en_fx, 26214 ); /* Q = (Q_prev_cw_en_fx + Q15+1)-Q16 = Q_prev_cw_en_fx */ -#ifdef BASOP_NOGLOB IF( LT_16( shl_o( hSC_VBR->vadsnr_fx, 1, &Overflow ), hSC_VBR->SNR_THLD_fx ) ) /*Q8 */ -#else - IF( LT_16( shl( hSC_VBR->vadsnr_fx, 1 ), hSC_VBR->SNR_THLD_fx ) ) /*Q8 */ -#endif { /* if ( DTFS_getEngy(*CURRP_NQ) > 0.8f * st->prev_cw_en && max(pos_nq, neg_nq) > 3.0f && st->rate_control ) */ /* pos_nq_fx and neg_nq_fx in Q28 ???? */ @@ -814,7 +783,7 @@ ivas_error ppp_voiced_encoder_fx( { /*if ( pos_nq > neg_nq && pos_nq > 2.0f * pos_q ) */ test(); - IF( GT_32( pos_nq_fx, neg_nq_fx ) && GT_32( Mult_32_16( pos_nq_fx, 16384 ), pos_q_fx ) ) + if ( GT_32( pos_nq_fx, neg_nq_fx ) && GT_32( Mult_32_16( pos_nq_fx, 16384 ), pos_q_fx ) ) { PPP_MODE_E = 'B'; move16(); @@ -822,7 +791,7 @@ ivas_error ppp_voiced_encoder_fx( test(); /*if ( pos_nq < neg_nq && neg_nq > 2.0f * neg_q ) */ - IF( LT_32( pos_nq_fx, neg_nq_fx ) && GT_32( Mult_32_16( neg_nq_fx, 16384 ), neg_q_fx ) ) + if ( LT_32( pos_nq_fx, neg_nq_fx ) && GT_32( Mult_32_16( neg_nq_fx, 16384 ), neg_q_fx ) ) { PPP_MODE_E = 'B'; move16(); @@ -849,8 +818,8 @@ ivas_error ppp_voiced_encoder_fx( test(); test(); test(); - IF( ( GT_32( pos_nq_fx, neg_nq_fx ) && GT_32( Mult_32_16( pos_nq_fx, 13107 ), pos_q_fx ) && ( hSC_VBR->rate_control ) ) || - ( GT_32( pos_nq_fx, neg_nq_fx ) && GT_32( Mult_32_16( pos_nq_fx, 16384 ), pos_q_fx ) && ( !hSC_VBR->rate_control ) ) ) + if ( ( GT_32( pos_nq_fx, neg_nq_fx ) && GT_32( Mult_32_16( pos_nq_fx, 13107 ), pos_q_fx ) && ( hSC_VBR->rate_control ) ) || + ( GT_32( pos_nq_fx, neg_nq_fx ) && GT_32( Mult_32_16( pos_nq_fx, 16384 ), pos_q_fx ) && ( !hSC_VBR->rate_control ) ) ) { PPP_MODE_E = 'B'; move16(); @@ -863,8 +832,8 @@ ivas_error ppp_voiced_encoder_fx( test(); test(); test(); - IF( ( LT_32( pos_nq_fx, neg_nq_fx ) && GT_32( Mult_32_16( neg_nq_fx, 13107 ), neg_q_fx ) && ( hSC_VBR->rate_control ) ) || - ( LT_32( pos_nq_fx, neg_nq_fx ) && GT_32( Mult_32_16( neg_nq_fx, 16384 ), neg_q_fx ) && ( !hSC_VBR->rate_control ) ) ) + if ( ( LT_32( pos_nq_fx, neg_nq_fx ) && GT_32( Mult_32_16( neg_nq_fx, 13107 ), neg_q_fx ) && ( hSC_VBR->rate_control ) ) || + ( LT_32( pos_nq_fx, neg_nq_fx ) && GT_32( Mult_32_16( neg_nq_fx, 16384 ), neg_q_fx ) && ( !hSC_VBR->rate_control ) ) ) { PPP_MODE_E = 'B'; move16(); @@ -905,11 +874,7 @@ ivas_error ppp_voiced_encoder_fx( /* compute energy of impz */ FOR( x_fx = 0; x_fx < 160; x_fx++ ) { -#ifdef BASOP_NOGLOB energy_impz_fx = L_add_o( energy_impz_fx, L_mult0( impzo_fx[x_fx], impzo_fx[x_fx] ), &Overflow ); -#else - energy_impz_fx = L_add( energy_impz_fx, L_mult0( impzo_fx[x_fx], impzo_fx[x_fx] ) ); -#endif } /*energy_impz = (float)(10*log10((float)energy_impz)); */ @@ -921,27 +886,20 @@ ivas_error ppp_voiced_encoder_fx( /* energy_impz_fx is Q11 */ Ltmp_32 = DTFS_getEngy_fx( CURRP_Q_E_FX ); /*Q = 2*(CURRP_Q_E_FX->Q) */ + move32(); Qadj = sub( hSC_VBR->Q_prev_cw_en_fx, shl( CURRP_Q_E_FX->Q, 1 ) ); -#ifdef BASOP_NOGLOB Ltmp_32 = L_shl_o( Ltmp_32, Qadj, &Overflow ); /* shift left required to adjust Q of CURRP_Q_E_FX = Q_prev_cw_en_fx */ -#else - Ltmp_32 = L_shl( Ltmp_32, Qadj ); /* shift left required to adjust Q of CURRP_Q_E_FX = Q_prev_cw_en_fx */ -#endif /* if ((DTFS_getEngy(*CURRP_Q_E) > st->prev_cw_en)&&(max(pos_q,neg_q)>3.5) && energy_impz>15.0 && tmpres>0.7) */ test(); test(); test(); -#ifdef BASOP_NOGLOB IF( ( GT_32( Ltmp_32, hSC_VBR->prev_cw_en_fx ) ) && ( GT_32( L_max( pos_q_fx, neg_q_fx ), 939524096 ) ) && ( GT_32( energy_impz_fx, 30720 ) ) && ( GT_32( Mult_32_16( tmpres_fx, 23265 ), shl_o( 1, sub( Qtmpres, 1 ), &Overflow ) ) ) ) -#else - IF( ( GT_32( Ltmp_32, hSC_VBR->prev_cw_en_fx ) ) && ( GT_32( L_max( pos_q_fx, neg_q_fx ), 939524096 ) ) && ( GT_32( energy_impz_fx, 30720 ) ) && ( GT_32( Mult_32_16( tmpres_fx, 23265 ), shl( 1, sub( Qtmpres, 1 ) ) ) ) ) -#endif { /* if ((pos_q > neg_q) && ((pos_q>3.0*pos_nq0) || ((pos_q > 1.5*pos_nq0) && (neg_q < 1.5*neg_nq0)))) */ test(); test(); test(); - IF( ( GT_32( pos_q_fx, neg_q_fx ) ) && ( ( GT_32( Mult_32_16( pos_q_fx, 10923 ), L_shr( pos_nq0_fx, sub( Qposnq, 28 ) ) ) ) || ( ( GT_32( Mult_32_16( pos_q_fx, 21845 ), L_shr( pos_nq0_fx, sub( Qposnq, 28 ) ) ) ) && ( LT_32( Mult_32_16( neg_q_fx, 21846 ), L_shr( neg_nq0_fx, sub( Qnegnq, 28 ) ) ) ) ) ) ) + if ( ( GT_32( pos_q_fx, neg_q_fx ) ) && ( ( GT_32( Mult_32_16( pos_q_fx, 10923 ), L_shr( pos_nq0_fx, sub( Qposnq, 28 ) ) ) ) || ( ( GT_32( Mult_32_16( pos_q_fx, 21845 ), L_shr( pos_nq0_fx, sub( Qposnq, 28 ) ) ) ) && ( LT_32( Mult_32_16( neg_q_fx, 21846 ), L_shr( neg_nq0_fx, sub( Qnegnq, 28 ) ) ) ) ) ) ) /* 10923 = (1/3) oin Q15, pos_q_fx is Q28, so result of Mult_32_16(pos_q_fx,10923) = Q28 */ /* L_shr(pos_nq0_fx,sub(Qposnq,28)) brings pos_nq0_fx with variable Q to fixed Q28 */ { @@ -952,7 +910,7 @@ ivas_error ppp_voiced_encoder_fx( test(); test(); /* if ((pos_q <= neg_q) && ((neg_q>3.0*neg_nq0)|| ((neg_q > 1.5*neg_nq0) && (pos_q < 1.5*pos_nq0)))) */ - IF( ( LE_32( pos_q_fx, neg_q_fx ) ) && ( ( GT_32( Mult_32_16( neg_q_fx, 10923 ), L_shr( neg_nq0_fx, sub( Qnegnq, 28 ) ) ) ) || ( ( GT_32( Mult_32_16( neg_q_fx, 21846 ), L_shr( neg_nq0_fx, sub( Qnegnq, 28 ) ) ) ) && ( LT_32( Mult_32_16( pos_q_fx, 21846 ), L_shr( pos_nq0_fx, sub( Qposnq, 28 ) ) ) ) ) ) ) + if ( ( LE_32( pos_q_fx, neg_q_fx ) ) && ( ( GT_32( Mult_32_16( neg_q_fx, 10923 ), L_shr( neg_nq0_fx, sub( Qnegnq, 28 ) ) ) ) || ( ( GT_32( Mult_32_16( neg_q_fx, 21846 ), L_shr( neg_nq0_fx, sub( Qnegnq, 28 ) ) ) ) && ( LT_32( Mult_32_16( pos_q_fx, 21846 ), L_shr( pos_nq0_fx, sub( Qposnq, 28 ) ) ) ) ) ) ) { PPP_MODE_E = 'B'; move16(); @@ -971,11 +929,13 @@ ivas_error ppp_voiced_encoder_fx( /* operate in ADR mode only the rate control is active. This adds some bumpups to improve the speech quality */ /* if ((DTFS_getEngy_band(*TMPDTFS, 1500.0, upper_cut_off_freq_of_interest)/DTFS_getEngy(*TMPDTFS) > 0.05)&&(!st->rate_control)) */ Ltemp1 = DTFS_getEngy_band_fx( *TMPDTFS_FX, 1500, upper_cut_off_freq_of_interest_fx ); /* Q = 2*TMPDTFS_FX->Q*/ - Ltemp2 = DTFS_getEngy_fx( TMPDTFS_FX ); /* Q = 2*TMPDTFS_FX->Q */ - + move32(); + Ltemp2 = DTFS_getEngy_fx( TMPDTFS_FX ); /* Q = 2*TMPDTFS_FX->Q */ + move32(); IF( Ltemp2 == 0 ) { Ltemp_fx = 0; + move32(); } ELSE { @@ -990,13 +950,9 @@ ivas_error ppp_voiced_encoder_fx( fracb = shl( fracb, scale ); expb = sub( expb, scale ); - tmp = div_s( fracb, fraca ); /* tmp in Q15 */ - exp = sub( expb, expa ); /* ans = tmp*2^(exp) */ -#ifdef BASOP_NOGLOB + tmp = div_s( fracb, fraca ); /* tmp in Q15 */ + exp = sub( expb, expa ); /* ans = tmp*2^(exp) */ Ltemp_fx = L_shl_o( tmp, add( exp, 12 ), &Overflow ); /* make tmp Q27 */ -#else - Ltemp_fx = L_shl( tmp, add( exp, 12 ) ); /* make tmp Q27 */ -#endif } test(); IF( GT_32( Ltemp_fx, 6710886 ) && ( !hSC_VBR->rate_control ) ) /* 0.05 in Q27 = 6710886 */ @@ -1005,14 +961,16 @@ ivas_error ppp_voiced_encoder_fx( /*DTFS_getEngy_band(*TMPDTFS3,1500.0,upper_cut_off_freq_of_interest)) < 0.1) */ Ltemp1 = DTFS_getEngy_band_fx( *TMPDTFS_FX, 1500, upper_cut_off_freq_of_interest_fx ); + move32(); Ltemp2 = DTFS_getEngy_band_fx( *TMPDTFS3_FX, 1500, upper_cut_off_freq_of_interest_fx ); - + move32(); /*--------------------------------------------------------------*/ /* Ltemp_fx = (Word32)divide_dp(Ltemp1, Ltemp2, Qadj,1);//Q29+1 */ /*--------------------------------------------------------------*/ IF( Ltemp2 == 0 ) { Ltemp_fx = 0; + move32(); } ELSE { @@ -1030,11 +988,7 @@ ivas_error ppp_voiced_encoder_fx( tmp = div_s( fracb, fraca ); exp = sub( expb, expa ); -#ifdef BASOP_NOGLOB Ltemp_fx = L_shl_o( tmp, add( exp, 14 ), &Overflow ); /* answer in Q29 */ -#else - Ltemp_fx = L_shl( tmp, add( exp, 14 ) ); /* answer in Q29 */ -#endif } /*-------------------------------------------*/ @@ -1057,9 +1011,10 @@ ivas_error ppp_voiced_encoder_fx( /* To increase bump up, raise first threshold, lower second */ /*tmp = (float)(10.0*log10(DTFS_getEngy(*TMPDTFS)/DTFS_getEngy(*TMPDTFS3)));*/ - Lacc = DTFS_getEngy_P2A_fx( TMPDTFS_FX ); /* Q = 2*(TMPDTFS_FX->Q) */ + Lacc = DTFS_getEngy_P2A_fx( TMPDTFS_FX ); /* Q = 2*(TMPDTFS_FX->Q) */ + move32(); Lacc1 = DTFS_getEngy_P2A_fx( TMPDTFS3_FX ); /* Q = 2*(TMPDTFS3_FX->Q) */ - + move32(); sft = shl( sub( TMPDTFS_FX->Q, TMPDTFS3_FX->Q ), 1 ); /* to check if Lacc<=2*Lacc1 */ flag1 = 0; @@ -1100,12 +1055,8 @@ ivas_error ppp_voiced_encoder_fx( L_tmp = L_shl( L_tmp, expa ); exp = sub( 30, add( expa, sub( 31, exp ) ) ); frac = Log2_norm_lc( L_tmp ); - L_tmp = Mpy_32_16( exp, frac, 12330 ); /* L_tmp is always Q13 */ -#ifdef BASOP_NOGLOB + L_tmp = Mpy_32_16( exp, frac, 12330 ); /* L_tmp is always Q13 */ Ltemp = L_shl_o( L_tmp, 10, &Overflow ); /* Ltemp is always Q23 */ -#else - Ltemp = L_shl( L_tmp, 10 ); /* Ltemp is always Q23 */ -#endif } ELSE { @@ -1119,11 +1070,7 @@ ivas_error ppp_voiced_encoder_fx( move16(); } -#ifdef BASOP_NOGLOB IF( LT_16( shl_o( hSC_VBR->vadsnr_fx, 1, &Overflow ), hSC_VBR->SNR_THLD_fx ) ) /* Q8 */ -#else - IF( LT_16( shl( hSC_VBR->vadsnr_fx, 1 ), hSC_VBR->SNR_THLD_fx ) ) /* Q8 */ -#endif { /* if ((( tmp < 3.05 && max(res_enratio,sp_enratio) > 0.8 ) && (st->rate_control))|| (( tmp < 2.8 && max(res_enratio,sp_enratio) > 0.65 ) && (!st->rate_control))) */ @@ -1168,7 +1115,7 @@ ivas_error ppp_voiced_encoder_fx( ELSE { } - if ( PPP_MODE_E == 'B' ) + IF( PPP_MODE_E == 'B' ) { hSC_VBR->bump_up = 1; move16(); @@ -1184,10 +1131,12 @@ ivas_error ppp_voiced_encoder_fx( IF( hSC_VBR->Q_to_F ) { hSC_VBR->patterncount = add( hSC_VBR->patterncount, hSC_VBR->pattern_m ); + move16(); IF( GE_16( hSC_VBR->patterncount, 1000 ) ) { hSC_VBR->patterncount = sub( hSC_VBR->patterncount, 1000 ); + move16(); PPP_MODE_E = 'B'; move16(); hSC_VBR->bump_up = 1; @@ -1216,8 +1165,9 @@ ivas_error ppp_voiced_encoder_fx( DTFS_copy_fx( dtfs_temp_fx, *CURRP_Q_E_FX ); Lacc = DTFS_getEngy_P2A_fx( CURRP_NQ_FX ); + move32(); hSC_VBR->Q_prev_cw_en_fx = norm_l( Lacc ); - + move16(); /* hSC_VBR->Q_prev_cw_en_fx = (Lacc==0)?31: hSC_VBR->Q_prev_cw_en_fx;move16(); */ if ( Lacc == 0 ) { @@ -1226,7 +1176,9 @@ ivas_error ppp_voiced_encoder_fx( } hSC_VBR->prev_cw_en_fx = (Word32) L_shl( Lacc, hSC_VBR->Q_prev_cw_en_fx ); /*2Q+Q_prev_cw_en_fx */ + move32(); hSC_VBR->Q_prev_cw_en_fx = add( hSC_VBR->Q_prev_cw_en_fx, shl( CURRP_NQ_FX->Q, 1 ) ); + move16(); /* Copy DTFS related parameters from 'dtfs_temp' to 'st_fx' structure */ hSC_VBR->dtfs_enc_lag = dtfs_temp_fx->lag_fx; move16(); @@ -1289,6 +1241,7 @@ static void synthesis_filter_fx( Word16 b[], Word16 x[], Word16 y[], Word16 buf[ Word16 i, j; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif FOR( i = 0; i < N; i++ ) { @@ -1298,28 +1251,18 @@ static void synthesis_filter_fx( Word16 b[], Word16 x[], Word16 y[], Word16 buf[ FOR( j = P - 1; j > 0; j-- ) { /* acc = L_sub(acc, L_mult(memory[j], coef[j])); */ -#ifdef BASOP_NOGLOB acc = L_msu_o( acc, buf[j], b[j], &Overflow ); /*Q13 */ -#else - acc = L_msu( acc, buf[j], b[j] ); /*Q13 */ -#endif buf[j] = buf[j - 1]; move16(); } /* acc = L_sub(acc, L_mult(memory[0], coef[0])); */ -#ifdef BASOP_NOGLOB acc = L_msu_o( acc, buf[0], b[0], &Overflow ); acc = L_shl_o( acc, 3, &Overflow ); *y++ = round_fx_o( acc, &Overflow ); + move16(); buf[0] = round_fx_o( acc, &Overflow ); -#else - acc = L_msu( acc, buf[0], b[0] ); - acc = L_shl( acc, 3 ); - - *y++ = round_fx( acc ); - buf[0] = round_fx( acc ); -#endif + move16(); } } /*==============================================================================*/ @@ -1364,6 +1307,7 @@ static Word32 DTFS_freq_corr_fx( Word16 Q_num, Q_den; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif IF( LT_16( X1_DTFS_fx.lag_fx, X2_DTFS_fx.lag_fx ) ) { @@ -1372,15 +1316,15 @@ static Word32 DTFS_freq_corr_fx( corr_fx = L_deposit_l( 0 ); - L_lband = L_mult( lband, X2_DTFS_fx.lag_fx ); - L_hband = L_mult( hband, X2_DTFS_fx.lag_fx ); + L_lband = L_mult( lband, X2_DTFS_fx.lag_fx ); /* Q0 * Q0 -> Q1 */ + L_hband = L_mult( hband, X2_DTFS_fx.lag_fx ); /* Q0 * Q0 -> Q1 */ HalfLag = s_min( shr( X2_DTFS_fx.lag_fx, 1 ), X2_DTFS_fx.nH_4kHz_fx ); /* get lband and hband */ FOR( k = 0; k <= HalfLag; k++ ) { freq_fx = L_mult( k, 12800 ); - IF( GE_32( freq_fx, L_lband ) ) + if ( GE_32( freq_fx, L_lband ) ) { BREAK; } @@ -1389,7 +1333,7 @@ static Word32 DTFS_freq_corr_fx( FOR( k = 0; k <= HalfLag; k++ ) { freq_fx = L_mult( k, 12800 ); - IF( GE_32( freq_fx, L_hband ) ) + if ( GE_32( freq_fx, L_hband ) ) { BREAK; } @@ -1399,13 +1343,8 @@ static Word32 DTFS_freq_corr_fx( FOR( k = lk; k < hk; k++ ) { -#ifdef BASOP_NOGLOB corr_fx = L_mac0_o( corr_fx, X1_DTFS_fx.a_fx[k], X2_DTFS_fx.a_fx[k], &Overflow ); /* Q(1) */ corr_fx = L_mac0_o( corr_fx, X1_DTFS_fx.b_fx[k], X2_DTFS_fx.b_fx[k], &Overflow ); /* Q(1) */ -#else - corr_fx = L_mac0( corr_fx, X1_DTFS_fx.a_fx[k], X2_DTFS_fx.a_fx[k] ); /* Q(1) */ - corr_fx = L_mac0( corr_fx, X1_DTFS_fx.b_fx[k], X2_DTFS_fx.b_fx[k] ); /* Q(1) */ -#endif } Qr = norm_l( corr_fx ); @@ -1415,16 +1354,13 @@ static Word32 DTFS_freq_corr_fx( move16(); } -#ifdef BASOP_NOGLOB E1_fx = round_fx_o( L_shl_o( corr_fx, Qr, &Overflow ), &Overflow ); /* Q(Qr-16) */ -#else - E1_fx = round_fx( L_shl( corr_fx, Qr ) ); /* Q(Qr-16) */ -#endif - Num = L_mult0( E1_fx, E1_fx ); /* Q(2+2*Qr-32+1) */ + Num = L_mult0( E1_fx, E1_fx ); /* Q(2+2*Qr-32+1) */ Q_num = sub( shl( add( add( X1_DTFS_fx.Q, X2_DTFS_fx.Q ), Qr ), 1 ), 32 ); /* PORTING: Handling the functions with variable no. of arguments */ E_fx = DTFS_getEngy_band_fx( X1_DTFS_fx, lband, hband ); /* Q(1) */ + move32(); q1 = norm_l( E_fx ); if ( E_fx == 0 ) { @@ -1432,11 +1368,7 @@ static Word32 DTFS_freq_corr_fx( move16(); } -#ifdef BASOP_NOGLOB E1_fx = round_fx_o( L_shl_o( E_fx, q1, &Overflow ), &Overflow ); /* Q(1+q1-16) */ -#else - E1_fx = round_fx( L_shl( E_fx, q1 ) ); /* Q(1+q1-16) */ -#endif /* PORTING: Handling the functions with variable no. of arguments */ E_fx = DTFS_getEngy_band_fx( X2_DTFS_fx, lband, hband ); /* Q(1) */ q2 = norm_l( E_fx ); @@ -1446,12 +1378,8 @@ static Word32 DTFS_freq_corr_fx( move16(); } -#ifdef BASOP_NOGLOB E2_fx = round_fx_o( L_shl_o( E_fx, q2, &Overflow ), &Overflow ); /* Q(1+q2-16) */ -#else - E2_fx = round_fx( L_shl( E_fx, q2 ) ); /* Q(1+q2-16) */ -#endif - Den = L_mult0( E1_fx, E2_fx ); /* Q(2+q1+q2-32+1) */ + Den = L_mult0( E1_fx, E2_fx ); /* Q(2+q1+q2-32+1) */ Q_den = sub( add( shl( add( X2_DTFS_fx.Q, X1_DTFS_fx.Q ), 1 ), add( q1, q2 ) ), 32 ); Num = L_max( Num, 1 ); @@ -1459,35 +1387,25 @@ static Word32 DTFS_freq_corr_fx( IF( Num == 0 ) { Result = 0; + move32(); *Qout = 31; + move16(); } ELSE { expa = norm_l( Num ); -#ifdef BASOP_NOGLOB fraca = extract_h( L_shl_o( Num, expa, &Overflow ) ); -#else - fraca = extract_h( L_shl( Num, expa ) ); -#endif expa = sub( 30, add( expa, Q_num ) ); expb = norm_l( Den ); -#ifdef BASOP_NOGLOB fracb = round_fx_o( L_shl_o( Den, expb, &Overflow ), &Overflow ); -#else - fracb = round_fx( L_shl( Den, expb ) ); -#endif expb = sub( 30, add( expb, Q_den ) ); scale = shr( sub( fraca, fracb ), 15 ); -#ifdef BASOP_NOGLOB fracb = shl_o( fracb, scale, &Overflow ); -#else - fracb = shl( fracb, scale ); -#endif expb = sub( expb, scale ); tmp = div_s( fracb, fraca ); @@ -1503,6 +1421,7 @@ static Word32 DTFS_freq_corr_fx( Result = L_negate( L_tmp ); } *Qout = sub( 30, exp ); + move16(); } return Result; } @@ -1532,6 +1451,7 @@ static Word16 DTFS_alignment_extract_td_fx( Word16 *x1, Word16 *x2, Word16 lag ) Word32 maxcorr, corr; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif maxcorr = L_add( MIN_32, 0 ); Adiff_fx = (Word16) ( s_max( 4, shr( lag, 3 ) ) ); @@ -1543,13 +1463,9 @@ static Word16 DTFS_alignment_extract_td_fx( Word16 *x1, Word16 *x2, Word16 lag ) corr = L_deposit_l( 0 ); FOR( k = 0; k < lag; k++ ) { -#ifdef BASOP_NOGLOB corr = L_mac_o( corr, x1[k], x2[( k - j + lag ) % lag], &Overflow ); -#else - corr = L_mac( corr, x1[k], x2[( k - j + lag ) % lag] ); -#endif } - if ( GT_32( corr, maxcorr ) ) + IF( GT_32( corr, maxcorr ) ) { idx = j; move16(); @@ -1589,17 +1505,19 @@ static Word32 DTFS_getEngy_band_fx( Word16 k, lk, hk, HalfLag; Word32 freq_fx, L_lband, L_hband; Word32 en_fx = 0; + move32(); #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif - L_lband = L_mult( lband, X_fx.lag_fx ); - L_hband = L_mult( hband, X_fx.lag_fx ); + L_lband = L_mult( lband, X_fx.lag_fx ); /* Q0 * Q0 -> Q1 */ + L_hband = L_mult( hband, X_fx.lag_fx ); /* Q0 * Q0 -> Q1 */ HalfLag = s_min( shr( sub( X_fx.lag_fx, 1 ), 1 ), X_fx.nH_4kHz_fx ); /* get lband and hband */ FOR( k = 1; k <= HalfLag; k++ ) { freq_fx = L_mult( k, 12800 ); - IF( GE_32( freq_fx, L_lband ) ) + if ( GE_32( freq_fx, L_lband ) ) { BREAK; } @@ -1609,7 +1527,7 @@ static Word32 DTFS_getEngy_band_fx( FOR( k = 1; k <= HalfLag; k++ ) { freq_fx = L_mult( k, 12800 ); - IF( GE_32( freq_fx, L_hband ) ) + if ( GE_32( freq_fx, L_hband ) ) { BREAK; } @@ -1619,13 +1537,8 @@ static Word32 DTFS_getEngy_band_fx( FOR( k = lk; k < hk; k++ ) { -#ifdef BASOP_NOGLOB en_fx = L_mac0_o( en_fx, X_fx.a_fx[k], X_fx.a_fx[k], &Overflow ); /* 2*X1.Q+1 */ en_fx = L_mac0_o( en_fx, X_fx.b_fx[k], X_fx.b_fx[k], &Overflow ); -#else - en_fx = L_mac0( en_fx, X_fx.a_fx[k], X_fx.a_fx[k] ); /* 2*X1.Q+1 */ - en_fx = L_mac0( en_fx, X_fx.b_fx[k], X_fx.b_fx[k] ); -#endif } if ( lband == 0 ) @@ -1637,13 +1550,8 @@ static Word32 DTFS_getEngy_band_fx( test(); IF( ( s_and( X_fx.lag_fx, 1 ) == 0 ) && ( hband == X_fx.upper_cut_off_freq_fx ) ) { -#ifdef BASOP_NOGLOB en_fx = L_mac0_o( en_fx, X_fx.a_fx[k], X_fx.a_fx[k], &Overflow ); en_fx = L_mac0_o( en_fx, X_fx.b_fx[k], X_fx.b_fx[k], &Overflow ); -#else - en_fx = L_mac0( en_fx, X_fx.a_fx[k], X_fx.a_fx[k] ); - en_fx = L_mac0( en_fx, X_fx.b_fx[k], X_fx.b_fx[k] ); -#endif } return en_fx; /* 2*X1.Q */ @@ -1688,10 +1596,13 @@ void sc_vbr_enc_init_fx( hSC_VBR->Q_to_F = 0; move16(); - hSC_VBR->numactive = 0; /* keep the count of the frames inside current 600 frame bloack.*/ - hSC_VBR->sum_of_rates_fx = 0; /* sum of the rates of past 600 active frames*/ + hSC_VBR->numactive = 0; /* keep the count of the frames inside current 600 frame bloack.*/ + move16(); + hSC_VBR->sum_of_rates_fx = 0; /* sum of the rates of past 600 active frames*/ + move32(); hSC_VBR->global_avr_rate_fx = 0; /* global rate upto current time. recorded a (rate in kbps) *6000*/ - hSC_VBR->global_frame_cnt = 0; /* 600 active frame block count. Used to update the global rate*/ + move32(); + hSC_VBR->global_frame_cnt = 0; /* 600 active frame block count. Used to update the global rate*/ move16(); hSC_VBR->rate_control = 0; move16(); @@ -1703,10 +1614,11 @@ void sc_vbr_enc_init_fx( hSC_VBR->vbr_generic_ho = 0; move16(); hSC_VBR->Local_VAD = 0; - + move16(); hSC_VBR->Last_Resort = 0; + move16(); hSC_VBR->set_ppp_generic = 0; - + move16(); hSC_VBR->last_7k2_coder_type = GENERIC; move16(); diff --git a/lib_enc/waveadjust_fec_cod.c b/lib_enc/waveadjust_fec_cod.c deleted file mode 100644 index 825401325748d89d4db5894372ff8dd2e53d76ec..0000000000000000000000000000000000000000 --- a/lib_enc/waveadjust_fec_cod.c +++ /dev/null @@ -1,41 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "prot.h" -#include "wmc_auto.h" diff --git a/lib_enc/waveadjust_fec_cod_fx.c b/lib_enc/waveadjust_fec_cod_fx.c index 378898522fefbf0ed6ee27e78f76e00a9e7db40a..f10a1bd0b2d1fff339dc2c8f93ef7ffdbbee9067 100644 --- a/lib_enc/waveadjust_fec_cod_fx.c +++ b/lib_enc/waveadjust_fec_cod_fx.c @@ -18,7 +18,10 @@ * *--------------------------------------------------------------------*/ -Word32 SFM_Cal_fx( Word32 magn[], Word16 n ) +Word32 SFM_Cal_fx( + Word32 magn[], /*Q = Qx*/ + Word16 n /*Q = Q0*/ +) { /* Counted Dymamic RAM: 16 words */ Word32 logCurFlatness; @@ -38,11 +41,7 @@ Word32 SFM_Cal_fx( Word32 magn[], Word16 n ) /* sum(log2(magn(i))) */ sumLogMagn = L_add( sumLogMagn, logMagn ); /* Q8 */ -#ifdef BASOP_NOGLOB - sumMagn = L_add_sat( sumMagn, magn_abs ); -#else - sumMagn = L_add( sumMagn, magn_abs ); -#endif + sumMagn = L_add_sat( sumMagn, magn_abs ); /*Qx*/ } IF( EQ_32( sumMagn, MAX_32 ) ) @@ -50,7 +49,7 @@ Word32 SFM_Cal_fx( Word32 magn[], Word16 n ) sumMagn = L_deposit_l( 0 ); FOR( i = 0; i < n; i++ ) { - magn_abs = L_shr( L_abs( magn[i] ), 8 ); + magn_abs = L_shr( L_abs( magn[i] ), 8 ); /* Qx-8 */ sumMagn = L_add( sumMagn, magn_abs ); } /* log2(sumMagn) */ @@ -78,7 +77,6 @@ Word32 SFM_Cal_fx( Word32 magn[], Word16 n ) logCurFlatness = L_deposit_l( div_l( L_shl( logMagn, 1 ), n ) ); frac = L_and( logCurFlatness, 0xFF ); norm_value = (Word16) L_shr( logCurFlatness, 8 ); - move16(); logCurFlatness = L_sub( kExp2TableFrac_x[frac], 33 ); logCurFlatness = L_shl( logCurFlatness, sub( 16, norm_value ) ); /* Q31 */ diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index d8cfec1d133dbcce6d623e7edda4b0229afb9811..12bc769faa915450e227b7617e096ec64e13cbca 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -1854,8 +1854,8 @@ static ivas_error ivas_rend_crendConvolver( FOR( k = 0; k < pCrend->hHrtfCrend->pIndex_frequency_max[i][j][m]; k++ ) { - tmp_out_re[k] = L_add( L_shl( Msub_32_32( Mpy_32_32( pFreq_buf_re[k], pFreq_filt_re[k] ), pFreq_buf_im[k], pFreq_filt_im[k] ), 2 ), tmp_out_re[k] ); // Qx - tmp_out_im[k] = L_add( L_shl( Madd_32_32( Mpy_32_32( pFreq_buf_re[k], pFreq_filt_im[k] ), pFreq_buf_im[k], pFreq_filt_re[k] ), 2 ), tmp_out_im[k] ); // Qx + tmp_out_re[k] = L_add( Msub_32_32( Mpy_32_32( pFreq_buf_re[k], pFreq_filt_re[k] ), pFreq_buf_im[k], pFreq_filt_im[k] ), tmp_out_re[k] ); // Qx - 2 + tmp_out_im[k] = L_add( Madd_32_32( Mpy_32_32( pFreq_buf_re[k], pFreq_filt_im[k] ), pFreq_buf_im[k], pFreq_filt_re[k] ), tmp_out_im[k] ); // Qx - 2 move32(); move32(); } @@ -1879,8 +1879,8 @@ static ivas_error ivas_rend_crendConvolver( pFreq_filt_im = &pCrend->hHrtfCrend->pOut_to_bin_diffuse_im_fx[j][offset]; // Q31 FOR( k = 0; k < pCrend->hHrtfCrend->pIndex_frequency_max_diffuse[j][m]; k++ ) { - tmp_out_re[k] = L_add( Msub_32_32( Mpy_32_32( pFreq_buf_re[k], pFreq_filt_re[k] ), pFreq_buf_im[k], pFreq_filt_im[k] ), tmp_out_re[k] ); // Qx - tmp_out_im[k] = L_add( Madd_32_32( Mpy_32_32( pFreq_buf_re[k], pFreq_filt_im[k] ), pFreq_buf_im[k], pFreq_filt_re[k] ), tmp_out_im[k] ); // Qx + tmp_out_re[k] = L_add( L_shr( Msub_32_32( Mpy_32_32( pFreq_buf_re[k], pFreq_filt_re[k] ), pFreq_buf_im[k], pFreq_filt_im[k] ), 2 ), tmp_out_re[k] ); // Qx - 2 + tmp_out_im[k] = L_add( L_shr( Madd_32_32( Mpy_32_32( pFreq_buf_re[k], pFreq_filt_im[k] ), pFreq_buf_im[k], pFreq_filt_re[k] ), 2 ), tmp_out_im[k] ); // Qx - 2 move32(); move32(); } @@ -1888,7 +1888,7 @@ static ivas_error ivas_rend_crendConvolver( } ivas_imdft_fx( tmp_out_re, tmp_out_im, pOut, subframe_length ); - + scale_sig32( pOut, shl( subframe_length, 1 ), 2 ); #ifdef DEBUGGING dbgwrite_txt( (const float *) pOut, subframe_length << 1, "Fixed_imdft_out.txt", NULL ); #endif diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 204ba19967d227778b32b82e54fda3d659f163be..71ecb5106be77e0f5381dd721bc665b3790c51d9 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -31,9 +31,9 @@ *******************************************************************************************************/ #include +#include "options.h" #include #include -#include "options.h" #include "prot.h" #include "prot_fx.h" #include "ivas_prot.h" @@ -72,9 +72,13 @@ Word16 slot_fx[4] = { 32767, 16384, 10922, 8192 }; #define LOG_10_BASE_2_Q29 1783446528 // Q29 #define TAN_30_FX 17157 // Q15 #define INV_TAN30_FX 28377 // Q14 -#define EPSILON_MANT 1180591621 /* 1e-12 in Q70 */ +#define EPSILON_MANT 1180591621 /* 1e-12 = 0.5497558*(2^-39) in Q70 */ #define EPSILON_EXP ( -39 ) -#define ADAPT_HTPROTO_ROT_LIM_1 0.8f +#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 MAX_GAIN_CACHE_SIZE ( ( MASA_MAXIMUM_DIRECTIONS * 3 ) + MAX_NUM_OBJECTS ) /* == different calls to get gains */ @@ -126,7 +130,20 @@ static void formulate2x2MixingMatrix_fx( Word32 Ein1_fx /*q_Ein*/, Word32 Ein2_f static void matrixMul_fx( Word32 Are[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_A*/, Word32 Aim[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_A*/, Word16 *q_A, Word32 Bre[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_B*/, Word32 Bim[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_B*/, Word16 *q_B, Word32 outRe[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_out*/, Word32 outIm[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_out*/, Word16 *q_out ); -static void matrixTransp2Mul_fx( Word32 Are[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_A*/, Word32 Aim[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_A*/, Word16 *q_A, Word32 Bre[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_B*/, Word32 Bim[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_B*/, Word16 *q_B, Word32 outRe[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_out*/, Word32 outIm[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_out*/, Word16 *q_out ); +static void matrixTransp2Mul_fx( + Word32 Are[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_A*/, + Word32 Aim[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_A*/, + Word16 *q_A, + 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 + int Ascale, + int Bscale, +#endif + Word32 outRe[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_out*/, + Word32 outIm[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_out*/, + Word16 *q_out ); /*------------------------------------------------------------------------- * ivas_dirac_dec_init_binaural_data() @@ -798,8 +815,30 @@ 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(); + + Copy_Scale_sig32( &( st_ivas->hTcBuffer->tc_fx[ch][nBins * slot + offsetSamples] ), tmp_arr, 60, -1 ); + scale_sig32( st_ivas->cldfbAnaDec[ch]->cldfb_state_fx, sub( st_ivas->cldfbAnaDec[ch]->p_filter_length, st_ivas->cldfbAnaDec[ch]->no_channels ), sub( sub( q_input, 1 ), st_ivas->cldfbAnaDec[ch]->Q_cldfb_state ) ); + st_ivas->cldfbAnaDec[ch]->Q_cldfb_state = sub( q_input, 1 ); + move16(); + + cldfbAnalysis_ts_fx_fixed_q( + tmp_arr, + Cldfb_RealBuffer_in_fx[ch][slot], + Cldfb_ImagBuffer_in_fx[ch][slot], + nBins, st_ivas->cldfbAnaDec[ch], &q_cldfb[ch][slot] ); + + 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( @@ -807,6 +846,8 @@ static void ivas_dirac_dec_binaural_internal_fx( 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(); IF( EQ_16( config_data.nchan_transport, 1 ) && @@ -847,6 +888,10 @@ 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 } } @@ -878,8 +923,7 @@ static void ivas_dirac_dec_binaural_internal_fx( } test(); - ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matrices_fx( hDiracDecBin, hSpatParamRendCom, &config_data, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, Rmat_fx, subframe, - hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] > 0, st_ivas->hMasaIsmData, q_inp ); + ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matrices_fx( hDiracDecBin, hSpatParamRendCom, &config_data, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, Rmat_fx, subframe, hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] > 0, st_ivas->hMasaIsmData, q_inp ); IF( EQ_32( config_data.ivas_format, ISM_FORMAT ) ) { @@ -917,8 +961,7 @@ static void ivas_dirac_dec_binaural_internal_fx( move16(); } - ivas_dirac_dec_binaural_determine_processing_matrices_fx( hDiracDecBin, hSpatParamRendCom, &config_data, max_band_decorr, Rmat_fx, subframe, - hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] > 0, nchanSeparateChannels, st_ivas->hMasaIsmData ); + ivas_dirac_dec_binaural_determine_processing_matrices_fx( hDiracDecBin, hSpatParamRendCom, &config_data, max_band_decorr, Rmat_fx, subframe, hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] > 0, nchanSeparateChannels, st_ivas->hMasaIsmData ); q_inp = Q6; move16(); @@ -1940,7 +1983,13 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices_fx( /* Make matrix multiplication M*Cx*M' to determine resulting covariance matrix of processing input with M */ 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, resultMtxRe_fx, resultMtxIm_fx, &q_res ); + 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 * residual (or missing) signal component. The procedure is active when there are not enough independent @@ -3278,10 +3327,17 @@ static void eig2x2_fx( tmp3 = BASOP_Util_Add_Mant32Exp( tmp2, sub( 31, q_tmp2 ), epsilon_mant, epsilon_exp, &exp_tmp3 ); +#if 1 tmp2 = BASOP_Util_Divide3232_Scale_cadence( ONE_IN_Q30, tmp3, &exp ); exp = sub( exp, sub( Q30, sub( 31, exp_tmp3 ) ) ); normVal_fx = Sqrt32( tmp2, &exp ); // q_tmp2 q_tmp2 = sub( 31, exp ); +#else + /* Note: This code part does not work yet, see pipeline issue for BASOP #1009 */ + /* although the same code works at other places: mantissa and q_format is fine */ + normVal_fx = ISqrt32( tmp3, &exp ); + q_tmp2 = sub( 31, exp ); +#endif IF( LT_16( q_tmp1, q_c ) ) { @@ -3347,10 +3403,17 @@ static void eig2x2_fx( tmp3 = BASOP_Util_Add_Mant32Exp( tmp2, sub( 31, q_tmp2 ), epsilon_mant, epsilon_exp, &exp_tmp3 ); +#if 1 tmp2 = BASOP_Util_Divide3232_Scale_cadence( ONE_IN_Q30, tmp3, &exp ); exp = sub( exp, sub( Q30, sub( 31, exp_tmp3 ) ) ); normVal_fx = Sqrt32( tmp2, &exp ); // q_tmp2 q_tmp2 = sub( 31, exp ); +#else + /* Note: This code part does not work yet, see pipeline issue for BASOP #1009 */ + /* although the same code works at other places: mantissa and q_format is fine */ + normVal_fx = ISqrt32( tmp3, &exp_tmp3 ); + q_tmp2 = sub( 31, exp_tmp3 ); +#endif IF( LT_16( q_tmp1, q_c ) ) { @@ -3405,9 +3468,13 @@ static void eig2x2_fx( } IF( q_U_1 != 0 ) - *q_U = q_U_1; + { + *q_U = q_U_1; + } ELSE + { *q_U = q_U_2; + } move16(); return; @@ -3463,8 +3530,10 @@ 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 ); @@ -3493,6 +3562,18 @@ static void matrixMul_fx( move32(); 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] ), + Aim_fx[chA][1], Bim_fx[1][chB] ); + move32(); + outIm_fx[chA][chB] = Madd_32_32( Madd_32_32( Madd_32_32( Mpy_32_32( Aim_fx[chA][0], Bre_fx[0][chB] ), + Aim_fx[chA][1], Bre_fx[1][chB] ), + Are_fx[chA][0], Bim_fx[0][chB] ), + Are_fx[chA][1], Bim_fx[1][chB] ); + move32(); #else test(); test(); @@ -3592,6 +3673,7 @@ static void matrixMul_fx( } outIm_fx[chA][chB] = L_add( outIm_fx[chA][chB], L_add( tmp1, tmp2 ) ); move32(); +#endif #endif /* #ifdef IVAS_ENH64_CADENCE_CHANGES */ } } @@ -3620,12 +3702,26 @@ 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] ), + Aim_fx[1][chA], Bim_fx[1][chB] ); + move32(); + outIm_fx[chA][chB] = Msub_32_32( Msub_32_32( Madd_32_32( Mpy_32_32( Are_fx[0][chA], Bim_fx[0][chB] ), + Are_fx[1][chA], Bim_fx[1][chB] ), + Aim_fx[0][chA], Bre_fx[0][chB] ), + Aim_fx[1][chA], Bre_fx[1][chB] ); + move32(); +#else test(); test(); test(); @@ -3692,6 +3788,7 @@ static void matrixTransp1Mul_fx( 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 ); @@ -3713,6 +3810,10 @@ 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 + int Ascale, + int Bscale, +#endif Word32 outRe_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_out*/ Word32 outIm_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_out*/ Word16 *q_out ) @@ -3720,20 +3821,33 @@ 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 - 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 ); - scale_sig32( Aim_fx[0], size, min_q_shift ); - *q_A = add( *q_A, min_q_shift ); - move16(); - 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 ); - scale_sig32( Bim_fx[0], size, min_q_shift ); - *q_B = add( *q_B, min_q_shift ); - move16(); +#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 ); + scale_sig32( Aim_fx[0], size, min_q_shift ); + *q_A = add( *q_A, min_q_shift ); + 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 ); + scale_sig32( Bim_fx[0], size, min_q_shift ); + *q_B = add( *q_B, min_q_shift ); + move16(); + } FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) { @@ -3748,6 +3862,18 @@ static void matrixTransp2Mul_fx( move32(); 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] ), + Aim_fx[chA][1], Bim_fx[chB][1] ); + move32(); + outIm_fx[chA][chB] = Msub_32_32( Msub_32_32( Madd_32_32( Mpy_32_32( Aim_fx[chA][0], Bre_fx[chB][0] ), + Aim_fx[chA][1], Bre_fx[chB][1] ), + Are_fx[chA][0], Bim_fx[chB][0] ), + Are_fx[chA][1], Bim_fx[chB][1] ); + move32(); #else test(); test(); @@ -3816,6 +3942,7 @@ static void matrixTransp2Mul_fx( 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 */ } } @@ -3890,6 +4017,7 @@ 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 ) ); @@ -3897,6 +4025,33 @@ static void chol2x2_fx( 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; + + /* Compute denom = 1.0 / outRe[0][0] */ + denom = ISqrt32( outRe[0][0], &exp ); + denom = Mpy_32_32( denom, denom ); + den_exp = shl( exp, 1 ); + + /* Normalise c_re, c_im */ + exp = norm_l( c_re ); + my_outRe = L_shl( c_re, exp ); + q_re2 = add( q_c, exp ); + exp = norm_l( c_im ); + my_outIm = L_shl( c_im, exp ); + q_im = add( q_c, exp ); + + /* Multiply and store c_re*denom and c_im*denom */ + outRe[1][0] = Mpy_32_32( denom, my_outRe ); + move32(); + q_re2 = sub( q_re2, den_exp ); + + outIm[1][0] = Mpy_32_32( denom, my_outIm ); + move32(); + q_im = sub( q_im, den_exp ); +#endif } if ( outRe[1][0] == 0 ) { @@ -3915,8 +4070,16 @@ 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 { @@ -3965,6 +4128,7 @@ 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 ) ); @@ -3972,9 +4136,25 @@ static void chol2x2_fx( 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; + + outRe[0][1] = Mpy_32_32( tmp1, c_re ); + move32(); + q_re2 = add( sub( 31, exp ), sub( q_c, 62 ) ); + + // outIm[0][1] = BASOP_Util_Divide3232_Scale_cadence( -c_im, 4611686, &exp ); + 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 ) ); @@ -3982,6 +4162,20 @@ static void chol2x2_fx( 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 ); + outRe[0][1] = Mpy_32_32( tmp1, c_re ); + 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 ); + outIm[0][1] = Mpy_32_32( tmp1, -c_im ); + move32(); + q_im = add( sub( 31, exp ), sub( q_c, q_re1 ) ); + } +#endif } if ( outRe[0][1] == 0 ) { @@ -4146,8 +4340,15 @@ 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 { @@ -4207,8 +4408,24 @@ static void formulate2x2MixingMatrix_fx( IF( temp == 0 ) { - BASOP_Util_Divide3232_Scale_cadence( E_out1, 4611686, &exp ); // 4611686 = Q62 +#ifdef FIX_1009_REPLACE_DIV_SQRT_BY_ISQRT_LC + IF( E_out1 == 0 ) + { + Ghat_fx[0] = 0; + exp = -19; + move32(); + move16(); + } + ELSE + { + temp = BASOP_Util_Divide3232_Scale_cadence( E_out1, 4611686, &exp ); // 4611686 = Q62 + 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 { @@ -4216,16 +4433,36 @@ 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 ) { - BASOP_Util_Divide3232_Scale_cadence( E_out2, 4611686, &exp1 ); // 4611686 = Q62 +#ifdef FIX_1009_REPLACE_DIV_SQRT_BY_ISQRT_LC + IF( E_out2 == 0 ) + { /* We can set hard-coded results */ + Ghat_fx[1] = 0; + exp1 = -19; + move16(); + } + ELSE + { + temp = BASOP_Util_Divide3232_Scale_cadence( E_out2, 4611686, &exp1 ); // 4611686 = Q62 + 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 { @@ -4233,8 +4470,13 @@ 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 ) ); @@ -4283,8 +4525,13 @@ 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 */ + exp = ONE_DIV_EPSILON_EXP; +#endif } ELSE { @@ -4296,8 +4543,13 @@ static void formulate2x2MixingMatrix_fx( 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 { @@ -4397,28 +4649,69 @@ static void formulate2x2MixingMatrix_fx( } } - matrixTransp2Mul_fx( tmpRe_fx, tmpIm_fx, &q_temp, Ure_fx, Uim_fx, &q_U, Pre_fx, Pim_fx, &q_P ); /* Nearest orthonormal matrix P to matrix A formulated */ + 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) */ +#if ( BINAURAL_CHANNELS != 2 ) FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) { FOR( chB = 0; chB < BINAURAL_CHANNELS; chB++ ) { 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 ); + + + 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] ); + Pre_fx[chA][chB] = Mpy_32_32( L_shl( Pre_fx[chA][chB], Pre_shift ), temp ); + Pim_fx[chA][chB] = Mpy_32_32( L_shl( Pim_fx[chA][chB], Pim_shift ), temp ); + 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 ) + { + q_Pre[chA][chB] = 31; + move16(); + } + if ( Pim_fx[chA][chB] == 0 ) + { + q_Pim[chA][chB] = 31; + move16(); } move32(); move32(); @@ -4426,6 +4719,72 @@ static void formulate2x2MixingMatrix_fx( move16(); } } +#else + /* BINAURAL_CHANNEL == 2 */ + FOR( chB = 0; chB < BINAURAL_CHANNELS; chB++ ) + { + IF( Sx_fx[chB] == 0 ) + { + Pre_fx[0][chB] = Mpy_32_32( Pre_fx[0][chB], ONE_DIV_EPSILON_MANT ); + q_Pre[0][chB] = sub( 62 - ONE_DIV_EPSILON_EXP, q_P ); + Pim_fx[0][chB] = Mpy_32_32( Pim_fx[0][chB], ONE_DIV_EPSILON_MANT ); + q_Pim[0][chB] = sub( 62 - ONE_DIV_EPSILON_EXP, q_P ); + Pre_fx[1][chB] = Mpy_32_32( Pre_fx[1][chB], ONE_DIV_EPSILON_MANT ); + q_Pre[1][chB] = sub( 62 - ONE_DIV_EPSILON_EXP, q_P ); + Pim_fx[1][chB] = Mpy_32_32( Pim_fx[1][chB], ONE_DIV_EPSILON_MANT ); + q_Pim[1][chB] = sub( 62 - ONE_DIV_EPSILON_EXP, q_P ); + } + ELSE + { + Word16 Pre_shift, Pim_shift; + temp = BASOP_Util_Add_Mant32Exp( Sx_fx[chB], sub( 31, q_Sx ), EPSILON_MANT, EPSILON_EXP, &exp_temp ); + temp = BASOP_Util_Divide3232_Scale_cadence( ONE_IN_Q30, temp, &exp ); + q_temp = add( sub( sub( q_P, exp ), sub( 31, Q30 ) ), exp_temp ); + + Pre_shift = norm_l( Pre_fx[0][chB] ); + Pim_shift = norm_l( Pim_fx[0][chB] ); + Pre_fx[0][chB] = Mpy_32_32( L_shl( Pre_fx[0][chB], Pre_shift ), temp ); + Pim_fx[0][chB] = Mpy_32_32( L_shl( Pim_fx[0][chB], Pim_shift ), temp ); + q_Pre[0][chB] = add( q_temp, Pre_shift ); + q_Pim[0][chB] = add( q_temp, Pim_shift ); + + Pre_shift = norm_l( Pre_fx[1][chB] ); + Pim_shift = norm_l( Pim_fx[1][chB] ); + Pre_fx[1][chB] = Mpy_32_32( L_shl( Pre_fx[1][chB], Pre_shift ), temp ); + Pim_fx[1][chB] = Mpy_32_32( L_shl( Pim_fx[1][chB], Pim_shift ), temp ); + q_Pre[1][chB] = add( q_temp, Pre_shift ); + q_Pim[1][chB] = add( q_temp, Pim_shift ); + } + if ( Pre_fx[0][chB] == 0 ) + { + q_Pre[0][chB] = 31; + move16(); + } + if ( Pim_fx[0][chB] == 0 ) + { + q_Pim[0][chB] = 31; + move16(); + } + if ( Pre_fx[1][chB] == 0 ) + { + q_Pre[1][chB] = 31; + move16(); + } + if ( Pim_fx[1][chB] == 0 ) + { + q_Pim[1][chB] = 31; + move16(); + } + move32(); + move32(); + move16(); + move16(); + move32(); + move32(); + move16(); + move16(); + } +#endif minimum_s( q_Pre[0], i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ), &exp ); q_P = s_min( q_P, exp ); minimum_s( q_Pim[0], i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ), &exp ); @@ -4444,8 +4803,12 @@ 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, Mre_fx, Mim_fx, q_M ); - + 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.c b/lib_rend/ivas_dirac_decorr_dec.c index c50d690c5b80f4812770e4aab2d6bbb26aabc62f..1788536e4ba8ad65fbf2ff9fa777eaff7972aef4 100644 --- a/lib_rend/ivas_dirac_decorr_dec.c +++ b/lib_rend/ivas_dirac_decorr_dec.c @@ -409,7 +409,7 @@ void ivas_dirac_dec_decorr_process_fx( HANDLE_DIRAC_DECORR_STATE h_freq_domain_decorr_ap_state ) { - Word16 ch_idx, k, l, idx_in_out, max_band_decorr; + Word16 ch_idx, k, l, max_band_decorr; Word16 split_bands_idx, band_idx, decorr_buffer_len, time_idx; Word16 offset, idx_filter, incr_aux; Word16 k_1, k_2, num_bands, filter_length, pre_delay, decorr_buffer_step; @@ -506,22 +506,24 @@ void ivas_dirac_dec_decorr_process_fx( set32_fx( onset_filter_fx, ONE_IN_Q31, imult1616( num_protos_diff, num_freq_bands ) ); Word16 q_temp = s_min( q_onset_dec, q_aux_buffer ); + Word16 shift_q = sub( q_onset_dec, q_temp ); - IF( NE_16( q_temp, q_onset_dec ) ) + IF( shift_q != 0 ) { - FOR( Word16 i = 0; i < imult1616( num_protos_diff, max_band_decorr_temp ); i++ ) + FOR( Word16 i = 0; i < num_protos_diff * max_band_decorr_temp; i++ ) { - h_freq_domain_decorr_ap_state->h_onset_detection_power_state.onset_detector_2_fx[i] = L_shr( h_freq_domain_decorr_ap_state->h_onset_detection_power_state.onset_detector_2_fx[i], sub( q_onset_dec, q_temp ) ); // q_temp - h_freq_domain_decorr_ap_state->h_onset_detection_power_state.onset_detector_1_fx[i] = L_shr( h_freq_domain_decorr_ap_state->h_onset_detection_power_state.onset_detector_1_fx[i], sub( q_onset_dec, q_temp ) ); // q_temp + h_freq_domain_decorr_ap_state->h_onset_detection_power_state.onset_detector_2_fx[i] = L_shr( h_freq_domain_decorr_ap_state->h_onset_detection_power_state.onset_detector_2_fx[i], shift_q ); // q_temp + h_freq_domain_decorr_ap_state->h_onset_detection_power_state.onset_detector_1_fx[i] = L_shr( h_freq_domain_decorr_ap_state->h_onset_detection_power_state.onset_detector_1_fx[i], shift_q ); // q_temp move32(); move32(); } } - IF( NE_16( q_temp, q_aux_buffer ) ) + shift_q = sub( q_aux_buffer, q_temp ); + IF( shift_q != 0 ) { - FOR( Word16 i = 0; i < shl( imult1616( num_protos_diff, max_band_decorr_temp ), 1 ); i++ ) + FOR( Word16 i = 0; i < 2 * num_protos_diff * max_band_decorr_temp; i++ ) { - aux_buffer_fx[i] = L_shr( aux_buffer_fx[i], sub( q_aux_buffer, q_temp ) ); // q_temp + aux_buffer_fx[i] = L_shr( aux_buffer_fx[i], shift_q ); // q_temp move32(); } } @@ -566,9 +568,9 @@ void ivas_dirac_dec_decorr_process_fx( /* final phase rotation */ FOR( k = 0; k < max_band_decorr; k++ ) { - *p_frame_dec_fx = L_sub( Mpy_32_16_1( ( *decorr_buffer_fx ), ( *phase_coeff_real_fx ) ), Mpy_32_16_1( ( *( decorr_buffer_fx + 1 ) ), ( *phase_coeff_imag_fx ) ) ); // sub( q_decorr_buf, 1 ) + *p_frame_dec_fx = Msub_32_16( Mpy_32_16_1( *decorr_buffer_fx, ( *phase_coeff_real_fx ) ), *( decorr_buffer_fx + 1 ), ( *phase_coeff_imag_fx ) ); // sub( q_decorr_buf, 1 ) p_frame_dec_fx++; - *p_frame_dec_fx = L_add( Mpy_32_16_1( ( *decorr_buffer_fx ), ( *phase_coeff_imag_fx ) ), Mpy_32_16_1( ( *( decorr_buffer_fx + 1 ) ), ( *phase_coeff_real_fx ) ) ); // sub( q_decorr_buf, 1 ) + *p_frame_dec_fx = Madd_32_16( Mpy_32_16_1( *decorr_buffer_fx, ( *phase_coeff_imag_fx ) ), ( *( decorr_buffer_fx + 1 ) ), ( *phase_coeff_real_fx ) ); // sub( q_decorr_buf, 1 ) p_frame_dec_fx++; phase_coeff_imag_fx++; phase_coeff_real_fx++; @@ -620,8 +622,8 @@ void ivas_dirac_dec_decorr_process_fx( #endif q_shift = getScaleFactor32( aux_buffer_fx, imult1616( imult1616( 2, num_protos_dir ), max_band_decorr_temp ) ); - - FOR( Word16 j = 0; j < shl( imult1616( num_protos_dir, max_band_decorr_temp ), 1 ); j++ ) + Word16 buf_len = shl( imult1616( num_protos_dir, max_band_decorr_temp ), 1 ); + FOR( Word16 j = 0; j < buf_len; j++ ) { aux_buffer_fx[j] = L_shl( aux_buffer_fx[j], q_shift ); // add( q_aux_buffer, q_shift ) move32(); @@ -674,8 +676,9 @@ void ivas_dirac_dec_decorr_process_fx( filter_coeff_num_real_fx = &h_freq_domain_decorr_ap_params->filter_coeff_num_real_fx[idx_filter]; // Q12 filter_coeff_den_real_fx = &h_freq_domain_decorr_ap_params->filter_coeff_den_real_fx[idx_filter]; // Q12 decorr_buffer_start_ptr_fx = &h_freq_domain_decorr_ap_state->decorr_buffer_fx[2 * ( ch_idx * max_band_decorr + band_idx )]; - input_real_fx = aux_buffer_fx[shl( add( imult1616( proto_index_dir[ch_idx], max_band_decorr ), band_idx ), 1 )]; // q_aux - input_imag_fx = aux_buffer_fx[add( shl( add( imult1616( proto_index_dir[ch_idx], max_band_decorr ), band_idx ), 1 ), 1 )]; // q_aux + Word16 idx = shl( add( imult1616( proto_index_dir[ch_idx], max_band_decorr ), band_idx ), 1 ); + input_real_fx = aux_buffer_fx[idx]; // q_aux + input_imag_fx = aux_buffer_fx[idx + 1]; // q_aux /* MA part of filter impulse response */ FOR( l = 0; l < filter_length; l++ ) @@ -766,14 +769,15 @@ void ivas_dirac_dec_decorr_process_fx( #ifdef MSAN_FIX q_shift = Q31; move16(); + offset = shl( max_band_decorr, 1 ); FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) { q_shift = s_min( q_shift, - L_norm_arr( &frame_dec_fx[shl( imult1616( ch_idx, num_freq_bands ), 1 )], shl( max_band_decorr, 1 ) ) ); + L_norm_arr( &frame_dec_fx[2 * ch_idx * num_freq_bands], offset ) ); } FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) { - Scale_sig32( &frame_dec_fx[shl( imult1616( ch_idx, num_freq_bands ), 1 )], shl( max_band_decorr, 1 ), q_shift ); + 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 ); @@ -784,13 +788,14 @@ void ivas_dirac_dec_decorr_process_fx( IF( h_freq_domain_decorr_ap_params->use_ducker ) { + Word16 len1 = shl( imult1616( max_band_decorr, num_protos_dir ), 1 ); /* compute direct power w/o onsets for the energy ratio, signal is still in the aux buffer */ - v_mult_fixed( aux_buffer_fx, aux_buffer_fx, aux_buffer_fx, shl( imult1616( max_band_decorr, num_protos_dir ), 1 ) ); // 2 *q_aux -31 + v_mult_fixed( aux_buffer_fx, aux_buffer_fx, aux_buffer_fx, len1 ); // 2 *q_aux -31 - q_aux_buffer = sub( imult1616( 2, q_aux_buffer ), 31 ); + q_aux_buffer = sub( shl( q_aux_buffer, 1 ), 31 ); // if this scaling is eliminated overflow is happening fot v_add_inc_fix - q_shift = sub( L_norm_arr( aux_buffer_fx, shl( imult1616( num_protos_dir, max_band_decorr ), 1 ) ), find_guarded_bits_fx( 2 ) ); + q_shift = sub( L_norm_arr( aux_buffer_fx, len1 ), 1 /*find_guarded_bits_fx( 2 )*/ ); Scale_sig32( aux_buffer_fx, shl( imult1616( num_protos_dir, max_band_decorr_temp ), 1 ), q_shift ); q_aux_buffer = add( q_aux_buffer, q_shift ); @@ -847,18 +852,18 @@ void ivas_dirac_dec_decorr_process_fx( } norm = W_norm( min64 ); #endif - - FOR( Word16 i = 0; i < shl( imult1616( num_channels, max_band_decorr ), 1 ); i++ ) + norm = sub( norm, 1 /*find_guarded_bits_fx( 2 )*/ ); + FOR( Word16 i = 0; i < 2 * num_channels * max_band_decorr; i++ ) { - aux_buffer_fx[i] = W_extract_h( W_shl( aux_64[i], sub( norm, find_guarded_bits_fx( 2 ) ) ) ); + aux_buffer_fx[i] = W_extract_h( W_shl( aux_64[i], norm ) ); move32(); } - q_aux_buffer = add( imult1616( 2, q_frame_f ), sub( sub( norm, 1 ), 32 ) ); + q_aux_buffer = add( shl( q_frame_f, 1 ), sub( norm, 32 ) ); FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) { - v_add_inc_fx( &aux_buffer_fx[shl( imult1616( ch_idx, max_band_decorr ), 1 )], 2, &aux_buffer_fx[add( shl( imult1616( ch_idx, max_band_decorr ), 1 ), 1 )], 2, &aux_buffer_fx[imult1616( ch_idx, max_band_decorr )], 1, max_band_decorr ); + v_add_inc_fx( &aux_buffer_fx[2 * ch_idx * max_band_decorr], 2, &aux_buffer_fx[2 * ch_idx * max_band_decorr + 1], 2, &aux_buffer_fx[ch_idx * max_band_decorr], 1, max_band_decorr ); } /* smooth energies */ @@ -959,7 +964,7 @@ void ivas_dirac_dec_decorr_process_fx( FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) { q_shift = s_min( q_shift, - sub( L_norm_arr( &frame_dec_fx[shl( imult1616( ch_idx, num_freq_bands ), 1 )], shl( max_band_decorr, 1 ) ), + sub( L_norm_arr( &frame_dec_fx[2 * ch_idx * num_freq_bands], shl( max_band_decorr, 1 ) ), Q2 ) ); } FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) @@ -974,7 +979,7 @@ void ivas_dirac_dec_decorr_process_fx( FOR( ch_idx = 0; ch_idx < num_channels; ch_idx++ ) { - Word32 *frame_dec_fx_ptr = &frame_dec_fx[shl( imult1616( ch_idx, num_freq_bands ), 1 )]; + Word32 *frame_dec_fx_ptr = &frame_dec_fx[2 * ch_idx * num_freq_bands]; Word16 cur_proto_index = imult1616( proto_index_dir[ch_idx], max_band_decorr ); Word16 cur_reverb_index = imult1616( ch_idx, max_band_decorr ); Word32 *reverb_energy_smooth_ptr = &h_freq_domain_decorr_ap_state->reverb_energy_smooth_fx[cur_reverb_index]; // q_aux @@ -1020,22 +1025,18 @@ void ivas_dirac_dec_decorr_process_fx( e_duck_gain = add( e_duck_gain, sub( e_direct_energy_smooth, add( e_reverb_energy_smooth, 1 ) ) ); duck_gain = Sqrt16( duck_gain, &e_duck_gain ); - Word16 comp_flag = BASOP_Util_Cmp_Mant32Exp( duck_gain, e_duck_gain, 16384, 2 ); - IF( EQ_16( comp_flag, 1 ) ) - { - duck_gain = 16384; // 2inQ13 - move16(); - } - ELSE + /* if ( duck_gain > 2.0f ) { - duck_gain = shl( duck_gain, sub( e_duck_gain, 2 ) ); // Q13 - } + duck_gain = 2.0f; + } */ + 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 ), 2 ); // 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 ), 2 ); // q_frame_dec + 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(); @@ -1055,7 +1056,7 @@ void ivas_dirac_dec_decorr_process_fx( Word16 sf = MAX_16; FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) { - sf = s_min( sf, getScaleFactor32( &frame_dec_fx[shl( imult1616( ch_idx, num_freq_bands ), 1 )], shl( max_band_decorr, 1 ) ) ); + sf = s_min( sf, getScaleFactor32( &frame_dec_fx[2 * ch_idx * num_freq_bands], shl( max_band_decorr, 1 ) ) ); } sf = s_min( sub( sf, 1 ), q_shift ); q_if_local = sub( q_shift, sf ); @@ -1065,7 +1066,7 @@ void ivas_dirac_dec_decorr_process_fx( #ifdef MSAN_FIX FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) { - scale_sig32( &frame_dec_fx[shl( imult1616( ch_idx, num_freq_bands ), 1 )], shl( max_band_decorr, 1 ), q_shift ); + 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 @@ -1078,7 +1079,7 @@ void ivas_dirac_dec_decorr_process_fx( #ifdef MSAN_FIX FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) { - scale_sig32( &frame_dec_fx[shl( imult1616( ch_idx, num_freq_bands ), 1 )], shl( max_band_decorr, 1 ), q_shift ); + 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 @@ -1098,24 +1099,22 @@ void ivas_dirac_dec_decorr_process_fx( FOR( k = 0; k < max_band_decorr; ++k ) { - aux_buffer_fx[2 * k] = Mpy_32_32( L_shr_r( input_frame_fx[add( shl( offset, 1 ), shl( k, 1 ) )], q_if_local ), L_sub( ONE_IN_Q31, onset_filter_fx[add( offset, k )] ) ); - aux_buffer_fx[add( shl( k, 1 ), 1 )] = Mpy_32_32( L_shr_r( input_frame_fx[add( add( shl( offset, 1 ), shl( k, 1 ) ), 1 )], q_if_local ), L_sub( ONE_IN_Q31, onset_filter_fx[add( offset, k )] ) ); // q_frame_f + aux_buffer_fx[2 * k] = Mpy_32_32( L_shr_r( input_frame_fx[2 * ( offset + k )], q_if_local ), L_sub( ONE_IN_Q31, onset_filter_fx[offset + k] ) ); + aux_buffer_fx[add( shl( k, 1 ), 1 )] = Mpy_32_32( L_shr_r( input_frame_fx[2 * ( offset + k ) + 1], q_if_local ), L_sub( ONE_IN_Q31, onset_filter_fx[offset + k] ) ); // q_frame_f move32(); move32(); } - v_add_fx( &frame_dec_fx[imult1616( ch_idx, shl( num_freq_bands, 1 ) )], aux_buffer_fx, &frame_dec_fx[imult1616( ch_idx, shl( num_freq_bands, 1 ) )], shl( max_band_decorr, 1 ) ); + v_add_fx( &frame_dec_fx[2 * ch_idx * num_freq_bands], aux_buffer_fx, &frame_dec_fx[2 * ch_idx * num_freq_bands], shl( max_band_decorr, 1 ) ); } } /* avoid decorrelation above maximum frequency -> set to zero the remaining frequencies*/ + Word16 val = shl( sub( num_freq_bands, h_freq_domain_decorr_ap_params->max_band_decorr ), 1 ); FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) { - /* calc output indices */ - idx_in_out = shl( ( add( imult1616( ch_idx, num_freq_bands ), h_freq_domain_decorr_ap_params->max_band_decorr ) ), 1 ); - /* copy to output signal */ - set32_fx( &frame_dec_fx[idx_in_out], 0, shl( sub( num_freq_bands, h_freq_domain_decorr_ap_params->max_band_decorr ), 1 ) ); + set32_fx( &frame_dec_fx[2 * ( ch_idx * num_freq_bands + h_freq_domain_decorr_ap_params->max_band_decorr )], 0, val ); } *q_frame_dec = q_frame_f; move16(); diff --git a/lib_rend/ivas_dirac_onsets_dec.c b/lib_rend/ivas_dirac_onsets_dec.c index 9e82fa02269f2456dac58a477d3916a05d34f13c..f53f414045fcb223afc70ae567278fc01084d64f 100644 --- a/lib_rend/ivas_dirac_onsets_dec.c +++ b/lib_rend/ivas_dirac_onsets_dec.c @@ -43,110 +43,6 @@ #include "wmc_auto.h" #include "prot_fx.h" -static Word16 BASOP_Util_Cmp_Mant32Exp_sat( Word32 a_m, Word16 a_e, Word32 b_m, Word16 b_e ); -Word16 BASOP_Util_Cmp_Mant32Exp_sat /*!< o: flag: result of comparison */ - /* 0, if a == b */ - /* 1, if a > b */ - /* -1, if a < b */ - ( Word32 a_m, /*!< i: Mantissa of 1st operand a */ - Word16 a_e, /*!< i: Exponent of 1st operand a */ - Word32 b_m, /*!< i: Mantissa of 2nd operand b */ - Word16 b_e ) /*!< i: Exponent of 2nd operand b */ - -{ - Word32 diff_m; - Word16 diff_e, shift, result; - - - /* - This function compares two input parameters, both represented by a 32-bit mantissa and a 16-bit exponent. - If both values are identical, 0 is returned. - If a is greater b, 1 is returned. - If a is less than b, -1 is returned. - */ - - /* Check, if both mantissa and exponents are identical, when normalized: return 0 */ - shift = norm_l( a_m ); - IF( shift ) - { - a_m = L_shl( a_m, shift ); - } - IF( shift ) - { - a_e = sub( a_e, shift ); - } - - shift = norm_l( b_m ); - IF( shift ) - { - b_m = L_shl( b_m, shift ); - } - IF( shift ) - { - b_e = sub( b_e, shift ); - } - - /* align exponent, if any mantissa is zero */ - if ( !a_m ) - { - a_e = b_e; - move16(); - } - if ( !b_m ) - { - b_e = a_e; - move16(); - } - - BASOP_SATURATE_WARNING_OFF_EVS - diff_m = L_sub_sat( a_m, b_m ); - BASOP_SATURATE_WARNING_ON_EVS - diff_e = sub( a_e, b_e ); - - test(); - IF( diff_m == 0 && diff_e == 0 ) - { - return 0; - } - - /* Check sign, exponent and mantissa to identify, whether a is greater b or not */ - result = -1; - move16(); - - IF( a_m >= 0 ) - { - /* a is positive */ - if ( b_m < 0 ) - { - result = 1; - move16(); - } - - test(); - test(); - test(); - if ( ( b_m >= 0 ) && ( ( diff_e > 0 ) || ( diff_e == 0 && diff_m > 0 ) ) ) - { - result = 1; - move16(); - } - } - ELSE - { - /* a is negative */ - test(); - test(); - test(); - if ( ( b_m < 0 ) && ( ( diff_e < 0 ) || ( diff_e == 0 && diff_m > 0 ) ) ) - { - result = 1; - move16(); - } - } - return result; -} - - /*------------------------------------------------------------------------- * ivas_dirac_dec_onset_detection_open() * @@ -247,31 +143,22 @@ void ivas_dirac_dec_onset_detection_process_fx( move32(); } - IF( *p_onset_detector_1_fx == 0 ) + if ( *p_onset_detector_1_fx == 0 ) { - *p_onset_detector_1_fx = L_add( *p_onset_detector_1_fx, EPSILON_FX ); /* Q(q_onset_detector) */ + *p_onset_detector_1_fx = EPSILON_FX; /* Q(q_onset_detector) */ move32(); } /*onset filter limited between 0 and 1*/ tmp_fx = BASOP_Util_Divide3232_Scale( *p_onset_detector_2_fx, *p_onset_detector_1_fx, &e_scale ); - tmp32_fx = L_mult0( tmp_fx, DIRAC_ONSET_GAIN_FX ); + tmp32_fx = L_mult0( tmp_fx, DIRAC_ONSET_GAIN_FX ); // Q= Q12 + (15-e_scale) if ( tmp32_fx < 0 ) { tmp32_fx = 0; move32(); } - Word16 comp_flag = BASOP_Util_Cmp_Mant32Exp_sat( tmp32_fx, add( e_scale, 4 ), ONE_IN_Q30, 1 ); - test(); - IF( EQ_16( comp_flag, 1 ) || comp_flag == 0 ) - { - tmp32_fx = ONE_IN_Q31; - move32(); - } - ELSE - { - tmp32_fx = L_shl( tmp32_fx, add( e_scale, 4 ) ); - } + tmp32_fx = L_shl_sat( tmp32_fx, add( e_scale, 4 ) ); + onset_filter[b] = tmp32_fx; move32(); diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index d9377b5c04af2eeb5fc953ee36347426e46d73cd..4686ca1e6044dc75e51765c4827c15ee0b53abcd 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -823,6 +823,7 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( Word32 sqr_inp, sqr; /*Directonal sound gain nrg compensation*/ + c = L_add( ONE_IN_Q29 /*1 Q29*/, Mpy_32_16_1( L_sub( h_dirac_output_synthesis_params->diffuse_compensation_factor_decorr_fx, ONE_IN_Q29 /*1 Q29*/ ), 5461 /*1.0 / 6.0 Q15*/ ) ); /*Diffuseness modellling nrg compensation*/ /*Q29*/ FOR( k = 0; k < num_freq_bands_diff; 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 @@ -838,15 +839,16 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( { IF( reference_power[k + ( ch_idx + 1 ) * num_freq_bands] == 0 ) { - b = BASOP_Util_Divide3232_Scale( reference_power[k + num_freq_bands], 232831 /* EPSILON in exp 63 */, &b_exp ); - b_exp = add( b_exp, sub( sub( 31, q_reference_power ), 63 ) ); + b = MAX_16; + move16(); + b_exp = 0; + move16(); } 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)*/ } } - c = L_add( ONE_IN_Q29 /*1 Q29*/, Mpy_32_16_1( L_sub( h_dirac_output_synthesis_params->diffuse_compensation_factor_decorr_fx, ONE_IN_Q29 /*1 Q29*/ ), 5461 /*1.0 / 6.0 Q15*/ ) ); /*Diffuseness modellling nrg compensation*/ /*Q29*/ 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(q_diff_aab) = 2*(h_dirac_output_synthesis_state->q_direct_responses) - b_exp - 31 + q_diffuseness -31 @@ -903,6 +905,7 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( move16(); } } + 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*/ 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 @@ -918,15 +921,16 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( { IF( reference_power[k + ( ch_idx + 1 ) * num_freq_bands] == 0 ) { - b = BASOP_Util_Divide3232_Scale( reference_power[k + num_freq_bands], 232831 /* EPSILON in exp 63 */, &b_exp ); - b_exp = add( b_exp, sub( sub( 31, q_reference_power ), 63 ) ); + b = MAX_16; + move16(); + b_exp = 0; + move16(); } 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)*/ } } - 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*/ 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 @@ -1195,7 +1199,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( Word16 buf_idx, ch_idx, i, l; Word16 num_freq_bands, num_freq_bands_diff; Word16 num_channels_dir, num_channels_diff; - Word32 g, g1, g2; + Word32 g, g1[MAX_FREQUENCY_BANDS], g2; Word32 *p_gains_dir, *p_gains_diff; Word32 *p_gains_dir_prev, *p_gains_diff_prev; Word32 *p_cy_cross_dir_smooth; @@ -1209,12 +1213,14 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( DIRAC_OUTPUT_SYNTHESIS_STATE h_dirac_output_synthesis_state; Word16 nchan_transport_foa; Word16 ch_idx_diff; + Word32 cmp1, cmp2; Word32 aux_buf[CLDFB_NO_CHANNELS_MAX]; Word32 ratio_float[DIRAC_HO_NUMSECTORS * CLDFB_NO_CHANNELS_MAX]; Word16 q_com = 0; move16(); Word16 exp = 0; move16(); + Word16 q_shift; /* collect some often used parameters */ h_dirac_output_synthesis_params = hDirACRend->h_output_synthesis_psd_params; @@ -1234,6 +1240,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( nchan_transport_foa = s_min( 4, nchan_transport ); move16(); + Word16 prod = imult1616( num_freq_bands, num_channels_dir ); /*-----------------------------------------------------------------* * comput target Gains *-----------------------------------------------------------------*/ @@ -1401,6 +1408,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( move16(); /*Diffuse gain*/ + q_com = s_min( h_dirac_output_synthesis_state.q_cy_auto_diff_smooth_prev, Q31 ); FOR( ch_idx = nchan_transport_foa; ch_idx < num_channels_diff; ch_idx++ ) { v_multc_fixed_16( h_dirac_output_synthesis_state.diffuse_power_factor_fx, // Q31 @@ -1409,7 +1417,6 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( num_freq_bands_diff ); // Scale to bring in common Q-factor - q_com = s_min( h_dirac_output_synthesis_state.q_cy_auto_diff_smooth_prev, Q31 ); Scale_sig32( &h_dirac_output_synthesis_state.cy_auto_diff_smooth_fx[ch_idx * num_freq_bands_diff], num_freq_bands_diff, sub( q_com, Q31 ) ); /*q31->q_com*/ @@ -1431,59 +1438,71 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( p_cy_cross_dir_smooth = h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx; p_gains_dir = h_dirac_output_synthesis_state.cy_cross_dir_smooth_prev_fx; + FOR( l = 0; l < num_freq_bands; l++ ) + { + g1[l] = Madd_32_32( POINT_3679_Q31, onset_filter[l], POINT_1175_Q31 - POINT_3679_Q31 ); // Q31, (Q31, Q31) -> Q31 + move32(); + } + + q_shift = sub( 26, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev ); + move16(); + /* Direct gains */ IF( hodirac_flag ) { + cmp1 = L_shr( 66437775 /* 0.99f in Q26 */, q_shift ); + cmp2 = L_shr( ONE_IN_Q27 /* 2.0f in Q26 */, q_shift ); FOR( ch_idx = 0; ch_idx < nchan_transport_foa; ch_idx++ ) { FOR( l = 0; l < num_freq_bands; l++ ) { - g1 = Madd_32_32( POINT_3679_Q31, onset_filter[l], POINT_1175_Q31 - POINT_3679_Q31 ); // Q31, (Q31, Q31) -> Q31 - g2 = Mpy_32_32( L_sub( ONE_IN_Q31, g1 ), *( p_gains_dir ) ); // (Q31, p_gains_dir_q) -> p_gains_dir_q - g2 = L_add_sat( g2, Mpy_32_32( g1, ( *( p_cy_cross_dir_smooth++ ) ) ) ); // p_gains_diff_q, (Q31, p_gains_diff_q) -> p_gains_diff_q - g2 = L_max( g2, Mpy_32_32( 2126008812 /* 0.99f in Q31 */, L_shl( 1, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev ) ) ); // p_gains_dir_q - g2 = L_min( g2, Mpy_32_32( ONE_IN_Q31 /* 2.0f in Q30 */, L_shl( 1, add( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, 1 ) ) ) ); // p_gains_dir_q - *( p_gains_dir++ ) = g2; // p_gains_dir_q + g2 = Mpy_32_32( L_sub( ONE_IN_Q31, g1[l] ), *( p_gains_dir ) ); // (Q31, p_gains_dir_q) -> p_gains_dir_q + g2 = L_add_sat( g2, Mpy_32_32( g1[l], ( *( p_cy_cross_dir_smooth++ ) ) ) ); // p_gains_diff_q, (Q31, p_gains_diff_q) -> p_gains_diff_q + g2 = L_max( g2, cmp1 ); // p_gains_dir_q + g2 = L_min( g2, cmp2 ); // p_gains_dir_q + *( p_gains_dir++ ) = g2; // p_gains_dir_q move32(); } } } ELSE { + cmp1 = L_shr( 57042534 /* 0.85f in Q26 */, q_shift ); + cmp2 = L_shr( 77175193 /* 1.15f in Q26 */, q_shift ); FOR( ch_idx = 0; ch_idx < nchan_transport_foa; ch_idx++ ) { FOR( l = 0; l < num_freq_bands; l++ ) { - g1 = Madd_32_32( POINT_3679_Q31, onset_filter[l], POINT_1175_Q31 - POINT_3679_Q31 ); // Q31, (Q31, Q31) -> Q31 - g2 = Mpy_32_32( L_sub( ONE_IN_Q31, g1 ), *( p_gains_dir ) ); // (Q31, p_gains_dir_q) -> p_gains_dir_q - g2 = L_add_sat( g2, Mpy_32_32( g1, ( *( p_cy_cross_dir_smooth++ ) ) ) ); // p_gains_diff_q, (Q31, p_gains_diff_q) -> p_gains_diff_q - g2 = L_max( g2, Mpy_32_32( 1825361101 /* 0.85f in Q31 */, L_shl( 1, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev ) ) ); // p_gains_dir_q - g2 = L_min( g2, Mpy_32_32( 1234803098 /* 1.15f in Q30 */, L_shl( 1, add( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, 1 ) ) ) ); // p_gains_dir_q - *( p_gains_dir++ ) = g2; // p_gains_dir_q + g2 = Mpy_32_32( L_sub( ONE_IN_Q31, g1[l] ), *( p_gains_dir ) ); // (Q31, p_gains_dir_q) -> p_gains_dir_q + g2 = L_add_sat( g2, Mpy_32_32( g1[l], ( *( p_cy_cross_dir_smooth++ ) ) ) ); // p_gains_diff_q, (Q31, p_gains_diff_q) -> p_gains_diff_q + g2 = L_max( g2, cmp1 ); // p_gains_dir_q + g2 = L_min( g2, cmp2 ); // p_gains_dir_q + *( p_gains_dir++ ) = g2; // p_gains_dir_q move32(); } } } /*Directional gains*/ + cmp1 = L_shr( -DIRAC_GAIN_LIMIT_Q26, q_shift ); + cmp2 = L_negate( cmp1 ); FOR( ch_idx = nchan_transport_foa; ch_idx < num_channels_dir; ch_idx++ ) { FOR( l = 0; l < num_freq_bands; l++ ) { - g1 = Madd_32_32( POINT_3679_Q31, onset_filter[l], POINT_1175_Q31 - POINT_3679_Q31 ); // Q31, (Q31, Q31) -> Q31 - g2 = Mpy_32_32( L_sub( ONE_IN_Q31, g1 ), *( p_gains_dir ) ); // (Q31, p_gains_dir_q) -> p_gains_dir_q - g2 = L_add_sat( g2, Mpy_32_32( g1, ( *( p_cy_cross_dir_smooth++ ) ) ) ); // p_gains_diff_q, (Q31, p_gains_diff_q) -> p_gains_diff_q - g2 = L_max( g2, W_extract_h( W_shl( W_mult_32_32( -DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev ) ), Q5 ) ) ); // p_gains_dir_q - g2 = L_min( g2, W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev ) ), Q5 ) ) ); // p_gains_dir_q - *( p_gains_dir++ ) = g2; // p_gains_dir_q + g2 = Mpy_32_32( L_sub( ONE_IN_Q31, g1[l] ), *( p_gains_dir ) ); // (Q31, p_gains_dir_q) -> p_gains_dir_q + g2 = L_add_sat( g2, Mpy_32_32( g1[l], ( *( p_cy_cross_dir_smooth++ ) ) ) ); // p_gains_diff_q, (Q31, p_gains_diff_q) -> p_gains_diff_q + g2 = L_max( g2, cmp1 ); // p_gains_dir_q + g2 = L_min( g2, cmp2 ); // p_gains_dir_q + *( p_gains_dir++ ) = g2; // p_gains_dir_q move32(); } } IF( hodirac_flag ) { - p_cy_cross_dir_smooth = h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx + imult1616( num_freq_bands, num_channels_dir ); - p_gains_dir = h_dirac_output_synthesis_state.cy_cross_dir_smooth_prev_fx + imult1616( num_freq_bands, num_channels_dir ); + p_cy_cross_dir_smooth = h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx + prod; + p_gains_dir = h_dirac_output_synthesis_state.cy_cross_dir_smooth_prev_fx + prod; /*Direct gains*/ FOR( ch_idx = 0; ch_idx < nchan_transport_foa; ch_idx++ ) @@ -1500,12 +1519,11 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( { FOR( l = 0; l < num_freq_bands; l++ ) { - g1 = Madd_32_32( POINT_3679_Q31, onset_filter[l], POINT_1175_Q31 - POINT_3679_Q31 ); // Q31, (Q31, Q31) -> Q31 - g2 = Mpy_32_32( L_sub( ONE_IN_Q31, g1 ), *( p_gains_dir ) ); // (Q31, p_gains_dir_q) -> p_gains_dir_q - g2 = L_add_sat( g2, Mpy_32_32( g1, ( *( p_cy_cross_dir_smooth++ ) ) ) ); // (p_gains_diff_q, (Q31, p_gains_diff_q) -> p_gains_diff_q - g2 = L_max( g2, W_extract_h( W_shl( W_mult_32_32( -DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev ) ), Q5 ) ) ); // p_gains_dir_q - g2 = L_min( g2, W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev ) ), Q5 ) ) ); // p_gains_dir_q - *( p_gains_dir++ ) = g2; // p_gains_dir_q + g2 = Mpy_32_32( L_sub( ONE_IN_Q31, g1[l] ), *( p_gains_dir ) ); // (Q31, p_gains_dir_q) -> p_gains_dir_q + g2 = L_add_sat( g2, Mpy_32_32( g1[l], ( *( p_cy_cross_dir_smooth++ ) ) ) ); // (p_gains_diff_q, (Q31, p_gains_diff_q) -> p_gains_diff_q + g2 = L_max( g2, cmp1 ); // p_gains_dir_q + g2 = L_min( g2, cmp2 ); // p_gains_dir_q + *( p_gains_dir++ ) = g2; // p_gains_dir_q move32(); } } @@ -1514,17 +1532,18 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( /*Diffuse gains*/ p_cy_auto_diff_smooth = h_dirac_output_synthesis_state.cy_auto_diff_smooth_fx + imult1616( nchan_transport_foa, num_freq_bands_diff ); p_gains_diff = h_dirac_output_synthesis_state.cy_auto_diff_smooth_prev_fx + imult1616( nchan_transport_foa, num_freq_bands_diff ); + g1[0] = POINT_1175_Q31; // Q31 + move32(); FOR( ch_idx = nchan_transport_foa; ch_idx < num_channels_diff; ch_idx++ ) { FOR( l = 0; l < num_freq_bands_diff; l++ ) { - g1 = POINT_1175_Q31; // Q31 move32(); - g2 = Mpy_32_32( L_sub( ONE_IN_Q31, g1 ), *( p_gains_diff ) ); // (Q31, p_gains_dir_q) -> p_gains_dir_q - g2 = L_add_sat( g2, Mpy_32_32( g1, ( *( p_cy_auto_diff_smooth++ ) ) ) ); // p_gains_diff_q, (Q31, p_gains_diff_q) -> p_gains_diff_q - g2 = L_max( g2, 0 ); // p_gains_diff_q - g2 = L_min( g2, W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state.q_cy_auto_diff_smooth_prev ) ), Q5 ) ) ); // p_gains_diff_q - *( p_gains_diff++ ) = g2; // p_gains_diff_q + g2 = Mpy_32_32( L_sub( ONE_IN_Q31, g1[0] ), *( p_gains_diff ) ); // (Q31, p_gains_dir_q) -> p_gains_dir_q + g2 = L_add_sat( g2, Mpy_32_32( g1[0], ( *( p_cy_auto_diff_smooth++ ) ) ) ); // p_gains_diff_q, (Q31, p_gains_diff_q) -> p_gains_diff_q + g2 = L_max( g2, 0 ); // p_gains_diff_q + g2 = L_min( g2, cmp2 ); // p_gains_diff_q + *( p_gains_diff++ ) = g2; // p_gains_diff_q move32(); } } @@ -1535,8 +1554,9 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( FOR( buf_idx = 0; buf_idx < nbslots; ++buf_idx ) { - g1 = L_deposit_h( h_dirac_output_synthesis_params.interpolator_fx[buf_idx] ); // Q31 - g2 = L_sub( ONE_IN_Q31, g1 ); // Q31 + g1[0] = L_deposit_h( h_dirac_output_synthesis_params.interpolator_fx[buf_idx] ); // Q31 + move32(); + g2 = L_sub( ONE_IN_Q31, g1[0] ); // Q31 /*Direct input->output*/ p_gains_dir = h_dirac_output_synthesis_state.cy_cross_dir_smooth_prev_fx; // (p_gains_dir_q) @@ -1557,7 +1577,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( shl( ch_idx * num_freq_bands, Q1 ); FOR( l = 0; l < num_freq_bands; l++ ) { - g = Madd_32_32( Mpy_32_32( g1, ( *( p_gains_dir++ ) ) ), g2, ( *( p_gains_dir_prev++ ) ) ); // (Q31, p_gains_dir_q) -> (p_gains_dir_q) + g = Madd_32_32( Mpy_32_32( g1[0], ( *( p_gains_dir++ ) ) ), g2, ( *( p_gains_dir_prev++ ) ) ); // (Q31, p_gains_dir_q) -> (p_gains_dir_q) output_real[l * num_channels_dir + ch_idx] = Mpy_32_32( g, ( *( p_proto_diff++ ) ) ); // (p_gains_dir_q, p_proto_diff_q) -> (p_gains_dir_q + p_proto_diff_q - 31) move32(); @@ -1583,25 +1603,31 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( shl( i_mult( proto_direct_index[1], num_freq_bands ), Q1 ); FOR( l = 0; l < num_freq_bands; l++ ) { - gs1 = Madd_32_32( Mpy_32_32( g1, ( *( p_gains_dir ) ) ), g2, ( *( p_gains_dir_prev ) ) ); // (Q31, p_gains_dir_q) -> (p_gains_dir_q) - gs2 = Madd_32_32( Mpy_32_32( g1, ( *( p_gains_dir + imult1616( num_freq_bands, num_channels_dir ) ) ) ), g2, ( *( p_gains_dir_prev + imult1616( num_freq_bands, num_channels_dir ) ) ) ); // (Q31, p_gains_dir_q) -> (p_gains_dir_q) + + Word32 temp1, temp2; + gs1 = Madd_32_32( Mpy_32_32( g1[0], ( *( p_gains_dir ) ) ), g2, ( *( p_gains_dir_prev ) ) ); // (Q31, p_gains_dir_q) -> (p_gains_dir_q) + gs2 = Madd_32_32( Mpy_32_32( g1[0], ( *( p_gains_dir + prod ) ) ), g2, ( *( p_gains_dir_prev + prod ) ) ); // (Q31, p_gains_dir_q) -> (p_gains_dir_q) p_gains_dir++; p_gains_dir_prev++; + temp1 = Mpy_32_32( 1903158016 /* 1.772454e+00f / 2 in Q31 */, ( *p_proto ) ); + temp2 = Mpy_32_32( 1098788992 /* 1.023327e+00f / 2 in Q31 */, ( *p_proto2 ) ); // ((p_gains_dir_q, p_proto_dir_q) >> 1) -> (p_gains_dir_q + p_proto_dir_q - 31) output_real[l * num_channels_dir + ch_idx] = Madd_32_32( - Mpy_32_32( gs1, ( L_add( Mpy_32_32( 1903158016 /* 1.772454e+00f / 2 in Q31 */, ( *p_proto ) ), Mpy_32_32( 1098788992 /* 1.023327e+00f / 2 in Q31 */, ( *p_proto2 ) ) ) ) ), /* s1 */ - gs2, L_sub( Mpy_32_32( 1903158016 /* 1.772454e+00f / 2 in Q31 */, ( *p_proto ) ), Mpy_32_32( 1098788992 /* 1.023327e+00f / 2 in Q31 */, ( *p_proto2 ) ) ) ); /* s2 */ + Mpy_32_32( gs1, ( L_add( temp1, temp2 ) ) ), /* s1 */ + gs2, L_sub( temp1, temp2 ) ); /* s2 */ move32(); p_proto++; p_proto2++; + temp1 = Mpy_32_32( 1903158016 /* 1.772454e+00f / 2 in Q31 */, ( *p_proto ) ); + temp2 = Mpy_32_32( 1098788992 /* 1.023327e+00f / 2 in Q31 */, ( *p_proto2 ) ); // ((p_gains_dir_q, p_proto_dir_q) >> 1) -> (p_gains_dir_q + p_proto_dir_q - 31) output_imag[l * num_channels_dir + ch_idx] = Madd_32_32( - Mpy_32_32( gs1, ( L_add( Mpy_32_32( 1903158016 /* 1.772454e+00f / 2 in Q31 */, ( *p_proto ) ), Mpy_32_32( 1098788992 /* 1.023327e+00f / 2 in Q31 */, ( *p_proto2 ) ) ) ) ), - gs2, L_sub( Mpy_32_32( 1903158016 /* 1.772454e+00f / 2 in Q31 */, ( *p_proto ) ), Mpy_32_32( 1098788992 /* 1.023327e+00f / 2 in Q31 */, ( *p_proto2 ) ) ) ); + Mpy_32_32( gs1, ( L_add( temp1, temp2 ) ) ), + gs2, L_sub( temp1, temp2 ) ); move32(); p_proto++; p_proto2++; @@ -1612,14 +1638,15 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( p_proto = h_dirac_output_synthesis_state.proto_direct_buffer_f_fx + shl( i_mult( buf_idx, i_mult( num_freq_bands, num_protos_dir ) ), Q1 ) + shl( i_mult( proto_direct_index[ch_idx], num_freq_bands ), Q1 ); + Word16 diff = sub( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, 31 ); FOR( l = 0; l < num_freq_bands; l++ ) { p_gains_dir++; p_gains_dir_prev++; - output_real[l * num_channels_dir + ch_idx] = L_shl( *( p_proto++ ), sub( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, 31 ) ); // p_proto_dir_q -> (p_gains_dir_q + p_proto_dir_q - 31) + output_real[l * num_channels_dir + ch_idx] = L_shl( *( p_proto++ ), diff ); // p_proto_dir_q -> (p_gains_dir_q + p_proto_dir_q - 31) move32(); - output_imag[l * num_channels_dir + ch_idx] = L_shl( *( p_proto++ ), sub( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, 31 ) ); // p_proto_dir_q -> (p_gains_dir_q + p_proto_dir_q - 31) + output_imag[l * num_channels_dir + ch_idx] = L_shl( *( p_proto++ ), diff ); // p_proto_dir_q -> (p_gains_dir_q + p_proto_dir_q - 31) move32(); } } @@ -1633,7 +1660,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( { FOR( l = 0; l < num_freq_bands; l++ ) { - g = Madd_32_32( Mpy_32_32( g1, ( *( p_gains_dir++ ) ) ), g2, ( *( p_gains_dir_prev++ ) ) ); // (Q31, p_gains_dir_q) -> (p_gains_dir_q) + g = Madd_32_32( Mpy_32_32( g1[0], ( *( p_gains_dir++ ) ) ), g2, ( *( p_gains_dir_prev++ ) ) ); // (Q31, p_gains_dir_q) -> (p_gains_dir_q) output_real[l * num_channels_dir + ch_idx] = Mpy_32_32( g, ( *( p_proto++ ) ) ); // (p_gains_dir_q, p_proto_dir_q) -> (p_gains_dir_q + p_proto_dir_q - 31) move32(); @@ -1643,14 +1670,15 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( } ELSE { + Word16 shift_q = sub( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, 31 ); FOR( l = 0; l < num_freq_bands; l++ ) { p_gains_dir++; p_gains_dir_prev++; - output_real[l * num_channels_dir + ch_idx] = L_shl( *( p_proto++ ), sub( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, 31 ) ); // p_proto_dir_q -> (p_gains_dir_q + p_proto_dir_q - 31) + output_real[l * num_channels_dir + ch_idx] = L_shl( *( p_proto++ ), shift_q ); // p_proto_dir_q -> (p_gains_dir_q + p_proto_dir_q - 31) move32(); - output_imag[l * num_channels_dir + ch_idx] = L_shl( *( p_proto++ ), sub( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, 31 ) ); // p_proto_dir_q -> (p_gains_dir_q + p_proto_dir_q - 31) + output_imag[l * num_channels_dir + ch_idx] = L_shl( *( p_proto++ ), shift_q ); // p_proto_dir_q -> (p_gains_dir_q + p_proto_dir_q - 31) move32(); } } @@ -1681,7 +1709,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( ch_idx_diff = add( ch_idx_diff, 1 ); FOR( l = 0; l < num_freq_bands_diff; l++ ) { - g = Madd_32_32( Mpy_32_32( g1, ( *( p_gains_diff++ ) ) ), g2, ( *( p_gains_diff_prev++ ) ) ); // (Q31, p_gains_diff_q) -> p_gains_diff_q + g = Madd_32_32( Mpy_32_32( g1[0], ( *( p_gains_diff++ ) ) ), g2, ( *( p_gains_diff_prev++ ) ) ); // (Q31, p_gains_diff_q) -> p_gains_diff_q // ((p_gains_diff_q, p_proto_diff_q) >> Q1) -> (p_gains_diff_q + p_proto_diff_q - 31) output_real[l * num_channels_dir + hDirACRend->sba_map_tc[ch_idx]] = @@ -1765,11 +1793,11 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( /* store estimates for next synthesis block */ IF( hodirac_flag ) { - Copy32( h_dirac_output_synthesis_state.cy_cross_dir_smooth_prev_fx, h_dirac_output_synthesis_state.gains_dir_prev_fx, imult1616( num_freq_bands, num_channels_dir ) * DIRAC_HO_NUMSECTORS ); /*h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev*/ + Copy32( h_dirac_output_synthesis_state.cy_cross_dir_smooth_prev_fx, h_dirac_output_synthesis_state.gains_dir_prev_fx, prod * DIRAC_HO_NUMSECTORS ); /*h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev*/ } ELSE { - Copy32( h_dirac_output_synthesis_state.cy_cross_dir_smooth_prev_fx, h_dirac_output_synthesis_state.gains_dir_prev_fx, imult1616( num_freq_bands, num_channels_dir ) ); /*h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev*/ + Copy32( h_dirac_output_synthesis_state.cy_cross_dir_smooth_prev_fx, h_dirac_output_synthesis_state.gains_dir_prev_fx, prod ); /*h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev*/ } *q_cy_cross_dir_smooth_prev = h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev; move16(); @@ -1781,11 +1809,11 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( /* reset values */ IF( hodirac_flag ) { - set_zero_fx( h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx, imult1616( num_freq_bands, num_channels_dir ) * DIRAC_HO_NUMSECTORS ); + set_zero_fx( h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx, prod * DIRAC_HO_NUMSECTORS ); } ELSE { - set_zero_fx( h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx, imult1616( num_freq_bands, num_channels_dir ) ); + set_zero_fx( h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx, prod ); } set_zero_fx( h_dirac_output_synthesis_state.cy_auto_diff_smooth_fx, imult1616( num_freq_bands_diff, num_channels_diff ) ); diff --git a/lib_rend/ivas_dirac_rend.c b/lib_rend/ivas_dirac_rend.c index 1982862bfba0627955807d33f96e4beae4eab510..cafd709664ea23abebc12fcdbc591fdeaae9fbc0 100644 --- a/lib_rend/ivas_dirac_rend.c +++ b/lib_rend/ivas_dirac_rend.c @@ -1444,15 +1444,15 @@ void protoSignalComputation_shd_fx( reference_power_fx[l] = L_shr( reference_power_fx[l + num_freq_bands], 1 ); /*2*Q(q_cldfb+min_q_shift)-31-1*/ move32(); + re1 = L_shl( RealBuffer_fx[1][0][l], min_q_shift ); /*Q(q_cldfb+min_q_shift)*/ + re2 = L_shl( RealBuffer_fx[2][0][l], min_q_shift ); /*Q(q_cldfb+min_q_shift)*/ + re3 = L_shl( RealBuffer_fx[3][0][l], min_q_shift ); /*Q(q_cldfb+min_q_shift)*/ + im1 = L_shl( ImagBuffer_fx[1][0][l], min_q_shift ); /*Q(q_cldfb+min_q_shift)*/ + im2 = L_shl( ImagBuffer_fx[2][0][l], min_q_shift ); /*Q(q_cldfb+min_q_shift)*/ + im3 = L_shl( ImagBuffer_fx[3][0][l], min_q_shift ); /*Q(q_cldfb+min_q_shift)*/ + FOR( k = 1; k < 4; k++ ) { - re1 = L_shl( RealBuffer_fx[1][0][l], min_q_shift ); /*Q(q_cldfb+min_q_shift)*/ - re2 = L_shl( RealBuffer_fx[2][0][l], min_q_shift ); /*Q(q_cldfb+min_q_shift)*/ - re3 = L_shl( RealBuffer_fx[3][0][l], min_q_shift ); /*Q(q_cldfb+min_q_shift)*/ - im1 = L_shl( ImagBuffer_fx[1][0][l], min_q_shift ); /*Q(q_cldfb+min_q_shift)*/ - im2 = L_shl( ImagBuffer_fx[2][0][l], min_q_shift ); /*Q(q_cldfb+min_q_shift)*/ - im3 = L_shl( ImagBuffer_fx[3][0][l], min_q_shift ); /*Q(q_cldfb+min_q_shift)*/ - idx = i_mult( 3, Rmat_k[k] ); idx1 = add( l, i_mult( add( k, 1 ), num_freq_bands ) ); @@ -1477,13 +1477,16 @@ void protoSignalComputation_shd_fx( } *proto_direct_buffer_f_q = add( q_cldfb, min_q_shift ); + move16(); *reference_power_q = sub( add( *proto_direct_buffer_f_q, *proto_direct_buffer_f_q ), 31 ); + move16(); + Word16 shift = sub( *proto_direct_buffer_f_q, q_cldfb ); FOR( k = 1; k < 4; k++ ) { - RealBuffer_fx[k][0][l] = L_shr( p_proto_direct_buffer_fx[2 * ( k * num_freq_bands + l )], sub( *proto_direct_buffer_f_q, q_cldfb ) ); // proto_direct_buffer_f_q -> q_cldfb + RealBuffer_fx[k][0][l] = L_shr( p_proto_direct_buffer_fx[2 * ( k * num_freq_bands + l )], shift ); // proto_direct_buffer_f_q -> q_cldfb move32(); - ImagBuffer_fx[k][0][l] = L_shr( p_proto_direct_buffer_fx[2 * ( k * num_freq_bands + l ) + 1], sub( *proto_direct_buffer_f_q, q_cldfb ) ); // proto_direct_buffer_f_q -> q_cldfb + ImagBuffer_fx[k][0][l] = L_shr( p_proto_direct_buffer_fx[2 * ( k * num_freq_bands + l ) + 1], shift ); // proto_direct_buffer_f_q -> q_cldfb move32(); } } @@ -4011,20 +4014,6 @@ static void ivas_masa_ext_dirac_render_sf_fx( move16(); } - /*Buffer Scaling*/ - FOR( ch = 0; ch < hDirACRend->hOutSetup.nchan_out_woLFE; ch++ ) - { - FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) - { - scale_sig32( Cldfb_RealBuffer_fx[ch][slot_idx], - hSpatParamRendCom->num_freq_bands, sub( 11, q_cldfb ) ); // q11 - scale_sig32( Cldfb_ImagBuffer_fx[ch][slot_idx], - hSpatParamRendCom->num_freq_bands, sub( 11, q_cldfb ) ); // q11 - } - } - q_cldfb = 11; - move16(); - 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*/ DirAC_mem.reference_power_q = add( DirAC_mem.reference_power_q, reference_power_temp_q ); diff --git a/lib_rend/ivas_efap.c b/lib_rend/ivas_efap.c index 7d47f31747a32108ebaa0c11967eff4d34a88c9d..0bf3b85a41002be531d3b862334d8650971b78ba 100644 --- a/lib_rend/ivas_efap.c +++ b/lib_rend/ivas_efap.c @@ -2479,7 +2479,7 @@ static Word16 in_tri_fx( Word16 tmp16, tmp_e; Word64 S[2]; /* Threshold adjusted */ - Word64 thresh_int = 4295; // 1e-6f in Q32 + Word64 thresh_int = 35184640; // 1e-6f in Q45 move64(); /* @@ -2490,7 +2490,7 @@ static Word16 in_tri_fx( */ v_sub_fixed( B, A, tmpDot1, 2, 0 ); // tmpDot1 q22 - v_sub_fixed( C, A, tmpDot2, 2, 0 ); // tmpDot 2q22 + v_sub_fixed( C, A, tmpDot2, 2, 0 ); // tmpDot2 q22 /* Verification of the non-colinearity : Q22 * Q22 = Q13 */ invFactor = L_sub( Mpy_32_32( tmpDot1[0], tmpDot2[1] ), Mpy_32_32( tmpDot1[1], tmpDot2[0] ) ); /*q22+q22-q31->q13*/ @@ -2516,68 +2516,18 @@ static Word16 in_tri_fx( move32(); matInv[1][1] = Mpy_32_32( tmpDot1[0], invFactor ); // q=22+invFactor_exp move32(); - - /* Computing S (Q13 + matInv_exp_final[i] + P_minus_A_exp_final + invFactor_exp - 1 ) = - matInv (Q22 + matInv_exp_final[i] + invFactor_exp) *(P-A) (Q22 + P_minus_A_exp_final) */ - Word16 matInv_exp[2][2], P_minus_A_exp[2]; - Word16 matInv_exp_final[2], P_minus_A_exp_final; - FOR( Word32 i = 0; i < 2; i++ ) - { - FOR( Word32 j = 0; j < 2; j++ ) - { - matInv_exp[i][j] = 31; - move16(); - IF( matInv[i][j] != 0 ) - { - matInv_exp[i][j] = norm_l( matInv[i][j] ); - move16(); - } - } - matInv_exp_final[i] = s_min( matInv_exp[i][0], matInv_exp[i][1] ); - move16(); - P_minus_A_exp[i] = 31; - move16(); - IF( P_minus_A[i] != 0 ) - { - P_minus_A_exp[i] = norm_l( P_minus_A[i] ); - move16(); - } - } - P_minus_A_exp_final = s_min( P_minus_A_exp[0], P_minus_A_exp[1] ); - - S[0] = L_add( L_shr( Mpy_32_32( L_shl( matInv[0][0], matInv_exp_final[0] ), L_shl( P_minus_A[0], P_minus_A_exp_final ) ), Q1 ), - L_shr( Mpy_32_32( L_shl( matInv[0][1], matInv_exp_final[0] ), L_shl( P_minus_A[1], P_minus_A_exp_final ) ), Q1 ) ); //(22+invFactor_exp+matInv_exp_final[0]+22+P_minus_A_exp_final-1)-31=>12+invFactor_exp+matInv_exp_final[0]+P_minus_A_exp_final + S[0] = W_mac_32_32( W_mult_32_32( matInv[0][0], P_minus_A[0] ), matInv[0][1], P_minus_A[1] ); // Q22+invFactor_exp +Q22 + 1 move64(); - S[1] = L_add( L_shr( Mpy_32_32( L_shl( matInv[1][0], matInv_exp_final[1] ), L_shl( P_minus_A[0], P_minus_A_exp_final ) ), Q1 ), - L_shr( Mpy_32_32( L_shl( matInv[1][1], matInv_exp_final[1] ), L_shl( P_minus_A[1], P_minus_A_exp_final ) ), Q1 ) ); //(22+invFactor_exp+matInv_exp_final[1]+22+P_minus_A_exp_final-1)-31=>12+invFactor_exp+matInv_exp_final[0]+P_minus_A_exp_final + S[0] = W_shr( S[0], invFactor_exp ); // q45 + move64(); + S[1] = W_mac_32_32( W_mult_32_32( matInv[1][0], P_minus_A[0] ), matInv[1][1], P_minus_A[1] ); // Q22+invFactor_exp +Q22 + 1 + move64(); + S[1] = W_shr( S[1], invFactor_exp ); // q45 move64(); - - /* Checking if we are in the triangle; For the theory, check Christian Borss article, section 3.2 */ - // Q32 S - IF( sub( sub( sub( Q20, matInv_exp_final[0] ), P_minus_A_exp_final ), invFactor_exp ) < 0 ) - { - S[0] = W_shr( S[0], sub( add( add( matInv_exp_final[0], P_minus_A_exp_final ), invFactor_exp ), Q20 ) ); // q32 - move64(); - } - ELSE - { - S[0] = W_shl( S[0], sub( sub( sub( Q20, matInv_exp_final[0] ), P_minus_A_exp_final ), invFactor_exp ) ); // q32 - move64(); - } - IF( sub( sub( sub( Q20, matInv_exp_final[1] ), P_minus_A_exp_final ), invFactor_exp ) < 0 ) - { - S[1] = W_shr( S[1], sub( add( add( matInv_exp_final[1], P_minus_A_exp_final ), invFactor_exp ), Q20 ) ); // q32 - move64(); - } - ELSE - { - S[1] = W_shl( S[1], sub( sub( sub( Q20, matInv_exp_final[1] ), P_minus_A_exp_final ), invFactor_exp ) ); // q32 - move64(); - } test(); test(); - IF( LT_64( S[0], -thresh_int ) || LT_64( S[1], -thresh_int ) || GT_64( W_add( S[0], S[1] ), W_add( W_shl( 1, 32 ), thresh_int ) ) ) + IF( LT_64( S[0], -thresh_int ) || LT_64( S[1], -thresh_int ) || GT_64( W_add( S[0], S[1] ), W_add( ONE_IN_Q45, thresh_int ) ) ) { return 0; } diff --git a/lib_rend/ivas_output_init_fx.c b/lib_rend/ivas_output_init_fx.c index 77cfa9c553f73a8c028e1abf54c8e5279ad7f7b0..bbe6ae4b594080faa9e97bc52ca25475134beb26 100644 --- a/lib_rend/ivas_output_init_fx.c +++ b/lib_rend/ivas_output_init_fx.c @@ -2,6 +2,10 @@ #include "ivas_prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" +#ifdef FIX_DISCLAIMER +#include +#endif + Word16 ivas_get_nchan_buffers_dec_ivas_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const Word16 sba_analysis_order, /* i : SBA order evaluated in SBA decoder */ @@ -157,3 +161,116 @@ Word16 ivas_get_nchan_buffers_dec_ivas_fx( return nchan_out_buff; } + +#ifdef FIX_DISCLAIMER +/*---------------------------------------------------------------------* + * get_channel_config() + * + * Gets a str related to audio configuration + *---------------------------------------------------------------------*/ + +ivas_error get_channel_config( + const AUDIO_CONFIG config, /* i : audio configuration */ + Word8 *str /* o : string with the configuration name */ +) +{ + 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_ISM1 ) ) + { + strcpy( (char *) str, "Object-based audio (1 object)" ); + } + ELSE IF( EQ_16( (Word16) config, IVAS_AUDIO_CONFIG_ISM2 ) ) + { + strcpy( (char *) str, "Object-based audio (2 objects)" ); + } + ELSE IF( EQ_16( (Word16) config, IVAS_AUDIO_CONFIG_ISM3 ) ) + { + strcpy( (char *) str, "Object-based audio (3 objects)" ); + } + ELSE IF( EQ_16( (Word16) config, IVAS_AUDIO_CONFIG_ISM4 ) ) + { + strcpy( (char *) str, "Object-based audio (4 objects)" ); + } + 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_MASA1 ) ) + { + strcpy( (char *) str, "Metadata-Assisted Spatial Audio mono (MASA1)" ); + } + ELSE IF( EQ_16( (Word16) config, IVAS_AUDIO_CONFIG_MASA2 ) ) + { + strcpy( (char *) str, "Metadata-Assisted Spatial Audio stereo (MASA2)" ); + } + 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_BINAURAL_SPLIT_CODED ) ) + { + strcpy( (char *) str, "BINAURAL_SPLIT_CODED" ); + } + ELSE IF( EQ_16( (Word16) config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + strcpy( (char *) str, "Binaural_Split_PCM" ); + } + 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 diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 396b1163a214518338cb8ba5699a79715a5162c4..4afd38886bbb90e2aaa4a856708e9314958a1870 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -81,6 +81,14 @@ 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 + + /*----------------------------------------------------------------------------------* * Limiter prototypes *----------------------------------------------------------------------------------*/ diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 14bb3b95754fca390e83e823c07a324dfdbbbfb0..86eea321bc28387a7d23287cbd18943db2a10cfd 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -4564,40 +4564,58 @@ static void renderBufferChannelLerp_fx( { i = 0; Word32 tmp = Q31_BY_SUB_FRAME_240; + Word32 tmp1 = 239; /* L_SUBFRAME_48k - 1 */ + move32(); move32(); move32(); SWITCH( outAudio.config.numSamplesPerChannel ) { case NUM_SAMPLES_960: tmp = Q31_BY_NUM_SAMPLES_960; + tmp1 = 959; /* NUM_SAMPLES_960 - 1 */ + move32(); move32(); BREAK; case NUM_SAMPLES_720: tmp = Q31_BY_NUM_SAMPLES_720; + tmp1 = 719; /* NUM_SAMPLES_720 - 1 */ + move32(); move32(); BREAK; case NUM_SAMPLES_320: tmp = Q31_BY_NUM_SAMPLES_320; + tmp1 = 319; /* NUM_SAMPLES_320 - 1 */ + move32(); move32(); BREAK; case NUM_SAMPLES_160: tmp = Q31_BY_NUM_SAMPLES_160; + tmp1 = 159; /* NUM_SAMPLES_160 - 1 */ + move32(); move32(); BREAK; case L_SUBFRAME_48k: tmp = Q31_BY_SUB_FRAME_240; + tmp1 = 239; /* L_SUBFRAME_48k - 1 */ + move32(); move32(); BREAK; case L_SUBFRAME_32k: tmp = Q31_BY_SUB_FRAME_180; + tmp1 = 179; /* L_SUBFRAME_32k - 1 */ + move32(); move32(); BREAK; case L_SUBFRAME_16k: tmp = Q31_BY_SUB_FRAME_80; + tmp1 = 79; /* L_SUBFRAME_16k - 1 */ + move32(); move32(); BREAK; case L_SUBFRAME_8k: tmp = Q31_BY_SUB_FRAME_40; + tmp1 = 39; /* L_SUBFRAME_8k - 1 */ + move32(); move32(); BREAK; default: @@ -4606,7 +4624,15 @@ static void renderBufferChannelLerp_fx( /* Otherwise use weighted average between previous and current gain */ DO { - fadeIn = UL_Mpy_32_32( i, tmp ); + IF( EQ_32( i, tmp1 ) ) + { + fadeIn = ONE_IN_Q31; + move32(); + } + ELSE + { + fadeIn = UL_Mpy_32_32( i, tmp ); + } fadeOut = L_sub( ONE_IN_Q31, fadeIn ); *outSmpl = L_add( Mpy_32_32( L_add( Mpy_32_32( fadeIn, currentGain ), Mpy_32_32( fadeOut, previousGain ) ), ( *inSmpl ) ), *outSmpl ); @@ -8457,3 +8483,98 @@ static void intermidiate_ext_dirac_render( } } } + +#ifdef FIX_DISCLAIMER +static ivas_error printConfigInfo_rend( + IVAS_REND_HANDLE hIvasRend /* i : IVAS renderer handle */ +) +{ + ivas_error error; + Word8 config_str[50]; + + /*-----------------------------------------------------------------* + * Print output audio configuration + *-----------------------------------------------------------------*/ + + IF( NE_32( ( error = get_channel_config( hIvasRend->outputConfig, &config_str[0] ) ), IVAS_ERR_OK ) ) + { + return error; + } + + fprintf( stdout, "Output configuration: %s\n", config_str ); + + /*-----------------------------------------------------------------* + * Print renderer configurations + *-----------------------------------------------------------------*/ + + fprintf( stdout, "Output sampling rate: %d Hz\n", hIvasRend->sampleRateOut ); + + if ( hIvasRend->headRotData.headRotEnabled ) + { + fprintf( stdout, "Head-tracking: ON\n" ); + } + + IF( EQ_16( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL ) || + EQ_16( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || + EQ_16( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || + EQ_16( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || + EQ_16( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + fprintf( stdout, "Render framesize: %dms\n", mult( hIvasRend->num_subframes, 5 ) ); + } + + return IVAS_ERR_OK; +} + + +/*---------------------------------------------------------------------* + * IVAS_REND_PrintInputConfig() + * + * + *---------------------------------------------------------------------*/ + +void IVAS_REND_PrintInputConfig( + const IVAS_AUDIO_CONFIG inputConfig /* i : input audio configuration */ +) +{ + Word8 config_str[50]; + + get_channel_config( inputConfig, &config_str[0] ); + fprintf( stdout, "Input configuration: %s\n", config_str ); + + return; +} + + +/*---------------------------------------------------------------------* + * IVAS_REND_PrintConfig() + * + * + *---------------------------------------------------------------------*/ + +ivas_error IVAS_REND_PrintConfig( + IVAS_REND_HANDLE hIvasRend /* i : IVAS renderer handle */ +) +{ + if ( hIvasRend == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + return printConfigInfo_rend( hIvasRend ); +} + + +/*---------------------------------------------------------------------* + * IVAS_REND_PrintDisclaimer() + * + * Print IVAS disclaimer to console + *---------------------------------------------------------------------*/ + +void IVAS_REND_PrintDisclaimer( void ) +{ + print_disclaimer( stderr ); + + return; +} +#endif diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index f3726a05b216041c6de9274204c369ff6051a92b..74e6070b529551c010c4cbe84c022487be01fe5e 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -324,6 +324,22 @@ void IVAS_REND_Close( ); +#ifdef FIX_DISCLAIMER +/* Disclaimer and info printing */ + +void IVAS_REND_PrintInputConfig( + const IVAS_AUDIO_CONFIG inputConfig /* i : input audio configuration */ +); + +ivas_error IVAS_REND_PrintConfig( + IVAS_REND_HANDLE hIvasRend /* i : IVAS renderer handle */ +); + +void IVAS_REND_PrintDisclaimer( + void +); +#endif + /* clang-format on */ #endif