diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 555603e6b2eb590f0085d6b0db59ec78ff85686a..2cb080114caf0c74affd134d115d17b7f264c571 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_STV_SANITIZERS: 1800
+ TESTCASE_TIMEOUT_LTV_SANITIZERS: 6000
CI_REGRESSION_THRESH_MLD: "0.1"
CI_REGRESSION_THRESH_MAX_ABS_DIFF: "50"
CI_REGRESSION_THRESH_SSNR: "-1"
@@ -33,6 +33,7 @@ variables:
TESTS_DIR_CODEC_BE_ON_MR: "tests/codec_be_on_mr_nonselection"
BUILD_WITH_DEBUG_MODE_INFO: ""
ENCODER_TEST: ""
+ 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'
@@ -295,17 +296,6 @@ 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:
- - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "pytest-compare"
- - if: $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
- - if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main" # only have MR pipelines for MRs to main
- - if: $CI_PIPELINE_SOURCE == 'push'
- when: never
- - if: $CI_PIPELINE_SOURCE == 'schedule'
- when: never
-
.rules-pytest-to-main-short:
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main" # only have MR pipelines for MRs to main
@@ -521,6 +511,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
@@ -568,7 +559,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
@@ -584,11 +578,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;
@@ -643,12 +637,13 @@ stages:
script:
- *print-common-info
- *update-scripts-repo
+ - *copy-ltv-files-to-testv-dir
- python3 ci/remove_unsupported_testcases.py $PRM_FILES
- *build-reference-and-dut-binaries
- make clean
- make -j CLANG=$CLANG_NUM
- if [[ $CLANG_NUM == 3 ]]; then export UBSAN_OPTIONS="suppressions=scripts/ubsan.supp,report_error_type=1"; fi
- - testcase_timeout=$TESTCASE_TIMEOUT_STV_SANITIZERS
+ - 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:
name: "$CI_JOB_NAME--sha-$CI_COMMIT_SHORT_SHA--results"
@@ -966,39 +961,41 @@ build-codec-linux-debugging-make:
# ---------------------------------------------------------------
### 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:
@@ -1084,6 +1081,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
@@ -1093,6 +1092,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
@@ -1102,6 +1103,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
@@ -1168,24 +1171,30 @@ 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
- - TEST_SUITE=$LONG_TEST_SUITE_SELF_TEST
+ - TEST_SUITE=$LONG_TEST_SUITE_NO_RENDERER
<<: *ivas-pytest-sanitizers-anchor
ivas-pytest-dec-asan:
extends:
- .test-job-linux
+ tags:
+ - ivas-basop-linux-fast
before_script:
- CLANG_NUM=2
- DUT_ENCODER_PATH=./$REF_ENCODER_PATH
- - TEST_SUITE=$LONG_TEST_SUITE_SELF_TEST
+ - TEST_SUITE=$LONG_TEST_SUITE_NO_RENDERER
<<: *ivas-pytest-sanitizers-anchor
ivas-pytest-dec-usan:
extends:
- .test-job-linux
+ tags:
+ - ivas-basop-linux-fast
before_script:
- CLANG_NUM=3
- DUT_ENCODER_PATH=./$REF_ENCODER_PATH
@@ -1511,6 +1520,21 @@ renderer-pytest-on-merge-request:
- *merge-request-comparison-check
+ allow_failure:
+ exit_codes:
+ - 123
+ artifacts:
+ name: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--job-$CI_JOB_NAME--results"
+ expire_in: 1 week
+ when: always
+ paths:
+ - report-junit.xml
+ - report.html
+ expose_as: "pytest renderer results"
+ reports:
+ junit:
+ - report-junit.xml
+
# compare bit exactness between target and source branch
ivas-pytest-on-merge-request:
extends:
@@ -1584,6 +1608,9 @@ ivas-pytest-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
+ # 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
@@ -1594,21 +1621,13 @@ ivas-pytest-on-merge-request:
- rm artifacts.zip
- rm -rf $public_dir
- ### 1.5.part: get the corresponding measurement from ivas-float-update-cmplx
- - job_id=$(python3 ci/get_id_of_last_job_occurence.py ivas-float-update-cmplx $CI_JOB_NAME $CI_PROJECT_ID)
+ ### 1.5.part: get the corresponding measurement from ivas-float-update
+ - job_id=$(python3 ci/get_id_of_last_job_occurence.py ivas-float-update $CI_JOB_NAME $CI_PROJECT_ID)
- echo $job_id
- curl --request GET "https://forge.3gpp.org/rep/api/v4/projects/$CI_PROJECT_ID/jobs/$job_id/artifacts" --output artifacts_ref.zip
- - unzip -j artifacts_ref.zip "*latest_WMOPS.csv"
-
- ### 2. part: setup specific for BASOP repo
- # hack for using the reference encoder -> need to build manually to make script use ref enc and BASOP dec
- - mkdir COMPLEXITY
- - cp IVAS_cod_ref COMPLEXITY/IVAS_cod
- # build branch code aain with instrumentation
- - make clean
- - bash scripts/prepare_instrumentation.sh -p BASOP -m MEM_ONLY
- - make -j -C $INSTR_DIR
- - cp $INSTR_DIR/IVAS_dec COMPLEXITY/IVAS_dec
+ - unzip -j artifacts_ref.zip "*latest_WMOPS.csv" || true
+ # add file to arguments only if the artifact could be retrieved to prevent error later.
+ - if [ -f latest_WMOPS.csv ]; then GET_WMOPS_ARGS="$GET_WMOPS_ARGS latest_WMOPS.csv"; fi
.complexity-measurements-prepare-artifacts:
&complexity-measurements-prepare-artifacts # prepare artifacts -> move to public directory
@@ -1636,6 +1655,7 @@ ivas-pytest-on-merge-request:
stage: test
variables:
ret_val: 0
+ GET_WMOPS_ARGS: "mem_only basop"
timeout: 3 hours 30 minutes
before_script:
- *print-common-info
@@ -1656,10 +1676,12 @@ complexity-stereo-in-stereo-out:
- .complexity-template
rules:
- if: $MEASURE_COMPLEXITY_LINUX
+ variables:
+ JOB_ID_INJECT: ""
script:
- in_format=stereo
- out_format=stereo
- - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" mem_only basop latest_WMOPS.csv || ret_val=$?
+ - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" $GET_WMOPS_ARGS || ret_val=$?
- *complexity-measurements-prepare-artifacts
- exit $ret_val
@@ -1670,11 +1692,13 @@ complexity-ism-in-binaural-out:
- if: $MEASURE_COMPLEXITY_LINUX
when: delayed
start_in: 1 hour
+ variables:
+ JOB_ID_INJECT: ""
script:
- in_format=ISM
- out_format=BINAURAL
- ret_val=0
- - bash ci/complexity_measurements/getWmops.sh "ISM+1 ISM+2 ISM+3 ISM+4" "$out_format" mem_only basop latest_WMOPS.csv || ret_val=$?
+ - bash ci/complexity_measurements/getWmops.sh "ISM+1 ISM+2 ISM+3 ISM+4" "$out_format" $GET_WMOPS_ARGS || ret_val=$?
- *complexity-measurements-prepare-artifacts
- exit $ret_val
@@ -1685,11 +1709,13 @@ complexity-ism-in-binaural_room_ir-out:
- if: $MEASURE_COMPLEXITY_LINUX
when: delayed
start_in: 2 hours
+ variables:
+ JOB_ID_INJECT: ""
script:
- in_format=ISM
- out_format=BINAURAL_ROOM_IR
- ret_val=0
- - bash ci/complexity_measurements/getWmops.sh "ISM+1 ISM+2 ISM+3 ISM+4" "$out_format" mem_only basop latest_WMOPS.csv || ret_val=$?
+ - bash ci/complexity_measurements/getWmops.sh "ISM+1 ISM+2 ISM+3 ISM+4" "$out_format" $GET_WMOPS_ARGS || ret_val=$?
- *complexity-measurements-prepare-artifacts
- exit $ret_val
@@ -1700,11 +1726,13 @@ complexity-ism-in-ext-out:
- if: $MEASURE_COMPLEXITY_LINUX
when: delayed
start_in: 3 hours 30 minutes
+ variables:
+ JOB_ID_INJECT: ""
script:
- in_format=ISM
- out_format=EXT
- ret_val=0
- - bash ci/complexity_measurements/getWmops.sh "ISM+1 ISM+2 ISM+3 ISM+4" "$out_format" mem_only basop latest_WMOPS.csv || ret_val=$?
+ - bash ci/complexity_measurements/getWmops.sh "ISM+1 ISM+2 ISM+3 ISM+4" "$out_format" $GET_WMOPS_ARGS || ret_val=$?
- *complexity-measurements-prepare-artifacts
- exit $ret_val
@@ -1715,11 +1743,13 @@ complexity-sba-hoa3-in-hoa3-out:
- if: $MEASURE_COMPLEXITY_LINUX
when: delayed
start_in: 4 hours 30 minutes
+ variables:
+ JOB_ID_INJECT: ""
script:
- in_format=HOA3
- out_format=HOA3
- ret_val=0
- - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" mem_only basop latest_WMOPS.csv || ret_val=$?
+ - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" $GET_WMOPS_ARGS || ret_val=$?
- *complexity-measurements-prepare-artifacts
- exit $ret_val
@@ -1730,11 +1760,13 @@ complexity-sba-hoa3-in-binaural-out:
- if: $MEASURE_COMPLEXITY_LINUX
when: delayed
start_in: 5 hours 30 minutes
+ variables:
+ JOB_ID_INJECT: ""
script:
- in_format=HOA3
- out_format=BINAURAL
- ret_val=0
- - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" mem_only basop latest_WMOPS.csv || ret_val=$?
+ - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" $GET_WMOPS_ARGS || ret_val=$?
- *complexity-measurements-prepare-artifacts
- exit $ret_val
@@ -1745,11 +1777,13 @@ complexity-sba-hoa3-in-binaural_room_ir-out:
- if: $MEASURE_COMPLEXITY_LINUX
when: delayed
start_in: 6 hours 30 minutes
+ variables:
+ JOB_ID_INJECT: ""
script:
- in_format=HOA3
- out_format=BINAURAL_ROOM_IR
- ret_val=0
- - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" mem_only basop latest_WMOPS.csv || ret_val=$?
+ - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" $GET_WMOPS_ARGS || ret_val=$?
- *complexity-measurements-prepare-artifacts
- exit $ret_val
@@ -1760,11 +1794,13 @@ complexity-mc-in-7_1_4-out:
- if: $MEASURE_COMPLEXITY_LINUX
when: delayed
start_in: 7 hours 30 minutes
+ variables:
+ JOB_ID_INJECT: ""
script:
- in_format=MC
- out_format=7_1_4
- ret_val=0
- - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" mem_only basop latest_WMOPS.csv || ret_val=$?
+ - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" $GET_WMOPS_ARGS || ret_val=$?
- *complexity-measurements-prepare-artifacts
- exit $ret_val
@@ -1775,11 +1811,13 @@ complexity-mc-in-binaural-out:
- if: $MEASURE_COMPLEXITY_LINUX
when: delayed
start_in: 10 hours
+ variables:
+ JOB_ID_INJECT: ""
script:
- in_format=MC
- out_format=BINAURAL
- ret_val=0
- - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" mem_only basop latest_WMOPS.csv || ret_val=$?
+ - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" $GET_WMOPS_ARGS || ret_val=$?
- *complexity-measurements-prepare-artifacts
- exit $ret_val
@@ -1790,11 +1828,13 @@ complexity-mc-in-binaural_room_ir-out:
- if: $MEASURE_COMPLEXITY_LINUX
when: delayed
start_in: 12 hours 30 minutes
+ variables:
+ JOB_ID_INJECT: ""
script:
- in_format=MC
- out_format=BINAURAL_ROOM_IR
- ret_val=0
- - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" mem_only basop latest_WMOPS.csv || ret_val=$?
+ - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" $GET_WMOPS_ARGS || ret_val=$?
- *complexity-measurements-prepare-artifacts
- exit $ret_val
@@ -1805,11 +1845,13 @@ complexity-masa-in-ext-out:
- if: $MEASURE_COMPLEXITY_LINUX
when: delayed
start_in: 15 hours
+ variables:
+ JOB_ID_INJECT: ""
script:
- in_format=MASA
- out_format=EXT
- ret_val=0
- - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" mem_only basop latest_WMOPS.csv || ret_val=$?
+ - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" $GET_WMOPS_ARGS || ret_val=$?
- *complexity-measurements-prepare-artifacts
- exit $ret_val
@@ -1820,11 +1862,13 @@ complexity-masa-in-binaural-out:
- if: $MEASURE_COMPLEXITY_LINUX
when: delayed
start_in: 16 hours
+ variables:
+ JOB_ID_INJECT: ""
script:
- in_format=MASA
- out_format=BINAURAL
- ret_val=0
- - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" mem_only basop latest_WMOPS.csv || ret_val=$?
+ - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" $GET_WMOPS_ARGS || ret_val=$?
- *complexity-measurements-prepare-artifacts
- exit $ret_val
@@ -1835,11 +1879,13 @@ complexity-masa-in-hoa3-out:
- if: $MEASURE_COMPLEXITY_LINUX
when: delayed
start_in: 17 hours
+ variables:
+ JOB_ID_INJECT: ""
script:
- in_format=MASA
- out_format=HOA3
- ret_val=0
- - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" mem_only basop latest_WMOPS.csv || ret_val=$?
+ - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" $GET_WMOPS_ARGS || ret_val=$?
- *complexity-measurements-prepare-artifacts
- exit $ret_val
@@ -1850,11 +1896,13 @@ 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
# - ret_val=0
-# - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" mem_only basop latest_WMOPS.csv || ret_val=$?
+# - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" $GET_WMOPS_ARGS || ret_val=$?
# - *complexity-measurements-prepare-artifacts
# - exit $ret_val
@@ -1865,11 +1913,13 @@ complexity-omasa-in-binaural-out:
- if: $MEASURE_COMPLEXITY_LINUX
when: delayed
start_in: 18 hours
+ variables:
+ JOB_ID_INJECT: ""
script:
- in_format=OMASA
- out_format=BINAURAL
- ret_val=0
- - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" mem_only basop latest_WMOPS.csv || ret_val=$?
+ - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" $GET_WMOPS_ARGS || ret_val=$?
- *complexity-measurements-prepare-artifacts
- exit $ret_val
@@ -1880,11 +1930,13 @@ complexity-omasa-in-hoa3-out:
- if: $MEASURE_COMPLEXITY_LINUX
when: delayed
start_in: 20 hours
+ variables:
+ JOB_ID_INJECT: ""
script:
- in_format=OMASA
- out_format=HOA3
- ret_val=0
- - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" mem_only basop latest_WMOPS.csv || ret_val=$?
+ - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" $GET_WMOPS_ARGS || ret_val=$?
- *complexity-measurements-prepare-artifacts
- exit $ret_val
@@ -1895,11 +1947,13 @@ complexity-StereoDmxEVS-stereo-in-mono-out:
- if: $MEASURE_COMPLEXITY_LINUX
when: delayed
start_in: 22 hours
+ variables:
+ JOB_ID_INJECT: ""
script:
- in_format=StereoDmxEVS
- out_format=mono
- ret_val=0
- - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" mem_only basop latest_WMOPS.csv || ret_val=$?
+ - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" $GET_WMOPS_ARGS || ret_val=$?
- *complexity-measurements-prepare-artifacts
- exit $ret_val
@@ -1914,7 +1968,7 @@ complexity-StereoDmxEVS-stereo-in-mono-out:
# - in_format=OSBA
# - out_format=EXT
# - ret_val=0
-# - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" mem_only basop latest_WMOPS.csv || ret_val=$?
+# - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" $GET_WMOPS_ARGS || ret_val=$?
# - *complexity-measurements-prepare-artifacts
# - exit $ret_val
@@ -1925,11 +1979,13 @@ complexity-osba-in-binaural-out:
- if: $MEASURE_COMPLEXITY_LINUX
when: delayed
start_in: 22 hours 30 minutes
+ variables:
+ JOB_ID_INJECT: ""
script:
- in_format=OSBA
- out_format=BINAURAL
- ret_val=0
- - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" mem_only basop latest_WMOPS.csv || ret_val=$?
+ - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" $GET_WMOPS_ARGS || ret_val=$?
- *complexity-measurements-prepare-artifacts
- exit $ret_val
@@ -1940,11 +1996,13 @@ complexity-osba-in-binaural_room_ir-out:
- if: $MEASURE_COMPLEXITY_LINUX
when: delayed
start_in: 25 hours
+ variables:
+ JOB_ID_INJECT: ""
script:
- in_format=OSBA
- out_format=BINAURAL_ROOM_IR
- ret_val=0
- - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" mem_only basop latest_WMOPS.csv || ret_val=$?
+ - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" $GET_WMOPS_ARGS || ret_val=$?
- *complexity-measurements-prepare-artifacts
- exit $ret_val
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 384fb8bb1855a74c55dcab5b3087c521a642062f..1a706cfebcc68923213296a43539b02069099335 100644
--- a/Workspace_msvc/lib_enc.vcxproj
+++ b/Workspace_msvc/lib_enc.vcxproj
@@ -229,6 +229,7 @@
+
@@ -238,13 +239,6 @@
-
-
-
-
-
-
-
@@ -278,28 +272,13 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -331,7 +310,6 @@
-
@@ -403,77 +381,33 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Workspace_msvc/lib_enc.vcxproj.filters b/Workspace_msvc/lib_enc.vcxproj.filters
index 2476cdb6cf5fa921fe54ffb28616676ae9849a81..907b5b9451f6332fadef2da2d80d0b67e5b8a712 100644
--- a/Workspace_msvc/lib_enc.vcxproj.filters
+++ b/Workspace_msvc/lib_enc.vcxproj.filters
@@ -19,12 +19,6 @@
enc_ivas_c
-
- enc_evs_c
-
-
- enc_evs_c
-
enc_evs_c
@@ -58,21 +52,9 @@
enc_evs_c
-
- enc_evs_c
-
-
- enc_evs_c
-
-
- enc_evs_c
-
enc_evs_c
-
- enc_evs_c
-
enc_evs_c
@@ -85,51 +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
-
-
- enc_all_c
-
-
- enc_all_c
-
-
- enc_all_c
-
-
- enc_all_c
-
enc_all_c
@@ -193,36 +138,9 @@
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
@@ -238,12 +156,6 @@
enc_all_c
-
- enc_all_c
-
-
- enc_all_c
-
enc_all_c
@@ -310,12 +222,6 @@
enc_all_c
-
- enc_all_c
-
-
- enc_all_c
-
enc_all_c
@@ -325,120 +231,17 @@
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
-
-
- enc_all_c
-
-
- enc_all_c
-
-
- enc_all_c
-
-
- enc_all_c
-
-
- enc_all_c
-
-
- enc_all_c
-
-
enc_all_c
enc_evs_c
-
- enc_evs_c
-
-
- enc_ivas_c
-
enc_ivas_c
@@ -454,9 +257,6 @@
enc_ivas_c
-
- enc_ivas_c
-
enc_ivas_c
@@ -1013,6 +813,9 @@
enc_evs_c
+
+ enc_ivas_c
+
diff --git a/apps/encoder.c b/apps/encoder.c
index a1b7f0d10118e6e9388a5313036ac7c37a8ceeb0..b06b5de0deaa24584551e1902907b92124e18085 100644
--- a/apps/encoder.c
+++ b/apps/encoder.c
@@ -353,6 +353,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
*------------------------------------------------------------------------------------------*/
@@ -998,7 +1007,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
}
i += 2;
@@ -1919,10 +1945,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..cef466471db4f1d2d9602c057a0f60a77e888c45 100644
--- a/lib_com/basop_util.c
+++ b/lib_com/basop_util.c
@@ -306,11 +306,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 +322,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 +338,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 +361,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 +374,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;
}
@@ -439,11 +421,7 @@ static Word32 ISqrt32_common( Word32 m,
assert( m >= 0x40000000 );
-#ifdef BASOP_NOGLOB
m16 = round_fx_o( m, &Overflow );
-#else
- m16 = round_fx( m );
-#endif
/* get table index (upper 6 bits minus 32) */
/* index = (m16 >> 25) - 32; */
@@ -676,13 +654,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 +902,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 +1405,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 +1448,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 +1636,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 +1733,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 +2168,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 +2339,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();
}
}
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/cldfb.c b/lib_com/cldfb.c
index 480f7e5d630c1e797e4645287a6bdf0abbffa316..5a3d2e1a27b1fd60aba746579f8bc5cee346fe1e 100644
--- a/lib_com/cldfb.c
+++ b/lib_com/cldfb.c
@@ -437,11 +437,11 @@ void cldfbAnalysis_ts_fx(
i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // q
i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // q
- i2_fx = Msub_32_16( 0, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // q
- i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // q
- i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // q
- i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // q
- i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // q
+ i2_fx = Msub_32_16( 0, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )] ); // q
+ i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )] ); // q
+ i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )] ); // q
+ i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )] ); // q
+ i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )] ); // q
r1_fx = Mpy_32_16_1( r1_fx, ptr_pf_sf ); // q - 1
r2_fx = Mpy_32_16_1( r2_fx, ptr_pf_sf ); // q - 1
@@ -569,6 +569,278 @@ void cldfbAnalysis_ts_fx(
return;
}
+void cldfbAnalysis_ts_fx_var_q(
+ const Word32 *timeIn_fx,
+ /* i : time buffer */ // q
+ Word32 realBuffer_fx[CLDFB_NO_CHANNELS_MAX],
+ /* o : real value buffer */ // q_cldfb - 5
+ Word32 imagBuffer_fx[CLDFB_NO_CHANNELS_MAX],
+ /* o : imag value buffer */ // q_cldfb - 5
+ const Word16 samplesToProcess, /* i : samples to process */
+ HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i : filterbank state */
+ Word16 *q_cldfb )
+
+{
+ Word16 i, k;
+ Word16 L2, M1, M2, M4;
+ Word16 no_col = h_cldfb->no_col;
+ move16();
+ Word32 r1_fx, r2_fx, rr12_fx, ir12_fx;
+ Word32 i1_fx, i2_fx, ri12_fx, ii12_fx;
+ Word32 rBuffer_fx[2 * CLDFB_NO_CHANNELS_MAX];
+ Word32 iBuffer_fx[2 * CLDFB_NO_CHANNELS_MAX];
+ const Word32 *rot_vctr_re_fx;
+ const Word32 *rot_vctr_im_fx;
+ const Word32 *rot_vctr_delay_re_fx;
+ const Word32 *rot_vctr_delay_im_fx;
+ const Word16 *ptr_pf_fx;
+ Word16 ptr_pf_sf;
+ Word32 *timeBuffer_fx, buffer_fx[( CLDFB_NO_CHANNELS_MAX * CLDFB_NO_COL_MAX ) + ( 9 * CLDFB_NO_CHANNELS_MAX )];
+ Word16 offset, frameSize;
+
+ offset = sub( h_cldfb->p_filter_length, h_cldfb->no_channels );
+ frameSize = i_mult( h_cldfb->no_channels, h_cldfb->no_col );
+
+ /* prepare input buffer */
+ timeBuffer_fx = buffer_fx;
+ Copy32( h_cldfb->cldfb_state_fx, timeBuffer_fx, offset );
+
+ IF( GT_16( samplesToProcess, -1 ) )
+ {
+ Copy32( timeIn_fx, timeBuffer_fx + offset, samplesToProcess );
+ set32_fx( timeBuffer_fx + add( offset, samplesToProcess ), 0, sub( frameSize, samplesToProcess ) );
+ }
+ ELSE
+ {
+ Copy32( timeIn_fx, timeBuffer_fx + offset, frameSize );
+ }
+
+ IF( NE_16( h_cldfb->Q_cldfb_state, *q_cldfb ) )
+ {
+ Word16 norm_st = L_norm_arr( timeBuffer_fx, offset );
+ IF( GE_16( norm_st, sub( *q_cldfb, h_cldfb->Q_cldfb_state ) ) )
+ {
+ scale_sig32( timeBuffer_fx, offset, sub( *q_cldfb, h_cldfb->Q_cldfb_state ) );
+ /* cldfb_state will get updated at end of processing with values whose q is same as
+ * *q_cldfb.
+ */
+ h_cldfb->Q_cldfb_state = *q_cldfb;
+ move16();
+ }
+ ELSE
+ {
+ scale_sig32( &timeBuffer_fx[offset], frameSize, sub( h_cldfb->Q_cldfb_state, *q_cldfb ) );
+ *q_cldfb = h_cldfb->Q_cldfb_state;
+ move16();
+ }
+ }
+
+ /* only process needed cols */
+ IF( GT_16( samplesToProcess, -1 ) )
+ {
+ no_col = s_min( no_col, idiv1616( sub( add( samplesToProcess, h_cldfb->no_channels ), 1 ), h_cldfb->no_channels ) );
+ assert( no_col == 1 );
+ }
+
+ M1 = h_cldfb->no_channels;
+ M2 = shr( M1, 1 );
+ M4 = shr( M1, 2 );
+ L2 = shl( M1, 1 );
+ move16();
+
+ if ( s_and( M2, 1 ) )
+ {
+ M4 = add( M4, 1 );
+ }
+
+ rot_vctr_re_fx = h_cldfb->rot_vec_ana_re_fx; // q = 29
+ rot_vctr_im_fx = h_cldfb->rot_vec_ana_im_fx; // q = 29
+ rot_vctr_delay_re_fx = h_cldfb->rot_vec_ana_delay_re_fx; // q = 31
+ rot_vctr_delay_im_fx = h_cldfb->rot_vec_ana_delay_im_fx; // q = 31
+
+ ptr_pf_fx = h_cldfb->p_filter;
+ ptr_pf_sf = h_cldfb->p_filter_sf; // Q14
+ move16();
+
+ FOR( i = 0; i < no_col; i++ )
+ {
+ FOR( k = 0; k < M4; k++ )
+ {
+ /* prototype filter */
+ r1_fx = Msub_32_16( 0, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // q
+ r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // q
+ r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // q
+ r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // q
+ r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // q
+
+ r2_fx = Msub_32_16( 0, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 0 * L2 )] ); // q
+ r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 1 * L2 )] ); // q
+ r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 2 * L2 )] ); // q
+ r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 3 * L2 )] ); // q
+ r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 4 * L2 )] ); // q
+
+ i1_fx = Msub_32_16( 0, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )] ); // q
+ i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )] ); // q
+ i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )] ); // q
+ i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )] ); // q
+ i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )] ); // q
+
+ i2_fx = Msub_32_16( 0, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // q
+ i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // q
+ i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // q
+ i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // q
+ i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // q
+
+ r1_fx = Mpy_32_16_1( r1_fx, ptr_pf_sf ); // q - 1
+ r2_fx = Mpy_32_16_1( r2_fx, ptr_pf_sf ); // q - 1
+ i1_fx = Mpy_32_16_1( i1_fx, ptr_pf_sf ); // q - 1
+ i2_fx = Mpy_32_16_1( i2_fx, ptr_pf_sf ); // q - 1
+
+ /* folding + pre modulation of DST IV */
+ rr12_fx = L_sub( r1_fx, r2_fx ); // q -1
+ ri12_fx = L_negate( L_add( i1_fx, i2_fx ) ); // q - 1
+ /*cplxMult(&rBuffer[2*k],&rBuffer[2*k+1],rr12,ri12,rot_vctr_re[k],rot_vctr_im[k]);*/
+ rBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), ri12_fx, rot_vctr_im_fx[k] ); // q - 3
+ rBuffer_fx[2 * k + 1] = Madd_32_32( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), ri12_fx, rot_vctr_re_fx[k] ); // q - 3
+ move32();
+ move32();
+
+ ///* folding + pre modulation of DCT IV */
+ ir12_fx = L_add( r1_fx, r2_fx ); // q - 1
+ ii12_fx = L_sub( i1_fx, i2_fx ); // q - 1
+ /*cplxMult(&iBuffer[2*k],&iBuffer[2*k+1],ir12,ii12,rot_vctr_re[k],rot_vctr_im[k]);*/
+ iBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), ii12_fx, rot_vctr_im_fx[k] ); // q - 3
+ iBuffer_fx[2 * k + 1] = Madd_32_32( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), ii12_fx, rot_vctr_re_fx[k] ); // q - 3
+ move32();
+ move32();
+ }
+
+ FOR( k = M4; k < M2; k++ )
+ {
+ /* prototype filter */
+ r1_fx = Msub_32_16( 0, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // q
+ r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // q
+ r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // q
+ r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // q
+ r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // q
+
+ r2_fx = Msub_32_16( 0, timeBuffer_fx[( L2 - 5 * M2 + ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 0 * L2 )] ); // q
+ r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[( L2 - 5 * M2 + ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 1 * L2 )] ); // q
+ r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[( L2 - 5 * M2 + ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 2 * L2 )] ); // q
+ r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[( L2 - 5 * M2 + ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 3 * L2 )] ); // q
+ r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[( L2 - 5 * M2 + ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 4 * L2 )] ); // q
+
+ i1_fx = Msub_32_16( 0, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // q
+ i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // q
+ i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // q
+ i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // q
+ i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // q
+
+ i2_fx = Msub_32_16( 0, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )] ); // q
+ i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )] ); // q
+ i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )] ); // q
+ i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )] ); // q
+ i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )] ); // q
+
+ r1_fx = Mpy_32_16_1( r1_fx, ptr_pf_sf ); // q - 1
+ r2_fx = Mpy_32_16_1( r2_fx, ptr_pf_sf ); // q - 1
+ i1_fx = Mpy_32_16_1( i1_fx, ptr_pf_sf ); // q - 1
+ i2_fx = Mpy_32_16_1( i2_fx, ptr_pf_sf ); // q - 1
+
+ /* folding + pre modulation of DST IV */
+ rr12_fx = L_add( r1_fx, r2_fx ); // q - 1
+ ri12_fx = L_sub( i1_fx, i2_fx ); // q - 1
+ /*cplxMult(&rBuffer[2*k],&rBuffer[2*k+1],rr12,ri12,rot_vctr_re[k],rot_vctr_im[k]);*/
+ rBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), ri12_fx, rot_vctr_im_fx[k] ); // q - 3
+ rBuffer_fx[2 * k + 1] = Madd_32_32( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), ri12_fx, rot_vctr_re_fx[k] ); // q - 3
+ move32();
+ move32();
+
+ /* folding + pre modulation of DCT IV */
+ ir12_fx = L_sub( r1_fx, r2_fx ); // q - 1
+ ii12_fx = L_add( i1_fx, i2_fx ); // q - 1
+ /*cplxMult(&iBuffer[2*k],&iBuffer[2*k+1],ir12,ii12,rot_vctr_re[k],rot_vctr_im[k]);*/
+ iBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), ii12_fx, rot_vctr_im_fx[k] ); // q - 3
+ iBuffer_fx[2 * k + 1] = Madd_32_32( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), ii12_fx, rot_vctr_re_fx[k] ); // q - 3
+ move32();
+ move32();
+ }
+
+ *q_cldfb = sub( *q_cldfb, 3 );
+ move16();
+
+ /* FFT of DST IV */
+ fft_cldfb_fx( rBuffer_fx, M2 );
+
+ /* post modulation of DST IV */
+ FOR( k = 0; k < M2; k++ )
+ {
+ /*cplxMult(&realBuffer[M1-1-(2*k)],&realBuffer[2*k],rBuffer[2*k],rBuffer[2*k+1],rot_vctr_re[k],rot_vctr_im[k]);*/
+ realBuffer_fx[( M1 - 1 ) - ( k * 2 )] = Msub_32_32( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_re_fx[k] ), rBuffer_fx[2 * k + 1], rot_vctr_im_fx[k] ); // q - 5
+ realBuffer_fx[2 * k] = Madd_32_32( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_im_fx[k] ), rBuffer_fx[2 * k + 1], rot_vctr_re_fx[k] ); // q - 5
+ move32();
+ move32();
+ }
+ *q_cldfb = sub( *q_cldfb, 2 );
+ move16();
+
+ /* FFT of DCT IV */
+ fft_cldfb_fx( iBuffer_fx, M2 );
+
+ /* post modulation of DCT IV */
+ FOR( k = 0; k < M2; k++ )
+ {
+ /* do it inplace */
+ /*cplxMult(&imagBuffer[2*k],&imagBuffer[M1-1-(2*k)],iBuffer[2*k],iBuffer[2*k+1],rot_vctr_re[k],rot_vctr_im[k]);*/
+ imagBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_re_fx[k] ), iBuffer_fx[2 * k + 1], rot_vctr_im_fx[k] ); // q - 5
+ imagBuffer_fx[( M1 - 1 ) - ( k * 2 )] = Madd_32_32( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_im_fx[k] ), iBuffer_fx[2 * k + 1], rot_vctr_re_fx[k] ); // q - 5
+ move32();
+ move32();
+ }
+
+ IF( EQ_32( h_cldfb->prototype, CLDFB_PROTOTYPE_5_00MS ) )
+ {
+ /* rotation due to delay*/
+ /*if(h_cldfb->da != M1)*/
+ IF( rot_vctr_delay_re_fx != NULL )
+ {
+ FOR( k = 0; k < M1; k++ )
+ {
+ Word32 cplx_aux_fx;
+ /* delay */
+ /*cplxMult(&rBuffer[k], &iBuffer[k], realBuffer[i][k], imagBuffer[i][k], cos((EVS_PI/M1)*(k+0.5)*((h_cldfb->da-M1)*0.5)),
+ sin((EVS_PI/M1)*(k+0.5)*((h_cldfb->da-M1)*0.5)));*/
+ /*cplxMult(&rBuffer[k], &iBuffer[k], realBuffer[k], imagBuffer[k], rot_vctr_delay_re[k], rot_vctr_delay_im[k]);*/
+ /*cplxMult(&realBuffer[k], &imagBuffer[k], realBuffer[k], imagBuffer[k], rot_vctr_delay_re[k], rot_vctr_delay_im[k]);*/
+ /*realBuffer[k] = rBuffer[k];
+ imagBuffer[k] = iBuffer[k];*/
+ cplx_aux_fx = Msub_32_32( Mpy_32_32( realBuffer_fx[k], rot_vctr_delay_re_fx[k] ), imagBuffer_fx[k], rot_vctr_delay_im_fx[k] ); // q - 5
+ imagBuffer_fx[k] = Madd_32_32( Mpy_32_32( realBuffer_fx[k], rot_vctr_delay_im_fx[k] ), imagBuffer_fx[k], rot_vctr_delay_re_fx[k] ); // q - 5
+ realBuffer_fx[k] = cplx_aux_fx;
+ move32();
+ move32();
+ }
+ }
+ }
+
+ timeBuffer_fx += i_mult( L2, 5 );
+ timeBuffer_fx += sub( h_cldfb->no_channels, h_cldfb->p_filter_length );
+ }
+
+ /* update memory */
+ IF( GT_16( samplesToProcess, -1 ) )
+ {
+ Copy32( buffer_fx + samplesToProcess, h_cldfb->cldfb_state_fx, offset );
+ }
+ ELSE
+ {
+ Copy32( buffer_fx + frameSize, h_cldfb->cldfb_state_fx, offset );
+ }
+
+ return;
+}
+
+
void cldfbAnalysis_ts_fx_fixed_q(
const Word32 *timeIn_fx,
/* i : time buffer */ // q
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 f346f3bb3e4a39ac08c5fe664f3d06f9ba6967d7..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.
@@ -866,7 +794,7 @@ void cng_params_postupd_ivas_fx(
apply_scale( &att_fx, bwidth, last_active_brate, scaleTableStereo, SIZE_SCALE_TABLE_STEREO );
att_fx = L_shr( Mpy_32_16_1( att_fx, 26214 ), 3 ); /* 26214 = 0.1f in Q18 */
att_fx = BASOP_Util_fPow( 1342177280 /* 10 in Q27 */, 4, att_fx, 8, &tmp );
- tmp = extract_h( L_shl( att_fx, tmp ) );
+ tmp = extract_h( L_shl_sat( att_fx, tmp ) ); // Fix for 3gpp #1080 (tmp set to 1.0)
}
ELSE
{
@@ -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 7e65723827fc815ad4a78a1bf7d85249c22661a7..66b6dc9a15d2f74cffce30849e79c01572b3fc3f 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
@@ -747,15 +754,15 @@ enum
#define PIT_UP_SAMP6 6
#define PIT_L_INTERPOL6_2 17
#define PIT_FIR_SIZE6_2 ( PIT_UP_SAMP6 * PIT_L_INTERPOL6_2 + 1 )
-#define E_MIN_Q11_FX 7 /* minimum allowable energy in Q11*/
#define E_MIN 0.0035f /* minimum allowable energy */
#define E_MIN_Q11_FX 7 /* minimum allowable energy in Q11*/
-#define E_MIN_Q16_FX 229 /* minimum allowable energy in Q16*/
#define STEP_DELTA 0.0625f /* quantization step for tilt compensation of gaussian cb. excitation */
#define GAMMA_EV 0.92f /* weighting factor for core synthesis error weighting */
#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 */
@@ -1937,7 +1944,7 @@ typedef enum _DCTTYPE
#define N_SMC_FEATURES 15 /* number of features */
#define N_SMC_MIXTURES 6 /* number of mixtures */
#define N_PCA_COEF 12 /* number of PCA components */
-#define HALF_N_PCA_COEF_LOG_P12_Q19 5781461//Q19 of (0.5f * N_PCA_COEF *logf( PI2 ))
+#define HALF_N_PCA_COEF_LOG_P12_Q18 2890731 //Q18 of (0.5f * N_PCA_COEF *logf( PI2 ))
#define SMC_ST_MEAN_FACT 0.5 /* forgetting factor of short-term IIR mean filter */
#define SMC_ST_MEAN_RSHIFT_FACT_FX 1 /* SMC_ST_MEAN_FACT equivalent right shift factor */
@@ -2776,6 +2783,7 @@ enum
#define MU_MA_FX 10923 /* original prediction factor for the AMR WB tables (Q15) */
#define E_MIN_FXQ15 115 /* Q15*/
+#define E_MIN_FXQ31 7516193 /* 0.0035d in Q31*/
#define MAX_DYNAMIC_FX (82*128)
#define MIN_DYNAMIC_FX (50*128)
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 28a5ed44adb89fe0d83c735cf750ce43c3ea0fc3..8d77da13a7eb7df052bb309302e7f19bdef81432 100644
--- a/lib_com/edct_fx.c
+++ b/lib_com/edct_fx.c
@@ -228,6 +228,67 @@ void edct_fx(
return;
}
+void edct_ivas_fx(
+ const Word32 *x, /* i : input signal Qq */
+ Word32 *y, /* o : output transform Qq */
+ Word16 length, /* i : length Q0*/
+ Word16 *q /* i : Q value of input signal */
+)
+{
+ Word16 i;
+ const Word16 *edct_table; /*Q16 */
+ Word32 re[L_FRAME_PLUS / 2];
+ Word32 im[L_FRAME_PLUS / 2];
+ Word32 L_tmp;
+ Word16 tmp;
+ Word16 len1;
+
+ edct_table = get_edct_table( length, q ); /*q*/
+ len1 = shr( length, 1 ); /*Q0*/
+ /* Twiddling and Pre-rotate */
+ FOR( i = 0; i < len1; i++ )
+ {
+ L_tmp = Mult_32_16( x[2 * i], edct_table[i] ); /*Q(q+1) */
+ re[i] = Madd_32_16( L_tmp, x[( length - ( 1 + ( i * 2 ) ) )], edct_table[( len1 - ( 1 + i ) )] ); /*Q(q+1) */
+ move32();
+
+ L_tmp = Mult_32_16( x[( length - ( 1 + ( i * 2 ) ) )], edct_table[i] ); /*Q(q+1) */
+ im[i] = Msub_32_16( L_tmp, x[( i * 2 )], edct_table[( len1 - ( 1 + i ) )] ); /*Q(q+1) */
+ move32();
+ }
+
+ *q = sub( 31, *q );
+ move16();
+ tmp = sub( s_min( getScaleFactor32( re, len1 ), getScaleFactor32( im, len1 ) ), find_guarded_bits_fx( len1 ) );
+ scale_sig32( re, len1, tmp );
+ scale_sig32( im, len1, tmp );
+
+ fft_fx( re, im, len1, 1 );
+ *q = sub( *q, tmp );
+ move16();
+
+ tmp = div_s( 4, length ); /*Q17 */
+ tmp = round_fx( L_mult( tmp, 19302 /*0.75f * EVS_PI in Q13*/ ) ); /*Q15 */
+ FOR( i = 0; i < len1; i++ )
+ {
+ L_tmp = Msub_32_16( re[i], im[i], tmp );
+ im[i] = Madd_32_16( im[i], re[i], tmp ); /*Q(q+1) */
+ re[i] = L_tmp; /*Q(q+1) */
+ move32();
+ move32();
+ }
+ FOR( i = 0; i < len1; i++ )
+ {
+ y[2 * i] = L_add( Mult_32_16( re[i], edct_table[i] ), Mult_32_16( im[i], edct_table[( len1 - ( 1 + i ) )] ) ); /*Q(q+2)*/
+ move32();
+ y[( length - ( 1 + ( i * 2 ) ) )] = L_sub( Mult_32_16( re[i], edct_table[( len1 - ( 1 + i ) )] ), Mult_32_16( im[i], edct_table[i] ) ); /*Q(q+2)*/
+ move32();
+ } /*Q(q-2) */
+
+ *q = sub( 31 + 2, *q );
+ move16();
+ return;
+}
/*-------------------------------------------------------------------------*
* FUNCTION : edst_fx()
*
@@ -396,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--;
@@ -437,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 */
@@ -463,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.c b/lib_com/fft_fx.c
index c4237bcc9b2efce09f1c19e027f163bfcd63c2b0..ba895d83c85f9b0f71100e94f7616a59e0d6fa94 100644
--- a/lib_com/fft_fx.c
+++ b/lib_com/fft_fx.c
@@ -7257,7 +7257,7 @@ Word16 find_guarded_bits_fx( Word32 n )
}
}
-Word16 L_norm_arr( Word32 *arr, Word16 size )
+Word16 L_norm_arr( const Word32 *arr, Word16 size )
{
Word16 q = 31;
move16();
@@ -7282,6 +7282,26 @@ Word16 L_norm_arr( Word32 *arr, Word16 size )
return q;
}
+Word16 norm_arr( Word16 *arr, Word16 size )
+{
+ Word16 q = 15;
+ Word16 exp = 0;
+ move16();
+ move16();
+ FOR( Word16 i = 0; i < size; i++ )
+ {
+ if ( arr[i] != 0 )
+ {
+ exp = norm_s( arr[i] );
+ }
+ if ( arr[i] != 0 )
+ {
+ q = s_min( q, exp );
+ }
+ }
+ return q;
+}
+
Word16 get_min_scalefactor( Word32 x, Word32 y )
{
#ifndef FIX_1104_OPT_GETMINSCALEFAC
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..85d0ae76a6e87bc28c3ea04e27d5d26d19a4d3c6 100644
--- a/lib_com/fft_rel.c
+++ b/lib_com/fft_rel.c
@@ -361,17 +361,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 +401,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 +418,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/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..5dfe6b1d60d0b91bd4af72426e6c728581063cd7 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++;
}
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..998f3f0488df977c48603fd05d53d9d829be6293 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
}
}
@@ -2216,14 +2167,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 +2186,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 +2194,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 +2206,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 +2246,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 +2385,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 +2405,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 +2463,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 +2472,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 1cc4f2a8e5411270f718867305ad9cf01da3002d..1fe54d164d6c56450486d840bb33e73efbd159f3 100644
--- a/lib_com/ivas_cnst.h
+++ b/lib_com/ivas_cnst.h
@@ -53,7 +53,7 @@
#define PI_OVER_180_Q25 ( 585635 ) // Q25
#define _180_IN_Q22 ( 754974720 ) // Q22
#define _360_IN_Q22 ( 1509949440 ) // Q22
-#define _180_OVER_PI_FX ( (Word32) ( ( 180.0f / EVS_PI ) * ONE_IN_Q10 ) )
+#define _180_OVER_PI_FX ( 58670 ) // Q10
#define PI_OVER_180_Q15 ( 572 ) // Q15
#define _180_OVER_PI_Q9 ( 29335 ) // Q9
#define PI_OVER_4_Q29 ( 421657440 ) // Q29
@@ -61,7 +61,7 @@
#define PI_OVER_Q29 ( 1686629760 ) // Q29
#define Q31_0_99 ( 2126008811 ) // Q31
#define Q31_0_01 ( 21474836 ) // Q31
-#define PI_OVER_180_FX ( (Word32) ( ( EVS_PI / 180.0f ) * ONE_IN_Q31 ) ) // Q31
+#define PI_OVER_180_FX ( 37480660 ) // Q31
#define PI_OVER_4_Q29 ( 421657440 ) // Q29
#define PI_OVER_Q29 ( 1686629760 ) // Q29
#define PI2_C_ADP_RATE_Q31 ( 449767936 ) // Q31 (2.0f * EVS_PI * pOTR->centerAdaptationRate)
@@ -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 138d86eaff789e0cbcf0e154dfb60d45b3637806..ebd958e1bc048b3bf303847e41e45fac74076112 100644
--- a/lib_com/ivas_dirac_com.c
+++ b/lib_com/ivas_dirac_com.c
@@ -610,7 +610,12 @@ void computeDirectionVectors_fixed(
Word32 *direction_vector_x, /* o: Q30*/
Word32 *direction_vector_y, /* o: Q30*/
Word32 *direction_vector_z, /* o: Q30*/
- Word16 i_e /*Exponent of all the intensity buffers*/ )
+ Word16 i_e /*Exponent of all the intensity buffers*/
+#ifdef NONBE_IMPROVE_DIRAC_INTENSITY_PREC
+ ,
+ Word16 *i_e_band
+#endif
+)
{
Word16 i;
Word32 intensityNorm;
@@ -628,9 +633,25 @@ void computeDirectionVectors_fixed(
scaled_x = L_shl( *intensity_real_x, norm_x );
scaled_y = L_shl( *intensity_real_y, norm_y );
scaled_z = L_shl( *intensity_real_z, norm_z );
+#ifdef NONBE_IMPROVE_DIRAC_INTENSITY_PREC
+ IF( i_e_band != NULL )
+ {
+ e_x = sub( Q31, add( i_e_band[i - enc_param_start_band], norm_x ) );
+ 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
+ {
+ e_x = sub( i_e, norm_x );
+ e_y = sub( i_e, norm_y );
+ e_z = sub( i_e, norm_z );
+ }
+#else
+
e_x = sub( i_e, norm_x );
e_y = sub( i_e, norm_y );
e_z = sub( i_e, norm_z );
+#endif
temp1 = BASOP_Util_Add_Mant32Exp( Mult_32_32( scaled_x, scaled_x ), shl( e_x, 1 ), Mult_32_32( scaled_y, scaled_y ), shl( e_y, 1 ), &exp1 );
intensityNorm = BASOP_Util_Add_Mant32Exp( temp1, exp1, Mult_32_32( scaled_z, scaled_z ), shl( e_z, 1 ), &intensityNorm_e );
@@ -945,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();
}
}
@@ -996,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 7a7126490db82d87e25a8f2c7f077977b198387f..5ea7b076547372e12d874221962cc368301efabc 100644
--- a/lib_com/ivas_prot.h
+++ b/lib_com/ivas_prot.h
@@ -69,10 +69,10 @@ void stereo_dmx_evs_enc(
/*! r: number of channels to be analysed */
-void copy_encoder_config(
+void copy_encoder_config_ivas_fx(
Encoder_Struct *st_ivas, /* i : IVAS encoder structure */
Encoder_State *st, /* o : encoder state structure */
- const int16_t flag_all /* i : flag 1==update all, 0=partial update */
+ const Word16 flag_all /* i : flag 1==update all, 0=partial update Q0*/
);
@@ -83,36 +83,21 @@ 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 */
const int32_t element_brate /* i : element bitrate */
);
-ivas_error create_mct_enc(
- Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */
-);
-
-ivas_error ivas_sba_enc_reconfigure(
+ivas_error create_mct_enc_fx(
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 */
);
-void ivas_mct_enc_close(
+void ivas_mct_enc_close_fx(
MCT_ENC_HANDLE *hMCT /* i/o: MCT encoder structure */
);
@@ -200,94 +185,97 @@ ivas_error pre_proc_front_ivas(
ivas_error pre_proc_front_ivas_fx(
SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */
CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
- const Word32 element_brate, /* i : SCE/CPE element bitrate */
- const Word16 nb_bits_metadata, /* i : number of metadata bits */
- const Word16 input_frame, /* i : frame length */
- const Word16 n, /* i : channel number */
- Word16 old_inp_12k8_fx[], /* o : (Q-1) buffer of old input signal */
- Word16 old_inp_16k_fx[], /* o : buffer of old input signal @16kHz Q-1 */
- Word32 *ener_fx, /* o : residual energy from Levinson-Durbin Q_r */
- Word16 *relE_fx, /* o : frame relative energy Q8 */
- Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* o : A(z) unquantized for the 4 subframes */
- Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* o : weighted A(z) unquantized for subframes */
- Word32 epsP_fx[M + 1], /* o : LP prediction errors */
+ const Word32 element_brate, /* i : SCE/CPE element bitrate Q0*/
+ const Word16 nb_bits_metadata, /* i : number of metadata bits Q0*/
+ const Word16 input_frame, /* i : frame length Q0*/
+ const Word16 n, /* i : channel number Q0*/
+ Word16 old_inp_12k8_fx[], /* o : buffer of old input signal Q_new-1*/
+ Word16 old_inp_16k_fx[], /* o : buffer of old input signal @16kHz Q_new-1*/
+ Word32 *ener_fx, /* o : residual energy from Levinson-Durbin epsP_fx_q*/
+ Word16 *relE_fx, /* o : frame relative energy Q8*/
+ Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* o : A(z) unquantized for the 4 subframes Q12*/
+ Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* o : weighted A(z) unquantized for subframes Q12*/
+ Word32 epsP_fx[M + 1], /* o : LP prediction errors epsP_fx_q*/
Word16 *epsP_fx_q,
- Word16 lsp_new_fx[M], /* o : LSPs at the end of the frame Q15 */
- Word16 lsp_mid_fx[M], /* o : LSPs in the middle of the frame Q15 */
- Word16 *vad_hover_flag, /* o : VAD hangover flag */
- Word16 *attack_flag, /* o : flag signaling attack */
- Word32 realBuffer_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: real buffer Q(q_re_im_buf) */
- Word32 imagBuffer_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: imag buffer Q(q_re_im_buf) */
- Word16 *q_re_im_buf, /* i/o: Q-factor of real and imag buffer */
- Word16 old_wsp[], /* o : weighted input signal buffer q_old_wsp*/
+ Word16 lsp_new_fx[M], /* o : LSPs at the end of the frame Q15*/
+ Word16 lsp_mid_fx[M], /* o : LSPs in the middle of the frame Q15*/
+ Word16 *vad_hover_flag, /* o : VAD hangover flag Q0*/
+ Word16 *attack_flag, /* o : flag signaling attack Q0*/
+ Word32 realBuffer_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: real buffer Q(q_re_im_buf)*/
+ Word32 imagBuffer_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: imag buffer Q(q_re_im_buf)*/
+ Word16 *q_re_im_buf, /* i/o: Q-factor of real and imag buffer */
+ Word16 old_wsp_fx[], /* o : weighted input signal buffer q_old_wsp*/
Word16 *q_old_wsp,
- Word16 pitch_fr_fx[NB_SUBFR], /* o : fractional pitch values Q6 */
- Word16 voicing_fr_fx[NB_SUBFR], /* o : fractional pitch gains Q15 */
- Word16 *loc_harm, /* o : harmonicity flag */
- Word16 *cor_map_sum_fx, /* o : speech/music clasif. parameter Q8 */
- Word16 *vad_flag_dtx, /* o : HE-SAD flag with additional DTX HO */
- Word32 enerBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : energy buffer */
- Word16 *enerBuffer_fx_exp, /* o : energy buffer */
- Word16 fft_buff_fx[2 * L_FFT], /* o : FFT buffer */
- Word16 *fft_buff_fx_q, /* o : FFT buffer */
- const Word16 tdm_A_PCh_fx[M + 1], /* i : unq. LP coeff. of primary channel Q12 */
- const Word16 tdm_lsp_new_PCh_fx[M], /* i : unq. LSPs of primary channel Q15 */
- const Word16 currFlatness_fx, /* i : flatness parameter Q7 */
- const Word16 tdm_ratio_idx, /* i : Current Ratio_L index */
- Word32 fr_bands_LR_fx[][2 * NB_BANDS], /* i : energy in frequency bands (fr_bands_LR_fx_q) */
- Word16 fr_bands_LR_fx_q,
- const Word16 Etot_LR_fx[], /* i : total energy Left & Right channel Q8*/
- Word32 lf_E_LR_fx[][2 * VOIC_BINS], /* i : per bin spectrum energy in lf, LR channels (lf_E_LR_fx_q) */
+ Word16 pitch_fr_fx[NB_SUBFR], /* o : fractional pitch values Q6*/
+ Word16 voicing_fr_fx[NB_SUBFR], /* o : fractional pitch gains Q15*/
+ Word16 *loc_harm, /* o : harmonicity flag Q0*/
+ Word16 *cor_map_sum_fx, /* o : speech/music clasif. parameter Q8*/
+ Word16 *vad_flag_dtx, /* o : HE-SAD flag with additional DTX HO Q0*/
+ Word32 enerBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : energy buffer enerBuffer_fx_exp*/
+ Word16 *enerBuffer_fx_exp, /* o : energy buffer */
+ Word16 fft_buff_fx[2 * L_FFT], /* o : FFT buffer fft_buff_fx_q*/
+ Word16 *fft_buff_fx_q, /* o : FFT buffer */
+ const Word16 tdm_A_PCh_fx[M + 1], /* i : unq. LP coeff. of primary channel Q12*/
+ const Word16 tdm_lsp_new_PCh_fx[M], /* i : unq. LSPs of primary channel Q15*/
+ const Word16 currFlatness_fx, /* i : flatness parameter Q7*/
+ const Word16 tdm_ratio_idx, /* i : Current Ratio_L index Q0*/
+ Word32 fr_bands_LR_fx[][2 * NB_BANDS], /* i : energy in frequency bands (fr_bands_LR_fx_q) fr_bands_LR_fx_q*/
+ Word16 fr_bands_LR_fx_q[CPE_CHANNELS],
+ const Word16 Etot_LR_fx[], /* i : total energy Left & Right channel Q8*/
+ Word32 lf_E_LR_fx[][2 * VOIC_BINS], /* i : per bin spectrum energy in lf, LR channels (lf_E_LR_fx_q)*/
Word16 lf_E_LR_fx_q,
- const Word16 localVAD_HE_SAD_LR[], /* i : HE-SAD flag without hangover, LR channels */
- Word32 band_energies_LR_fx[2 * NB_BANDS], /* o : energy in critical bands without minimum noise floor E_MIN (band_energies_LR_fx_q) */
+ const Word16 localVAD_HE_SAD_LR[], /* i : HE-SAD flag without hangover, LR channels Q0*/
+ Word32 band_energies_LR_fx[2 * NB_BANDS], /* o : energy in critical bands without minimum noise floor E_MIN (band_energies_LR_fx_q)*/
Word16 band_energies_LR_fx_q,
- const Word16 flag_16k_smc, /* i : flag to indicate if the OL SMC is run at 16 kHz */
- const Word16 front_vad_flag, /* i : front-VAD flag to overwrite VAD decision */
- const Word16 force_front_vad, /* i : flag to force VAD decision */
- const Word16 front_vad_dtx_flag, /* i : front-VAD DTX flag to overwrite VAD decision*/
- const IVAS_FORMAT ivas_format, /* i : IVAS format */
- const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) */
- const Word32 ivas_total_brate, /* i : IVAS total bitrate - for setting the DTX */
+ const Word16 flag_16k_smc, /* i : flag to indicate if the OL SMC is run at 16 kHz Q0*/
+ const Word16 front_vad_flag, /* i : front-VAD flag to overwrite VAD decision Q0*/
+ const Word16 force_front_vad, /* i : flag to force VAD decision Q0*/
+ const Word16 front_vad_dtx_flag, /* i : front-VAD DTX flag to overwrite VAD decision Q0*/
+ const IVAS_FORMAT ivas_format, /* i : IVAS format */
+ const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/
+#ifdef NONBE_1211_DTX_BR_SWITCHING
+ const Word32 last_ivas_total_brate, /* i : last IVAS total bitrate Q0*/
+#endif
+ const Word32 ivas_total_brate, /* i : IVAS total bitrate - for setting the DTX Q0*/
Word16 *Q_new
#ifdef DEBUG_MODE_INFO
,
const Word16 ch_idx
#endif
);
-ivas_error pre_proc_ivas(
+ivas_error pre_proc_ivas_fx(
Encoder_State *st, /* i/o: encoder state structure */
- const Word16 last_element_mode, /* i : last element mode */
- const Word32 element_brate, /* i : element bitrate */
- const Word32 last_element_brate, /* i : last element bitrate */
- const Word16 input_frame, /* i : frame length */
- Word16 old_inp_12k8_fx[], /* i/o: buffer of old input signal */
- Word16 old_inp_16k_fx[], /* i/o: buffer of old input signal @ 16kHz */
- Word16 **inp_fx, /* o : ptr. to inp. signal in the current frame*/
- Word32 *ener_fx, /* o : residual energy from Levinson-Durbin Q6 */
- Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* i/o: A(z) unquantized for the 4 subframes */
- Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* i/o: weighted A(z) unquantized for subframes */
- Word32 epsP_fx[M + 1], /* i : LP prediction errors epsP_fx_q */
- Word16 *epsP_fx_q, /* i : LP prediction errors */
- Word16 lsp_new_fx[M], /* i/o: LSPs at the end of the frame */
- Word16 lsp_mid_fx[M], /* i/o: LSPs in the middle of the frame */
- Word16 *new_inp_resamp16k_fx, /* o : new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE */
- Word16 *Voicing_flag, /* o : voicing flag for HQ FEC */
- Word16 old_wsp_fx[], /* i : weighted input signal buffer */
+ const Word16 last_element_mode, /* i : last element mode Q0*/
+ const Word32 element_brate, /* i : element bitrate Q0*/
+ const Word32 last_element_brate, /* i : last element bitrate Q0*/
+ const Word16 input_frame, /* i : frame length Q0*/
+ Word16 old_inp_12k8_fx[], /* i/o: buffer of old input signal Q_new-1 */
+ Word16 old_inp_16k_fx[], /* i/o: buffer of old input signal @ 16kHz Q_new-1 */
+ Word16 **inp_fx, /* o : ptr. to inp. signal in the current frame Q_new*/
+ Word32 *ener_fx, /* o : residual energy from Levinson-Durbin epsP_fx_q*/
+ Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* i/o: A(z) unquantized for the 4 subframes Q12*/
+ Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* i/o: weighted A(z) unquantized for subframes Q14*/
+ Word32 epsP_fx[M + 1], /* i : LP prediction errors epsP_fx_q*/
+ Word16 *epsP_fx_q, /* i : LP prediction errors */
+ Word16 lsp_new_fx[M], /* i/o: LSPs at the end of the frame Q15*/
+ Word16 lsp_mid_fx[M], /* i/o: LSPs in the middle of the frame Q15*/
+ Word16 *new_inp_resamp16k_fx, /* o : new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE Q_new-1*/
+ Word16 *Voicing_flag, /* o : voicing flag for HQ FEC Q0*/
+ Word16 old_wsp_fx[], /* i : weighted input signal buffer e_old_wsp*/
Word16 e_old_wsp,
- const Word16 loc_harm, /* i : harmonicity flag */
- const Word16 vad_flag_dtx, /* i : HE-SAD flag with additional DTX HO */
- const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) */
- const Word16 vad_hover_flag, /* i : VAD hangover flag */
- const Word16 flag_16k_smc, /* i : flag to indicate if the OL SMC is run at 16 kHz */
- Word32 enerBuffer_fx[CLDFB_NO_CHANNELS_MAX],
+ const Word16 loc_harm, /* i : harmonicity flag Q0*/
+ const Word16 vad_flag_dtx, /* i : HE-SAD flag with additional DTX HO Q0*/
+ const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/
+ const Word16 vad_hover_flag, /* i : VAD hangover flag Q0*/
+ const Word16 flag_16k_smc, /* i : flag to indicate if the OL SMC is run at 16 kHz Q0*/
+ Word32 enerBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* e_enerBuffer */
Word16 e_enerBuffer,
- Word16 fft_buff_fx[2 * L_FFT],
- Word16 cor_map_sum_fx, // Q8
+ Word16 fft_buff_fx[2 * L_FFT], /* Qx */
+ Word16 cor_map_sum_fx, /* Q8 */
Word16 *Q_new
);
/*! r: number of clipped samples */
-void ivas_initialize_handles_enc(
+void ivas_initialize_handles_enc_fx(
Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */
);
@@ -295,16 +283,16 @@ ivas_error ivas_init_encoder(
Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */
);
-void ivas_destroy_enc(
+void ivas_destroy_enc_fx(
Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */
);
-ivas_error ivas_initialize_MD_bstr_enc(
+ivas_error ivas_initialize_MD_bstr_enc_fx(
BSTR_ENC_HANDLE *hBstr, /* o : encoder MD bitstream handle */
Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */
);
-void ivas_destroy_MD_bstr_enc(
+void ivas_destroy_MD_bstr_enc_fx(
BSTR_ENC_HANDLE *hMetaData /* i/o: encoder MD bitstream handle */
);
@@ -402,37 +390,37 @@ void ivas_initialize_handles_dec(
Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
);
-ivas_error ivas_core_enc(
+ivas_error ivas_core_enc_fx(
SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */
CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
MCT_ENC_HANDLE hMCT, /* i/o: MCT encoder structure */
- const int16_t n_CoreChannels, /* i : number of core channels to be coded */
- Word16 old_inp_12k8_fx[][L_INP_12k8], /* i : buffer of old input signal */
- Word16 old_inp_16k_fx[][L_INP], /* i : buffer of old input signal */
+ const Word16 n_CoreChannels, /* i : number of core channels to be coded Q0*/
+ Word16 old_inp_12k8_fx[][L_INP_12k8], /* i : buffer of old input signal Q_new-1*/
+ Word16 old_inp_16k_fx[][L_INP], /* i : buffer of old input signal Q_new-1*/
Word16 Q_new[],
- Word32 ener_fx[], /* i : residual energy from Levinson-Durbin Q6*/
- Word16 A_fx[][NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes */
- Word16 Aw_fx[][NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquantized for subframes*/
- Word32 epsP_fx[][M + 1], /* i : LP prediction errors epsP_fx_q */
- Word16 epsP_fx_q[], /* i : LP prediction errors */
- Word16 lsp_new[][M], /* i : LSPs at the end of the frame Q15 */
- Word16 lsp_mid[][M], /* i : LSPs in the middle of the frame Q15 */
- const int16_t vad_hover_flag[], /* i : VAD hanglover flag */
- int16_t attack_flag[], /* i : attack flag (GSC or TC) */
- Word32 realBuffer_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: real buffer */
- Word32 imagBuffer_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: imag buffer */
+ Word32 ener_fx[], /* i : residual energy from Levinson-Durbin epsP_fx_q*/
+ Word16 A_fx[][NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12*/
+ Word16 Aw_fx[][NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquantized for subframes Q12*/
+ Word32 epsP_fx[][M + 1], /* i : LP prediction errors epsP_fx_q*/
+ Word16 epsP_fx_q[], /* i : LP prediction errors */
+ Word16 lsp_new_fx[][M], /* i : LSPs at the end of the frame Q15*/
+ Word16 lsp_mid_fx[][M], /* i : LSPs in the middle of the frame Q15*/
+ const Word16 vad_hover_flag[], /* i : VAD hanglover flag Q0*/
+ Word16 attack_flag[], /* i : attack flag (GSC or TC) Q0*/
+ Word32 realBuffer_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: real buffer q_re_im_buf*/
+ Word32 imagBuffer_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: imag buffer q_re_im_buf*/
Word16 *q_re_im_buf,
- Word16 old_wsp_fx[][L_WSP], /* i : weighted input signal buffer */
+ Word16 old_wsp_fx[][L_WSP], /* i : weighted input signal buffer e_old_wsp*/
Word16 e_old_wsp[],
- const int16_t loc_harm[], /* i : harmonicity flag */
- const Word16 cor_map_sum[], /* i : speech/music clasif. parameter Q8 */
- const int16_t vad_flag_dtx[], /* i : HE-SAD flag with additional DTX HO */
- Word32 enerBuffer_fx[][CLDFB_NO_CHANNELS_MAX], /* o : energy buffer */
- Word16 enerBuffer_fx_exp[], /* o : energy buffer */
- Word16 fft_buff_fx[][2 * L_FFT], /* i : FFT buffer */
- const int16_t tdm_SM_flag, /* i : channel combination scheme flag */
- const int16_t ivas_format, /* i : IVAS format */
- const int16_t flag_16k_smc /* i : flag to indicate if the OL SMC is run at 16 kHz */
+ const Word16 loc_harm[], /* i : harmonicity flag Q0*/
+ const Word16 cor_map_sum_fx[], /* i : speech/music clasif. parameter Q8*/
+ const Word16 vad_flag_dtx[], /* i : HE-SAD flag with additional DTX HO Q0*/
+ Word32 enerBuffer_fx[][CLDFB_NO_CHANNELS_MAX], /* o : energy buffer enerBuffer_fx_exp*/
+ Word16 enerBuffer_fx_exp[], /* o : energy buffer */
+ Word16 fft_buff_fx[][2 * L_FFT], /* i : FFT buffer Qx*/
+ const Word16 tdm_SM_or_LRTD_Pri, /* i : channel combination scheme flag Q0*/
+ const Word16 ivas_format, /* i : IVAS format Q0*/
+ const Word16 flag_16k_smc /* i : flag to indicate if the OL SMC is run at 16 kHz Q0*/
);
@@ -775,7 +763,7 @@ Word16 ism_quant_meta_fx(
const Word16 cbsize /* i : codebook size */
);
-ivas_error ivas_ism_metadata_enc_create(
+ivas_error ivas_ism_metadata_enc_create_fx(
Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */
const int16_t n_ISms, /* i : number of objects */
int32_t element_brate_tmp[] /* o : element bitrate per object */
@@ -818,11 +806,11 @@ ivas_error ivas_ism_metadata_dec(
/*! r: ISM format mode */
-ivas_error ivas_param_ism_enc_open(
+ivas_error ivas_param_ism_enc_open_fx(
Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */
);
-void ivas_param_ism_enc_close(
+void ivas_param_ism_enc_close_fx(
PARAM_ISM_CONFIG_HANDLE *hParamIsm, /* i/o: ParamISM handle */
const int32_t input_Fs /* i : input sampling_rate */
);
@@ -890,7 +878,7 @@ void ivas_ism_dtx_dec(
int16_t *nb_bits_metadata /* o : number of metadata bits */
);
-void ivas_ism_metadata_sid_enc(
+void ivas_ism_metadata_sid_enc_fx(
ISM_DTX_HANDLE hISMDTX, /* i/o: ISM DTX handle */
const int16_t flag_noisy_speech, /* i : noisy speech flag */
const int16_t nchan_ism, /* i : number of objects */
@@ -917,7 +905,7 @@ void ivas_ism_metadata_sid_dec(
);
-void ivas_param_ism_compute_noisy_speech_flag(
+void ivas_param_ism_compute_noisy_speech_flag_fx(
Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */
);
@@ -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 */
@@ -1652,9 +1598,9 @@ void InternalTCXDecoder(
void stereo_mdct_core_enc_fx(
CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
- Word16 new_samples[CPE_CHANNELS][L_INP], /* i : new samples */
- Word16 old_wsp[CPE_CHANNELS][L_WSP], /* i : 12.8kHz weighted speech (for LTP */
- Word16 pitch_buf_fx[CPE_CHANNELS][NB_SUBFR16k] /* o : floating pitch for each subframe */
+ Word16 new_samples[CPE_CHANNELS][L_INP], /* i : new samples Q0*/
+ Word16 old_wsp[CPE_CHANNELS][L_WSP], /* i : 12.8kHz weighted speech (for LTP Qx*/
+ Word16 pitch_buf_fx[CPE_CHANNELS][NB_SUBFR16k] /* o : floating pitch for each subframe Q6*/
);
void initMdctStereoEncData(
@@ -1931,12 +1877,12 @@ void splitAvailableBits(
int16_t *bits_ch1 /* o : bits for channel 1 */
);
-int16_t write_stereo_to_bitstream
+Word16 write_stereo_to_bitstream_fx
(
STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: Stereo MDCT encoder structure */
Encoder_State **sts, /* i/o: Encoder state structure */
- int16_t ms_mask[NB_DIV][MAX_SFB], /* i : bandwise MS mask */
- const int16_t mct_on, /* i : flag mct block (1) or stereo (0) */
+ Word16 ms_mask[NB_DIV][MAX_SFB], /* i : bandwise MS mask Q0*/
+ const Word16 mct_on, /* i : flag mct block (1) or stereo (0) Q0*/
BSTR_ENC_HANDLE hBstr /* i/o: bitstream handle */
);
@@ -2712,11 +2658,11 @@ void ivas_dirac_dec_get_response(
-ivas_error ivas_mc_paramupmix_enc_open(
+ivas_error ivas_mc_paramupmix_enc_open_fx(
Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */
);
-void ivas_mc_paramupmix_enc_close(
+void ivas_mc_paramupmix_enc_close_fx(
MC_PARAMUPMIX_ENC_HANDLE *hMCParamUpmix, /* i/o: MC Param-Upmix encoder handle */
const int32_t input_Fs /* i : input sampling rate */
);
@@ -3347,11 +3293,11 @@ void pca_dec_s3(
);
-void ivas_huffman_encode(
+void ivas_huffman_encode_fx(
ivas_huffman_cfg_t *huff_cfg,
- int16_t in,
- int16_t *hcode,
- int16_t *hlen
+ Word16 in,
+ Word16 *hcode,
+ Word16 *hlen
);
@@ -3456,11 +3402,11 @@ void generate_gridEq(
SPHERICAL_GRID_DATA *data /* o : data structure for grid */
);
-ivas_error ivas_masa_enc_open(
+ivas_error ivas_masa_enc_open_fx(
Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */
);
-void ivas_masa_enc_close(
+void ivas_masa_enc_close_fx(
MASA_ENCODER_HANDLE *hMasa /* i/o: MASA metadata structure */
);
@@ -3535,12 +3481,12 @@ void distribute_evenly_ism(
);
-int16_t ivas_qmetadata_encode_extended_gr_length(
+int16_t ivas_qmetadata_encode_extended_gr_length_fx(
const uint16_t value,
const uint16_t alphabet_size,
const int16_t gr_param);
-void ivas_qmetadata_encode_extended_gr(
+void ivas_qmetadata_encode_extended_gr_fx(
BSTR_ENC_HANDLE hMetaData, /* i/o: q_metadata handle */
const uint16_t value, /* i : value to be encoded */
const uint16_t alphabet_size, /* i : alphabet size */
@@ -3790,10 +3736,11 @@ void ivas_mcmasa_split_brate(
void ivas_mcmasa_dmx_modify_fx(
- const Word16 n_samples, /* i : input frame length in samples */
- Word32 dmx_fx[][L_FRAME48k + NS2SA(48000, IVAS_FB_ENC_DELAY_NS)], /* i/o: downmix signal to be transformed into another format Qx*/
- const Word16 n_chnls_dmx_old, /* i : number of downmix channels in the old format Q0*/
- const Word16 n_chnls_dmx_new /* i : number of downmix channels in the target format Q0*/
+ const Word16 n_samples, /* i : input frame length in samples */
+ Word32 dmx_fx[][L_FRAME48k + NS2SA(48000, IVAS_FB_ENC_DELAY_NS)], /* i/o: downmix signal to be transformed into another format Qx*/
+ Word16 dmx_Q[], /* i/o : Q of the intput signal which is being transformed*/
+ const Word16 n_chnls_dmx_old, /* i : number of downmix channels in the old format Q0 */
+ const Word16 n_chnls_dmx_new /* i : number of downmix channels in the target format Q0*/
);
ivas_error ivas_mono_dmx_renderer_open(
@@ -3821,7 +3768,7 @@ ivas_error ivas_create_lfe_lpf_enc(
const int32_t input_Fs /* i : input sampling rate */
);
-void ivas_lfe_lpf_enc_close(
+void ivas_lfe_lpf_enc_close_fx(
ivas_filters_process_state_t **hLfeLpf /* i/o: LFE LPF handle */
);
@@ -3836,12 +3783,12 @@ void ivas_lfe_lpf_enc_apply(
* LFE Coding prototypes
*----------------------------------------------------------------------------------*/
-ivas_error ivas_create_lfe_enc(
+ivas_error ivas_create_lfe_enc_fx(
LFE_ENC_HANDLE *hLFE, /* o : IVAS LFE encoder structure */
const int32_t input_Fs /* i : input sampling rate */
);
-void ivas_lfe_enc_close(
+void ivas_lfe_enc_close_fx(
LFE_ENC_HANDLE *hLFE /* i/o: LFE encoder handle */
);
diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h
index 6fd0c777fb04e5fd0fd5f8c67e88a7735d58a080..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 */
@@ -3228,7 +3241,12 @@ void computeDirectionVectors_fixed(
Word32 *direction_vector_x, /*Q30*/
Word32 *direction_vector_y, /*Q30*/
Word32 *direction_vector_z, /*Q30*/
- Word16 i_e /*Exponent of all the intensity buffers*/ );
+ Word16 i_e /*Exponent of all the intensity buffers*/
+#ifdef NONBE_IMPROVE_DIRAC_INTENSITY_PREC
+ ,
+ Word16 *i_e_band
+#endif
+);
UWord8 ivas_masa_surrcoh_signicant_fx(
@@ -3439,17 +3457,18 @@ ivas_error ivas_param_mc_enc_reconfig_fx(
Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */
);
-Word16 ivas_arith_encode_cmplx_cell_array(
+Word16 ivas_arith_encode_cmplx_cell_array_fx(
ivas_arith_t *pArith_re,
ivas_arith_t *pArith_re_diff,
- const Word16 *pDo_diff,
- const Word16 nB,
- Word16 *pSymbol_re,
- Word16 *pSymbol_old_re,
+ const Word16 *pDo_diff, /* Q0 */
+ const Word16 nB, /* Q0 */
+ Word16 *pSymbol_re, /* Q0 */
+ Word16 *pSymbol_old_re, /* Q0 */
ivas_cell_dim_t *pCell_dims,
BSTR_ENC_HANDLE hMetaData,
- const Word16 any_diff,
- const Word16 wc_strat_arith );
+ const Word16 any_diff, /* Q0 */
+ const Word16 wc_strat_arith /* Q0 */
+);
ivas_error stereo_dmx_evs_init_encoder_fx(
STEREO_DMX_EVS_ENC_HANDLE *hStereoDmxEVS_out, /* o : Stereo downmix for EVS encoder handle */
@@ -4122,7 +4141,7 @@ ivas_error ivas_set_ism_metadata_fx(
const Word16 non_diegetic_flag /* i : non-diegetic object flag */
);
-ivas_error ivas_ism_metadata_enc(
+ivas_error ivas_ism_metadata_enc_fx(
Word32 *ism_total_brate, /* i/o: ISM total bitrate */
const Word16 nchan_ism, /* i : number of ISM channels */
const Word16 nchan_transport, /* i : number of transport channels */
@@ -4276,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 */
@@ -4302,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 */
@@ -4316,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 */
@@ -4559,13 +4578,17 @@ ivas_error front_vad_fx(
const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) */
const Word16 input_frame, /* i : frame length */
Word16 vad_flag_dtx[], /* o : HE-SAD flag with additional DTX HO */
- Word32 fr_bands_fx[][2 * NB_BANDS], /* o : energy in frequency bands Q_buffer[n] + QSCALE + 2 */
+ Word32 fr_bands_fx[][2 * NB_BANDS], /* o : energy in frequency bands q_fr_bands_fx */
+ Word16 q_fr_bands[], /* o : Q of fr_bands_fx Q0 */
Word16 Etot_LR_fx[], /* o : total energy Left & Right channel Q8 */
- Word32 lf_E_fx[][2 * VOIC_BINS], /* i : per bin spectrum energy in lf, LR channels Q_buffer[n] + QSCALE */
+ Word32 lf_E_fx[][2 * VOIC_BINS], /* i : per bin spectrum energy in lf, LR channels q_lf_E */
+ Word16 q_lf_E[], /* o : Q of lf_E_fx */
Word16 localVAD_HE_SAD[], /* o : HE-SAD flag without hangover, LR channels */
Word16 vad_hover_flag[], /* o : VAD hangover flag */
- Word32 band_energies_LR_fx[2 * NB_BANDS], /* o : energy in critical bands without minimum noise floor E_MIN Q_buffer[1] + QSCALE + 2 - band_ener_guardbits*/
- Word32 *PS_out_fx, /* o : energy spectrum Q_buffer + QSCALE */
+ Word32 band_energies_LR_fx[2 * NB_BANDS], /* o : energy in critical bands without minimum noise floor E_MIN q_band_energies_LR */
+ Word16 *q_band_energies_LR, /* o : Q of band_energies_LR_fx */
+ Word32 *PS_out_fx, /* o : energy spectrum q_PS_out */
+ Word16 *q_PS_out, /* o : Q of PS_out_fx Q0 */
Word16 *Bin_E_out_fx, /* o : log-energy spectrum of the current frame Q7 */
Word16 Q_inp,
Word16 *Q_buffer,
@@ -4623,13 +4646,12 @@ Word32 logsumexp_fx(
const Word16 N /* i : number of elements in array x */
);
Word32 lin_interp32_fx(
- const Word32 x, /* i : the value to be mapped */
- const Word32 x1, /* i : source range interval: low end */
- const Word32 y1, /* i : source range interval: high end */
- const Word32 x2, /* i : target range interval: low */
- const Word32 y2, /* i : target range interval: high */
- const Word16 flag_sat, /* i : flag to indicate whether to apply saturation */
- Word16 *Q_io /*i/o : i/o Q factor of the output*/
+ const Word32 x, /* i : the value to be mapped */
+ const Word32 x1, /* i : source range interval: low end */
+ const Word32 y1, /* i : source range interval: high end */
+ const Word32 x2, /* i : target range interval: low */
+ const Word32 y2, /* i : target range interval: high */
+ const Word16 flag_sat /* i : flag to indicate whether to apply saturation */
);
void v_addc_fx(
@@ -4752,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 */
@@ -4841,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 */
@@ -4850,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 */
@@ -4928,17 +4955,6 @@ void ivas_dirac_dec_set_md_map(
const Word16 nCldfbTs /* i : number of CLDFB time slots */
);
-void computeDirectionVectors_fixed(
- Word32 *intensity_real_x,
- Word32 *intensity_real_y,
- Word32 *intensity_real_z,
- const Word16 enc_param_start_band,
- const Word16 num_frequency_bands,
- Word32 *direction_vector_x, /*Q30*/
- Word32 *direction_vector_y, /*Q30*/
- Word32 *direction_vector_z, /*Q30*/
- Word16 i_e /*Exponent of all the intensity buffers*/ );
-
void computeDirectionVectors_fx(
Word32 *intensity_real_x,
Word32 *intensity_real_y,
@@ -5752,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_qmetadata_com.c b/lib_com/ivas_qmetadata_com.c
index 73b85c7a529daaf94a6641cbf2a69d89c9621cc4..85d4332e0d8806efd57e95234d109bd47bf7a92a 100644
--- a/lib_com/ivas_qmetadata_com.c
+++ b/lib_com/ivas_qmetadata_com.c
@@ -280,8 +280,8 @@ void ivas_qmetadata_close_fx(
/*! r: codeword index */
Word16 masa_sq_fx(
- const Word32 in, /* i : input value */
- const Word32 *threshold, /* i : partition */
+ const Word32 in, /* i : input value Q30*/
+ const Word32 *threshold, /* i : partition Q30*/
const Word16 cb_sz /* i : codebook size */
)
{
diff --git a/lib_com/ivas_qspherical_com.c b/lib_com/ivas_qspherical_com.c
index 499585221bbb9c682fea3d63886c15bc0e54d5f9..c3608d2483461da35ca25d976d69b74c104eb179 100644
--- a/lib_com/ivas_qspherical_com.c
+++ b/lib_com/ivas_qspherical_com.c
@@ -668,15 +668,7 @@ Word16 quantize_phi_chan_compand_fx(
delta_phi = L_shr( delta_phi, sub( 9, tmp_e ) ); // Q22
// id_phi = (int16_t) round_f( ( phi / (float) delta_phi ) );
id_phi = BASOP_Util_Divide3232_Scale( phi, delta_phi, &tmp_e ); // Q15
- IF( GE_16( abs_s( id_phi ), shl_sat( 1, sub( 15, tmp_e ) ) ) )
- {
- id_phi = shr( id_phi, sub( 15, tmp_e ) ); // Q0
- }
- ELSE
- {
- id_phi = 0;
- move16();
- }
+ id_phi = round_fx( L_shl( id_phi, add( tmp_e, 1 ) ) ); // Q0
IF( add( id_phi, shr( n, 1 ) ) < 0 )
{
diff --git a/lib_com/ivas_spar_com.c b/lib_com/ivas_spar_com.c
index 7ab41d5edd70313a46658b38f859772a1d34005a..9f5106e0cff9752da43bd6a24ccd2b41f30a8901 100644
--- a/lib_com/ivas_spar_com.c
+++ b/lib_com/ivas_spar_com.c
@@ -2633,7 +2633,11 @@ static void ivas_calc_p_coeffs_per_band_enc_fx(
test();
IF( W_norm( re ) == 0 || W_norm( recon_uu_re[i][j] ) == 0 )
{
+#ifdef FIX_ISSUE_1122
+ recon_uu_re[i][j] = L_shr( recon_uu_re[i][j], 1 ); // q_recon_uu_re[i][j] - 1
+#else
re1[m] = L_shr( re1[m], 1 ); // q_recon_uu_re[i][j]-1
+#endif
move32();
q_recon_uu_re[i][j] = sub( q_recon_uu_re[i][j], 1 );
move16();
@@ -7040,7 +7044,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;
@@ -7051,49 +7055,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
@@ -7118,54 +7112,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_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 5738b6feb7715c9474c06907d2ae9b6e3e46186a..8d486df04dd62d69e843008e92faa6cc86770729 100644
--- a/lib_com/ivas_tools.c
+++ b/lib_com/ivas_tools.c
@@ -834,21 +834,18 @@ Word32 logsumexp_fx(
*---------------------------------------------------------------------*/
/*! r: mapped output value */
Word32 lin_interp32_fx(
- const Word32 x, /* i : the value to be mapped Qin*/
- const Word32 x1, /* i : source range interval: low end Qin*/
- const Word32 y1, /* i : source range interval: high end Qin*/
- const Word32 x2, /* i : target range interval: low Qin*/
- const Word32 y2, /* i : target range interval: high Qin*/
- const Word16 flag_sat, /* i : flag to indicate whether to apply saturation Q0*/
- Word16 *Q_io /*i/o : i/o Q factor of the output*/
+ const Word32 x, /* i : the value to be mapped Qx */
+ const Word32 x1, /* i : source range interval: low end Qx */
+ const Word32 y1, /* i : source range interval: high end Q31 */
+ const Word32 x2, /* i : target range interval: low Qx */
+ const Word32 y2, /* i : target range interval: high Q31 */
+ const Word16 flag_sat /* i : flag to indicate whether to apply saturation */
)
{
Word32 temp32;
Word32 temp_div;
- Word16 temp_e = 0;
- Word16 exp_out = 0;
- move16();
- move16();
+ Word16 exp_out;
+
IF( L_sub( x2, x1 ) == 0 )
{
return y1;
@@ -865,12 +862,12 @@ Word32 lin_interp32_fx(
}
}
- temp32 = Mpy_32_32( L_sub( x, x1 ), L_sub( y2, y1 ) ); // Qin*2 -31
- temp_div = L_deposit_h( BASOP_Util_Divide3232_Scale( temp32, L_sub( x2, x1 ), &temp_e ) ); // 31-temp_e + 2*Qin -31 - Qin = Qin-temp_e
- temp32 = BASOP_Util_Add_Mant32Exp( y1, sub( 31, *Q_io ), temp_div, sub( 31, sub( *Q_io, temp_e ) ), &exp_out ); // Qin-temp_e
- *Q_io = sub( 31, exp_out );
- move16();
- return temp32; /*Q_io*/
+ temp32 = Mpy_32_32( L_sub( x, x1 ), L_sub( y2, y1 ) ); /* Qx */
+ temp_div = L_deposit_h( BASOP_Util_Divide3232_Scale( temp32, L_sub( x2, x1 ), &exp_out ) );
+ temp32 = BASOP_Util_Add_Mant32Exp( y1, 0, temp_div, exp_out, &exp_out );
+ temp32 = L_shl_sat( temp32, exp_out ); /* Q31 */
+
+ return temp32;
}
/*-------------------------------------------------------------------*
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 21857fd103a62a8ed20039fee4e56fa0c1e5238a..b99fc47538f9cd8cae2507f1a5d809175a1e00a3 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--;
}
@@ -1678,41 +1724,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 +2239,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 +2332,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 +2559,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 );
}
@@ -3324,10 +3332,6 @@ void msvq_dec(
maxn = n;
move16();
}
- if ( maxn % 4 )
- {
- n = n;
- }
assert( ( maxn % 4 ) == 0 );
N34 = mult( maxn, 24576 /*0.75 Q15*/ );
@@ -3828,13 +3832,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
index a914c8e668570bea0fba57bf28685fd3efef420e..194fab0b32a84a619f6cb8286f41fc9334050d3f 100644
--- a/lib_com/options.h
+++ b/lib_com/options.h
@@ -51,6 +51,7 @@
#define DEBUG_MODE_INFO_TWEAK /* Enable command line switch to specify subdirectory for debug info output inside "./res/" */
#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 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 */
@@ -65,7 +66,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
@@ -89,9 +89,10 @@
#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 */
#define FIX_1105_OPT_MINIMUM_SL /* FhG: Optimize minimum_s(), minimum_l(), avoid IF */
#define FIX_1104_OPT_GETMINSCALEFAC /* FhG: Optimize get_min_scalefactor(), avoid IF */
@@ -100,6 +101,42 @@
#define FIX_1009_OPT_PARAMMC_RENDER /* FhG: Optimize ivas_param_mc_dec_render_fx() */
#define FIX_1109_OPTIM_MCT_STEREO_IGF_DEC /* FhG: optimize mctStereoIGF_dec_fx() */
#define FIX_1110_OPTIM_DIRAC_DECORR_PROC /* FhG: optimize ivas_dirac_dec_decorr_process() */
+#define FIX_1127_IMPROVE_SBA_MLD /* Ittiam: Avoid saturation for DiRAC reference power */
#define FIX_1100_REMOVE_LPC_RESCALING /* VA: Remove the rescaling of LPC coefficient to Q12 as residu and syn-filt are already taking care of it*/
-
+#define FIX_1133_IMPROVE_MC_MLD /* Ittiam: Correcting wrong updation of exponents in ivas_mc_paramupmix_param_est_enc_fx() */
+#define FIX_ISSUE_1122 /* Ittiam: Fix issue 1122: corrected incorrect scaling of a buffer leading to incorrect metadata bits */
+#define FIX_1132_STACK_CORRUPTION /* Stack corruption issue due of extending index access*/
+#define FIX_ISSUE_1092 /* Ittiam: Fix for Issue 1092: BASOP asserts in stereo fx encoder for selection test inputs*/
+#define FIX_ISSUE_1135 /* Ittiam: Fix for Issue 1135: downmixing difference between float and fixed-point (DFT - stereo) */
+#define FIX_ISSUE_1148
+#define FIX_ISSUE_1147 /* Ittiam: Fix for issue 1147: Added saturation in DetectTnsFilt_fx.*/
+#define FIX_ISSUE_1150 /* Ittiam: Fix for Issue 1150: Assertion error observed in evs_enc_fx (with option stereo_dmx_evs) from tcx_ltp_find_gain function*/
+#define FIX_ISSUE_1151 /* Ittiam: Fix for Issue 1151: Assertion error observed in evs_enc_fx (with option stereo_dmx_evs) from sp_mus_classif_gmm_fx function*/
+#define FIX_ISSUE_1153 /* Ittiam: Fix for Issue 1153: Assertion error observed in stereo_dmx_evs_enc_fx from calc_poc_fx function*/
+#define FIX_ISSUE_1154 /* Ittiam: Fix for Issue 1154: Encoder crash for ParamMC 7.1 at 96kbps in ivas_param_mc_param_est_enc_fx() */
+#define FIX_ISSUE_1157 /* Ittiam: Fix for Issue 1157: Encoder crash for Stereo at 48/64kbps DTX on/off in kernel_switch_trafo_fx() */
+#define FIX_ISSUE_1152 /* Ittiam: Fix for issue 1152: Assertion error observed in evs_enc_fx (with option stereo_dmx_evs) from find_tilt_fx function*/
+#define FIX_ISSUE_1156 /* Ittiam: Fix for Issue 1156: Encoder crash for Stereo at 32kbps in SWB_BWE_encoding_ivas_fx() */
+#define FIX_DISCLAIMER /* VA: Add disclaimer for external renderer + Add info about IVAS reference version (FLP issue 1225) */
+#define FIX_ISSUE_1167 /* Ittiam: Fix for Issue 1167: Encoder crash for OSBA ISM3SBA1 at 13.2 and 16.4 kbps in gauss_L2_ivas_fx() */
+#define FIX_1009_REPLACE_DIV_SQRT_BY_ISQRT_LC /* FhG: Reduce workload of binaural rendering: replace 1./tmp & sqrt by Isqrt32 */
+#define FIX_1113_OPT_DIRAC_BIN_REND /* FhG: Various optimizations to ivas_dirac_dec_binaual_functions.c */
+#define FIX_ISSUE_1187 /* Ittiam: Fix for issue 1187: Assertion error observed in evs_enc_fx (with option stereo_dmx_evs) from bass_pf_enc_fx function*/
+#define FIX_ISSUE_1186 /* Ittiam: Fix for Issue 1186: Energy/scaling issue for ISM-1 at all bitrates */
+#define FIX_ISSUE_1165 /* Ittiam: Fix for issue 1165: Assertion in lpc2lsp_fx for OMASA LTV input */
+#define FIX_ISSUE_1185 /* Ittiam: Fix for issue 1185: Assertion in ivas_dirac_dec_binaural_internal_fx() for crash in decoder in fft30_with_cmplx_data()*/
+#define FIX_ISSUE_1209 /* Ittiam: Fix for issue 1209: Assertion exit in BASOP encoder (stereo_dmx_evs)*/
+#define 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_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 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 */
#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 c55786ae4d8aafbb747c9a1e264bde1b661aa8f3..9985ca978d25841413a23beec53528ddca5ac455 100644
--- a/lib_com/prot.h
+++ b/lib_com/prot.h
@@ -2004,24 +2004,24 @@ void MDCT_selector(
const float enerBuffer[] /* i : energy buffer */
);
-ivas_error acelp_core_enc(
+ivas_error acelp_core_enc_ivas_fx(
Encoder_State *st, /* i/o: encoder state structure */
- const Word16 inp[], /* i : input signal of the current frame */
- Word16 A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes */
- Word16 Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes */
- const Word32 epsP[M + 1], /* i : LP prediction errors */
- Word16 lsp_new[M], /* i : LSPs at the end of the frame */
- Word16 lsp_mid[M], /* i : LSPs in the middle of the frame */
- const Word16 vad_hover_flag, /* i : VAD hangover flag */
- const Word16 attack_flag, /* i : attack flag (GSC or TC) */
- Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation 2*Q_new */
- Word16 *voice_factors_fx, /* o : voicing factors Q15 */
- Word16 old_syn_12k8_16k[], /* o : ACELP core synthesis at 12.8kHz or 16kHz to be used by SWB BWE */
+ const Word16 inp[], /* i : input signal of the current frame Q_new*/
+ Word16 A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12*/
+ Word16 Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes Q12*/
+ const Word32 epsP[M + 1], /* i : LP prediction errors Qx*/
+ Word16 lsp_new[M], /* i : LSPs at the end of the frame Q15*/
+ Word16 lsp_mid[M], /* i : LSPs in the middle of the frame Q15*/
+ const Word16 vad_hover_flag, /* i : VAD hangover flag Q0*/
+ const Word16 attack_flag, /* i : attack flag (GSC or TC) Q0*/
+ Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation st->prev_Q_bwe_exc*/
+ Word16 *voice_factors_fx, /* o : voicing factors Q15*/
+ Word16 old_syn_12k8_16k[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE q_old_syn_12k8_16*/
Word16 *q_old_syn_12k8_16,
- Word16 pitch_buf[NB_SUBFR16k], /* o : floating pitch for each subframe */
- Word16 *unbits, /* o : number of unused bits */
- STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder handle */
- Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */
+ Word16 pitch_buf[NB_SUBFR16k], /* o : floating pitch for each subframe Q6*/
+ Word16 *unbits, /* o : number of unused bits Q0*/
+ STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder handle */
+ Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel X2.56*/
Word16 Q_new );
ivas_error acelp_core_switch_dec_bfi(
@@ -2994,31 +2994,25 @@ void speech_music_classif(
int16_t *high_lpn_flag, /* o : sp/mus LPN flag */
const int16_t flag_spitch /* i : flag to indicate very short stable pitch */
);
-void ivas_find_wsp(
- const Word16 L_frame, /* i : length of the frame */
- const Word16 L_subfr, /* i : length of subframe */
- const Word16 nb_subfr, /* i : number of subframes */
- const Word16 *A_fx, /* i : A(z) filter coefficients */
- Word16 *Aw_fx, /* o : weighted A(z) filter coefficients */
- const Word16 *speech_fx, /* i : pointer to the denoised speech frame */
- const Word16 tilt_fact, /* i : tilt factor */
- Word16 *wsp_fx, /* o : poitnter to the weighted speech frame */
- Word16 *mem_wsp_fx, /* i/o: W(Z) denominator memory */
- const Word16 gamma, /* i : weighting factor */
- const Word16 L_look /* i : look-ahead */
-);
-void find_wsp(
- const int16_t L_frame, /* i : length of the frame */
- const int16_t L_subfr, /* i : length of subframe */
- const int16_t nb_subfr, /* i : number of subframes */
- const float *A, /* i : A(z) filter coefficients */
- float *Aw, /* o : weighted A(z) filter coefficients */
- const float *speech, /* i : pointer to the denoised speech frame */
- const float tilt_fact, /* i : tilt factor */
- float *wsp, /* o : poitnter to the weighted speech frame */
- float *mem_wsp, /* i/o: W(Z) denominator memory */
- const float gamma, /* i : weighting factor */
- const int16_t L_look /* i : look-ahead */
+void ivas_find_wsp_fx(
+ const Word16 L_frame, /* i : length of the frame Q0*/
+ const Word16 L_subfr, /* i : length of subframe Q0*/
+ const Word16 nb_subfr, /* i : number of subframes Q0*/
+ const Word16 *A_fx,
+ /* i : A(z) filter coefficients */ // Q12
+ Word16 *Aw_fx,
+ /* o : weighted A(z) filter coefficients */ // Q12
+ const Word16 *speech_fx,
+ /* i : pointer to the denoised speech frame */ // Q_new
+ const Word16 tilt_fact,
+ /* i : tilt factor */ // Q15
+ Word16 *wsp_fx,
+ /* o : poitnter to the weighted speech frame */ // Q_new
+ Word16 *mem_wsp_fx,
+ /* i/o: W(Z) denominator memory */ // Q_new
+ const Word16 gamma,
+ /* i : weighting factor */ // Q15
+ const Word16 L_look /* i : look-ahead Q0*/
);
void gain_enc_amr_wb(
@@ -5666,12 +5660,6 @@ void adapt_lag_wind_fx(
const int32_t sr_core /* i : core sampling rate */
);
-void init_coder_ace_plus(
- Encoder_State *st, /* i : Encoder state handle */
- const int32_t last_total_brate, /* i : last total bitrate */
- const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0)*/
-);
-
void core_coder_reconfig(
Encoder_State *st, /* i/o: encoder state structure */
const int32_t last_total_brate /* i : last total bitrate */
@@ -6141,17 +6129,18 @@ int16_t RCcontextMapping_encode2_estimate_no_mem_s17_LCS(
CONTEXT_HM_CONFIG *hm_cfg /* context-based harmonic model configuration */
);
-int16_t RCcontextMapping_encode2_estimate_bandWise_start(
- int16_t *x,
- const int16_t nt,
- const int16_t target,
+Word16 RCcontextMapping_encode2_estimate_bandWise_start_fx(
+ Word16 *x, /* Q0 */
+ const Word16 nt, /* Q0 */
+ const Word16 target, /* Q0 */
HANDLE_RC_CONTEXT_MEM hContextMem );
-int16_t RCcontextMapping_encode2_estimate_bandWise(
- int16_t *x,
- const int16_t start_line,
- const int16_t end_line,
- HANDLE_RC_CONTEXT_MEM hContextMem );
+Word16 RCcontextMapping_encode2_estimate_bandWise_fx(
+ Word16 *x, /* Q0 */
+ const Word16 start_line, /* Q0 */
+ const Word16 end_line, /* Q0 */
+ HANDLE_RC_CONTEXT_MEM hContextMem /* Q0 */
+);
void tcx_get_windows_flt(
TCX_CONFIG_HANDLE hTcxCfg, /* i : TCX configuration */
@@ -6605,16 +6594,16 @@ void decoder_acelp(
float *bwe_exc /* o : excitation for SWB TBE */
);
-void writeTCXMode(
- Encoder_State *st, /* i/o: encoder state structure */
- BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
- const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0)*/
- int16_t *nbits_start /* o : nbits start */
+void writeTCXMode_fx(
+ Encoder_State *st, /* i/o: encoder state structure */
+ BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
+ const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/
+ Word16 *nbits_start /* o : nbits start Q0*/
);
-void writeTCXWindowing(
- BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
- const int16_t overlap_mode /* i : overlap mode */
+void writeTCXWindowing_fx(
+ BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
+ const Word16 overlap_mode /* i : overlap mode Q0*/
);
void writeLPCparam(
diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h
index 13ab9bebda58d7f9eb2fcdd4e174590c30d9f7fd..3c2b1395c80e2d1b8846683a919e75393825f98d 100644
--- a/lib_com/prot_fx.h
+++ b/lib_com/prot_fx.h
@@ -206,12 +206,23 @@ void Scale_sig(
const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */
);
+void scale_sig(
+ Word16 x[], /* i/o: signal to scale Qx */
+ const Word16 lg, /* i : size of x[] Q0 */
+ const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */
+);
+
// tools.c
Word32 sum2_fx( /* o : sum of all squared vector elements Q(2x+1)*/
const Word16 *vec, /* i : i vector Qx*/
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 */
);
@@ -802,6 +813,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,
@@ -1683,13 +1702,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(
@@ -2727,6 +2744,12 @@ void time_envelop_shaping_fx(
const Word16 L, /* i : frame length */
Word16 *Q_synth );
+void time_envelop_shaping_ivas_fx(
+ Word16 werr[], /* i/o: SHB synthesis Q_synth*/
+ Word32 SWB_tenv[], /* i/o: frequency envelope Q15*/
+ const Word16 L, /* i : frame length */
+ Word16 *Q_synth );
+
void time_reduce_pre_echo_fx(
const Word16 *synth, /* i : ACELP core synthesis Q_syn*/
Word16 *error, /* i/o: SHB BWE synthesis Q0*/
@@ -3668,58 +3691,64 @@ gp_clips_fx.c
/========================================================================================================*/
void init_gp_clip_fx(
- Word16 mem[] /* o : memory of gain of pitch clipping algorithm */
+ Word16 mem[] /* o : memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/
);
Word16 gp_clip_fx(
- const Word16 element_mode, /* i : element mode */
- const Word32 core_brate, /* i : core bitrate */
- const Word16 *voicing, /* i : normalized correlations (from OL pitch) */
- const Word16 i_subfr, /* i : subframe index */
- const Word16 coder_type, /* i : type of coder */
- const Word16 xn[], /* i : target vector */
- Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm */
+ const Word16 element_mode, /* i : element mode Q0*/
+ const Word32 core_brate, /* i : core bitrate Q0*/
+ const Word16 *voicing, /* i : normalized correlations (from OL pitch) Q15*/
+ const Word16 i_subfr, /* i : subframe index Q0*/
+ const Word16 coder_type, /* i : type of coder Q0*/
+ const Word16 xn[], /* i : target vector Q_new*/
+ Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/
const Word16 Q_new /* i : scaling factor */
);
void gp_clip_test_isf_fx(
- const Word16 element_mode, /* i : element mode */
- const Word32 core_brate, /* i : core bitrate */
- const Word16 isf[], /* i : isf values (in frequency domain) */
- Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm */
- const Word16 Opt_AMR_WB /* i : flag indicating AMR-WB IO mode */
+ const Word16 element_mode, /* i : element mode Q0*/
+ const Word32 core_brate, /* i : core bitrate Q0*/
+ const Word16 isf[], /* i : isf values (in frequency domain) Q2.56*/
+ Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm Q15*/
+ const Word16 Opt_AMR_WB /* i : flag indicating AMR-WB IO mode Q0*/
);
void gp_clip_test_gain_pit_fx(
- const Word16 element_mode, /* i : element mode */
- const Word32 core_brate, /* i : core bitrate */
- const Word16 gain_pit, /* i : gain of quantized pitch Q14 */
- Word16 mem[] /* i/o: memory of gain of pitch clipping algorithm 1Q14 */
+ const Word16 element_mode, /* i : element mode Q0*/
+ const Word32 core_brate, /* i : core bitrate Q0*/
+ const Word16 gain_pit, /* i : gain of quantized pitch Q14*/
+ Word16 mem[] /* i/o: memory of gain of pitch clipping algorithm 1Q14*/
);
-Word16 Mode2_gp_clip(
- const Word16 *voicing, /* i : normalized correlations (from OL pitch) */
- const Word16 i_subfr, /* i : subframe index */
- const Word16 coder_type, /* i : type of coder */
- const Word16 xn[], /* i : target vector */
+Word16 Mode2_gp_clip_fx(
+ const Word16 *voicing, /* i : normalized correlations from OL pitch Q15 */
+ const Word16 i_subfr, /* i : subframe index Q0 */
+ const Word16 coder_type, /* i : type of coder Q0 */
+ const Word16 xn[], /* i : target vector Q_xn */
Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm */
- const Word16 L_subfr,
- const Word16 Q_xn /* i : xn data format */
+ /* mem[0]: Q0 */
+ /* mem[1]: 1Q14 */
+ /* mem[2]: 8Q7 */
+ /* mem[3]: Q0 (integer) */
+ /* mem[4]: Q14 */
+ /* mem[5]: Q14 */
+ const Word16 L_subfr, /* Q0 */
+ const Word16 Q_xn /* i : scaling factor of vector xn[] */
);
void gp_clip_test_lsf_fx(
- const Word16 element_mode, /* i : element mode */
- const Word16 lsf[], /* i : lsf values (in frequency domain) 14Q1*1.28 */
- Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm */
- const Word16 m /* i : dimension of lsf */
+ const Word16 element_mode, /* i : element mode Q0*/
+ const Word16 lsf[], /* i : lsf values (in frequency domain) 14Q1*1.28*/
+ Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/
+ const Word16 m /* i : dimension of lsf Q0*/
);
void gp_clip_test_lsf_ivas_fx(
- const Word16 element_mode, /* i : element mode */
- const Word32 core_brate, /* i : core bitrate */
- const Word16 lsf[], /* i : LSF vector */
- Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm */
- const Word16 Opt_AMR_WB /* i : flag indicating AMR-WB IO mode */
+ const Word16 element_mode, /* i : element mode Q0*/
+ const Word32 core_brate, /* i : core bitrate Q0*/
+ const Word16 lsf[], /* i : LSF vector 14Q1*1.28*/
+ Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/
+ const Word16 Opt_AMR_WB /* i : flag indicating AMR-WB IO mode Q0*/
);
/*========================================================================================================/
@@ -4437,6 +4466,13 @@ void edct_fx(
Word16 *q /* i : Q value of i signal */
);
+void edct_ivas_fx(
+ const Word32 *x, /* i : input signal Qq */
+ Word32 *y, /* o : output transform Qq */
+ Word16 length, /* i : length Q0*/
+ Word16 *q /* i : Q value of input signal */
+);
+
void edst_fx(
const Word32 *x, /* i : i signal Qq */
Word32 *y, /* o : output transform Qq */
@@ -4552,7 +4588,8 @@ void DoRTFTn_fx_ivas(
Word16 find_guarded_bits_fx( Word32 n );
-Word16 L_norm_arr( Word32 *arr, Word16 size );
+Word16 L_norm_arr( const Word32 *arr, Word16 size );
+Word16 norm_arr( Word16 *arr, Word16 size );
Word16 get_min_scalefactor( Word32 x, Word32 y );
@@ -4938,12 +4975,12 @@ void fine_gain_quant_fx(
const Word16 *gopt /* i : Optimal gains Q12 */
);
void fine_gain_quant_ivas_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const Word16 *ord, /* i : Indices for energy order Q0 */
- const Word16 num_sfm, /* i : Number of bands Q0 */
- const Word16 *gain_bits, /* i : Gain adjustment bits per sub band Q0 */
- Word16 *fg_pred, /* i/o: Predicted gains / Corrected gains Q12 */
- const Word16 *gopt /* i : Optimal gains Q12 */
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ const Word16 *ord, /* i : Indices for energy order Q0 */
+ const Word16 num_sfm, /* i : Number of bands Q0 */
+ const Word16 *gain_bits, /* i : Gain adjustment bits per sub band Q0 */
+ Word16 *fg_pred, /* i/o: Predicted gains / Corrected gains i:Q12 / o:Q11 */
+ const Word16 *gopt /* i : Optimal gains Q12 */
);
void get_max_pulses_fx(
const Word16 *band_start, /* i : Sub band start indices */
@@ -7668,10 +7705,10 @@ void fd_bwe_dec_init(
void hq_core_enc_ivas_fx(
Encoder_State *st, /* i/o: encoder state structure */
const Word16 *audio_fx, /* i : input audio signal Q0 */
- const Word16 input_frame, /* i : frame length */
- const Word16 hq_core_type, /* i : HQ core type */
- const Word16 Voicing_flag, /* i : Voicing flag for FER method selection */
- const Word16 vad_hover_flag /* i : VAD hangover flag */
+ const Word16 input_frame, /* i : frame length Q0*/
+ const Word16 hq_core_type, /* i : HQ core type Q0*/
+ const Word16 Voicing_flag, /* i : Voicing flag for FER method selection Q0*/
+ const Word16 vad_hover_flag /* i : VAD hangover flag Q0*/
);
// hq_core_dec_fx.c
@@ -9588,6 +9625,17 @@ void cldfbAnalysis_ts_fx(
Word16 *q_cldfb );
Word16 floor_log_2( Word32 num );
+void cldfbAnalysis_ts_fx_var_q(
+ const Word32 *timeIn_fx,
+ /* i : time buffer */ // q
+ Word32 realBuffer_fx[CLDFB_NO_CHANNELS_MAX],
+ /* o : real value buffer */ // q_cldfb - 5
+ Word32 imagBuffer_fx[CLDFB_NO_CHANNELS_MAX],
+ /* o : imag value buffer */ // q_cldfb - 5
+ const Word16 samplesToProcess, /* i : samples to process */
+ HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i : filterbank state */
+ Word16 *q_cldfb );
+
void cldfbAnalysis_ts_fx_fixed_q(
const Word32 *timeIn_fx,
/* i : time buffer */ // q
@@ -9906,14 +9954,14 @@ void tcx_scalar_quantization_ivas_fx(
Word8 const *memQuantZeros_fx, /* i: coefficients to be set to 0 */
const Word16 alfe_flag );
-Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS(
- Word16 *x, /* Spectral coefficients */
- const Word16 nt, /* L - size of spectrum (no. of spectral coefficients) */
- Word16 *lastnz_out,
- Word16 *nEncoded, /* No. of spectral coefficients that can be coded without an overflow occuring */
- const Word16 target, /* Target bits */
- Word16 *stop,
- Word16 mode,
+Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx(
+ Word16 *x, /* Spectral coefficients Q0*/
+ const Word16 nt, /* L - size of spectrum (no. of spectral coefficients) Q0*/
+ Word16 *lastnz_out, /* Q0 */
+ Word16 *nEncoded, /* No. of spectral coefficients that can be coded without an overflow occuring Q0*/
+ const Word16 target, /* Target bits Q0*/
+ Word16 *stop, /* Q0 */
+ Word16 mode, /* Q0 */
CONTEXT_HM_CONFIG *hm_cfg /* context-based harmonic model configuration */
);
@@ -9962,7 +10010,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 */
@@ -10032,6 +10080,12 @@ Word16 maximum_fx( /* o : index of the maximum value in t
Word16 *max_fx /* o : maximum value in the input vector */
);
+Word16 maximum_exp_fx( /* o : index of the maximum value in the input vector */
+ const Word16 *vec_fx, /* i : input vector */
+ const Word16 *exp_vec, /* i : exponents of input vector */
+ const Word16 lvec_fx /* i : length of input vector */
+);
+
Word16 maximum_abs_16_fx( /* o : index of the maximum abs value in the input vector */
const Word16 *vec, /* i : input vector */
const Word16 lvec, /* i : length of input vector */
@@ -10771,16 +10825,18 @@ Word32 sum2_32_fx(
Word16 *e );
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 */
+ 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 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 */
@@ -10793,14 +10849,14 @@ 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 */
const Word16 igfGridIdx, /* i : IGF grid index */
- const Word32 *pITFSpectrum /* i : MDCT spectrum */
-);
+ const Word32 *pITFSpectrum, /* i : MDCT spectrum */
+ Word16 exp_pITFSpectrum );
Word16 IGFEncWriteBitstream_ivas_fx(
const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : instance handle of IGF Encoder */
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
@@ -10818,19 +10874,24 @@ Word16 IGFSCFEncoderEncode(
const Word16 indepFlag /* i : if 1 frame is independent, 0 = frame is coded with data from previous frame */
);
/*ari_enc.c*/
-Word16 ari_encode_14bits_ext(
- Word16 *ptr,
- Word16 bp,
+Word16 ari_encode_14bits_ext_ivas_fx(
+ Word16 *ptr, /* Q0 */
+ Word16 bp, /* Q0 */
Tastat *s,
- Word32 symbol,
- const UWord16 *cum_freq );
-Word16 ari_encode_14bits_sign(
- Word16 *ptr,
- Word16 bp,
- Word32 bits,
+ Word32 symbol, /* Q0 */
+ UWord16 const *cum_freq /* Q0 */
+);
+Word16 ari_encode_14bits_sign_ivas_fx(
+ Word16 *ptr, /* Q0 */
+ Word16 bp, /* Q0 */
+ Word32 bits, /* Q0 */
Tastat *s,
- Word16 sign );
-Word16 ari_done_encoding_14bits( Word16 *ptr, Word16 bp, Tastat *s );
+ Word16 sign /* Q0 */
+);
+Word16 ari_done_encoding_14bits_ivas_fx(
+ Word16 *ptr, /* Q0 */
+ Word16 bp, /* Q0 */
+ Tastat *s );
void pack_bit(
const Word16 bit, /* i: bit to be packed */
UWord8 **pt, /* i/o: pointer to octet array into which bit will be placed */
@@ -10934,12 +10995,12 @@ Word16 get_next_coeff_mapped_ivas_fx(
);
void RCcontextMapping_encode2_no_mem_s17_LCS_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
- Word16 *x,
- const Word16 nt,
- Word16 lastnz,
- const Word16 nbbits,
- const Word16 resQMaxBits,
+ BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
+ Word16 *x, /* Q0 */
+ const Word16 nt, /* Q0 */
+ Word16 lastnz, /* Q0 */
+ const Word16 nbbits, /* Q0 */
+ const Word16 resQMaxBits, /* Q0 */
CONTEXT_HM_CONFIG *hm_cfg );
void writeTCXparam_fx(
@@ -10978,8 +11039,9 @@ void core_coder_mode_switch_ivas_fx(
void configureFdCngEnc_ivas_fx(
HANDLE_FD_CNG_ENC hFdCngEnc, /* i/o: Contains the variables related to the FD-based CNG process */
- const Word16 bwidth,
- const Word32 total_brate );
+ const Word16 bwidth, /* Q0 */
+ const Word32 total_brate /* Q0 */
+);
Word16 getTcxonly_ivas_fx(
const Word16 element_mode, /* i : IVAS element mode */
@@ -10991,9 +11053,9 @@ Word16 getTcxonly_ivas_fx(
void SetModeIndex_ivas_fx(
Encoder_State *st, /* i : Encoder state */
- const Word32 last_total_brate, /* i : last total bitrate */
- const Word16 last_element_mode, /* i : last IVAS element mode */
- const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) */
+ const Word32 last_total_brate, /* i : last total bitrate Q0*/
+ const Word16 last_element_mode, /* i : last IVAS element mode Q0*/
+ const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) Q0*/
);
void IGFEncSetMode_ivas_fx(
@@ -11059,16 +11121,16 @@ Word16 msvq_stage1_dct_recalc_candidates_fdcng_wb_fx(
);
void FEC_encode_ivas_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const ACELP_config acelp_cfg, /* i/o: configuration of the ACELP */
- const Word16 *synth, /* i : pointer to synthesized speech for E computation */
- const Word16 coder_type, /* i : type of coder */
- Word16 clas, /* i : signal clas for current frame */
- const Word16 *fpit, /* i : close loop fractional pitch buffer Q6 */
- const Word16 *res, /* i : LP residual signal frame */
- Word16 *last_pulse_pos, /* i/o: Position of the last pulse */
- const Word16 L_frame, /* i : Frame length */
- const Word32 total_brate, /* i : total codec bitrate */
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ const ACELP_config acelp_cfg, /* i/o: configuration of the ACELP */
+ const Word16 *synth, /* i : pointer to synthesized speech for E computation Q_Synth*/
+ const Word16 coder_type, /* i : type of coder Q0*/
+ Word16 clas, /* i : signal clas for current frame Q0*/
+ const Word16 *fpit, /* i : close loop fractional pitch buffer Q6*/
+ const Word16 *res, /* i : LP residual signal frame Qx*/
+ Word16 *last_pulse_pos, /* i/o: Position of the last pulse Q0*/
+ const Word16 L_frame, /* i : Frame length Q0*/
+ const Word32 total_brate, /* i : total codec bitrate Q0*/
const Word16 Q_synth /* i : input scaling */
);
diff --git a/lib_com/pvq_com_fx.c b/lib_com/pvq_com_fx.c
index 48ee402ef182f83254b64a6aa52a8a7a8bc26b09..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 */
@@ -515,12 +511,12 @@ void apply_gain_fx(
* Fine gain quantization
*--------------------------------------------------------------------------*/
void fine_gain_quant_ivas_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const Word16 *ord, /* i : Indices for energy order Q0 */
- const Word16 num_sfm, /* i : Number of bands Q0 */
- const Word16 *gain_bits, /* i : Gain adjustment bits per sub band Q0 */
- Word16 *fg_pred, /* i/o: Predicted gains / Corrected gains Q11 */
- const Word16 *gopt /* i : Optimal gains Q12 */
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ const Word16 *ord, /* i : Indices for energy order Q0 */
+ const Word16 num_sfm, /* i : Number of bands Q0 */
+ const Word16 *gain_bits, /* i : Gain adjustment bits per sub band Q0 */
+ Word16 *fg_pred, /* i/o: Predicted gains / Corrected gains i:Q12 / o:Q11 */
+ const Word16 *gopt /* i : Optimal gains Q12 */
)
{
Word16 band;
@@ -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 );
@@ -577,6 +569,10 @@ void fine_gain_quant_ivas_fx(
fg_pred[band] = round_fx( L_shl( L_tmp, sub( 15, exp1 ) ) ); /*12+exp1+16-exp1-16=12 - 1-> Q11*/
move16();
}
+ ELSE
+ {
+ fg_pred[band] = shr( fg_pred[band], 1 ); // Q12 -> Q11 To align all the fg_pred indices in same Q.
+ }
}
return;
@@ -624,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_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 bd22e7e4259ec48ffc7a2626da5143c2fec263bc..303d453f11ff22140e1a69a05f56c7b321ba71a3 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,90 @@ 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++;
+ }
+ }
+ }
+
+ return;
+}
+
+void time_envelop_shaping_ivas_fx(
+ Word16 werr[], /* i/o: SHB synthesis Q_synth*/
+ Word32 SWB_tenv[], /* i/o: frequency envelope Q15*/
+ const Word16 L, /* i : frame length */
+ Word16 *Q_synth )
+{
+ Word16 *pit;
+ Word32 Energy;
+ Word16 i, j;
+ Word16 tmp_ener, Energy_16;
+ Word64 Energy_64;
+ Word16 exp_L, exp, frac, tmp, inv_L, w_tmp, Energy_Q;
+ Word32 L_tmp;
+
+ pit = werr;
+ exp_L = norm_s( L );
+ inv_L = div_s( shl( 1, sub( 14, exp_L ) ), L ); /*Q(29-exp_L) */
+ FOR( i = 0; i < SWB_TENV; i++ )
+ {
+ Energy_64 = L_deposit_l( 0 );
+ FOR( j = 0; j < L / 4; j++ )
+ {
+ Energy_64 = W_mac0_16_16( Energy_64, *pit, *pit ); /*(2*Q_synth) */
+ pit++;
+ }
+ w_tmp = W_norm( Energy_64 );
+ Energy_64 = W_shl( Energy_64, w_tmp );
+ Energy = W_extract_h( Energy_64 ); /*2*Q_synth + w_tmp -32*/
+ Energy_Q = sub( add( shl( ( *Q_synth ), 1 ), w_tmp ), 32 );
+ Energy = Mult_32_16( Energy, inv_L ); /*Q(29-exp_L-15) -> Q(-exp_L+14+2*Q_synth+w_tmp-32) */
+ Energy_16 = 0;
+ move16();
+ /*exp = 31-(-exp_L+14 +(2*(*Q_synth)+w_tmp-32)); */
+ exp = sub( 17, sub( Energy_Q, exp_L ) );
+
+ IF( Energy != 0 )
+ {
+ exp = norm_l( Energy );
+ frac = extract_h( L_shl( Energy, exp ) );
+ /*exp = sub(exp, 30-(-exp_L+14-2+(2*(*Q_synth)+w_tmp-32))); */
+ exp = sub( exp, sub( 30, add( sub( Energy_Q, exp_L ), 14 - 2 ) ) );
+
+ tmp = div_s( 16384, frac );
+ L_tmp = L_deposit_h( tmp );
+ Energy = Isqrt_lc( L_tmp, &exp ); /*Q(31-exp) */
+ Energy_16 = round_fx( L_shl( Energy, sub( exp, 15 ) ) ); /*Q0 */
+ }
+
+ test();
+ IF( LT_32( SWB_tenv[i], 65536 /* 2 in Q15 */ ) && LT_32( Energy, L_shl_sat( SWB_tenv[i], sub( 16, exp ) ) ) )
+ {
+ *Q_synth = add( *Q_synth, 3 );
+ move16();
+ }
+ ELSE
+ {
+ pit -= shr( L, 2 );
+ tmp_ener = 0;
+ move16();
+ exp = 0;
+ move16();
+
+ IF( Energy_16 != 0 )
+ {
+ exp = norm_s( Energy_16 );
+ tmp_ener = div_s( shl( 1, sub( 14, exp ) ), Energy_16 ); /*Q(29-exp) */
+ }
+
+ L_tmp = Mult_32_16( SWB_tenv[i], tmp_ener ); /*Q(29-exp) */
+ tmp = round_fx( L_tmp ); /*Q(13-exp) */
+
+ FOR( j = 0; j < L / 4; j++ )
+ {
+ *pit = round_fx_sat( L_shl_sat( L_mult( tmp, *pit ), sub( exp, 1 ) ) ); /*Q(13-exp+1)->Q(14-exp)->Qsyn-3 */
move16();
pit++;
}
@@ -2265,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) */
@@ -2309,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 );
@@ -2354,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) */
@@ -2404,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();
}
@@ -2481,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++;
}
@@ -2575,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 );
@@ -2687,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 );
@@ -2993,12 +2842,8 @@ 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 */
-#else
- tmp3_fx = shr( tmp3_fx, add( 5, sub( exp2, exp1 ) ) ); /*10 */
-#endif
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 0535cb1c8398bf0ba28e93651dae605b447cbe7e..7c2c355517de0e64c06eb3eafc90c5d7e55e0c9a 100644
--- a/lib_com/swb_bwe_com_lr_fx.c
+++ b/lib_com/swb_bwe_com_lr_fx.c
@@ -208,7 +208,7 @@ Word16 har_est_fx(
Word16 blk_end_LEN;
Word16 *p_blk_peak_pos, *pm1_blk_peak_pos;
- Word16 *p_diff_peak_pos, *pm1_diff_peak_pos;
+ Word16 *pm1_diff_peak_pos;
Word16 blk_peak_max_idx, blk_peak_pos_max_diff, diff_peak_pos_te[30];
Word16 thr1, thr2;
@@ -387,8 +387,6 @@ Word16 har_est_fx(
blk_peak_max_idx = 0;
move16();
-
- p_diff_peak_pos = &diff_peak_pos[1];
pm1_diff_peak_pos = &diff_peak_pos[1 - 1];
FOR( i = 1; i < j; i++ )
{
@@ -410,7 +408,6 @@ Word16 har_est_fx(
temp = add( temp, 1 );
- p_diff_peak_pos++;
pm1_diff_peak_pos++;
}
blk_peak_pos_max_diff = diff_peak_pos[blk_peak_max_idx];
@@ -989,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 */
;
@@ -1019,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();
}
}
@@ -2330,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;
@@ -2357,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]); */
@@ -2403,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();
@@ -2433,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();
}
@@ -2647,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] );
@@ -2659,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
@@ -3274,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_fx.c b/lib_com/swb_tbe_com_fx.c
index 494dbebd5d0262f5d437ec2f3787954d8d4ae2bf..aeca8dff14131d58c6155fd7045c276a833a4110 100644
--- a/lib_com/swb_tbe_com_fx.c
+++ b/lib_com/swb_tbe_com_fx.c
@@ -982,7 +982,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 +1086,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 +1354,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 +1486,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 +1531,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 +1539,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 +1549,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 +1569,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 +1578,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 +1733,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 +1741,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 +1779,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 +1787,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 +1797,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 +1818,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 +1827,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 +1849,6 @@ void GenShapedWBExcitation_fx(
return;
}
-
/*-------------------------------------------------------------------*
* GenWBSynth()
*
@@ -2277,11 +2175,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 +2183,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 +2345,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 +2377,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 +2598,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 +2646,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 +2665,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 */
}
@@ -3114,11 +2979,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 +2988,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 );
@@ -3377,7 +3234,7 @@ void GenShapedSHBExcitation_ivas_enc_fx(
/* calculate pow22 */
/* pow22=0.00001f */
tmp = sub( shl( sub( *Q_bwe_exc, NOISE_QADJ ), 1 ), 31 );
- pow22 = L_shl( 21475l /*0.00001f Q31*/, tmp ); /* 0.00001f in 2*(*Q_bwe_exc-NOISE_QADJ) */
+ Word64 sum = W_shl( 21475l /*0.00001f Q31*/, tmp ); /* 0.00001f in 2*(*Q_bwe_exc-NOISE_QADJ) */
FOR( k = 0; k < L_FRAME16k; k++ )
{
/* White_exc16k[k] *= excNoisyEnv[k]; */
@@ -3388,14 +3245,11 @@ void GenShapedSHBExcitation_ivas_enc_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
+ sum = W_mac0_16_16( sum, White_exc16k[k], White_exc16k[k] ); /* 2*(Q_excTmp2-NOISE_QADJ)*/
}
- /*Q_pow22 = sub( shl(*Q_bwe_exc,1), 18 );*/
- Q_pow22 = shl( sub( Q_excTmp2, NOISE_QADJ ), 1 );
+ 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 ) );
}
@@ -3792,11 +3646,7 @@ 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 */
@@ -3846,11 +3696,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
{
@@ -3869,24 +3715,15 @@ 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) */
+ 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 */
}
@@ -3916,7 +3753,7 @@ void GenShapedSHBExcitation_ivas_enc_fx(
IF( LT_32( bitrate, ACELP_24k40 ) )
#endif
{
- syn_filt_fx( 0, lpc_shb, LPC_SHB_ORDER, exc16kWhtnd, excSHB, L_FRAME16k, state_lpc_syn, 1 );
+ Syn_filt_s( 0, lpc_shb, LPC_SHB_ORDER, exc16kWhtnd, excSHB, L_FRAME16k, state_lpc_syn, 1 );
/* i: exc16kWhtnd in Q_bwe_exc */
/* o: excSHB in Q_bwe_exc */
}
@@ -4217,11 +4054,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]));*/
@@ -4230,11 +4063,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 );
@@ -4491,11 +4320,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 );
@@ -4895,11 +4720,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 */
@@ -4949,11 +4770,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
{
@@ -4972,24 +4789,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 */
}
@@ -5675,42 +5483,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();
}
@@ -5740,12 +5533,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();
@@ -5754,12 +5543,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();
}
@@ -5768,12 +5553,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 )
{
@@ -5788,11 +5569,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 )
@@ -5894,11 +5671,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();
@@ -6075,20 +5848,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
}
}
@@ -6111,12 +5876,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
{
@@ -6165,20 +5926,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
}
}
@@ -6347,20 +6100,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
}
}
@@ -6383,12 +6128,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
{
@@ -6437,20 +6178,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
}
}
@@ -6728,7 +6461,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] ) );
@@ -6738,91 +6470,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*/
@@ -6833,18 +6526,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];
@@ -6856,89 +6537,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 */
@@ -6949,18 +6593,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] ) );
}
@@ -6979,18 +6611,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*/
@@ -7056,73 +6682,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];
@@ -7268,21 +6827,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;
@@ -7351,20 +6902,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) */
}
@@ -7384,11 +6927,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;
@@ -7415,11 +6954,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 );
@@ -7590,11 +7125,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();
@@ -7621,29 +7152,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();
}
}
@@ -7657,18 +7174,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
@@ -7676,31 +7186,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
}
}
@@ -7792,11 +7291,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();
@@ -7826,37 +7321,22 @@ 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();
}
}
ELSE
{
- Word16 shift = 8;
+ Word16 shift = 4;
move16();
- if ( element_mode == EVS_MONO )
- {
- shift = 4;
- move16();
- }
IF( gain_preQ_fx != 0 )
{
FOR( i = 0; i < L_subfr; i++ )
@@ -7865,17 +7345,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();
}
}
@@ -7884,14 +7357,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();
}
}
@@ -7899,16 +7367,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
}
}
@@ -7971,11 +7433,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..169ca57679e50a0239c2adc8c1b2b811bef108a9 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();
}
}
@@ -206,20 +187,14 @@ void syn_filt_fx(
Word16 buf[L_FRAME48k + L_FRAME48k / 2 + TCXLTP_LTP_ORDER]; /* temporary synthesis buffer */
Word16 s, *yy;
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,18 +212,10 @@ 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
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
}
yy[i] = s;
@@ -330,23 +297,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 +314,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 +330,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 64b7defc94efdaa59c549a80bf9b6c86b9d255e1..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,7 +1045,7 @@ void mdct_shaping(
FOR( l = 0; l < k; l++ )
{
- *x = L_shl( Mpy_32_16_r( *x, *gains ), *gains_exp ); /*Qx*/
+ *x = L_shl_o( Mpy_32_16_r( *x, *gains ), *gains_exp, &Overflow ); /*Qx*/
move32();
x++;
}
@@ -1091,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++;
@@ -1470,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 */
@@ -1710,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 */
@@ -1856,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 */
@@ -2173,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..d4de526d629dfad34aaebc39a4693bacd6ede9a5 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();
}
}
diff --git a/lib_com/tools.c b/lib_com/tools.c
index f757239f38f38da77ad373ff14f22007e7b9a2e7..733e5634aa9f05ec3562648a4e4e71627a34f052 100644
--- a/lib_com/tools.c
+++ b/lib_com/tools.c
@@ -281,13 +281,18 @@ Word32 sum2_32_exp_fx(
Word16 gb /* i : guard bits */
)
{
- Word16 i, s;
+ Word16 i, s, norm;
Word64 W_tmp;
W_tmp = 0;
Word64 var_a = 0;
move64();
move64();
+
+ norm = L_norm_arr( vec, lvec );
+
+ gb = sub( gb, norm );
+
FOR( i = 0; i < lvec; i++ )
{
var_a = W_mult0_32_32( vec[i], vec[i] ); // 2x
@@ -2195,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 62766e3b76035193c8732501a0eefa8e9ff0fc87..704b44b8483a247d765a60d5c141cda7a6b93c34 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,37 +969,45 @@ 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;
}
}
+/*-------------------------------------------------------------------*
+ * scale_sig
+ * Up/down scale a 16 bits vector
+ *-------------------------------------------------------------------*/
+void scale_sig(
+ Word16 x[], /* i/o: signal to scale Qx */
+ const Word16 lg, /* i : size of x[] Q0 */
+ const Word16 exp0 /* i : exponent: x = round(x << exp) Qx exp */
+)
+{
+ Word16 i;
+
+ IF( exp0 != 0 )
+ {
+ FOR( i = 0; i < lg; i++ )
+ {
+ x[i] = shl( x[i], exp0 );
+ move16();
+ }
+ }
+}
+
/*---------------------------------------------------------------------*
* mean()
*
@@ -1086,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();
}
}
@@ -1212,6 +1195,37 @@ Word16 maximum_fx( /* o : index of the maximum value in t
return ind;
}
+Word16 maximum_exp_fx( /* o : index of the maximum value in the input vector */
+ const Word16 *vec_fx, /* i : input vector */
+ const Word16 *exp_vec, /* i : exponents of input vector */
+ const Word16 lvec_fx /* i : length of input vector */
+)
+{
+ Word16 j, ind;
+ Word16 tmp, exp;
+ ind = 0;
+ move16();
+ tmp = vec_fx[0];
+ move16();
+ exp = exp_vec[0];
+ move16();
+
+ FOR( j = 1; j < lvec_fx; j++ )
+ {
+ IF( LT_16( tmp, shr_sat( vec_fx[j], sub( exp, exp_vec[j] ) ) ) )
+ {
+ ind = j;
+ move16();
+ tmp = vec_fx[j];
+ move16();
+ exp = exp_vec[j];
+ move16();
+ }
+ }
+
+ return ind;
+}
+
/*---------------------------------------------------------------------*
* maximum_abs_16_fx()
*
@@ -1499,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 */
@@ -1545,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*/
@@ -1570,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
}
/*-------------------------------------------------------------------*
@@ -1595,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*/
@@ -1622,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*/
@@ -1653,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;
}
@@ -1758,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();
}
}
@@ -1957,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 )
{
@@ -1978,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;
@@ -2029,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 )
{
@@ -2050,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;
@@ -2130,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;
@@ -2171,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;
@@ -2219,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;
@@ -2239,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;
@@ -2486,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-- )
@@ -2521,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();
}
}
@@ -2584,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,7 +2558,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++ )
@@ -2681,16 +2566,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();
}
}
@@ -2838,18 +2713,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 ) )
{
@@ -2950,11 +2817,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] );
@@ -2970,12 +2833,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();
}
}
@@ -3012,20 +2871,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] ) );
@@ -3052,11 +2903,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;
@@ -3064,15 +2911,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();
}
}
@@ -3222,11 +3063,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();
}
}
@@ -3234,11 +3071,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();
}
}
@@ -3365,39 +3198,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.
@@ -3405,11 +3220,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 );
@@ -3418,11 +3229,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 );
@@ -3494,11 +3301,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 );
@@ -3796,17 +3599,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();
}
@@ -4000,20 +3796,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 )
@@ -4461,10 +4249,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 ) )
{
@@ -4485,10 +4274,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/wmc_auto.c b/lib_debug/wmc_auto.c
index 731b01e1c14b7e8cad2fd4b922010941855b5224..d357c03dd7d09ed3721a2fd735b48c26978e6fec 100644
--- a/lib_debug/wmc_auto.c
+++ b/lib_debug/wmc_auto.c
@@ -2499,11 +2499,11 @@ long DeltaWeightedOperation( unsigned int CounterId )
void Reset_BASOP_WMOPS_counter( unsigned int counterId )
{
int i;
- long *ptr;
+ unsigned int *ptr;
/* reset the current BASOP operation counter */
- ptr = (long *) &multiCounter[counterId];
- for ( i = 0; i < (int) ( sizeof( multiCounter[counterId] ) / sizeof( long ) ); i++ )
+ ptr = (unsigned int *) &multiCounter[counterId];
+ for ( i = 0; i < (int) (sizeof(BASIC_OP) / sizeof(unsigned int)); i++ )
{
*ptr++ = 0;
}
@@ -2513,4 +2513,4 @@ void Reset_BASOP_WMOPS_counter( unsigned int counterId )
return;
}
-#endif
\ No newline at end of file
+#endif
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..778cc9ec32f89c906664ed647da71139c172ffd3 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 + 16
+#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 + 16
+#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 + 16
+#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 + 16
+#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..0686996f39a63f813179d33dd587dc0f5248530b 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 */
@@ -658,11 +634,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 +643,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 +654,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();
}
}
@@ -726,17 +690,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 +768,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 +781,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_ivas_fx.c b/lib_dec/acelp_core_dec_ivas_fx.c
index 49b3297836a70ff42e2b69e68ed4471fea852703..ed32a115f33061a0d06f3bd8ea55ff9c8db9dded 100644
--- a/lib_dec/acelp_core_dec_ivas_fx.c
+++ b/lib_dec/acelp_core_dec_ivas_fx.c
@@ -611,7 +611,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();
@@ -1731,12 +1735,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 +1772,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++ )
{
@@ -1995,7 +2003,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 +2074,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 +2120,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 +2165,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..f347cdb7eb18b6a2568665d547d5caf4cb07486c 100644
--- a/lib_dec/acelp_core_switch_dec_fx.c
+++ b/lib_dec/acelp_core_switch_dec_fx.c
@@ -332,12 +332,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 +816,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 +840,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 +973,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/avq_dec_fx.c b/lib_dec/avq_dec_fx.c
index a13678a97124b2c8af8361358a98b4035db7c57a..3bf7e3eb62ff897d2028a462d3e8f30c33ead199 100644
--- a/lib_dec/avq_dec_fx.c
+++ b/lib_dec/avq_dec_fx.c
@@ -184,7 +184,7 @@ void AVQ_demuxdec_fx(
move16();
FOR( j = i; j < Nsv - 1; j++ )
{
- if ( ( nq[svOrder[j]] == 0 ) )
+ if ( nq[svOrder[j]] == 0 )
{
nullVec = add( nullVec, 1 );
}
@@ -271,12 +271,7 @@ void AVQ_demuxdec_fx(
/*Compute AVQ code book number from unused Bits */
tmp = (Word16) ( sub( bits, add( add( shl( add( unusedbitsFlag, unused_bits_idx ), 2 ), unusedbitsFlag ), unused_bits_idx ) ) );
nq_est = idiv1616( tmp, 5 );
- IF( ( ( tmp % 5 ) == 0 ) )
- {
- nq_est = nq_est;
- move16();
- }
- ELSE
+ IF( ( ( tmp % 5 ) != 0 ) )
{
nq_est = add( nq_est, 1 );
}
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_dec_init_fx.c b/lib_dec/core_dec_init_fx.c
index c0a83460a51adaf9b87906158817144fc14a3ff0..671dbfd2ca520671ad8ab10abb004f32f8b055f2 100644
--- a/lib_dec/core_dec_init_fx.c
+++ b/lib_dec/core_dec_init_fx.c
@@ -1287,7 +1287,7 @@ void open_decoder_LPD_ivas_fx(
move16();
st->output_frame_fx = st->hTcxDec->L_frameTCX; /* Q0 */
move16();
- if ( ( st->ini_frame == 0 ) )
+ if ( st->ini_frame == 0 )
{
st->L_frameTCX_past = st->hTcxDec->L_frameTCX;
move16();
@@ -1360,7 +1360,7 @@ void open_decoder_LPD_ivas_fx(
}
}
- if ( ( st->ini_frame == 0 ) )
+ if ( st->ini_frame == 0 )
{
st->pit_res_max_past = st->pit_res_max;
move16();
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_LPD_fx.c b/lib_dec/dec_LPD_fx.c
index 9c2e014b4f5848aeaabee3343f09e6198aab4b0f..f3443349a1a542e0ff66f85b2ba1650107e1c2f8 100644
--- a/lib_dec/dec_LPD_fx.c
+++ b/lib_dec/dec_LPD_fx.c
@@ -448,7 +448,7 @@ void decoder_LPD_fx(
IF( st->enablePlcWaveadjust )
{
- if ( ( st->core == ACELP_CORE ) )
+ if ( st->core == ACELP_CORE )
{
st->tonality_flag = 0;
move16();
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..1abd3d58bddfe6e5bcd943b021175f46d936b7ea 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 ) )
{
@@ -794,37 +755,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 +838,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 +925,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..a6e06db54ab14b708376a5a3cea169ef83b10e0b 100644
--- a/lib_dec/dec_post_fx.c
+++ b/lib_dec/dec_post_fx.c
@@ -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 */
@@ -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_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..ffb49be38ac379865dbcfd897ab7458a1e9d73e8 100644
--- a/lib_dec/dec_uv_fx.c
+++ b/lib_dec/dec_uv_fx.c
@@ -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/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..c164d9e0667637c5bae2b7381a29abc08abf2ae0 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();
@@ -3812,11 +3719,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 +3728,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 +4258,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 +4267,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 +4689,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..c237bc987c97317269ac29c9fbe6a1e23afb0825 100644
--- a/lib_dec/gs_dec_fx.c
+++ b/lib_dec/gs_dec_fx.c
@@ -1586,7 +1586,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_core_dec.c b/lib_dec/ivas_core_dec.c
index e7708a747520a7675af7f515f362ec4a001d0c8f..c7893c88d1f66dfa58341f187344a38329ed61bc 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 */
@@ -574,12 +579,12 @@ ivas_error ivas_core_dec_fx(
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 +641,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 +668,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 +688,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 +923,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 +948,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 +987,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 +1013,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 +1113,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 +1217,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 +1251,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 +1437,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 +1522,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 +1540,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_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_masa_dec.c b/lib_dec/ivas_masa_dec.c
index 19ee1e68a54f1ed10ef9e29e25eb9526d2b433cf..983eb33095e6d03432387deede2d78b3c3a9270b 100644
--- a/lib_dec/ivas_masa_dec.c
+++ b/lib_dec/ivas_masa_dec.c
@@ -2326,15 +2326,11 @@ void ivas_spar_param_to_masa_param_mapping_fx(
move16();
res_q = 0;
move16();
- IF( E_fx > 0 )
- {
- E_fx = E_fx;
- }
- ELSE
+ IF( E_fx <= 0 )
{
E_fx = 1;
+ move32();
}
- move32();
ratio_float_fx = BASOP_Util_Divide3232_Scale( I_fx, E_fx, &res_q );
res_q = sub( res_q, sub( num_q, denom_q ) );
ratio_fx = L_shl_sat( ratio_float_fx, add( Q15, res_q ) ); // Q(15 + res_q)
diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c
index e3d8bf0c034ff19afd08dd299334be9c128ad9f5..4175d15def0080ebd3dd76978dc5135a43141db3 100644
--- a/lib_dec/ivas_mc_param_dec.c
+++ b/lib_dec/ivas_mc_param_dec.c
@@ -2037,7 +2037,6 @@ void ivas_param_mc_dec_render_fx(
&hParamMC->Cldfb_ImagBuffer_tc_fx[hParamMC->slots_rendered * nchan_transport * hParamMC->num_freq_bands],
hParamMC->proto_frame_f_fx, hParamMC->diff_proto_info,
hParamMC->num_freq_bands );
- Scale_sig32( hParamMC->proto_frame_f_fx, shl( imult1616( hParamMC->diff_proto_info->num_protos_diff, hParamMC->num_freq_bands ), 1 ), Q11 - Q5 );
/*-----------------------------------------------------------------*
* frequency domain decorrelation
*-----------------------------------------------------------------*/
@@ -2049,7 +2048,7 @@ void ivas_param_mc_dec_render_fx(
DIRAC_SYNTHESIS_COV_MC_LS,
nchan_transport,
hParamMC->proto_frame_f_fx,
- 11,
+ Q5,
hParamMC->diff_proto_info->num_protos_diff,
hParamMC->diff_proto_info->proto_index_diff,
hParamMC->proto_frame_dec_f_fx, // output
diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c
index f3afead8fe1b8c7a8c86783f0c498986ebff91c5..33a71fbcfd89437da2f31bd98966ae753e502013 100644
--- a/lib_dec/ivas_mct_dec.c
+++ b/lib_dec/ivas_mct_dec.c
@@ -250,9 +250,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 +334,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;
@@ -380,9 +383,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 +426,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 +450,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_spar_decoder.c b/lib_dec/ivas_spar_decoder.c
index fdace42d822ae5e85b084285873d70df63bad336..f76961ebed1d0486a52e9a4d1bb93b73d39ee082 100644
--- a/lib_dec/ivas_spar_decoder.c
+++ b/lib_dec/ivas_spar_decoder.c
@@ -1687,8 +1687,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 +1707,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 +1719,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 +1728,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 +1736,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*/
}
}
@@ -1897,14 +1900,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*/
diff --git a/lib_dec/ivas_stereo_cng_dec.c b/lib_dec/ivas_stereo_cng_dec.c
index f8d6f6086edf0308a7d11134905dfccbc6700c5b..df5f1569642e076f3296a73ae6947e2ba680cbe6 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 ) )
{
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..bcebc8008db090785eb50caa40978f768bb0b0ad 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 // VA2ITTIAM -> This ( 28 - norm_s( hCPE->hCoreCoder[0]->old_Aq_12_8_fx[0] - 1 ) ) is not working, leads to a left shit of 25 and old_Aq_12_8_fx[0] usually takes between 10 and 14 bits; should be something like (28 - (15 - norm_s(A[0]-1))
+ 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 6d4fc967ea10795e9a872894a1396557a3c0e7f7..829173da02bd00970748f7329a57c2a3c567b6ab 100644
--- a/lib_dec/ivas_stereo_mdct_stereo_dec.c
+++ b/lib_dec/ivas_stereo_mdct_stereo_dec.c
@@ -720,20 +720,7 @@ static void update_exp(
}
return;
}
-static Word16 norm_arr(
- Word16 *arr,
- Word32 size /* Q0 */
-)
-{
- Word16 q = 15;
- move16();
- FOR( Word32 i = 0; i < size; i++ )
- IF( arr[i] != 0 )
- {
- q = s_min( q, norm_s( arr[i] ) );
- }
- return q;
-}
+
void updateBuffersForDmxMdctStereo_fx(
CPE_DEC_HANDLE hCPE, /* i/o: CPE handle */
const Word16 output_frame, /* i : output frame length Q0*/
@@ -919,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_svd_dec.c b/lib_dec/ivas_svd_dec.c
index 3b8a90a4c87bd969a3359b24a3ee577266a1b55e..dc1965a5bdea4de61cb93bfb53464cf6b3c7ccf9 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);
@@ -836,14 +965,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 +1005,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 +1032,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 +1050,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 +1081,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 +1099,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 ) )
{
@@ -967,10 +1171,19 @@ IF( LT_16( currChannel, nChannelsL ) ) /* i <= m */
move32();
}
+#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 +1192,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 +1223,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 +1253,7 @@ IF( LT_16( currChannel, nChannelsL ) ) /* i <= m */
}
*singularVectors_e = exp_max;
move16();
+#endif
}
// rescaling block
@@ -1042,9 +1274,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 +1296,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 +1325,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 +1339,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 +1397,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 +1445,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 +1467,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 +1488,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 +1514,7 @@ static void biDiagonalReductionRight_fx(
}
*singularVectors_e = exp_max;
move16();
+#endif
}
}
@@ -1204,9 +1528,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 +1544,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,8 +1570,13 @@ 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
// fprintf( fp, "%e\n", me2f( t_ii, t_ii_e ) );
FOR( iCh = nCh + 1; iCh < nChannelsC; iCh++ ) /* nChannelsC */
{
@@ -1251,14 +1586,25 @@ static void singularVectorsAccumulationLeft_fx(
move16();
FOR( k = nCh + 1; k < nChannelsL; k++ ) /* nChannelsL */
{
+#ifndef FIX_1010_OPT_SINGLE_RESCALE
norm_y = BASOP_Util_Add_Mant32Exp( norm_y, norm_y_e, Mpy_32_32( singularVectors_Left[k][nCh], singularVectors_Left[k][iCh] ), add( sing_exp2[k][nCh], sing_exp2[k][iCh] ), &norm_y_e ); /* exp(norm_y_e) */
+#else
+ norm_y = BASOP_Util_Add_Mant32Exp( norm_y, norm_y_e, Mpy_32_32( singularVectors_Left[k][nCh], singularVectors_Left[k][iCh] ), add( singularVectors_Left_e[k][nCh], singularVectors_Left_e[k][iCh] ), &norm_y_e ); /* exp(norm_y_e) */
+#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,
+#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( temp_exp, sub( add( t_ii_e, norm_y_e ), singularVectors_Left_e[nCh][nCh] ) );
+#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 +1613,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 +1629,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 +1641,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 +1660,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 +1685,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 +1698,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 +1727,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 +1755,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 +1767,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 +1799,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 +1854,7 @@ static Word32 GivensRotation_fx(
*out_e = add( z_e, temp_exp );
}
}
-
+#endif
return ( r );
}
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.c b/lib_dec/swb_bwe_dec.c
index 1dcc5c111603f6ac4fbb50eeb0838ddcfc83d865..0f9863bdfc2bc874bbb7f9618a01d84365d71819 100644
--- a/lib_dec/swb_bwe_dec.c
+++ b/lib_dec/swb_bwe_dec.c
@@ -579,7 +579,8 @@ Word16 swb_bwe_dec_fx32(
}
/* time envelope shaping when the current frame is TRANSIENT frame */
- time_envelop_shaping_fx( hb_synth_fx16, SWB_tenv_tmp_fx, output_frame, &Q_syn_hb );
+ time_envelop_shaping_ivas_fx( hb_synth_fx16, SWB_tenv_tmp_fx, output_frame, &Q_syn_hb );
+
Q_syn_hb = sub( Q_syn_hb, 3 );
hBWE_FD->prev_td_energy_fx = SWB_tenv_fx[3];
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.c b/lib_enc/ACcontextMapping_enc.c
deleted file mode 100644
index 250bfcf1ba83a538bcbe37c040e151911684b936..0000000000000000000000000000000000000000
--- a/lib_enc/ACcontextMapping_enc.c
+++ /dev/null
@@ -1,712 +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 "ivas_prot.h" /* Range coder header file */
-#include "ivas_rom_com.h"
-#include "ivas_rom_enc.h"
-#include "wmc_auto.h"
-#include "prot_fx.h"
-
-
-/*-------------------------------------------------------------------*
- * ACcontextMapping_encode2_no_mem_s17_LC()
- *
- * Arithmetic encoder
- *-------------------------------------------------------------------*/
-/*-------------------------------------------------------------------*
- * find_last_nz_pair()
- *
- *
- *-------------------------------------------------------------------*/
-
-static Word16 find_last_nz_pair(
- const Word16 x[],
- const Word16 length,
- const CONTEXT_HM_CONFIG *hm_cfg )
-{
- Word16 last_nz, i;
- const Word16 *tmp;
-
- last_nz = 2;
- move16();
-
- IF( hm_cfg )
- {
- /* mapped kernel */
- tmp = hm_cfg->indexBuffer;
-
- FOR( i = length; i >= 4; i -= 2 )
- {
- test();
- IF( x[tmp[i - 2]] || x[tmp[i - 1]] )
- {
- last_nz = i;
- move16();
- BREAK;
- }
- }
- }
- ELSE
- {
- /* unmapped kernel */
-
- FOR( i = length; i >= 4; i -= 2 )
- {
- test();
- IF( x[i - 2] || x[i - 1] )
- {
- last_nz = i;
- move16();
- BREAK;
- }
- }
- }
-
- return last_nz;
-}
-
-
-/*-------------------------------------------------------------------*
- * ACcontextMapping_encode2_estimate_no_mem_s17_LC()
- *
- *
- *-------------------------------------------------------------------*/
-/*-------------------------------------------------------------------*
- * RCcontextMapping_encode2_estimate_no_mem_s17_LCS()
- *
- * Range coder bit-estimation
- *-------------------------------------------------------------------*/
-
-Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS(
- Word16 *x, /* Spectral coefficients */
- const Word16 nt, /* L - size of spectrum (no. of spectral coefficients) */
- Word16 *lastnz_out,
- Word16 *nEncoded, /* No. of spectral coefficients that can be coded without an overflow occuring */
- const Word16 target, /* Target bits */
- Word16 *stop,
- Word16 mode,
- CONTEXT_HM_CONFIG *hm_cfg /* context-based harmonic model configuration */
-)
-{
- /* Common variables */
- Word16 a1, b1;
- Word16 k, pki, lev1;
- UWord16 t;
- Word16 lastnz, lastnz2;
- Word16 rateFlag;
- Word32 bit_estimate_fx;
- Word16 bit_estimate_e;
- Word16 symbol;
- const UWord8 *lookup;
- Word32 nbits2_fx; // Q23
- Word16 nbits2_e; // Q23
-
- /* Initialization */
- bit_estimate_fx = 2 * ONE_IN_Q29;
- bit_estimate_e = 2;
- move32();
- nbits2_fx = 0;
- nbits2_e = 0;
- move32();
-
- /* bits to encode lastnz */
- k = 1;
- move16();
-
- WHILE( LT_16( k, nt / 2 ) )
- {
- bit_estimate_fx = BASOP_Util_Add_Mant32Exp( bit_estimate_fx, bit_estimate_e, ONE_IN_Q30, 1, &bit_estimate_e );
- k = k << 1;
- /* check while condition */
- }
-
- nbits2_fx = bit_estimate_fx;
- nbits2_e = bit_estimate_e;
-
- IF( hm_cfg )
- {
- Word16 a1_i, b1_i;
- Word16 stop2;
- Word16 total_output_bits;
- Word16 nt_half;
- Word32 c[2], *ctx;
- Word32 p1, p2;
- Word16 ii[2];
- Word16 idx1, idx2, idx;
- Word16 numPeakIndicesOrig = 0, numHoleIndices = 0; /* only to avoid compiler warning */
- move16();
- move16();
-
- /* Rate flag */
- IF( GT_16( target, 400 ) )
- {
- rateFlag = 2 << NBITS_CONTEXT; /* Select context-A for higher bitrates */
- move16();
- }
- ELSE
- {
- rateFlag = 0; /* Select context-B for lower bitrates */
- move16();
- }
-
- nt_half = shr( nt, 1 );
- move16();
- stop2 = 0;
- move16();
- c[0] = c[1] = 0;
- move32();
- move32();
-
- /* Find last non-zero tuple in the mapped domain signal */
- lastnz = find_last_nz_pair( x, nt, hm_cfg );
-
- lastnz2 = 2;
- move16();
-
- /* mapped domain */
- numPeakIndicesOrig = hm_cfg->numPeakIndices;
- move16();
- hm_cfg->numPeakIndices = s_min( hm_cfg->numPeakIndices, lastnz );
- move16();
- numHoleIndices = sub( lastnz, hm_cfg->numPeakIndices );
-
- /* Mark hole indices beyond lastnz as pruned */
- FOR( k = numHoleIndices; k < hm_cfg->numHoleIndices; ++k )
- {
- hm_cfg->holeIndices[k] = add( hm_cfg->holeIndices[k], nt );
- move16();
- }
-
- ii[0] = numPeakIndicesOrig;
- move16();
- ii[1] = 0;
- move16();
-
- p1 = p2 = 0; /* to avoid compilation warnings */
- move32();
- move32();
-
- /* Main Loop through the 2-tuples */
- FOR( k = 0; k < lastnz; k += 2 )
- {
- a1_i = get_next_coeff_mapped_ivas_fx( ii, &p1, &idx1, hm_cfg );
- b1_i = get_next_coeff_mapped_ivas_fx( ii, &p2, &idx2, hm_cfg );
-
- idx = s_min( idx1, idx2 );
-
- /* Get context */
- ctx = &c[L_or( p1, p2 )];
-
- t = (UWord16) L_add( *ctx, rateFlag );
- IF( LT_16( nt_half, idx ) )
- {
- t = add( t, ( 1 << NBITS_CONTEXT ) );
- }
-
- /* Init current 2-tuple encoding */
- a1 = (Word16) abs( x[a1_i] );
- b1 = (Word16) abs( x[b1_i] );
- lev1 = -( 1 << ( NBITS_CONTEXT + NBITS_RATEQ ) );
-
- bit_estimate_fx = BASOP_Util_Add_Mant32Exp( bit_estimate_fx, bit_estimate_e, s_min( a1, 1 ) * ONE_IN_Q30, 1, &bit_estimate_e );
- bit_estimate_fx = BASOP_Util_Add_Mant32Exp( bit_estimate_fx, bit_estimate_e, s_min( b1, 1 ) * ONE_IN_Q30, 1, &bit_estimate_e );
-
- /* pre-compute address of ari_pk_s17_LC_ext[0][Val_esc] to avoid doing it multiple times inside the loop */
- lookup = &ari_lookup_s17_LC[t] + ( 1 << ( NBITS_CONTEXT + NBITS_RATEQ ) );
-
- /* check while condition */
- /* MSBs coding */
- WHILE( GE_16( s_max( a1, b1 ), A_THRES ) )
- {
- pki = lookup[lev1]; /* ESC symbol */
-
- bit_estimate_fx = BASOP_Util_Add_Mant32Exp( bit_estimate_fx, bit_estimate_e, ari_bit_estimate_s17_LC_fx[pki][VAL_ESC], 8, &bit_estimate_e );
- bit_estimate_fx = BASOP_Util_Add_Mant32Exp( bit_estimate_fx, bit_estimate_e, 2 * ONE_IN_Q29, 2, &bit_estimate_e ); /* Add 2 LSB bits corresponding to the bit-plane */
-
- ( a1 ) = shr( a1, 1 );
- ( b1 ) = shr( b1, 1 );
-
- lev1 = s_min( add( lev1, ( 1 << ( NBITS_CONTEXT + NBITS_RATEQ ) ) ), 2 << ( NBITS_CONTEXT + NBITS_RATEQ ) );
-
- /* check while condition */
- }
-
- pki = lookup[lev1];
-
- symbol = add( a1, i_mult( A_THRES, b1 ) );
- bit_estimate_fx = BASOP_Util_Add_Mant32Exp( bit_estimate_fx, bit_estimate_e, ari_bit_estimate_s17_LC_fx[pki][symbol], 8, &bit_estimate_e );
-
- /* Should we truncate? */
- IF( GT_32( L_shr( bit_estimate_fx, sub( Q16, bit_estimate_e ) ), L_shl( target, Q15 ) ) )
- {
- stop2 = 1;
- move16();
-
- IF( *stop )
- {
- BREAK;
- }
- }
- ELSE
- {
- lastnz2 = add( b1_i, 1 );
- nbits2_fx = bit_estimate_fx;
- move32();
- nbits2_e = bit_estimate_e;
- move16();
- }
-
- /* Update context for next 2-tuple */
- IF( EQ_32( p1, p2 ) ) /* peak-peak or hole-hole context */
- {
- lev1 = shr( lev1, NBITS_CONTEXT + NBITS_RATEQ );
-
- IF( lev1 <= 0 )
- {
- t = add( 1, i_mult( add( a1, b1 ), add( lev1, 2 ) ) );
- }
- ELSE
- {
- t = add( 13, lev1 );
- }
-
- *ctx = L_add( imult3216( L_and( *ctx, 0xf ), 16 ), t );
- move32();
- }
- ELSE
- {
- /* mixed context */
-
- IF( s_and( idx1, 1 ) )
- {
- /* update first context */
- c[p1] = update_mixed_context_ivas_fx( c[p1], (Word16) abs( x[a1_i] ) );
- move32();
- }
-
- IF( s_and( idx2, 1 ) )
- {
- /* update second context */
- c[p2] = update_mixed_context_ivas_fx( c[p2], (Word16) abs( x[b1_i] ) );
- move32();
- }
- }
-
- } /*end of the 2-tuples loop*/
-
- total_output_bits = round_fx( L_shr( bit_estimate_fx, sub( Q15, bit_estimate_e ) ) );
-
- IF( *stop )
- {
- total_output_bits = round_fx( L_shr( nbits2_fx, sub( Q15, nbits2_e ) ) );
- }
-
- IF( stop2 )
- {
- stop2 = total_output_bits;
- move16();
- }
-
- *nEncoded = lastnz2;
- move16();
- *stop = stop2; /* If zero, it means no overflow occured during bit-estimation */
- move16();
- *lastnz_out = lastnz;
- move16();
-
- /* Restore hole indices beyond lastnz */
- FOR( k = numHoleIndices; k < hm_cfg->numHoleIndices; ++k )
- {
- hm_cfg->holeIndices[k] = sub( hm_cfg->holeIndices[k], nt );
- move16();
- }
- hm_cfg->numPeakIndices = numPeakIndicesOrig;
- move16();
-
- return round_fx( L_add( L_shr( nbits2_fx, sub( Q15, nbits2_e ) ), ONE_IN_Q14 ) );
- }
- ELSE /* if (!hm_cfg) */
- {
- Word16 esc_nb, cp, rateQ;
- UWord16 s;
- Word16 tot_bits2;
- Word16 overflow_flag = 0;
-
- /* Rate flag */
- IF( GT_16( target, 400 ) )
- {
- rateFlag = 2;
- move16();
- }
- ELSE
- {
- rateFlag = 0; /* Select context-B for lower bitrates */
- move16();
- }
-
- t = 0;
- move16();
- s = 0;
- move16();
- cp = 0;
- move16();
- lastnz = 1;
- move16();
- lastnz2 = 0;
- move16();
- tot_bits2 = 0;
- move16();
-
- /* Find last non-zero tuple in the mapped domain signal */
- FOR( lastnz = sub( nt, 2 ); lastnz >= 0; lastnz -= 2 )
- {
- test();
- IF( ( x[lastnz] != 0 ) || ( x[lastnz + 1] != 0 ) )
- {
- BREAK;
- }
- }
- lastnz = add( lastnz, 2 );
- IF( LT_16( lastnz, 2 ) )
- {
- lastnz = 2; /* At least one tuple is coded */
- move16();
- }
-
- lastnz2 = 2;
- move16();
-
- /* Main Loop through the 2-tuples */
- FOR( k = 0; k < lastnz; k += 2 )
- {
- /* Init current 2-tuple encoding */
- a1 = abs_s( x[k] );
- b1 = abs_s( x[k + 1] );
- lev1 = 0;
- move16();
- esc_nb = 0;
- move16();
- rateQ = add( rateFlag, (Word16) GT_16( k, shr( nt, 1 ) ) );
-
- bit_estimate_fx = BASOP_Util_Add_Mant32Exp( bit_estimate_fx, bit_estimate_e, s_min( a1, 1 ) * ONE_IN_Q30, 1, &bit_estimate_e );
- bit_estimate_fx = BASOP_Util_Add_Mant32Exp( bit_estimate_fx, bit_estimate_e, s_min( b1, 1 ) * ONE_IN_Q30, 1, &bit_estimate_e );
-
- /* pre-compute address of ari_pk_s17_LC_ext[0][Val_esc] to avoid doing it multiple times inside the loop */
- lookup = &ari_lookup_s17_LC[t + shl( rateQ, NBITS_CONTEXT )];
-
- /* check while condition */
- /* MSBs coding */
- WHILE( GE_16( s_max( a1, b1 ), A_THRES ) )
- {
- pki = lookup[( esc_nb << ( NBITS_CONTEXT + NBITS_RATEQ ) )];
-
- bit_estimate_fx = BASOP_Util_Add_Mant32Exp( bit_estimate_fx, bit_estimate_e, ari_bit_estimate_s17_LC_fx[pki][VAL_ESC], 8, &bit_estimate_e );
- bit_estimate_fx = BASOP_Util_Add_Mant32Exp( bit_estimate_fx, bit_estimate_e, 2 * ONE_IN_Q29, 2, &bit_estimate_e ); /* Add 2 LSB bits corresponding to the bit-plane */
-
- ( a1 ) = shr( a1, 1 );
- ( b1 ) = shr( b1, 1 );
-
- lev1 = add( lev1, 1 );
- esc_nb = s_min( lev1, 3 );
-
- /* check while condition */
- }
-
- pki = lookup[( esc_nb << ( NBITS_CONTEXT + NBITS_RATEQ ) )];
-
- symbol = add( a1, i_mult( A_THRES, b1 ) );
- bit_estimate_fx = BASOP_Util_Add_Mant32Exp( bit_estimate_fx, bit_estimate_e, ari_bit_estimate_s17_LC_fx[pki][symbol], 8, &bit_estimate_e );
-
- /* Should we truncate? */
- IF( GT_32( L_shr( bit_estimate_fx, sub( Q16, bit_estimate_e ) ), L_shl( target, Q15 ) ) ) /* Overflow occured */
- {
- overflow_flag = 1;
- move16();
- }
- ELSE
- {
- IF( abs_s( x[k] ) || abs_s( x[k + 1] ) ) /* No overflow & non-zero tuple */
- {
- nbits2_fx = bit_estimate_fx;
- nbits2_e = bit_estimate_e;
- move32();
- lastnz2 = add( k, 2 );
- }
- }
-
- /* Update context for next 2-tuple */
- IF( LT_16( esc_nb, 2 ) )
- {
- cp = add( 1, i_mult( add( a1, b1 ), add( esc_nb, 1 ) ) );
- }
- ELSE
- {
- cp = add( 12, esc_nb );
- }
- /*shift old bits and replace last 4 bits*/
- s = ( s << 4 ) + cp;
- t = ( s & 0xFF );
-
- } /*end of the 2-tuples loop*/
-
- tot_bits2 = round_fx( L_shr( nbits2_fx, sub( Q15, nbits2_e ) ) );
- IF( lastnz2 < lastnz ) /* Overflow occured because unable to code all tuples */
- {
- overflow_flag = 1;
- move16();
- }
- IF( EQ_16( mode, -1 ) )
- {
- tot_bits2 = round_fx( L_shr( bit_estimate_fx, sub( Q15, bit_estimate_e ) ) );
- }
- IF( overflow_flag == 0 ) /* No overflow */
- {
- *stop = 0;
- move16();
- }
- ELSE /* Overflow */
- {
- IF( *stop ){
- *stop = tot_bits2;
- move16();
- }
- ELSE
- {
- *stop = round_fx( L_shr( bit_estimate_fx, sub( Q15, bit_estimate_e ) ) );
- move16();
- }
-}
-
-*lastnz_out = lastnz;
-move16();
-*nEncoded = lastnz2;
-move16();
-/* Safety mechanism to avoid overflow */
-test();
-IF( EQ_16( lastnz2, 2 ) && EQ_16( overflow_flag, 1 ) )
-{
- FOR( k = 0; k < lastnz2; k++ )
- {
- x[k] = 0;
- move16();
- }
-}
-
-return tot_bits2;
-}
-}
-
-/*-------------------------------------------------------------------*
- * RCcontextMapping_encode2_estimate_bandWise_start()
- *
- * Range coder - start bandwise bit-estimation
- *-------------------------------------------------------------------*/
-
-Word16 RCcontextMapping_encode2_estimate_bandWise_start(
- Word16 *x,
- const Word16 nt,
- const Word16 target,
- HANDLE_RC_CONTEXT_MEM hContextMem )
-{
- Word16 i, k;
-
- /* Rate flag */
- IF( GT_16( target, 400 ) )
- {
- hContextMem->rateFlag = 2 << NBITS_CONTEXT;
- move16();
- }
- ELSE
- {
- hContextMem->rateFlag = 0;
- move16();
- }
-
- hContextMem->bit_estimate_fx = 2;
- move32();
- hContextMem->bit_estimate_e = Q31;
- move16();
-
-
- /* Init */
- hContextMem->nt_half = shr( nt, 1 );
- move16();
-
- /* bits to encode lastnz */
- k = 1;
- move16();
-
- WHILE( LT_16( k, hContextMem->nt_half ) )
- {
- hContextMem->bit_estimate_fx = L_add( hContextMem->bit_estimate_fx, 1 );
- move32();
-
- k = shl( k, 1 );
- /* check while condition */
- }
-
- /* bits to encode lastnz */
- hContextMem->nbits_old = extract_l( hContextMem->bit_estimate_fx );
- move16();
-
- hContextMem->ctx = 0;
- move16();
- hContextMem->lastnz = 2;
- move16();
-
- /* Find last non-zero tuple */
-
- FOR( i = nt; i >= 4; i -= 2 )
- {
- test();
- IF( x[i - 2] != 0 || x[i - 1] != 0 )
- {
- hContextMem->lastnz = i;
- move16();
- break;
- }
- }
- Word16 tmp2 = extract_l( hContextMem->bit_estimate_fx );
- Word16 tmp = norm_l( hContextMem->bit_estimate_fx );
- hContextMem->bit_estimate_e = sub( Q31, tmp );
- move16();
- hContextMem->bit_estimate_fx = L_shl( hContextMem->bit_estimate_fx, tmp );
- move32();
-
- return tmp2;
-}
-
-/*-------------------------------------------------------------------*
- * RCcontextMapping_encode2_estimate_bandWise()
- *
- * Range coder - bandwise bit-estimation
- *-------------------------------------------------------------------*/
-
-Word16 RCcontextMapping_encode2_estimate_bandWise(
- Word16 *x,
- const Word16 start_line,
- const Word16 end_line,
- HANDLE_RC_CONTEXT_MEM hContextMem )
-{
- Word16 a1, b1, a1_i, b1_i;
- Word16 k, pki, lev1;
- UWord16 t;
- Word16 bandBits = 0;
- move16();
- Word16 total_output_bits; /* No. of bits after finalization */
- Word16 symbol;
- const UWord8 *lookup;
- Word16 idx;
-
- /* Main Loop through the 2-tuples */
- /*hContextMem->nt_half = end_line >> 1;*/
- FOR( k = start_line; k < min( hContextMem->lastnz, end_line ); k += 2 )
- {
- a1_i = k;
- move16();
- b1_i = add( k, 1 );
-
- idx = k;
- move16();
-
- /* Get context */
- t = add( hContextMem->ctx, hContextMem->rateFlag );
- t = add( t, GE_16( hContextMem->nt_half, idx ) ? 0 : ( 1 << NBITS_CONTEXT ) );
-
- /* Init current 2-tuple encoding */
- a1 = abs_s( x[a1_i] );
- b1 = abs_s( x[b1_i] );
- lev1 = -( 1 << ( NBITS_CONTEXT + NBITS_RATEQ ) );
-
- /* Signs Bits */
- hContextMem->bit_estimate_fx = BASOP_Util_Add_Mant32Exp( hContextMem->bit_estimate_fx, hContextMem->bit_estimate_e, s_min( a1, 1 ) * ONE_IN_Q30, Q1, &hContextMem->bit_estimate_e );
- hContextMem->bit_estimate_fx = BASOP_Util_Add_Mant32Exp( hContextMem->bit_estimate_fx, hContextMem->bit_estimate_e, s_min( b1, 1 ) * ONE_IN_Q30, Q1, &hContextMem->bit_estimate_e );
-
- /* pre-compute address of ari_pk_s17_LC_ext[0][Val_esc] to avoid doing it multiple times inside the loop */
- lookup = &ari_lookup_s17_LC[t] + ( 1 << ( NBITS_CONTEXT + NBITS_RATEQ ) );
-
- /* check while condition */
- /* MSBs coding */
- WHILE( GE_16( s_max( a1, b1 ), A_THRES ) )
- {
- pki = lookup[lev1];
- hContextMem->bit_estimate_fx = BASOP_Util_Add_Mant32Exp( hContextMem->bit_estimate_fx, hContextMem->bit_estimate_e, ari_bit_estimate_s17_LC_fx[pki][VAL_ESC], Q8, &hContextMem->bit_estimate_e );
- hContextMem->bit_estimate_fx = BASOP_Util_Add_Mant32Exp( hContextMem->bit_estimate_fx, hContextMem->bit_estimate_e, 2 * ONE_IN_Q29, Q2, &hContextMem->bit_estimate_e ); /* Add the 2 LSB bits that were shifted out */
- // hContextMem->bit_estimate = hContextMem->bit_estimate + ari_bit_estimate_s17_LC[pki][VAL_ESC];
- // hContextMem->bit_estimate += 2; /* Add the 2 LSB bits that were shifted out */
-
- ( a1 ) = shr( a1, 1 );
- ( b1 ) = shr( b1, 1 );
-
- lev1 = s_min( add( lev1, ( 1 << ( NBITS_CONTEXT + NBITS_RATEQ ) ) ), 2 << ( NBITS_CONTEXT + NBITS_RATEQ ) );
- /* check while condition */
- }
-
- pki = lookup[lev1];
- symbol = add( a1, i_mult( A_THRES, b1 ) ); /* MSB symbol */
- hContextMem->bit_estimate_fx = BASOP_Util_Add_Mant32Exp( hContextMem->bit_estimate_fx, hContextMem->bit_estimate_e, ari_bit_estimate_s17_LC_fx[pki][symbol], Q8, &hContextMem->bit_estimate_e );
- // hContextMem->bit_estimate = hContextMem->bit_estimate + ari_bit_estimate_s17_LC[pki][symbol];
-
- /* Update context */
- lev1 = shr( lev1, NBITS_CONTEXT + NBITS_RATEQ );
-
- IF( lev1 <= 0 )
- {
- t = add( 1, i_mult( add( a1, b1 ), add( lev1, 2 ) ) );
- }
- ELSE
- {
- t = add( 13, lev1 );
- }
-
- hContextMem->ctx = add( i_mult( s_and( hContextMem->ctx, 0xf ), 16 ), t );
-
- } /*end of the 2-tuples loop*/
- total_output_bits = round_fx( L_shr( hContextMem->bit_estimate_fx, sub( Q15, hContextMem->bit_estimate_e ) ) );
- // total_output_bits = (Word16) ( hContextMem->bit_estimate + 0.5f );
-
- bandBits = sub( total_output_bits, hContextMem->nbits_old );
- hContextMem->nbits_old = total_output_bits;
- move16();
-
- return bandBits;
-}
diff --git a/lib_enc/ACcontextMapping_enc_fx.c b/lib_enc/ACcontextMapping_enc_fx.c
index 21089de9fd00cfbd08cbc87a2f430cc26fd55f69..08baa4f3d23dcbd61f5d030b675c9afdaed50180 100644
--- a/lib_enc/ACcontextMapping_enc_fx.c
+++ b/lib_enc/ACcontextMapping_enc_fx.c
@@ -7,11 +7,14 @@
#include "options.h"
#include "basop_util.h"
#include "cnst.h"
+#include "prot.h"
#include "prot_fx.h"
#include "ivas_prot_fx.h"
#include "rom_com.h"
#include "ivas_rom_com.h"
+#include "ivas_rom_enc.h"
#include "prot_fx_enc.h"
+#include "ivas_prot.h" /* Range coder header file */
/*-------------------------------------------------------------------*
* ACcontextMapping_encode2_no_mem_s17_LC_fx()
@@ -29,11 +32,11 @@
*/
void ACcontextMapping_encode2_no_mem_s17_LC_fx(
BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
- Word16 *x,
- Word16 nt,
- Word16 lastnz,
- Word16 nbbits,
- Word16 resQMaxBits,
+ Word16 *x, /* Q0 */
+ Word16 nt, /* Q0 */
+ Word16 lastnz, /* Q0 */
+ Word16 nbbits, /* Q0 */
+ Word16 resQMaxBits, /* Q0 */
CONTEXT_HM_CONFIG *hm_cfg )
{
Word16 ptr[BITBUFSIZE];
@@ -57,7 +60,8 @@ void ACcontextMapping_encode2_no_mem_s17_LC_fx(
a1 = 0; /* to avoid compilation warnings */
b1 = 0; /* to avoid compilation warnings */
-
+ move16();
+ move16();
/* Rate flag */
rateFlag = 0;
@@ -75,41 +79,41 @@ void ACcontextMapping_encode2_no_mem_s17_LC_fx(
move16();
/* Bits for encoding the number of encoded tuples */
- nbbits_ntuples = sub( 14, norm_s( negate( nt ) ) );
+ nbbits_ntuples = sub( 14, norm_s( negate( nt ) ) ); /* Q0 */
t = 0;
move16();
- bp = nbbits_ntuples;
+ bp = nbbits_ntuples; /* Q0 */
move16();
nbbits_signs = 0;
move16();
nbbits_lsbs = 0;
move16();
- nbbits_m2 = sub( nbbits, 2 );
+ nbbits_m2 = sub( nbbits, 2 ); /* Q0 */
flag_overflow = 0;
move16();
IF( hm_cfg ) /* mapped domain */
{
- numPeakIndicesOrig = hm_cfg->numPeakIndices;
+ numPeakIndicesOrig = hm_cfg->numPeakIndices; /* Q0 */
move16();
- hm_cfg->numPeakIndices = s_min( hm_cfg->numPeakIndices, lastnz );
+ hm_cfg->numPeakIndices = s_min( hm_cfg->numPeakIndices, lastnz ); /* Q0 */
move16();
- numHoleIndices = sub( lastnz, hm_cfg->numPeakIndices );
+ numHoleIndices = sub( lastnz, hm_cfg->numPeakIndices ); /* Q0 */
/* Mark hole indices beyond lastnz as pruned */
FOR( k = numHoleIndices; k < hm_cfg->numHoleIndices; ++k )
{
- hm_cfg->holeIndices[k] = add( hm_cfg->holeIndices[k], nt );
+ hm_cfg->holeIndices[k] = add( hm_cfg->holeIndices[k], nt ); /* Q0 */
move16();
}
- ii[0] = numPeakIndicesOrig;
+ ii[0] = numPeakIndicesOrig; /* Q0 */
move16();
ii[1] = 0;
move16();
- get_next_coeff = get_next_coeff_mapped;
+ get_next_coeff = get_next_coeff_mapped; /* Q0 */
move16();
}
ELSE /* unmapped domain */
@@ -121,7 +125,7 @@ void ACcontextMapping_encode2_no_mem_s17_LC_fx(
move16();
move16();
- get_next_coeff = get_next_coeff_unmapped;
+ get_next_coeff = get_next_coeff_unmapped; /* Q0 */
move16();
/* Find last non-zero tuple */
@@ -133,7 +137,7 @@ void ACcontextMapping_encode2_no_mem_s17_LC_fx(
WHILE( s_or( x[lastnz - 1], x[lastnz - 2] ) == 0 )
{
- lastnz = sub( lastnz, 2 );
+ lastnz = sub( lastnz, 2 ); /* Q0 */
}
x[0] = a1;
move16();
@@ -150,21 +154,20 @@ void ACcontextMapping_encode2_no_mem_s17_LC_fx(
FOR( k = 0; k < lastnz; k += 2 )
{
/* First coefficient */
- a1_i = get_next_coeff( ii, &p1, &idx1, hm_cfg );
+ a1_i = get_next_coeff( ii, &p1, &idx1, hm_cfg ); /* Q0 */
/* Second coefficient */
- b1_i = get_next_coeff( ii, &p2, &idx2, hm_cfg );
+ b1_i = get_next_coeff( ii, &p2, &idx2, hm_cfg ); /* Q0 */
- idx = s_min( idx1, idx2 );
+ idx = s_min( idx1, idx2 ); /* Q0 */
/* Get context */
- ctx = &c[s_or( p1, p2 )];
- move16();
+ ctx = &c[s_or( p1, p2 )]; /* Q0 */
/* _DIFF_FLOAT_FIX_ float is using t as UWord16 */
- t = add( *ctx, rateFlag );
+ t = add( *ctx, rateFlag ); /* Q0 */
if ( GT_16( idx, nt_half ) )
{
- t = add( t, 1 << NBITS_CONTEXT );
+ t = add( t, 1 << NBITS_CONTEXT ); /* Q0 */
}
/* Init current 2-tuple encoding */
@@ -179,43 +182,43 @@ void ACcontextMapping_encode2_no_mem_s17_LC_fx(
move16();
}
- a1 = abs_s( x[a1_i] );
- b1 = abs_s( x[b1_i] );
+ a1 = abs_s( x[a1_i] ); /* Q0 */
+ b1 = abs_s( x[b1_i] ); /* Q0 */
lev1 = -1;
move16();
/*Copy states*/
ari_copy_states_fx( &as, &as_overflow );
- bp_overflow = bp;
+ bp_overflow = bp; /* Q0 */
move16();
- nbbits_signs_overflow = nbbits_signs;
+ nbbits_signs_overflow = nbbits_signs; /* Q0 */
move16();
- nbbits_lsbs_overflow = nbbits_lsbs;
+ nbbits_lsbs_overflow = nbbits_lsbs; /* Q0 */
move16();
/*Signs encoding*/
- signs[nbbits_signs] = lshr( x[a1_i], 15 );
+ signs[nbbits_signs] = lshr( x[a1_i], 15 ); /* Q0 */
move16();
if ( a1 > 0 )
{
- nbbits_signs = add( nbbits_signs, 1 );
+ nbbits_signs = add( nbbits_signs, 1 ); /* Q0 */
}
- signs[nbbits_signs] = lshr( x[b1_i], 15 );
+ signs[nbbits_signs] = lshr( x[b1_i], 15 ); /* Q0 */
move16();
if ( b1 > 0 )
{
- nbbits_signs = add( nbbits_signs, 1 );
+ nbbits_signs = add( nbbits_signs, 1 ); /* Q0 */
}
/* MSBs coding */
WHILE( GE_16( s_max( a1, b1 ), A_THRES ) )
{
- tmp = add( t, Tab_esc_nb[lev1 + 1] );
+ tmp = add( t, Tab_esc_nb[lev1 + 1] ); /* Q0 */
assert( tmp >= 0 && tmp < 4096 );
- pki = ari_lookup_s17_LC[tmp];
+ pki = ari_lookup_s17_LC[tmp]; /* Q0 */
move16();
- bp = ari_encode_14bits_ext_fx( ptr, bp, &as, VAL_ESC, ari_pk_s17_LC_ext[pki] );
+ bp = ari_encode_14bits_ext_fx( ptr, bp, &as, VAL_ESC, ari_pk_s17_LC_ext[pki] ); /* Q0 */
*lsbs_bits2-- = s_and( a1, 1 );
move16();
@@ -223,32 +226,32 @@ void ACcontextMapping_encode2_no_mem_s17_LC_fx(
move16();
/* LSBs bit counting */
- nbbits_lsbs = add( nbbits_lsbs, 2 );
+ nbbits_lsbs = add( nbbits_lsbs, 2 ); /* Q0 */
a1 = shr( a1, 1 );
b1 = shr( b1, 1 );
- lev1 = s_min( add( lev1, 1 ), 2 );
+ lev1 = s_min( add( lev1, 1 ), 2 ); /* Q0 */
}
- tmp = add( t, Tab_esc_nb[lev1 + 1] );
+ tmp = add( t, Tab_esc_nb[lev1 + 1] ); /* Q0 */
assert( tmp >= 0 && tmp < 4096 );
- pki = ari_lookup_s17_LC[tmp];
+ pki = ari_lookup_s17_LC[tmp]; /* Q0 */
move16();
- bp = ari_encode_14bits_ext_fx( ptr, bp, &as, add( a1, shl( b1, A_THRES_SHIFT ) ), ari_pk_s17_LC_ext[pki] );
+ bp = ari_encode_14bits_ext_fx( ptr, bp, &as, add( a1, shl( b1, A_THRES_SHIFT ) ), ari_pk_s17_LC_ext[pki] ); /* Q0 */
/* Check bit budget */
IF( GT_16( add( add( add( bp, extract_l( as.value ) ), nbbits_signs ), nbbits_lsbs ), nbbits_m2 ) )
{
ari_copy_states_fx( &as_overflow, &as );
- bp = bp_overflow;
+ bp = bp_overflow; /* Q0 */
move16();
IF( flag_overflow == 0 )
{
- nbbits_signs = nbbits_signs_overflow;
+ nbbits_signs = nbbits_signs_overflow; /* Q0 */
move16();
- nbbits_lsbs = nbbits_lsbs_overflow;
+ nbbits_lsbs = nbbits_lsbs_overflow; /* Q0 */
move16();
IF( hm_cfg )
{
@@ -264,14 +267,14 @@ void ACcontextMapping_encode2_no_mem_s17_LC_fx(
move16();
assert( t >= 0 && t < 4096 );
- pki = ari_lookup_s17_LC[t];
+ pki = ari_lookup_s17_LC[t]; /* Q0 */
move16();
- bp = ari_encode_14bits_ext_fx( ptr, bp, &as, 0, ari_pk_s17_LC_ext[pki] );
+ bp = ari_encode_14bits_ext_fx( ptr, bp, &as, 0, ari_pk_s17_LC_ext[pki] ); /* Q0 */
IF( GT_16( add( add( add( bp, extract_l( as.value ) ), nbbits_signs ), nbbits_lsbs ), nbbits_m2 ) )
{
ari_copy_states_fx( &as_overflow, &as );
- bp = bp_overflow;
+ bp = bp_overflow; /* Q0 */
move16();
BREAK;
}
@@ -297,27 +300,27 @@ void ACcontextMapping_encode2_no_mem_s17_LC_fx(
if ( lev1 == 0 )
t = add( t, t );
- *ctx = add( shl( s_and( *ctx, 0xf ), 4 ), add( t, 1 ) );
+ *ctx = add( shl( s_and( *ctx, 0xf ), 4 ), add( t, 1 ) ); /* Q0 */
move16();
}
ELSE /* mixed context */
{
IF( s_and( idx1, 1 ) ) /* update first context */
{
- c[p1] = update_mixed_context( c[p1], abs_s( x[a1_i] ) );
+ c[p1] = update_mixed_context( c[p1], abs_s( x[a1_i] ) ); /* Q0 */
move16();
}
IF( s_and( idx2, 1 ) ) /* update second context */
{
- c[p2] = update_mixed_context( c[p2], abs_s( x[b1_i] ) );
+ c[p2] = update_mixed_context( c[p2], abs_s( x[b1_i] ) ); /* Q0 */
move16();
}
}
} /*end of the 2-tuples loop*/
/* End arithmetic coder, overflow management */
- bp = ari_done_encoding_14bits_fx( ptr, bp, &as );
+ bp = ari_done_encoding_14bits_fx( ptr, bp, &as ); /* Q0 */
/* Overflow is detected */
IF( NE_16( k, lastnz ) )
@@ -325,20 +328,20 @@ void ACcontextMapping_encode2_no_mem_s17_LC_fx(
IF( hm_cfg )
{
/* Fill with zero to be sure that the decoder finishes the MSB decoding at the same position */
- tmp = sub( nbbits, add( nbbits_signs, nbbits_lsbs ) );
+ tmp = sub( nbbits, add( nbbits_signs, nbbits_lsbs ) ); /* Q0 */
set16_fx( &ptr[bp], 0, sub( tmp, bp ) );
bp = tmp;
move16();
}
if ( !hm_cfg )
{
- lastnz = k;
+ lastnz = k; /* Q0 */
move16();
}
}
/* Push number of encoded tuples */
- value = sub( shr( lastnz, 1 ), 1 );
+ value = sub( shr( lastnz, 1 ), 1 ); /* Q0 */
push_next_indice_fx( hBstr, value, nbbits_ntuples );
/* Push arithmetic coded bits */
@@ -346,17 +349,17 @@ void ACcontextMapping_encode2_no_mem_s17_LC_fx(
/* Push sign bits */
push_next_bits_fx( hBstr, signs, nbbits_signs );
- bp = add( bp, nbbits_signs );
+ bp = add( bp, nbbits_signs ); /* Q0 */
/*write residual Quantization bits*/
- tmp = s_min( sub( sub( nbbits, bp ), nbbits_lsbs ), resQMaxBits );
+ tmp = s_min( sub( sub( nbbits, bp ), nbbits_lsbs ), resQMaxBits ); /* Q0 */
FOR( k = 0; k < tmp; k++ )
{
- ptr[nbbits - 1 - nbbits_lsbs - k] = x[nt + k];
+ ptr[nbbits - 1 - nbbits_lsbs - k] = x[nt + k]; /* Q0 */
move16();
}
/* Write filler bits */
- tmp = sub( nbbits, add( bp, nbbits_lsbs ) );
+ tmp = sub( nbbits, add( bp, nbbits_lsbs ) ); /* Q0 */
FOR( ; k < tmp; ++k )
{
ptr[nbbits - 1 - nbbits_lsbs - k] = 0;
@@ -378,7 +381,7 @@ void ACcontextMapping_encode2_no_mem_s17_LC_fx(
*
*-------------------------------------------------------------------*/
static Word16 find_last_nz_pair(
- const Word16 x[],
+ const Word16 x[], /* Q0 */
Word16 length,
const CONTEXT_HM_CONFIG *hm_cfg )
{
@@ -387,7 +390,7 @@ static Word16 find_last_nz_pair(
if ( hm_cfg )
{
- tmp = hm_cfg->indexBuffer;
+ tmp = hm_cfg->indexBuffer; /* Q0 */
move16();
}
@@ -395,9 +398,9 @@ static Word16 find_last_nz_pair(
move16();
lobs[1] = shr( length, 1 ); /* length/2 */
move16();
- lobs[2] = add( lobs[1], shr( length, 2 ) );
+ lobs[2] = add( lobs[1], shr( length, 2 ) ); /* Q0 */
move16();
- lobs[3] = add( lobs[2], shr( length, 3 ) );
+ lobs[3] = add( lobs[2], shr( length, 3 ) ); /* Q0 */
move16();
last_nz = 0;
@@ -412,11 +415,11 @@ static Word16 find_last_nz_pair(
{
if ( x[tmp[i - 2]] != 0 )
{
- last_nz = s_max( last_nz, i );
+ last_nz = s_max( last_nz, i ); /* Q0 */
}
if ( x[tmp[i - 1]] != 0 )
{
- last_nz = s_max( last_nz, i );
+ last_nz = s_max( last_nz, i ); /* Q0 */
}
}
}
@@ -426,11 +429,11 @@ static Word16 find_last_nz_pair(
{
if ( x[i - 2] != 0 )
{
- last_nz = s_max( last_nz, i );
+ last_nz = s_max( last_nz, i ); /* Q0 */
}
if ( x[i - 1] != 0 )
{
- last_nz = s_max( last_nz, i );
+ last_nz = s_max( last_nz, i ); /* Q0 */
}
}
}
@@ -448,12 +451,12 @@ static Word16 find_last_nz_pair(
*
*-------------------------------------------------------------------*/
Word16 ACcontextMapping_encode2_estimate_no_mem_s17_LC_fx(
- const Word16 *x,
- Word16 nt,
- Word16 *lastnz_out,
- Word16 *nEncoded,
- Word16 target,
- Word16 *stop,
+ const Word16 *x, /* Q0 */
+ Word16 nt, /* Q0 */
+ Word16 *lastnz_out, /* Q0 */
+ Word16 *nEncoded, /* Q0 */
+ Word16 target, /* Q0 */
+ Word16 *stop, /* Q0 */
CONTEXT_HM_CONFIG *hm_cfg )
{
Word16 a1, b1, a1_i, b1_i;
@@ -473,6 +476,8 @@ Word16 ACcontextMapping_encode2_estimate_no_mem_s17_LC_fx(
Word16 p1, p2;
Word16 ii[2], idx1, idx2, idx;
Word16 numPeakIndicesOrig = 0, numHoleIndices = 0; /* initialize just to avoid compiler warning */
+ move16();
+ move16();
get_next_coeff_function get_next_coeff;
@@ -481,12 +486,12 @@ Word16 ACcontextMapping_encode2_estimate_no_mem_s17_LC_fx(
move16();
if ( GT_16( target, 400 ) )
{
- rateFlag = 2 << NBITS_CONTEXT;
+ rateFlag = 2 << NBITS_CONTEXT; /* Q0 */
move16();
}
/* proba coded on 14bits -> proba=1 */
- proba = L_deposit_l( 16384 );
+ proba = L_deposit_l( 16384 ); /* Q0 */
/* Init */
nt_half = shr( nt, 1 );
@@ -497,13 +502,13 @@ Word16 ACcontextMapping_encode2_estimate_no_mem_s17_LC_fx(
move16();
/* bits to encode lastnz + 2 bits headroom */
- nbits = sub( 2 + 14, norm_s( sub( nt, 1 ) ) );
- nbits_old = nbits;
+ nbits = sub( 2 + 14, norm_s( sub( nt, 1 ) ) ); /* Q0 */
+ nbits_old = nbits; /* Q0 */
move16();
- nbits = sub( nbits, target );
+ nbits = sub( nbits, target ); /* Q0 */
/* Find last non-zero tuple in the mapped domain signal */
- lastnz = find_last_nz_pair( x, nt, hm_cfg );
+ lastnz = find_last_nz_pair( x, nt, hm_cfg ); /* Q0 */
/* At least one tuple is coded */
lastnz2 = 2;
@@ -511,25 +516,25 @@ Word16 ACcontextMapping_encode2_estimate_no_mem_s17_LC_fx(
IF( hm_cfg ) /* mapped domain */
{
- numPeakIndicesOrig = hm_cfg->numPeakIndices;
+ numPeakIndicesOrig = hm_cfg->numPeakIndices; /* Q0 */
move16();
- hm_cfg->numPeakIndices = s_min( hm_cfg->numPeakIndices, lastnz );
+ hm_cfg->numPeakIndices = s_min( hm_cfg->numPeakIndices, lastnz ); /* Q0 */
move16();
- numHoleIndices = sub( lastnz, hm_cfg->numPeakIndices );
+ numHoleIndices = sub( lastnz, hm_cfg->numPeakIndices ); /* Q0 */
/* Mark hole indices beyond lastnz as pruned */
FOR( k = numHoleIndices; k < hm_cfg->numHoleIndices; ++k )
{
- hm_cfg->holeIndices[k] = add( hm_cfg->holeIndices[k], nt );
+ hm_cfg->holeIndices[k] = add( hm_cfg->holeIndices[k], nt ); /* Q0 */
move16();
}
- ii[0] = numPeakIndicesOrig;
+ ii[0] = numPeakIndicesOrig; /* Q0 */
move16();
ii[1] = 0;
move16();
- get_next_coeff = get_next_coeff_mapped;
+ get_next_coeff = get_next_coeff_mapped; /* Q0 */
move16();
}
ELSE /* unmapped domain */
@@ -541,7 +546,7 @@ Word16 ACcontextMapping_encode2_estimate_no_mem_s17_LC_fx(
move16();
move16();
- get_next_coeff = get_next_coeff_unmapped;
+ get_next_coeff = get_next_coeff_unmapped; /* Q0 */
move16();
}
@@ -549,38 +554,37 @@ Word16 ACcontextMapping_encode2_estimate_no_mem_s17_LC_fx(
FOR( k = 0; k < lastnz; k += 2 )
{
/* First coefficient */
- a1_i = get_next_coeff( ii, &p1, &idx1, hm_cfg );
+ a1_i = get_next_coeff( ii, &p1, &idx1, hm_cfg ); /* Q0 */
/* Second coefficient */
- b1_i = get_next_coeff( ii, &p2, &idx2, hm_cfg );
+ b1_i = get_next_coeff( ii, &p2, &idx2, hm_cfg ); /* Q0 */
- idx = s_min( idx1, idx2 );
+ idx = s_min( idx1, idx2 ); /* Q0 */
/* Get context */
- ctx = &c[s_or( p1, p2 )];
- move16();
+ ctx = &c[s_or( p1, p2 )]; /* Q0 */
- t = add( *ctx, rateFlag );
+ t = add( *ctx, rateFlag ); /* Q0 */
if ( GT_16( idx, nt_half ) )
{
- t = add( t, 1 << NBITS_CONTEXT );
+ t = add( t, 1 << NBITS_CONTEXT ); /* Q0 */
}
/* Init current 2-tuple encoding */
- a1 = abs_s( x[a1_i] );
- b1 = abs_s( x[b1_i] );
+ a1 = abs_s( x[a1_i] ); /* Q0 */
+ b1 = abs_s( x[b1_i] ); /* Q0 */
lev1 = -( 1 << ( NBITS_CONTEXT + NBITS_RATEQ ) );
move16();
/* Signs Bits */
if ( a1 > 0 )
{
- nbits = add( nbits, 1 );
+ nbits = add( nbits, 1 ); /* Q0 */
}
if ( b1 > 0 )
{
- nbits = add( nbits, 1 );
+ nbits = add( nbits, 1 ); /* Q0 */
}
/* pre-compute address of ari_pk_s17_LC_ext[0][Val_esc] to avoid doing it multiple times inside the loop */
@@ -599,38 +603,38 @@ Word16 ACcontextMapping_encode2_estimate_no_mem_s17_LC_fx(
cum_freq_norm_e = norm_s( cum_freq[0] );
cum_freq_norm = shl( cum_freq[0], cum_freq_norm_e );
proba = Mpy_32_16_1( proba, cum_freq_norm );
- proba = L_shl( proba, sub( 14, cum_freq_norm_e ) );
+ proba = L_shl( proba, sub( 14, cum_freq_norm_e ) ); /* Q14 + cum_freq_norm_e */
/*Number of leading zero computed in one cycle=norm_l() in BASOP*/
nlz = sub( norm_l( proba ), 2 );
- proba = L_shl( proba, sub( nlz, 15 ) );
+ proba = L_shl( proba, sub( nlz, 15 ) ); /* cum_freq_norm_e */
- nbits = add( nbits, nlz );
+ nbits = add( nbits, nlz ); /* Q0 */
/*addition added as shift not done in norm_l(): real shift = 14-nlz*/
/*proba is rounded down on 14 bits ->automatic over-estimation of bit consumption*/
a1 = shr( a1, 1 );
b1 = shr( b1, 1 );
- lev1 = s_min( add( lev1, 1 << ( NBITS_CONTEXT + NBITS_RATEQ ) ), 2 << ( NBITS_CONTEXT + NBITS_RATEQ ) );
+ lev1 = s_min( add( lev1, 1 << ( NBITS_CONTEXT + NBITS_RATEQ ) ), 2 << ( NBITS_CONTEXT + NBITS_RATEQ ) ); /* Q0 */
}
- pki = lookup[lev1];
+ pki = lookup[lev1]; /* Q0 */
move16();
- symbol = add( a1, shl( b1, A_THRES_SHIFT ) );
- cum_freq = ari_pk_s17_LC_ext[pki] + symbol; /* address calculation not counted */
+ symbol = add( a1, shl( b1, A_THRES_SHIFT ) ); /* Q0 */
+ cum_freq = ari_pk_s17_LC_ext[pki] + symbol; /* address calculation not counted */
/*p1*p2=proba on 28 bits: p=0.5->power(2,27)*/
cum_freq_norm = sub( cum_freq[0], cum_freq[1] );
cum_freq_norm_e = norm_s( cum_freq_norm );
cum_freq_norm = shl( cum_freq_norm, cum_freq_norm_e );
proba = Mpy_32_16_1( proba, cum_freq_norm );
- proba = L_shl( proba, sub( 15, cum_freq_norm_e ) );
+ proba = L_shl( proba, sub( 15, cum_freq_norm_e ) ); /* Q15 + cum_freq_norm_e */
/*Number of leading zero computed in one cycle=norm_l() in BASOP*/
nlz = sub( norm_l( proba ), 3 );
- proba = L_shl( proba, sub( nlz, 14 ) );
+ proba = L_shl( proba, sub( nlz, 14 ) ); /* cum_freq_norm_e */
- nbits = add( nbits, nlz );
+ nbits = add( nbits, nlz ); /* Q0 */
/*addition added as shift not done in norm_l(): real shift = 14-nlz*/
/*proba is rounded down on 14 bits ->automatic over-estimation of bit consumption*/
@@ -652,15 +656,15 @@ Word16 ACcontextMapping_encode2_estimate_no_mem_s17_LC_fx(
test();
IF( hm_cfg || k == 0 || s_or( x[a1_i], x[b1_i] ) )
{
- nbits_old = add( nbits, target );
- lastnz2 = add( b1_i, 1 );
+ nbits_old = add( nbits, target ); /* Q0 */
+ lastnz2 = add( b1_i, 1 ); /* Q0 */
}
}
/* Update context for next 2-tuple */
IF( EQ_16( p1, p2 ) ) /* peak-peak or hole-hole context */
{
- lev1 = shr( lev1, NBITS_CONTEXT + NBITS_RATEQ );
+ lev1 = shr( lev1, NBITS_CONTEXT + NBITS_RATEQ ); /* Q0 */
if ( lev1 > 0 )
t = add( 12, lev1 );
if ( lev1 <= 0 )
@@ -668,46 +672,46 @@ Word16 ACcontextMapping_encode2_estimate_no_mem_s17_LC_fx(
if ( lev1 == 0 )
t = add( t, t );
- *ctx = add( shl( s_and( *ctx, 0xf ), 4 ), add( t, 1 ) );
+ *ctx = add( shl( s_and( *ctx, 0xf ), 4 ), add( t, 1 ) ); /* Q0 */
move16();
}
ELSE /* mixed context */
{
IF( s_and( idx1, 1 ) ) /* update first context */
{
- c[p1] = update_mixed_context( c[p1], abs_s( x[a1_i] ) );
+ c[p1] = update_mixed_context( c[p1], abs_s( x[a1_i] ) ); /* Q0 */
move16();
}
IF( s_and( idx2, 1 ) ) /* update second context */
{
- c[p2] = update_mixed_context( c[p2], abs_s( x[b1_i] ) );
+ c[p2] = update_mixed_context( c[p2], abs_s( x[b1_i] ) ); /* Q0 */
move16();
}
}
} /* end of the 2-tuples loop */
- nbits = add( nbits, target );
+ nbits = add( nbits, target ); /* Q0 */
/* Output */
if ( *stop )
{
- nbits = nbits_old;
+ nbits = nbits_old; /* Q0 */
move16();
}
if ( stop2 )
{
- stop2 = nbits;
+ stop2 = nbits; /* Q0 */
move16();
}
- *nEncoded = lastnz2;
+ *nEncoded = lastnz2; /* Q0 */
move16();
- *stop = stop2;
+ *stop = stop2; /* Q0 */
move16();
if ( lastnz_out )
{
- *lastnz_out = lastnz;
+ *lastnz_out = lastnz; /* Q0 */
move16();
}
@@ -716,10 +720,10 @@ Word16 ACcontextMapping_encode2_estimate_no_mem_s17_LC_fx(
/* Restore hole indices beyond lastnz */
FOR( k = numHoleIndices; k < hm_cfg->numHoleIndices; ++k )
{
- hm_cfg->holeIndices[k] = sub( hm_cfg->holeIndices[k], nt );
+ hm_cfg->holeIndices[k] = sub( hm_cfg->holeIndices[k], nt ); /* Q0 */
move16();
}
- hm_cfg->numPeakIndices = numPeakIndicesOrig;
+ hm_cfg->numPeakIndices = numPeakIndicesOrig; /* Q0 */
move16();
}
@@ -736,12 +740,12 @@ Word16 ACcontextMapping_encode2_estimate_no_mem_s17_LC_fx(
*-------------------------------------------------------------------*/
void RCcontextMapping_encode2_no_mem_s17_LCS_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
- Word16 *x,
- const Word16 nt,
- Word16 lastnz,
- const Word16 nbbits,
- const Word16 resQMaxBits,
+ BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
+ Word16 *x, /* Q0 */
+ const Word16 nt, /* Q0 */
+ Word16 lastnz, /* Q0 */
+ const Word16 nbbits, /* Q0 */
+ const Word16 resQMaxBits, /* Q0 */
CONTEXT_HM_CONFIG *hm_cfg )
{
Word16 ptr[BITBUFSIZE];
@@ -760,6 +764,8 @@ void RCcontextMapping_encode2_no_mem_s17_LCS_fx(
a1 = 0; /* to avoid compilation warnings */
b1 = 0; /* to avoid compilation warnings */
+ move16();
+ move16();
/* Init */
nt_half = shr( nt, 1 );
@@ -772,7 +778,7 @@ void RCcontextMapping_encode2_no_mem_s17_LCS_fx(
WHILE( LT_16( k, shr( nt, 1 ) ) )
{
- nbbits_ntuples = add( nbbits_ntuples, 1 );
+ nbbits_ntuples = add( nbbits_ntuples, 1 ); /* Q0 */
k = shl( k, 1 );
}
@@ -809,20 +815,20 @@ void RCcontextMapping_encode2_no_mem_s17_LCS_fx(
move32();
/* mapped domain */
- numPeakIndicesOrig = hm_cfg->numPeakIndices;
- hm_cfg->numPeakIndices = s_min( hm_cfg->numPeakIndices, lastnz );
- numHoleIndices = sub( lastnz, hm_cfg->numPeakIndices );
+ numPeakIndicesOrig = hm_cfg->numPeakIndices; /* Q0 */
+ hm_cfg->numPeakIndices = s_min( hm_cfg->numPeakIndices, lastnz ); /* Q0 */
+ numHoleIndices = sub( lastnz, hm_cfg->numPeakIndices ); /* Q0 */
move16();
move16();
/* Mark hole indices beyond lastnz as pruned */
FOR( k = numHoleIndices; k < hm_cfg->numHoleIndices; ++k )
{
- hm_cfg->holeIndices[k] = add( hm_cfg->holeIndices[k], nt );
+ hm_cfg->holeIndices[k] = add( hm_cfg->holeIndices[k], nt ); /* Q0 */
move16();
}
- ii[0] = numPeakIndicesOrig;
+ ii[0] = numPeakIndicesOrig; /* Q0 */
ii[1] = 0;
move16();
move16();
@@ -835,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;
@@ -843,15 +849,15 @@ void RCcontextMapping_encode2_no_mem_s17_LCS_fx(
FOR( k = 0; k < lastnz; k += 2 )
{
- a1_i = get_next_coeff_mapped_ivas_fx( ii, &p1, &idx1, hm_cfg );
- b1_i = get_next_coeff_mapped_ivas_fx( ii, &p2, &idx2, hm_cfg );
+ a1_i = get_next_coeff_mapped_ivas_fx( ii, &p1, &idx1, hm_cfg ); /* Q0 */
+ b1_i = get_next_coeff_mapped_ivas_fx( ii, &p2, &idx2, hm_cfg ); /* Q0 */
- idx = s_min( idx1, idx2 );
+ idx = s_min( idx1, idx2 ); /* Q0 */
/* Get context */
- ctx = &c[L_or( p1, p2 )];
+ ctx = &c[L_or( p1, p2 )]; /* Q0 */
- t = (UWord16) L_add( *ctx, rateFlag );
+ t = (UWord16) L_add( *ctx, rateFlag ); /* Q0 */
// t += ( nt_half >= idx ) ? 0 : ( 1 << NBITS_CONTEXT );
IF( LT_16( nt_half, idx ) )
{
@@ -859,8 +865,8 @@ void RCcontextMapping_encode2_no_mem_s17_LCS_fx(
}
/* Init current 2-tuple encoding */
- a1 = abs_s( x[a1_i] );
- b1 = abs_s( x[b1_i] );
+ a1 = abs_s( x[a1_i] ); /* Q0 */
+ b1 = abs_s( x[b1_i] ); /* Q0 */
lev1 = -1;
move16();
@@ -879,7 +885,7 @@ void RCcontextMapping_encode2_no_mem_s17_LCS_fx(
signs[nbbits_signs] = 1;
move16();
}
- nbbits_signs = add( nbbits_signs, 1 );
+ nbbits_signs = add( nbbits_signs, 1 ); /* Q0 */
}
IF( b1 > 0 )
@@ -895,15 +901,15 @@ void RCcontextMapping_encode2_no_mem_s17_LCS_fx(
signs[nbbits_signs] = 1;
move16();
}
- nbbits_signs = add( nbbits_signs, 1 );
+ nbbits_signs = add( nbbits_signs, 1 ); /* Q0 */
}
/* MSBs coding */
WHILE( GE_16( s_max( a1, b1 ), A_THRES ) )
{
- pki = ari_lookup_s17_LC[t + ( ( lev1 + 1 ) << ( NBITS_CONTEXT + NBITS_RATEQ ) )];
+ 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 );
@@ -911,17 +917,17 @@ void RCcontextMapping_encode2_no_mem_s17_LCS_fx(
move16();
/* LSBs bit counting */
- nbbits_lsbs = add( nbbits_lsbs, 2 );
+ nbbits_lsbs = add( nbbits_lsbs, 2 ); /* Q0 */
a1 = shr( a1, 1 );
b1 = shr( b1, 1 );
- lev1 = s_min( add( lev1, 1 ), 2 );
+ lev1 = s_min( add( lev1, 1 ), 2 ); /* Q0 */
}
- pki = ari_lookup_s17_LC[t + ( ( lev1 + 1 ) << ( NBITS_CONTEXT + NBITS_RATEQ ) )];
+ 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 */
@@ -932,14 +938,14 @@ void RCcontextMapping_encode2_no_mem_s17_LCS_fx(
IF( lev1 <= 0 )
{
- t = (UWord16) L_add( 1, L_mult0( add( a1, b1 ), add( lev1, 2 ) ) );
+ t = (UWord16) L_add( 1, L_mult0( add( a1, b1 ), add( lev1, 2 ) ) ); /* Q0 */
}
ELSE
{
- t = (UWord16) L_add( 13, lev1 );
+ t = (UWord16) L_add( 13, lev1 ); /* Q0 */
}
- *ctx = L_add( L_shl( L_and( *ctx, 0xf ), 4 ), t );
+ *ctx = L_add( L_shl( L_and( *ctx, 0xf ), 4 ), t ); /* Q0 */
move32();
}
ELSE
@@ -949,14 +955,14 @@ void RCcontextMapping_encode2_no_mem_s17_LCS_fx(
IF( s_and( idx1, 1 ) )
{
/* update first context */
- c[p1] = update_mixed_context_ivas_fx( c[p1], abs_s( x[a1_i] ) );
+ c[p1] = update_mixed_context_ivas_fx( c[p1], abs_s( x[a1_i] ) ); /* Q0 */
move32();
}
IF( s_and( idx2, 1 ) )
{
/* update second context */
- c[p2] = update_mixed_context_ivas_fx( c[p2], abs_s( x[b1_i] ) );
+ c[p2] = update_mixed_context_ivas_fx( c[p2], abs_s( x[b1_i] ) ); /* Q0 */
move32();
}
}
@@ -994,7 +1000,7 @@ void RCcontextMapping_encode2_no_mem_s17_LCS_fx(
WHILE( x[lastnz - 1] == 0 && x[lastnz - 2] == 0 )
{
test();
- lastnz = sub( lastnz, 2 );
+ lastnz = sub( lastnz, 2 ); /* Q0 */
}
x[0] = a1;
move16();
@@ -1003,15 +1009,15 @@ 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 )
{
/* Init current 2-tuple encoding */
- a1 = abs_s( x[k + 0] );
- b1 = abs_s( x[k + 1] );
+ a1 = abs_s( x[k + 0] ); /* Q0 */
+ b1 = abs_s( x[k + 1] ); /* Q0 */
lev1 = 0;
esc_nb = 0;
@@ -1032,7 +1038,7 @@ void RCcontextMapping_encode2_no_mem_s17_LCS_fx(
signs[nbbits_signs] = 1;
move16();
}
- nbbits_signs = add( nbbits_signs, 1 );
+ nbbits_signs = add( nbbits_signs, 1 ); /* Q0 */
}
IF( b1 > 0 )
@@ -1048,17 +1054,17 @@ void RCcontextMapping_encode2_no_mem_s17_LCS_fx(
signs[nbbits_signs] = 1;
move16();
}
- nbbits_signs = add( nbbits_signs, 1 );
+ nbbits_signs = add( nbbits_signs, 1 ); /* Q0 */
}
- rateQ = add( rateFlag, (Word16) GT_16( k, shr( nt, 1 ) ) );
+ rateQ = add( rateFlag, extract_l( GT_16( k, shr( nt, 1 ) ) ) );
/* MSBs coding */
WHILE( GE_16( s_max( a1, b1 ), A_THRES ) )
{
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 );
@@ -1066,29 +1072,30 @@ void RCcontextMapping_encode2_no_mem_s17_LCS_fx(
move16();
/* LSBs bit counting */
- nbbits_lsbs = add( nbbits_lsbs, 2 );
+ nbbits_lsbs = add( nbbits_lsbs, 2 ); /* Q0 */
a1 = shr( a1, 1 );
b1 = shr( b1, 1 );
- lev1 = add( lev1, 1 );
- esc_nb = s_min( lev1, 3 );
+ lev1 = add( lev1, 1 ); /* Q0 */
+ esc_nb = s_min( lev1, 3 ); /* Q0 */
}
move16();
- pki = ari_lookup_s17_LC[t + ( ( rateQ ) << NBITS_CONTEXT ) + ( esc_nb << ( NBITS_CONTEXT + NBITS_RATEQ ) )];
- 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 */
/* Update context for next 2-tuple */
IF( LT_16( esc_nb, 2 ) )
{
- cp = add( 1, imult1616( add( a1, b1 ), add( esc_nb, 1 ) ) );
+ cp = add( 1, imult1616( add( a1, b1 ), add( esc_nb, 1 ) ) ); /* Q0 */
}
ELSE
{
- cp = add( 12, esc_nb );
+ cp = add( 12, esc_nb ); /* Q0 */
}
/*Shift old 4 bits, replace last 4 bits*/
@@ -1099,13 +1106,13 @@ 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 */
- bp = add( rc_tot_bits, nbbits_ntuples ); /* Update bitstream pointer */
+ 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 */
/* Push number of encoded tuples */
- value = sub( shr( lastnz, 1 ), 1 );
+ value = sub( shr( lastnz, 1 ), 1 ); /* Q0 */
push_next_indice( hBstr, value, nbbits_ntuples );
/* Push range coded bits from byte_buffer to bitstream */
@@ -1122,13 +1129,13 @@ void RCcontextMapping_encode2_no_mem_s17_LCS_fx(
/* Push sign bits */
push_next_bits( hBstr, (UWord16 *) signs, nbbits_signs );
- bp = add( bp, nbbits_signs );
+ bp = add( bp, nbbits_signs ); /* Q0 */
/*write residual Quantization bits*/
FOR( k = 0; k < s_min( nbbits - bp - nbbits_lsbs, resQMaxBits ); k++ )
{
- ptr[nbbits - 1 - nbbits_lsbs - k] = x[nt + k];
+ ptr[nbbits - 1 - nbbits_lsbs - k] = x[nt + k]; /* Q0 */
move16();
}
/* Write filler bits */
@@ -1148,6 +1155,692 @@ void RCcontextMapping_encode2_no_mem_s17_LCS_fx(
return;
}
+/*-------------------------------------------------------------------*
+ * find_last_nz_pair_fx()
+ *
+ *
+ *-------------------------------------------------------------------*/
+
+static Word16 find_last_nz_pair_fx(
+ const Word16 x[], /* Q0 */
+ const Word16 length,
+ const CONTEXT_HM_CONFIG *hm_cfg )
+{
+ Word16 last_nz, i;
+ const Word16 *tmp;
+
+ last_nz = 2;
+ move16();
+
+ IF( hm_cfg )
+ {
+ /* mapped kernel */
+ tmp = hm_cfg->indexBuffer;
+
+ FOR( i = length; i >= 4; i -= 2 )
+ {
+ test();
+ IF( x[tmp[i - 2]] || x[tmp[i - 1]] )
+ {
+ last_nz = i; /* Q0 */
+ move16();
+ BREAK;
+ }
+ }
+ }
+ ELSE
+ {
+ /* unmapped kernel */
+
+ FOR( i = length; i >= 4; i -= 2 )
+ {
+ test();
+ IF( x[i - 2] || x[i - 1] )
+ {
+ last_nz = i; /* Q0 */
+ move16();
+ BREAK;
+ }
+ }
+ }
+
+ return last_nz;
+}
+
+
+/*-------------------------------------------------------------------*
+ * RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx()
+ *
+ * Range coder bit-estimation
+ *-------------------------------------------------------------------*/
+
+Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx(
+ Word16 *x, /* Spectral coefficients Q0*/
+ const Word16 nt, /* L - size of spectrum (no. of spectral coefficients) Q0*/
+ Word16 *lastnz_out, /* Q0 */
+ Word16 *nEncoded, /* No. of spectral coefficients that can be coded without an overflow occuring Q0*/
+ const Word16 target, /* Target bits Q0*/
+ Word16 *stop, /* Q0 */
+ Word16 mode, /* Q0 */
+ CONTEXT_HM_CONFIG *hm_cfg /* context-based harmonic model configuration */
+)
+{
+ /* Common variables */
+ Word16 a1, b1;
+ Word16 k, pki, lev1;
+ UWord16 t;
+ Word16 lastnz, lastnz2;
+ Word16 rateFlag;
+ Word32 bit_estimate_fx;
+ Word16 bit_estimate_e;
+ Word16 symbol;
+ const UWord8 *lookup;
+ Word32 nbits2_fx; // Q23
+ Word16 nbits2_e;
+
+ /* Initialization */
+ bit_estimate_fx = 2 * ONE_IN_Q29;
+ bit_estimate_e = 2;
+ move32();
+ move16();
+
+ nbits2_fx = 0;
+ nbits2_e = 0;
+ move32();
+ move16();
+
+ /* bits to encode lastnz */
+ k = 1;
+ move16();
+
+ WHILE( LT_16( k, nt / 2 ) )
+ {
+ bit_estimate_fx = BASOP_Util_Add_Mant32Exp( bit_estimate_fx, bit_estimate_e, ONE_IN_Q30, 1, &bit_estimate_e );
+ k = k << 1;
+ /* check while condition */
+ }
+
+ nbits2_fx = bit_estimate_fx; /* exp(bit_estimate_e) */
+ nbits2_e = bit_estimate_e;
+ move32();
+ move16();
+
+ IF( hm_cfg )
+ {
+ Word16 a1_i, b1_i;
+ Word16 stop2;
+ Word16 total_output_bits;
+ Word16 nt_half;
+ Word32 c[2], *ctx;
+ Word32 p1, p2;
+ Word16 ii[2];
+ Word16 idx1, idx2, idx;
+ Word16 numPeakIndicesOrig = 0, numHoleIndices = 0; /* only to avoid compiler warning */
+ move16();
+ move16();
+
+ /* Rate flag */
+ IF( GT_16( target, 400 ) )
+ {
+ rateFlag = 2 << NBITS_CONTEXT; /* Select context-A for higher bitrates */
+ move16();
+ }
+ ELSE
+ {
+ rateFlag = 0; /* Select context-B for lower bitrates */
+ move16();
+ }
+
+ nt_half = shr( nt, 1 );
+ move16();
+ stop2 = 0;
+ move16();
+ c[0] = c[1] = 0;
+ move32();
+ move32();
+
+ /* Find last non-zero tuple in the mapped domain signal */
+ lastnz = find_last_nz_pair_fx( x, nt, hm_cfg );
+
+ lastnz2 = 2;
+ move16();
+
+ /* mapped domain */
+ numPeakIndicesOrig = hm_cfg->numPeakIndices; /* Q0 */
+ move16();
+ hm_cfg->numPeakIndices = s_min( hm_cfg->numPeakIndices, lastnz ); /* Q0 */
+ move16();
+ numHoleIndices = sub( lastnz, hm_cfg->numPeakIndices ); /* Q0 */
+
+ /* Mark hole indices beyond lastnz as pruned */
+ FOR( k = numHoleIndices; k < hm_cfg->numHoleIndices; ++k )
+ {
+ hm_cfg->holeIndices[k] = add( hm_cfg->holeIndices[k], nt ); /* Q0 */
+ move16();
+ }
+
+ ii[0] = numPeakIndicesOrig; /* Q0 */
+ move16();
+ ii[1] = 0;
+ move16();
+
+ p1 = p2 = 0; /* to avoid compilation warnings */
+ move32();
+ move32();
+
+ /* Main Loop through the 2-tuples */
+ FOR( k = 0; k < lastnz; k += 2 )
+ {
+ a1_i = get_next_coeff_mapped_ivas_fx( ii, &p1, &idx1, hm_cfg ); /* Q0 */
+ b1_i = get_next_coeff_mapped_ivas_fx( ii, &p2, &idx2, hm_cfg ); /* Q0 */
+
+ idx = s_min( idx1, idx2 );
+
+ /* Get context */
+ ctx = &c[L_or( p1, p2 )];
+
+ t = (UWord16) L_add( *ctx, rateFlag );
+ IF( LT_16( nt_half, idx ) )
+ {
+ t = add( t, ( 1 << NBITS_CONTEXT ) );
+ }
+
+ /* Init current 2-tuple encoding */
+ a1 = (Word16) abs( x[a1_i] );
+ b1 = (Word16) abs( x[b1_i] );
+ lev1 = -( 1 << ( NBITS_CONTEXT + NBITS_RATEQ ) );
+
+ bit_estimate_fx = BASOP_Util_Add_Mant32Exp( bit_estimate_fx, bit_estimate_e, s_min( a1, 1 ) * ONE_IN_Q30, 1, &bit_estimate_e ); /* exp(bit_estimate_e) */
+ bit_estimate_fx = BASOP_Util_Add_Mant32Exp( bit_estimate_fx, bit_estimate_e, s_min( b1, 1 ) * ONE_IN_Q30, 1, &bit_estimate_e ); /* exp(bit_estimate_e) */
+
+ /* pre-compute address of ari_pk_s17_LC_ext[0][Val_esc] to avoid doing it multiple times inside the loop */
+ lookup = &ari_lookup_s17_LC[t] + ( 1 << ( NBITS_CONTEXT + NBITS_RATEQ ) );
+
+ /* check while condition */
+ /* MSBs coding */
+ WHILE( GE_16( s_max( a1, b1 ), A_THRES ) )
+ {
+ pki = lookup[lev1]; /* ESC symbol */
+
+ bit_estimate_fx = BASOP_Util_Add_Mant32Exp( bit_estimate_fx, bit_estimate_e, ari_bit_estimate_s17_LC_fx[pki][VAL_ESC], 8, &bit_estimate_e ); /* exp(bit_estimate_e) */
+ bit_estimate_fx = BASOP_Util_Add_Mant32Exp( bit_estimate_fx, bit_estimate_e, 2 * ONE_IN_Q29, 2, &bit_estimate_e ); /* Add 2 LSB bits corresponding to the bit-plane exp(bit_estimate_e) */
+
+ a1 = shr( a1, 1 );
+ b1 = shr( b1, 1 );
+
+ lev1 = s_min( add( lev1, ( 1 << ( NBITS_CONTEXT + NBITS_RATEQ ) ) ), 2 << ( NBITS_CONTEXT + NBITS_RATEQ ) );
+
+ /* check while condition */
+ }
+
+ pki = lookup[lev1];
+
+ symbol = add( a1, i_mult( A_THRES, b1 ) ); /* Q0 */
+ bit_estimate_fx = BASOP_Util_Add_Mant32Exp( bit_estimate_fx, bit_estimate_e, ari_bit_estimate_s17_LC_fx[pki][symbol], 8, &bit_estimate_e ); /* exp(bit_estimate_e) */
+
+ /* Should we truncate? */
+ IF( GT_32( L_shr( bit_estimate_fx, sub( Q16, bit_estimate_e ) ), L_shl( target, Q15 ) ) )
+ {
+ stop2 = 1;
+ move16();
+
+ IF( *stop )
+ {
+ BREAK;
+ }
+ }
+ ELSE
+ {
+ lastnz2 = add( b1_i, 1 );
+ nbits2_fx = bit_estimate_fx;
+ move32();
+ nbits2_e = bit_estimate_e;
+ move16();
+ }
+
+ /* Update context for next 2-tuple */
+ IF( EQ_32( p1, p2 ) ) /* peak-peak or hole-hole context */
+ {
+ lev1 = shr( lev1, NBITS_CONTEXT + NBITS_RATEQ );
+
+ IF( lev1 <= 0 )
+ {
+ t = add( 1, i_mult( add( a1, b1 ), add( lev1, 2 ) ) );
+ }
+ ELSE
+ {
+ t = add( 13, lev1 );
+ }
+
+ *ctx = L_add( imult3216( L_and( *ctx, 0xf ), 16 ), t );
+ move32();
+ }
+ ELSE
+ {
+ /* mixed context */
+
+ IF( s_and( idx1, 1 ) )
+ {
+ /* update first context */
+ c[p1] = update_mixed_context_ivas_fx( c[p1], abs_s( x[a1_i] ) ); /* Q0 */
+ move32();
+ }
+
+ IF( s_and( idx2, 1 ) )
+ {
+ /* update second context */
+ c[p2] = update_mixed_context_ivas_fx( c[p2], abs_s( x[b1_i] ) ); /* Q0 */
+ move32();
+ }
+ }
+
+ } /*end of the 2-tuples loop*/
+
+ total_output_bits = round_fx( L_shr( bit_estimate_fx, sub( Q15, bit_estimate_e ) ) ); /* Q0 */
+
+ IF( *stop )
+ {
+ total_output_bits = round_fx( L_shr( nbits2_fx, sub( Q15, nbits2_e ) ) ); /* Q0 */
+ }
+
+ IF( stop2 )
+ {
+ stop2 = total_output_bits; /* Q0 */
+ move16();
+ }
+
+ *nEncoded = lastnz2; /* Q0 */
+ move16();
+ *stop = stop2; /* If zero, it means no overflow occured during bit-estimation Q0*/
+ move16();
+ *lastnz_out = lastnz; /* Q0 */
+ move16();
+
+ /* Restore hole indices beyond lastnz */
+ FOR( k = numHoleIndices; k < hm_cfg->numHoleIndices; ++k )
+ {
+ hm_cfg->holeIndices[k] = sub( hm_cfg->holeIndices[k], nt ); /* Q0 */
+ move16();
+ }
+ hm_cfg->numPeakIndices = numPeakIndicesOrig; /* Q0 */
+ move16();
+
+ return round_fx( L_add( L_shr( nbits2_fx, sub( Q15, nbits2_e ) ), ONE_IN_Q14 ) ); /* Q0 */
+ }
+ ELSE /* if (!hm_cfg) */
+ {
+ Word16 esc_nb, cp, rateQ;
+ UWord16 s;
+ Word16 tot_bits2;
+ Word16 overflow_flag = 0;
+ move16();
+
+ /* Rate flag */
+ IF( GT_16( target, 400 ) )
+ {
+ rateFlag = 2; /* Q0 */
+ move16();
+ }
+ ELSE
+ {
+ rateFlag = 0; /* Select context-B for lower bitrates */
+ move16();
+ }
+
+ t = 0;
+ move16();
+ s = 0;
+ move16();
+ cp = 0;
+ move16();
+ lastnz = 1;
+ move16();
+ lastnz2 = 0;
+ move16();
+ tot_bits2 = 0;
+ move16();
+
+ /* Find last non-zero tuple in the mapped domain signal */
+ FOR( lastnz = sub( nt, 2 ); lastnz >= 0; lastnz -= 2 )
+ {
+ test();
+ IF( ( x[lastnz] != 0 ) || ( x[lastnz + 1] != 0 ) )
+ {
+ BREAK;
+ }
+ }
+ lastnz = add( lastnz, 2 ); /* Q0 */
+ IF( LT_16( lastnz, 2 ) )
+ {
+ lastnz = 2; /* At least one tuple is coded Q0*/
+ move16();
+ }
+
+ lastnz2 = 2;
+ move16();
+
+ /* Main Loop through the 2-tuples */
+ FOR( k = 0; k < lastnz; k += 2 )
+ {
+ /* Init current 2-tuple encoding */
+ a1 = abs_s( x[k] ); /* Q0 */
+ b1 = abs_s( x[k + 1] ); /* Q0 */
+ lev1 = 0;
+ move16();
+ esc_nb = 0;
+ move16();
+ rateQ = add( rateFlag, extract_l( GT_16( k, shr( nt, 1 ) ) ) ); /* Q0 */
+
+ bit_estimate_fx = BASOP_Util_Add_Mant32Exp( bit_estimate_fx, bit_estimate_e, s_min( a1, 1 ) * ONE_IN_Q30, 1, &bit_estimate_e ); /* exp(bit_estimate_e) */
+ bit_estimate_fx = BASOP_Util_Add_Mant32Exp( bit_estimate_fx, bit_estimate_e, s_min( b1, 1 ) * ONE_IN_Q30, 1, &bit_estimate_e ); /* exp(bit_estimate_e) */
+
+ /* pre-compute address of ari_pk_s17_LC_ext[0][Val_esc] to avoid doing it multiple times inside the loop */
+ lookup = &ari_lookup_s17_LC[t + shl( rateQ, NBITS_CONTEXT )]; /* Q0 */
+
+ /* check while condition */
+ /* MSBs coding */
+ WHILE( GE_16( s_max( a1, b1 ), A_THRES ) )
+ {
+ pki = lookup[( esc_nb << ( NBITS_CONTEXT + NBITS_RATEQ ) )]; /* Q0 */
+ move16();
+
+ bit_estimate_fx = BASOP_Util_Add_Mant32Exp( bit_estimate_fx, bit_estimate_e, ari_bit_estimate_s17_LC_fx[pki][VAL_ESC], 8, &bit_estimate_e ); /* exp(bit_estimate_e) */
+ bit_estimate_fx = BASOP_Util_Add_Mant32Exp( bit_estimate_fx, bit_estimate_e, 2 * ONE_IN_Q29, 2, &bit_estimate_e ); /* Add 2 LSB bits corresponding to the bit-plane exp(bit_estimate_e) */
+
+ a1 = shr( a1, 1 );
+ b1 = shr( b1, 1 );
+
+ lev1 = add( lev1, 1 );
+ esc_nb = s_min( lev1, 3 );
+
+ /* check while condition */
+ }
+
+ pki = lookup[( esc_nb << ( NBITS_CONTEXT + NBITS_RATEQ ) )]; /* Q0 */
+ move16();
+
+ symbol = add( a1, i_mult( A_THRES, b1 ) ); /* Q0 */
+ bit_estimate_fx = BASOP_Util_Add_Mant32Exp( bit_estimate_fx, bit_estimate_e, ari_bit_estimate_s17_LC_fx[pki][symbol], 8, &bit_estimate_e ); /* exp(bit_estimate_e) */
+
+ /* Should we truncate? */
+ IF( GT_32( L_shr( bit_estimate_fx, sub( Q16, bit_estimate_e ) ), L_shl( target, Q15 ) ) ) /* Overflow occured */
+ {
+ overflow_flag = 1;
+ move16();
+ }
+ ELSE
+ {
+ IF( abs_s( x[k] ) || abs_s( x[k + 1] ) ) /* No overflow & non-zero tuple */
+ {
+ nbits2_fx = bit_estimate_fx; /* exp(bit_estimate_e) */
+ nbits2_e = bit_estimate_e;
+ move32();
+ move16();
+ lastnz2 = add( k, 2 );
+ }
+ }
+
+ /* Update context for next 2-tuple */
+ IF( LT_16( esc_nb, 2 ) )
+ {
+ cp = add( 1, i_mult( add( a1, b1 ), add( esc_nb, 1 ) ) ); /* Q0 */
+ }
+ ELSE
+ {
+ cp = add( 12, esc_nb ); /* Q0 */
+ }
+ /*shift old bits and replace last 4 bits*/
+ s = (UWord16) L_add( L_shl( s, 4 ), cp );
+ t = s_and( s, 0xFF );
+
+ } /*end of the 2-tuples loop*/
+
+ tot_bits2 = round_fx( L_shr( nbits2_fx, sub( Q15, nbits2_e ) ) );
+ IF( LT_16( lastnz2, lastnz ) ) /* Overflow occured because unable to code all tuples */
+ {
+ overflow_flag = 1;
+ move16();
+ }
+ IF( EQ_16( mode, -1 ) )
+ {
+ tot_bits2 = round_fx( L_shr( bit_estimate_fx, sub( Q15, bit_estimate_e ) ) ); /* Q0 */
+ }
+ IF( overflow_flag == 0 ) /* No overflow */
+ {
+ *stop = 0;
+ move16();
+ }
+ ELSE /* Overflow */
+ {
+ IF( *stop ){
+ *stop = tot_bits2; /* Q0 */
+ move16();
+ }
+ ELSE
+ {
+ *stop = round_fx( L_shr( bit_estimate_fx, sub( Q15, bit_estimate_e ) ) ); /* Q0 */
+ move16();
+ }
+}
+
+*lastnz_out = lastnz; /* Q0 */
+move16();
+*nEncoded = lastnz2; /* Q0 */
+move16();
+/* Safety mechanism to avoid overflow */
+test();
+IF( EQ_16( lastnz2, 2 ) && EQ_16( overflow_flag, 1 ) )
+{
+ FOR( k = 0; k < lastnz2; k++ )
+ {
+ x[k] = 0;
+ move16();
+ }
+}
+
+return tot_bits2;
+}
+}
+
+
+/*-------------------------------------------------------------------*
+ * RCcontextMapping_encode2_estimate_bandWise_start_fx()
+ *
+ * Range coder - start bandwise bit-estimation
+ *-------------------------------------------------------------------*/
+
+Word16 RCcontextMapping_encode2_estimate_bandWise_start_fx(
+ Word16 *x, /* Q0 */
+ const Word16 nt, /* Q0 */
+ const Word16 target, /* Q0 */
+ HANDLE_RC_CONTEXT_MEM hContextMem )
+{
+ Word16 i, k;
+
+ /* Rate flag */
+ IF( GT_16( target, 400 ) )
+ {
+ hContextMem->rateFlag = 2 << NBITS_CONTEXT;
+ move16();
+ }
+ ELSE
+ {
+ hContextMem->rateFlag = 0;
+ move16();
+ }
+
+ hContextMem->bit_estimate_fx = 2; /* Q0 */
+ move32();
+ hContextMem->bit_estimate_e = Q31;
+ move16();
+
+
+ /* Init */
+ hContextMem->nt_half = shr( nt, 1 );
+ move16();
+
+ /* bits to encode lastnz */
+ k = 1;
+ move16();
+
+ WHILE( LT_16( k, hContextMem->nt_half ) )
+ {
+ hContextMem->bit_estimate_fx = L_add( hContextMem->bit_estimate_fx, 1 ); /* exp(bit_estimate_e) */
+ move32();
+
+ k = shl( k, 1 );
+ /* check while condition */
+ }
+
+ /* bits to encode lastnz */
+ hContextMem->nbits_old = extract_l( hContextMem->bit_estimate_fx ); /* Q0 */
+ move16();
+
+ hContextMem->ctx = 0;
+ move16();
+ hContextMem->lastnz = 2;
+ move16();
+
+ /* Find last non-zero tuple */
+
+ FOR( i = nt; i >= 4; i -= 2 )
+ {
+ test();
+ IF( x[i - 2] != 0 || x[i - 1] != 0 )
+ {
+ hContextMem->lastnz = i;
+ move16();
+ BREAK;
+ }
+ }
+ Word16 tmp2 = extract_l( hContextMem->bit_estimate_fx );
+ Word16 tmp = norm_l( hContextMem->bit_estimate_fx );
+ hContextMem->bit_estimate_e = sub( Q31, tmp );
+ move16();
+ hContextMem->bit_estimate_fx = L_shl( hContextMem->bit_estimate_fx, tmp ); /* exp(bit_estimate_e) */
+ move32();
+
+ return tmp2;
+}
+
+/*-------------------------------------------------------------------*
+ * RCcontextMapping_encode2_estimate_bandWise_fx()
+ *
+ * Range coder - bandwise bit-estimation
+ *-------------------------------------------------------------------*/
+
+Word16 RCcontextMapping_encode2_estimate_bandWise_fx(
+ Word16 *x, /* Q0 */
+ const Word16 start_line, /* Q0 */
+ const Word16 end_line, /* Q0 */
+ HANDLE_RC_CONTEXT_MEM hContextMem )
+{
+ Word16 a1, b1, a1_i, b1_i;
+ Word16 k, pki, lev1;
+ UWord16 t;
+ Word16 bandBits = 0;
+ move16();
+ Word16 total_output_bits; /* No. of bits after finalization */
+ Word16 symbol;
+ const UWord8 *lookup;
+ Word16 idx;
+ Word16 tmp;
+
+ /* Main Loop through the 2-tuples */
+ /*hContextMem->nt_half = end_line >> 1;*/
+ FOR( k = start_line; k < min( hContextMem->lastnz, end_line ); k += 2 )
+ {
+ a1_i = k; /* Q0 */
+ move16();
+ b1_i = add( k, 1 ); /* Q0 */
+
+ idx = k;
+ move16();
+
+ /* Get context */
+ t = add( hContextMem->ctx, hContextMem->rateFlag ); /* Q0 */
+
+ IF( GE_16( hContextMem->nt_half, idx ) )
+ {
+ tmp = 0;
+ }
+ ELSE
+ {
+ tmp = ( 1 << NBITS_CONTEXT );
+ }
+
+ t = add( t, tmp ); /* Q0 */
+
+ /* Init current 2-tuple encoding */
+ a1 = abs_s( x[a1_i] ); /* Q0 */
+ b1 = abs_s( x[b1_i] ); /* Q0 */
+ lev1 = -( 1 << ( NBITS_CONTEXT + NBITS_RATEQ ) ); /* Q0 */
+
+ /* Signs Bits */
+ hContextMem->bit_estimate_fx = BASOP_Util_Add_Mant32Exp( hContextMem->bit_estimate_fx, hContextMem->bit_estimate_e, imult3216( ONE_IN_Q30, s_min( a1, 1 ) ), Q1, &hContextMem->bit_estimate_e ); /* exp(hContextMem->bit_estimate_e) */
+ hContextMem->bit_estimate_fx = BASOP_Util_Add_Mant32Exp( hContextMem->bit_estimate_fx, hContextMem->bit_estimate_e, imult3216( ONE_IN_Q30, s_min( b1, 1 ) ), Q1, &hContextMem->bit_estimate_e ); /* exp(hContextMem->bit_estimate_e) */
+ move32();
+ move32();
+
+ /* pre-compute address of ari_pk_s17_LC_ext[0][Val_esc] to avoid doing it multiple times inside the loop */
+ lookup = &ari_lookup_s17_LC[t] + ( 1 << ( NBITS_CONTEXT + NBITS_RATEQ ) );
+
+ /* check while condition */
+ /* MSBs coding */
+ WHILE( GE_16( s_max( a1, b1 ), A_THRES ) )
+ {
+ pki = lookup[lev1]; /* Q0 */
+ move16();
+
+ hContextMem->bit_estimate_fx = BASOP_Util_Add_Mant32Exp( hContextMem->bit_estimate_fx, hContextMem->bit_estimate_e, ari_bit_estimate_s17_LC_fx[pki][VAL_ESC], Q8, &hContextMem->bit_estimate_e ); /* exp(hContextMem->bit_estimate_e) */
+ hContextMem->bit_estimate_fx = BASOP_Util_Add_Mant32Exp( hContextMem->bit_estimate_fx, hContextMem->bit_estimate_e, 2 * ONE_IN_Q29, Q2, &hContextMem->bit_estimate_e ); /* Add the 2 LSB bits that were shifted out exp(hContextMem->bit_estimate_e) */
+ move32();
+ move32();
+
+ // hContextMem->bit_estimate = hContextMem->bit_estimate + ari_bit_estimate_s17_LC[pki][VAL_ESC];
+ // hContextMem->bit_estimate += 2; /* Add the 2 LSB bits that were shifted out */
+
+ a1 = shr( a1, 1 );
+ b1 = shr( b1, 1 );
+
+ lev1 = s_min( add( lev1, ( 1 << ( NBITS_CONTEXT + NBITS_RATEQ ) ) ), 2 << ( NBITS_CONTEXT + NBITS_RATEQ ) ); /* Q0 */
+ /* check while condition */
+ }
+
+ pki = lookup[lev1]; /* Q0 */
+ move16();
+ symbol = add( a1, i_mult( A_THRES, b1 ) ); /* MSB symbol Q0*/
+ hContextMem->bit_estimate_fx = BASOP_Util_Add_Mant32Exp( hContextMem->bit_estimate_fx, hContextMem->bit_estimate_e, ari_bit_estimate_s17_LC_fx[pki][symbol], Q8, &hContextMem->bit_estimate_e ); /* exp(bit_estimate_e) */
+ move32();
+ // hContextMem->bit_estimate = hContextMem->bit_estimate + ari_bit_estimate_s17_LC[pki][symbol];
+
+ /* Update context */
+ lev1 = shr( lev1, NBITS_CONTEXT + NBITS_RATEQ );
+
+ IF( lev1 <= 0 )
+ {
+ t = add( 1, i_mult( add( a1, b1 ), add( lev1, 2 ) ) ); /* Q0 */
+ }
+ ELSE
+ {
+ t = add( 13, lev1 ); /* Q0 */
+ }
+
+ hContextMem->ctx = add( i_mult( s_and( hContextMem->ctx, 0xf ), 16 ), t ); /* Q0 */
+ move16();
+
+ } /*end of the 2-tuples loop*/
+ total_output_bits = round_fx( L_shr( hContextMem->bit_estimate_fx, sub( Q15, hContextMem->bit_estimate_e ) ) ); /* Q0 */
+ // total_output_bits = (Word16) ( hContextMem->bit_estimate + 0.5f );
+
+ bandBits = sub( total_output_bits, hContextMem->nbits_old ); /* Q0 */
+ hContextMem->nbits_old = total_output_bits; /* Q0 */
+ move16();
+
+ return bandBits;
+}
+
+
#ifdef IVAS_CODE_RANGE_CODER
/*-------------------------------------------------------------------*
diff --git a/lib_enc/FEC_enc.c b/lib_enc/FEC_enc.c
deleted file mode 100644
index 3d5aa4f6b215a78e13905dd808f2ecf0e995115d..0000000000000000000000000000000000000000
--- a/lib_enc/FEC_enc.c
+++ /dev/null
@@ -1,216 +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 "ivas_prot_fx.h"
-#include "prot_fx.h"
-
-/*-------------------------------------------------------------------*
- * FEC_encode()
- *
- * Encoder supplementary information for FEC
- *-------------------------------------------------------------------*/
-
-void FEC_encode_ivas_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const ACELP_config acelp_cfg, /* i/o: configuration of the ACELP */
- const Word16 *synth, /* i : pointer to synthesized speech for E computation */
- const Word16 coder_type, /* i : type of coder */
- Word16 clas, /* i : signal clas for current frame */
- const Word16 *fpit, /* i : close loop fractional pitch buffer Q6 */
- const Word16 *res, /* i : LP residual signal frame */
- Word16 *last_pulse_pos, /* i/o: Position of the last pulse */
- const Word16 L_frame, /* i : Frame length */
- const Word32 total_brate, /* i : total codec bitrate */
- const Word16 Q_synth /* i : input scaling */
-)
-{
- Word16 tmpS, index;
- Word16 maxi, sign, tmp_FER_pitch;
- Word32 enr_q, Ltmp;
- Word16 exp_enrq;
-
- tmpS = 0;
- move16();
- enr_q = 1;
- move16();
- sign = 0;
- move16();
- test();
- test();
- IF( GT_16( coder_type, UNVOICED ) && LT_16( coder_type, AUDIO ) && acelp_cfg.FEC_mode > 0 )
- {
- /*-----------------------------------------------------------------*
- * encode signal class (not needed for VC mode since it is clearly voiced) (2 bits)
- *-----------------------------------------------------------------*/
- IF( NE_16( coder_type, VOICED ) )
- {
- /* encode signal clas with 2 bits */
- test();
- IF( EQ_16( clas, UNVOICED_CLAS ) )
- {
- index = 0;
- move16();
- }
- ELSE IF( EQ_16( clas, VOICED_TRANSITION ) || EQ_16( clas, UNVOICED_TRANSITION ) )
- {
- index = 1;
- move16();
- }
- ELSE IF( EQ_16( clas, VOICED_CLAS ) )
- {
- index = 2;
- move16();
- }
- ELSE
- {
- index = 3;
- move16();
- }
- push_indice( hBstr, IND_FEC_CLAS, index, FEC_BITS_CLS );
- }
-
- /*-----------------------------------------------------------------*
- * encode frame energy (5 bits)
- *-----------------------------------------------------------------*/
- test();
- IF( GT_16( acelp_cfg.FEC_mode, 1 ) ) /* GENERIC and VOICED frames */
- {
- /* 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 );
- fer_energy_fx( L_frame, clas, synth32, Q_synth, shr_r( fpit[sub( shr( L_frame, 6 ), 1 )], 6 ), &enr_q, L_frame );
- exp_enrq = sub( 31, shl( Q_synth, 1 ) );
- IF( EQ_16( clas, VOICED_CLAS ) || EQ_16( clas, ONSET ) || EQ_16( clas, SIN_ONSET ) ) /* Voiced or Onset current frame */
- {
- exp_enrq = 31;
- move16();
- }
- /* linearly quantize the energy in the range 0 : FEC_ENR_STEP : 96 dB */
- /*tmpS = (short)( 10.0 * log10( enr_q + 0.001f ) / FEC_ENR_STEP )*/ /*To be converted fl_2_fx*/
-
- Ltmp = Mpy_32_32( BASOP_Util_Log10( enr_q, exp_enrq ), 894784853 /* 10 / FEC_ENR_STEP Q28 */ ); // Q 25 + 28 - 31 = Q22
- IF( Ltmp < 0 )
- {
- tmpS = extract_l( L_negate( L_shr( L_negate( Ltmp ), Q22 ) ) );
- }
- ELSE
- {
- tmpS = extract_l( L_shr( Ltmp, Q22 ) );
- }
-
- tmpS = s_min( tmpS, FEC_ENR_QLIMIT );
- tmpS = s_max( tmpS, 0 );
-
- push_indice( hBstr, IND_FEC_ENR, tmpS, FEC_BITS_ENR );
- }
- /*-----------------------------------------------------------------*
- * Encode last glottal pulse position (8 bits)
- *-----------------------------------------------------------------*/
- test();
- IF( GT_16( acelp_cfg.FEC_mode, 2 ) ) /* GENERIC frames */
- {
- /* retrieve the last glottal pulse position of the previous frame */
- /* use the current pitch information to scale or not the quantization */
- tmp_FER_pitch = shr( fpit[0], 6 ); /* take the 1st subframe pit, since it is easier to get on decoder side */
- sign = 0;
- move16();
- maxi = *last_pulse_pos;
- move16();
- IF( maxi < 0 )
- {
- sign = 1;
- move16();
- /*maxi = -maxi; */
- maxi = negate( maxi );
- }
-
- if ( GE_16( tmp_FER_pitch, 128 ) )
- {
- maxi = shr( maxi, 1 );
- }
-
- if ( GT_16( maxi, 127 ) )
- {
- /* better not use the glottal pulse position at all instead of using a wrong pulse */
- /* can happen only with pitch > 254 and max pit = 289 and should happen very rarely */
- maxi = 0;
- move16();
- }
-
- if ( EQ_16( sign, 1 ) )
- {
- maxi = add( maxi, 128 ); /* use 8 bits (MSB represent the sign of the pulse) */
- }
-
- push_indice( hBstr, IND_FEC_POS, maxi, FEC_BITS_POS );
- }
- maxi = 0;
- move16();
-
- /* If bitrate < 24k4, then the pitch
- is not represented in the same domain (12.k instead of 16k) */
- test();
- IF( GE_16( clas, VOICED_CLAS ) && GE_32( total_brate, ACELP_24k40 ) )
- {
- /*maxi = findpulse( L_frame, res, (short)(fpit[(L_frame>>6)-1]), 0, &sign ); */
- maxi = findpulse_fx( L_frame, res, shr_r( fpit[sub( shr( L_frame, 6 ), 1 )], 6 ), 0, &sign );
- if ( EQ_16( sign, 1 ) )
- {
- /*maxi = -maxi;*/
- maxi = negate( maxi );
- }
- }
-
- *last_pulse_pos = maxi;
- move16();
- }
- ELSE
- {
- *last_pulse_pos = 0;
- move16();
- }
-
- return;
-}
diff --git a/lib_enc/FEC_enc_fx.c b/lib_enc/FEC_enc_fx.c
index d35f18b61a9dcf5be4bf1727d91abeb852530913..9106e23e70eeb8e67b6eaa8cd1be674973598811 100644
--- a/lib_enc/FEC_enc_fx.c
+++ b/lib_enc/FEC_enc_fx.c
@@ -5,10 +5,12 @@
#include "options.h" /* Compilation switches */
#include "cnst.h" /* Common constants */
//#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 "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 "prot.h" /* Function prototypes */
+#include "ivas_prot_fx.h" /* Function prototypes */
/*============================================================================*/
@@ -37,18 +39,18 @@
/* */
/*============================================================================*/
void FEC_encode_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const ACELP_config acelp_cfg, /* i/o: configuration of the ACELP */
- const Word16 *synth, /* i : pointer to synthesized speech for E computation */
- const Word16 coder_type, /* i : type of coder */
- Word16 clas, /* i : signal clas for current frame */
- const Word16 *fpit, /* i : close loop fractional pitch buffer */
- const Word16 *res, /* i : LP residual signal frame */
- Word16 *last_pulse_pos, /* i/o: Position of the last pulse */
- const Word16 L_frame, /* i : Frame length */
- const Word32 total_brate, /* i : total codec bitrate */
- const Word16 Q_new, /* i : input scaling */
- const Word16 shift /* i : scaling to get 12bits */
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ const ACELP_config acelp_cfg, /* i/o: configuration of the ACELP */
+ const Word16 *synth, /* i : pointer to synthesized speech for E computation Q_synth*/
+ const Word16 coder_type, /* i : type of coder Q0*/
+ Word16 clas, /* i : signal clas for current frame Q0*/
+ const Word16 *fpit, /* i : close loop fractional pitch buffer Q6*/
+ const Word16 *res, /* i : LP residual signal frame Qx*/
+ Word16 *last_pulse_pos, /* i/o: Position of the last pulse Q0*/
+ const Word16 L_frame, /* i : Frame length Q0*/
+ const Word32 total_brate, /* i : total codec bitrate Q0*/
+ const Word16 Q_new, /* i : input scaling */
+ const Word16 shift /* i : scaling to get 12bits */
)
{
Word16 tmpS, index;
@@ -99,20 +101,19 @@ void FEC_encode_fx(
/*-----------------------------------------------------------------*
* encode frame energy (5 bits)
*-----------------------------------------------------------------*/
- test();
IF( GT_16( acelp_cfg.FEC_mode, 1 ) ) /* GENERIC and VOICED frames */
{
/* 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 );*/
- exp_enrq = frame_ener_fx( L_frame, clas, synth, shr_r( fpit[sub( shr( L_frame, 6 ), 1 )], 6 ), &enr_q, L_frame, Q_new, shift, 1 );
+ exp_enrq = frame_ener_fx( L_frame, clas, synth, shr_r( fpit[( L_frame >> 6 ) - 1], 6 ), &enr_q, L_frame, Q_new, shift, 1 );
/* linearly quantize the energy in the range 0 : FEC_ENR_STEP : 96 dB */
/*tmpS = (short)( 10.0 * log10( enr_q + 0.001f ) / FEC_ENR_STEP )*/ /*To be converted fl_2_fx*/
enr_lg_frac = Log2_norm_lc( enr_q );
- enr_lg_ent = sub( 30, exp_enrq );
- Ltmp = Mpy_32_16( enr_lg_ent, enr_lg_frac, LG10_s3_0 );
- tmpS = extract_h( L_shl( Ltmp, 1 ) );
+ enr_lg_ent = sub( 30, exp_enrq ); /* Q15 */
+ Ltmp = Mpy_32_16( enr_lg_ent, enr_lg_frac, LG10_s3_0 ); /* Q14 */
+ tmpS = extract_h( L_shl( Ltmp, 1 ) ); /* Q15 + 1 -> Q0*/
tmpS = s_min( tmpS, 31 );
tmpS = s_max( tmpS, 0 );
@@ -122,7 +123,6 @@ void FEC_encode_fx(
/*-----------------------------------------------------------------*
* Encode last glottal pulse position (8 bits)
*-----------------------------------------------------------------*/
- test();
IF( GT_16( acelp_cfg.FEC_mode, 2 ) ) /* GENERIC frames */
{
/* retrieve the last glottal pulse position of the previous frame */
@@ -130,14 +130,14 @@ void FEC_encode_fx(
tmp_FER_pitch = shr( fpit[0], 6 ); /* take the 1st subframe pit, since it is easier to get on decoder side */
sign = 0;
move16();
- maxi = *last_pulse_pos;
+ maxi = *last_pulse_pos; /* Q0 */
move16();
IF( maxi < 0 )
{
sign = 1;
move16();
/*maxi = -maxi; */
- maxi = negate( maxi );
+ maxi = negate( maxi ); /* Q0 */
}
if ( GE_16( tmp_FER_pitch, 128 ) )
@@ -155,7 +155,7 @@ void FEC_encode_fx(
if ( sign == 1 )
{
- maxi = add( maxi, 128 ); /* use 8 bits (MSB represent the sign of the pulse) */
+ maxi = add( maxi, 128 ); /* use 8 bits (MSB represent the sign of the pulse) Q0*/
}
push_indice_fx( hBstr, IND_FEC_POS, maxi, FEC_BITS_POS );
@@ -169,15 +169,15 @@ void FEC_encode_fx(
IF( GE_16( clas, VOICED_CLAS ) && GE_32( total_brate, ACELP_24k40 ) )
{
/*maxi = findpulse( L_frame, res, (short)(fpit[(L_frame>>6)-1]), 0, &sign ); */
- maxi = findpulse_fx( L_frame, res, shr_r( fpit[sub( shr( L_frame, 6 ), 1 )], 6 ), 0, &sign );
+ maxi = findpulse_fx( L_frame, res, shr_r( fpit[( L_frame >> 6 ) - 1], 6 ), 0, &sign ); /* Q0 */
if ( sign == 1 )
{
/*maxi = -maxi;*/
- maxi = negate( maxi );
+ maxi = negate( maxi ); /* Q0 */
}
}
- *last_pulse_pos = maxi;
+ *last_pulse_pos = maxi; /* Q0 */
move16();
}
ELSE
@@ -198,8 +198,8 @@ void FEC_encode_fx(
*-------------------------------------------------------------------*/
void FEC_lsf_estim_enc_fx(
- Encoder_State *st_fx, /* i : Encoder static memory */
- Word16 *lsf /* o : estimated LSF vector */
+ Encoder_State *st_fx, /* i : Encoder static memory */
+ Word16 *lsf /* o : estimated LSF vector Qlog2(2.56)*/
)
{
Word16 i;
@@ -222,7 +222,7 @@ void FEC_lsf_estim_enc_fx(
IF( EQ_16( st_fx->last_coder_type, UNVOICED ) )
{
/* clearly unvoiced */
- alpha = _ALPHA_UU_FX;
+ alpha = _ALPHA_UU_FX; /* Q15 */
move16();
}
ELSE
@@ -231,52 +231,54 @@ void FEC_lsf_estim_enc_fx(
test();
IF( EQ_16( st_fx->last_coder_type, AUDIO ) || EQ_16( st_fx->clas, INACTIVE_CLAS ) )
{
- alpha = 32604;
+ alpha = 32604; /* 0.995 in Q15 */
move16();
}
ELSE IF( EQ_16( st_fx->clas, UNVOICED_CLAS ) )
{
/* if stable, do not flatten the spectrum in the first erased frame */
/* alpha = st->stab_fac * (1.0f - 2.0f*ALPHA_U) + 2.0f*ALPHA_U; */
- alpha = add( mult( st_fx->stab_fac_fx, 32768 - _ALPHA_U_FX_X_2 ), _ALPHA_U_FX_X_2 );
+ alpha = add( mult( st_fx->stab_fac_fx, 32768 - _ALPHA_U_FX_X_2 ), _ALPHA_U_FX_X_2 ); /* Q15 */
}
ELSE IF( EQ_16( st_fx->clas, UNVOICED_TRANSITION ) )
{
- alpha = _ALPHA_UT_FX;
+ alpha = _ALPHA_UT_FX; /* Q15 */
move16();
}
ELSE IF( EQ_16( st_fx->clas, VOICED_CLAS ) || EQ_16( st_fx->clas, ONSET ) )
{
/* clearly voiced - mild convergence to the CNG spectrum for the first three erased frames */
- alpha = _ALPHA_V_FX;
+ alpha = _ALPHA_V_FX; /* Q15 */
move16();
}
ELSE IF( EQ_16( st_fx->clas, SIN_ONSET ) )
{
- alpha = _ALPHA_S_FX;
+ alpha = _ALPHA_S_FX; /* Q15 */
move16();
}
ELSE
{
/* long erasures and onsets - rapid convergence to the CNG spectrum */
- alpha = _ALPHA_VT_FX;
+ alpha = _ALPHA_VT_FX; /* Q15 */
move16();
}
}
/*----------------------------------------------------------------------*
* Extrapolate LSF vector
*----------------------------------------------------------------------*/
- tmp = sub( 32767, alpha );
+ tmp = sub( 32767, alpha ); /* Q15 */
/* extrapolate the old LSF vector */
FOR( i = 0; i < M; i++ )
{
/* calculate mean LSF vector */
/*lsf_mean[i] = BETA_FEC * lsf_mean[i] + (1-BETA_FEC) * st->lsf_adaptive_mean[i]; */
- lsf_mean[i] = mac_r( L_mult( BETA_FEC_FX, lsf_mean[i] ), 32768 - BETA_FEC_FX, st_fx->lsf_adaptive_mean_fx[i] );
+ lsf_mean[i] = mac_r( L_mult( BETA_FEC_FX, lsf_mean[i] ), 32768 - BETA_FEC_FX, st_fx->lsf_adaptive_mean_fx[i] ); /* Qlog2(2.56) */
+ move16();
/* move old LSF vector towards the mean LSF vector */
/* lsf[i] = alpha * st->lsf_old[i] + (1.0f - alpha) * lsf_mean[i]; */
- lsf[i] = mac_r( L_mult( alpha, st_fx->lsf_old_fx[i] ), tmp, lsf_mean[i] );
+ lsf[i] = mac_r( L_mult( alpha, st_fx->lsf_old_fx[i] ), tmp, lsf_mean[i] ); /* Qlog2(2.56) */
+ move16();
}
/* check LSF stability through LSF ordering */
@@ -291,3 +293,175 @@ void FEC_lsf_estim_enc_fx(
return;
}
+
+/*-------------------------------------------------------------------*
+ * FEC_encode()
+ *
+ * Encoder supplementary information for FEC
+ *-------------------------------------------------------------------*/
+
+void FEC_encode_ivas_fx(
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ const ACELP_config acelp_cfg, /* i/o: configuration of the ACELP */
+ const Word16 *synth, /* i : pointer to synthesized speech for E computation Q_Synth*/
+ const Word16 coder_type, /* i : type of coder Q0*/
+ Word16 clas, /* i : signal clas for current frame Q0*/
+ const Word16 *fpit, /* i : close loop fractional pitch buffer Q6*/
+ const Word16 *res, /* i : LP residual signal frame Qx*/
+ Word16 *last_pulse_pos, /* i/o: Position of the last pulse Q0*/
+ const Word16 L_frame, /* i : Frame length Q0*/
+ const Word32 total_brate, /* i : total codec bitrate Q0*/
+ const Word16 Q_synth /* i : input scaling */
+)
+{
+ Word16 tmpS, index;
+ Word16 maxi, sign, tmp_FER_pitch;
+ Word32 enr_q, Ltmp;
+ Word16 exp_enrq;
+
+ tmpS = 0;
+ move16();
+ enr_q = 1;
+ move16();
+ sign = 0;
+ move16();
+ test();
+ test();
+ IF( GT_16( coder_type, UNVOICED ) && LT_16( coder_type, AUDIO ) && acelp_cfg.FEC_mode > 0 )
+ {
+ /*-----------------------------------------------------------------*
+ * encode signal class (not needed for VC mode since it is clearly voiced) (2 bits)
+ *-----------------------------------------------------------------*/
+ IF( NE_16( coder_type, VOICED ) )
+ {
+ /* encode signal clas with 2 bits */
+ test();
+ IF( clas == UNVOICED_CLAS )
+ {
+ index = 0;
+ move16();
+ }
+ ELSE IF( EQ_16( clas, VOICED_TRANSITION ) || EQ_16( clas, UNVOICED_TRANSITION ) )
+ {
+ index = 1;
+ move16();
+ }
+ ELSE IF( EQ_16( clas, VOICED_CLAS ) )
+ {
+ index = 2;
+ move16();
+ }
+ ELSE
+ {
+ index = 3;
+ move16();
+ }
+ push_indice( hBstr, IND_FEC_CLAS, index, FEC_BITS_CLS );
+ }
+
+ /*-----------------------------------------------------------------*
+ * encode frame energy (5 bits)
+ *-----------------------------------------------------------------*/
+ IF( GT_16( acelp_cfg.FEC_mode, 1 ) ) /* GENERIC and VOICED frames */
+ {
+ /* 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_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 ) );
+
+ test();
+ test();
+ if ( EQ_16( clas, VOICED_CLAS ) || EQ_16( clas, ONSET ) || EQ_16( clas, SIN_ONSET ) ) /* Voiced or Onset current frame */
+ {
+ exp_enrq = 31;
+ move16();
+ }
+ /* linearly quantize the energy in the range 0 : FEC_ENR_STEP : 96 dB */
+ /*tmpS = (short)( 10.0 * log10( enr_q + 0.001f ) / FEC_ENR_STEP )*/ /*To be converted fl_2_fx*/
+
+ Ltmp = Mpy_32_32( BASOP_Util_Log10( enr_q, exp_enrq ), 894784853 /* 10 / FEC_ENR_STEP Q28 */ ); // Q 25 + 28 - 31 = Q22
+ IF( Ltmp < 0 )
+ {
+ tmpS = extract_l( L_negate( L_shr( L_negate( Ltmp ), Q22 ) ) ); /* Q0 */
+ }
+ ELSE
+ {
+ tmpS = extract_l( L_shr( Ltmp, Q22 ) ); /* Q0 */
+ }
+
+ tmpS = s_min( tmpS, FEC_ENR_QLIMIT );
+ tmpS = s_max( tmpS, 0 );
+
+ push_indice( hBstr, IND_FEC_ENR, tmpS, FEC_BITS_ENR );
+ }
+ /*-----------------------------------------------------------------*
+ * Encode last glottal pulse position (8 bits)
+ *-----------------------------------------------------------------*/
+
+ IF( GT_16( acelp_cfg.FEC_mode, 2 ) ) /* GENERIC frames */
+ {
+ /* retrieve the last glottal pulse position of the previous frame */
+ /* use the current pitch information to scale or not the quantization */
+ tmp_FER_pitch = shr( fpit[0], 6 ); /* take the 1st subframe pit, since it is easier to get on decoder side */
+ sign = 0;
+ move16();
+ maxi = *last_pulse_pos; /* Q0 */
+ move16();
+ IF( maxi < 0 )
+ {
+ sign = 1;
+ move16();
+ /*maxi = -maxi; */
+ maxi = negate( maxi );
+ }
+
+ if ( GE_16( tmp_FER_pitch, 128 ) )
+ {
+ maxi = shr( maxi, 1 );
+ }
+
+ if ( GT_16( maxi, 127 ) )
+ {
+ /* better not use the glottal pulse position at all instead of using a wrong pulse */
+ /* can happen only with pitch > 254 and max pit = 289 and should happen very rarely */
+ maxi = 0;
+ move16();
+ }
+
+ if ( EQ_16( sign, 1 ) )
+ {
+ maxi = add( maxi, 128 ); /* use 8 bits (MSB represent the sign of the pulse) Q0*/
+ }
+
+ push_indice( hBstr, IND_FEC_POS, maxi, FEC_BITS_POS );
+ }
+ maxi = 0;
+ move16();
+
+ /* If bitrate < 24k4, then the pitch
+ is not represented in the same domain (12.k instead of 16k) */
+ test();
+ IF( GE_16( clas, VOICED_CLAS ) && GE_32( total_brate, ACELP_24k40 ) )
+ {
+ /*maxi = findpulse( L_frame, res, (short)(fpit[(L_frame>>6)-1]), 0, &sign ); */
+ maxi = findpulse_fx( L_frame, res, shr_r( fpit[( L_frame >> 6 ) - 1], 6 ), 0, &sign );
+ if ( EQ_16( sign, 1 ) )
+ {
+ /*maxi = -maxi;*/
+ maxi = negate( maxi );
+ }
+ }
+
+ *last_pulse_pos = maxi; /* Q0 */
+ move16();
+ }
+ ELSE
+ {
+ *last_pulse_pos = 0;
+ move16();
+ }
+
+ return;
+}
diff --git a/lib_enc/SNR_calc.c b/lib_enc/SNR_calc.c
deleted file mode 100644
index 8d4adb219f2e97f01fc9e529ffbc94de34a8fde5..0000000000000000000000000000000000000000
--- a/lib_enc/SNR_calc.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/SNR_calc_fx.c b/lib_enc/SNR_calc_fx.c
index 320a68d255f539a42d1f543642c5abcd85a10863..f44530c849cf8108fea348eef9dc8eb888cf2795 100644
--- a/lib_enc/SNR_calc_fx.c
+++ b/lib_enc/SNR_calc_fx.c
@@ -10,6 +10,7 @@
#include "prot_fx_enc.h" /* Function prototypes */
#include "rom_enc.h"
#include "rom_com.h"
+#include "prot.h"
/*-------------------------------------------------------------------*
@@ -19,16 +20,15 @@
*-------------------------------------------------------------------*/
void calc_lf_snr_fx(
- Word32 *lf_snr_smooth, /* o : smoothed lf_snr*/
- Word32 *lf_snr, /* o : long time frequency domain
- SNR calculated by l_speech_snr and l_silence_snr*/
- const Word32 l_speech_snr, /* i : sum of active frames snr */
- const Word32 l_speech_snr_count, /* i : amount of the active frame */
- const Word32 l_silence_snr, /* i : sum of the nonactive frames snr*/
- const Word32 l_silence_snr_count, /* i : amount of the nonactive frame */
- const Word16 fg_energy_count, /* i : amount of the foreground energy frame */
- const Word16 bg_energy_count, /* i : amount of the background energy frame */
- const Word16 bw_index /* i : band width index*/
+ Word32 *lf_snr_smooth, /* o : smoothed lf_snr Q25*/
+ Word32 *lf_snr, /* o : long time frequency domain SNR calculated by l_speech_snr and l_silence_snr Q25*/
+ const Word32 l_speech_snr, /* i : sum of active frames snr Q16*/
+ const Word32 l_speech_snr_count, /* i : amount of the active frame Q0*/
+ const Word32 l_silence_snr, /* i : sum of the nonactive frames snr Q16*/
+ const Word32 l_silence_snr_count, /* i : amount of the nonactive frame Q0*/
+ const Word16 fg_energy_count, /* i : amount of the foreground energy frame Q0*/
+ const Word16 bg_energy_count, /* i : amount of the background energy frame Q0*/
+ const Word16 bw_index /* i : band width index Q0*/
)
{
@@ -36,18 +36,18 @@ void calc_lf_snr_fx(
Word16 q_divout, q_divout1;
- div1 = VAD_L_div( l_speech_snr, l_speech_snr_count, 16, 0, &q_divout );
- div2 = VAD_L_div( l_silence_snr, l_silence_snr_count, 16, 0, &q_divout1 );
- l_snr = VAD_L_ADD( div1, q_divout, L_negate( div2 ), q_divout1, &q_divout );
+ div1 = VAD_L_div( l_speech_snr, l_speech_snr_count, 16, 0, &q_divout ); /* q_divout */
+ div2 = VAD_L_div( l_silence_snr, l_silence_snr_count, 16, 0, &q_divout1 ); /* q_divout1 */
+ l_snr = VAD_L_ADD( div1, q_divout, L_negate( div2 ), q_divout1, &q_divout ); /* q_divout */
*lf_snr_smooth = MUL_F( *lf_snr_smooth, 29490 /* 0.9 Q15 */ );
move32();
- tmp = MUL_F( l_snr, 26214 );
- *lf_snr_smooth = VAD_L_ADD( *lf_snr_smooth, 25, tmp, add( 3, q_divout ), &q_divout1 );
+ tmp = MUL_F( l_snr, 26214 /* 0.8 in Q15 */ );
+ *lf_snr_smooth = VAD_L_ADD( *lf_snr_smooth, 25, tmp, add( 3, q_divout ), &q_divout1 ); /* q_divout1 */
move32();
- *lf_snr_smooth = L_shr( *lf_snr_smooth, sub( q_divout1, 25 ) );
+ *lf_snr_smooth = L_shr( *lf_snr_smooth, sub( q_divout1, 25 ) ); /* Q25 */
move32();
- l_snr = L_shr( l_snr, sub( q_divout, 25 ) );
+ l_snr = L_shr( l_snr, sub( q_divout, 25 ) ); /* Q25 */
test();
if ( ( LT_16( bg_energy_count, 56 ) ) || ( LT_16( fg_energy_count, 56 ) ) )
@@ -60,9 +60,9 @@ void calc_lf_snr_fx(
l_snr = L_sub( l_snr, 12079595 /* 0.36 Q25 */ );
l_snr = L_max( 0, l_snr );
- l_snr = L_min( l_snr, MAX_LF_SNR_TAB_FX[bw_index] );
+ l_snr = L_min( l_snr, MAX_LF_SNR_TAB_FX[bw_index] ); /* Q25 */
- *lf_snr = l_snr;
+ *lf_snr = l_snr; /* Q25 */
move32();
return;
}
@@ -73,14 +73,14 @@ void calc_lf_snr_fx(
*-------------------------------------------------------------------*/
void calc_lt_snr_fx(
VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */
- Word32 *lt_snr_org_fp, /* o : original long time SNR*/
- Word32 *lt_snr_fp, /* o : long time SNR calculated by fg_energy and bg_energy*/
- Word32 fg_energy, /* i : foreground energy sum */
- Word16 fg_energy_count, /* i : amount of the foreground energy frame */
- Word32 bg_energy, /* i : background energy sum */
- Word16 bg_energy_count, /* i : amount of the background energy frame */
- Word16 bw_index, /* i : band width index*/
- Word16 lt_noise_sp_center0 /* i : long time noise spectral center by 0*/
+ Word32 *lt_snr_org_fp, /* o : original long time SNR Q25*/
+ Word32 *lt_snr_fp, /* o : long time SNR calculated by fg_energy and bg_energy Q25*/
+ Word32 fg_energy, /* i : foreground energy sum Qx*/
+ Word16 fg_energy_count, /* i : amount of the foreground energy frame Q0*/
+ Word32 bg_energy, /* i : background energy sum Qx*/
+ Word16 bg_energy_count, /* i : amount of the background energy frame Q0*/
+ Word16 bw_index, /* i : band width index Q0*/
+ Word16 lt_noise_sp_center0 /* i : long time noise spectral center by 0 Q10*/
)
{
Word16 tmp_lt_noise_sp_center;
@@ -89,7 +89,7 @@ void calc_lt_snr_fx(
Word32 lt_snr, div1, div2, tmp;
- tmp_lt_noise_sp_center = sub( lt_noise_sp_center0, 1432 /* 1.4 Q10 */ );
+ tmp_lt_noise_sp_center = sub( lt_noise_sp_center0, 1432 /* 1.4 Q10 */ ); /* Q10 */
if ( GT_16( tmp_lt_noise_sp_center, 818 /* 0.8 Q10 */ ) )
{
tmp_lt_noise_sp_center = 818 /* 0.8 Q10 */;
@@ -103,28 +103,29 @@ void calc_lt_snr_fx(
}
div1 = MUL_F( fg_energy, bg_energy_count );
- div1 = VAD_L_ADD( div1, hVAD_CLDFB->fg_energy_scale, 1, 126, &q_div1 );
+ div1 = VAD_L_ADD( div1, hVAD_CLDFB->fg_energy_scale, 1, 126, &q_div1 ); /* q_div1 */
div2 = MUL_F( bg_energy, fg_energy_count );
- div2 = VAD_L_ADD( div2, hVAD_CLDFB->bg_energy_scale, 1, 126, &q_div2 );
- if ( div2 == 0 )
+ div2 = VAD_L_ADD( div2, hVAD_CLDFB->bg_energy_scale, 1, 126, &q_div2 ); /* q_div2 */
+ IF( div2 == 0 )
{
div2 = 1;
move32(); /* div2==0 , may occur for >30000 frames all zero input */
if ( div1 != 0 )
{
hVAD_CLDFB->bg_energy_scale = add( hVAD_CLDFB->fg_energy_scale, 50 );
+ move16();
}
}
- div2 = VAD_L_div( div1, div2, q_div1, q_div2, &q_divout );
+ div2 = VAD_L_div( div1, div2, q_div1, q_div2, &q_divout ); /* q_divout */
lt_snr_org = VAD_Log2( div2, q_divout );
- lt_snr_org = MUL_F( lt_snr_org, 9864 );
- lt_snr = lt_snr_org;
+ lt_snr_org = MUL_F( lt_snr_org, 9864 /* 0.3 in Q15 */ ); /* Q25 */
+ lt_snr = lt_snr_org; /* Q25 */
move32();
- *lt_snr_org_fp = lt_snr;
+ *lt_snr_org_fp = lt_snr; /* Q25 */
move32();
test();
- IF( LT_16( bg_energy_count, 56 ) || LT_16( fg_energy_count, 56 ) )
+ if ( LT_16( bg_energy_count, 56 ) || LT_16( fg_energy_count, 56 ) )
{
lt_snr = 70464302 /* 2.1 Q25 */;
move32();
@@ -132,26 +133,26 @@ void calc_lt_snr_fx(
IF( EQ_16( bw_index, CLDFBVAD_NB_ID ) )
{
- lt_snr = L_sub( L_shr( lt_snr, 1 ), 25165823 /* 0.75 Q25 */ );
+ lt_snr = L_sub( L_shr( lt_snr, 1 ), 25165823 /* 0.75 Q25 */ ); /* Q25 */
}
ELSE IF( EQ_16( bw_index, CLDFBVAD_WB_ID ) )
{
- lt_snr = L_sub( L_shr( lt_snr, 1 ), 25165823 /* 0.75 Q25 */ );
+ lt_snr = L_sub( L_shr( lt_snr, 1 ), 25165823 /* 0.75 Q25 */ ); /* Q25 */
}
ELSE
{
- lt_snr = MUL_F( lt_snr, 15073 /* 0.46 Q15 */ );
- lt_snr = L_sub( lt_snr, 23152557 /* 0.69 Q25 */ );
+ lt_snr = MUL_F( lt_snr, 15073 /* 0.46 Q15 */ ); /* Q25 */
+ lt_snr = L_sub( lt_snr, 23152557 /* 0.69 Q25 */ ); /* Q25 */
}
- tmp = MUL_F( lt_snr, 13107 /* 0.4 Q15 */ );
+ tmp = MUL_F( lt_snr, 13107 /* 0.4 Q15 */ ); /* Q25 */
- tmp = L_add( L_shr( tmp, 1 ), -26214 );
+ tmp = L_add( L_shr( tmp, 1 ), -26214 /* 0.0007 in Q25 */ );
- tmp = MUL_F( tmp, 13107 /* 0.4 Q15 */ );
+ tmp = MUL_F( tmp, 13107 /* 0.4 Q15 */ ); /* Q25 */
tmp = MUL_F( tmp, tmp_lt_noise_sp_center );
- lt_snr = VAD_L_ADD( lt_snr, 25, tmp, 19, &q_divout1 );
- lt_snr = L_shr( lt_snr, sub( q_divout1, 25 ) );
+ lt_snr = VAD_L_ADD( lt_snr, 25, tmp, 19, &q_divout1 ); /* q_divout1 */
+ lt_snr = L_shr( lt_snr, sub( q_divout1, 25 ) ); /* Q25 */
lt_snr = L_max( 0, lt_snr );
@@ -161,7 +162,7 @@ void calc_lt_snr_fx(
move32();
}
- *lt_snr_fp = lt_snr;
+ *lt_snr_fp = lt_snr; /* Q25 */
move32();
return;
}
@@ -172,9 +173,9 @@ void calc_lt_snr_fx(
*
*-------------------------------------------------------------------*/
void calc_snr_flux_fx(
- Word32 tsnr, /* i : time-domain SNR*/
- Word32 *pre_snr, /* i/o: time-domain SNR storage*/
- Word32 *snr_flux_fp /* o : average tsnr*/
+ Word32 tsnr, /* i : time-domain SNR Q25*/
+ Word32 *pre_snr, /* i/o: time-domain SNR storage Q25*/
+ Word32 *snr_flux_fp /* o : average tsnr Q25*/
)
{
Word32 i;
@@ -186,7 +187,7 @@ void calc_snr_flux_fx(
test();
IF( ( LT_32( L_shr( tsnr, 1 ), 43620759 /* 2.6f/2.0f Q25 */ ) ) && tsnr > 0 )
{
- pre_snr[0] = tsnr;
+ pre_snr[0] = tsnr; /* Q25 */
move32();
}
ELSE IF( tsnr <= 0 )
@@ -206,17 +207,17 @@ void calc_snr_flux_fx(
s16MaxCoefNorm = sub( ffr_getSfWord32( pre_snr, 32 ), 5 );
FOR( i = 0; i < 32; i++ )
{
- tmp = L_shl( pre_snr[i], s16MaxCoefNorm );
+ tmp = L_shl( pre_snr[i], s16MaxCoefNorm ); /* Q25 + s16MaxCoefNorm */
snr_flux = L_add( snr_flux, tmp );
}
snr_flux = L_shr( snr_flux, add( s16MaxCoefNorm, 5 ) );
- *snr_flux_fp = snr_flux;
+ *snr_flux_fp = snr_flux; /* Q25 */
move32();
/*update the tsnr storage pre_snr*/
FOR( i = PRE_SNR_NUM - 1; i > 0; i-- )
{
- pre_snr[i] = pre_snr[i - 1];
+ pre_snr[i] = pre_snr[i - 1]; /* Q25 */
move32();
}
return;
@@ -229,12 +230,12 @@ void calc_snr_flux_fx(
*
*-------------------------------------------------------------------*/
void snr_calc(
- VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */
- const Word16 sacle_sbpower, /* i : the Scaling of sbpower*/
- Word32 *snr, /* o : frequency domain SNR */
- Word32 *tsnr, /* o : time domain SNR */
- const Word32 frame_energy, /* i : current frame energy */
- const Word32 bwidth /* i : audio band width*/
+ VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */
+ const Word16 sacle_sbpower, /* i : the Scaling of sbpower */
+ Word32 *snr, /* o : frequency domain SNR Q25*/
+ Word32 *tsnr, /* o : time domain SNR Q25*/
+ const Word32 frame_energy, /* i : current frame energy sacle_sbpower*/
+ const Word32 bwidth /* i : audio band width Q0*/
)
{
Word32 i;
@@ -248,10 +249,12 @@ void snr_calc(
Word16 tmp_addQ1, tmp_addQ2, minscale, minscale1, minscale2, s16MaxCoefNorm, q_divout;
Word32 tmpspec_amp;
Word32 const CONSTfix = 1759218560;
- Word32 snr_tmpidx[12] = { 0 };
+ move32();
+ Word32 snr_tmpidx[12];
+ set_zero_fx( snr_tmpidx, 12 );
- SNR_sb_num = SNR_SUB_BAND_NUM[bwidth - CLDFBVAD_NB_ID];
+ SNR_sb_num = SNR_SUB_BAND_NUM[bwidth - CLDFBVAD_NB_ID]; /* Q0 */
move16();
sb_bg_energy = hVAD_CLDFB->sb_bg_energy;
frame_sb_energy = hVAD_CLDFB->frame_sb_energy;
@@ -262,14 +265,14 @@ void snr_calc(
move32();
FOR( i = 0; i < SNR_sb_num; i++ )
{
- div1 = VAD_L_ADD( frame_sb_energy[i], hVAD_CLDFB->frame_sb_energy_scale, CONSTfix, 44, &tmp_addQ1 );
- div2 = VAD_L_ADD( sb_bg_energy[i], hVAD_CLDFB->sb_bg_energy_scale, CONSTfix, 44, &tmp_addQ2 );
- tmp = VAD_L_div( div1, div2, tmp_addQ1, tmp_addQ2, &q_divout );
+ div1 = VAD_L_ADD( frame_sb_energy[i], hVAD_CLDFB->frame_sb_energy_scale, CONSTfix, 44, &tmp_addQ1 ); /* tmp_addQ1 */
+ div2 = VAD_L_ADD( sb_bg_energy[i], hVAD_CLDFB->sb_bg_energy_scale, CONSTfix, 44, &tmp_addQ2 ); /* tmp_addQ2 */
+ tmp = VAD_L_div( div1, div2, tmp_addQ1, tmp_addQ2, &q_divout ); /* q_divout */
tmp = VAD_Log2( tmp, q_divout );
if ( GT_32( tmp, -3355443 /* -0.10 Q25 */ ) )
{
- snr_tmpidx[i] = tmp;
+ snr_tmpidx[i] = tmp; /* Q25 */
move32();
}
}
@@ -277,21 +280,21 @@ void snr_calc(
s16MaxCoefNorm = sub( ffr_getSfWord32( snr_tmpidx, (Word16) SNR_sb_num ), 4 );
FOR( i = 0; i < SNR_sb_num; i++ )
{
- tmpspec_amp = L_shl( snr_tmpidx[i], s16MaxCoefNorm );
+ tmpspec_amp = L_shl( snr_tmpidx[i], s16MaxCoefNorm ); /* Q25 + s16MaxCoefNorm */
snr_tmp = L_add( snr_tmp, tmpspec_amp );
}
snr_tmp = L_max( 0, snr_tmp );
- snr_tmp = MUL_F( snr_tmp, BAND_MUL[bwidth - CLDFBVAD_NB_ID] );
- *snr = L_shr( snr_tmp, s16MaxCoefNorm );
+ snr_tmp = MUL_F( snr_tmp, BAND_MUL[bwidth - CLDFBVAD_NB_ID] ); /* Q25 + s16MaxCoefNorm */
+ *snr = L_shr( snr_tmp, s16MaxCoefNorm ); /* Q25 */
move32();
- IF( bwidth == CLDFBVAD_SWB_ID )
+ IF( EQ_32( bwidth, CLDFBVAD_SWB_ID ) )
{
IF( t_bg_energy )
{
minscale = norm_l( t_bg_energy );
minscale2 = sub( s_min( add( minscale, hVAD_CLDFB->scale_t_bg_energy ), 31 ), 1 );
- tmpsb_eg = L_shr( t_bg_energy, sub( hVAD_CLDFB->scale_t_bg_energy, minscale2 ) );
+ tmpsb_eg = L_shr( t_bg_energy, sub( hVAD_CLDFB->scale_t_bg_energy, minscale2 ) ); /* minscale2 */
constff = L_shr( 1, sub( 31, minscale2 ) );
}
ELSE
@@ -304,12 +307,12 @@ void snr_calc(
move16();
}
div2 = L_add( tmpsb_eg, constff );
- tmp = VAD_L_div( frame_energy, div2, sacle_sbpower, minscale2, &q_divout );
+ tmp = VAD_L_div( frame_energy, div2, sacle_sbpower, minscale2, &q_divout ); /* q_divout */
IF( tmp )
{
minscale = norm_l( tmp );
minscale2 = sub( s_min( add( minscale, q_divout ), 31 ), 1 );
- tmpsb_eg = L_shr( tmp, limitScale32( sub( q_divout, minscale2 ) ) );
+ tmpsb_eg = L_shr( tmp, limitScale32( sub( q_divout, minscale2 ) ) ); /* minscale2 */
constff = L_shr( 1, sub( 31, minscale2 ) );
tmp = L_add( tmpsb_eg, constff );
}
@@ -322,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; */
-#else
- *tsnr = L_add( *tsnr, MUL_F( *tsnr, 6226 ) ); /* *tsnr *= 1.2; */
-#endif
+ *tsnr = L_add_sat( *tsnr, MUL_F( *tsnr, 6226 ) ); /* *tsnr *= 1.2; Q25*/
move32();
}
ELSE
@@ -335,7 +334,7 @@ void snr_calc(
{
minscale = norm_l( frame_energy );
minscale1 = sub( s_min( add( minscale, sacle_sbpower ), 44 ), 1 );
- tmpframe_eg = L_shr( frame_energy, sub( sacle_sbpower, minscale1 ) );
+ tmpframe_eg = L_shr( frame_energy, sub( sacle_sbpower, minscale1 ) ); /* minscale1 */
constff = L_shr( CONSTfix, sub( 44, minscale1 ) );
}
ELSE
@@ -352,7 +351,7 @@ void snr_calc(
{
minscale = norm_l( t_bg_energy );
minscale2 = sub( s_min( add( minscale, hVAD_CLDFB->scale_t_bg_energy ), 44 ), 1 );
- tmpsb_eg = L_shr( t_bg_energy, sub( hVAD_CLDFB->scale_t_bg_energy, minscale2 ) );
+ tmpsb_eg = L_shr( t_bg_energy, sub( hVAD_CLDFB->scale_t_bg_energy, minscale2 ) ); /* minscale2 */
constff = L_shr( CONSTfix, sub( 44, minscale2 ) );
}
ELSE
@@ -365,29 +364,29 @@ void snr_calc(
move16();
}
div2 = L_add( tmpsb_eg, constff );
- tmp = VAD_L_div( div1, div2, minscale1, minscale2, &q_divout );
- *tsnr = VAD_Log2( tmp, q_divout );
+ tmp = VAD_L_div( div1, div2, minscale1, minscale2, &q_divout ); /* q_divout */
+ *tsnr = VAD_Log2( tmp, q_divout ); /* Q25 */
move32();
}
return;
}
Word32 construct_snr_thresh_fx(
- Word16 sp_center[], /* i : spectral center*/
- Word32 snr_flux, /* i : snr flux*/
- Word32 lt_snr, /* i : long time time domain snr*/
- Word32 l_snr, /* i : long time frequency domain snr*/
- Word32 continuous_speech_num, /* i : amount of continuous speech frames*/
- Word16 continuous_noise_num, /* i : amount of continuous noise frames*/
- Word32 fg_energy_est_start, /* i : whether if estimated energy*/
- Word16 bw_index /* i : band width index*/
+ Word16 sp_center[], /* i : spectral center Q10*/
+ Word32 snr_flux, /* i : snr flux Q25*/
+ Word32 lt_snr, /* i : long time time domain snr Q25*/
+ Word32 l_snr, /* i : long time frequency domain snr Q25*/
+ Word32 continuous_speech_num, /* i : amount of continuous speech frames Q0*/
+ Word16 continuous_noise_num, /* i : amount of continuous noise frames Q0*/
+ Word32 fg_energy_est_start, /* i : whether if estimated energy Q0*/
+ Word16 bw_index /* i : band width index Q0*/
)
{
Word32 bw_snr, tmp_snr, snr_delta, test_l_snr, tmp, div1, div2;
- snr_delta = COMVAD_INIT_SNR_DELTA_FX[bw_index];
+ snr_delta = COMVAD_INIT_SNR_DELTA_FX[bw_index]; /* Q25 */
move32();
bw_snr = lt_snr;
move32();
@@ -397,126 +396,108 @@ Word32 construct_snr_thresh_fx(
move32();
IF( EQ_16( bw_index, CLDFBVAD_SWB_ID ) )
{
-
- IF( GT_16( sp_center[3], 2864 /* 2.80 Q10 */ ) )
+ IF( GT_16( sp_center[2], 2660 /* 2.6 Q10 */ ) )
{
- snr_delta = snr_delta;
- move32();
- }
- ELSE IF( GT_16( sp_center[2], 2660 /* 2.6 Q10 */ ) )
- {
- snr_delta = L_add( snr_delta, 1006633 /* 0.03 Q25 */ );
+ snr_delta = L_add( snr_delta, 1006633 /* 0.03 Q25 */ ); /* Q25 */
}
ELSE IF( GT_16( sp_center[2], 1637 /* 1.6 Q10 */ ) )
{
- snr_delta = L_add( snr_delta, 1677722 /* 0.05 Q25 */ );
+ snr_delta = L_add( snr_delta, 1677722 /* 0.05 Q25 */ ); /* Q25 */
}
ELSE IF( GT_16( sp_center[3], 1432 /* 1.4 Q10 */ ) )
{
- snr_delta = L_add( snr_delta, 3355443 /* 0.10 Q25 */ );
+ snr_delta = L_add( snr_delta, 3355443 /* 0.10 Q25 */ ); /* Q25 */
}
ELSE
{
- snr_delta = L_add( snr_delta, 13421773 /* 0.40 Q25 */ );
+ snr_delta = L_add( snr_delta, 13421773 /* 0.40 Q25 */ ); /* Q25 */
}
- tmp = MUL_F( l_snr, 3277 /* 0.1 Q15 */ );
+ tmp = MUL_F( l_snr, 3277 /* 0.1 Q15 */ ); /* Q25 */
tmp = L_add( tmp, 20132659 /* 0.6 Q25 */ );
test();
test();
IF( GT_32( continuous_speech_num, 8 ) && EQ_32( fg_energy_est_start, 1 ) )
{
- snr_delta = L_sub( snr_delta, 6710886 /* 0.2 Q25 */ );
+ snr_delta = L_sub( snr_delta, 6710886 /* 0.2 Q25 */ ); /* Q25 */
}
ELSE IF( GT_16( continuous_noise_num, 12 ) && ( GT_32( snr_flux, tmp ) ) )
{
- snr_delta = L_add( snr_delta, 3355443 /* 0.10 Q25 */ );
+ snr_delta = L_add( snr_delta, 3355443 /* 0.10 Q25 */ ); /* Q25 */
}
ELSE IF( GT_16( continuous_noise_num, 24 ) )
{
- snr_delta = L_add( snr_delta, 6710886 /* 0.2 Q25 */ );
+ snr_delta = L_add( snr_delta, 6710886 /* 0.2 Q25 */ ); /* Q25 */
}
ELSE IF( ( GT_16( continuous_noise_num, 4 ) ) )
{
- snr_delta = L_add( snr_delta, 3355443 /* 0.10 Q25 */ );
+ snr_delta = L_add( snr_delta, 3355443 /* 0.10 Q25 */ ); /* Q25 */
}
}
ELSE IF( EQ_16( bw_index, CLDFBVAD_WB_ID ) )
{
-
- IF( GT_16( sp_center[3], 2864 /* 2.80 Q10 */ ) )
+ IF( GT_16( sp_center[2], 2660 /* 2.6 Q10 */ ) )
{
- snr_delta = snr_delta;
- move32();
- }
- ELSE IF( GT_16( sp_center[2], 2660 /* 2.6 Q10 */ ) )
- {
- snr_delta = L_add( snr_delta, 1006633 /* 0.03 Q25 */ );
+ snr_delta = L_add( snr_delta, 1006633 /* 0.03 Q25 */ ); /* Q25 */
}
ELSE IF( GT_16( sp_center[2], 1637 /* 1.6 Q10 */ ) )
{
- snr_delta = L_add( snr_delta, 1677722 /* 0.05 Q25 */ );
+ snr_delta = L_add( snr_delta, 1677722 /* 0.05 Q25 */ ); /* Q25 */
}
ELSE IF( GT_16( sp_center[3], 1432 /* 1.4 Q10 */ ) )
{
- snr_delta = L_add( snr_delta, 3355443 /* 0.10 Q25 */ );
+ snr_delta = L_add( snr_delta, 3355443 /* 0.10 Q25 */ ); /* Q25 */
}
ELSE
{
- snr_delta = L_add( snr_delta, 10066330 /* 0.30 Q25 */ );
+ snr_delta = L_add( snr_delta, 10066330 /* 0.30 Q25 */ ); /* Q25 */
}
- tmp = MUL_F( bw_snr, 3277 /* 0.1 Q15 */ );
- tmp = L_add( tmp, 20132659 /* 0.6 Q25 */ );
+ tmp = MUL_F( bw_snr, 3277 /* 0.1 Q15 */ ); /* Q25 */
+ tmp = L_add( tmp, 20132659 /* 0.6 Q25 */ ); /* Q25 */
test();
test();
IF( GT_32( continuous_speech_num, 8 ) && EQ_32( fg_energy_est_start, 1 ) )
{
- snr_delta = L_sub( snr_delta, 3355443 /* 0.10 Q25 */ );
+ snr_delta = L_sub( snr_delta, 3355443 /* 0.10 Q25 */ ); /* Q25 */
}
ELSE IF( GT_16( continuous_noise_num, 12 ) && ( GT_32( snr_flux, tmp ) ) )
{
- snr_delta = L_add( snr_delta, 3355443 /* 0.10 Q25 */ );
+ snr_delta = L_add( snr_delta, 3355443 /* 0.10 Q25 */ ); /* Q25 */
}
ELSE IF( GT_16( continuous_noise_num, 24 ) )
{
- snr_delta = L_add( snr_delta, 6710886 /* 0.20 Q25 */ );
+ snr_delta = L_add( snr_delta, 6710886 /* 0.20 Q25 */ ); /* Q25 */
}
ELSE IF( ( GT_16( continuous_noise_num, 4 ) ) )
{
- snr_delta = L_add( snr_delta, 3355443 /* 0.10 Q25 */ );
+ snr_delta = L_add( snr_delta, 3355443 /* 0.10 Q25 */ ); /* Q25 */
}
}
ELSE IF( EQ_16( bw_index, CLDFBVAD_NB_ID ) )
{
-
- IF( GT_16( sp_center[3], 3069 /* 3.0 Q10 */ ) )
- {
- snr_delta = snr_delta;
- move32();
- }
- ELSE IF( GT_16( sp_center[2], 2660 /* 2.6 Q10 */ ) )
+ IF( GT_16( sp_center[2], 2660 /* 2.6 Q10 */ ) )
{
- snr_delta = L_add( snr_delta, 671089 /* 0.02 Q25 */ );
+ snr_delta = L_add( snr_delta, 671089 /* 0.02 Q25 */ ); /* Q25 */
}
ELSE IF( GT_16( sp_center[2], 1637 /* 1.6 Q10 */ ) )
{
- snr_delta = L_add( snr_delta, 1342177 /* 0.04 Q25 */ );
+ snr_delta = L_add( snr_delta, 1342177 /* 0.04 Q25 */ ); /* Q25 */
}
ELSE IF( GT_16( sp_center[2], 1494 /* 1.46 Q10 */ ) )
{
- snr_delta = L_add( snr_delta, 3355443 /* 0.10 Q25 */ );
+ snr_delta = L_add( snr_delta, 3355443 /* 0.10 Q25 */ ); /* Q25 */
}
ELSE
{
- snr_delta = L_add( snr_delta, 6039798 /* 0.18 Q25 */ );
+ snr_delta = L_add( snr_delta, 6039798 /* 0.18 Q25 */ ); /* Q25 */
}
- tmp = MUL_F( l_snr, 3277 /* 0.1 Q15 */ );
- div1 = L_add( tmp, 6710886 /* 0.2 Q25 */ );
- div2 = L_add( tmp, 20132659 /* 0.6 Q25 */ );
+ tmp = MUL_F( l_snr, 3277 /* 0.1 Q15 */ ); /* Q25 */
+ div1 = L_add( tmp, 6710886 /* 0.2 Q25 */ ); /* Q25 */
+ div2 = L_add( tmp, 20132659 /* 0.6 Q25 */ ); /* Q25 */
test();
test();
@@ -525,19 +506,19 @@ Word32 construct_snr_thresh_fx(
test();
IF( GT_32( continuous_speech_num, 80 ) && EQ_32( fg_energy_est_start, 1 ) && ( GT_16( sp_center[0], 1432 /* 1.4 Q10 */ ) ) )
{
- snr_delta = L_sub( snr_delta, 10737418 /* 0.32 Q25 */ );
+ snr_delta = L_sub( snr_delta, 10737418 /* 0.32 Q25 */ ); /* Q25 */
}
ELSE IF( GT_32( continuous_speech_num, 8 ) && EQ_32( fg_energy_est_start, 1 ) && ( GT_32( snr_flux, div1 ) ) )
{
- snr_delta = L_sub( snr_delta, 3355443 /* 0.10 Q25 */ );
+ snr_delta = L_sub( snr_delta, 3355443 /* 0.10 Q25 */ ); /* Q25 */
}
ELSE IF( GT_16( continuous_noise_num, 12 ) && ( GT_32( snr_flux, div2 ) ) )
{
- snr_delta = L_add( snr_delta, 3355443 /* 0.10 Q25 */ );
+ snr_delta = L_add( snr_delta, 3355443 /* 0.10 Q25 */ ); /* Q25 */
}
ELSE IF( GT_16( continuous_noise_num, 24 ) )
{
- snr_delta = L_add( snr_delta, 6710886 /* 0.2 Q25 */ );
+ snr_delta = L_add( snr_delta, 6710886 /* 0.2 Q25 */ ); /* Q25 */
}
}
ELSE
@@ -545,7 +526,7 @@ Word32 construct_snr_thresh_fx(
snr_delta = 33554431 /* 1.0 Q25 */;
move32();
}
- tmp_snr = L_add( snr_delta, test_l_snr );
+ tmp_snr = L_add( snr_delta, test_l_snr ); /* Q25 */
return tmp_snr;
diff --git a/lib_enc/acelp_core_enc.c b/lib_enc/acelp_core_enc.c
deleted file mode 100644
index d3d542f321dd3fc4ec9043fc0aead352da399fab..0000000000000000000000000000000000000000
--- a/lib_enc/acelp_core_enc.c
+++ /dev/null
@@ -1,968 +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_enc.h"
-#include "rom_com.h"
-#include "prot.h"
-#include "ivas_cnst.h"
-#include "ivas_prot.h"
-#include "ivas_prot_fx.h"
-#include "prot_fx.h"
-#include "prot_fx_enc.h"
-#include "ivas_rom_com.h"
-#include "wmc_auto.h"
-#include "options_warnings.h"
-
-#include "prot_fx_enc.h"
-#include "prot_fx.h"
-
-/*-------------------------------------------------------------------*
- * acelp_core_enc()
- *
- * ACELP core encoder
- *--------------------------------------------------------------------*/
-ivas_error acelp_core_enc(
- Encoder_State *st, /* i/o: encoder state structure */
- const Word16 inp[], /* i : input signal of the current frame */
- Word16 A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes*/
- Word16 Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes*/
- const Word32 epsP[M + 1], /* i : LP prediction errors */
- Word16 lsp_new[M], /* i : LSPs at the end of the frame */
- Word16 lsp_mid[M], /* i : LSPs in the middle of the frame */
- const Word16 vad_hover_flag, /* i : VAD hangover flag */
- const Word16 attack_flag, /* i : attack flag (GSC or TC) */
- Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation */
- Word16 *voice_factors_fx, /* o : voicing factors Q15 */
- Word16 old_syn_12k8_16k[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE */
- Word16 *q_old_syn_12k8_16,
- Word16 pitch_buf[NB_SUBFR16k], /* o : floating pitch for each subframe */
- Word16 *unbits, /* o : number of unused bits */
- STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder handle */
- Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */
- Word16 Q_new )
-{
- Word16 i, nBits; /* reserved bits */
- LPD_state_HANDLE hLPDmem; /* i/o: acelp memories */
- Word16 tc_subfr; /* TC sub-frame indication */
- Word16 allow_cn_step;
- Word32 int_fs;
- Word16 nb_bits; /* parameters handling */
-
- /* SC-VBR - back-up memories for LSF quantizer and synthesis filter */
- Word16 pstreaklen;
- Word16 sid_bw = -1;
- Word16 next_force_sf_bck;
- Word16 uc_two_stage_flag;
- Word16 position;
- Word16 ppp_mode, nelp_mode;
- Word16 tdm_lp_reuse_flag, tdm_low_rate_mode, tdm_Pitch_reuse_flag;
-
- /* bitstream */
- BSTR_ENC_HANDLE hBstr = st->hBstr;
- Word16 old_exc_fx[L_EXC], *exc_fx; /* excitation signal buffer */
- Word16 lsf_new_fx[M]; /* ISFs at the end of the frame */
- Word16 Aq[NB_SUBFR16k * ( M + 1 )]; /* A(z) quantized for the 4 subframes */
- Word16 syn_fx[L_FRAME16k]; /* synthesis vector */
- Word16 res_fx[L_FRAME16k]; /* Residual signal for FER protection */
- Word16 exc2_fx[L_FRAME16k]; /* enhanced excitation */
- Word16 Es_pred_fx; /* predicited scaled innovation energy */
- Word16 tmp_noise_fx; /* NB post-filter long-term noise energy*/
- Word16 old_bwe_exc_fx[( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2]; /* excitation buffer Q_new */
- Word16 *bwe_exc_fx; /* excitation for SWB TBE Q_new */
- Word16 mem_MA_fx[M], mem_AR_fx[M], lsp_new_bck_fx[M], /*lsf_new_bck_fx[M],*/ lsp_mid_bck_fx[M], mem_syn_bck_fx[M];
- Word32 Bin_E_fx[L_FFT], Bin_E_old_fx[L_FFT / 2];
- Word16 clip_var_fx, mem_w0_bck_fx, streaklimit_fx;
-
-#ifdef MSAN_FIX
- set16_fx( old_bwe_exc_fx, 0, ( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2 );
- set16_fx( old_exc_fx, 0, L_EXC );
- set16_fx( Aq, 0, NB_SUBFR16k * ( M + 1 ) );
- set16_fx( syn_fx, 0, L_FRAME16k );
-#endif
-
- Word16 tilt_code_bck_fx;
- Word32 gc_threshold_bck_fx;
- Word16 clip_var_bck_fx[6];
- Word32 q_env_fx[NUM_ENV_CNG];
-#ifdef MSAN_FIX
- set32_fx( q_env_fx, 0, NUM_ENV_CNG );
-#endif
- Word16 exc3_fx[L_FRAME16k];
- Word16 syn1_fx[L_FRAME16k];
- Word16 *tdm_Pri_pitch_buf_fx;
-
- Word16 att_fx;
- Word16 tmpF_fx;
-
- test();
- IF( !st->Opt_AMR_WB && st->hBWE_TD != NULL )
- {
- Scale_sig( st->hBWE_TD->old_bwe_exc_fx, PIT16k_MAX * 2, sub( Q_new, st->prev_Q_new ) ); // Q_new
- }
- IF( st->hLPDmem )
- {
- Scale_sig( st->hLPDmem->old_exc, L_EXC_MEM, sub( Q_new, st->hLPDmem->q_lpd_old_exc ) ); // Q_new
- st->hLPDmem->q_lpd_old_exc = Q_new;
- move16();
- Scale_sig( st->hLPDmem->syn, M + 1, sub( Q_new, st->hLPDmem->q_lpd_syn ) ); // Q_new
- st->hLPDmem->q_lpd_syn = Q_new;
- move16();
- Scale_sig( st->hLPDmem->mem_syn, M, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); // Q_new -1
- Scale_sig( st->hLPDmem->mem_syn1_fx, M, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); // Q_new -1
- Scale_sig( st->hLPDmem->mem_syn2, M, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); // Q_new -1
- Scale_sig( st->hLPDmem->mem_syn3, M, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); // Q_new -1
- Scale_sig( st->hLPDmem->mem_syn_r, L_SYN_MEM, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); // Q_new -1
- st->hLPDmem->mem_w0 = shl_sat( st->hLPDmem->mem_w0, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); // Q_new -1
- move16();
- st->hLPDmem->q_mem_syn = sub( Q_new, 1 );
- move16();
- }
-
- Scale_sig32( st->Bin_E_old_fx, L_FFT / 2, sub( add( Q_new, Q_SCALE - 2 ), st->q_Bin_E_old ) ); // Q_new + Q_scale - 2
- st->q_Bin_E_old = add( Q_new, Q_SCALE - 2 );
- move16();
- Scale_sig32( st->Bin_E_fx, L_FFT, sub( add( Q_new, Q_SCALE - 2 ), st->q_Bin_E ) ); // Q_new + Q_scale - 2
- st->q_Bin_E = add( Q_new, Q_SCALE - 2 );
- move16();
-
- ivas_error error;
-
- error = IVAS_ERR_OK;
- move32();
-
- test();
- IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && LE_32( st->core_brate, SID_2k40 ) )
- {
- /* Core was ACELP because of DTX in MDCT-Stereo, but SID encoding for that is done in separate function */
- return error;
- }
-
- push_wmops( "acelp_core_enc" );
- /*------------------------------------------------------------------*
- * Initialization
- *------------------------------------------------------------------*/
-
- hLPDmem = st->hLPDmem;
-
- Es_pred_fx = 0;
- move16();
-
- exc_fx = old_exc_fx + L_EXC_MEM; /* pointer to excitation signal in the current frame */
- Copy( hLPDmem->old_exc, old_exc_fx, L_EXC_MEM );
- Scale_sig( old_exc_fx, L_EXC_MEM, sub( Q_new, hLPDmem->q_lpd_old_exc ) ); // Q_new
- IF( st->hBWE_TD != NULL )
- {
- bwe_exc_fx = old_bwe_exc_fx + PIT16k_MAX * 2; /* pointer to BWE excitation signal in the current frame */
- Copy( st->hBWE_TD->old_bwe_exc_fx, old_bwe_exc_fx, PIT16k_MAX * 2 );
- }
- ELSE
- {
- bwe_exc_fx = NULL;
- }
-
- st->bpf_off = 0;
- move16();
-
- test();
- test();
- test();
- IF( EQ_16( st->last_core, HQ_CORE ) || EQ_16( st->last_codec_mode, MODE2 ) || EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) )
- {
- /* in case of HQ->ACELP switching, do not apply BPF */
- st->bpf_off = 1;
- move16();
- /* reset the GSC pre echo energy threshold in case of switching */
- if ( st->hGSCEnc != NULL )
- {
- st->hGSCEnc->Last_frame_ener_fx = MAX_32;
- move32();
- }
- }
-
- /* force safety-net LSFQ in the first frames after CNG segment */
- if ( LE_32( st->last_core_brate, SID_2k40 ) )
- {
- st->Nb_ACELP_frames = 0;
- move16();
- }
- st->Nb_ACELP_frames = add( st->Nb_ACELP_frames, 1 );
- move16();
-
- IF( EQ_16( st->L_frame, L_FRAME ) )
- {
- int_fs = INT_FS_12k8;
- move32();
- }
- ELSE
- {
- int_fs = INT_FS_16k;
- move32();
- }
-
- tmp_noise_fx = 0;
- move16();
- tc_subfr = -1;
- move16();
- position = -1;
- move16();
-
- /* SC-VBR temporary variables */
- pstreaklen = 0;
- move16();
- clip_var_fx = 0;
- move16();
- mem_w0_bck_fx = 0;
- move16();
- streaklimit_fx = 0;
- move16();
-
- /* channel-aware mode */
- reset_rf_indices_fx( st );
-
- /* VBR modes */
- IF( st->Opt_SC_VBR )
- {
- ppp_mode = st->hSC_VBR->ppp_mode;
- nelp_mode = st->hSC_VBR->nelp_mode;
- }
- ELSE
- {
- ppp_mode = 0;
- nelp_mode = 0;
- }
- move16();
- move16();
-
- test();
- /* TD stereo */
-
- IF( EQ_16( st->element_mode, IVAS_CPE_TD ) && EQ_16( st->idchan, 1 ) )
- {
- tdm_lp_reuse_flag = hStereoTD->tdm_lp_reuse_flag;
- tdm_low_rate_mode = hStereoTD->tdm_low_rate_mode;
- tdm_Pitch_reuse_flag = hStereoTD->tdm_Pitch_reuse_flag;
- tdm_Pri_pitch_buf_fx = hStereoTD->tdm_Pri_pitch_buf_fx;
- }
- ELSE
- {
- tdm_lp_reuse_flag = 0;
- tdm_low_rate_mode = 0;
- test();
- if ( EQ_16( st->element_mode, IVAS_SCE ) && st->low_rate_mode )
- {
- tdm_low_rate_mode = 1;
- move16();
- }
- tdm_Pitch_reuse_flag = 0;
- tdm_Pri_pitch_buf_fx = NULL;
- }
- move16();
- move16();
- move16();
-
- /*-----------------------------------------------------------------*
- * ACELP@12k8 / ACELP@16k switching
- *-----------------------------------------------------------------*/
-
- test();
- test();
- IF( NE_16( st->last_L_frame, st->L_frame ) && ( st->last_core == ACELP_CORE || EQ_16( st->last_core, AMR_WB_CORE ) ) )
- {
- /* in case of switching, do not apply BPF (flag employed also in updt_enc()) */
- st->bpf_off = 1;
- move16();
-
- /* force safety-net LSFQ in the first frames after ACELP@12k8/ACELP@16k switching */
- st->Nb_ACELP_frames = 1;
- move16();
-
- /* convert old quantized LSP vector */
- IF( EQ_16( st->L_frame, L_FRAME ) )
- {
- st->rate_switching_reset = lsp_convert_poly_fx( st->lsp_old_fx, st->L_frame, 0 );
- move16();
- }
- ELSE
- {
- st->rate_switching_reset = st->rate_switching_reset_16kHz;
- move16();
- Copy( st->lsp_old16k_fx, st->lsp_old_fx, M ); // Q15
- }
-
- /* convert old quantized LSF vector */
- lsp2lsf_fx( st->lsp_old_fx, st->lsf_old_fx, M, int_fs );
-
- /* interpolation of unquantized ISPs */
- IF( st->rate_switching_reset )
- {
- /*extrapolation in case of unstable LSP*/
- int_lsp4_ivas_fx( st->L_frame, lsp_mid, lsp_mid, lsp_new, A, M, 0 );
- }
- ELSE
- {
- int_lsp4_ivas_fx( st->L_frame, st->lsp_old_fx, lsp_mid, lsp_new, A, M, 0 );
- }
-
- /* Reset LPC mem */
- Copy( GEWB_Ave_fx, st->mem_AR_fx, M );
- set16_fx( st->mem_MA_fx, 0, M );
-
- /* update synthesis filter memories */
- synth_mem_updt2( st->L_frame, st->last_L_frame, hLPDmem->old_exc, hLPDmem->mem_syn_r, hLPDmem->mem_syn2, hLPDmem->mem_syn, ENC );
- Copy( hLPDmem->old_exc, old_exc_fx, L_EXC_MEM );
- Copy( hLPDmem->mem_syn2, hLPDmem->mem_syn1_fx, M );
- Copy( hLPDmem->mem_syn2, hLPDmem->mem_syn3, M );
-
- /* 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();
- if ( st->last_bwidth == NB && st->bwidth != NB && st->ini_frame != 0 )
- {
- st->rate_switching_reset = 1;
- move16();
- }
-
- /*----------------------------------------------------------------*
- * Encoding of CNG frames
- *----------------------------------------------------------------*/
- test();
- IF( EQ_32( st->core_brate, SID_2k40 ) || EQ_32( st->core_brate, FRAME_NO_DATA ) )
- {
- IF( EQ_16( st->cng_type, LP_CNG ) )
- {
- /* Run CNG post parameter update */
- cng_params_postupd_ivas_fx( st->hTdCngEnc->ho_circ_ptr, &st->hTdCngEnc->cng_buf_cnt, st->hTdCngEnc->cng_exc2_buf, st->hTdCngEnc->cng_Qexc_buf, st->hTdCngEnc->cng_brate_buf, st->hTdCngEnc->ho_env_circ_fx, st->element_mode, st->hFdCngEnc->hFdCngCom->CngBandwidth );
-
- /* encode CNG parameters */
- CNG_enc_ivas_fx( st, Aq, inp, /*ener_fx,*/ lsp_mid, lsp_new, lsf_new_fx, &allow_cn_step, sub( Q_new, 1 ), q_env_fx, &sid_bw );
-
- /* comfort noise generation */
- CNG_exc_fx( st->core_brate, st->L_frame, &st->hTdCngEnc->Enew_fx, &st->hTdCngEnc->cng_seed, exc_fx, exc2_fx, &st->hTdCngEnc->lp_ener_fx, st->last_core_brate,
- &st->hDtxEnc->first_CNG, &st->hTdCngEnc->cng_ener_seed, bwe_exc_fx, allow_cn_step, &st->hTdCngEnc->last_allow_cn_step, sub( st->prev_Q_new, 1 ), sub( Q_new, 1 ), st->hTdCngEnc->num_ho,
- q_env_fx, st->hTdCngEnc->lp_env_fx, st->hTdCngEnc->old_env_fx, st->hTdCngEnc->exc_mem_fx, st->hTdCngEnc->exc_mem1_fx, &sid_bw, &st->hTdCngEnc->cng_ener_seed1, exc3_fx, st->Opt_AMR_WB, EVS_MONO );
-
- Scale_sig( exc_fx, st->L_frame, 1 );
- }
- ELSE
- {
- test();
- IF( EQ_32( st->core_brate, SID_2k40 ) && NE_16( st->element_mode, IVAS_CPE_MDCT ) )
- {
- FdCng_encodeSID_ivas_fx( st );
- st->hDtxEnc->last_CNG_L_frame = st->L_frame;
- move16();
- }
-
- Word16 Q_cngNoise = Q31, zero_flag = 0;
- move16();
- move16();
- FOR( Word16 j = 0; j < NPART; j++ )
- {
- IF( st->hFdCngEnc->hFdCngCom->cngNoiseLevel[j] != 0 )
- {
- zero_flag = 1;
- move16();
- BREAK;
- }
- }
- IF( zero_flag )
- {
- Q_cngNoise = getScaleFactor32( st->hFdCngEnc->hFdCngCom->cngNoiseLevel, NPART );
- }
- Scale_sig32( st->hFdCngEnc->hFdCngCom->cngNoiseLevel, NPART, Q_cngNoise );
- st->hFdCngEnc->hFdCngCom->cngNoiseLevelExp = sub( st->hFdCngEnc->hFdCngCom->cngNoiseLevelExp, Q_cngNoise );
- move16();
-
- generate_comfort_noise_enc_ivas_fx( st, Q_new, 1 );
- st->hTcxEnc->q_Txnq = Q_new;
- move16();
- Scale_sig( st->hFdCngEnc->hFdCngCom->A_cng, ( M + 1 ), sub( Q12, sub( 14, norm_s( st->hFdCngEnc->hFdCngCom->A_cng[0] ) ) ) );
- FdCng_exc( st->hFdCngEnc->hFdCngCom, &st->hDtxEnc->CNG_mode, st->L_frame, st->lsp_old_fx, st->hDtxEnc->first_CNG, st->hDtxEnc->lspCNG_fx, Aq, lsp_new, lsf_new_fx, exc_fx, exc2_fx, bwe_exc_fx );
- Copy( exc2_fx, exc3_fx, st->L_frame );
-
- IF( EQ_32( st->core_brate, SID_2k40 ) )
- {
- IF( st->hTdCngEnc != NULL )
- {
- Word16 enr, enr_index;
- enr = cng_energy_ivas_fx( st->element_mode, st->bwidth, st->hDtxEnc->CNG_mode, st->hTdCngEnc->CNG_att_fx, exc_fx, st->L_frame, Q_new );
-
- /* calculate the energy quantization index */
- enr_index = add( enr, 512 /* Q8(2.0) */ ); /* enr + 2.0 */
- enr_index = extract_l( L_shr( L_mult0( enr_index, STEP_SID_FX ), 12 + 8 ) ); /* Q0 (8+12-(8+12)) */
-
- /* limit the energy quantization index */
- enr_index = s_min( enr_index, 127 );
- enr_index = s_max( enr_index, 0 );
- st->hTdCngEnc->old_enr_index = enr_index;
- move16();
- }
- }
- }
-
- /* Reset HO counter in the first SID frame */
- if ( st->hTdCngEnc != NULL )
- {
- st->hTdCngEnc->burst_ho_cnt = 0;
- move16();
- }
-
- Scale_sig( st->hLPDmem->mem_syn, M, sub( st->Q_syn, st->hLPDmem->q_mem_syn ) ); // st->Q_syn
- Scale_sig( st->hLPDmem->mem_syn1_fx, M, sub( st->Q_syn, st->hLPDmem->q_mem_syn ) ); // st->Q_syn
- Scale_sig( st->hLPDmem->mem_syn2, M, sub( st->Q_syn, st->hLPDmem->q_mem_syn ) ); // st->Q_syn
- Scale_sig( st->hLPDmem->mem_syn3, M, sub( st->Q_syn, st->hLPDmem->q_mem_syn ) ); // st->Q_syn
- Scale_sig( st->hLPDmem->mem_syn_r, L_SYN_MEM, sub( st->Q_syn, st->hLPDmem->q_mem_syn ) ); // st->Q_syn
- st->hLPDmem->mem_w0 = shl_sat( st->hLPDmem->mem_w0, sub( st->Q_syn, st->hLPDmem->q_mem_syn ) ); // st->Q_syn
- move16();
- st->hLPDmem->q_mem_syn = st->Q_syn;
- move16();
-
- /* synthesis at 12.8kHz sampling rate */
- syn_12k8_fx( st->L_frame, Aq, exc3_fx, syn1_fx, hLPDmem->mem_syn3, 1, sub( Q_new, 1 ), st->Q_syn );
-
- /* reset the encoder */
- CNG_reset_enc_fx( st, hLPDmem, pitch_buf, voice_factors_fx, 0 );
-
- /* update st->mem_syn1_flt for ACELP core switching */
- Copy( hLPDmem->mem_syn3, hLPDmem->mem_syn1_fx, M );
-
- /* update ACELP core synthesis filter memory */
- Copy( hLPDmem->mem_syn3, hLPDmem->mem_syn, M );
-
- /* update old synthesis buffer - needed for ACELP internal sampling rate switching */
- Copy( syn1_fx + sub( st->L_frame, L_SYN_MEM ), hLPDmem->mem_syn_r, L_SYN_MEM );
-
- /* save and delay synthesis to be used by SWB BWE */
- IF( st->hBWE_FD != NULL )
- {
- st->hBWE_FD->mem_deemph_old_syn_fx = shl_sat( st->hBWE_FD->mem_deemph_old_syn_fx, sub( st->Q_syn, st->hBWE_FD->q_mem_deemph_old_syn ) );
- move16();
- Scale_sig( st->hBWE_FD->old_syn_12k8_16k_fx, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ), sub( st->Q_syn, st->hBWE_FD->q_mem_deemph_old_syn ) );
- save_old_syn_fx( st->L_frame, syn1_fx, old_syn_12k8_16k, st->hBWE_FD->old_syn_12k8_16k_fx, st->preemph_fac, &st->hBWE_FD->mem_deemph_old_syn_fx );
- *q_old_syn_12k8_16 = st->Q_syn;
- move16();
- st->hBWE_FD->q_mem_deemph_old_syn = st->Q_syn;
- move16();
- }
-
- Scale_sig( st->hLPDmem->syn, M + 1, sub( st->Q_syn, st->hLPDmem->q_lpd_syn ) );
- st->hLPDmem->q_lpd_syn = st->Q_syn;
- move16();
-
- /*Update MODE2 core switching memory*/
- deemph_fx( syn1_fx, st->preemph_fac, st->L_frame, &( hLPDmem->syn[M] ) );
- Copy( syn1_fx + add( st->L_frame, -M - 1 ), hLPDmem->syn, M + 1 );
- }
-
- /*----------------------------------------------------------------*
- * Encoding of all other frames
- *----------------------------------------------------------------*/
- ELSE
- {
-
- /*-----------------------------------------------------------------*
- * Configure ACELP bit allocation
- *-----------------------------------------------------------------*/
-
- Word16 temp = getScaleFactor16( st->hGSCEnc->last_exc_dct_in_fx, L_FRAME16k );
- Scale_sig( st->hGSCEnc->last_exc_dct_in_fx, L_FRAME16k, temp );
- st->hGSCEnc->Q_last_exc_dct_in = add( st->hGSCEnc->Q_last_exc_dct_in, temp );
- move16();
- nb_bits = 0;
- move16();
- st->acelp_cfg.FEC_mode = 0;
- move16();
- uc_two_stage_flag = 0;
- move16();
-
- test();
- IF( !nelp_mode && !ppp_mode )
- {
- 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 );
- }
-
- /*-----------------------------------------------------------------*
- * After inactive period, use the most up-to-date ISPs
- *-----------------------------------------------------------------*/
-
- test();
- test();
- IF( st->hDtxEnc != NULL && ( st->last_core_brate == FRAME_NO_DATA || EQ_32( st->last_core_brate, SID_2k40 ) ) )
- {
- Copy( st->hDtxEnc->lspCNG_fx, st->lsp_old_fx, M ); // Q15
- lsp2lsf_fx( st->hDtxEnc->lspCNG_fx, st->lsf_old_fx, M, int_fs );
- }
-
- /*-----------------------------------------------------------------*
- * Reset higher ACELP pre-quantizer in case of switching
- *-----------------------------------------------------------------*/
-
- IF( !st->use_acelp_preq )
- {
- st->mem_deemp_preQ_fx = 0;
- move16();
- st->last_code_preq = 0;
- move16();
- st->last_nq_preQ = 0;
- move16();
- }
- st->use_acelp_preq = 0;
- move16();
-
- /*-----------------------------------------------------------------*
- * LSF Quantization
- * A[z] calculation
- *-----------------------------------------------------------------*/
-
- /* SC-VBR & channel-aware mode - back-up memories for LSF quantizer and synthesis filter */
- lsf_syn_mem_backup_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 );
-
- IF( !tdm_lp_reuse_flag )
- {
- lsf_enc_ivas_fx( st, lsf_new_fx, lsp_new, lsp_mid, Aq, tdm_low_rate_mode, st->GSC_IVAS_mode, tdm_lsfQ_PCh, Q_new );
- }
- ELSE
- {
- const Word16 *pt_interp_2_fx;
-
- IF( NE_16( st->active_cnt, 1 ) )
- {
- Word16 beta_index;
- Word16 lsf_wgts_fx[M];
-
- /* intra_frame prediction for the LSFs */
- lsp2lsf_fx( lsp_new, lsf_new_fx, M, 12800 );
-
- Unified_weighting_fx( &st->Bin_E_fx[L_FFT / 2], add( Q_new, ( QSCALE - 2 ) ), lsf_new_fx, lsf_wgts_fx, st->bwidth == NB, (Word16) EQ_16( st->coder_type, UNVOICED ), st->sr_core, M );
-
- tdm_SCh_lsf_reuse_fx( ENC, st->element_brate, lsf_new_fx, lsp_new, tdm_lsfQ_PCh, lsf_wgts_fx, &beta_index );
-
- push_indice( hBstr, IND_IC_LSF_PRED, beta_index, TDM_IC_LSF_PRED_BITS );
- }
-
- pt_interp_2_fx = interpol_frac_12k8_fx;
-
- test();
- if ( EQ_16( tdm_low_rate_mode, 1 ) && GT_16( st->coder_type, UNVOICED ) )
- {
- pt_interp_2_fx = interpol_frac2_fx;
- }
-
- IF( EQ_16( st->active_cnt, 1 ) )
- {
- Copy( lsp_new, st->lsp_old_fx, M ); // Q15
- lsp2lsf_fx( lsp_new, st->lsf_old_fx, M, st->sr_core ); // Q x2.56
- lsp2lsf_fx( lsp_new, lsf_new_fx, M, st->sr_core ); // Q x2.56
- }
-
- /* LSP interpolation and conversion of LSPs to A(z) */
- int_lsp_fx( st->L_frame, st->lsp_old_fx, lsp_new, Aq, M, pt_interp_2_fx, 0 );
-
- /* Check LSF stability (distance between old LSFs and current LSFs) */
- st->stab_fac_fx = lsf_stab_fx( lsf_new_fx, st->lsf_old_fx, 0, st->L_frame ); // Q15
- }
- test();
- IF( EQ_16( st->last_core, HQ_CORE ) && st->element_mode > EVS_MONO )
- {
- /* Prepare ACB memory from last HQ frame */
- tmpF_fx = hLPDmem->old_exc[0];
- 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 );
- Residu3_fx( Aq, hLPDmem->old_exc, old_exc_fx, st->L_frame, 0 );
- }
-
- test();
- IF( st->last_core != ACELP_CORE && st->element_mode > EVS_MONO )
- {
- /* Prepare ACB memory of old_bwe_exc */
- IF( EQ_16( st->L_frame, L_FRAME ) )
- {
- lerp( old_exc_fx, old_bwe_exc_fx, L_EXC_MEM_DEC * HIBND_ACB_L_FAC, L_EXC_MEM_DEC );
- }
- ELSE
- {
- lerp( old_exc_fx, old_bwe_exc_fx, L_EXC_MEM_DEC * 2, L_EXC_MEM_DEC );
- }
- }
-
- /*---------------------------------------------------------------*
- * Calculation of LP residual (filtering through A[z] filter)
- *---------------------------------------------------------------*/
-
- calc_residu_fx( st, inp, res_fx, Aq );
- calculate_hangover_attenuation_gain_ivas_fx( st, &att_fx, vad_hover_flag );
-
- IF( NE_16( att_fx, 32767 /* ONE_IN_Q15 */ ) )
- {
- v_multc_fixed_16_16( res_fx, att_fx, res_fx, st->L_frame );
- }
-
- /*-----------------------------------------------------------------*
- * Determine TC subframe classification
- *-----------------------------------------------------------------*/
-
- IF( EQ_16( st->coder_type, TRANSITION ) )
- {
- tc_classif_enc_fx( Q_new, st->L_frame, &tc_subfr, &position, attack_flag, st->pitch[0], res_fx );
-
- 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 );
- }
-
- /*---------------------------------------------------------------*
- * Calculation of prediction for scaled innovation energy
- * (for memory-less gain quantizer)
- *---------------------------------------------------------------*/
-
- IF( nb_bits > 0 )
- {
- Es_pred_enc_fx( &Es_pred_fx, &i, st->L_frame, res_fx, st->voicing_fx, nb_bits, uc_two_stage_flag, Q_new );
- push_indice( hBstr, IND_ES_PRED, i, nb_bits );
- }
-
- /*------------------------------------------------------------*
- * Encode excitation according to coding type
- *------------------------------------------------------------*/
- test();
- test();
- IF( tdm_low_rate_mode ) /* tdm stereo low rate mode */
- {
- IF( LE_16( st->coder_type, UNVOICED ) )
- {
- tdm_low_rate_enc( st, Aq, res_fx, syn_fx, exc_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, 0 /*attack_flag*/, lsf_new_fx, &tmp_noise_fx, Q_new );
- }
- ELSE /* GENERIC */
- {
- encod_gen_2sbfr( st, inp, Aw, Aq, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, Q_new, 0 );
- }
- }
- ELSE IF( nelp_mode )
- {
- /* SC-VBR - NELP frames */
- encod_nelp_ivas_fx( st, inp, Aw, Aq, res_fx, syn_fx, &tmp_noise_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, Q_new, 0 );
- }
-
- ELSE IF( EQ_16( st->coder_type, UNVOICED ) )
- {
- /* UNVOICED frames (Gauss. excitation) */
- encod_unvoiced_ivas_fx( st, inp, Aw, Aq, Es_pred_fx, uc_two_stage_flag, res_fx, syn_fx, &tmp_noise_fx, exc_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, Q_new, 0 );
- }
- ELSE IF( EQ_16( st->coder_type, TRANSITION ) )
- {
- encod_tran_ivas_fx( st, inp, Aw, Aq, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, tc_subfr, position, unbits, 0, Q_new );
- }
- ELSE IF( ppp_mode )
- {
- /* SC-VBR - PPP frames */
- IF( ( error = encod_ppp_ivas_fx( st, inp, Aw, Aq, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, Q_new, 0 ) ) != IVAS_ERR_OK )
- {
- return error;
- }
-
- IF( st->hSC_VBR->bump_up ) /* PPP failed, bump up */
- {
- /* 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 */
- 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 );
-
- /* redo LSF quantization */
- lsf_enc_ivas_fx( st, lsf_new_fx, lsp_new, lsp_mid, Aq, tdm_low_rate_mode, 0, NULL, Q_new );
-
- /* recalculation of LP residual (filtering through A[z] filter) */
- calc_residu_fx( st, inp, res_fx, Aq );
- st->hTdCngEnc->burst_ho_cnt = 0;
- move16();
- /* VOICED frames in SC-VBR */
- encod_gen_voic_ivas_fx( st, inp, Aw, Aq, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, unbits, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, 0, Q_new );
- }
- }
- ELSE IF( EQ_16( st->coder_type, AUDIO ) || ( EQ_16( st->coder_type, INACTIVE ) && st->inactive_coder_type_flag ) )
- {
- /* AUDIO and INACTIVE frames (coded by GSC technology) */
- encod_audio_ivas_fx( st, inp, Aw, Aq, res_fx, syn_fx, exc_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, attack_flag, lsf_new_fx, &tmp_noise_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, Q_new, 0 );
- }
- ELSE
- {
- /* GENERIC, VOICED and INACTIVE frames (coded by AVQ technology) */
- encod_gen_voic_ivas_fx( st, inp, Aw, Aq, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, unbits, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, 0, Q_new );
- }
-
- FOR( i = 0; i < NB_SUBFR16k; i++ )
- {
- Scale_sig( &Aq[i * ( M + 1 )], ( M + 1 ), sub( Q12, sub( Q14, norm_s( Aq[i * ( M + 1 )] ) ) ) ); // Q12
- }
-
- /* update mem_syn1_flt for ACELP core switching */
- Copy( hLPDmem->mem_syn, hLPDmem->mem_syn1_fx, M );
-
- /* update old synthesis buffer - needed for ACELP internal sampling rate switching */
- Copy( syn_fx + sub( st->L_frame, L_SYN_MEM ), hLPDmem->mem_syn_r, L_SYN_MEM );
-
- Scale_sig( syn_fx, L_FRAME16k, sub( st->Q_syn, Q_new - 1 ) );
- /* save and delay synthesis to be used by SWB BWE */
- IF( st->hBWE_FD != NULL )
- {
- st->hBWE_FD->mem_deemph_old_syn_fx = shl_sat( st->hBWE_FD->mem_deemph_old_syn_fx, sub( s_min( st->Q_syn, st->hBWE_FD->q_mem_deemph_old_syn ), st->hBWE_FD->q_mem_deemph_old_syn ) );
- move16();
- Scale_sig( st->hBWE_FD->old_syn_12k8_16k_fx, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ), sub( s_min( st->Q_syn, st->hBWE_FD->q_mem_deemph_old_syn ), st->hBWE_FD->q_mem_deemph_old_syn ) );
-
- save_old_syn_fx( st->L_frame, syn_fx, old_syn_12k8_16k, st->hBWE_FD->old_syn_12k8_16k_fx, st->preemph_fac, &st->hBWE_FD->mem_deemph_old_syn_fx );
- *q_old_syn_12k8_16 = s_min( st->Q_syn, st->hBWE_FD->q_mem_deemph_old_syn );
- move16();
- st->hBWE_FD->q_mem_deemph_old_syn = s_min( st->Q_syn, st->hBWE_FD->q_mem_deemph_old_syn );
- move16();
- Scale_sig( syn_fx, st->L_frame, sub( st->Q_syn, s_min( st->Q_syn, st->hBWE_FD->q_mem_deemph_old_syn ) ) );
- }
-
- /*Update MODE2 core switching memory*/
- Copy( syn_fx, syn1_fx, st->L_frame );
-
- Scale_sig( st->hLPDmem->syn, M + 1, sub( st->Q_syn, st->hLPDmem->q_lpd_syn ) );
- st->hLPDmem->q_lpd_syn = st->Q_syn;
- move16();
-
- /*Update MODE2 core switching memory*/
- deemph_fx( syn1_fx, st->preemph_fac, st->L_frame, &( hLPDmem->syn[M] ) );
-
- Copy( syn1_fx + add( st->L_frame, -M - 1 ), hLPDmem->syn, M + 1 );
-
- test();
- IF( st->element_mode > EVS_MONO && st->hTcxEnc != NULL )
- {
- Copy( syn1_fx + shr( st->L_frame, 1 ), st->hTcxEnc->Txnq, shr( st->L_frame, 1 ) );
-#ifdef MSAN_FIX
- Scale_sig( st->hTcxEnc->Txnq + shr( st->L_frame, 1 ), sub( L_FRAME32k / 2 + 64, shr( st->L_frame, 1 ) ), sub( st->Q_syn, st->hTcxEnc->q_Txnq ) );
-#else
- Scale_sig( st->hTcxEnc->Txnq + shr( st->L_frame, 1 ), sub( L_FRAME32k / 2 + 64, shr( st->L_frame, 2 ) ), sub( st->Q_syn, st->hTcxEnc->q_Txnq ) );
-#endif
- st->hTcxEnc->q_Txnq = st->Q_syn;
- move16();
- }
-
- /*--------------------------------------------------------------------------------------*
- * Modify the excitation signal when the noise is stationary
- *--------------------------------------------------------------------------------------*/
- test();
- test();
- test();
- test();
- IF( !( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) ) && NE_16( nelp_mode, 1 ) && !( EQ_16( st->element_mode, IVAS_SCE ) && tdm_low_rate_mode ) )
- {
- /* exc2 buffer is needed only for updating of Aq[] which is needed for core switching */
- Copy( exc_fx, exc2_fx, st->L_frame );
-
- stat_noise_uv_enc_ivas_fx( st, epsP, lsp_new, lsp_mid, Aq, exc2_fx, uc_two_stage_flag, Q_new );
- }
-
- /*-----------------------------------------------------------------*
- * Encode supplementary information for Frame Error Concealment
- *-----------------------------------------------------------------*/
-
- Scale_sig( syn_fx, L_FRAME, sub( s_min( st->Q_syn, Q_new ), st->Q_syn ) );
-#ifdef MSAN_FIX
- Scale_sig( res_fx, st->L_frame, sub( s_min( st->Q_syn, Q_new ), Q_new ) );
-#else
- Scale_sig( res_fx, L_FRAME16k, sub( s_min( st->Q_syn, Q_new ), Q_new ) );
-#endif
- FEC_encode_ivas_fx( hBstr, st->acelp_cfg, syn_fx, st->coder_type, st->clas, pitch_buf, res_fx, &st->Last_pulse_pos, st->L_frame, st->total_brate, s_min( st->Q_syn, Q_new ) );
- IF( st->hBWE_TD != NULL )
- {
- IF( EQ_16( st->L_frame, L_FRAME ) )
- {
- Copy( Aq + 2 * ( M + 1 ), st->hBWE_TD->cur_sub_Aq_fx, ( M + 1 ) );
- }
- ELSE
- {
- Copy( Aq + 3 * ( M + 1 ), st->hBWE_TD->cur_sub_Aq_fx, ( M + 1 ) );
- }
- }
-
-
- } /* end of active inp coding */
-
- /*-----------------------------------------------------------------*
- * Write ACELP unused bits
- *-----------------------------------------------------------------*/
- test();
- test();
- IF( NE_32( st->core_brate, SID_2k40 ) && NE_32( st->core_brate, FRAME_NO_DATA ) && NE_32( st->core_brate, PPP_NELP_2k80 ) )
- {
- nBits = st->acelp_cfg.ubits;
- move16();
- WHILE( nBits > 0 )
- {
- i = s_min( nBits, 16 );
- push_indice( hBstr, IND_UNUSED, 0, i );
- nBits = sub( nBits, i );
- }
- }
-
- /*-----------------------------------------------------------------*
- * Apply non linearity in case of SWB TBE
- *-----------------------------------------------------------------*/
-
- IF( st->hBWE_TD != NULL )
- {
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- IF( ( EQ_16( st->last_Opt_SC_VBR, 1 ) && st->Opt_SC_VBR == 0 ) || ( ( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, WB_TBE ) || EQ_16( st->extl, FB_TBE ) ) && NE_16( st->last_extl, SWB_TBE ) && NE_16( st->last_extl, WB_TBE ) && NE_16( st->last_extl, FB_TBE ) ) || ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) && !st->tdm_LRTD_flag ) )
- {
- st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0;
- move16();
- set16_fx( st->hBWE_TD->old_bwe_exc_extended_fx, 0, NL_BUFF_OFFSET );
- }
-
- test();
- test();
- test();
- test();
- test();
- test();
- 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
- 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
- }
-
- test();
- if ( EQ_32( st->core_brate, SID_2k40 ) || EQ_32( st->core_brate, FRAME_NO_DATA ) )
- {
- st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0;
- move16();
- }
- }
-
- /*-----------------------------------------------------------------*
- * Updates
- *-----------------------------------------------------------------*/
-
- IF( st->hBWE_TD != NULL )
- {
- st->Q_exc = Q_new;
- move16();
- }
-
- updt_enc_fx( st, old_exc_fx, pitch_buf, Es_pred_fx, Aq, lsf_new_fx, lsp_new, old_bwe_exc_fx );
- st->hLPDmem->q_lpd_old_exc = Q_new;
- move16();
-
- test();
- test();
- IF( st->hTdCngEnc != NULL && st->Opt_DTX_ON && GT_32( st->core_brate, SID_2k40 ) )
- {
- /* update CNG parameters in active frames */
- Word16 q_exc = st->hTdCngEnc->cng_Qexc_buf[0];
- move16();
- FOR( Word16 ii = 0; ii < HO_HIST_SIZE; ii++ )
- {
- q_exc = s_min( q_exc, st->hTdCngEnc->cng_Qexc_buf[ii] );
- }
- q_exc = s_min( q_exc, Q_new );
-
- Scale_sig( exc_fx, L_EXC - L_EXC_MEM, sub( q_exc, Q_new ) );
- FOR( Word16 ii = 0; ii < HO_HIST_SIZE; ii++ )
- {
- Scale_sig( st->hTdCngEnc->cng_exc2_buf + ii * L_FFT, L_FFT, sub( q_exc, st->hTdCngEnc->cng_Qexc_buf[ii] ) );
- st->hTdCngEnc->cng_Qexc_buf[ii] = q_exc;
- move16();
- }
- cng_params_upd_ivas_fx( lsp_new, exc_fx, st->L_frame, &st->hTdCngEnc->ho_circ_ptr, st->hTdCngEnc->ho_ener_circ_fx,
- &st->hTdCngEnc->ho_circ_size, st->hTdCngEnc->ho_lsp_circ_fx, q_exc, ENC, st->hTdCngEnc->ho_env_circ_fx, &st->hTdCngEnc->cng_buf_cnt,
- st->hTdCngEnc->cng_exc2_buf, st->hTdCngEnc->cng_Qexc_buf, st->hTdCngEnc->cng_brate_buf, st->hDtxEnc->last_active_brate, st->element_mode,
- st->hFdCngEnc->hFdCngCom->CngBandwidth );
-
- IF( EQ_16( st->L_frame, L_FRAME ) )
- {
- /* store LSPs@16k, potentially to be used in CNG@16k */
- Copy( st->lsp_old16k_fx, &( st->hTdCngEnc->ho_lsp_circ2_fx[( st->hTdCngEnc->ho_circ_ptr ) * M] ), M );
- }
-
- /* set LSP@16k flag for the first buffer */
- IF( EQ_16( st->L_frame, L_FRAME ) )
- {
- st->hTdCngEnc->ho_16k_lsp[st->hTdCngEnc->ho_circ_ptr] = 0;
- }
- ELSE
- {
- st->hTdCngEnc->ho_16k_lsp[st->hTdCngEnc->ho_circ_ptr] = 1;
- }
- move16();
- /* efficient DTX hangover control */
- IF( GT_16( st->hTdCngEnc->burst_ho_cnt, 1 ) )
- {
- dtx_hangover_control_fx( st, lsp_new );
- }
- }
-
- /* SC-VBR update of average data rate */
- IF( EQ_16( st->vad_flag, 1 ) )
- {
- /* reset in case of bitrate switching in EVS */
- if ( st->hSC_VBR != NULL )
- {
- update_average_rate_fx( st->hSC_VBR, st->core_brate );
- }
- }
- pop_wmops();
-
- return error;
-}
diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c
index 66e34e2a58b614dace296d7eaea7ec8ceb7cc31b..8f63c6612dafe59660fd8fe46f204c58fea119de 100644
--- a/lib_enc/acelp_core_enc_fx.c
+++ b/lib_enc/acelp_core_enc_fx.c
@@ -6,36 +6,39 @@
#include
#include "options.h" /* Compilation switches */
#include "cnst.h"
+#include "prot.h"
#include "prot_fx.h"
#include "stat_enc.h"
#include "rom_com.h"
-#include "rom_enc.h" /* Encoder static table prototypes */
-#include "rom_com_fx.h" /* Static table prototypes */
-//#include "prot_fx.h" /* Function prototypes */
+#include "rom_enc.h" /* Encoder static table prototypes */
+#include "rom_com_fx.h" /* Static table prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
+#include "ivas_cnst.h"
+#include "ivas_prot.h"
+#include "ivas_prot_fx.h"
/*-------------------------------------------------------------------*
- * acelp_core_enc()
+ * acelp_core_enc_fx()
*
* ACELP core encoder
*--------------------------------------------------------------------*/
ivas_error acelp_core_enc_fx(
Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word16 inp_fx[], /* i : input signal of the current frame */
- const Word32 ener_fx, /* i : residual energy from Levinson-Durbin*/
- Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes*/
- Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes*/
- const Word16 epsP_h_fx[M + 1], /* i : LP prediction errors */
- const Word16 epsP_l_fx[M + 1], /* i : LP prediction errors */
- Word16 lsp_new_fx[M], /* i : LSPs at the end of the frame */
- Word16 lsp_mid_fx[M], /* i : LSPs in the middle of the frame */
- Word16 vad_hover_flag_fx, /* i : VAD hangover flag */
- const Word16 attack_flag, /* i : attack flag (GSC or TC) */
- Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation */
- Word16 *voice_factors_fx, /* o : voicing factors */
- Word16 old_syn_12k8_16k_fx[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE */
- Word16 pitch_buf_fx[NB_SUBFR16k], /* o : floating pitch for each subframe */
- Word16 *unbits_fx, /* o : number of unused bits */
+ const Word16 inp_fx[], /* i : input signal of the current frame Q_new*/
+ const Word32 ener_fx, /* i : residual energy from Levinson-Durbin Q6*/
+ Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12*/
+ Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes Q12*/
+ const Word16 epsP_h_fx[M + 1], /* i : LP prediction errors Qx*/
+ const Word16 epsP_l_fx[M + 1], /* i : LP prediction errors Qx*/
+ Word16 lsp_new_fx[M], /* i : LSPs at the end of the frame Q15*/
+ Word16 lsp_mid_fx[M], /* i : LSPs in the middle of the frame Q15*/
+ Word16 vad_hover_flag_fx, /* i : VAD hangover flag Q0*/
+ const Word16 attack_flag, /* i : attack flag (GSC or TC) Q0*/
+ Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation st->prev_Q_bwe_exc*/
+ Word16 *voice_factors_fx, /* o : voicing factors Q15*/
+ Word16 old_syn_12k8_16k_fx[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE q_old_syn*/
+ Word16 pitch_buf_fx[NB_SUBFR16k], /* o : floating pitch for each subframe Q6*/
+ Word16 *unbits_fx, /* o : number of unused bits Q0*/
const Word16 Q_new,
const Word16 shift
#ifdef ADD_LRTD
@@ -86,6 +89,7 @@ ivas_error acelp_core_enc_fx(
Word16 *tdm_Pri_pitch_buf;
Word16 uc_two_stage_flag;
Word16 att;
+ move16();
SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR;
DTX_ENC_HANDLE hDtxEnc = st_fx->hDtxEnc;
@@ -113,14 +117,15 @@ ivas_error acelp_core_enc_fx(
move16();
coder_type = st_fx->coder_type;
+ move16();
- exc_fx = old_exc_fx + L_EXC_MEM; /* pointer to excitation signal in the current frame */
- Copy( hLPDmem->old_exc, old_exc_fx, L_EXC_MEM );
+ exc_fx = old_exc_fx + L_EXC_MEM; /* pointer to excitation signal in the current frame */
+ Copy( hLPDmem->old_exc, old_exc_fx, L_EXC_MEM ); // q_lpd_old_exc
IF( hBWE_TD != NULL )
{
- bwe_exc_fx = old_bwe_exc_fx + PIT16k_MAX * 2; /* pointer to BWE excitation signal in the current frame */
- Copy( hBWE_TD->old_bwe_exc_fx, old_bwe_exc_fx, PIT16k_MAX * 2 );
+ bwe_exc_fx = old_bwe_exc_fx + PIT16k_MAX * 2; /* pointer to BWE excitation signal in the current frame */
+ Copy( hBWE_TD->old_bwe_exc_fx, old_bwe_exc_fx, PIT16k_MAX * 2 ); // Q_exc
}
ELSE
{
@@ -151,7 +156,8 @@ 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 );
+ st_fx->Nb_ACELP_frames = add( st_fx->Nb_ACELP_frames, 1 ); // Q0
+ move16();
int_fs_fx = INT_FS_16k_FX;
move16();
@@ -242,13 +248,14 @@ ivas_error acelp_core_enc_fx(
/* convert old quantized LSP vector */
IF( EQ_16( st_fx->L_frame, L_FRAME ) )
{
- st_fx->rate_switching_reset = lsp_convert_poly_fx( st_fx->lsp_old_fx, st_fx->L_frame, 0 );
+ st_fx->rate_switching_reset = lsp_convert_poly_fx( st_fx->lsp_old_fx, st_fx->L_frame, 0 ); // Q0
+ move16();
}
ELSE
{
- st_fx->rate_switching_reset = st_fx->rate_switching_reset_16kHz;
+ st_fx->rate_switching_reset = st_fx->rate_switching_reset_16kHz; // Q0
move16();
- Copy( st_fx->lsp_old16k_fx, st_fx->lsp_old_fx, M );
+ Copy( st_fx->lsp_old16k_fx, st_fx->lsp_old_fx, M ); // Q15
}
/* convert old quantized LSF vector */
@@ -266,14 +273,14 @@ ivas_error acelp_core_enc_fx(
}
/* Reset LPC mem */
- Copy( GEWB_Ave_fx, st_fx->mem_AR_fx, M );
+ Copy( GEWB_Ave_fx, st_fx->mem_AR_fx, M ); // x2.56
set16_fx( st_fx->mem_MA_fx, 0, M );
/* update synthesis filter memories */
synth_mem_updt2( st_fx->L_frame, st_fx->last_L_frame, hLPDmem->old_exc, hLPDmem->mem_syn_r, hLPDmem->mem_syn2, hLPDmem->mem_syn, ENC );
- Copy( hLPDmem->old_exc, old_exc_fx, L_EXC_MEM );
- Copy( hLPDmem->mem_syn2, hLPDmem->mem_syn1_fx, M );
- Copy( hLPDmem->mem_syn2, hLPDmem->mem_syn3, M );
+ Copy( hLPDmem->old_exc, old_exc_fx, L_EXC_MEM ); // q_lpd_old_exc
+ Copy( hLPDmem->mem_syn2, hLPDmem->mem_syn1_fx, M ); // q_mem_syn
+ Copy( hLPDmem->mem_syn2, hLPDmem->mem_syn3, M ); // q_mem_syn
/* update Aw[] coefficients */
weight_a_subfr_fx( shr( st_fx->L_frame, 6 ), A_fx, Aw_fx, st_fx->gamma, M );
@@ -320,24 +327,24 @@ ivas_error acelp_core_enc_fx(
FdCng_exc( st_fx->hFdCngEnc->hFdCngCom, &hDtxEnc->CNG_mode, st_fx->L_frame, st_fx->lsp_old_fx,
hDtxEnc->first_CNG, hDtxEnc->lspCNG_fx, Aq_fx, lsp_new_fx, lsf_new_fx, exc_fx, exc2_fx, bwe_exc_fx );
- Copy( exc2_fx, exc3_fx, st_fx->L_frame );
+ Copy( exc2_fx, exc3_fx, st_fx->L_frame ); // Q12
IF( EQ_32( st_fx->core_brate, SID_2k40 ) )
{
IF( hTdCngEnc != NULL )
{
/*IVAS_CODE CNG_att is missing */
- enr = cng_energy_fx( st_fx->element_mode, st_fx->bwidth, hDtxEnc->CNG_mode, /*st_fx->hTdCngEnc->CNG_att*/ 0, exc_fx, st_fx->L_frame, Q_new );
+ enr = cng_energy_fx( st_fx->element_mode, st_fx->bwidth, hDtxEnc->CNG_mode, /*st_fx->hTdCngEnc->CNG_att*/ 0, exc_fx, st_fx->L_frame, Q_new ); // Q8
/* calculate the energy quantization index */
enr_index = add( enr, 512 /* Q8(2.0) */ ); /* enr + 2.0 */
enr_index = extract_l( L_shr( L_mult0( enr_index, STEP_SID_FX ), 12 + 8 ) ); /* Q0 (8+12-(8+12)) */
/* limit the energy quantization index */
- enr_index = s_min( enr_index, 127 );
+ enr_index = s_min( enr_index, 127 ); // Q0
enr_index = s_max( enr_index, 0 );
- hTdCngEnc->old_enr_index = enr_index;
+ hTdCngEnc->old_enr_index = enr_index; /* Q0 */
move16();
}
}
@@ -361,7 +368,7 @@ ivas_error acelp_core_enc_fx(
Copy( hLPDmem->mem_syn3, hLPDmem->mem_syn, M );
/* update old synthesis buffer - needed for ACELP internal sampling rate switching */
- Copy( syn1_fx + st_fx->L_frame - L_SYN_MEM, hLPDmem->mem_syn_r, L_SYN_MEM );
+ Copy( syn1_fx + st_fx->L_frame - L_SYN_MEM, hLPDmem->mem_syn_r, L_SYN_MEM ); /* st_fx->Q_syn */
IF( hBWE_FD != NULL )
{
@@ -372,7 +379,7 @@ ivas_error acelp_core_enc_fx(
tmp16 = hLPDmem->syn[M];
move16();
E_UTIL_deemph2( sub( Q_new, 1 ), syn1_fx, st_fx->preemph_fac, st_fx->L_frame, &tmp16 );
- Copy( syn1_fx + st_fx->L_frame - M - 1, hLPDmem->syn, M + 1 );
+ Copy( syn1_fx + st_fx->L_frame - M - 1, hLPDmem->syn, M + 1 ); /* st_fx->Q_syn */
}
/*----------------------------------------------------------------*
@@ -408,7 +415,7 @@ ivas_error acelp_core_enc_fx(
test();
IF( st_fx->hDtxEnc != NULL && ( st_fx->last_core_brate == FRAME_NO_DATA || EQ_32( st_fx->last_core_brate, SID_2k40 ) ) )
{
- Copy( hDtxEnc->lspCNG_fx, st_fx->lsp_old_fx, M );
+ Copy( hDtxEnc->lspCNG_fx, st_fx->lsp_old_fx, M ); // Q15
lsp2lsf_fx( hDtxEnc->lspCNG_fx, st_fx->lsf_old_fx, M, int_fs_fx );
}
@@ -580,8 +587,7 @@ ivas_error acelp_core_enc_fx(
ELSE IF( EQ_16( coder_type, TRANSITION ) )
{
tc_subfr_fx = encod_tran_fx( st_fx, inp_fx, Aw_fx, Aq_fx, Es_pred_fx, res_fx, syn_fx,
- exc_fx, exc2_fx, pitch_buf_fx, voice_factors_fx, bwe_exc_fx, tc_subfr_fx, position, unbits_fx, shift, Q_new );
- move16();
+ exc_fx, exc2_fx, pitch_buf_fx, voice_factors_fx, bwe_exc_fx, tc_subfr_fx, position, unbits_fx, shift, Q_new ); /* Q0 */
}
ELSE IF( hSC_VBR->ppp_mode )
{
@@ -632,7 +638,7 @@ ivas_error acelp_core_enc_fx(
}
/* update st->mem_syn1 for ACELP core switching */
- Copy( hLPDmem->mem_syn, hLPDmem->mem_syn1_fx, M );
+ Copy( hLPDmem->mem_syn, hLPDmem->mem_syn1_fx, M ); /* q_mem_syn */
/* update old synthesis buffer - needed for ACELP internal sampling rate switching */
Copy( syn_fx + st_fx->L_frame - L_SYN_MEM, hLPDmem->mem_syn_r, L_SYN_MEM );
@@ -643,25 +649,31 @@ ivas_error acelp_core_enc_fx(
save_old_syn_fx( st_fx->L_frame, syn_fx, old_syn_12k8_16k_fx, hBWE_FD->old_syn_12k8_16k_fx, st_fx->preemph_fac, &hBWE_FD->mem_deemph_old_syn_fx );
}
/*Update MODE2 core switching memory*/
- Copy( syn_fx, syn1_fx, st_fx->L_frame );
+ Copy( syn_fx, syn1_fx, st_fx->L_frame ); // Q_syn
E_UTIL_deemph2( sub( Q_new, 1 ), syn1_fx, st_fx->preemph_fac, st_fx->L_frame, &hLPDmem->syn[M] );
- Copy( syn1_fx + st_fx->L_frame - M - 1, hLPDmem->syn, M + 1 );
- IF( GT_16( st_fx->element_mode, EVS_MONO ) && st_fx->hTcxEnc != NULL )
+ Copy( syn1_fx + st_fx->L_frame - M - 1, hLPDmem->syn, M + 1 ); // Q_syn
+
+ test();
+ IF( st_fx->element_mode > EVS_MONO && st_fx->hTcxEnc != NULL )
{
- Copy( syn1_fx + st_fx->L_frame / 2, st_fx->hTcxEnc->Txnq, st_fx->L_frame / 2 );
+ Copy( syn1_fx + st_fx->L_frame / 2, st_fx->hTcxEnc->Txnq, st_fx->L_frame / 2 ); // Q_syn
}
/*--------------------------------------------------------------------------------------*
* Modify the excitation signal when the noise is stationary
*--------------------------------------------------------------------------------------*/
+ test();
+ test();
+ test();
+ test();
IF( !( EQ_16( st_fx->idchan, 1 ) && EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) && NE_16( nelp_mode, 1 ) && !( EQ_16( st_fx->element_mode, IVAS_SCE ) && tdm_low_rate_mode ) )
{
L_epsP[0] = L_Comp( epsP_h_fx[2], epsP_l_fx[2] );
move32();
L_epsP[1] = L_Comp( epsP_h_fx[M], epsP_l_fx[M] );
move32();
- Copy( exc_fx, exc2_fx, st_fx->L_frame );
+ Copy( exc_fx, exc2_fx, st_fx->L_frame ); // Q_new
stat_noise_uv_enc_fx( st_fx, L_epsP, lsp_new_fx, lsp_mid_fx, Aq_fx, exc2_fx, uc_two_stage_flag, Q_new );
}
@@ -677,11 +689,11 @@ ivas_error acelp_core_enc_fx(
{
IF( EQ_16( st_fx->L_frame, L_FRAME ) )
{
- Copy( Aq_fx + 2 * ( M + 1 ), hBWE_TD->cur_sub_Aq_fx, ( M + 1 ) );
+ Copy( Aq_fx + 2 * ( M + 1 ), hBWE_TD->cur_sub_Aq_fx, ( M + 1 ) ); // Q12
}
ELSE
{
- Copy( Aq_fx + 3 * ( M + 1 ), hBWE_TD->cur_sub_Aq_fx, ( M + 1 ) );
+ Copy( Aq_fx + 3 * ( M + 1 ), hBWE_TD->cur_sub_Aq_fx, ( M + 1 ) ); // Q12
}
}
} /* end of active inp coding */
@@ -695,13 +707,14 @@ ivas_error acelp_core_enc_fx(
IF( NE_32( st_fx->core_brate, SID_2k40 ) && NE_32( st_fx->core_brate, FRAME_NO_DATA ) && NE_32( st_fx->core_brate, PPP_NELP_2k80 ) )
{
/* reserved bits */
- nBits = st_fx->acelp_cfg.ubits;
+ nBits = st_fx->acelp_cfg.ubits; // Q0
+ move16();
WHILE( nBits > 0 )
{
- i = s_min( nBits, 16 );
+ i = s_min( nBits, 16 ); // Q0
push_indice_fx( st_fx->hBstr, IND_UNUSED, 0, i );
- nBits = sub( nBits, i );
+ nBits = sub( nBits, i ); // Q0
}
}
@@ -742,6 +755,7 @@ ivas_error acelp_core_enc_fx(
*-----------------------------------------------------------------*/
updt_enc_fx( st_fx, old_exc_fx, pitch_buf_fx, Es_pred_fx, Aq_fx, lsf_new_fx, lsp_new_fx, old_bwe_exc_fx );
+ test();
test();
IF( hTdCngEnc != NULL && ( st_fx->Opt_DTX_ON != 0 ) && ( GT_32( st_fx->core_brate, SID_2k40 ) ) )
{
@@ -753,7 +767,7 @@ ivas_error acelp_core_enc_fx(
IF( EQ_16( st_fx->L_frame, L_FRAME ) )
{
/* store LSPs@16k, potentially to be used in CNG@16k */
- Copy( st_fx->lsp_old16k_fx, &( hTdCngEnc->ho_lsp_circ2_fx[( hTdCngEnc->ho_circ_ptr ) * M] ), M );
+ Copy( st_fx->lsp_old16k_fx, &( hTdCngEnc->ho_lsp_circ2_fx[( hTdCngEnc->ho_circ_ptr ) * M] ), M ); // Q15
}
/* Set 16k LSP flag for CNG buffer */
@@ -773,6 +787,7 @@ ivas_error acelp_core_enc_fx(
}
/* SC-VBR update of average data rate */
+ test();
IF( EQ_16( st_fx->vad_flag, 1 ) && ( hSC_VBR != NULL ) )
{
update_average_rate_fx( hSC_VBR, st_fx->core_brate );
@@ -780,3 +795,936 @@ ivas_error acelp_core_enc_fx(
return error;
}
+
+/*-------------------------------------------------------------------*
+ * acelp_core_enc_ivas_fx()
+ *
+ * ACELP core encoder
+ *--------------------------------------------------------------------*/
+ivas_error acelp_core_enc_ivas_fx(
+ Encoder_State *st, /* i/o: encoder state structure */
+ const Word16 inp[], /* i : input signal of the current frame Q_new*/
+ Word16 A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12*/
+ Word16 Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes Q12*/
+ const Word32 epsP[M + 1], /* i : LP prediction errors Qx*/
+ Word16 lsp_new[M], /* i : LSPs at the end of the frame Q15*/
+ Word16 lsp_mid[M], /* i : LSPs in the middle of the frame Q15*/
+ const Word16 vad_hover_flag, /* i : VAD hangover flag Q0*/
+ const Word16 attack_flag, /* i : attack flag (GSC or TC) Q0*/
+ Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation st->prev_Q_bwe_exc*/
+ Word16 *voice_factors_fx, /* o : voicing factors Q15*/
+ Word16 old_syn_12k8_16k[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE q_old_syn_12k8_16*/
+ Word16 *q_old_syn_12k8_16,
+ Word16 pitch_buf[NB_SUBFR16k], /* o : floating pitch for each subframe Q6*/
+ Word16 *unbits, /* o : number of unused bits Q0*/
+ STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder handle */
+ Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel X2.56*/
+ Word16 Q_new )
+{
+ Word16 i, nBits; /* reserved bits */
+ LPD_state_HANDLE hLPDmem; /* i/o: acelp memories */
+ Word16 tc_subfr; /* TC sub-frame indication */
+ Word16 allow_cn_step;
+ Word32 int_fs;
+ Word16 nb_bits; /* parameters handling */
+
+ /* SC-VBR - back-up memories for LSF quantizer and synthesis filter */
+ Word16 pstreaklen;
+ Word16 sid_bw = -1;
+ move16();
+ Word16 next_force_sf_bck;
+ Word16 uc_two_stage_flag;
+ Word16 position;
+ Word16 ppp_mode, nelp_mode;
+ Word16 tdm_lp_reuse_flag, tdm_low_rate_mode, tdm_Pitch_reuse_flag;
+
+ /* bitstream */
+ BSTR_ENC_HANDLE hBstr = st->hBstr;
+ Word16 old_exc_fx[L_EXC], *exc_fx; /* excitation signal buffer */
+ Word16 lsf_new_fx[M]; /* ISFs at the end of the frame */
+ Word16 Aq[NB_SUBFR16k * ( M + 1 )]; /* A(z) quantized for the 4 subframes */
+ Word16 syn_fx[L_FRAME16k]; /* synthesis vector */
+ Word16 res_fx[L_FRAME16k]; /* Residual signal for FER protection */
+ Word16 exc2_fx[L_FRAME16k]; /* enhanced excitation */
+ Word16 Es_pred_fx; /* predicited scaled innovation energy */
+ Word16 tmp_noise_fx; /* NB post-filter long-term noise energy*/
+ Word16 old_bwe_exc_fx[( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2]; /* excitation buffer Q_new */
+ Word16 *bwe_exc_fx; /* excitation for SWB TBE Q_new */
+ Word16 mem_MA_fx[M], mem_AR_fx[M], lsp_new_bck_fx[M], /*lsf_new_bck_fx[M],*/ lsp_mid_bck_fx[M], mem_syn_bck_fx[M];
+ Word32 Bin_E_fx[L_FFT], Bin_E_old_fx[L_FFT / 2];
+ Word16 clip_var_fx, mem_w0_bck_fx, streaklimit_fx;
+
+#ifdef MSAN_FIX
+ set16_fx( old_bwe_exc_fx, 0, ( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2 );
+ set16_fx( old_exc_fx, 0, L_EXC );
+ set16_fx( Aq, 0, NB_SUBFR16k * ( M + 1 ) );
+ set16_fx( syn_fx, 0, L_FRAME16k );
+#endif
+
+ Word16 tilt_code_bck_fx;
+ Word32 gc_threshold_bck_fx;
+ Word16 clip_var_bck_fx[6];
+ Word32 q_env_fx[NUM_ENV_CNG];
+#ifdef MSAN_FIX
+ set32_fx( q_env_fx, 0, NUM_ENV_CNG );
+ set16_fx( exc2_fx, 0, L_FRAME16k );
+#endif
+ Word16 exc3_fx[L_FRAME16k];
+ Word16 syn1_fx[L_FRAME16k];
+ Word16 *tdm_Pri_pitch_buf_fx;
+
+ Word16 att_fx;
+ Word16 tmpF_fx;
+
+ test();
+ IF( !st->Opt_AMR_WB && st->hBWE_TD != NULL )
+ {
+ Scale_sig( st->hBWE_TD->old_bwe_exc_fx, PIT16k_MAX * 2, sub( Q_new, st->prev_Q_new ) ); // Q_new
+ }
+ IF( st->hLPDmem )
+ {
+ Scale_sig( st->hLPDmem->old_exc, L_EXC_MEM, sub( Q_new, st->hLPDmem->q_lpd_old_exc ) ); // Q_new
+ st->hLPDmem->q_lpd_old_exc = Q_new;
+ move16();
+ Scale_sig( st->hLPDmem->syn, M + 1, sub( Q_new, st->hLPDmem->q_lpd_syn ) ); // Q_new
+ st->hLPDmem->q_lpd_syn = Q_new;
+ move16();
+ Scale_sig( st->hLPDmem->mem_syn, M, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); // Q_new -1
+ Scale_sig( st->hLPDmem->mem_syn1_fx, M, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); // Q_new -1
+ Scale_sig( st->hLPDmem->mem_syn2, M, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); // Q_new -1
+ Scale_sig( st->hLPDmem->mem_syn3, M, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); // Q_new -1
+ Scale_sig( st->hLPDmem->mem_syn_r, L_SYN_MEM, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); // Q_new -1
+ st->hLPDmem->mem_w0 = shl_sat( st->hLPDmem->mem_w0, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); // Q_new -1
+ move16();
+ st->hLPDmem->q_mem_syn = sub( Q_new, 1 );
+ move16();
+ }
+
+ Scale_sig32( st->Bin_E_old_fx, L_FFT / 2, sub( add( Q_new, Q_SCALE - 2 ), st->q_Bin_E_old ) ); // Q_new + Q_scale - 2
+ st->q_Bin_E_old = add( Q_new, Q_SCALE - 2 );
+ move16();
+ Scale_sig32( st->Bin_E_fx, L_FFT, sub( add( Q_new, Q_SCALE - 2 ), st->q_Bin_E ) ); // Q_new + Q_scale - 2
+ st->q_Bin_E = add( Q_new, Q_SCALE - 2 );
+ move16();
+
+ ivas_error error;
+
+ error = IVAS_ERR_OK;
+ move32();
+
+ test();
+ IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && LE_32( st->core_brate, SID_2k40 ) )
+ {
+ /* Core was ACELP because of DTX in MDCT-Stereo, but SID encoding for that is done in separate function */
+ return error;
+ }
+
+ push_wmops( "acelp_core_enc" );
+ /*------------------------------------------------------------------*
+ * Initialization
+ *------------------------------------------------------------------*/
+
+ hLPDmem = st->hLPDmem;
+
+ Es_pred_fx = 0;
+ move16();
+
+ exc_fx = old_exc_fx + L_EXC_MEM; /* pointer to excitation signal in the current frame */
+ Copy( hLPDmem->old_exc, old_exc_fx, L_EXC_MEM ); /* Q_new */
+ Scale_sig( old_exc_fx, L_EXC_MEM, sub( Q_new, hLPDmem->q_lpd_old_exc ) ); // Q_new
+ IF( st->hBWE_TD != NULL )
+ {
+ bwe_exc_fx = old_bwe_exc_fx + PIT16k_MAX * 2; /* pointer to BWE excitation signal in the current frame */
+ Copy( st->hBWE_TD->old_bwe_exc_fx, old_bwe_exc_fx, PIT16k_MAX * 2 ); // Q_new
+ }
+ ELSE
+ {
+ bwe_exc_fx = NULL;
+ }
+
+ st->bpf_off = 0;
+ move16();
+
+ test();
+ test();
+ test();
+ IF( EQ_16( st->last_core, HQ_CORE ) || EQ_16( st->last_codec_mode, MODE2 ) || EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) )
+ {
+ /* in case of HQ->ACELP switching, do not apply BPF */
+ st->bpf_off = 1;
+ move16();
+ /* reset the GSC pre echo energy threshold in case of switching */
+ if ( st->hGSCEnc != NULL )
+ {
+ st->hGSCEnc->Last_frame_ener_fx = MAX_32;
+ move32();
+ }
+ }
+
+ /* force safety-net LSFQ in the first frames after CNG segment */
+ if ( LE_32( st->last_core_brate, SID_2k40 ) )
+ {
+ st->Nb_ACELP_frames = 0;
+ move16();
+ }
+ st->Nb_ACELP_frames = add( st->Nb_ACELP_frames, 1 );
+ move16();
+
+ IF( EQ_16( st->L_frame, L_FRAME ) )
+ {
+ int_fs = INT_FS_12k8;
+ move32();
+ }
+ ELSE
+ {
+ int_fs = INT_FS_16k;
+ move32();
+ }
+
+ tmp_noise_fx = 0;
+ move16();
+ tc_subfr = -1;
+ move16();
+ position = -1;
+ move16();
+
+ /* SC-VBR temporary variables */
+ pstreaklen = 0;
+ move16();
+ clip_var_fx = 0;
+ move16();
+ mem_w0_bck_fx = 0;
+ move16();
+ streaklimit_fx = 0;
+ move16();
+
+ /* channel-aware mode */
+ reset_rf_indices_fx( st );
+
+ /* VBR modes */
+ IF( st->Opt_SC_VBR )
+ {
+ ppp_mode = st->hSC_VBR->ppp_mode;
+ nelp_mode = st->hSC_VBR->nelp_mode;
+ }
+ ELSE
+ {
+ ppp_mode = 0;
+ nelp_mode = 0;
+ }
+ move16();
+ move16();
+
+ test();
+ /* TD stereo */
+
+ IF( EQ_16( st->element_mode, IVAS_CPE_TD ) && EQ_16( st->idchan, 1 ) )
+ {
+ tdm_lp_reuse_flag = hStereoTD->tdm_lp_reuse_flag; // Q0
+ tdm_low_rate_mode = hStereoTD->tdm_low_rate_mode; // Q0
+ tdm_Pitch_reuse_flag = hStereoTD->tdm_Pitch_reuse_flag; // Q0
+ tdm_Pri_pitch_buf_fx = hStereoTD->tdm_Pri_pitch_buf_fx; // Q6
+ move16();
+ move16();
+ move16();
+ }
+ ELSE
+ {
+ tdm_lp_reuse_flag = 0;
+ tdm_low_rate_mode = 0;
+ move16();
+ move16();
+
+ test();
+ if ( EQ_16( st->element_mode, IVAS_SCE ) && st->low_rate_mode )
+ {
+ tdm_low_rate_mode = 1;
+ move16();
+ }
+ tdm_Pitch_reuse_flag = 0;
+ move16();
+ tdm_Pri_pitch_buf_fx = NULL;
+ }
+
+ /*-----------------------------------------------------------------*
+ * ACELP@12k8 / ACELP@16k switching
+ *-----------------------------------------------------------------*/
+
+ test();
+ test();
+ IF( NE_16( st->last_L_frame, st->L_frame ) && ( st->last_core == ACELP_CORE || EQ_16( st->last_core, AMR_WB_CORE ) ) )
+ {
+ /* in case of switching, do not apply BPF (flag employed also in updt_enc()) */
+ st->bpf_off = 1;
+ move16();
+
+ /* force safety-net LSFQ in the first frames after ACELP@12k8/ACELP@16k switching */
+ st->Nb_ACELP_frames = 1;
+ move16();
+
+ /* convert old quantized LSP vector */
+ IF( EQ_16( st->L_frame, L_FRAME ) )
+ {
+ st->rate_switching_reset = lsp_convert_poly_fx( st->lsp_old_fx, st->L_frame, 0 ); // Q0
+ move16();
+ }
+ ELSE
+ {
+ st->rate_switching_reset = st->rate_switching_reset_16kHz; // Q0
+ move16();
+ Copy( st->lsp_old16k_fx, st->lsp_old_fx, M ); // Q15
+ }
+
+ /* convert old quantized LSF vector */
+ lsp2lsf_fx( st->lsp_old_fx, st->lsf_old_fx, M, int_fs );
+
+ /* interpolation of unquantized ISPs */
+ IF( st->rate_switching_reset )
+ {
+ /*extrapolation in case of unstable LSP*/
+ int_lsp4_ivas_fx( st->L_frame, lsp_mid, lsp_mid, lsp_new, A, M, 0 );
+ }
+ ELSE
+ {
+ int_lsp4_ivas_fx( st->L_frame, st->lsp_old_fx, lsp_mid, lsp_new, A, M, 0 );
+ }
+
+ /* Reset LPC mem */
+ Copy( GEWB_Ave_fx, st->mem_AR_fx, M ); // Q2.56
+ set16_fx( st->mem_MA_fx, 0, M );
+
+ /* update synthesis filter memories */
+ synth_mem_updt2( st->L_frame, st->last_L_frame, hLPDmem->old_exc, hLPDmem->mem_syn_r, hLPDmem->mem_syn2, hLPDmem->mem_syn, ENC );
+ Copy( hLPDmem->old_exc, old_exc_fx, L_EXC_MEM ); // Q_new
+ Copy( hLPDmem->mem_syn2, hLPDmem->mem_syn1_fx, M ); /* hLPDmem->q_mem_syn */
+ Copy( hLPDmem->mem_syn2, hLPDmem->mem_syn3, M ); /* hLPDmem->q_mem_syn */
+
+ /* 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();
+ if ( st->last_bwidth == NB && st->bwidth != NB && st->ini_frame != 0 )
+ {
+ st->rate_switching_reset = 1;
+ move16();
+ }
+
+ /*----------------------------------------------------------------*
+ * Encoding of CNG frames
+ *----------------------------------------------------------------*/
+ test();
+ IF( EQ_32( st->core_brate, SID_2k40 ) || st->core_brate == FRAME_NO_DATA )
+ {
+ IF( st->cng_type == LP_CNG )
+ {
+ /* Run CNG post parameter update */
+ cng_params_postupd_ivas_fx( st->hTdCngEnc->ho_circ_ptr, &st->hTdCngEnc->cng_buf_cnt, st->hTdCngEnc->cng_exc2_buf, st->hTdCngEnc->cng_Qexc_buf, st->hTdCngEnc->cng_brate_buf, st->hTdCngEnc->ho_env_circ_fx, st->element_mode, st->hFdCngEnc->hFdCngCom->CngBandwidth );
+
+ /* encode CNG parameters */
+ CNG_enc_ivas_fx( st, Aq, inp, /*ener_fx,*/ lsp_mid, lsp_new, lsf_new_fx, &allow_cn_step, sub( Q_new, 1 ), q_env_fx, &sid_bw );
+
+ /* comfort noise generation */
+ CNG_exc_fx( st->core_brate, st->L_frame, &st->hTdCngEnc->Enew_fx, &st->hTdCngEnc->cng_seed, exc_fx, exc2_fx, &st->hTdCngEnc->lp_ener_fx, st->last_core_brate,
+ &st->hDtxEnc->first_CNG, &st->hTdCngEnc->cng_ener_seed, bwe_exc_fx, allow_cn_step, &st->hTdCngEnc->last_allow_cn_step, sub( st->prev_Q_new, 1 ), sub( Q_new, 1 ), st->hTdCngEnc->num_ho,
+ q_env_fx, st->hTdCngEnc->lp_env_fx, st->hTdCngEnc->old_env_fx, st->hTdCngEnc->exc_mem_fx, st->hTdCngEnc->exc_mem1_fx, &sid_bw, &st->hTdCngEnc->cng_ener_seed1, exc3_fx, st->Opt_AMR_WB, EVS_MONO );
+
+ Scale_sig( exc_fx, st->L_frame, 1 ); // Q_new + 1
+ }
+ ELSE
+ {
+ test();
+ IF( EQ_32( st->core_brate, SID_2k40 ) && NE_16( st->element_mode, IVAS_CPE_MDCT ) )
+ {
+ FdCng_encodeSID_ivas_fx( st );
+ st->hDtxEnc->last_CNG_L_frame = st->L_frame;
+ move16();
+ }
+
+ Word16 Q_cngNoise = Q31, zero_flag = 0;
+ move16();
+ move16();
+ FOR( Word16 j = 0; j < NPART; j++ )
+ {
+ IF( st->hFdCngEnc->hFdCngCom->cngNoiseLevel[j] != 0 )
+ {
+ zero_flag = 1;
+ move16();
+ BREAK;
+ }
+ }
+ IF( zero_flag )
+ {
+ Q_cngNoise = getScaleFactor32( st->hFdCngEnc->hFdCngCom->cngNoiseLevel, NPART );
+ }
+ Scale_sig32( st->hFdCngEnc->hFdCngCom->cngNoiseLevel, NPART, Q_cngNoise ); /* st->hFdCngEnc->hFdCngCom->cngNoiseLevelExp - Q_cngNoise */
+ st->hFdCngEnc->hFdCngCom->cngNoiseLevelExp = sub( st->hFdCngEnc->hFdCngCom->cngNoiseLevelExp, Q_cngNoise );
+ move16();
+
+ generate_comfort_noise_enc_ivas_fx( st, Q_new, 1 );
+ st->hTcxEnc->q_Txnq = Q_new;
+ move16();
+ Scale_sig( st->hFdCngEnc->hFdCngCom->A_cng, ( M + 1 ), sub( Q12, sub( 14, norm_s( st->hFdCngEnc->hFdCngCom->A_cng[0] ) ) ) ); /* Q12 */
+ FdCng_exc( st->hFdCngEnc->hFdCngCom, &st->hDtxEnc->CNG_mode, st->L_frame, st->lsp_old_fx, st->hDtxEnc->first_CNG, st->hDtxEnc->lspCNG_fx, Aq, lsp_new, lsf_new_fx, exc_fx, exc2_fx, bwe_exc_fx );
+ Copy( exc2_fx, exc3_fx, st->L_frame ); // Q_new
+
+ IF( EQ_32( st->core_brate, SID_2k40 ) )
+ {
+ IF( st->hTdCngEnc != NULL )
+ {
+ Word16 enr, enr_index;
+ enr = cng_energy_ivas_fx( st->element_mode, st->bwidth, st->hDtxEnc->CNG_mode, st->hTdCngEnc->CNG_att_fx, exc_fx, st->L_frame, Q_new ); /* Q8 */
+
+ /* calculate the energy quantization index */
+ enr_index = add( enr, 512 /* Q8(2.0) */ ); /* enr + 2.0 */
+ enr_index = extract_l( L_shr( L_mult0( enr_index, STEP_SID_FX ), 12 + 8 ) ); /* Q0 (8+12-(8+12)) */
+
+ /* limit the energy quantization index */
+ enr_index = s_min( enr_index, 127 ); /* Q0 */
+ enr_index = s_max( enr_index, 0 );
+ st->hTdCngEnc->old_enr_index = enr_index; /* Q0 */
+ move16();
+ }
+ }
+ }
+
+ /* Reset HO counter in the first SID frame */
+ if ( st->hTdCngEnc != NULL )
+ {
+ st->hTdCngEnc->burst_ho_cnt = 0;
+ move16();
+ }
+
+ Scale_sig( st->hLPDmem->mem_syn, M, sub( st->Q_syn, st->hLPDmem->q_mem_syn ) ); // st->Q_syn
+ Scale_sig( st->hLPDmem->mem_syn1_fx, M, sub( st->Q_syn, st->hLPDmem->q_mem_syn ) ); // st->Q_syn
+ Scale_sig( st->hLPDmem->mem_syn2, M, sub( st->Q_syn, st->hLPDmem->q_mem_syn ) ); // st->Q_syn
+ Scale_sig( st->hLPDmem->mem_syn3, M, sub( st->Q_syn, st->hLPDmem->q_mem_syn ) ); // st->Q_syn
+ Scale_sig( st->hLPDmem->mem_syn_r, L_SYN_MEM, sub( st->Q_syn, st->hLPDmem->q_mem_syn ) ); // st->Q_syn
+ st->hLPDmem->mem_w0 = shl_sat( st->hLPDmem->mem_w0, sub( st->Q_syn, st->hLPDmem->q_mem_syn ) ); // st->Q_syn
+ move16();
+ st->hLPDmem->q_mem_syn = st->Q_syn;
+ move16();
+
+ /* synthesis at 12.8kHz sampling rate */
+ syn_12k8_fx( st->L_frame, Aq, exc3_fx, syn1_fx, hLPDmem->mem_syn3, 1, sub( Q_new, 1 ), st->Q_syn );
+
+ /* reset the encoder */
+ CNG_reset_enc_fx( st, hLPDmem, pitch_buf, voice_factors_fx, 0 );
+
+ /* update st->mem_syn1_flt for ACELP core switching */
+ Copy( hLPDmem->mem_syn3, hLPDmem->mem_syn1_fx, M ); /* hLPDmem->q_mem_syn */
+
+ /* update ACELP core synthesis filter memory */
+ Copy( hLPDmem->mem_syn3, hLPDmem->mem_syn, M ); /* hLPDmem->q_mem_syn */
+
+ /* update old synthesis buffer - needed for ACELP internal sampling rate switching */
+ Copy( syn1_fx + sub( st->L_frame, L_SYN_MEM ), hLPDmem->mem_syn_r, L_SYN_MEM ); // st->Q_syn
+
+ /* save and delay synthesis to be used by SWB BWE */
+ IF( st->hBWE_FD != NULL )
+ {
+ st->hBWE_FD->mem_deemph_old_syn_fx = shl_sat( st->hBWE_FD->mem_deemph_old_syn_fx, sub( st->Q_syn, st->hBWE_FD->q_mem_deemph_old_syn ) ); /* st->Q_syn */
+ move16();
+ Scale_sig( st->hBWE_FD->old_syn_12k8_16k_fx, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ), sub( st->Q_syn, st->hBWE_FD->q_mem_deemph_old_syn ) ); /* st->Q_syn */
+ save_old_syn_fx( st->L_frame, syn1_fx, old_syn_12k8_16k, st->hBWE_FD->old_syn_12k8_16k_fx, st->preemph_fac, &st->hBWE_FD->mem_deemph_old_syn_fx );
+ *q_old_syn_12k8_16 = st->Q_syn;
+ move16();
+ st->hBWE_FD->q_mem_deemph_old_syn = st->Q_syn;
+ move16();
+ }
+
+ Scale_sig( st->hLPDmem->syn, M + 1, sub( st->Q_syn, st->hLPDmem->q_lpd_syn ) ); /* st->Q_syn */
+ st->hLPDmem->q_lpd_syn = st->Q_syn;
+ move16();
+
+ /*Update MODE2 core switching memory*/
+ deemph_fx( syn1_fx, st->preemph_fac, st->L_frame, &( hLPDmem->syn[M] ) );
+ Copy( syn1_fx + add( st->L_frame, -M - 1 ), hLPDmem->syn, M + 1 ); /* st->Q_syn */
+ }
+
+ /*----------------------------------------------------------------*
+ * Encoding of all other frames
+ *----------------------------------------------------------------*/
+ ELSE
+ {
+
+ /*-----------------------------------------------------------------*
+ * Configure ACELP bit allocation
+ *-----------------------------------------------------------------*/
+
+ Word16 temp = getScaleFactor16( st->hGSCEnc->last_exc_dct_in_fx, L_FRAME16k );
+ Scale_sig( st->hGSCEnc->last_exc_dct_in_fx, L_FRAME16k, temp ); /* Q_last_exc_dct_in + temp */
+ st->hGSCEnc->Q_last_exc_dct_in = add( st->hGSCEnc->Q_last_exc_dct_in, temp );
+ move16();
+ nb_bits = 0;
+ move16();
+ st->acelp_cfg.FEC_mode = 0;
+ move16();
+ uc_two_stage_flag = 0;
+ move16();
+
+ test();
+ IF( !nelp_mode && !ppp_mode )
+ {
+ 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 );
+ }
+
+ /*-----------------------------------------------------------------*
+ * After inactive period, use the most up-to-date ISPs
+ *-----------------------------------------------------------------*/
+
+ test();
+ test();
+ IF( st->hDtxEnc != NULL && ( st->last_core_brate == FRAME_NO_DATA || EQ_32( st->last_core_brate, SID_2k40 ) ) )
+ {
+ Copy( st->hDtxEnc->lspCNG_fx, st->lsp_old_fx, M ); // Q15
+ lsp2lsf_fx( st->hDtxEnc->lspCNG_fx, st->lsf_old_fx, M, int_fs );
+ }
+
+ /*-----------------------------------------------------------------*
+ * Reset higher ACELP pre-quantizer in case of switching
+ *-----------------------------------------------------------------*/
+
+ IF( !st->use_acelp_preq )
+ {
+ st->mem_deemp_preQ_fx = 0;
+ move16();
+ st->mem_preemp_preQ_fx = 0;
+ move16();
+ st->last_code_preq = 0;
+ move16();
+ st->last_nq_preQ = 0;
+ move16();
+ }
+ st->use_acelp_preq = 0;
+ move16();
+
+ /*-----------------------------------------------------------------*
+ * LSF Quantization
+ * A[z] calculation
+ *-----------------------------------------------------------------*/
+
+ /* SC-VBR & channel-aware mode - back-up memories for LSF quantizer and synthesis filter */
+ lsf_syn_mem_backup_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 );
+
+ IF( !tdm_lp_reuse_flag )
+ {
+ lsf_enc_ivas_fx( st, lsf_new_fx, lsp_new, lsp_mid, Aq, tdm_low_rate_mode, st->GSC_IVAS_mode, tdm_lsfQ_PCh, Q_new );
+ }
+ ELSE
+ {
+ const Word16 *pt_interp_2_fx;
+
+ IF( NE_16( st->active_cnt, 1 ) )
+ {
+ Word16 beta_index;
+ Word16 lsf_wgts_fx[M];
+
+ /* intra_frame prediction for the LSFs */
+ lsp2lsf_fx( lsp_new, lsf_new_fx, M, 12800 );
+
+ Unified_weighting_fx( &st->Bin_E_fx[L_FFT / 2], add( Q_new, ( QSCALE - 2 ) ), lsf_new_fx, lsf_wgts_fx, st->bwidth == NB, (Word16) EQ_16( st->coder_type, UNVOICED ), st->sr_core, M );
+
+ tdm_SCh_lsf_reuse_fx( ENC, st->element_brate, lsf_new_fx, lsp_new, tdm_lsfQ_PCh, lsf_wgts_fx, &beta_index );
+
+ push_indice( hBstr, IND_IC_LSF_PRED, beta_index, TDM_IC_LSF_PRED_BITS );
+ }
+
+ pt_interp_2_fx = interpol_frac_12k8_fx;
+
+ test();
+ if ( EQ_16( tdm_low_rate_mode, 1 ) && GT_16( st->coder_type, UNVOICED ) )
+ {
+ pt_interp_2_fx = interpol_frac2_fx; // Q15
+ }
+
+ IF( EQ_16( st->active_cnt, 1 ) )
+ {
+ Copy( lsp_new, st->lsp_old_fx, M ); // Q15
+ lsp2lsf_fx( lsp_new, st->lsf_old_fx, M, st->sr_core ); // Q x2.56
+ lsp2lsf_fx( lsp_new, lsf_new_fx, M, st->sr_core ); // Q x2.56
+ }
+
+ /* LSP interpolation and conversion of LSPs to A(z) */
+ int_lsp_fx( st->L_frame, st->lsp_old_fx, lsp_new, Aq, M, pt_interp_2_fx, 0 );
+
+ /* Check LSF stability (distance between old LSFs and current LSFs) */
+ st->stab_fac_fx = lsf_stab_fx( lsf_new_fx, st->lsf_old_fx, 0, st->L_frame ); // Q15
+ move16();
+ }
+ test();
+ IF( EQ_16( st->last_core, HQ_CORE ) && st->element_mode > EVS_MONO )
+ {
+ /* Prepare ACB memory from last HQ frame */
+ tmpF_fx = hLPDmem->old_exc[0];
+ 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 */
+ Residu3_fx( Aq, hLPDmem->old_exc, old_exc_fx, st->L_frame, 0 );
+ }
+
+ test();
+ IF( st->last_core != ACELP_CORE && st->element_mode > EVS_MONO )
+ {
+ /* Prepare ACB memory of old_bwe_exc */
+ IF( EQ_16( st->L_frame, L_FRAME ) )
+ {
+ lerp( old_exc_fx, old_bwe_exc_fx, L_EXC_MEM_DEC * HIBND_ACB_L_FAC, L_EXC_MEM_DEC );
+ }
+ ELSE
+ {
+ lerp( old_exc_fx, old_bwe_exc_fx, L_EXC_MEM_DEC * 2, L_EXC_MEM_DEC );
+ }
+ }
+
+ /*---------------------------------------------------------------*
+ * Calculation of LP residual (filtering through A[z] filter)
+ *---------------------------------------------------------------*/
+
+ calc_residu_fx( st, inp, res_fx, Aq );
+ calculate_hangover_attenuation_gain_ivas_fx( st, &att_fx, vad_hover_flag );
+
+ IF( NE_16( att_fx, 32767 /* ONE_IN_Q15 */ ) )
+ {
+ 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
+ *-----------------------------------------------------------------*/
+
+ IF( EQ_16( st->coder_type, TRANSITION ) )
+ {
+ tc_classif_enc_fx( Q_new, st->L_frame, &tc_subfr, &position, attack_flag, st->pitch[0], res_fx );
+
+ 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 );
+ }
+
+ /*---------------------------------------------------------------*
+ * Calculation of prediction for scaled innovation energy
+ * (for memory-less gain quantizer)
+ *---------------------------------------------------------------*/
+
+ IF( nb_bits > 0 )
+ {
+ Es_pred_enc_fx( &Es_pred_fx, &i, st->L_frame, res_fx, st->voicing_fx, nb_bits, uc_two_stage_flag, Q_new );
+ push_indice( hBstr, IND_ES_PRED, i, nb_bits );
+ }
+
+ /*------------------------------------------------------------*
+ * Encode excitation according to coding type
+ *------------------------------------------------------------*/
+ test();
+ test();
+ IF( tdm_low_rate_mode ) /* tdm stereo low rate mode */
+ {
+ IF( LE_16( st->coder_type, UNVOICED ) )
+ {
+ tdm_low_rate_enc( st, Aq, res_fx, syn_fx, exc_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, 0 /*attack_flag*/, lsf_new_fx, &tmp_noise_fx, Q_new );
+ }
+ ELSE /* GENERIC */
+ {
+ encod_gen_2sbfr( st, inp, Aw, Aq, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, Q_new, 0 );
+ }
+ }
+ ELSE IF( nelp_mode )
+ {
+ /* SC-VBR - NELP frames */
+ encod_nelp_ivas_fx( st, inp, Aw, Aq, res_fx, syn_fx, &tmp_noise_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, Q_new, 0 );
+ }
+
+ ELSE IF( EQ_16( st->coder_type, UNVOICED ) )
+ {
+ /* UNVOICED frames (Gauss. excitation) */
+ encod_unvoiced_ivas_fx( st, inp, Aw, Aq, Es_pred_fx, uc_two_stage_flag, res_fx, syn_fx, &tmp_noise_fx, exc_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, Q_new, 0 );
+ }
+ ELSE IF( EQ_16( st->coder_type, TRANSITION ) )
+ {
+ encod_tran_ivas_fx( st, inp, Aw, Aq, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, tc_subfr, position, unbits, 0, Q_new );
+ }
+ ELSE IF( ppp_mode )
+ {
+ /* SC-VBR - PPP frames */
+ IF( ( error = encod_ppp_ivas_fx( st, inp, Aw, Aq, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, Q_new, 0 ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+
+ IF( st->hSC_VBR->bump_up ) /* PPP failed, bump up */
+ {
+ /* 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 */
+ 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 );
+
+ /* redo LSF quantization */
+ lsf_enc_ivas_fx( st, lsf_new_fx, lsp_new, lsp_mid, Aq, tdm_low_rate_mode, 0, NULL, Q_new );
+
+ /* recalculation of LP residual (filtering through A[z] filter) */
+ calc_residu_fx( st, inp, res_fx, Aq );
+ st->hTdCngEnc->burst_ho_cnt = 0;
+ move16();
+ /* VOICED frames in SC-VBR */
+ encod_gen_voic_ivas_fx( st, inp, Aw, Aq, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, unbits, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, 0, Q_new );
+ }
+ }
+ ELSE IF( EQ_16( st->coder_type, AUDIO ) || ( st->coder_type == INACTIVE && st->inactive_coder_type_flag ) )
+ {
+ /* AUDIO and INACTIVE frames (coded by GSC technology) */
+ encod_audio_ivas_fx( st, inp, Aw, Aq, res_fx, syn_fx, exc_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, attack_flag, lsf_new_fx, &tmp_noise_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, Q_new, 0 );
+ }
+ ELSE
+ {
+ /* GENERIC, VOICED and INACTIVE frames (coded by AVQ technology) */
+ encod_gen_voic_ivas_fx( st, inp, Aw, Aq, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, unbits, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, 0, Q_new );
+ }
+
+ FOR( i = 0; i < NB_SUBFR16k; i++ )
+ {
+ Scale_sig( &Aq[i * ( M + 1 )], ( M + 1 ), sub( Q12, sub( Q14, norm_s( Aq[i * ( M + 1 )] ) ) ) ); // Q12
+ }
+
+ /* update mem_syn1_flt for ACELP core switching */
+ Copy( hLPDmem->mem_syn, hLPDmem->mem_syn1_fx, M ); // Q_syn
+
+ /* update old synthesis buffer - needed for ACELP internal sampling rate switching */
+ Copy( syn_fx + sub( st->L_frame, L_SYN_MEM ), hLPDmem->mem_syn_r, L_SYN_MEM ); // st->Q_syn
+
+ Scale_sig( syn_fx, L_FRAME16k, sub( st->Q_syn, Q_new - 1 ) ); // Q_syn
+ /* save and delay synthesis to be used by SWB BWE */
+ IF( st->hBWE_FD != NULL )
+ {
+ st->hBWE_FD->mem_deemph_old_syn_fx = shl_sat( st->hBWE_FD->mem_deemph_old_syn_fx, sub( s_min( st->Q_syn, st->hBWE_FD->q_mem_deemph_old_syn ), st->hBWE_FD->q_mem_deemph_old_syn ) ); // s_min( st->Q_syn, st->hBWE_FD->q_mem_deemph_old_syn )
+ move16();
+ Scale_sig( st->hBWE_FD->old_syn_12k8_16k_fx, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ), sub( s_min( st->Q_syn, st->hBWE_FD->q_mem_deemph_old_syn ), st->hBWE_FD->q_mem_deemph_old_syn ) ); // s_min( st->Q_syn, st->hBWE_FD->q_mem_deemph_old_syn )
+
+ save_old_syn_fx( st->L_frame, syn_fx, old_syn_12k8_16k, st->hBWE_FD->old_syn_12k8_16k_fx, st->preemph_fac, &st->hBWE_FD->mem_deemph_old_syn_fx );
+ *q_old_syn_12k8_16 = s_min( st->Q_syn, st->hBWE_FD->q_mem_deemph_old_syn );
+ move16();
+ st->hBWE_FD->q_mem_deemph_old_syn = s_min( st->Q_syn, st->hBWE_FD->q_mem_deemph_old_syn );
+ move16();
+ Scale_sig( syn_fx, st->L_frame, sub( st->Q_syn, s_min( st->Q_syn, st->hBWE_FD->q_mem_deemph_old_syn ) ) ); // st->Q_syn
+ }
+
+ /*Update MODE2 core switching memory*/
+ Copy( syn_fx, syn1_fx, st->L_frame ); // st->Q_syn
+
+ Scale_sig( st->hLPDmem->syn, M + 1, sub( st->Q_syn, st->hLPDmem->q_lpd_syn ) ); // st->Q_syn
+ st->hLPDmem->q_lpd_syn = st->Q_syn;
+ move16();
+
+ /*Update MODE2 core switching memory*/
+ deemph_fx( syn1_fx, st->preemph_fac, st->L_frame, &( hLPDmem->syn[M] ) );
+
+ Copy( syn1_fx + add( st->L_frame, -M - 1 ), hLPDmem->syn, M + 1 ); // st->Q_syn
+
+ test();
+ IF( st->element_mode > EVS_MONO && st->hTcxEnc != NULL )
+ {
+ Copy( syn1_fx + shr( st->L_frame, 1 ), st->hTcxEnc->Txnq, shr( st->L_frame, 1 ) ); // st->Q_syn
+#ifdef MSAN_FIX
+ Scale_sig( st->hTcxEnc->Txnq + shr( st->L_frame, 1 ), sub( L_FRAME32k / 2 + 64, shr( st->L_frame, 1 ) ), sub( st->Q_syn, st->hTcxEnc->q_Txnq ) ); // st->Q_syn
+#else
+ Scale_sig( st->hTcxEnc->Txnq + shr( st->L_frame, 1 ), sub( L_FRAME32k / 2 + 64, shr( st->L_frame, 2 ) ), sub( st->Q_syn, st->hTcxEnc->q_Txnq ) );
+#endif
+ st->hTcxEnc->q_Txnq = st->Q_syn;
+ move16();
+ }
+
+ /*--------------------------------------------------------------------------------------*
+ * Modify the excitation signal when the noise is stationary
+ *--------------------------------------------------------------------------------------*/
+ test();
+ test();
+ test();
+ test();
+ IF( !( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) ) && NE_16( nelp_mode, 1 ) && !( EQ_16( st->element_mode, IVAS_SCE ) && tdm_low_rate_mode ) )
+ {
+ /* exc2 buffer is needed only for updating of Aq[] which is needed for core switching */
+ Copy( exc_fx, exc2_fx, st->L_frame ); // Q_new
+
+ stat_noise_uv_enc_ivas_fx( st, epsP, lsp_new, lsp_mid, Aq, exc2_fx, uc_two_stage_flag, Q_new );
+ }
+
+ /*-----------------------------------------------------------------*
+ * Encode supplementary information for Frame Error Concealment
+ *-----------------------------------------------------------------*/
+
+ Scale_sig( syn_fx, L_FRAME, sub( s_min( st->Q_syn, Q_new ), st->Q_syn ) ); // min( st->Q_syn, Q_new )
+#ifdef MSAN_FIX
+ Scale_sig( res_fx, st->L_frame, sub( s_min( st->Q_syn, Q_new ), Q_new ) ); // min( st->Q_syn, Q_new )
+#else
+ Scale_sig( res_fx, L_FRAME16k, sub( s_min( st->Q_syn, Q_new ), Q_new ) );
+#endif
+ FEC_encode_ivas_fx( hBstr, st->acelp_cfg, syn_fx, st->coder_type, st->clas, pitch_buf, res_fx, &st->Last_pulse_pos, st->L_frame, st->total_brate, s_min( st->Q_syn, Q_new ) );
+ IF( st->hBWE_TD != NULL )
+ {
+ IF( EQ_16( st->L_frame, L_FRAME ) )
+ {
+ Copy( Aq + 2 * ( M + 1 ), st->hBWE_TD->cur_sub_Aq_fx, ( M + 1 ) ); // Q12
+ }
+ ELSE
+ {
+ Copy( Aq + 3 * ( M + 1 ), st->hBWE_TD->cur_sub_Aq_fx, ( M + 1 ) ); // Q12
+ }
+ }
+
+
+ } /* end of active inp coding */
+
+ /*-----------------------------------------------------------------*
+ * Write ACELP unused bits
+ *-----------------------------------------------------------------*/
+ test();
+ test();
+ IF( NE_32( st->core_brate, SID_2k40 ) && st->core_brate != FRAME_NO_DATA && NE_32( st->core_brate, PPP_NELP_2k80 ) )
+ {
+ nBits = st->acelp_cfg.ubits; // Q0
+ move16();
+ WHILE( nBits > 0 )
+ {
+ i = s_min( nBits, 16 ); // Q0
+ push_indice( hBstr, IND_UNUSED, 0, i );
+ nBits = sub( nBits, i ); // Q0
+ }
+ }
+
+ /*-----------------------------------------------------------------*
+ * Apply non linearity in case of SWB TBE
+ *-----------------------------------------------------------------*/
+
+ IF( st->hBWE_TD != NULL )
+ {
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( ( EQ_16( st->last_Opt_SC_VBR, 1 ) && st->Opt_SC_VBR == 0 ) || ( ( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, WB_TBE ) || EQ_16( st->extl, FB_TBE ) ) && NE_16( st->last_extl, SWB_TBE ) && NE_16( st->last_extl, WB_TBE ) && NE_16( st->last_extl, FB_TBE ) ) || ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) && !st->tdm_LRTD_flag ) )
+ {
+ st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0;
+ move16();
+ set16_fx( st->hBWE_TD->old_bwe_exc_extended_fx, 0, NL_BUFF_OFFSET );
+ }
+
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( !st->Opt_SC_VBR && ( st->idchan == 0 || NE_16( st->element_mode, IVAS_CPE_TD ) || ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) && st->tdm_LRTD_flag ) ) )
+ {
+ /* Apply a non linearity to the SHB excitation */
+#ifdef FIX_ISSUE_1237
+ Copy_Scale_sig_16_32_no_sat( st->hBWE_TD->old_bwe_exc_extended_fx, bwe_exc_extended_fx, NL_BUFF_OFFSET, ( sub( shl( Q_new, 1 ), sub( st->prev_Q_bwe_exc, 16 ) ) ) ); // prev_Q_bwe_exc
+#else
+ Copy_Scale_sig_16_32_DEPREC( st->hBWE_TD->old_bwe_exc_extended_fx, bwe_exc_extended_fx, NL_BUFF_OFFSET, ( sub( shl( Q_new, 1 ), sub( st->prev_Q_bwe_exc, 16 ) ) ) ); // prev_Q_bwe_exc
+#endif
+ non_linearity_ivas_fx( bwe_exc_fx, bwe_exc_extended_fx + NL_BUFF_OFFSET, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, Q_new, st->coder_type, voice_factors_fx, st->L_frame );
+ Copy_Scale_sig_32_16( bwe_exc_extended_fx + L_FRAME32k, st->hBWE_TD->old_bwe_exc_extended_fx, NL_BUFF_OFFSET, negate( sub( shl( Q_new, 1 ), sub( st->prev_Q_bwe_exc, 16 ) ) ) ); // prev_Q_bwe_exc
+ }
+
+ test();
+ if ( EQ_32( st->core_brate, SID_2k40 ) || st->core_brate == FRAME_NO_DATA )
+ {
+ st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0;
+ move16();
+ }
+ }
+
+ /*-----------------------------------------------------------------*
+ * Updates
+ *-----------------------------------------------------------------*/
+
+ if ( st->hBWE_TD != NULL )
+ {
+ st->Q_exc = Q_new;
+ move16();
+ }
+
+ updt_enc_fx( st, old_exc_fx, pitch_buf, Es_pred_fx, Aq, lsf_new_fx, lsp_new, old_bwe_exc_fx );
+ st->hLPDmem->q_lpd_old_exc = Q_new;
+ move16();
+
+ test();
+ test();
+ IF( st->hTdCngEnc != NULL && st->Opt_DTX_ON && GT_32( st->core_brate, SID_2k40 ) )
+ {
+ /* update CNG parameters in active frames */
+ Word16 q_exc = st->hTdCngEnc->cng_Qexc_buf[0];
+ move16();
+ FOR( Word16 ii = 0; ii < HO_HIST_SIZE; ii++ )
+ {
+ q_exc = s_min( q_exc, st->hTdCngEnc->cng_Qexc_buf[ii] );
+ }
+ q_exc = s_min( q_exc, Q_new );
+
+ Scale_sig( exc_fx, L_EXC - L_EXC_MEM, sub( q_exc, Q_new ) ); // q_exc
+ FOR( Word16 ii = 0; ii < HO_HIST_SIZE; ii++ )
+ {
+ Scale_sig( st->hTdCngEnc->cng_exc2_buf + ii * L_FFT, L_FFT, sub( q_exc, st->hTdCngEnc->cng_Qexc_buf[ii] ) ); // Q_exc
+ st->hTdCngEnc->cng_Qexc_buf[ii] = q_exc;
+ move16();
+ }
+ cng_params_upd_ivas_fx( lsp_new, exc_fx, st->L_frame, &st->hTdCngEnc->ho_circ_ptr, st->hTdCngEnc->ho_ener_circ_fx,
+ &st->hTdCngEnc->ho_circ_size, st->hTdCngEnc->ho_lsp_circ_fx, q_exc, ENC, st->hTdCngEnc->ho_env_circ_fx, &st->hTdCngEnc->cng_buf_cnt,
+ st->hTdCngEnc->cng_exc2_buf, st->hTdCngEnc->cng_Qexc_buf, st->hTdCngEnc->cng_brate_buf, st->hDtxEnc->last_active_brate, st->element_mode,
+ st->hFdCngEnc->hFdCngCom->CngBandwidth );
+
+ IF( EQ_16( st->L_frame, L_FRAME ) )
+ {
+ /* store LSPs@16k, potentially to be used in CNG@16k */
+ Copy( st->lsp_old16k_fx, &( st->hTdCngEnc->ho_lsp_circ2_fx[( st->hTdCngEnc->ho_circ_ptr ) * M] ), M ); // Q15
+ }
+
+ /* set LSP@16k flag for the first buffer */
+ IF( EQ_16( st->L_frame, L_FRAME ) )
+ {
+ st->hTdCngEnc->ho_16k_lsp[st->hTdCngEnc->ho_circ_ptr] = 0;
+ }
+ ELSE
+ {
+ st->hTdCngEnc->ho_16k_lsp[st->hTdCngEnc->ho_circ_ptr] = 1;
+ }
+ move16();
+ /* efficient DTX hangover control */
+ IF( GT_16( st->hTdCngEnc->burst_ho_cnt, 1 ) )
+ {
+ dtx_hangover_control_fx( st, lsp_new );
+ }
+ }
+
+ /* SC-VBR update of average data rate */
+ IF( EQ_16( st->vad_flag, 1 ) )
+ {
+ /* reset in case of bitrate switching in EVS */
+ if ( st->hSC_VBR != NULL )
+ {
+ update_average_rate_fx( st->hSC_VBR, st->core_brate );
+ }
+ }
+ pop_wmops();
+
+ return error;
+}
diff --git a/lib_enc/acelp_core_switch_enc.c b/lib_enc/acelp_core_switch_enc.c
deleted file mode 100644
index 9d6f499db09e405ecf613f29cb1442072afc3305..0000000000000000000000000000000000000000
--- a/lib_enc/acelp_core_switch_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_enc.h"
-#include "rom_com.h"
-#include "prot.h"
-#include "wmc_auto.h"
diff --git a/lib_enc/acelp_core_switch_enc_fx.c b/lib_enc/acelp_core_switch_enc_fx.c
index 029e3083ea893830d663c161a859cc83aa2943f9..d521d85a2a936d26c414194cc94c94160004fdfd 100644
--- a/lib_enc/acelp_core_switch_enc_fx.c
+++ b/lib_enc/acelp_core_switch_enc_fx.c
@@ -71,11 +71,11 @@ void acelp_core_switch_enc_fx(
move16(); /* pointer to excitation signal in the current frame */
Copy( hLPDmem->old_exc, old_exc, L_EXC_MEM ); /*now old_exc has the same scaling as st_fx->old_exc; need to change later? */
- Copy( st_fx->old_Aq_12_8_fx, Aq, M + 1 );
- Copy( st_fx->old_Aq_12_8_fx, Aq + ( M + 1 ), M + 1 );
- T_op[0] = st_fx->pitch[0];
+ Copy( st_fx->old_Aq_12_8_fx, Aq, M + 1 ); /* Q12 */
+ Copy( st_fx->old_Aq_12_8_fx, Aq + ( M + 1 ), M + 1 ); /* Q12 */
+ T_op[0] = st_fx->pitch[0]; /* Q0 */
move16();
- T_op[1] = st_fx->pitch[1];
+ T_op[1] = st_fx->pitch[1]; /* Q0 */
move16();
/*----------------------------------------------------------------*
@@ -84,7 +84,7 @@ void acelp_core_switch_enc_fx(
IF( EQ_16( st_fx->last_L_frame, L_FRAME ) ) /* ACELP@12k8 core */
{
- inp = inp12k8;
+ inp = inp12k8; /* Q0 */
IF( GT_32( st_fx->core_brate, ACELP_24k40 ) )
{
@@ -97,7 +97,7 @@ void acelp_core_switch_enc_fx(
}
ELSE /* ACELP@16k core */
{
- inp = inp16k;
+ inp = inp16k; /* Q0 */
IF( LE_32( st_fx->core_brate, ACELP_8k00 ) )
{
@@ -139,9 +139,9 @@ void acelp_core_switch_enc_fx(
#else
IF( NE_16( st_fx->last_L_frame, L_FRAME ) )
{
- T_op[0] = shr( add( round_fx( L_shl( L_mult( 20480, T_op[0] ), 2 ) ), 1 ), 1 );
+ T_op[0] = shr( add( round_fx( L_shl( L_mult( 20480, T_op[0] ), 2 ) ), 1 ), 1 ); /* Q0 */
move16();
- T_op[1] = shr( add( round_fx( L_shl( L_mult( 20480, T_op[1] ), 2 ) ), 1 ), 1 );
+ T_op[1] = shr( add( round_fx( L_shl( L_mult( 20480, T_op[1] ), 2 ) ), 1 ), 1 ); /* Q0 */
move16();
}
#endif
@@ -170,11 +170,11 @@ void acelp_core_switch_enc_fx(
#else
FOR( i = 0; i < 20; i++ )
{
- hBstr->ind_list[IND_CORE_SWITCHING_CELP_SUBFRAME + i].value = hBstr->ind_list[TAG_ACELP_SUBFR_LOOP_START + i].value;
+ hBstr->ind_list[IND_CORE_SWITCHING_CELP_SUBFRAME + i].value = hBstr->ind_list[TAG_ACELP_SUBFR_LOOP_START + i].value; /* Q0 */
move16();
- hBstr->ind_list[IND_CORE_SWITCHING_CELP_SUBFRAME + i].nb_bits = hBstr->ind_list[TAG_ACELP_SUBFR_LOOP_START + i].nb_bits;
+ hBstr->ind_list[IND_CORE_SWITCHING_CELP_SUBFRAME + i].nb_bits = hBstr->ind_list[TAG_ACELP_SUBFR_LOOP_START + i].nb_bits; /* Q0 */
move16();
- hBstr->ind_list[TAG_ACELP_SUBFR_LOOP_START + i].nb_bits = -1;
+ hBstr->ind_list[TAG_ACELP_SUBFR_LOOP_START + i].nb_bits = -1; /* Q0 */
move16();
}
#endif
@@ -218,11 +218,11 @@ void acelp_core_switch_enc_ivas_fx(
move16(); /* pointer to excitation signal in the current frame */
Copy( hLPDmem->old_exc, old_exc, L_EXC_MEM ); /*now old_exc has the same scaling as st_fx->old_exc; need to change later? */
- Copy( st_fx->old_Aq_12_8_fx, Aq, M + 1 );
- Copy( st_fx->old_Aq_12_8_fx, Aq + ( M + 1 ), M + 1 );
- T_op[0] = st_fx->pitch[0];
+ Copy( st_fx->old_Aq_12_8_fx, Aq, M + 1 ); /* Q12 */
+ Copy( st_fx->old_Aq_12_8_fx, Aq + ( M + 1 ), M + 1 ); /* Q12 */
+ T_op[0] = st_fx->pitch[0]; /* Q12 */
move16();
- T_op[1] = st_fx->pitch[1];
+ T_op[1] = st_fx->pitch[1]; /* Q12 */
move16();
/*----------------------------------------------------------------*
@@ -231,7 +231,7 @@ void acelp_core_switch_enc_ivas_fx(
IF( EQ_16( st_fx->last_L_frame, L_FRAME ) ) /* ACELP@12k8 core */
{
- inp = inp12k8;
+ inp = inp12k8; /* Q0 */
IF( GT_32( st_fx->core_brate, ACELP_24k40 ) )
{
@@ -244,7 +244,7 @@ void acelp_core_switch_enc_ivas_fx(
}
ELSE /* ACELP@16k core */
{
- inp = inp16k;
+ inp = inp16k; /* Q0 */
IF( LE_32( st_fx->core_brate, ACELP_8k00 ) )
{
@@ -256,15 +256,15 @@ void acelp_core_switch_enc_ivas_fx(
}
ELSE
{
- cbrate = L_min( st_fx->core_brate, ACELP_22k60 );
+ cbrate = L_min( st_fx->core_brate, ACELP_22k60 ); /* Q0 */
}
}
IF( NE_16( st_fx->last_L_frame, L_FRAME ) )
{
- T_op[0] = shr( add( round_fx( L_shl( L_mult( 20480, T_op[0] ), 2 ) ), 1 ), 1 );
+ T_op[0] = shr( add( round_fx( L_shl( L_mult( 20480 /* 1.25 in Q14 */, T_op[0] ), 2 ) ), 1 ), 1 ); /* Q0 */
move16();
- T_op[1] = shr( add( round_fx( L_shl( L_mult( 20480, T_op[1] ), 2 ) ), 1 ), 1 );
+ T_op[1] = shr( add( round_fx( L_shl( L_mult( 20480 /* 1.25 in Q14 */, T_op[1] ), 2 ) ), 1 ), 1 ); /* Q0 */
move16();
}
@@ -280,7 +280,7 @@ void acelp_core_switch_enc_ivas_fx(
* bit-stream: modify the layer of sub frame CELP
*----------------------------------------------------------------*/
- i = find_indice( hBstr, TAG_ACELP_SUBFR_LOOP_START, &value, &nb_bits );
+ i = find_indice( hBstr, TAG_ACELP_SUBFR_LOOP_START, &value, &nb_bits ); /* Q0 */
while ( hBstr->ind_list[i].id == TAG_ACELP_SUBFR_LOOP_START )
{
@@ -312,13 +312,13 @@ void acelp_core_switch_enc_ivas_fx(
static void encod_gen_voic_core_switch_fx(
Encoder_State *st_fx, /* i/o: state structure */
- const Word16 L_frame, /* i : length of the frame */
- const Word16 inp[], /* i : input signal */
- const Word16 Aq[], /* i : LP coefficients */
- const Word16 A[], /* i : unquantized A(z) filter */
- const Word16 T_op[], /* i : open loop pitch */
- Word16 *exc, /* i/o: current non-enhanced excitation */
- const Word32 core_bitrate, /* i : switching frame bitrate */
+ const Word16 L_frame, /* i : length of the frame Q0*/
+ const Word16 inp[], /* i : input signal Q0*/
+ const Word16 Aq[], /* i : LP coefficients Q12*/
+ const Word16 A[], /* i : unquantized A(z) filter Q12*/
+ const Word16 T_op[], /* i : open loop pitch Q0*/
+ Word16 *exc, /* i/o: current non-enhanced excitation Q_exc*/
+ const Word32 core_bitrate, /* i : switching frame bitrate Q0*/
Word16 shift,
Word16 Q_new )
{
@@ -396,7 +396,7 @@ static void encod_gen_voic_core_switch_fx(
hTdCngEnc->burst_ho_cnt = 0;
move16();
- st_fx->L_frame = tmp16;
+ st_fx->L_frame = tmp16; /* Q0 */
move16();
/*------------------------------------------------------------------*
@@ -404,7 +404,7 @@ static void encod_gen_voic_core_switch_fx(
*------------------------------------------------------------------*/
- Copy( res, exc, L_SUBFR );
+ Copy( res, exc, L_SUBFR ); /* Q1 */
IF( EQ_16( L_frame, L_FRAME16k ) )
{
@@ -422,7 +422,7 @@ static void encod_gen_voic_core_switch_fx(
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 );
+ Scale_sig( xn, L_SUBFR, shift ); /* Q_new */
/*----------------------------------------------------------------*
* Close-loop pitch search and quantization
@@ -430,7 +430,7 @@ static void encod_gen_voic_core_switch_fx(
*----------------------------------------------------------------*/
set16_fx( dummyF, -1, NB_SUBFR16k ); /* hack to signal ACELP->HQ switching frame */
pitch = pit_encode_fx( hBstr,
- st_fx->acelp_cfg.pitch_bits, core_bitrate, 0, L_frame, GENERIC, &pitch_limit_flag, 0, exc, L_SUBFR, T_op, &T0_min, &T0_max, &T0, &T0_frac, h1, xn, 0 /*hStereoTD->tdm_Pitch_reuse_flag*/, dummyF /*hStereoTD->tdm_Pri_pitch_buf*/ );
+ st_fx->acelp_cfg.pitch_bits, core_bitrate, 0, L_frame, GENERIC, &pitch_limit_flag, 0, exc, L_SUBFR, T_op, &T0_min, &T0_max, &T0, &T0_frac, h1, xn, 0 /*hStereoTD->tdm_Pitch_reuse_flag*/, dummyF /*hStereoTD->tdm_Pri_pitch_buf*/ ); /* Q6 */
/*-----------------------------------------------------------------*
* Find adaptive exitation
@@ -443,13 +443,13 @@ static void encod_gen_voic_core_switch_fx(
* or in case of floating point encoder & fixed p. decoder
*-----------------------------------------------------------------*/
- clip_gain = gp_clip_fx( st_fx->element_mode, core_bitrate, st_fx->voicing_fx, 0, GENERIC, xn, st_fx->clip_var_fx, sub( shift_wsp, 1 ) );
+ clip_gain = gp_clip_fx( st_fx->element_mode, core_bitrate, st_fx->voicing_fx, 0, GENERIC, xn, st_fx->clip_var_fx, sub( shift_wsp, 1 ) ); /* Q0 */
/*-----------------------------------------------------------------*
* LP filtering of the adaptive excitation, codebook target computation
*-----------------------------------------------------------------*/
- lp_flag = st_fx->acelp_cfg.ltf_mode;
- lp_select = lp_filt_exc_enc_fx( MODE1, GENERIC, 0, exc, h1, xn, y1, xn2, L_SUBFR, L_frame, g_corr, clip_gain, &gain_pit, &lp_flag );
+ lp_flag = st_fx->acelp_cfg.ltf_mode; /* Q0 */
+ lp_select = lp_filt_exc_enc_fx( MODE1, GENERIC, 0, exc, h1, xn, y1, xn2, L_SUBFR, L_frame, g_corr, clip_gain, &gain_pit, &lp_flag ); /* Q0 */
IF( EQ_16( lp_flag, NORMAL_OPERATION ) )
{
@@ -480,7 +480,7 @@ static void encod_gen_voic_core_switch_fx(
gp_clip_test_gain_pit_fx( st_fx->element_mode, core_bitrate, gain_pit, st_fx->clip_var_fx );
Lgcode = L_shl( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/
- gcode16 = round_fx( Lgcode );
+ gcode16 = round_fx( Lgcode ); /* Q0 */
hLPDmem->tilt_code = Est_tilt2( exc + 0, gain_pit, code, gain_code, &voice_fac, shift );
@@ -491,18 +491,11 @@ static void encod_gen_voic_core_switch_fx(
FOR( i = 0; i < L_SUBFR; i++ )
{
/* code in Q9, gain_pit in Q14 */
- L_tmp = L_mult( gcode16, code[i] );
-#ifdef BASOP_NOGLOB
- L_tmp = L_shl_sat( L_tmp, 5 );
+ 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], gain_pit );
- L_tmp = L_shl_sat( L_tmp, 1 ); /* saturation can occur here */
- exc[i] = round_fx_sat( L_tmp );
-#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
+ L_tmp = L_shl_sat( L_tmp, 1 ); /* saturation can occur here */
+ exc[i] = round_fx_sat( L_tmp ); /* Q_exc */
}
/* write reserved bits */
@@ -519,11 +512,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 ) );
-#else
- exc[i] = round_fx( L_shl( L_mult( exc[i], gain_pit ), 1 ) );
-#endif
+ exc[i] = round_fx_sat( L_shl_sat( L_mult_sat( exc[i], gain_pit ), 1 ) ); /* Q_exc */
}
return;
@@ -531,13 +520,13 @@ static void encod_gen_voic_core_switch_fx(
static void encod_gen_voic_core_switch_ivas_fx(
Encoder_State *st_fx, /* i/o: state structure */
- const Word16 L_frame, /* i : length of the frame */
- const Word16 inp[], /* i : input signal */
- const Word16 Aq[], /* i : LP coefficients */
- const Word16 A[], /* i : unquantized A(z) filter */
- const Word16 T_op[], /* i : open loop pitch */
- Word16 *exc, /* i/o: current non-enhanced excitation */
- const Word32 core_bitrate, /* i : switching frame bitrate */
+ const Word16 L_frame, /* i : length of the frame Q0*/
+ const Word16 inp[], /* i : input signal Q0*/
+ const Word16 Aq[], /* i : LP coefficients Q12*/
+ const Word16 A[], /* i : unquantized A(z) filter Q12*/
+ const Word16 T_op[], /* i : open loop pitch Q0*/
+ Word16 *exc, /* i/o: current non-enhanced excitation Q_exc*/
+ const Word32 core_bitrate, /* i : switching frame bitrate Q0*/
Word16 shift,
Word16 Q_new )
{
@@ -607,14 +596,14 @@ static void encod_gen_voic_core_switch_ivas_fx(
* Calculation of LP residual (filtering through A[z] filter)
*------------------------------------------------------------------*/
- tmp16 = st_fx->L_frame;
+ tmp16 = st_fx->L_frame; /* Q0 */
move16();
st_fx->L_frame = L_SUBFR;
move16();
calc_residu_fx( st_fx, inp, res, Aq );
// hTdCngEnc->burst_ho_cnt = 0;
- st_fx->L_frame = tmp16;
+ st_fx->L_frame = tmp16; /* Q0 */
move16();
/*------------------------------------------------------------------*
@@ -622,7 +611,7 @@ static void encod_gen_voic_core_switch_ivas_fx(
*------------------------------------------------------------------*/
- Copy( res, exc, L_SUBFR );
+ Copy( res, exc, L_SUBFR ); /* Q_exc */
IF( EQ_16( L_frame, L_FRAME16k ) )
{
@@ -640,7 +629,7 @@ static void encod_gen_voic_core_switch_ivas_fx(
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 );
+ Scale_sig( xn, L_SUBFR, shift ); /* Q_new */
/*----------------------------------------------------------------*
* Close-loop pitch search and quantization
@@ -648,7 +637,7 @@ static void encod_gen_voic_core_switch_ivas_fx(
*----------------------------------------------------------------*/
set16_fx( dummyF, -1, NB_SUBFR16k ); /* hack to signal ACELP->HQ switching frame */
pitch = pit_encode_ivas_fx( hBstr,
- st_fx->acelp_cfg.pitch_bits, core_bitrate, 0, L_frame, GENERIC, &pitch_limit_flag, 0, exc, L_SUBFR, T_op, &T0_min, &T0_max, &T0, &T0_frac, h1, xn, 0 /*hStereoTD->tdm_Pitch_reuse_flag*/, dummyF /*hStereoTD->tdm_Pri_pitch_buf*/ );
+ st_fx->acelp_cfg.pitch_bits, core_bitrate, 0, L_frame, GENERIC, &pitch_limit_flag, 0, exc, L_SUBFR, T_op, &T0_min, &T0_max, &T0, &T0_frac, h1, xn, 0 /*hStereoTD->tdm_Pitch_reuse_flag*/, dummyF /*hStereoTD->tdm_Pri_pitch_buf*/ ); /* Q6 */
/*-----------------------------------------------------------------*
* Find adaptive exitation
@@ -661,13 +650,13 @@ static void encod_gen_voic_core_switch_ivas_fx(
* or in case of floating point encoder & fixed p. decoder
*-----------------------------------------------------------------*/
- clip_gain = gp_clip_fx( st_fx->element_mode, core_bitrate, st_fx->voicing_fx, 0, GENERIC, xn, st_fx->clip_var_fx, sub( shift_wsp, 1 ) );
+ clip_gain = gp_clip_fx( st_fx->element_mode, core_bitrate, st_fx->voicing_fx, 0, GENERIC, xn, st_fx->clip_var_fx, sub( shift_wsp, 1 ) ); /* Q0 */
/*-----------------------------------------------------------------*
* LP filtering of the adaptive excitation, codebook target computation
*-----------------------------------------------------------------*/
- lp_flag = st_fx->acelp_cfg.ltf_mode;
- lp_select = lp_filt_exc_enc_ivas_fx( MODE1, GENERIC, 0, exc, h1, xn, y1, xn2, L_SUBFR, L_frame, g_corr, clip_gain, &gain_pit, &lp_flag );
+ lp_flag = st_fx->acelp_cfg.ltf_mode; /* Q0 */
+ lp_select = lp_filt_exc_enc_ivas_fx( MODE1, GENERIC, 0, exc, h1, xn, y1, xn2, L_SUBFR, L_frame, g_corr, clip_gain, &gain_pit, &lp_flag ); /* Q0 */
IF( EQ_16( lp_flag, NORMAL_OPERATION ) )
{
@@ -698,11 +687,11 @@ static void encod_gen_voic_core_switch_ivas_fx(
gp_clip_test_gain_pit_fx( st_fx->element_mode, core_bitrate, gain_pit, st_fx->clip_var_fx );
Lgcode = L_shl( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/
- gcode16 = round_fx( Lgcode );
+ gcode16 = round_fx( Lgcode ); /* Q0 */
// hLPDmem->tilt_code = Est_tilt2( exc + 0, gain_pit, code, gain_code, &voice_fac, shift );
// Q_new or shift ?? ->Qexc
- hLPDmem->tilt_code = est_tilt_ivas_fx( exc + 0, gain_pit, code, gain_code, &voice_fac, Q_new, L_SUBFR, 0 );
+ hLPDmem->tilt_code = est_tilt_ivas_fx( exc + 0, gain_pit, code, gain_code, &voice_fac, Q_new, L_SUBFR, 0 ); /* Q15 */
move16();
/*-----------------------------------------------------------------*
* Construct adaptive part of the excitation
@@ -711,18 +700,11 @@ static void encod_gen_voic_core_switch_ivas_fx(
FOR( i = 0; i < L_SUBFR; i++ )
{
/* code in Q9, gain_pit in Q14 */
- L_tmp = L_mult( gcode16, code[i] );
-#ifdef BASOP_NOGLOB
- L_tmp = L_shl_sat( L_tmp, 5 );
+ 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], gain_pit );
- L_tmp = L_shl_sat( L_tmp, 1 ); /* saturation can occur here */
- exc[i] = round_fx_sat( L_tmp );
-#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
+ L_tmp = L_shl_sat( L_tmp, 1 ); /* saturation can occur here */
+ exc[i] = round_fx_sat( L_tmp ); /* Q_exc */
move16();
}
@@ -740,11 +722,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 ) );
-#else
- exc[i] = round_fx( L_shl( L_mult( exc[i], gain_pit ), 1 ) );
-#endif
+ exc[i] = round_fx_sat( L_shl_sat( L_mult_sat( exc[i], gain_pit ), 1 ) ); /* Q_exc */
move16();
}
@@ -780,45 +758,47 @@ static void bwe_switch_enc_fx(
BSTR_ENC_HANDLE hBstr;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
hBstr = st_fx->hBstr;
L = NS2SA_FX2( st_fx->input_Fs, FRAME_SIZE_NS );
/* set multiplication factor according to the sampling rate */
- tmp = extract_l( L_shr( st_fx->input_Fs, 14 ) );
- delta_fx = add( tmp, 1 );
+ tmp = extract_l( L_shr( st_fx->input_Fs, 14 ) ); /* Q0 */
+ delta_fx = add( tmp, 1 ); /* Q0 */
Fs_kHz = shl( delta_fx, 4 );
tmp = add( tmp, i_mult2( 3, ( sub( st_fx->last_L_frame, L_FRAME ) != 0 ) ) );
- ptmp = fpointers_tab[tmp];
+ ptmp = fpointers_tab[tmp]; /* Q15 */
move16();
- hp_filter_fx = ptmp;
- fdelay_fx = i_mult2( 16, delta_fx );
+ hp_filter_fx = ptmp; /* Q15 */
+ fdelay_fx = i_mult2( 16, delta_fx ); /* Q0 */
IF( EQ_16( st_fx->last_L_frame, L_FRAME ) )
{
- fdelay_fx = i_mult2( 20, delta_fx );
+ fdelay_fx = i_mult2( 20, delta_fx ); /* Q0 */
}
- n = i_mult2( N16_CORE_SW, delta_fx );
+ n = i_mult2( N16_CORE_SW, delta_fx ); /* Q0 */
set16_fx( tmp_mem_fx, 0, 2 * L_FILT48k );
set16_fx( tmp_mem2_fx, 0, 2 * L_FILT48k );
- Loverlapp_fx = i_mult2( delta_fx, SWITCH_OVERLAP_8k * 2 );
- gapsize_fx = i_mult2( delta_fx, NS2SA( 16000, SWITCH_GAP_LENGTH_NS ) );
+ Loverlapp_fx = i_mult2( delta_fx, SWITCH_OVERLAP_8k * 2 ); /* Q0 */
+ gapsize_fx = i_mult2( delta_fx, NS2SA( 16000, SWITCH_GAP_LENGTH_NS ) ); /* Q0 */
shift = sub( add( add( shr( L, 1 ), n ), Loverlapp_fx ), gapsize_fx );
- Copy( new_speech_fx + shift, synth_subfr_bwe_fx, add( gapsize_fx, fdelay_fx ) );
- Copy( new_speech_fx + sub( shift, fdelay_fx ), tmp_mem_fx, fdelay_fx );
+ Copy( new_speech_fx + shift, synth_subfr_bwe_fx, add( gapsize_fx, fdelay_fx ) ); /* Q0 */
+ Copy( new_speech_fx + sub( shift, fdelay_fx ), tmp_mem_fx, fdelay_fx ); /* Q0 */
- tmp = add( gapsize_fx, fdelay_fx );
- fir_fx( synth_subfr_bwe_fx, hp_filter_fx, synth_subfr_bwe_fx, tmp_mem_fx, tmp, fdelay_fx, 1, 0 );
- Copy( synth_subfr_bwe_fx + shr( fdelay_fx, 1 ), synth_subfr_bwe_fx, sub( gapsize_fx, shr( fdelay_fx, 1 ) ) );
+ tmp = add( gapsize_fx, fdelay_fx ); /* Q0 */
+ fir_fx( synth_subfr_bwe_fx, hp_filter_fx, synth_subfr_bwe_fx, tmp_mem_fx, tmp, fdelay_fx, 1, 0 ); /* Q0 */
+ Copy( synth_subfr_bwe_fx + shr( fdelay_fx, 1 ), synth_subfr_bwe_fx, sub( gapsize_fx, shr( fdelay_fx, 1 ) ) ); /* Q0 */
- tmp = i_mult2( Fs_kHz, 10 );
+ tmp = i_mult2( Fs_kHz, 10 ); /* Q0 */
fir_fx( new_speech_fx, hp_filter_fx, hb_synth_tmp_fx, tmp_mem2_fx, tmp, fdelay_fx, 1, 0 );
- min_sq_cross_fx = L_negate( 1 );
+ min_sq_cross_fx = -1;
+ move32();
Qsq = 0;
move16();
min_corr_fx = 0;
@@ -828,15 +808,15 @@ static void bwe_switch_enc_fx(
d1m_fx = 0;
move16();
- maxd1_fx = sub( tmp, add( gapsize_fx, fdelay_fx ) );
+ maxd1_fx = sub( tmp, add( gapsize_fx, fdelay_fx ) ); /* Q0 */
IF( EQ_16( delta_fx, 2 ) )
{
- maxd1_fx = shr( maxd1_fx, 1 );
+ maxd1_fx = shr( maxd1_fx, 1 ); /* Q0 */
}
ELSE IF( EQ_16( delta_fx, 3 ) )
{
- maxd1_fx = extract_h( L_mult( maxd1_fx, 10923 ) );
+ maxd1_fx = extract_h( L_mult( maxd1_fx, 10923 /* 0.333 in Q15 */ ) ); /* Q0 */
}
/* find delay */
@@ -870,21 +850,23 @@ static void bwe_switch_enc_fx(
push_indice_fx( hBstr, IND_CORE_SWITCHING_AUDIO_DELAY, d1m_fx, AUDIODELAYBITS );
- tmp = add( i_mult2( d1m_fx, delta_fx ), fdelay_fx );
- ptmp = &hb_synth_tmp_fx[tmp];
+ tmp = add( i_mult2( d1m_fx, delta_fx ), fdelay_fx ); /* Q0 */
+ ptmp = &hb_synth_tmp_fx[tmp]; /* Q0 */
move16();
E1_fx = dotprod_satcont( synth_subfr_bwe_fx, synth_subfr_bwe_fx, 0, 0, &q_tmp1, gapsize_fx, 1 );
E2_fx = dotprod_satcont( ptmp, ptmp, 0, 0, &q_tmp2, gapsize_fx, 1 );
IF( !E1_fx )
{
- E1_fx = shl( 1, 14 );
+ E1_fx = 1 << 14;
+ move16();
q_tmp1 = 14;
move16();
}
IF( !E2_fx )
{
- E2_fx = shl( 1, 14 );
+ E2_fx = 1 << 14;
+ move16();
q_tmp2 = 14;
move16();
}
@@ -893,12 +875,8 @@ 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
- ind1_fx = usquant_fx( gain_fx, &gain_fx, shr( MINVALUEOFFIRSTGAIN_FX, 1 ), shr( DELTAOFFIRSTGAIN_FX, 4 ), ( 1 << NOOFGAINBITS1 ) );
+ 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 );
return;
@@ -1040,11 +1018,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 );
@@ -1052,7 +1026,15 @@ static void bwe_switch_enc_ivas_fx(
}
-static Word16 dotprod_satcont( const Word16 *x, const Word16 *y, Word16 qx, Word16 qy, Word16 *qo, Word16 len, Word16 delta )
+static Word16 dotprod_satcont(
+ const Word16 *x, /* qx */
+ const Word16 *y, /* qy */
+ Word16 qx,
+ Word16 qy,
+ Word16 *qo,
+ Word16 len, /* Q0 */
+ Word16 delta /* Q0 */
+)
{
Word16 tmp_tabx[L_FRAME48k], tmp_taby[L_FRAME48k];
Word16 shift, q, ener, i;
@@ -1061,8 +1043,8 @@ static Word16 dotprod_satcont( const Word16 *x, const Word16 *y, Word16 qx, Word
Flag Overflow = 0;
#endif
- Copy( x, tmp_tabx, len );
- Copy( y, tmp_taby, len );
+ Copy( x, tmp_tabx, len ); /* qx */
+ Copy( y, tmp_taby, len ); /* qy */
shift = 0;
move16();
DO
@@ -1072,20 +1054,16 @@ static Word16 dotprod_satcont( const Word16 *x, const Word16 *y, Word16 qx, Word
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 )
{
FOR( i = 0; i < len; i += delta )
{
- tmp_tabx[i] = shr( tmp_tabx[i], 2 );
+ tmp_tabx[i] = shr( tmp_tabx[i], 2 ); /* qx - 2 */
move16();
- tmp_taby[i] = shr( tmp_taby[i], 2 );
+ tmp_taby[i] = shr( tmp_taby[i], 2 ); /* qx - 2 */
move16();
}
shift = add( shift, 4 );
diff --git a/lib_enc/acelp_enc_util.c b/lib_enc/acelp_enc_util.c
deleted file mode 100644
index eb574bd70a8cd1b2a23801d28b3bc6442f2644ac..0000000000000000000000000000000000000000
--- a/lib_enc/acelp_enc_util.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 "prot.h"
-#include "cnst.h"
-#include "rom_com.h"
-#include "wmc_auto.h"
-
-/*-------------------------------------------------------------------*
- * E_ACELP_toeplitz_mul()
- *
- * Multiplication of Toeplitz matrix with vector c, such that d = toeplitz(R)*c
- *-------------------------------------------------------------------*/
diff --git a/lib_enc/acelp_enc_util_fx.c b/lib_enc/acelp_enc_util_fx.c
index 8fb74129723e6127d02c26efde383be94b41d343..181583e91d23686fd8a753128ec344665e4e27a2 100644
--- a/lib_enc/acelp_enc_util_fx.c
+++ b/lib_enc/acelp_enc_util_fx.c
@@ -34,11 +34,12 @@
* Vector length is L_SUBFR
*/
Word16 E_ACELP_toeplitz_mul_fx(
- const Word16 R[],
- const Word16 c[],
- Word16 d[],
- const Word16 L_subfr,
- const Word16 highrate )
+ const Word16 R[], /* Q9 */
+ const Word16 c[], /* Qx */
+ Word16 d[], /* exp(j) */
+ const Word16 L_subfr, /* Q0 */
+ const Word16 highrate /* Q0 */
+)
{
static const Word16 step = 4;
Word16 k, j, i;
@@ -57,26 +58,25 @@ Word16 E_ACELP_toeplitz_mul_fx(
L_maxloc = L_deposit_l( 0 );
FOR( i = k; i < L_subfr; i += step )
{
- s = L_mult( R[i], c[0] );
+ s = L_mult( R[i], c[0] ); /* Q10 + Qx */
FOR( j = 1; j < i; j++ )
{
- s = L_mac( s, R[i - j], c[j] );
+ s = L_mac( s, R[i - j], c[j] ); /* Q10 + Qx */
}
FOR( ; j < L_subfr; j++ )
{
- s = L_mac( s, R[j - i], c[j] );
+ s = L_mac( s, R[j - i], c[j] ); /* Q10 + Qx */
}
y32[i] = s;
move32();
s = L_abs( s );
- L_maxloc = L_max( s, L_maxloc );
+ L_maxloc = L_max( s, L_maxloc ); /* Q10 + Qx */
}
/* tot += 3*max / 8 */
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 */
@@ -89,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
}
@@ -113,16 +99,16 @@ Word16 E_ACELP_toeplitz_mul_fx(
/* Limit exponent to avoid overflows elsewhere. */
j = s_min( sub( norm_l( L_tot ), 4 + 16 ), 15 - 16 ); /* 4 -> 16 x tot */
- Copy_Scale_sig_32_16( y32, d, L_subfr, j );
+ Copy_Scale_sig_32_16( y32, d, L_subfr, j ); /* exp(j) */
return j;
}
void E_ACELP_weighted_code(
- const Word16 code[], /* i: code */
- const Word16 H[], /* i: impulse response */
- Word16 Q, /* i: Q format of H */
- Word16 y[] /* o: weighted code */
+ const Word16 code[], /* i: code Q9*/
+ const Word16 H[], /* i: impulse response Q*/
+ Word16 Q, /* i: Q format of H */
+ Word16 y[] /* o: weighted code Q9*/
)
{
Word16 i, j, k, one, n, nz[L_SUBFR];
@@ -150,8 +136,8 @@ void E_ACELP_weighted_code(
set16_fx( y, 0, j );
FOR( k = 0; k < L_SUBFR - j; k++ )
{
- L_tmp = L_mult( code[j], H[k] );
- y[j + k] = extract_h( L_shl( L_tmp, Q ) );
+ L_tmp = L_mult( code[j], H[k] ); /* Q10 + Q */
+ y[j + k] = extract_h( L_shl( L_tmp, Q ) ); /* Q9 */
}
FOR( i = 1; i < n; ++i )
@@ -161,16 +147,16 @@ void E_ACELP_weighted_code(
FOR( k = 0; k < L_SUBFR - j; k++ )
{
L_tmp = L_mult( y[j + k], one );
- L_tmp = L_mac( L_tmp, code[j], H[k] );
- y[j + k] = extract_h( L_shl( L_tmp, Q ) );
+ L_tmp = L_mac( L_tmp, code[j], H[k] ); /* Q10 + Q */
+ y[j + k] = extract_h( L_shl( L_tmp, Q ) ); /* Q9*/
}
}
}
void E_ACELP_conv(
- const Word16 xn2[], /* i */
- const Word16 h2[], /* i */
- Word16 cn2[] /* o */
+ const Word16 xn2[], /* i Qx*/
+ const Word16 h2[], /* i Q12*/
+ Word16 cn2[] /* o Q0*/
)
{
Word16 i, k;
@@ -182,25 +168,21 @@ void E_ACELP_conv(
{
/*cn2[k] = xn2[k]; */
Word64 L_tmp_64;
- L_tmp_64 = W_deposit32_l( L_mult( xn2[k], 0x800 ) );
+ L_tmp_64 = W_deposit32_l( L_mult( xn2[k], 0x800 ) ); /* 4Q11 */
FOR( i = 0; i < k; i++ )
{
/*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 );
-#ifdef BASOP_NOGLOB
- cn2[k] = round_fx_o( L_shl_o( L_tmp, 5, &Overflow ), &Overflow );
-#else
- cn2[k] = round_fx( L_shl( L_tmp, 5 ) );
-#endif
+ L_tmp = W_sat_l( L_tmp_64 ); /* 4Q11 */
+ cn2[k] = round_fx_o( L_shl_o( L_tmp, 5, &Overflow ), &Overflow ); /* Q0 */
}
}
-void E_ACELP_conv_ivas(
- const Word16 xn2[], /* i */
- const Word16 h2[], /* i */
- Word16 cn2[] /* o */
+void E_ACELP_conv_ivas_fx(
+ const Word16 xn2[], /* i Qx*/
+ const Word16 h2[], /* i Q12*/
+ Word16 cn2[] /* o Q0*/
)
{
Word16 i, k;
@@ -212,27 +194,23 @@ void E_ACELP_conv_ivas(
{
/*cn2[k] = xn2[k]; */
Word64 L_tmp_64;
- L_tmp_64 = W_deposit32_l( L_mult0( xn2[k], 0x800 ) );
+ L_tmp_64 = W_deposit32_l( L_mult0( xn2[k], 0x800 ) ); /* 4Q11 */
FOR( i = 0; i < k; i++ )
{
/*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 );
-#ifdef BASOP_NOGLOB
- cn2[k] = round_fx_o( L_shl_o( L_tmp, 5, &Overflow ), &Overflow );
-#else
- cn2[k] = round_fx( L_shl( L_tmp, 5 ) );
-#endif
+ L_tmp = W_sat_l( L_tmp_64 ); /* 4Q11 */
+ cn2[k] = round_fx_o( L_shl_o( L_tmp, 5, &Overflow ), &Overflow ); /* Q0*/
move16();
}
}
void E_ACELP_build_code(
- Word16 nb_pulse, /* i */
- const Word16 codvec[], /* i */
- const Word16 sign[], /* i */
- Word16 code[], /* o */
- Word16 ind[] /* o */
+ Word16 nb_pulse, /* i Q0*/
+ const Word16 codvec[], /* i Q0*/
+ const Word16 sign[], /* i Q0*/
+ Word16 code[], /* o Q9*/
+ Word16 ind[] /* o Q0*/
)
{
Word16 i, k, val, index, track, tmp, vec[4];
@@ -252,42 +230,42 @@ void E_ACELP_build_code(
FOR( k = 0; k < nb_pulse; ++k )
{
- i = codvec[k]; /* read pulse position */
+ i = codvec[k]; /* read pulse position Q0*/
move16();
- val = sign[i]; /* read sign */
+ val = sign[i]; /* read sign Q0*/
move16();
index = shr( i, 2 ); /* pos of pulse (0..15) */
track = s_and( i, 4 - 1 ); /* i % 4; */
- tmp = add( code[i], _1_Q9 );
+ tmp = add( code[i], _1_Q9 ); /* Q9 */
if ( val <= 0 )
{
- tmp = sub( code[i], _1_Q9 );
+ tmp = sub( code[i], _1_Q9 ); /* Q9 */
}
- code[i] = tmp;
+ code[i] = tmp; /* Q9 */
move16();
if ( val <= 0 )
{
- index = add( index, 16 );
+ index = add( index, 16 ); /* Q0 */
}
/* Calculate Current Store Index (we started at -1) so we increment first */
- i = add( vec[track], 1 );
+ i = add( vec[track], 1 ); /* Q0 */
/* Save Next Store Index */
- vec[track] = i;
+ vec[track] = i; /* Q0 */
move16();
- ind[i] = index;
+ ind[i] = index; /* Q0 */
move16();
}
}
void E_ACELP_setup_pulse_search_pos(
- const PulseConfig *config, /* i: pulse configuration */
- Word16 k, /* i: interation number */
- UWord8 ipos[] /* o: pulse search positions */
+ const PulseConfig *config, /* i: pulse configuration */
+ Word16 k, /* i: interation number Q0*/
+ UWord8 ipos[] /* o: pulse search positions Q0*/
)
{
Word16 restpulses, iPulse;
@@ -308,30 +286,30 @@ void E_ACELP_setup_pulse_search_pos(
/* add tracks from left */
FOR( iPulse = 0; iPulse < restpulses; iPulse++ )
{
- ipos[config->nb_pulse - restpulses + iPulse] = (UWord8) iPulse;
+ ipos[config->nb_pulse - restpulses + iPulse] = (UWord8) iPulse; /* Q0 */
move16();
}
/* Put the same track on the next position, because the 1-pulse search
* will access it to determine if this could be in any track. */
- ipos[config->nb_pulse] = ipos[config->nb_pulse - 1];
+ ipos[config->nb_pulse] = ipos[config->nb_pulse - 1]; /* Q0 */
move16();
BREAK;
case TRACKPOS_FIXED_EVEN: /* fixed track positions, odd tracks */
/* odd tracks, switch order for every iteration */
- ipos[config->nb_pulse - restpulses] = (UWord8) s_and( lshl( k, 1 ), 2 );
- move16(); /* 0 for even k, 2 for odd */
- ipos[config->nb_pulse - restpulses + 1] = (UWord8) s_xor( ipos[config->nb_pulse - restpulses], 2 );
- move16(); /* 2 for even k, 0 for odd */
+ ipos[config->nb_pulse - restpulses] = (UWord8) s_and( lshl( k, 1 ), 2 ); /* Q0 */
+ move16(); /* 0 for even k, 2 for odd */
+ ipos[config->nb_pulse - restpulses + 1] = (UWord8) s_xor( ipos[config->nb_pulse - restpulses], 2 ); /* Q0 */
+ move16(); /* 2 for even k, 0 for odd */
BREAK;
case TRACKPOS_FIXED_TWO: /* two tracks instead of four */
/* Put the next track on the next position, because the 1-pulse search
* will access it to determine if this could be in any track. */
- ipos[config->nb_pulse] = (UWord8) s_and( add( ipos[config->nb_pulse - 1], 1 ), 3 );
+ ipos[config->nb_pulse] = (UWord8) s_and( add( ipos[config->nb_pulse - 1], 1 ), 3 ); /* Q0 */
move16();
BREAK;
default: /* one or three free track positions */
/* copy an extra position from table - 1pulse search will access this */
- ipos[config->nb_pulse] = E_ROM_tipos[add( shl( k, 2 ), config->nb_pulse )];
+ ipos[config->nb_pulse] = E_ROM_tipos[add( shl( k, 2 ), config->nb_pulse )]; /* Q0 */
move16();
BREAK;
}
diff --git a/lib_enc/amr_wb_enc.c b/lib_enc/amr_wb_enc.c
deleted file mode 100644
index 6056f600b461d55e0226c5ee5c53648597aabd79..0000000000000000000000000000000000000000
--- a/lib_enc/amr_wb_enc.c
+++ /dev/null
@@ -1,45 +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"
diff --git a/lib_enc/amr_wb_enc_fx.c b/lib_enc/amr_wb_enc_fx.c
index 7b177d99a067b14fa75e57f906fe7c541ac4cb7f..d5bbfab29888b70eed940eb118b5ec21c260fc27 100644
--- a/lib_enc/amr_wb_enc_fx.c
+++ b/lib_enc/amr_wb_enc_fx.c
@@ -25,8 +25,8 @@
void amr_wb_enc_fx(
Encoder_State *st, /* i/o: encoder state structure */
- const Word16 input_sp[], /* i : input signal */
- const Word16 n_samples /* i : number of input samples */
+ const Word16 input_sp[], /* i : input signal Q0*/
+ const Word16 n_samples /* i : number of input samples Q0*/
)
{
Word16 i, delay;
@@ -95,25 +95,28 @@ void amr_wb_enc_fx(
* Initialization
*------------------------------------------------------------------*/
- st->L_frame = L_FRAME;
+ st->L_frame = L_FRAME; /* Q0 */
move16();
- st->gamma = GAMMA1;
+ st->gamma = GAMMA1; /* Q15 */
move16();
- st->core = AMR_WB_CORE;
+ st->core = AMR_WB_CORE; /* Q0 */
move16();
- st->core_brate = st->total_brate;
+ st->core_brate = st->total_brate; /* Q0 */
move16();
- st->input_bwidth = st->last_input_bwidth;
+ st->input_bwidth = st->last_input_bwidth; /* Q0 */
move16();
- st->bwidth = st->last_bwidth;
+ st->bwidth = st->last_bwidth; /* Q0 */
move16();
st->coder_type = GENERIC;
move16();
input_frame = st->input_frame_fx;
move16(); /* frame length of the input signal */
st->extl = -1;
+ move16();
st->encoderPastSamples_enc = ( L_FRAME * 9 ) / 16;
+ move16();
st->encoderLookahead_enc = L_LOOK_12k8;
+ move16();
st->bpf_off = 0;
move16();
test();
@@ -140,18 +143,18 @@ void amr_wb_enc_fx(
set16_fx( old_inp, 0, L_INP_12k8 );
exc = old_exc + L_EXC_MEM; /* pointer to excitation signal in the current frame */
- Copy( hLPDmem->old_exc, old_exc, L_EXC_MEM );
+ Copy( hLPDmem->old_exc, old_exc, L_EXC_MEM ); /* q_lpd_old_exc */
new_inp = old_inp + L_INP_MEM; /* pointer to new samples of the input signal */
inp = new_inp - L_LOOK_12k8; /* pointer to current frame of input signal */
wsp = old_wsp + L_WSP_MEM; /* pointer to current frame of weighted signal */
- Copy( st->old_inp_12k8_fx, old_inp, L_INP_MEM );
- Copy( st->old_wsp_fx, old_wsp, L_WSP_MEM );
+ Copy( st->old_inp_12k8_fx, old_inp, L_INP_MEM ); /* exp_old_inp_12k8 */
+ Copy( st->old_wsp_fx, old_wsp, L_WSP_MEM ); /* exp(exp_old_wsp) */
- 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_16k; /* pointer to the current frame of input signal in 16kHz core */
- Copy( st->old_inp_16k_fx, old_inp_16k, L_INP_MEM );
+ 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_16k; /* pointer to the current frame of input signal in 16kHz core */
+ Copy( st->old_inp_16k_fx, old_inp_16k, L_INP_MEM ); /* q_old_inp */
/* in case of switching, reset AMR-WB BWE memories */
test();
@@ -167,14 +170,14 @@ void amr_wb_enc_fx(
/* get delay to synchronize ACELP and MDCT frame */
delay = NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS );
- Copy( st->input_fx - delay, st->old_input_signal_fx, input_frame + delay );
+ Copy( st->input_fx - delay, st->old_input_signal_fx, input_frame + delay ); /* q_inp */
/*----------------------------------------------------------------*
* Buffering of input signal
* HP filtering
*----------------------------------------------------------------*/
- Copy( input_sp, st->input_fx, n_samples );
+ Copy( input_sp, st->input_fx, n_samples ); /* Q0 */
FOR( i = n_samples; i < input_frame; i++ )
{
st->input_fx[i] = 0;
@@ -195,25 +198,25 @@ void amr_wb_enc_fx(
/* in case of switching, do not apply BPF */
st->bpf_off = 1;
move16();
- st->rate_switching_reset = lsp_convert_poly_fx( st->lsp_old_fx, L_FRAME, 1 );
+ st->rate_switching_reset = lsp_convert_poly_fx( st->lsp_old_fx, L_FRAME, 1 ); /* Q0 */
/* convert old quantized LSF vector */
lsp2lsf_fx( st->lsp_old_fx, st->lsf_old_fx, M, INT_FS_FX );
/* Reset LPC mem */
- Copy( GEWB_Ave_fx, st->mem_AR_fx, M );
+ Copy( GEWB_Ave_fx, st->mem_AR_fx, M ); /* x2.56 */
set16_fx( st->mem_MA_fx, 0, M );
/* update synthesis filter memories */
synth_mem_updt2( L_FRAME, st->last_L_frame, hLPDmem->old_exc, hLPDmem->mem_syn_r, hLPDmem->mem_syn1_fx, hLPDmem->mem_syn, ENC );
- Copy( hLPDmem->mem_syn1_fx, hLPDmem->mem_syn2, M );
+ Copy( hLPDmem->mem_syn1_fx, hLPDmem->mem_syn2, M ); /* q_mem_syn */
- Copy( hLPDmem->old_exc, old_exc, L_EXC_MEM );
- Copy( hLPDmem->mem_syn2, hLPDmem->mem_syn3, M );
+ Copy( hLPDmem->old_exc, old_exc, L_EXC_MEM ); /* q_lpd_old_exc */
+ Copy( hLPDmem->mem_syn2, hLPDmem->mem_syn3, M ); /* q_mem_syn */
/* lsp -> isp */
Copy( stable_ISP_fx, isp_tmp, M );
- lsp2isp_fx( st->lsp_old_fx, st->lsp_old_fx, isp_tmp, M );
+ lsp2isp_fx( st->lsp_old_fx, st->lsp_old_fx, isp_tmp, M ); /* Q15 */
}
/* update buffer of old subframe pitch values */
@@ -223,17 +226,17 @@ void amr_wb_enc_fx(
IF( EQ_16( st->last_L_frame, L_FRAME32k ) )
{
/* (float)12800/(float)32000; */
- tmp = 13107;
+ tmp = 13107; /* 0.4 in Q15 */
}
ELSE IF( EQ_16( st->last_L_frame, 512 ) )
{
/* (float)12800/(float)25600; */
- tmp = 16384;
+ tmp = 16384; /* 0.5 in Q15 */
}
ELSE /* st->last_L_frame == L_FRAME16k */
{
/* (float)12800/(float)16000; */
- tmp = 26214;
+ tmp = 26214; /* 0.8 in Q15 */
}
FOR( i = NB_SUBFR16k - NB_SUBFR; i < NB_SUBFR16k; i++ )
@@ -252,7 +255,7 @@ void amr_wb_enc_fx(
test();
if ( EQ_16( st->last_bwidth, NB ) && st->ini_frame != 0 )
{
- st->rate_switching_reset = 1;
+ st->rate_switching_reset = 1; /* Q0 */
move16();
}
@@ -263,8 +266,8 @@ void amr_wb_enc_fx(
modify_Fs_fx( st->input_fx, input_frame, st->input_Fs, new_inp, 12800, st->mem_decim_fx, 0, &Q_new_inp, &mem_decim_size );
/* update signal buffer */
- Copy( new_inp, st->buf_speech_enc + L_FRAME, L_FRAME );
- Scale_sig( st->buf_speech_enc + L_FRAME, L_FRAME, 1 );
+ Copy( new_inp, st->buf_speech_enc + L_FRAME, L_FRAME ); /* Q0 */
+ Scale_sig( st->buf_speech_enc + L_FRAME, L_FRAME, 1 ); /* Q1 */
/*------------------------------------------------------------------*
* Perform fixed preemphasis through 1 - g*z^-1
@@ -273,7 +276,6 @@ void amr_wb_enc_fx(
Preemph_scaled( new_inp, &Q_new, &st->mem_preemph_fx, st->Q_max, PREEMPH_FAC, 0, 1, L_Q_MEM, L_FRAME, st->last_coder_type, 1 );
Q_exp = sub( Q_new, st->Q_old );
- move16();
st->Q_old = Q_new;
move16();
@@ -281,7 +283,6 @@ void amr_wb_enc_fx(
hNoiseEst->ave_enr2_fx, hNoiseEst->fr_bands1_fx, hNoiseEst->fr_bands2_fx, st->Bin_E_old_fx );
Q_exp = sub( Q_new, st->prev_Q_new );
- move16();
Scale_mem_enc( Q_exp, old_inp_16k, old_exc, hBWE_TD->old_bwe_exc_fx, &( hLPDmem->mem_w0 ), hLPDmem->mem_syn, hLPDmem->mem_syn2,
&st->mem_deemp_preQ_fx, hGSCEnc->last_exc_dct_in_fx, hBWE_FD->old_input_lp_fx );
@@ -305,7 +306,8 @@ void amr_wb_enc_fx(
*----------------------------------------------------------------*/
st->vad_flag = wb_vad_fx( st, fr_bands, &noisy_speech_HO, &clean_speech_HO, &NB_speech_HO,
- &snr_sum_he, &localVAD_HE_SAD, &( st->flag_noisy_speech_snr ), Q_new, hVAD, hNoiseEst, st->lp_speech_fx, st->lp_noise_fx );
+ &snr_sum_he, &localVAD_HE_SAD, &( st->flag_noisy_speech_snr ), Q_new, hVAD, hNoiseEst, st->lp_speech_fx, st->lp_noise_fx ); /* Q0 */
+ move16();
if ( st->vad_flag == 0 )
{
@@ -322,12 +324,13 @@ void amr_wb_enc_fx(
IF( NE_16( st->last_core, AMR_WB_CORE ) )
{
- st->fd_cng_reset_flag = 1;
+ st->fd_cng_reset_flag = 1; /* Q0 */
move16();
}
ELSE IF( s_and( ( st->fd_cng_reset_flag > 0 ), (Word16) ( LT_16( st->fd_cng_reset_flag, 10 ) ) ) )
{
- st->fd_cng_reset_flag = add( st->fd_cng_reset_flag, 1 );
+ st->fd_cng_reset_flag = add( st->fd_cng_reset_flag, 1 ); /* Q0 */
+ move16();
}
ELSE
{
@@ -358,26 +361,22 @@ void amr_wb_enc_fx(
IF( NE_16( st->bwidth, NB ) )
{
- lp_bckr = Mean32( hNoiseEst->bckr_fx, 10 );
+ lp_bckr = Mean32( hNoiseEst->bckr_fx, 10 ); /* q_bckr */
}
ELSE
{
- lp_bckr = Mean32( hNoiseEst->bckr_fx + 1, 9 );
+ 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 );
-#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. */
+ hp_bckr = L_shr( L_add_sat( hNoiseEst->bckr_fx[st->max_band - 1], hNoiseEst->bckr_fx[st->max_band] ), 1 ); /* q_bckr */
+ 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 );
+ tmp = BASOP_Util_Divide3232_Scale( lp_bckr, hp_bckr, &e_tmp ); /* exp(e_tmp) */
Ltmp = L_shr_r( L_deposit_h( tmp ), sub( 15, e_tmp ) );
- st->bckr_tilt_lt = L_add( Mpy_32_16_r( st->bckr_tilt_lt, 29491 ), Mpy_32_16_r( Ltmp, 3277 ) );
+ st->bckr_tilt_lt = L_add( Mpy_32_16_r( st->bckr_tilt_lt, 29491 ), Mpy_32_16_r( Ltmp, 3277 ) ); /* Q16 */
- corr_shift = correlation_shift_fx( hNoiseEst->totalNoise_fx );
+ corr_shift = correlation_shift_fx( hNoiseEst->totalNoise_fx ); /* Q15 */
/*----------------------------------------------------------------*
* WB, SWB and FB bandwidth detector
@@ -404,7 +403,7 @@ void amr_wb_enc_fx(
/* reset the OL pitch tracker memories during inactive frames */
pitch_ol_init_fx( &st->old_thres_fx, &st->old_pitch, &st->delta_pit, &st->old_corr_fx );
}
- old_pitch1 = st->pitch[1];
+ old_pitch1 = st->pitch[1]; /* Q0 */
move16();
analy_lp_AMR_WB_fx( inp, &ener, A, epsP_h, epsP_l, isp_new, st->lsp_old1_fx,
isf_new, st->old_pitch_la, st->old_voicing_la, Q_new, Q_r );
@@ -427,9 +426,9 @@ void amr_wb_enc_fx(
move16();
}
pitch_ol_fx( st->pitch, st->voicing_fx, &st->old_pitch, &st->old_corr_fx, corr_shift, &st->old_thres_fx, &st->delta_pit, st->old_wsp2_fx, wsp, st->mem_decim2_fx, relE, 0, st->bwidth, st->Opt_SC_VBR );
- st->old_pitch_la = st->pitch[2];
+ st->old_pitch_la = st->pitch[2]; /* Q0 */
move16();
- st->old_voicing_la = st->voicing_fx[2];
+ st->old_voicing_la = st->voicing_fx[2]; /* Q15 */
move16();
/* VAD parameters update */
@@ -495,16 +494,16 @@ void amr_wb_enc_fx(
CNG_reset_enc_fx( st, hLPDmem, pitch_buf, dummy_buf + L_FRAME, 0 );
/* update st->mem_syn1 for ACELP core switching */
- Copy( hLPDmem->mem_syn3, hLPDmem->mem_syn1_fx, M );
+ Copy( hLPDmem->mem_syn3, hLPDmem->mem_syn1_fx, M ); /* q_mem_syn */
/* update ACELP core synthesis filter memory */
- Copy( hLPDmem->mem_syn3, hLPDmem->mem_syn, M );
+ Copy( hLPDmem->mem_syn3, hLPDmem->mem_syn, M ); /* q_mem_syn */
/* update old synthesis buffer - needed for ACELP internal sampling rate switching */
- Copy( dummy_buf + L_FRAME - L_SYN_MEM, hLPDmem->mem_syn_r, L_SYN_MEM );
+ Copy( dummy_buf + L_FRAME - L_SYN_MEM, hLPDmem->mem_syn_r, L_SYN_MEM ); /* st->Q_syn */
/* Update MODE2 core switching memory */
E_UTIL_deemph2( sub( Q_new, 1 ), dummy_buf, PREEMPH_FAC, L_FRAME, &( hLPDmem->syn[M] ) );
- Copy( dummy_buf + L_FRAME - M - 1, hLPDmem->syn, M + 1 );
+ Copy( dummy_buf + L_FRAME - M - 1, hLPDmem->syn, M + 1 ); /* st->Q_syn */
}
/*----------------------------------------------------------------*
@@ -519,7 +518,7 @@ void amr_wb_enc_fx(
test();
IF( EQ_32( st->last_core_brate, FRAME_NO_DATA ) || EQ_32( st->last_core_brate, SID_1k75 ) )
{
- Copy( hDtxEnc->lspCNG_fx, st->lsp_old_fx, M );
+ Copy( hDtxEnc->lspCNG_fx, st->lsp_old_fx, M ); /* Q15 */
E_LPC_isp_isf_conversion( hDtxEnc->lspCNG_fx, st->lsf_old_fx, M );
set16_fx( old_exc, 0, L_EXC_MEM );
}
@@ -549,14 +548,14 @@ void amr_wb_enc_fx(
encod_amr_wb_fx( st, inp, Aw, Aq, res, syn, exc, exc2, pitch_buf, hf_gain_fx, inp_16k, shift, Q_new );
/* update st->mem_syn1 for ACELP core switching */
- Copy( hLPDmem->mem_syn, hLPDmem->mem_syn1_fx, M );
+ Copy( hLPDmem->mem_syn, hLPDmem->mem_syn1_fx, M ); /* st->q_mem_syn */
/* update old synthesis buffer - needed for ACELP internal sampling rate switching */
- Copy( syn + L_FRAME - L_SYN_MEM, hLPDmem->mem_syn_r, L_SYN_MEM );
+ Copy( syn + L_FRAME - L_SYN_MEM, hLPDmem->mem_syn_r, L_SYN_MEM ); /* st->Q_syn */
/* Update MODE2 core switching memory */
E_UTIL_deemph2( sub( Q_new, 1 ), syn, PREEMPH_FAC, L_FRAME, &( hLPDmem->syn[M] ) );
- Copy( syn + L_FRAME - M - 1, hLPDmem->syn, M + 1 );
+ Copy( syn + L_FRAME - M - 1, hLPDmem->syn, M + 1 ); /* st->Q_syn */
/*--------------------------------------------------------------------------------------*
* Write VAD information into the bitstream in AMR-WB IO mode
@@ -570,27 +569,27 @@ void amr_wb_enc_fx(
*-----------------------------------------------------------------*/
/* update old weighted speech buffer - for OL pitch analysis */
- Copy( &old_wsp[L_FRAME], st->old_wsp_fx, L_WSP_MEM );
+ Copy( &old_wsp[L_FRAME], st->old_wsp_fx, L_WSP_MEM ); /* exp(exp_old_wsp) */
/* update old input signal buffer */
- Copy( &old_inp[L_FRAME], st->old_inp_12k8_fx, L_INP_MEM );
+ Copy( &old_inp[L_FRAME], st->old_inp_12k8_fx, L_INP_MEM ); /* exp(exp_old_inp_12k8) */
/* update old input signal @16kHz buffer */
IF( GT_32( st->input_Fs, 8000 ) )
{
- Copy( &old_inp_16k[L_FRAME16k], st->old_inp_16k_fx, L_INP_MEM );
+ Copy( &old_inp_16k[L_FRAME16k], st->old_inp_16k_fx, L_INP_MEM ); /* exp(exp_old_inp_16k) */
}
/* update of old per-band energy spectrum */
- Copy32( fr_bands + NB_BANDS, hNoiseEst->enrO_fx, NB_BANDS );
+ Copy32( fr_bands + NB_BANDS, hNoiseEst->enrO_fx, NB_BANDS ); /* Q_new */
/* update the last bandwidth */
- st->last_input_bwidth = st->input_bwidth;
- st->last_bwidth = st->bwidth;
+ st->last_input_bwidth = st->input_bwidth; /* Q0 */
+ st->last_bwidth = st->bwidth; /* Q0 */
/* update signal buffers */
- Copy( new_inp, st->buf_speech_enc_pe + L_FRAME, L_FRAME );
- Copy( wsp, st->buf_wspeech_enc + L_FRAME + L_SUBFR, L_FRAME + L_LOOK_12k8 );
+ Copy( new_inp, st->buf_speech_enc_pe + L_FRAME, L_FRAME ); /* Q0 */
+ Copy( wsp, st->buf_wspeech_enc + L_FRAME + L_SUBFR, L_FRAME + L_LOOK_12k8 ); /* exp(exp_buf_wspeech_enc) */
updt_enc_fx( st, old_exc, pitch_buf, 0, Aq, isf_new, isp_new, dummy_buf );
/* update main codec parameters */
@@ -633,7 +632,7 @@ void amr_wb_enc_init_fx(
FOR( i = 0; i < GAIN_PRED_ORDER; i++ )
{
- hAmrwb_IO->past_qua_en_fx[i] = -14336; /* Q10gain quantization memory (used also in AMR-WB IO mode) */
+ hAmrwb_IO->past_qua_en_fx[i] = -14336; /* Q10 gain quantization memory (used also in AMR-WB IO mode) */
move16();
}
diff --git a/lib_enc/analy_lp.c b/lib_enc/analy_lp.c
deleted file mode 100644
index 2e657e155b94f2ee095cf1922c203d19c79fa7dc..0000000000000000000000000000000000000000
--- a/lib_enc/analy_lp.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 "rom_com.h"
-#include "prot.h"
-#include "wmc_auto.h"
-
-/*-------------------------------------------------------------------*
- * analy_lp()
- *
- * Perform LP analysis
- *
- * - autocorrelations + lag windowing
- * - Levinson-Durbin algorithm to find A(z)
- * - convert A(z) to LSPs
- * - find interpolated LSPs and convert back to A(z) for all subframes
- * - update LSPs for the next frame
- *-------------------------------------------------------------------*/
diff --git a/lib_enc/analy_lp_fx.c b/lib_enc/analy_lp_fx.c
index dc0e9c545f5edc38ce7b672e543496fa11f70e67..c2f9d0585d356c513226ee2059d219e835976724 100644
--- a/lib_enc/analy_lp_fx.c
+++ b/lib_enc/analy_lp_fx.c
@@ -63,7 +63,7 @@ void analy_lp_ivas_fx(
move16();
wind = assym_window_16k_fx; /*q15*/
}
- lsp = lsp_mid;
+ lsp = lsp_mid; /* Q15 */
half_frame = shr( L_frame, 1 );
FOR( i_subfr = 0; i_subfr <= 1; i_subfr++ )
@@ -105,7 +105,7 @@ void analy_lp_ivas_fx(
/* Conversion of A(z) to LSPs */
E_LPC_a_lsp_conversion( A, lsp, lsp_old, M );
- lsp = lsp_new;
+ lsp = lsp_new; /* Q15 */
}
IF( EQ_16( sec_chan_low_rate, 1 ) )
{
@@ -117,28 +117,28 @@ void analy_lp_ivas_fx(
/* LSP interpolation */
int_lsp4_ivas_fx( L_frame, lsp_old, lsp_mid, lsp_new, A, M, 0 );
}
- Copy( lsp_new, lsp_old, M );
- *ener = L_Comp( epsP_h[M], epsP_l[M] );
+ Copy( lsp_new, lsp_old, M ); /* Q15 */
+ *ener = L_Comp( epsP_h[M], epsP_l[M] ); /* Q_r */
move32();
return;
}
void analy_lp_fx(
- const Word16 speech[], /* i : pointer to the speech frame */
- const Word16 L_frame, /* i : length of the frame */
- const Word16 L_look, /* i : look-ahead */
- Word32 *ener, /* o : residual energy from Levinson-Durbin */
- Word16 A[], /* o : A(z) filter coefficients */
- Word16 epsP_h[], /* o : LP analysis residual energies for each iteration */
- Word16 epsP_l[], /* o : LP analysis residual energies for each iteration */
- Word16 lsp_new[], /* o : current frame LSPs */
- Word16 lsp_mid[], /* o : current mid-frame LSPs */
- Word16 lsp_old[], /* i/o: previous frame unquantized LSPs */
- const Word16 Top[2], /* i : open loop pitch lag */
- const Word16 Tnc[2], /* i : open loop pitch gain */
- const Word32 Core_sr, /* i : Internal core sampling rate */
- const Word16 sec_chan_low_rate, /* i : flag to signal second channel */
+ const Word16 speech[], /* i : pointer to the speech frame Q_new*/
+ const Word16 L_frame, /* i : length of the frame Q0*/
+ const Word16 L_look, /* i : look-ahead Q0*/
+ Word32 *ener, /* o : residual energy from Levinson-Durbin Q_r*/
+ Word16 A[], /* o : A(z) filter coefficients Q14*/
+ Word16 epsP_h[], /* o : LP analysis residual energies for each iteration Q_r*/
+ Word16 epsP_l[], /* o : LP analysis residual energies for each iteration Q_r*/
+ Word16 lsp_new[], /* o : current frame LSPs Q15*/
+ Word16 lsp_mid[], /* o : current mid-frame LSPs Q15*/
+ Word16 lsp_old[], /* i/o: previous frame unquantized LSPs Q15*/
+ const Word16 Top[2], /* i : open loop pitch lag Q0*/
+ const Word16 Tnc[2], /* i : open loop pitch gain Q15*/
+ const Word32 Core_sr, /* i : Internal core sampling rate Q0*/
+ const Word16 sec_chan_low_rate, /* i : flag to signal second channel Q0*/
Word16 Q_new,
Word16 *Q_r )
{
@@ -155,15 +155,15 @@ void analy_lp_fx(
{
wind_length = L_LP;
move16();
- wind = Assym_window_W16fx;
+ wind = Assym_window_W16fx; /* Q15 */
}
ELSE /* L_frame == L_FRAME16k */
{
wind_length = L_LP_16k;
move16();
- wind = assym_window_16k_fx;
+ wind = assym_window_16k_fx; /* Q15 */
}
- lsp = lsp_mid;
+ lsp = lsp_mid; /* Q15 */
half_frame = shr( L_frame, 1 );
FOR( i_subfr = 0; i_subfr <= 1; i_subfr++ )
@@ -190,7 +190,7 @@ void analy_lp_fx(
/* Conversion of A(z) to LSPs */
E_LPC_a_lsp_conversion( A, lsp, lsp_old, M );
- lsp = lsp_new;
+ lsp = lsp_new; /* Q15 */
}
IF( EQ_16( sec_chan_low_rate, 1 ) )
{
@@ -202,8 +202,8 @@ void analy_lp_fx(
/* LSP interpolation */
int_lsp4_fx( L_frame, lsp_old, lsp_mid, lsp_new, A, M, 0 );
}
- Copy( lsp_new, lsp_old, M );
- *ener = L_Comp( epsP_h[M], epsP_l[M] );
+ Copy( lsp_new, lsp_old, M ); /* Q15 */
+ *ener = L_Comp( epsP_h[M], epsP_l[M] ); /* Q_r */
move32();
return;
@@ -223,16 +223,16 @@ void analy_lp_fx(
*-------------------------------------------------------------------*/
void analy_lp_AMR_WB_fx(
- const Word16 speech[], /* i : pointer to the speech frame */
- Word32 *ener, /* o : residual energy from Levinson-Durbin */
- Word16 A[], /* o : A(z) filter coefficients */
- Word16 epsP_h[], /* o : LP analysis residual energies for each iteration */
- Word16 epsP_l[], /* o : LP analysis residual energies for each iteration */
- Word16 isp_new[], /* o : current frame ISPs */
- Word16 isp_old[], /* i/o: previous frame unquantized ISPs */
- Word16 isf_new[], /* o : current frame ISPs */
- Word16 Top, /* i : open loop pitch lag */
- Word16 Tnc, /* i : open loop pitch gain */
+ const Word16 speech[], /* i : pointer to the speech frame Q_new*/
+ Word32 *ener, /* o : residual energy from Levinson-Durbin Q_r*/
+ Word16 A[], /* o : A(z) filter coefficients Q14*/
+ Word16 epsP_h[], /* o : LP analysis residual energies for each iteration Q_r*/
+ Word16 epsP_l[], /* o : LP analysis residual energies for each iteration Q_r*/
+ Word16 isp_new[], /* o : current frame ISPs Q15*/
+ Word16 isp_old[], /* i/o: previous frame unquantized ISPs Q15*/
+ Word16 isf_new[], /* o : current frame ISPs Q15*/
+ Word16 Top, /* i : open loop pitch lag Q0*/
+ Word16 Tnc, /* i : open loop pitch gain Qx*/
Word16 Q_new,
Word16 *Q_r )
{
@@ -271,11 +271,11 @@ void analy_lp_AMR_WB_fx(
int_lsp_fx( L_FRAME, isp_old, isp_new, A, M, interpol_isp_amr_wb_fx, 1 );
/**ener = epsP[M];*/
- *ener = L_Comp( epsP_h[M], epsP_l[M] );
+ *ener = L_Comp( epsP_h[M], epsP_l[M] ); /* Q_r */
move32();
/* updates */
- Copy( isp_new, isp_old, M );
+ Copy( isp_new, isp_old, M ); /* Q15 */
return;
}
diff --git a/lib_enc/analy_sp.c b/lib_enc/analy_sp.c
deleted file mode 100644
index 0be76e525dda92b012f35a545e02e2cf42a331ce..0000000000000000000000000000000000000000
--- a/lib_enc/analy_sp.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 "rom_enc.h"
-#include "rom_com.h"
-#include "prot.h"
-#include "wmc_auto.h"
-#include
-#include "ivas_cnst.h"
diff --git a/lib_enc/analy_sp_fx.c b/lib_enc/analy_sp_fx.c
index d2e34b0124327ad3d66e2ba6a1d80605d7c9b8e3..d31f2ff089176cd3403b5b615ac7c4d967ac75eb 100644
--- a/lib_enc/analy_sp_fx.c
+++ b/lib_enc/analy_sp_fx.c
@@ -18,8 +18,7 @@
*-------------------------------------------------------------------*/
static void find_enr( Word16 data[], Word32 band[], Word32 *ptE, Word32 *LEtot, const Word16 min_band, const Word16 max_band, const Word16 Q_new2, const Word32 e_min, Word32 *Bin_E, Word16 BIN_FREQ_FX, Word32 *band_energies );
-static void ivas_find_enr( Word16 data[], Word32 band[], Word32 *ptE, Word32 *LEtot, const Word16 min_band, const Word16 max_band, const Word16 Q_new2, const Word32 e_min, Word32 *Bin_E, Word16 BIN_FREQ_FX, Word32 *band_energies );
-static void ivas_find_enr1( Word16 *data, Word16 q_data, Word32 *band, Word32 *ptE, Word32 *LEtot, const Word16 min_band, const Word16 max_band, const Word16 Q_new, const Word32 e_min, Word32 *Bin_E, Word16 BIN_FREQ_FX, Word32 *band_energies );
+static void ivas_find_enr( Word16 *data, Word16 q_data, Word32 *band, Word16 *q_band, Word32 *ptE, Word16 *q_ptE, Word64 *LEtot, const Word16 min_band, const Word16 max_band, Word32 *Bin_E, Word16 BIN_FREQ_FX, Word32 *band_energies );
#ifdef IVAS_CODE_CPE
static void find_enr_dft( CPE_ENC_HANDLE hCPE, const int32_t input_Fs, float DFT_past_DMX[], float band[], float *ptE, float *Etot, const int16_t min_band, const int16_t max_band, float *Bin_E, float *band_ener );
#endif
@@ -69,44 +68,52 @@ void analy_sp_fx(
* find energy per critical frequency band and total energy in dB
*-----------------------------------------------------------------*/
- pt_bands = fr_bands;
+ pt_bands = fr_bands; /* Q_new + QSCALE */
pt_fft = fft_buff;
LEtot = L_deposit_l( 0 );
IF( NE_16( element_mode, IVAS_CPE_DFT ) )
{
FOR( i_subfr = 0; i_subfr <= 1; i_subfr++ )
{
- pt = speech + 3 * ( L_SUBFR / 2 ) - L_FFT / 2;
+ pt = speech + 3 * ( L_SUBFR / 2 ) - L_FFT / 2; /* Q_new - preemph_bits */
if ( i_subfr != 0 )
{
- pt = speech + 7 * ( L_SUBFR / 2 ) - L_FFT / 2;
+ pt = speech + 7 * ( L_SUBFR / 2 ) - L_FFT / 2; /* Q_new - preemph_bits */
}
/* Clear 1st value of 1st part, copy 1st value of 2nd part */
fft_temp[0] = 0;
move16();
- fft_temp[L_FFT / 2] = pt[L_FFT / 2];
+ fft_temp[L_FFT / 2] = pt[L_FFT / 2]; /* Q_new - preemph_bits */
move16();
- Max_val = s_max( fft_temp[0], fft_temp[L_FFT / 2] );
- Min_val = s_min( fft_temp[0], fft_temp[L_FFT / 2] );
+ Max_val = s_max( fft_temp[0], fft_temp[L_FFT / 2] ); /* Q_new - preemph_bits */
+ Min_val = s_min( fft_temp[0], fft_temp[L_FFT / 2] ); /* Q_new - preemph_bits */
FOR( i = 1; i < L_FFT / 2; i++ )
{
/* 1st windowed part */
- fft_temp[i] = mult_r( pt[i], sqrt_han_window_fx[i] );
+ fft_temp[i] = mult_r( pt[i], sqrt_han_window_fx[i] ); /* Q_new - preemph_bits */
move16();
- if ( fft_temp[i] > 0 )
- Max_val = s_max( Max_val, fft_temp[i] );
- if ( fft_temp[i] < 0 )
- Min_val = s_min( Min_val, fft_temp[i] );
+ IF( fft_temp[i] > 0 )
+ {
+ Max_val = s_max( Max_val, fft_temp[i] ); /* Q_new - preemph_bits */
+ }
+ IF( fft_temp[i] < 0 )
+ {
+ Min_val = s_min( Min_val, fft_temp[i] ); /* Q_new - preemph_bits */
+ }
/* 2nd windowed part */
- fft_temp[L_FFT - i] = mult_r( pt[L_FFT - i], sqrt_han_window_fx[i] );
+ fft_temp[L_FFT - i] = mult_r( pt[L_FFT - i], sqrt_han_window_fx[i] ); /* Q_new - preemph_bits */
move16();
- if ( fft_temp[L_FFT - i] > 0 )
- Max_val = s_max( Max_val, fft_temp[L_FFT - i] );
- if ( fft_temp[L_FFT - i] < 0 )
- Min_val = s_min( Min_val, fft_temp[L_FFT - i] );
+ IF( fft_temp[L_FFT - i] > 0 )
+ {
+ Max_val = s_max( Max_val, fft_temp[L_FFT - i] ); /* Q_new - preemph_bits */
+ }
+ IF( fft_temp[L_FFT - i] < 0 )
+ {
+ Min_val = s_min( Min_val, fft_temp[L_FFT - i] ); /* Q_new - preemph_bits */
+ }
}
/* Combine -Min_val and Max_val into one */
@@ -115,7 +122,7 @@ void analy_sp_fx(
Scale_fac[i_subfr] = s_min( sub( norm_s( Max_val ), 1 ), 6 );
move16();
Scale_fac2 = shl( Scale_fac[i_subfr], 1 );
- Scale_sig( fft_temp, L_FRAME_12k8, Scale_fac[i_subfr] );
+ Scale_sig( fft_temp, L_FRAME_12k8, Scale_fac[i_subfr] ); /* Q_new - preemph_bits + Scale_fac */
r_fft_fx_lc( FFT_W128, SIZE_256, SIZE2_256, NUM_STAGE_256, fft_temp, pt_fft, 1 );
@@ -153,7 +160,7 @@ void analy_sp_fx(
Ltmp = Mpy_32( exp_etot, frac_etot, LG10, 0 );
/*Q8 Averaged the total energy over both half-frames in log10 */
- *Etot = extract_l( L_shr( Ltmp, 14 - 8 ) );
+ *Etot = extract_l( L_shr( Ltmp, 14 - 8 ) ); /* Q8 */
Bin_E[L_FFT / 2 - 1] = Bin_E[L_FFT / 2 - 2];
move32();
@@ -187,7 +194,7 @@ void analy_sp_fx(
/* -56783L is to substract 0.86643 in Q16 */
/* 28391 is 0.86643 in Q15 */
/* 1774 is (0.86643 in Q15) * 8 / 128 (/128 to go in Q7) */
- EspecdB[i] = mac_r( L_shl( L_msu( L_tmp2, exp, 28391 ), 3 + 7 ), exp_frac, 887 );
+ EspecdB[i] = mac_r( L_shl( L_msu( L_tmp2, exp, 28391 ), 3 + 7 ), exp_frac, 887 ); /* Q7 */
move16();
}
@@ -201,131 +208,149 @@ void analy_sp_fx(
* find input signal energy for each critical band using the DFT buffers
*------------------------------------------------------------------------*/
-static void find_enr_dft_fx(
- CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
- const Word32 input_Fs, /* i : input sampling rate */
- Word32 DFT_past_DMX_fx[], /* i:input DFT_Dmx (Q_inp_dmx ) */
- Word32 band_fx[], /* o : per band energy */
- Word32 *ptE_fx, /* o : per bin energy for low frequencies */
- Word32 *Etot_fx, /* i/o: total energy (Q8) */
- const Word16 min_band, /* i : minimum critical band */
- const Word16 max_band, /* i : maximum critical band */
- Word32 *Bin_E_fx, /* o : Per bin energy (Q7) */
- Word32 *band_ener_fx, /* o : per band energy without E_MIN (Qout) */
- Word16 Q_inp_dmx,
- Word16 *Qout )
+
+static void find_enr_dft_ivas_fx(
+ CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
+ const Word32 input_Fs, /* i : input sampling rate Q0*/
+ Word32 DFT_past_DMX_fx[], /* i :input DFT_Dmx (Q_inp_dmx ) */
+ Word32 band_fx[], /* o : per band energy (*q_band) */
+ Word16 *q_band, /* o : Q of per band energy */
+ Word32 *ptE_fx, /* o : per bin energy for low frequencies (*q_ptE) */
+ Word16 *q_ptE, /* o : Q of per bin energy for low frequencies */
+ Word64 *Etot_fx, /* i/o: total energy (Q8) */
+ const Word16 min_band, /* i : minimum critical band Q0*/
+ const Word16 max_band, /* i : maximum critical band Q0*/
+ Word32 *Bin_E_fx, /* o : Per bin energy (Q7) */
+ Word16 *q_Bin_E, /* o : Q of Per bin energy (*q_band) */
+ Word32 *band_ener_fx, /* o : per band energy without E_MIN */
+ Word16 Q_inp_dmx )
{
- Word16 i, cnt;
- Word32 tmp_fx;
+ Word16 i;
+ Word64 tot_ener;
Word32 freq;
const Word32 *ptR_fx, *ptI_fx;
- Word32 norm_val_fx;
- Word16 bin_cnt = 0;
- move16();
- // Word32 band_ener_fx[2 * NB_BANDS];
- // Etot_fx[0] = Etot[0] * ONE_IN_Q8;
+ Word16 norm_val_fx;
+ Word16 bin_cnt;
Word32 c_fx, s_fx;
+ Word32 g_fx;
+ Word32 scaleWin_fx;
+ Word16 bin_freq;
+ Word16 temp1, temp2, exp, exp1;
+ Word16 q_norm_val;
+ Word32 BinE_fx[STEREO_DFT_N_12k8_ENC / 2]; /* NB_BANDS = 20 (= 6350Hz) = highest band available for SR 12.8 -> bin_cnt = 158 */
+ Word32 c_1_fx, s_1_fx, g_1_fx, g_2_fx;
+ Word64 band_ener;
+ Word32 BinE, tmp_fx;
+ Word32 start_freq;
+ Word32 min_ener;
+ Word16 shift = 0;
+ move16();
+
/* One window - 40ms*12.8kHz = 512 samples */
- Word32 c_1_fx = 2147321984; // cosf( PI2 / STEREO_DFT_N_12k8_ENC ) * ONE_IN_Q31;
- Word32 s_1_fx = 26352928; // sinf( PI2 / STEREO_DFT_N_12k8_ENC ) * ONE_IN_Q31;
- Word32 g_1_fx = 1570240000; // ( 1.f + 0.68f * 0.68f ) * ONE_IN_Q30;
- Word32 g_2_fx = 1460288896; // 2 * 0.68f * ONE_IN_Q30;
+ c_1_fx = 1073660991; // 0.999924719 in Q30, cosf( PI2 / STEREO_DFT_N_12k8_ENC )
+ s_1_fx = 13176464; // 0.0122715384 in Q30, sinf( PI2 / STEREO_DFT_N_12k8_ENC )
+ g_1_fx = 1570240043; // 1.4624 in Q30, ( 1.f + 0.68f * 0.68f )
+ g_2_fx = 1460288880; // 1.36 in Q30, 2 * 0.68f
move32();
move32();
move32();
move32();
- Word32 g_fx;
- Word32 scaleWin_fx;
-
- Word32 BinE_fx[STEREO_DFT_N_12k8_ENC / 2]; /* NB_BANDS = 20 (= 6350Hz) = highest band available for SR 12.8 -> bin_cnt = 158 */
- Word16 tmp16, scale = 0;
- tmp16 = BASOP_Util_Divide3216_Scale( input_Fs, hCPE->hStereoDft->NFFT, &scale );
- tmp16 = shr( tmp16, negate( add( 1, scale ) ) );
- Word16 bin_freq = tmp16; // input_Fs / (float) hCPE->hStereoDft->NFFT; /* adaptive frequency bin width */
-
- // scaleWin = 1 / ( 2 * hCPE->hStereoDft->win_ana_energy );
- // scaleWin_fx = ONE_IN_Q31/ ( hCPE->hStereoDft->win_ana_energy_fx );
- scaleWin_fx = BASOP_Util_Divide3216_Scale( ONE_IN_Q31, hCPE->hStereoDft->win_ana_energy_fx, &scale ); // q = 16-scale
- Word16 scalewin_q = sub( 16, scale );
- tmp16 = BASOP_Util_Divide3216_Scale( BIN, bin_freq, &scale );
- tmp16 = shr( tmp16, negate( add( 1, scale ) ) );
- Word16 x_fx = tmp16;
+ bin_cnt = 0;
move16();
- scaleWin_fx = L_mult0( x_fx, extract_l( scaleWin_fx ) ); // scalewin_q
- // scaleWin *= (float) BIN / bin_freq;
- // norm_val = scaleWin * 4.0f / ( hCPE->hStereoDft->NFFT * hCPE->hStereoDft->NFFT );
- norm_val_fx = L_deposit_l( BASOP_Util_Divide3232_Scale( L_shl( scaleWin_fx, Q2 ), L_mult0( hCPE->hStereoDft->NFFT, hCPE->hStereoDft->NFFT ), &scale ) );
- norm_val_fx = L_shl( norm_val_fx, Q31 - ( scalewin_q + 15 - scale ) ); // q31
+
+ /* input_Fs / (float) hCPE->hStereoDft->NFFT;*/ /* adaptive frequency bin width */
+ bin_freq = BASOP_Util_Divide3216_Scale( input_Fs, hCPE->hStereoDft->NFFT, &exp );
+ bin_freq = shl( bin_freq, add( 1, exp ) ); // Q0
+
+ /* scaleWin = 1 / ( 2 * hCPE->hStereoDft->win_ana_energy );
+ scaleWin *= (float) BIN / bin_freq; */
+
+ temp2 = BASOP_Util_Divide3216_Scale( BIN, bin_freq, &exp );
+ temp2 = shl( temp2, add( 1, exp ) ); // Q0
+ exp = norm_s( hCPE->hStereoDft->win_ana_energy_fx );
+ temp1 = div_s( ONE_IN_Q14, shl( hCPE->hStereoDft->win_ana_energy_fx, exp ) ); // 14-(15+exp-1)+15 = 15+exp
+ scaleWin_fx = L_mult0( temp1, temp2 ); // 15+exp
+
+ /* scaleWin * 4.0f makes Q of scaleWin_fx from 15+exp to 13+exp
+ norm_val = scaleWin * 4.0f / ( hCPE->hStereoDft->NFFT * hCPE->hStereoDft->NFFT ); */
+
+ norm_val_fx = BASOP_Util_Divide3232_Scale( scaleWin_fx, L_mult0( hCPE->hStereoDft->NFFT, hCPE->hStereoDft->NFFT ), &exp1 ); // 13+exp+15-exp1 = 28+exp-exp1
+ q_norm_val = add( 28, sub( exp, exp1 ) );
ptR_fx = &DFT_past_DMX_fx[2]; /* first real */
ptI_fx = &DFT_past_DMX_fx[3]; /* first imaginary */
- move32();
- move32();
- c_fx = c_1_fx;
- s_fx = s_1_fx;
+
+ c_fx = c_1_fx; // Q30
+ s_fx = s_1_fx; // Q30
move32();
move32();
/* for low frequency bins, save per bin energy for the use in find_tilt() */
freq = bin_freq;
move32();
+
+ *q_band = add( shl( Q_inp_dmx, 1 ), sub( q_norm_val, 48 ) );
+ move16();
+ *q_Bin_E = *q_band;
+ move16();
+
+ IF( GT_16( *q_band, 39 ) )
+ {
+ shift = sub( *q_band, 39 );
+ *q_band = 39;
+ move16();
+ }
+
+ min_ener = L_shl( E_MIN_FXQ31 /* 0.0035 in Q31 */, sub( *q_band, 31 ) );
FOR( i = 0; i < NB_BANDS - 1; i++ ) /* up to maximum allowed voiced critical band */
{
- band_fx[i] = 0;
+ band_ener = 0;
+ move64();
+ start_freq = freq;
move32();
- cnt = 0;
- move16();
+
/* bins up to crit_band 17 (<= 3700 Hz):
* bin_cnt old (bin_width 50 Hz): 74 (74 * FRAMES_PER_SEC = 3700)
* bin_cnt new (bin_width 40 Hz): 92 (92 * 40 = 3680)
*/
- tmp16 = BASOP_Util_Divide3216_Scale( L_sub( crit_bands_fx[i], freq ), bin_freq, &scale );
- tmp16 = shr( tmp16, negate( add( 1, scale ) ) );
- Word32 freq_diff = L_deposit_l( tmp16 );
- Word16 guarded_bits;
- guarded_bits = find_guarded_bits_fx( freq_diff );
- s_fx = L_shr( s_fx, guarded_bits );
- c_fx = L_shr( c_fx, guarded_bits );
+
WHILE( LE_32( freq, crit_bands_fx[i] ) )
{
- Word64 te = ( W_add( W_mult0_32_32( *ptR_fx, *ptR_fx ), W_mult0_32_32( *ptI_fx, *ptI_fx ) ) );
- Word16 te_exp = W_norm( te );
- te = W_shl( te, te_exp ); // 2 * Q_inp_dmx + te_exp
- BinE_fx[bin_cnt] = W_extract_h( te ); // 2 * Q_inp_dmx + te_exp - 32
- move32();
- g_fx = L_sub( L_shr( g_1_fx, guarded_bits ), Mpy_32_32( g_2_fx, c_fx ) ); // 30 - guarded_bits
- tmp_fx = L_sub( Mpy_32_32( c_fx, c_1_fx ), Mpy_32_32( s_fx, s_1_fx ) ); // 31 - guarded_bits
- s_fx = L_add( Mpy_32_32( s_fx, c_1_fx ), Mpy_32_32( c_fx, s_1_fx ) ); // 31 - guarded_bits
- c_fx = tmp_fx; // 31 - guarded_bits
+ // g_fx = L_sub( g_1_fx, L_shl( Mpy_32_32( g_2_fx, c_fx ), 1 ) ); // 30
+ g_fx = L_sub( L_shr( g_1_fx, 1 ), Mpy_32_32( g_2_fx, c_fx ) ); // 29
+ tmp_fx = Msub_32_32( Mpy_32_32( c_fx, c_1_fx ), s_fx, s_1_fx ); // 29
+ s_fx = L_shl( Madd_32_32( Mpy_32_32( s_fx, c_1_fx ), c_fx, s_1_fx ), 1 ); // 30
+ c_fx = L_shl( tmp_fx, 1 ); // 30
+
+ BinE = Madd_32_32( Mpy_32_32( *ptR_fx, *ptR_fx ), *ptI_fx, *ptI_fx ); // 2*Q_inp_dmx-31
+ BinE_fx[bin_cnt] = Mpy_32_32( BinE, Mpy_32_16_1( g_fx, norm_val_fx ) ); // (2*Q_inp_dmx-31)+(q_norm_val+29-15)-31 = 2*Q_inp_dmx+q_norm_val-48 = *q_Bin_E
move32();
- Word64 ngmult = W_mult0_32_32( norm_val_fx, g_fx ); // Q31 + Q30 - gaurded_bits
- Word16 ngmult_exp = W_norm( ngmult );
- ngmult = W_shl( ngmult, ngmult_exp ); // Q31 + Q30 - gaurded_bits + ngmult_exp
- BinE_fx[bin_cnt] = Mpy_32_32( W_extract_h( ngmult ), BinE_fx[bin_cnt] ); //(Q31 + Q31 - gaurded_bits + ngmult_exp) - Q32 + (2 * Q_inp_dmx + te_exp - 32) - 31
- move32();
- // To Be Checked
- BinE_fx[bin_cnt] = L_shl_sat( BinE_fx[bin_cnt], sub( *Qout, sub( sub( add( add( shl( Q_inp_dmx, 1 ), te_exp ), ngmult_exp ), 34 ), guarded_bits ) ) );
- move32();
- // To Be Checked
- band_fx[i] = L_add_sat( BinE_fx[bin_cnt], band_fx[i] );
- move32();
+ /*
+ BIN_FREQ_FX = BIN, cnt = ( ( crit_bands_fx[i] - start_freq ) / bin_freq ) + 1
+ band[i] = BinE[bin_cnt];
+ band[i] *= inv_tbl[cnt]; // normalization per frequency bin
+ */
+ band_ener = W_mac_32_16( band_ener, BinE_fx[bin_cnt], inv_tbl_fx[( ( crit_bands_fx[i] - start_freq ) / bin_freq ) + 1] ); // *q_band+shift+16
+
ptR_fx += 2;
ptI_fx += 2;
- freq = L_add( freq, L_deposit_l( bin_freq ) );
- cnt = add( cnt, 1 );
+ freq = L_mac0( freq, bin_freq, 1 );
bin_cnt = add( bin_cnt, 1 );
}
- s_fx = L_shl( s_fx, guarded_bits );
- c_fx = L_shl( c_fx, guarded_bits );
- band_fx[i] = Mpy_32_16_r( band_fx[i], inv_tbl_fx[cnt] ); /* normalization per frequency bin */
+
+ /* normalization per frequency bin */
+ band_fx[i] = W_extract_h( W_shl( band_ener, sub( Q16, shift ) ) ); // *q_band
move32();
- band_ener_fx[i] = band_fx[i]; /* per band energy without E_MIN */
+
+ /* per band energy without E_MIN */
+ band_ener_fx[i] = band_fx[i]; // *q_band
move32();
- IF( LT_32( band_fx[i], L_shl( E_MIN_Q11_FX, sub( *Qout, Q11 ) ) ) )
+
+ if ( LT_32( band_fx[i], min_ener ) )
{
- band_fx[i] = L_shl( E_MIN_Q11_FX, sub( *Qout, Q11 ) );
+ band_fx[i] = min_ener; // *q_band
move32();
}
}
@@ -343,52 +368,47 @@ static void find_enr_dft_fx(
/* NB_BANDS = 24 (= 15500Hz) = highest band available for SR 32 -> bin_cnt = 387 */
/* NB_BANDS = 24 (= 15500Hz) = highest band available for SR 48 -> bin_cnt = 387 */
- for ( ; i < NB_BANDS; i++ )
+ FOR( ; i < NB_BANDS; i++ )
{
- band_fx[i] = 0;
+ band_ener = 0;
+ move64();
+ start_freq = freq;
move32();
- cnt = 0;
- move16();
- tmp16 = BASOP_Util_Divide3216_Scale( L_sub( 6399, freq ), bin_freq, &scale );
- tmp16 = shr( tmp16, negate( add( 1, scale ) ) );
- Word32 freq_diff = L_deposit_l( tmp16 );
- Word16 guarded_bits;
- guarded_bits = find_guarded_bits_fx( freq_diff );
- c_fx = L_shr( c_fx, guarded_bits );
+
WHILE( LT_32( freq, 6399 ) )
{
- Word64 te = ( W_add( W_mult0_32_32( *ptR_fx, *ptR_fx ), W_mult0_32_32( *ptI_fx, *ptI_fx ) ) );
- Word16 te_exp = W_norm( te );
- te = W_shl( te, te_exp ); // 2 * Q_inp_dmx + te_exp
- BinE_fx[bin_cnt] = W_extract_h( te ); // 2 * Q_inp_dmx + te_exp - 32
- move32();
- g_fx = L_sub( L_shr( g_1_fx, guarded_bits ), Mpy_32_32( g_2_fx, c_fx ) );
- Word64 ngmult = W_mult0_32_32( norm_val_fx, g_fx ); // Q31 + Q31 - gaurded_bits
- Word16 ngmult_exp = W_norm( ngmult );
- ngmult = W_shl( ngmult, ngmult_exp ); // Q31 + Q31 - gaurded_bits + ngmult_exp
- BinE_fx[bin_cnt] = Mpy_32_32( W_extract_h( ngmult ), BinE_fx[bin_cnt] ); //(Q31 + Q31 - gaurded_bits + ngmult_exp) - Q32 + (2 * Q_inp_dmx + te_exp - 32) - 31
- move32();
- // To Be Checked
- BinE_fx[bin_cnt] = L_shl_sat( BinE_fx[bin_cnt], sub( *Qout, sub( sub( add( add( shl( Q_inp_dmx, 1 ), te_exp ), ngmult_exp ), 34 ), guarded_bits ) ) );
- move32();
- // To Be Checked
- band_fx[i] = L_add_sat( BinE_fx[bin_cnt], band_fx[i] );
+ // g_fx = L_sub( g_1_fx, L_shl( Mpy_32_32( g_2_fx, c_fx ), 1 ) ); // 30
+ g_fx = L_sub( L_shr( g_1_fx, 1 ), Mpy_32_32( g_2_fx, c_fx ) ); // 29
+
+ BinE = Madd_32_32( Mpy_32_32( *ptR_fx, *ptR_fx ), *ptI_fx, *ptI_fx ); // 2*Q_inp_dmx-31
+ BinE_fx[bin_cnt] = Mpy_32_32( BinE, Mpy_32_16_1( g_fx, norm_val_fx ) ); // (2*Q_inp_dmx-31)+(q_norm_val+29-15)-31 = 2*Q_inp_dmx+q_norm_val-48 = *q_Bin_E
move32();
+
+ /*
+ BIN_FREQ_FX = BIN, cnt = ( ( 6399 - start_freq ) / bin_freq ) + 1
+ band[i] = BinE[bin_cnt];
+ band[i] *= inv_tbl[cnt]; // normalization per frequency bin
+ */
+ band_ener = W_mac_32_16( band_ener, BinE_fx[bin_cnt], inv_tbl_fx[( ( 6399 - start_freq ) / bin_freq ) + 1] ); // *q_band+shift
+
ptR_fx += 2;
ptI_fx += 2;
- freq = L_add( freq, L_deposit_l( bin_freq ) );
- cnt = add( cnt, 1 );
+ freq = L_mac0( freq, bin_freq, 1 );
bin_cnt = add( bin_cnt, 1 );
}
- c_fx = L_shl( c_fx, guarded_bits );
- band_fx[i] = Mpy_32_16_r( band_fx[i], inv_tbl_fx[cnt] );
+
+ /* normalization per frequency bin */
+ band_fx[i] = W_extract_h( W_shl( band_ener, sub( Q16, shift ) ) ); // *q_band
move32();
- band_ener_fx[i] = band_fx[i];
+
+ /* per band energy without E_MIN */
+ band_ener_fx[i] = band_fx[i]; // *q_band
move32();
- IF( LT_32( band_fx[i], L_shl( E_MIN_Q11_FX, sub( *Qout, Q11 ) ) ) )
+
+ if ( LT_32( band_fx[i], min_ener ) )
{
- band_fx[i] = L_shl( E_MIN_Q11_FX, sub( *Qout, Q11 ) );
+ band_fx[i] = min_ener; // *q_band
move32();
}
}
@@ -396,20 +416,26 @@ static void find_enr_dft_fx(
/* put bin energies from BinE into Bin_E[L_FFT/2-1] (interpolate 40 Hz bin values to fit into 50 Hz bins) */
/* Last value of Bin_E is handled outside this function*/
assert( bin_cnt == ( STEREO_DFT_N_12k8_ENC / 2 - 1 ) );
- BinE_fx[STEREO_DFT_N_12k8_ENC / 2 - 1] = BinE_fx[STEREO_DFT_N_12k8_ENC / 2 - 2];
+ BinE_fx[STEREO_DFT_N_12k8_ENC / 2 - 1] = BinE_fx[STEREO_DFT_N_12k8_ENC / 2 - 2]; // // *q_Bin_E
move32();
- L_lerp_fx( BinE_fx, Bin_E_fx, L_FFT / 2, STEREO_DFT_N_12k8_ENC / 2, Qout );
- MVR2R_WORD32( Bin_E_fx, ptE_fx, VOIC_BINS ); // Qout
+
+ L_lerp_fx( BinE_fx, Bin_E_fx, L_FFT / 2, STEREO_DFT_N_12k8_ENC / 2, q_Bin_E );
+
+ MVR2R_WORD32( Bin_E_fx, ptE_fx, VOIC_BINS ); // *q_Bin_E
+ *q_ptE = *q_Bin_E;
+ move16();
/* find the total log energy */
- tmp_fx = *Etot_fx;
- move32();
+ tot_ener = *Etot_fx;
+ move64();
+
FOR( i = min_band; i <= max_band; i++ )
{
- tmp_fx = L_add( tmp_fx, band_fx[i] ); // Qout
+ tot_ener = W_mac_32_32( tot_ener, band_fx[i], 1 ); // *q_band+1
}
- *Etot_fx = tmp_fx;
- move32();
+
+ *Etot_fx = tot_ener;
+ move64();
return;
}
@@ -418,38 +444,41 @@ static void find_enr_dft_fx(
*
* Spectral analysis of 12.8kHz input
*-------------------------------------------------------------------*/
-
void ivas_analy_sp_fx(
- const Word16 element_mode, /* i : element mode */
+ const Word16 element_mode, /* i : element mode Q0*/
CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
- const Word32 input_Fs, /* i : input sampling rate */
+ const Word32 input_Fs, /* i : input sampling rate Q0*/
Word16 *speech, /* i : speech buffer Q_new - preemph_bits */
const Word16 Q_new, /* i : current scaling exp Q0 */
- Word32 *fr_bands, /* o : energy in critical frequency bands Q_new + QSCALE */
- Word32 *lf_E, /* o : per bin E for first... Q_new + QSCALE - 2*/
+ Word32 *fr_bands, /* o : energy in critical frequency bands q_fr_bands */
+ Word16 *q_fr_bands, /* o : energy in critical frequency bands Q0 */
+ Word32 *lf_E, /* o : per bin E for first... q_lf_E */
+ Word16 *q_lf_E, /* o : per bin E for first... Q0 */
Word16 *Etot, /* o : total input energy Q8 */
const Word16 min_band, /* i : minimum critical band Q0 */
const Word16 max_band, /* i : maximum critical band Q0 */
- const Word32 e_min_scaled, /* i : minimum energy scaled Q_new + QSCALE */
- Word16 Scale_fac[2], /* o : FFT scales factors (2 values by frame) Q0 */
Word32 *Bin_E, /* o : per-bin energy spectrum Q7 */
+ Word16 *q_Bin_E, /* o : per-bin energy spectrum Q7 */
Word32 *Bin_E_old, /* o : per-bin energy spectrum of the previous frame Q7 */
- Word32 *PS, /* o : per-bin energy spectrum Q_new + QSCALE */
+ Word16 *q_Bin_E_old, /* o : per-bin energy spectrum of the previous frame Q7 */
+ Word32 *PS, /* o : per-bin energy spectrum Q_new + QSCALE - 2 */
+ Word16 *q_PS, /* o : per-bin energy spectrum Q_new + QSCALE - 2 */
Word16 *EspecdB, /* o : per-bin log energy spectrum (with f=0) Q7 */
- Word32 *band_energies, /* o : energy in critical frequency bands without minimum noise floor MODE2_E_MIN (Q_new + QSCALE + 2)*/
- Word16 *fft_buff /* o : FFT coefficients (Q_new + QSCALE + 2) */
+ Word32 *band_energies, /* o : energy in critical frequency bands without minimum noise floor MODE2_E_MIN (q_band_energies)*/
+ Word16 *q_band_energies, /* o : Q of energy in critical frequency bands without minimum noise floor MODE2_E_MIN */
+ Word16 *fft_buff, /* o : FFT coefficients (q_fft_buff) */
+ Word16 *q_fft_buff /* o : Q of FFT coefficients Q0 */
)
{
Word16 *pt;
Word16 i_subfr, i;
Word32 *pt_bands;
- Word32 Ltmp, LEtot;
+ Word32 Ltmp;
Word16 *pt_fft;
- Word16 Min_val, Max_val;
- Word16 Scale_fac2;
- Word16 fft_temp[L_FFT];
-
- (void) input_Fs;
+ Word16 exp, tmp;
+ Word64 LEtot;
+ LEtot = 0;
+ move64();
/*-----------------------------------------------------------------*
* Compute spectrum
* find energy per critical frequency band and total energy in dB
@@ -457,284 +486,209 @@ void ivas_analy_sp_fx(
pt_bands = fr_bands;
pt_fft = fft_buff;
- LEtot = L_deposit_l( 0 );
+
IF( NE_16( element_mode, IVAS_CPE_DFT ) )
{
- FOR( i_subfr = 0; i_subfr <= 1; i_subfr++ )
+ IF( is_zero_arr16( speech + 3 * ( L_SUBFR / 2 ) - L_FFT / 2, L_FFT + 4 * ( L_SUBFR / 2 ) ) )
{
- pt = speech + 3 * ( L_SUBFR / 2 ) - L_FFT / 2;
- IF( i_subfr != 0 )
- {
- pt = speech + 7 * ( L_SUBFR / 2 ) - L_FFT / 2;
- }
-
- /* Clear 1st value of 1st part, copy 1st value of 2nd part */
- fft_temp[0] = 0;
- move16();
- fft_temp[L_FFT / 2] = pt[L_FFT / 2];
+ set16_fx( pt_fft, 0, 2 * L_FFT );
+ *q_fft_buff = Q15;
move16();
- Max_val = s_max( fft_temp[0], fft_temp[L_FFT / 2] );
- Min_val = s_min( fft_temp[0], fft_temp[L_FFT / 2] );
-
- FOR( i = 1; i < L_FFT / 2; i++ )
- {
- /* 1st windowed part */
- fft_temp[i] = mult_r( pt[i], sqrt_han_window_fx[i] );
- move16();
- if ( fft_temp[i] > 0 )
- Max_val = s_max( Max_val, fft_temp[i] );
- if ( fft_temp[i] < 0 )
- Min_val = s_min( Min_val, fft_temp[i] );
-
- /* 2nd windowed part */
- fft_temp[L_FFT - i] = mult_r( pt[L_FFT - i], sqrt_han_window_fx[i] );
- move16();
- if ( fft_temp[L_FFT - i] > 0 )
- Max_val = s_max( Max_val, fft_temp[L_FFT - i] );
- if ( fft_temp[L_FFT - i] < 0 )
- Min_val = s_min( Min_val, fft_temp[L_FFT - i] );
- }
- /* Combine -Min_val and Max_val into one */
- Max_val = s_max( negate( Min_val ), Max_val );
+ set32_fx( Bin_E, 0, L_FFT );
+ set32_fx( lf_E, 0, 2 * VOIC_BINS );
+ set32_fx( band_energies, 0, 2 * NB_BANDS );
+ set32_fx( fr_bands, E_MIN_FXQ31, 2 * NB_BANDS ); // Q31 (*q_fr_bands)
- Scale_fac[i_subfr] = s_min( sub( norm_s( Max_val ), 1 ), 6 );
+ LEtot = W_shl( W_mult_32_16( E_MIN_FXQ31, add( sub( max_band, min_band ), 1 ) ), 1 ); // Q32 (*q_fr_bands+1)
+ *q_fr_bands = Q31;
+ *q_lf_E = *q_fr_bands;
move16();
- Scale_fac2 = shl( Scale_fac[i_subfr], 1 );
- Scale_sig( fft_temp, L_FRAME_12k8, Scale_fac[i_subfr] );
-
- r_fft_fx_lc( FFT_W128, SIZE_256, SIZE2_256, NUM_STAGE_256, fft_temp, pt_fft, 1 );
- Scale_sig( pt_fft, L_FFT, -1 ); // Q(-1)
- /*e_min_scaled = Q_new + QSCALE + 2*/
- ivas_find_enr( pt_fft, pt_bands, lf_E + i_subfr * VOIC_BINS, &LEtot, min_band, max_band,
- add( Q_new, Scale_fac2 ), e_min_scaled, &Bin_E[i_subfr * L_FFT / 2], BIN, band_energies + i_subfr * NB_BANDS );
- pt_bands += NB_BANDS;
- pt_fft += L_FFT;
- }
- LEtot = L_shl_sat( LEtot, 2 ); // Q_new + Q_SCALE - 2
- }
- ELSE
- {
- Word16 Qout = add( Q_new, QSCALE - 2 );
- find_enr_dft_fx( hCPE, input_Fs, hCPE->hStereoDft->DFT_fx[0], pt_bands, lf_E, &LEtot, min_band, max_band, Bin_E, band_energies, sub( Q31, hCPE->hStereoDft->DFT_fx_e[0] ), &Qout );
- MVR2R_WORD32( lf_E, lf_E + VOIC_BINS, VOIC_BINS );
- MVR2R_WORD32( Bin_E, Bin_E + ( L_FFT / 2 ), L_FFT / 2 );
- MVR2R_WORD32( band_energies, band_energies + NB_BANDS, NB_BANDS );
- MVR2R_WORD32( pt_bands, pt_bands + NB_BANDS, NB_BANDS );
- LEtot = L_shl( LEtot, 1 );
- }
- Word32 temp32_log;
- temp32_log = L_add( BASOP_Util_Log2( L_shr( LEtot, 1 ) ), L_shl( sub( Q31, add( Q_new, QSCALE - Q2 ) ), Q25 ) );
- temp32_log = Mpy_32_32( temp32_log, 1616142483 ); // log10(x) = log2(x)/log2(10)
- /* 10.0 * log10( (float) tmp )*/
- /* 10.0/log2(10) in Q29 = 1616142483*/
- *Etot = extract_l( L_shr( temp32_log, 23 - 8 ) ); // Q8
-
- Bin_E[L_FFT / 2 - 1] = Bin_E[L_FFT / 2 - 2];
- move32();
- Bin_E[L_FFT - 1] = Bin_E[L_FFT - 2];
- move32();
-
- /* Per-bin log-energy spectrum */
-
- FOR( i = 0; i < L_FFT / 2; i++ )
- {
- Bin_E_old[i] = Bin_E[i];
- move32();
- /* tmp = (input[i] + input[i+Len]+0.001f)/2.0f */
- Ltmp = L_max( L_shr( 21474, sub( Q31, add( Q_new, QSCALE ) ) ), L_add( L_shr( Bin_E[i], 1 ), L_shr( Bin_E[i + L_FFT / 2], 1 ) ) );
- if ( PS != NULL )
- {
- PS[i] = Ltmp;
- move32();
- }
- if ( EspecdB != NULL )
- {
- temp32_log = L_add( BASOP_Util_Log2( Ltmp ), L_shl( sub( Q31, Q_new + QSCALE ), Q25 ) );
- EspecdB[i] = extract_l( L_shr( Mpy_32_32( temp32_log, 1860652798 ), Q22 - Q7 ) ); /*log(x) = log2(x)*logf(2)*/
- /* 10.0*log((float)tmp) */
- /* 10.0*logf(2) in Q28 = 1860652798 */
-
move16();
}
- }
-
-
- return;
-}
-
-void ivas_analy_sp_fx_front(
- const Word16 element_mode, /* i : element mode */
- CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
- const Word32 input_Fs, /* i : input sampling rate */
- Word16 *speech, /* i : speech buffer Q_new - preemph_bits */
- const Word16 Q_new, /* i : current scaling exp Q0 */
- Word32 *fr_bands, /* o : energy in critical frequency bands Q_new + QSCALE - 2 */
- Word32 *lf_E, /* o : per bin E for first... Q_new + QSCALE - 2 */
- Word16 *Etot, /* o : total input energy Q8 */
- const Word16 min_band, /* i : minimum critical band Q0 */
- const Word16 max_band, /* i : maximum critical band Q0 */
- const Word32 e_min_scaled, /* i : minimum energy scaled Q_new + QSCALE - 2 */
- Word16 Scale_fac[2], /* o : FFT scales factors (2 values by frame) Q0 */
- Word32 *Bin_E, /* o : per-bin energy spectrum Q7 */
- Word32 *Bin_E_old, /* o : per-bin energy spectrum of the previous frame Q7 */
- Word32 *PS, /* o : per-bin energy spectrum Q_new + QSCALE - 2 */
- Word16 *EspecdB, /* o : per-bin log energy spectrum (with f=0) Q7 */
- Word32 *band_energies, /* o : energy in critical frequency bands without minimum noise floor MODE2_E_MIN (Q_new + QSCALE - 2)*/
- Word16 *fft_buff /* o : FFT coefficients (Q_new + Scale_fac[i_subfr]) */
-)
-{
- Word16 *pt;
- Word16 i_subfr, i;
- Word32 *pt_bands;
- Word32 Ltmp, LEtot;
- Word16 *pt_fft;
- Word32 temp32_log;
- Word16 max_pfft;
- /*-----------------------------------------------------------------*
- * Compute spectrum
- * find energy per critical frequency band and total energy in dB
- *-----------------------------------------------------------------*/
-
- pt_bands = fr_bands;
- pt_fft = fft_buff;
- LEtot = L_deposit_l( 0 );
- IF( NE_16( element_mode, IVAS_CPE_DFT ) )
- {
- FOR( i_subfr = 0; i_subfr <= 1; i_subfr++ )
+ ELSE
{
- /* set pointer to the beginning of the signal for spectral analysis */
- /* set the pointer for first analysis window */
- pt = speech + 3 * ( L_SUBFR / 2 ) - L_FFT / 2;
- IF( i_subfr != 0 )
- {
- /* set the pointer for second analysis window */
- pt = speech + 7 * ( L_SUBFR / 2 ) - L_FFT / 2;
- }
-
- /* Clear 1st value of 1st part, copy 1st value of 2nd part */
- pt_fft[0] = 0;
- move16();
- pt_fft[L_FFT / 2] = pt[L_FFT / 2];
+ 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 );
move16();
- FOR( i = 1; i < L_FFT / 2; i++ )
+ FOR( i_subfr = 0; i_subfr <= 1; i_subfr++ )
{
- /* 1st windowed part */
- pt_fft[i] = mult_r( pt[i], sqrt_han_window_fx[i] );
- move16();
+ /* set pointer to the beginning of the signal for spectral analysis */
+ /* set the pointer for first analysis window */
+ pt = speech + 3 * ( L_SUBFR / 2 ) - L_FFT / 2;
+ if ( i_subfr != 0 )
+ {
+ /* set the pointer for second analysis window */
+ pt = speech + 7 * ( L_SUBFR / 2 ) - L_FFT / 2;
+ }
- /* 2nd windowed part */
- pt_fft[L_FFT - i] = mult_r( pt[L_FFT - i], sqrt_han_window_fx[i] );
+ /* Clear 1st value of 1st part, copy 1st value of 2nd part */
+ pt_fft[0] = 0;
move16();
- }
-
- maximum_abs_16_fx( pt_fft, L_FFT, &max_pfft );
- IF( max_pfft > 0 )
- {
- Scale_fac[i_subfr] = sub( norm_s( max_pfft ), LOG2_L_FFT );
+ pt_fft[L_FFT / 2] = pt[L_FFT / 2]; // Q_new - preemph_bits
move16();
- }
- Scale_sig( pt_fft, L_FFT, Scale_fac[i_subfr] );
+ FOR( i = 1; i < L_FFT / 2; i++ )
+ {
+ /* 1st windowed part */
+ pt_fft[i] = mult_r( pt[i], sqrt_han_window_fx[i] ); // Q_new - preemph_bits
+ move16();
+
+ /* 2nd windowed part */
+ pt_fft[L_FFT - i] = mult_r( pt[L_FFT - i], sqrt_han_window_fx[i] ); // Q_new - preemph_bits
+ move16();
+ }
- /* compute the spectrum */
- fft_rel_fx( pt_fft, L_FFT, LOG2_L_FFT );
+ scale_sig( pt_fft, L_FFT, scale );
- /* find energy per critical band */
- ivas_find_enr1( pt_fft, add( Q_new, Scale_fac[i_subfr] ), pt_bands, lf_E + i_subfr * VOIC_BINS, &LEtot, min_band, max_band,
- Q_new, e_min_scaled, &Bin_E[i_subfr * L_FFT / 2], BIN, band_energies + i_subfr * NB_BANDS );
+ /* compute the spectrum */
+ fft_rel_fx( pt_fft, L_FFT, LOG2_L_FFT );
- pt_bands += NB_BANDS;
- pt_fft += L_FFT;
+ /* 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 );
+
+ pt_bands += NB_BANDS;
+ pt_fft += L_FFT;
+ }
}
+ *q_Bin_E = *q_lf_E;
+ move16();
+
/* Average total log energy over both half-frames */
/* *Etot = 10.0f * (float)log10(0.5f * *Etot); */
*Etot = -12800 /* 10.f * logf(0.00001f) in Q8 */;
move16();
IF( LEtot != 0 )
{
- /* Q of LEtot is Q_new + Q_SCALE - 1, LEtot / 2 can be considered as LEtot in Q_new + Q_SCALE - 1*/
- temp32_log = BASOP_Util_Log10( LEtot, sub( Q31, add( Q_new, QSCALE - Q1 ) ) ); // Q25
- temp32_log = Mpy_32_32( temp32_log, 1342177280 /* 10.f in Q27 */ ); // (Q25, Q27) -> Q21
- *Etot = extract_l( L_shr( temp32_log, Q21 - Q8 ) ); // Q8
+ /* Q of LEtot is q_fr_bands+1, LEtot / 2 can be considered as LEtot in q_fr_bands+2 */
+ exp = W_norm( LEtot );
+ LEtot = W_shl( LEtot, exp ); // q_fr_bands+2+exp
+ Ltmp = BASOP_Util_Log10( W_extract_h( LEtot ), sub( 61, add( *q_fr_bands, exp ) ) /* 31-(q_fr_bands+2+exp-32) */ ); // Q25
+ Ltmp = Mpy_32_32( Ltmp, 1342177280 /* 10.f in Q27 */ ); // (Q25, Q27) -> Q21
+ *Etot = extract_h( L_shl( Ltmp, Q24 - Q21 ) ); // Q8
move16();
}
}
ELSE
{
- Word16 Qout = add( Q_new, QSCALE - 2 );
- find_enr_dft_fx( hCPE, input_Fs, hCPE->hStereoDft->DFT_fx[0], pt_bands, lf_E, &LEtot, min_band, max_band, Bin_E, band_energies, sub( Q31, hCPE->hStereoDft->DFT_fx_e[0] ), &Qout );
- scale_sig32( lf_E, VOIC_BINS, sub( add( Q_new, QSCALE - 2 ), Qout ) );
- scale_sig32( Bin_E, ( L_FFT / 2 ), sub( add( Q_new, QSCALE - 2 ), Qout ) );
- MVR2R_WORD32( lf_E, lf_E + VOIC_BINS, VOIC_BINS );
- MVR2R_WORD32( Bin_E, Bin_E + ( L_FFT / 2 ), L_FFT / 2 );
- MVR2R_WORD32( band_energies, band_energies + NB_BANDS, NB_BANDS );
- MVR2R_WORD32( pt_bands, pt_bands + NB_BANDS, NB_BANDS );
-
- /* *Etot *= 2.f;
- *Etot = 10.0f * (float)log10(0.5f * *Etot);
- => *Etot = 10.0f * (float)log10(*Etot);
- */
+ IF( is_zero_arr( hCPE->hStereoDft->DFT_fx[0], STEREO_DFT_N_MAX_ENC ) )
+ {
+ set32_fx( Bin_E, 0, L_FFT );
+ set32_fx( lf_E, 0, 2 * VOIC_BINS );
+ set32_fx( band_energies, 0, 2 * NB_BANDS );
+ set32_fx( fr_bands, E_MIN_FXQ31, 2 * NB_BANDS ); // Q31 (*q_fr_bands)
+
+ LEtot = W_shl( W_mult_32_16( E_MIN_FXQ31, add( sub( max_band, min_band ), 1 ) ), 1 ); // Q32 (*q_fr_bands+1)
+ *q_fr_bands = Q31;
+ *q_lf_E = *q_fr_bands;
+ move16();
+ move16();
+ }
+ ELSE
+ {
+ exp = sub( getScaleFactor32( hCPE->hStereoDft->DFT_fx[0], STEREO_DFT_N_MAX_ENC ), 1 );
+ scale_sig32( hCPE->hStereoDft->DFT_fx[0], STEREO_DFT_N_MAX_ENC, exp ); /* exp(hCPE->hStereoDft->DFT_fx_e[0] - exp) */
+ hCPE->hStereoDft->DFT_fx_e[0] = sub( hCPE->hStereoDft->DFT_fx_e[0], exp );
+ move16();
+ find_enr_dft_ivas_fx( hCPE, input_Fs, hCPE->hStereoDft->DFT_fx[0], pt_bands, q_fr_bands, lf_E, q_lf_E, &LEtot, min_band, max_band, Bin_E, q_Bin_E, band_energies, sub( Q31, hCPE->hStereoDft->DFT_fx_e[0] ) );
+ MVR2R_WORD32( lf_E, lf_E + VOIC_BINS, VOIC_BINS );
+ MVR2R_WORD32( Bin_E, Bin_E + ( L_FFT / 2 ), L_FFT / 2 );
+ MVR2R_WORD32( band_energies, band_energies + NB_BANDS, NB_BANDS );
+ MVR2R_WORD32( pt_bands, pt_bands + NB_BANDS, NB_BANDS );
+ }
/* Average total log energy over both half-frames */
*Etot = -12800 /* 10.f * logf(0.00001f) in Q8 */;
move16();
IF( LEtot != 0 )
{
- temp32_log = BASOP_Util_Log10( LEtot, sub( Q31, add( Q_new, QSCALE - Q2 ) ) ); // Q25
- temp32_log = Mpy_32_32( temp32_log, 1342177280 /* 10.f in Q27 */ ); // (Q25, Q27) -> Q21
- *Etot = extract_l( L_shr( temp32_log, Q21 - Q8 ) ); // Q8
+ exp = W_norm( LEtot );
+ LEtot = W_shl( LEtot, exp ); // q_fr_bands+exp
+ Ltmp = BASOP_Util_Log10( W_extract_h( LEtot ), sub( 62, add( *q_fr_bands, exp ) ) /* 31-(q_fr_bands+1+exp-32) */ ); // Q25
+ Ltmp = Mpy_32_32( Ltmp, 1342177280 /* 10.f in Q27 */ ); // (Q25, Q27) -> Q21
+ *Etot = extract_h( L_shl( Ltmp, Q24 - Q21 ) ); // Q8
move16();
}
}
+ *q_band_energies = *q_fr_bands;
+ move16();
+
+ exp = sub( getScaleFactor32( fr_bands, 2 * NB_BANDS ), 1 );
+ scale_sig32( fr_bands, 2 * NB_BANDS, exp ); /* q_fr_bands + exp */
+ *q_fr_bands = add( *q_fr_bands, exp );
+ move16();
+
+ exp = sub( getScaleFactor32( band_energies, 2 * NB_BANDS ), 1 );
+ scale_sig32( band_energies, 2 * NB_BANDS, exp ); /* q_band_energies + exp */
+ *q_band_energies = add( *q_band_energies, exp );
+ move16();
+
+ *q_Bin_E_old = *q_Bin_E;
+ move16();
+
+
/* Per-bin log-energy spectrum */
- Bin_E[L_FFT / 2 - 1] = Bin_E[L_FFT / 2 - 2];
+ Bin_E[L_FFT / 2 - 1] = Bin_E[L_FFT / 2 - 2]; // *q_Bin_E
move32();
- Bin_E[L_FFT - 1] = Bin_E[L_FFT - 2];
+ Bin_E[L_FFT - 1] = Bin_E[L_FFT - 2]; // *q_Bin_E
move32();
FOR( i = 0; i < L_FFT / 2; i++ )
{
- Bin_E_old[i] = Bin_E[i];
+ Bin_E_old[i] = Bin_E[i]; // *q_Bin_E
move32();
- /* tmp = (input[i] + input[i+Len]+0.001f)/2.0f */
- // Ltmp = L_max( L_shr( 21474, sub( Q31, add( Q_new, QSCALE ) ) ), L_add( L_shr( Bin_E[i], 1 ), L_shr( Bin_E[i + L_FFT / 2], 1 ) ) );
- Ltmp = L_add( L_shr( Bin_E[i], 1 ), L_shr( Bin_E[i + L_FFT / 2], 1 ) ); // average
- if ( Ltmp == 0 )
- {
- // Ltmp = L_min( L_shr( 21474, sub( Q31, add( Q_new, QSCALE - 2 ) ) ), 1 );
- Ltmp = L_max( L_shr( 21474, sub( Q31, add( Q_new, QSCALE - 2 ) ) ), 1 );
- if ( EspecdB != NULL )
- {
- // temp32_log = L_add( BASOP_Util_Log2( Ltmp ), L_shl( sub( Q31, Q_new + QSCALE ), Q25 ) );
- // EspecdB[i] = -1474; /* log(1e-5) in Q7 */
- EspecdB[i] = -14736; /* log(1e-5) in Q7 */
- move16();
- }
+ /* PS[i] = ( Bin_E[i] + 1e-5f + Bin_E[i + L_FFT / 2] + 1e-5f ) / 2.0f; */
+ PS[i] = W_extract_h( W_mac_32_32( W_mult_32_32( Bin_E[i], ONE_IN_Q30 ), Bin_E[i + L_FFT / 2], ONE_IN_Q30 ) ); // *q_Bin_E
+ move32();
+
+ /* Bin_E[i] = (float) ( 10.0f * log( PS[i] ) ); */
+ IF( EspecdB != NULL )
+ {
+ EspecdB[i] = -14736; /* ln(1e-5) in Q7 */
+ move16();
}
- else
+
+ Bin_E[i] = -482887093; /* ln(1e-5) in Q22 */
+ move32();
+
+ IF( GT_32( PS[i], L_shl_sat( 21475, sub( *q_Bin_E, Q31 ) ) ) /*1e - 5 in *q_bin_E */ )
{
+ Ltmp = L_add( BASOP_Util_Log2( PS[i] ), L_shl( sub( Q31, *q_Bin_E ), Q25 ) );
+ Bin_E[i] = Mpy_32_32( Ltmp, 1860652798 /*10.0*logf(2) in Q28 */ ); // Q22
+ move32();
+
+ tmp = extract_h( L_shl( Bin_E[i], Q23 - Q22 ) ); // Q7
if ( EspecdB != NULL )
{
- temp32_log = L_add( BASOP_Util_Log2( Ltmp ), L_shl( sub( Q31, Q_new + QSCALE - 2 ), Q25 ) );
- EspecdB[i] = extract_l( L_shr( Mpy_32_32( temp32_log, 1860652798 ), Q22 - Q7 ) ); /*log(x) = log2(x)*logf(2)*/
- /* 10.0*log((float)tmp) */
- /* 10.0*logf(2) in Q28 = 1860652798 */
-
+ EspecdB[i] = tmp; // Q7
move16();
}
}
- if ( PS != NULL )
- {
- PS[i] = Ltmp;
- move32();
- }
}
+ if ( q_PS != NULL )
+ {
+ *q_PS = *q_Bin_E;
+ move16();
+ }
+
+ 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();
+ }
return;
}
@@ -746,329 +700,108 @@ void ivas_analy_sp_fx_front(
* The energy is normalized by the number of frequency bins in a channel
*------------------------------------------------------------------------*/
+/* Merge with ivas_find_enr function once analy_sp is unified */
static void ivas_find_enr(
Word16 data[], /* i : fft result */
- Word32 band[], /* o : per band energy Q_new + QSCALE */
- Word32 *ptE, /* o : per bin energy for low frequencies Q_new + QSCALE-2 */
- Word32 *LEtot, /* o : total energy Q_new + QSCALE */
+ Word16 q_data, /* i : Q of fft result */
+ Word32 band[], /* o : per band energy q_band */
+ Word16 *q_band, /* o : Q of per band energy */
+ Word32 *ptE, /* o : per bin energy for low frequencies q_ptE */
+ Word16 *q_ptE, /* o : Q of per bin energy for low frequencies Q0 */
+ Word64 *LEtot, /* o : total energy q_band+1 */
const Word16 min_band, /* i : minimum critical band Q0 */
const Word16 max_band, /* i : maximum critical band Q0 */
- const Word16 Q_new2, /* i : scaling factor Q0 */
- const Word32 e_min, /* i : minimum energy scaled Q_new + QSCALE */
- Word32 *Bin_E, /* o : Per bin energy Q_new + QSCALE-2 */
- Word16 BIN_FREQ_FX, /* i : Number of frequency bins */
- Word32 *band_energies /* o : per band energy without MODE2_E_MIN */
+ Word32 *Bin_E, /* o : Per bin energy q_ptE */
+ Word16 BIN_FREQ_FX, /* i : Number of frequency bins Q0 */
+ Word32 *band_energies /* o : per band energy without MODE2_E_MIN q_band */
)
{
- Word16 i, cnt, shift_to_norm;
- Word16 freq, wtmp;
- Word16 *ptR, *ptI, diff_scaleP1, diff_scaleM2;
- Word16 exp_band;
- Word32 Ltmp, Ltmp1;
+ Word16 i;
+ Word16 freq;
+ Word16 *ptR, *ptI;
Word16 voic_band;
- Word32 etot;
- Word16 exp_etot;
- Word32 *tmpptr;
-#ifdef BASOP_NOGLOB_DECLARE_LOCAL
- Flag Overflow = 0;
+ Word64 etot, band_ener;
+ Word16 start_freq;
+ Word32 min_ener;
+ Word16 shift = 0;
move16();
-#endif
-
ptR = &data[1]; /* first real */
ptI = &data[L_FFT - 1]; /* first imaginary */
- /*-----------------------------------------------------------------------------------*
- * Scaling needed by band and ptE output
- * Wants all energies scaled by Q_new + QSCALE to maintain maximum
- * precision on bckr noise in clean speech
- * First shift left by Q_new + QSCALE than shift right by 2*Q_new-1
- * shift left (Q_new + QSCALE - (2*Q_new -1))
- * shift left (QSCALE - Q_new + 1) == shift left by (QSCALE+1) - Q_new
- *-----------------------------------------------------------------------------------*/
-
- diff_scaleP1 = sub( QSCALE + 1 + 1, Q_new2 );
- diff_scaleM2 = sub( QSCALE + 1 - 2, Q_new2 );
-
voic_band = VOIC_BAND_8k;
move16();
assert( VOIC_BAND == VOIC_BAND_8k );
- etot = L_deposit_l( 0 );
- exp_etot = 0;
- move16();
-
/*-----------------------------------------------------------------*
* For low frequency bins, save per bin energy for the use
* in NS and find_tilt()
*-----------------------------------------------------------------*/
- freq = BIN_FREQ_FX;
+ *q_ptE = add( shl( q_data, 1 ), 14 );
+ move16();
+ *q_band = add( shl( q_data, 1 ), 14 );
move16();
- FOR( i = 0; i < voic_band; i++ ) /* up to maximum allowed voiced critical band */
- {
- tmpptr = Bin_E;
- move16();
- Ltmp1 = L_deposit_l( 0 );
-
- FOR( ; freq <= crit_bands_fx[i]; freq += BIN_FREQ_FX )
- {
- /*ptE = *ptR * *ptR + *ptI * *ptI */ /* energy */
- Word64 te = ( W_add( W_mult0_32_32( *ptR, *ptR ), W_mult0_32_32( *ptI, *ptI ) ) ); // 2 * Qfft
- Word16 te_exp = W_norm( te );
- te = W_shl( te, te_exp ); // 2 * Qfft + te_exp
- Ltmp = W_extract_h( te ); // 2 * Qfft + te_exp - 32
-
- Ltmp = L_shr( Ltmp, sub( te_exp, 32 ) );
- /* *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
- *ptE = L_shl_o( Ltmp, diff_scaleM2, &Overflow );
-#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++;*/
- *Bin_E = *ptE;
- move32();
- Bin_E++;
- Ltmp1 = L_add( Ltmp1, Ltmp );
-
- ptE++;
- ptR++;
- ptI--;
- }
-
- exp_band = sub( norm_l( Ltmp1 ), 1 ); /* divide by 2 to ensure band < cnt */
- wtmp = round_fx( L_shl( Ltmp1, exp_band ) );
-
- /* band[i] /= cnt */ /* normalization per frequency bin */
- cnt = (Word16) ( Bin_E - tmpptr );
- shift_to_norm = norm_s( cnt );
- wtmp = div_s( wtmp, shl( cnt, shift_to_norm ) );
- Ltmp1 = L_deposit_l( wtmp );
-
- 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 /* BASOP_NOGLOB */
- move32(); /* band scaled by Q_new + QSCALE */
- BASOP_SATURATE_WARNING_ON_EVS;
-
- test();
- IF( GE_16( i, min_band ) && LE_16( i, max_band ) )
- {
- IF( LT_32( band[i], e_min ) )
- {
- Ltmp1 = L_shl( e_min, 0 );
- exp_band = 0;
- move16();
- }
-
- wtmp = sub( exp_band, exp_etot );
- if ( wtmp > 0 )
- {
- etot = L_shr( etot, wtmp );
- }
- exp_etot = s_max( exp_etot, exp_band );
- etot = L_add( etot, L_shl( Ltmp1, sub( exp_band, exp_etot ) ) );
- }
-
- band_energies[i] = band[i];
- move32();
-
- band[i] = L_max( band[i], e_min );
- move32();
- }
- IF( EQ_16( BIN_FREQ_FX, 50 ) )
+ IF( GT_16( *q_band, 39 ) )
{
- /*-----------------------------------------------------------------*
- * Continue compute the E per critical band for high frequencies
- *-----------------------------------------------------------------*/
-
- FOR( i = voic_band; i < NB_BANDS; i++ )
- {
- tmpptr = Bin_E;
- move16();
- Ltmp1 = L_deposit_l( 0 );
-
- FOR( ; freq <= crit_bands_fx[i]; freq += BIN_FREQ_FX )
- {
- /* *ptE = *ptR * *ptR + *ptI * *ptI */
- Word64 te = ( W_add( W_mult0_32_32( *ptR, *ptR ), W_mult0_32_32( *ptI, *ptI ) ) );
- Word16 te_exp = W_norm( te );
- te = W_shl( te, te_exp );
- Ltmp = W_extract_h( te );
- Ltmp = L_shr( Ltmp, sub( te_exp, 32 ) );
-
- /* *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
- *Bin_E = L_shl_o( Ltmp, diff_scaleM2, &Overflow );
-#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++;
- Ltmp1 = L_add( Ltmp1, Ltmp );
-
- ptR++;
- ptI--;
- }
-
- exp_band = sub( norm_l( Ltmp1 ), 1 ); /* divide by 2 to ensure band < cnt */
- wtmp = round_fx( L_shl( Ltmp1, exp_band ) );
-
- /* band[i] /= cnt */ /* normalization per frequency bin */
- cnt = (Word16) ( Bin_E - tmpptr );
- shift_to_norm = norm_s( cnt );
- wtmp = div_s( wtmp, shl( cnt, shift_to_norm ) );
- Ltmp1 = L_deposit_l( wtmp );
-
- 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;
-
- test();
- IF( GE_16( i, min_band ) && LE_16( i, max_band ) )
- {
- IF( LT_32( band[i], e_min ) )
- {
- Ltmp1 = L_shl( e_min, 0 );
- exp_band = 0;
- move16();
- }
-
- wtmp = sub( exp_band, exp_etot );
- if ( wtmp > 0 )
- {
- etot = L_shr( etot, wtmp );
- }
- exp_etot = s_max( exp_etot, exp_band );
-
- etot = L_add( etot, L_shl( Ltmp1, sub( exp_band, exp_etot ) ) );
- }
-
- band_energies[i] = band[i];
- move32();
-
- band[i] = L_max( band[i], e_min );
- move32();
- }
+ shift = sub( *q_band, 39 );
+ *q_band = 39;
+ move16();
}
- /*-----------------------------------------------------------------*
- * 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();
-
-
- return;
-}
-
-/* Merge with ivas_find_enr function once analy_sp is unified */
-static void ivas_find_enr1(
- Word16 data[], /* i : fft result */
- Word16 q_data, /* i : Q of fft result */
- Word32 band[], /* o : per band energy Q_new + QSCALE-2 */
- Word32 *ptE, /* o : per bin energy for low frequencies Q_new + QSCALE-2 */
- Word32 *LEtot, /* o : total energy Q_new + QSCALE-2 */
- const Word16 min_band, /* i : minimum critical band Q0 */
- const Word16 max_band, /* i : maximum critical band Q0 */
- const Word16 Q_new, /* i : scaling factor Q0 */
- const Word32 e_min, /* i : minimum energy scaled Q_new + QSCALE-2 */
- Word32 *Bin_E, /* o : Per bin energy Q_new + QSCALE-2 */
- Word16 BIN_FREQ_FX, /* i : Number of frequency bins */
- Word32 *band_energies /* o : per band energy without MODE2_E_MIN Q_new + QSCALE-2 */
-)
-{
- Word16 i, cnt;
- Word16 freq;
- Word16 *ptR, *ptI;
- Word32 Ltmp;
- Word16 voic_band;
- Word32 etot;
- Word32 norm_val;
-
- norm_val = 131072 /* 4.0f / ( L_FFT * L_FFT ) in Q31 */;
- move32();
-
- ptR = &data[1]; /* first real */
- ptI = &data[L_FFT - 1]; /* first imaginary */
-
- voic_band = VOIC_BAND_8k;
- move16();
- assert( VOIC_BAND == VOIC_BAND_8k );
-
- /*-----------------------------------------------------------------*
- * For low frequency bins, save per bin energy for the use
- * in NS and find_tilt()
- *-----------------------------------------------------------------*/
+ min_ener = L_shl( E_MIN_FXQ31, sub( *q_band, Q31 ) ); // *q_band
freq = BIN_FREQ_FX;
move16();
FOR( i = 0; i < voic_band; i++ ) /* up to maximum allowed voiced critical band */
{
- band[i] = 0;
- move32();
- cnt = 0;
+ band_ener = 0;
+ move64();
+ start_freq = freq;
move16();
WHILE( LE_32( freq, crit_bands_fx[i] ) )
{
- // *ptE = *ptR * *ptR + *ptI * *ptI; /* energy */
- Word64 te = ( W_add( W_mult0_32_32( *ptR, *ptR ), W_mult0_32_32( *ptI, *ptI ) ) ); // 2 * Qfft
- Word16 te_exp = W_norm( te );
- te = W_shl( te, te_exp ); // 2 * Qfft + te_exp
- Ltmp = W_extract_h( te ); // 2 * Qfft + te_exp - 32
-
- // *ptE *= norm_val; /* normalization - corresponds to FFT normalization by 2/L_FFT */
- Ltmp = Mpy_32_32( Ltmp, norm_val ); // 2 * Qfft + te_exp - 32
- *ptE = L_shl_sat( Ltmp, sub( add( Q_new, QSCALE - 2 ), add( shl( q_data, Q1 ), sub( te_exp, 32 ) ) ) ); // Q_new + QSCALE - 2
- move32();
+ /*
+ *ptE = *ptR * *ptR + *ptI * *ptI;
+
+ Overflow occurs in the above operation only when ptR and ptI values are equal to -32768.
+ In that case, energy value will be 2^31 (only one greater than max 32 bit value).
+ Hence, saturation is added.
+
+ *ptE *= norm_val;
+ norm_val = 4 / (256 * 256), As the value is in power's of 2, result can be obtained by increasing the Q factor
+
+ Q of energy = 2 * q_data + 14 = *q_ptE
+ */
- *Bin_E++ = *ptE; // Q_new + QSCALE - 2
+ *ptE = L_mac0_sat( L_mult0( *ptR, *ptR ), *ptI, *ptI ); // *q_ptE
move32();
- band[i] = L_add_sat( band[i], *ptE++ ); // Q_new + QSCALE - 2
+
+ *Bin_E++ = *ptE; // *q_ptE
move32();
+
+ /*
+ BIN_FREQ_FX = BIN, cnt = ( ( crit_bands_fx[i] - start_freq ) / BIN ) + 1
+ band[i] += *ptE++;
+ band[i] *= inv_tbl[cnt]; // normalization per frequency bin
+ */
+ band_ener = W_mac_32_16( band_ener, *ptE, inv_tbl_fx[( ( crit_bands_fx[i] - start_freq ) / BIN ) + 1] ); // *q_band+16+shift
ptR++;
ptI--;
-
+ ptE++;
freq = add( freq, BIN_FREQ_FX );
- cnt = add( cnt, 1 );
}
- band[i] = Mpy_32_16_1( band[i], inv_tbl_fx[cnt] ); /* normalization per frequency bin */ // Q_new + QSCALE - 2
+ band[i] = W_extract_h( W_shl( band_ener, sub( Q16, shift ) ) ); // *q_band
move32();
- band_energies[i] = band[i]; /* per band energy without E_MIN */ // Q_new + QSCALE - 2
+ band_energies[i] = band[i]; /* per band energy without E_MIN */ // *q_band
move32();
- if ( LT_32( band[i], e_min ) ) // Q_new + QSCALE - 2
+ if ( LT_32( band[i], min_ener ) ) // *q_band
{
- band[i] = e_min; // Q_new + QSCALE - 2
+ band[i] = min_ener; // *q_band
move32();
}
}
@@ -1081,41 +814,50 @@ static void ivas_find_enr1(
FOR( i = voic_band; i < NB_BANDS; i++ )
{
- band[i] = 0;
- move32();
- cnt = 0;
+ band_ener = 0;
+ move64();
+ start_freq = freq;
move16();
WHILE( LE_32( freq, crit_bands_fx[i] ) )
{
- // *Bin_E = *ptR * *ptR + *ptI * *ptI;
- Word64 te = ( W_add( W_mult0_32_32( *ptR, *ptR ), W_mult0_32_32( *ptI, *ptI ) ) ); // 2 * Qfft
- Word16 te_exp = W_norm( te );
- te = W_shl( te, te_exp ); // 2 * Qfft + te_exp
- Ltmp = W_extract_h( te ); // 2 * Qfft + te_exp - 32
-
- // *Bin_E *= norm_val;
- Ltmp = Mpy_32_32( Ltmp, norm_val ); // 2 * Qfft + te_exp - 32
- *Bin_E = L_shl_sat( Ltmp, sub( add( Q_new, QSCALE - 2 ), add( shl( q_data, Q1 ), sub( te_exp, 32 ) ) ) ); // Q_new + QSCALE - 2
- move32();
+ /*
+ *Bin_E = *ptR * *ptR + *ptI * *ptI;
+
+ Overflow occurs in the below operation only when ptR and ptI values are equal to - 32768.
+ In that case, energy value will be 2 ^ 31 (only one greater than max 32 bit value).
+ Hence, saturation is added.
+
+ *Bin_E *= norm_val;
+ norm_val = 4 / (256 * 256), As the value is in power's of 2, result can be obtained by increasing the Q factor
- band[i] = L_add_sat( band[i], *Bin_E++ ); // Q_new + QSCALE - 2
+ Q of energy = 2 * q_data + 14 = *q_ptE
+ */
+
+ *Bin_E = L_mac0_sat( L_mult0( *ptR, *ptR ), *ptI, *ptI ); // 2*q_data+14 = *q_ptE
move32();
+
+ /*
+ BIN_FREQ_FX = BIN, cnt = ( ( crit_bands_fx[i] - start_freq ) / BIN ) + 1
+ band[i] += *ptE++;
+ band[i] *= inv_tbl[cnt]; // normalization per frequency bin
+ */
+ band_ener = W_mac_32_16( band_ener, *Bin_E, inv_tbl_fx[( ( crit_bands_fx[i] - start_freq ) / BIN ) + 1] ); // *q_band+16+shift
ptR++;
ptI--;
+ Bin_E++;
freq = add( freq, BIN_FREQ_FX );
- cnt = add( cnt, 1 );
}
- band[i] = Mpy_32_16_1( band[i], inv_tbl_fx[cnt] ); /* normalization per frequency bin */ // Q_new + QSCALE - 2
+ band[i] = W_extract_h( W_shl_nosat( band_ener, sub( Q16, shift ) ) ); // *q_band
move32();
- band_energies[i] = band[i]; /* per band energy without E_MIN */ // Q_new + QSCALE - 2
+ band_energies[i] = band[i]; /* per band energy without E_MIN */ // *q_band
move32();
- if ( LT_32( band[i], e_min ) ) // Q_new + QSCALE - 2
+ if ( LT_32( band[i], min_ener ) ) // *q_band
{
- band[i] = e_min; // Q_new + QSCALE - 2
+ band[i] = min_ener; // *q_band
move32();
}
}
@@ -1125,14 +867,14 @@ static void ivas_find_enr1(
* Find the total energy over the input bandwidth
*-----------------------------------------------------------------*/
- etot = *LEtot;
- move32();
+ etot = *LEtot; // *q_band
+ move64();
FOR( i = min_band; i <= max_band; i++ )
{
- etot = L_add_sat( etot, band[i] ); // Q_new + QSCALE - 2
+ etot = W_mac_32_32( etot, band[i], 1 ); // *q_band+1
}
- *LEtot = etot;
- move32();
+ *LEtot = etot; // *q_band+1
+ move64();
return;
}
@@ -1147,7 +889,7 @@ static void find_enr(
const Word16 Q_new2, /* i : scaling factor Q0 */
const Word32 e_min, /* i : minimum energy scaled Q_new + QSCALE */
Word32 *Bin_E, /* o : Per bin energy Q_new + QSCALE-2 */
- Word16 BIN_FREQ_FX, /* i : Number of frequency bins */
+ Word16 BIN_FREQ_FX, /* i : Number of frequency bins Q0 */
Word32 *band_energies /* o : per band energy without MODE2_E_MIN */
)
{
@@ -1162,7 +904,7 @@ static void find_enr(
Word32 *tmpptr;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
- move16();
+ move32();
#endif
@@ -1198,7 +940,7 @@ static void find_enr(
move16();
FOR( i = 0; i < voic_band; i++ ) /* up to maximum allowed voiced critical band */
{
- tmpptr = Bin_E;
+ tmpptr = Bin_E; /* Q_new + QSCALE - 2 */
move16();
Ltmp1 = L_deposit_l( 0 );
@@ -1210,13 +952,9 @@ 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
- *ptE = L_shl_o( Ltmp, diff_scaleM2, &Overflow );
-#else /* BASOP_NOGLOB */
- *ptE = L_shl( Ltmp, diff_scaleM2 );
-#endif /* BASOP_NOGLOB */
- move32(); /* scaled by Q_new + QSCALE - 2 */
+ 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 */
+ move32(); /* scaled by Q_new + QSCALE - 2 */
BASOP_SATURATE_WARNING_ON_EVS;
/*band[i] += *ptE++;*/
*Bin_E = *ptE;
@@ -1235,18 +973,14 @@ static void find_enr(
/* band[i] /= cnt */ /* normalization per frequency bin */
cnt = (Word16) ( Bin_E - tmpptr );
shift_to_norm = norm_s( cnt );
- wtmp = div_s( wtmp, shl( cnt, shift_to_norm ) );
- Ltmp1 = L_deposit_l( wtmp );
+ wtmp = div_s( wtmp, shl( cnt, shift_to_norm ) ); /* Q15 */
+ Ltmp1 = L_deposit_l( wtmp ); /* Q15 */
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 /* BASOP_NOGLOB */
- move32(); /* band scaled by Q_new + QSCALE */
+ 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 */
+ move32(); /* band scaled by Q_new + QSCALE */
BASOP_SATURATE_WARNING_ON_EVS;
test();
@@ -1268,7 +1002,7 @@ static void find_enr(
etot = L_add( etot, L_shl( Ltmp1, sub( exp_band, exp_etot ) ) );
}
- band_energies[i] = band[i];
+ band_energies[i] = band[i]; /* Q_new + QSCALE */
move32();
band[i] = L_max( band[i], e_min );
@@ -1295,13 +1029,9 @@ 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
- *Bin_E = L_shl_o( Ltmp, diff_scaleM2, &Overflow );
-#else /* BASOP_NOGLOB */
- *Bin_E = L_shl( Ltmp, diff_scaleM2 );
-#endif /* BASOP_NOGLOB */
- move32(); /* scaled by Q_new + QSCALE - 2 */
+ 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 */
+ move32(); /* scaled by Q_new + QSCALE - 2 */
BASOP_SATURATE_WARNING_ON_EVS;
Bin_E++;
Ltmp1 = L_add( Ltmp1, Ltmp );
@@ -1322,255 +1052,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;
-
- test();
- IF( GE_16( i, min_band ) && LE_16( i, max_band ) )
- {
- IF( LT_32( band[i], e_min ) )
- {
- Ltmp1 = L_shl( e_min, 0 );
- exp_band = 0;
- move16();
- }
-
- wtmp = sub( exp_band, exp_etot );
- if ( wtmp > 0 )
- {
- etot = L_shr( etot, wtmp );
- }
- exp_etot = s_max( exp_etot, exp_band );
-
- etot = L_add( etot, L_shl( Ltmp1, sub( exp_band, exp_etot ) ) );
- }
-
- band_energies[i] = band[i];
- move32();
-
- band[i] = L_max( band[i], e_min );
- move32();
- }
- }
-
- /*-----------------------------------------------------------------*
- * 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();
-
-
- return;
-}
-
-#ifdef IVAS_FLOAT_FIXED1
-/*------------------------------------------------------------------------*
- * ivas_find_enr()
- *
- * find input signal energy for each critical band and first 74 LF bins
- * The energy is normalized by the number of frequency bins in a channel
- *------------------------------------------------------------------------*/
-
-static void ivas_find_enr(
- Word16 data[], /* i : fft result */
- Word32 band[], /* o : per band energy Q_new + QSCALE */
- Word32 *ptE, /* o : per bin energy for low frequencies Q_new + QSCALE-2 */
- Word32 *LEtot, /* o : total energy Q_new + QSCALE */
- const Word16 min_band, /* i : minimum critical band Q0 */
- const Word16 max_band, /* i : maximum critical band Q0 */
- const Word16 Q_new2, /* i : scaling factor Q0 */
- const Word32 e_min, /* i : minimum energy scaled Q_new + QSCALE */
- Word32 *Bin_E, /* o : Per bin energy Q_new + QSCALE-2 */
- Word16 BIN_FREQ_FX, /* i : Number of frequency bins */
- Word32 *band_energies /* o : per band energy without MODE2_E_MIN */
-)
-{
- Word16 i, cnt, shift_to_norm;
- Word16 freq, wtmp;
- Word16 *ptR, *ptI, diff_scaleP1, diff_scaleM2;
- Word16 exp_band;
- Word32 Ltmp, Ltmp1;
- Word16 voic_band;
- Word32 etot;
- Word16 exp_etot;
- Word32 *tmpptr;
-#ifdef BASOP_NOGLOB_DECLARE_LOCAL
- Flag Overflow = 0;
-#endif
-
-
- ptR = &data[1]; /* first real */
- ptI = &data[L_FFT - 1]; /* first imaginary */
-
- /*-----------------------------------------------------------------------------------*
- * Scaling needed by band and ptE output
- * Wants all energies scaled by Q_new + QSCALE to maintain maximum
- * precision on bckr noise in clean speech
- * First shift left by Q_new + QSCALE than shift right by 2*Q_new-1
- * shift left (Q_new + QSCALE - (2*Q_new -1))
- * shift left (QSCALE - Q_new + 1) == shift left by (QSCALE+1) - Q_new
- *-----------------------------------------------------------------------------------*/
-
- diff_scaleP1 = sub( QSCALE + 1 + 1, Q_new2 );
- diff_scaleM2 = sub( QSCALE + 1 - 2, Q_new2 );
-
- voic_band = VOIC_BAND_8k;
- move16();
- assert( VOIC_BAND == VOIC_BAND_8k );
-
- etot = L_deposit_l( 0 );
- exp_etot = 0;
- move16();
-
- /*-----------------------------------------------------------------*
- * For low frequency bins, save per bin energy for the use
- * in NS and find_tilt()
- *-----------------------------------------------------------------*/
-
- freq = BIN_FREQ_FX;
- move16();
- FOR( i = 0; i < voic_band; i++ ) /* up to maximum allowed voiced critical band */
- {
- tmpptr = Bin_E;
- move16();
- Ltmp1 = L_deposit_l( 0 );
-
- FOR( ; freq <= crit_bands[i]; freq += BIN_FREQ_FX )
- {
- /*ptE = *ptR * *ptR + *ptI * *ptI */ /* energy */
- Ltmp = L_mult( *ptI, *ptI );
- Ltmp = L_mac( Ltmp, *ptR, *ptR );
-
- /* *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
- *ptE = L_shl_o( Ltmp, diff_scaleM2, &Overflow );
-#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++;*/
- *Bin_E = *ptE;
- move32();
- Bin_E++;
- Ltmp1 = L_add_sat( Ltmp1, Ltmp );
-
- ptE++;
- ptR++;
- ptI--;
- }
-
- exp_band = sub( norm_l( Ltmp1 ), 1 ); /* divide by 2 to ensure band < cnt */
- wtmp = round_fx( L_shl( Ltmp1, exp_band ) );
-
- /* band[i] /= cnt */ /* normalization per frequency bin */
- cnt = (Word16) ( Bin_E - tmpptr );
- shift_to_norm = norm_s( cnt );
- wtmp = div_s( wtmp, shl( cnt, shift_to_norm ) );
- Ltmp1 = L_deposit_l( wtmp );
-
- 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 /* BASOP_NOGLOB */
- move32(); /* band scaled by Q_new + QSCALE */
- BASOP_SATURATE_WARNING_ON_EVS;
-
- test();
- IF( GE_16( i, min_band ) && LE_16( i, max_band ) )
- {
- IF( LT_32( band[i], e_min ) )
- {
- Ltmp1 = L_shl( e_min, 0 );
- exp_band = 0;
- move16();
- }
-
- wtmp = sub( exp_band, exp_etot );
- if ( wtmp > 0 )
- {
- etot = L_shr( etot, wtmp );
- }
- exp_etot = s_max( exp_etot, exp_band );
- etot = L_add( etot, L_shl( Ltmp1, sub( exp_band, exp_etot ) ) );
- }
-
- band_energies[i] = band[i];
- move32();
-
- band[i] = L_max( band[i], e_min );
- move32();
- }
-
- IF( EQ_16( BIN_FREQ_FX, 50 ) )
- {
- /*-----------------------------------------------------------------*
- * Continue compute the E per critical band for high frequencies
- *-----------------------------------------------------------------*/
-
- FOR( i = voic_band; i < NB_BANDS; i++ )
- {
- tmpptr = Bin_E;
- move16();
- Ltmp1 = L_deposit_l( 0 );
-
- FOR( ; freq <= crit_bands[i]; freq += BIN_FREQ_FX )
- {
- /* *ptE = *ptR * *ptR + *ptI * *ptI */
- Ltmp = L_mult( *ptI, *ptI );
- Ltmp = L_mac_sat( Ltmp, *ptR, *ptR );
-
- /* *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
- *Bin_E = L_shl_o( Ltmp, diff_scaleM2, &Overflow );
-#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++;
- Ltmp1 = L_add_sat( Ltmp1, Ltmp );
-
- ptR++;
- ptI--;
- }
-
- exp_band = sub( norm_l( Ltmp1 ), 1 ); /* divide by 2 to ensure band < cnt */
- wtmp = round_fx( L_shl( Ltmp1, exp_band ) );
-
- /* band[i] /= cnt */ /* normalization per frequency bin */
- cnt = (Word16) ( Bin_E - tmpptr );
- shift_to_norm = norm_s( cnt );
- wtmp = div_s( wtmp, shl( cnt, shift_to_norm ) );
- Ltmp1 = L_deposit_l( wtmp );
-
- 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;
@@ -1606,163 +1088,10 @@ static void ivas_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();
return;
}
-#endif
-#ifdef IVAS_CODE_CPE
-/*------------------------------------------------------------------------*
- * find_enr_dft()
- *
- * find input signal energy for each critical band using the DFT buffers
- *------------------------------------------------------------------------*/
-
-static void find_enr_dft(
- CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
- const int32_t input_Fs, /* i : input sampling rate */
- float DFT_past_DMX[],
- float band[], /* o : per band energy */
- float *ptE, /* o : per bin energy for low frequencies */
- float *Etot, /* i/o: total energy */
- const int16_t min_band, /* i : minimum critical band */
- const int16_t max_band, /* i : maximum critical band */
- float *Bin_E, /* o : Per bin energy */
- float *band_ener /* o : per band energy without E_MIN */
-)
-{
- int16_t i, cnt;
- float freq, tmp;
- const float *ptR, *ptI;
- float norm_val;
- int16_t bin_cnt = 0;
-
- float c, s;
- /* One window - 40ms*12.8kHz = 512 samples */
- float c_1 = cosf( PI2 / STEREO_DFT_N_12k8_ENC );
- float s_1 = sinf( PI2 / STEREO_DFT_N_12k8_ENC );
- float g_1 = 1.f + 0.68f * 0.68f;
- float g_2 = 2 * 0.68f;
- float g;
- float scaleWin;
-
- float BinE[STEREO_DFT_N_12k8_ENC / 2]; /* NB_BANDS = 20 (= 6350Hz) = highest band available for SR 12.8 -> bin_cnt = 158 */
- float bin_freq = input_Fs / (float) hCPE->hStereoDft->NFFT; /* adaptive frequency bin width */
-
- scaleWin = 1 / ( 2 * hCPE->hStereoDft->win_ana_energy );
- scaleWin *= (float) BIN / bin_freq;
- norm_val = scaleWin * 4.0f / ( hCPE->hStereoDft->NFFT * hCPE->hStereoDft->NFFT );
-
- ptR = &DFT_past_DMX[2]; /* first real */
- ptI = &DFT_past_DMX[3]; /* first imaginary */
- c = c_1;
- s = s_1;
-
- /* for low frequency bins, save per bin energy for the use in find_tilt() */
- freq = bin_freq;
- for ( i = 0; i < NB_BANDS - 1; i++ ) /* up to maximum allowed voiced critical band */
- {
- band[i] = 0.0f;
- cnt = 0;
-
- /* bins up to crit_band 17 (<= 3700 Hz):
- * bin_cnt old (bin_width 50 Hz): 74 (74 * FRAMES_PER_SEC = 3700)
- * bin_cnt new (bin_width 40 Hz): 92 (92 * 40 = 3680)
- */
-
- while ( freq <= crit_bands[i] )
- {
- BinE[bin_cnt] = *ptR * *ptR + *ptI * *ptI; /* energy */
- g = g_1 - g_2 * c;
- tmp = c * c_1 - s * s_1;
- s = s * c_1 + c * s_1;
- c = tmp;
- BinE[bin_cnt] *= norm_val * g; /* normalization - corresponds to FFT normalization by 2/L_FFT */
- band[i] += BinE[bin_cnt];
- ptR += 2;
- ptI += 2;
-
- freq += bin_freq;
- cnt++;
- bin_cnt++;
- }
-
- band[i] *= inv_tbl[cnt]; /* normalization per frequency bin */
-
- band_ener[i] = band[i]; /* per band energy without E_MIN */
-
- if ( band[i] < E_MIN )
- {
- band[i] = E_MIN;
- }
- }
-
- /* continue computing the energy per critical band for higher frequencies */
-
- /* old version, FFT 256 @ SR12.8 (-> bin_width = 50 Hz):
- NB_BANDS = 20 (= 6350Hz) = highest band available for SR 12.8 -> bin_cnt = 127 = L_FFT/2-1*/
-
- /* new version: DFT (1200/800/400) @ input SR (48/32/16) (-> bin_width = 40 Hz):
- *
- */
- /* NB_BANDS = 20 (= 6350Hz) = highest band available for SR 12.8 -> bin_cnt = 158 */
- /* NB_BANDS = 21 (= 7700Hz) = highest band available for SR 16 -> bin_cnt = 192 */
- /* NB_BANDS = 24 (= 15500Hz) = highest band available for SR 32 -> bin_cnt = 387 */
- /* NB_BANDS = 24 (= 15500Hz) = highest band available for SR 48 -> bin_cnt = 387 */
-
- for ( ; i < NB_BANDS; i++ )
- {
- band[i] = 0.0f;
- cnt = 0;
- while ( freq < 6399.0f )
- {
- BinE[bin_cnt] = *ptR * *ptR + *ptI * *ptI;
- g = g_1 - g_2 * c;
- BinE[bin_cnt] *= norm_val * g;
- band[i] += BinE[bin_cnt];
- ptR += 2;
- ptI += 2;
-
- freq += bin_freq;
- cnt++;
- bin_cnt++;
- }
-
- band[i] *= inv_tbl[cnt]; /* normalization per frequency bin */
-
- band_ener[i] = band[i]; /* per band energy without E_MIN */
-
- if ( band[i] < E_MIN )
- {
- band[i] = E_MIN;
- }
- }
-
- /* put bin energies from BinE into Bin_E[L_FFT/2-1] (interpolate 40 Hz bin values to fit into 50 Hz bins) */
- /* Last value of Bin_E is handled outside this function*/
- assert( bin_cnt == ( STEREO_DFT_N_12k8_ENC / 2 - 1 ) );
- BinE[STEREO_DFT_N_12k8_ENC / 2 - 1] = BinE[STEREO_DFT_N_12k8_ENC / 2 - 2];
- lerp( BinE, Bin_E, L_FFT / 2, STEREO_DFT_N_12k8_ENC / 2 );
- mvr2r( Bin_E, ptE, VOIC_BINS );
-
-
- /* find the total log energy */
- tmp = *Etot;
- for ( i = min_band; i <= max_band; i++ )
- {
- tmp += band[i];
- }
-
- *Etot = tmp;
-
- return;
-}
-
-#endif
diff --git a/lib_enc/ari_enc.c b/lib_enc/ari_enc.c
index 733e3e72a10274c2ce2627330e37b3aa5e46c0cf..cda9d3c8270527bb9da7675dff645599620770bd 100644
--- a/lib_enc/ari_enc.c
+++ b/lib_enc/ari_enc.c
@@ -80,6 +80,9 @@ void ari_start_encoding_14bits(
s->low = 0;
s->high = ari_q4new;
s->bits_to_follow = 0;
+ move32();
+ move32();
+ move32();
return;
}
@@ -98,18 +101,21 @@ void ari_start_encoding_14bits_ivas_fx(
}
/*---------------------------------------------------------------
- * ari_done_encoding_14bits()
+ * ari_done_encoding_14bits_ivas_fx()
*
* Finish ArCo encoding
*-------------------------------------------------------------*/
-Word16 ari_done_encoding_14bits( Word16 *ptr, Word16 bp, Tastat *s )
+Word16 ari_done_encoding_14bits_ivas_fx(
+ Word16 *ptr, /* Q0 */
+ Word16 bp, /* Q0 */
+ Tastat *s )
{
Word16 bit;
bit = 0;
move16();
- if ( GE_32( s->low, ari_q1new ) )
+ IF( GE_32( s->low, ari_q1new ) )
{
bit = s_xor( bit, 1 );
}
@@ -118,17 +124,18 @@ Word16 ari_done_encoding_14bits( Word16 *ptr, Word16 bp, Tastat *s )
/*---------------------------------------------------------------
- * ari_encode_14bits_ext()
+ * ari_encode_14bits_ext_ivas_fx()
*
* encode function for extended proba tables: less branches needed for coding
*
*-------------------------------------------------------------*/
-Word16 ari_encode_14bits_ext(
- Word16 *ptr,
- Word16 bp,
+Word16 ari_encode_14bits_ext_ivas_fx(
+ Word16 *ptr, /* Q0 */
+ Word16 bp, /* Q0 */
Tastat *s,
- Word32 symbol,
- UWord16 const *cum_freq )
+ Word32 symbol, /* Q0 */
+ UWord16 const *cum_freq /* Q0 */
+)
{
Word32 low;
Word32 high;
@@ -140,7 +147,7 @@ Word16 ari_encode_14bits_ext(
high = L_add( s->high, 0 );
low = L_add( s->low, 0 );
- range = L_add( L_sub( high, low ), 1 );
+ range = L_add( L_sub( high, low ), 1 ); /* Q0 */
L_temp1 = L_shl( range, 15 - stat_bitsnew /*both are constants*/ );
Mpy_32_16_ss( L_temp1, cum_freq[symbol + 1], &L_temp2, &temp );
@@ -148,23 +155,23 @@ Word16 ari_encode_14bits_ext(
{
Mpy_32_16_ss( L_temp1, cum_freq[symbol], &range, &temp );
}
- high = L_sub( L_add( low, range ), 1 );
- low = L_add( low, L_temp2 );
+ high = L_sub( L_add( low, range ), 1 ); /* Q0 */
+ low = L_add( low, L_temp2 ); /* Q0 */
assert( s->bits_to_follow <= MAX_16 );
- bits_to_follow = extract_l( s->bits_to_follow );
+ bits_to_follow = extract_l( s->bits_to_follow ); /* Q0 */
FOR( i = 0; i < 0x7FFF; i++ )
{
IF( LT_32( high, ari_q2new ) )
{
- bp = ari_put_bit_plus_follow( ptr, bp, bits_to_follow, 0 );
+ bp = ari_put_bit_plus_follow( ptr, bp, bits_to_follow, 0 ); /* Q0 */
bits_to_follow = 0;
move16();
}
ELSE IF( GE_32( low, ari_q2new ) )
{
- bp = ari_put_bit_plus_follow( ptr, bp, bits_to_follow, 1 );
+ bp = ari_put_bit_plus_follow( ptr, bp, bits_to_follow, 1 ); /* Q0 */
bits_to_follow = 0;
move16();
low = L_sub( low, ari_q2new );
@@ -177,8 +184,8 @@ Word16 ari_encode_14bits_ext(
{
/* Output an opposite bit */
/* later if in middle half. */
- bits_to_follow = add( bits_to_follow, 1 );
- low = L_sub( low, ari_q1new ); /* Subtract offset to middle*/
+ bits_to_follow = add( bits_to_follow, 1 ); /* Q0 */
+ low = L_sub( low, ari_q1new ); /* Subtract offset to middle*/
high = L_sub( high, ari_q1new );
}
ELSE
@@ -186,15 +193,15 @@ Word16 ari_encode_14bits_ext(
BREAK; /* Otherwise exit loop. */
}
}
- low = L_add( low, low );
- high = L_add( L_add( high, high ), 1 ); /* Scale up code range. */
+ low = L_add( low, low ); /* Q0 */
+ high = L_add( L_add( high, high ), 1 ); /* Scale up code range. Q0*/
}
- s->low = low;
+ s->low = low; /* Q0 */
move32();
- s->high = high;
+ s->high = high; /* Q0 */
move32();
- s->bits_to_follow = bits_to_follow;
+ s->bits_to_follow = bits_to_follow; /* Q0 */
move32();
return bp;
@@ -202,39 +209,41 @@ Word16 ari_encode_14bits_ext(
/*------------------------------------------------------------------------
- * Function: ari_encode_14bits_range()
+ * Function: ari_encode_14bits_high_low_fx()
*
- * Encode an cumulative frequency interval.
*-------------------------------------------------------------------------*/
-/*------------------------------------------------------------------------
- * Function: ari_encode_14bits_sign()
- *
- * Encode a sign with equal probabilities.
- *-------------------------------------------------------------------------*/
-static Word16 ari_encode_14bits_high_low( Word16 *ptr, Word16 bp, Word16 bits, Tastat *s, Word32 high, Word32 low )
+
+static Word16 ari_encode_14bits_high_low_fx(
+ Word16 *ptr, /* Q0 */
+ Word16 bp, /* Q0 */
+ Word16 bits, /* Q0 */
+ Tastat *s,
+ Word32 high, /* Q0 */
+ Word32 low /* Q0 */
+)
{
Word16 bits_to_follow, tmp;
- bits_to_follow = extract_l( s->bits_to_follow );
+ bits_to_follow = extract_l( s->bits_to_follow ); /* Q0 */
move16();
/* while there are more than 16 bits left */
- tmp = sub( 16, bits );
+ tmp = sub( 16, bits ); /* Q0 */
WHILE( add( add( bp, bits_to_follow ), tmp ) < 0 )
{
IF( LE_32( high, ari_q2new ) )
{
- bp = ari_put_bit_plus_follow( ptr, bp, bits_to_follow, 0 );
+ bp = ari_put_bit_plus_follow( ptr, bp, bits_to_follow, 0 ); /* Q0 */
bits_to_follow = 0;
move16();
}
ELSE IF( GE_32( low, ari_q2new ) )
{
- bp = ari_put_bit_plus_follow( ptr, bp, bits_to_follow, 1 );
+ bp = ari_put_bit_plus_follow( ptr, bp, bits_to_follow, 1 ); /* Q0 */
bits_to_follow = 0;
move16();
- low = L_sub( low, ari_q2new );
- high = L_sub( high, ari_q2new ); /* Subtract offset to top. */
+ low = L_sub( low, ari_q2new ); /* Q0 */
+ high = L_sub( high, ari_q2new ); /* Subtract offset to top. Q0*/
}
ELSE
{
@@ -243,9 +252,9 @@ static Word16 ari_encode_14bits_high_low( Word16 *ptr, Word16 bp, Word16 bits, T
{
/* Output an opposite bit */
/* later if in middle half. */
- bits_to_follow = add( bits_to_follow, 1 );
- low = L_sub( low, ari_q1new ); /* Subtract offset to middle*/
- high = L_sub( high, ari_q1new );
+ bits_to_follow = add( bits_to_follow, 1 ); /* Q0 */
+ low = L_sub( low, ari_q1new ); /* Subtract offset to middle Q0*/
+ high = L_sub( high, ari_q1new ); /* Q0 */
}
ELSE
{
@@ -257,35 +266,47 @@ static Word16 ari_encode_14bits_high_low( Word16 *ptr, Word16 bp, Word16 bits, T
high = L_add( high, high ); /* Scale up code range. */
}
- s->low = low;
+ s->low = low; /* Q0 */
move32();
- s->high = L_sub( high, 1 );
+ s->high = L_sub( high, 1 ); /* Q0 */
move32();
- s->bits_to_follow = bits_to_follow;
+ s->bits_to_follow = bits_to_follow; /* Q0 */
move16();
return bp;
}
-Word16 ari_encode_14bits_sign( Word16 *ptr, Word16 bp, Word32 bits, Tastat *s, Word16 sign )
+
+/*------------------------------------------------------------------------
+ * Function: ari_encode_14bits_sign_ivas_fx()
+ *
+ * Encode a sign with equal probabilities.
+ *-------------------------------------------------------------------------*/
+Word16 ari_encode_14bits_sign_ivas_fx(
+ Word16 *ptr, /* Q0 */
+ Word16 bp, /* Q0 */
+ Word32 bits, /* Q0 */
+ Tastat *s,
+ Word16 sign /* Q0 */
+)
{
Word32 low, high, range;
Word32 L_tmp;
high = L_add( s->high, 1 );
low = L_add( s->low, 0 );
- range = L_sub( high, low );
+ range = L_sub( high, low ); /* Q0 */
L_tmp = L_shr( range, 1 );
if ( sign != 0 )
{
- high = L_add( low, L_tmp );
+ high = L_add( low, L_tmp ); /* Q0 */
}
if ( sign == 0 )
{
- low = L_add( low, L_tmp );
+ low = L_add( low, L_tmp ); /* Q0 */
}
- return ari_encode_14bits_high_low( ptr, bp, extract_l( bits ), s, high, low );
+ return ari_encode_14bits_high_low_fx( ptr, bp, extract_l( bits ), s, high, low );
}
/*------------------------------------------------------------------------
diff --git a/lib_enc/ari_enc_fx.c b/lib_enc/ari_enc_fx.c
index 872b6a1f3b6acb78d4db2987de223500ef45b48f..0ef053edd75ef58434abdc6fab944cb0851964de 100644
--- a/lib_enc/ari_enc_fx.c
+++ b/lib_enc/ari_enc_fx.c
@@ -56,19 +56,19 @@ void ari_start_encoding_14bits_fx( TastatEnc *s )
* Returns: new bit-stream position
*-------------------------------------------------------------*/
Word16 ari_put_bit_plus_follow(
- Word16 ptr[], /* o: bit-stream */
- Word16 bp, /* i: bit-stream position */
- Word16 bits_to_follow, /* i: number of opposite bits to follow 'bit' */
- Word16 bit /* i: bit to send */
+ Word16 ptr[], /* o: bit-stream Q0*/
+ Word16 bp, /* i: bit-stream position Q0*/
+ Word16 bits_to_follow, /* i: number of opposite bits to follow 'bit' Q0*/
+ Word16 bit /* i: bit to send Q0*/
)
{
assert( bit == 0 || bit == 1 );
- ptr[bp++] = bit; /* send initially a zero or one */
+ ptr[bp++] = bit; /* send initially a zero or one Q0*/
move16();
bit = s_xor( bit, 1 ); /* invert bit to send */
FOR( ; bits_to_follow > 0; bits_to_follow-- )
{
- ptr[bp++] = bit; /* send inverted bit */
+ ptr[bp++] = bit; /* send inverted bit Q0*/
move16();
}
return bp;
@@ -84,7 +84,10 @@ Word16 ari_put_bit_plus_follow(
*
* \return bit consumption
* ------------------------------------------------------------ - */
-Word16 ari_done_encoding_14bits_fx( Word16 *ptr, Word16 bp, TastatEnc *s )
+Word16 ari_done_encoding_14bits_fx(
+ Word16 *ptr, /* Q0 */
+ Word16 bp, /* Q0 */
+ TastatEnc *s )
{
Word16 bit;
@@ -113,11 +116,12 @@ Word16 ari_done_encoding_14bits_fx( Word16 *ptr, Word16 bp, TastatEnc *s )
* \return bit consumption
* ------------------------------------------------------------ - */
Word16 ari_encode_14bits_ext_fx(
- Word16 *ptr,
- Word16 bp,
+ Word16 *ptr, /* Q0 */
+ Word16 bp, /* Q0 */
TastatEnc *s,
- Word32 symbol,
- UWord16 const *cum_freq )
+ Word32 symbol, /* Q0 */
+ UWord16 const *cum_freq /* Q0 */
+)
{
Word32 low;
Word32 high;
@@ -129,7 +133,7 @@ Word16 ari_encode_14bits_ext_fx(
high = L_add( s->high, 0 );
low = L_add( s->low, 0 );
- range = L_sub( high, low );
+ range = L_sub( high, low ); /* Q0 */
L_temp1 = L_shl( range, 15 - stat_bitsnew /*both are constants*/ );
Mpy_32_16_ss( L_temp1, cum_freq[symbol + 1], &L_temp2, &temp );
@@ -137,27 +141,27 @@ Word16 ari_encode_14bits_ext_fx(
{
Mpy_32_16_ss( L_temp1, cum_freq[symbol], &range, &temp );
}
- high = L_add( low, range );
- low = L_add( low, L_temp2 );
+ high = L_add( low, range ); /* Q0 */
+ low = L_add( low, L_temp2 ); /* Q0 */
- bits_to_follow = s->value;
+ bits_to_follow = s->value; /* Q0 */
move16();
FOR( i = 0; i < 0x7FFF; i++ )
{
IF( LE_32( high, ari_q2new ) )
{
- bp = ari_put_bit_plus_follow( ptr, bp, bits_to_follow, 0 );
+ bp = ari_put_bit_plus_follow( ptr, bp, bits_to_follow, 0 ); /* Q0 */
bits_to_follow = 0;
move16();
}
ELSE IF( GE_32( low, ari_q2new ) )
{
- bp = ari_put_bit_plus_follow( ptr, bp, bits_to_follow, 1 );
+ bp = ari_put_bit_plus_follow( ptr, bp, bits_to_follow, 1 ); /* Q0 */
bits_to_follow = 0;
move16();
- low = L_sub( low, ari_q2new );
- high = L_sub( high, ari_q2new ); /* Subtract offset to top. */
+ low = L_sub( low, ari_q2new ); /* Q0 */
+ high = L_sub( high, ari_q2new ); /* Subtract offset to top. Q0*/
}
ELSE
{
@@ -166,9 +170,9 @@ Word16 ari_encode_14bits_ext_fx(
{
/* Output an opposite bit */
/* later if in middle half. */
- bits_to_follow = add( bits_to_follow, 1 );
- low = L_sub( low, ari_q1new ); /* Subtract offset to middle*/
- high = L_sub( high, ari_q1new );
+ bits_to_follow = add( bits_to_follow, 1 ); /* Q0 */
+ low = L_sub( low, ari_q1new ); /* Subtract offset to middle Q0*/
+ high = L_sub( high, ari_q1new ); /* Q0 */
}
ELSE
{
@@ -176,15 +180,15 @@ Word16 ari_encode_14bits_ext_fx(
}
}
- low = L_add( low, low );
- high = L_add( high, high ); /* Scale up code range. */
+ low = L_add( low, low ); /* Q0 */
+ high = L_add( high, high ); /* Scale up code range. Q0*/
}
- s->low = low;
+ s->low = low; /* Q0 */
move32();
- s->high = high;
+ s->high = high; /* Q0 */
move32();
- s->value = bits_to_follow;
+ s->value = bits_to_follow; /* Q0 */
move16();
return bp;
@@ -204,7 +208,14 @@ Word16 ari_encode_overflow_fx( TastatEnc *s )
*
*
*-------------------------------------------------------------------------*/
-static Word16 ari_encode_14bits_high_low( Word16 *ptr, Word16 bp, Word16 bits, TastatEnc *s, Word32 high, Word32 low )
+static Word16 ari_encode_14bits_high_low(
+ Word16 *ptr, /* Q0 */
+ Word16 bp, /* Q0 */
+ Word16 bits, /* Q0 */
+ TastatEnc *s,
+ Word32 high, /* Q0 */
+ Word32 low /* Q0 */
+)
{
Word16 bits_to_follow, tmp;
@@ -212,22 +223,22 @@ static Word16 ari_encode_14bits_high_low( Word16 *ptr, Word16 bp, Word16 bits, T
move16();
/* while there are more than 16 bits left */
- tmp = sub( 16, bits );
+ tmp = sub( 16, bits ); /* Q0 */
WHILE( add( add( bp, bits_to_follow ), tmp ) < 0 )
{
IF( LE_32( high, ari_q2new ) )
{
- bp = ari_put_bit_plus_follow( ptr, bp, bits_to_follow, 0 );
+ bp = ari_put_bit_plus_follow( ptr, bp, bits_to_follow, 0 ); /* Q0 */
bits_to_follow = 0;
move16();
}
ELSE IF( GE_32( low, ari_q2new ) )
{
- bp = ari_put_bit_plus_follow( ptr, bp, bits_to_follow, 1 );
+ bp = ari_put_bit_plus_follow( ptr, bp, bits_to_follow, 1 ); /* Q0 */
bits_to_follow = 0;
move16();
- low = L_sub( low, ari_q2new );
- high = L_sub( high, ari_q2new ); /* Subtract offset to top. */
+ low = L_sub( low, ari_q2new ); /* Q0 */
+ high = L_sub( high, ari_q2new ); /* Subtract offset to top. Q0*/
}
ELSE
{
@@ -236,9 +247,9 @@ static Word16 ari_encode_14bits_high_low( Word16 *ptr, Word16 bp, Word16 bits, T
{
/* Output an opposite bit */
/* later if in middle half. */
- bits_to_follow = add( bits_to_follow, 1 );
- low = L_sub( low, ari_q1new ); /* Subtract offset to middle*/
- high = L_sub( high, ari_q1new );
+ bits_to_follow = add( bits_to_follow, 1 ); /* Q0 */
+ low = L_sub( low, ari_q1new ); /* Subtract offset to middle Q0*/
+ high = L_sub( high, ari_q1new ); /* Q0 */
}
ELSE
{
@@ -246,15 +257,15 @@ static Word16 ari_encode_14bits_high_low( Word16 *ptr, Word16 bp, Word16 bits, T
}
}
- low = L_add( low, low );
- high = L_add( high, high ); /* Scale up code range. */
+ low = L_add( low, low ); /* Q0 */
+ high = L_add( high, high ); /* Scale up code range. Q0*/
}
- s->low = low;
+ s->low = low; /* Q0 */
move32();
- s->high = high;
+ s->high = high; /* Q0 */
move32();
- s->value = bits_to_follow;
+ s->value = bits_to_follow; /* Q0 */
move16();
return bp;
@@ -266,14 +277,21 @@ static Word16 ari_encode_14bits_high_low( Word16 *ptr, Word16 bp, Word16 bits, T
* Encode an cumulative frequency interval.
*-------------------------------------------------------------------------*/
-Word16 ari_encode_14bits_range_fx( Word16 *ptr, Word16 bp, Word16 bits, TastatEnc *s, Word16 cum_freq_low, Word16 cum_freq_high )
+Word16 ari_encode_14bits_range_fx(
+ Word16 *ptr, /* Q0 */
+ Word16 bp, /* Q0 */
+ Word16 bits, /* Q0 */
+ TastatEnc *s,
+ Word16 cum_freq_low, /* Q0 */
+ Word16 cum_freq_high /* Q0 */
+)
{
Word32 low, high, range;
- range = L_sub( s->high, s->low );
+ range = L_sub( s->high, s->low ); /* Q0 */
- high = L_add( s->low, mul_sbc_14bits( range, cum_freq_high ) );
- low = L_add( s->low, mul_sbc_14bits( range, cum_freq_low ) );
+ high = L_add( s->low, mul_sbc_14bits( range, cum_freq_high ) ); /* Q0 */
+ low = L_add( s->low, mul_sbc_14bits( range, cum_freq_low ) ); /* Q0 */
return ari_encode_14bits_high_low( ptr, bp, bits, s, high, low );
}
@@ -284,23 +302,29 @@ Word16 ari_encode_14bits_range_fx( Word16 *ptr, Word16 bp, Word16 bits, TastatEn
*
* Encode a sign with equal probabilities.
*-------------------------------------------------------------------------*/
-Word16 ari_encode_14bits_sign_fx( Word16 *ptr, Word16 bp, Word16 bits, TastatEnc *s, Word16 sign )
+Word16 ari_encode_14bits_sign_fx(
+ Word16 *ptr, /* Q0 */
+ Word16 bp, /* Q0 */
+ Word16 bits, /* Q0 */
+ TastatEnc *s,
+ Word16 sign /* Q0 */
+)
{
Word32 low, high, range;
Word32 L_tmp;
high = L_add( s->high, 0 );
low = L_add( s->low, 0 );
- range = L_sub( high, low );
+ range = L_sub( high, low ); /* Q0 */
L_tmp = L_shr( range, 1 );
if ( sign != 0 )
{
- high = L_add( low, L_tmp );
+ high = L_add( low, L_tmp ); /* Q0 */
}
if ( sign == 0 )
{
- low = L_add( low, L_tmp );
+ low = L_add( low, L_tmp ); /* Q0 */
}
return ari_encode_14bits_high_low( ptr, bp, bits, s, high, low );
@@ -311,25 +335,29 @@ Word16 ari_encode_14bits_sign_fx( Word16 *ptr, Word16 bp, Word16 bits, TastatEnc
*
* Finish up encoding in CBR mode.
*-------------------------------------------------------------------------*/
-Word16 ari_done_cbr_encoding_14bits_fx( Word16 *ptr, Word16 bp, Word16 bits, TastatEnc *s )
+Word16 ari_done_cbr_encoding_14bits_fx(
+ Word16 *ptr, /* Q0 */
+ Word16 bp, /* Q0 */
+ Word16 bits, /* Q0 */
+ TastatEnc *s )
{
Word16 high, tmp, k;
- tmp = sub( bits, 16 );
+ tmp = sub( bits, 16 ); /* Q0 */
WHILE( GT_16( sub( tmp, bp ), s->value ) )
{
- bp = ari_encode_14bits_sign_fx( ptr, bp, bits, s, 0 );
+ bp = ari_encode_14bits_sign_fx( ptr, bp, bits, s, 0 ); /* Q0 */
}
- high = extract_l( L_sub( s->high, 1 ) );
+ high = extract_l( L_sub( s->high, 1 ) ); /* Q0 */
- bp = ari_put_bit_plus_follow( ptr, bp, s->value, lshr( high, 15 ) );
+ bp = ari_put_bit_plus_follow( ptr, bp, s->value, lshr( high, 15 ) ); /* Q0 */
high = lshl( high, 1 );
tmp = s_min( 15, sub( bits, bp ) );
FOR( k = 0; k < tmp; ++k )
{
- ptr[bp++] = lshr( high, 15 );
+ ptr[bp++] = lshr( high, 15 ); /* Q0 */
move16();
high = lshl( high, 1 );
}
diff --git a/lib_enc/ari_hm_enc_fx.c b/lib_enc/ari_hm_enc_fx.c
index 3e6519a3b5fece3f0303e3cece17091315d6df23..a94f45528ec7e3d57470eb6e72b2aace5aa198ff 100644
--- a/lib_enc/ari_hm_enc_fx.c
+++ b/lib_enc/ari_hm_enc_fx.c
@@ -87,7 +87,7 @@ Word16 EncodeIndex_ivas_fx(
*
*-------------------------------------------------------------------*/
static Word16 SearchPeriodicityIndex_Single(
- const Word16 AbsMdct3[],
+ const Word16 AbsMdct3[], // Qx
const Word16 NumToConsider,
const Word32 Lag,
const Word16 FractionalResolution )
@@ -131,7 +131,7 @@ static Word16 SearchPeriodicityIndex_Single(
*
*-------------------------------------------------------------------*/
static void SearchPeriodicityIndex_Range(
- const Word16 AbsMdct3[],
+ const Word16 AbsMdct3[], // Qx
const Word16 NumToConsider,
const Word16 Lo,
const Word16 Hi,
@@ -139,7 +139,8 @@ static void SearchPeriodicityIndex_Range(
const Word16 Adj,
const Word16 Spacing,
Word16 *PeriodicityIndex,
- Word16 *Score )
+ Word16 *Score // Q0
+)
{
Word16 Index, BestIndex;
Word16 CurrentScore, BestScore;
@@ -194,7 +195,7 @@ static void SearchPeriodicityIndex_Range(
B = add( BestIndex, shr( Spacing, 1 ) );
- FOR( Index = add( BestIndex, 1 ); Index <= B; ++Index )
+ FOR( Index = BestIndex + 1; Index <= B; ++Index )
{
CurrentScore = SearchPeriodicityIndex_Single(
AbsMdct3,
@@ -225,7 +226,7 @@ Word16 SearchPeriodicityIndex_fx(
Word16 NumToConsider, /* i : Number of coefficients */
const Word16 TargetBits, /* i : Target bit budget (excl. Done flag) */
const Word16 LtpPitchLag, /* i : TCX-LTP pitch */
- const Word16 LtpGain, /* i : LTP gain */
+ const Word16 LtpGain, /* i : LTP gain Q15 */
Word16 *RelativeScore /* o : Energy concentration factor (2Q13) */
)
{
@@ -244,11 +245,12 @@ Word16 SearchPeriodicityIndex_fx(
Word32 tmp32;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/* Debug init (not instrumented) */
C = -3000;
-
+ move32();
PeriodicityIndex = 0;
move16();
Score = -1;
@@ -264,18 +266,22 @@ Word16 SearchPeriodicityIndex_fx(
{
C = L_shl( L_abs( Mdct[i + 1] ), s );
AbsMdct3[i] = round_fx( L_add( L_add( A, B ), C ) );
+ move16();
A = L_shl( L_abs( Mdct[i + 2] ), s );
AbsMdct3[i + 1] = round_fx( L_add( L_add( A, B ), C ) );
+ move16();
B = L_shl( L_abs( Mdct[i + 3] ), s );
AbsMdct3[i + 2] = round_fx( L_add( L_add( A, B ), C ) );
+ move16();
}
IF( LT_16( i, sub( NumToConsider, 1 ) ) )
{
C = L_shl( L_abs( Mdct[i + 1] ), s );
AbsMdct3[i] = round_fx( L_add( L_add( A, B ), C ) );
+ move16();
}
IF( LT_16( i, sub( NumToConsider, 2 ) ) )
@@ -283,6 +289,7 @@ Word16 SearchPeriodicityIndex_fx(
A = L_shl( L_abs( Mdct[i + 2] ), s );
assert( C != -3000 );
AbsMdct3[i + 1] = round_fx( L_add( L_add( A, B ), C ) );
+ move16();
}
AbsTotal = L_deposit_l( 0 );
@@ -452,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
{
@@ -479,8 +478,8 @@ Word16 SearchPeriodicityIndex_fx(
*-------------------------------------------------------------------*/
static void PeakFilter(
- const Word32 x[], /* i : absolute spectrum */
- Word32 y[], /* O : filtered absolute spectrum, must not alias x[] */
+ const Word32 x[], /* i : absolute spectrum Qx */
+ Word32 y[], /* O : filtered absolute spectrum, must not alias x[] Q(x-4)*/
const Word16 L_frame /* i : number of spectral lines */
)
{
@@ -491,7 +490,7 @@ static void PeakFilter(
flen = shr( L_frame, 4 );
/* m = kPeakElevationThreshold / (float)(2*flen + 1); */
- m = shr( div_s( 8 /*kPeakElevationThreshold Q3*/, add( shl( flen, 1 ), 1 ) ), 3 );
+ m = shr( div_s( 8 /*kPeakElevationThreshold Q3*/, add( shl( flen, 1 ), 1 ) ), 3 ); // Q15
a = L_deposit_l( 0 );
FOR( i = 0; i < flen; ++i )
@@ -501,14 +500,14 @@ static void PeakFilter(
FOR( i = 0; i < flen; ++i )
{
- y[i] = L_max( 0, L_sub( L_shr( x[i], 4 ), Mpy_32_16_1( a, m ) ) );
+ y[i] = L_max( 0, L_sub( L_shr( x[i], 4 ), Mpy_32_16_1( a, m ) ) ); // Q(x-4)
move32();
a = L_add( a, L_shr( x[i + flen], 4 ) );
}
sub( 0, 0 );
FOR( ; i < L_frame - flen; ++i )
{
- y[i] = L_max( 0, L_sub( L_shr( x[i], 4 ), Mpy_32_16_1( a, m ) ) );
+ y[i] = L_max( 0, L_sub( L_shr( x[i], 4 ), Mpy_32_16_1( a, m ) ) ); // Q(x-4)
move32();
a = L_sub( a, L_shr( x[i - flen], 4 ) );
a = L_add( a, L_shr( x[i + flen], 4 ) );
@@ -516,7 +515,7 @@ static void PeakFilter(
FOR( ; i < L_frame; ++i )
{
- y[i] = L_max( 0, L_sub( L_shr( x[i], 4 ), Mpy_32_16_1( a, m ) ) );
+ y[i] = L_max( 0, L_sub( L_shr( x[i], 4 ), Mpy_32_16_1( a, m ) ) ); // Q(x-4)
move32();
a = L_sub( a, L_shr( x[i - flen], 4 ) );
}
@@ -598,7 +597,7 @@ static Word32 tcx_hm_get_re(
*-------------------------------------------------------------------*/
static void tcx_hm_quantize_gain(
- const Word32 x[], /* i: absolute spectrum Q31-e */
+ const Word32 x[], /* i: absolute spectrum Q31-x_e */
const Word16 *x_e, /* i: absolute spectrum exponent Q0 */
const Word32 env[], /* i: envelope Q16 */
const Word32 lag, /* i: pitch lag Q0 */
@@ -645,6 +644,7 @@ static void tcx_hm_quantize_gain(
FOR( i = 0; i < L_frame; ++i )
{
x16[i] = extract_h( L_shl( x[i], s_x ) );
+ move16();
}
be = tcx_hm_get_re( x16, *gain, lag, fract_res, p, env, L_frame );
@@ -698,7 +698,8 @@ static void tcx_hm_quantize_gain(
/* Minimum selection, pe is Q14 */
IF( LT_32( L_shl( Mpy_32_16_1( e, pe ), 1 ), be ) )
{
- be = L_add( e, 0 );
+ be = e;
+ move32();
*gain_idx = g;
move16();
*gain = qGains[s][g];
diff --git a/lib_enc/arith_coder_enc_fx.c b/lib_enc/arith_coder_enc_fx.c
index 6b137f31e1b30c7a61fc9386be150537360c3a62..b97fd7931f5cb8dc056d25b872d23698a121f1e1 100644
--- a/lib_enc/arith_coder_enc_fx.c
+++ b/lib_enc/arith_coder_enc_fx.c
@@ -50,6 +50,7 @@ static Word16 tcx_arith_estimate_scale(
Word32 L_tmp, accu;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
@@ -71,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 );
@@ -92,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 );
@@ -195,19 +188,21 @@ static Word16 tcx_arith_find_max_scale( /* Q15-e *
Heap heap = { { { 0, 0 } }, 0 }; /* silence a compiler warning */
Word16 tmpi1, tmpi2;
const Word32 limit = -325614240l /*-9.70406052784f Q25*/; /* = ln(1/16384): log of smallest allowed probability */
-
+ move32();
/* Find the top most offending lines according to probability estimates */
FOR( i = 0; i < kMaxNumHeapElems; i++ )
{
heap.mElem[i].mIndex = 0;
move16();
heap.mElem[i].mScore = L_deposit_l( 0 );
+ move32();
}
tmp = add( shl( kMaxNumHeapElems, 1 ), 1 );
FOR( ; i < tmp; i++ )
{
heap.mElem[i].mScore = L_deposit_h( 0x7FFF );
+ move32();
}
FOR( k = 0; k < L_frame; k++ )
@@ -374,6 +369,7 @@ static Word16 tcx_arith_rateloop(
Word32 tmp2;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
@@ -383,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;
@@ -414,13 +404,14 @@ static Word16 tcx_arith_rateloop(
L_tmp = L_mac( 0x7FFFFFFF, exps[k], (Word16) 0x8000 ); /* Q31 */
L_tmp = L_negate( BASOP_Util_Log2( L_tmp ) ); /* Q25 */
fixed_bits[0][k] = round_fx( L_tmp ); /* Q9 */
-
+ move16();
/* fixed_bits[1][k] = 1 - s*0.5f*LOG2_E - log2f(1 - (exps[k]/65536.0f) * (exps[k]/65536.0f)); */
L_tmp = L_msu( 0x7FFFFFFF, exps[k], exps[k] ); /* Q31 */
L_tmp = BASOP_Util_Log2( L_tmp ); /* Q25 */
L_tmp = L_sub( 1 << 25, L_tmp );
L_tmp = L_sub( L_tmp, L_shl( L_mult0( mult_r( envelope[k], LOG2_E ), 1 << 10 ), envelope_e ) );
fixed_bits[1][k] = round_fx( L_tmp ); /* Q9 */
+ move16();
}
tmp2 = L_msu0( L_sub( max_complexity, 48 ), L_frame, 11 );
@@ -449,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;
@@ -485,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 );
}
}
@@ -708,6 +686,8 @@ void tcx_arith_encode_envelope_fx(
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
Flag Carry = 0;
+ move32();
+ move32();
#endif
assert( L_spec <= N_MAX_ARI );
@@ -730,6 +710,7 @@ void tcx_arith_encode_envelope_fx(
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] );
@@ -767,6 +748,7 @@ void tcx_arith_encode_envelope_fx(
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 );
@@ -782,20 +764,18 @@ void tcx_arith_encode_envelope_fx(
{
/* 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 */
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 ) ) );
@@ -810,4 +790,5 @@ void tcx_arith_encode_envelope_fx(
/* noise filling seed */
*nf_seed = extract_l( L_tmp2 );
+ move16();
}
diff --git a/lib_enc/avq_cod_fx.c b/lib_enc/avq_cod_fx.c
index 094d3fd78340282c0991914c8ee18a9216c1a0b1..202d60e51dd8e9c72ef431928b3ad14fefafaef8 100644
--- a/lib_enc/avq_cod_fx.c
+++ b/lib_enc/avq_cod_fx.c
@@ -16,7 +16,7 @@
* Local prototypes
*-------------------------------------------------------------------*/
static void wrte_cv( BSTR_ENC_HANDLE hBstr, const Word16 nq, const Word16 i_ind, const Word16 kv_ind, UWord16 I, Word16 kv[], Word16 *bits );
-static void wrte_cv_ivas( BSTR_ENC_HANDLE hBstr, const Word16 nq, const Word16 i_ind, const Word16 kv_ind, UWord16 I, Word16 kv[], Word16 *bits );
+static void wrte_cv_ivas_fx( BSTR_ENC_HANDLE hBstr, const Word16 nq, const Word16 i_ind, const Word16 kv_ind, UWord16 I, Word16 kv[], Word16 *bits );
/*-------------------------------------------------------------------*
* Function AVQ_cod() *
@@ -25,7 +25,7 @@ static void wrte_cv_ivas( BSTR_ENC_HANDLE hBstr, const Word16 nq, const Word16 i
*-------------------------------------------------------------------*/
void AVQ_cod_fx( /* o: comfort noise gain factor */
- const Word16 xri[], /* i: vector to quantize */
+ const Word16 xri[], /* i: vector to quantize Qx*/
Word16 xriq[], /* o: quantized normalized vector (assuming the bit budget is enough) */
const Word16 NB_BITS, /* i: number of allocated bits */
const Word16 Nsv, /* i: number of subvectors (lg=Nsv*8) */
@@ -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) */
@@ -72,7 +68,8 @@ void AVQ_cod_fx( /* o: comfort noise gain factor
Ltmp = L_mac( Ltmp, f_ebits, 1 );
Ltmp = L_add( L_shl( Ltmp, 6 ), L_shl( Ltmp, 4 ) ); /* Mult by 5.0 and then by 16 (To go to Q4). Do it using Mult by 80 (which is 64+16) */
ebits[l] = round_fx( Ltmp ); /*Q4*/
- tot_est_bits = add( tot_est_bits, shr( ebits[l], 4 ) );
+ move16();
+ tot_est_bits = add( tot_est_bits, shr( ebits[l], 4 ) ); // Q0
}
test();
test();
@@ -89,12 +86,12 @@ void AVQ_cod_fx( /* o: comfort noise gain factor
/* estimate gain according to number of bits allowed */
/* start at the middle (offset range = 0 to 255.75) Q6 */
- fac = 2048;
+ fac = 2048; // 128.0f in Q4
move16();
offset = 0;
move16();
- Ltmp = L_mult( 31130, sub( NB_BITS, Nsv ) ); /* (1810 - 8 - 1152/8)*.95*/
+ Ltmp = L_mult( 31130 /*.95f in Q15*/, sub( NB_BITS, Nsv ) ); /* (1810 - 8 - 1152/8)*.95*/
nbits_max = round_fx( L_shl( Ltmp, 4 ) );
/* tree search with 10 iterations : offset with step of 0.25 bits (0.3 dB) */
@@ -115,7 +112,7 @@ void AVQ_cod_fx( /* o: comfort noise gain factor
{
offset = sub( offset, fac );
}
- fac = mult( fac, 16384 );
+ fac = mult( fac, 16384 /*.5 in Q15*/ );
}
Ltmp = L_shr( L_mult( offset, 13107 ), 6 ); /* offset((2^21)/160 */
@@ -123,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 ) );
@@ -141,7 +134,7 @@ void AVQ_cod_fx( /* o: comfort noise gain factor
l_8 = shl( l, 3 );
FOR( i = 0; i < 8; i++ )
{
- x1[i] = L_shl( L_mult( xri[l_8 + i], gain_inv ), e_tmp );
+ x1[i] = L_shl( L_mult( xri[l_8 + i], gain_inv ), e_tmp ); // Q15
move32();
}
@@ -149,7 +142,7 @@ void AVQ_cod_fx( /* o: comfort noise gain factor
FOR( i = 0; i < 8; i++ )
{
- xriq[l_8 + i] = c[i];
+ xriq[l_8 + i] = c[i]; // Q0
move16();
}
}
@@ -157,7 +150,7 @@ void AVQ_cod_fx( /* o: comfort noise gain factor
/* round_fx bit allocations and save */
FOR( i = 0; i < Nsv; i++ )
{
- xriq[( Nsv * 8 ) + i] = shl( ebits[i], 7 - 4 );
+ xriq[( Nsv * 8 ) + i] = shl( ebits[i], 7 - 4 ); // Q0
move16();
}
@@ -229,8 +222,8 @@ void AVQ_encmux_fx(
/* sort subvectors by estimated bit allocations in decreasing order */
t = kv;
- move16(); /* reuse vector to save memory */
- move16(); /*ptr init*/
+ /* reuse vector to save memory */
+ /*ptr init*/
FOR( i = 0; i < Nsv; i++ )
{
t[i] = xriq[8 * Nsv + i];
@@ -325,11 +318,12 @@ void AVQ_encmux_fx(
move16();
move16();
move16();
+ move16();
if ( EQ_16( avq_bit_sFlag, 2 ) )
{
j = add( i, 1 );
}
- WHILE( LT_16( i, Nsvm1 ) )
+ WHILE( i < Nsvm1 )
{
svOrder[i] = j;
move16();
@@ -414,7 +408,7 @@ void AVQ_encmux_fx(
} /* for */
/* Bit Saving Solution */
test();
- IF( avq_bit_sFlag > 0 && bits > 8 )
+ IF( avq_bit_sFlag > 0 && GT_16( bits, 8 ) )
{
// PMT("code not validated yet")
bitsMod = s_and( bits, 4 /*bits%5*/ );
@@ -453,7 +447,7 @@ void AVQ_encmux_fx(
bitsMod = 0;
move16();
}
- ELSE IF( nq_est > 4 && ( ( bitsMod == 0 && nullVec > 3 && nullVec < 6 ) || ( bitsMod == 4 && nullVec == 5 ) ) && nq[svOrder[Nsvm2]] == 0 ) /* wasted bits 4, 5 for nq 6,7..*/
+ ELSE IF( nq_est > 4 && ( ( bitsMod == 0 && GT_16( nullVec, 3 ) && GT_16( nullVec, 6 ) ) || ( EQ_16( bitsMod, 4 ) && EQ_16( nullVec, 5 ) ) ) && nq[svOrder[Nsvm2]] == 0 ) /* wasted bits 4, 5 for nq 6,7..*/
{
overflow = 0;
move16();
@@ -627,8 +621,8 @@ void AVQ_encmux_ivas_fx(
/* sort subvectors by estimated bit allocations in decreasing order */
t = kv;
- move16(); /* reuse vector to save memory */
- move16(); /*ptr init*/
+ /* reuse vector to save memory */
+ /*ptr init*/
FOR( i = 0; i < Nsv; i++ )
{
t[i] = xriq[8 * Nsv + i];
@@ -723,6 +717,7 @@ void AVQ_encmux_ivas_fx(
move16();
move16();
move16();
+ move16();
if ( EQ_16( avq_bit_sFlag, 2 ) )
{
j = add( i, 1 );
@@ -814,17 +809,18 @@ void AVQ_encmux_ivas_fx(
bits = sub( bits, 1 );
}
- wrte_cv_ivas( hBstr, nq[k], i_ind, kv_ind, I[k], &kv[k * 8], &bits );
+ wrte_cv_ivas_fx( hBstr, nq[k], i_ind, kv_ind, I[k], &kv[k * 8], &bits );
}
} /* for */
/* Bit Saving Solution */
test();
- IF( avq_bit_sFlag > 0 && bits > 8 )
+ IF( avq_bit_sFlag > 0 && GT_16( bits, 8 ) )
{
// PMT("code not validated yet")
// bitsMod = bits%5;
bitsMod = bits;
- WHILE( GE_16( bitsMod, 5 ) )
+ move16();
+ WHILE( bitsMod >= 5 )
{
bitsMod = sub( bitsMod, 5 );
}
@@ -837,13 +833,13 @@ void AVQ_encmux_ivas_fx(
move16();
FOR( j = i; j < Nsv - 1; j++ )
{
- if ( nq[svOrder[j]] == 0 )
+ IF( nq[svOrder[j]] == 0 )
{
nullVec = add( nullVec, 1 );
}
}
/*nq_est = bits / 5;*/
- nq_est = mult( bits, 6554 );
+ nq_est = mult( bits, 6554 /*1/5 in Q15*/ );
assert( nq_est == bits / 5 );
test();
@@ -856,7 +852,7 @@ void AVQ_encmux_ivas_fx(
test();
test();
test();
- test();
+
IF( ( bitsMod > 0 || ( EQ_16( nullVec, 4 ) && EQ_16( nq_est, 5 ) ) ) && NE_16( bitsMod, 4 ) && GE_16( add( bits, nullVec ), add( add( shl( nq_est, 2 ), nq_est ), 4 ) ) /*5 * nq_est + 4*/ && nq[svOrder[Nsvm2]] == 0 ) /* detect need for dummy bits */
{
dummy_bits = sub( 5, bitsMod );
@@ -864,12 +860,12 @@ void AVQ_encmux_ivas_fx(
bitsMod = 0;
move16();
}
- ELSE IF( nq_est > 4 && ( ( bitsMod == 0 && nullVec > 3 && nullVec < 6 ) || ( bitsMod == 4 && nullVec == 5 ) ) && nq[svOrder[Nsvm2]] == 0 ) /* wasted bits 4, 5 for nq 6,7..*/
+ ELSE IF( GT_16( nq_est, 4 ) && ( ( bitsMod == 0 && GT_16( nullVec, 3 ) && LT_16( nullVec, 6 ) ) || ( EQ_16( bitsMod, 4 ) && EQ_16( nullVec, 5 ) ) ) && nq[svOrder[Nsvm2]] == 0 ) /* wasted bits 4, 5 for nq 6,7..*/
{
overflow = 0;
move16();
tmp = add( bitsMod, nullVec );
- WHILE( GE_16( tmp, 5 ) )
+ WHILE( tmp >= 5 )
{
tmp = sub( tmp, 5 );
}
@@ -896,18 +892,18 @@ void AVQ_encmux_ivas_fx(
}
bits = add( bits, overflow ); /*add fake bit */
unused_bits = sub( bits, add( shl( nq[i], 2 ), nq[i] ) );
- if ( nq[i] == 0 ) /*no bit savings*/
+ IF( nq[i] == 0 ) /*no bit savings*/
{
unused_bits = sub( unused_bits, 1 ); /*Stop Bit*/
}
/*unused_bits_idx = (int16_t)unused_bits / 5;*/
IF( unused_bits >= 0 )
{
- unused_bits_idx = mult( unused_bits, 6554 );
+ unused_bits_idx = mult( unused_bits, 6554 /*1/5 in Q15*/ );
}
ELSE
{
- unused_bits_idx = negate( mult( negate( unused_bits ), 6554 ) );
+ unused_bits_idx = negate( mult( negate( unused_bits ), 6554 /*1/5 in Q15*/ ) );
}
assert( unused_bits_idx == unused_bits / 5 );
unusedbitsFlag = 0;
@@ -951,7 +947,7 @@ void AVQ_encmux_ivas_fx(
/*Compute AVQ code book number from unused Bits */
bit_tmp = add( unusedbitsFlag, unused_bits_idx );
/*nq_est = (int16_t)ceil(0.2f * (bits - 5 * (unusedbitsFlag + unused_bits_idx)));*/
- nq_est = mult( 6554, sub( bits, add( shl( bit_tmp, 2 ), bit_tmp ) ) );
+ nq_est = mult( 6554 /*.2 in Q15*/, sub( bits, add( shl( bit_tmp, 2 ), bit_tmp ) ) );
assert( (int16_t) ceil( 0.2f * ( bits - 5 * ( unusedbitsFlag + unused_bits_idx ) ) ) == nq_est );
if ( EQ_16( nq_est, 1 ) )
@@ -963,7 +959,7 @@ void AVQ_encmux_ivas_fx(
bits = sub( bits, j );
- if ( nq_est != 0 )
+ IF( nq_est != 0 )
{
bits = sub( bits, 1 );
}
@@ -971,11 +967,11 @@ void AVQ_encmux_ivas_fx(
move16();
/* write codebook indices (rank I and event. Voronoi index kv) */
- wrte_cv_ivas( hBstr, nq[i], i_ind, kv_ind, I[i], &kv[i * 8], &bits );
+ wrte_cv_ivas_fx( hBstr, nq[i], i_ind, kv_ind, I[i], &kv[i * 8], &bits );
bits = sub( bits, dummy_bits );
- if ( NE_16( bitsMod, 4 ) )
+ IF( NE_16( bitsMod, 4 ) )
{
bits = add( bits, bitsMod );
}
@@ -1141,7 +1137,7 @@ static void wrte_cv(
return;
}
-static void wrte_cv_ivas(
+static void wrte_cv_ivas_fx(
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
const Word16 nq, /* i : AVQ nq index */
const Word16 i_ind, /* i : Base Bitstream index */
diff --git a/lib_enc/bass_psfilter_enc_fx.c b/lib_enc/bass_psfilter_enc_fx.c
index df52213c2bdc3d56ff7cbb9302ceaae8b3d78479..a1d672fe0059f3a6971fa0fb7f6bb6800745d88a 100644
--- a/lib_enc/bass_psfilter_enc_fx.c
+++ b/lib_enc/bass_psfilter_enc_fx.c
@@ -38,6 +38,7 @@ Word16 bass_pf_enc_fx(
Word32 ener2;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
@@ -69,10 +70,12 @@ Word16 bass_pf_enc_fx(
move16();
s3 = s4 = 0; /* initialization of s3 and s4 to suppress compiler warnings;
s3 and s4 get initialized for i_subfr == 0 */
-
+ move16();
+ move16();
nrg1 = nrg2 = 0; /* initialization fo nrg1 and nrg2 to suppress compiler warnings;
nrg1 and nrg1 get initialized for i_subfr == 0 */
-
+ move32();
+ move32();
FOR( i_subfr = 0; i_subfr < l_frame; i_subfr += l_subfr )
{
T = T_sf[sf];
@@ -126,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 )
@@ -154,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
}
}
@@ -182,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
}
}
@@ -218,7 +193,7 @@ Word16 bass_pf_enc_fx(
}
mem_bpf->lp_error_ener = L_add( Mpy_32_16_1( L_sub( mem_bpf->lp_error_ener, ener2 ), 32440 /*0.99f Q15*/ ), ener2 ); /* 15Q16 */
-
+ move32();
st = add( st, 6 );
ener2 = L_sub( mem_bpf->lp_error_ener, L_deposit_h( sub( 31, st ) ) );
IF( ener2 >= 0 )
@@ -235,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*/ ) )
{
@@ -265,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
}
}
@@ -282,14 +248,10 @@ Word16 bass_pf_enc_fx(
tmp32 = L_mult0( tmp16, syn[i + i_subfr] );
tmp32 = L_msu0( tmp32, tmp16, syn[i + i_subfr - T] );
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
}
}
}
@@ -298,6 +260,7 @@ Word16 bass_pf_enc_fx(
set16_fx( noise_in, 0, l_subfr );
set16_fx( error_in, 0, l_subfr );
s2 = s2_old;
+ move16();
}
tmp16 = shl( l_filt, 1 );
@@ -306,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 );
@@ -402,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 f572f4be37c41448fc990d70d53adac98cefa0e8..931b175ffcbcb81b781ceca892d01c8d71a9c16c 100644
--- a/lib_enc/bw_detect_fx.c
+++ b/lib_enc/bw_detect_fx.c
@@ -40,12 +40,12 @@
void bw_detect_fx(
Encoder_State *st, /* i/o: Encoder State */
- const Word16 signal_in[], /* i : input signal */
- Word16 *spectrum, /* i : MDCT spectrum */
+ const Word16 signal_in[], /* i : input signal */
+ Word16 *spectrum, /* i : MDCT spectrum */
const Word32 *enerBuffer, /* i : CLDFB Energy Q31 */
const Word16 *cldfbBuf_Ener_Exp, /* i : CLDFB Energy Exponent */
const IVAS_FORMAT ivas_format, /* i : IVAS format */
- const int16_t mct_on /* i : flag MCT mode */
+ const Word16 mct_on /* i : flag MCT mode */
)
{
Word16 Q_dct;
@@ -63,6 +63,7 @@ void bw_detect_fx(
Word32 cldfb_bin[9];
Word16 cldfb_bin_Exp[9];
Word16 cldfb_bin_width = 4;
+ move16();
const Word32 *pt32;
Word32 max_NB32, max_WB32, max_SWB32, max_FB32, mean_NB32, mean_WB32, mean_SWB32, mean_FB32; /* Q11*/ /* we need Word32 for the new cldfb energy vectors */
Word16 bwd_count_wider_bw;
@@ -74,6 +75,7 @@ void bw_detect_fx(
#endif
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
bwd_count_wider_bw = BWD_COUNT_WIDER_BW;
@@ -120,21 +122,18 @@ void bw_detect_fx(
move32(); /* result: Q31 */
}
- cldfb_bin[0] = Mpy_32_16_1( cldfb_bin[0], ScalFac );
- move32(); /* Q31 */
+ cldfb_bin[0] = Mpy_32_16_1( cldfb_bin[0], ScalFac ); // Q(31-cldfb_bin_Exp)
+ move32(); /* Q31 */
cldfb_bin_Exp[0] = add( cldfb_bin_Exp[0], CLDFBscalingFactor_EXP );
move16();
if ( cldfb_bin[i] == 0 )
{
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 */
@@ -153,7 +152,7 @@ void bw_detect_fx(
}
FOR( i = 1; i <= 2; i++ )
{
- cldfb_bin[i] = Mpy_32_16_1( cldfb_bin[i], ScalFac );
+ cldfb_bin[i] = Mpy_32_16_1( cldfb_bin[i], ScalFac ); // Q(31-(cldfv_bin_Exp+CLDFBscalingFactor_EXP))
move32();
cldfb_bin_Exp[i] = add( cldfb_bin_Exp[i], CLDFBscalingFactor_EXP );
move16();
@@ -161,6 +160,7 @@ void bw_detect_fx(
if ( cldfb_bin[i] == 0 )
{
cldfb_bin[i] = L_deposit_l( 1 );
+ move32();
}
L_tmp = BASOP_Util_Log2( cldfb_bin[i] ); /*(log2(660423549*2^(-31))/64)*2^31*/
L_tmp = L_add( L_tmp, L_shl( L_deposit_l( cldfb_bin_Exp[i] ), 31 - LD_DATA_SCALE ) ); /* Q25 */
@@ -191,7 +191,7 @@ void bw_detect_fx(
}
FOR( i = 3; i <= 6; i++ )
{
- cldfb_bin[i] = Mpy_32_16_1( cldfb_bin[i], ScalFac );
+ cldfb_bin[i] = Mpy_32_16_1( cldfb_bin[i], ScalFac ); // Q(31-(cldfv_bin_Exp+CLDFBscalingFactor_EXP))
move32();
cldfb_bin_Exp[i] = add( cldfb_bin_Exp[i], CLDFBscalingFactor_EXP );
move16();
@@ -199,6 +199,7 @@ void bw_detect_fx(
if ( cldfb_bin[i] == 0 )
{
cldfb_bin[i] = L_deposit_l( 1 );
+ move32();
}
L_tmp = BASOP_Util_Log2( cldfb_bin[i] ); /*(log2(660423549*2^(-31))/64)*2^31*/
L_tmp = L_add( L_tmp, L_shl( L_deposit_l( cldfb_bin_Exp[i] ), 31 - LD_DATA_SCALE ) ); /* Q25 */
@@ -231,6 +232,7 @@ void bw_detect_fx(
if ( cldfb_bin[i] == 0 )
{
cldfb_bin[i] = L_deposit_l( 1 );
+ move32();
}
L_tmp = BASOP_Util_Log2( cldfb_bin[i] ); /*(log2(660423549*2^(-31))/64)*2^31*/
L_tmp = L_add( L_tmp, L_shl( L_deposit_l( cldfb_bin_Exp[i] ), 31 - LD_DATA_SCALE ) ); /* Q25 */
@@ -300,18 +302,15 @@ 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;
move16();
}
ELSE
{
- Word16 l_frame = (int16_t) ( st->input_Fs / FRAMES_PER_SEC );
+ Word16 l_frame = extract_l( st->input_Fs / FRAMES_PER_SEC );
IF( EQ_16( st->core, TCX_10_CORE ) )
{
l_frame = shr( l_frame, 1 );
@@ -335,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++;
}
@@ -359,6 +354,7 @@ void bw_detect_fx(
e_tmp = sub( sub( 30, e_tmp ), Q_dct );
L_tmp = Mpy_32_16( e_tmp, f_tmp, 9864 ); /* Q16 */
spect_bin[i] = round_fx( L_shl( L_tmp, 11 ) ); /* Q11 */
+ move16();
}
}
}
@@ -527,23 +523,25 @@ void bw_detect_fx(
/*if( localVAD || st->lp_noise > 30 )*/
test();
- IF( st->localVAD || GT_16( st->lp_noise_fx, 7680 ) )
+ IF( st->localVAD || GT_16( st->lp_noise_fx, 7680 /*30 in Q8*/ ) )
{
/*st->lt_mean_NB_fx = ALPHA_BWD * st->lt_mean_NB_fx + (1-ALPHA_BWD) * mean_NB;*/
L_tmp = L_mult( ALPHA_BWD_FX, st->lt_mean_NB_fx ); /* Q15 * Q11 -> Q27 */
L_tmp = L_mac( L_tmp, 32768 - ALPHA_BWD_FX, mean_NB ); /* Q15 * Q11) -> L_mac(Q27, Q27) -> Q27*/
st->lt_mean_NB_fx = round_fx( L_tmp ); /* Q11 (27-16) */
+ move16();
/*st->lt_mean_WB_fx = ALPHA_BWD * st->lt_mean_WB_fx + (1-ALPHA_BWD) * mean_WB;*/
L_tmp = L_mult( ALPHA_BWD_FX, st->lt_mean_WB_fx );
L_tmp = L_mac( L_tmp, 32768 - ALPHA_BWD_FX, mean_WB );
st->lt_mean_WB_fx = round_fx( L_tmp );
+ move16();
/*st->lt_mean_SWB_fx = ALPHA_BWD * st->lt_mean_SWB_fx + (1-ALPHA_BWD) * mean_SWB;*/
L_tmp = L_mult( ALPHA_BWD_FX, st->lt_mean_SWB_fx );
L_tmp = L_mac( L_tmp, 32768 - ALPHA_BWD_FX, mean_SWB );
st->lt_mean_SWB_fx = round_fx( L_tmp );
-
+ move16();
IF( enerBuffer != NULL )
{
@@ -565,6 +563,7 @@ void bw_detect_fx(
IF( GT_32( L_tmp, L_tmp1 ) ) /* Q24 */
{
st->count_WB = add( st->count_WB, 1 );
+ move16();
}
}
ELSE
@@ -576,6 +575,7 @@ void bw_detect_fx(
IF( L_tmp < 0 )
{
st->count_WB = sub( st->count_WB, 1 );
+ move16();
}
}
@@ -603,6 +603,7 @@ void bw_detect_fx(
IF( L_tmp1 > 0 )
{
st->count_SWB = add( st->count_SWB, 1 );
+ move16();
}
}
ELSE
@@ -614,6 +615,7 @@ void bw_detect_fx(
IF( L_tmp1 < 0 )
{
st->count_SWB = sub( st->count_SWB, 1 );
+ move16();
}
}
/*if( max_FB > BWD_LT_THRESH_FX * st->lt_mean_SWB_fx && 0.83f * max_SWB > BWD_LT_THRESH_FX * st->lt_mean_WB_fx && max_WB > BWD_LT_THRESH_FX * st->lt_mean_NB_fx )*/
@@ -645,6 +647,7 @@ void bw_detect_fx(
IF( L_tmp1 > 0 )
{
st->count_FB = add( st->count_FB, 1 );
+ move16();
}
}
ELSE
@@ -656,6 +659,7 @@ void bw_detect_fx(
IF( L_tmp1 < 0 )
{
st->count_FB = sub( st->count_FB, 1 );
+ move16();
}
}
}
@@ -666,9 +670,10 @@ void bw_detect_fx(
{
/*if( 2 * max_WB > max_NB )*/
L_tmp = L_mult( 8192, max_WB ); /* 2.0 in Q12 x Q11 -> Q24*/
- if ( L_msu( L_tmp, max_NB, 4096 ) > 0 )
+ IF( L_msu( L_tmp, max_NB, 4096 ) > 0 )
{
st->count_WB = add( st->count_WB, 1 );
+ move16();
}
}
ELSE
@@ -678,22 +683,23 @@ void bw_detect_fx(
L_tmp = L_msu( L_tmp, mean_NB, 4096 );
test();
test();
- if ( L_tmp < 0 && !( EQ_16( mean_WB, -1 ) && EQ_16( mean_NB, -1 ) ) )
+ IF( L_tmp < 0 && !( EQ_16( mean_WB, -1 ) && EQ_16( mean_NB, -1 ) ) )
{
st->count_WB = sub( st->count_WB, 1 );
+ move16();
}
}
- test();
/*if( max_SWB > BWD_LT_THRESH * st->lt_mean_WB_fx && max_WB > BWD_LT_THRESH * st->lt_mean_NB_fx )*/
test();
IF( L_msu( L_deposit_h( max_SWB ), BWD_LT_THRESH_FX, st->lt_mean_WB_fx ) > 0 && L_msu( L_deposit_h( max_WB ), BWD_LT_THRESH_FX, st->lt_mean_NB_fx ) > 0 )
{
/*if( 2 * max_SWB > max_WB )*/
L_tmp = L_mult( 8192, max_SWB ); /* 2.0 in Q12 x Q11 -> Q24*/
- if ( L_msu( L_tmp, max_WB, 4096 ) > 0 )
+ IF( L_msu( L_tmp, max_WB, 4096 ) > 0 )
{
st->count_SWB = add( st->count_SWB, 1 );
+ move16();
}
}
ELSE
@@ -703,9 +709,10 @@ void bw_detect_fx(
L_tmp = L_msu( L_tmp, mean_WB, 4096 );
test();
test();
- if ( L_tmp < 0 && !( EQ_16( mean_SWB, -1 ) && EQ_16( mean_WB, -1 ) ) )
+ IF( L_tmp < 0 && !( EQ_16( mean_SWB, -1 ) && EQ_16( mean_WB, -1 ) ) )
{
st->count_SWB = sub( st->count_SWB, 1 );
+ move16();
}
}
@@ -716,9 +723,10 @@ void bw_detect_fx(
{
/*if( 2 * max_FB > max_SWB )*/
L_tmp = L_mult( 8192, max_FB ); /* 2.0 in Q12 x Q11 -> Q24*/
- if ( L_msu( L_tmp, max_SWB, 4096 ) > 0 )
+ IF( L_msu( L_tmp, max_SWB, 4096 ) > 0 )
{
st->count_FB = add( st->count_FB, 1 );
+ move16();
}
}
ELSE
@@ -727,9 +735,10 @@ void bw_detect_fx(
L_tmp = L_mult( 12288, mean_FB ); /* 3.0 in Q12 x Q11 -> Q24*/
test();
test();
- if ( L_msu( L_tmp, mean_SWB, 4096 ) < 0 && !( EQ_16( mean_FB, -1 ) && EQ_16( mean_SWB, -1 ) ) )
+ IF( L_msu( L_tmp, mean_SWB, 4096 ) < 0 && !( EQ_16( mean_FB, -1 ) && EQ_16( mean_SWB, -1 ) ) )
{
st->count_FB = sub( st->count_FB, 1 );
+ move16();
}
}
}
@@ -887,12 +896,12 @@ void bw_detect_fx(
/* verify that maximum encoded bandwidth (specified on the command line) is not exceeded */
- IF( GT_16( st->input_bwidth, st->max_bwidth ) )
+ if ( GT_16( st->input_bwidth, st->max_bwidth ) )
{
st->input_bwidth = st->max_bwidth;
move16();
}
- IF( EQ_16( st->element_mode, EVS_MONO ) )
+ IF( st->element_mode == EVS_MONO )
{
set_bw_fx( -1, -1, st, st->codec_mode );
}
@@ -1022,7 +1031,7 @@ void set_bw_fx(
BREAK;
}
}
- if ( EQ_16( n, FRAME_SIZE_NB ) )
+ IF( EQ_16( n, FRAME_SIZE_NB ) )
{
assert( !"Bitrate not supported: not part of EVS" );
}
diff --git a/lib_enc/cng_enc.c b/lib_enc/cng_enc.c
index dde1a574ad1dba8585f581d8e9750bd9cf162a0b..15dc89516be41e8fe8f976d302826a5ffe2a0827 100644
--- a/lib_enc/cng_enc.c
+++ b/lib_enc/cng_enc.c
@@ -47,13 +47,6 @@
#include "prot_fx.h"
#include "ivas_rom_com_fx.h"
-/*---------------------------------------------------------------------*
- * Local constants
- *---------------------------------------------------------------------*/
-
-#define MAX_DELTA_CNG 1
-#define ENER_MID_DEAD_ZONE 0.01 /* dead-zone width around mid points between quantization levels */
-
/*---------------------------------------------------------------------*
* Local function prototypes
*---------------------------------------------------------------------*/
@@ -169,10 +162,10 @@ static void shb_CNG_encod_ivas_fx(
Word16 tmp, tmp1, tmp2, scale, exp1, exp2, ener_mid_dec_thr_e;
tmp = BASOP_Util_Divide1616_Scale( st->hTdCngEnc->last_idx_ener, 22938, &scale ); // 0.7 in Q15 ->exp 0
- scale = scale + ( 15 - 0 );
+ scale = add( scale, ( 15 - 0 ) );
tmp = sub( tmp, shl( 6, sub( Q15, scale ) ) );
tmp1 = BASOP_Util_Divide1616_Scale( tmp, 3277, &exp1 );
- exp1 = exp1 + ( scale - 0 );
+ exp1 = add( exp1, ( scale - 0 ) );
ener_mid_dec_thr_fx = shr( mult( tmp1, 9864 ), 1 ); // exp = exp
@@ -272,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 */
@@ -284,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 */
@@ -298,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 );
@@ -327,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 )
{
@@ -346,7 +323,7 @@ static Word16 shb_DTX_ivas_fx(
move16();
move16();
}
- IF( GT_16( abs_s( sub( log_wb_ener_fx, hTdCngEnc->mov_wb_cng_ener_fx ) ), 3072 ) ) // 12 in Q8
+ IF( GT_16( abs_s( sub( log_wb_ener_fx, hTdCngEnc->mov_wb_cng_ener_fx ) ), 3072 /*12 in Q8*/ ) )
{
allow_cn_step = 1;
move16();
@@ -355,7 +332,7 @@ static Word16 shb_DTX_ivas_fx(
/* Also allow step if shb energy has dropped 12 dB */
test();
test();
- IF( ( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) && GT_16( sub( hTdCngEnc->mov_shb_cng_ener_fx, log_shb_ener_fx ), 3072 ) )
+ IF( ( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) && GT_16( sub( hTdCngEnc->mov_shb_cng_ener_fx, log_shb_ener_fx ), 3072 /*12 in Q8*/ ) )
{
allow_cn_step = 1;
move16();
@@ -365,16 +342,20 @@ static Word16 shb_DTX_ivas_fx(
{
hTdCngEnc->mov_wb_cng_ener_fx = log_wb_ener_fx;
hTdCngEnc->mov_shb_cng_ener_fx = log_shb_ener_fx;
+ move16();
+ move16();
}
ELSE
{
tmp = sub( log_wb_ener_fx, hTdCngEnc->mov_wb_cng_ener_fx ); /* Q8 */
- tmp = mult( tmp, 29491 ); /* Q8 */
+ tmp = mult( tmp, 29491 /* .9f in Q15*/ ); /* Q8 */
hTdCngEnc->mov_wb_cng_ener_fx = add( hTdCngEnc->mov_wb_cng_ener_fx, tmp ); /* Q8 */
+ move16();
tmp = sub( log_shb_ener_fx, hTdCngEnc->mov_shb_cng_ener_fx );
- tmp = mult( tmp, 8192 ); /* Q8 */
+ tmp = mult( tmp, 8192 /* .25f in Q15*/ ); /* Q8 */
hTdCngEnc->mov_shb_cng_ener_fx = add( hTdCngEnc->mov_shb_cng_ener_fx, tmp ); /* Q8 */
+ move16();
}
hTdCngEnc->shb_NO_DATA_cnt = add( hTdCngEnc->shb_NO_DATA_cnt, 1 );
@@ -383,10 +364,11 @@ static Word16 shb_DTX_ivas_fx(
move16();
move16();
- test();
- test();
IF( EQ_32( st->core_brate, SID_2k40 ) )
{
+ test();
+ test();
+ test();
IF( st->hDtxEnc->first_CNG == 0 )
{
update = 1;
@@ -443,6 +425,5 @@ static Word16 shb_DTX_ivas_fx(
move16();
}
- test();
return ( update );
}
diff --git a/lib_enc/cng_enc_fx.c b/lib_enc/cng_enc_fx.c
index 44ce22cc9d629151ac2cb0a67bfd0e5c19d4b3ff..8a2495b40c88f53dc790af9667dffb3a8bd4a1e1 100644
--- a/lib_enc/cng_enc_fx.c
+++ b/lib_enc/cng_enc_fx.c
@@ -50,10 +50,14 @@ void CNG_enc_fx(
Word16 m1;
Word16 res[L_FRAME16k];
Word16 step_inv = 0;
+ move16();
Word16 hi, lo;
Word16 maxl = 0;
+ move16();
Word16 num_bits = 0;
+ move16();
Word16 step = 0;
+ move16();
Word16 *pt_res;
const Word16 *pt_sp;
Word16 enr;
@@ -64,9 +68,11 @@ void CNG_enc_fx(
Word32 L_tmp1;
Word16 exp;
Word16 m = 0;
+ move16();
Word16 tmp[HO_HIST_SIZE * M];
Word16 ll, s_ptr;
Word16 tmpv, maxv, scale, att = 1;
+ move16();
Word16 lsf_tmp[M];
Word32 C[M];
Word32 max_val[2];
@@ -77,9 +83,12 @@ void CNG_enc_fx(
Word16 max_dev;
Word16 dist;
Word16 max_idx1[2] = { 0, 0 };
+ move16();
+ move16();
Word16 fft_io[L_FRAME16k];
Word16 *ptR, *ptI;
Word32 enr1 = 0;
+ move32();
Word32 env[NUM_ENV_CNG];
Word32 min1;
Word16 min1_idx;
@@ -90,21 +99,24 @@ void CNG_enc_fx(
Word16 temp_lo_fx, temp_hi_fx;
Word16 exp_pow;
Word16 force_cn_step = 0;
+ move16();
Word16 tmp_loop;
Word16 st_lp_sp_enr;
DTX_ENC_HANDLE hDtxEnc = st_fx->hDtxEnc;
TD_CNG_ENC_HANDLE hTdCngEnc = st_fx->hTdCngEnc;
BSTR_ENC_HANDLE hBstr = st_fx->hBstr;
st_lp_sp_enr = hTdCngEnc->lp_sp_enr_fx;
+ move16();
Word16 lp_ener_thr_scale;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/* Temp variables for floating point functions */
lp_ener_thr_scale = 8; /* 4.0f*/ /*IVAS_CODE Q2 */
move16();
- if ( NE_16( st_fx->element_mode, EVS_MONO ) )
+ if ( st_fx->element_mode != EVS_MONO )
{
lp_ener_thr_scale = 7; /* 3.5f;*/
move16();
@@ -163,8 +175,9 @@ void CNG_enc_fx(
test();
test();
test();
- IF( GT_32( st_fx->last_core_brate, SID_2k40 ) && ( EQ_16( st_fx->last_core, HQ_CORE ) || st_fx->hTdCngEnc->burst_ho_cnt > 0 ) && LT_16( hTdCngEnc->lp_sp_enr_fx, 1536 ) &&
- GT_16( sub( sp_enr, hTdCngEnc->lp_sp_enr_fx ), 1024 ) && GT_16( sp_enr, 1536 ) )
+ test();
+ IF( GT_32( st_fx->last_core_brate, SID_2k40 ) && ( EQ_16( st_fx->last_core, HQ_CORE ) || st_fx->hTdCngEnc->burst_ho_cnt > 0 ) && LT_16( hTdCngEnc->lp_sp_enr_fx, 1536 /*6.0f in Q8*/ ) &&
+ GT_16( sub( sp_enr, hTdCngEnc->lp_sp_enr_fx ), 1024 /*4.0f in Q8*/ ) && GT_16( sp_enr, 1536 /*6.0f in Q8*/ ) )
{
hTdCngEnc->lp_sp_enr_fx = sp_enr;
move16();
@@ -174,10 +187,12 @@ void CNG_enc_fx(
ELSE
{
hTdCngEnc->lp_sp_enr_fx = round_fx( L_mac( L_mult( 29491 /* 0.9, Q15 */, hTdCngEnc->lp_sp_enr_fx ), 3277 /* 0.1, Q15 */, sp_enr ) ); /* Q8 (8+15+1-16) */
+ move16();
}
}
/* update the pointer to circular buffer of old LSP vectors */
hTdCngEnc->cng_hist_ptr = add( hTdCngEnc->cng_hist_ptr, 1 );
+ move16();
if ( EQ_16( hTdCngEnc->cng_hist_ptr, DTX_HIST_SIZE ) )
{
hTdCngEnc->cng_hist_ptr = 0;
@@ -203,7 +218,7 @@ void CNG_enc_fx(
IF( EQ_16( st_fx->L_frame, L_FRAME ) )
{
lsp2lsf_fx( &hTdCngEnc->cng_lsp_hist_fx[i * M], lsf_tmp, M, INT_FS_FX );
- ftmp_fx = 964;
+ ftmp_fx = 964; /*(6400/(M+1))X2.56 */
move16(); /*QX2.56 */
tmpv = sub( 16384, add( lsf_tmp[M - 1], ftmp_fx ) ); /*QX2.56 */
L_tmp = L_mult0( tmpv, tmpv ); /*QX6.5536 */
@@ -211,7 +226,7 @@ void CNG_enc_fx(
ELSE
{
lsp2lsf_fx( &hTdCngEnc->cng_lsp_hist_fx[i * M], lsf_tmp, M, INT_FS_16k );
- ftmp_fx = 1205;
+ ftmp_fx = 1205; /*(8000/(M+1))X2.56*/
move16(); /*QX2.56 */
tmpv = sub( 20480, add( lsf_tmp[M - 1], ftmp_fx ) ); /*QX2.56 */
L_tmp = L_mult0( tmpv, tmpv ); /*QX6.5536 */
@@ -225,7 +240,7 @@ void CNG_enc_fx(
L_tmp = L_mac0( L_tmp, tmpv, tmpv ); /*QX6.5536 */
}
- C[i] = Mpy_32_16_1( L_tmp, 1928 );
+ C[i] = Mpy_32_16_1( L_tmp, 1928 /*.0588235f Q15*/ );
move32(); /*QX6.5536 */
IF( GT_32( C[i], max_val[0] ) )
@@ -251,6 +266,7 @@ void CNG_enc_fx(
FOR( i = 0; i < M; i++ )
{
L_tmp = 0;
+ move32();
FOR( j = 0; j < hDtxEnc->cng_hist_size; j++ )
{
L_tmp = L_add( L_tmp, L_deposit_l( hTdCngEnc->cng_lsp_hist_fx[j * M + i] ) ); /*Q15 */
@@ -260,6 +276,7 @@ void CNG_enc_fx(
tmpv = div_s( 1, sub( hDtxEnc->cng_hist_size, 2 ) ); /*Q15 */
L_tmp = Mpy_32_16_1( L_tmp, tmpv ); /*Q15 */
lsp_new[i] = extract_l( L_tmp ); /*Q15 */
+ move16();
}
max_idx1[0] = max_idx[0];
move16();
@@ -280,7 +297,7 @@ void CNG_enc_fx(
test();
test();
IF( ( ( hDtxEnc->cng_cnt == 0 ) &&
- GT_16( hTdCngEnc->lp_sp_enr_fx, 1536 ) &&
+ GT_16( hTdCngEnc->lp_sp_enr_fx, 1536 /* 6.0, Q8 */ ) &&
( LT_16( add( st_lp_sp_enr, 1024 /* 4.0, Q8 */ ), sp_enr ) ) &&
( hDtxEnc->first_CNG != 0 ) &&
( hTdCngEnc->old_enr_index >= 0 ) &&
@@ -297,12 +314,12 @@ void CNG_enc_fx(
Copy( st_fx->lsp_old_fx, hDtxEnc->lspCNG_fx, M );
/* Average the CNG spectral envelope in case of the very first CNG frame */
- IF( NE_16( st_fx->element_mode, EVS_MONO ) )
+ IF( st_fx->element_mode != EVS_MONO )
{
FOR( i = 0; i < M; i++ )
{
/*lsp_new[i] = 0.5f * (lsp_mid[i] + lsp_new[i]);*/
- lsp_new[i] = mac_r( L_mult( lsp_mid[i], 16384 ), lsp_new[i], 16384 );
+ lsp_new[i] = mac_r( L_mult( lsp_mid[i], 16384 ), lsp_new[i], 16384 /*.5 Q15*/ );
move16();
}
}
@@ -372,7 +389,8 @@ void CNG_enc_fx(
test();
test();
test();
- IF( EQ_16( st_fx->element_mode, EVS_MONO ) && ( ( st_fx->Opt_AMR_WB || EQ_16( st_fx->bwidth, WB ) ) && ( !hDtxEnc->first_CNG || GE_16( hTdCngEnc->act_cnt2, MIN_ACT_CNG_UPD ) ) ) )
+ test();
+ IF( st_fx->element_mode == EVS_MONO && ( ( st_fx->Opt_AMR_WB || EQ_16( st_fx->bwidth, WB ) ) && ( !hDtxEnc->first_CNG || GE_16( hTdCngEnc->act_cnt2, MIN_ACT_CNG_UPD ) ) ) )
{
IF( GT_32( hDtxEnc->last_active_brate, ACELP_16k40 ) )
{
@@ -382,11 +400,13 @@ void CNG_enc_fx(
ELSE
{
hDtxEnc->CNG_mode = get_cng_mode( hDtxEnc->last_active_brate );
+ move16();
}
}
/* If first sid after active burst update LSF history from circ buffer */
hTdCngEnc->burst_ho_cnt = s_min( hTdCngEnc->burst_ho_cnt, hTdCngEnc->ho_circ_size );
+ move16();
hTdCngEnc->act_cnt = 0;
move16();
s_ptr = add( sub( hTdCngEnc->ho_circ_ptr, hTdCngEnc->burst_ho_cnt ), 1 );
@@ -399,6 +419,7 @@ void CNG_enc_fx(
FOR( ll = hTdCngEnc->burst_ho_cnt; ll > 0; ll-- )
{
hTdCngEnc->ho_hist_ptr = add( hTdCngEnc->ho_hist_ptr, 1 );
+ move16();
if ( EQ_16( hTdCngEnc->ho_hist_ptr, HO_HIST_SIZE ) )
{
hTdCngEnc->ho_hist_ptr = 0;
@@ -422,9 +443,11 @@ void CNG_enc_fx(
Copy( &( hTdCngEnc->ho_lsp_circ_fx[s_ptr * M] ), &( hTdCngEnc->ho_lsp_hist_fx[hTdCngEnc->ho_hist_ptr * M] ), M );
Copy32( &( hTdCngEnc->ho_ener_circ_fx[s_ptr] ), &( hTdCngEnc->ho_ener_hist_fx[hTdCngEnc->ho_hist_ptr] ), 1 );
hTdCngEnc->ho_sid_bw = L_shl( L_and( hTdCngEnc->ho_sid_bw, (Word32) 0x3fffffffL ), 1 );
+ move32();
Copy32( &( hTdCngEnc->ho_env_circ_fx[s_ptr * NUM_ENV_CNG] ), &( hTdCngEnc->ho_env_hist_fx[hTdCngEnc->ho_hist_ptr * NUM_ENV_CNG] ), NUM_ENV_CNG );
hTdCngEnc->ho_hist_size = add( hTdCngEnc->ho_hist_size, 1 );
+ move16();
if ( GT_16( hTdCngEnc->ho_hist_size, HO_HIST_SIZE ) )
{
hTdCngEnc->ho_hist_size = HO_HIST_SIZE;
@@ -458,9 +481,10 @@ void CNG_enc_fx(
#endif
test();
test();
- IF( ( hDtxEnc->first_CNG > 0 || EQ_16( st_fx->element_mode, EVS_MONO ) ) && L_tmp1 > 0 )
+ IF( ( hDtxEnc->first_CNG > 0 || st_fx->element_mode == EVS_MONO ) && L_tmp1 > 0 )
{
*allow_cn_step = s_or( *allow_cn_step, 1 );
+ move16();
}
}
test();
@@ -481,7 +505,7 @@ void CNG_enc_fx(
L_enr = Mult_32_16( hTdCngEnc->ho_ener_hist_fx[ptr], W_DTX_HO_FX[0] ); /* Q6+15-15->Q6 */
weights = W_DTX_HO_FX[0]; /* Q15 */
-
+ move16();
m = 1;
move16();
FOR( k = 1; k < hTdCngEnc->ho_hist_size; k++ )
@@ -531,7 +555,7 @@ void CNG_enc_fx(
IF( EQ_16( st_fx->L_frame, L_FRAME ) )
{
lsp2lsf_fx( &tmp[i * M], lsf_tmp, M, INT_FS_FX );
- ftmp_fx = 964;
+ ftmp_fx = 964; /*(6400/(M+1))X2.56*/
move16(); /*QX2.56 */
tmpv = sub( 16384, add( lsf_tmp[M - 1], ftmp_fx ) ); /*QX2.56 */
L_tmp = L_mult0( tmpv, tmpv ); /*QX6.5536 */
@@ -539,7 +563,7 @@ void CNG_enc_fx(
ELSE
{
lsp2lsf_fx( &tmp[i * M], lsf_tmp, M, INT_FS_16k );
- ftmp_fx = 1205;
+ ftmp_fx = 1205; /*(8000/(M+1))X2.56*/
move16(); /*QX2.56 */
tmpv = sub( 20480, add( lsf_tmp[M - 1], ftmp_fx ) ); /*QX2.56 */
L_tmp = L_mult0( tmpv, tmpv ); /*QX6.5536 */
@@ -615,14 +639,12 @@ void CNG_enc_fx(
dist = 0; /*Q15 */
max_dev = 0; /*Q15 */
+ move16();
+ move16();
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;
@@ -656,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;
@@ -731,16 +741,17 @@ void CNG_enc_fx(
IF( EQ_16( st_fx->bwidth, WB ) && hDtxEnc->CNG_mode >= 0 )
{
ftmp_fx = HO_ATT_FX[hDtxEnc->CNG_mode];
+ move16();
}
ELSE
{
- ftmp_fx = 19661;
+ ftmp_fx = 19661; /*0.6f in Q15*/
move16();
}
- att = mult( ftmp_fx, 5461 ); /* Q15 */
- L_tmp = L_mult( att, 8 ); /* Q16 */
- tmp1 = extract_l( L_shr( L_tmp, 2 ) ); /* Q14 */
+ att = mult( ftmp_fx, 5461 /*1/6f in Q15*/ ); /* Q15 */
+ L_tmp = L_mult( att, 8 ); /* Q16 */
+ tmp1 = extract_l( L_shr( L_tmp, 2 ) ); /* Q14 */
tmp1 = add( 16384, tmp1 );
att = div_s( 16374, tmp1 ); /* Q15 */
@@ -769,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 ) );
@@ -807,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 */
@@ -826,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 */
@@ -864,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 );
@@ -919,6 +908,7 @@ void CNG_enc_fx(
enr = round_fx( L_tmp ); /* Q8 */
}
/* decrease the energy in case of WB input */
+ test();
IF( EQ_16( st_fx->element_mode, IVAS_SCE ) || EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) )
{
// PMT("CNG IVAS_SCE and IVAS_CPE_DFT code missing")
@@ -1011,6 +1001,7 @@ void CNG_enc_fx(
/* substract by 2 not done to leave Energy in Q2 */
lo = L_Extract_lc( L_tmp, &hi );
hTdCngEnc->Enew_fx = Pow2( add( hi, 4 ), lo ); /* Q6 */
+ move32();
IF( EQ_32( st_fx->core_brate, SID_2k40 ) )
{
/* enr1 = (float)log10( st->Enew*L_frame + 0.1f ) / (float)log10( 2.0f );*/
@@ -1018,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 ) );
@@ -1075,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 );
}
@@ -1098,6 +1081,7 @@ void CNG_enc_fx(
FOR( i = 0; i < NUM_ENV_CNG; i++ )
{
q_env[i] = L_deposit_l( CNG_details_codebook_fx[min1_idx][i] );
+ move32();
}
}
/* Update hangover memory during CNG */
@@ -1106,6 +1090,7 @@ void CNG_enc_fx(
{
/* update the pointer to circular buffer of old LSP vectors */
hTdCngEnc->ho_hist_ptr = add( hTdCngEnc->ho_hist_ptr, 1 );
+ move16();
if ( EQ_16( hTdCngEnc->ho_hist_ptr, HO_HIST_SIZE ) )
{
hTdCngEnc->ho_hist_ptr = 0;
@@ -1139,6 +1124,7 @@ void CNG_enc_fx(
Copy32( env, &( hTdCngEnc->ho_env_hist_fx[( hTdCngEnc->ho_hist_ptr ) * NUM_ENV_CNG] ), NUM_ENV_CNG );
}
hTdCngEnc->ho_hist_size = add( hTdCngEnc->ho_hist_size, 1 );
+ move16();
if ( GT_16( hTdCngEnc->ho_hist_size, HO_HIST_SIZE ) )
{
hTdCngEnc->ho_hist_size = HO_HIST_SIZE;
@@ -1167,6 +1153,7 @@ void CNG_enc_fx(
move16();
push_indice_fx( hBstr, IND_SID_TYPE, 0, 1 );
+ test();
IF( LT_32( st_fx->input_Fs, 32000 ) && NE_16( st_fx->element_mode, IVAS_CPE_DFT ) )
{
push_indice_fx( hBstr, IND_SID_BW, 0, 1 );
@@ -1193,6 +1180,7 @@ void CNG_enc_fx(
ELSE
{
hDtxEnc->cng_cnt = add( hDtxEnc->cng_cnt, 1 );
+ move16();
}
return;
@@ -1419,7 +1407,7 @@ void CNG_enc_ivas_fx(
IF( EQ_16( st_fx->L_frame, L_FRAME ) )
{
lsp2lsf_fx( &hTdCngEnc->cng_lsp_hist_fx[i * M], lsf_tmp, M, INT_FS_FX );
- ftmp_fx = 964;
+ ftmp_fx = 964; /*(6400/(M+1))X2.56*/
move16(); /*QX2.56 */
tmpv = sub( 16384, add( lsf_tmp[M - 1], ftmp_fx ) ); /*QX2.56 */
L_tmp = L_mult0( tmpv, tmpv ); /*QX6.5536 */
@@ -1427,7 +1415,7 @@ void CNG_enc_ivas_fx(
ELSE
{
lsp2lsf_fx( &hTdCngEnc->cng_lsp_hist_fx[i * M], lsf_tmp, M, INT_FS_16k );
- ftmp_fx = 1205;
+ ftmp_fx = 1205; /*(8000/(M+1))X2.56*/
move16(); /*QX2.56 */
tmpv = sub( 20480, add( lsf_tmp[M - 1], ftmp_fx ) ); /*QX2.56 */
L_tmp = L_mult0( tmpv, tmpv ); /*QX6.5536 */
@@ -1467,6 +1455,7 @@ void CNG_enc_ivas_fx(
FOR( i = 0; i < M; i++ )
{
L_tmp = 0;
+ move32();
FOR( j = 0; j < hDtxEnc->cng_hist_size; j++ )
{
L_tmp = L_add( L_tmp, L_deposit_l( hTdCngEnc->cng_lsp_hist_fx[j * M + i] ) ); /*Q15 */
@@ -1476,6 +1465,7 @@ void CNG_enc_ivas_fx(
tmpv = div_s( 1, sub( hDtxEnc->cng_hist_size, 2 ) ); /*Q15 */
L_tmp = Mpy_32_16_1( L_tmp, tmpv ); /*Q15 */
lsp_new[i] = extract_l( L_tmp ); /*Q15 */
+ move16();
}
max_idx1[0] = max_idx[0];
move16();
@@ -1518,7 +1508,7 @@ void CNG_enc_ivas_fx(
FOR( i = 0; i < M; i++ )
{
/*lsp_new[i] = 0.5f * (lsp_mid[i] + lsp_new[i]);*/
- lsp_new[i] = mac_r( L_mult( lsp_mid[i], 16384 ), lsp_new[i], 16384 );
+ lsp_new[i] = mac_r( L_mult( lsp_mid[i], 16384 /*.5f Q15*/ ), lsp_new[i], 16384 /*.5f Q15*/ );
move16();
}
}
@@ -1574,7 +1564,7 @@ void CNG_enc_ivas_fx(
FOR( i = 0; i < M; i++ )
{
/* AR low-pass filter */
- hDtxEnc->lspCNG_fx[i] = mac_r( L_mult( CNG_ISF_FACT_FX, hDtxEnc->lspCNG_fx[i] ), 32768 - CNG_ISF_FACT_FX, lsp_new[i] );
+ hDtxEnc->lspCNG_fx[i] = mac_r( L_mult( CNG_ISF_FACT_FX, hDtxEnc->lspCNG_fx[i] ), 32768 /*1f Q15*/ - CNG_ISF_FACT_FX, lsp_new[i] );
move16(); /* Q15 (15+15+1-16) */
}
}
@@ -1585,6 +1575,7 @@ void CNG_enc_ivas_fx(
test();
test();
test();
+ test();
IF( ( st_fx->element_mode == EVS_MONO ) && ( ( st_fx->Opt_AMR_WB || EQ_16( st_fx->bwidth, WB ) ) && ( !hDtxEnc->first_CNG || GE_16( hTdCngEnc->act_cnt2, MIN_ACT_CNG_UPD ) ) ) )
{
IF( GT_32( hDtxEnc->last_active_brate, ACELP_16k40 ) )
@@ -1595,6 +1586,7 @@ void CNG_enc_ivas_fx(
ELSE
{
hDtxEnc->CNG_mode = get_cng_mode( hDtxEnc->last_active_brate );
+ move16();
}
}
@@ -1688,7 +1680,7 @@ void CNG_enc_ivas_fx(
L_ener = Mult_32_16( hTdCngEnc->ho_ener_hist_fx[ptr], W_DTX_HO_FX[0] ); /* Q6+15-15->Q6 */
weights = W_DTX_HO_FX[0]; /* Q15 */
-
+ move16();
m = 1;
move16();
FOR( k = 1; k < hTdCngEnc->ho_hist_size; k++ )
@@ -1738,7 +1730,7 @@ void CNG_enc_ivas_fx(
IF( EQ_16( st_fx->L_frame, L_FRAME ) )
{
lsp2lsf_fx( &tmp[i * M], lsf_tmp, M, INT_FS_FX );
- ftmp_fx = 964;
+ ftmp_fx = 964; /*(6400/(M+1))X2.56*/
move16(); /*QX2.56 */
tmpv = sub( 16384, add( lsf_tmp[M - 1], ftmp_fx ) ); /*QX2.56 */
L_tmp = L_mult0( tmpv, tmpv ); /*QX6.5536 */
@@ -1746,7 +1738,7 @@ void CNG_enc_ivas_fx(
ELSE
{
lsp2lsf_fx( &tmp[i * M], lsf_tmp, M, INT_FS_16k );
- ftmp_fx = 1205;
+ ftmp_fx = 1205; /*(8000/(M+1))X2.56*/
move16(); /*QX2.56 */
tmpv = sub( 20480, add( lsf_tmp[M - 1], ftmp_fx ) ); /*QX2.56 */
L_tmp = L_mult0( tmpv, tmpv ); /*QX6.5536 */
@@ -1815,9 +1807,9 @@ void CNG_enc_ivas_fx(
}
L_tmp = L_sub( L_tmp, L_add( L_deposit_l( tmp[max_idx[0] * M + i] ), L_deposit_l( tmp[max_idx[1] * M + i] ) ) ); /*Q15 */
- tmpv = div_s( 1, sub( m, 2 ) ); /*Q15 */
- L_tmp = Mpy_32_16_1( L_tmp, tmpv ); /*Q15 */
- lsp_tmp[i] = extract_l( L_tmp ); /*Q15 */
+ tmpv = div_s( 1, sub( m, 2 ) ); /*Q15 */ /*Q15 */
+ L_tmp = Mpy_32_16_1( L_tmp, tmpv ); /*Q15 */ /*Q15 */
+ lsp_tmp[i] = extract_l( L_tmp ); /*Q15 */ /*Q15 */
move16();
}
}
@@ -1851,7 +1843,7 @@ void CNG_enc_ivas_fx(
FOR( i = 0; i < M; i++ )
{
/* AR low-pass filter */
- hDtxEnc->lspCNG_fx[i] = add( mult_r( 26214, lsp_tmp[i] ), mult_r( 6554, lsp_new[i] ) ); /* Q15 */
+ hDtxEnc->lspCNG_fx[i] = add( mult_r( 26214 /*.8f Q15*/, lsp_tmp[i] ), mult_r( 6554 /*.2f Q15*/, lsp_new[i] ) ); /* Q15 */
move16();
}
}
@@ -1863,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*/
@@ -1909,7 +1889,7 @@ void CNG_enc_ivas_fx(
{
E_LPC_f_lsp_a_conversion( hDtxEnc->lspCNG_fx, Aq, M );
exp = sub( Q14, norm_s( Aq[0] ) );
- Scale_sig( Aq, M, sub( Q12, exp ) );
+ Scale_sig( Aq, M, sub( Q12, exp ) ); // Q12
}
tmp_loop = shr( st_fx->L_frame, 6 );
@@ -1930,8 +1910,8 @@ void CNG_enc_ivas_fx(
{
L_tmp1 = L_mult0( hTdCngEnc->CNG_att_fx, 26214 /* 1/20.0f in Q19 */ ); // Q26 (7 + 19)
L_tmp1 = BASOP_Util_fPow( 1342177280 /*10 in Q27 */, 4, L_tmp1, 5, &exp );
- att = extract_h( L_shl( L_tmp1, exp ) ); // Q15
- v_multc_fixed_16_16( res1, att, res1, st_fx->L_frame ); /* Q_new */
+ att = extract_h( L_shl( L_sub( L_tmp1, EPSILON_FX ), exp ) ); // Q15 // Subtracting by EPSILON_FX to avoid assertion when L_tmp1 value is 1073741824 and exp =1
+ v_multc_fixed_16_16( res1, att, res1, st_fx->L_frame ); /* Q_new */
}
ELSE IF( st_fx->bwidth != NB )
{
@@ -1943,7 +1923,7 @@ void CNG_enc_ivas_fx(
}
ELSE
{
- ftmp_fx = 19661;
+ ftmp_fx = 19661; /*.6f in Q15*/
move16();
}
@@ -1978,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 ) );
@@ -2075,11 +2049,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 );
@@ -2130,6 +2100,7 @@ void CNG_enc_ivas_fx(
enr = round_fx( L_tmp ); /* Q8 */
}
/* decrease the energy in case of WB input */
+ test();
IF( EQ_16( st_fx->element_mode, IVAS_SCE ) || EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) )
{
enr = add( enr, mult( hTdCngEnc->CNG_att_fx, FAC_LOG2_BY10_Q16 ) ); /* Q8 (Q7 + Q16 - Q15)*/
@@ -2154,7 +2125,7 @@ void CNG_enc_ivas_fx(
ELSE
{
att = 384;
- move16(); /*Q8*/
+ move16(); /*1.5f Q8*/
}
enr = sub( enr, att );
}
@@ -2220,6 +2191,7 @@ void CNG_enc_ivas_fx(
/* substract by 2 not done to leave Energy in Q2 */
lo = L_Extract_lc( L_tmp, &hi );
hTdCngEnc->Enew_fx = Pow2( add( hi, 4 ), lo ); /* Q6 */
+ move32();
IF( EQ_32( st_fx->core_brate, SID_2k40 ) )
{
/* enr1 = (float)log10( st->Enew*L_frame + 0.1f ) / (float)log10( 2.0f );*/
@@ -2227,11 +2199,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 ) );
@@ -2272,7 +2240,7 @@ void CNG_enc_ivas_fx(
}
/* codebook search */
- min1 = 1310588928; /* Q17 */
+ min1 = 1310588928; /* 9999.0f Q17 */
move32();
min1_idx = 0;
move16();
@@ -2285,13 +2253,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 */
}
@@ -2425,6 +2389,7 @@ void swb_CNG_enc_fx(
)
{
Word16 shb_SID_updt_fx = 0;
+ move16();
TD_CNG_ENC_HANDLE hTdCngEnc = st_fx->hTdCngEnc;
test();
@@ -2534,10 +2499,11 @@ static void shb_CNG_encod_fx(
#ifndef IVAS_CODE
hBstr->nb_bits_tot = sub( hBstr->nb_bits_tot, hBstr->ind_list[IND_CNG_ENV1].nb_bits );
hBstr->ind_list[IND_CNG_ENV1].nb_bits = -1;
+ move16();
+ move16();
#else
delete_indice( hBstr, IND_CNG_ENV1 );
#endif
- move16();
#ifdef IVAS_CODE
if ( st->element_mode == IVAS_CPE_DFT )
{
@@ -2550,6 +2516,8 @@ static void shb_CNG_encod_fx(
}
hTdCngEnc->ho_sid_bw = L_shl( L_and( hTdCngEnc->ho_sid_bw, (Word32) 0x3fffffffL ), 1 );
hTdCngEnc->ho_sid_bw = L_or( hTdCngEnc->ho_sid_bw, 0x1L );
+ move32();
+ move32();
}
ELSE
{
@@ -2587,11 +2555,13 @@ static Word16 shb_DTX_fx(
Word16 fra;
Word16 att; /*Q8*/
Word16 allow_cn_step_fx = 0;
+ move16();
DTX_ENC_HANDLE hDtxEnc = st_fx->hDtxEnc;
TD_CNG_ENC_HANDLE hTdCngEnc = st_fx->hTdCngEnc;
TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
shb_new_speech_fx = shb_old_speech_fx + ( ACELP_LOOK_12k8 + L_SUBFR ) * 5 / 4;
Copy( hBWE_TD->old_speech_shb_fx, shb_old_speech_fx, ( ACELP_LOOK_12k8 + L_SUBFR ) * 5 / 4 );
@@ -2601,11 +2571,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 */
@@ -2613,11 +2579,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 */
@@ -2626,11 +2588,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 );
@@ -2649,11 +2607,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;
@@ -2666,7 +2620,7 @@ static Word16 shb_DTX_fx(
move16();
}
- if ( GT_16( abs_s( sub( log_wb_ener_fx, hTdCngEnc->mov_wb_cng_ener_fx ) ), 3072 ) )
+ if ( GT_16( abs_s( sub( log_wb_ener_fx, hTdCngEnc->mov_wb_cng_ener_fx ) ), 3072 /*12.0f Q8*/ ) )
{
allow_cn_step_fx = 1;
move16();
@@ -2688,15 +2642,16 @@ static Word16 shb_DTX_fx(
ELSE
{
tmp = sub( log_wb_ener_fx, hTdCngEnc->mov_wb_cng_ener_fx ); /* Q8 */
- tmp = mult( tmp, 29491 ); /* Q8 */
+ tmp = mult( tmp, 29491 /*.9f in Q15*/ ); /* Q8 */
hTdCngEnc->mov_wb_cng_ener_fx = add( hTdCngEnc->mov_wb_cng_ener_fx, tmp ); /* Q8 */
-
+ move16();
tmp = sub( log_shb_ener_fx, hTdCngEnc->mov_shb_cng_ener_fx );
- tmp = mult( tmp, 8192 ); /* Q8 */
+ tmp = mult( tmp, 8192 /*.25f in Q15*/ ); /* Q8 */
hTdCngEnc->mov_shb_cng_ener_fx = add( hTdCngEnc->mov_shb_cng_ener_fx, tmp ); /* Q8 */
+ move16();
}
hTdCngEnc->shb_NO_DATA_cnt = add( hTdCngEnc->shb_NO_DATA_cnt, 1 );
-
+ move16();
update_fx = 0;
move16();
IF( EQ_32( st_fx->core_brate, SID_2k40 ) )
@@ -2715,10 +2670,11 @@ static Word16 shb_DTX_fx(
update_fx = 1;
move16();
hTdCngEnc->shb_cng_ini_cnt = sub( hTdCngEnc->shb_cng_ini_cnt, 1 );
+ move16();
}
ELSE
{
- IF( GT_16( abs_s( sub( sub( hTdCngEnc->mov_wb_cng_ener_fx, hTdCngEnc->mov_shb_cng_ener_fx ), sub( hTdCngEnc->last_wb_cng_ener_fx, hTdCngEnc->last_shb_cng_ener_fx ) ) ), 768 ) )
+ IF( GT_16( abs_s( sub( sub( hTdCngEnc->mov_wb_cng_ener_fx, hTdCngEnc->mov_shb_cng_ener_fx ), sub( hTdCngEnc->last_wb_cng_ener_fx, hTdCngEnc->last_shb_cng_ener_fx ) ) ), 768 /*3.0f in Q8*/ ) )
{
update_fx = 1;
move16();
@@ -2777,14 +2733,14 @@ static Word16 shb_DTX_fx(
*---------------------------------------------------------------------*/
void calculate_hangover_attenuation_gain_fx(
Encoder_State *st, /* i : encoder state structure */
- Word16 *att, /* o : attenuation factor */
+ Word16 *att, /* o : attenuation factor Q15 */
const Word16 vad_hover_flag /* i : VAD hangover flag */
)
{
Word16 offset;
TD_CNG_ENC_HANDLE hTdCngEnc = st->hTdCngEnc;
- *att = 32767;
+ *att = 32767; // 1.0f in Q15
move16();
/* smoothing in case of CNG */
@@ -2793,7 +2749,7 @@ void calculate_hangover_attenuation_gain_fx(
test();
test();
test();
- IF( hTdCngEnc->burst_ho_cnt > 0 && ( vad_hover_flag != 0 ) && ( NE_16( st->bwidth, NB ) || GT_16( st->element_mode, EVS_MONO ) ) ) /* corresponds to line 504 in FLT acelp_core_enc.c */
+ IF( hTdCngEnc->burst_ho_cnt > 0 && ( vad_hover_flag != 0 ) && ( NE_16( st->bwidth, NB ) || st->element_mode > EVS_MONO ) ) /* corresponds to line 504 in FLT acelp_core_enc.c */
{
#ifdef IVAS_CODE
if ( st->element_mode == IVAS_CPE_DFT || st->element_mode == IVAS_CPE_TD )
@@ -2804,6 +2760,7 @@ void calculate_hangover_attenuation_gain_fx(
#endif
{
offset = 5;
+ move16();
test();
if ( EQ_16( st->bwidth, WB ) && st->hDtxEnc->CNG_mode >= 0 )
{
@@ -2811,7 +2768,7 @@ void calculate_hangover_attenuation_gain_fx(
move16();
}
assert( hTdCngEnc->burst_ho_cnt > 0 );
- *att = CNG_burst_att_fx[offset][sub( hTdCngEnc->burst_ho_cnt, 1 )]; /*Q15*/
+ *att = CNG_burst_att_fx[offset][hTdCngEnc->burst_ho_cnt - 1]; /*Q15*/
move16();
}
}
@@ -2821,20 +2778,20 @@ void calculate_hangover_attenuation_gain_fx(
void calculate_hangover_attenuation_gain_ivas_fx(
Encoder_State *st, /* i : encoder state structure */
- Word16 *att, /* o : attenuation factor */
+ Word16 *att, /* o : attenuation factor Q15 */
const Word16 vad_hover_flag /* i : VAD hangover flag */
)
{
Word16 lim, result_e;
- *att = 32767;
+ *att = 32767; // 1.0f in Q15
move16();
test();
test();
test();
test();
- IF( st->hTdCngEnc != NULL && ( vad_hover_flag != 0 ) && GT_16( st->hTdCngEnc->burst_ho_cnt, 0 ) && ( NE_16( st->bwidth, NB ) || GT_16( st->element_mode, EVS_MONO ) ) )
+ IF( st->hTdCngEnc != NULL && ( vad_hover_flag != 0 ) && GT_16( st->hTdCngEnc->burst_ho_cnt, 0 ) && ( NE_16( st->bwidth, NB ) || st->element_mode > EVS_MONO ) )
{
test();
IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) )
diff --git a/lib_enc/cod2t32_fx.c b/lib_enc/cod2t32_fx.c
index d933989970e0a6297977d86702570cf5eb5a6442..c9bbe5f30954307fb392712240508edeca860d56 100644
--- a/lib_enc/cod2t32_fx.c
+++ b/lib_enc/cod2t32_fx.c
@@ -30,10 +30,10 @@
void acelp_2t32_fx(
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const Word16 dn[], /* i : corr. between target and h[]. */
- const Word16 h[], /* i : impulse response of weighted synthesis filter */
- Word16 code[], /* o : algebraic (fixed) codebook excitation */
- Word16 y[] /* o : filtered fixed codebook excitation */
+ const Word16 dn[], /* i : corr. between target and h[]. Qx*/
+ const Word16 h[], /* i : impulse response of weighted synthesis filter Q12*/
+ Word16 code[], /* o : algebraic (fixed) codebook excitation Q9*/
+ Word16 y[] /* o : filtered fixed codebook excitation Q9*/
)
{
Word16 i, j, k, i0, i1, ix, iy, pos, pos2, sign0, sign1, index;
@@ -50,6 +50,7 @@ void acelp_2t32_fx(
Word16 rrixiy[MSIZE];
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/*----------------------------------------------------------------*
* Compute rrixix[][] needed for the codebook search.
@@ -57,37 +58,24 @@ void acelp_2t32_fx(
/* Init pointers to last position of rrixix[] */
p0 = &rrixix[0][NB_POS_FCB_2T - 1];
- move16();
p1 = &rrixix[1][NB_POS_FCB_2T - 1];
- move16();
ptr_h1 = h;
- move16();
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*/
}
p0 = rrixix[0];
- move16();
p1 = rrixix[1];
- move16();
FOR( i = 0; i < NB_POS_FCB_2T; i++ )
{
@@ -108,54 +96,34 @@ void acelp_2t32_fx(
pos2 = MSIZE - 2;
move16();
ptr_hf = h + 1;
- move16();
FOR( k = 0; k < NB_POS_FCB_2T; k++ )
{
/* Init pointers to last position of diagonals */
p1 = &rrixiy[pos];
- move16();
p0 = &rrixiy[pos2];
- move16();
ptr_h1 = h;
- move16();
ptr_h2 = ptr_hf;
- move16();
- L_cor = L_mult( *ptr_h1++, *ptr_h2++ );
+ 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 );
+ *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 );
+ *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
- p1 -= ( NB_POS_FCB_2T + 1 );
move16();
- p0 -= ( NB_POS_FCB_2T + 1 );
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
+ *p1 = round_fx_o( L_cor, &Overflow ); // Q9
pos -= NB_POS_FCB_2T;
move16();
pos2--;
ptr_hf += STEP;
- move16();
}
/*----------------------------------------------------------------*
@@ -168,18 +136,18 @@ void acelp_2t32_fx(
/* FIR high-pass filtering */
IF( i == 0 )
{
- L_tmp = L_msu( L_tmp, dn[1], 11469 );
+ L_tmp = L_msu( L_tmp, dn[1], 11469 /*.3f Q15*/ );
}
ELSE IF( EQ_16( i, L_SUBFR - 1 ) )
{
L_tmp = L_deposit_h( dn[i] );
- L_tmp = L_msu( L_tmp, dn[i - 1], 11469 );
+ L_tmp = L_msu( L_tmp, dn[i - 1], 11469 /*.3f Q15*/ );
}
ELSE
{
L_tmp = L_deposit_h( dn[i] );
- L_tmp = L_msu( L_tmp, dn[i - 1], 11469 );
- L_tmp = L_msu( L_tmp, dn[i + 1], 11469 );
+ L_tmp = L_msu( L_tmp, dn[i - 1], 11469 /*.3f Q15*/ );
+ L_tmp = L_msu( L_tmp, dn[i + 1], 11469 /*.3f Q15*/ );
}
/* pre-selection of polarities */
@@ -232,11 +200,8 @@ void acelp_2t32_fx(
*----------------------------------------------------------------*/
p0 = rrixix[0];
- move16();
p1 = rrixix[1];
- move16();
p2 = rrixiy;
- move16();
psk = -1;
move16();
alpk = 1;
@@ -257,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;
@@ -279,7 +236,6 @@ void acelp_2t32_fx(
}
}
p1 -= NB_POS_FCB_2T;
- move16();
IF( pos >= 0 )
{
@@ -293,8 +249,8 @@ void acelp_2t32_fx(
i0 = shr( ix, 1 );
i1 = shr( iy, 1 );
- sign0 = shl( pol[ix], 9 );
- sign1 = shl( pol[iy], 9 );
+ sign0 = shl( pol[ix], 9 ); // Q9
+ sign1 = shl( pol[iy], 9 ); // Q9
/*-------------------------------------------------------------------*
* Build the codeword, the filtered codeword and index of codevector.
@@ -327,12 +283,13 @@ void acelp_2t32_fx(
FOR( i = ix; i < L_SUBFR; i++ )
{
- y[i] = mult_r( sign0, h[i - ix] );
+ y[i] = mult_r( sign0, h[i - ix] ); // Q9
move16();
}
FOR( i = iy; i < L_SUBFR; i++ )
{
- y[i] = round_fx( L_mac( L_deposit_h( y[i] ), sign1, h[i - iy] ) );
+ y[i] = round_fx( L_mac( L_deposit_h( y[i] ), sign1, h[i - iy] ) ); // Q9
+ move16();
}
{
/* write index to array of indices */
@@ -343,10 +300,10 @@ void acelp_2t32_fx(
void acelp_2t32_ivas_fx(
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const Word16 dn[], /* i : corr. between target and h[]. */
- const Word16 h[], /* i : impulse response of weighted synthesis filter */
- Word16 code[], /* o : algebraic (fixed) codebook excitation */
- Word16 y[] /* o : filtered fixed codebook excitation */
+ const Word16 dn[], /* i : corr. between target and h[]. Qx*/
+ const Word16 h[], /* i : impulse response of weighted synthesis filter Q12*/
+ Word16 code[], /* o : algebraic (fixed) codebook excitation Q9 */
+ Word16 y[] /* o : filtered fixed codebook excitation Q9 */
)
{
Word16 i, j, k, i0, i1, ix, iy, pos, pos2, sign0, sign1, index;
@@ -371,37 +328,25 @@ void acelp_2t32_ivas_fx(
/* Init pointers to last position of rrixix[] */
p0 = &rrixix[0][NB_POS_FCB_2T - 1];
- move16();
p1 = &rrixix[1][NB_POS_FCB_2T - 1];
- move16();
ptr_h1 = h;
move16();
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*/
}
p0 = rrixix[0];
- move16();
p1 = rrixix[1];
- move16();
FOR( i = 0; i < NB_POS_FCB_2T; i++ )
{
@@ -422,52 +367,33 @@ void acelp_2t32_ivas_fx(
pos2 = MSIZE - 2;
move16();
ptr_hf = h + 1;
- move16();
FOR( k = 0; k < NB_POS_FCB_2T; k++ )
{
/* Init pointers to last position of diagonals */
p1 = &rrixiy[pos];
- move16();
p0 = &rrixiy[pos2];
- move16();
ptr_h1 = h;
- move16();
ptr_h2 = ptr_hf;
- move16();
- L_cor = L_mult( *ptr_h1++, *ptr_h2++ );
+ 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 );
+ *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 );
+ *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
- p1 -= ( NB_POS_FCB_2T + 1 );
move16();
- p0 -= ( NB_POS_FCB_2T + 1 );
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--;
+ pos2 = sub( pos2, 1 );
ptr_hf += STEP;
move16();
}
@@ -482,18 +408,18 @@ void acelp_2t32_ivas_fx(
/* FIR high-pass filtering */
IF( i == 0 )
{
- L_tmp = L_msu( L_tmp, dn[1], 11469 );
+ L_tmp = L_msu( L_tmp, dn[1], 11469 /*.3f Q15*/ );
}
ELSE IF( EQ_16( i, L_SUBFR - 1 ) )
{
L_tmp = L_deposit_h( dn[i] );
- L_tmp = L_msu( L_tmp, dn[i - 1], 11469 );
+ L_tmp = L_msu( L_tmp, dn[i - 1], 11469 /*.3f Q15*/ );
}
ELSE
{
L_tmp = L_deposit_h( dn[i] );
- L_tmp = L_msu( L_tmp, dn[i - 1], 11469 );
- L_tmp = L_msu( L_tmp, dn[i + 1], 11469 );
+ L_tmp = L_msu( L_tmp, dn[i - 1], 11469 /*.3f Q15*/ );
+ L_tmp = L_msu( L_tmp, dn[i + 1], 11469 /*.3f Q15*/ );
}
/* pre-selection of polarities */
@@ -546,11 +472,8 @@ void acelp_2t32_ivas_fx(
*----------------------------------------------------------------*/
p0 = rrixix[0];
- move16();
p1 = rrixix[1];
- move16();
p2 = rrixiy;
- move16();
psk = -1;
move16();
alpk = 1;
@@ -571,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;
@@ -593,7 +508,6 @@ void acelp_2t32_ivas_fx(
}
}
p1 -= NB_POS_FCB_2T;
- move16();
IF( pos >= 0 )
{
@@ -607,8 +521,8 @@ void acelp_2t32_ivas_fx(
i0 = shr( ix, 1 );
i1 = shr( iy, 1 );
- sign0 = shl( pol[ix], 9 );
- sign1 = shl( pol[iy], 9 );
+ sign0 = shl( pol[ix], 9 ); // Q9
+ sign1 = shl( pol[iy], 9 ); // Q9
/*-------------------------------------------------------------------*
* Build the codeword, the filtered codeword and index of codevector.
@@ -641,12 +555,13 @@ void acelp_2t32_ivas_fx(
FOR( i = ix; i < L_SUBFR; i++ )
{
- y[i] = mult_r( sign0, h[i - ix] );
+ y[i] = mult_r( sign0, h[i - ix] ); // Q9
move16();
}
FOR( i = iy; i < L_SUBFR; i++ )
{
- y[i] = round_fx( L_mac( L_deposit_h( y[i] ), sign1, h[i - iy] ) );
+ y[i] = round_fx( L_mac( L_deposit_h( y[i] ), sign1, h[i - iy] ) ); // Q9
+ move16();
}
{
/* write index to array of indices */
@@ -665,10 +580,10 @@ void acelp_2t32_ivas_fx(
void acelp_1t64_fx(
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const Word16 dn[], /* i : corr. between target and h[]. */
- const Word16 h[], /* i : impulse response of weighted synthesis filter */
- Word16 code[], /* o : algebraic (fixed) codebook excitation */
- Word16 y[], /* o : filtered fixed codebook excitation */
+ const Word16 dn[], /* i : corr. between target and h[]. Qx*/
+ const Word16 h[], /* i : impulse response of weighted synthesis filter Q12 */
+ Word16 code[], /* o : algebraic (fixed) codebook excitation Q9 */
+ Word16 y[], /* o : filtered fixed codebook excitation Q9 */
const Word16 L_subfr /* i : subframe length */
)
{
@@ -681,12 +596,12 @@ void acelp_1t64_fx(
IF( dn[pos] < 0 )
{
- sgn = -512;
+ sgn = -512; //-1 in Q9
move16();
}
ELSE
{
- sgn = 512;
+ sgn = 512; // 1 in Q9
move16();
}
@@ -704,12 +619,12 @@ void acelp_1t64_fx(
{
IF( sgn > 0 )
{
- y[i] = shr_r( h[i - pos], 3 );
+ y[i] = shr_r( h[i - pos], 3 ); // Q9
move16();
}
ELSE
{
- y[i] = negate( shr_r( h[i - pos], 3 ) );
+ y[i] = negate( shr_r( h[i - pos], 3 ) ); // Q9
move16();
}
}
@@ -734,10 +649,10 @@ void acelp_1t64_fx(
void acelp_1t64_ivas_fx(
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const Word16 dn[], /* i : corr. between target and h[]. */
- const Word16 h[], /* i : impulse response of weighted synthesis filter */
- Word16 code[], /* o : algebraic (fixed) codebook excitation */
- Word16 y[], /* o : filtered fixed codebook excitation */
+ const Word16 dn[], /* i : corr. between target and h[]. Qx */
+ const Word16 h[], /* i : impulse response of weighted synthesis filter Q12*/
+ Word16 code[], /* o : algebraic (fixed) codebook excitation Q9*/
+ Word16 y[], /* o : filtered fixed codebook excitation Q9*/
const Word16 L_subfr /* i : subframe length */
)
{
@@ -773,12 +688,12 @@ void acelp_1t64_ivas_fx(
{
IF( sgn > 0 )
{
- y[i] = shr_r( h[i - pos], 3 );
+ y[i] = shr_r( h[i - pos], 3 ); // Q9
move16();
}
ELSE
{
- y[i] = negate( shr_r( h[i - pos], 3 ) );
+ y[i] = negate( shr_r( h[i - pos], 3 ) ); // Q9
move16();
}
}
diff --git a/lib_enc/cod4t64_fast.c b/lib_enc/cod4t64_fast.c
index e40766bec0d6a18fcb61125176bcca1bc8dc3002..93bcc1ce3ffe44ca66128e467dbf5cf03d4c98ac 100644
--- a/lib_enc/cod4t64_fast.c
+++ b/lib_enc/cod4t64_fast.c
@@ -60,7 +60,7 @@
*---------------------------------------------------------------------*/
/*! r: return index (N+1 bits) */
-static Word16 quant_1p_N1_L_subfr(
+static Word16 quant_1p_N1_L_subfr_fx(
const Word16 nb_pos, /* i : number of positions */
const Word16 pos, /* i : position of the pulse */
const Word16 N /* i : number of bits for position */
@@ -72,7 +72,7 @@ static Word16 quant_1p_N1_L_subfr(
index = s_and( pos, mask );
- if ( s_and( pos, nb_pos ) != 0 )
+ IF( s_and( pos, nb_pos ) != 0 )
{
index = add( index, shl( 1, N ) );
}
@@ -83,14 +83,15 @@ static Word16 find_best_pulse_fx(
const Word16 L_subfr,
const Word16 nb_tracks,
const Word16 track,
- const Word32 dn[],
- const Word16 sign[],
- Word16 *s )
+ const Word32 dn[], // Qx
+ const Word16 sign[], // Q0
+ Word16 *s // Q0
+)
{
Word16 m, i;
Word32 temp, max_val;
- max_val = MIN_32;
+ max_val = EPSILLON_FX;
move32();
m = track;
move16();
@@ -370,7 +371,7 @@ void acelp_fast_fx(
{
h[i] = H[i];
move16();
- h_inv[i] = -H[i];
+ h_inv[i] = negate( H[i] );
move16();
}
@@ -594,7 +595,7 @@ void acelp_fast_fx(
move16();
s64 = 0;
-
+ move64();
FOR( i = track; i < L_subfr; i += nb_tracks )
{
dn[i] = L_shr( L_msu( L_mult0( Gd, dn_orig[i] ), G, *alp_pos0 ), 6 ); // Q_dn
@@ -606,11 +607,18 @@ void acelp_fast_fx(
dndn_fx = W_extract_h( W_shl( s64, exp1 ) ); // 2 * Q_dyn + exp1 - 31
dndn_e = sub( 31, sub( add( shl( Q_dn, 1 ), exp ), 31 ) );
+ IF( dndn_fx == 0 )
+ {
+ dndn_fx = 214748365 /* 0.1f in Q31 */;
+ move32();
+ dndn_e = 0;
+ move16();
+ }
s_coef_fx = BASOP_Util_Divide3232_Scale( dndn_fx, cncn_track[track], &exp1 );
exp1 = add( exp1, sub( dndn_e, cncn_track_e[track] ) );
s_coef_fx = Sqrt16( s_coef_fx, &exp1 );
exp1 = sub( exp1, shift );
- max_val_fx = MIN_16;
+ max_val_fx = EPSILLON_FX;
move16();
m[1] = track; // Q0
move16();
@@ -641,6 +649,7 @@ void acelp_fast_fx(
{
Gn = add( Gn, i_mult( s[1], shr( dn_orig[m[1]], 1 ) ) ); // Q_dn -1
Gd32 = Gd;
+ move16();
Gd32 = L_add( Gd32, L_add( alp[0], L_mult0( i_mult( shl( s[0], 1 ), s[1] ), alp[m[0] - m[1]] ) ) ); // Q6
G = Gn; // Q_dn - 1
move16();
@@ -672,6 +681,7 @@ void acelp_fast_fx(
{
Gn = add( Gn, i_mult( s[2], shr( dn_orig[m[2]], 1 ) ) ); // Q_dn-1
Gd32 = Gd;
+ move16();
Gd32 = L_add( Gd32, L_add( L_add( alp[0], L_mult0( i_mult( shl( s[0], 1 ), s[2] ), alp[m[0] - m[2]] ) ), L_mult0( i_mult( shl( s[1], 1 ), s[2] ), alp[m[1] - m[2]] ) ) ); // Q6
G = Gn; // Q_dn-1
move16();
@@ -711,12 +721,14 @@ void acelp_fast_fx(
{
Gn = add( Gn, i_mult( s[3], shr( dn_orig[m[3]], 1 ) ) ); // Q_dn-1
Gd32 = Gd;
+ move16();
Gd32 = L_add( Gd32, L_add( L_add( L_add( alp[0], L_mult0( i_mult( shl( s[0], 1 ), s[3] ), alp[m[0] - m[3]] ) ), L_mult0( i_mult( shl( s[1], 1 ), s[3] ), alp[m[1] - m[3]] ) ), L_mult0( i_mult( shl( s[2], 1 ), s[3] ), alp[m[2] - m[3]] ) ) ); // Q6
- G = Gn; // Q_dn-1
- G1 = i_mult( G, s[1] ); // Q_dn-1
- G2 = i_mult( G, s[2] ); // Q_dn-1
- G3 = i_mult( G, s[3] ); // Q_dn-1
- G = i_mult( G, s[0] ); // Q_dn-1
+ G = Gn;
+ move16(); // Q_dn-1
+ G1 = i_mult( G, s[1] ); // Q_dn-1
+ G2 = i_mult( G, s[2] ); // Q_dn-1
+ G3 = i_mult( G, s[3] ); // Q_dn-1
+ G = i_mult( G, s[0] ); // Q_dn-1
IF( EQ_16( cdk_index, 6 ) )
{
@@ -758,7 +770,30 @@ void acelp_fast_fx(
alp_pos3++;
}
- i = emaximum_32fx( Q_dn, dn, L_subfr, &L_tmp1 );
+ Word16 k;
+ Word64 W_tmp, W_tmp1;
+ Word64 emax;
+
+ emax = W_mult0_32_32( dn[0], dn[0] );
+ i = 0;
+ move16();
+
+ FOR( k = 1; k < L_subfr; k++ )
+ {
+ W_tmp = W_mult0_32_32( dn[k], dn[k] );
+ W_tmp1 = W_sub( W_tmp, emax );
+ if ( W_tmp1 > 0 )
+ {
+ i = k;
+ move16();
+ }
+ if ( LE_64( emax, W_tmp ) )
+ {
+ emax = W_tmp;
+ move64();
+ }
+ }
+
track = i % nb_tracks;
move16();
@@ -814,9 +849,9 @@ void acelp_fast_fx(
crit_den = W_extract_h( W_shl( s64, exp1 ) ); // 2*q_H + exp1 - 32
q_crit_den = add( shl( q_H, 1 ), sub( exp1, 32 ) );
- L_tmp1 = Mpy_32_32( crit_num, crit_den_max );
+ L_tmp1 = Mpy_32_32( crit_num, crit_den_max ); // q_crit_num+q_crit_den_max-31
exp = sub( add( q_crit_num, q_crit_den_max ), 31 );
- L_tmp2 = Mpy_32_32( crit_den, crit_num_max );
+ L_tmp2 = Mpy_32_32( crit_den, crit_num_max ); // q_crit_den+q_crit_num_max-31
exp1 = sub( add( q_crit_den, q_crit_num_max ), 31 );
IF( GT_16( exp, exp1 ) )
@@ -984,7 +1019,7 @@ void acelp_fast_fx(
j = i_mult( q, NPMAXPT );
IF( NE_16( ind_stream[j], -1 ) )
{
- idx = quant_1p_N1_L_subfr( nb_pos, ind_stream[j], bits_track );
+ idx = quant_1p_N1_L_subfr_fx( nb_pos, ind_stream[j], bits_track );
push_indice( hBstr, IND_ALG_CDBK_4T64, idx, add( bits_track, 1 ) );
}
}
@@ -1001,7 +1036,7 @@ void acelp_fast_fx(
}
ELSE
{
- idx = quant_1p_N1_L_subfr( nb_pos, ind_stream[j], bits_track );
+ idx = quant_1p_N1_L_subfr_fx( nb_pos, ind_stream[j], bits_track );
push_indice( hBstr, IND_ALG_CDBK_4T64, idx, add( bits_track, 1 ) );
}
}
diff --git a/lib_enc/cod4t64_fx.c b/lib_enc/cod4t64_fx.c
index 92db2139b7b4c08b412056294c6f194875c646fc..44cde6f27d8488be31521c55cd81eb875d3a196d 100644
--- a/lib_enc/cod4t64_fx.c
+++ b/lib_enc/cod4t64_fx.c
@@ -57,10 +57,10 @@ static Word32 pre_process_fx( const Word16 v[], Word16 sector_6p[], Word32 secto
Word16 acelp_4t64_fx(
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- Word16 dn[], /* i : corr. between target and h[]. */
+ Word16 dn[], /* i : corr. between target and h[]. */
const Word16 cn[], /* i : residual after long term prediction Q_new*/
const Word16 H[], /* i : impulse response of weighted synthesis filter Q12*/
- Word16 R[], /* i : autocorrelation values */
+ Word16 R[], /* i : autocorrelation values */
const Word16 acelpautoc, /* i : autocorrealtion flag */
Word16 code[], /* o : algebraic (fixed) codebook excitation Q9*/
Word16 y[], /* o : filtered fixed codebook excitation Q9*/
@@ -100,9 +100,9 @@ Word16 acelp_4t64_fx(
case 28: /* EVS pulse indexing: 28 bits, 6 pulses, 4 tracks */
config.nbiter = 4;
- move16(); /* 4x20x16=1280 loops */
- config.alp = 8192;
- move16(); /* coeff FOR sign setting */
+ move16(); /* 4x20x16=1280 loops */
+ config.alp = 8192; /*1 in Q13*/
+ move16(); /* coeff FOR sign setting */
config.nb_pulse = 6;
move16();
config.fixedpulses = 0;
@@ -117,9 +117,9 @@ Word16 acelp_4t64_fx(
case 36: /* EVS/AMR-WB pulse indexing: 36 bits, 8 pulses, 4 tracks */
config.nbiter = 4;
- move16(); /* 4x20x16=1280 loops */
- config.alp = 8192;
- move16(); /* coeff FOR sign setting */
+ move16(); /* 4x20x16=1280 loops */
+ config.alp = 8192; /*1 in Q13*/
+ move16(); /* coeff FOR sign setting */
config.nb_pulse = 8;
move16();
config.fixedpulses = 2;
@@ -135,8 +135,8 @@ Word16 acelp_4t64_fx(
case 43: /* EVS pulse indexing: 43 bits, 10 pulses, 4 tracks */
case 44: /* AMR-WB pulse indexing: 44 bits, 10 pulses, 4 tracks */
config.nbiter = 4;
- move16(); /* 4x26x16=1664 loops */
- config.alp = 8192;
+ move16(); /* 4x26x16=1664 loops */
+ config.alp = 8192; /*1 in Q13*/
move16();
config.nb_pulse = 10;
move16();
@@ -155,8 +155,8 @@ Word16 acelp_4t64_fx(
case 50: /* EVS pulse indexing: 50 bits, 12 pulses, 4 tracks */
case 52: /* AMR-WB pulse indexing: 52 bits, 12 pulses, 4 tracks */
config.nbiter = 4;
- move16(); /* 4x26x16=1664 loops */
- config.alp = 8192;
+ move16(); /* 4x26x16=1664 loops */
+ config.alp = 8192; /*1 in Q13*/
move16();
config.nb_pulse = 12;
move16();
@@ -175,8 +175,8 @@ Word16 acelp_4t64_fx(
case 62: /* EVS pulse indexing: 62 bits, 16 pulses, 4 tracks */
case 64: /* AMR-WB pulse indexing: 64 bits, 16 pulses, 4 tracks */
config.nbiter = 3;
- move16(); /* 3x36x16=1728 loops */
- config.alp = 6554;
+ move16(); /* 3x36x16=1728 loops */
+ config.alp = 6554; /*.8f in Q13*/
move16();
config.nb_pulse = 16;
move16();
@@ -198,8 +198,8 @@ Word16 acelp_4t64_fx(
case 72: /* AMR-WB pulse indexing: 72 bits, 18 pulses, 4 tracks */
config.nbiter = 3;
- move16(); /* 3x35x16=1680 loops */
- config.alp = 6144;
+ move16(); /* 3x35x16=1680 loops */
+ config.alp = 6144; /*.75f in Q13*/
move16();
config.nb_pulse = 18;
move16();
@@ -223,8 +223,8 @@ Word16 acelp_4t64_fx(
case 88: /* AMR-WB pulse indexing: 88 bits, 24 pulses, 4 tracks */
config.nbiter = 2;
- move16(); /* 2x53x16=1696 loop */
- config.alp = 4096;
+ move16(); /* 2x53x16=1696 loop */
+ config.alp = 4096; /*.5f in Q13*/
move16();
config.nb_pulse = 24;
move16();
@@ -255,7 +255,7 @@ Word16 acelp_4t64_fx(
case 87: /* EVS pulse indexing: 87 bits, 26 pulses, 4 tracks */
config.nbiter = 1;
move16();
- config.alp = 4096;
+ config.alp = 4096; /*.5f in Q13*/
move16();
config.nb_pulse = 26;
move16();
@@ -472,10 +472,10 @@ Word16 acelp_4t64_fx(
Word16 acelp_4t64_ivas_fx(
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- Word16 dn[], /* i : corr. between target and h[]. */
+ Word16 dn[], /* i : corr. between target and h[]. */
const Word16 cn[], /* i : residual after long term prediction Q_new*/
const Word16 H[], /* i : impulse response of weighted synthesis filter Q12*/
- Word16 R[], /* i : autocorrelation values */
+ Word16 R[], /* i : autocorrelation values */
const Word16 acelpautoc, /* i : autocorrealtion flag */
Word16 code[], /* o : algebraic (fixed) codebook excitation Q9*/
Word16 y[], /* o : filtered fixed codebook excitation Q9*/
@@ -515,9 +515,9 @@ Word16 acelp_4t64_ivas_fx(
case 28: /* EVS pulse indexing: 28 bits, 6 pulses, 4 tracks */
config.nbiter = 4;
- move16(); /* 4x20x16=1280 loops */
- config.alp = 8192;
- move16(); /* coeff FOR sign setting */
+ move16(); /* 4x20x16=1280 loops */
+ config.alp = 8192; /*1 in Q13*/
+ move16(); /* coeff FOR sign setting */
config.nb_pulse = 6;
move16();
config.fixedpulses = 0;
@@ -532,9 +532,9 @@ Word16 acelp_4t64_ivas_fx(
case 36: /* EVS/AMR-WB pulse indexing: 36 bits, 8 pulses, 4 tracks */
config.nbiter = 4;
- move16(); /* 4x20x16=1280 loops */
- config.alp = 8192;
- move16(); /* coeff FOR sign setting */
+ move16(); /* 4x20x16=1280 loops */
+ config.alp = 8192; /*1 in Q13*/
+ move16(); /* coeff FOR sign setting */
config.nb_pulse = 8;
move16();
config.fixedpulses = 2;
@@ -550,8 +550,8 @@ Word16 acelp_4t64_ivas_fx(
case 43: /* EVS pulse indexing: 43 bits, 10 pulses, 4 tracks */
case 44: /* AMR-WB pulse indexing: 44 bits, 10 pulses, 4 tracks */
config.nbiter = 4;
- move16(); /* 4x26x16=1664 loops */
- config.alp = 8192;
+ move16(); /* 4x26x16=1664 loops */
+ config.alp = 8192; /*1 in Q13*/
move16();
config.nb_pulse = 10;
move16();
@@ -570,8 +570,8 @@ Word16 acelp_4t64_ivas_fx(
case 50: /* EVS pulse indexing: 50 bits, 12 pulses, 4 tracks */
case 52: /* AMR-WB pulse indexing: 52 bits, 12 pulses, 4 tracks */
config.nbiter = 4;
- move16(); /* 4x26x16=1664 loops */
- config.alp = 8192;
+ move16(); /* 4x26x16=1664 loops */
+ config.alp = 8192; /*1 in Q13*/
move16();
config.nb_pulse = 12;
move16();
@@ -590,8 +590,8 @@ Word16 acelp_4t64_ivas_fx(
case 62: /* EVS pulse indexing: 62 bits, 16 pulses, 4 tracks */
case 64: /* AMR-WB pulse indexing: 64 bits, 16 pulses, 4 tracks */
config.nbiter = 3;
- move16(); /* 3x36x16=1728 loops */
- config.alp = 6554;
+ move16(); /* 3x36x16=1728 loops */
+ config.alp = 6554; /*.8f in Q13*/
move16();
config.nb_pulse = 16;
move16();
@@ -613,8 +613,8 @@ Word16 acelp_4t64_ivas_fx(
case 72: /* AMR-WB pulse indexing: 72 bits, 18 pulses, 4 tracks */
config.nbiter = 3;
- move16(); /* 3x35x16=1680 loops */
- config.alp = 6144;
+ move16(); /* 3x35x16=1680 loops */
+ config.alp = 6144; /*.75f in Q13*/
move16();
config.nb_pulse = 18;
move16();
@@ -638,8 +638,8 @@ Word16 acelp_4t64_ivas_fx(
case 88: /* AMR-WB pulse indexing: 88 bits, 24 pulses, 4 tracks */
config.nbiter = 2;
- move16(); /* 2x53x16=1696 loop */
- config.alp = 4096;
+ move16(); /* 2x53x16=1696 loop */
+ config.alp = 4096; /*.5f in Q13*/
move16();
config.nb_pulse = 24;
move16();
@@ -670,7 +670,7 @@ Word16 acelp_4t64_ivas_fx(
case 87: /* EVS pulse indexing: 87 bits, 26 pulses, 4 tracks */
config.nbiter = 1;
move16();
- config.alp = 4096;
+ config.alp = 4096; /*.5f in Q13*/
move16();
config.nb_pulse = 26;
move16();
@@ -709,7 +709,7 @@ Word16 acelp_4t64_ivas_fx(
}
config.codetrackpos = TRACKPOS_FIXED_FIRST;
- move16();
+ move32();
config.bits = nbbits;
move16();
@@ -905,7 +905,7 @@ static Word32 fcb_encode_cl_fx( /* o: class index of t
FOR( i = 0; i < pulse_num; i++ )
{
- k = L_sub( k, PI_select_table[L_sub( temp1, buffer[i] )][temp2--] );
+ k = L_sub( k, PI_select_table[temp1 - buffer[i]][temp2--] );
temp1 = L_sub( temp1, 1 );
}
@@ -917,7 +917,7 @@ static Word32 fcb_encode_cl_fx( /* o: class index of t
*encode fcb pulse index *
*---------------------------------------------------------------------*/
static Word32 fcb_encode_PI_fx( /* o: return index of the pulse on a track */
- const Word16 v[], /* i: pulse on a track */
+ const Word16 v[], /* i: pulse on a track Q9 */
const Word32 pulse_num /* i: number of the pulse on a track */
)
{
@@ -935,7 +935,7 @@ static Word32 fcb_encode_PI_fx( /* o: return index of t
/*encode the class and compute class offset*/
code_index = L_add( code_index, fcb_encode_class_fx( sector_p_num, pulse_num, pulse_pos_num ) );
- code_index = L_add( PI_offset[pulse_num][L_sub( L_add( pulse_num, 1L ), pulse_pos_num )], L_add( L_shl( code_index, extract_l( pulse_pos_num ) ), sign ) );
+ code_index = L_add( PI_offset[pulse_num][( ( pulse_num + 1L ) - pulse_pos_num )], L_add( L_shl( code_index, extract_l( pulse_pos_num ) ), sign ) );
return code_index;
}
@@ -999,7 +999,7 @@ static Word32 fcb_encode_position_fx( /* o: return
FOR( i = 0; i < pos_num; i++ )
{
/*mmm1 -= PI_select_table_fx[sub(n,pos_vector[i]-1)][temp2--];*/
- mmm1 = L_sub( mmm1, PI_select_table[L_sub( n, add( pos_vector[i], 1 ) )][temp2--] );
+ mmm1 = L_sub( mmm1, PI_select_table[n - ( pos_vector[i] + 1 )][temp2--] );
}
}
ELSE
@@ -1008,7 +1008,7 @@ static Word32 fcb_encode_position_fx( /* o: return
FOR( i = 0; i < pos_num; i++ )
{
/*mmm1 -= PI_select_table_fx[n-pos_vector[i]-1][temp2--];*/
- mmm1 = L_sub( mmm1, PI_select_table[L_sub( n, add( pos_vector[i], 1 ) )][temp2--] );
+ mmm1 = L_sub( mmm1, PI_select_table[n - ( pos_vector[i] + 1 )][temp2--] );
n = L_sub( n, 1 );
}
}
@@ -1232,7 +1232,7 @@ static Word32 quant_4p_4N_fx( /* o : return 4*N bits
Word16 posA[4], posB[4];
Word32 index;
- n_1 = (Word16) ( N - 1 );
+ n_1 = sub( N, 1 );
move16();
nb_pos = shl( 1, n_1 ); /* nb_pos = (1< it doesn't need to be operated by Basic Operators */
- n_1 = (Word16) ( N - 1 );
- move16();
+ n_1 = sub( N, 1 );
nb_pos = shl( 1, n_1 ); /* nb_pos = (1< 1, Q0 */
+ move32();
IF( v[k] > 0 )
{
sign = L_shl( sign, 1 );
@@ -1492,6 +1494,7 @@ static Word32 pre_process_fx( /* o: return sign value
}
}
*pulse_pos_num = L_deposit_l( j );
+move32();
return sign;
}
@@ -1510,7 +1513,7 @@ return sign;
*--------------------------------------------------------------------------*/
Word16 E_ACELP_code43bit_fx(
- const Word16 code[],
+ const Word16 code[], /*Q9*/
UWord32 *ps,
Word16 *p,
UWord16 idxs[] )
@@ -1522,8 +1525,9 @@ Word16 E_ACELP_code43bit_fx(
Word32 L_tmp;
Word32 joint_index;
static const Word32 joint_offset = 3611648; /*offset for 3 pulses per track*/
+ move32();
Word16 saved_bits = 0;
-
+ move16();
FOR( track = 0; track < 2; track++ )
{
ps[track] = fcb_encode_PI_fx( code + track, 3 );
@@ -1535,19 +1539,19 @@ Word16 E_ACELP_code43bit_fx(
FOR( track = 2; track < NB_TRACK_FCB_4T; track++ )
{
i = j = i_mult2( track, NPMAXPT );
- move16();
+
FOR( k = track; k < 64; k += 4 )
{
IF( code[k] )
{
tmp = shr( k, 2 );
- if ( code[k] < 0 )
+ IF( code[k] < 0 )
{
tmp = add( tmp, 16 );
}
ind[j] = tmp;
move16();
- IF( GT_16( abs_s( code[k] ), 512 ) )
+ IF( GT_16( abs_s( code[k] ), 512 /*Q9*/ ) )
{
ind[j + 1] = tmp;
move16();
@@ -1580,6 +1584,8 @@ Word16 E_ACELP_code43bit_fx(
idxs[0] = extract_l( L_add( L_shl( ps[2], 9 ), ps[3] ) );
idxs[1] = extract_l( L_add( L_shl( joint_index, 2 ), L_shr( ps[2], 7 ) ) );
idxs[2] = extract_l( L_shr( joint_index, 14 ) );
-
+ move16();
+ move16();
+ move16();
return saved_bits;
}
diff --git a/lib_enc/cod_ace_fx.c b/lib_enc/cod_ace_fx.c
index e11f068b60025545274b06dee47173f94398c4de..e701b8e466b946d9c4c6cbc739f4a77476e558ca 100644
--- a/lib_enc/cod_ace_fx.c
+++ b/lib_enc/cod_ace_fx.c
@@ -22,19 +22,19 @@
*-------------------------------------------------------------------*/
Word16 coder_acelp_fx( /* o : SEGSNR for CL decision */
- const Word16 A[], /* i : coefficients 4xAz[M+1] */
- const Word16 Aq[], /* i : coefficients 4xAz_q[M+1] */
- const Word16 speech[], /* i : speech[-M..lg] */
+ const Word16 A[], /* i : coefficients 4xAz[M+1] Qx*/
+ const Word16 Aq[], /* i : coefficients 4xAz_q[M+1] Q12*/
+ const Word16 speech[], /* i : speech[-M..lg] Qx*/
Word16 *prm, /* o : acelp parameters */
- Word16 stab_fac,
+ Word16 stab_fac, /*Q15 */
Encoder_State *st,
PLC_ENC_EVS_HANDLE hPlc_Ext,
const Word16 target_bits, /* i/o: coder memory state */
const Word16 Q_new,
const Word16 shift,
Word16 *pitch_buf, /* o : pitch values for each subfr.*/
- Word16 *voice_factors, /* o : voicing factors */
- Word16 *bwe_exc /* o : excitation for SWB TBE */
+ Word16 *voice_factors, /* o : voicing factors Q15 */
+ Word16 *bwe_exc /* o : excitation for SWB TBE Qx */
)
{
#ifndef SIMPLIFY_CODE_BE
@@ -73,13 +73,17 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision *
Word16 code2[L_SUBFR];
Word16 y22[L_SUBFR]; /* Filtered adaptive excitation */
Word16 error = 0;
- Word16 gain_preQ = 0; /* Gain of prequantizer excitation */
+ move16();
+ Word16 gain_preQ = 0; /* Gain of prequantizer excitation */
+ move16();
Word16 code_preQ[L_SUBFR]; /* Prequantizer excitation */
Word16 dummy = 0;
+ move16();
ACELP_config *acelp_cfg;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
acelp_cfg = &( st->acelp_cfg );
@@ -109,8 +113,9 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision *
move16();
move16();
move16();
+ move16();
L_frame = st->L_frame;
-
+ move16();
/*------------------------------------------------------------------------*
* Previous frame is TCX (for non-EVS modes)(deactivated permanently) *
@@ -126,11 +131,10 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision *
Q_new_p5 = add( Q_new, 5 );
/* Reset phase dispersion */
- IF( GT_16( st->last_core, ACELP_CORE ) )
+ IF( st->last_core > ACELP_CORE )
{
move16();
move16();
- move16();
hLPDmem->dm_fx.prev_gain_code = 0;
set16_fx( hLPDmem->dm_fx.prev_gain_pit, 0, 6 );
@@ -138,8 +142,6 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision *
}
/* set excitation memory*/
- move16();
- move16();
exc = exc_buf + L_EXC_MEM;
Copy( hLPDmem->old_exc, exc_buf, L_EXC_MEM );
*( exc + st->L_frame ) = 0;
@@ -193,8 +195,7 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision *
* - find synthesis speech *
* - update states of weighting filter *
*------------------------------------------------------------------------*/
- move16();
- move16();
+
p_A = A;
p_Aq = Aq;
@@ -231,7 +232,7 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision *
* or in case of floating point encoder & fixed p. decoder
*-----------------------------------------------------------------*/
- clip_gain = Mode2_gp_clip( st->voicing_fx, i_subfr, st->coder_type, xn, st->clip_var_fx, L_SUBFR, Q_xn );
+ clip_gain = Mode2_gp_clip_fx( st->voicing_fx, i_subfr, st->coder_type, xn, st->clip_var_fx, L_SUBFR, Q_xn );
/*-----------------------------------------------------------------*
* - find unity gain pitch excitation (adaptive codebook entry) *
@@ -292,7 +293,10 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision *
g_corr.xy2_e = sub( g_corr.xy2_e, add( Q_xn, 9 ) ); /* -(Q_xn+9) (xn: Q_xn y2: Q9) */
g_corr.y1y2_e = sub( g_corr.y1y2_e, add( Q_xn, 9 ) ); /* -(Q_xn+9) (y1: Q_xn y2: Q9) */
g_corr.xx_e = sub( g_corr.xx_e, add( Q_xn, Q_xn ) ); /* -(Q_xn+Q_xn) (xn: Q_xn) */
-
+ move16();
+ move16();
+ move16();
+ move16();
/*----------------------------------------------------------------------*
* Add Gaussian excitation *
@@ -334,6 +338,7 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision *
IF( st->Opt_RF_ON )
{
hRF->rf_tilt_buf[i_subfr / L_SUBFR] = hLPDmem->tilt_code;
+ move16();
}
/*-----------------------------------------------------------------*
* Update memory of the weighting filter
@@ -349,11 +354,8 @@ 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;
/*-------------------------------------------------------*
@@ -391,31 +393,14 @@ 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
/*-----------------------------------------------------------------*
@@ -454,8 +439,7 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision *
/*----------------------------------------------------------*
* Update *
*----------------------------------------------------------*/
- move16();
- move16();
+
p_A += ( M + 1 );
p_Aq += ( M + 1 );
@@ -499,7 +483,7 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision *
tmp = hLPDmem->syn[M];
E_UTIL_deemph2( sub( Q_new, 1 ), syn, st->preemph_fac, L_frame, &tmp );
- if ( st->hTcxEnc != NULL )
+ IF( st->hTcxEnc != NULL )
{
bufferCopyFx( syn + L_frame - ( L_frame / 2 ), hTcxEnc->Txnq, shr( L_frame, 1 ), 0 /*Qf_syn*/, -1 /*Qf_Txnq*/, 0 /*Q_syn*/, 0 /*Q_Txnq*/ );
}
@@ -511,6 +495,6 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision *
/*Update MODE1*/
Copy( p_Aq, st->old_Aq_12_8_fx, M + 1 );
st->old_Es_pred_fx = Es_pred;
-
+ move16();
return 0;
}
diff --git a/lib_enc/cod_tcx.c b/lib_enc/cod_tcx.c
index 72cfb8e96af4d2af62f59747899df8b8a13f6704..aaa7e4e2e13f01ee0207daa1bad4b3d412ba7824 100644
--- a/lib_enc/cod_tcx.c
+++ b/lib_enc/cod_tcx.c
@@ -55,9 +55,7 @@
*
*-------------------------------------------------------------------*/
-#define SIMILAR_TNS_THRESHOLD ( 0.04f )
#define SIMILAR_TNS_THRESHOLD_FX_IN_Q15 ( 1311 )
-#define TNS_GAIN_THRESHOLD_FOR_WHITE ( 3.0f )
#define TNS_GAIN_THRESHOLD_FOR_WHITE_FX_IN_Q7 ( 384 )
void TNSAnalysisStereo_fx(
Encoder_State **sts, /* i : encoder state handle */
@@ -132,7 +130,7 @@ void TNSAnalysisStereo_fx(
* Temporal Noise Shaping analysis *
*-----------------------------------------------------------*/
- IF( hTcxEnc->transform_type[k] == TCX_5 )
+ IF( EQ_16( hTcxEnc->transform_type[k], TCX_5 ) )
{
/* rearrange LF sub-window lines prior to TNS analysis & filtering */
tcx5TnsGrouping_fx( shr( L_frame, 2 ), shr( L_spec, 1 ), spectrum_fx );
@@ -141,12 +139,12 @@ void TNSAnalysisStereo_fx(
/* WMOPS: All initializations are either for safety or static (tables) and thus not to be counted */
ResetTnsData( &hTcxEnc->tnsData[k] );
- if ( st->hTcxCfg->pCurrentTnsConfig->maxOrder <= 0 )
+ IF( st->hTcxCfg->pCurrentTnsConfig->maxOrder <= 0 )
{
- break;
+ BREAK;
}
- CalculateTnsFilt_fx( st->hTcxCfg->pCurrentTnsConfig, spectrum_fx, &hTcxEnc->tnsData[k], NULL );
+ CalculateTnsFilt_fx( st->hTcxCfg->pCurrentTnsConfig, spectrum_fx, hTcxEnc->spectrum_e[k], &hTcxEnc->tnsData[k], NULL );
}
}
}
@@ -216,7 +214,7 @@ void TNSAnalysisStereo_fx(
sts[0]->hTcxCfg->pCurrentTnsConfig = &sts[0]->hTcxCfg->tnsConfig[sts[0]->hTcxEnc->transform_type[k] == TCX_20][( k == 0 ) && ( sts[0]->last_core == ACELP_CORE )];
sts[1]->hTcxCfg->pCurrentTnsConfig = &sts[1]->hTcxCfg->tnsConfig[sts[1]->hTcxEnc->transform_type[k] == TCX_20][( k == 0 ) && ( sts[1]->last_core == ACELP_CORE )];
- FOR( iFilter = sub( sts[0]->hTcxCfg->pCurrentTnsConfig->nMaxFilters, 1 ); iFilter >= 0; iFilter-- )
+ FOR( iFilter = sts[0]->hTcxCfg->pCurrentTnsConfig->nMaxFilters - 1; iFilter >= 0; iFilter-- )
{
STnsFilter *pFilter[2];
struct TnsParameters const *pTnsParameters[2];
@@ -229,8 +227,8 @@ void TNSAnalysisStereo_fx(
* both filters for the decision
*/
- meanPredictionGain_fx = mac_r( L_mult( pFilter[0]->predictionGain, 16384 ), pFilter[1]->predictionGain, 16384 ); // Q7
- maxPredictionGain_fx = s_max( maxPredictionGain_fx, meanPredictionGain_fx ); // Q7
+ meanPredictionGain_fx = mac_r( L_mult( pFilter[0]->predictionGain, 16384 /*0.5f Q15*/ ), pFilter[1]->predictionGain, 16384 /*0.5f Q15*/ ); // Q7
+ maxPredictionGain_fx = s_max( maxPredictionGain_fx, meanPredictionGain_fx ); // Q7
test();
test();
@@ -244,7 +242,7 @@ void TNSAnalysisStereo_fx(
}
test();
IF( LT_16( abs_s( sub( pFilter[0]->predictionGain, pFilter[1]->predictionGain ) ), mult( SIMILAR_TNS_THRESHOLD_FX_IN_Q15, meanPredictionGain_fx ) ) &&
- ( sts[0]->hTcxEnc->tnsData[k].nFilters == sts[1]->hTcxEnc->tnsData[k].nFilters ) )
+ ( EQ_16( sts[0]->hTcxEnc->tnsData[k].nFilters, sts[1]->hTcxEnc->tnsData[k].nFilters ) ) )
{
Word16 maxAvgSqrCoef_fx = s_max( pFilter[0]->avgSqrCoef, pFilter[1]->avgSqrCoef ); // Q15
@@ -259,7 +257,9 @@ void TNSAnalysisStereo_fx(
test();
IF( sts[0]->hTcxEnc->tnsData[k].nFilters > 0 || sts[1]->hTcxEnc->tnsData[k].nFilters > 0 || isTCX10 || LT_16( meanLtpGain_fx, 19660 /* 0.6 in Q15*/ ) )
{
- ++sts[0]->hTcxEnc->tnsData[k].nFilters;
+
+ sts[0]->hTcxEnc->tnsData[k].nFilters = add( sts[0]->hTcxEnc->tnsData[k].nFilters, 1 );
+ move16();
/* When order parameter is evaluated as 0 and change in precision causes the flow to reach here,
this may result in crash later. Changing the filter type here so the order is taken here in further section */
IF( pFilter[0]->order != 0 )
@@ -272,7 +272,8 @@ void TNSAnalysisStereo_fx(
pFilter[0]->filterType = TNS_FILTER_ON_ZERO;
move16();
}
- ++sts[1]->hTcxEnc->tnsData[k].nFilters;
+ sts[1]->hTcxEnc->tnsData[k].nFilters = add( sts[1]->hTcxEnc->tnsData[k].nFilters, 1 );
+ move16();
IF( pFilter[1]->order != 0 )
{
pFilter[1]->filterType = TNS_FILTER_ON;
@@ -291,7 +292,8 @@ void TNSAnalysisStereo_fx(
IF( GE_16( maxEnergyChange_fx, pTnsParameters[0]->minEnergyChange ) )
{
- ++sts[0]->hTcxEnc->tnsData[k].nFilters;
+ sts[0]->hTcxEnc->tnsData[k].nFilters = add( sts[0]->hTcxEnc->tnsData[k].nFilters, 1 );
+ move16();
/* When order parameter is evaluated as 0 and change in precision causes the flow to reach here,
this may result in crash later. Changing the filter type here so the order is taken here in further section */
IF( pFilter[0]->order != 0 )
@@ -304,7 +306,8 @@ void TNSAnalysisStereo_fx(
pFilter[0]->filterType = TNS_FILTER_ON_ZERO;
move16();
}
- ++sts[1]->hTcxEnc->tnsData[k].nFilters;
+ sts[1]->hTcxEnc->tnsData[k].nFilters = add( sts[1]->hTcxEnc->tnsData[k].nFilters, 1 );
+ move16();
IF( pFilter[1]->order != 0 )
{
pFilter[1]->filterType = TNS_FILTER_ON;
@@ -329,8 +332,12 @@ void TNSAnalysisStereo_fx(
{
pFilter[0]->filterType = TNS_FILTER_ON_ZERO;
pFilter[1]->filterType = TNS_FILTER_ON_ZERO;
- ++sts[0]->hTcxEnc->tnsData[k].nFilters;
- ++sts[1]->hTcxEnc->tnsData[k].nFilters;
+ move16();
+ move16();
+ sts[0]->hTcxEnc->tnsData[k].nFilters = add( sts[0]->hTcxEnc->tnsData[k].nFilters, 1 );
+ move16();
+ sts[1]->hTcxEnc->tnsData[k].nFilters = add( sts[1]->hTcxEnc->tnsData[k].nFilters, 1 );
+ move16();
}
ELSE IF( NE_16( sts[0]->hTcxEnc->tnsData[k].nFilters, sts[1]->hTcxEnc->tnsData[k].nFilters ) ) /* sanity check */
{
@@ -361,7 +368,7 @@ void TNSAnalysisStereo_fx(
IF( EQ_16( tmpIntValue, 1 ) ) /* the TNS coefficients are sufficiently similar to equalize the two filters */
{
- FOR( i = sub( maxOrder, 1 ); i >= 0; i-- )
+ FOR( i = maxOrder - 1; i >= 0; i-- )
{
IF( LT_16( abs_s( pFilter[0]->coefIndex[i] ), abs_s( pFilter[1]->coefIndex[i] ) ) )
{
@@ -438,7 +445,7 @@ void TNSAnalysisStereo_fx(
move16();
sts[1]->hTcxEnc->fUseTns[k] = 0;
move16();
- FOR( iFilter = sub( sts[0]->hTcxCfg->pCurrentTnsConfig->nMaxFilters, 1 ); iFilter >= 0; iFilter-- )
+ FOR( iFilter = sts[0]->hTcxCfg->pCurrentTnsConfig->nMaxFilters - 1; iFilter >= 0; iFilter-- )
{
sts[0]->hTcxEnc->tnsData[k].filter[iFilter].filterType = TNS_FILTER_OFF;
move16();
@@ -463,7 +470,7 @@ void TNSAnalysisStereo_fx(
move16();
sts[1]->hTcxEnc->fUseTns[k] = 0;
move16();
- FOR( iFilter = sub( sts[0]->hTcxCfg->pCurrentTnsConfig->nMaxFilters, 1 ); iFilter >= 0; iFilter-- )
+ FOR( iFilter = sts[0]->hTcxCfg->pCurrentTnsConfig->nMaxFilters - 1; iFilter >= 0; iFilter-- )
{
ClearTnsFilterCoefficients( sts[0]->hTcxEnc->tnsData[k].filter + iFilter );
ClearTnsFilterCoefficients( sts[1]->hTcxEnc->tnsData[k].filter + iFilter );
@@ -478,9 +485,9 @@ void TNSAnalysisStereo_fx(
/* individual decision for each channel */
FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
{
- if ( sts[ch]->mct_chan_mode == MCT_CHAN_MODE_IGNORE )
+ IF( EQ_32( sts[ch]->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) )
{
- continue;
+ CONTINUE;
}
Word8 isTCX10;
@@ -511,7 +518,7 @@ void TNSAnalysisStereo_fx(
move16();
sts[ch]->hTcxCfg->pCurrentTnsConfig = &sts[ch]->hTcxCfg->tnsConfig[sts[ch]->hTcxEnc->transform_type[k] == TCX_20][( k == 0 ) && ( sts[ch]->last_core == ACELP_CORE )];
- FOR( iFilter = sub( sts[ch]->hTcxCfg->pCurrentTnsConfig->nMaxFilters, 1 ); iFilter >= 0; iFilter-- )
+ FOR( iFilter = sts[ch]->hTcxCfg->pCurrentTnsConfig->nMaxFilters - 1; iFilter >= 0; iFilter-- )
{
STnsFilter *pFilter;
struct TnsParameters const *pTnsParameters;
@@ -524,9 +531,10 @@ void TNSAnalysisStereo_fx(
{
test();
test();
- IF( sts[ch]->hTcxEnc->tnsData[k].nFilters > 0 || isTCX10 || LT_16( sts[ch]->hTcxEnc->tcxltp_gain, 19660 ) )
+ IF( sts[ch]->hTcxEnc->tnsData[k].nFilters > 0 || isTCX10 || LT_16( sts[ch]->hTcxEnc->tcxltp_gain, 19660 /*.6f in Q15*/ ) )
{
- ++sts[ch]->hTcxEnc->tnsData[k].nFilters;
+ sts[ch]->hTcxEnc->tnsData[k].nFilters = add( sts[ch]->hTcxEnc->tnsData[k].nFilters, 1 );
+ move16();
/* When order parameter is evaluated as 0 and change in precision causes the flow to reach here,
this may result in crash later. Changing the filter type here so the order is taken here in further section */
IF( pFilter->order != 0 )
@@ -546,7 +554,8 @@ void TNSAnalysisStereo_fx(
IF( GE_16( maxEnergyChange_fx, pTnsParameters->minEnergyChange ) )
{
- ++sts[ch]->hTcxEnc->tnsData[k].nFilters;
+ sts[ch]->hTcxEnc->tnsData[k].nFilters = add( sts[ch]->hTcxEnc->tnsData[k].nFilters, 1 );
+ move16();
/* When order parameter is evaluated as 0 and change in precision causes the flow to reach here,
this may result in crash later. Changing the filter type here so the order is taken here in further section */
IF( pFilter->order != 0 )
@@ -571,7 +580,8 @@ void TNSAnalysisStereo_fx(
{
pFilter->filterType = TNS_FILTER_ON_ZERO;
move16();
- ++sts[ch]->hTcxEnc->tnsData[k].nFilters;
+ sts[ch]->hTcxEnc->tnsData[k].nFilters = add( sts[ch]->hTcxEnc->tnsData[k].nFilters, 1 );
+ move16();
}
ELSE
{
@@ -599,7 +609,7 @@ void TNSAnalysisStereo_fx(
move16();
sts[ch]->hTcxEnc->tnsData[k].nFilters = 0;
move16();
- FOR( iFilter = sub( sts[ch]->hTcxCfg->pCurrentTnsConfig->nMaxFilters, 1 ); iFilter >= 0; iFilter-- )
+ FOR( iFilter = sts[ch]->hTcxCfg->pCurrentTnsConfig->nMaxFilters - 1; iFilter >= 0; iFilter-- )
{
ClearTnsFilterCoefficients( sts[ch]->hTcxEnc->tnsData[k].filter + iFilter );
sts[ch]->hTcxEnc->tnsData[k].filter[iFilter].filterType = TNS_FILTER_OFF;
@@ -615,9 +625,9 @@ void TNSAnalysisStereo_fx(
/* we have the decision, set filter data accordingly */
FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
{
- if ( EQ_16( sts[ch]->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) )
+ IF( EQ_16( sts[ch]->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) )
{
- continue;
+ CONTINUE;
}
IF( EQ_16( sts[ch]->hTcxEnc->tcxMode, TCX_20 ) )
@@ -637,7 +647,7 @@ void TNSAnalysisStereo_fx(
{
sts[ch]->hTcxCfg->pCurrentTnsConfig = &sts[ch]->hTcxCfg->tnsConfig[sts[ch]->hTcxEnc->transform_type[k] == TCX_20][( k == 0 ) && ( sts[ch]->last_core == ACELP_CORE )];
- FOR( iFilter = sub( sts[ch]->hTcxCfg->pCurrentTnsConfig->nMaxFilters, 1 ); iFilter >= 0; iFilter-- )
+ FOR( iFilter = sts[ch]->hTcxCfg->pCurrentTnsConfig->nMaxFilters - 1; iFilter >= 0; iFilter-- )
{
STnsFilter *pFilter;
pFilter = sts[ch]->hTcxEnc->tnsData[k].filter + iFilter;
@@ -662,9 +672,9 @@ void TNSAnalysisStereo_fx(
FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
{
st = sts[ch];
- if ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE )
+ IF( EQ_32( st->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) )
{
- continue;
+ CONTINUE;
}
IF( EQ_16( st->hTcxEnc->tcxMode, TCX_20 ) )
@@ -683,6 +693,7 @@ void TNSAnalysisStereo_fx(
test();
test();
test();
+ test();
IF( bWhitenedDomain && ( ch > 0 ) && /* test for identical TNS filter data in both channels */
sts[0]->hTcxCfg->fIsTNSAllowed && sts[0]->hTcxEnc->fUseTns[k] &&
sts[1]->hTcxCfg->fIsTNSAllowed && sts[1]->hTcxEnc->fUseTns[k] )
@@ -701,7 +712,7 @@ void TNSAnalysisStereo_fx(
IF( equalFilterData )
{
- FOR( iFilter = sub( st->hTcxCfg->pCurrentTnsConfig->nMaxFilters, 1 ); iFilter >= 0; iFilter-- )
+ FOR( iFilter = st->hTcxCfg->pCurrentTnsConfig->nMaxFilters - 1; iFilter >= 0; iFilter-- )
{
const Word16 *pDataCh0 = (const Word16 *) &sts[0]->hTcxEnc->tnsData[k].filter[iFilter];
const Word16 *pDataCh1 = (const Word16 *) &sts[1]->hTcxEnc->tnsData[k].filter[iFilter];
@@ -711,18 +722,20 @@ void TNSAnalysisStereo_fx(
test();
WHILE( ( i >= 0 ) && EQ_16( pDataCh0[i], pDataCh1[i] ) )
{
+ test();
i = sub( i, 1 );
}
- if ( i >= 0 )
+ IF( i >= 0 )
{
equalFilterData = 0;
move16();
- break;
+ BREAK;
}
}
IF( equalFilterData )
{
st->hTcxEnc->tnsData[k].nFilters = i_mult( st->hTcxEnc->tnsData[k].nFilters, -1 ); /* signals common TNS */
+ move16();
}
}
}
@@ -747,7 +760,7 @@ void TNSAnalysisStereo_fx(
}
st->hTcxEnc->tnsData[k].tnsOnWhitenedSpectra = st->hTcxEnc->bTnsOnWhithenedSpectra[k];
-
+ move16();
EncodeTnsData_ivas_fx( st->hTcxCfg->pCurrentTnsConfig, &st->hTcxEnc->tnsData[k], param_core[ch] + k * NPRM_DIV + 1 + NOISE_FILL_RANGES + LTPSIZE, tnsSize[ch] + k, tnsBits[ch] + k );
}
diff --git a/lib_enc/cod_tcx_fx.c b/lib_enc/cod_tcx_fx.c
index 5bde2d5c01e9d7bb7a14e140dbef5d98dbd1a8a3..ebec48fa75eccf67034b2c7bae809728a32582b1 100644
--- a/lib_enc/cod_tcx_fx.c
+++ b/lib_enc/cod_tcx_fx.c
@@ -32,7 +32,7 @@ void HBAutocorrelation_fx(
TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */
Word16 left_overlap_mode, /* input: overlap mode of left window half */
Word16 right_overlap_mode, /* input: overlap mode of right window half */
- Word16 speech[], /* input: speech[-LFAC..L_frame+LFAC] */
+ Word16 speech[], /* input: speech[-LFAC..L_frame+LFAC] Qx*/
Word16 L_frame, /* input: frame length */
Word32 *r, /* output: autocorrelations vector */
Word16 m /* input : order of LP filter */
@@ -45,6 +45,7 @@ void HBAutocorrelation_fx(
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/*-----------------------------------------------------------*
@@ -64,70 +65,42 @@ void HBAutocorrelation_fx(
move16();
L_sum = L_deposit_l( 0 );
Overflow = 0;
- move16();
+ move32();
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;
- move16();
+ move32();
shift = 1;
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 = add( i, 1 ); j < len; j++ )
+ 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;
- move16();
+ 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 */
@@ -652,17 +625,19 @@ void TNSAnalysis_fx(
TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */
Word16 L_frame, /* input: frame length */
Word16 L_spec,
- Word16 tcxMode, /* input: TCX mode for the frame/subframe - TCX20 | TCX10 | TCX 5 (meaning 2 x TCX 5) */
- Word8 isAfterACELP, /* input: Flag indicating if the last frame was ACELP. For the second TCX subframe it should be 0 */
- Word32 spectrum[], /* input: MDCT spectrum */
- STnsData *pTnsData, /* output: Tns data */
- Word8 *pfUseTns, /* output: Flag indicating if TNS is used */
- Word16 *predictionGain )
+ Word16 tcxMode, /* input: TCX mode for the frame/subframe - TCX20 | TCX10 | TCX 5 (meaning 2 x TCX 5) */
+ Word8 isAfterACELP, /* input: Flag indicating if the last frame was ACELP. For the second TCX subframe it should be 0 */
+ Word32 spectrum[], /* input: MDCT spectrum Qx*/
+ STnsData *pTnsData, /* output: Tns data */
+ Word8 *pfUseTns, /* output: Flag indicating if TNS is used */
+ Word16 *predictionGain /*Q7*/
+)
{
Word32 buff[8];
Word16 tmp = 0; /* initialization only to avoid compiler warning, not counted */
Word16 tmp2 = 0; /* initialization only to avoid compiler warning, not counted */
-
+ move16();
+ move16();
/* Init TNS */
*pfUseTns = 0;
@@ -670,8 +645,7 @@ void TNSAnalysis_fx(
IF( hTcxCfg->fIsTNSAllowed != 0 )
{
- hTcxCfg->pCurrentTnsConfig = &hTcxCfg->tnsConfig[sub( tcxMode, TCX_20 ) == 0][isAfterACELP];
- test();
+ hTcxCfg->pCurrentTnsConfig = &hTcxCfg->tnsConfig[( tcxMode - TCX_20 ) == 0][isAfterACELP];
L_spec = hTcxCfg->pCurrentTnsConfig->iFilterBorders[0];
move16();
@@ -756,8 +730,7 @@ void TNSAnalysis_ivas_fx(
IF( hTcxCfg->fIsTNSAllowed != 0 )
{
- hTcxCfg->pCurrentTnsConfig = &hTcxCfg->tnsConfig[sub( transform_type, TCX_20 ) == 0][isAfterACELP];
- test();
+ hTcxCfg->pCurrentTnsConfig = &hTcxCfg->tnsConfig[( transform_type - TCX_20 ) == 0][isAfterACELP];
L_spec = hTcxCfg->pCurrentTnsConfig->iFilterBorders[0];
move16();
@@ -818,8 +791,8 @@ void TNSAnalysis_ivas_fx(
void ShapeSpectrum_fx(
TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */
- Word16 A[], /* input: quantized coefficients NxAz_q[M+1] */
- Word16 gainlpc[], /* output: MDCT gains for the previous frame */
+ Word16 A[], /* input: quantized coefficients NxAz_q[M+1] Q = 14 - norm(A[0])*/
+ Word16 gainlpc[], /* output: MDCT gains for the previous frame Q(15-gainlpc_e)*/
Word16 gainlpc_e[], /* output: MDCT gains exponents */
Word16 L_frame_glob, /* input: frame length */
Word16 L_spec,
@@ -834,6 +807,8 @@ void ShapeSpectrum_fx(
Word16 gainlpc_noinv_e[FDNS_NPTS];
Word16 i;
Word32 max_low_pre = 0, max_high_pre = 0;
+ move32();
+ move32();
TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc;
/*-----------------------------------------------------------*
@@ -875,6 +850,7 @@ void ShapeSpectrum_fx(
IF( st->enablePlcWaveadjust )
{
hTcxCfg->SFM2 = SFM_Cal_fx( spectrum, s_min( 200, L_frame ) );
+ move32();
}
test();
@@ -897,7 +873,7 @@ void ShapeSpectrum_fx(
max_high_pre = 0;
move32();
- for ( i = 0; i < L_spec - L_frame; i++ )
+ FOR( i = 0; i < L_spec - L_frame; i++ )
{
Word32 tmp = L_abs( spectrum[L_frame + i] );
if ( GT_32( tmp, max_high_pre ) )
@@ -925,6 +901,8 @@ void ShapeSpectrum_fx(
/* reduce the peaks in the IGF region, to make life of the core-coder easier... */
test();
+ test();
+ test();
IF( ( EQ_32( st->total_brate, ACELP_9k60 ) && EQ_16( st->bwidth, SWB ) ) ||
( EQ_32( st->total_brate, ACELP_13k20 ) && EQ_16( st->bwidth, SWB ) ) )
{
@@ -967,7 +945,7 @@ void ShapeSpectrum_fx(
max_low1 = 0;
move32();
- FOR( i = 0; i < sub( L_frame, sf_width ); i++ )
+ FOR( i = 0; i < ( L_frame - sf_width ); i++ )
{
Word32 tmp = L_abs( spectrum[L_frame - sf_width - 1 - i] );
if ( GT_32( tmp, max_low1 ) )
@@ -975,7 +953,7 @@ void ShapeSpectrum_fx(
max_low1 = tmp;
move32();
}
- if ( tmp > max_low2 )
+ if ( GT_32( tmp, max_low2 ) )
{
dist_low = add( sf_width, i );
}
@@ -987,10 +965,10 @@ void ShapeSpectrum_fx(
move32();
dist_high = 0;
move16();
- FOR( i = 0; i < sub( L_spec, L_frame ); i++ )
+ FOR( i = 0; i < ( L_spec - L_frame ); i++ )
{
Word32 tmp = L_abs( spectrum[L_frame + i] );
- if ( GT_32( tmp, max_high ) )
+ IF( GT_32( tmp, max_high ) )
{
max_high = tmp;
move32();
@@ -1036,6 +1014,7 @@ void ShapeSpectrum_fx(
FOR( i = 0; i < sub( L_spec, L_frame ); i++ )
{
spectrum[L_frame + i] = Mpy_32_16_1( spectrum[L_frame + i], fac );
+ move32();
}
}
}
@@ -1052,11 +1031,11 @@ void ShapeSpectrum_fx(
void ShapeSpectrum_ivas_fx(
TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */
Word16 A[], /* input: quantized coefficients NxAz_q[M+1], Q = 14 - norm(A[0]) */
- Word16 gainlpc[], /* output: MDCT gains for the previous frame */
+ Word16 gainlpc[], /* output: MDCT gains for the previous frame Q(15-gainlpc_e)*/
Word16 gainlpc_e[], /* output: MDCT gains exponents */
Word16 L_frame_glob, /* input: frame length */
Word16 L_spec,
- Word32 spectrum[], /* i/o: MDCT spectrum */
+ Word32 spectrum[], /* i/o: MDCT spectrum Q(31-spectrum_e) */
Word16 *spectrum_e, /* i/o: MDCT spectrum exponent */
Word8 pfUseTns, /* output: Flag indicating if TNS is used */
Encoder_State *st,
@@ -1075,6 +1054,13 @@ void ShapeSpectrum_ivas_fx(
TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc;
move32();
move32();
+ Word32 total_brate = st->total_brate;
+ move32();
+ if ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) )
+ {
+ total_brate = st->element_brate;
+ move32();
+ }
/*-----------------------------------------------------------*
* Init *
@@ -1098,7 +1084,7 @@ void ShapeSpectrum_ivas_fx(
{
L_frame = add( L_frame, hTcxCfg->tcx_offset );
L_spec = add( L_spec, shr( hTcxCfg->tcx_coded_lines, 2 ) );
- IF( hTcxCfg->lfacNext < 0 )
+ if ( hTcxCfg->lfacNext < 0 )
{
L_frame = sub( L_frame, hTcxCfg->lfacNext );
move16();
@@ -1110,7 +1096,7 @@ void ShapeSpectrum_ivas_fx(
tcxGetNoiseFillingTilt( A,
M,
L_frame,
- ( GE_32( st->total_brate, ACELP_13k20 ) && st->rf_mode == 0 ),
+ ( GE_32( total_brate, ACELP_13k20 ) && st->rf_mode == 0 ),
&hTcxEnc->noiseTiltFactor );
/* Calculate Spectrum Flatness Measure for the TCX Concealment */
@@ -1121,7 +1107,7 @@ void ShapeSpectrum_ivas_fx(
}
test();
- IF( LE_32( st->total_brate, ACELP_13k20 ) && EQ_16( st->bwidth, SWB ) )
+ IF( LE_32( total_brate, ACELP_13k20 ) && EQ_16( st->bwidth, SWB ) )
{
max_low_pre = 0;
move32();
@@ -1160,19 +1146,18 @@ void ShapeSpectrum_ivas_fx(
test();
IF( NE_16( len, L_spec ) && LT_16( add( q_spectrum, 1 ), sub( 31, *spectrum_e ) ) )
{
- scale_sig32( spectrum + len, sub( L_spec, len ), sub( add( q_spectrum, 1 ), sub( 31, *spectrum_e ) ) );
+ scale_sig32( spectrum + len, sub( L_spec, len ), sub( add( q_spectrum, 1 ), sub( 31, *spectrum_e ) ) ); // Q31
}
ELSE IF( NE_16( len, L_spec ) && GT_16( add( q_spectrum, 1 ), sub( 31, *spectrum_e ) ) )
{
- scale_sig32( spectrum, len, sub( sub( 31, *spectrum_e ), add( q_spectrum, 1 ) ) );
+ scale_sig32( spectrum, len, sub( sub( 31, *spectrum_e ), add( q_spectrum, 1 ) ) ); // Q(30-specturm_e)
q_spectrum = sub( 31 - 1, *spectrum_e );
}
FOR( i = L_frame; i < L_spec; i++ )
{
W_tmp = W_mult0_32_32( spectrum[i], sns_int_scf[hTcxCfg->psychParamsCurrent->nBands - 1] );
- W_tmp = W_shr( W_tmp, Q16 );
- spectrum[i] = W_extract_l( W_tmp );
+ spectrum[i] = W_extract_h( W_shl( W_tmp, Q16 ) );
move32();
}
*spectrum_e = sub( 31 - 1, q_spectrum ); // As the output spectrum from sns_shape_spectrum_fx has Q = q_spectrum + 1
@@ -1198,7 +1183,7 @@ void ShapeSpectrum_ivas_fx(
/* reduce the peaks in the IGF region, to make life of the core-coder easier... */
test();
- IF( LE_32( st->total_brate, ACELP_13k20 ) && EQ_16( st->bwidth, SWB ) )
+ IF( LE_32( total_brate, ACELP_13k20 ) && EQ_16( st->bwidth, SWB ) )
{
Word16 sf_width;
Word16 dist_low, dist_high;
@@ -1247,7 +1232,7 @@ void ShapeSpectrum_ivas_fx(
max_low1 = tmp;
move32();
}
- IF( GT_32( tmp, max_low2 ) )
+ if ( GT_32( tmp, max_low2 ) )
{
dist_low = add( sf_width, i );
}
@@ -1259,10 +1244,10 @@ void ShapeSpectrum_ivas_fx(
move32();
dist_high = 0;
move16();
- FOR( i = 0; i < sub( L_spec, L_frame ); i++ )
+ FOR( i = 0; i < ( L_spec - L_frame ); i++ )
{
Word32 tmp = L_abs( spectrum[L_frame + i] );
- if ( GT_32( tmp, max_high ) )
+ IF( GT_32( tmp, max_high ) )
{
max_high = tmp;
move32();
@@ -1526,15 +1511,15 @@ static Word16 GetTransWidth_ivas_fx(
static void EstimateTCXNoiseLevel_ivas_fx(
Encoder_State *st, /* i : encoder state handle */
- Word32 x_orig[], /* i : shaped MDCT spectrum */
+ Word32 x_orig[], /* i : shaped MDCT spectrum Q(31-x_orig_e) */
Word16 x_orig_e, /* i : shaped MDCT spectrum exponent */
Word32 spectrum[], /* i/o: quantized MDCT spectrum */
- const Word16 gain_tcx, /* i : global gain */
+ const Word16 gain_tcx, /* i : global gain Q(15-gain_tcx_e) */
const Word16 gain_tcx_e, /* i : global gain exponent */
const Word16 L_frame, /* i : frame length */
const Word16 noiseFillingBorder, /* i : noise filling border */
const Word16 hm_active, /* i : flag indicating if the harmonic model is active */
- Word16 *fac_ns, /* o : noise filling level, Q15 */
+ Word16 *fac_ns, /* o : noise filling level, fac_ns_q */
Word16 *fac_ns_q /* o : quantized noise filling level, Q0 */
)
{
@@ -1628,7 +1613,7 @@ void QuantizeSpectrum_ivas_fx(
Encoder_State *st, /* i/o: encoder state structure */
const Word16 A_fx[], /* i : quantized coefficients NxAz_q[M+1], Q = 14 - norm_s(A_fx[0]) */
const Word16 Aqind[], /* i : frame-independent quantized coefficients (M+1) */
- Word16 gainlpc_fx[], /* i : MDCT gains of the previous frame */
+ Word16 gainlpc_fx[], /* i : MDCT gains of the previous frame Q(15-gainlpc_e) */
Word16 gainlpc_e[], /* i : exponents of MDCT gains of the previous frame */
Word16 synth[], /* o : synthesis buffer, Q0 */
const Word16 nb_bits, /* i : bit budget */
@@ -1665,6 +1650,12 @@ void QuantizeSpectrum_ivas_fx(
QuantizeTCXSpectrum_fx( st, frame_cnt, hTcxEnc->spectrum_fx[frame_cnt], hTcxEnc->spectrum_e[frame_cnt], gainlpc_fx, gainlpc_e, Aqind, tnsSize, nb_bits, vad_hover_flag,
&L_frameTCX, &L_frame, &L_spec, &tcx_offset, &noiseFillingBorder, quantized_spectrum_fx, &quantized_spectrum_e, hm_cfg, &hm_active, lf_deemph_fact_fx, &nf_seed, &ener_fx, &ener_e, &gain_tcx_fx, &gain_tcx_e, prm );
+ if ( hTcxEnc->spectrum_e[frame_cnt] < 0 )
+ {
+ /*buffer is already scaled inside QuantizeTCXSpectrum_fx*/
+ hTcxEnc->spectrum_e[frame_cnt] = 0;
+ move16();
+ }
Word16 s1 = sub( getScaleFactor32( st->hTcxEnc->spectrum_fx[frame_cnt], L_frame ), 6 );
Word16 s2 = getScaleFactor32( quantized_spectrum_fx, s_max( L_frame, L_spec ) );
@@ -1707,8 +1698,8 @@ void QuantizeSpectrum_ivas_fx(
void EstimateStereoTCXNoiseLevel_fx(
Encoder_State **sts, /* i : state handle */
- Word32 *q_spectrum[CPE_CHANNELS][NB_DIV], /* i : quantized MDCT spectrum */
- Word16 gain_tcx[][NB_DIV], /* i : global gain */
+ Word32 *q_spectrum[CPE_CHANNELS][NB_DIV], /* i : quantized MDCT spectrum Qx */
+ Word16 gain_tcx[][NB_DIV], /* i : global gain Q(15-gain_tcx_e) */
Word16 gain_tcx_e[][NB_DIV], /* i : global gain exponent */
Word16 L_frame[][NB_DIV], /* i : frame length */
Word16 noiseFillingBorder[][NB_DIV], /* i : noise filling border */
@@ -1742,9 +1733,9 @@ void EstimateStereoTCXNoiseLevel_fx(
move16();
}
- if ( ignore_chan[ch] )
+ IF( ignore_chan[ch] )
{
- continue;
+ CONTINUE;
}
IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && !MCT_flag )
@@ -1811,8 +1802,8 @@ void EstimateStereoTCXNoiseLevel_fx(
test();
IF( L_tmp != 0 || L_tmp1 != 0 )
{
- scale_sig32( hTcxEnc->spectrum_fx[n], L_frame[ch][n], -Q1 );
- scale_sig32( combined_q_spectrum, L_frame[ch][n], -Q1 );
+ scale_sig32( hTcxEnc->spectrum_fx[n], L_frame[ch][n], -Q1 ); // Q(31-(spectrum_e+1)
+ scale_sig32( combined_q_spectrum, L_frame[ch][n], -Q1 ); // Q(31-(spectrum_e+1)
hTcxEnc->spectrum_e[n] = add( hTcxEnc->spectrum_e[n], Q1 );
move16();
}
@@ -1842,6 +1833,7 @@ void EstimateStereoTCXNoiseLevel_fx(
ELSE
{
hTcxEnc->noiseLevelMemory_cnt = sub( -1, hTcxEnc->noiseLevelMemory_cnt );
+ move16();
}
}
ELSE
@@ -1861,7 +1853,7 @@ void QuantizeSpectrum_fx(
TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */
Word16 A[], /* input: quantized coefficients NxAz_q[M+1] */
Word16 Aqind[], /* input: frame-independent quantized coefficients (M+1) */
- Word16 gainlpc[], /* input: MDCT gains of the previous frame */
+ Word16 gainlpc[], /* input: MDCT gains of the previous frame Q(15-gainlpc_e)*/
Word16 gainlpc_e[], /* input: MDCT gains exponents */
Word16 synth[],
Word16 L_frame_glob, /* input: frame length */
@@ -1869,7 +1861,7 @@ void QuantizeSpectrum_fx(
Word16 L_spec,
Word16 nb_bits, /*input: bit budget*/
Word8 tcxonly, /*input: only TCX flag*/
- Word32 spectrum[], /* i/o: MDCT spectrum, input is shaped MDCT spectrum */
+ Word32 spectrum[], /* i/o: MDCT spectrum, input is shaped MDCT spectrum Q(31-spectrum_e) */
Word16 *spectrum_e, /* i/o: MDCT spectrum exponent */
STnsData *pTnsData, /* input: Tns data */
Word8 fUseTns, /* input: Flag indicating if TNS is used */
@@ -2087,6 +2079,7 @@ void QuantizeSpectrum_fx(
FOR( i = st->hIGFEnc->infoStopLine; i < L_frameTCX; i++ )
{
spectrum[i] = L_deposit_l( 0 );
+ move32();
}
/*-----------------------------------------------------------*
@@ -2292,11 +2285,8 @@ 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
if ( GT_16( hTcxEnc->tcx_target_bits_fac, 0x5000 ) )
@@ -2415,11 +2405,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 )
{
@@ -2433,11 +2419,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
@@ -2490,11 +2472,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();
@@ -2529,7 +2507,7 @@ void QuantizeSpectrum_fx(
tmp8 = 1;
move16();
- if ( EQ_16( st->last_core, ACELP_CORE ) )
+ if ( st->last_core == ACELP_CORE )
{
tmp8 = 0;
move16();
@@ -2598,7 +2576,7 @@ void QuantizeSpectrum_fx(
/*-----------------------------------------------------------*
* Quantize TCX gain *
*-----------------------------------------------------------*/
-
+ test();
IF( GE_32( st->total_brate, ACELP_13k20 ) && st->rf_mode == 0 )
{
QuantizeGain( L_spec, &gain_tcx, &gain_tcx_e, &prm[0] );
@@ -2695,6 +2673,7 @@ void QuantizeSpectrum_fx(
{
/* noise filling start bin */
i = shr( L_frame, 3 );
+ test();
IF( GE_32( st->total_brate, ACELP_13k20 ) && st->rf_mode == 0 )
{
i = idiv1616U( L_frame, 6 );
@@ -2736,6 +2715,7 @@ void QuantizeSpectrum_fx(
IF( EQ_16( prm[NOISE_FILL_RANGES], 1 ) )
{
hTcxEnc->noiseLevelMemory_cnt = add( 1, abs_s( hTcxEnc->noiseLevelMemory_cnt ) ); /* update counter */
+ move16();
}
ELSE
{
@@ -2756,6 +2736,7 @@ void QuantizeSpectrum_fx(
tmp1 = sub( -1, hTcxEnc->noiseLevelMemory_cnt );
}
hTcxEnc->noiseLevelMemory_cnt = tmp1;
+ move16();
}
ELSE
{
@@ -2790,6 +2771,7 @@ void QuantizeSpectrum_fx(
* Noise Filling. *
*-----------------------------------------------------------*/
+ test();
/* Replication of ACELP formant enhancement for low rates */
IF( LT_32( st->total_brate, ACELP_13k20 ) || st->rf_mode != 0 )
{
@@ -2800,6 +2782,7 @@ void QuantizeSpectrum_fx(
{
tmp1 = 0;
move16();
+ test();
if ( GE_32( st->total_brate, ACELP_13k20 ) && st->rf_mode == 0 )
{
tmp1 = 1;
@@ -2814,7 +2797,7 @@ void QuantizeSpectrum_fx(
tcx_noise_filling( spectrum, *spectrum_e, nf_seed /* seed */, i, noiseFillingSize, noiseTransWidth, L_frame, hTcxEnc->noiseTiltFactor, fac_ns, NULL, st->element_mode );
}
-
+ test();
IF( LT_32( st->total_brate, ACELP_13k20 ) || st->rf_mode != 0 )
{
/* partially recompute global gain (energy part), taking noise filling and formant enhancement into account */
@@ -2849,14 +2832,14 @@ void QuantizeSpectrum_fx(
/*-----------------------------------------------------------*
* Apply gain *
*-----------------------------------------------------------*/
- IF( EQ_16( st->hTcxCfg->coder_type, INACTIVE ) )
+ IF( st->hTcxCfg->coder_type == INACTIVE )
{
gain_tcx = mult_r( gain_tcx, hTcxCfg->na_scale );
}
FOR( i = 0; i < L_spec; i++ )
{
- spectrum[i] = Mpy_32_16_1( spectrum[i], gain_tcx );
+ spectrum[i] = Mpy_32_16_1( spectrum[i], gain_tcx ); // Q(31-(spectrum_e+gain_tcx_e))
move32();
}
*spectrum_e = add( *spectrum_e, gain_tcx_e );
@@ -2896,8 +2879,6 @@ void QuantizeSpectrum_fx(
IF( hTcxCfg->fIsTNSAllowed != 0 )
{
- test();
- test();
test();
SetTnsConfig( hTcxCfg, sub( L_frame_glob, st->L_frame ) == 0, ( st->last_core == ACELP_CORE ) && ( frame_cnt == 0 ) );
@@ -2931,7 +2912,7 @@ void QuantizeSpectrum_fx(
s = getScaleFactor32( spectrum, L_frame );
FOR( i = 0; i < L_frame; i++ )
{
- spectrum[i] = L_shl( spectrum[i], s );
+ spectrum[i] = L_shl( spectrum[i], s ); // Q(31-(spectrum_e-s))
move32();
}
*spectrum_e = sub( *spectrum_e, s );
@@ -3047,11 +3028,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 */
@@ -3115,7 +3092,6 @@ void QuantizeSpectrum_fx(
0 );
- move16();
tmpP16 = xn_buf16 + add( sub( L_win, shr( L_ola, 1 ) ), shr( overlap, 1 ) );
tcx_windowing_synthesis_past_frame( tmpP16,
@@ -3130,11 +3106,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();
}
@@ -3144,7 +3116,7 @@ void QuantizeSpectrum_fx(
L_win );
/* extra folding-out on left side of win, for perfect reconstruction */
- FOR( w = shr( overlap, 1 ); w < overlap; w++ )
+ FOR( w = overlap / 2; w < overlap; w++ )
{
xn_buf16[overlap - 1 - w] = negate( xn_buf16[w] );
move16();
@@ -3260,11 +3232,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();
}
@@ -3324,11 +3292,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();
}
@@ -3337,31 +3301,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();
}
}
@@ -3391,11 +3343,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();
}
@@ -3403,11 +3351,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();
}
}
@@ -3421,11 +3365,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;
@@ -3546,9 +3486,9 @@ static Word16 DecideTonalSideInfo_fx(
void QuantizeTCXSpectrum_fx(
Encoder_State *st, /* i : state handle */
const Word16 frame_cnt, /* i : frame counter in the super_frame Q0 */
- Word32 *x_orig_fx, /* i : shaped MDCT spectrum */
- const Word16 x_orig_e, /* i : exp of shaped MDCT spectrum */
- Word16 *gainlpc_fx, /* i : FDNS gains */
+ Word32 *x_orig_fx, /* i : shaped MDCT spectrum Q(31-x_orig_e)*/
+ Word16 x_orig_e, /* i : exp of shaped MDCT spectrum */
+ Word16 *gainlpc_fx, /* i : FDNS gains Q(15-gainlpc_e)*/
Word16 *gainlpc_e, /* i : exp of FDNS gains */
const Word16 *Aqind, /* i : frame-independent quantized coefficients (M+1) Q0 */
const Word16 tnsSize, /* i : number of tns parameters put into prm Q0 */
@@ -3559,15 +3499,15 @@ void QuantizeTCXSpectrum_fx(
Word16 *pL_spec, /* o : length of the coded spectrum Q0 */
Word16 *ptcx_offset, /* o : folding point offset relative to the end of the previous frame Q0 */
Word16 *pnoiseFillingBorder, /* o : noise filling border Q0 */
- Word32 spectrum_fx[], /* o : quantized MDCT spectrum */
+ Word32 spectrum_fx[], /* o : quantized MDCT spectrum Q(31-spectrum_e)*/
Word16 *spectrum_e, /* o : exp of quantized MDCT spectrum */
CONTEXT_HM_CONFIG *hm_cfg, /* o : Context-based harmonic model configuration */
Word16 *hm_active, /* o : flag indicating if the harmonic model is active */
Word16 lf_deemph_fact_fx[], /* o : low frequency deemphasis factors Q14*/
Word16 *nf_seed, /* o : noise filling random seed Q0*/
- Word32 *ener_fx, /* o : energy of the quantized spectrum */
+ Word32 *ener_fx, /* o : energy of the quantized spectrum Q(31-ener_e) */
Word16 *ener_e, /* o : exp of energy of the quantized spectrum */
- Word16 *gain_tcx_fx, /* o : global gain */
+ Word16 *gain_tcx_fx, /* o : global gain Q(15-gain_tcx_e) */
Word16 *gain_tcx_e, /* o : exp of global gain */
Word16 prm[] /* o : tcx parameters Q0 */
)
@@ -3692,6 +3632,7 @@ void QuantizeTCXSpectrum_fx(
IF( EQ_16( st->core, TCX_20_CORE ) )
{
L_frame_glob = st->L_frame;
+ move16();
}
ELSE
{
@@ -3702,6 +3643,15 @@ void QuantizeTCXSpectrum_fx(
}
/* Start with the pre-shaped spectrum*/
+
+ /*scaling buffer to Q31 if exp < 0 to avoid overflow while scaling constants*/
+ IF( x_orig_e < 0 )
+ {
+ scale_sig32( x_orig_fx, L_spec, x_orig_e );
+ x_orig_e = 0;
+ move16();
+ }
+
Copy32( x_orig_fx, spectrum_fx, L_spec );
*spectrum_e = x_orig_e;
move16();
@@ -3793,7 +3743,7 @@ void QuantizeTCXSpectrum_fx(
}
/* Quantize original spectrum */
- sqGain_fx = SQ_gain_fx( spectrum_fx, *spectrum_e, shl( mult( hTcxEnc->tcx_target_bits_fac, sqTargetBits ), 1 ), L_spec, &sqGain_e );
+ sqGain_fx = SQ_gain_ivas_fx( spectrum_fx, *spectrum_e, shl( mult( hTcxEnc->tcx_target_bits_fac, sqTargetBits ), 1 ), L_spec, &sqGain_e );
tcx_scalar_quantization_ivas_fx( spectrum_fx, *spectrum_e, sqQ, L_spec, sqGain_fx, sqGain_e, st->hTcxCfg->sq_rounding, hTcxEnc->memQuantZeros, st->tcxonly );
@@ -3802,7 +3752,7 @@ void QuantizeTCXSpectrum_fx(
move16();
IF( st->element_mode > EVS_MONO )
{
- sqBits = RCcontextMapping_encode2_estimate_no_mem_s17_LCS( sqQ, L_spec, &lastnz, &nEncoded, sqTargetBits, &stop, 0, NULL );
+ sqBits = RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( sqQ, L_spec, &lastnz, &nEncoded, sqTargetBits, &stop, 0, NULL );
}
ELSE
{
@@ -3816,7 +3766,7 @@ void QuantizeTCXSpectrum_fx(
/* Context Mapping */
IF( st->element_mode > EVS_MONO )
{
- sqBitsCtxHm = RCcontextMapping_encode2_estimate_no_mem_s17_LCS( sqQ, L_spec, &lastnzCtxHm, &nEncodedCtxHm, sqTargetBits - NumIndexBits, &stopCtxHm, 0, hm_cfg );
+ sqBitsCtxHm = RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( sqQ, L_spec, &lastnzCtxHm, &nEncodedCtxHm, sqTargetBits - NumIndexBits, &stopCtxHm, 0, hm_cfg );
}
ELSE
{
@@ -3881,7 +3831,7 @@ void QuantizeTCXSpectrum_fx(
}
ELSE
{
- sqGain_fx = SQ_gain_fx( spectrum_fx, *spectrum_e, shl( mult( hTcxEnc->tcx_target_bits_fac, sqTargetBits ), 1 ), L_spec, &sqGain_e );
+ sqGain_fx = SQ_gain_ivas_fx( spectrum_fx, *spectrum_e, shl( mult( hTcxEnc->tcx_target_bits_fac, sqTargetBits ), 1 ), L_spec, &sqGain_e );
}
/* Quantize spectrum */
tcx_scalar_quantization_ivas_fx( spectrum_fx, *spectrum_e, sqQ, L_spec, sqGain_fx, sqGain_e, st->hTcxCfg->sq_rounding, hTcxEnc->memQuantZeros, st->tcxonly );
@@ -3892,7 +3842,7 @@ void QuantizeTCXSpectrum_fx(
IF( st->element_mode > EVS_MONO )
{
- sqBits_noStop = sqBits = RCcontextMapping_encode2_estimate_no_mem_s17_LCS( sqQ, L_spec, prm_lastnz, &nEncoded, sqTargetBits, &stop, 0, NULL );
+ sqBits_noStop = sqBits = RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( sqQ, L_spec, prm_lastnz, &nEncoded, sqTargetBits, &stop, 0, NULL );
move16();
}
ELSE
@@ -3919,19 +3869,15 @@ 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 ) )
+ if ( GT_16( hTcxEnc->tcx_target_bits_fac, 20480 /*1.25 in Q14*/ ) )
{
hTcxEnc->tcx_target_bits_fac = 20480;
move16();
}
- if ( LT_16( hTcxEnc->tcx_target_bits_fac, 12288 ) )
+ if ( LT_16( hTcxEnc->tcx_target_bits_fac, 12288 /*.75 in Q14*/ ) )
{
hTcxEnc->tcx_target_bits_fac = 12288;
move16();
@@ -3981,7 +3927,7 @@ void QuantizeTCXSpectrum_fx(
IF( st->element_mode > EVS_MONO )
{
/* Fix: Use updated value for target bits (sqTargetBits + NumIndexBits) before computing non-mapped estimate */
- sqBitsCtxHm = RCcontextMapping_encode2_estimate_no_mem_s17_LCS( sqQ, L_spec, &lastnz, &nEncodedCtxHm, sqTargetBits + NumIndexBits, &stopCtxHm, 0, NULL );
+ sqBitsCtxHm = RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( sqQ, L_spec, &lastnz, &nEncodedCtxHm, sqTargetBits + NumIndexBits, &stopCtxHm, 0, NULL );
}
ELSE
{
@@ -4056,7 +4002,7 @@ void QuantizeTCXSpectrum_fx(
move16();
IF( st->element_mode > EVS_MONO )
{
- sqBitsCtxHm = RCcontextMapping_encode2_estimate_no_mem_s17_LCS( sqQ, L_spec, &lastnzCtxHm, &nEncodedCtxHm, sqTargetBits - NumIndexBits, &stopCtxHm, 0, hm_cfg );
+ sqBitsCtxHm = RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( sqQ, L_spec, &lastnzCtxHm, &nEncodedCtxHm, sqTargetBits - NumIndexBits, &stopCtxHm, 0, hm_cfg );
}
ELSE
{
@@ -4170,7 +4116,7 @@ void QuantizeTCXSpectrum_fx(
sqTargetBits = add( sqTargetBits, NumIndexBits );
ctxHmBits = sub( ctxHmBits, NumIndexBits );
}
- sqBits = RCcontextMapping_encode2_estimate_no_mem_s17_LCS( sqQ, L_spec, prm_lastnz, &nEncoded, sqTargetBits, &stop, 0, NULL );
+ sqBits = RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( sqQ, L_spec, prm_lastnz, &nEncoded, sqTargetBits, &stop, 0, NULL );
}
ELSE
{
@@ -4194,8 +4140,10 @@ void QuantizeTCXSpectrum_fx(
FOR( i = 0; i < L_spec; i++ )
{
spectrum_fx[i] = (Word32) sqQ[i];
+ move32();
/* noise filling seed */
*nf_seed = (Word16) L_add( *nf_seed, L_mult0( abs_s( sqQ[i] ), shl( i, 1 ) ) );
+ move16();
}
tmp32 = L_deposit_l( 0 );
@@ -4204,11 +4152,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();
@@ -4300,6 +4244,7 @@ void QuantizeTCXSpectrum_fx(
{
calculate_hangover_attenuation_gain_ivas_fx( st, &att_fx, vad_hover_flag );
*gain_tcx_fx = mult( *gain_tcx_fx, att_fx );
+ move16();
}
/*-----------------------------------------------------------*
@@ -4383,13 +4328,13 @@ void coder_tcx_fx(
TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */
Word16 A[], /* input: quantized coefficients NxAz_q[M+1] */
Word16 Aqind[], /* input: frame-independent quantized coefficients (M+1) */
- Word16 synth[],
- Word16 L_frame_glob, /* input: frame length */
+ Word16 synth[], /*Qx*/
+ Word16 L_frame_glob, /* input: frame length */
Word16 L_frameTCX_glob,
Word16 L_spec,
Word16 nb_bits, /*input: bit budget*/
Word8 tcxonly, /*input: only TCX flag*/
- Word32 spectrum[], /* i/o: MDCT spectrum */
+ Word32 spectrum[], /* i/o: MDCT spectrum Q(31-spectrum_e)*/
Word16 *spectrum_e, /* i/o: MDCT spectrum exponent */
Word16 prm[], /* output: tcx parameters */
Encoder_State *st,
@@ -4485,6 +4430,7 @@ void coder_tcx_fx(
/* DCT */
edct_fx( tmp_buf, spectrum, L_frame, &Q );
*spectrum_e = sub( 31, Q );
+ move16();
}
@@ -4523,8 +4469,7 @@ void coder_tcx_fx(
powerSpec, &powerSpec_e );
IF( hTcxCfg->fIsTNSAllowed != 0 )
{
- test();
- test();
+
SetTnsConfig( hTcxCfg, sub( L_frame_glob, st->L_frame ) == 0, st->last_core == 0 );
TNSAnalysis_fx( hTcxCfg, L_frame, L_spec, TCX_20, st->last_core == 0, spectrum, hTcxEnc->tnsData, hTcxEnc->fUseTns, &st->hIGFEnc->tns_predictionGain );
@@ -4577,6 +4522,7 @@ void coder_tcx_fx(
#ifndef MSAN_FIX
hLPDmem->nbits = add( hLPDmem->nbits, add( tnsBits, ltpBits ) );
+ move16();
#endif
}
@@ -4655,18 +4601,18 @@ void InternalTCXDecoder_fx(
const Word16 tcx_offset, /* i : folding point offset relative to the end of the previous frame */
const Word16 noiseFillingBorder, /* i : noise filling border */
const Word32 *x_quant_fx, /* i : quantized spectrum, exponent same as spectrum_e */
- const Word32 ener_fx, /* i : energy of the quantized spectrum */
+ const Word32 ener_fx, /* i : energy of the quantized spectrum Q(31-ener_e) */
const Word16 ener_e, /* i : exponent of energy of the quantized spectrum */
Word16 lf_deemph_fact_fx[], /* i/o: low frequency deemphasis factors */
const Word16 fac_ns_fx, /* i : noise filling level, Q15 */
const Word16 nf_seed, /* i : noise filling random seed, Q0 */
const Word16 *A_fx, /* i : LPC representation of the FDNS gains, Q = 14 - norm_s(A_fx[0]) */
- Word16 gainlpc_fx[], /* i/o: FDNS gains */
+ Word16 gainlpc_fx[], /* i/o: FDNS gains Q(15-gainlpc_e) */
Word16 gainlpc_e[], /* i/o: FDNS gains exponents */
const Word16 hm_active, /* i : flag indicating if the harmonic model is active */
- Word16 gain_tcx_fx, /* i/o: global gain / quantized global gain */
+ Word16 gain_tcx_fx, /* i/o: global gain / quantized global gain Q(15-gain_tcx_e) */
Word16 *gain_tcx_e, /* i/o: global gain / quantized global gain exponent */
- Word32 spectrum_fx[], /* o : dequantized spectrum */
+ Word32 spectrum_fx[], /* o : dequantized spectrum Q(31-spectrum_e) */
Word16 *spectrum_e, /* o : exponent of dequantized spectrum */
Word16 synth[], /* o : time domain signal */
Word16 *gain_tcx_q /* o : quantized global gain (at low bitrates), Q0 */
@@ -4746,7 +4692,7 @@ void InternalTCXDecoder_fx(
tmp2 = add( tmp2, sub( ener_e, add( shl( sub( *spectrum_e, s ), 1 ), 1 ) ) );
tmp1 = Sqrt16( tmp1, &tmp2 );
- gain_tcx_fx = mult( gain_tcx_fx, tmp1 );
+ gain_tcx_fx = mult( gain_tcx_fx, tmp1 ); // Q(15-(gain_tcx_e+tmp2))
*gain_tcx_e = add( *gain_tcx_e, tmp2 );
move16();
@@ -4761,7 +4707,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 );
@@ -4771,11 +4717,11 @@ void InternalTCXDecoder_fx(
test();
IF( NE_16( len, L_frame ) && LT_16( q_spec, sub( 31, *spectrum_e ) ) )
{
- scale_sig32( spectrum_fx + len, sub( L_frame, len ), sub( q_spec, sub( 15, *spectrum_e ) ) );
+ scale_sig32( spectrum_fx + len, sub( L_frame, len ), sub( q_spec, sub( 15, *spectrum_e ) ) ); // q_spec
}
ELSE IF( NE_16( len, L_frame ) && GT_16( q_spec, sub( 31, *spectrum_e ) ) )
{
- scale_sig32( spectrum_fx, len, sub( sub( 15, *spectrum_e ), q_spec ) );
+ scale_sig32( spectrum_fx, len, sub( sub( 15, *spectrum_e ), q_spec ) ); // Q(31-spectrum_e)
q_spec = sub( 31, *spectrum_e );
}
*spectrum_e = sub( 31, q_spec );
@@ -4789,7 +4735,7 @@ void InternalTCXDecoder_fx(
* Apply gain *
*-----------------------------------------------------------*/
- IF( EQ_16( st->hTcxCfg->coder_type, INACTIVE ) )
+ IF( st->hTcxCfg->coder_type == INACTIVE )
{
gain_tcx_fx = mult_r( gain_tcx_fx, st->hTcxCfg->na_scale );
}
@@ -5000,11 +4946,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 */
@@ -5068,7 +5010,6 @@ void InternalTCXDecoder_fx(
0 );
- move16();
tmpP16 = xn_buf16 + add( sub( L_win, shr( L_ola, 1 ) ), shr( overlap, 1 ) );
tcx_windowing_synthesis_past_frame( tmpP16,
@@ -5083,11 +5024,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();
}
@@ -5182,7 +5119,7 @@ void InternalTCXDecoder_fx(
/* DCT */
Q = sub( 31, *spectrum_e );
- edct_fx( spectrum_fx, tmp_buf, L_frame, &Q );
+ edct_ivas_fx( spectrum_fx, tmp_buf, L_frame, &Q );
/* scale by sqrt(L / NORM_MDCT_FACTOR) */
tmp1 = mult_r( shl( L_frame, 4 ), 26214 /*128.f / NORM_MDCT_FACTOR Q15*/ ); /* 4Q11 */
@@ -5213,11 +5150,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();
}
@@ -5277,11 +5210,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();
}
@@ -5290,31 +5219,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();
}
}
@@ -5344,11 +5261,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();
}
@@ -5356,11 +5269,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();
}
}
@@ -5374,11 +5283,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;
@@ -5411,7 +5316,7 @@ void InternalTCXDecoder_fx(
st->hTcxCfg->tcx_curr_overlap_mode );
/* If current overlap mode = FULL_OVERLAP -> ALDO_WINDOW */
- IF( EQ_16( st->hTcxCfg->tcx_curr_overlap_mode, FULL_OVERLAP ) )
+ IF( st->hTcxCfg->tcx_curr_overlap_mode == FULL_OVERLAP )
{
FOR( i = 0; i < nz; i++ )
{
diff --git a/lib_enc/cod_uv_fx.c b/lib_enc/cod_uv_fx.c
index ca17c0f2506a20a33a41b2686efcafc2a7350615..8eccddc0b822eb5eaba77b68f5eba4f6f1cc3411 100644
--- a/lib_enc/cod_uv_fx.c
+++ b/lib_enc/cod_uv_fx.c
@@ -64,7 +64,7 @@ void gauss_L2_fx(
E_UTIL_f_convolve( code, h, y11, L_SUBFR ); /* y11: Q8+shift */
Scale_sig( y11, L_SUBFR, sub( 1, shift ) ); /* Q9 */
*gain = L_deposit_l( 0 );
-
+ move32();
/*Update correlations for gains coding */
tmp32 = L_shr( 21474836l /*0.01f Q31*/, 31 - 18 ); /* Q18 */
tmp32_2 = L_shr( 21474836l /*0.01f Q31*/, 31 - 18 ); /* Q18 */
@@ -76,22 +76,16 @@ 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();
}
void gauss_L2_ivas_fx(
@@ -139,29 +133,45 @@ void gauss_L2_ivas_fx(
E_UTIL_f_convolve( code, h, y11, L_SUBFR ); /* y11: Q8+shift */
Scale_sig( y11, L_SUBFR, sub( 1, shift ) ); /* Q9 */
*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/comvad_decision_fx.c b/lib_enc/comvad_decision_fx.c
index 505e18326fb3483811fef7a6904da7b22a9d68b4..1499bbfce0e51540ecf72e3d742924df9442ebaf 100644
--- a/lib_enc/comvad_decision_fx.c
+++ b/lib_enc/comvad_decision_fx.c
@@ -24,10 +24,10 @@
/*#define CLDFB_VAD*/ /* test on the CLDFB-VAD */
static Word16 comvad_hangover(
- const Word32 lt_snr_org, /* i : original long time SNR*/
- const Word32 snr, /* i : frequency domain SNR */
- const Word32 l_snr, /* i : long time frequency domain SNR calculated by l_speech_snr and l_silence_snr*/
- const Word32 snr_flux, /* i : average tsnr*/
+ const Word32 lt_snr_org, /* i : original long time SNR Q25*/
+ const Word32 snr, /* i : frequency domain SNR Q25*/
+ const Word32 l_snr, /* i : long time frequency domain SNR calculated by l_speech_snr and l_silence_snr Q25*/
+ const Word32 snr_flux, /* i : average tsnr Q25*/
const Word16 bw_index, /* i : band width index*/
const Word16 vad_flag,
const Word16 pre_res_hang_num, /* i : residual amount of previous hangover */
@@ -379,7 +379,7 @@ static Word16 comvad_hangover(
{
IF( ( NE_16( noisy_type, SILENCE ) ) )
{
- speech_flag--;
+ speech_flag = sub( speech_flag, 1 );
}
ELSE
{
@@ -395,13 +395,13 @@ static Word16 comvad_hangover(
Word16 comvad_decision_fx(
VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */
- const Word32 l_snr, /* i : long time frequency domain*/
- const Word32 lt_snr_org, /* i : original long time SNR*/
- const Word32 lt_snr, /* i : long time SNR calculated by fg_energy and bg_energy*/
- const Word32 snr_flux, /* i : average tsnr of several frames*/
- const Word32 snr, /* i : frequency domain SNR */
- Word32 tsnr, /* i : time domain SNR */
- const Word32 frame_energy, /* i : current frame energy */
+ const Word32 l_snr, /* i : long time frequency domain Q25*/
+ const Word32 lt_snr_org, /* i : original long time SNR Q25*/
+ const Word32 lt_snr, /* i : long time SNR calculated by fg_energy and bg_energy Q25*/
+ const Word32 snr_flux, /* i : average tsnr of several frames Q25*/
+ const Word32 snr, /* i : frequency domain SNR Q25 */
+ Word32 tsnr, /* i : time domain SNR Q25*/
+ const Word32 frame_energy, /* i : current frame energy Q(frame_energy_Q)*/
const Word16 music_backgound_f, /* i : background music flag*/
const Word16 frame_energy_Q, /* i : the Scaling of current frame energy*/
Word16 *cldfb_addition, /* o : adjust the harmonized hangover */
@@ -443,7 +443,7 @@ Word16 comvad_decision_fx(
move16();
test();
- IF( GT_32( hVAD_CLDFB->lf_snr_smooth, LS_MIN_SILENCE_SNR[hVAD_CLDFB->bw_index - CLDFBVAD_NB_ID] ) && GT_32( lt_snr_org, LT_MIN_SILENCE_SNR_FX[hVAD_CLDFB->bw_index - CLDFBVAD_NB_ID] ) )
+ if ( GT_32( hVAD_CLDFB->lf_snr_smooth, LS_MIN_SILENCE_SNR[hVAD_CLDFB->bw_index - CLDFBVAD_NB_ID] ) && GT_32( lt_snr_org, LT_MIN_SILENCE_SNR_FX[hVAD_CLDFB->bw_index - CLDFBVAD_NB_ID] ) )
{
noisy_type = SILENCE;
move16();
@@ -477,7 +477,7 @@ Word16 comvad_decision_fx(
IF( EQ_16( hVAD_CLDFB->fg_energy_count, 512 ) )
{
- fg_energy = MUL_F( fg_energy, 0x6000 );
+ fg_energy = MUL_F( fg_energy, 0x6000 /*.75f in Q15*/ );
hVAD_CLDFB->fg_energy_count = 384;
move16();
}
@@ -527,7 +527,7 @@ Word16 comvad_decision_fx(
l_silence_snr_count = L_shl( hVAD_CLDFB->l_silence_snr_count, Qnorm_silence_count );
snr_div_fix = div_l( l_silence_snr, extract_h( l_silence_snr_count ) );
}
- snr_sub = L_sub( snr, 0x3000000 );
+ snr_sub = L_sub( snr, 0x3000000 /*1.5f in Q25*/ );
snr_div_fix32 = L_deposit_l( snr_div_fix );
snr_div_fix32 = L_shr( snr_div_fix32, add( 6, sub( Qnorm_silence, Qnorm_silence_count ) ) );
@@ -536,7 +536,7 @@ Word16 comvad_decision_fx(
{
IF( EQ_32( hVAD_CLDFB->l_speech_snr_count, 512 ) )
{
- hVAD_CLDFB->l_speech_snr = L_add( MUL_F( hVAD_CLDFB->l_speech_snr, 0x6000 ), L_shr( snr, 9 ) );
+ hVAD_CLDFB->l_speech_snr = L_add( MUL_F( hVAD_CLDFB->l_speech_snr, 0x6000 /*.75f in Q15*/ ), L_shr( snr, 9 ) );
move32();
hVAD_CLDFB->l_speech_snr_count = L_deposit_l( 384 + 1 );
move32();
@@ -557,7 +557,7 @@ Word16 comvad_decision_fx(
{
Word32 lt_snr_add;
- lt_snr_add = L_add( 0x03cccccd, MUL_F( lt_snr, 0x23d7 ) );
+ lt_snr_add = L_add( 0x03cccccd /*1.9 in Q25*/, MUL_F( lt_snr, 0x23d7 ) );
if ( GT_32( snr_flux, lt_snr_add ) )
{
@@ -593,7 +593,7 @@ Word16 comvad_decision_fx(
{
Word32 lt_snr_add;
- lt_snr_add = L_add( 0x04333333, MUL_F( lt_snr, 0x1eb8 ) );
+ lt_snr_add = L_add( 0x04333333 /*2.1 in Q25*/, MUL_F( lt_snr, 0x1eb8 ) );
if ( GT_32( snr_flux, lt_snr_add ) )
{
@@ -629,7 +629,7 @@ Word16 comvad_decision_fx(
{
Word32 lt_snr_add;
- lt_snr_add = L_add( 0x04333333, MUL_F( lt_snr, 0x28f5 ) );
+ lt_snr_add = L_add( 0x04333333 /*2.1 Q25*/, MUL_F( lt_snr, 0x28f5 ) );
if ( ( GT_32( snr_flux, lt_snr_add ) ) )
{
@@ -671,7 +671,8 @@ Word16 comvad_decision_fx(
test();
if ( GT_16( hVAD_CLDFB->ltd_stable_rate[0], 2621 /* 0.08 Q15 */ ) && EQ_16( vad_flag, 1 ) && ( tmpout > 0 ) )
{
- hVAD_CLDFB->fg_energy_est_start = L_deposit_l( 1 );
+ hVAD_CLDFB->fg_energy_est_start = 1;
+ move32();
}
}
@@ -694,7 +695,7 @@ Word16 comvad_decision_fx(
move16();
}
vadb_flag = vad_flag;
-
+ move16();
IF( EQ_16( hVAD_CLDFB->bw_index, CLDFBVAD_SWB_ID ) )
{
test();
@@ -710,13 +711,14 @@ Word16 comvad_decision_fx(
test();
test();
test();
- IF( GT_32( snr_flux, 83886078 /* 2.5 Q25 */ ) || ( hVAD_CLDFB->continuous_speech_num2 > 40 && GT_32( snr_flux, 67108862 /* 2.0 Q25 */ ) ) || music_backgound_f == 1 )
+ IF( GT_32( snr_flux, 83886078 /* 2.5 Q25 */ ) || ( hVAD_CLDFB->continuous_speech_num2 > 40 && GT_32( snr_flux, 67108862 /* 2.0 Q25 */ ) ) || EQ_16( music_backgound_f, 1 ) )
{
vad_flag = s_or( vad_flag, vada_flag );
}
ELSE IF( EQ_16( SILENCE, noisy_type ) )
{
vad_flag = vada_flag;
+ move16();
}
}
}
@@ -735,13 +737,14 @@ Word16 comvad_decision_fx(
test();
test();
test();
- IF( GT_32( snr_flux, 73819748 /* 2.2 Q25 */ ) || ( hVAD_CLDFB->continuous_speech_num2 > 40 && GT_32( snr_flux, 57042532 /* 1.7 Q25 */ ) ) || music_backgound_f == 1 )
+ IF( GT_32( snr_flux, 73819748 /* 2.2 Q25 */ ) || ( hVAD_CLDFB->continuous_speech_num2 > 40 && GT_32( snr_flux, 57042532 /* 1.7 Q25 */ ) ) || EQ_16( music_backgound_f, 1 ) )
{
vad_flag = s_or( vad_flag, vada_flag );
}
ELSE IF( EQ_16( SILENCE, noisy_type ) )
{
vad_flag = vada_flag;
+ move16();
}
}
}
@@ -753,6 +756,7 @@ Word16 comvad_decision_fx(
IF( GT_32( hVAD_CLDFB->lf_snr_smooth, 419430388 /* 12.5 Q25 */ ) && music_backgound_f == 0 )
{
vad_flag = vada_flag;
+ move16();
}
}
ELSE
@@ -760,7 +764,7 @@ Word16 comvad_decision_fx(
test();
test();
test();
- IF( GT_32( snr_flux, 67108862 /* 2.0 Q25 */ ) || ( hVAD_CLDFB->continuous_speech_num2 > 30 && GT_32( snr_flux, 50331647 /* 1.5 Q25 */ ) ) || music_backgound_f == 1 )
+ IF( GT_32( snr_flux, 67108862 /* 2.0 Q25 */ ) || ( GT_16( hVAD_CLDFB->continuous_speech_num2, 30 ) && GT_32( snr_flux, 50331647 /* 1.5 Q25 */ ) ) || EQ_16( music_backgound_f, 1 ) )
{
vad_flag = s_or( vad_flag, vada_flag );
}
@@ -771,7 +775,7 @@ Word16 comvad_decision_fx(
{
IF( EQ_32( hVAD_CLDFB->l_silence_snr_count, 512 ) )
{
- hVAD_CLDFB->l_silence_snr = L_add( MUL_F( hVAD_CLDFB->l_silence_snr, 0x6000 ), L_shr( snr, 9 ) );
+ hVAD_CLDFB->l_silence_snr = L_add( MUL_F( hVAD_CLDFB->l_silence_snr, 0x6000 /*.75f Q15*/ ), L_shr( snr, 9 ) );
move32();
hVAD_CLDFB->l_silence_snr_count = L_deposit_l( 384 + 1 );
move32();
@@ -789,7 +793,7 @@ Word16 comvad_decision_fx(
{
IF( EQ_16( hVAD_CLDFB->bg_energy_count, 512 ) )
{
- bg_energy = MUL_F( bg_energy, 0x6000 );
+ bg_energy = MUL_F( bg_energy, 0x6000 /*.75f Q15*/ );
hVAD_CLDFB->bg_energy_count = 384;
move16();
}
@@ -804,9 +808,11 @@ Word16 comvad_decision_fx(
test();
hVAD_CLDFB->vad_flag_for_bk_update = vad_flag;
+ move16();
IF( LT_16( hVAD_CLDFB->update_count, 12 ) && EQ_16( vadb_flag, 1 ) )
{
hVAD_CLDFB->warm_hang_num = s_max( 20, speech_flag );
+ move16();
}
test();
IF( vad_flag == 0 && hVAD_CLDFB->warm_hang_num > 0 )
@@ -814,6 +820,7 @@ Word16 comvad_decision_fx(
hVAD_CLDFB->warm_hang_num = sub( hVAD_CLDFB->warm_hang_num, 1 );
vad_flag = 1;
move16();
+ move16();
}
@@ -827,15 +834,16 @@ Word16 comvad_decision_fx(
hVAD_CLDFB->speech_flag = speech_flag;
move16();
- move16();
test();
IF( EQ_16( noisy_type, SILENCE ) && NE_16( hVAD_CLDFB->bw_index, CLDFBVAD_NB_ID ) )
{
*cldfb_addition = 2;
+ move16();
}
ELSE
{
*cldfb_addition = 0;
+ move16();
if ( EQ_16( hVAD_CLDFB->bw_index, CLDFBVAD_WB_ID ) )
{
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_2div_fx.c b/lib_enc/core_enc_2div_fx.c
index 151561b091bea6801e7c95d3ddd5cc9bdfba53c4..fa74ec6b562f88a5e675aba13685de56fa703fdb 100644
--- a/lib_enc/core_enc_2div_fx.c
+++ b/lib_enc/core_enc_2div_fx.c
@@ -22,7 +22,7 @@
*-------------------------------------------------------------------*/
void core_encode_twodiv_fx(
- const Word16 new_samples[], /* i : new samples */
+ const Word16 new_samples[], /* i : new samples */
Encoder_State *st, /* i/o: coder memory state */
const Word16 coder_type, /* i : coding type */
Word16 Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes*/
@@ -60,9 +60,7 @@ void core_encode_twodiv_fx(
spectrum[1] = spectrum_buf + N_TCX10_MAX;
hm_cfg[0].indexBuffer = &indexBuffer[0];
- move16();
hm_cfg[1].indexBuffer = &indexBuffer[N_MAX / 2 + 1];
- move16();
move16();
move16();
@@ -203,19 +201,19 @@ void core_encode_twodiv_fx(
/* calculate noise-filling over whole spectrum for TCX10 frames */
move16();
- hTcxEnc->measuredBwRatio = 0x4000;
+ hTcxEnc->measuredBwRatio = 0x4000; // 1 in Q14
FOR( n = 0; n < 2; n++ )
{
target_bits = sub( shr( sub( add( bitsAvailable, 1 ), n ), 1 ), tnsBits[n] );
- if ( n == 0 )
+ IF( n == 0 )
{
target_bits = sub( target_bits, ltpBits );
}
test();
- if ( st->enablePlcWaveadjust && n )
+ IF( st->enablePlcWaveadjust && n )
{
target_bits = sub( target_bits, 1 );
}
@@ -285,7 +283,7 @@ void core_encode_twodiv_fx(
/* subtract bits for TCX overlap mode (1 bit: full, 2 bits: half or no overlap) */
target_bits = sub( target_bits, 1 );
test();
- if ( EQ_16( st->hTcxCfg->tcx_curr_overlap_mode, HALF_OVERLAP ) || EQ_16( st->hTcxCfg->tcx_curr_overlap_mode, MIN_OVERLAP ) )
+ IF( EQ_16( st->hTcxCfg->tcx_curr_overlap_mode, HALF_OVERLAP ) || EQ_16( st->hTcxCfg->tcx_curr_overlap_mode, MIN_OVERLAP ) )
{
target_bits = sub( target_bits, 1 );
}
@@ -293,7 +291,7 @@ void core_encode_twodiv_fx(
target_bits = sub( target_bits, st->hIGFEnc->infoTotalBitsPerFrameWritten );
- if ( st->enablePlcWaveadjust )
+ IF( st->enablePlcWaveadjust )
{
target_bits = sub( target_bits, 1 );
}
diff --git a/lib_enc/core_enc_init.c b/lib_enc/core_enc_init.c
index c378731ad5ad216a71d2715360d782733d3e1b29..d82d1b7ff8654dc8f84655987e562665d7209aef 100644
--- a/lib_enc/core_enc_init.c
+++ b/lib_enc/core_enc_init.c
@@ -52,7 +52,7 @@
*-----------------------------------------------------------------------*/
static void init_tcx_ivas_fx( Encoder_State *st, const Word16 L_frame_old, const Word32 total_brate, const Word32 last_total_brate, const Word16 MCT_flag );
static void init_core_sig_ana_ivas_fx( Encoder_State *st );
-static void init_modes_ivas_fx( Encoder_State *st, const int32_t last_total_brate );
+static void init_modes_ivas_fx( Encoder_State *st, const Word32 last_total_brate );
static void init_sig_buffers_ivas_fx( Encoder_State *st, const Word16 L_frame_old, const Word16 L_subfr );
static void init_acelp_ivas_fx( Encoder_State *st, Word16 L_frame_old, Word16 shift );
/*-----------------------------------------------------------------------*
@@ -121,7 +121,7 @@ void init_coder_ace_plus_ivas_fx(
test();
test();
test();
- IF( ( EQ_16( st->element_mode, EVS_MONO ) && EQ_32( st->L_frame, L_FRAME16k ) && LE_32( st->total_brate, ACELP_32k ) ) || ( GT_16( st->element_mode, EVS_MONO ) && EQ_32( st->L_frame, L_FRAME16k ) && LE_32( st->total_brate, MAX_ACELP_BRATE ) ) )
+ IF( ( st->element_mode == EVS_MONO && EQ_32( st->L_frame, L_FRAME16k ) && LE_32( st->total_brate, ACELP_32k ) ) || ( st->element_mode > EVS_MONO && EQ_32( st->L_frame, L_FRAME16k ) && LE_32( st->total_brate, MAX_ACELP_BRATE ) ) )
{
st->nb_subfr = NB_SUBFR16k;
move16();
@@ -160,7 +160,8 @@ void init_coder_ace_plus_ivas_fx(
st->currEnergyHF_fx = 0;
move32();
-
+ st->currEnergyHF_e_fx = 0;
+ move16();
test();
/* Initialize LPC analysis/quantization */
IF( LE_32( st->sr_core, INT_FS_16k ) && st->tcxonly == 0 )
@@ -221,7 +222,7 @@ void init_coder_ace_plus_ivas_fx(
init_acelp_ivas_fx( st, L_frame_old, 0 );
- IF( st->ini_frame == 0 )
+ if ( st->ini_frame == 0 )
{
st->tec_tfa = 0;
move16();
@@ -235,7 +236,7 @@ void init_coder_ace_plus_ivas_fx(
test();
test();
test();
- IF( EQ_16( st->bwidth, SWB ) && ( EQ_32( st->total_brate, ACELP_16k40 ) || EQ_32( st->total_brate, ACELP_24k40 ) ) && EQ_16( st->element_mode, EVS_MONO ) )
+ IF( EQ_16( st->bwidth, SWB ) && ( EQ_32( st->total_brate, ACELP_16k40 ) || EQ_32( st->total_brate, ACELP_24k40 ) ) && st->element_mode == EVS_MONO )
{
st->tec_tfa = 1;
move16();
@@ -254,7 +255,7 @@ void init_coder_ace_plus_ivas_fx(
test();
test();
test();
- IF( ( EQ_32( st->total_brate, ACELP_9k60 ) || EQ_32( st->total_brate, ACELP_16k40 ) || EQ_32( st->total_brate, ACELP_24k40 ) ) && EQ_16( st->element_mode, EVS_MONO ) )
+ IF( ( EQ_32( st->total_brate, ACELP_9k60 ) || EQ_32( st->total_brate, ACELP_16k40 ) || EQ_32( st->total_brate, ACELP_24k40 ) ) && st->element_mode == EVS_MONO )
{
st->glr = 1;
move16();
@@ -315,213 +316,6 @@ void init_coder_ace_plus_ivas_fx(
return;
}
-void init_coder_ace_plus(
- Encoder_State *st, /* i : Encoder state */
- const int32_t last_total_brate, /* i : last total bitrate */
- const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0) */
-)
-{
- TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc;
- int16_t L_frame_old; /*keep old frame size for switching */
- int16_t L_subfr;
-
- /* Bitrate */
- st->tcxonly = getTcxonly_ivas_fx( st->element_mode, st->total_brate, MCT_flag, st->is_ism_format );
-
- /* Core Sampling Rate */
- st->sr_core = getCoreSamplerateMode2_flt( st->element_mode, st->total_brate, st->bwidth, st->flag_ACELP16k, st->rf_mode, st->is_ism_format );
- st->fscale = sr2fscale( st->sr_core );
-
- /* Narrowband? */
- st->narrowBand = ( st->bwidth == NB ) ? 1 : 0;
-
- /* Core Framing */
- L_frame_old = st->last_L_frame;
- st->L_frame = (int16_t) ( st->sr_core / FRAMES_PER_SEC );
- st->L_frame_past = -1;
-
- if ( hTcxEnc != NULL )
- {
- hTcxEnc->L_frameTCX = (int16_t) ( st->input_Fs / FRAMES_PER_SEC );
-
- if ( st->ini_frame == 0 )
- {
- hTcxEnc->tcx_target_bits_fac = ONE_IN_Q14;
-
- set16_fx( hTcxEnc->Txnq, 0, L_FRAME32k / 2 + 64 );
- hTcxEnc->acelp_zir = hTcxEnc->Txnq + L_FRAME / 2;
- hTcxEnc->q_Txnq = Q15;
- move16();
- }
- }
-
- if ( ( st->element_mode == EVS_MONO && st->L_frame == L_FRAME16k && st->total_brate <= ACELP_32k ) || ( st->element_mode > EVS_MONO && st->L_frame == L_FRAME16k && st->total_brate <= MAX_ACELP_BRATE ) )
- {
- st->nb_subfr = NB_SUBFR16k;
- }
- else
- {
- st->nb_subfr = NB_SUBFR;
- }
- L_subfr = st->L_frame / st->nb_subfr;
-
- /* Core Lookahead */
- st->encoderLookahead_enc = NS2SA( st->sr_core, ACELP_LOOK_NS );
- st->encoderLookahead_FB = NS2SA( st->input_Fs, ACELP_LOOK_NS );
-
- if ( st->ini_frame == 0 )
- {
- st->acelpFramesCount = 0;
-#ifdef MSAN_FIX
- st->prevTempFlatness_fx = 128; // Q7
-#endif
- }
-
- /* Initialize TBE */
- if ( st->hBWE_TD != NULL )
- {
- st->hBWE_TD->prev_coder_type = GENERIC;
- set16_fx( st->hBWE_TD->prev_lsf_diff_fx, 16384, LPC_SHB_ORDER - 2 );
- st->hBWE_TD->prev_tilt_para_fx = 0;
- set16_fx( st->hBWE_TD->cur_sub_Aq_fx, 0, M + 1 );
- move16();
- }
-
- st->currEnergyHF_fx = 0;
- move32();
-
- /* Initialize LPC analysis/quantization */
- if ( st->sr_core <= INT_FS_16k && st->tcxonly == 0 )
- {
- st->lpcQuantization = 1;
- }
- else
- {
- st->lpcQuantization = 0;
- }
-
- st->next_force_safety_net = 0;
- if ( ( st->last_L_frame != st->L_frame ) || ( st->last_core == AMR_WB_CORE ) || ( st->last_core == HQ_CORE ) )
- {
- set16_fx( st->mem_MA_fx, 0, M );
- Copy( GEWB_Ave_fx, st->mem_AR_fx, M );
- }
-
- /* Initialize IGF */
- if ( st->hIGFEnc != NULL )
- {
- st->hIGFEnc->infoStopFrequency = -1;
- }
-
- if ( st->igf && st->hIGFEnc != NULL )
- {
- IGFEncSetMode_ivas_fx( st->hIGFEnc, st->total_brate, st->bwidth, st->element_mode, st->rf_mode );
- }
- else if ( st->hIGFEnc != NULL )
- {
- st->hIGFEnc->infoTotalBitsWritten = 0;
- st->hIGFEnc->infoTotalBitsPerFrameWritten = 0;
- }
-
- /* Initialize Core Signal Analysis Module */
- init_core_sig_ana_ivas_fx( st );
-
- /* Initialize TCX */
- if ( hTcxEnc != NULL )
- {
- init_tcx_ivas_fx( st, L_frame_old, st->total_brate, last_total_brate, MCT_flag );
- }
-
- /* Initialize Signal Buffers */
- init_sig_buffers_ivas_fx( st, L_frame_old, L_subfr );
-
- /* Initialize ACELP */
- init_acelp_ivas_fx( st, L_frame_old, 0 );
-
- if ( st->ini_frame == 0 )
- {
- st->tec_tfa = 0;
- }
-
- if ( st->hTECEnc != NULL )
- {
- resetTecEnc_Fx( st->hTECEnc, st->tec_tfa );
- }
-
- if ( st->bwidth == SWB && ( st->total_brate == ACELP_16k40 || st->total_brate == ACELP_24k40 ) && st->element_mode == EVS_MONO )
- {
- st->tec_tfa = 1;
- }
- else
- {
- st->tec_tfa = 0;
- }
-
- st->tec_flag = 0;
- st->tfa_flag = 0;
-
-
- if ( ( st->total_brate == ACELP_9k60 || st->total_brate == ACELP_16k40 || st->total_brate == ACELP_24k40 ) && st->element_mode == EVS_MONO )
- {
- st->glr = 1;
- }
- else
- {
- st->glr = 0;
- }
-
- st->glr_reset = 0;
-
- /* Initialize ACELP/TCX Modes */
- init_modes_ivas_fx( st, last_total_brate );
-
- /* Adaptive BPF */
- if ( st->total_brate >= HQ_48k )
- {
- st->enablePlcWaveadjust = 1;
- }
- else
- {
- st->enablePlcWaveadjust = 0;
- }
-
- set32_fx( st->mem_bpf_fx1, 0, 2 * L_FILT16k );
- set32_fx( st->mem_error_bpf_fx, 0, 2 * L_FILT16k );
-
- IF( st->ini_frame == 0 )
- {
- st->Q_max_enc[0] = 15;
- move16();
- st->Q_max_enc[1] = 15;
- move16();
- }
-
- IF( st->total_brate >= HQ_48k )
- {
- st->enablePlcWaveadjust = 1;
- move16();
- }
- ELSE
- {
- st->enablePlcWaveadjust = 0;
- move16();
- }
-
- if ( st->hPlcExt )
- {
- init_PLC_enc_fx( st->hPlcExt, st->sr_core );
- }
-
- st->glr_idx[0] = 0;
- st->glr_idx[1] = 0;
- st->mean_gc[0] = 0;
- st->mean_gc[1] = 0;
- st->prev_lsf4_mean = 0;
- st->last_stab_fac = 0;
-
- return;
-}
-
/*-----------------------------------------------------------------------*
* init_tcx()
*
@@ -618,13 +412,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;
@@ -670,7 +460,7 @@ static void init_sig_buffers_ivas_fx( Encoder_State *st, const Word16 L_frame_ol
hTcxEnc->exp_buf_speech_ltp = 0;
move16();
}
- set16_fx( st->buf_wspeech_enc, 0, L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320 ); /* increased by 320 to avoid memory overlap in ivas_find_wsp() and also to accomodate for the wspeech_enc */
+ set16_fx( st->buf_wspeech_enc, 0, L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320 ); /* increased by 320 to avoid memory overlap in ivas_find_wsp_fx() and also to accomodate for the wspeech_enc */
st->exp_buf_wspeech_enc = 0;
move16();
}
@@ -688,8 +478,8 @@ static void init_sig_buffers_ivas_fx( Encoder_State *st, const Word16 L_frame_ol
IF( NE_16( st->last_core, TCX_20_CORE ) && NE_16( st->last_core, TCX_10_CORE ) ) /* condition should be checked again */
{
Copy( st->buf_speech_enc, hTcxEnc->buf_speech_ltp, st->L_frame );
- Scale_sig( hTcxEnc->buf_speech_ltp, st->L_frame, sub( st->exp_buf_speech_enc, s_max( st->exp_buf_speech_enc, hTcxEnc->exp_buf_speech_ltp ) ) );
- Scale_sig( hTcxEnc->buf_speech_ltp + st->L_frame, sub( L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, st->L_frame ), sub( hTcxEnc->exp_buf_speech_ltp, s_max( st->exp_buf_speech_enc, hTcxEnc->exp_buf_speech_ltp ) ) );
+ Scale_sig( hTcxEnc->buf_speech_ltp, st->L_frame, sub( st->exp_buf_speech_enc, s_max( st->exp_buf_speech_enc, hTcxEnc->exp_buf_speech_ltp ) ) ); // Q(15-max(st->exp_buf_speech_enc, hTcxEnc->exp_buf_speech_ltp))
+ Scale_sig( hTcxEnc->buf_speech_ltp + st->L_frame, sub( L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, st->L_frame ), sub( hTcxEnc->exp_buf_speech_ltp, s_max( st->exp_buf_speech_enc, hTcxEnc->exp_buf_speech_ltp ) ) ); // Q(15-max(st->exp_buf_speech_enc, hTcxEnc->exp_buf_speech_ltp))
hTcxEnc->exp_buf_speech_ltp = s_max( hTcxEnc->exp_buf_speech_ltp, st->exp_buf_speech_enc );
move16();
}
@@ -707,9 +497,9 @@ static void init_sig_buffers_ivas_fx( Encoder_State *st, const Word16 L_frame_ol
// Copy_Scale_sig( st->old_inp_12k8_fx, st->buf_speech_enc_pe + st->L_frame - L_INP_MEM, L_INP_MEM, sub( st->prev_Q_new, st->prev_Q_old ) );
Copy( st->old_inp_12k8_fx, st->buf_speech_enc_pe + st->L_frame - L_INP_MEM, L_INP_MEM );
/* SCaling to common exponent*/
- Scale_sig( st->buf_speech_enc_pe + sub( st->L_frame, L_INP_MEM ), L_INP_MEM, sub( st->exp_old_inp_12k8, s_max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe ) ) );
- Scale_sig( st->buf_speech_enc_pe, sub( st->L_frame, L_INP_MEM ), sub( st->exp_buf_speech_enc_pe, s_max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe ) ) );
- Scale_sig( st->buf_speech_enc_pe + st->L_frame, sub( L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, st->L_frame ), sub( st->exp_buf_speech_enc_pe, s_max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe ) ) );
+ Scale_sig( st->buf_speech_enc_pe + sub( st->L_frame, L_INP_MEM ), L_INP_MEM, sub( st->exp_old_inp_12k8, s_max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe ) ) ); // Q(15-max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe ))
+ Scale_sig( st->buf_speech_enc_pe, sub( st->L_frame, L_INP_MEM ), sub( st->exp_buf_speech_enc_pe, s_max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe ) ) ); // Q(15-max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe ))
+ Scale_sig( st->buf_speech_enc_pe + st->L_frame, sub( L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, st->L_frame ), sub( st->exp_buf_speech_enc_pe, s_max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe ) ) ); // Q(15-max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe ))
st->exp_buf_speech_enc_pe = s_max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe );
move16();
}
@@ -758,7 +548,7 @@ static void init_sig_buffers_ivas_fx( Encoder_State *st, const Word16 L_frame_ol
hTcxEnc->new_speech_ltp = hTcxEnc->buf_speech_ltp + st->encoderPastSamples_enc + st->encoderLookahead_enc;
}
- if ( st->hTcxEnc != NULL )
+ IF( st->hTcxEnc != NULL )
{
st->hTcxEnc->new_speech_TCX = st->input_buff_fx + Mpy_32_32( st->input_Fs, ONE_BY_FRAMES_PER_SEC_Q31 );
st->hTcxEnc->speech_TCX = st->hTcxEnc->new_speech_TCX - st->encoderLookahead_FB;
@@ -771,7 +561,7 @@ static void init_sig_buffers_ivas_fx( Encoder_State *st, const Word16 L_frame_ol
hTcxEnc->speech_ltp = hTcxEnc->buf_speech_ltp + st->encoderPastSamples_enc;
}
- IF( GT_16( st->element_mode, EVS_MONO ) )
+ IF( st->element_mode > EVS_MONO )
{
st->wspeech_enc = st->buf_wspeech_enc + st->L_frame + L_SUBFR;
}
@@ -889,7 +679,7 @@ static void init_acelp_ivas_fx( Encoder_State *st, Word16 L_frame_old, Word16 sh
}
ELSE /*Rate switching*/
{
- IF( EQ_16( st->last_core, ACELP_CORE ) )
+ IF( st->last_core == ACELP_CORE )
{
lerp( hTcxEnc->Txnq, hTcxEnc->Txnq, shr( st->L_frame, 1 ), shr( L_frame_old, 1 ) );
}
@@ -900,7 +690,7 @@ static void init_acelp_ivas_fx( Encoder_State *st, Word16 L_frame_old, Word16 sh
hTcxEnc->acelp_zir = hTcxEnc->Txnq + shr( st->L_frame, 1 );
/* Rate switching */
- IF( EQ_16( st->last_codec_mode, MODE1 ) && EQ_16( st->element_mode, EVS_MONO ) )
+ IF( EQ_16( st->last_codec_mode, MODE1 ) && st->element_mode == EVS_MONO )
{
IF( hLPDmem != NULL )
{
@@ -1028,12 +818,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 ) ) )
@@ -1142,9 +928,9 @@ static void init_acelp_ivas_fx( Encoder_State *st, Word16 L_frame_old, Word16 sh
move32();
st->pst_lp_ener_fx = 0;
move16();
- if ( EQ_16( st->last_codec_mode, MODE1 ) )
+ IF( EQ_16( st->last_codec_mode, MODE1 ) )
{
- st->mem_bpf_fx.lp_error = L_deposit_l( 0 );
+ st->mem_bpf_fx.lp_error = 0;
move32();
st->pst_mem_deemp_err_fx = 0;
move16();
@@ -1195,7 +981,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 d35a443d82a1d25aa937d8e2012a071d0f676c1f..f6b5b5984d61e51db4559eaf62c1f4ec2a63b8ae 100644
--- a/lib_enc/core_enc_init_fx.c
+++ b/lib_enc/core_enc_init_fx.c
@@ -63,6 +63,7 @@ void init_coder_ace_plus_fx(
/* Core Sampling Rate */
st->sr_core = getCoreSamplerateMode2( st->element_mode, st->total_brate, st->bwidth, st->flag_ACELP16k, st->rf_mode, st->is_ism_format );
st->fscale = sr2fscale( st->sr_core );
+ move32();
move16();
/* Narrowband? */
@@ -77,12 +78,13 @@ void init_coder_ace_plus_fx(
/* Core Framing */
L_frame_old = st->last_L_frame;
move16();
- st->L_frame = extract_l( Mult_32_16( st->sr_core, 0x0290 ) );
+ st->L_frame = extract_l( Mult_32_16( st->sr_core, 0x0290 /* 1/FRAMES_PER_SEC in Q15*/ ) );
st->L_frame_past = -1;
move16();
+ move16();
- hTcxEnc->L_frameTCX = extract_l( Mult_32_16( st->input_Fs, 0x0290 ) );
-
+ hTcxEnc->L_frameTCX = extract_l( Mult_32_16( st->input_Fs, 0x0290 /* 1/FRAMES_PER_SEC in Q15*/ ) );
+ move16();
st->nb_subfr = NB_SUBFR;
move16();
L_subfr = shr( st->L_frame, 2 );
@@ -112,7 +114,7 @@ void init_coder_ace_plus_fx(
/* Initialize TBE */
hBWE_TD->prev_coder_type = GENERIC;
move16();
- set16_fx( hBWE_TD->prev_lsf_diff_fx, 16384, LPC_SHB_ORDER - 2 );
+ set16_fx( hBWE_TD->prev_lsf_diff_fx, 16384 /*.5f Q15*/, LPC_SHB_ORDER - 2 );
hBWE_TD->prev_tilt_para_fx = 0;
move16();
set16_fx( hBWE_TD->cur_sub_Aq_fx, 0, M + 1 );
@@ -149,8 +151,9 @@ void init_coder_ace_plus_fx(
if ( st->hIGFEnc != NULL )
{
st->hIGFEnc->infoStopFrequency = -1;
+ move16();
}
- move16();
+
IF( st->igf )
{
IGFEncSetMode_fx( st->hIGFEnc, st->total_brate, st->bwidth, st->element_mode, st->rf_mode );
@@ -158,9 +161,11 @@ void init_coder_ace_plus_fx(
ELSE IF( st->hIGFEnc != NULL )
{
st->hIGFEnc->infoTotalBitsWritten = 0;
+ move16();
if ( EQ_16( MCT_flag, -10 ) )
{
st->hIGFEnc->infoTotalBitsPerFrameWritten = 0;
+ move16();
}
/* the line above is needed for some transition, but when going from low rate to high rate, ex 7k2 to 96k, EVS fix point doesn't do the reset (or it does somewhere else */
}
@@ -209,7 +214,6 @@ void init_coder_ace_plus_fx(
/* Initialize DTX */
IF( st->ini_frame == 0 )
{
-
vad_init_fx( &st->vad_st );
}
@@ -269,8 +273,8 @@ void init_coder_ace_plus_fx(
move16();
move16();
move16(); /* casts */
- st->mean_gc[0] = L_deposit_h( 0 );
- st->mean_gc[1] = L_deposit_h( 0 );
+ st->mean_gc[0] = 0;
+ st->mean_gc[1] = 0;
st->prev_lsf4_mean = 0;
move16();
@@ -314,7 +318,7 @@ static void init_tcx_fx(
st->hTcxCfg->lfacNext = sub( st->hTcxCfg->tcx_offset, shr( st->L_frame, 2 ) );
move16();
st->hTcxCfg->lfacNextFB = sub( st->hTcxCfg->tcx_offsetFB, shr( hTcxEnc->L_frameTCX, 2 ) );
-
+ move16();
IF( st->ini_frame == 0 )
{
st->hTcxCfg->tcx_curr_overlap_mode = st->hTcxCfg->tcx_last_overlap_mode = ALDO_WINDOW;
@@ -375,7 +379,7 @@ static void init_tcx_fx(
/* TCX-LTP */
hTcxEnc->tcxltp = getTcxLtp( st->sr_core );
-
+ move16();
test();
test();
test();
@@ -392,7 +396,7 @@ static void init_tcx_fx(
hTcxEnc->tcxltp_norm_corr_past = 0;
move16();
}
- ELSE IF( NE_16( st->L_frame, L_frame_old ) && !( ( st->total_brate == 16400 || st->total_brate == 24400 ) && ( st->total_brate == st->last_total_brate ) && ( st->last_bwidth == st->bwidth ) ) )
+ ELSE IF( NE_16( st->L_frame, L_frame_old ) && !( ( EQ_32( st->total_brate, 16400 ) || EQ_32( st->total_brate, 24400 ) ) && ( EQ_32( st->total_brate, st->last_total_brate ) ) && ( EQ_32( st->last_bwidth, st->bwidth ) ) ) )
{
Word16 pitres, pitres_old;
Word16 pit, pit_old;
@@ -416,18 +420,13 @@ 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;
move16();
- move16();
hTcxEnc->tcxltp_pitch_fr_past = i_mult2( sub( pit, hTcxEnc->tcxltp_pitch_int_past ), pitres );
move16();
}
@@ -444,8 +443,9 @@ static void init_tcx_fx(
}
st->hTcxCfg->ctx_hm = getCtxHm( st->element_mode, st->total_brate, st->rf_mode );
-
+ move16();
hTcxEnc->tcx_lpc_shaped_ari = getTcxLpcShapedAri( st->total_brate, st->rf_mode, st->element_mode );
+ move16();
}
void init_sig_buffers_fx( Encoder_State *st, const Word16 L_frame_old, const Word16 L_subfr )
@@ -485,14 +485,14 @@ void init_sig_buffers_fx( Encoder_State *st, const Word16 L_frame_old, const Wor
Copy( st->buf_speech_enc, hTcxEnc->buf_speech_ltp, st->L_frame );
}
- 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 ) );
+ 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 ) ); // Q(prev_Q_new)
/*Resamp buffers needed only for ACELP*/
test();
test();
IF( EQ_16( st->L_frame, L_FRAME ) && !st->tcxonly )
{
- Copy_Scale_sig( st->old_inp_12k8_fx, st->buf_speech_enc_pe + st->L_frame - L_INP_MEM, L_INP_MEM, sub( st->prev_Q_new, st->prev_Q_old ) );
+ Copy_Scale_sig( st->old_inp_12k8_fx, st->buf_speech_enc_pe + st->L_frame - L_INP_MEM, L_INP_MEM, sub( st->prev_Q_new, st->prev_Q_old ) ); // Q(prev_Q_new)
}
ELSE IF( EQ_16( st->L_frame, L_FRAME16k ) && !st->tcxonly )
{
@@ -509,7 +509,7 @@ void init_sig_buffers_fx( Encoder_State *st, const Word16 L_frame_old, const Wor
ELSE IF( !st->tcxonly && GE_32( st->last_total_brate, ACELP_32k ) )
{
- 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 ) );
+ 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 ) ); // Q(prev_Q_new)
/*Resamp buffers needed only for ACELP*/
IF( EQ_16( st->L_frame, L_FRAME16k ) )
@@ -608,7 +608,7 @@ static void init_acelp_fx( Encoder_State *st, Word16 L_frame_old, const Word16 s
/* Init pitch lag */
st->pit_res_max = initPitchLagParameters( st->sr_core, &st->pit_min, &st->pit_fr1, &st->pit_fr1b, &st->pit_fr2, &st->pit_max );
-
+ move16();
/* Init LPDmem */
IF( st->ini_frame == 0 )
@@ -671,6 +671,8 @@ static void init_acelp_fx( Encoder_State *st, Word16 L_frame_old, const Word16 s
/* unquantized LPC*/
test();
+ test();
+ test();
IF( !( ( EQ_32( st->total_brate, ACELP_16k40 ) || EQ_32( st->total_brate, ACELP_24k40 ) ) && ( EQ_32( st->total_brate, st->last_total_brate ) ) && ( EQ_16( st->last_bwidth, st->bwidth ) ) ) )
{
Copy( st->lsp_old1_fx, st->lspold_enc_fx, M ); /*lsp old @12.8kHz*/
@@ -693,6 +695,8 @@ static void init_acelp_fx( Encoder_State *st, Word16 L_frame_old, const Word16 s
st->hTcxCfg->last_aldo = 1; /*It was previously ALDO*/
st->hTcxCfg->tcx_curr_overlap_mode = ALDO_WINDOW;
+ move16();
+ move16();
/*ALDO overlap windowed past: also used in MODE1 but for other MDCT-FB*/
set16_fx( hTcxEnc->old_out_fx, 0, st->L_frame );
}
@@ -704,6 +708,7 @@ static void init_acelp_fx( Encoder_State *st, Word16 L_frame_old, const Word16 s
{
/* convert quantized LSP vector */
st->rate_switching_reset = lsp_convert_poly_fx( st->lsp_old_fx, st->L_frame, 0 );
+ move16();
IF( st->tcxonly == 0 )
{
lsp2lsf_fx( st->lsp_old_fx, st->lsf_old_fx, M, st->sr_core );
@@ -737,11 +742,8 @@ 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();
}
}
ELSE IF( ( NE_16( st->L_frame, L_frame_old ) ) )
@@ -804,7 +806,8 @@ static void init_acelp_fx( Encoder_State *st, Word16 L_frame_old, const Word16 s
}
/* Post-processing */
- hLPDmem->dm_fx.prev_gain_code = L_deposit_l( 0 );
+ hLPDmem->dm_fx.prev_gain_code = 0;
+ move32();
set16_fx( hLPDmem->dm_fx.prev_gain_pit, 0, 6 );
hLPDmem->dm_fx.prev_state = 0;
@@ -815,7 +818,8 @@ static void init_acelp_fx( Encoder_State *st, Word16 L_frame_old, const Word16 s
/* Pulse Search configuration */
st->acelp_autocorr = 1;
move16();
-
+ test();
+ test();
/*Use for 12.8 kHz sampling rate and low bitrates, the conventional pulse search->better SNR*/
if ( ( LE_32( st->total_brate, ACELP_9k60 ) || st->rf_mode != 0 ) && ( EQ_32( st->sr_core, 12800 ) ) )
{
@@ -827,10 +831,12 @@ static void init_acelp_fx( Encoder_State *st, Word16 L_frame_old, const Word16 s
/*BPF parameters for adjusting gain in function of background noise*/
IF( EQ_16( st->codec_mode, MODE2 ) )
{
- st->mem_bpf_fx.lp_error_ener = L_deposit_l( 0 );
- if ( st->last_codec_mode == MODE1 )
+ st->mem_bpf_fx.lp_error_ener = 0;
+ move32();
+ if ( EQ_16( st->last_codec_mode, MODE1 ) )
{
- st->mem_bpf_fx.lp_error = L_deposit_l( 0 );
+ st->mem_bpf_fx.lp_error = 0;
+ move32();
}
}
@@ -889,13 +895,15 @@ static void init_modes_fx(
assert( st->fscale == 2 * st->L_frame ); /* this assumption is true if operated in 20ms frames with FSCALE_DENOM == 512, which is the current default */
tmp32 = L_shl( st->total_brate, 1 ); /* (float)st->L_frame/(float)st->fscale * (float)FSCALE_DENOM/128.0f * (float)st->bitrate */
st->bits_frame_nominal = extract_l( L_shr( Mpy_32_16_1( tmp32, 20972 ), 6 ) ); /* 20972 = 0.01 * 64 * 32768 */
-
+ move16();
IF( st->Opt_AMR_WB )
{
st->bits_frame = st->bits_frame_nominal;
st->bits_frame_core = st->bits_frame_nominal;
st->frame_size_index = 0;
move16();
+ move16();
+ move16();
}
ELSE
{
diff --git a/lib_enc/core_enc_ol_fx.c b/lib_enc/core_enc_ol_fx.c
index 89bd8b524b280bc48093e3f6c748206effec488b..04857c334d7130aa8b298baaa0bdb78f8cd5e82e 100644
--- a/lib_enc/core_enc_ol_fx.c
+++ b/lib_enc/core_enc_ol_fx.c
@@ -33,12 +33,12 @@ static void BITS_ALLOC_TCX_config_rf( Word16 *rf_frame_type, Word16 *rf_target_b
void core_encode_openloop_fx(
Encoder_State *st, /* i/o: encoder state structure */
const Word16 coder_type, /* i : coding type */
- const Word16 Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes*/
- const Word16 *lsp_new, /* i : LSPs at the end of the frame */
- const Word16 *lsp_mid, /* i : LSPs at the middle of the frame */
- Word16 *pitch_buf, /* i/o: floating pitch values for each subfr*/
- Word16 *voice_factors, /* o : voicing factors */
- Word16 *ptr_bwe_exc, /* o : excitation for SWB TBE */
+ const Word16 Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes */
+ const Word16 *lsp_new, /* i : LSPs at the end of the frame Q15*/
+ const Word16 *lsp_mid, /* i : LSPs at the middle of the frame Q15*/
+ Word16 *pitch_buf, /* i/o: floating pitch values for each subfr Q6*/
+ Word16 *voice_factors, /* o : voicing factors Q15*/
+ Word16 *ptr_bwe_exc, /* o : excitation for SWB TBE Qexc*/
const Word16 vad_hover_flag,
const Word16 vad_flag_dtx,
Word16 Q_new,
@@ -86,6 +86,7 @@ void core_encode_openloop_fx(
#endif
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc;
RF_ENC_HANDLE hRF = st->hRF;
@@ -123,23 +124,26 @@ void core_encode_openloop_fx(
/* back up LPD mem_w0 target generation memory */
hRF->rf_mem_w0 = hLPDmem->mem_w0;
-
+ move16();
/* back up clip gain memory */
Copy( st->clip_var_fx, hRF->rf_clip_var, 6 );
/* back up tilt code */
hRF->rf_tilt_code = hLPDmem->tilt_code;
-
+ move16();
/* back up dispMem */
hRF->rf_dm_fx.prev_state = hLPDmem->dm_fx.prev_state;
+ move16();
hRF->rf_dm_fx.prev_gain_code = hLPDmem->dm_fx.prev_gain_code;
+ move32();
FOR( i = 0; i < 6; i++ )
{
hRF->rf_dm_fx.prev_gain_pit[i] = hLPDmem->dm_fx.prev_gain_pit[i];
+ move16();
}
/* back up gc_threshold for noise addition */
hRF->rf_gc_threshold = hLPDmem->gc_threshold;
-
+ move32();
/* initialization */
tcx_lpc_cdk = 0;
@@ -233,7 +237,7 @@ void core_encode_openloop_fx(
/* calculate target bits for core coding */
target_bits = sub( target_bits, st->rf_target_bits_write );
}
- IF( st->igf != 0 )
+ if ( st->igf != 0 )
{
target_bits = sub( target_bits, get_tbe_bits_fx( st->total_brate, st->bwidth, st->rf_mode ) );
}
@@ -249,7 +253,7 @@ void core_encode_openloop_fx(
}
/* reset TBE buffers previous frame frame wasn't ACELP*/
- IF( NE_16( st->last_core, ACELP_CORE ) )
+ IF( st->last_core != ACELP_CORE )
{
TBEreset_enc_fx( st, st->bwidth );
}
@@ -261,6 +265,7 @@ void core_encode_openloop_fx(
IF( st->hPlcExt )
{
st->glr_idx[0] = encSideSpecPowDiffuseDetector_fx( st->hPlcExt->last_lsf_ref, st->hPlcExt->last_lsf_con, st->last_sr_core, &( st->prev_lsf4_mean ), (Word8) st->glr, coder_type );
+ move16();
Copy( lsf_q, st->hPlcExt->last_lsf_ref, M );
Copy( st->hPlcExt->lsf_con, st->hPlcExt->last_lsf_con, M );
@@ -272,12 +277,11 @@ void core_encode_openloop_fx(
st->glr_idx[0] = 0;
}
move16();
- move16();
st->hPlcExt->LPDmem = hLPDmem;
encoderSideLossSimulation_fx( st, st->hPlcExt, lsf_q, stab_fac, st->hPlcExt->calcOnlylsf, st->L_frame );
}
st->last_stab_fac = stab_fac;
-
+ move16();
hTcxEnc->tcxltp_norm_corr_past = st->voicing_fx[1];
move16();
@@ -355,7 +359,7 @@ void core_encode_openloop_fx(
/* Account for core signaling bits difference: bandwidth and ACELP/TCX signaling bit are replaced */
target_bits = add( target_bits, sub( add( FrameSizeConfig[st->frame_size_index].bandwidth_bits, 1 ), signalling_mode1_tcx20_enc_fx( st, 0 ) ) );
}
- ELSE if ( EQ_16( st->mdct_sw_enable, MODE2 ) )
+ ELSE IF( EQ_16( st->mdct_sw_enable, MODE2 ) )
{
target_bits = sub( target_bits, 1 );
}
@@ -396,7 +400,6 @@ void core_encode_openloop_fx(
coder_tcx_post_fx( st, hLPDmem, st->hTcxCfg, st->synth, A_q, Aw, st->wspeech_enc, Q_new, shift );
- move16();
IF( st->hPlcExt )
{
st->hPlcExt->LPDmem = hLPDmem;
@@ -430,7 +433,9 @@ void core_encode_openloop_fx(
lsf_update_memory( st->narrowBand, st->lsf_old_fx, st->mem_MA_fx, st->mem_MA_fx, M );
st->pstreaklen = 0;
- st->streaklimit_fx = 32767;
+ st->streaklimit_fx = 32767; /*1 Q15*/
+ move16();
+ move16();
/* check resonance for pitch clipping algorithm */
gp_clip_test_lsf_fx( st->element_mode, st->lsf_old_fx, st->clip_var_fx, 0 );
Copy( st->lsf_old_fx, st->mem_AR_fx, M );
@@ -447,6 +452,8 @@ void core_encode_openloop_fx(
*--------------------------------------------------------------*/
IF( st->Opt_DTX_ON != 0 )
{
+ test();
+ test();
/* update CNG parameters in active frames */
IF( EQ_16( st->bwidth, NB ) && st->enableTcxLpc && st->core != ACELP_CORE )
{
@@ -454,6 +461,7 @@ void core_encode_openloop_fx(
assert( st->L_frame == L_FRAME );
Copy( st->synth + L_FRAME - L_LP, buf, L_LP );
tmp = st->synth[L_FRAME - L_LP - 1];
+ move16();
E_UTIL_f_preemph2( Q_new - 1, buf, st->preemph_fac, L_LP, &tmp );
autocorr_fx( buf, M, r_h, r_l, &Q_r, L_LP, Assym_window_W16fx, 0, 0 );
lag_wind( r_h, r_l, M, INT_FS_FX, LAGW_WEAK );
@@ -501,12 +509,13 @@ void core_encode_openloop_fx(
*---------------------------------------------------------------*/
test();
- IF( GT_16( st->core, ACELP_CORE ) || ( st->rate_switching_reset != 0 ) )
+ IF( ( st->core > ACELP_CORE ) || ( st->rate_switching_reset != 0 ) )
{
/*TCX mode: copy values*/
set16_fx( st->mem_bpf_fx.noise_buf, 0, 2 * L_FILT16k ); /*TCX->no gain*/
set16_fx( st->mem_bpf_fx.error_buf, 0, L_FILT16k ); /*TCX->no gain*/
st->bpf_gain_param = 0;
+ move16();
}
ELSE IF( st->acelp_cfg.bpf_mode > 0 )
{
@@ -532,7 +541,7 @@ void core_encode_openloop_fx(
IF( EQ_16( st->rf_mode, 1 ) )
{
set16_fx( lsf_q_1st_rf, 0, M );
- IF( EQ_16( st->core, ACELP_CORE ) )
+ IF( st->core == ACELP_CORE )
{
/* convert LSPs to LP coefficients */
lsp2lsf_fx( lsp_new, lsf_uq_rf, M, st->sr_core );
@@ -541,14 +550,12 @@ void core_encode_openloop_fx(
/* first stage VQ, 8 bits; reuse TCX high rate codebook */
hRF->rf_indx_lsf[0][0] = vlpc_1st_cod_fx( lsf_uq_rf, lsf_q_1st_rf, w_rf, st->rf_mode );
+ move16();
/*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*/
}
@@ -567,6 +574,7 @@ void core_encode_openloop_fx(
tmp = lsf_q_diff_cb_8b_rf[i + M * hRF->rf_indx_lsf[0][1]]; /*tmp = quantized lsf_q_d_rf in Q6*/
tmp = shr( mult_r( tmp, 20972 ), 4 ); /* bring lsf_q_d_rf to Qx2.56 for addition */
lsf_q_rf[i] = add( lsf_q_1st_rf[i], tmp );
+ move16();
}
v_sort( lsf_q_rf, 0, M - 1 );
@@ -584,9 +592,12 @@ void core_encode_openloop_fx(
hRF->rf_indx_lsf[0][0] = param_lpc[1];
hRF->rf_indx_lsf[0][1] = param_lpc[2];
hRF->rf_indx_lsf[0][2] = param_lpc[3];
+ move16();
+ move16();
+ move16();
}
- IF( EQ_16( st->core, ACELP_CORE ) )
+ IF( st->core == ACELP_CORE )
{
/* current n-th ACELP frame and its corresponding partial copy */
@@ -608,8 +619,9 @@ void core_encode_openloop_fx(
/* RF frame type in the buffer */
hRF->rf_indx_frametype[0] = hRF->rf_frame_type;
hRF->rf_targetbits_buff[0] = hRF->rf_target_bits;
-
- IF( NE_16( hRF->rf_frame_type, RF_NO_DATA ) )
+ move16();
+ move16();
+ IF( hRF->rf_frame_type != RF_NO_DATA )
{
/* coder_acelp_rf_fx does the partial copy encoding based on the rf frame type chosen for the RF encoding */
coder_acelp_rf_fx( &( hRF->acelp_cfg_rf ), coder_type, Aw, Aq_rf, st->speech_enc_pe, st->voicing_fx, st->pitch,
@@ -651,7 +663,7 @@ void core_encode_openloop_fx(
test();
test();
test();
- IF(
+ if (
( EQ_16( st->core, TCX_20_CORE ) ) /*(st->core == TCX_20_CORE)*/
&& ( EQ_16( st->last_core, TCX_20_CORE ) ) /*&&(st->last_core == TCX_20_CORE)*/
&& ( EQ_16( hRF->rf_second_last_core, TCX_20_CORE ) ) /*&& (st->rf_second_last_core == TCX_20_CORE)*/
@@ -687,10 +699,12 @@ void core_encode_openloop_fx(
LT_16( hRF->rf_gain_tcx[0], mult_r( hRF->rf_gain_tcx[1], 29491 /*0.90f Q15*/ ) ) ) )
{
TD_mode = 0;
+ move16();
}
ELSE
{
TD_mode = 1;
+ move16();
}
/* updates */
@@ -743,6 +757,7 @@ static void closest_centroid_rf(
Word32 L_tmp, best_werr, werr;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
ind_vec[0] = 0;
@@ -758,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 );
@@ -782,12 +792,12 @@ static void closest_centroid_rf(
void core_acelp_tcx20_switching_fx(
Encoder_State *st, /* i/o: encoder state structure */
- Word16 non_staX, /* i : unbound non-stationarity for sp/mu clas */
- Word16 *pitch_fr, /* i/o: fraction pitch values */
- Word16 *voicing_fr, /* i/o: fractional voicing values */
- const Word16 currFlatness, /* i : flatness */
- const Word16 lsp_mid[M], /* i : LSPs at the middle of the frame */
- const Word16 stab_fac, /* i : LP filter stability */
+ Word16 non_staX, /* i : unbound non-stationarity for sp/mu clas Q8*/
+ Word16 *pitch_fr, /* i/o: fraction pitch values Q6*/
+ Word16 *voicing_fr, /* i/o: fractional voicing values Q15*/
+ const Word16 currFlatness, /* i : flatness Q7*/
+ const Word16 lsp_mid[M], /* i : LSPs at the middle of the frame Q15*/
+ const Word16 stab_fac, /* i : LP filter stability Q15*/
Word16 Q_new,
Word16 shift )
{
@@ -818,6 +828,7 @@ void core_acelp_tcx20_switching_fx(
SP_MUS_CLAS_HANDLE hSpMusClas = st->hSpMusClas;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/* Check minimum pitch for quantization */
@@ -920,7 +931,7 @@ void core_acelp_tcx20_switching_fx(
Copy( hTcxEnc->speech_ltp + sub( tcx_offset, shr( overlap, 1 ) ), xn_buf, add( L_frame, overlap ) );
tmp16 = shr( overlap, 1 );
- IF( EQ_16( st->last_core, ACELP_CORE ) )
+ IF( st->last_core == ACELP_CORE )
{
IF( tcx_offset < 0 )
{
@@ -958,7 +969,7 @@ void core_acelp_tcx20_switching_fx(
tmp16 = mult_r( shl( L_frame, 5 ), 29309 /*16*0.0559017 Q15*/ ); /* L_frame / sqrt(2*NORM_MDCT_FACTOR); Q9 */
FOR( i = 0; i < L_frame; i++ )
{
- x[i] = Mpy_32_16_1( x[i], tmp16 );
+ x[i] = Mpy_32_16_1( x[i], tmp16 ); // Q(31-(x_e+6))
move32();
}
x_e = add( x_e, 6 );
@@ -971,7 +982,7 @@ void core_acelp_tcx20_switching_fx(
IF( st->narrowBand )
{
- j = mult( L_frame, 20480 );
+ j = mult( L_frame, 20480 /* .625 Q15*/ );
set32_fx( &x[j], 0, sub( L_frame, j ) );
}
@@ -1094,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 */
@@ -1116,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
/*--------------------------------------------------------------*
@@ -1154,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);*/
@@ -1219,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 ) ||
-#else /* BASOP_NOGLOB */
- ( LT_16( add( st->prevTempFlatness_fx, currFlatness ), 416 /*3.25f Q7*/ ) || EQ_16( stab_fac, 0x7fff ) ||
-#endif
-#ifdef BASOP_NOGLOB
+ ( LT_16( add_o( st->prevTempFlatness_fx, currFlatness, &Overflow ), 416 /*3.25f Q7*/ ) || EQ_16( stab_fac, 0x7fff /*1 Q15*/ ) ||
( 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*/;
@@ -1241,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*/;
@@ -1269,7 +1252,7 @@ void core_acelp_tcx20_switching_fx(
test();
test();
test();
- if ( EQ_32( st->sr_core, INT_FS_12k8 ) && ( offset_tcx < 0x18950F ) && GT_16( non_staX, 1280 /*5.0f Q8*/ ) && ( snr_acelp >= snr_tcx - 1024 /*4.0f in Q8*/ ) && GE_16( st->acelpFramesCount, 1 ) && ( ( GT_16( hSpMusClas->lps_fx, hSpMusClas->lpm_fx ) && GE_16( tmp16, 9830 ) ) || ( GE_16( st->acelpFramesCount, 6 ) && ( hSpMusClas->lps_fx > hSpMusClas->lpm_fx - 768 ) ) ) && ( st->sp_aud_decision0 == 0 ) && st->vad_flag != 0 )
+ if ( EQ_32( st->sr_core, INT_FS_12k8 ) && ( offset_tcx < 0x18950F ) && GT_16( non_staX, 1280 /*5.0f Q8*/ ) && ( GE_16( snr_acelp, sub( snr_tcx, 1024 /*4.0f in Q8*/ ) ) ) && GE_16( st->acelpFramesCount, 1 ) && ( ( GT_16( hSpMusClas->lps_fx, hSpMusClas->lpm_fx ) && GE_16( tmp16, 9830 ) ) || ( GE_16( st->acelpFramesCount, 6 ) && ( GT_16( hSpMusClas->lps_fx, sub( hSpMusClas->lpm_fx, 768 ) ) ) ) ) && ( st->sp_aud_decision0 == 0 ) && st->vad_flag != 0 )
{
/* Fine tuned across various databases based on various metrics to detect TCX frames in speech.*/
dsnr = 1024;
@@ -1296,15 +1279,17 @@ void core_acelp_tcx20_switching_fx(
test();
test();
if ( EQ_32( st->sr_core, INT_FS_12k8 ) && ( LT_16( non_staX, 512 /*2.0f Q8*/ ) || ( st->flag_noisy_speech_snr == 0 && EQ_16( st->vad_flag, 1 ) && ( offset_tcx == L_add( 0xFFD57AB5, 0 ) ) && GE_16( st->acelpFramesCount, 6 ) ) ) &&
- ( st->last_core == ACELP_CORE || st->last_core == TCX_20_CORE ) )
+ ( st->last_core == ACELP_CORE || EQ_16( st->last_core, TCX_20_CORE ) ) )
{
st->core = st->last_core;
+ move16();
}
ELSE IF( GT_16( add( snr_acelp, dsnr ), snr_tcx ) )
{
st->core = ACELP_CORE;
move16();
st->acelpFramesCount = s_min( 32767 - 1, add( st->acelpFramesCount, 1 ) );
+ move16();
}
ELSE
{
@@ -1356,12 +1341,13 @@ void core_acelp_tcx20_switching_fx(
*-------------------------------------------------------------------*/
static void BITS_ALLOC_ACELP_config_rf(
const Word16 coder_type,
- Word16 *tilt_code,
+ Word16 *tilt_code, // Q15
Word16 *rf_frame_type,
Word16 *rf_target_bits,
Word16 nb_subfr,
Word16 rf_fec_indicator,
- Word16 *pitch_buf )
+ Word16 *pitch_buf // Q6
+)
{
Word16 mean_tc, min_tilt_code, max_tilt_code;
Word16 nrgMode, ltfMode, ltpMode, gainsMode;
@@ -1417,6 +1403,10 @@ static void BITS_ALLOC_ACELP_config_rf(
IF( EQ_16( rf_fec_indicator, 1 ) )
{
+ test();
+ test();
+ test();
+ test();
test();
test();
test();
@@ -1434,6 +1424,10 @@ static void BITS_ALLOC_ACELP_config_rf(
}
ELSE
{
+ test();
+ test();
+ test();
+ test();
test();
test();
test();
@@ -1456,41 +1450,52 @@ static void BITS_ALLOC_ACELP_config_rf(
/* rf_mode, 1 bit */
*rf_target_bits = add( *rf_target_bits, 1 );
-
+ move16();
/* rf_fec_offset 2 bits */
*rf_target_bits = add( *rf_target_bits, 2 );
-
+ move16();
/* rf_frame_type, 3 bits */
*rf_target_bits = add( *rf_target_bits, 3 );
-
+ move16();
/* LSF bits 8 + 8 bits */
*rf_target_bits = add( *rf_target_bits, 16 );
-
+ move16();
/* Intialize the RF mode frame type to all-pred */
*rf_frame_type = RF_ALLPRED;
-
+ move16();
+ test();
test();
- IF( EQ_16( coder_type, INACTIVE ) || en_partial_red == 0 )
+ test();
+ test();
+ IF( coder_type == INACTIVE || en_partial_red == 0 )
{
*rf_frame_type = RF_NO_DATA;
+ move16();
}
- ELSE IF( EQ_16( coder_type, UNVOICED ) || EQ_16( coder_type, INACTIVE ) )
+ ELSE IF( EQ_16( coder_type, UNVOICED ) || ( coder_type == INACTIVE ) )
{
*rf_frame_type = RF_NELP;
+ move16();
}
ELSE IF( EQ_16( coder_type, GENERIC ) && LT_16( max_tilt_code, 1638 /*0.05f Q15*/ ) )
{
*rf_frame_type = RF_NOPRED;
+ move16();
}
ELSE IF( EQ_16( coder_type, GENERIC ) && LT_16( mean_tc, 9830 /*0.3f Q15*/ ) )
{
*rf_frame_type = RF_GENPRED;
+ move16();
}
nrgMode = ACELP_NRG_MODE[1][1][*rf_frame_type];
ltfMode = ACELP_LTF_MODE[1][1][*rf_frame_type];
ltpMode = ACELP_LTP_MODE[1][1][*rf_frame_type];
gainsMode = ACELP_GAINS_MODE[1][1][*rf_frame_type];
+ move16();
+ move16();
+ move16();
+ move16();
/* Number of RF bits for different RF coder types */
SWITCH( *rf_frame_type )
@@ -1499,6 +1504,7 @@ static void BITS_ALLOC_ACELP_config_rf(
/* Es_pred bits 3 bits, LTF: 1, pitch: 8,5,5,5, FCB: 0, gain: 7,0,7,0, Diff GFr: 4*/
*rf_target_bits += ( ACELP_NRG_BITS[nrgMode] + ACELP_LTF_BITS[ltfMode] + ACELP_LTP_BITS_SFR[ltpMode][0] + ACELP_LTP_BITS_SFR[ltpMode][1] + ACELP_LTP_BITS_SFR[ltpMode][2] + ACELP_LTP_BITS_SFR[ltpMode][3] + ACELP_GAINS_BITS[gainsMode] + ACELP_GAINS_BITS[gainsMode] + 2 /*2 bits for PartialCopy GainFrame*/
);
+ move16();
BREAK;
case RF_NOPRED:
@@ -1506,6 +1512,7 @@ static void BITS_ALLOC_ACELP_config_rf(
/*bits += (3 + 0 + 0 + 28 + 12 + 2); */ /* 64 rf bits */
*rf_target_bits += ( ACELP_NRG_BITS[nrgMode] + ACELP_LTF_BITS[ltfMode] + 28 + ACELP_GAINS_BITS[gainsMode] + ACELP_GAINS_BITS[gainsMode] + 2 /*2 bits for PartialCopy GainFrame*/
);
+ move16();
BREAK;
case RF_GENPRED:
@@ -1513,16 +1520,19 @@ static void BITS_ALLOC_ACELP_config_rf(
/*bits += (3 + 0 + 16 + 23 + 10 + 0); */ /* 72 rf bits */
*rf_target_bits += ( ACELP_NRG_BITS[nrgMode] + ACELP_LTF_BITS[ltfMode] + ACELP_LTP_BITS_SFR[ltpMode][0] + ACELP_LTP_BITS_SFR[ltpMode][1] + ACELP_LTP_BITS_SFR[ltpMode][2] + ACELP_LTP_BITS_SFR[ltpMode][3] + 14 + ACELP_GAINS_BITS[gainsMode] + ACELP_GAINS_BITS[gainsMode] + 2 /*2 bits for PartialCopy GainFrame*/
);
+ move16();
BREAK;
case RF_NELP:
/* gain: 19, Diff GFr: 5 */
/*bits += (19 + 5); */
*rf_target_bits += ( 19 + NUM_BITS_SHB_FRAMEGAIN );
+ move16();
BREAK;
case RF_NO_DATA:
*rf_target_bits = 6;
+ move16();
BREAK;
default:
@@ -1553,7 +1563,7 @@ static void BITS_ALLOC_TCX_config_rf(
move16();
test();
- IF( EQ_16( coder_type, INACTIVE ) || EQ_16( last_core, ACELP_CORE ) )
+ IF( ( coder_type == INACTIVE ) || ( last_core == ACELP_CORE ) )
{
*rf_frame_type = RF_NO_DATA;
move16();
diff --git a/lib_enc/core_enc_switch.c b/lib_enc/core_enc_switch.c
index ba842b9ccd1542e261c12e381de5cab619dc2661..e5c3903a1789031ba9481c8f483235735965d117 100644
--- a/lib_enc/core_enc_switch.c
+++ b/lib_enc/core_enc_switch.c
@@ -219,6 +219,8 @@ void core_coder_mode_switch_ivas_fx(
}
st->currEnergyHF_fx = 0;
move32();
+ st->currEnergyHF_e_fx = 0;
+ move16();
Word16 shift = getScaleFactor16( st->old_inp_16k_fx, L_INP_MEM );
Scale_sig( st->old_inp_16k_fx, L_INP_MEM, shift );
st->exp_old_inp_16k = sub( st->exp_old_inp_16k, shift );
diff --git a/lib_enc/core_enc_updt.c b/lib_enc/core_enc_updt.c
index 92a2a7b9e16bca99edaa15efd4e6acc4bdbca01e..95f1c67b6cf9ded0a25f18b7436bb3b776894959 100644
--- a/lib_enc/core_enc_updt.c
+++ b/lib_enc/core_enc_updt.c
@@ -74,7 +74,7 @@ void core_encode_update_ivas_fx(
test();
IF( ( st->core == ACELP_CORE ) || EQ_16( st->core, AMR_WB_CORE ) || EQ_32( st->core_brate, SID_2k40 ) || ( st->core_brate == FRAME_NO_DATA ) )
{
- Word16 max_e = s_max( st->hTcxEnc->exp_buf_speech_ltp, hTcxEnc->exp_buf_speech_ltp );
+ Word16 max_e = s_max( st->hTcxEnc->exp_buf_speech_ltp, st->exp_buf_speech_enc );
Scale_sig( hTcxEnc->buf_speech_ltp, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, negate( sub( max_e, st->hTcxEnc->exp_buf_speech_ltp ) ) ); // Q(31-max_e)
Copy_Scale_sig( st->buf_speech_enc + st->L_frame, hTcxEnc->buf_speech_ltp + st->L_frame, st->L_frame, negate( sub( max_e, st->exp_buf_speech_enc ) ) ); // Q(31-max_e)
st->hTcxEnc->exp_buf_speech_ltp = max_e;
diff --git a/lib_enc/core_switching_enc.c b/lib_enc/core_switching_enc.c
index 1b69de26d8a6fcfbcc65d8b07999bf079d6e867d..d58a60ab26e7f55395ea3d2fc09a63364636e9b0 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 ) )
{
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/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 ee57efffe3b2735dcd2abba7fb1da5d9d236c078..7dd342318b37a54d1208764c72b0d19dfe36d390 100644
--- a/lib_enc/enc_acelp_fx.c
+++ b/lib_enc/enc_acelp_fx.c
@@ -20,19 +20,19 @@
#define _1_ 0x2000 /*Q12*/
#define _1_Q9 0x200
-static void E_ACELP_codearithp_fx( const Word16 v[], UWord32 *n, UWord32 *ps, Word16 *p );
+static void E_ACELP_codearithp_fx( const Word16 v[] /*Q9*/, UWord32 *n /*Q0*/, UWord32 *ps /*Q0*/, Word16 *p /*Q0*/ );
-void E_ACELP_h_vec_corr1( Word16 h[], Word16 vec[], UWord8 track, Word16 sign[], Word16 ( *rrixix )[16], Word16 cor[], Word16 dn2_pos[], Word16 nb_pulse );
+void E_ACELP_h_vec_corr1_fx( Word16 h[] /*Qx*/, Word16 vec[] /*Qx*/, UWord8 track /*Q0*/, Word16 sign[] /*Q15*/, Word16 ( *rrixix )[16] /*Q9*/, Word16 cor[] /*Q9*/, Word16 dn2_pos[] /*Q0*/, Word16 nb_pulse /*Q0*/ );
-void E_ACELP_h_vec_corr2( Word16 h[], Word16 vec[], UWord8 track, Word16 sign[], Word16 ( *rrixix )[16], Word16 cor[] );
+void E_ACELP_h_vec_corr2_fx( Word16 h[] /*Qx*/, Word16 vec[] /*Qx*/, UWord8 track /*Q0*/, Word16 sign[] /*Q15*/, Word16 ( *rrixix )[16] /*Q9*/, Word16 cor[] /*Q9*/ );
-Word16 E_ACELP_xy1_corr( Word16 xn[], Word16 y1[], ACELP_CbkCorr *g_corr, Word16 norm_flag, Word16 L_subfr, Word16 exp_xn );
+Word16 E_ACELP_xy1_corr_fx( Word16 xn[] /*Q15-exp_xn*/, Word16 y1[] /*Q15-exp_xn*/, ACELP_CbkCorr *g_corr, Word16 norm_flag /*Q0*/, Word16 L_subfr /*Q0*/, Word16 exp_xn );
-void E_ACELP_codebook_target_update( Word16 *x, Word16 *x2, Word16 *y, Word16 gain, Word16 L_subfr );
+void E_ACELP_codebook_target_update_fx( Word16 *x /*Q_xn*/, Word16 *x2 /*Q_xn*/, Word16 *y /*Q_xn*/, Word16 gain /*Q14*/, Word16 L_subfr /*Q0*/ );
-void E_ACELP_vec_neg( Word16 h[], Word16 h_inv[], Word16 L_subfr );
+void E_ACELP_vec_neg_fx( Word16 h[] /*Qx*/, Word16 h_inv[] /*Qx*/, Word16 L_subfr /*Q0*/ );
-void E_ACELP_corrmatrix( Word16 h[], Word16 sign[], Word16 vec[], Word16 rrixix[4][16], Word16 rrixiy[4][256] );
+void E_ACELP_corrmatrix_fx( Word16 h[] /*Q12*/, Word16 sign[] /*Q0*/, Word16 vec[] /*Q15*/, Word16 rrixix[4][16] /*Q9*/, Word16 rrixiy[4][256] /*Q9*/ );
/*
* E_ACELP_h_vec_corrx
@@ -51,7 +51,7 @@ void E_ACELP_corrmatrix( Word16 h[], Word16 sign[], Word16 vec[], Word16 rrixix[
* Returns:
* void
*/
-void E_ACELP_h_vec_corr1( Word16 h[], Word16 vec[], UWord8 track, Word16 sign[], Word16 ( *rrixix )[16], Word16 cor[], Word16 dn2_pos[], Word16 nb_pulse )
+void E_ACELP_h_vec_corr1_fx( Word16 h[] /*Qx*/, Word16 vec[] /*Qx*/, UWord8 track /*Q0*/, Word16 sign[] /*Q15*/, Word16 ( *rrixix )[16] /*Q9*/, Word16 cor[] /*Q9*/, Word16 dn2_pos[] /*Q0*/, Word16 nb_pulse /*Q0*/ )
{
Word16 i, j;
Word16 dn, corr;
@@ -60,109 +60,79 @@ void E_ACELP_h_vec_corr1( Word16 h[], Word16 vec[], UWord8 track, Word16 sign[],
Word32 L_sum;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
- dn2 = &dn2_pos[shl( track, 3 )];
- p0 = rrixix[track];
+ dn2 = &dn2_pos[( track * 8 )]; /*Q0*/
+ p0 = rrixix[track]; /*Q9*/
FOR( i = 0; i < nb_pulse; i++ )
{
- dn = dn2[i];
+ dn = dn2[i]; /*Q0*/
move16();
L_sum = L_deposit_l( 0 );
- p1 = h;
- p2 = &vec[dn];
+ p1 = h; /*Qx*/
+ 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 );
-#else
- L_sum = L_mac( L_sum, *p1++, *p2++ );
-#endif
+ L_sum = L_mac_o( L_sum, *p1++, *p2++, &Overflow ); /*2*Qx+1*/
}
-#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 );
-#else
- corr = add( p0[j], corr );
-#endif
+ corr = add_o( p0[j], corr, &Overflow ); /*Q9*/
}
if ( sign[dn] < 0 )
{
-#ifdef BASOP_NOGLOB
- corr = sub_o( p0[j], corr, &Overflow );
-#else /* BASOP_NOGLOB */
- corr = sub( p0[j], corr );
-#endif /* BASOP_NOGLOB */
+ corr = sub_o( p0[j], corr, &Overflow ); /*Q9*/
}
- cor[j] = corr;
+ cor[j] = corr; /*Q9*/
move16();
}
return;
}
-void E_ACELP_h_vec_corr2( Word16 h[], Word16 vec[], UWord8 track, Word16 sign[], Word16 ( *rrixix )[16], Word16 cor[] )
+void E_ACELP_h_vec_corr2_fx( Word16 h[] /*Qx*/, Word16 vec[] /*Qx*/, UWord8 track /*Q0*/, Word16 sign[] /*Q15*/, Word16 ( *rrixix )[16] /*Q9*/, Word16 cor[] /*Q9*/ )
{
Word16 i, j, pos, corr;
Word16 *p0, *p1, *p2;
Word32 L_sum;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
- p0 = rrixix[track];
+ p0 = rrixix[track]; /*Q9*/
- pos = track;
+ pos = track; /*Q0*/
move16();
FOR( i = 0; i < 16; i++ )
{
L_sum = L_deposit_l( 0 );
- p1 = h;
- p2 = &vec[pos];
+ p1 = h; /*Qx*/
+ 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 );
-#else
- L_sum = L_mac( L_sum, *p1++, *p2++ );
-#endif
+ L_sum = L_mac_o( L_sum, *p1++, *p2++, &Overflow ); /* 2*Qx+1 */
}
-#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 );
-#else
- corr = add( *p0++, corr );
-#endif
+ corr = add_o( *p0++, corr, &Overflow ); /*Q9*/
}
if ( sign[pos] < 0 )
{
-#ifdef BASOP_NOGLOB
- corr = sub_o( *p0++, corr, &Overflow );
-#else
- corr = sub( *p0++, corr );
-#endif
+ corr = sub_o( *p0++, corr, &Overflow ); /*Q9*/
}
- cor[i] = corr;
+ cor[i] = corr; /*Q9*/
move16();
pos = add( pos, 4 );
@@ -194,7 +164,7 @@ void E_ACELP_h_vec_corr2( Word16 h[], Word16 vec[], UWord8 track, Word16 sign[],
* Returns:
* void
*/
-static void E_ACELP_2pulse_search( Word16 nb_pos_ix, UWord8 track_x, UWord8 track_y, Word16 *ps, Word16 *alp, Word16 *ix, Word16 *iy, Word16 dn[], Word16 *dn2, Word16 cor_x[], Word16 cor_y[], Word16 ( *rrixiy )[256] )
+static void E_ACELP_2pulse_search( Word16 nb_pos_ix /*Q0*/, UWord8 track_x /*Q0*/, UWord8 track_y /*Q0*/, Word16 *ps /*Qdn*/, Word16 *alp /*Qx*/, Word16 *ix /*Q0*/, Word16 *iy /*Q0*/, Word16 dn[] /*Qdn*/, Word16 *dn2 /*Q0*/, Word16 cor_x[] /*Qx*/, Word16 cor_y[] /*Qx*/, Word16 ( *rrixiy )[256] /*Q9*/ )
{
Word16 x, x2, y, i, *pos_x;
Word16 ps0, ps1, alp2_16, ps2, sq;
@@ -203,78 +173,68 @@ static void E_ACELP_2pulse_search( Word16 nb_pos_ix, UWord8 track_x, UWord8 trac
Word16 sqk[2], alpk[2], ik;
Word32 xy_save;
Word16 check = 0; /* debug code not instrumented */
+
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/* eight dn2 max positions per track */
/*pos_x = &dn2[track_x << 3]; SHIFT(1); PTR_INIT(1);*/
- pos_x = &dn2[shl( track_x, 3 )];
+ pos_x = &dn2[( track_x * 8 )]; /*Qdn*/
move16();
/* save these to limit memory searches */
- alp0 = L_deposit_h( *alp );
- ps0 = *ps;
+ alp0 = L_deposit_h( *alp ); /*Qx-16*/
+ ps0 = *ps; /*Qdn*/
move16();
alpk[0] = 1;
move16();
sqk[0] = -1;
move16();
- x2 = shr( pos_x[0], 2 );
-#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][shl( x2, 4 )], _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 */
+ x2 = shr( pos_x[0], 2 ); /*Qdn*/
+ 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 )
{
sqk[0] = 1;
move16();
}
ik = 0;
move16();
- xy_save = L_mac0( L_deposit_l( track_y ), track_x, L_SUBFR );
+ xy_save = L_mac0( L_deposit_l( track_y ), track_x, L_SUBFR ); /*Q0*/
/* loop track 1 */
FOR( i = 0; i < nb_pos_ix; i++ )
{
- x = pos_x[i];
+ x = pos_x[i]; /*Qdn*/
move16();
x2 = shr( x, 2 );
/* dn[x] has only nb_pos_ix positions saved */
/*ps1 = ps0 + dn[x];*/
- ps1 = add( ps0, dn[x] );
+ 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;
- p2 = &rrixiy[track_x][shl( x2, 4 )];
+ p1 = cor_y; /*Qx*/
+ p2 = &rrixiy[track_x][( x2 * 16 )]; /*Q9*/
FOR( y = track_y; y < L_SUBFR; y += 4 )
{
/*ps2 = ps1 + dn[y];*/
- ps2 = add( ps1, dn[y] );
+ ps2 = add( ps1, dn[y] ); /*Qdn*/
+ move16();
/*alp2 = alp1 + (*p1++) + (*p2++);*/
-#ifdef BASOP_NOGLOB
- alp2 = L_mac_o( alp1, *p1++, _1_, &Overflow );
+ 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;
+ alpk[1 - ik] = alp2_16; /*Q6*/
move16();
/*sq = ps2 * ps2;*/
- sq = mult( ps2, ps2 );
- sqk[1 - ik] = sq;
+ sq = mult( ps2, ps2 ); /*2*Qdn+1*/
+ sqk[1 - ik] = sq; /*2*Qdn+1*/
move16();
/*s = (alpk[ik] * sq) - (sqk[0] * alp2);*/
@@ -283,28 +243,30 @@ static void E_ACELP_2pulse_search( Word16 nb_pos_ix, UWord8 track_x, UWord8 trac
if ( s > 0 )
{
ik = sub( 1, ik );
+ move16();
check = 1; /* debug code not instrumented */
+ move16();
}
if ( s > 0 )
{
- xy_save = L_mac0( y, x, L_SUBFR );
+ xy_save = L_mac0( y, x, L_SUBFR ); /*Qdn*/
}
}
}
assert( check ); /* debug code not instrumented */
- ps2 = extract_l( xy_save );
- *iy = s_and( ps2, L_SUBFR - 1 );
+ ps2 = extract_l( xy_save ); /*Qdn*/
+ *iy = s_and( ps2, L_SUBFR - 1 ); /*Q0*/
move16();
- *ix = lshr( ps2, 6 );
+ *ix = lshr( ps2, 6 ); /*Q0*/
move16();
/**ps = ps0 + dn[*ix] + dn[*iy];*/
- *ps = add( ps0, add( dn[*ix], dn[*iy] ) );
+ *ps = add( ps0, add( dn[*ix], dn[*iy] ) ); /*Qdn*/
move16();
- *alp = alpk[ik];
+ *alp = alpk[ik]; /*Q6*/
move16();
return;
}
@@ -330,12 +292,12 @@ static void E_ACELP_2pulse_search( Word16 nb_pos_ix, UWord8 track_x, UWord8 trac
* void
*/
static void E_ACELP_1pulse_search( UWord8 tracks[2],
- Word16 *ps,
- Word16 *alp,
- Word16 *ix,
- Word16 dn[],
- Word16 cor_x[],
- Word16 cor_y[] )
+ Word16 *ps, /*Qdn*/
+ Word16 *alp, /*Qx*/
+ Word16 *ix, /*Q0*/
+ Word16 dn[], /*Qdn*/
+ Word16 cor_x[], /*Q6*/
+ Word16 cor_y[] /*Q6*/ )
{
Word16 x, x_save = 0;
Word16 ps0;
@@ -348,14 +310,14 @@ static void E_ACELP_1pulse_search( UWord8 tracks[2],
/* save these to limit memory searches */
alp0 = L_deposit_h( *alp );
- ps0 = *ps;
+ ps0 = *ps; /*Qdn*/
move16();
alpk[0] = 1;
move16();
sqk[0] = -1;
move16();
- if ( mac_r_sat( alp0, cor_x[shr( tracks[0], 2 )], _1_ ) < 0 )
+ if ( mac_r_sat( alp0, cor_x[( tracks[0] / 4 )], _1_ ) < 0 )
{
sqk[0] = 1;
move16();
@@ -364,6 +326,7 @@ static void E_ACELP_1pulse_search( UWord8 tracks[2],
move16();
ntracks = 1;
+ move16();
if ( NE_16( tracks[1], tracks[0] ) )
{
ntracks = 2;
@@ -379,16 +342,16 @@ static void E_ACELP_1pulse_search( UWord8 tracks[2],
FOR( x = tracks[t]; x < L_SUBFR; x += 4 )
{
/*ps1 = ps0 + dn[x]; ADD(1);*/
- ps1 = add( ps0, dn[x] );
+ ps1 = add( ps0, dn[x] ); /*Qdn*/
/*alp1 = alp0 + cor_x[x>>2]; SHIFT(1);ADD(1);*/
- alp1 = mac_r_sat( alp0, cor_x[shr( x, 2 )], _1_ ); /*Q6*/
- alpk[1 - ik] = alp1;
+ alp1 = mac_r_sat( alp0, cor_x[( x / 4 )], _1_ ); /*Q6*/
+ alpk[1 - ik] = alp1; /*Q6*/
move16();
/*sq = ps1 * ps1; MULT(1);*/
- sq = mult( ps1, ps1 );
- sqk[1 - ik] = sq;
+ sq = mult( ps1, ps1 ); /*2*Qdn+1*/
+ sqk[1 - ik] = sq; /*2*Qdn+1*/
move16();
/*s = (alpk * sq) - (sqk * alp1); MULT(1);MAC(1); */
@@ -408,11 +371,11 @@ static void E_ACELP_1pulse_search( UWord8 tracks[2],
assert( check ); /* debug code not instrumented */
}
- *ps = add( ps0, dn[x_save] );
+ *ps = add( ps0, dn[x_save] ); /*2*Qdn+1*/
move16();
- *alp = alpk[ik];
+ *alp = alpk[ik]; /*Q6*/
move16();
- *ix = x_save;
+ *ix = x_save; /*Q0*/
move16();
return;
}
@@ -437,7 +400,7 @@ static void E_ACELP_1pulse_search( UWord8 tracks[2],
* Returns:
* void
*/
-static void E_ACELP_xh_corr( Word16 *x, Word16 *y, Word16 *h, Word16 L_subfr )
+static void E_ACELP_xh_corr( Word16 *x /*Qx*/, Word16 *y /*Qy*/, Word16 *h /*Q12*/, Word16 L_subfr /*Q0*/ )
{
Word16 i, j, k;
Word32 L_tmp, y32[L_SUBFR16k], L_maxloc, L_tot;
@@ -452,28 +415,23 @@ static void E_ACELP_xh_corr( Word16 *x, Word16 *y, Word16 *h, Word16 L_subfr )
L_maxloc = L_deposit_l( 0 );
FOR( i = k; i < L_subfr; i += 4 )
{
- L_tmp = L_mac0( 1L, x[i], h[0] ); /* 1 -> to avoid null dn[] */
+ L_tmp = L_mac0( 1L, x[i], h[0] ); /* 1 -> to avoid null dn[] Qx+Q12*/
FOR( j = i; j < L_subfr - 1; j++ )
{
- L_tmp = L_mac0( L_tmp, x[j + 1], h[j + 1 - i] );
+ L_tmp = L_mac0( L_tmp, x[j + 1], h[j + 1 - i] ); /*Qx+Q12*/
}
- y32[i] = L_tmp;
+ y32[i] = L_tmp; /*Qx+Q12*/
move32();
- L_tmp = L_abs( L_tmp );
- L_maxloc = L_max( L_tmp, L_maxloc );
+ L_tmp = L_abs( L_tmp ); /*Qx+Q12*/
+ L_maxloc = L_max( L_tmp, L_maxloc ); /*Qx+Q12*/
}
/* tot += 3*max / 8 */
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
}
@@ -482,7 +440,7 @@ static void E_ACELP_xh_corr( Word16 *x, Word16 *y, Word16 *h, Word16 L_subfr )
j = sub( norm_l( L_tot ), 4 + 16 ); /* 4 -> 16 x tot */
- Copy_Scale_sig_32_16( y32, y, L_subfr, j );
+ Copy_Scale_sig_32_16( y32, y, L_subfr, j ); /*Qy = Qx+Q12+j*/
return;
}
@@ -494,7 +452,7 @@ static void E_ACELP_xh_corr( Word16 *x, Word16 *y, Word16 *h, Word16 L_subfr )
* \param bits amount of target headroom bits for y
* \return exponent of y
*/
-Word16 E_ACELP_hh_corr( Word16 *x, Word16 *y, Word16 L_subfr, Word16 bits )
+Word16 E_ACELP_hh_corr( Word16 *x /*Q11*/, Word16 *y /*Qy*/, Word16 L_subfr /*Q0*/, Word16 bits /*Q0*/ )
{
Word16 i, j, k = 0; /* initialize just to avoid compiler warning */
Word32 L_tmp, L_sum;
@@ -504,21 +462,21 @@ Word16 E_ACELP_hh_corr( Word16 *x, Word16 *y, Word16 L_subfr, Word16 bits )
Word64 L_tmp_64;
Word64 L_sum_64;
- L_tmp_64 = W_mult0_16_16( x[i], x[0] );
+ L_tmp_64 = W_mult0_16_16( x[i], x[0] ); /*Q22*/
FOR( j = i + 2; j < L_subfr; j += 2 )
{
- L_tmp_64 = W_mac0_16_16( L_tmp_64, x[j], x[j - i] );
+ L_tmp_64 = W_mac0_16_16( L_tmp_64, x[j], x[j - i] ); /*Q22*/
}
L_sum_64 = L_tmp_64;
move64();
- L_tmp_64 = W_mult0_16_16( x[i + 1], x[1] );
+ L_tmp_64 = W_mult0_16_16( x[i + 1], x[1] ); /*Q22*/
FOR( j = i + 3; j < L_subfr; j += 2 )
{
- L_tmp_64 = W_mac0_16_16( L_tmp_64, x[j], x[j - i] );
+ L_tmp_64 = W_mac0_16_16( L_tmp_64, x[j], x[j - i] ); /*Q22*/
}
L_sum_64 = W_add_nosat( W_shr( L_sum_64, 1 ), W_shr( L_tmp_64, 1 ) );
- L_sum = W_sat_l( L_sum_64 );
+ L_sum = W_sat_l( L_sum_64 ); /*Q22*/
/* L_sum = L_shr( L_sum, 1 ); */
if ( i == 0 )
{
@@ -529,12 +487,12 @@ Word16 E_ACELP_hh_corr( Word16 *x, Word16 *y, Word16 L_subfr, Word16 bits )
k = sub( k, bits );
}
- y[i] = round_fx( L_shl( L_sum, k ) );
+ y[i] = round_fx( L_shl( L_sum, k ) ); /*Q22+k-16*/
}
- L_tmp = L_mult0( x[i], x[0] );
+ L_tmp = L_mult0( x[i], x[0] ); /*Q22*/
L_sum = L_shr( L_tmp, 1 );
- y[i] = round_fx( L_shl( L_sum, k ) );
+ y[i] = round_fx( L_shl( L_sum, k ) ); /*Qy = Q22+k-16*/
k = add( 1, k );
@@ -560,31 +518,24 @@ Word16 E_ACELP_hh_corr( Word16 *x, Word16 *y, Word16 L_subfr, Word16 bits )
* Returns:
* pitch gain (0 ... 1.2F) (Q14)
*/
-Word16 E_ACELP_xy1_corr( Word16 xn[], Word16 y1[], ACELP_CbkCorr *g_corr, Word16 norm_flag, Word16 L_subfr, Word16 exp_xn )
+Word16 E_ACELP_xy1_corr_fx( Word16 xn[] /*Q15-exp_xn*/, Word16 y1[] /*Q15-exp_xn*/, ACELP_CbkCorr *g_corr, Word16 norm_flag /*Q0*/, Word16 L_subfr /*Q0*/, Word16 exp_xn )
{
Word16 i, Q_xn;
Word16 xy, yy, exp_xy, exp_yy, gain;
Word32 L_off;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
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 );
+ 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 );
-#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
+ xy = round_fx_o( Dot_product12_offs( xn, y1, L_subfr, &exp_xy, L_off ), &Overflow ); /*Q15 - exp_xy*/
/* Compute doubled format out of the exponent */
Q_xn = shl( sub( 15, exp_xn ), 1 );
g_corr->y1y1 = yy;
@@ -606,23 +557,19 @@ Word16 E_ACELP_xy1_corr( Word16 xn[], Word16 y1[], ACELP_CbkCorr *g_corr, Word16
/* compute gain = xy/yy */
- xy = mult_r( xy, 0x4000 ); /* Be sure xy < yy */
- gain = div_s( xy, yy );
+ xy = mult_r( xy, 0x4000 ); /* Be sure xy < yy Q15 - exp_xy*/
+ gain = div_s( xy, yy ); /*Q14*/
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. */
/* if (gain > 1.2) gain = 1.2 in Q14 */
- gain = s_min( 19661 /*1.2f Q14*/ /* 19661 */, gain );
+ gain = s_min( 19661 /*1.2f Q14*/ /* 19661 */, gain ); /*Q14*/
/*Limit the energy of pitch contribution*/
IF( norm_flag )
@@ -630,28 +577,20 @@ Word16 E_ACELP_xy1_corr( Word16 xn[], Word16 y1[], ACELP_CbkCorr *g_corr, Word16
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 );
-#else
- tmp = round_fx( Dot_product12_offs( xn, xn, L_subfr, &exp_tmp, 1 ) );
-#endif
+ tmp = round_fx_o( Dot_product12_offs( xn, xn, L_subfr, &exp_tmp, 1 ), &Overflow ); /*Q15 - exp_tmp*/
/* gain_p_snr = sqrt(/) */
tmp = BASOP_Util_Divide1616_Scale( tmp, yy, &exp_div );
exp_tmp = add( sub( exp_tmp, exp_yy ), exp_div );
- tmp = Sqrt16( tmp, &exp_tmp );
+ tmp = Sqrt16( tmp, &exp_tmp ); /*Q15 - exp_tmp*/
/* 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 );
-#else /* BASOP_NOGLOB */
- tmp = round_fx( L_shl( Mpy_32_16_1( 1717986944l /*ACELP_GAINS_CONST Q31*/, tmp ), exp_tmp ) );
-#endif /* BASOP_NOGLOB */
+ tmp = round_fx_o( L_shl_o( Mpy_32_16_1( 1717986944l /*ACELP_GAINS_CONST Q31*/, tmp ), exp_tmp, &Overflow ), &Overflow ); /*Q14*/
BASOP_SATURATE_WARNING_ON_EVS
- gain = s_min( gain, tmp );
+ gain = s_min( gain, tmp ); /*Q14*/
}
bail:
@@ -679,7 +618,7 @@ bail:
* Returns:
* pitch gain (0 ... 1.2F)
*/
-void E_ACELP_xy2_corr( Word16 xn[], Word16 y1[], Word16 y2[], ACELP_CbkCorr *g_corr, Word16 L_subfr, Word16 exp_xn )
+void E_ACELP_xy2_corr( Word16 xn[] /*Q_xn*/, Word16 y1[] /*Q_xn*/, Word16 y2[] /*Q9*/, ACELP_CbkCorr *g_corr, Word16 L_subfr /*Q0*/, Word16 exp_xn )
{
Word16 xny2, y2y2, y1y2, xx, exp_xny2, exp_y2y2, exp_y1y2, exp_xx;
Word32 L_off;
@@ -687,20 +626,20 @@ void E_ACELP_xy2_corr( Word16 xn[], Word16 y1[], Word16 y2[], ACELP_CbkCorr *g_c
BASOP_SATURATE_ERROR_ON_EVS;
/* Compute scalar product */
- y2y2 = extract_h( Dot_product15_offs( y2, y2, L_subfr, &exp_y2y2, 5243l /*0.01f Q19*/ ) );
+ y2y2 = extract_h( Dot_product15_offs( y2, y2, L_subfr, &exp_y2y2, 5243l /*0.01f Q19*/ ) ); /*Q15-exp_y2y2*/
/* L_off = 1L; */
L_off = L_shr( 10737418l /*0.01f/2.0f Q31*/, sub( 30 - 9, exp_xn ) );
/* Compute scalar product */
- xny2 = extract_h( Dot_product12_offs( xn, y2, L_subfr, &exp_xny2, L_off ) );
+ xny2 = extract_h( Dot_product12_offs( xn, y2, L_subfr, &exp_xny2, L_off ) ); /*Q15-exp_xny2*/
/* Compute scalar product */
- y1y2 = extract_h( Dot_product12_offs( y1, y2, L_subfr, &exp_y1y2, L_off ) );
+ y1y2 = extract_h( Dot_product12_offs( y1, y2, L_subfr, &exp_y1y2, L_off ) ); /*Q15-exp_y1y2*/
/* Compute scalar product */
L_off = L_shr( 21474836l /*0.01f Q31*/, s_min( 31, sub( 30, shl( exp_xn, 1 ) ) ) );
- xx = extract_h( Dot_product12_offs( xn, xn, L_subfr, &exp_xx, L_off ) );
+ xx = extract_h( Dot_product12_offs( xn, xn, L_subfr, &exp_xx, L_off ) ); /*Q15-exp_xx*/
g_corr->y2y2 = y2y2;
@@ -741,12 +680,13 @@ void E_ACELP_xy2_corr( Word16 xn[], Word16 y1[], Word16 y2[], ACELP_CbkCorr *g_c
* Returns:
* void
*/
-void E_ACELP_codebook_target_update( Word16 *x, Word16 *x2, Word16 *y, Word16 gain, Word16 L_subfr )
+void E_ACELP_codebook_target_update_fx( Word16 *x /*Q_xn*/, Word16 *x2 /*Q_xn*/, Word16 *y /*Q_xn*/, Word16 gain /*Q14*/, Word16 L_subfr /*Q0*/ )
{
Word16 i, Q15_flag;
Word32 L_tmp;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
assert( gain >= 0 );
@@ -757,24 +697,16 @@ void E_ACELP_codebook_target_update( Word16 *x, Word16 *x2, Word16 *y, Word16 ga
Q15_flag = 1;
move16();
}
- gain = shl( gain, Q15_flag );
+ gain = shl( gain, Q15_flag ); /*Q14*/
FOR( i = 0; i < L_subfr; i++ )
{
- L_tmp = L_deposit_h( x[i] );
+ 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 );
-#else
- L_tmp = L_msu( L_tmp, y[i], gain );
-#endif
+ L_tmp = L_msu_o( L_tmp, y[i], gain, &Overflow ); /*Q_xn+15*/
}
-#ifdef BASOP_NOGLOB
- x2[i] = msu_ro( L_tmp, y[i], gain, &Overflow );
-#else
- x2[i] = msu_r( L_tmp, y[i], gain );
-#endif
+ x2[i] = msu_ro( L_tmp, y[i], gain, &Overflow ); /*Q_xn*/
move16();
}
}
@@ -800,7 +732,7 @@ void E_ACELP_codebook_target_update( Word16 *x, Word16 *x2, Word16 *y, Word16 ga
* Returns:
* void
*/
-void E_ACELP_pulsesign( const Word16 cn[], Word16 dn[], Word16 dn2[], Word16 sign[], Word16 vec[], const Word16 alp, const Word16 sign_val, const Word16 L_subfr )
+void E_ACELP_pulsesign( const Word16 cn[] /*Q_xn*/, Word16 dn[] /*Qdn*/, Word16 dn2[] /*Qdn2*/, Word16 sign[] /*Q13*/, Word16 vec[] /*Q15*/, const Word16 alp /*Q13*/, const Word16 sign_val /*Q15*/, const Word16 L_subfr /*Q0*/ )
{
Word16 i;
Word32 Lval, Lcor;
@@ -810,21 +742,18 @@ void E_ACELP_pulsesign( const Word16 cn[], Word16 dn[], Word16 dn2[], Word16 sig
Word16 val, index;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/* calculate energy for normalization of cn[] and dn[] */
- Lval = L_mac0( 1, cn[0], cn[0] );
- Lcor = L_mac0( 1, dn[0], dn[0] );
+ Lval = L_mac0( 1, cn[0], cn[0] ); /*2*Q_xn*/
+ Lcor = L_mac0( 1, dn[0], dn[0] ); /*2*Qdn*/
FOR( i = 1; i < L_subfr; i++ )
{
-#ifdef BASOP_NOGLOB
- Lval = L_mac0_o( Lval, cn[i], cn[i], &Overflow );
-#else /* BASOP_NOGLOB */
- Lval = L_mac0( Lval, cn[i], cn[i] );
-#endif /* BASOP_NOGLOB */
- Lcor = L_mac0( Lcor, dn[i], dn[i] );
+ Lval = L_mac0_o( Lval, cn[i], cn[i], &Overflow ); /*2*Q_xn*/
+ Lcor = L_mac0( Lcor, dn[i], dn[i] ); /*2*Qdn*/
}
e_dn = 31;
@@ -832,64 +761,55 @@ void E_ACELP_pulsesign( const Word16 cn[], Word16 dn[], Word16 dn2[], Word16 sig
e_cn = 31;
move16();
- Lval = Sqrt32( Lval, &e_dn );
- Lcor = Sqrt32( Lcor, &e_cn );
+ Lval = Sqrt32( Lval, &e_dn ); /*Q31 - e_dn*/
+ Lcor = Sqrt32( Lcor, &e_cn ); /*Q31 - e_cn*/
i = sub( e_dn, e_cn );
if ( i < 0 )
Lval = L_shl( Lval, i );
if ( i > 0 )
Lcor = L_shr( Lcor, i );
-#ifdef BASOP_NOGLOB
- k_dn = round_fx_o( Lval, &Overflow );
- k_cn = round_fx_o( Lcor, &Overflow );
-#else /* BASOP_NOGLOB */
- k_dn = round_fx( Lval );
- k_cn = round_fx( Lcor );
-#endif /* BASOP_NOGLOB */
+ k_dn = round_fx_o( Lval, &Overflow ); /*Q15 - e_dn*/
+ k_cn = round_fx_o( Lcor, &Overflow ); /*Q15 - e_cn*/
k_cn = mult_r( 0x2000, k_cn ); /* 1 in Q13 */
k_dn = mult_r( alp, k_dn ); /* alp in Q13 */
- sign_neg = negate( sign_val );
+ sign_neg = negate( sign_val ); /*Q15*/
- signs[0] = sign_neg;
+ signs[0] = sign_neg; /*Q15*/
move16();
- signs[1] = sign_val;
+ signs[1] = sign_val; /*Q15*/
move16();
- signs[2] = sign_neg;
+ signs[2] = sign_neg; /*Q15*/
move16();
- ptr16 = &signs[1];
+ ptr16 = &signs[1]; /*Q15*/
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 );
- Lcor = L_mac( Lcor, dn[i], k_dn );
-#ifdef BASOP_NOGLOB
- val = round_fx_o( L_shl_o( Lcor, 4, &Overflow ), &Overflow ); /*shifting by 4 may overflow but improves accuracy*/
-#else
- val = round_fx( L_shl( Lcor, 4 ) ); /*shifting by 4 may overflow but improves accuracy*/
-#endif
+ 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*/
index = shr( val, 15 );
- sign[i] = ptr16[index];
- move16(); /* yields -1 (when ps < 0) or 0 (when ps >= 0) */
- vec[i] = ptr16[index + 1];
+ sign[i] = ptr16[index]; /*Q15*/
+ move16(); /* yields -1 (when ps < 0) or 0 (when ps >= 0) */
+ vec[i] = ptr16[index + 1]; /*Q15*/
move16();
if ( val < 0 )
{
- dn[i] = negate( dn[i] );
+ dn[i] = negate( dn[i] ); /*Qdn*/
move16();
}
- dn2[i] = abs_s( val );
- move16(); /* dn2[] = mix of dn[] and cn[] */
+ dn2[i] = abs_s( val ); /*Qdn2 = Qdn + 4 - e_dn*/
+ move16(); /* dn2[] = mix of dn[] and cn[] */
}
}
-void E_ACELP_findcandidates( Word16 dn2[], Word16 dn2_pos[], Word16 pos_max[] )
+void E_ACELP_findcandidates( Word16 dn2[] /*Qx*/, Word16 dn2_pos[] /*Q0*/, Word16 pos_max[] /*Q0*/ )
{
Word16 i, k, j, i8;
Word16 *ps_ptr;
@@ -899,13 +819,13 @@ void E_ACELP_findcandidates( Word16 dn2[], Word16 dn2_pos[], Word16 pos_max[] )
i8 = shl( i, 3 );
FOR( k = i8; k < i8 + 8; k++ )
{
- ps_ptr = &dn2[i];
+ ps_ptr = &dn2[i]; /*Qx*/
FOR( j = i + 4; j < L_SUBFR; j += 4 )
{
if ( GT_16( dn2[j], *ps_ptr ) )
{
- ps_ptr = &dn2[j];
+ ps_ptr = &dn2[j]; /*Qx*/
move16();
}
}
@@ -915,15 +835,15 @@ void E_ACELP_findcandidates( Word16 dn2[], Word16 dn2_pos[], Word16 pos_max[] )
dn2_pos[k] = (Word16) ( ps_ptr - dn2 );
move16();
}
- pos_max[i] = dn2_pos[i8];
+ pos_max[i] = dn2_pos[i8]; /*Q0*/
move16();
}
}
-static void E_ACELP_apply_sign( Word16 *p0, Word16 *psign0 )
+static void E_ACELP_apply_sign( Word16 *p0 /*Qx*/, Word16 *psign0 /*Q15*/ )
{
- p0[0] = mult_r( p0[0], psign0[0] );
+ p0[0] = mult_r( p0[0], psign0[0] ); /*Qx*/
move16();
p0[1] = mult_r( p0[1], psign0[4] );
move16();
@@ -957,7 +877,7 @@ static void E_ACELP_apply_sign( Word16 *p0, Word16 *psign0 )
move16();
}
-void E_ACELP_vec_neg( Word16 h[], Word16 h_inv[], Word16 L_subfr )
+void E_ACELP_vec_neg_fx( Word16 h[] /*Qx*/, Word16 h_inv[] /*Qx*/, Word16 L_subfr /*Q0*/ )
{
Word16 i;
@@ -969,7 +889,7 @@ void E_ACELP_vec_neg( Word16 h[], Word16 h_inv[], Word16 L_subfr )
}
-void E_ACELP_corrmatrix( Word16 h[], Word16 sign[], Word16 vec[], Word16 rrixix[4][16], Word16 rrixiy[4][256] )
+void E_ACELP_corrmatrix_fx( Word16 h[] /*Q12*/, Word16 sign[] /*Q0*/, Word16 vec[] /*Q15*/, Word16 rrixix[4][16] /*Q9*/, Word16 rrixiy[4][256] /*Q9*/ )
{
Word16 *p0, *p1, *p2, *p3, *psign0, *psign1, *psign2, *psign3;
@@ -989,20 +909,20 @@ void E_ACELP_corrmatrix( Word16 h[], Word16 sign[], Word16 vec[], Word16 rrixix[
p2 = &rrixix[2][16 - 1];
p3 = &rrixix[3][16 - 1];
- ptr_h1 = h;
+ ptr_h1 = h; /*Q12*/
cor = L_deposit_l( 0 );
FOR( i = 0; i < 16; i++ )
{
- cor = L_mac( cor, *ptr_h1, *ptr_h1 );
+ cor = L_mac( cor, *ptr_h1, *ptr_h1 ); /*Q25*/
ptr_h1++;
- *p3-- = round_fx( L_shr( cor, 1 ) );
- cor = L_mac( cor, *ptr_h1, *ptr_h1 );
+ *p3-- = round_fx( L_shr( cor, 1 ) ); /* Q9 */
+ cor = L_mac( cor, *ptr_h1, *ptr_h1 ); /*Q25*/
ptr_h1++;
- *p2-- = round_fx( L_shr( cor, 1 ) );
- cor = L_mac( cor, *ptr_h1, *ptr_h1 );
+ *p2-- = round_fx( L_shr( cor, 1 ) ); /* Q9 */
+ cor = L_mac( cor, *ptr_h1, *ptr_h1 ); /*Q25*/
ptr_h1++;
- *p1-- = round_fx( L_shr( cor, 1 ) );
- cor = L_mac( cor, *ptr_h1, *ptr_h1 );
+ *p1-- = round_fx( L_shr( cor, 1 ) ); /* Q9 */
+ cor = L_mac( cor, *ptr_h1, *ptr_h1 ); /*Q25*/
ptr_h1++;
*p0-- = round_fx( L_shr( cor, 1 ) ); /* Q9 */
}
@@ -1015,77 +935,88 @@ void E_ACELP_corrmatrix( Word16 h[], Word16 sign[], Word16 vec[], Word16 rrixix[
/* storage order --> i2i3, i1i2, i0i1, i3i0 */
pos = 256 - 1;
- ptr_hf = h + 1;
+ move16();
+ ptr_hf = h + 1; /*Q12*/
FOR( k = 0; k < 16; k++ )
{
- p3 = &rrixiy[2][pos];
+ p3 = &rrixiy[2][pos]; /* Q9 */
p2 = &rrixiy[1][pos];
p1 = &rrixiy[0][pos];
p0 = &rrixiy[3][pos - 16];
cor = L_deposit_h( 0 );
- ptr_h1 = h;
- ptr_h2 = ptr_hf;
+ ptr_h1 = h; /*Q12*/
+ ptr_h2 = ptr_hf; /*Q12*/
FOR( i = k; i < 16 - 1; i++ )
{
- cor = L_mac( cor, *ptr_h1++, *ptr_h2++ );
- *p3 = round_fx( cor );
- cor = L_mac( cor, *ptr_h1++, *ptr_h2++ );
- *p2 = round_fx( cor );
- cor = L_mac( cor, *ptr_h1++, *ptr_h2++ );
- *p1 = round_fx( cor );
- cor = L_mac( cor, *ptr_h1++, *ptr_h2++ );
- *p0 = round_fx( cor );
+ cor = L_mac( cor, *ptr_h1++, *ptr_h2++ ); /*Q25*/
+ *p3 = round_fx( cor ); /*Q9*/
+ cor = L_mac( cor, *ptr_h1++, *ptr_h2++ ); /*Q25*/
+ *p2 = round_fx( cor ); /*Q9*/
+ cor = L_mac( cor, *ptr_h1++, *ptr_h2++ ); /*Q25*/
+ *p1 = round_fx( cor ); /*Q9*/
+ cor = L_mac( cor, *ptr_h1++, *ptr_h2++ ); /*Q25*/
+ *p0 = round_fx( cor ); /*Q9*/
p3 -= ( 16 + 1 );
p2 -= ( 16 + 1 );
p1 -= ( 16 + 1 );
p0 -= ( 16 + 1 );
}
- cor = L_mac( cor, *ptr_h1++, *ptr_h2++ );
- *p3 = round_fx( cor );
- cor = L_mac( cor, *ptr_h1++, *ptr_h2++ );
- *p2 = round_fx( cor );
- cor = L_mac( cor, *ptr_h1++, *ptr_h2++ );
- *p1 = round_fx( cor );
+ cor = L_mac( cor, *ptr_h1++, *ptr_h2++ ); /*Q25*/
+ *p3 = round_fx( cor ); /*Q9*/
+ cor = L_mac( cor, *ptr_h1++, *ptr_h2++ ); /*Q25*/
+ *p2 = round_fx( cor ); /*Q9*/
+ cor = L_mac( cor, *ptr_h1++, *ptr_h2++ ); /*Q25*/
+ *p1 = round_fx( cor ); /*Q9*/
+ move16();
+ move16();
+ move16();
pos -= 16;
+ move16();
ptr_hf += 4;
}
/* storage order --> i3i0, i2i3, i1i2, i0i1 */
pos = 256 - 1;
- ptr_hf = h + 3;
+ move16();
+ ptr_hf = h + 3; /*Q12*/
FOR( k = 0; k < 16; k++ )
{
- p3 = &rrixiy[3][pos];
+ p3 = &rrixiy[3][pos]; /*Q9*/
p2 = &rrixiy[2][pos - 1];
p1 = &rrixiy[1][pos - 1];
p0 = &rrixiy[0][pos - 1];
cor = L_deposit_h( 0 );
- ptr_h1 = h;
- ptr_h2 = ptr_hf;
+ ptr_h1 = h; /*Q12*/
+ ptr_h2 = ptr_hf; /*Q12*/
FOR( i = k; i < 16 - 1; i++ )
{
- cor = L_mac( cor, *ptr_h1++, *ptr_h2++ );
- *p3 = round_fx( cor );
- cor = L_mac( cor, *ptr_h1++, *ptr_h2++ );
- *p2 = round_fx( cor );
- cor = L_mac( cor, *ptr_h1++, *ptr_h2++ );
- *p1 = round_fx( cor );
- cor = L_mac( cor, *ptr_h1++, *ptr_h2++ );
- *p0 = round_fx( cor );
+ cor = L_mac( cor, *ptr_h1++, *ptr_h2++ ); /*Q25*/
+ *p3 = round_fx( cor ); /*Q9*/
+ cor = L_mac( cor, *ptr_h1++, *ptr_h2++ ); /*Q25*/
+ *p2 = round_fx( cor ); /*Q9*/
+ cor = L_mac( cor, *ptr_h1++, *ptr_h2++ ); /*Q25*/
+ *p1 = round_fx( cor ); /*Q9*/
+ cor = L_mac( cor, *ptr_h1++, *ptr_h2++ ); /*Q25*/
+ *p0 = round_fx( cor ); /*Q9*/
+ move16();
+ move16();
+ move16();
+ move16();
p3 -= ( 16 + 1 );
p2 -= ( 16 + 1 );
p1 -= ( 16 + 1 );
p0 -= ( 16 + 1 );
}
- cor = L_mac( cor, *ptr_h1++, *ptr_h2++ );
- *p3 = round_fx( cor );
+ cor = L_mac( cor, *ptr_h1++, *ptr_h2++ ); /*Q25*/
+ *p3 = round_fx( cor ); /*Q9*/
+ move16();
pos--;
ptr_hf += 4;
@@ -1095,7 +1026,7 @@ void E_ACELP_corrmatrix( Word16 h[], Word16 sign[], Word16 vec[], Word16 rrixix[
* Modification of rrixiy[][] to take signs into account.
*/
- p0 = &rrixiy[0][0];
+ p0 = &rrixiy[0][0]; /*Q9*/
/* speed-up: 11% */
p1 = &rrixiy[1][0];
@@ -1105,19 +1036,19 @@ void E_ACELP_corrmatrix( Word16 h[], Word16 sign[], Word16 vec[], Word16 rrixix[
FOR( i = 0; i < L_SUBFR; i += 4 )
{
- psign0 = &vec[1];
+ psign0 = &vec[1]; /*Q15*/
if ( sign[i + 0] > 0 )
psign0 = &sign[1];
- psign1 = &vec[2];
+ psign1 = &vec[2]; /*Q15*/
if ( sign[i + 1] > 0 )
psign1 = &sign[2];
- psign2 = &vec[3];
+ psign2 = &vec[3]; /*Q15*/
if ( sign[i + 2] > 0 )
psign2 = &sign[3];
- psign3 = &vec[0];
+ psign3 = &vec[0]; /*Q15*/
if ( sign[i + 3] > 0 )
psign3 = &sign[0];
@@ -1136,7 +1067,7 @@ void E_ACELP_corrmatrix( Word16 h[], Word16 sign[], Word16 vec[], Word16 rrixix[
return;
}
-void E_ACELP_4tsearch_fx( Word16 dn[], const Word16 cn[], const Word16 H[], Word16 code[], const PulseConfig *config, Word16 ind[], Word16 y[] )
+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*/ )
{
Word16 sign[L_SUBFR], vec[L_SUBFR];
Word16 cor_x[16], cor_y[16], h_buf[4 * L_SUBFR];
@@ -1157,6 +1088,7 @@ void E_ACELP_4tsearch_fx( Word16 dn[], const Word16 cn[], const Word16 H[], Word
Word16 check = 0; /* debug code not instrumented */
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
@@ -1196,13 +1128,9 @@ void E_ACELP_4tsearch_fx( Word16 dn[], const Word16 cn[], const Word16 H[], Word
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 );
-#else
- L_tmp = L_mac( L_tmp, H[i], H[i] );
-#endif
+ L_tmp = L_mac_o( L_tmp, H[i], H[i], &Overflow ); /*Q25*/
}
- val = extract_h( L_tmp );
+ val = extract_h( L_tmp ); /*Q9*/
BASOP_SATURATE_WARNING_ON_EVS
if ( GT_16( val, 0x2000 ) )
@@ -1216,15 +1144,15 @@ void E_ACELP_4tsearch_fx( Word16 dn[], const Word16 cn[], const Word16 H[], Word
move16();
}
- Copy_Scale_sig( H, h, L_SUBFR, scale );
+ Copy_Scale_sig( H, h, L_SUBFR, scale ); /*Q12+scale*/
- E_ACELP_vec_neg( h, h_inv, L_SUBFR );
+ E_ACELP_vec_neg_fx( h, h_inv, L_SUBFR );
/*
* Compute correlation matrices needed for the codebook search.
*/
- E_ACELP_corrmatrix( h, sign, vec, rrixix, rrixiy );
+ E_ACELP_corrmatrix_fx( h, sign, vec, rrixix, rrixiy );
/*
@@ -1275,25 +1203,25 @@ void E_ACELP_4tsearch_fx( Word16 dn[], const Word16 cn[], const Word16 H[], Word
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_ );
- alp = mac_r( s, rrixiy[ipos[0]][l], _1_ );
+ 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];
+ p0 = h - ind[0]; /*Q12+scale*/
if ( sign[ind[0]] < 0 )
{
- p0 = h_inv - ind[0];
+ p0 = h_inv - ind[0]; /*Q12+scale*/
}
- p1 = h - ind[1];
+ p1 = h - ind[1]; /*Q12+scale*/
if ( sign[ind[1]] < 0 )
{
- p1 = h_inv - ind[1];
+ p1 = h_inv - ind[1]; /*Q12+scale*/
}
FOR( i = 0; i < L_SUBFR; i++ )
{
- vec[i] = add( *p0++, *p1++ );
+ vec[i] = add( *p0++, *p1++ ); /*Q12+scale*/
move16();
}
}
@@ -1301,57 +1229,53 @@ void E_ACELP_4tsearch_fx( Word16 dn[], const Word16 cn[], const Word16 H[], Word
{
/* first stage: fix 4 pulses */
- ind[0] = pos_max[ipos[0]];
+ ind[0] = pos_max[ipos[0]]; /*Q0*/
move16();
- ind[1] = pos_max[ipos[1]];
+ ind[1] = pos_max[ipos[1]]; /*Q0*/
move16();
- ind[2] = pos_max[ipos[2]];
+ ind[2] = pos_max[ipos[2]]; /*Q0*/
move16();
- ind[3] = pos_max[ipos[3]];
+ 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];
+ p0 = h - ind[0]; /*Q12+scale*/
if ( sign[ind[0]] < 0 )
{
- p0 = h_inv - ind[0];
+ p0 = h_inv - ind[0]; /*Q12+scale*/
}
- p1 = h - ind[1];
+ p1 = h - ind[1]; /*Q12+scale*/
if ( sign[ind[1]] < 0 )
{
- p1 = h_inv - ind[1];
+ p1 = h_inv - ind[1]; /*Q12+scale*/
}
- p2 = h - ind[2];
+ p2 = h - ind[2]; /*Q12+scale*/
if ( sign[ind[2]] < 0 )
{
- p2 = h_inv - ind[2];
+ p2 = h_inv - ind[2]; /*Q12+scale*/
}
- p3 = h - ind[3];
+ p3 = h - ind[3]; /*Q12+scale*/
if ( sign[ind[3]] < 0 )
{
- p3 = h_inv - ind[3];
+ p3 = h_inv - ind[3]; /*Q12+scale*/
}
FOR( i = 0; i < L_SUBFR; i++ )
{
- vec[i] = add( add( add( *p0++, *p1++ ), *p2++ ), *p3++ );
+ vec[i] = add( add( add( *p0++, *p1++ ), *p2++ ), *p3++ ); /*Q12+scale*/
move16();
}
- L_tmp = L_mult( vec[0], vec[0] );
+ 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 );
-#else
- L_tmp = L_mac( L_tmp, vec[i], vec[i] );
-#endif
+ L_tmp = L_mac_o( L_tmp, vec[i], vec[i], &Overflow ); /*Q25+2*scale*/
- alp = round_fx( L_shr( L_tmp, 3 ) );
+ alp = round_fx( L_shr( L_tmp, 3 ) ); /*Q6+2*scale*/
/*alp *= 0.5F; */
}
@@ -1368,9 +1292,9 @@ void E_ACELP_4tsearch_fx( Word16 dn[], const Word16 cn[], const Word16 H[], Word
* of the next 2 pulses with previous fixed pulses.
* Each pulse can have 16 possible positions.
*/
- E_ACELP_h_vec_corr1( h, vec, ipos[j], sign, rrixix, cor_x, dn2_pos, config->nbpos[st] );
+ E_ACELP_h_vec_corr1_fx( h, vec, ipos[j], sign, rrixix, cor_x, dn2_pos, config->nbpos[st] );
- E_ACELP_h_vec_corr2( h, vec, ipos[j + 1], sign, rrixix, cor_y );
+ E_ACELP_h_vec_corr2_fx( h, vec, ipos[j + 1], sign, rrixix, cor_y );
/*
* Find best positions of 2 pulses.
@@ -1380,9 +1304,9 @@ void E_ACELP_4tsearch_fx( Word16 dn[], const Word16 cn[], const Word16 H[], Word
}
ELSE /* single pulse search */
{
- E_ACELP_h_vec_corr2( h, vec, ipos[j], sign, rrixix, cor_x );
+ E_ACELP_h_vec_corr2_fx( h, vec, ipos[j], sign, rrixix, cor_x );
- E_ACELP_h_vec_corr2( h, vec, ipos[j + 1], sign, rrixix, cor_y );
+ 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 );
@@ -1390,29 +1314,24 @@ void E_ACELP_4tsearch_fx( Word16 dn[], const Word16 cn[], const Word16 H[], Word
IF( GT_16( nb_pulse_m2, j ) )
{
- p0 = h - ind[j];
+ p0 = h - ind[j]; /*Q12+scale*/
if ( sign[ind[j]] < 0 )
{
- p0 = h_inv - ind[j];
+ p0 = h_inv - ind[j]; /*Q12+scale*/
}
- p1 = h - ind[j + 1];
+ p1 = h - ind[j + 1]; /*Q12+scale*/
if ( sign[ind[j + 1]] < 0 )
{
- p1 = h_inv - ind[j + 1];
+ p1 = h_inv - ind[j + 1]; /*Q12+scale*/
}
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 );
@@ -1428,6 +1347,7 @@ void E_ACELP_4tsearch_fx( Word16 dn[], const Word16 cn[], const Word16 H[], Word
if ( psk < 0 )
{
s = 1;
+ move32();
}
IF( s > 0 )
{
@@ -1435,8 +1355,8 @@ void E_ACELP_4tsearch_fx( Word16 dn[], const Word16 cn[], const Word16 H[], Word
move16();
alpk = alp;
move16();
- Copy( ind, codvec, nb_pulse );
- check = 1; /* debug code not instrumented */
+ Copy( ind, codvec, nb_pulse ); /*Q0*/
+ check = 1; /* debug code not instrumented */
}
}
@@ -1451,26 +1371,348 @@ void E_ACELP_4tsearch_fx( Word16 dn[], const Word16 cn[], const Word16 H[], Word
set16_fx( y, 0, L_SUBFR );
FOR( k = 0; k < nb_pulse; ++k )
{
- i = codvec[k];
+ i = codvec[k]; /*Q0*/
move16();
- p0 = h_inv - i;
+ p0 = h_inv - i; /*Q12+scale*/
if ( sign[i] > 0 )
{
p0 -= 2 * L_SUBFR;
}
FOR( i = 0; i < L_SUBFR; i++ )
{
-#ifdef BASOP_NOGLOB
- y[i] = add_o( y[i], *p0++, &Overflow );
-#else
- y[i] = add( y[i], *p0++ );
-#endif
+ y[i] = add_o( y[i], *p0++, &Overflow ); /*Q12+scale*/
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
@@ -1507,19 +1749,19 @@ void E_ACELP_4tsearch_fx( Word16 dn[], const Word16 cn[], const Word16 H[], Word
* void
*/
void E_ACELP_4t_fx(
- Word16 dn[],
+ Word16 dn[], /*Qdn*/
Word16 cn[] /* Q_xn */,
- Word16 H[],
- Word16 R[],
- Word8 acelpautoc,
- Word16 code[],
- Word16 cdk_index,
- Word16 _index[],
- const Word16 L_frame,
- const Word16 last_L_frame,
- const Word32 total_brate,
- const Word16 i_subfr,
- const int16_t cmpl_flag )
+ Word16 H[], /*Q12*/
+ Word16 R[], /*Qx*/
+ Word8 acelpautoc, /*Q0*/
+ Word16 code[], /*Q9*/
+ Word16 cdk_index, /*Q0*/
+ Word16 _index[], /*Q0*/
+ const Word16 L_frame, /*Q0*/
+ const Word16 last_L_frame, /*Q0*/
+ const Word32 total_brate, /*Q0*/
+ const Word16 i_subfr, /*Q0*/
+ const int16_t cmpl_flag /*Q0*/ )
{
PulseConfig config;
Word16 ind[NPMAXPT * 4];
@@ -1570,20 +1812,20 @@ void E_ACELP_4t_fx(
}
void E_ACELP_4t_ivas_fx(
- Word16 dn[],
+ Word16 dn[], /*Qdn*/
Word16 cn[] /* Q_xn */,
- Word16 H[],
- Word16 R[],
- Word8 acelpautoc,
- Word16 code[],
- Word16 cdk_index,
- Word16 _index[],
- const Word16 L_frame,
- const Word16 last_L_frame,
- const Word32 total_brate,
- const Word16 i_subfr,
- const int16_t cmpl_flag,
- Word16 element_mode )
+ Word16 H[], /*Q12*/
+ Word16 R[], /*Qx*/
+ Word8 acelpautoc, /*Q0*/
+ Word16 code[], /*Q9*/
+ Word16 cdk_index, /*Q0*/
+ Word16 _index[], /*Q0*/
+ const Word16 L_frame, /*Q0*/
+ const Word16 last_L_frame, /*Q0*/
+ const Word32 total_brate, /*Q0*/
+ const Word16 i_subfr, /*Q0*/
+ const int16_t cmpl_flag, /*Q0*/
+ Word16 element_mode /*Q0*/ )
{
PulseConfig config;
Word16 ind[NPMAXPT * 4];
@@ -1627,18 +1869,22 @@ 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;
}
static void E_ACELP_indexing_shift(
- Word16 wordcnt, /* i: 16-bit word count including the newly shifted-in bits */
- Word16 shift_bits, /* i: number of bits to shift in from the lsb */
- UWord16 lsb_bits, /* i: bits to shift in from the lsb */
- const UWord16 src[], /* i: source buffer */
- UWord16 dst[] /* o: destination buffer */
+ Word16 wordcnt, /* i: 16-bit word count including the newly shifted-in bits Q0*/
+ Word16 shift_bits, /* i: number of bits to shift in from the lsb Q0*/
+ UWord16 lsb_bits, /* i: bits to shift in from the lsb Q0*/
+ const UWord16 src[], /* i: source buffer Q0*/
+ UWord16 dst[] /* o: destination buffer Q(shift_bits)*/
)
{
Word16 right_shift, i;
@@ -1649,10 +1895,10 @@ static void E_ACELP_indexing_shift(
FOR( i = sub( wordcnt, 1 ); i > 0; --i )
{
- dst[i] = s_or( lshl( src[i], shift_bits ), lshr( src[i - 1], right_shift ) );
+ dst[i] = s_or( lshl( src[i], shift_bits ), lshr( src[i - 1], right_shift ) ); /*Q0+shift_bits*/
move16();
}
- dst[i] = s_or( lshl( src[i], shift_bits ), lsb_bits );
+ dst[i] = s_or( lshl( src[i], shift_bits ), lsb_bits ); /*Q(shift_bits)*/
move16();
return;
}
@@ -1660,10 +1906,10 @@ static void E_ACELP_indexing_shift(
#define MAX_IDX_LEN 9
Word16 E_ACELP_indexing_fx(
- const Word16 code[],
+ const Word16 code[], /*Q9*/
const PulseConfig *config,
- Word16 num_tracks,
- Word16 prm[] )
+ Word16 num_tracks, /*Q0*/
+ Word16 prm[] /*Q(shift_bits)*/ )
{
Word16 track, shift_bits;
Word16 p[NB_TRACK_FCB_4T], wordcnt;
@@ -1716,6 +1962,7 @@ Word16 E_ACELP_indexing_fx(
if ( GT_16( p[3], p[1] ) )
{
track = add( track, 2 );
+ move16();
}
shift_bits = 2;
move16();
@@ -1788,15 +2035,15 @@ Word16 E_ACELP_indexing_fx(
void E_ACELP_adaptive_codebook(
Word16 *exc, /* i/o: pointer to the excitation frame Q_new */
Word16 T0, /* i : integer pitch lag Q0 */
- Word16 T0_frac, /* i : fraction of lag */
- Word16 T0_res, /* i : pitch resolution */
- Word16 T0_res_max, /* i : maximum pitch resolution */
- Word16 mode, /* i : filtering mode (0: no, 1: yes, 2: adaptive) */
+ Word16 T0_frac, /* i : fraction of lag Q0 */
+ Word16 T0_res, /* i : pitch resolution Q0 */
+ Word16 T0_res_max, /* i : maximum pitch resolution Q0 */
+ Word16 mode, /* i : filtering mode (0: no, 1: yes, 2: adaptive) Q0 */
Word16 i_subfr, /* i : subframe index */
- Word16 L_subfr, /* i : subframe length */
- Word16 L_frame, /* i : subframe length */
+ Word16 L_subfr, /* i : subframe length Q0 */
+ Word16 L_frame, /* i : subframe length Q0 */
Word16 *h1, /* i : impulse response of weighted synthesis filter 1Q14+shift */
- Word16 clip_gain, /* i : flag to indicate ??? */
+ Word16 clip_gain, /* i : flag to indicate ??? Q14 */
Word16 *xn, /* i : Close-loop Pitch search target vector Q_xn */
Word16 *y1, /* o : zero-memory filtered adaptive excitation Q_xn */
ACELP_CbkCorr *g_corr, /* o : ACELP correlation values */
@@ -1813,15 +2060,20 @@ void E_ACELP_adaptive_codebook(
Word16 y2[L_SUBFR], xn2[L_SUBFR], code[L_SUBFR];
ACELP_CbkCorr g_corr2;
Word16 gain1 = 0, gain2 = 0, fac_m, fac_n;
+ move16();
+ move16();
Word16 i, select, exp_ener;
Word32 L_tmp, L_ener;
const Word16 *pitch_inter;
Word16 pit_L_interpol, pit_up_samp;
Word16 use_prev_sf_pit_gain = 0;
+ move16();
- if ( rf_mode == 1 && rf_coder_type == 100 )
+ test();
+ IF( EQ_16( rf_mode, 1 ) && EQ_16( rf_coder_type, 100 ) )
{
use_prev_sf_pit_gain = 1;
+ move16();
}
BASOP_SATURATE_ERROR_ON_EVS;
@@ -1830,14 +2082,15 @@ void E_ACELP_adaptive_codebook(
/* find pitch excitation */
/*for &exc[i_subfr]*/
- if ( EQ_16( T0_res, shr( T0_res_max, 1 ) ) )
+ IF( EQ_16( T0_res, shr( T0_res_max, 1 ) ) )
{
- T0_frac = shl( T0_frac, 1 );
+ T0_frac = shl( T0_frac, 1 ); /*Q0*/
}
+ test();
IF( EQ_16( T0_res_max, 6 ) && rf_mode == 0 )
{
- pitch_inter = pitch_inter6_2;
+ pitch_inter = pitch_inter6_2; /*Q14*/
pit_L_interpol = PIT_L_INTERPOL6_2;
move16();
pit_up_samp = PIT_UP_SAMP6;
@@ -1845,7 +2098,7 @@ void E_ACELP_adaptive_codebook(
}
ELSE
{
- pitch_inter = pitch_inter4_2;
+ pitch_inter = pitch_inter4_2; /*Q14*/
pit_L_interpol = L_INTERPOL2;
move16();
pit_up_samp = PIT_UP_SAMP;
@@ -1861,22 +2114,23 @@ void E_ACELP_adaptive_codebook(
IF( use_prev_sf_pit_gain == 0 )
{
- gain1 = E_ACELP_xy1_corr( xn, y1, g_corr, 1, L_subfr, exp_xn );
+ gain1 = E_ACELP_xy1_corr_fx( xn, y1, g_corr, 1, L_subfr, exp_xn ); /*Q14*/
- /* clip gain if necessary to avoid problem at decoder */ test();
- if ( clip_gain && GT_16( gain1, 15565 /*0.95 Q14*/ ) )
+ /* clip gain if necessary to avoid problem at decoder */
+ test();
+ IF( clip_gain && GT_16( gain1, 15565 /*0.95 Q14*/ ) )
{
gain1 = 15565 /*0.95f Q14*/;
move16();
}
- *pitch_gain = gain1;
+ *pitch_gain = gain1; /*Q14*/
move16();
}
/* find energy of new target xn2[] */
- E_ACELP_codebook_target_update( xn, xn2, y1, gain1, L_subfr );
- L_ener = Dot_product12_offs( xn2, xn2, L_subfr, &exp_ener, 0 );
- L_ener = L_shr( L_ener, sub( 31, exp_ener ) );
+ E_ACELP_codebook_target_update_fx( xn, xn2, y1, gain1, L_subfr );
+ L_ener = Dot_product12_offs( xn2, xn2, L_subfr, &exp_ener, 0 ); /*Q31-exp_ener*/
+ L_ener = L_shr( L_ener, sub( 31, exp_ener ) ); /*Q0*/
}
/*-----------------------------------------------------------------*
@@ -1896,28 +2150,29 @@ void E_ACELP_adaptive_codebook(
move16();
}
/* fac_n = 0.5*(1.0-fac_m); */
- fac_n = mult_r( sub( 0x7FFF, fac_m ), 0x4000 );
+ fac_n = mult_r( sub( 0x7FFF, fac_m ), 0x4000 ); /*Q15*/
FOR( i = 0; i < L_subfr; i++ )
{
- L_tmp = L_mult( fac_n, exc[i - 1 + i_subfr] );
- L_tmp = L_mac( L_tmp, fac_m, exc[i + 0 + i_subfr] );
- code[i] = mac_r( L_tmp, fac_n, exc[i + 1 + i_subfr] );
+ L_tmp = L_mult( fac_n, exc[i - 1 + i_subfr] ); /*Q_new+Q16*/
+ L_tmp = L_mac( L_tmp, fac_m, exc[i + 0 + i_subfr] ); /*Q_new+Q16*/
+ code[i] = mac_r( L_tmp, fac_n, exc[i + 1 + i_subfr] ); /*Q_new*/
move16();
}
E_UTIL_f_convolve( code, h1, y2, L_subfr );
- gain2 = E_ACELP_xy1_corr( xn, y2, &g_corr2, 1, L_subfr, exp_xn );
+ gain2 = E_ACELP_xy1_corr_fx( xn, y2, &g_corr2, 1, L_subfr, exp_xn ); /*Q14*/
- /* clip gain if necessary to avoid problem at decoder */ test();
- if ( clip_gain && GT_16( gain2, 15565 /*0.95 Q14*/ ) )
+ /* clip gain if necessary to avoid problem at decoder */
+ test();
+ IF( clip_gain && GT_16( gain2, 15565 /*0.95 Q14*/ ) )
{
gain2 = 15565 /*0.95f Q14*/;
move16();
}
/* find energy of new target xn2[] */
- E_ACELP_codebook_target_update( xn, xn2, y2, gain2, L_subfr );
- L_tmp = Dot_product12_offs( xn2, xn2, L_subfr, &exp_ener, 0 );
- L_tmp = L_shr( L_tmp, sub( 31, exp_ener ) );
+ E_ACELP_codebook_target_update_fx( xn, xn2, y2, gain2, L_subfr );
+ L_tmp = Dot_product12_offs( xn2, xn2, L_subfr, &exp_ener, 0 ); /*Q31 - exp_ener*/
+ L_tmp = L_shr( L_tmp, sub( 31, exp_ener ) ); /*Q0*/
/*-----------------------------------------------------------------*
* use the best prediction (minimise quadratic error). *
@@ -1928,9 +2183,9 @@ void E_ACELP_adaptive_codebook(
/* use the lp filter for pitch excitation prediction */
select = LOW_PASS;
move16();
- Copy( code, &exc[i_subfr], L_subfr );
- Copy( y2, y1, L_subfr );
- *pitch_gain = gain2;
+ Copy( code, &exc[i_subfr], L_subfr ); /*Q_new*/
+ Copy( y2, y1, L_subfr ); /*Q_xn*/
+ *pitch_gain = gain2; /*Q14*/
move16();
g_corr->y1y1 = g_corr2.y1y1;
move16();
@@ -1946,7 +2201,7 @@ void E_ACELP_adaptive_codebook(
/* no filter used for pitch excitation prediction */
select = FULL_BAND;
move16();
- *pitch_gain = gain1;
+ *pitch_gain = gain1; /*Q14*/
move16();
}
@@ -1964,6 +2219,7 @@ void E_ACELP_adaptive_codebook(
move16();
}
*lp_select = select;
+ move16();
BASOP_SATURATE_ERROR_OFF_EVS;
}
@@ -1993,9 +2249,9 @@ void E_ACELP_innovative_codebook_fx(
Word16 **pt_indice, /* i/o: quantization indices pointer */
Word16 *code, /* o : innovative codebook Q9 Q9 */
Word16 shift, /* i : Scaling to get 12 bits */
- const Word16 L_frame, /* i : length of the frame */
- const Word16 last_L_frame, /* i : length of the last frame */
- const Word32 total_brate /* i : ttoal bit-rate */
+ const Word16 L_frame, /* i : length of the frame Q0*/
+ const Word16 last_L_frame, /* i : length of the last frame Q0*/
+ const Word32 total_brate /* i : ttoal bit-rate Q0*/
)
{
Word16 xn2[L_SUBFR] /* Q_xn */, cn2[L_SUBFR] /* Q_xn */, dn[L_SUBFR] /* Rw2*cn2 */, h2[L_SUBFR] /* 4Q11 */;
@@ -2014,7 +2270,7 @@ void E_ACELP_innovative_codebook_fx(
BASOP_SATURATE_ERROR_ON_EVS;
/* Update target vector for ACELP codebook search */
- E_ACELP_codebook_target_update( xn, xn2, y1, pitch_gain, L_SUBFR );
+ E_ACELP_codebook_target_update_fx( xn, xn2, y1, pitch_gain, L_SUBFR );
/* Include fixed-gain pitch contribution into impulse resp. h1[] */
Copy_Scale_sig( h1, h2, L_SUBFR, sub( -3, shift ) ); /*h2 1Q14+shift -> 4Q11, 1bit of headroom for Residu and xh_corr*/
@@ -2036,7 +2292,7 @@ void E_ACELP_innovative_codebook_fx(
ELSE
{
BASOP_SATURATE_WARNING_OFF_EVS;
- E_ACELP_codebook_target_update( cn, cn2, &exc[i_subfr], pitch_gain, L_SUBFR );
+ E_ACELP_codebook_target_update_fx( cn, cn2, &exc[i_subfr], pitch_gain, L_SUBFR );
BASOP_SATURATE_WARNING_ON_EVS;
Scale_sig( cn2, L_SUBFR, shift );
E_ACELP_xh_corr( xn2, dn, h2, L_SUBFR );
@@ -2073,7 +2329,7 @@ void E_ACELP_innovative_codebook_fx(
* n - (output) range of possible states (0...n-1)
* p - (output) number of pulses found
*--------------------------------------------------------------------------*/
-static void E_ACELP_codearithp_fx( const Word16 v[], UWord32 *n, UWord32 *ps, Word16 *p )
+static void E_ACELP_codearithp_fx( const Word16 v[] /*Q9*/, UWord32 *n /*Q0*/, UWord32 *ps /*Q0*/, Word16 *p /*Q0*/ )
{
Word16 k, nb_pulse, i, t, pos[NPMAXPT], posno;
Word16 sign, m;
@@ -2081,6 +2337,8 @@ static void E_ACELP_codearithp_fx( const Word16 v[], UWord32 *n, UWord32 *ps, Wo
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
Flag Carry = 0;
+ move32();
+ move32();
#endif
/* Collect different pulse positions to pos[], number of them to posno */
@@ -2096,6 +2354,7 @@ static void E_ACELP_codearithp_fx( const Word16 v[], UWord32 *n, UWord32 *ps, Wo
move16();
}
t = add( t, 1 );
+ move16();
if ( sub( posno, NPMAXPT ) >= 0 )
{
BREAK;
@@ -2110,18 +2369,15 @@ static void E_ACELP_codearithp_fx( const Word16 v[], UWord32 *n, UWord32 *ps, Wo
move16();
FOR( k = 0; k < posno; ++k )
{
- sign = shr( v[shl( pos[k], 2 )], 9 ); /* sign with multiplicity */
- m = abs_s( sign ); /* multiplicity */
+ sign = shr( v[( pos[k] * 4 )], 9 ); /* sign with multiplicity Q0*/
+ m = abs_s( sign ); /* multiplicity */
nb_pulse = add( nb_pulse, m );
/* Code m-1 pulses */
FOR( i = 1; i < m; ++i )
{
Carry = 0;
-#ifdef BASOP_NOGLOB
+ move32();
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 )
{
@@ -2133,41 +2389,35 @@ static void E_ACELP_codearithp_fx( const Word16 v[], UWord32 *n, UWord32 *ps, Wo
/* We use L_add_c since we want to work with unsigned UWord32 */
/* Therefore, we have to clear carry */
Carry = 0;
+ move32();
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;
-#ifdef BASOP_NOGLOB
+ move32();
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 );
}
- *ps = s;
+ *ps = s; /*Q0*/
move32();
*n = L_deposit_l( 0 );
if ( nb_pulse )
{
- *n = pulsestostates[NB_POS_FCB_4T][nb_pulse - 1];
+ *n = pulsestostates[NB_POS_FCB_4T][nb_pulse - 1]; /*Q0*/
move32();
}
- *p = nb_pulse;
+ *p = nb_pulse; /*Q0*/
move16();
return;
}
-void fcb_pulse_track_joint_fx( UWord16 *idxs, Word16 wordcnt, UWord32 *index_n, Word16 *pulse_num, Word16 track_num )
+void fcb_pulse_track_joint_fx( UWord16 *idxs /*Q0*/, Word16 wordcnt /*Q0*/, UWord32 *index_n /*Q0*/, Word16 *pulse_num /*Q0*/, Word16 track_num /*Q0*/ )
{
Word16 hi_to_low[10];
UWord32 index, index_mask;
@@ -2176,7 +2426,7 @@ void fcb_pulse_track_joint_fx( UWord16 *idxs, Word16 wordcnt, UWord32 *index_n,
Word16 track, track_num1, pulse_num0, pulse_num1;
Word16 indx_flag_2;
- Copy( hi_to_low_tmpl, hi_to_low, 10 );
+ Copy( hi_to_low_tmpl, hi_to_low, 10 ); /*Q0*/
indx_flag = 0;
move16();
@@ -2196,7 +2446,7 @@ void fcb_pulse_track_joint_fx( UWord16 *idxs, Word16 wordcnt, UWord32 *index_n,
{
hi_to_low[7] = 9;
move16();
- index_mask = 0xFFFFFF;
+ index_mask = 0xFFFFFF; /*Q0*/
move32();
}
ELSE
@@ -2206,34 +2456,35 @@ void fcb_pulse_track_joint_fx( UWord16 *idxs, Word16 wordcnt, UWord32 *index_n,
hi_to_low[4] = 1;
move16();
}
- index_mask = L_shr( 0xFFFF, sub( 9, hi_to_low[4] ) );
+ index_mask = L_shr( 0xFFFF, sub( 9, hi_to_low[4] ) ); /*Q0*/
}
IF( GE_16( indx_flag_1, track_num ) )
{
indx_tmp = L_deposit_l( 0 );
- index = L_shr( index_n[0], low_len[pulse_num[0]] );
+ index = L_shr( index_n[0], low_len[pulse_num[0]] ); /*Q0*/
FOR( track = 1; track < track_num; track++ )
{
- pulse_num0 = pulse_num[track - 1];
+ pulse_num0 = pulse_num[track - 1]; /*Q0*/
move16();
- pulse_num1 = pulse_num[track];
+ pulse_num1 = pulse_num[track]; /*Q0*/
move16();
- indx_tmp = L_lshr( index_n[track], low_len[pulse_num1] );
+ indx_tmp = L_lshr( index_n[track], low_len[pulse_num1] ); /*Q0*/
/* index = index * indx_fact[pulse_num1] + indx_tmp; */
- index = UL_Mpy_32_32( index, UL_deposit_l( indx_fact[pulse_num1] ) );
+ index = UL_Mpy_32_32( index, UL_deposit_l( indx_fact[pulse_num1] ) ); /*Q0*/
index = UL_addNsD( index, indx_tmp );
index_n[track - 1] = L_add( L_and( index_n[track - 1], low_mask[pulse_num0] ),
- L_and( L_lshl( index, low_len[pulse_num0] ), index_mask ) );
+ L_and( L_lshl( index, low_len[pulse_num0] ), index_mask ) ); /*Q0*/
index = L_lshr( index, hi_to_low[pulse_num0] );
}
track_num1 = sub( track_num, 1 );
- pulse_num1 = pulse_num[track_num1];
+ move16();
+ pulse_num1 = pulse_num[track_num1]; /*Q0*/
move16();
index_n[track_num1] = L_and( L_add( L_and( index_n[track_num1], low_mask[pulse_num1] ),
L_lshl( index, low_len[pulse_num1] ) ),
- index_mask );
+ index_mask ); /*Q0*/
index = L_lshr( index, hi_to_low[pulse_num1] );
IF( GE_16( indx_flag, track_num ) )
{
@@ -2266,11 +2517,11 @@ void fcb_pulse_track_joint_fx( UWord16 *idxs, Word16 wordcnt, UWord32 *index_n,
}
ELSE
{
- index = index_n[0];
+ index = index_n[0]; /*Q0*/
move32();
FOR( track = 1; track < 4; track++ )
{
- pulse_num1 = pulse_num[track];
+ pulse_num1 = pulse_num[track]; /*Q0*/
index = L_add( L_lshl( index, index_len[pulse_num1] ), index_n[track] );
}
track = 0;
diff --git a/lib_enc/enc_acelp_tcx_main_fx.c b/lib_enc/enc_acelp_tcx_main_fx.c
index 0ee3c51856af219d536d57f65af0ff536d9fa766..3498321646e22d98a77ebd738db6e55f43fdee03 100644
--- a/lib_enc/enc_acelp_tcx_main_fx.c
+++ b/lib_enc/enc_acelp_tcx_main_fx.c
@@ -18,15 +18,15 @@
* encoder function for coding ACELP/TCX
*--------------------------------------------------------------------*/
void enc_acelp_tcx_main_fx(
- const Word16 new_samples[], /* i : new samples */
- Encoder_State *st, /* i/o: encoder state structure */
- Word16 Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes*/
- const Word16 lsp_new[M], /* i : LSPs at the end of the frame */
- const Word16 lsp_mid[M], /* i : LSPs at the middle of the frame */
- Word32 bwe_exc_extended[], /* i/o: bandwidth extended excitation */
- Word16 *voice_factors, /* o : voicing factors */
- Word16 pitch_buf[], /* o : floating pitch for each subframe */
- Word16 vad_hover_flag, /* i : VAD hangover flag */
+ const Word16 new_samples[], /* i : new samples Q15*/
+ Encoder_State *st, /* i/o: encoder state structure */
+ Word16 Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes Q12*/
+ const Word16 lsp_new[M], /* i : LSPs at the end of the frame Q15*/
+ const Word16 lsp_mid[M], /* i : LSPs at the middle of the frame Q15*/
+ Word32 bwe_exc_extended[], /* i/o: bandwidth extended excitation Q_new*/
+ Word16 *voice_factors, /* o : voicing factors Q15*/
+ Word16 pitch_buf[], /* o : floating pitch for each subframe Q6*/
+ Word16 vad_hover_flag, /* i : VAD hangover flag Q0*/
Word16 *Q_new,
Word16 *shift )
{
@@ -39,7 +39,7 @@ void enc_acelp_tcx_main_fx(
IF( EQ_16( st->last_core, ACELP_CORE ) )
{
set16_fx( old_bwe_exc + PIT16k_MAX * 2, 0, ( ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2 );
- Copy( hBWE_TD->old_bwe_exc_fx, old_bwe_exc, PIT16k_MAX * 2 );
+ Copy( hBWE_TD->old_bwe_exc_fx, old_bwe_exc, PIT16k_MAX * 2 ); /*Q_exc*/
}
ELSE
{
@@ -74,7 +74,7 @@ void enc_acelp_tcx_main_fx(
non_linearity_fx( ptr_bwe_exc, bwe_exc_extended, L_FRAME32k, &hBWE_TD->bwe_non_lin_prev_scale_fx, *Q_new, st->coder_type, voice_factors, st->L_frame );
/* update the old BWE exe memory */
- Copy( &old_bwe_exc[L_FRAME32k], hBWE_TD->old_bwe_exc_fx, PIT16k_MAX * 2 );
+ Copy( &old_bwe_exc[L_FRAME32k], hBWE_TD->old_bwe_exc_fx, PIT16k_MAX * 2 ); /*Q_exc*/
}
ELSE
{
diff --git a/lib_enc/enc_acelpx_fx.c b/lib_enc/enc_acelpx_fx.c
index af773cac453fa0e258ffb57e8936fc6cd0c5b302..f18da2ef27024789870875f55f2b3f04c1b01b1c 100644
--- a/lib_enc/enc_acelpx_fx.c
+++ b/lib_enc/enc_acelpx_fx.c
@@ -19,13 +19,13 @@
/*--------------------------------------------------------------------------------------*
* E_ACELP_update_cor
*--------------------------------------------------------------------------------------*/
-static void E_ACELP_update_cor(
- const Word16 pos[], /* i */
- Word16 nb_pulse, /* i */
- const Word16 sign[], /* i */
- const Word16 R[], /* i */
- const Word16 cor_in[], /* i */
- Word16 cor_out[] /* o */
+static void E_ACELP_update_cor_fx(
+ const Word16 pos[], /* i Q0*/
+ Word16 nb_pulse, /* i Q0*/
+ const Word16 sign[], /* i Q13*/
+ const Word16 R[], /* i Q9+scale*/
+ const Word16 cor_in[], /* i Q9*/
+ Word16 cor_out[] /* o Q9*/
)
{
Word16 sign_x, sign_y;
@@ -36,9 +36,9 @@ static void E_ACELP_update_cor(
{
/* Update product of autocorrelation and already fixed pulses. with the
* two newly found ones */
- sign_x = sign[pos[0]];
+ sign_x = sign[pos[0]]; /*Q13*/
move16();
- sign_y = sign[pos[1]];
+ sign_y = sign[pos[1]]; /*Q13*/
move16();
IF( s_xor( sign_x, sign_y ) < 0 )
@@ -50,24 +50,24 @@ static void E_ACELP_update_cor(
i = 0;
move16();
}
- pRx = R - pos[i];
- pRy = R - pos[1 - i];
+ pRx = R - pos[i]; /*Q9+scale*/
+ pRy = R - pos[1 - i]; /*Q9+scale*/
/* different sign x and y */
FOR( i = 0; i < L_SUBFR; i++ )
{
tmp = sub( pRx[i], pRy[i] );
if ( cor_in != NULL )
{
- tmp = add( tmp, cor_in[i] );
+ tmp = add( tmp, cor_in[i] ); /* Q9 */
}
- cor_out[i] = tmp;
+ cor_out[i] = tmp; /* Q9 */
move16();
}
}
ELSE
{
- pRx = R - pos[0];
- pRy = R - pos[1];
+ pRx = R - pos[0]; /*Q9+scale*/
+ pRy = R - pos[1]; /*Q9+scale*/
IF( sign_x > 0 )
{
/* sign x and y is positive */
@@ -76,9 +76,9 @@ static void E_ACELP_update_cor(
tmp = add( pRx[i], pRy[i] );
if ( cor_in != NULL )
{
- tmp = add( tmp, cor_in[i] );
+ tmp = add( tmp, cor_in[i] ); /* Q9 */
}
- cor_out[i] = tmp;
+ cor_out[i] = tmp; /* Q9 */
move16();
}
}
@@ -90,13 +90,13 @@ static void E_ACELP_update_cor(
tmp = add( pRx[i], pRy[i] );
if ( cor_in != NULL )
{
- tmp = sub( cor_in[i], tmp );
+ tmp = sub( cor_in[i], tmp ); /* Q9 */
}
if ( cor_in == NULL )
{
tmp = negate( tmp );
}
- cor_out[i] = tmp;
+ cor_out[i] = tmp; /* Q9 */
move16();
}
}
@@ -104,8 +104,8 @@ static void E_ACELP_update_cor(
}
ELSE IF( EQ_16( nb_pulse, 4 ) )
{
- E_ACELP_update_cor( pos, 2, sign, R, cor_in, cor_out );
- E_ACELP_update_cor( pos + 2, 2, sign, R, cor_out, cor_out );
+ E_ACELP_update_cor_fx( pos, 2, sign, R, cor_in, cor_out );
+ E_ACELP_update_cor_fx( pos + 2, 2, sign, R, cor_out, cor_out );
}
else
{
@@ -116,20 +116,20 @@ static void E_ACELP_update_cor(
* E_ACELP_2pulse_searchx
* Iterations: nb_pos_ix*16
*--------------------------------------------------------------------------------------*/
-static void E_ACELP_2pulse_searchx(
- const Word16 nb_pos_ix,
- const Word16 track_x,
- const Word16 track_y,
- Word16 *R,
- Word16 *ps,
- Word16 *alp,
- Word16 *ix,
- Word16 *iy,
- Word16 dn[],
- Word16 *dn2,
- Word16 cor[],
- Word16 sign[],
- Word16 sign_val_2 )
+static void E_ACELP_2pulse_searchx_fx(
+ const Word16 nb_pos_ix, /*Q0*/
+ const Word16 track_x, /*Q0*/
+ const Word16 track_y, /*Q0*/
+ Word16 *R, /*Q9+scale*/
+ Word16 *ps, /*Qdn*/
+ Word16 *alp, /*Q6*/
+ Word16 *ix, /*Q0*/
+ Word16 *iy, /*Q0*/
+ Word16 dn[], /*Qdn*/
+ Word16 *dn2, /*Q0*/
+ Word16 cor[], /*Q9*/
+ Word16 sign[], /*Q13*/
+ Word16 sign_val_2 /*Q15*/ )
{
Word16 i, x;
Word32 y;
@@ -141,21 +141,18 @@ static void E_ACELP_2pulse_searchx(
Word16 sqk[2], alpk[2], ik;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/* eight dn2 max positions per track */
- pos_x = &dn2[shl( track_x, 3 )];
+ pos_x = &dn2[( track_x * 8 )]; /*Qdn*/
move16();
/* save these to limit memory searches */
- ps0 = *ps;
+ 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_mac_sat( alp0, R[0], sign_val_2 );
-#else
- alp0 = L_mac( alp0, R[0], sign_val_2 );
-#endif
+ alp0 = L_deposit_h( *alp ); /* Qalp = Q_R*Q_signval */
+ alp0 = L_mac_sat( alp0, R[0], sign_val_2 ); /*Q9+scale+Q15*/
/* Ensure that in the loop below s > 0 in the first iteration, the actual values do not matter. */
sqk[0] = -1;
@@ -164,17 +161,13 @@ static void E_ACELP_2pulse_searchx(
move16();
x = pos_x[0];
move16();
- sgnx = sign[track_y];
+ sgnx = sign[track_y]; /*Q13*/
move16();
if ( sign[x] < 0 )
{
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;
@@ -183,38 +176,26 @@ static void E_ACELP_2pulse_searchx(
ik = 0;
move16();
- xy_save = L_mac0( L_deposit_l( track_y ), track_x, L_SUBFR );
+ xy_save = L_mac0( L_deposit_l( track_y ), track_x, L_SUBFR ); /*Q0*/
/* loop track 1 */
FOR( i = 0; i < nb_pos_ix; i++ )
{
- x = pos_x[i];
+ x = pos_x[i]; /*Q0*/
move16();
- sgnx = sign[x];
+ sgnx = sign[x]; /*Q13*/
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] );
-#else
- ps1 = add( ps0, dn[x] );
-#endif
+ ps1 = add_sat( ps0, dn[x] ); /*Qdn*/
/*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;
+ 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] );
-#else
- ps2 = add( ps1, dn[y] );
-#endif
+ ps2 = add_sat( ps1, dn[y] ); /*Qdn*/
/*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 );
@@ -223,49 +204,33 @@ static void E_ACELP_2pulse_searchx(
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;
+ alpk[1 - ik] = alp2_16; /* Qalp */
move16();
/*sq = ps2 * ps2; MULT(1);*/
sq = mult_r( ps2, ps2 ); /* (3+3)Q -> 6Q9 */
- sqk[1 - ik] = sq;
+ sqk[1 - ik] = sq; /* Q9 */
move16();
/*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 );
}
if ( s > 0 )
{
- xy_save = L_mac0( y, x, L_SUBFR );
+ xy_save = L_mac0( y, x, L_SUBFR ); /* Q0 */
}
assert( ( ( s >= 0 && i == 0 && y == track_y ) ) || ( y > track_y ) || ( i > 0 ) );
}
@@ -273,21 +238,21 @@ static void E_ACELP_2pulse_searchx(
ps1 = extract_l( xy_save );
pos[1] = s_and( ps1, L_SUBFR - 1 );
move16();
- pos[0] = lshr( ps1, 6 );
+ pos[0] = lshr( ps1, 6 ); /* Q0 */
move16();
/* Update numerator */
- *ps = add( add( ps0, dn[pos[0]] ), dn[pos[1]] );
+ *ps = add( add( ps0, dn[pos[0]] ), dn[pos[1]] ); /* Qdn */
move16();
/* Update denominator */
- *alp = alpk[ik];
+ *alp = alpk[ik]; /* Q_alp */
move16();
- E_ACELP_update_cor( pos, 2, sign, R, cor, cor );
+ E_ACELP_update_cor_fx( pos, 2, sign, R, cor, cor );
- *ix = pos[0];
+ *ix = pos[0]; /* Q0 */
move16();
- *iy = pos[1];
+ *iy = pos[1]; /* Q0 */
move16();
assert( ( ( pos[0] & 3 ) == track_x ) && ( ( pos[1] & 3 ) == track_y ) ); /* sanity check */
@@ -296,16 +261,16 @@ static void E_ACELP_2pulse_searchx(
/*--------------------------------------------------------------------------------------*
* E_ACELP_1pulse_searchx
*--------------------------------------------------------------------------------------*/
-static void E_ACELP_1pulse_searchx(
- UWord8 tracks[2],
- Word16 *R,
- Word16 *ps,
- Word16 *alp,
- Word16 *ix,
- Word16 dn[],
- Word16 cor[],
- Word16 sign[],
- Word16 sign_val_1 )
+static void E_ACELP_1pulse_searchx_fx(
+ UWord8 tracks[2], /*Q0*/
+ Word16 *R, /*Q9+scale*/
+ Word16 *ps, /* Qdn */
+ Word16 *alp, /*Q6*/
+ Word16 *ix, /*Q0*/
+ Word16 dn[], /* Qdn */
+ Word16 cor[], /* Q9 */
+ Word16 sign[], /* Q13 */
+ Word16 sign_val_1 /* Q15 */ )
{
Word16 x, x_save = 0;
Word16 ps0;
@@ -315,14 +280,16 @@ static void E_ACELP_1pulse_searchx(
Word32 s;
Word16 ntracks, t;
Word16 sqk[2], alpk[2], ik;
+ move16();
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/* save these to limit memory searches */
/*alp0 = *alp + R[0]; INDIRECT(1);*/
- ps0 = *ps;
+ ps0 = *ps; /* Qdn */
move16();
- alp0 = L_deposit_h( *alp );
+ alp0 = L_deposit_h( *alp ); /* Q22 */
alp0 = L_mac( alp0, R[0], sign_val_1 ); /* Qalp = (Q_R=Q_cor)*Q_signval */
/* Ensure that in the loop below s > 0 in the first iteration, the actual values do not matter. */
@@ -332,20 +299,17 @@ static void E_ACELP_1pulse_searchx(
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();
}
- x_save = tracks[0];
+ x_save = tracks[0]; /* Q0 */
move16();
ntracks = 1;
+ move16();
if ( NE_16( tracks[1], tracks[0] ) )
{
ntracks = 2;
@@ -359,26 +323,18 @@ static void E_ACELP_1pulse_searchx(
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;
+ alpk[1 - ik] = alp1; /* Qalp */
move16();
/*sq = ps1 * ps1; MULT(1);*/
sq = mult_r( ps1, ps1 ); /* 6Q9 */
- sqk[1 - ik] = sq;
+ sqk[1 - ik] = sq; /* Q9 */
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 );
-#else
- s = L_msu( L_mult( alpk[ik], sq ), sqk[ik], alp1 );
-#endif
+ s = L_msu_o( L_mult_o( alpk[ik], sq, &Overflow ), sqk[ik], alp1, &Overflow ); /* Q9+Qalp+1 */
if ( s > 0 )
{
ik = sub( 1, ik );
@@ -392,11 +348,11 @@ static void E_ACELP_1pulse_searchx(
}
}
- *ps = add( ps0, dn[x_save] );
+ *ps = add( ps0, dn[x_save] ); /* Qdn */
move16();
- *alp = alpk[ik];
+ *alp = alpk[ik]; /* Qalp */
move16();
- *ix = x_save;
+ *ix = x_save; /* Q0 */
move16();
}
@@ -406,12 +362,12 @@ static void E_ACELP_1pulse_searchx(
* Algorithm is identical to traditional covariance method
*--------------------------------------------------------------------------------------*/
void E_ACELP_4tsearchx_fx(
- Word16 dn[],
- const Word16 cn[],
- Word16 Rw[],
- Word16 code[],
+ Word16 dn[], /*Qdn*/
+ const Word16 cn[], /*Q_new*/
+ Word16 Rw[], /*Q9*/
+ Word16 code[], /*Q9*/
const PulseConfig *config,
- Word16 ind[] )
+ Word16 ind[] /*Q0*/ )
{
Word16 sign[L_SUBFR], vec[L_SUBFR];
Word16 cor[L_SUBFR];
@@ -427,8 +383,11 @@ void E_ACELP_4tsearchx_fx(
Word16 scale;
Word16 sign_val_1, sign_val_2;
Word16 nb_pulse, nb_pulse_m2;
+ move16();
+ move16();
ps = 0; /* to avoid compilation warnings */
+ move16();
alp = config->alp; /* Q13 */
@@ -447,10 +406,10 @@ void E_ACELP_4tsearchx_fx(
scale = 0;
move16();
- s = L_mult0( Rw[0], Rw[0] );
+ s = L_mult0( Rw[0], Rw[0] ); /*Q18*/
FOR( i = 1; i < L_SUBFR; i++ )
{
- s = L_mac0( s, Rw[i], Rw[i] );
+ s = L_mac0( s, Rw[i], Rw[i] ); /*Q18*/
}
if ( s_and( (Word16) GE_16( nb_pulse, 9 ), (Word16) GT_32( s, 0x800000 ) ) )
{
@@ -493,7 +452,7 @@ void E_ACELP_4tsearchx_fx(
/* Set up autocorrelation vector */
R = R_buf + L_SUBFR - 1;
- Copy_Scale_sig( Rw, R, L_SUBFR, scale );
+ Copy_Scale_sig( Rw, R, L_SUBFR, scale ); /*Q9+scale*/
FOR( k = 1; k < L_SUBFR; k++ )
{
R[-k] = R[k];
@@ -501,13 +460,13 @@ void E_ACELP_4tsearchx_fx(
}
/* Sign value */
- sign_val_2 = 0x2000;
+ sign_val_2 = 0x2000; /* Q15 */
move16();
if ( GE_16( nb_pulse, 24 ) )
{
- sign_val_2 = shr( sign_val_2, 1 );
+ sign_val_2 = shr( sign_val_2, 1 ); /* Q15 */
}
- sign_val_1 = shr( sign_val_2, 1 );
+ sign_val_1 = shr( sign_val_2, 1 ); /* Q15 */
/*
* Find sign for each pulse position.
@@ -535,7 +494,7 @@ void E_ACELP_4tsearchx_fx(
E_ACELP_setup_pulse_search_pos( config, k, ipos );
/* index to first non-fixed position */
- pos = config->fixedpulses;
+ pos = config->fixedpulses; /* Q0 */
move16();
IF( config->fixedpulses == 0 ) /* 1100, 11, 1110, 1111, 2211 */
@@ -553,23 +512,23 @@ void E_ACELP_4tsearchx_fx(
/* set fixed positions */
FOR( i = 0; i < pos; ++i )
{
- ind[i] = pos_max[ipos[i]];
+ ind[i] = pos_max[ipos[i]]; /* Q0 */
move16();
}
/* multiplication of autocorrelation with signed fixed pulses */
- E_ACELP_update_cor( ind, config->fixedpulses, sign, R, NULL, cor );
+ E_ACELP_update_cor_fx( ind, config->fixedpulses, sign, R, NULL, cor );
/* normalisation contribution of fixed part */
- s = L_mult0( cor[ind[0]], sign[ind[0]] );
- ps = dn[ind[0]];
+ s = L_mult0( cor[ind[0]], sign[ind[0]] ); /* Q22 */
+ ps = dn[ind[0]]; /* Qdn */
move16();
FOR( i = 1; i < pos; ++i )
{
- s = L_mac0( s, cor[ind[i]], sign[ind[i]] ); /*Q12+Q9+1=Q6 */
- ps = add( ps, dn[ind[i]] );
+ s = L_mac0( s, cor[ind[i]], sign[ind[i]] ); /*Q12+Q9+1=Q22 */
+ ps = add( ps, dn[ind[i]] ); /* Qdn */
}
- alp = round_fx( s ); /*mac0 >>1 sign = 2*/
+ alp = round_fx( s ); /*mac0 >>1 sign = 2 Q6*/
}
/* other stages of 2 pulses */
@@ -585,13 +544,13 @@ void E_ACELP_4tsearchx_fx(
* Each pulse can have 16 possible positions.
*/
- E_ACELP_2pulse_searchx( config->nbpos[st], ipos[j], ipos[j + 1], R, &ps, &alp,
- &ind[j], &ind[j + 1], dn, dn2_pos, cor, sign, sign_val_2 );
+ E_ACELP_2pulse_searchx_fx( config->nbpos[st], ipos[j], ipos[j + 1], R, &ps, &alp,
+ &ind[j], &ind[j + 1], dn, dn2_pos, cor, sign, sign_val_2 );
}
ELSE /* single pulse search */
{
- E_ACELP_1pulse_searchx( &ipos[j], R, &ps, &alp,
- &ind[j], dn, cor, sign, sign_val_1 );
+ E_ACELP_1pulse_searchx_fx( &ipos[j], R, &ps, &alp,
+ &ind[j], dn, cor, sign, sign_val_1 );
}
@@ -600,10 +559,10 @@ void E_ACELP_4tsearchx_fx(
/* memorise the best codevector */
/*ps2 = ps * ps; MULT(1);*/
- ps2 = mult( ps, ps );
+ ps2 = mult( ps, ps ); /* 2*Qdn+1 */
/*s = (alpk * ps2) - (ps2k * alp); MULT(2);ADD(1);*/
- s = L_msu( L_mult( alpk, ps2 ), ps2k, alp );
+ s = L_msu( L_mult( alpk, ps2 ), ps2k, alp ); /* 2*Qdn+8 */
IF( s > 0 )
{
@@ -611,7 +570,7 @@ void E_ACELP_4tsearchx_fx(
move16();
alpk = alp;
move16();
- Copy( ind, codvec, nb_pulse );
+ Copy( ind, codvec, nb_pulse ); /* Q0 */
}
}
@@ -623,12 +582,12 @@ void E_ACELP_4tsearchx_fx(
}
void E_ACELP_4tsearchx_ivas_fx(
- Word16 dn[],
- const Word16 cn[],
- Word16 Rw[],
- Word16 code[],
+ Word16 dn[], /*Qdn*/
+ const Word16 cn[], /*Q_new*/
+ Word16 Rw[], /*Q9*/
+ Word16 code[], /*Q9*/
const PulseConfig *config,
- Word16 ind[],
+ Word16 ind[], /*Q0*/
Word16 element_mode )
{
Word16 sign[L_SUBFR], vec[L_SUBFR];
@@ -670,10 +629,10 @@ void E_ACELP_4tsearchx_ivas_fx(
scale = 0;
move16();
- s = L_mult0( Rw[0], Rw[0] );
+ s = L_mult0( Rw[0], Rw[0] ); /* Q18 */
FOR( i = 1; i < L_SUBFR; i++ )
{
- s = L_mac0( s, Rw[i], Rw[i] );
+ s = L_mac0( s, Rw[i], Rw[i] ); /* Q18 */
}
if ( s_and( (Word16) GE_16( nb_pulse, 9 ), (Word16) GT_32( s, 0x800000 ) ) )
{
@@ -716,7 +675,7 @@ void E_ACELP_4tsearchx_ivas_fx(
/* Set up autocorrelation vector */
R = R_buf + L_SUBFR - 1;
- Copy_Scale_sig( Rw, R, L_SUBFR, scale );
+ Copy_Scale_sig( Rw, R, L_SUBFR, scale ); /* Q9 + scale */
FOR( k = 1; k < L_SUBFR; k++ )
{
R[-k] = R[k];
@@ -724,13 +683,13 @@ void E_ACELP_4tsearchx_ivas_fx(
}
/* Sign value */
- sign_val_2 = 0x2000;
+ sign_val_2 = 0x2000; /* Q15 */
move16();
if ( GE_16( nb_pulse, 24 ) )
{
- sign_val_2 = shr( sign_val_2, 1 );
+ sign_val_2 = shr( sign_val_2, 1 ); /* Q15 */
}
- sign_val_1 = shr( sign_val_2, 1 );
+ sign_val_1 = shr( sign_val_2, 1 ); /* Q15 */
/*
* Find sign for each pulse position.
@@ -758,7 +717,7 @@ void E_ACELP_4tsearchx_ivas_fx(
E_ACELP_setup_pulse_search_pos( config, k, ipos );
/* index to first non-fixed position */
- pos = config->fixedpulses;
+ pos = config->fixedpulses; /* Q0 */
move16();
IF( config->fixedpulses == 0 ) /* 1100, 11, 1110, 1111, 2211 */
@@ -776,23 +735,23 @@ void E_ACELP_4tsearchx_ivas_fx(
/* set fixed positions */
FOR( i = 0; i < pos; ++i )
{
- ind[i] = pos_max[ipos[i]];
+ ind[i] = pos_max[ipos[i]]; /* Q0 */
move16();
}
/* multiplication of autocorrelation with signed fixed pulses */
- E_ACELP_update_cor( ind, config->fixedpulses, sign, R, NULL, cor );
+ E_ACELP_update_cor_fx( ind, config->fixedpulses, sign, R, NULL, cor );
/* normalisation contribution of fixed part */
- s = L_mult0( cor[ind[0]], sign[ind[0]] );
- ps = dn[ind[0]];
+ s = L_mult0( cor[ind[0]], sign[ind[0]] ); /* Q22 */
+ ps = dn[ind[0]]; /* Qdn */
move16();
FOR( i = 1; i < pos; ++i )
{
- s = L_mac0( s, cor[ind[i]], sign[ind[i]] ); /*Q12+Q9+1=Q6 */
+ s = L_mac0( s, cor[ind[i]], sign[ind[i]] ); /*Q12+Q9+1=Q22 */
ps = add( ps, dn[ind[i]] );
}
- alp = round_fx( s ); /*mac0 >>1 sign = 2*/
+ alp = round_fx( s ); /*mac0 >>1 sign = 2 Q6*/
}
/* other stages of 2 pulses */
@@ -808,24 +767,24 @@ void E_ACELP_4tsearchx_ivas_fx(
* Each pulse can have 16 possible positions.
*/
- E_ACELP_2pulse_searchx( config->nbpos[st], ipos[j], ipos[j + 1], R, &ps, &alp,
- &ind[j], &ind[j + 1], dn, dn2_pos, cor, sign, sign_val_2 );
+ E_ACELP_2pulse_searchx_fx( config->nbpos[st], ipos[j], ipos[j + 1], R, &ps, &alp,
+ &ind[j], &ind[j + 1], dn, dn2_pos, cor, sign, sign_val_2 );
}
ELSE /* single pulse search */
{
- E_ACELP_1pulse_searchx( &ipos[j], R, &ps, &alp,
- &ind[j], dn, cor, sign, sign_val_1 );
+ E_ACELP_1pulse_searchx_fx( &ipos[j], R, &ps, &alp,
+ &ind[j], dn, cor, sign, sign_val_1 );
}
IF( GT_16( alp, ONE_IN_Q14 ) )
{
alp = shr( alp, 1 );
- Scale_sig( cor, L_SUBFR, -1 );
- Scale_sig( R_buf, 2 * L_SUBFR - 1, -1 );
+ Scale_sig( cor, L_SUBFR, -1 ); /*Q8*/
+ Scale_sig( R_buf, 2 * L_SUBFR - 1, -1 ); /*Q8+scale*/
#ifndef MSAN_FIX
Scale_sig( dn, 2 * L_SUBFR, -1 );
#else
- Scale_sig( dn, L_SUBFR, -1 );
+ Scale_sig( dn, L_SUBFR, -1 ); /*Qdn-1*/
#endif
}
@@ -835,10 +794,10 @@ void E_ACELP_4tsearchx_ivas_fx(
/* memorise the best codevector */
/*ps2 = ps * ps; MULT(1);*/
- ps2 = mult( ps, ps );
+ ps2 = mult( ps, ps ); /* 2*Qdn+1 */
/*s = (alpk * ps2) - (ps2k * alp); MULT(2);ADD(1);*/
- s = L_msu( L_mult( alpk, ps2 ), ps2k, alp );
+ s = L_msu( L_mult( alpk, ps2 ), ps2k, alp ); /* 2*Qdn+8 */
IF( s > 0 )
{
@@ -848,7 +807,7 @@ void E_ACELP_4tsearchx_ivas_fx(
move16();
alpk = alp;
move16();
- Copy( ind, codvec, nb_pulse );
+ Copy( ind, codvec, nb_pulse ); /*Q0*/
}
}
@@ -868,9 +827,9 @@ void E_ACELP_4tsearchx_ivas_fx(
FOR( k = 0; k < config->nb_pulse; k++ )
{
- i = codvec[k]; /* read pulse position */
+ i = codvec[k]; /* read pulse position Q0*/
move16();
- val = sign[i]; /* read sign */
+ val = sign[i]; /* read sign Q13*/
move16();
index = shr( i, 2 ); /* pos of pulse (0..15) */
@@ -878,16 +837,16 @@ void E_ACELP_4tsearchx_ivas_fx(
track = s_and( i, 3 );
IF( L_mult0( val, psk ) > 0 )
{
- code[i] = add( code[i], ONE_IN_Q9 /*1.0f*/ );
+ code[i] = add( code[i], ONE_IN_Q9 /*1.0f*/ ); /* Q9 */
move16();
- codvec[k] = add( codvec[k], 2 * L_SUBFR );
+ codvec[k] = add( codvec[k], 2 * L_SUBFR ); /* Q0 */
move16();
}
ELSE
{
- code[i] = sub( code[i], ONE_IN_Q9 /*1.0f*/ );
+ code[i] = sub( code[i], ONE_IN_Q9 /*1.0f*/ ); /* Q9 */
move16();
- index = add( index, 16 );
+ index = add( index, 16 ); /* Q0 */
}
i = imult1616( track, NPMAXPT );
diff --git a/lib_enc/enc_amr_wb_fx.c b/lib_enc/enc_amr_wb_fx.c
index 5d5ee6c48af075fa34ded5aadf29b936f275607e..08a20bbb9b8effbccc2227ae263e1c7a0d32ba4d 100644
--- a/lib_enc/enc_amr_wb_fx.c
+++ b/lib_enc/enc_amr_wb_fx.c
@@ -18,16 +18,16 @@
*-------------------------------------------------------------------*/
void encod_amr_wb_fx(
Encoder_State *st, /* i/o: state structure */
- const Word16 speech[], /* i : input speech */
- const Word16 Aw[], /* i : weighted A(z) unquantized for subframes */
- const Word16 Aq[], /* i : 12k8 Lp coefficient */
- const Word16 *res, /* i : residual signal */
- Word16 *syn, /* i/o: core synthesis */
- Word16 *exc, /* i/o: current non-enhanced excitation */
- Word16 *exc2, /* i/o: current enhanced excitation */
- Word16 *pitch_buf, /* i/o: floating pitch values for each subframe */
- Word16 hf_gain_fx[NB_SUBFR], /* o : decoded HF gain */
- const Word16 *speech16k_fx, /* i : input speech @16kHz */
+ const Word16 speech[], /* i : input speech Q_new-1*/
+ const Word16 Aw[], /* i : weighted A(z) unquantized for subframes Q12*/
+ const Word16 Aq[], /* i : 12k8 Lp coefficient Q12*/
+ const Word16 *res, /* i : residual signal Q_new*/
+ Word16 *syn, /* i/o: core synthesis st->Q_syn*/
+ Word16 *exc, /* i/o: current non-enhanced excitation Q_new*/
+ Word16 *exc2, /* i/o: current enhanced excitation Q_new*/
+ Word16 *pitch_buf, /* i/o: floating pitch values for each subframe Q6*/
+ Word16 hf_gain_fx[NB_SUBFR], /* o : decoded HF gain Q0*/
+ const Word16 *speech16k_fx, /* i : input speech @16kHz Qx*/
Word16 shift,
Word16 Q_new )
{
@@ -66,6 +66,7 @@ void encod_amr_wb_fx(
LPD_state_HANDLE hLPDmem = st->hLPDmem;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/*------------------------------------------------------------------*
@@ -84,31 +85,33 @@ void encod_amr_wb_fx(
unbits = 0;
move16();
- p_Aw = Aw;
- p_Aq = Aq;
- pt_pitch = pitch_buf;
+ p_Aw = Aw; /*Q12*/
+ p_Aq = Aq; /*Q12*/
+ pt_pitch = pitch_buf; /*Q6*/
shift_wsp = add( Q_new, shift );
- Copy( st->pitch, T_op, 2 );
+ Copy( st->pitch, T_op, 2 ); /*Q0*/
if ( LE_16( T_op[0], PIT_MIN ) )
{
- T_op[0] = shl( T_op[0], 1 );
+ T_op[0] = shl( T_op[0], 1 ); /*Q0*/
move16();
}
if ( LE_16( T_op[1], PIT_MIN ) )
{
/*T_op[1] *= 2;*/
- T_op[1] = shl( T_op[1], 1 );
+ T_op[1] = shl( T_op[1], 1 ); /*Q0*/
move16();
}
st->acelp_cfg.fcb_mode = 0; /* flag used in inov_encode() */
+ move16();
/*-----------------------------------------------------------------*
* Select LP filtering flag
*-----------------------------------------------------------------*/
lp_flag = NORMAL_OPERATION;
+ move16();
if ( LT_32( st->core_brate, ACELP_11k60 ) )
{
lp_flag = LOW_PASS;
@@ -126,7 +129,7 @@ void encod_amr_wb_fx(
* target in residual domain "cn"
* Compute impulse response, h1[], of weighted synthesis filter
*----------------------------------------------------------------*/
- Copy( &res[i_subfr], &exc[i_subfr], L_SUBFR );
+ Copy( &res[i_subfr], &exc[i_subfr], L_SUBFR ); /*Q_new*/
find_targets_fx( speech, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq,
res, L_SUBFR, p_Aw, TILT_FAC_FX, xn, cn, h1 );
@@ -184,23 +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 );
-#else /* BASOP_NOGLOB */
- Lgcode = L_shl( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/
- gcode16 = round_fx( Lgcode );
-#endif /* BASOP_NOGLOB */
+ gcode16 = round_fx_o( Lgcode, &Overflow ); /*Q0*/
- hLPDmem->tilt_code = Est_tilt2( exc + i_subfr, gain_pit, code, Lgcode, &voice_fac, shift );
+ 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 );
-#else /* BASOP_NOGLOB */
- exc2[i + i_subfr] = round_fx( L_shl( L_mult( gain_pit, exc[i + i_subfr] ), 1 ) );
-#endif /* 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();
}
/*-----------------------------------------------------------------*
@@ -208,38 +203,25 @@ void encod_amr_wb_fx(
*-----------------------------------------------------------------*/
/*st->mem_w0 = xn[L_SUBFR-1] - gain_pit * y1[L_SUBFR-1] - gain_code * y2[L_SUBFR-1];*/
- Ltmp = L_mult( gcode16, y2[L_SUBFR - 1] );
- Ltmp = L_shl( Ltmp, add( 5, shift ) );
+ Ltmp = L_mult( gcode16, y2[L_SUBFR - 1] ); /*Q10*/
+ Ltmp = L_shl( Ltmp, add( 5, shift ) ); /*Q15 - shift*/
Ltmp = L_negate( Ltmp );
- Ltmp = L_mac( Ltmp, xn[L_SUBFR - 1], 16384 );
- Ltmp = L_msu( Ltmp, y1[L_SUBFR - 1], gain_pit );
-#ifdef BASOP_NOGLOB
- Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) );
- hLPDmem->mem_w0 = round_fx_sat( Ltmp ); /*Q_new-1 */
-#else
- Ltmp = L_shl( Ltmp, sub( 1, shift ) );
- hLPDmem->mem_w0 = round_fx( Ltmp ); /*Q_new-1 */
-#endif
+ 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 */
+ Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); /* Q_new+15 */
+ hLPDmem->mem_w0 = round_fx_sat( Ltmp ); /*Q_new-1 */
+ move16();
/*-----------------------------------------------------------------*
* Find the total excitation
*-----------------------------------------------------------------*/
FOR( i = 0; i < L_SUBFR; i++ )
{
- L_tmp = L_mult( gcode16, code[i] );
-#ifdef BASOP_NOGLOB
- L_tmp = L_shl_sat( L_tmp, 5 );
- L_tmp = L_mac_sat( L_tmp, exc[i + i_subfr], gain_pit );
-#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 */
- exc[i + i_subfr] = round_fx_o( L_tmp, &Overflow );
-#else /* BASOP_NOGLOB */
- L_tmp = L_shl( L_tmp, 1 ); /* saturation can occur here */
- exc[i + i_subfr] = round_fx( L_tmp );
-#endif
+ 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 */
+ 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();
}
/*-----------------------------------------------------------------*
diff --git a/lib_enc/enc_gain_fx.c b/lib_enc/enc_gain_fx.c
index 3bf3db1aa705c07972ac8d67bb437604ce668cdb..7c9606cfc24bcf592bfd1a0390ea625645414b50 100644
--- a/lib_enc/enc_gain_fx.c
+++ b/lib_enc/enc_gain_fx.c
@@ -14,7 +14,7 @@
#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
-void E_GAIN_norm_corr( Word16 exc[], Word16 xn[], Word16 h[], Word16 t_min, Word16 t_max, Word16 corr_norm[], Word16 L_subfr );
+void E_GAIN_norm_corr_fx( Word16 exc[] /*Q_new*/, Word16 xn[] /*(Q_new+shift-1)*/, Word16 h[] /*(Q14+shift)*/, Word16 t_min, Word16 t_max, Word16 corr_norm[] /*(Q15+(Q_new+shift-1)+scale)*/, Word16 L_subfr );
/*
* E_GAIN_norm_corr
@@ -36,7 +36,7 @@ void E_GAIN_norm_corr( Word16 exc[], Word16 xn[], Word16 h[], Word16 t_min, Word
* Returns:
* void
*/
-void E_GAIN_norm_corr( Word16 exc[], Word16 xn[], Word16 h[], Word16 t_min, Word16 t_max, Word16 corr_norm[], Word16 L_subfr )
+void E_GAIN_norm_corr_fx( Word16 exc[] /*Q_new*/, Word16 xn[] /*(Q_new+shift-1)*/, Word16 h[] /*(Q14+shift)*/, Word16 t_min, Word16 t_max, Word16 corr_norm[] /*(Q15+(Q_new+shift-1)+scale)*/, Word16 L_subfr )
{
Word16 excf[L_SUBFR]; /* filtered past excitation (Q_new+shift-1) */
Word16 ps, norm, exp_alp, exp_ps, scale, L_subfr2;
@@ -53,7 +53,8 @@ void E_GAIN_norm_corr( Word16 exc[], Word16 xn[], Word16 h[], Word16 t_min, Word
/* Compute rounded down 1/sqrt(energy of xn[]) */
Dot_product12_offs( xn, xn, L_subfr, &scale, 1 );
- scale = add( scale, 2 + 1 ); /* energy of xn[] x 2 + rounded up */
+ scale = add( scale, 2 + 1 ); /* energy of xn[] x 2 + rounded up */
+ move16();
scale = negate( shr( scale, 1 ) ); /* (1< 0 )
{
t0_min = add( t0_min, 1 );
+ move16();
}
t_min = sub( t0_min, L_INTERPOL1 );
t_max = add( t0_max, L_INTERPOL1 );
+ move16();
+ move16();
/* allocate memory to normalized correlation vector */
corr = &corr_v[negate( t_min )]; /* corr[t_min..t_max] */
/* Compute normalized correlation between target and filtered excitation */
- E_GAIN_norm_corr( exc, xn, h, t_min, t_max, corr_v, L_subfr );
+ E_GAIN_norm_corr_fx( exc, xn, h, t_min, t_max, corr_v, L_subfr );
/* find integer pitch */
- max = corr[t0_min];
+ max = corr[t0_min]; /*(Q15+(Q_new+shift-1)+scale)*/
move16();
- t0 = t0_min;
+ t0 = t0_min; /*Q0*/
move16();
FOR( i = t0_min + 1; i <= t0_max; i++ )
@@ -306,26 +310,28 @@ Word16 E_GAIN_closed_loop_search_fx( Word16 exc[],
IF( EQ_16( t0_min_max_res, shr( pit_res_max, 1 ) ) )
{
- t0_min_frac = shl( t0_min_frac, 1 );
- t0_max_frac = shl( t0_max_frac, 1 );
+ t0_min_frac = shl( t0_min_frac, 1 ); /*Q0*/
+ t0_max_frac = shl( t0_max_frac, 1 ); /*Q0*/
}
step = 1;
- frac1 = sub( 1, pit_res_max );
- frac2 = sub( pit_res_max, 1 );
+ move16();
+ frac1 = sub( 1, pit_res_max ); /*Q0*/
+ frac2 = sub( pit_res_max, 1 ); /*Q0*/
test();
test();
IF( ( ( i_subfr == 0 ) && GE_16( t0, pit_fr2 ) ) || LE_16( pit_fr2, pit_min ) )
{
step = 2;
- frac1 = sub( 2, pit_res_max );
- frac2 = sub( pit_res_max, 2 );
+ move16();
+ frac1 = sub( 2, pit_res_max ); /*Q0*/
+ frac2 = sub( pit_res_max, 2 ); /*Q0*/
}
test();
IF( ( EQ_16( t0, t0_min ) ) && ( t0_min_frac == 0 ) )
{
- frac1 = t0_min_frac;
+ frac1 = t0_min_frac; /*Q0*/
move16();
}
ELSE
@@ -333,28 +339,29 @@ Word16 E_GAIN_closed_loop_search_fx( Word16 exc[],
test();
IF( ( EQ_16( t0, t0_min ) ) && ( LT_16( add( frac1, pit_res_max ), t0_min_frac ) ) )
{
- frac1 = sub( t0_min_frac, pit_res_max );
+ frac1 = sub( t0_min_frac, pit_res_max ); /*Q0*/
}
}
if ( EQ_16( t0, t0_max ) )
{
- frac2 = t0_max_frac;
+ frac2 = t0_max_frac; /*Q0*/
move16();
}
assert( frac1 <= 0 && frac2 >= 0 && frac2 > frac1 );
IF( EQ_16( pit_res_max, 6 ) )
{
- cor_max = E_GAIN_norm_corr_interpolate6( &corr[t0], frac1 );
- fraction = frac1;
+ cor_max = E_GAIN_norm_corr_interpolate6_fx( &corr[t0], frac1 ); /*(Q15+(Q_new+shift-1)+scale)*/
+ fraction = frac1; /*Q0*/
+ move16();
FOR( i = ( frac1 + step ); i <= frac2; i += step )
{
- temp = E_GAIN_norm_corr_interpolate6( &corr[t0], i );
+ temp = E_GAIN_norm_corr_interpolate6_fx( &corr[t0], i ); /*(Q15+(Q_new+shift-1)+scale)*/
IF( GT_16( temp, cor_max ) )
{
- cor_max = temp;
+ cor_max = temp; /*(Q15+(Q_new+shift-1)+scale)*/
move16();
fraction = i;
move16();
@@ -363,15 +370,16 @@ Word16 E_GAIN_closed_loop_search_fx( Word16 exc[],
}
ELSE
{
- cor_max = E_GAIN_norm_corr_interpolate( &corr[t0], frac1 );
- fraction = frac1;
+ cor_max = E_GAIN_norm_corr_interpolate_fx( &corr[t0], frac1 ); /*(Q15+(Q_new+shift-1)+scale)*/
+ fraction = frac1; /*Q0*/
+ move16();
FOR( i = ( frac1 + step ); i <= frac2; i += step )
{
- temp = E_GAIN_norm_corr_interpolate( &corr[t0], i );
+ temp = E_GAIN_norm_corr_interpolate_fx( &corr[t0], i ); /*(Q15+(Q_new+shift-1)+scale)*/
IF( GT_16( temp, cor_max ) )
{
- cor_max = temp;
+ cor_max = temp; /*(Q15+(Q_new+shift-1)+scale)*/
move16();
fraction = i;
move16();
@@ -382,23 +390,23 @@ Word16 E_GAIN_closed_loop_search_fx( Word16 exc[],
/* limit the fraction value */
IF( fraction < 0 )
{
- fraction = add( fraction, pit_res_max );
+ fraction = add( fraction, pit_res_max ); /*Q0*/
t0 = sub( t0, 1 );
}
test();
test();
IF( ( ( i_subfr == 0 ) && GE_16( t0, pit_fr2 ) ) || LE_16( pit_fr2, pit_min ) )
{
- *pit_res = shr( pit_res_max, 1 );
+ *pit_res = shr( pit_res_max, 1 ); /*Q0*/
move16();
- *pit_frac = shr( fraction, 1 );
+ *pit_frac = shr( fraction, 1 ); /*Q0*/
move16();
}
ELSE
{
- *pit_res = pit_res_max;
+ *pit_res = pit_res_max; /*Q0*/
move16();
- *pit_frac = fraction;
+ *pit_frac = fraction; /*Q0*/
move16();
}
return ( t0 );
diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c
index 856a4312fb88a0c92bbb3fb5228cada468bf8512..6f71b8ba1c2031d4a5079a801a107efa11746e6b 100644
--- a/lib_enc/enc_gen_voic_fx.c
+++ b/lib_enc/enc_gen_voic_fx.c
@@ -51,20 +51,20 @@
void encod_gen_voic_fx(
Encoder_State *st_fx, /* i/o: state structure */
- const Word16 speech_fx[], /* i : input speech */
- const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes */
- const Word16 Aq_fx[], /* i : 12k8 Lp coefficient */
- const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */
- const Word16 *res_fx, /* i : residual signal */
- Word16 *syn_fx, /* i/o: core synthesis */
- Word16 *exc_fx, /* i/o: current non-enhanced excitation */
- Word16 *exc2_fx, /* i/o: current enhanced excitation */
- Word16 *pitch_buf_fx, /* i/o: floating pitch values for each subframe */
- Word16 *voice_factors_fx, /* o : voicing factors */
- Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */
- Word16 *unbits_fx, /* i/o: number of unused bits */
- const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
- const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer */
+ const Word16 speech_fx[], /* i : input speech Q0*/
+ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/
+ const Word16 Aq_fx[], /* i : 12k8 Lp coefficient Q12*/
+ const Word16 Es_pred_fx, /* i : predicted scaled innov. energy Q8*/
+ const Word16 *res_fx, /* i : residual signal Q_new*/
+ Word16 *syn_fx, /* i/o: core synthesis Q_new*/
+ Word16 *exc_fx, /* i/o: current non-enhanced excitation Q0*/
+ Word16 *exc2_fx, /* i/o: current enhanced excitation Q0*/
+ Word16 *pitch_buf_fx, /* i/o: floating pitch values for each subframe Q6*/
+ Word16 *voice_factors_fx, /* o : voicing factors Q15*/
+ Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q0*/
+ Word16 *unbits_fx, /* i/o: number of unused bits Q0*/
+ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/
+ const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/
Word16 shift,
Word16 Q_new )
{
@@ -77,23 +77,32 @@ void encod_gen_voic_fx(
Word16 y1_fx[L_SUBFR] = { 0 }; /* Filtered adaptive excitation */
Word16 y2_fx[L_SUBFR]; /* Filtered algebraic excitation */
Word16 gain_pit_fx = 0; /* Pitch gain */
- Word16 voice_fac_fx; /* Voicing factor */
- Word32 gain_code_fx = 0; /* Gain of code */
- Word16 gain_inov_fx = 0; /* inovation gain */
- Word32 gc_mem[NB_SUBFR - 1]; /* gain_code from previous subframes */
- Word16 gp_mem[NB_SUBFR - 1]; /* gain_pitch from previous subframes*/
- Word16 i, i_subfr_fx; /* tmp variables */
- Word16 T0_fx = 0, T0_frac_fx = 0; /* close loop integer pitch and fractional part */
- Word16 T0_min_fx, T0_max_fx; /* pitch variables */
- Word16 *pt_pitch_fx; /* pointer to floating pitch buffer */
- Word16 g_corr_fx[10]; /* ACELP correl, values + gain pitch */
- Word16 clip_gain_fx; /* LSF clip gain */
- const Word16 *p_Aw_fx, *p_Aq_fx; /* pointer to LP filter coeff. vector*/
+ move16();
+ Word16 voice_fac_fx; /* Voicing factor */
+ Word32 gain_code_fx = 0; /* Gain of code */
+ move32();
+ Word16 gain_inov_fx = 0; /* inovation gain */
+ move16();
+ Word32 gc_mem[NB_SUBFR - 1]; /* gain_code from previous subframes */
+ Word16 gp_mem[NB_SUBFR - 1]; /* gain_pitch from previous subframes*/
+ Word16 i, i_subfr_fx; /* tmp variables */
+ Word16 T0_fx = 0, T0_frac_fx = 0; /* close loop integer pitch and fractional part */
+ move16();
+ move16();
+ Word16 T0_min_fx, T0_max_fx; /* pitch variables */
+ Word16 *pt_pitch_fx; /* pointer to floating pitch buffer */
+ Word16 g_corr_fx[10]; /* ACELP correl, values + gain pitch */
+ Word16 clip_gain_fx; /* LSF clip gain */
+ const Word16 *p_Aw_fx, *p_Aq_fx; /* pointer to LP filter coeff. vector*/
Word16 error_fx = 0;
- Word16 gain_preQ_fx = 0; /* Gain of prequantizer excitation */
+ Word16 gain_preQ_fx = 0; /* Gain of prequantizer excitation */
+ move16();
+ move16();
Word16 code_preQ_fx[L_SUBFR]; /* Prequantizer excitation */
Word16 unbits_PI_fx = 0; /* number of unused bits for PI */
Word32 norm_gain_code_fx = 0;
+ move16();
+ move32();
Word16 pitch_limit_flag;
Word16 gcode16;
Word32 Ltmp;
@@ -105,6 +114,7 @@ void encod_gen_voic_fx(
Word16 lp_select, lp_flag, L_frame;
#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;
@@ -148,9 +158,9 @@ void encod_gen_voic_fx(
*unbits_fx = 0;
move16();
- p_Aw_fx = Aw_fx;
- p_Aq_fx = Aq_fx;
- pt_pitch_fx = pitch_buf_fx;
+ p_Aw_fx = Aw_fx; /* Q12 */
+ p_Aq_fx = Aq_fx; /* Q12 */
+ pt_pitch_fx = pitch_buf_fx; /* Q6 */
gain_preQ_fx = 0;
move16();
set16_fx( code_preQ_fx, 0, L_SUBFR );
@@ -186,19 +196,19 @@ void encod_gen_voic_fx(
* Compute impulse response, h1[], of weighted synthesis filter
*----------------------------------------------------------------*/
- Copy( &res_fx[i_subfr_fx], &exc_fx[i_subfr_fx], L_SUBFR );
+ Copy( &res_fx[i_subfr_fx], &exc_fx[i_subfr_fx], L_SUBFR ); /*Q_new*/
find_targets_fx( speech_fx, hLPDmem->mem_syn, i_subfr_fx, &hLPDmem->mem_w0, p_Aq_fx,
res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx );
- Copy_Scale_sig( h1_fx, h2_fx, L_SUBFR, -2 );
- Scale_sig( h1_fx, L_SUBFR, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution */
+ Copy_Scale_sig( h1_fx, h2_fx, L_SUBFR, -2 ); /*Q11*/
+ Scale_sig( h1_fx, L_SUBFR, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution Q(14+shift)*/
/* scaling of xn[] to limit dynamic at 12 bits */
Scale_sig( xn_fx, L_SUBFR, shift );
*pt_pitch_fx = pit_encode_fx( hBstr, st_fx->acelp_cfg.pitch_bits, st_fx->core_brate, 0, L_frame, st_fx->coder_type, &pitch_limit_flag, i_subfr_fx, exc_fx,
- L_SUBFR, st_fx->pitch, &T0_min_fx, &T0_max_fx, &T0_fx, &T0_frac_fx, h1_fx, xn_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf );
+ L_SUBFR, st_fx->pitch, &T0_min_fx, &T0_max_fx, &T0_fx, &T0_frac_fx, h1_fx, xn_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf ); /* Q6 */
tbe_celp_exc( L_frame, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx );
@@ -234,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
@@ -283,21 +289,17 @@ void encod_gen_voic_fx(
if ( EQ_16( hSC_VBR->last_ppp_mode, 1 ) )
{
/* SC-VBR - all other st->clip_var values will be updated even in a PPP frame */
- st_fx->clip_var_fx[1] = gain_pit_fx;
+ st_fx->clip_var_fx[1] = gain_pit_fx; /*Q14*/
move16();
}
}
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 );
-#else
- Lgcode = L_shl( gain_code_fx, Q_new ); /* scaled gain_code with Qnew -> Q16*/
- gcode16 = round_fx( Lgcode );
-#endif
+ gcode16 = round_fx_o( Lgcode, &Overflow ); /*Q0*/
- hLPDmem->tilt_code = Est_tilt2( &exc_fx[i_subfr_fx], gain_pit_fx, code_fx, Lgcode, &voice_fac_fx, shift );
+ hLPDmem->tilt_code = Est_tilt2( &exc_fx[i_subfr_fx], gain_pit_fx, code_fx, Lgcode, &voice_fac_fx, shift ); /* Q15 */
+ move16();
/*-----------------------------------------------------------------*
* Transform domain contribution encoding - inactive frames
@@ -315,54 +317,35 @@ void encod_gen_voic_fx(
*-----------------------------------------------------------------*/
/* st_fx->mem_w0 = xn[L_SUBFR-1] - (gain_pit*y1[L_SUBFR-1]) - (gain_code*y2[L_SUBFR-1]); */
- Ltmp = L_mult( gcode16, y2_fx[L_SUBFR - 1] );
- Ltmp = L_shl( Ltmp, add( 5, shift ) );
+ Ltmp = L_mult( gcode16, y2_fx[L_SUBFR - 1] ); /*Q10*/
+ Ltmp = L_shl( Ltmp, add( 5, shift ) ); /*Q15+shift*/
Ltmp = L_negate( Ltmp );
- Ltmp = L_mac( Ltmp, xn_fx[L_SUBFR - 1], 16384 );
- Ltmp = L_msu( Ltmp, y1_fx[L_SUBFR - 1], gain_pit_fx );
-#ifdef BASOP_NOGLOB
- Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) );
- hLPDmem->mem_w0 = round_fx_sat( Ltmp ); /*Q_new-1 */
-#else
- Ltmp = L_shl( Ltmp, sub( 1, shift ) );
- hLPDmem->mem_w0 = round_fx( Ltmp ); /*Q_new-1 */
-#endif
+ 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 */
+ Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); /* 15 + Q_new */
+ hLPDmem->mem_w0 = round_fx_sat( Ltmp ); /*Q_new-1 */
+ move16();
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 */
/* Compute exc2 */
- Ltmp = L_shl_o( L_mult( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 1, &Overflow );
- exc2_fx[i + i_subfr_fx] = round_fx_o( L_add_o( Ltmp, Ltmp1, &Overflow ), &Overflow );
-#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
+ 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();
/* code in Q9, gain_pit in Q14 */
- Ltmp = L_mult( gcode16, code_fx[i] );
- Ltmp = L_shl( Ltmp, 5 );
- Ltmp = L_mac( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx );
-#ifdef BASOP_NOGLOB
- Ltmp = L_shl_o( Ltmp, 1, &Overflow ); /* saturation can occur here */
- exc_fx[i + i_subfr_fx] = round_fx_o( L_add_o( Ltmp, Ltmp1, &Overflow ), &Overflow );
-#else
- Ltmp = L_shl( Ltmp, 1 ); /* saturation can occur here */
-
- exc_fx[i + i_subfr_fx] = round_fx( L_add( Ltmp, Ltmp1 ) );
-#endif
+ 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
@@ -374,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] );
-#ifdef BASOP_NOGLOB
- Ltmp = L_shl_o( Ltmp, 5, &Overflow );
- Ltmp = L_mac_o( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx, &Overflow );
- Ltmp = L_shl_o( Ltmp, 1, &Overflow ); /* saturation can occur here */
- exc_fx[i + i_subfr_fx] = round_fx_o( Ltmp, &Overflow );
-#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
+ 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 */
}
}
/*-----------------------------------------------------------------*
@@ -418,9 +394,9 @@ void encod_gen_voic_fx(
IF( st_fx->Opt_SC_VBR )
{
/* SC-VBR */
- hSC_VBR->prev_ppp_gain_pit_fx = gain_pit_fx;
+ hSC_VBR->prev_ppp_gain_pit_fx = gain_pit_fx; /* Q14 */
move16();
- hSC_VBR->prev_tilt_code_fx = hLPDmem->tilt_code;
+ hSC_VBR->prev_tilt_code_fx = hLPDmem->tilt_code; /* Q15 */
move16();
}
return;
@@ -428,20 +404,20 @@ void encod_gen_voic_fx(
void encod_gen_voic_ivas_fx(
Encoder_State *st_fx, /* i/o: state structure */
- const Word16 speech_fx[], /* i : input speech */
- const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes */
- const Word16 Aq_fx[], /* i : 12k8 Lp coefficient */
- const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */
- const Word16 *res_fx, /* i : residual signal */
- Word16 *syn_fx, /* i/o: core synthesis */
- Word16 *exc_fx, /* i/o: current non-enhanced excitation */
- Word16 *exc2_fx, /* i/o: current enhanced excitation */
- Word16 *pitch_buf_fx, /* i/o: floating pitch values for each subframe */
- Word16 *voice_factors_fx, /* o : voicing factors */
- Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */
- Word16 *unbits_fx, /* i/o: number of unused bits */
- const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
- const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer */
+ const Word16 speech_fx[], /* i : input speech Q0*/
+ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/
+ const Word16 Aq_fx[], /* i : 12k8 Lp coefficient Q12*/
+ const Word16 Es_pred_fx, /* i : predicted scaled innov. energy Q8*/
+ const Word16 *res_fx, /* i : residual signal Q_new*/
+ Word16 *syn_fx, /* i/o: core synthesis Q_new*/
+ Word16 *exc_fx, /* i/o: current non-enhanced excitation Q0*/
+ Word16 *exc2_fx, /* i/o: current enhanced excitation Q0*/
+ Word16 *pitch_buf_fx, /* i/o: floating pitch values for each subframe Q6*/
+ Word16 *voice_factors_fx, /* o : voicing factors Q15*/
+ Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q0*/
+ Word16 *unbits_fx, /* i/o: number of unused bits Q0*/
+ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/
+ const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/
Word16 shift,
Word16 Q_new )
{
@@ -454,23 +430,32 @@ void encod_gen_voic_ivas_fx(
Word16 y1_fx[L_SUBFR] = { 0 }; /* Filtered adaptive excitation */
Word16 y2_fx[L_SUBFR]; /* Filtered algebraic excitation */
Word16 gain_pit_fx = 0; /* Pitch gain */
- Word16 voice_fac_fx; /* Voicing factor */
- Word32 gain_code_fx = 0; /* Gain of code */
- Word16 gain_inov_fx = 0; /* inovation gain */
- Word32 gc_mem[NB_SUBFR - 1]; /* gain_code from previous subframes */
- Word16 gp_mem[NB_SUBFR - 1]; /* gain_pitch from previous subframes*/
- Word16 i, i_subfr_fx; /* tmp variables */
- Word16 T0_fx = 0, T0_frac_fx = 0; /* close loop integer pitch and fractional part */
- Word16 T0_min_fx, T0_max_fx; /* pitch variables */
- Word16 *pt_pitch_fx; /* pointer to floating pitch buffer */
- Word16 g_corr_fx[10]; /* ACELP correl, values + gain pitch */
- Word16 clip_gain_fx; /* LSF clip gain */
- const Word16 *p_Aw_fx, *p_Aq_fx; /* pointer to LP filter coeff. vector*/
+ move16();
+ Word16 voice_fac_fx; /* Voicing factor */
+ Word32 gain_code_fx = 0; /* Gain of code */
+ Word16 gain_inov_fx = 0; /* inovation gain */
+ move32();
+ move16();
+ Word32 gc_mem[NB_SUBFR - 1]; /* gain_code from previous subframes */
+ Word16 gp_mem[NB_SUBFR - 1]; /* gain_pitch from previous subframes*/
+ Word16 i, i_subfr_fx; /* tmp variables */
+ Word16 T0_fx = 0, T0_frac_fx = 0; /* close loop integer pitch and fractional part */
+ move16();
+ move16();
+ Word16 T0_min_fx, T0_max_fx; /* pitch variables */
+ Word16 *pt_pitch_fx; /* pointer to floating pitch buffer */
+ Word16 g_corr_fx[10]; /* ACELP correl, values + gain pitch */
+ Word16 clip_gain_fx; /* LSF clip gain */
+ const Word16 *p_Aw_fx, *p_Aq_fx; /* pointer to LP filter coeff. vector*/
Word16 error_fx = 0;
- Word16 gain_preQ_fx = 0; /* Gain of prequantizer excitation */
+ Word16 gain_preQ_fx = 0; /* Gain of prequantizer excitation */
+ move16();
+ move16();
Word16 code_preQ_fx[L_SUBFR]; /* Prequantizer excitation */
Word16 unbits_PI_fx = 0; /* number of unused bits for PI */
Word32 norm_gain_code_fx = 0;
+ move16();
+ move32();
Word16 pitch_limit_flag;
Word16 gcode16;
Word32 Ltmp;
@@ -482,6 +467,7 @@ void encod_gen_voic_ivas_fx(
Word16 lp_select, lp_flag, L_frame;
#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;
@@ -525,9 +511,9 @@ void encod_gen_voic_ivas_fx(
*unbits_fx = 0;
move16();
- p_Aw_fx = Aw_fx;
- p_Aq_fx = Aq_fx;
- pt_pitch_fx = pitch_buf_fx;
+ p_Aw_fx = Aw_fx; /*Q12*/
+ p_Aq_fx = Aq_fx; /*Q12*/
+ pt_pitch_fx = pitch_buf_fx; /*Q6*/
gain_preQ_fx = 0;
move16();
set16_fx( code_preQ_fx, 0, L_SUBFR );
@@ -563,19 +549,19 @@ void encod_gen_voic_ivas_fx(
* Compute impulse response, h1[], of weighted synthesis filter
*----------------------------------------------------------------*/
- Copy( &res_fx[i_subfr_fx], &exc_fx[i_subfr_fx], L_SUBFR );
+ Copy( &res_fx[i_subfr_fx], &exc_fx[i_subfr_fx], L_SUBFR ); /*Q_new*/
find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr_fx, &hLPDmem->mem_w0, p_Aq_fx,
res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx );
- Copy_Scale_sig( h1_fx, h2_fx, L_SUBFR, -2 );
- Scale_sig( h1_fx, L_SUBFR, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution */
+ Copy_Scale_sig( h1_fx, h2_fx, L_SUBFR, -2 ); /*Q11*/
+ Scale_sig( h1_fx, L_SUBFR, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution Q14+shift*/
/* scaling of xn[] to limit dynamic at 12 bits */
Scale_sig( xn_fx, L_SUBFR, shift );
*pt_pitch_fx = pit_encode_ivas_fx( hBstr, st_fx->acelp_cfg.pitch_bits, st_fx->core_brate, 0, L_frame, st_fx->coder_type, &pitch_limit_flag, i_subfr_fx, exc_fx,
- L_SUBFR, st_fx->pitch, &T0_min_fx, &T0_max_fx, &T0_fx, &T0_frac_fx, h1_fx, xn_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf );
+ L_SUBFR, st_fx->pitch, &T0_min_fx, &T0_max_fx, &T0_fx, &T0_frac_fx, h1_fx, xn_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf ); /* Q6 */
// tbe_celp_exc(L_frame, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx);
tbe_celp_exc_ivas( st_fx->element_mode, st_fx->idchan, L_frame, L_SUBFR, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx, st_fx->tdm_LRTD_flag );
@@ -603,8 +589,8 @@ void encod_gen_voic_ivas_fx(
* LP filtering of the adaptive excitation, codebook target computation
*-----------------------------------------------------------------*/
- lp_select = lp_filt_exc_enc_fx( MODE1, st_fx->coder_type, i_subfr_fx, exc_fx, h1_fx,
- xn_fx, y1_fx, xn2_fx, L_SUBFR, L_frame, g_corr_fx, clip_gain_fx, &gain_pit_fx, &lp_flag );
+ lp_select = lp_filt_exc_enc_ivas_fx( MODE1, st_fx->coder_type, i_subfr_fx, exc_fx, h1_fx,
+ xn_fx, y1_fx, xn2_fx, L_SUBFR, L_frame, g_corr_fx, clip_gain_fx, &gain_pit_fx, &lp_flag );
IF( EQ_16( lp_flag, NORMAL_OPERATION ) )
{
@@ -612,11 +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*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
+ hSpMusClas->lowrate_pitchGain = round_fx_o( L_mac_o( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 6554, gain_pit_fx, &Overflow ), &Overflow ); /* Q14 */
+ move16();
/*-----------------------------------------------------------------*
* Transform domain contribution encoding - active frames
@@ -661,21 +644,17 @@ void encod_gen_voic_ivas_fx(
if ( EQ_16( hSC_VBR->last_ppp_mode, 1 ) )
{
/* SC-VBR - all other st->clip_var values will be updated even in a PPP frame */
- st_fx->clip_var_fx[1] = gain_pit_fx;
+ st_fx->clip_var_fx[1] = gain_pit_fx; /* Q14 */
move16();
}
}
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 );
-#else
- Lgcode = L_shl( gain_code_fx, Q_new ); /* scaled gain_code with Qnew -> Q16*/
- gcode16 = round_fx( Lgcode );
-#endif
+ gcode16 = round_fx_o( Lgcode, &Overflow ); /* Q0 */
- hLPDmem->tilt_code = Est_tilt2( &exc_fx[i_subfr_fx], gain_pit_fx, code_fx, Lgcode, &voice_fac_fx, shift );
+ 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();
/*-----------------------------------------------------------------*
* Transform domain contribution encoding - inactive frames
@@ -693,54 +672,36 @@ void encod_gen_voic_ivas_fx(
*-----------------------------------------------------------------*/
/* st_fx->mem_w0 = xn[L_SUBFR-1] - (gain_pit*y1[L_SUBFR-1]) - (gain_code*y2[L_SUBFR-1]); */
- Ltmp = L_mult0( gcode16, y2_fx[L_SUBFR - 1] );
- Ltmp = L_shl( Ltmp, add( 5, shift ) ); // Q_new+14+shift
+ Ltmp = L_mult0( gcode16, y2_fx[L_SUBFR - 1] ); /* Q9 */
+ Ltmp = L_shl( Ltmp, add( 5, shift ) ); // Q_new+14+shift
Ltmp = L_negate( Ltmp );
- Ltmp = L_mac( Ltmp, xn_fx[L_SUBFR - 1], 16384 ); // Q_new-1+15+shift
- Ltmp = L_msu( Ltmp, y1_fx[L_SUBFR - 1], gain_pit_fx ); // 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 */
-#else
- Ltmp = L_shl( Ltmp, sub( 1, shift ) );
- hLPDmem->mem_w0 = round_fx( Ltmp ); /*Q_new-1 */
-#endif
+ Ltmp = L_mac( Ltmp, xn_fx[L_SUBFR - 1], 16384 /*Q14*/ ); // Q_new-1+15+shift
+ Ltmp = L_msu( Ltmp, y1_fx[L_SUBFR - 1], gain_pit_fx /*Q14*/ ); // Q_new-1+15+shift
+ Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); // Q_new+15
+ hLPDmem->mem_w0 = round_fx_sat( Ltmp ); /*Q_new-1 */
+ move16();
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 */
/* Compute exc2 */
- Ltmp = L_shl_o( L_mult( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 1, &Overflow );
- exc2_fx[i + i_subfr_fx] = round_fx_o( L_add_o( Ltmp, Ltmp1, &Overflow ), &Overflow );
-#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
+ 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();
/* code in Q9, gain_pit in Q14 */
- Ltmp = L_mult( gcode16, code_fx[i] );
- Ltmp = L_shl( Ltmp, 5 );
- Ltmp = L_mac( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx );
-#ifdef BASOP_NOGLOB
- Ltmp = L_shl_o( Ltmp, 1, &Overflow ); /* saturation can occur here */
- exc_fx[i + i_subfr_fx] = round_fx_o( L_add_o( Ltmp, Ltmp1, &Overflow ), &Overflow );
-#else
- Ltmp = L_shl( Ltmp, 1 ); /* saturation can occur here */
-
- exc_fx[i + i_subfr_fx] = round_fx( L_add( Ltmp, Ltmp1 ) );
-#endif
+ 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
@@ -752,18 +713,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] );
-#ifdef BASOP_NOGLOB
- Ltmp = L_shl_o( Ltmp, 5, &Overflow );
- Ltmp = L_mac_o( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx, &Overflow );
- Ltmp = L_shl_o( Ltmp, 1, &Overflow ); /* saturation can occur here */
- exc_fx[i + i_subfr_fx] = round_fx_o( Ltmp, &Overflow );
-#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
+ 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 */
}
}
/*-----------------------------------------------------------------*
diff --git a/lib_enc/enc_gen_voic_rf.c b/lib_enc/enc_gen_voic_rf.c
deleted file mode 100644
index 33df891b88cc405395df6c65726cdab8fcfcb354..0000000000000000000000000000000000000000
--- a/lib_enc/enc_gen_voic_rf.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 "cnst.h"
-#include "prot.h"
-#include "rom_com.h"
-#include "wmc_auto.h"
-#include "prot_fx.h"
diff --git a/lib_enc/enc_gen_voic_rf_fx.c b/lib_enc/enc_gen_voic_rf_fx.c
index ae70dc6b33a5f4761cc65573c624c993b2f5394b..e9c9d87f74bfa057d719079170b1496c85b61887 100644
--- a/lib_enc/enc_gen_voic_rf_fx.c
+++ b/lib_enc/enc_gen_voic_rf_fx.c
@@ -5,11 +5,9 @@
#include
#include "options.h"
#include "cnst.h"
-//#include "prot_fx.h"
#include "rom_com_fx.h"
#include "stl.h"
#include "rom_basop_util.h"
-//#include "basop_mpy.h"
#include "rom_com.h" /* Common constants */
#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
@@ -50,7 +48,7 @@ void reset_rf_indices_fx(
hRF->rf_target_bits = 0;
move16();
- hRF->rf_tcxltp_pitch_int_past = st->L_frame;
+ hRF->rf_tcxltp_pitch_int_past = st->L_frame; /* Q0 */
move16();
hRF->rf_last_tns_active = 0;
move16();
@@ -117,18 +115,18 @@ void reset_rf_indices_fx(
*-------------------------------------------------------------------*/
void coder_acelp_rf_fx(
ACELP_config *acelp_cfg, /*input/output: configuration of the ACELP coding*/
- const Word16 coder_type, /* input: coding type */
- const Word16 A[], /* input: coefficients 4xAz[M+1] */
- const Word16 Aq[], /* input: coefficients 4xAz_q[M+1] */
- Word16 speech[], /* input: speech[-M..lg] */
- const Word16 voicing[], /* input: open-loop LTP gain */
- const Word16 T_op[], /* input: open-loop LTP lag */
- Word16 stab_fac,
+ const Word16 coder_type, /* input: coding type Q0*/
+ const Word16 A[], /* input: coefficients 4xAz[M+1] Q12*/
+ const Word16 Aq[], /* input: coefficients 4xAz_q[M+1] Q12*/
+ Word16 speech[], /* input: speech[-M..lg] Q_new-1*/
+ const Word16 voicing[], /* input: open-loop LTP gain Q15*/
+ const Word16 T_op[], /* input: open-loop LTP lag Q0*/
+ Word16 stab_fac, /* Q15 */
Encoder_State *st,
- Word16 target_bits, /* i/o : coder memory state */
- const Word16 rf_frame_type, /* i : rf_frame_type */
- Word16 *exc_rf, /* i/o: pointer to RF excitation */
- Word16 *syn_rf, /* i/o: pointer to RF synthesis */
+ Word16 target_bits, /* i/o : coder memory state Q0*/
+ const Word16 rf_frame_type, /* i : rf_frame_type Q0*/
+ Word16 *exc_rf, /* i/o: pointer to RF excitation Q_new*/
+ Word16 *syn_rf, /* i/o: pointer to RF synthesis Q_new-1*/
Word16 Q_new,
Word16 shift )
{
@@ -169,6 +167,7 @@ void coder_acelp_rf_fx(
Word16 lp_select;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
RF_ENC_HANDLE hRF = st->hRF;
@@ -184,16 +183,26 @@ void coder_acelp_rf_fx(
voice_fac = 0;
prev_gain_pit = 0;
Es_pred_rf = 0;
+ move32();
+ move32();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+
set16_fx( code, 0, L_SUBFR );
/*-----------------------------------------------------------------------*
* Configure ACELP partial copy *
*------------------------------------------------------------------------*/
- tmp2 = BITS_ALLOC_config_acelp( target_bits, rf_frame_type, &( hRF->acelp_cfg_rf ), 0, st->nb_subfr );
+ tmp2 = BITS_ALLOC_config_acelp( target_bits, rf_frame_type, &( hRF->acelp_cfg_rf ), 0, st->nb_subfr ); /* Q0 */
/* Init Framing parameters */
- L_frame = st->L_frame;
-
+ L_frame = st->L_frame; /* Q0 */
+ move16();
/*------------------------------------------------------------------------*
* Initialize buffers *
*------------------------------------------------------------------------*/
@@ -219,10 +228,13 @@ void coder_acelp_rf_fx(
*------------------------------------------------------------------------*/
Es_pred_rf = 0;
+ move16();
+
+ test();
IF( acelp_cfg->nrg_mode > 0 && NE_16( rf_frame_type, RF_NELP ) )
{
Es_pred_enc_fx( &Es_pred_rf, &hRF->rf_indx_EsPred[0], L_frame, exc_rf, voicing,
- acelp_cfg->nrg_bits, acelp_cfg->nrg_mode > 1, Q_new );
+ acelp_cfg->nrg_bits, extract_l( GT_16( acelp_cfg->nrg_mode, 1 ) ), Q_new );
}
/*------------------------------------------------------------------------*
@@ -275,7 +287,7 @@ void coder_acelp_rf_fx(
Scale_sig( h1, L_SUBFR, add( 1, shift ) ); /* Q13+1-shift */
/* scaling of xn[] to limit dynamic at 12 bits */
- Scale_sig( xn, L_SUBFR, shift );
+ Scale_sig( xn, L_SUBFR, shift ); /* Q_new + shift */
}
@@ -290,12 +302,12 @@ void coder_acelp_rf_fx(
{
nelp_encoder_fx( st, exc_rf, exc_nelp, &Q_new, 0 );
}
- Copy( &exc_nelp[i_subfr], exc2, L_SUBFR );
- Copy( &exc_nelp[i_subfr], exc_rf, L_SUBFR );
+ Copy( &exc_nelp[i_subfr], exc2, L_SUBFR ); /* Q_new */
+ Copy( &exc_nelp[i_subfr], exc_rf, L_SUBFR ); /* Q_new */
}
ELSE
{
- clip_gain = Mode2_gp_clip( voicing, i_subfr, coder_type, xn, hRF->rf_clip_var, L_SUBFR, Q_xn );
+ clip_gain = Mode2_gp_clip_fx( voicing, i_subfr, coder_type, xn, hRF->rf_clip_var, L_SUBFR, Q_xn ); // Q0
/*-----------------------------------------------------------------*
* - find unity gain pitch excitation (adaptive codebook entry) *
@@ -311,7 +323,7 @@ void coder_acelp_rf_fx(
IF( acelp_cfg->ltp_bits != 0 )
{
- prm_rf = &hRF->rf_indx_pitch[0][nSubfr];
+ prm_rf = &hRF->rf_indx_pitch[0][nSubfr]; /* Q0 */
/* Adaptive Codebook (GC and VC) */
Mode2_pit_encode_fx( acelp_cfg->ltp_mode, i_subfr, &prm_rf, &exc_rf[i_subfr],
@@ -324,7 +336,7 @@ void coder_acelp_rf_fx(
move16();
if ( acelp_cfg->gains_mode[i_subfr / L_SUBFR] > 0 )
{
- rf_coder_type = acelp_cfg->gains_mode[i_subfr / L_SUBFR];
+ rf_coder_type = acelp_cfg->gains_mode[i_subfr / L_SUBFR]; /* Q0 */
move16();
}
@@ -335,7 +347,7 @@ void coder_acelp_rf_fx(
if ( EQ_16( acelp_cfg->ltf_mode, NORMAL_OPERATION ) )
{
- hRF->rf_indx_ltfMode[0][nSubfr] = lp_select;
+ hRF->rf_indx_ltfMode[0][nSubfr] = lp_select; /* Q0 */
move16();
}
}
@@ -402,7 +414,7 @@ void coder_acelp_rf_fx(
*----------------------------------------------------------*/
IF( acelp_cfg->gains_mode[i_subfr / L_SUBFR] != 0 )
{
- prm_rf = &hRF->rf_indx_gain[0][nSubfr];
+ prm_rf = &hRF->rf_indx_gain[0][nSubfr]; /* Q0 */
encode_acelp_gains_fx( code, acelp_cfg->gains_mode[j_subfr], Es_pred_rf,
clip_gain, &g_corr, &gain_pit, &gain_code, &prm_rf, &past_gcode,
@@ -428,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] );
-#ifdef BASOP_NOGLOB
- Ltmp = L_shl_o( Ltmp, add( 5, Q_xn ), &Overflow );
- Ltmp = L_mac_o( Ltmp, y1[L_SUBFR - 1], gain_pit, &Overflow );
-#else
- Ltmp = L_shl( Ltmp, add( 5, Q_xn ) );
- Ltmp = L_mac( Ltmp, y1[L_SUBFR - 1], gain_pit );
-#endif
+ 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 */
/* Add Gaussian contribution*/
- Ltmp2 = Mpy_32_16_1( gain_code2, y22[L_SUBFR - 1] );
-#ifdef BASOP_NOGLOB
- Ltmp2 = L_shl_o( Ltmp2, add( 5, Q_xn ), &Overflow );
- Ltmp = L_add_o( Ltmp, Ltmp2, &Overflow );
- hRF->rf_mem_w0 = sub_o( xn[L_SUBFR - 1], round_fx_o( L_shl_o( Ltmp, 1, &Overflow ), &Overflow ), &Overflow );
+ 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
/*-------------------------------------------------------*
@@ -465,34 +462,20 @@ 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] );
-#ifdef BASOP_NOGLOB
- Ltmp = L_shl_o( Ltmp, Q_new_p5, &Overflow );
- Ltmp = L_mac_o( Ltmp, gain_pit, exc_rf[i + i_subfr], &Overflow );
- exc2[i] = round_fx_o( L_shl_o( Ltmp, 1, &Overflow ), &Overflow );
-#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] );
-#ifdef BASOP_NOGLOB
- Ltmp2 = L_shl_o( Ltmp2, Q_new_p5, &Overflow );
- Ltmp = L_add_o( Ltmp, Ltmp2, &Overflow );
- Ltmp = L_shl_o( Ltmp, 1, &Overflow ); /* saturation can occur here */
- exc_rf[i + i_subfr] = round_fx_o( Ltmp, &Overflow );
-#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
+ 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();
+ 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();
}
tmp2 = L_SUBFR;
+ move16();
}
@@ -506,7 +489,8 @@ void coder_acelp_rf_fx(
}
}
- IF( i_subfr < sub( L_frame, L_SUBFR ) || NE_16( rf_frame_type, RF_NELP ) )
+ test();
+ IF( LT_16( i_subfr, sub( L_frame, L_SUBFR ) ) || NE_16( rf_frame_type, RF_NELP ) )
{
/*----------------------------------------------------------*
@@ -524,11 +508,12 @@ void coder_acelp_rf_fx(
p_Aq += ( M + 1 );
nSubfr++;
- st->gain_code[j_subfr] = gain_code;
+ st->gain_code[j_subfr] = gain_code; /* Q16 */
j_subfr = add( j_subfr, 1 );
/* copy current gain for next subframe use, in case there is no explicit encoding */
prev_gain_pit = gain_pit;
+ move16();
}
diff --git a/lib_enc/enc_higher_acelp.c b/lib_enc/enc_higher_acelp.c
deleted file mode 100644
index a01b229ff9cdd26addc170ce3100e40a897bbc12..0000000000000000000000000000000000000000
--- a/lib_enc/enc_higher_acelp.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
-#include "cnst.h"
-#include "prot.h"
-#include "rom_com.h"
-#include "wmc_auto.h"
-
-/*---------------------------------------------------------------------*
- * Local function prototypes
- *---------------------------------------------------------------------*/
diff --git a/lib_enc/enc_higher_acelp_fx.c b/lib_enc/enc_higher_acelp_fx.c
index da58fe7212671e771cf5d8ff01b7761b2866028e..c4c5444696d0efcd6603c75867f336f1d0973426 100644
--- a/lib_enc/enc_higher_acelp_fx.c
+++ b/lib_enc/enc_higher_acelp_fx.c
@@ -21,25 +21,25 @@ static void find_cn_fx( const Word16 xn[], const Word16 Ap[], const Word16 *p_Aq
#define Q_MINUS 4
void transf_cdbk_enc_fx(
Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word16 harm_flag_acelp, /* i : harmonic flag for higher rates ACELP */
- const Word16 i_subfr, /* i : subframe index */
- Word16 cn[], /* i/o: target vector in residual domain */
- Word16 exc[], /* i/o: pointer to excitation signal frame */
- const Word16 *p_Aq, /* i : 12k8 Lp coefficient */
- const Word16 Ap[], /* i : weighted LP filter coefficients */
- const Word16 h1[], /* i : weighted filter input response */
- Word16 xn[], /* i/o: target vector */
- Word16 xn2[], /* i/o: target vector for innovation search */
- Word16 y1[], /* i/o: zero-memory filtered adaptive excitation */
- const Word16 y2[], /* i : zero-memory filtered innovative excitation */
- const Word16 Es_pred, /* i : predicited scaled innovation energy */
- Word16 *gain_pit, /* i/o: adaptive excitation gain */
- const Word32 gain_code, /* i : innovative excitation gain */
- Word16 g_corr[], /* o : ACELP correlation values */
- const Word16 clip_gain, /* i : adaptive gain clipping flag */
- Word16 *gain_preQ, /* o : prequantizer excitation gain */
- Word16 code_preQ[], /* o : prequantizer excitation */
- Word16 *unbits, /* o : number of AVQ unused bits */
+ const Word16 harm_flag_acelp, /* i : harmonic flag for higher rates ACELP Q0*/
+ const Word16 i_subfr, /* i : subframe index Q0*/
+ Word16 cn[], /* i/o: target vector in residual domain Q_new*/
+ Word16 exc[], /* i/o: pointer to excitation signal frame Q_new*/
+ const Word16 *p_Aq, /* i : 12k8 Lp coefficient Q12*/
+ const Word16 Ap[], /* i : weighted LP filter coefficients Q12*/
+ const Word16 h1[], /* i : weighted filter input response Q15*/
+ Word16 xn[], /* i/o: target vector Q_new + shift -1*/
+ Word16 xn2[], /* i/o: target vector for innovation search Q_new + shift -1*/
+ Word16 y1[], /* i/o: zero-memory filtered adaptive excitation Q_new + shift -1*/
+ const Word16 y2[], /* i : zero-memory filtered innovative excitation Q9*/
+ const Word16 Es_pred, /* i : predicited scaled innovation energy Q8*/
+ Word16 *gain_pit, /* i/o: adaptive excitation gain Q14*/
+ const Word32 gain_code, /* i : innovative excitation gain Q16*/
+ Word16 g_corr[], /* o : ACELP correlation values Q15*/
+ const Word16 clip_gain, /* i : adaptive gain clipping flag Q0*/
+ Word16 *gain_preQ, /* o : prequantizer excitation gain Q2*/
+ Word16 code_preQ[], /* o : prequantizer excitation Q_AVQ_OUT_DEC*/
+ Word16 *unbits, /* o : number of AVQ unused bits Q0*/
const Word16 Q_new, /* i : Current frame scaling */
const Word16 shift /* i : shifting applied to y1, xn,... */
)
@@ -56,11 +56,12 @@ void transf_cdbk_enc_fx(
Word16 trgtSvPos;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
avq_bit_sFlag = 0;
move16();
- if ( GT_16( st_fx->element_mode, EVS_MONO ) )
+ if ( st_fx->element_mode > EVS_MONO )
{
avq_bit_sFlag = 1;
move16();
@@ -72,7 +73,7 @@ void transf_cdbk_enc_fx(
Nsv = 8;
move16();
- nBits = st_fx->acelp_cfg.AVQ_cdk_bits[shr( i_subfr, 6 )];
+ nBits = st_fx->acelp_cfg.AVQ_cdk_bits[shr( i_subfr, 6 )]; /* Q0 */
move16();
/* increase # of AVQ allocated bits by unused bits from the previous subframe */
@@ -85,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];*/
@@ -97,14 +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 );
-#ifdef BASOP_NOGLOB
- Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) );
- 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
+ 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();
}
find_cn_fx( x_tran, Ap, p_Aq, x_in );
}
@@ -152,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 );
@@ -179,34 +166,22 @@ void transf_cdbk_enc_fx(
m_corr = shr( m_corr, 1 );
e_corr = add( e_corr, 1 );
}
- m_corr = div_s( m_corr, m_ener );
+ 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
- stmp = round_fx_o( L_shl_o( Ltmp, 16, &Overflow ), &Overflow );
-#else
- stmp = round_fx( L_shl( Ltmp, 16 ) );
-#endif
+ 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
{
@@ -215,34 +190,29 @@ void transf_cdbk_enc_fx(
}
IF( GT_32( st_fx->core_brate, 56000 ) )
{
- index = usquant_fx( stmp, &stmp, G_AVQ_MIN_INACT_64k_Q12, G_AVQ_DELTA_INACT_64k_Q12 >> 1, ( 1 << G_AVQ_BITS ) );
+ index = usquant_fx( stmp, &stmp, G_AVQ_MIN_INACT_64k_Q12, G_AVQ_DELTA_INACT_64k_Q12 >> 1, ( 1 << G_AVQ_BITS ) ); /* Q0 */
}
ELSE IF( GT_32( st_fx->core_brate, 42000 ) )
{
- index = usquant_fx( stmp, &stmp, G_AVQ_MIN_INACT_48k_Q12, G_AVQ_DELTA_INACT_48k_Q12 >> 1, ( 1 << G_AVQ_BITS ) );
+ index = usquant_fx( stmp, &stmp, G_AVQ_MIN_INACT_48k_Q12, G_AVQ_DELTA_INACT_48k_Q12 >> 1, ( 1 << G_AVQ_BITS ) ); /* Q0 */
}
ELSE
{
- index = usquant_fx( stmp, &stmp, G_AVQ_MIN_INACT_Q12, G_AVQ_DELTA_INACT_Q12 >> 1, ( 1 << G_AVQ_BITS ) );
+ 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
{
IF( Es_pred < 0 )
{
- Es_pred_loc = shr( negate( Es_pred ), 2 );
+ Es_pred_loc = shr( negate( Es_pred ), 2 ); /* Q8 */
}
ELSE
{
- Es_pred_loc = Es_pred;
+ Es_pred_loc = Es_pred; /* Q8 */
move16();
}
@@ -252,9 +222,9 @@ void transf_cdbk_enc_fx(
test();
IF( m_corr > 0 && m_den > 0 )
{
- m_corr = div_s( 16384, m_den );
+ m_corr = div_s( 16384, m_den ); /* 14 - 8 - e_den */
e_corr = sub( 14 - 8, e_den );
- Ltmp = L_shr( Mult_32_16( Ltmp, m_corr ), e_corr );
+ Ltmp = L_shr( Mult_32_16( Ltmp, m_corr ), e_corr ); /* Q18 */
}
ELSE
{
@@ -263,11 +233,11 @@ void transf_cdbk_enc_fx(
test();
IF( LE_32( st_fx->core_brate, 42000 ) && GT_32( st_fx->core_brate, ACELP_24k40 ) )
{
- index = gain_quant_fx( &Ltmp, &stmp, LG10_G_AVQ_MIN_32kbps_Q14, LG10_G_AVQ_MAX_Q13, G_AVQ_BITS, &e_den );
+ index = gain_quant_fx( &Ltmp, &stmp, LG10_G_AVQ_MIN_32kbps_Q14, LG10_G_AVQ_MAX_Q13, G_AVQ_BITS, &e_den ); /* Q0 */
}
ELSE
{
- index = gain_quant_fx( &Ltmp, &stmp, LG10_G_AVQ_MIN_Q14, LG10_G_AVQ_MAX_Q13, G_AVQ_BITS, &e_den );
+ index = gain_quant_fx( &Ltmp, &stmp, LG10_G_AVQ_MIN_Q14, LG10_G_AVQ_MAX_Q13, G_AVQ_BITS, &e_den ); /* Q0 */
}
Ltmp = L_mult( stmp, Es_pred_loc ); /* Q0*Q8 -> Q9*/
Ltmp = L_shl( Ltmp, add( e_den, 9 ) ); /* Q18*/
@@ -296,7 +266,7 @@ void transf_cdbk_enc_fx(
AVQ_encmux_fx( st_fx->hBstr, -1, x_norm, &nBits, Nsv, nq, avq_bit_sFlag, trgtSvPos );
/* save # of AVQ unused bits for next subframe */
- *unbits = nBits;
+ *unbits = nBits; /* Q0 */
move16();
/* at the last subframe, write AVQ unused bits */
@@ -318,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 ) ) );
@@ -332,7 +298,7 @@ void transf_cdbk_enc_fx(
test();
IF( NE_16( st_fx->coder_type, INACTIVE ) && LE_32( st_fx->core_brate, MAX_BRATE_AVQ_EXC_TD ) && GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) && !harm_flag_acelp )
{
- Copy( x_tran, code_preQ, L_SUBFR );
+ Copy( x_tran, code_preQ, L_SUBFR ); /* Q_AVQ_OUT_DEC */
}
ELSE
{
@@ -403,16 +369,12 @@ 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 );
-#else
- *gain_pit = corr_xy1_fx( xn, y1, g_corr, L_SUBFR, 0 );
-#endif
+ *gain_pit = corr_xy1_fx( xn, y1, g_corr, L_SUBFR, 0, &Overflow ); /* Q14 */
/* clip gain if necessary to avoid problems at decoder */
test();
if ( EQ_16( clip_gain, 1 ) && GT_16( *gain_pit, 15565 ) )
{
- *gain_pit = 15565;
+ *gain_pit = 15565; /* 0.95 in Q15 */
move16();
}
updt_tar_fx( xn, xn2, y1, *gain_pit, L_SUBFR );
@@ -425,25 +387,25 @@ void transf_cdbk_enc_fx(
}
void transf_cdbk_enc_ivas_fx(
Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word16 harm_flag_acelp, /* i : harmonic flag for higher rates ACELP */
- const Word16 i_subfr, /* i : subframe index */
- Word16 cn[], /* i/o: target vector in residual domain */
- Word16 exc[], /* i/o: pointer to excitation signal frame */
- const Word16 *p_Aq, /* i : 12k8 Lp coefficient */
- const Word16 Ap[], /* i : weighted LP filter coefficients */
- const Word16 h1[], /* i : weighted filter input response */
- Word16 xn[], /* i/o: target vector */
- Word16 xn2[], /* i/o: target vector for innovation search */
- Word16 y1[], /* i/o: zero-memory filtered adaptive excitation */
- const Word16 y2[], /* i : zero-memory filtered innovative excitation */
- const Word16 Es_pred, /* i : predicited scaled innovation energy */
- Word16 *gain_pit, /* i/o: adaptive excitation gain */
- const Word32 gain_code, /* i : innovative excitation gain */
- Word16 g_corr[], /* o : ACELP correlation values */
- const Word16 clip_gain, /* i : adaptive gain clipping flag */
- Word16 *gain_preQ, /* o : prequantizer excitation gain */
- Word16 code_preQ[], /* o : prequantizer excitation */
- Word16 *unbits, /* o : number of AVQ unused bits */
+ const Word16 harm_flag_acelp, /* i : harmonic flag for higher rates ACELP Q0*/
+ const Word16 i_subfr, /* i : subframe index Q0*/
+ Word16 cn[], /* i/o: target vector in residual domain Q_new*/
+ Word16 exc[], /* i/o: pointer to excitation signal frame Q_new*/
+ const Word16 *p_Aq, /* i : 12k8 Lp coefficient Q12*/
+ const Word16 Ap[], /* i : weighted LP filter coefficients Q12*/
+ const Word16 h1[], /* i : weighted filter input response Q15*/
+ Word16 xn[], /* i/o: target vector Q_new + shift -1*/
+ Word16 xn2[], /* i/o: target vector for innovation search Q_new + shift -1*/
+ Word16 y1[], /* i/o: zero-memory filtered adaptive excitation Q_new + shift -1*/
+ const Word16 y2[], /* i : zero-memory filtered innovative excitation Q9*/
+ const Word16 Es_pred, /* i : predicited scaled innovation energy Q8*/
+ Word16 *gain_pit, /* i/o: adaptive excitation gain Q14*/
+ const Word32 gain_code, /* i : innovative excitation gain Q16*/
+ Word16 g_corr[], /* o : ACELP correlation values Q15*/
+ const Word16 clip_gain, /* i : adaptive gain clipping flag Q0*/
+ Word16 *gain_preQ, /* o : prequantizer excitation gain Q2*/
+ Word16 code_preQ[], /* o : prequantizer excitation Q_AVQ_OUT_DEC*/
+ Word16 *unbits, /* o : number of AVQ unused bits Q0*/
const Word16 Q_new, /* i : Current frame scaling */
const Word16 shift /* i : shifting applied to y1, xn,... */
)
@@ -460,11 +422,12 @@ void transf_cdbk_enc_ivas_fx(
Word16 trgtSvPos;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
avq_bit_sFlag = 0;
move16();
- if ( GT_16( st_fx->element_mode, EVS_MONO ) )
+ if ( st_fx->element_mode > EVS_MONO )
{
avq_bit_sFlag = 1;
move16();
@@ -476,7 +439,7 @@ void transf_cdbk_enc_ivas_fx(
Nsv = 8;
move16();
- nBits = st_fx->acelp_cfg.AVQ_cdk_bits[shr( i_subfr, 6 )];
+ nBits = st_fx->acelp_cfg.AVQ_cdk_bits[i_subfr >> 6]; /* Q0 */
move16();
/* increase # of AVQ allocated bits by unused bits from the previous subframe */
@@ -489,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];*/
@@ -501,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 );
-#ifdef BASOP_NOGLOB
- Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) );
- 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
+ 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 */
}
find_cn_fx( x_tran, Ap, p_Aq, x_in );
}
@@ -556,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 );
@@ -575,42 +523,30 @@ void transf_cdbk_enc_ivas_fx(
m_corr = extract_h( L_shl( L_corr, e_corr ) );
e_corr = sub( 30, add( e_corr, sub( Qdct, Q_AVQ_OUT ) ) );
e_ener = norm_l( L_ener );
- m_ener = extract_h( L_shl( L_ener, e_ener ) );
+ m_ener = extract_h( L_shl( L_ener, e_ener ) ); /* 30 - e-ener */
e_ener = sub( 30, e_ener );
IF( GT_16( m_corr, m_ener ) )
{
- m_corr = shr( m_corr, 1 );
+ m_corr = shr( m_corr, 1 ); /* e_corr + 1 */
e_corr = add( e_corr, 1 );
}
- m_corr = div_s( m_corr, m_ener );
+ 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
- stmp = round_fx_o( L_shl_o( Ltmp, 16, &Overflow ), &Overflow );
-#else
- stmp = round_fx( L_shl( Ltmp, 16 ) );
-#endif
+ 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
{
@@ -619,24 +555,20 @@ void transf_cdbk_enc_ivas_fx(
}
IF( GT_32( st_fx->core_brate, 56000 ) )
{
- index = usquant_fx( stmp, &stmp, G_AVQ_MIN_INACT_64k_Q12, G_AVQ_DELTA_INACT_64k_Q12 >> 1, ( 1 << G_AVQ_BITS ) );
+ index = usquant_fx( stmp, &stmp, G_AVQ_MIN_INACT_64k_Q12, G_AVQ_DELTA_INACT_64k_Q12 >> 1, ( 1 << G_AVQ_BITS ) ); /* Q0 */
}
ELSE IF( GT_32( st_fx->core_brate, 42000 ) )
{
- index = usquant_fx( stmp, &stmp, G_AVQ_MIN_INACT_48k_Q12, G_AVQ_DELTA_INACT_48k_Q12 >> 1, ( 1 << G_AVQ_BITS ) );
+ index = usquant_fx( stmp, &stmp, G_AVQ_MIN_INACT_48k_Q12, G_AVQ_DELTA_INACT_48k_Q12 >> 1, ( 1 << G_AVQ_BITS ) ); /* Q0 */
}
ELSE
{
- index = usquant_fx( stmp, &stmp, G_AVQ_MIN_INACT_Q12, G_AVQ_DELTA_INACT_Q12 >> 1, ( 1 << G_AVQ_BITS ) );
+ 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*/
+ move16();
}
ELSE
{
@@ -658,7 +590,7 @@ void transf_cdbk_enc_ivas_fx(
{
m_corr = div_s( 16384, m_den );
e_corr = sub( 14 - 8, e_den );
- Ltmp = L_shr( Mult_32_16( Ltmp, m_corr ), e_corr );
+ Ltmp = L_shr( Mult_32_16( Ltmp, m_corr ), e_corr ); /* Q16 */
}
ELSE
{
@@ -667,22 +599,23 @@ void transf_cdbk_enc_ivas_fx(
test();
IF( LE_32( st_fx->core_brate, 42000 ) && GT_32( st_fx->core_brate, ACELP_24k40 ) )
{
- index = gain_quant_fx( &Ltmp, &stmp, LG10_G_AVQ_MIN_32kbps_Q14, LG10_G_AVQ_MAX_Q13, G_AVQ_BITS, &e_den );
+ index = gain_quant_fx( &Ltmp, &stmp, LG10_G_AVQ_MIN_32kbps_Q14, LG10_G_AVQ_MAX_Q13, G_AVQ_BITS, &e_den ); /* Q0 */
}
ELSE
{
- index = gain_quant_fx( &Ltmp, &stmp, LG10_G_AVQ_MIN_Q14, LG10_G_AVQ_MAX_Q13, G_AVQ_BITS, &e_den );
+ index = gain_quant_fx( &Ltmp, &stmp, LG10_G_AVQ_MIN_Q14, LG10_G_AVQ_MAX_Q13, G_AVQ_BITS, &e_den ); /* Q0 */
}
Ltmp = L_mult( stmp, Es_pred_loc ); /* Q0*Q8 -> Q9*/
Ltmp = L_shl( Ltmp, add( e_den, 9 ) ); /* Q18*/
*gain_preQ = round_fx( Ltmp ); /* Q2*/
+ move16();
}
push_indice( st_fx->hBstr, IND_AVQ_GAIN, index, G_AVQ_BITS );
/*--------------------------------------------------------------*
* Encode and multiplex subvectors into bit-stream
*--------------------------------------------------------------*/
- trgtSvPos = Nsv - 1;
+ trgtSvPos = sub( Nsv, 1 );
move16();
test();
test();
@@ -712,7 +645,8 @@ void transf_cdbk_enc_ivas_fx(
{
i = s_min( *unbits, 16 );
push_indice( st_fx->hBstr, IND_UNUSED, 0, i );
- *unbits -= i;
+ *unbits = sub( *unbits, i );
+ move16();
}
}
@@ -722,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 ) ) );
@@ -736,7 +666,7 @@ void transf_cdbk_enc_ivas_fx(
test();
IF( NE_16( st_fx->coder_type, INACTIVE ) && LE_32( st_fx->core_brate, MAX_BRATE_AVQ_EXC_TD ) && GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) && !harm_flag_acelp )
{
- Copy( x_tran, code_preQ, L_SUBFR );
+ Copy( x_tran, code_preQ, L_SUBFR ); /* Q_AVQ_OUT_DEC */
}
ELSE
{
@@ -762,7 +692,7 @@ void transf_cdbk_enc_ivas_fx(
}
st_fx->last_nq_preQ = nq[7];
move16();
-#if 1 // def IVAS_CODE
+
/* TD pre-quantizer: in extreme cases at subframe boundaries, lower the preemphasis memory to avoid a saturation */
test();
test();
@@ -771,23 +701,21 @@ void transf_cdbk_enc_ivas_fx(
test();
IF( GT_16( st_fx->element_mode, EVS_MONO ) && NE_16( st_fx->coder_type, INACTIVE ) && GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) && LE_32( st_fx->core_brate, MAX_BRATE_AVQ_EXC_TD ) && !harm_flag_acelp && code_preQ[0] != 0 )
{
- // if ( (float) abs( st->last_code_preq ) > 16.0f * (float) fabs( code_preQ[0] ) )
- if ( GT_16( abs_s( st_fx->last_code_preq ), shl_sat( abs_s( code_preQ[0] ), 4 ) ) )
+ IF( GT_16( abs_s( st_fx->last_code_preq ), shl_sat( abs_s( code_preQ[0] ), 4 ) ) )
{
st_fx->mem_preemp_preQ_fx = shr( st_fx->mem_preemp_preQ_fx, 4 );
move16();
}
- // else if ( (float) abs( st->last_code_preq ) > 8.0f * (float) fabs( code_preQ[0] ) )
- if ( GT_16( abs_s( st_fx->last_code_preq ), shl_sat( abs_s( code_preQ[0] ), 3 ) ) )
+ ELSE IF( GT_16( abs_s( st_fx->last_code_preq ), shl_sat( abs_s( code_preQ[0] ), 3 ) ) )
{
st_fx->mem_preemp_preQ_fx = shr( st_fx->mem_preemp_preQ_fx, 3 );
move16();
}
}
- // st->last_code_preq = (int16_t) code_preQ[L_SUBFR - 1];
st_fx->last_code_preq = shr( code_preQ[L_SUBFR - 1], 9 ); // Q0
-#endif
+ move16();
+
PREEMPH_FX( code_preQ, FAC_PRE_AVQ_FX, L_SUBFR, &( st_fx->mem_preemp_preQ_fx ) );
/*--------------------------------------------------------------*
@@ -817,16 +745,13 @@ 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 );
-#else
- *gain_pit = corr_xy1_fx( xn, y1, g_corr, L_SUBFR, 0 );
-#endif
+ *gain_pit = corr_xy1_fx( xn, y1, g_corr, L_SUBFR, 0, &Overflow ); /* Q14 */
+ move16();
/* clip gain if necessary to avoid problems at decoder */
test();
if ( EQ_16( clip_gain, 1 ) && GT_16( *gain_pit, 15565 ) )
{
- *gain_pit = 15565;
+ *gain_pit = 15565; /* 0.95 in Q14 */
move16();
}
updt_tar_fx( xn, xn2, y1, *gain_pit, L_SUBFR );
@@ -842,16 +767,16 @@ void transf_cdbk_enc_ivas_fx(
*-------------------------------------------------------------------*/
static void find_cn_fx(
- const Word16 xn[], /* i : target signal */
- const Word16 Ap[], /* i : weighted LP filter coefficients */
- const Word16 *p_Aq, /* i : 12k8 LP coefficients */
- Word16 cn[] /* o : target signal in residual domain */
+ const Word16 xn[], /* i : target signal Qx*/
+ const Word16 Ap[], /* i : weighted LP filter coefficients Q12*/
+ const Word16 *p_Aq, /* i : 12k8 LP coefficients Q12*/
+ Word16 cn[] /* o : target signal in residual domain Qx*/
)
{
Word16 tmp, tmp_fl[L_SUBFR + M];
set16_fx( tmp_fl, 0, M );
- Copy( xn, tmp_fl + M, L_SUBFR );
+ Copy( xn, tmp_fl + M, L_SUBFR ); /* Qx */
tmp = 0;
move16();
PREEMPH_FX( tmp_fl + M, PREEMPH_FAC_16k, L_SUBFR, &tmp );
@@ -865,12 +790,12 @@ static void find_cn_fx(
/*-----------------------------------------------------------------*
* Transform domain contribution encoding
*-----------------------------------------------------------------*/
-Word16 gain_quant_fx( /* o: quantization index */
- Word32 *gain, /* i: quantized gain (Q16) */
- Word16 *gain16, /* o: quantized gain (expg) */
- const Word16 c_min, /* i: log10 of lower limit in Q14 */
- const Word16 c_max, /* i: log10 of upper limit in Q13 */
- const Word16 bits, /* i: number of bits to quantize */
+Word16 gain_quant_fx( /* o: quantization index Q0*/
+ Word32 *gain, /* i: quantized gain Q16*/
+ Word16 *gain16, /* o: quantized gain expg*/
+ const Word16 c_min, /* i: log10 of lower limit in Q14*/
+ const Word16 c_max, /* i: log10 of upper limit in Q13*/
+ const Word16 bits, /* i: number of bits to quantize Q0*/
Word16 *expg /* o: output exponent of gain16 */
)
{
@@ -903,25 +828,20 @@ Word16 gain_quant_fx( /* o: quantization index
/*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 );
- frac = div_s( shl( 1, sub( 14, exp ) ), tmp1 ); /*Q(15-exp)*/
- L_tmp = L_mult( tmp2, frac ); /*Q(30-exp)*/
- L_tmp = Mult_32_16( L_tmp, sub( levels, 1 ) ); /*Q(15-exp)*/
- index = extract_l( L_shr( L_add( L_tmp, shr( 1 << 14, exp ) ), sub( 15, exp ) ) );
+ frac = div_s( shl( 1, sub( 14, exp ) ), tmp1 ); /*Q(15-exp)*/
+ L_tmp = L_mult( tmp2, frac ); /*Q(30-exp)*/
+ L_tmp = Mult_32_16( L_tmp, sub( levels, 1 ) ); /*Q(15-exp)*/
+ index = extract_l( L_shr( L_add( L_tmp, shr( 1 << 14, exp ) ), sub( 15, exp ) ) ); /* Q0 */
}
ELSE
{
- L_tmp = L_mult( tmp2, sub( levels, 1 ) ); /*Q15*/
- index = extract_l( L_shr( L_add( L_tmp, 1 << 14 ), 15 ) );
+ L_tmp = L_mult( tmp2, sub( levels, 1 ) ); /*Q15*/
+ index = extract_l( L_shr( L_add( L_tmp, 1 << 14 ), 15 ) ); /* Q0 */
}
index = s_max( index, 0 );
diff --git a/lib_enc/enc_nelp.c b/lib_enc/enc_nelp.c
deleted file mode 100644
index fd4f3cb7c53af6bc1a4a149c6db6799b8f39655e..0000000000000000000000000000000000000000
--- a/lib_enc/enc_nelp.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 "rom_com.h"
-#include "prot.h"
-#include "wmc_auto.h"
diff --git a/lib_enc/enc_nelp_fx.c b/lib_enc/enc_nelp_fx.c
index 004b43fd364f96b4fc9196af485e3aa38531e207..c3eb2ae189911eb524d0ed32b015b0a58959554d 100644
--- a/lib_enc/enc_nelp_fx.c
+++ b/lib_enc/enc_nelp_fx.c
@@ -43,17 +43,17 @@
/*==============================================================================*/
void encod_nelp_fx(
Encoder_State *st_fx, /* i/o: state structure */
- const Word16 *speech_fx, /* i : input speech */
- const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes */
- const Word16 Aq_fx[], /* i : 12k8 Lp coefficient */
- Word16 *res_fx, /* o : residual signal */
- Word16 *synth_fx, /* o : core synthesis */
- Word16 *tmp_noise_fx, /* o : long-term noise energy */
- Word16 *exc_fx, /* i/o: current non-enhanced excitation */
- Word16 *exc2_fx, /* i/o: current enhanced excitation */
- Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */
- Word16 *voice_factors_fx, /* o : voicing factors */
- Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */
+ const Word16 *speech_fx, /* i : input speech Q_new-1*/
+ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/
+ const Word16 Aq_fx[], /* i : 12k8 Lp coefficient Q12*/
+ Word16 *res_fx, /* o : residual signal Q_new*/
+ Word16 *synth_fx, /* o : core synthesis Q_new*/
+ Word16 *tmp_noise_fx, /* o : long-term noise energy Q0*/
+ Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/
+ Word16 *exc2_fx, /* i/o: current enhanced excitation Q_new*/
+ Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6*/
+ Word16 *voice_factors_fx, /* o : voicing factors Q15*/
+ Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q_new*/
Word16 Q_new,
Word16 shift
@@ -69,6 +69,7 @@ void encod_nelp_fx(
Word16 saved_Q_new = Q_new;
Word16 reduce_gains = 0;
+ move16();
LPD_state_HANDLE hLPDmem = st_fx->hLPDmem;
SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR;
@@ -95,13 +96,13 @@ void encod_nelp_fx(
* target in residual domain "cn"
* - Compute impulse response, h1[], of weighted synthesis filter
*----------------------------------------------------------------*/
- Copy( &res_fx[i_subfr], &exc_fx[i_subfr], L_SUBFR );
+ Copy( &res_fx[i_subfr], &exc_fx[i_subfr], L_SUBFR ); /* Q_new */
find_targets_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq_fx,
res_fx, L_SUBFR, p_Aw_fx, TILT_FAC_FX, xn_fx, NULL, h1_fx );
/* scale xn[] and h1[] to avoid overflow in dot_product12() */
- Scale_sig( xn_fx, L_SUBFR, shift ); /* scaling of xn[] to limit dynamic at 12 bits */
+ Scale_sig( xn_fx, L_SUBFR, shift ); /* scaling of xn[] to limit dynamic at 12 bits Q_new -1 + shift */
IF( i_subfr == 0 )
{
@@ -109,11 +110,12 @@ void encod_nelp_fx(
IF( EQ_16( hSC_VBR->Local_VAD, 1 ) && EQ_16( st_fx->bwidth, NB ) )
{
reduce_gains = 1;
+ move16();
}
nelp_encoder_fx( st_fx, res_fx, exc_nelp_fx, &Q_new, reduce_gains );
- Scale_sig( exc_nelp_fx, L_FRAME, ( saved_Q_new - Q_new ) );
+ Scale_sig( exc_nelp_fx, L_FRAME, ( saved_Q_new - Q_new ) ); /* saved_Q_new*/
}
@@ -137,36 +139,32 @@ void encod_nelp_fx(
move16();
}
- Copy( exc_nelp_fx, exc_fx, L_FRAME );
+ Copy( exc_nelp_fx, exc_fx, L_FRAME ); /* Q_new */
/*-----------------------------------------------------------------*
* 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 */
- hSC_VBR->prev_tilt_code_fx = hLPDmem->tilt_code;
+ move16(); /* purely unvoiced */
+ hSC_VBR->prev_tilt_code_fx = hLPDmem->tilt_code; /* Q15 */
move16();
- Copy( exc_fx, exc2_fx, L_FRAME );
+ Copy( exc_fx, exc2_fx, L_FRAME ); /* Q_new */
hSC_VBR->prev_ppp_gain_pit_fx = 0;
move16();
hLPDmem->dm_fx.prev_state = 0;
move16();
- hLPDmem->dm_fx.prev_gain_pit[0] = hSC_VBR->prev_ppp_gain_pit_fx;
+ hLPDmem->dm_fx.prev_gain_pit[0] = hSC_VBR->prev_ppp_gain_pit_fx; /* Q14 */
move16();
FOR( j = 1; j < 5; j++ )
{
- hLPDmem->dm_fx.prev_gain_pit[j] = hLPDmem->dm_fx.prev_gain_pit[j - 1];
+ hLPDmem->dm_fx.prev_gain_pit[j] = hLPDmem->dm_fx.prev_gain_pit[j - 1]; /* Q14 */
move16();
}
interp_code_5over2_fx( exc2_fx, bwe_exc_fx, L_FRAME );
@@ -224,7 +222,7 @@ void encod_nelp_ivas_fx(
{
set16_fx( hSC_VBR->nelp_lp_fit_mem, 0, NELP_LP_ORDER * 2 );
}
- Scale_sig( hSC_VBR->nelp_lp_fit_mem, NELP_LP_ORDER * 2, sub( Q_new, st_fx->prev_Q_new ) );
+ Scale_sig( hSC_VBR->nelp_lp_fit_mem, NELP_LP_ORDER * 2, sub( Q_new, st_fx->prev_Q_new ) ); /* Q_new */
pz_filter_sp_fx( num_nelp_lp_fx, den_nelp_lp_fx, res_fx, res_fx, hSC_VBR->nelp_lp_fit_mem, NELP_LP_ORDER, NELP_LP_ORDER, L_FRAME, 3 ); /*16-Q of filter coeff*/
}
@@ -241,13 +239,13 @@ void encod_nelp_ivas_fx(
* target in residual domain "cn"
* - Compute impulse response, h1[], of weighted synthesis filter
*----------------------------------------------------------------*/
- Copy( &res_fx[i_subfr], &exc_fx[i_subfr], L_SUBFR );
+ Copy( &res_fx[i_subfr], &exc_fx[i_subfr], L_SUBFR ); /* Q_new */
find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq_fx,
res_fx, L_SUBFR, p_Aw_fx, TILT_FAC_FX, xn_fx, NULL, h1_fx );
/* scale xn[] and h1[] to avoid overflow in dot_product12() */
- Scale_sig( xn_fx, L_SUBFR, shift ); /* scaling of xn[] to limit dynamic at 12 bits */
+ Scale_sig( xn_fx, L_SUBFR, shift ); /* scaling of xn[] to limit dynamic at 12 bits Q_new-1+shift */
IF( i_subfr == 0 )
{
@@ -260,7 +258,7 @@ void encod_nelp_ivas_fx(
nelp_encoder_ivas_fx( st_fx, res_fx, exc_nelp_fx, &Q_new, reduce_gains );
- Scale_sig( exc_nelp_fx, L_FRAME, ( saved_Q_new - Q_new ) );
+ Scale_sig( exc_nelp_fx, L_FRAME, ( saved_Q_new - Q_new ) ); /* saved_Q_new */
}
@@ -275,42 +273,38 @@ void encod_nelp_ivas_fx(
p_Aw_fx += ( M + 1 );
p_Aq_fx += ( M + 1 );
- *pitch_buf_fx = L_SUBFR_Q6;
+ *pitch_buf_fx = L_SUBFR_Q6; /* Q6 */
move16();
pitch_buf_fx++;
}
- Copy( exc_nelp_fx, exc_fx, L_FRAME );
+ Copy( exc_nelp_fx, exc_fx, L_FRAME ); /* Q_new */
/*-----------------------------------------------------------------*
* 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 */
hSC_VBR->prev_tilt_code_fx = hLPDmem->tilt_code;
move16();
- Copy( exc_fx, exc2_fx, L_FRAME );
+ Copy( exc_fx, exc2_fx, L_FRAME ); /* Q_new */
hSC_VBR->prev_ppp_gain_pit_fx = 0;
move16();
hLPDmem->dm_fx.prev_state = 0;
move16();
- hLPDmem->dm_fx.prev_gain_pit[0] = hSC_VBR->prev_ppp_gain_pit_fx;
+ hLPDmem->dm_fx.prev_gain_pit[0] = hSC_VBR->prev_ppp_gain_pit_fx; /* Q14 */
move16();
FOR( j = 1; j < 5; j++ )
{
- hLPDmem->dm_fx.prev_gain_pit[j] = hLPDmem->dm_fx.prev_gain_pit[j - 1];
+ hLPDmem->dm_fx.prev_gain_pit[j] = hLPDmem->dm_fx.prev_gain_pit[j - 1]; /* Q14 */
move16();
}
interp_code_5over2_fx( exc2_fx, bwe_exc_fx, L_FRAME );
diff --git a/lib_enc/enc_pit_exc.c b/lib_enc/enc_pit_exc.c
deleted file mode 100644
index fd4f3cb7c53af6bc1a4a149c6db6799b8f39655e..0000000000000000000000000000000000000000
--- a/lib_enc/enc_pit_exc.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 "rom_com.h"
-#include "prot.h"
-#include "wmc_auto.h"
diff --git a/lib_enc/enc_pit_exc_fx.c b/lib_enc/enc_pit_exc_fx.c
index 08f6a7a3bdbd7df7d556bea5214432594b01b609..9e3b817b1042504d9eb995245224954bd5b992a1 100644
--- a/lib_enc/enc_pit_exc_fx.c
+++ b/lib_enc/enc_pit_exc_fx.c
@@ -48,21 +48,21 @@
/*=======================================================================*/
void enc_pit_exc_fx(
Encoder_State *st_fx, /* i/o: State structure */
- const Word16 *speech, /* i : Input speech */
- const Word16 Aw[], /* i : weighted A(z) unquantized for subframes */
- const Word16 Aq[], /* i : 12k8 Lp coefficient */
- const Word16 Es_pred, /* i : predicted scaled innov. energy */
- const Word16 *res, /* i : residual signal */
- Word16 *synth, /* i/o: core synthesis */
- Word16 *exc, /* i/o: current non-enhanced excitation */
- Word16 *T0, /* i/o: close loop integer pitch */
- Word16 *T0_frac, /* i/o: close-loop pitch period - fractional part */
- Word16 *pitch_buf, /* i/o: Fractionnal per subframe pitch */
- const Word16 nb_subfr, /* i : Number of subframe considered */
- Word16 *gpit, /* o : pitch mean gpit */
- Word16 *saved_bit_pos, /* o : saved position in the bitstream before pitch contribution */
- const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
- const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer */
+ const Word16 *speech, /* i : Input speech Q_new-1*/
+ const Word16 Aw[], /* i : weighted A(z) unquantized for subframes Q12*/
+ const Word16 Aq[], /* i : 12k8 Lp coefficient Q12*/
+ const Word16 Es_pred, /* i : predicted scaled innov. energy Q8*/
+ const Word16 *res, /* i : residual signal Q_new*/
+ Word16 *synth, /* i/o: core synthesis Q_new*/
+ Word16 *exc, /* i/o: current non-enhanced excitation Q_new*/
+ Word16 *T0, /* i/o: close loop integer pitch Q0*/
+ Word16 *T0_frac, /* i/o: close-loop pitch period - fractional part Q0*/
+ Word16 *pitch_buf, /* i/o: Fractionnal per subframe pitch Q6*/
+ const Word16 nb_subfr, /* i : Number of subframe considered Q0*/
+ Word16 *gpit, /* o : pitch mean gpit Q15*/
+ Word16 *saved_bit_pos, /* o : saved position in the bitstream before pitch contribution Q0*/
+ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/
+ const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/
Word16 Q_new,
Word16 shift )
{
@@ -87,6 +87,7 @@ void enc_pit_exc_fx(
Word16 cum_gpit, gpit_tmp;
Word32 Local_BR, Pitch_BR;
Word16 Pitch_CT, unbits_PI = 0; /* saved bits for PI */
+ move16();
Word32 norm_gain_code;
Word16 pitch_limit_flag;
Word16 h2[PIT_EXC_L_SUBFR + ( M + 1 )]; /* Impulse response vector */
@@ -104,6 +105,7 @@ void enc_pit_exc_fx(
LPD_state_HANDLE hLPDmem = st_fx->hLPDmem;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/*------------------------------------------------------------------*
@@ -114,11 +116,13 @@ void enc_pit_exc_fx(
move16(); /* always extended pitch Q range */
use_fcb = 0;
unbits_PI = 0;
- test();
- test();
+ move16();
+ move16();
Pitch_CT = GENERIC;
move16();
+ test();
+ test();
IF( st_fx->GSC_IVAS_mode > 0 && ( st_fx->GSC_noisy_speech || GT_32( st_fx->core_brate, GSC_H_RATE_STG ) ) )
{
Local_BR = ACELP_8k00;
@@ -134,7 +138,7 @@ void enc_pit_exc_fx(
Local_BR = ACELP_9k60;
move32();
}
- Pitch_BR = st_fx->core_brate;
+ Pitch_BR = st_fx->core_brate; /* Q0 */
move32();
}
}
@@ -148,7 +152,7 @@ void enc_pit_exc_fx(
move16();
if ( EQ_16( st_fx->L_frame, L_FRAME16k ) )
{
- Pitch_BR = st_fx->core_brate;
+ Pitch_BR = st_fx->core_brate; /* Q0 */
move32();
}
}
@@ -157,12 +161,12 @@ void enc_pit_exc_fx(
Local_BR = ACELP_7k20;
move32();
- Pitch_BR = st_fx->core_brate;
+ Pitch_BR = st_fx->core_brate; /* Q0 */
move32();
Pitch_CT = AUDIO;
move16();
- if ( EQ_16( st_fx->L_frame, L_FRAME16k ) )
+ IF( EQ_16( st_fx->L_frame, L_FRAME16k ) )
{
Local_BR = ACELP_13k20;
move32();
@@ -188,9 +192,9 @@ void enc_pit_exc_fx(
cum_gpit = 0;
move16();
- L_subfr = mult_r( st_fx->L_frame, div_s( 1, nb_subfr ) );
+ L_subfr = mult_r( st_fx->L_frame, div_s( 1, nb_subfr ) ); /* Q0 */
- lp_flag = st_fx->acelp_cfg.ltf_mode;
+ lp_flag = st_fx->acelp_cfg.ltf_mode; /* Q0 */
test();
test();
@@ -245,27 +249,27 @@ void enc_pit_exc_fx(
* target in residual domain "cn"
* Compute impulse response, h1[], of weighted synthesis filter
*----------------------------------------------------------------*/
- Copy( &res[i_subfr], &exc[i_subfr], L_subfr );
- /* condition on target (compared to float) has been put outside the loop */
-#if 1 // ndef BUG_FIX
+ Copy( &res[i_subfr], &exc[i_subfr], L_subfr ); /* Q_new */
+ /* condition on target (compared to float) has been put outside the loop */
+#if 1 // ndef BUG_FIX
find_targets_fx( speech, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq,
res, L_subfr, p_Aw, st_fx->preemph_fac, xn, cn, h1 );
#else
find_targets_fx( speech, hGSCEnc->mem_syn_tmp_fx, i_subfr, &hLPDmem->mem_w0, p_Aq, /*_DIFF_FLOAT_FIX_ --> Here I think mem_syn_tmp_fx should be used */
res, L_subfr, p_Aw, st_fx->preemph_fac, xn, cn, h1 );
#endif
- Copy_Scale_sig( h1, h2, L_subfr, -2 );
+ Copy_Scale_sig( h1, h2, L_subfr, -2 ); /* Q13 */
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 );
+ Scale_sig( xn, L_subfr, shift ); /* Q_new - 1 + shift */
/*----------------------------------------------------------------*
* Close-loop pitch search and quantization
* Adaptive exc. construction
*----------------------------------------------------------------*/
*pt_pitch = pit_encode_fx( hBstr, st_fx->acelp_cfg.pitch_bits, Pitch_BR, 0, st_fx->L_frame, Pitch_CT, &pitch_limit_flag, i_subfr, exc,
- L_subfr, st_fx->pitch, &T0_min, &T0_max, T0, T0_frac, h1, xn, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf );
+ L_subfr, st_fx->pitch, &T0_min, &T0_max, T0, T0_frac, h1, xn, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf ); /* Q6 */
/*-----------------------------------------------------------------*
* Find adaptive exitation
*-----------------------------------------------------------------*/
@@ -276,7 +280,7 @@ void enc_pit_exc_fx(
* or in case of floating point encoder & fixed p. decoder
*-----------------------------------------------------------------*/
- clip_gain = gp_clip_fx( st_fx->element_mode, st_fx->core_brate, st_fx->voicing_fx, i_subfr, AUDIO, xn, st_fx->clip_var_fx, sub( shift_wsp, 1 ) );
+ clip_gain = gp_clip_fx( st_fx->element_mode, st_fx->core_brate, st_fx->voicing_fx, i_subfr, AUDIO, xn, st_fx->clip_var_fx, sub( shift_wsp, 1 ) ); /* Q0 */
/*-----------------------------------------------------------------*
* Codebook target computation
@@ -284,7 +288,7 @@ void enc_pit_exc_fx(
*-----------------------------------------------------------------*/
lp_select = lp_filt_exc_enc_fx( MODE1, AUDIO, i_subfr, exc, h1,
- xn, y1, xn2, L_subfr, st_fx->L_frame, g_corr, clip_gain, &gain_pit, &lp_flag );
+ 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 ) )
{
@@ -292,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*/
@@ -312,12 +312,12 @@ void enc_pit_exc_fx(
{
IF( GE_32( st_fx->core_brate, MIN_RATE_FCB ) )
{
- pit_idx = vquant_fx( &gain_pit, mean_gp_fx, &gain_pit, dic_gp_fx, 1, 32 );
+ pit_idx = vquant_fx( &gain_pit, mean_gp_fx, &gain_pit, dic_gp_fx, 1, 32 ); /* Q0 */
push_indice_fx( hBstr, IND_PIT_IDX, pit_idx, 5 );
}
ELSE
{
- pit_idx = vquant_fx( &gain_pit, mean_gp_fx, &gain_pit, dic_gp_fx, 1, 16 );
+ pit_idx = vquant_fx( &gain_pit, mean_gp_fx, &gain_pit, dic_gp_fx, 1, 16 ); /* Q0 */
push_indice_fx( hBstr, IND_PIT_IDX, pit_idx, 4 );
}
}
@@ -352,16 +352,11 @@ 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 );
+ hLPDmem->tilt_code = Est_tilt2( &exc[i_subfr], gain_pit, code, Lgcode, &voice_fac, shift ); /* Q15 */
move16();
}
ELSE
@@ -374,36 +369,22 @@ void enc_pit_exc_fx(
*-----------------------------------------------------------------*/
IF( use_fcb != 0 )
{
- Ltmp = L_mult( gcode16, y2[L_subfr - 1] );
-#ifdef BASOP_NOGLOB
- Ltmp = L_shl_o( Ltmp, add( 5, shift ), &Overflow );
- Ltmp = L_negate( Ltmp );
- Ltmp = L_mac_o( Ltmp, xn[L_subfr - 1], 16384, &Overflow );
- Ltmp = L_msu_o( Ltmp, y1[L_subfr - 1], gain_pit, &Overflow );
- Ltmp = L_shl_o( Ltmp, sub( 1, shift ), &Overflow );
- hLPDmem->mem_w0 = 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_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( 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
+ Ltmp = L_mac_o( Ltmp, xn[L_subfr - 1], 16384, &Overflow ); /* Q_new + Q15 + shift */
+ Ltmp = L_msu_o( Ltmp, y1[L_subfr - 1], gain_pit, &Overflow ); /* Q_new + Q15 + shift */
+ 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( xn[L_subfr - 1], 16384 );
-#ifdef BASOP_NOGLOB
- Ltmp = L_msu_sat( Ltmp, y1[L_subfr - 1], gain_pit );
- Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) );
- hLPDmem->mem_w0 = 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 ) );
- hLPDmem->mem_w0 = round_fx( Ltmp ); /*Q_new-1 */
-#endif
+ 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();
}
/*-----------------------------------------------------------------*
@@ -415,19 +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] );
-#ifdef BASOP_NOGLOB
- Ltmp = L_shl_o( Ltmp, 5, &Overflow );
- Ltmp = L_mac_o( Ltmp, exc[i + i_subfr], gain_pit, &Overflow );
- Ltmp = L_shl_o( Ltmp, 1, &Overflow ); /* saturation can occur here */
- exc[i + i_subfr] = round_fx_o( Ltmp, &Overflow );
-#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
+ 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
@@ -435,14 +409,9 @@ void enc_pit_exc_fx(
FOR( i = 0; i < L_subfr; i++ )
{
- Ltmp = L_mult( exc[i + i_subfr], gain_pit );
-#ifdef BASOP_NOGLOB
- Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here */
- exc[i + i_subfr] = round_fx_sat( Ltmp );
-#else
- Ltmp = L_shl( Ltmp, 1 ); /* saturation can occur here */
- exc[i + i_subfr] = round_fx( Ltmp );
-#endif
+ Ltmp = L_mult( exc[i + i_subfr], gain_pit ); /* Q15 + 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 */
}
}
@@ -455,7 +424,7 @@ void enc_pit_exc_fx(
IF( EQ_16( L_subfr, 5 * L_SUBFR ) )
{
- cum_gpit = gpit_tmp;
+ cum_gpit = gpit_tmp; /* Q14 */
move16();
pt_pitch++;
*pt_pitch = *( pt_pitch - 1 );
@@ -478,7 +447,7 @@ void enc_pit_exc_fx(
{
IF( i_subfr == 0 )
{
- cum_gpit = mult_r( gpit_tmp, 13107 ); /* .4f*/
+ cum_gpit = mult_r( gpit_tmp, 13107 /* .4f in Q15 */ ); /* Q14 */
pt_pitch++;
*pt_pitch = *( pt_pitch - 1 );
move16();
@@ -488,7 +457,7 @@ void enc_pit_exc_fx(
}
ELSE
{
- cum_gpit = add( cum_gpit, mult_r( gpit_tmp, 19660 ) ); /*0.6*/
+ cum_gpit = add( cum_gpit, mult_r( gpit_tmp, 19660 /* 0.6 in Q15 */ ) ); /* Q14 */
pt_pitch++;
*pt_pitch = *( pt_pitch - 1 );
move16();
@@ -504,11 +473,11 @@ void enc_pit_exc_fx(
{
IF( i_subfr == 0 )
{
- cum_gpit = mult_r( gpit_tmp, 16384 );
+ cum_gpit = mult_r( gpit_tmp, 16384 /* 0.5 in Q15 */ ); /* Q14 */
}
ELSE
{
- cum_gpit = add( cum_gpit, mult_r( gpit_tmp, 16384 ) );
+ cum_gpit = add( cum_gpit, mult_r( gpit_tmp, 16384 /* 0.5 in Q15 */ ) ); /* Q14 */
}
p_Aw += 2 * ( M + 1 );
move16();
@@ -521,7 +490,7 @@ void enc_pit_exc_fx(
}
ELSE IF( EQ_16( L_subfr, 4 * L_SUBFR ) )
{
- cum_gpit = gpit_tmp;
+ cum_gpit = gpit_tmp; /* Q14 */
move16();
pt_pitch++;
@@ -541,11 +510,11 @@ void enc_pit_exc_fx(
IF( i_subfr == 0 )
{
- cum_gpit = mult_r( gpit_tmp, 8192 );
+ cum_gpit = mult_r( gpit_tmp, 8192 /* 0.25 in Q15 */ ); /* Q14 */
}
ELSE
{
- cum_gpit = add( cum_gpit, mult_r( gpit_tmp, 8192 ) );
+ cum_gpit = add( cum_gpit, mult_r( gpit_tmp, 8192 /* 0.25 in Q15 */ ) ); /* Q14 */
}
pt_pitch++;
@@ -554,31 +523,27 @@ 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*/
}
void enc_pit_exc_ivas_fx(
Encoder_State *st_fx, /* i/o: State structure */
- const Word16 *speech, /* i : Input speech */
- const Word16 Aw[], /* i : weighted A(z) unquantized for subframes */
- const Word16 Aq[], /* i : 12k8 Lp coefficient */
- const Word16 Es_pred, /* i : predicted scaled innov. energy */
- const Word16 *res, /* i : residual signal */
- Word16 *synth, /* i/o: core synthesis */
- Word16 *exc, /* i/o: current non-enhanced excitation */
- Word16 *T0, /* i/o: close loop integer pitch */
- Word16 *T0_frac, /* i/o: close-loop pitch period - fractional part */
- Word16 *pitch_buf, /* i/o: Fractionnal per subframe pitch */
- const Word16 nb_subfr, /* i : Number of subframe considered */
- Word16 *gpit, /* o : pitch mean gpit */
- Word16 *saved_bit_pos, /* o : saved position in the bitstream before pitch contribution */
- const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
- const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer */
+ const Word16 *speech, /* i : Input speech Q_new-1*/
+ const Word16 Aw[], /* i : weighted A(z) unquantized for subframes Q12*/
+ const Word16 Aq[], /* i : 12k8 Lp coefficient Q12*/
+ const Word16 Es_pred, /* i : predicted scaled innov. energy Q8*/
+ const Word16 *res, /* i : residual signal Q_new*/
+ Word16 *synth, /* i/o: core synthesis Q_new*/
+ Word16 *exc, /* i/o: current non-enhanced excitation Q_new*/
+ Word16 *T0, /* i/o: close loop integer pitch Q0*/
+ Word16 *T0_frac, /* i/o: close-loop pitch period - fractional part Q0*/
+ Word16 *pitch_buf, /* i/o: Fractionnal per subframe pitch Q6*/
+ const Word16 nb_subfr, /* i : Number of subframe considered Q0*/
+ Word16 *gpit, /* o : pitch mean gpit Q15*/
+ Word16 *saved_bit_pos, /* o : saved position in the bitstream before pitch contribution Q0*/
+ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/
+ const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/
Word16 Q_new,
Word16 shift )
{
@@ -620,6 +585,7 @@ void enc_pit_exc_ivas_fx(
LPD_state_HANDLE hLPDmem = st_fx->hLPDmem;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/*------------------------------------------------------------------*
@@ -630,13 +596,15 @@ void enc_pit_exc_ivas_fx(
move16(); /* always extended pitch Q range */
use_fcb = 0;
unbits_PI = 0;
- test();
- test();
+ move16();
+ move16();
Pitch_CT = GENERIC;
move16();
#ifdef MSAN_FIX
set16_fx( cn1, 0, PIT_EXC_L_SUBFR );
#endif
+ test();
+ test();
IF( st_fx->GSC_IVAS_mode > 0 && ( st_fx->GSC_noisy_speech || GT_32( st_fx->core_brate, GSC_H_RATE_STG ) ) )
{
Local_BR = ACELP_8k00;
@@ -706,9 +674,10 @@ void enc_pit_exc_ivas_fx(
cum_gpit = 0;
move16();
- L_subfr = mult_r( st_fx->L_frame, div_s( 1, nb_subfr ) );
+ L_subfr = mult_r( st_fx->L_frame, div_s( 1, nb_subfr ) ); /* Q0 */
lp_flag = st_fx->acelp_cfg.ltf_mode;
+ move16();
test();
test();
@@ -737,13 +706,14 @@ void enc_pit_exc_ivas_fx(
set16_fx( st_fx->acelp_cfg.fixed_cdk_index, 14, NB_SUBFR16k );
}
- *saved_bit_pos = st_fx->next_bit_pos_fx;
+ *saved_bit_pos = st_fx->next_bit_pos_fx; /* Q0 */
move16();
/*------------------------------------------------------------------*
* ACELP subframe loop
*------------------------------------------------------------------*/
cn = NULL;
+ test();
if ( EQ_16( L_subfr, L_SUBFR ) || EQ_16( L_subfr, L_SUBFR * 2 ) )
{
cn = cn1;
@@ -763,24 +733,25 @@ void enc_pit_exc_ivas_fx(
* target in residual domain "cn"
* Compute impulse response, h1[], of weighted synthesis filter
*----------------------------------------------------------------*/
- Copy( &res[i_subfr], &exc[i_subfr], L_subfr );
+ Copy( &res[i_subfr], &exc[i_subfr], L_subfr ); /* Q_new */
/* condition on target (compared to float) has been put outside the loop */
- find_targets_ivas_fx( speech, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq,
+ find_targets_ivas_fx( speech, hGSCEnc->mem_syn_tmp_fx, i_subfr, &hGSCEnc->mem_w0_tmp_fx, p_Aq,
res, L_subfr, p_Aw, st_fx->preemph_fac, xn, cn, h1 );
- Copy_Scale_sig( h1, h2, L_subfr, -2 );
+ Copy_Scale_sig( h1, h2, L_subfr, -2 ); /* Q13 */
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 );
+ Scale_sig( xn, L_subfr, shift ); /* Q_new - 1 + shift */
/*----------------------------------------------------------------*
* Close-loop pitch search and quantization
* Adaptive exc. construction
*----------------------------------------------------------------*/
*pt_pitch = pit_encode_ivas_fx( hBstr, st_fx->acelp_cfg.pitch_bits, Pitch_BR, 0, st_fx->L_frame, Pitch_CT, &pitch_limit_flag, i_subfr, exc,
- L_subfr, st_fx->pitch, &T0_min, &T0_max, T0, T0_frac, h1, xn, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf );
+ L_subfr, st_fx->pitch, &T0_min, &T0_max, T0, T0_frac, h1, xn, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf ); /* Q6 */
+ move16();
/*-----------------------------------------------------------------*
* Find adaptive exitation
*-----------------------------------------------------------------*/
@@ -791,15 +762,15 @@ void enc_pit_exc_ivas_fx(
* or in case of floating point encoder & fixed p. decoder
*-----------------------------------------------------------------*/
- clip_gain = gp_clip_fx( st_fx->element_mode, st_fx->core_brate, st_fx->voicing_fx, i_subfr, AUDIO, xn, st_fx->clip_var_fx, sub( shift_wsp, 1 ) );
+ clip_gain = gp_clip_fx( st_fx->element_mode, st_fx->core_brate, st_fx->voicing_fx, i_subfr, AUDIO, xn, st_fx->clip_var_fx, sub( shift_wsp, 1 ) ); /* Q0 */
/*-----------------------------------------------------------------*
* Codebook target computation
* (No LP filtering of the adaptive excitation)
*-----------------------------------------------------------------*/
- lp_select = lp_filt_exc_enc_fx( MODE1, AUDIO, i_subfr, exc, h1,
- xn, y1, xn2, L_subfr, st_fx->L_frame, g_corr, clip_gain, &gain_pit, &lp_flag );
+ lp_select = lp_filt_exc_enc_ivas_fx( MODE1, AUDIO, i_subfr, exc, h1,
+ xn, y1, xn2, L_subfr, st_fx->L_frame, g_corr, clip_gain, &gain_pit, &lp_flag ); /* Q0 */
IF( EQ_16( lp_flag, NORMAL_OPERATION ) )
{
@@ -807,11 +778,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*/
@@ -868,16 +835,11 @@ 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_tilt2( &exc[i_subfr], gain_pit, code, Lgcode, &voice_fac, shift );
+ hLPDmem->tilt_code = est_tilt_ivas_fx( &exc[i_subfr], gain_pit, code, gain_code, &voice_fac, Q_new, L_SUBFR, 0 ); // Q15
move16();
}
ELSE
@@ -891,35 +853,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
- hLPDmem->mem_w0 = 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 ) );
- hLPDmem->mem_w0 = round_fx( Ltmp ); /*Q_new-1 */
-#endif
+ hGSCEnc->mem_w0_tmp_fx = round_fx_o( Ltmp, &Overflow ); /*Q_new-1 */
}
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
- hLPDmem->mem_w0 = 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 ) );
- hLPDmem->mem_w0 = round_fx( Ltmp ); /*Q_new-1 */
-#endif
+ hGSCEnc->mem_w0_tmp_fx = round_fx_sat( Ltmp ); /*Q_new-1 */
}
/*-----------------------------------------------------------------*
@@ -931,19 +877,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] );
-#ifdef BASOP_NOGLOB
- Ltmp = L_shl_o( Ltmp, 5, &Overflow );
- Ltmp = L_mac_o( Ltmp, exc[i + i_subfr], gain_pit, &Overflow );
- Ltmp = L_shl_o( Ltmp, 1, &Overflow ); /* saturation can occur here */
- exc[i + i_subfr] = round_fx_o( Ltmp, &Overflow );
-#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
+ 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
@@ -951,14 +890,10 @@ void enc_pit_exc_ivas_fx(
FOR( i = 0; i < L_subfr; i++ )
{
- Ltmp = L_mult( exc[i + i_subfr], gain_pit );
-#ifdef BASOP_NOGLOB
- Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here */
- exc[i + i_subfr] = round_fx_sat( Ltmp );
-#else
- Ltmp = L_shl( Ltmp, 1 ); /* saturation can occur here */
- exc[i + i_subfr] = round_fx( Ltmp );
-#endif
+ Ltmp = L_mult( exc[i + i_subfr], gain_pit ); /* Q15 + 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();
}
}
@@ -994,7 +929,7 @@ void enc_pit_exc_ivas_fx(
{
IF( i_subfr == 0 )
{
- cum_gpit = mult_r( gpit_tmp, 13107 ); /* .4f*/
+ cum_gpit = mult_r( gpit_tmp, 13107 /* .4f in Q15 */ ); /* Q14 */
pt_pitch++;
*pt_pitch = *( pt_pitch - 1 );
move16();
@@ -1004,7 +939,7 @@ void enc_pit_exc_ivas_fx(
}
ELSE
{
- cum_gpit = add( cum_gpit, mult_r( gpit_tmp, 19660 ) ); /*0.6*/
+ cum_gpit = add( cum_gpit, mult_r( gpit_tmp, 19660 /* 0.6 in Q15 */ ) ); /* Q14 */
pt_pitch++;
*pt_pitch = *( pt_pitch - 1 );
move16();
@@ -1020,11 +955,11 @@ void enc_pit_exc_ivas_fx(
{
IF( i_subfr == 0 )
{
- cum_gpit = mult_r( gpit_tmp, 16384 );
+ cum_gpit = mult_r( gpit_tmp, 16384 /* 0.5 in Q15 */ ); /* Q14 */
}
ELSE
{
- cum_gpit = add( cum_gpit, mult_r( gpit_tmp, 16384 ) );
+ cum_gpit = add( cum_gpit, mult_r( gpit_tmp, 16384 /* 0.5 in Q15 */ ) ); /* Q14 */
}
p_Aw += 2 * ( M + 1 );
move16();
@@ -1057,11 +992,11 @@ void enc_pit_exc_ivas_fx(
IF( i_subfr == 0 )
{
- cum_gpit = mult_r( gpit_tmp, 8192 );
+ cum_gpit = mult_r( gpit_tmp, 8192 /* 0.25 in Q15 */ ); /* Q14 */
}
ELSE
{
- cum_gpit = add( cum_gpit, mult_r( gpit_tmp, 8192 ) );
+ cum_gpit = add( cum_gpit, mult_r( gpit_tmp, 8192 /* 0.25 in Q15 */ ) ); /* Q14 */
}
pt_pitch++;
@@ -1070,10 +1005,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_ppp.c b/lib_enc/enc_ppp.c
deleted file mode 100644
index e7a8ca967132cf8896fc4a231dbaf74eed596840..0000000000000000000000000000000000000000
--- a/lib_enc/enc_ppp.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/enc_ppp_fx.c b/lib_enc/enc_ppp_fx.c
index 775a863d3379a11e3bae50bc02bd3f27329329d0..f1a87d2d296ec128e7aa823519ec942206c2f42e 100644
--- a/lib_enc/enc_ppp_fx.c
+++ b/lib_enc/enc_ppp_fx.c
@@ -53,16 +53,16 @@ void E_LPC_f_lsp_a_conversion( const Word16 *lsp, Word16 *a, const Word16 m );
/*=======================================================================================*/
ivas_error encod_ppp_fx(
Encoder_State *st_fx, /* i/o: state structure */
- const Word16 speech_fx[], /* i : input speech Q_new*/
- const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes */
- const Word16 Aq_fx[], /* i : 12k8 Lp coefficient */
- Word16 *res_fx, /* i : residual signal Q_new*/
- Word16 *synth_fx, /* o : core synthesis Q-1*/
- Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/
- Word16 *exc2_fx, /* o : current enhanced excitation Q0*/
- Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6*/
- Word16 *voice_factors, /* o : voicing factors */
- Word16 *bwe_exc, /* o : excitation for SWB TBE */
+ const Word16 speech_fx[], /* i : input speech Q_new*/
+ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/
+ const Word16 Aq_fx[], /* i : 12k8 Lp coefficient Q14*/
+ Word16 *res_fx, /* i : residual signal Q_new*/
+ Word16 *synth_fx, /* o : core synthesis Q-1*/
+ Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/
+ Word16 *exc2_fx, /* o : current enhanced excitation Q0*/
+ Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6*/
+ Word16 *voice_factors, /* o : voicing factors Q15*/
+ Word16 *bwe_exc, /* o : excitation for SWB TBE Q_new*/
Word16 Q_new,
Word16 shift )
{
@@ -77,6 +77,7 @@ ivas_error encod_ppp_fx(
Word16 shift_wsp = add( Q_new, shift );
Word16 rate_ctrl_fx;
Word16 saved_Q_new = Q_new;
+ move16();
LPD_state_HANDLE hLPDmem = st_fx->hLPDmem;
SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR;
BSTR_ENC_HANDLE hBstr = st_fx->hBstr;
@@ -101,7 +102,7 @@ ivas_error encod_ppp_fx(
* Compute impulse response, h1[], of weighted synthesis filter
*----------------------------------------------------------------*/
- Copy( &res_fx[i_subfr], &exc_fx[i_subfr], L_SUBFR );
+ Copy( &res_fx[i_subfr], &exc_fx[i_subfr], L_SUBFR ); /* Q_new */
find_targets_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq_fx,
res_fx, L_SUBFR, p_Aw_fx, TILT_FAC_FX, xn_fx, NULL, h1_fx );
@@ -130,7 +131,7 @@ ivas_error encod_ppp_fx(
return error;
}
- Scale_sig( exc_fx, L_FRAME, ( saved_Q_new - Q_new ) );
+ Scale_sig( exc_fx, L_FRAME, ( saved_Q_new - Q_new ) ); /* saved_Q_new */
if ( EQ_16( hSC_VBR->bump_up, 1 ) )
{
i_subfr = L_FRAME;
@@ -199,37 +200,38 @@ ivas_error encod_ppp_fx(
}
ELSE
{
- Copy( excQ_ppp_fx, exc_fx, L_FRAME );
+ Copy( excQ_ppp_fx, exc_fx, L_FRAME ); /* Q_new */
/*-----------------------------------------------------------------*
* Updates: last value of new target is stored in mem_w0
*-----------------------------------------------------------------*/
hLPDmem->mem_w0 = sub( shr( xn_fx[L_SUBFR - 1], shift ), shr( exc_fx[L_FRAME - 1], 1 ) ); /*Q_new-1 */
+ move16();
- Copy( exc_fx, exc2_fx, L_FRAME );
+ Copy( exc_fx, exc2_fx, L_FRAME ); /* Q_new */
hLPDmem->dm_fx.prev_state = 2;
- move16(); /*Q0 dispMem index 0 */
- hLPDmem->dm_fx.prev_gain_pit[0] = hSC_VBR->prev_ppp_gain_pit_fx;
- move16(); /*Q14 dispMem index 2 */
+ move16(); /*Q0 dispMem index 0 */
+ hLPDmem->dm_fx.prev_gain_pit[0] = hSC_VBR->prev_ppp_gain_pit_fx; /* Q14 */
+ move16(); /*Q14 dispMem index 2 */
FOR( k = 1; k < 5; k++ )
{
- hLPDmem->dm_fx.prev_gain_pit[k] = hLPDmem->dm_fx.prev_gain_pit[k - 1];
+ hLPDmem->dm_fx.prev_gain_pit[k] = hLPDmem->dm_fx.prev_gain_pit[k - 1]; /* Q14 */
move16();
}
- hLPDmem->tilt_code = hSC_VBR->prev_tilt_code_fx;
+ hLPDmem->tilt_code = hSC_VBR->prev_tilt_code_fx; /* Q15 */
move16();
- Copy( pitch_fx, pitch_buf_fx, NB_SUBFR );
- pitch_buf_fx[NB_SUBFR16k - 1] = pitch_fx[NB_SUBFR - 1];
+ Copy( pitch_fx, pitch_buf_fx, NB_SUBFR ); /* Q6 */
+ pitch_buf_fx[NB_SUBFR16k - 1] = pitch_fx[NB_SUBFR - 1]; /* Q6 */
interp_code_5over2_fx( exc2_fx, bwe_exc, L_FRAME );
set16_fx( voice_factors, 0, NB_SUBFR16k );
}
- hSC_VBR->rate_control = rate_ctrl_fx;
+ hSC_VBR->rate_control = rate_ctrl_fx; /* Q0 */
move16();
set16_fx( hSC_VBR->nelp_lp_fit_mem, 0, NELP_LP_ORDER * 2 );
@@ -239,16 +241,16 @@ ivas_error encod_ppp_fx(
ivas_error encod_ppp_ivas_fx(
Encoder_State *st_fx, /* i/o: state structure */
- const Word16 speech_fx[], /* i : input speech Q_new*/
- const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes */
- const Word16 Aq_fx[], /* i : 12k8 Lp coefficient */
- Word16 *res_fx, /* i : residual signal Q_new*/
- Word16 *synth_fx, /* o : core synthesis Q-1*/
- Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/
- Word16 *exc2_fx, /* o : current enhanced excitation Q0*/
- Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6*/
- Word16 *voice_factors, /* o : voicing factors */
- Word16 *bwe_exc, /* o : excitation for SWB TBE */
+ const Word16 speech_fx[], /* i : input speech Q_new*/
+ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/
+ const Word16 Aq_fx[], /* i : 12k8 Lp coefficient Q12*/
+ Word16 *res_fx, /* i : residual signal Q_new*/
+ Word16 *synth_fx, /* o : core synthesis Q-1*/
+ Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/
+ Word16 *exc2_fx, /* o : current enhanced excitation Q0*/
+ Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6*/
+ Word16 *voice_factors, /* o : voicing factors Q15*/
+ Word16 *bwe_exc, /* o : excitation for SWB TBE Q_new*/
Word16 Q_new,
Word16 shift )
{
@@ -288,7 +290,7 @@ ivas_error encod_ppp_ivas_fx(
* Compute impulse response, h1[], of weighted synthesis filter
*----------------------------------------------------------------*/
- Copy( &res_fx[i_subfr], &exc_fx[i_subfr], L_SUBFR );
+ Copy( &res_fx[i_subfr], &exc_fx[i_subfr], L_SUBFR ); /* Q_new */
find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq_fx,
res_fx, L_SUBFR, p_Aw_fx, TILT_FAC_FX, xn_fx, NULL, h1_fx );
@@ -301,7 +303,7 @@ ivas_error encod_ppp_ivas_fx(
{
FOR( k = 0; k < M; k++ )
{
- p_Aq_curr_fx[k] = p_Aq_fx[k + ( 3 * ( M + 1 ) ) + 1];
+ p_Aq_curr_fx[k] = p_Aq_fx[k + ( 3 * ( M + 1 ) ) + 1]; /* Q12 */
move16();
}
@@ -317,7 +319,7 @@ ivas_error encod_ppp_ivas_fx(
return error;
}
- Scale_sig( exc_fx, L_FRAME, sub( saved_Q_new, Q_new ) );
+ Scale_sig( exc_fx, L_FRAME, sub( saved_Q_new, Q_new ) ); /* saved_Q_new */
if ( EQ_16( hSC_VBR->bump_up, 1 ) )
{
i_subfr = L_FRAME;
@@ -386,7 +388,7 @@ ivas_error encod_ppp_ivas_fx(
}
ELSE
{
- Copy( excQ_ppp_fx, exc_fx, L_FRAME );
+ Copy( excQ_ppp_fx, exc_fx, L_FRAME ); /* Q_new */
/*-----------------------------------------------------------------*
* Updates: last value of new target is stored in mem_w0
@@ -394,7 +396,7 @@ ivas_error encod_ppp_ivas_fx(
hLPDmem->mem_w0 = sub( shr( xn_fx[L_SUBFR - 1], shift ), shr( exc_fx[L_FRAME - 1], 1 ) ); /*Q_new-1 */
- Copy( exc_fx, exc2_fx, L_FRAME );
+ Copy( exc_fx, exc2_fx, L_FRAME ); /* Q_new */
hLPDmem->dm_fx.prev_state = 2;
move16(); /*Q0 dispMem index 0 */
@@ -403,11 +405,11 @@ ivas_error encod_ppp_ivas_fx(
FOR( k = 1; k < 5; k++ )
{
- hLPDmem->dm_fx.prev_gain_pit[k] = hLPDmem->dm_fx.prev_gain_pit[k - 1];
+ hLPDmem->dm_fx.prev_gain_pit[k] = hLPDmem->dm_fx.prev_gain_pit[k - 1]; /* Q14 */
move16();
}
- hLPDmem->tilt_code = hSC_VBR->prev_tilt_code_fx;
+ hLPDmem->tilt_code = hSC_VBR->prev_tilt_code_fx; /* Q15 */
move16();
Copy( pitch_fx, pitch_buf_fx, NB_SUBFR );
pitch_buf_fx[NB_SUBFR16k - 1] = pitch_fx[NB_SUBFR - 1];
@@ -416,7 +418,7 @@ ivas_error encod_ppp_ivas_fx(
set16_fx( voice_factors, 0, NB_SUBFR16k );
}
- hSC_VBR->rate_control = rate_ctrl_fx;
+ hSC_VBR->rate_control = rate_ctrl_fx; /* Q0 */
move16();
set16_fx( hSC_VBR->nelp_lp_fit_mem, 0, NELP_LP_ORDER * 2 );
diff --git a/lib_enc/enc_prm.c b/lib_enc/enc_prm.c
index 1239a104c6ca7ec870e4cfb55f2167f8f2f14a4d..6c6ade036529b72b8094b3e06bc1ccb654ef6094 100644
--- a/lib_enc/enc_prm.c
+++ b/lib_enc/enc_prm.c
@@ -44,16 +44,16 @@
/*-------------------------------------------------------------------*
- * writeTCXMode()
+ * writeTCXMode_fx()
*
* write TCX mode
*--------------------------------------------------------------------*/
-void writeTCXMode(
- Encoder_State *st, /* i/o: encoder state structure */
- BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
- const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) */
- Word16 *nbits_start /* o : nbits start */
+void writeTCXMode_fx(
+ Encoder_State *st, /* i/o: encoder state structure */
+ BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
+ const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/
+ Word16 *nbits_start /* o : nbits start Q0*/
)
{
UWord16 index;
@@ -110,8 +110,8 @@ void writeTCXMode(
}
/* retrieve the number of bits for signaling */
- idx = add( idx, 1 );
- nBits = extract_l( acelp_sig_tbl[idx] );
+ idx = add( idx, 1 ); /* Q0 */
+ nBits = extract_l( acelp_sig_tbl[idx] ); /* Q0 */
/* retrieve the signaling index */
idx = add( idx, 1 );
@@ -203,14 +203,14 @@ void writeTCXMode(
/*-------------------------------------------------------------------*
- * writeTCXWindowing()
+ * writeTCXWindowing_fx()
*
* write TCX transform type
*-------------------------------------------------------------------*/
-void writeTCXWindowing(
+void writeTCXWindowing_fx(
BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
- const Word16 overlap_mode /* i : overlap mode */
+ const Word16 overlap_mode /* i : overlap mode Q0*/
)
{
diff --git a/lib_enc/enc_prm_fx.c b/lib_enc/enc_prm_fx.c
index c67a3f447e06f266b3e8f0c986862d5b53e3e17e..d394fa2d3acbf5703f33934fcbf011e214f0b7a7 100644
--- a/lib_enc/enc_prm_fx.c
+++ b/lib_enc/enc_prm_fx.c
@@ -17,9 +17,10 @@
static void enc_prm_hm(
- Word16 *prm_hm,
+ Word16 *prm_hm, /* Q0 */
Encoder_State *st,
- Word16 L_frame )
+ Word16 L_frame /* Q0 */
+)
{
Word8 flag;
BSTR_ENC_HANDLE hBstr = st->hBstr;
@@ -55,9 +56,10 @@ static void enc_prm_hm(
}
}
static void enc_prm_hm_ivas_fx(
- Word16 *prm_hm,
+ Word16 *prm_hm, /* Q0 */
Encoder_State *st,
- Word16 L_frame )
+ Word16 L_frame /* Q0 */
+)
{
Word8 flag;
BSTR_ENC_HANDLE hBstr = st->hBstr;
@@ -100,9 +102,11 @@ static void enc_prm_hm_ivas_fx(
* encode RF parameters for ACELP and TCX partial copy *
*-----------------------------------------------------------------*/
-void enc_prm_rf_ivas_fx( Encoder_State *st,
- const Word16 rf_frame_type,
- const Word16 fec_offset )
+void enc_prm_rf_ivas_fx(
+ Encoder_State *st,
+ const Word16 rf_frame_type, /* Q0 */
+ const Word16 fec_offset /* Q0 */
+)
{
Word16 sfr, nb_subfr, n, index;
Word16 ltp_mode, ltf_mode, gains_mode;
@@ -111,7 +115,7 @@ void enc_prm_rf_ivas_fx( Encoder_State *st,
BSTR_ENC_HANDLE hBstr = st->hBstr;
- nb_subfr = st->nb_subfr;
+ nb_subfr = st->nb_subfr; /* Q0 */
move16();
/* partial copy bitstream writing */
test();
@@ -269,9 +273,11 @@ void enc_prm_rf_ivas_fx( Encoder_State *st,
/* write RF frame type last in the bitstream */
push_next_indice( hBstr, rf_frame_type, 3 );
}
-void enc_prm_rf_fx( Encoder_State *st,
- const Word16 rf_frame_type,
- const Word16 fec_offset )
+void enc_prm_rf_fx(
+ Encoder_State *st,
+ const Word16 rf_frame_type, /* Q0 */
+ const Word16 fec_offset /* Q0 */
+)
{
Word16 sfr, nb_subfr, n, index;
Word16 ltp_mode, ltf_mode, gains_mode;
@@ -280,7 +286,7 @@ void enc_prm_rf_fx( Encoder_State *st,
BSTR_ENC_HANDLE hBstr = st->hBstr;
- nb_subfr = st->nb_subfr;
+ nb_subfr = st->nb_subfr; /* Q0 */
/* partial copy bitstream writing */
test();
@@ -370,9 +376,9 @@ void enc_prm_rf_fx( Encoder_State *st,
/* ES pred */
push_next_indice_fx( hBstr, hRF->rf_indx_EsPred[fec_offset], 3 );
- ltp_mode = ACELP_LTP_MODE[1][1][rf_frame_type];
- ltf_mode = ACELP_LTF_MODE[1][1][rf_frame_type];
- gains_mode = ACELP_GAINS_MODE[1][1][rf_frame_type];
+ ltp_mode = ACELP_LTP_MODE[1][1][rf_frame_type]; /* Q0 */
+ ltf_mode = ACELP_LTF_MODE[1][1][rf_frame_type]; /* Q0 */
+ gains_mode = ACELP_GAINS_MODE[1][1][rf_frame_type]; /* Q0 */
/* Subframe parameters */
FOR( sfr = 0; sfr < nb_subfr; sfr++ )
@@ -446,13 +452,14 @@ void enc_prm_rf_fx( Encoder_State *st,
void enc_prm_fx(
const Word16 coder_type, /* (i) : coding type */
- Word16 param[], /* (i) : parameters */
- Word16 param_lpc[], /* (i) : LPC parameters */
+ Word16 param[], /* (i) : parameters Q0*/
+ Word16 param_lpc[], /* (i) : LPC parameters Q0*/
Encoder_State *st, /* i/o : quantization Analysis values */
- Word16 L_frame,
+ Word16 L_frame, /* Q0 */
CONTEXT_HM_CONFIG hm_cfg[],
- Word16 *bits_param_lpc,
- Word16 no_param_lpc )
+ Word16 *bits_param_lpc, /* Q0 */
+ Word16 no_param_lpc /* Q0 */
+)
{
Word16 j, k, n, sfr, core, last_core, *prm, tmp;
Word16 nbits_start, total_nbbits;
@@ -507,7 +514,7 @@ void enc_prm_fx(
move16();
move16();
j = 0;
- nbits_start = hBstr->nb_bits_tot;
+ nbits_start = hBstr->nb_bits_tot; /* Q0 */
/*--------------------------------------------------------------------------------*
@@ -517,7 +524,7 @@ void enc_prm_fx(
IF( EQ_16( st->mdct_sw, MODE1 ) )
{
/* Adjust st->bits_frame_core not to subtract MODE2 bandwidth signaling */
- st->bits_frame_core = add( st->bits_frame_core, FrameSizeConfig[st->frame_size_index].bandwidth_bits );
+ st->bits_frame_core = add( st->bits_frame_core, FrameSizeConfig[st->frame_size_index].bandwidth_bits ); /* Q0 */
/* Write MODE1 core mode signaling */
signalling_mode1_tcx20_enc_fx( st, 1 );
@@ -565,19 +572,19 @@ void enc_prm_fx(
}
/* retrieve the number of bits for signalling */
- nBits = (Word16) acelp_sig_tbl[++idx];
+ nBits = (Word16) acelp_sig_tbl[++idx]; /* Q0 */
/* retrieve the signalling index */
- idx = add( idx, 1 );
- start_idx = idx;
+ idx = add( idx, 1 ); /* Q0 */
+ start_idx = idx; /* Q0 */
tmp32 = SIG2IND_fx( coder_type, st->bwidth, st->sharpFlag, st->rf_mode );
WHILE( NE_32( acelp_sig_tbl[idx], tmp32 ) )
{
- idx = add( idx, 1 );
+ idx = add( idx, 1 ); /* Q0 */
}
push_next_indice_fx( hBstr, idx - start_idx, nBits );
push_next_indice_fx( hBstr, 0, 1 ); /* Indicate to the decoder that the core is ACELP*/
- nbits_start = 3;
+ nbits_start = 3; /* Q0 */
}
ELSE
{
@@ -612,7 +619,7 @@ void enc_prm_fx(
}
/* retrieve the number of bits for signalling */
- nBits = (Word16) acelp_sig_tbl[++idx];
+ nBits = (Word16) acelp_sig_tbl[++idx]; /* Q0 */
test();
test();
@@ -628,8 +635,8 @@ void enc_prm_fx(
}
/* retrieve the signalling index */
- idx = add( idx, 1 );
- start_idx = idx;
+ idx = add( idx, 1 ); /* Q0 */
+ start_idx = idx; /* Q0 */
tmp32 = SIG2IND_fx( st->hTcxCfg->coder_type, st->bwidth, st->sharpFlag, st->rf_mode );
WHILE( NE_32( acelp_sig_tbl[idx], tmp32 ) )
{
@@ -720,7 +727,7 @@ void enc_prm_fx(
st->glr_reset = 0;
move16();
- nbits_header = sub( hBstr->nb_bits_tot, nbits_start );
+ nbits_header = sub( hBstr->nb_bits_tot, nbits_start ); /* Q0 */
/*--------------------------------------------------------------------------------*
@@ -730,7 +737,7 @@ void enc_prm_fx(
IF( s_and( st->enableTcxLpc != 0, core != ACELP_CORE ) )
{
/* Encode the indices */
- nbits_lpc = enc_lsf_tcxlpc_fx( ¶m_lpc, hBstr );
+ nbits_lpc = enc_lsf_tcxlpc_fx( ¶m_lpc, hBstr ); /* Q0 */
}
ELSE
{
@@ -745,7 +752,7 @@ void enc_prm_fx(
move16();
}
- nbits_lpc = encode_lpc_avq_fx( hBstr, numlpc, param_lpc, st->core, st->element_mode );
+ nbits_lpc = encode_lpc_avq_fx( hBstr, numlpc, param_lpc, st->core, st->element_mode ); /* Q0 */
}
ELSE IF( EQ_16( st->lpcQuantization, 1 ) )
{
@@ -753,11 +760,11 @@ void enc_prm_fx(
test();
IF( EQ_32( st->sr_core, 16000 ) && EQ_16( coder_type, VOICED ) && EQ_16( core, ACELP_CORE ) )
{
- nbits_lpc = lsf_bctcvq_encprm_fx( hBstr, param_lpc, bits_param_lpc, no_param_lpc );
+ nbits_lpc = lsf_bctcvq_encprm_fx( hBstr, param_lpc, bits_param_lpc, no_param_lpc ); /* Q0 */
}
ELSE
{
- nbits_lpc = lsf_msvq_ma_encprm_fx( hBstr, param_lpc, core, coder_type, st->acelp_cfg.midLpc, bits_param_lpc, no_param_lpc );
+ nbits_lpc = lsf_msvq_ma_encprm_fx( hBstr, param_lpc, core, coder_type, st->acelp_cfg.midLpc, bits_param_lpc, no_param_lpc ); /* Q0 */
}
}
ELSE
@@ -787,7 +794,7 @@ void enc_prm_fx(
}
/* Mean energy (2 or 3 bits) */
- n = ACELP_NRG_BITS[st->acelp_cfg.nrg_mode];
+ n = ACELP_NRG_BITS[st->acelp_cfg.nrg_mode]; /* Q0 */
IF( n != 0 )
{
@@ -800,7 +807,7 @@ void enc_prm_fx(
{
/* Pitch lag (4, 5, 6, 8 or 9 bits) */
move16();
- n = ACELP_LTP_BITS_SFR[st->acelp_cfg.ltp_mode][sfr];
+ n = ACELP_LTP_BITS_SFR[st->acelp_cfg.ltp_mode][sfr]; /* Q0 */
IF( n != 0 )
{
@@ -841,7 +848,7 @@ void enc_prm_fx(
push_next_indice_fx( hBstr, prm[j++], bitcnt );
}
- j = add( j_old, 8 );
+ j = add( j_old, 8 ); /* Q0 */
}
/* Gains (5b, 6b or 7b / subfr) */
@@ -887,9 +894,9 @@ void enc_prm_fx(
j = add( j, 3 );
/* TCX spectral data */
- lg = L_frame;
+ lg = L_frame; /* Q0 */
move16();
- lgFB = st->hTcxCfg->tcx_coded_lines;
+ lgFB = st->hTcxCfg->tcx_coded_lines; /* Q0 */
move16();
IF( last_core == ACELP_CORE )
@@ -899,7 +906,7 @@ void enc_prm_fx(
lgFB = add( lgFB, shr( lgFB, 2 ) );
if ( st->hTcxCfg->lfacNext < 0 )
{
- lg = sub( lg, st->hTcxCfg->lfacNext );
+ lg = sub( lg, st->hTcxCfg->lfacNext ); /* Q0 */
}
}
@@ -912,7 +919,7 @@ void enc_prm_fx(
IF( st->hTcxCfg->fIsTNSAllowed )
{
WriteTnsData_fx( st->hTcxCfg->pCurrentTnsConfig, prm + j, &nTnsParams, st, &nTnsBits );
- j = add( j, nTnsParams );
+ j = add( j, nTnsParams ); /* Q0 */
}
hm_size = shl( mult( st->hTcxCfg->bandwidth, lg ), 1 );
@@ -950,17 +957,17 @@ void enc_prm_fx(
IGFEncWriteBitstream_fx( st->hIGFEnc, hBstr, &st->hIGFEnc->infoTotalBitsPerFrameWritten, IGF_GRID_LB_NORM, 1 );
}
}
- total_nbbits = sub( hBstr->nb_bits_tot, nbits_start );
+ total_nbbits = sub( hBstr->nb_bits_tot, nbits_start ); /* Q0 */
if ( EQ_16( st->rf_mode, 1 ) )
{
- total_nbbits = add( total_nbbits, st->rf_target_bits_write );
+ total_nbbits = add( total_nbbits, st->rf_target_bits_write ); /* Q0 */
}
- nbits_tcx = sub( st->bits_frame_core, total_nbbits );
+ nbits_tcx = sub( st->bits_frame_core, total_nbbits ); /* Q0 */
IF( hTcxEnc->tcx_lpc_shaped_ari != 0 )
{
push_next_bits_fx( hBstr, &prm[++j], nbits_tcx );
- j = add( j, nbits_tcx );
+ j = add( j, nbits_tcx ); /* Q0 */
}
ELSE
{
@@ -990,7 +997,7 @@ void enc_prm_fx(
move16();
IF( st->igf )
{
- nbits_igf = IGFEncWriteConcatenatedBitstream_fx( st->hIGFEnc, hBstr );
+ nbits_igf = IGFEncWriteConcatenatedBitstream_fx( st->hIGFEnc, hBstr ); /* Q0 */
}
FOR( k = 0; k < 2; k++ )
{
@@ -1004,7 +1011,7 @@ void enc_prm_fx(
j = 0;
move16();
- nbits_tcx = total_nbbits = sub( hBstr->nb_bits_tot, nbits_start );
+ nbits_tcx = total_nbbits = sub( hBstr->nb_bits_tot, nbits_start ); /* Q0 */
test();
IF( st->enablePlcWaveadjust && k )
@@ -1043,11 +1050,11 @@ void enc_prm_fx(
IF( s_and( k == 0, last_core == ACELP_CORE ) )
{
/* ACE->TCX transition */
- lg = add( lg, st->hTcxCfg->tcx_offset );
+ lg = add( lg, st->hTcxCfg->tcx_offset ); /* Q0 */
lgFB = add( lgFB, shr( lgFB, 1 ) );
if ( st->hTcxCfg->lfacNext < 0 )
{
- lg = sub( lg, st->hTcxCfg->lfacNext );
+ lg = sub( lg, st->hTcxCfg->lfacNext ); /* Q0 */
}
}
@@ -1084,9 +1091,9 @@ void enc_prm_fx(
}
j = add( j, NPRM_CTX_HM );
- total_nbbits = sub( hBstr->nb_bits_tot, nbits_start );
+ total_nbbits = sub( hBstr->nb_bits_tot, nbits_start ); /* Q0 */
- nbits_tcx = sub( shr( sub( add( sub( sub( sub( st->bits_frame_core, nbits_header ), nbits_lpc ), nbits_igf ), 1 ), k ), 1 ), sub( total_nbbits, nbits_tcx ) );
+ nbits_tcx = sub( shr( sub( add( sub( sub( sub( st->bits_frame_core, nbits_header ), nbits_lpc ), nbits_igf ), 1 ), k ), 1 ), sub( total_nbbits, nbits_tcx ) ); /* Q0 */
phm_cfg = NULL;
move16();
@@ -1109,7 +1116,7 @@ void enc_prm_fx(
*--------------------------------------------------------------------------------*/
- total_nbbits = sub( hBstr->nb_bits_tot, nbits_start );
+ total_nbbits = sub( hBstr->nb_bits_tot, nbits_start ); /* Q0 */
/* Check if total encoded bits does not exceed CBR target bits (->this must never happen) */
@@ -1132,10 +1139,10 @@ void enc_prm_fx(
void writeLPCparam_fx(
Encoder_State *st, /* i/o: encoder state structure */
BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
- const Word16 param_lpc[], /* i : LPC parameters to write */
- const Word16 bits_param_lpc[], /* i : bits per LPC parameter */
- const Word16 no_param_lpc, /* i : number of LPC parameters */
- Word16 *nbits_lpc /* o : LPC bits written */
+ const Word16 param_lpc[], /* i : LPC parameters to write Q0*/
+ const Word16 bits_param_lpc[], /* i : bits per LPC parameter Q0*/
+ const Word16 no_param_lpc, /* i : number of LPC parameters Q0*/
+ Word16 *nbits_lpc /* o : LPC bits written Q0*/
)
{
Word16 numlpc;
@@ -1144,7 +1151,7 @@ void writeLPCparam_fx(
IF( st->enableTcxLpc && st->core != ACELP_CORE )
{
/* Encode the indices */
- *nbits_lpc = enc_lsf_tcxlpc_ivas_fx( ¶m_lpc, hBstr );
+ *nbits_lpc = enc_lsf_tcxlpc_ivas_fx( ¶m_lpc, hBstr ); /* Q0 */
move16();
}
ELSE
@@ -1163,7 +1170,7 @@ void writeLPCparam_fx(
move16();
}
- *nbits_lpc = encode_lpc_avq_ivas_fx( hBstr, numlpc, param_lpc, st->core, st->element_mode );
+ *nbits_lpc = encode_lpc_avq_ivas_fx( hBstr, numlpc, param_lpc, st->core, st->element_mode ); /* Q0 */
move16();
}
ELSE IF( EQ_16( st->lpcQuantization, 1 ) )
@@ -1174,12 +1181,12 @@ void writeLPCparam_fx(
{
assert( st->element_mode == EVS_MONO );
- *nbits_lpc = lsf_bctcvq_encprm_ivas_fx( hBstr, param_lpc, bits_param_lpc, no_param_lpc );
+ *nbits_lpc = lsf_bctcvq_encprm_ivas_fx( hBstr, param_lpc, bits_param_lpc, no_param_lpc ); /* Q0 */
move16();
}
ELSE
{
- *nbits_lpc = lsf_msvq_ma_encprm_ivas_fx( hBstr, param_lpc, st->core, st->coder_type, st->acelp_cfg.midLpc, bits_param_lpc, no_param_lpc );
+ *nbits_lpc = lsf_msvq_ma_encprm_ivas_fx( hBstr, param_lpc, st->core, st->coder_type, st->acelp_cfg.midLpc, bits_param_lpc, no_param_lpc ); /* Q0 */
move16();
}
}
@@ -1199,17 +1206,18 @@ void writeLPCparam_fx(
*-------------------------------------------------------------------*/
void writeTCXparam_fx(
- Encoder_State *st, /* i/o: Encoder State handle */
- BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
- CONTEXT_HM_CONFIG hm_cfg[], /* i/o: HM config */
- Word16 param[], /* i : parameters */
- const Word16 nbits_header,
- const Word16 nbits_start,
- const Word16 nbits_lpc,
- const Word16 *no_param_tns, /* i : number of TNS parameters per subframe */
- Word16 p_param[2], /* i/o: pointer to parameters from previous bs writing */
- const Word16 target_bitsTCX10[2],
- const Word16 pre_past_flag )
+ Encoder_State *st, /* i/o: Encoder State handle */
+ BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
+ CONTEXT_HM_CONFIG hm_cfg[], /* i/o: HM config */
+ Word16 param[], /* i : parameters Q0*/
+ const Word16 nbits_header, /* Q0 */
+ const Word16 nbits_start, /* Q0 */
+ const Word16 nbits_lpc, /* Q0 */
+ const Word16 *no_param_tns, /* i : number of TNS parameters per subframe Q0*/
+ Word16 p_param[2], /* i/o: pointer to parameters from previous bs writing Q0*/
+ const Word16 target_bitsTCX10[2], /* Q0 */
+ const Word16 pre_past_flag /* Q0 */
+)
{
Word16 *prm;
Word16 j, k, nSubframes, core, last_core;
@@ -1264,7 +1272,7 @@ void writeTCXparam_fx(
test();
IF( LT_16( st->element_mode, IVAS_CPE_MDCT ) && k == 0 && st->igf && EQ_16( core, TCX_10_CORE ) )
{
- nbits_igf = IGFEncWriteConcatenatedBitstream_ivas_fx( st->hIGFEnc, hBstr );
+ nbits_igf = IGFEncWriteConcatenatedBitstream_ivas_fx( st->hIGFEnc, hBstr ); /* Q0 */
}
flag_ctx_hm = 0;
@@ -1274,7 +1282,7 @@ void writeTCXparam_fx(
j = 0;
move16();
- nbits_tcx = total_nbbits = sub( hBstr->nb_bits_tot, nbits_start );
+ nbits_tcx = total_nbbits = sub( hBstr->nb_bits_tot, nbits_start ); /* Q0 */
move16();
test();
@@ -1319,7 +1327,7 @@ void writeTCXparam_fx(
}
ELSE
{
- j = add( j, sub( p_param[k], 2 ) );
+ j = add( j, sub( p_param[k], 2 ) ); /* Q0 */
}
/* TCX spectral data */
@@ -1331,12 +1339,12 @@ void writeTCXparam_fx(
IF( post_part && k == 0 && last_core == ACELP_CORE )
{
/* ACE->TCX transition */
- lg = add( lg, st->hTcxCfg->tcx_offset );
- lgFB = add( lgFB, shr( lgFB, sub( 3, nSubframes ) ) );
+ lg = add( lg, st->hTcxCfg->tcx_offset ); /* Q0 */
+ lgFB = add( lgFB, shr( lgFB, sub( 3, nSubframes ) ) ); /* Q0 */
IF( st->hTcxCfg->lfacNext < 0 )
{
- lg = sub( lg, st->hTcxCfg->lfacNext );
+ lg = sub( lg, st->hTcxCfg->lfacNext ); /* Q0 */
}
}
@@ -1368,7 +1376,7 @@ void writeTCXparam_fx(
IF( no_param_tns && ( st->hTcxEnc->tnsData[k].nFilters < 0 ) )
{
/* a negative filter count means that the filters are identical to those in the first channel at the same sub-frame */
- nTnsParams = no_param_tns[k];
+ nTnsParams = no_param_tns[k]; /* Q0 */
move16();
}
ELSE
@@ -1377,14 +1385,14 @@ void writeTCXparam_fx(
}
IF( no_param_tns )
{
- nTnsBits = add( nTnsBits, 1 );
+ nTnsBits = add( nTnsBits, 1 ); /* Q0 */
}
- j = add( j, nTnsParams );
+ j = add( j, nTnsParams ); /* Q0 */
}
IF( post_part )
{
- hm_size = imult1616( mult( 2, st->hTcxCfg->bandwidth ), lg );
+ hm_size = imult1616( mult( 2, st->hTcxCfg->bandwidth ), lg ); /* Q0 */
test();
test();
@@ -1430,35 +1438,35 @@ void writeTCXparam_fx(
IGFEncWriteBitstream_ivas_fx( st->hIGFEnc, hBstr, &st->hIGFEnc->infoTotalBitsPerFrameWritten, gridIdx, 1 );
}
- total_nbbits = sub( hBstr->nb_bits_tot, nbits_start );
+ total_nbbits = sub( hBstr->nb_bits_tot, nbits_start ); /* Q0 */
IF( EQ_16( core, TCX_20_CORE ) )
{
IF( st->rf_mode )
{
- total_nbbits = add( total_nbbits, st->rf_target_bits_write );
+ total_nbbits = add( total_nbbits, st->rf_target_bits_write ); /* Q0 */
}
- nbits_tcx = sub( st->bits_frame_core, total_nbbits );
+ nbits_tcx = sub( st->bits_frame_core, total_nbbits ); /* Q0 */
}
ELSE /* TCX_10_CORE */
{
- nbits_tcx = sub( shr( sub( add( sub( sub( sub( st->bits_frame_core, nbits_header ), nbits_lpc ), nbits_igf ), 1 ), k ), 1 ), sub( total_nbbits, nbits_tcx ) );
+ nbits_tcx = sub( shr( sub( add( sub( sub( sub( st->bits_frame_core, nbits_header ), nbits_lpc ), nbits_igf ), 1 ), k ), 1 ), sub( total_nbbits, nbits_tcx ) ); /* Q0 */
}
}
ELSE
{
/*Context HM flag*/
- p_param[k] = j;
+ p_param[k] = j; /* Q0 */
move16();
}
}
ELSE
{
- nbits_tcx = st->bits_frame_channel;
+ nbits_tcx = st->bits_frame_channel; /* Q0 */
move16();
IF( EQ_16( core, TCX_10_CORE ) )
{
- nbits_tcx = sub( target_bitsTCX10[k], NBITS_TCX_GAIN + NOISE_FILL_RANGES * NBITS_NOISE_FILL_LEVEL );
+ nbits_tcx = sub( target_bitsTCX10[k], NBITS_TCX_GAIN + NOISE_FILL_RANGES * NBITS_NOISE_FILL_LEVEL ); /* Q0 */
}
}
@@ -1468,7 +1476,7 @@ void writeTCXparam_fx(
IF( st->hTcxEnc->tcx_lpc_shaped_ari && EQ_16( core, TCX_20_CORE ) )
{
push_next_bits( hBstr, (UWord16 *) &prm[++j], nbits_tcx );
- j = add( j, nbits_tcx );
+ j = add( j, nbits_tcx ); /* Q0 */
}
ELSE
{
diff --git a/lib_enc/enc_tran.c b/lib_enc/enc_tran.c
deleted file mode 100644
index fc894ba6cc3b0f6891e5522d7bdaa893786ada84..0000000000000000000000000000000000000000
--- a/lib_enc/enc_tran.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/enc_tran_fx.c b/lib_enc/enc_tran_fx.c
index c7f7bcd51cb5b449143630268e87af0a81a1ac2e..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 */
@@ -47,20 +47,20 @@
Word16 encod_tran_fx(
Encoder_State *st_fx, /* i/o: state structure */
- const Word16 speech_fx[], /* i : input speech */
- const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes */
- const Word16 Aq_fx[], /* i : 12k8 Lp coefficient */
- const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */
- const Word16 *res_fx, /* i : residual signal */
- Word16 *syn_fx, /* i/o: core synthesis */
- Word16 *exc_fx, /* i/o: current non-enhanced excitation */
- Word16 *exc2_fx, /* i/o: current enhanced excitation */
- Word16 *pitch_buf_fx, /* i/o: floating pitch values for each subframe */
- Word16 *voice_factors, /* o : voicing factors */
- Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE */
- Word16 tc_subfr, /* i/o: TC subframe classification */
- Word16 position, /* i : maximum of residual signal index */
- Word16 *unbits, /* i/o: number of unused bits */
+ const Word16 speech_fx[], /* i : input speech Q0*/
+ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/
+ const Word16 Aq_fx[], /* i : 12k8 Lp coefficient Q12*/
+ const Word16 Es_pred_fx, /* i : predicted scaled innov. energy Q8*/
+ const Word16 *res_fx, /* i : residual signal Q_new*/
+ Word16 *syn_fx, /* i/o: core synthesis Q_new*/
+ Word16 *exc_fx, /* i/o: current non-enhanced excitation Q0*/
+ Word16 *exc2_fx, /* i/o: current enhanced excitation Q0*/
+ Word16 *pitch_buf_fx, /* i/o: floating pitch values for each subframe Q6*/
+ Word16 *voice_factors, /* o : voicing factors Q15*/
+ Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE Q0*/
+ Word16 tc_subfr, /* i/o: TC subframe classification Q0*/
+ Word16 position, /* i : maximum of residual signal index Q0*/
+ Word16 *unbits, /* i/o: number of unused bits Q0*/
const Word16 shift, /* i : Scaling to get 12 bits */
const Word16 Q_new /* i : Input scaling */
)
@@ -96,6 +96,7 @@ Word16 encod_tran_fx(
Word32 L_tmp;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
BSTR_ENC_HANDLE hBstr = st_fx->hBstr;
SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR;
@@ -131,14 +132,14 @@ Word16 encod_tran_fx(
/**unbits = 0;move16();*/
Jopt_flag = 0;
move16();
- unbits_ACELP = *unbits;
+ unbits_ACELP = *unbits; /* Q0 */
move16();
*unbits = 0;
move16();
- p_Aw = Aw_fx;
- p_Aq = Aq_fx;
- pt_pitch = pitch_buf_fx;
+ p_Aw = Aw_fx; /* Q12 */
+ p_Aq = Aq_fx; /* Q12 */
+ pt_pitch = pitch_buf_fx; /* Q6 */
gain_preQ = 0;
move16();
set16_fx( code_preQ, 0, L_SUBFR );
@@ -156,7 +157,7 @@ Word16 encod_tran_fx(
* Compute impulse response, h1[], of weighted synthesis filter
*----------------------------------------------------------------*/
- Copy( &res_fx[i_subfr], &exc_fx[i_subfr], L_SUBFR );
+ Copy( &res_fx[i_subfr], &exc_fx[i_subfr], L_SUBFR ); /* Q_new */
find_targets_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq,
res_fx, L_SUBFR, p_Aw, st_fx->preemph_fac, xn, cn, h1 );
@@ -228,31 +229,21 @@ 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 );
+ hLPDmem->tilt_code = Est_tilt2( &exc_fx[i_subfr], gain_pit, code, Lgcode, &voice_fac, shift ); /* Q15 */
/*-----------------------------------------------------------------*
* Update memory of the weighting filter
*-----------------------------------------------------------------*/
/*st->mem_w0 = xn[L_SUBFR-1] - (gain_pit*y1[L_SUBFR-1]) - (gain_code*y2[L_SUBFR-1]);*/
- L_tmp = L_mult( gcode16, y2[L_SUBFR - 1] );
- L_tmp = L_shl( L_tmp, add( 5, shift ) );
+ L_tmp = L_mult( gcode16, y2[L_SUBFR - 1] ); /* Q10 + Q_new */
+ L_tmp = L_shl( L_tmp, add( 5, shift ) ); /* Q15 + Q_new + shift */
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 ) );
- 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
@@ -268,19 +259,15 @@ 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 ) );
-#else
- exc2_fx[i + i_subfr] = round_fx( L_shl( L_mult( gain_pit, exc_fx[i + i_subfr] ), 1 ) );
-#endif
+ 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
{
- Gain_pitX2 = shl( gain_pit, 1 );
+ Gain_pitX2 = shl( gain_pit, 1 ); /* Q15 */
FOR( i = 0; i < L_SUBFR; i++ )
{
- exc2_fx[i + i_subfr] = mult_r( Gain_pitX2, exc_fx[i + i_subfr] );
+ exc2_fx[i + i_subfr] = mult_r( Gain_pitX2, exc_fx[i + i_subfr] ); /* Q_new */
}
}
@@ -291,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] );
-#ifdef BASOP_NOGLOB
- L_tmp = L_shl_o( L_tmp, 5, &Overflow );
- L_tmp = L_mac_o( L_tmp, exc_fx[i + i_subfr], gain_pit, &Overflow );
- L_tmp = L_shl_o( L_tmp, 1, &Overflow ); /* saturation can occur here */
- exc_fx[i + i_subfr] = round_fx_o( L_tmp, &Overflow );
-#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
+ 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 */
}
/*-----------------------------------------------------------------*
@@ -314,24 +294,14 @@ 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 );
- exc2_fx[i + i_subfr] = add_o( exc2_fx[i + i_subfr], tmp_fx, &Overflow );
- move16();
- exc_fx[i + i_subfr] = add_o( exc_fx[i + i_subfr], tmp_fx, &Overflow );
- 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 );
+ exc2_fx[i + i_subfr] = add_o( exc2_fx[i + i_subfr], tmp_fx, &Overflow ); /* Q_exc */
move16();
- exc_fx[i + i_subfr] = add( exc_fx[i + i_subfr], tmp_fx );
+ exc_fx[i + i_subfr] = add_o( exc_fx[i + i_subfr], tmp_fx, &Overflow ); /* Q_exc */
move16();
-#endif
}
}
@@ -439,9 +409,9 @@ Word16 encod_tran_fx(
IF( st_fx->Opt_SC_VBR )
{
/* SC-VBR */
- hSC_VBR->prev_ppp_gain_pit_fx = gain_pit;
+ hSC_VBR->prev_ppp_gain_pit_fx = gain_pit; /* Q14 */
move16();
- hSC_VBR->prev_tilt_code_fx = hLPDmem->tilt_code;
+ hSC_VBR->prev_tilt_code_fx = hLPDmem->tilt_code; /* Q15 */
move16();
}
@@ -450,20 +420,20 @@ Word16 encod_tran_fx(
Word16 encod_tran_ivas_fx(
Encoder_State *st_fx, /* i/o: state structure */
- const Word16 speech_fx[], /* i : input speech */
- const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes */
- const Word16 Aq_fx[], /* i : 12k8 Lp coefficient */
- const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */
- const Word16 *res_fx, /* i : residual signal */
- Word16 *syn_fx, /* i/o: core synthesis */
- Word16 *exc_fx, /* i/o: current non-enhanced excitation */
- Word16 *exc2_fx, /* i/o: current enhanced excitation */
- Word16 *pitch_buf_fx, /* i/o: floating pitch values for each subframe */
- Word16 *voice_factors, /* o : voicing factors */
- Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE */
- Word16 tc_subfr, /* i/o: TC subframe classification */
- Word16 position, /* i : maximum of residual signal index */
- Word16 *unbits, /* i/o: number of unused bits */
+ const Word16 speech_fx[], /* i : input speech Q0*/
+ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/
+ const Word16 Aq_fx[], /* i : 12k8 Lp coefficient Q12*/
+ const Word16 Es_pred_fx, /* i : predicted scaled innov. energy Q8*/
+ const Word16 *res_fx, /* i : residual signal Q_new*/
+ Word16 *syn_fx, /* i/o: core synthesis Q_new*/
+ Word16 *exc_fx, /* i/o: current non-enhanced excitation Q0*/
+ Word16 *exc2_fx, /* i/o: current enhanced excitation Q0*/
+ Word16 *pitch_buf_fx, /* i/o: floating pitch values for each subframe Q6*/
+ Word16 *voice_factors, /* o : voicing factors Q15*/
+ Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE Q0*/
+ Word16 tc_subfr, /* i/o: TC subframe classification Q0*/
+ Word16 position, /* i : maximum of residual signal index Q0*/
+ Word16 *unbits, /* i/o: number of unused bits Q0*/
const Word16 shift, /* i : Scaling to get 12 bits */
const Word16 Q_new /* i : Input scaling */
)
@@ -499,6 +469,7 @@ Word16 encod_tran_ivas_fx(
Word32 L_tmp;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
BSTR_ENC_HANDLE hBstr = st_fx->hBstr;
SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR;
@@ -506,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
*------------------------------------------------------------------*/
@@ -534,13 +510,13 @@ Word16 encod_tran_ivas_fx(
/**unbits = 0;move16();*/
Jopt_flag = 0;
move16();
- unbits_ACELP = *unbits;
+ unbits_ACELP = *unbits; /* Q0 */
move16();
*unbits = 0;
move16();
- p_Aw = Aw_fx;
- p_Aq = Aq_fx;
+ p_Aw = Aw_fx; /* Q12 */
+ p_Aq = Aq_fx; /* Q12 */
pt_pitch = pitch_buf_fx;
gain_preQ = 0;
move16();
@@ -559,13 +535,12 @@ Word16 encod_tran_ivas_fx(
* Compute impulse response, h1[], of weighted synthesis filter
*----------------------------------------------------------------*/
- Copy( &res_fx[i_subfr], &exc_fx[i_subfr], L_SUBFR );
+ Copy( &res_fx[i_subfr], &exc_fx[i_subfr], L_SUBFR ); /* Q_new */
find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq,
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 );
@@ -584,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 );
}
@@ -631,14 +607,9 @@ 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_tilt2( &exc_fx[i_subfr], gain_pit, code, Lgcode, &voice_fac, shift );
+ 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
*-----------------------------------------------------------------*/
@@ -649,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
@@ -671,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 ) );
-#else
- exc2_fx[i + i_subfr] = round_fx( L_shl( L_mult( gain_pit, exc_fx[i + i_subfr] ), 1 ) );
-#endif
+ 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
@@ -683,7 +645,7 @@ Word16 encod_tran_ivas_fx(
Gain_pitX2 = shl( gain_pit, 1 );
FOR( i = 0; i < L_SUBFR; i++ )
{
- exc2_fx[i + i_subfr] = mult_r( Gain_pitX2, exc_fx[i + i_subfr] );
+ exc2_fx[i + i_subfr] = mult_r( Gain_pitX2, exc_fx[i + i_subfr] ); /* Q_exc */
}
}
@@ -694,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] );
-#ifdef BASOP_NOGLOB
- L_tmp = L_shl_o( L_tmp, 5, &Overflow );
- L_tmp = L_mac_o( L_tmp, exc_fx[i + i_subfr], gain_pit, &Overflow );
- L_tmp = L_shl_o( L_tmp, 1, &Overflow ); /* saturation can occur here */
- exc_fx[i + i_subfr] = round_fx_o( L_tmp, &Overflow );
-#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
+ 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 */
}
/*-----------------------------------------------------------------*
@@ -717,24 +672,14 @@ 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 );
- exc2_fx[i + i_subfr] = add_o( exc2_fx[i + i_subfr], tmp_fx, &Overflow );
- move16();
- exc_fx[i + i_subfr] = add_o( exc_fx[i + i_subfr], tmp_fx, &Overflow );
- 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 );
+ exc2_fx[i + i_subfr] = add_o( exc2_fx[i + i_subfr], tmp_fx, &Overflow ); /* Q_exc */
move16();
- exc_fx[i + i_subfr] = add( exc_fx[i + i_subfr], tmp_fx );
+ exc_fx[i + i_subfr] = add_o( exc_fx[i + i_subfr], tmp_fx, &Overflow ); /* Q_exc */
move16();
-#endif
}
}
@@ -843,9 +788,9 @@ Word16 encod_tran_ivas_fx(
IF( st_fx->Opt_SC_VBR )
{
/* SC-VBR */
- hSC_VBR->prev_ppp_gain_pit_fx = gain_pit;
+ hSC_VBR->prev_ppp_gain_pit_fx = gain_pit; /* Q14 */
move16();
- hSC_VBR->prev_tilt_code_fx = hLPDmem->tilt_code;
+ hSC_VBR->prev_tilt_code_fx = hLPDmem->tilt_code; /* Q15 */
move16();
}
diff --git a/lib_enc/enc_uv.c b/lib_enc/enc_uv.c
deleted file mode 100644
index ccdf49ed34f76e6fc8e0305d1de54cbdde0ce8fa..0000000000000000000000000000000000000000
--- a/lib_enc/enc_uv.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
-#include "options.h"
-#include
-#include "cnst.h"
-#include "prot.h"
-#include "wmc_auto.h"
diff --git a/lib_enc/enc_uv_fx.c b/lib_enc/enc_uv_fx.c
index ea88f28b5eff44a563723987895777f3666759dd..32c397613d81fc1637b5bba217ba854d731f755f 100644
--- a/lib_enc/enc_uv_fx.c
+++ b/lib_enc/enc_uv_fx.c
@@ -18,18 +18,18 @@
/*fixed point implementation of unvoiced_encoder*/
void encod_unvoiced_fx(
Encoder_State *st_fx, /* i/o: state structure */
- const Word16 *speech_fx, /* i : Input speech */
- const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes */
- const Word16 *Aq_fx, /* i : 12k8 Lp coefficient */
- const Word16 Es_pred, /* i : predicted scaled innov. energy */
- const Word16 uc_two_stage_flag, /* i : flag indicating two-stage UC */
- const Word16 *res_fx, /* i : residual signal */
- Word16 *syn_fx, /* o : core synthesis */
- Word16 *tmp_noise_fx, /* o : long-term noise energy */
- Word16 *exc_fx, /* i/o: current non-enhanced excitation */
- Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */
- Word16 *voice_factors_fx, /* o : voicing factors */
- Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE */
+ const Word16 *speech_fx, /* i : Input speech Q_new*/
+ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/
+ const Word16 *Aq_fx, /* i : 12k8 Lp coefficient Q12*/
+ const Word16 Es_pred, /* i : predicted scaled innov. energy Q8*/
+ const Word16 uc_two_stage_flag, /* i : flag indicating two-stage UC Q0*/
+ const Word16 *res_fx, /* i : residual signal Q_new*/
+ Word16 *syn_fx, /* o : core synthesis Q_new*/
+ Word16 *tmp_noise_fx, /* o : long-term noise energy Q0*/
+ Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/
+ Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6*/
+ Word16 *voice_factors_fx, /* o : voicing factors Q15*/
+ Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE Q_exc*/
const Word16 Q_new,
const Word16 shift )
{
@@ -91,7 +91,7 @@ void encod_unvoiced_fx(
* Compute impulse response, h1[], of weighted synthesis filter
*----------------------------------------------------------------*/
i_subfr_idx = shr( i_subfr, 6 );
- Copy( &res_fx[i_subfr], &exc_fx[i_subfr], L_SUBFR );
+ Copy( &res_fx[i_subfr], &exc_fx[i_subfr], L_SUBFR ); /* Q_new */
find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq_fx,
res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx );
@@ -108,7 +108,7 @@ void encod_unvoiced_fx(
{
*pt_pitch_fx = gaus_encode_fx( st_fx, i_subfr, h1_fx, xn_fx, exc_fx, &hLPDmem->mem_w0, st_fx->clip_var_fx,
&hLPDmem->tilt_code, code_fx, &L_gain_code_fx, y2_fx, &gain_inov_fx,
- &voice_fac_fx, &gain_pit_fx, Q_new, shift, &norm_gain_code_fx );
+ &voice_fac_fx, &gain_pit_fx, Q_new, shift, &norm_gain_code_fx ); /* Q0 */
}
ELSE
{
@@ -123,7 +123,7 @@ void encod_unvoiced_fx(
* Gain clipping test to avoid unstable synthesis on frame erasure
* or in case of floating point encoder & fixed p. decoder
*-----------------------------------------------------------------*/
- Mode2_gp_clip( st_fx->voicing_fx, i_subfr, st_fx->coder_type, xn_fx, st_fx->clip_var_fx, L_SUBFR, Q_xn );
+ Mode2_gp_clip_fx( st_fx->voicing_fx, i_subfr, st_fx->coder_type, xn_fx, st_fx->clip_var_fx, L_SUBFR, Q_xn );
*pt_pitch_fx = L_SUBFR;
move16();
/*----------------------------------------------------------------------*
@@ -148,7 +148,7 @@ void encod_unvoiced_fx(
*----------------------------------------------------------*/
index = gain_enc_uv_fx( code_fx, code2, L_SUBFR, &gain_pit_fx, &L_gain_code_fx, &gain_code2,
- st_fx->flag_noisy_speech_snr, &g_corr, Es_pred, &norm_gain_code_fx, &gain_inov_fx, FUNC_GAIN_ENC_GACELP_UV );
+ st_fx->flag_noisy_speech_snr, &g_corr, Es_pred, &norm_gain_code_fx, &gain_inov_fx, FUNC_GAIN_ENC_GACELP_UV ); /* Q0 */
#ifdef DEBUGGING
assert( st_fx->acelp_cfg.gains_mode[i_subfr_idx] == 7 && "Error: UC two-stage, only 5+2 gain Q is supported" );
@@ -175,21 +175,17 @@ void encod_unvoiced_fx(
* Update memory of the weighting filter
*-----------------------------------------------------------------*/
/* st_fx->mem_w0 = xn[L_SUBFR-1] - (gain_pit*y1[L_SUBFR-1]) - (gain_code*y2[L_SUBFR-1]); */
- Ltmp = Mpy_32_16_1( L_gain_code_fx, y2_fx[L_SUBFR - 1] );
- Ltmp = L_shl( Ltmp, add( 5, Q_xn ) );
- Ltmp = L_mac( Ltmp, y1[L_SUBFR - 1], gain_pit_fx );
+ Ltmp = Mpy_32_16_1( L_gain_code_fx, y2_fx[L_SUBFR - 1] ); /* Q10 */
+ Ltmp = L_shl( Ltmp, add( 5, Q_xn ) ); /* Q15 + Q_xn */
+ Ltmp = L_mac( Ltmp, y1[L_SUBFR - 1], gain_pit_fx ); /* Q15 + Q_xn */
/* Add Gaussian contribution*/
- Ltmp2 = Mpy_32_16_1( gain_code2, y22[L_SUBFR - 1] );
- Ltmp2 = L_shl( Ltmp2, add( 5, Q_xn ) );
- Ltmp = L_add( Ltmp, Ltmp2 );
- hLPDmem->mem_w0 = sub( xn_fx[L_SUBFR - 1], round_fx( L_shl( Ltmp, 1 ) ) );
+ Ltmp2 = Mpy_32_16_1( gain_code2, y22[L_SUBFR - 1] ); /* Q10 */
+ Ltmp2 = L_shl( Ltmp2, add( 5, Q_xn ) ); /* Q15 + Q_xn */
+ Ltmp = L_add( Ltmp, Ltmp2 ); /* Q15 + Q_xn */
+ 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;
/*-------------------------------------------------------*
@@ -202,28 +198,21 @@ void encod_unvoiced_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] );
- Ltmp = L_shl( Ltmp, Q_new_p5 );
- Ltmp = L_mac( Ltmp, gain_pit_fx, exc_fx[i + i_subfr] );
- Ltmp2 = Mpy_32_16_1( gain_code_vect[j], code_fx[i] );
- Ltmp2 = L_shl( Ltmp2, Q_new_p5 );
- Ltmp = L_add( Ltmp, Ltmp2 );
-#ifdef BASOP_NOGLOB
- Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here */
- exc_fx[i + i_subfr] = round_fx_sat( Ltmp );
-#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 = Mpy_32_16_1( gain_code2, code2[i] ); /* Q10 */
+ Ltmp = L_shl( Ltmp, Q_new_p5 ); /* Q15 + Q_new */
+ Ltmp = L_mac( Ltmp, gain_pit_fx, exc_fx[i + i_subfr] ); /* Q_new + Q15 */
+ 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 */
+ 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();
}
}
- *tmp_noise_fx = extract_h( norm_gain_code_fx );
+ *tmp_noise_fx = extract_h( norm_gain_code_fx ); /* Q0 */
voice_factors_fx[i_subfr / L_SUBFR] = 0;
move16();
@@ -241,9 +230,9 @@ void encod_unvoiced_fx(
}
/* SC-VBR */
- hSC_VBR->prev_ppp_gain_pit_fx = gain_pit_fx;
+ hSC_VBR->prev_ppp_gain_pit_fx = gain_pit_fx; /* Q14 */
move16();
- hSC_VBR->prev_tilt_code_fx = hLPDmem->tilt_code;
+ hSC_VBR->prev_tilt_code_fx = hLPDmem->tilt_code; /* Q15 */
move16();
return;
@@ -251,18 +240,18 @@ void encod_unvoiced_fx(
void encod_unvoiced_ivas_fx(
Encoder_State *st_fx, /* i/o: state structure */
- const Word16 *speech_fx, /* i : Input speech */
- const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes */
- const Word16 *Aq_fx, /* i : 12k8 Lp coefficient */
- const Word16 Es_pred, /* i : predicted scaled innov. energy */
- const Word16 uc_two_stage_flag, /* i : flag indicating two-stage UC */
- const Word16 *res_fx, /* i : residual signal */
- Word16 *syn_fx, /* o : core synthesis */
- Word16 *tmp_noise_fx, /* o : long-term noise energy */
- Word16 *exc_fx, /* i/o: current non-enhanced excitation */
- Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */
- Word16 *voice_factors_fx, /* o : voicing factors */
- Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE */
+ const Word16 *speech_fx, /* i : Input speech Q_new*/
+ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/
+ const Word16 *Aq_fx, /* i : 12k8 Lp coefficient Q12*/
+ const Word16 Es_pred, /* i : predicted scaled innov. energy Q8*/
+ const Word16 uc_two_stage_flag, /* i : flag indicating two-stage UC Q0*/
+ const Word16 *res_fx, /* i : residual signal Q_new*/
+ Word16 *syn_fx, /* o : core synthesis Q_new*/
+ Word16 *tmp_noise_fx, /* o : long-term noise energy Q0*/
+ Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/
+ Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6*/
+ Word16 *voice_factors_fx, /* o : voicing factors Q15*/
+ Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE Q_exc*/
const Word16 Q_new,
const Word16 shift )
{
@@ -325,7 +314,7 @@ void encod_unvoiced_ivas_fx(
* Compute impulse response, h1[], of weighted synthesis filter
*----------------------------------------------------------------*/
i_subfr_idx = shr( i_subfr, 6 );
- Copy( &res_fx[i_subfr], &exc_fx[i_subfr], L_SUBFR );
+ Copy( &res_fx[i_subfr], &exc_fx[i_subfr], L_SUBFR ); /* Q_new */
find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq_fx,
res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx );
@@ -342,7 +331,7 @@ void encod_unvoiced_ivas_fx(
{
*pt_pitch_fx = gaus_encode_ivas_fx( st_fx, i_subfr, h1_fx, xn_fx, exc_fx, &hLPDmem->mem_w0, st_fx->clip_var_fx,
&hLPDmem->tilt_code, code_fx, &L_gain_code_fx, y2_fx, &gain_inov_fx,
- &voice_fac_fx, &gain_pit_fx, Q_new, shift, &norm_gain_code_fx );
+ &voice_fac_fx, &gain_pit_fx, Q_new, shift, &norm_gain_code_fx ); /* Q0 */
move16();
}
ELSE
@@ -358,7 +347,7 @@ void encod_unvoiced_ivas_fx(
* Gain clipping test to avoid unstable synthesis on frame erasure
* or in case of floating point encoder & fixed p. decoder
*-----------------------------------------------------------------*/
- Mode2_gp_clip( st_fx->voicing_fx, i_subfr, st_fx->coder_type, xn_fx, st_fx->clip_var_fx, L_SUBFR, Q_xn );
+ Mode2_gp_clip_fx( st_fx->voicing_fx, i_subfr, st_fx->coder_type, xn_fx, st_fx->clip_var_fx, L_SUBFR, Q_xn );
*pt_pitch_fx = L_SUBFR << 6;
move16();
/*----------------------------------------------------------------------*
@@ -390,7 +379,7 @@ void encod_unvoiced_ivas_fx(
*----------------------------------------------------------*/
index = gain_enc_uv_fx( code_fx, code2, L_SUBFR, &gain_pit_fx, &L_gain_code_fx, &gain_code2,
- st_fx->flag_noisy_speech_snr, &g_corr, Es_pred, &norm_gain_code_fx, &gain_inov_fx, FUNC_GAIN_ENC_GACELP_UV );
+ st_fx->flag_noisy_speech_snr, &g_corr, Es_pred, &norm_gain_code_fx, &gain_inov_fx, FUNC_GAIN_ENC_GACELP_UV ); /* Q0 */
#ifdef DEBUGGING
assert( st_fx->acelp_cfg.gains_mode[i_subfr_idx] == 7 && "Error: UC two-stage, only 5+2 gain Q is supported" );
@@ -418,21 +407,17 @@ void encod_unvoiced_ivas_fx(
* Update memory of the weighting filter
*-----------------------------------------------------------------*/
/* st_fx->mem_w0 = xn[L_SUBFR-1] - (gain_pit*y1[L_SUBFR-1]) - (gain_code*y2[L_SUBFR-1]); */
- Ltmp = Mpy_32_16_1( L_gain_code_fx, y2_fx[L_SUBFR - 1] );
- Ltmp = L_shl( Ltmp, add( 5, Q_xn ) ); // Qxn+15
- Ltmp = L_mac( Ltmp, y1[L_SUBFR - 1], gain_pit_fx );
+ Ltmp = Mpy_32_16_1( L_gain_code_fx, y2_fx[L_SUBFR - 1] ); /* Q10 */
+ Ltmp = L_shl( Ltmp, add( 5, Q_xn ) ); // Qxn+15
+ Ltmp = L_mac( Ltmp, y1[L_SUBFR - 1], gain_pit_fx ); /* Qxn + Q15 */
/* Add Gaussian contribution*/
- Ltmp2 = Mpy_32_16_1( gain_code2, y22[L_SUBFR - 1] );
- Ltmp2 = L_shl( Ltmp2, add( 5, Q_xn ) ); // Q_xn+15
- Ltmp = L_add( Ltmp, Ltmp2 );
+ Ltmp2 = Mpy_32_16_1( gain_code2, y22[L_SUBFR - 1] ); /* Q10 */
+ Ltmp2 = L_shl( Ltmp2, add( 5, Q_xn ) ); // Q_xn+15
+ Ltmp = L_add( Ltmp, Ltmp2 ); /* Qxn + Q15 */
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] );
-#ifdef BASOP_NOGLOB
- Ltmp = L_shl_sat( Ltmp, Q_new_p5 );
- Ltmp = L_mac_sat( Ltmp, gain_pit_fx, exc_fx[i + i_subfr] );
-#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] );
-#ifdef BASOP_NOGLOB
- Ltmp2 = L_shl_sat( Ltmp2, Q_new_p5 );
- Ltmp = L_add_sat( Ltmp, Ltmp2 );
- Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here */
- exc_fx[i + i_subfr] = round_fx_sat( Ltmp );
-#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
+ 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 */
+ 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;
@@ -480,7 +451,14 @@ void encod_unvoiced_ivas_fx(
voice_factors_fx[i_subfr / L_SUBFR] = 0;
move16();
+#ifdef FIX_ISSUE_1148
+ if ( st_fx->hBWE_TD != NULL )
+ {
+ interp_code_5over2_fx( &exc_fx[i_subfr], &bwe_exc_fx[i_subfr * HIBND_ACB_L_FAC], L_SUBFR );
+ }
+#else
interp_code_5over2_fx( &exc_fx[i_subfr], &bwe_exc_fx[i_subfr * HIBND_ACB_L_FAC], L_SUBFR );
+#endif
/*-----------------------------------------------------------------*
* Synthesize speech to update mem_syn[].
@@ -496,9 +474,9 @@ void encod_unvoiced_ivas_fx(
/* SC-VBR */
IF( hSC_VBR )
{
- hSC_VBR->prev_ppp_gain_pit_fx = gain_pit_fx;
+ hSC_VBR->prev_ppp_gain_pit_fx = gain_pit_fx; /* Q14 */
move16();
- hSC_VBR->prev_tilt_code_fx = hLPDmem->tilt_code;
+ hSC_VBR->prev_tilt_code_fx = hLPDmem->tilt_code; /* Q15 */
move16();
}
diff --git a/lib_enc/energy.c b/lib_enc/energy.c
deleted file mode 100644
index 59a3eb11a82f687754109ba17252b6dfe625aca8..0000000000000000000000000000000000000000
--- a/lib_enc/energy.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 "cnst.h"
-#include "rom_enc.h"
-#include "wmc_auto.h"
diff --git a/lib_enc/energy_fx.c b/lib_enc/energy_fx.c
index 054245a6d288b432c1c5b5107d52f713ce9ed4d6..6d81eb82a7b8bd9dfe8261486ebf6330f1bdefbb 100644
--- a/lib_enc/energy_fx.c
+++ b/lib_enc/energy_fx.c
@@ -17,18 +17,18 @@
*
*-------------------------------------------------------------------*/
void est_energy_fx(
- Word32 enerBuffer[CLDFB_NO_CHANNELS_MAX], /* i : energy vector per band */
- Word16 enerBuffer_exp, /* i : exponent of energy vector */
- Word32 *frame_sb_energy, /* o : energy of sub-band divided non-uniformly*/
- Word32 *frame_energy2_p, /* o : frame energy 2*/
- Word32 *HB_Power_p, /* o : high frequency energy*/
- Word32 *frame_energy_p, /* o : frame energy 1*/
- Word16 *sb_power_Q, /* o : the scaling of sb_power*/
- Word16 *frame_energy2_Q, /* o : the scaling of frame_energy*/
- Word16 *HB_Power_Q, /* o : the scaling of HB_Power*/
- Word16 *frame_energy_Q, /* o : the Scaling of frame_energy*/
- Word16 *frame_sb_energy_scale, /* o : the Scaling of frame_sb_energy[]*/
- const Word32 bandwidth /* i : band width*/
+ Word32 enerBuffer[CLDFB_NO_CHANNELS_MAX], /* i : energy vector per band enerBuffer_exp*/
+ Word16 enerBuffer_exp, /* i : exponent of energy vector */
+ Word32 *frame_sb_energy, /* o : energy of sub-band divided non-uniformly frame_sb_energy_scale*/
+ Word32 *frame_energy2_p, /* o : frame energy 2 frame_energy2_Q*/
+ Word32 *HB_Power_p, /* o : high frequency energy HB_Power_Q*/
+ Word32 *frame_energy_p, /* o : frame energy 1 frame_energy_Q*/
+ Word16 *sb_power_Q, /* o : the scaling of sb_power */
+ Word16 *frame_energy2_Q, /* o : the scaling of frame_energy */
+ Word16 *HB_Power_Q, /* o : the scaling of HB_Power */
+ Word16 *frame_energy_Q, /* o : the Scaling of frame_energy */
+ Word16 *frame_sb_energy_scale, /* o : the Scaling of frame_sb_energy[] */
+ const Word32 bandwidth /* i : band width Q0*/
)
{
Word32 i, j;
@@ -56,44 +56,38 @@ void est_energy_fx(
BandNum = BAND_NUM_TAB[bandwidth];
move16();
- frame_energy2 = L_shr( sb_power[1], shr_tmp );
- HB_Power = L_shr( sb_power[6], shr_tmp );
+ frame_energy2 = L_shr( sb_power[1], shr_tmp ); /* 31 - enerBuffer_exp - shr_tmp */
+ 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 );
-#ifdef BASOP_NOGLOB
- frame_energy2 = L_add_sat( frame_energy2, Ltmp32 );
+ 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 );
+ frame_energy2 = L_sub( frame_energy2, Ltmp32 ); /* 31 - enerBuffer_exp - shr_tmp */
- sb_power_tmp = L_shr( sb_power[0], shr_tmp );
+ sb_power_tmp = L_shr( sb_power[0], shr_tmp ); /* 31 - enerBuffer_exp - shr_tmp */
IF( EQ_32( bandwidth, 1 ) )
{
- frame_energy = L_add( frame_energy2, MUL_F( sb_power_tmp, 0x147a ) );
+ frame_energy = L_add( frame_energy2, MUL_F( sb_power_tmp, 0x147a /* 0.16 in Q15 */ ) );
}
ELSE IF( EQ_32( bandwidth, 2 ) )
{
- frame_energy = L_add( frame_energy2, MUL_F( sb_power_tmp, 0x1eb8 ) );
+ frame_energy = L_add( frame_energy2, MUL_F( sb_power_tmp, 0x1eb8 /* 0.24 in Q15 */ ) );
}
ELSE IF( EQ_32( bandwidth, 3 ) )
{
- frame_energy = L_add( frame_energy2, MUL_F( sb_power_tmp, 0x23d7 ) );
+ frame_energy = L_add( frame_energy2, MUL_F( sb_power_tmp, 0x23d7 /* 0.28 in Q15 */ ) );
}
ELSE IF( EQ_32( bandwidth, 4 ) )
{
- frame_energy = L_add( frame_energy2, MUL_F( sb_power_tmp, 0x23d7 ) );
+ frame_energy = L_add( frame_energy2, MUL_F( sb_power_tmp, 0x23d7 /* 0.28 in Q15 */ ) );
}
ELSE
{
- frame_energy = L_add( frame_energy2, MUL_F( sb_power_tmp, 0x23d7 ) );
+ frame_energy = L_add( frame_energy2, MUL_F( sb_power_tmp, 0x23d7 /* 0.28 in Q15 */ ) );
}
*frame_energy2_p = frame_energy2;
@@ -115,7 +109,7 @@ void est_energy_fx(
FOR( i = 0; i < 6; i++ )
{
- frame_sb_energy[i] = sb_power[i];
+ frame_sb_energy[i] = sb_power[i]; /* sb_power_Q */
move32();
}
@@ -123,19 +117,15 @@ void est_energy_fx(
{
s32CopyPower = 0;
move32();
- widthsb = sub( Nregion_index[i + 1], Nregion_index[i] );
+ widthsb = sub( Nregion_index[i + 1], Nregion_index[i] ); /* Q0 */
s16MaxCoefNorm = sub( ffr_getSfWord32( ( sb_power + Nregion_index[i] ), widthsb ), NREGION_PREOFF[i] );
FOR( j = Nregion_index[i]; j < Nregion_index[i + 1]; j++ )
{
- tmpspec_amp = L_shl( sb_power[j], s16MaxCoefNorm );
+ 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 );
-#else /* BASOP_NOGLOB */
- frame_sb_energy[i] = L_shr( s32CopyPower, s16MaxCoefNorm );
-#endif
+ frame_sb_energy[i] = L_shr_o( s32CopyPower, s16MaxCoefNorm, &Overflow ); /* sb_power_Q */
move32();
}
@@ -180,28 +170,29 @@ static void NormEnergyWord32(
*
*-------------------------------------------------------------------*/
static void update_sb_bg_energy(
- Word32 *sb_bg_energy,
- Word16 *tbg_energy_count,
+ Word32 *sb_bg_energy, /* p_scale_sb_energy */
+ Word16 *tbg_energy_count, /* Q0 */
Word16 *p_scale_sb_energy,
- const Word32 SNR_sb_num,
- const Word32 *frame_sb_energy,
+ const Word32 SNR_sb_num, /* Q0 */
+ const Word32 *frame_sb_energy, /* frame_sb_energy_scale */
const Word16 frame_sb_energy_scale,
- const Word16 FAC_16Q15_a,
+ const Word16 FAC_16Q15_a, /* Q15 */
const Word16 tmp_Q_add,
- const Word16 FAC_16Q19_b )
+ const Word16 FAC_16Q19_b /* Q19 */
+)
{
Word32 sb_bg_energy_ti, tmp;
Word16 tmpQ, i;
- *tbg_energy_count = add( *tbg_energy_count, 1 );
+ *tbg_energy_count = add( *tbg_energy_count, 1 ); /* Q0 */
move16();
tmpQ = add( tmp_Q_add, frame_sb_energy_scale );
FOR( i = 0; i < SNR_sb_num; i++ )
{
- sb_bg_energy_ti = MUL_F( sb_bg_energy[i], FAC_16Q15_a );
+ sb_bg_energy_ti = MUL_F( sb_bg_energy[i], FAC_16Q15_a ); /* p_scale_sb_energy */
tmp = MUL_F( frame_sb_energy[i], FAC_16Q19_b );
- sb_bg_energy[i] = VAD_L_ADD( sb_bg_energy_ti, p_scale_sb_energy[i], tmp, tmpQ, &p_scale_sb_energy[i] );
+ sb_bg_energy[i] = VAD_L_ADD( sb_bg_energy_ti, p_scale_sb_energy[i], tmp, tmpQ, &p_scale_sb_energy[i] ); /* p_scale_sb_energy */
move32();
}
}
@@ -212,12 +203,13 @@ static void update_sb_bg_energy(
*
*-------------------------------------------------------------------*/
void background_update_fx(
- VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */
- Word16 scale, /* i : the scaling of frame energy*/
- Word32 frame_energy, /* i : current frame energy*/
- Word32 update_flag, /* i : update flag*/
- Word16 music_backgound_f, /* i : background music flag*/
- Word32 snr )
+ VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */
+ Word16 scale, /* i : the scaling of frame energy */
+ Word32 frame_energy, /* i : current frame energy scale*/
+ Word32 update_flag, /* i : update flag Q0*/
+ Word16 music_backgound_f, /* i : background music flag Q0*/
+ Word32 snr /* Q25 */
+)
{
Word32 tmp;
Word16 i, tmpQ, cmp_lt_frame, cmp_pre_frame;
@@ -279,12 +271,13 @@ void background_update_fx(
test();
test();
test();
- IF( ( LT_16( hVAD_CLDFB->frameloop, 60 ) ) && ( GT_16( hVAD_CLDFB->frameloop, 5 ) ) && ( LT_16( f_tonality_rate[0], 9174 /* 0.56 Q14 */ ) ) && ( LT_16( f_tonality_rate[1], 8192 /* 0.5 Q14 */ ) ) && ( LT_16( ltd_stable_rate[1], 1966 /* 0.06 Q15 */ ) ) && LT_32( snr, 83886080 ) )
+ IF( ( LT_16( hVAD_CLDFB->frameloop, 60 ) ) && ( GT_16( hVAD_CLDFB->frameloop, 5 ) ) && ( LT_16( f_tonality_rate[0], 9174 /* 0.56 Q14 */ ) ) && ( LT_16( f_tonality_rate[1], 8192 /* 0.5 Q14 */ ) ) && ( LT_16( ltd_stable_rate[1], 1966 /* 0.06 Q15 */ ) ) && LT_32( snr, 83886080 /* 2.5f in Q25 */ ) )
{
IF( LT_16( hVAD_CLDFB->frameloop, 50 ) )
{
- exp_frame_energy_amendment.s32Mantissa = VAD_L_div( exp_frame_energy.s32Mantissa, 10, exp_frame_energy.s16Exp, 0, &q_divout );
+ exp_frame_energy_amendment.s32Mantissa = VAD_L_div( exp_frame_energy.s32Mantissa, 10, exp_frame_energy.s16Exp, 0, &q_divout ); /* exp(divout) */
exp_frame_energy_amendment.s16Exp = q_divout;
+ move16();
t_bg_energy_sum = VAD_AddExp( t_bg_energy_sum, exp_frame_energy_amendment );
}
ELSE
@@ -303,8 +296,9 @@ void background_update_fx(
{
IF( LT_16( hVAD_CLDFB->frameloop, 50 ) )
{
- exp_frame_energy_amendment.s32Mantissa = VAD_L_div( exp_frame_energy.s32Mantissa, 10, exp_frame_energy.s16Exp, 0, &q_divout );
+ exp_frame_energy_amendment.s32Mantissa = VAD_L_div( exp_frame_energy.s32Mantissa, 10, exp_frame_energy.s16Exp, 0, &q_divout ); /* exp(q_divout) */
exp_frame_energy_amendment.s16Exp = q_divout;
+ move16();
t_bg_energy_sum = VAD_AddExp( t_bg_energy_sum, exp_frame_energy_amendment );
}
ELSE
@@ -314,7 +308,8 @@ void background_update_fx(
update_sb_bg_energy( sb_bg_energy, &hVAD_CLDFB->tbg_energy_count, p_scale_sb_energy, SNR_sb_num, frame_sb_energy, hVAD_CLDFB->frame_sb_energy_scale,
31456 /* 0.96 Q15 */, 4, 20971 /* 0.04 Q19 */ );
- hVAD_CLDFB->bg_update_count = add( hVAD_CLDFB->bg_update_count, 1 );
+ hVAD_CLDFB->bg_update_count = add( hVAD_CLDFB->bg_update_count, 1 ); /* Q0 */
+ move16();
}
ELSE
{
@@ -329,9 +324,9 @@ void background_update_fx(
tmpQ = add( 9, hVAD_CLDFB->frame_sb_energy_scale );
FOR( i = 0; i < SNR_sb_num; i++ )
{
- sb_bg_energy_ti = MUL_F( sb_bg_energy[i], 32734 /* 0.999 Q15 */ );
+ sb_bg_energy_ti = MUL_F( sb_bg_energy[i], 32734 /* 0.999 Q15 */ ); /* p_scale_sb_energy */
tmp = MUL_F( frame_sb_energy[i], 16777 /* 0.001 Q24 */ );
- sb_bg_energy[i] = VAD_L_ADD( sb_bg_energy_ti, p_scale_sb_energy[i], tmp, tmpQ, &p_scale_sb_energy[i] );
+ sb_bg_energy[i] = VAD_L_ADD( sb_bg_energy_ti, p_scale_sb_energy[i], tmp, tmpQ, &p_scale_sb_energy[i] ); /* p_scale_sb_energy */
move32();
}
}
@@ -340,8 +335,9 @@ void background_update_fx(
{
IF( LT_16( hVAD_CLDFB->frameloop, 50 ) )
{
- exp_frame_energy_amendment.s32Mantissa = VAD_L_div( exp_frame_energy.s32Mantissa, 10, exp_frame_energy.s16Exp, 0, &q_divout );
+ exp_frame_energy_amendment.s32Mantissa = VAD_L_div( exp_frame_energy.s32Mantissa, 10, exp_frame_energy.s16Exp, 0, &q_divout ); /* exp(q_divout) */
exp_frame_energy_amendment.s16Exp = q_divout;
+ move16();
t_bg_energy_sum = VAD_AddExp( t_bg_energy_sum, exp_frame_energy_amendment );
}
ELSE
@@ -358,8 +354,9 @@ void background_update_fx(
{
IF( LT_16( hVAD_CLDFB->frameloop, 50 ) )
{
- exp_frame_energy_amendment.s32Mantissa = VAD_L_div( exp_frame_energy.s32Mantissa, 10, exp_frame_energy.s16Exp, 0, &q_divout );
+ exp_frame_energy_amendment.s32Mantissa = VAD_L_div( exp_frame_energy.s32Mantissa, 10, exp_frame_energy.s16Exp, 0, &q_divout ); /* exp(q_divout) */
exp_frame_energy_amendment.s16Exp = q_divout;
+ move16();
t_bg_energy_sum = VAD_AddExp( t_bg_energy_sum, exp_frame_energy_amendment );
}
ELSE
@@ -373,7 +370,7 @@ void background_update_fx(
{
IF( LT_16( hVAD_CLDFB->frameloop, 50 ) )
{
- exp_frame_energy_amendment.s32Mantissa = VAD_L_div( exp_frame_energy.s32Mantissa, 10, exp_frame_energy.s16Exp, 0, &q_divout );
+ exp_frame_energy_amendment.s32Mantissa = VAD_L_div( exp_frame_energy.s32Mantissa, 10, exp_frame_energy.s16Exp, 0, &q_divout ); /* exp(q_divout) */
exp_frame_energy_amendment.s16Exp = q_divout;
t_bg_energy_sum = VAD_AddExp( t_bg_energy_sum, exp_frame_energy_amendment );
}
@@ -390,7 +387,7 @@ void background_update_fx(
ELSE
{
cmp_pre_frame = VAD_L_CMP( t_bg_energy, hVAD_CLDFB->scale_t_bg_energy, MUL_F( exp_frame_energy.s32Mantissa, 32000 ), sub( exp_frame_energy.s16Exp, 9 ) );
- cmp_lt_frame = VAD_L_CMP( sb_bg_energy[0], scale_sb_energy, MUL_F( frame_sb_energy[0], 20480 ), sub( hVAD_CLDFB->frame_sb_energy_scale, 4 ) );
+ cmp_lt_frame = VAD_L_CMP( sb_bg_energy[0], scale_sb_energy, MUL_F( frame_sb_energy[0], 20480 /* 10 in Q11 */ ), sub( hVAD_CLDFB->frame_sb_energy_scale, 4 ) );
test();
IF( ( cmp_pre_frame > 0 ) && ( cmp_lt_frame > 0 ) )
@@ -398,9 +395,9 @@ void background_update_fx(
tmpQ = add( 3, hVAD_CLDFB->frame_sb_energy_scale );
FOR( i = 0; i < SNR_sb_num; i++ )
{
- sb_bg_energy_ti = MUL_F( sb_bg_energy[i], 29490 /* 0.90 Q15 */ );
+ sb_bg_energy_ti = MUL_F( sb_bg_energy[i], 29490 /* 0.90 Q15 */ ); /* p_scale_sb_energy */
tmp = MUL_F( frame_sb_energy[i], 26214 /* 0.10 Q18 */ );
- sb_bg_energy[i] = VAD_L_ADD( sb_bg_energy_ti, p_scale_sb_energy[i], tmp, tmpQ, &p_scale_sb_energy[i] );
+ sb_bg_energy[i] = VAD_L_ADD( sb_bg_energy_ti, p_scale_sb_energy[i], tmp, tmpQ, &p_scale_sb_energy[i] ); /* p_scale_sb_energy */
move32();
}
}
@@ -412,16 +409,16 @@ void background_update_fx(
tmpQ = add( 9, hVAD_CLDFB->frame_sb_energy_scale );
FOR( i = 0; i < SNR_sb_num; i++ )
{
- sb_bg_energy_ti = MUL_F( sb_bg_energy[i], 32734 /* 0.999 Q15 */ );
+ sb_bg_energy_ti = MUL_F( sb_bg_energy[i], 32734 /* 0.999 Q15 */ ); /* exp(p_scale_sb_energy) */
tmp = MUL_F( frame_sb_energy[i], 16777 /* 0.001 Q24 */ );
- sb_bg_energy[i] = VAD_L_ADD( sb_bg_energy_ti, p_scale_sb_energy[i], tmp, tmpQ, &p_scale_sb_energy[i] );
+ sb_bg_energy[i] = VAD_L_ADD( sb_bg_energy_ti, p_scale_sb_energy[i], tmp, tmpQ, &p_scale_sb_energy[i] ); /* exp(p_scale_sb_energy) */
move32();
}
}
}
}
- tmp = L_mult0( 160, (Word16) hVAD_CLDFB->tbg_energy_count );
+ tmp = L_mult0( 160, (Word16) hVAD_CLDFB->tbg_energy_count ); /* Q31 */
cmp_pre_frame = VAD_L_CMP( t_bg_energy_sum.s32Mantissa, t_bg_energy_sum.s16Exp, tmp, 0 );
IF( cmp_pre_frame > 0 )
{
@@ -438,10 +435,10 @@ void background_update_fx(
test();
IF( ( EQ_16( music_backgound_f, 1 ) ) && ( LT_32( hVAD_CLDFB->lt_snr_org, 107374179 /* 3.2 Q25 */ ) ) && ( cmp_pre_frame > 0 ) && update_flag == 0 )
{
- tmp = L_shr( 2147 /* 0.000001 Q31 */, sub( 31, scale_sb_energy ) );
+ tmp = L_shr( 2147 /* 0.000001 Q31 */, sub( 31, scale_sb_energy ) ); /* scale_sb_energy */
FOR( i = 0; i < SNR_sb_num; i++ )
{
- sb_bg_energy[i] = L_add( MUL_F( sb_bg_energy[i], 32112 /* 0.98 Q15 */ ), tmp );
+ sb_bg_energy[i] = L_add( MUL_F( sb_bg_energy[i], 32112 /* 0.98 Q15 */ ), tmp ); /* scale_sb_energy */
move32();
}
}
@@ -451,10 +448,14 @@ void background_update_fx(
cmp_pre_frame = VAD_L_CMP( exp_frame_energy.s32Mantissa, exp_frame_energy.s16Exp, MUL_F( t_bg_energy, 5000 ), sub( hVAD_CLDFB->scale_t_bg_energy, 15 ) );
IF( cmp_pre_frame < 0 )
{
- tmp = L_shr( 2147 /* 0.000001 Q31 */, sub( 31, scale_sb_energy ) );
+ tmp = L_shr( 2147 /* 0.000001 Q31 */, sub( 31, scale_sb_energy ) ); /* scale_sb_energy */
FOR( i = 0; i < SNR_sb_num; i++ )
{
- sb_bg_energy[i] = L_add( MUL_F( sb_bg_energy[i], 32112 /* 0.98 Q15 */ ), tmp );
+#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();
}
}
@@ -467,7 +468,7 @@ void background_update_fx(
t_bg_energy_sum.s32Mantissa = MUL_F( t_bg_energy_sum.s32Mantissa, 24575 /* 0.75 Q15 */ );
}
- t_bg_energy = VAD_L_div( t_bg_energy_sum.s32Mantissa, hVAD_CLDFB->tbg_energy_count, t_bg_energy_sum.s16Exp, 0, &q_divout );
+ t_bg_energy = VAD_L_div( t_bg_energy_sum.s32Mantissa, hVAD_CLDFB->tbg_energy_count, t_bg_energy_sum.s16Exp, 0, &q_divout ); /* exp(q_divout) */
hVAD_CLDFB->scale_t_bg_energy = q_divout;
move16();
hVAD_CLDFB->t_bg_energy = t_bg_energy;
diff --git a/lib_enc/eval_pit_contr.c b/lib_enc/eval_pit_contr.c
deleted file mode 100644
index d441f6ead49ddcb3a6a1ffab0962633db8157cd0..0000000000000000000000000000000000000000
--- a/lib_enc/eval_pit_contr.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/eval_pit_contr_fx.c b/lib_enc/eval_pit_contr_fx.c
index a438b79a69d7c00f4014be221038ba6ef65b1921..e49463a5cf1a9eccf19b817a54d636bf68ca46c3 100644
--- a/lib_enc/eval_pit_contr_fx.c
+++ b/lib_enc/eval_pit_contr_fx.c
@@ -51,11 +51,11 @@
Word16 Pit_exc_contribution_len_fx( /* o : bin where pitch contribution is significant */
Encoder_State *st_fx, /* i/o: state structure */
- const Word16 *dct_res, /* i : DCT of residual */
- Word16 *dct_pitex, /* i/o: DCT of pitch contribution */
- Word16 *pitch_buf, /* i/o: Pitch per subframe */
- const Word16 nb_subfr, /* i : Number of subframe considered */
- Word16 *hangover, /* i : hangover for the time contribution switching */
+ const Word16 *dct_res, /* i : DCT of residual Qnew*/
+ Word16 *dct_pitex, /* i/o: DCT of pitch contribution Qnew*/
+ Word16 *pitch_buf, /* i/o: Pitch per subframe Q6*/
+ const Word16 nb_subfr, /* i : Number of subframe considered Q0*/
+ Word16 *hangover, /* i : hangover for the time contribution switching Q0*/
Word16 Qnew )
{
@@ -80,6 +80,8 @@ Word16 Pit_exc_contribution_len_fx( /* o : bin where pit
SP_MUS_CLAS_HANDLE hSpMusClas = st_fx->hSpMusClas;
BSTR_ENC_HANDLE hBstr = st_fx->hBstr;
GSC_ENC_HANDLE hGSCEnc = st_fx->hGSCEnc;
+ move16();
+ move16();
if ( EQ_16( st_fx->L_frame, L_FRAME16k ) )
{
@@ -115,8 +117,8 @@ Word16 Pit_exc_contribution_len_fx( /* o : bin where pit
FOR( j = 0; j < mfreq_bindiv_loc[i]; j++ ) /* up to maximum allowed voiced critical band */
{
- tmp_ex = mult_r( dct_pitex[j + freq], 8192 );
- tmp_res = mult_r( dct_res[j + freq], 8192 );
+ tmp_ex = mult_r( dct_pitex[j + freq], 8192 /* 0.25 in Q15 */ );
+ tmp_res = mult_r( dct_res[j + freq], 8192 /* 0.25 in Q15 */ );
corr_tmp = L_mac0( corr_tmp, tmp_res, tmp_ex ); /*2*Qnew*/
ener_res = L_mac0( ener_res, tmp_res, tmp_res ); /*2*Qnew*/
ener_pit = L_mac0( ener_pit, tmp_ex, tmp_ex ); /*2*Qnew*/
@@ -145,10 +147,10 @@ Word16 Pit_exc_contribution_len_fx( /* o : bin where pit
FOR( i = 1; i < Mbands_loc - 1; i++ ) /* up to maximum allowed voiced critical band */
{
- L_tmp = L_mult( BETA_FX, corr_dct_pit[i - 1] );
- L_tmp = L_mac( L_tmp, BETA_FX, corr_dct_pit[i + 1] );
+ L_tmp = L_mult( BETA_FX, corr_dct_pit[i - 1] ); /* Q30 */
+ L_tmp = L_mac( L_tmp, BETA_FX, corr_dct_pit[i + 1] ); /* Q30 */
- tmp = mac_r( L_tmp, ALPA_FX, corr_dct_pit[i] );
+ tmp = mac_r( L_tmp, ALPA_FX, corr_dct_pit[i] ); /* Q30 */
tmp = s_max( tmp, val_thrs );
corr_dct_pit_tmp[i] = shl( sub( tmp, val_thrs ), 1 );
@@ -176,7 +178,7 @@ Word16 Pit_exc_contribution_len_fx( /* o : bin where pit
if ( EQ_16( st_fx->L_frame, L_FRAME16k ) )
{
/*av_corr *= 1.25f;*/
- av_corr = add( av_corr, shr( av_corr, 2 ) );
+ av_corr = add( av_corr, shr( av_corr, 2 ) ); /* Q2 */
}
test();
if ( GE_16( st_fx->GSC_IVAS_mode, 1 ) || LT_32( st_fx->core_brate, ACELP_9k60 ) )
@@ -193,7 +195,7 @@ Word16 Pit_exc_contribution_len_fx( /* o : bin where pit
{
last_pit_band = i;
move16();
- min_corr = ftmp;
+ min_corr = ftmp; /* Q2 */
move16();
}
}
@@ -315,13 +317,13 @@ Word16 Pit_exc_contribution_len_fx( /* o : bin where pit
{
last_pit_band = add( BAND1k2, 1 );
}
- last_pit_bin = mfreq_loc_div_25[last_pit_band];
+ last_pit_bin = mfreq_loc_div_25[last_pit_band]; /* Q0 */
move16();
st_fx->bpf_off = 0;
move16();
- max_len = sub( st_fx->L_frame, last_pit_bin );
+ max_len = sub( st_fx->L_frame, last_pit_bin ); /* Q0 */
if ( EQ_16( st_fx->bwidth, NB ) )
{
@@ -350,7 +352,7 @@ Word16 Pit_exc_contribution_len_fx( /* o : bin where pit
FOR( i = 0; i < Len; i++ )
{
- dct_pitex[i + last_pit_bin] = mult_r( dct_pitex[i + last_pit_bin], sm_table_fx[i] );
+ dct_pitex[i + last_pit_bin] = mult_r( dct_pitex[i + last_pit_bin], sm_table_fx[i] ); /* Q_new */
}
FOR( ; i < max_len; i++ )
{
@@ -358,7 +360,7 @@ Word16 Pit_exc_contribution_len_fx( /* o : bin where pit
move16();
}
}
- hGSCEnc->mem_last_pit_band = last_pit_band;
+ hGSCEnc->mem_last_pit_band = last_pit_band; /* Q0 */
move16();
pit_contr_idx = sub( last_pit_band, BAND1k2 );
}
@@ -383,7 +385,7 @@ Word16 Pit_exc_contribution_len_fx( /* o : bin where pit
#ifndef IVAS_CODE_BITSTREAM
IF( hBstr->ind_list[i].nb_bits != -1 )
{
- hBstr->nb_bits_tot = sub( hBstr->nb_bits_tot, hBstr->ind_list[i].nb_bits );
+ hBstr->nb_bits_tot = sub( hBstr->nb_bits_tot, hBstr->ind_list[i].nb_bits ); /* Q0 */
hBstr->ind_list[i].nb_bits = -1;
move16();
}
@@ -395,7 +397,8 @@ Word16 Pit_exc_contribution_len_fx( /* o : bin where pit
#ifndef IVAS_CODE_BITSTREAM
IF( hBstr->ind_list[IND_ES_PRED].nb_bits != -1 )
{
- hBstr->nb_bits_tot = sub( hBstr->nb_bits_tot, hBstr->ind_list[IND_ES_PRED].nb_bits );
+ hBstr->nb_bits_tot = sub( hBstr->nb_bits_tot, hBstr->ind_list[IND_ES_PRED].nb_bits ); /* Q0 */
+ move16();
hBstr->ind_list[IND_ES_PRED].nb_bits = -1;
move16();
}
@@ -434,11 +437,11 @@ Word16 Pit_exc_contribution_len_fx( /* o : bin where pit
Word16 Pit_exc_contribution_len_ivas_fx( /* o : bin where pitch contribution is significant */
Encoder_State *st_fx, /* i/o: state structure */
- const Word16 *dct_res, /* i : DCT of residual */
- Word16 *dct_pitex, /* i/o: DCT of pitch contribution */
- Word16 *pitch_buf, /* i/o: Pitch per subframe */
- const Word16 nb_subfr, /* i : Number of subframe considered */
- Word16 *hangover, /* i : hangover for the time contribution switching */
+ const Word16 *dct_res, /* i : DCT of residual Q_new*/
+ Word16 *dct_pitex, /* i/o: DCT of pitch contribution Q_new*/
+ Word16 *pitch_buf, /* i/o: Pitch per subframe Q6*/
+ const Word16 nb_subfr, /* i : Number of subframe considered Q0*/
+ Word16 *hangover, /* i : hangover for the time contribution switching Q0*/
Word16 Qnew )
{
@@ -463,6 +466,7 @@ Word16 Pit_exc_contribution_len_ivas_fx( /* o : bin wher
SP_MUS_CLAS_HANDLE hSpMusClas = st_fx->hSpMusClas;
BSTR_ENC_HANDLE hBstr = st_fx->hBstr;
GSC_ENC_HANDLE hGSCEnc = st_fx->hGSCEnc;
+ move16();
if ( EQ_16( st_fx->L_frame, L_FRAME16k ) )
{
@@ -521,33 +525,33 @@ Word16 Pit_exc_contribution_len_ivas_fx( /* o : bin wher
move16(); /* 0.5 in Q14*/
/* Smooth the inter-correlation value and skip the last band for the average (since last band is almost always 0)*/
tmp = mac_r( L_mult( ALPA_FX, corr_dct_pit[0] ), ALPAM1_FX, corr_dct_pit[1] ); /*Qnew*/
- tmp = s_max( tmp, val_thrs );
+ tmp = s_max( tmp, val_thrs ); /*Qnew */
- corr_dct_pit_tmp[0] = shl( sub( tmp, val_thrs ), 1 );
+ corr_dct_pit_tmp[0] = shl( sub( tmp, val_thrs ), 1 ); /* Q_new + 1 */
move16();
FOR( i = 1; i < Mbands_loc - 1; i++ ) /* up to maximum allowed voiced critical band */
{
- L_tmp = L_mult( BETA_FX, corr_dct_pit[i - 1] );
- L_tmp = L_mac( L_tmp, BETA_FX, corr_dct_pit[i + 1] );
+ L_tmp = L_mult( BETA_FX, corr_dct_pit[i - 1] ); /* Q_new + 16 */
+ L_tmp = L_mac( L_tmp, BETA_FX, corr_dct_pit[i + 1] ); /* Q_new + 16 */
- tmp = mac_r( L_tmp, ALPA_FX, corr_dct_pit[i] );
- tmp = s_max( tmp, val_thrs );
+ tmp = mac_r( L_tmp, ALPA_FX, corr_dct_pit[i] ); /* Q_new */
+ tmp = s_max( tmp, val_thrs ); /* Q_new */
- corr_dct_pit_tmp[i] = shl( sub( tmp, val_thrs ), 1 );
+ corr_dct_pit_tmp[i] = shl( sub( tmp, val_thrs ), 1 ); /* Q_new + 1 */
move16();
}
tmp = mac_r( L_mult( ALPA_FX, corr_dct_pit[i] ), ALPAM1_FX, corr_dct_pit[i - 1] ); /*Qnew*/
- tmp = s_max( tmp, val_thrs );
- corr_dct_pit_tmp[i] = shl( sub( tmp, val_thrs ), 1 );
+ tmp = s_max( tmp, val_thrs ); /* Q_new */
+ corr_dct_pit_tmp[i] = shl( sub( tmp, val_thrs ), 1 ); /* Q_new + 1 */
move16();
- Copy( corr_dct_pit_tmp, corr_dct_pit, Mbands_loc );
+ Copy( corr_dct_pit_tmp, corr_dct_pit, Mbands_loc ); /* Q_new + 1 */
L_tmp1 = L_mult( DIV_NB_VOIC_FX, corr_dct_pit[0] ); /*Qnew*/
FOR( i = 1; i < NB_VOIC_FX; i++ ) /* up to maximum allowed voiced critical band */
{
- L_tmp1 = L_mac( L_tmp1, DIV_NB_VOIC_FX, corr_dct_pit[i] );
+ L_tmp1 = L_mac( L_tmp1, DIV_NB_VOIC_FX, corr_dct_pit[i] ); /* Q_new + 16 */
}
av_corr = round_fx( L_tmp1 ); /*Qnew*/
@@ -652,7 +656,7 @@ Word16 Pit_exc_contribution_len_ivas_fx( /* o : bin wher
move16();
}
- ( *hangover ) = sub( ( *hangover ), 1 );
+ ( *hangover ) = sub( ( *hangover ), 1 ); /* Q0 */
if ( *hangover < 0 )
{
*hangover = 0;
@@ -678,7 +682,7 @@ Word16 Pit_exc_contribution_len_ivas_fx( /* o : bin wher
test();
test();
/*if(st_fx->core_brate core_brate, ACELP_9k60 ) && LT_16( low_pit, 4096 ) )
+ IF( LT_32( st_fx->core_brate, ACELP_9k60 ) && LT_16( low_pit, 4096 /* 64 in Q6 */ ) )
{
last_pit_band = add( 9, BAND1k2 );
if ( EQ_16( st_fx->bwidth, NB ) )
@@ -686,7 +690,7 @@ Word16 Pit_exc_contribution_len_ivas_fx( /* o : bin wher
last_pit_band = add( 7, BAND1k2 );
}
}
- ELSE IF( LT_32( st_fx->core_brate, ACELP_9k60 ) && LT_16( low_pit, 8192 ) )
+ ELSE IF( LT_32( st_fx->core_brate, ACELP_9k60 ) && LT_16( low_pit, 8192 /* 128 in Q6 */ ) )
{
last_pit_band = add( 5, BAND1k2 );
}
@@ -698,7 +702,7 @@ Word16 Pit_exc_contribution_len_ivas_fx( /* o : bin wher
{
last_pit_band = add( BAND1k2, 1 );
}
- last_pit_bin = mfreq_loc_div_25[last_pit_band];
+ last_pit_bin = mfreq_loc_div_25[last_pit_band]; /* Q15 */
move16();
st_fx->bpf_off = 0;
@@ -733,7 +737,7 @@ Word16 Pit_exc_contribution_len_ivas_fx( /* o : bin wher
FOR( i = 0; i < Len; i++ )
{
- dct_pitex[i + last_pit_bin] = mult_r( dct_pitex[i + last_pit_bin], sm_table_fx[i] );
+ dct_pitex[i + last_pit_bin] = mult_r( dct_pitex[i + last_pit_bin], sm_table_fx[i] ); /* Q_new */
}
FOR( ; i < max_len; i++ )
{
diff --git a/lib_enc/evs_enc.c b/lib_enc/evs_enc.c
deleted file mode 100644
index d4fe802221847d9ecedad7d46d88d7aeb2f2d099..0000000000000000000000000000000000000000
--- a/lib_enc/evs_enc.c
+++ /dev/null
@@ -1,45 +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 "wmc_auto.h"
-#include "ivas_prot_fx.h"
-#include "prot_fx.h"
-#include "prot_fx_enc.h"
diff --git a/lib_enc/evs_enc_fx.c b/lib_enc/evs_enc_fx.c
index 787eb6c68f8cf45fef04ca67e6b8eecba7d44cc1..3005edd6e61cd9f11d47b5f0a858a4a02377daad 100644
--- a/lib_enc/evs_enc_fx.c
+++ b/lib_enc/evs_enc_fx.c
@@ -30,10 +30,10 @@ static void configure_core_coder_loc( Encoder_State *st );
*-------------------------------------------------------------------*/
ivas_error evs_enc_fx(
- Encoder_State *st, /* i/o: encoder state structure */
- const Word16 *data, /* i : input signal */
- Word32 *mem_hp20_in_fx, /* i/o: hp20 filter memory */
- const Word16 n_samples /* i : number of input samples */
+ Encoder_State *st, /* i/o: encoder state structure */
+ const Word16 *data, /* i : input signal Q0*/
+ Word32 *mem_hp20_in_fx, /* i/o: hp20 filter memory Qx*/
+ const Word16 n_samples /* i : number of input samples Q0*/
)
{
Word16 i, input_frame, delay;
@@ -144,13 +144,13 @@ ivas_error evs_enc_fx(
/* get delay to synchronize ACELP and MDCT frame */
delay = NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS );
- Copy( st->input_fx - delay, st->old_input_signal_fx, input_frame + delay );
+ Copy( st->input_fx - delay, st->old_input_signal_fx, input_frame + delay ); /* st->q_inp */
/*----------------------------------------------------------------*
* convert 'short' input data to 'float'
*----------------------------------------------------------------*/
- Copy( data, st->input_fx, input_frame );
+ Copy( data, st->input_fx, input_frame ); /* st-> q_inp */
IF( LT_16( n_samples, input_frame ) )
{
set16_fx( st->input_fx + n_samples, 0, sub( input_frame, n_samples ) );
@@ -225,7 +225,7 @@ ivas_error evs_enc_fx(
IF( EQ_16( st->last_L_frame, L_FRAME ) && st->ini_frame != 0 )
{
/* this is just an approximation, but it is sufficient */
- Copy( st->lsp_old1_fx, st->lspold_enc_fx, M );
+ Copy( st->lsp_old1_fx, st->lspold_enc_fx, M ); /* Q15 */
}
}
ELSE
@@ -238,7 +238,7 @@ ivas_error evs_enc_fx(
move16();
}
- st->sr_core = L_mult0( FRAMES_PER_SEC, st->L_frame );
+ st->sr_core = L_mult0( FRAMES_PER_SEC, st->L_frame ); /* Q0 */
st->core_brate = st->total_brate;
move32();
@@ -332,7 +332,7 @@ ivas_error evs_enc_fx(
bwe_exc_extended, voice_factors, pitch_buf,
vad_hover_flag, &Q_new, &shift );
#ifndef FIX_I4_OL_PITCH
- Copy( pitch_orig, st->pitch, 3 ); /* populate the original OL pitch values back */
+ Copy( pitch_orig, st->pitch, 3 ); /* populate the original OL pitch values back Q0*/
#endif
/*---------------------------------------------------------------------*
@@ -393,12 +393,12 @@ ivas_error evs_enc_fx(
move32();
}
- st->core_brate = L_sub( st->total_brate, st->extl_brate );
+ st->core_brate = L_sub( st->total_brate, st->extl_brate ); /* Q0 */
IF( EQ_16( st->tec_tfa, 1 ) )
{
- st->core_brate = L_sub( st->core_brate, BITS_TEC );
- st->core_brate = L_sub( st->core_brate, BITS_TFA );
+ st->core_brate = L_sub( st->core_brate, BITS_TEC ); /* Q0 */
+ st->core_brate = L_sub( st->core_brate, BITS_TFA ); /* Q0 */
}
}
@@ -413,14 +413,14 @@ ivas_error evs_enc_fx(
IF( st->igf != 0 && EQ_16( st->core, ACELP_CORE ) && GT_32( st->core_brate, SID_2k40 ) )
{
/* padBits = ((st->bits_frame+7)/8)*8 - (st->nb_bits_tot + (st->rf_target_bits_write - ((st->Opt_RF_ON==1)?1:0) ) + get_tbe_bits(st->total_brate, st->bwidth, st->rf_mode )); */
- tmp = add( get_tbe_bits_fx( st->total_brate, st->bwidth, st->rf_mode ), sub( st->rf_target_bits_write, st->rf_mode ) );
- padBits = sub( sub( shl( shr( add( st->bits_frame, 7 ), 3 ), 3 ), hBstr->nb_bits_tot ), tmp );
+ tmp = add( get_tbe_bits_fx( st->total_brate, st->bwidth, st->rf_mode ), sub( st->rf_target_bits_write, st->rf_mode ) ); /* Q0 */
+ padBits = sub( sub( shl( shr( add( st->bits_frame, 7 ), 3 ), 3 ), hBstr->nb_bits_tot ), tmp ); /* Q0 */
}
ELSE
{
/* padBits = ((st->bits_frame+7)/8)*8 - (st->nb_bits_tot + (st->rf_target_bits_write - ((st->Opt_RF_ON==1)?1:0) )); */
- tmp = sub( st->rf_target_bits_write, st->rf_mode );
- padBits = sub( shl( shr( add( st->bits_frame, 7 ), 3 ), 3 ), add( hBstr->nb_bits_tot, tmp ) );
+ tmp = sub( st->rf_target_bits_write, st->rf_mode ); /* Q0 */
+ padBits = sub( shl( shr( add( st->bits_frame, 7 ), 3 ), 3 ), add( hBstr->nb_bits_tot, tmp ) ); /* Q0 */
}
FOR( i = 0; i < padBits; i++ )
@@ -517,7 +517,7 @@ ivas_error evs_enc_fx(
st->hTECEnc->corrFlag = 0;
move16();
}
- st->tfa_flag = tfaEnc_TBE_fx( st->tfa_enr, st->last_core, st->voicing_fx, pitch_buf, shl( Q_shb_spch, 1 ) );
+ st->tfa_flag = tfaEnc_TBE_fx( st->tfa_enr, st->last_core, st->voicing_fx, pitch_buf, shl( Q_shb_spch, 1 ) ); /* Q0 */
set_TEC_TFA_code_fx( st->hTECEnc->corrFlag, &st->tec_flag, &st->tfa_flag );
}
ELSE
diff --git a/lib_enc/ext_sig_ana.c b/lib_enc/ext_sig_ana.c
deleted file mode 100644
index 9f9fa4c23133239f729cb22721f441ff8c4e71c0..0000000000000000000000000000000000000000
--- a/lib_enc/ext_sig_ana.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
-#include "options.h"
-#include
-#include "prot.h"
-#include "rom_com.h"
-#include "wmc_auto.h"
diff --git a/lib_enc/ext_sig_ana_fx.c b/lib_enc/ext_sig_ana_fx.c
index 0ad43487ac788b746cdc6c5dcc23370f05fd86cb..f55d870201908577b1e19eb447b5033d48d81bb6 100644
--- a/lib_enc/ext_sig_ana_fx.c
+++ b/lib_enc/ext_sig_ana_fx.c
@@ -23,19 +23,19 @@
void core_signal_analysis_high_bitrate_fx(
const Word16 *new_samples, /*i: 0Q15*/
- const Word16 T_op[3], /* i : open-loop pitch values for quantiz. */
- Word16 lsp_new[],
- Word16 lsp_mid[],
+ const Word16 T_op[3], /* i : open-loop pitch values for quantiz. Q0*/
+ Word16 lsp_new[], /* Q15 */
+ Word16 lsp_mid[], /* Q15 */
Encoder_State *st,
- Word16 pTnsSize[],
- Word16 pTnsBits[],
- Word16 param_core[],
- Word16 *ltpBits,
- const Word16 L_frame,
- const Word16 L_frameTCX,
- const Word16 last_element_mode,
- const Word16 vad_hover_flag, /* i : VAD hangover flag */
- Word32 **spectrum,
+ Word16 pTnsSize[], /* Q0 */
+ Word16 pTnsBits[], /* Q0 */
+ Word16 param_core[], /* Q0 */
+ Word16 *ltpBits, /* Q0 */
+ const Word16 L_frame, /* Q0 */
+ const Word16 L_frameTCX, /* Q0 */
+ const Word16 last_element_mode, /* Q0 */
+ const Word16 vad_hover_flag, /* i : VAD hangover flag Q0*/
+ Word32 **spectrum, /* spectrum_e */
Word16 *spectrum_e,
Word16 *Q_new )
{
@@ -93,10 +93,10 @@ void core_signal_analysis_high_bitrate_fx(
right_overlap = -1;
move16();
- tcx10SizeFB = shl( st->hTcxCfg->tcx5SizeFB, 1 );
- tcx5SizeFB = st->hTcxCfg->tcx5SizeFB;
+ tcx10SizeFB = shl( st->hTcxCfg->tcx5SizeFB, 1 ); /* Q0 */
+ tcx5SizeFB = st->hTcxCfg->tcx5SizeFB; /* Q0 */
move16();
- tcx10Size = shl( st->hTcxCfg->tcx5Size, 1 );
+ tcx10Size = shl( st->hTcxCfg->tcx5Size, 1 ); /* Q0 */
/*--------------------------------------------------------------*
* Input Signal Processing: copy, HP filter, pre-emphasis
@@ -105,8 +105,8 @@ void core_signal_analysis_high_bitrate_fx(
/* Copy Samples */
IF( st->tcxonly && NE_16( st->element_mode, IVAS_CPE_MDCT ) )
{
- Copy( new_samples, st->new_speech_enc, L_frame );
- Scale_sig( st->new_speech_enc, L_frame, 1 );
+ Copy( new_samples, st->new_speech_enc, L_frame ); /* Q0 */
+ Scale_sig( st->new_speech_enc, L_frame, 1 ); /* Q1 */
}
/*--------------------------------------------------------------*
@@ -158,16 +158,16 @@ void core_signal_analysis_high_bitrate_fx(
move16();
/* Rescale Memory */
- Scale_sig( st->old_inp_16k_fx, L_INP_MEM, sub( *Q_new, st->Q_old ) );
+ Scale_sig( st->old_inp_16k_fx, L_INP_MEM, sub( *Q_new, st->Q_old ) ); /* Q_new */
IF( Q_exp != 0 )
{
- Scale_sig( st->buf_speech_enc_pe, st->encoderPastSamples_enc + st->encoderLookahead_enc, Q_exp );
+ Scale_sig( st->buf_speech_enc_pe, st->encoderPastSamples_enc + st->encoderLookahead_enc, Q_exp ); /* Q15 - exp_buf_speech_enc_pe + Q_exp */
Scale_sig( &( st->mem_wsp_enc ), 1, Q_exp );
}
IF( EQ_16( hTcxEnc->tcxMode, TCX_10 ) )
{
- Copy( ¶m_core[1 + NOISE_FILL_RANGES], ¶m_core[NPRM_DIV + 1 + NOISE_FILL_RANGES], LTPSIZE );
+ Copy( ¶m_core[1 + NOISE_FILL_RANGES], ¶m_core[NPRM_DIV + 1 + NOISE_FILL_RANGES], LTPSIZE ); /* Q0 */
}
@@ -178,19 +178,19 @@ void core_signal_analysis_high_bitrate_fx(
{
lsp[0] = lsp_new;
lsp[1] = lsp_mid;
- alw_pitch_lag_12k8[0] = st->pitch[0];
+ alw_pitch_lag_12k8[0] = st->pitch[0]; /* Q0 */
move16();
- alw_pitch_lag_12k8[1] = st->pitch[1];
+ alw_pitch_lag_12k8[1] = st->pitch[1]; /* Q0 */
move16();
- alw_voicing[0] = st->voicing_fx[0];
+ alw_voicing[0] = st->voicing_fx[0]; /* Q15 */
move16();
- alw_voicing[1] = st->voicing_fx[1];
+ alw_voicing[1] = st->voicing_fx[1]; /* Q15 */
move16();
- alw_pitch_lag_12k8_wc = s_min( alw_pitch_lag_12k8[0], alw_pitch_lag_12k8[1] );
- alw_voicing_wc = s_max( alw_voicing[0], alw_voicing[1] );
+ alw_pitch_lag_12k8_wc = s_min( alw_pitch_lag_12k8[0], alw_pitch_lag_12k8[1] ); /* Q0 */
+ alw_voicing_wc = s_max( alw_voicing[0], alw_voicing[1] ); /* Q15 */
}
- overlap_mode[0] = last_overlap; /* Overlap between the last and the current frame */
+ overlap_mode[0] = last_overlap; /* Overlap between the last and the current frame Q0*/
move16();
IF( EQ_16( hTcxEnc->tcxMode, TCX_20 ) )
@@ -200,14 +200,14 @@ void core_signal_analysis_high_bitrate_fx(
transform_type[0] = TCX_20;
transform_type[1] = TCX_20;
move16();
- overlap_mode[1] = curr_overlap; /* Overlap between the current and the next frame */
+ overlap_mode[1] = curr_overlap; /* Overlap between the current and the next frame Q0*/
move16();
IF( NE_16( st->element_mode, IVAS_CPE_MDCT ) )
{
- alw_pitch_lag_12k8[0] = alw_pitch_lag_12k8_wc;
+ alw_pitch_lag_12k8[0] = alw_pitch_lag_12k8_wc; /* Q0 */
move16();
- alw_voicing[0] = alw_voicing_wc;
+ alw_voicing[0] = alw_voicing_wc; /* Q15 */
move16();
}
}
@@ -260,7 +260,7 @@ void core_signal_analysis_high_bitrate_fx(
move16();
}
}
- overlap_mode[2] = curr_overlap; /* Overlap between the current and the next frame */
+ overlap_mode[2] = curr_overlap; /* Overlap between the current and the next frame Q0*/
move16();
}
IF( NE_16( transform_type[0], TCX_20 ) )
@@ -273,14 +273,14 @@ void core_signal_analysis_high_bitrate_fx(
FOR( frameno = 0; frameno < nSubframes; frameno++ )
{
- L_subframe = L_frameTCX;
+ L_subframe = L_frameTCX; /* Q0 */
move16();
if ( NE_16( nSubframes, 1 ) )
L_subframe = shr( L_frameTCX, 1 );
- lpc_left_overlap_mode = overlap_mode[frameno];
+ lpc_left_overlap_mode = overlap_mode[frameno]; /* Q0 */
move16();
- lpc_right_overlap_mode = overlap_mode[frameno + 1];
+ lpc_right_overlap_mode = overlap_mode[frameno + 1]; /* Q0 */
move16();
if ( EQ_16( lpc_left_overlap_mode, ALDO_WINDOW ) )
{
@@ -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] );
-#else
- tcx20Win[folding_offset + i] = sub( tcx20Win[folding_offset + i], tcx20Win[folding_offset - 1 - i] );
-#endif
+ tcx20Win[folding_offset + i] = sub_sat( tcx20Win[folding_offset + i], tcx20Win[folding_offset - 1 - i] ); // Q0
move16();
}
#ifdef IVAS_CODE
@@ -338,19 +334,15 @@ 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] );
-#else
- tcx20Win[L_subframe + folding_offset - 1 - i] = add( tcx20Win[L_subframe + folding_offset - 1 - i], tcx20Win[L_subframe + folding_offset + i] );
-#endif
+ tcx20Win[L_subframe + folding_offset - 1 - i] = add_sat( tcx20Win[L_subframe + folding_offset - 1 - i], tcx20Win[L_subframe + folding_offset + i] ); // Q0
move16();
}
/* 2xTCX5 */
- L_subframe = tcx5SizeFB;
+ L_subframe = tcx5SizeFB; /* Q0 */
move16();
tmpP16 = tcx20Win;
- tmpP32 = spectrum[frameno];
+ tmpP32 = spectrum[frameno]; /* exp(spectrum) */
assert( st->mct_chan_mode != MCT_CHAN_MODE_LFE );
FOR( i = 0; i < 2; i++ )
{
@@ -411,7 +403,7 @@ void core_signal_analysis_high_bitrate_fx(
FOR( i = 0; i < L_subframe; i++ )
{
- tmp_buf[i] = Mpy_32_16_1( tmp_buf[i], tmp1 );
+ tmp_buf[i] = Mpy_32_16_1( tmp_buf[i], tmp1 ); /* Q - 4 */
move32();
}
Q = sub( Q, tmp2 );
@@ -579,9 +571,9 @@ void core_signal_analysis_high_bitrate_fx(
/* group sub-windows: interleave bins according to their frequencies */
FOR( i = 0; i < tcx5SizeFB; i++ )
{
- interleaveBuf[2 * i] = spectrum[frameno][i];
+ interleaveBuf[2 * i] = spectrum[frameno][i]; /* exp(spectrum_e) */
move32();
- interleaveBuf[2 * i + 1] = spectrum[frameno][tcx5SizeFB + i];
+ interleaveBuf[2 * i + 1] = spectrum[frameno][tcx5SizeFB + i]; /* exp(spectrum_e) */
move32();
}
MVR2R_WORD32( interleaveBuf, spectrum[frameno], tcx10SizeFB );
@@ -617,7 +609,7 @@ void core_signal_analysis_high_bitrate_fx(
}
/* Copy memory */
- MVR2R_WORD16( lsp_new, st->lspold_enc_fx, M );
+ MVR2R_WORD16( lsp_new, st->lspold_enc_fx, M ); /* Q15 */
}
}
@@ -632,20 +624,20 @@ void core_signal_analysis_high_bitrate_fx(
void core_signal_analysis_high_bitrate_ivas_fx(
const Word16 *new_samples, /*i: Q0 */
- const Word16 T_op[3], /* i : open-loop pitch values for quantiz. */
+ const Word16 T_op[3], /* i : open-loop pitch values for quantiz. Q0*/
Word16 lsp_new[], /* Q15 */
Word16 lsp_mid[], /* Q15 */
Encoder_State *st,
- Word16 pTnsSize[],
- Word16 pTnsBits[],
- Word16 param_core[],
- Word16 *ltpBits,
- Word32 *windowed_samples,
- const Word16 L_frame,
- const Word16 L_frameTCX,
- const Word16 last_element_mode,
- const Word16 vad_hover_flag, /* i : VAD hangover flag */
- Word32 **spectrum,
+ Word16 pTnsSize[], /* Q0 */
+ Word16 pTnsBits[], /* Q0 */
+ Word16 param_core[], /* Q0 */
+ Word16 *ltpBits, /* Q0 */
+ Word32 *windowed_samples, /* q_win */
+ const Word16 L_frame, /* Q0 */
+ const Word16 L_frameTCX, /* Q0 */
+ const Word16 last_element_mode, /* Q0 */
+ const Word16 vad_hover_flag, /* i : VAD hangover flag Q0*/
+ Word32 **spectrum, /* exp(spectrum_e) */
Word16 *spectrum_e,
Word16 *Q_new,
Word16 *q_win )
@@ -657,13 +649,14 @@ void core_signal_analysis_high_bitrate_ivas_fx(
Word16 i, frameno;
Word16 L_subframe;
Word16 left_overlap = -1, right_overlap = -1, folding_offset;
- Word32 buf[N_MAX + L_MDCT_OVLP_MAX]; /* Buffer for TCX20/TCX10 windowing */
- Word32 buf_powerSPec[N_MAX + L_MDCT_OVLP_MAX]; /* Buffer for TCX20/TCX10 windowing */
- Word16 mdstWin[N_MAX + L_MDCT_OVLP_MAX]; /* Buffer for MDST windowing */
+ Word32 buf[N_MAX + L_MDCT_OVLP_MAX]; /* Buffer for TCX20/TCX10 windowing */
+ Word32 buf_powerSPec[N_MAX + L_MDCT_OVLP_MAX]; /* Buffer for TCX20/TCX10 windowing */
+ Word16 buf_powerSPec_exp[N_MAX + L_MDCT_OVLP_MAX]; /* Buffer for TCX20/TCX10 windowing */
+ Word16 mdstWin[N_MAX + L_MDCT_OVLP_MAX]; /* Buffer for MDST windowing */
Word16 *pMdstWin;
Word16 lpc_left_overlap_mode, lpc_right_overlap_mode;
Word32 *powerSpec = buf_powerSPec;
- Word16 powerSpec_e;
+ Word16 *powerSpec_e = buf_powerSPec_exp;
Word16 *tcx20Win = (Word16 *) buf;
Word32 *tcx20Win_32 = buf;
Word32 interleaveBuf[N_TCX10_MAX];
@@ -692,16 +685,16 @@ void core_signal_analysis_high_bitrate_ivas_fx(
move16();
move16();
(void) vad_hover_flag;
- powerSpec_e = 0;
- move16();
-
+ 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 );
if ( NE_16( last_element_mode, st->element_mode ) )
{
@@ -717,15 +710,15 @@ void core_signal_analysis_high_bitrate_ivas_fx(
test();
IF( st->tcxonly && NE_16( st->element_mode, IVAS_CPE_MDCT ) )
{
- Copy( new_samples, st->new_speech_enc, L_frame );
- Scale_sig( st->new_speech_enc, L_frame, 1 ); // Q1
+ Copy( new_samples, st->new_speech_enc, L_frame ); /* Q0 */
+ Scale_sig( st->new_speech_enc, L_frame, 1 ); // Q1
}
/*--------------------------------------------------------------*
* TCX-LTP
*---------------------------------------------------------------*/
- if ( st->element_mode == IVAS_CPE_DFT )
+ if ( EQ_16( st->element_mode, IVAS_CPE_DFT ) )
{
if ( st->element_mode > EVS_MONO )
{
@@ -736,9 +729,9 @@ void core_signal_analysis_high_bitrate_ivas_fx(
wspeech_fx = st->buf_wspeech_enc + st->L_frame + idiv1616( st->L_frame, st->nb_subfr );
}
}
- else if ( st->element_mode != IVAS_CPE_MDCT )
+ else if ( NE_16( st->element_mode, IVAS_CPE_MDCT ) )
{
- speech_fx = st->buf_speech_enc + +st->encoderPastSamples_enc;
+ speech_fx = st->buf_speech_enc + st->encoderPastSamples_enc;
speech_ltp_fx = st->hTcxEnc->buf_speech_ltp + st->encoderPastSamples_enc;
}
@@ -746,7 +739,7 @@ void core_signal_analysis_high_bitrate_ivas_fx(
{
tcx_ltp_encode_ivas_fx( st, hTcxEnc->tcxMode, L_frame, wspeech_fx, NULL, wspeech_fx, T_op, ¶m_core[1 + NOISE_FILL_RANGES], ltpBits, NULL, disable_ltp, st->element_mode );
}
- ELSE IF( st->element_mode != IVAS_CPE_MDCT )
+ ELSE IF( NE_16( st->element_mode, IVAS_CPE_MDCT ) )
{
tcx_ltp_encode_ivas_fx( st, hTcxEnc->tcxMode, L_frame, speech_fx + st->encoderLookahead_enc, speech_ltp_fx + st->encoderLookahead_enc, speech_fx + st->encoderLookahead_enc, T_op, ¶m_core[1 + NOISE_FILL_RANGES], ltpBits, NULL, disable_ltp, st->element_mode );
}
@@ -769,20 +762,22 @@ void core_signal_analysis_high_bitrate_ivas_fx(
move16();
IF( Q_exp != 0 )
{
- Scale_sig( st->buf_speech_enc_pe, st->encoderPastSamples_enc + st->encoderLookahead_enc, Q_exp ); // *Q_new
- Scale_sig( &( st->mem_wsp_enc ), 1, Q_exp ); // *Q_new
+ Scale_sig( st->buf_speech_enc_pe, st->encoderPastSamples_enc + st->encoderLookahead_enc, sub( Q_exp, sub( Q15, st->exp_buf_speech_enc_pe ) ) ); // *Q_new
+ st->exp_buf_speech_enc_pe = sub( Q15, Q_exp );
+ move16();
+ Scale_sig( &( st->mem_wsp_enc ), 1, Q_exp ); // *Q_new
}
IF( EQ_16( hTcxEnc->tcxMode, TCX_10 ) )
{
- Copy( ¶m_core[1 + NOISE_FILL_RANGES], ¶m_core[NPRM_DIV + 1 + NOISE_FILL_RANGES], LTPSIZE );
+ Copy( ¶m_core[1 + NOISE_FILL_RANGES], ¶m_core[NPRM_DIV + 1 + NOISE_FILL_RANGES], LTPSIZE ); // Q0
}
IF( NE_16( st->element_mode, IVAS_CPE_MDCT ) )
{
- lsp[0] = lsp_new;
+ lsp[0] = lsp_new; // Q15
move16();
- lsp[1] = lsp_mid;
+ lsp[1] = lsp_mid; // Q15
move16();
}
@@ -792,19 +787,19 @@ void core_signal_analysis_high_bitrate_ivas_fx(
IF( NE_16( st->element_mode, IVAS_CPE_MDCT ) )
{
- alw_pitch_lag_12k8[0] = st->pitch[0];
+ alw_pitch_lag_12k8[0] = st->pitch[0]; // Q0
move16();
- alw_pitch_lag_12k8[1] = st->pitch[1];
+ alw_pitch_lag_12k8[1] = st->pitch[1]; // Q0
move16();
- alw_voicing[0] = st->voicing_fx[0];
+ alw_voicing[0] = st->voicing_fx[0]; // Q15
move16();
- alw_voicing[1] = st->voicing_fx[1];
+ alw_voicing[1] = st->voicing_fx[1]; // Q15
move16();
- alw_pitch_lag_12k8_wc = s_min( alw_pitch_lag_12k8[0], alw_pitch_lag_12k8[1] );
- alw_voicing_wc = s_max( alw_voicing[0], alw_voicing[1] );
+ alw_pitch_lag_12k8_wc = s_min( alw_pitch_lag_12k8[0], alw_pitch_lag_12k8[1] ); // Q0
+ alw_voicing_wc = s_max( alw_voicing[0], alw_voicing[1] ); // Q15
}
- overlap_mode[0] = last_overlap; /* Overlap between the last and the current frame */
+ overlap_mode[0] = last_overlap; /* Overlap between the last and the current frame Q0*/
move16();
IF( EQ_16( hTcxEnc->tcxMode, TCX_20 ) )
@@ -815,14 +810,14 @@ void core_signal_analysis_high_bitrate_ivas_fx(
move16();
transform_type[1] = TCX_20;
move16();
- overlap_mode[1] = curr_overlap; /* Overlap between the current and the next frame */
+ overlap_mode[1] = curr_overlap; /* Overlap between the current and the next frame Q0*/
move16();
IF( NE_16( st->element_mode, IVAS_CPE_MDCT ) )
{
- alw_pitch_lag_12k8[0] = alw_pitch_lag_12k8_wc;
+ alw_pitch_lag_12k8[0] = alw_pitch_lag_12k8_wc; // Q0
move16();
- alw_voicing[0] = alw_voicing_wc;
+ alw_voicing[0] = alw_voicing_wc; // Q15
move16();
}
}
@@ -875,7 +870,7 @@ void core_signal_analysis_high_bitrate_ivas_fx(
move16();
}
}
- overlap_mode[2] = curr_overlap; /* Overlap between the current and the next frame */
+ overlap_mode[2] = curr_overlap; /* Overlap between the current and the next frame Q0*/
move16();
}
@@ -891,16 +886,16 @@ void core_signal_analysis_high_bitrate_ivas_fx(
FOR( frameno = 0; frameno < nSubframes; frameno++ )
{
- L_subframe = L_frameTCX;
+ L_subframe = L_frameTCX; // Q0
move16();
IF( NE_16( nSubframes, 1 ) )
{
L_subframe = shr( L_frameTCX, 1 );
}
- lpc_left_overlap_mode = overlap_mode[frameno];
+ lpc_left_overlap_mode = overlap_mode[frameno]; // Q0
move16();
- lpc_right_overlap_mode = overlap_mode[frameno + 1];
+ lpc_right_overlap_mode = overlap_mode[frameno + 1]; // Q0
move16();
if ( EQ_16( lpc_left_overlap_mode, ALDO_WINDOW ) )
{
@@ -921,13 +916,31 @@ void core_signal_analysis_high_bitrate_ivas_fx(
IF( windowed_samples != NULL ) /* store overlap data for later */
{
assert( frameno == 0 );
- windowed_samples[0] = L_deposit_l( overlap_mode[frameno] );
- windowed_samples[1] = L_deposit_l( overlap_mode[frameno + 1] );
+ windowed_samples[0] = L_deposit_l( overlap_mode[frameno] ); // Q0
+ windowed_samples[1] = L_deposit_l( overlap_mode[frameno + 1] ); // Q0
}
IF( NE_16( st->element_mode, IVAS_CPE_MDCT ) )
{
+ Word16 left_overlap_mode, right_overlap_mode;
+ if ( EQ_16( overlap_mode[frameno], ALDO_WINDOW ) )
+ {
+ left_overlap_mode = FULL_OVERLAP;
+ }
+ else
+ {
+ left_overlap_mode = overlap_mode[frameno]; // Q0
+ }
+
+ if ( EQ_16( overlap_mode[frameno + 1], ALDO_WINDOW ) )
+ {
+ right_overlap_mode = FULL_OVERLAP;
+ }
+ else
+ {
+ right_overlap_mode = overlap_mode[frameno + 1]; // Q0
+ }
/* Windowing of the 2xTCX5 subframes or 1xTCX10 or 1xTCX20 */
- WindowSignal( st->hTcxCfg, st->hTcxCfg->tcx_offsetFB, overlap_mode[frameno] == ALDO_WINDOW ? FULL_OVERLAP : overlap_mode[frameno], overlap_mode[frameno + 1] == ALDO_WINDOW ? FULL_OVERLAP : overlap_mode[frameno + 1], &left_overlap, &right_overlap, &hTcxEnc->speech_TCX[frameno * tcx10SizeFB], &L_subframe, mdstWin, 1, 1 );
+ WindowSignal( st->hTcxCfg, st->hTcxCfg->tcx_offsetFB, left_overlap_mode, right_overlap_mode, &left_overlap, &right_overlap, &hTcxEnc->speech_TCX[frameno * tcx10SizeFB], &L_subframe, mdstWin, 1, 1 );
}
}
ELSE
@@ -940,15 +953,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] );
- windowed_samples[frameno * L_FRAME_MAX + 1] = L_deposit_l( overlap_mode[frameno + 1] );
- Copy_Scale_sig_16_32( tcx20Win, windowed_samples + frameno * L_FRAME_MAX + 2, L_subframe + ( left_overlap + right_overlap ) / 2, 0 );
- *q_win = s_min( *q_win, sub( L_norm_arr( windowed_samples + frameno * L_FRAME_MAX + 2, L_subframe + ( left_overlap + right_overlap ) / 2 ), 1 ) );
+ 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
+ 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 );
+ 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
+ }
}
}
@@ -959,11 +983,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] );
-#else
- tcx20Win[folding_offset + i] = sub( tcx20Win[folding_offset + i], tcx20Win[folding_offset - 1 - i] );
-#endif
+ tcx20Win[folding_offset + i] = sub_sat( tcx20Win[folding_offset + i], tcx20Win[folding_offset - 1 - i] ); // Q0
move16();
}
@@ -979,11 +999,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 */
@@ -991,11 +1007,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();
}
}
@@ -1004,11 +1016,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] );
-#else
- tcx20Win[L_subframe + folding_offset - 1 - i] = add( tcx20Win[L_subframe + folding_offset - 1 - i], tcx20Win[L_subframe + folding_offset + i] );
-#endif
+ tcx20Win[L_subframe + folding_offset - 1 - i] = add_sat( tcx20Win[L_subframe + folding_offset - 1 - i], tcx20Win[L_subframe + folding_offset + i] ); // Q0
move16();
}
@@ -1072,7 +1080,7 @@ void core_signal_analysis_high_bitrate_ivas_fx(
Word16 Q;
Q = q_out_wtda;
- edct_fx( tcx20Win_32, hTcxEnc->spectrum_fx[frameno], L_subframe, &Q );
+ edct_ivas_fx( tcx20Win_32, hTcxEnc->spectrum_fx[frameno], L_subframe, &Q );
hTcxEnc->spectrum_e[frameno] = sub( 31, Q );
move16();
@@ -1100,11 +1108,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 */
@@ -1112,11 +1116,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();
}
}
@@ -1154,16 +1154,16 @@ void core_signal_analysis_high_bitrate_ivas_fx(
}
/* Compute noise-measure flags for spectrum filling and quantization */
- AnalyzePowerSpectrum_fx( st, div_l( L_mult( L_subframe, st->L_frame ), hTcxEnc->L_frameTCX ),
- L_subframe, left_overlap, right_overlap, hTcxEnc->spectrum_fx[frameno], hTcxEnc->spectrum_e[frameno],
- pMdstWin, powerSpec, &powerSpec_e );
+ AnalyzePowerSpectrum_ivas_fx( st, div_l( L_mult( L_subframe, st->L_frame ), hTcxEnc->L_frameTCX ),
+ L_subframe, left_overlap, right_overlap, hTcxEnc->spectrum_fx[frameno], hTcxEnc->spectrum_e[frameno],
+ pMdstWin, powerSpec, powerSpec_e );
}
}
}
IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) )
{
- L_subframe = idiv1616( L_frameTCX, nSubframes );
+ L_subframe = idiv1616( L_frameTCX, nSubframes ); /* Q0 */
test();
IF( EQ_16( transform_type[frameno], TCX_20 ) && NE_16( st->hTcxCfg->tcx_last_overlap_mode, TRANSITION_OVERLAP ) )
@@ -1182,11 +1182,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] );
-#else
- mdstWin[left_overlap / 2 + i] = add( mdstWin[left_overlap / 2 + i], mdstWin[left_overlap / 2 - 1 - i] );
-#endif
+ mdstWin[left_overlap / 2 + i] = add_sat( mdstWin[left_overlap / 2 + i], mdstWin[left_overlap / 2 - 1 - i] ); // Q0
}
test();
@@ -1200,11 +1196,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 */
@@ -1212,11 +1204,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();
}
}
@@ -1224,11 +1212,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] );
-#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
+ 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
move16();
}
@@ -1299,11 +1283,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 */
@@ -1311,11 +1291,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();
}
}
@@ -1360,9 +1336,9 @@ void core_signal_analysis_high_bitrate_ivas_fx(
/* group sub-windows: interleave bins according to their frequencies */
FOR( i = 0; i < tcx5SizeFB; i++ )
{
- interleaveBuf[2 * i] = hTcxEnc->spectrum_fx[frameno][i];
+ interleaveBuf[2 * i] = hTcxEnc->spectrum_fx[frameno][i]; /* hTcxEnc->spectrum_e */
move32();
- interleaveBuf[2 * i + 1] = hTcxEnc->spectrum_fx[frameno][tcx5SizeFB + i];
+ interleaveBuf[2 * i + 1] = hTcxEnc->spectrum_fx[frameno][tcx5SizeFB + i]; /* hTcxEnc->spectrum_e */
move32();
}
MVR2R_WORD32( interleaveBuf, hTcxEnc->spectrum_fx[frameno], tcx10SizeFB );
@@ -1394,10 +1370,7 @@ void core_signal_analysis_high_bitrate_ivas_fx(
IF( st->igf )
{
Word16 q_spectrum = sub( Q31, hTcxEnc->spectrum_e[frameno] );
- Word16 q_powerSpec = sub( Q31, powerSpec_e );
- st->hIGFEnc->spec_be_igf_e = hTcxEnc->spectrum_e[frameno];
- move16();
- ProcessIGF_ivas_fx( st, hTcxEnc->spectrum_fx[frameno], hTcxEnc->spectrum_fx[frameno], &q_spectrum, powerSpec, &q_powerSpec, transform_type[frameno] == TCX_20, frameno, 0, vad_hover_flag );
+ ProcessIGF_ivas_fx( st, hTcxEnc->spectrum_fx[frameno], hTcxEnc->spectrum_fx[frameno], &q_spectrum, powerSpec, powerSpec_e, transform_type[frameno] == TCX_20, frameno, 0, vad_hover_flag );
}
}
}
diff --git a/lib_enc/fd_cng_enc.c b/lib_enc/fd_cng_enc.c
index 47408845100650353abdfd4e1c633078c2dfd84a..5c493876bab2caeb84ae0a6f9db36e2bcd1c5371 100644
--- a/lib_enc/fd_cng_enc.c
+++ b/lib_enc/fd_cng_enc.c
@@ -73,39 +73,39 @@
* Perform noise estimation
*-------------------------------------------------------------------*/
void perform_noise_estimation_enc_ivas_fx(
- Word32 *band_energies, /* i: energy in critical bands without minimum noise floor MODE2_E_MIN */
+ Word32 *band_energies, /* i: energy in critical bands without minimum noise floor MODE2_E_MIN band_energies_exp*/
Word16 band_energies_exp,
- Word32 *enerBuffer,
+ Word32 *enerBuffer, /* enerBuffer_exp */
Word16 enerBuffer_exp,
HANDLE_FD_CNG_ENC hFdCngEnc, /* i/o: CNG structure containing all buffers and variables */
- const Word32 input_Fs, /* i : input sampling rate */
+ const Word32 input_Fs, /* i : input sampling rate Q0*/
CPE_ENC_HANDLE hCPE /* i : CPE encoder structure */
)
{
Word16 i, j, s, s1, s2;
Word16 numBands;
- Word16 numCoreBands = hFdCngEnc->hFdCngCom->numCoreBands;
+ Word16 numCoreBands = hFdCngEnc->hFdCngCom->numCoreBands; /* Q0 */
move16();
- Word16 regularStopBand = hFdCngEnc->hFdCngCom->regularStopBand;
+ Word16 regularStopBand = hFdCngEnc->hFdCngCom->regularStopBand; /* Q0 */
move16();
- Word16 numSlots = hFdCngEnc->hFdCngCom->numSlots;
+ Word16 numSlots = hFdCngEnc->hFdCngCom->numSlots; /* Q0 */
move16();
assert( numSlots == 16 );
Word32 numSlots_inv_fx = 134217728;
move32();
- Word32 *periodog = hFdCngEnc->hFdCngCom->periodog;
+ Word32 *periodog = hFdCngEnc->hFdCngCom->periodog; /* exp(peridog_exp) */
Word32 *ptr_per_fx = periodog;
- Word16 npart = hFdCngEnc->hFdCngCom->npart;
+ Word16 npart = hFdCngEnc->hFdCngCom->npart; /* Q0 */
move16();
- Word16 nFFTpart = hFdCngEnc->hFdCngCom->nFFTpart;
+ Word16 nFFTpart = hFdCngEnc->hFdCngCom->nFFTpart; /* Q0 */
move16();
- Word16 nCLDFBpart = hFdCngEnc->hFdCngCom->nCLDFBpart;
+ Word16 nCLDFBpart = hFdCngEnc->hFdCngCom->nCLDFBpart; /* Q0 */
move16();
- Word16 *psize = hFdCngEnc->hFdCngCom->psize;
+ Word16 *psize = hFdCngEnc->hFdCngCom->psize; // 6Q9
Word32 *msPeriodog_fx = hFdCngEnc->msPeriodog_fx;
- Word32 *msNoiseEst_fx = hFdCngEnc->msNoiseEst_fx;
+ Word32 *msNoiseEst_fx = hFdCngEnc->msNoiseEst_fx; /* exp(msNoiseEst_fx_exp) */
Word16 *msLogPeriodog_fx = hFdCngEnc->msLogPeriodog_fx;
Word16 *msLogNoiseEst_fx = hFdCngEnc->msLogNoiseEst_fx;
@@ -170,7 +170,7 @@ void perform_noise_estimation_enc_ivas_fx(
/* 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 );
+ *ptr_per_fx = Mpy_32_32( enerBuffer[j], scaleEB_fx ); /* exp(enerBuffer_exp) */
move32();
ptr_per_fx++;
@@ -181,7 +181,7 @@ void perform_noise_estimation_enc_ivas_fx(
hFdCngEnc->hFdCngCom->exp_cldfb_periodog = add( sub( enerBuffer_exp, 4 ), CLDFBscalingFactor_EXP );
move16();
- numBands = sub( regularStopBand, numCoreBands );
+ numBands = sub( regularStopBand, numCoreBands ); /* Q0 */
IF( numBands > 0 )
{
@@ -211,13 +211,13 @@ void perform_noise_estimation_enc_ivas_fx(
FOR( i = 0; i < nFFTpart; i++ )
{
- msPeriodog_fx[i] = L_shr( msPeriodog_fx[i], s1 );
+ msPeriodog_fx[i] = L_shr( msPeriodog_fx[i], s1 ); /* hFdCngEnc->msPeriodog_fx_exp_fft */
move32();
}
FOR( i = 0; i < nCLDFBpart; i++ )
{
- msPeriodog_fx[nFFTpart + i] = L_shr( msPeriodog_fx[nFFTpart + i], s_min( 31, s2 ) );
+ msPeriodog_fx[nFFTpart + i] = L_shr( msPeriodog_fx[nFFTpart + i], s_min( 31, s2 ) ); /* hFdCngEnc->msPeriodog_fx_exp_fft */
move32();
}
}
@@ -425,14 +425,14 @@ void FdCng_encodeSID_ivas_fx(
/* NB last band energy compensation */
IF( hFdCngCom->CngBandwidth == NB )
{
- hFdCngCom->sidNoiseEst[N - 1] = Mpy_32_16_1( hFdCngCom->sidNoiseEst[N - 1], NB_LAST_BAND_SCALE );
+ hFdCngCom->sidNoiseEst[N - 1] = Mpy_32_16_1( hFdCngCom->sidNoiseEst[N - 1], NB_LAST_BAND_SCALE ); // exp(hFdCngCom->sidNoiseEstExp)
move32();
}
test();
IF( EQ_16( hFdCngCom->CngBandwidth, SWB ) && LE_32( hFdCngCom->CngBitrate, ACELP_13k20 ) )
{
- hFdCngCom->sidNoiseEst[N - 1] = Mpy_32_16_1( hFdCngCom->sidNoiseEst[N - 1], SWB_13k2_LAST_BAND_SCALE );
+ hFdCngCom->sidNoiseEst[N - 1] = Mpy_32_16_1( hFdCngCom->sidNoiseEst[N - 1], SWB_13k2_LAST_BAND_SCALE ); // exp(hFdCngCom->sidNoiseEstExp)
move32();
}
@@ -485,7 +485,7 @@ void FdCng_encodeSID_ivas_fx(
*-------------------------------------------------------------------*/
void stereoFdCngCoherence_fx(
Encoder_State **sts, /* i/o: core encoder structures */
- const Word16 last_element_mode, /* i : last element mode */
+ const Word16 last_element_mode, /* i : last element mode Q0*/
Word16 fft_buf_fx[CPE_CHANNELS][2 * L_FFT], /* i : fft buffers for L and R channels fft_exp*/
Word16 fft_exp )
{
@@ -508,9 +508,9 @@ void stereoFdCngCoherence_fx(
/* case: at least one channel has triggered VAD -> ACTIVE FRAME */
IF( EQ_32( sts[0]->core_brate, -1 ) )
{
- sts[1]->total_brate = sts[0]->total_brate;
+ sts[1]->total_brate = sts[0]->total_brate; /* Q0 */
move32();
- sts[1]->active_cnt = sts[0]->active_cnt;
+ sts[1]->active_cnt = sts[0]->active_cnt; /* Q0 */
move16();
if ( GE_32( sts[1]->active_cnt, CNG_TYPE_HO ) )
{
@@ -520,9 +520,9 @@ void stereoFdCngCoherence_fx(
}
IF( EQ_32( sts[1]->core_brate, -1 ) )
{
- sts[0]->total_brate = sts[1]->total_brate;
+ sts[0]->total_brate = sts[1]->total_brate; /* Q0 */
move32();
- sts[0]->active_cnt = sts[1]->active_cnt;
+ sts[0]->active_cnt = sts[1]->active_cnt; /* Q0 */
move16();
if ( GE_16( sts[0]->active_cnt, CNG_TYPE_HO ) )
{
@@ -556,15 +556,15 @@ void stereoFdCngCoherence_fx(
}
/* synchronize SID counters */
- sts[0]->hDtxEnc->cnt_SID = s_min( sts[0]->hDtxEnc->cnt_SID, sts[1]->hDtxEnc->cnt_SID );
- sts[1]->hDtxEnc->cnt_SID = sts[0]->hDtxEnc->cnt_SID;
+ sts[0]->hDtxEnc->cnt_SID = s_min( sts[0]->hDtxEnc->cnt_SID, sts[1]->hDtxEnc->cnt_SID ); /* Q0 */
+ sts[1]->hDtxEnc->cnt_SID = sts[0]->hDtxEnc->cnt_SID; /* Q0 */
move16();
move16();
}
pt_fftL = fft_buf_fx[0];
pt_fftR = fft_buf_fx[1];
- mem = sts[0]->hFdCngEnc->mem_coherence_fx;
+ mem = sts[0]->hFdCngEnc->mem_coherence_fx; /* exp(sts[0]->hFdCngEnc->mem_coherence_exp) */
mem_exp = sts[0]->hFdCngEnc->mem_coherence_exp;
FOR( i_subfr = 0; i_subfr < 2; i_subfr++ )
{
@@ -579,28 +579,28 @@ void stereoFdCngCoherence_fx(
move16();
move16();
- cr = BASOP_Util_Add_Mant32Exp( cr, cr_exp, L_add( L_mult( pt_fftL[0], pt_fftR[0] ), L_mult( pt_fftL[L_FFT / 2], pt_fftR[L_FFT / 2] ) ), shl( fft_exp, 1 ), &cr_exp );
- eL = BASOP_Util_Add_Mant32Exp( eL, eL_exp, L_add( L_mult( pt_fftL[0], pt_fftL[0] ), L_mult( pt_fftL[L_FFT / 2], pt_fftL[L_FFT / 2] ) ), shl( fft_exp, 1 ), &eL_exp );
- eR = BASOP_Util_Add_Mant32Exp( eR, eR_exp, L_add( L_mult( pt_fftR[0], pt_fftR[0] ), L_mult( pt_fftR[L_FFT / 2], pt_fftR[L_FFT / 2] ) ), shl( fft_exp, 1 ), &eR_exp );
+ cr = BASOP_Util_Add_Mant32Exp( cr, cr_exp, L_add( L_mult( pt_fftL[0], pt_fftR[0] ), L_mult( pt_fftL[L_FFT / 2], pt_fftR[L_FFT / 2] ) ), shl( fft_exp, 1 ), &cr_exp ); /* exp(cr_exp) */
+ eL = BASOP_Util_Add_Mant32Exp( eL, eL_exp, L_add( L_mult( pt_fftL[0], pt_fftL[0] ), L_mult( pt_fftL[L_FFT / 2], pt_fftL[L_FFT / 2] ) ), shl( fft_exp, 1 ), &eL_exp ); /* exp(eL_exp) */
+ eR = BASOP_Util_Add_Mant32Exp( eR, eR_exp, L_add( L_mult( pt_fftR[0], pt_fftR[0] ), L_mult( pt_fftR[L_FFT / 2], pt_fftR[L_FFT / 2] ) ), shl( fft_exp, 1 ), &eR_exp ); /* exp(eR_exp) */
FOR( i = 1; i < L_FFT / 2; i++ )
{
- cr = BASOP_Util_Add_Mant32Exp( cr, cr_exp, L_add( L_mult( pt_fftL[i], pt_fftR[i] ), L_mult( pt_fftL[L_FFT - i], pt_fftR[L_FFT - i] ) ), shl( fft_exp, 1 ), &cr_exp );
- ci = BASOP_Util_Add_Mant32Exp( ci, ci_exp, L_add( L_mult( -pt_fftL[i], pt_fftR[L_FFT - i] ), L_mult( pt_fftL[L_FFT - i], pt_fftR[i] ) ), shl( fft_exp, 1 ), &ci_exp );
- eL = BASOP_Util_Add_Mant32Exp( eL, eL_exp, L_add( L_mult( pt_fftL[i], pt_fftL[i] ), L_mult( pt_fftL[L_FFT - i], pt_fftL[L_FFT - i] ) ), shl( fft_exp, 1 ), &eL_exp );
- eR = BASOP_Util_Add_Mant32Exp( eR, eR_exp, L_add( L_mult( pt_fftR[i], pt_fftR[i] ), L_mult( pt_fftR[L_FFT - i], pt_fftR[L_FFT - i] ) ), shl( fft_exp, 1 ), &eR_exp );
+ cr = BASOP_Util_Add_Mant32Exp( cr, cr_exp, L_add( L_mult( pt_fftL[i], pt_fftR[i] ), L_mult( pt_fftL[L_FFT - i], pt_fftR[L_FFT - i] ) ), shl( fft_exp, 1 ), &cr_exp ); /* exp(cr_exp) */
+ ci = BASOP_Util_Add_Mant32Exp( ci, ci_exp, L_add( L_mult( -pt_fftL[i], pt_fftR[L_FFT - i] ), L_mult( pt_fftL[L_FFT - i], pt_fftR[i] ) ), shl( fft_exp, 1 ), &ci_exp ); /* exp(ci_exp) */
+ eL = BASOP_Util_Add_Mant32Exp( eL, eL_exp, L_add( L_mult( pt_fftL[i], pt_fftL[i] ), L_mult( pt_fftL[L_FFT - i], pt_fftL[L_FFT - i] ) ), shl( fft_exp, 1 ), &eL_exp ); /* exp(eL_exp) */
+ eR = BASOP_Util_Add_Mant32Exp( eR, eR_exp, L_add( L_mult( pt_fftR[i], pt_fftR[i] ), L_mult( pt_fftR[L_FFT - i], pt_fftR[L_FFT - i] ) ), shl( fft_exp, 1 ), &eR_exp ); /* exp(eR_exp) */
}
test();
test();
IF( LE_32( sts[0]->ini_frame, 50 ) || ( sts[0]->vad_flag == 0 && sts[1]->vad_flag == 0 ) )
{
- mem[0] = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( mem[0], 31129 /*0.95f*/ ), mem_exp[0], Mpy_32_16_1( cr, 1638 /*0.05f*/ ), cr_exp, &mem_exp[0] );
+ mem[0] = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( mem[0], 31129 /*0.95f*/ ), mem_exp[0], Mpy_32_16_1( cr, 1638 /*0.05f*/ ), cr_exp, &mem_exp[0] ); /* exp(mem_exp[0]) */
move32();
- mem[1] = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( mem[1], 31129 /*0.95f*/ ), mem_exp[1], Mpy_32_16_1( ci, 1638 /*0.05f*/ ), ci_exp, &mem_exp[1] );
+ mem[1] = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( mem[1], 31129 /*0.95f*/ ), mem_exp[1], Mpy_32_16_1( ci, 1638 /*0.05f*/ ), ci_exp, &mem_exp[1] ); /* exp(mem_exp[1]) */
move32();
- mem[2] = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( mem[2], 31129 /*0.95f*/ ), mem_exp[2], Mpy_32_16_1( eL, 1638 /*0.05f*/ ), eL_exp, &mem_exp[2] );
+ mem[2] = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( mem[2], 31129 /*0.95f*/ ), mem_exp[2], Mpy_32_16_1( eL, 1638 /*0.05f*/ ), eL_exp, &mem_exp[2] ); /* exp(mem_exp[2]) */
move32();
- mem[3] = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( mem[3], 31129 /*0.95f*/ ), mem_exp[3], Mpy_32_16_1( eR, 1638 /*0.05f*/ ), eR_exp, &mem_exp[3] );
+ mem[3] = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( mem[3], 31129 /*0.95f*/ ), mem_exp[3], Mpy_32_16_1( eR, 1638 /*0.05f*/ ), eR_exp, &mem_exp[3] ); /* exp(mem_exp[3]) */
move32();
}
@@ -609,7 +609,7 @@ void stereoFdCngCoherence_fx(
}
Word16 sqr_inp, temp, sqr_out, sqr_inp_exp;
- Word32 sqr_inp32 = BASOP_Util_Add_Mant32Exp( Mpy_32_32( mem[0], mem[0] ), shl( mem_exp[0], 1 ), Mpy_32_32( mem[1], mem[1] ), shl( mem_exp[1], 1 ), &sqr_inp_exp );
+ Word32 sqr_inp32 = BASOP_Util_Add_Mant32Exp( Mpy_32_32( mem[0], mem[0] ), shl( mem_exp[0], 1 ), Mpy_32_32( mem[1], mem[1] ), shl( mem_exp[1], 1 ), &sqr_inp_exp ); /* exp(sqr_inp_exp) */
sqr_inp = BASOP_Util_Divide3232_Scale( sqr_inp32, Mpy_32_32( mem[2], mem[3] ), &temp );
sqr_inp_exp = add( temp, sub( sqr_inp_exp, add( mem_exp[2], mem_exp[3] ) ) );
sqr_out = Sqrt16( sqr_inp, &sqr_inp_exp );
@@ -666,13 +666,13 @@ void FdCngEncodeMDCTStereoSID_fx(
FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
{
sts[ch] = hCPE->hCoreCoder[ch];
- lr_in_ptr_fx[ch] = &sts[ch]->hFdCngEnc->msNoiseEst_fx[0];
+ lr_in_ptr_fx[ch] = &sts[ch]->hFdCngEnc->msNoiseEst_fx[0]; /* exp(sts[ch]->hFdCngEnc->msNoiseEst_fx_exp) */
lr_in_ptr_e[ch] = sts[ch]->hFdCngEnc->msNoiseEst_fx_exp;
ms_ptr_fx[ch] = &logNoiseEst_fx[ch][0];
- lr_out_ptr_fx[ch] = &sts[ch]->hFdCngEnc->hFdCngCom->sidNoiseEst[0];
+ lr_out_ptr_fx[ch] = &sts[ch]->hFdCngEnc->hFdCngCom->sidNoiseEst[0]; /* exp(sts[ch]->hFdCngEnc->hFdCngCom->sidNoiseEstExp) */
lr_out_ptr_e[ch] = sts[ch]->hFdCngEnc->hFdCngCom->sidNoiseEstExp;
}
- N = sts[0]->hFdCngEnc->npartDec;
+ N = sts[0]->hFdCngEnc->npartDec; /* Q0 */
move16();
set16_fx( weights_fx, ONE_IN_Q8, NPART );
@@ -733,14 +733,14 @@ void FdCngEncodeMDCTStereoSID_fx(
move32();
FOR( p = N_GAIN_MIN; p < N_GAIN_MAX; p++ )
{
- tmp32 = Mpy_32_32( ms_ptr_fx[ch][p], 165191050 ); // Q23
- gain_fx[ch] = L_add( gain_fx[ch], tmp32 ); // Q23
+ tmp32 = Mpy_32_32( ms_ptr_fx[ch][p], 165191050 /* 0.07 in Q31*/ ); // Q23
+ gain_fx[ch] = L_add( gain_fx[ch], tmp32 ); // Q23
move32();
}
FOR( p = 0; p < N; p++ )
{
- ms_ptr_fx[ch][p] = L_sub( ms_ptr_fx[ch][p], gain_fx[ch] );
+ ms_ptr_fx[ch][p] = L_sub( ms_ptr_fx[ch][p], gain_fx[ch] ); // Q23
move32();
}
}
@@ -823,7 +823,7 @@ void FdCngEncodeMDCTStereoSID_fx(
tmp = Inv16( N, &tmp_e );
FOR( p = 0; p < N; p++ )
{
- gain_fx[ch] = L_add( gain_fx[ch], Mpy_32_16_1( ms_ptr_fx[ch][p], shl( tmp, tmp_e ) ) );
+ gain_fx[ch] = L_add( gain_fx[ch], Mpy_32_16_1( ms_ptr_fx[ch][p], shl( tmp, tmp_e ) ) ); // Q23
move32();
}
gain_fx[ch] = L_sub( L_shl( Mpy_32_16_1( E_fx[ch], shl( tmp, tmp_e ) ), Q23 - Q19 ), L_shl( gain_fx[ch], sub( ms_ptr_e, 8 ) ) ); // Q23
@@ -832,7 +832,7 @@ void FdCngEncodeMDCTStereoSID_fx(
apply_scale( &gain_fx[ch], sts[ch]->hFdCngEnc->hFdCngCom->CngBandwidth, sts[ch]->element_brate, scaleTableStereo, SIZE_SCALE_TABLE_STEREO );
/* quantize gain */
- gain_idx[ch] = (Word16) Mpy_32_32_r( L_add( gain_fx[ch], 251658240 ), 384 );
+ gain_idx[ch] = (Word16) Mpy_32_32_r( L_add( gain_fx[ch], 251658240 ), 384 ); // Q23
move16();
gain_idx[ch] = s_max( 0, s_min( 127, gain_idx[ch] ) );
move16();
@@ -1008,14 +1008,14 @@ void FdCngEncodeDiracMDCTStereoSID_fx(
move16();
FOR( p = N_GAIN_MIN; p < N_GAIN_MAX; p++ )
{
- tmp32 = Mpy_32_32( ms_ptr_fx[0][p], 165191050 ); // Q23
- gain_fx[0] = L_add( gain_fx[0], tmp32 ); // Q23
+ tmp32 = Mpy_32_32( ms_ptr_fx[0][p], 165191050 /* 0.07 in Q31 */ ); // Q23
+ gain_fx[0] = L_add( gain_fx[0], tmp32 ); // Q23
move32();
}
FOR( p = 0; p < N[0]; p++ )
{
- ms_ptr_fx[0][p] = L_sub( ms_ptr_fx[0][p], gain_fx[0] );
+ ms_ptr_fx[0][p] = L_sub( ms_ptr_fx[0][p], gain_fx[0] ); // Q23
move32();
}
@@ -1035,7 +1035,7 @@ void FdCngEncodeDiracMDCTStereoSID_fx(
extend_dctN_input_fx( ms_ptr_fx[0], dct_target_fx, N[0], tot_sig_ext_fx, FDCNG_VQ_MAX_LEN, invTrfMatrix_fx, FDCNG_VQ_DCT_MAXTRUNC, IDCT_T2_XX_21 ); /* use 18 basis vectors*/
- Copy32( tot_sig_ext_fx, ms_ptr_fx[0], FDCNG_VQ_MAX_LEN ); /* write extended result as input to VQ stage #1 */
+ Copy32( tot_sig_ext_fx, ms_ptr_fx[0], FDCNG_VQ_MAX_LEN ); /* write extended result as input to VQ stage #1 Q23*/
}
create_IDCT_N_Matrix_fx( invTrfMatrix_fx, FDCNG_VQ_MAX_LEN, FDCNG_VQ_DCT_MAXTRUNC, sizeof( tmpRAM_fx ) / ( sizeof( Word32 ) ) );
@@ -1043,7 +1043,7 @@ void FdCngEncodeDiracMDCTStereoSID_fx(
msvq_dec_fx( ivas_cdk_37bits_fx, NULL, NULL, FD_CNG_stages_37bits, N[0], FD_CNG_maxN_37bits, indices[0], 1, invTrfMatrix_fx, ms_ptr_fx[0], NULL, 7 );
shift = find_guarded_bits_fx( N[0] );
ms_ptr_e = sub( 31, sub( 20, shift ) );
- scale_sig32( ms_ptr_fx[1], N[1], sub( 8, ms_ptr_e ) );
+ scale_sig32( ms_ptr_fx[1], N[1], sub( 8, ms_ptr_e ) ); /* Q31 - ms_ptr_e */
/* set S to zero */
set32_fx( ms_ptr_fx[1], 0, NPART );
@@ -1056,7 +1056,7 @@ void FdCngEncodeDiracMDCTStereoSID_fx(
tmp = Inv16( N[0], &tmp_e );
FOR( p = 0; p < N[0]; p++ )
{
- gain_fx[0] = L_add( gain_fx[0], Mpy_32_16_1( ms_ptr_fx[0][p], shl( tmp, tmp_e ) ) );
+ gain_fx[0] = L_add( gain_fx[0], Mpy_32_16_1( ms_ptr_fx[0][p], shl( tmp, tmp_e ) ) ); // Q23
move32();
}
gain_fx[0] = L_sub( L_shl( Mpy_32_16_1( E_fx[0], shl( tmp, tmp_e ) ), Q23 - Q18 ), L_shl( gain_fx[0], ms_ptr_e - 8 ) ); // Q23
@@ -1070,7 +1070,7 @@ void FdCngEncodeDiracMDCTStereoSID_fx(
gain_idx[0] = s_max( 0, s_min( 127, gain_idx[0] ) );
move16();
- gain_fx[0] = Mpy_32_16_1( L_shl( sub( gain_idx[0], GAIN_Q_OFFSET_IVAS_FX_Q0 ), 23 ), 21845 ); // Q23
+ gain_fx[0] = Mpy_32_16_1( L_shl( sub( gain_idx[0], GAIN_Q_OFFSET_IVAS_FX_Q0 ), 23 ), 21845 /* 0.66 in Q15 */ ); // Q23
move32();
gain_fx[1] = gain_fx[0]; // Q23
move32();
@@ -1089,9 +1089,9 @@ void FdCngEncodeDiracMDCTStereoSID_fx(
tmp_e = -MAX_16;
FOR( p = 0; p < N[ch]; p++ )
{
- pow = L_shl( gain_fx[ch], sub( 8, ms_ptr_e ) );
- pow = L_add( ms_ptr_fx[ch][p], pow );
- pow = Mpy_32_32( pow, 214748365 ); /*pow = 0.1*/
+ pow = L_shl( gain_fx[ch], sub( 8, ms_ptr_e ) ); /* Q31 - ms_ptr_e */
+ pow = L_add( ms_ptr_fx[ch][p], pow ); /* Q31 - ms_ptr_e */
+ pow = Mpy_32_32( pow, 214748365 /* 0.1 in Q31 */ ); /*pow = 0.1 Q31 - ms_ptr_e*/
lr_out_ptr_fx[ch][p] = BASOP_Util_fPow( 10, 31, pow, ms_ptr_e, &e_lr_out[p] );
tmp_e = s_max( tmp_e, e_lr_out[p] );
}
@@ -1109,12 +1109,12 @@ void FdCngEncodeDiracMDCTStereoSID_fx(
/* NB last band energy compensation */
IF( hFdCngCom->CngBandwidth == NB )
{
- lr_out_ptr_fx[ch][N[ch] - 1] = Mpy_32_16_1( lr_out_ptr_fx[ch][N[ch] - 1], NB_LAST_BAND_SCALE );
+ lr_out_ptr_fx[ch][N[ch] - 1] = Mpy_32_16_1( lr_out_ptr_fx[ch][N[ch] - 1], NB_LAST_BAND_SCALE ); // Q(31 - tmp_e)
move32();
}
ELSE IF( hFdCngCom->CngBandwidth == SWB && LE_32( hFdCngCom->CngBitrate, ACELP_13k20 ) )
{
- lr_out_ptr_fx[ch][N[ch] - 1] = Mpy_32_16_1( lr_out_ptr_fx[ch][N[ch] - 1], SWB_13k2_LAST_BAND_SCALE );
+ lr_out_ptr_fx[ch][N[ch] - 1] = Mpy_32_16_1( lr_out_ptr_fx[ch][N[ch] - 1], SWB_13k2_LAST_BAND_SCALE ); // Q(31 - tmp_e)
move32();
}
/* scale bands and get scalefactors */
diff --git a/lib_enc/fd_cng_enc_fx.c b/lib_enc/fd_cng_enc_fx.c
index 34b67b2ff575ffc52bfd6e7505d1a74921c26d89..d5be64f77daaf026dd2c967b1a30830764634c6f 100644
--- a/lib_enc/fd_cng_enc_fx.c
+++ b/lib_enc/fd_cng_enc_fx.c
@@ -51,7 +51,10 @@ void createFdCngEnc_fx( HANDLE_FD_CNG_ENC *hFdCngEnc )
return;
}
-void initFdCngEnc_fx( HANDLE_FD_CNG_ENC hsEnc, Word32 input_Fs, Word16 scale )
+void initFdCngEnc_fx(
+ HANDLE_FD_CNG_ENC hsEnc,
+ Word32 input_Fs, /* Q0 */
+ Word16 scale )
{
Word16 j;
HANDLE_FD_CNG_COM hsCom = hsEnc->hFdCngCom;
@@ -65,7 +68,7 @@ void initFdCngEnc_fx( HANDLE_FD_CNG_ENC hsEnc, Word32 input_Fs, Word16 scale )
move16();
hsCom->numCoreBands = 16;
move16();
- hsCom->regularStopBand = idiv1616U( extract_l( L_shr( input_Fs, 5 ) ), 25 );
+ hsCom->regularStopBand = idiv1616U( extract_l( L_shr( input_Fs, 5 ) ), 25 ); /* Q0 */
move16();
if ( GT_16( hsCom->regularStopBand, 40 ) )
{
@@ -88,7 +91,7 @@ void initFdCngEnc_fx( HANDLE_FD_CNG_ENC hsEnc, Word32 input_Fs, Word16 scale )
{
hsCom->stopFFTbin = 256;
move16();
- hsCom->stopBand = add( sub( hsCom->regularStopBand, hsCom->numCoreBands ), hsCom->stopFFTbin );
+ hsCom->stopBand = add( sub( hsCom->regularStopBand, hsCom->numCoreBands ), hsCom->stopFFTbin ); /* Q0 */
move16();
hsCom->nFFTpart = 20;
move16();
@@ -96,12 +99,12 @@ void initFdCngEnc_fx( HANDLE_FD_CNG_ENC hsEnc, Word32 input_Fs, Word16 scale )
initPartitions( sidparts_encoder_noise_est, SIZE_SIDPARTS_ENC_NOISE_EST, hsCom->startBand, hsCom->stopBand, hsCom->part, &hsCom->npart, hsCom->midband, hsCom->psize, hsCom->psize_norm, &hsCom->psize_norm_exp, hsCom->psize_inv, 0 );
- hsCom->nCLDFBpart = sub( hsCom->npart, hsCom->nFFTpart );
+ hsCom->nCLDFBpart = sub( hsCom->npart, hsCom->nFFTpart ); /* Q0 */
move16();
FOR( j = 0; j < hsCom->nCLDFBpart; j++ )
{
- hsCom->CLDFBpart[j] = sub( hsCom->part[j + hsCom->nFFTpart], sub( 256, hsCom->startBand ) );
- hsCom->CLDFBpsize_inv[j] = hsCom->psize_inv[j + hsCom->nFFTpart];
+ hsCom->CLDFBpart[j] = sub( hsCom->part[j + hsCom->nFFTpart], sub( 256, hsCom->startBand ) ); /* Q0 */
+ hsCom->CLDFBpsize_inv[j] = hsCom->psize_inv[j + hsCom->nFFTpart]; /* Q15 */
move16();
move16();
}
@@ -151,8 +154,9 @@ void initFdCngEnc_fx( HANDLE_FD_CNG_ENC hsEnc, Word32 input_Fs, Word16 scale )
* Configure FD_CNG *
************************************/
void configureFdCngEnc_fx( HANDLE_FD_CNG_ENC hsEnc, /* i/o: Contains the variables related to the FD-based CNG process */
- Word16 bandwidth, /* i: bandwidth */
- Word32 bitrate )
+ Word16 bandwidth, /* i: bandwidth Q0*/
+ Word32 bitrate /* Q0 */
+)
{
HANDLE_FD_CNG_COM hsCom = hsEnc->hFdCngCom;
Word16 psizeDec[NPART];
@@ -169,7 +173,7 @@ void configureFdCngEnc_fx( HANDLE_FD_CNG_ENC hsEnc, /* i/o: Contains the variabl
hsCom->CngBandwidth = SWB;
move16();
}
- hsCom->CngBitrate = bitrate;
+ hsCom->CngBitrate = bitrate; /* Q0 */
move32();
/* NB configuration */
@@ -212,16 +216,16 @@ void configureFdCngEnc_fx( HANDLE_FD_CNG_ENC hsEnc, /* i/o: Contains the variabl
hsCom->FdCngSetup = FdCngSetup_swb2;
}
}
- hsCom->fftlen = hsCom->FdCngSetup.fftlen;
+ hsCom->fftlen = hsCom->FdCngSetup.fftlen; /* Q0 */
move16();
- hsEnc->stopFFTbinDec = hsCom->FdCngSetup.stopFFTbin;
+ hsEnc->stopFFTbinDec = hsCom->FdCngSetup.stopFFTbin; /* Q0 */
move16();
/* Configure the SID quantizer and the Confort Noise Generator */
- hsEnc->startBandDec = hsCom->startBand;
+ hsEnc->startBandDec = hsCom->startBand; /* Q0 */
move16();
- hsEnc->stopBandDec = add( hsCom->FdCngSetup.sidPartitions[hsCom->FdCngSetup.numPartitions - 1], 1 );
+ hsEnc->stopBandDec = add( hsCom->FdCngSetup.sidPartitions[hsCom->FdCngSetup.numPartitions - 1], 1 ); /* Q0 */
move16();
initPartitions( hsCom->FdCngSetup.sidPartitions,
hsCom->FdCngSetup.numPartitions,
@@ -277,8 +281,9 @@ void configureFdCngEnc_fx( HANDLE_FD_CNG_ENC hsEnc, /* i/o: Contains the variabl
void configureFdCngEnc_ivas_fx(
HANDLE_FD_CNG_ENC hFdCngEnc, /* i/o: Contains the variables related to the FD-based CNG process */
- const Word16 bwidth,
- const Word32 total_brate )
+ const Word16 bwidth, /* Q0 */
+ const Word32 total_brate /* Q0 */
+)
{
HANDLE_FD_CNG_COM hsCom = hFdCngEnc->hFdCngCom;
Word16 psizeDec[NPART];
@@ -288,14 +293,14 @@ void configureFdCngEnc_ivas_fx(
set16_fx( psizeDec, 0, NPART );
- hsCom->CngBandwidth = bwidth;
+ hsCom->CngBandwidth = bwidth; /* Q0 */
move16();
IF( EQ_16( hsCom->CngBandwidth, FB ) )
{
hsCom->CngBandwidth = SWB;
move16();
}
- hsCom->CngBitrate = total_brate;
+ hsCom->CngBitrate = total_brate; /* Q0 */
move32();
/* NB configuration */
@@ -338,16 +343,16 @@ void configureFdCngEnc_ivas_fx(
hsCom->FdCngSetup = FdCngSetup_swb2;
}
}
- hsCom->fftlen = hsCom->FdCngSetup.fftlen;
+ hsCom->fftlen = hsCom->FdCngSetup.fftlen; /* Q0 */
move16();
- hFdCngEnc->stopFFTbinDec = hsCom->FdCngSetup.stopFFTbin;
+ hFdCngEnc->stopFFTbinDec = hsCom->FdCngSetup.stopFFTbin; /* Q0 */
move16();
/* Configure the SID quantizer and the Confort Noise Generator */
- hFdCngEnc->startBandDec = hsCom->startBand;
+ hFdCngEnc->startBandDec = hsCom->startBand; /* Q0 */
move16();
- hFdCngEnc->stopBandDec = add( hsCom->FdCngSetup.sidPartitions[hsCom->FdCngSetup.numPartitions - 1], 1 );
+ hFdCngEnc->stopBandDec = add( hsCom->FdCngSetup.sidPartitions[hsCom->FdCngSetup.numPartitions - 1], 1 ); /* Q0 */
move16();
initPartitions( hsCom->FdCngSetup.sidPartitions,
hsCom->FdCngSetup.numPartitions,
@@ -381,17 +386,17 @@ void configureFdCngEnc_ivas_fx(
{
case 512:
hsCom->fftSineTab_fx = NULL;
- hsCom->olapWinAna_fx = olapWinAna512_fx;
- hsCom->olapWinSyn_fx = olapWinSyn256_fx;
+ hsCom->olapWinAna_fx = olapWinAna512_fx; /* Q30 */
+ hsCom->olapWinSyn_fx = olapWinSyn256_fx; /* Q15 */
hsCom->fftlenShift = 8;
move16();
hsCom->fftlenFac = 32767 /*1.0 Q15*/;
move16();
BREAK;
case 640:
- hsCom->fftSineTab_fx = fftSineTab640_fx;
- hsCom->olapWinAna_fx = olapWinAna640_fx;
- hsCom->olapWinSyn_fx = olapWinSyn320_fx;
+ hsCom->fftSineTab_fx = fftSineTab640_fx; /* Q15 */
+ hsCom->olapWinAna_fx = olapWinAna640_fx; /* Q30 */
+ hsCom->olapWinSyn_fx = olapWinSyn320_fx; /* Q15 */
hsCom->fftlenShift = 9;
move16();
hsCom->fftlenFac = 20480 /*0.625 Q15*/;
@@ -440,8 +445,8 @@ void resetFdCngEnc_fx(
/* st->totalNoise_fx; Q8 Noise estimator - total noise energy */
/* Detect fast increase of totalNoise */
- totalNoiseIncrease = sub( hNoiseEst->totalNoise_fx, st->last_totalNoise_fx );
- st->last_totalNoise_fx = hNoiseEst->totalNoise_fx;
+ totalNoiseIncrease = sub( hNoiseEst->totalNoise_fx, st->last_totalNoise_fx ); // Q8
+ st->last_totalNoise_fx = hNoiseEst->totalNoise_fx; // Q8
move16();
IF( totalNoiseIncrease > 0 )
{
@@ -449,17 +454,17 @@ void resetFdCngEnc_fx(
{
FOR( n = 0; n < TOTALNOISE_HIST_SIZE - 1; n++ )
{
- st->totalNoise_increase_hist_fx[n] = st->totalNoise_increase_hist_fx[n + 1];
+ st->totalNoise_increase_hist_fx[n] = st->totalNoise_increase_hist_fx[n + 1]; // Q8
move16();
}
- st->totalNoise_increase_hist_fx[TOTALNOISE_HIST_SIZE - 1] = totalNoiseIncrease;
+ st->totalNoise_increase_hist_fx[TOTALNOISE_HIST_SIZE - 1] = totalNoiseIncrease; // Q8
move16();
}
ELSE
{
- st->totalNoise_increase_hist_fx[st->totalNoise_increase_len] = totalNoiseIncrease;
+ st->totalNoise_increase_hist_fx[st->totalNoise_increase_len] = totalNoiseIncrease; // Q8
move16();
- st->totalNoise_increase_len = add( st->totalNoise_increase_len, 1 );
+ st->totalNoise_increase_len = add( st->totalNoise_increase_len, 1 ); // Q0
}
}
ELSE
@@ -471,7 +476,7 @@ void resetFdCngEnc_fx(
move16();
FOR( n = 0; n < st->totalNoise_increase_len; n++ )
{
- totalNoiseIncrease = add( totalNoiseIncrease, st->totalNoise_increase_hist_fx[n] );
+ totalNoiseIncrease = add( totalNoiseIncrease, st->totalNoise_increase_hist_fx[n] ); // Q8
}
test();
@@ -518,9 +523,9 @@ void resetFdCngEnc_fx(
Returns:
void
*/
-void perform_noise_estimation_enc_fx( Word32 *band_energies, /* i: energy in critical bands without minimum noise floor MODE2_E_MIN */
+void perform_noise_estimation_enc_fx( Word32 *band_energies, /* i: energy in critical bands without minimum noise floor MODE2_E_MIN band_energies_exp*/
Word16 band_energies_exp, /* i: exponent for energy in critical bands without minimum noise floor MODE2_E_MIN */
- Word32 *enerBuffer,
+ Word32 *enerBuffer, /* enerBuffer_exp */
Word16 enerBuffer_exp,
HANDLE_FD_CNG_ENC st /* i/o: FD_CNG structure containing all buffers and variables */
)
@@ -560,8 +565,8 @@ void perform_noise_estimation_enc_fx( Word32 *band_energies, /* i: energy in
/* preemphasis compensation and grouping of per bin energies into msPeriodog */
FOR( i = 0; i < nFFTpart; i++ )
{
- tmp = L_add( L_shr( band_energies[i], 1 ), L_shr( band_energies[i + NB_BANDS], 1 ) );
- msPeriodog[i] = Mpy_32_16_1( tmp, preemphCompensation_fx[i] );
+ tmp = L_add( L_shr( band_energies[i], 1 ), L_shr( band_energies[i + NB_BANDS], 1 ) ); /* exp(band_energies_exp) */
+ msPeriodog[i] = Mpy_32_16_1( tmp, preemphCompensation_fx[i] ); /* exp(band_energies_exp + 4) */
move32();
}
@@ -569,7 +574,7 @@ void perform_noise_estimation_enc_fx( Word32 *band_energies, /* i: energy in
st->msPeriodog_fx_exp_fft = add( band_energies_exp, PREEMPH_COMPENSATION_EXP );
move16();
- numBands = sub( regularStopBand, numCoreBands );
+ numBands = sub( regularStopBand, numCoreBands ); /* Q0 */
IF( numBands > 0 )
{
@@ -577,7 +582,7 @@ void perform_noise_estimation_enc_fx( Word32 *band_energies, /* i: energy in
FOR( j = numCoreBands; j < regularStopBand; j++ )
{
- *ptr_per = Mpy_32_16_1( enerBuffer[j], st->hFdCngCom->scalingFactor );
+ *ptr_per = Mpy_32_16_1( enerBuffer[j], st->hFdCngCom->scalingFactor ); /* exp(enerBuffer_exp) */
move32();
ptr_per++;
@@ -612,13 +617,13 @@ void perform_noise_estimation_enc_fx( Word32 *band_energies, /* i: energy in
FOR( i = 0; i < nFFTpart; i++ )
{
- msPeriodog[i] = L_shr( msPeriodog[i], s1 );
+ msPeriodog[i] = L_shr( msPeriodog[i], s1 ); // st->msPeriodog_fx_exp_fft
move32();
}
FOR( i = 0; i < nCLDFBpart; i++ )
{
- msPeriodog[nFFTpart + i] = L_shr( msPeriodog[nFFTpart + i], s_min( 31, s2 ) );
+ msPeriodog[nFFTpart + i] = L_shr( msPeriodog[nFFTpart + i], s_min( 31, s2 ) ); // st->msPeriodog_fx_exp_fft
move32();
}
}
@@ -681,19 +686,18 @@ void perform_noise_estimation_enc_fx( Word32 *band_energies, /* i: energy in
Returns:
void
*/
-Word16
-AdjustFirstSID_fx(
- Word16 npart, /* i : number of parts */
- Word32 *msPeriodog, /* i : pointer to periodog vector */
- Word16 msPeriodog_exp, /* i : exponent of periodog vector */
- Word32 *energy_ho, /* i/o : pointer to energy */
- Word16 *energy_ho_exp, /* i/o : pointer to exponent of energy */
- Word32 *msNoiseEst, /* i/o : pointer to estimated noise */
- Word16 *msNoiseEst_exp, /* i/o : pointer to exponent of estimated noise */
- Word32 *msNoiseEst_old, /* i/o : pointer to old estimated noise */
- Word16 *msNoiseEst_old_exp, /* i/o : pointer to exponent of old estimated noise */
- Word16 *active_frame_counter, /* i/o : pointer to active frame counter */
- Encoder_State *stcod /* i : pointer to Coder_State_Plus structure */
+Word16 AdjustFirstSID_fx(
+ Word16 npart, /* i : number of parts Q0*/
+ Word32 *msPeriodog, /* i : pointer to periodog vector msPeriodog_exp */
+ Word16 msPeriodog_exp, /* i : exponent of periodog vector */
+ Word32 *energy_ho, /* i/o : pointer to energy energy_ho_exp*/
+ Word16 *energy_ho_exp, /* i/o : pointer to exponent of energy */
+ Word32 *msNoiseEst, /* i/o : pointer to estimated noise msNoiseEst_exp*/
+ Word16 *msNoiseEst_exp, /* i/o : pointer to exponent of estimated noise */
+ Word32 *msNoiseEst_old, /* i/o : pointer to old estimated noise msNoiseEst_old_exp*/
+ Word16 *msNoiseEst_old_exp, /* i/o : pointer to exponent of old estimated noise */
+ Word16 *active_frame_counter, /* i/o : pointer to active frame counter Q0*/
+ Encoder_State *stcod /* i : pointer to Coder_State_Plus structure */
)
{
Word16 i, sc, s1, s2, lambda, lambdaM1, invFac;
@@ -706,7 +710,7 @@ AdjustFirstSID_fx(
/* Detect the hangover period and the first SID frame at the beginning of each CNG phase */
/* First hangover frame */
- Copy32( msPeriodog, energy_ho, npart );
+ Copy32( msPeriodog, energy_ho, npart ); /* exp(msPeriodog_exp) */
*energy_ho_exp = msPeriodog_exp;
move16();
@@ -724,8 +728,8 @@ AdjustFirstSID_fx(
/* active_frame_counter scaled by (1/1024.0) for compensation */
tmp32 = L_shl( L_deposit_l( add( *active_frame_counter, 1 ) ), WORD32_BITS - 1 - 10 );
tmp32 = BASOP_Util_InvLog2( Mpy_32_16_1( tmp32, -30877 /*-0.94229902485 Q15*/ ) );
- lambda = extract_h( tmp32 );
- lambdaM1 = extract_h( L_sub( 0x7FFFFFFF, tmp32 ) );
+ lambda = extract_h( tmp32 ); /* Q15 */
+ lambdaM1 = extract_h( L_sub( 0x7FFFFFFF /* 1.0f in Q31*/, tmp32 ) );
}
invFac = getNormReciprocalWord16( 1 );
@@ -739,7 +743,7 @@ AdjustFirstSID_fx(
FOR( i = 0; i < npart; i++ )
{
- msNoiseEst_old[i] = Mpy_32_16_1( msNoiseEst_old[i], lambda );
+ msNoiseEst_old[i] = Mpy_32_16_1( msNoiseEst_old[i], lambda ); /* exp(msNoiseEst_old) */
move32();
tmp32 = Mpy_32_16_1( Mpy_32_16_1( energy_ho[i], invFac ), lambdaM1 );
energy_ho[i] = L_add( L_shr( msNoiseEst_old[i], s1 ), L_shr( tmp32, s2 ) );
@@ -756,16 +760,16 @@ AdjustFirstSID_fx(
move32();
FOR( i = 0; i < npart; i++ )
{
- msNoiseEst_local = L_shr( msNoiseEst[i], s1 );
- energy_ho_local = L_shr( energy_ho[i], s2 );
+ msNoiseEst_local = L_shr( msNoiseEst[i], s1 ); /* exp(msNoiseEst + s1) */
+ energy_ho_local = L_shr( energy_ho[i], s2 ); /* exp(energy_ho_exp + s2) */
IF( GT_32( msNoiseEst_local, energy_ho_local ) )
{
- msNoiseEst[i] = energy_ho_local;
+ msNoiseEst[i] = energy_ho_local; /* exp(energy_ho_exp + s2) */
move32();
}
ELSE
{
- msNoiseEst[i] = msNoiseEst_local;
+ msNoiseEst[i] = msNoiseEst_local; /* exp(energy_ho_exp + s2) */
move32();
}
if ( msNoiseEst[i] > 0 )
@@ -788,13 +792,13 @@ AdjustFirstSID_fx(
IF( NE_32( stcod->core_brate, SID_2k40 ) && NE_32( stcod->core_brate, FRAME_NO_DATA ) )
{
/* Count the number of active frames in a row */
- *active_frame_counter = add( *active_frame_counter, 1 );
+ *active_frame_counter = add( *active_frame_counter, 1 ); /* Q0 */
move16();
}
ELSE
{
/* Store the noise estimate obtained in the CNG phases */
- Copy32( msNoiseEst, msNoiseEst_old, npart );
+ Copy32( msNoiseEst, msNoiseEst_old, npart ); /* exp(msNoiseEst_exp) */
*msNoiseEst_old_exp = *msNoiseEst_exp;
move16();
}
@@ -825,14 +829,14 @@ AdjustFirstSID_fx(
Returns:
void
*/
-static void msvq_encoder( const Word16 *const cb[], /* i : Codebook (indexed cb[*stages][levels][p]) scaled with 8 bits */
- Word16 u[], /* i : Vector to be encoded (prediction and mean removed) */
- const Word16 levels[], /* i : Number of levels in each stage */
- Word16 maxC, /* i : Tree search size */
- Word16 stages, /* i : Number of stages */
- Word16 N, /* i : Vector dimension */
- Word16 maxN, /* i : Codebook vector dimension */
- Word16 Idx[] /* o : Indices */
+static void msvq_encoder( const Word16 *const cb[], /* i : Codebook (indexed cb[*stages][levels][p]) scaled with 8 bits Q9.7*/
+ Word16 u[], /* i : Vector to be encoded (prediction and mean removed) Q9.7*/
+ const Word16 levels[], /* i : Number of levels in each stage Q0*/
+ Word16 maxC, /* i : Tree search size Q0*/
+ Word16 stages, /* i : Number of stages Q0*/
+ Word16 N, /* i : Vector dimension Q0*/
+ Word16 maxN, /* i : Codebook vector dimension Q0*/
+ Word16 Idx[] /* o : Indices Q0*/
)
{
Word32 *dist[2];
@@ -947,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 ) */
@@ -998,7 +998,7 @@ static void msvq_encoder( const Word16 *const cb[], /* i : Codebook (indexed cb
pTmp += N;
/* Get indices that were used for parent node */
- Copy( indices[0] + parents[c] * stages, indices[1] + c * stages, s );
+ Copy( indices[0] + parents[c] * stages, indices[1] + c * stages, s ); // Q0
}
m = maxC;
move16();
@@ -1634,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();
}
@@ -1647,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();
}
@@ -1728,10 +1720,10 @@ void generate_comfort_noise_enc_ivas_fx( Encoder_State *stcod,
cngNoiseLevel = st->cngNoiseLevel;
cngNoiseLevelExp = st->cngNoiseLevelExp;
move16();
- ptr_level = cngNoiseLevel;
+ ptr_level = cngNoiseLevel; // cngNoiseLevelExp
seed = &( st->seed );
- fftBuffer = st->fftBuffer;
- timeDomainOutput = st->timeDomainBuffer;
+ fftBuffer = st->fftBuffer; // st->fftBuffer_exp
+ timeDomainOutput = st->timeDomainBuffer; // Q15
/*
Generate Gaussian random noise in real and imaginary parts of the FFT bins
@@ -1748,7 +1740,7 @@ void generate_comfort_noise_enc_ivas_fx( Encoder_State *stcod,
randGaussExp = CNG_RAND_GAUSS_SHIFT;
move16();
- cnt = sub( stenc->stopFFTbinDec, stenc->startBandDec );
+ cnt = sub( stenc->stopFFTbinDec, stenc->startBandDec ); // Q)=0
IF( stenc->startBandDec == 0 )
{
/* DC component in FFT */
@@ -1886,7 +1878,7 @@ void generate_comfort_noise_enc_ivas_fx( Encoder_State *stcod,
seed_loc = st->seed;
move16();
- N = st->frameSize;
+ N = st->frameSize; // Q0
move16();
N2 = shr( st->frameSize, 1 );
@@ -1942,7 +1934,7 @@ void generate_comfort_noise_enc_ivas_fx( Encoder_State *stcod,
FOR( i = 0; i < N2; i++ )
{
- timeDomainOutput[i] = add( timeDomainOutput[i], shl( hTcxEnc->Txnq[i], TCX_IMDCT_HEADROOM ) );
+ timeDomainOutput[i] = add( timeDomainOutput[i], shl( hTcxEnc->Txnq[i], TCX_IMDCT_HEADROOM ) ); // Q15
move16();
}
}
@@ -1972,6 +1964,7 @@ void generate_comfort_noise_enc_ivas_fx( Encoder_State *stcod,
preemph_fac = stcod->preemph_fac;
move16();
Q_exc = Q_new;
+ move16();
Q_syn = sub( Q_new, 1 );
/* shift to be in the range of values supported by getNormReciprocalWord16() */
@@ -2029,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();
}
@@ -2042,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();
}
@@ -2093,12 +2078,12 @@ void generate_comfort_noise_enc_ivas_fx( Encoder_State *stcod,
/*! r: CNG energy */
Word16 cng_energy_fx(
- const Word16 element_mode, /* i : element mode */
- const Word16 bwidth, /* i : audio bandwidh */
- const Word16 CNG_mode, /* i : mode for DTX configuration */
- const Word16 CNG_att, /* i : attenuation factor for CNG */
- const Word16 *exc, /* i : input signal */
- const Word16 len, /* i : vector length */
+ const Word16 element_mode, /* i : element mode Q0*/
+ const Word16 bwidth, /* i : audio bandwidh Q0*/
+ const Word16 CNG_mode, /* i : mode for DTX configuration Q0*/
+ const Word16 CNG_att, /* i : attenuation factor for CNG Q7*/
+ const Word16 *exc, /* i : input signal Q_new*/
+ const Word16 len, /* i : vector length Q0*/
const Word16 Q_new /* i : Input scaling */
)
{
@@ -2193,11 +2178,11 @@ Word16 cng_energy_fx(
/*! r: CNG energy */
Word16 cng_energy_ivas_fx(
- const Word16 element_mode, /* i : element mode */
- const Word16 bwidth, /* i : audio bandwidh */
- const Word16 CNG_mode, /* i : mode for DTX configuration */
- const Word16 CNG_att, /* i : attenuation factor for CNG Q7 */
- const Word16 *exc, /* i : input signal */
+ const Word16 element_mode, /* i : element mode Q0*/
+ const Word16 bwidth, /* i : audio bandwidh Q0*/
+ const Word16 CNG_mode, /* i : mode for DTX configuration Q0*/
+ const Word16 CNG_att, /* i : attenuation factor for CNG Q7*/
+ const Word16 *exc, /* i : input signal Q_new*/
const Word16 len, /* i : vector length */
const Word16 Q_new /* i : Input scaling */
)
@@ -2264,11 +2249,13 @@ Word16 cng_energy_ivas_fx(
{
/* Bitrate adapted attenuation */
att = ENR_ATT_fx[CNG_mode];
+ move16();
}
ELSE
{
/* Use least attenuation for higher bitrates */
att = ENR_ATT_fx[4];
+ move16();
}
}
ELSE
diff --git a/lib_enc/find_tar.c b/lib_enc/find_tar.c
deleted file mode 100644
index e7a8ca967132cf8896fc4a231dbaf74eed596840..0000000000000000000000000000000000000000
--- a/lib_enc/find_tar.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/find_tar_fx.c b/lib_enc/find_tar_fx.c
index dc8477fc42db2aab8e4093e9f80a49bddde323a6..c758db8f33e893b6552b6914c9dc77c0f56023aa 100644
--- a/lib_enc/find_tar_fx.c
+++ b/lib_enc/find_tar_fx.c
@@ -14,16 +14,16 @@
void find_targets_fx(
const Word16 *speech, /* i : pointer to the speech frame Q_new-1*/
const Word16 *mem_syn, /* i : memory of the synthesis filter Q_new-1*/
- const Word16 i_subfr, /* i : subframe index */
+ const Word16 i_subfr, /* i : subframe index Q0*/
Word16 *mem_w0, /* i/o: weighting filter denominator memory Q_new-1*/
const Word16 *p_Aq, /* i : interpolated quantized A(z) filter Q12*/
const Word16 *res, /* i : residual signal Q_new*/
- const Word16 L_subfr, /* i : length of vectors for gain quantization */
+ const Word16 L_subfr, /* i : length of vectors for gain quantization Q0*/
const Word16 *Ap, /* i : unquantized A(z) filter with bandwidth expansion Q12*/
- Word16 tilt_fac, /* i : tilt factor Q15 */
+ Word16 tilt_fac, /* i : tilt factor Q15*/
Word16 *xn, /* o : Close-loop Pitch search target vector Q_new-1*/
Word16 *cn, /* o : target vector in residual domain Q_new*/
- Word16 *h1 /* o : impulse response of weighted synthesis filter */
+ Word16 *h1 /* o : impulse response of weighted synthesis filter Q14*/
)
{
Word16 i;
@@ -33,6 +33,7 @@ void find_targets_fx(
Word32 Ltmp;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/*------------------------------------------------------------------------*
* Find the target vector for excitation search:
@@ -49,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] );
-#else
- temp[i] = sub( speech[i + i_subfr - M], mem_syn[i] );
-#endif
+ temp[i] = sub_sat( speech[i + i_subfr - M], mem_syn[i] ); /* Q_new - 1 */
move16();
}
Syn_filt_s( 1, p_Aq, M, &res[i_subfr], temp + M, L_subfr, temp, 0 ); /* error in Q_new -1 */
@@ -77,7 +74,7 @@ void find_targets_fx(
Scale_sig( cn, L_SUBFR / 2, 1 );
/* second half: res[] --> cn[] (approximated and faster) */
- Copy( &res[i_subfr + ( L_SUBFR / 2 )], cn + ( L_SUBFR / 2 ), L_SUBFR / 2 );
+ Copy( &res[i_subfr + ( L_SUBFR / 2 )], cn + ( L_SUBFR / 2 ), L_SUBFR / 2 ); /* Q_new */
}
/*---------------------------------------------------------------*
@@ -89,13 +86,13 @@ void find_targets_fx(
d = sub( scaleq, scale );
IF( d >= 0 )
{
- Copy( p_Aq, Aqs, M + 1 );
+ Copy( p_Aq, Aqs, M + 1 ); /* Q12 */
s = add( scaleq, 1 );
s2 = shr( 16384, d );
}
ELSE
{
- Copy_Scale_sig( p_Aq, Aqs, M + 1, d );
+ Copy_Scale_sig( p_Aq, Aqs, M + 1, d ); /* Q12 */
s = add( scale, 1 );
s2 = 16384;
}
@@ -103,84 +100,56 @@ void find_targets_fx(
move16();
FOR( i = 0; i < M; i++ )
{
- Ltmp = L_mult( Ap[i], s2 );
+ 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 );
-#else
- Ltmp = L_msu( Ltmp, Aqs[j], h1[i - j] );
-#endif
+ Ltmp = L_msu_o( Ltmp, Aqs[j], h1[i - j], &Overflow ); /* Q27 */
}
-#ifdef BASOP_NOGLOB /* Critical Overflow */
- h1[i] = round_fx_o( L_shl_o( Ltmp, s, &Overflow ), &Overflow );
-#else
- h1[i] = round_fx( L_shl( Ltmp, s ) );
-#endif
+ h1[i] = round_fx_o( L_shl_o( Ltmp, s, &Overflow ), &Overflow ); /* Q11 + s */
}
- Ltmp = L_mult( Ap[i], s2 );
+ 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 );
-#else
- Ltmp = L_msu( Ltmp, Aqs[j], h1[i - j] );
-#endif
+ Ltmp = L_msu_o( Ltmp, Aqs[j], h1[i - j], &Overflow ); /* Q27 */
}
-#ifdef BASOP_NOGLOB /* Critical Overflow */
- h1[M] = round_fx_o( L_shl_o( Ltmp, s, &Overflow ), &Overflow );
-#else
- h1[M] = round_fx( L_shl( Ltmp, s ) );
-#endif
+ h1[M] = round_fx_o( L_shl_o( Ltmp, s, &Overflow ), &Overflow ); /* Q11 + s */
// 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++ )
{
- Ltmp = L_msu( 0, Aqs[1], h1[i - 1] );
+ 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 );
-#else
- Ltmp = L_msu( Ltmp, Aqs[j], h1[i - j] );
-#endif
+ Ltmp = L_msu_o( Ltmp, Aqs[j], h1[i - j], &Overflow ); /* Q27 */
}
-#ifdef BASOP_NOGLOB /* Critical Overflow */
- h1[i] = round_fx_o( L_shl_o( Ltmp, s, &Overflow ), &Overflow );
-#else
- h1[i] = round_fx( L_shl( Ltmp, s ) );
-#endif
+ h1[i] = round_fx_o( L_shl_o( Ltmp, s, &Overflow ), &Overflow ); /* Q11 + s */
}
IF( Overflow )
{
s2 = shr( s2, 1 );
FOR( i = 0; i < M; i++ )
{
- Ltmp = L_mult( Ap[i], s2 );
+ Ltmp = L_mult( Ap[i], s2 ); /* Q27 */
FOR( j = 1; j <= i; j++ )
{
- Ltmp = L_msu( Ltmp, Aqs[j], h1[i - j] );
+ Ltmp = L_msu( Ltmp, Aqs[j], h1[i - j] ); /* Q27 */
}
-#ifdef BASOP_NOGLOB
- h1[i] = round_fx( L_shl_o( Ltmp, s, &Overflow ) );
-#else
- h1[i] = round_fx( L_shl( Ltmp, s ) );
-#endif
+ h1[i] = round_fx( L_shl_o( Ltmp, s, &Overflow ) ); /* Q11 + s */
}
- Ltmp = L_mult( Ap[i], s2 );
+ Ltmp = L_mult( Ap[i], s2 ); /* Q27 */
FOR( j = 1; j <= M; j++ )
{
- Ltmp = L_msu( Ltmp, Aqs[j], h1[i - j] );
+ Ltmp = L_msu( Ltmp, Aqs[j], h1[i - j] ); /* Q27 */
}
- h1[M] = round_fx( L_shl( Ltmp, s ) );
+ h1[M] = round_fx( L_shl( Ltmp, s ) ); /* Q11 + s */
FOR( i = M + 1; i < L_subfr; i++ )
{
- Ltmp = L_msu( 0, Aqs[1], h1[i - 1] );
+ Ltmp = L_msu( 0, Aqs[1], h1[i - 1] ); /* Q27 */
FOR( j = 2; j <= M; j++ )
{
- Ltmp = L_msu( Ltmp, Aqs[j], h1[i - j] );
+ Ltmp = L_msu( Ltmp, Aqs[j], h1[i - j] ); /* Q27 */
}
- h1[i] = round_fx( L_shl( Ltmp, s ) );
+ h1[i] = round_fx( L_shl( Ltmp, s ) ); /* Q11 + s */
}
}
@@ -193,16 +162,16 @@ void find_targets_fx(
void find_targets_ivas_fx(
const Word16 *speech, /* i : pointer to the speech frame Q_new-1*/
const Word16 *mem_syn, /* i : memory of the synthesis filter Q_new-1*/
- const Word16 i_subfr, /* i : subframe index */
+ const Word16 i_subfr, /* i : subframe index Q0*/
Word16 *mem_w0, /* i/o: weighting filter denominator memory Q_new-1*/
const Word16 *p_Aq, /* i : interpolated quantized A(z) filter Q12*/
const Word16 *res, /* i : residual signal Q_new*/
- const Word16 L_subfr, /* i : length of vectors for gain quantization */
+ const Word16 L_subfr, /* i : length of vectors for gain quantization Q0*/
const Word16 *Ap, /* i : unquantized A(z) filter with bandwidth expansion Q12*/
- Word16 tilt_fac, /* i : tilt factor Q15 */
+ Word16 tilt_fac, /* i : tilt factor Q15*/
Word16 *xn, /* o : Close-loop Pitch search target vector Q_new-1*/
Word16 *cn, /* o : target vector in residual domain Q_new*/
- Word16 *h1 /* o : impulse response of weighted synthesis filter */
+ Word16 *h1 /* o : impulse response of weighted synthesis filter Q14*/
)
{
Word16 i;
@@ -228,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] );
-#else
- temp[i] = sub( speech[i + i_subfr - M], mem_syn[i] );
-#endif
+ temp[i] = sub_sat( speech[i + i_subfr - M], mem_syn[i] ); /* Q_new - 1 */
move16();
}
Syn_filt_s( 1, p_Aq, M, &res[i_subfr], temp + M, L_subfr, temp, 0 );
@@ -253,10 +218,10 @@ void find_targets_ivas_fx(
preemph_copy_fx( xn, cn, tilt_fac, shr( L_subfr, 1 ), temp );
syn_filt_s_lc_fx( 1, Ap, cn, temp, shr( L_subfr, 1 ) ); /* Q-1 -> Q-2 */
Residu3_lc_fx( p_Aq, M, temp, cn, shr( L_subfr, 1 ), 1 ); /* Q-2 -> Q-1 */
- Scale_sig( cn, shr( L_subfr, 1 ), 1 );
+ Scale_sig( cn, shr( L_subfr, 1 ), 1 ); /* Q_new */
/* second half: res[] --> cn[] (approximated and faster) */
- Copy( &res[i_subfr + shr( L_subfr, 1 )], cn + shr( L_subfr, 1 ), shr( L_subfr, 1 ) );
+ Copy( &res[i_subfr + shr( L_subfr, 1 )], cn + shr( L_subfr, 1 ), shr( L_subfr, 1 ) ); /* Q_new */
}
/*---------------------------------------------------------------*
@@ -268,13 +233,13 @@ void find_targets_ivas_fx(
d = sub( scaleq, scale );
IF( d >= 0 )
{
- Copy( p_Aq, Aqs, M + 1 );
+ Copy( p_Aq, Aqs, M + 1 ); /* Q12 */
s = add( scaleq, 1 );
s2 = shr( 16384, d );
}
ELSE
{
- Copy_Scale_sig( p_Aq, Aqs, M + 1, d );
+ Copy_Scale_sig( p_Aq, Aqs, M + 1, d ); /* Q12 */
s = add( scale, 1 );
s2 = 16384;
}
@@ -283,84 +248,56 @@ void find_targets_ivas_fx(
move16();
FOR( i = 0; i < M; i++ )
{
- Ltmp = L_mult( Ap[i], s2 );
+ 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 );
-#else
- Ltmp = L_msu( Ltmp, Aqs[j], h1[i - j] );
-#endif
+ Ltmp = L_msu_o( Ltmp, Aqs[j], h1[i - j], &Overflow ); /* Q27 */
}
-#ifdef BASOP_NOGLOB /* Critical Overflow */
- h1[i] = round_fx_o( L_shl_o( Ltmp, s, &Overflow ), &Overflow );
-#else
- h1[i] = round_fx( L_shl( Ltmp, s ) );
-#endif
+ h1[i] = round_fx_o( L_shl_o( Ltmp, s, &Overflow ), &Overflow ); /* Q11 + s */
}
- Ltmp = L_mult( Ap[i], s2 );
+ 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 );
-#else
- Ltmp = L_msu( Ltmp, Aqs[j], h1[i - j] );
-#endif
+ Ltmp = L_msu_o( Ltmp, Aqs[j], h1[i - j], &Overflow ); /* Q27 */
}
-#ifdef BASOP_NOGLOB /* Critical Overflow */
- h1[M] = round_fx_o( L_shl_o( Ltmp, s, &Overflow ), &Overflow );
-#else
- h1[M] = round_fx( L_shl( Ltmp, s ) );
-#endif
+ h1[M] = round_fx_o( L_shl_o( Ltmp, s, &Overflow ), &Overflow ); /* Q11 + s */
// 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++ )
{
- Ltmp = L_msu( 0, Aqs[1], h1[i - 1] );
+ 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 );
-#else
- Ltmp = L_msu( Ltmp, Aqs[j], h1[i - j] );
-#endif
+ Ltmp = L_msu_o( Ltmp, Aqs[j], h1[i - j], &Overflow ); /* Q27 */
}
-#ifdef BASOP_NOGLOB /* Critical Overflow */
- h1[i] = round_fx_o( L_shl_o( Ltmp, s, &Overflow ), &Overflow );
-#else
- h1[i] = round_fx( L_shl( Ltmp, s ) );
-#endif
+ h1[i] = round_fx_o( L_shl_o( Ltmp, s, &Overflow ), &Overflow ); /* Q11 + s */
}
IF( Overflow )
{
s2 = shr( s2, 1 );
FOR( i = 0; i < M; i++ )
{
- Ltmp = L_mult( Ap[i], s2 );
+ Ltmp = L_mult( Ap[i], s2 ); /* Q27 */
FOR( j = 1; j <= i; j++ )
{
- Ltmp = L_msu( Ltmp, Aqs[j], h1[i - j] );
+ Ltmp = L_msu( Ltmp, Aqs[j], h1[i - j] ); /* Q27 */
}
-#ifdef BASOP_NOGLOB
- h1[i] = round_fx( L_shl_o( Ltmp, s, &Overflow ) );
-#else
- h1[i] = round_fx( L_shl( Ltmp, s ) );
-#endif
+ h1[i] = round_fx( L_shl_o( Ltmp, s, &Overflow ) ); /* Q11 + s */
}
- Ltmp = L_mult( Ap[i], s2 );
+ Ltmp = L_mult( Ap[i], s2 ); /* Q27 */
FOR( j = 1; j <= M; j++ )
{
- Ltmp = L_msu( Ltmp, Aqs[j], h1[i - j] );
+ Ltmp = L_msu( Ltmp, Aqs[j], h1[i - j] ); /* Q27 */
}
- h1[M] = round_fx( L_shl( Ltmp, s ) );
+ h1[M] = round_fx( L_shl( Ltmp, s ) ); /* Q11 + s */
FOR( i = M + 1; i < L_subfr; i++ )
{
- Ltmp = L_msu( 0, Aqs[1], h1[i - 1] );
+ Ltmp = L_msu( 0, Aqs[1], h1[i - 1] ); /* Q27 */
FOR( j = 2; j <= M; j++ )
{
- Ltmp = L_msu( Ltmp, Aqs[j], h1[i - j] );
+ Ltmp = L_msu( Ltmp, Aqs[j], h1[i - j] ); /* Q27 */
}
- h1[i] = round_fx( L_shl( Ltmp, s ) );
+ h1[i] = round_fx( L_shl( Ltmp, s ) ); /* Q11 + s */
}
}
diff --git a/lib_enc/find_tilt.c b/lib_enc/find_tilt.c
index c5e16ed22962d9f18f21f00a79ac9c7b52fa7278..952805169e2281289bab083b96c5c4186e853a47 100644
--- a/lib_enc/find_tilt.c
+++ b/lib_enc/find_tilt.c
@@ -56,20 +56,21 @@
* Find LF/HF energy ratio
*-------------------------------------------------------------------*/
void find_tilt_ivas_fx(
- const Word32 fr_bands[], /* i : energy in frequency bands Q_new*/
- const Word32 bckr[], /* i : per band background noise energy estimate Q_new*/
+ const Word32 fr_bands[], /* i : energy in frequency bands q_fr_bands*/
+ const Word16 q_fr_bands, /* i : Q of fr_bands Q0*/
+ const Word32 bckr[], /* i : per band background noise energy estimate q_bckr*/
+ const Word16 q_bckr, /* i : Q of bckr Q0*/
Word32 ee[2], /* o : lf/hf E ration for present frame Q6*/
const Word16 pitch[3], /* i : open loop pitch values for 3 half-frames Q0*/
const Word16 voicing[3], /* i : normalized correlation for 3 half-frames Q15*/
- const Word32 *lf_E, /* i : per bin energy for low frequencies Q_new - 2*/
+ const Word32 *lf_E, /* i : per bin energy for low frequencies q_lf_E*/
+ const Word16 q_lf_E, /* i : Q of lf_E */
const Word16 corr_shift, /* i : normalized correlation correction Q15*/
const Word16 bwidth, /* i : input signal bandwidth */
const Word16 max_band, /* i : maximum critical band */
Word32 hp_E[], /* o : energy in HF Q_new*/
const Word16 codec_mode, /* i : MODE1 or MODE2 */
- const Word16 Q_new, /* i : scaling factor */
- Word32 *bckr_tilt_lt /* i/o: lf/hf E ratio of background noise Q16 */
- ,
+ Word32 *bckr_tilt_lt, /* i/o: lf/hf E ratio of background noise Q16 */
Word16 Opt_vbr_mode )
{
Word32 lp_bckr = 0, hp_bckr = 0, lp_E, Ltmp;
@@ -80,6 +81,9 @@ void find_tilt_ivas_fx(
Word16 m_Fs, e_Fs;
Word16 m_cnt, e_cnt;
Word16 m_hpE, e_hpE;
+ Word64 sum;
+ Word16 inv_bands, q_lp_E;
+ Word32 Le_min_scaled, Ltmp2;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
move32();
@@ -90,25 +94,29 @@ void find_tilt_ivas_fx(
* Initializations
*-----------------------------------------------------------------*/
- IF( NE_16( bwidth, NB ) )
+ IF( ( bwidth != NB ) )
{
/* WB processing */
bin = BIN4_FX;
- move16(); /* First useful frequency bin ~ 50 Hz */
- pt_bands = fr_bands;
- tmp_E = lf_E;
- pt_bckr = bckr;
+ move16(); /* First useful frequency bin ~ 50 Hz */
+ pt_bands = fr_bands; /* Q_new */
+ tmp_E = lf_E; /* Q_new - 2 */
+ pt_bckr = bckr; /* Q_new */
nb_bands = 10;
+ inv_bands = 3277 /* 1/10 in Q15 */;
+ move16();
move16();
}
ELSE
{
/* NB processing */
- bin = add( shl( BIN4_FX, 1 ), BIN4_FX ); /* First useful frequency bin ~ 150 Hz */
- pt_bands = fr_bands + 1; /* Exlcude 1st critical band */
- tmp_E = lf_E + 2; /* Start at the 3rd bin (150 Hz) */
- pt_bckr = bckr + 1; /* Exlcude 1st critical band */
+ bin = 3 * BIN4_FX; /* First useful frequency bin ~ 150 Hz */
+ pt_bands = fr_bands + 1; /* Exlcude 1st critical band */
+ tmp_E = lf_E + 2; /* Start at the 3rd bin (150 Hz) */
+ pt_bckr = bckr + 1; /* Exlcude 1st critical band */
nb_bands = 9;
+ inv_bands = 3641; /* 1/9 in Q15 */
+ move16();
move16(); /* Nb. of "low" frequency bands taken into account in NB processing */
}
@@ -121,197 +129,168 @@ void find_tilt_ivas_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 = L_shr( L_add_sat( bckr[max_band - 1], bckr[max_band] ), 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. */
+ sum = 0;
+ move64();
+ FOR( i = 0; i < nb_bands; i++ )
+ {
+ sum = W_mac_32_16( sum, pt_bckr[i], inv_bands ); // q_bckr+16
+ }
+ lp_bckr = W_shl_sat_l( sum, -16 ); // q_bckr
+ /*hp_bckr = 0.5f * (bckr[max_band-1] + bckr[max_band]);*/ /* estimated noise E in last 2 critical bands */
+ hp_bckr = W_extract_h( W_mac_32_32( W_mult_32_32( bckr[max_band - 1], ONE_IN_Q30 ), bckr[max_band], ONE_IN_Q30 ) ); // q_bckr
+ if ( hp_bckr == 0 ) /* Avoid division by zero. */
{
hp_bckr = L_deposit_l( 1 );
}
Ltmp = BASOP_Util_Divide3232_Scale_cadence( lp_bckr, hp_bckr, &e_tmp );
- Ltmp = Mpy_32_16_r( Ltmp, 3277 );
+ Ltmp = Mpy_32_16_r( Ltmp, 3277 /* 0.1f in Q15 */ );
Ltmp = L_shr_sat( Ltmp, sub( 15, e_tmp ) );
- *bckr_tilt_lt = L_add_sat( Mpy_32_16_r( *bckr_tilt_lt, 29491 ), Ltmp );
+ *bckr_tilt_lt = L_add_sat( Mpy_32_16_r( *bckr_tilt_lt, 29491 /* 0.9f in Q15 */ ), Ltmp ); // Q16
move32();
test();
- IF( EQ_16( codec_mode, MODE2 ) || Opt_vbr_mode == 1 )
+ IF( EQ_16( codec_mode, MODE2 ) || EQ_16( Opt_vbr_mode, 1 ) )
{
/*lp_bckr *= FACT;*/
/*hp_bckr *= FACT;*/
-#ifdef BASOP_NOGLOB
- lp_bckr = L_add_sat( L_shl_sat( lp_bckr, 1 ), lp_bckr );
- 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
+ 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 */
}
/*mean_voi = 0.5f * (voicing[1] + voicing[2]) + corr_shift;*/
- Ltmp = L_mult( voicing[1], 16384 );
- Ltmp = L_mac( Ltmp, voicing[2], 16384 );
-#ifdef BASOP_NOGLOB
- Ltmp = L_mac_o( Ltmp, corr_shift, 32767, &Overflow );
- mean_voi = round_fx_o( Ltmp, &Overflow );
-#else
- Ltmp = L_mac( Ltmp, corr_shift, 32767 );
- mean_voi = round_fx( Ltmp );
-#endif
+ 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
/*f0 = INT_FS_FX / pitch[2];*/
e_tmp = norm_s( pitch[2] );
m_tmp = shl( pitch[2], e_tmp );
- m_Fs = div_s( INT_FS_FX, m_tmp );
+ m_Fs = div_s( INT_FS_FX, m_tmp ); /* exp(e_tmp) */
e_Fs = sub( 15, e_tmp );
f0 = shr( m_Fs, sub( e_Fs, 4 ) ); /* Q4 */
+ Le_min_scaled = L_shl( E_MIN_FXQ31, sub( q_fr_bands, Q31 ) ); // q_fr_bands=q_bckr
+
FOR( i = 0; i < 2; i++ )
{
- /*hp_E[i] = 0.5f * (hf_bands[max_band-1] + hf_bands[max_band]) - hp_bckr; */ /* averaged E in last 2 critical bands */
- Ltmp = L_add( L_shr( hf_bands[max_band - 1], 1 ), L_shr( hf_bands[max_band], 1 ) );
- hp_E[i] = L_sub( Ltmp, hp_bckr );
- move32();
- IF( Opt_vbr_mode == 0 )
- {
- IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( hp_E[i], sub( 31, Q_new ), E_MIN_IVAS_FX, 31 - Q19 ), -1 ) )
- {
- hp_E[i] = L_shl( E_MIN_IVAS_FX, sub( Q_new, Q19 ) );
- move32();
- }
- }
- ELSE
+ /*hp_E[i] = 0.5f * (hf_bands[max_band-1] + hf_bands[max_band]) - hp_bckr; */ /* averaged E in last 2 critical bands */
+ Ltmp = W_extract_h( W_mac_32_32( W_mult_32_32( hf_bands[max_band - 1], ONE_IN_Q30 ), hf_bands[max_band], ONE_IN_Q30 ) ); // q_fr_bands
+ Ltmp = L_sub( Ltmp, hp_bckr ); // q_fr_bands
+
+ Ltmp2 = L_max( Ltmp, L_shl_sat( 1, q_fr_bands ) ); // q_fr_bands, saturation is added because q_fr_bands is limited to 31
+ if ( Opt_vbr_mode == 0 )
{
- hp_E[i] = L_max( hp_E[i], L_shl( 1, Q_new ) );
- move32();
+ Ltmp2 = L_max( Ltmp, Le_min_scaled ); // q_fr_bands
}
+ hp_E[i] = L_max( Ltmp2, 1 ); // to prevent division by zero
+ move32();
test();
IF( GT_16( mean_voi, TH_COR_FX ) && LT_16( pitch[2], TH_PIT_FX ) ) /* High-pitched voiced frames */
{
- freq = bin;
- move16(); /* 1st useful frequency bin */
+ freq = bin; // Q4
+ move16(); /* 1st useful frequency bin */
m_cnt = 0;
move16();
- lp_E = L_deposit_l( 0 );
+ sum = 0;
+ move64();
f1 = add( shr( f0, 1 ), f0 ); /* Middle between 2 harmonics */
f2 = f0;
move16();
- WHILE( LE_16( freq, 20320 ) ) /* End frequency of 10th critical band */
+ WHILE( LE_16( freq, 20320 /* 1270.0f in Q4 */ ) ) /* End frequency of 10th critical band */
{
FOR( ; freq <= f1; freq += BIN4_FX )
{
/* include only bins sufficiently close to harmonics */
tmp = sub( freq, f2 );
- IF( L_mac0( -(Word32) TH_D_FX * TH_D_FX, tmp, tmp ) < 0 )
+ IF( L_mac0( -TH_D_FX * TH_D_FX, tmp, tmp ) < 0 )
{
-#ifdef BASOP_NOGLOB
- lp_E = L_add_o( *pt_E, lp_E, &Overflow );
-#else
- lp_E = L_add( *pt_E, lp_E );
-#endif
+ sum = W_mac_32_16( sum, *pt_E, 1 ); // q_lf_E+1
m_cnt = add( m_cnt, 1 );
}
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 );
- m_tmp = extract_h( L_shl( lp_E, e_tmp ) );
-
- e_tmp = sub( e_tmp, 2 ); /* lf_e divided by 4 in anal_sp */
+ e_tmp = sub( W_norm( sum ), 1 );
+ m_tmp = extract_h( W_extract_h( W_shl( sum, e_tmp ) ) ); // q_lf_E+1+e_tmp-32-16
+ e_tmp = sub( add( q_lf_E, e_tmp ), 47 );
e_cnt = norm_s( m_cnt );
- m_cnt = shl( m_cnt, e_cnt );
+ m_cnt = shl( m_cnt, e_cnt ); // e_cnt
- m_tmp = div_s( m_tmp, m_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 );
-#else
- lp_E = L_sub( L_shr( m_tmp, sub( e_tmp, 1 ) ), lp_bckr );
-#endif
+ m_tmp = div_s( m_tmp, m_cnt ); // Q15+e_tmp-e_cnt
+ e_tmp = add( Q15, sub( e_tmp, e_cnt ) );
+ sum = W_shl( m_tmp, sub( add( q_bckr, 1 ), e_tmp ) ); // q_bckr+1
+ sum = W_msu_32_16( sum, lp_bckr, 1 ); // q_bckr+1
+ q_lp_E = W_norm( sum );
+ lp_E = W_extract_h( W_shl( sum, q_lp_E ) ); // q_bckr+1+q_lp_E-32
+ q_lp_E = sub( add( q_lp_E, q_bckr ), Q31 );
- pt_E = tmp_E + VOIC_BINS; /* Update for next half-frame */
+ pt_E = tmp_E + VOIC_BINS; /* Update for next half-frame Q_new - 1 */
}
ELSE /* Other than high-pitched voiced frames */
{
/*lp_E = mean( pt_bands, nb_bands ) - lp_bckr;*/ /* averaged E in first critical bands, up to 1270 Hz */
- lp_E = L_sub( Mean32( pt_bands, nb_bands ), lp_bckr );
- }
- IF( Opt_vbr_mode == 0 )
- {
- IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( lp_E, sub( 31, Q_new ), E_MIN_IVAS_FX, 31 - Q19 ), -1 ) )
+ sum = 0;
+ move64();
+ FOR( Word16 j = 0; j < nb_bands; j++ )
{
- lp_E = L_shl( E_MIN_IVAS_FX, sub( Q_new, Q19 ) );
+ sum = W_mac_32_16( sum, pt_bands[j], inv_bands ); // q_fr_bands+16
}
+ sum = W_mac_32_16( sum, lp_bckr, -ONE_IN_Q15 ); // q_fr_bands+16
+ lp_E = W_round48_L( sum ); // q_fr_bands=q_bckr
+ q_lp_E = q_bckr; // q_fr_bands=q_bckr
+ move16();
}
- ELSE
- {
- lp_E = L_max( lp_E, 0 );
- }
- /*ee[i] = lp_E / hp_E[i];*/ /* LF/HF ratio */
test();
- IF( lp_E != 0 && hp_E[i] != 0 )
+ IF( Opt_vbr_mode == 0 && GT_32( L_shl_sat( Le_min_scaled, sub( q_lp_E, q_bckr ) ), lp_E ) )
{
- e_tmp = sub( norm_l( lp_E ), 1 );
- m_tmp = extract_h( L_shl( lp_E, e_tmp ) );
- e_hpE = norm_l( hp_E[i] );
- m_hpE = extract_h( L_shl( hp_E[i], e_hpE ) );
- m_tmp = div_s( m_tmp, m_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
+ lp_E = E_MIN_FXQ31;
+ q_lp_E = Q31;
move32();
+ move16();
+ }
+ if ( Opt_vbr_mode != 0 )
+ {
+ lp_E = L_max( lp_E, 0 ); // q_lp_E
}
- ELSE IF( lp_E == 0 )
+ /*ee[i] = lp_E / hp_E[i];*/ /* LF/HF ratio */
+
+ if ( lp_E == 0 )
{
- ee[i] = L_deposit_l( 0 );
+ ee[i] = 0;
move32();
}
- ELSE
+ test();
+ IF( lp_E != 0 )
{
- ee[i] = MAX_32;
+ e_tmp = sub( norm_l( lp_E ), 1 );
+ m_tmp = extract_h( L_shl( lp_E, e_tmp ) ); // e_tmp+q_lp_E-16
+ e_hpE = norm_l( hp_E[i] );
+ 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 ) );
+ ee[i] = L_shr_o( m_tmp, add( e_tmp, 15 - 6 ), &Overflow ); /* ee in Q6 */
move32();
}
- IF( EQ_16( bwidth, NB ) ) /* For NB input, compensate for the missing bands */
+ IF( 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 = L_shl_o( ee[i], 3, &Overflow ); /* Q6 */
+ IF( EQ_32( Ltmp, MAX_32 ) ) /* if Overflow: Compute with less precision */
{
- Ltmp = Mult_32_16( ee[i], 24576 ); /* 6/8 */
-#ifdef BASOP_NOGLOB
- ee[i] = L_shl_sat( Ltmp, 3 );
-#else
- ee[i] = L_shl( Ltmp, 3 );
-#endif
- move32(); /* x8 */
+ Ltmp = Mult_32_16( ee[i], 24576 /* 0.75 in Q15 */ ); /* 6/8 Q6*/
+ ee[i] = L_shl_sat( Ltmp, 3 ); /* Q6 */
+ move32(); /* x8 */
}
ELSE
{
- ee[i] = Mult_32_16( Ltmp, 24576 );
+ ee[i] = Mult_32_16( Ltmp, 24576 /* 0.75 in Q15 */ );
move32(); /* 6/8 */
}
}
diff --git a/lib_enc/find_tilt_fx.c b/lib_enc/find_tilt_fx.c
index f0c39eee21dafe9fe30de6bee54dbdd2d4a6854c..44ad404e379b1ba6cc234b1b013d9d6e7e2942c2 100644
--- a/lib_enc/find_tilt_fx.c
+++ b/lib_enc/find_tilt_fx.c
@@ -23,14 +23,15 @@ void find_tilt_fx(
const Word16 voicing[3], /* i : normalized correlation for 3 half-frames Q15*/
const Word32 *lf_E, /* i : per bin energy for low frequencies Q_new + Q_SCALE - 2*/
const Word16 corr_shift, /* i : normalized correlation correction Q15*/
- const Word16 bwidth, /* i : input signal bandwidth */
- const Word16 max_band, /* i : maximum critical band */
+ const Word16 bwidth, /* i : input signal bandwidth Q0*/
+ const Word16 max_band, /* i : maximum critical band Q0*/
Word32 hp_E[], /* o : energy in HF Q_new + Q_SCALE*/
- const Word16 codec_mode, /* i : MODE1 or MODE2 */
+ const Word16 codec_mode, /* i : MODE1 or MODE2 Q0*/
const Word16 Q_new, /* i : scaling factor */
- Word32 *bckr_tilt_lt /* i/o: lf/hf E ratio of background noise Q16 */
+ Word32 *bckr_tilt_lt /* i/o: lf/hf E ratio of background noise Q16*/
,
- Word16 Opt_vbr_mode )
+ Word16 Opt_vbr_mode /* Q0 */
+)
{
Word32 lp_bckr = 0, hp_bckr = 0, lp_E, Ltmp;
const Word32 *pt_E, *pt_bands, *pt_bckr, *hf_bands, *tmp_E;
@@ -41,8 +42,11 @@ void find_tilt_fx(
Word16 m_cnt, e_cnt;
Word16 m_hpE, e_hpE;
Word16 scaling;
+ move32();
+ move32();
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/*-----------------------------------------------------------------*
* Initializations
@@ -53,10 +57,10 @@ void find_tilt_fx(
{
/* WB processing */
bin = BIN4_FX;
- move16(); /* First useful frequency bin ~ 50 Hz */
- pt_bands = fr_bands;
- tmp_E = lf_E;
- pt_bckr = bckr;
+ move16(); /* First useful frequency bin ~ 50 Hz */
+ pt_bands = fr_bands; /* Q_new + QSCALE */
+ tmp_E = lf_E; /* Q_new + QSCALE - 2 */
+ pt_bckr = bckr; /* Q_new + QSCALE */
nb_bands = 10;
move16();
}
@@ -64,9 +68,9 @@ void find_tilt_fx(
{
/* NB processing */
bin = add( shl( BIN4_FX, 1 ), BIN4_FX ); /* First useful frequency bin ~ 150 Hz */
- pt_bands = fr_bands + 1; /* Exlcude 1st critical band */
- tmp_E = lf_E + 2; /* Start at the 3rd bin (150 Hz) */
- pt_bckr = bckr + 1; /* Exlcude 1st critical band */
+ pt_bands = fr_bands + 1; /* Exlcude 1st critical band Q_new + QSCALE*/
+ tmp_E = lf_E + 2; /* Start at the 3rd bin (150 Hz) Q_new + QSCALE - 2*/
+ pt_bckr = bckr + 1; /* Exlcude 1st critical band Q_new + QSCALE*/
nb_bands = 9;
move16(); /* Nb. of "low" frequency bands taken into account in NB processing */
}
@@ -75,71 +79,63 @@ void find_tilt_fx(
* Find spectrum tilt
*-----------------------------------------------------------------*/
- pt_E = tmp_E; /* Point at the 1st useful element of the per-bin energy vector */
- hf_bands = fr_bands;
+ pt_E = tmp_E; /* Point at the 1st useful element of the per-bin energy vector */
+ hf_bands = fr_bands; /* Q_new + QSCALE */
/* 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 = L_shr( L_add_sat( bckr[max_band - 1], bckr[max_band] ), 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. */
+ /*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 */
+ 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
+ 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 ) );
- *bckr_tilt_lt = L_add( Mpy_32_16_r( *bckr_tilt_lt, 29491 ), Mpy_32_16_r( Ltmp, 3277 ) );
+#endif
+
+ *bckr_tilt_lt = L_add( Mpy_32_16_r( *bckr_tilt_lt, 29491 ), Mpy_32_16_r( Ltmp, 3277 ) ); /* Q16 */
test();
IF( EQ_16( codec_mode, MODE2 ) || Opt_vbr_mode == 1 )
{
/*lp_bckr *= FACT;*/
/*hp_bckr *= FACT;*/
-#ifdef BASOP_NOGLOB
- lp_bckr = L_add_sat( L_shl_sat( lp_bckr, 1 ), lp_bckr );
+ 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 );
- Ltmp = L_mac( Ltmp, voicing[2], 16384 );
-#ifdef BASOP_NOGLOB
- Ltmp = L_mac_o( Ltmp, corr_shift, 32767, &Overflow );
- mean_voi = round_fx_o( Ltmp, &Overflow );
-#else
- Ltmp = L_mac( Ltmp, corr_shift, 32767 );
- mean_voi = round_fx( Ltmp );
-#endif
+ 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, &Overflow ); /* Q31 */
+ mean_voi = round_fx_o( Ltmp, &Overflow ); /* Q15 */
/*f0 = INT_FS_FX / pitch[2];*/
e_tmp = norm_s( pitch[2] );
m_tmp = shl( pitch[2], e_tmp );
- m_Fs = div_s( INT_FS_FX, m_tmp );
+ m_Fs = div_s( INT_FS_FX, m_tmp ); /* exp(e_tmp) */
e_Fs = sub( 15, e_tmp );
f0 = shr( m_Fs, sub( e_Fs, 4 ) ); /* Q4 */
FOR( i = 0; i < 2; i++ )
{
- /*hp_E[i] = 0.5f * (hf_bands[max_band-1] + hf_bands[max_band]) - hp_bckr; */ /* averaged E in last 2 critical bands */
- Ltmp = L_add( L_shr( hf_bands[max_band - 1], 1 ), L_shr( hf_bands[max_band], 1 ) );
- hp_E[i] = L_sub( Ltmp, hp_bckr );
+ /*hp_E[i] = 0.5f * (hf_bands[max_band-1] + hf_bands[max_band]) - hp_bckr; */ /* averaged E in last 2 critical bands */
+ Ltmp = L_add( L_shr( hf_bands[max_band - 1], 1 ), L_shr( hf_bands[max_band], 1 ) ); /* Q_new + QSCALE */
+ hp_E[i] = L_sub( Ltmp, hp_bckr ); /* Q_new + QSCALE */
IF( Opt_vbr_mode == 0 )
{
- hp_E[i] = L_max( hp_E[i], L_shl( E_MIN_FX, Q_new ) );
+ hp_E[i] = L_max( hp_E[i], L_shl( E_MIN_FX, Q_new ) ); /* Q_new + QSCALE */
move32();
}
ELSE
{
- hp_E[i] = L_max( hp_E[i], L_shl( 1, scaling ) );
+ hp_E[i] = L_max( hp_E[i], L_shl( 1, scaling ) ); /* Q_new + QSCALE */
move32();
}
@@ -163,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 );
-#else
- lp_E = L_add( *pt_E, lp_E );
-#endif
- m_cnt = add( m_cnt, 1 );
+ lp_E = L_add_o( *pt_E, lp_E, &Overflow ); /* Q_new + QSCALE - 2 */
+ 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 );
@@ -189,21 +176,17 @@ void find_tilt_fx(
e_cnt = norm_s( m_cnt );
m_cnt = shl( m_cnt, e_cnt );
- m_tmp = div_s( m_tmp, m_cnt );
+ 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 );
-#else
- lp_E = L_sub( L_shr( m_tmp, sub( e_tmp, 1 ) ), lp_bckr );
-#endif
+ lp_E = L_sub_o( L_shr_o( m_tmp, sub( e_tmp, 1 ), &Overflow ), lp_bckr, &Overflow ); /* Q_new + QSCALE */
pt_E = tmp_E + VOIC_BINS; /* Update for next half-frame */
}
ELSE /* Other than high-pitched voiced frames */
{
- /*lp_E = mean( pt_bands, nb_bands ) - lp_bckr;*/ /* averaged E in first critical bands, up to 1270 Hz */
- lp_E = L_sub( Mean32( pt_bands, nb_bands ), lp_bckr );
+ /*lp_E = mean( pt_bands, nb_bands ) - lp_bckr;*/ /* averaged E in first critical bands, up to 1270 Hz */
+ lp_E = L_sub( Mean32( pt_bands, nb_bands ), lp_bckr ); /* Q_new + QSCALE */
}
IF( Opt_vbr_mode == 0 )
{
@@ -221,14 +204,10 @@ void find_tilt_fx(
m_tmp = extract_h( L_shl( lp_E, e_tmp ) );
e_hpE = norm_l( hp_E[i] );
m_hpE = extract_h( L_shl( hp_E[i], e_hpE ) );
- m_tmp = div_s( m_tmp, m_hpE );
+ 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 )
{
@@ -241,25 +220,17 @@ 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 ); /* 6/8 */
-#ifdef BASOP_NOGLOB
+ Ltmp = Mult_32_16( ee[i], 24576 /* 0.75 in Q15 */ ); /* 6/8 Q6*/
ee[i] = L_shl_sat( Ltmp, 3 );
-#else
- ee[i] = L_shl( Ltmp, 3 );
-#endif
move32(); /* x8 */
}
ELSE
{
- ee[i] = Mult_32_16( Ltmp, 24576 );
- move32(); /* 6/8 */
+ ee[i] = Mult_32_16( Ltmp, 24576 /* 0.75 in Q15 */ ); /* Q6 */
+ move32(); /* 6/8 */
}
}
diff --git a/lib_enc/find_uv.c b/lib_enc/find_uv.c
index 972c402426034edf8f20cc593fc90e353a64f29a..2e14972c7b3f9a671f2ac37ca04b5039ca67df0c 100644
--- a/lib_enc/find_uv.c
+++ b/lib_enc/find_uv.c
@@ -58,9 +58,9 @@
*-------------------------------------------------------------------*/
/*! r: maximum energy ratio */
-static Word16 find_ener_decrease_fx( /* o : maximum energy ratio Q10 */
- const Word16 ind_deltaMax, /* i : index of the beginning of maximum energy search */
- const Word32 *pt_enr_ssf /* i : Pointer to the energy buffer */
+static Word16 find_ener_decrease_fx( /* o : maximum energy ratio Q10*/
+ const Word16 ind_deltaMax, /* i : index of the beginning of maximum energy search Q0*/
+ const Word32 *pt_enr_ssf /* i : Pointer to the energy buffer Qx*/
)
{
Word16 i, j, end, flag;
@@ -74,9 +74,9 @@ static Word16 find_ener_decrease_fx( /* o : maximum
dE2 = 0;
move16();
- j = ind_deltaMax + 2;
+ j = add( ind_deltaMax, 2 ); /* Q0 */
move16();
- end = j + L_ENR;
+ end = add( j, L_ENR );
move16();
maxEnr = L_add( pt_enr_ssf[j], 0 );
j = add( j, 1 );
@@ -87,7 +87,7 @@ static Word16 find_ener_decrease_fx( /* o : maximum
test();
IF( ( GT_32( pt_enr_ssf[i], maxEnr ) ) && ( flag == 0 ) )
{
- maxEnr = L_add( pt_enr_ssf[i], 0 ); /*Q0*/
+ maxEnr = pt_enr_ssf[i]; /* Qx */
j = add( j, 1 );
}
ELSE
@@ -100,25 +100,17 @@ static Word16 find_ener_decrease_fx( /* o : maximum
minEnr = L_add( maxEnr, 0 );
FOR( i = j; i < end; i++ )
{
- minEnr = L_min( minEnr, pt_enr_ssf[i] );
+ minEnr = L_min( minEnr, pt_enr_ssf[i] ); /* Qx */
}
-#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;
}
@@ -130,17 +122,17 @@ static Word16 find_ener_decrease_fx( /* o : maximum
*-------------------------------------------------------------------*/
Word16 find_uv_ivas_fx( /* o : coding type */
Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word16 *T_op_fr, /* i : pointer to adjusted fractional pitch (4 val.) Q6 */
- const Word16 *voicing_fr, /* i : refined correlation for each subframes Q15 */
- const Word16 *speech, /* i : pointer to speech signal for E computation Q_new */
- const Word32 *ee, /* i : lf/hf Energy ratio for present frame Q6 */
- Word32 *dE1X, /* o : sudden energy increase for S/M classifier */
- const Word16 corr_shift, /* i : normalized correlation correction in noise Q15 */
- const Word16 relE, /* i : relative frame energy Q8 */
- const Word16 Etot, /* i : total energy Q8 */
- const Word32 hp_E[], /* i : energy in HF q_hp_E */
- Word16 *flag_spitch, /* i/o: flag to indicate very short stable pitch and high correlation */
- const Word16 last_core_orig, /* i : original last core */
+ const Word16 *T_op_fr, /* i : pointer to adjusted fractional pitch (4 val.) Q6*/
+ const Word16 *voicing_fr, /* i : refined correlation for each subframes Q15*/
+ const Word16 *speech, /* i : pointer to speech signal for E computation Q_new*/
+ const Word32 *ee, /* i : lf/hf Energy ratio for present frame Q6*/
+ Word32 *dE1X, /* o : sudden energy increase for S/M classifier Q13*/
+ const Word16 corr_shift, /* i : normalized correlation correction in noise Q15*/
+ const Word16 relE, /* i : relative frame energy Q8*/
+ const Word16 Etot, /* i : total energy Q8*/
+ const Word32 hp_E[], /* i : energy in HF q_hp_E*/
+ Word16 *flag_spitch, /* i/o: flag to indicate very short stable pitch and high correlation Q0*/
+ const Word16 last_core_orig, /* i : original last core Q0*/
STEREO_CLASSIF_HANDLE hStereoClassif, /* i/o: stereo classifier structure */
const Word16 Q_new,
const Word16 q_hp_E )
@@ -170,9 +162,9 @@ Word16 find_uv_ivas_fx( /* o : coding typ
IF( hSC_VBR != NULL )
{
- Last_Resort = hSC_VBR->Last_Resort;
+ Last_Resort = hSC_VBR->Last_Resort; /* Q0 */
move16();
- vadnoise = hSC_VBR->vadnoise_fx;
+ vadnoise = hSC_VBR->vadnoise_fx; /* Q8 */
move16();
}
ELSE
@@ -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 ) )
{
@@ -233,7 +221,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ
move16();
}
- dE1 = L_max( dE1, fac_32 );
+ dE1 = L_max( dE1, fac_32 ); /* Q13 */
pt_enr_ssf++;
pt_enr_ssf1++;
@@ -243,14 +231,14 @@ Word16 find_uv_ivas_fx( /* o : coding typ
{
IF( st_fx->idchan == 0 )
{
- hStereoClassif->dE1_ch1_fx = dE1;
+ hStereoClassif->dE1_ch1_fx = dE1; /* Q13 */
move32();
hStereoClassif->dE1_ch1_e = 31 - Q13;
move16();
}
ELSE
{
- hStereoClassif->dE1_ch2_fx = dE1;
+ hStereoClassif->dE1_ch2_fx = dE1; /* Q13 */
move32();
hStereoClassif->dE1_ch2_e = 31 - Q13;
move16();
@@ -259,7 +247,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ
if ( dE1X != NULL )
{
- *dE1X = dE1;
+ *dE1X = dE1; /* Q13 */
move32();
}
@@ -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 = L_add_o( L_add_o( st_fx->ee_old_fx, ee[0], &Overflow ), ee[1], &Overflow );
-#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_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 */
+ 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 );
- Ltmp0 = L_mac( Ltmp0, st_fx->voicing_fx[1], 10923 );
-#ifdef BASOP_NOGLOB // -dtx 12650 amrwb\Dtx3.INP
- mean_voi3 = mac_r_sat( Ltmp0, st_fx->voicing_fx[2], 10923 ); /*Q15*/
-#else
- mean_voi3 = mac_r( Ltmp0, st_fx->voicing_fx[2], 10923 ); /*Q15*/
-#endif
+ 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 */
+ mean_voi3 = mac_r_sat( Ltmp0, st_fx->voicing_fx[2], 10923 /* 1/3 in Q15 */ ); /*Q15*/
/*-----------------------------------------------------------------*
* Total frame energy difference (dE3)
*-----------------------------------------------------------------*/
@@ -299,15 +279,11 @@ Word16 find_uv_ivas_fx( /* o : coding typ
move32();
nb_cond = 1;
move16(); /* no additional condition for WB input */
- IF( EQ_16( st_fx->input_bwidth, NB ) )
+ IF( st_fx->input_bwidth == NB )
{
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();
@@ -324,9 +300,9 @@ Word16 find_uv_ivas_fx( /* o : coding typ
{
IF( LT_16( sub( shl( NB_SSF, 1 ), ind_deltaMax ), L_ENR ) )
{
- st_fx->old_ind_deltaMax = ind_deltaMax;
+ st_fx->old_ind_deltaMax = ind_deltaMax; /* Q0 */
move16();
- Copy32( pt_enr_ssf, st_fx->old_enr_ssf_fx, 2 * NB_SSF );
+ Copy32( pt_enr_ssf, st_fx->old_enr_ssf_fx, 2 * NB_SSF ); /* Qx */
}
ELSE
{
@@ -345,8 +321,8 @@ Word16 find_uv_ivas_fx( /* o : coding typ
{
IF( st_fx->old_ind_deltaMax >= 0 )
{
- Copy32( st_fx->old_enr_ssf_fx, enr_ssf, 2 * NB_SSF );
- dE2 = find_ener_decrease_fx( st_fx->old_ind_deltaMax, enr_ssf );
+ Copy32( st_fx->old_enr_ssf_fx, enr_ssf, 2 * NB_SSF ); /* Qx */
+ dE2 = find_ener_decrease_fx( st_fx->old_ind_deltaMax, enr_ssf ); /* Q10 */
if ( GT_32( dE2, dE2_th ) )
{
@@ -366,7 +342,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ
tmp_offset_flag = 1;
move16();
- IF( NE_16( st_fx->input_bwidth, NB ) )
+ IF( st_fx->input_bwidth != NB )
{
ee0_th = 154; /*2.4 in Q6 */
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 */
+ 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 */
{
tmp_offset_flag = 0;
move16();
@@ -419,14 +389,14 @@ Word16 find_uv_ivas_fx( /* o : coding typ
move16();
/* SC-VBR - determine the threshold on relative energy as a function of lp_noise */
- IF( NE_16( st_fx->input_bwidth, NB ) )
+ IF( st_fx->input_bwidth != NB )
{
/*relE_thres = 0.700f * st->lp_noise - 33.5f; (lp_noise in Q8, constant Q8<<16) */
- L_tmp = L_mac( -562036736, 22938, st_fx->lp_noise_fx );
- if ( Last_Resort == 0 )
+ L_tmp = L_mac( -562036736 /* 33.5f in Q24 */, 22938 /* 0.7 in Q15 */, st_fx->lp_noise_fx ); // Q24
+ IF( Last_Resort == 0 )
{
/*relE_thres = 0.650f * st->lp_noise - 33.5f; (lp_noise in Q8, constant Q8<<16)*/
- L_tmp = L_mac( -562036736, 21299, st_fx->lp_noise_fx );
+ L_tmp = L_mac( -562036736 /* 33.5f in Q24 */, 21299 /* 0.650f in Q15 */, st_fx->lp_noise_fx ); // Q24
}
relE_thres = round_fx( L_tmp );
}
@@ -434,10 +404,10 @@ Word16 find_uv_ivas_fx( /* o : coding typ
{
/*relE_thres = 0.60f * st->lp_noise - 28.2f; (lp_noise in Q8, constant Q8<<16)*/
- L_tmp = L_mac( -473117491, 19661, st_fx->lp_noise_fx );
+ L_tmp = L_mac( -473117491 /* 28.2f in Q24 */, 19661 /* 0.6f in Q15 */, st_fx->lp_noise_fx ); // Q24
relE_thres = round_fx( L_tmp );
}
- relE_thres = s_max( relE_thres, -6400 ); /* Q8 */
+ relE_thres = s_max( relE_thres, -6400 /* -25.0f in Q8 */ ); /* Q8 */
/* SC-VBR = set flag on low relative energy */
if ( LT_16( relE, relE_thres ) )
@@ -448,7 +418,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ
/* SC-VBR - correction of voicing threshold for NB inputs (important only in noisy conditions) */
test();
- if ( EQ_16( st_fx->input_bwidth, NB ) && LT_16( vadnoise, 20 << 8 ) ) /* vadnoise in Q8, constant Q0<<8 */
+ if ( st_fx->input_bwidth == NB && LT_16( vadnoise, 20 << 8 ) ) /* vadnoise in Q8, constant Q0<<8 */
{
mean_voi3_offset = 1638; /*0.05f Q15*/
move16();
@@ -458,7 +428,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ
/* make decision whether frame is unvoiced */
coder_type = GENERIC;
move16();
- IF( EQ_16( st_fx->input_bwidth, NB ) )
+ IF( st_fx->input_bwidth == NB )
{
test();
test();
@@ -470,30 +440,16 @@ Word16 find_uv_ivas_fx( /* o : coding typ
test();
test();
test();
- test();
-#ifdef BASOP_NOGLOB
- if ( ( ( LT_16( add_o( mean_voi3, corr_shift, &Overflow ), add( 22282, 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], 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) */
-#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
+ 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... */
+ ( 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 /* 29.0f in Q13 */ ) ) && /* Avoid on sharp energy spikes */
+ ( 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) */
{
coder_type = UNVOICED;
move16();
@@ -510,32 +466,16 @@ Word16 find_uv_ivas_fx( /* o : coding typ
test();
test();
test();
- test();
- test();
- test();
-#ifdef BASOP_NOGLOB
- if ( ( ( LT_16( add_o( mean_voi3, corr_shift, &Overflow ), add( 22774, 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 ) ) && ( 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) */
-#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
+ 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... */
+ ( LT_32( ee[1], 397 /* 6.2f in Q16 */ ) ) && ( 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 /* 30.0f in Q13 */ ) ) && /* Avoid on sharp energy spikes */
+ ( 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) */
{
coder_type = UNVOICED;
move16();
@@ -555,9 +495,9 @@ Word16 find_uv_ivas_fx( /* o : coding typ
test();
IF( EQ_16( st_fx->localVAD, 1 ) && EQ_16( coder_type, GENERIC ) && NE_16( last_core_orig, AMR_WB_CORE ) )
{
- dpit1 = abs_s( sub( T_op_fr[1], T_op_fr[0] ) );
- dpit2 = abs_s( sub( T_op_fr[2], T_op_fr[1] ) );
- dpit3 = abs_s( sub( T_op_fr[3], T_op_fr[2] ) );
+ dpit1 = abs_s( sub( T_op_fr[1], T_op_fr[0] ) ); /* Q6 */
+ dpit2 = abs_s( sub( T_op_fr[2], T_op_fr[1] ) ); /* Q6 */
+ dpit3 = abs_s( sub( T_op_fr[3], T_op_fr[2] ) ); /* Q6 */
test();
test();
@@ -568,11 +508,11 @@ Word16 find_uv_ivas_fx( /* o : coding typ
test();
test();
test();
- IF( ( GT_16( voicing_fr[0], 19825 ) ) && /* normalized correlation high in 1st sf. */
- ( GT_16( voicing_fr[1], 19825 ) ) && /* normalized correlation high in 2st sf. */
- ( GT_16( voicing_fr[2], 19825 ) ) && /* normalized correlation high in 3st sf. */
- ( GT_16( voicing_fr[3], 19825 ) ) && /* normalized correlation high in 4st sf. */
- ( GT_32( mean_ee, 256 ) ) && /* energy concentrated in low frequencies */
+ IF( ( GT_16( voicing_fr[0], 19825 /* 0.605 in Q15 */ ) ) && /* normalized correlation high in 1st sf. */
+ ( GT_16( voicing_fr[1], 19825 /* 0.605 in Q15 */ ) ) && /* normalized correlation high in 2st sf. */
+ ( GT_16( voicing_fr[2], 19825 /* 0.605 in Q15 */ ) ) && /* normalized correlation high in 3st sf. */
+ ( GT_16( voicing_fr[3], 19825 /* 0.605 in Q15 */ ) ) && /* normalized correlation high in 4st sf. */
+ ( GT_32( mean_ee, 256 /* 4.0f in Q6 */ ) ) && /* energy concentrated in low frequencies */
( LT_16( dpit1, 3 << 6 ) ) &&
( LT_16( dpit2, 3 << 6 ) ) &&
( LT_16( dpit3, 3 << 6 ) ) )
@@ -580,7 +520,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ
coder_type = VOICED;
move16();
}
- ELSE IF( st_fx->Opt_SC_VBR && EQ_16( st_fx->input_bwidth, NB ) && LT_16( vadnoise, 20 << 8 ) )
+ ELSE IF( st_fx->Opt_SC_VBR && st_fx->input_bwidth == NB && LT_16( vadnoise, 20 << 8 ) )
{
test();
test();
@@ -589,11 +529,11 @@ Word16 find_uv_ivas_fx( /* o : coding typ
test();
test();
test();
- IF( GT_16( voicing_fr[0], 8192 ) && /* normalized correlation high in 1st sf. */
- ( GT_16( voicing_fr[1], 8192 ) ) && /* normalized correlation high in 2st sf. */
- ( GT_16( voicing_fr[2], 8192 ) ) && /* normalized correlation high in 3st sf. */
- ( GT_16( voicing_fr[3], 8192 ) ) && /* normalized correlation high in 4st sf. */
- ( GT_32( mean_ee, 64 ) ) && /* energy concentrated in low frequencies */
+ IF( GT_16( voicing_fr[0], 8192 /* 0.25 in Q15 */ ) && /* normalized correlation high in 1st sf. */
+ ( GT_16( voicing_fr[1], 8192 /* 0.25 in Q15 */ ) ) && /* normalized correlation high in 2st sf. */
+ ( GT_16( voicing_fr[2], 8192 /* 0.25 in Q15 */ ) ) && /* normalized correlation high in 3st sf. */
+ ( GT_16( voicing_fr[3], 8192 /* 0.25 in Q15 */ ) ) && /* normalized correlation high in 4st sf. */
+ ( GT_32( mean_ee, 64 /* 1.0f in Q6 */ ) ) && /* energy concentrated in low frequencies */
( LT_16( dpit1, 5 << 6 ) ) &&
( LT_16( dpit2, 5 << 6 ) ) &&
( LT_16( dpit3, 5 << 6 ) ) )
@@ -607,14 +547,14 @@ Word16 find_uv_ivas_fx( /* o : coding typ
/* set VOICED mode for frames with very stable pitch and high correlation
and avoid to switch to AUDIO/MUSIC later */
- voicing_m = mac_r( L_mac( L_mac( L_mult( voicing_fr[3], 8192 ), voicing_fr[2], 8192 ), voicing_fr[1], 8192 ), voicing_fr[0], 8192 );
+ voicing_m = mac_r( L_mac( L_mac( L_mult( voicing_fr[3], 8192 /* 0.25 in Q15 */ ), voicing_fr[2], 8192 /* 0.25 in Q15 */ ), voicing_fr[1], 8192 /* 0.25 in Q15 */ ), voicing_fr[0], 8192 /* 0.25 in Q15 */ ); /* Q15 */
test();
test();
test();
test();
test();
IF( *flag_spitch || ( LE_16( dpit1, 3 << 6 ) && LE_16( dpit2, 3 << 6 ) && LE_16( dpit3, 3 << 6 ) &&
- GT_16( voicing_m, 31130 ) && GT_16( st_fx->voicing_sm_fx, 31785 ) ) )
+ GT_16( voicing_m, 31130 /* 0.95f in Q15 */ ) && GT_16( st_fx->voicing_sm_fx, 31785 /* 0.97f in Q15 */ ) ) )
{
coder_type = VOICED;
move16();
@@ -627,7 +567,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ
* Channel-aware mode - set RF mode and total bitrate
*-----------------------------------------------------------------*/
- st_fx->rf_mode = st_fx->Opt_RF_ON;
+ st_fx->rf_mode = st_fx->Opt_RF_ON; /* Q0 */
move16();
IF( EQ_16( coder_type, GENERIC ) )
@@ -636,11 +576,11 @@ Word16 find_uv_ivas_fx( /* o : coding typ
test();
test();
test();
- IF( ( LT_16( voicing_fr[0], 6554 ) ) && /* normalized correlation high in 2st sf. */
- ( LT_16( voicing_fr[1], 6554 ) ) && /* normalized correlation high in 2st sf. */
- ( LT_16( voicing_fr[2], 6554 ) ) && /* normalized correlation high in 3rd sf. */
- ( LT_16( voicing_fr[3], 6554 ) ) && /* normalized correlation high in 4th sf. */
- ( GT_16( vadnoise, 25 << 8 ) ) ) /* when speech is clean */
+ IF( ( LT_16( voicing_fr[0], 6554 /* 0.2f in Q15 */ ) ) && /* normalized correlation high in 2st sf. */
+ ( LT_16( voicing_fr[1], 6554 /* 0.2f in Q15 */ ) ) && /* normalized correlation high in 2st sf. */
+ ( LT_16( voicing_fr[2], 6554 /* 0.2f in Q15 */ ) ) && /* normalized correlation high in 3rd sf. */
+ ( LT_16( voicing_fr[3], 6554 /* 0.2f in Q15 */ ) ) && /* normalized correlation high in 4th sf. */
+ ( GT_16( vadnoise, 25 << 8 ) ) ) /* when speech is clean */
{
st_fx->rf_mode = 0;
@@ -685,7 +625,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ
test();
if ( st_fx->spike_hyst >= 0 && LT_16( st_fx->spike_hyst, 2 ) )
{
- st_fx->spike_hyst = add( st_fx->spike_hyst, 1 );
+ st_fx->spike_hyst = add( st_fx->spike_hyst, 1 ); /* Q0 */
move16();
}
@@ -694,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( 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
+ ( 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 */
{
st_fx->spike_hyst = -1;
move16();
@@ -712,7 +648,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ
move32(); /*Q13*/
/* save the raw coder_type for various modules later in the codec (the reason is that e.g. UNVOICED is lost at higher rates) */
- st_fx->coder_type_raw = coder_type;
+ st_fx->coder_type_raw = coder_type; /* Q0 */
move16();
return coder_type;
diff --git a/lib_enc/find_uv_fx.c b/lib_enc/find_uv_fx.c
index 778e7b51a80dbabf5cc77cdc978df6cfbed03b26..3f4c8abc7103221d0b9558cfe49d893e531b23ce 100644
--- a/lib_enc/find_uv_fx.c
+++ b/lib_enc/find_uv_fx.c
@@ -23,9 +23,9 @@
* energy is trailing off after a spike
*-------------------------------------------------------------------*/
-static Word16 find_ener_decrease_fx( /* o : maximum energy ratio Q10 */
- const Word16 ind_deltaMax, /* i : index of the beginning of maximum energy search */
- const Word32 *pt_enr_ssf /* i : Pointer to the energy buffer */
+static Word16 find_ener_decrease_fx( /* o : maximum energy ratio Q10*/
+ const Word16 ind_deltaMax, /* i : index of the beginning of maximum energy search Q0*/
+ const Word32 *pt_enr_ssf /* i : Pointer to the energy buffer Qx*/
)
{
Word16 i, j, end, flag;
@@ -34,6 +34,7 @@ static Word16 find_ener_decrease_fx( /* o : maximum
Word16 dE2, exp0, exp1;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
dE2 = 0;
@@ -52,7 +53,7 @@ static Word16 find_ener_decrease_fx( /* o : maximum
test();
IF( ( GT_32( pt_enr_ssf[i], maxEnr ) ) && ( flag == 0 ) )
{
- maxEnr = L_add( pt_enr_ssf[i], 0 ); /*Q0*/
+ maxEnr = L_add( pt_enr_ssf[i], 0 ); /*Qx*/
j = add( j, 1 );
}
ELSE
@@ -65,25 +66,17 @@ static Word16 find_ener_decrease_fx( /* o : maximum
minEnr = L_add( maxEnr, 0 );
FOR( i = j; i < end; i++ )
{
- minEnr = L_min( minEnr, pt_enr_ssf[i] );
+ minEnr = L_min( minEnr, pt_enr_ssf[i] ); /* Qx */
}
-#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;
}
@@ -94,23 +87,23 @@ static Word16 find_ener_decrease_fx( /* o : maximum
* Decision about coder type
*-------------------------------------------------------------------*/
-Word16 find_uv_fx( /* o : coding type */
- Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word16 *T_op_fr, /* i : pointer to adjusted fractional pitch (4 val.) Q6*/
- const Word16 *voicing_fr, /* i : refined correlation for each subframes Q15*/
- const Word16 *speech, /* i : pointer to speech signal for E computation Q_new*/
- const Word32 *ee, /* i : lf/hf Energy ratio for present frame Q6*/
+Word16 find_uv_fx( /* o : coding type */
+ Encoder_State *st_fx, /* i/o: encoder state structure */
+ const Word16 *T_op_fr, /* i : pointer to adjusted fractional pitch (4 val.) Q6*/
+ const Word16 *voicing_fr, /* i : refined correlation for each subframes Q15*/
+ const Word16 *speech, /* i : pointer to speech signal for E computation Q_new*/
+ const Word32 *ee, /* i : lf/hf Energy ratio for present frame Q6*/
#ifdef IVAS_CODE
Word32 *dE1X, /* o : sudden energy increase for S/M classifier */
#endif
- const Word16 corr_shift, /* i : normalized correlation correction in noise Q15*/
- const Word16 relE, /* i : relative frame energy Q8*/
- const Word16 Etot, /* i : total energy Q8*/
- const Word32 hp_E[], /* i : energy in HF Q_new + Q_SCALE*/
+ const Word16 corr_shift, /* i : normalized correlation correction in noise Q15*/
+ const Word16 relE, /* i : relative frame energy Q8*/
+ const Word16 Etot, /* i : total energy Q8*/
+ const Word32 hp_E[], /* i : energy in HF Q_new + Q_SCALE*/
const Word16 Q_new,
- Word16 *flag_spitch, /* i/o: flag to indicate very short stable pitch and high correlation */
+ Word16 *flag_spitch, /* i/o: flag to indicate very short stable pitch and high correlation Q0*/
const Word16 shift,
- const Word16 last_core_orig /* i : original last core */
+ const Word16 last_core_orig /* i : original last core Q0*/
#ifdef IVAS_CODE
,
STEREO_CLASSIF_HANDLE hStereoClassif /* i/o: stereo classifier structure */
@@ -135,6 +128,7 @@ Word16 find_uv_fx( /* o : coding type
SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
Word16 Last_Resort;
@@ -142,13 +136,17 @@ Word16 find_uv_fx( /* o : coding type
IF( hSC_VBR != NULL )
{
- Last_Resort = hSC_VBR->Last_Resort;
+ Last_Resort = hSC_VBR->Last_Resort; /* Q0 */
vadnoise = hSC_VBR->vadnoise_fx;
+ move16();
+ move16();
}
ELSE
{
Last_Resort = 0;
vadnoise = 0;
+ move16();
+ move16();
}
Q_in = sub( Q_new, 1 );
@@ -163,7 +161,7 @@ Word16 find_uv_fx( /* o : coding type
*-----------------------------------------------------------------*/
/* Find maximum energy per short subblocks */
- pt_speech = speech - SSF;
+ pt_speech = speech - SSF; /* Q_new */
pt_enr_ssf = enr_ssf + 2 * NB_SSF;
FOR( i = 0; i < 2 * ( NB_SSF + 1 ); i++ )
{
@@ -191,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 ) )
{
@@ -203,7 +197,7 @@ Word16 find_uv_fx( /* o : coding type
move16();
}
- dE1 = L_max( dE1, fac_32 );
+ dE1 = L_max( dE1, fac_32 ); /* Q13 */
pt_enr_ssf++;
pt_enr_ssf1++;
@@ -232,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 = L_add_o( L_add_o( st_fx->ee_old_fx, ee[0], &Overflow ), ee[1], &Overflow );
-#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_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 */
+ 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 );
- Ltmp0 = L_mac( Ltmp0, st_fx->voicing_fx[1], 10923 );
-#ifdef BASOP_NOGLOB // -dtx 12650 amrwb\Dtx3.INP
- mean_voi3 = mac_r_sat( Ltmp0, st_fx->voicing_fx[2], 10923 ); /*Q15*/
-#else
- mean_voi3 = mac_r( Ltmp0, st_fx->voicing_fx[2], 10923 ); /*Q15*/
-#endif
+ 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 */
+ mean_voi3 = mac_r_sat( Ltmp0, st_fx->voicing_fx[2], 10923 /* 1/3 in Q15 */ ); /*Q15*/
/*-----------------------------------------------------------------*
* Total frame energy difference (dE3)
*-----------------------------------------------------------------*/
@@ -267,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 ) ) /*( mean_voi3 + corr_shift ) >= 0.68f*/
-#else
- if ( GE_16( add( mean_voi3, corr_shift ), 22282 ) ) /*( mean_voi3 + corr_shift ) >= 0.68f*/
-#endif
+ if ( GE_16( add_o( mean_voi3, corr_shift, &Overflow ), 22282 /* 0.68 in Q15 */ ) ) /*( mean_voi3 + corr_shift ) >= 0.68f*/
{
nb_cond = 0;
move16();
@@ -288,9 +270,9 @@ Word16 find_uv_fx( /* o : coding type
{
IF( LT_16( sub( shl( NB_SSF, 1 ), ind_deltaMax ), L_ENR ) )
{
- st_fx->old_ind_deltaMax = ind_deltaMax;
+ st_fx->old_ind_deltaMax = ind_deltaMax; /* Q0 */
move16();
- Copy32( pt_enr_ssf, st_fx->old_enr_ssf_fx, 2 * NB_SSF );
+ Copy32( pt_enr_ssf, st_fx->old_enr_ssf_fx, 2 * NB_SSF ); /* Qx */
}
ELSE
{
@@ -309,8 +291,8 @@ Word16 find_uv_fx( /* o : coding type
{
IF( st_fx->old_ind_deltaMax >= 0 )
{
- Copy32( st_fx->old_enr_ssf_fx, enr_ssf, 2 * NB_SSF );
- dE2 = find_ener_decrease_fx( st_fx->old_ind_deltaMax, enr_ssf );
+ Copy32( st_fx->old_enr_ssf_fx, enr_ssf, 2 * NB_SSF ); /* Qx */
+ dE2 = find_ener_decrease_fx( st_fx->old_ind_deltaMax, enr_ssf ); /* Q10 */
if ( GT_32( dE2, dE2_th ) )
{
@@ -348,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();
@@ -382,11 +358,11 @@ Word16 find_uv_fx( /* o : coding type
IF( NE_16( st_fx->input_bwidth, NB ) )
{
/*relE_thres = 0.700f * st->lp_noise - 33.5f; (lp_noise in Q8, constant Q8<<16) */
- L_tmp = L_mac( -562036736, 22938, st_fx->lp_noise_fx );
+ L_tmp = L_mac( -562036736 /* 33.5f in Q24 */, 22938 /* 0.7 in Q15 */, st_fx->lp_noise_fx ); // Q24
if ( Last_Resort == 0 )
{
/*relE_thres = 0.650f * st->lp_noise - 33.5f; (lp_noise in Q8, constant Q8<<16)*/
- L_tmp = L_mac( -562036736, 21299, st_fx->lp_noise_fx );
+ L_tmp = L_mac( -562036736 /* 33.5f in Q24 */, 21299 /* 0.650f in Q15 */, st_fx->lp_noise_fx ); // Q24
}
relE_thres = round_fx( L_tmp );
}
@@ -394,10 +370,10 @@ Word16 find_uv_fx( /* o : coding type
{
/*relE_thres = 0.60f * st->lp_noise - 28.2f; (lp_noise in Q8, constant Q8<<16)*/
- L_tmp = L_mac( -473117491, 19661, st_fx->lp_noise_fx );
+ L_tmp = L_mac( -473117491 /* 28.2f in Q24 */, 19661 /* 0.6f in Q15 */, st_fx->lp_noise_fx ); // Q24
relE_thres = round_fx( L_tmp );
}
- relE_thres = s_max( relE_thres, -6400 ); /* Q8 */
+ relE_thres = s_max( relE_thres, -6400 /* -25.0f in Q8 */ ); /* Q8 */
/* SC-VBR = set flag on low relative energy */
if ( LT_16( relE, relE_thres ) )
@@ -432,29 +408,16 @@ 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, 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], 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) */
-#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
+ 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... */
+ ( 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 /* 29.0f in Q13 */ ) ) && /* Avoid on sharp energy spikes */
+ ( 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) */
{
coder_type = UNVOICED;
move16();
@@ -474,29 +437,16 @@ 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, mean_voi3_offset ) ) ) && /* normalized correlation low */
- ( LT_16( add_sat( 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) */
-#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
+ 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... */
+ ( LT_32( ee[1], 397 /* 6.2f in Q6 */ ) ) && ( 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 /* 30.0f in Q13 */ ) ) && /* Avoid on sharp energy spikes */
+ ( 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) */
{
coder_type = UNVOICED;
move16();
@@ -516,9 +466,9 @@ Word16 find_uv_fx( /* o : coding type
test();
IF( EQ_16( st_fx->localVAD, 1 ) && EQ_16( coder_type, GENERIC ) && NE_16( last_core_orig, AMR_WB_CORE ) )
{
- dpit1 = abs_s( sub( T_op_fr[1], T_op_fr[0] ) );
- dpit2 = abs_s( sub( T_op_fr[2], T_op_fr[1] ) );
- dpit3 = abs_s( sub( T_op_fr[3], T_op_fr[2] ) );
+ dpit1 = abs_s( sub( T_op_fr[1], T_op_fr[0] ) ); // Q6
+ dpit2 = abs_s( sub( T_op_fr[2], T_op_fr[1] ) ); // Q6
+ dpit3 = abs_s( sub( T_op_fr[3], T_op_fr[2] ) ); // Q6
test();
test();
@@ -529,11 +479,11 @@ Word16 find_uv_fx( /* o : coding type
test();
test();
test();
- IF( ( GT_16( voicing_fr[0], 19825 ) ) && /* normalized correlation high in 1st sf. */
- ( GT_16( voicing_fr[1], 19825 ) ) && /* normalized correlation high in 2st sf. */
- ( GT_16( voicing_fr[2], 19825 ) ) && /* normalized correlation high in 3st sf. */
- ( GT_16( voicing_fr[3], 19825 ) ) && /* normalized correlation high in 4st sf. */
- ( GT_32( mean_ee, 256 ) ) && /* energy concentrated in low frequencies */
+ IF( ( GT_16( voicing_fr[0], 19825 /* 0.605 in Q15 */ ) ) && /* normalized correlation high in 1st sf. */
+ ( GT_16( voicing_fr[1], 19825 /* 0.605 in Q15 */ ) ) && /* normalized correlation high in 2st sf. */
+ ( GT_16( voicing_fr[2], 19825 /* 0.605 in Q15 */ ) ) && /* normalized correlation high in 3st sf. */
+ ( GT_16( voicing_fr[3], 19825 /* 0.605 in Q15 */ ) ) && /* normalized correlation high in 4st sf. */
+ ( GT_32( mean_ee, 256 /* 4.0f in Q6 */ ) ) && /* energy concentrated in low frequencies */
( LT_16( dpit1, 3 << 6 ) ) &&
( LT_16( dpit2, 3 << 6 ) ) &&
( LT_16( dpit3, 3 << 6 ) ) )
@@ -550,11 +500,11 @@ Word16 find_uv_fx( /* o : coding type
test();
test();
test();
- IF( GT_16( voicing_fr[0], 8192 ) && /* normalized correlation high in 1st sf. */
- ( GT_16( voicing_fr[1], 8192 ) ) && /* normalized correlation high in 2st sf. */
- ( GT_16( voicing_fr[2], 8192 ) ) && /* normalized correlation high in 3st sf. */
- ( GT_16( voicing_fr[3], 8192 ) ) && /* normalized correlation high in 4st sf. */
- ( GT_32( mean_ee, 64 ) ) && /* energy concentrated in low frequencies */
+ IF( GT_16( voicing_fr[0], 8192 /* 0.25 in Q15 */ ) && /* normalized correlation high in 1st sf. */
+ ( GT_16( voicing_fr[1], 8192 /* 0.25 in Q15 */ ) ) && /* normalized correlation high in 2st sf. */
+ ( GT_16( voicing_fr[2], 8192 /* 0.25 in Q15 */ ) ) && /* normalized correlation high in 3st sf. */
+ ( GT_16( voicing_fr[3], 8192 /* 0.25 in Q15 */ ) ) && /* normalized correlation high in 4st sf. */
+ ( GT_32( mean_ee, 64 ) ) && /* energy concentrated in low frequencies */
( LT_16( dpit1, 5 << 6 ) ) &&
( LT_16( dpit2, 5 << 6 ) ) &&
( LT_16( dpit3, 5 << 6 ) ) )
@@ -568,14 +518,14 @@ Word16 find_uv_fx( /* o : coding type
/* set VOICED mode for frames with very stable pitch and high correlation
and avoid to switch to AUDIO/MUSIC later */
- voicing_m = mac_r( L_mac( L_mac( L_mult( voicing_fr[3], 8192 ), voicing_fr[2], 8192 ), voicing_fr[1], 8192 ), voicing_fr[0], 8192 );
+ voicing_m = mac_r( L_mac( L_mac( L_mult( voicing_fr[3], 8192 /* 0.25 in Q15 */ ), voicing_fr[2], 8192 /* 0.25 in Q15 */ ), voicing_fr[1], 8192 /* 0.25 in Q15 */ ), voicing_fr[0], 8192 /* 0.25 in Q15 */ );
test();
test();
test();
test();
test();
IF( *flag_spitch || ( LE_16( dpit1, 3 << 6 ) && LE_16( dpit2, 3 << 6 ) && LE_16( dpit3, 3 << 6 ) &&
- GT_16( voicing_m, 31130 ) && GT_16( st_fx->voicing_sm_fx, 31785 ) ) )
+ GT_16( voicing_m, 31130 /* 0.95f in Q15 */ ) && GT_16( st_fx->voicing_sm_fx, 31785 /* 0.97f in Q15 */ ) ) )
{
coder_type = VOICED;
move16();
@@ -588,7 +538,7 @@ Word16 find_uv_fx( /* o : coding type
* Channel-aware mode - set RF mode and total bitrate
*-----------------------------------------------------------------*/
- st_fx->rf_mode = st_fx->Opt_RF_ON;
+ st_fx->rf_mode = st_fx->Opt_RF_ON; /* Q0 */
move16();
IF( EQ_16( coder_type, GENERIC ) )
@@ -597,11 +547,11 @@ Word16 find_uv_fx( /* o : coding type
test();
test();
test();
- IF( ( LT_16( voicing_fr[0], 6554 ) ) && /* normalized correlation high in 2st sf. */
- ( LT_16( voicing_fr[1], 6554 ) ) && /* normalized correlation high in 2st sf. */
- ( LT_16( voicing_fr[2], 6554 ) ) && /* normalized correlation high in 3rd sf. */
- ( LT_16( voicing_fr[3], 6554 ) ) && /* normalized correlation high in 4th sf. */
- ( GT_16( vadnoise, 25 << 8 ) ) ) /* when speech is clean */
+ IF( ( LT_16( voicing_fr[0], 6554 /* 0.2f in Q15 */ ) ) && /* normalized correlation high in 2st sf. */
+ ( LT_16( voicing_fr[1], 6554 /* 0.2f in Q15 */ ) ) && /* normalized correlation high in 2st sf. */
+ ( LT_16( voicing_fr[2], 6554 /* 0.2f in Q15 */ ) ) && /* normalized correlation high in 3rd sf. */
+ ( LT_16( voicing_fr[3], 6554 /* 0.2f in Q15 */ ) ) && /* normalized correlation high in 4th sf. */
+ ( GT_16( vadnoise, 25 << 8 ) ) ) /* when speech is clean */
{
st_fx->rf_mode = 0;
@@ -641,7 +591,7 @@ Word16 find_uv_fx( /* o : coding type
test();
if ( st_fx->spike_hyst >= 0 && LT_16( st_fx->spike_hyst, 2 ) )
{
- st_fx->spike_hyst = add( st_fx->spike_hyst, 1 );
+ st_fx->spike_hyst = add( st_fx->spike_hyst, 1 ); /* Q0 */
}
/* reset spike hysteresis */
@@ -649,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/find_wsp.c b/lib_enc/find_wsp.c
index 9ba0a3c0764e86263dd28cebfe9af965e82e59a4..00729bde0ca3e5ac6d67d4ebf4fe522f504bb94e 100644
--- a/lib_enc/find_wsp.c
+++ b/lib_enc/find_wsp.c
@@ -41,14 +41,14 @@
#include "wmc_auto.h"
#include "prot_fx.h"
/*-------------------------------------------------------------------*
- * find_wsp()
+ * ivas_find_wsp_fx()
*
* Compute weighted speech used in open-loop pitch search
*-------------------------------------------------------------------*/
-void ivas_find_wsp(
- const Word16 L_frame, /* i : length of the frame */
- const Word16 L_subfr, /* i : length of subframe */
- const Word16 nb_subfr, /* i : number of subframes */
+void ivas_find_wsp_fx(
+ const Word16 L_frame, /* i : length of the frame Q0*/
+ const Word16 L_subfr, /* i : length of subframe Q0*/
+ const Word16 nb_subfr, /* i : number of subframes Q0*/
const Word16 *A_fx,
/* i : A(z) filter coefficients */ // Q12
Word16 *Aw_fx,
@@ -63,7 +63,7 @@ void ivas_find_wsp(
/* i/o: W(Z) denominator memory */ // Q_new
const Word16 gamma,
/* i : weighting factor */ // Q15
- const Word16 L_look /* i : look-ahead */
+ const Word16 L_look /* i : look-ahead Q0*/
)
{
Word16 *p_Aw_fx, tmp_fx;
@@ -79,7 +79,7 @@ void ivas_find_wsp(
* Compute weighted speech for all subframes
*-----------------------------------------------------------------*/
p_Aw_fx = Aw_fx;
- for ( i_subfr = 0; i_subfr < L_frame; i_subfr += L_subfr )
+ FOR( i_subfr = 0; i_subfr < L_frame; i_subfr += L_subfr )
{
Residu3_fx( p_Aw_fx, &speech_fx[i_subfr], &wsp_fx[i_subfr], L_subfr, 0 );
p_Aw_fx += ( M + 1 );
diff --git a/lib_enc/find_wsp_fx.c b/lib_enc/find_wsp_fx.c
index de81f19214e626801376295422c993120a79672c..7468c3dc77c5fd6064b8665f05a46dbb5e6c806b 100644
--- a/lib_enc/find_wsp_fx.c
+++ b/lib_enc/find_wsp_fx.c
@@ -31,17 +31,17 @@
* void
*/
void find_wsp_fx(
- const Word16 Az[], /* i : A(z) filter coefficients */
- const Word16 speech[], /* i : pointer to the denoised speech frame */
- Word16 wsp[], /* o : poitnter to the weighted speech frame */
- Word16 *mem_wsp, /* i/o: W(Z) denominator memory */
- const Word16 preemph_fac, /* i : pre - emphasis factor Q15 */
- const Word16 L_frame, /* i : length of the frame */
- const Word16 lookahead, /* i : look-ahead */
- const Word16 L_subfr, /* i : length of subframe */
- Word16 *Aw, /* o : weighted A(z) filter coefficients */
- const Word16 gamma, /* i : weighting factor */
- const Word16 nb_subfr /* i : number of subframes */
+ const Word16 Az[], /* i : A(z) filter coefficients Q12*/
+ const Word16 speech[], /* i : pointer to the denoised speech frame Q_new-preemph_bits*/
+ Word16 wsp[], /* o : poitnter to the weighted speech frame Q_new-preemph_bits*/
+ Word16 *mem_wsp, /* i/o: W(Z) denominator memory Q_new-preemph_bits*/
+ const Word16 preemph_fac, /* i : pre - emphasis factor Q15*/
+ const Word16 L_frame, /* i : length of the frame Q0*/
+ const Word16 lookahead, /* i : look-ahead Q0*/
+ const Word16 L_subfr, /* i : length of subframe Q0*/
+ Word16 *Aw, /* o : weighted A(z) filter coefficients Q12*/
+ const Word16 gamma, /* i : weighting factor Q15*/
+ const Word16 nb_subfr /* i : number of subframes Q0*/
)
{
Word16 i_subfr, wtmp;
diff --git a/lib_enc/frame_spec_dif_cor_rate_fx.c b/lib_enc/frame_spec_dif_cor_rate_fx.c
index 117ced6baf87ef4209f4d88104b659e4b4c84856..3e2eb40155f5e006eda820818db061688d9d2299 100644
--- a/lib_enc/frame_spec_dif_cor_rate_fx.c
+++ b/lib_enc/frame_spec_dif_cor_rate_fx.c
@@ -20,10 +20,10 @@
*
*-------------------------------------------------------------------*/
void frame_spec_dif_cor_rate_fx(
- VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */
- Word32 *spec_amp, /* i : spectral amplitude*/
- Word16 sacle, /* i : the scaling of spec_amp*/
- Word16 f_tonality_rate[3] /* o : tonality rate*/
+ VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */
+ Word32 *spec_amp, /* i : spectral amplitude scale*/
+ Word16 sacle, /* i : the scaling of spec_amp */
+ Word16 f_tonality_rate[3] /* o : tonality rate Qx*/
)
{
@@ -36,22 +36,23 @@ void frame_spec_dif_cor_rate_fx(
Word32 m, dx, dy;
Word16 *pre_spec_low_dif = hVAD_CLDFB->pre_spec_low_dif;
const Word32 FIX_cost1 = 2147484 /* 0.001f Q31 */;
-
+ move16();
+ move32();
p_dx_Q = &dx_Q;
maxVal = 0;
move32();
FOR( i = 0; i < PRE_SPEC_DIF_NUM; i++ )
{
- tmp = L_sub( spec_amp[i + 6], spec_amp[i + 5] );
+ tmp = L_sub( spec_amp[i + 6], spec_amp[i + 5] ); /* scale */
if ( tmp < 0 )
{
tmp = 0;
move32();
}
- tmpspec_low_dif[i] = tmp;
+ tmpspec_low_dif[i] = tmp; /* scale */
move32();
- maxVal = L_max( maxVal, tmp );
+ maxVal = L_max( maxVal, tmp ); /* scale */
}
resu = 31;
move16();
@@ -71,14 +72,14 @@ void frame_spec_dif_cor_rate_fx(
FOR( i = 0; i < PRE_SPEC_DIF_NUM; i++ )
{
- spec_low_dif_tmp = round_fx( L_shl( tmpspec_low_dif[i], scalefactor ) );
- m = L_mac0( m, spec_low_dif_tmp, pre_spec_low_dif[i] );
- dx = L_mac0( dx, spec_low_dif_tmp, spec_low_dif_tmp );
- dy = L_mac0( dy, pre_spec_low_dif[i], pre_spec_low_dif[i] );
+ spec_low_dif_tmp = round_fx( L_shl( tmpspec_low_dif[i], scalefactor ) ); /* scale + scalefactor - 16 */
+ m = L_mac0( m, spec_low_dif_tmp, pre_spec_low_dif[i] ); /* scale + scalefactor - 16 + hVAD_CLDFB->scale_spec_low_dif */
+ dx = L_mac0( dx, spec_low_dif_tmp, spec_low_dif_tmp ); /* scale + scalefactor - 16 + hVAD_CLDFB->scale_spec_low_dif */
+ dy = L_mac0( dy, pre_spec_low_dif[i], pre_spec_low_dif[i] ); /* scale + scalefactor - 16 */
pre_spec_low_dif[i] = spec_low_dif_tmp;
move16();
}
- dx = L_mult0( round_fx( dx ), round_fx( dy ) );
+ dx = L_mult0( round_fx( dx ), round_fx( dy ) ); /* 2 * (scale + scalefactor - 16 + hVAD_CLDFB->scale_spec_low_dif) - 32 */
tmpq = add( sacle, scalefactor );
tmpq = sub( tmpq, 16 );
tmpq2 = add( tmpq, hVAD_CLDFB->scale_spec_low_dif );
@@ -88,11 +89,11 @@ void frame_spec_dif_cor_rate_fx(
move16();
IF( LT_16( *p_dx_Q, 31 ) )
{
- dx = L_add( dx, L_shr( FIX_cost1, limitScale32( sub( 31, *p_dx_Q ) ) ) );
+ dx = L_add( dx, L_shr( FIX_cost1, limitScale32( sub( 31, *p_dx_Q ) ) ) ); /* 2 * (scale + scalefactor - 16 + hVAD_CLDFB->scale_spec_low_dif) - 32 */
}
ELSE
{
- dx = L_add( L_shr( dx, limitScale32( sub( *p_dx_Q, 31 ) ) ), FIX_cost1 );
+ dx = L_add( L_shr( dx, limitScale32( sub( *p_dx_Q, 31 ) ) ), FIX_cost1 ); /* Q31 */
*p_dx_Q = 31;
move16();
}
@@ -110,10 +111,10 @@ void frame_spec_dif_cor_rate_fx(
f_tonality_rate[0] = spec_dif_cor_rate;
move16();
- tmp = L_mac0( L_mult0( f_tonality_rate[1], 31456 /* 0.96 Q15 */ ), spec_dif_cor_rate, 1311 /* 0.04 Q15 */ );
+ tmp = L_mac0( L_mult0( f_tonality_rate[1], 31456 /* 0.96 Q15 */ ), spec_dif_cor_rate, 1311 /* 0.04 Q15 */ ); /* tmpq */
f_tonality_rate[1] = shl( round_fx( tmp ), 1 );
move16();
- tmp = L_mac0( L_mult0( f_tonality_rate[2], 29490 /* 0.90 Q15 */ ), spec_dif_cor_rate, 3277 /* 0.1 Q15 */ );
+ tmp = L_mac0( L_mult0( f_tonality_rate[2], 29490 /* 0.90 Q15 */ ), spec_dif_cor_rate, 3277 /* 0.1 Q15 */ ); /* tmpq */
f_tonality_rate[2] = shl( round_fx( tmp ), 1 );
move16();
hVAD_CLDFB->scale_spec_low_dif = tmpq;
diff --git a/lib_enc/gain_enc_fx.c b/lib_enc/gain_enc_fx.c
index 30caee67e01193ed958623185ab36ec51ea19e42..162fc41fa62738ea3379513ff32d59279984efc9 100644
--- a/lib_enc/gain_enc_fx.c
+++ b/lib_enc/gain_enc_fx.c
@@ -50,14 +50,14 @@ static Word16 Find_Opt_gainQ_fx( Word16 *coeff, Word16 *exp_coeff, Word16 *gain_
/*==========================================================================*/
void Es_pred_enc_fx(
- Word16 *Es_pred, /* o : predicited scaled innovation energy Q8 */
- Word16 *indice, /* o : indice of quantization */
- const Word16 L_frame, /* i : length of the frame */
- const Word16 *res, /* i : residual signal */
- const Word16 *voicing, /* i : normalized correlation in three 1/2frames */
- const Word16 nb_bits, /* i : allocated number of bits */
- const Word16 no_ltp, /* i : no_ltp flag */
- Word16 Q_new /* i : Scaling in speech Q0 */
+ Word16 *Es_pred, /* o : predicited scaled innovation energy Q8*/
+ Word16 *indice, /* o : indice of quantization Q0*/
+ const Word16 L_frame, /* i : length of the frame Q0*/
+ const Word16 *res, /* i : residual signal Q_new*/
+ const Word16 *voicing, /* i : normalized correlation in three 1/2frames Q15*/
+ const Word16 nb_bits, /* i : allocated number of bits Q0*/
+ const Word16 no_ltp, /* i : no_ltp flag Q0*/
+ Word16 Q_new /* i : Scaling in speech Q0*/
)
{
Word16 i, i_subfr, size, tmp16, tmp16_2, Q_res;
@@ -67,6 +67,7 @@ void Es_pred_enc_fx(
Word32 ener_fx, Lmean_ener_code, Ltmp;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
Lmean_ener_code = L_deposit_l( 0 );
@@ -90,16 +91,12 @@ void Es_pred_enc_fx(
FOR( i_subfr = 0; i_subfr < L_frame; i_subfr += L_SUBFR )
{
/* calculate the energy of residual signal */
- tmp16 = mult_r( res[i_subfr + 0], 8192 ); /* remove 2bits */
+ tmp16 = mult_r( res[i_subfr + 0], 8192 /* 1 in Q13 */ ); /* remove 2bits Q_new - 2*/
ener_fx = L_mult( tmp16, tmp16 );
FOR( i = 1; i < L_SUBFR; i++ )
{
- tmp16 = mult_r( res[i_subfr + i], 8192 ); /* remove 2bits */
-#ifdef BASOP_NOGLOB
+ tmp16 = mult_r( res[i_subfr + i], 8192 /* 1 in Q13 */ ); /* remove 2bits Q_new - 2*/
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) */
@@ -119,6 +116,7 @@ void Es_pred_enc_fx(
if ( ( ener_dB < 0 ) && ( no_ltp == 0 ) )
{
ener_dB = 0;
+ move16();
}
/* update the average energy of residual signal */
@@ -142,22 +140,22 @@ void Es_pred_enc_fx(
{
case 5:
{
- qua_table = Es_pred_qua_5b_fx;
+ qua_table = Es_pred_qua_5b_fx; // Q8
BREAK;
}
case 4:
{
- qua_table = Es_pred_qua_4b_fx;
+ qua_table = Es_pred_qua_4b_fx; // Q8
BREAK;
}
case 3:
{
- qua_table = Es_pred_qua_3b_fx;
+ qua_table = Es_pred_qua_3b_fx; // Q8
BREAK;
}
default:
{
- qua_table = Es_pred_qua_5b_fx;
+ qua_table = Es_pred_qua_5b_fx; // Q8
BREAK;
}
}
@@ -166,13 +164,13 @@ void Es_pred_enc_fx(
{
mean_ener_code16 = extract_h( Lmean_ener_code ); /*Q8*/
- qua_table = Es_pred_qua_4b_no_ltp_fx;
+ qua_table = Es_pred_qua_4b_no_ltp_fx; // Q8
}
/*size = extract_l(pow2_fx[nb_bits]); */ /*maximum number of bit is 6 */
size = shl( 1, nb_bits ); /*maximum number of bit is 6 */
/* find the nearest neighbour (codevector) */
- *Es_pred = qua_table[0];
+ *Es_pred = qua_table[0]; // Q8
move16();
tmp16 = abs_s( sub( mean_ener_code16, qua_table[0] ) );
*indice = 0;
@@ -180,18 +178,14 @@ 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;
move16();
*indice = i;
move16();
- *Es_pred = qua_table[i];
+ *Es_pred = qua_table[i]; // Q8
move16();
}
}
@@ -209,24 +203,24 @@ void Es_pred_enc_fx(
* - the mean-squared weighted error criterion is used for codebook search
*---------------------------------------------------------------------*/
void gain_enc_mless_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const Word16 gains_mode[], /* i : gain bits */
- const Word16 element_mode, /* i : element mode */
- const Word16 L_frame, /* i : length of the frame */
- const Word16 i_subfr, /* i : subframe index */
- const Word16 tc_subfr, /* i : TC subframe index */
- const Word16 *xn, /* i : target vector */
- const Word16 *y1, /* i : zero-memory filtered adaptive excitation */
- const Word16 Q_xn, /* i : xn and y1 scaling */
- const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation */
- const Word16 *code, /* i : algebraic excitation */
- const Word16 Es_pred, /* i : predicted scaled innovation energy */
- Word16 *gain_pit, /* o : quantized pitch gain */
- Word32 *gain_code, /* o : quantized codebook gain */
- Word16 *gain_inov, /* o : gain of the innovation (used for normalization) */
- Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation */
- Word16 *g_corr, /* i/o: correlations , -2,, -2 and 2 */
- const Word16 clip_gain /* i : gain pitch clipping flag (1 = clipping) */
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ const Word16 gains_mode[], /* i : gain bits Q0*/
+ const Word16 element_mode, /* i : element mode Q0*/
+ const Word16 L_frame, /* i : length of the frame Q0*/
+ const Word16 i_subfr, /* i : subframe index Q0*/
+ const Word16 tc_subfr, /* i : TC subframe index Q0*/
+ const Word16 *xn, /* i : target vector Q_xn*/
+ const Word16 *y1, /* i : zero-memory filtered adaptive excitation Q_xn*/
+ const Word16 Q_xn, /* i : xn and y1 scaling */
+ const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9*/
+ const Word16 *code, /* i : algebraic excitation Q9*/
+ const Word16 Es_pred, /* i : predicted scaled innovation energy Q8*/
+ Word16 *gain_pit, /* o : quantized pitch gain Q14*/
+ Word32 *gain_code, /* o : quantized codebook gain Q16*/
+ Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/
+ Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/
+ Word16 *g_corr, /* i/o: correlations , -2,, -2 and 2 Qx*/
+ const Word16 clip_gain /* i : gain pitch clipping flag (1 = clipping) Q0*/
)
{
@@ -242,6 +236,7 @@ void gain_enc_mless_fx(
Word32 L_frac_num, L_frac_den, L_div;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/*-----------------------------------------------------------------*
@@ -304,6 +299,7 @@ void gain_enc_mless_fx(
/* 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)) */
/*----------------------------------------------------------------*
@@ -325,7 +321,7 @@ void gain_enc_mless_fx(
* select the codebook, size and number of bits
* set the gains searching range
*-----------------------------------------------------------------*/
- nBits = gains_mode[shr( i_subfr, 6 )];
+ nBits = gains_mode[i_subfr >> 6];
move16();
test();
@@ -364,9 +360,9 @@ void gain_enc_mless_fx(
}
L_frac_den = L_sub( L_tmp1, L_tmp2 ); /*Q31*/
- frac_den = extract_h( L_frac_den );
- frac_den = s_max( frac_den, 1 );
- L_frac_den = L_max( L_frac_den, 1 );
+ frac_den = extract_h( L_frac_den ); /* Q15 */
+ frac_den = s_max( frac_den, 1 ); /* Q15 */
+ L_frac_den = L_max( L_frac_den, 1 ); /* Q31 */
exp = norm_l( L_frac_den );
tmp = div_s( shl( 1, sub( 14, exp ) ), frac_den ); /*Q(14-exp)*/
@@ -393,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] );
@@ -409,25 +401,24 @@ void gain_enc_mless_fx(
{
L_tmp2 = L_shr( L_tmp2, sub( exp1, exp2 ) ); /*Q31*/
exp_num = exp1;
+ move16();
}
ELSE
{
L_tmp1 = L_shr( L_tmp1, sub( exp2, exp1 ) ); /*Q31*/
exp_num = exp2;
+ move16();
}
L_frac_num = L_sub( L_tmp1, L_tmp2 ); /*Q31*/
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 ) );
+ move16();
/* set number of bits for two SQs */
nBits2 = shr( add( nBits, 1 ), 1 );
@@ -447,16 +438,13 @@ void gain_enc_mless_fx(
tmp = div_s( 16384, gcode0 ); /*Q15*/
L_tmp = Mult_32_16( *gain_code, tmp ); /*Q16*/
*gain_code = L_shr( L_tmp, add( 14, exp_gcode0 ) ); /*Q16*/
+ move32();
}
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
{
@@ -477,12 +465,12 @@ void gain_enc_mless_fx(
case 6:
{
qua_table = gain_qua_mless_6b_fx;
- if ( GT_16( element_mode, EVS_MONO ) )
+ if ( element_mode > EVS_MONO )
{
#ifdef IVAS_CODE
qua_table = gain_qua_mless_6b_stereo;
#else
- // PMTE()
+ // PMTE()
#endif
}
move16();
@@ -494,7 +482,7 @@ void gain_enc_mless_fx(
}
case 5:
{
- qua_table = gain_qua_mless_5b_fx;
+ qua_table = gain_qua_mless_5b_fx; // Q14
move16();
if ( EQ_16( clip_gain, 1 ) )
{
@@ -504,7 +492,7 @@ void gain_enc_mless_fx(
}
default:
{
- qua_table = gain_qua_mless_6b_fx;
+ qua_table = gain_qua_mless_6b_fx; // Q14
move16();
if ( EQ_16( clip_gain, 1 ) )
{
@@ -525,7 +513,7 @@ void gain_enc_mless_fx(
/*-----------------------------------------------------------------*
* search for the best quantizer
*-----------------------------------------------------------------*/
- index = Find_Opt_gainQ_fx( coeff, exp_coeff, gain_pit, gain_code, gcode0, exp_gcode0, qua_table, size );
+ index = Find_Opt_gainQ_fx( coeff, exp_coeff, gain_pit, gain_code, gcode0, exp_gcode0, qua_table, size ); // Q0
push_indice_fx( hBstr, IND_GAIN, index, nBits );
}
@@ -541,24 +529,24 @@ void gain_enc_mless_fx(
}
void gain_enc_mless_ivas_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const Word16 gains_mode[], /* i : gain bits */
- const Word16 element_mode, /* i : element mode */
- const Word16 L_frame, /* i : length of the frame */
- const Word16 i_subfr, /* i : subframe index */
- const Word16 tc_subfr, /* i : TC subframe index */
- const Word16 *xn, /* i : target vector */
- const Word16 *y1, /* i : zero-memory filtered adaptive excitation */
- const Word16 Q_xn, /* i : xn and y1 scaling */
- const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation */
- const Word16 *code, /* i : algebraic excitation */
- const Word16 Es_pred, /* i : predicted scaled innovation energy */
- Word16 *gain_pit, /* o : quantized pitch gain */
- Word32 *gain_code, /* o : quantized codebook gain */
- Word16 *gain_inov, /* o : gain of the innovation (used for normalization) */
- Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation */
- Word16 *g_corr, /* i/o: correlations , -2,, -2 and 2 */
- const Word16 clip_gain /* i : gain pitch clipping flag (1 = clipping) */
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ const Word16 gains_mode[], /* i : gain bits Q0*/
+ const Word16 element_mode, /* i : element mode Q0*/
+ const Word16 L_frame, /* i : length of the frame Q0*/
+ const Word16 i_subfr, /* i : subframe index Q0*/
+ const Word16 tc_subfr, /* i : TC subframe index Q0*/
+ const Word16 *xn, /* i : target vector Q_xn*/
+ const Word16 *y1, /* i : zero-memory filtered adaptive excitation Q_xn*/
+ const Word16 Q_xn, /* i : xn and y1 scaling */
+ const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9*/
+ const Word16 *code, /* i : algebraic excitation Q9*/
+ const Word16 Es_pred, /* i : predicted scaled innovation energy Q8*/
+ Word16 *gain_pit, /* o : quantized pitch gain Q14*/
+ Word32 *gain_code, /* o : quantized codebook gain Q16*/
+ Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/
+ Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/
+ Word16 *g_corr, /* i/o: correlations , -2,, -2 and 2 Qx*/
+ const Word16 clip_gain /* i : gain pitch clipping flag (1 = clipping) Q0*/
)
{
@@ -574,6 +562,7 @@ void gain_enc_mless_ivas_fx(
Word32 L_frac_num, L_frac_den, L_div;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/*-----------------------------------------------------------------*
@@ -613,30 +602,44 @@ void gain_enc_mless_ivas_fx(
/* gain_inov = 1.0f / sqrt((dot_product(code, code, L_SUBFR) + 0.01) / L_SUBFR) */
L_tmp = Dot_product12( code, code, L_SUBFR, &exp_code );
exp_inov = sub( exp_code, 18 + 6 );
- exp_code = sub( exp_code, 30 );
- /*Ei = 10 * log10((dot_product(code, code, L_SUBFR) + 0.01) / L_SUBFR) */
+ // To avoid crash in case code value is 0,
+ IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( L_tmp, exp_inov, 21474836, 0 ), -1 ) )
+ {
+ // 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 );
- /*----------------------------------------------------------------*
- * 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 */
+ /*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 */
+
+ /*---------------------------------------------------------------*
+ * 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 */
-
/* gcode0 = pow(10, 0.05 * (Es_pred - Ei)) */
/*----------------------------------------------------------------*
* gcode0 = pow(10.0, gcode0/20)
@@ -657,7 +660,7 @@ void gain_enc_mless_ivas_fx(
* select the codebook, size and number of bits
* set the gains searching range
*-----------------------------------------------------------------*/
- nBits = gains_mode[shr( i_subfr, 6 )];
+ nBits = gains_mode[i_subfr >> 6];
move16();
test();
@@ -696,9 +699,9 @@ void gain_enc_mless_ivas_fx(
}
L_frac_den = L_sub( L_tmp1, L_tmp2 ); /*Q31*/
- frac_den = extract_h( L_frac_den );
- frac_den = s_max( frac_den, 1 );
- L_frac_den = L_max( L_frac_den, 1 );
+ frac_den = extract_h( L_frac_den ); /* Q15 */
+ frac_den = s_max( frac_den, 1 ); /* Q15 */
+ L_frac_den = L_max( L_frac_den, 1 ); /* Q31 */
exp = norm_l( L_frac_den );
tmp = div_s( shl( 1, sub( 14, exp ) ), frac_den ); /*Q(14-exp)*/
@@ -725,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] );
@@ -741,22 +740,20 @@ void gain_enc_mless_ivas_fx(
{
L_tmp2 = L_shr( L_tmp2, sub( exp1, exp2 ) ); /*Q31*/
exp_num = exp1;
+ move16();
}
ELSE
{
L_tmp1 = L_shr( L_tmp1, sub( exp2, exp1 ) ); /*Q31*/
exp_num = exp2;
+ move16();
}
L_frac_num = L_sub( L_tmp1, L_tmp2 ); /*Q31*/
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 ) );
@@ -779,16 +776,13 @@ void gain_enc_mless_ivas_fx(
tmp = div_s( 16384, gcode0 ); /*Q15*/
L_tmp = Mult_32_16( *gain_code, tmp ); /*Q16*/
*gain_code = L_shr( L_tmp, add( 14, exp_gcode0 ) ); /*Q16*/
+ move32();
}
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
{
@@ -798,8 +792,7 @@ void gain_enc_mless_ivas_fx(
{
case 7:
{
- qua_table = gain_qua_mless_7b_fx;
- move16();
+ qua_table = gain_qua_mless_7b_fx; // Q14
if ( EQ_16( clip_gain, 1 ) )
{
size = sub( size, 30 );
@@ -808,12 +801,11 @@ void gain_enc_mless_ivas_fx(
}
case 6:
{
- qua_table = gain_qua_mless_6b_fx;
- if ( GT_16( element_mode, EVS_MONO ) )
+ qua_table = gain_qua_mless_6b_fx; // Q14
+ if ( element_mode > EVS_MONO )
{
qua_table = gain_qua_mless_6b_stereo_fx;
}
- move16();
if ( EQ_16( clip_gain, 1 ) )
{
size = sub( size, 14 );
@@ -822,8 +814,7 @@ void gain_enc_mless_ivas_fx(
}
case 5:
{
- qua_table = gain_qua_mless_5b_fx;
- move16();
+ qua_table = gain_qua_mless_5b_fx; // Q14
if ( EQ_16( clip_gain, 1 ) )
{
size = sub( size, 6 );
@@ -832,8 +823,7 @@ void gain_enc_mless_ivas_fx(
}
default:
{
- qua_table = gain_qua_mless_6b_fx;
- move16();
+ qua_table = gain_qua_mless_6b_fx; // Q14
if ( EQ_16( clip_gain, 1 ) )
{
size = sub( size, 14 );
@@ -862,7 +852,7 @@ void gain_enc_mless_ivas_fx(
exp = s_max( exp, 0 );
tmp = div_s( shr( 8192, exp ), *gain_inov );
- *norm_gain_code = L_shr( Mult_32_16( *gain_code, tmp ), sub( 1, exp ) );
+ *norm_gain_code = L_shr( Mult_32_16( *gain_code, tmp ), sub( 1, exp ) ); // Q16
move32();
return;
@@ -880,21 +870,21 @@ void gain_enc_mless_ivas_fx(
*---------------------------------------------------------------------*/
void gain_enc_SQ_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const Word16 gains_mode[], /* i : gain bits */
- const Word16 i_subfr, /* i : subframe index */
- const Word16 *xn, /* i : target vector Q_xn */
- const Word16 *yy1, /* i : zero-memory filtered adaptive excitation Q_xn */
- const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9 */
- const Word16 *code, /* i : algebraic excitation Q9 */
- const Word16 Es_pred, /* i : predicted scaled innovation energy Q8 */
- Word16 *gain_pit, /* o : quantized pitch gain Q14 */
- Word32 *gain_code, /* o : quantized codebook gain Q16 */
- Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12 */
- Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16 */
- Word16 *g_corr, /* i/o: correlations , ,, -2 and 2 */
- const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) */
- const Word16 Q_xn /* i : xn and y1 scaling */
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ const Word16 gains_mode[], /* i : gain bits Q0*/
+ const Word16 i_subfr, /* i : subframe index Q0*/
+ const Word16 *xn, /* i : target vector Q_xn*/
+ const Word16 *yy1, /* i : zero-memory filtered adaptive excitation Q_xn*/
+ const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9*/
+ const Word16 *code, /* i : algebraic excitation Q9*/
+ const Word16 Es_pred, /* i : predicted scaled innovation energy Q8*/
+ Word16 *gain_pit, /* o : quantized pitch gain Q14*/
+ Word32 *gain_code, /* o : quantized codebook gain Q16*/
+ Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/
+ Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/
+ Word16 *g_corr, /* i/o: correlations , ,, -2 and 2 Qx*/
+ const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) Q0*/
+ const Word16 Q_xn /* i : xn and y1 scaling */
)
{
Word16 index, nBits_pitch, nBits_code;
@@ -909,6 +899,7 @@ void gain_enc_SQ_fx(
Word32 L_frac_num, L_frac_den, L_div;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/*-----------------------------------------------------------------*
@@ -931,16 +922,19 @@ void gain_enc_SQ_fx(
/* Compute scalar product */
coeff[2] = extract_h( Dot_product12( y2, y2, L_SUBFR, &exp ) );
+ move16();
exp_coeff[2] = add( sub( exp, 18 ), shl( Q_xn, 1 ) );
move16(); /* -18 (y2 Q9) */
/* Compute scalar product */
coeff[3] = extract_h( Dot_product12( xn, y2, L_SUBFR, &exp ) );
+ move16();
exp_coeff[3] = add( sub( exp, 9 ), Q_xn );
move16(); /* -9 (y2 Q9), (xn y2) */
/* Compute scalar product */
coeff[4] = extract_h( Dot_product12( yy1, y2, L_SUBFR, &exp ) );
+ move16();
exp_coeff[4] = add( sub( exp, 9 ), Q_xn );
move16(); /* -9 (y2 Q9), (y1 y2) */
@@ -1010,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 ) )
@@ -1031,9 +1021,9 @@ void gain_enc_SQ_fx(
}
L_frac_den = L_sub( L_tmp1, L_tmp2 ); /*Q31*/
- frac_den = extract_h( L_frac_den );
- frac_den = s_max( frac_den, 1 );
- L_frac_den = L_max( L_frac_den, 1 );
+ frac_den = extract_h( L_frac_den ); /* Q15 */
+ frac_den = s_max( frac_den, 1 ); /* Q15 */
+ L_frac_den = L_max( L_frac_den, 1 ); /* Q31 */
exp = norm_l( L_frac_den );
tmp = div_s( shl( 1, sub( 14, exp ) ), frac_den ); /*Q(14-exp)*/
@@ -1056,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] );
@@ -1081,26 +1063,20 @@ void gain_enc_SQ_fx(
{
L_tmp2 = L_shr( L_tmp2, sub( exp1, exp2 ) ); /*Q31*/
exp_num = exp1;
+ move16();
}
ELSE
{
L_tmp1 = L_shr( L_tmp1, sub( exp2, exp1 ) ); /*Q31*/
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 ) );
@@ -1111,14 +1087,14 @@ void gain_enc_SQ_fx(
test();
test();
- IF( EQ_16( clip_gain, 1 ) && GT_16( *gain_pit, 15565 ) )
+ IF( EQ_16( clip_gain, 1 ) && GT_16( *gain_pit, 15565 /* 0.95 in Q14 */ ) )
{
- *gain_pit = 15565;
+ *gain_pit = 15565; /* 0.95 in Q14 */
move16();
}
- ELSE IF( EQ_16( clip_gain, 2 ) && GT_16( *gain_pit, 10650 ) )
+ ELSE IF( EQ_16( clip_gain, 2 ) && GT_16( *gain_pit, 10650 /* 0.65 in Q14 */ ) )
{
- *gain_pit = 10650;
+ *gain_pit = 10650; /* 0.65 in Q14 */
move16();
}
@@ -1126,7 +1102,8 @@ void gain_enc_SQ_fx(
* search for the best quantized values
*-----------------------------------------------------------------*/
- nBits_pitch = gains_mode[shr( i_subfr, 6 )];
+ nBits_pitch = gains_mode[i_subfr >> 6];
+ move16();
/* set number of bits for two SQs */
nBits_code = shr( add( nBits_pitch, 1 ), 1 );
@@ -1136,8 +1113,7 @@ void gain_enc_SQ_fx(
/*tmp1 = (G_PITCH_MAX - G_PITCH_MIN) / ((1 << nBits_pitch) - 1);*/ /* set quantization step */
tmp1 = mult_r( G_PITCH_MAX_Q13, div_s( 1, sub( shl( 1, nBits_pitch ), 1 ) ) ); /*Q13*/ /* set quantization step */
- index = usquant_fx( *gain_pit, gain_pit, G_PITCH_MIN_Q14, tmp1, shl( 1, nBits_pitch ) );
- move16();
+ index = usquant_fx( *gain_pit, gain_pit, G_PITCH_MIN_Q14, tmp1, shl( 1, nBits_pitch ) ); // Q0
push_indice_fx( hBstr, IND_GAIN_PIT, index, nBits_pitch );
/* gain_code Q */
@@ -1147,16 +1123,13 @@ void gain_enc_SQ_fx(
tmp = div_s( 16384, gcode0 ); /*Q15*/
L_tmp = Mult_32_16( *gain_code, tmp ); /*Q16*/
*gain_code = L_shr( L_tmp, add( 14, exp_gcode0 ) ); /*Q16*/
+ move32();
}
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; */
@@ -1164,28 +1137,28 @@ void gain_enc_SQ_fx(
exp = s_max( exp, 0 );
tmp = div_s( shr( 8192, exp ), *gain_inov );
- *norm_gain_code = L_shr( Mult_32_16( *gain_code, tmp ), sub( 1, exp ) );
+ *norm_gain_code = L_shr( Mult_32_16( *gain_code, tmp ), sub( 1, exp ) ); // Q16
move32();
return;
}
void gain_enc_SQ_ivas_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const Word16 gains_mode[], /* i : gain bits */
- const Word16 i_subfr, /* i : subframe index */
- const Word16 *xn, /* i : target vector Q_xn */
- const Word16 *yy1, /* i : zero-memory filtered adaptive excitation Q_xn */
- const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9 */
- const Word16 *code, /* i : algebraic excitation Q9 */
- const Word16 Es_pred, /* i : predicted scaled innovation energy Q8 */
- Word16 *gain_pit, /* o : quantized pitch gain Q14 */
- Word32 *gain_code, /* o : quantized codebook gain Q16 */
- Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12 */
- Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16 */
- Word16 *g_corr, /* i/o: correlations , ,, -2 and 2 */
- const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) */
- const Word16 Q_xn /* i : xn and y1 scaling */
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ const Word16 gains_mode[], /* i : gain bits Q0*/
+ const Word16 i_subfr, /* i : subframe index Q0*/
+ const Word16 *xn, /* i : target vector Q_xn*/
+ const Word16 *yy1, /* i : zero-memory filtered adaptive excitation Q_xn*/
+ const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9*/
+ const Word16 *code, /* i : algebraic excitation Q9*/
+ const Word16 Es_pred, /* i : predicted scaled innovation energy Q8*/
+ Word16 *gain_pit, /* o : quantized pitch gain Q14*/
+ Word32 *gain_code, /* o : quantized codebook gain Q16*/
+ Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/
+ Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/
+ Word16 *g_corr, /* i/o: correlations , ,, -2 and 2 Qx*/
+ const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) Q0*/
+ const Word16 Q_xn /* i : xn and y1 scaling */
)
{
Word16 index, nBits_pitch, nBits_code;
@@ -1200,6 +1173,7 @@ void gain_enc_SQ_ivas_fx(
Word32 L_frac_num, L_frac_den, L_div;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/*-----------------------------------------------------------------*
@@ -1222,16 +1196,19 @@ void gain_enc_SQ_ivas_fx(
/* Compute scalar product */
coeff[2] = extract_h( Dot_product12( y2, y2, L_SUBFR, &exp ) );
+ move16();
exp_coeff[2] = add( sub( exp, 18 ), shl( Q_xn, 1 ) );
move16(); /* -18 (y2 Q9) */
/* Compute scalar product */
coeff[3] = extract_h( Dot_product12( xn, y2, L_SUBFR, &exp ) );
+ move16();
exp_coeff[3] = add( sub( exp, 9 ), Q_xn );
move16(); /* -9 (y2 Q9), (xn y2) */
/* Compute scalar product */
coeff[4] = extract_h( Dot_product12( yy1, y2, L_SUBFR, &exp ) );
+ move16();
exp_coeff[4] = add( sub( exp, 9 ), Q_xn );
move16(); /* -9 (y2 Q9), (y1 y2) */
@@ -1301,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 ) )
@@ -1322,9 +1295,9 @@ void gain_enc_SQ_ivas_fx(
}
L_frac_den = L_sub( L_tmp1, L_tmp2 ); /*Q31*/
- frac_den = extract_h( L_frac_den );
- frac_den = s_max( frac_den, 1 );
- L_frac_den = L_max( L_frac_den, 1 );
+ frac_den = extract_h( L_frac_den ); /* Q15 */
+ frac_den = s_max( frac_den, 1 ); /* Q15 */
+ L_frac_den = L_max( L_frac_den, 1 ); /* Q31 */
exp = norm_l( L_frac_den );
tmp = div_s( shl( 1, sub( 14, exp ) ), frac_den ); /*Q(14-exp)*/
@@ -1347,27 +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*/
-#else /* BASOP_NOGLOB */
- *gain_pit = round_fx( L_shl( L_div, add( exp, exp_div ) ) ); /*Q14*/
-#endif /* BASOP_NOGLOB */
+ move16();
// 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*/
@@ -1377,26 +1339,20 @@ void gain_enc_SQ_ivas_fx(
{
L_tmp2 = L_shr( L_tmp2, sub( exp1, exp2 ) ); /*Q31*/
exp_num = exp1;
+ move16();
}
ELSE
{
L_tmp1 = L_shr( L_tmp1, sub( exp2, exp1 ) ); /*Q31*/
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 ) );
@@ -1407,14 +1363,14 @@ void gain_enc_SQ_ivas_fx(
test();
test();
- IF( EQ_16( clip_gain, 1 ) && GT_16( *gain_pit, 15565 ) )
+ IF( EQ_16( clip_gain, 1 ) && GT_16( *gain_pit, 15565 /* 0.95 in Q14 */ ) )
{
- *gain_pit = 15565;
+ *gain_pit = 15565; /* 0.95 in Q14 */
move16();
}
- ELSE IF( EQ_16( clip_gain, 2 ) && GT_16( *gain_pit, 10650 ) )
+ ELSE IF( EQ_16( clip_gain, 2 ) && GT_16( *gain_pit, 10650 /* 0.65 in Q14 */ ) )
{
- *gain_pit = 10650;
+ *gain_pit = 10650; /* 0.65 in Q14 */
move16();
}
@@ -1422,7 +1378,8 @@ void gain_enc_SQ_ivas_fx(
* search for the best quantized values
*-----------------------------------------------------------------*/
- nBits_pitch = gains_mode[shr( i_subfr, 6 )];
+ nBits_pitch = gains_mode[i_subfr >> 6];
+ move16();
/* set number of bits for two SQs */
nBits_code = shr( add( nBits_pitch, 1 ), 1 );
@@ -1433,7 +1390,6 @@ void gain_enc_SQ_ivas_fx(
tmp1 = mult_r( G_PITCH_MAX_Q13, div_s( 1, sub( shl( 1, nBits_pitch ), 1 ) ) ); /*Q13*/ /* set quantization step */
index = usquant_fx( *gain_pit, gain_pit, G_PITCH_MIN_Q14, tmp1, shl( 1, nBits_pitch ) );
- move16();
push_indice( hBstr, IND_GAIN_PIT, index, nBits_pitch );
/* gain_code Q */
@@ -1443,16 +1399,13 @@ void gain_enc_SQ_ivas_fx(
tmp = div_s( 16384, gcode0 ); /*Q15*/
L_tmp = Mult_32_16( *gain_code, tmp ); /*Q16*/
*gain_code = L_shr( L_tmp, add( 14, exp_gcode0 ) ); /*Q16*/
+ move32();
}
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; */
@@ -1460,7 +1413,7 @@ void gain_enc_SQ_ivas_fx(
exp = s_max( exp, 0 );
tmp = div_s( shr( 8192, exp ), *gain_inov );
- *norm_gain_code = L_shr( Mult_32_16( *gain_code, tmp ), sub( 1, exp ) );
+ *norm_gain_code = L_shr( Mult_32_16( *gain_code, tmp ), sub( 1, exp ) ); // Q16
move32();
return;
@@ -1471,12 +1424,12 @@ void gain_enc_SQ_ivas_fx(
*
* Quantization of gain for Gaussian codebook
*-------------------------------------------------------------------*/
-Word16 gain_enc_gaus_fx( /* o : Return index of quantization */
- Word32 *gain, /* i/o: Code gain to quantize */
- const Word16 bits, /* i : number of bits to quantize */
- const Word16 lowBound, /* i : lower bound of quantizer (dB) Q8 */
- const Word16 stepSize, /* i : Step size choice Q14 */
- const Word16 inv_stepSize /* i : Step size choice Q15 */
+Word16 gain_enc_gaus_fx( /* o : Return index of quantization */
+ Word32 *gain, /* i/o: Code gain to quantize Q16*/
+ const Word16 bits, /* i : number of bits to quantize Q0*/
+ const Word16 lowBound, /* i : lower bound of quantizer (dB) Q8*/
+ const Word16 stepSize, /* i : Step size choice Q14*/
+ const Word16 inv_stepSize /* i : Step size choice Q15*/
)
{
Word16 index, exp_gain, frac_gain, wtmp;
@@ -1484,6 +1437,7 @@ Word16 gain_enc_gaus_fx( /* o : Return index of quant
Word32 Ltmp, enr;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/*enr = 20.0 * log10(*gain + 0.001) codebook gain in dB */
exp_gain = norm_l( *gain );
@@ -1499,10 +1453,10 @@ Word16 gain_enc_gaus_fx( /* o : Return index of quant
wtmp = sub( wenr, lowBound ); /* Q8 */
- index = extract_l( L_shr( L_mac( 8388608, wtmp, inv_stepSize ), 16 + 8 ) );
+ index = extract_l( L_shr( L_mac( 8388608, wtmp, inv_stepSize ), 16 + 8 ) ); // Q0
/* index [0 (1< 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 );
}
@@ -1714,24 +1660,24 @@ void gain_enc_tc_fx(
expg = s_max( expg, 0 );
tmp_fx = div_s( shr( 8192, expg ), *gain_inov_fx );
- *norm_gain_code_fx = L_shr( Mult_32_16( *gain_code_fx, tmp_fx ), sub( 1, expg ) );
+ *norm_gain_code_fx = L_shr( Mult_32_16( *gain_code_fx, tmp_fx ), sub( 1, expg ) ); // Q16
move32();
return;
}
void gain_enc_tc_ivas_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const Word16 gains_mode[], /* i : gain bits */
- const Word16 i_subfr, /* i : subframe index */
- const Word16 xn_fx[], /* i : target vector */
- const Word16 y2_fx[], /* i : zero-memory filtered algebraic codebook excitation */
- const Word16 code_fx[], /* i : algebraic excitation */
- const Word16 Es_pred_fx, /* i : predicted scaled innovation energy */
- Word16 *gain_pit_fx, /* o : Pitch gain / Quantized pitch gain */
- Word32 *gain_code_fx, /* o : quantized codebook gain */
- Word16 *gain_inov_fx, /* o : innovation gain */
- Word32 *norm_gain_code_fx, /* o : norm. gain of the codebook excitation */
- const Word16 Q_xn /* i : xn and y1 scaling Q0 */
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ const Word16 gains_mode[], /* i : gain bits Q0*/
+ const Word16 i_subfr, /* i : subframe index Q0*/
+ const Word16 xn_fx[], /* i : target vector Q_xn*/
+ const Word16 y2_fx[], /* i : zero-memory filtered algebraic codebook excitation Q_xn*/
+ const Word16 code_fx[], /* i : algebraic excitation Q9*/
+ const Word16 Es_pred_fx, /* i : predicted scaled innovation energy Q8*/
+ Word16 *gain_pit_fx, /* o : Pitch gain / Quantized pitch gain Q14*/
+ Word32 *gain_code_fx, /* o : quantized codebook gain Q16*/
+ Word16 *gain_inov_fx, /* o : innovation gain Q12*/
+ Word32 *norm_gain_code_fx, /* o : norm. gain of the codebook excitation Q6*/
+ const Word16 Q_xn /* i : xn and y1 scaling */
)
{
Word16 i, index = 0, nBits, num, den, exp_num, exp_den;
@@ -1741,10 +1687,14 @@ void gain_enc_tc_ivas_fx(
Word16 wgain_code = 0, gain_code16;
*gain_pit_fx = 0;
move16();
+ move16();
+ move16();
+
/*----------------------------------------------------------------*
* get number of bits for gain quantization
*----------------------------------------------------------------*/
- nBits = gains_mode[shr( i_subfr, 6 )];
+ nBits = gains_mode[i_subfr >> 6]; // Q0
+ move16();
/*----------------------------------------------------------------*
* find the code pitch (for current subframe)
@@ -1771,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
- *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
+ 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 */
move32();
/*----------------------------------------------------------------*
@@ -1828,6 +1774,7 @@ void gain_enc_tc_ivas_fx(
tmp16 = div_s( 16384, gcode0_fx ); /*Q15*/
L_tmp = Mult_32_16( *gain_code_fx, tmp16 ); /*Q16*/
*gain_code_fx = L_shr( L_tmp, add( 14, exp_gcode0 ) ); /*Q16*/
+ move32();
}
ELSE
{
@@ -1868,7 +1815,7 @@ void gain_enc_tc_ivas_fx(
{
/* 2-bit -> 3-bit decoding */
index = shr( index, 1 );
- wgain_code = tbl_gain_code_tc_fx[shl( index, 1 )];
+ wgain_code = tbl_gain_code_tc_fx[index * 2]; // Q13
move16();
/**gain_code *= gcode0;*/
L_tmp = L_mult( wgain_code, gcode0_fx ); /* Q13*Q0 -> Q14 */
@@ -1878,15 +1825,11 @@ void gain_enc_tc_ivas_fx(
}
ELSE /* nBits == 3 */
{
- wgain_code = tbl_gain_code_tc_fx[index];
+ wgain_code = tbl_gain_code_tc_fx[index]; // Q13
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 );
}
@@ -1900,7 +1843,7 @@ void gain_enc_tc_ivas_fx(
expg = s_max( expg, 0 );
tmp_fx = div_s( shr( 8192, expg ), *gain_inov_fx );
- *norm_gain_code_fx = L_shr( Mult_32_16( *gain_code_fx, tmp_fx ), sub( 1, expg ) );
+ *norm_gain_code_fx = L_shr( Mult_32_16( *gain_code_fx, tmp_fx ), sub( 1, expg ) ); // Q6
move32();
return;
}
@@ -1910,14 +1853,14 @@ void gain_enc_tc_ivas_fx(
* Find the best quantizer
*-----------------------------------------------------------------*/
static Word16 Find_Opt_gainQ_fx(
- Word16 *coeff,
+ Word16 *coeff, /* exp(exp_coeff) */
Word16 *exp_coeff,
- Word16 *gain_pit,
- Word32 *gain_code,
- Word16 gcode0,
+ Word16 *gain_pit, /* Q14 */
+ Word32 *gain_code, /* Q16 */
+ Word16 gcode0, /* exp(exp_gcode0) */
Word16 exp_gcode0,
- const Word16 *cdbk, /* i : Codebook used */
- const Word16 size /* i : size of Codebook used */
+ const Word16 *cdbk, /* i : Codebook used Q14*/
+ const Word16 size /* i : size of Codebook used Q0*/
)
{
Word16 index, i, j;
@@ -1930,6 +1873,7 @@ static Word16 Find_Opt_gainQ_fx(
Word32 L_tmp, L_tmp1;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
@@ -1993,7 +1937,7 @@ static Word16 Find_Opt_gainQ_fx(
}
/* searching of codebook */
- p = cdbk;
+ p = cdbk; // Q14
move16();
dist_min = L_deposit_h( MAX_16 );
index = 0;
@@ -2005,8 +1949,8 @@ static Word16 Find_Opt_gainQ_fx(
g_code = *p++;
move16();
- g_code = mult_r( g_code, gcode0 );
- g2_pitch = mult_r( g_pitch, g_pitch );
+ g_code = mult_r( g_code, gcode0 ); // exp_gcode - 1
+ g2_pitch = mult_r( g_pitch, g_pitch ); // Q13
g_pit_cod = mult_r( g_code, g_pitch );
L_tmp = L_mult( g_code, g_code );
g2_code_lo = L_Extract_lc( L_tmp, &g2_code );
@@ -2019,17 +1963,13 @@ static Word16 Find_Opt_gainQ_fx(
L_tmp = L_mac( L_tmp, coeff_lo[3], g_code );
L_tmp = L_mac( L_tmp, coeff_lo[4], g_pit_cod );
L_tmp = L_shr( L_tmp, 12 );
- L_tmp = L_mac( L_tmp, coeff[0], g2_pitch );
- L_tmp = L_mac( L_tmp, coeff[1], g_pitch );
- L_tmp = L_mac( L_tmp, coeff[2], g2_code );
- L_tmp = L_mac( L_tmp, coeff[3], g_code );
- L_tmp = L_mac( L_tmp, coeff[4], g_pit_cod );
+ L_tmp = L_mac( L_tmp, coeff[0], g2_pitch ); /* 15 - coeff_exp + 13 - 1 */
+ L_tmp = L_mac( L_tmp, coeff[1], g_pitch ); /* 15 - coeff_exp + 13 - 1 */
+ L_tmp = L_mac( L_tmp, coeff[2], g2_code ); /* 15 - coeff_exp + 13 - 1 */
+ 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;
@@ -2038,7 +1978,7 @@ static Word16 Find_Opt_gainQ_fx(
dist_min = L_min( L_tmp, dist_min );
}
- p = &cdbk[add( index, index )];
+ p = &cdbk[add( index, index )]; // Q14
move16();
*gain_pit = *p++; /* selected pitch gain in Q14 */
@@ -2046,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;
}
@@ -2070,10 +2006,10 @@ static Word16 Find_Opt_gainQ_fx(
*---------------------------------------------------------------------*/
void gain_enc_lbr_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const Word16 gains_mode[], /* i : gain bits */
- const Word16 coder_type, /* i : coding type */
- const Word16 i_subfr, /* i : subframe index */
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ const Word16 gains_mode[], /* i : gain bits Q0*/
+ const Word16 coder_type, /* i : coding type Q0*/
+ const Word16 i_subfr, /* i : subframe index Q0*/
const Word16 *xn, /* i : target vector Q_xn*/
const Word16 *y1, /* i : zero-memory filtered adaptive excitation Q_xn*/
const Word16 Q_xn, /* i : xn and y1 format */
@@ -2084,10 +2020,10 @@ void gain_enc_lbr_fx(
Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/
Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/
Word16 *g_corr, /* i/o: correlations , -2,, -2 and 2 mant/exp*/
- Word32 gc_mem[], /* i/o: gain_code from previous subframes */
- Word16 gp_mem[], /* i/o: gain_pitch from previous subframes */
- const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) */
- const int16_t L_subfr /* i : subframe length */
+ Word32 gc_mem[], /* i/o: gain_code from previous subframes Q16*/
+ Word16 gp_mem[], /* i/o: gain_pitch from previous subframes Q14*/
+ const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) Q0*/
+ const Word16 L_subfr /* i : subframe length Q0*/
)
{
@@ -2097,6 +2033,8 @@ void gain_enc_lbr_fx(
Word16 coeff[5], exp_coeff[5];
Word16 exp, exp_code, exp_inov, exp_gcode0, frac, tmp, L_subfr_sf;
Word32 L_tmp, L_tmp1, L_inov;
+ move16();
+ move16();
L_subfr_sf = 6;
move16();
@@ -2128,18 +2066,21 @@ void gain_enc_lbr_fx(
}
#endif
coeff[2] = extract_h( Dot_product12( y2, y2, L_subfr, &exp ) );
+ move16();
exp_coeff[2] = add( sub( exp, 18 ), shl( Q_xn, 1 ) ); /* -18 (y2 Q9) */
move16();
/* Compute scalar product -2* */
coeff[3] = extract_h( L_negate( Dot_product12( xn, y2, L_subfr, &exp ) ) );
+ move16();
exp_coeff[3] = add( sub( exp, 9 - 1 ), Q_xn ); /* -9 (y2 Q9), +1 (2 xn y2) */
move16();
/* Compute scalar product 2* */
coeff[4] = extract_h( Dot_product12( y1, y2, L_subfr, &exp ) );
+ move16();
exp_coeff[4] = add( sub( exp, 9 - 1 ), Q_xn ); /* -9 (y2 Q9), +1 (2 yy1 y2) */
move16();
@@ -2155,6 +2096,7 @@ void gain_enc_lbr_fx(
exp_inov = sub( exp_code, add( 18, L_subfr_sf ) );
L_inov = Isqrt_lc( L_inov, &exp_inov );
*gain_inov = extract_h( L_shl( L_inov, sub( exp_inov, 3 ) ) ); /* gain_inov in Q12 */
+ move16();
/*-----------------------------------------------------------------*
@@ -2172,9 +2114,10 @@ void gain_enc_lbr_fx(
* calculate prediction of gcode
* search for the best codeword
*-----------------------------------------------------------------*/
+ test();
IF( i_subfr == 0 )
{
- b = b_1sfr_fx;
+ b = b_1sfr_fx; // Q12
move16();
n_pred = 2;
move16();
@@ -2183,43 +2126,38 @@ void gain_enc_lbr_fx(
{
case 8:
{
- cdbk = gp_gamma_1sfr_8b_fx;
- move16();
+ cdbk = gp_gamma_1sfr_8b_fx; /* Q14 / Q9 */
if ( EQ_16( clip_gain, 1 ) )
{
size = sub( size, 60 );
}
- move16();
BREAK;
}
case 7:
{
- cdbk = gp_gamma_1sfr_7b_fx;
- move16();
+ cdbk = gp_gamma_1sfr_7b_fx; /* Q14 / Q9 */
if ( EQ_16( clip_gain, 1 ) )
{
size = sub( size, 27 );
}
- move16();
BREAK;
}
case 6:
{
- cdbk = gp_gamma_1sfr_6b_fx;
- move16();
+ cdbk = gp_gamma_1sfr_6b_fx; /* Q14 / Q9 */
if ( EQ_16( clip_gain, 1 ) )
{
size = sub( size, 10 );
}
- move16();
BREAK;
}
}
/* calculate predicted gain */
- aux[0] = 4096;
+ aux[0] = 4096; /* 1 in Q12 */
move16();
aux[1] = shl( ctype, 12 );
+ move16();
/* gcode0 = (float)pow(10, dotp(b, aux, n_pred) - 0.5f * (float)log10(Ecode));
gcode0 = (float)pow(10, dotp(b, aux, n_pred) - 0.05f * 10 * (float)log10(Ecode));
@@ -2251,7 +2189,7 @@ void gain_enc_lbr_fx(
/* output of Pow2() will be: */
/* 16384 < Pow2() <= 32767 */
exp_gcode0 = sub( exp_gcode0, 14 );
- index = Find_Opt_gainQ_fx( coeff, exp_coeff, gain_pit, gain_code, gcode0, exp_gcode0, cdbk, size );
+ index = Find_Opt_gainQ_fx( coeff, exp_coeff, gain_pit, gain_code, gcode0, exp_gcode0, cdbk, size ); // Q0
gc_mem[0] = *gain_code;
move16(); /*Q16*/
@@ -2269,30 +2207,26 @@ void gain_enc_lbr_fx(
{
case 7:
{
- cdbk = gp_gamma_2sfr_7b_fx;
- move16();
+ cdbk = gp_gamma_2sfr_7b_fx; /* Q14/Q9 */
if ( EQ_16( clip_gain, 1 ) )
{
size = sub( size, 30 );
}
- move16();
BREAK;
}
case 6:
{
- cdbk = gp_gamma_2sfr_6b_fx;
- move16();
+ cdbk = gp_gamma_2sfr_6b_fx; /* Q14/Q9 */
if ( EQ_16( clip_gain, 1 ) )
{
size = sub( size, 12 );
}
- move16();
BREAK;
}
}
/* calculate predicted gain */
- aux[0] = 4096;
+ aux[0] = 4096; /* 1 in Q12 */
move16();
aux[1] = shl( ctype, 12 );
move16();
@@ -2305,6 +2239,7 @@ void gain_enc_lbr_fx(
L_tmp1 = Mpy_32_16( exp, frac, 9864 );
move16(); /* Q16 */
aux[2] = round_fx( L_shl( L_tmp1, 12 ) ); /* Q12 */
+ move16();
aux[3] = shr( gp_mem[0], 2 );
move16(); /*Q12*/
@@ -2323,15 +2258,15 @@ void gain_enc_lbr_fx(
/* 16384 < Pow2() <= 32767 */
exp_gcode0 = sub( exp_gcode0, 14 );
- index = Find_Opt_gainQ_fx( coeff, exp_coeff, gain_pit, gain_code, gcode0, exp_gcode0, cdbk, size );
- gc_mem[1] = *gain_code;
+ index = Find_Opt_gainQ_fx( coeff, exp_coeff, gain_pit, gain_code, gcode0, exp_gcode0, cdbk, size ); // Q0
+ gc_mem[1] = *gain_code; // Q16
move32();
- gp_mem[1] = *gain_pit;
+ gp_mem[1] = *gain_pit; // Q14
move16();
}
ELSE IF( EQ_16( i_subfr, 2 * L_SUBFR ) )
{
- b = b_3sfr_fx;
+ b = b_3sfr_fx; // Q12
move16();
n_pred = 6;
move16();
@@ -2349,15 +2284,14 @@ void gain_enc_lbr_fx(
}
ELSE
{
- cdbk = gp_gamma_3sfr_6b_fx;
- move16();
+ cdbk = gp_gamma_3sfr_6b_fx; /* Q14 / Q9 */
if ( EQ_16( clip_gain, 1 ) )
{
size = sub( size, 11 );
}
}
/* calculate predicted gain */
- aux[0] = 4096;
+ aux[0] = 4096; /* 1 in Q12 */
move16();
aux[1] = shl( ctype, 12 );
move16();
@@ -2369,6 +2303,7 @@ void gain_enc_lbr_fx(
exp = sub( sub( 30, exp ), 16 ); /*Q_format(gc_mem[0])=16*/
L_tmp1 = Mpy_32_16( exp, frac, 9864 ); /* Q16 */
aux[2] = round_fx( L_shl( L_tmp1, 12 ) ); /* Q12 */
+ move16();
/*aux[3] = (float)log10(gc_mem[1]);
= log2(gc_mem[1])*log10(2);*/
@@ -2377,6 +2312,7 @@ void gain_enc_lbr_fx(
exp = sub( sub( 30, exp ), 16 ); /*Q_format(gc_mem[1])=16*/
L_tmp1 = Mpy_32_16( exp, frac, 9864 ); /* Q16 */
aux[3] = round_fx( L_shl( L_tmp1, 12 ) ); /* Q12 */
+ move16();
aux[4] = shr( gp_mem[0], 2 );
move16(); /*Q12*/
@@ -2426,14 +2362,14 @@ void gain_enc_lbr_fx(
index = Find_Opt_gainQ_fx( coeff, exp_coeff, gain_pit, gain_code, gcode0, exp_gcode0, cdbk, size );
- gc_mem[2] = *gain_code;
+ gc_mem[2] = *gain_code; // Q16
move32();
- gp_mem[2] = *gain_pit;
+ gp_mem[2] = *gain_pit; // Q14
move16();
}
ELSE IF( EQ_16( i_subfr, 3 * L_SUBFR ) )
{
- b = b_4sfr_fx;
+ b = b_4sfr_fx; // Q12
move16();
n_pred = 8;
move16();
@@ -2451,16 +2387,14 @@ void gain_enc_lbr_fx(
}
ELSE
{
- cdbk = gp_gamma_4sfr_6b_fx;
- move16();
+ cdbk = gp_gamma_4sfr_6b_fx; /* Q14 / Q9 */
if ( EQ_16( clip_gain, 1 ) )
{
size = sub( size, 11 );
- move16();
}
}
/* calculate predicted gain */
- aux[0] = 4096;
+ aux[0] = 4096; /* 1 in Q12 */
move16();
aux[1] = shl( ctype, 12 );
move16();
@@ -2472,6 +2406,7 @@ void gain_enc_lbr_fx(
exp = sub( sub( 30, exp ), 16 ); /*Q_format(gc_mem[0])=16*/
L_tmp1 = Mpy_32_16( exp, frac, 9864 ); /* Q16 */
aux[2] = round_fx( L_shl( L_tmp1, 12 ) ); /* Q12 */
+ move16();
/*aux[3] = (float)log10(gc_mem[1]);
= log2(gc_mem[1])*log10(2);*/
@@ -2480,6 +2415,7 @@ void gain_enc_lbr_fx(
exp = sub( sub( 30, exp ), 16 ); /*Q_format(gc_mem[1])=16*/
L_tmp1 = Mpy_32_16( exp, frac, 9864 ); /* Q16 */
aux[3] = round_fx( L_shl( L_tmp1, 12 ) ); /* Q12 */
+ move16();
/*aux[4] = (float)log10(gc_mem[2]);
@@ -2489,6 +2425,7 @@ void gain_enc_lbr_fx(
exp = sub( sub( 30, exp ), 16 ); /*Q_format(gc_mem[2])=16*/
L_tmp1 = Mpy_32_16( exp, frac, 9864 ); /* Q16 */
aux[4] = round_fx( L_shl( L_tmp1, 12 ) ); /* Q12 */
+ move16();
aux[5] = shr( gp_mem[0], 2 );
move16(); /*Q12*/
@@ -2510,7 +2447,7 @@ void gain_enc_lbr_fx(
/* 16384 < Pow2() <= 32767 */
exp_gcode0 = sub( exp_gcode0, 14 );
- index = Find_Opt_gainQ_fx( coeff, exp_coeff, gain_pit, gain_code, gcode0, exp_gcode0, cdbk, size );
+ index = Find_Opt_gainQ_fx( coeff, exp_coeff, gain_pit, gain_code, gcode0, exp_gcode0, cdbk, size ); // Q0
}
/* *norm_gain_code = *gain_code / *gain_inov; */
@@ -2518,7 +2455,7 @@ void gain_enc_lbr_fx(
exp = s_max( exp, 0 );
tmp = div_s( shr( 8192, exp ), *gain_inov );
- *norm_gain_code = L_shr( Mult_32_16( *gain_code, tmp ), sub( 1, exp ) );
+ *norm_gain_code = L_shr( Mult_32_16( *gain_code, tmp ), sub( 1, exp ) ); // Q16
move32();
{
push_indice_fx( hBstr, IND_GAIN, index, nBits );
@@ -2527,10 +2464,10 @@ void gain_enc_lbr_fx(
}
void gain_enc_lbr_ivas_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const Word16 gains_mode[], /* i : gain bits */
- const Word16 coder_type, /* i : coding type */
- const Word16 i_subfr, /* i : subframe index */
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ const Word16 gains_mode[], /* i : gain bits Q0*/
+ const Word16 coder_type, /* i : coding type Q0*/
+ const Word16 i_subfr, /* i : subframe index Q0*/
const Word16 *xn, /* i : target vector Q_xn*/
const Word16 *y1, /* i : zero-memory filtered adaptive excitation Q_xn*/
const Word16 Q_xn, /* i : xn and y1 format */
@@ -2541,10 +2478,10 @@ void gain_enc_lbr_ivas_fx(
Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/
Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/
Word16 *g_corr, /* i/o: correlations , -2,, -2 and 2 mant/exp*/
- Word32 gc_mem[], /* i/o: gain_code from previous subframes Q16*/
- Word16 gp_mem[], /* i/o: gain_pitch from previous subframes Q14*/
- const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) */
- const int16_t L_subfr /* i : subframe length */
+ Word32 gc_mem[], /* i/o: gain_code from previous subframes Q16*/
+ Word16 gp_mem[], /* i/o: gain_pitch from previous subframes Q14*/
+ const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) Q0*/
+ const Word16 L_subfr /* i : subframe length Q0*/
)
{
@@ -2554,6 +2491,7 @@ void gain_enc_lbr_ivas_fx(
Word16 coeff[5], exp_coeff[5];
Word16 exp, exp_code, exp_inov, exp_gcode0, frac, tmp, L_subfr_sf;
Word32 L_tmp, L_tmp1, L_inov;
+ move16();
L_subfr_sf = 6;
move16();
@@ -2585,18 +2523,21 @@ void gain_enc_lbr_ivas_fx(
}
#endif
coeff[2] = extract_h( Dot_product12( y2, y2, L_subfr, &exp ) );
+ move16();
exp_coeff[2] = add( sub( exp, 18 ), shl( Q_xn, 1 ) ); /* -18 (y2 Q9) */
move16();
/* Compute scalar product -2* */
coeff[3] = extract_h( L_negate( Dot_product12( xn, y2, L_subfr, &exp ) ) );
+ move16();
exp_coeff[3] = add( sub( exp, 9 - 1 ), Q_xn ); /* -9 (y2 Q9), +1 (2 xn y2) */
move16();
/* Compute scalar product 2* */
coeff[4] = extract_h( Dot_product12( y1, y2, L_subfr, &exp ) );
+ move16();
exp_coeff[4] = add( sub( exp, 9 - 1 ), Q_xn ); /* -9 (y2 Q9), +1 (2 yy1 y2) */
move16();
@@ -2612,6 +2553,7 @@ void gain_enc_lbr_ivas_fx(
exp_inov = sub( exp_code, add( 18, L_subfr_sf ) );
L_inov = Isqrt_lc( L_inov, &exp_inov );
*gain_inov = extract_h( L_shl_sat( L_inov, sub( exp_inov, 3 ) ) ); /* gain_inov in Q12 */
+ move16();
/*-----------------------------------------------------------------*
@@ -2629,9 +2571,10 @@ void gain_enc_lbr_ivas_fx(
* calculate prediction of gcode
* search for the best codeword
*-----------------------------------------------------------------*/
+ test();
IF( i_subfr == 0 )
{
- b = b_1sfr_fx;
+ b = b_1sfr_fx; // Q12
move16();
n_pred = 2;
move16();
@@ -2640,43 +2583,38 @@ void gain_enc_lbr_ivas_fx(
{
case 8:
{
- cdbk = gp_gamma_1sfr_8b_fx;
- move16();
+ cdbk = gp_gamma_1sfr_8b_fx; /* Q14 / Q9 */
if ( EQ_16( clip_gain, 1 ) )
{
size = sub( size, 60 );
}
- move16();
BREAK;
}
case 7:
{
- cdbk = gp_gamma_1sfr_7b_fx;
- move16();
+ cdbk = gp_gamma_1sfr_7b_fx; /* Q14 / Q9 */
if ( EQ_16( clip_gain, 1 ) )
{
size = sub( size, 27 );
}
- move16();
BREAK;
}
case 6:
{
- cdbk = gp_gamma_1sfr_6b_fx;
- move16();
+ cdbk = gp_gamma_1sfr_6b_fx; /* Q14 / Q9 */
if ( EQ_16( clip_gain, 1 ) )
{
size = sub( size, 10 );
}
- move16();
BREAK;
}
}
/* calculate predicted gain */
- aux[0] = 4096;
+ aux[0] = 4096; /* 1 in Q12 */
move16();
aux[1] = shl( ctype, 12 );
+ move16();
/* gcode0 = (float)pow(10, dotp(b, aux, n_pred) - 0.5f * (float)log10(Ecode));
gcode0 = (float)pow(10, dotp(b, aux, n_pred) - 0.05f * 10 * (float)log10(Ecode));
@@ -2717,7 +2655,7 @@ void gain_enc_lbr_ivas_fx(
}
ELSE IF( EQ_16( i_subfr, L_SUBFR ) || EQ_16( L_subfr, 2 * L_SUBFR ) )
{
- b = b_2sfr_fx;
+ b = b_2sfr_fx; // Q12
move16();
n_pred = 4;
move16();
@@ -2726,8 +2664,7 @@ void gain_enc_lbr_ivas_fx(
{
case 7:
{
- cdbk = gp_gamma_2sfr_7b_fx;
- move16();
+ cdbk = gp_gamma_2sfr_7b_fx; /* Q14 / Q9 */
if ( EQ_16( clip_gain, 1 ) )
{
size = sub( size, 30 );
@@ -2736,8 +2673,7 @@ void gain_enc_lbr_ivas_fx(
}
case 6:
{
- cdbk = gp_gamma_2sfr_6b_fx;
- move16();
+ cdbk = gp_gamma_2sfr_6b_fx; /* Q14 / Q9 */
if ( EQ_16( clip_gain, 1 ) )
{
size = sub( size, 12 );
@@ -2747,7 +2683,7 @@ void gain_enc_lbr_ivas_fx(
}
/* calculate predicted gain */
- aux[0] = 4096;
+ aux[0] = 4096; /* 1 in Q12 */
move16();
aux[1] = shl( ctype, 12 );
move16();
@@ -2778,21 +2714,21 @@ void gain_enc_lbr_ivas_fx(
/* 16384 < Pow2() <= 32767 */
exp_gcode0 = sub( exp_gcode0, 14 );
- index = Find_Opt_gainQ_fx( coeff, exp_coeff, gain_pit, gain_code, gcode0, exp_gcode0, cdbk, size );
- gc_mem[1] = *gain_code;
+ index = Find_Opt_gainQ_fx( coeff, exp_coeff, gain_pit, gain_code, gcode0, exp_gcode0, cdbk, size ); // Q0
+ gc_mem[1] = *gain_code; // Q16
move32();
- gp_mem[1] = *gain_pit;
+ gp_mem[1] = *gain_pit; // Q14
move16();
}
ELSE IF( EQ_16( i_subfr, 2 * L_SUBFR ) )
{
- b = b_3sfr_fx;
+ b = b_3sfr_fx; // Q12
move16();
n_pred = 6;
move16();
IF( EQ_16( nBits, 7 ) )
{
- cdbk = gp_gamma_3sfr_7b_fx;
+ cdbk = gp_gamma_3sfr_7b_fx; /* Q14 / Q9 */
if ( EQ_16( clip_gain, 1 ) )
{
size = sub( size, 28 );
@@ -2800,15 +2736,14 @@ void gain_enc_lbr_ivas_fx(
}
ELSE
{
- cdbk = gp_gamma_3sfr_6b_fx;
- move16();
+ cdbk = gp_gamma_3sfr_6b_fx; /* Q14 / Q9 */
if ( EQ_16( clip_gain, 1 ) )
{
size = sub( size, 11 );
}
}
/* calculate predicted gain */
- aux[0] = 4096;
+ aux[0] = 4096; // Q12
move16();
aux[1] = shl( ctype, 12 );
move16();
@@ -2820,6 +2755,7 @@ void gain_enc_lbr_ivas_fx(
exp = sub( sub( 30, exp ), 16 ); /*Q_format(gc_mem[0])=16*/
L_tmp1 = Mpy_32_16( exp, frac, 9864 ); /* Q16 */
aux[2] = round_fx( L_shl( L_tmp1, 12 ) ); /* Q12 */
+ move16();
/*aux[3] = (float)log10(gc_mem[1]);
= log2(gc_mem[1])*log10(2);*/
@@ -2878,21 +2814,20 @@ void gain_enc_lbr_ivas_fx(
index = Find_Opt_gainQ_fx( coeff, exp_coeff, gain_pit, gain_code, gcode0, exp_gcode0, cdbk, size );
- gc_mem[2] = *gain_code;
+ gc_mem[2] = *gain_code; /* Q16 */
move32();
- gp_mem[2] = *gain_pit;
+ gp_mem[2] = *gain_pit; /* Q14 */
move16();
}
ELSE IF( EQ_16( i_subfr, 3 * L_SUBFR ) )
{
- b = b_4sfr_fx;
+ b = b_4sfr_fx; /* Q12 */
move16();
n_pred = 8;
move16();
IF( EQ_16( nBits, 7 ) )
{
- cdbk = gp_gamma_4sfr_7b_fx;
- move16();
+ cdbk = gp_gamma_4sfr_7b_fx; /* Q14 / Q9 */
if ( EQ_16( clip_gain, 1 ) )
{
size = sub( size, 25 );
@@ -2900,15 +2835,14 @@ void gain_enc_lbr_ivas_fx(
}
ELSE
{
- cdbk = gp_gamma_4sfr_6b_fx;
- move16();
+ cdbk = gp_gamma_4sfr_6b_fx; /* Q14 / Q9 */
if ( EQ_16( clip_gain, 1 ) )
{
size = sub( size, 11 );
}
}
/* calculate predicted gain */
- aux[0] = 4096;
+ aux[0] = 4096; // Q12
move16();
aux[1] = shl( ctype, 12 );
move16();
@@ -2960,7 +2894,7 @@ void gain_enc_lbr_ivas_fx(
/* 16384 < Pow2() <= 32767 */
exp_gcode0 = sub( exp_gcode0, 14 );
- index = Find_Opt_gainQ_fx( coeff, exp_coeff, gain_pit, gain_code, gcode0, exp_gcode0, cdbk, size );
+ index = Find_Opt_gainQ_fx( coeff, exp_coeff, gain_pit, gain_code, gcode0, exp_gcode0, cdbk, size ); // Q0
}
/* *norm_gain_code = *gain_code / *gain_inov; */
@@ -2968,7 +2902,7 @@ void gain_enc_lbr_ivas_fx(
exp = s_max( exp, 0 );
tmp = div_s( shr( 8192, exp ), *gain_inov );
- *norm_gain_code = L_shr( Mult_32_16( *gain_code, tmp ), sub( 1, exp ) );
+ *norm_gain_code = L_shr( Mult_32_16( *gain_code, tmp ), sub( 1, exp ) ); // Q16
move32();
{
push_indice( hBstr, IND_GAIN, index, nBits );
@@ -2989,20 +2923,20 @@ void gain_enc_lbr_ivas_fx(
void gain_enc_amr_wb_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const Word16 *xn, /* i : target vector */
- const Word16 Q_xn, /* i : xn and yy1 format Q0 */
- const Word16 *yy1, /* i : zero-memory filtered adaptive excitation */
- const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation */
- const Word16 *code, /* i : algebraic excitation */
- const Word32 core_brate, /* i : core bitrate */
- Word16 *gain_pit, /* i/o: pitch gain / Quantized pitch gain */
- Word32 *gain_code, /* o : quantized codebook gain */
- Word16 *gain_inov, /* o : gain of the innovation (used for normalization) */
- Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation */
- Word16 *g_coeff, /* i/o: correlations , -2,, -2 and 2 */
- const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) */
- Word16 *past_qua_en /* i/o: gain quantization memory (4 words) */
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ const Word16 *xn, /* i : target vector Q_xn*/
+ const Word16 Q_xn, /* i : xn and yy1 format */
+ const Word16 *yy1, /* i : zero-memory filtered adaptive excitation Q_xn*/
+ const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9*/
+ const Word16 *code, /* i : algebraic excitation Q9*/
+ const Word32 core_brate, /* i : core bitrate Q0*/
+ Word16 *gain_pit, /* i/o: pitch gain / Quantized pitch gain Q14*/
+ Word32 *gain_code, /* o : quantized codebook gain Q16*/
+ Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/
+ Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/
+ Word16 *g_coeff, /* i/o: correlations , -2,, -2 and 2 Qx*/
+ const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) Q0*/
+ Word16 *past_qua_en /* i/o: gain quantization memory (4 words) Q10*/
)
{
@@ -3015,15 +2949,16 @@ void gain_enc_amr_wb_fx(
const Word16 *t_qua_gain, *p;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/*----------------------------------------------------------------*
* Find the initial quantization pitch index
* Set gains search range
*----------------------------------------------------------------*/
- IF( core_brate >= ACELP_12k65 )
+ IF( GE_32( core_brate, ACELP_12k65 ) )
{
- t_qua_gain = t_qua_gain7b_fx;
+ t_qua_gain = t_qua_gain7b_fx; // Q14
move16();
/* pt at 1/4th of table */
p = t_qua_gain7b_fx + RANGE;
@@ -3038,14 +2973,14 @@ void gain_enc_amr_wb_fx(
}
min_ind = 0;
move16();
- g_pitch = *gain_pit;
+ g_pitch = *gain_pit; // Q14
move16();
FOR( i = 0; i < j; i++ )
{
if ( GT_16( g_pitch, *p ) )
{
- min_ind = add( min_ind, 1 );
+ min_ind = add( min_ind, 1 ); // Q0
}
p += 2;
}
@@ -3055,7 +2990,7 @@ void gain_enc_amr_wb_fx(
}
ELSE
{
- t_qua_gain = t_qua_gain6b_fx;
+ t_qua_gain = t_qua_gain6b_fx; // Q14
min_ind = 0;
move16();
size = RANGE;
@@ -3090,14 +3025,20 @@ void gain_enc_amr_wb_fx(
/* Compute scalar product */
coeff[2] = extract_h( Dot_product12( y2, y2, L_SUBFR, &exp ) );
exp_coeff[2] = add( sub( exp, 18 ), shl( Q_xn, 1 ) ); /* -18 (y2 Q9) */
+ move16();
+ move16();
/* Compute scalar product -2* */
coeff[3] = extract_h( L_negate( Dot_product12( xn, y2, L_SUBFR, &exp ) ) );
exp_coeff[3] = add( sub( exp, 9 - 1 ), Q_xn ); /* -9 (y2 Q9), +1 (2 xn y2) */
+ move16();
+ move16();
/* Compute scalar product 2* */
coeff[4] = extract_h( Dot_product12( yy1, y2, L_SUBFR, &exp ) );
exp_coeff[4] = add( sub( exp, 9 - 1 ), Q_xn ); /* -9 (y2 Q9), +1 (2 yy1 y2) */
+ move16();
+ move16();
/*----------------------------------------------------------------*
* Find energy of code and compute:
@@ -3112,6 +3053,7 @@ void gain_enc_amr_wb_fx(
exp_inov = sub( exp_code, 18 + 6 );
L_inov = Isqrt_lc( L_inov, &exp_inov );
*gain_inov = extract_h( L_shl( L_inov, sub( exp_inov, 3 ) ) ); /* gain_inov in Q12 */
+ move16();
exp_code = sub( exp_code, 18 + 6 + 31 );
frac = Log2_lc( L_tmp, &exp );
@@ -3208,7 +3150,7 @@ void gain_enc_amr_wb_fx(
/* Codebook search */
dist_min = L_add( MAX_32, 0 );
- p = &t_qua_gain[shl( min_ind, 1 )];
+ p = &t_qua_gain[shl( min_ind, 1 )]; // Q14
move16();
index = 0;
@@ -3220,8 +3162,8 @@ void gain_enc_amr_wb_fx(
g_code = *p++;
move16();
- g_code = mult_r( g_code, gcode0 );
- g2_pitch = mult_r( g_pitch, g_pitch );
+ g_code = mult_r( g_code, gcode0 ); // exp(gcode) - 1
+ g2_pitch = mult_r( g_pitch, g_pitch ); // Q13
g_pit_cod = mult_r( g_code, g_pitch );
L_tmp = L_mult( g_code, g_code );
L_Extract( L_tmp, &g2_code, &g2_code_lo );
@@ -3234,17 +3176,13 @@ void gain_enc_amr_wb_fx(
L_tmp = L_mac( L_tmp, coeff_lo[3], g_code );
L_tmp = L_mac( L_tmp, coeff_lo[4], g_pit_cod );
L_tmp = L_shr( L_tmp, 12 );
- L_tmp = L_mac( L_tmp, coeff[0], g2_pitch );
- L_tmp = L_mac( L_tmp, coeff[1], g_pitch );
- L_tmp = L_mac( L_tmp, coeff[2], g2_code );
- L_tmp = L_mac( L_tmp, coeff[3], g_code );
- L_tmp = L_mac( L_tmp, coeff[4], g_pit_cod );
+ L_tmp = L_mac( L_tmp, coeff[0], g2_pitch ); /* 15 - coeff_exp + 13 - 1 */
+ L_tmp = L_mac( L_tmp, coeff[1], g_pitch ); /* 15 - coeff_exp + 13 - 1 */
+ L_tmp = L_mac( L_tmp, coeff[2], g2_code ); /* 15 - coeff_exp + 13 - 1 */
+ 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 )
{
@@ -3266,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();
@@ -3292,13 +3226,13 @@ void gain_enc_amr_wb_fx(
* update table of past quantized energies
*----------------------------------------------------------------*/
- past_qua_en[3] = past_qua_en[2];
+ past_qua_en[3] = past_qua_en[2]; // Q10
move16();
- past_qua_en[2] = past_qua_en[1];
+ past_qua_en[2] = past_qua_en[1]; // Q10
move16();
- past_qua_en[1] = past_qua_en[0];
+ past_qua_en[1] = past_qua_en[0]; // Q10
move16();
- past_qua_en[0] = qua_ener;
+ past_qua_en[0] = qua_ener; // Q10
move16();
@@ -3306,7 +3240,7 @@ void gain_enc_amr_wb_fx(
exp = s_max( exp, 0 );
tmp = div_s( shr( 8192, exp ), *gain_inov );
- *norm_gain_code = L_shr( Mult_32_16( *gain_code, tmp ), sub( 1, exp ) );
+ *norm_gain_code = L_shr( Mult_32_16( *gain_code, tmp ), sub( 1, exp ) ); // Q16
move32();
push_indice_fx( hBstr, IND_GAIN, index, nBits );
diff --git a/lib_enc/gaus_enc.c b/lib_enc/gaus_enc.c
deleted file mode 100644
index d441f6ead49ddcb3a6a1ffab0962633db8157cd0..0000000000000000000000000000000000000000
--- a/lib_enc/gaus_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 "rom_com.h"
-#include "prot.h"
-#include "wmc_auto.h"
diff --git a/lib_enc/gaus_enc_fx.c b/lib_enc/gaus_enc_fx.c
index 9b91bd505c9273da79cb65a2f25c626463fc1f98..a9add7ea809f9c8fcd1541cb85f10011adc96ef1 100644
--- a/lib_enc/gaus_enc_fx.c
+++ b/lib_enc/gaus_enc_fx.c
@@ -28,6 +28,8 @@ static Word16 cod_2pos_fx( const Word16 ind1, const Word16 ind2, const Word16 si
static void gauss2v_fx( BSTR_ENC_HANDLE hBstr, const Word16 h[], const Word16 xn[], const Word16 dn[], Word16 code[], Word16 y1[], Word32 *gain, const Word16 lg, const Word16 shift, const Word16 Q_new, const Word16 nb_bits );
+static void gauss2v_ivas_fx( BSTR_ENC_HANDLE hBstr, const Word16 h[], const Word16 xn[], const Word16 dn[], Word16 code[], Word16 y1[], Word32 *gain, const Word16 lg, const Word16 shift, const Word16 Q_new, const Word16 nb_bits );
+
/*-------------------------------------------------------------------*
* Gaus_encode
*
@@ -39,22 +41,22 @@ static void gauss2v_fx( BSTR_ENC_HANDLE hBstr, const Word16 h[], const Word16 xn
*-------------------------------------------------------------------*/
Word16 gaus_encode_fx(
Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word16 i_subfr, /* i : subframe index */
- const Word16 *h1, /* i : weighted filter input response */
- const Word16 *xn, /* i : target vector */
- Word16 *exc, /* o : pointer to excitation signal frame */
- Word16 *mem_w0, /* o : weighting filter denominator memory */
- Word16 *clip_gain, /* o : memory of gain of pitch clipping algorithm */
- Word16 *tilt_code, /* o : synthesis excitation spectrum tilt */
- Word16 *code, /* o : algebraic excitation Q9 */
- Word32 *gain_code, /* o : Code gain. Q16 */
- Word16 *y2, /* o : zero-memory filtered adaptive excitation Q9 */
- Word16 *gain_inov, /* o : innovation gain Q12 */
- Word16 *voice_fac, /* o : voicing factor Q15 */
- Word16 *gain_pit, /* o : adaptive excitation gain Q14 */
- const Word16 Q_new, /* i : scaling factor */
- const Word16 shift, /* i : scaling factor */
- Word32 *norm_gain_code /* o : normalized innovative cb. gain Q16 */
+ const Word16 i_subfr, /* i : subframe index Q0*/
+ const Word16 *h1, /* i : weighted filter input response Q14*/
+ const Word16 *xn, /* i : target vector Q12*/
+ Word16 *exc, /* o : pointer to excitation signal frame Q_new*/
+ Word16 *mem_w0, /* o : weighting filter denominator memory Q_new*/
+ Word16 *clip_gain, /* o : memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/
+ Word16 *tilt_code, /* o : synthesis excitation spectrum tilt Q15*/
+ Word16 *code, /* o : algebraic excitation Q9*/
+ Word32 *gain_code, /* o : Code gain. Q16*/
+ Word16 *y2, /* o : zero-memory filtered adaptive excitation Q9*/
+ Word16 *gain_inov, /* o : innovation gain Q12*/
+ Word16 *voice_fac, /* o : voicing factor Q15*/
+ Word16 *gain_pit, /* o : adaptive excitation gain Q14*/
+ const Word16 Q_new, /* i : scaling factor */
+ const Word16 shift, /* i : scaling factor */
+ Word32 *norm_gain_code /* o : normalized innovative cb. gain Q16*/
)
{
Word16 nb_bits, idx;
@@ -64,6 +66,7 @@ Word16 gaus_encode_fx(
Word16 exp, tmp, tmp_idx;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/*----------------------------------------------------------------*
@@ -74,7 +77,7 @@ Word16 gaus_encode_fx(
corr_xh_fx( xn, dn, h1 );
tmp_idx = shr( i_subfr, 6 );
- nb_bits = st_fx->acelp_cfg.fixed_cdk_index[tmp_idx];
+ nb_bits = st_fx->acelp_cfg.fixed_cdk_index[tmp_idx]; /* Q0 */
move16();
gauss2v_fx( st_fx->hBstr, h1, xn, dn, code, y2, gain_code, L_SUBFR, shift, Q_new, shr( nb_bits, 1 ) );
@@ -90,52 +93,44 @@ Word16 gaus_encode_fx(
Ltmp = Isqrt_lc( Ltmp, &exp_code );
*gain_inov = extract_h( L_shl( Ltmp, sub( exp_code, 3 ) ) ); /* g_code_inov in Q12 */
- nb_bits = st_fx->acelp_cfg.gains_mode[tmp_idx];
+ nb_bits = st_fx->acelp_cfg.gains_mode[tmp_idx]; /* Q0 */
move16();
/* low bound = -30; stepSize = 1.71875; inv_stepSize = 0.5818181 */
- idx = gain_enc_gaus_fx( gain_code, nb_bits, -7680, 28160, 19065 );
+ idx = gain_enc_gaus_fx( gain_code, nb_bits, -7680, 28160, 19065 ); /* Q0 */
push_indice_fx( st_fx->hBstr, IND_GAIN, idx, nb_bits );
/*----------------------------------------------------------------*
* 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 ) );
+ exc[i + i_subfr] = round_fx( L_shl( L_mult( gcode, code[i] ), 15 - 9 ) ); /* Q_new */
}
/*----------------------------------------------------------------*
* Updates: last value of new target is stored in mem_w0
*----------------------------------------------------------------*/
- Ltmp = L_mult( gcode, y2[L_SUBFR - 1] );
- Ltmp = L_shl( Ltmp, add( 5, shift ) );
+ Ltmp = L_mult( gcode, y2[L_SUBFR - 1] ); /* Q_new + 10 */
+ Ltmp = L_shl( Ltmp, add( 5, shift ) ); /* Q_new + 15 + shift */
Ltmp = L_negate( Ltmp );
- Ltmp = L_mac( Ltmp, xn[L_SUBFR - 1], 16384 );
-#ifdef BASOP_NOGLOB
- Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) );
- *mem_w0 = round_fx_sat( Ltmp );
-#else
- Ltmp = L_shl( Ltmp, sub( 1, shift ) );
- *mem_w0 = round_fx( Ltmp );
-#endif
+ Ltmp = L_mac( Ltmp, xn[L_SUBFR - 1], 16384 ); /* Q_new + 15 + shift */
+ Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); /* Q_new + 16 */
+ *mem_w0 = round_fx_sat( Ltmp ); /* Q_new */
+ move16();
init_gp_clip_fx( clip_gain ); /* reset pitch clipping parameters */
*gain_pit = 0;
*tilt_code = 0;
- move16(); /* purely unvoiced */
- *voice_fac = -32768;
- move16(); /* purely unvoiced */
+ move16(); /* purely unvoiced */
+ *voice_fac = -32768; /* -1 in Q31 */
+ move16(); /* purely unvoiced */
exp = sub( norm_s( *gain_inov ), 1 );
exp = s_max( exp, 0 );
tmp = div_s( shr( 8192, exp ), *gain_inov );
- *norm_gain_code = L_shr( Mult_32_16( *gain_code, tmp ), sub( 1, exp ) );
+ *norm_gain_code = L_shr( Mult_32_16( *gain_code, tmp ), sub( 1, exp ) ); /* Q16 */
move16();
return ( L_SUBFR << 6 );
@@ -143,31 +138,33 @@ Word16 gaus_encode_fx(
Word16 gaus_encode_ivas_fx(
Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word16 i_subfr, /* i : subframe index */
- const Word16 *h1, /* i : weighted filter input response */
- const Word16 *xn, /* i : target vector */
- Word16 *exc, /* o : pointer to excitation signal frame */
- Word16 *mem_w0, /* o : weighting filter denominator memory */
- Word16 *clip_gain, /* o : memory of gain of pitch clipping algorithm */
- Word16 *tilt_code, /* o : synthesis excitation spectrum tilt */
- Word16 *code, /* o : algebraic excitation Q9 */
- Word32 *gain_code, /* o : Code gain. Q16 */
- Word16 *y2, /* o : zero-memory filtered adaptive excitation Q9 */
- Word16 *gain_inov, /* o : innovation gain Q12 */
- Word16 *voice_fac, /* o : voicing factor Q15 */
- Word16 *gain_pit, /* o : adaptive excitation gain Q14 */
- const Word16 Q_new, /* i : scaling factor */
- const Word16 shift, /* i : scaling factor */
- Word32 *norm_gain_code /* o : normalized innovative cb. gain Q16 */
+ const Word16 i_subfr, /* i : subframe index Q0*/
+ const Word16 *h1, /* i : weighted filter input response Q14*/
+ const Word16 *xn, /* i : target vector Q12*/
+ Word16 *exc, /* o : pointer to excitation signal frame Q_new*/
+ Word16 *mem_w0, /* o : weighting filter denominator memory Q_new*/
+ Word16 *clip_gain, /* o : memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/
+ Word16 *tilt_code, /* o : synthesis excitation spectrum tilt Q15*/
+ Word16 *code, /* o : algebraic excitation Q9*/
+ Word32 *gain_code, /* o : Code gain. Q16*/
+ Word16 *y2, /* o : zero-memory filtered adaptive excitation Q9*/
+ Word16 *gain_inov, /* o : innovation gain Q12*/
+ Word16 *voice_fac, /* o : voicing factor Q15*/
+ Word16 *gain_pit, /* o : adaptive excitation gain Q14*/
+ const Word16 Q_new, /* i : scaling factor */
+ const Word16 shift, /* i : scaling factor */
+ Word32 *norm_gain_code /* o : normalized innovative cb. gain Q16*/
)
{
Word16 nb_bits, idx;
Word16 i = 0;
+ move16();
Word32 Ltmp;
Word16 dn[L_SUBFR], exp_code, gcode; /* Correlation between xn and h1 */
Word16 exp, tmp, tmp_idx;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/*----------------------------------------------------------------*
@@ -178,10 +175,10 @@ Word16 gaus_encode_ivas_fx(
corr_xh_fx( xn, dn, h1 );
tmp_idx = shr( i_subfr, 6 );
- nb_bits = st_fx->acelp_cfg.fixed_cdk_index[tmp_idx];
+ nb_bits = st_fx->acelp_cfg.fixed_cdk_index[tmp_idx]; /* Q0 */
move16();
- gauss2v_fx( st_fx->hBstr, h1, xn, dn, code, y2, gain_code, L_SUBFR, shift, Q_new, shr( nb_bits, 1 ) );
+ gauss2v_ivas_fx( st_fx->hBstr, h1, xn, dn, code, y2, gain_code, L_SUBFR, shift, Q_new, shr( nb_bits, 1 ) );
/*----------------------------------------------------------------*
* Encode gaussian gain
@@ -194,52 +191,44 @@ Word16 gaus_encode_ivas_fx(
Ltmp = Isqrt_lc( Ltmp, &exp_code );
*gain_inov = extract_h( L_shl( Ltmp, sub( exp_code, 3 ) ) ); /* g_code_inov in Q12 */
- nb_bits = st_fx->acelp_cfg.gains_mode[tmp_idx];
+ nb_bits = st_fx->acelp_cfg.gains_mode[tmp_idx]; /* Q0 */
move16();
/* low bound = -30; stepSize = 1.71875; inv_stepSize = 0.5818181 */
- idx = gain_enc_gaus_fx( gain_code, nb_bits, -7680, 28160, 19065 );
+ idx = gain_enc_gaus_fx( gain_code, nb_bits, -7680, 28160, 19065 ); /* Q0 */
push_indice( st_fx->hBstr, IND_GAIN, idx, nb_bits );
/*----------------------------------------------------------------*
* 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 ) );
+ exc[i + i_subfr] = round_fx( L_shl( L_mult( gcode, code[i] ), 15 - 9 ) ); /* Q_new */
}
/*----------------------------------------------------------------*
* Updates: last value of new target is stored in mem_w0
*----------------------------------------------------------------*/
- Ltmp = L_mult( gcode, y2[L_SUBFR - 1] );
- Ltmp = L_shl( Ltmp, add( 5, shift ) );
+ Ltmp = L_mult( gcode, y2[L_SUBFR - 1] ); /* Q_new + 10 */
+ Ltmp = L_shl( Ltmp, add( 5, shift ) ); /* Q_new + 15 + shift */
Ltmp = L_negate( Ltmp );
- Ltmp = L_mac( Ltmp, xn[L_SUBFR - 1], 16384 );
-#ifdef BASOP_NOGLOB
- Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) );
- *mem_w0 = round_fx_sat( Ltmp );
-#else
- Ltmp = L_shl( Ltmp, sub( 1, shift ) );
- *mem_w0 = round_fx( Ltmp );
-#endif
+ Ltmp = L_mac( Ltmp, xn[L_SUBFR - 1], 16384 ); /* Q_new + 15 + shift */
+ Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); /* Q_new + 16 */
+ *mem_w0 = round_fx_sat( Ltmp ); /* Q_new */
+ move16();
init_gp_clip_fx( clip_gain ); /* reset pitch clipping parameters */
*gain_pit = 0;
*tilt_code = 0;
- move16(); /* purely unvoiced */
- *voice_fac = -32768;
- move16(); /* purely unvoiced */
+ move16(); /* purely unvoiced */
+ *voice_fac = -32768; /* -1 in Q15 */
+ move16(); /* purely unvoiced */
exp = sub( norm_s( *gain_inov ), 1 );
exp = s_max( exp, 0 );
tmp = div_s( shr( 8192, exp ), *gain_inov );
- *norm_gain_code = L_shr( Mult_32_16( *gain_code, tmp ), sub( 1, exp ) );
+ *norm_gain_code = L_shr( Mult_32_16( *gain_code, tmp ), sub( 1, exp ) ); /* Q16 */
move16();
return ( L_SUBFR << 6 );
@@ -253,6 +242,467 @@ Word16 gaus_encode_ivas_fx(
* One Gaussian vector of 192 values vectors delayed by 2
*-------------------------------------------------------------------*/
void gauss2v_fx(
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder state structure */
+ const Word16 h[], /* i : weighted LP filter impulse response Q15 */
+ const Word16 xn[], /* i : target signal Q12 */
+ const Word16 dn[], /* i : backward filtered target Q12 */
+ Word16 code[], /* o : gaussian excitation Q9 */
+ Word16 y1[], /* o : zero-memory filtered gauss. excitation Q8 */
+ Word32 *gain, /* o : excitation gain. 32-bit number in Q16 */
+ const Word16 lg, /* i : subframe size Q0 */
+ const Word16 shift, /* i : Scaling factor Q0 */
+ const Word16 Q_new, /* i : Scaling factor Q0 */
+ const Word16 nb_bits /* i : nb ob bits per track (max 6) Q0 */
+)
+{
+ Word16 i, j, ind1, ind2;
+ Word16 nvec, step;
+ Word32 cor, cora, dotprod;
+ Word16 enerw;
+ Word32 eneri, cor2;
+ Word32 enerw32, cor2w32;
+ Word16 *cpt1;
+ Word16 *pt1, *pt2;
+ Word32 max_val[NMAX + 1];
+ Word16 *pos[NMAX + 1];
+ Word32 sign[NMAX + 1];
+ Word32 ener[NMAX + 1], corr[NMAX + 1], ener1;
+ Word16 dico2[L_SUBFR * NMAX];
+ Word16 exp_num;
+ Word16 exp_den;
+ Word16 Num;
+ Word16 Den;
+ Word32 GainPortion1;
+ Word32 GainPortion2;
+ Word32 cor_abs;
+ Word16 cor_neg;
+ Word16 div_result;
+ Word32 ener_sqrt;
+ Word32 Portion;
+ Word16 sign1, sign2;
+ Word16 enerw_norm, enerw_mantissa;
+ Word16 cor2w_norm, cor2w_mantissa;
+ Word16 eneri_norm, eneri_mantissa;
+ Word16 cor2_norm, cor2_mantissa;
+ Word16 difference_norm;
+ Word32 cor32; /* 32-bit intermediate value*/
+ Word16 hi1, lo1;
+ Word16 update_best;
+ Word16 idx;
+ Word32 Lc0, Lc1, Lnum, Lden;
+ Word16 gxx, gcc, index_delta, delta, m_sign, inv_delta;
+ Word16 hg[190], Gaus_dico2[190];
+ Word16 shiftP3;
+#ifdef BASOP_NOGLOB_DECLARE_LOCAL
+ Flag Overflow = 0;
+ move32();
+#endif
+
+ /*----------------------------------------------------------------*
+ * Encode the tilt of gaussian excitation
+ *----------------------------------------------------------------*/
+
+ /* Compute spectral tilt of target */
+ Lc0 = L_mult( xn[1], xn[1] ); /* Q25 */
+ Lc1 = L_mult( xn[1], xn[0] ); /* Q25 */
+ FOR( i = 2; i < L_SUBFR; i++ )
+ {
+ /* fc0 += xn[i]*xn[i] */
+ /* fc1 += xn[i]*xn[i-1] */
+ Lc0 = L_mac_sat( Lc0, xn[i], xn[i] ); /* Q25 */
+ Lc1 = L_mac_sat( Lc1, xn[i], xn[i - 1] ); /* Q25 */
+ }
+ /* fgxx = fc1/fc0 */
+ exp_num = sub( norm_l( Lc1 ), 1 );
+ Num = extract_h( L_shl( Lc1, exp_num ) );
+ m_sign = s_or( shr( Num, 16 ), 1 ); /* Remove sign */
+ Num = abs_s( Num );
+ Lc0 = L_max( Lc0, 1 );
+ exp_den = norm_l( Lc0 );
+ Den = extract_h( L_shl( Lc0, exp_den ) ); /* Q9 + exp_den */
+ gxx = shr( div_s( Num, Den ), sub( exp_num, sub( exp_den, 2 ) ) ); /* Q13 */
+ gxx = i_mult2( gxx, m_sign ); /* Apply sign */
+
+ set16_fx( hg, 0, 190 ); /* Compute spectral tilt of filtered codebook */
+ Copy( h, hg, L_SUBFR ); // Q15
+ conv_fx( gaus_dico_fx, hg, Gaus_dico2, 190 ); // Q12
+
+ Lc0 = L_mult( Gaus_dico2[1], Gaus_dico2[1] ); /* Q25 */
+ Lc1 = L_mult( Gaus_dico2[1], Gaus_dico2[0] ); /* Q25 */
+ FOR( i = 2; i < 190; i++ )
+ {
+ /* fc0 += fgaus_dico2[i]*fgaus_dico2[i] */
+ /* fc1 += fgaus_dico2[i]*fgaus_dico2[i-1] */
+ Lc0 = L_mac( Lc0, Gaus_dico2[i], Gaus_dico2[i] ); /* Q25 */
+ Lc1 = L_mac( Lc1, Gaus_dico2[i], Gaus_dico2[i - 1] ); /* Q25 */
+ }
+
+ /* fgcc = fc1/fc0 */
+
+ exp_num = sub( norm_l( Lc1 ), 1 );
+ Num = extract_h( L_shl( Lc1, exp_num ) );
+ m_sign = s_or( shr( Num, 16 ), 1 ); /* Remove sign */
+ Num = abs_s( Num );
+
+ Lc0 = L_max( Lc0, 1 );
+ exp_den = norm_l( Lc0 );
+ Den = extract_h( L_shl( Lc0, exp_den ) );
+ gcc = shr( div_s( Num, Den ), sub( exp_num, sub( exp_den, 2 ) ) ); /* Q13 */
+ gcc = i_mult2( gcc, m_sign ); /* Apply sign */
+
+ /* fdelta = (1-fgcc*fgxx) / (2*fgcc+fgxx) Compute and quantize spectral tilt modification factor */
+ Lnum = L_sub( 134217728L, L_mult( gcc, gxx ) ); /* Q30 */
+ Lden = L_mac( L_mult( gxx, 8192 ), gcc, 16384 ); /* Q30 */
+
+ exp_num = sub( norm_l( Lnum ), 1 );
+ Num = extract_h( L_shl( Lnum, exp_num ) ); /* Q14 + exp_den */
+ m_sign = s_or( shr( Num, 16 ), 1 ); /* Remove sign */
+ Num = abs_s( Num );
+
+ Lden = L_max( Lden, 1 );
+ exp_den = norm_l( Lden );
+ Den = extract_h( L_shl( Lden, exp_den ) );
+
+ delta = shr_o( div_s( Num, Den ), sub( exp_num, exp_den ), &Overflow ); /* Q15 */
+ delta = i_mult2( delta, m_sign ); /* Apply sign Q0*/
+ /* index_delta = (short)(FAC_DELTA * fdelta) */
+ index_delta = shr( delta, SFAC_DELTA );
+
+ /* index_delta [0,7] */
+ index_delta = s_max( index_delta, 0 );
+ index_delta = s_min( index_delta, 7 );
+
+ /* fdelta = STEP_DELTA * (float)index_delta */
+ delta = shl( index_delta, 11 ); /* delta in Q15 */
+
+ IF( delta > 0 ) /* Adapt spectral tilt of initial codebook */
+ {
+ /* Computation of 1 / (1+fdelta*fdelta) */
+ inv_delta = inv_delta_tab[sub( index_delta, 1 )];
+ move16(); /* Q15 */
+
+ /* fgaus_dico2[0] = gaus_dico[0] */
+ Gaus_dico2[0] = gaus_dico_fx[0]; /* Q12 */
+ move16();
+ FOR( i = 1; i < 190; i++ )
+ {
+ /* fgaus_dico2[i] = (gaus_dico[i] - fdelta*gaus_dico[i-1]) / (1 + fdelta*fdelta) */
+ Lnum = L_msu( L_deposit_h( gaus_dico_fx[i] ), delta, gaus_dico_fx[i - 1] );
+ Gaus_dico2[i] = round_fx( Mpy_32_16_1( Lnum, inv_delta ) );
+ }
+ }
+ ELSE
+ {
+ FOR( i = 0; i < 190; i++ )
+ {
+ /* fgaus_dico2[i] = gaus_dico[i] */
+ Gaus_dico2[i] = gaus_dico_fx[i]; /* Q12 */
+ move16();
+ }
+ }
+
+ /*----------------------------------------------------------------*
+ * Initializations
+ *----------------------------------------------------------------*/
+
+ ind1 = 0;
+ move16();
+ ind2 = 0;
+ move16();
+
+ nvec = shl( 1, nb_bits );
+ step = shr( 0x80, nb_bits );
+
+ /*----------------------------------------------------------------*
+ * dot product between dn and gaussian codevectors,
+ * keep NMAX best vectors
+ *----------------------------------------------------------------*/
+
+ set32_fx( max_val, 0, NMAX + 1 );
+ set32_fx( sign, 0, NMAX + 1 );
+
+ FOR( i = 0; i < NMAX + 1; i++ )
+ {
+ pos[i] = (Word16 *) Gaus_dico2;
+ }
+
+ cpt1 = Gaus_dico2;
+ move16();
+
+ FOR( i = 0; i < nvec; i++ )
+ {
+ /* Dot product without normalization, because values are compared with each other afterwards. */
+ cor = Dot_product( cpt1, dn, lg ); /* Q12 * Q12 * length of 64 + 1 left shift ==> Q31*/
+ cora = L_abs( cor );
+ j = NMAX - 1;
+ move16();
+
+ DO
+ {
+ IF( GE_32( cora, max_val[j] ) )
+ {
+ max_val[j + 1] = max_val[j];
+ move32(); /*Q31*/
+ pos[j + 1] = pos[j];
+ move16(); /*Pointer*/
+ sign[j + 1] = sign[j];
+ move32(); /*Q31*/
+ max_val[j] = cora;
+ move32(); /*Q31*/
+ pos[j] = cpt1;
+ move16(); /*Pointer*/
+ sign[j] = cor;
+ move32(); /*Q31*/
+ }
+ j--;
+ }
+ WHILE( j >= 0 );
+ cpt1 += step;
+ }
+
+ /*----------------------------------------------------------------*
+ * filter selected vectors
+ * put sign
+ * compute energy
+ *----------------------------------------------------------------*/
+
+ pt1 = dico2;
+ move16();
+ FOR( i = 0; i < NMAX; i++ )
+ {
+ /* Input vector (pos) Q12, filter coefs in Q15, result in same format as input vector (Q12) */
+ conv_fx( pos[i], h, pt1, lg );
+
+ /* put sign and compute energy */
+ IF( sign[i] < 0 )
+ {
+ FOR( j = 0; j < lg; j++ )
+ {
+ pt1[j] = negate( pt1[j] );
+ move16(); /*Store into dico2*/
+ }
+ }
+ ener[i] = Dot_product( pt1, pt1, lg ); /* pt1 points to filtered vector in dico2, in Q12 */
+ move32(); /* Result is for Q12 * Q12 with length of 64 (6 bits) + 1 left shift => Q31 */
+ corr[i] = Dot_product( pt1, xn, lg ); /* must be equal to sign[i] !! */
+ move32(); /* pt1 points into dico2, in Q12. xn is in Q12 */
+ /* Result is for Q12 * Q12 with length of 64 (6 bits) + 1 left shift => Q31 */
+ pt1 += L_SUBFR;
+ }
+
+ /*------------------------------------------------------------------------*
+ * try all combinations of NMAX best vectors
+ *------------------------------------------------------------------------*/
+
+ pt1 = dico2;
+ move16();
+
+ /* Initial values for search algorithm */
+ enerw32 = L_deposit_h( 0x80 );
+ cor2w32 = L_deposit_l( -2 );
+ enerw_norm = norm_l( enerw32 );
+ cor2w_norm = norm_l( cor2w32 );
+ cor2w_mantissa = round_fx( L_shl( cor2w32, cor2w_norm ) );
+ enerw_mantissa = round_fx( L_shl( enerw32, enerw_norm ) );
+
+ FOR( i = 0; i < NMAX; i++ )
+ {
+ pt2 = pt1;
+ move16();
+ FOR( j = i; j < NMAX; j++ )
+ {
+ cor32 = L_add( corr[i], corr[j] ); /* Q31 */
+
+ dotprod = Dot_product( pt1, pt2, lg ); /* Q12 * Q12 * length of 64 + 1 left shift ==> Q31 */
+
+ /* eneri = round_fx(ener[i]) + round_fx(ener[j]) + 2*round_fx(dotprod) */
+ /* Use ScalingShift to stay aligned with ener[] */
+ eneri = L_shl( dotprod, 1 ); /* One left shift added for factor of 2 */
+ eneri = L_add( ener[i], eneri );
+ eneri = L_add( ener[j], eneri ); /* Q31 */
+
+ lo1 = L_Extract_lc( cor32, &hi1 );
+ cor2 = Sad_32( 0, hi1, lo1 ); /* Square + Add */
+
+ cor2_norm = norm_l( cor2 );
+ eneri_norm = norm_l( eneri );
+ 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 );
+ difference_norm = sub( add( cor2_norm, enerw_norm ), add( cor2w_norm, eneri_norm ) );
+
+ update_best = 0;
+ move16();
+
+ IF( difference_norm > 0 )
+ {
+ if ( GT_32( L_shr( L_mult( cor2_mantissa, enerw_mantissa ), difference_norm ),
+ L_mult( cor2w_mantissa, eneri_mantissa ) ) )
+ {
+ update_best = 1;
+ move16();
+ }
+ }
+ ELSE
+ {
+ if ( L_msu_sat( L_shl( L_mult( cor2w_mantissa, eneri_mantissa ), difference_norm ), cor2_mantissa, enerw_mantissa ) < 0 ) // Saturation to be revisited
+ {
+ update_best = 1;
+ move16();
+ }
+ }
+ IF( update_best != 0 )
+ {
+ cor2w_mantissa = cor2_mantissa;
+ move16();
+ cor2w_norm = cor2_norm;
+ move16();
+ enerw_mantissa = eneri_mantissa;
+ move16();
+ enerw_norm = eneri_norm;
+ move16();
+ ind1 = i;
+ move16();
+ ind2 = j;
+ move16();
+ }
+ pt2 += L_SUBFR;
+ }
+ pt1 += L_SUBFR;
+ }
+
+ enerw = round_fx( L_shr( L_deposit_h( enerw_mantissa ), enerw_norm ) );
+
+ /*----------------------------------------------------------------*
+ * Compute zero-memory filtered gauss. excitation y
+ *----------------------------------------------------------------*/
+
+ pt1 = dico2 + ind1 * L_SUBFR;
+ move16(); /*Pointer arithmetic*/
+ pt2 = dico2 + ind2 * L_SUBFR;
+ move16();
+
+ shiftP3 = add( shift, 3 );
+ FOR( i = 0; i < lg; i++ )
+ {
+ /* Sum of 2 Q12 values, must give a Q1.8 */
+ y1[i] = shr( add( pt1[i], pt2[i] ), shiftP3 );
+ move16(); /* Compensate for "shift" */
+ }
+
+ /*----------------------------------------------------------------*
+ * signs of vectors
+ *----------------------------------------------------------------*/
+
+ sign1 = ( -32768 );
+ move16();
+ if ( sign[ind1] >= 0 )
+ {
+ sign1 = 32767;
+ move16();
+ }
+
+ sign2 = ( -32768 );
+ move16();
+ if ( sign[ind2] >= 0 )
+ {
+ sign2 = 32767;
+ move16();
+ }
+
+ /*----------------------------------------------------------------*
+ * Compute code
+ *----------------------------------------------------------------*/
+
+ pt1 = pos[ind1];
+ move16(); /* Points to gaussian vector (gaus_dico_fx) in Q12 */
+ pt2 = pos[ind2];
+ move16(); /* Points to gaussian vector (gaus_dico_fx) in Q12 */
+
+ /* sign[ind1] and sign[ind2] */
+ FOR( i = 0; i < lg; i++ )
+ {
+ /* code[i]=(pt1[i]*sign1 + pt2[i]*sign2) /8 */
+ /* Division by 8 (shift by 3) is for scaling (Q12 to Q0.9 output) */
+ code[i] = shr( add( mult( pt1[i], sign1 ), mult( pt2[i], sign2 ) ), 3 );
+ move16();
+ }
+
+ cor = L_add( corr[ind1], corr[ind2] );
+
+ /*----------------------------------------------------------------*
+ * Compute index
+ *----------------------------------------------------------------*/
+
+ i = (Word16) ( ( pos[ind1] - Gaus_dico2 ) / step ); /* Division by step can be replaced by shift. Pointer arithmetic */
+ j = (Word16) ( ( pos[ind2] - Gaus_dico2 ) / step ); /* Division by step can be replaced by shift. Pointer arithmetic */
+
+ idx = cod_2pos_fx( i, j, sign1, sign2, nvec ); /* Q0 */
+ move16();
+
+ push_indice_fx( hBstr, IND_GAUS_CDBK_INDEX, idx, 2 * nb_bits + 1 );
+ push_indice_fx( hBstr, IND_TILT_FACTOR, index_delta, 3 );
+
+ /*----------------------------------------------------------------*
+ * Find quantized gain
+ *----------------------------------------------------------------*/
+
+ /* Divide cor/enerw: intermediate result stored into GainPortion1 */
+ cor_neg = 0;
+ move16();
+ if ( cor < 0 ) /* Make Num positive. */
+ {
+ cor_neg = 1;
+ move16();
+ }
+ cor_abs = L_abs( cor );
+
+ exp_num = sub( norm_l( cor_abs ), 1 );
+ exp_den = norm_s( enerw );
+ Num = round_fx( L_shl( cor_abs, exp_num ) );
+ Den = shl( enerw, exp_den );
+
+ GainPortion1 = 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 */
+ IF( cor_neg != 0 )
+ {
+ div_result = negate( div_result ); /* Retrieve sign */
+ }
+ /* Re-scale to compensate for normalization*/
+ GainPortion1 = L_shr( L_deposit_l( div_result ), sub( exp_num, exp_den ) );
+ }
+
+ ener1 = Dot_product( xn, xn, lg ); /* Q12 * Q12 * length of 64 + 1 left shift ==> Q31 */
+
+ exp_num = sub( norm_s( enerw ), 1 );
+ exp_den = norm_l( ener1 );
+ Num = shl( enerw, exp_num );
+ Den = round_fx_sat( L_shl_sat( ener1, exp_den ) );
+ 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*/
+ GainPortion2 = L_shr_sat( L_deposit_l( div_result ), sub( exp_num, exp_den ) );
+ }
+
+ ener_sqrt = Isqrt( L_shl_sat( GainPortion2, 1 ) ); /* Make value a Q16 prior to division (align on power of 4) */
+ 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 */
+ *gain = L_shl_o( Portion, sub( 13, Q_new ), &Overflow ); /* Q16 */
+ move32();
+
+ return;
+}
+
+void gauss2v_ivas_fx(
BSTR_ENC_HANDLE hBstr, /* i/o: encoder state structure */
const Word16 h[], /* i : weighted LP filter impulse response Q15 */
const Word16 xn[], /* i : target signal Q12 */
@@ -306,6 +756,7 @@ void gauss2v_fx(
Word16 shiftP3;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/*----------------------------------------------------------------*
@@ -319,13 +770,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] );
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 );
@@ -378,12 +824,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 */
+ delta = i_mult2( delta, m_sign ); /* Apply sign */
/* index_delta = (short)(FAC_DELTA * fdelta) */
index_delta = shr( delta, SFAC_DELTA );
@@ -402,11 +844,13 @@ void gauss2v_fx(
/* fgaus_dico2[0] = gaus_dico[0] */
Gaus_dico2[0] = gaus_dico_fx[0];
+ move16();
FOR( i = 1; i < 190; i++ )
{
/* fgaus_dico2[i] = (gaus_dico[i] - fdelta*gaus_dico[i-1]) / (1 + fdelta*fdelta) */
Lnum = L_msu( L_deposit_h( gaus_dico_fx[i] ), delta, gaus_dico_fx[i - 1] );
Gaus_dico2[i] = round_fx( Mpy_32_16_1( Lnum, inv_delta ) );
+ move16();
}
}
ELSE
@@ -544,13 +988,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;
@@ -662,8 +1101,8 @@ void gauss2v_fx(
idx = cod_2pos_fx( i, j, sign1, sign2, nvec );
move16();
- push_indice_fx( hBstr, IND_GAUS_CDBK_INDEX, idx, 2 * nb_bits + 1 );
- push_indice_fx( hBstr, IND_TILT_FACTOR, index_delta, 3 );
+ push_indice( hBstr, IND_GAUS_CDBK_INDEX, idx, 2 * nb_bits + 1 );
+ push_indice( hBstr, IND_TILT_FACTOR, index_delta, 3 );
/*----------------------------------------------------------------*
* Find quantized gain
@@ -701,56 +1140,39 @@ 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 );
-#else
- *gain = L_shl( Portion, sub( 13, Q_new ) );
-#endif
move32();
return;
}
-
/*---------------------------------------------------------------------*
* Put selected codevector positions and signs into quantization index
*---------------------------------------------------------------------*/
-static Word16 cod_2pos_fx( /* o : codebook quantization index */
- const Word16 ind1, /* i : index of 1st gaussian vector */
- const Word16 ind2, /* i : index of 2nd gaussian vector */
- const Word16 sign1, /* i : sign of 1st gaussian vector */
- const Word16 sign2, /* i : sign of 2nd gaussian vector */
- const Word16 n /* i : nb. of codebook vectors */
+static Word16 cod_2pos_fx( /* o : codebook quantization index */
+ const Word16 ind1, /* i : index of 1st gaussian vector Q0*/
+ const Word16 ind2, /* i : index of 2nd gaussian vector Q0*/
+ const Word16 sign1, /* i : sign of 1st gaussian vector Qx*/
+ const Word16 sign2, /* i : sign of 2nd gaussian vector Qx*/
+ const Word16 n /* i : nb. of codebook vectors Q0*/
)
{
Word16 i1, i2, index, s1, s2;
@@ -774,16 +1196,16 @@ static Word16 cod_2pos_fx( /* o : codebook quantization in
{
IF( LE_16( ind1, ind2 ) )
{
- i1 = ind1;
+ i1 = ind1; /* Q0 */
move16();
- i2 = ind2;
+ i2 = ind2; /* Q0 */
move16();
}
ELSE
{
- i1 = ind2;
+ i1 = ind2; /* Q0 */
move16();
- i2 = ind1;
+ i2 = ind1; /* Q0 */
move16();
}
}
@@ -791,16 +1213,16 @@ static Word16 cod_2pos_fx( /* o : codebook quantization in
{
IF( GT_16( ind1, ind2 ) )
{
- i1 = ind1;
+ i1 = ind1; /* Q0 */
move16();
- i2 = ind2;
+ i2 = ind2; /* Q0 */
move16();
}
ELSE
{
- i1 = ind2;
+ i1 = ind2; /* Q0 */
move16();
- i2 = ind1;
+ i2 = ind1; /* Q0 */
move16();
s1 = s2;
move16();
diff --git a/lib_enc/gp_clip.c b/lib_enc/gp_clip.c
deleted file mode 100644
index 7dd2c1f21169fdc182f70f2f4e86aa4bb3106165..0000000000000000000000000000000000000000
--- a/lib_enc/gp_clip.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 "cnst.h"
-#include "wmc_auto.h"
diff --git a/lib_enc/gp_clip_fx.c b/lib_enc/gp_clip_fx.c
index bf532a085cf9fc3164f867f3c3e3db1a1de82d13..b4845a1a43dae07f4e10cc615258262fd586f0fa 100644
--- a/lib_enc/gp_clip_fx.c
+++ b/lib_enc/gp_clip_fx.c
@@ -68,7 +68,7 @@
* Pitch Gain clipping initializations
*-------------------------------------------------------------------*/
void init_gp_clip_fx(
- Word16 mem[] /* o : memory of gain of pitch clipping algorithm */
+ Word16 mem[] /* o : memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/
)
{
mem[0] = DIST_ISF_MAX;
@@ -98,13 +98,13 @@ void init_gp_clip_fx(
*-------------------------------------------------------------------*/
Word16 gp_clip_fx(
- const Word16 element_mode, /* i : element mode */
- const Word32 core_brate, /* i : core bitrate */
- const Word16 *voicing, /* i : normalized correlations (from OL pitch) */
- const Word16 i_subfr, /* i : subframe index */
- const Word16 coder_type, /* i : type of coder */
- const Word16 xn[], /* i : target vector */
- Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm */
+ const Word16 element_mode, /* i : element mode Q0*/
+ const Word32 core_brate, /* i : core bitrate Q0*/
+ const Word16 *voicing, /* i : normalized correlations (from OL pitch) Q15*/
+ const Word16 i_subfr, /* i : subframe index Q0*/
+ const Word16 coder_type, /* i : type of coder Q0*/
+ const Word16 xn[], /* i : target vector Q_new*/
+ Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/
const Word16 Q_new /* i : scaling factor */
)
{
@@ -116,16 +116,16 @@ Word16 gp_clip_fx(
Word16 thres;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
clip = 0;
move16();
test();
test();
- IF( EQ_32( core_brate, ACELP_6k60 ) || EQ_32( core_brate, ACELP_8k85 ) || GT_16( element_mode, EVS_MONO ) )
+ IF( EQ_32( core_brate, ACELP_6k60 ) || EQ_32( core_brate, ACELP_8k85 ) || element_mode > EVS_MONO )
{
- thres = add( 14746, mult( 1638, extract_l( L_mult( mem[0], (Word16) ( 16384 / DIST_ISF_MAX_IO ) ) ) ) ); /* clipping is activated when filtered pitch gain > threshold (0.94 to 1 in Q14) */
- test();
+ thres = add( 14746 /* 0.9 in Q14 */, mult( 1638 /* 0.1 in Q14 */, extract_l( L_mult( mem[0], (Word16) ( 16384 / DIST_ISF_MAX_IO ) ) ) ) ); /* clipping is activated when filtered pitch gain > threshold (0.94 to 1 in Q14) */
if ( GT_16( mem[1], thres ) )
{
clip = 1;
@@ -142,25 +142,17 @@ 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) */
e_ener = norm_l( ener );
f_ener = Log2_norm_lc( L_shl( ener, e_ener ) );
e_ener = sub( 30, e_ener );
- IF( GT_16( element_mode, EVS_MONO ) )
+ IF( element_mode > EVS_MONO )
{
e_ener = sub( e_ener, Q_new * 2 + 1 );
}
@@ -168,20 +160,20 @@ Word16 gp_clip_fx(
{
e_ener = sub( e_ener, Q_new );
}
- ener = Mpy_32_16( e_ener, f_ener, LG10 );
- wener = round_fx( L_shl( ener, 10 ) );
+ ener = Mpy_32_16( e_ener, f_ener, LG10 ); /* Q14 */
+ wener = round_fx( L_shl( ener, 10 ) ); /* Q8 */
test();
- if ( LT_16( wener, sub( mem[2], 1536 ) ) && GT_16( mem[1], 16384 ) )
+ if ( LT_16( wener, sub( mem[2], 1536 /* 6.0f in Q8 */ ) ) && GT_16( mem[1], 16384 /* 1 in Q14 */ ) )
{
clip = 1;
move16();
}
- mem[2] = wener;
+ mem[2] = wener; /* Q8 */
move16();
- L_tmp = L_mult( ALPHA1, mem[4] );
+ L_tmp = L_mult( ALPHA1, mem[4] ); /* Q30 */
test();
test();
@@ -189,19 +181,19 @@ Word16 gp_clip_fx(
{
/* mem[4] = (1-ALPHA1) + ALPHA1 * mem[4], if branch taken */
/* mem[4] = ALPHA1 * mem[4], otherwise */
- L_tmp = L_add( L_tmp, 32768L * ( 32768 - ALPHA1 ) );
+ L_tmp = L_add( L_tmp, 32768L * ( 32768 - ALPHA1 ) ); /* Q30 */
}
- mem[4] = round_fx( L_tmp );
+ mem[4] = round_fx( L_tmp ); /* Q14 */
L_tmp = L_mult( ALPHA4, mem[5] );
- if ( i_subfr == 0 )
+ IF( i_subfr == 0 )
{
/* mem[5] = (1-ALPHA4) * voicing[0] + ALPHA4 * mem[5] */
mem[5] = mac_r( L_tmp, ( 32768 - ALPHA4 ) / 2, voicing[0] );
move16(); /* /2 to put voicing from Q15 to Q14 */
}
- if ( EQ_16( i_subfr, 2 * L_SUBFR ) )
+ IF( EQ_16( i_subfr, 2 * L_SUBFR ) )
{
/* mem[5] = (1-ALPHA4) * voicing[1] + ALPHA4 * mem[5] */
mem[5] = mac_r( L_tmp, ( 32768 - ALPHA4 ) / 2, voicing[1] );
@@ -219,7 +211,7 @@ Word16 gp_clip_fx(
}
ELSE
{
- mem[3] = add( mem[3], 1 );
+ mem[3] = add( mem[3], 1 ); /* Q0 */
move16();
}
@@ -233,16 +225,16 @@ Word16 gp_clip_fx(
*-------------------------------------------------------------------*/
void gp_clip_test_isf_fx(
- const Word16 element_mode, /* i : element mode */
- const Word32 core_brate, /* i : core bitrate */
- const Word16 isf[], /* i : isf values (in frequency domain) */
- Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm */
- const Word16 Opt_AMR_WB /* i : flag indicating AMR-WB IO mode */
+ const Word16 element_mode, /* i : element mode Q0*/
+ const Word32 core_brate, /* i : core bitrate Q0*/
+ const Word16 isf[], /* i : isf values (in frequency domain) Q2.56*/
+ Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm Q15*/
+ const Word16 Opt_AMR_WB /* i : flag indicating AMR-WB IO mode Q0*/
)
{
Word16 i, dist, dist_min, m;
- dist_min = sub( isf[1], isf[0] );
+ dist_min = sub( isf[1], isf[0] ); /* Q2.56 */
m = M;
move16();
@@ -255,15 +247,15 @@ void gp_clip_test_isf_fx(
move16(); /* ptr init*/
FOR( i = 2; i < m; i++ )
{
- dist = sub( isf[i], isf[i - 1] );
- dist_min = s_min( dist, dist_min );
+ dist = sub( isf[i], isf[i - 1] ); /* Q2.56 */
+ dist_min = s_min( dist, dist_min ); /* Q2.56 */
}
- dist = extract_h( L_mac( L_mult( 26214, mem[0] ), 6554, dist_min ) );
+ dist = extract_h( L_mac( L_mult( 26214 /* 0.8f in Q15 */, mem[0] ), 6554 /* 0.2f in Q15 */, dist_min ) ); /* Q15 */
test();
test();
- IF( EQ_32( core_brate, ACELP_6k60 ) || EQ_32( core_brate, ACELP_8k85 ) || GT_16( element_mode, EVS_MONO ) )
+ IF( EQ_32( core_brate, ACELP_6k60 ) || EQ_32( core_brate, ACELP_8k85 ) || element_mode > EVS_MONO )
{
dist = s_min( dist, DIST_ISF_MAX_IO );
}
@@ -271,7 +263,7 @@ void gp_clip_test_isf_fx(
{
dist = s_min( dist, DIST_ISF_MAX );
}
- mem[0] = dist;
+ mem[0] = dist; /* Q15 */
move16();
return;
@@ -284,10 +276,10 @@ void gp_clip_test_isf_fx(
*-------------------------------------------------------------------*/
void gp_clip_test_gain_pit_fx(
- const Word16 element_mode, /* i : element mode */
- const Word32 core_brate, /* i : core bitrate */
- const Word16 gain_pit, /* i : gain of quantized pitch Q14 */
- Word16 mem[] /* i/o: memory of gain of pitch clipping algorithm 1Q14 */
+ const Word16 element_mode, /* i : element mode Q0*/
+ const Word32 core_brate, /* i : core bitrate Q0*/
+ const Word16 gain_pit, /* i : gain of quantized pitch Q14*/
+ Word16 mem[] /* i/o: memory of gain of pitch clipping algorithm 1Q14*/
)
{
Word16 gain;
@@ -295,19 +287,19 @@ void gp_clip_test_gain_pit_fx(
test();
test();
- IF( EQ_32( core_brate, ACELP_6k60 ) || EQ_32( core_brate, ACELP_8k85 ) || GT_16( element_mode, EVS_MONO ) )
+ IF( EQ_32( core_brate, ACELP_6k60 ) || EQ_32( core_brate, ACELP_8k85 ) || element_mode > EVS_MONO )
{
- L_tmp = L_mult( 32113, mem[1] ); /* long term LTP gain average (>250ms) */
- L_tmp = L_mac( L_tmp, 655, gain_pit );
+ L_tmp = L_mult( 32113 /* 0.98 in Q15 */, mem[1] ); /* long term LTP gain average (>250ms) */
+ L_tmp = L_mac( L_tmp, 655 /* 0.02 in Q15 */, gain_pit );
}
ELSE
{
- L_tmp = L_mult( 29491, mem[1] );
- L_tmp = L_mac( L_tmp, 3277, gain_pit );
+ L_tmp = L_mult( 29491 /* 0.9 in Q15 */, mem[1] );
+ L_tmp = L_mac( L_tmp, 3277 /* 0.1 in Q15 */, gain_pit );
}
gain = extract_h( L_tmp );
gain = s_max( gain, GAIN_PIT_MIN );
- mem[1] = gain;
+ mem[1] = gain; /* Q14 */
move16();
return;
@@ -323,10 +315,10 @@ void gp_clip_test_gain_pit_fx(
* prediction (lp_gp > 0.9)
* - target energy drops by 6 dB AND a good pitch prediction (lp_gp>1.0)
*-------------------------------------------------------------------*/
-Word16 Mode2_gp_clip(
+Word16 Mode2_gp_clip_fx(
const Word16 *voicing, /* i : normalized correlations from OL pitch Q15 */
- const Word16 i_subfr, /* i : subframe index */
- const Word16 coder_type, /* i : type of coder */
+ const Word16 i_subfr, /* i : subframe index Q0 */
+ const Word16 coder_type, /* i : type of coder Q0 */
const Word16 xn[], /* i : target vector Q_xn */
Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm */
/* mem[0]: Q0 */
@@ -335,8 +327,8 @@ Word16 Mode2_gp_clip(
/* mem[3]: Q0 (integer) */
/* mem[4]: Q14 */
/* mem[5]: Q14 */
- const Word16 L_subfr,
- const Word16 Q_xn /* i : scaling factor of vector xn[] */
+ const Word16 L_subfr, /* Q0 */
+ const Word16 Q_xn /* i : scaling factor of vector xn[] */
)
{
Word16 clip, tmp, exp_xn;
@@ -344,6 +336,7 @@ Word16 Mode2_gp_clip(
Word32 wener, Ltmp;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
move16();
clip = 0;
@@ -362,11 +355,7 @@ Word16 Mode2_gp_clip(
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);*/
@@ -393,20 +382,20 @@ Word16 Mode2_gp_clip(
if ( s_or( (Word16) EQ_16( coder_type, GENERIC ), (Word16) EQ_16( coder_type, TRANSITION ) ) )
{
- Ltmp = L_add( Ltmp, ALPHA1_M1 );
+ Ltmp = L_add( Ltmp, ALPHA1_M1 ); /* Q30 */
}
- mem[4] = round_fx( Ltmp );
+ mem[4] = round_fx( Ltmp ); /* Q14 */
Ltmp = Mpy_32_16_1( ALPHA4, mem[5] ); /* mem[5] in Q14 format, Ltmp in Q14 */
IF( i_subfr == 0 )
{
- move16(); /* voicing: Q15 */
- mem[5] = round_fx( L_add( Mpy_32_16_1( ALPHA4_M1, voicing[0] ), Ltmp ) );
+ move16(); /* voicing: Q15 */
+ mem[5] = round_fx( L_add( Mpy_32_16_1( ALPHA4_M1, voicing[0] ), Ltmp ) ); /* Q14 */
}
ELSE IF( EQ_16( i_subfr, shl( L_subfr, 1 ) ) )
{
move16();
- mem[5] = round_fx( L_add( Mpy_32_16_1( ALPHA4_M1, voicing[1] ), Ltmp ) );
+ mem[5] = round_fx( L_add( Mpy_32_16_1( ALPHA4_M1, voicing[1] ), Ltmp ) ); /* Q14 */
}
IF( GT_16( mem[3], WINDOW_SIZE ) )
@@ -421,7 +410,7 @@ Word16 Mode2_gp_clip(
ELSE
{
move16();
- mem[3] = add( mem[3], 1 );
+ mem[3] = add( mem[3], 1 ); /* Q0 */
}
@@ -434,10 +423,10 @@ Word16 Mode2_gp_clip(
* check the minimum distance of LSFs for pitch gain clipping flag
*-------------------------------------------------------------------*/
void gp_clip_test_lsf_fx(
- const Word16 element_mode, /* i : element mode */
- const Word16 lsf[], /* i : lsf values (in frequency domain) 14Q1*1.28 */
- Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm */
- const Word16 m /* i : dimension of lsf */
+ const Word16 element_mode, /* i : element mode Q0*/
+ const Word16 lsf[], /* i : lsf values (in frequency domain) 14Q1*1.28*/
+ Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/
+ const Word16 m /* i : dimension of lsf Q0*/
)
{
Word16 i;
@@ -445,22 +434,22 @@ void gp_clip_test_lsf_fx(
dist_max = DIST_ISF_MAX;
move16();
- if ( GT_16( element_mode, EVS_MONO ) )
+ if ( element_mode > EVS_MONO )
{
dist_max = DIST_ISF_MAX_IO;
move16();
}
- dist_min = sub( lsf[1], lsf[0] );
+ dist_min = sub( lsf[1], lsf[0] ); /* 14Q1*1.28 */
FOR( i = 2; i < m - 1; i++ )
{
- dist = sub( lsf[i], lsf[i - 1] );
+ dist = sub( lsf[i], lsf[i - 1] ); /* 14Q1*1.28 */
dist_min = s_min( dist, dist_min );
}
/*dist = 0.8f*mem[0] + 0.2f*dist_min;*/
- dist = s_min( dist_max, mac_r( L_mult( 26214 /*0.8f Q15*/, mem[0] ), 6554 /*0.2f Q15*/, dist_min ) );
+ dist = s_min( dist_max, mac_r( L_mult( 26214 /*0.8f Q15*/, mem[0] ), 6554 /*0.2f Q15*/, dist_min ) ); /* x2.56 */
- mem[0] = dist;
+ mem[0] = dist; /* x2.56 */
move16();
@@ -468,18 +457,18 @@ void gp_clip_test_lsf_fx(
}
void gp_clip_test_lsf_ivas_fx(
- const Word16 element_mode, /* i : element mode */
- const Word32 core_brate, /* i : core bitrate */
- const Word16 lsf[], /* i : LSF vector */
- Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm */
- const Word16 Opt_AMR_WB /* i : flag indicating AMR-WB IO mode */
+ const Word16 element_mode, /* i : element mode Q0*/
+ const Word32 core_brate, /* i : core bitrate Q0*/
+ const Word16 lsf[], /* i : LSF vector 14Q1*1.28*/
+ Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/
+ const Word16 Opt_AMR_WB /* i : flag indicating AMR-WB IO mode Q0*/
)
{
Word16 i;
Word16 m;
Word16 dist, dist_min;
- dist_min = sub( lsf[1], lsf[0] );
+ dist_min = sub( lsf[1], lsf[0] ); /* 14Q1*1.28 */
IF( Opt_AMR_WB )
{
@@ -494,12 +483,12 @@ void gp_clip_test_lsf_ivas_fx(
FOR( i = 2; i < m; i++ )
{
- dist = sub( lsf[i], lsf[i - 1] );
+ dist = sub( lsf[i], lsf[i - 1] ); /* 14Q1*1.28 */
dist_min = s_min( dist, dist_min );
}
// dist = 0.8f * mem[0] + 0.2f * dist_min;
- dist = mac_r( L_mult( 26214 /*0.8f Q15*/, mem[0] ), 6554 /*0.2f Q15*/, dist_min );
+ dist = mac_r( L_mult( 26214 /*0.8f Q15*/, mem[0] ), 6554 /*0.2f Q15*/, dist_min ); /* 2.56x */
test();
test();
@@ -517,7 +506,7 @@ void gp_clip_test_lsf_ivas_fx(
move16();
}
- mem[0] = dist;
+ mem[0] = dist; /* 2.56x */
move16();
return;
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 b63ebeb3af9c631cb03c53907e5d3824c2a4b17b..53ad3dbb20a352a0240f4cdeb6957c30dea10d1c 100644
--- a/lib_enc/hq_classifier_enc_fx.c
+++ b/lib_enc/hq_classifier_enc_fx.c
@@ -28,10 +28,10 @@
* Local functions
*-----------------------------------------------------------------*/
-void hvq_classifier_fx( const Word32 *input, Word16 *prev_Npeaks, Word16 *prev_peaks, Word16 *hqswb_clas, Word16 *Npeaks, Word16 *peaks, const Word32 L_core_brate, const Word16 last_core, Word32 *L_nf_gains, Word16 *hvq_hangover, Word32 *L_pe_gains );
+void hvq_classifier_fx( const Word32 *input /*Q12*/, Word16 *prev_Npeaks, Word16 *prev_peaks, Word16 *hqswb_clas, Word16 *Npeaks, Word16 *peaks, const Word32 L_core_brate, const Word16 last_core, Word32 *L_nf_gains /*Q12*/, Word16 *hvq_hangover, Word32 *L_pe_gains /*Q12*/ );
static Word16 hf_spectrum_sparseness_fx(
Encoder_State *st, /* i/o: encoder state structure */
- const Word32 *coefs_fx /* i : MDCT spectrum */
+ const Word32 *coefs_fx /* i : MDCT spectrum Q12*/
);
/*--------------------------------------------------------------------------*
* hf_spectrum_sparseness()
@@ -64,8 +64,8 @@ static Word16 hf_spectrum_sparseness_fx(
Word16 inv_rms32_e = 0;
move16();
- crest_lp_fx = &st->hHQ_core->crest_lp_fx;
- crest_mod_lp_fx = &st->hHQ_core->crest_mod_lp_fx;
+ crest_lp_fx = &st->hHQ_core->crest_lp_fx; /* &st->hHQ_core->crest_lp_q */
+ crest_mod_lp_fx = &st->hHQ_core->crest_mod_lp_fx; /* &st->hHQ_core->crest_mod_lp_q */
result = TRUE;
move16();
@@ -74,7 +74,7 @@ static Word16 hf_spectrum_sparseness_fx(
FOR( i = 0; i < L_SPEC_HB; i++ )
{
- A_fx[i] = L_abs( coefs_fx[i + L_SPEC_HB] );
+ A_fx[i] = L_abs( coefs_fx[i + L_SPEC_HB] ); /* Q12 */
move32();
}
low_count_fx = 0;
@@ -88,24 +88,25 @@ static Word16 hf_spectrum_sparseness_fx(
IF( Amax_fx == 0 )
{
/* For all-zero input the crest is 1.0 */
- crest_fx = L_shl( 1, st->hHQ_core->crest_lp_q );
- crest_mod_fx = L_shl( 1, st->hHQ_core->crest_mod_lp_q );
+ crest_fx = L_shl( 1, st->hHQ_core->crest_lp_q ); /* &st->hHQ_core->crest_lp_q */
+ crest_mod_fx = L_shl( 1, st->hHQ_core->crest_mod_lp_q ); /* &st->hHQ_core->crest_mod_lp_q */
low_count_fx = 0;
move16();
}
ELSE
{
#endif
- thr_fx = Mpy_32_32( Amax_fx, PEAK_THRESHOLD_FX );
- movmean_fx = 0; /* avoid uninitialized warning */
- // p_num = &inv_tbl[HALF_WIN_LENGTH + 1]; /* Table for division 1./(11:21) */
- p_num_fx = &inv_tbl_fx[HALF_WIN_LENGTH + 1]; /* Table for division 1./(11:21) */
+ thr_fx = Mpy_32_32( Amax_fx, PEAK_THRESHOLD_FX ); /* Q12 */
+ movmean_fx = 0; /* avoid uninitialized warning */
+ move32();
+ // p_num = &inv_tbl[HALF_WIN_LENGTH + 1]; /* Table for division 1./(11:21) */
+ p_num_fx = &inv_tbl_fx[HALF_WIN_LENGTH + 1]; /* Table for division 1./(11:21) Q15*/
FOR( i = 0; i < L_SPEC_HB; i++ )
{
// inv_rms += A[i] * A[i];
- inv_rms_fx = W_add( inv_rms_fx, W_shr( W_mult0_32_32( A_fx[i], A_fx[i] ), Q9 ) ); // 2*Q12 -Q9 (Q9 for guard bits
+ inv_rms_fx = W_add( inv_rms_fx, W_shr( W_mult0_32_32( A_fx[i], A_fx[i] ), Q9 ) ); // 2*Q12 -Q9 (Q9 for guard bits) Q15
- if ( LT_32( A_fx[i], thr_fx ) )
+ IF( LT_32( A_fx[i], thr_fx ) )
{
low_count_fx = add( low_count_fx, 1 );
}
@@ -136,27 +137,27 @@ static Word16 hf_spectrum_sparseness_fx(
}
}
- if ( LT_32( crest_mod_fx, movmean_fx ) )
+ IF( LT_32( crest_mod_fx, movmean_fx ) )
{
crest_mod_fx = movmean_fx; // Q12
move32();
}
}
Word16 l_shift = W_norm( inv_rms_fx );
- inv_rms32_fx = W_extract_h( W_shl( inv_rms_fx, l_shift ) ); // Q15+l_shift-32
- Word16 q_rms = sub( add( Q15, l_shift ), 32 ); // q_rms
- inv_rms32_div_fx = BASOP_Util_Divide3232_Scale_cadence( inv_rms32_fx, L_SPEC_HB, &inv_rms32_e );
+ inv_rms32_fx = W_extract_h( W_shl( inv_rms_fx, l_shift ) ); // Q15+l_shift-32
+ Word16 q_rms = sub( add( Q15, l_shift ), 32 ); // q_rms
+ inv_rms32_div_fx = BASOP_Util_Divide3232_Scale_cadence( inv_rms32_fx, L_SPEC_HB, &inv_rms32_e ); /* Q31-inv_rms32_e */
inv_rms32_e = sub( 31, add( sub( Q31, inv_rms32_e ), q_rms ) );
// inv_rms = 1.0f / (float) sqrtf( inv_rms / L_SPEC_HB );
- inv_rms32_fx = ISqrt32( inv_rms32_div_fx, &inv_rms32_e );
+ inv_rms32_fx = ISqrt32( inv_rms32_div_fx, &inv_rms32_e ); /* Q31-inv_rms32_e */
- crest_fx = Mpy_32_32( Amax_fx, inv_rms32_fx ); // Q12 + (Q31-inv_rms32_e) -Q31 = Q12 - inv_rms32_e
- crest_mod_fx = Mpy_32_32( crest_mod_fx, inv_rms32_fx ); // Q12 + (Q31-inv_rms32_e) -Q31 = Q12 - inv_rms32_e
- *crest_lp_fx = L_shr( *crest_lp_fx, sub( st->hHQ_core->crest_lp_q, sub( Q12, inv_rms32_e ) ) );
+ crest_fx = Mpy_32_32( Amax_fx, inv_rms32_fx ); // Q12 + (Q31-inv_rms32_e) -Q31 = Q12 - inv_rms32_e
+ crest_mod_fx = Mpy_32_32( crest_mod_fx, inv_rms32_fx ); // Q12 + (Q31-inv_rms32_e) -Q31 = Q12 - inv_rms32_e
+ *crest_lp_fx = L_shr( *crest_lp_fx, sub( st->hHQ_core->crest_lp_q, sub( Q12, inv_rms32_e ) ) ); /* Q12-inv_rms32_e */
move32();
st->hHQ_core->crest_lp_q = sub( Q12, inv_rms32_e );
move16();
- *crest_mod_lp_fx = L_shr( *crest_mod_lp_fx, sub( st->hHQ_core->crest_mod_lp_q, sub( Q12, inv_rms32_e ) ) );
+ *crest_mod_lp_fx = L_shr( *crest_mod_lp_fx, sub( st->hHQ_core->crest_mod_lp_q, sub( Q12, inv_rms32_e ) ) ); /* Q12-inv_rms32_e */
move32();
st->hHQ_core->crest_mod_lp_q = sub( Q12, inv_rms32_e );
move16();
@@ -179,7 +180,7 @@ static Word16 hf_spectrum_sparseness_fx(
}
}
- return result;
+ return result; /* Q0 */
}
/*--------------------------------------------------------------------------*
* hq_classifier_enc_fx()
@@ -216,7 +217,8 @@ Word16 hq_classifier_enc_fx( /* o : Consumed bits
IF( EQ_16( length, L_FRAME32k ) && NE_16( is_transient, 1 ) && LE_32( st_fx->core_brate, HQ_32k ) && EQ_16( st_fx->bwidth, st_fx->last_bwidth ) )
{
/* Detect HQ_HARMONIC mode */
- *hqswb_clas = peak_avrg_ratio_fx( st_fx->total_brate, coefs, NUMC_N + 96, &hHQ_core->mode_count, &hHQ_core->mode_count1, 12 );
+ *hqswb_clas = peak_avrg_ratio_fx( st_fx->total_brate, coefs, NUMC_N + 96, &hHQ_core->mode_count, &hHQ_core->mode_count1, 12 ); /* Q0 */
+ move16();
/* Detect harmonic VQ mode HQ_HVQ */
hvq_classifier_fx( coefs, &hHQ_core->prev_Npeaks, hHQ_core->prev_peaks, hqswb_clas, Npeaks, peaks, st_fx->core_brate, st_fx->last_core,
@@ -229,7 +231,8 @@ Word16 hq_classifier_enc_fx( /* o : Consumed bits
IF( EQ_16( length, L_FRAME48k ) && NE_16( is_transient, 1 ) && LE_32( st_fx->core_brate, HQ_32k ) && EQ_16( st_fx->bwidth, st_fx->last_bwidth ) )
{
/* Detect HQ_HARMONIC mode */
- *hqswb_clas = peak_avrg_ratio_fx( st_fx->total_brate, coefs, NUMC_N + 96, &hHQ_core->mode_count, &hHQ_core->mode_count1, 12 );
+ *hqswb_clas = peak_avrg_ratio_fx( st_fx->total_brate, coefs, NUMC_N + 96, &hHQ_core->mode_count, &hHQ_core->mode_count1, 12 ); /* Q0 */
+ move16();
/* Detect harmonic VQ mode HQ_HVQ */
hvq_classifier_fx( coefs, &hHQ_core->prev_Npeaks, hHQ_core->prev_peaks, hqswb_clas, Npeaks, peaks,
st_fx->core_brate, st_fx->last_core, nf_gains, &hHQ_core->hvq_hangover, pe_gains );
@@ -239,7 +242,7 @@ Word16 hq_classifier_enc_fx( /* o : Consumed bits
test();
IF( EQ_16( length, L_FRAME48k ) && LE_32( st_fx->core_brate, HQ_32k ) && EQ_16( *hqswb_clas, HQ_NORMAL ) )
{
- *hqswb_clas = HQ_GEN_FB;
+ *hqswb_clas = HQ_GEN_FB; /* Q0 */
move16();
}
@@ -276,7 +279,7 @@ Word16 hq_classifier_enc_fx( /* o : Consumed bits
test();
IF( EQ_16( *hqswb_clas, HQ_NORMAL ) && EQ_16( length, L_FRAME32k ) && LE_32( st_fx->core_brate, HQ_32k ) )
{
- *hqswb_clas = HQ_GEN_SWB;
+ *hqswb_clas = HQ_GEN_SWB; /* Q0 */
move16();
}
#else
@@ -289,7 +292,7 @@ Word16 hq_classifier_enc_fx( /* o : Consumed bits
max_brate = HQ_32k;
move32();
- if ( GT_16( st_fx->element_mode, EVS_MONO ) )
+ if ( st_fx->element_mode > EVS_MONO )
{
max_brate = HQ_48k;
move32();
@@ -320,6 +323,7 @@ Word16 hq_classifier_enc_fx( /* o : Consumed bits
harmonic_decision = hf_spectrum_sparseness( st, coefs );
#else
harmonic_decision = 0;
+ move16();
#endif
test();
IF( EQ_16( *hqswb_clas, HQ_HARMONIC ) && !harmonic_decision )
@@ -391,12 +395,12 @@ Word16 hq_classifier_enc_ivas_fx( /* o : Consumed bi
move32();
}
- *hqswb_clas = HQ_NORMAL;
+ *hqswb_clas = HQ_NORMAL; /* Q0 */
bits = 1;
move16();
IF( EQ_16( is_transient, 1 ) )
{
- *hqswb_clas = HQ_TRANSIENT;
+ *hqswb_clas = HQ_TRANSIENT; /* Q0 */
move16();
}
@@ -410,7 +414,7 @@ Word16 hq_classifier_enc_ivas_fx( /* o : Consumed bi
IF( !is_transient && EQ_16( st_fx->bwidth, st_fx->last_bwidth ) )
{
/* Detect HQ_HARMONIC mode */
- *hqswb_clas = peak_avrg_ratio_ivas_fx( st_fx->total_brate, coefs, NUMC_N + 96, &hHQ_core->mode_count, &hHQ_core->mode_count1, 12 );
+ *hqswb_clas = peak_avrg_ratio_ivas_fx( st_fx->total_brate, coefs, NUMC_N + 96, &hHQ_core->mode_count, &hHQ_core->mode_count1, 12 ); /* Q0 */
harmonic_decision = hf_spectrum_sparseness_fx( st_fx, coefs );
@@ -418,7 +422,7 @@ Word16 hq_classifier_enc_ivas_fx( /* o : Consumed bi
test();
IF( EQ_16( *hqswb_clas, HQ_HARMONIC ) && !harmonic_decision )
{
- *hqswb_clas = HQ_NORMAL;
+ *hqswb_clas = HQ_NORMAL; /* Q0 */
move16();
}
ELSE
@@ -443,17 +447,17 @@ Word16 hq_classifier_enc_ivas_fx( /* o : Consumed bi
{
IF( EQ_16( length, L_SPEC32k ) )
{
- *hqswb_clas = HQ_GEN_SWB;
+ *hqswb_clas = HQ_GEN_SWB; /* Q0 */
move16();
}
ELSE IF( EQ_16( length, L_SPEC48k ) )
{
- *hqswb_clas = HQ_GEN_FB;
+ *hqswb_clas = HQ_GEN_FB; /* Q0 */
move16();
}
}
- return bits;
+ return bits; /* Q0 */
}
/*--------------------------------------------------------------------------*
* peak_avrg_ratio()
@@ -461,9 +465,9 @@ Word16 hq_classifier_enc_ivas_fx( /* o : Consumed bi
* Classify the input signal and decide if it has a harmonic structure
*--------------------------------------------------------------------------*/
Word16 peak_avrg_ratio_ivas_fx(
- const Word32 total_brate, /* i : total bitrate */
+ const Word32 total_brate, /* i : total bitrate Q0*/
const Word32 *input_hi_fx, /* i : input signal Q_coeff */
- const Word16 length, /* i : number of coefficients */
+ const Word16 length, /* i : number of coefficients Q0*/
Word16 *mode_count, /* i/o: HQ_HARMONIC mode count Q0*/
Word16 *mode_count1, /* i/o: HQ_NORMAL mode count Q0*/
Word16 Q_coeff )
@@ -488,6 +492,7 @@ Word16 peak_avrg_ratio_ivas_fx(
k1 = 0;
move16();
q = 96; /* q used for indexing */
+ move16();
FOR( i = 3; i < 17; i++ )
{
@@ -500,11 +505,12 @@ Word16 peak_avrg_ratio_ivas_fx(
input_abs_fx[q] = L_shr( input_abs_fx[q], 5 ); /*Q_coeff-5 */
move32();
mean_fx = L_add( mean_fx, input_abs_fx[q] ); /*Q_coeff-5 */
- IF( GT_32( input_abs_fx[q], peak_fx ) )
+ if ( GT_32( input_abs_fx[q], peak_fx ) )
{
peak_fx = input_abs_fx[q]; /*Q_coeff-5 */
+ move32();
}
- q = add( q, 1 );
+ q += 1;
}
IF( LT_16( i, 8 ) )
@@ -528,26 +534,30 @@ Word16 peak_avrg_ratio_ivas_fx(
test();
IF( GE_16( add( k, k1 ), 10 ) && GT_16( k1, 5 ) )
{
- if ( LT_16( *mode_count, 8 ) )
+ IF( LT_16( *mode_count, 8 ) )
{
*mode_count = add( *mode_count, 1 );
+ move16();
}
- if ( *mode_count1 > 0 )
+ IF( *mode_count1 > 0 )
{
*mode_count1 = sub( *mode_count1, 1 );
+ move16();
}
}
ELSE
{
- if ( LT_16( *mode_count1, 8 ) )
+ IF( LT_16( *mode_count1, 8 ) )
{
*mode_count1 = add( *mode_count1, 1 );
+ move16();
}
- if ( *mode_count > 0 )
+ IF( *mode_count > 0 )
{
*mode_count = sub( *mode_count, 1 );
+ move16();
}
}
@@ -558,12 +568,12 @@ Word16 peak_avrg_ratio_ivas_fx(
test();
test();
- if ( ( GE_16( add( k, k1 ), 5 ) && GT_16( k1, 2 ) && LT_32( total_brate, HQ_BWE_CROSSOVER_BRATE ) ) || ( ( ( GE_16( add( k, k1 ), 10 ) && GT_16( k1, 5 ) ) || GE_16( *mode_count, 5 ) ) && LT_16( *mode_count1, 5 ) ) )
+ IF( ( GE_16( add( k, k1 ), 5 ) && GT_16( k1, 2 ) && LT_32( total_brate, HQ_BWE_CROSSOVER_BRATE ) ) || ( ( ( GE_16( add( k, k1 ), 10 ) && GT_16( k1, 5 ) ) || GE_16( *mode_count, 5 ) ) && LT_16( *mode_count1, 5 ) ) )
{
hqswb_clas = HQ_HARMONIC;
move16();
}
- return hqswb_clas;
+ return hqswb_clas; /* Q0 */
}
/*--------------------------------------------------------------------------*
* peak_avrg_ratio()
@@ -571,11 +581,11 @@ Word16 peak_avrg_ratio_ivas_fx(
* Classify the input signal and decide if it has a harmonic structure
*--------------------------------------------------------------------------*/
Word16 peak_avrg_ratio_fx(
- const Word32 total_brate, /* i : total bitrate */
- const Word32 *input_hi_fx, /* i : input signal */
- const Word16 length, /* i : number of coefficients */
- Word16 *mode_count, /* i/o: HQ_HARMONIC mode count */
- Word16 *mode_count1, /* i/o: HQ_NORMAL mode count */
+ const Word32 total_brate, /* i : total bitrate Q0*/
+ const Word32 *input_hi_fx, /* i : input signal Q_coeff*/
+ const Word16 length, /* i : number of coefficients Q0*/
+ Word16 *mode_count, /* i/o: HQ_HARMONIC mode count Q0*/
+ Word16 *mode_count1, /* i/o: HQ_NORMAL mode count Q0*/
Word16 Q_coeff )
{
Word16 i, j, q, k, k1, hqswb_clas;
@@ -585,7 +595,7 @@ Word16 peak_avrg_ratio_fx(
FOR( i = 96; i < length; i++ )
{
- input_abs_fx[i] = L_abs( input_hi_fx[i] );
+ input_abs_fx[i] = L_abs( input_hi_fx[i] ); /* Q_coeff */
}
hqswb_clas = HQ_NORMAL;
@@ -597,6 +607,7 @@ Word16 peak_avrg_ratio_fx(
k1 = 0;
move16();
q = 96; /* q used for indexing */
+ move16();
FOR( i = 3; i < 17; i++ )
{
@@ -607,12 +618,14 @@ Word16 peak_avrg_ratio_fx(
FOR( j = 0; j < 32; j++ )
{
input_abs_fx[q] = L_shr( input_abs_fx[q], 5 ); /*Q_coeff-5 */
- mean_fx = L_add( mean_fx, input_abs_fx[q] ); /*Q_coeff-5 */
- IF( GT_32( input_abs_fx[q], peak_fx ) )
+ move32();
+ mean_fx = L_add( mean_fx, input_abs_fx[q] ); /*Q_coeff-5 */
+ if ( GT_32( input_abs_fx[q], peak_fx ) )
{
peak_fx = input_abs_fx[q]; /*Q_coeff-5 */
+ move32();
}
- q++;
+ q += 1;
}
IF( LT_16( i, 8 ) )
@@ -636,26 +649,30 @@ Word16 peak_avrg_ratio_fx(
test();
IF( GE_16( add( k, k1 ), 10 ) && GT_16( k1, 5 ) )
{
- if ( LT_16( *mode_count, 8 ) )
+ IF( LT_16( *mode_count, 8 ) )
{
*mode_count = add( *mode_count, 1 );
+ move16();
}
- if ( *mode_count1 > 0 )
+ IF( *mode_count1 > 0 )
{
*mode_count1 = sub( *mode_count1, 1 );
+ move16();
}
}
ELSE
{
- if ( LT_16( *mode_count1, 8 ) )
+ IF( LT_16( *mode_count1, 8 ) )
{
*mode_count1 = add( *mode_count1, 1 );
+ move16();
}
- if ( *mode_count > 0 )
+ IF( *mode_count > 0 )
{
*mode_count = sub( *mode_count, 1 );
+ move16();
}
}
@@ -666,7 +683,7 @@ Word16 peak_avrg_ratio_fx(
test();
test();
#ifndef SOLVED_COMP_ENC_DEC /*This affect BE even if it shouldn't*/
- if ( ( GE_16( add( k, k1 ), 5 ) && GT_16( k1, 2 ) && EQ_32( total_brate, HQ_24k40 ) ) || ( ( ( GE_16( add( k, k1 ), 10 ) && GT_16( k1, 5 ) ) || GE_16( *mode_count, 5 ) ) && LT_16( *mode_count1, 5 ) ) )
+ IF( ( GE_16( add( k, k1 ), 5 ) && GT_16( k1, 2 ) && EQ_32( total_brate, HQ_24k40 ) ) || ( ( ( GE_16( add( k, k1 ), 10 ) && GT_16( k1, 5 ) ) || GE_16( *mode_count, 5 ) ) && LT_16( *mode_count1, 5 ) ) )
#else
if ( ( GE_16( add( k, k1 ), 5 ) && GT_16( k1, 2 ) && LT_32( total_brate, HQ_BWE_CROSSOVER_BRATE ) ) || ( ( ( GE_16( add( k, k1 ), 10 ) && GT_16( k1, 5 ) ) || GE_16( *mode_count, 5 ) ) && LT_16( *mode_count1, 5 ) ) )
#endif
@@ -675,7 +692,7 @@ Word16 peak_avrg_ratio_fx(
move16();
}
- return hqswb_clas;
+ return hqswb_clas; /* Q0 */
}
/*--------------------------------------------------------------------------*
@@ -738,19 +755,19 @@ void hvq_classifier_ivas_fx(
{
nsub = HVQ_NSUB_24k;
move16();
- inv_nsub = 4681;
- move16(); /* 1/7 in Q15 */
- inv_gains_nsub = 10923;
- move16(); /* 1/3 in Q15 */
+ inv_nsub = 4681; /* 1/7 in Q15 */
+ move16();
+ inv_gains_nsub = 10923; /* 1/3 in Q15 */
+ move16();
}
ELSE
{
nsub = HVQ_NSUB_32k;
move16();
- inv_nsub = 3277;
- move16(); /* 1/10 in Q15 */
- inv_gains_nsub = 6554;
- move16(); /* 1/5 in Q15 */
+ inv_nsub = 3277; /* 1/10 in Q15 */
+ move16();
+ inv_gains_nsub = 6554; /* 1/5 in Q15 */
+ move16();
}
N = shl( nsub, 5 ); /* Mult by 32 (HVQ_BW) */
@@ -761,10 +778,11 @@ void hvq_classifier_ivas_fx(
{
FOR( i = 0; i < N; i++ )
{
- L_input_abs[i] = L_abs( input[i] );
- if ( L_input_abs[i] > L_input_max )
+ L_input_abs[i] = L_abs( input[i] ); /* Q12 */
+ move16();
+ IF( GT_32( L_input_abs[i], L_input_max ) )
{
- L_input_max = L_input_abs[i];
+ L_input_max = L_input_abs[i]; /* Q12 */
move16();
}
}
@@ -773,10 +791,10 @@ void hvq_classifier_ivas_fx(
*Npeaks = 0;
move16();
- L_nf = 3276800;
- move32(); /* 800 in Q12 */
- L_pe = 3276800;
- move32(); /* 800 in Q12 */
+ L_nf = 3276800; /* 800 in Q12 */
+ move32();
+ L_pe = 3276800; /* 800 in Q12 */
+ move32();
num_sharp_bands = 0;
move16();
k = 0;
@@ -798,7 +816,7 @@ void hvq_classifier_ivas_fx(
FOR( j = 0; j < HVQ_BW; j++ )
{
- L_d = L_input_abs[q];
+ L_d = L_input_abs[q]; /* Q12 */
IF( GT_32( L_d, L_nf ) )
{
/*nf = HVQ_NF_WEIGHT1 * nf + (1 - HVQ_NF_WEIGHT1) * d; */
@@ -829,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 );
- L_pe_mean[i] = L_add_sat( L_pe_mean[i], L_pe );
-#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
+ 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();
IF( GT_32( L_d, L_peak ) )
@@ -843,7 +856,7 @@ void hvq_classifier_ivas_fx(
L_peak = L_add( L_d, 0 );
}
- q = add( q, 1 );
+ q += 1;
}
L_nf_mean[i] = L_shr( L_nf_mean[i], 5 ); /* Divide by 5 (HVQ_BW) */
L_pe_mean[i] = L_shr( L_pe_mean[i], 5 ); /* Divide by 5 (HVQ_BW) */
@@ -885,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 );
-#else
- sharp_dist = add( sharp_dist, sub( sharp[i], HVQ_SHARP_THRES_FX ) );
-#endif
+ sharp_dist = add_o( sharp_dist, sub( sharp[i], HVQ_SHARP_THRES_FX ), &Overflow ); /* Q6 */
if ( GT_16( sharp[i], HVQ_SHARP_THRES_FX ) )
{
num_sharp_bands = add( num_sharp_bands, 1 );
@@ -898,12 +907,12 @@ void hvq_classifier_ivas_fx(
/* Estimate noise floor gains */
offset = s_and( nsub, 1 );
- FOR( i = 0; i < s_and( nsub, (Word16) 0xFFFE ); i++ )
+ FOR( i = 0; i < ( nsub & (Word16) 0xFFFE ); i++ )
{
/*(2*i+1)/nsub */
- idx = mult( add( shl( i, 1 ), 1 ), add( inv_nsub, 1 ) ); /*0+15-15 = 0 */
- L_nf_gains[idx] = L_add( L_nf_gains[idx], L_nf_mean[i + offset] );
- L_pe_gains[idx] = L_add( L_pe_gains[idx], L_pe_mean[i + offset] );
+ idx = mult( add( shl( i, 1 ), 1 ), add( inv_nsub, 1 ) ); /*0+15-15 = 0 */
+ L_nf_gains[idx] = L_add( L_nf_gains[idx], L_nf_mean[i + offset] ); /* Q12 */
+ L_pe_gains[idx] = L_add( L_pe_gains[idx], L_pe_mean[i + offset] ); /* Q12 */
move32();
move32();
}
@@ -917,7 +926,7 @@ void hvq_classifier_ivas_fx(
/* Allocate available peaks */
FOR( i = 0; i < nsub; i++ )
{
- avail_peaks[i] = HVQ_PA_PEAKS_SHARP1;
+ avail_peaks[i] = HVQ_PA_PEAKS_SHARP1; /* Q0 */
move16();
idx = mult( add( shl( i, 1 ), 1 ), add( inv_nsub, 1 ) ); /*0+15-15 = 0 */
Mpy_32_16_ss( L_nf_gains[idx], HVQ_PA_FAC_FX, &L_tmp, &lsb ); /* 12+15-15 -> Q12 */
@@ -925,12 +934,12 @@ void hvq_classifier_ivas_fx(
{
IF( LT_16( sharp[i], HVQ_PA_SHARP_THRES3_FX ) )
{
- avail_peaks[i] = HVQ_PA_PEAKS_SHARP3;
+ avail_peaks[i] = HVQ_PA_PEAKS_SHARP3; /* Q0 */
move16();
}
ELSE IF( LT_16( sharp[i], HVQ_PA_SHARP_THRES2_FX ) )
{
- avail_peaks[i] = HVQ_PA_PEAKS_SHARP2;
+ avail_peaks[i] = HVQ_PA_PEAKS_SHARP2; /* Q0 */
move16();
}
}
@@ -940,9 +949,9 @@ void hvq_classifier_ivas_fx(
/* Adjust threshold around previous peaks */
FOR( i = 0; i < *prev_Npeaks; i++ )
{
- j = sub( prev_peaks[i], 2 );
- k = add( prev_peaks[i], 2 );
- p_adj = hvq_thr_adj_fx;
+ j = sub( prev_peaks[i], 2 ); /* Q0 */
+ k = add( prev_peaks[i], 2 ); /* Q0 */
+ p_adj = hvq_thr_adj_fx; /* Q15 */
FOR( q = j; q < k; q++ )
{
@@ -973,16 +982,16 @@ void hvq_classifier_ivas_fx(
}
ELSE
{
- L_input_abs[num_peak_cands] = L_input_abs[i];
+ L_input_abs[num_peak_cands] = L_input_abs[i]; /* Q12 */
move32();
- peak_cand_idx[num_peak_cands] = i;
+ peak_cand_idx[num_peak_cands] = i; /* Q0 */
move16();
num_peak_cands = add( num_peak_cands, 1 );
}
}
- peak_th = (Word16) BASOP_Util_Divide3232_Scale( L_add( W_extract_l( W_mult0_32_32( L_core_brate, HVQ_PEAKS_PER_DELTA_THR ) ), HVQ_PEAKS_PER_DELTA_THR_OFFS ), HVQ_PEAKS_BPS_DELTA, &temp_e );
+ peak_th = extract_l( BASOP_Util_Divide3232_Scale( L_add( W_extract_l( W_mult0_32_32( L_core_brate, HVQ_PEAKS_PER_DELTA_THR ) ), HVQ_PEAKS_PER_DELTA_THR_OFFS ), HVQ_PEAKS_BPS_DELTA, &temp_e ) );
peak_th = shr( peak_th, sub( 15, temp_e ) );
/* Find peaks */
pindx = maximum_32_fx( L_input_abs, num_peak_cands, &L_m );
@@ -994,7 +1003,7 @@ void hvq_classifier_ivas_fx(
idx = mult( peak_cand_idx[pindx], INV_HVQ_BW ); /* 0+15-15=0 */
IF( avail_peaks[idx] > 0 )
{
- peaks[i++] = peak_cand_idx[pindx];
+ peaks[i++] = peak_cand_idx[pindx]; /* Q0 */
avail_peaks[idx]--;
}
@@ -1055,7 +1064,7 @@ void hvq_classifier_ivas_fx(
pindx = maximum_32_fx( L_input_abs, num_peak_cands, &L_m );
}
- *Npeaks = i;
+ *Npeaks = i; /* Q0 */
move16();
IF( GT_16( *Npeaks, HVQ_MIN_PEAKS ) )
{
@@ -1066,28 +1075,28 @@ void hvq_classifier_ivas_fx(
test();
IF( LE_16( sharp_dist, SHARP_DIST_THRES_FX ) && *hvq_hangover < 0 )
{
- *hvq_hangover = add( *hvq_hangover, 1 );
+ *hvq_hangover = add( *hvq_hangover, 1 ); /* Q0 */
}
ELSE
{
- *hqswb_clas = HQ_HVQ;
+ *hqswb_clas = HQ_HVQ; /* Q0 */
move16();
- *hvq_hangover = 2;
+ *hvq_hangover = 2; /* Q0 */
move16();
}
/* update memory */
- *prev_Npeaks = *Npeaks;
+ *prev_Npeaks = *Npeaks; /* Q0 */
move16();
- Copy( peaks, prev_peaks, *Npeaks );
+ Copy( peaks, prev_peaks, *Npeaks ); /* Q0 */
}
ELSE
{
IF( *hvq_hangover > 0 )
{
- *hqswb_clas = HQ_HVQ;
+ *hqswb_clas = HQ_HVQ; /* Q0 */
move16();
- *hvq_hangover = sub( *hvq_hangover, 1 );
+ *hvq_hangover = sub( *hvq_hangover, 1 ); /* Q0 */
move16();
}
ELSE
@@ -1110,6 +1119,7 @@ void hvq_classifier_ivas_fx(
Word16 Npeaks_temp = *Npeaks;
*Npeaks = BASOP_Util_Divide3232_Scale( L_add( W_extract_l( W_mult0_32_32( L_core_brate, HVQ_PEAKS_PER_DELTA ) ), HVQ_PEAKS_PER_DELTA_OFFS ), HVQ_PEAKS_BPS_DELTA, &temp_e );
*Npeaks = s_min( shr( *Npeaks, sub( 15, temp_e ) ), Npeaks_temp );
+ move16();
}
ELSE
{
@@ -1167,6 +1177,7 @@ void hvq_classifier_fx(
Word16 peak_cand_idx[HVQ_THRES_BIN_32k], avail_peaks[HVQ_NSUB_32k];
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
L_input_max = L_deposit_l( 0 );
set32_fx( L_thr, 0, L_FRAME16k );
@@ -1179,19 +1190,19 @@ void hvq_classifier_fx(
{
nsub = HVQ_NSUB_24k;
move16();
- inv_nsub = 4681;
- move16(); /* 1/7 in Q15 */
- inv_gains_nsub = 10923;
- move16(); /* 1/3 in Q15 */
+ inv_nsub = 4681; /* 1/7 in Q15 */
+ move16();
+ inv_gains_nsub = 10923; /* 1/3 in Q15 */
+ move16();
}
ELSE
{
nsub = HVQ_NSUB_32k;
move16();
- inv_nsub = 3277;
- move16(); /* 1/10 in Q15 */
- inv_gains_nsub = 6554;
- move16(); /* 1/5 in Q15 */
+ inv_nsub = 3277; /* 1/10 in Q15 */
+ move16();
+ inv_gains_nsub = 6554; /* 1/5 in Q15 */
+ move16();
}
N = shl( nsub, 5 ); /* Mult by 32 (HVQ_BW) */
@@ -1202,10 +1213,10 @@ void hvq_classifier_fx(
{
FOR( i = 0; i < N; i++ )
{
- L_input_abs[i] = L_abs( input[i] );
- if ( L_input_abs[i] > L_input_max )
+ L_input_abs[i] = L_abs( input[i] ); /* Q12 */
+ IF( GT_32( L_input_abs[i], L_input_max ) )
{
- L_input_max = L_input_abs[i];
+ L_input_max = L_input_abs[i]; /* Q12 */
move16();
}
}
@@ -1214,10 +1225,10 @@ void hvq_classifier_fx(
*Npeaks = 0;
move16();
- L_nf = 3276800;
- move32(); /* 800 in Q12 */
- L_pe = 3276800;
- move32(); /* 800 in Q12 */
+ L_nf = 3276800; /* 800 in Q12 */
+ move32();
+ L_pe = 3276800; /* 800 in Q12 */
+ move32();
num_sharp_bands = 0;
move16();
k = 0;
@@ -1233,9 +1244,13 @@ void hvq_classifier_fx(
L_peak = 0;
L_nf_mean[i] = 0;
L_pe_mean[i] = 0;
+ move32();
+ move32();
+ move32();
FOR( j = 0; j < HVQ_BW; j++ )
{
- L_d = L_input_abs[q];
+ L_d = L_input_abs[q]; /* Q12 */
+ move32();
IF( GT_32( L_d, L_nf ) )
{
/*nf = HVQ_NF_WEIGHT1 * nf + (1 - HVQ_NF_WEIGHT1) * d; */
@@ -1266,22 +1281,21 @@ 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 );
- L_pe_mean[i] = L_add_sat( L_pe_mean[i], L_pe );
-#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
+ 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();
IF( GT_32( L_d, L_peak ) )
{
L_peak = L_add( L_d, 0 );
}
- q = add( q, 1 );
+ q += 1;
}
L_nf_mean[i] = L_shr( L_nf_mean[i], 5 ); /* Divide by 5 (HVQ_BW) */
L_pe_mean[i] = L_shr( L_pe_mean[i], 5 ); /* Divide by 5 (HVQ_BW) */
+ move32();
+ move32();
/*thr_tmp = (float)pow( pe_mean[i]/nf_mean[i], HVQ_THR_POW ) * nf_mean[i]; */
exp1 = norm_l( L_nf_mean[i] );
@@ -1317,14 +1331,11 @@ void hvq_classifier_fx(
Mpy_32_16_ss( L_peak, inv_nf_mean, &L_tmp, &lsb ); /* 12+33-s-15=30-s */
shift = sub( exp1, 8 );
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 );
-#else
- sharp_dist = add( sharp_dist, sub( sharp[i], HVQ_SHARP_THRES_FX ) );
-#endif
- if ( GT_16( sharp[i], HVQ_SHARP_THRES_FX ) )
+ IF( GT_16( sharp[i], HVQ_SHARP_THRES_FX ) )
{
num_sharp_bands = add( num_sharp_bands, 1 );
}
@@ -1332,12 +1343,14 @@ void hvq_classifier_fx(
/* Estimate noise floor gains */
offset = s_and( nsub, 1 );
- FOR( i = 0; i < s_and( nsub, (Word16) 0xFFFE ); i++ )
+ FOR( i = 0; i < ( nsub & (Word16) 0xFFFE ); i++ )
{
/*(2*i+1)/nsub */
idx = mult( add( shl( i, 1 ), 1 ), add( inv_nsub, 1 ) ); /*0+15-15 = 0 */
L_nf_gains[idx] = L_add( L_nf_gains[idx], L_nf_mean[i + offset] );
L_pe_gains[idx] = L_add( L_pe_gains[idx], L_pe_mean[i + offset] );
+ move32();
+ move32();
}
FOR( i = 0; i < HVQ_NF_GROUPS; i++ )
@@ -1372,9 +1385,10 @@ void hvq_classifier_fx(
/* Adjust threshold around previous peaks */
FOR( i = 0; i < *prev_Npeaks; i++ )
{
- j = sub( prev_peaks[i], 2 );
- k = add( prev_peaks[i], 2 );
- p_adj = hvq_thr_adj_fx;
+ j = sub( prev_peaks[i], 2 ); /* Q0 */
+ k = add( prev_peaks[i], 2 ); /* Q0 */
+ p_adj = hvq_thr_adj_fx; /* Q15 */
+ move16();
FOR( q = j; q < k; q++ )
{
@@ -1391,17 +1405,22 @@ void hvq_classifier_fx(
L_input_abs[1] = L_deposit_l( 0 );
L_input_abs[N - 2] = L_deposit_l( 0 );
L_input_abs[N - 1] = L_deposit_l( 0 );
+ move32();
+ move32();
+ move32();
+ move32();
FOR( i = 0; i < N - 2; i++ )
{
IF( LT_32( L_input_abs[i], L_thr[i] ) )
{
L_input_abs[i] = L_deposit_l( 0 );
+ move32();
}
ELSE
{
- L_input_abs[num_peak_cands] = L_input_abs[i];
+ L_input_abs[num_peak_cands] = L_input_abs[i]; /* Q12 */
move32();
- peak_cand_idx[num_peak_cands] = i;
+ peak_cand_idx[num_peak_cands] = i; /* Q0 */
move16();
num_peak_cands = add( num_peak_cands, 1 );
}
@@ -1430,7 +1449,8 @@ void hvq_classifier_fx(
idx = mult( peak_cand_idx[pindx], INV_HVQ_BW ); /* 0+15-15=0 */
IF( avail_peaks[idx] > 0 )
{
- peaks[i++] = peak_cand_idx[pindx];
+ peaks[i++] = peak_cand_idx[pindx]; /* Q0 */
+ move16();
avail_peaks[idx]--;
}
@@ -1460,7 +1480,7 @@ void hvq_classifier_fx(
}
tmp = sub( N, 1 );
- if ( GT_16( high, tmp ) )
+ IF( GT_16( high, tmp ) )
{
high = tmp;
move16();
@@ -1488,7 +1508,7 @@ void hvq_classifier_fx(
}
}
- pindx = maximum_32_fx( L_input_abs, num_peak_cands, &L_m );
+ pindx = maximum_32_fx( L_input_abs, num_peak_cands, &L_m ); /* Q0 */
}
*Npeaks = i;
@@ -1506,24 +1526,24 @@ void hvq_classifier_fx(
}
ELSE
{
- *hqswb_clas = HQ_HVQ;
+ *hqswb_clas = HQ_HVQ; /* Q0 */
move16();
- *hvq_hangover = 2;
+ *hvq_hangover = 2; /* Q0 */
move16();
}
/* update memory */
- *prev_Npeaks = *Npeaks;
+ *prev_Npeaks = *Npeaks; /* Q0 */
move16();
- Copy( peaks, prev_peaks, *Npeaks );
+ Copy( peaks, prev_peaks, *Npeaks ); /* Q0 */
}
ELSE
{
IF( *hvq_hangover > 0 )
{
- *hqswb_clas = HQ_HVQ;
+ *hqswb_clas = HQ_HVQ; /* Q0 */
move16();
- *hvq_hangover = sub( *hvq_hangover, 1 );
+ *hvq_hangover = sub( *hvq_hangover, 1 ); /* Q0 */
move16();
}
ELSE
@@ -1543,12 +1563,12 @@ void hvq_classifier_fx(
#ifndef ADD_IVAS_HQ_CODE
IF( EQ_32( L_core_brate, HQ_24k40 ) )
{
- *Npeaks = s_min( HVQ_MAX_PEAKS_24k, *Npeaks );
+ *Npeaks = s_min( HVQ_MAX_PEAKS_24k, *Npeaks ); /* Q0 */
move16();
}
ELSE
{
- *Npeaks = s_min( HVQ_MAX_PEAKS_32k, *Npeaks );
+ *Npeaks = s_min( HVQ_MAX_PEAKS_32k, *Npeaks ); /* Q0 */
move16();
}
#else
diff --git a/lib_enc/hq_core_enc.c b/lib_enc/hq_core_enc.c
index 91701fd7f73a18ba66e3b3a3e4cd3205c7151c67..dc29b801b61b26856aded3b3da62be97f6cf0cdb 100644
--- a/lib_enc/hq_core_enc.c
+++ b/lib_enc/hq_core_enc.c
@@ -54,10 +54,10 @@
void hq_core_enc_ivas_fx(
Encoder_State *st, /* i/o: encoder state structure */
const Word16 *audio_fx, /* i : input audio signal Q0 */
- const Word16 input_frame_orig, /* i : frame length */
- const Word16 hq_core_type, /* i : HQ core type */
- const Word16 Voicing_flag, /* i : Voicing flag for FER method selection */
- const Word16 vad_hover_flag /* i : VAD hangover flag */
+ const Word16 input_frame_orig, /* i : frame length Q0*/
+ const Word16 hq_core_type, /* i : HQ core type Q0*/
+ const Word16 Voicing_flag, /* i : Voicing flag for FER method selection Q0*/
+ const Word16 vad_hover_flag /* i : VAD hangover flag Q0*/
)
{
Word16 i, is_transient, num_bits, extra_unused;
@@ -68,7 +68,7 @@ void hq_core_enc_ivas_fx(
Word16 two_frames_buffer[2 * L_FRAME48k];
Word16 tmp;
Word16 Aq_old_fx[M + 1];
- Word16 output_fx[L_FRAME16k];
+ Word16 output_fx[L_FRAME48k];
Word16 Q_audio;
Word16 out_q = 0, old_q = 0;
move16();
@@ -87,20 +87,21 @@ void hq_core_enc_ivas_fx(
set32_fx( wtda_audio_fx32, 0, 2 * L_FRAME48k );
st->Nb_ACELP_frames = 0;
move16();
- set_zero_fx( t_audio_fx, L_FRAME48k );
+ set_zero_fx( t_audio_fx, L_FRAME48k_EXT );
/* set input_frame length */
- input_frame = input_frame_orig;
+ input_frame = input_frame_orig; /* Q0 */
/* Sanity check, it should never happen at the encoder side (no BFI) */
IF( st->hTcxCfg->tcx_curr_overlap_mode == FULL_OVERLAP )
{
st->hTcxCfg->tcx_last_overlap_mode = ALDO_WINDOW;
+ move16();
}
ELSE
{
st->hTcxCfg->tcx_last_overlap_mode = st->hTcxCfg->tcx_curr_overlap_mode;
+ move16();
}
- move16();
st->hTcxCfg->tcx_curr_overlap_mode = ALDO_WINDOW;
move16();
@@ -110,8 +111,8 @@ void hq_core_enc_ivas_fx(
* Write signaling information
*--------------------------------------------------------------------------*/
- num_bits = BASOP_Util_Divide3232_Scale( st->total_brate, FRAMES_PER_SEC, &exp );
- num_bits = shr( num_bits, sub( 15, exp ) );
+ num_bits = BASOP_Util_Divide3232_Scale( st->total_brate, FRAMES_PER_SEC, &exp ); /* Q15-exp */
+ num_bits = shr( num_bits, sub( 15, exp ) ); /* Q0 */
extra_unused = 0;
move16();
@@ -119,7 +120,7 @@ void hq_core_enc_ivas_fx(
* Detect signal transition
*--------------------------------------------------------------------------*/
- is_transient = detect_transient_fx( audio_fx, input_frame, 0, st );
+ is_transient = detect_transient_fx( audio_fx, input_frame, 0, st ); /* Q0 */
move16();
test();
@@ -144,10 +145,13 @@ 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 ) );
-
- inner_frame = inner_frame_tbl[st->bwidth];
- L_spec = l_spec_ext_tbl[st->bwidth];
+#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;
move16();
move16();
@@ -161,14 +165,14 @@ void hq_core_enc_ivas_fx(
*--------------------------------------------------------------------------*/
Q_audio = 0;
move16();
- Scale_sig( st->old_input_signal_fx, input_frame, negate( st->q_old_inp ) );
- Scale_sig( st->input_fx, add( input_frame, NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ), negate( st->q_inp ) );
+ Scale_sig( st->old_input_signal_fx, input_frame, negate( st->q_old_inp ) ); /* Q0 */
+ Scale_sig( st->input_fx, add( input_frame, NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ), negate( st->q_inp ) ); /* Q0 */
st->q_old_inp = 0;
move16();
st->q_inp = 0;
move16();
- Copy( st->old_input_signal_fx, two_frames_buffer, input_frame );
- Copy( audio_fx, two_frames_buffer + input_frame, input_frame );
+ Copy( st->old_input_signal_fx, two_frames_buffer, input_frame ); /* Q0 */
+ Copy( audio_fx, two_frames_buffer + input_frame, input_frame ); /* Q0 */
wtda_fx( two_frames_buffer + input_frame, &Q_audio, wtda_audio_fx32, NULL, 0,
st->hTcxCfg->tcx_last_overlap_mode, st->hTcxCfg->tcx_curr_overlap_mode, input_frame );
@@ -191,7 +195,7 @@ void hq_core_enc_ivas_fx(
Word16 tmp_q = Q_audio;
move16();
direct_transform_fx( wtda_audio_fx32, t_audio_fx, is_transient, input_frame, &Q_audio, st->element_mode );
- scale_sig32( wtda_audio_fx32, L_FRAME48k_EXT, sub( Q_audio, tmp_q ) );
+ scale_sig32( wtda_audio_fx32, L_FRAME48k_EXT, sub( Q_audio, tmp_q ) ); /* Q_audio */
/* scale coefficients to their nominal level (8kHz) */
IF( NE_16( input_frame, NORM_MDCT_FACTOR ) )
@@ -199,17 +203,18 @@ void hq_core_enc_ivas_fx(
UWord16 lsb;
tmp = mult_r( input_frame, 410 / 2 ); /* 1/8000 in Q15 */
Word16 ener_match_fx = hq_nominal_scaling[tmp];
+ move16();
FOR( i = 0; i < input_frame; i++ )
{
/*t_audio_q[i] *= ener_match; */
- Mpy_32_16_ss( t_audio_fx[i], ener_match_fx, &t_audio_fx[i], &lsb );
- move16(); /* Q12 */
+ Mpy_32_16_ss( t_audio_fx[i], ener_match_fx, &t_audio_fx[i], &lsb ); /* Q12 */
+ move16();
}
}
/* limit encoded band-width according to the command-line OR BWD limitation */
- inner_frame = inner_frame_tbl[st->bwidth];
- L_spec = l_spec_tbl[st->bwidth];
+ inner_frame = inner_frame_tbl[st->bwidth]; /* Q0 */
+ L_spec = l_spec_tbl[st->bwidth]; /* Q0 */
move16();
move16();
@@ -222,7 +227,7 @@ void hq_core_enc_ivas_fx(
FOR( i = 1; i < NUM_TIME_SWITCHING_BLOCKS; i++ )
{
tmp = shr( inner_frame, 2 );
- Copy32( t_audio_fx + i_mult2( i, shr( input_frame, 2 ) ), t_audio_fx + i_mult2( i, tmp ), tmp );
+ Copy32( t_audio_fx + i_mult2( i, shr( input_frame, 2 ) ), t_audio_fx + i_mult2( i, tmp ), tmp ); /* Q_audio */
}
}
@@ -232,7 +237,7 @@ void hq_core_enc_ivas_fx(
/* subtract signaling bits */
- num_bits = sub( num_bits, hBstr->nb_bits_tot );
+ num_bits = sub( num_bits, hBstr->nb_bits_tot ); /* Q0 */
/*--------------------------------------------------------------------------
* High-band gain control in case of BWS
@@ -241,9 +246,9 @@ void hq_core_enc_ivas_fx(
IF( st->bwidth_sw_cnt > 0 )
{
Word32 L_tmp;
- tmp = BASOP_Util_Divide1616_Scale( 3, BWS_TRAN_PERIOD, &exp );
+ tmp = BASOP_Util_Divide1616_Scale( 3, BWS_TRAN_PERIOD, &exp ); /* Q15-exp */
shr( tmp, exp );
- L_tmp = L_deposit_h( tmp );
+ L_tmp = L_deposit_h( tmp ); /* Q31-exp */
IF( is_transient )
{
FOR( i = 0; i < NUM_TIME_SWITCHING_BLOCKS; i++ )
@@ -282,7 +287,7 @@ void hq_core_enc_ivas_fx(
* Transform-domain encoding
*--------------------------------------------------------------------------*/
- scale_sig32( t_audio_fx, L_FRAME48k, sub( Q12, Q_audio ) );
+ scale_sig32( t_audio_fx, L_FRAME48k_EXT, sub( Q12, Q_audio ) );
scale_sig32( wtda_audio_fx32, 2 * L_FRAME48k, sub( Q12, Q_audio ) );
Q_audio = 12;
move16();
@@ -315,7 +320,7 @@ void hq_core_enc_ivas_fx(
test();
IF( st->element_mode > EVS_MONO && ( st->last_core == ACELP_CORE || EQ_16( st->last_core, AMR_WB_CORE ) ) )
{
- overlap = st->hTcxCfg->tcx_mdct_window_length;
+ overlap = st->hTcxCfg->tcx_mdct_window_length; /* Q0 */
move16();
nz = NS2SA( st->sr_core, N_ZERO_MDCT_NS );
@@ -349,7 +354,7 @@ void hq_core_enc_ivas_fx(
/*Compute windowed synthesis in case of switching to ALDO windows in next frame*/
- Copy( wtda_audio_fx16 + sub( L_frame, nz ), st->hTcxEnc->old_out_fx, nz + overlap );
+ Copy( wtda_audio_fx16 + sub( L_frame, nz ), st->hTcxEnc->old_out_fx, nz + overlap ); /* Q0 */
set16_fx( st->hTcxEnc->old_out_fx + add( nz, overlap ), 0, nz );
tcx_windowing_synthesis_past_frame( st->hTcxEnc->old_out_fx + nz, st->hTcxCfg->tcx_aldo_window_1_trunc, st->hTcxCfg->tcx_mdct_window_half, st->hTcxCfg->tcx_mdct_window_minimum, overlap, st->hTcxCfg->tcx_mdct_window_half_length, st->hTcxCfg->tcx_mdct_window_min_length, FULL_OVERLAP );
@@ -359,9 +364,11 @@ void hq_core_enc_ivas_fx(
// This implementation is diffrent in float code need to revisit to check its correctness.
st->hTcxEnc->old_out_fx[nz + overlap + i] = mult( wtda_audio_fx16[L_frame - 1 - i], st->hTcxCfg->tcx_aldo_window_1_trunc[i].v.re ); // Q0 + Q15 - Q15 -> Q0;
st->hTcxEnc->old_out_fx[nz / 2 + ( nz + overlap + i )] = mult( wtda_audio_fx16[nz / 2 + ( L_frame - 1 - i )], st->hTcxCfg->tcx_aldo_window_1_trunc[nz / 2 - 1 - i].v.im ); // Q0 + Q15 - Q15 -> Q0;
+ move16();
+ move16();
}
- Copy( wtda_audio_fx16 + sub( shr( overlap, 1 ), tcx_offset ), output_fx, st->L_frame );
+ Copy( wtda_audio_fx16 + sub( shr( overlap, 1 ), tcx_offset ), output_fx, st->L_frame ); /* Q0 */
}
ELSE
{
@@ -371,12 +378,12 @@ void hq_core_enc_ivas_fx(
move32();
FOR( i = 0; i < input_frame; i++ )
{
- t_audio_fx[i] = Mpy_32_32( t_audio_fx[i], ener_match_fx );
- move32(); /* Q12 - 1 -> Q11 */
+ t_audio_fx[i] = Mpy_32_32( t_audio_fx[i], ener_match_fx ); /* Q12 - 1 -> Q11 */
+ move32();
}
Q_audio = sub( Q_audio, 1 );
- scale_sig32( wtda_audio_fx32, 2 * L_FRAME48k, sub( Q_audio, tmp_q ) );
+ scale_sig32( wtda_audio_fx32, 2 * L_FRAME48k, sub( Q_audio, tmp_q ) ); /* Q_audio */
Inverse_Transform( t_audio_fx, &Q_audio, wtda_audio_fx32, is_transient, L_FRAME16k, inner_frame, st->element_mode );
@@ -384,8 +391,8 @@ void hq_core_enc_ivas_fx(
move16();
window_ola_fx( wtda_audio_fx32, output_fx, &out_q, st->hTcxEnc->old_out_fx, &old_q, L_FRAME16k, st->hTcxCfg->tcx_last_overlap_mode, st->hTcxCfg->tcx_curr_overlap_mode, 0, 0, NULL );
- Scale_sig( output_fx, L_FRAME16k, negate( out_q ) );
- Scale_sig( st->hTcxEnc->old_out_fx, L_FRAME32k, negate( old_q ) );
+ Scale_sig( output_fx, L_FRAME16k, negate( out_q ) ); /* Q0 */
+ Scale_sig( st->hTcxEnc->old_out_fx, L_FRAME32k, negate( old_q ) ); /* Q0 */
st->hTcxEnc->Q_old_out = 0;
move16();
}
@@ -394,7 +401,7 @@ void hq_core_enc_ivas_fx(
{
/* Store LB synthesis in case of switch to ACELP */
Copy( output_fx, st->hLPDmem->old_exc, L_FRAME16k );
- st->hLPDmem->q_lpd_old_exc = 15;
+ st->hLPDmem->q_lpd_old_exc = 0;
move16();
}
pop_wmops();
diff --git a/lib_enc/hq_core_enc_fx.c b/lib_enc/hq_core_enc_fx.c
index faef4c1e0e99888c1480cef1ffcdd8d4ade86135..6dc7bb5b95f981002a28f310591ca9e2393384cb 100644
--- a/lib_enc/hq_core_enc_fx.c
+++ b/lib_enc/hq_core_enc_fx.c
@@ -19,10 +19,10 @@
void hq_core_enc_fx(
Encoder_State *st_fx,
const Word16 *audio, /* i : input audio signal Q0 */
- const Word16 input_frame_orig, /* i : frame length */
- const Word16 hq_core_type, /* i : HQ core type */
- const Word16 Voicing_flag, /* i : Voicing flag for FER method selection */
- const Word16 vad_hover_flag /* i : VAD hangover flag */
+ const Word16 input_frame_orig, /* i : frame length Q0*/
+ const Word16 hq_core_type, /* i : HQ core type Q0*/
+ const Word16 Voicing_flag, /* i : Voicing flag for FER method selection Q0*/
+ const Word16 vad_hover_flag /* i : VAD hangover flag Q0*/
)
{
Word16 i, is_transient, num_bits, extra_unused;
@@ -31,6 +31,7 @@ void hq_core_enc_fx(
Word16 Q_audio = 0;
Word16 inner_frame, input_frame;
Word16 ener_match; /* Q13/Q15 */
+ move16();
Word16 tmp;
Word32 L_tmp;
@@ -52,7 +53,7 @@ void hq_core_enc_fx(
move16();
/* set input_frame length */
- input_frame = input_frame_orig;
+ input_frame = input_frame_orig; /* Q0 */
move16();
/* Sanity check, it should never happen at the encoder side (no BFI) */
IF( EQ_16( st_fx->hTcxCfg->tcx_curr_overlap_mode, FULL_OVERLAP ) )
@@ -85,13 +86,13 @@ void hq_core_enc_fx(
* Detect signal transition
*--------------------------------------------------------------------------*/
- is_transient = detect_transient_fx( audio, input_frame, 0, st_fx );
+ is_transient = detect_transient_fx( audio, input_frame, 0, st_fx ); /* Q0 */
#ifdef ADD_IVAS_HQ_CODE
test();
test();
test();
- IF( GT_16( st_fx->element_mode, EVS_MONO ) && ( EQ_16( st_fx->last_core, ACELP_CORE ) || EQ_16( st_fx->last_core, AMR_WB_CORE ) ) )
+ IF( ( st_fx->element_mode > EVS_MONO ) && ( ( st_fx->last_core == ACELP_CORE ) || EQ_16( st_fx->last_core, AMR_WB_CORE ) ) )
{
/*--------------------------------------------------------------------------
* IVAS switching frame
@@ -124,8 +125,8 @@ void hq_core_enc_fx(
* DCT transform
*--------------------------------------------------------------------------*/
- Copy( st_fx->old_input_signal_fx, two_frames_buffer, input_frame );
- Copy( audio, two_frames_buffer + input_frame, input_frame );
+ Copy( st_fx->old_input_signal_fx, two_frames_buffer, input_frame ); /* st_fx->q_old_inp */
+ Copy( audio, two_frames_buffer + input_frame, input_frame ); /* Q0 */
wtda_fx( two_frames_buffer + input_frame, &Q_audio, wtda_audio, NULL, 0,
st_fx->hTcxCfg->tcx_last_overlap_mode, st_fx->hTcxCfg->tcx_curr_overlap_mode, input_frame );
@@ -146,7 +147,7 @@ void hq_core_enc_fx(
}
#ifndef ADD_IVAS_HQ_CODE
/* subtract signalling bits */
- num_bits = sub( num_bits, hBstr->nb_bits_tot );
+ num_bits = sub( num_bits, hBstr->nb_bits_tot ); /* Q0 */
#endif
direct_transform_fx( wtda_audio, t_audio, is_transient, input_frame, &Q_audio, st_fx->element_mode );
@@ -161,17 +162,18 @@ void hq_core_enc_fx(
{
tmp = mult_r( input_frame, 410 / 2 ); /* 1/8000 in Q15 */
ener_match = hq_nominal_scaling[tmp];
+ move16();
FOR( i = 0; i < input_frame; i++ )
{
/*t_audio_q[i] *= ener_match; */
- Mpy_32_16_ss( t_audio[i], ener_match, &t_audio[i], &lsb );
- move16(); /* Q12 */
+ Mpy_32_16_ss( t_audio[i], ener_match, &t_audio[i], &lsb ); /* Q12 */
+ move16();
}
}
}
/* limit encoded band-width according to the command-line OR BWD limitation */
- inner_frame = inner_frame_tbl[st_fx->bwidth];
+ inner_frame = inner_frame_tbl[st_fx->bwidth]; /* Q0 */
move16();
#ifdef ADD_IVAS_HQ_CODE_L_SPEC
L_spec = l_spec_tbl[st_fx->bwidth];
@@ -185,7 +187,7 @@ void hq_core_enc_fx(
{
tmp = i_mult2( i, shr( input_frame, 2 ) );
tmp = shr( inner_frame, 2 );
- Copy32( t_audio + i_mult2( i, shr( input_frame, 2 ) ), t_audio + i_mult2( i, tmp ), tmp );
+ Copy32( t_audio + i_mult2( i, shr( input_frame, 2 ) ), t_audio + i_mult2( i, tmp ), tmp ); /* Q12 */
}
}
@@ -221,6 +223,8 @@ void hq_core_enc_fx(
* Classify whether to put extra bits for FER mitigation
*--------------------------------------------------------------------------*/
+ test();
+ test();
test();
IF( ( EQ_16( st_fx->last_core, TCX_20_CORE ) || EQ_16( st_fx->last_core, TCX_10_CORE ) || EQ_16( st_fx->last_core, HQ_CORE ) ) && GT_32( st_fx->core_brate, MINIMUM_RATE_TO_ENCODE_VOICING_FLAG ) )
{
@@ -246,6 +250,7 @@ void hq_core_enc_fx(
FOR( i = 0; i < inner_frame; i++ )
{
t_audio[i] = L_shr( t_audio[i], sub( Q_audio, 12 ) ); /* Q12 */
+ move32();
}
hq_lr_enc_fx( st_fx, t_audio, inner_frame, &num_bits, is_transient );
Q_audio = 12;
@@ -257,6 +262,7 @@ void hq_core_enc_fx(
FOR( i = 0; i < inner_frame; i++ )
{
t_audio[i] = L_shr( t_audio[i], sub( Q_audio, 12 ) ); /* Q12 */
+ move32();
}
#ifdef ADD_IVAS_HQ_CODE_L_SPEC
@@ -360,8 +366,8 @@ void HQ_core_enc_init_fx(
move16();
hHQ_core->prev_stab_hfe2 = 0;
move16();
- hHQ_core->prev_ni_ratio_fx = 16384;
- move16(); /* 0.5 */
+ hHQ_core->prev_ni_ratio_fx = 16384; /* Q15 */
+ move16(); /* 0.5 */
set16_fx( hHQ_core->prev_En_sb_fx, 0, NB_SWB_SUBBANDS );
set16_fx( hHQ_core->last_bitalloc_max_band, 0, 2 );
set32_fx( hHQ_core->last_ni_gain_fx, 0, BANDS_MAX );
@@ -370,11 +376,11 @@ void HQ_core_enc_init_fx(
move16();
#ifdef MSAN_FIX
- hHQ_core->crest_lp_fx = HQ_CREST_THRESHOLD_FX;
+ hHQ_core->crest_lp_fx = HQ_CREST_THRESHOLD_FX; /* Q28 */
move32();
hHQ_core->crest_lp_q = Q28;
move16();
- hHQ_core->crest_mod_lp_fx = HQ_CREST_MOD_THRESHOLD_FX;
+ hHQ_core->crest_mod_lp_fx = HQ_CREST_MOD_THRESHOLD_FX; /* Q29 */
move32();
hHQ_core->crest_mod_lp_q = Q29;
move16();
diff --git a/lib_enc/hq_env_enc_fx.c b/lib_enc/hq_env_enc_fx.c
index e04489b18341d3125b69ab673755a46dc39983eb..b0875968e2c2ede803105d6d7fae94bea062f55e 100644
--- a/lib_enc/hq_env_enc_fx.c
+++ b/lib_enc/hq_env_enc_fx.c
@@ -19,7 +19,7 @@
*--------------------------------------------------------------------------------------*/
Word16 encode_envelope_indices_fx( /* o : Number of bits if flag_pack=0,0 if flag_pack=1 Q0 */
- BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream */
+ BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream Q0 */
const Word16 num_sfm, /* i : Number of subbands Q0 */
const Word16 numnrmibits, /* i : Bitrate of fall-back coding mode Q0 */
Word16 *difidx, /* i/o: Diff indices/encoded diff indices Q0 */
@@ -68,12 +68,12 @@ Word16 encode_envelope_indices_fx( /* o : Number of b
{
IF( GT_16( difidx[i], index_max ) )
{
- index_max = difidx[i];
+ index_max = difidx[i]; /* Q0 */
move16();
}
IF( LT_16( difidx[i], index_min ) )
{
- index_min = difidx[i];
+ index_min = difidx[i]; /* Q0 */
move16();
}
}
@@ -82,7 +82,7 @@ Word16 encode_envelope_indices_fx( /* o : Number of b
{
FOR( i = 1; i < num_sfm; i++ )
{
- j = difidx[i];
+ j = difidx[i]; /* Q0 */
move16();
bits = add( bits, huffsizn_tran[j] );
}
@@ -95,24 +95,24 @@ Word16 encode_envelope_indices_fx( /* o : Number of b
/* LC mode 0 = Context based coding */
FOR( i = 1; i < num_sfm; i++ )
{
- j = difidx[i];
+ j = difidx[i]; /* Q0 */
move16();
IF( GT_16( prevj, HTH_NORM ) )
{
/* above */
- hcode_l = add( hcode_l, huffsizn_n[31 - j] );
+ hcode_l = add( hcode_l, huffsizn_n[31 - j] ); /* Q0 */
}
ELSE
{
IF( LT_16( prevj, LTH_NORM ) )
{
/* less */
- hcode_l = add( hcode_l, huffsizn_n[j] );
+ hcode_l = add( hcode_l, huffsizn_n[j] ); /* Q0 */
}
ELSE
{
/* equal */
- hcode_l = add( hcode_l, huffsizn_e[j] );
+ hcode_l = add( hcode_l, huffsizn_e[j] ); /* Q0 */
}
}
prevj = j;
@@ -136,24 +136,24 @@ Word16 encode_envelope_indices_fx( /* o : Number of b
prevj = add( difidx[0], OFFSET_NORM );
FOR( i = 1; i < num_sfm; i++ )
{
- j = difidx[i];
+ j = difidx[i]; /* Q0 */
move16();
IF( GT_16( prevj, HTH_NORM ) )
{
/* above */
- hcode_l = add( hcode_l, huffsizn_n[sub( 31, j )] );
+ hcode_l = add( hcode_l, huffsizn_n[( 31 - j )] ); /* Q0 */
}
ELSE
{
IF( LT_16( prevj, LTH_NORM ) )
{
/* less */
- hcode_l = add( hcode_l, huffsizn_n[j] );
+ hcode_l = add( hcode_l, huffsizn_n[j] ); /* Q0 */
}
ELSE
{
/* equal */
- hcode_l = add( hcode_l, huffsizn_e[j] );
+ hcode_l = add( hcode_l, huffsizn_e[j] ); /* Q0 */
}
}
prevj = j;
@@ -171,16 +171,16 @@ Word16 encode_envelope_indices_fx( /* o : Number of b
move16();
FOR( i = 1; i < num_sfm; i++ )
{
- j = difidx[i];
+ j = difidx[i]; /* Q0 */
move16();
- bits = add( bits, huffsizn[j] );
+ bits = add( bits, huffsizn[j] ); /* Q0 */
}
/*------------------------------------------------------------------------------*
* comparing bit expenses of coding mode 2 with that of the optimal coding mode
*------------------------------------------------------------------------------*/
- if ( GT_16( hcode_l, bits ) )
+ IF( GT_16( hcode_l, bits ) )
{
*LCmode = 2;
move16();
@@ -197,7 +197,7 @@ Word16 encode_envelope_indices_fx( /* o : Number of b
move16();
FOR( i = 1; i < num_sfm; i++ )
{
- difidx_org[i] = difidx[i];
+ difidx_org[i] = difidx[i]; /* Q0 */
move16();
}
@@ -207,7 +207,7 @@ Word16 encode_envelope_indices_fx( /* o : Number of b
{
IF( GT_16( difidx_org[i - 1], 17 ) )
{
- difidx[i] = add( difidx_org[i], s_min( sub( difidx_org[i - 1], 17 ), 3 ) );
+ difidx[i] = add( difidx_org[i], s_min( sub( difidx_org[i - 1], 17 ), 3 ) ); /* Q0 */
move16();
IF( GT_16( difidx[i], 31 ) )
{
@@ -219,7 +219,7 @@ Word16 encode_envelope_indices_fx( /* o : Number of b
IF( LT_16( difidx_org[i - 1], 13 ) )
{
- difidx[i] = add( difidx_org[i], s_max( sub( difidx_org[i - 1], 13 ), -3 ) );
+ difidx[i] = add( difidx_org[i], s_max( sub( difidx_org[i - 1], 13 ), -3 ) ); /* Q0 */
move16();
IF( difidx[i] < 0 )
{
@@ -246,7 +246,7 @@ Word16 encode_envelope_indices_fx( /* o : Number of b
{
FOR( i = 1; i < num_sfm; i++ )
{
- j = difidx[i];
+ j = difidx[i]; /* Q0 */
move16();
bits = add( bits, resize_huffsizn[j] );
}
@@ -255,7 +255,7 @@ Word16 encode_envelope_indices_fx( /* o : Number of b
* comparing bit expenses of coding mode 1 with that of coding mode 0
*------------------------------------------------------------------*/
- if ( GT_16( hcode_l, bits ) )
+ IF( GT_16( hcode_l, bits ) )
{
*LCmode = 1;
move16();
@@ -271,7 +271,7 @@ Word16 encode_envelope_indices_fx( /* o : Number of b
* comparing bit expenses of coding mode 3 with that of the optimal coding mode
*------------------------------------------------------------------------------*/
- if ( GE_16( hcode_l, numnrmibits ) )
+ IF( GE_16( hcode_l, numnrmibits ) )
{
*LCmode = 3;
move16();
@@ -285,7 +285,7 @@ Word16 encode_envelope_indices_fx( /* o : Number of b
{
FOR( i = 2; i < num_sfm; i++ )
{
- difidx[i] = difidx_org[i];
+ difidx[i] = difidx_org[i]; /* Q0 */
move16();
}
}
@@ -315,11 +315,11 @@ Word16 encode_envelope_indices_fx( /* o : Number of b
/* LC mode 0 Transient Huffman Coding */
FOR( i = 1; i < num_sfm; i++ )
{
- j = difidx[i];
+ j = difidx[i]; /* Q0 */
move16();
- m = huffnorm_tran[j];
+ m = huffnorm_tran[j]; /* Q0 */
move16();
- r = huffsizn_tran[j];
+ r = huffsizn_tran[j]; /* Q0 */
move16();
v = 0;
move16();
@@ -327,9 +327,9 @@ Word16 encode_envelope_indices_fx( /* o : Number of b
/* Bit reverse */
FOR( k = 0; k < r; k++ )
{
- v = lshl( v, 1 );
- v = s_or( v, s_and( m, 1 ) );
- m = lshr( m, 1 );
+ v = lshl( v, 1 ); /* Q0 */
+ v = s_or( v, s_and( m, 1 ) ); /* Q0 */
+ m = lshr( m, 1 ); /* Q0 */
}
push_indice_fx( hBstr, IND_HQ2_DIFF_ENERGY, v, r );
@@ -341,15 +341,15 @@ Word16 encode_envelope_indices_fx( /* o : Number of b
prevj = add( difidx[0], OFFSET_NORM );
FOR( i = 1; i < num_sfm; i++ )
{
- j = difidx[i];
+ j = difidx[i]; /* Q0 */
move16();
IF( GT_16( prevj, HTH_NORM ) )
{
/* above */
- r = huffsizn_n[sub( 31, j )];
+ r = huffsizn_n[( 31 - j )]; /* Q0 */
move16();
- m = huffnorm_n[sub( 31, j )];
+ m = huffnorm_n[( 31 - j )]; /* Q0 */
move16();
}
ELSE
@@ -357,17 +357,17 @@ Word16 encode_envelope_indices_fx( /* o : Number of b
IF( LT_16( prevj, LTH_NORM ) )
{
/* less */
- r = huffsizn_n[j];
+ r = huffsizn_n[j]; /* Q0 */
move16();
- m = huffnorm_n[j];
+ m = huffnorm_n[j]; /* Q0 */
move16();
}
ELSE
{
/* equal */
- r = huffsizn_e[j];
+ r = huffsizn_e[j]; /* Q0 */
move16();
- m = huffnorm_e[j];
+ m = huffnorm_e[j]; /* Q0 */
move16();
}
}
@@ -387,15 +387,15 @@ Word16 encode_envelope_indices_fx( /* o : Number of b
prevj = add( difidx[0], OFFSET_NORM );
FOR( i = 1; i < num_sfm; i++ )
{
- j = difidx[i];
+ j = difidx[i]; /* Q0 */
move16();
IF( GT_16( prevj, HTH_NORM ) )
{
/* above */
- r = huffsizn_n[sub( 31, j )];
+ r = huffsizn_n[( 31 - j )]; /* Q0 */
move16();
- m = huffnorm_n[sub( 31, j )];
+ m = huffnorm_n[( 31 - j )]; /* Q0 */
move16();
}
ELSE
@@ -403,17 +403,17 @@ Word16 encode_envelope_indices_fx( /* o : Number of b
IF( LT_16( prevj, LTH_NORM ) )
{
/* less */
- r = huffsizn_n[j];
+ r = huffsizn_n[j]; /* Q0 */
move16();
- m = huffnorm_n[j];
+ m = huffnorm_n[j]; /* Q0 */
move16();
}
ELSE
{
/* equal */
- r = huffsizn_e[j];
+ r = huffsizn_e[j]; /* Q0 */
move16();
- m = huffnorm_e[j];
+ m = huffnorm_e[j]; /* Q0 */
move16();
}
}
@@ -441,7 +441,7 @@ Word16 encode_envelope_indices_fx( /* o : Number of b
move16();
FOR( i = 1; i < num_sfm; i++ )
{
- difidx_org[i] = difidx[i];
+ difidx_org[i] = difidx[i]; /* Q0 */
move16();
}
@@ -449,7 +449,7 @@ Word16 encode_envelope_indices_fx( /* o : Number of b
{
IF( GT_16( difidx_org[i - 1], 17 ) )
{
- difidx[i] = add( difidx_org[i], s_min( sub( difidx_org[i - 1], 17 ), 3 ) );
+ difidx[i] = add( difidx_org[i], s_min( sub( difidx_org[i - 1], 17 ), 3 ) ); /* Q0 */
move16();
IF( GT_16( difidx[i], 31 ) )
{
@@ -461,7 +461,7 @@ Word16 encode_envelope_indices_fx( /* o : Number of b
IF( LT_16( difidx_org[i - 1], 13 ) )
{
- difidx[i] = add( difidx_org[i], s_max( sub( difidx_org[i - 1], 13 ), -3 ) );
+ difidx[i] = add( difidx_org[i], s_max( sub( difidx_org[i - 1], 13 ), -3 ) ); /* Q0 */
move16();
IF( difidx[i] < 0 )
{
@@ -486,7 +486,7 @@ Word16 encode_envelope_indices_fx( /* o : Number of b
{
FOR( i = 1; i < num_sfm; i++ )
{
- j = difidx[i];
+ j = difidx[i]; /* Q0 */
move16();
}
}
@@ -496,12 +496,12 @@ Word16 encode_envelope_indices_fx( /* o : Number of b
/* LC mode 2 -> LC mode 1 */
FOR( i = 1; i < num_sfm; i++ )
{
- j = difidx[i];
+ j = difidx[i]; /* Q0 */
move16();
- m = resize_huffnorm[j];
+ m = resize_huffnorm[j]; /* Q0 */
move16();
- r = resize_huffsizn[j];
+ r = resize_huffsizn[j]; /* Q0 */
move16();
v = 0;
move16();
@@ -509,9 +509,9 @@ Word16 encode_envelope_indices_fx( /* o : Number of b
/* Bit reverse */
FOR( k = 0; k < r; k++ )
{
- v = lshl( v, 1 );
- v = s_or( v, s_and( m, 1 ) );
- m = lshr( m, 1 );
+ v = lshl( v, 1 ); /* Q0 */
+ v = s_or( v, s_and( m, 1 ) ); /* Q0 */
+ m = lshr( m, 1 ); /* Q0 */
}
IF( flag_HQ2 == 0 )
@@ -529,12 +529,12 @@ Word16 encode_envelope_indices_fx( /* o : Number of b
/* LC mode 1 -> LC mode 2 */
FOR( i = 1; i < num_sfm; i++ )
{
- j = difidx[i];
+ j = difidx[i]; /* Q0 */
move16();
- m = huffnorm[j];
+ m = huffnorm[j]; /* Q0 */
move16();
- r = huffsizn[j];
+ r = huffsizn[j]; /* Q0 */
move16();
push_indice_fx( hBstr, IND_YNRM, m, r );
@@ -554,7 +554,7 @@ Word16 encode_envelope_indices_fx( /* o : Number of b
}
Word16 encode_envelope_indices_ivas_fx( /* o : Number of bits if flag_pack=0,0 if flag_pack=1 Q0 */
- BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream */
+ BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream Q0 */
const Word16 num_sfm, /* i : Number of subbands Q0 */
const Word16 numnrmibits, /* i : Bitrate of fall-back coding mode Q0 */
Word16 *difidx, /* i/o: Diff indices/encoded diff indices Q0 */
@@ -603,12 +603,12 @@ Word16 encode_envelope_indices_ivas_fx( /* o : Number
{
IF( GT_16( difidx[i], index_max ) )
{
- index_max = difidx[i];
+ index_max = difidx[i]; /* Q0 */
move16();
}
IF( LT_16( difidx[i], index_min ) )
{
- index_min = difidx[i];
+ index_min = difidx[i]; /* Q0 */
move16();
}
}
@@ -617,7 +617,7 @@ Word16 encode_envelope_indices_ivas_fx( /* o : Number
{
FOR( i = 1; i < num_sfm; i++ )
{
- j = difidx[i];
+ j = difidx[i]; /* Q0 */
move16();
bits = add( bits, huffsizn_tran[j] );
}
@@ -630,24 +630,24 @@ Word16 encode_envelope_indices_ivas_fx( /* o : Number
/* LC mode 0 = Context based coding */
FOR( i = 1; i < num_sfm; i++ )
{
- j = difidx[i];
+ j = difidx[i]; /* Q0 */
move16();
IF( GT_16( prevj, HTH_NORM ) )
{
/* above */
- hcode_l = add( hcode_l, huffsizn_n[31 - j] );
+ hcode_l = add( hcode_l, huffsizn_n[31 - j] ); /* Q0 */
}
ELSE
{
IF( LT_16( prevj, LTH_NORM ) )
{
/* less */
- hcode_l = add( hcode_l, huffsizn_n[j] );
+ hcode_l = add( hcode_l, huffsizn_n[j] ); /* Q0 */
}
ELSE
{
/* equal */
- hcode_l = add( hcode_l, huffsizn_e[j] );
+ hcode_l = add( hcode_l, huffsizn_e[j] ); /* Q0 */
}
}
prevj = j;
@@ -671,24 +671,24 @@ Word16 encode_envelope_indices_ivas_fx( /* o : Number
prevj = add( difidx[0], OFFSET_NORM );
FOR( i = 1; i < num_sfm; i++ )
{
- j = difidx[i];
+ j = difidx[i]; /* Q0 */
move16();
IF( GT_16( prevj, HTH_NORM ) )
{
/* above */
- hcode_l = add( hcode_l, huffsizn_n[sub( 31, j )] );
+ hcode_l = add( hcode_l, huffsizn_n[( 31 - j )] ); /* Q0 */
}
ELSE
{
IF( LT_16( prevj, LTH_NORM ) )
{
/* less */
- hcode_l = add( hcode_l, huffsizn_n[j] );
+ hcode_l = add( hcode_l, huffsizn_n[j] ); /* Q0 */
}
ELSE
{
/* equal */
- hcode_l = add( hcode_l, huffsizn_e[j] );
+ hcode_l = add( hcode_l, huffsizn_e[j] ); /* Q0 */
}
}
prevj = j;
@@ -706,7 +706,7 @@ Word16 encode_envelope_indices_ivas_fx( /* o : Number
move16();
FOR( i = 1; i < num_sfm; i++ )
{
- j = difidx[i];
+ j = difidx[i]; /* Q0 */
move16();
bits = add( bits, huffsizn[j] );
}
@@ -715,7 +715,7 @@ Word16 encode_envelope_indices_ivas_fx( /* o : Number
* comparing bit expenses of coding mode 2 with that of the optimal coding mode
*------------------------------------------------------------------------------*/
- if ( GT_16( hcode_l, bits ) )
+ IF( GT_16( hcode_l, bits ) )
{
*LCmode = 2;
move16();
@@ -732,7 +732,7 @@ Word16 encode_envelope_indices_ivas_fx( /* o : Number
move16();
FOR( i = 1; i < num_sfm; i++ )
{
- difidx_org[i] = difidx[i];
+ difidx_org[i] = difidx[i]; /* Q0 */
move16();
}
@@ -742,7 +742,7 @@ Word16 encode_envelope_indices_ivas_fx( /* o : Number
{
IF( GT_16( difidx_org[i - 1], 17 ) )
{
- difidx[i] = add( difidx_org[i], s_min( sub( difidx_org[i - 1], 17 ), 3 ) );
+ difidx[i] = add( difidx_org[i], s_min( sub( difidx_org[i - 1], 17 ), 3 ) ); /* Q0 */
move16();
IF( GT_16( difidx[i], 31 ) )
{
@@ -754,7 +754,7 @@ Word16 encode_envelope_indices_ivas_fx( /* o : Number
IF( LT_16( difidx_org[i - 1], 13 ) )
{
- difidx[i] = add( difidx_org[i], s_max( sub( difidx_org[i - 1], 13 ), -3 ) );
+ difidx[i] = add( difidx_org[i], s_max( sub( difidx_org[i - 1], 13 ), -3 ) ); /* Q0 */
move16();
IF( difidx[i] < 0 )
{
@@ -781,7 +781,7 @@ Word16 encode_envelope_indices_ivas_fx( /* o : Number
{
FOR( i = 1; i < num_sfm; i++ )
{
- j = difidx[i];
+ j = difidx[i]; /* Q0 */
move16();
bits = add( bits, resize_huffsizn[j] );
}
@@ -790,7 +790,7 @@ Word16 encode_envelope_indices_ivas_fx( /* o : Number
* comparing bit expenses of coding mode 1 with that of coding mode 0
*------------------------------------------------------------------*/
- if ( GT_16( hcode_l, bits ) )
+ IF( GT_16( hcode_l, bits ) )
{
*LCmode = 1;
move16();
@@ -806,7 +806,7 @@ Word16 encode_envelope_indices_ivas_fx( /* o : Number
* comparing bit expenses of coding mode 3 with that of the optimal coding mode
*------------------------------------------------------------------------------*/
- if ( GE_16( hcode_l, numnrmibits ) )
+ IF( GE_16( hcode_l, numnrmibits ) )
{
*LCmode = 3;
move16();
@@ -820,7 +820,7 @@ Word16 encode_envelope_indices_ivas_fx( /* o : Number
{
FOR( i = 2; i < num_sfm; i++ )
{
- difidx[i] = difidx_org[i];
+ difidx[i] = difidx_org[i]; /* Q0 */
move16();
}
}
@@ -850,11 +850,11 @@ Word16 encode_envelope_indices_ivas_fx( /* o : Number
/* LC mode 0 Transient Huffman Coding */
FOR( i = 1; i < num_sfm; i++ )
{
- j = difidx[i];
+ j = difidx[i]; /* Q0 */
move16();
- m = huffnorm_tran[j];
+ m = huffnorm_tran[j]; /* Q0 */
move16();
- r = huffsizn_tran[j];
+ r = huffsizn_tran[j]; /* Q0 */
move16();
v = 0;
move16();
@@ -862,9 +862,9 @@ Word16 encode_envelope_indices_ivas_fx( /* o : Number
/* Bit reverse */
FOR( k = 0; k < r; k++ )
{
- v = lshl( v, 1 );
- v = s_or( v, s_and( m, 1 ) );
- m = lshr( m, 1 );
+ v = lshl( v, 1 ); /* Q0 */
+ v = s_or( v, s_and( m, 1 ) ); /* Q0 */
+ m = lshr( m, 1 ); /* Q0 */
}
push_indice( hBstr, IND_HQ2_DIFF_ENERGY, v, r );
@@ -876,15 +876,15 @@ Word16 encode_envelope_indices_ivas_fx( /* o : Number
prevj = add( difidx[0], OFFSET_NORM );
FOR( i = 1; i < num_sfm; i++ )
{
- j = difidx[i];
+ j = difidx[i]; /* Q0 */
move16();
IF( GT_16( prevj, HTH_NORM ) )
{
/* above */
- r = huffsizn_n[sub( 31, j )];
+ r = huffsizn_n[( 31 - j )]; /* Q0 */
move16();
- m = huffnorm_n[sub( 31, j )];
+ m = huffnorm_n[( 31 - j )]; /* Q0 */
move16();
}
ELSE
@@ -892,17 +892,17 @@ Word16 encode_envelope_indices_ivas_fx( /* o : Number
IF( LT_16( prevj, LTH_NORM ) )
{
/* less */
- r = huffsizn_n[j];
+ r = huffsizn_n[j]; /* Q0 */
move16();
- m = huffnorm_n[j];
+ m = huffnorm_n[j]; /* Q0 */
move16();
}
ELSE
{
/* equal */
- r = huffsizn_e[j];
+ r = huffsizn_e[j]; /* Q0 */
move16();
- m = huffnorm_e[j];
+ m = huffnorm_e[j]; /* Q0 */
move16();
}
}
@@ -922,15 +922,15 @@ Word16 encode_envelope_indices_ivas_fx( /* o : Number
prevj = add( difidx[0], OFFSET_NORM );
FOR( i = 1; i < num_sfm; i++ )
{
- j = difidx[i];
+ j = difidx[i]; /* Q0 */
move16();
IF( GT_16( prevj, HTH_NORM ) )
{
/* above */
- r = huffsizn_n[sub( 31, j )];
+ r = huffsizn_n[( 31 - j )]; /* Q0 */
move16();
- m = huffnorm_n[sub( 31, j )];
+ m = huffnorm_n[( 31 - j )]; /* Q0 */
move16();
}
ELSE
@@ -938,17 +938,17 @@ Word16 encode_envelope_indices_ivas_fx( /* o : Number
IF( LT_16( prevj, LTH_NORM ) )
{
/* less */
- r = huffsizn_n[j];
+ r = huffsizn_n[j]; /* Q0 */
move16();
- m = huffnorm_n[j];
+ m = huffnorm_n[j]; /* Q0 */
move16();
}
ELSE
{
/* equal */
- r = huffsizn_e[j];
+ r = huffsizn_e[j]; /* Q0 */
move16();
- m = huffnorm_e[j];
+ m = huffnorm_e[j]; /* Q0 */
move16();
}
}
@@ -976,7 +976,7 @@ Word16 encode_envelope_indices_ivas_fx( /* o : Number
move16();
FOR( i = 1; i < num_sfm; i++ )
{
- difidx_org[i] = difidx[i];
+ difidx_org[i] = difidx[i]; /* Q0 */
move16();
}
@@ -984,7 +984,7 @@ Word16 encode_envelope_indices_ivas_fx( /* o : Number
{
IF( GT_16( difidx_org[i - 1], 17 ) )
{
- difidx[i] = add( difidx_org[i], s_min( sub( difidx_org[i - 1], 17 ), 3 ) );
+ difidx[i] = add( difidx_org[i], s_min( sub( difidx_org[i - 1], 17 ), 3 ) ); /* Q0 */
move16();
IF( GT_16( difidx[i], 31 ) )
{
@@ -996,7 +996,7 @@ Word16 encode_envelope_indices_ivas_fx( /* o : Number
IF( LT_16( difidx_org[i - 1], 13 ) )
{
- difidx[i] = add( difidx_org[i], s_max( sub( difidx_org[i - 1], 13 ), -3 ) );
+ difidx[i] = add( difidx_org[i], s_max( sub( difidx_org[i - 1], 13 ), -3 ) ); /* Q0 */
move16();
IF( difidx[i] < 0 )
{
@@ -1021,7 +1021,7 @@ Word16 encode_envelope_indices_ivas_fx( /* o : Number
{
FOR( i = 1; i < num_sfm; i++ )
{
- j = difidx[i];
+ j = difidx[i]; /* Q0 */
move16();
}
}
@@ -1031,12 +1031,12 @@ Word16 encode_envelope_indices_ivas_fx( /* o : Number
/* LC mode 2 -> LC mode 1 */
FOR( i = 1; i < num_sfm; i++ )
{
- j = difidx[i];
+ j = difidx[i]; /* Q0 */
move16();
- m = resize_huffnorm[j];
+ m = resize_huffnorm[j]; /* Q0 */
move16();
- r = resize_huffsizn[j];
+ r = resize_huffsizn[j]; /* Q0 */
move16();
v = 0;
move16();
@@ -1044,9 +1044,9 @@ Word16 encode_envelope_indices_ivas_fx( /* o : Number
/* Bit reverse */
FOR( k = 0; k < r; k++ )
{
- v = lshl( v, 1 );
- v = s_or( v, s_and( m, 1 ) );
- m = lshr( m, 1 );
+ v = lshl( v, 1 ); /* Q0 */
+ v = s_or( v, s_and( m, 1 ) ); /* Q0 */
+ m = lshr( m, 1 ); /* Q0 */
}
IF( flag_HQ2 == 0 )
@@ -1064,12 +1064,12 @@ Word16 encode_envelope_indices_ivas_fx( /* o : Number
/* LC mode 1 -> LC mode 2 */
FOR( i = 1; i < num_sfm; i++ )
{
- j = difidx[i];
+ j = difidx[i]; /* Q0 */
move16();
- m = huffnorm[j];
+ m = huffnorm[j]; /* Q0 */
move16();
- r = huffsizn[j];
+ r = huffsizn[j]; /* Q0 */
move16();
push_indice( hBstr, IND_YNRM, m, r );
@@ -1113,20 +1113,20 @@ void diff_envelope_coding_fx(
/* Reorder quantization indices and quantized norms */
reordernorm_fx( ynrm, normqlg2, idxbuf, normbuf, num_env_bands );
diffcod_fx( num_env_bands, idxbuf, &difidx[1] );
- difidx[0] = idxbuf[0];
+ difidx[0] = idxbuf[0]; /* Q0 */
move16();
recovernorm_fx( idxbuf, ynrm, normqlg2, num_env_bands );
}
ELSE
{
diffcod_fx( num_env_bands, &ynrm[start_norm], &difidx[1] );
- difidx[0] = ynrm[start_norm];
+ difidx[0] = ynrm[start_norm]; /* Q0 */
move16();
tmp = add( start_norm, num_env_bands );
FOR( i = start_norm; i < tmp; i++ )
{
- normqlg2[i] = dicnlg2[ynrm[i]];
+ normqlg2[i] = dicnlg2[ynrm[i]]; /* Q0 */
move16();
move16();
}
diff --git a/lib_enc/hq_hr_enc.c b/lib_enc/hq_hr_enc.c
index 07080804eb0063c217028438ad92480e21232fde..f73925978f0f7f80cdad30357bf272f047979f7d 100644
--- a/lib_enc/hq_hr_enc.c
+++ b/lib_enc/hq_hr_enc.c
@@ -53,11 +53,11 @@
void hq_hr_enc_ivas_fx(
Encoder_State *st, /* i/o: encoder state structure */
- Word32 *t_audio_fx, /* i/o: transform-domain coefficients */
- const Word16 length, /* i : length of spectrum */
- Word16 *num_bits, /* i/o: number of available bits */
- const Word16 is_transient, /* i : transient flag */
- const Word16 vad_hover_flag /* i : VAD hangover flag */
+ Word32 *t_audio_fx, /* i/o: transform-domain coefficients Q12*/
+ const Word16 length, /* i : length of spectrum Q0*/
+ Word16 *num_bits, /* i/o: number of available bits Q0*/
+ const Word16 is_transient, /* i : transient flag Q0*/
+ const Word16 vad_hover_flag /* i : VAD hangover flag Q0*/
)
{
Word16 nb_sfm;
@@ -113,7 +113,7 @@ void hq_hr_enc_ivas_fx(
/*------------------------------------------------------------------*
* Classification
*------------------------------------------------------------------*/
- bits = hq_classifier_enc_ivas_fx( st, length, t_audio_fx, is_transient, &Npeaks, peaks, pe_gains_fx, nf_gains_fx, &hqswb_clas );
+ bits = hq_classifier_enc_ivas_fx( st, length, t_audio_fx, is_transient, &Npeaks, peaks, pe_gains_fx, nf_gains_fx, &hqswb_clas ); /* Q0 */
*num_bits = sub( *num_bits, bits );
move16();
@@ -135,7 +135,7 @@ void hq_hr_enc_ivas_fx(
IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) )
{
calculate_hangover_attenuation_gain_ivas_fx( st, &att_fx, vad_hover_flag );
- v_multc_att32( t_audio_fx, att_fx, t_audio_fx, sfm_end[sub( num_sfm, 1 )] );
+ v_multc_att32( t_audio_fx, att_fx, t_audio_fx, sfm_end[( num_sfm - 1 )] ); /* Q12 */
}
/*------------------------------------------------------------------*
@@ -149,7 +149,7 @@ void hq_hr_enc_ivas_fx(
diff_envelope_coding_fx( is_transient, num_env_bands, start_norm, ynrm, normqlg2, difidx );
/* Find norm coding mode and calculate number of bits */
- hcode_l = encode_envelope_indices_ivas_fx( hBstr, num_env_bands, numnrmibits, difidx, &LCmode, 0, NORMAL_HQ_CORE, is_transient );
+ hcode_l = encode_envelope_indices_ivas_fx( hBstr, num_env_bands, numnrmibits, difidx, &LCmode, 0, NORMAL_HQ_CORE, is_transient ); /* Q0 */
*num_bits = sub( *num_bits, add( hcode_l, NORM0_BITS + FLAGS_BITS ) );
move16();
@@ -187,12 +187,13 @@ void hq_hr_enc_ivas_fx(
test();
IF( EQ_16( hqswb_clas, HQ_GEN_SWB ) || EQ_16( hqswb_clas, HQ_GEN_FB ) )
{
- b_delta_env = calc_nor_delta_hf_ivas_fx( hBstr, t_audio_fx, ynrm, Rsubband, num_env_bands, nb_sfm, sfmsize, sfm_start, core_sfm );
+ b_delta_env = calc_nor_delta_hf_ivas_fx( hBstr, t_audio_fx, ynrm, Rsubband, num_env_bands, nb_sfm, sfmsize, sfm_start, core_sfm ); /* Q0 */
sum = sub( sum, b_delta_env );
}
normalizecoefs_fx( t_audio_fx, ynrm, nb_sfm, sfm_start, sfm_end, t_audio_norm );
}
Word16 Q_audio = 12, Q_shift;
+ move16();
/*------------------------------------------------------------------*
* Quantize/code spectral fine structure using PVQ or HVQ
*------------------------------------------------------------------*/
@@ -204,7 +205,7 @@ void hq_hr_enc_ivas_fx(
}
ELSE
{
- shape_bits = pvq_core_enc_ivas_fx( hBstr, t_audio_norm, t_audio_q_norm, &Q_audio, sum, nb_sfm, sfm_start, sfm_end, sfmsize, Rsubband, R, npulses, maxpulse, HQ_CORE );
+ shape_bits = pvq_core_enc_ivas_fx( hBstr, t_audio_norm, t_audio_q_norm, &Q_audio, sum, nb_sfm, sfm_start, sfm_end, sfmsize, Rsubband, R, npulses, maxpulse, HQ_CORE ); /* Q0 */
*num_bits = add( *num_bits, sub( sum, shape_bits ) );
move16();
}
@@ -212,9 +213,9 @@ void hq_hr_enc_ivas_fx(
test();
IF( EQ_16( hqswb_clas, HQ_HVQ ) || EQ_16( hqswb_clas, HQ_HARMONIC ) )
{
- subband_search_offset = subband_search_offsets_13p2kbps_Har;
- wBands[0] = SWB_SB_BW_LEN0_16KBPS_HAR;
- wBands[1] = SWB_SB_BW_LEN1_16KBPS_HAR;
+ subband_search_offset = subband_search_offsets_13p2kbps_Har; /* Q0 */
+ wBands[0] = SWB_SB_BW_LEN0_16KBPS_HAR; /* Q0 */
+ wBands[1] = SWB_SB_BW_LEN1_16KBPS_HAR; /* Q0 */
move16();
move16();
IF( EQ_16( hqswb_clas, HQ_HARMONIC ) )
@@ -247,24 +248,25 @@ void hq_hr_enc_ivas_fx(
test();
IF( EQ_16( hqswb_clas, HQ_GEN_SWB ) || EQ_16( hqswb_clas, HQ_GEN_FB ) )
{
- nf_idx = noise_adjust_fx( t_audio_norm, 12, R, sfm_start, sfm_end, s_max( core_sfm, sub( num_env_bands, 1 ) ) );
+ nf_idx = noise_adjust_fx( t_audio_norm, 12, R, sfm_start, sfm_end, s_max( core_sfm, sub( num_env_bands, 1 ) ) ); /* Q0 */
push_indice( hBstr, IND_NF_IDX, nf_idx, 2 );
}
ELSE
{
- nf_idx = noise_adjust_fx( t_audio_norm, 12, R, sfm_start, sfm_end, core_sfm );
+ nf_idx = noise_adjust_fx( t_audio_norm, 12, R, sfm_start, sfm_end, core_sfm ); /* Q0 */
push_indice( hBstr, IND_NF_IDX, nf_idx, 2 );
}
}
/* updates */
- hHQ_core->prev_hqswb_clas = hqswb_clas;
+ hHQ_core->prev_hqswb_clas = hqswb_clas; /* Q0 */
move16();
/* Prepare synthesis for LB generation in case of switch to ACELP */
IF( NE_16( hqswb_clas, HQ_HVQ ) )
{
apply_envelope_enc_ivas_fx( t_audio_q_norm, ynrm, num_sfm, sfm_start, sfm_end, t_audio_q_fx );
+ scale_sig32( t_audio_q_fx, length, sub( Q12, Q_audio ) ); // Q12
}
IF( is_transient )
diff --git a/lib_enc/hq_hr_enc_fx.c b/lib_enc/hq_hr_enc_fx.c
index f1ff0d62f5911f289b84cce3a05e244c8dce6e84..f73a926dc5177ed57cbbcfaeeec3c93b77eb3512 100644
--- a/lib_enc/hq_hr_enc_fx.c
+++ b/lib_enc/hq_hr_enc_fx.c
@@ -20,7 +20,7 @@ void hq_hr_enc_fx(
const Word16 length, /* i : length of spectrum Q0 */
Word16 *num_bits, /* i : number of available bits Q0 */
const Word16 is_transient, /* i : transient flag Q0 */
- const Word16 vad_hover_flag /* i : VAD hangover flag */
+ const Word16 vad_hover_flag /* i : VAD hangover flag Q0 */
)
{
Word16 nb_sfm; /* Q0 */
@@ -47,7 +47,8 @@ void hq_hr_enc_fx(
Word16 hq_generic_offset; /* Q0 */
Word16 hq_generic_fenv[HQ_FB_FENV]; /* Q1 */
Word16 hq_generic_exc_clas = 0; /* Q0 */
- Word16 core_sfm; /* Q0 */
+ move16();
+ Word16 core_sfm; /* Q0 */
Word16 har_freq_est1, har_freq_est2;
Word16 flag_dis;
const Word16 *subband_search_offset;
@@ -68,6 +69,8 @@ void hq_hr_enc_fx(
Npeaks = 0;
Q_audio = 0; /* to avoid compilation warnings */
+ move16();
+ move16();
set16_fx( npulses, 0, NB_SFM );
set16_fx( maxpulse, 0, NB_SFM );
@@ -86,9 +89,10 @@ void hq_hr_enc_fx(
* Classification
*------------------------------------------------------------------*/
- bits = hq_classifier_enc_fx( st_fx, length, t_audio, is_transient, &Npeaks, peaks, pe_gains, nf_gains, &hqswb_clas );
+ bits = hq_classifier_enc_fx( st_fx, length, t_audio, is_transient, &Npeaks, peaks, pe_gains, nf_gains, &hqswb_clas ); /* Q0 */
- *num_bits = sub( *num_bits, bits );
+ *num_bits = sub( *num_bits, bits ); /* Q0 */
+ move16();
/*------------------------------------------------------------------*
* set quantization parameters
@@ -111,7 +115,7 @@ void hq_hr_enc_fx(
IF( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) )
{
calculate_hangover_attenuation_gain_fx( st_fx, &att, vad_hover_flag );
- v_multc_att32( t_audio, att, t_audio, sfm_end[sub( num_sfm, 1 )] );
+ v_multc_att32( t_audio, att, t_audio, sfm_end[( num_sfm - 1 )] ); /* Q12 */
}
/*------------------------------------------------------------------*
* Scalar quantization of norms
@@ -125,8 +129,9 @@ void hq_hr_enc_fx(
diff_envelope_coding_fx( is_transient, num_env_bands, start_norm, ynrm, normqlg2, difidx );
/* Find coding mode and calculate bit rate */
- hcode_l = encode_envelope_indices_fx( st_fx->hBstr, num_env_bands, numnrmibits, difidx, &LCmode, 0, NORMAL_HQ_CORE, is_transient );
- *num_bits = sub( *num_bits, add( hcode_l, NORM0_BITS + FLAGS_BITS ) );
+ hcode_l = encode_envelope_indices_fx( st_fx->hBstr, num_env_bands, numnrmibits, difidx, &LCmode, 0, NORMAL_HQ_CORE, is_transient ); /* Q0 */
+ *num_bits = sub( *num_bits, add( hcode_l, NORM0_BITS + FLAGS_BITS ) ); /* Q0 */
+ move16();
/* Encode norm indices */
encode_envelope_indices_fx( st_fx->hBstr, num_env_bands, numnrmibits, difidx, &LCmode, 1, NORMAL_HQ_CORE, is_transient );
@@ -141,7 +146,8 @@ void hq_hr_enc_fx(
hq_generic_encoding_fx( t_audio, hq_generic_fenv, hq_generic_offset, st_fx, &hq_generic_exc_clas /*, length*/ );
IF( EQ_16( hq_generic_exc_clas, HQ_GENERIC_SP_EXC ) )
{
- *num_bits = add( *num_bits, 1 ); /* conditional 1 bit saving for representing FD3 BWE excitation class */
+ *num_bits = add( *num_bits, 1 ); /* conditional 1 bit saving for representing FD3 BWE excitation class Q0*/
+ move16();
}
map_hq_generic_fenv_norm_fx( hqswb_clas, hq_generic_fenv, ynrm, normqlg2, num_env_bands, nb_sfm, hq_generic_offset );
}
@@ -161,11 +167,12 @@ void hq_hr_enc_fx(
test();
IF( hqswb_clas == HQ_GEN_SWB || hqswb_clas == HQ_GEN_FB )
{
- b_delta_env = calc_nor_delta_hf_fx( st_fx->hBstr, t_audio, ynrm, Rsubband, num_env_bands, nb_sfm, sfmsize, sfm_start, core_sfm );
- sum -= b_delta_env;
+ b_delta_env = calc_nor_delta_hf_fx( st_fx->hBstr, t_audio, ynrm, Rsubband, num_env_bands, nb_sfm, sfmsize, sfm_start, core_sfm ); /* Q0 */
+ sum = sub( sum, b_delta_env );
}
normalizecoefs_fx( t_audio, ynrm, nb_sfm, sfm_start, sfm_end, t_audio_norm );
Q_audio = 12;
+ move16();
}
/*------------------------------------------------------------------*
@@ -174,22 +181,24 @@ void hq_hr_enc_fx(
IF( EQ_16( hqswb_clas, HQ_HVQ ) )
{
sum = hvq_enc_fx( st_fx, st_fx->core_brate, *num_bits, Npeaks, ynrm, R, peaks, nf_gains, noise_level, pe_gains, t_audio, t_audio_q );
- *num_bits = sub( *num_bits, sum );
+ *num_bits = sub( *num_bits, sum ); /* Q0 */
+ move16();
}
ELSE
{
shape_bits = pvq_core_enc_fx( st_fx->hBstr, t_audio_norm, t_audio_q_norm, &Q_audio, sum, nb_sfm, sfm_start, sfm_end, sfmsize, Rsubband, R,
npulses, maxpulse, HQ_CORE );
- *num_bits = add( *num_bits, sub( sum, shape_bits ) );
+ *num_bits = add( *num_bits, sub( sum, shape_bits ) ); /* Q0 */
+ move16();
}
test();
IF( EQ_16( hqswb_clas, HQ_HVQ ) || EQ_16( hqswb_clas, HQ_HARMONIC ) )
{
- subband_search_offset = subband_search_offsets_13p2kbps_Har;
- wBands[0] = SWB_SB_BW_LEN0_16KBPS_HAR;
+ subband_search_offset = subband_search_offsets_13p2kbps_Har; /* Q0 */
+ wBands[0] = SWB_SB_BW_LEN0_16KBPS_HAR; /* Q0 */
move16();
- wBands[1] = SWB_SB_BW_LEN1_16KBPS_HAR;
+ wBands[1] = SWB_SB_BW_LEN1_16KBPS_HAR; /* Q0 */
move16();
IF( EQ_16( hqswb_clas, HQ_HARMONIC ) )
@@ -198,12 +207,13 @@ void hq_hr_enc_fx(
FOR( i = 0; i < 300; i++ )
{
t_audio_q[i] = L_shl( L_deposit_l( t_audio_q_norm[i] ), Q_shift ); /* Q12 */
+ move32();
}
}
har_est_fx( t_audio_q, 300, &har_freq_est1, &har_freq_est2, &flag_dis, &hHQ_core->prev_frm_hfe2, subband_search_offset, wBands, &hHQ_core->prev_stab_hfe2 );
- hHQ_core->prev_frm_hfe2 = har_freq_est2;
+ hHQ_core->prev_frm_hfe2 = har_freq_est2; /* Q0 */
move16();
}
@@ -224,17 +234,17 @@ void hq_hr_enc_fx(
test();
IF( EQ_16( hqswb_clas, HQ_GEN_SWB ) || EQ_16( hqswb_clas, HQ_GEN_FB ) )
{
- nf_idx = noise_adjust_fx( t_audio_norm, 12, R, sfm_start, sfm_end, s_max( core_sfm, sub( num_env_bands, 1 ) ) );
+ nf_idx = noise_adjust_fx( t_audio_norm, 12, R, sfm_start, sfm_end, s_max( core_sfm, sub( num_env_bands, 1 ) ) ); /* Q0 */
push_indice_fx( st_fx->hBstr, IND_NF_IDX, nf_idx, 2 );
}
ELSE
{
- nf_idx = noise_adjust_fx( t_audio_norm, 12, R, sfm_start, sfm_end, core_sfm );
+ nf_idx = noise_adjust_fx( t_audio_norm, 12, R, sfm_start, sfm_end, core_sfm ); /* Q0 */
push_indice_fx( st_fx->hBstr, IND_NF_IDX, nf_idx, 2 );
}
}
/* updates */
- hHQ_core->prev_hqswb_clas = hqswb_clas;
+ hHQ_core->prev_hqswb_clas = hqswb_clas; /* Q0 */
move16();
/* Prepare synthesis for LB generation in case of switch to ACELP */
diff --git a/lib_enc/hq_lr_enc_fx.c b/lib_enc/hq_lr_enc_fx.c
index e602d28b36257214b18b592633dbc60b98ccb8db..424689804d665f7b3bd8325169cf647bc4627d9b 100644
--- a/lib_enc/hq_lr_enc_fx.c
+++ b/lib_enc/hq_lr_enc_fx.c
@@ -18,14 +18,14 @@
* Local function prototypes
*--------------------------------------------------------------------------*/
-static Word16 band_energy_quant_fx( BSTR_ENC_HANDLE hBstr, const Word32 *L_t_audio, const Word16 band_start_fx[], const Word16 band_end_fx[], Word32 L_band_energy[], const Word16 bands_fx, const Word32 L_qint, const Word16 eref_fx, const Word16 is_transient_fx );
+static Word16 band_energy_quant_fx( BSTR_ENC_HANDLE hBstr, const Word32 *L_t_audio /*Q12*/, const Word16 band_start_fx[], const Word16 band_end_fx[], Word32 L_band_energy[] /*Q14*/, const Word16 bands_fx, const Word32 L_qint /*Q29*/, const Word16 eref_fx /*Q10*/, const Word16 is_transient_fx );
-static Word16 p2a_threshold_quant_fx( BSTR_ENC_HANDLE hBstr, const Word32 *L_t_audio, const Word16 band_start[], const Word16 band_end[], const Word16 band_width[], const Word16 bands, const Word16 p2a_bands, const Word16 p2a_th, Word16 *p2a_flags );
+static Word16 p2a_threshold_quant_fx( BSTR_ENC_HANDLE hBstr, const Word32 *L_t_audio /*Q12*/, const Word16 band_start[], const Word16 band_end[], const Word16 band_width[], const Word16 bands, const Word16 p2a_bands, const Word16 p2a_th /*Q11*/, Word16 *p2a_flags );
-static void mdct_spectrum_fine_gain_enc_fx( Encoder_State *st_fx, const Word32 L_ybuf[], Word32 L_y2[], const Word16 band_start[], const Word16 band_end[], const Word16 k_sort[], const Word16 bands, const Word32 L_qint, const Word16 Ngq, const Word16 gqlevs, const Word16 gqbits );
+static void mdct_spectrum_fine_gain_enc_fx( Encoder_State *st_fx, const Word32 L_ybuf[] /*Q12*/, Word32 L_y2[] /*Q12*/, const Word16 band_start[], const Word16 band_end[], const Word16 k_sort[], const Word16 bands, const Word32 L_qint /*Q29*/, const Word16 Ngq, const Word16 gqlevs, const Word16 gqbits );
-static Word16 p2a_threshold_quant_ivas_fx( BSTR_ENC_HANDLE hBstr, const Word32 *L_t_audio, const Word16 band_start[], const Word16 band_end[], const Word16 band_width[], const Word16 bands, const Word16 p2a_bands, const Word16 p2a_th, Word16 *p2a_flags );
+static Word16 p2a_threshold_quant_ivas_fx( BSTR_ENC_HANDLE hBstr, const Word32 *L_t_audio /*Q12*/, const Word16 band_start[], const Word16 band_end[], const Word16 band_width[], const Word16 bands, const Word16 p2a_bands, const Word16 p2a_th /*Q11*/, Word16 *p2a_flags );
static void mdct_spectrum_fine_gain_enc_ivas_fx(
Encoder_State *st_fx, /* i/o: encoder state structure */
const Word32 L_ybuf[], /* i : Q12 : input spectrum */
@@ -41,15 +41,15 @@ static void mdct_spectrum_fine_gain_enc_ivas_fx(
);
static Word16 band_energy_quant_ivas_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const Word32 *L_t_audio,
- const Word16 band_start[],
- const Word16 band_end[],
- Word32 L_band_energy[],
- const Word16 bands_fx,
- const Word32 L_qint, /* Q29 */
- const Word16 eref_fx, /* Q10 */
- const Word16 is_transient );
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ const Word32 *L_t_audio, /* Q12 */
+ const Word16 band_start[], /* Q0 */
+ const Word16 band_end[], /* Q0 */
+ Word32 L_band_energy[], /* Q14 */
+ const Word16 bands_fx, /* Q0 */
+ const Word32 L_qint, /* Q29 */
+ const Word16 eref_fx, /* Q10 */
+ const Word16 is_transient /* Q0 */ );
/*--------------------------------------------------------------------------*
* spt_shorten_domain_set()
@@ -59,16 +59,16 @@ static Word16 band_energy_quant_ivas_fx(
static void spt_shorten_domain_set_fx(
Encoder_State *st_fx, /* i: encoder state structure */
- const Word32 L_t_audio[], /* i: input spectrum */
- const Word16 p2a_flags[], /* i: p2a anlysis information */
- const Word16 new_band_start[], /* i: new band start position */
- const Word16 new_band_end[], /* i: new band end position */
- const Word16 new_band_width[], /* i: new subband band width */
- const Word16 bands, /* i: total number of subbands */
- Word16 band_start[], /* i/o: band start position */
- Word16 band_end[], /* i/o: band end position */
- Word16 band_width[], /* i: sub band band width */
- Word16 *bit_budget /* i/o: bit budget */
+ const Word32 L_t_audio[], /* i: input spectrum Q12*/
+ const Word16 p2a_flags[], /* i: p2a anlysis information Q0*/
+ const Word16 new_band_start[], /* i: new band start position Q0*/
+ const Word16 new_band_end[], /* i: new band end position Q0*/
+ const Word16 new_band_width[], /* i: new subband band width Q0*/
+ const Word16 bands, /* i: total number of subbands Q0*/
+ Word16 band_start[], /* i/o: band start position Q0*/
+ Word16 band_end[], /* i/o: band end position Q0*/
+ Word16 band_width[], /* i: sub band band width Q0*/
+ Word16 *bit_budget /* i/o: bit budget Q0*/
)
{
Word16 i, j, k;
@@ -81,7 +81,8 @@ static void spt_shorten_domain_set_fx(
kpos = 0;
j = 0;
move16();
- FOR( k = sub( bands, SPT_SHORTEN_SBNUM ); k < bands; k++ )
+ move16();
+ FOR( k = ( bands - SPT_SHORTEN_SBNUM ); k < bands; k++ )
{
IF( EQ_16( p2a_flags[k], 1 ) )
{
@@ -96,7 +97,8 @@ static void spt_shorten_domain_set_fx(
{
IF( LT_32( L_max_y2, L_abs( L_t_audio[i] ) ) )
{
- L_max_y2 = L_abs( L_t_audio[i] );
+ L_max_y2 = L_abs( L_t_audio[i] ); /* Q12 */
+ move32();
max_y2_pos = i;
move16();
}
@@ -104,22 +106,23 @@ static void spt_shorten_domain_set_fx(
test();
IF( GE_16( max_y2_pos, new_band_start[j] ) && LE_16( max_y2_pos, new_band_end[j] ) )
{
- band_start[k] = new_band_start[j];
+ band_start[k] = new_band_start[j]; /* Q0 */
move16();
- band_end[k] = new_band_end[j];
+ band_end[k] = new_band_end[j]; /* Q0 */
move16();
- band_width[k] = new_band_width[j];
+ band_width[k] = new_band_width[j]; /* Q0 */
move16();
spt_shorten_flag[j] = 1;
move16();
}
}
push_indice_fx( st_fx->hBstr, IND_HQ2_SPT_SHORTEN, spt_shorten_flag[j], 1 );
- *bit_budget = sub( *bit_budget, 1 );
+ *bit_budget = sub( *bit_budget, 1 ); /* Q0 */
+ move16();
}
- kpos = add( kpos, 1 );
- j = add( j, 1 );
+ kpos += 1;
+ j += 1;
}
return;
@@ -127,16 +130,16 @@ static void spt_shorten_domain_set_fx(
static void spt_shorten_domain_set_ivas_fx(
Encoder_State *st_fx, /* i: encoder state structure */
- const Word32 L_t_audio[], /* i: input spectrum */
- const Word16 p2a_flags[], /* i: p2a anlysis information */
- const Word16 new_band_start[], /* i: new band start position */
- const Word16 new_band_end[], /* i: new band end position */
- const Word16 new_band_width[], /* i: new subband band width */
- const Word16 bands, /* i: total number of subbands */
- Word16 band_start[], /* i/o: band start position */
- Word16 band_end[], /* i/o: band end position */
- Word16 band_width[], /* i: sub band band width */
- Word16 *bit_budget /* i/o: bit budget */
+ const Word32 L_t_audio[], /* i: input spectrum Q12*/
+ const Word16 p2a_flags[], /* i: p2a anlysis information Q0*/
+ const Word16 new_band_start[], /* i: new band start position Q0*/
+ const Word16 new_band_end[], /* i: new band end position Q0*/
+ const Word16 new_band_width[], /* i: new subband band width Q0*/
+ const Word16 bands, /* i: total number of subbands Q0*/
+ Word16 band_start[], /* i/o: band start position Q0*/
+ Word16 band_end[], /* i/o: band end position Q0*/
+ Word16 band_width[], /* i: sub band band width Q0*/
+ Word16 *bit_budget /* i/o: bit budget Q0*/
)
{
Word16 i, j, k;
@@ -150,7 +153,7 @@ static void spt_shorten_domain_set_ivas_fx(
j = 0;
move16();
move16();
- FOR( k = sub( bands, SPT_SHORTEN_SBNUM ); k < bands; k++ )
+ FOR( k = ( bands - SPT_SHORTEN_SBNUM ); k < bands; k++ )
{
IF( EQ_16( p2a_flags[k], 1 ) )
{
@@ -165,7 +168,8 @@ static void spt_shorten_domain_set_ivas_fx(
{
IF( LT_32( L_max_y2, L_abs( L_t_audio[i] ) ) )
{
- L_max_y2 = L_abs( L_t_audio[i] );
+ L_max_y2 = L_abs( L_t_audio[i] ); /* Q12 */
+ move32();
max_y2_pos = i;
move16();
}
@@ -173,22 +177,23 @@ static void spt_shorten_domain_set_ivas_fx(
test();
IF( GE_16( max_y2_pos, new_band_start[j] ) && LE_16( max_y2_pos, new_band_end[j] ) )
{
- band_start[k] = new_band_start[j];
+ band_start[k] = new_band_start[j]; /* Q0 */
move16();
- band_end[k] = new_band_end[j];
+ band_end[k] = new_band_end[j]; /* Q0 */
move16();
- band_width[k] = new_band_width[j];
+ band_width[k] = new_band_width[j]; /* Q0 */
move16();
spt_shorten_flag[j] = 1;
move16();
}
}
push_indice( st_fx->hBstr, IND_HQ2_SPT_SHORTEN, spt_shorten_flag[j], 1 );
- *bit_budget = sub( *bit_budget, 1 );
+ *bit_budget = sub( *bit_budget, 1 ); /* Q0 */
+ move16();
}
- kpos = add( kpos, 1 );
- j = add( j, 1 );
+ kpos += 1;
+ j += 1;
}
return;
@@ -270,6 +275,7 @@ void hq_lr_enc_fx(
BSTR_ENC_HANDLE hBstr = st_fx->hBstr;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
@@ -288,6 +294,7 @@ void hq_lr_enc_fx(
enerH_fx = L_deposit_l( 0 );
tmp2 = 0; /* to avoid compilation warnings */
+ move16();
L_bwe_br = L_add( st_fx->core_brate, 0 );
hqswb_clas_fx = HQ_NORMAL;
@@ -303,13 +310,14 @@ void hq_lr_enc_fx(
}
ELSE
{
- hqswb_clas_fx = peak_avrg_ratio_fx( st_fx->total_brate, L_t_audio, NUMC_N, &hHQ_core->mode_count, &hHQ_core->mode_count1, SWB_BWE_LR_Qs );
+ hqswb_clas_fx = peak_avrg_ratio_fx( st_fx->total_brate, L_t_audio, NUMC_N, &hHQ_core->mode_count, &hHQ_core->mode_count1, SWB_BWE_LR_Qs ); /* Q0 */
}
/* write the classification information into the bitstream */
push_indice_fx( hBstr, IND_HQ2_SWB_CLAS, hqswb_clas_fx, 2 );
( *num_bits_fx ) = sub( *num_bits_fx, 2 );
- if ( EQ_16( hqswb_clas_fx, HQ_NORMAL ) )
+ move16();
+ IF( EQ_16( hqswb_clas_fx, HQ_NORMAL ) )
{
flag_spt_fx = 1;
move16();
@@ -321,15 +329,16 @@ void hq_lr_enc_fx(
push_indice_fx( st_fx->hBstr, IND_HQ2_SWB_CLAS, is_transient_fx, 1 );
/* subtract one bit for the transient flag */
- ( *num_bits_fx )--;
+ ( *num_bits_fx ) = sub( ( *num_bits_fx ), 1 );
+ move16();
}
hq2_core_configure_fx( inner_frame_fx, *num_bits_fx, is_transient_fx, &bands_fx, &length_fx, band_width, band_start, band_end,
&L_qint, &eref_fx, &bit_alloc_weight_fx, &gqlevs_fx, &Ngq_fx, &p2a_bands_fx, &p2a_th_fx, &pd_thresh_fx, &ld_slope_fx, &ni_coef_fx, L_bwe_br );
- highlength_fx = band_end[sub( bands_fx, 1 )];
+ highlength_fx = band_end[( bands_fx - 1 )]; /* Q0 */
move16();
- har_bands_fx = bands_fx;
+ har_bands_fx = bands_fx; /* Q0 */
move16();
test();
@@ -342,6 +351,7 @@ void hq_lr_enc_fx(
IF( EQ_16( hqswb_clas_fx, HQ_NORMAL ) || EQ_16( hqswb_clas_fx, HQ_HARMONIC ) )
{
( *num_bits_fx ) = sub( *num_bits_fx, get_usebit_npswb_fx( hqswb_clas_fx ) );
+ move16();
}
}
@@ -353,7 +363,7 @@ void hq_lr_enc_fx(
{
j = 0;
move16();
- FOR( k = sub( bands_fx, SPT_SHORTEN_SBNUM ); k < bands_fx; k++ )
+ FOR( k = ( bands_fx - SPT_SHORTEN_SBNUM ); k < bands_fx; k++ )
{
hHQ_core->prev_SWB_peak_pos[j] = 0;
move16();
@@ -368,16 +378,18 @@ void hq_lr_enc_fx(
{
/* If so, collapse transient frame (4 short transforms) to remove uncoded coefficients */
- k1_step_fx = shr( length_fx, 2 ); /* k1 = length/NUM_TIME_SWITCHING_BLOCKS */
- k2_step_fx = shr( inner_frame_fx, 2 ); /* k2 = inner_frame/NUM_TIME_SWITCHING_BLOCKS */
- k1_fx = k1_step_fx;
- k2_fx = k2_step_fx;
+ k1_step_fx = shr( length_fx, 2 ); /* k1 = length/NUM_TIME_SWITCHING_BLOCKS Q0*/
+ k2_step_fx = shr( inner_frame_fx, 2 ); /* k2 = inner_frame/NUM_TIME_SWITCHING_BLOCKS Q0*/
+ k1_fx = k1_step_fx; /* Q0 */
+ k2_fx = k2_step_fx; /* Q0 */
+ move16();
+ move16();
FOR( i = 1; i < NUM_TIME_SWITCHING_BLOCKS; i++ )
{
/*k1 = i*length/NUM_TIME_SWITCHING_BLOCKS; */
/*k2 = i*inner_frame/NUM_TIME_SWITCHING_BLOCKS; */
- Copy32( &L_t_audio[k2_fx], &L_t_audio[k1_fx], k1_step_fx );
+ Copy32( &L_t_audio[k2_fx], &L_t_audio[k1_fx], k1_step_fx ); /* Q12 */
k1_fx = add( k1_fx, k1_step_fx );
k2_fx = add( k2_fx, k2_step_fx );
@@ -386,13 +398,13 @@ void hq_lr_enc_fx(
/* Spectral energy calculation/quantization */
ebits_fx = band_energy_quant_fx( hBstr, L_t_audio, band_start, band_end, L_band_energy, bands_fx,
- L_qint, eref_fx, is_transient_fx );
+ L_qint, eref_fx, is_transient_fx ); /* Q0 */
/* First pass bit budget for TCQ of spectral band information */
exp_norm = norm_s( gqlevs_fx ); /* gqbits_fx = (short int) log2_f ((float) gqlevs_fx); */
gqbits_fx = sub( 14, exp_norm );
- bit_budget_fx = sub( sub( *num_bits_fx, ebits_fx ), round_fx( L_shl( L_mult( Ngq_fx, gqbits_fx ), 15 ) ) ); /* (*num_bits) - (short) ceil (ebits) - Ngq * gqbits; */
+ bit_budget_fx = sub( sub( *num_bits_fx, ebits_fx ), round_fx( L_shl( L_mult( Ngq_fx, gqbits_fx ), 15 ) ) ); /* (*num_bits) - (short) ceil (ebits) - Ngq * gqbits; Q0*/
pbits_fx = 0;
@@ -409,7 +421,7 @@ void hq_lr_enc_fx(
ELSE
{
/* High band tonality detector based on per band peak-to-average ratio */
- pbits_fx = p2a_threshold_quant_fx( hBstr, L_t_audio, band_start, band_end, band_width, bands_fx, p2a_bands_fx, p2a_th_fx, p2a_flags_fx );
+ pbits_fx = p2a_threshold_quant_fx( hBstr, L_t_audio, band_start, band_end, band_width, bands_fx, p2a_bands_fx, p2a_th_fx, p2a_flags_fx ); /* Q0 */
bit_budget_fx = sub( bit_budget_fx, pbits_fx );
IF( EQ_16( hqswb_clas_fx, HQ_NORMAL ) )
@@ -421,7 +433,7 @@ void hq_lr_enc_fx(
ELSE
{
/* High band tonality detector based on per band peak-to-average ratio */
- pbits_fx = p2a_threshold_quant_fx( hBstr, L_t_audio, band_start, band_end, band_width, bands_fx, p2a_bands_fx, p2a_th_fx, p2a_flags_fx );
+ pbits_fx = p2a_threshold_quant_fx( hBstr, L_t_audio, band_start, band_end, band_width, bands_fx, p2a_bands_fx, p2a_th_fx, p2a_flags_fx ); /* Q0 */
bit_budget_fx = sub( bit_budget_fx, pbits_fx );
}
@@ -434,6 +446,7 @@ void hq_lr_enc_fx(
/* Estimate number of bits per band */
Q_band_energy = SWB_BWE_LR_Qbe;
+ move16();
FOR( i = 0; i < bands_fx; i++ )
{
@@ -442,32 +455,28 @@ 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++ )
{
- L_tmp2 = Ep_fx[i];
- L_tmp = L_max( 1, L_tmp2 );
+ L_tmp2 = Ep_fx[i]; /* Q -6 */
+ L_tmp = L_max( 1, L_tmp2 ); /* Q -6 */
exp = norm_l( L_tmp );
- tmp = extract_h( L_shl( L_tmp, exp ) );
+ tmp = extract_h( L_shl( L_tmp, exp ) ); /* Q -6 + exp - 16 */
- L_tmp3 = (Word32) band_width[i];
+ L_tmp3 = L_deposit_l( band_width[i] ); /* Q0 */
exp2 = norm_l( L_tmp3 );
- tmp2 = extract_h( L_shl( L_tmp3, exp2 ) );
+ tmp2 = extract_h( L_shl( L_tmp3, exp2 ) ); /* exp2 - 16 */
exp2 = sub( exp, exp2 ); /* Denormalize and substract */
tmp3 = sub( tmp2, tmp );
- if ( tmp3 > 0 )
+ IF( tmp3 > 0 )
{
tmp2 = shr( tmp2, 1 );
}
- if ( tmp3 > 0 )
+ IF( tmp3 > 0 )
{
exp2 = add( exp2, 1 );
}
@@ -475,6 +484,7 @@ void hq_lr_enc_fx(
L_tmp = L_deposit_h( tmp );
L_tmp = Isqrt_lc( L_tmp, &exp2 ); /*Q(31-exp2) */
Ep_tmp_fx[i] = L_shr( L_tmp, sub( 15, exp2 ) ); /*Q13 */
+ move32();
}
test();
@@ -491,18 +501,19 @@ void hq_lr_enc_fx(
move16();
bit_budget_fx = sub( bit_budget_fx, trans_bit );
gama_fx = 27852; /*Q15 0.85f;// */
- beta_fx = 17203;
- move16(); /*Q14 1.05f; */
+ beta_fx = 17203; /*Q14 1.05f; */
+ move16();
+ move16();
- set16_fx( &p2a_flags_tmp[sub( bands_fx, trans_bit )], 0, 2 );
+ set16_fx( &p2a_flags_tmp[( bands_fx - trans_bit )], 0, 2 );
IF( EQ_32( st_fx->core_brate, ACELP_13k20 ) )
{
- beta_fx = 13107;
- move16(); /*14 1.25f; */
- gama_fx = 31130;
- move16(); /*0.95f; */
- Copy( &p2a_flags_fx[sub( bands_fx, trans_bit )], &p2a_flags_tmp[sub( bands_fx, trans_bit )], trans_bit );
+ beta_fx = 13107; /*14 1.25f; */
+ move16();
+ gama_fx = 31130; /*0.95f; */
+ move16();
+ Copy( &p2a_flags_fx[( bands_fx - trans_bit )], &p2a_flags_tmp[( bands_fx - trans_bit )], trans_bit ); /* Q0 */
}
/* calculate the the low band/high band energy and the variance/avrage of the envelopes */
Ep_vari_fx = L_deposit_l( 0 );
@@ -513,21 +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 */
-#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
+ move32();
}
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 */
@@ -573,16 +576,18 @@ void hq_lr_enc_fx(
L_tmp2 = L_add( L_tmp, 13107 ); /*15 */
tmp2 = extract_l( L_min( L_max( L_tmp2, 16384 ), gama_fx ) ); /*15 = 15 */
L_band_energy_tmp[i] = Mult_32_16( L_band_energy_tmp[i], tmp2 ); /*Q(Q_band_energy+15-15 = Q_band_energy) */
+ move32();
}
}
}
ELSE
{
j = 0;
- FOR( i = sub( bands_fx, trans_bit ); i < bands_fx; i++ )
+ move16();
+ FOR( i = ( bands_fx - trans_bit ); i < bands_fx; i++ )
{
- alpha_fx = 16384;
- move16(); /*Q14 */
+ alpha_fx = 16384; /*Q14 */
+ move16();
IF( EQ_16( p2a_flags_tmp[i], 1 ) )
{
L_tmp = Mult_32_16( Ep_tmp_fx[i], sub( bands_fx, lowband ) ); /*Q(13+0-15 = -2) */
@@ -602,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 );
@@ -623,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 ); /*14 */
- tmp = extract_l( L_min( L_tmp, 13107 ) ); /*14 */
+ 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-2 */
-#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 );
@@ -655,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 ); /*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 ); /*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
{
@@ -682,17 +671,14 @@ 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 =14 */
- L_tmp = L_max( L_tmp, 13926 ); /*14 */
- tmp2 = extract_l( L_min( L_tmp, 16384 ) ); /*14 */
- alpha_fx = shl( mult( alpha_fx, tmp2 ), 1 ); /*14+14-15+1 =14 */
+ 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();
}
}
lowband = 3;
@@ -704,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 */
@@ -753,7 +731,7 @@ void hq_lr_enc_fx(
L_tmp = Mult_32_16( L_tmp, lowband ); /*Q(exp+2+0-15 = exp-13) */
L_tmp = Mult_32_16( L_tmp, 18842 ); /*Q(exp-13+16-16 = exp-13) */
L_tmp = L_shl( L_tmp, sub( 27, exp ) ); /*Q14 0.5 */
- tmp2 = extract_l( L_min( L_tmp, 19661 ) ); /*14 */
+ tmp2 = extract_l( L_min( L_tmp, 19661 ) ); /*Q14 */
L_tmp = Mult_32_16( L_band_energy_tmp[i], tmp2 ); /*Q(Q_band_energy+14-15 = Q_band_energy-1) */
L_band_energy_tmp[i] = L_shl( L_tmp, 1 ); /*Q_band_energy */
}
@@ -769,14 +747,11 @@ void hq_lr_enc_fx(
}
ELSE IF( is_transient_fx == 0 && EQ_16( inner_frame_fx, L_FRAME16k ) )
{
- bit_budget_fx = sub( bit_budget_fx, 2 ); /* bits in high bands to indicate the last 2 subbands is allocated bits or not */
+ 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 );
-#else /* BASOP_NOGLOB */
- Ep_tmp_fx[i] = L_shl( Ep_tmp_fx[i], 2 );
-#endif /* BASOP_NOGLOB */
+ Ep_tmp_fx[i] = L_shl_o( Ep_tmp_fx[i], 2, &Overflow ); /* Q15 */
+ move32();
}
IF( EQ_32( st_fx->core_brate, ACELP_13k20 ) )
{
@@ -784,8 +759,8 @@ void hq_lr_enc_fx(
move16();
highband = 15;
move16();
- bw_low = sub( band_start[highband], band_start[lowband] );
- bw_high = sub( add( band_end[sub( bands_fx, 1 )], 1 ), band_start[highband] );
+ bw_low = sub( band_start[highband], band_start[lowband] ); /* Q0 */
+ bw_high = sub( add( band_end[( bands_fx - 1 )], 1 ), band_start[highband] ); /* Q0 */
}
ELSE
{
@@ -793,8 +768,8 @@ void hq_lr_enc_fx(
move16();
highband = 16;
move16();
- bw_low = sub( band_start[highband], band_start[lowband] );
- bw_high = sub( add( band_end[sub( bands_fx, 1 )], 1 ), band_start[highband] );
+ bw_low = sub( band_start[highband], band_start[lowband] ); /* Q0 */
+ bw_high = sub( add( band_end[( bands_fx - 1 )], 1 ), band_start[highband] ); /* Q0 */
}
/* calculate the the low band/high band energy and the variance/avrage of the envelopes */
enerL_fx = L_deposit_l( 0 );
@@ -806,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[sub( 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_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_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
}
}
@@ -845,7 +804,7 @@ void hq_lr_enc_fx(
L_tmp = Mult_32_16( L_shl( enerH_fx, i ), shl( bw_low, j ) ); /* i + j -15 */
L_tmp2 = Mult_32_16( L_shl( enerL_fx, i ), shl( bw_high, j ) ); /*i + j -15 */
L_tmp2 = L_sub( L_tmp, L_tmp2 );
- FOR( i = sub( bands_fx, p2a_bands_fx ); i < bands_fx; i++ )
+ FOR( i = ( bands_fx - p2a_bands_fx ); i < bands_fx; i++ )
{
test();
IF( EQ_16( p2a_flags_fx[i], 1 ) || L_tmp2 > 0 )
@@ -853,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 );
@@ -885,8 +840,8 @@ void hq_lr_enc_fx(
}
ELSE
{
- alpha_fx = 16384;
- move16(); /*Q14 */
+ alpha_fx = 16384; /*Q14 */
+ move16();
}
IF( add( sub( i, bands_fx ), p2a_bands_fx ) > 0 )
@@ -895,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 );
@@ -925,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 );
@@ -954,6 +901,7 @@ void hq_lr_enc_fx(
}
L_tmp = Mult_32_16( L_band_energy_tmp[i], alpha_fx ); /*Q(Q_band_energy+14-15=Q_band_energy-1) */
L_band_energy_tmp[i] = L_shl( L_tmp, 1 ); /*Q Q_band_energy */
+ move32();
}
lowband = 6;
move16();
@@ -964,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 */
@@ -1000,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 );
@@ -1025,6 +961,7 @@ void hq_lr_enc_fx(
tmp = extract_l( L_min( L_tmp, 19661 ) ); /*//Q14 */
L_tmp = Mult_32_16( L_band_energy_tmp[i], tmp ); /*Q(Q_band_energy+14-15 = Q_band_energy-1) */
L_band_energy_tmp[i] = L_shl( L_tmp, 1 ); /*Q_band_energy */
+ move32();
}
}
@@ -1054,20 +991,25 @@ void hq_lr_enc_fx(
tcq_core_LR_enc_fx( hBstr, /*st_fx->idchan, */ inp_vector_fx, /*t_audio, */ L_t_audio, /*y2, */ L_y2, bit_budget_fx, bands_fx, band_start, band_end, band_width, /*Rk*/ L_Rk, npulses_fx, k_sort_fx,
p2a_flags_fx, p2a_bands_fx, hHQ_core->last_bitalloc_max_band, inner_frame_fx, adjustFlag, is_transient_fx );
+ test();
+ test();
IF( ( EQ_16( inner_frame_fx, L_FRAME8k ) && LE_32( st_fx->core_brate, ACELP_13k20 ) ) || EQ_16( inner_frame_fx, L_FRAME16k ) )
{
j = 0;
+ move16();
FOR( i = 2; i > 0; i-- )
{
IF( npulses_fx[bands_fx - i] > 0 )
{
- hHQ_core->last_bitalloc_max_band[j] = 1;
+ hHQ_core->last_bitalloc_max_band[j] = 1; /* Q0 */
+ move16();
}
ELSE
{
- hHQ_core->last_bitalloc_max_band[j] = 0;
+ hHQ_core->last_bitalloc_max_band[j] = 0; /* Q0 */
+ move16();
}
- j++;
+ j += 1;
}
}
@@ -1088,7 +1030,7 @@ void hq_lr_enc_fx(
/* Inject noise into components having relatively low pulse energy per band */
ni_seed_fx = add( add( add( npulses_fx[0], npulses_fx[1] ), npulses_fx[2] ), npulses_fx[3] );
- Copy32( L_y2, L_y2_ni, band_end[bands_fx - 1] + 1 );
+ Copy32( L_y2, L_y2_ni, band_end[bands_fx - 1] + 1 ); /* Q12 */
hq2_noise_inject_fx( L_y2_ni, band_start, band_end, band_width, Ep_fx, L_Rk, npulses_fx, ni_seed_fx, bands_fx, 0, bw_low, bw_high, enerL_fx, enerH_fx,
hHQ_core->last_ni_gain_fx, hHQ_core->last_env_fx, &hHQ_core->last_max_pos_pulse, p2a_flags_fx, p2a_bands_fx,
hqswb_clas_fx, st_fx->bwidth, L_bwe_br );
@@ -1121,11 +1063,11 @@ void hq_lr_enc_fx(
}
}
}
- Copy32( L_y2_ni, L_y2, lowlength_fx );
+ Copy32( L_y2_ni, L_y2, lowlength_fx ); /* Q12 */
}
ELSE
{
- Copy32( L_y2_ni, L_y2, add( band_end[bands_fx - 1], 1 ) ); /* HQ_TRANSIENT */
+ Copy32( L_y2_ni, L_y2, add( band_end[bands_fx - 1], 1 ) ); /* HQ_TRANSIENT Q12*/
}
}
@@ -1164,10 +1106,10 @@ void hq_lr_enc_fx(
void hq_lr_enc_ivas_fx(
Encoder_State *st, /* i/o: encoder state structure */
- Word32 L_t_audio[], /* i/o: transform-domain coefs. */
- const Word16 inner_frame, /* i : inner frame length */
- Word16 *num_bits, /* i/o: number of available bits */
- const Word16 is_transient /* i : transient flag */
+ Word32 L_t_audio[], /* i/o: transform-domain coefs. Q12*/
+ const Word16 inner_frame, /* i : inner frame length Q0*/
+ Word16 *num_bits, /* i/o: number of available bits Q0*/
+ const Word16 is_transient /* i : transient flag Q0*/
)
{
Word16 i;
@@ -1238,9 +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;
-#endif /* BASOP_NOGLOB */
+ move32();
BSTR_ENC_HANDLE hBstr = st->hBstr;
HQ_ENC_HANDLE hHQ_core = st->hHQ_core;
@@ -1271,19 +1212,19 @@ void hq_lr_enc_ivas_fx(
{
IF( EQ_16( is_transient, 1 ) )
{
- hqswb_clas = HQ_TRANSIENT;
+ hqswb_clas = HQ_TRANSIENT; /* Q0 */
move16();
}
ELSE
{
- hqswb_clas = peak_avrg_ratio_fx( st->total_brate, L_t_audio, NUMC_N, &hHQ_core->mode_count, &hHQ_core->mode_count1, SWB_BWE_LR_Qs );
+ hqswb_clas = peak_avrg_ratio_fx( st->total_brate, L_t_audio, NUMC_N, &hHQ_core->mode_count, &hHQ_core->mode_count1, SWB_BWE_LR_Qs ); /* Q0 */
}
/* write the classification information into the bitstream */
push_indice( hBstr, IND_HQ2_SWB_CLAS, hqswb_clas, 2 );
( *num_bits ) = sub( *num_bits, 2 );
move16();
- if ( EQ_16( hqswb_clas, HQ_NORMAL ) )
+ IF( EQ_16( hqswb_clas, HQ_NORMAL ) )
{
flag_spt = 1;
move16();
@@ -1305,9 +1246,9 @@ void hq_lr_enc_ivas_fx(
&L_qint, &eref_fx, &bit_alloc_weight_fx, &gqlevs, &Ngq, &p2a_bands, &p2a_th_fx, &pd_thresh_fx, &ld_slope_fx, &ni_coef_fx, bwe_br );
- highlength = band_end[sub( bands, 1 )];
+ highlength = band_end[( bands - 1 )]; /* Q0 */
move16();
- har_bands = bands;
+ har_bands = bands; /* Q0 */
move16();
@@ -1333,11 +1274,11 @@ void hq_lr_enc_ivas_fx(
{
j = 0;
move16();
- FOR( k = sub( bands, SPT_SHORTEN_SBNUM ); k < bands; k++ )
+ FOR( k = ( bands - SPT_SHORTEN_SBNUM ); k < bands; k++ )
{
hHQ_core->prev_SWB_peak_pos[j] = 0;
move16();
- j = add( j, 1 );
+ j += 1;
}
}
}
@@ -1347,10 +1288,10 @@ void hq_lr_enc_ivas_fx(
{
/* If so, collapse transient frame (4 short transforms) to remove uncoded coefficients */
- k1_step_fx = shr( length, 2 ); /* k1 = length/NUM_TIME_SWITCHING_BLOCKS */
- k2_step_fx = shr( inner_frame, 2 ); /* k2 = inner_frame/NUM_TIME_SWITCHING_BLOCKS */
- k1_fx = k1_step_fx;
- k2_fx = k2_step_fx;
+ k1_step_fx = shr( length, 2 ); /* k1 = length/NUM_TIME_SWITCHING_BLOCKS Q0*/
+ k2_step_fx = shr( inner_frame, 2 ); /* k2 = inner_frame/NUM_TIME_SWITCHING_BLOCKS Q0*/
+ k1_fx = k1_step_fx; /* Q0 */
+ k2_fx = k2_step_fx; /* Q0 */
move16();
move16();
FOR( i = 1; i < NUM_TIME_SWITCHING_BLOCKS; i++ )
@@ -1358,7 +1299,7 @@ void hq_lr_enc_ivas_fx(
/*k1 = i*length/NUM_TIME_SWITCHING_BLOCKS; */
/*k2 = i*inner_frame/NUM_TIME_SWITCHING_BLOCKS; */
- Copy32( &L_t_audio[k2_fx], &L_t_audio[k1_fx], k1_step_fx );
+ Copy32( &L_t_audio[k2_fx], &L_t_audio[k1_fx], k1_step_fx ); /* Q12 */
k1_fx = add( k1_fx, k1_step_fx );
k2_fx = add( k2_fx, k2_step_fx );
@@ -1368,13 +1309,13 @@ void hq_lr_enc_ivas_fx(
/* Spectral energy calculation/quantization */
ebits_fx = band_energy_quant_ivas_fx( hBstr, L_t_audio, band_start, band_end, L_band_energy, bands,
- L_qint, eref_fx, is_transient );
+ L_qint, eref_fx, is_transient ); /* Q0 */
/* First pass bit budget for TCQ of spectral band information */
exp_norm = norm_s( gqlevs ); /* gqbits_fx = (short int) log2_f ((float) gqlevs_fx); */
gqbits = sub( 14, exp_norm );
- bit_budget = sub( sub( *num_bits, ebits_fx ), round_fx( L_shl( L_mult( Ngq, gqbits ), 15 ) ) ); /* (*num_bits) - (short) ceil (ebits) - Ngq * gqbits; */
+ bit_budget = sub( sub( *num_bits, ebits_fx ), round_fx( L_shl( L_mult( Ngq, gqbits ), 15 ) ) ); /* (*num_bits) - (short) ceil (ebits) - Ngq * gqbits; Q0*/
pbits = 0;
@@ -1391,7 +1332,7 @@ void hq_lr_enc_ivas_fx(
ELSE
{
/* High band tonality detector based on per band peak-to-average ratio */
- pbits = p2a_threshold_quant_ivas_fx( hBstr, L_t_audio, band_start, band_end, band_width, bands, p2a_bands, p2a_th_fx, p2a_flags );
+ pbits = p2a_threshold_quant_ivas_fx( hBstr, L_t_audio, band_start, band_end, band_width, bands, p2a_bands, p2a_th_fx, p2a_flags ); /* Q0 */
bit_budget = sub( bit_budget, pbits );
IF( EQ_16( hqswb_clas, HQ_NORMAL ) )
@@ -1403,7 +1344,7 @@ void hq_lr_enc_ivas_fx(
ELSE
{
/* High band tonality detector based on per band peak-to-average ratio */
- pbits = p2a_threshold_quant_ivas_fx( hBstr, L_t_audio, band_start, band_end, band_width, bands, p2a_bands, p2a_th_fx, p2a_flags );
+ pbits = p2a_threshold_quant_ivas_fx( hBstr, L_t_audio, band_start, band_end, band_width, bands, p2a_bands, p2a_th_fx, p2a_flags ); /* Q0 */
bit_budget = sub( bit_budget, pbits );
}
@@ -1427,18 +1368,19 @@ void hq_lr_enc_ivas_fx(
L_tmp = Pow2( 30, frac1 );
exp = sub( exp, 30 );
Ep_fx[i] = L_shl( L_tmp, sub( exp, 6 ) ); /* Q -6 */
+ move32();
}
FOR( i = 0; i < bands; i++ )
{
- L_tmp2 = Ep_fx[i];
+ L_tmp2 = Ep_fx[i]; /* Q -6 */
L_tmp = L_max( 1, L_tmp2 );
exp = norm_l( L_tmp );
- tmp = extract_h( L_shl( L_tmp, exp ) );
+ tmp = extract_h( L_shl( L_tmp, exp ) ); /* Q -6 + exp - 16 */
- L_tmp3 = (Word32) band_width[i];
+ L_tmp3 = L_deposit_l( band_width[i] ); /* Q0 */
exp2 = norm_l( L_tmp3 );
- tmp2 = extract_h( L_shl( L_tmp3, exp2 ) );
+ tmp2 = extract_h( L_shl( L_tmp3, exp2 ) ); /* exp2 - 16 */
exp2 = sub( exp, exp2 ); /* Denormalize and substract */
@@ -1451,11 +1393,12 @@ void hq_lr_enc_ivas_fx(
{
exp2 = add( exp2, 1 );
}
- tmp = div_s( tmp2, tmp );
- L_tmp = L_deposit_h( tmp );
- L_tmp = Isqrt_lc1( L_tmp, &exp2 );
- move32(); /*Q(31-exp2) */
- Ep_tmp_fx[i] = L_shr( L_tmp, sub( 15, exp2 ) ); /*Q13 */
+ tmp = div_s( tmp2, tmp ); /* Q15 */
+ L_tmp = L_deposit_h( tmp ); /* Q31 */
+ L_tmp = Isqrt_lc1( L_tmp, &exp2 ); /*Q(31-exp2) */
+ move32();
+ Ep_tmp_fx[i] = L_shr( L_tmp, sub( 15, exp2 ) ); /*Q16 */
+ move32();
}
#undef WMC_TOOL_SKIP
@@ -1473,19 +1416,19 @@ void hq_lr_enc_ivas_fx(
trans_bit = 2;
move16();
bit_budget = sub( bit_budget, trans_bit );
- gama_fx = 27852; /*Q15 0.85f; */
- beta_fx = 17203;
+ gama_fx = 27852; /*Q15 0.85f */
+ beta_fx = 17203; /*Q14 1.05f */
+ move16();
move16();
- move16(); /*Q14 1.05f; */
set_s( &p2a_flags_tmp[bands - trans_bit], 0, 2 );
IF( EQ_32( st->core_brate, ACELP_13k20 ) )
{
- beta_fx = 13107;
- move16(); /*14 1.25f; */
- gama_fx = 31130;
- move16(); /*0.95f; */
- mvs2s( &p2a_flags[sub( bands, trans_bit )], &p2a_flags_tmp[sub( bands, trans_bit )], trans_bit );
+ beta_fx = 13107; /* Q14 1.25f */
+ move16();
+ gama_fx = 31130; /* 0.95f Q15 */
+ move16();
+ mvs2s( &p2a_flags[( bands - trans_bit )], &p2a_flags_tmp[( bands - trans_bit )], trans_bit );
}
/* calculate the the low band/high band energy and the variance/avrage of the envelopes */
@@ -1501,31 +1444,31 @@ void hq_lr_enc_ivas_fx(
{
IF( sub( i, lowband ) >= 0 )
{
- 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 */
+ 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 */
}
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];
- move32(); /*Q15 */
+ Ep_peak_fx = Ep_tmp_fx[i]; /*Q15 */
+ move32();
}
}
}
/* modify the last p2a_bands subbands band_energies */
k = bands;
+ move16();
mvl2l( L_band_energy, L_band_energy_tmp, k ); /*Q_band_energy */
Mpy_32_16_ss( Ep_peak_fx, 24576, &L_tmp, &lo );
Mpy_32_16_ss( Ep_peak_fx, shl( sub( bands, lowband ), 9 ), &L_tmp2, &lo );
Mpy_32_16_ss( Ep_avrg_fx, 1126, &L_tmp3, &lo );
- IF( ( ( L_sub( L_tmp, L_shr( Ep_avrgL_fx, 1 ) ) < 0 && st->core_brate == ACELP_13k20 ) || st->core_brate < ACELP_13k20 ) &&
+ test();
+ test();
+ test();
+ IF( ( ( L_sub( L_tmp, L_shr( Ep_avrgL_fx, 1 ) ) < 0 && EQ_32( st->core_brate, ACELP_13k20 ) ) || LT_32( st->core_brate, ACELP_13k20 ) ) &&
L_sub( L_tmp2, L_tmp3 ) < 0 && L_sub( L_tmp2, L_shr( Ep_avrg_fx, 7 ) ) > 0 )
{
FOR( i = lowband; i < bands; i++ )
@@ -1562,10 +1505,10 @@ void hq_lr_enc_ivas_fx(
{
j = 0;
move16();
- FOR( i = sub( bands, trans_bit ); i < bands; i++ )
+ FOR( i = ( bands - trans_bit ); i < bands; i++ )
{
- alpha_fx = 16384;
- move16(); /*Q14 */
+ alpha_fx = 16384; /*Q14 */
+ move16();
IF( sub( p2a_flags_tmp[i], 1 ) == 0 )
{
Mpy_32_16_ss( Ep_tmp_fx[i], sub( bands, lowband ), &L_tmp, &lo );
@@ -1609,7 +1552,7 @@ void hq_lr_enc_ivas_fx(
L_tmp2 = L_shl( L_tmp2, sub( 13, exp ) ); /*Q(13+exp-15 +13-exp +3 = 14) */
L_tmp = L_min( L_tmp, L_tmp2 ); /*14 */
tmp = extract_l( L_min( L_tmp, 13107 ) ); /*14 */
- alpha_fx = add( 16384, tmp );
+ alpha_fx = add( 16384, tmp ); /* Q14 */
}
IF( sub( hHQ_core->last_bitalloc_max_band[j++], 1 ) == 0 )
{
@@ -1630,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
{
@@ -1669,6 +1605,7 @@ void hq_lr_enc_ivas_fx(
}
Mpy_32_16_ss( L_band_energy_tmp[i], alpha_fx, &L_tmp, &lo );
L_band_energy_tmp[i] = L_shl( L_tmp, 1 ); /*Q(Q_band_energy+14-15 +1= Q_band_energy) */
+ move32();
}
}
lowband = 3;
@@ -1683,24 +1620,23 @@ 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
{
Ep_avrgL_fx = L_add( Ep_avrgL_fx, L_shr( Ep_tmp_fx[i], 1 ) ); /*Q12 */
IF( L_sub( Ep_tmp_fx[i], Ep_peak_fx ) > 0 )
{
- Ep_peak_fx = Ep_tmp_fx[i];
- move32(); /*Q13 */
+ Ep_peak_fx = Ep_tmp_fx[i]; /*Q13 */
+ move32();
}
}
}
Mpy_32_16_ss( Ep_peak_fx, 28262, &L_tmp, &lo );
Mpy_32_16_ss( Ep_avrgL_fx, 24576, &L_tmp2, &lo );
+
+ test();
+ test();
IF( L_sub( L_shr( Ep_avrg_fx, 2 ), L_tmp2 ) > 0 && L_sub( L_shr( Ep_avrg_fx, 4 ), L_tmp2 ) < 0 && L_sub( L_tmp, Ep_avrgL_fx ) > 0 )
{
adjustFlag = 1;
@@ -1726,15 +1662,11 @@ 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();
}
}
#undef WMC_TOOL_SKIP
@@ -1754,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 );
+ 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 ) )
{
@@ -1767,8 +1695,8 @@ void hq_lr_enc_ivas_fx(
move16();
highband = 15;
move16();
- bw_low = sub( band_start[highband], band_start[lowband] );
- bw_high = sub( add( band_end[sub( bands, 1 )], 1 ), band_start[highband] );
+ bw_low = sub( band_start[highband], band_start[lowband] ); /* Q0 */
+ bw_high = sub( add( band_end[( bands - 1 )], 1 ), band_start[highband] ); /* Q0 */
}
ELSE
{
@@ -1776,8 +1704,8 @@ void hq_lr_enc_ivas_fx(
move16();
highband = 16;
move16();
- bw_low = sub( band_start[highband], band_start[lowband] );
- bw_high = sub( add( band_end[sub( bands, 1 )], 1 ), band_start[highband] );
+ bw_low = sub( band_start[highband], band_start[lowband] ); /* Q0 */
+ bw_high = sub( add( band_end[( bands - 1 )], 1 ), band_start[highband] ); /* Q0 */
}
/* calculate the the low band/high band energy and the variance/avrage of the envelopes */
enerL_fx = 0;
@@ -1790,14 +1718,11 @@ void hq_lr_enc_ivas_fx(
move32();
FOR( i = 0; i < bands; i++ )
{
+ test();
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 )
@@ -1811,6 +1736,7 @@ void hq_lr_enc_ivas_fx(
}
/* modify the last p2a_bands subbands band_energies */
k = bands;
+ move16();
mvl2l( L_band_energy, L_band_energy_tmp, k ); /*Q_band_energy */
L_tmp = L_max( enerH_fx, enerL_fx );
@@ -1821,7 +1747,7 @@ void hq_lr_enc_ivas_fx(
Mpy_32_16_ss( L_shl( enerL_fx, i ), shl( bw_high, j ), &L_tmp2, &lo );
L_tmp2 = L_sub( L_tmp, L_tmp2 );
- FOR( i = sub( bands, p2a_bands ); i < bands; i++ )
+ FOR( i = ( bands - p2a_bands ); i < bands; i++ )
{
test();
IF( sub( p2a_flags[i], 1 ) == 0 || L_tmp2 > 0 )
@@ -1829,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 );
@@ -1861,22 +1783,18 @@ void hq_lr_enc_ivas_fx(
}
ELSE
{
- alpha_fx = 16384;
- move16(); /*Q14 */
+ alpha_fx = 16384; /* Q14 */
+ move16();
}
IF( add( sub( i, bands ), p2a_bands ) > 0 )
{
tmp = sub( bands, p2a_bands );
- IF( sub( hHQ_core->last_bitalloc_max_band[sub( i, add( tmp, 1 ) )], 1 ) == 0 )
+ IF( sub( hHQ_core->last_bitalloc_max_band[( i - ( tmp + 1 ) )], 1 ) == 0 )
{
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 );
@@ -1901,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 );
@@ -1930,6 +1844,7 @@ void hq_lr_enc_ivas_fx(
}
Mpy_32_16_ss( L_band_energy_tmp[i], alpha_fx, &L_tmp, &lo );
L_band_energy_tmp[i] = L_shl( L_tmp, 1 ); /*Q Q_band_energy */
+ move32();
}
lowband = 6;
move16();
@@ -1943,23 +1858,15 @@ 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];
- move32(); /*Q15 */
+ Ep_peak_fx = Ep_tmp_fx[i]; /* Q15 */
+ move32();
}
}
}
@@ -1980,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 );
@@ -2005,6 +1908,7 @@ void hq_lr_enc_ivas_fx(
tmp = extract_l( L_min( L_tmp, 19661 ) ); /*Q14 */
Mpy_32_16_ss( L_band_energy_tmp[i], tmp, &L_tmp, &lo );
L_band_energy_tmp[i] = L_shl( L_tmp, 1 ); /*Q_band_energy */
+ move32();
}
}
#undef WMC_TOOL_SKIP
@@ -2065,9 +1969,9 @@ void hq_lr_enc_ivas_fx(
}
/* Inject noise into components having relatively low pulse energy per band */
- ni_seed = add( add( add( npulses[0], npulses[1] ), npulses[2] ), npulses[3] );
+ ni_seed = add( add( add( npulses[0], npulses[1] ), npulses[2] ), npulses[3] ); /* Q0 */
- Copy32( L_y2, L_y2_ni, band_end[bands - 1] + 1 );
+ Copy32( L_y2, L_y2_ni, band_end[bands - 1] + 1 ); /* Q12 */
test();
test();
IF( EQ_16( st->bwidth, SWB ) && ( EQ_32( bwe_br, HQ_16k40 ) || EQ_32( bwe_br, HQ_13k20 ) ) )
@@ -2096,16 +2000,16 @@ void hq_lr_enc_ivas_fx(
}
}
}
- Copy32( L_y2_ni, L_y2, lowlength );
+ Copy32( L_y2_ni, L_y2, lowlength ); /* Q12 */
}
ELSE
{
- Copy32( L_y2_ni, L_y2, band_end[bands - 1] + 1 ); /* HQ_TRANSIENT */
+ Copy32( L_y2_ni, L_y2, band_end[bands - 1] + 1 ); /* HQ_TRANSIENT Q12*/
}
}
ELSE
{
- Copy32( L_y2_ni, L_y2, band_end[bands - 1] + 1 ); /* NB, WB */
+ Copy32( L_y2_ni, L_y2, band_end[bands - 1] + 1 ); /* NB, WB Q12*/
}
updat_prev_frm_fx( L_y2, L_t_audio, bwe_br, length, inner_frame, bands, st->bwidth, is_transient, hqswb_clas, &hHQ_core->prev_hqswb_clas, hHQ_core->prev_SWB_peak_pos, prev_SWB_peak_pos_tmp, &hHQ_core->prev_frm_hfe2, &hHQ_core->prev_stab_hfe2, bws_cnt );
@@ -2152,18 +2056,18 @@ void hq_lr_enc_ivas_fx(
static Word16 small_symbol_enc_tran_fx( /* o : bits */
BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream */
- const Word16 *qbidx, /* i : input of dequantized differential energy */
- const Word16 BANDS, /* i : number of bands */
- Word16 *hLCmode, /* i/o: LC mode info */
- const Word16 flag_pack, /* i : indicator of packing or estimating bits */
- const Word16 is_transient )
+ const Word16 *qbidx, /* i : input of dequantized differential energy Q0*/
+ const Word16 BANDS, /* i : number of bands Q0*/
+ Word16 *hLCmode, /* i/o: LC mode info Q0*/
+ const Word16 flag_pack, /* i : indicator of packing or estimating bits Q0*/
+ const Word16 is_transient /* Q0 */ )
{
Word16 i, bits;
Word16 difidx[BANDS_MAX];
FOR( i = 0; i < BANDS; i++ )
{
- difidx[i] = add( qbidx[i], LRMDCT_BE_OFFSET );
+ difidx[i] = add( qbidx[i], LRMDCT_BE_OFFSET ); /* Q0 */
move16();
}
@@ -2181,8 +2085,8 @@ static Word16 small_symbol_enc_tran_fx( /* o : bits
IF( flag_pack == 0 )
{
/* estimating # of bits */
- bits = encode_envelope_indices_fx( hBstr, BANDS, -1, difidx, hLCmode, flag_pack, LOW_RATE_HQ_CORE_TRAN, is_transient );
- bits = add( bits, BITS_DE_FCOMP ); /* xx bits for diff. energies + BITS_DE_FCOMP bits for first energies */
+ bits = encode_envelope_indices_fx( hBstr, BANDS, -1, difidx, hLCmode, flag_pack, LOW_RATE_HQ_CORE_TRAN, is_transient ); /* Q0 */
+ bits = add( bits, BITS_DE_FCOMP ); /* xx bits for diff. energies + BITS_DE_FCOMP bits for first energies */
}
ELSE
{
@@ -2191,24 +2095,24 @@ static Word16 small_symbol_enc_tran_fx( /* o : bits
encode_envelope_indices_fx( hBstr, BANDS, -1, difidx, hLCmode, flag_pack, LOW_RATE_HQ_CORE_TRAN, is_transient );
}
- return add( bits, BITS_DE_HMODE ); /* xx bits for diff. energies + 1 bit for LC coding mode */
+ return add( bits, BITS_DE_HMODE ); /* xx bits for diff. energies + 1 bit for LC coding mode Q0*/
}
static Word16 small_symbol_enc_tran_ivas_fx( /* o : bits */
BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream */
- const Word16 *qbidx, /* i : input of dequantized differential energy */
- const Word16 BANDS, /* i : number of bands */
- Word16 *hLCmode, /* i/o: LC mode info */
- const Word16 flag_pack, /* i : indicator of packing or estimating bits */
- const Word16 is_transient )
+ const Word16 *qbidx, /* i : input of dequantized differential energy Q0*/
+ const Word16 BANDS, /* i : number of bands Q0*/
+ Word16 *hLCmode, /* i/o: LC mode info Q0*/
+ const Word16 flag_pack, /* i : indicator of packing or estimating bits Q0*/
+ const Word16 is_transient /* Q0 */ )
{
Word16 i, bits;
Word16 difidx[BANDS_MAX];
FOR( i = 0; i < BANDS; i++ )
{
- difidx[i] = add( qbidx[i], LRMDCT_BE_OFFSET );
+ difidx[i] = add( qbidx[i], LRMDCT_BE_OFFSET ); /* Q0 */
move16();
}
@@ -2226,8 +2130,8 @@ static Word16 small_symbol_enc_tran_ivas_fx( /* o : bit
IF( flag_pack == 0 )
{
/* estimating # of bits */
- bits = encode_envelope_indices_ivas_fx( hBstr, BANDS, -1, difidx, hLCmode, flag_pack, LOW_RATE_HQ_CORE_TRAN, is_transient );
- bits = add( bits, BITS_DE_FCOMP ); /* xx bits for diff. energies + BITS_DE_FCOMP bits for first energies */
+ bits = encode_envelope_indices_ivas_fx( hBstr, BANDS, -1, difidx, hLCmode, flag_pack, LOW_RATE_HQ_CORE_TRAN, is_transient ); /* Q0 */
+ bits = add( bits, BITS_DE_FCOMP ); /* xx bits for diff. energies + BITS_DE_FCOMP bits for first energies */
}
ELSE
{
@@ -2236,7 +2140,7 @@ static Word16 small_symbol_enc_tran_ivas_fx( /* o : bit
encode_envelope_indices_ivas_fx( hBstr, BANDS, -1, difidx, hLCmode, flag_pack, LOW_RATE_HQ_CORE_TRAN, is_transient );
}
- return add( bits, BITS_DE_HMODE ); /* xx bits for diff. energies + 1 bit for LC coding mode */
+ return add( bits, BITS_DE_HMODE ); /* xx bits for diff. energies + 1 bit for LC coding mode Q0*/
}
@@ -2250,23 +2154,23 @@ static Word16 small_symbol_enc_tran_ivas_fx( /* o : bit
static Word16 small_symbol_enc_fx( /* o : bits */
BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream */
- const Word16 *qbidx, /* i : input of dequantized differential energy */
- const Word16 BANDS, /* i : number of bands */
- Word16 *hLCmode, /* i/o: LC mode info */
- const Word16 flag_pack /* i : indicator of packing or estimating bits */
+ const Word16 *qbidx, /* i : input of dequantized differential energy Q0*/
+ const Word16 BANDS, /* i : number of bands Q0*/
+ Word16 *hLCmode, /* i/o: LC mode info Q0*/
+ const Word16 flag_pack /* i : indicator of packing or estimating bits Q0*/
,
- const Word16 is_transient )
+ const Word16 is_transient /* Q0 */ )
{
Word16 i, bits;
Word16 difidx[BANDS_MAX], LSB[BANDS_MAX];
/* Preparing lossless coding input */
- difidx[0] = add( qbidx[0], DE_OFFSET0 );
+ difidx[0] = add( qbidx[0], DE_OFFSET0 ); /* Q0 */
move16();
FOR( i = 1; i < BANDS; ++i )
{
- difidx[i] = add( qbidx[i], DE_OFFSET1 );
+ difidx[i] = add( qbidx[i], DE_OFFSET1 ); /* Q0 */
move16();
}
@@ -2283,9 +2187,9 @@ static Word16 small_symbol_enc_fx( /* o : bits
/* splitting MSB and LSB */
FOR( i = 0; i < BANDS; ++i )
{
- LSB[i] = s_and( difidx[i], 1 );
+ LSB[i] = s_and( difidx[i], 1 ); /* Q0 */
move16();
- difidx[i] = shr( difidx[i], 1 );
+ difidx[i] = shr( difidx[i], 1 ); /* Q0 */
move16();
}
@@ -2294,11 +2198,11 @@ static Word16 small_symbol_enc_fx( /* o : bits
{
/* estimating # of bits */
/* Encoding MSB bits */
- bits = encode_envelope_indices_fx( hBstr, BANDS, -1, difidx, hLCmode, flag_pack, LOW_RATE_HQ_CORE, is_transient );
- bits = add( bits, BITS_DE_FCOMP ); /* xx bits for diff. energies + BITS_DE_FCOMP bits for first energies */
+ bits = encode_envelope_indices_fx( hBstr, BANDS, -1, difidx, hLCmode, flag_pack, LOW_RATE_HQ_CORE, is_transient ); /* Q0 */
+ bits = add( bits, BITS_DE_FCOMP ); /* xx bits for diff. energies + BITS_DE_FCOMP bits for first energies */
/* Encoding LSB bit packing */
- bits = add( bits, BANDS );
+ bits = add( bits, BANDS ); /* Q0 */
}
ELSE
{
@@ -2314,27 +2218,27 @@ static Word16 small_symbol_enc_fx( /* o : bits
}
}
- return add( bits, BITS_DE_HMODE ); /* xx bits for diff. energies + 1 bit for LC coding mode */
+ return add( bits, BITS_DE_HMODE ); /* xx bits for diff. energies + 1 bit for LC coding mode Q0*/
}
static Word16 small_symbol_enc_ivas_fx(
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const Word16 *qbidx, /* i : input of dequantized differential energy */
- const Word16 BANDS, /* i : number of bands */
- Word16 *hLCmode, /* i/o: LC mode info */
- const Word16 flag_pack, /* i : indicator of packing or estimating bits */
- const Word16 is_transient )
+ const Word16 *qbidx, /* i : input of dequantized differential energy Q0*/
+ const Word16 BANDS, /* i : number of bands Q0*/
+ Word16 *hLCmode, /* i/o: LC mode info Q0*/
+ const Word16 flag_pack, /* i : indicator of packing or estimating bits Q0*/
+ const Word16 is_transient /* Q0 */ )
{
Word16 i, bits;
Word16 difidx[BANDS_MAX], LSB[BANDS_MAX];
/* Preparing lossless coding input */
- difidx[0] = add( qbidx[0], DE_OFFSET0 );
+ difidx[0] = add( qbidx[0], DE_OFFSET0 ); /* Q0 */
move16();
FOR( i = 1; i < BANDS; ++i )
{
- difidx[i] = add( qbidx[i], DE_OFFSET1 );
+ difidx[i] = add( qbidx[i], DE_OFFSET1 ); /* Q0 */
move16();
}
@@ -2351,9 +2255,9 @@ static Word16 small_symbol_enc_ivas_fx(
/* splitting MSB and LSB */
FOR( i = 0; i < BANDS; ++i )
{
- LSB[i] = s_and( difidx[i], 1 );
+ LSB[i] = s_and( difidx[i], 1 ); /* Q0 */
move16();
- difidx[i] = shr( difidx[i], 1 );
+ difidx[i] = shr( difidx[i], 1 ); /* Q0 */
move16();
}
@@ -2362,11 +2266,11 @@ static Word16 small_symbol_enc_ivas_fx(
{
/* estimating # of bits */
/* Encoding MSB bits */
- bits = encode_envelope_indices_ivas_fx( hBstr, BANDS, -1, difidx, hLCmode, flag_pack, LOW_RATE_HQ_CORE, is_transient );
- bits = add( bits, BITS_DE_FCOMP ); /* xx bits for diff. energies + BITS_DE_FCOMP bits for first energies */
+ bits = encode_envelope_indices_ivas_fx( hBstr, BANDS, -1, difidx, hLCmode, flag_pack, LOW_RATE_HQ_CORE, is_transient ); /* Q0 */
+ bits = add( bits, BITS_DE_FCOMP ); /* xx bits for diff. energies + BITS_DE_FCOMP bits for first energies Q0*/
/* Encoding LSB bit packing */
- bits = add( bits, BANDS );
+ bits = add( bits, BANDS ); /* Q0 */
}
ELSE
{
@@ -2382,16 +2286,16 @@ static Word16 small_symbol_enc_ivas_fx(
}
}
- return add( bits, BITS_DE_HMODE ); /* xx bits for diff. energies + 1 bit for LC coding mode */
+ return add( bits, BITS_DE_HMODE ); /* xx bits for diff. energies + 1 bit for LC coding mode Q0*/
}
-static Word16 large_symbol_enc_fx( /* o : bits */
+static Word16 large_symbol_enc_fx( /* o : bits Q0*/
BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream */
- Word16 *qbidx, /* i : input of dequantized differential energy */
- const Word16 BANDS, /* i : number of bands */
- Word16 *hLCmode0, /* i/o: LC mode info */
- const Word16 flag_pack /* i : indicator of packing or estimating bits */
+ Word16 *qbidx, /* i : input of dequantized differential energy Q0*/
+ const Word16 BANDS, /* i : number of bands Q0*/
+ Word16 *hLCmode0, /* i/o: LC mode info Q0*/
+ const Word16 flag_pack /* i : indicator of packing or estimating bits Q0*/
)
{
Word16 i, bits, tmp;
@@ -2404,7 +2308,7 @@ static Word16 large_symbol_enc_fx( /* o : bits
Word16 lsbdepth1;
Word16 cnt_outlyer, pos_outlyer, cnt_outlyer0;
- min_q = 513;
+ min_q = 513; /* Q0 */
move16();
max_q = -1;
move16();
@@ -2453,15 +2357,15 @@ static Word16 large_symbol_enc_fx( /* o : bits
test();
IF( GT_16( qbidx[i], 3 ) || LT_16( qbidx[i], -4 ) )
{
- cnt_outlyer = add( cnt_outlyer, 1 );
+ cnt_outlyer = add( cnt_outlyer, 1 ); /* Q0 */
pos_outlyer = i;
move16();
}
test();
- if ( GT_16( qbidx[i], sub( ABS_ENG_OFFSET, 1 ) ) || LT_16( qbidx[i], -ABS_ENG_OFFSET ) )
+ IF( GT_16( qbidx[i], ( ABS_ENG_OFFSET - 1 ) ) || LT_16( qbidx[i], -ABS_ENG_OFFSET ) )
{
- cnt_outlyer = add( cnt_outlyer, 1 );
+ cnt_outlyer = add( cnt_outlyer, 1 ); /* Q0 */
}
}
@@ -2469,37 +2373,39 @@ static Word16 large_symbol_enc_fx( /* o : bits
test();
IF( cnt_outlyer0 == 0 && LE_16( cnt_outlyer, 1 ) )
{
- bitsmode0 = add( add( BITS_DE_8SMODE, BITS_DE_8SMODE_N0 ), BITS_DE_8SMODE_N1 );
+ bitsmode0 = ( BITS_DE_8SMODE + BITS_DE_8SMODE_N0 ) + BITS_DE_8SMODE_N1; /* Q0 */
+ move16();
IF( EQ_16( cnt_outlyer, 1 ) )
{
/* 01 */
- bitsmode0 = add( bitsmode0, add( BITS_DE_8SPOS, BITS_ABS_ENG ) );
+ bitsmode0 = add( bitsmode0, ( BITS_DE_8SPOS + BITS_ABS_ENG ) ); /* Q0 */
}
FOR( i = 0; i < pos_outlyer; ++i )
{
- tdifidx0[i] = qbidx[i];
+ tdifidx0[i] = qbidx[i]; /* Q0 */
move16();
- bitsmode0 = add( bitsmode0, hessize[tdifidx0[i] + 4] );
+ bitsmode0 = add( bitsmode0, hessize[tdifidx0[i] + 4] ); /* Q0 */
}
FOR( i = add( pos_outlyer, 1 ); i < BANDS; ++i )
{
- tdifidx0[i] = qbidx[i];
+ tdifidx0[i] = qbidx[i]; /* Q0 */
move16();
- bitsmode0 = add( bitsmode0, hessize[tdifidx0[i] + 4] );
+ bitsmode0 = add( bitsmode0, hessize[tdifidx0[i] + 4] ); /* Q0 */
}
}
ELSE IF( EQ_16( cnt_outlyer0, 1 ) && LE_16( cnt_outlyer, 1 ) )
{
- bitsmode0 = add( add( BITS_DE_8SMODE, BITS_DE_8SMODE_N0 ), BITS_DE_8SMODE_N1 );
- tdifidx0[0] = qbidx[0];
+ bitsmode0 = ( BITS_DE_8SMODE + BITS_DE_8SMODE_N0 ) + BITS_DE_8SMODE_N1; /* Q0 */
+ move16();
+ tdifidx0[0] = qbidx[0]; /* Q0 */
move16();
bitsmode0 = add( bitsmode0, BITS_ABS_ENG );
IF( EQ_16( cnt_outlyer, 1 ) )
{
/* 11 */
- bitsmode0 = add( bitsmode0, add( BITS_DE_8SPOS, BITS_ABS_ENG ) );
+ bitsmode0 = add( bitsmode0, ( BITS_DE_8SPOS + BITS_ABS_ENG ) ); /* Q0 */
}
ELSE
{
@@ -2509,16 +2415,16 @@ static Word16 large_symbol_enc_fx( /* o : bits
FOR( i = 1; i < pos_outlyer; ++i )
{
- tdifidx0[i] = qbidx[i];
+ tdifidx0[i] = qbidx[i]; /* Q0 */
move16();
- bitsmode0 = add( bitsmode0, hessize[tdifidx0[i] + 4] );
+ bitsmode0 = add( bitsmode0, hessize[tdifidx0[i] + 4] ); /* Q0 */
}
FOR( i = add( pos_outlyer, 1 ); i < BANDS; ++i )
{
- tdifidx0[i] = qbidx[i];
+ tdifidx0[i] = qbidx[i]; /* Q0 */
move16();
- bitsmode0 = add( bitsmode0, hessize[tdifidx0[i] + 4] );
+ bitsmode0 = add( bitsmode0, hessize[tdifidx0[i] + 4] ); /* Q0 */
}
}
ELSE
@@ -2555,9 +2461,9 @@ static Word16 large_symbol_enc_fx( /* o : bits
basic_shift = i;
move16();
- min_bits = 1000;
+ min_bits = 1000; /* Q0 */
move16();
- min_bits_pos = basic_shift;
+ min_bits_pos = basic_shift; /* Q0 */
move16();
tmp = add( basic_shift, 3 );
FOR( offset0 = basic_shift; offset0 < tmp; offset0++ )
@@ -2567,17 +2473,17 @@ static Word16 large_symbol_enc_fx( /* o : bits
min_q = MAXIMUM_ENERGY_LOWBRATE;
move16();
- bitsmode1 = add( BITS_DE_8SMODE, BITS_MAX_DEPTH );
+ bitsmode1 = add( BITS_DE_8SMODE, BITS_MAX_DEPTH ); /* Q0 */
FOR( i = 0; i < BANDS; ++i )
{
- bitsmode1 = add( bitsmode1, add( hessize[add( shr( qbidx[i], offset0 ), 4 )], offset0 ) );
+ bitsmode1 = add( bitsmode1, add( hessize[( ( qbidx[i] >> offset0 ) + 4 )], offset0 ) );
}
IF( GT_16( min_bits, bitsmode1 ) )
{
- min_bits_pos = offset0;
+ min_bits_pos = offset0; /* Q0 */
move16();
- min_bits = bitsmode1;
+ min_bits = bitsmode1; /* Q0 */
move16();
}
}
@@ -2591,6 +2497,8 @@ static Word16 large_symbol_enc_fx( /* o : bits
{
LSB1[i] = s_and( qbidx[i], sub( shl( 1, lsbdepth1 ), 1 ) );
tdifidx1[i] = shr( qbidx[i], lsbdepth1 );
+ move16();
+ move16();
}
}
@@ -2601,14 +2509,14 @@ static Word16 large_symbol_enc_fx( /* o : bits
/* Encoding MSB bits */
IF( LT_16( bitsmode0, bitsmode1 ) )
{
- bits = bitsmode0;
+ bits = bitsmode0; /* Q0 */
move16();
*hLCmode0 = 0;
move16();
}
ELSE
{
- bits = bitsmode1;
+ bits = bitsmode1; /* Q0 */
move16();
*hLCmode0 = 1;
move16();
@@ -2630,7 +2538,7 @@ static Word16 large_symbol_enc_fx( /* o : bits
{
/* 01 */
push_indice_fx( hBstr, IND_HQ2_DENG_8SMODE_N1, 1, BITS_DE_8SMODE_N1 );
- bits = add( bits, BITS_DE_8SMODE_N1 );
+ bits = add( bits, BITS_DE_8SMODE_N1 ); /* Q0 */
push_indice_fx( hBstr, IND_HQ2_DENG_8SPOS, pos_outlyer, BITS_DE_8SPOS );
bits = add( bits, BITS_DE_8SPOS );
push_indice_fx( hBstr, IND_HQ2_DIFF_ENERGY, qbidx[pos_outlyer] + ABS_ENG_OFFSET, BITS_ABS_ENG );
@@ -2640,19 +2548,19 @@ static Word16 large_symbol_enc_fx( /* o : bits
{
/* 00 */
push_indice_fx( hBstr, IND_HQ2_DENG_8SMODE_N1, 0, BITS_DE_8SMODE_N1 );
- bits = add( bits, BITS_DE_8SMODE_N1 );
+ bits = add( bits, BITS_DE_8SMODE_N1 ); /* Q0 */
}
FOR( i = 0; i < pos_outlyer; ++i )
{
push_indice_fx( hBstr, IND_HQ2_DIFF_ENERGY, hescode[tdifidx0[i] + 4], hessize[tdifidx0[i] + 4] );
- bitsmode0 = add( bitsmode0, hessize[tdifidx0[i] + 4] );
+ bitsmode0 = add( bitsmode0, hessize[tdifidx0[i] + 4] ); /* Q0 */
}
- FOR( i = add( pos_outlyer, 1 ); i < BANDS; ++i )
+ FOR( i = ( pos_outlyer + 1 ); i < BANDS; ++i )
{
push_indice_fx( hBstr, IND_HQ2_DIFF_ENERGY, hescode[tdifidx0[i] + 4], hessize[tdifidx0[i] + 4] );
- bitsmode0 = add( bitsmode0, hessize[tdifidx0[i] + 4] );
+ bitsmode0 = add( bitsmode0, hessize[tdifidx0[i] + 4] ); /* Q0 */
}
}
ELSE IF( EQ_16( cnt_outlyer0, 1 ) )
@@ -2662,7 +2570,7 @@ static Word16 large_symbol_enc_fx( /* o : bits
IF( EQ_16( cnt_outlyer, 1 ) )
{
push_indice_fx( hBstr, IND_HQ2_DENG_8SMODE_N1, 1, BITS_DE_8SMODE_N1 );
- bits = add( bits, BITS_DE_8SMODE_N1 );
+ bits = add( bits, BITS_DE_8SMODE_N1 ); /* Q0 */
push_indice_fx( hBstr, IND_HQ2_DENG_8SPOS, pos_outlyer, BITS_DE_8SPOS );
bits = add( bits, BITS_DE_8SPOS );
push_indice_fx( hBstr, IND_HQ2_DIFF_ENERGY, qbidx[0] + ABS_ENG_OFFSET, BITS_ABS_ENG );
@@ -2673,34 +2581,34 @@ static Word16 large_symbol_enc_fx( /* o : bits
ELSE
{
push_indice_fx( hBstr, IND_HQ2_DENG_8SMODE_N1, 0, BITS_DE_8SMODE_N1 );
- bits = add( bits, BITS_DE_8SMODE_N1 );
+ bits = add( bits, BITS_DE_8SMODE_N1 ); /* Q0 */
push_indice_fx( hBstr, IND_HQ2_DIFF_ENERGY, qbidx[0] + ABS_ENG_OFFSET, BITS_ABS_ENG );
- bits = add( bits, BITS_ABS_ENG );
+ bits = add( bits, BITS_ABS_ENG ); /* Q0 */
}
FOR( i = 1; i < pos_outlyer; ++i )
{
push_indice_fx( hBstr, IND_HQ2_DIFF_ENERGY, hescode[tdifidx0[i] + 4], hessize[tdifidx0[i] + 4] );
- bits = add( bits, hessize[tdifidx0[i] + 4] );
+ bits = add( bits, hessize[tdifidx0[i] + 4] ); /* Q0 */
}
FOR( i = pos_outlyer + 1; i < BANDS; ++i )
{
push_indice_fx( hBstr, IND_HQ2_DIFF_ENERGY, hescode[tdifidx0[i] + 4], hessize[tdifidx0[i] + 4] );
- bits = add( bits, hessize[tdifidx0[i] + 4] );
+ bits = add( bits, hessize[tdifidx0[i] + 4] ); /* Q0 */
}
}
}
ELSE
{
- bits = add( BITS_DE_8SMODE, BITS_MAX_DEPTH );
+ bits = add( BITS_DE_8SMODE, BITS_MAX_DEPTH ); /* Q0 */
push_indice_fx( hBstr, IND_HQ2_DENG_8SMODE, 1, BITS_DE_8SMODE );
push_indice_fx( hBstr, IND_HQ2_DENG_8SDEPTH, lsbdepth1, BITS_MAX_DEPTH );
FOR( i = 0; i < BANDS; ++i )
{
push_indice_fx( hBstr, IND_HQ2_DIFF_ENERGY, hescode[tdifidx1[i] + 4], hessize[tdifidx1[i] + 4] );
- bits = add( bits, hessize[tdifidx1[i] + 4] );
+ bits = add( bits, hessize[tdifidx1[i] + 4] ); /* Q0 */
}
IF( lsbdepth1 > 0 )
@@ -2710,21 +2618,21 @@ static Word16 large_symbol_enc_fx( /* o : bits
push_indice_fx( hBstr, IND_HQ2_DIFF_ENERGY, LSB1[i], lsbdepth1 );
}
/*bits += BANDS * lsbdepth1; */
- bits = add( bits, extract_h( L_shl( L_mult( BANDS, lsbdepth1 ), 15 ) ) );
+ bits = add( bits, extract_h( L_shl( L_mult( BANDS, lsbdepth1 ), 15 ) ) ); /* Q0 */
}
}
}
- return bits; /* xx bits for diff. energies + 1 bit for LC coding mode */
+ return bits; /* xx bits for diff. energies + 1 bit for LC coding mode Q0*/
}
static Word16 large_symbol_enc_ivas_fx(
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- Word16 *qbidx, /* i : input of dequantized differential energy */
- const Word16 BANDS, /* i : number of bands */
- Word16 *hLCmode0, /* i/o: LC mode info */
- const Word16 flag_pack /* i : indicator of packing or estimating bits */
+ Word16 *qbidx, /* i : input of dequantized differential energy Q0*/
+ const Word16 BANDS, /* i : number of bands Q0*/
+ Word16 *hLCmode0, /* i/o: LC mode info Q0*/
+ const Word16 flag_pack /* i : indicator of packing or estimating bits Q0*/
)
{
Word16 i, bits, tmp;
@@ -2737,7 +2645,7 @@ static Word16 large_symbol_enc_ivas_fx(
Word16 lsbdepth1;
Word16 cnt_outlyer, pos_outlyer, cnt_outlyer0;
- min_q = 513;
+ min_q = 513; /* Q0 */
move16();
max_q = -1;
move16();
@@ -2786,15 +2694,15 @@ static Word16 large_symbol_enc_ivas_fx(
test();
IF( GT_16( qbidx[i], 3 ) || LT_16( qbidx[i], -4 ) )
{
- cnt_outlyer = add( cnt_outlyer, 1 );
+ cnt_outlyer = add( cnt_outlyer, 1 ); /* Q0 */
pos_outlyer = i;
move16();
}
test();
- if ( GT_16( qbidx[i], sub( ABS_ENG_OFFSET, 1 ) ) || LT_16( qbidx[i], -ABS_ENG_OFFSET ) )
+ IF( GT_16( qbidx[i], ( ABS_ENG_OFFSET - 1 ) ) || LT_16( qbidx[i], -ABS_ENG_OFFSET ) )
{
- cnt_outlyer = add( cnt_outlyer, 1 );
+ cnt_outlyer = add( cnt_outlyer, 1 ); /* Q0 */
}
}
@@ -2802,37 +2710,39 @@ static Word16 large_symbol_enc_ivas_fx(
test();
IF( cnt_outlyer0 == 0 && LE_16( cnt_outlyer, 1 ) )
{
- bitsmode0 = add( add( BITS_DE_8SMODE, BITS_DE_8SMODE_N0 ), BITS_DE_8SMODE_N1 );
+ bitsmode0 = ( BITS_DE_8SMODE + BITS_DE_8SMODE_N0 ) + BITS_DE_8SMODE_N1; /* Q0 */
+ move16();
IF( EQ_16( cnt_outlyer, 1 ) )
{
/* 01 */
- bitsmode0 = add( bitsmode0, add( BITS_DE_8SPOS, BITS_ABS_ENG ) );
+ bitsmode0 = add( bitsmode0, add( BITS_DE_8SPOS, BITS_ABS_ENG ) ); /* Q0 */
}
FOR( i = 0; i < pos_outlyer; ++i )
{
- tdifidx0[i] = qbidx[i];
+ tdifidx0[i] = qbidx[i]; /* Q0 */
move16();
- bitsmode0 = add( bitsmode0, hessize[tdifidx0[i] + 4] );
+ bitsmode0 = add( bitsmode0, hessize[tdifidx0[i] + 4] ); /* Q0 */
}
- FOR( i = add( pos_outlyer, 1 ); i < BANDS; ++i )
+ FOR( i = ( pos_outlyer + 1 ); i < BANDS; ++i )
{
- tdifidx0[i] = qbidx[i];
+ tdifidx0[i] = qbidx[i]; /* Q0 */
move16();
- bitsmode0 = add( bitsmode0, hessize[tdifidx0[i] + 4] );
+ bitsmode0 = add( bitsmode0, hessize[tdifidx0[i] + 4] ); /* Q0 */
}
}
ELSE IF( EQ_16( cnt_outlyer0, 1 ) && LE_16( cnt_outlyer, 1 ) )
{
- bitsmode0 = add( add( BITS_DE_8SMODE, BITS_DE_8SMODE_N0 ), BITS_DE_8SMODE_N1 );
- tdifidx0[0] = qbidx[0];
+ bitsmode0 = ( BITS_DE_8SMODE + BITS_DE_8SMODE_N0 ) + BITS_DE_8SMODE_N1; /* Q0 */
move16();
- bitsmode0 = add( bitsmode0, BITS_ABS_ENG );
+ tdifidx0[0] = qbidx[0]; /* Q0 */
+ move16();
+ bitsmode0 = add( bitsmode0, BITS_ABS_ENG ); /* Q0 */
IF( EQ_16( cnt_outlyer, 1 ) )
{
/* 11 */
- bitsmode0 = add( bitsmode0, add( BITS_DE_8SPOS, BITS_ABS_ENG ) );
+ bitsmode0 = add( bitsmode0, ( BITS_DE_8SPOS + BITS_ABS_ENG ) ); /* Q0 */
}
ELSE
{
@@ -2842,27 +2752,27 @@ static Word16 large_symbol_enc_ivas_fx(
FOR( i = 1; i < pos_outlyer; ++i )
{
- tdifidx0[i] = qbidx[i];
+ tdifidx0[i] = qbidx[i]; /* Q0 */
move16();
- bitsmode0 = add( bitsmode0, hessize[tdifidx0[i] + 4] );
+ bitsmode0 = add( bitsmode0, hessize[tdifidx0[i] + 4] ); /* Q0 */
}
- FOR( i = add( pos_outlyer, 1 ); i < BANDS; ++i )
+ FOR( i = ( pos_outlyer + 1 ); i < BANDS; ++i )
{
- tdifidx0[i] = qbidx[i];
+ tdifidx0[i] = qbidx[i]; /* Q0 */
move16();
- bitsmode0 = add( bitsmode0, hessize[tdifidx0[i] + 4] );
+ bitsmode0 = add( bitsmode0, hessize[tdifidx0[i] + 4] ); /* Q0 */
}
}
ELSE
{
- bitsmode0 = 20000;
+ bitsmode0 = 20000; /* Q0 */
move16();
}
}
test();
- IF( flag_pack == 0 || *hLCmode0 == 1 )
+ IF( flag_pack == 0 || EQ_16( *hLCmode0, 1 ) )
{
/* components 0 range : -256~255 */
max_q = MINIMUM_ENERGY_LOWBRATE;
@@ -2888,9 +2798,9 @@ static Word16 large_symbol_enc_ivas_fx(
basic_shift = i;
move16();
- min_bits = 1000;
+ min_bits = 1000; /* Q0 */
move16();
- min_bits_pos = basic_shift;
+ min_bits_pos = basic_shift; /* Q0 */
move16();
tmp = add( basic_shift, 3 );
FOR( offset0 = basic_shift; offset0 < tmp; offset0++ )
@@ -2900,30 +2810,33 @@ static Word16 large_symbol_enc_ivas_fx(
min_q = MAXIMUM_ENERGY_LOWBRATE;
move16();
- bitsmode1 = add( BITS_DE_8SMODE, BITS_MAX_DEPTH );
+ bitsmode1 = ( BITS_DE_8SMODE + BITS_MAX_DEPTH ); /* Q0 */
+ move16();
FOR( i = 0; i < BANDS; ++i )
{
- bitsmode1 = add( bitsmode1, add( hessize[add( shr( qbidx[i], offset0 ), 4 )], offset0 ) );
+ bitsmode1 = add( bitsmode1, add( hessize[( ( qbidx[i] >> offset0 ) + 4 )], offset0 ) ); /* Q0 */
}
IF( GT_16( min_bits, bitsmode1 ) )
{
- min_bits_pos = offset0;
+ min_bits_pos = offset0; /* Q0 */
move16();
- min_bits = bitsmode1;
+ min_bits = bitsmode1; /* Q0 */
move16();
}
}
- bitsmode1 = min_bits;
+ bitsmode1 = min_bits; /* Q0 */
move16();
- lsbdepth1 = min_bits_pos;
+ lsbdepth1 = min_bits_pos; /* Q0 */
move16();
FOR( i = 0; i < BANDS; ++i )
{
LSB1[i] = s_and( qbidx[i], sub( shl( 1, lsbdepth1 ), 1 ) );
tdifidx1[i] = shr( qbidx[i], lsbdepth1 );
+ move16();
+ move16();
}
}
@@ -2934,14 +2847,14 @@ static Word16 large_symbol_enc_ivas_fx(
/* Encoding MSB bits */
IF( LT_16( bitsmode0, bitsmode1 ) )
{
- bits = bitsmode0;
+ bits = bitsmode0; /* Q0 */
move16();
*hLCmode0 = 0;
move16();
}
ELSE
{
- bits = bitsmode1;
+ bits = bitsmode1; /* Q0 */
move16();
*hLCmode0 = 1;
move16();
@@ -2963,7 +2876,7 @@ static Word16 large_symbol_enc_ivas_fx(
{
/* 01 */
push_indice( hBstr, IND_HQ2_DENG_8SMODE_N1, 1, BITS_DE_8SMODE_N1 );
- bits = add( bits, BITS_DE_8SMODE_N1 );
+ bits = add( bits, BITS_DE_8SMODE_N1 ); /* Q0 */
push_indice( hBstr, IND_HQ2_DENG_8SPOS, pos_outlyer, BITS_DE_8SPOS );
bits = add( bits, BITS_DE_8SPOS );
push_indice( hBstr, IND_HQ2_DIFF_ENERGY, qbidx[pos_outlyer] + ABS_ENG_OFFSET, BITS_ABS_ENG );
@@ -2973,29 +2886,29 @@ static Word16 large_symbol_enc_ivas_fx(
{
/* 00 */
push_indice( hBstr, IND_HQ2_DENG_8SMODE_N1, 0, BITS_DE_8SMODE_N1 );
- bits = add( bits, BITS_DE_8SMODE_N1 );
+ bits = add( bits, BITS_DE_8SMODE_N1 ); /* Q0 */
}
FOR( i = 0; i < pos_outlyer; ++i )
{
push_indice( hBstr, IND_HQ2_DIFF_ENERGY, hescode[tdifidx0[i] + 4], hessize[tdifidx0[i] + 4] );
- bitsmode0 = add( bitsmode0, hessize[tdifidx0[i] + 4] );
+ bitsmode0 = add( bitsmode0, hessize[tdifidx0[i] + 4] ); /* Q0 */
}
- FOR( i = add( pos_outlyer, 1 ); i < BANDS; ++i )
+ FOR( i = ( pos_outlyer + 1 ); i < BANDS; ++i )
{
push_indice( hBstr, IND_HQ2_DIFF_ENERGY, hescode[tdifidx0[i] + 4], hessize[tdifidx0[i] + 4] );
- bitsmode0 = add( bitsmode0, hessize[tdifidx0[i] + 4] );
+ bitsmode0 = add( bitsmode0, hessize[tdifidx0[i] + 4] ); /* Q0 */
}
}
ELSE IF( EQ_16( cnt_outlyer0, 1 ) )
{
push_indice( hBstr, IND_HQ2_DENG_8SMODE_N0, 1, BITS_DE_8SMODE_N0 );
- bits = add( bits, BITS_DE_8SMODE_N0 );
+ bits = add( bits, BITS_DE_8SMODE_N0 ); /* Q0 */
IF( EQ_16( cnt_outlyer, 1 ) )
{
push_indice( hBstr, IND_HQ2_DENG_8SMODE_N1, 1, BITS_DE_8SMODE_N1 );
- bits = add( bits, BITS_DE_8SMODE_N1 );
+ bits = add( bits, BITS_DE_8SMODE_N1 ); /* Q0 */
push_indice( hBstr, IND_HQ2_DENG_8SPOS, pos_outlyer, BITS_DE_8SPOS );
bits = add( bits, BITS_DE_8SPOS );
push_indice( hBstr, IND_HQ2_DIFF_ENERGY, qbidx[0] + ABS_ENG_OFFSET, BITS_ABS_ENG );
@@ -3006,21 +2919,21 @@ static Word16 large_symbol_enc_ivas_fx(
ELSE
{
push_indice( hBstr, IND_HQ2_DENG_8SMODE_N1, 0, BITS_DE_8SMODE_N1 );
- bits = add( bits, BITS_DE_8SMODE_N1 );
+ bits = add( bits, BITS_DE_8SMODE_N1 ); /* Q0 */
push_indice( hBstr, IND_HQ2_DIFF_ENERGY, qbidx[0] + ABS_ENG_OFFSET, BITS_ABS_ENG );
- bits = add( bits, BITS_ABS_ENG );
+ bits = add( bits, BITS_ABS_ENG ); /* Q0 */
}
FOR( i = 1; i < pos_outlyer; ++i )
{
push_indice( hBstr, IND_HQ2_DIFF_ENERGY, hescode[tdifidx0[i] + 4], hessize[tdifidx0[i] + 4] );
- bits = add( bits, hessize[tdifidx0[i] + 4] );
+ bits = add( bits, hessize[tdifidx0[i] + 4] ); /* Q0 */
}
FOR( i = pos_outlyer + 1; i < BANDS; ++i )
{
push_indice( hBstr, IND_HQ2_DIFF_ENERGY, hescode[tdifidx0[i] + 4], hessize[tdifidx0[i] + 4] );
- bits = add( bits, hessize[tdifidx0[i] + 4] );
+ bits = add( bits, hessize[tdifidx0[i] + 4] ); /* Q0 */
}
}
}
@@ -3033,7 +2946,7 @@ static Word16 large_symbol_enc_ivas_fx(
FOR( i = 0; i < BANDS; ++i )
{
push_indice( hBstr, IND_HQ2_DIFF_ENERGY, hescode[tdifidx1[i] + 4], hessize[tdifidx1[i] + 4] );
- bits = add( bits, hessize[tdifidx1[i] + 4] );
+ bits = add( bits, hessize[tdifidx1[i] + 4] ); /* Q0 */
}
IF( lsbdepth1 > 0 )
@@ -3043,12 +2956,12 @@ static Word16 large_symbol_enc_ivas_fx(
push_indice( hBstr, IND_HQ2_DIFF_ENERGY, LSB1[i], lsbdepth1 );
}
/*bits += BANDS * lsbdepth1; */
- bits = add( bits, extract_h( L_shl( L_mult( BANDS, lsbdepth1 ), 15 ) ) );
+ bits = add( bits, extract_h( L_shl( L_mult( BANDS, lsbdepth1 ), 15 ) ) ); /* Q0 */
}
}
}
- return bits; /* xx bits for diff. energies + 1 bit for LC coding mode */
+ return bits; /* xx bits for diff. energies + 1 bit for LC coding mode Q0*/
}
/*-------------------------------------------------------------------*
@@ -3074,6 +2987,7 @@ static Word16 band_energy_quant_fx(
Word16 hLCmode0, hLCmode1, deng_bits;
Word16 deng_cmode = 0;
Word16 hbits;
+ move16();
Word32 L_E;
Word16 QE;
@@ -3104,7 +3018,7 @@ static Word16 band_energy_quant_fx(
L_tmp = L_deposit_l( 1295 ); /* 1295 = sqrt(0.1) (Qs) */
FOR( i = band_start[k]; i <= band_end[k]; i++ )
{
- L_tmp = L_or( L_tmp, L_abs( L_t_audio[i] ) );
+ L_tmp = L_or( L_tmp, L_abs( L_t_audio[i] ) ); /* Qs */
}
exp_norm = norm_l( L_tmp );
exp_norm = sub( exp_norm, exp_safe ); /* safe_shift */
@@ -3114,18 +3028,19 @@ static Word16 band_energy_quant_fx(
FOR( i = band_start[k]; i <= band_end[k]; i++ )
{
/*E += yos[i] * yos[i]; */
- temp_fx = round_fx( L_shl( L_t_audio[i], exp_norm ) );
- L_E = L_mac( L_E, temp_fx, temp_fx ); /* (Qs+exp_norm-16)*2+1 */
+ temp_fx = round_fx( L_shl( L_t_audio[i], exp_norm ) ); /* Qs+exp_norm-16 */
+ L_E = L_mac( L_E, temp_fx, temp_fx ); /* (Qs+exp_norm-16)*2+1 */
}
/*band_energy[k] = (float) log2_f (E + 1.0e-1f); */
exp_norm2 = norm_l( L_E );
exp = add( add( shl( sub( add( SWB_BWE_LR_Qs, exp_norm ), 16 ), 1 ), 1 ), exp_norm2 );
- L_E = L_shl( L_E, exp_norm2 );
+ L_E = L_shl( L_E, exp_norm2 ); /* (Qs+exp_norm-16)*2 + 1 + exp_norm2 */
frac = Log2_norm_lc( L_E );
exp = sub( 30, exp );
L_tmp = L_Comp( exp, frac );
L_band_energy[k] = L_shr( L_tmp, 2 ); /* Q16->Qbe(Q14) */
+ move32();
}
IF( is_transient_fx )
@@ -3144,53 +3059,55 @@ static Word16 band_energy_quant_fx(
{
/*bq1[k] = round_f (band_energy[k] / qint); */
L_tmp = Mpy_32_16_1( L_band_energy[k], rev_qint_fx ); /* Q14+Qrev_qint-15 */
- bq1_fx[k] = round_fx( L_shl( L_tmp, sub( 17, Qrev_qint ) ) ); /* 16-(14+Qrev_qint-15) */
+ bq1_fx[k] = round_fx( L_shl( L_tmp, sub( 17, Qrev_qint ) ) ); /* Q0 */
+ move16();
}
IF( is_transient_fx )
{
- Copy( bq1_fx, bq1_temp_fx, bands_fx );
+ Copy( bq1_fx, bq1_temp_fx, bands_fx ); /* Q0 */
/* Calculate the differential energies */
diffcod_lrmdct_fx( bands_fx, bq0_fx, bq1_temp_fx, bq2_temp_fx, is_transient_fx );
}
/* Calculate the differential energies */
- bq2_fx[0] = sub( bq1_fx[0], bq0_fx );
+ bq2_fx[0] = sub( bq1_fx[0], bq0_fx ); /* Q0 */
+ move16();
FOR( k = 1; k < bands_fx; k++ )
{
- bq2_fx[k] = sub( bq1_fx[k], bq1_fx[k - 1] );
+ bq2_fx[k] = sub( bq1_fx[k], bq1_fx[k - 1] ); /* Q0 */
move16();
}
/* Modifying qbidx to be located in the range -256~255 */
FOR( i = 0; i < bands_fx; ++i )
{
- if ( GT_16( bq2_fx[i], MAXIMUM_ENERGY_LOWBRATE ) )
+ IF( GT_16( bq2_fx[i], MAXIMUM_ENERGY_LOWBRATE ) )
{
- bq2_fx[i] = MAXIMUM_ENERGY_LOWBRATE;
+ bq2_fx[i] = MAXIMUM_ENERGY_LOWBRATE; /* Q0 */
move16();
}
- if ( LT_16( bq2_fx[i], MINIMUM_ENERGY_LOWBRATE ) )
+ IF( LT_16( bq2_fx[i], MINIMUM_ENERGY_LOWBRATE ) )
{
- bq2_fx[i] = MINIMUM_ENERGY_LOWBRATE;
+ bq2_fx[i] = MINIMUM_ENERGY_LOWBRATE; /* Q0 */
move16();
}
}
/* Get number of bits by Huffman0 coding */
- ebits = large_symbol_enc_fx( hBstr, bq2_fx, bands_fx, &hLCmode0, 0 );
+ ebits = large_symbol_enc_fx( hBstr, bq2_fx, bands_fx, &hLCmode0, 0 ); /* Q0 */
IF( is_transient_fx )
{
/* Get number of bits by Huffman coding */
- hbits = small_symbol_enc_tran_fx( hBstr, bq2_temp_fx, bands_fx, &hLCmode1, 0, is_transient_fx );
+ hbits = small_symbol_enc_tran_fx( hBstr, bq2_temp_fx, bands_fx, &hLCmode1, 0, is_transient_fx ); /* Q0 */
}
ELSE
{
/* Get number of bits by Huffman coding */
- hbits = small_symbol_enc_fx( hBstr, bq2_fx, bands_fx, &hLCmode1, 0, is_transient_fx );
+ hbits = small_symbol_enc_fx( hBstr, bq2_fx, bands_fx, &hLCmode1, 0, is_transient_fx ); /* Q0 */
}
/* comparing used bits */
@@ -3201,7 +3118,7 @@ static Word16 band_energy_quant_fx(
move16();
push_indice_fx( hBstr, IND_HQ2_DENG_MODE, deng_cmode, BITS_DE_CMODE );
large_symbol_enc_fx( hBstr, bq2_fx, bands_fx, &hLCmode0, 1 );
- deng_bits = add( ebits, BITS_DE_CMODE );
+ deng_bits = add( ebits, BITS_DE_CMODE ); /* Q0 */
}
ELSE
{
@@ -3210,12 +3127,12 @@ static Word16 band_energy_quant_fx(
move16();
push_indice_fx( hBstr, IND_HQ2_DENG_MODE, deng_cmode, BITS_DE_CMODE );
- deng_bits = add( hbits, BITS_DE_CMODE );
+ deng_bits = add( hbits, BITS_DE_CMODE ); /* Q0 */
/* packing indice */
IF( is_transient_fx )
{
- Copy( bq2_temp_fx, bq2_fx, bands_fx );
+ Copy( bq2_temp_fx, bq2_fx, bands_fx ); /* Q0 */
small_symbol_enc_tran_fx( hBstr, bq2_fx, bands_fx, &hLCmode1, 1, is_transient_fx );
}
ELSE
@@ -3225,17 +3142,18 @@ static Word16 band_energy_quant_fx(
}
/* Reconstruct quantized spectrum */
- bq1_fx[0] = add( bq2_fx[0], bq0_fx );
+ bq1_fx[0] = add( bq2_fx[0], bq0_fx ); /* Q0 */
move16();
FOR( k = 1; k < bands_fx; k++ )
{
- bq1_fx[k] = add( bq2_fx[k], bq1_fx[k - 1] );
+ bq1_fx[k] = add( bq2_fx[k], bq1_fx[k - 1] ); /* Q0 */
move16();
}
FOR( k = 0; k < bands_fx; k++ )
{
L_band_energy[k] = Mpy_32_16_1( L_qint, bq1_fx[k] ); /* 29+0-15 -> Qbe(Q14) */
+ move32();
}
IF( is_transient_fx )
@@ -3243,7 +3161,7 @@ static Word16 band_energy_quant_fx(
reverse_transient_frame_energies_fx( L_band_energy, bands_fx );
}
- return ( deng_bits );
+ return ( deng_bits ); /* Q0 */
}
@@ -3294,7 +3212,7 @@ static Word16 band_energy_quant_ivas_fx(
L_tmp = L_deposit_l( 1295 ); /* 1295 = sqrt(0.1) (Qs) */
FOR( i = band_start[k]; i <= band_end[k]; i++ )
{
- L_tmp = L_or( L_tmp, L_abs( L_t_audio[i] ) );
+ L_tmp = L_or( L_tmp, L_abs( L_t_audio[i] ) ); /* Qs */
}
exp_norm = norm_l( L_tmp );
exp_norm = sub( exp_norm, exp_safe ); /* safe_shift */
@@ -3304,18 +3222,19 @@ static Word16 band_energy_quant_ivas_fx(
FOR( i = band_start[k]; i <= band_end[k]; i++ )
{
/*E += yos[i] * yos[i]; */
- temp_fx = round_fx( L_shl( L_t_audio[i], exp_norm ) );
- L_E = L_mac( L_E, temp_fx, temp_fx ); /* (Qs+exp_norm-16)*2+1 */
+ temp_fx = round_fx( L_shl( L_t_audio[i], exp_norm ) ); /* Qs+exp_norm-16 */
+ L_E = L_mac( L_E, temp_fx, temp_fx ); /* (Qs+exp_norm-16)*2+1 */
}
/*band_energy[k] = (float) log2_f (E + 1.0e-1f); */
exp_norm2 = norm_l( L_E );
exp = add( add( shl( sub( add( SWB_BWE_LR_Qs, exp_norm ), 16 ), 1 ), 1 ), exp_norm2 );
- L_E = L_shl( L_E, exp_norm2 );
+ L_E = L_shl( L_E, exp_norm2 ); /* (Qs+exp_norm-16)*2 + 1 + exp_norm2 */
frac = Log2_norm_lc( L_E );
exp = sub( 30, exp );
L_tmp = L_Comp( exp, frac );
L_band_energy[k] = L_shr( L_tmp, 2 ); /* Q16->Qbe(Q14) */
+ move32();
}
IF( is_transient )
@@ -3333,24 +3252,26 @@ static Word16 band_energy_quant_ivas_fx(
{
/*bq1[k] = round_f (band_energy[k] / qint); */
L_tmp = L_mls( L_band_energy[k], rev_qint_fx ); /* Q14+Qrev_qint-15 */
- bq1_fx[k] = round_fx( L_shl( L_tmp, sub( 17, Qrev_qint ) ) ); /* 16-(14+Qrev_qint-15) */
+ bq1_fx[k] = round_fx( L_shl( L_tmp, sub( 17, Qrev_qint ) ) ); /* Q0 */
+ move16();
}
#undef WMC_TOOL_SKIP
IF( is_transient )
{
- Copy( bq1_fx, bq1_temp_fx, bands );
+ Copy( bq1_fx, bq1_temp_fx, bands ); /* Q0 */
/* Calculate the differential energies */
- diffcod_lrmdct_fx( bands, bq0_fx, bq1_temp_fx, bq2_temp_fx, is_transient );
+ diffcod_lrmdct_fx( bands, bq0_fx, bq1_temp_fx, bq2_temp_fx, is_transient ); /* Q0 */
}
/* Calculate the differential energies */
- bq2_fx[0] = sub( bq1_fx[0], bq0_fx );
+ bq2_fx[0] = sub( bq1_fx[0], bq0_fx ); /* Q0 */
+ move16();
FOR( k = 1; k < bands; k++ )
{
- bq2_fx[k] = sub( bq1_fx[k], bq1_fx[k - 1] );
+ bq2_fx[k] = sub( bq1_fx[k], bq1_fx[k - 1] ); /* Q0 */
move16();
}
@@ -3358,30 +3279,30 @@ static Word16 band_energy_quant_ivas_fx(
/* Modifying qbidx to be located in the range -256~255 */
FOR( i = 0; i < bands; ++i )
{
- if ( bq2_fx[i] > MAXIMUM_ENERGY_LOWBRATE )
+ IF( GT_16( bq2_fx[i], MAXIMUM_ENERGY_LOWBRATE ) )
{
- bq2_fx[i] = MAXIMUM_ENERGY_LOWBRATE;
+ bq2_fx[i] = MAXIMUM_ENERGY_LOWBRATE; /* Q0 */
move16();
}
- if ( bq2_fx[i] < MINIMUM_ENERGY_LOWBRATE )
+ IF( LT_16( bq2_fx[i], MINIMUM_ENERGY_LOWBRATE ) )
{
- bq2_fx[i] = MINIMUM_ENERGY_LOWBRATE;
+ bq2_fx[i] = MINIMUM_ENERGY_LOWBRATE; /* Q0 */
move16();
}
}
/* Get number of bits by Huffman0 coding */
- ebits = large_symbol_enc_ivas_fx( hBstr, bq2_fx, bands, &hLCmode0, 0 );
+ ebits = large_symbol_enc_ivas_fx( hBstr, bq2_fx, bands, &hLCmode0, 0 ); /* Q0 */
IF( is_transient )
{
/* Get number of bits by Huffman coding */
- hbits = small_symbol_enc_tran_ivas_fx( hBstr, bq2_temp_fx, bands, &hLCmode1, 0, is_transient );
+ hbits = small_symbol_enc_tran_ivas_fx( hBstr, bq2_temp_fx, bands, &hLCmode1, 0, is_transient ); /* Q0 */
}
ELSE
{
/* Get number of bits by Huffman coding */
- hbits = small_symbol_enc_ivas_fx( hBstr, bq2_fx, bands, &hLCmode1, 0, is_transient );
+ hbits = small_symbol_enc_ivas_fx( hBstr, bq2_fx, bands, &hLCmode1, 0, is_transient ); /* Q0 */
}
test();
@@ -3391,7 +3312,7 @@ static Word16 band_energy_quant_ivas_fx(
move16();
push_indice( hBstr, IND_HQ2_DENG_MODE, deng_cmode, BITS_DE_CMODE );
large_symbol_enc_ivas_fx( hBstr, bq2_fx, bands, &hLCmode0, 1 );
- deng_bits = add( ebits, BITS_DE_CMODE );
+ deng_bits = add( ebits, BITS_DE_CMODE ); /* Q0 */
}
ELSE
{
@@ -3400,12 +3321,12 @@ static Word16 band_energy_quant_ivas_fx(
move16();
push_indice( hBstr, IND_HQ2_DENG_MODE, deng_cmode, BITS_DE_CMODE );
- deng_bits = add( hbits, BITS_DE_CMODE );
+ deng_bits = add( hbits, BITS_DE_CMODE ); /* Q0 */
/* packing indice */
IF( is_transient )
{
- Copy( bq2_temp_fx, bq2_fx, bands );
+ Copy( bq2_temp_fx, bq2_fx, bands ); /* Q0 */
small_symbol_enc_tran_ivas_fx( hBstr, bq2_fx, bands, &hLCmode1, 1, is_transient );
}
ELSE
@@ -3415,17 +3336,19 @@ static Word16 band_energy_quant_ivas_fx(
}
/* Reconstruct quantized spectrum */
- bq1_fx[0] = add( bq2_fx[0], bq0_fx );
+ bq1_fx[0] = add( bq2_fx[0], bq0_fx ); /* Q0 */
+ move16();
FOR( k = 1; k < bands; k++ )
{
- bq1_fx[k] = add( bq2_fx[k], bq1_fx[k - 1] );
+ bq1_fx[k] = add( bq2_fx[k], bq1_fx[k - 1] ); /* Q0 */
+ move16();
}
FOR( k = 0; k < bands; k++ )
{
#define WMC_TOOL_SKIP
- L_band_energy[k] = L_mls( L_qint, (Word16) bq1_fx[k] );
- move32(); /* 29+0-15 -> Qbe(Q14) */
+ L_band_energy[k] = L_mls( L_qint, (Word16) bq1_fx[k] ); /* 29+0-15 -> Qbe(Q14) */
+ move32();
#undef WMC_TOOL_SKIP
}
@@ -3434,7 +3357,7 @@ static Word16 band_energy_quant_ivas_fx(
reverse_transient_frame_energies_fx( L_band_energy, bands );
}
- return ( deng_bits );
+ return ( deng_bits ); /* Q0 */
}
@@ -3474,16 +3397,18 @@ static Word16 p2a_threshold_quant_fx(
Word16 p2a_fx;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
exp_safe = 4; /* never happen overflow. */
+ move16();
set16_fx( p2a_flags_fx, 1, bands );
move16();
j = 0;
move16();
- FOR( k = sub( bands, p2a_bands ); k < bands; k++ )
+ FOR( k = ( bands - p2a_bands ); k < bands; k++ )
{
L_a = L_deposit_l( 0 );
L_p = L_deposit_l( 0 );
@@ -3491,7 +3416,7 @@ static Word16 p2a_threshold_quant_fx(
L_tmp = L_deposit_l( 0 );
FOR( i = band_start[k]; i <= band_end[k]; i++ )
{
- L_tmp = L_or( L_tmp, L_abs( L_t_audio[i] ) );
+ L_tmp = L_or( L_tmp, L_abs( L_t_audio[i] ) ); /* Q12 */
}
exp_norm = norm_l( L_tmp );
exp_norm = sub( exp_norm, exp_safe );
@@ -3499,9 +3424,9 @@ static Word16 p2a_threshold_quant_fx(
FOR( i = band_start[k]; i <= band_end[k]; i++ )
{
temp_fx = round_fx( L_shl( L_t_audio[i], exp_norm ) ); /* Q12+exp_norm-16 -> exp_norm-4 */
- L_e = L_mult( temp_fx, temp_fx );
+ L_e = L_mult( temp_fx, temp_fx ); /* 2*(exp_norm-4)+1 */
- if ( GT_32( L_e, L_p ) )
+ IF( GT_32( L_e, L_p ) )
{
L_p = L_add( L_e, 0 );
}
@@ -3515,8 +3440,8 @@ static Word16 p2a_threshold_quant_fx(
exp_normn = norm_l( L_a );
exp_normn = sub( exp_normn, 1 );
exp_normd = norm_s( band_width[k] );
- norm_a_fx = div_l( L_shl( L_a, exp_normn ), shl( band_width[k], exp_normd ) );
- Qnorm_a = sub( sub( add( Qa, exp_normn ), exp_normd ), 1 ); /* (Qa+exp_normn)-exp_normd-1); */
+ norm_a_fx = div_l( L_shl( L_a, exp_normn ), shl( band_width[k], exp_normd ) ); /* (Qa+exp_normn)-exp_normd-1); */
+ Qnorm_a = sub( sub( add( Qa, exp_normn ), exp_normd ), 1 );
/*p2a = 10.0f * (float) log10 (p / a); */
p2a_fx = 0;
@@ -3526,7 +3451,7 @@ static Word16 p2a_threshold_quant_fx(
exp_normn = norm_l( L_p );
exp_normn = sub( exp_normn, 1 );
exp_normd = norm_s( norm_a_fx );
- pa_fx = div_l( L_shl( L_p, exp_normn ), shl( norm_a_fx, exp_normd ) );
+ pa_fx = div_l( L_shl( L_p, exp_normn ), shl( norm_a_fx, exp_normd ) ); /* Qpa + exp_normn + Qnorm_a + exp_normd - 1 */
Qpa = sub( sub( add( Qa, exp_normn ), add( Qnorm_a, exp_normd ) ), 1 );
L_tmp = L_deposit_h( pa_fx );
@@ -3540,14 +3465,10 @@ 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 ) )
+ IF( LE_16( p2a_fx, p2a_th_fx ) )
{
p2a_flags_fx[k] = 0;
move16();
@@ -3563,7 +3484,7 @@ static Word16 p2a_threshold_quant_fx(
j = add( j, 1 );
}
- return ( j );
+ return ( j ); /* Q0 */
}
static Word16 p2a_threshold_quant_ivas_fx(
@@ -3596,6 +3517,7 @@ static Word16 p2a_threshold_quant_ivas_fx(
Word16 p2a_fx;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
exp_safe = 4; /* never happen overflow. */
@@ -3605,7 +3527,7 @@ static Word16 p2a_threshold_quant_ivas_fx(
j = 0;
move16();
- FOR( k = sub( bands, p2a_bands ); k < bands; k++ )
+ FOR( k = ( bands - p2a_bands ); k < bands; k++ )
{
L_a = L_deposit_l( 0 );
L_p = L_deposit_l( 0 );
@@ -3613,7 +3535,7 @@ static Word16 p2a_threshold_quant_ivas_fx(
L_tmp = L_deposit_l( 0 );
FOR( i = band_start[k]; i <= band_end[k]; i++ )
{
- L_tmp = L_or( L_tmp, L_abs( L_t_audio[i] ) );
+ L_tmp = L_or( L_tmp, L_abs( L_t_audio[i] ) ); /* Q12 */
}
exp_norm = norm_l( L_tmp );
exp_norm = sub( exp_norm, exp_safe );
@@ -3621,9 +3543,9 @@ static Word16 p2a_threshold_quant_ivas_fx(
FOR( i = band_start[k]; i <= band_end[k]; i++ )
{
temp_fx = round_fx( L_shl( L_t_audio[i], exp_norm ) ); /* Q12+exp_norm-16 -> exp_norm-4 */
- L_e = L_mult( temp_fx, temp_fx );
+ L_e = L_mult( temp_fx, temp_fx ); /* (exp_norm-4)*2 + 1 */
- if ( GT_32( L_e, L_p ) )
+ IF( GT_32( L_e, L_p ) )
{
L_p = L_add( L_e, 0 );
}
@@ -3637,8 +3559,8 @@ static Word16 p2a_threshold_quant_ivas_fx(
exp_normn = norm_l( L_a );
exp_normn = sub( exp_normn, 1 );
exp_normd = norm_s( band_width[k] );
- norm_a_fx = div_l( L_shl( L_a, exp_normn ), shl( band_width[k], exp_normd ) );
- Qnorm_a = sub( sub( add( Qa, exp_normn ), exp_normd ), 1 ); /* (Qa+exp_normn)-exp_normd-1); */
+ norm_a_fx = div_l( L_shl( L_a, exp_normn ), shl( band_width[k], exp_normd ) ); /* (Qa+exp_normn)-exp_normd-1); */
+ Qnorm_a = sub( sub( add( Qa, exp_normn ), exp_normd ), 1 );
/*p2a = 10.0f * (float) log10 (p / a); */
p2a_fx = 0;
@@ -3648,7 +3570,7 @@ static Word16 p2a_threshold_quant_ivas_fx(
exp_normn = norm_l( L_p );
exp_normn = sub( exp_normn, 1 );
exp_normd = norm_s( norm_a_fx );
- pa_fx = div_l( L_shl( L_p, exp_normn ), shl( norm_a_fx, exp_normd ) );
+ pa_fx = div_l( L_shl( L_p, exp_normn ), shl( norm_a_fx, exp_normd ) ); /* Qpa + exp_normn + Qnorm_a + exp_normd - 1 */
Qpa = sub( sub( add( Qa, exp_normn ), add( Qnorm_a, exp_normd ) ), 1 );
L_tmp = L_deposit_h( pa_fx );
@@ -3662,14 +3584,10 @@ 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 ) )
+ IF( LE_16( p2a_fx, p2a_th_fx ) )
{
p2a_flags_fx[k] = 0;
move16();
@@ -3685,7 +3603,7 @@ static Word16 p2a_threshold_quant_ivas_fx(
j = add( j, 1 );
}
- return ( j );
+ return ( j ); /* Q0 */
}
@@ -3735,6 +3653,7 @@ static void mdct_spectrum_fine_gain_enc_fx(
Word16 imin_fx;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/* Fine gain quantization on only the most significant energy bands */
@@ -3743,23 +3662,25 @@ static void mdct_spectrum_fine_gain_enc_fx(
exp_normn = norm_l( L_qint );
exp_normn = sub( exp_normn, 1 );
exp_normd = norm_s( gqlevs );
- delta_fx = div_l( L_shl( L_qint, exp_normn ), shl( gqlevs, exp_normd ) );
- Qdelta = add( sub( exp_normn, exp_normd ), 28 ); /* 29+exp_normn-(exp_normd)-1; */
- L_delta = L_shl( L_deposit_h( delta_fx ), sub( 13, Qdelta ) );
+ delta_fx = div_l( L_shl( L_qint, exp_normn ), shl( gqlevs, exp_normd ) ); /* 29+exp_normn-(exp_normd)-1; */
+ Qdelta = add( sub( exp_normn, exp_normd ), 28 );
+ L_delta = L_shl( L_deposit_h( delta_fx ), sub( 13, Qdelta ) ); /* Q29 */
/*q = (-qint + delta) / 2.0f; */
- L_q = L_shr( L_sub( L_delta, L_qint ), 1 );
+ L_q = L_shr( L_sub( L_delta, L_qint ), 1 ); /* Q29 */
FOR( i = 0; i < gqlevs; i++ )
{
/*gain_table[i] = (float) pow (2.0f, q * 0.5f); */
- L_temp = L_shr( L_shr( L_q, 1 ), sub( 29, 16 ) );
+ L_temp = L_shr( L_shr( L_q, 1 ), sub( 29, 16 ) ); /* Q16 */
temp_lo_fx = L_Extract_lc( L_temp, &temp_hi_fx );
Qgt = sub( 14, temp_hi_fx );
gain_table_fx[i] = extract_l( Pow2( 14, temp_lo_fx ) ); /* Qgt */
+ move16();
/*q += delta; */
L_q = L_add( L_q, L_delta );
gain_table_fx[i] = shl( gain_table_fx[i], sub( 14, Qgt ) ); /* Qgt -> Q14 */
+ move16();
}
FOR( k = sub( bands, Ngq ); k < bands; k++ )
@@ -3776,8 +3697,8 @@ static void mdct_spectrum_fine_gain_enc_fx(
L_temp = L_deposit_l( 0 );
FOR( i = band_start[k_sort[k]]; i <= band_end[k_sort[k]]; i++ )
{
- L_temp = L_or( L_temp, L_abs( L_y2[i] ) );
- L_temp = L_or( L_temp, L_abs( L_ybuf[i] ) );
+ L_temp = L_or( L_temp, L_abs( L_y2[i] ) ); /* Q12 */
+ L_temp = L_or( L_temp, L_abs( L_ybuf[i] ) ); /* Q12 */
}
exp_norm = norm_l( L_temp );
exp_norm = sub( exp_norm, exp_safe ); /* safe_shift */
@@ -3788,12 +3709,12 @@ static void mdct_spectrum_fine_gain_enc_fx(
FOR( i = band_start[k_sort[k]]; i <= band_end[k_sort[k]]; i++ )
{
/*Eyy += y2[i] * y2[i]; */
- temp_fx = round_fx( L_shl( L_y2[i], exp_norm ) );
- L_Eyy = L_mac( L_Eyy, temp_fx, temp_fx );
+ temp_fx = round_fx( L_shl( L_y2[i], exp_norm ) ); /* Q12 + exp_norm - 16 */
+ L_Eyy = L_mac( L_Eyy, temp_fx, temp_fx ); /* (Q12 + exp_norm - 16)*2 + 1 */
/*Exy += ybuf[i] * y2[i]; */
- temp2_fx = round_fx( L_shl( L_ybuf[i], exp_norm ) );
- L_Exy = L_mac( L_Exy, temp2_fx, temp_fx );
+ temp2_fx = round_fx( L_shl( L_ybuf[i], exp_norm ) ); /* Q12 + exp_norm - 16 */
+ L_Exy = L_mac( L_Exy, temp2_fx, temp_fx ); /* (Q12 + exp_norm - 16)*2 + 1 */
}
test();
@@ -3803,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 ) );
-#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 */
+ 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 */
+ 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();
@@ -3817,18 +3734,18 @@ static void mdct_spectrum_fine_gain_enc_fx(
move16();
FOR( i = 0; i < gqlevs; i++ )
{
- d_fx = abs_s( sub( gamma_fx, gain_table_fx[i] ) );
+ d_fx = abs_s( sub( gamma_fx, gain_table_fx[i] ) ); /* Q14 */
IF( LT_16( d_fx, dmin_fx ) )
{
- dmin_fx = d_fx;
+ dmin_fx = d_fx; /* Q14 */
move16();
imin_fx = i;
move16();
}
}
- gamma_fx = gain_table_fx[imin_fx];
- move16(); /* Q14 */
+ gamma_fx = gain_table_fx[imin_fx]; /* Q14 */
+ move16();
FOR( i = band_start[k_sort[k]]; i <= band_end[k_sort[k]]; i++ )
{
@@ -3836,11 +3753,13 @@ static void mdct_spectrum_fine_gain_enc_fx(
/* This IF statement for keeping same mantissa evenif y2 is plus or minus */
IF( L_y2[i] >= 0x0 )
{
- L_y2[i] = L_shl( Mpy_32_16_1( L_y2[i], gamma_fx ), 1 );
+ L_y2[i] = L_shl( Mpy_32_16_1( L_y2[i], gamma_fx ), 1 ); /* Q12 */
+ move32();
}
ELSE
{
- L_y2[i] = L_negate( L_shl( Mpy_32_16_1( L_abs( L_y2[i] ), gamma_fx ), 1 ) );
+ L_y2[i] = L_negate( L_shl( Mpy_32_16_1( L_abs( L_y2[i] ), gamma_fx ), 1 ) ); /* Q12 */
+ move32();
}
}
}
@@ -3896,6 +3815,7 @@ static void mdct_spectrum_fine_gain_enc_ivas_fx(
Word16 imin_fx;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/* Fine gain quantization on only the most significant energy bands */
@@ -3905,22 +3825,24 @@ static void mdct_spectrum_fine_gain_enc_ivas_fx(
exp_normn = sub( exp_normn, 1 );
exp_normd = norm_s( gqlevs );
delta_fx = div_l( L_shl( L_qint, exp_normn ), shl( gqlevs, exp_normd ) );
- Qdelta = add( sub( exp_normn, exp_normd ), 28 ); /* 29+exp_normn-(exp_normd)-1; */
- L_delta = L_shl( L_deposit_h( delta_fx ), sub( 13, Qdelta ) );
+ Qdelta = add( sub( exp_normn, exp_normd ), 28 ); /* 29+exp_normn-(exp_normd)-1; */
+ L_delta = L_shl( L_deposit_h( delta_fx ), sub( 13, Qdelta ) ); /* Q29 */
/*q = (-qint + delta) / 2.0f; */
- L_q = L_shr( L_sub( L_delta, L_qint ), 1 );
+ L_q = L_shr( L_sub( L_delta, L_qint ), 1 ); /* Q29 */
FOR( i = 0; i < gqlevs; i++ )
{
/*gain_table[i] = (float) pow (2.0f, q * 0.5f); */
- L_temp = L_shr( L_shr( L_q, 1 ), sub( 29, 16 ) );
+ L_temp = L_shr( L_shr( L_q, 1 ), sub( 29, 16 ) ); /* Q16 */
temp_lo_fx = L_Extract_lc( L_temp, &temp_hi_fx );
Qgt = sub( 14, temp_hi_fx );
gain_table_fx[i] = extract_l( Pow2( 14, temp_lo_fx ) ); /* Qgt */
+ move16();
/*q += delta; */
L_q = L_add( L_q, L_delta );
gain_table_fx[i] = shl( gain_table_fx[i], sub( 14, Qgt ) ); /* Qgt -> Q14 */
+ move16();
}
FOR( k = sub( bands, Ngq ); k < bands; k++ )
@@ -3937,8 +3859,8 @@ static void mdct_spectrum_fine_gain_enc_ivas_fx(
L_temp = L_deposit_l( 0 );
FOR( i = band_start[k_sort[k]]; i <= band_end[k_sort[k]]; i++ )
{
- L_temp = L_or( L_temp, L_abs( L_y2[i] ) );
- L_temp = L_or( L_temp, L_abs( L_ybuf[i] ) );
+ L_temp = L_or( L_temp, L_abs( L_y2[i] ) ); /* Q12 */
+ L_temp = L_or( L_temp, L_abs( L_ybuf[i] ) ); /* Q12 */
}
exp_norm = norm_l( L_temp );
exp_norm = sub( exp_norm, exp_safe ); /* safe_shift */
@@ -3949,12 +3871,12 @@ static void mdct_spectrum_fine_gain_enc_ivas_fx(
FOR( i = band_start[k_sort[k]]; i <= band_end[k_sort[k]]; i++ )
{
/*Eyy += y2[i] * y2[i]; */
- temp_fx = round_fx( L_shl( L_y2[i], exp_norm ) );
- L_Eyy = L_mac( L_Eyy, temp_fx, temp_fx );
+ temp_fx = round_fx( L_shl( L_y2[i], exp_norm ) ); /* Q12 + exp_norm - 16 */
+ L_Eyy = L_mac( L_Eyy, temp_fx, temp_fx ); /* (Q12 + exp_norm - 16)*2 + 1 */
/*Exy += ybuf[i] * y2[i]; */
- temp2_fx = round_fx( L_shl( L_ybuf[i], exp_norm ) );
- L_Exy = L_mac( L_Exy, temp2_fx, temp_fx );
+ temp2_fx = round_fx( L_shl( L_ybuf[i], exp_norm ) ); /* Q12 + exp_norm - 16 */
+ L_Exy = L_mac( L_Exy, temp2_fx, temp_fx ); /* (Q12 + exp_norm - 16)*2 + 1 */
}
test();
@@ -3964,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 ) );
-#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 */
+ 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 */
+ 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();
@@ -3978,18 +3896,18 @@ static void mdct_spectrum_fine_gain_enc_ivas_fx(
move16();
FOR( i = 0; i < gqlevs; i++ )
{
- d_fx = abs_s( sub( gamma_fx, gain_table_fx[i] ) );
+ d_fx = abs_s( sub( gamma_fx, gain_table_fx[i] ) ); /* Q14 */
IF( LT_16( d_fx, dmin_fx ) )
{
- dmin_fx = d_fx;
+ dmin_fx = d_fx; /* Q14 */
move16();
- imin_fx = i;
+ imin_fx = i; /* Q0 */
move16();
}
}
- gamma_fx = gain_table_fx[imin_fx];
- move16(); /* Q14 */
+ gamma_fx = gain_table_fx[imin_fx]; /* Q14 */
+ move16();
FOR( i = band_start[k_sort[k]]; i <= band_end[k_sort[k]]; i++ )
{
@@ -3997,11 +3915,13 @@ static void mdct_spectrum_fine_gain_enc_ivas_fx(
/* This IF statement for keeping same mantissa evenif y2 is plus or minus */
IF( L_y2[i] >= 0x0 )
{
- L_y2[i] = L_shl( Mpy_32_16_1( L_y2[i], gamma_fx ), 1 );
+ L_y2[i] = L_shl( Mpy_32_16_1( L_y2[i], gamma_fx ), 1 ); /* Q12 */
+ move32();
}
ELSE
{
- L_y2[i] = L_negate( L_shl( Mpy_32_16_1( L_abs( L_y2[i] ), gamma_fx ), 1 ) );
+ L_y2[i] = L_negate( L_shl( Mpy_32_16_1( L_abs( L_y2[i] ), gamma_fx ), 1 ) ); /* Q12 */
+ move32();
}
}
}
diff --git a/lib_enc/hvq_enc_fx.c b/lib_enc/hvq_enc_fx.c
index aae437c01c68bfdc0b68272e2d7a9c66da6077cb..5414329e2360335f49d5fbbb93d34f28d1decafb 100644
--- a/lib_enc/hvq_enc_fx.c
+++ b/lib_enc/hvq_enc_fx.c
@@ -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,13 +146,9 @@ 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] );
move16();
}
@@ -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
{
@@ -311,11 +295,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,12 +322,8 @@ 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] );
}
ELSE
@@ -374,22 +350,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
{
diff --git a/lib_enc/igf_enc.c b/lib_enc/igf_enc.c
index 4fa98f20bfbd8f3c6339e546163407e4005a3762..c15c6866657d1b7c26783976a8d66dc552edce4c 100644
--- a/lib_enc/igf_enc.c
+++ b/lib_enc/igf_enc.c
@@ -184,7 +184,7 @@ static Word16 IGF_getSFM_new_fx(
const Word16 *logSpec, /* i : log of power spectrum */
const Word16 start, /* i : start subband index */
const Word16 stop, /* i : stop subband index */
- Word16 e_ps /*Stores exp related to power spectrum*/
+ Word16 *e_ps /*Stores exp related to power spectrum*/
)
{
Word16 n;
@@ -215,7 +215,7 @@ static Word16 IGF_getSFM_new_fx(
move32();
move16();
num = add( num, n );
- denom = BASOP_Util_Add_Mant32Exp( tmp, e_ps, denom, denom_e, &denom_e );
+ denom = BASOP_Util_Add_Mant32Exp( tmp, e_ps[i], denom, denom_e, &denom_e );
}
numf = BASOP_Util_Divide1616_Scale( num, sub( stop, start ), &numf_e );
@@ -232,8 +232,6 @@ static Word16 IGF_getSFM_new_fx(
return sfm;
}
-
-
/*-------------------------------------------------------------------*
* IGF_getTilt()
*
@@ -340,6 +338,94 @@ static Word32 IGF_getTNR_fx(
return tonalToNoise;
}
+static Word32 IGF_getTNR_ivas_fx(
+ const Word32 *powerSpectrum, /* i : energies */
+ const Word16 start, /* i : start subband index */
+ const Word16 stop, /* i : stop subband index */
+ const Word16 adap, /* i : SFB width adaptation */
+ Word16 *e_ps, /*Stores exponent for powerSpectrum*/
+ Word16 e_adap /*Stores exponent for adap*/
+)
+{
+ Word16 i;
+ Word16 width;
+ Word32 avg;
+ Word32 tonal;
+ Word16 tonal_e; /* holds exp for tonal*/
+ Word32 noise;
+ Word16 noise_e; /* holds exp for noise*/
+ Word32 tonalToNoise;
+ Word32 rootSpec[300];
+ Word16 rootSpec_e[300]; /*rootSpec_e[i] holds exp for rootSpec[i]*/
+ Word16 avg_e; /* holds exp for avg*/
+ Word16 tmp_e;
+ avg = 0;
+ tonal = 0;
+ noise = EPSILON_FX;
+ tonal_e = 0;
+ noise_e = 0;
+ avg_e = 0;
+ tmp_e = 0;
+ move32();
+ move32();
+ move32();
+ move16();
+ move16();
+ move16();
+ move16();
+
+ set32_fx( rootSpec, 0, 300 );
+ set16_fx( rootSpec_e, 0, 300 );
+
+ width = sub( stop, start );
+ FOR( i = start; i < stop; i++ )
+ {
+ rootSpec_e[( i - start )] = e_ps[i];
+ move16();
+ 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[( 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[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_sat( L_shl_sat( 1, sub( 15, normSpec_e ) ), L_shl_sat( adap, sub( e_adap, normSpec_e ) ) ) ) )
+ {
+ 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_sat( 1, sub( 15, normSpec_e ) ) ) )
+ {
+ noise = BASOP_Util_Add_Mant32Exp( noise, noise_e, rootSpec[( i - start )], rootSpec_e[( i - start )], &noise_e ); /*noise += rootSpec[i - start];*/
+ }
+ }
+
+ /*tonalToNoise = 20.f * log10f( max( 1e-018f, tonal / noise ) )*/
+ 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 );
+ }
+ ELSE
+ {
+ Word16 temp = BASOP_Util_Divide3232_Scale( tonal, noise, &tmp_e ); /*tonal / noise*/
+ tmp_e = add( tmp_e, sub( tonal_e, noise_e ) );
+ IF( GE_16( temp, 1 ) )
+ {
+ tonalToNoise = imult3216( Mult_32_16( L_add( BASOP_Util_Log2( temp ), L_shl( add( 16, tmp_e ), Q25 ) ) /*Q25*/, INV_Log2_10_Q12 ) /*25+12-15*/, 20 ); /*Q22*/
+ }
+ ELSE
+ {
+ tonalToNoise = -1509949440; /*-360.f Q22*/
+ move32();
+ }
+ }
+
+ return tonalToNoise;
+}
/*-------------------------------------------------------------------*
* IGF_CalculateEnvelope()
@@ -352,7 +438,7 @@ static void IGF_CalculateEnvelope_ivas_fx(
Word32 *pMDCTSpectrum_fx, /* i : MDCT spectrum */
Word16 e_mdct, /* i : exp of MDCT spectrum */
Word32 *pPowerSpectrum_fx, /* i : MDCT^2 + MDST^2 spectrum, or estimate */
- Word16 e_ps, /* i : exp of power spectrum */
+ Word16 *e_ps, /* i : exp of power spectrum */
const Word16 igfGridIdx, /* i : IGF grid index */
const Word16 isTransient, /* i : flag indicating if transient is detected */
const Word16 last_core_acelp, /* i : indicator if last frame was ACELP core */
@@ -438,7 +524,7 @@ static void IGF_CalculateEnvelope_ivas_fx(
{
IF( LT_32( 1, pPowerSpectrum_fx[sb] ) )
{
- hPrivateData->logSpec[sb] = s_max( 0, (Word16) L_shr( L_add( BASOP_Util_Log2( pPowerSpectrum_fx[sb] ), L_shl( e_ps, Q25 ) ), Q25 ) );
+ hPrivateData->logSpec[sb] = s_max( 0, (Word16) L_shr( L_add( BASOP_Util_Log2( pPowerSpectrum_fx[sb] ), L_shl( e_ps[sb], Q25 ) ), Q25 ) );
move16();
}
ELSE
@@ -477,14 +563,16 @@ static void IGF_CalculateEnvelope_ivas_fx(
move16();
FOR( sb = swb_offset[sfb]; sb < swb_offset[sfb + 1]; sb++ )
{
- sfbEnergyC = BASOP_Util_Add_Mant32Exp( sfbEnergyC, sfbEnergyC_e, pPowerSpectrum_fx[sb], e_ps, &sfbEnergyC_e );
+ Word16 shift = norm_l( pPowerSpectrum_fx[sb] );
+ sfbEnergyC = BASOP_Util_Add_Mant32Exp( sfbEnergyC, sfbEnergyC_e, L_shl( pPowerSpectrum_fx[sb], shift ), sub( e_ps[sb], shift ), &sfbEnergyC_e );
// sfbEnergyTileR = BASOP_Util_Add_Mant32Exp( sfbEnergyTileR, sfbEnergyTileR_e, Mult_32_32( pMDCTSpectrum_fx[strt_cpy], pMDCTSpectrum_fx[strt_cpy] ), shl( e_mdct, 1 ), &sfbEnergyTileR_e );
Word64 tmp64 = W_mult_32_32( pMDCTSpectrum_fx[strt_cpy], pMDCTSpectrum_fx[strt_cpy] );
Word16 tmp64_e = W_norm( tmp64 );
tmp64 = W_shl( tmp64, tmp64_e );
sfbEnergyTileR = BASOP_Util_Add_Mant32Exp( sfbEnergyTileR, sfbEnergyTileR_e, W_extract_h( tmp64 ), shl( e_mdct, 1 ) - tmp64_e, &sfbEnergyTileR_e );
- sfbEnergyTileC = BASOP_Util_Add_Mant32Exp( sfbEnergyTileC, sfbEnergyTileC_e, pPowerSpectrum_fx[strt_cpy], e_ps, &sfbEnergyTileC_e );
+ shift = norm_l( pPowerSpectrum_fx[strt_cpy] );
+ sfbEnergyTileC = BASOP_Util_Add_Mant32Exp( sfbEnergyTileC, sfbEnergyTileC_e, L_shl( pPowerSpectrum_fx[strt_cpy], shift ), sub( e_ps[strt_cpy], shift ), &sfbEnergyTileC_e );
strt_cpy = add( strt_cpy, 1 );
}
@@ -615,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;
@@ -656,7 +744,7 @@ static void IGF_CalculateEnvelope_ivas_fx(
}
ELSE
{
- y = imult1616( 20, extract_l( L_shr( Mult_32_16( ( L_add( BASOP_Util_Log2( pPowerSpectrum_fx[sb] ), L_shl( e_ps, Q25 ) ) ), INV_Log2_10_Q15 ), Q25 ) ) ); /*Q0*/
+ 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*/
}
mean_y_fx_tmp = L_mac0( mean_y_fx_tmp, y, 1 ); /*Q0*/
mean_xy_fx = L_add( mean_xy_fx, L_mult0( y, x ) ); /*Q0*/
@@ -728,7 +816,7 @@ static void IGF_CalculateEnvelope_ivas_fx(
tonalToNoise_e = 9;
move16();
adap = BASOP_Util_Divide1616_Scale( width, 40, &adap_e );
- tonalToNoise = IGF_getTNR_fx( pPowerSpectrum_fx, swb_offset[sfb], swb_offset[sfb + 1], adap, e_ps, adap_e ); /*Q22*/
+ tonalToNoise = IGF_getTNR_ivas_fx( pPowerSpectrum_fx, swb_offset[sfb], swb_offset[sfb + 1], adap, e_ps, adap_e ); /*Q22*/
IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( tonalToNoise, tonalToNoise_e, L_add( L_shl( 10, sub( 15, adap_e ) ), adap ), add( 16, adap_e ) ), -1 ) )
{
@@ -1250,7 +1338,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 );
@@ -1590,7 +1681,7 @@ static void IGF_Whitening_ivas_fx(
IF( LT_32( powerSpectrum[sb], 1 ) )
hPrivateData->logSpec[sb] = 0; /* max(0,FLT_MIN_EXP )*/
ELSE
- hPrivateData->logSpec[sb] = extract_l( L_max( 0, L_shr( L_add( BASOP_Util_Log2( powerSpectrum[sb] ), L_shl( *powerSpectrum_e, Q25 ) ), Q25 ) ) );
+ hPrivateData->logSpec[sb] = extract_l( L_max( 0, L_shr( L_add( BASOP_Util_Log2( powerSpectrum[sb] ), L_shl( powerSpectrum_e[sb], Q25 ) ), Q25 ) ) );
move16();
}
}
@@ -1606,7 +1697,7 @@ static void IGF_Whitening_ivas_fx(
}
ELSE
{
- tmp = BASOP_Util_Divide1616_Scale( IGF_getSFM_new_fx( powerSpectrum, hPrivateData->logSpec, hGrid->tile[p], hGrid->tile[p + 1], *powerSpectrum_e ), IGF_getCrest_new_fx( hPrivateData->logSpec, hGrid->tile[p], hGrid->tile[p + 1], &crest_e ), &tmp_e );
+ tmp = BASOP_Util_Divide1616_Scale( IGF_getSFM_new_fx( powerSpectrum, hPrivateData->logSpec, hGrid->tile[p], hGrid->tile[p + 1], powerSpectrum_e ), IGF_getCrest_new_fx( hPrivateData->logSpec, hGrid->tile[p], hGrid->tile[p + 1], &crest_e ), &tmp_e );
tmp_e = sub( tmp_e, crest_e );
}
@@ -2487,7 +2578,7 @@ void IGFEncApplyMono_ivas_fx(
Word32 *pMDCTSpectrum_fx, /* i/o: MDCT spectrum */
Word16 e_mdct, /* i : exponent of pMDCTspectrum */
Word32 *pPowerSpectrum_fx, /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */
- Word16 e_ps, /* i : exponent of pPowerSpectrum */
+ Word16 *e_ps, /* i : exponent of pPowerSpectrum */
const Word16 isTCX20, /* i : flag indicating if the input is TCX20 or TCX10/2xTCX5 */
const Word8 isTNSActive, /* i : flag indicating if the TNS is active */
const Word16 sp_aud_decision0, /* i : first stage switching decision */
@@ -2495,11 +2586,20 @@ void IGFEncApplyMono_ivas_fx(
)
{
Word32 *pPowerSpectrumParameter_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 )
{
@@ -2516,10 +2616,12 @@ void IGFEncApplyMono_ivas_fx(
IF( !isTNSActive && isTCX20 )
{
pPowerSpectrumParameter_fx = pPowerSpectrum_fx;
+ pPowerSpectrumParameter_exp = e_ps;
}
ELSE
{
pPowerSpectrumParameter_fx = NULL;
+ pPowerSpectrumParameter_exp = NULL;
}
IGF_UpdateInfo( st->hIGFEnc, igfGridIdx );
@@ -2530,28 +2632,43 @@ void IGFEncApplyMono_ivas_fx(
calculate_hangover_attenuation_gain_ivas_fx( st, &att_fx, vad_hover_flag );
}
- IGF_CalculateEnvelope_ivas_fx( st->hIGFEnc, pMDCTSpectrum_fx, e_mdct, pPowerSpectrumParameter_fx, e_ps, igfGridIdx, st->hTranDet->transientDetector.bIsAttackPresent, last_core_acelp, st->element_mode, att_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;
+ pPowerSpectrumParameter_exp = e_ps;
}
ELSE
{
pPowerSpectrumParameter_fx = NULL;
+ pPowerSpectrumParameter_exp = NULL;
}
IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) )
{
- IGF_Whitening_ivas_fx( st->hIGFEnc, pPowerSpectrumParameter_fx, &e_ps, igfGridIdx, st->hTranDet->transientDetector.bIsAttackPresent, last_core_acelp, isTNSActive, sp_aud_decision0, st->element_brate, st->element_mode );
+ IGF_Whitening_ivas_fx( st->hIGFEnc, pPowerSpectrumParameter_fx, pPowerSpectrumParameter_exp, igfGridIdx, st->hTranDet->transientDetector.bIsAttackPresent, last_core_acelp, isTNSActive, sp_aud_decision0, st->element_brate, st->element_mode );
}
ELSE
{
- IGF_Whitening_ivas_fx( st->hIGFEnc, pPowerSpectrumParameter_fx, &e_ps, igfGridIdx, st->hTranDet->transientDetector.bIsAttackPresent, last_core_acelp, isTNSActive, sp_aud_decision0, st->total_brate, st->element_mode );
+ IGF_Whitening_ivas_fx( st->hIGFEnc, pPowerSpectrumParameter_fx, pPowerSpectrumParameter_exp, igfGridIdx, st->hTranDet->transientDetector.bIsAttackPresent, last_core_acelp, isTNSActive, sp_aud_decision0, st->total_brate, st->element_mode );
}
- IGF_ErodeSpectrum( &highPassEner_exp, st->hIGFEnc, pMDCTSpectrum_fx, pPowerSpectrumParameter_fx, e_ps, igfGridIdx );
+ IF( pPowerSpectrumParameter_fx )
+ {
+ FOR( Word16 i = 0; i < N_MAX + L_MDCT_OVLP_MAX; i++ )
+ {
+ common_pPowerSpectrum_exp = s_max( common_pPowerSpectrum_exp, pPowerSpectrumParameter_exp[i] );
+ }
+
+ FOR( Word16 i = 0; i < N_MAX + L_MDCT_OVLP_MAX; i++ )
+ {
+ common_pPowerSpectrum_fx[i] = L_shl( common_pPowerSpectrum_fx[i], sub( pPowerSpectrumParameter_exp[i], common_pPowerSpectrum_exp ) );
+ move16();
+ }
+ }
+ IGF_ErodeSpectrum_ivas_fx( &highPassEner_exp, st->hIGFEnc, pMDCTSpectrum_fx, pPowerSpectrumParameter_fx, common_pPowerSpectrum_exp, igfGridIdx, 0 );
}
@@ -2572,8 +2689,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 )
{
Word16 highPassEner_exp;
Word32 *pPowerSpectrumParameter_fx[NB_DIV]; /* If it is NULL it informs a function that specific handling is needed */
@@ -2581,6 +2698,7 @@ void IGFEncApplyStereo_fx(
Word16 coreMsMask[N_MAX];
Word16 sfb, ch, last_core_acelp;
STEREO_MDCT_BAND_PARAMETERS *sfbConf;
+ Word16 exp_pPowerSpectrum[L_FRAME48k];
/* assumptions: stereo filling was already done on the flattened spectra
* IGF region is always coded M/S, never L/R (to be done in the encoder)
@@ -2644,9 +2762,11 @@ void IGFEncApplyStereo_fx(
pPowerSpectrumParameter_fx[ch] = NULL;
}
- IGF_Whitening_ivas_fx( hIGFEnc[ch], pPowerSpectrumParameter_fx[ch], &sts[ch]->hTcxEnc->spectrum_e[frameno], 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 );
+ set16_fx( exp_pPowerSpectrum, sts[ch]->hTcxEnc->spectrum_e[frameno], L_FRAME48k );
+
+ IGF_Whitening_ivas_fx( hIGFEnc[ch], pPowerSpectrumParameter_fx[ch], &exp_pPowerSpectrum[0], igfGridIdx, sts[ch]->hTranDet->transientDetector.bIsAttackPresent, last_core_acelp, ( sts[0]->hTcxEnc->fUseTns[frameno] || sts[1]->hTcxEnc->fUseTns[frameno] ), sp_aud_decision0, element_brate, sts[ch]->element_mode );
- IGF_ErodeSpectrum( &highPassEner_exp, hIGFEnc[ch], sts[ch]->hTcxEnc->spectrum_fx[frameno], pPowerSpectrumParameter_fx[ch], sts[ch]->hTcxEnc->spectrum_e[frameno], igfGridIdx );
+ IGF_ErodeSpectrum_ivas_fx( &highPassEner_exp, hIGFEnc[ch], sts[ch]->hTcxEnc->spectrum_fx[frameno], pPowerSpectrumParameter_fx[ch], sts[ch]->hTcxEnc->spectrum_e[frameno], igfGridIdx, mct_on );
}
return;
}
@@ -2661,13 +2781,18 @@ void IGFEncApplyStereo_fx(
void IGFSaveSpectrumForITF_ivas_fx(
IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i/o: instance handle of IGF Encoder */
const Word16 igfGridIdx, /* i : IGF grid index */
- const Word32 *pITFSpectrum /* i : MDCT spectrum */
-)
+ const Word32 *pITFSpectrum, /* i : MDCT spectrum */
+ Word16 exp_pITFSpectrum )
{
IGF_UpdateInfo( hIGFEnc, igfGridIdx );
Copy32( pITFSpectrum + IGF_START_MN, hIGFEnc->spec_be_igf, sub( hIGFEnc->infoStopLine, IGF_START_MN ) );
+ scale_sig32( hIGFEnc->spec_be_igf, sub( hIGFEnc->infoStopLine, IGF_START_MN ), sub( exp_pITFSpectrum, s_max( exp_pITFSpectrum, hIGFEnc->spec_be_igf_e ) ) );
+ scale_sig32( hIGFEnc->spec_be_igf + sub( hIGFEnc->infoStopLine, IGF_START_MN ), sub( N_MAX_TCX - IGF_START_MN, sub( hIGFEnc->infoStopLine, IGF_START_MN ) ), sub( hIGFEnc->spec_be_igf_e, s_max( exp_pITFSpectrum, hIGFEnc->spec_be_igf_e ) ) );
+ hIGFEnc->spec_be_igf_e = s_max( exp_pITFSpectrum, hIGFEnc->spec_be_igf_e );
+ move16();
+
return;
}
diff --git a/lib_enc/igf_enc_fx.c b/lib_enc/igf_enc_fx.c
index f0d83e41638f29ab714154ca905d259a68a90acf..9e38d4d6cdefa19275cfebb90d2fd1825e568676 100644
--- a/lib_enc/igf_enc_fx.c
+++ b/lib_enc/igf_enc_fx.c
@@ -218,23 +218,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 +234,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 +247,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 );
@@ -440,17 +412,9 @@ void IGF_ErodeSpectrum( Word16 *highPassEner_exp, /**< ou
FOR( i = 0; i < igfBgn; i++ )
{
Carry = 0;
-#ifdef BASOP_NOGLOB
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
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*/
@@ -473,15 +437,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 +450,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,11 +475,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 )
{
@@ -567,6 +516,199 @@ void IGF_ErodeSpectrum( Word16 *highPassEner_exp, /**< ou
}
}
+void IGF_ErodeSpectrum_ivas_fx( Word16 *highPassEner_exp, /**< out: | exponent of highPassEner */
+ 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;
+ Word32 L_c;
+ Word32 highPassEner_Ovfl;
+ Word16 s;
+ Word16 tmploop;
+ Word16 *swb_offset;
+ Word16 sfb;
+ Word16 startSfb;
+ Word16 stopSfb;
+ Word16 line;
+ Word16 flag;
+ Word16 *igfScaleF;
+ Word16 tmp;
+ Word32 L_tmp;
+
+#ifdef BASOP_NOGLOB_DECLARE_LOCAL
+ Flag Overflow = 0;
+ Flag Carry = 0;
+ move32();
+ move32();
+#endif
+
+ 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();
+ *highPassEner_exp = 0;
+ move16();
+ highPassEner = 0;
+ move32();
+
+ IF( NULL == pPowerSpectrum )
+ {
+ FOR( i = igfBgn; i < hGrid->infoGranuleLen; i++ )
+ {
+ pSpectrum[i] = 0;
+ move32();
+ }
+ return;
+ }
+
+ IF( igfBgn > 0 )
+ {
+ L_c = 0;
+ move32();
+ FOR( i = 0; i < igfBgn; i++ )
+ {
+ Carry = 0;
+ highPassEner = L_add_co( highPassEner, Mpy_32_16_1( pPowerSpectrum[i], shl( i, 4 ) /*Q4*/ ) /*Q20, pPowerSpectrum_exp*/, &Carry, &Overflow );
+ Overflow = 0;
+ L_c = L_macNs_co( L_c, 0, 0, &Carry, &Overflow );
+ }
+
+ highPassEner = norm_llQ31( L_c, highPassEner, highPassEner_exp ); /*Q20, highPassEner_exp*/
+ *highPassEner_exp = add( *highPassEner_exp, pPowerSpectrum_exp );
+ test();
+ test();
+ test();
+ test();
+ test();
+ 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 ) )
+ {
+ igfBgn = shl( igfBgn, 0 );
+ }
+ ELSE IF( mct_on && ( EQ_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_SWB_48000_CPE ) || EQ_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_SWB_64000_CPE ) ) )
+ {
+ igfBgn = imult1616( igfBgn, 45 /*0.7.Q6*/ );
+ igfBgn = shr( igfBgn, 7 );
+ }
+ ELSE
+ {
+ igfBgn = shl( igfBgn, 1 );
+ }
+ highPassEner = L_deposit_l( BASOP_Util_Divide3216_Scale( highPassEner /*Q20, highPassEner_exp*/, igfBgn /*Q0*/, &s ) ); /*Q15, highPassEner_exp+11-16+s*/
+ *highPassEner_exp = add( add( *highPassEner_exp, s ), 12 - 16 + ( 31 - 15 ) ); /*Q15->Q31,highPassEner_exp*/
+ lastLine = pSpectrum[i - 1];
+ move32();
+ nextLine = 0;
+ move32();
+
+ /* 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 */
+ 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 );
+
+ if ( L_tmp >= 0 )
+ {
+ nextLine = pSpectrum[i];
+ move32();
+ }
+ tmploop = sub( igfEnd, 1 );
+ FOR( /*i*/; i < tmploop; i++ )
+ {
+ /* May overflow - just for threshold comparison */
+ BASOP_SATURATE_WARNING_OFF_EVS
+ L_tmp = L_add_sat( pPowerSpectrum[i], highPassEner_Ovfl );
+ BASOP_SATURATE_WARNING_ON_EVS;
+
+ IF( L_tmp < 0 )
+ {
+ lastLine = pSpectrum[i];
+ move32();
+ pSpectrum[i] = nextLine;
+ move32();
+ nextLine = 0;
+ move32();
+ }
+ ELSE
+ {
+ pSpectrum[i - 1] = lastLine;
+ move32();
+ lastLine = pSpectrum[i];
+ move32();
+ nextLine = pSpectrum[i + 1];
+ move32();
+ }
+ }
+
+ /* May overflow - just for threshold comparison */
+ BASOP_SATURATE_WARNING_OFF_EVS
+ L_tmp = L_add_sat( pPowerSpectrum[i], highPassEner_Ovfl );
+ BASOP_SATURATE_WARNING_ON_EVS
+ if ( L_tmp < 0 )
+ {
+ pSpectrum[i] = 0;
+ move32();
+ }
+ }
+
+ /* delete spectrum above igfEnd: */
+ FOR( i = igfEnd; i < hGrid->infoGranuleLen; i++ )
+ {
+ pSpectrum[i] = 0;
+ pPowerSpectrum[i] = 0;
+ move32();
+ move32();
+ }
+
+ FOR( sfb = startSfb; sfb < stopSfb; sfb++ )
+ {
+ flag = 0;
+ move16();
+ FOR( line = swb_offset[sfb]; line < swb_offset[sfb + 1]; line++ )
+ {
+ if ( pSpectrum[line] != 0 )
+ {
+ flag = 1;
+ move16();
+ }
+ }
+ tmp = igfScaleF[sfb];
+ move16();
+ IF( flag )
+ {
+ tmp = sub( igfScaleF[sfb], 1 );
+ }
+ if ( igfScaleF[sfb] )
+ {
+ igfScaleF[sfb] = tmp;
+ move16();
+ }
+ }
+}
+
/**********************************************************************/ /*
crest factor calculation
**************************************************************************/
@@ -633,13 +775,8 @@ Word16 IGF_getCrest( /**< ou
/* 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 )
{
@@ -712,18 +849,10 @@ Word16 IGF_getSFM( /**< out: Q15| SFM value
num = L_add( num, L_deposit_l( n ) ); /*Q0*/
Carry = 0;
-#ifdef BASOP_NOGLOB
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
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,11 +888,7 @@ 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 );
/**SFM_exp = s_min(*SFM_exp, 0);*/
@@ -875,13 +1000,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*/
diff --git a/lib_enc/igf_scf_enc.c b/lib_enc/igf_scf_enc.c
index 5ac4f4e3e9c278705e73817d0c46402ae38b93bb..04ca67979f1eb2a809bf66b850d15804691b9c61 100644
--- a/lib_enc/igf_scf_enc.c
+++ b/lib_enc/igf_scf_enc.c
@@ -93,11 +93,11 @@ static void arith_encode_bits(
FOR( i = nBits - 1; i >= 0; --i ) /* nBits > 0 */
{
bit = s_and( shr( x, i ), 1 );
- hPrivateData->ptrBitIndex = ari_encode_14bits_sign( ptr,
- hPrivateData->ptrBitIndex,
- 32767, /* disable the bit count limitation */
- &hPrivateData->acState,
- bit );
+ hPrivateData->ptrBitIndex = ari_encode_14bits_sign_ivas_fx( ptr,
+ hPrivateData->ptrBitIndex,
+ 32767, /* disable the bit count limitation */
+ &hPrivateData->acState,
+ bit );
}
}
@@ -128,11 +128,11 @@ static void arith_encode_residual(
{
x = sub( x, IGF_MIN_ENC_SEPARATE - 1 ); /* (x - IGF_MIN_ENC_SEPARATE) + 1 */
/* encode one of the IGF_SYMBOLS_IN_TABLE == 27 alphabet symbols using the new raw AC function */
- hPrivateData->ptrBitIndex = ari_encode_14bits_ext( ptr,
- hPrivateData->ptrBitIndex,
- &hPrivateData->acState,
- x,
- cumulativeFrequencyTable );
+ hPrivateData->ptrBitIndex = ari_encode_14bits_ext_ivas_fx( ptr,
+ hPrivateData->ptrBitIndex,
+ &hPrivateData->acState,
+ x,
+ cumulativeFrequencyTable );
return;
}
@@ -141,21 +141,21 @@ static void arith_encode_residual(
{
/* send escape code 0 to indicate x <= IGF_MIN_ENC_SEPARATE - 1 */
extra = sub( IGF_MIN_ENC_SEPARATE - 1, x );
- hPrivateData->ptrBitIndex = ari_encode_14bits_ext( ptr,
- hPrivateData->ptrBitIndex,
- &hPrivateData->acState,
- 0,
- cumulativeFrequencyTable );
+ hPrivateData->ptrBitIndex = ari_encode_14bits_ext_ivas_fx( ptr,
+ hPrivateData->ptrBitIndex,
+ &hPrivateData->acState,
+ 0,
+ cumulativeFrequencyTable );
}
ELSE /* x > IGF_MAX_ENC_SEPARATE */
{
/* send escape code (IGF_SYMBOLS_IN_TABLE - 1) to indicate x >= IGF_MAX_ENC_SEPARATE + 1 */
extra = sub( x, IGF_MAX_ENC_SEPARATE + 1 );
- hPrivateData->ptrBitIndex = ari_encode_14bits_ext( ptr,
- hPrivateData->ptrBitIndex,
- &hPrivateData->acState,
- IGF_SYMBOLS_IN_TABLE - 1,
- cumulativeFrequencyTable );
+ hPrivateData->ptrBitIndex = ari_encode_14bits_ext_ivas_fx( ptr,
+ hPrivateData->ptrBitIndex,
+ &hPrivateData->acState,
+ IGF_SYMBOLS_IN_TABLE - 1,
+ cumulativeFrequencyTable );
}
/* encode one of the tails of the distribution */
@@ -221,11 +221,11 @@ static void encode_sfe_vector(
{
/* (t == 0) && (f == 0) */
/* encode one of the IGF_SYMBOLS_IN_TABLE == 27 alphabet symbols using the new raw AC function */
- hPrivateData->ptrBitIndex = ari_encode_14bits_ext( ptr,
- hPrivateData->ptrBitIndex,
- &hPrivateData->acState,
- shr( x[f], 2 ),
- (const UWord16 *) hPrivateData->cf_se00 );
+ hPrivateData->ptrBitIndex = ari_encode_14bits_ext_ivas_fx( ptr,
+ hPrivateData->ptrBitIndex,
+ &hPrivateData->acState,
+ shr( x[f], 2 ),
+ (const UWord16 *) hPrivateData->cf_se00 );
arith_encode_bits( hPrivateData, ptr, x[f] & 3, 2 ); /* LSBs as 2 bit raw */
}
ELSE IF( EQ_16( f, 1 ) )
@@ -298,7 +298,7 @@ Word16 IGFSCFEncoderEncode(
encode_sfe_vector( hPublicData, ptr, hPublicData->t, hPublicData->prev, sfe, hPublicData->scfCountLongBlock[igfGridIdx] );
- hPublicData->ptrBitIndex = ari_done_encoding_14bits( ptr, hPublicData->ptrBitIndex, &hPublicData->acState ); /* finish AC encoding */
+ hPublicData->ptrBitIndex = ari_done_encoding_14bits_ivas_fx( ptr, hPublicData->ptrBitIndex, &hPublicData->acState ); /* finish AC encoding */
hPublicData->bitCount = add( hPublicData->bitCount, hPublicData->ptrBitIndex );
move16();
move16();
diff --git a/lib_enc/init_enc.c b/lib_enc/init_enc.c
index e7c66738847aeba5512e56f56b3fb895f45af8a3..7d046db5ff8c5601d00294cdb54ad60dd53717d3 100644
--- a/lib_enc/init_enc.c
+++ b/lib_enc/init_enc.c
@@ -1072,7 +1072,8 @@ ivas_error init_encoder_ivas_fx(
}
st->currEnergyHF_fx = 0;
move32();
-
+ st->currEnergyHF_e_fx = 0;
+ move16();
#ifdef MSAN_FIX
st->prevEnergyHF_fx = 0;
move32();
diff --git a/lib_enc/inov_enc_fx.c b/lib_enc/inov_enc_fx.c
index 725cad9132e818521df6c8cc3e363bcd326227ae..a2567535209f5e6777477e7da66811aa8bc78e3e 100644
--- a/lib_enc/inov_enc_fx.c
+++ b/lib_enc/inov_enc_fx.c
@@ -504,7 +504,7 @@ Word16 inov_encode_ivas_fx(
// Word16 Rw_e = E_ACELP_hh_corr( h2, Rw, L_SUBFR, 3 );
corr_hh_ivas_fx( h2, Rw, &Rw_q, L_subfr ); // Q(Rw) = Q11-2
- E_ACELP_conv_ivas( xn2, h2, cn ); // Qcn = Qxn2
+ E_ACELP_conv_ivas_fx( xn2, h2, cn ); // Qcn = Qxn2
/* dn_e -> Rw_e*Q_xn */
// Scale_sig(Rw, L_SUBFR, sub(5, Rw_e)); //Q9
diff --git a/lib_enc/ivas_agc_enc.c b/lib_enc/ivas_agc_enc.c
index 5caa4d0b991e9bc7000187791799913c5fb00250..dcc55f5ad00003a0d2d1a9dae89a19b9ab97905d 100644
--- a/lib_enc/ivas_agc_enc.c
+++ b/lib_enc/ivas_agc_enc.c
@@ -210,7 +210,7 @@ Word32 pow32_fx( Word16 inp, Word16 indx )
/*! r: AGC enable flag */
Word16 ivas_agc_enc_get_flag(
- const Word16 nchan_transport /* i : number of transport channels */
+ const Word16 nchan_transport /* i : number of transport channels Q0*/
)
{
Word16 agc_flag;
@@ -236,15 +236,16 @@ Word16 ivas_agc_enc_get_flag(
static void ivas_agc_enc_init_fx(
ivas_agc_enc_state_t *hAgcEnc,
- const Word16 input_frame,
- const Word16 nchan_inp,
- const Word16 delay )
+ const Word16 input_frame, /* Q0 */
+ const Word16 nchan_inp, /* Q0 */
+ const Word16 delay /* Q0 */
+)
{
Word16 i;
ivas_agc_enc_chan_state_t *ptrG = hAgcEnc->gain_state;
ivas_agc_chan_data_t *ptr = hAgcEnc->gain_data;
- hAgcEnc->agc_com.in_delay = delay;
+ hAgcEnc->agc_com.in_delay = delay; /* Q0 */
move16();
hAgcEnc->agc_com.num_coeff = FOA_CHANNELS;
move16();
@@ -284,9 +285,9 @@ static void ivas_agc_enc_init_fx(
ptrG++;
/* gain_data */
- ptr->absGainExp = hAgcEnc->agc_com.absEmin;
+ ptr->absGainExp = hAgcEnc->agc_com.absEmin; /* Q0 */
move16();
- ptr->absGainExpCurr = hAgcEnc->agc_com.absEmin;
+ ptr->absGainExpCurr = hAgcEnc->agc_com.absEmin; /* Q0 */
move16();
ptr++;
}
@@ -303,8 +304,8 @@ static void ivas_agc_enc_init_fx(
ivas_error ivas_spar_agc_enc_open_fx(
ivas_agc_enc_state_t **hAgcEnc, /* i/o: SPAR AGC encoder handle */
- const Word32 input_Fs, /* i : input sampling rate */
- const Word16 nchan_inp /* i : number of input channels */
+ const Word32 input_Fs, /* i : input sampling rate Q0*/
+ const Word16 nchan_inp /* i : number of input channels Q0*/
)
{
ivas_agc_enc_state_t *hAgc;
@@ -315,7 +316,7 @@ ivas_error ivas_spar_agc_enc_open_fx(
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR AGC encoder" );
}
- input_frame = extract_l( Mpy_32_16_1( input_Fs, INV_FRAME_PER_SEC_Q15 ) );
+ input_frame = extract_l( Mpy_32_16_1( input_Fs, INV_FRAME_PER_SEC_Q15 ) ); /* Q0 */
delay = NS2SA_FX2( input_Fs, ( IVAS_ENC_DELAY_NS + IVAS_DEC_DELAY_NS ) );
IF( ( hAgc->agc_com.winFunc_fx = (Word16 *) malloc( sizeof( Word16 ) * ( input_frame - delay ) ) ) == NULL )
@@ -386,9 +387,9 @@ void ivas_spar_agc_enc_close_fx(
void ivas_agc_enc_process_fx(
ivas_agc_enc_state_t *hAgcEnc, /* i/o: AGC encoder handle */
BSTR_ENC_HANDLE hMetaData, /* i/o: MetaData handle */
- Word32 **ppPcm_in, /* i : input audio channels */
- Word32 **ppPcm_out, /* o : output audio channels */
- const Word16 n_channels, /* i : number of channels */
+ Word32 **ppPcm_in, /* i : input audio channels q_ppPcm*/
+ Word32 **ppPcm_out, /* o : output audio channels q_ppPcm*/
+ const Word16 n_channels, /* i : number of channels Q0*/
const ENCODER_CONFIG_HANDLE hEncoderConfig, /* i : configuration structure */
Word16 *q_ppPcm )
{
@@ -400,8 +401,8 @@ void ivas_agc_enc_process_fx(
Word16 q_predMaxAbsVal, q_MaxAbsVal;
ivas_agc_enc_state_t *pState = hAgcEnc;
- input_frame = extract_l( Mpy_32_16_1( hEncoderConfig->input_Fs, INV_FRAME_PER_SEC_Q15 ) );
- offset = sub( input_frame, pState->agc_com.in_delay );
+ input_frame = extract_l( Mpy_32_16_1( hEncoderConfig->input_Fs, INV_FRAME_PER_SEC_Q15 ) ); /* Q0 */
+ offset = sub( input_frame, pState->agc_com.in_delay ); /* Q0 */
AGC_flag = 0;
move16();
@@ -429,20 +430,20 @@ void ivas_agc_enc_process_fx(
IF( LT_16( pState->gain_state[i].q_lastGain_fx, Q31 ) )
{
gain_norm = norm_l( L_abs( pState->gain_state[i].lastGain_fx ) );
- pState->gain_state[i].lastGain_fx = L_shl( pState->gain_state[i].lastGain_fx, gain_norm );
+ pState->gain_state[i].lastGain_fx = L_shl( pState->gain_state[i].lastGain_fx, gain_norm ); /* pState->gain_state[i].q_lastGain_fx + gain_norm */
move32();
pState->gain_state[i].q_lastGain_fx = add( pState->gain_state[i].q_lastGain_fx, gain_norm );
move16();
}
FOR( j = 0; j < input_frame; j++ )
{
- sampleAbsVal = L_abs( ppPcm_in[i][j] );
+ sampleAbsVal = L_abs( ppPcm_in[i][j] ); /* q_ppPcm */
q_sampleAbsVal = q_ppPcm[i];
move16();
IF( EQ_16( BASOP_Util_Cmp_Mant32Exp_sat( sampleAbsVal, sub( Q31, q_sampleAbsVal ), MaxAbsVal, sub( Q31, q_MaxAbsVal ) ), 1 ) )
{
- MaxAbsVal = sampleAbsVal;
+ MaxAbsVal = sampleAbsVal; /* q_sampleAbsVal */
move32();
q_MaxAbsVal = q_sampleAbsVal;
move16();
@@ -454,14 +455,14 @@ void ivas_agc_enc_process_fx(
{
IF( EQ_16( BASOP_Util_Cmp_Mant32Exp_sat( sampleAbsVal, sub( Q31, q_sampleAbsVal ), predMaxAbsVal, sub( Q31, q_predMaxAbsVal ) ), 1 ) )
{
- predMaxAbsVal = sampleAbsVal;
+ predMaxAbsVal = sampleAbsVal; /* q_sampleAbsVal */
move32();
q_predMaxAbsVal = q_sampleAbsVal;
move16();
}
}
- ppPcm_out[i][j] = Mpy_32_32( ppPcm_in[i][j], pState->gain_state[i].lastGain_fx );
+ ppPcm_out[i][j] = Mpy_32_32( ppPcm_in[i][j], pState->gain_state[i].lastGain_fx ); /* q_ppPcm + State->gain_state[i].q_lastGain_fx - 31 */
move32();
q_pcm = add( q_ppPcm[i], sub( pState->gain_state[i].q_lastGain_fx, Q31 ) );
IF( !isClipped )
@@ -501,7 +502,7 @@ void ivas_agc_enc_process_fx(
}
}
- pState->gain_state[i].MaxAbsVal_del_fx = predMaxAbsVal;
+ pState->gain_state[i].MaxAbsVal_del_fx = predMaxAbsVal; /* q_predMaxAbsVal */
move32();
pState->gain_state[i].q_MaxAbsVal_del_fx = q_predMaxAbsVal;
move16();
@@ -537,10 +538,10 @@ void ivas_agc_enc_process_fx(
temp1 = Mpy_32_32( pState->smFact_fx, MaxAbsVal ); // q_MaxAbsVal
temp2 = Mpy_32_32( ( L_sub( ONE_IN_Q31, pState->smFact_fx ) ), pState->gain_state[i].lastMaxAbs_fx ); // q_lastMaxAbs_fx
- smoothedMaxAbsVal = BASOP_Util_Add_Mant32Exp( temp1, sub( Q31, q_MaxAbsVal ), temp2, sub( Q31, pState->gain_state[i].q_lastMaxAbs_fx ), &e_result );
+ smoothedMaxAbsVal = BASOP_Util_Add_Mant32Exp( temp1, sub( Q31, q_MaxAbsVal ), temp2, sub( Q31, pState->gain_state[i].q_lastMaxAbs_fx ), &e_result ); /* exp(e_result) */
q_smoothedMaxAbsVal = sub( Q31, e_result );
- pState->gain_state[i].lastMaxAbs_fx = smoothedMaxAbsVal;
+ pState->gain_state[i].lastMaxAbs_fx = smoothedMaxAbsVal; /* q_smoothedMaxAbsVal */
move32();
pState->gain_state[i].q_lastMaxAbs_fx = q_smoothedMaxAbsVal;
move16();
@@ -548,7 +549,7 @@ void ivas_agc_enc_process_fx(
Comp_flag = BASOP_Util_Cmp_Mant32Exp_sat( smoothedMaxAbsVal, sub( Q31, q_smoothedMaxAbsVal ), MaxAbsVal, sub( Q31, q_MaxAbsVal ) );
IF( EQ_16( Comp_flag, 1 ) )
{
- temp1 = smoothedMaxAbsVal;
+ temp1 = smoothedMaxAbsVal; /* q_smoothedMaxAbsVal */
move32();
q_temp = q_smoothedMaxAbsVal;
move16();
@@ -560,9 +561,9 @@ void ivas_agc_enc_process_fx(
q_temp = q_MaxAbsVal;
move16();
}
- temp1 = Mpy_32_32( temp1, TWO_IN_Q29 );
+ temp1 = Mpy_32_32( temp1, TWO_IN_Q29 ); /* q_temp + 29 - 31 */
q_temp = add( q_temp, Q29 - Q31 );
- maxGain = Mpy_32_32( temp1, pState->gain_state[i].lastGain_fx );
+ maxGain = Mpy_32_32( temp1, pState->gain_state[i].lastGain_fx ); /* q_temp + pState->gain_state[i].q_lastGain_fx - 31 */
q_maxGain = add( q_temp, sub( pState->gain_state[i].q_lastGain_fx, Q31 ) );
temp2 = ONE_MINUS_M_DELTA_PROD_FLT_FC; // Q15
@@ -582,7 +583,7 @@ void ivas_agc_enc_process_fx(
}
ELSE
{
- pState->gain_state[i].lastMaxAbs_fx = MaxAbsVal;
+ pState->gain_state[i].lastMaxAbs_fx = MaxAbsVal; /* q_MaxAbsVal */
move32();
pState->gain_state[i].q_lastMaxAbs_fx = q_MaxAbsVal;
move16();
@@ -604,7 +605,7 @@ void ivas_agc_enc_process_fx(
Word32 temp1, temp2;
actualMaxAbsVal = Mpy_32_32( pState->gain_state[i].lastMaxAbs_fx, pState->gain_state[i].lastGain_fx ); // QlastGain_fx
q_actualMaxAbsVal = add( pState->gain_state[i].q_lastMaxAbs_fx, sub( pState->gain_state[i].q_lastGain_fx, Q31 ) );
- idx = s_min( sub( offset, 1 ), MaxAbsValIdx );
+ idx = s_min( sub( offset, 1 ), MaxAbsValIdx ); /* Q0 */
q_actualMaxAbsVal = add( q_actualMaxAbsVal, norm_l( actualMaxAbsVal ) );
temp1 = L_shl( actualMaxAbsVal, norm_l( actualMaxAbsVal ) );
@@ -620,16 +621,16 @@ void ivas_agc_enc_process_fx(
}
ELSE
{
- temp_16 = BASOP_Util_Divide3232_Scale( temp1, temp2, &div_e );
+ temp_16 = BASOP_Util_Divide3232_Scale( temp1, temp2, &div_e ); /* exp(div_e) */
IF( div_e < 0 )
{
temp_16 = shr( temp_16, (Word16) abs( div_e ) );
div_e = 0;
move16();
}
- temp_16 = ceil_fx( temp_16, sub( Q15, div_e ) );
+ temp_16 = ceil_fx( temp_16, sub( Q15, div_e ) ); /* Q0 */
}
- pState->gain_state[i].gainExpVal = temp_16;
+ pState->gain_state[i].gainExpVal = temp_16; /* Q0 */
move16();
WHILE( !isCompensated )
@@ -641,7 +642,7 @@ void ivas_agc_enc_process_fx(
move16();
Word32 tmp_2 = ONE_IN_Q31;
move16();
- tmp_1 = pState->gain_state[i].gainExpVal;
+ tmp_1 = pState->gain_state[i].gainExpVal; /* Q0 */
move16();
FOR( idx = clippedIdx; idx <= MaxAbsValIdx; idx++ )
{
@@ -651,21 +652,21 @@ void ivas_agc_enc_process_fx(
move16();
IF( tmp_1 < 0 )
{
- tmp_2 = pow32_fx( pState->agc_com.winFunc_fx[offset - 1], ( negate( tmp_1 ) ) );
+ tmp_2 = pow32_fx( pState->agc_com.winFunc_fx[offset - 1], ( negate( tmp_1 ) ) ); /* Q31 */
IF( tmp_2 < 0 )
{
- tmp_2 = L_deposit_h( BASOP_Util_Divide3232_Scale( ONE_IN_Q31, L_negate( tmp_2 ), &e_div ) );
+ tmp_2 = L_deposit_h( BASOP_Util_Divide3232_Scale( ONE_IN_Q31, L_negate( tmp_2 ), &e_div ) ); /* exp(e_div) */
tmp_2 = L_negate( tmp_2 );
}
ELSE
{
- tmp_2 = L_deposit_h( BASOP_Util_Divide3232_Scale( ONE_IN_Q31, tmp_2, &e_div ) );
+ tmp_2 = L_deposit_h( BASOP_Util_Divide3232_Scale( ONE_IN_Q31, tmp_2, &e_div ) ); /* exp(e_div) */
}
q_tmp_2 = sub( Q31, e_div );
}
ELSE
{
- tmp_2 = pow32_fx( pState->agc_com.winFunc_fx[offset - 1], tmp_1 );
+ tmp_2 = pow32_fx( pState->agc_com.winFunc_fx[offset - 1], tmp_1 ); /* Q31 */
q_tmp_2 = Q31;
move16();
}
@@ -674,15 +675,15 @@ void ivas_agc_enc_process_fx(
{
IF( tmp_1 < 0 )
{
- tmp_2 = pow32_fx( pState->agc_com.winFunc_fx[idx], ( negate( tmp_1 ) ) );
+ tmp_2 = pow32_fx( pState->agc_com.winFunc_fx[idx], ( negate( tmp_1 ) ) ); /* Q31 */
IF( tmp_2 < 0 )
{
- tmp_2 = L_deposit_h( BASOP_Util_Divide3232_Scale( ONE_IN_Q31, L_negate( tmp_2 ), &e_div ) );
+ tmp_2 = L_deposit_h( BASOP_Util_Divide3232_Scale( ONE_IN_Q31, L_negate( tmp_2 ), &e_div ) ); /* exp(e_div) */
tmp_2 = L_negate( tmp_2 );
}
ELSE
{
- tmp_2 = L_deposit_h( BASOP_Util_Divide3232_Scale( ONE_IN_Q31, tmp_2, &e_div ) );
+ tmp_2 = L_deposit_h( BASOP_Util_Divide3232_Scale( ONE_IN_Q31, tmp_2, &e_div ) ); /* exp(e_div) */
}
q_tmp_2 = sub( Q31, e_div );
}
@@ -694,7 +695,7 @@ void ivas_agc_enc_process_fx(
}
}
- tmpSignal = Mpy_32_32( ppPcm_out[i][idx], tmp_2 );
+ tmpSignal = Mpy_32_32( ppPcm_out[i][idx], tmp_2 ); /* q_pcm + q_tmp_2 - 31 */
q_tmpSignal = add( q_pcm, sub( q_tmp_2, 31 ) );
Word16 comp_flag_1 = BASOP_Util_Cmp_Mant32Exp_sat( tmpSignal, sub( Q31, q_tmpSignal ), ONE_MINUS_M_DELTA_PROD_FLT_FC, Q16 );
@@ -730,13 +731,13 @@ void ivas_agc_enc_process_fx(
}
IF( !isCompensated )
{
- pState->gain_state[i].gainExpVal = add( pState->gain_state[i].gainExpVal, 1 );
+ pState->gain_state[i].gainExpVal = add( pState->gain_state[i].gainExpVal, 1 ); /* Q0 */
move16();
}
IF( GT_16( pState->gain_state[i].gainExpVal, currMaxAttExp ) )
{
- pState->gain_state[i].gainExpVal = s_min( pState->gain_state[i].gainExpVal, currMaxAttExp );
+ pState->gain_state[i].gainExpVal = s_min( pState->gain_state[i].gainExpVal, currMaxAttExp ); /* Q0 */
move16();
BREAK;
}
@@ -748,7 +749,7 @@ void ivas_agc_enc_process_fx(
{
Word16 tmp_1, q_tmp_2, e_div;
Word32 tmp_2;
- tmp_1 = pState->gain_state[i].gainExpVal;
+ tmp_1 = pState->gain_state[i].gainExpVal; /* Q0 */
move16();
IF( GT_16( offset, idx ) )
@@ -758,18 +759,18 @@ void ivas_agc_enc_process_fx(
tmp_2 = pow32_fx( pState->agc_com.winFunc_fx[idx], ( negate( tmp_1 ) ) );
IF( tmp_2 < 0 )
{
- tmp_2 = L_deposit_h( BASOP_Util_Divide3232_Scale( ONE_IN_Q31, L_negate( tmp_2 ), &e_div ) );
+ tmp_2 = L_deposit_h( BASOP_Util_Divide3232_Scale( ONE_IN_Q31, L_negate( tmp_2 ), &e_div ) ); /* exp(e_div) */
tmp_2 = L_negate( tmp_2 );
}
ELSE
{
- tmp_2 = L_deposit_h( BASOP_Util_Divide3232_Scale( ONE_IN_Q31, tmp_2, &e_div ) );
+ tmp_2 = L_deposit_h( BASOP_Util_Divide3232_Scale( ONE_IN_Q31, tmp_2, &e_div ) ); /* exp(e_div) */
}
q_tmp_2 = sub( Q31, e_div );
}
ELSE
{
- tmp_2 = pow32_fx( pState->agc_com.winFunc_fx[idx], tmp_1 );
+ tmp_2 = pow32_fx( pState->agc_com.winFunc_fx[idx], tmp_1 ); /* Q31 */
q_tmp_2 = Q31;
move16();
}
@@ -778,21 +779,21 @@ void ivas_agc_enc_process_fx(
{
IF( tmp_1 < 0 )
{
- tmp_2 = pow32_fx( pState->agc_com.winFunc_fx[offset - 1], ( negate( tmp_1 ) ) );
+ tmp_2 = pow32_fx( pState->agc_com.winFunc_fx[offset - 1], ( negate( tmp_1 ) ) ); /* Q31 */
IF( tmp_2 < 0 )
{
- tmp_2 = L_deposit_h( BASOP_Util_Divide3232_Scale( ONE_IN_Q31, L_negate( tmp_2 ), &e_div ) );
+ tmp_2 = L_deposit_h( BASOP_Util_Divide3232_Scale( ONE_IN_Q31, L_negate( tmp_2 ), &e_div ) ); /* exp(e_div) */
tmp_2 = L_negate( tmp_2 );
}
ELSE
{
- tmp_2 = L_deposit_h( BASOP_Util_Divide3232_Scale( ONE_IN_Q31, tmp_2, &e_div ) );
+ tmp_2 = L_deposit_h( BASOP_Util_Divide3232_Scale( ONE_IN_Q31, tmp_2, &e_div ) ); /* exp(e_div) */
}
q_tmp_2 = sub( Q31, e_div );
}
ELSE
{
- tmp_2 = pow32_fx( pState->agc_com.winFunc_fx[offset - 1], tmp_1 );
+ tmp_2 = pow32_fx( pState->agc_com.winFunc_fx[offset - 1], tmp_1 ); /* Q31 */
q_tmp_2 = Q31;
move16();
}
@@ -806,29 +807,29 @@ void ivas_agc_enc_process_fx(
Word16 tmp_1, q_tmp_2, e_div;
Word32 tmp_2;
- tmp_1 = pState->gain_state[i].gainExpVal;
+ tmp_1 = pState->gain_state[i].gainExpVal; /* Q0 */
move16();
IF( tmp_1 < 0 )
{
- tmp_2 = pow32_fx( pState->agc_com.winFunc_fx[offset - 1], ( negate( tmp_1 ) ) );
+ tmp_2 = pow32_fx( pState->agc_com.winFunc_fx[offset - 1], ( negate( tmp_1 ) ) ); /* Q31 */
IF( tmp_2 < 0 )
{
- tmp_2 = L_deposit_h( BASOP_Util_Divide3232_Scale( ONE_IN_Q31, L_negate( tmp_2 ), &e_div ) );
+ tmp_2 = L_deposit_h( BASOP_Util_Divide3232_Scale( ONE_IN_Q31, L_negate( tmp_2 ), &e_div ) ); /* exp(e_div) */
tmp_2 = L_negate( tmp_2 );
}
ELSE
{
- tmp_2 = L_deposit_h( BASOP_Util_Divide3232_Scale( ONE_IN_Q31, tmp_2, &e_div ) );
+ tmp_2 = L_deposit_h( BASOP_Util_Divide3232_Scale( ONE_IN_Q31, tmp_2, &e_div ) ); /* exp(e_div) */
}
q_tmp_2 = sub( Q31, e_div );
}
ELSE
{
- tmp_2 = pow32_fx( pState->agc_com.winFunc_fx[offset - 1], tmp_1 );
+ tmp_2 = pow32_fx( pState->agc_com.winFunc_fx[offset - 1], tmp_1 ); /* Q31 */
q_tmp_2 = Q31;
move16();
}
- pState->gain_state[i].lastGain_fx = Mpy_32_32( pState->gain_state[i].lastGain_fx, tmp_2 );
+ pState->gain_state[i].lastGain_fx = Mpy_32_32( pState->gain_state[i].lastGain_fx, tmp_2 ); /* pState->gain_state[i].q_lastGain_fx + q_tmp_2 - 31 */
move32();
pState->gain_state[i].q_lastGain_fx = add( pState->gain_state[i].q_lastGain_fx, sub( q_tmp_2, Q31 ) );
move16();
@@ -860,11 +861,11 @@ void ivas_agc_enc_process_fx(
{
IF( pState->gain_state[i].gainExpVal <= 0 )
{
- pState->gain_state[i].gainExpVal = add( pState->agc_com.maxAttExp, 1 );
+ pState->gain_state[i].gainExpVal = add( pState->agc_com.maxAttExp, 1 ); /* Q0 */
move16();
}
}
- pState->gain_data[i].absGainExpCurr = sub( pState->gain_data[i].absGainExp, pState->gain_state[i].gainExpVal );
+ pState->gain_data[i].absGainExpCurr = sub( pState->gain_data[i].absGainExp, pState->gain_state[i].gainExpVal ); /* Q0 */
move16();
test();
diff --git a/lib_enc/ivas_core_enc.c b/lib_enc/ivas_core_enc.c
index a2a87bacc5234fd072009af9a79a19c6798ec827..a25ee85c611c5ccb05cae804d320216c8ebf5490 100644
--- a/lib_enc/ivas_core_enc.c
+++ b/lib_enc/ivas_core_enc.c
@@ -49,41 +49,41 @@
/*-------------------------------------------------------------------*
- * ivas_core_enc()
+ * ivas_core_enc_fx()
*
* Principal IVAS core coder routine, where number of core channels is 1 or 2
*-------------------------------------------------------------------*/
-ivas_error ivas_core_enc(
+ivas_error ivas_core_enc_fx(
SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */
CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
MCT_ENC_HANDLE hMCT, /* i/o: MCT encoder structure */
- const Word16 n_CoreChannels, /* i : number of core channels to be coded */
- Word16 old_inp_12k8_fx[][L_INP_12k8], /* i : buffer of old input signal */
- Word16 old_inp_16k_fx[][L_INP], /* i : buffer of old input signal */
+ const Word16 n_CoreChannels, /* i : number of core channels to be coded Q0*/
+ Word16 old_inp_12k8_fx[][L_INP_12k8], /* i : buffer of old input signal Q_new-1*/
+ Word16 old_inp_16k_fx[][L_INP], /* i : buffer of old input signal Q_new-1*/
Word16 Q_new[],
- Word32 ener_fx[], /* i : residual energy from Levinson-Durbin epsP_fx_q */
- Word16 A_fx[][NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes */
- Word16 Aw_fx[][NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquantized for subframes */
- Word32 epsP_fx[][M + 1], /* i : LP prediction errors epsP_fx_q */
+ Word32 ener_fx[], /* i : residual energy from Levinson-Durbin epsP_fx_q*/
+ Word16 A_fx[][NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12*/
+ Word16 Aw_fx[][NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquantized for subframes Q12*/
+ Word32 epsP_fx[][M + 1], /* i : LP prediction errors epsP_fx_q*/
Word16 epsP_fx_q[], /* i : LP prediction errors */
- Word16 lsp_new_fx[][M], /* i : LSPs at the end of the frame Q15 */
- Word16 lsp_mid_fx[][M], /* i : LSPs in the middle of the frame Q15 */
- const Word16 vad_hover_flag[], /* i : VAD hanglover flag */
- Word16 attack_flag[], /* i : attack flag (GSC or TC) */
- Word32 realBuffer_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: real buffer */
- Word32 imagBuffer_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: imag buffer */
+ Word16 lsp_new_fx[][M], /* i : LSPs at the end of the frame Q15*/
+ Word16 lsp_mid_fx[][M], /* i : LSPs in the middle of the frame Q15*/
+ const Word16 vad_hover_flag[], /* i : VAD hanglover flag Q0*/
+ Word16 attack_flag[], /* i : attack flag (GSC or TC) Q0*/
+ Word32 realBuffer_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: real buffer q_re_im_buf*/
+ Word32 imagBuffer_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: imag buffer q_re_im_buf*/
Word16 *q_re_im_buf,
- Word16 old_wsp_fx[][L_WSP], /* i : weighted input signal buffer */
+ Word16 old_wsp_fx[][L_WSP], /* i : weighted input signal buffer e_old_wsp*/
Word16 e_old_wsp[],
- const Word16 loc_harm[], /* i : harmonicity flag */
- const Word16 cor_map_sum_fx[], /* i : speech/music clasif. parameter Q8 */
- const Word16 vad_flag_dtx[], /* i : HE-SAD flag with additional DTX HO */
- Word32 enerBuffer_fx[][CLDFB_NO_CHANNELS_MAX], /* o : energy buffer */
- Word16 enerBuffer_fx_exp[], /* o : energy buffer */
- Word16 fft_buff_fx[][2 * L_FFT], /* i : FFT buffer */
- const Word16 tdm_SM_or_LRTD_Pri, /* i : channel combination scheme flag */
- const Word16 ivas_format, /* i : IVAS format */
- const Word16 flag_16k_smc /* i : flag to indicate if the OL SMC is run at 16 kHz */
+ const Word16 loc_harm[], /* i : harmonicity flag Q0*/
+ const Word16 cor_map_sum_fx[], /* i : speech/music clasif. parameter Q8*/
+ const Word16 vad_flag_dtx[], /* i : HE-SAD flag with additional DTX HO Q0*/
+ Word32 enerBuffer_fx[][CLDFB_NO_CHANNELS_MAX], /* o : energy buffer enerBuffer_fx_exp*/
+ Word16 enerBuffer_fx_exp[], /* o : energy buffer */
+ Word16 fft_buff_fx[][2 * L_FFT], /* i : FFT buffer Qx*/
+ const Word16 tdm_SM_or_LRTD_Pri, /* i : channel combination scheme flag Q0*/
+ const Word16 ivas_format, /* i : IVAS format Q0*/
+ const Word16 flag_16k_smc /* i : flag to indicate if the OL SMC is run at 16 kHz Q0*/
)
{
Word16 n, input_frame;
@@ -150,9 +150,9 @@ ivas_error ivas_core_enc(
sts = hSCE->hCoreCoder;
hStereoTD = NULL;
hStereoICBWE = NULL;
- element_brate = hSCE->element_brate;
+ element_brate = hSCE->element_brate; /* Q0 */
move32();
- last_element_brate = hSCE->last_element_brate;
+ last_element_brate = hSCE->last_element_brate; /* Q0 */
move32();
last_element_mode = IVAS_SCE;
move16();
@@ -161,7 +161,7 @@ ivas_error ivas_core_enc(
}
ELSE
{
- cpe_id = hCPE->cpe_id;
+ cpe_id = hCPE->cpe_id; /* Q0 */
move16();
MCT_flag = 0;
move16();
@@ -172,17 +172,17 @@ ivas_error ivas_core_enc(
}
sts = hCPE->hCoreCoder;
hStereoICBWE = hCPE->hStereoICBWE;
- element_brate = hCPE->element_brate;
+ element_brate = hCPE->element_brate; /* Q0 */
move32();
- last_element_brate = hCPE->last_element_brate;
+ last_element_brate = hCPE->last_element_brate; /* Q0 */
move32();
- last_element_mode = hCPE->last_element_mode;
+ last_element_mode = hCPE->last_element_mode; /* Q0 */
move16();
IF( hCPE->hStereoTD != NULL )
{
hStereoTD = hCPE->hStereoTD;
- tdm_Pitch_reuse_flag = hCPE->hStereoTD->tdm_Pitch_reuse_flag;
+ tdm_Pitch_reuse_flag = hCPE->hStereoTD->tdm_Pitch_reuse_flag; /* Q0 */
move16();
}
ELSE
@@ -211,7 +211,7 @@ ivas_error ivas_core_enc(
unbits[n] = 0;
move16();
- st->element_brate = element_brate;
+ st->element_brate = element_brate; /* Q0 */
move32();
/*---------------------------------------------------------------------*
@@ -224,7 +224,7 @@ ivas_error ivas_core_enc(
tmp_shift = sub( tmp_shift, 5 );
IF( tmp_shift < 0 )
{
- scale_sig32( enerBuffer_fx[n], st->cldfbAnaEnc->no_channels, tmp_shift );
+ scale_sig32( enerBuffer_fx[n], st->cldfbAnaEnc->no_channels, tmp_shift ); /* enerBuffer_fx_exp[n] - tmp_shift */
enerBuffer_fx_exp[n] = sub( enerBuffer_fx_exp[n], tmp_shift );
move16();
}
@@ -250,9 +250,9 @@ ivas_error ivas_core_enc(
}
IF( EQ_32( ivas_format, SBA_FORMAT ) )
{
- IF( NE_32( ( error = pre_proc_ivas( st, last_element_mode, element_brate, last_element_brate, input_frame, old_inp_12k8_fx[n] /* i: -1, o: Q_new - 1 */, old_inp_16k_fx[n] /* i: -1, o: Q_new - 1 */,
- &inp_fx[n], &ener_fx[n], A_fx[n], Aw_fx[n], epsP_fx[n], &epsP_fx_q[n], lsp_new_fx[n], lsp_mid_fx[n], new_inp_resamp16k_fx[n], &Voicing_flag[n], old_wsp_fx[n], e_old_wsp[n], loc_harm[n],
- vad_flag_dtx[n], MCT_flag, vad_hover_flag[n], flag_16k_smc, enerBuffer_fx[n], enerBuffer_fx_exp[n], fft_buff_fx[n], cor_map_sum_fx[n], &Q_new[n] ) ),
+ IF( NE_32( ( error = pre_proc_ivas_fx( st, last_element_mode, element_brate, last_element_brate, input_frame, old_inp_12k8_fx[n] /* i: -1, o: Q_new - 1 */, old_inp_16k_fx[n] /* i: -1, o: Q_new - 1 */,
+ &inp_fx[n], &ener_fx[n], A_fx[n], Aw_fx[n], epsP_fx[n], &epsP_fx_q[n], lsp_new_fx[n], lsp_mid_fx[n], new_inp_resamp16k_fx[n], &Voicing_flag[n], old_wsp_fx[n], e_old_wsp[n], loc_harm[n],
+ vad_flag_dtx[n], MCT_flag, vad_hover_flag[n], flag_16k_smc, enerBuffer_fx[n], enerBuffer_fx_exp[n], fft_buff_fx[n], cor_map_sum_fx[n], &Q_new[n] ) ),
IVAS_ERR_OK ) )
{
return error;
@@ -260,9 +260,9 @@ ivas_error ivas_core_enc(
}
ELSE
{
- IF( NE_32( ( error = pre_proc_ivas( st, last_element_mode, element_brate, element_brate, input_frame, old_inp_12k8_fx[n] /* i: -1, o: Q_new - 1 */, old_inp_16k_fx[n] /* i: -1, o: Q_new - 1 */,
- &inp_fx[n], &ener_fx[n], A_fx[n], Aw_fx[n], epsP_fx[n], &epsP_fx_q[n], lsp_new_fx[n], lsp_mid_fx[n], new_inp_resamp16k_fx[n], &Voicing_flag[n], old_wsp_fx[n], e_old_wsp[n], loc_harm[n],
- vad_flag_dtx[n], MCT_flag, vad_hover_flag[n], flag_16k_smc, enerBuffer_fx[n], enerBuffer_fx_exp[n], fft_buff_fx[n], cor_map_sum_fx[n], &Q_new[n] ) ),
+ IF( NE_32( ( error = pre_proc_ivas_fx( st, last_element_mode, element_brate, element_brate, input_frame, old_inp_12k8_fx[n] /* i: -1, o: Q_new - 1 */, old_inp_16k_fx[n] /* i: -1, o: Q_new - 1 */,
+ &inp_fx[n], &ener_fx[n], A_fx[n], Aw_fx[n], epsP_fx[n], &epsP_fx_q[n], lsp_new_fx[n], lsp_mid_fx[n], new_inp_resamp16k_fx[n], &Voicing_flag[n], old_wsp_fx[n], e_old_wsp[n], loc_harm[n],
+ vad_flag_dtx[n], MCT_flag, vad_hover_flag[n], flag_16k_smc, enerBuffer_fx[n], enerBuffer_fx_exp[n], fft_buff_fx[n], cor_map_sum_fx[n], &Q_new[n] ) ),
IVAS_ERR_OK ) )
{
return error;
@@ -308,8 +308,8 @@ ivas_error ivas_core_enc(
/* write TD stereo spatial parameters */
move_indices( hStereoTD->tdm_hBstr_tmp.ind_list, st->hBstr->ind_list, hStereoTD->tdm_hBstr_tmp.nb_ind_tot );
- st->hBstr->nb_ind_tot = add( st->hBstr->nb_ind_tot, hStereoTD->tdm_hBstr_tmp.nb_ind_tot );
- st->hBstr->nb_bits_tot = add( st->hBstr->nb_bits_tot, hStereoTD->tdm_hBstr_tmp.nb_bits_tot );
+ st->hBstr->nb_ind_tot = add( st->hBstr->nb_ind_tot, hStereoTD->tdm_hBstr_tmp.nb_ind_tot ); /* Q0 */
+ st->hBstr->nb_bits_tot = add( st->hBstr->nb_bits_tot, hStereoTD->tdm_hBstr_tmp.nb_bits_tot ); /* Q0 */
reset_indices_enc( &hStereoTD->tdm_hBstr_tmp, MAX_IND_TDM_TMP );
}
@@ -342,7 +342,7 @@ ivas_error ivas_core_enc(
/* ACELP core encoder */
Word16 Q_old_syn_12k8_16k = 0;
move16();
- IF( NE_32( ( error = acelp_core_enc( st, inp_fx[n], /*ener[n],*/ A_fx[n], Aw_fx[n], epsP_fx[n], lsp_new_fx[n], lsp_mid_fx[n], vad_hover_flag[0], attack_flag[n], bwe_exc_extended_fx[n], voice_factors_fx[n], old_syn_12k8_16k_fx[n], &Q_old_syn_12k8_16k, pitch_buf_fx[n], &unbits[n], hStereoTD, tdm_lsfQ_PCh_fx, Q_new[n] ) ), IVAS_ERR_OK ) )
+ IF( NE_32( ( error = acelp_core_enc_ivas_fx( st, inp_fx[n], /*ener[n],*/ A_fx[n], Aw_fx[n], epsP_fx[n], lsp_new_fx[n], lsp_mid_fx[n], vad_hover_flag[0], attack_flag[n], bwe_exc_extended_fx[n], voice_factors_fx[n], old_syn_12k8_16k_fx[n], &Q_old_syn_12k8_16k, pitch_buf_fx[n], &unbits[n], hStereoTD, tdm_lsfQ_PCh_fx, Q_new[n] ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -363,10 +363,9 @@ ivas_error ivas_core_enc(
Scale_sig( old_inp_12k8_fx[n], L_INP_12k8, sub( Q1, Q_new[n] ) ); // Q0
Scale_sig( old_inp_16k_fx[n], L_INP, sub( Q1, Q_new[n] ) ); // Q0
- Scale_sig( st->hTcxEnc->Txnq, L_FRAME32k / 2 + 64, sub( -1, st->hTcxEnc->q_Txnq ) );
+ Scale_sig( st->hTcxEnc->Txnq, L_FRAME32k / 2 + 64, sub( negate( 1 ), st->hTcxEnc->q_Txnq ) ); /* Q(-1) */
st->hTcxEnc->q_Txnq = -Q1;
move16();
-
Q_spec_old = hTcxEnc->spectrum_long_e;
move16();
/* TCX core encoder */
@@ -645,18 +644,12 @@ ivas_error ivas_core_enc(
st->q_old_inp = st->q_inp = 0;
move16();
move16();
-
- if ( st->hTcxEnc != NULL )
- {
- st->hTcxEnc->exp_buf_speech_ltp = 31; // Q0
- move16();
- }
IF( st->hBWE_FD != NULL )
{
- Scale_sig( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k, sub( -1, st->Q_old_wtda ) );
- st->Q_old_wtda = -1; // This reset is required for resolving crash issue. Needs to be looked into further
+ Scale_sig( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k, sub( negate( 1 ), st->Q_old_wtda ) ); // Q(-1)
+ st->Q_old_wtda = -1; // This reset is required for resolving crash issue. Needs to be looked into further
move16();
- Scale_sig( st->hBWE_FD->old_input_lp_fx, NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_NS ), sub( sub( Q_new[n], 1 ), st->hBWE_FD->prev_Q_input_lp ) );
+ Scale_sig( st->hBWE_FD->old_input_lp_fx, NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_NS ), sub( sub( Q_new[n], 1 ), st->hBWE_FD->prev_Q_input_lp ) ); /* Q_new[n] - 1 */
st->hBWE_FD->prev_Q_input_lp = sub( Q_new[n], 1 );
move16();
}
@@ -743,7 +736,7 @@ ivas_error ivas_core_enc(
}
Word16 q_new_swb_speech_buffer = getScaleFactor16( new_swb_speech_buffer_fx_16, input_frame );
- Scale_sig( new_swb_speech_buffer_fx_16, q_new_swb_speech_buffer, input_frame ); // Q0->q_new_swb_speech_buffer
+ Scale_sig( new_swb_speech_buffer_fx_16, input_frame, q_new_swb_speech_buffer ); // Q0->q_new_swb_speech_buffer
/* SWB TBE encoder */
test();
@@ -801,8 +794,13 @@ ivas_error ivas_core_enc(
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
+#ifdef FIX_ISSUE_1237
+ 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 );
+#else
+ Copy_Scale_sig_16_32_DEPREC( new_swb_speech_buffer_fx_16, new_swb_speech_buffer_fx, input_frame, Q16 ); // q_new_swb_speech_buffer
+ Copy_Scale_sig_16_32_DEPREC( voice_factors_fx[0], voice_factors_fx32[0], NB_SUBFR16k, Q16 ); // Q31
+#endif
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] );
@@ -842,10 +840,6 @@ ivas_error ivas_core_enc(
st->hBWE_FD->prev_Q_input_lp = sub( Q_new[n], 1 );
move16();
}
- IF( st->hTcxEnc != NULL )
- {
- Scale_sig( st->hTcxEnc->buf_speech_ltp, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, negate( st->hTcxEnc->exp_buf_speech_ltp ) ); // Q0
- }
}
/*------------------------------------------------------------------*
diff --git a/lib_enc/ivas_core_pre_proc.c b/lib_enc/ivas_core_pre_proc.c
index edef59ba2c0009b043ca84beb1f0eca704c3d283..848e26ce3d4cbeb7b247ef415be9fc40e8e26da4 100644
--- a/lib_enc/ivas_core_pre_proc.c
+++ b/lib_enc/ivas_core_pre_proc.c
@@ -45,40 +45,40 @@
#include "basop_util.h"
/*-------------------------------------------------------------------*
- * pre_proc_ivas()
+ * pre_proc_ivas_fx()
*
* Pre-processing (Selection of internal Fs, classification, SC VBR decision,
* Decision matrix, Preprocessing at other Fs, core switching decision, ...)
*--------------------------------------------------------------------*/
-ivas_error pre_proc_ivas(
- Encoder_State *st, /* i/o: encoder state structure */
- const Word16 last_element_mode, /* i : last element mode */
- const Word32 element_brate, /* i : element bitrate */
- const Word32 last_element_brate, /* i : last element bitrate */
- const Word16 input_frame, /* i : frame length */
- Word16 old_inp_12k8_fx[], /* i/o: buffer of old input signal Q_new-1 */
- Word16 old_inp_16k_fx[], /* i/o: buffer of old input signal @ 16kHz Q_new-1 */
- Word16 **inp_fx, /* o : ptr. to inp. signal in the current frame*/
- Word32 *ener_fx, /* o : residual energy from Levinson-Durbin epsP_fx_q */
- Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* i/o: A(z) unquantized for the 4 subframes */
- Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* i/o: weighted A(z) unquantized for subframes */
- Word32 epsP_fx[M + 1], /* i : LP prediction errors epsP_fx_q */
- Word16 *epsP_fx_q, /* i : LP prediction errors */
- Word16 lsp_new_fx[M], /* i/o: LSPs at the end of the frame */
- Word16 lsp_mid_fx[M], /* i/o: LSPs in the middle of the frame */
- Word16 *new_inp_resamp16k_fx, /* o : new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE */
- Word16 *Voicing_flag, /* o : voicing flag for HQ FEC */
- Word16 old_wsp_fx[], /* i : weighted input signal buffer */
+ivas_error pre_proc_ivas_fx(
+ Encoder_State *st, /* i/o: encoder state structure */
+ const Word16 last_element_mode, /* i : last element mode Q0*/
+ const Word32 element_brate, /* i : element bitrate Q0*/
+ const Word32 last_element_brate, /* i : last element bitrate Q0*/
+ const Word16 input_frame, /* i : frame length Q0*/
+ Word16 old_inp_12k8_fx[], /* i/o: buffer of old input signal Q_new-1 */
+ Word16 old_inp_16k_fx[], /* i/o: buffer of old input signal @ 16kHz Q_new-1 */
+ Word16 **inp_fx, /* o : ptr. to inp. signal in the current frame Q_new*/
+ Word32 *ener_fx, /* o : residual energy from Levinson-Durbin epsP_fx_q*/
+ Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* i/o: A(z) unquantized for the 4 subframes Q12*/
+ Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* i/o: weighted A(z) unquantized for subframes Q14*/
+ Word32 epsP_fx[M + 1], /* i : LP prediction errors epsP_fx_q*/
+ Word16 *epsP_fx_q, /* i : LP prediction errors */
+ Word16 lsp_new_fx[M], /* i/o: LSPs at the end of the frame Q15*/
+ Word16 lsp_mid_fx[M], /* i/o: LSPs in the middle of the frame Q15*/
+ Word16 *new_inp_resamp16k_fx, /* o : new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE Q_new-1*/
+ Word16 *Voicing_flag, /* o : voicing flag for HQ FEC Q0*/
+ Word16 old_wsp_fx[], /* i : weighted input signal buffer e_old_wsp*/
Word16 e_old_wsp,
- const Word16 loc_harm, /* i : harmonicity flag */
- const Word16 vad_flag_dtx, /* i : HE-SAD flag with additional DTX HO */
- const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) */
- const Word16 vad_hover_flag, /* i : VAD hangover flag */
- const Word16 flag_16k_smc, /* i : flag to indicate if the OL SMC is run at 16 kHz */
- Word32 enerBuffer_fx[CLDFB_NO_CHANNELS_MAX],
+ const Word16 loc_harm, /* i : harmonicity flag Q0*/
+ const Word16 vad_flag_dtx, /* i : HE-SAD flag with additional DTX HO Q0*/
+ const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/
+ const Word16 vad_hover_flag, /* i : VAD hangover flag Q0*/
+ const Word16 flag_16k_smc, /* i : flag to indicate if the OL SMC is run at 16 kHz Q0*/
+ Word32 enerBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* e_enerBuffer */
Word16 e_enerBuffer,
- Word16 fft_buff_fx[2 * L_FFT],
- Word16 cor_map_sum_fx, // Q8
+ Word16 fft_buff_fx[2 * L_FFT], /* Qx */
+ Word16 cor_map_sum_fx, /* Q8 */
Word16 *Q_new )
{
Word16 L_look, element_mode, lMemRecalc_12k8;
@@ -138,13 +138,13 @@ ivas_error pre_proc_ivas(
IF( st->core_brate == FRAME_NO_DATA )
{
/* prevent "L_frame" changes in CNG segments */
- st->L_frame = st->last_L_frame;
+ st->L_frame = st->last_L_frame; /* Q0 */
move16();
}
ELSE IF( EQ_32( st->core_brate, SID_2k40 ) && GE_16( st->bwidth, WB ) && st->hDtxEnc->first_CNG && ( st->hTdCngEnc != NULL && LT_16( st->hTdCngEnc->act_cnt2, MIN_ACT_CNG_UPD ) ) )
{
/* prevent "L_frame" changes in SID frame after short segment of active frames */
- st->L_frame = st->hDtxEnc->last_CNG_L_frame;
+ st->L_frame = st->hDtxEnc->last_CNG_L_frame; /* Q0 */
move16();
}
ELSE IF( ( ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && GE_32( st->element_brate, IVAS_64k ) && GE_16( st->bwidth, SWB ) ) || ( EQ_16( element_mode, IVAS_SCE ) && GT_32( st->total_brate, MAX_ACELP_BRATE ) && GE_16( st->bwidth, SWB ) ) ) && NE_32( st->core_brate, SID_2k40 ) )
@@ -191,7 +191,7 @@ ivas_error pre_proc_ivas(
if ( st->ini_frame == 0 )
{
/* avoid switching of internal ACELP Fs in the very first frame */
- st->last_L_frame = st->L_frame;
+ st->last_L_frame = st->L_frame; /* Q0 */
move16();
}
@@ -217,9 +217,9 @@ ivas_error pre_proc_ivas(
move16();
}
- st->sr_core = L_mult0( st->L_frame, FRAMES_PER_SEC );
- st->encoderLookahead_enc = NS2SA_FX2( st->sr_core, ACELP_LOOK_NS );
- st->encoderPastSamples_enc = shr( ( imult1616( st->L_frame, 9 ) ), 4 );
+ st->sr_core = L_mult0( st->L_frame, FRAMES_PER_SEC ); /* Q0 */
+ st->encoderLookahead_enc = NS2SA_FX2( st->sr_core, ACELP_LOOK_NS ); /* Q0 */
+ st->encoderPastSamples_enc = shr( ( imult1616( st->L_frame, 9 ) ), 4 ); /* Q0 */
move32();
move16();
move16();
@@ -248,7 +248,7 @@ ivas_error pre_proc_ivas(
test();
test();
/* enforce TRANSITION frames */
- IF( !( EQ_16( st->element_mode, IVAS_CPE_TD ) && EQ_16( st->idchan, 1 ) ) && 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_32( st->last_core_brate, FRAME_NO_DATA ) && NE_32( st->last_core_brate, SID_2k40 ) && NE_16( st->coder_type_raw, VOICED ) )
+ IF( !( EQ_16( st->element_mode, IVAS_CPE_TD ) && EQ_16( st->idchan, 1 ) ) && NE_16( st->last_L_frame, st->L_frame ) && st->core_brate != FRAME_NO_DATA && NE_32( st->core_brate, SID_2k40 ) && st->last_core_brate != FRAME_NO_DATA && NE_32( st->last_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;
@@ -298,10 +298,11 @@ ivas_error pre_proc_ivas(
st->mdct_sw_enable = MODE1;
move16();
move16();
+
test();
test();
test();
- IF( ( LE_32( st->total_brate, MIN_BRATE_GSC_NOISY_FLAG ) || LT_16( st->bwidth, SWB ) || st->flag_ACELP16k ) && st->GSC_IVAS_mode == 0 )
+ if ( ( LE_32( st->total_brate, MIN_BRATE_GSC_NOISY_FLAG ) || LT_16( st->bwidth, SWB ) || st->flag_ACELP16k ) && st->GSC_IVAS_mode == 0 )
{
st->GSC_noisy_speech = 0;
move16();
@@ -311,7 +312,7 @@ ivas_error pre_proc_ivas(
ivas_decision_matrix_enc_fx( st, element_brate, fft_buff_fx, enerBuffer_fx, e_enerBuffer, last_element_mode );
test();
test();
- IF( EQ_16( st->L_frame, L_FRAME16k ) && ( EQ_16( st->coder_type, VOICED ) || EQ_16( st->coder_type, UNVOICED ) ) ) /* VOICED and UNVOICED are not supported in ACELP@16k */
+ if ( EQ_16( st->L_frame, L_FRAME16k ) && ( EQ_16( st->coder_type, VOICED ) || EQ_16( st->coder_type, UNVOICED ) ) ) /* VOICED and UNVOICED are not supported in ACELP@16k */
{
st->coder_type = GENERIC;
move16();
@@ -323,22 +324,22 @@ ivas_error pre_proc_ivas(
st->Nb_ACELP_frames = 0;
move16();
/* Configure TCX with the same bitrate as given when (re-)initializing TCX */
- total_brate_tmp = st->total_brate;
+ total_brate_tmp = st->total_brate; /* Q0 */
move32();
- st->total_brate = L_mult0( st->bits_frame_nominal, FRAMES_PER_SEC );
+ st->total_brate = L_mult0( st->bits_frame_nominal, FRAMES_PER_SEC ); /* Q0 */
move32();
- SetModeIndex_ivas_fx( st, st->last_bits_frame_nominal * FRAMES_PER_SEC, last_element_mode, MCT_flag );
+ SetModeIndex_ivas_fx( st, imult3216( st->last_bits_frame_nominal, FRAMES_PER_SEC ), last_element_mode, MCT_flag );
- st->sr_core = getCoreSamplerateMode2( element_mode, st->total_brate, st->bwidth, st->flag_ACELP16k, st->rf_mode, st->is_ism_format );
+ st->sr_core = getCoreSamplerateMode2( element_mode, st->total_brate, st->bwidth, st->flag_ACELP16k, st->rf_mode, st->is_ism_format ); /* Q0 */
move16();
- st->total_brate = total_brate_tmp;
+ st->total_brate = total_brate_tmp; /* Q0 */
move32();
- st->L_frame = extract_l( Mpy_32_32( st->sr_core, ONE_BY_FRAMES_PER_SEC_Q31 ) );
+ st->L_frame = extract_l( Mpy_32_32( st->sr_core, ONE_BY_FRAMES_PER_SEC_Q31 ) ); /* Q0 */
move16();
- st->encoderLookahead_enc = NS2SA_FX2( st->sr_core, ACELP_LOOK_NS );
- st->encoderPastSamples_enc = shr( ( imult1616( st->L_frame, 9 ) ), 4 );
+ st->encoderLookahead_enc = NS2SA_FX2( st->sr_core, ACELP_LOOK_NS ); /* Q0 */
+ st->encoderPastSamples_enc = shr( ( imult1616( st->L_frame, 9 ) ), 4 ); /* Q0 */
move16();
move16();
@@ -393,7 +394,7 @@ ivas_error pre_proc_ivas(
test();
test();
- IF( NE_16( st->extl, -1 ) && NE_16( st->extl, IGF_BWE ) && EQ_16( st->igf, 1 ) )
+ if ( NE_16( st->extl, -1 ) && NE_16( st->extl, IGF_BWE ) && EQ_16( st->igf, 1 ) )
{
st->igf = 0;
move16();
@@ -409,12 +410,12 @@ ivas_error pre_proc_ivas(
test();
IF( EQ_16( loc_harm, 1 ) && GT_16( cor_map_sum_fx, 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 );
+ st->last_harm_flag_acelp = add( st->last_harm_flag_acelp, 1 ); /* Q0 */
move16();
IF( GT_16( st->last_harm_flag_acelp, 10 ) )
{
- st->last_harm_flag_acelp = 10;
+ st->last_harm_flag_acelp = 10; /* Q0 */
move16();
}
}
@@ -430,22 +431,22 @@ ivas_error pre_proc_ivas(
IF( EQ_16( st->coder_type, AUDIO ) )
{
- st->audio_frame_cnt = add( st->audio_frame_cnt, AUDIO_COUNTER_STEP );
+ st->audio_frame_cnt = add( st->audio_frame_cnt, AUDIO_COUNTER_STEP ); /* Q0 */
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 );
+ st->audio_frame_cnt = sub( st->audio_frame_cnt, 1 ); /* Q0 */
move16();
}
- IF( GT_16( st->audio_frame_cnt, AUDIO_COUNTER_MAX ) )
+ if ( GT_16( st->audio_frame_cnt, AUDIO_COUNTER_MAX ) )
{
- st->audio_frame_cnt = AUDIO_COUNTER_MAX;
+ st->audio_frame_cnt = AUDIO_COUNTER_MAX; /* Q0 */
move16();
}
- IF( st->audio_frame_cnt < 0 )
+ if ( st->audio_frame_cnt < 0 )
{
st->audio_frame_cnt = 0;
move16();
@@ -478,7 +479,7 @@ ivas_error pre_proc_ivas(
/* channel-aware mode - due to lack of signaling bit, sharpFlag is 1 always in RF mode */
test();
test();
- IF( st->rf_mode && ( EQ_16( st->coder_type, VOICED ) || EQ_16( st->coder_type, GENERIC ) ) )
+ if ( st->rf_mode && ( EQ_16( st->coder_type, VOICED ) || EQ_16( st->coder_type, GENERIC ) ) )
{
st->sharpFlag = 1;
move16();
@@ -491,7 +492,7 @@ ivas_error pre_proc_ivas(
st->sharpFlag = 0;
move16();
test();
- IF( EQ_16( st->coder_type, GENERIC ) || EQ_16( st->coder_type, VOICED ) )
+ if ( EQ_16( st->coder_type, GENERIC ) || EQ_16( st->coder_type, VOICED ) )
{
st->sharpFlag = 1;
move16();
@@ -528,7 +529,7 @@ ivas_error pre_proc_ivas(
sr_core_tmp = L_max( INT_FS_16k, st->sr_core );
}
- L_look = NS2SA( sr_core_tmp, ACELP_LOOK_NS ); /* lookahead at other sampling rate (16kHz, 25.6kHz, 32kHz) */
+ L_look = NS2SA( sr_core_tmp, ACELP_LOOK_NS ); /* lookahead at other sampling rate (16kHz, 25.6kHz, 32kHz) Q0*/
move16();
inp_16k_fx = old_inp_16k_fx + L_INP_MEM - L_look;
@@ -541,34 +542,35 @@ ivas_error pre_proc_ivas(
inp_16k_fx = old_inp_16k_fx + L_INP_MEM - L_look;
Word16 shift = getScaleFactor16( st->old_inp_12k8_fx, L_INP_MEM );
- Scale_sig( st->old_inp_12k8_fx, L_INP_MEM, shift );
+ Scale_sig( st->old_inp_12k8_fx, L_INP_MEM, shift ); /* exp(st->exp_old_inp_12k8 - shift) */
st->exp_old_inp_12k8 = sub( st->exp_old_inp_12k8, shift );
move16();
- Scale_sig( st->old_inp_16k_fx, L_INP_MEM, sub( Q_old_inp_16k, sub( Q15, st->exp_old_inp_16k ) ) );
+ Scale_sig( st->old_inp_16k_fx, L_INP_MEM, sub( Q_old_inp_16k, sub( Q15, st->exp_old_inp_16k ) ) ); /* Q15 - st->exp_old_inp_16k */
st->exp_old_inp_16k = sub( Q15, Q_old_inp_16k );
move16();
IF( st->hBWE_FD != NULL )
{
- Scale_sig( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k, sub( -1, st->Q_old_wtda ) );
- st->Q_old_wtda = -1; // This reset needs to be looked into
+ Scale_sig( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k, sub( -1, st->Q_old_wtda ) ); /* -1Q */
+ st->Q_old_wtda = -1; // This reset needs to be looked into
move16();
}
- st->mem_preemph_enc = shl( st->mem_preemph_enc, sub( Q_old_inp_16k, sub( Q15, st->exp_mem_preemph_enc ) ) );
+ st->mem_preemph_enc = shl( st->mem_preemph_enc, sub( Q_old_inp_16k, sub( Q15, st->exp_mem_preemph_enc ) ) ); /* Q15 - Q_old_inp_16k */
move16();
st->exp_mem_preemph_enc = sub( Q15, Q_old_inp_16k );
move16();
- Scale_sig( st->buf_speech_enc, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, sub( Q_old_inp_16k, sub( Q15, st->exp_buf_speech_enc ) ) );
+ Scale_sig( st->buf_speech_enc, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, sub( Q_old_inp_16k, sub( Q15, st->exp_buf_speech_enc ) ) ); /* Q15 - Q_old_inp_16k */
st->exp_buf_speech_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 ) ) );
+ 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 */
st->exp_buf_speech_enc_pe = sub( Q15, Q_old_inp_16k );
move16();
Scale_sig( st->input_fx, input_frame, sub( -1, st->q_inp ) );
st->q_inp = -1;
- 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 ) ) );
+ 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->exp_buf_wspeech_enc = sub( Q15, Q_old_inp_16k );
move16();
Word16 Q_old_inp_128k = *Q_new;
@@ -579,32 +581,37 @@ ivas_error pre_proc_ivas(
A_fx, Aw_fx,
epsP_fx,
lsp_new_fx, lsp_mid_fx, Q_old_inp_16k, Q_r, Q_new, 0 );
- IF( NE_32( error, IVAS_ERR_OK ) )
+ IF( error != IVAS_ERR_OK )
{
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 ) ) )
{
/* update signal buffers */
- Copy( new_inp_12k8_fx, st->buf_speech_enc_pe + st->L_frame, L_FRAME );
+ Copy_Scale_sig( new_inp_12k8_fx, st->buf_speech_enc_pe + st->L_frame, L_FRAME, sub( sub( Q15, st->exp_buf_speech_enc_pe ), sub( *Q_new, Q1 ) ) );
Copy( st->buf_speech_enc + L_FRAME32k, st->buf_speech_enc + st->L_frame, L_FRAME );
test();
IF( EQ_16( element_mode, IVAS_CPE_DFT ) )
{
- Copy( st->buf_speech_enc + L_FRAME32k - STEREO_DFT_OVL_12k8, st->buf_speech_enc + st->L_frame - STEREO_DFT_OVL_12k8, STEREO_DFT_OVL_12k8 );
+ Copy( st->buf_speech_enc + L_FRAME32k - STEREO_DFT_OVL_12k8, st->buf_speech_enc + st->L_frame - STEREO_DFT_OVL_12k8, STEREO_DFT_OVL_12k8 ); /* Q_new - 1 */
}
ELSE IF( EQ_16( element_mode, IVAS_CPE_TD ) || EQ_16( element_mode, IVAS_CPE_MDCT ) )
{
- Copy( st->buf_speech_enc + L_FRAME32k - lMemRecalc_12k8 - L_FILT, st->buf_speech_enc + st->L_frame - lMemRecalc_12k8 - L_FILT, lMemRecalc_12k8 + L_FILT );
+ Copy( st->buf_speech_enc + L_FRAME32k - lMemRecalc_12k8 - L_FILT, st->buf_speech_enc + st->L_frame - lMemRecalc_12k8 - L_FILT, lMemRecalc_12k8 + L_FILT ); /* Q_new - 1 */
}
ELSE IF( EQ_16( element_mode, IVAS_SCE ) )
{
- Copy( st->buf_speech_enc + L_FRAME32k - L_FILT, st->buf_speech_enc + st->L_frame - L_FILT, L_FILT );
+ Copy( st->buf_speech_enc + L_FRAME32k - L_FILT, st->buf_speech_enc + st->L_frame - L_FILT, L_FILT ); /* Q_new - 1 */
}
IF( st->tcxonly == 0 )
@@ -615,7 +622,7 @@ ivas_error pre_proc_ivas(
IF( flag_16k_smc )
{
- Copy( st->buf_speech_enc + L_FRAME16k, new_inp_resamp16k_fx, L_FRAME16k );
+ Copy( st->buf_speech_enc + L_FRAME16k, new_inp_resamp16k_fx, L_FRAME16k ); /* Q_new - 1 */
}
/*-----------------------------------------------------------------*
@@ -623,22 +630,21 @@ ivas_error pre_proc_ivas(
*-----------------------------------------------------------------*/
/* update old weighted speech buffer - for OL pitch analysis */
- Copy( &old_wsp_fx[L_FRAME], st->old_wsp_fx, L_WSP_MEM );
+ Copy( &old_wsp_fx[L_FRAME], st->old_wsp_fx, L_WSP_MEM ); /* exp(e_old_wsp) */
st->exp_old_wsp = e_old_wsp;
move16();
- st->exp_buf_speech_enc_pe = sub( Q15, *Q_new - 1 );
- move16();
/* set the pointer of the current frame for the ACELP core */
IF( EQ_16( st->L_frame, L_FRAME ) )
{
- *inp_fx = inp_12k8_fx;
+ *inp_fx = inp_12k8_fx; /* Q_old_inp_128k */
*Q_new = Q_old_inp_128k;
move16();
}
ELSE
{
*inp_fx = inp_16k_fx;
+ Scale_sig( old_inp_12k8_fx, L_INP_12k8, sub( *Q_new, Q_old_inp_128k ) );
}
/* Update VAD hangover frame counter in active frames */
@@ -651,7 +657,7 @@ ivas_error pre_proc_ivas(
test();
IF( st->hTdCngEnc != NULL && st->Opt_DTX_ON && vad_hover_flag )
{
- st->hTdCngEnc->burst_ho_cnt = add( st->hTdCngEnc->burst_ho_cnt, 1 );
+ st->hTdCngEnc->burst_ho_cnt = add( st->hTdCngEnc->burst_ho_cnt, 1 ); /* Q0 */
move16();
if ( GT_16( st->hTdCngEnc->burst_ho_cnt, HO_HIST_SIZE ) )
{
@@ -677,22 +683,23 @@ ivas_error pre_proc_ivas(
*--------------------------------------------------------------------*/
ivas_error ivas_compute_core_buffers_fx(
Encoder_State *st, /* i/o: encoder state structure */
- Word16 **inp16k_out_fx, /* o : ptr. to inp. signal in the current frame */
- Word16 *old_inp_16k_fx, /* i/o: buffer of old input signal @ 16kHz */
- Word16 new_inp_resamp16k_out_fx[], /* o : new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE */
- const Word16 input_frame, /* i : frame length */
- const Word16 last_element_mode, /* i : last element mode */
- const Word32 sr_core, /* i : core-coder sampling rate */
- Word32 *ener_fx, /* o : residual energy from Levinson-Durbin Q_r */
- Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* i/o: A(z) unquantized for the 4 subframes */
- Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* i/o: weighted A(z) unquantized for subframes */
- Word32 epsP_fx[M + 1], /* i/o: LP prediction errors */
- Word16 lsp_new_fx[M], /* i/o: LSPs at the end of the frame */
- Word16 lsp_mid_fx[M], /* i/o: LSPs in the middle of the frame */
+ Word16 **inp16k_out_fx, /* o : ptr. to inp. signal in the current frame Q_new-1*/
+ Word16 *old_inp_16k_fx, /* i/o: buffer of old input signal @ 16kHz Q_new-1*/
+ Word16 new_inp_resamp16k_out_fx[], /* o : new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE Q_old_inp_16k*/
+ const Word16 input_frame, /* i : frame length Q0*/
+ const Word16 last_element_mode, /* i : last element mode Q0*/
+ const Word32 sr_core, /* i : core-coder sampling rate Q0*/
+ Word32 *ener_fx, /* o : residual energy from Levinson-Durbin Q_r*/
+ Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* i/o: A(z) unquantized for the 4 subframes Q14*/
+ Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* i/o: weighted A(z) unquantized for subframes Q14*/
+ Word32 epsP_fx[M + 1], /* i/o: LP prediction errors Q_r*/
+ Word16 lsp_new_fx[M], /* i/o: LSPs at the end of the frame Q15*/
+ Word16 lsp_mid_fx[M], /* i/o: LSPs in the middle of the frame Q15*/
Word16 Q_old_inp_16k,
Word16 Q_r[2],
Word16 *Q_new,
- Word16 downscale_buf_speech_enc_pe )
+ Word16 downscale_buf_speech_enc_pe /* Q0 */
+)
{
Word16 *inp_16k_fx, *new_inp_16k_fx;
Word16 delay, element_mode;
@@ -719,11 +726,11 @@ ivas_error ivas_compute_core_buffers_fx(
#endif
set16_fx( epsP_h, 0, M + 1 );
set16_fx( epsP_l, 0, M + 1 );
- signal_in_fx = st->input_fx;
+ signal_in_fx = st->input_fx; /* st->q_inp */
- input_Fs = st->input_Fs;
+ input_Fs = st->input_Fs; /* Q0 */
move32();
- element_mode = st->element_mode;
+ element_mode = st->element_mode; /* Q0 */
move16();
lMemRecalc_16k = 0;
@@ -767,15 +774,15 @@ ivas_error ivas_compute_core_buffers_fx(
IF( EQ_16( element_mode, IVAS_CPE_DFT ) )
{
- Copy( st->old_inp_16k_fx, old_inp_16k_fx, L_INP_MEM - STEREO_DFT_OVL_16k );
+ Copy( st->old_inp_16k_fx, old_inp_16k_fx, L_INP_MEM - STEREO_DFT_OVL_16k ); /* Q_new - 1 */
}
ELSE IF( EQ_16( element_mode, IVAS_CPE_TD ) )
{
- Copy( st->old_inp_16k_fx, old_inp_16k_fx, L_INP_MEM - L_MEM_RECALC_16K - L_FILT16k );
+ Copy( st->old_inp_16k_fx, old_inp_16k_fx, L_INP_MEM - L_MEM_RECALC_16K - L_FILT16k ); /* Q_new - 1 */
}
ELSE
{
- Copy( st->old_inp_16k_fx, old_inp_16k_fx, L_INP_MEM - L_FILT16k );
+ Copy( st->old_inp_16k_fx, old_inp_16k_fx, L_INP_MEM - L_FILT16k ); /* Q_new - 1 */
}
/*---------------------------------------------------------------*
@@ -791,18 +798,18 @@ ivas_error ivas_compute_core_buffers_fx(
delay = NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS );
move16();
Copy( st->mem_decim16k_fx + delay, new_inp_16k_fx, delay );
- Copy( signal_in_fx, new_inp_16k_fx + delay, input_frame );
- Copy( signal_in_fx + input_frame - shl( delay, 1 ), st->mem_decim16k_fx, shl( delay, 1 ) );
+ Copy( signal_in_fx, new_inp_16k_fx + delay, input_frame ); /* st->q_inp */
+ Copy( signal_in_fx + input_frame - shl( delay, 1 ), st->mem_decim16k_fx, shl( delay, 1 ) ); /* st->q_inp */
}
ELSE IF( EQ_32( input_Fs, 32000 ) || EQ_32( input_Fs, 48000 ) )
{
- size_modified = modify_Fs_ivas_fx( signal_in_fx, input_frame, input_Fs, new_inp_16k_fx, sr_core, st->mem_decim16k_fx, 0, &Q_tmp, &mem_decim16k_size );
- Scale_sig( new_inp_16k_fx, size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */
+ size_modified = modify_Fs_ivas_fx( signal_in_fx, input_frame, input_Fs, new_inp_16k_fx, sr_core, st->mem_decim16k_fx, 0, &Q_tmp, &mem_decim16k_size ); /* Q0 */
+ Scale_sig( new_inp_16k_fx, size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */
- Copy( st->mem_decim16k_fx, mem_decim16k_dummy_fx, 2 * L_FILT_MAX );
+ Copy( st->mem_decim16k_fx, mem_decim16k_dummy_fx, 2 * L_FILT_MAX ); /* Q(-1) */
set16_fx( temp1F_icatdmResampBuf_fx, 0, L_FILT_MAX );
- size_modified = modify_Fs_ivas_fx( temp1F_icatdmResampBuf_fx, NS2SA( input_Fs, DELAY_FIR_RESAMPL_NS ), input_Fs, new_inp_16k_fx + NS2SA( sr_core, FRAME_SIZE_NS ), sr_core, mem_decim16k_dummy_fx, 0, &Q_tmp, &mem_decim16k_size );
- Scale_sig( new_inp_16k_fx + NS2SA( sr_core, FRAME_SIZE_NS ), size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */
+ size_modified = modify_Fs_ivas_fx( temp1F_icatdmResampBuf_fx, NS2SA( input_Fs, DELAY_FIR_RESAMPL_NS ), input_Fs, new_inp_16k_fx + NS2SA( sr_core, FRAME_SIZE_NS ), sr_core, mem_decim16k_dummy_fx, 0, &Q_tmp, &mem_decim16k_size ); /* Q0 */
+ Scale_sig( new_inp_16k_fx + NS2SA( sr_core, FRAME_SIZE_NS ), size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */
}
}
ELSE IF( EQ_16( element_mode, IVAS_CPE_TD ) )
@@ -813,9 +820,9 @@ ivas_error ivas_compute_core_buffers_fx(
/* no resampling needed, only delay adjustment to account for the FIR resampling delay */
delay = NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS );
move16();
- Copy( st->mem_decim16k_fx + delay, new_inp_16k_fx - sub( lMemRecalc, add( delay, L_FILT16k ) ), delay );
- Copy( signal_in_fx - lMemRecalc, new_inp_16k_fx - add( lMemRecalc, L_FILT16k ), add( input_frame, lMemRecalc ) );
- Copy( signal_in_fx + sub( sub( input_frame, lMemRecalc ), shl( delay, 1 ) ), st->mem_decim16k_fx, shl( delay, 1 ) );
+ Copy( st->mem_decim16k_fx + delay, new_inp_16k_fx - sub( lMemRecalc, add( delay, L_FILT16k ) ), delay ); /* Q(-1) */
+ Copy( signal_in_fx - lMemRecalc, new_inp_16k_fx - add( lMemRecalc, L_FILT16k ), add( input_frame, lMemRecalc ) ); /* st->q_inp */
+ Copy( signal_in_fx + sub( sub( input_frame, lMemRecalc ), shl( delay, 1 ) ), st->mem_decim16k_fx, shl( delay, 1 ) ); /* st->q_inp */
}
ELSE IF( EQ_32( input_Fs, 32000 ) || EQ_32( input_Fs, 48000 ) )
{
@@ -827,30 +834,30 @@ ivas_error ivas_compute_core_buffers_fx(
Word16 length_16k = NS2SA_FX2( INT_FS_16k, L_MEM_RECALC_SCH_NS - DELAY_FIR_RESAMPL_NS );
move16();
- Copy( signal_in_fx - lMemRecalc - length_inp - 2 * NS2SA( input_Fs, DELAY_FIR_RESAMPL_NS ), st->mem_decim16k_fx, 2 * NS2SA( input_Fs, DELAY_FIR_RESAMPL_NS ) );
- size_modified = modify_Fs_ivas_fx( signal_in_fx - lMemRecalc - length_inp, length_inp, input_Fs, new_inp_16k_fx - lMemRecalc_16k - length_16k, sr_core, st->mem_decim16k_fx, 0, &Q_tmp, &mem_decim16k_size );
- Scale_sig( new_inp_16k_fx - lMemRecalc_16k - length_16k, size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */
+ Copy( signal_in_fx - lMemRecalc - length_inp - 2 * NS2SA( input_Fs, DELAY_FIR_RESAMPL_NS ), st->mem_decim16k_fx, 2 * NS2SA( input_Fs, DELAY_FIR_RESAMPL_NS ) ); /* st->q_inp */
+ size_modified = modify_Fs_ivas_fx( signal_in_fx - lMemRecalc - length_inp, length_inp, input_Fs, new_inp_16k_fx - lMemRecalc_16k - length_16k, sr_core, st->mem_decim16k_fx, 0, &Q_tmp, &mem_decim16k_size ); /* Q0 */
+ Scale_sig( new_inp_16k_fx - lMemRecalc_16k - length_16k, size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */
}
- size_modified = modify_Fs_ivas_fx( signal_in_fx - lMemRecalc, input_frame, input_Fs, new_inp_16k_fx - ( lMemRecalc * sr_core ) / st->input_Fs, sr_core, st->mem_decim16k_fx, 0, &Q_tmp, &mem_decim16k_size );
- Scale_sig( new_inp_16k_fx - ( lMemRecalc * sr_core ) / st->input_Fs, size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */
+ size_modified = modify_Fs_ivas_fx( signal_in_fx - lMemRecalc, input_frame, input_Fs, new_inp_16k_fx - ( lMemRecalc * sr_core ) / st->input_Fs, sr_core, st->mem_decim16k_fx, 0, &Q_tmp, &mem_decim16k_size ); /* Q0 */
+ Scale_sig( new_inp_16k_fx - ( lMemRecalc * sr_core ) / st->input_Fs, size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */
Copy( st->mem_decim16k_fx, mem_decim16k_dummy_fx, 2 * L_FILT_MAX );
IF( lMemRecalc > 0 )
{
- size_modified = modify_Fs_ivas_fx( signal_in_fx - lMemRecalc + input_frame, lMemRecalc, input_Fs, new_inp_16k_fx + NS2SA( sr_core, FRAME_SIZE_NS ) - ( lMemRecalc * sr_core ) / st->input_Fs, sr_core, mem_decim16k_dummy_fx, 0, &Q_tmp, &mem_decim16k_size );
- Scale_sig( new_inp_16k_fx + NS2SA( sr_core, FRAME_SIZE_NS ) - ( lMemRecalc * sr_core ) / st->input_Fs, size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */
+ size_modified = modify_Fs_ivas_fx( signal_in_fx - lMemRecalc + input_frame, lMemRecalc, input_Fs, new_inp_16k_fx + NS2SA( sr_core, FRAME_SIZE_NS ) - ( lMemRecalc * sr_core ) / st->input_Fs, sr_core, mem_decim16k_dummy_fx, 0, &Q_tmp, &mem_decim16k_size ); /* Q0 */
+ Scale_sig( new_inp_16k_fx + NS2SA( sr_core, FRAME_SIZE_NS ) - ( lMemRecalc * sr_core ) / st->input_Fs, size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */
}
set16_fx( temp1F_icatdmResampBuf_fx, 0, L_FILT_MAX );
- size_modified = modify_Fs_ivas_fx( temp1F_icatdmResampBuf_fx, NS2SA( input_Fs, DELAY_FIR_RESAMPL_NS ), input_Fs, new_inp_16k_fx + NS2SA( sr_core, FRAME_SIZE_NS ), sr_core, mem_decim16k_dummy_fx, 0, &Q_tmp, &mem_decim16k_size );
- Scale_sig( new_inp_16k_fx + NS2SA( sr_core, FRAME_SIZE_NS ), size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */
+ size_modified = modify_Fs_ivas_fx( temp1F_icatdmResampBuf_fx, NS2SA( input_Fs, DELAY_FIR_RESAMPL_NS ), input_Fs, new_inp_16k_fx + NS2SA( sr_core, FRAME_SIZE_NS ), sr_core, mem_decim16k_dummy_fx, 0, &Q_tmp, &mem_decim16k_size ); /* Q0 */
+ Scale_sig( new_inp_16k_fx + NS2SA( sr_core, FRAME_SIZE_NS ), size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */
}
}
ELSE IF( st->idchan == 0 )
{
/* update the FIR resampling filter memory, needed for switching to time-domain (FIR) resampling */
- Copy( signal_in_fx + input_frame - NS2SA( input_Fs, L_MEM_RECALC_NS ) - 2 * NS2SA( input_Fs, DELAY_FIR_RESAMPL_NS ), st->mem_decim16k_fx, 2 * NS2SA( input_Fs, DELAY_FIR_RESAMPL_NS ) );
+ Copy( signal_in_fx + input_frame - NS2SA( input_Fs, L_MEM_RECALC_NS ) - 2 * NS2SA( input_Fs, DELAY_FIR_RESAMPL_NS ), st->mem_decim16k_fx, 2 * NS2SA( input_Fs, DELAY_FIR_RESAMPL_NS ) ); /* st->q_inp */
}
/*------------------------------------------------*
@@ -866,12 +873,12 @@ ivas_error ivas_compute_core_buffers_fx(
IF( EQ_16( element_mode, IVAS_CPE_DFT ) )
{
/* save input resampled at 16kHz, non-preemphasised.*/
- Copy( new_inp_16k_fx, new_inp_resamp16k_fx, L_FRAME16k );
+ Copy( new_inp_16k_fx, new_inp_resamp16k_fx, L_FRAME16k ); /* Q_old_inp_16k */
IF( EQ_16( st->bwidth, WB ) )
{
- Copy_Scale_sig( new_inp_16k_fx - delay, st->hBWE_FD->old_input_wb_fx, delay, -( Q_old_inp_16k + 1 ) ); /* Scaling to Q(-1) */
- Copy( new_inp_16k_fx - STEREO_DFT_OVL_16k, st->hBWE_FD->L_old_wtda_swb_fx + L_FRAME16k - STEREO_DFT_OVL_16k + delay, STEREO_DFT_OVL_16k - delay ); /* Check Q here once. Q should be Q_old_wtda */
+ Copy_Scale_sig( new_inp_16k_fx - delay, st->hBWE_FD->old_input_wb_fx, delay, negate( add( Q_old_inp_16k, 1 ) ) ); /* Scaling to Q(-1) */
+ Copy( new_inp_16k_fx - STEREO_DFT_OVL_16k, st->hBWE_FD->L_old_wtda_swb_fx + L_FRAME16k - STEREO_DFT_OVL_16k + delay, sub( STEREO_DFT_OVL_16k, delay ) ); /* Check Q here once. Q should be Q_old_wtda */
}
}
ELSE IF( EQ_16( element_mode, IVAS_CPE_TD ) )
@@ -882,18 +889,18 @@ ivas_error ivas_compute_core_buffers_fx(
test();
IF( EQ_16( st->bwidth, WB ) && st->hBWE_FD != NULL )
{
- Copy_Scale_sig( new_inp_16k_fx + L_FILT16k - delay, st->hBWE_FD->old_input_wb_fx, delay, -( Q_old_inp_16k + 1 ) ); /* Scaling to Q(-1) */
- Copy( new_inp_16k_fx - L_MEM_RECALC_16K, st->hBWE_FD->L_old_wtda_swb_fx + L_FRAME16k - L_MEM_RECALC_16K - L_FILT16k + delay, L_MEM_RECALC_16K + L_FILT16k - delay ); /* Check Q here once. Q should be Q_old_wtda */
+ Copy_Scale_sig( new_inp_16k_fx + L_FILT16k - delay, st->hBWE_FD->old_input_wb_fx, delay, negate( add( Q_old_inp_16k, 1 ) ) ); /* Scaling to Q(-1) */
+ Copy( new_inp_16k_fx - L_MEM_RECALC_16K, st->hBWE_FD->L_old_wtda_swb_fx + L_FRAME16k - L_MEM_RECALC_16K - L_FILT16k + delay, sub( L_MEM_RECALC_16K + L_FILT16k, delay ) ); /* Check Q here once. Q should be Q_old_wtda */
}
}
ELSE IF( element_mode == IVAS_SCE )
{
/* save input resampled at 16kHz, non-preemphasised */
- Copy( new_inp_16k_fx + L_FILT16k, new_inp_resamp16k_fx, L_FRAME16k );
+ Copy( new_inp_16k_fx + L_FILT16k, new_inp_resamp16k_fx, L_FRAME16k ); /* Q_old_inp_16k */
IF( EQ_16( st->bwidth, WB ) )
{
- Copy_Scale_sig( new_inp_16k_fx, st->hBWE_FD->old_input_wb_fx + delay - L_FILT16k, L_FILT16k, -( Q_old_inp_16k + 1 ) ); /* Scaling to Q(-1) */
+ Copy_Scale_sig( new_inp_16k_fx, st->hBWE_FD->old_input_wb_fx + delay - L_FILT16k, L_FILT16k, negate( add( Q_old_inp_16k, 1 ) ) ); /* Scaling to Q(-1) */
/* all buffer st->hBWE_FD->old_wtda_swb is correct and does not need to be updated */
}
}
@@ -913,7 +920,7 @@ ivas_error ivas_compute_core_buffers_fx(
test();
if ( st->tcxonly == 0 && !( ( EQ_16( element_mode, IVAS_CPE_TD ) && EQ_16( st->idchan, 1 ) ) || EQ_16( element_mode, IVAS_CPE_MDCT ) ) )
{
- st->mem_preemph_enc = new_inp_16k_fx[L_frame_tmp - 1];
+ st->mem_preemph_enc = new_inp_16k_fx[L_frame_tmp - 1]; /* Q(-1) */
move16();
}
@@ -925,7 +932,7 @@ ivas_error ivas_compute_core_buffers_fx(
set32_fx( sig_out, 0, 960 );
test();
test();
- 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 );
}
@@ -935,24 +942,24 @@ ivas_error ivas_compute_core_buffers_fx(
{
IF( EQ_16( element_mode, IVAS_CPE_DFT ) )
{
- Copy( new_inp_16k_fx - STEREO_DFT_OVL_16k + L_FRAME16k, st->inp_16k_mem_stereo_sw_fx, STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k ); /* update for TD/DFT stereo switching */
+ Copy( new_inp_16k_fx - STEREO_DFT_OVL_16k + L_FRAME16k, st->inp_16k_mem_stereo_sw_fx, STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k ); /* update for TD/DFT stereo switching Q(-1) */
- st->mem_preemph16k_fx = st->mem_preemph16k_DFT_fx;
+ st->mem_preemph16k_fx = st->mem_preemph16k_DFT_fx; /* Q(-1) */
move16();
- st->mem_preemph16k_DFT_fx = old_inp_16k_fx[L_INP_MEM - STEREO_DFT_OVL_16k + L_FRAME16k - 1];
+ st->mem_preemph16k_DFT_fx = old_inp_16k_fx[L_INP_MEM - STEREO_DFT_OVL_16k + L_FRAME16k - 1]; /* Q_new - 1 */
move16();
IF( EQ_16( st->L_frame, L_FRAME16k ) )
{
- Copy( new_inp_16k_fx - STEREO_DFT_OVL_16k, st->buf_speech_enc + L_FRAME16k - STEREO_DFT_OVL_16k, L_FRAME16k + STEREO_DFT_OVL_16k );
+ Copy( new_inp_16k_fx - STEREO_DFT_OVL_16k, st->buf_speech_enc + L_FRAME16k - STEREO_DFT_OVL_16k, L_FRAME16k + STEREO_DFT_OVL_16k ); /* Q(-1) */
}
// PREEMPH_FX(new_inp_16k_fx - STEREO_DFT_OVL_16k, PREEMPH_FAC_16k, L_FRAME16k, &(st->mem_preemph16k_fx));
- PREEMPH_32FX( new_inp_16k_fx - STEREO_DFT_OVL_16k, sig_out, PREEMPH_FAC_16k, L_FRAME16k, &( st->mem_preemph16k_fx ) );
+ PREEMPH_32FX( new_inp_16k_fx - STEREO_DFT_OVL_16k, sig_out, PREEMPH_FAC_16k, L_FRAME16k, &( st->mem_preemph16k_fx ) ); /* Q(-1) */
tmp_fx = st->mem_preemph16k_fx;
move16();
// PREEMPH_FX(new_inp_16k_fx - STEREO_DFT_OVL_16k + L_FRAME16k, PREEMPH_FAC_16k, STEREO_DFT_OVL_16k, &tmp_fx);
- PREEMPH_32FX( new_inp_16k_fx - STEREO_DFT_OVL_16k + L_FRAME16k, sig_out + L_FRAME16k, PREEMPH_FAC_16k, STEREO_DFT_OVL_16k, &tmp_fx );
+ PREEMPH_32FX( new_inp_16k_fx - STEREO_DFT_OVL_16k + L_FRAME16k, sig_out + L_FRAME16k, PREEMPH_FAC_16k, STEREO_DFT_OVL_16k, &tmp_fx ); /* Q(-1) */
preemp_start_idx = new_inp_16k_fx - STEREO_DFT_OVL_16k;
move16();
preemp_len = STEREO_DFT_OVL_16k + L_FRAME16k;
@@ -964,16 +971,16 @@ ivas_error ivas_compute_core_buffers_fx(
{
st->mem_preemph16k_fx = st->mem_preemph16k_DFT_fx;
move16();
- Copy( st->inp_16k_mem_stereo_sw_fx, new_inp_16k_fx - L_MEM_RECALC_16K - ( STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k ), STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k );
+ Copy( st->inp_16k_mem_stereo_sw_fx, new_inp_16k_fx - L_MEM_RECALC_16K - ( STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k ), STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k ); /* Q(-1) */
// PREEMPH_FX(new_inp_16k_fx - L_MEM_RECALC_16K - (STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k), PREEMPH_FAC_16k, STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k, &st->mem_preemph16k_fx);
- PREEMPH_32FX( new_inp_16k_fx - L_MEM_RECALC_16K - ( STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k ), sig_out, PREEMPH_FAC_16k, STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k, &st->mem_preemph16k_fx );
+ PREEMPH_32FX( new_inp_16k_fx - L_MEM_RECALC_16K - ( STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k ), sig_out, PREEMPH_FAC_16k, STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k, &st->mem_preemph16k_fx ); /* Q(-1) */
preemp_start_idx = new_inp_16k_fx - L_MEM_RECALC_16K - ( STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k );
move16();
preemp_len = STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k;
move16();
}
- st->mem_preemph16k_DFT_fx = old_inp_16k_fx[L_INP_MEM - STEREO_DFT_OVL_16k + L_FRAME16k - 1];
+ st->mem_preemph16k_DFT_fx = old_inp_16k_fx[L_INP_MEM - STEREO_DFT_OVL_16k + L_FRAME16k - 1]; /* Q_new - 1 */
move16();
/* preemphasise past segment of input signal when switching from MDCT stereo */
@@ -983,7 +990,7 @@ ivas_error ivas_compute_core_buffers_fx(
move16();
// PREEMPH_FX(new_inp_16k_fx - lMemRecalc_16k - length_16k, PREEMPH_FAC, length_16k, &st->mem_preemph16k_fx);
- PREEMPH_32FX( new_inp_16k_fx - lMemRecalc_16k - length_16k, sig_out, PREEMPH_FAC, length_16k, &st->mem_preemph16k_fx );
+ PREEMPH_32FX( new_inp_16k_fx - lMemRecalc_16k - length_16k, sig_out, PREEMPH_FAC, length_16k, &st->mem_preemph16k_fx ); /* Q(-1) */
preemp_start_idx = new_inp_16k_fx - lMemRecalc_16k - length_16k;
preemp_len = length_16k;
move16();
@@ -991,14 +998,14 @@ ivas_error ivas_compute_core_buffers_fx(
IF( EQ_16( st->L_frame, L_FRAME16k ) )
{
- Copy( new_inp_16k_fx - lMemRecalc_16k, st->buf_speech_enc + sub( L_FRAME16k - L_FILT16k, lMemRecalc_16k ), add( lMemRecalc_16k, L_FRAME16k + L_FILT16k ) );
+ Copy( new_inp_16k_fx - lMemRecalc_16k, st->buf_speech_enc + sub( L_FRAME16k - L_FILT16k, lMemRecalc_16k ), add( lMemRecalc_16k, L_FRAME16k + L_FILT16k ) ); /* Q_new - 1 */
}
// PREEMPH_FX(new_inp_16k_fx - lMemRecalc_16k, PREEMPH_FAC_16k, L_FRAME16k, &(st->mem_preemph16k_fx));
- PREEMPH_32FX( new_inp_16k_fx - lMemRecalc_16k, sig_out + preemp_len, PREEMPH_FAC_16k, L_FRAME16k, &( st->mem_preemph16k_fx ) );
+ PREEMPH_32FX( new_inp_16k_fx - lMemRecalc_16k, sig_out + preemp_len, PREEMPH_FAC_16k, L_FRAME16k, &( st->mem_preemph16k_fx ) ); /* Q(-1) */
tmp_fx = st->mem_preemph16k_fx;
move16();
// PREEMPH_FX(new_inp_16k_fx - lMemRecalc_16k + L_FRAME16k, PREEMPH_FAC_16k, lMemRecalc_16k + L_FILT16k, &tmp_fx);
- PREEMPH_32FX( new_inp_16k_fx - lMemRecalc_16k + L_FRAME16k, sig_out + preemp_len + L_FRAME16k, PREEMPH_FAC_16k, lMemRecalc_16k + L_FILT16k, &tmp_fx );
+ PREEMPH_32FX( new_inp_16k_fx - lMemRecalc_16k + L_FRAME16k, sig_out + preemp_len + L_FRAME16k, PREEMPH_FAC_16k, lMemRecalc_16k + L_FILT16k, &tmp_fx ); /* Q(-1) */
IF( preemp_start_idx && preemp_len )
{
preemp_len = add( preemp_len, add( L_FRAME16k + L_FILT16k, lMemRecalc_16k ) );
@@ -1014,11 +1021,11 @@ ivas_error ivas_compute_core_buffers_fx(
ELSE IF( EQ_16( element_mode, IVAS_SCE ) )
{
// PREEMPH_FX(new_inp_16k_fx, PREEMPH_FAC_16k, L_FRAME16k, &(st->mem_preemph16k_fx));
- PREEMPH_32FX( new_inp_16k_fx, sig_out, PREEMPH_FAC_16k, L_FRAME16k, &( st->mem_preemph16k_fx ) );
+ PREEMPH_32FX( new_inp_16k_fx, sig_out, PREEMPH_FAC_16k, L_FRAME16k, &( st->mem_preemph16k_fx ) ); /* Q(-1) */
tmp_fx = st->mem_preemph16k_fx;
move16();
// PREEMPH_FX(new_inp_16k_fx + L_FRAME16k, PREEMPH_FAC_16k, L_FILT16k, &tmp_fx);
- PREEMPH_32FX( new_inp_16k_fx + L_FRAME16k, sig_out + L_FRAME16k, PREEMPH_FAC_16k, L_FILT16k, &tmp_fx );
+ PREEMPH_32FX( new_inp_16k_fx + L_FRAME16k, sig_out + L_FRAME16k, PREEMPH_FAC_16k, L_FILT16k, &tmp_fx ); /* Q(-1) */
preemp_start_idx = new_inp_16k_fx;
preemp_len = L_FRAME16k + L_FILT16k;
move16();
@@ -1058,12 +1065,12 @@ ivas_error ivas_compute_core_buffers_fx(
{
IF( EQ_16( element_mode, IVAS_CPE_DFT ) )
{
- st->mem_preemph16k_fx = new_inp_16k_fx[L_frame_tmp - STEREO_DFT_OVL_16k - 1];
+ st->mem_preemph16k_fx = new_inp_16k_fx[L_frame_tmp - STEREO_DFT_OVL_16k - 1]; /* Q_new - 1 */
move16();
}
ELSE IF( EQ_16( element_mode, IVAS_CPE_TD ) )
{
- st->mem_preemph16k_fx = new_inp_16k_fx[L_frame_tmp - lMemRecalc_16k - 1];
+ st->mem_preemph16k_fx = new_inp_16k_fx[L_frame_tmp - lMemRecalc_16k - 1]; /* Q_new - 1 */
move16();
}
ELSE IF( EQ_16( element_mode, IVAS_CPE_MDCT ) )
@@ -1073,10 +1080,10 @@ ivas_error ivas_compute_core_buffers_fx(
}
ELSE /* SCE */
{
- st->mem_preemph16k_fx = new_inp_16k_fx[L_frame_tmp - 1];
+ st->mem_preemph16k_fx = new_inp_16k_fx[L_frame_tmp - 1]; /* Q_new - 1 */
move16();
}
- st->mem_preemph16k_DFT_fx = st->mem_preemph16k_fx;
+ st->mem_preemph16k_DFT_fx = st->mem_preemph16k_fx; /* Q_new - 1 */
move16();
}
@@ -1120,7 +1127,7 @@ ivas_error ivas_compute_core_buffers_fx(
IF( EQ_16( st->last_L_frame, L_FRAME ) )
{
/* this is just an approximation, but it is sufficient */
- Copy( st->lsp_old1_fx, st->lspold_enc_fx, M );
+ Copy( st->lsp_old1_fx, st->lspold_enc_fx, M ); /* Q15 */
}
IF( Q_new )
@@ -1136,7 +1143,7 @@ ivas_error ivas_compute_core_buffers_fx(
* Compute Weighted Input
*---------------------------------------------------------------*/
- ivas_find_wsp( L_FRAME16k, L_SUBFR, NB_SUBFR16k, A_fx, Aw_fx, st->speech_enc_pe, PREEMPH_FAC_16k, st->wspeech_enc, &st->mem_wsp_enc, st->gamma, L_LOOK_16k );
+ ivas_find_wsp_fx( L_FRAME16k, L_SUBFR, NB_SUBFR16k, A_fx, Aw_fx, st->speech_enc_pe, PREEMPH_FAC_16k, st->wspeech_enc, &st->mem_wsp_enc, st->gamma, L_LOOK_16k );
}
/*-----------------------------------------------------------------*
@@ -1165,14 +1172,14 @@ ivas_error ivas_compute_core_buffers_fx(
ELSE IF( GT_32( input_Fs, 8000 ) )
{
lerp( st->old_inp_12k8_fx + L_INP_MEM - L_INP_MEM * 4 / 5, st->old_inp_16k_fx, L_INP_MEM, L_INP_MEM * 4 / 5 );
- Scale_sig( st->old_inp_16k_fx, L_INP_MEM, sub( -1 /* Q st->old_inp_16k_fx = -1 */, sub( 15, st->exp_old_inp_16k ) ) );
+ Scale_sig( st->old_inp_16k_fx, L_INP_MEM, sub( -1 /* Q st->old_inp_16k_fx = -1 */, sub( 15, st->exp_old_inp_12k8 ) ) );
st->exp_old_inp_16k = Q16; // Q-1
move16();
}
IF( inp16k_out_fx != NULL )
{
- *inp16k_out_fx = inp_16k_fx;
+ *inp16k_out_fx = inp_16k_fx; /* Q_new - 1 */
}
IF( new_inp_resamp16k_out_fx != NULL )
diff --git a/lib_enc/ivas_core_pre_proc_front.c b/lib_enc/ivas_core_pre_proc_front.c
index 66e8b9fcf91ad2e9e0cc7e83cb8ec8f985cfaa21..9e09f93f662b0e7ff3d7447316fed3ae9247b2e0 100644
--- a/lib_enc/ivas_core_pre_proc_front.c
+++ b/lib_enc/ivas_core_pre_proc_front.c
@@ -84,57 +84,60 @@ static Word16 get_zero_flag( Word32 arr[], Word16 len )
}
ivas_error pre_proc_front_ivas_fx(
- SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */
- CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
- const Word32 element_brate, /* i : SCE/CPE element bitrate */
- const Word16 nb_bits_metadata, /* i : number of metadata bits */
- const Word16 input_frame, /* i : frame length */
- const Word16 n, /* i : channel number */
- Word16 old_inp_12k8_fx[], /* o : buffer of old input signal Q_new-1 */
- Word16 old_inp_16k_fx[], /* o : buffer of old input signal @16kHz Q_new-1 */
- Word32 *ener_fx, /* o : residual energy from Levinson-Durbin epsP_fx_q */
- Word16 *relE_fx, /* o : frame relative energy Q8 */
- Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* o : A(z) unquantized for the 4 subframes Q12 */
- Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* o : weighted A(z) unquantized for subframes Q12 */
- Word32 epsP_fx[M + 1], /* o : LP prediction errors */
+ SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */
+ CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
+ const Word32 element_brate, /* i : SCE/CPE element bitrate Q0*/
+ const Word16 nb_bits_metadata, /* i : number of metadata bits Q0*/
+ const Word16 input_frame, /* i : frame length Q0*/
+ const Word16 n, /* i : channel number Q0*/
+ Word16 old_inp_12k8_fx[], /* o : buffer of old input signal Q_new-1*/
+ Word16 old_inp_16k_fx[], /* o : buffer of old input signal @16kHz Q_new-1*/
+ Word32 *ener_fx, /* o : residual energy from Levinson-Durbin epsP_fx_q*/
+ Word16 *relE_fx, /* o : frame relative energy Q8*/
+ Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* o : A(z) unquantized for the 4 subframes Q12*/
+ Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* o : weighted A(z) unquantized for subframes Q12*/
+ Word32 epsP_fx[M + 1], /* o : LP prediction errors epsP_fx_q*/
Word16 *epsP_fx_q,
- Word16 lsp_new_fx[M], /* o : LSPs at the end of the frame Q15 */
- Word16 lsp_mid_fx[M], /* o : LSPs in the middle of the frame Q15 */
- Word16 *vad_hover_flag, /* o : VAD hangover flag */
- Word16 *attack_flag, /* o : flag signaling attack */
- Word32 realBuffer_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: real buffer Q(q_re_im_buf) */
- Word32 imagBuffer_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: imag buffer Q(q_re_im_buf) */
- Word16 *q_re_im_buf, /* i/o: Q-factor of real and imag buffer */
- Word16 old_wsp_fx[], /* o : weighted input signal buffer q_old_wsp*/
+ Word16 lsp_new_fx[M], /* o : LSPs at the end of the frame Q15*/
+ Word16 lsp_mid_fx[M], /* o : LSPs in the middle of the frame Q15*/
+ Word16 *vad_hover_flag, /* o : VAD hangover flag Q0*/
+ Word16 *attack_flag, /* o : flag signaling attack Q0*/
+ Word32 realBuffer_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: real buffer Q(q_re_im_buf)*/
+ Word32 imagBuffer_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: imag buffer Q(q_re_im_buf)*/
+ Word16 *q_re_im_buf, /* i/o: Q-factor of real and imag buffer */
+ Word16 old_wsp_fx[], /* o : weighted input signal buffer q_old_wsp*/
Word16 *q_old_wsp,
- Word16 pitch_fr_fx[NB_SUBFR], /* o : fractional pitch values Q6 */
- Word16 voicing_fr_fx[NB_SUBFR], /* o : fractional pitch gains Q15 */
- Word16 *loc_harm, /* o : harmonicity flag */
- Word16 *cor_map_sum_fx, /* o : speech/music clasif. parameter Q8 */
- Word16 *vad_flag_dtx, /* o : HE-SAD flag with additional DTX HO */
- Word32 enerBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : energy buffer */
- Word16 *enerBuffer_fx_exp, /* o : energy buffer */
- Word16 fft_buff_fx[2 * L_FFT], /* o : FFT buffer */
- Word16 *fft_buff_fx_q, /* o : FFT buffer */
- const Word16 tdm_A_PCh_fx[M + 1], /* i : unq. LP coeff. of primary channel Q12 */
- const Word16 tdm_lsp_new_PCh_fx[M], /* i : unq. LSPs of primary channel Q15 */
- const Word16 currFlatness_fx, /* i : flatness parameter Q7 */
- const Word16 tdm_ratio_idx, /* i : Current Ratio_L index */
- Word32 fr_bands_LR_fx[][2 * NB_BANDS], /* i : energy in frequency bands (fr_bands_LR_fx_q) */
- Word16 fr_bands_LR_fx_q,
- const Word16 Etot_LR_fx[], /* i : total energy Left & Right channel Q8*/
- Word32 lf_E_LR_fx[][2 * VOIC_BINS], /* i : per bin spectrum energy in lf, LR channels (lf_E_LR_fx_q) */
+ Word16 pitch_fr_fx[NB_SUBFR], /* o : fractional pitch values Q6*/
+ Word16 voicing_fr_fx[NB_SUBFR], /* o : fractional pitch gains Q15*/
+ Word16 *loc_harm, /* o : harmonicity flag Q0*/
+ Word16 *cor_map_sum_fx, /* o : speech/music clasif. parameter Q8*/
+ Word16 *vad_flag_dtx, /* o : HE-SAD flag with additional DTX HO Q0*/
+ Word32 enerBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : energy buffer enerBuffer_fx_exp*/
+ Word16 *enerBuffer_fx_exp, /* o : energy buffer */
+ Word16 fft_buff_fx[2 * L_FFT], /* o : FFT buffer fft_buff_fx_q*/
+ Word16 *fft_buff_fx_q, /* o : FFT buffer */
+ const Word16 tdm_A_PCh_fx[M + 1], /* i : unq. LP coeff. of primary channel Q12*/
+ const Word16 tdm_lsp_new_PCh_fx[M], /* i : unq. LSPs of primary channel Q15*/
+ const Word16 currFlatness_fx, /* i : flatness parameter Q7*/
+ const Word16 tdm_ratio_idx, /* i : Current Ratio_L index Q0*/
+ Word32 fr_bands_LR_fx[][2 * NB_BANDS], /* i : energy in frequency bands (fr_bands_LR_fx_q) fr_bands_LR_fx_q*/
+ Word16 fr_bands_LR_fx_q[CPE_CHANNELS],
+ const Word16 Etot_LR_fx[], /* i : total energy Left & Right channel Q8*/
+ Word32 lf_E_LR_fx[][2 * VOIC_BINS], /* i : per bin spectrum energy in lf, LR channels (lf_E_LR_fx_q)*/
Word16 lf_E_LR_fx_q,
- const Word16 localVAD_HE_SAD_LR[], /* i : HE-SAD flag without hangover, LR channels */
- Word32 band_energies_LR_fx[2 * NB_BANDS], /* o : energy in critical bands without minimum noise floor E_MIN (band_energies_LR_fx_q) */
+ const Word16 localVAD_HE_SAD_LR[], /* i : HE-SAD flag without hangover, LR channels Q0*/
+ Word32 band_energies_LR_fx[2 * NB_BANDS], /* o : energy in critical bands without minimum noise floor E_MIN (band_energies_LR_fx_q)*/
Word16 band_energies_LR_fx_q,
- const Word16 flag_16k_smc, /* i : flag to indicate if the OL SMC is run at 16 kHz */
- const Word16 front_vad_flag, /* i : front-VAD flag to overwrite VAD decision */
- const Word16 force_front_vad, /* i : flag to force VAD decision */
- const Word16 front_vad_dtx_flag, /* i : front-VAD DTX flag to overwrite VAD decision*/
- const IVAS_FORMAT ivas_format, /* i : IVAS format */
- const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) */
- const Word32 ivas_total_brate, /* i : IVAS total bitrate - for setting the DTX */
+ const Word16 flag_16k_smc, /* i : flag to indicate if the OL SMC is run at 16 kHz Q0*/
+ const Word16 front_vad_flag, /* i : front-VAD flag to overwrite VAD decision Q0*/
+ const Word16 force_front_vad, /* i : flag to force VAD decision Q0*/
+ const Word16 front_vad_dtx_flag, /* i : front-VAD DTX flag to overwrite VAD decision Q0*/
+ const IVAS_FORMAT ivas_format, /* i : IVAS format */
+ const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/
+#ifdef NONBE_1211_DTX_BR_SWITCHING
+ const Word32 last_ivas_total_brate, /* i : last IVAS total bitrate Q0*/
+#endif
+ const Word32 ivas_total_brate, /* i : IVAS total bitrate - for setting the DTX Q0*/
Word16 *Q_new
#ifdef DEBUG_MODE_INFO
,
@@ -153,21 +156,21 @@ ivas_error pre_proc_front_ivas_fx(
}
Word16 old_inp_12k8_e;
Word16 shift = getScaleFactor16( st->old_inp_12k8_fx, 240 );
- Scale_sig( st->old_inp_12k8_fx, 240, shift );
+ Scale_sig( st->old_inp_12k8_fx, 240, shift ); /* exp(st->exp_old_inp_12k8 - shift) */
st->exp_old_inp_12k8 = sub( st->exp_old_inp_12k8, shift );
move16();
shift = getScaleFactor16( old_inp_12k8_fx, 496 );
- Scale_sig( old_inp_12k8_fx, 496, shift );
+ Scale_sig( old_inp_12k8_fx, 496, shift ); /* exp(16 - shift) */
old_inp_12k8_e = sub( Q16, shift );
IF( GT_16( old_inp_12k8_e, st->exp_old_inp_12k8 ) )
{
- Scale_sig( st->old_inp_12k8_fx, 240, sub( st->exp_old_inp_12k8, old_inp_12k8_e ) );
+ Scale_sig( st->old_inp_12k8_fx, 240, sub( st->exp_old_inp_12k8, old_inp_12k8_e ) ); /* exp(old_inp_12k8_e) */
st->exp_old_inp_12k8 = old_inp_12k8_e;
move16();
}
ELSE
{
- Scale_sig( old_inp_12k8_fx, 496, sub( old_inp_12k8_e, st->exp_old_inp_12k8 ) );
+ Scale_sig( old_inp_12k8_fx, 496, sub( old_inp_12k8_e, st->exp_old_inp_12k8 ) ); /* exp(st->exp_old_inp_12k8) */
old_inp_12k8_e = st->exp_old_inp_12k8;
move16();
}
@@ -247,7 +250,7 @@ ivas_error pre_proc_front_ivas_fx(
Word16 realBuffer16[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
Word16 imagBuffer16[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
Word16 res_cod_SNR_M_fx_e[STEREO_DFT_BAND_MAX];
- Word16 band_energies_fx_exp, Qfact_PS, q_lf_E_fx;
+ Word16 Qfact_PS, q_lf_E_fx;
#ifdef DEBUG_MODE_INFO
Word32 *in_buff_temp;
Word16 in_q_temp;
@@ -259,14 +262,19 @@ 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 ) );
- 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 ) );
+#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 ) );
+ Scale_sig( hSCE->hCoreCoder[n]->input_fx, input_frame, sub( -1, hSCE->hCoreCoder[n]->q_inp ) ); /* Q(-1) */
hSCE->hCoreCoder[n]->q_inp = -1;
move16();
- Scale_sig( hSCE->hCoreCoder[n]->old_input_signal_fx, input_frame, sub( -1, hSCE->hCoreCoder[n]->q_old_inp ) );
+ Scale_sig( hSCE->hCoreCoder[n]->old_input_signal_fx, input_frame, sub( -1, hSCE->hCoreCoder[n]->q_old_inp ) ); /* Q(-1) */
hSCE->hCoreCoder[n]->q_old_inp = -1;
move16();
@@ -277,14 +285,19 @@ 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 ) );
- 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 ) );
+#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 ) );
+ Scale_sig( hCPE->hCoreCoder[n]->input_fx, input_frame, sub( -1, hCPE->hCoreCoder[n]->q_inp ) ); /* Q(-1) */
hCPE->hCoreCoder[n]->q_inp = -1;
move16();
- Scale_sig( hCPE->hCoreCoder[n]->old_input_signal_fx, input_frame, sub( -1, hCPE->hCoreCoder[n]->q_old_inp ) );
+ Scale_sig( hCPE->hCoreCoder[n]->old_input_signal_fx, input_frame, sub( -1, hCPE->hCoreCoder[n]->q_old_inp ) ); /* Q(-1) */
hCPE->hCoreCoder[n]->q_old_inp = -1;
move16();
#ifdef DEBUG_MODE_INFO
@@ -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++ )
{
@@ -345,7 +360,7 @@ ivas_error pre_proc_front_ivas_fx(
move16();
IF( st->cldfbAnaEnc != NULL )
{
- scale_sig32( st->cldfbAnaEnc->cldfb_state_fx, sub( sub( st->cldfbAnaEnc->p_filter_length, st->cldfbAnaEnc->no_channels ), st->cldfbAnaEnc->zeros ), sub( Q11, st->cldfbAnaEnc->Q_cldfb_state ) );
+ scale_sig32( st->cldfbAnaEnc->cldfb_state_fx, sub( sub( st->cldfbAnaEnc->p_filter_length, st->cldfbAnaEnc->no_channels ), st->cldfbAnaEnc->zeros ), sub( Q11, st->cldfbAnaEnc->Q_cldfb_state ) ); /* Q11 */
st->cldfbAnaEnc->Q_cldfb_state = Q11;
move16();
}
@@ -356,10 +371,10 @@ ivas_error pre_proc_front_ivas_fx(
#ifndef REMOVE_IVAS_UNUSED_PARAMETERS_WARNING
signal_in = hSCE->hCoreCoder[n]->input;
#endif
- signal_in_fx = hSCE->hCoreCoder[n]->input_fx;
- signal32_in_fx = hSCE->hCoreCoder[n]->input32_fx;
+ signal_in_fx = hSCE->hCoreCoder[n]->input_fx; /* hSCE->hCoreCoder[n]->q_inp */
+ signal32_in_fx = hSCE->hCoreCoder[n]->input32_fx; /* hSCE->hCoreCoder[n]->q_inp32 */
element_mode = IVAS_SCE;
- last_element_brate = hSCE->last_element_brate;
+ last_element_brate = hSCE->last_element_brate; /* Q0 */
hStereoClassif = NULL;
lr_vad_enabled = 0;
move16();
@@ -372,10 +387,10 @@ ivas_error pre_proc_front_ivas_fx(
#ifndef REMOVE_IVAS_UNUSED_PARAMETERS_WARNING
signal_in = hCPE->hCoreCoder[n]->input;
#endif
- signal_in_fx = hCPE->hCoreCoder[n]->input_fx;
- signal32_in_fx = hCPE->hCoreCoder[n]->input32_fx;
+ signal_in_fx = hCPE->hCoreCoder[n]->input_fx; /* hSCE->hCoreCoder[n]->q_inp */
+ signal32_in_fx = hCPE->hCoreCoder[n]->input32_fx; /* hSCE->hCoreCoder[n]->q_inp32 */
element_mode = hCPE->element_mode;
- last_element_brate = hCPE->last_element_brate;
+ last_element_brate = hCPE->last_element_brate; /* Q0 */
hStereoClassif = hCPE->hStereoClassif;
lr_vad_enabled = 0;
move16();
@@ -399,13 +414,13 @@ ivas_error pre_proc_front_ivas_fx(
IF( hCPE->hStereoTD != NULL )
{
- tdm_SM_last_clas = &hCPE->hStereoTD->tdm_SM_last_clas[n];
- Copy( hCPE->hStereoTD->tdm_SM_last_clas, hCPE->hStereoTD->tdm_SM_last2_clas, CPE_CHANNELS );
+ tdm_SM_last_clas = &hCPE->hStereoTD->tdm_SM_last_clas[n]; /* Q0 */
+ Copy( hCPE->hStereoTD->tdm_SM_last_clas, hCPE->hStereoTD->tdm_SM_last2_clas, CPE_CHANNELS ); /* Q0 */
}
IF( hCPE->hStereoDft != NULL )
{
- res_cod_SNR_M_fx = hCPE->hStereoDft->res_cod_SNR_M_fx;
+ res_cod_SNR_M_fx = hCPE->hStereoDft->res_cod_SNR_M_fx; /* Q(31 - res_cod_SNR_M_fx_e[]) */
}
}
@@ -420,7 +435,7 @@ ivas_error pre_proc_front_ivas_fx(
lMemRecalc_12k8 = NS2SA_FX2( INT_FS_12k8, L_MEM_RECALC_NS );
}
- input_Fs = st->input_Fs;
+ input_Fs = st->input_Fs; /* Q0 */
move32();
localVAD_HE_SAD = 0;
@@ -468,9 +483,9 @@ ivas_error pre_proc_front_ivas_fx(
L_look = L_LOOK_12k8; /* lookahead at 12.8kHz */
move16();
- Scale_sig( old_inp_12k8_fx, L_INP_12k8, sub( Q_to_be_looked_into, sub( Q15, old_inp_12k8_e ) ) );
+ Scale_sig( old_inp_12k8_fx, L_INP_12k8, sub( Q_to_be_looked_into, sub( Q15, old_inp_12k8_e ) ) ); /* Q_to_be_looked_into*/
old_inp_12k8_e = sub( Q15, Q_to_be_looked_into );
- Scale_sig( st->old_inp_12k8_fx, 240, sub( Q_to_be_looked_into, sub( Q15, st->exp_old_inp_12k8 ) ) );
+ Scale_sig( st->old_inp_12k8_fx, 240, sub( Q_to_be_looked_into, sub( Q15, st->exp_old_inp_12k8 ) ) ); /* Q_to_be_looked_into */
st->exp_old_inp_12k8 = sub( Q15, Q_to_be_looked_into );
move16();
new_inp_12k8_fx = old_inp_12k8_fx + L_INP_MEM; /* pointer to new samples of the input signal in 12.8kHz core */
@@ -483,26 +498,26 @@ ivas_error pre_proc_front_ivas_fx(
IF( EQ_16( element_mode, IVAS_CPE_DFT ) )
{
- Copy( st->old_inp_12k8_fx, old_inp_12k8_fx, L_INP_MEM - STEREO_DFT_OVL_12k8 );
+ Copy( st->old_inp_12k8_fx, old_inp_12k8_fx, L_INP_MEM - STEREO_DFT_OVL_12k8 ); /* exp(st->exp_old_inp_12k8) */
}
ELSE IF( EQ_16( element_mode, IVAS_CPE_TD ) )
{
- Copy( st->old_inp_12k8_fx, old_inp_12k8_fx, sub( L_INP_MEM - L_FILT, lMemRecalc_12k8 ) );
+ Copy( st->old_inp_12k8_fx, old_inp_12k8_fx, sub( L_INP_MEM - L_FILT, lMemRecalc_12k8 ) ); /* exp(st->exp_old_inp_12k8) */
}
ELSE
{
- Copy( st->old_inp_12k8_fx, old_inp_12k8_fx, L_INP_MEM - L_FILT );
+ Copy( st->old_inp_12k8_fx, old_inp_12k8_fx, L_INP_MEM - L_FILT ); /* exp(st->exp_old_inp_12k8) */
}
- Copy( st->old_wsp_fx, old_wsp_fx, L_WSP_MEM );
+ Copy( st->old_wsp_fx, old_wsp_fx, L_WSP_MEM ); /* exp(st->exp_old_wsp) */
*q_old_wsp = sub( Q15, st->exp_old_wsp );
move16();
wsp_fx = old_wsp_fx + L_WSP_MEM; /* pointer to the current frame of weighted signal in 12.8kHz core */
- st->rf_mode = st->Opt_RF_ON;
+ st->rf_mode = st->Opt_RF_ON; /* Q0 */
move16();
- last_core_orig = st->last_core;
+ last_core_orig = st->last_core; /* Q0 */
move16();
/*--------------------------------------------------------------*
@@ -545,13 +560,13 @@ ivas_error pre_proc_front_ivas_fx(
test();
IF( EQ_16( element_mode, IVAS_SCE ) )
{
- new_inp_out_size = modify_Fs_ivas_fx( signal_in_fx, input_frame, input_Fs, new_inp_12k8_fx, INT_FS_12k8, st->mem_decim_fx, ( st->max_bwidth == NB ), &Q_new_inp, &mem_decim_size );
- Scale_sig( new_inp_12k8_fx, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to Q_to_be_looked_into*/
+ new_inp_out_size = modify_Fs_ivas_fx( signal_in_fx, input_frame, input_Fs, new_inp_12k8_fx, INT_FS_12k8, st->mem_decim_fx, ( st->max_bwidth == NB ), &Q_new_inp, &mem_decim_size ); /* Q0 */
+ Scale_sig( new_inp_12k8_fx, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to Q_to_be_looked_into*/
- Copy( st->mem_decim_fx, mem_decim_dummy_fx, 2 * L_FILT_MAX );
+ Copy( st->mem_decim_fx, mem_decim_dummy_fx, 2 * L_FILT_MAX ); /* Q(-1) */
set16_fx( temp1F_icatdmResampBuf_fx, 0, L_FILT_MAX );
- new_inp_out_size = modify_Fs_ivas_fx( temp1F_icatdmResampBuf_fx, NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS ), input_Fs, new_inp_12k8_fx + L_FRAME, INT_FS_12k8, mem_decim_dummy_fx, 0, &Q_new_inp, &mem_decim_size );
- Scale_sig( new_inp_12k8_fx + L_FRAME, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to Q_to_be_looked_into*/
+ new_inp_out_size = modify_Fs_ivas_fx( temp1F_icatdmResampBuf_fx, NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS ), input_Fs, new_inp_12k8_fx + L_FRAME, INT_FS_12k8, mem_decim_dummy_fx, 0, &Q_new_inp, &mem_decim_size ); /* Q0 */
+ Scale_sig( new_inp_12k8_fx + L_FRAME, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to Q_to_be_looked_into*/
}
ELSE IF( EQ_16( element_mode, IVAS_CPE_TD ) || EQ_16( element_mode, IVAS_CPE_MDCT ) )
{
@@ -562,30 +577,30 @@ ivas_error pre_proc_front_ivas_fx(
Word16 length_inp = NS2SA_FX2( input_Fs, L_MEM_RECALC_SCH_NS );
Word16 length_12k8 = NS2SA_FX2( INT_FS_12k8, L_MEM_RECALC_SCH_NS );
- new_inp_out_size = modify_Fs_ivas_fx( signal_in_fx - lMemRecalc - length_inp, length_inp, input_Fs, new_inp_12k8_fx - lMemRecalc_12k8 - length_12k8, INT_FS_12k8, st->mem_decim_fx, 0, &Q_new_inp, &mem_decim_size );
- Scale_sig( new_inp_12k8_fx - lMemRecalc_12k8 - length_12k8, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to Q_to_be_looked_into*/
+ new_inp_out_size = modify_Fs_ivas_fx( signal_in_fx - lMemRecalc - length_inp, length_inp, input_Fs, new_inp_12k8_fx - lMemRecalc_12k8 - length_12k8, INT_FS_12k8, st->mem_decim_fx, 0, &Q_new_inp, &mem_decim_size ); /* Q0 */
+ Scale_sig( new_inp_12k8_fx - lMemRecalc_12k8 - length_12k8, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to Q_to_be_looked_into*/
}
- new_inp_out_size = modify_Fs_ivas_fx( signal_in_fx - lMemRecalc, input_frame, input_Fs, new_inp_12k8_fx - lMemRecalc_12k8, INT_FS_12k8, st->mem_decim_fx, ( st->max_bwidth == NB ), &Q_new_inp, &mem_decim_size );
- Copy( st->mem_decim_fx, mem_decim_dummy_fx, 2 * L_FILT_MAX );
- Scale_sig( new_inp_12k8_fx - lMemRecalc_12k8, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to Q_to_be_looked_into*/
+ new_inp_out_size = modify_Fs_ivas_fx( signal_in_fx - lMemRecalc, input_frame, input_Fs, new_inp_12k8_fx - lMemRecalc_12k8, INT_FS_12k8, st->mem_decim_fx, ( st->max_bwidth == NB ), &Q_new_inp, &mem_decim_size ); /* Q0 */
+ Copy( st->mem_decim_fx, mem_decim_dummy_fx, 2 * L_FILT_MAX ); /* Q(-1) */
+ Scale_sig( new_inp_12k8_fx - lMemRecalc_12k8, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to Q_to_be_looked_into*/
IF( lMemRecalc > 0 )
{
- new_inp_out_size = modify_Fs_ivas_fx( signal_in_fx + sub( input_frame, lMemRecalc ), lMemRecalc, input_Fs, new_inp_12k8_fx + sub( L_FRAME, lMemRecalc_12k8 ), INT_FS_12k8, mem_decim_dummy_fx, ( st->max_bwidth == NB ), &Q_new_inp, &mem_decim_size );
- Scale_sig( new_inp_12k8_fx + sub( L_FRAME, lMemRecalc_12k8 ), new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to Q_to_be_looked_into*/
+ new_inp_out_size = modify_Fs_ivas_fx( signal_in_fx + sub( input_frame, lMemRecalc ), lMemRecalc, input_Fs, new_inp_12k8_fx + sub( L_FRAME, lMemRecalc_12k8 ), INT_FS_12k8, mem_decim_dummy_fx, ( st->max_bwidth == NB ), &Q_new_inp, &mem_decim_size ); /* Q0 */
+ Scale_sig( new_inp_12k8_fx + L_FRAME - lMemRecalc_12k8, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to Q_to_be_looked_into*/
}
set16_fx( temp1F_icatdmResampBuf_fx, 0, L_FILT_MAX );
- new_inp_out_size = modify_Fs_ivas_fx( temp1F_icatdmResampBuf_fx, NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS ), input_Fs, new_inp_12k8_fx + L_FRAME, INT_FS_12k8, mem_decim_dummy_fx, 0, &Q_new_inp, &mem_decim_size );
- Scale_sig( new_inp_12k8_fx + L_FRAME, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to Q_to_be_looked_into*/
+ new_inp_out_size = modify_Fs_ivas_fx( temp1F_icatdmResampBuf_fx, NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS ), input_Fs, new_inp_12k8_fx + L_FRAME, INT_FS_12k8, mem_decim_dummy_fx, 0, &Q_new_inp, &mem_decim_size ); /* Q0 */
+ Scale_sig( new_inp_12k8_fx + L_FRAME, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to Q_to_be_looked_into*/
}
ELSE /* DFT stereo */
{
/* update the FIR resampling filter memory, needed for switching to time-domain (FIR) resampling */
- Copy( signal_in_fx + sub( input_frame, add( NS2SA_FX2( input_Fs, L_MEM_RECALC_NS ), 2 * NS2SA( input_Fs, DELAY_FIR_RESAMPL_NS ) ) ), st->mem_decim_fx, 2 * NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS ) );
+ Copy( signal_in_fx + sub( input_frame, add( NS2SA_FX2( input_Fs, L_MEM_RECALC_NS ), 2 * NS2SA( input_Fs, DELAY_FIR_RESAMPL_NS ) ) ), st->mem_decim_fx, 2 * NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS ) ); /* hSCE->hCoreCoder[n]->q_inp */
}
- Scale_sig( st->buf_speech_enc, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, sub( -1, sub( 15, st->exp_buf_speech_enc ) ) );
+ Scale_sig( st->buf_speech_enc, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, sub( -1, sub( 15, st->exp_buf_speech_enc ) ) ); /* Q(-1) */
st->exp_buf_speech_enc = 16;
move16();
@@ -593,15 +608,15 @@ ivas_error pre_proc_front_ivas_fx(
test();
IF( EQ_16( element_mode, IVAS_CPE_DFT ) )
{
- Copy( new_inp_12k8_fx - STEREO_DFT_OVL_12k8, st->buf_speech_enc + L_FRAME32k - STEREO_DFT_OVL_12k8, L_FRAME + STEREO_DFT_OVL_12k8 );
+ Copy( new_inp_12k8_fx - STEREO_DFT_OVL_12k8, st->buf_speech_enc + L_FRAME32k - STEREO_DFT_OVL_12k8, L_FRAME + STEREO_DFT_OVL_12k8 ); /* Q_to_be_looked_into */
}
ELSE IF( EQ_16( element_mode, IVAS_CPE_TD ) || EQ_16( element_mode, IVAS_CPE_MDCT ) )
{
- Copy( new_inp_12k8_fx - lMemRecalc_12k8, st->buf_speech_enc + L_FRAME32k - lMemRecalc_12k8 - L_FILT, add( L_FRAME + L_FILT, lMemRecalc_12k8 ) );
+ Copy( new_inp_12k8_fx - lMemRecalc_12k8, st->buf_speech_enc + L_FRAME32k - lMemRecalc_12k8 - L_FILT, add( L_FRAME + L_FILT, lMemRecalc_12k8 ) ); /* Q_to_be_looked_into */
}
ELSE
{
- Copy( new_inp_12k8_fx, st->buf_speech_enc + L_FRAME32k, L_FRAME );
+ Copy( new_inp_12k8_fx, st->buf_speech_enc + L_FRAME32k, L_FRAME ); /* Q_to_be_looked_into */
}
/*------------------------------------------------------------------*
@@ -617,7 +632,7 @@ ivas_error pre_proc_front_ivas_fx(
test();
test();
- IF( ( st->bwidth == NB || 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 );
}
@@ -625,11 +640,11 @@ ivas_error pre_proc_front_ivas_fx(
test();
IF( EQ_16( element_mode, IVAS_CPE_DFT ) )
{
- Copy( new_inp_12k8_fx - STEREO_DFT_OVL_12k8 + L_FRAME, st->inp_12k8_mem_stereo_sw_fx, STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT ); /* memory for TD/DFT stereo switching */
+ Copy( new_inp_12k8_fx - STEREO_DFT_OVL_12k8 + L_FRAME, st->inp_12k8_mem_stereo_sw_fx, STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT ); /* memory for TD/DFT stereo switching Q_to_be_looked_into*/
- st->mem_preemph_fx = st->mem_preemph_DFT_fx;
+ st->mem_preemph_fx = st->mem_preemph_DFT_fx; /* Q(-1) */
move16();
- st->mem_preemph_DFT_fx = old_inp_12k8_fx[L_INP_MEM - STEREO_DFT_OVL_12k8 + L_FRAME - 1];
+ st->mem_preemph_DFT_fx = old_inp_12k8_fx[L_INP_MEM - STEREO_DFT_OVL_12k8 + L_FRAME - 1]; /* Q_new - 1 */
move16();
// PREEMPH_FX( new_inp_12k8_fx - STEREO_DFT_OVL_12k8, PREEMPH_FAC, L_FRAME, &st->mem_preemph_fx );
@@ -652,7 +667,7 @@ ivas_error pre_proc_front_ivas_fx(
{
st->mem_preemph_fx = st->mem_preemph_DFT_fx;
move16();
- Copy( st->inp_12k8_mem_stereo_sw_fx, new_inp_12k8_fx - L_MEM_RECALC_12K8 - ( STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT ), STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT );
+ Copy( st->inp_12k8_mem_stereo_sw_fx, new_inp_12k8_fx - L_MEM_RECALC_12K8 - ( STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT ), STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT ); /* Q(-1) */
// PREEMPH_FX( new_inp_12k8_fx - L_MEM_RECALC_12K8 - ( STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT ), PREEMPH_FAC, STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT, &st->mem_preemph_fx );
PREEMPH_32FX( new_inp_12k8_fx - L_MEM_RECALC_12K8 - ( STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT ), sig_out, PREEMPH_FAC, STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT, &st->mem_preemph_fx );
preemp_start_idx = new_inp_12k8_fx - L_MEM_RECALC_12K8 - ( STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT );
@@ -661,7 +676,7 @@ ivas_error pre_proc_front_ivas_fx(
move16();
}
- st->mem_preemph_DFT_fx = old_inp_12k8_fx[L_INP_MEM - STEREO_DFT_OVL_12k8 + L_FRAME - 1]; /* == inp_12k8[L_FRAME-1] */
+ st->mem_preemph_DFT_fx = old_inp_12k8_fx[L_INP_MEM - STEREO_DFT_OVL_12k8 + L_FRAME - 1]; /* == inp_12k8[L_FRAME-1] Q_new - 1 */
move16();
}
@@ -680,7 +695,7 @@ ivas_error pre_proc_front_ivas_fx(
// PREEMPH_FX( new_inp_12k8_fx - lMemRecalc_12k8, PREEMPH_FAC, L_FRAME, &st->mem_preemph_fx );
PREEMPH_32FX( new_inp_12k8_fx - lMemRecalc_12k8, sig_out + preemp_len, PREEMPH_FAC, L_FRAME, &st->mem_preemph_fx );
- dummy_fx = st->mem_preemph_fx;
+ dummy_fx = st->mem_preemph_fx; /* Q(-1) */
move16();
// PREEMPH_FX( new_inp_12k8_fx - lMemRecalc_12k8 + L_FRAME, PREEMPH_FAC, lMemRecalc_12k8 + L_FILT, &dummy_fx );
PREEMPH_32FX( new_inp_12k8_fx - lMemRecalc_12k8 + L_FRAME, sig_out + preemp_len + L_FRAME, PREEMPH_FAC, lMemRecalc_12k8 + L_FILT, &dummy_fx );
@@ -688,13 +703,13 @@ ivas_error pre_proc_front_ivas_fx(
test();
IF( preemp_start_idx && preemp_len )
{
- preemp_len = add( preemp_len, add( L_FRAME + L_FILT, lMemRecalc_12k8 ) );
+ preemp_len = add( preemp_len, add( L_FRAME + L_FILT, lMemRecalc_12k8 ) ); /* Q0 */
move16();
}
ELSE
{
preemp_start_idx = new_inp_12k8_fx - lMemRecalc_12k8;
- preemp_len = add( L_FRAME + L_FILT, lMemRecalc_12k8 );
+ preemp_len = add( L_FRAME + L_FILT, lMemRecalc_12k8 ); /* Q) */
move16();
}
}
@@ -738,9 +753,9 @@ ivas_error pre_proc_front_ivas_fx(
st->Q_max[i] = shift;
move16();
- Copy_Scale_sig32_16( sig_out, preemp_start_idx, preemp_len, *Q_new );
+ Copy_Scale_sig32_16( sig_out, preemp_start_idx, preemp_len, *Q_new ); /* Q_to_be_looked_into + Q_new */
- Scale_sig( old_inp_12k8_fx, (Word16) ( preemp_start_idx - old_inp_12k8_fx ), *Q_new );
+ Scale_sig( old_inp_12k8_fx, (Word16) ( preemp_start_idx - old_inp_12k8_fx ), *Q_new ); /* Q(-1) */
*Q_new = add( *Q_new, Q_to_be_looked_into );
move16();
@@ -755,68 +770,16 @@ ivas_error pre_proc_front_ivas_fx(
Word16 *lgBin_E_fx;
Word32 PS_fx[128];
Word32 band_energies_fx[2 * NB_BANDS];
+ Word16 q_band_energies;
lgBin_E_fx = NULL;
if ( st != NULL )
{
lgBin_E_fx = &st->lgBin_E_fx[0];
}
- Word16 Scale_fac[2] = { 0 };
- move16();
- move16();
- Scale_sig32( st->Bin_E_fx, L_FFT, sub( add( *Q_new, Q_SCALE - 2 ), st->q_Bin_E ) );
- st->q_Bin_E = add( *Q_new, Q_SCALE - 2 );
- move16();
- Word32 Le_min_scaled = L_shr_r( L_add( L_shr( E_MIN_FXQ15, sub( 14, add( *Q_new, QSCALE - 2 ) ) ), 1 ), 1 );
- ivas_analy_sp_fx_front( element_mode, hCPE, input_Fs, inp_12k8_fx /*old_inp_12k8_e*/, *Q_new, fr_bands_fx, lf_E_fx, &Etot_fx, st->min_band, st->max_band, Le_min_scaled, Scale_fac, st->Bin_E_fx, st->Bin_E_old_fx, PS_fx, lgBin_E_fx, band_energies_fx, fft_buff_fx /*, Q_inp_dmx*/ );
- st->q_Bin_E_old = add( *Q_new, Q_SCALE - 2 );
- move16();
- fr_bands_fx_q = add( *Q_new, QSCALE - 2 );
- band_energies_fx_exp = sub( 31, add( *Q_new, QSCALE - 2 ) );
- Word16 tmp_norm = L_norm_arr( fr_bands_fx, 2 * NB_BANDS );
- IF( GE_16( tmp_norm, 2 ) )
- {
- scale_sig32( fr_bands_fx, 2 * NB_BANDS, 2 );
- fr_bands_fx_q = add( fr_bands_fx_q, 2 );
- }
- tmp_norm = L_norm_arr( band_energies_fx, 2 * NB_BANDS );
- IF( GE_16( tmp_norm, 2 ) )
- {
- scale_sig32( band_energies_fx, 2 * NB_BANDS, 2 );
- band_energies_fx_exp = sub( band_energies_fx_exp, 2 );
- }
- Qfact_PS = add( *Q_new, QSCALE - 2 );
- q_lf_E_fx = add( *Q_new, QSCALE - 2 );
- IF( lgBin_E_fx != NULL )
- {
- Copy_Scale_sig_16_32( st->lgBin_E_fx, st->Bin_E_fx, L_FFT / 2, sub( st->q_Bin_E, Q7 ) );
- }
-
- Word16 min_q = MAX_16, fft_q[2];
- Word16 i_sbfr;
- FOR( i_sbfr = 0; i_sbfr < 2; i_sbfr++ )
- {
- fft_q[i_sbfr] = add( *Q_new, Scale_fac[i_sbfr] );
- move16();
- min_q = s_min( min_q, fft_q[i_sbfr] );
- }
- FOR( i_sbfr = 0; i_sbfr < 2; i_sbfr++ )
- {
- Scale_sig( fft_buff_fx + i_sbfr * L_FFT, L_FFT, sub( min_q, fft_q[i_sbfr] ) );
- }
- *fft_buff_fx_q = min_q;
- move16();
-
- Word16 Q_bands0 = 0, Q_bands1 = 0;
- move16();
- move16();
-
- Scale_sig32( st->hNoiseEst->bckr_fx, NB_BANDS, sub( add( *Q_new, QSCALE ), st->hNoiseEst->q_bckr ) );
- st->hNoiseEst->q_bckr = add( *Q_new, QSCALE );
- move16();
- Scale_sig32( st->hNoiseEst->enrO_fx, NB_BANDS, sub( add( *Q_new, QSCALE ), st->hNoiseEst->q_enrO ) );
- st->hNoiseEst->q_enrO = add( *Q_new, QSCALE );
- move16();
+ ivas_analy_sp_fx( element_mode, hCPE, input_Fs, inp_12k8_fx /*old_inp_12k8_e*/, *Q_new, fr_bands_fx, &fr_bands_fx_q, lf_E_fx, &q_lf_E_fx,
+ &Etot_fx, st->min_band, st->max_band, st->Bin_E_fx, &st->q_Bin_E, st->Bin_E_old_fx, &st->q_Bin_E_old, PS_fx, &Qfact_PS,
+ lgBin_E_fx, band_energies_fx, &q_band_energies, fft_buff_fx, fft_buff_fx_q );
IF( hStereoClassif != NULL )
{
@@ -827,10 +790,10 @@ ivas_error pre_proc_front_ivas_fx(
}
ELSE
{
- hStereoClassif->silence_flag = sub( hStereoClassif->silence_flag, 1 );
+ hStereoClassif->silence_flag = sub( hStereoClassif->silence_flag, 1 ); /* Q0 */
move16();
}
- hStereoClassif->silence_flag = s_max( 0, hStereoClassif->silence_flag );
+ hStereoClassif->silence_flag = s_max( 0, hStereoClassif->silence_flag ); /* Q0 */
move16();
}
@@ -856,15 +819,32 @@ ivas_error pre_proc_front_ivas_fx(
move16();
}
- st->vad_flag = wb_vad_ivas_fx( st, fr_bands_fx, &i, &i, &i, &snr_sum_he_fx, &localVAD_HE_SAD, &( st->flag_noisy_speech_snr ), *Q_new, NULL, NULL, -MAX_16, -MAX_16 ); //-100000f == max 16bit float
+ Word16 scale = add( L_norm_arr( st->hNoiseEst->bckr_fx, NB_BANDS ), st->hNoiseEst->q_bckr );
+ scale = s_min( scale, add( L_norm_arr( st->hNoiseEst->enrO_fx, NB_BANDS ), st->hNoiseEst->q_enrO ) );
+ scale = s_min( scale, fr_bands_fx_q );
+
+ scale_sig32( st->hNoiseEst->bckr_fx, NB_BANDS, sub( scale, st->hNoiseEst->q_bckr ) );
+ st->hNoiseEst->q_bckr = scale;
+ move16();
+
+ scale_sig32( st->hNoiseEst->enrO_fx, NB_BANDS, sub( scale, st->hNoiseEst->q_enrO ) );
+ st->hNoiseEst->q_enrO = scale;
+ move16();
+
+ scale_sig32( fr_bands_fx, 2 * NB_BANDS, sub( scale, fr_bands_fx_q ) );
+ fr_bands_fx_q = scale;
+ move16();
+
+ st->vad_flag = wb_vad_ivas_fx( st, fr_bands_fx, fr_bands_fx_q, &i, &i, &i, &snr_sum_he_fx, &localVAD_HE_SAD,
+ &( st->flag_noisy_speech_snr ), NULL, NULL, -MAX_16, -MAX_16 ); //-100000f == max 16bit float
move16();
test();
IF( EQ_16( force_front_vad, 1 ) || EQ_16( front_vad_flag, 1 ) )
{
/* overwrite VAD decision with front-VAD decision if external VAD is set to 1*/
- st->vad_flag = front_vad_flag;
- st->localVAD = front_vad_flag;
+ st->vad_flag = front_vad_flag; /* Q0 */
+ st->localVAD = front_vad_flag; /* Q0 */
move16();
move16();
}
@@ -873,7 +853,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 );
+ *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 */
move16();
}
ELSE
@@ -881,14 +861,14 @@ ivas_error pre_proc_front_ivas_fx(
/* This only applies to st->idchan==0 now */
/* Add down mix stereo activity to LR vad_flag_dtx */
test();
- *vad_flag_dtx = *vad_flag_dtx || st->vad_flag;
+ *vad_flag_dtx = *vad_flag_dtx || st->vad_flag; /* Q0 */
move16();
/* Determine hangover flag status based on LR localVAD and downmix localVAD */
test();
test();
- *vad_hover_flag = *vad_flag_dtx && !( LR_localVAD || st->localVAD );
+ *vad_hover_flag = *vad_flag_dtx && !( LR_localVAD || st->localVAD ); /* Q0 */
move16();
}
@@ -896,7 +876,7 @@ ivas_error pre_proc_front_ivas_fx(
if ( EQ_16( force_front_vad, 1 ) || EQ_16( front_vad_dtx_flag, 1 ) )
{
/* overwrite VAD decision with front-VAD decision if external VAD is set to 1*/
- *vad_flag_dtx = front_vad_dtx_flag;
+ *vad_flag_dtx = front_vad_dtx_flag; /* Q0 */
move16();
}
@@ -932,7 +912,7 @@ ivas_error pre_proc_front_ivas_fx(
test();
if ( EQ_16( st->idchan, 1 ) && EQ_16( element_mode, IVAS_CPE_TD ) && EQ_16( st->tdm_LRTD_flag, 1 ) && GE_16( st->bits_frame_channel, IVAS_16k4 / FRAMES_PER_SEC ) )
{
- st->bwidth = hCPE->hCoreCoder[0]->bwidth;
+ st->bwidth = hCPE->hCoreCoder[0]->bwidth; /* Q0 */
move16();
}
@@ -942,43 +922,52 @@ ivas_error pre_proc_front_ivas_fx(
* Correlation correction as a function of total noise level
*----------------------------------------------------------------*/
- Le_min_scaled = L_shr_r( L_add( L_shr( E_MIN_FXQ15, sub( 14, add( *Q_new, QSCALE ) ) ), 1 ), 1 );
-
- noise_est_down_fx( fr_bands_fx, st->hNoiseEst->bckr_fx, tmpN_fx, tmpE_fx, st->min_band, st->max_band, &st->hNoiseEst->totalNoise_fx, Etot_fx, &st->hNoiseEst->Etot_last_fx, &st->hNoiseEst->Etot_v_h2_fx, *Q_new, Le_min_scaled );
- st->hNoiseEst->q_bckr = add( *Q_new, QSCALE );
+ noise_est_down_ivas_fx( fr_bands_fx, fr_bands_fx_q, st->hNoiseEst->bckr_fx, tmpN_fx, tmpE_fx, st->min_band, st->max_band,
+ &st->hNoiseEst->totalNoise_fx, Etot_fx, &st->hNoiseEst->Etot_last_fx, &st->hNoiseEst->Etot_v_h2_fx );
+ q_tmpN = fr_bands_fx_q;
+ q_tmpE = fr_bands_fx_q;
+ move16();
move16();
test();
IF( lr_vad_enabled && st->idchan == 0 )
{
- Scale_sig32( hCPE->hFrontVad[0]->hNoiseEst->bckr_fx, NB_BANDS, sub( add( fr_bands_LR_fx_q, Q_SCALE ), hCPE->hFrontVad[0]->hNoiseEst->q_bckr ) );
- Scale_sig32( hCPE->hFrontVad[1]->hNoiseEst->bckr_fx, NB_BANDS, sub( add( fr_bands_LR_fx_q, Q_SCALE ), hCPE->hFrontVad[1]->hNoiseEst->q_bckr ) );
+ scale = add( L_norm_arr( hCPE->hFrontVad[0]->hNoiseEst->bckr_fx, NB_BANDS ), hCPE->hFrontVad[0]->hNoiseEst->q_bckr );
+ scale = s_min( scale, add( L_norm_arr( hCPE->hFrontVad[1]->hNoiseEst->bckr_fx, NB_BANDS ), hCPE->hFrontVad[1]->hNoiseEst->q_bckr ) );
+ scale = s_min( scale, add( L_norm_arr( fr_bands_LR_fx[0], 2 * NB_BANDS ), fr_bands_LR_fx_q[0] ) );
+ scale = s_min( scale, add( L_norm_arr( fr_bands_LR_fx[1], 2 * NB_BANDS ), fr_bands_LR_fx_q[1] ) );
- Word32 Le_min_scaled0, Le_min_scaled1;
- Le_min_scaled0 = L_shr_r( L_add( L_shr( E_MIN_FXQ15, sub( 14, add( Q_bands0, QSCALE ) ) ), 1 ), 1 );
- noise_est_down_fx( fr_bands_LR_fx[0], hCPE->hFrontVad[0]->hNoiseEst->bckr_fx, tmpN_LR_fx[0], tmpE_LR_fx[0], st->min_band, st->max_band, &hCPE->hFrontVad[0]->hNoiseEst->totalNoise_fx, Etot_LR_fx[0], &hCPE->hFrontVad[0]->hNoiseEst->Etot_last_fx, &hCPE->hFrontVad[0]->hNoiseEst->Etot_v_h2_fx, Q_bands0, Le_min_scaled0 );
- hCPE->hFrontVad[0]->hNoiseEst->q_bckr = add( Q_bands0, QSCALE );
+ scale_sig32( fr_bands_LR_fx[0], 2 * NB_BANDS, sub( scale, fr_bands_LR_fx_q[0] ) );
+ fr_bands_LR_fx_q[0] = scale;
move16();
- Le_min_scaled1 = L_shr_r( L_add( L_shr( E_MIN_FXQ15, sub( 14, add( Q_bands1, QSCALE ) ) ), 1 ), 1 );
- noise_est_down_fx( fr_bands_LR_fx[1], hCPE->hFrontVad[1]->hNoiseEst->bckr_fx, tmpN_LR_fx[1], tmpE_LR_fx[1], st->min_band, st->max_band, &hCPE->hFrontVad[1]->hNoiseEst->totalNoise_fx, Etot_LR_fx[1], &hCPE->hFrontVad[1]->hNoiseEst->Etot_last_fx, &hCPE->hFrontVad[1]->hNoiseEst->Etot_v_h2_fx, Q_bands1, Le_min_scaled1 );
- hCPE->hFrontVad[1]->hNoiseEst->q_bckr = add( Q_bands1, QSCALE );
+ scale_sig32( fr_bands_LR_fx[1], 2 * NB_BANDS, sub( scale, fr_bands_LR_fx_q[1] ) );
+ fr_bands_LR_fx_q[1] = scale;
move16();
- corr_shiftL_fx = correlation_shift_fx( hCPE->hFrontVad[0]->hNoiseEst->totalNoise_fx );
- corr_shiftR_fx = correlation_shift_fx( hCPE->hFrontVad[1]->hNoiseEst->totalNoise_fx );
- q_tmpN_LR[0] = q_tmpE_LR[0] = add( Q_bands0, QSCALE );
+ scale_sig32( hCPE->hFrontVad[0]->hNoiseEst->bckr_fx, NB_BANDS, sub( scale, hCPE->hFrontVad[0]->hNoiseEst->q_bckr ) );
+ hCPE->hFrontVad[0]->hNoiseEst->q_bckr = scale;
move16();
+ scale_sig32( hCPE->hFrontVad[1]->hNoiseEst->bckr_fx, NB_BANDS, sub( scale, hCPE->hFrontVad[1]->hNoiseEst->q_bckr ) );
+ hCPE->hFrontVad[1]->hNoiseEst->q_bckr = scale;
move16();
- q_tmpN_LR[1] = q_tmpE_LR[1] = add( Q_bands1, QSCALE );
+
+ noise_est_down_ivas_fx( fr_bands_LR_fx[0], fr_bands_LR_fx_q[0], hCPE->hFrontVad[0]->hNoiseEst->bckr_fx, tmpN_LR_fx[0], tmpE_LR_fx[0], st->min_band, st->max_band, &hCPE->hFrontVad[0]->hNoiseEst->totalNoise_fx, Etot_LR_fx[0], &hCPE->hFrontVad[0]->hNoiseEst->Etot_last_fx, &hCPE->hFrontVad[0]->hNoiseEst->Etot_v_h2_fx );
+ noise_est_down_ivas_fx( fr_bands_LR_fx[1], fr_bands_LR_fx_q[1], hCPE->hFrontVad[1]->hNoiseEst->bckr_fx, tmpN_LR_fx[1], tmpE_LR_fx[1], st->min_band, st->max_band, &hCPE->hFrontVad[1]->hNoiseEst->totalNoise_fx, Etot_LR_fx[1], &hCPE->hFrontVad[1]->hNoiseEst->Etot_last_fx, &hCPE->hFrontVad[1]->hNoiseEst->Etot_v_h2_fx );
+
+ q_tmpN_LR[0] = q_tmpE_LR[0] = scale;
+ move16();
+ move16();
+ q_tmpN_LR[1] = q_tmpE_LR[1] = scale;
move16();
move16();
+
+ corr_shiftL_fx = correlation_shift_fx( hCPE->hFrontVad[0]->hNoiseEst->totalNoise_fx ); // Q15
+ corr_shiftR_fx = correlation_shift_fx( hCPE->hFrontVad[1]->hNoiseEst->totalNoise_fx ); // Q15
}
- q_tmpN = q_tmpE = add( *Q_new, QSCALE );
- move16();
- *relE_fx = sub( Etot_fx, st->lp_speech_fx );
+ *relE_fx = sub( Etot_fx, st->lp_speech_fx ); // Q8
move16();
- corr_shift_fx = correlation_shift_fx( st->hNoiseEst->totalNoise_fx );
+ corr_shift_fx = correlation_shift_fx( st->hNoiseEst->totalNoise_fx ); /* Q15 */
/*----------------------------------------------------------------*
* FD-CNG Noise Estimator
@@ -1007,7 +996,7 @@ ivas_error pre_proc_front_ivas_fx(
st->hFdCngEnc->msPeriodog_fx_exp_fft = sub( 31, normmsPeriodog_fx );
move16();
move16();
- Scale_sig32( st->hFdCngEnc->msPeriodog_fx, NPART, normmsPeriodog_fx );
+ Scale_sig32( st->hFdCngEnc->msPeriodog_fx, NPART, normmsPeriodog_fx ); /* exp(st->hFdCngEnc->msPeriodog_fx_exp - normmsPeriodog_fx) */
st->hFdCngEnc->msPeriodog_fx_exp = sub( st->hFdCngEnc->msPeriodog_fx_exp, normmsPeriodog_fx );
Word16 msNoiseEst_Q = Q31;
move16();
@@ -1017,7 +1006,7 @@ ivas_error pre_proc_front_ivas_fx(
{
msNoiseEst_Q = getScaleFactor32( st->hFdCngEnc->msNoiseEst_fx, NPART );
}
- Scale_sig32( st->hFdCngEnc->msNoiseEst_old_fx, NPART, msNoiseEst_Q );
+ Scale_sig32( st->hFdCngEnc->msNoiseEst_old_fx, NPART, msNoiseEst_Q ); /* exp(st->hFdCngEnc->msNoiseEst_old_fx_exp - msNoiseEst_Q) */
st->hFdCngEnc->msNoiseEst_fx_exp = sub( st->hFdCngEnc->msNoiseEst_old_fx_exp, msNoiseEst_Q );
move16();
perform_noise_estimation_enc_ivas_fx( band_energies_LR_fx, sub( Q31, band_energies_LR_fx_q ), enerBuffer_fx, *enerBuffer_fx_exp, st->hFdCngEnc, input_Fs, hCPE );
@@ -1029,9 +1018,9 @@ ivas_error pre_proc_front_ivas_fx(
move16();
shift = getScaleFactor32( band_energies_fx, 2 * NB_BANDS );
scale_sig32( band_energies_fx, 2 * NB_BANDS, shift );
- band_energies_fx_exp = sub( band_energies_fx_exp, shift );
+ q_band_energies = add( q_band_energies, shift );
- zero_flag = get_zero_flag( st->hFdCngEnc->msPeriodog_fx, NPART );
+ zero_flag = get_zero_flag( st->hFdCngEnc->msPeriodog_fx, NPART ); /* Q0 */
IF( zero_flag )
{
normmsPeriodog_fx = getScaleFactor32( st->hFdCngEnc->msPeriodog_fx, NPART );
@@ -1040,20 +1029,20 @@ ivas_error pre_proc_front_ivas_fx(
st->hFdCngEnc->msPeriodog_fx_exp_fft = sub( 31, normmsPeriodog_fx );
move16();
move16();
- Scale_sig32( st->hFdCngEnc->msPeriodog_fx, NPART, normmsPeriodog_fx );
- st->hFdCngEnc->msPeriodog_fx_exp = st->hFdCngEnc->msPeriodog_fx_exp - normmsPeriodog_fx;
+ Scale_sig32( st->hFdCngEnc->msPeriodog_fx, NPART, normmsPeriodog_fx ); /* exp(st->hFdCngEnc->msPeriodog_fx_exp - normmsPeriodog_fx)*/
+ st->hFdCngEnc->msPeriodog_fx_exp = sub( st->hFdCngEnc->msPeriodog_fx_exp, normmsPeriodog_fx );
move16();
Word16 msNoiseEst_Q = Q31;
move16();
- zero_flag = get_zero_flag( st->hFdCngEnc->msNoiseEst_fx, NPART );
+ zero_flag = get_zero_flag( st->hFdCngEnc->msNoiseEst_fx, NPART ); /* Q0 */
IF( zero_flag )
{
msNoiseEst_Q = getScaleFactor32( st->hFdCngEnc->msNoiseEst_fx, NPART );
}
- Scale_sig32( st->hFdCngEnc->msNoiseEst_old_fx, NPART, msNoiseEst_Q );
- st->hFdCngEnc->msNoiseEst_fx_exp = st->hFdCngEnc->msNoiseEst_old_fx_exp - msNoiseEst_Q;
+ Scale_sig32( st->hFdCngEnc->msNoiseEst_old_fx, NPART, msNoiseEst_Q ); /* exp(st->hFdCngEnc->msNoiseEst_old_fx_exp - msNoiseEst_Q) */
+ st->hFdCngEnc->msNoiseEst_fx_exp = sub( st->hFdCngEnc->msNoiseEst_old_fx_exp, msNoiseEst_Q );
move16();
- zero_flag = get_zero_flag( st->hFdCngEnc->hFdCngCom->periodog, PERIODOGLEN );
+ zero_flag = get_zero_flag( st->hFdCngEnc->hFdCngCom->periodog, PERIODOGLEN ); /* Q0 */
Word16 normmsperiodog = 31;
move16();
IF( zero_flag )
@@ -1063,7 +1052,7 @@ ivas_error pre_proc_front_ivas_fx(
st->hFdCngEnc->hFdCngCom->exp_cldfb_periodog = sub( 31, normmsperiodog );
move16();
- perform_noise_estimation_enc_ivas_fx( band_energies_fx, band_energies_fx_exp, enerBuffer_fx, *enerBuffer_fx_exp, st->hFdCngEnc, input_Fs, hCPE );
+ perform_noise_estimation_enc_ivas_fx( band_energies_fx, sub( Q31, q_band_energies ), enerBuffer_fx, *enerBuffer_fx_exp, st->hFdCngEnc, input_Fs, hCPE );
}
}
}
@@ -1088,14 +1077,19 @@ 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();
IF( hCPE != NULL && hCPE->hStereoDft != NULL && EQ_32( st->core_brate, SID_2k40 ) )
{
/* Add another period of expected xcorr updates */
- hCPE->hStereoDft->expectedNumUpdates = add( hCPE->hStereoDft->expectedNumUpdates, st->hDtxEnc->max_SID );
+ hCPE->hStereoDft->expectedNumUpdates = add( hCPE->hStereoDft->expectedNumUpdates, st->hDtxEnc->max_SID ); /* Q0 */
move16();
}
@@ -1111,17 +1105,17 @@ ivas_error pre_proc_front_ivas_fx(
IF( EQ_16( element_mode, IVAS_SCE ) )
{
- total_brate = st->total_brate;
+ total_brate = st->total_brate; /* Q0 */
move32();
}
ELSE
{
- total_brate = imult3216( FRAMES_PER_SEC, st->bits_frame_nominal );
+ total_brate = imult3216( FRAMES_PER_SEC, st->bits_frame_nominal ); /* Q0 */
}
configureFdCngEnc_ivas_fx( st->hFdCngEnc, s_max( st->input_bwidth, WB ), total_brate );
IF( hCPE != NULL )
{
- st->hFdCngEnc->hFdCngCom->CngBitrate = L_sub( hCPE->element_brate, 1 );
+ st->hFdCngEnc->hFdCngCom->CngBitrate = L_sub( hCPE->element_brate, 1 ); /* Q0 */
move32();
}
}
@@ -1136,29 +1130,29 @@ ivas_error pre_proc_front_ivas_fx(
IF( zero_flag )
{
msPeriodog_fx_Q = getScaleFactor32( st->hFdCngEnc->msPeriodog_fx, NPART );
- scale_sig32( st->hFdCngEnc->msPeriodog_fx, NPART, msPeriodog_fx_Q );
+ scale_sig32( st->hFdCngEnc->msPeriodog_fx, NPART, msPeriodog_fx_Q ); /* exp(st->hFdCngEnc->msPeriodog_fx_exp - msPeriodog_fx_Q) */
st->hFdCngEnc->msPeriodog_fx_exp = sub( st->hFdCngEnc->msPeriodog_fx_exp, msPeriodog_fx_Q );
move16();
}
Word16 energy_ho_fx_Q = Q31;
move16();
- zero_flag = get_zero_flag( st->hFdCngEnc->energy_ho_fx, NPART );
+ zero_flag = get_zero_flag( st->hFdCngEnc->energy_ho_fx, NPART ); /* Q0 */
IF( zero_flag )
{
energy_ho_fx_Q = getScaleFactor32( st->hFdCngEnc->energy_ho_fx, NPART );
- scale_sig32( st->hFdCngEnc->energy_ho_fx, NPART, energy_ho_fx_Q );
+ scale_sig32( st->hFdCngEnc->energy_ho_fx, NPART, energy_ho_fx_Q ); /* exp(st->hFdCngEnc->energy_ho_fx_exp - energy_ho_fx_Q) */
st->hFdCngEnc->energy_ho_fx_exp = sub( st->hFdCngEnc->energy_ho_fx_exp, energy_ho_fx_Q );
move16();
}
Word16 msNoiseEst_old_Q = Q31;
move16();
- zero_flag = get_zero_flag( st->hFdCngEnc->msNoiseEst_old_fx, NPART );
+ zero_flag = get_zero_flag( st->hFdCngEnc->msNoiseEst_old_fx, NPART ); /* Q0 */
IF( zero_flag )
{
msNoiseEst_old_Q = getScaleFactor32( st->hFdCngEnc->msNoiseEst_old_fx, NPART );
- scale_sig32( st->hFdCngEnc->msNoiseEst_old_fx, NPART, msNoiseEst_old_Q );
+ scale_sig32( st->hFdCngEnc->msNoiseEst_old_fx, NPART, msNoiseEst_old_Q ); /* exp(st->hFdCngEnc->msNoiseEst_old_fx_exp - msNoiseEst_old_Q) */
st->hFdCngEnc->msNoiseEst_old_fx_exp = sub( st->hFdCngEnc->msNoiseEst_old_fx_exp, msNoiseEst_old_Q );
move16();
}
@@ -1182,13 +1176,13 @@ ivas_error pre_proc_front_ivas_fx(
Q_new_loc = *Q_new;
move16();
- alw_pitch_lag_12k8[0] = st->old_pitch_la;
+ alw_pitch_lag_12k8[0] = st->old_pitch_la; /* Q0 */
move16();
- alw_pitch_lag_12k8[1] = st->old_pitch_la;
+ alw_pitch_lag_12k8[1] = st->old_pitch_la; /* Q0 */
move16();
- alw_voicing_fx[0] = st->voicing_fx[2];
+ alw_voicing_fx[0] = st->voicing_fx[2]; /* Q15 */
move16();
- alw_voicing_fx[1] = st->voicing_fx[2];
+ alw_voicing_fx[1] = st->voicing_fx[2]; /* Q15 */
move16();
i = 0;
@@ -1215,9 +1209,9 @@ ivas_error pre_proc_front_ivas_fx(
lsp2lsf_fx( lsp_new_fx, lsf_new_fx, M, INT_FS_12k8 );
- stab_fac_fx = lsf_stab_fx( lsf_new_fx, st->lsf_old1_fx, 0, L_FRAME );
+ stab_fac_fx = lsf_stab_fx( lsf_new_fx, st->lsf_old1_fx, 0, L_FRAME ); /* Q15 */
- Copy( lsf_new_fx, st->lsf_old1_fx, M );
+ Copy( lsf_new_fx, st->lsf_old1_fx, M ); /* Q2.56 */
test();
IF( EQ_16( element_mode, IVAS_CPE_TD ) && EQ_16( st->idchan, 1 ) )
@@ -1227,8 +1221,8 @@ 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 );
- 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 ) );
+ 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();
}
@@ -1239,12 +1233,12 @@ ivas_error pre_proc_front_ivas_fx(
* 1/4 pitch precision improvement
*----------------------------------------------------------------*/
- st->mem_wsp_fx = shl( st->mem_wsp_fx, sub( *Q_new, st->mem_wsp_q ) );
+ st->mem_wsp_fx = shl( st->mem_wsp_fx, sub( *Q_new, st->mem_wsp_q ) ); /* Q_new */
st->mem_wsp_q = *Q_new;
move16();
move16();
- ivas_find_wsp( L_FRAME, L_SUBFR, NB_SUBFR, A_fx, Aw_fx, inp_12k8_fx, TILT_FAC_FX, wsp_fx, &st->mem_wsp_fx, GAMMA1, L_LOOK_12k8 );
+ ivas_find_wsp_fx( L_FRAME, L_SUBFR, NB_SUBFR, A_fx, Aw_fx, inp_12k8_fx, TILT_FAC_FX, wsp_fx, &st->mem_wsp_fx, GAMMA1, L_LOOK_12k8 );
Word16 Q_wsp = *Q_new;
move16();
@@ -1256,8 +1250,8 @@ ivas_error pre_proc_front_ivas_fx(
old_pitch1 = st->pitch[1];
move16();
- Word16 shift1 = getScaleFactor16( old_wsp_fx, L_WSP_MEM );
- Word16 shift2 = getScaleFactor16( wsp_fx, L_WSP - L_WSP_MEM );
+ Word16 shift1 = norm_arr( old_wsp_fx, L_WSP_MEM );
+ Word16 shift2 = norm_arr( wsp_fx, L_WSP - L_WSP_MEM );
maximum_abs_16_fx( old_wsp_fx, L_WSP_MEM, &shift );
if ( !shift )
{
@@ -1271,111 +1265,37 @@ ivas_error pre_proc_front_ivas_fx(
move16();
}
shift = s_min( add( *q_old_wsp, shift1 ), add( Q_wsp, shift2 ) );
- Scale_sig( old_wsp_fx, L_WSP_MEM, sub( shift, *q_old_wsp ) );
- Scale_sig( wsp_fx, L_WSP - L_WSP_MEM, sub( shift, Q_wsp ) );
+ shift = s_min( shift, add( norm_arr( st->mem_decim2_fx, 3 ), st->Q_old_wsp2 ) );
+ shift = s_min( shift, add( norm_arr( st->old_wsp2_fx, ( L_WSP_MEM - L_INTERPOL ) / OPL_DECIM ), st->Q_old_wsp2 ) );
+ scale_sig( old_wsp_fx, L_WSP_MEM, sub( shift, *q_old_wsp ) );
+ scale_sig( wsp_fx, L_WSP - L_WSP_MEM, sub( shift, Q_wsp ) );
+
*q_old_wsp = shift;
move16();
Q_wsp = shift;
move16();
- Scale_sig( st->mem_decim2_fx, 3, sub( Q_wsp, st->Q_old_wsp2 ) ); // Q( mem_decim ) = Q( old_wsp2 )
- Scale_sig( st->old_wsp2_fx, ( L_WSP_MEM - L_INTERPOL ) / OPL_DECIM, sub( Q_wsp, st->Q_old_wsp2 ) );
+ scale_sig( st->mem_decim2_fx, 3, sub( Q_wsp, st->Q_old_wsp2 ) ); // Q( mem_decim ) = Q( old_wsp2 )
+ scale_sig( st->old_wsp2_fx, ( L_WSP_MEM - L_INTERPOL ) / OPL_DECIM, sub( Q_wsp, st->Q_old_wsp2 ) ); // Q_wsp
+
st->Q_old_wsp2 = Q_wsp;
move16();
pitch_ol_ivas_fx( st->pitch, st->voicing_fx, &st->old_pitch, &st->old_corr_fx, corr_shift_fx, &st->old_thres_fx,
- &st->delta_pit, st->old_wsp2_fx, wsp_fx, st->mem_decim2_fx, *relE_fx, st->clas, st->input_bwidth, st->Opt_SC_VBR );
+ &st->delta_pit, st->old_wsp2_fx, wsp_fx, st->mem_decim2_fx, *relE_fx, st->clas, st->input_bwidth, st->Opt_SC_VBR, Q_wsp );
/* Updates for adaptive lag window memory */
- st->old_pitch_la = st->pitch[2];
+ st->old_pitch_la = st->pitch[2]; /* Q0 */
move16();
- test();
- IF( lr_vad_enabled && st->idchan == 0 )
- {
- FOR( i = 0; i < 2; i++ )
- {
- shift = getScaleFactor32( tmpN_LR_fx[i], NB_BANDS );
- scale_sig32( tmpN_LR_fx[i], NB_BANDS, shift );
- q_tmpN_LR[i] = add( q_tmpN_LR[i], shift );
- move16();
-
- shift = getScaleFactor32( tmpE_LR_fx[i], NB_BANDS );
- scale_sig32( tmpE_LR_fx[i], NB_BANDS, shift );
- q_tmpE_LR[i] = add( q_tmpE_LR[i], shift );
- move16();
- }
- }
- shift = getScaleFactor32( tmpN_fx, NB_BANDS );
- scale_sig32( tmpN_fx, NB_BANDS, shift );
- q_tmpN = add( q_tmpN, shift );
- shift = getScaleFactor32( tmpE_fx, NB_BANDS );
- scale_sig32( tmpE_fx, NB_BANDS, shift );
- q_tmpE = add( q_tmpE, shift );
-
- shift = getScaleFactor32( lf_E_fx, 2 * VOIC_BINS );
- scale_sig32( lf_E_fx, 2 * VOIC_BINS, shift );
- q_lf_E_fx = add( q_lf_E_fx, shift );
+ shift = sub( norm_arr( old_wsp_fx, L_WSP ), 3 );
+ scale_sig( old_wsp_fx, L_WSP, shift );
- shift = sub( getScaleFactor16( old_wsp_fx, L_WSP ), 3 );
- Scale_sig( old_wsp_fx, L_WSP, shift );
*q_old_wsp = add( *q_old_wsp, shift );
move16();
Q_wsp = *q_old_wsp;
move16();
- Word16 q_fr_bands = Q30;
- move16();
- q_fr_bands = s_min( q_fr_bands, q_tmpN );
- q_fr_bands = s_min( q_fr_bands, q_tmpE );
- q_fr_bands = s_min( q_fr_bands, sub( fr_bands_fx_q, 4 ) /* needs 4 gaurd bits for summation */ );
- q_fr_bands = s_min( q_fr_bands, st->hNoiseEst->q_bckr );
- q_fr_bands = s_min( q_fr_bands, st->hNoiseEst->fr_bands_fx_q );
- q_fr_bands = s_min( q_fr_bands, st->hNoiseEst->ave_enr_q );
- q_fr_bands = s_min( q_fr_bands, add( q_lf_E_fx, 2 ) );
-
- test();
- IF( lr_vad_enabled && st->idchan == 0 )
- {
- FOR( Word16 j = 0; j < 2; j++ )
- {
- q_fr_bands = s_min( q_fr_bands, add( lf_E_LR_fx_q, 2 ) );
- q_fr_bands = s_min( q_fr_bands, q_tmpN_LR[j] );
- q_fr_bands = s_min( q_fr_bands, q_tmpE_LR[j] );
- q_fr_bands = s_min( q_fr_bands, fr_bands_LR_fx_q );
- q_fr_bands = s_min( q_fr_bands, hCPE->hFrontVad[j]->hNoiseEst->q_bckr );
- q_fr_bands = s_min( q_fr_bands, hCPE->hFrontVad[j]->hNoiseEst->fr_bands_fx_q );
- q_fr_bands = s_min( q_fr_bands, hCPE->hFrontVad[j]->hNoiseEst->ave_enr_q );
- }
- }
- Word16 q_inp_12k8 = *Q_new; // inp_12k8_fx
- move16();
-
- scale_sig32( lf_E_fx, 2 * VOIC_BINS, sub( sub( q_fr_bands, 2 ), q_lf_E_fx ) );
- q_lf_E_fx = sub( q_fr_bands, 2 );
- scale_sig32( tmpN_fx, NB_BANDS, sub( q_fr_bands, q_tmpN ) );
- q_tmpN = q_fr_bands;
-
- scale_sig32( tmpE_fx, NB_BANDS, sub( q_fr_bands, q_tmpE ) );
- q_tmpE = q_fr_bands;
- test();
- IF( lr_vad_enabled && st->idchan == 0 )
- {
- FOR( i = 0; i < 2; i++ )
- {
- scale_sig32( tmpN_LR_fx[i], NB_BANDS, sub( q_fr_bands, q_tmpN_LR[i] ) );
- q_tmpN_LR[i] = q_fr_bands;
- move16();
-
- scale_sig32( tmpE_LR_fx[i], NB_BANDS, sub( q_fr_bands, q_tmpE_LR[i] ) );
- q_tmpE_LR[i] = q_fr_bands;
- move16();
- }
- }
- scale_sig32( fr_bands_fx, 2 * NB_BANDS, sub( q_fr_bands, fr_bands_fx_q ) );
- fr_bands_fx_q = q_fr_bands;
- move16();
-
- Copy_Scale_sig_32_16( st->Bin_E_fx, st->lgBin_E_fx, L_FFT / 2, sub( Q7, st->q_Bin_E ) );
+ Copy_Scale_sig_32_16( st->Bin_E_fx, st->lgBin_E_fx, L_FFT / 2, sub( Q7, st->q_Bin_E ) ); /* Q7 */
/* Detection of very short stable pitch period */
StableHighPitchDetect_ivas_fx( &flag_spitch, st->pitch, st->voicing_fx, wsp_fx, st->localVAD, &st->voicing_sm_fx, &st->voicing0_sm_fx, &st->LF_EnergyRatio_sm_fx, &st->predecision_flag, &st->diff_sm_fx, &st->energy_sm_fx, *q_old_wsp, st->lgBin_E_fx );
@@ -1412,104 +1332,96 @@ ivas_error pre_proc_front_ivas_fx(
/*------------------------------------------------------------------*
* Update estimated noise energy and voicing cut-off frequency
*-----------------------------------------------------------------*/
-
- scale_sig32( st->hNoiseEst->bckr_fx, NB_BANDS, sub( q_fr_bands, st->hNoiseEst->q_bckr ) );
- st->hNoiseEst->q_bckr = q_fr_bands;
- move16();
- scale_sig32( st->hNoiseEst->fr_bands1_fx, NB_BANDS, sub( q_fr_bands, st->hNoiseEst->fr_bands_fx_q ) );
- scale_sig32( st->hNoiseEst->fr_bands2_fx, NB_BANDS, sub( q_fr_bands, st->hNoiseEst->fr_bands_fx_q ) );
- st->hNoiseEst->fr_bands_fx_q = q_fr_bands;
- move16();
- scale_sig32( st->hNoiseEst->ave_enr_fx, NB_BANDS, sub( q_fr_bands, st->hNoiseEst->ave_enr_q ) );
- scale_sig32( st->hNoiseEst->ave_enr2_fx, NB_BANDS, sub( q_fr_bands, st->hNoiseEst->ave_enr_q ) );
- st->hNoiseEst->ave_enr_q = q_fr_bands;
- move16();
-
- FOR( Word16 k = 0; k < NB_BANDS; k++ )
{
- fr_bands_fx[k] = L_max( 1, fr_bands_fx[k] );
- move32();
+ // TODO: this scalings to be checked
+ scale = s_min( Q30, add( st->hNoiseEst->q_bckr, L_norm_arr( st->hNoiseEst->bckr_fx, NB_BANDS ) ) );
+ scale = s_min( scale, sub( add( fr_bands_fx_q, L_norm_arr( fr_bands_fx, 2 * NB_BANDS ) ), 4 ) );
+ scale_sig32( st->hNoiseEst->bckr_fx, NB_BANDS, sub( scale, st->hNoiseEst->q_bckr ) );
+ scale_sig32( fr_bands_fx, 2 * NB_BANDS, sub( scale, fr_bands_fx_q ) );
+ st->hNoiseEst->q_bckr = fr_bands_fx_q = scale;
}
- noise_est_ivas_fx( st, old_pitch1, tmpN_fx, epsP_h, epsP_l, Etot_fx, *relE_fx, corr_shift_fx, tmpE_fx, fr_bands_fx, cor_map_sum_fx, &ncharX_fx, &sp_div_fx, &q_sp_div,
- &non_staX_fx, loc_harm, lf_E_fx, &st->hNoiseEst->harm_cor_cnt, st->hNoiseEst->Etot_l_lp_fx, st->hNoiseEst->Etot_v_h2_fx, &st->hNoiseEst->bg_cnt, st->lgBin_E_fx, sub( q_fr_bands, QSCALE ), L_shl( E_MIN_IVAS_FX, sub( q_fr_bands, Q19 ) ), &dummy_fx, S_map_fx, hStereoClassif, NULL, st->ini_frame );
+ scale = s_min( Q31, s_min( add( q_tmpN, L_norm_arr( tmpN_fx, NB_BANDS ) ), add( st->hNoiseEst->q_bckr, L_norm_arr( st->hNoiseEst->bckr_fx, NB_BANDS ) ) ) );
+ scale = sub( scale, 1 ); // guard bits
+ scale_sig32( st->hNoiseEst->bckr_fx, NB_BANDS, sub( scale, st->hNoiseEst->q_bckr ) );
+ scale_sig32( tmpN_fx, NB_BANDS, sub( scale, q_tmpN ) );
+ st->hNoiseEst->q_bckr = q_tmpN = scale;
+ move16();
+ move16();
- /*Scaling to avoid 0 values*/
- shift = s_min( L_norm_arr( st->hNoiseEst->fr_bands1_fx, NB_BANDS ), L_norm_arr( st->hNoiseEst->fr_bands2_fx, NB_BANDS ) );
- scale_sig32( st->hNoiseEst->fr_bands1_fx, NB_BANDS, shift );
- scale_sig32( st->hNoiseEst->fr_bands2_fx, NB_BANDS, shift );
- st->hNoiseEst->fr_bands_fx_q = add( st->hNoiseEst->fr_bands_fx_q, shift );
+ scale = s_min( Q31, add( st->hNoiseEst->ave_enr_q, s_min( L_norm_arr( st->hNoiseEst->ave_enr_fx, NB_BANDS ), L_norm_arr( st->hNoiseEst->ave_enr2_fx, NB_BANDS ) ) ) );
+ scale = s_min( scale, add( q_tmpE, L_norm_arr( tmpE_fx, NB_BANDS ) ) );
+ scale = sub( scale, 1 ); // guard bits
+ scale_sig32( tmpE_fx, NB_BANDS, sub( scale, q_tmpE ) );
+ scale_sig32( st->hNoiseEst->ave_enr_fx, NB_BANDS, sub( scale, st->hNoiseEst->ave_enr_q ) );
+ scale_sig32( st->hNoiseEst->ave_enr2_fx, NB_BANDS, sub( scale, st->hNoiseEst->ave_enr_q ) );
+ st->hNoiseEst->ave_enr_q = q_tmpE = scale;
move16();
- shift = s_min( L_norm_arr( st->hNoiseEst->ave_enr_fx, NB_BANDS ), L_norm_arr( st->hNoiseEst->ave_enr2_fx, NB_BANDS ) );
- scale_sig32( st->hNoiseEst->ave_enr_fx, NB_BANDS, shift );
- scale_sig32( st->hNoiseEst->ave_enr2_fx, NB_BANDS, shift );
- st->hNoiseEst->ave_enr_q = add( st->hNoiseEst->ave_enr_q, shift );
move16();
- shift = L_norm_arr( st->hNoiseEst->bckr_fx, NB_BANDS );
- scale_sig32( st->hNoiseEst->bckr_fx, NB_BANDS, shift );
- st->hNoiseEst->q_bckr = add( st->hNoiseEst->q_bckr, shift );
+
+ scale = add( st->hNoiseEst->fr_bands_fx_q, s_min( L_norm_arr( st->hNoiseEst->fr_bands1_fx, NB_BANDS ), L_norm_arr( st->hNoiseEst->fr_bands2_fx, NB_BANDS ) ) );
+ scale = s_min( scale, add( fr_bands_fx_q, L_norm_arr( fr_bands_fx, 2 * NB_BANDS ) ) );
+ scale_sig32( fr_bands_fx, 2 * NB_BANDS, sub( scale, fr_bands_fx_q ) );
+ scale_sig32( st->hNoiseEst->fr_bands1_fx, NB_BANDS, sub( scale, st->hNoiseEst->fr_bands_fx_q ) );
+ scale_sig32( st->hNoiseEst->fr_bands2_fx, NB_BANDS, sub( scale, st->hNoiseEst->fr_bands_fx_q ) );
+ st->hNoiseEst->fr_bands_fx_q = fr_bands_fx_q = scale;
move16();
- shift = L_norm_arr( st->hNoiseEst->enrO_fx, NB_BANDS );
- scale_sig32( st->hNoiseEst->enrO_fx, NB_BANDS, shift );
- st->hNoiseEst->q_enrO = add( st->hNoiseEst->q_enrO, shift );
move16();
+ noise_est_ivas_fx( st, old_pitch1, tmpN_fx, epsP_fx, Etot_fx, *relE_fx, corr_shift_fx, tmpE_fx, q_tmpE, fr_bands_fx, fr_bands_fx_q, cor_map_sum_fx,
+ &ncharX_fx, &sp_div_fx, &q_sp_div, &non_staX_fx, loc_harm, lf_E_fx, q_lf_E_fx, &st->hNoiseEst->harm_cor_cnt, st->hNoiseEst->Etot_l_lp_fx,
+ st->hNoiseEst->Etot_v_h2_fx, &st->hNoiseEst->bg_cnt, st->lgBin_E_fx, &dummy_fx, S_map_fx,
+ hStereoClassif, NULL, st->ini_frame );
+
test();
IF( lr_vad_enabled && st->idchan == 0 )
{
FOR( Word16 j = 0; j < 2; j++ )
{
- scale_sig32( hCPE->hFrontVad[j]->hNoiseEst->bckr_fx, NB_BANDS, sub( q_fr_bands, hCPE->hFrontVad[j]->hNoiseEst->q_bckr ) );
- hCPE->hFrontVad[j]->hNoiseEst->q_bckr = q_fr_bands;
+ scale = s_min( add( q_tmpN_LR[j], L_norm_arr( tmpN_LR_fx[j], NB_BANDS ) ), add( hCPE->hFrontVad[j]->hNoiseEst->q_bckr, L_norm_arr( hCPE->hFrontVad[j]->hNoiseEst->bckr_fx, NB_BANDS ) ) );
+ scale = sub( s_min( Q31, scale ), 1 );
+ scale_sig32( hCPE->hFrontVad[j]->hNoiseEst->bckr_fx, NB_BANDS, sub( scale, hCPE->hFrontVad[j]->hNoiseEst->q_bckr ) );
+ scale_sig32( tmpN_LR_fx[j], NB_BANDS, sub( scale, q_tmpN_LR[j] ) );
+ hCPE->hFrontVad[j]->hNoiseEst->q_bckr = q_tmpN_LR[j] = scale;
move16();
- scale_sig32( hCPE->hFrontVad[j]->hNoiseEst->fr_bands1_fx, NB_BANDS, sub( q_fr_bands, hCPE->hFrontVad[j]->hNoiseEst->fr_bands_fx_q ) );
- scale_sig32( hCPE->hFrontVad[j]->hNoiseEst->fr_bands2_fx, NB_BANDS, sub( q_fr_bands, hCPE->hFrontVad[j]->hNoiseEst->fr_bands_fx_q ) );
- hCPE->hFrontVad[j]->hNoiseEst->fr_bands_fx_q = q_fr_bands;
move16();
- scale_sig32( hCPE->hFrontVad[j]->hNoiseEst->ave_enr_fx, NB_BANDS, sub( q_fr_bands, hCPE->hFrontVad[j]->hNoiseEst->ave_enr_q ) );
- scale_sig32( hCPE->hFrontVad[j]->hNoiseEst->ave_enr2_fx, NB_BANDS, sub( q_fr_bands, hCPE->hFrontVad[j]->hNoiseEst->ave_enr_q ) );
- hCPE->hFrontVad[j]->hNoiseEst->ave_enr_q = q_fr_bands;
- move16();
- shift = L_norm_arr( hCPE->hFrontVad[j]->hNoiseEst->bckr_fx, NB_BANDS );
- scale_sig32( hCPE->hFrontVad[j]->hNoiseEst->bckr_fx, NB_BANDS, shift );
- hCPE->hFrontVad[j]->hNoiseEst->q_bckr = add( hCPE->hFrontVad[j]->hNoiseEst->q_bckr, shift );
+
+ scale = add( hCPE->hFrontVad[j]->hNoiseEst->ave_enr_q, s_min( L_norm_arr( hCPE->hFrontVad[j]->hNoiseEst->ave_enr_fx, NB_BANDS ), L_norm_arr( hCPE->hFrontVad[j]->hNoiseEst->ave_enr2_fx, NB_BANDS ) ) );
+ scale = s_min( scale, add( q_tmpE_LR[j], L_norm_arr( tmpE_LR_fx[j], NB_BANDS ) ) );
+ scale = sub( s_min( Q31, scale ), 1 );
+ scale_sig32( tmpE_LR_fx[j], NB_BANDS, sub( scale, q_tmpE_LR[j] ) );
+ scale_sig32( hCPE->hFrontVad[j]->hNoiseEst->ave_enr_fx, NB_BANDS, sub( scale, hCPE->hFrontVad[j]->hNoiseEst->ave_enr_q ) );
+ scale_sig32( hCPE->hFrontVad[j]->hNoiseEst->ave_enr2_fx, NB_BANDS, sub( scale, hCPE->hFrontVad[j]->hNoiseEst->ave_enr_q ) );
+ hCPE->hFrontVad[j]->hNoiseEst->ave_enr_q = q_tmpE_LR[j] = scale;
move16();
- shift = L_norm_arr( hCPE->hFrontVad[j]->hNoiseEst->enrO_fx, NB_BANDS );
- scale_sig32( hCPE->hFrontVad[j]->hNoiseEst->enrO_fx, NB_BANDS, shift );
- hCPE->hFrontVad[j]->hNoiseEst->q_enrO = add( hCPE->hFrontVad[j]->hNoiseEst->q_enrO, shift );
move16();
- FOR( Word16 k = 0; k < NB_BANDS; k++ )
- {
- hCPE->hFrontVad[j]->hNoiseEst->fr_bands1_fx[k] = L_max( 1, hCPE->hFrontVad[j]->hNoiseEst->fr_bands1_fx[k] );
- move32();
- hCPE->hFrontVad[j]->hNoiseEst->fr_bands2_fx[k] = L_max( 1, hCPE->hFrontVad[j]->hNoiseEst->fr_bands2_fx[k] );
- move32();
- }
+ scale = add( hCPE->hFrontVad[j]->hNoiseEst->fr_bands_fx_q, s_min( L_norm_arr( hCPE->hFrontVad[j]->hNoiseEst->fr_bands1_fx, NB_BANDS ), L_norm_arr( hCPE->hFrontVad[j]->hNoiseEst->fr_bands2_fx, NB_BANDS ) ) );
+ scale = s_min( scale, add( fr_bands_LR_fx_q[j], L_norm_arr( fr_bands_LR_fx[j], 2 * NB_BANDS ) ) );
+ scale_sig32( fr_bands_LR_fx[j], 2 * NB_BANDS, sub( scale, fr_bands_LR_fx_q[j] ) );
+ scale_sig32( hCPE->hFrontVad[j]->hNoiseEst->fr_bands1_fx, NB_BANDS, sub( scale, hCPE->hFrontVad[j]->hNoiseEst->fr_bands_fx_q ) );
+ scale_sig32( hCPE->hFrontVad[j]->hNoiseEst->fr_bands2_fx, NB_BANDS, sub( scale, hCPE->hFrontVad[j]->hNoiseEst->fr_bands_fx_q ) );
+ hCPE->hFrontVad[j]->hNoiseEst->fr_bands_fx_q = fr_bands_LR_fx_q[j] = scale;
+ move16();
+ move16();
}
- /* Run noise_est for Left and Right channel */
*loc_harmLR_fx = *loc_harm;
- noise_est_ivas_fx( st, old_pitch1, tmpN_LR_fx[0], epsP_h, epsP_l, Etot_LR_fx[0], sub( Etot_LR_fx[0], hCPE->hFrontVad[0]->lp_speech_fx ), corr_shiftL_fx, tmpE_LR_fx[0], fr_bands_LR_fx[0], &cor_map_sum_LR_fx[0], &ncharX_LR_fx, &sp_div_LR_fx, &q_sp_div_LR,
- &non_staX_LR_fx, loc_harmLR_fx, lf_E_LR_fx[0], &hCPE->hFrontVad[0]->hNoiseEst->harm_cor_cnt, hCPE->hFrontVad[0]->hNoiseEst->Etot_l_lp_fx, hCPE->hFrontVad[0]->hNoiseEst->Etot_v_h2_fx, &hCPE->hFrontVad[0]->hNoiseEst->bg_cnt, st->lgBin_E_fx, sub( q_fr_bands, QSCALE ), L_shl( E_MIN_IVAS_FX, sub( q_fr_bands, Q19 ) ), &dummy_fx, S_map_LR_fx, NULL, hCPE->hFrontVad[0], hCPE->hFrontVad[0]->ini_frame );
-
- /* Note: the index [0] in the last argument is intended, the ini_frame counter is only maintained in the zero-th channel's VAD handle */
- noise_est_ivas_fx( st, old_pitch1, tmpN_LR_fx[1], epsP_h, epsP_l, Etot_LR_fx[1], sub( Etot_LR_fx[1], hCPE->hFrontVad[1]->lp_speech_fx ), corr_shiftR_fx, tmpE_LR_fx[1], fr_bands_LR_fx[1], &cor_map_sum_LR_fx[1], &ncharX_LR_fx, &sp_div_LR_fx, &q_sp_div_LR,
- &non_staX_LR_fx, loc_harmLR_fx, lf_E_LR_fx[1], &hCPE->hFrontVad[1]->hNoiseEst->harm_cor_cnt, hCPE->hFrontVad[1]->hNoiseEst->Etot_l_lp_fx, hCPE->hFrontVad[1]->hNoiseEst->Etot_v_h2_fx, &hCPE->hFrontVad[1]->hNoiseEst->bg_cnt, st->lgBin_E_fx, sub( q_fr_bands, QSCALE ), L_shl( E_MIN_IVAS_FX, sub( q_fr_bands, Q19 ) ), &dummy_fx, S_map_LR_fx, NULL, hCPE->hFrontVad[1], hCPE->hFrontVad[0]->ini_frame );
+ move16();
+ /* Run noise_est for Left and Right channel */
+ noise_est_ivas_fx( st, old_pitch1, tmpN_LR_fx[0], epsP_fx, Etot_LR_fx[0], sub( Etot_LR_fx[0], hCPE->hFrontVad[0]->lp_speech_fx ), corr_shiftL_fx,
+ tmpE_LR_fx[0], q_tmpE_LR[0], fr_bands_LR_fx[0], fr_bands_LR_fx_q[0], &cor_map_sum_LR_fx[0], &ncharX_LR_fx, &sp_div_LR_fx, &q_sp_div_LR,
+ &non_staX_LR_fx, loc_harmLR_fx, lf_E_LR_fx[0], lf_E_LR_fx_q, &hCPE->hFrontVad[0]->hNoiseEst->harm_cor_cnt,
+ hCPE->hFrontVad[0]->hNoiseEst->Etot_l_lp_fx, hCPE->hFrontVad[0]->hNoiseEst->Etot_v_h2_fx, &hCPE->hFrontVad[0]->hNoiseEst->bg_cnt,
+ st->lgBin_E_fx, &dummy_fx, S_map_LR_fx, NULL, hCPE->hFrontVad[0], hCPE->hFrontVad[0]->ini_frame );
- /*Scaling to avoid 0 values*/
- FOR( Word16 j = 0; j < 2; j++ )
- {
- shift = s_min( L_norm_arr( hCPE->hFrontVad[j]->hNoiseEst->fr_bands1_fx, NB_BANDS ), L_norm_arr( hCPE->hFrontVad[j]->hNoiseEst->fr_bands2_fx, NB_BANDS ) );
- scale_sig32( hCPE->hFrontVad[j]->hNoiseEst->fr_bands1_fx, NB_BANDS, shift );
- scale_sig32( hCPE->hFrontVad[j]->hNoiseEst->fr_bands2_fx, NB_BANDS, shift );
- hCPE->hFrontVad[j]->hNoiseEst->fr_bands_fx_q = add( hCPE->hFrontVad[j]->hNoiseEst->fr_bands_fx_q, shift );
- shift = s_min( L_norm_arr( hCPE->hFrontVad[j]->hNoiseEst->ave_enr_fx, NB_BANDS ), L_norm_arr( hCPE->hFrontVad[j]->hNoiseEst->ave_enr2_fx, NB_BANDS ) );
- scale_sig32( hCPE->hFrontVad[j]->hNoiseEst->ave_enr_fx, NB_BANDS, shift );
- scale_sig32( hCPE->hFrontVad[j]->hNoiseEst->ave_enr2_fx, NB_BANDS, shift );
- hCPE->hFrontVad[j]->hNoiseEst->ave_enr_q = add( hCPE->hFrontVad[j]->hNoiseEst->ave_enr_q, shift );
- }
+ /* Note: the index [0] in the last argument is intended, the ini_frame counter is only maintained in the zero-th channel's VAD handle */
+ noise_est_ivas_fx( st, old_pitch1, tmpN_LR_fx[1], epsP_fx, Etot_LR_fx[1], sub( Etot_LR_fx[1], hCPE->hFrontVad[1]->lp_speech_fx ), corr_shiftR_fx,
+ tmpE_LR_fx[1], q_tmpE_LR[1], fr_bands_LR_fx[1], fr_bands_LR_fx_q[1], &cor_map_sum_LR_fx[1], &ncharX_LR_fx, &sp_div_LR_fx, &q_sp_div_LR,
+ &non_staX_LR_fx, loc_harmLR_fx, lf_E_LR_fx[1], lf_E_LR_fx_q, &hCPE->hFrontVad[1]->hNoiseEst->harm_cor_cnt,
+ hCPE->hFrontVad[1]->hNoiseEst->Etot_l_lp_fx, hCPE->hFrontVad[1]->hNoiseEst->Etot_v_h2_fx, &hCPE->hFrontVad[1]->hNoiseEst->bg_cnt,
+ st->lgBin_E_fx, &dummy_fx, S_map_LR_fx, NULL, hCPE->hFrontVad[1], hCPE->hFrontVad[0]->ini_frame );
}
/*------------------------------------------------------------------*
@@ -1526,11 +1438,23 @@ ivas_error pre_proc_front_ivas_fx(
* Find spectral tilt
* UC and VC frame selection
*-----------------------------------------------------------------*/
- find_tilt_ivas_fx( fr_bands_fx, st->hNoiseEst->bckr_fx, ee_fx, st->pitch, st->voicing_fx, lf_E_fx, corr_shift_fx, st->input_bwidth, st->max_band, hp_E_fx, MODE1, q_fr_bands, &( st->bckr_tilt_lt ), st->Opt_SC_VBR );
+ scale = s_min( Q31, s_min( add( st->hNoiseEst->q_bckr, L_norm_arr( st->hNoiseEst->bckr_fx, NB_BANDS ) ), add( fr_bands_fx_q, L_norm_arr( fr_bands_fx, 2 * NB_BANDS ) ) ) );
+ scale_sig32( fr_bands_fx, 2 * NB_BANDS, sub( scale, fr_bands_fx_q ) );
+ scale_sig32( st->hNoiseEst->bckr_fx, NB_BANDS, sub( scale, st->hNoiseEst->q_bckr ) );
+ st->hNoiseEst->q_bckr = fr_bands_fx_q = scale;
+ move16();
+ move16();
- 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_inp_12k8, q_fr_bands );
+ find_tilt_ivas_fx( fr_bands_fx, fr_bands_fx_q, st->hNoiseEst->bckr_fx, st->hNoiseEst->q_bckr, ee_fx, st->pitch, st->voicing_fx, lf_E_fx, q_lf_E_fx,
+ corr_shift_fx, st->input_bwidth, st->max_band, hp_E_fx, MODE1, &( st->bckr_tilt_lt ), st->Opt_SC_VBR );
- Copy_Scale_sig_16_32( st->lgBin_E_fx, st->Bin_E_fx, L_FFT / 2, sub( st->q_Bin_E, Q7 ) );
+ st->coder_type = find_uv_ivas_fx( st, pitch_fr_fx, voicing_fr_fx, inp_12k8_fx, ee_fx, &dE1X_fx, corr_shift_fx, *relE_fx, Etot_fx, hp_E_fx,
+ &flag_spitch, last_core_orig, hStereoClassif, *Q_new /*q_inp_12k8*/, fr_bands_fx_q ); // Q0
+#ifdef FIX_ISSUE_1237
+ Copy_Scale_sig_16_32_no_sat( st->lgBin_E_fx, st->Bin_E_fx, L_FFT / 2, sub( st->q_Bin_E, Q7 ) );
+#else
+ Copy_Scale_sig_16_32_DEPREC( st->lgBin_E_fx, st->Bin_E_fx, L_FFT / 2, sub( st->q_Bin_E, Q7 ) );
+#endif
/*-----------------------------------------------------------------*
* channel aware mode configuration *
@@ -1546,13 +1470,14 @@ ivas_error pre_proc_front_ivas_fx(
* TC frame selection
*-----------------------------------------------------------------*/
- st->clas = signal_clas_fx( st, inp_12k8_fx, ee_fx, *relE_fx, L_look, tdm_SM_last_clas );
+ st->clas = signal_clas_fx( st, inp_12k8_fx, ee_fx, *relE_fx, L_look, tdm_SM_last_clas ); /* Q0 */
+ move16();
select_TC_fx( MODE1, st->tc_cnt, &st->coder_type, st->localVAD );
if ( st->Opt_SC_VBR )
{
- st->hSC_VBR->Local_VAD = st->localVAD;
+ st->hSC_VBR->Local_VAD = st->localVAD; /* Q0 */
move16();
}
@@ -1564,10 +1489,10 @@ ivas_error pre_proc_front_ivas_fx(
Word16 max_e_Etot;
max_e_Etot = s_max( hStereoClassif->e_Etot_buf_fx, s_max( hStereoClassif->Etot_up_e, hStereoClassif->Etot_dn_e ) );
- scale_sig32( hStereoClassif->Etot_buf_fx, 3, sub( hStereoClassif->e_Etot_buf_fx, max_e_Etot ) );
- hStereoClassif->Etot_up_fx = L_shr( hStereoClassif->Etot_up_fx, sub( max_e_Etot, hStereoClassif->Etot_up_e ) );
+ scale_sig32( hStereoClassif->Etot_buf_fx, 3, sub( hStereoClassif->e_Etot_buf_fx, max_e_Etot ) ); /* exp(max_e_Etot) */
+ hStereoClassif->Etot_up_fx = L_shr( hStereoClassif->Etot_up_fx, sub( max_e_Etot, hStereoClassif->Etot_up_e ) ); /* exp(max_e_Etot) */
move32();
- hStereoClassif->Etot_dn_fx = L_shr( hStereoClassif->Etot_dn_fx, sub( max_e_Etot, hStereoClassif->Etot_dn_e ) );
+ hStereoClassif->Etot_dn_fx = L_shr( hStereoClassif->Etot_dn_fx, sub( max_e_Etot, hStereoClassif->Etot_dn_e ) ); /* exp(max_e_Etot) */
move32();
hStereoClassif->Etot_up_e = hStereoClassif->Etot_dn_e = hStereoClassif->e_Etot_buf_fx = max_e_Etot;
move16();
@@ -1575,7 +1500,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 ) );
}
/*----------------------------------------------------------------*
@@ -1587,7 +1512,7 @@ ivas_error pre_proc_front_ivas_fx(
scale_sig32( PS_fx, 128, shift );
Qfact_PS = add( Qfact_PS, shift );
- smc_dec = ivas_smc_gmm_fx( st, hStereoClassif, localVAD_HE_SAD, Etot_fx, lsp_new_fx, *cor_map_sum_fx /*Q8*/, epsP_fx, PS_fx, non_staX_fx, *relE_fx, &high_lpn_flag, flag_spitch, Qfact_PS, *epsP_fx_q, hSpMusClas->past_PS_Q );
+ smc_dec = ivas_smc_gmm_fx( st, hStereoClassif, localVAD_HE_SAD, Etot_fx, lsp_new_fx, *cor_map_sum_fx /*Q8*/, epsP_fx, PS_fx, non_staX_fx, *relE_fx, &high_lpn_flag, flag_spitch, Qfact_PS, *epsP_fx_q, hSpMusClas->past_PS_Q ); /* Q0 */
#ifdef DEBUGGING
if ( st->idchan == 0 )
@@ -1612,7 +1537,7 @@ ivas_error pre_proc_front_ivas_fx(
ivas_long_enr_fx( st, Etot_fx, localVAD_HE_SAD, high_lpn_flag, NULL, 1, NULL, NULL );
- Copy32( fr_bands_fx + NB_BANDS, st->hNoiseEst->enrO_fx, NB_BANDS );
+ Copy32( fr_bands_fx + NB_BANDS, st->hNoiseEst->enrO_fx, NB_BANDS ); /* fr_bands_fx_q */
st->hNoiseEst->q_enrO = fr_bands_fx_q;
move16();
@@ -1621,11 +1546,11 @@ ivas_error pre_proc_front_ivas_fx(
{
ivas_long_enr_fx( st, -1, localVAD_HE_SAD, high_lpn_flag, hCPE->hFrontVad, CPE_CHANNELS, localVAD_HE_SAD_LR, Etot_LR_fx );
- Copy32( fr_bands_LR_fx[0] + NB_BANDS, hCPE->hFrontVad[0]->hNoiseEst->enrO_fx, NB_BANDS );
- hCPE->hFrontVad[0]->hNoiseEst->q_enrO = fr_bands_LR_fx_q;
+ Copy32( fr_bands_LR_fx[0] + NB_BANDS, hCPE->hFrontVad[0]->hNoiseEst->enrO_fx, NB_BANDS ); // fr_bands_LR_fx_q
+ hCPE->hFrontVad[0]->hNoiseEst->q_enrO = fr_bands_LR_fx_q[0];
move16();
- Copy32( fr_bands_LR_fx[1] + NB_BANDS, hCPE->hFrontVad[1]->hNoiseEst->enrO_fx, NB_BANDS );
- hCPE->hFrontVad[1]->hNoiseEst->q_enrO = fr_bands_LR_fx_q;
+ Copy32( fr_bands_LR_fx[1] + NB_BANDS, hCPE->hFrontVad[1]->hNoiseEst->enrO_fx, NB_BANDS ); // fr_bands_LR_fx_q
+ hCPE->hFrontVad[1]->hNoiseEst->q_enrO = fr_bands_LR_fx_q[1];
move16();
}
@@ -1671,14 +1596,14 @@ ivas_error pre_proc_front_ivas_fx(
test();
test();
test();
- IF( EQ_32( ivas_format, SBA_FORMAT ) && NE_32( st->core_brate, FRAME_NO_DATA ) && EQ_32( st->last_core_brate, FRAME_NO_DATA ) && st->sba_br_sw_while_no_data )
+ IF( EQ_32( ivas_format, SBA_FORMAT ) && st->core_brate != FRAME_NO_DATA && st->last_core_brate == FRAME_NO_DATA && st->sba_br_sw_while_no_data )
{
SetModeIndex_ivas_fx( st, L_mult0( st->bits_frame_nominal, FRAMES_PER_SEC ), element_mode, MCT_flag );
st->sba_br_sw_while_no_data = 0;
move16();
}
- ELSE IF( EQ_32( ivas_format, SBA_FORMAT ) && EQ_32( st->core_brate, FRAME_NO_DATA ) && NE_32( element_brate, last_element_brate ) )
+ ELSE IF( EQ_32( ivas_format, SBA_FORMAT ) && st->core_brate == FRAME_NO_DATA && NE_32( element_brate, last_element_brate ) )
{
st->sba_br_sw_while_no_data = 1;
move16();
@@ -1686,12 +1611,12 @@ ivas_error pre_proc_front_ivas_fx(
IF( flag_16k_smc )
{
- Scale_sig( st->input_fx, input_frame, sub( -1, st->q_inp ) );
+ Scale_sig( st->input_fx, input_frame, sub( -1, st->q_inp ) ); /* Q(-1) */
st->q_inp = -1;
move16();
}
/* these are for ivas_acelp_tcx20_switching_fx */
- Scale_sig32( st->hTcxEnc->spectrum_long_fx, N_MAX, sub( st->hTcxEnc->spectrum_long_e, 16 ) );
+ Scale_sig32( st->hTcxEnc->spectrum_long_fx, N_MAX, sub( st->hTcxEnc->spectrum_long_e, 16 ) ); /* Q(-1) */
st->hTcxEnc->spectrum_long_e = 16;
move16();
st->hTcxEnc->spectrum_e[0] = 16;
@@ -1703,27 +1628,27 @@ ivas_error pre_proc_front_ivas_fx(
Word16 Q_old_inp_16k = -1;
move16();
- Scale_sig( st->old_inp_16k_fx, L_INP_MEM, sub( Q_old_inp_16k, sub( Q15, st->exp_old_inp_16k ) ) );
+ Scale_sig( st->old_inp_16k_fx, L_INP_MEM, sub( Q_old_inp_16k, sub( Q15, st->exp_old_inp_16k ) ) ); /* Q15 - Q_old_inp_16k */
st->exp_old_inp_16k = sub( Q15, Q_old_inp_16k );
move16();
IF( st->hBWE_FD != NULL )
{
- Scale_sig( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k, sub( -1, st->Q_old_wtda ) );
- st->Q_old_wtda = -1; // This reset needs to be looked into
+ Scale_sig( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k, sub( -1, st->Q_old_wtda ) ); /* Q(-1) */
+ st->Q_old_wtda = -1; // This reset needs to be looked into
move16();
}
- st->mem_preemph_enc = shl( st->mem_preemph_enc, sub( Q_old_inp_16k, sub( Q15, st->exp_mem_preemph_enc ) ) );
+ st->mem_preemph_enc = shl( st->mem_preemph_enc, sub( Q_old_inp_16k, sub( Q15, st->exp_mem_preemph_enc ) ) ); /* Q15 - Q_old_inp_16k */
move16();
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 ) ) );
+ 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->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 ) ) );
+ 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 */
st->exp_buf_speech_enc_pe = sub( Q15, Q_old_inp_16k );
move16();
- Scale_sig( st->buf_speech_enc, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, sub( Q_old_inp_16k, sub( Q15, st->exp_buf_speech_enc ) ) );
+ Scale_sig( st->buf_speech_enc, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, sub( Q_old_inp_16k, sub( Q15, st->exp_buf_speech_enc ) ) ); /* Q15 - Q_old_inp_16k */
st->exp_buf_speech_enc = sub( Q15, Q_old_inp_16k );
move16();
@@ -1734,7 +1659,7 @@ ivas_error pre_proc_front_ivas_fx(
A_fx, Aw_fx,
epsP_fx,
lsp_new_fx, lsp_mid_fx, Q_old_inp_16k, Q_r, Q_new, 1 );
- IF( error != IVAS_ERR_OK )
+ IF( NE_32( error, IVAS_ERR_OK ) )
{
return error;
}
@@ -1746,21 +1671,21 @@ ivas_error pre_proc_front_ivas_fx(
*Q_new = add( *Q_new, Q_to_be_looked_into ); // actual Q_new
move16();
- Scale_sig( old_inp_12k8_fx, L_INP_12k8, sub( *Q_new, Q_old_inp_12k8 ) );
+ Scale_sig( old_inp_12k8_fx, L_INP_12k8, sub( *Q_new, Q_old_inp_12k8 ) ); /* Q_new */
- 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 ) ) );
+ 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();
- 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 );
+ 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
{
- Scale_sig( old_wsp_fx, L_WSP, sub( *Q_new, *q_old_wsp ) );
+ Scale_sig( old_wsp_fx, L_WSP, sub( *Q_new, *q_old_wsp ) ); /* Q_new */
*q_old_wsp = *Q_new;
move16();
Q_wsp = *Q_new;
move16();
- smc_dec = ivas_acelp_tcx20_switching_fx( st, inp_12k8_fx, *Q_new, wsp_fx, 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 );
+ smc_dec = ivas_acelp_tcx20_switching_fx( st, inp_12k8_fx, *Q_new, wsp_fx, 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 */
}
}
/* Switch to ACELP for non-harmonic transient signals */
@@ -1788,7 +1713,7 @@ ivas_error pre_proc_front_ivas_fx(
}
}
- Scale_sig32( st->Bin_E_fx, L_FFT, sub( add( *Q_new, Q_SCALE - 2 ), st->q_Bin_E ) );
+ Scale_sig32( st->Bin_E_fx, L_FFT, sub( add( *Q_new, Q_SCALE - 2 ), st->q_Bin_E ) ); /* Q_new + Q_SCALE - 2 */
st->q_Bin_E = add( *Q_new, Q_SCALE - 2 );
move16();
/* 2nd stage speech/music classification (ACELP/GSC/TCX core selection) */
@@ -1803,7 +1728,7 @@ ivas_error pre_proc_front_ivas_fx(
test();
if ( st->Opt_DTX_ON && NE_16( element_mode, IVAS_CPE_DFT ) )
{
- st->vad_flag = *vad_flag_dtx;
+ st->vad_flag = *vad_flag_dtx; /* Q0 */
move16();
}
@@ -1811,7 +1736,7 @@ ivas_error pre_proc_front_ivas_fx(
* Update old input signal buffer
*-----------------------------------------------------------------*/
shift = getScaleFactor16( &old_inp_12k8_fx[L_FRAME], L_INP_MEM );
- Copy_Scale_sig( &old_inp_12k8_fx[L_FRAME], st->old_inp_12k8_fx, L_INP_MEM, shift );
+ Copy_Scale_sig( &old_inp_12k8_fx[L_FRAME], st->old_inp_12k8_fx, L_INP_MEM, shift ); /* Q_new + shift */
st->exp_old_inp_12k8 = sub( Q15, add( *Q_new, shift ) );
move16();
@@ -1896,9 +1821,9 @@ static void calculate_energy_buffer_fx(
*--------------------------------------------------------------------*/
static void calculate_energy_buffer_ivas_fx(
CPE_ENC_HANDLE hCPE, /* i : CPE encoder structure */
- Word32 enerBuffer_dft_fx[], /* o : energy buffer() */
- const Word16 no_channels, /* i : no. of used CLDFB channels */
- const Word32 input_Fs, /* i : input sampling rate */
+ Word32 enerBuffer_dft_fx[], /* o : energy buffer() exp(enerBuffer_dft_e)*/
+ const Word16 no_channels, /* i : no. of used CLDFB channels Q0*/
+ const Word32 input_Fs, /* i : input sampling rate Q0*/
Word16 *enerBuffer_dft_e )
{
Word16 i, j;
@@ -1910,13 +1835,14 @@ static void calculate_energy_buffer_ivas_fx(
Word16 norm_nrg_DMX_fx;
Word64 max_abs_nrg_DMX_fx;
Flag overflow = 0;
+ move32();
max_abs_nrg_DMX_fx = 0;
move64();
Word16 temp_q1 = sub( norm_l( input_Fs ), 1 );
Word16 temp_q2 = norm_s( hCPE->hStereoDft->NFFT );
- band_res_dft_fx = div_l( L_shl( input_Fs, temp_q1 ), shl( hCPE->hStereoDft->NFFT, temp_q2 ) );
+ band_res_dft_fx = div_l( L_shl( input_Fs, temp_q1 ), shl( hCPE->hStereoDft->NFFT, temp_q2 ) ); /* Q0 */
/* chan_width_f = 24000.f / CLDFB_NO_CHANNELS_MAX; */
chan_width_f_fx = 24000 / CLDFB_NO_CHANNELS_MAX;
move16();
diff --git a/lib_enc/ivas_corecoder_enc_reconfig.c b/lib_enc/ivas_corecoder_enc_reconfig.c
index ea5676d5f909e31d496b472b0ad51108cc8848bf..847cdd0f633a14a5a2a3e0b7714924f64a3a4e55 100644
--- a/lib_enc/ivas_corecoder_enc_reconfig.c
+++ b/lib_enc/ivas_corecoder_enc_reconfig.c
@@ -48,11 +48,11 @@
/* Some float operations are still pending */
ivas_error ivas_corecoder_enc_reconfig_fx(
Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */
- const Word16 nSCE_old, /* i : number of SCEs in previous frame */
- const Word16 nCPE_old, /* i : number of CPEs in previous frame */
- const Word16 nchan_transport_old, /* i : number of TCs in previous frame */
- const Word32 brate_SCE, /* i : bitrate to be set for the SCEs */
- const Word32 brate_CPE, /* i : bitrate to be set for the CPEs */
+ const Word16 nSCE_old, /* i : number of SCEs in previous frame Q0*/
+ const Word16 nCPE_old, /* i : number of CPEs in previous frame Q0*/
+ const Word16 nchan_transport_old, /* i : number of TCs in previous frame Q0*/
+ const Word32 brate_SCE, /* i : bitrate to be set for the SCEs Q0*/
+ const Word32 brate_CPE, /* i : bitrate to be set for the CPEs Q0*/
const MC_MODE last_mc_mode /* i : switching between MC modes: last mode */
)
{
@@ -81,22 +81,22 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
move32();
set16_fx( q_input_buff, Q31, MCT_MAX_BLOCKS );
- input_frame = idiv1616U( extract_l( L_shr( hEncoderConfig->input_Fs, 1 ) ), FRAMES_PER_SEC / 2 );
- len_inp_memory = input_frame;
+ input_frame = idiv1616U( extract_l( L_shr( hEncoderConfig->input_Fs, 1 ) ), FRAMES_PER_SEC / 2 ); /* Q0 */
+ len_inp_memory = input_frame; /* Q0 */
move16();
IF( EQ_16( hEncoderConfig->ivas_format, SBA_FORMAT ) )
{
- len_inp_memory = add( len_inp_memory, NS2SA( hEncoderConfig->input_Fs, IVAS_FB_ENC_DELAY_NS ) );
+ len_inp_memory = add( len_inp_memory, NS2SA( hEncoderConfig->input_Fs, IVAS_FB_ENC_DELAY_NS ) ); /* Q0 */
}
- nchan_transport_old_real = nchan_transport_old;
+ nchan_transport_old_real = nchan_transport_old; /* Q0 */
move16();
- nchan_transport_real = st_ivas->nchan_transport;
+ nchan_transport_real = st_ivas->nchan_transport; /* Q0 */
move16();
IF( EQ_16( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) )
{
- nchan_transport_real = add( nchan_transport_real, st_ivas->hEncoderConfig->nchan_ism );
+ nchan_transport_real = add( nchan_transport_real, st_ivas->hEncoderConfig->nchan_ism ); /* Q0 */
}
/*-----------------------------------------------------------------*
@@ -110,15 +110,15 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
FOR( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ )
{
copy_encoder_config_fx( st_ivas, st_ivas->hSCE[sce_id]->hCoreCoder[0], 0 );
- st_ivas->hSCE[sce_id]->element_brate = brate_SCE;
+ st_ivas->hSCE[sce_id]->element_brate = brate_SCE; /* Q0 */
move32();
- st_ivas->hSCE[sce_id]->hCoreCoder[0]->total_brate = st_ivas->hSCE[sce_id]->element_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */
+ st_ivas->hSCE[sce_id]->hCoreCoder[0]->total_brate = st_ivas->hSCE[sce_id]->element_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() Q0*/
move32();
}
FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
{
- st_ivas->hCPE[cpe_id]->element_brate = brate_CPE;
+ st_ivas->hCPE[cpe_id]->element_brate = brate_CPE; /* Q0 */
move32();
/* prepare bitstream buffers */
@@ -133,14 +133,14 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
tmp = 0;
move16();
}
- st_ivas->hCPE[cpe_id]->hCoreCoder[n]->total_brate = L_shr( st_ivas->hCPE[cpe_id]->element_brate, tmp ); /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */
+ st_ivas->hCPE[cpe_id]->hCoreCoder[n]->total_brate = L_shr( st_ivas->hCPE[cpe_id]->element_brate, tmp ); /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() Q0*/
move32();
}
}
IF( GT_16( st_ivas->nCPE, 1 ) )
{
- IF( NE_32( ( error = mct_enc_reconfigure_fx( st_ivas, 0 ) ), IVAS_ERR_OK ) )
+ IF( ( error = mct_enc_reconfigure_fx( st_ivas, 0 ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -153,13 +153,13 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
test();
IF( EQ_16( hEncoderConfig->ivas_format, MC_FORMAT ) && EQ_16( last_mc_mode, MC_MODE_MCMASA ) )
{
- nchan_transport_old_real = add( nSCE_old, i_mult( CPE_CHANNELS, nCPE_old ) );
+ nchan_transport_old_real = add( nSCE_old, i_mult( CPE_CHANNELS, nCPE_old ) ); /* Q0 */
}
test();
IF( EQ_16( hEncoderConfig->ivas_format, MC_FORMAT ) && EQ_16( st_ivas->mc_mode, MC_MODE_MCMASA ) )
{
- nchan_transport_real = add( st_ivas->nSCE, i_mult( CPE_CHANNELS, st_ivas->nCPE ) );
+ nchan_transport_real = add( st_ivas->nSCE, i_mult( CPE_CHANNELS, st_ivas->nCPE ) ); /* Q0 */
}
/* something in transport changes */
@@ -176,7 +176,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
}
/* save bitstream information */
- nb_bits_tot = hBstr->nb_bits_tot;
+ nb_bits_tot = hBstr->nb_bits_tot; /* Q0 */
move16();
i = 0;
move16();
@@ -188,13 +188,13 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
{
IF( hBstr->ind_list[i].nb_bits > 0 )
{
- temp_ind_list[i].id = hBstr->ind_list[i].id;
+ temp_ind_list[i].id = hBstr->ind_list[i].id; /* Q0 */
move16();
- temp_ind_list[i].value = hBstr->ind_list[i].value;
+ temp_ind_list[i].value = hBstr->ind_list[i].value; /* Q0 */
move16();
- temp_ind_list[i].nb_bits = hBstr->ind_list[i].nb_bits;
+ temp_ind_list[i].nb_bits = hBstr->ind_list[i].nb_bits; /* Q0 */
move16();
- hBstr->ind_list[i].nb_bits = -1;
+ hBstr->ind_list[i].nb_bits = -1; /* Q0 */
move16();
}
@@ -203,7 +203,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
hBstr->nb_ind_tot = 0;
move16();
- nb_bits = add( nb_bits, temp_ind_list[i].nb_bits );
+ nb_bits = add( nb_bits, temp_ind_list[i].nb_bits ); /* Q0 */
i = add( i, 1 );
test();
}
@@ -224,12 +224,12 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
FOR( k = 0; k < nSCE_old; k++ )
{
shift = getScaleFactor16( st_ivas->hSCE[k]->hCoreCoder[0]->old_input_signal_fx, input_frame );
- Scale_sig( st_ivas->hSCE[k]->hCoreCoder[0]->old_input_signal_fx, input_frame, shift );
+ Scale_sig( st_ivas->hSCE[k]->hCoreCoder[0]->old_input_signal_fx, input_frame, shift ); /* st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp + shift */
st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp = add( st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp, shift );
move16();
q_com_sce = s_min( q_com_sce, st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp );
shift = getScaleFactor16( st_ivas->hSCE[k]->hCoreCoder[0]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ) );
- Scale_sig( st_ivas->hSCE[k]->hCoreCoder[0]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), shift );
+ Scale_sig( st_ivas->hSCE[k]->hCoreCoder[0]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), shift ); /* st_ivas->hSCE[k]->hCoreCoder[0]->q_inp + shift */
st_ivas->hSCE[k]->hCoreCoder[0]->q_inp = add( st_ivas->hSCE[k]->hCoreCoder[0]->q_inp, shift );
move16();
q_com_sce = s_min( q_com_sce, st_ivas->hSCE[k]->hCoreCoder[0]->q_inp );
@@ -244,12 +244,12 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
FOR( n = 0; n < CPE_CHANNELS; n++ )
{
shift = getScaleFactor16( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->old_input_signal_fx, input_frame );
- Scale_sig( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->old_input_signal_fx, input_frame, shift );
+ Scale_sig( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->old_input_signal_fx, input_frame, shift ); /* st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp + shift */
st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp = add( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp, shift );
move16();
q_com_cpe = s_min( q_com_cpe, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp );
shift = getScaleFactor16( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ) );
- Scale_sig( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), shift );
+ Scale_sig( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), shift ); /* st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp + shift */
st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp = add( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp, shift );
move16();
q_com_cpe = s_min( q_com_cpe, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp );
@@ -261,13 +261,13 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
{
FOR( k = 0; k < nSCE_old; k++ )
{
- Scale_sig( st_ivas->hSCE[k]->hCoreCoder[0]->old_input_signal_fx, input_frame, sub( q_com, st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp ) );
+ Scale_sig( st_ivas->hSCE[k]->hCoreCoder[0]->old_input_signal_fx, input_frame, sub( q_com, st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp ) ); /* q_com */
st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp = q_com;
move16();
- 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 ) );
+ 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 );
+ 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();
}
@@ -279,13 +279,13 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
{
FOR( n = 0; n < CPE_CHANNELS; n++ )
{
- Scale_sig( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->old_input_signal_fx, input_frame, sub( q_com, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp ) );
+ Scale_sig( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->old_input_signal_fx, input_frame, sub( q_com, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp ) ); /* q_com */
st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp = q_com;
move16();
- 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 ) );
+ 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 );
+ 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();
}
@@ -302,7 +302,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
IF( nSCE_old > 0 )
{
set32_fx( input_buff_fx[0], 0, len_inp_memory );
- Copy32( st_ivas->hSCE[0]->hCoreCoder[0]->input_buff32_fx, input_buff_fx[0], len_inp_memory );
+ Copy32( st_ivas->hSCE[0]->hCoreCoder[0]->input_buff32_fx, input_buff_fx[0], len_inp_memory ); /* st_ivas->hSCE[0]->hCoreCoder[0]->q_inp32 */
q_input_buff[0] = st_ivas->hSCE[0]->hCoreCoder[0]->q_inp32;
move16();
}
@@ -312,20 +312,21 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
set32_fx( input_buff_fx[n + 1], 0, len_inp_memory );
IF( nCPE_old > 0 )
{
- Copy32( st_ivas->hCPE[0]->hCoreCoder[n]->input_buff32_fx, input_buff_fx[n + 1], len_inp_memory );
+ Copy32( st_ivas->hCPE[0]->hCoreCoder[n]->input_buff32_fx, input_buff_fx[n + 1], len_inp_memory ); /* st_ivas->hCPE[0]->hCoreCoder[n]->q_inp32 */
q_input_buff[n + 1] = st_ivas->hCPE[0]->hCoreCoder[n]->q_inp32;
move16();
}
}
- ivas_mcmasa_dmx_modify_fx( len_inp_memory, input_buff_fx, nSCE_old + CPE_CHANNELS * nCPE_old, st_ivas->nSCE + CPE_CHANNELS * st_ivas->nCPE );
+ ivas_mcmasa_dmx_modify_fx( len_inp_memory, input_buff_fx, q_input_buff, nSCE_old + CPE_CHANNELS * nCPE_old, st_ivas->nSCE + CPE_CHANNELS * st_ivas->nCPE );
+
n_CoreCoder_existing = 0;
move16();
}
ELSE
{
- n_CoreCoder_existing = s_min( nchan_transport_real, nchan_transport_old_real );
+ n_CoreCoder_existing = s_min( nchan_transport_real, nchan_transport_old_real ); /* Q0 */
}
/* destroy superfluous core-coder elements */
@@ -334,11 +335,11 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
/* save input audio buffers */
IF( GT_16( n_CoreCoder_existing, sce_id ) )
{
- Copy32( st_ivas->hSCE[sce_id]->hCoreCoder[0]->input_buff32_fx, input_buff_fx[sce_id], len_inp_memory );
+ Copy32( st_ivas->hSCE[sce_id]->hCoreCoder[0]->input_buff32_fx, input_buff_fx[sce_id], len_inp_memory ); /* st_ivas->hSCE[sce_id]->hCoreCoder[0]->q_inp32 */
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;
}
@@ -349,7 +350,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
{
IF( n_CoreCoder_existing > cpe_id * CPE_CHANNELS + n )
{
- Copy32( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_buff32_fx, input_buff_fx[( cpe_id - st_ivas->nCPE ) * CPE_CHANNELS + n], len_inp_memory );
+ Copy32( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_buff32_fx, input_buff_fx[( cpe_id - st_ivas->nCPE ) * CPE_CHANNELS + n], len_inp_memory ); /* st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp32 */
q_input_buff[( cpe_id - st_ivas->nCPE ) * CPE_CHANNELS + n] = st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp32;
move16();
}
@@ -360,7 +361,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
test();
IF( LE_16( st_ivas->nCPE, 1 ) && st_ivas->hMCT != NULL )
{
- ivas_mct_enc_close( &( st_ivas->hMCT ) );
+ ivas_mct_enc_close_fx( &( st_ivas->hMCT ) );
}
/* special case, if we have MCT now and had a single CPE before, remove the MDCT Stereo handles */
@@ -379,17 +380,17 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
FOR( sce_id = 0; sce_id < nSCE_existing; sce_id++ )
{
copy_encoder_config_fx( st_ivas, st_ivas->hSCE[sce_id]->hCoreCoder[0], 0 );
- st_ivas->hSCE[sce_id]->element_brate = brate_SCE;
+ st_ivas->hSCE[sce_id]->element_brate = brate_SCE; /* Q0 */
move32();
- st_ivas->hSCE[sce_id]->hCoreCoder[0]->total_brate = st_ivas->hSCE[sce_id]->element_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */
+ st_ivas->hSCE[sce_id]->hCoreCoder[0]->total_brate = st_ivas->hSCE[sce_id]->element_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() Q0*/
move32();
- ivas_destroy_MD_bstr_enc( &( st_ivas->hSCE[sce_id]->hMetaData ) );
+ ivas_destroy_MD_bstr_enc_fx( &( st_ivas->hSCE[sce_id]->hMetaData ) );
}
FOR( sce_id = nSCE_existing; sce_id < st_ivas->nSCE; sce_id++ )
{
- IF( NE_32( ( error = create_sce_enc_fx( st_ivas, sce_id, brate_SCE ) ), IVAS_ERR_OK ) )
+ IF( ( error = create_sce_enc_fx( st_ivas, sce_id, brate_SCE ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -398,7 +399,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
test();
IF( GT_16( n_CoreCoder_existing, sce_id ) && NE_16( hEncoderConfig->ivas_format, MASA_ISM_FORMAT ) )
{
- Copy32( input_buff_fx[sce_id], st_ivas->hSCE[sce_id]->hCoreCoder[0]->input_buff32_fx, len_inp_memory );
+ Copy32( input_buff_fx[sce_id], st_ivas->hSCE[sce_id]->hCoreCoder[0]->input_buff32_fx, len_inp_memory ); /* q_input_buff[sce_id] */
st_ivas->hSCE[sce_id]->hCoreCoder[0]->q_inp32 = q_input_buff[sce_id];
move16();
}
@@ -412,7 +413,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
IF( st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData == NULL )
{
- IF( NE_32( ( error = ivas_initialize_MD_bstr_enc( &( st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData ), st_ivas ) ), IVAS_ERR_OK ) )
+ IF( NE_32( ( error = ivas_initialize_MD_bstr_enc_fx( &( st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData ), st_ivas ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -425,7 +426,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
FOR( cpe_id = 0; cpe_id < nCPE_existing; cpe_id++ )
{
- st_ivas->hCPE[cpe_id]->element_brate = brate_CPE;
+ st_ivas->hCPE[cpe_id]->element_brate = brate_CPE; /* Q0 */
move32();
/* allocate buffer of indices */
@@ -434,7 +435,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
copy_encoder_config_fx( st_ivas, st_ivas->hCPE[cpe_id]->hCoreCoder[n], 0 );
IF( GT_16( st_ivas->nCPE, 1 ) )
{
- st_ivas->hCPE[cpe_id]->hCoreCoder[n]->total_brate = st_ivas->hCPE[cpe_id]->element_brate;
+ st_ivas->hCPE[cpe_id]->hCoreCoder[n]->total_brate = st_ivas->hCPE[cpe_id]->element_brate; /* Q0 */
}
ELSE
{
@@ -458,13 +459,13 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
FOR( cpe_id = nCPE_existing; cpe_id < st_ivas->nCPE; cpe_id++ )
{
test();
- IF( EQ_16( st_ivas->mc_mode, MC_MODE_MCMASA ) && st_ivas->hMcMasa->separateChannelEnabled )
+ if ( EQ_16( st_ivas->mc_mode, MC_MODE_MCMASA ) && st_ivas->hMcMasa->separateChannelEnabled )
{
st_ivas->hEncoderConfig->element_mode_init = IVAS_CPE_MDCT;
move16();
}
- IF( NE_32( ( error = create_cpe_enc_fx( st_ivas, cpe_id, brate_CPE ) ), IVAS_ERR_OK ) )
+ IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, brate_CPE ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -475,7 +476,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
IF( GT_16( n_CoreCoder_existing, add( i_mult( cpe_id, CPE_CHANNELS ), n ) ) )
{
- Copy32( input_buff_fx[n], st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_buff32_fx, len_inp_memory );
+ Copy32( input_buff_fx[n], st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_buff32_fx, len_inp_memory ); /* q_input_buff */
st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp32 = q_input_buff[n];
move16();
}
@@ -512,21 +513,21 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
{
IF( temp_ind_list[i].nb_bits > 0 )
{
- st_ivas->hSCE[0]->hCoreCoder[0]->hBstr->ind_list[i].id = temp_ind_list[i].id;
+ st_ivas->hSCE[0]->hCoreCoder[0]->hBstr->ind_list[i].id = temp_ind_list[i].id; /* Q0 */
move16();
- st_ivas->hSCE[0]->hCoreCoder[0]->hBstr->ind_list[i].value = temp_ind_list[i].value;
+ st_ivas->hSCE[0]->hCoreCoder[0]->hBstr->ind_list[i].value = temp_ind_list[i].value; /* Q0 */
move16();
- st_ivas->hSCE[0]->hCoreCoder[0]->hBstr->ind_list[i].nb_bits = temp_ind_list[i].nb_bits;
+ st_ivas->hSCE[0]->hCoreCoder[0]->hBstr->ind_list[i].nb_bits = temp_ind_list[i].nb_bits; /* Q0 */
move16();
}
- nb_bits = add( nb_bits, temp_ind_list[i].nb_bits );
+ nb_bits = add( nb_bits, temp_ind_list[i].nb_bits ); /* Q0 */
i = add( i, 1 );
test();
}
- st_ivas->hSCE[0]->hCoreCoder[0]->hBstr->nb_ind_tot = i;
+ st_ivas->hSCE[0]->hCoreCoder[0]->hBstr->nb_ind_tot = i; /* Q0 */
move16();
- st_ivas->hSCE[0]->hCoreCoder[0]->hBstr->nb_bits_tot = nb_bits_tot;
+ st_ivas->hSCE[0]->hCoreCoder[0]->hBstr->nb_bits_tot = nb_bits_tot; /* Q0 */
move16();
}
ELSE IF( st_ivas->nCPE > 0 )
@@ -536,21 +537,21 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
{
IF( temp_ind_list[i].nb_bits > 0 )
{
- st_ivas->hCPE[0]->hCoreCoder[0]->hBstr->ind_list[i].id = temp_ind_list[i].id;
+ st_ivas->hCPE[0]->hCoreCoder[0]->hBstr->ind_list[i].id = temp_ind_list[i].id; /* Q0 */
move16();
- st_ivas->hCPE[0]->hCoreCoder[0]->hBstr->ind_list[i].value = temp_ind_list[i].value;
+ st_ivas->hCPE[0]->hCoreCoder[0]->hBstr->ind_list[i].value = temp_ind_list[i].value; /* Q0 */
move16();
- st_ivas->hCPE[0]->hCoreCoder[0]->hBstr->ind_list[i].nb_bits = temp_ind_list[i].nb_bits;
+ st_ivas->hCPE[0]->hCoreCoder[0]->hBstr->ind_list[i].nb_bits = temp_ind_list[i].nb_bits; /* Q0 */
move16();
}
- nb_bits = add( nb_bits, temp_ind_list[i].nb_bits );
+ nb_bits = add( nb_bits, temp_ind_list[i].nb_bits ); /* Q0 */
i = add( i, 1 );
test();
}
- st_ivas->hCPE[0]->hCoreCoder[0]->hBstr->nb_ind_tot = i;
+ st_ivas->hCPE[0]->hCoreCoder[0]->hBstr->nb_ind_tot = i; /* Q0 */
move16();
- st_ivas->hCPE[0]->hCoreCoder[0]->hBstr->nb_bits_tot = nb_bits_tot;
+ st_ivas->hCPE[0]->hCoreCoder[0]->hBstr->nb_bits_tot = nb_bits_tot; /* Q0 */
move16();
}
@@ -560,7 +561,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
/* restore modified transport signal */
IF( st_ivas->nSCE )
{
- Copy32( input_buff_fx[0], st_ivas->hSCE[0]->hCoreCoder[0]->input_buff32_fx, len_inp_memory );
+ Copy32( input_buff_fx[0], st_ivas->hSCE[0]->hCoreCoder[0]->input_buff32_fx, len_inp_memory ); /* q_input_buff */
st_ivas->hSCE[0]->hCoreCoder[0]->q_inp32 = q_input_buff[0];
move16();
}
@@ -569,7 +570,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
{
FOR( n = 0; n < CPE_CHANNELS; n++ )
{
- Copy32( input_buff_fx[n + 1], st_ivas->hCPE[0]->hCoreCoder[n]->input_buff32_fx, len_inp_memory );
+ Copy32( input_buff_fx[n + 1], st_ivas->hCPE[0]->hCoreCoder[n]->input_buff32_fx, len_inp_memory ); /* q_input_buff */
st_ivas->hCPE[0]->hCoreCoder[n]->q_inp32 = q_input_buff[n + 1];
move16();
}
@@ -627,31 +628,31 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
/* set correct nominal bitrates and igf config already here, needed for the correct init of the MDCT Stereo handles for MCT */
FOR( n = 0; n < CPE_CHANNELS; n++ )
{
- st_ivas->hCPE[0]->hCoreCoder[n]->total_brate = st_ivas->hCPE[0]->element_brate;
+ st_ivas->hCPE[0]->hCoreCoder[n]->total_brate = st_ivas->hCPE[0]->element_brate; /* Q0 */
move32();
- st_ivas->hCPE[0]->hCoreCoder[n]->bits_frame_nominal = extract_l( Mpy_32_32( st_ivas->hCPE[0]->element_brate, 42949673 ) /* 1/50 in Q31*/ );
+ st_ivas->hCPE[0]->hCoreCoder[n]->bits_frame_nominal = extract_l( Mpy_32_32( st_ivas->hCPE[0]->element_brate, 42949673 ) /* 1/50 in Q31*/ ); /* Q0 */
move16();
st_ivas->hCPE[0]->hCoreCoder[n]->igf = getIgfPresent_fx( st_ivas->hCPE[0]->hCoreCoder[n]->element_mode,
st_ivas->hCPE[0]->hCoreCoder[n]->bits_frame_nominal * FRAMES_PER_SEC,
st_ivas->hCPE[0]->hCoreCoder[n]->bwidth,
- st_ivas->hCPE[0]->hCoreCoder[n]->rf_mode );
+ st_ivas->hCPE[0]->hCoreCoder[n]->rf_mode ); /* Q0 */
move16();
- IF( NE_32( ( error = IGF_Reconfig( &st_ivas->hCPE[0]->hCoreCoder[n]->hIGFEnc, st_ivas->hCPE[0]->hCoreCoder[n]->igf, 1, st_ivas->hCPE[0]->element_brate, st_ivas->hCPE[0]->hCoreCoder[n]->bwidth, st_ivas->hCPE[0]->hCoreCoder[n]->element_mode, st_ivas->hCPE[0]->hCoreCoder[n]->rf_mode ) ), IVAS_ERR_OK ) )
+ IF( ( error = IGF_Reconfig( &st_ivas->hCPE[0]->hCoreCoder[n]->hIGFEnc, st_ivas->hCPE[0]->hCoreCoder[n]->igf, 1, st_ivas->hCPE[0]->element_brate, st_ivas->hCPE[0]->hCoreCoder[n]->bwidth, st_ivas->hCPE[0]->hCoreCoder[n]->element_mode, st_ivas->hCPE[0]->hCoreCoder[n]->rf_mode ) ) != IVAS_ERR_OK )
{
return error;
}
}
}
- IF( NE_32( ( error = create_mct_enc( st_ivas ) ), IVAS_ERR_OK ) )
+ IF( ( error = create_mct_enc_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
}
ELSE IF( st_ivas->hMCT != NULL && GT_16( st_ivas->nCPE, 1 ) )
{
- IF( NE_32( ( error = mct_enc_reconfigure_fx( st_ivas, st_ivas->nchan_transport != nchan_transport_old ) ), IVAS_ERR_OK ) )
+ IF( ( error = mct_enc_reconfigure_fx( st_ivas, st_ivas->nchan_transport != nchan_transport_old ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -662,7 +663,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
{
IF( st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData == NULL )
{
- IF( NE_32( ( error = ivas_initialize_MD_bstr_enc( &( st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData ), st_ivas ) ), IVAS_ERR_OK ) )
+ IF( NE_32( ( error = ivas_initialize_MD_bstr_enc_fx( &( st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData ), st_ivas ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -672,7 +673,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
FOR( cpe_id = 0; cpe_id < st_ivas->nCPE - 1; cpe_id++ )
{
- ivas_destroy_MD_bstr_enc( &( st_ivas->hCPE[cpe_id]->hMetaData ) );
+ ivas_destroy_MD_bstr_enc_fx( &( st_ivas->hCPE[cpe_id]->hMetaData ) );
}
}
@@ -688,7 +689,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
/* set correct nominal bitrates and igf config already here, needed for the correct init of the MDCT Stereo handle */
FOR( n = 0; n < CPE_CHANNELS; n++ )
{
- st_ivas->hCPE[0]->hCoreCoder[n]->total_brate = st_ivas->hCPE[0]->element_brate;
+ st_ivas->hCPE[0]->hCoreCoder[n]->total_brate = st_ivas->hCPE[0]->element_brate; /* Q0 */
move32();
st_ivas->hCPE[0]->hCoreCoder[n]->bits_frame_nominal = extract_l( Mpy_32_32( st_ivas->hCPE[0]->element_brate, 42949673 ) ) /* 1/50 in Q31*/; // ( st_ivas->hCPE[0]->element_brate / FRAMES_PER_SEC );
move16();
@@ -696,11 +697,11 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
st_ivas->hCPE[0]->hCoreCoder[n]->igf = getIgfPresent_fx( st_ivas->hCPE[0]->hCoreCoder[n]->element_mode,
L_mult0( st_ivas->hCPE[0]->hCoreCoder[n]->bits_frame_nominal, FRAMES_PER_SEC ),
st_ivas->hCPE[0]->hCoreCoder[n]->bwidth,
- st_ivas->hCPE[0]->hCoreCoder[n]->rf_mode );
+ st_ivas->hCPE[0]->hCoreCoder[n]->rf_mode ); /* Q0 */
move16();
- IF( NE_32( ( error = IGF_Reconfig( &st_ivas->hCPE[0]->hCoreCoder[n]->hIGFEnc, st_ivas->hCPE[0]->hCoreCoder[n]->igf, 1, st_ivas->hCPE[0]->element_brate, st_ivas->hCPE[0]->hCoreCoder[n]->bwidth, st_ivas->hCPE[0]->hCoreCoder[n]->element_mode, st_ivas->hCPE[0]->hCoreCoder[n]->rf_mode ) ), IVAS_ERR_OK ) )
+ IF( ( error = IGF_Reconfig( &st_ivas->hCPE[0]->hCoreCoder[n]->hIGFEnc, st_ivas->hCPE[0]->hCoreCoder[n]->igf, 1, st_ivas->hCPE[0]->element_brate, st_ivas->hCPE[0]->hCoreCoder[n]->bwidth, st_ivas->hCPE[0]->hCoreCoder[n]->element_mode, st_ivas->hCPE[0]->hCoreCoder[n]->rf_mode ) ) != IVAS_ERR_OK )
{
return error;
}
diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c
index 630fcf38e43fc41e1fa549834005d23d0247153d..5f04dc87f5014d8fc121c77ce211ec344ced090b 100644
--- a/lib_enc/ivas_cpe_enc.c
+++ b/lib_enc/ivas_cpe_enc.c
@@ -61,26 +61,30 @@ static void stereo_mode_combined_format_enc_fx( const Encoder_Struct *st_ivas, C
* Channel Pair Element (CPE) encoding routine
*-------------------------------------------------------------------*/
ivas_error ivas_cpe_enc_fx(
- Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */
- const Word16 cpe_id, /* i : CPE # identifier */
- Word32 data_fx_ch0[], /* i : input signal for channel 0 Q(q_data_fx) */
- Word32 data_fx_ch1[], /* i : input signal for channel 1 Q(q_data_fx) */
- Word16 q_data_fx, /* i : Q-factor of input signal for both channels */
- const Word16 input_frame, /* i : input frame length per channel */
- const Word16 nb_bits_metadata, /* i : number of metadata bits */
+ Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */
+ const Word16 cpe_id, /* i : CPE # identifier Q0*/
+ Word32 data_fx_ch0[], /* i : input signal for channel 0 Q(q_data_fx)*/
+ Word32 data_fx_ch1[], /* i : input signal for channel 1 Q(q_data_fx)*/
+ Word16 q_data_fx, /* i : Q-factor of input signal for both channels */
+ const Word16 input_frame, /* i : input frame length per channel Q0*/
+ const Word16 nb_bits_metadata, /* i : number of metadata bits Q0*/
Word16 Q_new_out[] )
{
CPE_ENC_HANDLE hCPE;
Encoder_State **sts;
Word16 n, n_CoreChannels;
- Word32 old_inp_12k8_fx[CPE_CHANNELS][L_INP_12k8]; /* buffer of input signal @ 12k8 Q16 */
+ Word32 old_inp_12k8_fx[CPE_CHANNELS][L_INP_12k8]; /* buffer of input signal @ 12k8 Q15 */
Word16 old_inp_12k8_16fx[CPE_CHANNELS][L_INP_12k8]; /* buffer of input signal @ 12k8 Q_new-1 */
- Word32 old_inp_16k_fx[CPE_CHANNELS][L_INP]; /* buffer of input signal @ 16kHz Q16 */
+ Word32 old_inp_16k_fx[CPE_CHANNELS][L_INP]; /* buffer of input signal @ 16kHz Q15 */
Word16 old_inp_16k_16fx[CPE_CHANNELS][L_INP]; /* buffer of input signal @ 16kHz Q_new-1 */
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 */
Word16 relE_fx[CPE_CHANNELS]; /* frame relative energy Q8 */
Word16 A_fx[CPE_CHANNELS][NB_SUBFR16k * ( M + 1 )] = { 0 }; /* A(z) unquantized for subframes Q12 */
@@ -113,6 +117,7 @@ ivas_error ivas_cpe_enc_fx(
Word32 band_energies_LR_fx[2 * NB_BANDS]; /* energy in critical bands without minimum noise floor E_MIN (Q_buffer + QSCALE - band_ener_guardbits) */
Word16 Q_buffer[2];
Word16 orig_input_fx[CPE_CHANNELS][L_FRAME48k];
+ Word16 Q_orig_inp[CPE_CHANNELS];
Word16 Etot_last_fx[CPE_CHANNELS];
Word32 tmp, input_Fs;
Word16 max_bwidth, ivas_format;
@@ -180,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
/*------------------------------------------------------------------*
@@ -188,16 +194,24 @@ ivas_error ivas_cpe_enc_fx(
FOR( n = 0; n < CPE_CHANNELS; n++ )
{
- sts[n]->idchan = n;
- sts[n]->core = -1;
- sts[n]->core_brate = -1; /* updated in dtx() */
- sts[n]->max_bwidth = max_bwidth;
+ sts[n]->idchan = n; /* Q0 */
+ sts[n]->core = -1; /* Q0 */
+ sts[n]->core_brate = -1; /* updated in dtx() Q0*/
+ sts[n]->max_bwidth = max_bwidth; /* Q0 */
+ move32();
+ move16();
+ move16();
+ move16();
+
IF( st_ivas->hMCT == NULL ) /*already updated before CPE call*/
{
- sts[n]->input_bwidth = sts[n]->last_input_bwidth; /* updated in BWD */
- sts[n]->bwidth = sts[n]->last_bwidth; /* updated in BWD */
+ sts[n]->input_bwidth = sts[n]->last_input_bwidth; /* updated in BWD Q0*/
+ sts[n]->bwidth = sts[n]->last_bwidth; /* updated in BWD Q0*/
+ move16();
+ move16();
}
sts[n]->rate_switching_reset = 0;
+ move16();
#ifdef DEBUGGING
sts[n]->force = hEncoderConfig->force;
@@ -205,15 +219,30 @@ ivas_error ivas_cpe_enc_fx(
#endif
}
- Copy32( data_fx_ch0, sts[0]->input32_fx, input_frame ); // Q(q_data_fx)
- Copy_Scale_sig32_16( sts[0]->input32_fx, sts[0]->input_fx, input_frame, sub( Q16, q_data_fx ) ); // Q(q_data_fx) -> Q0
- sts[0]->q_inp = 0;
+ Copy32( data_fx_ch0, sts[0]->input32_fx, input_frame ); // Q(q_data_fx)
+ sts[0]->q_inp32 = q_data_fx;
+ move16();
+ Word16 norm = L_norm_arr( sts[0]->input32_fx, input_frame );
+ scale_sig32( sts[0]->input32_fx, input_frame, norm );
+ sts[0]->q_inp32 = add( sts[0]->q_inp32, norm );
+ move16();
+
+ Copy_Scale_sig32_16( sts[0]->input32_fx, sts[0]->input_fx, input_frame, 0 );
+ sts[0]->q_inp = sub( sts[0]->q_inp32, Q16 );
move16();
IF( data_fx_ch1 != NULL ) /*this may happen for cases with odd number of channels*/
{
- Copy32( data_fx_ch1, sts[1]->input32_fx, input_frame ); // Q(q_data_fx)
- Copy_Scale_sig32_16( sts[1]->input32_fx, sts[1]->input_fx, input_frame, sub( Q16, q_data_fx ) ); // Q(q_data_fx) -> Q0
- sts[1]->q_inp = 0;
+ Copy32( data_fx_ch1, sts[1]->input32_fx, input_frame ); // Q(q_data_fx)
+ sts[1]->q_inp32 = q_data_fx;
+ move16();
+
+ norm = L_norm_arr( sts[1]->input32_fx, input_frame );
+ scale_sig32( sts[1]->input32_fx, input_frame, norm );
+ sts[1]->q_inp32 = add( sts[1]->q_inp32, norm );
+ move16();
+
+ Copy_Scale_sig32_16( sts[1]->input32_fx, sts[1]->input_fx, input_frame, 0 );
+ sts[1]->q_inp = sub( sts[1]->q_inp32, Q16 );
move16();
}
@@ -233,14 +262,14 @@ 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 );
+ hCPE->element_mode = select_stereo_mode_fx( hCPE, ivas_format );
}
stereo_mode_combined_format_enc_fx( st_ivas, hCPE );
Word16 Q_inp = 0;
move16();
- Word16 band_ener_guardbits = find_guarded_bits_fx( 2 * NB_BANDS );
+
Word16 Q_add = 2;
move16();
Word16 front_create_flag = 0;
@@ -248,64 +277,82 @@ ivas_error ivas_cpe_enc_fx(
#ifdef MSAN_FIX
set32_fx( band_energies_LR_fx, 0, 2 * NB_BANDS );
#endif
-#ifdef IVAS_FLOAT_FIXED_CONVERSIONS
- for ( n = 0; n < CPE_CHANNELS; n++ )
+
+ IF( hCPE->hFrontVad[0] != NULL && NE_16( hCPE->element_mode, IVAS_CPE_MDCT ) )
+ {
+ Word16 scale_inp = Q15;
+ Q_add = 0;
+ move16();
+ FOR( n = 0; n < CPE_CHANNELS; n++ )
+ {
+ scale_inp = s_min( scale_inp, s_min( sts[n]->q_inp, hCPE->hFrontVad[n]->q_mem_decim ) );
+ }
+ FOR( n = 0; n < CPE_CHANNELS; n++ )
+ {
+ Scale_sig( sts[n]->input_fx, input_frame, sub( scale_inp, sts[n]->q_inp ) );
+ Scale_sig( hCPE->hFrontVad[n]->mem_decim_fx, 2 * L_FILT_MAX, sub( scale_inp, hCPE->hFrontVad[n]->q_mem_decim ) );
+ sts[n]->q_inp = scale_inp;
+ move16();
+ hCPE->hFrontVad[n]->q_mem_decim = scale_inp;
+ }
+ Q_inp = scale_inp;
+ move16();
+ }
+
+ FOR( n = 0; n < CPE_CHANNELS; n++ )
{
Q_buffer[n] = 15;
move16();
}
-#endif
test();
IF( hCPE->hFrontVad[0] != NULL && NE_16( hCPE->element_mode, IVAS_CPE_MDCT ) )
{
- Word16 Qband = -1;
- move16();
- Word16 Q_new_old = add( add( sub( Q_inp, Qband ), Q_add ), QSCALE );
-
FOR( n = 0; n < CPE_CHANNELS; n++ )
{
Q_buffer[n] = hCPE->hFrontVad[n]->q_buffer_12k8;
move16();
- Scale_sig32( hCPE->hFrontVad[n]->hNoiseEst->bckr_fx, 20, sub( Q_new_old, hCPE->hFrontVad[n]->hNoiseEst->q_bckr ) );
- hCPE->hFrontVad[n]->hNoiseEst->q_bckr = Q_new_old;
- move16();
- Scale_sig32( hCPE->hFrontVad[n]->hNoiseEst->enrO_fx, 20, sub( Q_new_old, hCPE->hFrontVad[n]->hNoiseEst->q_enrO ) );
- hCPE->hFrontVad[n]->hNoiseEst->q_enrO = Q_new_old;
- move16();
}
}
-
- IF( NE_32( ( error = front_vad_fx( hCPE, NULL, hEncoderConfig, &hCPE->hFrontVad[0], st_ivas->hMCT != NULL, input_frame, vad_flag_dtx, fr_bands_fx, Etot_LR_fx, lf_E_fx, localVAD_HE_SAD, vad_hover_flag, band_energies_LR_fx, NULL, NULL, Q_inp, Q_buffer, Q_add, &front_create_flag ) ), IVAS_ERR_OK ) )
+ Word16 q_band_energies_LR;
+ Word16 q_fr_bands[2], q_lf_E[2];
+ IF( NE_32( ( error = front_vad_fx( hCPE, NULL, hEncoderConfig, &hCPE->hFrontVad[0], st_ivas->hMCT != NULL, input_frame, vad_flag_dtx,
+ fr_bands_fx, q_fr_bands, Etot_LR_fx, lf_E_fx, q_lf_E, localVAD_HE_SAD, vad_hover_flag, band_energies_LR_fx,
+ &q_band_energies_LR, NULL, NULL, NULL, Q_inp, Q_buffer, Q_add, &front_create_flag ) ),
+ IVAS_ERR_OK ) )
{
return error;
}
-#ifdef IVAS_FLOAT_FIXED_CONVERSIONS
- if ( hCPE->hFrontVad[0] != NULL && hCPE->element_mode != IVAS_CPE_MDCT )
+ IF( hCPE->hFrontVad[0] != NULL && NE_16( hCPE->element_mode, IVAS_CPE_MDCT ) )
{
- for ( n = 0; n < CPE_CHANNELS; n++ )
+ FOR( n = 0; n < CPE_CHANNELS; n++ )
{
// Scale_sig( hCPE->hFrontVad[n]->buffer_12k8_fx + 384, 3 * L_FRAME / 2 - 384, sub( Q_buffer[n], hCPE->hFrontVad[n]->q_buffer_12k8 ) );
hCPE->hFrontVad[n]->q_buffer_12k8 = Q_buffer[n];
+ move16();
}
}
-#endif
sts[0]->element_mode = hCPE->element_mode;
sts[1]->element_mode = hCPE->element_mode;
+ move16();
+ move16();
n_CoreChannels = 2;
- if ( hCPE->element_mode == IVAS_CPE_DFT )
+ move16();
+ IF( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) )
{
n_CoreChannels = 1; /* in DFT stereo, only M channel is coded */
+ move16();
sts[1]->vad_flag = 0;
+ move16();
}
/*----------------------------------------------------------------*
* dynamically allocate data structures depending on the actual stereo mode
*----------------------------------------------------------------*/
- IF( NE_32( ( error = stereo_memory_enc_fx( hCPE, input_Fs, max_bwidth, ivas_format, st_ivas->nchan_transport ) ), IVAS_ERR_OK ) )
+ IF( ( error = stereo_memory_enc_fx( hCPE, input_Fs, max_bwidth, ivas_format, st_ivas->nchan_transport ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -314,28 +361,31 @@ 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 ) );
- Copy_Scale_sig_16_32( sts[0]->input_fx, sts[0]->input32_fx, input_frame, sub( Q11, sts[0]->q_inp ) );
-
+#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 );
+ scale_sig32( sts[1]->input32_fx, input_frame, shift ); /* Q11 + shift */
sts[1]->q_inp32 = add( Q11, shift );
move16();
shift = getScaleFactor32( sts[0]->input32_fx, input_frame );
- scale_sig32( sts[0]->input32_fx, input_frame, shift );
+ scale_sig32( sts[0]->input32_fx, input_frame, shift ); /* Q11 + shift */
sts[0]->q_inp32 = add( Q11, shift );
move16();
Q_inp = s_min( Q_inp, s_min( sts[0]->q_inp32, sts[1]->q_inp32 ) );
- scale_sig32( sts[0]->input32_fx, input_frame, sub( Q_inp, sts[0]->q_inp32 ) );
- scale_sig32( sts[1]->input32_fx, input_frame, sub( Q_inp, sts[1]->q_inp32 ) );
+ scale_sig32( sts[0]->input32_fx, input_frame, sub( Q_inp, sts[0]->q_inp32 ) ); /* Q_inp */
+ scale_sig32( sts[1]->input32_fx, input_frame, sub( Q_inp, sts[1]->q_inp32 ) ); /* Q_inp */
sts[1]->q_inp32 = sts[0]->q_inp32 = Q_inp;
move16();
move16();
- IF( NE_32( ( error = stereo_set_tdm_fx( hCPE, input_frame, Q_inp ) ), IVAS_ERR_OK ) )
+ IF( ( error = stereo_set_tdm_fx( hCPE, input_frame, Q_inp ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -345,56 +395,62 @@ ivas_error ivas_cpe_enc_fx(
* Resets/updates in case of stereo switching
*----------------------------------------------------------------*/
shift = getScaleFactor16( sts[1]->old_input_signal_fx, input_frame );
- Scale_sig( sts[1]->old_input_signal_fx, input_frame, shift );
+ 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 );
+ Scale_sig( sts[1]->input_fx, input_frame, shift ); /* sts[1]->q_inp + shift */
sts[1]->q_inp = add( sts[1]->q_inp, shift );
move16();
shift = getScaleFactor16( sts[0]->old_input_signal_fx, input_frame );
- Scale_sig( sts[0]->old_input_signal_fx, input_frame, shift );
+ Scale_sig( sts[0]->old_input_signal_fx, input_frame, shift ); /* sts[1]->q_old_inp + shift */
sts[0]->q_old_inp = add( sts[0]->q_old_inp, shift );
move16();
shift = getScaleFactor16( sts[0]->input_fx, input_frame );
- Scale_sig( sts[0]->input_fx, input_frame, shift );
+ 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();
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 ) );
- Scale_sig( sts[1]->input_fx, input_frame, sub( q_inp, sts[1]->q_inp ) );
- Scale_sig( sts[1]->old_input_signal_fx, input_frame, sub( q_inp, sts[1]->q_old_inp ) );
+ Scale_sig( sts[1]->input_fx, input_frame, sub( q_inp, sts[1]->q_inp ) ); /* q_inp */
+ Scale_sig( sts[1]->old_input_signal_fx, input_frame, sub( q_inp, sts[1]->q_old_inp ) ); /* q_inp */
sts[1]->q_inp = q_inp;
sts[1]->q_old_inp = q_inp;
- Scale_sig( sts[0]->input_fx, input_frame, sub( q_inp, sts[0]->q_inp ) );
- Scale_sig( sts[0]->old_input_signal_fx, input_frame, sub( q_inp, sts[0]->q_old_inp ) );
+ move16();
+ move16();
+
+ Scale_sig( sts[0]->input_fx, input_frame, sub( q_inp, sts[0]->q_inp ) ); /* q_inp */
+ Scale_sig( sts[0]->old_input_signal_fx, input_frame, sub( q_inp, sts[0]->q_old_inp ) ); /* q_inp */
sts[0]->q_inp = q_inp;
move16();
sts[0]->q_old_inp = q_inp;
move16();
- Scale_sig( sts[0]->buf_speech_enc, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, sub( q_inp, sub( Q15, sts[0]->exp_buf_speech_enc ) ) );
-
+ Scale_sig( sts[0]->buf_speech_enc, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, sub( q_inp, sub( Q15, sts[0]->exp_buf_speech_enc ) ) ); // q_inp
+ sts[0]->exp_buf_speech_enc = sub( Q15, q_inp );
+ move16();
stereo_switching_enc_fx( hCPE, sts[0]->old_input_signal_fx, input_frame, q_inp );
/*----------------------------------------------------------------*
* 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 );
+ 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 );
+ 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();
stereo_tca_enc_fx( hCPE, input_frame );
- Copy_Scale_sig32_16( sts[0]->input_buff32_fx, sts[0]->input_buff_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), sub( add( Q16, 0 ), sts[0]->q_inp32 ) );
- Copy_Scale_sig32_16( sts[1]->input_buff32_fx, sts[1]->input_buff_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), sub( add( Q16, 0 ), sts[1]->q_inp32 ) );
+ shift = s_min( 0, sub( add( L_norm_arr( sts[0]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ), sts[0]->q_inp32 ), 16 ) );
+ shift = s_min( shift, sub( add( L_norm_arr( sts[1]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ), sts[1]->q_inp32 ), 16 ) );
+ Copy_Scale_sig32_16( sts[0]->input_buff32_fx, sts[0]->input_buff_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), sub( add( Q16, shift ), sts[0]->q_inp32 ) ); // shift
+ Copy_Scale_sig32_16( sts[1]->input_buff32_fx, sts[1]->input_buff_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), sub( add( Q16, shift ), sts[1]->q_inp32 ) ); // shift
- sts[0]->q_inp = sts[1]->q_inp = sts[0]->q_old_inp = sts[1]->q_old_inp = 0;
+ sts[0]->q_inp = sts[1]->q_inp = sts[0]->q_old_inp = sts[1]->q_old_inp = shift;
move16();
move16();
move16();
@@ -405,14 +461,15 @@ ivas_error ivas_cpe_enc_fx(
FOR( n = 0; n < CPE_CHANNELS; n++ )
{
- Scale_sig( sts[n]->input_fx, input_frame, sub( -1, sts[n]->q_inp ) );
- sts[n]->q_inp = -1;
- Copy( sts[n]->input_fx, orig_input_fx[n], input_frame );
+ Copy( sts[n]->input_fx, orig_input_fx[n], input_frame ); /* sts->q_inp */
+ Scale_sig( orig_input_fx[n], input_frame, sub( -1, sts[n]->q_inp ) ); // Q(-1)
+ Q_orig_inp[n] = -1;
+ move16();
IF( hCPE->hStereoICBWE != NULL )
{
- hCPE->hStereoICBWE->dataChan_fx[n] = &orig_input_fx[n][0];
- hCPE->hStereoICBWE->q_dataChan_fx = sts[n]->q_inp;
+ hCPE->hStereoICBWE->dataChan_fx[n] = &orig_input_fx[n][0]; // Q_orig_inp
+ hCPE->hStereoICBWE->q_dataChan_fx = Q_orig_inp[n];
move16();
}
}
@@ -470,23 +527,32 @@ ivas_error ivas_cpe_enc_fx(
IF( NE_16( hCPE->element_mode, IVAS_CPE_MDCT ) && ( NE_32( hCPE->element_brate, hCPE->last_element_brate ) || NE_16( hCPE->last_element_mode, hCPE->element_mode ) || sts[0]->ini_frame == 0 ||
( NE_32( ivas_total_brate, st_ivas->hEncoderConfig->last_ivas_total_brate ) ) || LE_32( sts[0]->last_core_brate, SID_2k40 ) ) ) /* If the last frame was SID or NO_DATA, we need to run stereo_dft_config here since VAD decision is not known yet */
{
+ STEREO_DFT_CONFIG_DATA_HANDLE hConfig;
+ IF( hCPE->hStereoDft == NULL )
+ {
+ hConfig = NULL;
+ }
+ ELSE
+ {
+ hConfig = hCPE->hStereoDft->hConfig;
+ }
IF( st_ivas->hQMetaData != NULL )
{
test();
/* No Basop - st_ivas->ism_mode != ISM_MODE_NONE as comparison with 0 */
IF( EQ_16( ivas_format, MASA_ISM_FORMAT ) && st_ivas->ism_mode != ISM_MODE_NONE )
{
- stereo_dft_config_fx( hCPE->hStereoDft == NULL ? NULL : hCPE->hStereoDft->hConfig, L_mult0( st_ivas->hQMetaData->bits_frame_nominal, 35 /* 0.70f * FRAMES_PER_SEC */ ), &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal );
+ stereo_dft_config_fx( hConfig, L_mult0( st_ivas->hQMetaData->bits_frame_nominal, 35 /* 0.70f * FRAMES_PER_SEC */ ), &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal );
}
ELSE
{
- stereo_dft_config_fx( hCPE->hStereoDft == NULL ? NULL : hCPE->hStereoDft->hConfig, L_mult0( st_ivas->hQMetaData->bits_frame_nominal, FRAMES_PER_SEC ), &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal );
+ stereo_dft_config_fx( hConfig, L_mult0( st_ivas->hQMetaData->bits_frame_nominal, FRAMES_PER_SEC ), &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal );
}
}
ELSE
{
/* note; "bits_frame_nominal" needed in TD stereo as well */
- stereo_dft_config_fx( hCPE->hStereoDft == NULL ? NULL : hCPE->hStereoDft->hConfig, hCPE->element_brate, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal );
+ stereo_dft_config_fx( hConfig, hCPE->element_brate, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal );
}
}
@@ -494,8 +560,8 @@ ivas_error ivas_cpe_enc_fx(
{
IF( hCPE->hStereoTD->tdm_LRTD_flag )
{
- sts[0]->bits_frame_nominal = (int16_t) ( ( hCPE->element_brate >> 1 ) / FRAMES_PER_SEC );
- sts[1]->bits_frame_nominal = (int16_t) ( ( hCPE->element_brate >> 1 ) / FRAMES_PER_SEC );
+ sts[0]->bits_frame_nominal = extract_l( Mult_32_32( L_shr( hCPE->element_brate, 1 ), ONE_BY_FRAMES_PER_SEC_Q31 ) ); /* Q0 */
+ sts[1]->bits_frame_nominal = extract_l( Mult_32_32( L_shr( hCPE->element_brate, 1 ), ONE_BY_FRAMES_PER_SEC_Q31 ) ); /* Q0 */
}
ELSE
{
@@ -503,50 +569,75 @@ ivas_error ivas_cpe_enc_fx(
}
}
- if ( hCPE->element_mode == IVAS_CPE_MDCT )
+ IF( EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) )
{
/* compute bit-rate surplus per channel in combined format coding */
- int32_t brate_surplus[CPE_CHANNELS];
- if ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_DISC )
+ Word32 brate_surplus[CPE_CHANNELS];
+ test();
+ test();
+ IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) || EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) || EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) )
{
- brate_surplus[0] = ( ( hCPE->brate_surplus / FRAMES_PER_SEC ) >> 1 ) * FRAMES_PER_SEC;
- brate_surplus[1] = hCPE->brate_surplus - brate_surplus[0];
+ brate_surplus[0] = imult3216( L_shr( Mpy_32_32_r( hCPE->brate_surplus, ONE_BY_FRAMES_PER_SEC_Q31 ), 1 ), FRAMES_PER_SEC ); /* Q0 */
+ brate_surplus[1] = L_sub( hCPE->brate_surplus, brate_surplus[0] ); /* Q0 */
+ move32();
+ move32();
}
/* this is just for initialization, the true values of "total_brate" and "bits_frame_channel" are set later */
- for ( n = 0; n < n_CoreChannels; n++ )
+ FOR( n = 0; n < n_CoreChannels; n++ )
{
- if ( st_ivas->hMCT )
+ IF( st_ivas->hMCT )
{
- int16_t lfe_bits;
- lfe_bits = ( ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCT ? st_ivas->hLFE->lfe_bits : 0 );
- sts[n]->total_brate = hCPE->element_brate;
- sts[n]->bits_frame_nominal = (int16_t) ( hCPE->element_brate / FRAMES_PER_SEC );
- sts[n]->bits_frame_channel = (int16_t) ( ( ivas_total_brate / FRAMES_PER_SEC - lfe_bits - nb_bits_metadata ) / st_ivas->hMCT->nchan_out_woLFE );
+ Word16 lfe_bits;
+ test();
+ IF( EQ_16( ivas_format, MC_FORMAT ) && EQ_16( st_ivas->mc_mode, MC_MODE_MCT ) )
+ {
+ lfe_bits = st_ivas->hLFE->lfe_bits;
+ move16();
+ }
+ ELSE
+ {
+ lfe_bits = 0;
+ move16();
+ }
+ sts[n]->total_brate = hCPE->element_brate; /* Q0 */
+ sts[n]->bits_frame_nominal = extract_l( Mpy_32_32_r( hCPE->element_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); /* Q0 */
+ sts[n]->bits_frame_channel = ( idiv1616( sub( sub( extract_l( Mpy_32_32_r( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ), lfe_bits ), nb_bits_metadata ), st_ivas->hMCT->nchan_out_woLFE ) ); /* Q0 */
+ move32();
+ move16();
+ move16();
}
- else
+ ELSE
{
- sts[n]->bits_frame_nominal = (int16_t) ( hCPE->element_brate / FRAMES_PER_SEC );
- sts[n]->bits_frame_channel = (int16_t) ( ( hCPE->element_brate / FRAMES_PER_SEC ) / n_CoreChannels );
- sts[n]->total_brate = hCPE->element_brate / n_CoreChannels;
+ sts[n]->bits_frame_nominal = extract_l( Mpy_32_32_r( hCPE->element_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); /* Q0 */
+ sts[n]->bits_frame_channel = idiv1616( extract_l( Mpy_32_32_r( hCPE->element_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ), n_CoreChannels ); /* Q0 */
+ sts[n]->total_brate = L_shl( div_l( hCPE->element_brate, n_CoreChannels ), 1 ); /* Q0 */
+ move32();
+ move16();
+ move16();
/* subtract bit-rate for combined format coding */
- if ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_DISC )
+ IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) || EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) || EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) )
{
- sts[n]->bits_frame_channel += (int16_t) ( brate_surplus[n] / FRAMES_PER_SEC );
- sts[n]->total_brate += brate_surplus[n];
+ sts[n]->bits_frame_channel = add( sts[n]->bits_frame_channel, extract_l( Mpy_32_32_r( brate_surplus[n], ONE_BY_FRAMES_PER_SEC_Q31 ) ) ); /* Q0 */
+ sts[n]->total_brate = L_add( sts[n]->total_brate, brate_surplus[n] ); /* Q0 */
+ move32();
+ move16();
}
}
}
/* reconfiguration in case of bitrate switching */
- if ( hCPE->element_brate != hCPE->last_element_brate && st_ivas->hMCT == NULL )
+ IF( NE_32( hCPE->element_brate, hCPE->last_element_brate ) && st_ivas->hMCT == NULL )
{
#ifdef DEBUGGING
hCPE->hStereoMdct->mdct_stereo_mode_cmdl = hEncoderConfig->mdct_stereo_mode_cmdl;
#endif
initMdctStereoEncData_fx( hCPE->hStereoMdct, ivas_format, hCPE->element_mode, hCPE->element_brate, max_bwidth, 0, NULL, 0 );
- hCPE->hStereoMdct->isSBAStereoMode = ( ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) && ( st_ivas->nchan_transport == 2 ) );
+ test();
+ test();
+ hCPE->hStereoMdct->isSBAStereoMode = ( ( EQ_16( ivas_format, SBA_FORMAT ) || EQ_16( ivas_format, SBA_ISM_FORMAT ) ) && ( EQ_16( st_ivas->nchan_transport, 2 ) ) ); /* Q0 */
+ move16();
}
}
@@ -555,54 +646,53 @@ ivas_error ivas_cpe_enc_fx(
* Stereo down-mix
*----------------------------------------------------------------*/
// printf("\n%f %f ", hCPE->hStereoClassif->is_speech, hCPE->hCoreCoder[0]->hSpMusClas->past_dlp[0]);
- if ( hCPE->element_mode == IVAS_CPE_DFT )
+ IF( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) )
{
-#ifdef IVAS_FLOAT_FIXED_CONVERSIONS
- /* flt2fix: to be removed */
#ifndef MSAN_FIX
hCPE->hStereoClassif->xtalk_score_fx = floatToFixed( hCPE->hStereoClassif->xtalk_score, 31 );
#endif // !MSAN_FIX
/*flt2fix: dft_synthesize*/
- if ( hCPE->element_mode == IVAS_CPE_DFT && hCPE->hStereoDft->res_cod_mode[STEREO_DFT_OFFSET] )
+ test();
+ if ( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) && hCPE->hStereoDft->res_cod_mode[STEREO_DFT_OFFSET] )
{
sts[1]->exp_old_inp_12k8 = Q15;
move16();
}
- /*flt2fix end*/
-#endif
Word16 temp = getScaleFactor32( hCPE->hStereoDft->Spd_L_smooth_fx, STEREO_DFT_N_32k_ENC / 2 );
- scale_sig32( hCPE->hStereoDft->Spd_L_smooth_fx, STEREO_DFT_N_32k_ENC / 2, temp );
+ scale_sig32( hCPE->hStereoDft->Spd_L_smooth_fx, STEREO_DFT_N_32k_ENC / 2, temp ); /* exp(hCPE->hStereoDft->Spd_L_smooth_fx_e - temp)*/
hCPE->hStereoDft->Spd_L_smooth_fx_e = sub( hCPE->hStereoDft->Spd_L_smooth_fx_e, temp );
+ move16();
temp = getScaleFactor32( hCPE->hStereoDft->Spd_R_smooth_fx, STEREO_DFT_N_32k_ENC / 2 );
- scale_sig32( hCPE->hStereoDft->Spd_R_smooth_fx, STEREO_DFT_N_32k_ENC / 2, temp );
+ scale_sig32( hCPE->hStereoDft->Spd_R_smooth_fx, STEREO_DFT_N_32k_ENC / 2, temp ); /* exp(hCPE->hStereoDft->Spd_R_smooth_fx_e - temp) */
hCPE->hStereoDft->Spd_R_smooth_fx_e = sub( hCPE->hStereoDft->Spd_R_smooth_fx_e, temp );
+ move16();
shift = getScaleFactor16( sts[1]->old_input_signal_fx, input_frame );
- Scale_sig( sts[1]->old_input_signal_fx, input_frame, shift );
+ 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 );
+ 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 ) );
- 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 ) );
+ Scale_sig( sts[1]->input_fx, input_frame, sub( s_min( sts[1]->q_inp, sts[1]->q_old_inp ), sts[1]->q_inp ) ); /* min( sts[1]->q_inp, sts[1]->q_old_inp) */
+ Scale_sig( sts[1]->old_input_signal_fx, input_frame, sub( s_min( sts[1]->q_old_inp, sts[1]->q_inp ), sts[1]->q_old_inp ) ); /* min( sts[1]->q_old_inp, sts[1]->q_inp) */
sts[1]->q_inp = s_min( sts[1]->q_inp, sts[1]->q_old_inp );
move16();
sts[1]->q_old_inp = sts[1]->q_inp;
move16();
shift = getScaleFactor16( sts[0]->old_input_signal_fx, input_frame );
- Scale_sig( sts[0]->old_input_signal_fx, input_frame, shift );
+ 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 );
+ Scale_sig( sts[0]->input_fx, input_frame, shift ); /* sts[0]->q_inp + shift */
sts[0]->q_inp = add( sts[0]->q_inp, shift );
move16();
- Scale_sig( sts[0]->input_fx, input_frame, sub( s_min( sts[0]->q_inp, sts[0]->q_old_inp ), sts[0]->q_inp ) );
- 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 ) );
+ Scale_sig( sts[0]->input_fx, input_frame, sub( s_min( sts[0]->q_inp, sts[0]->q_old_inp ), sts[0]->q_inp ) ); /* min( sts[1]->q_inp, sts[1]->q_old_inp) */
+ Scale_sig( sts[0]->old_input_signal_fx, input_frame, sub( s_min( sts[0]->q_old_inp, sts[0]->q_inp ), sts[0]->q_old_inp ) ); /* min( sts[1]->q_old_inp, sts[1]->q_inp) */
sts[0]->q_inp = s_min( sts[0]->q_inp, sts[0]->q_old_inp );
move16();
sts[0]->q_old_inp = sts[0]->q_inp;
@@ -615,7 +705,7 @@ ivas_error ivas_cpe_enc_fx(
stereo_dft_enc_analyze_fx( sts, CPE_CHANNELS, input_frame, hCPE->hStereoDft, NULL, hCPE->hStereoDft->DFT_fx, hCPE->hStereoDft->DFT_fx_e, hCPE->input_mem_fx, hCPE->q_input_mem );
- sts[0]->total_brate = L_mult0( add( sts[0]->bits_frame_nominal, 10 ), FRAMES_PER_SEC ); /* add small overhead; st[0]->total_brate used in coder_type_modif() */
+ sts[0]->total_brate = L_mult0( add( sts[0]->bits_frame_nominal, 10 ), FRAMES_PER_SEC ); /* add small overhead; st[0]->total_brate used in coder_type_modif() Q0*/
/* Update DFT Stereo memories */
stereo_dft_enc_update_fx( hCPE->hStereoDft, sts[0]->max_bwidth );
@@ -623,26 +713,26 @@ ivas_error ivas_cpe_enc_fx(
/* DFT stereo processing */
stereo_dft_enc_process_fx( hCPE, vad_flag_dtx, vad_hover_flag, input_frame );
}
- else if ( EQ_16( hCPE->element_mode, IVAS_CPE_TD ) )
+ ELSE IF( EQ_16( hCPE->element_mode, IVAS_CPE_TD ) )
{
- Scale_sig( sts[0]->input_fx, input_frame, negate( sts[0]->q_inp ) );
+ Scale_sig( sts[0]->input_fx, input_frame, negate( sts[0]->q_inp ) ); /* Q0 */
sts[0]->q_inp = 0;
move16();
- Scale_sig( sts[1]->input_fx, input_frame, negate( sts[1]->q_inp ) );
+ Scale_sig( sts[1]->input_fx, input_frame, negate( sts[1]->q_inp ) ); /* Q0 */
sts[1]->q_inp = 0;
move16();
/* Determine the energy ratio between the 2 channels */
tdm_ratio_idx = stereo_tdm_ener_analysis_fx(
ivas_format,
- hCPE, input_frame, &tdm_SM_or_LRTD_Pri, &tdm_ratio_idx_SM );
+ hCPE, input_frame, &tdm_SM_or_LRTD_Pri, &tdm_ratio_idx_SM ); /* Q0 */
/* Compute the downmix signal based on the ratio index */
Word16 tdm_SM_flag;
IF( hCPE->hStereoTD->tdm_LRTD_flag == 0 )
{
- tdm_SM_flag = tdm_SM_or_LRTD_Pri;
+ tdm_SM_flag = tdm_SM_or_LRTD_Pri; /* Q0 */
move16();
}
ELSE
@@ -654,64 +744,64 @@ ivas_error ivas_cpe_enc_fx(
/* signal the bitrate for BW selection in the SCh */
sts[0]->bits_frame_channel = 0;
- sts[1]->bits_frame_channel = extract_l( Mpy_32_32( hCPE->element_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) );
- sts[1]->bits_frame_channel = add( sts[1]->bits_frame_channel, extract_l( Mpy_32_32( hCPE->brate_surplus, ONE_BY_FRAMES_PER_SEC_Q31 ) ) );
+ sts[1]->bits_frame_channel = extract_l( Mpy_32_32_r( hCPE->element_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); /* Q0 */
+ sts[1]->bits_frame_channel = add( sts[1]->bits_frame_channel, extract_l( Mpy_32_32_r( hCPE->brate_surplus, ONE_BY_FRAMES_PER_SEC_Q31 ) ) ); /* Q0 */
move16();
move16();
move16();
- IF( st_ivas->hQMetaData != NULL )
+ if ( st_ivas->hQMetaData != NULL )
{
- sts[1]->bits_frame_channel = sub( sts[1]->bits_frame_channel, st_ivas->hQMetaData->metadata_max_bits );
+ sts[1]->bits_frame_channel = sub( sts[1]->bits_frame_channel, st_ivas->hQMetaData->metadata_max_bits ); /* Q0 */
move16();
}
- Etot_last_fx[0] = sts[0]->hNoiseEst->Etot_last_fx;
- Etot_last_fx[1] = sts[1]->hNoiseEst->Etot_last_fx;
+ Etot_last_fx[0] = sts[0]->hNoiseEst->Etot_last_fx; /* Q8 */
+ Etot_last_fx[1] = sts[1]->hNoiseEst->Etot_last_fx; /* Q8 */
move16();
move16();
}
- else if ( hCPE->element_mode == IVAS_CPE_MDCT )
+ ELSE IF( EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) )
{
-#ifdef IVAS_FLOAT_FIXED_CONVERSIONS
- if ( hCPE->hStereoMdct != NULL && hCPE->hStereoMdct->hItd != NULL )
+ test();
+ IF( hCPE->hStereoMdct != NULL && hCPE->hStereoMdct->hItd != NULL )
{
- if ( hCPE->element_mode == IVAS_CPE_DFT && hCPE->hStereoDft->res_cod_mode[STEREO_DFT_OFFSET] )
+ test();
+ if ( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) && hCPE->hStereoDft->res_cod_mode[STEREO_DFT_OFFSET] )
{
sts[1]->exp_old_inp_12k8 = Q15;
move16();
}
}
-#endif
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 );
+ 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 );
+ 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 ) );
- 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 ) );
+ 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;
move16();
shift = getScaleFactor16( sts[0]->old_input_signal_fx, input_frame );
- Scale_sig( sts[0]->old_input_signal_fx, input_frame, shift );
+ 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 );
+ Scale_sig( sts[0]->input_fx, input_frame, shift ); /* sts[0]->q_inp + shift */
sts[0]->q_inp = add( sts[0]->q_inp, shift );
move16();
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 ) );
- 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 ) );
+ 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;
@@ -725,11 +815,19 @@ ivas_error ivas_cpe_enc_fx(
* DFT stereo: iDFT and resampling on both channels
*----------------------------------------------------------------*/
- if ( hCPE->element_mode == IVAS_CPE_DFT )
+ IF( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) )
{
- int32_t internal_Fs;
+ Word32 internal_Fs;
- internal_Fs = getTcxonly_ivas_fx( IVAS_CPE_MDCT, sts[0]->bits_frame_nominal * FRAMES_PER_SEC, 0, sts[0]->is_ism_format ) == 0 ? INT_FS_16k : max( INT_FS_16k, sts[0]->sr_core );
+ IF( getTcxonly_ivas_fx( IVAS_CPE_MDCT, imult1616( sts[0]->bits_frame_nominal, FRAMES_PER_SEC ), 0, sts[0]->is_ism_format ) == 0 )
+ {
+ internal_Fs = INT_FS_16k;
+ move32();
+ }
+ ELSE
+ {
+ internal_Fs = max( INT_FS_16k, sts[0]->sr_core );
+ }
/* iDFT at input sampling rate */
Word16 out_start_ind, out_end_ind;
@@ -739,46 +837,53 @@ 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
+ Word16 common_q = s_min( sub( sts[0]->q_inp, 2 ), sts[0]->q_old_inp ); /* -2 from target Q-factor sts[0]->q_inp to avoid some saturations (issue 1135) */
+ Word16 fir_delay_len = NS2SA( sts[0]->input_Fs, DELAY_FIR_RESAMPL_NS );
+ 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
+ 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 ) )
{
- Copy32( sts[0]->input32_fx - STEREO_DFT_OVL_16k, old_inp_16k_fx[0] + L_INP_MEM - STEREO_DFT_OVL_16k, input_frame + STEREO_DFT_OVL_16k );
+ Copy32( sts[0]->input32_fx - STEREO_DFT_OVL_16k, old_inp_16k_fx[0] + L_INP_MEM - STEREO_DFT_OVL_16k, add( input_frame, STEREO_DFT_OVL_16k ) ); /* Q_inp */
out_16k_start_ind = -STEREO_DFT_OVL_16k;
- out_16k_end_ind = out_16k_start_ind + input_frame + STEREO_DFT_OVL_16k;
+ out_16k_end_ind = add( out_16k_start_ind, add( input_frame, STEREO_DFT_OVL_16k ) );
+ move16();
+ move16();
}
ELSE
{
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();
IF( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) && hCPE->hStereoDft->res_cod_mode[STEREO_DFT_OFFSET] )
{
- Copy_Scale_sig_16_32_no_sat( sts[1]->old_inp_12k8_fx, old_inp_12k8_fx[1], L_INP_MEM, 16 - 0 );
+ Copy_Scale_sig_16_32_no_sat( sts[1]->old_inp_12k8_fx, old_inp_12k8_fx[1], L_INP_MEM, 15 - 0 ); // Q15
stereo_dft_enc_synthesize_fx( hCPE->hStereoDft, old_inp_12k8_fx[1] + L_INP_MEM, &out_12k8_start_ind[1], &out_12k8_end_ind[1], 1, input_Fs, 8000, 0, NULL );
/* 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 - 16 );
- }
- 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 ), Q16 ) );
-
- Copy_Scale_sig32_16( old_inp_16k_fx[0], old_inp_16k_16fx[0], L_INP, -1 ); // Q16->Q-1
-#ifdef IVAS_FLOAT_FIXED_CONVERSIONS
- /*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], -Q17 );
- if ( hCPE->element_mode == IVAS_CPE_DFT && hCPE->hStereoDft->res_cod_mode[STEREO_DFT_OFFSET] )
- {
+ Copy_Scale_sig_32_16( old_inp_12k8_fx[1] + L_FRAME8k, sts[1]->old_inp_12k8_fx, L_INP_MEM, 0 - 15 ); // Q0
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], -Q17 ); // Q-1
+ Copy_Scale_sig_32_16( old_inp_12k8_fx[1], old_inp_12k8_16fx[1], L_INP_12k8, -Q16 ); // Q-1
}
- /*fix2flt end*/
-#endif
+
/* no iDFT at input sampling rate for Side channel -> reset the buffer */
set16_fx( sts[1]->input_fx, 0, input_frame );
sts[1]->q_inp = Q15;
@@ -802,11 +907,25 @@ ivas_error ivas_cpe_enc_fx(
set16_fx( old_wsp_fx[n], 0, L_WSP );
q_old_wsp = Q15;
move16();
+ Word16 front_vad_flag;
+ IF( st_ivas->hSpar != NULL )
+ {
+ front_vad_flag = st_ivas->hSpar->front_vad_flag;
+ }
+ ELSE
+ {
+ 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, add( Q_buffer[n], QSCALE ), Etot_LR_fx, lf_E_fx, add( Q_buffer[n], QSCALE - 2 ), localVAD_HE_SAD,
- band_energies_LR_fx, sub( add( Q_buffer[n], QSCALE ), band_ener_guardbits ), 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_flag : 0, 0, 0, ivas_format, st_ivas->hMCT != NULL, ivas_total_brate, &Q_new[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 )
@@ -814,7 +933,7 @@ ivas_error ivas_cpe_enc_fx(
);
e_old_wsp[n] = sub( Q15, q_old_wsp );
move16();
- if ( error != IVAS_ERR_OK )
+ IF( error != IVAS_ERR_OK )
{
return error;
}
@@ -828,33 +947,39 @@ ivas_error ivas_cpe_enc_fx(
fft_buff_fx_final_q = sub( fft_buff_fx_final_q, 2 ); // headroom
FOR( n = 0; n < n_CoreChannels; n++ )
{
- Scale_sig( fft_buff_fx[n], 2 * L_FFT, sub( fft_buff_fx_final_q, fft_buff_fx_q[n] ) );
+ Scale_sig( fft_buff_fx[n], 2 * L_FFT, sub( fft_buff_fx_final_q, fft_buff_fx_q[n] ) ); /* fft_buff_fx_final_q */
}
/* sanity check -> DTX not supported for more than one SCEs/CPEs */
- if ( st_ivas->nSCE + st_ivas->nCPE > 1 )
+ IF( GT_16( add( st_ivas->nSCE, st_ivas->nCPE ), 1 ) )
{
- if ( sts[0]->core_brate == SID_2k40 || sts[0]->core_brate == FRAME_NO_DATA )
+ test();
+ IF( EQ_32( sts[0]->core_brate, SID_2k40 ) || sts[0]->core_brate == FRAME_NO_DATA )
{
- sts[0]->core_brate = -1;
- sts[0]->total_brate = hCPE->element_brate;
+ sts[0]->core_brate = -1; /* Q0 */
+ sts[0]->total_brate = hCPE->element_brate; /* Q0 */
+ move32();
+ move32();
}
}
/*----------------------------------------------------------------*
* Stereo DTX updates
*----------------------------------------------------------------*/
-
- if ( ivas_format == MASA_FORMAT && nb_bits_metadata > 0 && hCPE->hCoreCoder[0]->Opt_DTX_ON )
+ test();
+ test();
+ IF( EQ_16( ivas_format, MASA_FORMAT ) && nb_bits_metadata > 0 && hCPE->hCoreCoder[0]->Opt_DTX_ON )
{
- if ( hCPE->element_mode == IVAS_CPE_DFT || hCPE->element_mode == IVAS_CPE_TD )
+ test();
+ IF( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) || EQ_16( hCPE->element_mode, IVAS_CPE_TD ) )
{
reset_metadata_spatial_fx( ivas_format, hCPE->hMetaData, hCPE->element_brate, &tmp, sts[0]->core_brate, nb_bits_metadata );
}
}
/* MDCT stereo DTX: active/inactive frame decision; compute FD CNG coherence */
- if ( hCPE->element_mode == IVAS_CPE_MDCT && hEncoderConfig->Opt_DTX_ON )
+ test();
+ IF( EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) && hEncoderConfig->Opt_DTX_ON )
{
stereoFdCngCoherence_fx( sts, hCPE->last_element_mode, fft_buff_fx, sub( 15, fft_buff_fx_final_q ) /*fft exp*/ );
@@ -881,27 +1006,36 @@ ivas_error ivas_cpe_enc_fx(
IF( ( NE_32( hCPE->last_element_brate, hCPE->element_brate ) || NE_16( hCPE->element_mode, hCPE->last_element_mode ) || ( EQ_16( hCPE->element_mode, IVAS_CPE_TD ) && NE_16( sts[0]->bits_frame_nominal, last_bits_frame_nominal ) ) || NE_16( sts[n]->last_bwidth, sts[n]->bwidth ) ) && ( n == 0 || EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) ) )
{
Word16 igf;
- igf = getIgfPresent_fx( sts[n]->element_mode, L_mult0( sts[n]->bits_frame_nominal, FRAMES_PER_SEC ), sts[n]->max_bwidth, sts[n]->rf_mode );
- IF( NE_32( ( error = IGF_Reconfig_fx( &sts[n]->hIGFEnc, igf, 0, L_mult0( sts[n]->bits_frame_nominal, FRAMES_PER_SEC ), sts[n]->max_bwidth, sts[n]->element_mode, sts[n]->rf_mode ) ), IVAS_ERR_OK ) )
+ igf = getIgfPresent_fx( sts[n]->element_mode, L_mult0( sts[n]->bits_frame_nominal, FRAMES_PER_SEC ), sts[n]->max_bwidth, sts[n]->rf_mode ); /* Q0 */
+ IF( ( error = IGF_Reconfig_fx( &sts[n]->hIGFEnc, igf, 0, L_mult0( sts[n]->bits_frame_nominal, FRAMES_PER_SEC ), sts[n]->max_bwidth, sts[n]->element_mode, sts[n]->rf_mode ) ) != IVAS_ERR_OK )
{
return error;
}
}
}
- if ( hCPE->element_mode == IVAS_CPE_MDCT && st_ivas->hMCT == NULL )
+ test();
+ IF( EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) && st_ivas->hMCT == NULL )
{
/* set coded BW for MDCT stereo */
set_bw_stereo_fx( hCPE );
/* reconfiguration of MDCT stereo */
- if ( sts[0]->bwidth != sts[0]->last_bwidth || ( ( hCPE->last_element_brate != hCPE->element_brate || hCPE->last_element_mode != hCPE->element_mode ) && sts[0]->bwidth != sts[0]->max_bwidth ) )
+ test();
+ test();
+ test();
+ IF( sts[0]->bwidth != sts[0]->last_bwidth || ( ( hCPE->last_element_brate != hCPE->element_brate || hCPE->last_element_mode != hCPE->element_mode ) && sts[0]->bwidth != sts[0]->max_bwidth ) )
{
initMdctStereoEncData_fx( hCPE->hStereoMdct, ivas_format, hCPE->element_mode, hCPE->element_brate, sts[0]->bwidth, 0, NULL, 0 );
- hCPE->hStereoMdct->isSBAStereoMode = ( ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) && ( st_ivas->nchan_transport == 2 ) );
- if ( hCPE->element_brate <= MAX_MDCT_ITD_BRATE && ivas_format == STEREO_FORMAT )
+ test();
+ test();
+ test();
+ hCPE->hStereoMdct->isSBAStereoMode = ( ( EQ_16( ivas_format, SBA_FORMAT ) || EQ_16( ivas_format, SBA_ISM_FORMAT ) ) && ( EQ_16( st_ivas->nchan_transport, 2 ) ) ); /* Q0 */
+
+ test();
+ IF( LE_32( hCPE->element_brate, MAX_MDCT_ITD_BRATE ) && EQ_16( ivas_format, STEREO_FORMAT ) )
{
- IF( NE_32( ( error = initMdctItdHandling_fx( hCPE->hStereoMdct, input_Fs ) ), IVAS_ERR_OK ) )
+ IF( ( error = initMdctItdHandling_fx( hCPE->hStereoMdct, input_Fs ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -910,20 +1044,24 @@ ivas_error ivas_cpe_enc_fx(
}
/* set ACELP@12k8 / ACELP@16k flag for flexible ACELP core */
- for ( n = 0; n < n_CoreChannels; n++ )
+ FOR( n = 0; n < n_CoreChannels; n++ )
{
- if ( ( sts[0]->core_brate == SID_2k40 || sts[0]->core_brate == FRAME_NO_DATA ) && hCPE->element_mode == IVAS_CPE_DFT )
+ test();
+ test();
+ IF( ( EQ_32( sts[0]->core_brate, SID_2k40 ) || sts[0]->core_brate == FRAME_NO_DATA ) && EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) )
{
- sts[n]->flag_ACELP16k = set_ACELP_flag_IVAS( hCPE->element_mode, hCPE->element_brate, sts[n]->core_brate, n, sts[0]->tdm_LRTD_flag, sts[n]->bwidth, sts[n]->cng_type );
+ sts[n]->flag_ACELP16k = set_ACELP_flag_IVAS( hCPE->element_mode, hCPE->element_brate, sts[n]->core_brate, n, sts[0]->tdm_LRTD_flag, sts[n]->bwidth, sts[n]->cng_type ); /* Q0 */
+ move16();
}
- else
+ ELSE
{
- sts[n]->flag_ACELP16k = set_ACELP_flag_IVAS( hCPE->element_mode, hCPE->element_brate, sts[n]->total_brate, n, sts[0]->tdm_LRTD_flag, sts[n]->bwidth, sts[n]->cng_type );
+ sts[n]->flag_ACELP16k = set_ACELP_flag_IVAS( hCPE->element_mode, hCPE->element_brate, sts[n]->total_brate, n, sts[0]->tdm_LRTD_flag, sts[n]->bwidth, sts[n]->cng_type ); /* Q0 */
+ move16();
}
}
/* configure TD stereo encoder */
- if ( hCPE->element_mode == IVAS_CPE_TD )
+ IF( EQ_16( hCPE->element_mode, IVAS_CPE_TD ) )
{
tdm_ol_pitch_comparison_fx( hCPE, pitch_fr_fx, voicing_fr_fx );
tdm_configure_enc_fx( ivas_format, st_ivas->ism_mode, hCPE, Etot_last_fx, tdm_SM_or_LRTD_Pri, tdm_ratio_idx, tdm_ratio_idx_SM, attack_flag[0], nb_bits_metadata );
@@ -967,7 +1105,7 @@ ivas_error ivas_cpe_enc_fx(
IF( hEncoderConfig->Opt_DTX_ON )
{
test();
- IF( EQ_32( sts[0]->core_brate, SID_2k40 ) || EQ_32( sts[0]->core_brate, FRAME_NO_DATA ) )
+ IF( EQ_32( sts[0]->core_brate, SID_2k40 ) || sts[0]->core_brate == FRAME_NO_DATA )
{
/* Reconfigure DFT Stereo for inactive frames */
IF( EQ_32( sts[0]->core_brate, SID_2k40 ) )
@@ -988,7 +1126,7 @@ ivas_error ivas_cpe_enc_fx(
}
/* Write stereo bitstream */
- cpe_brate = st_ivas->hCPE[0]->element_brate;
+ cpe_brate = st_ivas->hCPE[0]->element_brate; /* Q0 */
move16();
/* DFT stereo side bits */
@@ -999,14 +1137,14 @@ ivas_error ivas_cpe_enc_fx(
test();
test();
test();
- IF( ( EQ_16( ivas_format, MASA_FORMAT ) || EQ_16( ivas_format, MASA_ISM_FORMAT ) ) && LT_32( cpe_brate, MASA_STEREO_MIN_BITRATE ) && NE_32( sts[0]->core_brate, SID_2k40 ) && NE_32( sts[0]->core_brate, FRAME_NO_DATA ) )
+ IF( ( EQ_16( ivas_format, MASA_FORMAT ) || EQ_16( ivas_format, MASA_ISM_FORMAT ) ) && LT_32( cpe_brate, MASA_STEREO_MIN_BITRATE ) && NE_32( sts[0]->core_brate, SID_2k40 ) && sts[0]->core_brate != FRAME_NO_DATA )
{
nb_bits = 0; /* Only mono downmix is transmitted in this case */
move16();
}
- ELSE IF( ( EQ_16( ivas_format, MASA_FORMAT ) || EQ_16( ivas_format, MASA_ISM_FORMAT ) ) && ( EQ_32( sts[0]->core_brate, SID_2k40 ) || EQ_32( sts[0]->core_brate, FRAME_NO_DATA ) ) )
+ ELSE 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 ) )
{
- nb_bits = hCPE->hMetaData->nb_bits_tot;
+ nb_bits = hCPE->hMetaData->nb_bits_tot; /* Q0 */
move16();
}
ELSE
@@ -1015,44 +1153,51 @@ ivas_error ivas_cpe_enc_fx(
}
/* Residual coding in MDCT domain */
- if ( !( ( ivas_format == MASA_FORMAT || ivas_format == MASA_ISM_FORMAT ) && ( sts[0]->core_brate == SID_2k40 || sts[0]->core_brate == FRAME_NO_DATA ) ) )
+ test();
+ 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 ) ) )
{
- int16_t max_bits = (int16_t) ( hCPE->element_brate / FRAMES_PER_SEC - 0.8f * sts[0]->bits_frame_nominal );
- if ( ivas_format == MASA_FORMAT || ivas_format == MASA_ISM_FORMAT )
+ 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 ) )
{
- max_bits -= nb_bits_metadata;
- if ( hCPE->brate_surplus < 0 )
+ max_bits = sub( max_bits, nb_bits_metadata );
+ IF( hCPE->brate_surplus < 0 )
{
- max_bits += (int16_t) ( hCPE->brate_surplus / FRAMES_PER_SEC );
+ max_bits = add( max_bits, extract_l( Mpy_32_32_r( hCPE->brate_surplus, ONE_BY_FRAMES_PER_SEC_Q31 ) ) );
}
}
-#ifdef IVAS_FLOAT_FIXED_CONVERSIONS
- FOR( int i = 0; i < CPE_CHANNELS; i++ )
+ FOR( Word16 i = 0; i < CPE_CHANNELS; i++ )
{
- Copy_Scale_sig_16_32( old_inp_12k8_16fx[i], old_inp_12k8_fx[i], Q16 + Q1, L_INP_12k8 );
+ Copy_Scale_sig_16_32_no_sat( old_inp_12k8_16fx[i], old_inp_12k8_fx[i], L_INP_12k8, Q16 + Q1 );
}
-#endif
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 );
}
- if ( sts[0]->core_brate == FRAME_NO_DATA || sts[0]->core_brate == SID_2k40 )
+ IF( sts[0]->core_brate == FRAME_NO_DATA || EQ_32( sts[0]->core_brate, SID_2k40 ) )
{
assert( ( nb_bits <= ( ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - SID_FORMAT_NBITS ) ) && "Stereo DFT CNG: bit budget is violated" );
}
- else
+ ELSE
{
/* Flexible total bitrate in M channel */
- sts[0]->total_brate = hCPE->element_brate - ( nb_bits * FRAMES_PER_SEC );
+ sts[0]->total_brate = L_sub( hCPE->element_brate, L_deposit_l( imult1616( nb_bits, FRAMES_PER_SEC ) ) );
+ move32();
}
/* subtract metadata bitbudget */
- sts[0]->total_brate -= ( nb_bits_metadata * FRAMES_PER_SEC );
+ sts[0]->total_brate = L_sub( sts[0]->total_brate, L_deposit_l( imult1616( nb_bits_metadata, FRAMES_PER_SEC ) ) );
+ move32();
/* subtract bit-rate for combined format coding */
- if ( ivas_format == MASA_ISM_FORMAT && ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_DISC ) )
+ test();
+ test();
+ test();
+ if ( EQ_16( ivas_format, MASA_ISM_FORMAT ) && ( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) || EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) || EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) )
{
- sts[0]->total_brate += hCPE->brate_surplus;
+ sts[0]->total_brate = L_add( sts[0]->total_brate, hCPE->brate_surplus );
+ move32();
}
}
@@ -1063,11 +1208,11 @@ ivas_error ivas_cpe_enc_fx(
FOR( n = 0; n < n_CoreChannels; n++ )
{
- Scale_sig( old_wsp_fx[n], L_WSP, sub( e_old_wsp[n], Q16 ) );
+ Scale_sig( old_wsp_fx[n], L_WSP, sub( e_old_wsp[n], Q16 ) ); /* exp(16) */
e_old_wsp[n] = 16;
move16();
}
- IF( NE_32( ( error = ivas_core_enc( NULL, hCPE, st_ivas->hMCT, n_CoreChannels, old_inp_12k8_16fx, old_inp_16k_16fx, 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, tdm_SM_or_LRTD_Pri, ivas_format, 0 ) ), IVAS_ERR_OK ) )
+ IF( NE_32( ( error = ivas_core_enc_fx( NULL, hCPE, st_ivas->hMCT, n_CoreChannels, old_inp_12k8_16fx, old_inp_16k_16fx, 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, tdm_SM_or_LRTD_Pri, ivas_format, 0 ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -1076,48 +1221,57 @@ ivas_error ivas_cpe_enc_fx(
* Common updates
*----------------------------------------------------------------*/
- hCPE->last_element_brate = hCPE->element_brate;
- hCPE->last_element_mode = hCPE->element_mode;
+ hCPE->last_element_brate = hCPE->element_brate; /* Q0 */
+ move32();
+ hCPE->last_element_mode = hCPE->element_mode; /* Q0 */
+ move16();
- if ( ivas_format == MASA_ISM_FORMAT )
+ if ( EQ_16( ivas_format, MASA_ISM_FORMAT ) )
{
- hCPE->element_brate = element_brate_ref;
+ hCPE->element_brate = element_brate_ref; /* Q0 */
+ move32();
}
- if ( hCPE->element_mode == IVAS_CPE_MDCT && hCPE->hStereoMdct != NULL && hCPE->hStereoMdct->hItd != NULL )
+ IF( EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) && hCPE->hStereoMdct != NULL && hCPE->hStereoMdct->hItd != NULL )
{
/* update input samples buffer */
- for ( n = 0; n < CPE_CHANNELS; n++ )
+ FOR( n = 0; n < CPE_CHANNELS; n++ )
{
- Copy( orig_input_fx[n], sts[n]->old_input_signal_fx, input_frame );
- sts[n]->q_old_inp = sts[n]->q_inp;
+ Copy( orig_input_fx[n], sts[n]->old_input_signal_fx, input_frame ); /* Q_orig_inp */
+ sts[n]->q_old_inp = Q_orig_inp[n];
+ move16();
}
}
- else if ( hCPE->element_mode == IVAS_CPE_DFT )
+ ELSE IF( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) )
{
- Copy( sts[0]->input_fx, sts[0]->old_input_signal_fx, input_frame );
+ Copy( sts[0]->input_fx, sts[0]->old_input_signal_fx, input_frame ); /* sts[n]->q_inp */
sts[0]->q_old_inp = sts[0]->q_inp;
+ move16();
}
- else if ( st_ivas->hMCT == NULL ) /* note: in MCT, input buffers are updated later in ivas_mct_enc() */
+ ELSE IF( st_ivas->hMCT == NULL ) /* note: in MCT, input buffers are updated later in ivas_mct_enc() */
{
/* update input samples buffer */
- for ( n = 0; n < CPE_CHANNELS; n++ )
+ FOR( n = 0; n < CPE_CHANNELS; n++ )
{
- Copy( sts[n]->input_fx, sts[n]->old_input_signal_fx, input_frame );
+ Copy( sts[n]->input_fx, sts[n]->old_input_signal_fx, input_frame ); /* sts[n]->q_inp */
sts[n]->q_old_inp = sts[n]->q_inp;
+ move16();
}
}
- if ( hCPE->hFrontVad[0] != NULL )
+ IF( hCPE->hFrontVad[0] != NULL )
{
- hCPE->hFrontVad[0]->ini_frame++;
- hCPE->hFrontVad[0]->ini_frame = min( hCPE->hFrontVad[0]->ini_frame, MAX_FRAME_COUNTER );
+ hCPE->hFrontVad[0]->ini_frame = add( hCPE->hFrontVad[0]->ini_frame, 1 );
+ hCPE->hFrontVad[0]->ini_frame = s_min( hCPE->hFrontVad[0]->ini_frame, MAX_FRAME_COUNTER );
+ move16();
+ move16();
}
/* Store previous attack detection flag */
- for ( n = 0; n < CPE_CHANNELS; n++ )
+ FOR( n = 0; n < CPE_CHANNELS; n++ )
{
- sts[n]->hTranDet->transientDetector.prev_bIsAttackPresent = sts[n]->hTranDet->transientDetector.bIsAttackPresent;
+ sts[n]->hTranDet->transientDetector.prev_bIsAttackPresent = sts[n]->hTranDet->transientDetector.bIsAttackPresent; /* Q0 */
+ move16();
}
IF( Q_new_out )
@@ -1144,8 +1298,8 @@ ivas_error ivas_cpe_enc_fx(
*-------------------------------------------------------------------------*/
ivas_error create_cpe_enc_fx(
Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */
- const Word16 cpe_id, /* i : CPE # identifier */
- const Word32 element_brate /* i : element bitrate */
+ const Word16 cpe_id, /* i : CPE # identifier Q0*/
+ const Word32 element_brate /* i : element bitrate Q0*/
)
{
Word16 n;
@@ -1162,11 +1316,11 @@ ivas_error create_cpe_enc_fx(
ivas_format = hEncoderConfig->ivas_format;
move16();
- element_mode_init = hEncoderConfig->element_mode_init;
+ element_mode_init = hEncoderConfig->element_mode_init; /* Q0 */
move16();
- input_Fs = hEncoderConfig->input_Fs;
+ input_Fs = hEncoderConfig->input_Fs; /* Q0 */
move16();
- max_bwidth = hEncoderConfig->max_bwidth;
+ max_bwidth = hEncoderConfig->max_bwidth; /* Q0 */
move16();
/*-----------------------------------------------------------------*
@@ -1182,15 +1336,15 @@ ivas_error create_cpe_enc_fx(
* Initialization - general parameters
*-----------------------------------------------------------------*/
- hCPE->cpe_id = cpe_id;
+ hCPE->cpe_id = cpe_id; /* Q0 */
move16();
- hCPE->element_brate = element_brate;
+ hCPE->element_brate = element_brate; /* Q0 */
move16();
- hCPE->last_element_brate = hCPE->element_brate;
+ hCPE->last_element_brate = hCPE->element_brate; /* Q0 */
move16();
- hCPE->element_mode = element_mode_init;
+ hCPE->element_mode = element_mode_init; /* Q0 */
move16();
- hCPE->last_element_mode = element_mode_init;
+ hCPE->last_element_mode = element_mode_init; /* Q0 */
move16();
hCPE->hStereoDft = NULL;
@@ -1251,7 +1405,7 @@ ivas_error create_cpe_enc_fx(
IF( EQ_16( cpe_id, sub( st_ivas->nCPE, 1 ) ) )
{
- IF( NE_32( ( error = ivas_initialize_MD_bstr_enc( &( hCPE->hMetaData ), st_ivas ) ), IVAS_ERR_OK ) )
+ IF( NE_32( ( error = ivas_initialize_MD_bstr_enc_fx( &( hCPE->hMetaData ), st_ivas ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -1272,12 +1426,12 @@ ivas_error create_cpe_enc_fx(
IF( GT_16( st_ivas->nCPE, 1 ) )
{
- st->total_brate = hCPE->element_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */
+ st->total_brate = hCPE->element_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() Q0*/
move32();
}
ELSE
{
- st->total_brate = L_shr( hCPE->element_brate, 1 ); /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */
+ st->total_brate = L_shr( hCPE->element_brate, 1 ); /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() Q0*/
move32();
}
st->mct_chan_mode = MCT_CHAN_MODE_REGULAR;
@@ -1289,7 +1443,8 @@ ivas_error create_cpe_enc_fx(
IF( st->hFdCngEnc != NULL )
{
- st->hFdCngEnc->hFdCngCom->CngBitrate = L_sub( hCPE->element_brate, 1 );
+ st->hFdCngEnc->hFdCngCom->CngBitrate = L_sub( hCPE->element_brate, 1 ); /* Q0 */
+ move32();
}
hCPE->hCoreCoder[n] = st;
@@ -1325,7 +1480,7 @@ ivas_error create_cpe_enc_fx(
{
FOR( n = 0; n < CPE_CHANNELS; n++ )
{
- IF( NE_32( ( error = front_vad_create_fx( &( hCPE->hFrontVad[n] ), hEncoderConfig ) ), IVAS_ERR_OK ) )
+ IF( ( error = front_vad_create_fx( &( hCPE->hFrontVad[n] ), hEncoderConfig ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -1345,7 +1500,7 @@ ivas_error create_cpe_enc_fx(
IF( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) )
{
- IF( NE_32( ( error = stereo_dft_enc_create_fx( &( hCPE->hStereoDft ), input_Fs, max_bwidth ) ), IVAS_ERR_OK ) )
+ IF( ( error = stereo_dft_enc_create_fx( &( hCPE->hStereoDft ), input_Fs, max_bwidth ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -1385,7 +1540,7 @@ ivas_error create_cpe_enc_fx(
IF( EQ_16( hCPE->element_mode, IVAS_CPE_TD ) )
{
- if ( ( hCPE->hStereoTD = (STEREO_TD_ENC_DATA_HANDLE) malloc( sizeof( STEREO_TD_ENC_DATA ) ) ) == NULL )
+ IF( ( hCPE->hStereoTD = (STEREO_TD_ENC_DATA_HANDLE) malloc( sizeof( STEREO_TD_ENC_DATA ) ) ) == NULL )
{
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD Stereo\n" ) );
}
@@ -1396,6 +1551,7 @@ ivas_error create_cpe_enc_fx(
* MDCT stereo initialization
*-----------------------------------------------------------------*/
+ test();
IF( EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) && EQ_16( st_ivas->nCPE, 1 ) )
{
IF( ( hCPE->hStereoMdct = (STEREO_MDCT_ENC_DATA_HANDLE) malloc( sizeof( STEREO_MDCT_ENC_DATA ) ) ) == NULL )
@@ -1422,12 +1578,17 @@ ivas_error create_cpe_enc_fx(
#endif
initMdctStereoEncData_fx( hCPE->hStereoMdct, ivas_format, hCPE->element_mode, hCPE->element_brate, max_bwidth, 0, NULL, 1 );
+
+ test();
+ test();
hCPE->hStereoMdct->isSBAStereoMode = ( ( EQ_16( ivas_format, SBA_FORMAT ) || EQ_16( ivas_format, SBA_ISM_FORMAT ) ) && EQ_16( st_ivas->nchan_transport, 2 ) );
+ move16();
+
test();
test();
IF( EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) && LE_32( element_brate, MAX_MDCT_ITD_BRATE ) && EQ_16( ivas_format, STEREO_FORMAT ) )
{
- IF( NE_32( ( error = initMdctItdHandling_fx( hCPE->hStereoMdct, input_Fs ) ), IVAS_ERR_OK ) )
+ IF( ( error = initMdctItdHandling_fx( hCPE->hStereoMdct, input_Fs ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -1466,7 +1627,7 @@ void destroy_cpe_enc(
}
}
- ivas_destroy_MD_bstr_enc( &( hCPE->hMetaData ) );
+ ivas_destroy_MD_bstr_enc_fx( &( hCPE->hMetaData ) );
FOR( n = 0; n < CPE_CHANNELS; n++ )
{
@@ -1548,7 +1709,7 @@ static void stereo_mode_combined_format_enc_fx(
IF( EQ_16( hEncoderConfig->ivas_format, MASA_ISM_FORMAT ) )
{
- element_brate_ref = hCPE->element_brate;
+ element_brate_ref = hCPE->element_brate; /* Q0 */
move32();
test();
@@ -1566,9 +1727,9 @@ static void stereo_mode_combined_format_enc_fx(
}
ELSE
{
- st_ivas->hMasa->data.hOmasaData->omasa_stereo_sw_cnt = add( st_ivas->hMasa->data.hOmasaData->omasa_stereo_sw_cnt, 1 );
+ st_ivas->hMasa->data.hOmasaData->omasa_stereo_sw_cnt = add( st_ivas->hMasa->data.hOmasaData->omasa_stereo_sw_cnt, 1 ); /* Q0 */
move16();
- st_ivas->hMasa->data.hOmasaData->omasa_stereo_sw_cnt = s_min( st_ivas->hMasa->data.hOmasaData->omasa_stereo_sw_cnt, OMASA_STEREO_SW_CNT_MAX );
+ st_ivas->hMasa->data.hOmasaData->omasa_stereo_sw_cnt = s_min( st_ivas->hMasa->data.hOmasaData->omasa_stereo_sw_cnt, OMASA_STEREO_SW_CNT_MAX ); /* Q0 */
move16();
}
@@ -1578,7 +1739,7 @@ static void stereo_mode_combined_format_enc_fx(
move16();
hCPE->element_brate = IVAS_64k;
move32();
- hCPE->brate_surplus = L_sub( hCPE->brate_surplus, L_sub( hCPE->element_brate, element_brate_ref ) );
+ hCPE->brate_surplus = L_sub( hCPE->brate_surplus, L_sub( hCPE->element_brate, element_brate_ref ) ); /* Q0 */
move32();
}
@@ -1593,6 +1754,5 @@ static void stereo_mode_combined_format_enc_fx(
}
}
}
-
return;
}
diff --git a/lib_enc/ivas_decision_matrix_enc.c b/lib_enc/ivas_decision_matrix_enc.c
index 84939b6024d105b136501dddd94932b742ef7c7d..27da713240e155b7c669d1173e8d51f64eab6653 100644
--- a/lib_enc/ivas_decision_matrix_enc.c
+++ b/lib_enc/ivas_decision_matrix_enc.c
@@ -74,11 +74,11 @@
void ivas_decision_matrix_enc_fx(
Encoder_State *st, /* i : encoder state structure */
- const Word32 element_brate, /* i : element bitrate */
- const Word16 fft_buff[], /* i : FFT buffer */
- const Word32 enerBuffer[], /* i : energy buffer */
+ const Word32 element_brate, /* i : element bitrate Q0*/
+ const Word16 fft_buff[], /* i : FFT buffer Qx*/
+ const Word32 enerBuffer[], /* i : energy buffer enerBuffer_exp*/
Word16 enerBuffer_exp,
- const Word16 last_element_mode /* i : last element mode */
+ const Word16 last_element_mode /* i : last element mode Q0*/
)
{
Word32 icbwe_brate;
@@ -96,7 +96,7 @@ void ivas_decision_matrix_enc_fx(
st->extl_brate = 0;
move16();
- IF( NE_16( st->element_mode, IVAS_CPE_MDCT ) )
+ if ( NE_16( st->element_mode, IVAS_CPE_MDCT ) )
{
st->igf = 0;
move16();
@@ -106,13 +106,13 @@ void ivas_decision_matrix_enc_fx(
test();
/* SID and FRAME_NO_DATA frames */
- IF( st->Opt_DTX_ON && ( EQ_32( st->core_brate, SID_2k40 ) || EQ_32( st->core_brate, FRAME_NO_DATA ) ) )
+ IF( st->Opt_DTX_ON && ( EQ_32( st->core_brate, SID_2k40 ) || st->core_brate == FRAME_NO_DATA ) )
{
st->core = ACELP_CORE;
move16();
test();
- IF( GE_32( st->input_Fs, 32000 ) || GE_16( st->bwidth, SWB ) )
+ if ( GE_32( st->input_Fs, 32000 ) || GE_16( st->bwidth, SWB ) )
{
st->extl = SWB_CNG;
move16();
@@ -195,7 +195,7 @@ void ivas_decision_matrix_enc_fx(
ELSE
{
/* select TCX core or HQ core using bits_frame_nominal to match the TCX configuration bitrate */
- st->core = mdct_classifier_ivas_fx( st, fft_buff, enerBuffer, enerBuffer_exp, ( st->bits_frame_nominal * FRAMES_PER_SEC ) );
+ st->core = mdct_classifier_ivas_fx( st, fft_buff, enerBuffer, enerBuffer_exp, L_mult0( st->bits_frame_nominal, FRAMES_PER_SEC ) ); /* Q0 */
move16();
}
}
@@ -208,14 +208,14 @@ void ivas_decision_matrix_enc_fx(
test();
/* do not allow TD stereo ACELP core -> DFT stereo TCX core switching as it is on the WC complexity path */
- IF( ( ( EQ_16( st->last_core, ACELP_CORE ) && EQ_16( last_element_mode, IVAS_CPE_TD ) && EQ_16( st->element_mode, IVAS_CPE_DFT ) ) || ( EQ_16( st->tdm_LRTD_flag, 1 ) && LE_32( st->total_brate, IVAS_16k4 ) ) ) && EQ_16( st->core, TCX_20_CORE ) && LE_32( st->total_brate, MAX_ACELP_BRATE ) ) /* Override TCX in case of LRTD && primary channel has low bitrate*/
+ if ( ( ( st->last_core == ACELP_CORE && EQ_16( last_element_mode, IVAS_CPE_TD ) && EQ_16( st->element_mode, IVAS_CPE_DFT ) ) || ( EQ_16( st->tdm_LRTD_flag, 1 ) && LE_32( st->total_brate, IVAS_16k4 ) ) ) && EQ_16( st->core, TCX_20_CORE ) && LE_32( st->total_brate, MAX_ACELP_BRATE ) ) /* Override TCX in case of LRTD && primary channel has low bitrate*/
{
st->core = ACELP_CORE;
move16();
}
test();
- IF( st->is_ism_format && st->tcxonly )
+ if ( st->is_ism_format && st->tcxonly )
{
st->core = TCX_20_CORE;
move16();
@@ -244,10 +244,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;
@@ -276,7 +283,7 @@ void ivas_decision_matrix_enc_fx(
move16();
move16();
- IF( st->low_rate_mode )
+ if ( st->low_rate_mode )
{
st->coder_type = INACTIVE;
move16();
@@ -288,7 +295,7 @@ void ivas_decision_matrix_enc_fx(
test();
test();
test();
- IF( st->is_ism_format && st->flag_ACELP16k && !st->low_rate_mode && EQ_16( st->core, ACELP_CORE ) && LT_32( st->total_brate, add( ACELP_16k_LOW_LIMIT, FB_TBE_1k8 ) ) )
+ if ( st->is_ism_format && st->flag_ACELP16k && !st->low_rate_mode && st->core == ACELP_CORE && LT_32( st->total_brate, add( ACELP_16k_LOW_LIMIT, FB_TBE_1k8 ) ) )
{
st->core = TCX_20_CORE;
move16();
@@ -298,15 +305,15 @@ void ivas_decision_matrix_enc_fx(
* Select ACELP and GSC extension layer
*---------------------------------------------------------------------*/
- IF( EQ_16( st->core, ACELP_CORE ) )
+ IF( st->core == ACELP_CORE )
{
/* WB */
+ test();
IF( EQ_16( st->bwidth, WB ) )
{
test();
test();
test();
- test();
IF( LT_32( st->total_brate, MIN_BRATE_WB_BWE ) || ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) ) )
{
st->extl = WB_BWE;
@@ -316,7 +323,7 @@ void ivas_decision_matrix_enc_fx(
{
test();
test();
- IF( ( EQ_16( st->sp_aud_decision1, 1 ) && st->sp_aud_decision2 == 0 ) || EQ_16( st->coder_type, INACTIVE ) )
+ IF( ( EQ_16( st->sp_aud_decision1, 1 ) && st->sp_aud_decision2 == 0 ) || st->coder_type == INACTIVE )
{
st->extl = WB_BWE;
move16();
@@ -361,7 +368,7 @@ void ivas_decision_matrix_enc_fx(
test();
test();
test();
- IF( ( ( ( EQ_16( st->sp_aud_decision1, 1 ) && st->sp_aud_decision2 == 0 ) || EQ_16( st->coder_type, INACTIVE ) ) && !st->GSC_noisy_speech ) /* Note: SWB BWE is not used for GSC noisy speech */ )
+ IF( ( ( ( EQ_16( st->sp_aud_decision1, 1 ) && st->sp_aud_decision2 == 0 ) || st->coder_type == INACTIVE ) && !st->GSC_noisy_speech ) /* Note: SWB BWE is not used for GSC noisy speech */ )
{
st->extl = SWB_BWE;
move16();
@@ -423,7 +430,7 @@ void ivas_decision_matrix_enc_fx(
test();
test();
- IF( GE_32( st->total_brate, MIN_BRATE_SWB_TBE_2k80 ) && st->flag_ACELP16k && EQ_16( st->element_mode, IVAS_SCE ) )
+ if ( GE_32( st->total_brate, MIN_BRATE_SWB_TBE_2k80 ) && st->flag_ACELP16k && EQ_16( st->element_mode, IVAS_SCE ) )
{
st->extl_brate = FB_TBE_3k0;
move32();
@@ -448,7 +455,7 @@ void ivas_decision_matrix_enc_fx(
icbwe_brate = STEREO_BITS_ICBWE * FRAMES_PER_SEC;
move32();
- IF( st->flag_ACELP16k == 0 )
+ if ( st->flag_ACELP16k == 0 )
{
icbwe_brate = ( STEREO_BITS_ICBWE - STEREO_ICBWE_SPBITS ) * FRAMES_PER_SEC;
move32();
@@ -459,7 +466,7 @@ void ivas_decision_matrix_enc_fx(
icbwe_brate = STEREO_BITS_ICBWE_DFT * FRAMES_PER_SEC;
move32();
- IF( st->flag_ACELP16k == 0 )
+ if ( st->flag_ACELP16k == 0 )
{
icbwe_brate = ( STEREO_BITS_ICBWE_DFT - STEREO_ICBWE_SPBITS ) * FRAMES_PER_SEC;
move32();
@@ -471,9 +478,9 @@ void ivas_decision_matrix_enc_fx(
test();
test();
test();
- if ( GE_16( st->element_mode, IVAS_CPE_DFT ) && EQ_16( st->core, ACELP_CORE ) && ( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, FB_TBE ) ) && !( EQ_16( st->element_mode, IVAS_CPE_TD ) && st->tdm_LRTD_flag ) )
+ if ( GE_16( st->element_mode, IVAS_CPE_DFT ) && st->core == ACELP_CORE && ( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, FB_TBE ) ) && !( EQ_16( st->element_mode, IVAS_CPE_TD ) && st->tdm_LRTD_flag ) )
{
- icbwe_brate = L_add( icbwe_brate, STEREO_ICBWE_MSFLAG_BITS * FRAMES_PER_SEC );
+ icbwe_brate = L_add( icbwe_brate, STEREO_ICBWE_MSFLAG_BITS * FRAMES_PER_SEC ); /* Q0 */
move32();
}
}
@@ -481,19 +488,19 @@ void ivas_decision_matrix_enc_fx(
/* set core bitrate */
- st->core_brate = L_sub( L_sub( st->total_brate, st->extl_brate ), icbwe_brate );
+ st->core_brate = L_sub( L_sub( st->total_brate, st->extl_brate ), icbwe_brate ); /* Q0 */
move32();
IF( st->ini_frame == 0 )
{
/* avoid core switching in the very first frame */
- st->last_core = st->core;
+ st->last_core = st->core; /* Q0 */
move16();
- st->last_core_brate = st->core_brate;
+ st->last_core_brate = st->core_brate; /* Q0 */
move32();
- st->last_extl = st->extl;
+ st->last_extl = st->extl; /* Q0 */
move16();
}
@@ -504,7 +511,7 @@ void ivas_decision_matrix_enc_fx(
st->inactive_coder_type_flag = 0; /* AVQ by default */
move16();
- IF( LE_32( st->total_brate, MAX_GSC_INACTIVE_BRATE ) )
+ if ( LE_32( st->total_brate, MAX_GSC_INACTIVE_BRATE ) )
{
st->inactive_coder_type_flag = 1; /* GSC */
move16();
@@ -520,11 +527,11 @@ void ivas_decision_matrix_enc_fx(
*---------------------------------------------------------------------*/
void ivas_signaling_enc_fx(
- Encoder_State *st, /* i/o: encoder state structure */
- const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) */
- const Word32 element_brate, /* i : element bitrate */
- const Word16 tdm_SM_or_LRTD_Pri, /* i : channel combination scheme flag in TD stereo OR LRTD primary channel */
- const Word16 tdm_Pitch_reuse_flag /* i : primary channel pitch reuse flag in TD stereo */
+ Encoder_State *st, /* i/o: encoder state structure */
+ const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/
+ const Word32 element_brate, /* i : element bitrate Q0*/
+ const Word16 tdm_SM_or_LRTD_Pri, /* i : channel combination scheme flag in TD stereo OR LRTD primary channel Q0*/
+ const Word16 tdm_Pitch_reuse_flag /* i : primary channel pitch reuse flag in TD stereo Q0*/
)
{
Word16 ind;
@@ -559,7 +566,7 @@ void ivas_signaling_enc_fx(
test();
IF( ( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) && !MCT_flag ) /* note: in MCT, the MDCT stereo is used exclusively */
{
- ind = sub( st->element_mode, IVAS_CPE_DFT );
+ ind = sub( st->element_mode, IVAS_CPE_DFT ); /* Q0 */
push_indice( hBstr, IND_SMODE, ind, NBITS_ELEMENT_MODE );
}
@@ -579,7 +586,7 @@ void ivas_signaling_enc_fx(
( LT_32( element_brate, MIN_BRATE_FB_ISM ) && st->is_ism_format ) )
{
/* WB and SWB are supported */
- ind = sub( st->bwidth, WB );
+ ind = sub( st->bwidth, WB ); /* Q0 */
push_indice( hBstr, IND_BWIDTH, ind, 1 );
}
ELSE
@@ -597,7 +604,7 @@ void ivas_signaling_enc_fx(
test();
IF( EQ_16( st->element_mode, IVAS_CPE_TD ) || GE_32( st->total_brate, STEREO_TCX_MIN_RATE ) )
{
- IF( EQ_16( st->core, ACELP_CORE ) )
+ IF( st->core == ACELP_CORE )
{
push_indice( hBstr, IND_CORE, 0, 1 );
}
@@ -611,7 +618,7 @@ void ivas_signaling_enc_fx(
* Write core dependent signaling
*--------------------------------------------------------------------------*/
- IF( EQ_16( st->core, ACELP_CORE ) )
+ IF( st->core == ACELP_CORE )
{
/* write coder type */
push_indice( hBstr, IND_ACELP_SIGNALLING, st->coder_type, 3 );
diff --git a/lib_enc/ivas_dirac_enc.c b/lib_enc/ivas_dirac_enc.c
index 51a446d383139b0704527c62aaa3ca7bbc170f4a..017aa2904815a042a5e6b6452151b9ac661b390a 100644
--- a/lib_enc/ivas_dirac_enc.c
+++ b/lib_enc/ivas_dirac_enc.c
@@ -53,7 +53,13 @@ static void computeIntensityVector_enc_fx(
Word32 Cldfb_ImagBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX],
const Word16 enc_param_start_band, /* i : first band to process */
const Word16 num_frequency_bands,
- Word32 intensity_real[DIRAC_NUM_DIMS][DIRAC_MAX_NBANDS] );
+ Word32 intensity_real[DIRAC_NUM_DIMS][DIRAC_MAX_NBANDS]
+#ifdef NONBE_IMPROVE_DIRAC_INTENSITY_PREC
+ ,
+ Word16 q_cldfb,
+ Word16 q_intensity_real[DIRAC_MAX_NBANDS]
+#endif
+);
/*-------------------------------------------------------------------------
* ivas_dirac_enc_open()
@@ -82,7 +88,7 @@ ivas_error ivas_dirac_enc_open_fx(
{
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC Config\n" ) );
}
- hDirAC->firstrun_sector_params = 1;
+ hDirAC->firstrun_sector_params = 1; /* Q0 */
move16();
set32_fx( hDirAC->sec_I_vec_smth_x_fx[0], 0, NUM_ANA_SECTORS * IVAS_MAX_NUM_BANDS );
@@ -101,7 +107,7 @@ ivas_error ivas_dirac_enc_open_fx(
st_ivas->hDirAC = hDirAC;
- IF( NE_32( ( error = ivas_dirac_config_fx( (void *) st_ivas, ENC ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_dirac_config_fx( (void *) st_ivas, ENC ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -112,7 +118,7 @@ ivas_error ivas_dirac_enc_open_fx(
FOR( i = 0; i < DIRAC_MAX_NBANDS + 1; i++ )
{
/* adapt band grouping to from CLDFB to MDFT bands */
- hDirAC->band_grouping[i] = imult1616( hDirAC->band_grouping[i], CLDFB_TO_MDFT_FAC );
+ hDirAC->band_grouping[i] = imult1616( hDirAC->band_grouping[i], CLDFB_TO_MDFT_FAC ); /* Q0 */
move16();
}
dirac_slot_ns = DIRAC_SLOT_ENC_NS;
@@ -139,7 +145,7 @@ ivas_error ivas_dirac_enc_open_fx(
Word16 tmp_e = 0;
move16();
- Word16 tmp = BASOP_Util_Divide3232_Scale( (Word32) DIRAC_NO_COL_AVG_DIFF_NS, dirac_slot_ns, &tmp_e );
+ Word16 tmp = BASOP_Util_Divide3232_Scale( (Word32) DIRAC_NO_COL_AVG_DIFF_NS, dirac_slot_ns, &tmp_e ); /* exp(tmp_e) */
hDirAC->no_col_avg_diff = shr( tmp, sub( 15, tmp_e ) );
move16();
@@ -188,7 +194,7 @@ ivas_error ivas_dirac_enc_open_fx(
move16();
st_ivas->hDirAC = hDirAC;
- st_ivas->hSpar->enc_param_start_band = st_ivas->hDirAC->hConfig->enc_param_start_band;
+ st_ivas->hSpar->enc_param_start_band = st_ivas->hDirAC->hConfig->enc_param_start_band; /* Q0 */
move16();
return error;
@@ -245,7 +251,7 @@ ivas_error ivas_dirac_enc_reconfigure(
*------------------------------------------------------------------------*/
void ivas_dirac_enc_close_fx(
DIRAC_ENC_HANDLE *hDirAC_out, /* i/o: encoder DirAC handle */
- const Word32 input_Fs /* i : input sampling rate */
+ const Word32 input_Fs /* i : input sampling rate Q0*/
)
{
Word16 i, j;
@@ -314,15 +320,15 @@ ivas_error ivas_dirac_enc_fx(
DIRAC_ENC_HANDLE hDirAC, /* i/o: encoder DirAC handle */
IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata handle */
BSTR_ENC_HANDLE hMetaData, /* i/o: Metadata bitstream handle */
- Word32 *data_f_fx[], /* i/o: SBA channels Qx */
- Word32 **pp_fr_real_fx, /* o : real freq domain values pp_fr_q */
- Word32 **pp_fr_imag_fx, /* o : imag freq domain values pp_fr_q */
+ Word32 *data_f_fx[], /* i/o: SBA channels Qx*/
+ Word32 **pp_fr_real_fx, /* o : real freq domain values pp_fr_q*/
+ Word32 **pp_fr_imag_fx, /* o : imag freq domain values pp_fr_q*/
Word16 pp_fr_q,
- 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 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 shift )
{
Word16 orig_dirac_bands;
Word32 dir_fx[3], avg_dir_fx[3];
@@ -330,14 +336,24 @@ ivas_error ivas_dirac_enc_fx(
ivas_error error;
push_wmops( "ivas_dirac_enc" );
- Word16 nchan_fb_in = hodirac_flag ? HOA2_CHANNELS : FOA_CHANNELS;
- move16();
+ Word16 nchan_fb_in;
+
+ IF( hodirac_flag )
+ {
+ nchan_fb_in = HOA2_CHANNELS;
+ move16();
+ }
+ 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 )
{
- orig_dirac_bands = hQMetaData->q_direction[0].cfg.nbands;
+ orig_dirac_bands = hQMetaData->q_direction[0].cfg.nbands; /* Q0 */
move16();
IF( EQ_16( dtx_vad, 1 ) )
@@ -380,7 +396,7 @@ ivas_error ivas_dirac_enc_fx(
}
}
- IF( NE_32( ( error = ivas_qmetadata_enc_encode_fx( hMetaData, hQMetaData, hodirac_flag ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_qmetadata_enc_encode_fx( hMetaData, hQMetaData, hodirac_flag ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -405,15 +421,15 @@ ivas_error ivas_dirac_enc_fx(
{
ivas_qmetadata_azimuth_elevation_to_direction_vector_fx( hQMetaData->q_direction[0].band_data[j].azimuth_fx[i], hQMetaData->q_direction[0].band_data[j].elevation_fx[i], &dir_fx[0] );
- Word32 vecLen_fx = Mpy_32_32( hQMetaData->q_direction[0].band_data[j].energy_ratio_fx[i] /*Q30*/, hDirAC->buffer_energy_fx[i * orig_dirac_bands + j] );
- avg_dir_fx[0] = L_add( avg_dir_fx[0], Mpy_32_32( dir_fx[0], vecLen_fx ) ); // Q30 + hDirAC->buffer_energy_q[i * orig_dirac_bands + j] - 1 - 31
- avg_dir_fx[1] = L_add( avg_dir_fx[1], Mpy_32_32( dir_fx[1], vecLen_fx ) ); // Q30 + hDirAC->buffer_energy_q[i * orig_dirac_bands + j] - 1 - 31
- avg_dir_fx[2] = L_add( avg_dir_fx[2], Mpy_32_32( dir_fx[2], vecLen_fx ) ); // Q30 + hDirAC->buffer_energy_q[i * orig_dirac_bands + j] - 1 - 31
+ Word32 vecLen_fx = Mpy_32_32( hQMetaData->q_direction[0].band_data[j].energy_ratio_fx[i] /*Q30*/, hDirAC->buffer_energy_fx[i * orig_dirac_bands + j] ); /* hDirAC->buffer_energy_q[i * orig_dirac_bands + j] - 1 */
+ avg_dir_fx[0] = L_add( avg_dir_fx[0], Mpy_32_32( dir_fx[0], vecLen_fx ) ); // Q30 + hDirAC->buffer_energy_q[i * orig_dirac_bands + j] - 1 - 31
+ avg_dir_fx[1] = L_add( avg_dir_fx[1], Mpy_32_32( dir_fx[1], vecLen_fx ) ); // Q30 + hDirAC->buffer_energy_q[i * orig_dirac_bands + j] - 1 - 31
+ avg_dir_fx[2] = L_add( avg_dir_fx[2], Mpy_32_32( dir_fx[2], vecLen_fx ) ); // Q30 + hDirAC->buffer_energy_q[i * orig_dirac_bands + j] - 1 - 31
move32();
move32();
move32();
avg_dir_e = sub( 31, ( sub( add( Q30, hDirAC->buffer_energy_q[i * orig_dirac_bands + j] ), 1 - 31 ) ) );
- energySum_fx = BASOP_Util_Add_Mant32Exp( energySum_fx, energySum_e, hDirAC->buffer_energy_fx[i * orig_dirac_bands + j], sub( 31, hDirAC->buffer_energy_q[i * orig_dirac_bands + j] ), &energySum_e );
+ energySum_fx = BASOP_Util_Add_Mant32Exp( energySum_fx, energySum_e, hDirAC->buffer_energy_fx[i * orig_dirac_bands + j], sub( 31, hDirAC->buffer_energy_q[i * orig_dirac_bands + j] ), &energySum_e ); /* exp(energySum_e) */
}
Word16 x = getScaleFactor32( avg_dir_fx, 3 );
@@ -431,16 +447,16 @@ ivas_error ivas_dirac_enc_fx(
move16();
Word16 denom_e = 0;
move16();
- Word32 denom = BASOP_Util_Add_Mant32Exp( energySum_fx, energySum_e, EPSILON_FX_M, EPSILON_FX_E, &denom_e );
+ Word32 denom = BASOP_Util_Add_Mant32Exp( energySum_fx, energySum_e, EPSILON_FX_M, EPSILON_FX_E, &denom_e ); /* exp(denom_e) */
- er_tmp = BASOP_Util_Divide3232_Scale( tmp, denom, &er_tmp_e );
+ er_tmp = BASOP_Util_Divide3232_Scale( tmp, denom, &er_tmp_e ); /* exp(er_tmp_e) */
er_tmp_e = add( er_tmp_e, sub( tmp_e, denom_e ) );
er_tmp = shr( er_tmp, sub( 1, ( er_tmp_e ) ) ); // Q14
- hQMetaData->q_direction[0].band_data[0].energy_ratio_fx[i] = L_deposit_h( er_tmp ); // Q30
- hQMetaData->q_direction[0].band_data[1].azimuth_fx[i] = hQMetaData->q_direction[0].band_data[orig_dirac_bands - 1].azimuth_fx[i];
- hQMetaData->q_direction[0].band_data[1].elevation_fx[i] = hQMetaData->q_direction[0].band_data[orig_dirac_bands - 1].elevation_fx[i];
- hQMetaData->q_direction[0].band_data[1].energy_ratio_fx[i] = hQMetaData->q_direction[0].band_data[orig_dirac_bands - 1].energy_ratio_fx[i];
+ hQMetaData->q_direction[0].band_data[0].energy_ratio_fx[i] = L_deposit_h( er_tmp ); // Q30
+ hQMetaData->q_direction[0].band_data[1].azimuth_fx[i] = hQMetaData->q_direction[0].band_data[orig_dirac_bands - 1].azimuth_fx[i]; // Q22
+ hQMetaData->q_direction[0].band_data[1].elevation_fx[i] = hQMetaData->q_direction[0].band_data[orig_dirac_bands - 1].elevation_fx[i]; // Q22
+ hQMetaData->q_direction[0].band_data[1].energy_ratio_fx[i] = hQMetaData->q_direction[0].band_data[orig_dirac_bands - 1].energy_ratio_fx[i]; // Q30
move32();
move32();
move32();
@@ -459,19 +475,20 @@ ivas_error ivas_dirac_enc_fx(
IF( EQ_16( dtx_vad, 1 ) )
{
len = hQMetaData->q_direction[0].cfg.nblocks;
+ move16();
}
ELSE
{
len = 1;
+ move16();
}
- move16();
FOR( b = hQMetaData->q_direction->cfg.start_band; b < hQMetaData->q_direction->cfg.nbands; b++ )
{
FOR( i_ts = 0; i_ts < len; i_ts++ )
{
- hQMetaData->q_direction->band_data[b].azimuth_fx[i_ts] = hQMetaData->q_direction->band_data[b].q_azimuth_fx[i_ts];
- hQMetaData->q_direction->band_data[b].elevation_fx[i_ts] = hQMetaData->q_direction->band_data[b].q_elevation_fx[i_ts];
- hQMetaData->q_direction[0].band_data[b].energy_ratio_fx[0] = L_sub( ONE_IN_Q30, diffuseness_reconstructions_fx[hQMetaData->q_direction[0].band_data[b].energy_ratio_index[0]] );
+ hQMetaData->q_direction->band_data[b].azimuth_fx[i_ts] = hQMetaData->q_direction->band_data[b].q_azimuth_fx[i_ts]; // Q22
+ hQMetaData->q_direction->band_data[b].elevation_fx[i_ts] = hQMetaData->q_direction->band_data[b].q_elevation_fx[i_ts]; // Q22
+ hQMetaData->q_direction[0].band_data[b].energy_ratio_fx[0] = L_sub( ONE_IN_Q30, diffuseness_reconstructions_fx[hQMetaData->q_direction[0].band_data[b].energy_ratio_index[0]] ); // Q30
move32();
move32();
move32();
@@ -482,9 +499,9 @@ ivas_error ivas_dirac_enc_fx(
{
FOR( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ )
{
- hQMetaData->q_direction[0].band_data[orig_dirac_bands - 1].azimuth_fx[i] = hQMetaData->q_direction[0].band_data[1].azimuth_fx[0];
- hQMetaData->q_direction[0].band_data[orig_dirac_bands - 1].elevation_fx[i] = hQMetaData->q_direction[0].band_data[1].elevation_fx[0];
- hQMetaData->q_direction[0].band_data[orig_dirac_bands - 1].energy_ratio_fx[i] = hQMetaData->q_direction[0].band_data[1].energy_ratio_fx[0];
+ hQMetaData->q_direction[0].band_data[orig_dirac_bands - 1].azimuth_fx[i] = hQMetaData->q_direction[0].band_data[1].azimuth_fx[0]; // Q22
+ hQMetaData->q_direction[0].band_data[orig_dirac_bands - 1].elevation_fx[i] = hQMetaData->q_direction[0].band_data[1].elevation_fx[0]; // Q22
+ hQMetaData->q_direction[0].band_data[orig_dirac_bands - 1].energy_ratio_fx[i] = hQMetaData->q_direction[0].band_data[1].energy_ratio_fx[0]; // Q30
move32();
move32();
move32();
@@ -494,16 +511,16 @@ ivas_error ivas_dirac_enc_fx(
{
FOR( j = sub( orig_dirac_bands, 2 ); j >= 0; j-- )
{
- hQMetaData->q_direction[0].band_data[j].azimuth_fx[i] = hQMetaData->q_direction[0].band_data[0].azimuth_fx[0];
- hQMetaData->q_direction[0].band_data[j].elevation_fx[i] = hQMetaData->q_direction[0].band_data[0].elevation_fx[0];
- hQMetaData->q_direction[0].band_data[j].energy_ratio_fx[i] = hQMetaData->q_direction[0].band_data[0].energy_ratio_fx[0];
+ hQMetaData->q_direction[0].band_data[j].azimuth_fx[i] = hQMetaData->q_direction[0].band_data[0].azimuth_fx[0]; // Q22
+ hQMetaData->q_direction[0].band_data[j].elevation_fx[i] = hQMetaData->q_direction[0].band_data[0].elevation_fx[0]; // Q22
+ hQMetaData->q_direction[0].band_data[j].energy_ratio_fx[i] = hQMetaData->q_direction[0].band_data[0].energy_ratio_fx[0]; // Q30
move32();
move32();
move32();
}
}
- hQMetaData->q_direction->cfg.nbands = orig_dirac_bands;
+ hQMetaData->q_direction->cfg.nbands = orig_dirac_bands; /* Q0 */
move16();
}
}
@@ -521,12 +538,12 @@ ivas_error ivas_dirac_enc_fx(
*-------------------------------------------------------------------------*/
static Word16 ivas_dirac_get_mono_flag_fx(
- const Word16 *band_grouping, /* i : Band grouping for estimation */
- Word32 Cldfb_RealBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i : Real part of input signal */
- Word32 Cldfb_ImagBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i : Imag part of input signal */
- Word16 e_Cldfb, /* i : Exponent of cldfb buffer */
- const Word16 nchan_ana, /* i : number of analysis channels */
- Word16 *mono_frame_count ) /* i/o: current number of mono frames count */
+ const Word16 *band_grouping, /* i : Band grouping for estimation Q0*/
+ Word32 Cldfb_RealBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i : Real part of input signal e_Cldfb*/
+ Word32 Cldfb_ImagBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i : Imag part of input signal e_Cldfb*/
+ Word16 e_Cldfb, /* i : Exponent of cldfb buffer */
+ const Word16 nchan_ana, /* i : number of analysis channels Q0*/
+ Word16 *mono_frame_count ) /* i/o: current number of mono frames count Q0*/
{
Word16 brange[2];
Word16 i, j, ch_idx;
@@ -554,8 +571,8 @@ static Word16 ivas_dirac_get_mono_flag_fx(
move32();
move32();
- brange[0] = band_grouping[i];
- brange[1] = band_grouping[i + 1];
+ brange[0] = band_grouping[i]; /* Q0 */
+ brange[1] = band_grouping[i + 1]; /* Q0 */
move16();
move16();
@@ -568,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] );
- acc = W_mac_32_32( acc, Cldfb_ImagBuffer[0][j], Cldfb_ImagBuffer[0][j] );
- shift1 = W_norm( acc );
- W_band_power = W_extract_h( W_shl( acc, 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] );
- acc1 = W_mac_32_32( acc1, Cldfb_ImagBuffer[ch_idx][j], Cldfb_ImagBuffer[ch_idx][j] );
- shift2 = W_norm( acc1 );
- other_ch_band_power = W_extract_h( W_shl( acc1, 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 )
@@ -606,7 +627,7 @@ static Word16 ivas_dirac_get_mono_flag_fx(
{
Word16 tmp_div_e = 0;
move16();
- Word16 tmp_div = BASOP_Util_Divide3232_Scale( W_band_power, DIRAC_MONO_NORM_FACTOR_M, &tmp_div_e );
+ Word16 tmp_div = BASOP_Util_Divide3232_Scale( W_band_power, DIRAC_MONO_NORM_FACTOR_M, &tmp_div_e ); /* exp(tmp_div_e) */
tmp_div_e = add( tmp_div_e, sub( W_band_power_e, DIRAC_MONO_NORM_FACTOR_E ) );
Word16 W_band_power_norm_e = 0;
move16();
@@ -681,7 +702,7 @@ static Word16 ivas_dirac_get_mono_flag_fx(
{
IF( LT_16( *mono_frame_count, DIRAC_MONO_FRAME_THRESH ) )
{
- *mono_frame_count = add( *mono_frame_count, 1 );
+ *mono_frame_count = add( *mono_frame_count, 1 ); /* Q0 */
move16();
}
}
@@ -714,18 +735,18 @@ static Word16 ivas_dirac_get_mono_flag_fx(
void computeReferencePower_enc_fx_dirac(
const Word16 *band_grouping, /* i : Band grouping for estimation */
- Word32 Cldfb_RealBuffer[][DIRAC_NO_FB_BANDS_MAX], /* i : Real part of input signal */
- Word32 Cldfb_ImagBuffer[][DIRAC_NO_FB_BANDS_MAX], /* i : Imag part of input signal */
+ Word32 Cldfb_RealBuffer[][DIRAC_NO_FB_BANDS_MAX], /* i : Real part of input signal e_Cldfb*/
+ Word32 Cldfb_ImagBuffer[][DIRAC_NO_FB_BANDS_MAX], /* i : Imag part of input signal e_Cldfb*/
Word16 e_Cldfb, /* i : exponent of Cldfb buffer */
- Word32 *reference_power, /* o : Estimated power */
+ Word32 *reference_power, /* o : Estimated power e_reference*/
Word16 *e_reference, /* o : exponent of reference_power */
- const Word16 enc_param_start_band, /* i : first band to process */
- const Word16 num_freq_bands, /* i : Number of frequency bands */
+ const Word16 enc_param_start_band, /* i : first band to process Q0*/
+ const Word16 num_freq_bands, /* i : Number of frequency bands Q0*/
const IVAS_FORMAT ivas_format, /* i : ivas_format */
- Word16 ref_power_w, /* i : use 0 if hodirac is enabled */
- const Word16 nchan_ana, /* i : number of analysis channels */
- Word16 *mono_frame_count, /* i/o: Mono Frame Count */
- Word16 *dirac_mono_flag /* i/o: Mono Flag */
+ Word16 ref_power_w, /* i : use 0 if hodirac is enabled Q0*/
+ const Word16 nchan_ana, /* i : number of analysis channels Q0*/
+ Word16 *mono_frame_count, /* i/o: Mono Frame Count Q0*/
+ Word16 *dirac_mono_flag /* i/o: Mono Flag Q0*/
)
{
Word16 brange[2];
@@ -739,10 +760,24 @@ void computeReferencePower_enc_fx_dirac(
IF( dirac_mono_flag != NULL )
{
- *dirac_mono_flag = ivas_dirac_get_mono_flag_fx( band_grouping, Cldfb_RealBuffer, Cldfb_ImagBuffer, e_Cldfb, nchan_ana, mono_frame_count );
+ *dirac_mono_flag = ivas_dirac_get_mono_flag_fx( band_grouping, Cldfb_RealBuffer, Cldfb_ImagBuffer, e_Cldfb, nchan_ana, mono_frame_count ); /* Q0 */
move16();
}
-
+#ifdef FIX_1127_IMPROVE_SBA_MLD
+ Word16 gb = 0;
+ move16();
+ FOR( i = 0; i < num_freq_bands; i++ )
+ {
+ brange[0] = band_grouping[i + enc_param_start_band];
+ brange[1] = band_grouping[i + enc_param_start_band + 1];
+ move16();
+ move16();
+ gb = s_max( gb, find_guarded_bits_fx( sub( brange[1], brange[0] ) ) );
+ }
+ e_reference_W = sub( 31, sub( add( shl( sub( 31, e_Cldfb ), 1 ), 1 ), gb ) );
+ e_reference_temp = e_reference_W;
+#endif
+ move16();
FOR( i = 0; i < num_freq_bands; i++ )
{
brange[0] = band_grouping[i + enc_param_start_band];
@@ -758,14 +793,18 @@ void computeReferencePower_enc_fx_dirac(
FOR( j = brange[0]; j < brange[1]; j++ )
{
+#ifdef FIX_1127_IMPROVE_SBA_MLD
+ reference_power_W[i] = W_add( reference_power_W[i], W_shr( W_mult_32_32( Cldfb_RealBuffer[0][j], Cldfb_RealBuffer[0][j] ), gb ) ); /* exp(2 * e_Cldfb) */
+ reference_power_W[i] = W_add( reference_power_W[i], W_shr( W_mult_32_32( Cldfb_ImagBuffer[0][j], Cldfb_ImagBuffer[0][j] ), gb ) ); /* exp(2 * e_Cldfb) */
+#else
reference_power_W[i] = W_mac_32_32( reference_power_W[i], Cldfb_RealBuffer[0][j], Cldfb_RealBuffer[0][j] );
reference_power_W[i] = W_mac_32_32( reference_power_W[i], Cldfb_ImagBuffer[0][j], Cldfb_ImagBuffer[0][j] );
+ e_reference_W = imult1616( (Word16) 2, e_Cldfb );
+#endif
move64();
move64();
-
- e_reference_W = imult1616( (Word16) 2, e_Cldfb );
}
- reference_power_temp[i] = W_add( reference_power_temp[i], reference_power_W[i] );
+ reference_power_temp[i] = W_add( reference_power_temp[i], reference_power_W[i] ); /* exp(2 * e_Cldfb) */
move64();
FOR( ch_idx = 1; ch_idx < nchan_ana; ch_idx++ )
@@ -773,19 +812,23 @@ void computeReferencePower_enc_fx_dirac(
/* abs()^2 */
FOR( j = brange[0]; j < brange[1]; j++ )
{
+#ifdef FIX_1127_IMPROVE_SBA_MLD
+ reference_power_temp[i] = W_add( reference_power_temp[i], W_shr( W_mult_32_32( Cldfb_RealBuffer[ch_idx][j], Cldfb_RealBuffer[ch_idx][j] ), gb ) ); /* exp(2 * e_Cldfb) */
+ reference_power_temp[i] = W_add( reference_power_temp[i], W_shr( W_mult_32_32( Cldfb_ImagBuffer[ch_idx][j], Cldfb_ImagBuffer[ch_idx][j] ), gb ) ); /* exp(2 * e_Cldfb) */
+#else
reference_power_temp[i] = W_mac_32_32( reference_power_temp[i], Cldfb_RealBuffer[ch_idx][j], Cldfb_RealBuffer[ch_idx][j] );
reference_power_temp[i] = W_mac_32_32( reference_power_temp[i], Cldfb_ImagBuffer[ch_idx][j], Cldfb_ImagBuffer[ch_idx][j] );
+ e_reference_temp = imult1616( (Word16) 2, e_Cldfb );
+#endif
move64();
move64();
-
- e_reference_temp = imult1616( (Word16) 2, e_Cldfb );
}
}
}
FOR( i = 0; i < num_freq_bands; i++ )
{
- reference_power_temp[i] = W_shr( reference_power_temp[i], 1 );
+ reference_power_temp[i] = W_shr( reference_power_temp[i], 1 ); /* exp(2 * e_Cldfb + 1) */
move64();
}
@@ -796,39 +839,35 @@ void computeReferencePower_enc_fx_dirac(
{
IF( BASOP_Util_Cmp_Mant32Exp( W_extract_h( reference_power_temp[i] ), e_reference_temp, W_extract_h( reference_power_W[i] ), e_reference_W ) < 0 )
{
- reference_power_temp[i] = reference_power_W[i];
+ reference_power_temp[i] = reference_power_W[i]; /* exp(2 * e_Cldfb + 1 ) */
move64();
}
}
}
- 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();
}
- *e_reference = sub( e_reference_temp, min_norm );
move16();
return;
}
void computeReferencePower_enc_fx(
- const Word16 *band_grouping, /* i : Band grouping for estimation */
- Word32 Cldfb_RealBuffer[][DIRAC_NO_FB_BANDS_MAX], /* i : Real part of input signal */
- Word32 Cldfb_ImagBuffer[][DIRAC_NO_FB_BANDS_MAX], /* i : Imag part of input signal */
- Word32 *reference_power, /* o : Estimated power */
- const Word16 enc_param_start_band, /* i : first band to process */
- const Word16 num_freq_bands, /* i : Number of frequency bands */
+ const Word16 *band_grouping, /* i : Band grouping for estimation Q0*/
+ Word32 Cldfb_RealBuffer[][DIRAC_NO_FB_BANDS_MAX], /* i : Real part of input signal inp_q*/
+ Word32 Cldfb_ImagBuffer[][DIRAC_NO_FB_BANDS_MAX], /* i : Imag part of input signal inp_q*/
+ Word32 *reference_power, /* o : Estimated power ref_exp*/
+ const Word16 enc_param_start_band, /* i : first band to process Q0*/
+ const Word16 num_freq_bands, /* i : Number of frequency bands Q0*/
const IVAS_FORMAT ivas_format, /* i : ivas_format */
- Word16 ref_power_w, /* i : use 0 if hodirac is enabled */
- const Word16 nchan_ana, /* i : number of analysis channels */
+ Word16 ref_power_w, /* i : use 0 if hodirac is enabled Q0*/
+ const Word16 nchan_ana, /* i : number of analysis channels Q0*/
Word16 inp_q, /* i : q of cld buffers */
Word16 *ref_exp /* i : output q */
)
@@ -842,9 +881,9 @@ void computeReferencePower_enc_fx(
Word64 reference_power_W[DIRAC_MAX_NBANDS];
FOR( i = 0; i < num_freq_bands; i++ )
{
- brange[0] = band_grouping[i + enc_param_start_band];
+ brange[0] = band_grouping[i + enc_param_start_band]; /* Q0 */
move16();
- brange[1] = band_grouping[i + enc_param_start_band + 1];
+ brange[1] = band_grouping[i + enc_param_start_band + 1]; /* Q0 */
move16();
reference_power[i] = 0;
move32();
@@ -884,7 +923,7 @@ void computeReferencePower_enc_fx(
{
IF( LT_64( reference_power_tmp[i], reference_power_W[i] ) )
{
- reference_power_tmp[i] = reference_power_W[i];
+ reference_power_tmp[i] = reference_power_W[i]; // 2*inp_q + 1
move64();
}
}
@@ -914,17 +953,18 @@ void computeReferencePower_enc_fx(
void ivas_dirac_param_est_enc_fx(
DIRAC_ENC_HANDLE hDirAC,
IVAS_QDIRECTION *q_direction,
- const UWord8 useLowerRes,
- Word32 *data_f_fx[],
- Word32 **pp_fr_real_fx,
- Word32 **pp_fr_imag_fx,
+ const UWord8 useLowerRes, /* Q0 */
+ Word32 *data_f_fx[], /* Qx */
+ Word32 **pp_fr_real_fx, /* pp_fr_q */
+ Word32 **pp_fr_imag_fx, /* pp_fr_q */
Word16 pp_fr_q,
- const Word16 input_frame,
+ const Word16 input_frame, /* Q0 */
const IVAS_FORMAT ivas_format,
- const Word16 hodirac_flag,
- const Word16 nchan_fb_in,
- Word16 *mono_frame_count,
- Word16 *dirac_mono_flag )
+ const Word16 hodirac_flag, /* Q0 */
+ const Word16 nchan_fb_in, /* Q0 */
+ Word16 *mono_frame_count, /* 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;
@@ -936,13 +976,17 @@ void ivas_dirac_param_est_enc_fx(
Word32 *p_Cldfb_ImagBuffer_fx[DIRAC_MAX_ANA_CHANS];
Word16 cldfb_q;
Word32 intensity_real_fx[DIRAC_NUM_DIMS][DIRAC_MAX_NBANDS];
+#ifdef NONBE_IMPROVE_DIRAC_INTENSITY_PREC
+ Word16 intensity_real_q[DIRAC_MAX_NBANDS];
+#else
Word16 intensity_real_q;
+#endif
Word32 direction_vector_fx[DIRAC_NUM_DIMS][DIRAC_MAX_NBANDS];
Word16 direction_vector_q;
Word32 diffuseness_vector_fx[DIRAC_MAX_NBANDS];
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;
@@ -950,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];
@@ -959,20 +1003,24 @@ void ivas_dirac_param_est_enc_fx(
Word16 ene_secs_exp[2 * DIRAC_MAX_ANA_CHANS * DIRAC_MAX_NBANDS];
push_wmops( "dirac_enc_param_est" );
- num_freq_bands = hDirAC->hConfig->nbands;
+ num_freq_bands = hDirAC->hConfig->nbands; /* Q0 */
move16();
/* Initialization */
cldfb_q = 0;
move16();
+
+#ifndef NONBE_IMPROVE_DIRAC_INTENSITY_PREC
intensity_real_q = 0;
move16();
+#endif
+
direction_vector_q = 0;
move16();
diffuseness_vector_q = 0;
move16();
- l_ts = idiv1616( input_frame, MAX_PARAM_SPATIAL_SUBFRAMES );
+ l_ts = idiv1616( input_frame, MAX_PARAM_SPATIAL_SUBFRAMES ); /* Q0 */
IF( useLowerRes )
{
q_direction->cfg.nblocks = 1;
@@ -993,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 );
@@ -1014,17 +1064,26 @@ void ivas_dirac_param_est_enc_fx(
/* do processing over all CLDFB time slots */
FOR( block_m_idx = 0; block_m_idx < num_blocks; block_m_idx++ )
{
- mrange[0] = hDirAC->block_grouping[block_m_idx];
+ mrange[0] = hDirAC->block_grouping[block_m_idx]; /* Q0 */
move16();
- mrange[1] = hDirAC->block_grouping[add( block_m_idx, 1 )];
+ mrange[1] = hDirAC->block_grouping[block_m_idx + 1];
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();
@@ -1032,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++ )
@@ -1045,8 +1113,8 @@ void ivas_dirac_param_est_enc_fx(
{
FOR( i = 0; i < nchan_fb_in; i++ )
{
- Copy32( &pp_fr_real_fx[i][imult1616( ts, l_ts )], Cldfb_RealBuffer_fx[i], l_ts );
- Copy32( &pp_fr_imag_fx[i][imult1616( ts, l_ts )], Cldfb_ImagBuffer_fx[i], l_ts );
+ Copy32( &pp_fr_real_fx[i][ts * l_ts], Cldfb_RealBuffer_fx[i], l_ts ); /* pp_fr_q */
+ Copy32( &pp_fr_imag_fx[i][ts * l_ts], Cldfb_ImagBuffer_fx[i], l_ts ); /* pp_fr_q */
}
cldfb_q = pp_fr_q;
move16();
@@ -1054,7 +1122,7 @@ void ivas_dirac_param_est_enc_fx(
Word16 ref_power_w = 1;
move16();
- IF( hodirac_flag )
+ if ( hodirac_flag )
{
ref_power_w = 0;
move16();
@@ -1066,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,
@@ -1081,10 +1149,16 @@ void ivas_dirac_param_est_enc_fx(
Cldfb_ImagBuffer_fx,
hDirAC->hConfig->enc_param_start_band,
num_freq_bands,
- intensity_real_fx );
-
+ intensity_real_fx
+#ifdef NONBE_IMPROVE_DIRAC_INTENSITY_PREC
+ ,
+ cldfb_q,
+ intensity_real_q
+#endif
+ );
+#ifndef NONBE_IMPROVE_DIRAC_INTENSITY_PREC
intensity_real_q = sub( shl( cldfb_q, 1 ), 31 ); // 2 * Q_Cldfb + 1 - 32;
-
+#endif
IF( !hodirac_flag )
{
computeDirectionVectors_fixed(
@@ -1095,26 +1169,41 @@ void ivas_dirac_param_est_enc_fx(
num_freq_bands,
direction_vector_fx[0],
direction_vector_fx[1],
- direction_vector_fx[2],
- sub( 31, intensity_real_q ) );
+ direction_vector_fx[2]
+#ifdef NONBE_IMPROVE_DIRAC_INTENSITY_PREC
+ ,
+ 31, intensity_real_q
+#else
+ ,
+ sub( 31, intensity_real_q )
+#endif
+ );
direction_vector_q = Q30;
move16();
}
/* fill buffers of length "averaging_length" time slots for intensity and energy */
- hDirAC->index_buffer_intensity = add( ( hDirAC->index_buffer_intensity % hDirAC->no_col_avg_diff ), 1 ); /* averaging_length = 32 */
+ hDirAC->index_buffer_intensity = add( ( hDirAC->index_buffer_intensity % hDirAC->no_col_avg_diff ), 1 ); /* averaging_length = 32 Q0*/
move16();
- index = hDirAC->index_buffer_intensity;
+ index = hDirAC->index_buffer_intensity; /* Q0 */
move16();
FOR( i = 0; i < DIRAC_NUM_DIMS; i++ )
{
/* only real part needed */
- Copy32( intensity_real_fx[i], &( hDirAC->buffer_intensity_real_fx[i][index - 1][0] ), num_freq_bands );
+ Copy32( intensity_real_fx[i], &( hDirAC->buffer_intensity_real_fx[i][index - 1][0] ), num_freq_bands ); /* intensity_real_q */
+#ifdef NONBE_IMPROVE_DIRAC_INTENSITY_PREC
+ Copy( intensity_real_q, &hDirAC->buffer_intensity_real_q[i][index - 1][0], num_freq_bands );
+#else
set16_fx( &hDirAC->buffer_intensity_real_q[i][index - 1][0], intensity_real_q, num_freq_bands );
+#endif
+ }
+ Copy32( reference_power_fx[ts], &( hDirAC->buffer_energy_fx[( index - 1 ) * num_freq_bands] ), num_freq_bands ); /* exp(reference_power_exp) */
+ FOR( i = 0; i < num_freq_bands; i++ )
+ {
+ hDirAC->buffer_energy_q[( index - 1 ) * num_freq_bands + i] = sub( 31, reference_power_exp[ts][i] );
+ move16();
}
- Copy32( reference_power_fx[ts], &( hDirAC->buffer_energy_fx[( index - 1 ) * num_freq_bands] ), num_freq_bands );
- set16_fx( &hDirAC->buffer_energy_q[( index - 1 ) * num_freq_bands], sub( 31, reference_power_exp ), num_freq_bands );
Word16 buffer_intensity_real_single_q;
buffer_intensity_real_single_q = hDirAC->buffer_intensity_real_q[0][0][0];
@@ -1135,7 +1224,7 @@ void ivas_dirac_param_est_enc_fx(
{
FOR( k = 0; k < num_freq_bands; k++ )
{
- hDirAC->buffer_intensity_real_fx[i][j][k] = L_shl( hDirAC->buffer_intensity_real_fx[i][j][k], sub( buffer_intensity_real_single_q, hDirAC->buffer_intensity_real_q[i][j][k] ) );
+ hDirAC->buffer_intensity_real_fx[i][j][k] = L_shl( hDirAC->buffer_intensity_real_fx[i][j][k], sub( buffer_intensity_real_single_q, hDirAC->buffer_intensity_real_q[i][j][k] ) ); /* buffer_intensity_real_single_q */
move32();
hDirAC->buffer_intensity_real_q[i][j][k] = buffer_intensity_real_single_q;
move16();
@@ -1149,7 +1238,7 @@ void ivas_dirac_param_est_enc_fx(
minimum_fx( hDirAC->buffer_energy_q, buffer_len, &buffer_energy_single_q );
FOR( i = 0; i < buffer_len; i++ )
{
- hDirAC->buffer_energy_fx[i] = L_shl( hDirAC->buffer_energy_fx[i], sub( buffer_energy_single_q, hDirAC->buffer_energy_q[i] ) );
+ hDirAC->buffer_energy_fx[i] = L_shl( hDirAC->buffer_energy_fx[i], sub( buffer_energy_single_q, hDirAC->buffer_energy_q[i] ) ); /* buffer_energy_single_q */
move32();
hDirAC->buffer_energy_q[i] = buffer_energy_single_q;
move16();
@@ -1182,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] );
+ 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] );
+ 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();
}
}
@@ -1201,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 ) );
+ 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 ) );
+ 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 ) );
+ 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 ) );
+ 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] );
+ 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] );
+ 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 );
}
}
@@ -1231,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] ) );
+ 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] ) );
+ 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] ) );
+ 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 ) );
- 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
+ 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( 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];
+ 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 ) );
- 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
+ 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( 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];
+ 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 ) );
- 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
+ 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( 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
@@ -1276,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++ )
@@ -1289,10 +1405,17 @@ void ivas_dirac_param_est_enc_fx(
Scale_sig32( dir_v_fx, 3, -1 );
ivas_qmetadata_direction_vector_to_azimuth_elevation_fx(
dir_v_fx,
+#ifdef NONBE_IMPROVE_DIRAC_INTENSITY_PREC
+ Q29,
+#else
+
Q30,
+#endif
&q_direction->band_data[band_m_idx].azimuth_fx[block_m_idx],
&q_direction->band_data[band_m_idx].elevation_fx[block_m_idx] );
}
+ hDirAC->direction_vector_m_exp[block_m_idx] = 1;
+ move16();
}
/* Sectors */
@@ -1312,9 +1435,9 @@ void ivas_dirac_param_est_enc_fx(
q_direction[1].band_data[band_m_idx].elevation_fx[block_m_idx] = L_shr( ele_secs_fx[num_freq_bands + band_m_idx], 1 ); // Q23 -> Q22
move32();
- L_tmp = BASOP_Util_Add_Mant32Exp( ONE_IN_Q30, Q1, L_negate( diff_secs_fx[band_m_idx] ), diff_secs_exp[band_m_idx], &e_tmp );
- L_tmp1 = BASOP_Util_Add_Mant32Exp( ONE_IN_Q30, Q1, L_negate( diff_secs_fx[num_freq_bands + band_m_idx] ), diff_secs_exp[num_freq_bands + band_m_idx], &e_tmp1 );
- L_tmp1 = BASOP_Util_Add_Mant32Exp( L_tmp, e_tmp, L_tmp1, e_tmp1, &e_tmp1 );
+ L_tmp = BASOP_Util_Add_Mant32Exp( ONE_IN_Q30, Q1, L_negate( diff_secs_fx[band_m_idx] ), diff_secs_exp[band_m_idx], &e_tmp ); /* exp(e_tmp) */
+ L_tmp1 = BASOP_Util_Add_Mant32Exp( ONE_IN_Q30, Q1, L_negate( diff_secs_fx[num_freq_bands + band_m_idx] ), diff_secs_exp[num_freq_bands + band_m_idx], &e_tmp1 ); /* exp(e_tmp1) */
+ L_tmp1 = BASOP_Util_Add_Mant32Exp( L_tmp, e_tmp, L_tmp1, e_tmp1, &e_tmp1 ); /* exp(e_tmp1) */
IF( L_tmp1 == 0 )
{
q_direction[1].band_data[band_m_idx].energy_ratio_fx[block_m_idx] = L_shl( div_l( L_tmp, EPSILON_FX ), Q30 - Q15 ); // Q30
@@ -1322,7 +1445,7 @@ void ivas_dirac_param_est_enc_fx(
}
ELSE
{
- L_tmp = L_deposit_h( BASOP_Util_Divide3232_Scale( L_tmp, L_add( L_tmp1, EPSILON_FX ), &exp_diff ) );
+ L_tmp = L_deposit_h( BASOP_Util_Divide3232_Scale( L_tmp, L_add( L_tmp1, EPSILON_FX ), &exp_diff ) ); /* exp(exp_diff) */
exp_diff = add( exp_diff, sub( e_tmp, e_tmp1 ) );
q_direction[1].band_data[band_m_idx].energy_ratio_fx[block_m_idx] = L_shl( L_tmp, sub( exp_diff, Q1 ) ); // Q30
move32();
@@ -1337,7 +1460,7 @@ void ivas_dirac_param_est_enc_fx(
IF( GT_32( renormalization_factor_diff_fx[band_m_idx], EPSILON_FX ) )
{
Word16 tmp_e;
- hDirAC->diffuseness_m_fx[band_m_idx] = L_deposit_h( BASOP_Util_Divide3232_Scale( hDirAC->diffuseness_m_fx[band_m_idx], renormalization_factor_diff_fx[band_m_idx], &tmp_e ) );
+ hDirAC->diffuseness_m_fx[band_m_idx] = L_deposit_h( BASOP_Util_Divide3232_Scale( hDirAC->diffuseness_m_fx[band_m_idx], renormalization_factor_diff_fx[band_m_idx], &tmp_e ) ); /* exp(tmp_e) */
move32();
tmp_e = add( tmp_e, sub( hDirAC->diffuseness_m_exp[band_m_idx], renormalization_factor_diff_exp[band_m_idx] ) );
hDirAC->diffuseness_m_fx[band_m_idx] = L_shr( hDirAC->diffuseness_m_fx[band_m_idx], sub( 1, tmp_e ) ); // to Q30
@@ -1377,11 +1500,17 @@ void ivas_dirac_param_est_enc_fx(
*------------------------------------------------------------------------*/
static void computeIntensityVector_enc_fx(
const DIRAC_ENC_HANDLE hDirAC,
- Word32 Cldfb_RealBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX],
- Word32 Cldfb_ImagBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX],
- const Word16 enc_param_start_band, /* i : first band to process */
- const Word16 num_frequency_bands,
- Word32 intensity_real[DIRAC_NUM_DIMS][DIRAC_MAX_NBANDS] )
+ Word32 Cldfb_RealBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* q_cldfb */
+ Word32 Cldfb_ImagBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* q_cldfb */
+ const Word16 enc_param_start_band, /* i : first band to process Q0*/
+ const Word16 num_frequency_bands, /* Q0 */
+ Word32 intensity_real[DIRAC_NUM_DIMS][DIRAC_MAX_NBANDS] /* q_intensity_real */
+#ifdef NONBE_IMPROVE_DIRAC_INTENSITY_PREC
+ ,
+ Word16 q_cldfb,
+ Word16 q_intensity_real[DIRAC_MAX_NBANDS]
+#endif
+)
{
/* Reminder
* X = a + ib; Y = c + id
@@ -1390,14 +1519,20 @@ static void computeIntensityVector_enc_fx(
Word16 i, j;
Word32 real, img;
Word16 brange[2];
-
+#ifdef NONBE_IMPROVE_DIRAC_INTENSITY_PREC
+ Word16 shift_value = sub( shl( q_cldfb, 1 ), 31 );
+#endif
FOR( i = 0; i < num_frequency_bands; i++ )
{
- brange[0] = hDirAC->band_grouping[i + enc_param_start_band];
+ brange[0] = hDirAC->band_grouping[i + enc_param_start_band]; /* Q0 */
move16();
- brange[1] = hDirAC->band_grouping[i + enc_param_start_band + 1];
+ brange[1] = hDirAC->band_grouping[i + enc_param_start_band + 1]; /* Q0 */
move16();
-
+#ifdef NONBE_IMPROVE_DIRAC_INTENSITY_PREC
+ Word16 num_bins = sub( brange[1], brange[0] );
+ Word16 gb = find_guarded_bits_fx( num_bins );
+ Word16 norm;
+#endif
intensity_real[0][i] = 0;
move32();
intensity_real[1][i] = 0;
@@ -1416,11 +1551,36 @@ static void computeIntensityVector_enc_fx(
move32();
img = Cldfb_ImagBuffer[0][j];
move32();
+#ifdef NONBE_IMPROVE_DIRAC_INTENSITY_PREC
+ Word64 t1, t2, t3;
+ t1 = W_mac_32_32( W_mult_32_32( Cldfb_RealBuffer[3][j], real ), Cldfb_ImagBuffer[3][j], img ); /* 2 * q_cldfb + 1 */
+ t2 = W_mac_32_32( W_mult_32_32( Cldfb_RealBuffer[1][j], real ), Cldfb_ImagBuffer[1][j], img ); /* 2 * q_cldfb + 1 */
+ t3 = W_mac_32_32( W_mult_32_32( Cldfb_RealBuffer[2][j], real ), Cldfb_ImagBuffer[2][j], img ); /* 2 * q_cldfb + 1 */
+ t1 = W_shr( t1, gb );
+ t2 = W_shr( t2, gb );
+ t3 = W_shr( t3, gb );
+ /* Intensity is XYZ order, audio is WYZX order. */
+ tmp_1 = W_add( tmp_1, t1 ); /* 2 * q_cldfb + 1 */
+ tmp_2 = W_add( tmp_2, t2 ); /* 2 * q_cldfb + 1 */
+ tmp_3 = W_add( tmp_3, t3 ); /* 2 * q_cldfb + 1 */
+#else
/* Intensity is XYZ order, audio is WYZX order. */
tmp_1 = W_add( tmp_1, W_add( W_mult_32_32( Cldfb_RealBuffer[3][j], real ), W_mult_32_32( Cldfb_ImagBuffer[3][j], img ) ) );
tmp_2 = W_add( tmp_2, W_add( W_mult_32_32( Cldfb_RealBuffer[1][j], real ), W_mult_32_32( Cldfb_ImagBuffer[1][j], img ) ) );
tmp_3 = W_add( tmp_3, W_add( W_mult_32_32( Cldfb_RealBuffer[2][j], real ), W_mult_32_32( Cldfb_ImagBuffer[2][j], img ) ) );
+#endif
}
+#ifdef NONBE_IMPROVE_DIRAC_INTENSITY_PREC
+ norm = s_min( W_norm( tmp_1 ), W_norm( tmp_2 ) );
+ norm = s_min( norm, W_norm( tmp_3 ) );
+ intensity_real[0][i] = W_extract_h( W_shl( tmp_1, norm ) ); // shift_value - (gb - norm)
+ move32();
+ intensity_real[1][i] = W_extract_h( W_shl( tmp_2, norm ) ); // shift_value - (gb - norm)
+ move32();
+ intensity_real[2][i] = W_extract_h( W_shl( tmp_3, norm ) ); // shift_value - (gb - norm)
+ q_intensity_real[i] = sub( shift_value, sub( gb, norm ) );
+ move16();
+#else
intensity_real[0][i] = W_extract_h( tmp_1 ); // output Q= 2* input_q + 1 - 32
move32();
@@ -1428,6 +1588,7 @@ static void computeIntensityVector_enc_fx(
move32();
intensity_real[2][i] = W_extract_h( tmp_3 ); // output Q= 2* input_q + 1 - 32
move32();
+#endif
}
return;
@@ -1439,11 +1600,11 @@ static void computeIntensityVector_enc_fx(
*
*------------------------------------------------------------------------*/
void computeDiffuseness_mdft_fx(
- Word32 **buffer_intensity[DIRAC_NUM_DIMS],
- const Word32 *buffer_energy,
- const Word16 num_freq_bands,
- const UWord16 no_col_avg_diff,
- Word32 *diffuseness,
+ Word32 **buffer_intensity[DIRAC_NUM_DIMS], /* q_factor_intensity */
+ const Word32 *buffer_energy, /* q_factor_energy */
+ const Word16 num_freq_bands, /* Q0 */
+ const UWord16 no_col_avg_diff, /* Q0 */
+ Word32 *diffuseness, /* q_diffuseness */
Word16 *q_factor_intensity,
Word16 *q_factor_energy,
Word16 *q_diffuseness /*Ouput Q*/
@@ -1479,7 +1640,7 @@ void computeDiffuseness_mdft_fx(
FOR( k = 0; k < num_freq_bands; k++ )
{
- energy_slow[k] = BASOP_Util_Add_Mant32Exp( energy_slow[k], energy_slow_e[k], p_tmp_c[k], sub( 31, tmp_q ), &energy_slow_e[k] );
+ energy_slow[k] = BASOP_Util_Add_Mant32Exp( energy_slow[k], energy_slow_e[k], p_tmp_c[k], sub( 31, tmp_q ), &energy_slow_e[k] ); /* exp(energy_slow_e)*/
move32();
}
@@ -1489,7 +1650,7 @@ void computeDiffuseness_mdft_fx(
p_tmp = buffer_intensity[j][i];
FOR( k = 0; k < num_freq_bands; k++ )
{
- intensity_slow[j * num_freq_bands + k] = BASOP_Util_Add_Mant32Exp( intensity_slow[j * num_freq_bands + k], intensity_slow_e[j * num_freq_bands + k], p_tmp[k], sub( 31, q_factor_intensity[i] ), &intensity_slow_e[j * num_freq_bands + k] );
+ intensity_slow[j * num_freq_bands + k] = BASOP_Util_Add_Mant32Exp( intensity_slow[j * num_freq_bands + k], intensity_slow_e[j * num_freq_bands + k], p_tmp[k], sub( 31, q_factor_intensity[i] ), &intensity_slow_e[j * num_freq_bands + k] ); /* exp(intensity_slow_e) */
move32();
}
}
@@ -1503,10 +1664,10 @@ void computeDiffuseness_mdft_fx(
FOR( k = 0; k < num_freq_bands; k++ )
{
- p_tmp[k] = Mpy_32_32( p_tmp[k], p_tmp[k] );
+ p_tmp[k] = Mpy_32_32( p_tmp[k], p_tmp[k] ); /* 2 * (31-p_tmp_e) - 31 */
move32();
tmp_q = sub( shl( sub( 31, p_tmp_e[k] ), 1 ), 31 );
- intensity_slow_abs[k] = BASOP_Util_Add_Mant32Exp( intensity_slow_abs[k], intensity_slow_abs_e[k], p_tmp[k], sub( 31, tmp_q ), &intensity_slow_abs_e[k] );
+ intensity_slow_abs[k] = BASOP_Util_Add_Mant32Exp( intensity_slow_abs[k], intensity_slow_abs_e[k], p_tmp[k], sub( 31, tmp_q ), &intensity_slow_abs_e[k] ); /* exp(intensity_slow_abs_e) */
move32();
}
}
@@ -1519,7 +1680,7 @@ void computeDiffuseness_mdft_fx(
{
tmp = Sqrt32( p_tmp[i], &intensity_slow_abs_e[i] );
- tmp = L_deposit_h( BASOP_Util_Divide3232_Scale( tmp, L_add( energy_slow[i], EPSILLON_FX ), &tmp_q ) );
+ tmp = L_deposit_h( BASOP_Util_Divide3232_Scale( tmp, L_add( energy_slow[i], EPSILLON_FX ), &tmp_q ) ); /* exp(tmp_q) */
tmp_q = add( tmp_q, sub( intensity_slow_abs_e[i], energy_slow_e[i] ) );
tmp = L_shl_sat( tmp, tmp_q );
tmp = L_sub( ONE_IN_Q31, tmp );
diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c
index 3979326e44c485ed93ca92f7fe6fa48a03576d08..a7fb7146130327a5c8b98fd6cc89395c60faa857 100644
--- a/lib_enc/ivas_enc.c
+++ b/lib_enc/ivas_enc.c
@@ -52,9 +52,9 @@
* Principal IVAS encoder routine
*-------------------------------------------------------------------*/
ivas_error ivas_enc_fx(
- Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */
- const Word16 *data, /* i : input signal Q0 */
- const Word16 n_samples /* i : number of input samples */
+ Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */
+ const Word16 *data, /* i : input signal Q0*/
+ const Word16 n_samples /* i : number of input samples Q0*/
)
{
Word16 i, n, input_frame, n_samples_chan, nchan_inp /*, scale*/;
@@ -77,10 +77,10 @@ ivas_error ivas_enc_fx(
hEncoderConfig = st_ivas->hEncoderConfig;
- input_Fs = hEncoderConfig->input_Fs;
+ input_Fs = hEncoderConfig->input_Fs; /* Q0 */
ivas_format = hEncoderConfig->ivas_format;
- nchan_inp = hEncoderConfig->nchan_inp;
- ivas_total_brate = hEncoderConfig->ivas_total_brate;
+ nchan_inp = hEncoderConfig->nchan_inp; /* Q0 */
+ ivas_total_brate = hEncoderConfig->ivas_total_brate; /* Q0 */
move32();
move32();
move16();
@@ -89,12 +89,12 @@ ivas_error ivas_enc_fx(
input_frame = extract_l( Mpy_32_16_1( input_Fs, INV_FRAME_PER_SEC_Q15 ) );
IF( NE_16( nchan_inp, 1 ) )
{
- n_samples_chan = div_l( L_deposit_l( n_samples ), nchan_inp );
- n_samples_chan = shl( n_samples_chan, 1 );
+ n_samples_chan = div_l( L_deposit_l( n_samples ), nchan_inp ); /* Q0 */
+ n_samples_chan = shl( n_samples_chan, 1 ); /* Q0 */
}
ELSE
{
- n_samples_chan = n_samples;
+ n_samples_chan = n_samples; /* Q0 */
move16();
}
set16_fx( nb_bits_metadata, 0, MAX_SCE + 1 );
@@ -106,9 +106,12 @@ ivas_error ivas_enc_fx(
FOR( n = 0; n < MAX_INPUT_CHANNELS + MAX_NUM_OBJECTS; n++ )
{
data_fx[n] = st_ivas->p_data_fx[n];
+ IF( data_fx[n] )
+ {
+ Scale_sig32( data_fx[n], input_frame, sub( Q11, st_ivas->q_data_fx ) ); // Q11
+ }
}
-
- st_ivas->q_data_fx = 11; // Q-factor of the input buffer
+ st_ivas->q_data_fx = Q11;
move16();
n = 0;
move16();
@@ -119,7 +122,7 @@ ivas_error ivas_enc_fx(
data_fx[n][i] = L_mult0( data[i * nchan_inp + n], shl( 1, st_ivas->q_data_fx ) );
move32();
}
- n++;
+ n = add( n, 1 );
}
IF( LT_16( n_samples_chan, input_frame ) )
@@ -132,14 +135,14 @@ ivas_error ivas_enc_fx(
IF( EQ_32( ivas_format, SBA_FORMAT ) )
{
- IF( NE_32( ( 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;
}
}
ELSE IF( EQ_32( ivas_format, SBA_ISM_FORMAT ) )
{
- IF( NE_32( ( error = ivas_osba_enc_reconfig( st_ivas ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_osba_enc_reconfig( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -177,9 +180,9 @@ ivas_error ivas_enc_fx(
test();
IF( EQ_32( ivas_format, STEREO_FORMAT ) )
{
- st_ivas->hCPE[0]->element_brate = ivas_total_brate;
+ st_ivas->hCPE[0]->element_brate = ivas_total_brate; /* Q0 */
move32();
- IF( NE_32( ( error = ivas_cpe_enc_fx( st_ivas, 0, data_fx[0], data_fx[1], st_ivas->q_data_fx, input_frame, 0 /* no metadata */, NULL ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_cpe_enc_fx( st_ivas, 0, data_fx[0], data_fx[1], st_ivas->q_data_fx, input_frame, 0 /* no metadata */, NULL ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -187,7 +190,7 @@ ivas_error ivas_enc_fx(
ELSE IF( EQ_32( ivas_format, ISM_FORMAT ) )
{
/* select ISM format mode; reconfigure the ISM format encoder */
- IF( NE_32( ( error = ivas_ism_enc_config( st_ivas ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_ism_enc_config( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -200,7 +203,7 @@ ivas_error ivas_enc_fx(
ivas_param_ism_stereo_dmx_fx( st_ivas, data_fx, input_frame );
/* Core coding of Stereo DMX */
- IF( NE_32( ( error = ivas_ism_enc_fx( st_ivas, data_fx, st_ivas->q_data_fx, input_frame, nb_bits_metadata, 0 ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_ism_enc_fx( st_ivas, data_fx, st_ivas->q_data_fx, input_frame, nb_bits_metadata, 0 ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -208,7 +211,7 @@ ivas_error ivas_enc_fx(
ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MODE_DISC ) )
{
/* Analysis, decision about bitrates per channel & core coding */
- IF( NE_32( ( error = ivas_ism_enc_fx( st_ivas, data_fx, st_ivas->q_data_fx, input_frame, nb_bits_metadata, 0 ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_ism_enc_fx( st_ivas, data_fx, st_ivas->q_data_fx, input_frame, nb_bits_metadata, 0 ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -238,25 +241,25 @@ ivas_error ivas_enc_fx(
{
ivas_masa_estimate_energy_fx( st_ivas->hMasa, data_fx, input_frame, st_ivas->nchan_transport, st_ivas->q_data_fx ); /* energy-estimation uses TF-resolution: 4x24 */
- IF( NE_32( ( error = ivas_masa_enc_config_fx( st_ivas ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_masa_enc_config_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
IF( EQ_16( st_ivas->nchan_transport, 2 ) )
{
- IF( NE_32( ( error = ivas_masa_encode_fx( st_ivas->hMasa, st_ivas->hQMetaData, hMetaData, &nb_bits_metadata[0], st_ivas->nchan_transport, ivas_format, ivas_total_brate, hEncoderConfig->Opt_DTX_ON, st_ivas->hCPE[0]->element_mode,
- ISM_MODE_NONE, -1, NULL, -1, NULL, 0, 0 ) ),
- IVAS_ERR_OK ) )
+ IF( ( error = ivas_masa_encode_fx( st_ivas->hMasa, st_ivas->hQMetaData, hMetaData, &nb_bits_metadata[0], st_ivas->nchan_transport, ivas_format, ivas_total_brate, hEncoderConfig->Opt_DTX_ON, st_ivas->hCPE[0]->element_mode,
+ ISM_MODE_NONE, -1, NULL, -1, NULL, 0, 0 ) ) !=
+ IVAS_ERR_OK )
{
return error;
}
}
ELSE
{
- IF( NE_32( ( error = ivas_masa_encode_fx( st_ivas->hMasa, st_ivas->hQMetaData, hMetaData, &nb_bits_metadata[0], st_ivas->nchan_transport, ivas_format, ivas_total_brate, hEncoderConfig->Opt_DTX_ON, -1,
- ISM_MODE_NONE, -1, NULL, -1, NULL, 0, 0 ) ),
- IVAS_ERR_OK ) )
+ IF( ( error = ivas_masa_encode_fx( st_ivas->hMasa, st_ivas->hQMetaData, hMetaData, &nb_bits_metadata[0], st_ivas->nchan_transport, ivas_format, ivas_total_brate, hEncoderConfig->Opt_DTX_ON, -1,
+ ISM_MODE_NONE, -1, NULL, -1, NULL, 0, 0 ) ) !=
+ IVAS_ERR_OK )
{
return error;
}
@@ -264,7 +267,7 @@ ivas_error ivas_enc_fx(
}
ELSE IF( EQ_32( ivas_format, SBA_FORMAT ) )
{
- IF( NE_32( ( error = ivas_spar_enc_fx( st_ivas, data_fx, input_frame, nb_bits_metadata, hMetaData ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_spar_enc_fx( st_ivas, data_fx, input_frame, nb_bits_metadata, hMetaData ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -278,21 +281,21 @@ ivas_error ivas_enc_fx(
/* core-coding of transport channels */
IF( EQ_16( st_ivas->nSCE, 1 ) )
{
- IF( NE_32( ( error = ivas_sce_enc_fx( st_ivas, 0, data_fx[0], st_ivas->q_data_fx, input_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_sce_enc_fx( st_ivas, 0, data_fx[0], st_ivas->q_data_fx, input_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK )
{
return error;
}
}
ELSE IF( EQ_16( st_ivas->nCPE, 1 ) ) /* Stereo DMX */
{
- IF( NE_32( ( error = ivas_cpe_enc_fx( st_ivas, 0, data_fx[0], data_fx[1], st_ivas->q_data_fx, input_frame, nb_bits_metadata[0], NULL ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_cpe_enc_fx( st_ivas, 0, data_fx[0], data_fx[1], st_ivas->q_data_fx, input_frame, nb_bits_metadata[0], NULL ) ) != IVAS_ERR_OK )
{
return error;
}
}
ELSE IF( GT_16( st_ivas->nCPE, 1 ) ) /* FOA/HOA format */
{
- IF( NE_32( ( error = ivas_mct_enc_fx( st_ivas, data_fx, st_ivas->q_data_fx, input_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_mct_enc_fx( st_ivas, data_fx, st_ivas->q_data_fx, input_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -313,18 +316,18 @@ ivas_error ivas_enc_fx(
IF( EQ_16( sub( st_ivas->hEncoderConfig->nchan_inp, hEncoderConfig->nchan_ism ), 1 ) )
{
v_multc_fixed( data_fx[hEncoderConfig->nchan_ism], L_deposit_h( INV_SQRT2_FX_Q15 ) /* Q31 */, data_fx[hEncoderConfig->nchan_ism], input_frame );
- Copy32( data_fx[hEncoderConfig->nchan_ism], data_fx[hEncoderConfig->nchan_ism + 1], input_frame );
+ Copy32( data_fx[hEncoderConfig->nchan_ism], data_fx[hEncoderConfig->nchan_ism + 1], input_frame ); /* st_ivas->q_data_fx */
}
/* Estimate TF-tile energy for the input MASA stream */
ivas_masa_estimate_energy_fx( st_ivas->hMasa, &( data_fx[hEncoderConfig->nchan_ism] ), input_frame, st_ivas->nchan_transport, st_ivas->q_data_fx );
- IF( NE_32( ( error = ivas_omasa_enc_config_fx( st_ivas ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_omasa_enc_config_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
- set_s( nb_bits_metadata, 0, MAX_SCE + 1 );
+ set16_fx( nb_bits_metadata, 0, MAX_SCE + 1 );
idx_separated_object = 0;
move16();
@@ -338,6 +341,7 @@ ivas_error ivas_enc_fx(
/* Scaling data_fx */
{
Word16 norm_data_in = MAX16B;
+ move16();
FOR( i = 0; i < hEncoderConfig->nchan_ism + st_ivas->nchan_transport; i++ )
{
norm_data_in = s_min( norm_data_in, L_norm_arr( data_fx[i], input_frame ) );
@@ -345,7 +349,7 @@ ivas_error ivas_enc_fx(
norm_data_in = sub( norm_data_in, 7 ); /*guard bit is 4->to handle overflow in cldfbAnalysis*/
FOR( i = 0; i < hEncoderConfig->nchan_ism + st_ivas->nchan_transport; i++ )
{
- scale_sig32( data_fx[i], input_frame, norm_data_in );
+ scale_sig32( data_fx[i], input_frame, norm_data_in ); /* st_ivas->q_data_fx + norm_data_in */
}
st_ivas->q_data_fx = add( st_ivas->q_data_fx, norm_data_in );
move16();
@@ -377,14 +381,14 @@ ivas_error ivas_enc_fx(
}
ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) )
{
- flag_omasa_ener_brate = ivas_omasa_ener_brate_fx( st_ivas->hEncoderConfig->nchan_ism, ivas_total_brate, data_fx, input_frame, sub( 31, st_ivas->q_data_fx ) );
+ flag_omasa_ener_brate = ivas_omasa_ener_brate_fx( st_ivas->hEncoderConfig->nchan_ism, ivas_total_brate, data_fx, input_frame, sub( 31, st_ivas->q_data_fx ) ); /* Q0 */
/* Analysis, decision about bitrates per channel & core coding */
IF( NE_32( ( error = ivas_ism_enc_fx( st_ivas, data_fx, st_ivas->q_data_fx, input_frame, &nb_bits_metadata[1], flag_omasa_ener_brate ) ), IVAS_ERR_OK ) )
{
return error;
}
- n = st_ivas->hEncoderConfig->nchan_ism;
+ n = st_ivas->hEncoderConfig->nchan_ism; /* Q0 */
move16();
}
@@ -398,7 +402,19 @@ ivas_error ivas_enc_fx(
}
/* Encode MASA parameters and write MASA metadata bitstream */
- IF( NE_32( ( error = ivas_masa_encode_fx( st_ivas->hMasa, st_ivas->hQMetaData, hMetaData, nb_bits_metadata, st_ivas->nchan_transport, ivas_format, ivas_total_brate, st_ivas->hEncoderConfig->Opt_DTX_ON, st_ivas->nchan_transport == 2 ? st_ivas->hCPE[0]->element_mode : -1,
+ Word16 element_mode;
+ if ( st_ivas->nchan_transport == 2 )
+ {
+ element_mode = st_ivas->hCPE[0]->element_mode;
+ move16();
+ }
+ else
+ {
+ element_mode = -1;
+ move16();
+ }
+
+ IF( NE_32( ( error = ivas_masa_encode_fx( st_ivas->hMasa, st_ivas->hQMetaData, hMetaData, nb_bits_metadata, st_ivas->nchan_transport, ivas_format, ivas_total_brate, st_ivas->hEncoderConfig->Opt_DTX_ON, element_mode,
st_ivas->ism_mode, hEncoderConfig->nchan_ism, st_ivas->hIsmMetaData, idx_separated_object, st_ivas->hOMasa, st_ivas->hIsmMetaData[0]->ism_imp, flag_omasa_ener_brate ) ),
IVAS_ERR_OK ) )
{
@@ -430,11 +446,11 @@ ivas_error ivas_enc_fx(
IF( st_ivas->ism_mode == ISM_MODE_NONE )
{
- nchan = imult1616( add( st_ivas->sba_analysis_order, 1 ), add( st_ivas->sba_analysis_order, 1 ) );
+ nchan = imult1616( add( st_ivas->sba_analysis_order, 1 ), add( st_ivas->sba_analysis_order, 1 ) ); /* Q0 */
}
ELSE
{
- nchan = hEncoderConfig->nchan_ism;
+ nchan = hEncoderConfig->nchan_ism; /* Q0 */
move16();
}
FOR( n = 0; n < nchan; n++ )
@@ -459,27 +475,27 @@ ivas_error ivas_enc_fx(
}
/* SBA metadata encoding and SBA metadata bitstream writing */
- IF( NE_32( ( error = ivas_spar_enc_fx( st_ivas, data_fx, input_frame, nb_bits_metadata, hMetaData ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_spar_enc_fx( st_ivas, data_fx, input_frame, nb_bits_metadata, hMetaData ) ) != IVAS_ERR_OK )
{
return error;
}
- hEncoderConfig->sba_planar = planar_sba_orig;
+ hEncoderConfig->sba_planar = planar_sba_orig; /* Q0 */
move16();
}
ELSE
{
- n = hEncoderConfig->nchan_ism;
+ n = hEncoderConfig->nchan_ism; /* Q0 */
move16();
hMetaData = st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData;
- IF( NE_32( ( error = ivas_ism_metadata_enc( &st_ivas->hEncoderConfig->ivas_total_brate, n, st_ivas->hEncoderConfig->nchan_ism, st_ivas->hIsmMetaData, NULL, hMetaData, &nb_bits_metadata[1], 0, st_ivas->ism_mode, NULL, st_ivas->hEncoderConfig->ism_extended_metadata_flag, -256 /* -1.0f in Q8 */, 0, NULL, st_ivas->hCPE[0]->hCoreCoder[0]->ini_frame ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_ism_metadata_enc_fx( &st_ivas->hEncoderConfig->ivas_total_brate, n, st_ivas->hEncoderConfig->nchan_ism, st_ivas->hIsmMetaData, NULL, hMetaData, &nb_bits_metadata[1], 0, st_ivas->ism_mode, NULL, st_ivas->hEncoderConfig->ism_extended_metadata_flag, -256 /* -1.0f in Q8 */, 0, NULL, st_ivas->hCPE[0]->hCoreCoder[0]->ini_frame ) ) != IVAS_ERR_OK )
{
return error;
}
/* SBA metadata encoding and SBA metadata bitstream writing */
- IF( NE_32( ( error = ivas_spar_enc_fx( st_ivas, &data_fx[n], input_frame, nb_bits_metadata, hMetaData ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_spar_enc_fx( st_ivas, &data_fx[n], input_frame, nb_bits_metadata, hMetaData ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -491,21 +507,21 @@ ivas_error ivas_enc_fx(
/* core-coding of transport channels */
IF( EQ_16( st_ivas->nSCE, 1 ) )
{
- IF( NE_32( ( error = ivas_sce_enc_fx( st_ivas, 0, data_fx[0], st_ivas->q_data_fx, input_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_sce_enc_fx( st_ivas, 0, data_fx[0], st_ivas->q_data_fx, input_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK )
{
return error;
}
}
ELSE IF( EQ_16( st_ivas->nCPE, 1 ) ) /* Stereo DMX */
{
- IF( NE_32( ( error = ivas_cpe_enc_fx( st_ivas, 0, data_fx[0], data_fx[1], st_ivas->q_data_fx, input_frame, nb_bits_metadata[0], NULL ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_cpe_enc_fx( st_ivas, 0, data_fx[0], data_fx[1], st_ivas->q_data_fx, input_frame, nb_bits_metadata[0], NULL ) ) != IVAS_ERR_OK )
{
return error;
}
}
ELSE IF( GT_16( st_ivas->nCPE, 1 ) ) /* FOA/HOA format */
{
- IF( NE_32( ( error = ivas_mct_enc_fx( st_ivas, data_fx, st_ivas->q_data_fx, input_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_mct_enc_fx( st_ivas, data_fx, st_ivas->q_data_fx, input_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -514,7 +530,7 @@ ivas_error ivas_enc_fx(
ELSE IF( EQ_32( ivas_format, MC_FORMAT ) )
{
/* select MC format mode; write MC LS setup; reconfigure the MC format encoder */
- IF( NE_32( ( error = ivas_mc_enc_config_fx( st_ivas ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_mc_enc_config_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -571,7 +587,7 @@ ivas_error ivas_enc_fx(
ivas_lfe_enc_fx( st_ivas->hLFE, data_fx[LFE_CHANNEL], st_ivas->q_data_fx, input_frame, st_ivas->hLFE->hBstr );
- IF( NE_32( ( error = ivas_mct_enc_fx( st_ivas, data_fx, st_ivas->q_data_fx, input_frame, hMetaData->nb_bits_tot ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_mct_enc_fx( st_ivas, data_fx, st_ivas->q_data_fx, input_frame, hMetaData->nb_bits_tot ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -583,14 +599,14 @@ ivas_error ivas_enc_fx(
IF( EQ_16( st_ivas->nCPE, 1 ) ) /* Stereo DMX */
{
- IF( NE_32( ( error = ivas_cpe_enc_fx( st_ivas, 0, data_fx[0], data_fx[1], st_ivas->q_data_fx, input_frame, hMetaData->nb_bits_tot, NULL ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_cpe_enc_fx( st_ivas, 0, data_fx[0], data_fx[1], st_ivas->q_data_fx, input_frame, hMetaData->nb_bits_tot, NULL ) ) != IVAS_ERR_OK )
{
return error;
}
}
ELSE IF( GT_16( st_ivas->nCPE, 1 ) )
{
- IF( NE_32( ( error = ivas_mct_enc_fx( st_ivas, data_fx, st_ivas->q_data_fx, input_frame, hMetaData->nb_bits_tot ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_mct_enc_fx( st_ivas, data_fx, st_ivas->q_data_fx, input_frame, hMetaData->nb_bits_tot ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -625,23 +641,23 @@ ivas_error ivas_enc_fx(
scale_sig32( st_ivas->hQMetaData->q_direction[0].band_data[i].energy_ratio_fx, MAX_PARAM_SPATIAL_SUBFRAMES, -1 ); // Q31 -> Q30
}
- IF( NE_32( ( error = ivas_masa_encode_fx( st_ivas->hMasa, st_ivas->hQMetaData, hMetaData, &nb_bits_metadata[0], st_ivas->nchan_transport, ivas_format, ivas_total_brate, 0, -1,
- ISM_MODE_NONE, -1, NULL, -1, NULL, 0, 0 ) ),
- IVAS_ERR_OK ) )
+ IF( ( error = ivas_masa_encode_fx( st_ivas->hMasa, st_ivas->hQMetaData, hMetaData, &nb_bits_metadata[0], st_ivas->nchan_transport, ivas_format, ivas_total_brate, 0, -1,
+ ISM_MODE_NONE, -1, NULL, -1, NULL, 0, 0 ) ) !=
+ IVAS_ERR_OK )
{
return error;
}
IF( st_ivas->hMcMasa->separateChannelEnabled )
{
- IF( NE_32( ( error = ivas_sce_enc_fx( st_ivas, 0, data_fx[2], st_ivas->q_data_fx, input_frame, 0 ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_sce_enc_fx( st_ivas, 0, data_fx[2], st_ivas->q_data_fx, input_frame, 0 ) ) != IVAS_ERR_OK )
{
return error;
}
st_ivas->hCPE[0]->hCoreCoder[0]->hBstr->ind_list = st_ivas->hSCE[0]->hCoreCoder[0]->hBstr->ind_list + st_ivas->hSCE[0]->hCoreCoder[0]->hBstr->nb_ind_tot;
- IF( NE_32( ( error = ivas_cpe_enc_fx( st_ivas, 0, data_fx[0], data_fx[1], st_ivas->q_data_fx, input_frame, hMetaData->nb_bits_tot, NULL ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_cpe_enc_fx( st_ivas, 0, data_fx[0], data_fx[1], st_ivas->q_data_fx, input_frame, hMetaData->nb_bits_tot, NULL ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -650,14 +666,14 @@ ivas_error ivas_enc_fx(
{
IF( EQ_16( st_ivas->nSCE, 1 ) )
{
- IF( NE_32( ( error = ivas_sce_enc_fx( st_ivas, 0, data_fx[0], st_ivas->q_data_fx, input_frame, hMetaData->nb_bits_tot ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_sce_enc_fx( st_ivas, 0, data_fx[0], st_ivas->q_data_fx, input_frame, hMetaData->nb_bits_tot ) ) != IVAS_ERR_OK )
{
return error;
}
}
ELSE IF( EQ_16( st_ivas->nCPE, 1 ) ) /* Stereo DMX */
{
- IF( NE_32( ( error = ivas_cpe_enc_fx( st_ivas, 0, data_fx[0], data_fx[1], st_ivas->q_data_fx, input_frame, hMetaData->nb_bits_tot, NULL ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_cpe_enc_fx( st_ivas, 0, data_fx[0], data_fx[1], st_ivas->q_data_fx, input_frame, hMetaData->nb_bits_tot, NULL ) ) != IVAS_ERR_OK )
{
return error;
}
diff --git a/lib_enc/ivas_enc_cov_handler.c b/lib_enc/ivas_enc_cov_handler.c
index cf42f8cc89beccfe7ef532296592e76bac70d6ae..5c19d8e02de9052305c9c3746018a113f903b0a8 100644
--- a/lib_enc/ivas_enc_cov_handler.c
+++ b/lib_enc/ivas_enc_cov_handler.c
@@ -62,12 +62,12 @@ static void ivas_band_cov_fx( Word32 **ppIn_FR_real, Word32 **ppIn_FR_imag, Word
*------------------------------------------------------------------------*/
ivas_error ivas_spar_covar_enc_open_fx(
- ivas_enc_cov_handler_state_t **hCovEnc, /* i/o: SPAR Covar. encoder handle */
- ivas_filterbank_t *pFb, /* i/o: FB handle */
- const Word32 input_Fs, /* i : input sampling rate */
- const Word16 nchan_inp, /* i : number of input channels */
- const COV_SMOOTHING_TYPE smooth_mode, /* i : Smooth covariance for SPAR or MC*/
- const Word32 ivas_total_brate /* i : IVAS total bitrate */
+ ivas_enc_cov_handler_state_t **hCovEnc, /* i/o: SPAR Covar. encoder handle */
+ ivas_filterbank_t *pFb, /* i/o: FB handle */
+ const Word32 input_Fs, /* i : input sampling rate Q0*/
+ const Word16 nchan_inp, /* i : number of input channels Q0*/
+ const COV_SMOOTHING_TYPE smooth_mode, /* i : Smooth covariance for SPAR or MC */
+ const Word32 ivas_total_brate /* i : IVAS total bitrate Q0*/
)
{
ivas_enc_cov_handler_state_t *hCovState;
@@ -92,7 +92,7 @@ ivas_error ivas_spar_covar_enc_open_fx(
{
cov_smooth_cfg.max_update_rate_fx = ONE_IN_Q31; // Q31
move32();
- cov_smooth_cfg.min_pool_size = 20;
+ cov_smooth_cfg.min_pool_size = 20; // Q0
move16();
}
@@ -111,7 +111,7 @@ ivas_error ivas_spar_covar_enc_open_fx(
return error;
}
- hCovState->num_bins = extract_l( Mpy_32_32( input_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) );
+ hCovState->num_bins = extract_l( Mpy_32_32( input_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ); /* Q0 */
hCovState->prior_dtx_present = 0;
move16();
@@ -133,7 +133,7 @@ ivas_error ivas_spar_covar_enc_open_fx(
void ivas_spar_covar_enc_close_fx(
ivas_enc_cov_handler_state_t **hCovEnc, /* i/o: SPAR Covar. encoder handle */
- const Word16 nchan_inp /* i : number of input channels */
+ const Word16 nchan_inp /* i : number of input channels Q0*/
)
{
ivas_enc_cov_handler_state_t *hCovState;
@@ -165,14 +165,15 @@ void ivas_spar_covar_enc_close_fx(
static Word16 ivas_spar_get_activeW_flag_fx(
ivas_enc_cov_handler_state_t *hCovEnc,
- Word32 *cov_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH],
- Word32 *cov_dtx_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH],
+ Word32 *cov_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], /* q_cov_real */
+ Word32 *cov_dtx_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], /* q_cov_real */
Word16 *q_cov_real[IVAS_SPAR_MAX_CH],
- const Word16 dtx_vad,
- const Word16 nchan_inp,
- const Word16 nchan_transport,
- Word16 *res_ind,
- const Word16 *dmx_order )
+ const Word16 dtx_vad, /* Q0 */
+ const Word16 nchan_inp, /* Q0 */
+ const Word16 nchan_transport, /* Q0 */
+ Word16 *res_ind, /* Q0 */
+ const Word16 *dmx_order /* Q0 */
+)
{
Word16 b, ch, num_bands, num_chs, activeW_flag;
Word32 bb_var[FOA_CHANNELS], sm_fact, side_ch_var, en_ratio;
@@ -182,8 +183,8 @@ static Word16 ivas_spar_get_activeW_flag_fx(
Word32 L_tmp, L_tmp1;
Word16 exp_diff, q_com, guard_bits;
- num_chs = s_min( nchan_inp, FOA_CHANNELS );
- num_bands = ivas_get_num_bands_from_bw_idx( SPAR_CONFIG_BW );
+ num_chs = s_min( nchan_inp, FOA_CHANNELS ); /* Q0 */
+ num_bands = ivas_get_num_bands_from_bw_idx( SPAR_CONFIG_BW ); /* Q0 */
set_zero_fx( bb_var, FOA_CHANNELS );
set_s( q_bb_var, Q31, FOA_CHANNELS );
@@ -225,7 +226,7 @@ static Word16 ivas_spar_get_activeW_flag_fx(
q_shift = Q31;
move16();
q_shift = W_norm( bb_var_64bit[ch] );
- bb_var[ch] = W_extract_l( W_shl_nosat( bb_var_64bit[ch], sub( q_shift, 32 ) ) );
+ bb_var[ch] = W_extract_l( W_shl_nosat( bb_var_64bit[ch], sub( q_shift, 32 ) ) ); /* q_bb_var[ch] + sub( q_shift, 32 ) */
move32();
q_bb_var[ch] = add( q_bb_var[ch], sub( q_shift, 32 ) );
move16();
@@ -294,7 +295,7 @@ static Word16 ivas_spar_get_activeW_flag_fx(
{
Word16 max_idx;
Word32 max_val;
- max_idx = nchan_transport;
+ max_idx = nchan_transport; /* Q0 */
move16();
max_val = hCovEnc->bb_var_lt_fx[max_idx]; // q_bb_var[max_idx]
move32();
@@ -306,12 +307,12 @@ static Word16 ivas_spar_get_activeW_flag_fx(
move32();
}
}
- *res_ind = max_idx;
+ *res_ind = max_idx; /* Q0 */
move16();
}
ELSE IF( EQ_16( nchan_transport, 3 ) )
{
- *res_ind = dmx_order[nchan_transport];
+ *res_ind = dmx_order[nchan_transport]; /* Q0 */
move16();
}
}
@@ -328,25 +329,26 @@ return activeW_flag;
void ivas_enc_cov_handler_process_fx(
ivas_enc_cov_handler_state_t *hCovEnc, /* i/o: SPAR Covar. encoder handle */
- Word32 **ppIn_FR_real,
- Word32 **ppIn_FR_imag,
+ Word32 **ppIn_FR_real, /* q_ppIn_FR */
+ Word32 **ppIn_FR_imag, /* q_ppIn_FR */
Word16 q_ppIn_FR,
- Word32 *cov_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH],
+ Word32 *cov_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], /* q_cov_real */
Word16 *q_cov_real[IVAS_SPAR_MAX_CH],
- Word32 *cov_dtx_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH],
+ Word32 *cov_dtx_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], /* q_cov_dtx_real */
Word16 *q_cov_dtx_real[IVAS_SPAR_MAX_CH],
- ivas_filterbank_t *pFb, /* i/o: FB handle */
- const Word16 start_band,
- const Word16 end_band,
- const Word16 num_ch,
- const Word16 dtx_vad,
- const Word16 transient_det[2],
- const Word16 HOA_md_ind[IVAS_SPAR_MAX_CH],
- Word16 *res_ind,
- const Word16 *remix_order,
- Word16 *dyn_active_w_flag,
- const Word16 nchan_transport,
- const Word16 is_sba )
+ ivas_filterbank_t *pFb, /* i/o: FB handle */
+ const Word16 start_band, /* Q0 */
+ const Word16 end_band, /* Q0 */
+ const Word16 num_ch, /* Q0 */
+ const Word16 dtx_vad, /* Q0 */
+ const Word16 transient_det[2], /* Q0 */
+ const Word16 HOA_md_ind[IVAS_SPAR_MAX_CH], /* Q0 */
+ Word16 *res_ind, /* Q0 */
+ const Word16 *remix_order, /* Q0 */
+ Word16 *dyn_active_w_flag, /* Q0 */
+ const Word16 nchan_transport, /* Q0 */
+ const Word16 is_sba /* Q0 */
+)
{
Word16 i, j;
Word16 dtx_cov_flag;
@@ -410,7 +412,7 @@ void ivas_enc_cov_handler_process_fx(
move16();
IF( GT_16( nchan_transport, 1 ) && LE_16( nchan_transport, sub( FOA_CHANNELS, 1 ) ) )
{
- *dyn_active_w_flag = ivas_spar_get_activeW_flag_fx( hCovEnc, cov_real, cov_real, q_cov_real, dtx_vad, num_ch, nchan_transport, res_ind, remix_order );
+ *dyn_active_w_flag = ivas_spar_get_activeW_flag_fx( hCovEnc, cov_real, cov_real, q_cov_real, dtx_vad, num_ch, nchan_transport, res_ind, remix_order ); /* Q0 */
}
ELSE
{
@@ -423,7 +425,7 @@ void ivas_enc_cov_handler_process_fx(
{
FOR( j = 0; j < num_ch; j++ )
{
- Copy32( cov_real[i][j], cov_dtx_real[i][j], pFb->filterbank_num_bands );
+ Copy32( cov_real[i][j], cov_dtx_real[i][j], pFb->filterbank_num_bands ); /* q_cov_real */
q_cov_dtx_real[i][j] = q_cov_real[i][j];
move16();
}
@@ -437,13 +439,13 @@ void ivas_enc_cov_handler_process_fx(
{
FOR( j = 0; j < num_ch; j++ )
{
- Copy32( cov_real[i][j], hCovEnc->pCov_dtx_state->pPrior_cov_real_fx[i][j], pFb->filterbank_num_bands );
+ Copy32( cov_real[i][j], hCovEnc->pCov_dtx_state->pPrior_cov_real_fx[i][j], pFb->filterbank_num_bands ); /* q_cov_real */
FOR( k = 0; k < pFb->filterbank_num_bands; k++ )
{
hCovEnc->pCov_dtx_state->q_prior_cov_real_per_band[i][j][k] = hCovEnc->pCov_state->q_cov_real_per_band[i][j][k];
move16();
}
- Copy32( cov_real[i][j], cov_dtx_real[i][j], pFb->filterbank_num_bands );
+ Copy32( cov_real[i][j], cov_dtx_real[i][j], pFb->filterbank_num_bands ); /* q_cov_real */
Copy( hCovEnc->pCov_state->q_cov_real_per_band[i][j], hCovEnc->pCov_dtx_state->q_cov_real_per_band[i][j], pFb->filterbank_num_bands );
}
}
@@ -472,7 +474,7 @@ void ivas_enc_cov_handler_process_fx(
{
FOR( j = 0; j < num_ch; j++ )
{
- Copy32( hCovEnc->pCov_dtx_state->pPrior_cov_real_fx[i][j], cov_dtx_real[i][j], pFb->filterbank_num_bands );
+ Copy32( hCovEnc->pCov_dtx_state->pPrior_cov_real_fx[i][j], cov_dtx_real[i][j], pFb->filterbank_num_bands ); /* q_cov_real */
FOR( k = 0; k < pFb->filterbank_num_bands; k++ )
{
hCovEnc->pCov_dtx_state->q_cov_real_per_band[i][j][k] = hCovEnc->pCov_dtx_state->q_prior_cov_real_per_band[i][j][k];
@@ -491,34 +493,37 @@ void ivas_enc_cov_handler_process_fx(
static void ivas_band_cov_fx(
- Word32 **ppIn_FR_real,
- Word32 **ppIn_FR_imag,
+ Word32 **ppIn_FR_real, /* q_In_FR */
+ Word32 **ppIn_FR_imag, /* q_In_FR */
Word16 q_In_FR,
- const Word16 num_chans,
- const Word16 num_bins,
- Word16 stride,
- Word32 **pFb_bin_to_band,
- const Word16 *pFb_start_bin_per_band,
- const Word16 *pFb_active_bins_per_band,
- const Word16 start_band,
- const Word16 end_band,
- Word32 *cov_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH],
+ const Word16 num_chans, /* Q0 */
+ const Word16 num_bins, /* Q0 */
+ Word16 stride, /* Q0 */
+ Word32 **pFb_bin_to_band, /* Q22 */
+ const Word16 *pFb_start_bin_per_band, /* Q0 */
+ const Word16 *pFb_active_bins_per_band, /* Q0 */
+ const Word16 start_band, /* Q0 */
+ const Word16 end_band, /* Q0 */
+ Word32 *cov_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], /* q_cov_real */
Word16 *q_cov_real[IVAS_SPAR_MAX_CH],
- const Word16 HOA_md_ind[IVAS_SPAR_MAX_CH] )
+ const Word16 HOA_md_ind[IVAS_SPAR_MAX_CH] /* Q0 */
+)
{
Word16 i, j, k;
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++ )
{
- Word16 i1 = HOA_md_ind[i];
- Word16 j1 = HOA_md_ind[j];
+ Word16 i1 = HOA_md_ind[i]; /* Q0 */
+ Word16 j1 = HOA_md_ind[j]; /* Q0 */
move16();
move16();
@@ -533,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 );
}
@@ -553,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 );
+ start_bin = pFb_start_bin_per_band[k]; /* Q0 */
move16();
- start_bin = pFb_start_bin_per_band[k];
- move16();
- active_bins = pFb_active_bins_per_band[k];
+ 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();
@@ -592,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 ) ) );
+ 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_entropy_coder.c b/lib_enc/ivas_entropy_coder.c
index 9949aab631b0a61d79d957f54ed71601fc9fdf6e..da4826776567c8b471c1c3ffaa35ace99882d301 100644
--- a/lib_enc/ivas_entropy_coder.c
+++ b/lib_enc/ivas_entropy_coder.c
@@ -51,18 +51,19 @@
*-----------------------------------------------------------------------------------------*/
static ivas_error ivas_get_dyn_freq_model_fx(
- Word16 *pInput,
- const Word16 length,
- Word16 *model_index,
+ Word16 *pInput, /* Q0 */
+ const Word16 length, /* Q0 */
+ Word16 *model_index, /* Q0 */
ivas_arith_t *pArith,
- Word16 **ppCum_freq )
+ Word16 **ppCum_freq /* Q0 */
+)
{
Word32 curr_dist[IVAS_MAX_QUANT_LEVELS];
Word16 i, n[IVAS_MAX_QUANT_LEVELS + 1], model_idx;
Word32 curr_bps, curr_bps_min, curr_bps_new;
Word16 range = pArith->range;
Word16 m;
- Word16 offset = negate( pArith->vals[0] );
+ Word16 offset = negate( pArith->vals[0] ); /* Q0 */
ivas_error error;
error = IVAS_ERR_OK;
move32();
@@ -75,7 +76,7 @@ static ivas_error ivas_get_dyn_freq_model_fx(
FOR( i = 0; i < length; i++ )
{
- n[pInput[i] + offset] = add( n[pInput[i] + offset], 1 );
+ n[pInput[i] + offset] = add( n[pInput[i] + offset], 1 ); /* Q0 */
move16();
}
@@ -85,7 +86,7 @@ static ivas_error ivas_get_dyn_freq_model_fx(
{
curr_dist[i] = L_deposit_l( n[i] );
move32();
- curr_bps = L_sub( curr_bps, curr_dist[i] * pArith->saved_dist_arr[0][i] );
+ curr_bps = L_sub( curr_bps, W_extract_l( W_mult0_32_32( curr_dist[i], pArith->saved_dist_arr[0][i] ) ) );
}
curr_bps_min = curr_bps;
move32();
@@ -104,7 +105,7 @@ static ivas_error ivas_get_dyn_freq_model_fx(
move32();
FOR( i = 0; i < range; i++ )
{
- curr_bps_new = L_sub( curr_bps_new, ( curr_dist[i] * pArith->saved_dist_arr[m + 1][i] ) );
+ curr_bps_new = L_sub( curr_bps_new, W_extract_l( W_mult0_32_32( curr_dist[i], pArith->saved_dist_arr[m + 1][i] ) ) );
}
#ifdef DEBUGGING
{
@@ -123,32 +124,34 @@ static ivas_error ivas_get_dyn_freq_model_fx(
IF( LT_32( curr_bps_min, curr_bps ) )
{
- *ppCum_freq = pArith->cum_freq[model_idx + 1];
- model_idx = add( model_idx, 1 );
+ *ppCum_freq = pArith->cum_freq[model_idx + 1]; /* Q0 */
+ model_idx = add( model_idx, 1 ); /* Q0 */
}
ELSE
{
model_idx = 0;
- *ppCum_freq = pArith->cum_freq[0];
+ move16();
+ *ppCum_freq = pArith->cum_freq[0]; /* Q0 */
}
- *model_index = model_idx;
+ *model_index = model_idx; /* Q0 */
move16();
return error;
}
/*-----------------------------------------------------------------------------------------*
- * Function ivas_arith_encode_array()
+ * Function ivas_arith_encode_array_fx()
*
* Arith encoding of an array of symbols
*-----------------------------------------------------------------------------------------*/
-static Word16 ivas_arith_encode_array(
- Word16 *pInput,
+static Word16 ivas_arith_encode_array_fx(
+ Word16 *pInput, /* Q0 */
ivas_arith_t *pArith,
BSTR_ENC_HANDLE hMetaData,
- const Word16 in_len,
- const Word16 wc_strat_arith )
+ const Word16 in_len, /* Q0 */
+ const Word16 wc_strat_arith /* Q0 */
+)
{
Word16 model_index, i, ind;
Word16 *pCum_freq = NULL;
@@ -168,14 +171,14 @@ static Word16 ivas_arith_encode_array(
}
ELSE
{
- pCum_freq = pArith->cum_freq[0];
+ pCum_freq = pArith->cum_freq[0]; /* Q0 */
}
ari_start_encoding_14bits( &as );
FOR( i = 0; i < in_len; i++ )
{
- ind = sub( pInput[i], pArith->vals[0] );
+ ind = sub( pInput[i], pArith->vals[0] ); /* Q0 */
ivas_ari_encode_14bits_ext_fx( hMetaData, &as, ind, (const UWord16 *) pCum_freq );
IF( GT_16( hMetaData->nb_bits_tot, wc_strat_arith ) )
{
@@ -195,18 +198,19 @@ static Word16 ivas_arith_encode_array(
/*-----------------------------------------------------------------------------------------*
- * Function ivas_arithCoder_encode_array_diff()
+ * Function ivas_arithCoder_encode_array_diff_fx()
*
* Differential arith encoding
*-----------------------------------------------------------------------------------------*/
-static Word16 ivas_arithCoder_encode_array_diff(
+static Word16 ivas_arithCoder_encode_array_diff_fx(
ivas_arith_t *pArith_diff,
- Word16 *pIn_new,
- Word16 *pIn_old_scratch,
- const Word16 length,
+ Word16 *pIn_new, /* Q0 */
+ Word16 *pIn_old_scratch, /* Q0 */
+ const Word16 length, /* Q0 */
BSTR_ENC_HANDLE hMetaData,
- const Word16 wc_strat_arith )
+ const Word16 wc_strat_arith /* Q0 */
+)
{
Word16 n;
Word16 arith_result;
@@ -215,13 +219,13 @@ static Word16 ivas_arithCoder_encode_array_diff(
{
FOR( n = 0; n < length; n++ )
{
- pIn_old_scratch[n] = sub( pIn_new[n], pIn_old_scratch[n] );
+ pIn_old_scratch[n] = sub( pIn_new[n], pIn_old_scratch[n] ); /* Q0 */
move16();
}
ivas_wrap_arround_fx( pIn_old_scratch, pArith_diff->vals[0], pArith_diff->vals[pArith_diff->range - 1], length );
- arith_result = ivas_arith_encode_array( pIn_old_scratch, pArith_diff, hMetaData, length, wc_strat_arith );
+ arith_result = ivas_arith_encode_array_fx( pIn_old_scratch, pArith_diff, hMetaData, length, wc_strat_arith ); /* Q0 */
IF( arith_result < 0 )
{
return -1;
@@ -233,27 +237,28 @@ static Word16 ivas_arithCoder_encode_array_diff(
/*-----------------------------------------------------------------------------------------*
- * Function ivas_huffman_encode()
+ * Function ivas_huffman_encode_fx()
*
* ivas_huffman_encode
*-----------------------------------------------------------------------------------------*/
-void ivas_huffman_encode(
+void ivas_huffman_encode_fx(
ivas_huffman_cfg_t *huff_cfg,
- Word16 in,
- Word16 *hcode,
- Word16 *hlen )
+ Word16 in, /* Q0 */
+ Word16 *hcode, /* Q0 */
+ Word16 *hlen /* Q0 */
+)
{
Word16 min_sym_val;
const Word16 *codebook;
- min_sym_val = huff_cfg->codebook[0];
+ min_sym_val = huff_cfg->codebook[0]; /* Q0 */
move16();
- codebook = &huff_cfg->codebook[3 * ( in - min_sym_val )];
- *hlen = codebook[1];
+ codebook = &huff_cfg->codebook[3 * ( in - min_sym_val )]; /* Q0 */
+ *hlen = codebook[1]; /* Q0 */
move16();
- *hcode = codebook[2];
+ *hcode = codebook[2]; /* Q0 */
move16();
return;
@@ -261,17 +266,17 @@ void ivas_huffman_encode(
/*-----------------------------------------------------------------------------------------*
- * Function arith_encode_cell_array()
+ * Function arith_encode_cell_array_fx()
*
* Arithmetic encode a cell array
*-----------------------------------------------------------------------------------------*/
-static Word16 arith_encode_cell_array(
+static Word16 arith_encode_cell_array_fx(
ivas_cell_dim_t *pCell_dims,
BSTR_ENC_HANDLE hMetaData,
- const Word16 nB,
+ const Word16 nB, /* Q0 */
ivas_arith_t *pArith,
- Word16 *pSymbol,
+ Word16 *pSymbol, /* Q0 */
const Word16 wc_strat_arith )
{
Word16 total_symbol_len = 0;
@@ -281,7 +286,7 @@ static Word16 arith_encode_cell_array(
FOR( i = 0; i < nB; i++ )
{
- total_symbol_len = add( total_symbol_len, imult1616( pCell_dims[i].dim1, pCell_dims[i].dim2 ) );
+ total_symbol_len = add( total_symbol_len, imult1616( pCell_dims[i].dim1, pCell_dims[i].dim2 ) ); /* Q0 */
}
assert( LE_16( total_symbol_len, ( IVAS_MAX_INPUT_LEN ) ) );
@@ -290,7 +295,7 @@ static Word16 arith_encode_cell_array(
{
IF( GT_16( pArith->range, 1 ) )
{
- arith_result = ivas_arith_encode_array( pSymbol, pArith, hMetaData, total_symbol_len, wc_strat_arith );
+ arith_result = ivas_arith_encode_array_fx( pSymbol, pArith, hMetaData, total_symbol_len, wc_strat_arith ); /* Q0 */
IF( arith_result < 0 )
{
return -1;
@@ -303,19 +308,20 @@ static Word16 arith_encode_cell_array(
/*-----------------------------------------------------------------------------------------*
- * Function arith_encode_cell_array_diff()
+ * Function arith_encode_cell_array_diff_fx()
*
* Arithmetic encode a cell array - differential
*-----------------------------------------------------------------------------------------*/
-static Word16 arith_encode_cell_array_diff(
+static Word16 arith_encode_cell_array_diff_fx(
const ivas_cell_dim_t *pCell_dims,
BSTR_ENC_HANDLE hMetaData,
- Word16 nB,
+ Word16 nB, /* Q0 */
ivas_arith_t *pArith_diff,
- Word16 *pSymbol_old,
- Word16 *pSymbol,
- const Word16 wc_strat_arith )
+ Word16 *pSymbol_old, /* Q0 */
+ Word16 *pSymbol, /* Q0 */
+ const Word16 wc_strat_arith /* Q0 */
+)
{
Word16 i, total_symbol_len;
Word16 arith_result;
@@ -324,7 +330,7 @@ static Word16 arith_encode_cell_array_diff(
move16();
FOR( i = 0; i < nB; i++ )
{
- total_symbol_len = add( total_symbol_len, ( imult1616( pCell_dims[i].dim1, pCell_dims[i].dim2 ) ) );
+ total_symbol_len = add( total_symbol_len, ( imult1616( pCell_dims[i].dim1, pCell_dims[i].dim2 ) ) ); /* Q0 */
}
assert( LE_16( total_symbol_len, ( IVAS_MAX_INPUT_LEN ) ) );
@@ -333,7 +339,7 @@ static Word16 arith_encode_cell_array_diff(
{
IF( GT_16( pArith_diff->range, 1 ) )
{
- arith_result = ivas_arithCoder_encode_array_diff( pArith_diff, pSymbol, pSymbol_old, total_symbol_len, hMetaData, wc_strat_arith );
+ arith_result = ivas_arithCoder_encode_array_diff_fx( pArith_diff, pSymbol, pSymbol_old, total_symbol_len, hMetaData, wc_strat_arith ); /* Q0 */
IF( arith_result < 0 )
{
return -1;
@@ -346,22 +352,23 @@ static Word16 arith_encode_cell_array_diff(
/*-----------------------------------------------------------------------------------------*
- * Function ivas_arith_encode_cmplx_cell_array()
+ * Function ivas_arith_encode_cmplx_cell_array_fx()
*
* Arithmetic encode a cell array
*-----------------------------------------------------------------------------------------*/
-Word16 ivas_arith_encode_cmplx_cell_array(
+Word16 ivas_arith_encode_cmplx_cell_array_fx(
ivas_arith_t *pArith_re,
ivas_arith_t *pArith_re_diff,
- const Word16 *pDo_diff,
- const Word16 nB,
- Word16 *pSymbol_re,
- Word16 *pSymbol_old_re,
+ const Word16 *pDo_diff, /* Q0 */
+ const Word16 nB, /* Q0 */
+ Word16 *pSymbol_re, /* Q0 */
+ Word16 *pSymbol_old_re, /* Q0 */
ivas_cell_dim_t *pCell_dims,
BSTR_ENC_HANDLE hMetaData,
- const Word16 any_diff,
- const Word16 wc_strat_arith )
+ const Word16 any_diff, /* Q0 */
+ const Word16 wc_strat_arith /* Q0 */
+)
{
Word16 input_old[IVAS_MAX_INPUT_LEN];
Word16 input_new[IVAS_MAX_INPUT_LEN];
@@ -381,19 +388,19 @@ Word16 ivas_arith_encode_cmplx_cell_array(
move16();
FOR( i = 0; i < nB; i++ )
{
- len = ( imult1616( pCell_dims[i].dim1, pCell_dims[i].dim2 ) );
+ len = ( imult1616( pCell_dims[i].dim1, pCell_dims[i].dim2 ) ); /* Q0 */
move16();
IF( pDo_diff[i] != 0 )
{
FOR( j = 0; j < len; j++ )
{
- input_old[idx] = pSymbol_old_re[total_len + j];
- input_new[idx++] = pSymbol_re[total_len + j];
+ input_old[idx] = pSymbol_old_re[total_len + j]; /* Q0 */
+ input_new[idx++] = pSymbol_re[total_len + j]; /* Q0 */
move16();
move16();
}
- cell_dim_diff[i].dim1 = pCell_dims[i].dim1;
- cell_dim_diff[i].dim2 = pCell_dims[i].dim2;
+ cell_dim_diff[i].dim1 = pCell_dims[i].dim1; /* Q0 */
+ cell_dim_diff[i].dim2 = pCell_dims[i].dim2; /* Q0 */
cell_dim[i].dim1 = 0;
cell_dim[i].dim2 = 0;
move16();
@@ -405,28 +412,28 @@ Word16 ivas_arith_encode_cmplx_cell_array(
{
FOR( j = 0; j < len; j++ )
{
- input[idx1++] = pSymbol_re[total_len + j];
+ input[idx1++] = pSymbol_re[total_len + j]; /* Q0 */
move16();
}
cell_dim_diff[i].dim1 = 0;
cell_dim_diff[i].dim2 = 0;
- cell_dim[i].dim1 = pCell_dims[i].dim1;
- cell_dim[i].dim2 = pCell_dims[i].dim2;
+ cell_dim[i].dim1 = pCell_dims[i].dim1; /* Q0 */
+ cell_dim[i].dim2 = pCell_dims[i].dim2; /* Q0 */
move16();
move16();
move16();
move16();
}
- total_len = add( total_len, len );
+ total_len = add( total_len, len ); /* Q0 */
}
- arith_result = arith_encode_cell_array( cell_dim, hMetaData, nB, pArith_re, input, wc_strat_arith );
+ arith_result = arith_encode_cell_array_fx( cell_dim, hMetaData, nB, pArith_re, input, wc_strat_arith ); /* Q0 */
IF( arith_result < 0 )
{
return -1;
}
- arith_result = arith_encode_cell_array_diff( cell_dim_diff, hMetaData, nB, pArith_re_diff, input_old, input_new, wc_strat_arith );
+ arith_result = arith_encode_cell_array_diff_fx( cell_dim_diff, hMetaData, nB, pArith_re_diff, input_old, input_new, wc_strat_arith ); /* Q0 */
move16();
IF( arith_result < 0 )
{
@@ -435,7 +442,7 @@ Word16 ivas_arith_encode_cmplx_cell_array(
}
ELSE
{
- arith_result = arith_encode_cell_array( pCell_dims, hMetaData, nB, pArith_re, pSymbol_re, wc_strat_arith );
+ arith_result = arith_encode_cell_array_fx( pCell_dims, hMetaData, nB, pArith_re, pSymbol_re, wc_strat_arith ); /* Q0 */
IF( arith_result < 0 )
{
return -1;
diff --git a/lib_enc/ivas_front_vad.c b/lib_enc/ivas_front_vad.c
index f892dca8f87d7936ebbb81c09e093f94221a4a7c..f52bdadb460c4bca9fedea4aab0ca732f65a2455 100644
--- a/lib_enc/ivas_front_vad.c
+++ b/lib_enc/ivas_front_vad.c
@@ -52,21 +52,25 @@
* Standalone front-VAD module
*-----------------------------------------------------------------------------------------*/
ivas_error front_vad_fx(
- CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure, nullable */
- Encoder_State *st, /* i/o: encoder state structure */
- const ENCODER_CONFIG_HANDLE hEncoderConfig, /* i : configuration structure */
- FRONT_VAD_ENC_HANDLE *hFrontVads, /* i/o: FrontVad handles */
- const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) */
- const Word16 input_frame, /* i : frame length */
- Word16 vad_flag_dtx[], /* o : HE-SAD flag with additional DTX HO */
- Word32 fr_bands_fx[][2 * NB_BANDS], /* o : energy in frequency bands Q_buffer[n] + QSCALE + 2 */
- Word16 Etot_LR_fx[], /* o : total energy Left & Right channel Q8 */
- Word32 lf_E_fx[][2 * VOIC_BINS], /* i : per bin spectrum energy in lf, LR channels Q_buffer[n] + QSCALE */
- Word16 localVAD_HE_SAD[], /* o : HE-SAD flag without hangover, LR channels */
- Word16 vad_hover_flag[], /* o : VAD hangover flag */
- Word32 band_energies_LR_fx[2 * NB_BANDS], /* o : energy in critical bands without minimum noise floor E_MIN Q_buffer[1] + QSCALE + 2 - band_ener_guardbits*/
- Word32 *PS_out_fx, /* o : energy spectrum Q_buffer + QSCALE */
- Word16 *Bin_E_out_fx, /* o : log-energy spectrum of the current frame Q7 */
+ CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure, nullable */
+ Encoder_State *st, /* i/o: encoder state structure */
+ const ENCODER_CONFIG_HANDLE hEncoderConfig, /* i : configuration structure */
+ FRONT_VAD_ENC_HANDLE *hFrontVads, /* i/o: FrontVad handles */
+ const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/
+ const Word16 input_frame, /* i : frame length Q0*/
+ Word16 vad_flag_dtx[], /* o : HE-SAD flag with additional DTX HO Q0*/
+ Word32 fr_bands_fx[][2 * NB_BANDS], /* o : energy in frequency bands q_fr_bands_fx*/
+ Word16 q_fr_bands[], /* o : Q of fr_bands_fx */
+ Word16 Etot_LR_fx[], /* o : total energy Left & Right channel Q8*/
+ Word32 lf_E_fx[][2 * VOIC_BINS], /* i : per bin spectrum energy in lf, LR channels q_lf_E*/
+ Word16 q_lf_E[], /* o : Q of lf_E_fx */
+ Word16 localVAD_HE_SAD[], /* o : HE-SAD flag without hangover, LR channels Q0*/
+ Word16 vad_hover_flag[], /* o : VAD hangover flag Q0*/
+ Word32 band_energies_LR_fx[2 * NB_BANDS], /* o : energy in critical bands without minimum noise floor E_MIN q_band_energies_LR */
+ Word16 *q_band_energies_LR, /* o : Q of band_energies_LR_fx */
+ Word32 *PS_out_fx, /* o : energy spectrum q_PS_out*/
+ Word16 *q_PS_out, /* o : Q of PS_out_fx Q0*/
+ Word16 *Bin_E_out_fx, /* o : log-energy spectrum of the current frame Q7*/
Word16 Q_inp,
Word16 *Q_buffer,
Word16 Q_add,
@@ -86,24 +90,30 @@ ivas_error front_vad_fx(
Word16 dummy_short;
Word16 element_mode, last_element_mode;
ivas_error error;
- Word16 Q_new = 0, band_ener_guardbits = 0;
+ Word16 Q_new;
Word16 Qband, mem_decim_size;
error = IVAS_ERR_OK;
push_wmops( "front_vad" );
+ move16();
+ move16();
+
+ Q_new = 0;
+ move16();
lgBin_E_fx = NULL;
if ( st != NULL )
{
- lgBin_E_fx = &st->lgBin_E_fx[0];
+ lgBin_E_fx = &st->lgBin_E_fx[0]; /* Q8 */
move16();
}
IF( hCPE != NULL )
{
n_chan = CPE_CHANNELS;
+ move16();
sts = &hCPE->hCoreCoder[0];
- element_mode = hCPE->element_mode;
+ element_mode = hCPE->element_mode; /* Q0 */
move16();
- last_element_mode = hCPE->last_element_mode;
+ last_element_mode = hCPE->last_element_mode; /* Q0 */
move16();
}
ELSE IF( st != NULL )
@@ -186,19 +196,32 @@ ivas_error front_vad_fx(
set_val_Word32( band_energies_LR_fx, 0, 2 * NB_BANDS );
Qband = -1;
move16();
- Word16 Q_new_old = add( sub( Q_inp, Qband ), Q_add );
IF( *front_create_flag )
{
+ Word16 scale_inp = Q15;
+ Q_add = 0;
+ move16();
FOR( n = 0; n < n_chan; n++ )
{
- scale_sig32( hFrontVads[n]->hNoiseEst->bckr_fx, 20, sub( add( Q_new_old, QSCALE ), Q11 ) );
- scale_sig32( hFrontVads[n]->hNoiseEst->enrO_fx, 20, sub( add( Q_new_old, QSCALE ), Q11 ) );
hFrontVads[n]->lp_speech_fx = shr( hFrontVads[n]->lp_speech_fx, 1 );
move16();
+
+ scale_inp = s_min( sts[n]->q_inp, hCPE->hFrontVad[n]->q_mem_decim );
+ Scale_sig( sts[n]->input_fx, input_frame, sub( scale_inp, sts[n]->q_inp ) );
+ Scale_sig( hCPE->hFrontVad[n]->mem_decim_fx, 2 * L_FILT_MAX, sub( scale_inp, hCPE->hFrontVad[n]->q_mem_decim ) );
+ sts[n]->q_inp = scale_inp;
+ hCPE->hFrontVad[n]->q_mem_decim = scale_inp;
+ Q_inp = scale_inp;
+ move16();
+ Q_buffer[n] = hCPE->hFrontVad[n]->q_buffer_12k8;
+ move16();
}
}
- band_ener_guardbits = find_guarded_bits_fx( 2 * NB_BANDS );
+
+ Word16 q_Bin_E, q_Bin_E_old;
+ Word16 q_band_energies;
+ Word16 q_fft_buffLR;
FOR( n = 0; n < n_chan; n++ )
{
FRONT_VAD_ENC_HANDLE hFrontVad;
@@ -212,50 +235,80 @@ ivas_error front_vad_fx(
modify_Fs_fx( sts[n]->input_fx, input_frame, sts[0]->input_Fs, hFrontVad->buffer_12k8_fx + L_FFT / 2, INT_FS_12k8, hFrontVad->mem_decim_fx, ( sts[0]->max_bwidth == NB ), &Qband, &mem_decim_size );
/* Preemphasis */
- hFrontVad->mem_preemph_fx = shl( hFrontVad->mem_preemph_fx, sub( add( Q_inp, Qband ), hFrontVad->q_mem_preemph_fx ) );
+ hFrontVad->mem_preemph_fx = shl( hFrontVad->mem_preemph_fx, sub( add( Q_inp, Qband ), hFrontVad->q_mem_preemph_fx ) ); /* Q_inp + Qband */
move16();
hFrontVad->q_mem_preemph_fx = add( Q_inp, Qband );
move16();
PREEMPH_FX( hFrontVad->buffer_12k8_fx + L_FFT / 2, PREEMPH_FAC, L_FRAME, &hFrontVad->mem_preemph_fx );
- Word16 Scale_fac[2];
Q_new = add( sub( Q_inp, Qband ), Q_add );
- Scale_sig( hFrontVad->buffer_12k8_fx, L_FFT / 2, Q_new - Q_buffer[n] );
- Scale_sig( hFrontVad->buffer_12k8_fx + L_FFT / 2, 384 - L_FFT / 2, Q_new - add( Q_inp, Qband ) );
+ Scale_sig( hFrontVad->buffer_12k8_fx, L_FFT / 2, sub( Q_new, Q_buffer[n] ) ); /* Q_new */
+ Scale_sig( hFrontVad->buffer_12k8_fx + L_FFT / 2, 384 - L_FFT / 2, sub( Q_new, add( Q_inp, Qband ) ) ); /* Q_new */
Q_buffer[n] = Q_new;
- Word32 Le_min_scaled = L_shr_r( L_add( L_shr( E_MIN_FXQ15, sub( 14, add( Q_new, QSCALE ) ) ), 1 ), 1 );
- Le_min_scaled = L_shl( Le_min_scaled, 2 );
- ivas_analy_sp_fx( IVAS_CPE_TD, hCPE, sts[0]->input_Fs, hFrontVad->buffer_12k8_fx + L_FFT / 2 - 3 * ( L_SUBFR / 2 ), Q_new, fr_bands_fx[n], lf_E_fx[n], &Etot_LR_fx[n], sts[0]->min_band, sts[0]->max_band, Le_min_scaled, Scale_fac, Bin_E_fx, Bin_E_old_fx, PS_fx, lgBin_E_fx, band_energies_fx, fft_buffLR_fx );
+ move16();
+
+ ivas_analy_sp_fx( IVAS_CPE_TD, hCPE, sts[0]->input_Fs, hFrontVad->buffer_12k8_fx + L_FFT / 2 - 3 * ( L_SUBFR / 2 ), Q_new, fr_bands_fx[n],
+ &q_fr_bands[n], lf_E_fx[n], &q_lf_E[n], &Etot_LR_fx[n], sts[0]->min_band, sts[0]->max_band, Bin_E_fx, &q_Bin_E, Bin_E_old_fx,
+ &q_Bin_E_old, PS_fx, q_PS_out, lgBin_E_fx, band_energies_fx, &q_band_energies, fft_buffLR_fx, &q_fft_buffLR );
+ if ( n == 0 )
+ {
+ *q_band_energies_LR = q_band_energies;
+ move16();
+ }
+
+ /* v_add( &band_energies[0], &band_energies_LR[0], &band_energies_LR[0], 2 * NB_BANDS ); */
+ IF( EQ_16( n, 1 ) )
+ {
+ IF( LT_16( *q_band_energies_LR, q_band_energies ) )
+ {
+ scale_sig32( band_energies_fx, 2 * NB_BANDS, sub( *q_band_energies_LR, q_band_energies ) ); // q_band_energies_LR
+ }
+ ELSE
+ {
+ scale_sig32( band_energies_LR_fx, 2 * NB_BANDS, sub( q_band_energies, *q_band_energies_LR ) ); // q_band_energies_LR
+ *q_band_energies_LR = q_band_energies;
+ move16();
+ }
+ }
+
+ v_add_fx( &band_energies_fx[0], &band_energies_LR_fx[0], &band_energies_LR_fx[0], 2 * NB_BANDS ); // q_band_energies_LR
/* add up energies for later calculating average of channel energies */
- // Scale_sig32( &band_energies_LR_fx[0], ( Q_new + QSCALE + 2 ) - ( Q_new_old + QSCALE + 2 - band_ener_guardbits ), 40 );
- Q_new_old = Q_new;
- v_add_fixed( &band_energies_fx[0], &band_energies_LR_fx[0], &band_energies_LR_fx[0], 2 * NB_BANDS, band_ener_guardbits );
- Word32 Etot_fx = L_deposit_h( Etot_LR_fx[n] );
+ Word32 Etot_fx = L_deposit_h( Etot_LR_fx[n] ); /* Q24 */
noise_est_pre_32fx( Etot_fx, hFrontVads[0]->ini_frame, hFrontVad->hNoiseEst, 0, 0, 0 );
/* wb_vad */
- Scale_sig32( hFrontVads[n]->hNoiseEst->bckr_fx, NB_BANDS, Q_new + QSCALE - ( Q_new_old + QSCALE ) );
- Scale_sig32( hFrontVads[n]->hNoiseEst->enrO_fx, NB_BANDS, Q_new + QSCALE - ( Q_new_old + QSCALE ) );
- hFrontVad->hVAD->vad_flag = wb_vad_ivas_fx( sts[n], fr_bands_fx[n], &dummy, &dummy, &dummy, &snr_sum_he_fx, &localVAD_HE_SAD[n], &dummy_short, Q_new, hFrontVad->hVAD, hFrontVad->hNoiseEst, hFrontVad->lp_speech_fx, hFrontVad->lp_noise_fx );
+ 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;
+ move16();
+
+ scale_sig32( fr_bands_fx[n], 2 * NB_BANDS, sub( scale, q_fr_bands[n] ) ); // scale
+ q_fr_bands[n] = scale;
+ move16();
+
+ hFrontVad->hVAD->vad_flag = wb_vad_ivas_fx( sts[n], fr_bands_fx[n], q_fr_bands[n], &dummy, &dummy, &dummy, &snr_sum_he_fx,
+ &localVAD_HE_SAD[n], &dummy_short, hFrontVad->hVAD, hFrontVad->hNoiseEst,
+ hFrontVad->lp_speech_fx, hFrontVad->lp_noise_fx ); // Q0
test();
test();
if ( n == 0 && GT_16( n_chan, 1 ) && EQ_16( last_element_mode, IVAS_CPE_DFT ) )
{
- sts[1]->last_coder_type = sts[0]->last_coder_type;
+ sts[1]->last_coder_type = sts[0]->last_coder_type; /* Q0 */
move16();
}
- vad_flag_dtx[n] = ivas_dtx_hangover_addition_fx( sts[n], hFrontVad->hVAD->vad_flag, hFrontVad->lp_speech_fx - hFrontVad->lp_noise_fx, 0 /* <- no cldfb addition */, &vad_hover_flag[n], hFrontVad->hVAD, hFrontVad->hNoiseEst, &hFrontVads[n]->rem_dtx_ho );
+ vad_flag_dtx[n] = ivas_dtx_hangover_addition_fx( sts[n], hFrontVad->hVAD->vad_flag, sub( hFrontVad->lp_speech_fx, hFrontVad->lp_noise_fx ), 0 /* <- no cldfb addition */, &vad_hover_flag[n], hFrontVad->hVAD, hFrontVad->hNoiseEst, &hFrontVads[n]->rem_dtx_ho ); /* Q0 */
move16();
if ( EQ_16( n_chan, 1 ) )
{
- sts[n]->vad_flag = hFrontVad->hVAD->vad_flag;
+ sts[n]->vad_flag = hFrontVad->hVAD->vad_flag; /* Q0 */
move16();
}
}
@@ -263,10 +316,12 @@ ivas_error front_vad_fx(
IF( EQ_16( n_chan, CPE_CHANNELS ) )
{
/* get average channel energies, adding up was already done, so only need to scale by number of channels */
- v_multc_fixed( &band_energies_LR_fx[0], ONE_IN_Q30, &band_energies_LR_fx[0], 2 * NB_BANDS );
+ v_multc_fixed( &band_energies_LR_fx[0], ONE_IN_Q30 /* 0.5f in Q31 */, &band_energies_LR_fx[0], 2 * NB_BANDS );
/* Logical OR between L and R decisions */
+ test();
vad_flag_dtx[0] = vad_flag_dtx[0] || vad_flag_dtx[1];
+ move16();
}
IF( sts[0]->hFdCngEnc != NULL )
{
@@ -354,8 +409,8 @@ ivas_error front_vad_create_fx(
move16();
hFrontVad->q_mem_preemph_fx = Q15;
move16();
- hFrontVad->q_buffer_12k8 = Q31;
- hFrontVad->q_mem_decim = Q31;
+ hFrontVad->q_buffer_12k8 = Q15;
+ hFrontVad->q_mem_decim = Q15;
hFrontVad->ini_frame = 0;
move16();
hFrontVad->hVAD->vad_flag = 1;
@@ -433,10 +488,10 @@ void front_vad_destroy_fx(
* Standalone front-VAD module for SPAR
*-----------------------------------------------------------------------------------------*/
ivas_error front_vad_spar_fx(
- SPAR_ENC_HANDLE hSpar, /* i/o: SPAR encoder structure */
- const Word32 *omni_in, /* i : omnidirectional input signal Q11 */
- ENCODER_CONFIG_HANDLE hEncoderConfig, /* i : encoder configuration handle */
- const Word16 input_frame /* i : input frame length */
+ SPAR_ENC_HANDLE hSpar, /* i/o: SPAR encoder structure */
+ const Word32 *omni_in, /* i : omnidirectional input signal Q11*/
+ ENCODER_CONFIG_HANDLE hEncoderConfig, /* i : encoder configuration handle */
+ const Word16 input_frame /* i : input frame length Q0*/
)
{
FRONT_VAD_ENC_HANDLE hFrontVad;
@@ -488,6 +543,7 @@ ivas_error front_vad_spar_fx(
Word16 tmp;
Word16 old_pitch;
ivas_error error;
+ Word16 Qfact_PS;
push_wmops( "front_vad_SPAR" );
error = IVAS_ERR_OK;
@@ -506,15 +562,6 @@ ivas_error front_vad_spar_fx(
move16();
Word16 front_create_flag = 0;
move16();
- Word16 Qband = -1;
- move16();
- Word16 Q_bands = Q9;
- move16();
-
- Scale_sig32( hFrontVad->hNoiseEst->ave_enr_fx, NB_BANDS, ( Q_bands + QSCALE ) - hFrontVad->hNoiseEst->ave_enr_q );
- Scale_sig32( hFrontVad->hNoiseEst->ave_enr2_fx, NB_BANDS, ( Q_bands + QSCALE ) - hFrontVad->hNoiseEst->ave_enr_q );
- hFrontVad->hNoiseEst->ave_enr_q = ( Q_bands + QSCALE );
- move16();
Word16 tmp1;
Word16 Q_inp_12k8 = hFrontVad->q_buffer_12k8;
move16();
@@ -525,8 +572,8 @@ ivas_error front_vad_spar_fx(
MVR2R_WORD16( st->old_wsp_fx, old_wsp_fx, L_WSP_MEM );
wsp_fx = old_wsp_fx + L_WSP_MEM;
- st->core_brate = -1; /* updated in dtx() */
- st->input_bwidth = st->last_input_bwidth;
+ st->core_brate = -1; /* updated in dtx() */
+ st->input_bwidth = st->last_input_bwidth; /* Q0 */
move32();
move16();
@@ -535,7 +582,7 @@ ivas_error front_vad_spar_fx(
*-----------------------------------------------------------------*/
st->input_fx = input_fx;
- Copy_Scale_sig32_16( omni_in, st->input_fx, input_frame, Q16 - Q11 );
+ Copy_Scale_sig32_16( omni_in, st->input_fx, input_frame, Q16 - Q11 ); /* Q16 */
delay_signal( st->input_fx, input_frame, hFrontVad->delay_buf_fx, hFrontVad->delay_samples );
/* Scaling only if the omni_in buffer contains non-zero values */
@@ -559,7 +606,7 @@ ivas_error front_vad_spar_fx(
}
IF( tmp != 0 )
{
- Scale_sig( st->input_fx, input_frame, s );
+ Scale_sig( st->input_fx, input_frame, s ); /* s */
}
Q_inp = s;
move16();
@@ -568,18 +615,17 @@ ivas_error front_vad_spar_fx(
*-----------------------------------------------------------------*/
Word16 scale;
- Word16 Q_new_old = add( sub( Q_inp, Qband ), Q_add );
-
- Scale_sig32( hFrontVad->hNoiseEst->bckr_fx, 20, sub( add( Q_new_old, QSCALE + 2 ), hFrontVad->hNoiseEst->q_bckr ) ); // Q_new_old +QSCALE +2
- Scale_sig32( hFrontVad->hNoiseEst->enrO_fx, 20, sub( add( Q_new_old, QSCALE + 2 ), hFrontVad->hNoiseEst->q_enrO ) );
- hFrontVad->hNoiseEst->q_enrO = add( Q_new_old, QSCALE + 2 );
- move16();
Word16 Q_buffer = hFrontVad->q_buffer_12k8;
move16();
- Scale_sig( hFrontVad->mem_decim_fx, 2 * L_FILT_MAX, sub( Q_inp, hFrontVad->q_mem_decim ) );
+ Scale_sig( hFrontVad->mem_decim_fx, 2 * L_FILT_MAX, sub( Q_inp, hFrontVad->q_mem_decim ) ); /* Q_inp */
hFrontVad->q_mem_decim = Q_inp;
move16();
- IF( NE_32( ( error = front_vad_fx( NULL, st, hEncoderConfig, &hFrontVad, 0 /* MCT_flag */, input_frame, vad_flag_dtx, fr_bands_fx, Etot_fx, lf_E_fx, localVAD_HE_SAD, vad_hover_flag, band_energies_fx, &PS_fx[0], &st->lgBin_E_fx[0], Q_inp, &Q_buffer, Q_add, &front_create_flag ) ), IVAS_ERR_OK ) )
+ Word16 q_band_energies;
+ Word16 q_fr_bands[2], q_lf_E[2];
+ IF( NE_32( ( error = front_vad_fx( NULL, st, hEncoderConfig, &hFrontVad, 0 /* MCT_flag */, input_frame, vad_flag_dtx, fr_bands_fx,
+ q_fr_bands, Etot_fx, lf_E_fx, q_lf_E, localVAD_HE_SAD, vad_hover_flag, band_energies_fx,
+ &q_band_energies, PS_fx, &Qfact_PS, &st->lgBin_E_fx[0], Q_inp, &Q_buffer, Q_add, &front_create_flag ) ),
+ IVAS_ERR_OK ) )
{
return error;
}
@@ -589,25 +635,27 @@ ivas_error front_vad_spar_fx(
Q_inp_12k8 = hFrontVad->q_buffer_12k8;
move16();
- IF( st->lgBin_E_fx != NULL )
- {
- Copy_Scale_sig_16_32( st->lgBin_E_fx, st->Bin_E_fx, L_FFT / 2, sub( st->q_Bin_E, Q7 ) );
- }
- Scale_sig32( fr_bands_fx[0], 40, sub( ( Q_bands + QSCALE ), add( Q_buffer, QSCALE + 2 ) ) );
+ scale = s_min( add( q_fr_bands[0], L_norm_arr( fr_bands_fx[0], 2 * NB_BANDS ) ), add( hFrontVad->hNoiseEst->q_bckr, L_norm_arr( hFrontVad->hNoiseEst->bckr_fx, NB_BANDS ) ) );
+ scale_sig32( fr_bands_fx[0], 40, sub( scale, q_fr_bands[0] ) ); // scale
+ scale_sig32( hFrontVad->hNoiseEst->bckr_fx, NB_BANDS, sub( scale, hFrontVad->hNoiseEst->q_bckr ) ); // scale
+ hFrontVad->hNoiseEst->q_bckr = q_fr_bands[0] = scale;
+ move16();
+ move16();
- Word32 e_min_scaled;
- e_min_scaled = L_shr_r( L_add( L_shr( E_MIN_FXQ15, sub( 14, add( Q_bands, QSCALE ) ) ), 1 ), 1 );
+ noise_est_down_ivas_fx( fr_bands_fx[0], q_fr_bands[0], hFrontVad->hNoiseEst->bckr_fx, tmpN_fx, tmpE_fx, st->min_band, st->max_band,
+ &hFrontVad->hNoiseEst->totalNoise_fx, Etot_fx[0], &hFrontVad->hNoiseEst->Etot_last_fx, &hFrontVad->hNoiseEst->Etot_v_h2_fx );
- Scale_sig32( hFrontVad->hNoiseEst->bckr_fx, 20, sub( Q_bands + QSCALE, add( Q_new_old, QSCALE + 2 ) ) );
- hFrontVad->hNoiseEst->q_bckr = Q_bands + QSCALE;
- move16();
- noise_est_down_fx( fr_bands_fx[0], hFrontVad->hNoiseEst->bckr_fx, tmpN_fx, tmpE_fx, st->min_band, st->max_band, &hFrontVad->hNoiseEst->totalNoise_fx, Etot_fx[0], &hFrontVad->hNoiseEst->Etot_last_fx, &hFrontVad->hNoiseEst->Etot_v_h2_fx, Q_bands, e_min_scaled );
- corr_shift_fx = correlation_shift_fx( hFrontVad->hNoiseEst->totalNoise_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;
- alw_pitch_lag_12k8[1] = st->old_pitch_la;
+ alw_pitch_lag_12k8[0] = st->old_pitch_la; /* Q0 */
+ alw_pitch_lag_12k8[1] = st->old_pitch_la; /* Q0 */
alw_voicing_fx[0] = st->voicing_fx[2];
alw_voicing_fx[1] = st->voicing_fx[2];
move16();
@@ -617,8 +665,8 @@ ivas_error front_vad_spar_fx(
Word16 Q_r[2] = { 0 };
move16();
move16();
- Scale_sig( hFrontVad->mem_decim_fx, 2 * L_FILT_MAX, sub( s_min( Q_inp_12k8, hFrontVad->q_mem_decim ), hFrontVad->q_mem_decim ) );
- Scale_sig( inp_12k8_fx, 3 * L_FRAME / 2, sub( s_min( Q_inp_12k8, hFrontVad->q_mem_decim ), Q_inp_12k8 ) );
+ Scale_sig( hFrontVad->mem_decim_fx, 2 * L_FILT_MAX, sub( s_min( Q_inp_12k8, hFrontVad->q_mem_decim ), hFrontVad->q_mem_decim ) ); /* min( hFrontVad->q_mem_decim, hFrontVad->q_buffer_12k8 */
+ Scale_sig( inp_12k8_fx, 3 * L_FRAME / 2, sub( s_min( Q_inp_12k8, hFrontVad->q_mem_decim ), Q_inp_12k8 ) ); /* min( hFrontVad->q_mem_decim, hFrontVad->q_buffer_12k8 */
Q_inp_12k8 = s_min( hFrontVad->q_mem_decim, hFrontVad->q_buffer_12k8 );
hFrontVad->q_mem_decim = Q_inp_12k8;
move16();
@@ -635,10 +683,10 @@ ivas_error front_vad_spar_fx(
relE_fx = sub( Etot_fx[0], st->lp_speech_fx );
Scale_sig( A_fx, ( L_FRAME / L_SUBFR ) * ( M + 1 ), -2 ); // Q12
- st->mem_wsp_fx = (Word16) shl_sat( st->mem_wsp_fx, Q_inp_12k8 - st->mem_wsp_q );
+ st->mem_wsp_fx = (Word16) shl_sat( st->mem_wsp_fx, Q_inp_12k8 - st->mem_wsp_q ); /* Q_inp_12k8 */
st->mem_wsp_q = Q_inp_12k8;
move16();
- ivas_find_wsp( L_FRAME, L_SUBFR, NB_SUBFR, A_fx, Aw_fx, inp_12k8_fx, TILT_FAC_FX, wsp_fx, &st->mem_wsp_fx, GAMMA1, L_LOOK_12k8 );
+ ivas_find_wsp_fx( L_FRAME, L_SUBFR, NB_SUBFR, A_fx, Aw_fx, inp_12k8_fx, TILT_FAC_FX, wsp_fx, &st->mem_wsp_fx, GAMMA1, L_LOOK_12k8 );
IF( st->vad_flag == 0 )
{
@@ -648,32 +696,66 @@ ivas_error front_vad_spar_fx(
old_pitch = st->pitch[1];
move16();
- Scale_sig( wsp_fx, 368, sub( Q8, Q_inp_12k8 ) );
- pitch_ol_ivas_fx( st->pitch, st->voicing_fx, &st->old_pitch, &st->old_corr_fx, corr_shift_fx, &st->old_thres_fx, &st->delta_pit, st->old_wsp2_fx, wsp_fx, st->mem_decim2_fx, relE_fx, st->clas, st->input_bwidth, st->Opt_SC_VBR );
+ Scale_sig( wsp_fx, 368, sub( Q8, Q_inp_12k8 ) ); // Q8
+ pitch_ol_ivas_fx( st->pitch, st->voicing_fx, &st->old_pitch, &st->old_corr_fx, corr_shift_fx, &st->old_thres_fx, &st->delta_pit, st->old_wsp2_fx, wsp_fx, st->mem_decim2_fx, relE_fx, st->clas, st->input_bwidth, st->Opt_SC_VBR, Q8 );
+
/* Updates for adaptive lag window memory */
- st->old_pitch_la = st->pitch[2];
+ st->old_pitch_la = st->pitch[2]; /* Q0 */
move16();
- Scale_sig( wsp_fx, 368, Q9 - Q8 );
+ Scale_sig( wsp_fx, 368, Q9 - Q8 ); /* Q9 */
StableHighPitchDetect_ivas_fx( &flag_spitch, st->pitch, st->voicing_fx, wsp_fx, st->localVAD, &st->voicing_sm_fx, &st->voicing0_sm_fx, &st->LF_EnergyRatio_sm_fx, &st->predecision_flag, &st->diff_sm_fx, &st->energy_sm_fx, Q12, st->lgBin_E_fx );
IF( st->hSpMusClas != NULL )
{
Word16 dummy_int;
+ Word16 *cor_strong_limit;
dummy_int = 0;
move16();
- loc_harm = multi_harm_fx( st->lgBin_E_fx, hFrontVad->hNoiseEst->old_S_fx, hFrontVad->hNoiseEst->cor_map_fx, &hFrontVad->hNoiseEst->multi_harm_limit_fx, st->total_brate, st->bwidth, ( st->hGSCEnc != NULL ) ? &st->hGSCEnc->cor_strong_limit : &dummy_int, &st->hSpMusClas->mean_avr_dyn_fx, &st->hSpMusClas->last_sw_dyn_fx, &cor_map_sum_fx, &dummy_fx, S_map_fx );
+ if ( st->hGSCEnc != NULL )
+ {
+ cor_strong_limit = &st->hGSCEnc->cor_strong_limit;
+ }
+ else
+ {
+ cor_strong_limit = &dummy_int;
+ }
+ loc_harm = multi_harm_fx( st->lgBin_E_fx, hFrontVad->hNoiseEst->old_S_fx, hFrontVad->hNoiseEst->cor_map_fx, &hFrontVad->hNoiseEst->multi_harm_limit_fx, st->total_brate, st->bwidth, cor_strong_limit, &st->hSpMusClas->mean_avr_dyn_fx, &st->hSpMusClas->last_sw_dyn_fx, &cor_map_sum_fx, &dummy_fx, S_map_fx ); /* Q0 */
}
+
scale = getScaleFactor32( epsP_fx, M + 1 );
Q_esp = add( Q_r[0], scale );
- Scale_sig32( epsP_fx, M + 1, scale );
- FOR( Word16 i = 0; i <= M; i++ )
- {
- L_Extract( epsP_fx[i], &epsP_h[i], &epsP_l[i] );
- }
- Q_bands = Q9;
+ Scale_sig32( epsP_fx, M + 1, scale ); // Q_esp
+
+ scale = add( hFrontVad->hNoiseEst->ave_enr_q, s_min( L_norm_arr( hFrontVad->hNoiseEst->ave_enr_fx, NB_BANDS ), L_norm_arr( hFrontVad->hNoiseEst->ave_enr2_fx, NB_BANDS ) ) );
+ scale = s_min( scale, add( hFrontVad->hNoiseEst->q_bckr, L_norm_arr( tmpE_fx, NB_BANDS ) ) );
+ scale = sub( s_min( scale, Q31 ), 1 );
+ scale_sig32( hFrontVad->hNoiseEst->ave_enr_fx, NB_BANDS, sub( scale, hFrontVad->hNoiseEst->ave_enr_q ) );
+ scale_sig32( hFrontVad->hNoiseEst->ave_enr2_fx, NB_BANDS, sub( scale, hFrontVad->hNoiseEst->ave_enr_q ) );
+ scale_sig32( tmpE_fx, NB_BANDS, sub( scale, hFrontVad->hNoiseEst->q_bckr ) );
+ hFrontVad->hNoiseEst->ave_enr_q = scale;
+ move16();
+
+ scale = add( hFrontVad->hNoiseEst->q_bckr, s_min( L_norm_arr( hFrontVad->hNoiseEst->bckr_fx, NB_BANDS ), L_norm_arr( tmpN_fx, NB_BANDS ) ) );
+ scale = sub( s_min( Q31, scale ), 1 ); // guard bits
+ scale_sig32( hFrontVad->hNoiseEst->bckr_fx, NB_BANDS, sub( scale, hFrontVad->hNoiseEst->q_bckr ) );
+ scale_sig32( tmpN_fx, NB_BANDS, sub( scale, hFrontVad->hNoiseEst->q_bckr ) );
+ hFrontVad->hNoiseEst->q_bckr = scale;
move16();
- Scale_sig32( lf_E_fx[0], 148, ( Q_bands + QSCALE - 2 ) - ( Q_buffer + QSCALE ) );
- noise_est_ivas_fx( st, old_pitch, tmpN_fx, epsP_h, epsP_l, Etot_fx[0], Etot_fx[0] - hFrontVad->lp_speech_fx, corr_shift_fx, tmpE_fx, fr_bands_fx[0], &cor_map_sum_fx, NULL, &sp_div_fx, &Q_sp_div, &non_staX_fx, &loc_harm, lf_E_fx[0], &hFrontVad->hNoiseEst->harm_cor_cnt, hFrontVad->hNoiseEst->Etot_l_lp_fx, hFrontVad->hNoiseEst->Etot_v_h2_fx, &hFrontVad->hNoiseEst->bg_cnt, st->lgBin_E_fx, Q_bands, e_min_scaled, &sp_floor, S_map_fx, NULL, hFrontVad, hFrontVad->ini_frame );
+ scale = add( hFrontVad->hNoiseEst->fr_bands_fx_q, s_min( L_norm_arr( hFrontVad->hNoiseEst->fr_bands1_fx, NB_BANDS ), L_norm_arr( hFrontVad->hNoiseEst->fr_bands2_fx, NB_BANDS ) ) );
+ scale = s_min( scale, add( q_fr_bands[0], L_norm_arr( fr_bands_fx[0], 2 * NB_BANDS ) ) );
+ scale = s_min( Q31, scale );
+ scale_sig32( hFrontVad->hNoiseEst->fr_bands1_fx, NB_BANDS, sub( scale, hFrontVad->hNoiseEst->fr_bands_fx_q ) );
+ scale_sig32( hFrontVad->hNoiseEst->fr_bands2_fx, NB_BANDS, sub( scale, hFrontVad->hNoiseEst->fr_bands_fx_q ) );
+ scale_sig32( fr_bands_fx[0], 2 * NB_BANDS, sub( scale, q_fr_bands[0] ) );
+ hFrontVad->hNoiseEst->fr_bands_fx_q = q_fr_bands[0] = scale;
+ move16();
+ move16();
+
+ noise_est_ivas_fx( st, old_pitch, tmpN_fx, epsP_fx, Etot_fx[0], sub( Etot_fx[0], hFrontVad->lp_speech_fx ), corr_shift_fx, tmpE_fx,
+ hFrontVad->hNoiseEst->ave_enr_q, fr_bands_fx[0], q_fr_bands[0], &cor_map_sum_fx, NULL, &sp_div_fx, &Q_sp_div, &non_staX_fx, &loc_harm,
+ lf_E_fx[0], q_lf_E[0], &hFrontVad->hNoiseEst->harm_cor_cnt, hFrontVad->hNoiseEst->Etot_l_lp_fx, hFrontVad->hNoiseEst->Etot_v_h2_fx,
+ &hFrontVad->hNoiseEst->bg_cnt, st->lgBin_E_fx, &sp_floor, S_map_fx, NULL, hFrontVad, hFrontVad->ini_frame );
+
MVR2R_WORD16( st->pitch, st->pitch, 3 );
vad_param_updt_fx( st, st->pitch[1], corr_shift_fx, corr_shift_fx, A_fx, &hFrontVad, 1 );
/* 1st stage speech/music classification (GMM model) */
@@ -683,7 +765,7 @@ ivas_error front_vad_spar_fx(
Word16 Etot_fx_0 = Etot_fx[0];
move16();
scale = getScaleFactor32( PS_fx, 128 );
- Word16 Qfact_PS = add( add( Q_buffer, QSCALE ), scale );
+ Qfact_PS = add( Qfact_PS, scale );
Scale_sig32( PS_fx, 128, scale );
ivas_smc_gmm_fx( st, NULL, localVAD_HE_SAD[0], Etot_fx_0, lsp_new_fx, cor_map_sum_fx, epsP_fx, PS_fx, non_sta_fx, relE_fx, &high_lpn_flag, flag_spitch, Qfact_PS, Q_esp, hSpMusClas->past_PS_Q );
@@ -691,10 +773,10 @@ ivas_error front_vad_spar_fx(
ivas_long_enr_fx( st, -1, localVAD_HE_SAD[0], high_lpn_flag, &hFrontVad, 1, localVAD_HE_SAD, Etot_fx );
/* increase ini_frame counter */
- hFrontVad->ini_frame = min( add( hFrontVad->ini_frame, 1 ), MAX_FRAME_COUNTER );
- st->ini_frame = hFrontVad->ini_frame;
+ hFrontVad->ini_frame = s_min( add( hFrontVad->ini_frame, 1 ), MAX_FRAME_COUNTER ); /* Q0 */
+ st->ini_frame = hFrontVad->ini_frame; /* Q0 */
move16();
- hSpar->front_vad_flag = st->vad_flag;
+ hSpar->front_vad_flag = st->vad_flag; /* Q0 */
move16();
hSpar->front_vad_dtx_flag = 1;
move16();
diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c
index 06e4f7a3aecbf5db926bf33897ad2733f28adfa7..7a499ce672a40c045dd7106844155f63c0f2ab8c 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"
@@ -78,7 +79,7 @@ void ivas_write_format_fx(
ind = 4;
move16();
- nBits = add( nBits, extra_bits );
+ nBits = add( nBits, extra_bits ); /* Q0 */
}
BREAK;
case MC_FORMAT:
@@ -89,26 +90,26 @@ void ivas_write_format_fx(
ind = 6;
move16();
- nBits = add( nBits, extra_bits );
+ nBits = add( nBits, extra_bits ); /* Q0 */
BREAK;
case MASA_FORMAT:
ind = 7;
move16();
- nBits = add( nBits, extra_bits );
+ nBits = add( nBits, extra_bits ); /* Q0 */
BREAK;
case MASA_ISM_FORMAT:
IF( st_ivas->ism_mode == ISM_MODE_NONE )
{
ind = 7; /* send MASA format */
move16();
- nBits = add( nBits, extra_bits );
+ nBits = add( nBits, extra_bits ); /* Q0 */
}
ELSE
{
ind = 10;
move16();
- nBits = add( nBits, add( extra_bits, IVAS_COMBINED_FORMAT_SIGNALLING_BITS ) );
+ nBits = add( nBits, add( extra_bits, IVAS_COMBINED_FORMAT_SIGNALLING_BITS ) ); /* Q0 */
}
BREAK;
case SBA_ISM_FORMAT:
@@ -116,13 +117,13 @@ void ivas_write_format_fx(
{
ind = 6; /* send SBA format */
move16();
- nBits = add( nBits, extra_bits );
+ nBits = add( nBits, extra_bits ); /* Q0 */
}
ELSE
{
ind = 11; /* 1011 */
move16();
- nBits = add( nBits, add( extra_bits, IVAS_COMBINED_FORMAT_SIGNALLING_BITS ) );
+ nBits = add( nBits, add( extra_bits, IVAS_COMBINED_FORMAT_SIGNALLING_BITS ) ); /* Q0 */
}
BREAK;
default:
@@ -150,7 +151,7 @@ void ivas_write_format_fx(
void ivas_write_format_sid_fx(
const IVAS_FORMAT ivas_format, /* i : IVAS format */
- const Word16 element_mode, /* i : element bitrate */
+ const Word16 element_mode, /* i : element bitrate Q0*/
BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */
)
{
@@ -234,78 +235,91 @@ Word16 getNumChanAnalysis_fx(
{
Word16 n;
- n = add( st_ivas->nSCE, CPE_CHANNELS * st_ivas->nCPE );
+ n = add( st_ivas->nSCE, CPE_CHANNELS * st_ivas->nCPE ); /* Q0 */
test();
test();
test();
test();
IF( EQ_32( st_ivas->hEncoderConfig->ivas_format, SBA_FORMAT ) )
{
- n = imult1616( add( st_ivas->sba_analysis_order, 1 ), add( st_ivas->sba_analysis_order, 1 ) );
+ n = imult1616( add( st_ivas->sba_analysis_order, 1 ), add( st_ivas->sba_analysis_order, 1 ) ); /* Q0 */
}
ELSE IF( EQ_32( st_ivas->hEncoderConfig->ivas_format, MC_FORMAT ) && ( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMMC ) || EQ_32( st_ivas->mc_mode, MC_MODE_MCMASA ) ) )
{
- n = st_ivas->hEncoderConfig->nchan_inp;
+ n = st_ivas->hEncoderConfig->nchan_inp; /* Q0 */
move16();
}
ELSE IF( EQ_32( st_ivas->hEncoderConfig->ivas_format, MC_FORMAT ) && EQ_32( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) )
{
- n = st_ivas->hEncoderConfig->nchan_inp;
+ n = st_ivas->hEncoderConfig->nchan_inp; /* Q0 */
move16();
}
ELSE IF( EQ_32( st_ivas->hEncoderConfig->ivas_format, ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) )
{
- n = st_ivas->hEncoderConfig->nchan_inp;
+ n = st_ivas->hEncoderConfig->nchan_inp; /* Q0 */
move16();
}
ELSE IF( EQ_32( st_ivas->hEncoderConfig->ivas_format, MASA_ISM_FORMAT ) )
{
- n = st_ivas->hEncoderConfig->nchan_inp;
+ n = st_ivas->hEncoderConfig->nchan_inp; /* Q0 */
move16();
}
ELSE IF( EQ_32( st_ivas->hEncoderConfig->ivas_format, SBA_ISM_FORMAT ) )
{
- n = add( st_ivas->hEncoderConfig->nchan_ism, imult1616( add( st_ivas->sba_analysis_order, 1 ), add( st_ivas->sba_analysis_order, 1 ) ) );
+ n = add( st_ivas->hEncoderConfig->nchan_ism, imult1616( add( st_ivas->sba_analysis_order, 1 ), add( st_ivas->sba_analysis_order, 1 ) ) ); /* Q0 */
}
return n;
}
/*-------------------------------------------------------------------*
- * copy_encoder_config()
+ * copy_encoder_config_ivas_fx()
*
* Copy configuration structrue to the state structrure
*-------------------------------------------------------------------*/
-void copy_encoder_config(
- Encoder_Struct *st_ivas, /* i : IVAS encoder structure */
- Encoder_State *st, /* o : encoder state structure */
- const Word16 flag_all /* i : flag 1==update all, 0=partial update*/
+void copy_encoder_config_ivas_fx(
+ Encoder_Struct *st_ivas, /* i : IVAS encoder structure */
+ Encoder_State *st, /* o : encoder state structure */
+ const Word16 flag_all /* i : flag 1==update all, 0=partial update Q0*/
)
{
- if ( flag_all )
+ IF( flag_all )
{
- st->input_Fs = st_ivas->hEncoderConfig->input_Fs;
+ st->input_Fs = st_ivas->hEncoderConfig->input_Fs; /* Q0 */
+ move32();
- st->last_codec_mode = st_ivas->last_codec_mode;
- st->last_total_brate = st_ivas->hEncoderConfig->last_ivas_total_brate;
+ st->last_codec_mode = st_ivas->last_codec_mode; /* Q0 */
+ move16();
+ st->last_total_brate = st_ivas->hEncoderConfig->last_ivas_total_brate; /* Q0 */
+ move32();
- st->Opt_DTX_ON = st_ivas->hEncoderConfig->Opt_DTX_ON;
+ st->Opt_DTX_ON = st_ivas->hEncoderConfig->Opt_DTX_ON; /* Q0 */
+ move16();
- st->last_Opt_SC_VBR = st_ivas->hEncoderConfig->last_Opt_SC_VBR;
+ st->last_Opt_SC_VBR = st_ivas->hEncoderConfig->last_Opt_SC_VBR; /* Q0 */
+ move16();
}
- st->Opt_AMR_WB = st_ivas->hEncoderConfig->Opt_AMR_WB;
- st->Opt_SC_VBR = st_ivas->hEncoderConfig->Opt_SC_VBR;
+ st->Opt_AMR_WB = st_ivas->hEncoderConfig->Opt_AMR_WB; /* Q0 */
+ st->Opt_SC_VBR = st_ivas->hEncoderConfig->Opt_SC_VBR; /* Q0 */
+ move16();
+ move16();
- st->codec_mode = st_ivas->codec_mode;
- st->max_bwidth = st_ivas->hEncoderConfig->max_bwidth;
+ st->codec_mode = st_ivas->codec_mode; /* Q0 */
+ st->max_bwidth = st_ivas->hEncoderConfig->max_bwidth; /* Q0 */
+ move16();
+ move16();
- st->Opt_RF_ON = st_ivas->hEncoderConfig->Opt_RF_ON;
- st->rf_fec_offset = st_ivas->hEncoderConfig->rf_fec_offset;
- st->rf_fec_indicator = st_ivas->hEncoderConfig->rf_fec_indicator;
+ st->Opt_RF_ON = st_ivas->hEncoderConfig->Opt_RF_ON; /* Q0 */
+ st->rf_fec_offset = st_ivas->hEncoderConfig->rf_fec_offset; /* Q0 */
+ st->rf_fec_indicator = st_ivas->hEncoderConfig->rf_fec_indicator; /* Q0 */
+ move16();
+ move16();
+ move16();
- st->element_mode = st_ivas->hEncoderConfig->element_mode_init;
+ st->element_mode = st_ivas->hEncoderConfig->element_mode_init; /* Q0 */
+ move16();
return;
}
@@ -316,62 +330,62 @@ void copy_encoder_config(
*-------------------------------------------------------------------*/
void copy_encoder_config_fx(
- Encoder_Struct *st_ivas, /* i : IVAS encoder structure */
- Encoder_State *st_fx, /* o : encoder state structure */
- const Word16 flag_all /* i : flag 1==update all, 0=partial update*/
+ Encoder_Struct *st_ivas, /* i : IVAS encoder structure */
+ Encoder_State *st_fx, /* o : encoder state structure */
+ const Word16 flag_all /* i : flag 1==update all, 0=partial update Q0*/
)
{
IF( flag_all )
{
- st_fx->input_Fs = st_ivas->hEncoderConfig->input_Fs;
+ st_fx->input_Fs = st_ivas->hEncoderConfig->input_Fs; /* Q0 */
move32();
- st_fx->last_codec_mode = st_ivas->last_codec_mode;
+ st_fx->last_codec_mode = st_ivas->last_codec_mode; /* Q0 */
move16();
- st_fx->last_total_brate = st_ivas->hEncoderConfig->last_ivas_total_brate;
+ st_fx->last_total_brate = st_ivas->hEncoderConfig->last_ivas_total_brate; /* Q0 */
move32();
- st_fx->Opt_DTX_ON = st_ivas->hEncoderConfig->Opt_DTX_ON;
+ st_fx->Opt_DTX_ON = st_ivas->hEncoderConfig->Opt_DTX_ON; /* Q0 */
move16();
- st_fx->last_Opt_SC_VBR = st_ivas->hEncoderConfig->last_Opt_SC_VBR;
+ st_fx->last_Opt_SC_VBR = st_ivas->hEncoderConfig->last_Opt_SC_VBR; /* Q0 */
move16();
}
- st_fx->Opt_AMR_WB = st_ivas->hEncoderConfig->Opt_AMR_WB;
+ st_fx->Opt_AMR_WB = st_ivas->hEncoderConfig->Opt_AMR_WB; /* Q0 */
move16();
- st_fx->Opt_SC_VBR = st_ivas->hEncoderConfig->Opt_SC_VBR;
+ st_fx->Opt_SC_VBR = st_ivas->hEncoderConfig->Opt_SC_VBR; /* Q0 */
move16();
- st_fx->codec_mode = st_ivas->codec_mode;
+ st_fx->codec_mode = st_ivas->codec_mode; /* Q0 */
move16();
- st_fx->max_bwidth = st_ivas->hEncoderConfig->max_bwidth;
+ st_fx->max_bwidth = st_ivas->hEncoderConfig->max_bwidth; /* Q0 */
move16();
- st_fx->Opt_RF_ON = st_ivas->hEncoderConfig->Opt_RF_ON;
+ st_fx->Opt_RF_ON = st_ivas->hEncoderConfig->Opt_RF_ON; /* Q0 */
move16();
- st_fx->rf_fec_offset = st_ivas->hEncoderConfig->rf_fec_offset;
+ st_fx->rf_fec_offset = st_ivas->hEncoderConfig->rf_fec_offset; /* Q0 */
move16();
- st_fx->rf_fec_indicator = st_ivas->hEncoderConfig->rf_fec_indicator;
+ st_fx->rf_fec_indicator = st_ivas->hEncoderConfig->rf_fec_indicator; /* Q0 */
move16();
#ifdef DEBUGGING
st_fx->force = st_ivas->hEncoderConfig->force;
#endif
- st_fx->element_mode = st_ivas->hEncoderConfig->element_mode_init;
+ st_fx->element_mode = st_ivas->hEncoderConfig->element_mode_init; /* Q0 */
move16();
return;
}
/*-------------------------------------------------------------------------
- * ivas_initialize_handles_enc()
+ * ivas_initialize_handles_enc_fx()
*
* NULL initialization of handles
*-------------------------------------------------------------------------*/
-void ivas_initialize_handles_enc(
+void ivas_initialize_handles_enc_fx(
Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */
)
{
@@ -466,38 +480,48 @@ ivas_error ivas_init_encoder(
hEncoderConfig = st_ivas->hEncoderConfig;
ivas_format = hEncoderConfig->ivas_format;
- input_Fs = hEncoderConfig->input_Fs;
- ivas_total_brate = hEncoderConfig->ivas_total_brate;
+ input_Fs = hEncoderConfig->input_Fs; /* Q0 */
+ ivas_total_brate = hEncoderConfig->ivas_total_brate; /* Q0 */
+ move32();
+ move32();
- hEncoderConfig->last_ivas_total_brate = ivas_total_brate;
+ hEncoderConfig->last_ivas_total_brate = ivas_total_brate; /* Q0 */
+ move32();
- if ( ivas_format != MONO_FORMAT )
+ if ( NE_32( ivas_format, MONO_FORMAT ) )
{
/* In IVAS, ensure that minimum coded bandwidth is WB */
- hEncoderConfig->max_bwidth = max( hEncoderConfig->max_bwidth, WB );
+ hEncoderConfig->max_bwidth = max( hEncoderConfig->max_bwidth, WB ); /* Q0 */
+ move16();
}
st_ivas->ism_mode = ISM_MODE_NONE;
st_ivas->mc_mode = MC_MODE_NONE;
+ move32();
+ move32();
st_ivas->nchan_transport = -1;
+ move16();
/*-----------------------------------------------------------------*
* Allocate floating-point input audio buffers
*-----------------------------------------------------------------*/
- nchan_inp_buff = hEncoderConfig->nchan_inp;
- if ( ivas_format == MONO_FORMAT )
+ nchan_inp_buff = hEncoderConfig->nchan_inp; /* Q0 */
+ move16();
+
+ IF( EQ_32( ivas_format, MONO_FORMAT ) )
{
nchan_inp_buff = 0;
+ move16();
}
- else if ( ivas_format == MASA_ISM_FORMAT )
+ ELSE IF( EQ_32( ivas_format, MASA_ISM_FORMAT ) )
{
- if ( hEncoderConfig->nchan_inp - hEncoderConfig->nchan_ism == 1 ) /* mono is duplicated in monoMASA */
+ if ( EQ_32( sub( hEncoderConfig->nchan_inp, hEncoderConfig->nchan_ism ), 1 ) ) /* mono is duplicated in monoMASA */
{
- nchan_inp_buff++;
+ nchan_inp_buff = add( nchan_inp_buff, 1 );
}
- nchan_inp_buff++; /* for *data_separated_object */
+ nchan_inp_buff = add( nchan_inp_buff, 1 ); /* for *data_separated_object */
}
FOR( n = 0; n < nchan_inp_buff; n++ )
@@ -507,7 +531,10 @@ ivas_error ivas_init_encoder(
{
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for floating-point input audio buffer!\n" ) );
}
+ set32_fx( st_ivas->p_data_fx[n], 0, extract_l( Mpy_32_16_1( input_Fs, INV_FRAME_PER_SEC_Q15 ) ) );
}
+ st_ivas->q_data_fx = Q11;
+ move16();
FOR( ; n < MAX_INPUT_CHANNELS + MAX_NUM_OBJECTS; n++ )
{
st_ivas->p_data_fx[n] = NULL;
@@ -517,10 +544,11 @@ ivas_error ivas_init_encoder(
*-----------------------------------------------------------------*/
/* set the maximum allowed number of indices in the list */
- st_ivas->ivas_max_num_indices = get_ivas_max_num_indices_fx( ivas_format, ivas_total_brate );
+ st_ivas->ivas_max_num_indices = get_ivas_max_num_indices_fx( ivas_format, ivas_total_brate ); /* Q0 */
+ move16();
/* allocate buffer of indices */
- if ( ( st_ivas->ind_list = (INDICE_HANDLE) malloc( st_ivas->ivas_max_num_indices * sizeof( Indice ) ) ) == NULL )
+ IF( ( st_ivas->ind_list = (INDICE_HANDLE) malloc( st_ivas->ivas_max_num_indices * sizeof( Indice ) ) ) == NULL )
{
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for buffer of indices!\n" ) );
}
@@ -529,15 +557,17 @@ ivas_error ivas_init_encoder(
for ( i = 0; i < st_ivas->ivas_max_num_indices; i++ )
{
st_ivas->ind_list[i].nb_bits = -1;
+ move16();
}
/* set the maximum allowed number of metadata indices in the list */
- st_ivas->ivas_max_num_indices_metadata = get_ivas_max_num_indices_metadata_fx( st_ivas->hEncoderConfig->ivas_format, st_ivas->hEncoderConfig->ivas_total_brate );
+ st_ivas->ivas_max_num_indices_metadata = get_ivas_max_num_indices_metadata_fx( st_ivas->hEncoderConfig->ivas_format, st_ivas->hEncoderConfig->ivas_total_brate ); /* Q0 */
+ move16();
/* allocate buffer of metadata indices */
- if ( st_ivas->ivas_max_num_indices_metadata > 0 )
+ IF( st_ivas->ivas_max_num_indices_metadata > 0 )
{
- if ( ( st_ivas->ind_list_metadata = (INDICE_HANDLE) malloc( st_ivas->ivas_max_num_indices_metadata * sizeof( Indice ) ) ) == NULL )
+ IF( ( st_ivas->ind_list_metadata = (INDICE_HANDLE) malloc( st_ivas->ivas_max_num_indices_metadata * sizeof( Indice ) ) ) == NULL )
{
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for buffer of metadata indices!\n" ) );
}
@@ -546,9 +576,10 @@ ivas_error ivas_init_encoder(
for ( i = 0; i < st_ivas->ivas_max_num_indices_metadata; i++ )
{
st_ivas->ind_list_metadata[i].nb_bits = -1;
+ move16();
}
}
- else
+ ELSE
{
st_ivas->ind_list_metadata = NULL;
}
@@ -557,7 +588,7 @@ ivas_error ivas_init_encoder(
* Allocate and initialize SCE/CPE and other handles
*-----------------------------------------------------------------*/
- if ( ivas_format == MONO_FORMAT )
+ IF( EQ_32( ivas_format, MONO_FORMAT ) )
{
st_ivas->nSCE = 1; /* in mono, there is always only one SCE */
move16();
@@ -569,87 +600,92 @@ ivas_error ivas_init_encoder(
move16();
test();
- IF( NE_16( st_ivas->hEncoderConfig->element_mode_init, EVS_MONO ) )
+ IF( st_ivas->hEncoderConfig->element_mode_init != EVS_MONO )
{
- IF( NE_32( ( error = create_sce_enc_fx( st_ivas, sce_id, ivas_total_brate ) ), IVAS_ERR_OK ) )
+ IF( ( error = create_sce_enc_fx( st_ivas, sce_id, ivas_total_brate ) ) != IVAS_ERR_OK )
{
return error;
}
}
ELSE
{
- IF( NE_32( ( 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;
}
}
/* prepare stereo downmix for EVS */
- if ( hEncoderConfig->stereo_dmx_evs == 1 )
+ IF( EQ_16( hEncoderConfig->stereo_dmx_evs, 1 ) )
{
- if ( ( error = stereo_dmx_evs_init_encoder_fx( &( st_ivas->hStereoDmxEVS ), input_Fs ) ) != IVAS_ERR_OK )
+ IF( ( error = stereo_dmx_evs_init_encoder_fx( &( st_ivas->hStereoDmxEVS ), input_Fs ) ) != IVAS_ERR_OK )
{
return error;
}
}
}
- else if ( ivas_format == STEREO_FORMAT )
+ ELSE IF( EQ_32( ivas_format, STEREO_FORMAT ) )
{
st_ivas->nSCE = 0;
st_ivas->nCPE = 1; /* in stereo, there is always only one CPE */
st_ivas->nchan_transport = CPE_CHANNELS;
cpe_id = 0;
+ move16();
+ move16();
+ move16();
+ move16();
- if ( ( error = create_cpe_enc_fx( st_ivas, cpe_id, ivas_total_brate ) ) != IVAS_ERR_OK )
+ IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, ivas_total_brate ) ) != IVAS_ERR_OK )
{
return error;
}
}
- else if ( ivas_format == ISM_FORMAT )
+ ELSE IF( EQ_32( ivas_format, ISM_FORMAT ) )
{
st_ivas->ism_mode = ivas_ism_mode_select( hEncoderConfig->nchan_inp, ivas_total_brate );
- if ( ( error = ivas_ism_metadata_enc_create( st_ivas, hEncoderConfig->nchan_inp, element_brate_tmp ) ) != IVAS_ERR_OK )
+ IF( ( error = ivas_ism_metadata_enc_create_fx( st_ivas, hEncoderConfig->nchan_inp, element_brate_tmp ) ) != IVAS_ERR_OK )
{
return error;
}
- for ( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ )
+ FOR( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ )
{
- if ( ( error = create_sce_enc_fx( st_ivas, sce_id, element_brate_tmp[sce_id] ) ) != IVAS_ERR_OK )
+ IF( ( error = create_sce_enc_fx( st_ivas, sce_id, element_brate_tmp[sce_id] ) ) != IVAS_ERR_OK )
{
return error;
}
}
- if ( st_ivas->ism_mode == ISM_MODE_PARAM )
+ IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) )
{
- if ( ( error = ivas_param_ism_enc_open( st_ivas ) ) != IVAS_ERR_OK )
+ IF( ( error = ivas_param_ism_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
}
- if ( st_ivas->hEncoderConfig->Opt_DTX_ON )
+ IF( st_ivas->hEncoderConfig->Opt_DTX_ON )
{
- if ( ( error = ivas_ism_dtx_open( st_ivas ) ) != IVAS_ERR_OK )
+ IF( ( error = ivas_ism_dtx_open( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
}
}
- else if ( ivas_format == SBA_FORMAT || ivas_format == MASA_FORMAT )
+ ELSE IF( EQ_32( ivas_format, SBA_FORMAT ) || EQ_32( ivas_format, MASA_FORMAT ) )
{
IF( ( error = ivas_qmetadata_open_fx( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK )
{
return error;
}
- if ( ivas_format == SBA_FORMAT )
+ IF( EQ_32( ivas_format, SBA_FORMAT ) )
{
- st_ivas->sba_analysis_order = ivas_sba_get_analysis_order_fx( ivas_total_brate, st_ivas->hEncoderConfig->sba_order );
+ st_ivas->sba_analysis_order = ivas_sba_get_analysis_order_fx( ivas_total_brate, st_ivas->hEncoderConfig->sba_order ); /* Q0 */
+ move16();
- if ( ( error = ivas_spar_enc_open_fx( st_ivas, 0 ) ) != IVAS_ERR_OK )
+ IF( ( error = ivas_spar_enc_open_fx( st_ivas, 0 ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -659,74 +695,82 @@ ivas_error ivas_init_encoder(
return error;
}
}
- else
+ ELSE
{
- st_ivas->nchan_transport = hEncoderConfig->nchan_inp;
+ st_ivas->nchan_transport = hEncoderConfig->nchan_inp; /* Q0 */
+ move16();
- if ( ( error = ivas_masa_enc_open( st_ivas ) ) != IVAS_ERR_OK )
+ IF( ( error = ivas_masa_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
}
- for ( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ )
+ FOR( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ )
{
IF( ( error = create_sce_enc_fx( st_ivas, sce_id, ivas_total_brate / st_ivas->nchan_transport ) ) != IVAS_ERR_OK )
{
return error;
}
- if ( ivas_format == SBA_FORMAT && st_ivas->hEncoderConfig->Opt_DTX_ON )
+ if ( EQ_32( ivas_format, SBA_FORMAT ) && st_ivas->hEncoderConfig->Opt_DTX_ON )
{
st_ivas->hSCE[sce_id]->hCoreCoder[0]->dtx_sce_sba = 1;
+ move16();
}
}
- for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
+ FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
{
- if ( ( error = create_cpe_enc_fx( st_ivas, cpe_id, ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS ) ) != IVAS_ERR_OK )
+ Word32 res_dec, res_frac;
+ iDiv_and_mod_32( ivas_total_brate, st_ivas->nchan_transport, &res_dec, &res_frac, 0 );
+ IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, imult3216( res_dec, CPE_CHANNELS ) ) ) != IVAS_ERR_OK )
{
return error;
}
- for ( n = 0; n < CPE_CHANNELS; n++ )
+ FOR( n = 0; n < CPE_CHANNELS; n++ )
{
if ( hEncoderConfig->Opt_DTX_ON )
{
st_ivas->hCPE[cpe_id]->hCoreCoder[n]->cng_sba_flag = 1;
+ move16();
}
}
}
- if ( st_ivas->nCPE > 1 )
+ IF( GT_16( st_ivas->nCPE, 1 ) )
{
- if ( ( error = create_mct_enc( st_ivas ) ) != IVAS_ERR_OK )
+ IF( ( error = create_mct_enc_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
}
}
- else if ( ivas_format == MASA_ISM_FORMAT )
+ ELSE IF( EQ_32( ivas_format, MASA_ISM_FORMAT ) )
{
Word32 ism_total_brate;
Word16 k;
- st_ivas->ism_mode = ivas_omasa_ism_mode_select_fx( ivas_total_brate, hEncoderConfig->nchan_ism );
+ st_ivas->ism_mode = ivas_omasa_ism_mode_select_fx( ivas_total_brate, hEncoderConfig->nchan_ism ); /* Q0 */
move32();
st_ivas->nchan_transport = 2;
+ move16();
- if ( ( error = ivas_ism_metadata_enc_create( st_ivas, hEncoderConfig->nchan_ism, element_brate_tmp ) ) != IVAS_ERR_OK )
+ IF( ( error = ivas_ism_metadata_enc_create_fx( st_ivas, hEncoderConfig->nchan_ism, element_brate_tmp ) ) != IVAS_ERR_OK )
{
return error;
}
k = 0;
- while ( k < SIZE_IVAS_BRATE_TBL && ivas_total_brate != ivas_brate_tbl[k] )
+ move16();
+ while ( k < SIZE_IVAS_BRATE_TBL && NE_32( ivas_total_brate, ivas_brate_tbl[k] ) )
{
k++;
}
ism_total_brate = 0;
+ move32();
FOR( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ )
{
ism_total_brate = L_add( ism_total_brate, sep_object_brate[k - 2][st_ivas->nSCE - 1] );
@@ -740,43 +784,45 @@ ivas_error ivas_init_encoder(
{
return error;
}
- if ( ( error = ivas_masa_enc_open( st_ivas ) ) != IVAS_ERR_OK )
+ IF( ( error = ivas_masa_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
- if ( st_ivas->ism_mode != ISM_MASA_MODE_DISC )
+ IF( NE_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) )
{
- if ( ( error = ivas_omasa_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK )
+ IF( ( error = ivas_omasa_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
}
- if ( ivas_total_brate - ism_total_brate >= MIN_BRATE_MDCT_STEREO )
+ if ( GE_32( L_sub( ivas_total_brate, ism_total_brate ), MIN_BRATE_MDCT_STEREO ) )
{
st_ivas->hEncoderConfig->element_mode_init = IVAS_CPE_MDCT;
+ move16();
}
else
{
st_ivas->hEncoderConfig->element_mode_init = IVAS_CPE_DFT;
+ move16();
}
- if ( ( error = create_cpe_enc_fx( st_ivas, 0, ivas_total_brate - ism_total_brate ) ) != IVAS_ERR_OK )
+ IF( ( error = create_cpe_enc_fx( st_ivas, 0, L_sub( ivas_total_brate, ism_total_brate ) ) ) != IVAS_ERR_OK )
{
return error;
}
}
- else if ( ivas_format == SBA_ISM_FORMAT )
+ ELSE IF( EQ_32( ivas_format, SBA_ISM_FORMAT ) )
{
st_ivas->ism_mode = ISM_MODE_NONE;
- if ( ivas_total_brate >= IVAS_256k )
+ if ( GE_32( ivas_total_brate, IVAS_256k ) )
{
st_ivas->ism_mode = ISM_SBA_MODE_DISC;
}
- if ( ( error = ivas_ism_metadata_enc_create( st_ivas, hEncoderConfig->nchan_ism, element_brate_tmp ) ) != IVAS_ERR_OK )
+ IF( ( error = ivas_ism_metadata_enc_create_fx( st_ivas, hEncoderConfig->nchan_ism, element_brate_tmp ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -788,8 +834,9 @@ ivas_error ivas_init_encoder(
}
st_ivas->sba_analysis_order = ivas_sba_get_analysis_order_fx( ivas_total_brate, st_ivas->hEncoderConfig->sba_order );
+ move16();
- if ( ( error = ivas_spar_enc_open_fx( st_ivas, 0 ) ) != IVAS_ERR_OK )
+ IF( ( error = ivas_spar_enc_open_fx( st_ivas, 0 ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -799,7 +846,7 @@ ivas_error ivas_init_encoder(
return error;
}
- if ( st_ivas->ism_mode == ISM_MODE_NONE )
+ IF( EQ_32( st_ivas->ism_mode, ISM_MODE_NONE ) )
{
/* allocate and initialize SBA core-coders */
IF( EQ_16( st_ivas->nchan_transport, 1 ) )
@@ -810,132 +857,148 @@ ivas_error ivas_init_encoder(
}
}
- for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
+ FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
{
- if ( ( error = create_cpe_enc_fx( st_ivas, cpe_id, ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS ) ) != IVAS_ERR_OK )
+ Word32 res_dec, res_frac;
+ iDiv_and_mod_32( ivas_total_brate, st_ivas->nchan_transport, &res_dec, &res_frac, 0 );
+ IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, imult3216( res_dec, CPE_CHANNELS ) ) ) != IVAS_ERR_OK )
{
return error;
}
}
- if ( st_ivas->nCPE > 1 )
+ IF( GT_16( st_ivas->nCPE, 1 ) )
{
- if ( ( error = create_mct_enc( st_ivas ) ) != IVAS_ERR_OK )
+ IF( ( error = create_mct_enc_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
}
}
- else
+ ELSE
{
/* allocate and initialize MCT core coder */
- st_ivas->nCPE += ( st_ivas->hEncoderConfig->nchan_ism + 1 ) >> 1;
+ st_ivas->nCPE = add( st_ivas->nCPE, shr( add( st_ivas->hEncoderConfig->nchan_ism, 1 ), 1 ) );
- for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
+ FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
{
- if ( ( error = create_cpe_enc_fx( st_ivas, cpe_id, ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS ) ) != IVAS_ERR_OK )
+ Word32 res_dec, res_frac;
+ iDiv_and_mod_32( ivas_total_brate, st_ivas->nchan_transport, &res_dec, &res_frac, 0 );
+ IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, imult3216( res_dec, CPE_CHANNELS ) ) ) != IVAS_ERR_OK )
{
return error;
}
}
- if ( ( error = create_mct_enc( st_ivas ) ) != IVAS_ERR_OK )
+ IF( ( error = create_mct_enc_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
}
- if ( ( error = ivas_osba_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK )
+ IF( ( error = ivas_osba_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
}
- else if ( ivas_format == MC_FORMAT )
+ ELSE IF( EQ_32( ivas_format, MC_FORMAT ) )
{
- st_ivas->mc_mode = ivas_mc_mode_select_fx( hEncoderConfig->mc_input_setup, ivas_total_brate );
+ st_ivas->mc_mode = ivas_mc_mode_select_fx( hEncoderConfig->mc_input_setup, ivas_total_brate ); /* Q0 */
- if ( ( error = ivas_create_lfe_lpf_enc_fx( &st_ivas->hLfeLpf, hEncoderConfig->input_Fs ) ) != IVAS_ERR_OK )
+ IF( ( error = ivas_create_lfe_lpf_enc_fx( &st_ivas->hLfeLpf, hEncoderConfig->input_Fs ) ) != IVAS_ERR_OK )
{
return error;
}
- if ( st_ivas->mc_mode == MC_MODE_MCT )
+ IF( EQ_32( st_ivas->mc_mode, MC_MODE_MCT ) )
{
st_ivas->nSCE = 0;
- st_ivas->nCPE = hEncoderConfig->nchan_inp / CPE_CHANNELS;
+ st_ivas->nCPE = idiv1616( hEncoderConfig->nchan_inp, CPE_CHANNELS ); /* Q0 */
+ move16();
+ move16();
- for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
+ FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
{
- if ( ( error = create_cpe_enc_fx( st_ivas, cpe_id, ( ivas_total_brate / ( hEncoderConfig->nchan_inp - 1 ) * CPE_CHANNELS ) ) ) != IVAS_ERR_OK )
+ Word32 res_dec, res_frac;
+ iDiv_and_mod_32( ivas_total_brate, sub( hEncoderConfig->nchan_inp, 1 ), &res_dec, &res_frac, 0 );
+ IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, imult3216( res_dec, CPE_CHANNELS ) ) ) != IVAS_ERR_OK )
{
return error;
}
}
- if ( ( error = create_mct_enc( st_ivas ) ) != IVAS_ERR_OK )
+ IF( ( error = create_mct_enc_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
- if ( ( error = ivas_create_lfe_enc( &st_ivas->hLFE, input_Fs ) ) != IVAS_ERR_OK )
+ IF( ( error = ivas_create_lfe_enc_fx( &st_ivas->hLFE, input_Fs ) ) != IVAS_ERR_OK )
{
return error;
}
- st_ivas->nchan_transport = ivas_mc_ls_setup_get_num_channels_fx( st_ivas->hEncoderConfig->mc_input_setup );
+ st_ivas->nchan_transport = ivas_mc_ls_setup_get_num_channels_fx( st_ivas->hEncoderConfig->mc_input_setup ); /* Q0 */
+ move16();
}
- else if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX )
+ ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) )
{
st_ivas->nSCE = 0;
st_ivas->nCPE = MC_PARAMUPMIX_MAX_TRANSPORT_CHANS / 2;
st_ivas->nchan_transport = MC_PARAMUPMIX_MAX_TRANSPORT_CHANS;
+ move16();
+ move16();
+ move16();
- if ( ( error = ivas_mc_paramupmix_enc_open( st_ivas ) ) != IVAS_ERR_OK )
+ IF( ( error = ivas_mc_paramupmix_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
- for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
+ FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
{
- if ( ( error = create_cpe_enc_fx( st_ivas, cpe_id, ( ivas_total_brate / st_ivas->nCPE ) ) ) != IVAS_ERR_OK )
+ Word32 res_dec, res_frac;
+ iDiv_and_mod_32( ivas_total_brate, st_ivas->nCPE, &res_dec, &res_frac, 0 );
+ IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, res_dec ) ) != IVAS_ERR_OK )
{
return error;
}
}
- if ( ( error = create_mct_enc( st_ivas ) ) != IVAS_ERR_OK )
+ IF( ( error = create_mct_enc_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
- if ( ( error = ivas_create_lfe_enc( &st_ivas->hLFE, input_Fs ) ) != IVAS_ERR_OK )
+ IF( ( error = ivas_create_lfe_enc_fx( &st_ivas->hLFE, input_Fs ) ) != IVAS_ERR_OK )
{
return error;
}
}
- else if ( st_ivas->mc_mode == MC_MODE_PARAMMC )
+ ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMMC ) )
{
- if ( ( error = ivas_param_mc_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK )
+ IF( ( error = ivas_param_mc_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
- for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
+ FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
{
- if ( ( error = create_cpe_enc_fx( st_ivas, cpe_id, ivas_total_brate / ( st_ivas->nCPE + st_ivas->nSCE ) ) ) != IVAS_ERR_OK )
+ Word32 res_dec, res_frac;
+ iDiv_and_mod_32( ivas_total_brate, add( st_ivas->nCPE, st_ivas->nSCE ), &res_dec, &res_frac, 0 );
+ IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, res_dec ) ) != IVAS_ERR_OK )
{
return error;
}
}
- if ( st_ivas->nCPE > 1 )
+ IF( GT_16( st_ivas->nCPE, 1 ) )
{
- if ( ( error = create_mct_enc( st_ivas ) ) != IVAS_ERR_OK )
+ IF( ( error = create_mct_enc_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
}
}
- else if ( st_ivas->mc_mode == MC_MODE_MCMASA )
+ ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_MCMASA ) )
{
Word32 brate_sce, brate_cpe;
@@ -946,11 +1009,11 @@ ivas_error ivas_init_encoder(
return error;
}
- if ( ( error = ivas_masa_enc_open( st_ivas ) ) != IVAS_ERR_OK )
+ IF( ( error = ivas_masa_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
- if ( ( error = ivas_mcmasa_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK )
+ IF( ( error = ivas_mcmasa_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -965,11 +1028,12 @@ ivas_error ivas_init_encoder(
}
}
- for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
+ FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
{
hEncoderConfig->element_mode_init = IVAS_CPE_MDCT;
+ move16();
- if ( ( error = create_cpe_enc_fx( st_ivas, cpe_id, brate_cpe ) ) != IVAS_ERR_OK )
+ IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, brate_cpe ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -982,7 +1046,8 @@ ivas_error ivas_init_encoder(
*-----------------------------------------------------------------*/
/* set number of input channels used for analysis/coding */
- n = getNumChanAnalysis_fx( st_ivas );
+ n = getNumChanAnalysis_fx( st_ivas ); /* Q0 */
+ move16();
IF( n > 0 )
{
@@ -1026,18 +1091,18 @@ ivas_error ivas_init_encoder_fx(
hEncoderConfig = st_ivas->hEncoderConfig;
ivas_format = hEncoderConfig->ivas_format;
move32();
- input_Fs = hEncoderConfig->input_Fs;
+ input_Fs = hEncoderConfig->input_Fs; /* Q0 */
move32();
- ivas_total_brate = hEncoderConfig->ivas_total_brate;
+ ivas_total_brate = hEncoderConfig->ivas_total_brate; /* Q0 */
move32();
- hEncoderConfig->last_ivas_total_brate = ivas_total_brate;
+ hEncoderConfig->last_ivas_total_brate = ivas_total_brate; /* Q0 */
move32();
IF( NE_16( ivas_format, MONO_FORMAT ) )
{
/* In IVAS, ensure that minimum coded bandwidth is WB */
- hEncoderConfig->max_bwidth = extract_l( L_max( hEncoderConfig->max_bwidth, WB ) );
+ hEncoderConfig->max_bwidth = extract_l( L_max( hEncoderConfig->max_bwidth, WB ) ); /* Q0 */
move16();
}
st_ivas->ism_mode = ISM_MODE_NONE;
@@ -1052,7 +1117,7 @@ ivas_error ivas_init_encoder_fx(
* Allocate floating-point input audio buffers
*-----------------------------------------------------------------*/
- nchan_inp_buff = hEncoderConfig->nchan_inp;
+ nchan_inp_buff = hEncoderConfig->nchan_inp; /* Q0 */
move16();
IF( EQ_16( ivas_format, MONO_FORMAT ) )
{
@@ -1063,10 +1128,10 @@ ivas_error ivas_init_encoder_fx(
{
IF( EQ_16( sub( hEncoderConfig->nchan_inp, hEncoderConfig->nchan_ism ), 1 ) ) /* mono is duplicated in monoMASA */
{
- nchan_inp_buff = add( nchan_inp_buff, 1 );
+ nchan_inp_buff = add( nchan_inp_buff, 1 ); /* Q0 */
}
- nchan_inp_buff = add( nchan_inp_buff, 1 ); /* for *data_separated_object */
+ nchan_inp_buff = add( nchan_inp_buff, 1 ); /* for *data_separated_object Q0*/
}
FOR( n = 0; n < nchan_inp_buff; n++ )
@@ -1088,7 +1153,7 @@ ivas_error ivas_init_encoder_fx(
*-----------------------------------------------------------------*/
/* set the maximum allowed number of indices in the list */
- st_ivas->ivas_max_num_indices = get_ivas_max_num_indices_fx( ivas_format, ivas_total_brate );
+ st_ivas->ivas_max_num_indices = get_ivas_max_num_indices_fx( ivas_format, ivas_total_brate ); /* Q0 */
move16();
/* allocate buffer of indices */
@@ -1105,7 +1170,7 @@ ivas_error ivas_init_encoder_fx(
}
/* set the maximum allowed number of metadata indices in the list */
- st_ivas->ivas_max_num_indices_metadata = get_ivas_max_num_indices_metadata_fx( st_ivas->hEncoderConfig->ivas_format, st_ivas->hEncoderConfig->ivas_total_brate );
+ st_ivas->ivas_max_num_indices_metadata = get_ivas_max_num_indices_metadata_fx( st_ivas->hEncoderConfig->ivas_format, st_ivas->hEncoderConfig->ivas_total_brate ); /* Q0 */
move16();
/* allocate buffer of metadata indices */
IF( st_ivas->ivas_max_num_indices_metadata > 0 )
@@ -1131,7 +1196,7 @@ ivas_error ivas_init_encoder_fx(
* Allocate and initialize SCE/CPE and other handles
*-----------------------------------------------------------------*/
test();
- IF( EQ_16( ivas_format, MONO_FORMAT ) )
+ IF( EQ_32( ivas_format, MONO_FORMAT ) )
{
st_ivas->nSCE = 1; /* in mono, there is always only one SCE */
move16();
@@ -1143,16 +1208,16 @@ ivas_error ivas_init_encoder_fx(
move16();
test();
- IF( EQ_16( st_ivas->hEncoderConfig->element_mode_init, EVS_MONO ) )
+ IF( st_ivas->hEncoderConfig->element_mode_init == EVS_MONO )
{
- IF( NE_32( ( 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;
}
}
ELSE
{
- IF( NE_32( ( error = create_sce_enc_fx( st_ivas, sce_id, ivas_total_brate ) ), IVAS_ERR_OK ) )
+ IF( ( error = create_sce_enc_fx( st_ivas, sce_id, ivas_total_brate ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -1161,13 +1226,13 @@ ivas_error ivas_init_encoder_fx(
/* prepare stereo downmix for EVS */
IF( EQ_16( hEncoderConfig->stereo_dmx_evs, 1 ) )
{
- IF( NE_32( ( error = stereo_dmx_evs_init_encoder_fx( &( st_ivas->hStereoDmxEVS ), input_Fs ) ), IVAS_ERR_OK ) )
+ IF( ( error = stereo_dmx_evs_init_encoder_fx( &( st_ivas->hStereoDmxEVS ), input_Fs ) ) != IVAS_ERR_OK )
{
return error;
}
}
}
- ELSE IF( ivas_format == STEREO_FORMAT )
+ ELSE IF( EQ_32( ivas_format, STEREO_FORMAT ) )
{
st_ivas->nSCE = 0;
move16();
@@ -1178,24 +1243,24 @@ ivas_error ivas_init_encoder_fx(
cpe_id = 0;
move16();
- IF( NE_32( ( error = create_cpe_enc_fx( st_ivas, cpe_id, ivas_total_brate ) ), IVAS_ERR_OK ) )
+ IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, ivas_total_brate ) ) != IVAS_ERR_OK )
{
return error;
}
}
ELSE IF( EQ_32( ivas_format, ISM_FORMAT ) )
{
- st_ivas->ism_mode = ivas_ism_mode_select( hEncoderConfig->nchan_inp, ivas_total_brate );
+ st_ivas->ism_mode = ivas_ism_mode_select( hEncoderConfig->nchan_inp, ivas_total_brate ); /* Q0 */
move32();
- IF( NE_32( ( error = ivas_ism_metadata_enc_create( st_ivas, hEncoderConfig->nchan_inp, element_brate_tmp ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_ism_metadata_enc_create_fx( st_ivas, hEncoderConfig->nchan_inp, element_brate_tmp ) ) != IVAS_ERR_OK )
{
return error;
}
FOR( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ )
{
- IF( NE_32( ( error = create_sce_enc_fx( st_ivas, sce_id, element_brate_tmp[sce_id] ) ), IVAS_ERR_OK ) )
+ IF( ( error = create_sce_enc_fx( st_ivas, sce_id, element_brate_tmp[sce_id] ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -1203,7 +1268,7 @@ ivas_error ivas_init_encoder_fx(
IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) )
{
- IF( NE_32( ( error = ivas_param_ism_enc_open( st_ivas ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_param_ism_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -1211,7 +1276,7 @@ ivas_error ivas_init_encoder_fx(
IF( st_ivas->hEncoderConfig->Opt_DTX_ON )
{
- IF( NE_32( ( error = ivas_ism_dtx_open( st_ivas ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_ism_dtx_open( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -1219,31 +1284,31 @@ ivas_error ivas_init_encoder_fx(
}
ELSE IF( EQ_32( ivas_format, SBA_FORMAT ) || EQ_32( ivas_format, MASA_FORMAT ) )
{
- IF( NE_32( ( error = ivas_qmetadata_open_fx( &( st_ivas->hQMetaData ) ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_qmetadata_open_fx( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK )
{
return error;
}
IF( EQ_32( ivas_format, SBA_FORMAT ) )
{
- st_ivas->sba_analysis_order = ivas_sba_get_analysis_order_fx( ivas_total_brate, st_ivas->hEncoderConfig->sba_order );
+ st_ivas->sba_analysis_order = ivas_sba_get_analysis_order_fx( ivas_total_brate, st_ivas->hEncoderConfig->sba_order ); /* Q0 */
move16();
- IF( NE_32( ( error = ivas_spar_enc_open_fx( st_ivas, 0 ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_spar_enc_open_fx( st_ivas, 0 ) ) != IVAS_ERR_OK )
{
return error;
}
- IF( NE_32( ( error = ivas_dirac_enc_open_fx( st_ivas ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_dirac_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
}
ELSE
{
- st_ivas->nchan_transport = hEncoderConfig->nchan_inp;
+ st_ivas->nchan_transport = hEncoderConfig->nchan_inp; /* Q0 */
move16();
- IF( NE_32( ( error = ivas_masa_enc_open( st_ivas ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_masa_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -1253,7 +1318,7 @@ ivas_error ivas_init_encoder_fx(
{
Word32 res_dec, res_frac;
iDiv_and_mod_32( ivas_total_brate, st_ivas->nchan_transport, &res_dec, &res_frac, 0 );
- IF( NE_32( ( error = create_sce_enc_fx( st_ivas, sce_id, res_dec ) ), IVAS_ERR_OK ) )
+ IF( ( error = create_sce_enc_fx( st_ivas, sce_id, res_dec ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -1269,7 +1334,7 @@ ivas_error ivas_init_encoder_fx(
{
Word32 res_dec, res_frac;
iDiv_and_mod_32( ivas_total_brate, st_ivas->nchan_transport, &res_dec, &res_frac, 0 );
- IF( NE_32( ( error = create_cpe_enc_fx( st_ivas, cpe_id, imult3216( res_dec, CPE_CHANNELS ) ) ), IVAS_ERR_OK ) )
+ IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, imult3216( res_dec, CPE_CHANNELS ) ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -1286,7 +1351,7 @@ ivas_error ivas_init_encoder_fx(
IF( st_ivas->nCPE > 1 )
{
- IF( NE_32( ( error = create_mct_enc( st_ivas ) ), IVAS_ERR_OK ) )
+ IF( ( error = create_mct_enc_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -1297,12 +1362,12 @@ ivas_error ivas_init_encoder_fx(
Word32 ism_total_brate;
Word16 k;
- st_ivas->ism_mode = ivas_omasa_ism_mode_select_fx( ivas_total_brate, hEncoderConfig->nchan_ism );
+ st_ivas->ism_mode = ivas_omasa_ism_mode_select_fx( ivas_total_brate, hEncoderConfig->nchan_ism ); /* Q0 */
move32();
st_ivas->nchan_transport = 2;
move16();
- IF( NE_32( ( error = ivas_ism_metadata_enc_create( st_ivas, hEncoderConfig->nchan_ism, element_brate_tmp ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_ism_metadata_enc_create_fx( st_ivas, hEncoderConfig->nchan_ism, element_brate_tmp ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -1312,32 +1377,32 @@ ivas_error ivas_init_encoder_fx(
test();
WHILE( LT_16( k, SIZE_IVAS_BRATE_TBL ) && NE_32( ivas_total_brate, ivas_brate_tbl[k] ) )
{
- k = add( k, 1 );
+ k++;
}
ism_total_brate = 0;
move32();
FOR( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ )
{
- ism_total_brate = L_add( ism_total_brate, sep_object_brate[k - 2][st_ivas->nSCE - 1] );
- IF( NE_32( ( error = create_sce_enc_fx( st_ivas, sce_id, sep_object_brate[k - 2][st_ivas->nSCE - 1] ) ), IVAS_ERR_OK ) )
+ ism_total_brate = L_add( ism_total_brate, sep_object_brate[k - 2][st_ivas->nSCE - 1] ); /* Q0 */
+ IF( ( error = create_sce_enc_fx( st_ivas, sce_id, sep_object_brate[k - 2][st_ivas->nSCE - 1] ) ) != IVAS_ERR_OK )
{
return error;
}
}
- IF( NE_32( ( error = ivas_qmetadata_open_fx( &( st_ivas->hQMetaData ) ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_qmetadata_open_fx( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK )
{
return error;
}
- IF( NE_32( ( error = ivas_masa_enc_open( st_ivas ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_masa_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
IF( NE_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) )
{
- IF( NE_32( ( error = ivas_omasa_enc_open_fx( st_ivas ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_omasa_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -1354,7 +1419,7 @@ ivas_error ivas_init_encoder_fx(
move16();
}
- IF( NE_32( ( error = create_cpe_enc_fx( st_ivas, 0, L_sub( ivas_total_brate, ism_total_brate ) ) ), IVAS_ERR_OK ) )
+ IF( ( error = create_cpe_enc_fx( st_ivas, 0, L_sub( ivas_total_brate, ism_total_brate ) ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -1370,25 +1435,25 @@ ivas_error ivas_init_encoder_fx(
move32();
}
- IF( NE_32( ( error = ivas_ism_metadata_enc_create( st_ivas, hEncoderConfig->nchan_ism, element_brate_tmp ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_ism_metadata_enc_create_fx( st_ivas, hEncoderConfig->nchan_ism, element_brate_tmp ) ) != IVAS_ERR_OK )
{
return error;
}
/* allocate and initialize SBA handles */
- IF( NE_32( ( error = ivas_qmetadata_open_fx( &( st_ivas->hQMetaData ) ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_qmetadata_open_fx( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK )
{
return error;
}
- st_ivas->sba_analysis_order = ivas_sba_get_analysis_order_fx( ivas_total_brate, st_ivas->hEncoderConfig->sba_order );
+ st_ivas->sba_analysis_order = ivas_sba_get_analysis_order_fx( ivas_total_brate, st_ivas->hEncoderConfig->sba_order ); /* Q0 */
- IF( NE_32( ( error = ivas_spar_enc_open_fx( st_ivas, 0 ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_spar_enc_open_fx( st_ivas, 0 ) ) != IVAS_ERR_OK )
{
return error;
}
- IF( NE_32( ( error = ivas_dirac_enc_open_fx( st_ivas ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_dirac_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -1398,7 +1463,7 @@ ivas_error ivas_init_encoder_fx(
/* allocate and initialize SBA core-coders */
IF( EQ_16( st_ivas->nchan_transport, 1 ) )
{
- IF( NE_32( ( error = create_sce_enc_fx( st_ivas, 0, ivas_total_brate ) ), IVAS_ERR_OK ) )
+ IF( ( error = create_sce_enc_fx( st_ivas, 0, ivas_total_brate ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -1408,7 +1473,7 @@ ivas_error ivas_init_encoder_fx(
{
Word32 res_dec, res_frac;
iDiv_and_mod_32( ivas_total_brate, st_ivas->nchan_transport, &res_dec, &res_frac, 0 );
- IF( NE_32( ( error = create_cpe_enc_fx( st_ivas, cpe_id, imult3216( res_dec, CPE_CHANNELS ) ) ), IVAS_ERR_OK ) )
+ IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, imult3216( res_dec, CPE_CHANNELS ) ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -1416,7 +1481,7 @@ ivas_error ivas_init_encoder_fx(
IF( GT_16( st_ivas->nCPE, 1 ) )
{
- IF( NE_32( ( error = create_mct_enc( st_ivas ) ), IVAS_ERR_OK ) )
+ IF( ( error = create_mct_enc_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -1425,34 +1490,34 @@ ivas_error ivas_init_encoder_fx(
ELSE
{
/* allocate and initialize MCT core coder */
- st_ivas->nCPE = add( st_ivas->nCPE, shr( add( st_ivas->hEncoderConfig->nchan_ism, 1 ), 1 ) );
+ st_ivas->nCPE = add( st_ivas->nCPE, shr( add( st_ivas->hEncoderConfig->nchan_ism, 1 ), 1 ) ); /* Q0 */
FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
{
Word32 res_dec, res_frac;
iDiv_and_mod_32( ivas_total_brate, st_ivas->nchan_transport, &res_dec, &res_frac, 0 );
- IF( NE_32( ( error = create_cpe_enc_fx( st_ivas, cpe_id, imult3216( res_dec, CPE_CHANNELS ) ) ), IVAS_ERR_OK ) )
+ IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, imult3216( res_dec, CPE_CHANNELS ) ) ) != IVAS_ERR_OK )
{
return error;
}
}
- IF( NE_32( ( error = create_mct_enc( st_ivas ) ), IVAS_ERR_OK ) )
+ IF( ( error = create_mct_enc_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
}
- IF( NE_32( ( error = ivas_osba_enc_open_fx( st_ivas ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_osba_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
}
ELSE IF( EQ_32( ivas_format, MC_FORMAT ) )
{
- st_ivas->mc_mode = ivas_mc_mode_select_fx( hEncoderConfig->mc_input_setup, ivas_total_brate );
+ st_ivas->mc_mode = ivas_mc_mode_select_fx( hEncoderConfig->mc_input_setup, ivas_total_brate ); /* Q0 */
move32();
- IF( NE_32( ( error = ivas_create_lfe_lpf_enc_fx( &st_ivas->hLfeLpf, hEncoderConfig->input_Fs ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_create_lfe_lpf_enc_fx( &st_ivas->hLfeLpf, hEncoderConfig->input_Fs ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -1461,30 +1526,30 @@ ivas_error ivas_init_encoder_fx(
{
st_ivas->nSCE = 0;
move16();
- st_ivas->nCPE = idiv1616( hEncoderConfig->nchan_inp, CPE_CHANNELS );
+ st_ivas->nCPE = idiv1616( hEncoderConfig->nchan_inp, CPE_CHANNELS ); /* Q0 */
move16();
FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
{
Word32 res_dec, res_frac;
iDiv_and_mod_32( ivas_total_brate, sub( hEncoderConfig->nchan_inp, 1 ), &res_dec, &res_frac, 0 );
- IF( NE_32( ( error = create_cpe_enc_fx( st_ivas, cpe_id, imult3216( res_dec, CPE_CHANNELS ) ) ), IVAS_ERR_OK ) )
+ IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, imult3216( res_dec, CPE_CHANNELS ) ) ) != IVAS_ERR_OK )
{
return error;
}
}
- IF( NE_32( ( error = create_mct_enc( st_ivas ) ), IVAS_ERR_OK ) )
+ IF( ( error = create_mct_enc_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
- IF( NE_32( ( error = ivas_create_lfe_enc( &st_ivas->hLFE, input_Fs ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_create_lfe_enc_fx( &st_ivas->hLFE, input_Fs ) ) != IVAS_ERR_OK )
{
return error;
}
- st_ivas->nchan_transport = ivas_mc_ls_setup_get_num_channels_fx( st_ivas->hEncoderConfig->mc_input_setup );
+ st_ivas->nchan_transport = ivas_mc_ls_setup_get_num_channels_fx( st_ivas->hEncoderConfig->mc_input_setup ); /* Q0 */
move16();
}
ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) )
@@ -1496,7 +1561,7 @@ ivas_error ivas_init_encoder_fx(
st_ivas->nchan_transport = MC_PARAMUPMIX_MAX_TRANSPORT_CHANS;
move16();
- IF( NE_32( ( error = ivas_mc_paramupmix_enc_open( st_ivas ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_mc_paramupmix_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -1505,32 +1570,32 @@ ivas_error ivas_init_encoder_fx(
{
Word32 res_dec, res_frac;
iDiv_and_mod_32( ivas_total_brate, st_ivas->nCPE, &res_dec, &res_frac, 0 );
- IF( NE_32( ( error = create_cpe_enc_fx( st_ivas, cpe_id, res_dec ) ), IVAS_ERR_OK ) )
+ IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, res_dec ) ) != IVAS_ERR_OK )
{
return error;
}
}
- IF( NE_32( ( error = create_mct_enc( st_ivas ) ), IVAS_ERR_OK ) )
+ IF( ( error = create_mct_enc_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
- IF( NE_32( ( error = ivas_create_lfe_enc( &st_ivas->hLFE, input_Fs ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_create_lfe_enc_fx( &st_ivas->hLFE, input_Fs ) ) != IVAS_ERR_OK )
{
return error;
}
}
- ELSE IF( st_ivas->mc_mode == MC_MODE_PARAMMC )
+ ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMMC ) )
{
- IF( NE_32( ( error = ivas_param_mc_enc_open_fx( st_ivas ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_param_mc_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
{
- IF( NE_32( ( error = create_cpe_enc_fx( st_ivas, cpe_id, ivas_total_brate / ( st_ivas->nCPE + st_ivas->nSCE ) ) ), IVAS_ERR_OK ) )
+ IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, ivas_total_brate / ( st_ivas->nCPE + st_ivas->nSCE ) ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -1538,7 +1603,7 @@ ivas_error ivas_init_encoder_fx(
IF( GT_16( st_ivas->nCPE, 1 ) )
{
- IF( NE_32( ( error = create_mct_enc( st_ivas ) ), IVAS_ERR_OK ) )
+ IF( ( error = create_mct_enc_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -1550,17 +1615,17 @@ ivas_error ivas_init_encoder_fx(
ivas_mcmasa_setNumTransportChannels_fx( &( st_ivas->nchan_transport ), &( hEncoderConfig->element_mode_init ), ivas_total_brate );
- IF( NE_32( ( error = ivas_qmetadata_open_fx( &( st_ivas->hQMetaData ) ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_qmetadata_open_fx( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK )
{
return error;
}
- IF( NE_32( ( error = ivas_masa_enc_open( st_ivas ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_masa_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
- IF( NE_32( ( error = ivas_mcmasa_enc_open_fx( st_ivas ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_mcmasa_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -1568,7 +1633,7 @@ ivas_error ivas_init_encoder_fx(
FOR( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ )
{
- IF( NE_32( ( error = create_sce_enc_fx( st_ivas, sce_id, brate_sce ) ), IVAS_ERR_OK ) )
+ IF( ( error = create_sce_enc_fx( st_ivas, sce_id, brate_sce ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -1576,10 +1641,10 @@ ivas_error ivas_init_encoder_fx(
FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
{
- hEncoderConfig->element_mode_init = IVAS_CPE_MDCT;
+ hEncoderConfig->element_mode_init = IVAS_CPE_MDCT; /* Q0 */
move16();
- IF( NE_32( ( error = create_cpe_enc_fx( st_ivas, cpe_id, brate_cpe ) ), IVAS_ERR_OK ) )
+ IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, brate_cpe ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -1929,23 +1994,24 @@ void destroy_evs_core_enc_fx(
/*-------------------------------------------------------------------------
- * ivas_destroy_enc()
+ * ivas_destroy_enc_fx()
*
* Close IVAS encoder handles
*-------------------------------------------------------------------------*/
-void ivas_destroy_enc(
+void ivas_destroy_enc_fx(
Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */
)
{
Word16 i, n, nchan_inp;
nchan_inp = st_ivas->hEncoderConfig->nchan_inp;
+ move16();
/* SCE handles */
for ( i = 0; i < MAX_SCE; i++ )
{
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;
}
}
@@ -1963,7 +2029,7 @@ void ivas_destroy_enc(
/* HP20 filter handles */
if ( st_ivas->mem_hp20_in_fx != NULL )
{
- n = getNumChanAnalysis_fx( st_ivas );
+ n = getNumChanAnalysis_fx( st_ivas ); /* Q0 */
for ( i = 0; i < n; i++ )
{
@@ -1991,25 +2057,25 @@ void ivas_destroy_enc(
ivas_dirac_enc_close_fx( &( st_ivas->hDirAC ), st_ivas->hEncoderConfig->input_Fs );
/* ParamISM handle */
- ivas_param_ism_enc_close( &( st_ivas->hParamIsm ), st_ivas->hEncoderConfig->input_Fs );
+ ivas_param_ism_enc_close_fx( &( st_ivas->hParamIsm ), st_ivas->hEncoderConfig->input_Fs );
/* SPAR handle */
ivas_spar_enc_close_fx( &( st_ivas->hSpar ), st_ivas->hEncoderConfig->input_Fs, nchan_inp, 0 );
/* MASA handle */
- ivas_masa_enc_close( &( st_ivas->hMasa ) );
+ ivas_masa_enc_close_fx( &( st_ivas->hMasa ) );
/* MCT handle */
- ivas_mct_enc_close( &( st_ivas->hMCT ) );
+ ivas_mct_enc_close_fx( &( st_ivas->hMCT ) );
/* LFE handle */
- ivas_lfe_enc_close( &( st_ivas->hLFE ) );
+ ivas_lfe_enc_close_fx( &( st_ivas->hLFE ) );
/* LFE low pass filter state */
- ivas_lfe_lpf_enc_close( &( st_ivas->hLfeLpf ) );
+ ivas_lfe_lpf_enc_close_fx( &( st_ivas->hLfeLpf ) );
/* Param-Upmix MC handle */
- ivas_mc_paramupmix_enc_close( &( st_ivas->hMCParamUpmix ), st_ivas->hEncoderConfig->input_Fs );
+ ivas_mc_paramupmix_enc_close_fx( &( st_ivas->hMCParamUpmix ), st_ivas->hEncoderConfig->input_Fs );
/* Parametric MC handle */
ivas_param_mc_enc_close_fx( &( st_ivas->hParamMC ), st_ivas->hEncoderConfig->input_Fs );
@@ -2027,27 +2093,27 @@ void ivas_destroy_enc(
stereo_dmx_evs_close_encoder_fx( &( st_ivas->hStereoDmxEVS ) );
/* Encoder configuration handle */
- if ( st_ivas->hEncoderConfig != NULL )
+ IF( st_ivas->hEncoderConfig != NULL )
{
free( st_ivas->hEncoderConfig );
st_ivas->hEncoderConfig = NULL;
}
/* Buffer of indices */
- if ( st_ivas->ind_list != NULL )
+ IF( st_ivas->ind_list != NULL )
{
free( st_ivas->ind_list );
}
- if ( st_ivas->ind_list_metadata != NULL )
+ IF( st_ivas->ind_list_metadata != NULL )
{
free( st_ivas->ind_list_metadata );
}
/* floating-point input audio buffers */
- for ( n = 0; n < MAX_INPUT_CHANNELS + MAX_NUM_OBJECTS; n++ )
+ FOR( n = 0; n < MAX_INPUT_CHANNELS + MAX_NUM_OBJECTS; n++ )
{
- if ( st_ivas->p_data_fx[n] != NULL )
+ IF( st_ivas->p_data_fx[n] != NULL )
{
free( st_ivas->p_data_fx[n] );
st_ivas->p_data_fx[n] = NULL;
@@ -2061,12 +2127,12 @@ void ivas_destroy_enc(
}
/*-------------------------------------------------------------------------
- * ivas_initialize_MD_bstr_enc()
+ * ivas_initialize_MD_bstr_enc_fx()
*
* Allocate and initialize SCE/CPE MD bitstream handle
*-------------------------------------------------------------------------*/
-ivas_error ivas_initialize_MD_bstr_enc(
+ivas_error ivas_initialize_MD_bstr_enc_fx(
BSTR_ENC_HANDLE *hMetaData_out, /* o : encoder MD bitstream handle */
Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */
)
@@ -2081,7 +2147,7 @@ ivas_error ivas_initialize_MD_bstr_enc(
/* set pointer to the buffer of metadata indices */
hMetaData->ind_list = st_ivas->ind_list_metadata;
hMetaData->ivas_ind_list_zero = &st_ivas->ind_list_metadata;
- hMetaData->ivas_max_num_indices = &st_ivas->ivas_max_num_indices_metadata;
+ hMetaData->ivas_max_num_indices = &st_ivas->ivas_max_num_indices_metadata; /* Q0 */
hMetaData->st_ivas = st_ivas;
reset_indices_enc( hMetaData, st_ivas->ivas_max_num_indices_metadata );
@@ -2093,12 +2159,12 @@ ivas_error ivas_initialize_MD_bstr_enc(
/*-------------------------------------------------------------------------
- * ivas_destroy_MD_bstr_enc()
+ * ivas_destroy_MD_bstr_enc_fx()
*
* Destroy SCE/CPE MD bitstream handle
*-------------------------------------------------------------------------*/
-void ivas_destroy_MD_bstr_enc(
+void ivas_destroy_MD_bstr_enc_fx(
BSTR_ENC_HANDLE *hMetaData /* i/o: encoder MD bitstream handle */
)
{
diff --git a/lib_enc/ivas_ism_dtx_enc.c b/lib_enc/ivas_ism_dtx_enc.c
index 791404a11104208056aa91fb8bc18c7e6e609904..f098dc0e4aa3a1f449e23ea3918334ff0aaea699 100644
--- a/lib_enc/ivas_ism_dtx_enc.c
+++ b/lib_enc/ivas_ism_dtx_enc.c
@@ -108,13 +108,13 @@ ivas_error ivas_ism_dtx_open(
Word16 ivas_ism_dtx_enc_fx(
ISM_DTX_HANDLE hISMDTX, /* i/o: ISM DTX handle */
SCE_ENC_HANDLE hSCE[MAX_SCE], /* i/o: SCE encoder structure */
- const Word32 ivas_total_brate, /* i : IVAS total bitrate */
- const Word16 nchan_ism, /* i : number of objects */
- const Word16 nchan_transport, /* i : number of transport channels */
- Word16 vad_flag[MAX_NUM_OBJECTS], /* i : VAD flag */
+ const Word32 ivas_total_brate, /* i : IVAS total bitrate Q0*/
+ const Word16 nchan_ism, /* i : number of objects Q0*/
+ const Word16 nchan_transport, /* i : number of transport channels Q0*/
+ Word16 vad_flag[MAX_NUM_OBJECTS], /* i : VAD flag Q0*/
ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handles */
- Word16 md_diff_flag[], /* o : metadata differential flag */
- Word16 *sid_flag /* o : indication of SID frame */
+ Word16 md_diff_flag[], /* o : metadata differential flag Q0*/
+ Word16 *sid_flag /* o : indication of SID frame Q0*/
)
{
Word16 ch, dtx_flag;
@@ -139,7 +139,7 @@ Word16 ivas_ism_dtx_enc_fx(
move16();
FOR( ch = 0; ch < nchan_transport; ch++ )
{
- dtx_flag = s_and( dtx_flag, !vad_flag[ch] );
+ dtx_flag = s_and( dtx_flag, !vad_flag[ch] ); /* Q0 */
}
/* compute global ISM based on long-term background noise */
@@ -222,33 +222,33 @@ Word16 ivas_ism_dtx_enc_fx(
}
/* estimate SID metadata bit-budget */
- nBits = add( nBits, 1 ); /* number of objects */
- nBits = add( nBits, 1 ); /* SID metadata flag */
+ nBits = add( nBits, 1 ); /* number of objects Q0*/
+ nBits = add( nBits, 1 ); /* SID metadata flag Q0*/
IF( EQ_16( md_diff_flag[ch], 1 ) )
{
- nBits = add( nBits, nBits_azimuth );
- nBits = add( nBits, nBits_elevation );
+ nBits = add( nBits, nBits_azimuth ); /* Q0 */
+ nBits = add( nBits, nBits_elevation ); /* Q0 */
}
}
/* calculate maximum available MD bit-budget */
nBits_MD_max = ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC;
move16();
- nBits_MD_max = sub( nBits_MD_max, SID_FORMAT_NBITS );
+ nBits_MD_max = sub( nBits_MD_max, SID_FORMAT_NBITS ); /* Q0 */
if ( GT_16( nchan_transport, 1 ) )
{
- nBits_MD_max = sub( nBits_MD_max, nBits_sce_id );
+ nBits_MD_max = sub( nBits_MD_max, nBits_sce_id ); /* Q0 */
}
FOR( ch = 0; ch < nchan_transport - 1; ch++ )
{
- nBits_MD_max = sub( nBits_MD_max, nBits_coh ); /* coherence */
+ nBits_MD_max = sub( nBits_MD_max, nBits_coh ); /* coherence Q0*/
}
if ( GT_16( nchan_ism, 3 ) )
{
- nBits_MD_max = sub( nBits_MD_max, 1 ); /* ism_mode flag */
+ nBits_MD_max = sub( nBits_MD_max, 1 ); /* ism_mode flag Q0*/
}
/* too many metadata bits -> switch to active coding */
@@ -308,12 +308,12 @@ Word16 ivas_ism_dtx_enc_fx(
}
/* * update the global SID counter */
- hISMDTX->cnt_SID_ISM = add( hISMDTX->cnt_SID_ISM, 1 );
+ hISMDTX->cnt_SID_ISM = add( hISMDTX->cnt_SID_ISM, 1 ); /* Q0 */
move16();
IF( GE_16( hISMDTX->cnt_SID_ISM, hSCE[0]->hCoreCoder[0]->hDtxEnc->max_SID ) )
{
/* adaptive SID update interval */
- hSCE[0]->hCoreCoder[0]->hDtxEnc->max_SID = hSCE[0]->hCoreCoder[0]->hDtxEnc->interval_SID;
+ hSCE[0]->hCoreCoder[0]->hDtxEnc->max_SID = hSCE[0]->hCoreCoder[0]->hDtxEnc->interval_SID; /* Q0 */
hISMDTX->cnt_SID_ISM = 0;
move16();
move16();
@@ -326,7 +326,7 @@ Word16 ivas_ism_dtx_enc_fx(
move32();
}
- IF( EQ_16( hISMDTX->cnt_SID_ISM, 0 ) )
+ IF( hISMDTX->cnt_SID_ISM == 0 )
{
hSCE[hISMDTX->sce_id_dtx]->hCoreCoder[0]->core_brate = SID_2k40;
*sid_flag = 1;
@@ -336,7 +336,7 @@ Word16 ivas_ism_dtx_enc_fx(
}
test();
- IF( EQ_16( dtx_flag, 1 ) && EQ_16( *sid_flag, 0 ) )
+ IF( EQ_16( dtx_flag, 1 ) && *sid_flag == 0 )
{
set16_fx( md_diff_flag, 0, nchan_transport );
}
@@ -352,8 +352,8 @@ Word16 ivas_ism_dtx_enc_fx(
void ivas_ism_get_sce_id_dtx_fx(
ISM_DTX_HANDLE hISMDTX, /* i/o: ISM DTX handle */
SCE_ENC_HANDLE hSCE[MAX_SCE], /* i/o: SCE encoder structure */
- const Word16 nchan_transport, /* i : number of transport channels */
- const Word16 input_frame /* i : input frame length per channel */
+ const Word16 nchan_transport, /* i : number of transport channels Q0*/
+ const Word16 input_frame /* i : input frame length per channel Q0*/
)
{
Word32 tmp_energy[MAX_NUM_OBJECTS];
@@ -380,7 +380,7 @@ void ivas_ism_get_sce_id_dtx_fx(
{
FOR( i = 0; i < ( PARAM_ISM_HYS_BUF_SIZE - 1 ); i++ )
{
- hISMDTX->long_term_energy_stereo_dmx_enc_fx[j][i] = hISMDTX->long_term_energy_stereo_dmx_enc_fx[j][i + 1];
+ hISMDTX->long_term_energy_stereo_dmx_enc_fx[j][i] = hISMDTX->long_term_energy_stereo_dmx_enc_fx[j][i + 1]; /* exp(hISMDTX->long_term_energy_stereo_dmx_enc_e) */
move32();
}
long_term_energy_stereo_dmx_enc_e[j] = 20;
@@ -404,10 +404,10 @@ void ivas_ism_get_sce_id_dtx_fx(
{
FOR( i = 0; i < PARAM_ISM_HYS_BUF_SIZE - 1; i++ )
{
- hISMDTX->long_term_energy_stereo_dmx_enc_fx[j][i] = L_shr( hISMDTX->long_term_energy_stereo_dmx_enc_fx[j][i], max_exp - hISMDTX->long_term_energy_stereo_dmx_enc_e );
+ hISMDTX->long_term_energy_stereo_dmx_enc_fx[j][i] = L_shr( hISMDTX->long_term_energy_stereo_dmx_enc_fx[j][i], max_exp - hISMDTX->long_term_energy_stereo_dmx_enc_e ); /* exp(max_exp) */
move32();
}
- hISMDTX->long_term_energy_stereo_dmx_enc_fx[j][PARAM_ISM_HYS_BUF_SIZE - 1] = L_shr( hISMDTX->long_term_energy_stereo_dmx_enc_fx[j][PARAM_ISM_HYS_BUF_SIZE - 1], max_exp - long_term_energy_stereo_dmx_enc_e[j] );
+ hISMDTX->long_term_energy_stereo_dmx_enc_fx[j][PARAM_ISM_HYS_BUF_SIZE - 1] = L_shr( hISMDTX->long_term_energy_stereo_dmx_enc_fx[j][PARAM_ISM_HYS_BUF_SIZE - 1], max_exp - long_term_energy_stereo_dmx_enc_e[j] ); /* exp(max_exp) */
move32();
}
hISMDTX->long_term_energy_stereo_dmx_enc_e = max_exp;
@@ -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();
@@ -433,10 +433,10 @@ void ivas_ism_get_sce_id_dtx_fx(
*
*-------------------------------------------------------------------*/
void ivas_ism_coh_estim_dtx_enc_fx(
- ISM_DTX_HANDLE hISMDTX, /* i/o: ISM DTX handle */
- SCE_ENC_HANDLE hSCE[MAX_SCE], /* i/o: SCE encoder structure */
- const Word16 nchan_transport, /* i : number of transport channels */
- const Word16 input_frame /* i : input frame length */
+ ISM_DTX_HANDLE hISMDTX, /* i/o: ISM DTX handle */
+ SCE_ENC_HANDLE hSCE[MAX_SCE], /* i/o: SCE encoder structure */
+ const Word16 nchan_transport, /* i : number of transport channels Q0*/
+ const Word16 input_frame /* i : input frame length Q0*/
)
{
Encoder_State *st, *st_id0;
@@ -465,7 +465,7 @@ void ivas_ism_coh_estim_dtx_enc_fx(
norm_inp = norm_l( st_id0->input32_fx[i] );
scaled_inp = L_shl( st_id0->input32_fx[i], norm_inp );
tot_exp = shl( sub( 20, norm_inp ), 1 );
- acorr_ene_fx[hISMDTX->sce_id_dtx] = BASOP_Util_Add_Mant32Exp( acorr_ene_fx[hISMDTX->sce_id_dtx], acorr_ene_e[hISMDTX->sce_id_dtx], Mult_32_32( scaled_inp, scaled_inp ), tot_exp, &acorr_ene_e[hISMDTX->sce_id_dtx] );
+ acorr_ene_fx[hISMDTX->sce_id_dtx] = BASOP_Util_Add_Mant32Exp( acorr_ene_fx[hISMDTX->sce_id_dtx], acorr_ene_e[hISMDTX->sce_id_dtx], Mult_32_32( scaled_inp, scaled_inp ), tot_exp, &acorr_ene_e[hISMDTX->sce_id_dtx] ); /* exp(acorr_ene_e) */
move32();
}
@@ -473,7 +473,7 @@ void ivas_ism_coh_estim_dtx_enc_fx(
{
IF( EQ_16( sce_id, hISMDTX->sce_id_dtx ) )
{
- hISMDTX->coh_fx[sce_id] = 32767;
+ hISMDTX->coh_fx[sce_id] = 32767; /* 1 in Q15 */
move16();
continue;
}
@@ -492,14 +492,14 @@ void ivas_ism_coh_estim_dtx_enc_fx(
norm_inp = norm_l( st->input32_fx[i] );
scaled_inp = L_shl( st->input32_fx[i], norm_inp );
tot_exp = shl( sub( 20, norm_inp ), 1 );
- acorr_ene_fx[sce_id] = BASOP_Util_Add_Mant32Exp( acorr_ene_fx[sce_id], acorr_ene_e[sce_id], Mult_32_32( scaled_inp, scaled_inp ), tot_exp, &acorr_ene_e[sce_id] );
+ acorr_ene_fx[sce_id] = BASOP_Util_Add_Mant32Exp( acorr_ene_fx[sce_id], acorr_ene_e[sce_id], Mult_32_32( scaled_inp, scaled_inp ), tot_exp, &acorr_ene_e[sce_id] ); /* exp(acorr_ene_e) */
move32();
- xcorr_ene_fx = BASOP_Util_Add_Mant32Exp( xcorr_ene_fx, xcorr_ene_e, Mult_32_32( scaled_inp, scaled_inp ), tot_exp, &xcorr_ene_e );
+ xcorr_ene_fx = BASOP_Util_Add_Mant32Exp( xcorr_ene_fx, xcorr_ene_e, Mult_32_32( scaled_inp, scaled_inp ), tot_exp, &xcorr_ene_e ); /* exp(xcorr_ene_e) */
}
Word16 coh_e;
Word16 temp_e = acorr_ene_e[hISMDTX->sce_id_dtx] + acorr_ene_e[sce_id];
Word32 temp = Sqrt32( L_add( Mult_32_32( acorr_ene_fx[hISMDTX->sce_id_dtx], acorr_ene_fx[sce_id] ), EPSILON_FX ), &temp_e ); /*fabsf( xcorr_ene ) / ( sqrtf( ( acorr_ene[hISMDTX->sce_id_dtx] * acorr_ene[sce_id] ) + EPSILON ) );*/
- hISMDTX->coh_fx[sce_id] = BASOP_Util_Divide3232_Scale( L_abs( xcorr_ene_fx ), temp, &coh_e );
+ hISMDTX->coh_fx[sce_id] = BASOP_Util_Divide3232_Scale( L_abs( xcorr_ene_fx ), temp, &coh_e ); /* coh_e + (xcorr_ene_e - temp_e) */
move16();
coh_e = add( coh_e, sub( xcorr_ene_e, temp_e ) );
IF( coh_e < 0 )
@@ -509,7 +509,7 @@ void ivas_ism_coh_estim_dtx_enc_fx(
coh_e = 0;
}
/* ensure value of coherence is between [0,1] */
- hISMDTX->coh_fx[sce_id] = check_bounds_s_fx( hISMDTX->coh_fx[sce_id], 0, shl_sat( 1, 15 - coh_e ) );
+ hISMDTX->coh_fx[sce_id] = check_bounds_s_fx( hISMDTX->coh_fx[sce_id], 0, shl_sat( 1, 15 - coh_e ) ); /* Q0 */
hISMDTX->coh_fx[sce_id] = shl_sat( hISMDTX->coh_fx[sce_id], coh_e );
move16();
move16();
diff --git a/lib_enc/ivas_ism_enc.c b/lib_enc/ivas_ism_enc.c
index 1a956f4c5a583fd8297302d0977672a3b37c78e7..3dc12da91c14b90eeface25130a6ff70fc433226 100644
--- a/lib_enc/ivas_ism_enc.c
+++ b/lib_enc/ivas_ism_enc.c
@@ -51,12 +51,12 @@
* ISM CoreCoders encoding routine
*-------------------------------------------------------------------*/
ivas_error ivas_ism_enc_fx(
- Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */
- Word32 *data[], /* i : input signal [channels][samples] Q(q_data) */
- Word16 q_data, /* i : Q-factor of input signal */
- const Word16 input_frame, /* i : input frame length per channel */
- Word16 *nb_bits_metadata, /* i : number of metadata bits */
- const Word16 flag_omasa_ener_brate /* i : less bitrate for objects in OMASA flag */
+ Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */
+ Word32 *data[], /* i : input signal [channels][samples] Q(q_data)*/
+ Word16 q_data, /* i : Q-factor of input signal */
+ const Word16 input_frame, /* i : input frame length per channel Q0*/
+ Word16 *nb_bits_metadata, /* i : number of metadata bits Q0*/
+ const Word16 flag_omasa_ener_brate /* i : less bitrate for objects in OMASA flag Q0*/
)
{
SCE_ENC_HANDLE hSCE;
@@ -138,7 +138,7 @@ ivas_error ivas_ism_enc_fx(
move16();
set16_fx( md_diff_flag, 1, nchan_ism );
- nchan_transport_ism = st_ivas->nchan_transport;
+ nchan_transport_ism = st_ivas->nchan_transport; /* Q0 */
move16();
IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) )
{
@@ -149,7 +149,7 @@ ivas_error ivas_ism_enc_fx(
}
ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) )
{
- nchan_transport_ism = st_ivas->hEncoderConfig->nchan_ism;
+ nchan_transport_ism = st_ivas->hEncoderConfig->nchan_ism; /* Q0 */
move16();
}
FOR( sce_id = 0; sce_id < nchan_transport_ism; sce_id++ )
@@ -237,11 +237,15 @@ ivas_error ivas_ism_enc_fx(
q_old_wsp = Q15;
move16();
-
+ Word16 q_fr_bands[2];
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],
- 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, 31, 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]
+#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
@@ -249,7 +253,7 @@ ivas_error ivas_ism_enc_fx(
);
e_old_wsp[sce_id][0] = sub( Q15, q_old_wsp );
move16();
- IF( NE_32( error, IVAS_ERR_OK ) )
+ IF( error != IVAS_ERR_OK )
{
return error;
}
@@ -261,7 +265,7 @@ ivas_error ivas_ism_enc_fx(
}
ELSE
{
- vad_flag[sce_id] = st->vad_flag;
+ vad_flag[sce_id] = st->vad_flag; /* Q0 */
move16();
}
}
@@ -276,7 +280,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 ) );
+#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();
}
@@ -286,7 +294,7 @@ ivas_error ivas_ism_enc_fx(
{
ivas_ism_get_sce_id_dtx_fx( st_ivas->hISMDTX, st_ivas->hSCE, st_ivas->nchan_transport, input_frame );
- dtx_flag = ivas_ism_dtx_enc_fx( st_ivas->hISMDTX, st_ivas->hSCE, st_ivas->hEncoderConfig->ivas_total_brate, nchan_ism, st_ivas->nchan_transport, vad_flag, st_ivas->hIsmMetaData, md_diff_flag, &sid_flag );
+ dtx_flag = ivas_ism_dtx_enc_fx( st_ivas->hISMDTX, st_ivas->hSCE, st_ivas->hEncoderConfig->ivas_total_brate, nchan_ism, st_ivas->nchan_transport, vad_flag, st_ivas->hIsmMetaData, md_diff_flag, &sid_flag ); /* Q0 */
IF( sid_flag )
{
@@ -300,20 +308,20 @@ ivas_error ivas_ism_enc_fx(
* Metadata quantization and encoding
*-----------------------------------------------------------------*/
- IF( EQ_16( st_ivas->ism_mode, ISM_MODE_PARAM ) )
+ IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) )
{
- ivas_param_ism_compute_noisy_speech_flag( st_ivas );
- flag_noisy_speech = st_ivas->hParamIsm->flag_noisy_speech;
+ ivas_param_ism_compute_noisy_speech_flag_fx( st_ivas );
+ flag_noisy_speech = st_ivas->hParamIsm->flag_noisy_speech; // Q0
move16();
}
IF( dtx_flag )
{
- ivas_ism_metadata_sid_enc( st_ivas->hISMDTX, flag_noisy_speech, nchan_ism, st_ivas->nchan_transport, st_ivas->ism_mode, st_ivas->hIsmMetaData, sid_flag, md_diff_flag, st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData, nb_bits_metadata );
+ ivas_ism_metadata_sid_enc_fx( st_ivas->hISMDTX, flag_noisy_speech, nchan_ism, st_ivas->nchan_transport, st_ivas->ism_mode, st_ivas->hIsmMetaData, sid_flag, md_diff_flag, st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData, nb_bits_metadata );
}
ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) )
{
- IF( NE_32( ( error = ivas_ism_metadata_enc( &st_ivas->hEncoderConfig->ivas_total_brate, nchan_ism, nchan_transport_ism, st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData, nb_bits_metadata, vad_flag, st_ivas->ism_mode, st_ivas->hParamIsm, st_ivas->hEncoderConfig->ism_extended_metadata_flag, -256 /* -1.0f in Q8 */, 0, NULL, st_ivas->hSCE[0]->hCoreCoder[0]->ini_frame ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_ism_metadata_enc_fx( &st_ivas->hEncoderConfig->ivas_total_brate, nchan_ism, nchan_transport_ism, st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData, nb_bits_metadata, vad_flag, st_ivas->ism_mode, st_ivas->hParamIsm, st_ivas->hEncoderConfig->ism_extended_metadata_flag, -256 /* -1.0f in Q8 */, 0, NULL, st_ivas->hSCE[0]->hCoreCoder[0]->ini_frame ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -327,28 +335,49 @@ ivas_error ivas_ism_enc_fx(
move16();
FOR( i = 0; i < st_ivas->nSCE; i++ )
{
- ism_total_brate = L_add( ism_total_brate, st_ivas->hSCE[i]->element_brate );
+ ism_total_brate = L_add( ism_total_brate, st_ivas->hSCE[i]->element_brate ); /* Q0 */
}
}
ELSE
{
- ism_total_brate = st_ivas->hEncoderConfig->ivas_total_brate;
+ ism_total_brate = st_ivas->hEncoderConfig->ivas_total_brate; /* Q0 */
move32();
}
- ism_total_brate_ref = ism_total_brate;
+ ism_total_brate_ref = ism_total_brate; /* Q0 */
move32();
- IF( NE_32( ( error = ivas_ism_metadata_enc( &ism_total_brate, nchan_ism, nchan_transport_ism, st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData,
- nb_bits_metadata, vad_flag, st_ivas->ism_mode, NULL, st_ivas->hEncoderConfig->ism_extended_metadata_flag, st_ivas->hMasa != NULL ? st_ivas->hMasa->data.hOmasaData->lp_noise_CPE_fx : 0, flag_omasa_ener_brate, st_ivas->hMasa != NULL ? &( st_ivas->hMasa->data.hOmasaData->omasa_stereo_sw_cnt ) : NULL, st_ivas->hSCE[0]->hCoreCoder[0]->ini_frame ) ),
- IVAS_ERR_OK ) )
+ Word16 lp_noise_CPE_fx;
+ if ( st_ivas->hMasa != NULL )
+ {
+ lp_noise_CPE_fx = st_ivas->hMasa->data.hOmasaData->lp_noise_CPE_fx;
+ move16();
+ }
+ else
+ {
+ lp_noise_CPE_fx = 0;
+ move16();
+ }
+
+ Word16 *omasa_stereo_sw_cnt;
+ if ( st_ivas->hMasa != NULL )
+ {
+ omasa_stereo_sw_cnt = &( st_ivas->hMasa->data.hOmasaData->omasa_stereo_sw_cnt );
+ }
+ else
+ {
+ omasa_stereo_sw_cnt = NULL;
+ }
+ IF( ( error = ivas_ism_metadata_enc_fx( &ism_total_brate, nchan_ism, nchan_transport_ism, st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData,
+ nb_bits_metadata, vad_flag, st_ivas->ism_mode, NULL, st_ivas->hEncoderConfig->ism_extended_metadata_flag, lp_noise_CPE_fx, flag_omasa_ener_brate, omasa_stereo_sw_cnt, st_ivas->hSCE[0]->hCoreCoder[0]->ini_frame ) ) !=
+ IVAS_ERR_OK )
{
return error;
}
IF( EQ_32( st_ivas->hEncoderConfig->ivas_format, MASA_ISM_FORMAT ) )
{
- st_ivas->hCPE[0]->brate_surplus = L_sub( ism_total_brate_ref, ism_total_brate );
+ st_ivas->hCPE[0]->brate_surplus = L_sub( ism_total_brate_ref, ism_total_brate ); /* Q0 */
move32();
}
}
@@ -403,7 +432,7 @@ ivas_error ivas_ism_enc_fx(
{
Word16 igf;
igf = getIgfPresent_fx( st->element_mode, L_mult0( st->bits_frame_nominal, FRAMES_PER_SEC ), st->max_bwidth, st->rf_mode );
- IF( NE_32( ( error = IGF_Reconfig_fx( &st->hIGFEnc, igf, 0, L_mult0( st->bits_frame_nominal, FRAMES_PER_SEC ), st->max_bwidth, st->element_mode, st->rf_mode ) ), IVAS_ERR_OK ) )
+ IF( ( error = IGF_Reconfig_fx( &st->hIGFEnc, igf, 0, L_mult0( st->bits_frame_nominal, FRAMES_PER_SEC ), st->max_bwidth, st->element_mode, st->rf_mode ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -423,7 +452,7 @@ ivas_error ivas_ism_enc_fx(
}
ELSE
{
- st->flag_ACELP16k = set_ACELP_flag_IVAS( IVAS_SCE, hSCE->element_brate, st->total_brate, 0, 0, -1, -1 );
+ st->flag_ACELP16k = set_ACELP_flag_IVAS( IVAS_SCE, hSCE->element_brate, st->total_brate, 0, 0, -1, -1 ); /* Q0 */
move16();
}
@@ -437,10 +466,10 @@ ivas_error ivas_ism_enc_fx(
test();
IF( !dtx_flag || ( dtx_flag && EQ_16( sce_id, st_ivas->hISMDTX->sce_id_dtx ) ) )
{
- Scale_sig( old_wsp_fx[sce_id][0], L_WSP, sub( e_old_wsp[sce_id][0], Q16 ) );
+ Scale_sig( old_wsp_fx[sce_id][0], L_WSP, sub( e_old_wsp[sce_id][0], Q16 ) ); /* exp(16) */
e_old_wsp[sce_id][0] = 16;
move16();
- IF( NE_32( ( error = ivas_core_enc( hSCE, NULL, NULL, 1, old_inp_12k8_fx[sce_id], old_inp_16k_fx[sce_id], Q_new[sce_id], ener_fx[sce_id], A_fx[sce_id], Aw_fx[sce_id], epsP_fx[sce_id], epsP_fx_q[sce_id], lsp_new_fx[sce_id], lsp_mid_fx[sce_id], vad_hover_flag[sce_id], attack_flag[sce_id], realBuffer_fx[sce_id], imagBuffer_fx[sce_id], &q_re_im_buf[sce_id], old_wsp_fx[sce_id], e_old_wsp[sce_id], loc_harm[sce_id], cor_map_sum_fx[sce_id], vad_flag_dtx[sce_id], enerBuffer_fx[sce_id], enerBuffer_fx_exp[sce_id], fft_buff_fx[sce_id], 0, ISM_FORMAT, 0 ) ), IVAS_ERR_OK ) )
+ IF( NE_32( ( error = ivas_core_enc_fx( hSCE, NULL, NULL, 1, old_inp_12k8_fx[sce_id], old_inp_16k_fx[sce_id], Q_new[sce_id], ener_fx[sce_id], A_fx[sce_id], Aw_fx[sce_id], epsP_fx[sce_id], epsP_fx_q[sce_id], lsp_new_fx[sce_id], lsp_mid_fx[sce_id], vad_hover_flag[sce_id], attack_flag[sce_id], realBuffer_fx[sce_id], imagBuffer_fx[sce_id], &q_re_im_buf[sce_id], old_wsp_fx[sce_id], e_old_wsp[sce_id], loc_harm[sce_id], cor_map_sum_fx[sce_id], vad_flag_dtx[sce_id], enerBuffer_fx[sce_id], enerBuffer_fx_exp[sce_id], fft_buff_fx[sce_id], 0, ISM_FORMAT, 0 ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -452,15 +481,15 @@ ivas_error ivas_ism_enc_fx(
/* update input samples buffer */
- Copy( st->input_fx, st->old_input_signal_fx, input_frame );
+ Copy( st->input_fx, st->old_input_signal_fx, input_frame ); /* st->q_inp */
st->q_old_inp = st->q_inp;
move16();
- hSCE->last_element_brate = hSCE->element_brate;
+ hSCE->last_element_brate = hSCE->element_brate; /* Q0 */
move32();
/* Store previous attack detection flag */
- st->hTranDet->transientDetector.prev_bIsAttackPresent = st->hTranDet->transientDetector.bIsAttackPresent;
+ st->hTranDet->transientDetector.prev_bIsAttackPresent = st->hTranDet->transientDetector.bIsAttackPresent; /* Q0 */
move16();
prev_st = st;
@@ -472,9 +501,9 @@ ivas_error ivas_ism_enc_fx(
{
IF( NE_16( sce_id, st_ivas->hISMDTX->sce_id_dtx ) )
{
- st_ivas->hSCE[sce_id]->hCoreCoder[0]->last_core = st_ivas->hSCE[st_ivas->hISMDTX->sce_id_dtx]->hCoreCoder[0]->last_core;
- st_ivas->hSCE[sce_id]->hCoreCoder[0]->last_core_brate = st_ivas->hSCE[st_ivas->hISMDTX->sce_id_dtx]->hCoreCoder[0]->core_brate;
- st_ivas->hSCE[sce_id]->hCoreCoder[0]->last_L_frame = st_ivas->hSCE[st_ivas->hISMDTX->sce_id_dtx]->hCoreCoder[0]->last_L_frame;
+ st_ivas->hSCE[sce_id]->hCoreCoder[0]->last_core = st_ivas->hSCE[st_ivas->hISMDTX->sce_id_dtx]->hCoreCoder[0]->last_core; /* Q0 */
+ st_ivas->hSCE[sce_id]->hCoreCoder[0]->last_core_brate = st_ivas->hSCE[st_ivas->hISMDTX->sce_id_dtx]->hCoreCoder[0]->core_brate; /* Q0 */
+ st_ivas->hSCE[sce_id]->hCoreCoder[0]->last_L_frame = st_ivas->hSCE[st_ivas->hISMDTX->sce_id_dtx]->hCoreCoder[0]->last_L_frame; /* Q0 */
move16();
move32();
move16();
@@ -509,7 +538,7 @@ ivas_error ivas_ism_enc_config(
move16();
/* select ISM format mode */
- st_ivas->ism_mode = ivas_ism_mode_select( st_ivas->hEncoderConfig->nchan_inp, st_ivas->hEncoderConfig->ivas_total_brate );
+ st_ivas->ism_mode = ivas_ism_mode_select( st_ivas->hEncoderConfig->nchan_inp, st_ivas->hEncoderConfig->ivas_total_brate ); /* Q0 */
move16();
/* ISM bit-rate switching */
@@ -518,7 +547,7 @@ ivas_error ivas_ism_enc_config(
{
Word32 element_brate_tmp[MAX_NUM_OBJECTS];
- nchan_transport_old = st_ivas->nchan_transport;
+ nchan_transport_old = st_ivas->nchan_transport; /* Q0 */
move16();
/* Reset and Initialize */
@@ -528,25 +557,25 @@ ivas_error ivas_ism_enc_config(
}
ELSE
{
- st_ivas->nchan_transport = st_ivas->hEncoderConfig->nchan_inp;
+ st_ivas->nchan_transport = st_ivas->hEncoderConfig->nchan_inp; /* Q0 */
}
move16();
- nCPE_old = st_ivas->nCPE;
+ nCPE_old = st_ivas->nCPE; /* Q0 */
move16();
- nSCE_old = st_ivas->nSCE;
+ nSCE_old = st_ivas->nSCE; /* Q0 */
move16();
- st_ivas->nSCE = st_ivas->nchan_transport;
+ st_ivas->nSCE = st_ivas->nchan_transport; /* Q0 */
move16();
st_ivas->nCPE = 0;
move16();
- IF( NE_32( ( error = ivas_ism_config_fx( st_ivas->hEncoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hEncoderConfig->nchan_inp, NULL, 0, NULL, NULL, element_brate_tmp, NULL, NULL, 0 ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_ism_config_fx( st_ivas->hEncoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hEncoderConfig->nchan_inp, NULL, 0, NULL, NULL, element_brate_tmp, NULL, NULL, 0 ) ) != IVAS_ERR_OK )
{
return error;
}
- IF( NE_32( ( error = ivas_corecoder_enc_reconfig_fx( st_ivas, nSCE_old, nCPE_old, nchan_transport_old, st_ivas->hEncoderConfig->ivas_total_brate / st_ivas->nchan_transport, imult3216( ( st_ivas->hEncoderConfig->ivas_total_brate / st_ivas->nchan_transport ), CPE_CHANNELS ), MC_MODE_NONE ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_corecoder_enc_reconfig_fx( st_ivas, nSCE_old, nCPE_old, nchan_transport_old, st_ivas->hEncoderConfig->ivas_total_brate / st_ivas->nchan_transport, imult3216( ( st_ivas->hEncoderConfig->ivas_total_brate / st_ivas->nchan_transport ), CPE_CHANNELS ), MC_MODE_NONE ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -555,7 +584,7 @@ ivas_error ivas_ism_enc_config(
IF( EQ_16( st_ivas->ism_mode, ISM_MODE_PARAM ) && EQ_16( last_ism_mode, ISM_MODE_DISC ) )
{
/* Allocate and Initialize the memory used by ParamISM when switch from Discrete ISM */
- IF( NE_32( ( error = ivas_param_ism_enc_open( st_ivas ) ), IVAS_ERR_OK ) )
+ IF( ( error = ivas_param_ism_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -565,7 +594,7 @@ ivas_error ivas_ism_enc_config(
IF( EQ_16( st_ivas->ism_mode, ISM_MODE_DISC ) && EQ_16( last_ism_mode, ISM_MODE_PARAM ) )
{
/* Deallocate the memory used by ParamISM when switch to Discrete ISM */
- ivas_param_ism_enc_close( &( st_ivas->hParamIsm ), st_ivas->hEncoderConfig->input_Fs );
+ ivas_param_ism_enc_close_fx( &( st_ivas->hParamIsm ), st_ivas->hEncoderConfig->input_Fs );
}
}
diff --git a/lib_enc/ivas_ism_metadata_enc.c b/lib_enc/ivas_ism_metadata_enc.c
index ffd0e1b1d456362d6500b9e23f4f0607d8fb0135..9bcc34dd8003099485b07e246bc3a98006ec4ce5 100644
--- a/lib_enc/ivas_ism_metadata_enc.c
+++ b/lib_enc/ivas_ism_metadata_enc.c
@@ -72,9 +72,9 @@
* Local function declarations
*-----------------------------------------------------------------------*/
-static void encode_angle_indices( BSTR_ENC_HANDLE hBstr, ISM_METADATA_ANGLE_HANDLE angle, const int16_t last_ism_metadata_flag, const int16_t ini_frame, const int16_t idx_angle1_abs, const int16_t idx_angle2_abs, int16_t *flag_abs_angle1, int16_t *flag_abs_angle2 );
+static void encode_angle_indices_fx( BSTR_ENC_HANDLE hBstr, ISM_METADATA_ANGLE_HANDLE angle, const Word16 last_ism_metadata_flag, const Word16 ini_frame, const Word16 idx_angle1_abs, const Word16 idx_angle2_abs, Word16 *flag_abs_angle1, Word16 *flag_abs_angle2 );
-static void encode_radius( BSTR_ENC_HANDLE hBstr, int16_t *last_radius_idx, int16_t *radius_diff_cnt, const int16_t last_ism_metadata_flag, const int16_t idx_radius_abs, int16_t *flag_abs_radius );
+static void encode_radius_fx( BSTR_ENC_HANDLE hBstr, Word16 *last_radius_idx, Word16 *radius_diff_cnt, const Word16 last_ism_metadata_flag, const Word16 idx_radius_abs, Word16 *flag_abs_radius );
/*-------------------------------------------------------------------------*
@@ -102,15 +102,15 @@ ivas_error ivas_set_ism_metadata_fx(
move16();
/* save read metadata parameters to the internal codec structure */
- hIsmMeta->azimuth_fx = azimuth;
+ hIsmMeta->azimuth_fx = azimuth; // Q22
move32();
- hIsmMeta->elevation_fx = elevation;
+ hIsmMeta->elevation_fx = elevation; // Q22
move32();
- hIsmMeta->radius_fx = radius_meta;
+ hIsmMeta->radius_fx = radius_meta; // Q9
move16();
- hIsmMeta->yaw_fx = yaw;
+ hIsmMeta->yaw_fx = yaw; // Q22
move16();
- hIsmMeta->pitch_fx = pitch;
+ hIsmMeta->pitch_fx = pitch; // Q22
move16();
hIsmMeta->non_diegetic_flag = non_diegetic_flag;
move16();
@@ -124,7 +124,7 @@ ivas_error ivas_set_ism_metadata_fx(
* Rate importance of particular ISM streams
*-------------------------------------------------------------------------*/
-static void rate_ism_importance(
+static void rate_ism_importance_fx(
const Word16 nchan_transport, /* i : number of transported channels */
ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handles */
SCE_ENC_HANDLE hSCE[], /* i/o: SCE encoder handles */
@@ -187,7 +187,7 @@ static void rate_ism_importance(
* quantize and encode ISM metadata
*-------------------------------------------------------------------------*/
-ivas_error ivas_ism_metadata_enc(
+ivas_error ivas_ism_metadata_enc_fx(
Word32 *ism_total_brate, /* i/o: ISM total bitrate */
const Word16 nchan_ism, /* i : number of ISM channels */
const Word16 nchan_transport, /* i : number of transport channels */
@@ -334,7 +334,7 @@ ivas_error ivas_ism_metadata_enc(
IF( NE_16( ism_mode, ISM_SBA_MODE_DISC ) )
{
- rate_ism_importance( nchan_transport, hIsmMeta, hSCE, lowrate_metadata_flag, ism_imp );
+ rate_ism_importance_fx( nchan_transport, hIsmMeta, hSCE, lowrate_metadata_flag, ism_imp );
}
}
@@ -475,18 +475,18 @@ ivas_error ivas_ism_metadata_enc(
/* Map azimuth to panning range [-90:90] */
IF( GT_32( hIsmMetaData->azimuth_fx, 377487360 /*90.0f Q22*/ ) )
{
- hIsmMetaData->azimuth_fx = L_sub( 754974720 /*180.0f Q22*/, hIsmMetaData->azimuth_fx );
+ hIsmMetaData->azimuth_fx = L_sub( 754974720 /*180.0f Q22*/, hIsmMetaData->azimuth_fx ); // Q22
move32();
}
IF( LT_32( hIsmMetaData->azimuth_fx, L_negate( 377487360 ) /*-90.0f Q22*/ ) )
{
- hIsmMetaData->azimuth_fx = L_sub( L_negate( 754974720 ) /*-180.0f Q22*/, hIsmMetaData->azimuth_fx );
+ hIsmMetaData->azimuth_fx = L_sub( L_negate( 754974720 ) /*-180.0f Q22*/, hIsmMetaData->azimuth_fx ); // Q22
move32();
}
idx_angle1_abs = ism_quant_meta_fx( hIsmMetaData->azimuth_fx, &valQ_fx, ism_azimuth_borders_fx, ISM_Q_STEP_FX, ISM_Q_STEP_BORDER_FX, 1 << ISM_AZIMUTH_NBITS );
- encode_angle_indices( hBstr, &( hIsmMetaData->position_angle ), hIsmMetaData->last_ism_metadata_flag, hSCE[0]->hCoreCoder[0]->ini_frame, idx_angle1_abs, 0, &flag_abs_azimuth[ch], NULL );
+ encode_angle_indices_fx( hBstr, &( hIsmMetaData->position_angle ), hIsmMetaData->last_ism_metadata_flag, hSCE[0]->hCoreCoder[0]->ini_frame, idx_angle1_abs, 0, &flag_abs_azimuth[ch], NULL );
}
ELSE
{
@@ -506,7 +506,7 @@ ivas_error ivas_ism_metadata_enc(
idx_angle2_abs = hParamIsm->ele_index[ch];
move16();
}
- encode_angle_indices( hBstr, &( hIsmMetaData->position_angle ), hIsmMetaData->last_ism_metadata_flag, ini_frame, idx_angle1_abs, idx_angle2_abs, &flag_abs_azimuth[ch], &flag_abs_elevation[ch] );
+ encode_angle_indices_fx( hBstr, &( hIsmMetaData->position_angle ), hIsmMetaData->last_ism_metadata_flag, ini_frame, idx_angle1_abs, idx_angle2_abs, &flag_abs_azimuth[ch], &flag_abs_elevation[ch] );
/*----------------------------------------------------------------*
* Quantize and encode radius, yaw, and pitch
*----------------------------------------------------------------*/
@@ -520,8 +520,8 @@ ivas_error ivas_ism_metadata_enc(
idx_radius_abs = usquant_fx( hIsmMetaData->radius_fx, &valQ_fx_tmp, ISM_RADIUS_MIN_Q9, ISM_RADIUS_DELTA_Q8, 1 << ISM_RADIUS_NBITS );
valQ_fx = L_shr( L_deposit_h( valQ_fx_tmp ), 3 ); // Q22
// valQ = fixedToFloat( valQ_fx, Q22 );
- encode_angle_indices( hBstr, &( hIsmMetaData->orientation_angle ), hIsmMetaData->last_ism_metadata_flag, ini_frame, idx_angle1_abs, idx_angle2_abs, &flag_abs_yaw[ch], &flag_abs_pitch[ch] );
- encode_radius( hBstr, &hIsmMetaData->last_radius_idx, &hIsmMetaData->radius_diff_cnt, hIsmMetaData->last_ism_metadata_flag, idx_radius_abs, &flag_abs_radius[ch] );
+ encode_angle_indices_fx( hBstr, &( hIsmMetaData->orientation_angle ), hIsmMetaData->last_ism_metadata_flag, ini_frame, idx_angle1_abs, idx_angle2_abs, &flag_abs_yaw[ch], &flag_abs_pitch[ch] );
+ encode_radius_fx( hBstr, &hIsmMetaData->last_radius_idx, &hIsmMetaData->radius_diff_cnt, hIsmMetaData->last_ism_metadata_flag, idx_radius_abs, &flag_abs_radius[ch] );
}
}
@@ -536,11 +536,11 @@ ivas_error ivas_ism_metadata_enc(
}
/* Updates */
- hIsmMeta[ch]->last_true_azimuth_fx = hIsmMeta[ch]->azimuth_fx;
+ hIsmMeta[ch]->last_true_azimuth_fx = hIsmMeta[ch]->azimuth_fx; // Q22
move32();
- hIsmMeta[ch]->last_true_elevation_fx = hIsmMeta[ch]->elevation_fx;
+ hIsmMeta[ch]->last_true_elevation_fx = hIsmMeta[ch]->elevation_fx; // Q22
move32();
- hIsmMeta[ch]->last_true_radius_fx = hIsmMeta[ch]->radius_fx;
+ hIsmMeta[ch]->last_true_radius_fx = hIsmMeta[ch]->radius_fx; // Q22
move16();
}
}
@@ -553,7 +553,7 @@ ivas_error ivas_ism_metadata_enc(
i = 0;
move16();
test();
- WHILE( i == 0 || i < idiv1616( nchan_ism, INTER_OBJECT_PARAM_CHECK ) )
+ WHILE( i == 0 || i < ( nchan_ism / INTER_OBJECT_PARAM_CHECK ) )
{
Word16 num, abs_num, abs_first, abs_next, pos_zero;
Word16 abs_matrice[INTER_OBJECT_PARAM_CHECK * ISM_NUM_PARAM];
@@ -581,7 +581,7 @@ ivas_error ivas_ism_metadata_enc(
abs_first = 0;
move16();
- WHILE( GT_16( abs_num, 1 ) )
+ WHILE( abs_num > 1 )
{
/* find first "1" entry */
WHILE( abs_matrice[abs_first] == 0 )
@@ -599,7 +599,7 @@ ivas_error ivas_ism_metadata_enc(
/* find "0" position */
pos_zero = 0;
move16();
- WHILE( EQ_16( abs_matrice[pos_zero], 1 ) )
+ WHILE( abs_matrice[pos_zero] == 1 )
{
pos_zero = add( pos_zero, 1 );
}
@@ -612,7 +612,7 @@ ivas_error ivas_ism_metadata_enc(
move16();
}
- IF( abs_next % ISM_NUM_PARAM == 1 )
+ IF( EQ_16( abs_next % ISM_NUM_PARAM, 1 ) )
{
hIsmMeta[ch]->position_angle.angle2_diff_cnt = sub( abs_num, 1 );
move16();
@@ -869,7 +869,7 @@ ivas_error ivas_ism_metadata_enc(
* Create, allocate, initialize and configure IVAS encoder ISM metadata handles
*-------------------------------------------------------------------------*/
-ivas_error ivas_ism_metadata_enc_create(
+ivas_error ivas_ism_metadata_enc_create_fx(
Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */
const Word16 n_ISms, /* i : number of objects */
Word32 element_brate_tmp[] /* o : element bitrate per object */
@@ -976,21 +976,21 @@ ivas_error ivas_ism_metadata_enc_create(
ivas_ism_reset_metadata_enc( st_ivas->hIsmMetaData[ch] );
- st_ivas->hIsmMetaData[ch]->last_azimuth_fx = 0;
+ st_ivas->hIsmMetaData[ch]->last_azimuth_fx = 0; // Q22
move32();
- st_ivas->hIsmMetaData[ch]->last_elevation_fx = 0;
+ st_ivas->hIsmMetaData[ch]->last_elevation_fx = 0; // Q22
move32();
- st_ivas->hIsmMetaData[ch]->last_true_azimuth_fx = 0;
+ st_ivas->hIsmMetaData[ch]->last_true_azimuth_fx = 0; // Q22
move32();
- st_ivas->hIsmMetaData[ch]->last_true_elevation_fx = 0;
+ st_ivas->hIsmMetaData[ch]->last_true_elevation_fx = 0; // Q22
move32();
st_ivas->hIsmMetaData[ch]->ism_md_fec_cnt_enc = 0;
move16();
st_ivas->hIsmMetaData[ch]->ism_md_inc_diff_cnt = ISM_MD_INC_DIFF_CNT_MAX;
move16();
- st_ivas->hIsmMetaData[ch]->last_true_radius_fx = ONE_IN_Q9;
+ st_ivas->hIsmMetaData[ch]->last_true_radius_fx = ONE_IN_Q9; // Q9
move16();
}
@@ -1028,7 +1028,7 @@ ivas_error ivas_ism_metadata_enc_create(
*
* Radius index encoding
*-------------------------------------------------------------------------*/
-static void encode_radius(
+static void encode_radius_fx(
BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
Word16 *last_radius_idx, /* i/o: last radius index */
Word16 *radius_diff_cnt, /* i/o: radius diff coding counter */
@@ -1143,7 +1143,7 @@ static void encode_radius(
* Encoding of an angle
*----------------------------------------------------------------*/
-static void encode_angle_indices(
+static void encode_angle_indices_fx(
BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
ISM_METADATA_ANGLE_HANDLE angle, /* i/o: angle handle */
const Word16 last_ism_metadata_flag, /* i : last frame ism_metadata_flag */
@@ -1168,8 +1168,8 @@ static void encode_angle_indices(
move16();
*flag_abs_angle1 = 0; /* differential coding by default */
test();
- if ( EQ_16( angle->angle1_diff_cnt, ISM_FEC_MAX ) /* make differential encoding in ISM_FEC_MAX consecutive frames at maximum (in order to control the decoding in FEC) */
- || last_ism_metadata_flag == 0 /* If last frame had no metadata coded, do not use differential coding */
+ IF( EQ_16( angle->angle1_diff_cnt, ISM_FEC_MAX ) /* make differential encoding in ISM_FEC_MAX consecutive frames at maximum (in order to control the decoding in FEC) */
+ || last_ism_metadata_flag == 0 /* If last frame had no metadata coded, do not use differential coding */
)
{
*flag_abs_angle1 = 1;
@@ -1418,7 +1418,7 @@ static void encode_angle_indices(
* Quantize and encode ISM metadata in SID frame
*-------------------------------------------------------------------*/
-void ivas_ism_metadata_sid_enc(
+void ivas_ism_metadata_sid_enc_fx(
ISM_DTX_HANDLE hISMDTX, /* i/o: ISM DTX handle */
const Word16 flag_noisy_speech, /* i : noisy speech flag */
const Word16 nchan_ism, /* i : number of objects */
diff --git a/lib_enc/ivas_ism_param_enc.c b/lib_enc/ivas_ism_param_enc.c
index 171b229b4bcd8d47533f0b9c98ba640b7e387970..1430607d63c1a7d7f103bf877c38327641aae61a 100644
--- a/lib_enc/ivas_ism_param_enc.c
+++ b/lib_enc/ivas_ism_param_enc.c
@@ -160,7 +160,7 @@ static void ivas_param_ism_compute_obj_parameters_fx(
move16();
move16();
}
- assert( ( power_ratios_m[b][m] >= ONE_IN_Q14 /* 0.5 in Q15 */ ) && ( power_ratios_m[b][m] <= ONE_IN_Q15 /* 1 in Q15 */ ) );
+ assert( ( power_ratios_m[b][m] >= ONE_IN_Q14 /* 0.5 in Q15 */ ) && ( power_ratios_m[b][m] <= MAX_16 /* 1 in Q15 */ ) );
/* Quantize power ratios */
/* Power ratio range [0.5,1] is mapped to [0,1] first, rounding via truncation float->integer */
@@ -180,7 +180,7 @@ static void ivas_param_ism_compute_obj_parameters_fx(
tmp1 = W_norm( ref_power_local_frame[0] );
tmp2 = W_norm( ref_power_local_frame[i] );
tmp_ratio = BASOP_Util_Divide3232_Scale( W_extract_h( W_shl( ref_power_local_frame[0], tmp1 ) ), W_extract_h( W_shl( ref_power_local_frame[i], tmp2 ) ), &e_tmp ); // ((Qx + tmp1) - 16) - ((Qx + tmp2) - 16) + 15 - e_tmp = 15 + tmp1 - tmp2 - e_tmp
- tmp_ratio = W_shl( tmp_ratio, sub( sub( e_tmp, 1 ), sub( tmp1, tmp2 ) ) ); // Q14
+ tmp_ratio = W_shl( tmp_ratio, sub( sub( e_tmp, 1 ), sub( tmp1, tmp2 ) ) ); // Q14 // Q14
test();
IF( GT_64( tmp_ratio, 15974 /* 0.975f in Q14 */ ) && LT_64( tmp_ratio, 16794 /* 1.025f in Q14*/ ) )
@@ -220,7 +220,7 @@ static void ivas_param_ism_enc_quantize_DOA_fx(
azi_idx = ism_quant_meta_fx( hIsmMetaData[i]->azimuth_fx, &valQ_fx, ism_azimuth_borders_fx, ISM_Q_STEP_FX, ISM_Q_STEP_BORDER_FX, 1 << ISM_AZIMUTH_NBITS );
/*Replace azimuth with quantized values */
- hIsmMetaData[i]->azimuth_fx = valQ_fx;
+ hIsmMetaData[i]->azimuth_fx = valQ_fx; // Q22
move32();
/* Copy the quantized indices */
@@ -312,17 +312,17 @@ void ivas_param_ism_stereo_dmx_fx(
cardioid_right[i] = sub( ONE_IN_Q14 /* 1.0f in Q14 */, cardioid_left[i] ); /* corresponds to: alpha + ( 1 - alpha ) * cosf( tmp + tmp_1 ); */
move16();
/* Loop over all samples */
- FOR( j = 0; j < shr( input_frame, 1 ); j++ )
+ FOR( j = 0; j < input_frame >> 1; j++ )
{
tmp = data[i][j];
move32();
- tmp = W_extract_l( W_shr( W_mult_32_16( tmp, add( last_cardioid_left, mult0( j, grad ) ) ), 15 ) );
- stereo_dmx[0][j] = L_add( stereo_dmx[0][j], tmp ); /* Qx DMX Left */
+ tmp = W_extract_l( W_shr( W_mult_32_16( tmp, add( last_cardioid_left, mult0( j, grad ) ) ), 15 ) ); /* Qx DMX Left */
+ stereo_dmx[0][j] = L_add( stereo_dmx[0][j], tmp ); /* Qx DMX Left */
move32();
tmp = data[i][j];
move32();
- tmp = W_extract_l( W_shr( W_mult_32_16( tmp, add( last_cardioid_right, negate( mult0( j, grad ) ) ) ), 15 ) );
- stereo_dmx[1][j] = L_add( stereo_dmx[1][j], tmp ); /* Qx DMX Right */
+ tmp = W_extract_l( W_shr( W_mult_32_16( tmp, add( last_cardioid_right, negate( mult0( j, grad ) ) ) ), 15 ) ); /* Qx DMX Right */
+ stereo_dmx[1][j] = L_add( stereo_dmx[1][j], tmp ); /* Qx DMX Right */
move32();
ene_data = W_add( ene_data, W_mult_32_32( data[i][j], data[i][j] ) ); /* 2 * Qx + 1 energy of all objects combined */
}
@@ -330,13 +330,13 @@ void ivas_param_ism_stereo_dmx_fx(
{
tmp = data[i][j];
move32();
- tmp = W_extract_l( W_shr( W_mult_32_16( tmp, cardioid_left[i] ), 15 ) );
- stereo_dmx[0][j] = L_add( stereo_dmx[0][j], tmp ); /* Qx DMX Left */
+ tmp = W_extract_l( W_shr( W_mult_32_16( tmp, cardioid_left[i] ), 15 ) ); /* Qx DMX Left */
+ stereo_dmx[0][j] = L_add( stereo_dmx[0][j], tmp ); /* Qx DMX Left */
move32();
tmp = data[i][j];
move32();
- tmp = W_extract_l( W_shr( W_mult_32_16( tmp, cardioid_right[i] ), 15 ) );
- stereo_dmx[1][j] = L_add( stereo_dmx[1][j], tmp ); /* Qx DMX Right */
+ tmp = W_extract_l( W_shr( W_mult_32_16( tmp, cardioid_right[i] ), 15 ) ); /* Qx DMX Right */
+ stereo_dmx[1][j] = L_add( stereo_dmx[1][j], tmp ); /* Qx DMX Right */
move32();
ene_data = W_add( ene_data, W_mult_32_32( data[i][j], data[i][j] ) ); /* 2 * Qx + 1 energy of all objects combined */
}
@@ -351,18 +351,18 @@ void ivas_param_ism_stereo_dmx_fx(
{
tmp = data[i][j];
move32();
- tmp = W_extract_l( W_shr( W_mult_32_16( tmp, cardioid_left[i] ), 15 ) );
- stereo_dmx[0][j] = L_add( stereo_dmx[0][j], tmp ); /* Qx DMX Left */
+ tmp = W_extract_l( W_shr( W_mult_32_16( tmp, cardioid_left[i] ), 15 ) ); /* Qx DMX Left */
+ stereo_dmx[0][j] = L_add( stereo_dmx[0][j], tmp ); /* Qx DMX Left */
move32();
tmp = data[i][j];
move32();
- tmp = W_extract_l( W_shr( W_mult_32_16( tmp, cardioid_right[i] ), 15 ) );
- stereo_dmx[1][j] = L_add( stereo_dmx[1][j], tmp ); /* Qx DMX Right */
+ tmp = W_extract_l( W_shr( W_mult_32_16( tmp, cardioid_right[i] ), 15 ) ); /* Qx DMX Right */
+ stereo_dmx[1][j] = L_add( stereo_dmx[1][j], tmp ); /* Qx DMX Right */
move32();
ene_data = W_add( ene_data, W_mult_32_32( data[i][j], data[i][j] ) ); /* 2 * Qx + 1 energy of all objects combined */
}
}
- st_ivas->hParamIsm->last_cardioid_left_fx[i] = cardioid_left[i];
+ st_ivas->hParamIsm->last_cardioid_left_fx[i] = cardioid_left[i]; // Q14
move16();
}
@@ -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 );
@@ -389,7 +389,7 @@ void ivas_param_ism_stereo_dmx_fx(
tmp_1 = 15 + 1;
move16();
- FOR( i = 0; i < shr( input_frame, 1 ); i++ )
+ FOR( i = 0; i < input_frame >> 1; i++ )
{
stereo_dmx[0][i] = W_extract_l( W_shr( W_mult_32_32( stereo_dmx[0][i], L_add( tmp, mult0( i, grad ) ) ), tmp_1 ) ); // Qx
move32();
@@ -437,7 +437,7 @@ void ivas_param_ism_stereo_dmx_fx(
* Open Param ISM handle
*-------------------------------------------------------------------------*/
-ivas_error ivas_param_ism_enc_open(
+ivas_error ivas_param_ism_enc_open_fx(
Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */
)
{
@@ -479,7 +479,7 @@ ivas_error ivas_param_ism_enc_open(
hParamIsm->nbands = MAX_PARAM_ISM_NBANDS;
move16();
- max_bins = extract_l( Mpy_32_32( input_Fs, 10737418 ) ); // (int16_t) ( ( MDFT_FB_BANDS_240 * input_Fs ) / 48000 );
+ max_bins = extract_l( Mpy_32_32( input_Fs, 10737418 /*240/48000.Q31*/ ) ); // (int16_t) ( ( MDFT_FB_BANDS_240 * input_Fs ) / 48000 );
FOR( i = 0; i < ( hParamIsm->nbands + 1 ); i++ )
{
hParamIsm->band_grouping[i] = CLDFB_TO_MDFT_FAC * Param_ISM_band_grouping[i];
@@ -505,7 +505,7 @@ ivas_error ivas_param_ism_enc_open(
* Close Param ISM encoder handle
*-------------------------------------------------------------------------*/
-void ivas_param_ism_enc_close(
+void ivas_param_ism_enc_close_fx(
PARAM_ISM_CONFIG_HANDLE *hParamIsm, /* i/o: ParamISM handle */
const Word32 input_Fs /* i : input sampling_rate */
)
@@ -604,7 +604,7 @@ void ivas_param_ism_enc_fx(
*
*-------------------------------------------------------------------*/
-void ivas_param_ism_compute_noisy_speech_flag(
+void ivas_param_ism_compute_noisy_speech_flag_fx(
Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */
)
{
diff --git a/lib_enc/ivas_lfe_enc.c b/lib_enc/ivas_lfe_enc.c
index 6a67cd814f4ab00b21402f326de9305e1d1de693..e72270e6cb513fef5a0680588777c2ea79366a22 100644
--- a/lib_enc/ivas_lfe_enc.c
+++ b/lib_enc/ivas_lfe_enc.c
@@ -433,14 +433,14 @@ void ivas_lfe_enc_fx(
IF( LT_16( q_data_lfe_ch, hLFE->q_old_wtda_audio ) )
{
- Scale_sig32( hLFE->old_wtda_audio_fx, fade_len, sub( q_data_lfe_ch, hLFE->q_old_wtda_audio ) );
+ Scale_sig32( hLFE->old_wtda_audio_fx, fade_len, sub( q_data_lfe_ch, hLFE->q_old_wtda_audio ) ); // hLFE->q_old_wtda_audio
hLFE->q_old_wtda_audio = q_data_lfe_ch;
move16();
}
IF( GT_16( q_data_lfe_ch, hLFE->q_old_wtda_audio ) )
{
- Scale_sig32( data_lfe_ch, input_frame, sub( hLFE->q_old_wtda_audio, q_data_lfe_ch ) );
+ Scale_sig32( data_lfe_ch, input_frame, sub( hLFE->q_old_wtda_audio, q_data_lfe_ch ) ); // hLFE->q_old_wtda_audio;
q_data_lfe_ch = hLFE->q_old_wtda_audio;
move16();
}
@@ -451,7 +451,7 @@ void ivas_lfe_enc_fx(
q_out1 = Find_Max_Norm32( wtda_audio_fx, input_frame );
q_out1 = sub( q_out1, find_guarded_bits_fx( dct_len ) );
- Scale_sig32( wtda_audio_fx, input_frame, q_out1 );
+ Scale_sig32( wtda_audio_fx, input_frame, q_out1 ); // Q10 + q_out1
q_out1 = add( q_data_lfe_ch, q_out1 );
ivas_mdct_fx( wtda_audio_fx, t_audio_fx, dct_len, &q_out1 );
@@ -464,7 +464,7 @@ void ivas_lfe_enc_fx(
/* mdct */
q_out2 = Find_Max_Norm32( wtda_audio_fx, input_frame );
q_out2 = sub( q_out2, find_guarded_bits_fx( dct_len ) );
- Scale_sig32( wtda_audio_fx, input_frame, q_out2 );
+ Scale_sig32( wtda_audio_fx, input_frame, q_out2 ); // Q10 + q_out2
q_out2 = add( q_data_lfe_ch, q_out2 );
ivas_mdct_fx( wtda_audio_fx, t_audio_fx, dct_len, &q_out2 );
@@ -479,7 +479,7 @@ void ivas_lfe_enc_fx(
q_out2 = add( q_out2, min( q_tmp2, sub( q_out1, q_out2 ) ) );
IF( GT_16( q_out1, q_out2 ) )
{
- Scale_sig32( lfe_dct_fx, num_dct_pass_bins, sub( q_out2, q_out1 ) );
+ Scale_sig32( lfe_dct_fx, num_dct_pass_bins, sub( q_out2, q_out1 ) ); // q_out2
q_out1 = q_out2;
move16();
}
@@ -490,7 +490,7 @@ void ivas_lfe_enc_fx(
q_out1 = add( q_out1, min( q_tmp1, sub( q_out2, q_out1 ) ) );
IF( LT_16( q_out1, q_out2 ) )
{
- Scale_sig32( lfe_dct_fx + num_dct_pass_bins, num_dct_pass_bins, sub( q_out1, q_out2 ) );
+ Scale_sig32( lfe_dct_fx + num_dct_pass_bins, num_dct_pass_bins, sub( q_out1, q_out2 ) ); // q_out1
q_out1 = q_out2;
move16();
}
@@ -507,7 +507,7 @@ void ivas_lfe_enc_fx(
*
* Create, allocate and initialize IVAS encoder LFE handle
*-------------------------------------------------------------------------*/
-ivas_error ivas_create_lfe_enc(
+ivas_error ivas_create_lfe_enc_fx(
LFE_ENC_HANDLE *hLFE_out, /* o : IVAS LFE encoder structure */
const Word32 input_Fs /* i : input sampling rate */
)
@@ -575,7 +575,7 @@ ivas_error ivas_create_lfe_enc(
// hLFE->lfe_enc_indices_coeffs_tbl[i][j] =
// (int16_t) ceilf( log2f( (float) ( ivas_lfe_num_ele_in_coder_models[i][j] + 1 ) ) );
hLFE->lfe_enc_indices_coeffs_tbl[i][j] =
- floor_log_2( add( ivas_lfe_num_ele_in_coder_models[i][j], 1 ) );
+ floor_log_2( add( ivas_lfe_num_ele_in_coder_models[i][j], 1 ) ); // Q0
move16();
}
}
@@ -590,7 +590,7 @@ ivas_error ivas_create_lfe_enc(
*
* Destroy IVAS cncoder LFE handle
*-------------------------------------------------------------------------*/
-void ivas_lfe_enc_close(
+void ivas_lfe_enc_close_fx(
LFE_ENC_HANDLE *hLFE /* i/o: LFE encoder handle */
)
{
@@ -628,7 +628,7 @@ ivas_error ivas_create_lfe_lpf_enc_fx(
const Word32 input_Fs /* i : input sampling rate */
)
{
- const Word32 *filt_coeff;
+ const Word32 *filt_coeff; // 31 - filt_coeff_e
const Word16 *filt_coeff_e = NULL;
IF( hLfeLpf == NULL )
@@ -657,7 +657,7 @@ ivas_error ivas_create_lfe_lpf_enc_fx(
*
* Destroy IVAS cncoder LFE low pass filter state
*-------------------------------------------------------------------------*/
-void ivas_lfe_lpf_enc_close(
+void ivas_lfe_lpf_enc_close_fx(
ivas_filters_process_state_t **hLfeLpf /* i/o: LFE LPF handle */
)
{
@@ -681,7 +681,7 @@ void ivas_lfe_lpf_enc_close(
*-------------------------------------------------------------------------*/
void ivas_lfe_lpf_enc_apply_fx(
ivas_filters_process_state_t *hLfeLpf, /* i/o: LFE LPF handle */
- Word32 data_lfe_ch[], /* i/o: LFE signal */
+ Word32 data_lfe_ch[], /* i/o: LFE signal Q11*/
const Word16 input_frame /* i : input frame length per channel */
)
{
diff --git a/lib_enc/ivas_masa_enc.c b/lib_enc/ivas_masa_enc.c
index abf70944298a06a45d20d58667e4967a3ca28ba2..583a37006e814324e8f3a3755f02ed83051b76a8 100644
--- a/lib_enc/ivas_masa_enc.c
+++ b/lib_enc/ivas_masa_enc.c
@@ -118,7 +118,7 @@ static void masa_metadata_direction_alignment_fx( MASA_ENCODER_HANDLE hMasa );
*
* open and initialize MASA encoder
*-----------------------------------------------------------------------*/
-ivas_error ivas_masa_enc_open(
+ivas_error ivas_masa_enc_open_fx(
Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */
)
{
@@ -179,16 +179,16 @@ ivas_error ivas_masa_enc_open(
Copy( DirAC_block_grouping, hMasa->config.block_grouping, MAX_PARAM_SPATIAL_SUBFRAMES + 1 );
Copy( MASA_band_grouping_24, hMasa->config.band_grouping, MASA_FREQUENCY_BANDS + 1 );
- hMasa->data.onset_detector_1_fx = 0;
- hMasa->data.onset_detector_2_fx = 0;
+ hMasa->data.onset_detector_1_fx = 0; // hMasa->data.q_onset_detector
+ hMasa->data.onset_detector_2_fx = 0; // hMasa->data.q_onset_detector
hMasa->data.q_onset_detector = 0;
move32();
move32();
move16();
- set32_fx( hMasa->data.lfeToTotalEnergyRatio_fx, 0, MAX_PARAM_SPATIAL_SUBFRAMES );
+ set32_fx( hMasa->data.lfeToTotalEnergyRatio_fx, 0, MAX_PARAM_SPATIAL_SUBFRAMES ); // hMasa->data.lfeToTotalEnergyRatio_e
set16_fx( hMasa->data.lfeToTotalEnergyRatio_e, 0, MAX_PARAM_SPATIAL_SUBFRAMES );
- hMasa->data.prevq_lfeToTotalEnergyRatio_fx = 0;
+ hMasa->data.prevq_lfeToTotalEnergyRatio_fx = 0; // Q31
move32();
hMasa->data.prevq_lfeIndex = 0;
@@ -201,10 +201,10 @@ ivas_error ivas_masa_enc_open(
move16();
move32();
- set_zero_fx( hMasa->data.dir_align_state.previous_azi_dir1_fx, MASA_FREQUENCY_BANDS );
- set_zero_fx( hMasa->data.dir_align_state.previous_ele_dir1_fx, MASA_FREQUENCY_BANDS );
- set_zero_fx( hMasa->data.dir_align_state.previous_azi_dir2_fx, MASA_FREQUENCY_BANDS );
- set_zero_fx( hMasa->data.dir_align_state.previous_ele_dir2_fx, MASA_FREQUENCY_BANDS );
+ set_zero_fx( hMasa->data.dir_align_state.previous_azi_dir1_fx, MASA_FREQUENCY_BANDS ); // Q22
+ set_zero_fx( hMasa->data.dir_align_state.previous_ele_dir1_fx, MASA_FREQUENCY_BANDS ); // Q22
+ set_zero_fx( hMasa->data.dir_align_state.previous_azi_dir2_fx, MASA_FREQUENCY_BANDS ); // Q22
+ set_zero_fx( hMasa->data.dir_align_state.previous_ele_dir2_fx, MASA_FREQUENCY_BANDS ); // Q22
IF( EQ_32( hEncoderConfig->ivas_format, MASA_ISM_FORMAT ) )
{
@@ -217,7 +217,7 @@ ivas_error ivas_masa_enc_open(
FOR( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ )
{
- set32_fx( hOmasaData->masa_to_total_energy_ratio_fx[i], 0, MASA_FREQUENCY_BANDS );
+ set32_fx( hOmasaData->masa_to_total_energy_ratio_fx[i], 0, MASA_FREQUENCY_BANDS ); // Q30
}
hOmasaData->lp_noise_CPE_fx = -256; /* -1 in Q8 */
@@ -227,7 +227,7 @@ ivas_error ivas_masa_enc_open(
FOR( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ )
{
- set_zero_fx( hOmasaData->energy_ism_fx[i], MASA_FREQUENCY_BANDS );
+ set_zero_fx( hOmasaData->energy_ism_fx[i], MASA_FREQUENCY_BANDS ); // hOmasaData->energy_ism_fx_e
set16_fx( hOmasaData->energy_ism_fx_e[i], 0, MASA_FREQUENCY_BANDS );
}
@@ -248,7 +248,7 @@ ivas_error ivas_masa_enc_open(
*
* close MASA encoder
*-----------------------------------------------------------------------*/
-void ivas_masa_enc_close(
+void ivas_masa_enc_close_fx(
MASA_ENCODER_HANDLE *hMasa /* i/o: MASA metadata structure */
)
{
@@ -322,7 +322,6 @@ ivas_error ivas_masa_encode_fx(
IF( EQ_32( ivas_format, MASA_FORMAT ) || EQ_32( ivas_format, MASA_ISM_FORMAT ) )
{
/* Create the MASA SID descriptor for the metadata and CPE mode, in order to have the SID frame self-contained. */
- test();
IF( Opt_DTX_ON && hQMetaData != NULL )
{
IF( EQ_16( nchan_transport, 2 ) ) /* this is MASA format in CPE only */
@@ -351,9 +350,9 @@ ivas_error ivas_masa_encode_fx(
{
FOR( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ )
{
- Copy32( hMasa->masaMetadata.directional_meta[i].azimuth_fx[j], h_orig_metadata[i].azimuth_fx[j], MASA_FREQUENCY_BANDS );
- Copy32( hMasa->masaMetadata.directional_meta[i].elevation_fx[j], h_orig_metadata[i].elevation_fx[j], MASA_FREQUENCY_BANDS );
- Copy32( hMasa->masaMetadata.directional_meta[i].energy_ratio_fx[j], h_orig_metadata[i].energy_ratio_fx[j], MASA_FREQUENCY_BANDS );
+ Copy32( hMasa->masaMetadata.directional_meta[i].azimuth_fx[j], h_orig_metadata[i].azimuth_fx[j], MASA_FREQUENCY_BANDS ); // Q22
+ Copy32( hMasa->masaMetadata.directional_meta[i].elevation_fx[j], h_orig_metadata[i].elevation_fx[j], MASA_FREQUENCY_BANDS ); // Q22
+ Copy32( hMasa->masaMetadata.directional_meta[i].energy_ratio_fx[j], h_orig_metadata[i].energy_ratio_fx[j], MASA_FREQUENCY_BANDS ); // Q30
Copy( (Word16 *) ( hMasa->masaMetadata.directional_meta[i].spherical_index[j] ), (Word16 *) ( h_orig_metadata[i].spherical_index[j] ), MASA_FREQUENCY_BANDS );
}
}
@@ -384,7 +383,7 @@ ivas_error ivas_masa_encode_fx(
{
FOR( j = 0; j < MASA_FREQUENCY_BANDS; j++ )
{
- hMasa->data.energy_fx[i][j] = L_shr( hMasa->data.energy_fx[i][j], sub( s, hMasa->data.energy_e[i][j] ) );
+ hMasa->data.energy_fx[i][j] = L_shr( hMasa->data.energy_fx[i][j], sub( s, hMasa->data.energy_e[i][j] ) ); // hMasa->data.energy_e[i][j] -> s
hMasa->data.energy_e[i][j] = s;
move32();
move16();
@@ -700,9 +699,9 @@ ivas_error ivas_masa_encode_fx(
{
FOR( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ )
{
- Copy32( h_orig_metadata[i].azimuth_fx[j], hMasa->masaMetadata.directional_meta[i].azimuth_fx[j], MASA_FREQUENCY_BANDS );
- Copy32( h_orig_metadata[i].elevation_fx[j], hMasa->masaMetadata.directional_meta[i].elevation_fx[j], MASA_FREQUENCY_BANDS );
- Copy32( h_orig_metadata[i].energy_ratio_fx[j], hMasa->masaMetadata.directional_meta[i].energy_ratio_fx[j], MASA_FREQUENCY_BANDS );
+ Copy32( h_orig_metadata[i].azimuth_fx[j], hMasa->masaMetadata.directional_meta[i].azimuth_fx[j], MASA_FREQUENCY_BANDS ); // Q22
+ Copy32( h_orig_metadata[i].elevation_fx[j], hMasa->masaMetadata.directional_meta[i].elevation_fx[j], MASA_FREQUENCY_BANDS ); // Q22
+ Copy32( h_orig_metadata[i].energy_ratio_fx[j], hMasa->masaMetadata.directional_meta[i].energy_ratio_fx[j], MASA_FREQUENCY_BANDS ); // Q30
}
}
@@ -815,6 +814,9 @@ void ivas_masa_estimate_energy_fx(
{
q_buf = q_data;
move16();
+ scale_sig32( hMasa->data.cldfbAnaEnc[i]->cldfb_state_fx, hMasa->data.cldfbAnaEnc[i]->cldfb_state_length, sub( q_buf, hMasa->data.cldfbAnaEnc[i]->Q_cldfb_state ) );
+ hMasa->data.cldfbAnaEnc[i]->Q_cldfb_state = q_buf;
+ move16();
cldfbAnalysis_ts_fx_fixed_q( &( data_fx[i][l_ts * ts] ), Input_RealBuffer[i], Input_ImagBuffer[i], l_ts, hMasa->data.cldfbAnaEnc[i], &q_buf ); // (q_data - 5) for Input_RealBuffer[i], Input_ImagBuffer[i]
}
@@ -1105,7 +1107,7 @@ ivas_error ivas_masa_enc_config_fx(
maxBand = 0;
move16();
test();
- WHILE( LE_16( maxBand, MASA_FREQUENCY_BANDS ) && LE_16( MASA_band_grouping_24[maxBand], maxBin ) )
+ WHILE( ( maxBand <= MASA_FREQUENCY_BANDS ) && ( MASA_band_grouping_24[maxBand] <= maxBin ) )
{
test();
maxBand = (UWord8) add( maxBand, 1 );
@@ -1131,7 +1133,7 @@ ivas_error ivas_masa_enc_config_fx(
continueLoop = 1;
move16();
test();
- WHILE( GT_16( maxBand, 5 ) && continueLoop )
+ WHILE( ( maxBand > 5 ) && continueLoop )
{
test();
FOR( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES; sf++ )
@@ -1203,7 +1205,8 @@ ivas_error ivas_masa_enc_config_fx(
}
ELSE
{
- st_ivas->hMasa->data.hOmasaData->lp_noise_CPE_fx = shr( add( st_ivas->hCPE[0]->hCoreCoder[0]->lp_noise_fx, st_ivas->hCPE[0]->hCoreCoder[1]->lp_noise_fx ), 1 ); /*Q8*/
+ /* ( st_ivas->hCPE[0]->hCoreCoder[0]->lp_noise + st_ivas->hCPE[0]->hCoreCoder[1]->lp_noise ) / CPE_CHANNELS; */
+ st_ivas->hMasa->data.hOmasaData->lp_noise_CPE_fx = extract_h( L_mac( L_mult( st_ivas->hCPE[0]->hCoreCoder[0]->lp_noise_fx, ONE_IN_Q14 ), st_ivas->hCPE[0]->hCoreCoder[1]->lp_noise_fx, ONE_IN_Q14 ) ); /*Q8*/
}
move16();
}
@@ -1519,7 +1522,7 @@ static void combine_freqbands_and_subframes_fx(
}
}
- if ( i == 0 )
+ IF( i == 0 )
{
energy[j][k] = energySum; // 31-energySum_e
energy_e[j][k] = energySum_e;
@@ -1887,7 +1890,7 @@ void ivas_masa_combine_directions_fx(
}
static void find_n_largest_fx(
- const Word32 *input_fx,
+ const Word32 *input_fx, // Q(31 - exp_input)
Word16 exp_input,
Word16 *largestIndices,
const Word16 numElements,
@@ -1900,13 +1903,13 @@ static void find_n_largest_fx(
FOR( j = 0; j < numElements; j++ )
{
- values[j] = input_fx[j];
+ values[j] = input_fx[j]; // Q(31 - exp_input)
move32();
}
FOR( i = 0; i < numLargest; i++ )
{
- largestValue = values[0];
+ largestValue = values[0]; // Q(31 - exp_input)
move32();
largestIndex = 0;
move16();
@@ -1914,7 +1917,7 @@ static void find_n_largest_fx(
{
IF( GT_32( values[j], largestValue ) )
{
- largestValue = values[j];
+ largestValue = values[j]; // Q(31 - exp_input)
largestIndex = j;
move32();
move16();
@@ -1924,12 +1927,12 @@ static void find_n_largest_fx(
move16();
IF( exp_input != 0 )
{
- values[largestIndex] = L_negate( 1 << ( sub( 31, exp_input ) ) );
+ values[largestIndex] = L_negate( 1 << ( sub( 31, exp_input ) ) ); // Q(31 - exp_input)
move32();
}
ELSE
{
- values[largestIndex] = 1 << ( sub( 31, exp_input ) );
+ values[largestIndex] = 1 << ( sub( 31, exp_input ) ); // Q(31 - exp_input)
move32();
}
}
@@ -1966,9 +1969,9 @@ static void move_metadata_to_qmetadata_fx(
{
FOR( band = 0; band < numCodingBands; band++ )
{
- hQMeta->q_direction[dir].band_data[band].azimuth_fx[sf] = hMeta->directional_meta[dir].azimuth_fx[sf][band];
- hQMeta->q_direction[dir].band_data[band].elevation_fx[sf] = hMeta->directional_meta[dir].elevation_fx[sf][band];
- hQMeta->q_direction[dir].band_data[band].energy_ratio_fx[sf] = hMeta->directional_meta[dir].energy_ratio_fx[sf][band];
+ hQMeta->q_direction[dir].band_data[band].azimuth_fx[sf] = hMeta->directional_meta[dir].azimuth_fx[sf][band]; // Q22
+ hQMeta->q_direction[dir].band_data[band].elevation_fx[sf] = hMeta->directional_meta[dir].elevation_fx[sf][band]; // Q22
+ hQMeta->q_direction[dir].band_data[band].energy_ratio_fx[sf] = hMeta->directional_meta[dir].energy_ratio_fx[sf][band]; // Q30
hQMeta->q_direction[dir].band_data[band].spherical_index[sf] = hMeta->directional_meta[dir].spherical_index[sf][band];
move32();
move32();
@@ -1977,7 +1980,7 @@ static void move_metadata_to_qmetadata_fx(
IF( hQMeta->q_direction[dir].coherence_band_data != NULL )
{
- hQMeta->q_direction[dir].coherence_band_data[band].spread_coherence[sf] = (UWord8) mult_r( hMeta->directional_meta[dir].spread_coherence_fx[sf][band], UINT8_MAX );
+ hQMeta->q_direction[dir].coherence_band_data[band].spread_coherence[sf] = (UWord8) mult_r( hMeta->directional_meta[dir].spread_coherence_fx[sf][band], UINT8_MAX ); // Q15
move16();
}
}
@@ -1990,7 +1993,7 @@ static void move_metadata_to_qmetadata_fx(
{
IF( hQMeta->surcoh_band_data != NULL )
{
- hQMeta->surcoh_band_data[band].surround_coherence[sf] = (UWord8) mult_r( hMeta->common_meta.surround_coherence_fx[sf][band], UINT8_MAX );
+ hQMeta->surcoh_band_data[band].surround_coherence[sf] = (UWord8) mult_r( hMeta->common_meta.surround_coherence_fx[sf][band], UINT8_MAX ); // Q15
move16();
}
}
@@ -2072,12 +2075,12 @@ static void detect_metadata_composition_fx(
{
sf = 0;
move16();
- WHILE( !dirValid[dir] && LT_16( sf, MAX_PARAM_SPATIAL_SUBFRAMES ) )
+ WHILE( !dirValid[dir] && ( sf < MAX_PARAM_SPATIAL_SUBFRAMES ) )
{
test();
band = 0;
move16();
- WHILE( !dirValid[dir] && LT_16( band, MASA_FREQUENCY_BANDS ) )
+ WHILE( !dirValid[dir] && ( band < MASA_FREQUENCY_BANDS ) )
{
test();
IF( GE_32( hMeta->directional_meta[dir].energy_ratio_fx[sf][band] /*q30*/, MASA_RATIO_THRESHOLD_FX >> 1 /*q30*/ ) )
@@ -2119,7 +2122,7 @@ static void detect_metadata_composition_fx(
}
}
- IF( *isTwoDir == FALSE )
+ if ( *isTwoDir == FALSE )
{
/* Further checks will be done with just one direction */
numDir = 1;
@@ -2132,9 +2135,10 @@ static void detect_metadata_composition_fx(
sf = 1;
move16();
move16();
- WHILE( EQ_16( sfSimilar, TRUE ) && LT_16( sf, MAX_PARAM_SPATIAL_SUBFRAMES ) )
+
+ test();
+ WHILE( ( sfSimilar == TRUE ) && ( sf < MAX_PARAM_SPATIAL_SUBFRAMES ) )
{
- test();
sfSimilar = are_masa_subframes_similar_fx( hMeta, 0, hMeta, sf );
sf = (Word8) add( sf, 1 );
move16();
@@ -2155,19 +2159,19 @@ static void detect_metadata_composition_fx(
/* Check spread coherence */
dir = 0;
move16();
- WHILE( cohPresent == FALSE && LT_16( dir, numDir ) )
+ test();
+ WHILE( cohPresent == FALSE && ( dir < numDir ) )
{
- test();
sf = 0;
move16();
- WHILE( cohPresent == FALSE && LT_16( sf, nSubFrames ) )
+ test();
+ WHILE( cohPresent == FALSE && ( sf < nSubFrames ) )
{
- test();
band = 0;
move16();
- WHILE( cohPresent == FALSE /*has value zero*/ && LT_16( band, MASA_FREQUENCY_BANDS ) )
+ test();
+ WHILE( cohPresent == FALSE /*has value zero*/ && ( band < MASA_FREQUENCY_BANDS ) )
{
- test();
/* Check coherences for presence of coherence */
IF( GT_16( hMeta->directional_meta[dir].spread_coherence_fx[sf][band] /*Q15*/, MASA_COHERENCE_THRESHOLD_FX >> 16 ) ) /*Q15*/
{
@@ -2360,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 );
@@ -2496,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;
@@ -2524,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
@@ -2554,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();
@@ -2563,7 +2584,7 @@ static void reduce_metadata_further_fx(
{
FOR( band = 0; band < numCodingBands; band++ )
{
- hqmetadata->q_direction[0].coherence_band_data[band].spread_coherence[sf] = hqmetadata->q_direction[0].coherence_band_data[band].spread_coherence[0];
+ hqmetadata->q_direction[0].coherence_band_data[band].spread_coherence[sf] = hqmetadata->q_direction[0].coherence_band_data[band].spread_coherence[0]; // Q0
move16();
}
}
@@ -2582,18 +2603,18 @@ static void reduce_metadata_further_fx(
/* Use the selected frequency band to represent all data */
FOR( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES; sf++ )
{
- hqmetadata->q_direction[0].band_data[0].azimuth_fx[sf] = hqmetadata->q_direction[0].band_data[selectedBand].azimuth_fx[sf];
- hqmetadata->q_direction[0].band_data[0].elevation_fx[sf] = hqmetadata->q_direction[0].band_data[selectedBand].elevation_fx[sf];
- hqmetadata->q_direction[0].band_data[0].energy_ratio_fx[sf] = hqmetadata->q_direction[0].band_data[selectedBand].energy_ratio_fx[sf];
+ hqmetadata->q_direction[0].band_data[0].azimuth_fx[sf] = hqmetadata->q_direction[0].band_data[selectedBand].azimuth_fx[sf]; // Q22
+ hqmetadata->q_direction[0].band_data[0].elevation_fx[sf] = hqmetadata->q_direction[0].band_data[selectedBand].elevation_fx[sf]; // Q22
+ hqmetadata->q_direction[0].band_data[0].energy_ratio_fx[sf] = hqmetadata->q_direction[0].band_data[selectedBand].energy_ratio_fx[sf]; // Q30
move32();
move32();
move32();
- if ( hqmetadata->q_direction[0].coherence_band_data != NULL )
+ IF( hqmetadata->q_direction[0].coherence_band_data != NULL )
{
- hqmetadata->q_direction[0].coherence_band_data[0].spread_coherence[sf] = hqmetadata->q_direction[0].coherence_band_data[selectedBand].spread_coherence[sf];
+ hqmetadata->q_direction[0].coherence_band_data[0].spread_coherence[sf] = hqmetadata->q_direction[0].coherence_band_data[selectedBand].spread_coherence[sf]; // Q0
move16();
}
- if ( hqmetadata->surcoh_band_data != NULL )
+ IF( hqmetadata->surcoh_band_data != NULL )
{
hqmetadata->surcoh_band_data[0].surround_coherence[sf] = hqmetadata->surcoh_band_data[selectedBand].surround_coherence[sf];
move16();
@@ -2607,7 +2628,7 @@ static void reduce_metadata_further_fx(
{
FOR( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES; sf++ )
{
- hqmetadata->q_direction[0].coherence_band_data[band].spread_coherence[sf] = hqmetadata->q_direction[0].coherence_band_data[0].spread_coherence[sf];
+ hqmetadata->q_direction[0].coherence_band_data[band].spread_coherence[sf] = hqmetadata->q_direction[0].coherence_band_data[0].spread_coherence[sf]; // Q0
move16();
}
}
@@ -2657,7 +2678,7 @@ static Word16 encode_lfe_to_total_energy_ratio_fx(
move16();
/* Determine maximum amount of LFE energy in any subframe */
- maxLFESubFrameEner = 0;
+ maxLFESubFrameEner = 0; // maxLFESubFrameEner_e
move32();
maxLFESubFrameEner_e = 0;
move16();
@@ -2665,7 +2686,7 @@ static Word16 encode_lfe_to_total_energy_ratio_fx(
{
IF( BASOP_Util_Cmp_Mant32Exp( hMasa->data.lfeToTotalEnergyRatio_fx[i], hMasa->data.lfeToTotalEnergyRatio_e[i], maxLFESubFrameEner, maxLFESubFrameEner_e ) > 0 )
{
- maxLFESubFrameEner = hMasa->data.lfeToTotalEnergyRatio_fx[i];
+ maxLFESubFrameEner = hMasa->data.lfeToTotalEnergyRatio_fx[i]; // hMasa->data.lfeToTotalEnergyRatio_e[i]
move32();
maxLFESubFrameEner_e = hMasa->data.lfeToTotalEnergyRatio_e[i];
move16();
@@ -2897,7 +2918,7 @@ void ivas_masa_enc_reconfigure_fx(
st_ivas->hCPE[cpe_id]->element_brate = imult3216( tmp_br, 2 ); //( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS;
move32();
- IF( st_ivas->nCPE > 1 )
+ IF( GT_16( st_ivas->nCPE, 1 ) )
{
tmp = 1;
}
@@ -2939,7 +2960,7 @@ void ivas_masa_enc_reconfigure_fx(
*-------------------------------------------------------------------*/
static void average_masa_metadata_fx(
MASA_METADATA_FRAME *hMeta,
- Word32 energy[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /*i*/
+ Word32 energy[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /*i Q(31 - energy_e) */
Word16 energy_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /*i:stores exponent values for energy_e*/
const SPHERICAL_GRID_DATA *Sph_Grid16,
const UWord8 useSphGrid )
@@ -3111,16 +3132,16 @@ static void copy_masa_metadata_subframe_fx(
/* directional metadata */
FOR( dir = 0; dir < MASA_MAXIMUM_DIRECTIONS; dir++ )
{
- Copy32( hMetaFrom->directional_meta[dir].azimuth_fx[sfFrom], hMetaTo->directional_meta[dir].azimuth_fx[sfTo], MASA_FREQUENCY_BANDS );
- Copy32( hMetaFrom->directional_meta[dir].elevation_fx[sfFrom], hMetaTo->directional_meta[dir].elevation_fx[sfTo], MASA_FREQUENCY_BANDS );
- Copy32( hMetaFrom->directional_meta[dir].energy_ratio_fx[sfFrom], hMetaTo->directional_meta[dir].energy_ratio_fx[sfTo], MASA_FREQUENCY_BANDS );
- Copy( hMetaFrom->directional_meta[dir].spread_coherence_fx[sfFrom], hMetaTo->directional_meta[dir].spread_coherence_fx[sfTo], MASA_FREQUENCY_BANDS );
+ Copy32( hMetaFrom->directional_meta[dir].azimuth_fx[sfFrom], hMetaTo->directional_meta[dir].azimuth_fx[sfTo], MASA_FREQUENCY_BANDS ); // Q22
+ Copy32( hMetaFrom->directional_meta[dir].elevation_fx[sfFrom], hMetaTo->directional_meta[dir].elevation_fx[sfTo], MASA_FREQUENCY_BANDS ); // Q22
+ Copy32( hMetaFrom->directional_meta[dir].energy_ratio_fx[sfFrom], hMetaTo->directional_meta[dir].energy_ratio_fx[sfTo], MASA_FREQUENCY_BANDS ); // Q30
+ Copy( hMetaFrom->directional_meta[dir].spread_coherence_fx[sfFrom], hMetaTo->directional_meta[dir].spread_coherence_fx[sfTo], MASA_FREQUENCY_BANDS ); // Q15
}
/* common metadata */
- Copy32( hMetaFrom->common_meta.diffuse_to_total_ratio_fx[sfFrom], hMetaTo->common_meta.diffuse_to_total_ratio_fx[sfTo], MASA_FREQUENCY_BANDS );
- Copy( hMetaFrom->common_meta.surround_coherence_fx[sfFrom], hMetaTo->common_meta.surround_coherence_fx[sfTo], MASA_FREQUENCY_BANDS );
- Copy32( hMetaFrom->common_meta.remainder_to_total_ratio_fx[sfFrom], hMetaTo->common_meta.remainder_to_total_ratio_fx[sfTo], MASA_FREQUENCY_BANDS );
+ Copy32( hMetaFrom->common_meta.diffuse_to_total_ratio_fx[sfFrom], hMetaTo->common_meta.diffuse_to_total_ratio_fx[sfTo], MASA_FREQUENCY_BANDS ); // Q30
+ Copy( hMetaFrom->common_meta.surround_coherence_fx[sfFrom], hMetaTo->common_meta.surround_coherence_fx[sfTo], MASA_FREQUENCY_BANDS ); // Q15
+ Copy32( hMetaFrom->common_meta.remainder_to_total_ratio_fx[sfFrom], hMetaTo->common_meta.remainder_to_total_ratio_fx[sfTo], MASA_FREQUENCY_BANDS ); // Q30
return;
}
@@ -3209,18 +3230,18 @@ static UWord8 are_masa_subframes_similar_fx(
move16();
move16();
- WHILE( EQ_16( sf_differ, FALSE ) && LE_16( dir, num_dir ) )
+ WHILE( ( sf_differ == FALSE ) && ( dir <= num_dir ) )
{
test();
band_idx = 0;
move16();
- WHILE( EQ_16( sf_differ, FALSE ) && LT_16( band_idx, MASA_FREQUENCY_BANDS ) )
+ WHILE( ( sf_differ == FALSE ) && ( band_idx < MASA_FREQUENCY_BANDS ) )
{
test();
Word32 azi_dif_fx;
- azi_dif_fx = L_abs( L_sub( frame1->directional_meta[dir].azimuth_fx[sf1_idx][band_idx], frame2->directional_meta[dir].azimuth_fx[sf2_idx][band_idx] ) );
+ azi_dif_fx = L_abs( L_sub( frame1->directional_meta[dir].azimuth_fx[sf1_idx][band_idx], frame2->directional_meta[dir].azimuth_fx[sf2_idx][band_idx] ) ); // Q22
IF( GT_32( azi_dif_fx, 180 << Q22 ) )
- azi_dif_fx = L_sub( 360 << Q22, azi_dif_fx );
+ azi_dif_fx = L_sub( 360 << Q22, azi_dif_fx ); // Q22
IF( GT_32( azi_dif_fx, ONE_IN_Q21 /*0.5 in Q22*/ ) )
{
@@ -3258,7 +3279,7 @@ static UWord8 are_masa_subframes_similar_fx(
}
/* check the common metadata */
- WHILE( EQ_16( sf_differ, FALSE ) && LT_16( band_idx, MASA_FREQUENCY_BANDS ) )
+ WHILE( ( sf_differ == FALSE ) && ( band_idx < MASA_FREQUENCY_BANDS ) )
{
test();
IF( GT_32( L_abs( L_sub( frame1->common_meta.surround_coherence_fx[sf1_idx][band_idx], frame2->common_meta.surround_coherence_fx[sf2_idx][band_idx] ) ), MASA_COHERENCE_TOLERANCE_FX ) )
@@ -3770,19 +3791,19 @@ void ivas_merge_masa_metadata_fx(
move16();
IF( EQ_16( band_n_dirs, 2 ) )
{
- energyTimesRatioMASA_fx[1] = Mpy_32_32( eneBand_fx, hMeta->directional_meta[1].energy_ratio_fx[sf][band] );
+ energyTimesRatioMASA_fx[1] = Mpy_32_32( eneBand_fx, hMeta->directional_meta[1].energy_ratio_fx[sf][band] ); // energyTimesRatioMASA_e
energyTimesRatioMASA_e[1] = add( eneBand_e, 1 );
}
ELSE
{
- energyTimesRatioMASA_fx[1] = 0;
+ energyTimesRatioMASA_fx[1] = 0; // energyTimesRatioMASA_e
energyTimesRatioMASA_e[1] = 0;
}
move32();
move16();
/* target is original MASA diffuseness */
- total_diff_nrg_fx = Mpy_32_32( eneBand_fx, hMeta->common_meta.diffuse_to_total_ratio_fx[sf][band] );
+ total_diff_nrg_fx = Mpy_32_32( eneBand_fx, hMeta->common_meta.diffuse_to_total_ratio_fx[sf][band] ); // total_diff_nrg_e
total_diff_nrg_e = add( eneBand_e, 1 );
/* criterion is mean of ISM ratio and new ratio */
@@ -3842,6 +3863,7 @@ void ivas_merge_masa_metadata_fx(
ELSE
{
hMeta->directional_meta[merge_dest].energy_ratio_fx[sf][band] = hOMasaMeta->directional_meta[0].energy_ratio_fx[sf][band]; /*q30*/
+ move32();
}
/* clip with original ISM dir */
hMeta->common_meta.diffuse_to_total_ratio_fx[sf][band] = L_sub( ONE_IN_Q30, hMeta->directional_meta[merge_dest].energy_ratio_fx[sf][band] ); /*q30*/
@@ -3920,7 +3942,7 @@ static void quantize_ratio_ism_vector_ivas_fx(
IF( tmp < 0 )
{
/* take it out from quantize function */
- Copy( ratio_ism, ratio_ism_loc, idx_sep_object );
+ Copy( ratio_ism, ratio_ism_loc, idx_sep_object ); // Q(15 - ratio_ism_e)
Copy( &ratio_ism[idx_sep_object + 1], &ratio_ism_loc[idx_sep_object], nchan_ism - idx_sep_object - 1 );
no_ism_loc = sub( nchan_ism, 1 );
}
@@ -3980,7 +4002,7 @@ static void quantize_ratio_ism_vector_ivas_fx(
move16();
move16();
- WHILE( LT_16( part_idx_sum, max_sum_idx ) )
+ WHILE( ( part_idx_sum < max_sum_idx ) )
{
best_i = -1;
move16();
@@ -4162,7 +4184,7 @@ static void transform_index_and_GR_encode_ivas_fx(
/* GR encoding */
FOR( i = 0; i < len; i++ )
{
- ivas_qmetadata_encode_extended_gr( hMetaData, idx[i], 100, GR_order );
+ ivas_qmetadata_encode_extended_gr_fx( hMetaData, idx[i], 100, GR_order );
}
return;
@@ -4183,7 +4205,7 @@ static Word16 try_differential_fx(
b_signif = 0;
move16();
- WHILE( LT_16( b_signif, numCodingBands ) && GE_32( masa_to_total_energy_ratio[b_signif], MASA2TOTAL_THR_Q30 ) )
+ WHILE( ( b_signif < numCodingBands ) && ( masa_to_total_energy_ratio[b_signif] >= MASA2TOTAL_THR_Q30 ) )
{
test();
b_signif = add( b_signif, 1 );
@@ -4211,7 +4233,7 @@ static Word16 try_differential_fx(
/* GR encoding */
FOR( i = 0; i < nchan_ism - 1; i++ )
{
- nbits0 = add( nbits0, ivas_qmetadata_encode_extended_gr_length( diff_idx[i], 100, 0 ) );
+ nbits0 = add( nbits0, ivas_qmetadata_encode_extended_gr_length_fx( diff_idx[i], 100, 0 ) );
}
}
}
@@ -4332,8 +4354,8 @@ static void estimate_bits_subband_ism_ratio_fx(
/* GR encoding */
FOR( i = 0; i < nchan_ism - 1 - shift_one; i++ )
{
- nbits0 = add( nbits0, ivas_qmetadata_encode_extended_gr_length( diff_idx[i], 100, 0 ) );
- nbits1 = add( nbits1, ivas_qmetadata_encode_extended_gr_length( diff_idx[i], 100, 1 ) );
+ nbits0 = add( nbits0, ivas_qmetadata_encode_extended_gr_length_fx( diff_idx[i], 100, 0 ) );
+ nbits1 = add( nbits1, ivas_qmetadata_encode_extended_gr_length_fx( diff_idx[i], 100, 1 ) );
}
*p_nbits0 = nbits0;
@@ -4471,7 +4493,7 @@ static Word16 encode_ratio_ism_subframe_fx(
move16();
move16();
move16();
- WHILE( LT_16( b_signif, numCodingBands ) && GE_32( masa_to_total_energy_ratio[b_signif], MASA2TOTAL_THR_Q30 ) )
+ WHILE( ( b_signif < numCodingBands ) && ( masa_to_total_energy_ratio[b_signif] >= MASA2TOTAL_THR_Q30 ) )
{
test();
b_signif = add( b_signif, 1 );
@@ -4735,8 +4757,8 @@ static void ivas_encode_masaism_metadata_fx(
{
FOR( band = 0; band < nbands_work; band++ )
{
- energy_ism = 0; /* ISM energy for current subband */
- energy_ism_e = 0; /* ISM energy for current subband */
+ energy_ism = 0; /* ISM energy for current subband */ // energy_ism_e
+ energy_ism_e = 0; /* ISM energy for current subband */
move32();
move16();
FOR( obj = 0; obj < nchan_ism; obj++ )
diff --git a/lib_enc/ivas_mc_param_enc.c b/lib_enc/ivas_mc_param_enc.c
index 26a81c1330a574838d052a3e393cbe2297d5564d..0577df3407257d03337d57a269fc8b14f6629426 100644
--- a/lib_enc/ivas_mc_param_enc.c
+++ b/lib_enc/ivas_mc_param_enc.c
@@ -52,13 +52,13 @@
* Local function prototypes
*------------------------------------------------------------------------*/
-static void ivas_param_mc_write_bs( const PARAM_MC_ENC_HANDLE hParamMC, int16_t *ILD_idx, int16_t *ICC_idx, uint16_t bit_buffer[PARAM_MC_MAX_BITS], int16_t *bit_pos );
+static void ivas_param_mc_write_bs_fx( const PARAM_MC_ENC_HANDLE hParamMC, Word16 *ILD_idx, Word16 *ICC_idx, UWord16 bit_buffer[PARAM_MC_MAX_BITS], Word16 *bit_pos );
-static void ivas_param_mc_dec2bin( const int16_t val, const int16_t N, uint16_t bits[PARAM_MC_MAX_BITS] );
+static void ivas_param_mc_dec2bin_fx( const Word16 val, const Word16 N, UWord16 bits[PARAM_MC_MAX_BITS] );
-static void ivas_param_mc_encode_parameter( int16_t *idx_in, HANDLE_IVAS_PARAM_MC_METADATA hMetadataPMC, HANDLE_PARAM_MC_PARAMETER_CODING_INFO hParameterCodingInfo, const int16_t nbands, const int16_t band_step, const int16_t map_size_wo_lfe, const int16_t map_size, uint16_t bit_buffer[PARAM_MC_MAX_BITS], int16_t *bit_pos );
+static void ivas_param_mc_encode_parameter_fx( Word16 *idx_in, HANDLE_IVAS_PARAM_MC_METADATA hMetadataPMC, HANDLE_PARAM_MC_PARAMETER_CODING_INFO hParameterCodingInfo, const Word16 nbands, const Word16 band_step, const Word16 map_size_wo_lfe, const Word16 map_size, UWord16 bit_buffer[PARAM_MC_MAX_BITS], Word16 *bit_pos );
-static void ivas_param_mc_range_encoder( const int16_t *seq_in, const int16_t num_symbols, const uint16_t *cum_freq, const uint16_t *sym_freq, const uint16_t tot_shift, const int16_t max_nb_bits, uint16_t *bit_buffer, int16_t *bit_pos );
+static void ivas_param_mc_range_encoder_fx( const Word16 *seq_in, const Word16 num_symbols, const UWord16 *cum_freq, const UWord16 *sym_freq, const UWord16 tot_shift, const Word16 max_nb_bits, UWord16 *bit_buffer, Word16 *bit_pos );
#define ATTACKTHRESHOLD_E 4
@@ -147,7 +147,7 @@ ivas_error ivas_param_mc_enc_open_fx(
}
/* get dmx factors */
- hParamMC->dmx_factors_fx = ivas_param_mc_conf[config_index].dmx_fac_fx;
+ hParamMC->dmx_factors_fx = ivas_param_mc_conf[config_index].dmx_fac_fx; // Q31
/* set FB config. */
IF( NE_32( ( error = ivas_fb_set_cfg( &fb_cfg, MC_FORMAT, nchan_inp, 0, 0, input_Fs, 0 ) ), IVAS_ERR_OK ) )
@@ -216,12 +216,12 @@ ivas_error ivas_param_mc_enc_open_fx(
move16();
/* Init total/dmx ener factors */
- set32_fx( hParamMC->ener_fac_fx, 0, PARAM_MC_MAX_PARAMETER_BANDS );
+ set32_fx( hParamMC->ener_fac_fx, 0, PARAM_MC_MAX_PARAMETER_BANDS ); // Q21
/* init previous ILDs */
FOR( i = 0; i < PARAM_MC_MAX_PARAMETER_BANDS; i++ )
{
- set32_fx( hParamMC->prev_ilds_fx[i], 0, PARAM_MC_SZ_ILD_MAP );
+ set32_fx( hParamMC->prev_ilds_fx[i], 0, PARAM_MC_SZ_ILD_MAP ); // Q21
}
st_ivas->hParamMC = hParamMC;
@@ -292,7 +292,7 @@ ivas_error ivas_param_mc_enc_reconfig_fx(
}
/* get dmx factors */
- hParamMC->dmx_factors_fx = ivas_param_mc_conf[config_index].dmx_fac_fx;
+ hParamMC->dmx_factors_fx = ivas_param_mc_conf[config_index].dmx_fac_fx; // Q31
/* open/init parameter coding */
ivas_param_mc_metadata_open_fx( mc_input_setup, ivas_total_brate, &hParamMC->hMetadataPMC );
@@ -349,7 +349,7 @@ ivas_error ivas_param_mc_enc_reconfig_fx(
move16();
/* Init total/dmx ener factors */
- set32_fx( hParamMC->ener_fac_fx, 0, PARAM_MC_MAX_PARAMETER_BANDS );
+ set32_fx( hParamMC->ener_fac_fx, 0, PARAM_MC_MAX_PARAMETER_BANDS ); // Q21
return error;
@@ -536,7 +536,7 @@ void ivas_param_mc_enc_fx(
/* just copy data_dmx generated above, contains already the downmix */
FOR( ch = 0; ch < st_ivas->nchan_transport; ch++ )
{
- Copy32( data_dmx_fx[ch], data_f_fx[ch], input_frame );
+ Copy32( data_dmx_fx[ch], data_f_fx[ch], input_frame ); // q_data_dmx_fx16
}
/* we have to run the transient detector on the second channel of the last CPE if we
@@ -547,15 +547,15 @@ void ivas_param_mc_enc_fx(
{
Word16 cpe_idx = shr( ch, 1 );
- set32_fx( data_f_fx[ch], 0, input_frame );
- set16_fx( data_f_fx16, 0, input_frame );
+ set32_fx( data_f_fx[ch], 0, input_frame ); // Q11
+ set16_fx( data_f_fx16, 0, input_frame ); // Q11
RunTransientDetection_ivas_fx( data_f_fx16, input_frame, st_ivas->hCPE[cpe_idx]->hCoreCoder[ch - cpe_idx * CPE_CHANNELS]->hTranDet, 0 );
}
}
/* write Parametric MC side info bitstream into temporary buffer*/
- ivas_param_mc_write_bs( hParamMC, ILD_idx, ICC_idx, bit_buffer, &bit_pos );
+ ivas_param_mc_write_bs_fx( hParamMC, ILD_idx, ICC_idx, bit_buffer, &bit_pos );
/* push the Parametric MC side info from the temporary buffer into the medatdata bitstream*/
push_next_bits( hMetaData, bit_buffer, bit_pos );
@@ -606,7 +606,7 @@ static void ivas_param_mc_dmx_fx(
move16();
FOR( inp_ch = 0; inp_ch < nchan_input; inp_ch++ )
{
- ( *dmx_sample_fx ) = Madd_32_32( ( *dmx_sample_fx ), data_f_fx[idx[inp_ch]][i], ( *( p_dmx_fac_fx++ ) ) );
+ ( *dmx_sample_fx ) = Madd_32_32( ( *dmx_sample_fx ), data_f_fx[idx[inp_ch]][i], ( *( p_dmx_fac_fx++ ) ) ); // Q_x - 11
move16();
}
}
@@ -626,9 +626,9 @@ static void ivas_param_mc_dmx_fx(
static void ivas_param_mc_param_est_enc_fx(
PARAM_MC_ENC_HANDLE hParamMC, /* i/o: Parametric MC encoder handle */
Word32 *data_f_fx[], /* i : Input frame in the time domain Q11 */
- Word32 Cy_sum_fx[][MAX_CICP_CHANNELS][MAX_CICP_CHANNELS], /* o : Covariance matrix for the original frame */
+ Word32 Cy_sum_fx[][MAX_CICP_CHANNELS][MAX_CICP_CHANNELS], /* o : Covariance matrix for the original frame Cy_sum_e*/
Word16 Cy_sum_e[][MAX_CICP_CHANNELS][MAX_CICP_CHANNELS], /* o : Covariance matrix for the original frame */
- Word32 Cx_sum_fx[][PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_TRANSPORT_CHANS], /* o : Covariance matrix for the downmixed frame */
+ Word32 Cx_sum_fx[][PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_TRANSPORT_CHANS], /* o : Covariance matrix for the downmixed frame Cx_sum_e*/
Word16 Cx_sum_e[][PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_TRANSPORT_CHANS], /* o : Covariance matrix for the downmixed frame */
const Word16 input_frame, /* i : Input frame length */
const Word16 nchan_input, /* i : number of input channels */
@@ -1009,13 +1009,17 @@ static void ivas_param_mc_param_est_enc_fx(
{
ref_channel_idx = h_ild_mapping->ref_channel_idx[k][ref_channel_cnt];
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_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
+ L_tmp = L_deposit_h( BASOP_Util_Divide3232_Scale( Nrg_fx[h_ild_mapping->ild_index[k]], L_add( L_tmp, EPSILLON_FX ), &tmp_e ) );
+#else
L_tmp = L_deposit_h( BASOP_Util_Divide3232_Scale( Nrg_fx[h_ild_mapping->ild_index[k]], L_tmp, &tmp_e ) );
+#endif
tmp_e = add( sub( Nrg_e[h_ild_mapping->ild_index[k]], ref_ener_e ), tmp_e );
@@ -1393,7 +1397,11 @@ static void ivas_param_mc_quantize_ilds_fx(
ref_ener_fx = BASOP_Util_Add_Mant32Exp( ref_ener_fx, ref_ener_e, Cx_fx[ref_channel_idx][ref_channel_idx], Cx_e[ref_channel_idx][ref_channel_idx], &ref_ener_e );
}
ref_ener_fx = Mpy_32_16_1( ref_ener_fx, hParamMC->hMetadataPMC.ild_factors_fx[k] );
+#ifdef FIX_ISSUE_1154
+ L_tmp = L_deposit_h( BASOP_Util_Divide3232_Scale( Nrg_fx[h_ild_mapping->ild_index[k]], L_add( ref_ener_fx, EPSILLON_FX ), &tmp_e ) );
+#else
L_tmp = L_deposit_h( BASOP_Util_Divide3232_Scale( Nrg_fx[h_ild_mapping->ild_index[k]], ref_ener_fx, &tmp_e ) );
+#endif
tmp_e = add( sub( Nrg_e[h_ild_mapping->ild_index[k]], ref_ener_e ), tmp_e );
/*10 in Q21 = 1342177280*/
ILD_fx[k] = Mpy_32_32( 1342177280, BASOP_Util_Log10( L_tmp, tmp_e ) ); // Q21
@@ -1633,8 +1641,8 @@ static void ivas_param_mc_transient_detection_fx(
push_wmops( "param_mc_trn_det" );
attackRatioThreshold_fx = hTranDet->transientDetector.attackRatioThreshold;
- pSubblockNrg_fx = &hTranDet->subblockEnergies.subblockNrg[hParamMC->transient_detector_delay];
- pAccSubblockNrg_fx = &hTranDet->subblockEnergies.accSubblockNrg[hParamMC->transient_detector_delay];
+ pSubblockNrg_fx = &hTranDet->subblockEnergies.subblockNrg[hParamMC->transient_detector_delay]; // Q0
+ pAccSubblockNrg_fx = &hTranDet->subblockEnergies.accSubblockNrg[hParamMC->transient_detector_delay]; // Q0
bIsAttackPresent = FALSE;
move16();
@@ -1680,7 +1688,7 @@ return;
* Write the metadata bitstream
*------------------------------------------------------------------------*/
-static void ivas_param_mc_write_bs(
+static void ivas_param_mc_write_bs_fx(
const PARAM_MC_ENC_HANDLE hParamMC, /* i/o: Parametric MC encoder Handle */
Word16 *ILD_idx, /* i : ILD quantizer indices sequence */
Word16 *ICC_idx, /* i : ICC quantizer indices sequence */
@@ -1762,11 +1770,11 @@ static void ivas_param_mc_write_bs(
}
}
- ivas_param_mc_encode_parameter( ICC_idx, &hParamMC->hMetadataPMC, &hParamMC->hMetadataPMC.icc_coding,
- nbands, band_step, icc_map_size_wo_lfe, icc_map_size, bit_buffer, bit_pos );
+ ivas_param_mc_encode_parameter_fx( ICC_idx, &hParamMC->hMetadataPMC, &hParamMC->hMetadataPMC.icc_coding,
+ nbands, band_step, icc_map_size_wo_lfe, icc_map_size, bit_buffer, bit_pos );
- ivas_param_mc_encode_parameter( ILD_idx, &hParamMC->hMetadataPMC, &hParamMC->hMetadataPMC.ild_coding,
- nbands, band_step, ild_map_size_wo_lfe, ild_map_size, bit_buffer, bit_pos );
+ ivas_param_mc_encode_parameter_fx( ILD_idx, &hParamMC->hMetadataPMC, &hParamMC->hMetadataPMC.ild_coding,
+ nbands, band_step, ild_map_size_wo_lfe, ild_map_size, bit_buffer, bit_pos );
pop_wmops();
return;
@@ -1774,13 +1782,13 @@ static void ivas_param_mc_write_bs(
/*-------------------------------------------------------------------------
- * ivas_param_mc_encode_parameter()
+ * ivas_param_mc_encode_parameter_fx()
*
* (entropy) encode a sequence of parameter indices
*------------------------------------------------------------------------*/
-static void ivas_param_mc_encode_parameter(
- int16_t *quant_idx, /* i : indices sequence to encode */
+static void ivas_param_mc_encode_parameter_fx(
+ Word16 *quant_idx, /* i : indices sequence to encode */
HANDLE_IVAS_PARAM_MC_METADATA hMetadataPMC, /* i : Parametric MC metadata handle */
HANDLE_PARAM_MC_PARAMETER_CODING_INFO hParameterCodingInfo, /* i : parameter quantization and coding info */
const Word16 nbands, /* i : number of parameter bands to encode */
@@ -1867,10 +1875,10 @@ static void ivas_param_mc_encode_parameter(
bit_cnt_uni = sub( i_mult( sz_seq, hParameterCodingInfo->uni_bits ), 1 ); /* -1 for the additional diff/direct signaling bit for the range encoder*/
/* code the direct index sequence */
- ivas_param_mc_range_encoder( seq, sz_seq, hParameterCodingInfo->cum_freq, hParameterCodingInfo->sym_freq, PARAM_MC_RANGE_CODER_TOT_SHIFT, bit_cnt_uni, &tmp_bit_buffer[0], &bit_cnt_range );
+ ivas_param_mc_range_encoder_fx( seq, sz_seq, hParameterCodingInfo->cum_freq, hParameterCodingInfo->sym_freq, PARAM_MC_RANGE_CODER_TOT_SHIFT, bit_cnt_uni, &tmp_bit_buffer[0], &bit_cnt_range );
/* Coding the delta index sequence */
- ivas_param_mc_range_encoder( seq_delta, sz_seq, hParameterCodingInfo->cum_freq_delta, hParameterCodingInfo->sym_freq_delta, PARAM_MC_RANGE_CODER_TOT_SHIFT, bit_cnt_uni, &tmp_bit_buffer_diff[0], &bit_cnt_range_diff );
+ ivas_param_mc_range_encoder_fx( seq_delta, sz_seq, hParameterCodingInfo->cum_freq_delta, hParameterCodingInfo->sym_freq_delta, PARAM_MC_RANGE_CODER_TOT_SHIFT, bit_cnt_uni, &tmp_bit_buffer_diff[0], &bit_cnt_range_diff );
bit_cnt_range_min = s_min( bit_cnt_range, bit_cnt_range_diff );
@@ -1885,7 +1893,7 @@ static void ivas_param_mc_encode_parameter(
FOR( i = 0; i < sz_seq; ++i )
{
- ivas_param_mc_dec2bin( seq[i], hParameterCodingInfo->uni_bits, &bit_buffer[*( bit_pos ) + bit_pos_tmp] );
+ ivas_param_mc_dec2bin_fx( seq[i], hParameterCodingInfo->uni_bits, &bit_buffer[*( bit_pos ) + bit_pos_tmp] );
bit_pos_tmp = add( bit_pos_tmp, hParameterCodingInfo->uni_bits );
}
*bit_pos = add( *bit_pos, bit_pos_tmp );
@@ -1927,7 +1935,7 @@ static void ivas_param_mc_encode_parameter(
* Decimal to binary routine
*------------------------------------------------------------------------*/
-static void ivas_param_mc_dec2bin(
+static void ivas_param_mc_dec2bin_fx(
const Word16 val, /* i : value to encode */
const Word16 N, /* i : number of bits for encoding the value */
UWord16 bits[PARAM_MC_MAX_BITS] ) /* o : encoded bits buffer */
@@ -1953,7 +1961,7 @@ static void ivas_param_mc_dec2bin(
* Parametric MC Range encoder
*-------------------------------------------------------------------*/
-static void ivas_param_mc_range_encoder(
+static void ivas_param_mc_range_encoder_fx(
const Word16 *seq_in, /* i : input sequence */
const Word16 num_symbols, /* i : Number of symbole to encode */
const UWord16 *cum_freq, /* i : cumulated frequencies */
@@ -1971,14 +1979,14 @@ static void ivas_param_mc_range_encoder(
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;
@@ -1987,15 +1995,15 @@ static void ivas_param_mc_range_encoder(
}
/* 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 */
/* 1) Push all complete bytes, one byte at a time */
- FOR( i = 0; i < shr( rc_tot_bits, 3 ); ++i )
+ FOR( i = 0; i < ( rc_tot_bits >> 3 ); ++i )
{
/* use rc_st_enc.byte_buffer */
- bits = &bit_buffer[shl( i, 3 )];
+ bits = &bit_buffer[i << 3];
byte = rc_st_enc.byte_buffer[i];
move16();
@@ -2023,7 +2031,7 @@ static void ivas_param_mc_range_encoder(
{
UWord8 rem_bits = (UWord8) s_and( rc_tot_bits, 7 );
- bits = &bit_buffer[shl( i, 3 )];
+ bits = &bit_buffer[( i << 3 )];
byte = rc_st_enc.byte_buffer[i];
move16();
diff --git a/lib_enc/ivas_mc_paramupmix_enc.c b/lib_enc/ivas_mc_paramupmix_enc.c
index e51703ea359608ca3a18edf3a73ed76816b56a47..61f817b2f0d93edadfe1eb1d366f4afe838afcaf 100644
--- a/lib_enc/ivas_mc_paramupmix_enc.c
+++ b/lib_enc/ivas_mc_paramupmix_enc.c
@@ -80,7 +80,7 @@ static void quantize_pars_fx( const Word32 *v_fx, Word16 exp_v, const Word16 nq,
void ivas_mc_paramupmix_enc_fx(
Encoder_Struct *st_ivas, /* i/o: IVAS Encoder handle */
BSTR_ENC_HANDLE hBStr, /* i/o: IVAS Metadata bitstream handle */
- Word32 *data_fx[],
+ Word32 *data_fx[], // st_ivas->q_data_fx
const Word16 input_frame /* i : input frame length */
)
{
@@ -95,8 +95,8 @@ void ivas_mc_paramupmix_enc_fx(
bit_pos = 0;
/* Parameter estimation */
- Word32 alphas_fx[MC_PARAMUPMIX_COMBINATIONS][IVAS_MAX_NUM_BANDS];
- Word32 betas_fx[MC_PARAMUPMIX_COMBINATIONS][IVAS_MAX_NUM_BANDS];
+ Word32 alphas_fx[MC_PARAMUPMIX_COMBINATIONS][IVAS_MAX_NUM_BANDS]; // exp_alphas
+ Word32 betas_fx[MC_PARAMUPMIX_COMBINATIONS][IVAS_MAX_NUM_BANDS]; // exp_betas
Word16 exp_alphas = 31, exp_betas = 31;
move16();
move16();
@@ -126,7 +126,7 @@ void ivas_mc_paramupmix_enc_fx(
*
* Initialize MC ParamUpmix encoder handle
*------------------------------------------------------------------------*/
-ivas_error ivas_mc_paramupmix_enc_open(
+ivas_error ivas_mc_paramupmix_enc_open_fx(
Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */
)
{
@@ -270,7 +270,7 @@ ivas_error ivas_mc_paramupmix_enc_open(
*
* Close MC Param-Upmix encoder handle
*------------------------------------------------------------------------*/
-void ivas_mc_paramupmix_enc_close(
+void ivas_mc_paramupmix_enc_close_fx(
MC_PARAMUPMIX_ENC_HANDLE *hMCParamUpmix, /* i/o: MC Param-Upmix encoder handle */
const Word32 input_Fs /* i : input sampling rate */
)
@@ -465,12 +465,12 @@ static void huffman_encode_fx(
}
static void quantize_pars_fx(
- const Word32 *v_fx,
+ const Word32 *v_fx, // exp_v
Word16 exp_v,
const Word16 nq,
- const Word32 *data_fx,
+ const Word32 *data_fx, // Q28
Word32 vq[IVAS_MAX_NUM_BANDS],
- Word32 *vdeq_fx,
+ Word32 *vdeq_fx, // exp_vdeq
Word16 *exp_vdeq )
{
Word16 iv, iq, iq0, iq1;
@@ -480,7 +480,7 @@ static void quantize_pars_fx(
iq0 = 0;
iq1 = sub( nq, 1 );
- WHILE( GT_16( sub( iq1, iq0 ), 1 ) )
+ WHILE( ( iq1 - iq0 ) > 1 )
{
iq = shr( add( iq0, iq1 ), 1 );
Word16 cmp_1 = BASOP_Util_Cmp_Mant32Exp( v_fx[iv], exp_v, data_fx[iq], 31 - Q28 );
@@ -527,17 +527,17 @@ static void quantize_pars_fx(
}
static void quantize_alpha_fx(
- const Word32 *alpha_fx,
+ const Word32 *alpha_fx, // 31 - exp_alpha
Word16 exp_alpha,
Word16 *pnq,
Word32 aq[IVAS_MAX_NUM_BANDS],
- Word32 *adeq_fx,
+ Word32 *adeq_fx, // 31 - exp_adeq
Word16 *exp_adeq )
{
Word16 nq;
const Word32 *data_fx;
- nq = ivas_mc_paramupmix_alpha_quant_table_fx.nquant;
+ nq = ivas_mc_paramupmix_alpha_quant_table_fx.nquant; // Q0
move16();
data_fx = ivas_mc_paramupmix_alpha_quant_table_fx.data; // Q28
@@ -566,13 +566,13 @@ static void quantize_beta_fx(
FOR( iv = 0; iv < IVAS_MAX_NUM_BANDS; iv++ )
{
- quant_table_fx = tables_fx[ivas_param_upmx_mx_qmap[aq[iv]]];
+ quant_table_fx = tables_fx[ivas_param_upmx_mx_qmap[aq[iv]]]; // Q28
iq0 = 0;
move16();
iq1 = sub( quant_table_fx.nquant, 1 );
- WHILE( GT_16( sub( iq1, iq0 ), 1 ) )
+ WHILE( ( ( iq1 - iq0 ) > 1 ) )
{
iq = shr( add( iq0, iq1 ), 1 );
@@ -604,12 +604,12 @@ static void quantize_beta_fx(
IF( EQ_16( cmp_2, negate( 1 ) ) )
{
bq[iv] = iq0;
- bdeq_fx[iv] = quant_table_fx.data[iq0];
+ bdeq_fx[iv] = quant_table_fx.data[iq0]; // Q28
}
ELSE
{
bq[iv] = iq1;
- bdeq_fx[iv] = quant_table_fx.data[iq1];
+ bdeq_fx[iv] = quant_table_fx.data[iq1]; // Q28
}
move16();
move32();
@@ -625,9 +625,9 @@ static void quantize_beta_fx(
static void put_ec_data_fx(
MC_PARAMUPMIX_ENC_HANDLE hMCParamUpmix,
const Word16 ch,
- const Word32 pars_fx[IVAS_MAX_NUM_BANDS],
+ const Word32 pars_fx[IVAS_MAX_NUM_BANDS], // Q(31 - exp_paras)
Word16 exp_paras,
- const Word32 alphas_fx[IVAS_MAX_NUM_BANDS],
+ const Word32 alphas_fx[IVAS_MAX_NUM_BANDS], // Q(31 - exp_alphas)
Word16 exp_alphas,
const PAR_TYPE parType,
UWord16 bit_buffer[MC_PARAMUPMIX_MAX_BITS],
@@ -636,8 +636,8 @@ static void put_ec_data_fx(
Word16 nq;
Word32 alphaQuant[IVAS_MAX_NUM_BANDS];
Word32 betaQuant[IVAS_MAX_NUM_BANDS];
- Word32 alphaDequant_fx[IVAS_MAX_NUM_BANDS];
- Word32 betaDequant_fx[IVAS_MAX_NUM_BANDS];
+ Word32 alphaDequant_fx[IVAS_MAX_NUM_BANDS]; // 31 - exp_alphaDequant
+ Word32 betaDequant_fx[IVAS_MAX_NUM_BANDS]; // 31 - exp_betaDequant
Word16 exp_alphaDequant = 31, exp_betaDequant = 31;
@@ -760,12 +760,12 @@ static void ivas_mc_paramupmix_dmx_fx(
static ivas_error ivas_mc_paramupmix_param_est_enc_fx(
MC_PARAMUPMIX_ENC_HANDLE hMCParamUpmix, /* i/o: MC Param-Upmix encoder handle */
- Word32 *data_f_fx[],
+ Word32 *data_f_fx[], // Q_data_f
Word16 Q_data_f,
- const Word16 input_frame, /* i : Input frame length */
- Word32 alphas_fx[MC_PARAMUPMIX_COMBINATIONS][IVAS_MAX_NUM_BANDS],
+ const Word16 input_frame, /* i : Input frame length */
+ Word32 alphas_fx[MC_PARAMUPMIX_COMBINATIONS][IVAS_MAX_NUM_BANDS], // 31 - exp_alphas
Word16 *exp_alphas,
- Word32 betas_fx[MC_PARAMUPMIX_COMBINATIONS][IVAS_MAX_NUM_BANDS],
+ Word32 betas_fx[MC_PARAMUPMIX_COMBINATIONS][IVAS_MAX_NUM_BANDS], // 31 - exp_betas
Word16 *exp_betas )
{
@@ -775,11 +775,11 @@ static ivas_error ivas_mc_paramupmix_param_est_enc_fx(
Word32 fr_imagbuffer_fx[MC_PARAMUPMIX_COMBINATIONS * MC_PARAMUPMIX_NCH][L_FRAME48k];
Word32 *p_fr_realbuffer_fx[MC_PARAMUPMIX_COMBINATIONS * MC_PARAMUPMIX_NCH];
Word32 *p_fr_imagbuffer_fx[MC_PARAMUPMIX_COMBINATIONS * MC_PARAMUPMIX_NCH];
- Word32 *cov_real_fx[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH];
- Word32 *cov_dtx_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
+ Word32 *cov_dtx_real_fx[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; // q_cov_dtx_real
Word16 *q_cov_real[IVAS_SPAR_MAX_CH];
Word16 *q_cov_dtx_real[IVAS_SPAR_MAX_CH];
- Word32 *pp_in_fr_real_fx[MC_PARAMUPMIX_COMBINATIONS * MC_PARAMUPMIX_NCH], *pp_in_fr_imag_fx[MC_PARAMUPMIX_COMBINATIONS * MC_PARAMUPMIX_NCH];
+ Word32 *pp_in_fr_real_fx[MC_PARAMUPMIX_COMBINATIONS * MC_PARAMUPMIX_NCH], *pp_in_fr_imag_fx[MC_PARAMUPMIX_COMBINATIONS * MC_PARAMUPMIX_NCH]; // q_ppIn_FR
Word16 q_ppIn_FR;
Word32 rxy_fx, ryy_fx;
@@ -822,8 +822,8 @@ static ivas_error ivas_mc_paramupmix_param_est_enc_fx(
pcm_in_fx[2 * i] = data_f_fx[chan1s[i]];
pcm_in_fx[2 * i + 1] = data_f_fx[chan2s[i]];
- Scale_sig32( pcm_in_fx[2 * i], input_frame, sub( Q14, Q_data_f ) );
- Scale_sig32( pcm_in_fx[2 * i + 1], input_frame, sub( Q14, Q_data_f ) );
+ Scale_sig32( pcm_in_fx[2 * i], input_frame, sub( Q14, Q_data_f ) ); // Q14
+ Scale_sig32( pcm_in_fx[2 * i + 1], input_frame, sub( Q14, Q_data_f ) ); // Q14
}
/*-----------------------------------------------------------------------------------------*
@@ -898,10 +898,10 @@ static ivas_error ivas_mc_paramupmix_param_est_enc_fx(
FOR( b = 0; b < MC_PARAMUPMIX_COMBINATIONS; b++ )
{
- pp_in_fr_real_fx[0] = p_fr_realbuffer_fx[2 * b];
- pp_in_fr_imag_fx[0] = p_fr_imagbuffer_fx[2 * b];
- pp_in_fr_real_fx[1] = FR_Real_Mid_fx;
- pp_in_fr_imag_fx[1] = FR_Imag_Mid_fx;
+ pp_in_fr_real_fx[0] = p_fr_realbuffer_fx[2 * b]; // q_ppIn_FR
+ pp_in_fr_imag_fx[0] = p_fr_imagbuffer_fx[2 * b]; // q_ppIn_FR
+ pp_in_fr_real_fx[1] = FR_Real_Mid_fx; // q_ppIn_FR
+ pp_in_fr_imag_fx[1] = FR_Imag_Mid_fx; // q_ppIn_FR
v_add_fx( pp_in_fr_real_fx[0], p_fr_realbuffer_fx[2 * b + 1], pp_in_fr_real_fx[1], L_FRAME48k );
v_add_fx( pp_in_fr_imag_fx[0], p_fr_imagbuffer_fx[2 * b + 1], pp_in_fr_imag_fx[1], L_FRAME48k );
@@ -910,9 +910,9 @@ static ivas_error ivas_mc_paramupmix_param_est_enc_fx(
{
FOR( j = 0; j < MC_PARAMUPMIX_NCH; j++ )
{
- cov_real_fx[i][j] = hMCParamUpmix->cov_real_fx[b][i][j];
+ cov_real_fx[i][j] = hMCParamUpmix->cov_real_fx[b][i][j]; // q_cov_real
move32();
- cov_dtx_real_fx[i][j] = hMCParamUpmix->cov_dtx_real_fx[b][i][j];
+ cov_dtx_real_fx[i][j] = hMCParamUpmix->cov_dtx_real_fx[b][i][j]; // q_cov_dtx_real
move32();
}
IF( ( q_cov_real[i] = (Word16 *) malloc( sizeof( Word16 ) * MC_PARAMUPMIX_NCH ) ) == NULL )
@@ -1042,10 +1042,12 @@ static ivas_error ivas_mc_paramupmix_param_est_enc_fx(
IF( LT_16( maxbands, IVAS_MAX_NUM_BANDS ) )
{
+#ifndef FIX_1133_IMPROVE_MC_MLD
*exp_alphas = 0;
move16();
*exp_betas = 0;
move16();
+#endif
FOR( b = 0; b < MC_PARAMUPMIX_COMBINATIONS; b++ )
{
FOR( bnd = maxbands; bnd < IVAS_MAX_NUM_BANDS; bnd++ )
diff --git a/lib_enc/ivas_mcmasa_enc.c b/lib_enc/ivas_mcmasa_enc.c
index ad46c3e4a7d96059ad59e4c8a61d3151708490ac..ad52915d1d7acffdaa2ff5d9f39d5b3a1708d15c 100644
--- a/lib_enc/ivas_mcmasa_enc.c
+++ b/lib_enc/ivas_mcmasa_enc.c
@@ -191,7 +191,7 @@ ivas_error ivas_mcmasa_enc_open_fx(
{
IF( GE_32( hMcMasa->band_grouping[i], maxBin ) )
{
- hMcMasa->band_grouping[i] = maxBin;
+ hMcMasa->band_grouping[i] = maxBin; // Q0
move16();
hMcMasa->nbands = i;
move16();
@@ -346,7 +346,7 @@ ivas_error ivas_mcmasa_enc_open_fx(
{
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for McMasa\n" ) );
}
- set_zero_fx( hMcMasa->buffer_intensity_real_fx[i][j], hMcMasa->nbands );
+ set_zero_fx( hMcMasa->buffer_intensity_real_fx[i][j], hMcMasa->nbands ); // hMcMasa->buffer_intensity_real_q
}
}
set16_fx( hMcMasa->buffer_intensity_real_q, 31, DIRAC_NO_COL_AVG_DIFF );
@@ -358,7 +358,7 @@ ivas_error ivas_mcmasa_enc_open_fx(
FOR( j = 0; j < hMcMasa->no_col_avg_diff; j++ )
{
- IF( ( hMcMasa->buffer_intensity_real_vert_fx[j] = (Word32 *) malloc( hMcMasa->nbands * sizeof( Word32 ) ) ) == NULL )
+ IF( ( hMcMasa->buffer_intensity_real_vert_fx[j] = (Word32 *) malloc( hMcMasa->nbands * sizeof( Word32 ) ) ) == NULL ) // hMcMasa->buffer_intensity_real_vert_q
{
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for McMasa\n" ) );
}
@@ -369,7 +369,7 @@ ivas_error ivas_mcmasa_enc_open_fx(
{
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for McMasa\n" ) );
}
- set_zero_fx( hMcMasa->buffer_energy_fx, imult1616( hMcMasa->nbands, hMcMasa->no_col_avg_diff ) );
+ set_zero_fx( hMcMasa->buffer_energy_fx, imult1616( hMcMasa->nbands, hMcMasa->no_col_avg_diff ) ); // hMcMasa->buffer_energy_q
set16_fx( hMcMasa->buffer_intensity_real_vert_q, 31, DIRAC_NO_COL_AVG_DIFF );
set16_fx( hMcMasa->buffer_energy_q, 31, DIRAC_NO_COL_AVG_DIFF );
@@ -402,8 +402,8 @@ ivas_error ivas_mcmasa_enc_open_fx(
}
ELSE IF( EQ_32( st_ivas->hEncoderConfig->mc_input_setup, MC_LS_SETUP_5_1_4 ) )
{
- Copy32( ls_azimuth_CICP16_fx, ls_azimuth, sub( nchan_inp, 1 ) );
- Copy32( ls_elevation_CICP16_fx, ls_elevation, sub( nchan_inp, 1 ) );
+ Copy32( ls_azimuth_CICP16_fx, ls_azimuth, sub( nchan_inp, 1 ) ); // Q22
+ Copy32( ls_elevation_CICP16_fx, ls_elevation, sub( nchan_inp, 1 ) ); // Q22
hMcMasa->numHorizontalChannels = 5;
move16();
hMcMasa->isHorizontalSetup = 0;
@@ -411,8 +411,8 @@ ivas_error ivas_mcmasa_enc_open_fx(
}
ELSE
{
- Copy32( ls_azimuth_CICP19_fx, ls_azimuth, sub( nchan_inp, 1 ) );
- Copy32( ls_elevation_CICP19_fx, ls_elevation, sub( nchan_inp, 1 ) );
+ Copy32( ls_azimuth_CICP19_fx, ls_azimuth, sub( nchan_inp, 1 ) ); // Q22
+ Copy32( ls_elevation_CICP19_fx, ls_elevation, sub( nchan_inp, 1 ) ); // Q22
hMcMasa->numHorizontalChannels = 7;
move16();
hMcMasa->isHorizontalSetup = 0;
@@ -421,8 +421,8 @@ ivas_error ivas_mcmasa_enc_open_fx(
IF( hMcMasa->separateChannelEnabled )
{
- Copy32( &ls_azimuth[hMcMasa->separateChannelIndex + 1], &ls_azimuth[hMcMasa->separateChannelIndex], numAnalysisChannels - hMcMasa->separateChannelIndex );
- Copy32( &ls_elevation[hMcMasa->separateChannelIndex + 1], &ls_elevation[hMcMasa->separateChannelIndex], numAnalysisChannels - hMcMasa->separateChannelIndex );
+ Copy32( &ls_azimuth[hMcMasa->separateChannelIndex + 1], &ls_azimuth[hMcMasa->separateChannelIndex], numAnalysisChannels - hMcMasa->separateChannelIndex ); // Q22
+ Copy32( &ls_elevation[hMcMasa->separateChannelIndex + 1], &ls_elevation[hMcMasa->separateChannelIndex], numAnalysisChannels - hMcMasa->separateChannelIndex ); // Q22
hMcMasa->numHorizontalChannels = sub( hMcMasa->numHorizontalChannels, 1 );
move16();
}
@@ -437,32 +437,32 @@ 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();
}
hMcMasa->combineRatios = hMasa->config.mergeRatiosOverSubframes;
move16();
- Copy32( ls_azimuth, hMcMasa->ls_azimuth_fx, numAnalysisChannels );
+ Copy32( ls_azimuth, hMcMasa->ls_azimuth_fx, numAnalysisChannels ); // Q22
FOR( i = 0; i < hMcMasa->numHorizontalChannels; i++ )
{
- left_min = L_shl( 360, 22 );
- right_min = L_negate( L_shl( 360, 22 ) );
+ left_min = ( 360 << 22 );
+ right_min = -( ( 360 << 22 ) );
FOR( j = 0; j < hMcMasa->numHorizontalChannels; j++ )
{
@@ -546,14 +546,14 @@ ivas_error ivas_mcmasa_enc_reconfig_fx(
/* bitrate changed, may need to do something */
/* brute-force solution: close McMASA and re-instantiate with new settings */
- ivas_masa_enc_close( &( st_ivas->hMasa ) );
+ ivas_masa_enc_close_fx( &( st_ivas->hMasa ) );
ivas_mcmasa_enc_close_fx( &( st_ivas->hMcMasa ), st_ivas->hEncoderConfig->input_Fs );
/* Determine if to separate some channels from the analysis */
ivas_mcmasa_setNumTransportChannels_fx( &( st_ivas->nchan_transport ), &( st_ivas->hEncoderConfig->element_mode_init ), ivas_total_brate );
- IF( NE_32( ( error = ivas_masa_enc_open( st_ivas ) ), IVAS_ERR_OK ) )
+ IF( NE_32( ( error = ivas_masa_enc_open_fx( st_ivas ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -674,21 +674,21 @@ void ivas_mcmasa_enc_fx(
move16();
UWord8 fixedDistance = 0;
move16();
- Word32 elevation_m_values_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];
- Word32 azimuth_m_values_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];
- Word32 energyRatio_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];
- Word32 spreadCoherence_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];
- Word32 surroundingCoherence_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];
+ Word32 elevation_m_values_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; // Q22
+ Word32 azimuth_m_values_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; // Q22
+ Word32 energyRatio_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; // Q31
+ Word32 spreadCoherence_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; // Q30
+ Word32 surroundingCoherence_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; // Q31
Word32 separatedChannelSignal[L_FRAME48k];
/* Compute low frequency energy */
computeLfeEnergy_fx( hMcMasa, data_fx, input_frame, q_inp );
/* Sum center and LFE, move surround channels */
- v_add_32( data_fx[2], data_fx[3], data_fx[2], input_frame );
+ v_add_32( data_fx[2], data_fx[3], data_fx[2], input_frame ); // q_inp
FOR( i = 4; i < nchan_inp; i++ )
{
- Copy32( data_fx[i], data_fx[i - 1], input_frame );
+ Copy32( data_fx[i], data_fx[i - 1], input_frame ); // q_inp
}
IF( hMcMasa->separateChannelEnabled )
@@ -698,12 +698,12 @@ void ivas_mcmasa_enc_fx(
move16();
/* Separate the identified channel */
- Copy32( data_fx[i], separatedChannelSignal, input_frame );
+ Copy32( data_fx[i], separatedChannelSignal, input_frame ); // q_inp
/* Move the remaining channels in order to perform the analysis without the separated channel */
FOR( i = ( hMcMasa->separateChannelIndex + 1 ); i < ( nchan_inp - 1 ); i++ )
{
- Copy32( data_fx[i], data_fx[i - 1], input_frame );
+ Copy32( data_fx[i], data_fx[i - 1], input_frame ); // q_inp
}
}
@@ -713,7 +713,7 @@ void ivas_mcmasa_enc_fx(
/* Determine LFE-to-total energy ratio */
FOR( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ )
{
- hMasa->data.lfeToTotalEnergyRatio_fx[i] = L_deposit_h( BASOP_Util_Divide3232_Scale( hMcMasa->lfeLfEne[i], L_add( EPSILON_FX, hMcMasa->totalLfEne[i] ), &hMasa->data.lfeToTotalEnergyRatio_e[i] ) );
+ hMasa->data.lfeToTotalEnergyRatio_fx[i] = L_deposit_h( BASOP_Util_Divide3232_Scale( hMcMasa->lfeLfEne[i], L_add( EPSILON_FX, hMcMasa->totalLfEne[i] ), &hMasa->data.lfeToTotalEnergyRatio_e[i] ) ); // hMasa->data.lfeToTotalEnergyRatio_e[i]
hMasa->data.lfeToTotalEnergyRatio_e[i] = add( sub( hMcMasa->lfeLfEne_e[i], hMcMasa->totalLfEne_e[i] ), hMasa->data.lfeToTotalEnergyRatio_e[i] );
move32();
move16();
@@ -735,18 +735,18 @@ void ivas_mcmasa_enc_fx(
move16();
}
- hQMeta->q_direction[0].band_data[i].azimuth_fx[j] = azimuth_m_values_fx[j][i];
+ hQMeta->q_direction[0].band_data[i].azimuth_fx[j] = azimuth_m_values_fx[j][i]; // Q22
move32();
- hQMeta->q_direction[0].band_data[i].elevation_fx[j] = elevation_m_values_fx[j][i];
+ hQMeta->q_direction[0].band_data[i].elevation_fx[j] = elevation_m_values_fx[j][i]; // Q22
move32();
- hQMeta->q_direction[0].band_data[i].energy_ratio_fx[j] = energyRatio_fx[k][i];
+ hQMeta->q_direction[0].band_data[i].energy_ratio_fx[j] = energyRatio_fx[k][i]; // Q30
move32();
hQMeta->q_direction[0].band_data[i].distance[j] = fixedDistance;
move16();
IF( hQMeta->surcoh_band_data != NULL )
{
- hQMeta->q_direction[0].coherence_band_data[i].spread_coherence[j] = (UWord8) round_fx( Mpy_32_32( spreadCoherence_fx[j][i], L_shl( UINT8_MAX, Q16 ) ) ); // Q0
+ hQMeta->q_direction[0].coherence_band_data[i].spread_coherence[j] = (UWord8) round_fx( Mpy_32_32( spreadCoherence_fx[j][i], L_shl( UINT8_MAX, Q17 ) ) ); // Q0
hQMeta->surcoh_band_data[i].surround_coherence[j] = (UWord8) round_fx( Mpy_32_32( surroundingCoherence_fx[k][i], L_shl( UINT8_MAX, Q16 ) ) ); // Q0
move16();
move16();
@@ -761,11 +761,11 @@ void ivas_mcmasa_enc_fx(
{
FOR( j = 0; j < nBlocks; j++ )
{
- hQMeta->q_direction[0].band_data[i].azimuth_fx[j] = 0;
+ hQMeta->q_direction[0].band_data[i].azimuth_fx[j] = 0; // Q22
move32();
- hQMeta->q_direction[0].band_data[i].elevation_fx[j] = 0;
+ hQMeta->q_direction[0].band_data[i].elevation_fx[j] = 0; // Q22
move32();
- hQMeta->q_direction[0].band_data[i].energy_ratio_fx[j] = 0;
+ hQMeta->q_direction[0].band_data[i].energy_ratio_fx[j] = 0; // Q30
move32();
hQMeta->q_direction[0].band_data[i].distance[j] = 0;
move16();
@@ -805,7 +805,7 @@ void ivas_mcmasa_enc_fx(
i = 0;
move16();
test();
- WHILE( LT_16( i, nBlocks ) && hQMeta->all_coherence_zero )
+ WHILE( ( i < nBlocks ) && hQMeta->all_coherence_zero )
{
test();
j = 0;
@@ -814,7 +814,7 @@ void ivas_mcmasa_enc_fx(
WHILE( LT_16( j, nBands ) && hQMeta->all_coherence_zero )
{
test();
- IF( GT_32( spreadCoherence_fx[i][j], MASA_COHERENCE_THRESHOLD_FX ) )
+ IF( GT_32( spreadCoherence_fx[i][j], MASA_COHERENCE_THRESHOLD_FX >> 1 ) )
{
hQMeta->all_coherence_zero = 0;
move16();
@@ -873,11 +873,11 @@ void ivas_mcmasa_enc_fx(
void ivas_mcmasa_param_est_enc_fx(
MCMASA_ENC_HANDLE hMcMasa, /* i : McMASA encoder structure */
MASA_ENCODER_HANDLE hMasa, /* i : MASA encoder structure */
- Word32 *data_f[], /* i : Audio frame in MC-format */
+ Word32 *data_f[], /* i : Audio frame in MC-format Q(q_inp) */
Word32 elevation_m_values_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* o : Estimated elevation Q22 */
Word32 azimuth_m_values_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* o : Estimated azimuth Q22 */
Word32 energyRatio_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* o : Estimated direct-to-total ratio Q31 */
- Word32 spreadCoherence_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* o : Estimated spread coherence Q31 */
+ Word32 spreadCoherence_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* o : Estimated spread coherence Q30 */
Word32 surroundingCoherence_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* o : Estimated surround coherence Q31 */
const Word16 input_frame, /* i : Input frame size */
const Word16 nchan_inp, /* i : Number of input channels */
@@ -904,13 +904,13 @@ void ivas_mcmasa_param_est_enc_fx(
Word32 intensity_even_real_fx[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS];
Word32 direction_vector_fx[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS];
Word32 diffuseness_vector_fx[MASA_FREQUENCY_BANDS];
- Word32 vertical_diffuseness_vector_fx[MASA_FREQUENCY_BANDS];
- Word32 diffuseness_m_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];
+ Word32 vertical_diffuseness_vector_fx[MASA_FREQUENCY_BANDS]; // q_vdv
+ Word32 diffuseness_m_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; // diffuseness_e
Word16 diffuseness_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];
- Word32 coherentEnergyRatio_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];
+ Word32 coherentEnergyRatio_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; // coherentEnergyRatio_e
Word16 coherentEnergyRatio_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];
Word16 band_m_idx, block_m_idx;
- Word32 renormalization_factor_diff_fx[MASA_FREQUENCY_BANDS];
+ Word32 renormalization_factor_diff_fx[MASA_FREQUENCY_BANDS]; // renormalization_factor_diff_e
Word16 renormalization_factor_diff_e[MASA_FREQUENCY_BANDS];
Word32 norm_tmp_fx;
Word16 mrange[2], brange[2];
@@ -918,7 +918,7 @@ void ivas_mcmasa_param_est_enc_fx(
CovarianceMatrix COVls[MASA_FREQUENCY_BANDS];
Word32 absCOVls_fx[MCMASA_MAX_ANA_CHANS][MCMASA_MAX_ANA_CHANS];
Word16 absCOVls_e[MCMASA_MAX_ANA_CHANS][MCMASA_MAX_ANA_CHANS];
- Word32 lsEnergy_fx[MCMASA_MAX_ANA_CHANS];
+ Word32 lsEnergy_fx[MCMASA_MAX_ANA_CHANS]; // lsEnergy_e
Word16 lsEnergy_e[MCMASA_MAX_ANA_CHANS];
Word32 lsEnergySum_fx, maxEne_fx;
Word16 lsEnergySum_e = 0, maxEne_e;
@@ -929,15 +929,15 @@ void ivas_mcmasa_param_est_enc_fx(
Word16 i1, i2, i3;
Word32 angleDist_fx, minAngleDist_fx;
Word32 currentAzi_fx;
- Word32 lsEnergyRelation_fx;
+ Word32 lsEnergyRelation_fx; // lsEnergyRelation_e
Word16 lsEnergyRelation_e;
- Word32 tempLsEnergyRelation_fx;
+ Word32 tempLsEnergyRelation_fx; // tempLsEnergyRelation_e
Word16 tempLsEnergyRelation_e;
Word32 stereoness_fx, cohwideness_fx, spreadCoh_fx;
Word32 stereoRatio_fx, cohPanRatio_fx;
Word32 stereoCoh_fx, cohPanCoh_fx, cohRatio_fx;
Word16 stereoCoh_e, cohPanCoh_e, spreadCoh_e, stereoness_e;
- Word32 renormalization_factor_coh_fx[MASA_FREQUENCY_BANDS];
+ Word32 renormalization_factor_coh_fx[MASA_FREQUENCY_BANDS]; // renormalization_factor_coh_e
Word16 renormalization_factor_coh_e[MASA_FREQUENCY_BANDS];
Word16 surroundingCoherence_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];
Word16 numAnalysisChannels;
@@ -967,24 +967,24 @@ void ivas_mcmasa_param_est_enc_fx(
IF( hMcMasa->combineRatios )
{
/* Need to initialize renormalization_factors, and variables to be normalized */
- set_zero_fx( renormalization_factor_diff_fx, hMcMasa->nbands );
+ set_zero_fx( renormalization_factor_diff_fx, hMcMasa->nbands ); // renormalization_factor_diff_e
set16_fx( renormalization_factor_diff_e, 0, hMcMasa->nbands );
- set_zero_fx( &diffuseness_m_fx[0][0], MASA_FREQUENCY_BANDS * MAX_PARAM_SPATIAL_SUBFRAMES );
+ set_zero_fx( &diffuseness_m_fx[0][0], MASA_FREQUENCY_BANDS * MAX_PARAM_SPATIAL_SUBFRAMES ); // diffuseness_e
set16_fx( &diffuseness_e[0][0], 31, MASA_FREQUENCY_BANDS * MAX_PARAM_SPATIAL_SUBFRAMES );
- set_zero_fx( renormalization_factor_coh_fx, hMcMasa->nbands );
+ set_zero_fx( renormalization_factor_coh_fx, hMcMasa->nbands ); // renormalization_factor_coh_e
set16_fx( renormalization_factor_coh_e, 31, hMcMasa->nbands );
- set_zero_fx( surroundingCoherence_fx[0], hMcMasa->nbands );
+ set_zero_fx( surroundingCoherence_fx[0], hMcMasa->nbands ); // surroundingCoherence_e
set16_fx( &surroundingCoherence_e[0][0], 31, MASA_FREQUENCY_BANDS * MAX_PARAM_SPATIAL_SUBFRAMES );
- set_zero_fx( coherentEnergyRatio_fx[0], hMcMasa->nbands );
+ set_zero_fx( coherentEnergyRatio_fx[0], hMcMasa->nbands ); // coherentEnergyRatio_e
set16_fx( &coherentEnergyRatio_e[0][0], 0, MASA_FREQUENCY_BANDS * MAX_PARAM_SPATIAL_SUBFRAMES );
}
/* Copy current frame to memory for delay compensation */
FOR( i = 0; i < numAnalysisChannels; i++ )
{
- pcm_in[i] = data_f[i];
- p_Chnl_RealBuffer_fx[i] = &Chnl_RealBuffer_fx[i][0];
- p_Chnl_ImagBuffer_fx[i] = &Chnl_ImagBuffer_fx[i][0];
+ pcm_in[i] = data_f[i]; // q_inp
+ p_Chnl_RealBuffer_fx[i] = &Chnl_RealBuffer_fx[i][0]; // q_inp
+ p_Chnl_ImagBuffer_fx[i] = &Chnl_ImagBuffer_fx[i][0]; // q_inp
}
/* initialising energy_fx */
@@ -992,7 +992,7 @@ void ivas_mcmasa_param_est_enc_fx(
{
FOR( i = 0; i < MASA_FREQUENCY_BANDS; i++ )
{
- hMasa->data.energy_fx[block_m_idx][i] = 0;
+ hMasa->data.energy_fx[block_m_idx][i] = 0; // hMasa->data.energy_e
move32();
hMasa->data.energy_e[block_m_idx][i] = 31;
move16();
@@ -1024,8 +1024,8 @@ void ivas_mcmasa_param_est_enc_fx(
{
FOR( j = 0; j < numAnalysisChannels; j++ )
{
- set_zero_fx( COVls[i].xr_fx[j], numAnalysisChannels );
- set_zero_fx( COVls[i].xi_fx[j], numAnalysisChannels );
+ set_zero_fx( COVls[i].xr_fx[j], numAnalysisChannels ); // COVls[i].xr_e[j]
+ set_zero_fx( COVls[i].xi_fx[j], numAnalysisChannels ); // COVls[i].xi_e[j]
set16_fx( COVls[i].xr_e[j], 0, numAnalysisChannels );
set16_fx( COVls[i].xi_e[j], 0, numAnalysisChannels );
}
@@ -1094,21 +1094,21 @@ void ivas_mcmasa_param_est_enc_fx(
/* Compute standard FOA */
/* W */
- v_add_32( Chnl_RealBuffer_fx[0], Chnl_RealBuffer_fx[1], Foa_RealBuffer_fx[0], num_freq_bins );
- v_add_32( Chnl_ImagBuffer_fx[0], Chnl_ImagBuffer_fx[1], Foa_ImagBuffer_fx[0], num_freq_bins );
+ v_add_32( Chnl_RealBuffer_fx[0], Chnl_RealBuffer_fx[1], Foa_RealBuffer_fx[0], num_freq_bins ); // inp_q
+ v_add_32( Chnl_ImagBuffer_fx[0], Chnl_ImagBuffer_fx[1], Foa_ImagBuffer_fx[0], num_freq_bins ); // inp_q
FOR( i = 2; i < numAnalysisChannels; i++ )
{
- v_add_32( Chnl_RealBuffer_fx[i], Foa_RealBuffer_fx[0], Foa_RealBuffer_fx[0], num_freq_bins );
- v_add_32( Chnl_ImagBuffer_fx[i], Foa_ImagBuffer_fx[0], Foa_ImagBuffer_fx[0], num_freq_bins );
+ v_add_32( Chnl_RealBuffer_fx[i], Foa_RealBuffer_fx[0], Foa_RealBuffer_fx[0], num_freq_bins ); // inp_q
+ v_add_32( Chnl_ImagBuffer_fx[i], Foa_ImagBuffer_fx[0], Foa_ImagBuffer_fx[0], num_freq_bins ); // inp_q
}
/* Y */
- v_multc_fixed( Chnl_RealBuffer_fx[0], hMcMasa->chnlToFoaMtx_fx[1][0], Foa_RealBuffer_fx[1], num_freq_bins );
- v_multc_fixed( Chnl_ImagBuffer_fx[0], hMcMasa->chnlToFoaMtx_fx[1][0], Foa_ImagBuffer_fx[1], num_freq_bins );
+ v_multc_fixed( Chnl_RealBuffer_fx[0], hMcMasa->chnlToFoaMtx_fx[1][0], Foa_RealBuffer_fx[1], num_freq_bins ); // inp_q
+ v_multc_fixed( Chnl_ImagBuffer_fx[0], hMcMasa->chnlToFoaMtx_fx[1][0], Foa_ImagBuffer_fx[1], num_freq_bins ); // inp_q
FOR( i = 1; i < numAnalysisChannels; i++ )
{
- v_multc_acc_32_32( Chnl_RealBuffer_fx[i], hMcMasa->chnlToFoaMtx_fx[1][i], Foa_RealBuffer_fx[1], num_freq_bins );
- v_multc_acc_32_32( Chnl_ImagBuffer_fx[i], hMcMasa->chnlToFoaMtx_fx[1][i], Foa_ImagBuffer_fx[1], num_freq_bins );
+ v_multc_acc_32_32( Chnl_RealBuffer_fx[i], hMcMasa->chnlToFoaMtx_fx[1][i], Foa_RealBuffer_fx[1], num_freq_bins ); // inp_q
+ v_multc_acc_32_32( Chnl_ImagBuffer_fx[i], hMcMasa->chnlToFoaMtx_fx[1][i], Foa_ImagBuffer_fx[1], num_freq_bins ); // inp_q
}
/* Z */
@@ -1120,49 +1120,49 @@ void ivas_mcmasa_param_est_enc_fx(
}
ELSE
{
- v_multc_fixed( Chnl_RealBuffer_fx[0], hMcMasa->chnlToFoaMtx_fx[2][0], Foa_RealBuffer_fx[2], num_freq_bins );
- v_multc_fixed( Chnl_ImagBuffer_fx[0], hMcMasa->chnlToFoaMtx_fx[2][0], Foa_ImagBuffer_fx[2], num_freq_bins );
+ v_multc_fixed( Chnl_RealBuffer_fx[0], hMcMasa->chnlToFoaMtx_fx[2][0], Foa_RealBuffer_fx[2], num_freq_bins ); // inp_q
+ v_multc_fixed( Chnl_ImagBuffer_fx[0], hMcMasa->chnlToFoaMtx_fx[2][0], Foa_ImagBuffer_fx[2], num_freq_bins ); // inp_q
FOR( i = 1; i < numAnalysisChannels; i++ )
{
- v_multc_acc_32_32( Chnl_RealBuffer_fx[i], hMcMasa->chnlToFoaMtx_fx[2][i], Foa_RealBuffer_fx[2], num_freq_bins );
- v_multc_acc_32_32( Chnl_ImagBuffer_fx[i], hMcMasa->chnlToFoaMtx_fx[2][i], Foa_ImagBuffer_fx[2], num_freq_bins );
+ v_multc_acc_32_32( Chnl_RealBuffer_fx[i], hMcMasa->chnlToFoaMtx_fx[2][i], Foa_RealBuffer_fx[2], num_freq_bins ); // inp_q
+ v_multc_acc_32_32( Chnl_ImagBuffer_fx[i], hMcMasa->chnlToFoaMtx_fx[2][i], Foa_ImagBuffer_fx[2], num_freq_bins ); // inp_q
}
}
/* X */
- v_multc_fixed( Chnl_RealBuffer_fx[0], hMcMasa->chnlToFoaMtx_fx[3][0], Foa_RealBuffer_fx[3], num_freq_bins );
- v_multc_fixed( Chnl_ImagBuffer_fx[0], hMcMasa->chnlToFoaMtx_fx[3][0], Foa_ImagBuffer_fx[3], num_freq_bins );
+ v_multc_fixed( Chnl_RealBuffer_fx[0], hMcMasa->chnlToFoaMtx_fx[3][0], Foa_RealBuffer_fx[3], num_freq_bins ); // inp_q
+ v_multc_fixed( Chnl_ImagBuffer_fx[0], hMcMasa->chnlToFoaMtx_fx[3][0], Foa_ImagBuffer_fx[3], num_freq_bins ); // inp_q
FOR( i = 1; i < numAnalysisChannels; i++ )
{
- v_multc_acc_32_32( Chnl_RealBuffer_fx[i], hMcMasa->chnlToFoaMtx_fx[3][i], Foa_RealBuffer_fx[3], num_freq_bins );
- v_multc_acc_32_32( Chnl_ImagBuffer_fx[i], hMcMasa->chnlToFoaMtx_fx[3][i], Foa_ImagBuffer_fx[3], num_freq_bins );
+ v_multc_acc_32_32( Chnl_RealBuffer_fx[i], hMcMasa->chnlToFoaMtx_fx[3][i], Foa_RealBuffer_fx[3], num_freq_bins ); // inp_q
+ v_multc_acc_32_32( Chnl_ImagBuffer_fx[i], hMcMasa->chnlToFoaMtx_fx[3][i], Foa_ImagBuffer_fx[3], num_freq_bins ); // inp_q
}
/* Compute even FOA */
/* W */
- Copy32( Foa_RealBuffer_fx[0], FoaEven_RealBuffer_fx[0], num_freq_bins );
- Copy32( Foa_ImagBuffer_fx[0], FoaEven_ImagBuffer_fx[0], num_freq_bins );
+ Copy32( Foa_RealBuffer_fx[0], FoaEven_RealBuffer_fx[0], num_freq_bins ); // inp_q
+ Copy32( Foa_ImagBuffer_fx[0], FoaEven_ImagBuffer_fx[0], num_freq_bins ); // inp_q
/* Y */
- v_multc_fixed( Chnl_RealBuffer_fx[0], hMcMasa->chnlToFoaEvenMtx_fx[1][0], FoaEven_RealBuffer_fx[1], num_freq_bins );
- v_multc_fixed( Chnl_ImagBuffer_fx[0], hMcMasa->chnlToFoaEvenMtx_fx[1][0], FoaEven_ImagBuffer_fx[1], num_freq_bins );
+ v_multc_fixed( Chnl_RealBuffer_fx[0], hMcMasa->chnlToFoaEvenMtx_fx[1][0], FoaEven_RealBuffer_fx[1], num_freq_bins ); // inp_q
+ v_multc_fixed( Chnl_ImagBuffer_fx[0], hMcMasa->chnlToFoaEvenMtx_fx[1][0], FoaEven_ImagBuffer_fx[1], num_freq_bins ); // inp_q
FOR( i = 1; i < numAnalysisChannels; i++ )
{
- v_multc_acc_32_32( Chnl_RealBuffer_fx[i], hMcMasa->chnlToFoaEvenMtx_fx[1][i], FoaEven_RealBuffer_fx[1], num_freq_bins );
- v_multc_acc_32_32( Chnl_ImagBuffer_fx[i], hMcMasa->chnlToFoaEvenMtx_fx[1][i], FoaEven_ImagBuffer_fx[1], num_freq_bins );
+ v_multc_acc_32_32( Chnl_RealBuffer_fx[i], hMcMasa->chnlToFoaEvenMtx_fx[1][i], FoaEven_RealBuffer_fx[1], num_freq_bins ); // inp_q
+ v_multc_acc_32_32( Chnl_ImagBuffer_fx[i], hMcMasa->chnlToFoaEvenMtx_fx[1][i], FoaEven_ImagBuffer_fx[1], num_freq_bins ); // inp_q
}
/* Z (even setups are handled as horizontal) */
- set_zero_fx( FoaEven_RealBuffer_fx[2], num_freq_bins );
- set_zero_fx( FoaEven_ImagBuffer_fx[2], num_freq_bins );
+ set_zero_fx( FoaEven_RealBuffer_fx[2], num_freq_bins ); // inp_q
+ set_zero_fx( FoaEven_ImagBuffer_fx[2], num_freq_bins ); // inp_q
/* X */
- v_multc_fixed( Chnl_RealBuffer_fx[0], hMcMasa->chnlToFoaEvenMtx_fx[3][0], FoaEven_RealBuffer_fx[3], num_freq_bins );
- v_multc_fixed( Chnl_ImagBuffer_fx[0], hMcMasa->chnlToFoaEvenMtx_fx[3][0], FoaEven_ImagBuffer_fx[3], num_freq_bins );
+ v_multc_fixed( Chnl_RealBuffer_fx[0], hMcMasa->chnlToFoaEvenMtx_fx[3][0], FoaEven_RealBuffer_fx[3], num_freq_bins ); // inp_q
+ v_multc_fixed( Chnl_ImagBuffer_fx[0], hMcMasa->chnlToFoaEvenMtx_fx[3][0], FoaEven_ImagBuffer_fx[3], num_freq_bins ); // inp_q
FOR( i = 1; i < numAnalysisChannels; i++ )
{
- v_multc_acc_32_32( Chnl_RealBuffer_fx[i], hMcMasa->chnlToFoaEvenMtx_fx[3][i], FoaEven_RealBuffer_fx[3], num_freq_bins );
- v_multc_acc_32_32( Chnl_ImagBuffer_fx[i], hMcMasa->chnlToFoaEvenMtx_fx[3][i], FoaEven_ImagBuffer_fx[3], num_freq_bins );
+ v_multc_acc_32_32( Chnl_RealBuffer_fx[i], hMcMasa->chnlToFoaEvenMtx_fx[3][i], FoaEven_RealBuffer_fx[3], num_freq_bins ); // inp_q
+ v_multc_acc_32_32( Chnl_ImagBuffer_fx[i], hMcMasa->chnlToFoaEvenMtx_fx[3][i], FoaEven_ImagBuffer_fx[3], num_freq_bins ); // inp_q
}
/* Direction estimation */
@@ -1182,7 +1182,12 @@ void ivas_mcmasa_param_est_enc_fx(
num_freq_bands,
direction_vector_fx[0],
direction_vector_fx[1],
- direction_vector_fx[2], c_e );
+ direction_vector_fx[2], c_e
+#ifdef NONBE_IMPROVE_DIRAC_INTENSITY_PREC
+ ,
+ NULL
+#endif
+ );
/* Power and intensity estimation for diffuseness */
computeIntensityVector_enc_fx(
@@ -1212,11 +1217,11 @@ void ivas_mcmasa_param_est_enc_fx(
FOR( i = 0; i < DIRAC_NUM_DIMS; i++ )
{
/* only real part needed */
- Copy32( intensity_even_real_fx[i], &( hMcMasa->buffer_intensity_real_fx[i][index - 1][0] ), num_freq_bands );
+ Copy32( intensity_even_real_fx[i], &( hMcMasa->buffer_intensity_real_fx[i][index - 1][0] ), num_freq_bands ); // hMcMasa->buffer_intensity_real_q
}
hMcMasa->buffer_intensity_real_q[index - 1] = sub( shl( inp_q, 1 ), 31 );
move16();
- Copy32( reference_power_fx[ts], &( hMcMasa->buffer_energy_fx[( index - 1 ) * num_freq_bands] ), num_freq_bands );
+ Copy32( reference_power_fx[ts], &( hMcMasa->buffer_energy_fx[( index - 1 ) * num_freq_bands] ), num_freq_bands ); // ref_e
hMcMasa->buffer_energy_q[index - 1] = sub( Q31, ref_e );
move16();
@@ -1356,7 +1361,7 @@ void ivas_mcmasa_param_est_enc_fx(
}
}
}
- surrCoh_fx = L_shl( surrCoh_fx, surrCoh_e );
+ surrCoh_fx = L_shl( surrCoh_fx, surrCoh_e ); // Q31
surrCoh_e = 0;
move16();
surrCoh_fx = Mult_32_32( surrCoh_fx, surrCoh_fx );
@@ -1526,18 +1531,18 @@ void ivas_mcmasa_param_est_enc_fx(
tempCoh_fx = BASOP_Util_Add_Mant32Exp( stereoness_fx, stereoness_e, L_negate( L_sub( cohwideness_fx, L_shl( 1, sub( 30, cohPanCoh_e ) ) ) ), cohPanCoh_e, &tempCoh_e );
IF( ( tempCoh_e < 0 ) )
{
- tempCoh_fx = L_shl( tempCoh_fx, tempCoh_e );
+ tempCoh_fx = L_shl( tempCoh_fx, tempCoh_e ); // Q31
tempCoh_e = 0;
move16();
}
IF( GT_32( tempCoh_fx, L_shl_sat( 1, sub( 30, tempCoh_e ) ) ) )
{
- spreadCoh_fx = tempCoh_fx;
+ spreadCoh_fx = tempCoh_fx; // tempCoh_e
move32();
}
ELSE
{
- spreadCoh_fx = L_shl_sat( 1, sub( 30, tempCoh_e ) );
+ spreadCoh_fx = L_shl_sat( 1, sub( 30, tempCoh_e ) ); // Q30
}
spreadCoh_e = tempCoh_e;
move16();
@@ -1545,21 +1550,21 @@ void ivas_mcmasa_param_est_enc_fx(
}
IF( ( spreadCoh_e < 0 ) )
{
- spreadCoh_fx = L_shl( spreadCoh_fx, spreadCoh_e );
+ spreadCoh_fx = L_shl( spreadCoh_fx, spreadCoh_e ); // Q31
spreadCoh_e = 0;
move16();
}
IF( ( GE_32( spreadCoh_fx, L_shl_sat( 1, sub( 31, spreadCoh_e ) ) ) ) )
{
- spreadCoh_fx = L_shl_sat( 1, sub( 31, spreadCoh_e ) );
+ spreadCoh_fx = L_shl_sat( 1, sub( 31, spreadCoh_e ) ); // Q31
}
IF( ( spreadCoh_fx <= 0 ) )
{
spreadCoh_fx = 0;
move32();
}
- spreadCoh_fx = L_shl( spreadCoh_fx, spreadCoh_e ); /*Q31*/
+ spreadCoh_fx = L_shl( spreadCoh_fx, sub( spreadCoh_e, 1 ) ); /*Q30*/
/* Compute energy ratio tuning parameter */
lsEnergySum_fx = 0;
@@ -1594,7 +1599,7 @@ void ivas_mcmasa_param_est_enc_fx(
IF( GE_32( cohRatio_fx, ONE_IN_Q31 ) )
{
- cohRatio_fx = ONE_IN_Q31;
+ cohRatio_fx = ONE_IN_Q31; // Q31
move32();
}
IF( cohRatio_fx <= 0 )
@@ -1619,7 +1624,7 @@ void ivas_mcmasa_param_est_enc_fx(
}
/* Store values */
- spreadCoherence_fx[block_m_idx][band_m_idx] = spreadCoh_fx; /*Q31*/
+ spreadCoherence_fx[block_m_idx][band_m_idx] = spreadCoh_fx; /*Q30*/
move32();
IF( hMcMasa->combineRatios )
@@ -1729,6 +1734,7 @@ void ivas_mcmasa_param_est_enc_fx(
void ivas_mcmasa_dmx_modify_fx(
const Word16 n_samples, /* i : input frame length in samples */
Word32 dmx_fx[][L_FRAME48k + NS2SA( 48000, IVAS_FB_ENC_DELAY_NS )], /* i/o: downmix signal to be transformed into another format Qx*/
+ Word16 dmx_Q[], /* i/o : Q of the intput signal which is being transformed*/
const Word16 n_chnls_dmx_old, /* i : number of downmix channels in the old format Q0 */
const Word16 n_chnls_dmx_new ) /* i : number of downmix channels in the target format Q0*/
{
@@ -1744,6 +1750,11 @@ void ivas_mcmasa_dmx_modify_fx(
return;
}
+ Word16 Q_min_1_2, Q_min_0_1_2;
+
+ Q_min_1_2 = s_min( dmx_Q[1], dmx_Q[2] );
+ Q_min_0_1_2 = s_min( dmx_Q[1], s_min( dmx_Q[2], dmx_Q[0] ) );
+
IF( EQ_16( n_chnls_dmx_old, 1 ) )
{
/* split mono energy into identical channels */
@@ -1770,14 +1781,24 @@ void ivas_mcmasa_dmx_modify_fx(
IF( EQ_16( n_chnls_dmx_new, 1 ) )
{
/* sum l and r */
- dmx_fx[0][i] = L_add( dmx_fx[1][i], dmx_fx[2][i] );
+ dmx_fx[1][i] = L_shl( dmx_fx[1][i], sub( Q_min_1_2, dmx_Q[1] ) );
+ dmx_fx[2][i] = L_shl( dmx_fx[2][i], sub( Q_min_1_2, dmx_Q[2] ) );
+ move32();
+ move32();
+
+ dmx_fx[0][i] = L_add( dmx_fx[1][i], dmx_fx[2][i] ); // dmx_q
move32();
}
ELSE IF( EQ_16( n_chnls_dmx_new, 3 ) )
{
+ dmx_fx[1][i] = L_shl( dmx_fx[1][i], sub( Q_min_1_2, dmx_Q[1] ) );
+ dmx_fx[2][i] = L_shl( dmx_fx[2][i], sub( Q_min_1_2, dmx_Q[2] ) );
+ move32();
+ move32();
+
dmx_fx[0][i] = L_shr( L_add( dmx_fx[1][i], dmx_fx[2][i] ), 1 );
- dmx_fx[1][i] = L_sub( dmx_fx[1][i], dmx_fx[0][i] );
- dmx_fx[2][i] = L_sub( dmx_fx[2][i], dmx_fx[0][i] );
+ dmx_fx[1][i] = L_sub( dmx_fx[1][i], dmx_fx[0][i] ); // dmx_q
+ dmx_fx[2][i] = L_sub( dmx_fx[2][i], dmx_fx[0][i] ); // dmx_q
move32();
move32();
move32();
@@ -1791,15 +1812,31 @@ void ivas_mcmasa_dmx_modify_fx(
IF( EQ_16( n_chnls_dmx_new, 1 ) )
{
/* sum all channels */
+
+ dmx_fx[0][i] = L_shl( dmx_fx[0][i], sub( Q_min_0_1_2, dmx_Q[1] ) );
+ dmx_fx[1][i] = L_shl( dmx_fx[1][i], sub( Q_min_0_1_2, dmx_Q[1] ) );
+ dmx_fx[2][i] = L_shl( dmx_fx[2][i], sub( Q_min_0_1_2, dmx_Q[2] ) );
+ move32();
+ move32();
+ move32();
+
dmx_fx[0][i] = L_add( L_add( dmx_fx[0][i], dmx_fx[1][i] ), dmx_fx[2][i] );
move32();
}
ELSE IF( EQ_16( n_chnls_dmx_new, 2 ) )
{
+
+ dmx_fx[0][i] = L_shl( dmx_fx[0][i], sub( Q_min_0_1_2, dmx_Q[1] ) );
+ dmx_fx[1][i] = L_shl( dmx_fx[1][i], sub( Q_min_0_1_2, dmx_Q[1] ) );
+ dmx_fx[2][i] = L_shl( dmx_fx[2][i], sub( Q_min_0_1_2, dmx_Q[2] ) );
+ move32();
+ move32();
+ move32();
+
/* mix center into sides */
dmx_fx[0][i] = Mpy_32_16_1( dmx_fx[0][i], INV_SQRT2_FX_Q15 );
- dmx_fx[1][i] = L_add( dmx_fx[1][i], dmx_fx[0][i] );
- dmx_fx[2][i] = L_add( dmx_fx[2][i], dmx_fx[0][i] );
+ dmx_fx[1][i] = L_add( dmx_fx[1][i], dmx_fx[0][i] ); // dmx_q
+ dmx_fx[2][i] = L_add( dmx_fx[2][i], dmx_fx[0][i] ); // dmx_q
move32();
move32();
move32();
@@ -1807,6 +1844,39 @@ void ivas_mcmasa_dmx_modify_fx(
}
}
+ // Q updation for different channels
+
+ IF( EQ_16( n_chnls_dmx_old, 1 ) )
+ {
+ /* split mono energy into identical channels */
+ IF( EQ_16( n_chnls_dmx_new, 2 ) )
+ {
+ dmx_Q[1] = dmx_Q[0];
+ move16();
+ dmx_Q[2] = dmx_Q[0];
+ move16();
+ }
+ }
+ ELSE IF( EQ_16( n_chnls_dmx_old, 2 ) )
+ {
+ dmx_Q[0] = Q_min_1_2;
+ move16();
+ dmx_Q[1] = Q_min_1_2;
+ move16();
+ dmx_Q[2] = Q_min_1_2;
+ move16();
+ }
+ ELSE IF( EQ_16( n_chnls_dmx_old, 3 ) )
+ {
+ dmx_Q[0] = Q_min_0_1_2;
+ move16();
+ dmx_Q[1] = Q_min_0_1_2;
+ move16();
+ dmx_Q[2] = Q_min_0_1_2;
+ move16();
+ }
+
+
return;
}
@@ -1817,7 +1887,7 @@ void ivas_mcmasa_dmx_modify_fx(
/* Compute downmix */
static void ivas_mcmasa_dmx_fx(
MCMASA_ENC_HANDLE hMcMasa,
- Word32 *data_fx[],
+ Word32 *data_fx[], // Q(31 - data_e)
Word16 data_e,
const Word16 input_frame,
const Word16 nchan_transport,
@@ -1875,7 +1945,7 @@ static void ivas_mcmasa_dmx_fx(
FOR( i = 0; i < input_frame; i++ )
{
- data_fx[0][i] = L_add( data_fx[0][i], data_fx[leftIndex][i] );
+ data_fx[0][i] = L_add( data_fx[0][i], data_fx[leftIndex][i] ); // data_e
move32();
data_fx[1][i] = L_add( data_fx[1][i], data_fx[rightIndex][i] );
move32();
@@ -1888,9 +1958,9 @@ static void ivas_mcmasa_dmx_fx(
{
dmx_c_fx = W_extract_h( W_mult_32_32( INV_SQRT2_FX, data_fx[2][i] ) );
move32();
- data_fx[0][i] = L_add( dmx_c_fx, data_fx[0][i] );
+ data_fx[0][i] = L_add( dmx_c_fx, data_fx[0][i] ); // data_e
move32();
- data_fx[1][i] = L_add( dmx_c_fx, data_fx[1][i] );
+ data_fx[1][i] = L_add( dmx_c_fx, data_fx[1][i] ); // data_e
move32();
}
}
@@ -1954,10 +2024,10 @@ static void ivas_mcmasa_dmx_fx(
FOR( j = 0; j < nchan_transport; j++ )
{
- data_fx[j][i] = Mpy_32_32( instEQ_fx, data_fx[j][i] );
+ data_fx[j][i] = Mpy_32_32( instEQ_fx, data_fx[j][i] ); // data_e + instEQ_e - 31
move32();
move32();
- data_fx[j][i] = L_shl( data_fx[j][i], instEQ_e );
+ data_fx[j][i] = L_shl( data_fx[j][i], instEQ_e ); // data_e + 2*instEQ_e - 31
}
}
@@ -2138,8 +2208,8 @@ static void computeVerticalDiffuseness_fx(
return;
}
static void computeEvenLayout_fx(
- const Word32 *ls_azimuth,
- Word32 *ls_azimuth_even,
+ const Word32 *ls_azimuth, // Q22
+ Word32 *ls_azimuth_even, // Q22
const Word16 numChannels )
{
Word16 i;
@@ -2208,7 +2278,7 @@ static void computeEvenLayout_fx(
}
static void computeLfeEnergy_fx(
MCMASA_ENC_HANDLE hMcMasa,
- Word32 *data_fx[],
+ Word32 *data_fx[], // q_inp
const Word16 input_frame,
Word16 q_inp )
{
@@ -2229,8 +2299,8 @@ static void computeLfeEnergy_fx(
IF( hMcMasa->separateChannelEnabled )
{
- Copy32( data_fx[lfeChannelIndex], &( hMcMasa->delay_buffer_lfe[0][hMcMasa->num_samples_delay_comp - hMcMasa->offset_comp] ), hMcMasa->offset_comp );
- Copy32( data_fx[separateChannelIndex], &( hMcMasa->delay_buffer_lfe[1][hMcMasa->num_samples_delay_comp - hMcMasa->offset_comp] ), hMcMasa->offset_comp );
+ Copy32( data_fx[lfeChannelIndex], &( hMcMasa->delay_buffer_lfe[0][hMcMasa->num_samples_delay_comp - hMcMasa->offset_comp] ), hMcMasa->offset_comp ); // q_inp
+ Copy32( data_fx[separateChannelIndex], &( hMcMasa->delay_buffer_lfe[1][hMcMasa->num_samples_delay_comp - hMcMasa->offset_comp] ), hMcMasa->offset_comp ); // q_inp
}
ELSE
{
@@ -2252,10 +2322,10 @@ static void computeLfeEnergy_fx(
Word32 delayedInputSignal[2][L_FRAME48k];
Word32 lowPassSignal[2][L_FRAME48k];
- Copy32( &( hMcMasa->delay_buffer_lfe[0][0] ), &( delayedInputSignal[0][0] ), hMcMasa->num_slots_delay_comp * l_ts );
- Copy32( data_fx[lfeChannelIndex] + hMcMasa->offset_comp, &( delayedInputSignal[0][hMcMasa->num_slots_delay_comp * l_ts] ), ( MDFT_NO_COL_MAX - hMcMasa->num_slots_delay_comp ) * l_ts );
- Copy32( &( hMcMasa->delay_buffer_lfe[1][0] ), &( delayedInputSignal[1][0] ), hMcMasa->num_slots_delay_comp * l_ts );
- Copy32( data_fx[separateChannelIndex] + hMcMasa->offset_comp, &( delayedInputSignal[1][hMcMasa->num_slots_delay_comp * l_ts] ), ( MDFT_NO_COL_MAX - hMcMasa->num_slots_delay_comp ) * l_ts );
+ Copy32( &( hMcMasa->delay_buffer_lfe[0][0] ), &( delayedInputSignal[0][0] ), hMcMasa->num_slots_delay_comp * l_ts ); // q_inp
+ Copy32( data_fx[lfeChannelIndex] + hMcMasa->offset_comp, &( delayedInputSignal[0][hMcMasa->num_slots_delay_comp * l_ts] ), ( MDFT_NO_COL_MAX - hMcMasa->num_slots_delay_comp ) * l_ts ); // q_inp
+ Copy32( &( hMcMasa->delay_buffer_lfe[1][0] ), &( delayedInputSignal[1][0] ), hMcMasa->num_slots_delay_comp * l_ts ); // q_inp
+ Copy32( data_fx[separateChannelIndex] + hMcMasa->offset_comp, &( delayedInputSignal[1][hMcMasa->num_slots_delay_comp * l_ts] ), ( MDFT_NO_COL_MAX - hMcMasa->num_slots_delay_comp ) * l_ts ); // q_inp
lowpassCoef = L_shl( div_w( 1, (Word32) hMcMasa->ringBufferSize ), Q6 ); // Q.37(31+6)
@@ -2342,8 +2412,8 @@ static void computeLfeEnergy_fx(
IF( hMcMasa->separateChannelEnabled )
{
- Copy32( data_fx[lfeChannelIndex] + ( input_frame - hMcMasa->num_samples_delay_comp + hMcMasa->offset_comp ), &( hMcMasa->delay_buffer_lfe[0][0] ), sub( hMcMasa->num_samples_delay_comp, hMcMasa->offset_comp ) );
- Copy32( data_fx[separateChannelIndex] + ( input_frame - hMcMasa->num_samples_delay_comp + hMcMasa->offset_comp ), &( hMcMasa->delay_buffer_lfe[1][0] ), sub( hMcMasa->num_samples_delay_comp, hMcMasa->offset_comp ) );
+ Copy32( data_fx[lfeChannelIndex] + ( input_frame - hMcMasa->num_samples_delay_comp + hMcMasa->offset_comp ), &( hMcMasa->delay_buffer_lfe[0][0] ), sub( hMcMasa->num_samples_delay_comp, hMcMasa->offset_comp ) ); // q_in
+ Copy32( data_fx[separateChannelIndex] + ( input_frame - hMcMasa->num_samples_delay_comp + hMcMasa->offset_comp ), &( hMcMasa->delay_buffer_lfe[1][0] ), sub( hMcMasa->num_samples_delay_comp, hMcMasa->offset_comp ) ); // q_in
}
return;
diff --git a/lib_enc/ivas_mct_core_enc.c b/lib_enc/ivas_mct_core_enc.c
index db8ca015496e2fac9d6fba4059527925140ac78e..f5f179778178b46b5b42d2037eecd9d79b3c7b87 100644
--- a/lib_enc/ivas_mct_core_enc.c
+++ b/lib_enc/ivas_mct_core_enc.c
@@ -78,11 +78,11 @@ static void FindChannelRatio_fx(
IF( NE_32( sts[i]->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) )
{
// sum_nrg += nrg[i];
- sum_nrg = BASOP_Util_Add_Mant32Exp( sum_nrg, sum_e, nrg[i], nrg_e[i], &sum_e );
+ sum_nrg = BASOP_Util_Add_Mant32Exp( sum_nrg, sum_e, nrg[i], nrg_e[i], &sum_e ); // sum_e
}
}
// sum_nrg = 1.0f / max( sum_nrg, EPSILON );
- sum_nrg = BASOP_Util_Divide3232_Scale( ONE_IN_Q31, L_add_sat( sum_nrg, EPSILON_FX ), &inv_e );
+ sum_nrg = BASOP_Util_Divide3232_Scale( ONE_IN_Q31, L_add_sat( sum_nrg, EPSILON_FX ), &inv_e ); // inv_e
inv_e = add( inv_e, sub( 0, sum_e ) );
FOR( i = 0; i < nChannels; i++ )
@@ -137,7 +137,7 @@ static void AdjustChannelRatios_fx(
move32();
FOR( i = 0; i < nChannels; i++ )
{
- sum_ratio = L_add( sum_ratio, temp_brs[i] );
+ sum_ratio = L_add( sum_ratio, temp_brs[i] ); // Q0
}
FOR( i = 0; i < nChannels; i++ )
{
@@ -145,7 +145,7 @@ static void AdjustChannelRatios_fx(
// force_ch_bit_ratios[i] = min( BITRATE_MCT_RATIO_RANGE - 1, max( 1, (uint16_t) ( BITRATE_MCT_RATIO_RANGE * cur_ratio + 0.5f ) ) );
cur_ratio = BASOP_Util_Divide3232_Scale( temp_brs[i], sum_ratio, &cur_ratio_e );
- cur_ratio = shr_r( cur_ratio, sub( 11, cur_ratio_e ) );
+ cur_ratio = shr_r( cur_ratio, sub( 11, cur_ratio_e ) ); // Q11
force_ch_bit_ratios[i] = s_min( BITRATE_MCT_RATIO_RANGE - 1, s_max( 1, (UWord16) ( cur_ratio ) ) );
move16();
}
@@ -207,8 +207,8 @@ static void AdjustChannelRatios_fx(
// cur_ratio = chBitRatios[i] / sum_ratio;
// chBitRatios[i] = min( BITRATE_MCT_RATIO_RANGE - 1, max( 1, (uint16_t) ( BITRATE_MCT_RATIO_RANGE * cur_ratio + 0.5f ) ) );
- cur_ratio = div_s( chBitRatios[i], extract_l( sum_ratio ) );
- chBitRatios[i] = s_min( BITRATE_MCT_RATIO_RANGE - 1, s_max( 1, (UWord16) mult_r( BITRATE_MCT_RATIO_RANGE, cur_ratio ) ) );
+ cur_ratio = div_s( chBitRatios[i], extract_l( sum_ratio ) ); // Q15
+ chBitRatios[i] = s_min( BITRATE_MCT_RATIO_RANGE - 1, s_max( 1, (UWord16) mult_r( BITRATE_MCT_RATIO_RANGE, cur_ratio ) ) ); // Q0
move16();
}
@@ -237,12 +237,13 @@ void ivas_mct_core_enc_fx(
Word16 nCPE;
Word32 *orig_spectrum_fx[MCT_MAX_CHANNELS][2]; /* Pointers to MDCT output for a short block (L/R) */
Word32 powerSpec_fx[MCT_MAX_CHANNELS][L_FRAME48k];
+ Word16 exp_powerSpec[MCT_MAX_CHANNELS][N_MAX + L_MDCT_OVLP_MAX];
Word32 mdst_fx;
Word32 powerSpecMsInv_long_fx[MCT_MAX_CHANNELS][L_FRAME48k]; /* MS inv power spectrum, also inverse MDST spectrum */
Word32 *powerSpecMsInv_fx[MCT_MAX_CHANNELS][2];
Word32 *inv_mdst_spectrum_fx[MCT_MAX_CHANNELS][2];
Word32 *inv_spectrum_fx[MCT_MAX_CHANNELS][2];
- Word32 *mdst_spectrum_fx[MCT_MAX_CHANNELS][2] = { NULL };
+ Word32 *mdst_spectrum_fx[MCT_MAX_CHANNELS][2] = { { NULL } };
Word32 inv_spectrum_long_fx[MCT_MAX_CHANNELS][L_FRAME48k]; /* quantized MDCT spectrum, inv ms mask mdst spectrum, scratch for MS spectra in the MS decision */
Word16 total_side_bits;
Word16 chBitRatios[MCT_MAX_CHANNELS];
@@ -277,13 +278,15 @@ void ivas_mct_core_enc_fx(
{
set32_fx( powerSpecMsInv_long_fx[ch], 0, L_FRAME48k );
q_powSpec[ch] = 0;
+ move16();
+ set16_fx( exp_powerSpec[ch], 0, N_MAX + L_MDCT_OVLP_MAX );
}
#endif // MSAN_FIX
FOR( ch = 0; ch < nChannels; ch++ )
{
set32_fx( inv_spectrum_long_fx[ch], 0, L_FRAME48k );
- set32_fx( powerSpec_fx[ch], 0, L_FRAME48k );
- set32_fx( powerSpecMsInv_long_fx[ch], 0, L_FRAME48k );
+ set32_fx( powerSpec_fx[ch], 0, L_FRAME48k ); // tmp_q_powSpec
+ set32_fx( powerSpecMsInv_long_fx[ch], 0, L_FRAME48k ); // tmp_q_powSpecInv
inv_mdst_spectrum_fx[ch][0] = powerSpecMsInv_fx[ch][0] = powerSpecMsInv_long_fx[ch];
inv_mdst_spectrum_fx[ch][1] = powerSpecMsInv_fx[ch][1] = powerSpecMsInv_long_fx[ch] + N_TCX10_MAX;
@@ -310,7 +313,7 @@ void ivas_mct_core_enc_fx(
mdst_spectrum_fx[i][0] = hMCT->p_mdst_spectrum_long_fx[cpe_id][ch];
mdst_spectrum_fx[i][1] = hMCT->p_mdst_spectrum_long_fx[cpe_id][ch] + N_TCX10_MAX;
- orig_spectrum_fx[i][0] = hMCT->p_orig_spectrum_long_fx[cpe_id][ch];
+ orig_spectrum_fx[i][0] = hMCT->p_orig_spectrum_long_fx[cpe_id][ch]; // q_origSpec
orig_spectrum_fx[i][1] = hMCT->p_orig_spectrum_long_fx[cpe_id][ch] + N_TCX10_MAX;
sp_aud_decision0[i] = hCPE[cpe_id]->hCoreCoder[0]->sp_aud_decision0;
@@ -436,8 +439,8 @@ void ivas_mct_core_enc_fx(
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] );
tmp_s = sub( W_norm( W_tmp ), 1 );
W_tmp = W_shl( W_tmp, tmp_s );
- powerSpec_fx[ch][add( i, imult1616( n, L_subframeTCX ) )] = W_extract_h( W_tmp );
- tmp_q_powSpec[add( i, imult1616( n, L_subframeTCX ) )] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32
+ powerSpec_fx[ch][( i + ( n * L_subframeTCX ) )] = W_extract_h( W_tmp );
+ tmp_q_powSpec[( i + ( n * L_subframeTCX ) )] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32
move32();
move16();
@@ -496,13 +499,15 @@ void ivas_mct_core_enc_fx(
FOR( i = 1; i < L_subframeTCX - 1; i++ )
{
- mdst_fx = L_sub( L_shr( sts[ch]->hTcxEnc->spectrum_fx[n][i + 1], 1 ), L_shr( sts[ch]->hTcxEnc->spectrum_fx[n][i - 1], 1 ) ); /* An MDST estimate */
+ mdst_fx = L_sub( L_shr( sts[ch]->hTcxEnc->spectrum_fx[n][i + 1], 1 ), L_shr( sts[ch]->hTcxEnc->spectrum_fx[n][i - 1], 1 ) ); /* An MDST estimate, Q = q_spec - 1 */
- W_tmp = W_mac_32_32( W_mult_32_32( mdst_fx, mdst_fx ), L_shr( sts[ch]->hTcxEnc->spectrum_fx[n][i], 1 ), L_shr( sts[ch]->hTcxEnc->spectrum_fx[n][i], 1 ) );
+ W_tmp = W_mac_32_32( W_mult_32_32( mdst_fx, mdst_fx ), L_shr( sts[ch]->hTcxEnc->spectrum_fx[n][i], 1 ), L_shr( sts[ch]->hTcxEnc->spectrum_fx[n][i], 1 ) ); // Q = 2 * (q_spec - 1) + 1
tmp_s = W_norm( W_tmp );
W_tmp = W_shl( W_tmp, tmp_s );
- powerSpec_fx[ch][add( i, imult1616( n, L_subframeTCX ) )] = W_extract_h( W_tmp );
- tmp_q_powSpec[add( i, imult1616( n, L_subframeTCX ) )] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32
+
+ powerSpec_fx[ch][i + ( n * L_subframeTCX )] = W_extract_h( W_tmp );
+ tmp_q_powSpec[i + ( n * L_subframeTCX )] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 33 ); // Q = 2 * (q_spec - 1) + 1 + tmp_s - 32
+
move32();
move16();
}
@@ -510,8 +515,8 @@ void ivas_mct_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] );
tmp_s = sub( W_norm( W_tmp ), 1 );
W_tmp = W_shl( W_tmp, tmp_s );
- powerSpec_fx[ch][add( sub( L_subframeTCX, 1 ), imult1616( n, L_subframeTCX ) )] = W_extract_h( W_tmp );
- tmp_q_powSpec[add( sub( L_subframeTCX, 1 ), imult1616( n, L_subframeTCX ) )] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32
+ powerSpec_fx[ch][( ( L_subframeTCX - 1 ) + ( n * L_subframeTCX ) )] = W_extract_h( W_tmp );
+ tmp_q_powSpec[( ( L_subframeTCX - 1 ) + ( n * L_subframeTCX ) )] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32
move32();
move16();
}
@@ -543,7 +548,7 @@ void ivas_mct_core_enc_fx(
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] ) );
- powerSpec_fx[ch][add( i, imult1616( n, L_subframeTCX ) )] = L_shr( powerSpec_fx[ch][add( i, imult1616( n, L_subframeTCX ) )], sub( tmp_q_powSpec[i], q_powSpec[ch] ) );
+ powerSpec_fx[ch][( i + ( n * L_subframeTCX ) )] = L_shr( powerSpec_fx[ch][( i + ( n * L_subframeTCX ) )], sub( tmp_q_powSpec[i], q_powSpec[ch] ) );
move32();
move32();
}
@@ -636,8 +641,9 @@ void ivas_mct_core_enc_fx(
FOR( n = 0; n < nSubframes; n++ )
{
q_spectrum = sub( 31, st->hTcxEnc->spectrum_e[n] );
+ set16_fx( exp_powerSpec[ch], sub( Q31, q_powSpec[ch] ), N_MAX + L_MDCT_OVLP_MAX );
- ProcessIGF_ivas_fx( st, st->hTcxEnc->spectrum_fx[n], orig_spectrum_fx[ch][n], &q_spectrum, &powerSpec_fx[ch][n * L_subframeTCX], &q_powSpec[ch], st->core == TCX_20_CORE, n, sp_aud_decision0[ch], 0 );
+ ProcessIGF_ivas_fx( st, st->hTcxEnc->spectrum_fx[n], orig_spectrum_fx[ch][n], &q_spectrum, &powerSpec_fx[ch][n * L_subframeTCX], &exp_powerSpec[ch][n * L_subframeTCX], st->core == TCX_20_CORE, n, sp_aud_decision0[ch], 0 );
st->hIGFEnc->spec_be_igf_e = sub( 31, q_origSpec );
st->hTcxEnc->spectrum_e[n] = sub( 31, q_spectrum );
diff --git a/lib_enc/ivas_mct_enc.c b/lib_enc/ivas_mct_enc.c
index 98bf7a3a5ca0ba88e91ba6f3a09c81fe1a3f8910..8c194bed19057993fb0cd12f0e8f4419bf8bc201 100644
--- a/lib_enc/ivas_mct_enc.c
+++ b/lib_enc/ivas_mct_enc.c
@@ -58,7 +58,7 @@ static ivas_error ivas_mc_enc_reconfig_fx( Encoder_Struct *st_ivas, const Word16
* Set hMCT handle parameters
*-------------------------------------------------------------------*/
-static void set_mct_enc_params(
+static void set_mct_enc_params_fx(
MCT_ENC_HANDLE hMCT, /* i/o: MCT encoder structure */
const Word32 ivas_total_brate, /* i : IVAS total bitrate */
const IVAS_FORMAT ivas_format, /* i : IVAS_format */
@@ -79,7 +79,7 @@ static void set_mct_enc_params(
FOR( n = 0; n < MCT_MAX_CHANNELS; n++ )
{
- set32_fx( hMCT->lastxCorrMatrix_fx[n], 0, MCT_MAX_CHANNELS );
+ set32_fx( hMCT->lastxCorrMatrix_fx[n], 0, MCT_MAX_CHANNELS ); // hMCT->lastxCorrMatrix_e
}
hMCT->lastxCorrMatrix_e = 0;
move16();
@@ -129,7 +129,7 @@ static void map_input_to_cpe_channels_ivas_fx(
FOR( n = 0; n < LFE_CHANNEL - 1; n++ )
{
- pdata[i] = data[n];
+ pdata[i] = data[n]; // Qx
i = add( i, 1 );
}
test();
@@ -138,7 +138,7 @@ static void map_input_to_cpe_channels_ivas_fx(
{
FOR( n = LFE_CHANNEL + 1; n < nchan_transport; n++ )
{
- pdata[i] = data[n];
+ pdata[i] = data[n]; // Qx
i = add( i, 1 );
}
pdata[i] = data[LFE_CHANNEL - 1];
@@ -147,7 +147,7 @@ static void map_input_to_cpe_channels_ivas_fx(
{
FOR( ; n < nchan_transport; n++ )
{
- pdata[i] = data[n];
+ pdata[i] = data[n]; // Qx
i = add( i, 1 );
}
}
@@ -282,45 +282,54 @@ ivas_error ivas_mct_enc_fx(
}
}
-#ifdef IVAS_FLOAT_FIXED_CONVERSIONS // Float to Fixed, to be removed
Word16 q_spec = Q31;
Word16 q_origSpec = Q31;
- Word16 q_com = Q31, q_com_spec = Q31;
move16();
move16();
Word16 length, ch, nCPE;
- nCPE = ( hMCT->nchan_out_woLFE % 2 ) == 0 ? ( hMCT->nchan_out_woLFE / 2 ) : ( hMCT->nchan_out_woLFE / 2 ) + 1;
+ IF( ( hMCT->nchan_out_woLFE % 2 ) == 0 )
+ {
+ nCPE = idiv1616( hMCT->nchan_out_woLFE, 2 );
+ }
+ ELSE
+ {
+ nCPE = add( idiv1616( hMCT->nchan_out_woLFE, 2 ), 1 );
+ }
- for ( cpe_id = 0; cpe_id < nCPE; cpe_id++ )
+ FOR( cpe_id = 0; cpe_id < nCPE; cpe_id++ )
{
- for ( ch = 0; ch < CPE_CHANNELS; ch++ )
+ FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
{
- if ( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->mct_chan_mode == MCT_CHAN_MODE_IGNORE )
+ Word16 norm;
+ IF( EQ_32( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) )
+ {
+ CONTINUE;
+ }
+
+ // 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 ) )
{
- continue;
+ length = st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->L_frameTCX;
+ move16();
}
- 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 ( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->last_core == ACELP_CORE )
+ ELSE
{
- length += length / 4;
+ 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
}
- for ( Word16 k = 0; k <= ( ( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->core == TCX_20_CORE ) ? 1 : NB_DIV ) - 1; k++ )
+
+ IF( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->last_core == ACELP_CORE )
{
- 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 ) );
- }
+ length = add( length, idiv1616( length, 4 ) );
}
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++ )
{
@@ -332,7 +341,7 @@ ivas_error ivas_mct_enc_fx(
}
IF( hMCT->p_orig_spectrum_long_fx[cpe_id][ch] )
{
- Scale_sig32( hMCT->p_orig_spectrum_long_fx[cpe_id][ch], L_FRAME48k, sub( q_origSpec, hMCT->q_orig_spectrum_long_fx[cpe_id][ch] ) );
+ Scale_sig32( hMCT->p_orig_spectrum_long_fx[cpe_id][ch], L_FRAME48k, sub( q_origSpec, hMCT->q_orig_spectrum_long_fx[cpe_id][ch] ) ); // q_origSpec
hMCT->q_orig_spectrum_long_fx[cpe_id][ch] = q_origSpec;
move16();
}
@@ -340,67 +349,36 @@ 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( cpe_id = 0; cpe_id < nCPE; cpe_id++ )
{
- for ( ch = 0; ch < CPE_CHANNELS; ch++ )
+ 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 ( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->last_core == ACELP_CORE )
+ IF( EQ_16( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->core, TCX_20 ) )
{
- length += length / 4;
+ length = st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->L_frameTCX;
+ move16();
}
- for ( Word16 k = 0; k <= ( ( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->core == TCX_20_CORE ) ? 1 : NB_DIV ) - 1; k++ )
+ ELSE
{
- /*if ( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum[0] )
- {
- floatToFixed_arrL32( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum[k], st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_fx[k], q_spec, length );
- st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_e[0] = sub( Q31, q_spec );
- st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_e[1] = sub( Q31, q_spec );
- }*/
- 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] ) );
- hMCT->q_mdst_spectrum_long_fx[cpe_id][ch][k] = q_spec;
- move16();
- }
+ length = idiv1616( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->L_frameTCX, NB_DIV );
}
- }
- }
-#ifdef IVAS_FLOAT_FIXED_CONVERSIONS
- 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 ) )
+ IF( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->last_core == ACELP_CORE )
{
- i = add( i, 1 );
- CONTINUE;
+ length = add( length, idiv1616( length, 4 ) );
}
- i++;
- }
- }
-#endif
-#endif // 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( 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] )
+ {
+ 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] ) );
+ }
+ }
}
}
@@ -417,12 +395,27 @@ ivas_error ivas_mct_enc_fx(
{
length = idiv1616( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->L_frameTCX, NB_DIV );
}
- scale_sig32( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_long_fx, N_MAX, sub( q_spec, sub( 31, st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_long_e ) ) );
+ scale_sig32( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_long_fx, N_MAX, sub( q_spec, sub( 31, st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_long_e ) ) ); // q_spec
st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_e[0] = sub( 31, q_spec );
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();
+ }
+ }
}
}
@@ -456,10 +449,10 @@ ivas_error ivas_mct_enc_fx(
}
ELSE
{
- scale_sig32( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_fx[0], length, sub( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_e[0], e_spec ) );
- scale_sig32( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_fx[0] + length, sub( N_TCX10_MAX, length ), sub( sub( 31, q_spec ), e_spec ) );
- scale_sig32( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_fx[1], length, sub( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_e[0], e_spec ) );
- scale_sig32( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_fx[1] + length, sub( N_MAX - N_TCX10_MAX, length ), sub( sub( 31, q_spec ), e_spec ) );
+ scale_sig32( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_fx[0], length, sub( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_e[0], e_spec ) ); // st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_e[0]
+ scale_sig32( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_fx[0] + length, sub( N_TCX10_MAX, length ), sub( sub( 31, q_spec ), e_spec ) ); // 31 - q_spec
+ scale_sig32( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_fx[1], length, sub( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_e[0], e_spec ) ); // st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_e[0]
+ scale_sig32( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_fx[1] + length, sub( N_MAX - N_TCX10_MAX, length ), sub( sub( 31, q_spec ), e_spec ) ); // 31 - q_spec
st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_long_e = e_spec;
move16();
}
@@ -470,45 +463,21 @@ ivas_error ivas_mct_enc_fx(
}
}
-#ifdef IVAS_FLOAT_FIXED_CONVERSIONS
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 ( sts_tmp[ch]->last_core == ACELP_CORE )
- {
- length += length / 4;
- }
- }
-#endif
/* Spectrum quantization and coding */
FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
{
hCPE = st_ivas->hCPE[cpe_id];
- if ( cpe_id > 0 )
+ IF( cpe_id > 0 )
{
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;
}
-#ifdef IVAS_FLOAT_FIXED_CONVERSIONS
- Encoder_State /**st,*/ **sts;
- FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
- {
- sts = hCPE->hCoreCoder;
- st = sts[ch];
- }
-#endif
+
ivas_mdct_quant_coder_fx( hCPE, hMCT->tnsBits[cpe_id], hMCT->tnsSize[cpe_id], hMCT->p_param[cpe_id], 1 );
-#ifdef IVAS_FLOAT_FIXED_CONVERSIONS
- FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
- {
- sts = hCPE->hCoreCoder;
- st = sts[ch];
- }
-#endif
/* update input samples buffer (as done in ivas_cpe_enc() for other than MCT coding) */
FOR( n = 0; n < CPE_CHANNELS; n++ )
{
@@ -516,22 +485,8 @@ ivas_error ivas_mct_enc_fx(
hCPE->hCoreCoder[n]->q_old_inp = hCPE->hCoreCoder[n]->q_inp;
move16();
/* common encoder updates */
-#ifdef IVAS_FLOAT_FIXED_CONVERSIONS
- st = hCPE->hCoreCoder[n];
- IF( st->hTcxEnc != NULL )
- {
- st->hTcxEnc->exp_buf_speech_ltp = 31; /*Q0*/
- }
-#endif
-
- updt_enc_common_ivas_fx( st, Q_new_out[cpe_id][n] );
-#ifdef IVAS_FLOAT_FIXED_CONVERSIONS
- IF( st->hTcxEnc != NULL )
- {
- Scale_sig( st->hTcxEnc->buf_speech_ltp, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, st->hTcxEnc->exp_buf_speech_ltp );
- }
-#endif
+ updt_enc_common_ivas_fx( hCPE->hCoreCoder[n], Q_new_out[cpe_id][n] );
}
}
@@ -545,7 +500,7 @@ ivas_error ivas_mct_enc_fx(
* Create, allocate and initialize IVAS encoder MCT handle
*-------------------------------------------------------------------------*/
-ivas_error create_mct_enc(
+ivas_error create_mct_enc_fx(
Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */
)
{
@@ -677,7 +632,7 @@ ivas_error create_mct_enc(
* Initializations
*-----------------------------------------------------------------*/
- set_mct_enc_params( hMCT, ivas_total_brate, ivas_format, 1 );
+ set_mct_enc_params_fx( hMCT, ivas_total_brate, ivas_format, 1 );
st_ivas->hMCT = hMCT;
@@ -869,7 +824,7 @@ ivas_error mct_enc_reconfigure_fx(
* Initializations
*-----------------------------------------------------------------*/
- set_mct_enc_params( hMCT, ivas_total_brate, ivas_format, b_nchan_change );
+ set_mct_enc_params_fx( hMCT, ivas_total_brate, ivas_format, b_nchan_change );
return error;
}
@@ -881,7 +836,7 @@ ivas_error mct_enc_reconfigure_fx(
* Close MCT
*-------------------------------------------------------------------------*/
-void ivas_mct_enc_close(
+void ivas_mct_enc_close_fx(
MCT_ENC_HANDLE *hMCT /* i/o: MCT encoder structure */
)
{
@@ -1013,11 +968,11 @@ static ivas_error ivas_mc_enc_reconfig_fx(
IF( st_ivas->hLFE != NULL )
{
/* LFE handle */
- ivas_lfe_enc_close( &( st_ivas->hLFE ) );
+ ivas_lfe_enc_close_fx( &( st_ivas->hLFE ) );
}
/* create LFE handle */
- IF( NE_32( ( error = ivas_create_lfe_enc( &st_ivas->hLFE, st_ivas->hEncoderConfig->input_Fs ) ), IVAS_ERR_OK ) )
+ IF( NE_32( ( error = ivas_create_lfe_enc_fx( &st_ivas->hLFE, st_ivas->hEncoderConfig->input_Fs ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -1025,12 +980,12 @@ static ivas_error ivas_mc_enc_reconfig_fx(
/*De-allocate handles for other MC modes*/
ivas_param_mc_enc_close_fx( &( st_ivas->hParamMC ), st_ivas->hEncoderConfig->input_Fs );
- ivas_mc_paramupmix_enc_close( &( st_ivas->hMCParamUpmix ), st_ivas->hEncoderConfig->input_Fs );
+ ivas_mc_paramupmix_enc_close_fx( &( st_ivas->hMCParamUpmix ), st_ivas->hEncoderConfig->input_Fs );
/* De-allocate McMasa-related handles */
ivas_mcmasa_enc_close_fx( &( st_ivas->hMcMasa ), st_ivas->hEncoderConfig->input_Fs );
- ivas_masa_enc_close( &( st_ivas->hMasa ) );
+ ivas_masa_enc_close_fx( &( st_ivas->hMasa ) );
ivas_qmetadata_close_fx( &st_ivas->hQMetaData );
}
@@ -1049,11 +1004,11 @@ static ivas_error ivas_mc_enc_reconfig_fx(
IF( st_ivas->hLFE != NULL )
{
/* LFE handle */
- ivas_lfe_enc_close( &( st_ivas->hLFE ) );
+ ivas_lfe_enc_close_fx( &( st_ivas->hLFE ) );
}
/* create LFE handle */
- IF( NE_32( ( error = ivas_create_lfe_enc( &st_ivas->hLFE, st_ivas->hEncoderConfig->input_Fs ) ), IVAS_ERR_OK ) )
+ IF( NE_32( ( error = ivas_create_lfe_enc_fx( &st_ivas->hLFE, st_ivas->hEncoderConfig->input_Fs ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -1061,7 +1016,7 @@ static ivas_error ivas_mc_enc_reconfig_fx(
IF( NE_32( last_mc_mode, MC_MODE_PARAMUPMIX ) )
{
- IF( NE_32( ( error = ivas_mc_paramupmix_enc_open( st_ivas ) ), IVAS_ERR_OK ) )
+ IF( NE_32( ( error = ivas_mc_paramupmix_enc_open_fx( st_ivas ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -1072,7 +1027,7 @@ static ivas_error ivas_mc_enc_reconfig_fx(
/* De-allocate McMasa-related handles */
ivas_mcmasa_enc_close_fx( &( st_ivas->hMcMasa ), st_ivas->hEncoderConfig->input_Fs );
- ivas_masa_enc_close( &( st_ivas->hMasa ) );
+ ivas_masa_enc_close_fx( &( st_ivas->hMasa ) );
ivas_qmetadata_close_fx( &st_ivas->hQMetaData );
}
@@ -1098,17 +1053,17 @@ static ivas_error ivas_mc_enc_reconfig_fx(
IF( st_ivas->hMasa != NULL )
{
- ivas_masa_enc_close( &( st_ivas->hMasa ) );
+ ivas_masa_enc_close_fx( &( st_ivas->hMasa ) );
st_ivas->hMasa = NULL;
}
- ivas_mc_paramupmix_enc_close( &( st_ivas->hMCParamUpmix ), st_ivas->hEncoderConfig->input_Fs );
+ ivas_mc_paramupmix_enc_close_fx( &( st_ivas->hMCParamUpmix ), st_ivas->hEncoderConfig->input_Fs );
test();
IF( EQ_32( last_mc_mode, MC_MODE_PARAMUPMIX ) && st_ivas->hLFE != NULL )
{
/* LFE handle */
- ivas_lfe_enc_close( &( st_ivas->hLFE ) );
+ ivas_lfe_enc_close_fx( &( st_ivas->hLFE ) );
}
ivas_qmetadata_close_fx( &st_ivas->hQMetaData );
@@ -1117,14 +1072,14 @@ static ivas_error ivas_mc_enc_reconfig_fx(
test();
IF( EQ_32( last_mc_mode, MC_MODE_MCT ) && LE_16( st_ivas->nchan_transport, CPE_CHANNELS ) )
{
- ivas_mct_enc_close( &( st_ivas->hMCT ) );
+ ivas_mct_enc_close_fx( &( st_ivas->hMCT ) );
}
test();
IF( EQ_32( last_mc_mode, MC_MODE_MCT ) && st_ivas->hLFE != NULL )
{
/* LFE handle */
- ivas_lfe_enc_close( &( st_ivas->hLFE ) );
+ ivas_lfe_enc_close_fx( &( st_ivas->hLFE ) );
}
}
ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_MCMASA ) )
@@ -1138,7 +1093,7 @@ static ivas_error ivas_mc_enc_reconfig_fx(
return error;
}
- IF( NE_32( ( error = ivas_masa_enc_open( st_ivas ) ), IVAS_ERR_OK ) )
+ IF( NE_32( ( error = ivas_masa_enc_open_fx( st_ivas ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -1158,21 +1113,21 @@ static ivas_error ivas_mc_enc_reconfig_fx(
ivas_param_mc_enc_close_fx( &( st_ivas->hParamMC ), st_ivas->hEncoderConfig->input_Fs );
- ivas_mc_paramupmix_enc_close( &( st_ivas->hMCParamUpmix ), st_ivas->hEncoderConfig->input_Fs );
+ ivas_mc_paramupmix_enc_close_fx( &( st_ivas->hMCParamUpmix ), st_ivas->hEncoderConfig->input_Fs );
test();
IF( EQ_32( last_mc_mode, MC_MODE_PARAMUPMIX ) && st_ivas->hLFE != NULL )
{
/* LFE handle */
- ivas_lfe_enc_close( &( st_ivas->hLFE ) );
+ ivas_lfe_enc_close_fx( &( st_ivas->hLFE ) );
}
IF( EQ_32( last_mc_mode, MC_MODE_MCT ) )
{
/* LFE handle */
- ivas_lfe_enc_close( &( st_ivas->hLFE ) );
+ ivas_lfe_enc_close_fx( &( st_ivas->hLFE ) );
- ivas_mct_enc_close( &( st_ivas->hMCT ) );
+ ivas_mct_enc_close_fx( &( st_ivas->hMCT ) );
}
}
diff --git a/lib_enc/ivas_mct_enc_mct.c b/lib_enc/ivas_mct_enc_mct.c
index db6d8916cef61c38c87ca125eb505a6af97d9d55..18218aa257144fde5068e0a7799cf17a9672b152 100644
--- a/lib_enc/ivas_mct_enc_mct.c
+++ b/lib_enc/ivas_mct_enc_mct.c
@@ -97,7 +97,7 @@ void getChannelEnergies_fx(
move32();
FOR( n = 0; n < nSubframes; n++ )
{
- sum2 = sum2_32_exp_fx( st->hTcxEnc->spectrum_fx[n], L_subframe, &sum2_e, gb );
+ sum2 = sum2_32_exp_fx( st->hTcxEnc->spectrum_fx[n], L_subframe, &sum2_e, gb ); // 31 - sum2_e
nrg[ch] = BASOP_Util_Add_Mant32Exp( nrg[ch], nrg_e[ch], sum2, sum2_e, &nrg_e[ch] );
move32();
@@ -106,7 +106,7 @@ void getChannelEnergies_fx(
move16();
}
- nrg[ch] = Sqrt32( nrg[ch], &nrg_e[ch] );
+ nrg[ch] = Sqrt32( nrg[ch], &nrg_e[ch] ); // nrg_e
move32();
}
}
@@ -145,7 +145,7 @@ static void getNextBestCorrelation_fx(
IF( L_abs( xCorrMatrix[ch1][ch2] ) > 0 )
{
assert( i < ( MCT_MAX_CHANNELS * ( MCT_MAX_CHANNELS - 1 ) ) / 2 );
- tmp_corrVals[i] = L_abs( xCorrMatrix[ch1][ch2] );
+ tmp_corrVals[i] = L_abs( xCorrMatrix[ch1][ch2] ); // Qx
move32();
i = add( i, 1 );
}
@@ -158,7 +158,7 @@ static void getNextBestCorrelation_fx(
v_sort_ind_fixed( tmp_corrVals, tmp_org, add( tmp_idx, 1 ) );
/* get max, or 2nd max and so on depending on sortInd value */
- *max_corr = tmp_corrVals[sub( tmp_idx, sortInd )];
+ *max_corr = tmp_corrVals[( tmp_idx - sortInd )]; // Qx
move32();
/*find channel pair for this max_corr*/
@@ -170,7 +170,7 @@ static void getNextBestCorrelation_fx(
{
*_ch1 = ch1;
*_ch2 = ch2;
- *max_corr = xCorrMatrix[ch1][ch2]; /* assign to max_corr its actual value */
+ *max_corr = xCorrMatrix[ch1][ch2]; /* assign to max_corr its actual value */ // Qx
move16();
move16();
move32();
@@ -252,9 +252,9 @@ static void getCorrelationMatrix_fx(
FOR( ch2 = ch1 + 1; ch2 < nchan; ch2++ )
{
// tmp = sqrtf( xCorrMatrix[ch1][ch1] * xCorrMatrix[ch2][ch2] );
- W_tmp = W_mult0_32_32( xCorrMatrix[ch1][ch1], xCorrMatrix[ch2][ch2] );
+ W_tmp = W_mult0_32_32( xCorrMatrix[ch1][ch1], xCorrMatrix[ch2][ch2] ); // ( 31 - xCorrMatrix_exp[ch1][ch1] ) + ( 31 - xCorrMatrix_exp[ch2][ch2] )
s = W_norm( W_tmp );
- L_tmp = W_extract_h( W_shl( W_tmp, s ) );
+ L_tmp = W_extract_h( W_shl( W_tmp, s ) ); // s + ( 31 - xCorrMatrix_exp[ch1][ch1] ) + ( 31 - xCorrMatrix_exp[ch2][ch2] ) - 32
s = sub( add( s, 30 ), add( xCorrMatrix_exp[ch1][ch1], xCorrMatrix_exp[ch2][ch2] ) ); // s = s + ( 31 - xCorrMatrix_exp[ch1][ch1] ) + ( 31 - xCorrMatrix_exp[ch2][ch2] ) - 32;
s = sub( 31, s );
@@ -296,7 +296,7 @@ static void getCorrelationMatrix_fx(
{
FOR( ch2 = ch1 + 1; ch2 < nchan; ch2++ )
{
- xCorrMatrix[ch1][ch2] = L_shl_sat( xCorrMatrix[ch1][ch2], add( s, sub( xCorrMatrix_exp[ch1][ch2], *xCorrMatrix_e ) ) );
+ xCorrMatrix[ch1][ch2] = L_shl_sat( xCorrMatrix[ch1][ch2], add( s, sub( xCorrMatrix_exp[ch1][ch2], *xCorrMatrix_e ) ) ); // xCorrMatrix_e - s
move32();
}
}
@@ -334,7 +334,7 @@ static void getBestCorrelation_fx(
{
IF( LT_32( L_abs( *max_corr ), L_abs( xCorrMatrix[ch1][ch2] ) ) )
{
- *max_corr = xCorrMatrix[ch1][ch2];
+ *max_corr = xCorrMatrix[ch1][ch2]; // Qx
move32();
*_ch1 = ch1;
@@ -377,12 +377,12 @@ static void getBlockValues_fx(
/* map vectors to current block channels */
FOR( n = 0; n < 2; n++ )
{
- p_mdst_spectrum[0][n] = mdst_spectrum[ch1][n];
- p_mdst_spectrum[1][n] = mdst_spectrum[ch2][n];
- p_inv_spectrum[0][n] = inv_spectrum[ch1][n];
- p_inv_spectrum[1][n] = inv_spectrum[ch2][n];
- p_inv_mdst_spectrum[0][n] = inv_mdst_spectrum[ch1][n];
- p_inv_mdst_spectrum[1][n] = inv_mdst_spectrum[ch2][n];
+ p_mdst_spectrum[0][n] = mdst_spectrum[ch1][n]; // q_spec
+ p_mdst_spectrum[1][n] = mdst_spectrum[ch2][n]; // q_spec
+ p_inv_spectrum[0][n] = inv_spectrum[ch1][n]; // q_spec
+ p_inv_spectrum[1][n] = inv_spectrum[ch2][n]; // q_spec
+ p_inv_mdst_spectrum[0][n] = inv_mdst_spectrum[ch1][n]; // q_spec
+ p_inv_mdst_spectrum[1][n] = inv_mdst_spectrum[ch2][n]; // q_spec
}
p_st[0] = sts[ch1];
p_st[1] = sts[ch2];
@@ -604,8 +604,8 @@ static void getGlobalILD_fx(
FOR( k = 0; k < nSubframes; k++ )
{
- v_multc_fixed( sts[ch]->hTcxEnc->spectrum_fx[k], L_deposit_h( qratio ), sts[ch]->hTcxEnc->spectrum_fx[k], L_subframe );
- v_multc_fixed( mdst_spectrum[ch][k], L_deposit_h( qratio ), mdst_spectrum[ch][k], L_subframe );
+ v_multc_fixed( sts[ch]->hTcxEnc->spectrum_fx[k], L_deposit_h( qratio ), sts[ch]->hTcxEnc->spectrum_fx[k], L_subframe ); // sts[ch]->hTcxEnc->spectrum_e
+ v_multc_fixed( mdst_spectrum[ch][k], L_deposit_h( qratio ), mdst_spectrum[ch][k], L_subframe ); // sts[ch]->hTcxEnc->spectrum_e
}
}
}
@@ -623,9 +623,9 @@ static void getGlobalILD_fx(
void apply_MCT_enc_fx(
MCT_ENC_HANDLE hMCT, /* i/o: MCT encoder structure */
Encoder_State **sts, /* i/o: encoder state structure */
- Word32 *mdst_spectrum[MCT_MAX_CHANNELS][NB_DIV], /* i/o: MDST spectrum */
- Word32 *inv_spectrum[MCT_MAX_CHANNELS][NB_DIV], /* i/o: inverse spectrum */
- Word32 *inv_mdst_spectrum[MCT_MAX_CHANNELS][NB_DIV], /* i/o: inverse MDST spectrum */
+ Word32 *mdst_spectrum[MCT_MAX_CHANNELS][NB_DIV], /* i/o: MDST spectrum Qx*/
+ Word32 *inv_spectrum[MCT_MAX_CHANNELS][NB_DIV], /* i/o: inverse spectrum Qx*/
+ Word32 *inv_mdst_spectrum[MCT_MAX_CHANNELS][NB_DIV], /* i/o: inverse MDST spectrum Qx*/
const Word16 nchan /* i : number of channels */
)
{
@@ -734,7 +734,7 @@ void apply_MCT_enc_fx(
move16();
move16();
currBlockDataCnt = 0;
- WHILE( LT_16( currBlockDataCnt, hMCT->nchan_out_woLFE ) )
+ WHILE( ( currBlockDataCnt < hMCT->nchan_out_woLFE ) )
{
/* find best fitting channel pair: */
ch1 = -1;
@@ -959,7 +959,7 @@ void write_mct_bitstream_fx(
p_st[1] = sts[hBlock->ch2];
/*then business as usual for each block pair */
- write_stereo_to_bitstream( hMCT->hBlockData[pair]->hStereoMdct, p_st, hBlock->mask, 1, hBstr );
+ write_stereo_to_bitstream_fx( hMCT->hBlockData[pair]->hStereoMdct, p_st, hBlock->mask, 1, hBstr );
}
hMCT->nBitsMCT = sub( hBstr->nb_bits_tot, nbits_start );
@@ -997,6 +997,7 @@ void mctStereoIGF_enc_fx(
Encoder_State *st;
Word16 singleChEle[MCT_MAX_CHANNELS];
Word16 q_spectrum;
+ Word16 exp_powerSpec[MCT_MAX_CHANNELS][N_MAX + L_MDCT_OVLP_MAX];
L_subframeTCX = 0; /* to avoid compilation warning */
move16();
@@ -1033,7 +1034,7 @@ void mctStereoIGF_enc_fx(
sts[ch2]->hBstr->ind_list = sts[0]->hBstr->ind_list + sts[0]->hBstr->nb_ind_tot;
}
- p_powerSpec_fx[0] = powerSpec_fx[ch1];
+ p_powerSpec_fx[0] = powerSpec_fx[ch1]; // q_powerSpec
p_powerSpec_fx[1] = powerSpec_fx[ch2];
/* Band-wise M/S for MDST */
@@ -1047,9 +1048,9 @@ void mctStereoIGF_enc_fx(
FOR( n = 0; n < nSubframes; n++ )
{
- p_orig_spectrum_fx[0][n] = orig_spectrum_fx[ch1][n];
+ p_orig_spectrum_fx[0][n] = orig_spectrum_fx[ch1][n]; // q_origSpec
p_orig_spectrum_fx[1][n] = orig_spectrum_fx[ch2][n];
- p_powerSpecMsInv_fx[0][n] = powerSpecMsInv_fx[ch1][n];
+ p_powerSpecMsInv_fx[0][n] = powerSpecMsInv_fx[ch1][n]; // q_powerSpec
p_powerSpecMsInv_fx[1][n] = powerSpecMsInv_fx[ch2][n];
p_inv_spectrum_fx[0][n] = inv_spectrum_fx[ch1][n];
p_inv_spectrum_fx[1][n] = inv_spectrum_fx[ch2][n];
@@ -1085,14 +1086,9 @@ void mctStereoIGF_enc_fx(
move16();
}
- p_st[0]->hIGFEnc->spec_be_igf_e = sub( 31, q_origSpec );
- p_st[1]->hIGFEnc->spec_be_igf_e = sub( 31, q_origSpec );
- move16();
- move16();
-
ProcessStereoIGF_fx( hMCT->hBlockData[b]->hStereoMdct, p_st, hMCT->hBlockData[b]->mask,
- p_orig_spectrum_fx,
- p_powerSpec_fx, p_powerSpecMsInv_fx, p_inv_spectrum_fx, n, sp_aud_decision0[ch1], p_st[0]->total_brate );
+ p_orig_spectrum_fx, q_origSpec, q_origSpec,
+ p_powerSpec_fx, p_powerSpecMsInv_fx, p_inv_spectrum_fx, n, sp_aud_decision0[ch1], p_st[0]->total_brate, 1 );
}
ELSE
{
@@ -1109,7 +1105,8 @@ void mctStereoIGF_enc_fx(
q_spectrum = sub( 31, st->hTcxEnc->spectrum_e[n] );
- ProcessIGF_ivas_fx( st, st->hTcxEnc->spectrum_fx[n], orig_spectrum_fx[p_ch[ch]][n], &q_spectrum, &powerSpec_fx[p_ch[ch]][n * L_subframeTCX], &q_powerSpec[p_ch[ch]], st->core == TCX_20_CORE, n, sp_aud_decision0[ch], 0 );
+ set16_fx( exp_powerSpec[p_ch[ch]], sub( Q31, q_powerSpec[p_ch[ch]] ), N_MAX + L_MDCT_OVLP_MAX );
+ ProcessIGF_ivas_fx( st, st->hTcxEnc->spectrum_fx[n], orig_spectrum_fx[p_ch[ch]][n], &q_spectrum, &powerSpec_fx[p_ch[ch]][n * L_subframeTCX], &exp_powerSpec[p_ch[ch]][n * L_subframeTCX], st->core == TCX_20_CORE, n, sp_aud_decision0[ch], 0 );
st->hTcxEnc->spectrum_e[n] = sub( 31, q_spectrum );
move16();
@@ -1149,7 +1146,8 @@ void mctStereoIGF_enc_fx(
{
q_spectrum = sub( 31, st->hTcxEnc->spectrum_e[n] );
- ProcessIGF_ivas_fx( st, st->hTcxEnc->spectrum_fx[n], orig_spectrum_fx[ch][n], &q_spectrum, &powerSpec_fx[ch][n * L_subframeTCX], &q_powerSpec[ch], st->core == TCX_20_CORE, n, sp_aud_decision0[ch], 0 );
+ set16_fx( exp_powerSpec[ch], sub( Q31, q_powerSpec[ch] ), N_MAX + L_MDCT_OVLP_MAX );
+ ProcessIGF_ivas_fx( st, st->hTcxEnc->spectrum_fx[n], orig_spectrum_fx[ch][n], &q_spectrum, &powerSpec_fx[ch][n * L_subframeTCX], &exp_powerSpec[ch][n * L_subframeTCX], st->core == TCX_20_CORE, n, sp_aud_decision0[ch], 0 );
st->hTcxEnc->spectrum_e[n] = sub( 31, q_spectrum );
move16();
diff --git a/lib_enc/ivas_mdct_core_enc.c b/lib_enc/ivas_mdct_core_enc.c
index 1313ba4f33bfef47235d49d5bdfc84d7f25df203..734fbcf9d7c60f5f09369bd9d60015737296b1d6 100644
--- a/lib_enc/ivas_mdct_core_enc.c
+++ b/lib_enc/ivas_mdct_core_enc.c
@@ -81,15 +81,15 @@ static void enc_prm_pre_mdct_fx(
* Header
*--------------------------------------------------------------------------------*/
- writeTCXMode( st, hBstr, MCT_flag, &nbits_start );
+ writeTCXMode_fx( st, hBstr, MCT_flag, &nbits_start );
/* write last_core for core switching and error concealment */
push_next_indice( hBstr, st->last_core != ACELP_CORE, 1 );
- writeTCXWindowing( hBstr, st->hTcxCfg->tcx_curr_overlap_mode );
+ writeTCXWindowing_fx( hBstr, st->hTcxCfg->tcx_curr_overlap_mode );
IF( EQ_16( st->core, TCX_10_CORE ) )
{
- writeTCXWindowing( hBstr, st->hTcxCfg->tcx_last_overlap_mode );
+ writeTCXWindowing_fx( hBstr, st->hTcxCfg->tcx_last_overlap_mode );
}
IF( st->last_core != ACELP_CORE )
@@ -130,10 +130,10 @@ static void enc_prm_pre_mdct_fx(
*---------------------------------------------------------------*/
static Word16 kernel_switch_detect_fx(
- Word32 *sigR0, /* i/o: MDCT samples of the 1st (left) channel */
- Word32 *sigR1, /* i/o: MDCT samples of the 2nd (right) channel */
- Word32 *sigI0, /* i/o: MDST samples of the 1st (left) channel */
- Word32 *sigI1, /* i/o: MDST samples of the 2nd (right) channel */
+ Word32 *sigR0, /* i/o: MDCT samples of the 1st (left) channel q_in*/
+ Word32 *sigR1, /* i/o: MDCT samples of the 2nd (right) channel q_in*/
+ Word32 *sigI0, /* i/o: MDST samples of the 1st (left) channel q_in*/
+ Word32 *sigI1, /* i/o: MDST samples of the 2nd (right) channel q_in*/
const Word16 q_in, /* i : common Q for MDCT and MDST samples */
const Word16 nSamplesCore, /* i : number of core-coded samples below IGF */
const Word16 nSamplesMax, /* i : transform length (number of MCLT lines) */
@@ -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 );
@@ -547,14 +547,18 @@ static void kernel_switch_update_transforms_fx(
Copy_Scale_sig_32_16( windowedTimeSignal + 2, windowedTimeSignal_16 + 2, add( s, shr( add( leftOverlap, rightOverlap ), 1 ) ), -Q16 ); // *q_windowedTimeSignal - Q16
WindowSignal( hTcxCfg, shr( leftOverlap, 1 ), RECTANGULAR_OVERLAP, MIN_OVERLAP, &leftOverlap, &rightOverlap, windowedTimeSignal_16 + 2, &s, tcx5Win, 0, 1 ); // *q_windowedTimeSignal - Q16
Copy_Scale_sig_16_32_no_sat( tcx5Win, tcx5Win_32, add( s, shr( add( leftOverlap, rightOverlap ), 1 ) ), Q16 ); // *q_windowedTimeSignal
-
+#ifdef FIX_ISSUE_1157
+ q_shift = -Q8;
+#else
q_shift = -Q7;
+#endif
move16();
scale_sig32( tcx5Win_32, add( s /* L_subfr. */, shr( add( leftOverlap, rightOverlap ), 1 ) ), q_shift ); // *q_windowedTimeSignal + q_shift
kernel_switch_trafo_fx( tcx5Win_32, sigR, leftOverlap, sub( s /* L_subfr. */, shr( add( leftOverlap, rightOverlap ), 1 ) ), rightOverlap, kernelType ); // *q_windowedTimeSignal + q_shift
/* 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 ) );
@@ -576,14 +580,19 @@ 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
q_shift = -Q7;
+#endif
move16();
scale_sig32( windowedTimeSignal + 2, add( s /* L_subfr. */, shr( add( leftOverlap, rightOverlap ), 1 ) ), q_shift ); // *q_windowedTimeSignal + q_shift
kernel_switch_trafo_fx( windowedTimeSignal + 2, sigR, leftOverlap, sub( s /* L_subfr. */, shr( add( leftOverlap, rightOverlap ), 1 ) ), rightOverlap, kernelType ); // *q_windowedTimeSignal + q_shift
/* 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 ) );
@@ -651,26 +660,26 @@ static void applyStereoPreProcessingCplx(
{
IF( sign < 0 )
{
- dmxR1_fx = L_add( Mpy_32_32( valR1_fx, factDe_fx ), Mpy_32_32( valR2_fx, factIn_fx ) );
- dmxI1_fx = L_add( Mpy_32_32( valI1_fx, factDe_fx ), Mpy_32_32( valI2_fx, factIn_fx ) );
+ dmxR1_fx = L_add( Mpy_32_32( valR1_fx, factDe_fx ), Mpy_32_32( valR2_fx, factIn_fx ) ); // Q = q_com + Q22 - 31
+ dmxI1_fx = L_add( Mpy_32_32( valI1_fx, factDe_fx ), Mpy_32_32( valI2_fx, factIn_fx ) ); // Q = q_com + Q22 - 31
}
ELSE
{
- dmxR1_fx = L_sub( Mpy_32_32( valR2_fx, factIn_fx ), Mpy_32_32( valR1_fx, factDe_fx ) );
- dmxI1_fx = L_sub( Mpy_32_32( valI2_fx, factIn_fx ), Mpy_32_32( valI1_fx, factDe_fx ) );
+ dmxR1_fx = L_sub( Mpy_32_32( valR2_fx, factIn_fx ), Mpy_32_32( valR1_fx, factDe_fx ) ); // Q = q_com + Q22 - 31
+ dmxI1_fx = L_sub( Mpy_32_32( valI2_fx, factIn_fx ), Mpy_32_32( valI1_fx, factDe_fx ) ); // Q = q_com + Q22 - 31
}
}
ELSE
{
IF( sign < 0 )
{
- dmxR1_fx = L_add( Mpy_32_32( valR1_fx, factDe_fx ), Mpy_32_32( valR2_fx, factIn_fx ) );
- dmxI1_fx = L_add( Mpy_32_32( valI1_fx, factDe_fx ), Mpy_32_32( valI2_fx, factIn_fx ) );
+ dmxR1_fx = L_add( Mpy_32_32( valR1_fx, factDe_fx ), Mpy_32_32( valR2_fx, factIn_fx ) ); // Q = q_com + Q22 - 31
+ dmxI1_fx = L_add( Mpy_32_32( valI1_fx, factDe_fx ), Mpy_32_32( valI2_fx, factIn_fx ) ); // Q = q_com + Q22 - 31
}
ELSE
{
- dmxR1_fx = L_sub( Mpy_32_32( valR1_fx, factDe_fx ), Mpy_32_32( valR2_fx, factIn_fx ) );
- dmxI1_fx = L_sub( Mpy_32_32( valI1_fx, factDe_fx ), Mpy_32_32( valI2_fx, factIn_fx ) );
+ dmxR1_fx = L_sub( Mpy_32_32( valR1_fx, factDe_fx ), Mpy_32_32( valR2_fx, factIn_fx ) ); // Q = q_com + Q22 - 31
+ dmxI1_fx = L_sub( Mpy_32_32( valI1_fx, factDe_fx ), Mpy_32_32( valI2_fx, factIn_fx ) ); // Q = q_com + Q22 - 31
}
}
}
@@ -678,40 +687,40 @@ static void applyStereoPreProcessingCplx(
{
IF( sign < 0 )
{
- dmxI1_fx = L_sub( Mpy_32_32( valI1_fx, factDe_fx ), Mpy_32_32( valI2_fx, factIn_fx ) );
+ dmxI1_fx = L_sub( Mpy_32_32( valI1_fx, factDe_fx ), Mpy_32_32( valI2_fx, factIn_fx ) ); // Q = q_com + Q22 - 31
}
ELSE
{
- dmxI1_fx = L_add( Mpy_32_32( valI1_fx, factDe_fx ), Mpy_32_32( valI2_fx, factIn_fx ) );
+ dmxI1_fx = L_add( Mpy_32_32( valI1_fx, factDe_fx ), Mpy_32_32( valI2_fx, factIn_fx ) ); // Q = q_com + Q22 - 31
}
}
IF( LT_32( L_abs( dmxR2_fx ), L_shr( L_add( absR1_fx, absR2_fx ), 9 ) ) ) /* avoid destructive summations */
{
- IF( Mpy_32_32( absR1_fx, factIn_fx ) < Mpy_32_32( absR2_fx, factDe_fx ) )
+ IF( LT_32( Mpy_32_32( absR1_fx, factIn_fx ), Mpy_32_32( absR2_fx, factDe_fx ) ) )
{
IF( sign < 0 )
{
- dmxR2_fx = L_add( Mpy_32_32( valR2_fx, factDe_fx ), Mpy_32_32( valR1_fx, factIn_fx ) );
- dmxI2_fx = L_add( Mpy_32_32( valI2_fx, factDe_fx ), Mpy_32_32( valI1_fx, factIn_fx ) );
+ dmxR2_fx = L_add( Mpy_32_32( valR2_fx, factDe_fx ), Mpy_32_32( valR1_fx, factIn_fx ) ); // Q = q_com + Q22 - 31
+ dmxI2_fx = L_add( Mpy_32_32( valI2_fx, factDe_fx ), Mpy_32_32( valI1_fx, factIn_fx ) ); // Q = q_com + Q22 - 31
}
ELSE
{
- dmxR2_fx = L_sub( Mpy_32_32( valR1_fx, factIn_fx ), Mpy_32_32( valR2_fx, factDe_fx ) );
- dmxI2_fx = L_sub( Mpy_32_32( valI1_fx, factIn_fx ), Mpy_32_32( valI2_fx, factDe_fx ) );
+ dmxR2_fx = L_sub( Mpy_32_32( valR1_fx, factIn_fx ), Mpy_32_32( valR2_fx, factDe_fx ) ); // Q = q_com + Q22 - 31
+ dmxI2_fx = L_sub( Mpy_32_32( valI1_fx, factIn_fx ), Mpy_32_32( valI2_fx, factDe_fx ) ); // Q = q_com + Q22 - 31
}
}
ELSE
{
IF( sign < 0 )
{
- dmxR2_fx = L_add( Mpy_32_32( valR1_fx, factIn_fx ), Mpy_32_32( valR2_fx, factDe_fx ) );
- dmxI2_fx = L_add( Mpy_32_32( valI1_fx, factIn_fx ), Mpy_32_32( valI2_fx, factDe_fx ) );
+ dmxR2_fx = L_add( Mpy_32_32( valR1_fx, factIn_fx ), Mpy_32_32( valR2_fx, factDe_fx ) ); // Q = q_com + Q22 - 31
+ dmxI2_fx = L_add( Mpy_32_32( valI1_fx, factIn_fx ), Mpy_32_32( valI2_fx, factDe_fx ) ); // Q = q_com + Q22 - 31
}
ELSE
{
- dmxR2_fx = L_sub( Mpy_32_32( valR1_fx, factIn_fx ), Mpy_32_32( valR2_fx, factDe_fx ) );
- dmxI2_fx = L_sub( Mpy_32_32( valI1_fx, factIn_fx ), Mpy_32_32( valI2_fx, factDe_fx ) );
+ dmxR2_fx = L_sub( Mpy_32_32( valR1_fx, factIn_fx ), Mpy_32_32( valR2_fx, factDe_fx ) ); // Q = q_com + Q22 - 31
+ dmxI2_fx = L_sub( Mpy_32_32( valI1_fx, factIn_fx ), Mpy_32_32( valI2_fx, factDe_fx ) ); // Q = q_com + Q22 - 31
}
}
}
@@ -719,11 +728,11 @@ static void applyStereoPreProcessingCplx(
{
IF( sign < 0 )
{
- dmxI2_fx = L_sub( Mpy_32_32( valI2_fx, factDe_fx ), Mpy_32_32( valI1_fx, factIn_fx ) );
+ dmxI2_fx = L_sub( Mpy_32_32( valI2_fx, factDe_fx ), Mpy_32_32( valI1_fx, factIn_fx ) ); // Q = q_com + Q22 - 31
}
ELSE
{
- dmxI2_fx = L_add( Mpy_32_32( valI2_fx, factDe_fx ), Mpy_32_32( valI1_fx, factIn_fx ) );
+ dmxI2_fx = L_add( Mpy_32_32( valI2_fx, factDe_fx ), Mpy_32_32( valI1_fx, factIn_fx ) ); // Q = q_com + Q22 - 31
}
}
temp1 = norm_l( valR1_fx );
@@ -905,9 +914,13 @@ static uint16_t enc_ste_pre_mdct(
absMagnR_fx = Sqrt32( L_add( Mpy_32_32( sigR1_fx[s], sigR1_fx[s] ), Mpy_32_32( sigI1_fx[s], sigI1_fx[s] ) ), &absMagnR_e );
corr_fx = L_add( corr_fx, L_add( Mpy_32_32( sigR0_fx[s], sigR1_fx[s] ), Mpy_32_32( sigI0_fx[s], sigI1_fx[s] ) ) ); // q_com*2 - 31
- sumL_fx = L_add( sumL_fx, L_add( sigR0_fx[s], sigI0_fx[s] ) ); // q_com
- sumR_fx = L_add( sumR_fx, L_add( sigR1_fx[s], sigI1_fx[s] ) ); // q_com
-
+#ifdef FIX_ISSUE_1092
+ sumL_fx = L_add( sumL_fx, L_add( L_shr( sigR0_fx[s], 1 ), L_shr( sigI0_fx[s], 1 ) ) ); // q_com -1
+ sumR_fx = L_add( sumR_fx, L_add( L_shr( sigR1_fx[s], 1 ), L_shr( sigI1_fx[s], 1 ) ) ); // q_com - 1
+#else
+ sumL_fx = L_add( sumL_fx, L_add( sigR0_fx[s], sigI0_fx[s] ) ); // q_com
+ sumR_fx = L_add( sumR_fx, L_add( sigR1_fx[s], sigI1_fx[s] ) ); // q_com
+#endif
sumMagnL_fx = BASOP_Util_Add_Mant32Exp( sumMagnL_fx, sumMagnL_e, absMagnL_fx, absMagnL_e, &sumMagnL_e );
sumMagnR_fx = BASOP_Util_Add_Mant32Exp( sumMagnR_fx, sumMagnR_e, absMagnR_fx, absMagnR_e, &sumMagnR_e );
sumPrdLR_fx = BASOP_Util_Add_Mant32Exp( sumPrdLR_fx, sumPrdLR_e, Mpy_32_32( absMagnL_fx, absMagnR_fx ), add( absMagnL_e, absMagnR_e ), &sumPrdLR_e );
@@ -919,8 +932,11 @@ static uint16_t enc_ste_pre_mdct(
temp1 = L_shl( preproLen, x1 );
corr_fx = Mpy_32_32( corr_fx, temp1 );
x1 = sub( 62, add( shl( *q_com, 1 ), x1 ) );
+#ifdef FIX_ISSUE_1092
+ corr_fx = BASOP_Util_Add_Mant32Exp( corr_fx, x1, Mpy_32_32( sumL_fx, sumR_fx ), sub( 62, shl( sub( *q_com, 1 ), 1 ) ), &x1 );
+#else
corr_fx = BASOP_Util_Add_Mant32Exp( corr_fx, x1, Mpy_32_32( sumL_fx, sumR_fx ), sub( 62, shl( *q_com, 1 ) ), &x1 );
-
+#endif
IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( corr_fx, x1, -maxSqrValue_fx, 52 ), -1 ) )
{
@@ -955,7 +971,7 @@ static uint16_t enc_ste_pre_mdct(
sumR_fx = BASOP_Util_Add_Mant32Exp( sumPrdRR_fx, sumPrdRR_e, temp3, shl( sumMagnR_e, 1 ), &sumR_e );
test();
- IF( LE_32( corr_fx, 0 ) || LE_32( Mpy_32_32( sumL_fx, sumR_fx ), 0 ) )
+ IF( ( corr_fx <= 0 ) || ( Mpy_32_32( sumL_fx, sumR_fx ) <= 0 ) )
{
corr_fx = 0;
move32();
@@ -971,14 +987,14 @@ static uint16_t enc_ste_pre_mdct(
test();
test();
test();
- IF( ( GT_32( L_shl( corr_fx, sub( corr_e, s_max( corr_e, 0 ) ) ), L_shl( 1610612736, sub( 0, s_max( corr_e, 0 ) ) ) ) && corrIdxPrev == 0 ) || ( LE_32( L_shl( corr_fx, sub( corr_e, s_max( corr_e, 0 ) ) ), L_shl( 1610612736, sub( 0, s_max( corr_e, 0 ) ) ) ) && corrIdxPrev > 0 ) )
+ IF( ( GT_32( L_shl( corr_fx, sub( corr_e, s_max( corr_e, 0 ) ) ), L_shl( 1610612736 /*0.75.Q31*/, sub( 0, s_max( corr_e, 0 ) ) ) ) && corrIdxPrev == 0 ) || ( LE_32( L_shl( corr_fx, sub( corr_e, s_max( corr_e, 0 ) ) ), L_shl( 1610612736 /*0.75.Q31*/, sub( 0, s_max( corr_e, 0 ) ) ) ) && corrIdxPrev > 0 ) )
{
stepWeightI_fx = ONE_IN_Q22;
move32();
stepWeightD_fx = L_sub( ONE_IN_Q24, stepWeightI_fx );
}
test();
- IF( LE_32( L_shl( corr_fx, sub( corr_e, s_max( corr_e, 0 ) ) ), L_shl( 1610612736, sub( 0, s_max( corr_e, 0 ) ) ) ) && corrIdxPrev == 0 ) /* bypass all processing, just return */
+ IF( LE_32( L_shl( corr_fx, sub( corr_e, s_max( corr_e, 0 ) ) ), L_shl( 1610612736 /*0.75.Q31*/, sub( 0, s_max( corr_e, 0 ) ) ) ) && corrIdxPrev == 0 ) /* bypass all processing, just return */
{
return 0;
}
@@ -991,7 +1007,7 @@ static uint16_t enc_ste_pre_mdct(
xTalkI_fx = stepWeightI_fx; // Q22
xTalkD_fx = imult3216( stepWeightD_fx, sub( shl( fadeInLen, 1 ), 1 ) ); // Q22
- for ( s = sub( fadeInLen, 1 ); s > 0; s--, sigR0_fx++, sigR1_fx++, sigI0_fx++, sigI1_fx++, tmp++ )
+ FOR( s = ( fadeInLen - 1 ); s > 0; ( s--, sigR0_fx++, sigR1_fx++, sigI0_fx++, sigI1_fx++, tmp++ ) )
{
applyStereoPreProcessingCplx( sigR0_fx, sigR1_fx, sigI0_fx, sigI1_fx, *q_com, xTalkI_fx, xTalkD_fx, chanCorrSign_fx, &x1, &x2, &x3, &x4 );
mdct_exp1[tmp] = x1;
@@ -1006,7 +1022,7 @@ static uint16_t enc_ste_pre_mdct(
xTalkD_fx = L_sub( xTalkD_fx, stepWeightD_fx );
}
- for ( s = preproLen - fadeInLen; s > 0; s--, sigR0_fx++, sigR1_fx++, sigI0_fx++, sigI1_fx++, tmp++ )
+ FOR( s = preproLen - fadeInLen; s > 0; ( s--, sigR0_fx++, sigR1_fx++, sigI0_fx++, sigI1_fx++, tmp++ ) )
{
applyStereoPreProcessingCplx( sigR0_fx, sigR1_fx, sigI0_fx, sigI1_fx, *q_com, xTalkI_fx, xTalkD_fx, chanCorrSign_fx, &x1, &x2, &x3, &x4 );
mdct_exp1[tmp] = x1;
@@ -1021,7 +1037,7 @@ static uint16_t enc_ste_pre_mdct(
IF( LT_16( nSampProc, nSamplesMax ) ) /* fade-out of processing at start of IGF range */
{
- for ( s = s_min( fadeInLen, nSamplesMax - nSampProc ) - 1; s > 0; s--, sigR0_fx++, sigR1_fx++, sigI0_fx++, sigI1_fx++, tmp++ )
+ FOR( s = s_min( fadeInLen, nSamplesMax - nSampProc ) - 1; s > 0; ( s--, sigR0_fx++, sigR1_fx++, sigI0_fx++, sigI1_fx++, tmp++ ) )
{
xTalkI_fx = L_sub( xTalkI_fx, stepWeightI_fx );
xTalkD_fx = L_add( xTalkD_fx, stepWeightD_fx );
@@ -1054,18 +1070,18 @@ static uint16_t enc_ste_pre_mdct(
FOR( s = 0; s < s_max( nSamplesCore, nSamplesMax ); s++ )
{
- sigR0_fx[s] = L_shl( sigR0_fx[s], sub( mdct_exp1[s], shift_r ) );
+ sigR0_fx[s] = L_shl( sigR0_fx[s], sub( mdct_exp1[s], shift_r ) ); // mdct_exp1
move32();
- sigI0_fx[s] = L_shl( sigI0_fx[s], sub( mdst_exp1[s], shift_r ) );
+ sigI0_fx[s] = L_shl( sigI0_fx[s], sub( mdst_exp1[s], shift_r ) ); // mdct_exp1
move32();
- sigR1_fx[s] = L_shl( sigR1_fx[s], sub( mdct_exp2[s], shift_r ) );
+ sigR1_fx[s] = L_shl( sigR1_fx[s], sub( mdct_exp2[s], shift_r ) ); // mdct_exp2
move32();
- sigI1_fx[s] = L_shl( sigI1_fx[s], sub( mdst_exp2[s], shift_r ) );
+ sigI1_fx[s] = L_shl( sigI1_fx[s], sub( mdst_exp2[s], shift_r ) ); // mdct_exp2
move32();
}
*q_com = sub( 31, shift_r );
move16();
- IF( GT_32( L_shl( corr_fx, sub( corr_e, s_max( corr_e, 0 ) ) ), L_shl( 1610612736, sub( 0, s_max( corr_e, 0 ) ) ) ) )
+ IF( GT_32( L_shl( corr_fx, sub( corr_e, s_max( corr_e, 0 ) ) ), L_shl( 1610612736 /*0.75.Q31*/, sub( 0, s_max( corr_e, 0 ) ) ) ) )
{
ans = 1;
}
@@ -1119,12 +1135,12 @@ void enc_prm_igf_mdct(
void ivas_mdct_core_whitening_enc_fx(
CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
- Word16 new_samples_fx[CPE_CHANNELS][L_INP], /* i : new samples */
- Word16 old_wsp_fx[CPE_CHANNELS][L_WSP], /* i : 12.8kHz weighted speech (for LTP */
- Word16 pitch_buf_fx[CPE_CHANNELS][NB_SUBFR16k], /* o : floating pitch for each subframe */
- Word32 *mdst_spectrum_long_fx[CPE_CHANNELS], /* o : buffer for MDST spectrum */
+ Word16 new_samples_fx[CPE_CHANNELS][L_INP], /* i : new samples Q0*/
+ Word16 old_wsp_fx[CPE_CHANNELS][L_WSP], /* i : 12.8kHz weighted speech (for LTP Qx*/
+ Word16 pitch_buf_fx[CPE_CHANNELS][NB_SUBFR16k], /* o : floating pitch for each subframe Q6*/
+ Word32 *mdst_spectrum_long_fx[CPE_CHANNELS], /* o : buffer for MDST spectrum mdst_spectrum_e*/
Word16 tnsBits[CPE_CHANNELS][NB_DIV], /* o : buffer TNS bits */
- Word32 *orig_spectrum_long[CPE_CHANNELS], /* o : origingal spectrum w/o whitening */
+ Word32 *orig_spectrum_long[CPE_CHANNELS], /* o : origingal spectrum w/o whitening orig_spectrum_e*/
Word16 tnsSize[CPE_CHANNELS][NB_DIV], /* o : number of tns parameters put into prm */
Word16 p_param[CPE_CHANNELS][NB_DIV], /* o : pointer to the parameter table */
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
@@ -1171,7 +1187,7 @@ void ivas_mdct_core_whitening_enc_fx(
{
FOR( i = 0; i < NB_DIV; i++ )
{
- set32_fx( scf_fx[ch][i], 0, M );
+ set32_fx( scf_fx[ch][i], 0, M ); // scf_q_fx
set32_fx( scf_q_fx[ch][i], 0, M );
}
set16_fx( A_q_fx[ch][0], 0, M + 1 );
@@ -1242,7 +1258,7 @@ void ivas_mdct_core_whitening_enc_fx(
move32();
move32();
- sts[0]->hTcxEnc->tcxltp_norm_corr_past = sts[1]->hTcxEnc->tcxltp_norm_corr_past = extract_l( L_shr( L_add( sts[0]->hTcxEnc->tcxltp_norm_corr_past, sts[1]->hTcxEnc->tcxltp_norm_corr_past ), 1 ) );
+ sts[0]->hTcxEnc->tcxltp_norm_corr_past = sts[1]->hTcxEnc->tcxltp_norm_corr_past = extract_l( L_shr( L_add( sts[0]->hTcxEnc->tcxltp_norm_corr_past, sts[1]->hTcxEnc->tcxltp_norm_corr_past ), 1 ) ); // Q15
move16();
move16();
@@ -1393,10 +1409,10 @@ void ivas_mdct_core_whitening_enc_fx(
q_com = s_min( Q31, add( q_min, q_com ) );
- Scale_sig32( hTcxEnc0->spectrum_fx[n], shr( hTcxEnc0->L_frameTCX, shift ) /*hTcxEnc0->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, hTcxEnc0->spectrum_e[n] ) ) );
- Scale_sig32( hTcxEnc1->spectrum_fx[n], shr( hTcxEnc1->L_frameTCX, shift ) /*hTcxEnc1->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, hTcxEnc1->spectrum_e[n] ) ) );
- Scale_sig32( mdst_spectrum_fx[0][n], shr( hTcxEnc0->L_frameTCX, shift ) /*hTcxEnc0->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, mdst_spectrum_e[0][n] ) ) );
- Scale_sig32( mdst_spectrum_fx[1][n], shr( hTcxEnc1->L_frameTCX, shift ) /*hTcxEnc1->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, mdst_spectrum_e[1][n] ) ) );
+ Scale_sig32( hTcxEnc0->spectrum_fx[n], shr( hTcxEnc0->L_frameTCX, shift ) /*hTcxEnc0->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, hTcxEnc0->spectrum_e[n] ) ) ); // q_com
+ Scale_sig32( hTcxEnc1->spectrum_fx[n], shr( hTcxEnc1->L_frameTCX, shift ) /*hTcxEnc1->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, hTcxEnc1->spectrum_e[n] ) ) ); // q_com
+ Scale_sig32( mdst_spectrum_fx[0][n], shr( hTcxEnc0->L_frameTCX, shift ) /*hTcxEnc0->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, mdst_spectrum_e[0][n] ) ) ); // q_com
+ Scale_sig32( mdst_spectrum_fx[1][n], shr( hTcxEnc1->L_frameTCX, shift ) /*hTcxEnc1->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, mdst_spectrum_e[1][n] ) ) ); // q_com
const Word16 switchKernel = /* these 4 transform types can be applied: 0 = MDCT-IV, 1 = MDST-II, 2 = MDCT-II, 3 = MDST-IV */
kernel_switch_detect_fx( hTcxEnc0->spectrum_fx[n], hTcxEnc1->spectrum_fx[n], mdst_spectrum_fx[0][n], mdst_spectrum_fx[1][n], q_com, nSampCore / nSubframes,
@@ -1462,7 +1478,7 @@ void ivas_mdct_core_whitening_enc_fx(
hTcxEnc0->kernel_type[n] = 0;
move16();
- if ( hTcxEnc0->kernel_symmetry_past )
+ IF( hTcxEnc0->kernel_symmetry_past )
{
hTcxEnc0->kernel_type[n] = 3;
move16();
@@ -1470,7 +1486,7 @@ void ivas_mdct_core_whitening_enc_fx(
hTcxEnc1->kernel_type[n] = 0;
move16();
- if ( hTcxEnc1->kernel_symmetry_past )
+ IF( hTcxEnc1->kernel_symmetry_past )
{
hTcxEnc1->kernel_type[n] = 3;
move16();
@@ -1487,8 +1503,8 @@ void ivas_mdct_core_whitening_enc_fx(
q_com = s_min( L_norm_arr( hTcxEnc0->spectrum_fx[n], shr( hTcxEnc0->L_frameTCX, shift ) /*hTcxEnc0->L_frameTCX / nSubframes*/ ), L_norm_arr( mdst_spectrum_fx[0][n], shr( hTcxEnc0->L_frameTCX, shift ) /*hTcxEnc0->L_frameTCX / nSubframes*/ ) );
q_com = s_min( Q31, add( q_min, q_com ) );
- Scale_sig32( hTcxEnc0->spectrum_fx[n], shr( hTcxEnc0->L_frameTCX, shift ) /*hTcxEnc0->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, hTcxEnc0->spectrum_e[n] ) ) );
- Scale_sig32( mdst_spectrum_fx[0][n], shr( hTcxEnc0->L_frameTCX, shift ) /*hTcxEnc0->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, mdst_spectrum_e[0][n] ) ) );
+ Scale_sig32( hTcxEnc0->spectrum_fx[n], shr( hTcxEnc0->L_frameTCX, shift ) /*hTcxEnc0->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, hTcxEnc0->spectrum_e[n] ) ) ); // q_com
+ Scale_sig32( mdst_spectrum_fx[0][n], shr( hTcxEnc0->L_frameTCX, shift ) /*hTcxEnc0->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, mdst_spectrum_e[0][n] ) ) ); // q_com
speech = NULL;
if ( NE_16( n, 1 ) )
@@ -1508,8 +1524,8 @@ void ivas_mdct_core_whitening_enc_fx(
q_com = s_min( L_norm_arr( hTcxEnc1->spectrum_fx[n], shr( hTcxEnc1->L_frameTCX, shift ) /*hTcxEnc1->L_frameTCX / nSubframes*/ ), L_norm_arr( mdst_spectrum_fx[1][n], shr( hTcxEnc1->L_frameTCX, shift ) /*hTcxEnc1->L_frameTCX / nSubframes*/ ) );
q_com = s_min( Q31, add( q_min, q_com ) );
- Scale_sig32( hTcxEnc1->spectrum_fx[n], shr( hTcxEnc1->L_frameTCX, shift ) /*hTcxEnc1->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, hTcxEnc1->spectrum_e[n] ) ) );
- Scale_sig32( mdst_spectrum_fx[1][n], shr( hTcxEnc1->L_frameTCX, shift ) /*hTcxEnc1->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, mdst_spectrum_e[1][n] ) ) );
+ Scale_sig32( hTcxEnc1->spectrum_fx[n], shr( hTcxEnc1->L_frameTCX, shift ) /*hTcxEnc1->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, hTcxEnc1->spectrum_e[n] ) ) ); // q_com
+ Scale_sig32( mdst_spectrum_fx[1][n], shr( hTcxEnc1->L_frameTCX, shift ) /*hTcxEnc1->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, mdst_spectrum_e[1][n] ) ) ); // q_com
speech = NULL;
if ( NE_16( n, 1 ) )
@@ -1558,10 +1574,10 @@ void ivas_mdct_core_whitening_enc_fx(
q_com = sub( s_min( Q31, add( sub( Q31, exp_max ), exp_com ) ), 6 ); // 6 guarded bits
exp_com = sub( Q31, q_com );
- Scale_sig32( hTcxEnc0->spectrum_fx[n], shr( hTcxEnc0->L_frameTCX, shift ) /* hTcxEnc0->L_frameTCX/nSubframes */, sub( hTcxEnc0->spectrum_e[n], exp_com ) );
- Scale_sig32( hTcxEnc1->spectrum_fx[n], shr( hTcxEnc1->L_frameTCX, shift ) /* hTcxEnc1->L_frameTCX/nSubframes */, sub( hTcxEnc1->spectrum_e[n], exp_com ) );
- Scale_sig32( mdst_spectrum_fx[0][n], shr( hTcxEnc0->L_frameTCX, shift ) /* hTcxEnc0->L_frameTCX/nSubframes */, sub( mdst_spectrum_e[0][n], exp_com ) );
- Scale_sig32( mdst_spectrum_fx[1][n], shr( hTcxEnc1->L_frameTCX, shift ) /* hTcxEnc1->L_frameTCX/nSubframes */, sub( mdst_spectrum_e[1][n], exp_com ) );
+ Scale_sig32( hTcxEnc0->spectrum_fx[n], shr( hTcxEnc0->L_frameTCX, shift ) /* hTcxEnc0->L_frameTCX/nSubframes */, sub( hTcxEnc0->spectrum_e[n], exp_com ) ); // hTcxEnc0->spectrum_e
+ Scale_sig32( hTcxEnc1->spectrum_fx[n], shr( hTcxEnc1->L_frameTCX, shift ) /* hTcxEnc1->L_frameTCX/nSubframes */, sub( hTcxEnc1->spectrum_e[n], exp_com ) ); // hTcxEnc1->spectrum_e
+ Scale_sig32( mdst_spectrum_fx[0][n], shr( hTcxEnc0->L_frameTCX, shift ) /* hTcxEnc0->L_frameTCX/nSubframes */, sub( mdst_spectrum_e[0][n], exp_com ) ); // mdst_spectrum_e
+ Scale_sig32( mdst_spectrum_fx[1][n], shr( hTcxEnc1->L_frameTCX, shift ) /* hTcxEnc1->L_frameTCX/nSubframes */, sub( mdst_spectrum_e[1][n], exp_com ) ); // mdst_spectrum_e
Word16 q_com_orig = q_com;
move16();
@@ -1576,10 +1592,10 @@ void ivas_mdct_core_whitening_enc_fx(
IF( NE_16( q_com_orig, q_com ) )
{
Word16 scale = sub( q_com, q_com_orig );
- Scale_sig32( hTcxEnc0->spectrum_fx[n] + length, offset2, scale );
- Scale_sig32( hTcxEnc1->spectrum_fx[n] + length, offset2, scale );
- Scale_sig32( mdst_spectrum_fx[0][n] + length, offset2, scale );
- Scale_sig32( mdst_spectrum_fx[1][n] + length, offset2, scale );
+ Scale_sig32( hTcxEnc0->spectrum_fx[n] + length, offset2, scale ); // q_com
+ Scale_sig32( hTcxEnc1->spectrum_fx[n] + length, offset2, scale ); // q_com
+ Scale_sig32( mdst_spectrum_fx[0][n] + length, offset2, scale ); // q_com
+ Scale_sig32( mdst_spectrum_fx[1][n] + length, offset2, scale ); // q_com
}
exp_max = sub( Q31, q_com );
@@ -1592,10 +1608,10 @@ void ivas_mdct_core_whitening_enc_fx(
q_com = sub( s_min( Q31, add( q_com, exp_com ) ), 6 );
exp_com = sub( Q31, q_com );
- Scale_sig32( hTcxEnc0->spectrum_fx[n], shr( hTcxEnc0->L_frameTCX, shift ) /* hTcxEnc0->L_frameTCX/nSubframes */, sub( exp_max, exp_com ) );
- Scale_sig32( hTcxEnc1->spectrum_fx[n], shr( hTcxEnc1->L_frameTCX, shift ) /* hTcxEnc1->L_frameTCX/nSubframes */, sub( exp_max, exp_com ) );
- Scale_sig32( mdst_spectrum_fx[0][n], shr( hTcxEnc0->L_frameTCX, shift ) /* hTcxEnc0->L_frameTCX/nSubframes */, sub( exp_max, exp_com ) );
- Scale_sig32( mdst_spectrum_fx[1][n], shr( hTcxEnc1->L_frameTCX, shift ) /* hTcxEnc1->L_frameTCX/nSubframes */, sub( exp_max, exp_com ) );
+ Scale_sig32( hTcxEnc0->spectrum_fx[n], shr( hTcxEnc0->L_frameTCX, shift ) /* hTcxEnc0->L_frameTCX/nSubframes */, sub( exp_max, exp_com ) ); // exp_max
+ Scale_sig32( hTcxEnc1->spectrum_fx[n], shr( hTcxEnc1->L_frameTCX, shift ) /* hTcxEnc1->L_frameTCX/nSubframes */, sub( exp_max, exp_com ) ); // exp_max
+ Scale_sig32( mdst_spectrum_fx[0][n], shr( hTcxEnc0->L_frameTCX, shift ) /* hTcxEnc0->L_frameTCX/nSubframes */, sub( exp_max, exp_com ) ); // exp_max
+ Scale_sig32( mdst_spectrum_fx[1][n], shr( hTcxEnc1->L_frameTCX, shift ) /* hTcxEnc1->L_frameTCX/nSubframes */, sub( exp_max, exp_com ) ); // exp_max
q_com_orig = q_com;
move16();
@@ -1607,15 +1623,15 @@ void ivas_mdct_core_whitening_enc_fx(
IF( NE_16( q_com_orig, q_com ) )
{
Word16 scale = sub( q_com, q_com_orig );
- Scale_sig32( hTcxEnc0->spectrum_fx[n], tcx5SizeFB, scale );
- Scale_sig32( hTcxEnc1->spectrum_fx[n], tcx5SizeFB, scale );
- Scale_sig32( mdst_spectrum_fx[0][n], tcx5SizeFB, scale );
- Scale_sig32( mdst_spectrum_fx[1][n], tcx5SizeFB, scale );
-
- Scale_sig32( hTcxEnc0->spectrum_fx[n] + offset1, offset2, scale );
- Scale_sig32( hTcxEnc1->spectrum_fx[n] + offset1, offset2, scale );
- Scale_sig32( mdst_spectrum_fx[0][n] + offset1, offset2, scale );
- Scale_sig32( mdst_spectrum_fx[1][n] + offset1, offset2, scale );
+ Scale_sig32( hTcxEnc0->spectrum_fx[n], tcx5SizeFB, scale ); // q_com
+ Scale_sig32( hTcxEnc1->spectrum_fx[n], tcx5SizeFB, scale ); // q_com
+ 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
}
mdst_spectrum_e[0][n] = sub( Q31, q_com );
hTcxEnc0->spectrum_e[n] = sub( Q31, q_com );
@@ -1642,10 +1658,10 @@ void ivas_mdct_core_whitening_enc_fx(
q_com = sub( s_min( Q31, add( sub( Q31, exp_max ), exp_com ) ), 6 );
exp_com = sub( Q31, q_com );
- Scale_sig32( hTcxEnc0->spectrum_fx[n], shr( hTcxEnc0->L_frameTCX, shift ) /* hTcxEnc0->L_frameTCX/nSubframes */, sub( hTcxEnc0->spectrum_e[n], exp_com ) );
- Scale_sig32( hTcxEnc1->spectrum_fx[n], shr( hTcxEnc1->L_frameTCX, shift ) /* hTcxEnc1->L_frameTCX/nSubframes */, sub( hTcxEnc1->spectrum_e[n], exp_com ) );
- Scale_sig32( mdst_spectrum_fx[0][n], shr( hTcxEnc0->L_frameTCX, shift ) /* hTcxEnc0->L_frameTCX/nSubframes */, sub( mdst_spectrum_e[0][n], exp_com ) );
- Scale_sig32( mdst_spectrum_fx[1][n], shr( hTcxEnc1->L_frameTCX, shift ) /* hTcxEnc1->L_frameTCX/nSubframes */, sub( mdst_spectrum_e[1][n], exp_com ) );
+ Scale_sig32( hTcxEnc0->spectrum_fx[n], shr( hTcxEnc0->L_frameTCX, shift ) /* hTcxEnc0->L_frameTCX/nSubframes */, sub( hTcxEnc0->spectrum_e[n], exp_com ) ); // hTcxEnc0->spectrum_e
+ Scale_sig32( hTcxEnc1->spectrum_fx[n], shr( hTcxEnc1->L_frameTCX, shift ) /* hTcxEnc1->L_frameTCX/nSubframes */, sub( hTcxEnc1->spectrum_e[n], exp_com ) ); // hTcxEnc0->spectrum_e
+ Scale_sig32( mdst_spectrum_fx[0][n], shr( hTcxEnc0->L_frameTCX, shift ) /* hTcxEnc0->L_frameTCX/nSubframes */, sub( mdst_spectrum_e[0][n], exp_com ) ); // mdst_spectrum_e
+ Scale_sig32( mdst_spectrum_fx[1][n], shr( hTcxEnc1->L_frameTCX, shift ) /* hTcxEnc1->L_frameTCX/nSubframes */, sub( mdst_spectrum_e[1][n], exp_com ) ); // mdst_spectrum_e
Word16 q_com_orig = q_com;
move16();
@@ -1656,10 +1672,10 @@ void ivas_mdct_core_whitening_enc_fx(
IF( NE_16( q_com_orig, q_com ) )
{
Word16 scale = sub( q_com, q_com_orig );
- Scale_sig32( hTcxEnc0->spectrum_fx[n] + length, offset2, scale );
- Scale_sig32( hTcxEnc1->spectrum_fx[n] + length, offset2, scale );
- Scale_sig32( mdst_spectrum_fx[0][n] + length, offset2, scale );
- Scale_sig32( mdst_spectrum_fx[1][n] + length, offset2, scale );
+ Scale_sig32( hTcxEnc0->spectrum_fx[n] + length, offset2, scale ); // q_com
+ Scale_sig32( hTcxEnc1->spectrum_fx[n] + length, offset2, scale ); // q_com
+ Scale_sig32( mdst_spectrum_fx[0][n] + length, offset2, scale ); // q_com
+ Scale_sig32( mdst_spectrum_fx[1][n] + length, offset2, scale ); // q_com
}
exp_com = sub( Q31, q_com );
mdst_spectrum_e[0][n] = exp_com;
@@ -1734,8 +1750,8 @@ void ivas_mdct_core_whitening_enc_fx(
q_com = s_min( Q31, add( q_min, q_com ) );
- Scale_sig32( hTcxEncCh->spectrum_fx[n], shr( hTcxEncCh->L_frameTCX, shift ) /*hTcxEncCh->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, hTcxEncCh->spectrum_e[n] ) ) );
- Scale_sig32( mdst_spectrum_fx[ch][n], shr( hTcxEncCh->L_frameTCX, shift ) /*hTcxEncCh->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, mdst_spectrum_e[ch][n] ) ) );
+ Scale_sig32( hTcxEncCh->spectrum_fx[n], shr( hTcxEncCh->L_frameTCX, shift ) /*hTcxEncCh->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, hTcxEncCh->spectrum_e[n] ) ) ); // q_com
+ Scale_sig32( mdst_spectrum_fx[ch][n], shr( hTcxEncCh->L_frameTCX, shift ) /*hTcxEncCh->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, mdst_spectrum_e[ch][n] ) ) ); // q_com
speech = hTcxEncCh->speech_TCX;
if ( n != 0 )
@@ -1797,7 +1813,7 @@ void ivas_mdct_core_whitening_enc_fx(
}
FOR( n = 0; n < nSubframes; n++ )
{
- Scale_sig32( hTcxEnc->spectrum_fx[n], shr( hTcxEnc->L_frameTCX, shift ) /*hTcxEnc->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, hTcxEnc->spectrum_e[n] ) ) );
+ Scale_sig32( hTcxEnc->spectrum_fx[n], shr( hTcxEnc->L_frameTCX, shift ) /*hTcxEnc->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, hTcxEnc->spectrum_e[n] ) ) ); // q_com
hTcxEnc->spectrum_e[n] = sub( Q31, q_com );
move16();
}
@@ -1855,8 +1871,8 @@ void ivas_mdct_core_whitening_enc_fx(
}
FOR( n = 0; n < nSubframes; n++ )
{
- Scale_sig32( hTcxEnc->spectrum_fx[n], shr( hTcxEnc->L_frameTCX, shift ) /*hTcxEnc->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, hTcxEnc->spectrum_e[n] ) ) );
- Scale_sig32( mdst_spectrum_fx[ch][n], shr( hTcxEnc->L_frameTCX, shift ) /*hTcxEnc->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, mdst_spectrum_e[ch][n] ) ) );
+ Scale_sig32( hTcxEnc->spectrum_fx[n], shr( hTcxEnc->L_frameTCX, shift ) /*hTcxEnc->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, hTcxEnc->spectrum_e[n] ) ) ); // q_com
+ Scale_sig32( mdst_spectrum_fx[ch][n], shr( hTcxEnc->L_frameTCX, shift ) /*hTcxEnc->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, mdst_spectrum_e[ch][n] ) ) ); // q_com
hTcxEnc->spectrum_e[n] = sub( Q31, q_com );
move16();
mdst_spectrum_e[ch][n] = sub( Q31, q_com );
@@ -2175,7 +2191,7 @@ void ivas_mdct_core_whitening_enc_fx(
FOR( n = 0; n < nSubframes; n++ )
{
- Scale_sig32( hTcxEnc->spectrum_fx[n], shr( hTcxEnc->L_frameTCX, shift ) /*hTcxEnc->L_frameTCX / nSubframes*/, sub( q_com, sub( 31, hTcxEnc->spectrum_e[n] ) ) );
+ Scale_sig32( hTcxEnc->spectrum_fx[n], shr( hTcxEnc->L_frameTCX, shift ) /*hTcxEnc->L_frameTCX / nSubframes*/, sub( q_com, sub( 31, hTcxEnc->spectrum_e[n] ) ) ); // q_com
hTcxEnc->spectrum_e[n] = sub( 31, q_com );
move16();
}
@@ -2463,7 +2479,7 @@ void ivas_mdct_core_whitening_enc_fx(
}
ELSE
{
- set16_fx( pitch_buf_fx[ch], L_SUBFR << Q6, NB_SUBFR16k );
+ set16_fx( pitch_buf_fx[ch], L_SUBFR << Q6, NB_SUBFR16k ); // Q6
}
}
@@ -2493,11 +2509,11 @@ void ivas_mdct_quant_coder_fx(
Word16 nbits_start, total_nbbits;
Word16 fac_ns_fx[CPE_CHANNELS][NB_DIV]; /* noise filling level */
- Word32 ener_fx[CPE_CHANNELS][NB_DIV]; /* energy of the quantized spectrum */
- Word16 gain_tcx_fx[CPE_CHANNELS][NB_DIV]; /* global gain */
+ Word32 ener_fx[CPE_CHANNELS][NB_DIV]; /* energy of the quantized spectrum ener_e*/
+ Word16 gain_tcx_fx[CPE_CHANNELS][NB_DIV]; /* global gain gain_tcx_e*/
Word16 gain_tcx_e[CPE_CHANNELS][NB_DIV];
Word32 quantized_spectrum_long_fx[CPE_CHANNELS][N_MAX]; /* quantized MDCT spectrum, inv ms mask mdst spectrum, scratch for MS spectra in the MS decision */
- Word32 *quantized_spectrum_fx[CPE_CHANNELS][NB_DIV];
+ Word32 *quantized_spectrum_fx[CPE_CHANNELS][NB_DIV]; // quantized_spectrum_e
Word16 quantized_spectrum_e[CPE_CHANNELS][NB_DIV];
Word16 ener_e[CPE_CHANNELS][NB_DIV];
@@ -2605,11 +2621,11 @@ void ivas_mdct_quant_coder_fx(
FOR( n = 0; n < nSubframes; n++ )
{
temp_scale = getScaleFactor32( quantized_spectrum_fx[ch][n], L_spec[ch][n] );
- scale_sig32( quantized_spectrum_fx[ch][n], L_spec[ch][n], temp_scale );
+ scale_sig32( quantized_spectrum_fx[ch][n], L_spec[ch][n], temp_scale ); // quantized_spectrum_e
quantized_spectrum_e[ch][n] = sub( quantized_spectrum_e[ch][n], temp_scale );
min_shift = s_max( min_shift, quantized_spectrum_e[ch][n] );
temp_scale = getScaleFactor32( st->hTcxEnc->spectrum_fx[n], L_spec[ch][n] );
- scale_sig32( st->hTcxEnc->spectrum_fx[n], L_spec[ch][n], temp_scale );
+ scale_sig32( st->hTcxEnc->spectrum_fx[n], L_spec[ch][n], temp_scale ); // st->hTcxEnc->spectrum_e
st->hTcxEnc->spectrum_e[n] = sub( st->hTcxEnc->spectrum_e[n], temp_scale );
min_shift = s_max( min_shift, st->hTcxEnc->spectrum_e[n] );
}
@@ -2718,7 +2734,8 @@ void ivas_mdct_quant_coder_fx(
writeTCXparam_fx( st, st->hBstr, NULL, param_core[ch], 0, 0, 0, NULL, p_param[ch], target_bitsTCX10[ch], 1 );
- total_nbbits = st->hBstr->nb_bits_tot - nbits_start - nSubframes * ( NBITS_TCX_GAIN + NOISE_FILL_RANGES * NBITS_NOISE_FILL_LEVEL );
+ total_nbbits = sub( sub( st->hBstr->nb_bits_tot, nbits_start ), imult1616( nSubframes, ( NBITS_TCX_GAIN + NOISE_FILL_RANGES * NBITS_NOISE_FILL_LEVEL ) ) );
+ // total_nbbits = st->hBstr->nb_bits_tot - nbits_start - nSubframes * ( NBITS_TCX_GAIN + NOISE_FILL_RANGES * NBITS_NOISE_FILL_LEVEL );
assert( st->bits_frame_channel == total_nbbits );
}
diff --git a/lib_enc/ivas_omasa_enc.c b/lib_enc/ivas_omasa_enc.c
index bee6fa22ce0744420084afdecec5ff49952143b5..a9ebf8ec3bc278e472a912fd03cf1d92ba509ab1 100644
--- a/lib_enc/ivas_omasa_enc.c
+++ b/lib_enc/ivas_omasa_enc.c
@@ -291,7 +291,7 @@ ivas_error ivas_omasa_enc_config_fx(
k = 0;
move16();
- WHILE( LT_16( k, SIZE_IVAS_BRATE_TBL ) && NE_32( ivas_total_brate, ivas_brate_tbl[k] ) )
+ WHILE( ( k < SIZE_IVAS_BRATE_TBL ) && ( ivas_total_brate != ivas_brate_tbl[k] ) )
{
test();
k = add( k, 1 );
@@ -458,7 +458,7 @@ void ivas_omasa_set_config_fx(
}
}
- Copy( DirAC_block_grouping, hOMasa->block_grouping, MAX_PARAM_SPATIAL_SUBFRAMES + 1 );
+ Copy( DirAC_block_grouping, hOMasa->block_grouping, MAX_PARAM_SPATIAL_SUBFRAMES + 1 ); // Q0
IF( EQ_16( hOMasa->nSubframes, 1 ) )
{
hOMasa->block_grouping[1] = hOMasa->block_grouping[MAX_PARAM_SPATIAL_SUBFRAMES];
@@ -478,7 +478,7 @@ void ivas_omasa_enc_fx(
OMASA_ENC_HANDLE hOMasa, /* i/o: OMASA encoder handle */
MASA_ENCODER_HANDLE hMasa, /* i/o: MASA encoder handle */
ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handle */
- Word32 *data_in[], /* i/o: Input / transport audio signals */
+ Word32 *data_in[], /* i/o: Input / transport audio signals q_data*/
Word16 q_data, /* i : Q0 Stores the q for data_in */
const Word16 input_frame, /* i : Input frame size */
const Word16 nchan_transport, /* i : Number of transport channels */
@@ -756,8 +756,8 @@ void ivas_omasa_enc_fx(
/* Move the ISM metadata to the first entry for encoding in the MASA_ONE_OBJ mode */
IF( EQ_16( ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) )
{
- hIsmMeta[0]->azimuth_fx = hIsmMeta[*idx_separated_object]->azimuth_fx;
- hIsmMeta[0]->elevation_fx = hIsmMeta[*idx_separated_object]->elevation_fx;
+ hIsmMeta[0]->azimuth_fx = hIsmMeta[*idx_separated_object]->azimuth_fx; // Q22
+ hIsmMeta[0]->elevation_fx = hIsmMeta[*idx_separated_object]->elevation_fx; // Q22
move32();
move32();
}
@@ -815,6 +815,7 @@ void ivas_set_ism_importance_interformat_fx(
}
ctype = hSCE[ch]->hCoreCoder[0]->coder_type_raw;
+ move16();
st->low_rate_mode = 0;
move16();
@@ -920,7 +921,7 @@ void ivas_set_surplus_brate_enc(
Word16 ivas_omasa_ener_brate_fx(
const Word16 nchan_ism, /* i : number of ISMs */
const Word32 ivas_total_brate, /* i : IVAS total bitrate */
- Word32 *data_f[], /* i : Input / transport audio signals */
+ Word32 *data_f[], /* i : Input / transport audio signals data_e*/
const Word16 input_frame, /* i : Input frame size */
Word16 data_e /*i:exponent for data_f */
)
@@ -973,7 +974,7 @@ Word16 ivas_omasa_ener_brate_fx(
energy_ism = Mpy_32_16_1( energy_ism, temp );
IF( energy_ism_e < 0 )
{
- energy_ism = L_shl( energy_ism, energy_ism_e );
+ energy_ism = L_shl( energy_ism, energy_ism_e ); // Q31
energy_ism_e = 0;
move16();
}
@@ -1115,7 +1116,12 @@ static void ivas_omasa_param_est_enc_fx(
{
q = q_data;
move16();
- cldfbAnalysis_ts_fx_fixed_q( &( data[i][l_ts * ts] ), Chnl_RealBuffer_fx[i], Chnl_ImagBuffer_fx[i], l_ts, hOMasa->cldfbAnaEnc[i], &q ); /*q_data-5*/
+#if 0
+ scale_sig32( hOMasa->cldfbAnaEnc[i]->cldfb_state_fx, hOMasa->cldfbAnaEnc[i]->cldfb_state_length, sub( q, hOMasa->cldfbAnaEnc[i]->Q_cldfb_state ) );
+ hOMasa->cldfbAnaEnc[i]->Q_cldfb_state = q;
+ move16();
+#endif
+ cldfbAnalysis_ts_fx_var_q( &( data[i][l_ts * ts] ), Chnl_RealBuffer_fx[i], Chnl_ImagBuffer_fx[i], l_ts, hOMasa->cldfbAnaEnc[i], &q ); /*q_data-5*/
norm_buff = s_min( norm_buff, L_norm_arr( Chnl_RealBuffer_fx[i], 60 ) );
norm_buff = s_min( norm_buff, L_norm_arr( Chnl_ImagBuffer_fx[i], 60 ) );
}
@@ -1197,7 +1203,12 @@ static void ivas_omasa_param_est_enc_fx(
computeIntensityVector_enc_fx( hOMasa->band_grouping, Foa_RealBuffer_fx, Foa_ImagBuffer_fx, num_freq_bands, intensity_real_fx, guard_bits );
intensity_real_e = sub( add( 62, guard_bits ), shl( q, 1 ) );
- computeDirectionVectors_fixed( intensity_real_fx[0], intensity_real_fx[1], intensity_real_fx[2], 0, num_freq_bands, direction_vector_fx[0], direction_vector_fx[1], direction_vector_fx[2], intensity_real_e );
+ computeDirectionVectors_fixed( intensity_real_fx[0], intensity_real_fx[1], intensity_real_fx[2], 0, num_freq_bands, direction_vector_fx[0], direction_vector_fx[1], direction_vector_fx[2], intensity_real_e
+#ifdef NONBE_IMPROVE_DIRAC_INTENSITY_PREC
+ ,
+ NULL
+#endif
+ );
/* Power estimation for diffuseness */
diff --git a/lib_enc/ivas_osba_enc.c b/lib_enc/ivas_osba_enc.c
index f018f250a9f7e980b6db552c8a5b639278879213..9d7c92dd092af32dd24a5726fb402d117eb5b317 100644
--- a/lib_enc/ivas_osba_enc.c
+++ b/lib_enc/ivas_osba_enc.c
@@ -63,9 +63,9 @@ static void ivas_osba_render_ism_to_sba_fx(
* Merge SBA transport channels
*-------------------------------------------------------------------*/
static void ivas_merge_sba_transports_fx(
- Word32 data_in_f1[][L_FRAME48k],
- Word32 *data_in_f2[],
- Word32 *data_out_f[],
+ Word32 data_in_f1[][L_FRAME48k], // Q_f1
+ Word32 *data_in_f2[], // Q_f2
+ Word32 *data_out_f[], // Q_out
const Word16 input_frame,
const Word16 sba_analysis_order,
Word16 Q_f1,
@@ -133,10 +133,10 @@ ivas_error ivas_osba_enc_open_fx(
tmp32 = L_shr( tmp32, sub( 15, tmp_e ) );
input_frame = extract_l( tmp32 );
- for ( i = 0; i < input_frame; i++ )
+ FOR( i = 0; i < input_frame; i++ )
{
tmp32 = L_deposit_h( BASOP_Util_Divide1616_Scale( i, input_frame, &tmp_e ) );
- hOSba->interpolator_fx[i] = L_shl( tmp32, tmp_e );
+ hOSba->interpolator_fx[i] = L_shl( tmp32, tmp_e ); // Q31
move32();
}
st_ivas->hOSba = hOSba;
@@ -408,7 +408,7 @@ ivas_error ivas_osba_enc_reconfig(
void ivas_osba_enc_fx(
OSBA_ENC_HANDLE hOSba, /* i/o: OSBA encoder handle */
ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handle */
- Word32 *data_in_fx[], /* i/o: Input / transport audio signals */
+ Word32 *data_in_fx[], /* i/o: Input / transport audio signals q_data*/
const Word16 input_frame, /* i : Input frame size */
const Word16 nchan_ism, /* i : Number of objects for parameter analysis */
const ISM_MODE ism_mode, /* i : ISM mode */
@@ -427,7 +427,7 @@ void ivas_osba_enc_fx(
/*keep the delay buffer up to date*/
FOR( n = 0; n < nchan_ism; n++ )
{
- MVR2R_WORD32( &data_in_fx[n][input_frame - delay_s], hOSba->input_data_mem_fx[n], delay_s );
+ MVR2R_WORD32( &data_in_fx[n][input_frame - delay_s], hOSba->input_data_mem_fx[n], delay_s ); // Q_data
}
/* Convert ISM to SBA */
@@ -450,8 +450,8 @@ void ivas_osba_enc_fx(
{
delay_signal_fx( data_in_fx[n], input_frame, hOSba->input_data_mem_fx[n], delay_s );
- azimuth_fx = extract_l( L_shr( L_add( hIsmMeta[n]->azimuth_fx, 2097152 ), Q22 ) );
- elevation_fx = extract_l( L_shr( L_add( hIsmMeta[n]->elevation_fx, 2097152 ), Q22 ) );
+ azimuth_fx = extract_l( L_shr( L_add( hIsmMeta[n]->azimuth_fx, 2097152 /*0.5.Q22*/ ), Q22 ) ); // Q0
+ elevation_fx = extract_l( L_shr( L_add( hIsmMeta[n]->elevation_fx, 2097152 /*0.5.Q22*/ ), Q22 ) ); // Q0
ivas_dirac_dec_get_response_fx( azimuth_fx, elevation_fx, hOSba->prev_object_dm_gains_fx[n], sba_analysis_order, Q30 );
}
}
@@ -467,14 +467,14 @@ void ivas_osba_enc_fx(
*--------------------------------------------------------------------------*/
/* Render ISMs to SBA */
static void ivas_osba_render_ism_to_sba_fx(
- Word32 *data_in_fx[],
- Word32 data_out_fx[][L_FRAME48k],
+ Word32 *data_in_fx[], // Q_data
+ Word32 data_out_fx[][L_FRAME48k], // Q_data
const Word16 input_frame,
const Word16 sba_analysis_order,
const Word16 nchan_ism,
ISM_METADATA_HANDLE hIsmMeta[],
- Word32 prev_gains_fx[][MAX_INPUT_CHANNELS],
- const Word32 interpolator_fx[L_FRAME48k],
+ Word32 prev_gains_fx[][MAX_INPUT_CHANNELS], // Q30
+ const Word32 interpolator_fx[L_FRAME48k], // Q31
Word16 *Q_data )
{
Word16 i, j, k;
@@ -495,31 +495,32 @@ static void ivas_osba_render_ism_to_sba_fx(
FOR( i = 0; i < nchan_ism; i++ )
{
// azimuth = (int16_t) floorf( hIsmMeta[i]->azimuth + 0.5f );
- azimuth_fx = extract_l( L_shr( L_add( hIsmMeta[i]->azimuth_fx, 2097152 ), Q22 ) );
+ azimuth_fx = extract_l( L_shr( L_add( hIsmMeta[i]->azimuth_fx, 2097152 /*0.5.Q22*/ ), Q22 ) ); // Q0
// elevation = (int16_t) floorf( hIsmMeta[i]->elevation + 0.5f );
- elevation_fx = extract_l( L_shr( L_add( hIsmMeta[i]->elevation_fx, 2097152 ), Q22 ) );
+ elevation_fx = extract_l( L_shr( L_add( hIsmMeta[i]->elevation_fx, 2097152 /*0.5.Q22*/ ), Q22 ) ); // Q0
ivas_dirac_dec_get_response_fx( azimuth_fx, elevation_fx, gains_fx, sba_analysis_order, Q30 );
/* Render using the sh gains */
FOR( j = 0; j < nchan_sba; j++ )
{
+ test();
IF( L_abs( gains_fx[j] ) > 0 || L_abs( prev_gains_fx[i][j] ) > 0 )
{
FOR( k = 0; k < input_frame; k++ )
{
// g1 = interpolator[k];
- g1_fx = interpolator_fx[k];
+ g1_fx = interpolator_fx[k]; // Q31
move32();
// g2 = 1.0f - g1;
- g2_fx = L_sub( ONE_IN_Q31, g1_fx );
+ g2_fx = L_sub( ONE_IN_Q31, g1_fx ); // Q31
move32();
// data_out_f[j][k] += ( g1 * gains[j] + g2 * prev_gains[i][j] ) * data_in_f[i][k];
data_out_fx[j][k] = L_add( data_out_fx[j][k], L_shr( Mpy_32_32( L_add( Mpy_32_32( g1_fx, gains_fx[j] ), Mpy_32_32( g2_fx, prev_gains_fx[i][j] ) ), data_in_fx[i][k] ), 1 ) ); // Q_data-2
move32();
}
}
- prev_gains_fx[i][j] = gains_fx[j];
+ prev_gains_fx[i][j] = gains_fx[j]; // Q30
move32();
}
}
diff --git a/lib_enc/ivas_pca_enc.c b/lib_enc/ivas_pca_enc.c
index fccef003672e81c07cc1b37862f3bb6d6a26bcea..4e133567c762b3b113274d78ffc6dfe50e2724e1 100644
--- a/lib_enc/ivas_pca_enc.c
+++ b/lib_enc/ivas_pca_enc.c
@@ -98,7 +98,7 @@ static void pca_enc_reset_fx(
}
static void pca_transform_sub_fx(
- Word16 *eigVec,
+ Word16 *eigVec, // Q15
Word32 *transformed_data[8], /* i : input/transformed audio channels Q11 */
const Word16 start,
const Word16 len,
@@ -112,7 +112,7 @@ static void pca_transform_sub_fx(
{
FOR( k = 0; k < n_channels; k++ )
{
- buffer_data[k] = transformed_data[k][j + start];
+ buffer_data[k] = transformed_data[k][j + start]; // Q11
move32();
}
FOR( k = 0; k < n_channels; k++ )
@@ -121,10 +121,10 @@ static void pca_transform_sub_fx(
move32();
FOR( i = 0; i < n_channels; i++ )
{
- temp2 = Mpy_32_16_1( buffer_data[i], eigVec[k * IVAS_PCA_INTERP + i] );
+ temp2 = Mpy_32_16_1( buffer_data[i], eigVec[k * IVAS_PCA_INTERP + i] ); // Q11
temp = L_add( temp, temp2 );
}
- transformed_data[k][add( j, start )] = temp;
+ transformed_data[k][( j + start )] = temp; // Q11
move32();
}
}
@@ -142,7 +142,7 @@ static void pca_enc_transform_fx(
{
Word16 time_slot;
Word16 slot_len;
- Word16 eigVec_interp_fx[FOA_CHANNELS * FOA_CHANNELS]; /* eigenvectors in current frame */
+ Word16 eigVec_interp_fx[FOA_CHANNELS * FOA_CHANNELS]; /* eigenvectors in current frame Q15*/
Word16 ql_interp_fx[IVAS_PCA_LEN_INTERP_Q], qr_interp_fx[IVAS_PCA_LEN_INTERP_Q];
quat_shortestpath_fx( hPCA->prev_ql_fx, ql_fx, hPCA->prev_qr_fx, qr_fx );
@@ -167,9 +167,9 @@ static void pca_update_state_fx(
Word16 *eigVec, // Q15
const Word16 n_channels )
{
- Copy( qr, hPCA->prev_qr_fx, IVAS_PCA_INTERP );
- Copy( ql, hPCA->prev_ql_fx, IVAS_PCA_INTERP );
- Copy( eigVec, hPCA->prev_eigVec_fx, imult1616( n_channels, n_channels ) );
+ Copy( qr, hPCA->prev_qr_fx, IVAS_PCA_INTERP ); // Q15
+ Copy( ql, hPCA->prev_ql_fx, IVAS_PCA_INTERP ); // Q15
+ Copy( eigVec, hPCA->prev_eigVec_fx, imult1616( n_channels, n_channels ) ); // Q15
return;
}
@@ -356,7 +356,7 @@ void ivas_pca_enc_fx(
{
FOR( k = 0; k < FOA_CHANNELS; k++ )
{
- ptr_sig_fx[k] = &data_fx[k][i];
+ ptr_sig_fx[k] = &data_fx[k][i]; // Q11
}
@@ -388,7 +388,7 @@ void ivas_pca_enc_fx(
FOR( Word16 idx = 0; idx < FOA_CHANNELS * FOA_CHANNELS; idx++ )
{
- r_fx[idx] = L_shr( r_fx[idx], ( sub( tmp_q[idx], q ) ) );
+ r_fx[idx] = L_shr( r_fx[idx], ( sub( tmp_q[idx], q ) ) ); // q
move32();
}
@@ -401,10 +401,10 @@ void ivas_pca_enc_fx(
FOR( k = 0; k < FOA_CHANNELS * FOA_CHANNELS; k++ )
{
- L_tmp = L_shr( Mpy_32_32( alpha_fx, r_fx[k] ), sub( q, min_q ) );
- L_tmp1 = L_shr( Mpy_32_32( one_minus_alpha_fx, hPCA->old_r_sm_fx[k] ), sub( hPCA->old_r_sm_q, min_q ) );
- r_sm_fx[k] = L_add( L_tmp, L_tmp1 );
- hPCA->old_r_sm_fx[k] = r_sm_fx[k];
+ L_tmp = L_shr( Mpy_32_32( alpha_fx, r_fx[k] ), sub( q, min_q ) ); // min_q
+ L_tmp1 = L_shr( Mpy_32_32( one_minus_alpha_fx, hPCA->old_r_sm_fx[k] ), sub( hPCA->old_r_sm_q, min_q ) ); // min_q
+ r_sm_fx[k] = L_add( L_tmp, L_tmp1 ); // min_q
+ hPCA->old_r_sm_fx[k] = r_sm_fx[k]; // min_q
move32();
move32();
}
@@ -415,13 +415,13 @@ void ivas_pca_enc_fx(
/* conditioning */
FOR( k = 0; k < FOA_CHANNELS; k++ )
{
- temp_fx32 = r_sm_fx[k * FOA_CHANNELS + k];
+ temp_fx32 = r_sm_fx[k * FOA_CHANNELS + k]; // min_q
move32();
IF( LT_32( temp_fx32, L_shr( 64424, sub( 31, hPCA->old_r_sm_q ) ) ) ) // IVAS_PCA_COV_THRES in Q31
{
- temp_fx32 = L_shr( 64424, sub( 31, hPCA->old_r_sm_q ) ); // IVAS_PCA_COV_THRES in Q31
+ temp_fx32 = L_shr( 64424, sub( 31, hPCA->old_r_sm_q ) ); // IVAS_PCA_COV_THRES in Q31 /*hPCA->old_r_sm_q */
}
- r_sm_fx[k * FOA_CHANNELS + k] = temp_fx32; /* pointer reuse */
+ r_sm_fx[k * FOA_CHANNELS + k] = temp_fx32; /* pointer reuse */ // hPCA->old_r_sm_q
move32();
}
@@ -539,7 +539,7 @@ void ivas_pca_enc_fx(
/* copy j-th column to column k */
FOR( l = 0; l < n_channels; l++ )
{
- eigVec_tmp_fx[l * n_channels + k] = eigVec_fx[l * n_channels + j];
+ eigVec_tmp_fx[l * n_channels + k] = eigVec_fx[l * n_channels + j]; // Q31
move16();
}
D_tmp_fx[k] = extract_l( D_fx[j] );
@@ -548,7 +548,7 @@ void ivas_pca_enc_fx(
FOR( k = 0; k < n_channels * n_channels; k++ )
{
- eigVec_fx[k] = eigVec_tmp_fx[k];
+ eigVec_fx[k] = eigVec_tmp_fx[k]; // Q31
move32();
}
@@ -571,14 +571,14 @@ void ivas_pca_enc_fx(
{
FOR( i = 0; i < n_channels; i++ )
{
- eigVec_fx[i * n_channels + k] = L_negate( eigVec_fx[i * n_channels + k] );
+ eigVec_fx[i * n_channels + k] = L_negate( eigVec_fx[i * n_channels + k] ); // Q31
move32();
}
}
}
/* force rotation matrix(det = +1) */
- Copy_Scale_sig32_16( eigVec_fx, eigVec_fx16, FOA_CHANNELS * FOA_CHANNELS, -16 );
+ Copy_Scale_sig32_16( eigVec_fx, eigVec_fx16, FOA_CHANNELS * FOA_CHANNELS, -16 ); // Q15
det_fx = mat_det4_fx( eigVec_fx16 );
IF( det_fx < 0 )
{
@@ -603,29 +603,29 @@ void ivas_pca_enc_fx(
*-----------------------------------------------------------------*/
/* convert frrm rotation matrix to double quaternion */
- Copy_Scale_sig_32_16( eigVec_fx, eigVec_fx16, FOA_CHANNELS * FOA_CHANNELS, -16 );
+ Copy_Scale_sig_32_16( eigVec_fx, eigVec_fx16, FOA_CHANNELS * FOA_CHANNELS, -16 ); // Q15
mat2dquat_fx( eigVec_fx16, ql_fx, qr_fx );
- dotl_fx = Dot_product( hPCA->prev_ql_fx, ql_fx, 4 );
- dotr_fx = Dot_product( hPCA->prev_qr_fx, qr_fx, 4 );
+ dotl_fx = Dot_product( hPCA->prev_ql_fx, ql_fx, 4 ); // Q31
+ dotr_fx = Dot_product( hPCA->prev_qr_fx, qr_fx, 4 ); // Q31
IF( LT_32( dotl_fx, dotr_fx ) )
{
- min_dot_fx = dotl_fx;
+ min_dot_fx = dotl_fx; // Q31
move32();
}
ELSE
{
- min_dot_fx = dotr_fx;
+ min_dot_fx = dotr_fx; // Q31
move32();
}
IF( LT_16( ql_fx[0], qr_fx[0] ) )
{
- min_dot2_fx = L_deposit_h( ql_fx[0] );
+ min_dot2_fx = L_deposit_h( ql_fx[0] ); // Q31
}
ELSE
{
- min_dot2_fx = L_deposit_h( qr_fx[0] );
+ min_dot2_fx = L_deposit_h( qr_fx[0] ); // Q31
}
bypass_decision = PCA_MODE_ACTIVE;
diff --git a/lib_enc/ivas_qmetadata_enc.c b/lib_enc/ivas_qmetadata_enc.c
index 28218d70d4752d444463a6a490574e85054484ba..00b62f2f6d07e86fe3432dfd0f3df07229fe2c28 100644
--- a/lib_enc/ivas_qmetadata_enc.c
+++ b/lib_enc/ivas_qmetadata_enc.c
@@ -51,7 +51,7 @@
* Local function prototypes
*-----------------------------------------------------------------------*/
-static void ivas_qmetadata_quantize_diffuseness_nrg_ratios_fx( IVAS_QMETADATA_HANDLE hQMetaData, int16_t *needed_bits, int16_t *nbits_diff, int16_t *dfRatioBits, const int16_t hodirac_flag );
+static void ivas_qmetadata_quantize_diffuseness_nrg_ratios_fx( IVAS_QMETADATA_HANDLE hQMetaData, Word16 *needed_bits, Word16 *nbits_diff, Word16 *dfRatioBits, const Word16 hodirac_flag );
static Word16 ivas_qmetadata_entropy_encode_diffuseness_fx(
BSTR_ENC_HANDLE hMetaData,
@@ -88,11 +88,11 @@ static Word16 ivas_qmetadata_get_optimal_gr_param_fx(
const Word16 gr_param_count,
Word16 *opt_gr_size );
-Word16 ivas_qmetadata_encode_extended_gr_length( const UWord16 value, const UWord16 alphabet_size, const Word16 gr_param );
+Word16 ivas_qmetadata_encode_extended_gr_length_fx( const UWord16 value, const UWord16 alphabet_size, const Word16 gr_param );
-static Word16 ivas_qmetadata_encode_quasi_uniform_length( const UWord16 value, const UWord16 alphabet_size );
+static Word16 ivas_qmetadata_encode_quasi_uniform_length_fx( const UWord16 value, const UWord16 alphabet_size );
-static void ivas_qmetadata_encode_quasi_uniform( BSTR_ENC_HANDLE hMetaData, const UWord16 value, const UWord16 alphabet_size );
+static void ivas_qmetadata_encode_quasi_uniform_fx( BSTR_ENC_HANDLE hMetaData, const UWord16 value, const UWord16 alphabet_size );
static Word16 ivas_qmetadata_reorder_elevation_index_fx(
const Word16 elevation_index,
@@ -131,16 +131,16 @@ static Word16 ivas_qmetadata_quantize_coherence_fx(
);
static void dct4_transform_fx(
- uint8_t *v, /* i : input 4D vector */
+ UWord8 *v, /* i : input 4D vector */
Word32 *dct_v /* o : output transformed vector Q31 */
);
static Word32 quantize_DCT_0_coh_fx( // o:Q21
const Word16 x, /* i : input value Q14 */
- const int16_t j, /* i : subband index */
+ const Word16 j, /* i : subband index */
const Word16 *coherence_cb, /* i : coherence codebook Q14 */
const Word16 delta_var, /* i : azimuth variance threshold Q6 */
- const int16_t no_cb, /* i : maximum number of codewords */
+ const Word16 no_cb, /* i : maximum number of codewords */
IVAS_QDIRECTION *q_direction, /* i : quantized metadata */
UWord16 *idx_x, /* o : codewords index */
Word16 *p_no_cb, /* o : actual number of codewords dependent on energy ratio value */
@@ -162,7 +162,7 @@ static Word16 encode_coherence_indexesDCT1_fx(
BSTR_ENC_HANDLE hMetaData /* i : metadata handle */
);
-static UWord64 create_combined_index( uint16_t *idx_dct, const int16_t len, const int16_t *no_cb_vec );
+static UWord64 create_combined_index_fx( uint16_t *idx_dct, const Word16 len, const Word16 *no_cb_vec );
static Word16 encode_surround_coherence_fx(
IVAS_QMETADATA *hQMetaData, /* i : quantized metadata */
@@ -186,9 +186,9 @@ static void ivas_diffuseness_huff_ec_prepare_fx(
UWord16 *avr_idx,
Word16 *diffuseness_bits_huff );
-static int16_t coherence_coding_length( const uint16_t *idx_sur_coh_shift, const uint8_t idx_shift_len, const int16_t coding_subbands, const int16_t *no_cv, uint16_t *mr_idx, int16_t *no_cv_shift, int16_t *p_min_idx, int16_t *GR_ord, int16_t *nbits_fr, int16_t *nbits_fr1 );
+static Word16 coherence_coding_length( const uint16_t *idx_sur_coh_shift, const UWord8 idx_shift_len, const Word16 coding_subbands, const Word16 *no_cv, uint16_t *mr_idx, Word16 *no_cv_shift, Word16 *p_min_idx, Word16 *GR_ord, Word16 *nbits_fr, Word16 *nbits_fr1 );
-static int16_t write_2dir_info( BSTR_ENC_HANDLE hMetaData, uint8_t *twoDirBands, const int16_t n, const int16_t k );
+static Word16 write_2dir_info( BSTR_ENC_HANDLE hMetaData, UWord8 *twoDirBands, const Word16 n, const Word16 k );
static void transform_azimuth_dir2_fx(
IVAS_QMETADATA_HANDLE hQMetaData,
@@ -289,9 +289,9 @@ ivas_error ivas_qmetadata_enc_encode_fx(
{
IF( EQ_16( hQMetaData->twoDirBands[i], 1 ) )
{
- Copy32( hQMetaData->q_direction[1].band_data[i].azimuth_fx, hQMetaData->q_direction[1].band_data[d].azimuth_fx, hQMetaData->q_direction[1].cfg.nblocks );
- Copy32( hQMetaData->q_direction[1].band_data[i].elevation_fx, hQMetaData->q_direction[1].band_data[d].elevation_fx, hQMetaData->q_direction[1].cfg.nblocks );
- Copy32( hQMetaData->q_direction[1].band_data[i].energy_ratio_fx, hQMetaData->q_direction[1].band_data[d].energy_ratio_fx, hQMetaData->q_direction[1].cfg.nblocks );
+ Copy32( hQMetaData->q_direction[1].band_data[i].azimuth_fx, hQMetaData->q_direction[1].band_data[d].azimuth_fx, hQMetaData->q_direction[1].cfg.nblocks ); // Q22
+ Copy32( hQMetaData->q_direction[1].band_data[i].elevation_fx, hQMetaData->q_direction[1].band_data[d].elevation_fx, hQMetaData->q_direction[1].cfg.nblocks ); // Q22
+ Copy32( hQMetaData->q_direction[1].band_data[i].energy_ratio_fx, hQMetaData->q_direction[1].band_data[d].energy_ratio_fx, hQMetaData->q_direction[1].cfg.nblocks ); // Q30
dir2_bands[d] = i;
move16();
@@ -646,7 +646,7 @@ ivas_error ivas_qmetadata_enc_encode_fx(
/* finalize writing coherence */
test();
test();
- IF( GT_16( bits_coherence[d], 0 ) && EQ_16( all_coherence_zero, 0 ) && GT_16( nblocks, 1 ) )
+ IF( ( bits_coherence[d] > 0 ) && ( all_coherence_zero == 0 ) && GT_16( nblocks, 1 ) )
{
bit_pos_start = hMetaData->nb_bits_tot;
hMetaData->nb_bits_tot = bit_pos_start_coh;
@@ -716,7 +716,7 @@ ivas_error ivas_qmetadata_enc_encode_hr_384_512_fx(
{
push_next_indice( hMetaData, 1, 1 );
/* write the number of inactive higher bands */
- ivas_qmetadata_encode_extended_gr( hMetaData, sub( hQMetaData->q_direction->cfg.inactiveBands, 1 ), MASA_MAXIMUM_CODING_SUBBANDS, 1 );
+ ivas_qmetadata_encode_extended_gr_fx( hMetaData, sub( hQMetaData->q_direction->cfg.inactiveBands, 1 ), MASA_MAXIMUM_CODING_SUBBANDS, 1 );
}
ELSE
{
@@ -741,9 +741,9 @@ ivas_error ivas_qmetadata_enc_encode_hr_384_512_fx(
{
IF( EQ_16( hQMetaData->twoDirBands[i], 1 ) )
{
- Copy32( hQMetaData->q_direction[1].band_data[i].azimuth_fx, hQMetaData->q_direction[1].band_data[d].azimuth_fx, hQMetaData->q_direction[1].cfg.nblocks );
- Copy32( hQMetaData->q_direction[1].band_data[i].elevation_fx, hQMetaData->q_direction[1].band_data[d].elevation_fx, hQMetaData->q_direction[1].cfg.nblocks );
- Copy32( hQMetaData->q_direction[1].band_data[i].energy_ratio_fx, hQMetaData->q_direction[1].band_data[d].energy_ratio_fx, hQMetaData->q_direction[1].cfg.nblocks );
+ Copy32( hQMetaData->q_direction[1].band_data[i].azimuth_fx, hQMetaData->q_direction[1].band_data[d].azimuth_fx, hQMetaData->q_direction[1].cfg.nblocks ); // Q22
+ Copy32( hQMetaData->q_direction[1].band_data[i].elevation_fx, hQMetaData->q_direction[1].band_data[d].elevation_fx, hQMetaData->q_direction[1].cfg.nblocks ); // Q22
+ Copy32( hQMetaData->q_direction[1].band_data[i].energy_ratio_fx, hQMetaData->q_direction[1].band_data[d].energy_ratio_fx, hQMetaData->q_direction[1].cfg.nblocks ); // Q30
IF( hQMetaData->coherence_flag )
{
@@ -827,16 +827,16 @@ ivas_error ivas_qmetadata_enc_encode_hr_384_512_fx(
{
FOR( i = start_band; i < nbands; i++ )
{
- Copy32( azimuth_orig_fx[i], q_direction->band_data[i].azimuth_fx, nblocks );
- Copy32( elevation_orig_fx[i], q_direction->band_data[i].elevation_fx, nblocks );
+ Copy32( azimuth_orig_fx[i], q_direction->band_data[i].azimuth_fx, nblocks ); // Q22
+ Copy32( elevation_orig_fx[i], q_direction->band_data[i].elevation_fx, nblocks ); // Q22
}
}
ELSE
{
FOR( i = start_band; i < nbands; i++ )
{
- Copy32( q_direction->band_data[i].azimuth_fx, q_direction->band_data[i].q_azimuth_fx, nblocks );
- Copy32( q_direction->band_data[i].elevation_fx, q_direction->band_data[i].q_elevation_fx, nblocks );
+ Copy32( q_direction->band_data[i].azimuth_fx, q_direction->band_data[i].q_azimuth_fx, nblocks ); // Q22
+ Copy32( q_direction->band_data[i].elevation_fx, q_direction->band_data[i].q_elevation_fx, nblocks ); // Q22
}
}
}
@@ -945,7 +945,7 @@ void ivas_qmetadata_enc_sid_encode_fx(
{
q_direction->band_data[b].energy_ratio_index[0] = s_max( q_direction->band_data[b].energy_ratio_index[0], 4 );
move16();
- bits_diff = add( bits_diff, ivas_qmetadata_encode_quasi_uniform_length( sub( q_direction->band_data[b].energy_ratio_index[0], 4 ), DIRAC_DIFFUSE_LEVELS - 4 ) );
+ bits_diff = add( bits_diff, ivas_qmetadata_encode_quasi_uniform_length_fx( sub( q_direction->band_data[b].energy_ratio_index[0], 4 ), DIRAC_DIFFUSE_LEVELS - 4 ) );
q_direction->band_data[b].bits_sph_idx[0] = bits_direction_masa[q_direction->band_data[b].energy_ratio_index[0]];
move16();
@@ -953,7 +953,7 @@ void ivas_qmetadata_enc_sid_encode_fx(
{
q_direction->band_data[b].azimuth_m_alphabet[0] = 1 << ( s_min( 8, q_direction->band_data[b].bits_sph_idx[0] ) );
move16();
- bits_dir = add( bits_dir, ivas_qmetadata_encode_quasi_uniform_length( sub( q_direction->band_data[b].azimuth_m_alphabet[0], 1 ), q_direction->band_data[b].azimuth_m_alphabet[0] ) );
+ bits_dir = add( bits_dir, ivas_qmetadata_encode_quasi_uniform_length_fx( sub( q_direction->band_data[b].azimuth_m_alphabet[0], 1 ), q_direction->band_data[b].azimuth_m_alphabet[0] ) );
}
ELSE
{
@@ -1016,7 +1016,7 @@ void ivas_qmetadata_enc_sid_encode_fx(
FOR( b = start_band; b < nbands; b++ )
{
q_direction->band_data[b].energy_ratio_index[0] = s_max( q_direction->band_data[b].energy_ratio_index[0], 4 );
- bits_diff = add( bits_diff, ivas_qmetadata_encode_quasi_uniform_length( sub( q_direction->band_data[b].energy_ratio_index[0], 4 ), DIRAC_DIFFUSE_LEVELS - 4 ) );
+ bits_diff = add( bits_diff, ivas_qmetadata_encode_quasi_uniform_length_fx( sub( q_direction->band_data[b].energy_ratio_index[0], 4 ), DIRAC_DIFFUSE_LEVELS - 4 ) );
q_direction->band_data[b].bits_sph_idx[0] = bits_direction_masa[q_direction->band_data[b].energy_ratio_index[0]];
move16();
move16();
@@ -1025,7 +1025,7 @@ void ivas_qmetadata_enc_sid_encode_fx(
{
q_direction->band_data[b].azimuth_m_alphabet[0] = shl( 1, ( s_min( 5, q_direction->band_data[b].bits_sph_idx[0] ) ) );
move16();
- bits_dir = add( bits_dir, ivas_qmetadata_encode_quasi_uniform_length( sub( q_direction->band_data[b].azimuth_m_alphabet[0], 1 ), q_direction->band_data[b].azimuth_m_alphabet[0] ) );
+ bits_dir = add( bits_dir, ivas_qmetadata_encode_quasi_uniform_length_fx( sub( q_direction->band_data[b].azimuth_m_alphabet[0], 1 ), q_direction->band_data[b].azimuth_m_alphabet[0] ) );
}
ELSE
{
@@ -1061,7 +1061,7 @@ void ivas_qmetadata_enc_sid_encode_fx(
/*Code diffuseness*/
FOR( b = start_band; b < nbands; b++ )
{
- ivas_qmetadata_encode_quasi_uniform( hMetaData, sub( q_direction->band_data[b].energy_ratio_index[0], 4 ), DIRAC_DIFFUSE_LEVELS - 4 );
+ ivas_qmetadata_encode_quasi_uniform_fx( hMetaData, sub( q_direction->band_data[b].energy_ratio_index[0], 4 ), DIRAC_DIFFUSE_LEVELS - 4 );
}
/* Compute and Quantize an average direction per band*/
@@ -1117,14 +1117,14 @@ void ivas_qmetadata_enc_sid_encode_fx(
{
FOR( b = start_band; b < nbands; b++ )
{
- ivas_qmetadata_encode_quasi_uniform( hMetaData, q_direction->band_data[b].azimuth_index[0], q_direction->band_data[b].azimuth_m_alphabet[0] );
+ ivas_qmetadata_encode_quasi_uniform_fx( hMetaData, q_direction->band_data[b].azimuth_index[0], q_direction->band_data[b].azimuth_m_alphabet[0] );
}
}
/* fill bits*/
assert( ( hMetaData->nb_bits_tot - bit_pos_start ) <= metadata_sid_bits && "Too many written bits!" );
- WHILE( LT_16( ( sub( hMetaData->nb_bits_tot, bit_pos_start ) ), metadata_sid_bits ) )
+ WHILE( ( ( ( hMetaData->nb_bits_tot - bit_pos_start ) ) < metadata_sid_bits ) )
{
push_next_indice( hMetaData, 0, 1 ); /*fill bit*/
}
@@ -1165,7 +1165,7 @@ void reset_metadata_spatial_fx(
metadata_sid_bits = (Word16) ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - SID_FORMAT_NBITS;
move16();
- WHILE( LT_16( hMetaData->nb_bits_tot, metadata_sid_bits ) )
+ WHILE( ( hMetaData->nb_bits_tot < metadata_sid_bits ) )
{
push_next_indice( hMetaData, 0, 1 ); /*fill bit*/
}
@@ -1177,9 +1177,9 @@ void reset_metadata_spatial_fx(
next_ind_sid = hMetaData->nb_ind_tot;
move16();
move16();
- WHILE( GT_16( hMetaData->nb_bits_tot, nb_bits_metadata ) )
+ WHILE( ( hMetaData->nb_bits_tot > nb_bits_metadata ) )
{
- next_ind_sid--;
+ next_ind_sid = sub( next_ind_sid, 1 );
hMetaData->nb_bits_tot = sub( hMetaData->nb_bits_tot, hMetaData->ind_list[next_ind_sid].nb_bits );
move16();
}
@@ -1221,9 +1221,9 @@ void reset_metadata_spatial_fx(
ELSE IF( NE_32( ivas_format, SBA_FORMAT ) )
{
/* Reset SID metadata bits*/
- WHILE( GT_16( hMetaData->nb_bits_tot, nb_bits_metadata ) )
+ WHILE( ( hMetaData->nb_bits_tot > nb_bits_metadata ) )
{
- hMetaData->nb_ind_tot--;
+ hMetaData->nb_ind_tot = sub( hMetaData->nb_ind_tot, 1 );
hMetaData->nb_bits_tot = sub( hMetaData->nb_bits_tot, hMetaData->ind_list[hMetaData->nb_ind_tot].nb_bits );
hMetaData->ind_list[hMetaData->nb_ind_tot].nb_bits = -1;
move16();
@@ -1381,10 +1381,10 @@ static void ivas_qmetadata_quantize_diffuseness_nrg_ratios_hr_512_fx(
push_next_indice( hMetaData, index, MASA_BITS_ER_HR );
hQMetaData->q_direction[1].band_data[j].energy_ratio_index[k] = index;
move16();
- hQMetaData->q_direction[1].band_data[j].energy_ratio_fx[k] = W_extract_h( W_sub( ONE_IN_Q62, diffuseness_reconstructions_hr_fx[index] ) );
+ hQMetaData->q_direction[1].band_data[j].energy_ratio_fx[k] = W_extract_h( W_sub( ONE_IN_Q62, diffuseness_reconstructions_hr_fx[index] ) ); // Q30
move32();
- ratioSum = L_add( hQMetaData->q_direction[0].band_data[pos_2dir_band[j]].energy_ratio_fx[k], hQMetaData->q_direction[1].band_data[j].energy_ratio_fx[k] );
+ ratioSum = L_add( hQMetaData->q_direction[0].band_data[pos_2dir_band[j]].energy_ratio_fx[k], hQMetaData->q_direction[1].band_data[j].energy_ratio_fx[k] ); // Q30
IF( GT_32( ratioSum, ONE_IN_Q30 /*1.0f*/ ) )
{
@@ -1672,9 +1672,9 @@ static void ivas_diffuseness_huff_ec_prepare_fx(
{
av = add( av, q_direction->band_data[b].energy_ratio_index[0] );
}
- // av = (int16_t) ( 0.5f + av / (float) nbands );
+ // av = (Word16) ( 0.5f + av / (float) nbands );
av = BASOP_Util_Divide1616_Scale( av, nbands, &av_e );
- av = shr_r( av, sub( 15, av_e ) );
+ av = shr_r( av, sub( 15, av_e ) ); // Q0
*best_av = av;
move16();
@@ -1769,7 +1769,7 @@ static Word16 ivas_qmetadata_entropy_encode_diffuseness_fx(
move16();
FOR( b = start_band; b < nbands; b++ )
{
- diffuseness_bits_raw = add( diffuseness_bits_raw, ivas_qmetadata_encode_quasi_uniform_length( q_direction->band_data[b].energy_ratio_index[0], DIRAC_DIFFUSE_LEVELS ) );
+ diffuseness_bits_raw = add( diffuseness_bits_raw, ivas_qmetadata_encode_quasi_uniform_length_fx( q_direction->band_data[b].energy_ratio_index[0], DIRAC_DIFFUSE_LEVELS ) );
}
min_diffuseness_m_index = q_direction->band_data[start_band].energy_ratio_index[0];
@@ -1798,15 +1798,15 @@ static Word16 ivas_qmetadata_entropy_encode_diffuseness_fx(
/* one bit is used to indicate whether diffuseness values are entropy coded or coded raw */
IF( EQ_16( min_diffuseness_m_index, max_diffuseness_m_index ) ) /* all values are equal */
{
- push_next_indice( hMetaData, 0, 1 ); /* dif_use_raw_coding */
- push_next_indice( hMetaData, 1, 1 ); /* dif_have_unique_value */
- ivas_qmetadata_encode_quasi_uniform( hMetaData, min_diffuseness_m_index, DIRAC_DIFFUSE_LEVELS ); /* dif_unique_value */
+ push_next_indice( hMetaData, 0, 1 ); /* dif_use_raw_coding */
+ push_next_indice( hMetaData, 1, 1 ); /* dif_have_unique_value */
+ ivas_qmetadata_encode_quasi_uniform_fx( hMetaData, min_diffuseness_m_index, DIRAC_DIFFUSE_LEVELS ); /* dif_unique_value */
}
ELSE IF( EQ_16( add( min_diffuseness_m_index, 1 ), max_diffuseness_m_index ) ) /* only two consecutive values are present */
{
- push_next_indice( hMetaData, 0, 1 ); /* dif_use_raw_coding */
- push_next_indice( hMetaData, 0, 1 ); /* dif_have_unique_value */
- ivas_qmetadata_encode_quasi_uniform( hMetaData, min_diffuseness_m_index, DIRAC_DIFFUSE_LEVELS - 1 ); /* dif_min_value */
+ push_next_indice( hMetaData, 0, 1 ); /* dif_use_raw_coding */
+ push_next_indice( hMetaData, 0, 1 ); /* dif_have_unique_value */
+ ivas_qmetadata_encode_quasi_uniform_fx( hMetaData, min_diffuseness_m_index, DIRAC_DIFFUSE_LEVELS - 1 ); /* dif_min_value */
FOR( b = start_band; b < nbands; b++ )
{
@@ -1819,7 +1819,7 @@ static Word16 ivas_qmetadata_entropy_encode_diffuseness_fx(
FOR( b = start_band; b < nbands; b++ )
{
- ivas_qmetadata_encode_quasi_uniform( hMetaData, q_direction->band_data[b].energy_ratio_index[0], DIRAC_DIFFUSE_LEVELS ); /* dif_values */
+ ivas_qmetadata_encode_quasi_uniform_fx( hMetaData, q_direction->band_data[b].energy_ratio_index[0], DIRAC_DIFFUSE_LEVELS ); /* dif_values */
}
}
}
@@ -1850,7 +1850,7 @@ static Word16 ivas_qmetadata_entropy_encode_diffuseness_fx(
push_next_indice( hMetaData, 1, 1 );
FOR( b = start_band; b < nbands; b++ )
{
- ivas_qmetadata_encode_quasi_uniform( hMetaData, q_direction->band_data[b].energy_ratio_index[0], DIRAC_DIFFUSE_LEVELS ); /* dif_values */
+ ivas_qmetadata_encode_quasi_uniform_fx( hMetaData, q_direction->band_data[b].energy_ratio_index[0], DIRAC_DIFFUSE_LEVELS ); /* dif_values */
}
}
}
@@ -1858,7 +1858,7 @@ static Word16 ivas_qmetadata_entropy_encode_diffuseness_fx(
*diffuseness_index_max_ec_frame = 5;
move16();
/* adaptively select the diffuseness_index_max_ec threshold */
- if ( GT_16( min_diffuseness_m_index, 5 ) )
+ IF( GT_16( min_diffuseness_m_index, 5 ) )
{
*diffuseness_index_max_ec_frame = DIRAC_DIFFUSE_LEVELS - 1;
move16();
@@ -1961,13 +1961,13 @@ static Word16 ivas_qmetadata_entropy_encode_df_ratio_fx(
push_next_indice( hMetaData, 0, 1 ); /* Signal between one value or bandwise diff mode */
}
- ivas_qmetadata_encode_quasi_uniform( hMetaData, min_index, max_alphabet_size );
+ ivas_qmetadata_encode_quasi_uniform_fx( hMetaData, min_index, max_alphabet_size );
}
ELSE IF( EQ_16( add( min_index, 1 ), max_index ) && GT_16( ec_mode, 1 ) ) /* only two consecutive values are present */
{
push_next_indice( hMetaData, 0, 1 );
push_next_indice( hMetaData, 1, 1 );
- ivas_qmetadata_encode_quasi_uniform( hMetaData, min_index, sub( max_alphabet_size, 1 ) );
+ ivas_qmetadata_encode_quasi_uniform_fx( hMetaData, min_index, sub( max_alphabet_size, 1 ) );
FOR( b = start_band; b < nbands; b++ )
{
@@ -1983,7 +1983,7 @@ static Word16 ivas_qmetadata_entropy_encode_df_ratio_fx(
FOR( b = start_band; b < nbands; b++ )
{
- ivas_qmetadata_encode_quasi_uniform( hMetaData, q_direction->band_data[b].energy_ratio_index[0], shl( 1, df_ratio_bits[b] ) ); /* dif_values */
+ ivas_qmetadata_encode_quasi_uniform_fx( hMetaData, q_direction->band_data[b].energy_ratio_index[0], shl( 1, df_ratio_bits[b] ) ); /* dif_values */
}
}
@@ -2016,11 +2016,11 @@ void restore_metadata_buffer_fx(
}
/*-------------------------------------------------------------------------
- * ivas_qmetadata_encode_quasi_uniform()
+ * ivas_qmetadata_encode_quasi_uniform_fx()
*
* encode value using a quasi-uniform code of b or b + 1 bits, where b = floor(log2(alphabet_size))
*------------------------------------------------------------------------*/
-static void ivas_qmetadata_encode_quasi_uniform(
+static void ivas_qmetadata_encode_quasi_uniform_fx(
BSTR_ENC_HANDLE hMetaData,
const UWord16 value,
const UWord16 alphabet_size )
@@ -2048,12 +2048,12 @@ static void ivas_qmetadata_encode_quasi_uniform(
* GR encoder function definitions
*-----------------------------------------------------------------------*/
/*-------------------------------------------------------------------------
- * GR_bits_new()
+ * GR_bits_new_fx()
*
*
*------------------------------------------------------------------------*/
/*! r: number of bits using Golomb Rice code */
-static Word16 GR_bits_new(
+static Word16 GR_bits_new_fx(
UWord16 *data, /* i : data to encode with GR */
Word16 *no_symb, /* i : number of symbols for each component*/
const Word16 no_data, /* i : number of input data */
@@ -2070,7 +2070,7 @@ static Word16 GR_bits_new(
FOR( i = 0; i < no_data; i++ )
{
- nb = ivas_qmetadata_encode_extended_gr_length( data[i], no_symb[i], GR_order );
+ nb = ivas_qmetadata_encode_extended_gr_length_fx( data[i], no_symb[i], GR_order );
nbits = add( nbits, nb );
}
@@ -2078,7 +2078,7 @@ static Word16 GR_bits_new(
{
FOR( i = 0; i < no_data; i++ )
{
- nb = ivas_qmetadata_encode_extended_gr_length( data[i], no_symb[i], GR_order - 1 );
+ nb = ivas_qmetadata_encode_extended_gr_length_fx( data[i], no_symb[i], GR_order - 1 );
nbits1 = add( nbits1, nb );
}
@@ -2111,8 +2111,8 @@ static Word16 GR_bits_new(
* Encoding azimuth indexes with GR code using context
*------------------------------------------------------------------------*/
/*! r: numer of bits used for coding */
-static Word16 GR_bits_azimuth_context(
- UWord16 *data_in, /* i : data to be encoded */
+static Word16 GR_bits_azimuth_context_fx(
+ UWord16 *data_in, /* i : data to be encoded Qx*/
Word16 *no_symb, /* i : number of symbols for each component */
const Word16 no_data_in, /* i : number of input data */
const Word16 GR_order, /* i : GR order (GR_order or GR_order-1 are used ) */
@@ -2135,7 +2135,7 @@ static Word16 GR_bits_azimuth_context(
{
no_symb_local[no_data] = no_symb[i];
move16();
- data[no_data++] = data_in[i];
+ data[no_data++] = data_in[i]; // Qx
move16();
}
}
@@ -2163,7 +2163,7 @@ static Word16 GR_bits_azimuth_context(
{
*real_GR_ord = sub( GR_order, (Word16) EQ_16( bits_dir[i], 2 ) );
move16();
- nbits = add( nbits, ivas_qmetadata_encode_extended_gr_length( data[i], no_symb_local[i], *real_GR_ord ) );
+ nbits = add( nbits, ivas_qmetadata_encode_extended_gr_length_fx( data[i], no_symb_local[i], *real_GR_ord ) );
}
}
@@ -2171,27 +2171,27 @@ static Word16 GR_bits_azimuth_context(
move16();
IF( use_context == 0 )
{
- nbits = GR_bits_new( data, no_symb_local, no_data, GR_order, 1, real_GR_ord );
+ nbits = GR_bits_new_fx( data, no_symb_local, no_data, GR_order, 1, real_GR_ord );
nbits1 = nbits;
move16();
- min_val = data[0];
+ min_val = data[0]; // Qx
move16();
FOR( i = 1; i < no_data; i++ )
{
if ( LT_32( data[i], min_val ) )
{
- min_val = data[i];
+ min_val = data[i]; // Qx
move16();
}
}
FOR( i = 0; i < no_data; i++ )
{
- cdata[i] = (UWord16) L_sub( data[i], min_val );
+ cdata[i] = (UWord16) L_sub( data[i], min_val ); // Qx
move16();
}
maximum_s( no_symb_local, no_data, &max_val );
- nbits1 = add( GR_bits_new( cdata, no_symb_local, no_data, sub( GR_order, 1 ), 1, &real_GR_ord1 ), ivas_qmetadata_encode_extended_gr_length( min_val, max_val, MASA_GR_ORD_AZ ) );
+ nbits1 = add( GR_bits_new_fx( cdata, no_symb_local, no_data, sub( GR_order, 1 ), 1, &real_GR_ord1 ), ivas_qmetadata_encode_extended_gr_length_fx( min_val, max_val, MASA_GR_ORD_AZ ) );
IF( LT_16( nbits1, nbits ) )
{
@@ -2220,7 +2220,7 @@ static Word16 GR_bits_azimuth_context(
* Golomb Rice encoding with mean removing
*------------------------------------------------------------------------*/
/*! r: number of bits used */
-static Word16 mean_removed_GR_new(
+static Word16 mean_removed_GR_new_fx(
const UWord16 *idx, /* i : data to encode */
const Word16 max_no_symb,
const Word16 len, /* i : number of data */
@@ -2235,7 +2235,7 @@ static Word16 mean_removed_GR_new(
Word16 max_ns[MASA_MAXIMUM_CODING_SUBBANDS];
/* av = (Word16) ( 0.5f + sum_s( (const Word16 *) idx, len ) / (float) len ); */
- av = div_l( L_add( L_shl( sum16_fx( (const Word16 *) idx, len ), 1 ), 1 ), len );
+ av = shr( add( 1, idiv1616U( shl( sum16_fx( (const Word16 *) idx, len ), 1 ), len ) ), 1 ); // Q0
*p_av = av;
move16();
@@ -2251,7 +2251,7 @@ static Word16 mean_removed_GR_new(
{
IF( sh_idx[i] < 0 )
{
- sh_idx[i] = -2 * sh_idx[i];
+ sh_idx[i] = imult1616( -2, sh_idx[i] );
}
ELSE IF( sh_idx[i] > 0 )
{
@@ -2267,16 +2267,16 @@ static Word16 mean_removed_GR_new(
move16();
}
- nbits = GR_bits_new( mr_idx, max_ns, len, *GR_ord, adapt_GR, GR_ord );
+ nbits = GR_bits_new_fx( mr_idx, max_ns, len, *GR_ord, adapt_GR, GR_ord );
return nbits;
}
/*-------------------------------------------------------------------------
- * ivas_qmetadata_encode_quasi_uniform_length()
+ * ivas_qmetadata_encode_quasi_uniform_length_fx()
*
*------------------------------------------------------------------------*/
-static Word16 ivas_qmetadata_encode_quasi_uniform_length(
+static Word16 ivas_qmetadata_encode_quasi_uniform_length_fx(
const UWord16 value,
const UWord16 alphabet_size )
{
@@ -2392,7 +2392,7 @@ static Word16 ivas_qmetadata_entropy_encode_dir_fx(
{
FOR( j = 0; j < nblocks; j++ )
{
- direction_bits_ec = add( direction_bits_ec, ivas_qmetadata_encode_quasi_uniform_length( q_direction->band_data[i].azimuth_index[j], q_direction->band_data[i].azimuth_m_alphabet[j] ) );
+ direction_bits_ec = add( direction_bits_ec, ivas_qmetadata_encode_quasi_uniform_length_fx( q_direction->band_data[i].azimuth_index[j], q_direction->band_data[i].azimuth_m_alphabet[j] ) );
}
}
}
@@ -2415,24 +2415,24 @@ static Word16 ivas_qmetadata_entropy_encode_dir_fx(
IF( NE_32( q_direction->cfg.mc_ls_setup, MC_LS_SETUP_INVALID ) )
{
- avg_elevation_alphabet = no_theta_masa[bits_direction_masa[diff_idx_min] - 3];
+ avg_elevation_alphabet = no_theta_masa[bits_direction_masa[diff_idx_min] - 3]; // Q0
move16();
- avg_azimuth_alphabet = no_phi_masa[bits_direction_masa[diff_idx_min] - 1][0]; /* average azimuth is quantized on the equatorial plane */
+ avg_azimuth_alphabet = no_phi_masa[bits_direction_masa[diff_idx_min] - 1][0]; /* average azimuth is quantized on the equatorial plane Q0*/
move16();
}
ELSE
{
- avg_elevation_alphabet = sub( shl( no_theta_masa[bits_direction_masa[diff_idx_min] - 3], 1 ), 1 );
- avg_azimuth_alphabet = no_phi_masa[bits_direction_masa[diff_idx_min] - 1][0]; /* average azimuth is quantized on the equatorial plane */
+ avg_elevation_alphabet = sub( shl( no_theta_masa[bits_direction_masa[diff_idx_min] - 3], 1 ), 1 ); // Q0
+ avg_azimuth_alphabet = no_phi_masa[bits_direction_masa[diff_idx_min] - 1][0]; /* average azimuth is quantized on the equatorial plane Q0*/
move16();
}
- no_th = no_theta_masa[bits_direction_masa[diff_idx_min] - 3];
+ no_th = no_theta_masa[bits_direction_masa[diff_idx_min] - 3]; // Q0
move16();
FOR( i = 0; i < no_th; i++ )
{
- theta_cb[i] = imult1616( i, round_fx( delta_theta_masa_fx[bits_direction_masa[diff_idx_min] - 3] ) );
+ theta_cb[i] = imult1616( i, round_fx( delta_theta_masa_fx[bits_direction_masa[diff_idx_min] - 3] ) ); // Q6
move16();
}
@@ -2444,13 +2444,13 @@ static Word16 ivas_qmetadata_entropy_encode_dir_fx(
IF( avg_elevation < 0 )
{
- abs_theta = L_negate( avg_elevation );
+ abs_theta = L_negate( avg_elevation ); // Q22
sign_th = -1;
move16();
}
ELSE
{
- abs_theta = avg_elevation;
+ abs_theta = avg_elevation; // Q22
move32();
sign_th = 1;
move16();
@@ -2477,7 +2477,7 @@ static Word16 ivas_qmetadata_entropy_encode_dir_fx(
// avg_elevation *= sign_th;
if ( sign_th < 0 )
{
- avg_elevation = L_negate( avg_elevation );
+ avg_elevation = L_negate( avg_elevation ); // Q22
}
}
@@ -2512,11 +2512,11 @@ static Word16 ivas_qmetadata_entropy_encode_dir_fx(
move16();
IF( NE_32( q_direction->cfg.mc_ls_setup, MC_LS_SETUP_INVALID ) )
{
- elevation_bits_ec = ivas_qmetadata_encode_quasi_uniform_length( avg_elevation_index, avg_elevation_alphabet );
+ elevation_bits_ec = ivas_qmetadata_encode_quasi_uniform_length_fx( avg_elevation_index, avg_elevation_alphabet );
}
ELSE
{
- elevation_bits_ec = ivas_qmetadata_encode_quasi_uniform_length( ivas_qmetadata_reorder_generic_fx( sub( avg_elevation_index, shr( avg_elevation_alphabet, 1 ) ) ), avg_elevation_alphabet );
+ elevation_bits_ec = ivas_qmetadata_encode_quasi_uniform_length_fx( ivas_qmetadata_reorder_generic_fx( sub( avg_elevation_index, shr( avg_elevation_alphabet, 1 ) ) ), avg_elevation_alphabet );
}
idx = 0;
move16();
@@ -2529,11 +2529,11 @@ static Word16 ivas_qmetadata_entropy_encode_dir_fx(
/* project the quantized average elevation to the same grid as the current sample */
IF( NE_32( q_direction->cfg.mc_ls_setup, MC_LS_SETUP_INVALID ) )
{
- avg_elevation_index_projected = ivas_chan_project_elevation_index_fx( avg_elevation_index, avg_elevation_alphabet, q_direction->band_data[i].elevation_m_alphabet[j] );
+ avg_elevation_index_projected = ivas_chan_project_elevation_index_fx( avg_elevation_index, avg_elevation_alphabet, q_direction->band_data[i].elevation_m_alphabet[j] ); // Q0
}
ELSE
{
- avg_elevation_index_projected = ivas_dirac_project_elevation_index_fx( avg_elevation_index, avg_elevation_alphabet, q_direction->band_data[i].elevation_m_alphabet[j] );
+ avg_elevation_index_projected = ivas_dirac_project_elevation_index_fx( avg_elevation_index, avg_elevation_alphabet, q_direction->band_data[i].elevation_m_alphabet[j] ); // Q0
}
IF( NE_32( q_direction->cfg.mc_ls_setup, MC_LS_SETUP_INVALID ) )
@@ -2586,23 +2586,23 @@ static Word16 ivas_qmetadata_entropy_encode_dir_fx(
}
ELSE
{
- gr_param_elevation = ivas_qmetadata_get_optimal_gr_param_fx( dist_elevation_indexes, idx, 4, &gr_size_elevation );
+ gr_param_elevation = ivas_qmetadata_get_optimal_gr_param_fx( dist_elevation_indexes, idx, 4, &gr_size_elevation ); // Q0
egr_size_elevation = 0;
move16();
FOR( i = 0; i < idx; i++ )
{
- egr_size_elevation = add( egr_size_elevation, ivas_qmetadata_encode_extended_gr_length( dist_elevation_indexes[i], dist_elevation_alphabets[i], gr_param_elevation ) );
+ egr_size_elevation = add( egr_size_elevation, ivas_qmetadata_encode_extended_gr_length_fx( dist_elevation_indexes[i], dist_elevation_alphabets[i], gr_param_elevation ) ); // Q0
}
}
- elevation_bits_ec = add( elevation_bits_ec, add( ivas_qmetadata_encode_quasi_uniform_length( gr_param_elevation, 4 + 1 ), egr_size_elevation ) );
+ elevation_bits_ec = add( elevation_bits_ec, add( ivas_qmetadata_encode_quasi_uniform_length_fx( gr_param_elevation, 4 + 1 ), egr_size_elevation ) ); // Q0
IF( LT_16( elevation_bits_ec, elevation_bits_ec_best ) )
{
- elevation_bits_ec_best = elevation_bits_ec;
+ elevation_bits_ec_best = elevation_bits_ec; // Q0
move16();
- avg_elevation_index_best = avg_elevation_index;
+ avg_elevation_index_best = avg_elevation_index; // Q0
move16();
- gr_param_elevation_best = gr_param_elevation;
+ gr_param_elevation_best = gr_param_elevation; // Q0
move16();
FOR( idx = 0; idx < dist_count; idx++ )
{
@@ -2642,7 +2642,7 @@ static Word16 ivas_qmetadata_entropy_encode_dir_fx(
avg_azimuth_index = (UWord16) ( add( avg_azimuth_index, avg_azimuth_alphabet ) % avg_azimuth_alphabet );
all_zero_dist_azimuth_indexes = 1;
move16();
- azimuth_bits_ec = ivas_qmetadata_encode_quasi_uniform_length( ivas_qmetadata_reorder_generic_fx( sub( avg_azimuth_index, shr( avg_azimuth_alphabet, 1 ) ) ), avg_azimuth_alphabet );
+ azimuth_bits_ec = ivas_qmetadata_encode_quasi_uniform_length_fx( ivas_qmetadata_reorder_generic_fx( sub( avg_azimuth_index, shr( avg_azimuth_alphabet, 1 ) ) ), avg_azimuth_alphabet );
idx = 0;
move16();
@@ -2724,11 +2724,11 @@ static Word16 ivas_qmetadata_entropy_encode_dir_fx(
move16();
FOR( i = 0; i < idx; i++ )
{
- egr_size_azimuth = add( egr_size_azimuth, ivas_qmetadata_encode_extended_gr_length( dist_azimuth_indexes[i], dist_azimuth_alphabets[i], gr_param_azimuth ) );
+ egr_size_azimuth = add( egr_size_azimuth, ivas_qmetadata_encode_extended_gr_length_fx( dist_azimuth_indexes[i], dist_azimuth_alphabets[i], gr_param_azimuth ) );
}
}
- azimuth_bits_ec = add( azimuth_bits_ec, add( ivas_qmetadata_encode_quasi_uniform_length( gr_param_azimuth, 5 + 1 ), egr_size_azimuth ) );
+ azimuth_bits_ec = add( azimuth_bits_ec, add( ivas_qmetadata_encode_quasi_uniform_length_fx( gr_param_azimuth, 5 + 1 ), egr_size_azimuth ) );
IF( LT_16( azimuth_bits_ec, azimuth_bits_ec_best ) )
{
@@ -2778,7 +2778,7 @@ static Word16 ivas_qmetadata_entropy_encode_dir_fx(
{
FOR( j = 0; j < nblocks; j++ )
{
- ivas_qmetadata_encode_quasi_uniform( hMetaData, q_direction->band_data[i].azimuth_index[j], q_direction->band_data[i].azimuth_m_alphabet[j] );
+ ivas_qmetadata_encode_quasi_uniform_fx( hMetaData, q_direction->band_data[i].azimuth_index[j], q_direction->band_data[i].azimuth_m_alphabet[j] );
}
}
}
@@ -2797,28 +2797,28 @@ static Word16 ivas_qmetadata_entropy_encode_dir_fx(
/* encode the ExtendedGR part for elevation */
IF( NE_32( q_direction->cfg.mc_ls_setup, MC_LS_SETUP_INVALID ) )
{
- ivas_qmetadata_encode_quasi_uniform( hMetaData, avg_elevation_index_best, avg_elevation_alphabet );
+ ivas_qmetadata_encode_quasi_uniform_fx( hMetaData, avg_elevation_index_best, avg_elevation_alphabet );
}
ELSE
{
- ivas_qmetadata_encode_quasi_uniform( hMetaData, ivas_qmetadata_reorder_generic_fx( sub( avg_elevation_index_best, shr( avg_elevation_alphabet, 1 ) ) ), avg_elevation_alphabet );
+ ivas_qmetadata_encode_quasi_uniform_fx( hMetaData, ivas_qmetadata_reorder_generic_fx( sub( avg_elevation_index_best, shr( avg_elevation_alphabet, 1 ) ) ), avg_elevation_alphabet );
}
- ivas_qmetadata_encode_quasi_uniform( hMetaData, gr_param_elevation_best, 4 + 1 );
+ ivas_qmetadata_encode_quasi_uniform_fx( hMetaData, gr_param_elevation_best, 4 + 1 );
IF( NE_16( gr_param_elevation_best, 4 ) ) /* not all zero */
{
FOR( idx = 0; idx < dist_count; idx++ )
{
- ivas_qmetadata_encode_extended_gr( hMetaData, dist_elevation_indexes_best[idx], dist_elevation_alphabets[idx], gr_param_elevation_best );
+ ivas_qmetadata_encode_extended_gr_fx( hMetaData, dist_elevation_indexes_best[idx], dist_elevation_alphabets[idx], gr_param_elevation_best );
}
}
}
/* encode the ExtendedGR part for azimuth */
- ivas_qmetadata_encode_quasi_uniform( hMetaData, ivas_qmetadata_reorder_generic_fx( sub( avg_azimuth_index_best, shr( avg_azimuth_alphabet, 1 ) ) ), avg_azimuth_alphabet );
+ ivas_qmetadata_encode_quasi_uniform_fx( hMetaData, ivas_qmetadata_reorder_generic_fx( sub( avg_azimuth_index_best, shr( avg_azimuth_alphabet, 1 ) ) ), avg_azimuth_alphabet );
- ivas_qmetadata_encode_quasi_uniform( hMetaData, gr_param_azimuth_best, 5 + 1 );
+ ivas_qmetadata_encode_quasi_uniform_fx( hMetaData, gr_param_azimuth_best, 5 + 1 );
IF( NE_16( gr_param_azimuth_best, 5 ) ) /* not all zero */
{
@@ -2830,24 +2830,24 @@ static Word16 ivas_qmetadata_entropy_encode_dir_fx(
{
IF( GT_16( dist_azimuth_indexes_best[idx], 1 ) )
{
- ivas_qmetadata_encode_extended_gr( hMetaData, sub( dist_azimuth_indexes_best[idx], 2 ), dist_azimuth_alphabets[idx], gr_param_azimuth_best );
- bits_gained = add( bits_gained, sub( ivas_qmetadata_encode_extended_gr_length( dist_azimuth_indexes_best[idx], dist_azimuth_alphabets[idx], gr_param_azimuth_best ),
- ivas_qmetadata_encode_extended_gr_length( sub( dist_azimuth_indexes_best[idx], 2 ), dist_azimuth_alphabets[idx], gr_param_azimuth_best ) ) );
+ ivas_qmetadata_encode_extended_gr_fx( hMetaData, sub( dist_azimuth_indexes_best[idx], 2 ), dist_azimuth_alphabets[idx], gr_param_azimuth_best );
+ bits_gained = add( bits_gained, sub( ivas_qmetadata_encode_extended_gr_length_fx( dist_azimuth_indexes_best[idx], dist_azimuth_alphabets[idx], gr_param_azimuth_best ),
+ ivas_qmetadata_encode_extended_gr_length_fx( sub( dist_azimuth_indexes_best[idx], 2 ), dist_azimuth_alphabets[idx], gr_param_azimuth_best ) ) );
}
ELSE IF( EQ_16( dist_azimuth_indexes_best[idx], 1 ) )
{
- ivas_qmetadata_encode_extended_gr( hMetaData, sub( dist_azimuth_indexes_best[idx], 1 ), dist_azimuth_alphabets[idx], gr_param_azimuth_best );
- bits_gained = add( bits_gained, sub( ivas_qmetadata_encode_extended_gr_length( dist_azimuth_indexes_best[idx], dist_azimuth_alphabets[idx], gr_param_azimuth_best ),
- ivas_qmetadata_encode_extended_gr_length( sub( dist_azimuth_indexes_best[idx], 1 ), dist_azimuth_alphabets[idx], gr_param_azimuth_best ) ) );
+ ivas_qmetadata_encode_extended_gr_fx( hMetaData, sub( dist_azimuth_indexes_best[idx], 1 ), dist_azimuth_alphabets[idx], gr_param_azimuth_best );
+ bits_gained = add( bits_gained, sub( ivas_qmetadata_encode_extended_gr_length_fx( dist_azimuth_indexes_best[idx], dist_azimuth_alphabets[idx], gr_param_azimuth_best ),
+ ivas_qmetadata_encode_extended_gr_length_fx( sub( dist_azimuth_indexes_best[idx], 1 ), dist_azimuth_alphabets[idx], gr_param_azimuth_best ) ) );
}
ELSE
{
- ivas_qmetadata_encode_extended_gr( hMetaData, dist_azimuth_indexes_best[idx], dist_azimuth_alphabets[idx], gr_param_azimuth_best );
+ ivas_qmetadata_encode_extended_gr_fx( hMetaData, dist_azimuth_indexes_best[idx], dist_azimuth_alphabets[idx], gr_param_azimuth_best );
}
}
ELSE
{
- ivas_qmetadata_encode_extended_gr( hMetaData, dist_azimuth_indexes_best[idx], dist_azimuth_alphabets[idx], gr_param_azimuth_best );
+ ivas_qmetadata_encode_extended_gr_fx( hMetaData, dist_azimuth_indexes_best[idx], dist_azimuth_alphabets[idx], gr_param_azimuth_best );
}
}
@@ -2866,24 +2866,24 @@ static Word16 ivas_qmetadata_entropy_encode_dir_fx(
{
IF( GT_16( dist_azimuth_indexes_best[idx], 1 ) )
{
- ivas_qmetadata_encode_extended_gr( hMetaData, sub( dist_azimuth_indexes_best[idx], 2 ), dist_azimuth_alphabets[idx], gr_param_azimuth_best );
- bits_gained = add( bits_gained, sub( ivas_qmetadata_encode_extended_gr_length( dist_azimuth_indexes_best[idx], dist_azimuth_alphabets[idx], gr_param_azimuth_best ),
- ivas_qmetadata_encode_extended_gr_length( sub( dist_azimuth_indexes_best[idx], 2 ), dist_azimuth_alphabets[idx], gr_param_azimuth_best ) ) );
+ ivas_qmetadata_encode_extended_gr_fx( hMetaData, sub( dist_azimuth_indexes_best[idx], 2 ), dist_azimuth_alphabets[idx], gr_param_azimuth_best );
+ bits_gained = add( bits_gained, sub( ivas_qmetadata_encode_extended_gr_length_fx( dist_azimuth_indexes_best[idx], dist_azimuth_alphabets[idx], gr_param_azimuth_best ),
+ ivas_qmetadata_encode_extended_gr_length_fx( sub( dist_azimuth_indexes_best[idx], 2 ), dist_azimuth_alphabets[idx], gr_param_azimuth_best ) ) );
}
ELSE IF( EQ_16( dist_azimuth_indexes_best[idx], 1 ) )
{
- ivas_qmetadata_encode_extended_gr( hMetaData, sub( dist_azimuth_indexes_best[idx], 1 ), dist_azimuth_alphabets[idx], gr_param_azimuth_best );
- bits_gained = add( bits_gained, sub( ivas_qmetadata_encode_extended_gr_length( dist_azimuth_indexes_best[idx], dist_azimuth_alphabets[idx], gr_param_azimuth_best ),
- ivas_qmetadata_encode_extended_gr_length( sub( dist_azimuth_indexes_best[idx], 1 ), dist_azimuth_alphabets[idx], gr_param_azimuth_best ) ) );
+ ivas_qmetadata_encode_extended_gr_fx( hMetaData, sub( dist_azimuth_indexes_best[idx], 1 ), dist_azimuth_alphabets[idx], gr_param_azimuth_best );
+ bits_gained = add( bits_gained, sub( ivas_qmetadata_encode_extended_gr_length_fx( dist_azimuth_indexes_best[idx], dist_azimuth_alphabets[idx], gr_param_azimuth_best ),
+ ivas_qmetadata_encode_extended_gr_length_fx( sub( dist_azimuth_indexes_best[idx], 1 ), dist_azimuth_alphabets[idx], gr_param_azimuth_best ) ) );
}
ELSE
{
- ivas_qmetadata_encode_extended_gr( hMetaData, dist_azimuth_indexes_best[idx], dist_azimuth_alphabets[idx], gr_param_azimuth_best );
+ ivas_qmetadata_encode_extended_gr_fx( hMetaData, dist_azimuth_indexes_best[idx], dist_azimuth_alphabets[idx], gr_param_azimuth_best );
}
}
ELSE
{
- ivas_qmetadata_encode_extended_gr( hMetaData, dist_azimuth_indexes_best[idx], dist_azimuth_alphabets[idx], gr_param_azimuth_best );
+ ivas_qmetadata_encode_extended_gr_fx( hMetaData, dist_azimuth_indexes_best[idx], dist_azimuth_alphabets[idx], gr_param_azimuth_best );
}
}
}
@@ -2950,18 +2950,18 @@ static Word16 ivas_qmetadata_raw_encode_dir_fx(
{
IF( hMetaData != NULL )
{
- ivas_qmetadata_encode_quasi_uniform( hMetaData, q_direction->band_data[i].azimuth_index[j], q_direction->band_data[i].azimuth_m_alphabet[j] );
+ ivas_qmetadata_encode_quasi_uniform_fx( hMetaData, q_direction->band_data[i].azimuth_index[j], q_direction->band_data[i].azimuth_m_alphabet[j] );
}
ELSE
{
direction_bits_raw = add( direction_bits_raw,
- ivas_qmetadata_encode_quasi_uniform_length( q_direction->band_data[i].azimuth_index[j], q_direction->band_data[i].azimuth_m_alphabet[j] ) );
+ ivas_qmetadata_encode_quasi_uniform_length_fx( q_direction->band_data[i].azimuth_index[j], q_direction->band_data[i].azimuth_m_alphabet[j] ) );
}
}
}
}
- if ( hMetaData != NULL )
+ IF( hMetaData != NULL )
{
direction_bits_raw = sub( hMetaData->nb_bits_tot, start_bits );
}
@@ -3013,12 +3013,12 @@ static Word16 ivas_qmetadata_get_optimal_gr_param_fx(
}
/*-------------------------------------------------------------------------
- * ivas_qmetadata_encode_extended_gr_length()
+ * ivas_qmetadata_encode_extended_gr_length_fx()
*
*
*------------------------------------------------------------------------*/
Word16
-ivas_qmetadata_encode_extended_gr_length(
+ivas_qmetadata_encode_extended_gr_length_fx(
const UWord16 value,
const UWord16 alphabet_size,
const Word16 gr_param )
@@ -3033,7 +3033,7 @@ ivas_qmetadata_encode_extended_gr_length(
IF( LE_32( msb_alphabet_size, 3 ) )
{
/* EncodeQuasiUniform is always equal or better than Limited GR with up to 3 msb values */
- bits = ivas_qmetadata_encode_quasi_uniform_length( value, alphabet_size );
+ bits = ivas_qmetadata_encode_quasi_uniform_length_fx( value, alphabet_size );
}
ELSE
{
@@ -3048,7 +3048,7 @@ ivas_qmetadata_encode_extended_gr_length(
ELSE
{
lsb = (UWord16) L_and( value, L_sub( L_shl( 1U, gr_param ), 1 ) );
- bits = add( bits, ivas_qmetadata_encode_quasi_uniform_length( lsb, (UWord16) L_sub( alphabet_size, L_shl( L_sub( msb_alphabet_size, 1 ), gr_param ) ) ) );
+ bits = add( bits, ivas_qmetadata_encode_quasi_uniform_length_fx( lsb, (UWord16) L_sub( alphabet_size, L_shl( L_sub( msb_alphabet_size, 1 ), gr_param ) ) ) );
}
}
@@ -3133,11 +3133,11 @@ static Word16 ivas_qmetadata_reorder_azimuth_index_fx(
}
/*-------------------------------------------------------------------------
- * ivas_qmetadata_encode_extended_gr()
+ * ivas_qmetadata_encode_extended_gr_fx()
*
*
*------------------------------------------------------------------------*/
-void ivas_qmetadata_encode_extended_gr(
+void ivas_qmetadata_encode_extended_gr_fx(
BSTR_ENC_HANDLE hMetaData,
const UWord16 value,
const UWord16 alphabet_size,
@@ -3152,7 +3152,7 @@ void ivas_qmetadata_encode_extended_gr(
IF( LE_32( msb_alphabet_size, 3 ) )
{
/* EncodeQuasiUniform is always equal or better than Limited GR with up to 3 msb values */
- ivas_qmetadata_encode_quasi_uniform( hMetaData, value, alphabet_size );
+ ivas_qmetadata_encode_quasi_uniform_fx( hMetaData, value, alphabet_size );
}
ELSE
{
@@ -3175,7 +3175,7 @@ void ivas_qmetadata_encode_extended_gr(
}
ELSE
{
- ivas_qmetadata_encode_quasi_uniform( hMetaData, lsb, (UWord16) L_sub( alphabet_size, L_shl( L_sub( msb_alphabet_size, 1 ), gr_param ) ) );
+ ivas_qmetadata_encode_quasi_uniform_fx( hMetaData, lsb, (UWord16) L_sub( alphabet_size, L_shl( L_sub( msb_alphabet_size, 1 ), gr_param ) ) );
}
}
@@ -3253,7 +3253,7 @@ static Word16 truncGR0_fx(
move32();
data_idx[i] = remap3b[data_idx[i]];
move16();
- bits = add( bits, ivas_qmetadata_encode_extended_gr_length( data_idx[i], 8, 0 ) );
+ bits = add( bits, ivas_qmetadata_encode_extended_gr_length_fx( data_idx[i], 8, 0 ) );
// diff[i] = -st[i] - ct[i] * cosf( PI_OVER_180 * ( data[i] - data_hat[i] ) ); /*(data[i] - data_hat[i])*(data[i] - data_hat[i]);*/
L_temp = L_deposit_h( getCosWord16R2( extract_l( L_shr( Mpy_32_16_1( L_sub( data_fx[i], data_hat_fx[i] ), 91 ), 7 ) ) ) ); // Q31
diff_fx[i] = L_negate( L_add( L_shr( st_fx[i], 1 ), L_shr( Mpy_32_32( ct_fx[i], L_temp ), 1 ) ) ); // Q30
@@ -3269,7 +3269,7 @@ static Word16 truncGR0_fx(
{
IF( GT_32( data_idx[indx[i]], 3 ) )
{
- bits = sub( bits, ivas_qmetadata_encode_extended_gr_length( data_idx[indx[i]], 8, 0 ) );
+ bits = sub( bits, ivas_qmetadata_encode_extended_gr_length_fx( data_idx[indx[i]], 8, 0 ) );
// data_idx[indx[i]] = quantize_phi( data[indx[i]] + 180, 0, &data_hat[indx[i]], 4 );
data_idx[indx[i]] = quantize_phi_enc_fx( L_add( data_fx[indx[i]], DEGREE_180_Q_22 ), 0, &data_hat_fx[indx[i]], 4 );
move16();
@@ -3278,7 +3278,7 @@ static Word16 truncGR0_fx(
move32();
data_idx[indx[i]] = remap2b[data_idx[indx[i]]];
move16();
- bits = add( bits, ivas_qmetadata_encode_extended_gr_length( data_idx[indx[i]], 8, 0 ) );
+ bits = add( bits, ivas_qmetadata_encode_extended_gr_length_fx( data_idx[indx[i]], 8, 0 ) );
// diff[indx[i]] = -st[i] - ct[i] * cosf( PI_OVER_180 * ( data[indx[i]] - data_hat[indx[i]] ) );
L_temp = L_deposit_h( getCosWord16R2( extract_l( L_shr( Mpy_32_16_1( L_sub( data_fx[indx[i]], data_hat_fx[indx[i]] ), 91 ), 7 ) ) ) ); // Q31
@@ -3300,7 +3300,7 @@ static Word16 truncGR0_fx(
IF( GT_16( data_idx[indx[i]], 1 ) )
{
- bits = sub( bits, ivas_qmetadata_encode_extended_gr_length( data_idx[indx[i]], 8, 0 ) );
+ bits = sub( bits, ivas_qmetadata_encode_extended_gr_length_fx( data_idx[indx[i]], 8, 0 ) );
IF( LE_32( L_abs( data_fx[indx[i]] ), 377487360 ) ) // 90 in Q22
{
@@ -3319,7 +3319,7 @@ static Word16 truncGR0_fx(
move32();
}
- bits = add( bits, ivas_qmetadata_encode_extended_gr_length( data_idx[indx[i]], 8, 0 ) );
+ bits = add( bits, ivas_qmetadata_encode_extended_gr_length_fx( data_idx[indx[i]], 8, 0 ) );
// diff[indx[i]] = -st[i] - ct[i] * cosf( PI_OVER_180 * ( data[indx[i]] - data_hat[indx[i]] ) );
L_temp = L_deposit_h( getCosWord16R2( extract_l( L_shr( Mpy_32_16_1( L_sub( data_fx[indx[i]], data_hat_fx[indx[i]] ), 91 ), 7 ) ) ) ); // Q31
@@ -3412,14 +3412,14 @@ static Word16 truncGR0_chan_fx(
{
data_idx[i] = quantize_phi_chan_lbr_fx( data_fx[i], &data_hat_fx[i], 9 );
move16();
- bits = add( bits, ivas_qmetadata_encode_extended_gr_length( data_idx[i], 9, 0 ) );
+ bits = add( bits, ivas_qmetadata_encode_extended_gr_length_fx( data_idx[i], 9, 0 ) );
// diff[i] = -st[i] - ct[i] * cosf( ( data[i] - data_hat[i] ) * PI_OVER_180 );
L_temp = L_deposit_h( getCosWord16R2( extract_l( L_shr( Mpy_32_16_1( L_sub( data_fx[i], data_hat_fx[i] ), 91 ), 7 ) ) ) ); // Q31
diff_fx[i] = L_negate( L_add( L_shr( st_fx[i], 1 ), L_shr( Mpy_32_32( ct_fx[i], L_temp ), 1 ) ) ); // Q30
move32();
}
- WHILE( GT_16( bits, bits_allowed ) )
+ WHILE( ( bits > bits_allowed ) )
{
// min_diff = 1000.0f;
min_diff_fx = 2097152000; // 1000 in Q21
@@ -3454,10 +3454,10 @@ static Word16 truncGR0_chan_fx(
IF( GT_16( idx_crt, -1 ) )
{
- bits = sub( bits, ivas_qmetadata_encode_extended_gr_length( data_idx[idx_crt], 9, 0 ) );
+ bits = sub( bits, ivas_qmetadata_encode_extended_gr_length_fx( data_idx[idx_crt], 9, 0 ) );
data_idx[idx_crt] = quantize_phi_chan_lbr_fx( data_fx[idx_crt], &data_hat_fx[idx_crt], add( data_idx[idx_crt], 1 ) );
move16();
- bits = add( bits, ivas_qmetadata_encode_extended_gr_length( data_idx[idx_crt], 9, 0 ) );
+ bits = add( bits, ivas_qmetadata_encode_extended_gr_length_fx( data_idx[idx_crt], 9, 0 ) );
// diff[idx_crt] = -st[idx_crt] - ct[idx_crt] * cosf( ( data[idx_crt] - data_hat[idx_crt] ) * PI_OVER_180 );
L_temp = L_deposit_h( getCosWord16R2( extract_l( L_shr( Mpy_32_16_1( L_sub( data_fx[idx_crt], data_hat_fx[idx_crt] ), 91 ), 7 ) ) ) ); // Q31
@@ -3481,7 +3481,7 @@ static Word16 truncGR0_chan_fx(
move16();
IF( data_idx[idx_crt] > 0 )
{
- bits = sub( bits, ivas_qmetadata_encode_extended_gr_length( data_idx[idx_crt], 9, 0 ) );
+ bits = sub( bits, ivas_qmetadata_encode_extended_gr_length_fx( data_idx[idx_crt], 9, 0 ) );
data_idx[idx_crt] = 0;
move16();
data_hat_fx[idx_crt] = 0;
@@ -3705,14 +3705,14 @@ static Word16 common_direction_fx(
{
FOR( i = 0; i < len; i++ )
{
- ivas_qmetadata_encode_extended_gr( hMetaData, q_direction->band_data[band_idx].azimuth_index[i], 9, 0 );
+ ivas_qmetadata_encode_extended_gr_fx( hMetaData, q_direction->band_data[band_idx].azimuth_index[i], 9, 0 );
}
}
ELSE
{
FOR( i = 0; i < len; i++ )
{
- ivas_qmetadata_encode_extended_gr( hMetaData, q_direction->band_data[band_idx].azimuth_index[i], 8, 0 );
+ ivas_qmetadata_encode_extended_gr_fx( hMetaData, q_direction->band_data[band_idx].azimuth_index[i], 8, 0 );
}
}
}
@@ -3734,8 +3734,9 @@ static Word16 encode_directions_subband_fx(
const Word16 no_subframes,
const Word16 last_subband,
Word16 *p_diff,
- Word32 *elevation_orig_fx,
- Word32 *azimuth_orig_fx )
+ Word32 *elevation_orig_fx, // Q22
+ Word32 *azimuth_orig_fx // Q22
+)
{
Word16 allowed_bits, use_vq, max_nb_idx, k;
Word16 diff;
@@ -3807,8 +3808,8 @@ static Word16 encode_directions_subband_fx(
IF( last_subband == 0 )
{
- Copy32( elevation_orig_fx, q_direction->band_data[j].elevation_fx, no_subframes );
- Copy32( azimuth_orig_fx, q_direction->band_data[j].azimuth_fx, no_subframes );
+ Copy32( elevation_orig_fx, q_direction->band_data[j].elevation_fx, no_subframes ); // Q22
+ Copy32( azimuth_orig_fx, q_direction->band_data[j].azimuth_fx, no_subframes ); // Q22
joint_encoding_fx( q_direction, j, next_j, coding_subbands, bits_dir0, allowed_bits, hMetaData, &diff );
}
ELSE
@@ -3831,8 +3832,8 @@ static Word16 encode_directions_subband_fx(
ELSE
{
/* there is only joint coding */
- Copy32( elevation_orig_fx, q_direction->band_data[j].elevation_fx, no_subframes );
- Copy32( azimuth_orig_fx, q_direction->band_data[j].azimuth_fx, no_subframes );
+ Copy32( elevation_orig_fx, q_direction->band_data[j].elevation_fx, no_subframes ); // Q22
+ Copy32( azimuth_orig_fx, q_direction->band_data[j].azimuth_fx, no_subframes ); // Q22
IF( last_subband == 0 )
{
@@ -3859,8 +3860,8 @@ static Word16 encode_directions_subband_fx(
{
/* 1 subframe case */
/* there is only joint coding */
- Copy32( elevation_orig_fx, q_direction->band_data[j].elevation_fx, no_subframes );
- Copy32( azimuth_orig_fx, q_direction->band_data[j].azimuth_fx, no_subframes );
+ Copy32( elevation_orig_fx, q_direction->band_data[j].elevation_fx, no_subframes ); // Q22
+ Copy32( azimuth_orig_fx, q_direction->band_data[j].azimuth_fx, no_subframes ); // Q22
IF( last_subband == 0 )
{
@@ -3983,8 +3984,8 @@ static ivas_error requantize_direction_EC_3_fx(
IVAS_QDIRECTION *q_direction,
const Word16 coding_subbands,
BSTR_ENC_HANDLE hMetaData,
- Word32 elevation_orig_fx[MASA_MAXIMUM_CODING_SUBBANDS][MAX_PARAM_SPATIAL_SUBFRAMES],
- Word32 azimuth_orig_fx[MASA_MAXIMUM_CODING_SUBBANDS][MAX_PARAM_SPATIAL_SUBFRAMES],
+ Word32 elevation_orig_fx[MASA_MAXIMUM_CODING_SUBBANDS][MAX_PARAM_SPATIAL_SUBFRAMES], // Q22
+ Word32 azimuth_orig_fx[MASA_MAXIMUM_CODING_SUBBANDS][MAX_PARAM_SPATIAL_SUBFRAMES], // Q22
Word16 *ind_order )
{
/* gradually increase the bits following the performance of the EC layer*/
@@ -4090,7 +4091,7 @@ static ivas_error requantize_direction_EC_3_fx(
{
FOR( k = 0; k < no_subframes; k++ )
{
- ivas_qmetadata_encode_extended_gr( hMetaData, q_direction->band_data[j].azimuth_index[k], q_direction->cfg.mc_ls_setup != MC_LS_SETUP_INVALID ? 9 : 8, 0 );
+ ivas_qmetadata_encode_extended_gr_fx( hMetaData, q_direction->band_data[j].azimuth_index[k], q_direction->cfg.mc_ls_setup != MC_LS_SETUP_INVALID ? 9 : 8, 0 );
}
}
}
@@ -4240,7 +4241,7 @@ static void joint_encoding_fx(
IF( len_data > 0 )
{
- nbits = GR_bits_new( data, no_symb_ele, len_data, MASA_GR_ORD_EL, 1, &GR_ord_elevation );
+ nbits = GR_bits_new_fx( data, no_symb_ele, len_data, MASA_GR_ORD_EL, 1, &GR_ord_elevation );
}
ELSE
{
@@ -4273,9 +4274,9 @@ static void joint_encoding_fx(
nbits = add( nbits, 1 );
}
- nbits = add( nbits, GR_bits_azimuth_context( q_direction->band_data[j].azimuth_index,
- q_direction->band_data[j].azimuth_m_alphabet, q_direction->cfg.nblocks, MASA_GR_ORD_AZ,
- q_direction->band_data[j].bits_sph_idx, &GR_ord_azimuth, &use_context ) );
+ nbits = add( nbits, GR_bits_azimuth_context_fx( q_direction->band_data[j].azimuth_index,
+ q_direction->band_data[j].azimuth_m_alphabet, q_direction->cfg.nblocks, MASA_GR_ORD_AZ,
+ q_direction->band_data[j].bits_sph_idx, &GR_ord_azimuth, &use_context ) );
IF( allowed_bits == 0 )
{
@@ -4507,7 +4508,7 @@ static ivas_error write_ec_direction_fx(
{
bits_crt = hMetaData->nb_bits_tot;
move16();
- ivas_qmetadata_encode_extended_gr( hMetaData, data, qdirection->band_data[j_idx].elevation_m_alphabet[i], GR_ord_elevation );
+ ivas_qmetadata_encode_extended_gr_fx( hMetaData, data, qdirection->band_data[j_idx].elevation_m_alphabet[i], GR_ord_elevation );
nbits = add( nbits, sub( hMetaData->nb_bits_tot, bits_crt ) );
}
}
@@ -4532,7 +4533,7 @@ static ivas_error write_ec_direction_fx(
{
bits_crt = hMetaData->nb_bits_tot;
move16();
- ivas_qmetadata_encode_extended_gr( hMetaData, data, qdirection->band_data[j_idx].azimuth_m_alphabet[i], GR_ord_azimuth );
+ ivas_qmetadata_encode_extended_gr_fx( hMetaData, data, qdirection->band_data[j_idx].azimuth_m_alphabet[i], GR_ord_azimuth );
nbits = add( nbits, sub( hMetaData->nb_bits_tot, bits_crt ) );
}
}
@@ -4562,7 +4563,7 @@ static ivas_error write_ec_direction_fx(
bits_crt = hMetaData->nb_bits_tot;
move16();
maximum_s( qdirection->band_data[j_idx].azimuth_m_alphabet, len, &max_val );
- ivas_qmetadata_encode_extended_gr( hMetaData, min_val, max_val, MASA_GR_ORD_AZ );
+ ivas_qmetadata_encode_extended_gr_fx( hMetaData, min_val, max_val, MASA_GR_ORD_AZ );
nbits = add( nbits, sub( hMetaData->nb_bits_tot, bits_crt ) );
FOR( i = 0; i < len; i++ )
@@ -4572,7 +4573,7 @@ static ivas_error write_ec_direction_fx(
{
bits_crt = hMetaData->nb_bits_tot;
move16();
- ivas_qmetadata_encode_extended_gr( hMetaData, data, qdirection->band_data[j_idx].azimuth_m_alphabet[i], GR_ord_azimuth );
+ ivas_qmetadata_encode_extended_gr_fx( hMetaData, data, qdirection->band_data[j_idx].azimuth_m_alphabet[i], GR_ord_azimuth );
nbits = add( nbits, sub( hMetaData->nb_bits_tot, bits_crt ) );
}
}
@@ -4596,13 +4597,13 @@ static ivas_error write_ec_direction_fx(
case 2:
bits_crt = hMetaData->nb_bits_tot;
move16();
- ivas_qmetadata_encode_extended_gr( hMetaData, data, qdirection->band_data[j_idx].azimuth_m_alphabet[i], MASA_GR_ORD_AZ - 1 );
+ ivas_qmetadata_encode_extended_gr_fx( hMetaData, data, qdirection->band_data[j_idx].azimuth_m_alphabet[i], MASA_GR_ORD_AZ - 1 );
nbits = add( nbits, sub( hMetaData->nb_bits_tot, bits_crt ) );
BREAK;
default:
bits_crt = hMetaData->nb_bits_tot;
move16();
- ivas_qmetadata_encode_extended_gr( hMetaData, data, qdirection->band_data[j_idx].azimuth_m_alphabet[i], MASA_GR_ORD_AZ );
+ ivas_qmetadata_encode_extended_gr_fx( hMetaData, data, qdirection->band_data[j_idx].azimuth_m_alphabet[i], MASA_GR_ORD_AZ );
nbits = add( nbits, sub( hMetaData->nb_bits_tot, bits_crt ) );
BREAK;
}
@@ -4619,7 +4620,7 @@ static ivas_error write_ec_direction_fx(
* Local functions (coherence Q and coding)
*-----------------------------------------------------------------------*/
/*! r: index */
-static UWord64 create_combined_index(
+static UWord64 create_combined_index_fx(
UWord16 *idx_dct, /* i : indexes to combine */
const Word16 len, /* i : number of indexes */
const Word16 *no_cb_vec /* i : how many codewords for each position */
@@ -4665,12 +4666,12 @@ static Word16 encode_coherence_indexesDCT0_fx(
IF( nbits1 > 0 )
{
half_len = shr( len, 1 );
- idx = create_combined_index( idx_dct, half_len, no_cb_vec );
- idx1 = create_combined_index( &idx_dct[half_len], half_len, &no_cb_vec[half_len] );
+ idx = create_combined_index_fx( idx_dct, half_len, no_cb_vec );
+ idx1 = create_combined_index_fx( &idx_dct[half_len], half_len, &no_cb_vec[half_len] );
}
ELSE
{
- idx = create_combined_index( idx_dct, len, no_cb_vec );
+ idx = create_combined_index_fx( idx_dct, len, no_cb_vec );
idx1 = 0;
move16();
}
@@ -4682,7 +4683,7 @@ static Word16 encode_coherence_indexesDCT0_fx(
}
ELSE
{
- // no_idx16 = (int16_t) round_f( ( nbits / 16.0f + 0.5f ) );
+ // no_idx16 = (Word16) round_f( ( nbits / 16.0f + 0.5f ) );
no_idx16 = shr_r( add( nbits, ONE_IN_Q3 ), 4 );
}
@@ -4708,7 +4709,7 @@ static Word16 encode_coherence_indexesDCT0_fx(
}
ELSE
{
- // no_idx16 = (int16_t) round_f( ( nbits1 / 16.0f + 0.5f ) );
+ // no_idx16 = (Word16) round_f( ( nbits1 / 16.0f + 0.5f ) );
no_idx16 = shr_r( add( nbits1, ONE_IN_Q3 ), 4 );
}
@@ -4765,7 +4766,7 @@ static Word16 coherence_coding_length(
{
no_cb = no_cb * no_cv[j];
}
- //*nbits_fr = (int16_t) ceilf( logf( (float) no_cb ) * INV_LOG_2 );
+ //*nbits_fr = (Word16) ceilf( logf( (float) no_cb ) * INV_LOG_2 );
IF( LE_64( no_cb, 1 ) )
{
*nbits_fr = 0;
@@ -4781,7 +4782,7 @@ static Word16 coherence_coding_length(
{
no_cb = no_cb * no_cv[j];
}
- //*nbits_fr1 = (int16_t) ceilf( logf( (float) no_cb ) * INV_LOG_2 );
+ //*nbits_fr1 = (Word16) ceilf( logf( (float) no_cb ) * INV_LOG_2 );
IF( LE_64( no_cb, 1 ) )
{
*nbits_fr1 = 0;
@@ -4799,7 +4800,7 @@ static Word16 coherence_coding_length(
{
no_cb = no_cb * no_cv[j];
}
- //*nbits_fr = (int16_t) ceilf( logf( (float) no_cb ) * INV_LOG_2 );
+ //*nbits_fr = (Word16) ceilf( logf( (float) no_cb ) * INV_LOG_2 );
IF( LE_64( no_cb, 1 ) )
{
*nbits_fr = 0;
@@ -4814,7 +4815,7 @@ static Word16 coherence_coding_length(
}
- minimum_s( (const Word16 *) idx_sur_coh_shift, (int16_t) idx_shift_len, &min_idx );
+ minimum_s( (const Word16 *) idx_sur_coh_shift, (Word16) idx_shift_len, &min_idx );
FOR( j = 0; j < idx_shift_len; j++ )
{
mr_idx[j] = sub( idx_sur_coh_shift[j], min_idx );
@@ -4822,7 +4823,7 @@ static Word16 coherence_coding_length(
no_cv_shift[j] = sub( no_cv_shift[j], min_idx );
move16();
}
- nbits = add( add( min_idx, 1 ), GR_bits_new( mr_idx, no_cv_shift, idx_shift_len, *GR_ord, 1, GR_ord ) );
+ nbits = add( add( min_idx, 1 ), GR_bits_new_fx( mr_idx, no_cv_shift, idx_shift_len, *GR_ord, 1, GR_ord ) );
*p_min_idx = min_idx;
move16();
@@ -4876,7 +4877,7 @@ static Word16 encode_spread_coherence_1sf_fx(
move16();
extra_cv = -1;
move16();
- WHILE( LE_16( tmp, coding_subbands ) )
+ WHILE( ( tmp <= coding_subbands ) )
{
tmp = add( tmp, 6 );
extra_cv = add( extra_cv, 1 );
@@ -4897,7 +4898,7 @@ static Word16 encode_spread_coherence_1sf_fx(
// idx_sp_coh[j] = (uint16_t) roundf( q_direction->coherence_band_data[j].spread_coherence[0] / ( 255.0f / (float) idx_ER ) );
idx_sp_coh[j] = extract_l( Mpy_32_32_r( imult1616( q_direction->coherence_band_data[j].spread_coherence[0], idx_ER ), 8421505 /* 1/255.f in Q31 */ ) );
move16();
- // q_direction->coherence_band_data[j].spread_coherence[0] = (uint8_t) roundf( idx_sp_coh[j] * ( 255.0f / (float) idx_ER ) );
+ // q_direction->coherence_band_data[j].spread_coherence[0] = (UWord8) roundf( idx_sp_coh[j] * ( 255.0f / (float) idx_ER ) );
IF( idx_sp_coh[j] )
{
q_direction->coherence_band_data[j].spread_coherence[0] = (UWord8) idiv1616( imult1616( idx_sp_coh[j], 255 ), idx_ER );
@@ -4966,19 +4967,19 @@ static Word16 encode_spread_coherence_1sf_fx(
/* write max value*/
bits_GR = hMasaMetaData->nb_bits_tot;
move16();
- ivas_qmetadata_encode_extended_gr( hMasaMetaData, add( sub( sub( MASA_MAX_NO_CV_SUR_COH, max_val ), 1 ), extra_cv ), add( MASA_MAX_NO_CV_SUR_COH, extra_cv ), 0 );
+ ivas_qmetadata_encode_extended_gr_fx( hMasaMetaData, add( sub( sub( MASA_MAX_NO_CV_SUR_COH, max_val ), 1 ), extra_cv ), add( MASA_MAX_NO_CV_SUR_COH, extra_cv ), 0 );
nbits = add( nbits, sub( hMasaMetaData->nb_bits_tot, bits_GR ) );
}
IF( nbits_fr1 > 0 )
{
half_coding_subbands = shr( coding_subbands, 1 );
- idx = create_combined_index( idx_sp_coh, half_coding_subbands, no_cv );
- idx1 = create_combined_index( &idx_sp_coh[half_coding_subbands], half_coding_subbands, &no_cv[half_coding_subbands] );
+ idx = create_combined_index_fx( idx_sp_coh, half_coding_subbands, no_cv );
+ idx1 = create_combined_index_fx( &idx_sp_coh[half_coding_subbands], half_coding_subbands, &no_cv[half_coding_subbands] );
}
ELSE
{
- idx = create_combined_index( idx_sp_coh, coding_subbands, no_cv );
+ idx = create_combined_index_fx( idx_sp_coh, coding_subbands, no_cv );
}
// if ( nbits_fr % 16 == 0 )
@@ -4988,7 +4989,7 @@ static Word16 encode_spread_coherence_1sf_fx(
}
ELSE
{
- // no_idx16 = (int16_t) round_f( ( nbits_fr / 16.0f + 0.5f ) );
+ // no_idx16 = (Word16) round_f( ( nbits_fr / 16.0f + 0.5f ) );
no_idx16 = shr_r( add( nbits_fr, ONE_IN_Q3 ), 4 );
}
@@ -5012,7 +5013,7 @@ static Word16 encode_spread_coherence_1sf_fx(
}
ELSE
{
- // no_idx16 = (int16_t) round_f( ( nbits_fr1 / 16.0f + 0.5f ) );
+ // no_idx16 = (Word16) round_f( ( nbits_fr1 / 16.0f + 0.5f ) );
no_idx16 = shr_r( add( nbits_fr1, ONE_IN_Q3 ), 4 );
}
@@ -5044,7 +5045,7 @@ static Word16 encode_spread_coherence_1sf_fx(
/* write the min */
bits_GR = hMasaMetaData->nb_bits_tot;
move16();
- ivas_qmetadata_encode_extended_gr( hMasaMetaData, min_idx, add( MASA_MAX_NO_CV_SUR_COH, extra_cv ), 0 );
+ ivas_qmetadata_encode_extended_gr_fx( hMasaMetaData, min_idx, add( MASA_MAX_NO_CV_SUR_COH, extra_cv ), 0 );
nbits = add( nbits, sub( hMasaMetaData->nb_bits_tot, bits_GR ) );
/* write GR data */
@@ -5052,7 +5053,7 @@ static Word16 encode_spread_coherence_1sf_fx(
{
bits_GR = hMasaMetaData->nb_bits_tot;
move16();
- ivas_qmetadata_encode_extended_gr( hMasaMetaData, mr_idx_sp_coh[j], no_cv_shift[j], GR_ord );
+ ivas_qmetadata_encode_extended_gr_fx( hMasaMetaData, mr_idx_sp_coh[j], no_cv_shift[j], GR_ord );
nbits = add( nbits, sub( hMasaMetaData->nb_bits_tot, bits_GR ) );
}
}
@@ -5118,11 +5119,11 @@ static Word16 encode_surround_coherence_fx(
{
k = add( k, hQMetaData->twoDirBands[j] );
idx16 = s_max( sub( k, 1 ), 0 );
- error_ratio_surr = W_sat_l( W_sub( W_sub( ONE_IN_Q30, q_direction[0].band_data[j].energy_ratio_fx[0] ), W_mult0_32_32( q_direction[1].band_data[idx16].energy_ratio_fx[0], hQMetaData->twoDirBands[j] ) ) );
+ error_ratio_surr = W_sat_l( W_sub( W_sub( ONE_IN_Q30, q_direction[0].band_data[j].energy_ratio_fx[0] ), W_mult0_32_32( q_direction[1].band_data[idx16].energy_ratio_fx[0], hQMetaData->twoDirBands[j] ) ) ); // Q30
}
ELSE
{
- error_ratio_surr = L_sub( ONE_IN_Q30, q_direction[0].band_data[j].energy_ratio_fx[0] );
+ error_ratio_surr = L_sub( ONE_IN_Q30, q_direction[0].band_data[j].energy_ratio_fx[0] ); // Q30
}
IF( error_ratio_surr <= 0 )
@@ -5193,18 +5194,18 @@ static Word16 encode_surround_coherence_fx(
/* write max value*/
bits_GR = hMetaData->nb_bits_tot;
move16();
- ivas_qmetadata_encode_extended_gr( hMetaData, sub( MASA_MAX_NO_CV_SUR_COH - 1, max_val ), MASA_MAX_NO_CV_SUR_COH, 0 );
+ ivas_qmetadata_encode_extended_gr_fx( hMetaData, sub( MASA_MAX_NO_CV_SUR_COH - 1, max_val ), MASA_MAX_NO_CV_SUR_COH, 0 );
nbits = add( nbits, sub( hMetaData->nb_bits_tot, bits_GR ) );
}
IF( nbits_fr1 > 0 )
{
- idx = create_combined_index( idx_sur_coh, half_coding_subbands, no_cv );
- idx1 = create_combined_index( &idx_sur_coh[half_coding_subbands], half_coding_subbands, &no_cv[half_coding_subbands] );
+ idx = create_combined_index_fx( idx_sur_coh, half_coding_subbands, no_cv );
+ idx1 = create_combined_index_fx( &idx_sur_coh[half_coding_subbands], half_coding_subbands, &no_cv[half_coding_subbands] );
}
ELSE
{
- idx = create_combined_index( idx_sur_coh, coding_subbands, no_cv );
+ idx = create_combined_index_fx( idx_sur_coh, coding_subbands, no_cv );
}
// if ( nbits_fr % 16 == 0 )
@@ -5214,7 +5215,7 @@ static Word16 encode_surround_coherence_fx(
}
ELSE
{
- // no_idx16 = (int16_t) round_f( ( nbits_fr / 16.0f + 0.5f ) );
+ // no_idx16 = (Word16) round_f( ( nbits_fr / 16.0f + 0.5f ) );
no_idx16 = shr_r( add( nbits_fr, ONE_IN_Q3 ), 4 );
}
@@ -5238,7 +5239,7 @@ static Word16 encode_surround_coherence_fx(
}
ELSE
{
- // no_idx16 = (int16_t) round_f( ( nbits_fr1 / 16.0f + 0.5f ) );
+ // no_idx16 = (Word16) round_f( ( nbits_fr1 / 16.0f + 0.5f ) );
no_idx16 = shr_r( add( nbits_fr1, ONE_IN_Q3 ), 4 );
}
@@ -5271,7 +5272,7 @@ static Word16 encode_surround_coherence_fx(
/* write the min */
bits_GR = hMetaData->nb_bits_tot;
move16();
- ivas_qmetadata_encode_extended_gr( hMetaData, min_idx, MASA_MAX_NO_CV_SUR_COH, 0 );
+ ivas_qmetadata_encode_extended_gr_fx( hMetaData, min_idx, MASA_MAX_NO_CV_SUR_COH, 0 );
nbits = add( nbits, sub( hMetaData->nb_bits_tot, bits_GR ) );
/* write GR data */
@@ -5280,7 +5281,7 @@ static Word16 encode_surround_coherence_fx(
bits_GR = hMetaData->nb_bits_tot;
move16();
- ivas_qmetadata_encode_extended_gr( hMetaData, mr_idx_sur_coh[j], no_cv_shift[j], GR_ord );
+ ivas_qmetadata_encode_extended_gr_fx( hMetaData, mr_idx_sur_coh[j], no_cv_shift[j], GR_ord );
nbits = add( nbits, sub( hMetaData->nb_bits_tot, bits_GR ) );
}
@@ -5303,7 +5304,7 @@ static Word16 encode_surround_coherence_hr_fx(
UWord64 idx, idx1;
Word16 no_idx16;
Word16 no_cv[MASA_MAXIMUM_CODING_SUBBANDS];
- Word32 error_ratio_surr;
+ Word32 error_ratio_surr; // Q30
IVAS_QDIRECTION *q_direction;
Word16 half_coding_subbands, nbits_fr1, coding_subbands;
Word16 all_coherence_zero;
@@ -5343,15 +5344,15 @@ static Word16 encode_surround_coherence_hr_fx(
{
k = add( k, hQMetaData->twoDirBands[j] );
idx16 = s_max( sub( k, 1 ), 0 );
- error_ratio_surr = L_sub( ONE_IN_Q30, q_direction[0].band_data[j].energy_ratio_fx[sf] );
+ error_ratio_surr = L_sub( ONE_IN_Q30, q_direction[0].band_data[j].energy_ratio_fx[sf] ); // Q30
IF( hQMetaData->twoDirBands[j] )
{
- error_ratio_surr = L_sub( error_ratio_surr, q_direction[1].band_data[idx16].energy_ratio_fx[sf] );
+ error_ratio_surr = L_sub( error_ratio_surr, q_direction[1].band_data[idx16].energy_ratio_fx[sf] ); // Q30
}
}
ELSE
{
- error_ratio_surr = L_sub( ONE_IN_Q30, q_direction[0].band_data[j].energy_ratio_fx[sf] );
+ error_ratio_surr = L_sub( ONE_IN_Q30, q_direction[0].band_data[j].energy_ratio_fx[sf] ); // Q30
}
/* if ( error_ratio_surr <= 0 ) Restricting precision to 7 decimal places */
@@ -5424,18 +5425,18 @@ static Word16 encode_surround_coherence_hr_fx(
/* write max value*/
bits_GR = hMetaData->nb_bits_tot;
move16();
- ivas_qmetadata_encode_extended_gr( hMetaData, sub( MASA_MAX_NO_CV_SUR_COH - 1, max_val ), MASA_MAX_NO_CV_SUR_COH, 0 );
+ ivas_qmetadata_encode_extended_gr_fx( hMetaData, sub( MASA_MAX_NO_CV_SUR_COH - 1, max_val ), MASA_MAX_NO_CV_SUR_COH, 0 );
nbits = add( nbits, sub( hMetaData->nb_bits_tot, bits_GR ) );
}
IF( nbits_fr1 > 0 )
{
- idx = create_combined_index( idx_sur_coh, half_coding_subbands, no_cv );
- idx1 = create_combined_index( &idx_sur_coh[half_coding_subbands], half_coding_subbands, &no_cv[half_coding_subbands] );
+ idx = create_combined_index_fx( idx_sur_coh, half_coding_subbands, no_cv );
+ idx1 = create_combined_index_fx( &idx_sur_coh[half_coding_subbands], half_coding_subbands, &no_cv[half_coding_subbands] );
}
ELSE
{
- idx = create_combined_index( idx_sur_coh, coding_subbands, no_cv );
+ idx = create_combined_index_fx( idx_sur_coh, coding_subbands, no_cv );
}
IF( nbits_fr % 16 == 0 )
@@ -5497,7 +5498,7 @@ static Word16 encode_surround_coherence_hr_fx(
/* write the min */
bits_GR = hMetaData->nb_bits_tot;
move16();
- ivas_qmetadata_encode_extended_gr( hMetaData, min_idx, MASA_MAX_NO_CV_SUR_COH, 0 );
+ ivas_qmetadata_encode_extended_gr_fx( hMetaData, min_idx, MASA_MAX_NO_CV_SUR_COH, 0 );
nbits = add( nbits, sub( hMetaData->nb_bits_tot, bits_GR ) );
/* write GR data */
@@ -5506,7 +5507,7 @@ static Word16 encode_surround_coherence_hr_fx(
bits_GR = hMetaData->nb_bits_tot;
move16();
- ivas_qmetadata_encode_extended_gr( hMetaData, mr_idx_sur_coh[j], no_cv_shift[j], GR_ord );
+ ivas_qmetadata_encode_extended_gr_fx( hMetaData, mr_idx_sur_coh[j], no_cv_shift[j], GR_ord );
nbits = add( nbits, sub( hMetaData->nb_bits_tot, bits_GR ) );
}
@@ -5527,10 +5528,10 @@ static Word16 encode_surround_coherence_hr_fx(
/*! r: quantized value */
static Word32 quantize_DCT_0_coh_fx( // o:Q21
const Word16 x, /* i : input value Q14 */
- const int16_t j, /* i : subband index */
+ const Word16 j, /* i : subband index */
const Word16 *coherence_cb, /* i : coherence codebook Q14 */
const Word16 delta_var, /* i : azimuth variance threshold Q6 */
- const int16_t no_cb, /* i : maximum number of codewords */
+ const Word16 no_cb, /* i : maximum number of codewords */
IVAS_QDIRECTION *q_direction, /* i : quantized metadata */
UWord16 *idx_x, /* o : codewords index */
Word16 *p_no_cb, /* o : actual number of codewords dependent on energy ratio value */
@@ -5596,11 +5597,11 @@ static Word16 encode_coherence_indexesDCT1_fx(
nbits = 0;
move16();
- nbits = mean_removed_GR_new( idx_dct, MASA_NO_CV_COH1, len, 0, &GR_ord, &av, mr_idx_dct );
+ nbits = mean_removed_GR_new_fx( idx_dct, MASA_NO_CV_COH1, len, 0, &GR_ord, &av, mr_idx_dct );
FOR( i = 0; i < len; i++ )
{
- ivas_qmetadata_encode_extended_gr( hMetaData, mr_idx_dct[i], 2 * MASA_NO_CV_COH1, GR_ord );
+ ivas_qmetadata_encode_extended_gr_fx( hMetaData, mr_idx_dct[i], 2 * MASA_NO_CV_COH1, GR_ord );
}
nbits = add( nbits, len_huf_masa[av] );
@@ -5616,7 +5617,7 @@ static Word16 encode_coherence_indexesDCT1_fx(
* 4D implementation of DCT transform
*-------------------------------------------------------------------*/
static void dct4_transform_fx(
- uint8_t *v, /* i : input 4D vector */
+ UWord8 *v, /* i : input 4D vector */
Word32 *dct_v /* o : output transformed vector Q21 */
)
{
@@ -5629,11 +5630,11 @@ static void dct4_transform_fx(
dct_v[0] = L_add( a, b ); // 0.5f * (a + b);
move32();
- dct_v[1] = L_add( Mpy_32_32_r( 1402911301 /*0.653281482438188f*/, c ), Mpy_32_32_r( 581104888 /*0.270598050073099f*/, d ) );
+ dct_v[1] = L_add( Mpy_32_32_r( 1402911301 /*0.653281482438188f.Q31*/, c ), Mpy_32_32_r( 581104888 /*0.270598050073099f.Q31*/, d ) );
move32();
dct_v[2] = L_sub( a, b ); // 0.5f * (a - b);
move32();
- dct_v[3] = L_sub( Mpy_32_32_r( 581104888 /*0.270598050073099f*/, c ), Mpy_32_32_r( 1402911301 /*0.653281482438188f*/, d ) );
+ dct_v[3] = L_sub( Mpy_32_32_r( 581104888 /*0.270598050073099f.Q31*/, c ), Mpy_32_32_r( 1402911301 /*0.653281482438188f.Q31*/, d ) );
move32();
return;
@@ -5679,7 +5680,7 @@ static Word16 ivas_qmetadata_quantize_coherence_hr_512_fx(
cbsize = shl( 1, bits_coh );
// delta = 256.0f / cbsize;
- delta = div_l( 256, shr( cbsize, 1 ) );
+ delta = div_l( 256, shr( cbsize, 1 ) ); // Q15
FOR( k = 0; k < nblocks; k++ )
{
@@ -5689,7 +5690,7 @@ static Word16 ivas_qmetadata_quantize_coherence_hr_512_fx(
{
idx_coh[j] = usquant_fx( (Word16) ( q_direction->coherence_band_data[j].spread_coherence[k] ), &tmp, shr( delta, 1 ), shr( delta, 1 ) /* Q-1 */, cbsize );
move16();
- q_direction->coherence_band_data[j].spread_coherence[k] = (UWord8) add( imult1616( idx_coh[j], delta ), shr( delta, 1 ) );
+ q_direction->coherence_band_data[j].spread_coherence[k] = (UWord8) add( imult1616( idx_coh[j], delta ), shr( delta, 1 ) /*delta/2*/ ); // Q15
if ( LT_16( idx_coh[j], min_idx ) )
{
min_idx = idx_coh[j];
@@ -5706,8 +5707,8 @@ static Word16 ivas_qmetadata_quantize_coherence_hr_512_fx(
{
idx_coh[j] = sub( idx_coh[j], min_idx );
move16();
- nbits0 = add( nbits0, ivas_qmetadata_encode_extended_gr_length( idx_coh[j], sub( cbsize, min_idx ), 0 ) );
- nbits1 = add( nbits1, ivas_qmetadata_encode_extended_gr_length( idx_coh[j], sub( cbsize, min_idx ), 1 ) );
+ nbits0 = add( nbits0, ivas_qmetadata_encode_extended_gr_length_fx( idx_coh[j], sub( cbsize, min_idx ), 0 ) );
+ nbits1 = add( nbits1, ivas_qmetadata_encode_extended_gr_length_fx( idx_coh[j], sub( cbsize, min_idx ), 1 ) );
}
IF( nbits0 < nbits1 )
{
@@ -5724,7 +5725,7 @@ static Word16 ivas_qmetadata_quantize_coherence_hr_512_fx(
GR_param_av = 1;
move16();
- nbits_av = mean_removed_GR_new( idx_coh, cbsize, nbands, 1, &GR_param_av, &av, mr_idx );
+ nbits_av = mean_removed_GR_new_fx( idx_coh, cbsize, nbands, 1, &GR_param_av, &av, mr_idx );
IF( LT_16( nbits_av, nbits1 ) )
{
@@ -5744,7 +5745,7 @@ static Word16 ivas_qmetadata_quantize_coherence_hr_512_fx(
FOR( j = 0; j < nbands; j++ )
{
- ivas_qmetadata_encode_extended_gr( hMetaData, mr_idx[j], imult1616( 2, cbsize ), GR_param );
+ ivas_qmetadata_encode_extended_gr_fx( hMetaData, mr_idx[j], imult1616( 2, cbsize ), GR_param );
}
}
ELSE
@@ -5760,7 +5761,7 @@ static Word16 ivas_qmetadata_quantize_coherence_hr_512_fx(
FOR( j = 0; j < nbands; j++ )
{
- ivas_qmetadata_encode_extended_gr( hMetaData, idx_coh[j], sub( cbsize, min_idx ), GR_param );
+ ivas_qmetadata_encode_extended_gr_fx( hMetaData, idx_coh[j], sub( cbsize, min_idx ), GR_param );
}
}
}
@@ -5893,7 +5894,7 @@ static Word16 ivas_qmetadata_quantize_coherence_fx(
IF( write_flag )
{
/* quantize first DCT parameter */
- dct_coh[j][0] = quantize_DCT_0_coh_fx( extract_l( L_shr_r( dct_coh[j][0], 7 ) ), j, coherence_cb0_masa_Q14, MASA_DELTA_AZI_DCT0 << Q6, MASA_NO_CV_COH, q_direction, &idx_dct[k], &no_cb_vec[j], hrmasa_flag );
+ dct_coh[j][0] = quantize_DCT_0_coh_fx( extract_l( L_shr_r( dct_coh[j][0], 7 ) ), j, coherence_cb0_masa_Q14, MASA_DELTA_AZI_DCT0 << Q6, MASA_NO_CV_COH, q_direction, &idx_dct[k], &no_cb_vec[j], hrmasa_flag ); // Q21
move32();
}
@@ -5930,7 +5931,7 @@ static Word16 ivas_qmetadata_quantize_coherence_fx(
no_cb = no_cb * no_cb_vec[j];
}
- // nbits = (int16_t) ceilf( logf( (float) no_cb ) * INV_LOG_2 );
+ // nbits = (Word16) ceilf( logf( (float) no_cb ) * INV_LOG_2 );
IF( LE_64( no_cb, 1 ) )
{
nbits = 0;
@@ -5947,7 +5948,7 @@ static Word16 ivas_qmetadata_quantize_coherence_fx(
{
no_cb = no_cb * no_cb_vec[j];
}
- // nbits1 = (int16_t) ceilf( logf( (float) no_cb ) * INV_LOG_2 );
+ // nbits1 = (Word16) ceilf( logf( (float) no_cb ) * INV_LOG_2 );
IF( LE_64( no_cb, 1 ) )
{
nbits1 = 0;
@@ -5968,7 +5969,7 @@ static Word16 ivas_qmetadata_quantize_coherence_fx(
no_cb = no_cb * no_cb_vec[j];
}
- // nbits = (int16_t) ceilf( logf( (float) no_cb ) * INV_LOG_2 );
+ // nbits = (Word16) ceilf( logf( (float) no_cb ) * INV_LOG_2 );
IF( LE_64( no_cb, 1 ) )
{
nbits = 0;
@@ -6064,7 +6065,7 @@ static void ivas_qmetadata_reorder_2dir_bands_fx(
hQMetaData->q_direction[1].band_data[band].spherical_index[sf] = uint16_tmp;
move16();
- fx_tmp = hQMetaData->q_direction[0].band_data[band].azimuth_fx[sf];
+ fx_tmp = hQMetaData->q_direction[0].band_data[band].azimuth_fx[sf]; // Q22
move32();
hQMetaData->q_direction[0].band_data[band].azimuth_fx[sf] = hQMetaData->q_direction[1].band_data[band].azimuth_fx[sf];
move32();
@@ -6073,7 +6074,7 @@ static void ivas_qmetadata_reorder_2dir_bands_fx(
fx_tmp = hQMetaData->q_direction[0].band_data[band].elevation_fx[sf];
move32();
- hQMetaData->q_direction[0].band_data[band].elevation_fx[sf] = hQMetaData->q_direction[1].band_data[band].elevation_fx[sf];
+ hQMetaData->q_direction[0].band_data[band].elevation_fx[sf] = hQMetaData->q_direction[1].band_data[band].elevation_fx[sf]; // Q22
move32();
hQMetaData->q_direction[1].band_data[band].elevation_fx[sf] = fx_tmp;
move32();
@@ -6099,7 +6100,7 @@ static void ivas_qmetadata_reorder_2dir_bands_fx(
{
fx_tmp = hQMetaData->q_direction[0].band_data[band].energy_ratio_fx[0];
move32();
- hQMetaData->q_direction[0].band_data[band].energy_ratio_fx[0] = hQMetaData->q_direction[1].band_data[band].energy_ratio_fx[0];
+ hQMetaData->q_direction[0].band_data[band].energy_ratio_fx[0] = hQMetaData->q_direction[1].band_data[band].energy_ratio_fx[0]; // Q30
move32();
hQMetaData->q_direction[1].band_data[band].energy_ratio_fx[0] = fx_tmp;
move32();
@@ -6153,7 +6154,7 @@ static Word16 write_2dir_info(
move16();
FOR( i = 0; i < k; i++ )
{
- ivas_qmetadata_encode_extended_gr( hMetaData, dif_p[i], 24, 0 );
+ ivas_qmetadata_encode_extended_gr_fx( hMetaData, dif_p[i], 24, 0 );
}
nbits = sub( hMetaData->nb_bits_tot, j );
@@ -6179,7 +6180,7 @@ static void transform_azimuth_dir2_fx(
FOR( b = 0; b < hQMetaData->q_direction[1].cfg.nblocks; b++ )
{
Word64 azimuth;
- azimuth = W_add( W_deposit32_l( L_sub( hQMetaData->q_direction[1].band_data[i].azimuth_fx[b], hQMetaData->q_direction[0].band_data[dir2_bands[i]].azimuth_fx[b] ) ), DEGREE_180_Q_22 );
+ azimuth = W_add( W_deposit32_l( L_sub( hQMetaData->q_direction[1].band_data[i].azimuth_fx[b], hQMetaData->q_direction[0].band_data[dir2_bands[i]].azimuth_fx[b] ) ), DEGREE_180_Q_22 ); // Q22
IF( GE_64( azimuth, DEGREE_180_Q_22 ) )
{
@@ -6227,11 +6228,11 @@ static Word16 divide_GR_orders_fx(
FOR( j = 0; j <= i; j++ )
{
- nb_GR = add( nb_GR, ivas_qmetadata_encode_extended_gr_length( q_idx[j], 100, GR1 ) );
+ nb_GR = add( nb_GR, ivas_qmetadata_encode_extended_gr_length_fx( q_idx[j], 100, GR1 ) );
}
FOR( j = i + 1; j < len; j++ )
{
- nb_GR = add( nb_GR, ivas_qmetadata_encode_extended_gr_length( q_idx[j], 100, GR2 ) );
+ nb_GR = add( nb_GR, ivas_qmetadata_encode_extended_gr_length_fx( q_idx[j], 100, GR2 ) );
}
IF( LT_16( nb_GR, nb_GR_min ) )
@@ -6261,8 +6262,8 @@ static Word16 find_optimal_GR_order_fx(
move16();
FOR( i = 0; i < len; i++ )
{
- nb_GR_0 = add( nb_GR_0, ivas_qmetadata_encode_extended_gr_length( q_idx[i], 100, 0 ) );
- nb_GR_1 = add( nb_GR_1, ivas_qmetadata_encode_extended_gr_length( q_idx[i], 100, 1 ) );
+ nb_GR_0 = add( nb_GR_0, ivas_qmetadata_encode_extended_gr_length_fx( q_idx[i], 100, 0 ) );
+ nb_GR_1 = add( nb_GR_1, ivas_qmetadata_encode_extended_gr_length_fx( q_idx[i], 100, 1 ) );
}
IF( LT_16( nb_GR_0, nb_GR_1 ) )
@@ -6410,7 +6411,7 @@ static Word16 write_stream_dct_coeffs_omasa_fx(
update_needed = 0;
move16();
move16();
- WHILE( GE_16( len_stream, 8 ) && GT_16( nb_GR_min, max_bits ) && GE_16( changed, 1 ) )
+ WHILE( ( len_stream >= 8 ) && ( nb_GR_min > max_bits ) && ( changed >= 1 ) )
{
test();
test();
@@ -6427,19 +6428,19 @@ static Word16 write_stream_dct_coeffs_omasa_fx(
{
changed = 1;
move16();
- nb_GR_min = sub( nb_GR_min, ivas_qmetadata_encode_extended_gr_length( q_idx[j], 100, GR2 ) );
+ nb_GR_min = sub( nb_GR_min, ivas_qmetadata_encode_extended_gr_length_fx( q_idx[j], 100, GR2 ) );
q_idx[j] = sub( q_idx[j], 2 );
move16();
- nb_GR_min = add( nb_GR_min, ivas_qmetadata_encode_extended_gr_length( q_idx[j], 100, GR2 ) );
+ nb_GR_min = add( nb_GR_min, ivas_qmetadata_encode_extended_gr_length_fx( q_idx[j], 100, GR2 ) );
}
ELSE
{
changed = 1;
move16();
- nb_GR_min = sub( nb_GR_min, ivas_qmetadata_encode_extended_gr_length( q_idx[j], 100, GR1 ) );
+ nb_GR_min = sub( nb_GR_min, ivas_qmetadata_encode_extended_gr_length_fx( q_idx[j], 100, GR1 ) );
q_idx[j] = sub( q_idx[j], 2 );
move16();
- nb_GR_min = add( nb_GR_min, ivas_qmetadata_encode_extended_gr_length( q_idx[j], 100, 0 ) );
+ nb_GR_min = add( nb_GR_min, ivas_qmetadata_encode_extended_gr_length_fx( q_idx[j], 100, 0 ) );
}
}
ELSE IF( EQ_16( q_idx[j], 1 ) )
@@ -6448,20 +6449,20 @@ static Word16 write_stream_dct_coeffs_omasa_fx(
{
changed = 1;
move16();
- nb_GR_min = sub( nb_GR_min, ivas_qmetadata_encode_extended_gr_length( q_idx[j], 100, GR2 ) );
+ nb_GR_min = sub( nb_GR_min, ivas_qmetadata_encode_extended_gr_length_fx( q_idx[j], 100, GR2 ) );
q_idx[j] = sub( q_idx[j], 1 );
move16();
- nb_GR_min = add( nb_GR_min, ivas_qmetadata_encode_extended_gr_length( q_idx[j], 100, GR2 ) );
+ nb_GR_min = add( nb_GR_min, ivas_qmetadata_encode_extended_gr_length_fx( q_idx[j], 100, GR2 ) );
}
ELSE
{
changed = 1;
move16();
- nb_GR_min = sub( nb_GR_min, ivas_qmetadata_encode_extended_gr_length( q_idx[j], 100, GR1 ) );
+ nb_GR_min = sub( nb_GR_min, ivas_qmetadata_encode_extended_gr_length_fx( q_idx[j], 100, GR1 ) );
q_idx[j] = sub( q_idx[j], 1 );
move16();
- nb_GR_min = add( nb_GR_min, ivas_qmetadata_encode_extended_gr_length( q_idx[j], 100, 0 ) );
+ nb_GR_min = add( nb_GR_min, ivas_qmetadata_encode_extended_gr_length_fx( q_idx[j], 100, 0 ) );
}
}
IF( LT_16( nb_GR_min, max_bits ) )
@@ -6495,12 +6496,12 @@ static Word16 write_stream_dct_coeffs_omasa_fx(
/* write GR data */
FOR( i = 1; i <= i_min; i++ )
{
- ivas_qmetadata_encode_extended_gr( hMetaData, q_idx[i], 100, GR1 );
+ ivas_qmetadata_encode_extended_gr_fx( hMetaData, q_idx[i], 100, GR1 );
}
FOR( i = i_min + 1; i < len_stream; i++ )
{
- ivas_qmetadata_encode_extended_gr( hMetaData, q_idx[i], 100, GR2 );
+ ivas_qmetadata_encode_extended_gr_fx( hMetaData, q_idx[i], 100, GR2 );
}
}
ELSE
@@ -6511,7 +6512,7 @@ static Word16 write_stream_dct_coeffs_omasa_fx(
nb_bits = add( nb_bits, 1 );
FOR( i = 1; i < len_stream; i++ )
{
- ivas_qmetadata_encode_extended_gr( hMetaData, q_idx[i], 100, GR1 );
+ ivas_qmetadata_encode_extended_gr_fx( hMetaData, q_idx[i], 100, GR1 );
}
}
@@ -6542,7 +6543,6 @@ void ivas_omasa_encode_masa_to_total_fx(
Word16 q_idx[MAX_PARAM_SPATIAL_SUBFRAMES * MASA_FREQUENCY_BANDS];
Word32 dct_data_tmp[MAX_PARAM_SPATIAL_SUBFRAMES * MASA_FREQUENCY_BANDS];
Word32 dct_data[MAX_PARAM_SPATIAL_SUBFRAMES * MASA_FREQUENCY_BANDS];
- Word16 dct_data_e = 0, dct_data_tmp_e, q_dct_data_e;
Word16 bits_pos, nb_bits;
Word16 n_streams, len_stream, tmp_e;
Word32 L_tmp;
@@ -6558,7 +6558,7 @@ void ivas_omasa_encode_masa_to_total_fx(
{
FOR( j = 0; j < nblocks; j++ )
{
- data[k] = masa_to_total_energy_ratio[j][i];
+ data[k] = L_shr( masa_to_total_energy_ratio[j][i], Q5 );
move32();
k = add( k, 1 );
}
@@ -6571,42 +6571,42 @@ void ivas_omasa_encode_masa_to_total_fx(
SWITCH( len_stream )
{
case 4:
- matrix_product_mant_exp_fx( dct4_fx, 0 /* Q31 */, nblocks, nblocks, 0, data, 1 /* Q30*/, 1, nblocks, 1, dct_data, &dct_data_e );
+ matrix_product_fx( dct4_fx, nblocks, nblocks, 0, data, 1, nblocks, 1, dct_data );
n_streams = 1;
len_stream = 4;
move16();
BREAK;
case 5:
- matrix_product_mant_exp_fx( dct5_fx, 0 /* Q31 */, nbands, nbands, 0, data, 1 /* Q30 */, 1, nbands, 1, dct_data, &dct_data_e );
+ matrix_product_fx( dct5_fx, nbands, nbands, 0, data, 1, nbands, 1, dct_data );
n_streams = 1;
len_stream = nbands;
move16();
move16();
BREAK;
case 8:
- matrix_product_mant_exp_fx( dct8_fx, 0 /* Q31 */, nbands, nbands, 0, data, 1 /* Q30 */, 1, nbands, 1, dct_data, &dct_data_e );
+ matrix_product_fx( dct8_fx, nbands, nbands, 0, data, 1, nbands, 1, dct_data );
n_streams = 1;
len_stream = nbands;
move16();
BREAK;
case 12:
- matrix_product_mant_exp_fx( dct12_fx, 0 /* Q31 */, nbands, nbands, 0, data, 1 /* Q30 */, 1, nbands, 1, dct_data, &dct_data_e );
+ matrix_product_fx( dct12_fx, nbands, nbands, 0, data, 1, nbands, 1, dct_data );
n_streams = 1;
len_stream = nbands;
move16();
move16();
BREAK;
case 20:
- matrix_product_mant_exp_fx( dct5_fx, 0 /* Q31 */, nbands, nbands, 0, data, 1 /* Q30 */, nblocks, nbands, 1, dct_data_tmp, &dct_data_e );
- matrix_product_mant_exp_fx( dct_data_tmp, dct_data_e, nbands, nblocks, 0, dct4_fx, 0 /* Q31 */, nblocks, nblocks, 1, dct_data, &dct_data_e );
+ matrix_product_fx( dct5_fx, nbands, nbands, 0, data, nblocks, nbands, 1, dct_data_tmp );
+ matrix_product_fx( dct_data_tmp, nbands, nblocks, 0, dct4_fx, nblocks, nblocks, 1, dct_data );
n_streams = 1;
len_stream = imult1616( nbands, nblocks );
move16();
move16();
BREAK;
case 32:
- matrix_product_mant_exp_fx( dct8_fx, 0 /* Q31 */, nbands, nbands, 0, data, 1 /* Q30 */, nblocks, nbands, 1, dct_data_tmp, &dct_data_e );
- matrix_product_mant_exp_fx( dct_data_tmp, dct_data_e, nbands, nblocks, 0, dct4_fx, 0 /* Q31 */, nblocks, nblocks, 1, dct_data, &dct_data_e );
+ matrix_product_fx( dct8_fx, nbands, nbands, 0, data, nblocks, nbands, 1, dct_data_tmp );
+ matrix_product_fx( dct_data_tmp, nbands, nblocks, 0, dct4_fx, nblocks, nblocks, 1, dct_data );
n_streams = nblocks;
len_stream = nbands;
move16();
@@ -6622,7 +6622,7 @@ void ivas_omasa_encode_masa_to_total_fx(
j = imult1616( k, len_stream );
/* quantize with fixed common step */
L_tmp = BASOP_Util_Divide3232_Scale_cadence( dct_data[j], step, &tmp_e );
- tmp_e = add( tmp_e, dct_data_e );
+ tmp_e = add( tmp_e, Q6 );
q_idx[j] = rint_new_fx( L_shr( L_tmp, sub( 15, tmp_e ) ) /* Q16 */ ); // Q0
move16();
@@ -6645,7 +6645,7 @@ void ivas_omasa_encode_masa_to_total_fx(
FOR( i = 1; i < len_stream; i++ )
{
L_tmp = BASOP_Util_Divide3232_Scale_cadence( dct_data[j + i], step, &tmp_e );
- tmp_e = add( tmp_e, dct_data_e );
+ tmp_e = add( tmp_e, Q6 );
q_idx[j + i] = rint_new_fx( L_shr( L_tmp, sub( 15, tmp_e ) ) );
move16();
q_dct_data[j + i] = Mpy_32_16_1( step, shl( q_idx[j + i], 9 ) /* Q9 */ ); // Q25
@@ -6689,50 +6689,38 @@ void ivas_omasa_encode_masa_to_total_fx(
}
}
- q_dct_data_e = 6; // Q25
- move16();
/* inverse DCT2 transform */
SWITCH( len_stream )
{
case 4:
- matrix_product_mant_exp_fx( dct4_fx, 0 /* Q31 */, nblocks, nblocks, 1, q_dct_data, q_dct_data_e, nblocks, 1, 0, dct_data_tmp, &dct_data_tmp_e );
+ matrix_product_q30_fx( dct4_fx, nblocks, nblocks, 1, q_dct_data, nblocks, 1, 0, dct_data_tmp );
Copy32( dct_data_tmp, q_dct_data, nblocks );
- q_dct_data_e = dct_data_tmp_e;
- move16();
BREAK;
case 5:
- matrix_product_mant_exp_fx( dct5_fx, 0 /* Q31 */, nbands, nbands, 1, q_dct_data, q_dct_data_e, nbands, 1, 0, dct_data_tmp, &dct_data_tmp_e );
+ matrix_product_q30_fx( dct5_fx, nbands, nbands, 1, q_dct_data, nbands, 1, 0, dct_data_tmp );
Copy32( dct_data_tmp, q_dct_data, nbands );
- q_dct_data_e = dct_data_tmp_e;
- move16();
BREAK;
case 8:
- matrix_product_mant_exp_fx( dct8_fx, 0 /* Q31 */, nbands, nbands, 1, q_dct_data, q_dct_data_e, nbands, 1, 0, dct_data_tmp, &dct_data_tmp_e );
+ matrix_product_q30_fx( dct8_fx, nbands, nbands, 1, q_dct_data, nbands, 1, 0, dct_data_tmp );
Copy32( dct_data_tmp, q_dct_data, nbands );
- q_dct_data_e = dct_data_tmp_e;
- move16();
BREAK;
case 12:
- matrix_product_mant_exp_fx( dct12_fx, 0 /* Q31 */, nbands, nbands, 1, q_dct_data, q_dct_data_e, nbands, 1, 0, dct_data_tmp, &dct_data_tmp_e );
+ matrix_product_q30_fx( dct12_fx, nbands, nbands, 1, q_dct_data, nbands, 1, 0, dct_data_tmp );
Copy32( dct_data_tmp, q_dct_data, nbands );
- q_dct_data_e = dct_data_tmp_e;
- move16();
BREAK;
case 20:
- matrix_product_mant_exp_fx( dct5_fx, 0 /* Q31 */, nbands, nbands, 1, q_dct_data, q_dct_data_e, nbands, nblocks, 0, dct_data_tmp, &dct_data_tmp_e );
- matrix_product_mant_exp_fx( dct_data_tmp, dct_data_tmp_e, nbands, nblocks, 0, dct4_fx, 0 /* Q31 */, nblocks, nblocks, 0, q_dct_data, &q_dct_data_e ); /* reuse of variable*/
+ matrix_product_fx( dct5_fx, nbands, nbands, 1, q_dct_data, nbands, nblocks, 0, dct_data_tmp );
+ matrix_product_q30_fx( dct_data_tmp, nbands, nblocks, 0, dct4_fx, nblocks, nblocks, 0, q_dct_data ); /* reuse of variable*/
BREAK;
case 32:
- matrix_product_mant_exp_fx( dct8_fx, 0 /* Q31 */, nbands, nbands, 1, q_dct_data, q_dct_data_e, nbands, nblocks, 0, dct_data_tmp, &dct_data_tmp_e );
- matrix_product_mant_exp_fx( dct_data_tmp, dct_data_tmp_e, nbands, nblocks, 0, dct4_fx, 0 /* Q31 */, nblocks, nblocks, 0, q_dct_data, &q_dct_data_e );
+ matrix_product_fx( dct8_fx, nbands, nbands, 1, q_dct_data, nbands, nblocks, 0, dct_data_tmp );
+ matrix_product_q30_fx( dct_data_tmp, nbands, nblocks, 0, dct4_fx, nblocks, nblocks, 0, q_dct_data );
BREAK;
default:
printf( "Incorrect number of coefficients for OMASA.\n" );
BREAK;
}
- scale_sig32( q_dct_data, MAX_PARAM_SPATIAL_SUBFRAMES * MASA_FREQUENCY_BANDS, sub( Q30, sub( 31, q_dct_data_e ) ) ); // Scaling to Q30
-
k = 0;
move16();
FOR( i = 0; i < nblocks; i++ )
@@ -6740,7 +6728,7 @@ void ivas_omasa_encode_masa_to_total_fx(
FOR( j = 0; j < nbands; j++ )
{
masa_to_total_energy_ratio[i][j] = L_max( 0, q_dct_data[k] );
- masa_to_total_energy_ratio[i][j] = L_min( ONE_IN_Q30, masa_to_total_energy_ratio[i][j] );
+ masa_to_total_energy_ratio[i][j] = L_min( ONE_IN_Q30, masa_to_total_energy_ratio[i][j] ); // Q30
move32();
move32();
k = add( k, 1 );
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_rom_enc.h b/lib_enc/ivas_rom_enc.h
index e859dc5e69e75bc0cf2f39d98479c15b3f753862..501965bfa9d90f3e6f7bb510d1a06704df2407b1 100644
--- a/lib_enc/ivas_rom_enc.h
+++ b/lib_enc/ivas_rom_enc.h
@@ -48,16 +48,16 @@ extern const Word32 unclr_mean_td[];
extern const Word32 unclr_scale_td[];
extern const Word32 unclr_coef_td[];
-extern const int16_t xtalk_isel_td[];
+extern const Word16 xtalk_isel_td[];
extern const Word32 xtalk_mean_td[];
extern const Word32 xtalk_scale_td[];
extern const Word32 xtalk_coef_td[];
-extern const int16_t xtalk_isel_dft[];
+extern const Word16 xtalk_isel_dft[];
extern const Word32 xtalk_mean_dft_q15[];
extern const Word32 xtalk_scale_dft_q15[];
extern const Word32 xtalk_coef_dft_q30[];
-extern const int16_t unclr_isel_dft[];
+extern const Word16 unclr_isel_dft[];
extern const Word32 unclr_mean_dft_Q15[];
extern const Word32 unclr_scale_dft_Q15[];
extern const Word32 unclr_coef_dft_Q28[];
@@ -75,9 +75,8 @@ extern const Word32 icbwe_regressionValuesDFT_fx[];
* DFT stereo ROM tables
*----------------------------------------------------------------------------------*/
-extern const int16_t itd_vad_band_tbl[];
+extern const Word16 itd_vad_band_tbl[];
extern const Word32 ild_q_Q25[16];
-extern const int16_t ild_q[];
extern const Word32 Wn_table_fx[50];
extern const Word16 win_ana_8k_fx[STEREO_DFT_OVL_8k];
@@ -101,12 +100,12 @@ extern const Word32 ari_bit_estimate_s17_LC_fx[RANGE_N_CONTEXT][RANGE_N_SYMBOLS]
/*----------------------------------------------------------------------------------*
* ECLVQ Stereo ROM tables
*----------------------------------------------------------------------------------*/
-extern const int16_t log2_1px_table[65];
+extern const Word16 log2_1px_table[65];
extern const Word32 log2TB_Q31[ECSQ_log2TB_SIZE];
extern const Word16 ECSQ_log2_fact_Q10[1 + ECSQ_SEGMENT_SIZE];
-extern const uint16_t ECSQ_tab_param[ECSQ_CONFIG_COUNT][1 + ECSQ_PARAM_COUNT];
-extern const uint16_t *const ECSQ_tab_abs_lsbs[1 + 4];
-extern const uint16_t ECSQ_tab_vals[ECSQ_PARAM_COUNT - 1][1 + ECSQ_TAB_VALS_SIZE];
+extern const UWord16 ECSQ_tab_param[ECSQ_CONFIG_COUNT][1 + ECSQ_PARAM_COUNT];
+extern const UWord16 *const ECSQ_tab_abs_lsbs[1 + 4];
+extern const UWord16 ECSQ_tab_vals[ECSQ_PARAM_COUNT - 1][1 + ECSQ_TAB_VALS_SIZE];
/*----------------------------------------------------------------------------------*
@@ -123,7 +122,7 @@ extern const Word32 Stereo_dmx_wnd_coef_48k_fx[L_FRAME48k];
extern const HUFF_TABLE huff_alpha_table;
extern const HUFF_TABLE huff_beta_table;
-extern const int16_t mc_paramupmix_fb_remix_order[4];
+extern const Word16 mc_paramupmix_fb_remix_order[4];
/*----------------------------------------------------------------------------------*
* ParamMC ROM tables
diff --git a/lib_enc/ivas_rom_enc.c b/lib_enc/ivas_rom_enc_fx.c
similarity index 98%
rename from lib_enc/ivas_rom_enc.c
rename to lib_enc/ivas_rom_enc_fx.c
index 2326c5c8c8822d3e95dd114e3c50445dbc0f7201..e4361b933b537ecf40fe8aaaccb51f6a6b5c9fba 100644
--- a/lib_enc/ivas_rom_enc.c
+++ b/lib_enc/ivas_rom_enc_fx.c
@@ -67,7 +67,7 @@ const Word32 unclr_coef_td[SIZE_UNCLR_ISEL_TD] = /*Q15*/
};
/* UNCLR classifier in DFT stereo: list of selected features */
-const int16_t unclr_isel_dft[SIZE_UNCLR_ISEL_DFT] =
+const Word16 unclr_isel_dft[SIZE_UNCLR_ISEL_DFT] =
{
E_gainILD, E_gainIPD, E_angle_rot, E_g_pred, E_cohSNR, E_d_prodL_prodR, E_sum_xcorr, E_xcorr_itd_value
};
@@ -90,7 +90,7 @@ const Word32 unclr_coef_dft_Q28[SIZE_UNCLR_ISEL_DFT] =
};
/* xtalk clasifier in TD stereo: list of selected features */
-const int16_t xtalk_isel_td[SIZE_XTALK_ISEL_TD] =
+const Word16 xtalk_isel_td[SIZE_XTALK_ISEL_TD] =
{
E_d_clas, E_d_voicing, E_sum_d_LSF, E_d_lepsP_13, E_d_cor_map_sum, E_d_nchar, E_d_non_sta, E_d_sp_div, E_sum_prod, E_tdm_es_em, E_m_corrL_corrR, E_corrEst0, E_corrEst_ncorr, E_corrLagStats0, E_ica_corr_value0, E_diff_corrLM_corrRM, E_tdm_LT_es_em
};
@@ -108,7 +108,7 @@ const Word32 xtalk_coef_td[SIZE_XTALK_ISEL_TD] = /*Q15*/
{
1841, 4353, 3322, -5411, 1061, 2716, -2453, 1046, 45199, -51474, -2431, -2245, 2194, -542, -135853, 99, 18138
};
-const int16_t xtalk_isel_dft[SIZE_XTALK_ISEL_DFT] =
+const Word16 xtalk_isel_dft[SIZE_XTALK_ISEL_DFT] =
{
E_clas, E_gainILD, E_gainIPD, E_angle_rot, E_g_pred, E_d_prodL_prodR, E_sum_xcorr, E_xcorr_itd_value, E_gphat_d_itd2, E_gphat_ratio_m1_m2, E_gphat_m2_m2
};
@@ -127,8 +127,6 @@ const Word32 xtalk_coef_dft_q30[SIZE_XTALK_ISEL_DFT] =
/*----------------------------------------------------------------------------------*
* Stereo IC-BWE ROM tables
*----------------------------------------------------------------------------------*/
-#define FLOAT_2_FIX_Q30(a) ((Word32)(a * 1024.0 * 1024.0 * 1024.0))
-#define FLOAT_2_FIX_Q31(a) ((Word32)(a * 1024.0 * 1024.0 * 1024.0 * 2.0))
/* Q30Value >> Q5 */
const Word32 icbwe_thr_TDM_fx[7] = {-1318855552 >> 5, -1667671424 >> 5, -1072553216 >> 5,
920192448 >> 5, 897910144 >> 5, 936654016 >> 5,
@@ -148,8 +146,8 @@ const Word32 icbwe_regressionValuesDFT_fx[8] = {65221224, 333933696, 1127643648,
* DFT stereo ROM tables
*----------------------------------------------------------------------------------*/
-/* DFT stereo ITD ROM table */
-const int16_t itd_vad_band_tbl[STEREO_DFT_ITD_VAD_BAND_NUM+1] =
+/* DFT stereo ITD ROM table Q0*/
+const Word16 itd_vad_band_tbl[STEREO_DFT_ITD_VAD_BAND_NUM+1] =
{
5, 8, 11, 16, 21, 26, 30, 37, 43, 51, 59,
69, 80, 93, 107, 126, 147, 176, 211, 254, 320
@@ -159,10 +157,6 @@ const Word32 ild_q_Q25[16] =
{
0, 67108864, 134217728, 201326592, 268435456, 335544320, 436207616, 536870912, 637534208, 738197504, 838860800, 1006632960, 1174405120, 1342177280, 1509949440, 1677721600
};
-const int16_t ild_q[16] =
-{
- 0,2,4,6,8,10,13,16,19,22,25,30,35,40,45,50
-};
/* table of values of the analysis window cross-correlation function at 32kHz (stride 8) */
const Word32 Wn_table_fx[50] = /*Q31*/
@@ -176,14 +170,14 @@ const Word32 Wn_table_fx[50] = /*Q31*/
1208316416, 1184339328
};
-
+//Q15
const Word16 win_ana_8k_fx[STEREO_DFT_OVL_8k] = {
3471, 6011, 7759, 9178, 10404, 11497, 12492, 13411, 14268, 15072, 15832, 16554, 17241, 17898, 18527, 19131, 19711, 20271,
20810, 21331, 21834, 22320, 22790, 23245, 23686, 24113, 24526, 24927, 25315, 25691, 26055, 26407, 26749, 27079, 27399,
27708, 28007, 28295, 28574, 28843, 29102, 29352, 29592, 29823, 30045, 30257, 30461, 30656, 30841, 31018, 31186, 31345,
31496, 31638, 31772, 31897, 32013, 32121, 32221, 32312, 32395, 32470, 32536, 32594, 32643, 32684, 32717, 32742, 32759, 32767
};
-
+//Q15
const Word16 win_ana_12k8_fx[STEREO_DFT_OVL_12k8] = {
2744, 4753, 6135, 7259, 8229, 9096, 9887, 10618, 11300, 11943, 12552, 13131, 13685, 14216, 14726, 15218, 15693, 16152,
16598, 17030, 17449, 17857, 18255, 18642, 19019, 19388, 19747, 20098, 20441, 20777, 21105, 21426, 21741, 22048, 22350,
@@ -193,7 +187,7 @@ const Word16 win_ana_12k8_fx[STEREO_DFT_OVL_12k8] = {
31714, 31796, 31874, 31949, 32020, 32088, 32153, 32215, 32273, 32328, 32380, 32429, 32474, 32516, 32555, 32590, 32622,
32652, 32677, 32700, 32719, 32735, 32748, 32758, 32764, 32767
};
-
+//Q15
const Word16 win_ana_16k_fx[STEREO_DFT_OVL_16k] = {
2454, 4251, 5488, 6493, 7361, 8137, 8845, 9500, 10112, 10688, 11234, 11754, 12251, 12729, 13188, 13631, 14059, 14473,
14875, 15266, 15646, 16016, 16377, 16729, 17072, 17408, 17736, 18057, 18372, 18680, 18982, 19278, 19568, 19853, 20133,
@@ -205,7 +199,7 @@ const Word16 win_ana_16k_fx[STEREO_DFT_OVL_16k] = {
32375, 32414, 32452, 32487, 32520, 32551, 32580, 32607, 32632, 32654, 32675, 32693, 32710, 32724, 32737, 32747, 32755,
32762, 32766, 32767
};
-
+//Q15
const Word16 win_ana_32k_fx[STEREO_DFT_OVL_32k] = {
1735, 3006, 3881, 4591, 5206, 5755, 6257, 6720, 7154, 7563, 7951, 8320, 8674, 9013, 9341, 9657, 9962, 10259, 10547,
10827, 11100, 11366, 11626, 11881, 12129, 12373, 12611, 12845, 13075, 13300, 13521, 13739, 13953, 14164, 14371, 14575,
@@ -225,7 +219,7 @@ const Word16 win_ana_32k_fx[STEREO_DFT_OVL_32k] = {
32637, 32649, 32660, 32670, 32680, 32689, 32698, 32706, 32714, 32721, 32728, 32734, 32740, 32745, 32749, 32753, 32757,
32760, 32763, 32765, 32766, 32767, 32767,
};
-
+//Q15
const Word16 win_ana_48k_fx[STEREO_DFT_OVL_MAX] = {
1417, 2454, 3168, 3749, 4251, 4699, 5109, 5488, 5842, 6176, 6493, 6795, 7084, 7361, 7629, 7887, 8137, 8380, 8616, 8845,
9069, 9287, 9500, 9708, 9912, 10112, 10307, 10500, 10688, 10873, 11055, 11234, 11410, 11583, 11754, 11922, 12088, 12251,
@@ -253,6 +247,7 @@ const Word16 win_ana_48k_fx[STEREO_DFT_OVL_MAX] = {
32699, 32705, 32710, 32715, 32720, 32724, 32729, 32733, 32737, 32740, 32744, 32747, 32750, 32753, 32755, 32758, 32760,
32762, 32763, 32765, 32766, 32767, 32767, 32767, 32767
};
+//Q31
const Word32 win_syn_8k_fx[STEREO_DFT_OVL_8k] = {
2552069, 13257920, 28512140, 47194820, 68734296, 92758192, 118992928, 147223104, 177270272, 208980864, 242218768, 276861760, 312796896, 349919776, 388131456,
427338304, 467450272, 508381120, 550047232, 592367232, 635262144, 678654848, 722469312, 766631488, 811068480, 855708672, 900481344, 945317568, 990149120,
@@ -261,7 +256,7 @@ const Word32 win_syn_8k_fx[STEREO_DFT_OVL_8k] = {
1980701440, 2002483840, 2022827776, 2041707136, 2059098624, 2074979712, 2089330176, 2102132224, 2113369344, 2123027840, 2131095296, 2137561472, 2142418176,
2145659392, 2147280896
};
-
+//Q31
const Word32 win_syn_12k8_fx[STEREO_DFT_OVL_12k8] = {
1261002, 6551972, 14094794, 23341214, 34014852, 45938972, 58986220, 73058896, 88077968, 103977504, 120700824, 138198304, 156425504, 175342256, 194911840,
215100336, 235876160, 257209056, 279070880, 301434752, 324274976, 347566784, 371285952, 395409728, 419915296, 444781024, 469985376, 495507360, 521326560,
@@ -273,7 +268,7 @@ const Word32 win_syn_12k8_fx[STEREO_DFT_OVL_12k8] = {
2062192000, 2072117888, 2081447424, 2090175872, 2098299008, 2105812608, 2112713344, 2118997504, 2124662144, 2129704192, 2134121728, 2137912064, 2141073664,
2143604608, 2145504128, 2146770944, 2147404416
};
-
+//Q31
const Word32 win_syn_16k_fx[STEREO_DFT_OVL_16k] = {
902372, 4688386, 10086516, 16705275, 24347740, 32888712, 42238640, 52328808, 63104236, 74519400, 86535432, 99118824, 112239520, 125870888, 139988880, 154570928,
169597088, 185047600, 200904832, 217152048, 233772928, 250752224, 268075536, 285728512, 303697792, 321970304, 340533344, 359374528, 378481760, 397843456,
@@ -287,7 +282,7 @@ const Word32 win_syn_16k_fx[STEREO_DFT_OVL_16k] = {
2092676480, 2099077632, 2105088640, 2110707584, 2115932544, 2120762112, 2125194240, 2129228160, 2132862336, 2136095360, 2138926592, 2141355136, 2143379968,
2145000704, 2146216576, 2147027584, 2147432960
};
-
+//Q31
const Word32 win_syn_32k_fx[STEREO_DFT_OVL_32k] = {
319116, 1657642, 3566755, 5907942, 8612268, 11636355, 14948419, 18525698, 22348862, 26402882, 30674656, 35153448, 39829380, 44694072, 49740016, 54960336, 60348800,
65899616, 71607840, 77468328, 83476984, 89629312, 95921440, 102349712, 108910496, 115600336, 122416448, 129355608, 136415040, 143591712, 150883056, 158286720,
@@ -311,7 +306,7 @@ const Word32 win_syn_32k_fx[STEREO_DFT_OVL_32k] = {
2126240128, 2128257280, 2130174336, 2131991296, 2133708160, 2135324800, 2136840960, 2138256512, 2139571712, 2140785920, 2141899136, 2142911616, 2143823104,
2144633472, 2145342592, 2145950592, 2146457344, 2146862848, 2147166848, 2147369600, 2147470976
};
-
+//Q31
const Word32 win_syn_48k_fx[STEREO_DFT_OVL_MAX] = {
173731, 902372, 1941540, 3216071, 4688386, 6334862, 8138533, 10086516, 12168931, 14377618, 16705275, 19146106, 21695168, 24347740, 27099956, 29947948, 32888712,
35919240, 39036744, 42238640, 45522788, 48886820, 52328808, 55846816, 59439128, 63104236, 66840212, 70645768, 74519400, 78459600, 82465520, 86535432, 90668480,
@@ -345,7 +340,7 @@ const Word32 win_syn_48k_fx[STEREO_DFT_OVL_MAX] = {
2133984512, 2135062400, 2136095360, 2137083776, 2138027648, 2138926592, 2139780992, 2140590464, 2141355136, 2142075008, 2142749952, 2143379968, 2143965184,
2144505344, 2145000704, 2145451008, 2145856256, 2146216576, 2146531840, 2146802304, 2147027584, 2147207680, 2147342720, 2147432960, 2147478016
};
-
+//Q31
const Word32 win_mdct_8k_fx[STEREO_DFT_OVL_8k] = {
24094122, 72270552, 120410264, 168489632, 216483968, 264369408, 312121728, 359716832, 407130912, 454339904, 501320192, 548047936, 594499712, 640652160, 686482048,
731966336, 777081984, 821806336, 866117120, 909991488, 953407808, 996343936, 1038778432, 1080689792, 1122057216, 1162859392, 1203076224, 1242687104, 1281672320,
@@ -360,7 +355,7 @@ const Word32 win_mdct_8k_fx[STEREO_DFT_OVL_8k] = {
*----------------------------------------------------------------------------------*/
/* approximation table for log2(1 + x) in Q10 format, with x in [0, 1] in Q6 format */
-const int16_t log2_1px_table[65] =
+const Word16 log2_1px_table[65] =
{
0, 23, 45, 68, 90, 111, 132, 153, 174, 194, 214, 234, 254, 273, 292, 311,
330, 348, 366, 384, 402, 419, 436, 454, 470, 487, 504, 520, 536, 552, 568, 584,
@@ -376,7 +371,8 @@ const Word16 ECSQ_log2_fact_Q10[1 + ECSQ_SEGMENT_SIZE] =
{
0, 0, 1024, 2647, 4695, 7072, 9719, 12594, 15666
};
-const uint16_t ECSQ_tab_param[ECSQ_CONFIG_COUNT][1 + ECSQ_PARAM_COUNT] =
+//Q0
+const UWord16 ECSQ_tab_param[ECSQ_CONFIG_COUNT][1 + ECSQ_PARAM_COUNT] =
{
{ 16384, 15360, 14336, 13312, 12288, 11264, 10240, 9216, 8192, 7168, 6144, 5120, 4096, 3072, 2048, 1024, 0 }, /* un-optimized (reserved) */
{ 16384, 7090, 365, 171, 73, 38, 21, 13, 9, 7, 6, 5, 4, 3, 2, 1, 0 }, /* 34 kbps target SNR */
@@ -386,8 +382,8 @@ const uint16_t ECSQ_tab_param[ECSQ_CONFIG_COUNT][1 + ECSQ_PARAM_COUNT] =
{ 16384, 6940, 633, 186, 74, 38, 21, 13, 9, 7, 6, 5, 4, 3, 2, 1, 0 }, /* 56 kbps target SNR */
{ 16384, 10548, 1936, 774, 117, 41, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 } /* 56 kbps target bits */
};
-
-const uint16_t ECSQ_tab_vals[ECSQ_PARAM_COUNT - 1][1 + ECSQ_TAB_VALS_SIZE] =
+//Q0
+const UWord16 ECSQ_tab_vals[ECSQ_PARAM_COUNT - 1][1 + ECSQ_TAB_VALS_SIZE] =
{
{ 16384, 9939, 3659, 1349, 499, 186, 71, 29, 14, 8, 6, 5, 4, 3, 2, 1, 0 }, /* param = 0 */
{ 16384, 12760, 7739, 4694, 2847, 1727, 1048, 636, 386, 234, 142, 86, 52, 32, 20, 12, 0 }, /* param = 1 */
@@ -407,31 +403,32 @@ const uint16_t ECSQ_tab_vals[ECSQ_PARAM_COUNT - 1][1 + ECSQ_TAB_VALS_SIZE] =
};
/* table for uniform coding of absolute values in {0, +-1} */
-static const uint16_t ECSQ_tab_abs_1bit[1 + 2] =
+//Q0
+static const UWord16 ECSQ_tab_abs_1bit[1 + 2] =
{
16384, 10922, 0
};
/* table for uniform coding of absolute values in {0, +-1, +-2, +-3} */
-static const uint16_t ECSQ_tab_abs_2bit[1 + 4] =
+static const UWord16 ECSQ_tab_abs_2bit[1 + 4] =
{
16384, 14046, 9364, 4682, 0
};
/* table for uniform coding of absolute values in {0, +-1, ..., +-7} */
-static const uint16_t ECSQ_tab_abs_3bit[1 + 8] =
+static const UWord16 ECSQ_tab_abs_3bit[1 + 8] =
{
16384, 15288, 13104, 10920, 8736, 6552, 4368, 2184, 0
};
/* table for uniform coding of absolute values in {0, +-1, ..., +-15} */
-static const uint16_t ECSQ_tab_abs_4bit[1 + 16] =
+static const UWord16 ECSQ_tab_abs_4bit[1 + 16] =
{
16384, 15870, 14812, 13754, 12696, 11638, 10580, 9522, 8464, 7406, 6348, 5290, 4232, 3174, 2116, 1058, 0
};
/* array of tables for uniform coding of absolute values */
-const uint16_t * const ECSQ_tab_abs_lsbs[1 + 4] =
+const UWord16 * const ECSQ_tab_abs_lsbs[1 + 4] =
{
NULL, ECSQ_tab_abs_1bit, ECSQ_tab_abs_2bit, ECSQ_tab_abs_3bit, ECSQ_tab_abs_4bit
};
@@ -747,7 +744,7 @@ const HUFF_TABLE huff_beta_table =
}
};
-const int16_t mc_paramupmix_fb_remix_order[4] = {0, 1, 2, 3};
+const Word16 mc_paramupmix_fb_remix_order[4] = {0, 1, 2, 3};
/*----------------------------------------------------------------------------------*
* ParamMC ROM tables
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 52c899f08009118c9ce9eb584683339d96dde98b..dd9cb61a0231c005f65b5ad388516755e4a2da62 100644
--- a/lib_enc/ivas_sce_enc.c
+++ b/lib_enc/ivas_sce_enc.c
@@ -177,8 +177,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
@@ -249,11 +247,16 @@ ivas_error ivas_sce_enc_fx(
q_old_wsp = Q15;
move16();
+ Word16 q_fr_bands[2];
error = pre_proc_front_ivas_fx( hSCE, NULL, hSCE->element_brate, nb_bits_metadata, input_frame, 0, old_inp_12k8_fx[0], old_inp_16k_fx[0],
&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, 31, Etot_LR_fx, lf_E_fx, 31, localVAD_HE_SAD, NULL, 31, flag_16k_smc,
+ 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
@@ -261,7 +264,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;
}
@@ -314,7 +317,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 );
@@ -327,7 +330,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 );
}
@@ -348,10 +351,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( 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;
}
@@ -429,7 +432,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( &( 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;
}
@@ -464,7 +467,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;
}
@@ -476,12 +479,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 */
@@ -520,7 +523,7 @@ ivas_error create_evs_sce_enc(
test();
IF( NE_32( st_ivas->hEncoderConfig->ivas_format, MONO_FORMAT ) && EQ_16( sce_id, sub( st_ivas->nSCE, 1 ) ) )
{
- IF( NE_32( ( error = ivas_initialize_MD_bstr_enc( &( 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;
}
@@ -613,12 +616,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*/
)
@@ -642,7 +645,7 @@ void destroy_sce_enc(
}
}
- ivas_destroy_MD_bstr_enc( &( hSCE->hMetaData ) );
+ ivas_destroy_MD_bstr_enc_fx( &( hSCE->hMetaData ) );
free( hSCE );
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 21c876f565ee698627fd695c125579d7b356bf1d..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 );
@@ -1231,7 +1232,7 @@ static Word16 ivas_get_huffman_coded_bs_fx(
FOR( j = pred_offset; j < pred_coeff_dim; j++ )
{
- ivas_huffman_encode( &hMdEnc->huff_coeffs.pred_huff_re[qsi], hMdEnc->spar_md.band_coeffs_idx[i].pred_index_re[j], &code, &len );
+ ivas_huffman_encode_fx( &hMdEnc->huff_coeffs.pred_huff_re[qsi], hMdEnc->spar_md.band_coeffs_idx[i].pred_index_re[j], &code, &len );
IF( GT_16( ( add( hMetaData->nb_bits_tot, len ) ), hMdEnc->spar_md_cfg.max_bits_per_blk ) )
{
return -1;
@@ -1242,7 +1243,7 @@ static Word16 ivas_get_huffman_coded_bs_fx(
Word16 n = imult1616( ndec, sub( ndm, 1 ) );
FOR( j = 0; j < n; j++ )
{
- ivas_huffman_encode( &hMdEnc->huff_coeffs.drct_huff_re[qsi], hMdEnc->spar_md.band_coeffs_idx[i].drct_index_re[j], &code, &len );
+ ivas_huffman_encode_fx( &hMdEnc->huff_coeffs.drct_huff_re[qsi], hMdEnc->spar_md.band_coeffs_idx[i].drct_index_re[j], &code, &len );
IF( GT_16( ( add( hMetaData->nb_bits_tot, len ) ), hMdEnc->spar_md_cfg.max_bits_per_blk ) )
{
return -1;
@@ -1252,7 +1253,7 @@ static Word16 ivas_get_huffman_coded_bs_fx(
FOR( j = 0; j < ndec; j++ )
{
- ivas_huffman_encode( &hMdEnc->huff_coeffs.decd_huff_re[qsi], hMdEnc->spar_md.band_coeffs_idx[i].decd_index_re[j], &code, &len );
+ ivas_huffman_encode_fx( &hMdEnc->huff_coeffs.decd_huff_re[qsi], hMdEnc->spar_md.band_coeffs_idx[i].decd_index_re[j], &code, &len );
IF( GT_16( ( add( hMetaData->nb_bits_tot, len ) ), hMdEnc->spar_md_cfg.max_bits_per_blk ) )
{
return -1;
@@ -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 ) )
@@ -1393,8 +1395,8 @@ static Word16 ivas_get_arith_coded_bs_fx(
ivas_copy_band_coeffs_idx_to_arr( hMdEnc->spar_md_prior.band_coeffs_idx_mapped, nB, symbol_arr_old_re, pred_cell_dims, PRED_COEFF );
}
- arith_result = ivas_arith_encode_cmplx_cell_array( &hMdEnc->arith_coeffs.pred_arith_re[qsi], &hMdEnc->arith_coeffs.pred_arith_re_diff[qsi], pDo_diff, nB,
- symbol_arr_re, symbol_arr_old_re, pred_cell_dims, hMetaData, any_diff, hMdEnc->spar_md_cfg.max_bits_per_blk );
+ arith_result = ivas_arith_encode_cmplx_cell_array_fx( &hMdEnc->arith_coeffs.pred_arith_re[qsi], &hMdEnc->arith_coeffs.pred_arith_re_diff[qsi], pDo_diff, nB,
+ symbol_arr_re, symbol_arr_old_re, pred_cell_dims, hMetaData, any_diff, hMdEnc->spar_md_cfg.max_bits_per_blk );
move16();
IF( arith_result < 0 )
{
@@ -1431,8 +1433,8 @@ static Word16 ivas_get_arith_coded_bs_fx(
}
- arith_result = ivas_arith_encode_cmplx_cell_array( &hMdEnc->arith_coeffs.drct_arith_re[qsi], &hMdEnc->arith_coeffs.drct_arith_re_diff[qsi], pDo_diff, nB,
- symbol_arr_re, symbol_arr_old_re, drct_cell_dims, hMetaData, any_diff, hMdEnc->spar_md_cfg.max_bits_per_blk );
+ arith_result = ivas_arith_encode_cmplx_cell_array_fx( &hMdEnc->arith_coeffs.drct_arith_re[qsi], &hMdEnc->arith_coeffs.drct_arith_re_diff[qsi], pDo_diff, nB,
+ symbol_arr_re, symbol_arr_old_re, drct_cell_dims, hMetaData, any_diff, hMdEnc->spar_md_cfg.max_bits_per_blk );
move16();
IF( arith_result < 0 )
@@ -1447,8 +1449,8 @@ static Word16 ivas_get_arith_coded_bs_fx(
ivas_copy_band_coeffs_idx_to_arr( hMdEnc->spar_md_prior.band_coeffs_idx_mapped, nB, symbol_arr_old_re, decd_cell_dims, DECD_COEFF );
}
- arith_result = ivas_arith_encode_cmplx_cell_array( &hMdEnc->arith_coeffs.decd_arith_re[qsi], &hMdEnc->arith_coeffs.decd_arith_re_diff[qsi], pDo_diff, nB,
- symbol_arr_re, symbol_arr_old_re, decd_cell_dims, hMetaData, any_diff, hMdEnc->spar_md_cfg.max_bits_per_blk );
+ arith_result = ivas_arith_encode_cmplx_cell_array_fx( &hMdEnc->arith_coeffs.decd_arith_re[qsi], &hMdEnc->arith_coeffs.decd_arith_re_diff[qsi], pDo_diff, nB,
+ symbol_arr_re, symbol_arr_old_re, decd_cell_dims, hMetaData, any_diff, hMdEnc->spar_md_cfg.max_bits_per_blk );
move16();
IF( arith_result < 0 )
@@ -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 e9b06d77df8844c24b5fc3cffad5f54006ebbbbc..db72219cd60469b91e9dc3111ddf5ebfce911aed 100644
--- a/lib_enc/ivas_stat_enc.h
+++ b/lib_enc/ivas_stat_enc.h
@@ -85,9 +85,14 @@ typedef struct stereo_itd_data_struct
Word16 prev_sum_nrg_L_lb_fx_e;
Word32 prev_xcorr_lb_fx[STEREO_DFT_XCORR_LB_MAX];
Word16 prev_xcorr_lb_fx_e;
+#ifdef FIX_ISSUE_1092
+ Word32 E_band_n_fx[STEREO_DFT_ITD_VAD_BAND_NUM]; /*E_band_n_exp*/
+ Word16 E_band_n_exp[STEREO_DFT_ITD_VAD_BAND_NUM];
+#else
Word32 E_band_n_fx[STEREO_DFT_ITD_VAD_BAND_NUM]; /*Q0*/
+#endif
Word32 xcorr_smooth_fx[STEREO_DFT_N_32k_ENC];
- Word16 xcorr_smooth_fx_e;
+ Word16 xcorr_smooth_fx_e[STEREO_DFT_N_32k_ENC];
Word32 lp_phat_peak_fx; /* low-pass GCC PHAT peak value */ // Q31
// Word16 q_itd;
Word32 deltaItd_fx[STEREO_DFT_ENC_DFT_NB]; // Q16
@@ -116,15 +121,15 @@ typedef struct dft_ana_struct
/* State of the range encoder */
typedef struct
{
- uint32_t rc_low;
- uint32_t rc_range;
- int16_t rc_cache;
- int16_t rc_carry;
- int16_t rc_carry_count;
+ UWord32 rc_low;
+ UWord32 rc_range;
+ Word16 rc_cache;
+ Word16 rc_carry;
+ Word16 rc_carry_count;
- uint8_t byte_buffer[RANGE_UNI_BUFFER_BYTES_MAX];
- int16_t byte_count;
- int16_t last_byte_bit_count;
+ UWord8 byte_buffer[RANGE_UNI_BUFFER_BYTES_MAX];
+ Word16 byte_count;
+ Word16 last_byte_bit_count;
} RangeUniEncState;
@@ -272,7 +277,7 @@ typedef struct stereo_dft_enc_data_struct
const Word16 *dft_trigo_16k_fx;
const Word16 *dft_trigo_32k_fx;
- Word32 output_mem_res_8k_fx[STEREO_DFT_OVL_8k]; // Q16
+ Word32 output_mem_res_8k_fx[STEREO_DFT_OVL_8k]; // Q15
Word32 res_cod_NRG_M_fx[STEREO_DFT_BAND_MAX]; // Q(31 - res_cod_NRG_M_fx_e[])
Word16 res_cod_NRG_M_fx_e[STEREO_DFT_BAND_MAX];
@@ -289,11 +294,11 @@ typedef struct stereo_dft_enc_data_struct
Word16 past_dot_prod_real_fx_e[STEREO_DFT_NRG_PAST_LEN * STEREO_DFT_BAND_MAX];
Word32 past_dot_prod_imag_fx[STEREO_DFT_NRG_PAST_LEN * STEREO_DFT_BAND_MAX]; // Q(31 - past_dot_prod_imag_fx_e[])
Word16 past_dot_prod_imag_fx_e[STEREO_DFT_NRG_PAST_LEN * STEREO_DFT_BAND_MAX];
- Word32 output_mem_dmx_fx[STEREO_DFT_OVL_MAX]; // Q16
- Word32 output_mem_dmx_12k8_fx[STEREO_DFT_OVL_12k8]; // Q16
- Word32 output_mem_dmx_16k_fx[STEREO_DFT_OVL_16k]; /*can hold 16, 12.8 or 32kHz signals*/ // Q16
- Word32 output_mem_dmx_32k_fx[STEREO_DFT_OVL_32k]; /*can hold 16, 12.8 or 32kHz signals*/ // Q16
- Word32 output_mem_dmx_16k_shb_fx[STEREO_DFT_OVL_16k]; // Q16
+ Word32 output_mem_dmx_fx[STEREO_DFT_OVL_MAX]; // Q15
+ Word32 output_mem_dmx_12k8_fx[STEREO_DFT_OVL_12k8]; // Q15
+ Word32 output_mem_dmx_16k_fx[STEREO_DFT_OVL_16k]; /*can hold 16, 12.8 or 32kHz signals*/ // Q15
+ Word32 output_mem_dmx_32k_fx[STEREO_DFT_OVL_32k]; /*can hold 16, 12.8 or 32kHz signals*/ // Q15
+ Word32 output_mem_dmx_16k_shb_fx[STEREO_DFT_OVL_16k]; // Q15
Word16 input_mem_itd_fx[CPE_CHANNELS][STEREO_DFT_OVL_MAX];
Word16 q_input_mem_itd[CPE_CHANNELS];
Word32 gipd_fx[STEREO_DFT_ENC_DFT_NB]; // Q13
@@ -313,23 +318,23 @@ typedef struct stereo_mdct_enc_data_structure
STEREO_MDCT_BAND_PARAMETERS stbParamsTCX20afterACELP; /* stereo frequency band parameters for transition frames */
/* only intraframe */
- int16_t mdct_stereo_mode[2]; /* mdct stereo mode: LR, MS, band-wise MS */
+ Word16 mdct_stereo_mode[2]; /* mdct stereo mode: LR, MS, band-wise MS */
#ifdef DEBUGGING
- int16_t mdct_stereo_mode_cmdl; /* MDCT stereo mode from command-line */
- int16_t fDualMono; /* force dual mono in MDCT stereo mode */
- int16_t fMSstereo; /* force full-band MS in MDCT stereo mode */
+ Word16 mdct_stereo_mode_cmdl; /* MDCT stereo mode from command-line */
+ Word16 fDualMono; /* force dual mono in MDCT stereo mode */
+ Word16 fMSstereo; /* force full-band MS in MDCT stereo mode */
#endif
- int16_t global_ild[2]; /* Quantized ILD for the whole spectrum */
- int16_t split_ratio; /* Ratio of bitrate (1 to 7), split_ratio = 8 * 1st chn bitrate / (1st + 2nd chn bitrate) */
+ Word16 global_ild[2]; /* Quantized ILD for the whole spectrum */
+ Word16 split_ratio; /* Ratio of bitrate (1 to 7), split_ratio = 8 * 1st chn bitrate / (1st + 2nd chn bitrate) */
- int16_t IGFStereoMode[2]; /* MDCT stereo mode for IGF */
+ Word16 IGFStereoMode[2]; /* MDCT stereo mode for IGF */
ITD_DATA_HANDLE hItd;
DFT_ANA_HANDLE hDft_ana;
- int16_t sw_uncorr;
+ Word16 sw_uncorr;
- int16_t isSBAStereoMode;
+ Word16 isSBAStereoMode;
} STEREO_MDCT_ENC_DATA, *STEREO_MDCT_ENC_DATA_HANDLE;
@@ -395,17 +400,16 @@ typedef struct stereo_td_enc_data_structure
Word16 tdm_SM_modi_flag; /* Flag that indicates to modify ratio */
Word16 tdm_SM_reset_flag; /* Flag that indicates to reset the parameters for SM mode */
- Word16 tdm_FD2LRTD_SW_cnt; /* Count the number of frames following a FD to LRTD switching */
- Word16 tdm_LRTD_flag; /* LRTD stereo mode flag */
- Word16 prev_fr_LRTD_TD_dec; /* At the beginning of a frame, contains the previous LRTD decision that might have been modified during last frame */
- Word16 tdm_inst_ratio_idx; /* Instantaneous correlation ratio index */
- Word16 tdm_last_inst_ratio_idx; /* previous frame instantaneous correlation ratio index */
- Word16 tdm_vad_hangover_cnt; /* Count the number of frames where hangover_cnt >= 5 in both primary and secondary channel */
- Word16 tdm_ini_frame_cnt; /* Count the number of frame to decide how to evaluate the local VAD of primary and secondary channel */
- Word16 tdm_last_LRTD_frame_cnt; /* Count the number of frame since the last LRTD frame */
- Word16 tdm_last_LRTD_PriCh_cnt; /* Count the number of frame since the primary channel changed */
- Word16 flag_skip_DMX; /* flag that indicates whether the TD downmixing is skipped */
- // Word32 tdm_Pri_pitch_buf_fx[NB_SUBFR];
+ Word16 tdm_FD2LRTD_SW_cnt; /* Count the number of frames following a FD to LRTD switching */
+ Word16 tdm_LRTD_flag; /* LRTD stereo mode flag */
+ Word16 prev_fr_LRTD_TD_dec; /* At the beginning of a frame, contains the previous LRTD decision that might have been modified during last frame */
+ Word16 tdm_inst_ratio_idx; /* Instantaneous correlation ratio index */
+ Word16 tdm_last_inst_ratio_idx; /* previous frame instantaneous correlation ratio index */
+ Word16 tdm_vad_hangover_cnt; /* Count the number of frames where hangover_cnt >= 5 in both primary and secondary channel */
+ Word16 tdm_ini_frame_cnt; /* Count the number of frame to decide how to evaluate the local VAD of primary and secondary channel */
+ Word16 tdm_last_LRTD_frame_cnt; /* Count the number of frame since the last LRTD frame */
+ Word16 tdm_last_LRTD_PriCh_cnt; /* Count the number of frame since the primary channel changed */
+ Word16 flag_skip_DMX; /* flag that indicates whether the TD downmixing is skipped */
Word16 tdm_Pri_pitch_buf_fx[NB_SUBFR]; // Q6
} STEREO_TD_ENC_DATA, *STEREO_TD_ENC_DATA_HANDLE;
@@ -452,7 +456,6 @@ typedef struct stereo_tca_enc_data_structure
Word32 C_mem_fx[2 * L_NCSHIFT_DS + 1];
Word16 C_mem_exp[2 * L_NCSHIFT_DS + 1];
Word32 E1_mem_fx, E2_mem_fx;
- // Word16 E1_E2_mem_exp;
Word16 E1_mem_exp;
Word16 E2_mem_exp;
Word32 delay_0_mem_fx[MAX_DELAYREGLEN];
@@ -573,6 +576,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
@@ -589,11 +593,10 @@ typedef struct ivas_stereo_classifier_data_structure
Word32 Etot_up_fx; /* average energy in dB - upper bound */
Word16 Etot_up_e; /* average energy in dB - upper bound */
Word32 relE_buf_fx[UNCLR_L_RELE]; /* running buffer for relative energy Q31 */
- Word16 relE_buf_e; /* running buffer for relative energy Q31 */
Word32 Etot_buf_fx[UNCLR_L_ETOT]; /* running buffer for average energy in dB */
Word16 e_Etot_buf_fx; /* exponent for Etot_buf_fx*/
Word32 relE_0_1_fx; /* relative energy in the current frame normalized to (0,1) Q31 */
- Word32 relE_0_1_LT_fx; // Q31
+ Word32 relE_0_1_LT_fx; /* Q31 */
Word32 unclr_relE_0_1_LT_fx[UNCLR_RC_ORDER]; // Q31
Word32 unclr_wscore_fx; // Q31
Word32 unclr_fv_fx[SSC_MAX_NFEA]; /* UNCLR - feature vector */ // Q15
@@ -645,7 +648,6 @@ typedef struct front_vad_enc
Word16 buffer_12k8_fx[3 * L_FRAME / 2];
Word16 q_mem_decim;
Word16 q_buffer_12k8;
- // Word32 buffer_12k8_fx[3 * L_FRAME / 2]; /* 12k8 signal buffer */
} FRONT_VAD_ENC, *FRONT_VAD_ENC_HANDLE;
@@ -729,9 +731,9 @@ typedef struct ivas_enc_cov_handler_state_t
{
ivas_cov_smooth_state_t *pCov_state;
ivas_cov_smooth_state_t *pCov_dtx_state;
- int16_t num_bins;
- int16_t prior_dtx_present;
- int16_t prior_var_flag;
+ Word16 num_bins;
+ Word16 prior_dtx_present;
+ Word16 prior_var_flag;
Word32 bb_var_lt_fx[FOA_CHANNELS];
} ivas_enc_cov_handler_state_t;
@@ -785,10 +787,6 @@ typedef struct ivas_spar_enc_lib_t
Word32 core_nominal_brate; /* Nominal bitrate for core coding */
FRONT_VAD_ENC_HANDLE hFrontVad; /* front-VAD handle */
ENC_CORE_HANDLE hCoreCoderVAD; /* core-coder handle for front-VAD module */
-#ifndef EVS_FLOAT_ENC
- // ENC_CORE_HANDLE_FX hCoreCoderVAD_fx; /* core coder handle */
-#endif
-
Word16 spar_reconfig_flag;
Word16 front_vad_flag;
Word16 front_vad_dtx_flag;
@@ -859,23 +857,23 @@ typedef struct ivas_omasa_enc_state_structure
Word16 broadband_energy_prev_e; /*exponent for broadband_energy_prev_fx*/
Word16 fade_out_gain_fx[L_FRAME48k]; /*q15*/
Word16 fade_in_gain_fx[L_FRAME48k]; /*q15*/
- uint8_t nbands;
- uint8_t nCodingBands;
- uint8_t nSubframes;
+ UWord8 nbands;
+ UWord8 nCodingBands;
+ UWord8 nSubframes;
/* CLDFB analysis */
- int16_t num_Cldfb_instances;
+ Word16 num_Cldfb_instances;
HANDLE_CLDFB_FILTER_BANK cldfbAnaEnc[MAX_NUM_OBJECTS];
/* DirAC parameter estimation */
- int16_t band_grouping[MASA_FREQUENCY_BANDS + 1];
- int16_t block_grouping[5];
+ Word16 band_grouping[MASA_FREQUENCY_BANDS + 1];
+ Word16 block_grouping[5];
/* diffuseness */
- int16_t index_buffer_intensity;
+ Word16 index_buffer_intensity;
- int16_t prev_selected_object;
- uint8_t changing_object;
+ Word16 prev_selected_object;
+ UWord8 changing_object;
} OMASA_ENC_STATE, *OMASA_ENC_HANDLE;
@@ -912,8 +910,8 @@ typedef struct ivas_masa_dir_align_struct
typedef struct ivas_masa_sync_struct
{
MASA_METADATA_FRAME previous_metadata;
- uint8_t prev_sim_stop;
- uint8_t prev_offset;
+ UWord8 prev_sim_stop;
+ UWord8 prev_offset;
MASA_FRAME_MODE frame_mode;
} MASA_SYNC_STATE, *MASA_SYNC_HANDLE;
@@ -961,15 +959,15 @@ typedef struct ivas_masa_encoder_struct
typedef struct ivas_mcmasa_enc_data_structure
{
- int16_t nbands;
- int16_t nCodingBands;
+ Word16 nbands;
+ Word16 nCodingBands;
/* delay compensation */
Word32 *delay_buffer_lfe[2]; /* Delay buffer for LFE estimation */
- int16_t num_samples_delay_comp;
- int16_t num_slots_delay_comp;
- int16_t offset_comp;
+ Word16 num_samples_delay_comp;
+ Word16 num_slots_delay_comp;
+ Word16 offset_comp;
IVAS_FB_MIXER_HANDLE hFbMixer;
IVAS_FB_MIXER_HANDLE hFbMixerLfe;
@@ -977,12 +975,12 @@ typedef struct ivas_mcmasa_enc_data_structure
/* DirAC parameter estimation */
Word32 **direction_vector_m_fx[DIRAC_NUM_DIMS]; /* Average direction vector */
Word16 **direction_vector_e[DIRAC_NUM_DIMS]; /* Average direction vector */
- int16_t band_grouping[MASA_FREQUENCY_BANDS + 1];
- int16_t block_grouping[5];
+ Word16 band_grouping[MASA_FREQUENCY_BANDS + 1];
+ Word16 block_grouping[5];
/* diffuseness */
- int16_t index_buffer_intensity;
- int8_t no_col_avg_diff;
+ Word16 index_buffer_intensity;
+ Word8 no_col_avg_diff;
Word32 **buffer_intensity_real_fx[DIRAC_NUM_DIMS];
Word16 buffer_intensity_real_q[DIRAC_NO_COL_AVG_DIFF];
Word32 **buffer_intensity_real_vert_fx;
@@ -993,11 +991,11 @@ typedef struct ivas_mcmasa_enc_data_structure
Word32 chnlToFoaEvenMtx_fx[FOA_CHANNELS][MCMASA_MAX_ANA_CHANS];
Word32 ls_azimuth_fx[MCMASA_MAX_ANA_CHANS];
- int16_t leftNearest[MCMASA_MAX_ANA_CHANS];
- int16_t rightNearest[MCMASA_MAX_ANA_CHANS];
- int16_t numHorizontalChannels;
- uint8_t isHorizontalSetup;
- uint8_t combineRatios;
+ Word16 leftNearest[MCMASA_MAX_ANA_CHANS];
+ Word16 rightNearest[MCMASA_MAX_ANA_CHANS];
+ Word16 numHorizontalChannels;
+ UWord8 isHorizontalSetup;
+ UWord8 combineRatios;
Word32 prevMultiChEne_fx;
Word16 prevMultiChEne_e;
@@ -1007,8 +1005,8 @@ typedef struct ivas_mcmasa_enc_data_structure
Word16 prevEQ_e;
Word16 interpolator_fx[L_FRAME48k];
- uint8_t separateChannelEnabled;
- int16_t separateChannelIndex;
+ UWord8 separateChannelEnabled;
+ Word16 separateChannelIndex;
/* LFE coding */
Word32 lfeLfEne[MAX_PARAM_SPATIAL_SUBFRAMES];
@@ -1016,9 +1014,9 @@ typedef struct ivas_mcmasa_enc_data_structure
Word32 totalLfEne[MAX_PARAM_SPATIAL_SUBFRAMES];
Word16 totalLfEne_e[MAX_PARAM_SPATIAL_SUBFRAMES];
Word32 *lfeAnaRingBuffer[2];
- int16_t ringBufferPointer;
+ Word16 ringBufferPointer;
Word32 lowpassSum[2];
- int16_t ringBufferSize;
+ Word16 ringBufferSize;
} MCMASA_ENC_DATA, *MCMASA_ENC_HANDLE;
@@ -1033,7 +1031,7 @@ typedef struct ivas_osba_enc_data_structure
Word32 interpolator_fx[L_FRAME48k];
Word32 prev_object_dm_gains_fx[MAX_NUM_OBJECTS][MAX_INPUT_CHANNELS];
- int16_t nchan_ism;
+ Word16 nchan_ism;
Word32 *input_data_mem_fx[MAX_NUM_OBJECTS];
} OSBA_ENC_DATA, *OSBA_ENC_HANDLE;
@@ -1101,14 +1099,12 @@ typedef struct cpe_enc_data_structure
STEREO_CNG_ENC_HANDLE hStereoCng; /* Stereo CNG data structure */
FRONT_VAD_ENC_HANDLE hFrontVad[CPE_CHANNELS];
- // float *input_mem[CPE_CHANNELS]; /* input channels buffers memory; needed to be up-to-date for TD->DFT stereo switching */
-
Word32 brate_surplus; /* bitrate surplus for bitrate adaptation in combined format coding */
Word16 *input_mem_fx[CPE_CHANNELS]; /* input channels buffers memory; needed to be up-to-date for TD->DFT stereo switching */
Word16 q_input_mem[CPE_CHANNELS];
#ifdef DEBUGGING
- int16_t stereo_mode_cmdl; /* stereo mode forced from the commaand-line */
+ Word16 stereo_mode_cmdl; /* stereo mode forced from the commaand-line */
#endif
} CPE_ENC_DATA, *CPE_ENC_HANDLE;
@@ -1120,9 +1116,9 @@ typedef struct cpe_enc_data_structure
typedef struct mct_block_data_struct
{
- int16_t isActive;
- int16_t ch1, ch2;
- int16_t mask[2][MAX_SFB];
+ Word16 isActive;
+ Word16 ch1, ch2;
+ Word16 mask[2][MAX_SFB];
STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct; /* MDCT stereo data handle */
} MCT_BLOCK_DATA, *MCT_BLOCK_DATA_HANDLE;
@@ -1131,16 +1127,16 @@ typedef struct mct_enc_data_structure
{
BSTR_ENC_HANDLE hBstr; /* bitstream handle for side bits - in MCT, side bits are written at the beginning of the bitstream */
- int16_t nchan_out_woLFE; /* number of active channels within multi-channel configuration */
- int16_t currBlockDataCnt;
- int16_t bitsChannelPairIndex; /* bits needed to code channel pair index, depends on number of active channels */
+ Word16 nchan_out_woLFE; /* number of active channels within multi-channel configuration */
+ Word16 currBlockDataCnt;
+ Word16 bitsChannelPairIndex; /* bits needed to code channel pair index, depends on number of active channels */
MCT_BLOCK_DATA_HANDLE hBlockData[MCT_MAX_BLOCKS];
Word32 lastxCorrMatrix_fx[MCT_MAX_CHANNELS][MCT_MAX_CHANNELS];
Word16 lastxCorrMatrix_e;
- int16_t lowE_ch[MCT_MAX_CHANNELS];
- uint16_t mc_global_ild[MCT_MAX_CHANNELS];
- int16_t nBitsMCT; /* number of bits spent on mct side info */
+ Word16 lowE_ch[MCT_MAX_CHANNELS];
+ UWord16 mc_global_ild[MCT_MAX_CHANNELS];
+ Word16 nBitsMCT; /* number of bits spent on mct side info */
/* pointers to local buffers */
Word32 *p_mdst_spectrum_long_fx[MCT_MAX_BLOCKS][CPE_CHANNELS];
Word32 *p_orig_spectrum_long_fx[MCT_MAX_BLOCKS][CPE_CHANNELS];
@@ -1148,11 +1144,11 @@ typedef struct mct_enc_data_structure
Word16 q_orig_spectrum_long_com;
Word16 q_mdst_spectrum_long_fx[MCT_MAX_BLOCKS][CPE_CHANNELS][NB_DIV];
- int16_t tnsBits[MCT_MAX_BLOCKS][CPE_CHANNELS][NB_DIV]; /* number of tns bits in the frame */
- int16_t tnsSize[MCT_MAX_BLOCKS][CPE_CHANNELS][NB_DIV]; /* number of tns parameters put into prm */
- int16_t p_param[MCT_MAX_BLOCKS][CPE_CHANNELS][NB_DIV];
+ Word16 tnsBits[MCT_MAX_BLOCKS][CPE_CHANNELS][NB_DIV]; /* number of tns bits in the frame */
+ Word16 tnsSize[MCT_MAX_BLOCKS][CPE_CHANNELS][NB_DIV]; /* number of tns parameters put into prm */
+ Word16 p_param[MCT_MAX_BLOCKS][CPE_CHANNELS][NB_DIV];
- int16_t hbr_mct;
+ Word16 hbr_mct;
} MCT_ENC_DATA, *MCT_ENC_HANDLE;
@@ -1169,9 +1165,9 @@ typedef struct stereo_dmx_evs_phase_only_correlation_structure
Word32 peak_width_fx[CPE_CHANNELS]; // Q16
Word32 confidence_fx; // Q31
- int16_t ispeak[CPE_CHANNELS];
- int16_t itdLR[CPE_CHANNELS];
- int16_t shift_limit;
+ Word16 ispeak[CPE_CHANNELS];
+ Word16 itdLR[CPE_CHANNELS];
+ Word16 shift_limit;
const Word32 *wnd_fx;
@@ -1182,7 +1178,7 @@ typedef struct stereo_dmx_evs_phase_only_correlation_structure
typedef struct stereo_dmx_evs_correlation_filter_structure
{
- int16_t init_frmCntr;
+ Word16 init_frmCntr;
Word16 isd_rate_s_fx; // Q15
Word32 iccr_s_fx; // Q31
@@ -1191,8 +1187,8 @@ typedef struct stereo_dmx_evs_correlation_filter_structure
Word32 Pi_fx[STEREO_DMX_EVS_NB_SUBBAND_MAX]; // Q31
Word16 rfft_ipd_coef_fx[L_FRAME48k / 2 + 1];
- int16_t pha_len;
- int16_t fad_len;
+ Word16 pha_len;
+ Word16 fad_len;
Word16 win_fx[STEREO_DMX_EVS_PHA_LEN_MAX]; // Q14
@@ -1204,14 +1200,14 @@ typedef struct stereo_dmx_evs_correlation_filter_structure
STEREO_DMX_EVS_PHA curr_pha;
STEREO_DMX_EVS_PHA prev_pha;
- int16_t pha_hys_cnt;
+ Word16 pha_hys_cnt;
- int16_t prc_thres;
+ Word16 prc_thres;
STEREO_DMX_EVS_PRC curr_prc;
STEREO_DMX_EVS_PRC prev_prc;
- int16_t prc_hys_cnt;
+ Word16 prc_hys_cnt;
Word32 fad_g_prc_fx[L_FRAME48k]; // Q31
- int16_t fad_len_prc;
+ Word16 fad_len_prc;
Word32 trns_aux_energy_fx[CPE_CHANNELS];
@@ -1248,9 +1244,9 @@ typedef struct ivas_lfe_enc_data_structure
{
LFE_WINDOW_HANDLE pWindow_state;
BSTR_ENC_HANDLE hBstr; /* pointer to encoder bitstream handle */
- const uint16_t *cum_freq_models[IVAS_MAX_NUM_QUANT_STRATS][IVAS_MAX_NUM_DCT_COEF_GROUPS];
- int16_t lfe_enc_indices_coeffs_tbl[IVAS_MAX_NUM_QUANT_STRATS][IVAS_MAX_NUM_DCT_COEF_GROUPS];
- int16_t lfe_bits;
+ const UWord16 *cum_freq_models[IVAS_MAX_NUM_QUANT_STRATS][IVAS_MAX_NUM_DCT_COEF_GROUPS];
+ Word16 lfe_enc_indices_coeffs_tbl[IVAS_MAX_NUM_QUANT_STRATS][IVAS_MAX_NUM_DCT_COEF_GROUPS];
+ Word16 lfe_bits;
Word32 *old_wtda_audio_fx;
Word16 q_old_wtda_audio;
@@ -1298,9 +1294,9 @@ typedef struct encoder_config_structure
#ifdef DEBUGGING
/* debugging options */
- int16_t stereo_mode_cmdl; /* stereo mode forced from the command-line */
- int16_t force; /* parameter to force specific "core" of the Core-Coder*/
- int16_t mdct_stereo_mode_cmdl; /* mdct stereo mode forced from command-line, employed only when DEBUG_FORCE_MDCT_STEREO_MODE is activated */
+ Word16 stereo_mode_cmdl; /* stereo mode forced from the command-line */
+ Word16 force; /* parameter to force specific "core" of the Core-Coder*/
+ Word16 mdct_stereo_mode_cmdl; /* mdct stereo mode forced from command-line, employed only when DEBUG_FORCE_MDCT_STEREO_MODE is activated */
#endif
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 c2e4f350c3d4900bf43ac04cd45f0b7f3afcea8a..c84fd73f1850eb4c4fd55af43f7a780acfb7f283 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,7 +162,8 @@ Word16 select_stereo_mode(
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, -5243 /* -0.01 in Q19*/ ) && EQ_16( hCPE->hCoreCoder[0]->vad_flag, 1 ) && ( hCPE->hStereoMdct->sw_uncorr || hStereoClassif->xtalk_decision ) )
+ 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;
move16();
@@ -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();
@@ -365,8 +367,6 @@ void stereo_classifier_init_fx(
move16();
set_zero_fx( hStereoClassif->relE_buf_fx, UNCLR_L_RELE );
- hStereoClassif->relE_buf_e = 0;
- move16();
set_zero_fx( hStereoClassif->Etot_buf_fx, UNCLR_L_ETOT );
hStereoClassif->e_Etot_buf_fx = 0;
move16();
@@ -425,15 +425,12 @@ void stereo_classifier_init_fx(
*-----------------------------------------------------------------*/
/* Information on ouputs:
hStereoClassif->Etot_buf_fx has expoenent hStereoClassif->e_Etot_buf_fx
-hStereoClassif->relE_buf_fx has expoenent hStereoClassif->relE_buf_e
hStereoClassif->lsf_ch1_fx has Q1*1.28
hStereoClassif->xtalk_fv_fx has exponent 16
hStereoClassif->voicing_ch1_fx has Q-factor Q15
hStereoClassif->lepsP_ch1_fx has exponent 16
hStereoClassif->Etot_up_fx has exponent hStereoClassif->Etot_up_e
hStereoClassif->Etot_dn_fx has exponent hStereoClassif->Etot_dn_e
-hStereoClassif->relE_0_1_fx has exponent hStereoClassif->relE_buf_e
-hStereoClassif->relE_0_1_LT_fx has exponent hStereoClassif->relE_buf_e
hStereoClassif->cor_map_sum_ch1_fx has exponent hStereoClassif->cor_map_sum_ch1_e
hStereoClassif->non_sta_ch1_fx has exponent hStereoClassif->non_sta_ch1_e
hStereoClassif->sp_div_ch1_fx has exponent sp_div_e
@@ -455,9 +452,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 */
@@ -466,10 +463,11 @@ void stereo_classifier_features_ivas_fx(
)
{
Word16 i, clas_ch2;
- Word16 e_relE_0_1_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 )
{
@@ -500,12 +498,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();
@@ -576,7 +600,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();
@@ -585,30 +609,27 @@ void stereo_classifier_features_ivas_fx(
}
/* normalize Etot to (0,1) */
- e_relE_0_1_fx = sub( 31, hStereoClassif->e_Etot_buf_fx );
- hStereoClassif->relE_0_1_fx = lin_interp32_fx( hStereoClassif->Etot_buf_fx[0], hStereoClassif->Etot_dn_fx, 0, hStereoClassif->Etot_up_fx, L_shr( 1932735283, hStereoClassif->e_Etot_buf_fx /*0.9f exp:Etot_buf_fx*/ ), 1, &e_relE_0_1_fx ); /*e_relE_0_1_fx is ouput exp*/
- e_relE_0_1_fx = sub( 31, e_relE_0_1_fx );
+ hStereoClassif->relE_0_1_fx = lin_interp32_fx( hStereoClassif->Etot_buf_fx[0], hStereoClassif->Etot_dn_fx, 0, hStereoClassif->Etot_up_fx, 1932735283 /* 0.9 in Q31 */, 1 );
move32();
/* update relE_buf */
Copy32( &hStereoClassif->relE_buf_fx[0], &hStereoClassif->relE_buf_fx[1], UNCLR_L_RELE - 1 );
- hStereoClassif->relE_0_1_fx = L_shr( hStereoClassif->relE_0_1_fx, sub( hStereoClassif->relE_buf_e, e_relE_0_1_fx ) ); /*scaling down to exponent of e_relE_buf_fx*/
- hStereoClassif->relE_buf_fx[0] = hStereoClassif->relE_0_1_fx; /*scaling down to exponent of e_relE_buf_fx*/
- move32();
+ hStereoClassif->relE_buf_fx[0] = hStereoClassif->relE_0_1_fx;
move32();
IF( GE_32( hStereoClassif->relE_0_1_fx, hStereoClassif->relE_buf_fx[1] ) )
{
- hStereoClassif->relE_0_1_LT_fx = Mpy_32_16_1( hStereoClassif->relE_0_1_LT_fx, 29491 /*0.9f q15*/ ) + Mpy_32_16_1( hStereoClassif->relE_0_1_fx, 3277 /*0.1f q15*/ );
+ hStereoClassif->relE_0_1_LT_fx = L_add( Mpy_32_16_1( hStereoClassif->relE_0_1_LT_fx, 29491 /* 0.9f in Q15 */ ), Mpy_32_16_1( hStereoClassif->relE_0_1_fx, 3277 /* 0.1f in Q15 */ ) );
}
ELSE
{
- hStereoClassif->relE_0_1_LT_fx = Mpy_32_16_1( hStereoClassif->relE_0_1_LT_fx, 31129 /*0.95f q15*/ ) + Mpy_32_16_1( hStereoClassif->relE_0_1_fx, 1638 /*0.05f0 q15*/ );
+ hStereoClassif->relE_0_1_LT_fx = L_add( Mpy_32_16_1( hStereoClassif->relE_0_1_LT_fx, 31129 /* 0.95f in Q15 */ ), Mpy_32_16_1( hStereoClassif->relE_0_1_fx, 1638 /* 0.05f in Q15 */ ) );
}
move32();
/* estimate VAD flag based on relative energy */
- IF( LT_32( hStereoClassif->relE_0_1_LT_fx, L_shr( 214748365, hStereoClassif->relE_buf_e ) ) )
+
+ IF( LT_32( hStereoClassif->relE_0_1_LT_fx, 214748365 /* 0.1f in Q31 */ ) )
{
hStereoClassif->vad_relE = 0;
}
@@ -628,7 +649,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*/
@@ -720,11 +740,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();
@@ -734,13 +755,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();
@@ -883,7 +910,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 );
@@ -906,7 +957,7 @@ void unclr_classifier_td_fx(
test();
test();
test();
- if ( ( ( hStereoClassif->unclr_decision == 0 && GT_32( hStereoClassif->unclr_wscore_fx, 214748365 /*0.1f in Q31*/ ) ) || ( EQ_16( hStereoClassif->unclr_decision, 1 ) && LT_32( hStereoClassif->unclr_wscore_fx, 150323855 /*-0.07f in Q31*/ ) ) ) && ( hStereoClassif->unclr_sw_enable_cnt[0] > 0 || hStereoClassif->unclr_sw_enable_cnt[1] > 0 ) )
+ if ( ( ( hStereoClassif->unclr_decision == 0 && GT_32( hStereoClassif->unclr_wscore_fx, 214748365 /*0.1f in Q31*/ ) ) || ( EQ_16( hStereoClassif->unclr_decision, 1 ) && LT_32( hStereoClassif->unclr_wscore_fx, -150323855 /*-0.07f in Q31*/ ) ) ) && ( hStereoClassif->unclr_sw_enable_cnt[0] > 0 || hStereoClassif->unclr_sw_enable_cnt[1] > 0 ) )
{
/* let's switch the binary decision */
hStereoClassif->unclr_decision = !hStereoClassif->unclr_decision;
@@ -985,7 +1036,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);
@@ -1126,7 +1202,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*/ ) )
@@ -1161,6 +1237,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 */
@@ -1195,7 +1273,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();
@@ -1221,7 +1306,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 ) )
{
@@ -1235,7 +1320,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 ) )
{
@@ -1323,7 +1408,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 );
@@ -1427,14 +1512,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*/
@@ -1579,10 +1664,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 0a3c84b1e77b3196498aa7765831a300a8c75356..92add6cddc5169bdd1cd123455b234ca740e0fa2 100644
--- a/lib_enc/ivas_stereo_cng_enc.c
+++ b/lib_enc/ivas_stereo_cng_enc.c
@@ -109,11 +109,11 @@ void stereo_dft_enc_sid_calc_coh_fx(
xspec_scale = Sqrt32( L_tmp3, &L_tmp3_e );
// xspec_scale = L_shl(xspec_scale, L_tmp3_e);//Q31
- hStereoDft->xspec_smooth_fx[2 * k] = Mpy_32_32( hStereoDft->xspec_smooth_fx[2 * k], xspec_scale );
+ hStereoDft->xspec_smooth_fx[2 * k] = Mpy_32_32( hStereoDft->xspec_smooth_fx[2 * k], xspec_scale ); // Q(31-(xspec_smooth_fx_e+tmp3_e))
move32();
hStereoDft->xspec_smooth_fx_e[2 * k] = add( hStereoDft->xspec_smooth_fx_e[2 * k], L_tmp3_e );
move16();
- hStereoDft->xspec_smooth_fx[2 * k + 1] = Mpy_32_32( hStereoDft->xspec_smooth_fx[2 * k + 1], xspec_scale );
+ hStereoDft->xspec_smooth_fx[2 * k + 1] = Mpy_32_32( hStereoDft->xspec_smooth_fx[2 * k + 1], xspec_scale ); // Q(31-(xspec_smooth_fx_e+tmp3_e))
move32();
hStereoDft->xspec_smooth_fx_e[2 * k + 1] = add( hStereoDft->xspec_smooth_fx_e[2 * k + 1], L_tmp3_e );
move16();
@@ -231,10 +231,10 @@ void stereo_dft_enc_sid_calc_coh_fx(
void stereo_dft_enc_sid_coh_fx(
BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
- Word32 *mem_cohBand, /* i/o: Coherence memory */
+ Word32 *mem_cohBand, /* i/o: Coherence memory Q31 */
const Word16 nbands, /* i : number of DFT stereo bands */
Word16 *nb_bits, /* i/o: number of bits written */
- Word32 *cohBand /* i/o: Coherence per band */
+ Word32 *cohBand /* i/o: Coherence per band Q31 */
)
{
Word16 b, k;
@@ -384,7 +384,7 @@ void stereo_dft_enc_sid_coh_fx(
alphaptr = &dft_cng_alpha_bits_fx[alpha_step][alpha_level];
pptr = dft_cng_coh_pred_fx[coh_pred_index]; /* Set pointer to selected predictor */
pred = 3277 /*0.4f in Q13*/;
-
+ move16();
FOR( b = 0; b < nbands; b++ )
{
/* Intra-frame prediction using quantized values */
@@ -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();
}
@@ -429,7 +429,7 @@ void stereo_dft_enc_sid_coh_fx(
move16();
}
- mem_cohBand[b] = L_deposit_h( cohBandq[b] ); /* Update memory for next frame */
+ mem_cohBand[b] = L_deposit_h( cohBandq[b] ); /* Update memory for next frame Q31*/
move32();
pred = 0;
move16();
@@ -658,7 +658,7 @@ void stereo_cng_upd_counters_fx(
STEREO_CNG_ENC_HANDLE hStereoCng, /* i/o: Stereo CNG data structure */
const Word32 element_mode, /* i : element mode */
const Word16 nbands, /* i : Number of bands in active */
- const Word32 sidSideGain[], /* i : SID side gains */
+ const Word32 sidSideGain[], /* i : SID side gains Q31 */
const Word16 burst_ho_count, /* i : Hang-over count */
Word16 *coh_fade_counter /* i : Coherence fade counter */
)
diff --git a/lib_enc/ivas_stereo_dft_enc.c b/lib_enc/ivas_stereo_dft_enc.c
index e2b4597653eaf9b59053312cffc747149fcfcc27..90e9752f47982a63607d4ddc347e70f6067505a3 100644
--- a/lib_enc/ivas_stereo_dft_enc.c
+++ b/lib_enc/ivas_stereo_dft_enc.c
@@ -737,8 +737,7 @@ void stereo_enc_itd_init_fx(
set16_fx( hItd->td_itd_32k, 0, STEREO_DFT_ENC_DFT_NB );
set16_fx( hItd->itd_index, 0, STEREO_DFT_ENC_DFT_NB );
set32_fx( hItd->xcorr_smooth_fx, 0, STEREO_DFT_N_32k_ENC );
- hItd->xcorr_smooth_fx_e = 0;
- move16();
+ set16_fx( hItd->xcorr_smooth_fx_e, 0, STEREO_DFT_N_32k_ENC );
hItd->lp_phat_peak_fx = 0;
move32();
hItd->itd_hangover = 0;
@@ -753,6 +752,9 @@ void stereo_enc_itd_init_fx(
hItd->prev_xcorr_lb_fx_e = 0;
move16();
set32_fx( hItd->E_band_n_fx, ITD_VAD_E_BAND_N_INIT, STEREO_DFT_ITD_VAD_BAND_NUM );
+#ifdef FIX_ISSUE_1092
+ set16_fx( hItd->E_band_n_exp, Q31, STEREO_DFT_ITD_VAD_BAND_NUM );
+#endif
hItd->vad_frm_cnt = 0;
move16();
hItd->pre_vad = 0;
@@ -819,7 +821,7 @@ void stereo_dft_enc_update_fx(
move32();
/* Update the parameters and serial */
- FOR( i = 0; i < imult1616( k_offset, STEREO_DFT_BAND_MAX ); i++ )
+ FOR( i = 0; i < ( k_offset * STEREO_DFT_BAND_MAX ); i++ )
{
hStereoDft->side_gain_fx[i] = hStereoDft->side_gain_fx[STEREO_DFT_BAND_MAX + i];
move32();
@@ -884,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);
@@ -937,9 +939,9 @@ void stereo_dft_enc_analyze_fx(
const Word16 input_frame, /* i : input frame length */
STEREO_DFT_ENC_DATA_HANDLE hStereoDft, /* i/o: encoder stereo handle */
STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: encoder MDCT stereo handle */
- Word32 DFT[CPE_CHANNELS][STEREO_DFT_N_MAX_ENC], /* o : DFT buffers */
+ Word32 DFT[CPE_CHANNELS][STEREO_DFT_N_MAX_ENC], /* o : DFT buffers Q(31-DFT_e) */
Word16 DFT_e[CPE_CHANNELS], /* o : DFT buffers */
- Word16 *input_mem[CPE_CHANNELS], /* i/o: input buffer memory */
+ Word16 *input_mem[CPE_CHANNELS], /* i/o: input buffer memory Q(q_input_mem_ */
Word16 *q_input_mem )
{
Word16 i, n;
@@ -1011,10 +1013,10 @@ void stereo_dft_enc_analyze_fx(
{
trigo_enc[i] = pTrigo[i * trigo_step];
move16();
- trigo_enc[sub( shr( NFFT, 1 ), i )] = pTrigo[L_mult0( i, trigo_step )];
+ trigo_enc[( ( NFFT / 2 ) - i )] = pTrigo[L_mult0( i, trigo_step )];
move16();
}
- trigo_enc[shr( NFFT, 2 )] = pTrigo[L_mult0( shr( NFFT, 2 ), trigo_step )];
+ trigo_enc[NFFT / 4] = pTrigo[( ( NFFT / 4 ) * trigo_step )];
move16();
/*Forwards FFT: L and R*/
@@ -1023,42 +1025,42 @@ void stereo_dft_enc_analyze_fx(
{
pDFT_L[i] = 0;
move32();
- pDFT_L[sub( sub( NFFT, 1 ), i )] = 0;
+ pDFT_L[( ( NFFT - 1 ) - i )] = 0;
move32();
pDFT_R[i] = 0;
move32();
- pDFT_R[sub( sub( NFFT, 1 ), i )] = 0;
+ pDFT_R[( ( NFFT - 1 ) - i )] = 0;
move32();
}
FOR( n = 0; n < n_channels; n++ )
{
- Scale_sig( &mem[n][0], dft_ovl, sts[n]->q_inp - q_input_mem[n] );
+ Scale_sig( &mem[n][0], dft_ovl, sts[n]->q_inp - q_input_mem[n] ); // Q(sts[n]->q_inp)
q_input_mem[n] = sts[n]->q_inp;
move16();
}
/*overlapping parts*/
FOR( i = 0; i < dft_ovl; i++ )
{
- pDFT_L[add( dft_zp, i )] = L_mult0( mem[0][i], pWin[i] );
+ pDFT_L[( dft_zp + i )] = L_mult0( mem[0][i], pWin[i] );
move32();
- pDFT_L[sub( add( add( dft_zp, N ), dft_ovl ) - 1, i )] = L_mult0( input[0][sub( add( add( offset, N ), dft_ovl ) - 1, i )], pWin[i] );
+ pDFT_L[( ( ( dft_zp + N ) + dft_ovl ) - 1 - i )] = L_mult0( input[0][offset + N + dft_ovl - 1 - i], pWin[i] );
move32();
- pDFT_R[add( dft_zp, i )] = L_mult0( mem[1][i], pWin[i] );
+ pDFT_R[dft_zp + i] = L_mult0( mem[1][i], pWin[i] );
move32();
- pDFT_R[sub( add( add( dft_zp, N ), dft_ovl ) - 1, i )] = L_mult0( input[1][sub( add( add( offset, N ), dft_ovl ) - 1, i )], pWin[i] );
+ pDFT_R[( ( dft_zp + N ) + dft_ovl ) - 1 - i] = L_mult0( input[1][offset + N + dft_ovl - 1 - i], pWin[i] );
move32();
}
/*middle part*/
FOR( i = 0; i < N - dft_ovl; i++ )
{
- pDFT_L[add( add( dft_zp, dft_ovl ), i )] = L_shr( L_deposit_h( input[0][add( add( offset, dft_ovl ), i )] ), 1 );
+ pDFT_L[dft_zp + dft_ovl + i] = L_shr( L_deposit_h( input[0][offset + dft_ovl + i] ), 1 );
move32();
- pDFT_R[add( add( dft_zp, dft_ovl ), i )] = L_shr( L_deposit_h( input[1][add( add( offset, dft_ovl ), i )] ), 1 );
+ pDFT_R[dft_zp + dft_ovl + i] = L_shr( L_deposit_h( input[1][offset + dft_ovl + i] ), 1 );
move32();
}
DFT_e[0] = sub( 31, add( 15, sts[0]->q_inp ) );
@@ -1096,13 +1098,14 @@ void stereo_dft_enc_analyze_fx(
{
mem[n] = &input[n][sub( N, dft_ovl )];
}
-
+ test();
+ test();
IF( hStereoDft != NULL && hStereoDft->hConfig->hybrid_itd_flag && hStereoDft->hItd->td_itd[STEREO_DFT_OFFSET] )
{
FOR( n = 0; n < n_channels; n++ )
{
#ifdef MSAN_FIX
- Scale_sig( hStereoDft->input_mem_itd_fx[n], dft_ovl, sub( sts[n]->q_inp, hStereoDft->q_input_mem_itd[n] ) );
+ Scale_sig( hStereoDft->input_mem_itd_fx[n], dft_ovl, sub( sts[n]->q_inp, hStereoDft->q_input_mem_itd[n] ) ); // Q(sts[n]->q_inp)
#else
Scale_sig( hStereoDft->input_mem_itd_fx[n], STEREO_DFT_OVL_MAX, sts[n]->q_inp - hStereoDft->q_input_mem_itd[n] );
#endif // MSAN_FIX
@@ -1132,7 +1135,7 @@ void stereo_dft_enc_analyze_fx(
Word32 stereo_dft_enc_synthesize_fx(
STEREO_DFT_ENC_DATA_HANDLE hStereoDft, /* i/o: encoder stereo handle */
// float *output, /* o : output synthesis */
- Word32 *output_fx, /* o : output synthesis Q16 */
+ Word32 *output_fx, /* o : output synthesis Q15 */
Word16 *output_start_index,
Word16 *output_end_index,
const Word16 chan, /* i : channel number */
@@ -1360,14 +1363,14 @@ Word32 stereo_dft_enc_synthesize_fx(
offset = 0;
move16();
- FOR( i = 0; i < shr( NFFT, 2 ); i++ )
+ FOR( i = 0; i < NFFT / 4; i++ )
{
- trigo_enc_fx[i] = trigo_fx[imult1616( i, trigo_step )];
+ trigo_enc_fx[i] = trigo_fx[i * trigo_step];
move16();
- trigo_enc_fx[sub( shr( NFFT, 1 ), i )] = trigo_fx[imult1616( i, trigo_step )];
+ trigo_enc_fx[( NFFT / 2 ) - i] = trigo_fx[i * trigo_step];
move16();
}
- trigo_enc_fx[shr( NFFT, 2 )] = trigo_fx[imult1616( shr( NFFT, 2 ), trigo_step )];
+ trigo_enc_fx[NFFT / 4] = trigo_fx[( NFFT / 4 ) * trigo_step];
move16();
/*-----------------------------------------------------------------*
@@ -1497,15 +1500,15 @@ Word32 stereo_dft_enc_synthesize_fx(
scal_fac = sub( 1, find_guarded_bits_fx( NFFT ) );
scale_sig32( tmp_fx, NFFT, scal_fac ); // Q16
rfft_fx( tmp_fx, trigo_enc_fx, NFFT, +1 );
- Scale_sig32( tmp_fx, NFFT, sub( sub( DFT_in_fx_e, scal_fac ), 15 ) ); // Q16
+ Scale_sig32( tmp_fx, NFFT, sub( sub( DFT_in_fx_e, scal_fac ), 16 ) ); // Q15
FOR( i = 0; i < ovl; i++ )
{
// output[offset + i] = mem[i] + tmp[zp + i] * win[i];
- output_fx[offset + i] = L_add_sat( mem_fx[i], Mpy_32_32( tmp_fx[zp + i], win_fx[i] ) );
+ output_fx[offset + i] = L_add_sat( mem_fx[i], Mpy_32_32( tmp_fx[zp + i], win_fx[i] ) ); // Q15
move32();
// mem[i] = tmp[zp + N + i] * win[ovl - 1 - i];
- mem_fx[i] = Mpy_32_32( tmp_fx[zp + N + i], win_fx[ovl - 1 - i] );
+ mem_fx[i] = Mpy_32_32( tmp_fx[zp + N + i], win_fx[ovl - 1 - i] ); // Q15
move32();
}
@@ -1513,7 +1516,7 @@ Word32 stereo_dft_enc_synthesize_fx(
FOR( i = 0; i < N - ovl; i++ )
{
// output_fx[offset + ovl + i] = tmp[zp + ovl + i];
- output_fx[offset + ovl + i] = tmp_fx[zp + ovl + i];
+ output_fx[offset + ovl + i] = tmp_fx[zp + ovl + i]; // Q15
move32();
}
@@ -1523,13 +1526,13 @@ Word32 stereo_dft_enc_synthesize_fx(
FOR( i = 0; i < ovl; i++ )
{
- Word32 ifft_deviation = tmp_fx[zp + N + ovl];
+ Word32 ifft_deviation = tmp_fx[zp + N + ovl]; // Q15
move32();
// output[offset + N + i] = ( tmp[zp + N + i] - ifft_deviation ) / win_ana[ovl - 1 - i] + ifft_deviation;
Word16 L_temp_e;
Word32 L_temp = BASOP_Util_Divide3232_Scale_cadence( L_sub_sat( tmp_fx[zp + N + i], ifft_deviation ), L_deposit_h( win_ana_fx[ovl - 1 - i] ), &L_temp_e );
L_temp = L_shl_sat( L_temp, L_temp_e );
- output_fx[offset + N + i] = L_add_sat( L_temp, ifft_deviation ); // Q16
+ output_fx[offset + N + i] = L_add_sat( L_temp, ifft_deviation ); // Q15
move32();
}
@@ -1629,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 );
@@ -1859,8 +1862,28 @@ void stereo_dft_enc_process_fx(
IF( pgIpd[0] != 0 )
{
- c_fx = shl_sat( getCosWord16( (Word16) pgIpd[0] ), 1 ); // Q15 saturation expected
- s_fx = getSinWord16( (Word16) 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*/
@@ -2413,7 +2436,7 @@ void stereo_dft_enc_process_fx(
}
FOR( i = 0; i < STEREO_DFT_N_MAX_ENC; i++ )
{
- DFT_DMX[i] = L_shr_r( DFT_DMX[i], sub( max_exp, DFT_DMX_e[i] ) );
+ DFT_DMX[i] = L_shr_r( DFT_DMX[i], sub( max_exp, DFT_DMX_e[i] ) ); // Q(31-max_exp)
move32();
}
hStereoDft->DFT_fx_e[0] = max_exp;
@@ -2427,7 +2450,7 @@ void stereo_dft_enc_process_fx(
}
FOR( i = 0; i < STEREO_DFT_N_8k_ENC; i++ )
{
- DFT_RES[i] = L_shr_r( DFT_RES[i], sub( max_exp, DFT_RES_e[i] ) );
+ DFT_RES[i] = L_shr_r( DFT_RES[i], sub( max_exp, DFT_RES_e[i] ) ); // Q(31-max_exp)
move32();
}
hStereoDft->DFT_fx_e[1] = max_exp;
@@ -2746,7 +2769,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*/
@@ -2772,7 +2795,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();
@@ -2783,7 +2806,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 ) ) )
{
@@ -2866,7 +2889,7 @@ void stereo_dft_enc_write_BS_fx(
sp_aud_decision0 = 0;
move16();
- IF( EQ_16( hCPE->last_element_mode, IVAS_CPE_DFT ) )
+ if ( EQ_16( hCPE->last_element_mode, IVAS_CPE_DFT ) )
{
sp_aud_decision0 = hCPE->hCoreCoder[0]->sp_aud_decision0;
move16();
@@ -2881,7 +2904,7 @@ void stereo_dft_enc_write_BS_fx(
move16();
test();
- IF( EQ_32( core_brate, FRAME_NO_DATA ) || EQ_32( core_brate, SID_2k40 ) )
+ IF( ( core_brate == FRAME_NO_DATA ) || EQ_32( core_brate, SID_2k40 ) )
{
NFFT_inner = s_min( STEREO_DFT_N_32k_ENC, STEREO_DFT_N_MAX_ENC * inner_frame_tbl[hCPE->hCoreCoder[0]->bwidth] / L_FRAME48k );
hStereoDft->band_res[k_offset] = hStereoDft->hConfig->band_res;
@@ -2901,7 +2924,7 @@ void stereo_dft_enc_write_BS_fx(
hStereoDft->nbands = stereo_dft_band_config_fx( hStereoDft->band_limits, hStereoDft->band_res[k_offset], NFFT_inner, ENC );
move16();
- IF( EQ_32( core_brate, FRAME_NO_DATA ) )
+ IF( core_brate == FRAME_NO_DATA )
{
/* No data frame */
( *nb_bits ) = 0;
@@ -3035,11 +3058,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
{
@@ -3208,18 +3231,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
{
@@ -3242,6 +3265,7 @@ ELSE
}
( *nb_bits ) = add( *nb_bits, nb );
+move16();
IF( EQ_32( core_brate, SID_2k40 ) )
{
@@ -3437,7 +3461,7 @@ static void stereo_dft_enc_compute_prm_fx(
sum_past_dpi_e = 0;
move16();
- WHILE( LT_16( hStereoDft->band_limits_dmx[b2], hStereoDft->band_limits[b + 1] ) )
+ WHILE( hStereoDft->band_limits_dmx[b2] < hStereoDft->band_limits[b + 1] )
{
pDFT_L = DFT_L_fx;
// DFT_L_e = hStereoDft->DFT_fx_e[0];
@@ -3796,7 +3820,7 @@ static void stereo_dft_enc_compute_prm_fx(
move32();
}
// dItd32 = (int16_t) floorf( conversion_factor * hStereoDft->hItd->deltaItd[k_offset] + 0.5f );
- dItd32 = (Word16) L_shr_r( Mpy_32_32( conversion_factor, hStereoDft->hItd->deltaItd_fx[k_offset] ), Q15 ); // Q0
+ dItd32 = extract_l( L_shr_r( Mpy_32_32( conversion_factor, hStereoDft->hItd->deltaItd_fx[k_offset] ), Q15 ) ); // Q0
gain_offset = stereo_dft_gain_offset_fx( c, c_e, dItd32 ); // Q31
pPredGain[b] = L_max( 0, L_sub( pPredGain[b], gain_offset ) );
@@ -3947,8 +3971,6 @@ static void stereo_dft_enc_compute_prm_fx(
ELSE
{
stereo_dft_enc_get_reverb_flag_fx( hStereoDft, pPredGain, sub_nrg_DMX, sub_nrg_DMX_e, sub_nrg_L, sub_nrg_L_e, sub_nrg_R, sub_nrg_R_e, k_offset, bin_nrgL_fx, bin_nrgL_fx_e, bin_nrgR_fx, bin_nrgR_fx_e );
- // printf( "\n%d ", hStereoDft->reverb_flag );
- // printf( "\n%f ", (float)hStereoDft->res_pred_gain_fx[18]/0x7fffffff);
}
@@ -4174,7 +4196,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++ )
@@ -4269,6 +4291,7 @@ static Word32 stereo_dft_calc_mean_bipd_fx(
{
ipd_buf[i] = L_add( ipd_buf[i], 2 * EVS_PI_FX );
}
+ move32();
}
// ipd_smooth = (i / (float)(i + 1)) * ipd_smooth + (1 / (float)(i + 1)) * ipd_buf[i];
ipd_smooth = L_add( Mpy_32_16_1( ipd_smooth, ipd_table1[i] ), Mpy_32_16_1( ipd_buf[i], ipd_table2[i] ) ); // Q13
@@ -4326,7 +4349,7 @@ static Word32 stereo_dft_calc_mean_ipd_change_fx(
// ipd_mean_change /= gipd_band_max;
ipd_mean_change = BASOP_Util_Divide3232_Scale_cadence( ipd_mean_change, gipd_band_max, &ipd_mean_change_e );
ipd_mean_change_e = add( ipd_mean_change_e, 18 - 31 );
- ipd_mean_change = L_shr( ipd_mean_change, sub( 18, ipd_mean_change_e ) );
+ ipd_mean_change = L_shr( ipd_mean_change, sub( 18, ipd_mean_change_e ) ); // Q13
return ipd_mean_change;
}
@@ -4434,6 +4457,7 @@ static void stereo_dft_enc_get_nipd_flag_fx(
hStereoDft->no_ipd_flag = hStereoDft->prev_no_ipd_flag;
move16();
hStereoDft->no_ipd_cnt = add( hStereoDft->no_ipd_cnt, 1 );
+ move16();
}
ELSE
{
@@ -4454,8 +4478,8 @@ static void stereo_dft_enc_get_nipd_flag_fx(
* ---------------------------------------------------------------*/
static void stereo_dft_enc_get_reverb_flag_fx(
STEREO_DFT_ENC_DATA_HANDLE hStereoDft,
- Word32 *pPredGain, // Q31
- Word32 *sub_nrg_DMX,
+ Word32 *pPredGain, // Q31
+ Word32 *sub_nrg_DMX, // Q(31-sub_nrg_DMX_e)
Word16 *sub_nrg_DMX_e,
const Word32 *sub_nrg_L, // Q(31-sub_nrg_L_e[])
const Word16 *sub_nrg_L_e,
diff --git a/lib_enc/ivas_stereo_dft_enc_itd.c b/lib_enc/ivas_stereo_dft_enc_itd.c
index 45eb643a570256b33d5c65f990ac20f1608f26b7..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 )
{
@@ -205,10 +205,15 @@ static void stereo_dft_quantize_itd_fx(
*-------------------------------------------------------------------------*/
static Word32 itd_vad_ms_snr_calc_fx(
+#ifdef FIX_ISSUE_1092
+ Word32 E_band_n[STEREO_DFT_ITD_VAD_BAND_NUM], // E_band_n_exp
+ Word16 E_band_n_exp[STEREO_DFT_ITD_VAD_BAND_NUM],
+#else
Word32 E_band_n[STEREO_DFT_ITD_VAD_BAND_NUM], // Q0
- Word32 *Spd,
+#endif
+ 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 )
{
@@ -248,7 +253,11 @@ static Word32 itd_vad_ms_snr_calc_fx(
// snr[i] = E_band[i] / E_band_n[i];
snr[i] = BASOP_Util_Divide3232_Scale_cadence( E_band[i], E_band_n[i], &snr_e[i] );
move32();
+#ifdef FIX_ISSUE_1092
+ snr_e[i] = add( snr_e[i], sub( E_band_e[i], E_band_n_exp[i] ) );
+#else
snr_e[i] = add( snr_e[i], sub( E_band_e[i], 31 ) );
+#endif
move16();
// if ( snr[i] < 1 )
IF( BASOP_Util_Cmp_Mant32Exp( snr[i], snr_e[i], 1, 31 ) < 0 )
@@ -284,11 +293,16 @@ static Word32 itd_vad_ms_snr_calc_fx(
*
*-------------------------------------------------------------------------*/
static void itd_vad_background_update_fx(
+#ifdef FIX_ISSUE_1092
+ Word32 E_band_n[STEREO_DFT_ITD_VAD_BAND_NUM], // E_band_n_exp
+ Word16 E_band_n_exp[STEREO_DFT_ITD_VAD_BAND_NUM],
+#else
Word32 E_band_n[STEREO_DFT_ITD_VAD_BAND_NUM], // Q0
+#endif
Word16 *vad_frm_cnt,
- const Word32 ms_snr,
+ 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;
@@ -326,23 +340,21 @@ static void itd_vad_background_update_fx(
Word16 q_temp = norm_l( *vad_frm_cnt );
L_temp = L_shl( *vad_frm_cnt, q_temp );
L_temp_e = sub( 31, q_temp );
+#ifdef FIX_ISSUE_1092
+ L_temp = BASOP_Util_Add_Mant32Exp( Mpy_32_32( E_band_n[i], L_temp ), add( E_band_n_exp[i], L_temp_e ), E_band[i], E_band_e[i], &L_temp_e );
+#else
L_temp = BASOP_Util_Add_Mant32Exp( Mpy_32_32( E_band_n[i], L_temp ), add( 31, L_temp_e ), E_band[i], E_band_e[i], &L_temp_e );
+#endif
E_band_n[i] = BASOP_Util_Divide3232_Scale_cadence( L_temp, L_add( *vad_frm_cnt, 1 ), &E_band_n_e_tmp );
move32();
+#ifdef FIX_ISSUE_1092
+ E_band_n_exp[i] = add( E_band_n_e_tmp, sub( L_temp_e, 31 ) );
+#else
E_band_n_e_tmp = add( E_band_n_e_tmp, sub( L_temp_e, 31 ) );
E_band_n[i] = L_shr_r( E_band_n[i], sub( 31, E_band_n_e_tmp ) ); // Q31
+#endif
move16();
}
- /*Word16 max_exp = E_band_n_e_tmp[0];
- for ( i = 1; i < STEREO_DFT_ITD_VAD_BAND_NUM; i++ )
- {
- max_exp = s_max( max_exp, E_band_n_e_tmp[i] );
- }
- *E_band_n_e = max_exp;
- for ( i = 0; i < STEREO_DFT_ITD_VAD_BAND_NUM; i++ )
- {
- E_band_n[i] = L_shr_r( E_band_n[i], sub( *E_band_n_e, E_band_n_e_tmp[i] ) );
- }*/
}
ELSE
{
@@ -352,6 +364,20 @@ static void itd_vad_background_update_fx(
FOR( i = 0; i < STEREO_DFT_ITD_VAD_BAND_NUM; i++ )
{
// E_band_n[i] = 0.96f * E_band_n[i] + 0.04f * E_band[i];
+#ifdef FIX_ISSUE_1092
+ E_band_n[i] = BASOP_Util_Add_Mant32Exp( Mpy_32_32( 2061584302 /*0.96 in Q31*/, E_band_n[i] ), E_band_n_exp[i], Mpy_32_32( 85899346 /*0.04 in Q31*/, E_band[i] ), E_band_e[i], &E_band_n_e_tmp );
+ move32();
+ E_band_n_exp[i] = E_band_n_e_tmp;
+ move16();
+ // if ( E_band_n[i] < 1.0f )
+ IF( BASOP_Util_Cmp_Mant32Exp( E_band_n[i], E_band_n_exp[i], MAX_32, 0 ) < 0 )
+ {
+ E_band_n[i] = MAX_32;
+ move32();
+ E_band_n_exp[i] = 0;
+ move16();
+ }
+#else
E_band_n[i] = BASOP_Util_Add_Mant32Exp( Mpy_32_32( 2061584302, E_band_n[i] ), 31, Mpy_32_32( 85899346, E_band[i] ), E_band_e[i], &E_band_n_e_tmp );
move32();
// if ( E_band_n[i] < 1.0f )
@@ -364,17 +390,8 @@ static void itd_vad_background_update_fx(
}
E_band_n[i] = L_shr_r( E_band_n[i], sub( 31, E_band_n_e_tmp ) ); // Q31
move32();
+#endif
}
- /*Word16 max_exp = E_band_n_e_tmp[0];
- for ( i = 1; i < STEREO_DFT_ITD_VAD_BAND_NUM; i++ )
- {
- max_exp = s_max( max_exp, E_band_n_e_tmp[i] );
- }
- *E_band_n_e = max_exp;
- for ( i = 0; i < STEREO_DFT_ITD_VAD_BAND_NUM; i++ )
- {
- E_band_n[i] = L_shr_r( E_band_n[i], sub( *E_band_n_e, E_band_n_e_tmp[i] ) );
- }*/
}
}
@@ -387,13 +404,18 @@ static void itd_vad_background_update_fx(
*-------------------------------------------------------------------------*/
static Word16 stereo_dft_enc_itd_vad_fx(
+#ifdef FIX_ISSUE_1092
+ Word32 E_band_n[STEREO_DFT_ITD_VAD_BAND_NUM], // E_band_n_exp
+ Word16 E_band_n_exp[STEREO_DFT_ITD_VAD_BAND_NUM],
+#else
Word32 E_band_n[STEREO_DFT_ITD_VAD_BAND_NUM], // Q0
+#endif
Word16 *vad_frm_cnt,
- Word32 *Spd_L,
+ 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;
@@ -414,12 +436,17 @@ static Word16 stereo_dft_enc_itd_vad_fx(
Spd_e[i] = sub( Spd_e[i], 1 );
move16();
}
+#ifdef FIX_ISSUE_1092
+ *mssnr = itd_vad_ms_snr_calc_fx( E_band_n, E_band_n_exp, Spd, Spd_e, E_band, E_band_e, mssnr_e );
+ move32();
+ itd_vad_background_update_fx( E_band_n, E_band_n_exp, vad_frm_cnt, *mssnr, *mssnr_e, E_band, E_band_e );
+#else
*mssnr = itd_vad_ms_snr_calc_fx( E_band_n, Spd, Spd_e, E_band, E_band_e, mssnr_e );
move32();
itd_vad_background_update_fx( E_band_n, vad_frm_cnt, *mssnr, *mssnr_e, E_band, E_band_e );
-
+#endif
// if ( *mssnr < ITD_VAD_THRSHOLD )
IF( BASOP_Util_Cmp_Mant32Exp( *mssnr, *mssnr_e, ITD_VAD_THRSHOLD_Q31, 0 ) < 0 )
{
@@ -445,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 )
{
@@ -495,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();
@@ -524,10 +551,10 @@ static Word32 calc_mean_E_ratio_fx(
FOR( i = band_limits[b]; i < min( band_limits[b + 1], STEREO_DFT_N_32k_ENC / 2 ); i++ )
{
// sum_xcorr[0] += hItd->xcorr_smooth[2 * i];
- sum_xcorr[0] = BASOP_Util_Add_Mant32Exp( sum_xcorr[0], sum_xcorr_e[0], hItd->xcorr_smooth_fx[2 * i], hItd->xcorr_smooth_fx_e, &sum_xcorr_e[0] );
+ sum_xcorr[0] = BASOP_Util_Add_Mant32Exp( sum_xcorr[0], sum_xcorr_e[0], hItd->xcorr_smooth_fx[2 * i], hItd->xcorr_smooth_fx_e[2 * i], &sum_xcorr_e[0] );
move32();
// sum_xcorr[1] += hItd->xcorr_smooth[2 * i + 1];
- sum_xcorr[1] = BASOP_Util_Add_Mant32Exp( sum_xcorr[1], sum_xcorr_e[1], hItd->xcorr_smooth_fx[2 * i + 1], hItd->xcorr_smooth_fx_e, &sum_xcorr_e[1] );
+ sum_xcorr[1] = BASOP_Util_Add_Mant32Exp( sum_xcorr[1], sum_xcorr_e[1], hItd->xcorr_smooth_fx[2 * i + 1], hItd->xcorr_smooth_fx_e[2 * i + 1], &sum_xcorr_e[1] );
move32();
// sum_nrg_L += nrg_L[i];
sum_nrg_L = BASOP_Util_Add_Mant32Exp( sum_nrg_L, sum_nrg_L_e, nrg_L[i], nrg_L_e[i], &sum_nrg_L_e );
@@ -583,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] ) );
@@ -622,15 +651,14 @@ static void resetEstimates_fx(
ITD_DATA_HANDLE hItd )
{
set32_fx( hItd->xcorr_smooth_fx, 0, STEREO_DFT_N_32k_ENC );
- hItd->xcorr_smooth_fx_e = 0;
- move16();
+ set16_fx( hItd->xcorr_smooth_fx_e, 0, STEREO_DFT_N_32k_ENC );
set32_fx( hItd->acorr_L_fx, 0, STEREO_DFT_BAND_MAX );
hItd->acorr_L_fx_e = 0;
move16();
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;
@@ -641,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;
@@ -682,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 )
@@ -738,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)
@@ -844,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();
@@ -861,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();
@@ -1096,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();
@@ -1134,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 )
@@ -1293,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 */
@@ -1444,13 +1473,15 @@ void stereo_dft_enc_compute_itd_fx(
move16();
FOR( Word16 ii = 0; ii < 11; ii++ )
{
- L_temp = BASOP_Util_Add_Mant32Exp( L_temp, L_temp_e, Spd_L[i + 1], Spd_L_e[i + 1], &L_temp_e );
+ L_temp = BASOP_Util_Add_Mant32Exp( L_temp, L_temp_e, Spd_L[ii + 1], Spd_L_e[ii + 1], &L_temp_e );
}
// L_temp = sum2_32_fx( &Spd_L[1], 11, &L_temp_e );
sum_nrg_L_lb = BASOP_Util_Add_Mant32Exp( sum_nrg_L_lb, sum_nrg_L_lb_e, L_temp, L_temp_e, &sum_nrg_L_lb_e );
-
+#ifdef FIX_ISSUE_1092
+ vad_flag_itd = stereo_dft_enc_itd_vad_fx( hItd->E_band_n_fx, hItd->E_band_n_exp, &( hItd->vad_frm_cnt ), Spd_L, Spd_L_e, Spd_R, Spd_R_e, &mssnr, &mssnr_e );
+#else
vad_flag_itd = stereo_dft_enc_itd_vad_fx( hItd->E_band_n_fx, &( hItd->vad_frm_cnt ), Spd_L, Spd_L_e, Spd_R, Spd_R_e, &mssnr, &mssnr_e );
-
+#endif
vad_flag_itd = vad_flag_itd && vad_flag_dtx[0];
// if ( sum_nrg_L < EPSILON )
@@ -1466,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 );
@@ -1490,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 );
@@ -1583,7 +1614,7 @@ void stereo_dft_enc_compute_itd_fx(
}
Word16 xcorr_smooth_fx_tmp_e[STEREO_DFT_N_32k_ENC];
- set16_fx( xcorr_smooth_fx_tmp_e, hItd->xcorr_smooth_fx_e, STEREO_DFT_N_32k_ENC );
+ Copy( hItd->xcorr_smooth_fx_e, xcorr_smooth_fx_tmp_e, STEREO_DFT_N_32k_ENC );
hItd->xcorr_smooth_fx[0] = 0;
move32();
xcorr_smooth_fx_tmp_e[0] = 0;
@@ -1690,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];
@@ -1733,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 )
@@ -1796,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;
@@ -1843,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;
@@ -1909,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;
@@ -1942,17 +1983,7 @@ void stereo_dft_enc_compute_itd_fx(
/* RESCALING TO COMMON EXP */
max_exp = MIN_16;
move16();
- FOR( i = 0; i < STEREO_DFT_N_32k_ENC; i++ )
- {
- max_exp = s_max( max_exp, xcorr_smooth_fx_tmp_e[i] );
- }
- hItd->xcorr_smooth_fx_e = max_exp;
- move16();
- FOR( i = 0; i < STEREO_DFT_N_32k_ENC; i++ )
- {
- hItd->xcorr_smooth_fx[i] = L_shr_r( hItd->xcorr_smooth_fx[i], sub( hItd->xcorr_smooth_fx_e, xcorr_smooth_fx_tmp_e[i] ) );
- move32();
- }
+ Copy( xcorr_smooth_fx_tmp_e, hItd->xcorr_smooth_fx_e, STEREO_DFT_N_32k_ENC );
max_exp = MIN_16;
move16();
FOR( i = 0; i < STEREO_DFT_N_32k_ENC; i++ )
@@ -2062,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 );
@@ -2094,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 ) ) );
@@ -2105,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();
}
@@ -2162,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 );
@@ -2170,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 );
@@ -2185,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();
@@ -2202,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) */
@@ -2223,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();
@@ -2231,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 );
@@ -2417,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 35f2467151a02a6e921a27388ed7b42b5758abd7..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,26 +239,27 @@ 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 );
- IF( LE_16( g_e, 0 ) )
- g = g;
- ELSE
- g = check_bounds_s_fx( g, negate( shl( 1, 15 - g_e ) ), shl( ONE_HALF, ( 1 - g_e ) ) );
- IF( LE_16( nsr_e, 0 ) )
- nsr = nsr;
- ELSE
- nsr = check_bounds_s_fx( nsr, 0, shl( 1, 15 - ( nsr_e ) ) );
- g = shl( g, g_e - 1 ); // q14
- nsr = shl( nsr, nsr_e ); // Q15
+ 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 ) ) );
+ }
+ IF( nsr_e > 0 )
+ {
+ nsr = check_bounds_s_fx( nsr, 0, shl( 1, sub( 15, nsr_e ) ) );
+ }
+ 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,18 +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
{
@@ -270,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
@@ -328,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;
@@ -343,6 +373,7 @@ void stereo_td_itd_fx(
Word16 itd, itd_max;
Word16 shift_input[L_FRAME48k];
Word16 shift_mem[L_FRAME48k];
+ Word16 q_shift_mem;
Word16 *mdct_mem[CPE_CHANNELS];
// Word16 q_mdct_mem[CPE_CHANNELS];
Word16 q_shift, q_new_shift;
@@ -354,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;
}
}
@@ -408,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!" );
@@ -449,17 +475,21 @@ 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();
}
ELSE
{
/*shift past part*/
Copy( mdct_mem[ch] + shift[ch], shift_mem, input_frame - shift[ch] );
Copy( sts[ch]->input_fx, shift_mem + input_frame - shift[ch], shift[ch] );
+ q_shift_mem = sts[ch]->q_inp;
+ 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();
@@ -490,7 +520,9 @@ void stereo_td_itd_fx(
ELSE
{
Copy( shift_mem, mdct_mem[ch], input_frame );
- Scale_sig( mdct_mem[ch], input_frame, sub( sts[ch]->q_inp, *q_input_mem ) );
+ sts[ch]->q_old_inp = q_new_shift;
+ move16();
+ Scale_sig( mdct_mem[ch], input_frame, sub( sts[ch]->q_inp, q_shift_mem ) ); // Q(sts[ch]->q_inp)
}
}
}
@@ -520,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 801aae865f15574a313d07f1da729b75675e5a19..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 );
@@ -1005,7 +984,11 @@ static void calc_poc_fx(
FOR( i = 0; i < hPHA->pha_len; i++ )
{
// hPHA->p_curr_taps[n][i] *= hPHA->win[i];
+#ifdef FIX_ISSUE_1153
+ hPHA->p_curr_taps_fx[n][i] = Mpy_32_16_1( hPHA->p_curr_taps_fx[n][i], hPHA->win_fx[i] ); // Q30
+#else
hPHA->p_curr_taps_fx[n][i] = L_shl( Mpy_32_16_1( hPHA->p_curr_taps_fx[n][i], hPHA->win_fx[i] ), 1 ); // Q31
+#endif
move32();
}
@@ -1013,9 +996,22 @@ static void calc_poc_fx(
move32();
energy_e = 0;
move16();
+#ifdef FIX_ISSUE_1153
+ Word16 shift = L_norm_arr( hPHA->p_curr_taps_fx[n], hPHA->pha_len );
+ IF( shift )
+ {
+ scale_sig32( hPHA->p_curr_taps_fx[n], hPHA->pha_len, 1 );
+ shift = 1;
+ move16();
+ }
+#endif
FOR( i = 0; i < hPHA->pha_len; i++ )
{
+#ifdef FIX_ISSUE_1153
+ energy = BASOP_Util_Add_Mant32Exp( energy, energy_e, Mpy_32_32_r( hPHA->p_curr_taps_fx[n][i], hPHA->p_curr_taps_fx[n][i] ), shl( sub( 1, shift ), 1 ), &energy_e );
+#else
energy = BASOP_Util_Add_Mant32Exp( energy, energy_e, Mpy_32_32_r( hPHA->p_curr_taps_fx[n][i], hPHA->p_curr_taps_fx[n][i] ), 0, &energy_e );
+#endif
}
// energy = (float) inv_sqrt( energy + EPSILON );
energy = BASOP_Util_Add_Mant32Exp( energy, energy_e, EPSILON_FX_M, EPSILON_FX_E, &energy_e );
@@ -1065,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();
@@ -1125,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;
@@ -1144,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;
@@ -1186,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;
@@ -1211,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++ )
{
@@ -1219,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*/
@@ -1357,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*/
{
@@ -1383,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();
@@ -1403,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;
}
@@ -1480,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 );
@@ -1554,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();
@@ -1605,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;
}
@@ -1616,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 */
@@ -1860,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();
@@ -1898,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();
@@ -1928,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
@@ -2084,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;
@@ -2123,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;
@@ -2276,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();
@@ -2333,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 ) )
@@ -2344,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 ) )
@@ -2355,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
@@ -2380,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;
@@ -2395,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();
@@ -2487,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:
@@ -2513,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 dbf4e1f7cfe5cb2b388a9e22e8133c46a40e9c3a..3f4696a0698e53d21ea0ef0c48f714b426e95daf 100644
--- a/lib_enc/ivas_stereo_ica_enc.c
+++ b/lib_enc/ivas_stereo_ica_enc.c
@@ -52,14 +52,14 @@
static void unclr_calc_corr_features_fx(
STEREO_CLASSIF_HANDLE hStereoClassif, /* i/o: stereo classifier handle */
STEREO_TCA_ENC_HANDLE hStereoTCA, /* i/o: ICA Stereo Encoder handle */
- Word32 buf1[], /* i : left channel */
- Word32 buf2[], /* i : right channel */
+ Word32 buf1[], /* i : left channel q_com*/
+ Word32 buf2[], /* i : right channel q_com*/
Word16 q_com,
- const Word16 length, /* i : length of input signal buffers */
- Word32 corrEst[], /* i : buffer containing inter-channel correlation values */
+ const Word16 length, /* i : length of input signal buffers Q0*/
+ Word32 corrEst[], /* i : buffer containing inter-channel correlation values Q31-corrEst_exp*/
Word16 corrEst_exp,
- const int16_t lagSearchRange[], /* i : minimum and maximum lags for corrEst[] */
- Word32 *corrEst_ncorr, /* o : norm. x-correlation btw. current and previous correlation buffers */
+ const Word16 lagSearchRange[], /* i : minimum and maximum lags for corrEst[] Q0*/
+ Word32 *corrEst_ncorr, /* o : norm. x-correlation btw. current and previous correlation buffers Q31-corrEst_ncorr_exp*/
Word16 *corrEst_ncorr_exp );
@@ -67,7 +67,7 @@ static void unclr_calc_corr_features_fx(
#define XH_BIAS_FX_Q15 13107
#define XL_WIDTH_FX_Q15 3932
#define XH_WIDTH_FX_Q15 4915
-#define SMOOTH_DIST_FACTOR_FX_Q15 14418
+#define SMOOTH_DIST_FACTOR_FX_Q15 13107
#define A_BIAS_FX_Q15 3277
#define B_BIAS_FX_Q15 -16384
#define A_WIDTH_FX_Q31 32212264
@@ -82,11 +82,11 @@ static void unclr_calc_corr_features_fx(
* ---------------------------------------------------------------*/
static void tcaTargetCh_LA_fx(
STEREO_TCA_ENC_HANDLE hStereoTCA,
- Word32 *ptrChanL,
- Word32 *ptrChanR,
+ Word32 *ptrChanL, /* q_com */
+ Word32 *ptrChanR, /* q_com */
Word16 *q_com,
- const Word16 currentNCShift,
- const Word16 input_frame )
+ const Word16 currentNCShift, /* Q0 */
+ const Word16 input_frame /* Q0 */ )
{
Word16 i, j;
Word16 tempS, temp, sine_inp;
@@ -99,7 +99,7 @@ static void tcaTargetCh_LA_fx(
ref_exp = sub( 31, *q_com );
target_exp = sub( 31, *q_com );
- set16_fx( target_exp_temp, target_exp, L_FRAME48k + 30 );
+ set16_fx( target_exp_temp, target_exp, L_FRAME48k + currentNCShift );
IF( EQ_16( hStereoTCA->refChanIndx, L_CH_INDX ) )
{
@@ -121,44 +121,46 @@ static void tcaTargetCh_LA_fx(
move32();
tempF2_exp = 0;
move16();
- FOR( i = 0; i < sub( input_frame, currentNCShift ); i++ )
+ FOR( i = 0; i < ( input_frame - currentNCShift ); i++ )
{
- tempF1 = BASOP_Util_Add_Mant32Exp( tempF1, tempF1_exp, L_abs( ref[i] ), ref_exp, &tempF1_exp );
- tempF2 = BASOP_Util_Add_Mant32Exp( tempF2, tempF2_exp, L_abs( target[i + currentNCShift] ), target_exp, &tempF2_exp );
+ tempF1 = BASOP_Util_Add_Mant32Exp( tempF1, tempF1_exp, L_abs( ref[i] ), ref_exp, &tempF1_exp ); /* Q31-tempF1_exp */
+ tempF2 = BASOP_Util_Add_Mant32Exp( tempF2, tempF2_exp, L_abs( target[i + currentNCShift] ), target_exp, &tempF2_exp ); /* Q31-tempF2_exp */
}
IF( tempF1 == 0 )
{
- gAdj = ONE_IN_Q31;
+ gAdj = ONE_IN_Q31; /* Q31 */
move32();
gAdj_exp = 0;
move16();
}
ELSE
{
- Word32 deno = BASOP_Util_Add_Mant32Exp( tempF1, tempF1_exp, -21475 /*0.00001f in Q31*/, 0, &temp );
+ Word32 deno = BASOP_Util_Add_Mant32Exp( tempF1, tempF1_exp, -21475 /*0.00001f in Q31*/, 0, &temp ); /* Q31-temp */
Word16 deno_exp;
IF( deno > 0 )
{
deno = tempF1;
+ move32();
deno_exp = tempF1_exp;
+ move16();
}
ELSE
{
deno = 21475;
+ move32();
deno_exp = 0;
+ move16();
}
- move32();
- move32();
- gAdj = BASOP_Util_Divide3232_Scale_cadence( tempF2, deno, &gAdj_exp );
+ gAdj = BASOP_Util_Divide3232_Scale_cadence( tempF2, deno, &gAdj_exp ); /* Q31-gAdj_exp */
gAdj_exp = add( gAdj_exp, sub( tempF2_exp, deno_exp ) );
}
FOR( i = 0; i < tempS; i++ )
{
- sine_inp = BASOP_Util_Divide1616_Scale( add( shl( i, 10 ), 512 ), shl( tempS, 1 ), &temp );
- sine_inp = shl_sat( sine_inp, add( temp, -10 ) );
- win[i] = getSineWord16R2( shr( sine_inp, 1 ) );
+ sine_inp = BASOP_Util_Divide1616_Scale( add( shl( i, 10 ), 512 /* 0.5 Q10 */ ), shl( tempS, 1 ), &temp ); /* Q15-(temp+(15-10)) */
+ sine_inp = shl_sat( sine_inp, add( temp, -10 ) ); /*Q0*/
+ win[i] = getSineWord16R2( shr( sine_inp, 1 ) ); /*Q15*/
move16();
}
@@ -167,9 +169,9 @@ static void tcaTargetCh_LA_fx(
Word16 exp_com = target_exp_temp[0];
move16();
- FOR( i = sub( input_frame, add( currentNCShift, tempS ) ); i < sub( input_frame, currentNCShift ); ( i++, j++ ) )
+ FOR( i = ( input_frame - ( currentNCShift + tempS ) ); i < ( input_frame - currentNCShift ); ( i++, j++ ) )
{
- target[i + currentNCShift] = BASOP_Util_Add_Mant32Exp( Mpy_32_32( Mpy_32_16_1( gAdj, win[j] ), ref[i] ), add( ref_exp, gAdj_exp ), Mpy_32_16_1( target[i + currentNCShift], sub( MAX_16, win[j] ) ), target_exp, &temp );
+ target[i + currentNCShift] = BASOP_Util_Add_Mant32Exp( Mpy_32_32( Mpy_32_16_1( gAdj, win[j] ), ref[i] ), add( ref_exp, gAdj_exp ), Mpy_32_16_1( target[i + currentNCShift], sub( MAX_16, win[j] ) ), target_exp, &temp ); /* Q31-temp */
move32();
target_exp_temp[i + currentNCShift] = temp;
move16();
@@ -178,18 +180,18 @@ static void tcaTargetCh_LA_fx(
FOR( ; i < input_frame; i++ )
{
- target[i + currentNCShift] = Mpy_32_32( gAdj, ref[i] );
+ target[i + currentNCShift] = Mpy_32_32( gAdj, ref[i] ); /* Q31-target_exp_temp */
move32();
target_exp_temp[i + currentNCShift] = add( gAdj_exp, ref_exp );
move16();
exp_com = s_max( exp_com, target_exp_temp[i + currentNCShift] );
}
- FOR( i = 0; i < input_frame; i++ )
+ FOR( i = 0; i < input_frame + currentNCShift; i++ )
{
- target[i] = L_shl( target[i], sub( target_exp_temp[i], exp_com ) );
+ target[i] = L_shl( target[i], sub( target_exp_temp[i], exp_com ) ); /* Q31-exp_com */
move32();
- ref[i] = L_shl( ref[i], sub( ref_exp, exp_com ) );
+ ref[i] = L_shl( ref[i], sub( ref_exp, exp_com ) ); /* Q31-exp_com */
move32();
}
*q_com = sub( 31, exp_com );
@@ -206,8 +208,8 @@ static void tcaTargetCh_LA_fx(
void spectral_balancer_fx16(
Word16 *signal, /* i/o : signal Qx */
Word16 *mem, /* i/o : mem Qx */
- const Word16 lg, /* i : input signal length */
- const Word16 coeff_set /* i : coefficient set */
+ const Word16 lg, /* i : input signal length Q0*/
+ const Word16 coeff_set /* i : coefficient set Q0*/
)
{
Word16 i;
@@ -268,26 +270,26 @@ void spectral_balancer_fx16(
FOR( i = 0; i < lg; i++ )
{
- x2 = x1;
+ x2 = x1; /*Qx*/
move16();
- x1 = x0;
+ x1 = x0; /*Qx*/
move16();
- x0 = signal[i];
+ x0 = signal[i]; /*Qx*/
move16();
// y0 = (y1 * a1) + (y2 * a2) + (x0 * b0) + (x1 * b1) + (x2 * b2);
y0 = extract_l( W_extract_l( W_shr( W_mac_32_16( W_mac_32_16( W_mac_32_16( W_mac_32_16( W_mult_32_16( a1, y1 ), a2, y2 ), b0, x0 ), b1, x1 ), b2, x2 ), 30 ) ) ); // Qx
- signal[i] = y0;
+ signal[i] = y0; /*Qx*/
move16();
- y2 = y1;
+ y2 = y1; /*Qx*/
move16();
- y1 = y0;
+ y1 = y0; /*Qx*/
move16();
}
- mem[0] = y1;
- mem[1] = y2;
- mem[2] = x0;
- mem[3] = x1;
+ mem[0] = y1; /*Qx*/
+ mem[1] = y2; /*Qx*/
+ mem[2] = x0; /*Qx*/
+ mem[3] = x1; /*Qx*/
move16();
move16();
move16();
@@ -299,18 +301,18 @@ void spectral_balancer_fx16(
void spectral_balancer_fx(
Word32 *signal, /* i/o : signal Qx */
Word32 *mem, /* i/o : mem Qx */
- const Word16 lg, /* i : input signal length */
- const Word16 coeff_set /* i : coefficient set */
+ const Word16 lg, /* i : input signal length Q0*/
+ const Word16 coeff_set /* i : coefficient set Q0*/
)
{
Word16 i;
Word32 x0, x1, x2, y0, y1, y2;
Word32 a1, a2, b0, b1, b2;
- y1 = mem[0];
- y2 = mem[1];
- x0 = mem[2];
- x1 = mem[3];
+ y1 = mem[0]; /*Qx*/
+ y2 = mem[1]; /*Qx*/
+ x0 = mem[2]; /*Qx*/
+ x1 = mem[3]; /*Qx*/
move32();
move32();
move32();
@@ -351,28 +353,28 @@ void spectral_balancer_fx(
FOR( i = 0; i < lg; i++ )
{
- x2 = x1;
+ x2 = x1; /*Qx*/
move16();
- x1 = x0;
+ x1 = x0; /*Qx*/
move16();
- x0 = signal[i];
+ x0 = signal[i]; /*Qx*/
move16();
y0 = W_extract_l( W_shr( W_mac_32_32( W_mac_32_32( W_mac_32_32( W_mac_32_32( W_mult_32_32( a1, y1 ), a2, y2 ), b0, x0 ), b1, x1 ), b2, x2 ), 30 ) ); // Qx
- signal[i] = y0;
+ signal[i] = y0; /*Qx*/
move16();
- y2 = y1;
+ y2 = y1; /*Qx*/
move16();
- y1 = y0;
+ y1 = y0; /*Qx*/
move16();
}
- mem[0] = y1;
+ mem[0] = y1; /*Qx*/
move32();
- mem[1] = y2;
+ mem[1] = y2; /*Qx*/
move32();
- mem[2] = x0;
+ mem[2] = x0; /*Qx*/
move32();
- mem[3] = x1;
+ mem[3] = x1; /*Qx*/
move32();
return;
@@ -384,14 +386,14 @@ void spectral_balancer_fx(
*
* De-emphasize and resample the L and R channels.
* ---------------------------------------------------------------*/
-static void deEmphResample(
+static void deEmphResample_fx(
STEREO_TCA_ENC_HANDLE hStereoTCA, /* i/o: Stereo TCA encoder handle */
const Word32 *tempChan1_fx, /* i : Stereo data Qx*/
const Word32 *tempChan2_fx, /* i : Stereo data Qx*/
- Word32 *chan1_fx, // Qx
- Word32 *chan2_fx, // Qx
- const Word16 input_frame,
- const Word16 dsFactor )
+ Word32 *chan1_fx, /*Qx*/
+ Word32 *chan2_fx, /*Qx*/
+ const Word16 input_frame, /*Q0*/
+ const Word16 dsFactor /*Q0*/ )
{
Word32 buf1_fx[L_FRAME48k], buf2_fx[L_FRAME48k];
Word32 tempBuf1_fx[2 * L_FRAME_DS], tempBuf2_fx[2 * L_FRAME_DS];
@@ -399,23 +401,23 @@ static void deEmphResample(
Word16 dsFac1, dsFac2;
/* Estimate first and second stage downsample factors */
- dsFac1 = shr( dsFactor, 1 );
- dsFac2 = idiv1616( dsFactor, dsFac1 );
+ dsFac1 = shr( dsFactor, 1 ); /*Qx*/
+ dsFac2 = idiv1616( dsFactor, dsFac1 ); /*Qx*/
/* convert stereo data to two distinct channels, e.g., L, R */
- Copy32( tempChan1_fx, buf1_fx, input_frame );
- Copy32( tempChan2_fx, buf2_fx, input_frame );
+ Copy32( tempChan1_fx, buf1_fx, input_frame ); /*Qx*/
+ Copy32( tempChan2_fx, buf2_fx, input_frame ); /*Qx*/
/* De-emphasis, 1/(1-mu z^-1), and resample, stage 1 */
deemph_fx_32( 0, buf1_fx, PREEMPH_FAC_16k, input_frame, &hStereoTCA->memdecim_fx[0] );
deemph_fx_32( 0, buf2_fx, PREEMPH_FAC_16k, input_frame, &hStereoTCA->memdecim_fx[1] );
- FOR( i = 0; i < idiv1616( input_frame, dsFac1 ); i++ )
+ FOR( i = 0; i < ( input_frame / dsFac1 ); i++ )
{
- tempBuf1_fx[i] = buf1_fx[i * dsFac1];
+ tempBuf1_fx[i] = buf1_fx[i * dsFac1]; /*Qx*/
move32();
- tempBuf2_fx[i] = buf2_fx[i * dsFac1];
+ tempBuf2_fx[i] = buf2_fx[i * dsFac1]; /*Qx*/
move32();
}
@@ -423,11 +425,11 @@ static void deEmphResample(
deemph_fx_32( 0, tempBuf1_fx, PREEMPH_FAC_16k, idiv1616( input_frame, dsFac1 ), &hStereoTCA->memdecim_fx[2] );
deemph_fx_32( 0, tempBuf2_fx, PREEMPH_FAC_16k, idiv1616( input_frame, dsFac1 ), &hStereoTCA->memdecim_fx[3] );
- FOR( i = 0; i < idiv1616( input_frame, dsFactor ); i++ )
+ FOR( i = 0; i < ( input_frame / dsFactor ); i++ )
{
- chan1_fx[i] = tempBuf1_fx[i * dsFac2];
+ chan1_fx[i] = tempBuf1_fx[i * dsFac2]; /*Qx*/
move32();
- chan2_fx[i] = tempBuf2_fx[i * dsFac2];
+ chan2_fx[i] = tempBuf2_fx[i * dsFac2]; /*Qx*/
move32();
}
@@ -444,13 +446,13 @@ static void deEmphResample(
* ---------------------------------------------------------------*/
static void utilCrossCorr_mod_fx(
STEREO_TCA_ENC_HANDLE hStereoTCA, /* i/o: ICA Stereo Encoder handle */
- Word32 *buf1,
- Word32 *buf2,
+ Word32 *buf1, /*q_com*/
+ Word32 *buf2, /*q_com*/
const Word16 q_com,
- Word32 *corrEst, /* o : correlation estimate */
- Word16 *corrEst_Exp, /* o : correlation estimate */
- const Word16 *lagSearchRange,
- const Word16 len )
+ Word32 *corrEst, /* o : correlation estimate Q31-corrEst_Exp*/
+ Word16 *corrEst_Exp, /* o : correlation estimate Q31-corrEst_Exp*/
+ const Word16 *lagSearchRange, /*Q0*/
+ const Word16 len /*Q0*/ )
{
Word32 C, E1, E2, C_C_mem;
Word16 i, j, E1_exp, E2_exp, Inv_Tot_E_exp, k, C_exp, exp, gb;
@@ -463,33 +465,34 @@ static void utilCrossCorr_mod_fx(
gb = 0;
move16();
- if ( LT_16( L_norm_arr( buf1, len ), 2 ) )
+ IF( LT_16( L_norm_arr( buf1, len ), 2 ) )
{
gb = 2;
move16();
}
- E1 = sum2_32_exp_fx( buf1, len, &E1_exp, gb );
+ E1 = sum2_32_exp_fx( buf1, len, &E1_exp, gb ); /* Q31-E1_exp */
gb = 0;
move16();
- if ( LT_16( L_norm_arr( buf2, len ), 2 ) )
+ IF( LT_16( L_norm_arr( buf2, len ), 2 ) )
{
gb = 2;
move16();
}
- E2 = sum2_32_exp_fx( buf2, len, &E2_exp, gb );
+ E2 = sum2_32_exp_fx( buf2, len, &E2_exp, gb ); /* Q31-E2_exp */
- Word32 E1_mul = BASOP_Util_Add_Mant32Exp( E1, E1_exp, hStereoTCA->E1_mem_fx, hStereoTCA->E1_mem_exp, &E1_exp );
- Word32 E2_mul = BASOP_Util_Add_Mant32Exp( E2, E2_exp, hStereoTCA->E2_mem_fx, hStereoTCA->E2_mem_exp, &E2_exp );
+ Word16 temp1, temp2;
+ Word32 E1_mul = BASOP_Util_Add_Mant32Exp( E1, E1_exp, hStereoTCA->E1_mem_fx, hStereoTCA->E1_mem_exp, &temp1 ); /* Q31-temp1 */
+ Word32 E2_mul = BASOP_Util_Add_Mant32Exp( E2, E2_exp, hStereoTCA->E2_mem_fx, hStereoTCA->E2_mem_exp, &temp2 ); /* Q31-temp2 */
Word32 sqr_inp = Mpy_32_32( E1_mul, E2_mul );
- Word16 sq_exp = add( E1_exp, E2_exp );
+ Word16 sq_exp = add( temp1, temp2 );
IF( sqr_inp )
{
- sqr_inp = Sqrt32( sqr_inp, &sq_exp );
- sqr_inp = Mpy_32_32( sqr_inp, 1342177280 /* 320 in Q22*/ );
+ sqr_inp = Sqrt32( sqr_inp, &sq_exp ); /* Q31-sq_exp */
+ sqr_inp = Mpy_32_32( sqr_inp, 1342177280 /* 320 in Q22*/ ); /* Q31-sq_exp+22-31 */
sq_exp = add( sq_exp, 9 );
- Inv_Tot_E = BASOP_Util_Divide3232_Scale( ONE_IN_Q31, sqr_inp, &Inv_Tot_E_exp );
+ Inv_Tot_E = BASOP_Util_Divide3232_Scale( ONE_IN_Q31, sqr_inp, &Inv_Tot_E_exp ); /* Q15-Inv_Tot_E_exp */
Inv_Tot_E_exp = add( Inv_Tot_E_exp, sub( 0, sq_exp ) );
}
ELSE
@@ -500,9 +503,9 @@ static void utilCrossCorr_mod_fx(
move16();
}
- hStereoTCA->E1_mem_fx = E1;
+ hStereoTCA->E1_mem_fx = E1; /* Q31-E1_exp */
move32();
- hStereoTCA->E2_mem_fx = E2;
+ hStereoTCA->E2_mem_fx = E2; /* Q31-E2_exp */
move32();
hStereoTCA->E1_mem_exp = E1_exp;
move16();
@@ -511,21 +514,20 @@ static void utilCrossCorr_mod_fx(
*corrEst_Exp = corrEst_exp[0];
move16();
- /* FOR BASOP causing error/warning */
- for ( i = lagSearchRange[0], j = 0; i <= 0; i++, j++ )
+ FOR( ( i = lagSearchRange[0], j = 0 ); i <= 0; ( i++, j++ ) )
{
L64_sum = 1;
move64();
FOR( k = 0; k < len; k++ )
{
- L64_sum = W_mac_32_32( L64_sum, buf1[k], buf2[k + i] );
+ L64_sum = W_mac_32_32( L64_sum, buf1[k], buf2[k + i] ); /* 2*q_com+1 */
}
k = W_norm( L64_sum );
- L64_sum = W_shl( L64_sum, k );
- C = W_extract_h( L64_sum ); // ener_side_q
+ L64_sum = W_shl( L64_sum, k ); /* 2*q_com+1+k */
+ C = W_extract_h( L64_sum ); // ener_side_q
C_exp = sub( 31, sub( add( add( shl( q_com, 1 ), 1 ), k ), 32 ) );
- C_C_mem = BASOP_Util_Add_Mant32Exp( C, C_exp, hStereoTCA->C_mem_fx[j], hStereoTCA->C_mem_exp[j], &exp );
- corrEst[j] = Mpy_32_16_1( C_C_mem, Inv_Tot_E );
+ C_C_mem = BASOP_Util_Add_Mant32Exp( C, C_exp, hStereoTCA->C_mem_fx[j], hStereoTCA->C_mem_exp[j], &exp ); /* Q31-exp */
+ corrEst[j] = Mpy_32_16_1( C_C_mem, Inv_Tot_E ); /* Q31-corrEst_exp */
move32();
corrEst_exp[j] = add( Inv_Tot_E_exp, exp );
move16();
@@ -537,21 +539,20 @@ static void utilCrossCorr_mod_fx(
move16();
}
- /* FOR BASOP causing error/warning */
- for ( ; i <= lagSearchRange[1]; i++, j++ )
+ FOR( ; i <= lagSearchRange[1]; ( i++, j++ ) )
{
L64_sum = 1;
move64();
FOR( k = 0; k < len; k++ )
{
- L64_sum = W_mac_32_32( L64_sum, buf1[k - i], buf2[k] );
+ L64_sum = W_mac_32_32( L64_sum, buf1[k - i], buf2[k] ); /* 2*q_com+1 */
}
k = W_norm( L64_sum );
- L64_sum = W_shl( L64_sum, k );
- C = W_extract_h( L64_sum ); // ener_side_q
+ L64_sum = W_shl( L64_sum, k ); /* 2*q_com+1+k */
+ C = W_extract_h( L64_sum ); // ener_side_q
C_exp = sub( 31, sub( add( add( shl( q_com, 1 ), 1 ), k ), 32 ) );
- C_C_mem = BASOP_Util_Add_Mant32Exp( C, C_exp, hStereoTCA->C_mem_fx[j], hStereoTCA->C_mem_exp[j], &exp );
- corrEst[j] = Mpy_32_16_1( C_C_mem, Inv_Tot_E );
+ C_C_mem = BASOP_Util_Add_Mant32Exp( C, C_exp, hStereoTCA->C_mem_fx[j], hStereoTCA->C_mem_exp[j], &exp ); /* Q31-exp */
+ corrEst[j] = Mpy_32_16_1( C_C_mem, Inv_Tot_E ); /* Q31-corrEst_exp */
move32();
corrEst_exp[j] = add( Inv_Tot_E_exp, exp );
move16();
@@ -567,7 +568,7 @@ static void utilCrossCorr_mod_fx(
FOR( i = 0; i < ( 2 * L_NCSHIFT_DS + 1 ); i++ )
{
- corrEst[i] = L_shl( corrEst[i], sub( corrEst_exp[i], *corrEst_Exp ) );
+ corrEst[i] = L_shl( corrEst[i], sub( corrEst_exp[i], *corrEst_Exp ) ); /* Q31-corrEst_Exp */
move32();
}
@@ -584,12 +585,12 @@ static void utilCrossCorr_fx(
Word16 buf1_q,
const Word32 *buf2, // buf2_q
Word16 buf2_q,
- const Word32 *win,
- Word32 *corrEst, /* o : correlation estimate corrEst_e */
+ const Word32 *win, /*Qx*/
+ Word32 *corrEst, /* o : correlation estimate corrEst_e */
Word16 *corrEst_e,
- const Word16 *lagSearchRange,
- const Word16 len,
- const Word16 winSymmFlag )
+ const Word16 *lagSearchRange, /*Q0*/
+ const Word16 len, /*Q0*/
+ const Word16 winSymmFlag /*Q0*/ )
{
Word32 tempBuf1[L_FRAME48k];
Word32 tempBuf2[L_FRAME48k];
@@ -619,17 +620,17 @@ static void utilCrossCorr_fx(
FOR( i = shr( len, 1 ); i < len; i++ )
{
- tempBuf1[i] = Mpy_32_32( win[len - 1 - i], buf1[i] );
+ tempBuf1[i] = Mpy_32_32( win[len - 1 - i], buf1[i] ); /* Qx+buf1_q-31 */
move32();
- tempBuf2[i] = Mpy_32_32( win[len - 1 - i], buf2[i] );
+ tempBuf2[i] = Mpy_32_32( win[len - 1 - i], buf2[i] ); /* Qx+buf2_q-31 */
move32();
}
}
}
ELSE
{
- Copy32( buf1, tempBuf1, len );
- Copy32( buf2, tempBuf2, len );
+ Copy32( buf1, tempBuf1, len ); /* buf1_q */
+ Copy32( buf2, tempBuf2, len ); /* buf2_q */
}
Word16 temp1_e = sub( Q31, buf1_q );
@@ -653,20 +654,20 @@ static void utilCrossCorr_fx(
assert( lagSearchRange[0] <= lagSearchRange[1] );
/* first part of noncausal corr est. */
- for ( i = lagSearchRange[0], j = 0; i <= s_min( 0, lagSearchRange[1] ); ( i++, j++ ) )
+ FOR( ( i = lagSearchRange[0], j = 0 ); i <= s_min( 0, lagSearchRange[1] ); ( i++, j++ ) )
{
L64_sum = 0;
move64();
- FOR( k = 0; k < add( len, i ); k++ )
+ FOR( k = 0; k < ( len + i ); k++ )
{
- L64_sum = W_mac_32_32( L64_sum, buf1[k - i], buf2[k] );
+ L64_sum = W_mac_32_32( L64_sum, buf1[k - i], buf2[k] ); /* buf1_q+buf2_q+1 */
}
k = W_norm( L64_sum );
- L64_sum = W_shl( L64_sum, k );
- temp = W_extract_h( L64_sum );
+ L64_sum = W_shl( L64_sum, k ); /* buf1_q+buf2_q+1+k */
+ temp = W_extract_h( L64_sum ); /* buf1_q+buf2_q+1+k-32 */
res_e = sub( 31, sub( add( add( add( buf1_q, buf2_q ), 1 ), k ), 32 ) );
- corrEst[j] = L_deposit_h( BASOP_Util_Divide3216_Scale( temp, ( len + i ), &tmp_e ) );
+ corrEst[j] = L_deposit_h( BASOP_Util_Divide3216_Scale( temp, ( len + i ), &tmp_e ) ); /* Q31-max_e */
move32();
corrEstTemp_e[j] = add( tmp_e, sub( res_e, 15 ) );
move16();
@@ -674,20 +675,20 @@ static void utilCrossCorr_fx(
}
/* second part of noncausal corr est. */
- for ( ; i <= lagSearchRange[1]; ( i++, j++ ) )
+ FOR( ; i <= lagSearchRange[1]; ( i++, j++ ) )
{
L64_sum = 1;
move64();
FOR( k = 0; k < sub( len, i ); k++ )
{
- L64_sum = W_mac_32_32( L64_sum, buf1[k], buf2[k + i] );
+ L64_sum = W_mac_32_32( L64_sum, buf1[k], buf2[k + i] ); /* buf1_q+buf2_q+1 */
}
k = W_norm( L64_sum );
- L64_sum = W_shl( L64_sum, k );
- temp = W_extract_h( L64_sum );
+ L64_sum = W_shl( L64_sum, k ); /* buf1_q+buf2_q+1+k */
+ temp = W_extract_h( L64_sum ); /* buf1_q+buf2_q+1+k-32 */
res_e = sub( 31, sub( add( add( add( buf1_q, buf2_q ), 1 ), k ), 32 ) );
- corrEst[j] = L_deposit_h( BASOP_Util_Divide3216_Scale( temp, ( len - i ), &tmp_e ) );
+ corrEst[j] = L_deposit_h( BASOP_Util_Divide3216_Scale( temp, ( len - i ), &tmp_e ) ); /* Q31-max_e */
move32();
corrEstTemp_e[j] = add( tmp_e, sub( res_e, 15 ) );
move16();
@@ -698,7 +699,7 @@ static void utilCrossCorr_fx(
FOR( i = 0; i < j; i++ )
{
- corrEst[i] = L_shr( corrEst[i], sub( max_e, corrEstTemp_e[i] ) );
+ corrEst[i] = L_shr( corrEst[i], sub( max_e, corrEstTemp_e[i] ) ); /* Q31-corrEstTemp_e */
move32();
}
@@ -716,22 +717,23 @@ static void utilCrossCorr_fx(
* Non-causal shift estimation to encode future samples.
* ---------------------------------------------------------------*/
-static Word16 TRUNC_FX( Word32 inp, Word16 exp )
+static Word16 TRUNC_FX( Word32 inp /*Q31-exp*/, Word16 exp )
{
Word16 ouptut;
Word32 temp;
- temp = L_shr( inp, sub( 31, exp ) );
+ temp = L_shr( inp, sub( 31, exp ) ); /*Q0*/
test();
IF( GT_32( temp, 32767 ) || LT_32( temp, -32768 ) )
{
+ test();
IF( temp < 0 )
{
- ouptut = -32768;
+ ouptut = -32768; /*Q0*/
}
ELSE
{
- ouptut = 32767;
+ ouptut = 32767; /*Q0*/
}
move16();
}
@@ -739,31 +741,31 @@ static Word16 TRUNC_FX( Word32 inp, Word16 exp )
{
IF( NE_32( temp, L_shl_sat( 1, sub( 31, exp ) ) ) )
{
- Word32 temp1 = L_add_sat( inp, L_shl_sat( 1, sub( 31, add( exp, 1 ) ) ) );
- ouptut = (Word16) L_shr( temp1, sub( 31, exp ) );
+ Word32 temp1 = L_add_sat( inp, L_shl_sat( 1, sub( 31, add( exp, 1 ) ) ) ); /* Q31-exp */
+ ouptut = extract_l( L_shr( temp1, sub( 31, exp ) ) ); /*Q0*/
IF( temp < 0 )
{
- ouptut = add( ouptut, 1 );
+ ouptut = add( ouptut, 1 ); /*Q0*/
}
}
ELSE
{
- ouptut = (Word16) temp;
+ ouptut = extract_l( temp ); /*Q0*/
move16();
}
}
- return ouptut;
+ return ouptut; /*Q0*/
}
static void corrStatsEst_fx(
STEREO_TCA_ENC_HANDLE hStereoTCA, /* i/o: Stereo TCA Encoder handle */
Word32 *buf1_fx, /* i : channel 1 q_com*/
Word32 *buf2_fx, /* i : channel 2 q_com*/
Word16 q_com,
- const Word16 bufLenDS, /* i : buffer length */
- const Word16 dsFactor, /* i : buffer length */
- const Word16 vad_flag1, /* i : VAD flag channel 1 */
- const Word16 vad_flag2, /* i : VAD flag channel 2 */
+ const Word16 bufLenDS, /* i : buffer length Q0*/
+ const Word16 dsFactor, /* i : buffer length Q0*/
+ const Word16 vad_flag1, /* i : VAD flag channel 1 Q0*/
+ const Word16 vad_flag2, /* i : VAD flag channel 2 Q0*/
STEREO_CLASSIF_HANDLE hStereoClassif /* i/o: stereo classifier handle */
)
{
@@ -831,46 +833,36 @@ static void corrStatsEst_fx(
/* back up the corrEst */
FOR( i = 0; i < 2; i++ )
{
- Copy32( hStereoTCA->corrEstPrev_fx[i + 1], hStereoTCA->corrEstPrev_fx[i], tempLen );
+ Copy32( hStereoTCA->corrEstPrev_fx[i + 1], hStereoTCA->corrEstPrev_fx[i], tempLen ); /* Q31-hStereoTCA->corrEstPrev_exp */
}
temp = getScaleFactor32( corrEst_fx, 2 * L_NCSHIFT_DS + 1 );
- scale_sig32( corrEst_fx, 2 * L_NCSHIFT_DS + 1, temp );
+ scale_sig32( corrEst_fx, 2 * L_NCSHIFT_DS + 1, temp ); /* Q31-corrEst_exp */
corrEst_exp = sub( corrEst_exp, temp );
- IF( GT_16( corrEst_exp, hStereoTCA->corrEstPrev_exp ) )
- {
- scale_sig32( hStereoTCA->corrEstPrev_fx[0], 2 * L_NCSHIFT_DS + 1, sub( hStereoTCA->corrEstPrev_exp, corrEst_exp ) );
- scale_sig32( hStereoTCA->corrEstPrev_fx[1], 2 * L_NCSHIFT_DS + 1, sub( hStereoTCA->corrEstPrev_exp, corrEst_exp ) );
- Copy32( corrEst_fx, hStereoTCA->corrEstPrev_fx[2], tempLen );
- hStereoTCA->corrEstPrev_exp = corrEst_exp;
- move16();
- }
- ELSE
- {
- Copy32( corrEst_fx, hStereoTCA->corrEstPrev_fx[2], tempLen );
- scale_sig32( hStereoTCA->corrEstPrev_fx[2], 2 * L_NCSHIFT_DS + 1, sub( corrEst_exp, hStereoTCA->corrEstPrev_exp ) );
- }
- scale_sig32( hStereoTCA->corrEstPrev_fx[0], 2 * L_NCSHIFT_DS + 1, -1 );
- scale_sig32( hStereoTCA->corrEstPrev_fx[1], 2 * L_NCSHIFT_DS + 1, -1 );
- scale_sig32( hStereoTCA->corrEstPrev_fx[2], 2 * L_NCSHIFT_DS + 1, -1 );
- hStereoTCA->corrEstPrev_exp = add( hStereoTCA->corrEstPrev_exp, 1 );
+ Copy32( corrEst_fx, hStereoTCA->corrEstPrev_fx[2], tempLen ); /* Q31-corrEst_exp */
+ hStereoTCA->corrEstPrev_exp = corrEst_exp;
+ move16();
+ Word16 gb = find_guarded_bits_fx( 2 * L_NCSHIFT_DS + 1 );
+
+ scale_sig32( hStereoTCA->corrEstPrev_fx[2], 2 * L_NCSHIFT_DS + 1, -gb ); /* Q31-hStereoTCA->corrEstPrev_exp-1 */
+ hStereoTCA->corrEstPrev_exp = add( hStereoTCA->corrEstPrev_exp, gb );
move16();
Word32 buf1_fx_temp[L_FRAME_DS];
Word32 buf2_fx_temp[L_FRAME_DS];
- Copy32( buf1_fx, buf1_fx_temp, L_FRAME_DS );
- Copy32( buf2_fx, buf2_fx_temp, L_FRAME_DS );
+ Copy32( buf1_fx, buf1_fx_temp, L_FRAME_DS ); /* q_com */
+ Copy32( buf2_fx, buf2_fx_temp, L_FRAME_DS ); /* q_com */
- scale_sig32( buf1_fx_temp, L_FRAME_DS, -4 );
- scale_sig32( buf2_fx_temp, L_FRAME_DS, -4 );
+ scale_sig32( buf1_fx_temp, L_FRAME_DS, -4 ); /* q_com-4 */
+ scale_sig32( buf2_fx_temp, L_FRAME_DS, -4 ); /* q_com-4 */
temp_A_fx = L_add( sumAbs_fx( buf1_fx_temp, L_FRAME_DS - L_XCORRMEM_DS ), sumAbs_fx( buf2_fx_temp, L_FRAME_DS - L_XCORRMEM_DS ) );
temp_B_fx = L_add( sumAbs_fx( buf1_fx_temp + ( L_FRAME_DS - L_XCORRMEM_DS ), L_XCORRMEM_DS ), sumAbs_fx( buf2_fx_temp + ( L_FRAME_DS - L_XCORRMEM_DS ), L_XCORRMEM_DS ) );
- tempF_fx = BASOP_Util_Add_Mant32Exp( L_add( temp_A_fx, temp_B_fx ), sub( 31, sub( q_com, 4 ) ), hStereoTCA->mem_tempF_fx, hStereoTCA->mem_tempF_exp, &temp );
+ tempF_fx = BASOP_Util_Add_Mant32Exp( L_add( temp_A_fx, temp_B_fx ), sub( 31, sub( q_com, 4 ) ), hStereoTCA->mem_tempF_fx, hStereoTCA->mem_tempF_exp, &temp ); /* Q31-tempF_exp */
Word16 tempF_exp = temp;
- hStereoTCA->mem_tempF_fx = temp_B_fx;
+ hStereoTCA->mem_tempF_fx = temp_B_fx; /* Q31-hStereoTCA->mem_tempF_exp */
move32();
hStereoTCA->mem_tempF_exp = sub( 31, sub( q_com, 4 ) );
move16();
@@ -894,18 +886,18 @@ static void corrStatsEst_fx(
move32();
/* long term corr Stats estimation */
- v_multc_fixed_16( hStereoTCA->corrEstLT_fx, alpha_fx, hStereoTCA->corrEstLT_fx, 2 * L_NCSHIFT_DS + 1 );
- v_multc_fixed_16( corrEst_fx, sub( MAX_16, alpha_fx ), corrEst_fx, 2 * L_NCSHIFT_DS + 1 );
+ v_multc_fixed_16( hStereoTCA->corrEstLT_fx, alpha_fx, hStereoTCA->corrEstLT_fx, 2 * L_NCSHIFT_DS + 1 ); /* Q31-hStereoTCA->corrEstLT_exp */
+ v_multc_fixed_16( corrEst_fx, sub( MAX_16, alpha_fx ), corrEst_fx, 2 * L_NCSHIFT_DS + 1 ); /* Q31-corrEst_exp */
v_add_fixed_me( hStereoTCA->corrEstLT_fx, hStereoTCA->corrEstLT_exp, corrEst_fx, corrEst_exp, hStereoTCA->corrEstLT_fx, &hStereoTCA->corrEstLT_exp, 2 * L_NCSHIFT_DS + 1, 0 );
- hStereoTCA->ica_envVarLT_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( hStereoTCA->ica_envVarLT_fx, SMOOTH_ENV_FACTOR_FX_Q15 ), hStereoTCA->ica_envVarLT_exp, Mpy_32_16_1( tempF_fx, ONE_IN_Q15 - SMOOTH_ENV_FACTOR_FX_Q15 ), tempF_exp, &hStereoTCA->ica_envVarLT_exp ); // SMOOTH_ENV_FACTOR_FX_Q15
+ hStereoTCA->ica_envVarLT_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( hStereoTCA->ica_envVarLT_fx, SMOOTH_ENV_FACTOR_FX_Q15 ), hStereoTCA->ica_envVarLT_exp, Mpy_32_16_1( tempF_fx, ONE_IN_Q15 - SMOOTH_ENV_FACTOR_FX_Q15 ), tempF_exp, &hStereoTCA->ica_envVarLT_exp ); // SMOOTH_ENV_FACTOR_FX_Q15 (Q31-hStereoTCA->ica_envVarLT_exp)
move32();
- Copy32( hStereoTCA->corrEstLT_fx, corrEst_fx, 2 * L_NCSHIFT_DS + 1 );
+ Copy32( hStereoTCA->corrEstLT_fx, corrEst_fx, 2 * L_NCSHIFT_DS + 1 ); /* Q31-hStereoTCA->corrEstLT_exp */
corrEst_exp = hStereoTCA->corrEstLT_exp;
move16();
- Y_hat_fx = hStereoTCA->delay_0_mem_fx[0];
+ Y_hat_fx = hStereoTCA->delay_0_mem_fx[0]; /* Q31-hStereoTCA->delay_0_mem_exp */
move32();
Y_hat_exp = hStereoTCA->delay_0_mem_exp;
move16();
@@ -913,36 +905,38 @@ static void corrStatsEst_fx(
/* Note: keep X_hat and X_SQR_hat calculations inside the loop to allow future tuning of MAX_DELAYREGLEN */
FOR( i = 1; i < MAX_DELAYREGLEN; i++ )
{
- X_hat_fx = BASOP_Util_Add_Mant32Exp( X_hat_fx, X_hat_exp, L_shl( i, 27 ), 4, &X_hat_exp );
- Y_hat_fx = BASOP_Util_Add_Mant32Exp( Y_hat_fx, Y_hat_exp, hStereoTCA->delay_0_mem_fx[i], hStereoTCA->delay_0_mem_exp, &Y_hat_exp );
- XY_hat_fx = BASOP_Util_Add_Mant32Exp( XY_hat_fx, XY_hat_exp, Mpy_32_32( hStereoTCA->delay_0_mem_fx[i], L_shl( i, 27 ) ), add( 4, hStereoTCA->delay_0_mem_exp ), &XY_hat_exp );
- X_SQR_hat_fx = BASOP_Util_Add_Mant32Exp( X_SQR_hat_fx, X_SQR_hat_exp, Mpy_32_32( L_shl( i, 27 ), L_shl( i, 27 ) ), 8, &X_SQR_hat_exp );
+ X_hat_fx = BASOP_Util_Add_Mant32Exp( X_hat_fx, X_hat_exp, L_shl( i, 27 ), 4, &X_hat_exp ); /* Q31-X_hat_exp */
+ Y_hat_fx = BASOP_Util_Add_Mant32Exp( Y_hat_fx, Y_hat_exp, hStereoTCA->delay_0_mem_fx[i], hStereoTCA->delay_0_mem_exp, &Y_hat_exp ); /* Q31-Y_hat_exp */
+ XY_hat_fx = BASOP_Util_Add_Mant32Exp( XY_hat_fx, XY_hat_exp, Mpy_32_32( hStereoTCA->delay_0_mem_fx[i], L_shl( i, 27 ) ), add( 4, hStereoTCA->delay_0_mem_exp ), &XY_hat_exp ); /* Q31-XY_hat_exp */
+ X_SQR_hat_fx = BASOP_Util_Add_Mant32Exp( X_SQR_hat_fx, X_SQR_hat_exp, Mpy_32_32( L_shl( i, 27 ), L_shl( i, 27 ) ), 8, &X_SQR_hat_exp ); /* Q31-X_SQR_hat_exp */
}
- X_hat_fx = Mpy_32_16_1( X_hat_fx, INV_MAX_DELAYREGLEN_FX_Q15 );
- Y_hat_fx = Mpy_32_16_1( Y_hat_fx, INV_MAX_DELAYREGLEN_FX_Q15 );
- XY_hat_fx = Mpy_32_16_1( XY_hat_fx, INV_MAX_DELAYREGLEN_FX_Q15 );
- X_SQR_hat_fx = Mpy_32_16_1( X_SQR_hat_fx, INV_MAX_DELAYREGLEN_FX_Q15 );
+ X_hat_fx = Mpy_32_16_1( X_hat_fx, INV_MAX_DELAYREGLEN_FX_Q15 ); /* Q31-X_hat_exp */
+ Y_hat_fx = Mpy_32_16_1( Y_hat_fx, INV_MAX_DELAYREGLEN_FX_Q15 ); /* Q31-Y_hat_exp */
+ XY_hat_fx = Mpy_32_16_1( XY_hat_fx, INV_MAX_DELAYREGLEN_FX_Q15 ); /* Q31-XY_hat_exp */
+ X_SQR_hat_fx = Mpy_32_16_1( X_SQR_hat_fx, INV_MAX_DELAYREGLEN_FX_Q15 ); /* Q31-X_SQR_hat_exp */
beta_reg_fx = 0;
move32();
beta_reg_exp = 0;
move16();
- tempF_fx = BASOP_Util_Add_Mant32Exp( X_SQR_hat_fx, X_SQR_hat_exp, L_negate( Mpy_32_32( X_hat_fx, X_hat_fx ) ), shl( X_hat_exp, 1 ), &tempF_exp );
+ tempF_fx = BASOP_Util_Add_Mant32Exp( X_SQR_hat_fx, X_SQR_hat_exp, L_negate( Mpy_32_32( X_hat_fx, X_hat_fx ) ), shl( X_hat_exp, 1 ), &tempF_exp ); /* Q31-tempF_exp */
IF( tempF_fx != 0 )
{
- temp32 = BASOP_Util_Add_Mant32Exp( XY_hat_fx, XY_hat_exp, L_negate( Mpy_32_32( X_hat_fx, Y_hat_fx ) ), add( X_hat_exp, Y_hat_exp ), &exp );
- beta_reg_fx = BASOP_Util_Divide3232_Scale_cadence( temp32, tempF_fx, &beta_reg_exp );
+ temp32 = BASOP_Util_Add_Mant32Exp( XY_hat_fx, XY_hat_exp, L_negate( Mpy_32_32( X_hat_fx, Y_hat_fx ) ), add( X_hat_exp, Y_hat_exp ), &exp ); /* Q31-exp */
+ beta_reg_fx = BASOP_Util_Divide3232_Scale_cadence( temp32, tempF_fx, &beta_reg_exp ); /* Q31-beta_reg_exp */
if ( beta_reg_fx )
{
beta_reg_exp = add( beta_reg_exp, sub( exp, tempF_exp ) );
}
}
- 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 );
- 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 );
+ 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;
@@ -959,21 +953,21 @@ static void corrStatsEst_fx(
move16();
}
- bias_par_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( hStereoTCA->smooth_dist_reg_prv_corr_fx, A_BIAS_FX_Q15 ), hStereoTCA->smooth_dist_reg_prv_corr_exp, L_shl( B_BIAS_FX_Q15, Q16 ), 0, &bias_par_exp );
+ bias_par_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( hStereoTCA->smooth_dist_reg_prv_corr_fx, A_BIAS_FX_Q15 ), hStereoTCA->smooth_dist_reg_prv_corr_exp, L_shl( B_BIAS_FX_Q15, Q16 ), 0, &bias_par_exp ); /* Q31-bias_par_exp */
- Word32 XH_BIAS_tmp = L_shl( XH_BIAS_FX_Q15, Q16 );
- Word32 XL_BIAS_tmp = L_shl( XL_BIAS_FX_Q15, Q16 );
+ Word32 XH_BIAS_tmp = L_shl( XH_BIAS_FX_Q15, Q16 ); /* Q31 */
+ Word32 XL_BIAS_tmp = L_shl( XL_BIAS_FX_Q15, Q16 ); /* Q31 */
IF( bias_par_exp < 0 )
{
- bias_par_fx = L_shl( bias_par_fx, bias_par_exp );
+ bias_par_fx = L_shl( bias_par_fx, bias_par_exp ); /* Q31 */
bias_par_exp = 0;
move16();
}
ELSE
{
- XH_BIAS_tmp = L_shr( XH_BIAS_tmp, bias_par_exp );
- XL_BIAS_tmp = L_shr( XL_BIAS_tmp, bias_par_exp );
+ XH_BIAS_tmp = L_shr( XH_BIAS_tmp, bias_par_exp ); /* Q31-bias_par_exp */
+ XL_BIAS_tmp = L_shr( XL_BIAS_tmp, bias_par_exp ); /* Q31-bias_par_exp */
}
bias_par_fx = L_min( bias_par_fx, XH_BIAS_tmp );
@@ -982,13 +976,13 @@ static void corrStatsEst_fx(
bias_par_exp = 0;
move16();
- width_par_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_32( hStereoTCA->smooth_dist_reg_prv_corr_fx, A_WIDTH_FX_Q31 ), hStereoTCA->smooth_dist_reg_prv_corr_exp, B_WIDTH_FX_Q31, 0, &width_par_exp );
- Word32 XH_WIDTH_tmp = L_shl( XH_WIDTH_FX_Q15, Q16 );
- Word32 XL_WIDTH_tmp = L_shl( XL_WIDTH_FX_Q15, Q16 );
+ width_par_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_32( hStereoTCA->smooth_dist_reg_prv_corr_fx, A_WIDTH_FX_Q31 ), hStereoTCA->smooth_dist_reg_prv_corr_exp, B_WIDTH_FX_Q31, 0, &width_par_exp ); /* Q31-width_par_exp */
+ Word32 XH_WIDTH_tmp = L_shl( XH_WIDTH_FX_Q15, Q16 ); /* Q31 */
+ Word32 XL_WIDTH_tmp = L_shl( XL_WIDTH_FX_Q15, Q16 ); /* Q31 */
IF( width_par_exp < 0 )
{
- width_par_fx = L_shl( width_par_fx, width_par_exp );
+ width_par_fx = L_shl( width_par_fx, width_par_exp ); /* Q31 */
width_par_exp = 0;
move16();
}
@@ -1003,39 +997,40 @@ static void corrStatsEst_fx(
width_par_exp = 0;
move16();
- win_width = (Word16) L_shr( Mpy_32_32( width_par_fx, 1350565888 /* ( 4L_NCSHIFT_DS + 1 ) in Q23 */ ), sub( 31, add( width_par_exp, 8 ) ) );
+ win_width = (Word16) L_shr( Mpy_32_32( width_par_fx, 1350565888 /* ( 4L_NCSHIFT_DS + 1 ) in Q23 */ ), sub( 31, add( width_par_exp, 8 ) ) ); /* Q23-(31-(width_par_exp-8)) */
win_bias_fx = round_fx( bias_par_fx ); // Q15
k1_fx = add( MAX_16 >> 1, shr( win_bias_fx, 1 ) ); // Q15
k2_fx = sub( MAX_16 >> 1, shr( win_bias_fx, 1 ) ); // Q15
- FOR( i = 0; i < sub( 2 * L_NCSHIFT_DS, shl( win_width, 1 ) ); i++ )
+ FOR( i = 0; i < ( 2 * L_NCSHIFT_DS - ( win_width * 2 ) ); i++ )
{
loc_weight_win_fx[i] = win_bias_fx; // Q15
move16();
}
- FOR( i = sub( 2 * L_NCSHIFT_DS, shl( win_width, 1 ) ); i <= add( 2 * L_NCSHIFT_DS, shl( win_width, 1 ) ); i++ )
+ FOR( i = ( 2 * L_NCSHIFT_DS - ( win_width * 2 ) ); i <= ( 2 * L_NCSHIFT_DS + ( win_width * 2 ) ); i++ )
{
- Word16 cos_inp = BASOP_Util_Divide1616_Scale( sub( i, 2 * L_NCSHIFT_DS ), shl( win_width, 1 ), &exp );
+ Word16 cos_inp = BASOP_Util_Divide1616_Scale( sub( i, 2 * L_NCSHIFT_DS ), shl( win_width, 1 ), &exp ); /* Q15-exp */
cos_inp = shr_sat( cos_inp, sub( 0, exp ) );
- cos_inp = getCosWord16R2( shr( cos_inp, 1 ) );
- loc_weight_win_fx[i] = add( k1_fx, mult( k2_fx, cos_inp ) );
+ cos_inp = getCosWord16R2( shr( cos_inp, 1 ) ); // Q15
+ loc_weight_win_fx[i] = add( k1_fx, mult( k2_fx, cos_inp ) ); // Q15
move16();
}
- FOR( i = add( 2 * L_NCSHIFT_DS, shl( win_width, 1 ) ); i < ( 4 * L_NCSHIFT_DS + 1 ); i++ )
+ FOR( i = ( 2 * L_NCSHIFT_DS + ( win_width * 2 ) ); i < ( 4 * L_NCSHIFT_DS + 1 ); i++ )
{
loc_weight_win_fx[i] = win_bias_fx; // Q15
move16();
}
-
- Word16 x = TRUNC_FX( reg_prv_corr_fx, 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 );
+ Word16 x = TRUNC_FX( reg_prv_corr_fx, reg_prv_corr_exp ); /* Q0 */
move16();
- for ( i = 0, j = sub( L_NCSHIFT_DS, x ); i < 2 * L_NCSHIFT_DS + 1; i++, j++ )
+ for ( i = 0, j = ( L_NCSHIFT_DS - x ); i < 2 * L_NCSHIFT_DS + 1; i++, j++ )
{
- corrEst_fx[i] = Mpy_32_16_1( corrEst_fx[i], loc_weight_win_fx[j] );
+ corrEst_fx[i] = Mpy_32_16_1( corrEst_fx[i], loc_weight_win_fx[j] ); /* Q31-corrEst_exp */
move32();
}
test();
@@ -1043,15 +1038,15 @@ static void corrStatsEst_fx(
IF( LT_32( hStereoTCA->prevTargetGain_fx, 429496730 /*0.8f in Q29*/ ) && vad_flag1 )
{
/* ch 2 is prev reference channel */
- v_multc_fixed( corrEst_fx, 644245095 /*1.2f in Q29*/, corrEst_fx, L_NCSHIFT_DS + 1 );
- v_multc_fixed( corrEst_fx + L_NCSHIFT_DS + 1, 447213470 /* 0.833 in Q29*/, corrEst_fx + L_NCSHIFT_DS + 1, L_NCSHIFT_DS );
+ v_multc_fixed( corrEst_fx, 644245095 /*1.2f in Q29*/, corrEst_fx, L_NCSHIFT_DS + 1 ); /* Q31-corrEst_exp */
+ v_multc_fixed( corrEst_fx + L_NCSHIFT_DS + 1, 447213470 /* 0.833 in Q29*/, corrEst_fx + L_NCSHIFT_DS + 1, L_NCSHIFT_DS ); /* Q31-corrEst_exp */
corrEst_exp = add( corrEst_exp, 2 );
}
ELSE IF( GT_32( hStereoTCA->prevTargetGain_fx, 644245094 /*1.2f in Q29*/ ) && vad_flag1 )
{
/* ch 1 is prev reference channel */
- v_multc_fixed( corrEst_fx, 447213470 /* 0.833 f in Q29*/, corrEst_fx, L_NCSHIFT_DS );
- v_multc_fixed( corrEst_fx + L_NCSHIFT_DS, 644245095 /*1.2f in Q29*/, corrEst_fx + L_NCSHIFT_DS, L_NCSHIFT_DS + 1 );
+ v_multc_fixed( corrEst_fx, 447213470 /* 0.833 f in Q29*/, corrEst_fx, L_NCSHIFT_DS ); /* Q31-corrEst_exp */
+ v_multc_fixed( corrEst_fx + L_NCSHIFT_DS, 644245095 /*1.2f in Q29*/, corrEst_fx + L_NCSHIFT_DS, L_NCSHIFT_DS + 1 ); /* Q31-corrEst_exp */
corrEst_exp = add( corrEst_exp, 2 );
}
test();
@@ -1061,9 +1056,9 @@ static void corrStatsEst_fx(
j = s_min( 2 * L_NCSHIFT_DS, add( hStereoTCA->prevCorrLagStats[0], 1 + L_NCSHIFT_DS ) );
k = add( sub( j, i ), 1 );
- v_multc_fixed( corrEst_fx, ONE_IN_Q29 /*1.0f in Q29*/, corrEst_fx, i ); // to allign in same exp
- v_multc_fixed( corrEst_fx + i, 644245095 /*1.2f in Q29*/, corrEst_fx + i, k );
- v_multc_fixed( corrEst_fx + i + k, ONE_IN_Q29 /*1.0f in Q29*/, corrEst_fx + i + k, sub( 2 * L_NCSHIFT_DS + 1, i + k ) ); // to allign in same exp
+ v_multc_fixed( corrEst_fx, ONE_IN_Q29 /*1.0f in Q29*/, corrEst_fx, i ); // to allign in same exp (Q31-corrEst_exp)
+ v_multc_fixed( corrEst_fx + i, 644245095 /*1.2f in Q29*/, corrEst_fx + i, k ); /* Q31-corrEst_exp */
+ v_multc_fixed( corrEst_fx + i + k, ONE_IN_Q29 /*1.0f in Q29*/, corrEst_fx + i + k, sub( 2 * L_NCSHIFT_DS + 1, i + k ) ); // to allign in same exp (Q31-corrEst_exp)
corrEst_exp = add( corrEst_exp, 2 );
}
@@ -1075,35 +1070,35 @@ static void corrStatsEst_fx(
corrLagStats[0] = add( corrLagStats[0], lagSearchRange[0] );
move16();
- stmp = i_mult( corrLagStats[0], dsFactor );
- hStereoClassif->unclr_fv_fx[E_corrLagStats0] = L_shl( stmp, Q15 );
+ stmp = i_mult( corrLagStats[0], dsFactor ); /* Q0 */
+ hStereoClassif->unclr_fv_fx[E_corrLagStats0] = L_shl( stmp, Q15 ); /* Q15 */
move32();
- hStereoClassif->xtalk_fv_fx[E_corrLagStats0] = L_shl( stmp, Q15 );
+ hStereoClassif->xtalk_fv_fx[E_corrLagStats0] = L_shl( stmp, Q15 ); /* Q15 */
move32();
- hStereoClassif->xtalk_fv_fx[E_ica_corr_value0] = L_shl( tempF_fx, sub( tempF_exp, Q16 ) );
+ hStereoClassif->xtalk_fv_fx[E_ica_corr_value0] = L_shl( tempF_fx, sub( tempF_exp, Q16 ) ); /* Q15 */
move32();
test();
- if ( vad_flag1 == 0 && GT_16( alpha_fx, 22938 /* 0.7f in Q15 */ ) )
+ IF( vad_flag1 == 0 && GT_16( alpha_fx, 22938 /* 0.7f in Q15 */ ) )
{
corrLagStats[0] = 0;
move16();
}
- dist_reg_prv_corr_fx = L_abs( BASOP_Util_Add_Mant32Exp( reg_prv_corr_fx, reg_prv_corr_exp, -corrLagStats[0], Q31, &dist_reg_prv_corr_exp ) );
+ dist_reg_prv_corr_fx = L_abs( BASOP_Util_Add_Mant32Exp( reg_prv_corr_fx, reg_prv_corr_exp, -corrLagStats[0], Q31, &dist_reg_prv_corr_exp ) ); /* Q31-dist_reg_prv_corr_exp */
test();
IF( EQ_16( vad_flag1, 1 ) && EQ_16( vad_flag2, 1 ) )
{
- hStereoTCA->smooth_dist_reg_prv_corr_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( hStereoTCA->smooth_dist_reg_prv_corr_fx, SMOOTH_DIST_FACTOR_FX_Q15 ), hStereoTCA->smooth_dist_reg_prv_corr_exp, Mpy_32_16_1( dist_reg_prv_corr_fx, MAX_16 - SMOOTH_DIST_FACTOR_FX_Q15 ), dist_reg_prv_corr_exp, &hStereoTCA->smooth_dist_reg_prv_corr_exp );
+ hStereoTCA->smooth_dist_reg_prv_corr_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( hStereoTCA->smooth_dist_reg_prv_corr_fx, SMOOTH_DIST_FACTOR_FX_Q15 ), hStereoTCA->smooth_dist_reg_prv_corr_exp, Mpy_32_16_1( dist_reg_prv_corr_fx, MAX_16 - SMOOTH_DIST_FACTOR_FX_Q15 ), dist_reg_prv_corr_exp, &hStereoTCA->smooth_dist_reg_prv_corr_exp ); /* Q31-hStereoTCA->smooth_dist_reg_prv_corr_exp */
move32();
- Copy32( &( hStereoTCA->delay_0_mem_fx[1] ), &( hStereoTCA->delay_0_mem_fx[0] ), MAX_DELAYREGLEN - 1 );
+ Copy32( &( hStereoTCA->delay_0_mem_fx[1] ), &( hStereoTCA->delay_0_mem_fx[0] ), MAX_DELAYREGLEN - 1 ); /* Q31-hStereoTCA->delay_0_mem_exp */
- hStereoTCA->delay_0_mem_fx[MAX_DELAYREGLEN - 1] = BASOP_Util_Add_Mant32Exp( Mpy_32_32( hStereoTCA->delay_0_mem_fx[MAX_DELAYREGLEN - 1], 429496730 /* 0.2 in Q31*/ ), hStereoTCA->delay_0_mem_exp, L_mult0( 26214 /* 0.8 in Q15*/, corrLagStats[0] ), Q16, &temp );
+ hStereoTCA->delay_0_mem_fx[MAX_DELAYREGLEN - 1] = BASOP_Util_Add_Mant32Exp( Mpy_32_32( hStereoTCA->delay_0_mem_fx[MAX_DELAYREGLEN - 1], 429496730 /* 0.2 in Q31*/ ), hStereoTCA->delay_0_mem_exp, L_mult0( 26214 /* 0.8 in Q15*/, corrLagStats[0] ), Q16, &temp ); /* Q31-temp */
move32();
- Word32 inpp = L_abs( BASOP_Util_Add_Mant32Exp( reg_prv_corr_fx, reg_prv_corr_exp, -hStereoTCA->delay_0_mem_fx[0], hStereoTCA->delay_0_mem_exp, &exp ) );
- inpp = L_shr( inpp, sub( Q31, exp ) );
- IF( GT_32( inpp, 25 ) )
+ Word32 inpp = L_abs( BASOP_Util_Add_Mant32Exp( reg_prv_corr_fx, reg_prv_corr_exp, -hStereoTCA->delay_0_mem_fx[0], hStereoTCA->delay_0_mem_exp, &exp ) ); /* Q31-exp */
+ inpp = L_shl_sat( inpp, sub( exp, 5 ) ); /* Q26 */
+ IF( GT_32( inpp, 1677721600 ) ) // 25 in Q26
{
set32_fx( &( hStereoTCA->delay_0_mem_fx[0] ), hStereoTCA->delay_0_mem_fx[MAX_DELAYREGLEN - 1], MAX_DELAYREGLEN - 1 );
hStereoTCA->delay_0_mem_exp = temp;
@@ -1113,13 +1108,13 @@ static void corrStatsEst_fx(
{
IF( GT_16( temp, hStereoTCA->delay_0_mem_exp ) )
{
- scale_sig32( hStereoTCA->delay_0_mem_fx, MAX_DELAYREGLEN - 1, sub( hStereoTCA->delay_0_mem_exp, temp ) );
+ scale_sig32( hStereoTCA->delay_0_mem_fx, MAX_DELAYREGLEN - 1, sub( hStereoTCA->delay_0_mem_exp, temp ) ); /* Q31-hStereoTCA->delay_0_mem_exp */
hStereoTCA->delay_0_mem_exp = temp;
move16();
}
ELSE
{
- hStereoTCA->delay_0_mem_fx[MAX_DELAYREGLEN - 1] = L_shl( hStereoTCA->delay_0_mem_fx[MAX_DELAYREGLEN - 1], sub( temp, hStereoTCA->delay_0_mem_exp ) );
+ hStereoTCA->delay_0_mem_fx[MAX_DELAYREGLEN - 1] = L_shl( hStereoTCA->delay_0_mem_fx[MAX_DELAYREGLEN - 1], sub( temp, hStereoTCA->delay_0_mem_exp ) ); /* Q31-temp */
move32();
}
}
@@ -1134,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 );
+ 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();
}
@@ -1155,7 +1152,7 @@ static void corrStatsEst_fx(
winInterp_fx = ica_sincInterp6_fx + SINC_ORDER1;
}
- corrLagStats[1] = i_mult( corrLagStats[0], dsFactor );
+ corrLagStats[1] = i_mult( corrLagStats[0], dsFactor ); /* Q0 */
move16();
interpMin = s_max( -sub( dsFactor, 1 ), -add( corrLagStats[1], i_mult( L_NCSHIFT_DS, dsFactor ) ) );
interpMax = s_min( sub( dsFactor, 1 ), sub( i_mult( L_NCSHIFT_DS, dsFactor ), corrLagStats[1] ) );
@@ -1165,29 +1162,29 @@ static void corrStatsEst_fx(
{
rInterp_fx[k] = 0;
move32();
- FOR( j = -idiv1616( SINC_ORDER1, dsFactor ); j <= idiv1616( SINC_ORDER1, dsFactor ); j++ )
+ FOR( j = -( SINC_ORDER1 / dsFactor ); j <= ( SINC_ORDER1 / dsFactor ); j++ )
{
- m = i_mult( j, dsFactor );
+ m = i_mult( j, dsFactor ); /* Q0 */
test();
IF( GE_16( sub( m, i ), -SINC_ORDER1 ) && LE_16( sub( m, i ), SINC_ORDER1 ) )
{
IF( GT_16( j, sub( lagSearchRange[1], corrLagStats[0] ) ) )
{
- rInterp_fx[k] = BASOP_Util_Add_Mant32Exp( rInterp_fx[k], rInterp_exp[k], Mpy_32_32( tempRK_fx[lagSearchRange[1] - corrLagStats[0]], winInterp_fx[m - i] ), hStereoTCA->corrEstLT_exp, &temp );
+ rInterp_fx[k] = BASOP_Util_Add_Mant32Exp( rInterp_fx[k], rInterp_exp[k], Mpy_32_32( tempRK_fx[lagSearchRange[1] - corrLagStats[0]], winInterp_fx[m - i] ), hStereoTCA->corrEstLT_exp, &temp ); /* Q31-temp */
move32();
rInterp_exp[k] = temp;
move16();
}
ELSE IF( LT_16( j, sub( lagSearchRange[0], corrLagStats[0] ) ) )
{
- rInterp_fx[k] = BASOP_Util_Add_Mant32Exp( rInterp_fx[k], rInterp_exp[k], Mpy_32_32( tempRK_fx[lagSearchRange[0] - corrLagStats[0]], winInterp_fx[m - i] ), hStereoTCA->corrEstLT_exp, &temp );
+ rInterp_fx[k] = BASOP_Util_Add_Mant32Exp( rInterp_fx[k], rInterp_exp[k], Mpy_32_32( tempRK_fx[lagSearchRange[0] - corrLagStats[0]], winInterp_fx[m - i] ), hStereoTCA->corrEstLT_exp, &temp ); /* Q31-temp */
move32();
rInterp_exp[k] = temp;
move16();
}
ELSE
{
- rInterp_fx[k] = BASOP_Util_Add_Mant32Exp( rInterp_fx[k], rInterp_exp[k], Mpy_32_32( tempRK_fx[j], winInterp_fx[m - i] ), hStereoTCA->corrEstLT_exp, &temp );
+ rInterp_fx[k] = BASOP_Util_Add_Mant32Exp( rInterp_fx[k], rInterp_exp[k], Mpy_32_32( tempRK_fx[j], winInterp_fx[m - i] ), hStereoTCA->corrEstLT_exp, &temp ); /* Q31-temp */
move32();
rInterp_exp[k] = temp;
move16();
@@ -1204,15 +1201,15 @@ static void corrStatsEst_fx(
FOR( i = 0; i < MAX_INTERPOLATE; i++ )
{
- rInterp_fx[i] = L_shl( rInterp_fx[i], sub( rInterp_exp[i], temp ) );
+ rInterp_fx[i] = L_shl( rInterp_fx[i], sub( rInterp_exp[i], temp ) ); /* Q31-rInterp_exp[i] */
move32();
}
- corrLagStats[1] = add( corrLagStats[1], add( maximum_32_fx( rInterp_fx, interpLen, &tempF_fx ), interpMin ) );
+ corrLagStats[1] = add( corrLagStats[1], add( maximum_32_fx( rInterp_fx, interpLen, &tempF_fx ), interpMin ) ); /* Q0 */
move16();
/* save corr lag stats for the current frame */
- Copy( corrLagStats, hStereoTCA->corrLagStats, 3 );
+ Copy( corrLagStats, hStereoTCA->corrLagStats, 3 ); /* Q0 */
return;
}
@@ -1225,14 +1222,14 @@ static void corrStatsEst_fx(
static void estDownmixGain_fx(
STEREO_TCA_ENC_HANDLE hStereoTCA, /* i/o: Stereo TCA Encoder handle */
- const Word32 *chan1, /* i : reference signal Qx */
- const Word32 *chan2, /* i/o: target signal to be scaled Qx */
- const Word16 q_chan, /* i : Q of the channel signal */
- const Word16 ncShift, /* i : shift */
- const Word16 length, /* i : input frame length */
- const Word16 element_mode, /* i : element mode */
+ const Word32 *chan1, /* i : reference signal q_chan */
+ const Word32 *chan2, /* i/o: target signal to be scaled q_chan */
+ const Word16 q_chan, /* i : Q of the channel signal Q0*/
+ const Word16 ncShift, /* i : shift Q0*/
+ const Word16 length, /* i : input frame length Q0*/
+ const Word16 element_mode, /* i : element mode Q0*/
STEREO_CLASSIF_HANDLE hStereoClassif, /* i/o: stereo classifier handle */
- const Word16 tdm_LRTD_flag /* i : LRTD stereo mode flag */
+ const Word16 tdm_LRTD_flag /* i : LRTD stereo mode flag Q0*/
)
{
Word16 i, i1, i2;
@@ -1251,12 +1248,12 @@ static void estDownmixGain_fx(
{
i1 = 0;
move16();
- i2 = ncShift;
+ i2 = ncShift; /* Q0 */
move16();
}
ELSE
{
- i1 = ncShift;
+ i1 = ncShift; /* Q0 */
move16();
i2 = 0;
move16();
@@ -1269,11 +1266,11 @@ static void estDownmixGain_fx(
move32();
FOR( i = 0; i < length; i++ )
{
- tempN = L_add( tempN, L_abs( chan1[i1 + i] ) );
- tempD = L_add( tempD, L_abs( chan2[i2 + i] ) );
+ tempN = L_add( tempN, L_abs( chan1[i1 + i] ) ); /* q_chan */
+ tempD = L_add( tempD, L_abs( chan2[i2 + i] ) ); /* q_chan */
}
- alpha = hStereoTCA->corrStatsSmoothFac_fx;
+ alpha = hStereoTCA->corrStatsSmoothFac_fx; /* Q15 */
move16();
IF( tempD == 0 )
{
@@ -1283,7 +1280,7 @@ static void estDownmixGain_fx(
}
ELSE
{
- currentGain = BASOP_Util_Divide3232_Scale( tempN, tempD, &exp );
+ currentGain = BASOP_Util_Divide3232_Scale( tempN, tempD, &exp ); /* Q31-exp */
currentGain_e = exp;
move16();
if ( currentGain == 0 )
@@ -1306,7 +1303,7 @@ static void estDownmixGain_fx(
currentGain_log10 = BASOP_Util_Log10( L_deposit_h( currentGain ), currentGain_e ); // Output in Q25
// multiplication result will be Q25 should be fit to Q15 hence right shift by 10.
// Q25 - Q10 = Q15
- currentGain = extract_l( L_shr( Madd_32_16( Mpy_32_16_1( prevTargetGain_log10, alpha ), currentGain_log10, sub( MAX_16, alpha ) ), Q10 ) );
+ currentGain = extract_l( L_shr( Madd_32_16( Mpy_32_16_1( prevTargetGain_log10, alpha ), currentGain_log10, sub( MAX_16, alpha ) ), Q10 ) ); /* Q15 */
currentGain_e = 0;
move16();
@@ -1318,8 +1315,8 @@ static void estDownmixGain_fx(
// tempD = powf( 10, currentGain );
// 10 ^ currentGain = 2 ^ (3.32192809488 * currentGain)
// 3.32192809488 in Q13 27213
- tempD = BASOP_util_Pow2( L_mult( currentGain, 27213 ), add( currentGain_e, Q2 ), &exp );
- unclr_instTargetGain = L_deposit_h( BASOP_Util_Divide3232_Scale( tempN, L_add( tempD, EPSILON_FX ), &exp_div ) );
+ tempD = BASOP_util_Pow2( L_mult( currentGain, 27213 ), add( currentGain_e, Q2 ), &exp ); /* Q31-exp */
+ unclr_instTargetGain = L_deposit_h( BASOP_Util_Divide3232_Scale( tempN, L_add( tempD, EPSILON_FX ), &exp_div ) ); /* Q31-exp */
exp = add( sub( exp_chan, exp ), exp_div );
if ( unclr_instTargetGain == 0 )
{
@@ -1328,7 +1325,7 @@ static void estDownmixGain_fx(
}
unclr_instTargetGain = BASOP_Util_Log10( L_add( unclr_instTargetGain, L_shr( MAX_32, sub( Q31, exp ) ) ), exp );
// unclr_fv_fx is expected in Q15 - log result will be in Q25 - hence rightshift by 10.
- hStereoClassif->unclr_fv_fx[E_ica_instTargetGain] = L_shr( unclr_instTargetGain, Q10 );
+ hStereoClassif->unclr_fv_fx[E_ica_instTargetGain] = L_shr( unclr_instTargetGain, Q10 ); /* Q15 */
move32();
}
@@ -1344,7 +1341,7 @@ static void estDownmixGain_fx(
/* 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 ) );
+ currentGain = shr( currentGain, sub( Q15, currentGain_e ) ); /* Q15 */
currentGain_e = 0;
move16();
}
@@ -1354,7 +1351,7 @@ static void estDownmixGain_fx(
IF( GE_16( norm_s( currentGain ), sub( currentGain_e, 1 ) ) )
{
/* convert currentGain into Q14 */
- currentGain = shl( currentGain, sub( currentGain_e, 1 ) );
+ currentGain = shl( currentGain, sub( currentGain_e, 1 ) ); /* Q14 */
currentGain_e = 1;
move16();
}
@@ -1365,7 +1362,7 @@ static void estDownmixGain_fx(
}
/* quantize the target gain */
- hStereoTCA->indx_ica_gD = usquant_fx( currentGain, &temp, shr( STEREO_TCA_GDMIN_FX_Q14, shift ), shr( STEREO_TCA_GDSTEP_FX_Q13, shift ), 1 << STEREO_BITS_TCA_GD );
+ hStereoTCA->indx_ica_gD = usquant_fx( currentGain, &temp, shr( STEREO_TCA_GDMIN_FX_Q14, shift ), shr( STEREO_TCA_GDSTEP_FX_Q13, shift ), ( 1 << STEREO_BITS_TCA_GD ) ); /* Q13 */
move16();
// hStereoTCA->targetGain_fx = powf( 10, temp );
// 10 ^ temp = 2 ^ (3.32192809488 * temp)
@@ -1373,7 +1370,7 @@ static void estDownmixGain_fx(
// exponent of power function input will be 2 more since constant is in Q13
exp = 2;
move16();
- hStereoTCA->targetGain_fx = BASOP_util_Pow2( L_mult( temp, 27213 ), add( currentGain_e, 2 ), &exp );
+ hStereoTCA->targetGain_fx = BASOP_util_Pow2( L_mult( temp, 27213 ), add( currentGain_e, 2 ), &exp ); /* Q31-exp */
move32();
hStereoTCA->targetGain_fx = L_shl( hStereoTCA->targetGain_fx, sub( exp, 2 ) ); // Q29
move32();
@@ -1391,9 +1388,9 @@ static void icaMemUpdate_fx(
Word32 *bufChanL, /* i/o: L signal correction from previous frame q_com*/
Word32 *bufChanR, /* i/o: R signal correction from previous frame q_com*/
Word16 q_com,
- const Word16 lMemRecalc, /* i : memory length at input Sampling Rate */
- const Word16 lMemRecalc_SCh, /* i : SCh memory length at input Sampling Rate*/
- const Word16 input_frame /* i : frame length */
+ const Word16 lMemRecalc, /* i : memory length at input Sampling Rate Q0*/
+ const Word16 lMemRecalc_SCh, /* i : SCh memory length at input Sampling Rate Q0*/
+ const Word16 input_frame /* i : frame length Q0*/
)
{
Word32 *ptr1, *ptr2;
@@ -1409,29 +1406,29 @@ static void icaMemUpdate_fx(
IF( hCPE->hStereoTD->tdm_last_SM_flag )
{
- ratio_L = hCPE->hStereoTD->tdm_last_ratio_SM_fx;
+ ratio_L = hCPE->hStereoTD->tdm_last_ratio_SM_fx; /* Q31 */
move32();
One_m_Ratio = L_sub( ratio_L, MAX_32 );
}
ELSE
{
- ratio_L = hCPE->hStereoTD->tdm_last_ratio_fx;
+ ratio_L = hCPE->hStereoTD->tdm_last_ratio_fx; /* Q31 */
move32();
One_m_Ratio = L_sub( MAX_32, ratio_L );
}
- ptr1 = sts[0]->input32_fx - add( lMemRecalc, lMemRecalc_SCh );
- ptr2 = sts[1]->input32_fx - add( lMemRecalc, lMemRecalc_SCh );
+ ptr1 = sts[0]->input32_fx - add( lMemRecalc, lMemRecalc_SCh ); /* Q31-sts[0]->q_inp32 */
+ ptr2 = sts[1]->input32_fx - add( lMemRecalc, lMemRecalc_SCh ); /* Q31-sts[1]->q_inp32 */
IF( EQ_16( hCPE->last_element_mode, IVAS_CPE_TD ) )
{
IF( hCPE->hStereoTD->flag_skip_DMX )
{
- FOR( i = lMemRecalc_SCh; i < add( lMemRecalc, lMemRecalc_SCh ); i++ )
+ FOR( i = lMemRecalc_SCh; i < ( lMemRecalc + lMemRecalc_SCh ); i++ )
{
- ptr1[i] = bufChanL[i];
+ ptr1[i] = bufChanL[i]; /* q_com */
move32();
- ptr2[i] = bufChanR[i];
+ ptr2[i] = bufChanR[i]; /* q_com */
move32();
}
}
@@ -1439,9 +1436,9 @@ static void icaMemUpdate_fx(
{
FOR( i = lMemRecalc_SCh; i < lMemRecalc + lMemRecalc_SCh; i++ )
{
- ptr1[i] = L_add( Mpy_32_32( bufChanR[i], One_m_Ratio ), Mpy_32_32( bufChanL[i], ratio_L ) );
+ ptr1[i] = L_add( Mpy_32_32( bufChanR[i], One_m_Ratio ), Mpy_32_32( bufChanL[i], ratio_L ) ); /* q_com */
move32();
- ptr2[i] = L_sub( Mpy_32_32( bufChanL[i], One_m_Ratio ), Mpy_32_32( bufChanR[i], ratio_L ) );
+ ptr2[i] = L_sub( Mpy_32_32( bufChanL[i], One_m_Ratio ), Mpy_32_32( bufChanR[i], ratio_L ) ); /* q_com */
move32();
}
}
@@ -1459,7 +1456,7 @@ static void icaMemUpdate_fx(
/* reconstruction of the Secondary channel past segment */
FOR( i = 0; i < lMemRecalc_SCh; i++ )
{
- ptr2[i] = L_add( Mpy_32_32( bufChanL[i], One_m_Ratio ), Mpy_32_32( bufChanR[i], ratio_L ) );
+ ptr2[i] = L_add( Mpy_32_32( bufChanL[i], One_m_Ratio ), Mpy_32_32( bufChanR[i], ratio_L ) ); /* q_com */
move32();
}
@@ -1468,18 +1465,18 @@ static void icaMemUpdate_fx(
incr = fac; // Q15
move16();
- FOR( i = lMemRecalc_SCh; i < add( lMemRecalc, lMemRecalc_SCh ); i++ )
+ FOR( i = lMemRecalc_SCh; i < ( lMemRecalc + lMemRecalc_SCh ); i++ )
{
- tmp1 = bufChanL[i];
+ tmp1 = bufChanL[i]; /* q_com */
move32();
- tmp2 = bufChanR[i];
+ tmp2 = bufChanR[i]; /* q_com */
move32();
- ptr1[i] = L_add( Mpy_32_16_1( ptr1[i], sub( MAX_16, fac ) ), Mpy_32_16_1( tmp1, fac ) );
+ ptr1[i] = L_add( Mpy_32_16_1( ptr1[i], sub( MAX_16, fac ) ), Mpy_32_16_1( tmp1, fac ) ); /* q_com */
move32();
/*ptr2[i] = (1.0f - fac) * ptr2[i] + fac * tmp2;*/ /* the secondary channel (downmixed) buffer of DFT stereo is empty ! */
- ptr2[i] = tmp2;
+ ptr2[i] = tmp2; /* q_com */
move32();
fac = add_sat( fac, incr );
@@ -1490,7 +1487,7 @@ static void icaMemUpdate_fx(
/* reconstruction of the Secondary channel past segment */
FOR( i = 0; i < lMemRecalc_SCh; i++ )
{
- ptr2[i] = L_sub( Mpy_32_32( bufChanL[i], One_m_Ratio ), Mpy_32_32( bufChanR[i], ratio_L ) );
+ ptr2[i] = L_sub( Mpy_32_32( bufChanL[i], One_m_Ratio ), Mpy_32_32( bufChanR[i], ratio_L ) ); /* q_com */
move32();
}
@@ -1498,15 +1495,15 @@ static void icaMemUpdate_fx(
fac = div_s( 1, lMemRecalc ); // Q15
incr = fac; // Q15
move16();
- FOR( i = lMemRecalc_SCh; i < add( lMemRecalc, lMemRecalc_SCh ); i++ )
+ FOR( i = lMemRecalc_SCh; i < ( lMemRecalc + lMemRecalc_SCh ); i++ )
{
- tmp1 = L_add( Mpy_32_32( bufChanR[i], One_m_Ratio ), Mpy_32_32( bufChanL[i], ratio_L ) );
- tmp2 = L_sub( Mpy_32_32( bufChanL[i], One_m_Ratio ), Mpy_32_32( bufChanR[i], ratio_L ) );
+ tmp1 = L_add( Mpy_32_32( bufChanR[i], One_m_Ratio ), Mpy_32_32( bufChanL[i], ratio_L ) ); /* q_com */
+ tmp2 = L_sub( Mpy_32_32( bufChanL[i], One_m_Ratio ), Mpy_32_32( bufChanR[i], ratio_L ) ); /* q_com */
- ptr1[i] = L_add( Mpy_32_16_1( ptr1[i], sub( MAX_16, fac ) ), Mpy_32_16_1( tmp1, fac ) );
+ ptr1[i] = L_add( Mpy_32_16_1( ptr1[i], sub( MAX_16, fac ) ), Mpy_32_16_1( tmp1, fac ) ); /* q_com */
move32();
/*ptr2[i] = (1.0f - fac) * ptr2[i] + fac * tmp2;*/ /* the secondary channel (downmixed) buffer of DFT stereo is empty ! */
- ptr2[i] = tmp2;
+ ptr2[i] = tmp2; /* q_com */
move32();
fac = add_sat( fac, incr );
@@ -1519,8 +1516,8 @@ static void icaMemUpdate_fx(
{
assert( L_MEM_RECALC_TBE_NS <= L_MEM_RECALC_NS );
i = NS2SA( sts[0]->input_Fs, L_MEM_RECALC_TBE_NS );
- Copy_Scale_sig_32_16( bufChanL + sub( add( lMemRecalc, lMemRecalc_SCh ), i ), hCPE->hStereoICBWE->icbwe_inp_mem_fx[0], i, -Q16 );
- Copy_Scale_sig_32_16( bufChanR + sub( add( lMemRecalc, lMemRecalc_SCh ), i ), hCPE->hStereoICBWE->icbwe_inp_mem_fx[1], i, -Q16 );
+ Copy_Scale_sig_32_16( bufChanL + sub( add( lMemRecalc, lMemRecalc_SCh ), i ), hCPE->hStereoICBWE->icbwe_inp_mem_fx[0], i, -Q16 ); /* q_com-16 */
+ Copy_Scale_sig_32_16( bufChanR + sub( add( lMemRecalc, lMemRecalc_SCh ), i ), hCPE->hStereoICBWE->icbwe_inp_mem_fx[1], i, -Q16 ); /* q_com-16 */
hCPE->hStereoICBWE->q_dataChan_fx = sub( q_com, Q16 );
move16();
}
@@ -1535,7 +1532,7 @@ static void icaMemUpdate_fx(
* ---------------------------------------------------------------*/
void stereo_tca_enc_fx(
CPE_ENC_HANDLE hCPE, /* i : CPE encoder structure */
- const Word16 input_frame /* i : length of a frame per channel */
+ const Word16 input_frame /* i : length of a frame per channel Q0*/
)
{
/* temp variables */
@@ -1599,12 +1596,12 @@ void stereo_tca_enc_fx(
/* populate L/R memories into current buffers */
Word16 tempp_scale = L_norm_arr( hStereoTCA->memChanL_fx, L_MEM_RECALC_48K + L_MEM_RECALC_48k_SCH );
tempp_scale = s_min( tempp_scale, L_norm_arr( hStereoTCA->memChanR_fx, L_MEM_RECALC_48K + L_MEM_RECALC_48k_SCH ) );
- scale_sig32( hStereoTCA->memChanL_fx, L_MEM_RECALC_48K + L_MEM_RECALC_48k_SCH, tempp_scale );
- scale_sig32( hStereoTCA->memChanR_fx, L_MEM_RECALC_48K + L_MEM_RECALC_48k_SCH, tempp_scale );
+ scale_sig32( hStereoTCA->memChanL_fx, L_MEM_RECALC_48K + L_MEM_RECALC_48k_SCH, tempp_scale ); /* hStereoTCA->memChan_q + tempp_scale */
+ scale_sig32( hStereoTCA->memChanR_fx, L_MEM_RECALC_48K + L_MEM_RECALC_48k_SCH, tempp_scale ); /* hStereoTCA->memChan_q + tempp_scale */
hStereoTCA->memChan_q = add( hStereoTCA->memChan_q, tempp_scale );
move16();
- Copy32( hStereoTCA->memChanL_fx, bufChanL_fx, add( lMemRecalc, lMemRecalc_SCh ) );
- Copy32( hStereoTCA->memChanR_fx, bufChanR_fx, add( lMemRecalc, lMemRecalc_SCh ) );
+ Copy32( hStereoTCA->memChanL_fx, bufChanL_fx, add( lMemRecalc, lMemRecalc_SCh ) ); /* hStereoTCA->memChan_q */
+ Copy32( hStereoTCA->memChanR_fx, bufChanR_fx, add( lMemRecalc, lMemRecalc_SCh ) ); /* hStereoTCA->memChan_q */
bufChan_q = hStereoTCA->memChan_q;
move16();
/* pointers to the current frame */
@@ -1612,14 +1609,14 @@ void stereo_tca_enc_fx(
ptrChanR_fx = bufChanR_fx + add( lMemRecalc, lMemRecalc_SCh ); // Q:bufChan_q
/* copy interleaved stereo data to two channels, e.g., L, R */
- Copy32( sts[0]->input32_fx, ptrChanL_fx, input_frame );
- Copy32( sts[1]->input32_fx, ptrChanR_fx, input_frame );
+ Copy32( sts[0]->input32_fx, ptrChanL_fx, input_frame ); /* sts[0]->q_inp32 */
+ Copy32( sts[1]->input32_fx, ptrChanR_fx, input_frame ); /* sts[1]->q_inp32 */
/* Scaling buffers to common Q*/
- scale_sig32( ptrChanL_fx, input_frame, sub( s_min( q_com, bufChan_q ), q_com ) );
- scale_sig32( ptrChanR_fx, input_frame, sub( s_min( q_com, bufChan_q ), q_com ) );
- scale_sig32( bufChanL_fx, add( lMemRecalc, lMemRecalc_SCh ), sub( s_min( q_com, bufChan_q ), bufChan_q ) );
- scale_sig32( bufChanR_fx, add( lMemRecalc, lMemRecalc_SCh ), sub( s_min( q_com, bufChan_q ), bufChan_q ) );
+ scale_sig32( ptrChanL_fx, input_frame, sub( s_min( q_com, bufChan_q ), q_com ) ); /* s_min( q_com, bufChan_q ) */
+ scale_sig32( ptrChanR_fx, input_frame, sub( s_min( q_com, bufChan_q ), q_com ) ); /* s_min( q_com, bufChan_q ) */
+ scale_sig32( bufChanL_fx, add( lMemRecalc, lMemRecalc_SCh ), sub( s_min( q_com, bufChan_q ), bufChan_q ) ); /* s_min( q_com, bufChan_q ) */
+ scale_sig32( bufChanR_fx, add( lMemRecalc, lMemRecalc_SCh ), sub( s_min( q_com, bufChan_q ), bufChan_q ) ); /* s_min( q_com, bufChan_q ) */
bufChan_q = s_min( q_com, bufChan_q );
q_com = bufChan_q;
move16();
@@ -1673,7 +1670,7 @@ void stereo_tca_enc_fx(
tempS = hStereoTCA->prevRefChanIndx;
move16();
- Copy( hStereoTCA->prevCorrLagStats, tempS_buff, 3 );
+ Copy( hStereoTCA->prevCorrLagStats, tempS_buff, 3 ); /* Q0 */
stereo_tca_init_enc_fx( hStereoTCA, input_Fs );
@@ -1695,13 +1692,13 @@ void stereo_tca_enc_fx(
hStereoTCA->prevRefChanIndx = tempS;
move16();
- Copy( tempS_buff, hStereoTCA->prevCorrLagStats, 3 );
+ Copy( tempS_buff, hStereoTCA->prevCorrLagStats, 3 ); /* Q0 */
/* populate memory */
IF( EQ_16( hCPE->last_element_mode, IVAS_CPE_MDCT ) )
{
- Copy32( sts[0]->input32_fx - add( lMemRecalc, lMemRecalc_SCh ), bufChanL_fx, add( lMemRecalc, lMemRecalc_SCh ) );
- Copy32( sts[1]->input32_fx - add( lMemRecalc, lMemRecalc_SCh ), bufChanR_fx, add( lMemRecalc, lMemRecalc_SCh ) );
+ Copy32( sts[0]->input32_fx - add( lMemRecalc, lMemRecalc_SCh ), bufChanL_fx, add( lMemRecalc, lMemRecalc_SCh ) ); /* sts[0]->q_inp32 */
+ Copy32( sts[1]->input32_fx - add( lMemRecalc, lMemRecalc_SCh ), bufChanR_fx, add( lMemRecalc, lMemRecalc_SCh ) ); /* sts[1]->q_inp32 */
}
}
@@ -1714,6 +1711,7 @@ void stereo_tca_enc_fx(
scale_sig32( bufChanL_DS_fx, ADDED_MEM_DS, sub( s_min( hStereoTCA->memChan_DS_q, bufChan_q ), hStereoTCA->memChan_DS_q ) ); // s_min( hStereoTCA->memChan_DS_q, bufChan_q )
scale_sig32( bufChanR_DS_fx, ADDED_MEM_DS, sub( s_min( hStereoTCA->memChan_DS_q, bufChan_q ), hStereoTCA->memChan_DS_q ) ); // s_min( hStereoTCA->memChan_DS_q, bufChan_q )
+ scale_sig32( hStereoTCA->memdecim_fx, 12, sub( s_min( hStereoTCA->memChan_DS_q, bufChan_q ), hStereoTCA->memChan_DS_q ) ); // s_min( hStereoTCA->memChan_DS_q, bufChan_q )
bufChan_q = s_min( hStereoTCA->memChan_DS_q, bufChan_q );
q_com = bufChan_q;
@@ -1723,14 +1721,14 @@ void stereo_tca_enc_fx(
/* pointers to the current frame of DS */
- ptrChanL_DS_fx = bufChanL_DS_fx + ADDED_MEM_DS;
- ptrChanR_DS_fx = bufChanR_DS_fx + ADDED_MEM_DS;
+ ptrChanL_DS_fx = bufChanL_DS_fx + ADDED_MEM_DS; /* hStereoTCA->memChan_DS_q */
+ ptrChanR_DS_fx = bufChanR_DS_fx + ADDED_MEM_DS; /* hStereoTCA->memChan_DS_q */
/* resample factor */
- dsFactor = (Word16) Mpy_32_32( input_Fs, 268436 /* 1/CORR_INTER_FS in Q31*/ ); // Q0
+ dsFactor = extract_l( Mpy_32_32( input_Fs, 268436 /* 1/CORR_INTER_FS in Q31*/ ) ); // Q0
/* resample the stereo channels */
- deEmphResample( hStereoTCA, ptrChanL_fx, ptrChanR_fx, ptrChanL_DS_fx, ptrChanR_DS_fx, input_frame, dsFactor );
+ deEmphResample_fx( hStereoTCA, ptrChanL_fx, ptrChanR_fx, ptrChanL_DS_fx, ptrChanR_DS_fx, input_frame, dsFactor );
/**********************NEED to Allign first 40 index in each channel ************************************/
/* inter-channel corrStats estimation */
@@ -1757,7 +1755,7 @@ void stereo_tca_enc_fx(
move16();
maxCorrStatsDev = N_MAX_SHIFT_CHANGE;
move16();
- if ( LE_16( hStereoTCA->corrStatsSmoothFac_fx, 22938 /*0.7f*/ ) )
+ IF( LE_16( hStereoTCA->corrStatsSmoothFac_fx, 22938 /*0.7f*/ ) )
{
maxCorrStatsDev = 160; /* L_NCSHIFT_MAX @ 32kHz */
move16();
@@ -1765,7 +1763,7 @@ void stereo_tca_enc_fx(
IF( LT_32( input_Fs, 32000 ) )
{
- maxCorrStatsDev = (Word16) Mpy_32_32( imult3216( input_Fs, maxCorrStatsDev ), 67109 /* 1/32000.0f in Q31*/ ); // Q0
+ maxCorrStatsDev = extract_l( Mpy_32_32( imult3216( input_Fs, maxCorrStatsDev ), 67109 /* 1/32000.0f in Q31*/ ) ); // Q0
}
musicMode = ( hCPE->hCoreCoder[0]->sp_aud_decision0 == 1 || sts[0]->last_core > ACELP_CORE );
@@ -1778,17 +1776,17 @@ void stereo_tca_enc_fx(
set16_fx( hStereoTCA->corrLagStats + 1, 0, 2 );
}
- tempS = sub( hStereoTCA->corrLagStats[1], hStereoTCA->prevCorrLagStats[2] );
+ tempS = sub( hStereoTCA->corrLagStats[1], hStereoTCA->prevCorrLagStats[2] ); /* Q0 */
IF( GT_16( abs_s( tempS ), maxCorrStatsDev ) )
{
IF( tempS > 0 )
{
- hStereoTCA->corrLagStats[2] = add( hStereoTCA->prevCorrLagStats[2], maxCorrStatsDev );
+ hStereoTCA->corrLagStats[2] = add( hStereoTCA->prevCorrLagStats[2], maxCorrStatsDev ); /* Q0 */
}
ELSE
{
- hStereoTCA->corrLagStats[2] = add( hStereoTCA->prevCorrLagStats[2], -maxCorrStatsDev );
+ hStereoTCA->corrLagStats[2] = add( hStereoTCA->prevCorrLagStats[2], -maxCorrStatsDev ); /* Q0 */
}
move16();
}
@@ -1802,22 +1800,24 @@ void stereo_tca_enc_fx(
{
tempF_fx = 0;
move32();
+ corrEstStage2_exp = 0;
+ move16();
IF( !musicMode )
{
- tempLag[0] = s_min( hStereoTCA->corrLagStats[2], hStereoTCA->prevCorrLagStats[2] );
+ tempLag[0] = s_min( hStereoTCA->corrLagStats[2], hStereoTCA->prevCorrLagStats[2] ); /* Q0 */
move16();
- tempLag[1] = s_max( hStereoTCA->corrLagStats[2], hStereoTCA->prevCorrLagStats[2] );
+ tempLag[1] = s_max( hStereoTCA->corrLagStats[2], hStereoTCA->prevCorrLagStats[2] ); /* Q0 */
move16();
neighborLimit = s_min( 3, maxCorrStatsDev );
IF( LT_16( hStereoTCA->prevCorrLagStats[2], hStereoTCA->corrLagStats[2] ) )
{
- tempLag[1] = s_min( tempLag[1], add( tempLag[0], neighborLimit ) );
+ tempLag[1] = s_min( tempLag[1], add( tempLag[0], neighborLimit ) ); /* Q0 */
}
ELSE
{
- tempLag[0] = s_max( tempLag[0], sub( tempLag[1], neighborLimit ) );
+ tempLag[0] = s_max( tempLag[0], sub( tempLag[1], neighborLimit ) ); /* Q0 */
}
move16();
utilCrossCorr_fx( ptrChanL_fx, q_com, ptrChanR_fx, q_com, NULL, corrEstStage2_fx, &corrEstStage2_exp, tempLag, input_frame, 0 );
@@ -1830,22 +1830,22 @@ void stereo_tca_enc_fx(
IF( GT_16( abs_s( tempS ), neighborLimit ) )
{
- tempLag[0] = hStereoTCA->corrLagStats[1];
+ tempLag[0] = hStereoTCA->corrLagStats[1]; /* Q0 */
move16();
- tempLag[1] = hStereoTCA->corrLagStats[1];
+ tempLag[1] = hStereoTCA->corrLagStats[1]; /* Q0 */
move16();
utilCrossCorr_fx( ptrChanL_fx, q_com, ptrChanR_fx, q_com, NULL, &tempF1_fx, &tempF1_exp, tempLag, input_frame, 0 );
test();
- IF( GT_32( tempF1_fx, tempF_fx ) || musicMode )
+ IF( ( BASOP_Util_Cmp_Mant32Exp( tempF1_fx, tempF1_exp, tempF_fx, corrEstStage2_exp ) > 0 ) || musicMode )
{
IF( tempS > 0 )
{
- hStereoTCA->corrLagStats[2] = add( hStereoTCA->prevCorrLagStats[2], s_min( abs_s( tempS ), maxCorrStatsDev ) );
+ hStereoTCA->corrLagStats[2] = add( hStereoTCA->prevCorrLagStats[2], s_min( abs_s( tempS ), maxCorrStatsDev ) ); /* Q0 */
}
ELSE
{
- hStereoTCA->corrLagStats[2] = add( hStereoTCA->prevCorrLagStats[2], s_max( -abs_s( tempS ), -maxCorrStatsDev ) );
+ hStereoTCA->corrLagStats[2] = add( hStereoTCA->prevCorrLagStats[2], s_max( -abs_s( tempS ), -maxCorrStatsDev ) ); /* Q0 */
}
move16();
}
@@ -1879,37 +1879,37 @@ void stereo_tca_enc_fx(
1. adjust samples,
2. interp shift variation,
3. gain estimation */
- prevNCShift = abs_s( hStereoTCA->prevCorrLagStats[2] );
- currentNCShift = abs_s( hStereoTCA->corrLagStats[2] );
+ prevNCShift = abs_s( hStereoTCA->prevCorrLagStats[2] ); /* Q0 */
+ currentNCShift = abs_s( hStereoTCA->corrLagStats[2] ); /* Q0 */
IF( EQ_16( hStereoTCA->prevRefChanIndx, L_CH_INDX ) )
{
- 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*/
+ 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( lMemRecalc, lMemRecalc_SCh ), input_mem_loc_fx[0], add( lMemRecalc, lMemRecalc_SCh ) ); // bufChan_q - 2
v_multc_fixed( ptrChanR_fx + sub( prevNCShift, 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 */
+ 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*/
}
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*/
+ 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
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*/
+ 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*/
}
bufChan_q = sub( bufChan_q, 2 );
q_com = bufChan_q;
move16();
input_mem_loc_q = bufChan_q;
move16();
- target_fx = ptrChanR_fx;
- target_idx = R_CH_INDX;
+ target_fx = ptrChanR_fx; /* bufChan_q -2 */
+ target_idx = R_CH_INDX; /* Q0 */
move16();
/* identify target signal to correct for shift variations */
test();
test();
IF( ( prevNCShift == 0 && hStereoTCA->corrLagStats[2] < 0 ) || EQ_16( hStereoTCA->prevRefChanIndx, R_CH_INDX ) )
{
- target_fx = ptrChanL_fx;
+ target_fx = ptrChanL_fx; /* bufChan_q - 2 */
target_idx = L_CH_INDX;
move16();
}
@@ -1926,7 +1926,7 @@ void stereo_tca_enc_fx(
}
/* Note!! : Always keep the assert (prevNCShift>>1) below according to the equation used here to get tempS */
- tempS = shr( currentNCShift, 1 );
+ tempS = shr( currentNCShift, 1 ); /* Q0 */
IF( LE_32( abs( sub( currentNCShift, prevNCShift ) ), L_min( N_MAX_SHIFT_CHANGE, Mpy_32_32( imult3216( input_Fs, N_MAX_SHIFT_CHANGE ), 67109 /* 1/32000.0f in Q31*/ ) ) ) )
{
@@ -1934,18 +1934,22 @@ void stereo_tca_enc_fx(
}
ELSE
{
- tempS = s_min( s_max( tempS, add( sub( prevNCShift, currentNCShift ), sub( L_shift_adapt, input_frame ) ) ), add( sub( prevNCShift, currentNCShift ), lMemRecalc ) );
+ tempS = s_min( s_max( tempS, add( sub( prevNCShift, currentNCShift ), sub( L_shift_adapt, input_frame ) ) ), add( sub( prevNCShift, currentNCShift ), lMemRecalc ) ); /* Q0 */
adjustTargetSignal_fx( ( target_fx - tempS ), prevNCShift, currentNCShift, L_shift_adapt, 1 );
}
IF( target_idx == L_CH_INDX )
{
- Copy32( target_fx - tempS, &( input_mem_loc_fx[target_idx][lMemRecalc + lMemRecalc_SCh - tempS - currentNCShift] ), add( currentNCShift, tempS ) );
+ Copy32( target_fx - tempS, &( input_mem_loc_fx[target_idx][lMemRecalc + lMemRecalc_SCh - tempS - currentNCShift] ), add( currentNCShift, tempS ) ); /* bufChan_q - 2 */
}
ELSE
{
- v_multc_fixed( target_fx - tempS, hStereoTCA->prevTargetGain_fx, &( input_mem_loc_fx[target_idx][lMemRecalc + lMemRecalc_SCh - tempS - currentNCShift] ), add( currentNCShift, tempS ) );
+ v_multc_fixed( target_fx - tempS, hStereoTCA->prevTargetGain_fx, &( input_mem_loc_fx[target_idx][lMemRecalc + lMemRecalc_SCh - tempS - currentNCShift] ), add( currentNCShift, tempS ) ); /* bufChan_q - 2 */
+ scale_sig32( input_mem_loc_fx[target_idx], sub( sub( add( lMemRecalc, lMemRecalc_SCh ), tempS ), currentNCShift ), -2 );
+ scale_sig32( &input_mem_loc_fx[target_idx][lMemRecalc + lMemRecalc_SCh], sub( NS2SA( 48000, L_MEM_RECALC_NS + L_MEM_RECALC_SCH_NS ), add( lMemRecalc, lMemRecalc_SCh ) ), -2 );
+ scale_sig32( input_mem_loc_fx[0], NS2SA( 48000, L_MEM_RECALC_NS + L_MEM_RECALC_SCH_NS ), -2 );
+ input_mem_loc_q = sub( bufChan_q, 2 );
}
}
@@ -1967,16 +1971,16 @@ void stereo_tca_enc_fx(
/* quantize the corrStats */
Word16 temp_exp, tempF_16fx;
- Word16 scalar_value = BASOP_Util_Divide1616_Scale( currentNCShift, dsFactor, &temp_exp );
+ Word16 scalar_value = BASOP_Util_Divide1616_Scale( currentNCShift, dsFactor, &temp_exp ); /* Q15-temp_exp */
IF( temp_exp < 0 )
{
- scalar_value = shl( scalar_value, sub( temp_exp, Q3 ) ); // Q12
- hStereoTCA->indx_ica_NCShift = usquant_fx( scalar_value, &tempF_16fx, 0, ONE_IN_Q11, 1 << STEREO_BITS_TCA_CORRSTATS );
+ scalar_value = shl( scalar_value, sub( temp_exp, Q3 ) ); // Q12
+ hStereoTCA->indx_ica_NCShift = usquant_fx( scalar_value, &tempF_16fx, 0, ONE_IN_Q11, ( 1 << STEREO_BITS_TCA_CORRSTATS ) ); /* Q0 */
move16();
}
ELSE
{
- hStereoTCA->indx_ica_NCShift = usquant_fx( scalar_value, &tempF_16fx, 0, shl( 1, sub( 14, temp_exp ) ), 1 << STEREO_BITS_TCA_CORRSTATS );
+ hStereoTCA->indx_ica_NCShift = usquant_fx( scalar_value, &tempF_16fx, 0, shl( 1, sub( 14, temp_exp ) ), ( 1 << STEREO_BITS_TCA_CORRSTATS ) ); /* Q0 */
move16();
}
tempF_fx = tempF_16fx;
@@ -1995,7 +1999,7 @@ void stereo_tca_enc_fx(
currentNCShift = 0; /* only to avoid compilation warning */
move16();
- target_fx = ptrChanL_fx; /* only to avoid compilation warning */
+ target_fx = ptrChanL_fx; /* only to avoid compilation warning bufChan_q*/
move16();
target_idx = L_CH_INDX; /* only to avoid compilation warning */
move16();
@@ -2021,8 +2025,8 @@ void stereo_tca_enc_fx(
*-----------------------------------------------------------------*/
/* back up the L/R missing target */
- Copy32( bufChanL_fx + input_frame, hStereoTCA->memChanL_fx, add( lMemRecalc, lMemRecalc_SCh ) );
- Copy32( bufChanR_fx + input_frame, hStereoTCA->memChanR_fx, add( lMemRecalc, lMemRecalc_SCh ) );
+ Copy32( bufChanL_fx + input_frame, hStereoTCA->memChanL_fx, add( lMemRecalc, lMemRecalc_SCh ) ); /* bufChan_q */
+ Copy32( bufChanR_fx + input_frame, hStereoTCA->memChanR_fx, add( lMemRecalc, lMemRecalc_SCh ) ); /* bufChan_q */
hStereoTCA->memChan_q = bufChan_q;
IF( currentNCShift != 0 )
@@ -2030,16 +2034,14 @@ void stereo_tca_enc_fx(
/* Temporal channel adjustment of the LA samples based on the NC shift */
tcaTargetCh_LA_fx( hStereoTCA, ptrChanL_fx, ptrChanR_fx, &q_com, currentNCShift, input_frame );
- Word16 additional_length = NS2SA( L_mult0( input_frame, FRAMES_PER_SEC ), L_SAMPLES_LA_NS );
- move16();
- scale_sig32( bufChanL_fx, add( lMemRecalc, lMemRecalc_SCh ), sub( s_min( q_com, bufChan_q ), bufChan_q ) ); // s_min( q_com, bufChan_q )
- scale_sig32( bufChanL_fx + add( lMemRecalc, lMemRecalc_SCh ), add( input_frame, additional_length ), sub( s_min( q_com, bufChan_q ), q_com ) ); // s_min( q_com, bufChan_q )
- scale_sig32( bufChanL_fx + add( add( lMemRecalc, lMemRecalc_SCh ), add( input_frame, additional_length ) ), sub( L_MEM_RECALC_48K + L_MEM_RECALC_48k_SCH + L_FRAME48k + L_NCSHIFTMAX, add( add( lMemRecalc, lMemRecalc_SCh ), add( input_frame, additional_length ) ) ), sub( s_min( q_com, bufChan_q ), bufChan_q ) ); // s_min( q_com, bufChan_q )
+ scale_sig32( bufChanL_fx, add( lMemRecalc, lMemRecalc_SCh ), sub( s_min( q_com, bufChan_q ), bufChan_q ) ); // s_min( q_com, bufChan_q )
+ scale_sig32( bufChanL_fx + add( lMemRecalc, lMemRecalc_SCh ), add( input_frame, currentNCShift ), sub( s_min( q_com, bufChan_q ), q_com ) ); // s_min( q_com, bufChan_q )
+ scale_sig32( bufChanL_fx + add( add( lMemRecalc, lMemRecalc_SCh ), add( input_frame, currentNCShift ) ), sub( L_MEM_RECALC_48K + L_MEM_RECALC_48k_SCH + L_FRAME48k + L_NCSHIFTMAX, add( add( lMemRecalc, lMemRecalc_SCh ), add( input_frame, currentNCShift ) ) ), sub( s_min( q_com, bufChan_q ), bufChan_q ) ); // s_min( q_com, bufChan_q )
/* Scaling to common Q*/
- scale_sig32( bufChanR_fx, add( lMemRecalc, lMemRecalc_SCh ), sub( s_min( q_com, bufChan_q ), bufChan_q ) ); // s_min( q_com, bufChan_q )
- scale_sig32( bufChanR_fx + add( lMemRecalc, lMemRecalc_SCh ), add( input_frame, additional_length ), sub( s_min( q_com, bufChan_q ), q_com ) ); // s_min( q_com, bufChan_q )
- scale_sig32( bufChanR_fx + add( add( lMemRecalc, lMemRecalc_SCh ), add( input_frame, additional_length ) ), sub( L_MEM_RECALC_48K + L_MEM_RECALC_48k_SCH + L_FRAME48k + L_NCSHIFTMAX, add( add( lMemRecalc, lMemRecalc_SCh ), add( input_frame, additional_length ) ) ), sub( s_min( q_com, bufChan_q ), bufChan_q ) ); // s_min( q_com, bufChan_q )
+ scale_sig32( bufChanR_fx, add( lMemRecalc, lMemRecalc_SCh ), sub( s_min( q_com, bufChan_q ), bufChan_q ) ); // s_min( q_com, bufChan_q )
+ scale_sig32( bufChanR_fx + add( lMemRecalc, lMemRecalc_SCh ), add( input_frame, currentNCShift ), sub( s_min( q_com, bufChan_q ), q_com ) ); // s_min( q_com, bufChan_q )
+ scale_sig32( bufChanR_fx + add( add( lMemRecalc, lMemRecalc_SCh ), add( input_frame, currentNCShift ) ), sub( L_MEM_RECALC_48K + L_MEM_RECALC_48k_SCH + L_FRAME48k + L_NCSHIFTMAX, add( add( lMemRecalc, lMemRecalc_SCh ), add( input_frame, currentNCShift ) ) ), sub( s_min( q_com, bufChan_q ), bufChan_q ) ); // s_min( q_com, bufChan_q )
bufChan_q = s_min( q_com, bufChan_q );
q_com = bufChan_q;
}
@@ -2051,19 +2053,24 @@ void stereo_tca_enc_fx(
scale_sig32( sts[0]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), sub( s_min( input_mem_loc_q, sts[0]->q_inp32 ), sts[0]->q_inp32 ) ); // s_min( input_mem_loc_q, sts[0]->q_inp32 )
scale_sig32( sts[1]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), sub( s_min( input_mem_loc_q, sts[1]->q_inp32 ), sts[1]->q_inp32 ) ); // s_min( input_mem_loc_q, sts[0]->q_inp32 )
- input_mem_loc_q = s_min( input_mem_loc_q, sts[0]->q_inp32 );
+ input_mem_loc_q = s_min( input_mem_loc_q, sts[0]->q_inp32 ); /* sts[0]->q_inp32 */
sts[0]->q_inp32 = input_mem_loc_q;
move16();
sts[1]->q_inp32 = input_mem_loc_q;
move16();
- icaMemUpdate_fx( sts, hCPE, input_mem_loc_fx[0], input_mem_loc_fx[1], q_com, lMemRecalc, lMemRecalc_SCh, input_frame );
+ icaMemUpdate_fx( sts, hCPE, input_mem_loc_fx[0], input_mem_loc_fx[1], input_mem_loc_q, lMemRecalc, lMemRecalc_SCh, input_frame );
/* populate the st->input target buffer */
test();
IF( hCPE->hStereoTD->prev_fr_LRTD_TD_dec == 0 || EQ_16( prev_ICA_flag, 1 ) )
{
- Copy32( target_fx + currentNCShift, sts[target_idx]->input32_fx, input_frame );
+ Word16 shift = sub( q_com, sts[target_idx]->q_inp32 );
+ FOR( Word16 idx = 0; idx < input_frame; idx++ )
+ {
+ sts[target_idx]->input32_fx[idx] = L_shr( target_fx[currentNCShift + idx], shift );
+ move32();
+ }
}
IF( NE_16( hCPE->element_mode, IVAS_CPE_DFT ) )
@@ -2100,14 +2107,14 @@ void stereo_tca_enc_fx(
}
/* update L/R DS memories */
- Copy32( bufChanL_DS_fx + L_FRAME_DS, hStereoTCA->memChanL_DS_fx, ADDED_MEM_DS );
- Copy32( bufChanR_DS_fx + L_FRAME_DS, hStereoTCA->memChanR_DS_fx, ADDED_MEM_DS );
+ Copy32( bufChanL_DS_fx + L_FRAME_DS, hStereoTCA->memChanL_DS_fx, ADDED_MEM_DS ); /* hStereoTCA->memChan_DS_q */
+ Copy32( bufChanR_DS_fx + L_FRAME_DS, hStereoTCA->memChanR_DS_fx, ADDED_MEM_DS ); /* hStereoTCA->memChan_DS_q */
/* save the reference channel index for next frame */
- hStereoTCA->prevRefChanIndx = hStereoTCA->refChanIndx;
+ hStereoTCA->prevRefChanIndx = hStereoTCA->refChanIndx; /* Q0 */
move16();
/* save the corr lag stats for next frame */
- Copy( hStereoTCA->corrLagStats, hStereoTCA->prevCorrLagStats, 3 );
+ Copy( hStereoTCA->corrLagStats, hStereoTCA->prevCorrLagStats, 3 ); /* Q0 */
/* save the target gain for next frame */
hStereoTCA->prevTargetGain_fx = hStereoTCA->targetGain_fx; // Q29
@@ -2121,18 +2128,18 @@ void stereo_tca_enc_fx(
*-------------------------------------------------------------------*/
void stereo_tca_init_enc_fx(
STEREO_TCA_ENC_HANDLE hStereoTCA, /* i/o: Stereo ICA handle */
- const Word32 input_Fs /* i : input sampling frequency */
+ const Word32 input_Fs /* i : input sampling frequency Q0*/
)
{
Word16 div1;
Word16 div_e;
hStereoTCA->lMemRecalc = NS2SA_FX2( input_Fs, L_MEM_RECALC_NS );
move16();
- div1 = BASOP_Util_Divide3232_Scale( L_mult( hStereoTCA->lMemRecalc, INT_FS_12k8 ), input_Fs, &div_e );
+ div1 = BASOP_Util_Divide3232_Scale( L_mult( hStereoTCA->lMemRecalc, INT_FS_12k8 ), input_Fs, &div_e ); /* Q15-div_e */
hStereoTCA->lMemRecalc_12k8 = shr( div1, 1 + sub( 15, div_e ) );
move16();
- div1 = BASOP_Util_Divide3232_Scale( L_mult( hStereoTCA->lMemRecalc, INT_FS_16k ), input_Fs, &div_e );
+ div1 = BASOP_Util_Divide3232_Scale( L_mult( hStereoTCA->lMemRecalc, INT_FS_16k ), input_Fs, &div_e ); /* Q15-div_e */
hStereoTCA->lMemRecalc_16k = shr( div1, 1 + sub( 15, div_e ) );
move16();
@@ -2210,10 +2217,10 @@ static void unclr_calc_corr_features_fx(
Word32 buf1[], /* i : left channel q_com*/
Word32 buf2[], /* i : right channel q_com*/
Word16 q_com,
- const Word16 length, /* i : length of input signal buffers */
+ const Word16 length, /* i : length of input signal buffers Q0*/
Word32 corrEst[], /* i : buffer containing inter-channel correlation values corrEst_exp*/
Word16 corrEst_exp,
- const Word16 lagSearchRange[], /* i : minimum and maximum lags for corrEst[] */
+ const Word16 lagSearchRange[], /* i : minimum and maximum lags for corrEst[] Q0*/
Word32 *corrEst_ncorr, /* o : norm. x-correlation btw. current and previous correlation buffers corrEst_ncorr_exp*/
Word16 *corrEst_ncorr_exp )
{
@@ -2246,22 +2253,22 @@ static void unclr_calc_corr_features_fx(
FOR( i = 0; i < length; i++ )
{
- mono_i = BASOP_Util_Add_Mant32Exp( L_shr( buf1[i], 1 ), sub( 31, q_com ), L_shr( buf2[i], 1 ), sub( 31, q_com ), &exp );
- corrL = BASOP_Util_Add_Mant32Exp( corrL, corrL_exp, Mpy_32_32( buf1[i], mono_i ), add( sub( 31, q_com ), exp ), &corrL_exp );
- corrR = BASOP_Util_Add_Mant32Exp( corrR, corrR_exp, Mpy_32_32( buf2[i], mono_i ), add( sub( 31, q_com ), exp ), &corrR_exp );
+ mono_i = BASOP_Util_Add_Mant32Exp( L_shr( buf1[i], 1 ), sub( 31, q_com ), L_shr( buf2[i], 1 ), sub( 31, q_com ), &exp ); /* Q31-exp */
+ corrL = BASOP_Util_Add_Mant32Exp( corrL, corrL_exp, Mpy_32_32( buf1[i], mono_i ), add( sub( 31, q_com ), exp ), &corrL_exp ); /* Q31-corrL_exp */
+ 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 );
- ener_side = BASOP_Util_Add_Mant32Exp( ener_side, ener_side_exp, Mpy_32_32( side_i, side_i ), shl( exp, 1 ), &ener_side_exp );
- 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 );
+ 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 */
+ 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 */
}
/* average energy of L and R channels */
- hStereoClassif->ave_ener_L_fx = Mpy_32_32( hStereoTCA->E1_mem_fx, 13421772 /* 1/length in Q31*/ );
+ hStereoClassif->ave_ener_L_fx = Mpy_32_32( hStereoTCA->E1_mem_fx, 13421772 /* 1/length in Q31*/ ); /* Q31-hStereoClassif->ave_ener_L_fx_e */
move32();
hStereoClassif->ave_ener_L_fx_e = hStereoTCA->E1_mem_exp;
move16();
- hStereoClassif->ave_ener_R_fx = Mpy_32_32( hStereoTCA->E2_mem_fx, 13421772 /* 1/length in Q31*/ );
+ hStereoClassif->ave_ener_R_fx = Mpy_32_32( hStereoTCA->E2_mem_fx, 13421772 /* 1/length in Q31*/ ); /* Q31-hStereoClassif->ave_ener_R_fx_e */
move32();
hStereoClassif->ave_ener_R_fx_e = hStereoTCA->E2_mem_exp;
move16();
@@ -2269,7 +2276,7 @@ static void unclr_calc_corr_features_fx(
/* unnormalized L/R correlation */
IF( sum_prod )
{
- sum_prod = BASOP_Util_Log10( L_abs( sum_prod ), sum_prod_exp );
+ sum_prod = BASOP_Util_Log10( L_abs( sum_prod ), sum_prod_exp ); /* Q31-sum_prod_exp */
sum_prod_exp = 6;
move16();
}
@@ -2286,12 +2293,12 @@ static void unclr_calc_corr_features_fx(
hStereoClassif->xtalk_fv_fx[E_sum_prod] = L_shr( sum_prod, 10 ); // Q15
move32();
/* S/M energy ratio */
- Word32 inp1 = Sqrt32( Mpy_32_32( ener_side, 13421773 /* 1/L_FRAME_DS in Q31*/ ), &ener_side_exp );
- inp1 = BASOP_Util_Log10( inp1, ener_side_exp );
+ Word32 inp1 = Sqrt32( Mpy_32_32( ener_side, 13421773 /* 1/L_FRAME_DS in Q31*/ ), &ener_side_exp ); /* Q31-ener_side_exp */
+ inp1 = BASOP_Util_Log10( inp1, ener_side_exp ); /* Q31-ener_side_exp */
Word16 temp = ener_exp;
move16();
- Word32 inp2 = Sqrt32( Mpy_32_32( ener, 13421773 /* 1/L_FRAME_DS in Q31*/ ), &ener_exp );
- inp2 = BASOP_Util_Log10( inp2, ener_exp );
+ Word32 inp2 = Sqrt32( Mpy_32_32( ener, 13421773 /* 1/L_FRAME_DS in Q31*/ ), &ener_exp ); /* Q31-ener_exp */
+ inp2 = BASOP_Util_Log10( inp2, ener_exp ); /* Q31-ener_exp */
ener_exp = temp;
move16();
@@ -2319,17 +2326,17 @@ static void unclr_calc_corr_features_fx(
move32();
}
- hStereoClassif->unclr_fv_fx[E_corrEst0] = L_shl( corrEst[abs_s( lagSearchRange[0] )], sub( corrEst_exp, 16 ) );
+ hStereoClassif->unclr_fv_fx[E_corrEst0] = L_shl( corrEst[abs_s( lagSearchRange[0] )], sub( corrEst_exp, 16 ) ); /* Q15 */
move32();
- hStereoClassif->unclr_fv_fx[E_corrEstMax] = L_shl( corrEstMax, sub( corrEst_exp, 16 ) );
+ hStereoClassif->unclr_fv_fx[E_corrEstMax] = L_shl( corrEstMax, sub( corrEst_exp, 16 ) ); /* Q15 */
move32();
- hStereoClassif->unclr_fv_fx[E_corrLagMax] = L_shl( corrLagMax, 15 );
+ hStereoClassif->unclr_fv_fx[E_corrLagMax] = L_shl( corrLagMax, 15 ); /* Q15 */
move32();
- hStereoClassif->xtalk_fv_fx[E_corrEst0] = L_shl( corrEst[abs_s( lagSearchRange[0] )], sub( corrEst_exp, 16 ) );
+ hStereoClassif->xtalk_fv_fx[E_corrEst0] = L_shl( corrEst[abs_s( lagSearchRange[0] )], sub( corrEst_exp, 16 ) ); /* Q15 */
move32();
- hStereoClassif->xtalk_fv_fx[E_corrEstMax] = L_shl( corrEstMax, sub( corrEst_exp, 16 ) );
+ hStereoClassif->xtalk_fv_fx[E_corrEstMax] = L_shl( corrEstMax, sub( corrEst_exp, 16 ) ); /* Q15 */
move32();
- hStereoClassif->xtalk_fv_fx[E_corrLagMax] = L_shl( corrLagMax, 15 );
+ hStereoClassif->xtalk_fv_fx[E_corrLagMax] = L_shl( corrLagMax, 15 ); /* Q15 */
move32();
/* L/M and R/M correlation */
@@ -2345,14 +2352,14 @@ static void unclr_calc_corr_features_fx(
move32();
}
- ic_Lm = BASOP_Util_Divide3232_Scale_cadence( corrL, ener, &exp1 );
+ ic_Lm = BASOP_Util_Divide3232_Scale_cadence( corrL, ener, &exp1 ); /* Q31-exp1 */
exp1 = add( exp1, sub( corrL_exp, ener_exp ) );
- ic_Rm = BASOP_Util_Divide3232_Scale_cadence( corrR, ener, &exp2 );
+ ic_Rm = BASOP_Util_Divide3232_Scale_cadence( corrR, ener, &exp2 ); /* Q31-exp2 */
exp2 = add( exp2, sub( corrR_exp, ener_exp ) );
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 );
+ 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
@@ -2372,16 +2379,17 @@ static void unclr_calc_corr_features_fx(
/* norm. x-correlation btw. current and previous correlation buffers */
tempLen = ( 2 * L_NCSHIFT_DS + 1 );
+ move16();
Word64 L64_sum = 0;
move64();
FOR( k = 0; k < tempLen; k++ )
{
- L64_sum = W_mac_32_32( L64_sum, corrEst[k], hStereoTCA->corrEstPrev_fx[2][k] );
+ L64_sum = W_mac_32_32( L64_sum, corrEst[k], hStereoTCA->corrEstPrev_fx[2][k] ); /* 2*(Q31-corrEst_exp)+1 */
}
k = W_norm( L64_sum );
- L64_sum = W_shl( L64_sum, k );
- num = W_extract_h( L64_sum ); // ener_side_q
+ L64_sum = W_shl( L64_sum, k ); /* 2*(Q31-corrEst_exp)+1+k */
+ num = W_extract_h( L64_sum ); // ener_side_q
num_exp = sub( 31, sub( add( add( add( sub( 31, corrEst_exp ), sub( 31, hStereoTCA->corrEstPrev_exp ) ), 1 ), k ), 32 ) );
exp1 = corrEst_exp;
@@ -2393,24 +2401,26 @@ static void unclr_calc_corr_features_fx(
inp2 = sum2_32_exp_fx( hStereoTCA->corrEstPrev_fx[2], tempLen, &exp2, 3 );
den_exp = add( exp1, exp2 );
- den = Sqrt32( Mpy_32_32( inp1, inp2 ), &den_exp );
+ den = Sqrt32( Mpy_32_32( inp1, inp2 ), &den_exp ); /* Q31-den_exp */
IF( den == 0 )
{
*corrEst_ncorr = 0;
- move16();
- *corrEst_ncorr_exp = 0;
move32();
+ *corrEst_ncorr_exp = 0;
+ move16();
}
ELSE
{
- *corrEst_ncorr = BASOP_Util_Divide3232_Scale_cadence( num, den, &exp );
+ *corrEst_ncorr = BASOP_Util_Divide3232_Scale_cadence( num, den, &exp ); /* Q31-corrEst_ncorr_exp */
*corrEst_ncorr_exp = add( exp, sub( num_exp, den_exp ) );
+ move32();
+ move16();
}
- hStereoClassif->unclr_fv_fx[E_corrEst_ncorr] = L_shl( *corrEst_ncorr, sub( *corrEst_ncorr_exp, 16 ) );
+ hStereoClassif->unclr_fv_fx[E_corrEst_ncorr] = L_shl( *corrEst_ncorr, sub( *corrEst_ncorr_exp, 16 ) ); /* Q15 */
move32();
- hStereoClassif->xtalk_fv_fx[E_corrEst_ncorr] = L_shl( *corrEst_ncorr, sub( *corrEst_ncorr_exp, 16 ) );
+ hStereoClassif->xtalk_fv_fx[E_corrEst_ncorr] = L_shl( *corrEst_ncorr, sub( *corrEst_ncorr_exp, 16 ) ); /* Q15 */
move32();
return;
diff --git a/lib_enc/ivas_stereo_icbwe_enc.c b/lib_enc/ivas_stereo_icbwe_enc.c
index 7ed9d71d179ec00e7e98b21412195130e0481684..cc5f8453a7676c6874338305c4f63a79870bd9a3 100644
--- a/lib_enc/ivas_stereo_icbwe_enc.c
+++ b/lib_enc/ivas_stereo_icbwe_enc.c
@@ -61,7 +61,7 @@ static void ic_bwe_enc_reset_fx(
/* inter-channel BWE spectral shape adj. */
hStereoICBWE->prevSpecMapping_fx = 0;
move32();
- hStereoICBWE->prevgsMapping_fx = ONE_IN_Q31;
+ hStereoICBWE->prevgsMapping_fx = ONE_IN_Q31; /* Q31 */
move32();
hStereoICBWE->prevgsMapping_e = 0;
move16();
@@ -71,7 +71,7 @@ static void ic_bwe_enc_reset_fx(
set32_fx( hStereoICBWE->memShbSpecXcorr_fx, 0, 6 );
hStereoICBWE->memShbSpecXcorr_e = 0;
move16();
- set32_fx( hStereoICBWE->memGsEnerMap_fx, ONE_IN_Q31, 2 );
+ set32_fx( hStereoICBWE->memGsEnerMap_fx, ONE_IN_Q31, 2 ); /* Q31 */
hStereoICBWE->memGsEnerMap_e = 0;
move16();
set32_fx( hStereoICBWE->mem_nrg_L_fx, 0, 2 );
@@ -83,7 +83,7 @@ static void ic_bwe_enc_reset_fx(
set32_fx( hStereoICBWE->mem_nrg_DMX_fx, 0, 2 );
hStereoICBWE->mem_nrg_DMX_fx_e = 0;
move16();
- hStereoICBWE->gDes_pastFrame_fx = ONE_IN_Q31;
+ hStereoICBWE->gDes_pastFrame_fx = ONE_IN_Q31; /* Q31 */
move32();
hStereoICBWE->gDes_pastFrame_e = 0;
move16();
@@ -101,13 +101,13 @@ static void ic_bwe_enc_reset_fx(
* Encode and apply the spectral shape mapping of ref to the non-ref channel
*---------------------------------------------------------------------------*/
static Word16 ic_bwe_enc_specMapping_ivas_fx(
- const Word32 *shb_frame_target_fx, /* i : target shb */
+ const Word32 *shb_frame_target_fx, /* i : target shb Q31-shb_frame_target_e*/
Word16 shb_frame_target_e,
- Word32 *shb_synth_nonref_fx, /* o : non-ref shb synth */
+ Word32 *shb_synth_nonref_fx, /* o : non-ref shb synth Q31-shb_synth_nonref_e*/
Word16 shb_synth_nonref_e,
- Word32 *specMapping_fx, /* i/o: current frame's mapping */
- Word32 *memShbSpecMapping_fx, /* i/o: current frame's mapping */
- Word32 *memShbSpecXcorr_fx, /* i/o: ic bwe spec mapping scorr memory */
+ Word32 *specMapping_fx, /* i/o: current frame's mapping Qx*/
+ Word32 *memShbSpecMapping_fx, /* i/o: current frame's mapping Qx*/
+ Word32 *memShbSpecXcorr_fx, /* i/o: ic bwe spec mapping scorr memory Q31-memShbSpecXcorr_e*/
Word16 *memShbSpecXcorr_e )
{
Word16 idx;
@@ -115,11 +115,12 @@ static Word16 ic_bwe_enc_specMapping_ivas_fx(
Word16 Txx1_fx = 0, Txx2_fx = 0, Txx3_fx = 0, T_desired_fx = 0;
Word16 Txx1_e = 0, Txx2_e = 0, Txx3_e = 0, T_desired_e = 0;
Word16 T_nonref_target_fx, temp_fx;
+ Word32 temp00_fx, temp11_fx;
+ Word16 temp00_exp, temp11_exp;
Word32 temp0_fx, temp1_fx, temp2_fx, temp3_fx;
Word16 a_fx, b_fx, c_fx, a_e, b_e, c_e;
Word16 u_fx, u1_fx, u2_fx, u_e = 0, u1_e, u2_e;
Word16 temp0_exp, temp1_exp, temp2_exp, temp3_exp, exp, T_nonref_target_e;
- Word16 exp_buf[6];
move16();
move16();
@@ -133,84 +134,71 @@ static Word16 ic_bwe_enc_specMapping_ivas_fx(
/* Calculate rxx(1)/rxx(0) of the non ref target */
- temp0_fx = dotp_fixed_ivas_fx( shb_frame_target_fx, shb_frame_target_e, shb_frame_target_fx, shb_frame_target_e, L_FRAME16k - 1, &temp0_exp );
- temp1_fx = dotp_fixed_ivas_fx( shb_frame_target_fx, shb_frame_target_e, shb_frame_target_fx + 1, shb_frame_target_e, L_FRAME16k - 1, &temp1_exp );
+ temp00_fx = dotp_fixed_ivas_fx( shb_frame_target_fx, shb_frame_target_e, shb_frame_target_fx, shb_frame_target_e, L_FRAME16k - 1, &temp00_exp ); /* Q31-temp0_exp */
+ temp11_fx = dotp_fixed_ivas_fx( shb_frame_target_fx, shb_frame_target_e, shb_frame_target_fx + 1, shb_frame_target_e, L_FRAME16k - 1, &temp11_exp ); /* Q31-temp1_exp */
- /* Smoothing */
- temp0_fx = L_shr( temp0_fx, 1 );
- temp1_fx = L_shr( temp1_fx, 1 );
+ /* Calculate rxx(1)/rxx(0) of the non ref synth */
+ temp0_fx = dotp_fixed_ivas_fx( shb_synth_nonref_fx, shb_synth_nonref_e, shb_synth_nonref_fx, shb_synth_nonref_e, L_FRAME16k - 3, &temp0_exp ); /* Q31-temp0_exp */
+ temp1_fx = dotp_fixed_ivas_fx( shb_synth_nonref_fx, shb_synth_nonref_e, shb_synth_nonref_fx + 1, shb_synth_nonref_e, L_FRAME16k - 3, &temp1_exp ); /* Q31-temp1_exp */
+ temp2_fx = dotp_fixed_ivas_fx( shb_synth_nonref_fx, shb_synth_nonref_e, shb_synth_nonref_fx + 2, shb_synth_nonref_e, L_FRAME16k - 3, &temp2_exp ); /* Q31-temp2_exp */
+ temp3_fx = dotp_fixed_ivas_fx( shb_synth_nonref_fx, shb_synth_nonref_e, shb_synth_nonref_fx + 3, shb_synth_nonref_e, L_FRAME16k - 3, &temp3_exp ); /* Q31-temp3_exp */
+ exp = s_max( *memShbSpecXcorr_e, s_max( s_max( s_max( temp00_exp, temp11_exp ), s_max( temp0_exp, temp1_exp ) ), s_max( temp2_exp, temp3_exp ) ) );
- memShbSpecXcorr_fx[0] = temp0_fx; // tem0_exp
- memShbSpecXcorr_fx[1] = L_shr( temp1_fx, temp0_exp - temp1_exp ); // temp0_exp
- exp = sub( temp0_exp, temp1_exp );
- exp_buf[0] = exp;
- exp_buf[1] = exp;
- move32();
- move32();
- move16();
- move16();
+ temp00_fx = L_shr( temp00_fx, sub( exp, temp00_exp ) );
+ temp11_fx = L_shr( temp11_fx, sub( exp, temp11_exp ) );
+ temp0_fx = L_shr( temp0_fx, sub( exp, temp0_exp ) );
+ temp1_fx = L_shr( temp1_fx, sub( exp, temp1_exp ) );
+ temp2_fx = L_shr( temp2_fx, sub( exp, temp2_exp ) );
+ temp3_fx = L_shr( temp3_fx, sub( exp, temp3_exp ) );
- IF( temp0_fx != 0 )
- {
- T_nonref_target_fx = BASOP_Util_Divide3232_Scale( temp1_fx, temp0_fx, &T_nonref_target_e ); // exp
- }
- ELSE
+ /* Smoothing */
+
+ FOR( Word16 i = 0; i < 6; i++ )
{
- T_nonref_target_fx = 0;
- T_nonref_target_e = 31;
+ memShbSpecXcorr_fx[i] = L_shl( memShbSpecXcorr_fx[i], sub( *memShbSpecXcorr_e, exp ) );
move32();
- move16();
}
+ *memShbSpecXcorr_e = exp;
+ move16();
- /* Calculate rxx(1)/rxx(0) of the non ref synth */
- temp0_fx = dotp_fixed_ivas_fx( shb_synth_nonref_fx, shb_synth_nonref_e, shb_synth_nonref_fx, shb_synth_nonref_e, L_FRAME16k - 3, &temp0_exp );
- temp1_fx = dotp_fixed_ivas_fx( shb_synth_nonref_fx, shb_synth_nonref_e, shb_synth_nonref_fx + 1, shb_synth_nonref_e, L_FRAME16k - 3, &temp1_exp );
- temp2_fx = dotp_fixed_ivas_fx( shb_synth_nonref_fx, shb_synth_nonref_e, shb_synth_nonref_fx + 2, shb_synth_nonref_e, L_FRAME16k - 3, &temp2_exp );
- temp3_fx = dotp_fixed_ivas_fx( shb_synth_nonref_fx, shb_synth_nonref_e, shb_synth_nonref_fx + 3, shb_synth_nonref_e, L_FRAME16k - 3, &temp3_exp );
+ temp00_fx = L_add( L_shr( temp00_fx, 1 ), L_shr( memShbSpecXcorr_fx[0], 1 ) );
+ temp11_fx = L_add( L_shr( temp11_fx, 1 ), L_shr( memShbSpecXcorr_fx[1], 1 ) );
+ temp0_fx = L_add( L_shr( temp0_fx, 1 ), L_shr( memShbSpecXcorr_fx[2], 1 ) );
+ temp1_fx = L_add( L_shr( temp1_fx, 1 ), L_shr( memShbSpecXcorr_fx[3], 1 ) );
+ temp2_fx = L_add( L_shr( temp2_fx, 1 ), L_shr( memShbSpecXcorr_fx[4], 1 ) );
+ temp3_fx = L_add( L_shr( temp3_fx, 1 ), L_shr( memShbSpecXcorr_fx[5], 1 ) );
- /* Smoothing */
- temp0_fx = L_shr( temp0_fx, 1 );
- temp1_fx = L_shr( temp1_fx, 1 );
- temp2_fx = L_shr( temp2_fx, 1 );
- temp3_fx = L_shr( temp3_fx, 1 );
-
- exp_buf[2] = temp0_exp;
- exp_buf[3] = temp1_exp;
- exp_buf[4] = temp2_exp;
- exp_buf[5] = temp3_exp;
- exp = exp_buf[0];
- move16();
- move16();
- move16();
- move16();
+ T_nonref_target_fx = 0;
+ move32();
+ T_nonref_target_e = 31;
move16();
- FOR( Word16 i = 0; i < 6; i++ )
+
+ IF( temp00_fx != 0 )
{
- IF( LT_16( exp, exp_buf[i] ) )
- {
- exp = exp_buf[i];
- move16();
- }
+ T_nonref_target_fx = BASOP_Util_Divide3232_Scale( temp11_fx, temp00_fx, &T_nonref_target_e );
}
- memShbSpecXcorr_fx[2] = L_shr( temp0_fx, sub( exp, temp0_exp ) );
- memShbSpecXcorr_fx[3] = L_shr( temp1_fx, sub( exp, temp1_exp ) );
- memShbSpecXcorr_fx[4] = L_shr( temp2_fx, sub( exp, temp2_exp ) );
- memShbSpecXcorr_fx[5] = L_shr( temp3_fx, sub( exp, temp3_exp ) );
- *memShbSpecXcorr_e = exp;
+
+ memShbSpecXcorr_fx[0] = temp00_fx;
move32();
+ memShbSpecXcorr_fx[1] = temp11_fx;
move32();
+ memShbSpecXcorr_fx[2] = temp0_fx; /* Q31-exp */
move32();
+ memShbSpecXcorr_fx[3] = temp1_fx; /* Q31-exp */
+ move32();
+ memShbSpecXcorr_fx[4] = temp2_fx; /* Q31-exp */
+ move32();
+ memShbSpecXcorr_fx[5] = temp3_fx; /* Q31-exp */
move32();
- move16();
IF( temp0_fx != 0 )
{
- Txx1_fx = BASOP_Util_Divide3232_Scale( temp1_fx, temp0_fx, &Txx1_e );
- Txx2_fx = BASOP_Util_Divide3232_Scale( temp2_fx, temp0_fx, &Txx2_e );
- Txx3_fx = BASOP_Util_Divide3232_Scale( temp3_fx, temp0_fx, &Txx3_e );
+ Txx1_fx = BASOP_Util_Divide3232_Scale( temp1_fx, temp0_fx, &Txx1_e ); /* Q31-Txx1_e */
+ Txx2_fx = BASOP_Util_Divide3232_Scale( temp2_fx, temp0_fx, &Txx2_e ); /* Q31-Txx1_e */
+ Txx3_fx = BASOP_Util_Divide3232_Scale( temp3_fx, temp0_fx, &Txx3_e ); /* Q31-Txx1_e */
}
T_desired_fx = T_nonref_target_fx;
@@ -219,32 +207,32 @@ static Word16 ic_bwe_enc_specMapping_ivas_fx(
move16();
Word16 tmp, tmp1;
- exp = BASOP_Util_Add_MantExp( Txx3_fx, Txx3_e, Txx1_fx, Txx1_e, &tmp );
- tmp1 = mult( Txx2_fx, T_desired_fx ); // Txx2_e + T_desired_e
- a_e = BASOP_Util_Add_MantExp( tmp1, sub( add( Txx2_e, T_desired_e ), 1 ), negate( tmp ), exp, &a_fx );
+ exp = BASOP_Util_Add_MantExp( Txx3_fx, Txx3_e, Txx1_fx, Txx1_e, &tmp ); /* Q15-exp */
+ tmp1 = mult( Txx2_fx, T_desired_fx ); // Txx2_e + T_desired_e
+ a_e = BASOP_Util_Add_MantExp( tmp1, sub( add( Txx2_e, T_desired_e ), 1 ), negate( tmp ), exp, &a_fx ); /* Q15-a_e */
- exp = BASOP_Util_Add_MantExp( Txx2_fx, Txx2_e, 32767, 1, &tmp );
- tmp1 = mult( Txx1_fx, T_desired_fx ); // Txx1_e + T_desired_e
- b_e = BASOP_Util_Add_MantExp( tmp1, sub( add( Txx1_e, T_desired_e ), 1 ), negate( tmp ), exp, &b_fx );
+ exp = BASOP_Util_Add_MantExp( Txx2_fx, Txx2_e, 32767, 1, &tmp ); /* Q15-exp */
+ tmp1 = mult( Txx1_fx, T_desired_fx ); // Txx1_e + T_desired_e
+ b_e = BASOP_Util_Add_MantExp( tmp1, sub( add( Txx1_e, T_desired_e ), 1 ), negate( tmp ), exp, &b_fx ); /* Q15-b_fx */
- c_e = BASOP_Util_Add_MantExp( T_desired_fx, T_desired_e, negate( Txx1_fx ), Txx1_e, &c_fx );
+ c_e = BASOP_Util_Add_MantExp( T_desired_fx, T_desired_e, negate( Txx1_fx ), Txx1_e, &c_fx ); /* Q15-c_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
- exp = BASOP_Util_Add_MantExp( tmp, add( b_e, b_e ), tmp1, add( a_e, add( c_e, 2 ) ), &temp_fx );
+ exp = BASOP_Util_Add_MantExp( tmp, add( b_e, b_e ), tmp1, add( a_e, add( c_e, 2 ) ), &temp_fx ); /* Q15-exp */
test();
IF( temp_fx >= 0 && a_fx != 0 )
{
- temp_fx = Sqrt16( temp_fx, &exp );
- exp = BASOP_Util_Add_MantExp( negate( b_fx ), b_e, temp_fx, exp, &tmp );
- u1_e = BASOP_Util_Divide1616_Scale( tmp, a_fx, &u1_fx );
+ temp_fx = Sqrt16( temp_fx, &exp ); /* Q15-exp */
+ exp = BASOP_Util_Add_MantExp( negate( b_fx ), b_e, temp_fx, exp, &tmp ); /* Q15-exp */
+ u1_e = BASOP_Util_Divide1616_Scale( tmp, a_fx, &u1_fx ); /* Q15-u1_e */
u1_e = add( u1_e, sub( exp, add( a_e, 1 ) ) );
- exp = BASOP_Util_Add_MantExp( negate( b_fx ), b_e, negate( temp_fx ), exp, &tmp );
- u2_e = BASOP_Util_Divide1616_Scale( tmp, a_fx, &u2_fx );
+ exp = BASOP_Util_Add_MantExp( negate( b_fx ), b_e, negate( temp_fx ), exp, &tmp ); /* Q15-exp */
+ u2_e = BASOP_Util_Divide1616_Scale( tmp, a_fx, &u2_fx ); /* Q15-u2_e */
u2_e = add( u2_e, sub( exp, add( a_e, 1 ) ) );
test();
@@ -298,7 +286,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 << STEREO_ICBWE_SPBITS ) ); // -0.6 in in Q15 -> -19660, 0.2 in Q15 -> 6553
*specMapping_fx = L_deposit_h( specMapping16 );
move32();
@@ -324,17 +312,17 @@ static Word16 ic_bwe_enc_specMapping_ivas_fx(
/*! r: return quant. index value */
static Word16 ic_bwe_enc_gsMapping_ivas_fx(
- const Word32 relG_targ_fx, /* i : gDes, rel gain target */
+ const Word32 relG_targ_fx, /* i : gDes, rel gain target Q31-relG_targ_e*/
Word16 relG_targ_e,
- const Word16 *shbSynth_fx, /* i : ref synth signal */
+ const Word16 *shbSynth_fx, /* i : ref synth signal Q15-shbSynth_e*/
Word16 shbSynth_e, /* i : ref synth signal */
- Word32 *synthSHB_nonref_fx, /* i : nonref synth signal */
+ Word32 *synthSHB_nonref_fx, /* i : nonref synth signal Q31-synthSHB_nonref_e*/
Word16 *synthSHB_nonref_e, /* i : nonref synth signal */
- Word32 *gsMapping_fx, /* i/o: gs mapping */
+ Word32 *gsMapping_fx, /* i/o: gs mapping Q31-gsMapping_e*/
Word16 *gsMapping_e, /* i/o: gs mapping */
- Word32 *memEner_fx, /* */
+ Word32 *memEner_fx, /* Q31-memEner_e*/
Word16 *memEner_e,
- const Word16 element_mode /* i : element mode */
+ const Word16 element_mode /* i : element mode Q0*/
)
{
Word16 i;
@@ -355,13 +343,13 @@ static Word16 ic_bwe_enc_gsMapping_ivas_fx(
move16();
FOR( i = 0; i < L_FRAME16k; i++ )
{
- temp1_fx32 = BASOP_Util_Add_Mant32Exp( temp1_fx32, temp1_exp, L_abs( L_deposit_h( shbSynth_fx[i] ) ), exp1, &temp1_exp );
- temp2_fx32 = BASOP_Util_Add_Mant32Exp( temp2_fx32, temp2_exp, L_abs( synthSHB_nonref_fx[i] ), exp2, &temp2_exp );
+ temp1_fx32 = BASOP_Util_Add_Mant32Exp( temp1_fx32, temp1_exp, L_abs( L_deposit_h( shbSynth_fx[i] ) ), exp1, &temp1_exp ); /* Q31-temp1_exp */
+ 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;
- memEner_fx[1] = L_shr( temp2_fx32, abs_s( sub( temp1_exp, 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 */
move32();
move32();
*memEner_e = s_max( temp1_exp, temp2_exp );
@@ -389,7 +377,7 @@ static Word16 ic_bwe_enc_gsMapping_ivas_fx(
temp2_fx = extract_l( L_shr( temp2_fx32, Q10 ) ); // Q15
gsMapping_fx16 = 0;
move16();
- idx = squant_fx( temp2_fx, &gsMapping_fx16, icbwe_gsMapping_tbl_fx, 1 << STEREO_ICBWE_GSBITS ); // Q12
+ 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
@@ -397,13 +385,13 @@ static Word16 ic_bwe_enc_gsMapping_ivas_fx(
temp2_fx = extract_l( L_shr( temp2_fx32, Q10 ) ); // Q15
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 ) ); // 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
- *gsMapping_fx = BASOP_util_Pow2( L_mult, 5, &e );
+ *gsMapping_fx = BASOP_util_Pow2( L_mult, 5, &e ); /* Q31-e */
move32();
*gsMapping_e = e; // Q31
@@ -420,7 +408,7 @@ static void icbwe_dft_stereo_param_ivas_fx(
STEREO_ICBWE_ENC_HANDLE hStereoICBWE, /* i/o: */
STEREO_DFT_ENC_DATA_HANDLE hStereoDft, /* i : */
Encoder_State *st, /* i/o: */
- Word32 *shb_synth_nonref_fx, /* i/o: */
+ Word32 *shb_synth_nonref_fx, /* i/o: Q31-shb_synth_nonref_e*/
Word16 shb_synth_nonref_e /* i/o: */
)
{
@@ -465,6 +453,9 @@ static void icbwe_dft_stereo_param_ivas_fx(
sum_nrg_L_fx = sum_32_fx( hStereoICBWE->mem_nrg_L_fx, 2, &sum_nrg_L_e ); // hStereoICBWE->mem_nrg_L_fx_e
sum_nrg_R_fx = sum_32_fx( hStereoICBWE->mem_nrg_R_fx, 2, &sum_nrg_R_e ); // hStereoICBWE->mem_nrg_R_fx_e
sum_nrg_DMX_fx = sum_32_fx( hStereoICBWE->mem_nrg_DMX_fx, 2, &sum_nrg_DMX_e ); // hStereoICBWE->mem_nrg_DMX_fx_e
+ move16();
+ move16();
+ move16();
/* refChanIndex_bwe refinement */
@@ -487,7 +478,7 @@ static void icbwe_dft_stereo_param_ivas_fx(
slopeILD_fx = 0;
move32();
- spIndx = squant_fx( slopeILD_fx, &slopeILD_fx, slope_table_fx16, 1 << STEREO_ICBWE_SPBITS_DFT );
+ spIndx = squant_fx( slopeILD_fx, &slopeILD_fx, slope_table_fx16, 1 << STEREO_ICBWE_SPBITS_DFT ); /* Q0 */
test();
test();
@@ -499,26 +490,21 @@ static void icbwe_dft_stereo_param_ivas_fx(
Word32 L_tmp, L_tmp1;
L_tmp = Mpy_32_32( hStereoICBWE->mem_nrg_L_fx[1], hStereoICBWE->mem_nrg_R_fx[0] ); // hStereoICBWE->mem_nrg_L_fx_e[1] + hStereoICBWE->mem_nrg_R_fx_e[1]
L_tmp1 = Mpy_32_32( hStereoICBWE->mem_nrg_R_fx[1], hStereoICBWE->mem_nrg_L_fx[0] ); // hStereoICBWE->mem_nrg_L_fx_e[1] + hStereoICBWE->mem_nrg_R_fx_e[1]
- tmp1 = BASOP_Util_Divide3232_Scale( L_tmp, L_tmp1, &exp1 );
+ tmp1 = BASOP_Util_Divide3232_Scale( L_tmp, L_tmp1, &exp1 ); /* Q15-exp1 */
exp1 = add( exp1, sub( add( hStereoICBWE->mem_nrg_L_fx_e, hStereoICBWE->mem_nrg_R_fx_e ), add( hStereoICBWE->mem_nrg_L_fx_e, hStereoICBWE->mem_nrg_R_fx_e ) ) );
L_tmp = BASOP_Util_Log10( L_deposit_h( tmp1 ), exp1 );
L_tmp = Mpy_32_32( normFac_fx, L_tmp ); // // Q25 + Q29 - Q31 -> Q23
slopeILD_fx = extract_l( L_shr( L_tmp, 16 ) ); // Q23 - Q16 -> Q7
IF( hStereoICBWE->refChanIndx_bwe == L_CH_INDX )
{
- slopeILD_fx = negate( slopeILD_fx );
- }
- ELSE
- {
- slopeILD_fx = slopeILD_fx;
- move16();
+ slopeILD_fx = negate( slopeILD_fx ); /* Q7 */
}
spIndx = squant_fx( slopeILD_fx, &slopeILD_fx, slope_table_fx16, 1 << STEREO_ICBWE_SPBITS_DFT );
IF( Mpy_32_32( spec_table_fx[spIndx], hStereoICBWE->prevSpecMapping_fx ) < 0 )
{
slopeILD_fx = 0;
move32();
- spIndx = squant_fx( slopeILD_fx, &slopeILD_fx, slope_table_fx16, 1 << STEREO_ICBWE_SPBITS_DFT );
+ spIndx = squant_fx( slopeILD_fx, &slopeILD_fx, slope_table_fx16, 1 << STEREO_ICBWE_SPBITS_DFT ); /* Q0 */
}
hStereoICBWE->prevSpecMapping_fx = spec_table_fx[spIndx]; // q31
@@ -538,16 +524,16 @@ static void icbwe_dft_stereo_param_ivas_fx(
Word16 exp;
IF( hStereoICBWE->refChanIndx_bwe == L_CH_INDX )
{
- gDes_fx = BASOP_Util_Divide3232_Scale( sum_nrg_R_fx, sum_nrg_DMX_fx, &exp );
+ gDes_fx = BASOP_Util_Divide3232_Scale( sum_nrg_R_fx, sum_nrg_DMX_fx, &exp ); /* Q15-exp */
exp = add( exp, sub( sum_nrg_R_e, sum_nrg_DMX_e ) );
}
ELSE
{
- gDes_fx = BASOP_Util_Divide3232_Scale( sum_nrg_L_fx, sum_nrg_DMX_fx, &exp );
+ gDes_fx = BASOP_Util_Divide3232_Scale( sum_nrg_L_fx, sum_nrg_DMX_fx, &exp ); /* Q15-exp */
exp = add( exp, sub( sum_nrg_L_e, sum_nrg_DMX_e ) );
}
- gDes_fx = Sqrt16( gDes_fx, &exp );
+ gDes_fx = Sqrt16( gDes_fx, &exp ); /* Q15-exp */
Word16 exp1 = hStereoICBWE->gDes_pastFrame_e, exp2, tmp;
Word32 tmp321 = 0, tmp322 = 0;
move32();
@@ -556,16 +542,16 @@ static void icbwe_dft_stereo_param_ivas_fx(
tmp321 = Sqrt32( hStereoICBWE->gDes_pastFrame_fx, &exp1 ); // exp1
exp2 = exp;
move16();
- tmp = Sqrt16( gDes_fx, &exp2 );
+ tmp = Sqrt16( gDes_fx, &exp2 ); /* Q15-exp2 */
tmp322 = Mpy_32_32( tmp321, L_deposit_h( tmp ) ); // exp1 + exp2
hStereoICBWE->gDes_pastFrame_fx = tmp322;
hStereoICBWE->gDes_pastFrame_e = add( exp1, exp2 );
move32();
move16();
- gsIndx = ic_bwe_enc_gsMapping_ivas_fx( hStereoICBWE->gDes_pastFrame_fx, hStereoICBWE->gDes_pastFrame_e, hStereoICBWE->shbSynthRef_fx, hStereoICBWE->shbSynthRef_e, shb_synth_nonref_fx, &shb_synth_nonref_e, &( hStereoICBWE->prevgsMapping_fx ), &( hStereoICBWE->prevgsMapping_e ), hStereoICBWE->memGsEnerMap_fx, &hStereoICBWE->memGsEnerMap_e, st->element_mode );
+ gsIndx = ic_bwe_enc_gsMapping_ivas_fx( hStereoICBWE->gDes_pastFrame_fx, hStereoICBWE->gDes_pastFrame_e, hStereoICBWE->shbSynthRef_fx, hStereoICBWE->shbSynthRef_e, shb_synth_nonref_fx, &shb_synth_nonref_e, &( hStereoICBWE->prevgsMapping_fx ), &( hStereoICBWE->prevgsMapping_e ), hStereoICBWE->memGsEnerMap_fx, &hStereoICBWE->memGsEnerMap_e, st->element_mode ); /* Q0 */
- hStereoICBWE->gDes_pastFrame_fx = L_deposit_h( gDes_fx );
+ hStereoICBWE->gDes_pastFrame_fx = L_deposit_h( gDes_fx ); /* Q31-exp */
hStereoICBWE->gDes_pastFrame_e = exp;
move32();
move16();
@@ -584,9 +570,9 @@ static void icbwe_dft_stereo_param_ivas_fx(
void stereo_icBWE_enc_ivas_fx(
CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
- const Word32 shb_speech_ref_fx[], /* i : SHB speech ref channel */
+ const Word32 shb_speech_ref_fx[], /* i : SHB speech ref channel Q31-shb_speech_ref_e*/
const Word16 shb_speech_ref_e, /* i : SHB speech ref channel */
- Word32 shb_speech_nonref_fx[], /* i/o: SHB speech non-ref channel */
+ Word32 shb_speech_nonref_fx[], /* i/o: SHB speech non-ref channel Q31-shb_speech_nonref_e*/
Word16 shb_speech_nonref_e, /* i/o: SHB speech non-ref channel */
const Word32 *voice_factors_fx /* i : voicing factors Q31 */
)
@@ -678,7 +664,8 @@ 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, negate( sub( max_e, hStereoICBWE->mem_shb_speech_ref_e ) ) + Q16 ); // 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;
shb_frame_ref_e = max_e;
@@ -689,9 +676,10 @@ void stereo_icBWE_enc_ivas_fx(
shb_synth_nonref_e = max_e;
move16();
- Copy_Scale_sig32( shb_speech_ref_fx, shb_frame_ref_fx + L_LOOK_16k - refMemLen, L_FRAME16k, negate( sub( max_e, shb_speech_ref_e ) ) );
+ Copy_Scale_sig32( shb_speech_ref_fx, shb_frame_ref_fx + L_LOOK_16k - refMemLen, L_FRAME16k, negate( sub( max_e, shb_speech_ref_e ) ) ); /* shb_speech_ref_e */
Copy_Scale_sig_32_16( shb_frame_ref_fx + L_FRAME16k, hStereoICBWE->mem_shb_speech_ref_fx, L_LOOK_16k, negate( sub( max_e, hStereoICBWE->mem_shb_speech_ref_e ) ) - Q16 ); // mem_shb_speech_ref_e
+
test();
test();
IF( ( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, FB_TBE ) ) && EQ_16( st->flag_ACELP16k, 1 ) )
@@ -724,7 +712,7 @@ void stereo_icBWE_enc_ivas_fx(
{
temp1_fx = 0;
temp1_e = 0;
- temp2_fx = ONE_IN_Q31;
+ temp2_fx = ONE_IN_Q31; /* Q31 */
temp2_e = 0;
move16();
move32();
@@ -735,16 +723,16 @@ void stereo_icBWE_enc_ivas_fx(
{
temp1_e = 0, temp2_e = 0;
move16();
- move32();
+ move16();
temp1_fx = Sqrt32( nlMixFac_fx[i], &temp1_e );
- temp2_fx = Sqrt32( L_sub( ONE_IN_Q31, nlMixFac_fx[i] ), &temp2_e );
+ 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 );
- tmp = shr( tmp, sub( Q15, exp ) );
+ 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++ ) )
{
- 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] ) );
+ 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 */
move32();
}
}
@@ -762,7 +750,7 @@ void stereo_icBWE_enc_ivas_fx(
FOR( j = 0; j < L_FRAME16k; j++ )
{
- excSHB_nonref_fx[j] = L_shr( excSHB_nonref_fx[j], sub( max_e, exp_buf[j] ) );
+ excSHB_nonref_fx[j] = L_shr( excSHB_nonref_fx[j], sub( max_e, exp_buf[j] ) ); /* Q31-max_e */
move32();
}
/* LP synthesis */
@@ -770,8 +758,8 @@ void stereo_icBWE_enc_ivas_fx(
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 ) ) );
- Copy_Scale_sig32( excSHB_nonref_fx, excSHB_nonref_fx, L_FRAME16k, negate( sub( tmp_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 );
@@ -782,10 +770,10 @@ void stereo_icBWE_enc_ivas_fx(
}
ELSE
{
- Copy_Scale_sig_32_16( shb_frame_ref_fx, hStereoICBWE->shbSynthRef_fx, L_FRAME16k, -16 ); // max_e
+ Copy_Scale_sig_32_16( shb_frame_ref_fx, hStereoICBWE->shbSynthRef_fx, L_FRAME16k, -16 ); /* Q15-shb_frame_ref_e */
hStereoICBWE->shbSynthRef_e = shb_frame_ref_e;
move16();
- Copy32( shb_frame_ref_fx, shb_synth_nonref_fx, L_FRAME16k ); // max_e
+ Copy32( shb_frame_ref_fx, shb_synth_nonref_fx, L_FRAME16k ); /* Q31-shb_frame_ref_e */
shb_synth_nonref_e = shb_frame_ref_e;
move16();
set32_fx( hStereoICBWE->mem_lpc_shbsynth_nonref_fx, 0, 10 );
@@ -802,31 +790,36 @@ 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();
move16();
/* shb_frame_ref_ICBWE @ (8.75 - shb_speech_delay (=1.25) ms) after shb_speech */
- Copy_Scale_sig32( shb_speech_ref_fx, shb_frame_ref_fx + L_LOOK_16k - refMemLen, L_FRAME16k, negate( sub( max_e, shb_speech_ref_e ) ) );
+ Copy_Scale_sig32( shb_speech_ref_fx, shb_frame_ref_fx + L_LOOK_16k - refMemLen, L_FRAME16k, negate( sub( max_e, shb_speech_ref_e ) ) ); /* Q31-max_e */
Copy_Scale_sig_32_16( shb_frame_ref_fx + L_FRAME16k, hStereoICBWE->mem_shb_speech_ref_fx, L_LOOK_16k, sub( negate( sub( max_e, hStereoICBWE->mem_shb_speech_ref_e ) ), Q16 ) ); // mem_shb_speech_ref_e
set32_fx( shb_frame_nonref_fx, 0, L_LOOK_16k + L_FRAME16k );
max_e = s_max( hStereoICBWE->mem_shb_speech_nonref_e, shb_speech_nonref_e );
Copy_Scale_sig( hStereoICBWE->mem_shb_speech_nonref_fx, hStereoICBWE->mem_shb_speech_nonref_fx, L_LOOK_16k, negate( sub( max_e, hStereoICBWE->mem_shb_speech_nonref_e ) ) ); // mem_shb_speech_ref_e
-
- 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();
move16();
/* shb_frame_ref_ICBWE @ (8.75 - shb_speech_delay (=1.25) ms) after shb_speech */
- Copy_Scale_sig32( shb_speech_nonref_fx, shb_frame_nonref_fx + L_LOOK_16k - nonRefMemLen, L_FRAME16k, negate( sub( max_e, shb_speech_nonref_e ) ) );
+ Copy_Scale_sig32( shb_speech_nonref_fx, shb_frame_nonref_fx + L_LOOK_16k - nonRefMemLen, L_FRAME16k, negate( sub( max_e, shb_speech_nonref_e ) ) ); /* Q31-max_e */
Copy_Scale_sig_32_16( shb_frame_nonref_fx + L_FRAME16k, hStereoICBWE->mem_shb_speech_nonref_fx, L_LOOK_16k, sub( negate( sub( max_e, hStereoICBWE->mem_shb_speech_ref_e ) ), Q16 ) ); // mem_shb_speech_ref_e
@@ -871,14 +864,14 @@ void stereo_icBWE_enc_ivas_fx(
move32();
move32();
L_tmp = sum2_32_fx( shb_frame_nonref_fx + sub( L_LOOK_16k, refMemLen ), L_FRAME16k, &temp1_e );
- temp1_fx = Sqrt32( L_tmp, &temp1_e );
+ temp1_fx = Sqrt32( L_tmp, &temp1_e ); /* Q31-temp1_e */
/*temp1 = 0.8f*hStereoICBWE->prevNonRefEner + 0.2f*temp1;*/
/*temp2 = 0.8f*hStereoICBWE->prevRefEner + 0.2f*temp2;*/
IF( temp2_fx == 0 )
{
- gDes_fx = 1073741824;
+ gDes_fx = 1073741824; /* 1.0 in Q30 */
gDes_e = 1;
move16();
move32();
@@ -894,8 +887,8 @@ void stereo_icBWE_enc_ivas_fx(
exp = hStereoICBWE->gDes_pastFrame_e;
move16();
move16();
- L_tmp = Sqrt32( gDes_fx, &tmp );
- L_tmp1 = Sqrt32( hStereoICBWE->gDes_pastFrame_fx, &exp );
+ L_tmp = Sqrt32( gDes_fx, &tmp ); /* Q31-tmp */
+ L_tmp1 = Sqrt32( hStereoICBWE->gDes_pastFrame_fx, &exp ); /* Q31-exp */
hStereoICBWE->gDes_pastFrame_fx = Mpy_32_32( L_tmp, L_tmp1 ); // tmp + exp
hStereoICBWE->gDes_pastFrame_e = add( tmp, exp );
@@ -918,9 +911,9 @@ void stereo_icBWE_enc_ivas_fx(
Copy32( voice_factors_fx, nlMixFac_fx, NB_SUBFR16k ); // Q31
test();
- IF( LT_32( gTarget_fx, 268435456 ) || GT_32( gTarget_fx, 1073741824 ) ) //
+ IF( LT_32( gTarget_fx, 268435456 ) || GT_32( gTarget_fx, 1073741824 ) ) // 0.5 in Q29 & 2.0 in Q29
{
- v_multc_fixed( voice_factors_fx, 1073741824, nlMixFac_fx, NB_SUBFR16k );
+ v_multc_fixed( voice_factors_fx, 1073741824 /*0.5 in Q31*/, nlMixFac_fx, NB_SUBFR16k ); /* Q31 */
}
IF( st->flag_ACELP16k == 0 )
@@ -944,7 +937,7 @@ void stereo_icBWE_enc_ivas_fx(
temp1_fx = 0;
temp1_e = 0;
- temp2_fx = ONE_IN_Q31;
+ temp2_fx = ONE_IN_Q31; /* Q31 */
temp2_e = 0;
move32();
move32();
@@ -954,15 +947,15 @@ void stereo_icBWE_enc_ivas_fx(
ELSE
{
temp1_e = 0, temp2_e = 0;
- temp1_fx = Sqrt32( nlMixFac_fx[i], &temp1_e );
- temp2_fx = Sqrt32( L_sub( ONE_IN_Q31, nlMixFac_fx[i] ), &temp2_e );
+ 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();
}
FOR( j = 0; j < ( L_FRAME16k / 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] ) );
+ 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 */
move32();
}
}
@@ -980,7 +973,7 @@ void stereo_icBWE_enc_ivas_fx(
FOR( j = 0; j < L_FRAME16k; j++ )
{
- excSHB_nonref_fx[j] = L_shr( excSHB_nonref_fx[j], sub( max_e, exp_buf[j] ) );
+ excSHB_nonref_fx[j] = L_shr( excSHB_nonref_fx[j], sub( max_e, exp_buf[j] ) ); /* Q31-max_e */
move32();
}
/* LP synthesis */
@@ -989,8 +982,8 @@ void stereo_icBWE_enc_ivas_fx(
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 ) ) );
- Copy_Scale_sig32( excSHB_nonref_fx, excSHB_nonref_fx, L_FRAME16k, negate( sub( tmp_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 */
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 );
@@ -1002,7 +995,7 @@ void stereo_icBWE_enc_ivas_fx(
Copy_Scale_sig_32_16( shb_frame_ref_fx, hStereoICBWE->shbSynthRef_fx, L_FRAME16k, -16 ); // max_e
hStereoICBWE->shbSynthRef_e = shb_frame_ref_e;
move16();
- Copy32( shb_frame_ref_fx, shb_synth_nonref_fx, L_FRAME16k );
+ Copy32( shb_frame_ref_fx, shb_synth_nonref_fx, L_FRAME16k ); /* Q31-shb_synth_nonref_e */
shb_synth_nonref_e = shb_frame_ref_e;
move16();
set32_fx( hStereoICBWE->mem_lpc_shbsynth_nonref_fx, 0, 10 );
@@ -1014,7 +1007,7 @@ void stereo_icBWE_enc_ivas_fx(
IF( ( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, WB_TBE ) || EQ_16( st->extl, FB_TBE ) ) && EQ_16( st->flag_ACELP16k, 1 ) )
{
/* IC BWE spectral mapping */
- 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 ) );
+ 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
{
@@ -1038,9 +1031,9 @@ void stereo_icBWE_enc_ivas_fx(
/* IC BWE GS mapping */
- gsIndx = ic_bwe_enc_gsMapping_ivas_fx( hStereoICBWE->gDes_pastFrame_fx, hStereoICBWE->gDes_pastFrame_e, hStereoICBWE->shbSynthRef_fx, hStereoICBWE->shbSynthRef_e, shb_synth_nonref_fx, &shb_synth_nonref_e, &( hStereoICBWE->prevgsMapping_fx ), &( hStereoICBWE->prevgsMapping_e ), hStereoICBWE->memGsEnerMap_fx, &hStereoICBWE->memGsEnerMap_e, st->element_mode );
+ gsIndx = ic_bwe_enc_gsMapping_ivas_fx( hStereoICBWE->gDes_pastFrame_fx, hStereoICBWE->gDes_pastFrame_e, hStereoICBWE->shbSynthRef_fx, hStereoICBWE->shbSynthRef_e, shb_synth_nonref_fx, &shb_synth_nonref_e, &( hStereoICBWE->prevgsMapping_fx ), &( hStereoICBWE->prevgsMapping_e ), hStereoICBWE->memGsEnerMap_fx, &hStereoICBWE->memGsEnerMap_e, st->element_mode ); /* Q0 */
- hStereoICBWE->gDes_pastFrame_fx = gDes_fx;
+ hStereoICBWE->gDes_pastFrame_fx = gDes_fx; /* Q31-hStereoICBWE->gDes_pastFrame_e */
hStereoICBWE->gDes_pastFrame_e = gDes_e;
move32();
move16();
@@ -1048,7 +1041,7 @@ void stereo_icBWE_enc_ivas_fx(
}
/* IC-BWE updates */
- hStereoICBWE->prev_refChanIndx_bwe = hStereoICBWE->refChanIndx_bwe;
+ hStereoICBWE->prev_refChanIndx_bwe = hStereoICBWE->refChanIndx_bwe; /* Q0 */
move16();
return;
@@ -1152,19 +1145,19 @@ void stereo_icBWE_init_enc_fx(
* Inter-channel BWE pre-proc of the non-ref channel
*-------------------------------------------------------------------*/
static void findRefChanBWE_fx(
- const Word16 *input0_fx, /* i/o : input 0 Qx */
- const Word16 *input1_fx, /* i/o : input 1 Qx */
- Word16 *refChanIndx_bwe, /* o : Ref Channel Index bwe */
- const Word16 input_frame, /* i : input 0 & 1 frame length */
- Word16 *mem0_fx, /* i/o : mem 0 for input 0 Qx */
- Word16 *mem1_fx /* i/o : mem 1 for input 1 Qx */
+ const Word16 *input0_fx, /* i/o : input 0 Qx q_dataChan_fx*/
+ const Word16 *input1_fx, /* i/o : input 1 Qx q_dataChan_fx*/
+ Word16 *refChanIndx_bwe, /* o : Ref Channel Index bwe Q0*/
+ const Word16 input_frame, /* i : input 0 & 1 frame length Q0*/
+ Word16 *mem0_fx, /* i/o : mem 0 for input 0 Qx q_dataChan_fx*/
+ Word16 *mem1_fx /* i/o : mem 1 for input 1 Qx q_dataChan_fx*/
)
{
Word16 inp0_fx[L_FRAME48k], inp1_fx[L_FRAME48k];
Word32 tempF_fx, tempF1_fx;
- Copy( input0_fx, inp0_fx, input_frame );
- Copy( input1_fx, inp1_fx, input_frame );
+ Copy( input0_fx, inp0_fx, input_frame ); /* q_dataChan_fx */
+ Copy( input1_fx, inp1_fx, input_frame ); /* q_dataChan_fx */
spectral_balancer_fx16( inp0_fx, mem0_fx, input_frame, 1 );
spectral_balancer_fx16( inp1_fx, mem1_fx, input_frame, 1 );
@@ -1174,12 +1167,12 @@ static void findRefChanBWE_fx(
IF( LT_32( tempF1_fx, Mpy_32_32( 1374389535 /* 0.64f Q31 */, tempF_fx ) ) )
{
- *refChanIndx_bwe = L_CH_INDX;
+ *refChanIndx_bwe = L_CH_INDX; /* Q0 */
move16();
}
ELSE IF( LT_32( tempF_fx, Mpy_32_32( 1374389535 /* 0.64f Q31 */, tempF1_fx ) ) )
{
- *refChanIndx_bwe = R_CH_INDX;
+ *refChanIndx_bwe = R_CH_INDX; /* Q0 */
move16();
}
@@ -1194,8 +1187,8 @@ static void findRefChanBWE_fx(
*-------------------------------------------------------------------*/
void stereo_icBWE_preproc_fx(
CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
- const Word16 input_frame, /* i : input frame length */
- Word16 shb_speech_nonref_fx[], /* o : SHB speech non-ref channel */
+ const Word16 input_frame, /* i : input frame length Q0*/
+ Word16 shb_speech_nonref_fx[], /* o : SHB speech non-ref channel q_shb_speech_nonref_fx*/
Word16 q_shb_speech_nonref_fx /* i : Q SHB speech non-ref channel */
)
{
@@ -1210,6 +1203,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 */
@@ -1238,11 +1235,11 @@ void stereo_icBWE_preproc_fx(
IF( GE_16( hCPE->element_mode, IVAS_CPE_DFT ) && GE_32( input_Fs, 32000 ) )
{
set16_fx( temp_inp_fx, 0, L_FRAME48k );
- Copy( hStereoICBWE->dataChan_fx[0], temp_inp_fx + nonRefMemLen, sub( input_frame, nonRefMemLen ) );
+ Copy( hStereoICBWE->dataChan_fx[0], temp_inp_fx + nonRefMemLen, sub( input_frame, nonRefMemLen ) ); /* q_dataChan_fx */
IF( EQ_32( input_Fs, 48000 ) )
{
- Copy( temp_inp_fx, temp_in_fx, L_FRAME48k );
+ Copy( temp_inp_fx, temp_in_fx, L_FRAME48k ); /* q_dataChan_fx */
set16_fx( temp_inp_fx, 0, L_FRAME48k );
i = 2 * L_FILT48k + L_FILT_2OVER3;
move16();
@@ -1252,17 +1249,17 @@ void stereo_icBWE_preproc_fx(
/* flip the spectrum */
FOR( i = 0; i < L_FRAME32k; i += 2 )
{
- temp_inp_fx[i] = negate( temp_inp_fx[i] );
+ temp_inp_fx[i] = negate( temp_inp_fx[i] ); /* q_dataChan_fx */
move16();
}
- Copy( temp_inp_fx + L_FRAME32k - 2 * L_FILT32k, hStereoICBWE->memModifyFs_icbwe_fx[0], 2 * L_FILT32k );
+ Copy( temp_inp_fx + L_FRAME32k - 2 * L_FILT32k, hStereoICBWE->memModifyFs_icbwe_fx[0], 2 * L_FILT32k ); /* q_dataChan_fx */
set16_fx( temp_inp_fx, 0, L_FRAME48k );
- Copy( hStereoICBWE->dataChan_fx[1], temp_inp_fx + nonRefMemLen, sub( input_frame, nonRefMemLen ) );
+ Copy( hStereoICBWE->dataChan_fx[1], temp_inp_fx + nonRefMemLen, sub( input_frame, nonRefMemLen ) ); /* q_dataChan_fx */
IF( EQ_32( input_Fs, 48000 ) )
{
- Copy( temp_inp_fx, temp_in_fx, L_FRAME48k );
+ Copy( temp_inp_fx, temp_in_fx, L_FRAME48k ); /* q_dataChan_fx */
set16_fx( temp_inp_fx, 0, L_FRAME48k );
i = 2 * L_FILT48k + L_FILT_2OVER3;
move16();
@@ -1273,10 +1270,10 @@ void stereo_icBWE_preproc_fx(
/* flip the spectrum */
FOR( i = 0; i < input_frame; i += 2 )
{
- temp_inp_fx[i] = negate( temp_inp_fx[i] );
+ temp_inp_fx[i] = negate( temp_inp_fx[i] ); /* q_dataChan_fx */
move16();
}
- Copy( temp_inp_fx + L_FRAME32k - 2 * L_FILT32k, hStereoICBWE->memModifyFs_icbwe_fx[1], 2 * L_FILT32k );
+ Copy( temp_inp_fx + L_FRAME32k - 2 * L_FILT32k, hStereoICBWE->memModifyFs_icbwe_fx[1], 2 * L_FILT32k ); /* q_dataChan_fx */
}
return;
@@ -1285,10 +1282,10 @@ void stereo_icBWE_preproc_fx(
IF( NE_16( hCPE->element_mode, IVAS_CPE_TD ) )
{
/* initial estimate of refChanIndx_bwe */
- gD_fx = hStereoTCA->targetGain_fx;
+ gD_fx = hStereoTCA->targetGain_fx; /* Q29 */
move32();
- refChanIndx_bwe = hStereoTCA->refChanIndx;
+ refChanIndx_bwe = hStereoTCA->refChanIndx; /* Q0 */
move16();
test();
test();
@@ -1298,7 +1295,7 @@ void stereo_icBWE_preproc_fx(
refChanIndx_bwe = !( hStereoTCA->refChanIndx );
move16();
}
- hStereoICBWE->refChanIndx_bwe = refChanIndx_bwe;
+ hStereoICBWE->refChanIndx_bwe = refChanIndx_bwe; /* Q0 */
move16();
set16_fx( hStereoICBWE->dec_2over3_mem_fx, 0, L_FILT_2OVER3 );
@@ -1310,10 +1307,10 @@ void stereo_icBWE_preproc_fx(
return;
}
- gD_fx = hStereoTCA->targetGain_fx;
+ gD_fx = hStereoTCA->targetGain_fx; /* Q29 */
move32();
- refChanIndx_bwe = hStereoTCA->refChanIndx;
+ refChanIndx_bwe = hStereoTCA->refChanIndx; /* Q0 */
move16();
test();
test();
@@ -1331,19 +1328,19 @@ void stereo_icBWE_preproc_fx(
IF( EQ_16( refChanIndx_bwe, R_CH_INDX ) )
{
- Copy( hStereoICBWE->icbwe_inp_mem_fx[0], temp_inp_fx, nonRefMemLen );
- Copy( hStereoICBWE->dataChan_fx[0], temp_inp_fx + nonRefMemLen, sub( input_frame, nonRefMemLen ) );
+ Copy( hStereoICBWE->icbwe_inp_mem_fx[0], temp_inp_fx, nonRefMemLen ); /* q_dataChan_fx */
+ Copy( hStereoICBWE->dataChan_fx[0], temp_inp_fx + nonRefMemLen, sub( input_frame, nonRefMemLen ) ); /* q_dataChan_fx */
}
ELSE
{
- Copy( hStereoICBWE->icbwe_inp_mem_fx[1], temp_inp_fx, nonRefMemLen );
- Copy( hStereoICBWE->dataChan_fx[1], temp_inp_fx + nonRefMemLen, sub( input_frame, nonRefMemLen ) );
+ Copy( hStereoICBWE->icbwe_inp_mem_fx[1], temp_inp_fx, nonRefMemLen ); /* q_dataChan_fx */
+ Copy( hStereoICBWE->dataChan_fx[1], temp_inp_fx + nonRefMemLen, sub( input_frame, nonRefMemLen ) ); /* q_dataChan_fx */
}
IF( EQ_32( input_Fs, 48000 ) )
{
/*printf("\n Non-ref target HB generation for 48 kHz sample rate needs alignment verification \n");*/
- Copy( temp_inp_fx, temp_in_fx, L_FRAME48k );
+ Copy( temp_inp_fx, temp_in_fx, L_FRAME48k ); /* q_dataChan_fx */
set16_fx( temp_inp_fx, 0, L_FRAME48k );
decimate_2_over_3_allpass_fx( temp_in_fx, L_FRAME48k, temp_inp_fx, hStereoICBWE->dec_2over3_mem_fx, allpass_poles_3_ov_2, decimate_3_ov_2_lowpass_num_fx, decimate_3_ov_2_lowpass_den_fx, hStereoICBWE->dec_2over3_mem_lp_fx );
@@ -1352,25 +1349,25 @@ void stereo_icBWE_preproc_fx(
/* flip the spectrum */
FOR( i = 0; i < input_frame; i += 2 )
{
- temp_inp_fx[i] = negate( temp_inp_fx[i] );
+ temp_inp_fx[i] = negate( temp_inp_fx[i] ); /* q_dataChan_fx */
move16();
}
test();
test();
test();
- IF( GE_16( hCPE->element_mode, IVAS_CPE_DFT ) && GE_32( input_Fs, 32000 ) && ( NE_16( st->last_core, ACELP_CORE ) || EQ_16( st->last_extl, -1 ) ) )
+ IF( GE_16( hCPE->element_mode, IVAS_CPE_DFT ) && GE_32( input_Fs, 32000 ) && ( ( st->last_core != ACELP_CORE ) || EQ_16( st->last_extl, -1 ) ) )
{
- Copy_Scale_sig( hStereoICBWE->memModifyFs_icbwe_fx[!refChanIndx_bwe], hStereoICBWE->mem_decim_shb_ch0_fx, 2 * L_FILT32k, sub( 0, hStereoICBWE->q_dataChan_fx ) );
+ Copy_Scale_sig( hStereoICBWE->memModifyFs_icbwe_fx[!refChanIndx_bwe], hStereoICBWE->mem_decim_shb_ch0_fx, 2 * L_FILT32k, sub( 0, hStereoICBWE->q_dataChan_fx ) ); /* Q0 */
}
Word16 Q_new_inp, mem_decim_size;
- Scale_sig( temp_inp_fx, L_FRAME48k, sub( 0, hStereoICBWE->q_dataChan_fx ) );
+ Scale_sig( temp_inp_fx, L_FRAME48k, sub( 0, hStereoICBWE->q_dataChan_fx ) ); /* q_dataChan_fx */
/* IVAS-219: Re-wire the shb nonref estimation through a lite CLDFB */
modify_Fs_fx( temp_inp_fx, L_FRAME32k, 32000, tempSHB_fx, 16000, hStereoICBWE->mem_decim_shb_ch0_fx, 0, &Q_new_inp, &mem_decim_size );
- Copy_Scale_sig( tempSHB_fx, shb_speech_nonref_fx, L_FRAME16k, sub( q_shb_speech_nonref_fx, Q_new_inp ) );
+ Copy_Scale_sig( tempSHB_fx, shb_speech_nonref_fx, L_FRAME16k, sub( q_shb_speech_nonref_fx, Q_new_inp ) ); /* q_shb_speech_nonref_fx */
return;
}
diff --git a/lib_enc/ivas_stereo_mdct_core_enc.c b/lib_enc/ivas_stereo_mdct_core_enc.c
index 123b2615905547e3fb23f1144414bc3145d03e35..ffc671d4126704f6d9128b99a18e21b723b79856 100644
--- a/lib_enc/ivas_stereo_mdct_core_enc.c
+++ b/lib_enc/ivas_stereo_mdct_core_enc.c
@@ -49,17 +49,17 @@
* Synchronize under certain conditions the tcx modes and set overlap
* windows accordingly
*-------------------------------------------------------------------*/
-static void sync_tcx_mode(
+static void sync_tcx_mode_fx(
Encoder_State **st /* i/o: Encoder state */
)
{
- const Word32 prevAccNrg0 = st[0]->hTranDet->subblockEnergies.accSubblockNrg[st[0]->hTranDet->subblockEnergies.nDelay];
+ const Word32 prevAccNrg0 = st[0]->hTranDet->subblockEnergies.accSubblockNrg[st[0]->hTranDet->subblockEnergies.nDelay]; /* Q0 */
move32();
- const Word32 prevAccNrg1 = st[1]->hTranDet->subblockEnergies.accSubblockNrg[st[1]->hTranDet->subblockEnergies.nDelay];
+ const Word32 prevAccNrg1 = st[1]->hTranDet->subblockEnergies.accSubblockNrg[st[1]->hTranDet->subblockEnergies.nDelay]; /* Q0 */
move32();
- const Word32 lastAccNrg0 = st[0]->hTranDet->subblockEnergies.accSubblockNrg[add( st[0]->hTranDet->subblockEnergies.nDelay, st[0]->hTranDet->transientDetector.nSubblocksToCheck )];
+ const Word32 lastAccNrg0 = st[0]->hTranDet->subblockEnergies.accSubblockNrg[( st[0]->hTranDet->subblockEnergies.nDelay + st[0]->hTranDet->transientDetector.nSubblocksToCheck )]; /* Q0 */
move32();
- const Word32 lastAccNrg1 = st[1]->hTranDet->subblockEnergies.accSubblockNrg[add( st[1]->hTranDet->subblockEnergies.nDelay, st[1]->hTranDet->transientDetector.nSubblocksToCheck )];
+ const Word32 lastAccNrg1 = st[1]->hTranDet->subblockEnergies.accSubblockNrg[( st[1]->hTranDet->subblockEnergies.nDelay + st[1]->hTranDet->transientDetector.nSubblocksToCheck )]; /* Q0 */
move32();
test();
@@ -84,8 +84,8 @@ static void sync_tcx_mode(
test();
test();
test();
- IF( GT_32( prevAccNrg0, Mpy_32_16_1( prevAccNrg1, 1311 ) ) && GT_32( prevAccNrg1, Mpy_32_16_1( prevAccNrg0, 1311 ) ) /* 14 dB */
- && GT_32( lastAccNrg0, Mpy_32_16_1( lastAccNrg1, 2048 ) ) && GT_32( lastAccNrg1, Mpy_32_16_1( lastAccNrg0, 2048 ) ) ) /* 12 dB */
+ IF( GT_32( prevAccNrg0, Mpy_32_16_1( prevAccNrg1, 1311 /*1/25 in Q15*/ ) ) && GT_32( prevAccNrg1, Mpy_32_16_1( prevAccNrg0, 1311 /*1/25 in Q15*/ ) ) /* 14 dB */
+ && GT_32( lastAccNrg0, Mpy_32_16_1( lastAccNrg1, 2048 /*1/12 in Q15*/ ) ) && GT_32( lastAccNrg1, Mpy_32_16_1( lastAccNrg0, 2048 /*1/12 in Q15*/ ) ) ) /* 12 dB */
{
st[0]->hTcxEnc->tcxMode = st[1]->hTcxEnc->tcxMode = s_max( st[0]->hTcxEnc->tcxMode, st[1]->hTcxEnc->tcxMode ); /* synchronize TCX mode of both channels */
move16();
@@ -130,15 +130,17 @@ static void sync_tcx_mode(
*-------------------------------------------------------------------*/
void stereo_mdct_core_enc_fx(
CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
- Word16 new_samples[CPE_CHANNELS][L_INP], /* i : new samples */
- Word16 old_wsp[CPE_CHANNELS][L_WSP], /* i : 12.8kHz weighted speech (for LTP */
- Word16 pitch_buf_fx[CPE_CHANNELS][NB_SUBFR16k] /* o : floating pitch for each subframe */
+ Word16 new_samples[CPE_CHANNELS][L_INP], /* i : new samples Q0*/
+ Word16 old_wsp[CPE_CHANNELS][L_WSP], /* i : 12.8kHz weighted speech (for LTP Qx*/
+ Word16 pitch_buf_fx[CPE_CHANNELS][NB_SUBFR16k] /* o : floating pitch for each subframe Q6*/
)
{
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 */
Word32 *powerSpecMsInv_fx[CPE_CHANNELS][NB_DIV];
Word32 quantized_spectrum_long_fx[CPE_CHANNELS][N_MAX]; /* quantized MDCT spectrum, inv ms mask mdst spectrum, scratch for MS spectra in the MS decision */
@@ -153,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;
@@ -186,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];
@@ -209,11 +214,11 @@ void stereo_mdct_core_enc_fx(
Word16 tmp_e = 0;
move16();
Word32 L_tmp;
- L_tmp = Sqrt32( L_add( L_shr( Mpy_32_32( sts[0]->hTcxEnc->tfm_mem_fx, sts[0]->hTcxEnc->tfm_mem_fx ), 1 ), L_shr( Mpy_32_32( sts[1]->hTcxEnc->tfm_mem_fx, sts[1]->hTcxEnc->tfm_mem_fx ), 1 ) ), &tmp_e ); /* RMS */
+ L_tmp = Sqrt32( L_add( L_shr( Mpy_32_32( sts[0]->hTcxEnc->tfm_mem_fx, sts[0]->hTcxEnc->tfm_mem_fx ), 1 ), L_shr( Mpy_32_32( sts[1]->hTcxEnc->tfm_mem_fx, sts[1]->hTcxEnc->tfm_mem_fx ), 1 ) ), &tmp_e ); /* RMS Q31-tmp_e*/
sts[0]->hTcxEnc->tfm_mem_fx = sts[1]->hTcxEnc->tfm_mem_fx = L_shl( L_tmp, tmp_e ); /* Q31 */
move32();
move32();
- sts[0]->hTcxEnc->tcxltp_norm_corr_past = sts[1]->hTcxEnc->tcxltp_norm_corr_past = extract_l( L_shr( L_add( sts[0]->hTcxEnc->tcxltp_norm_corr_past, sts[1]->hTcxEnc->tcxltp_norm_corr_past ), 1 ) );
+ sts[0]->hTcxEnc->tcxltp_norm_corr_past = sts[1]->hTcxEnc->tcxltp_norm_corr_past = extract_l( L_shr( L_add( sts[0]->hTcxEnc->tcxltp_norm_corr_past, sts[1]->hTcxEnc->tcxltp_norm_corr_past ), 1 ) ); /* Q15 */
move16();
move16();
FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
@@ -229,7 +234,7 @@ void stereo_mdct_core_enc_fx(
EQ_16( sts[0]->hTcxCfg->tcx_last_overlap_mode, sts[1]->hTcxCfg->tcx_last_overlap_mode ) ||
EQ_16( add( sts[0]->hTcxCfg->tcx_last_overlap_mode, sts[1]->hTcxCfg->tcx_last_overlap_mode ), extract_l( 5 ) ) ) ) /* disable syncing for stereo switching or large diff in last frame overlap */
{
- sync_tcx_mode( sts );
+ sync_tcx_mode_fx( sts );
}
IF( hCPE->hCoreCoder[0]->igf )
{
@@ -264,14 +269,15 @@ 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();
sts[ch]->hTcxEnc->tns_ms_flag[1] = 0;
move16();
- Scale_sig( sts[ch]->input_fx, (Word16) ( sts[ch]->input_Fs / 50 ) + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), negate( sts[ch]->q_inp ) );
- Scale_sig( sts[ch]->old_input_signal_fx, (Word16) ( sts[ch]->input_Fs / 50 ), negate( sts[ch]->q_old_inp ) );
+ Scale_sig( sts[ch]->input_fx, add( extract_l( Mpy_32_32( sts[ch]->input_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ), NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ), negate( sts[ch]->q_inp ) ); /* Q0 */
+ Scale_sig( sts[ch]->old_input_signal_fx, extract_l( Mpy_32_32( sts[ch]->input_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ), negate( sts[ch]->q_old_inp ) ); /* Q0 */
sts[ch]->q_old_inp = 0;
move16();
sts[ch]->q_inp = 0;
@@ -303,8 +309,8 @@ void stereo_mdct_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( orig_spectrum_fx[i][0], N_TCX10_MAX, sub( orig_spectrum_e[i][0], max_e ) );
- Scale_sig32( orig_spectrum_fx[i][1], N_TCX10_MAX, sub( orig_spectrum_e[i][1], max_e ) );
+ Scale_sig32( orig_spectrum_fx[i][0], N_TCX10_MAX, sub( orig_spectrum_e[i][0], max_e ) ); /* Q31-max_e */
+ Scale_sig32( orig_spectrum_fx[i][1], N_TCX10_MAX, sub( orig_spectrum_e[i][1], max_e ) ); /* Q31-max_e */
p_orig_spectrum_e[i] = max_e;
move16();
}
@@ -328,19 +334,19 @@ void stereo_mdct_core_enc_fx(
FOR( n = 0; n < nSubframes; n++ )
{
- st->side_bits_frame_channel = add( st->side_bits_frame_channel, NBITS_TCX_GAIN + NOISE_FILL_RANGES * NBITS_NOISE_FILL_LEVEL );
+ st->side_bits_frame_channel = add( st->side_bits_frame_channel, NBITS_TCX_GAIN + NOISE_FILL_RANGES * NBITS_NOISE_FILL_LEVEL ); /* Q0 */
move16();
}
}
- sts[0]->side_bits_frame_channel = add( sts[0]->side_bits_frame_channel, SMDCT_NBBITS_SPLIT_RATIO );
+ sts[0]->side_bits_frame_channel = add( sts[0]->side_bits_frame_channel, SMDCT_NBBITS_SPLIT_RATIO ); /* Q0 */
move16();
/*--------------------------------------------------------------*
* Stereo Processing
*---------------------------------------------------------------*/
-
- if ( !hStereoMdct->isSBAStereoMode )
+ test();
+ IF( !hStereoMdct->isSBAStereoMode )
{
/* Common q for mdst_spectrum and spectrum */
Word16 k;
@@ -365,13 +371,13 @@ void stereo_mdct_core_enc_fx(
n_sb = 1;
move16();
}
- length = idiv1616( sts[ch]->hTcxEnc->L_frameTCX, n_sb );
+ length = idiv1616( sts[ch]->hTcxEnc->L_frameTCX, n_sb ); /* Q0 */
FOR( k = 0; k <= ( ( sts[ch]->core == TCX_20_CORE ) ? 1 : NB_DIV ) - 1; k++ )
{
- Scale_sig32( sts[ch]->hTcxEnc->spectrum_fx[k], length, sub( q_spec, sub( Q31, sts[ch]->hTcxEnc->spectrum_e[k] ) ) );
+ Scale_sig32( sts[ch]->hTcxEnc->spectrum_fx[k], length, sub( q_spec, sub( Q31, sts[ch]->hTcxEnc->spectrum_e[k] ) ) ); /* q_spec */
sts[ch]->hTcxEnc->spectrum_e[k] = sub( Q31, q_spec );
- Scale_sig32( mdst_spectrum_fx[ch][k], length, sub( q_spec, sub( Q31, mdst_spectrum_e[ch][k] ) ) );
+ Scale_sig32( mdst_spectrum_fx[ch][k], length, sub( q_spec, sub( Q31, mdst_spectrum_e[ch][k] ) ) ); /* q_spec */
mdst_spectrum_e[ch][k] = sub( Q31, q_spec );
}
}
@@ -388,7 +394,7 @@ void stereo_mdct_core_enc_fx(
IF( EQ_16( sts[ch]->hTcxEnc->tcxMode, TCX_20 ) )
{
nSubframes = 1;
- L_subframeTCX = sts[ch]->hTcxEnc->L_frameTCX;
+ L_subframeTCX = sts[ch]->hTcxEnc->L_frameTCX; /* Q0 */
move16();
move16();
}
@@ -396,13 +402,13 @@ void stereo_mdct_core_enc_fx(
{
nSubframes = NB_DIV;
move16();
- L_subframeTCX = shr( sts[ch]->hTcxEnc->L_frameTCX, 1 );
+ L_subframeTCX = shr( sts[ch]->hTcxEnc->L_frameTCX, 1 ); /* Q0 */
}
/* in MCT only relevant for bitrate switching from non-MCT bitrates */
IF( EQ_16( sts[ch]->last_core, ACELP_CORE ) )
{
- L_subframeTCX = add( L_subframeTCX, shr( L_subframeTCX, 2 ) );
+ L_subframeTCX = add( L_subframeTCX, shr( L_subframeTCX, 2 ) ); /* Q0 */
}
FOR( n = 0; n < nSubframes; n++ )
@@ -414,18 +420,18 @@ void stereo_mdct_core_enc_fx(
/* power spectrum: MDCT^2 + MDST^2 */
FOR( i = 0; i < L_subframeTCX; i++ )
{
- W_tmp = W_mac_32_32( W_mult_32_32( mdst_spectrum_fx[ch][n][i], mdst_spectrum_fx[ch][n][i] ), sts[ch]->hTcxEnc->spectrum_fx[n][i], sts[ch]->hTcxEnc->spectrum_fx[n][i] );
- tmp_s = sub( W_norm( W_tmp ), 1 );
- W_tmp = W_shl( W_tmp, tmp_s );
- powerSpec_fx[ch][( i + ( n * L_subframeTCX ) )] = W_extract_h( W_tmp );
+ W_tmp = W_mac_32_32( W_mult_32_32( mdst_spectrum_fx[ch][n][i], mdst_spectrum_fx[ch][n][i] ), sts[ch]->hTcxEnc->spectrum_fx[n][i], sts[ch]->hTcxEnc->spectrum_fx[n][i] ); /* 2*q_spec+1 */
+ tmp_s = W_norm( W_tmp );
+ W_tmp = W_shl( W_tmp, tmp_s ); /* 2*q_spec+1+tmp_s */
+ powerSpec_fx[ch][( i + ( n * L_subframeTCX ) )] = W_extract_h( W_tmp ); /* 2*q_spec+1+tmp_s-32 */
tmp_q_powSpec[( i + ( n * L_subframeTCX ) )] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32
move32();
move16();
- W_tmp = W_mac_32_32( W_mult_32_32( inv_mdst_spectrum_fx[ch][n][i], inv_mdst_spectrum_fx[ch][n][i] ), inv_spectrum_fx[ch][n][i], inv_spectrum_fx[ch][n][i] );
- tmp_s = sub( W_norm( W_tmp ), 1 );
- W_tmp = W_shl( W_tmp, tmp_s );
- powerSpecMsInv_fx[ch][n][i] = W_extract_h( W_tmp );
+ W_tmp = W_mac_32_32( W_mult_32_32( inv_mdst_spectrum_fx[ch][n][i], inv_mdst_spectrum_fx[ch][n][i] ), inv_spectrum_fx[ch][n][i], inv_spectrum_fx[ch][n][i] ); /* 2*q_spec+1 */
+ tmp_s = W_norm( W_tmp );
+ W_tmp = W_shl( W_tmp, tmp_s ); /* 2*q_spec+1+tmp_s */
+ 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
move32();
move16();
@@ -436,62 +442,62 @@ void stereo_mdct_core_enc_fx(
IF( NE_16( hStereoMdct->mdct_stereo_mode[n], SMDCT_DUAL_MONO ) )
{
/* power spectrum: MDCT^2 + MDST^2 */
- W_tmp = W_mult_32_32( inv_spectrum_fx[ch][n][0], inv_spectrum_fx[ch][n][0] );
- tmp_s = sub( W_norm( W_tmp ), 1 );
- W_tmp = W_shl( W_tmp, tmp_s );
- powerSpecMsInv_fx[ch][n][0] = W_extract_h( W_tmp );
+ W_tmp = W_mult_32_32( inv_spectrum_fx[ch][n][0], inv_spectrum_fx[ch][n][0] ); /* 2*q_spec+1 */
+ tmp_s = W_norm( W_tmp );
+ W_tmp = W_shl( W_tmp, tmp_s ); /* 2*q_spec+1+tmp_s */
+ 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
move32();
move16();
FOR( i = 1; i < L_subframeTCX - 1; i++ )
{
- Word32 mdst_fx = L_sub( inv_spectrum_fx[ch][n][i + 1], inv_spectrum_fx[ch][n][i - 1] ); /* An MDST estimate */
+ 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] );
- tmp_s = sub( W_norm( W_tmp ), 1 );
- W_tmp = W_shl( W_tmp, tmp_s );
- powerSpecMsInv_fx[ch][n][i] = W_extract_h( W_tmp );
+ 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 = 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
move32();
move16();
}
- W_tmp = W_mult_32_32( inv_spectrum_fx[ch][n][L_subframeTCX - 1], inv_spectrum_fx[ch][n][L_subframeTCX - 1] );
- tmp_s = sub( W_norm( W_tmp ), 1 );
- W_tmp = W_shl( W_tmp, tmp_s );
- powerSpecMsInv_fx[ch][n][L_subframeTCX - 1] = W_extract_h( W_tmp );
+ 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 = 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
move32();
move16();
}
/* 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] );
- tmp_s = sub( W_norm( W_tmp ), 1 );
- W_tmp = W_shl( W_tmp, tmp_s );
- powerSpec_fx[ch][n * L_subframeTCX] = W_extract_h( W_tmp );
+ W_tmp = W_mult_32_32( sts[ch]->hTcxEnc->spectrum_fx[n][0], sts[ch]->hTcxEnc->spectrum_fx[n][0] ); /* 2*q_spec+1 */
+ tmp_s = W_norm( W_tmp );
+ W_tmp = W_shl( W_tmp, tmp_s ); /* 2*q_spec+1+tmp_s */
+ powerSpec_fx[ch][n * L_subframeTCX] = W_extract_h( W_tmp ); /* 2*q_spec+1+tmp_s-32 */
tmp_q_powSpec[n * L_subframeTCX] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32
move32();
move16();
FOR( i = 1; i < L_subframeTCX - 1; i++ )
{
- Word32 mdst_fx = L_sub( sts[ch]->hTcxEnc->spectrum_fx[n][i + 1], sts[ch]->hTcxEnc->spectrum_fx[n][i - 1] ); /* An MDST estimate */
+ 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] );
- tmp_s = sub( W_norm( W_tmp ), 1 );
- W_tmp = W_shl( W_tmp, tmp_s );
- powerSpec_fx[ch][( i + ( n * L_subframeTCX ) )] = W_extract_h( W_tmp );
+ W_tmp = W_mac_32_32( W_mult_32_32( mdst_fx, mdst_fx ), sts[ch]->hTcxEnc->spectrum_fx[n][i], sts[ch]->hTcxEnc->spectrum_fx[n][i] ); /* 2*q_spec+1 */
+ tmp_s = W_norm( W_tmp );
+ W_tmp = W_shl( W_tmp, tmp_s ); /* 2*q_spec+1+tmp_s */
+ powerSpec_fx[ch][( i + ( n * L_subframeTCX ) )] = W_extract_h( W_tmp ); /* 2*q_spec+1+tmp_s-32 */
tmp_q_powSpec[( i + ( n * L_subframeTCX ) )] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32
move32();
move16();
}
- W_tmp = W_mult_32_32( sts[ch]->hTcxEnc->spectrum_fx[n][L_subframeTCX - 1], sts[ch]->hTcxEnc->spectrum_fx[n][L_subframeTCX - 1] );
- tmp_s = sub( W_norm( W_tmp ), 1 );
- W_tmp = W_shl( W_tmp, tmp_s );
- powerSpec_fx[ch][( ( L_subframeTCX - 1 ) + ( n * L_subframeTCX ) )] = W_extract_h( W_tmp );
+ W_tmp = W_mult_32_32( sts[ch]->hTcxEnc->spectrum_fx[n][L_subframeTCX - 1], sts[ch]->hTcxEnc->spectrum_fx[n][L_subframeTCX - 1] ); /* 2*q_spec+1 */
+ tmp_s = W_norm( W_tmp );
+ W_tmp = W_shl( W_tmp, tmp_s ); /* 2*q_spec+1+tmp_s */
+ powerSpec_fx[ch][( ( L_subframeTCX - 1 ) + ( n * L_subframeTCX ) )] = W_extract_h( W_tmp ); /* 2*q_spec+1+tmp_s-32 */
tmp_q_powSpec[( ( L_subframeTCX - 1 ) + ( n * L_subframeTCX ) )] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32
move32();
move16();
@@ -500,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] ) );
- powerSpec_fx[ch][( i + ( n * L_subframeTCX ) )] = L_shr( powerSpec_fx[ch][( i + ( n * L_subframeTCX ) )], sub( tmp_q_powSpec[i], q_powSpec[ch] ) );
+ 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();
}
@@ -545,11 +561,11 @@ void stereo_mdct_core_enc_fx(
nSubframes = NB_DIV;
move16();
}
- L_subframeTCX = idiv1616( st->hTcxEnc->L_frameTCX, nSubframes );
+ L_subframeTCX = idiv1616( st->hTcxEnc->L_frameTCX, nSubframes ); /* Q0 */
IF( st->last_core == ACELP_CORE )
{
- L_subframeTCX = add( L_subframeTCX, shr( L_subframeTCX, 2 ) );
+ L_subframeTCX = add( L_subframeTCX, shr( L_subframeTCX, 2 ) ); /* Q0 */
}
test();
test();
@@ -560,11 +576,11 @@ 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 );
}
- st->hTcxEnc->measuredBwRatio = ONE_IN_Q14; /* No bandwidth limit for the noise filling */
+ st->hTcxEnc->measuredBwRatio = ONE_IN_Q14; /* No bandwidth limit for the noise filling Q14*/
move16();
}
@@ -586,7 +602,7 @@ void stereo_mdct_core_enc_fx(
nSubframes = 1;
move16();
}
- L_subframeTCX = idiv1616( sts[0]->hTcxEnc->L_frameTCX, nSubframes );
+ L_subframeTCX = idiv1616( sts[0]->hTcxEnc->L_frameTCX, nSubframes ); /* Q0 */
FOR( n = 0; n < nSubframes; n++ )
{
test();
@@ -594,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 ) )
@@ -609,18 +626,25 @@ void stereo_mdct_core_enc_fx(
n_sb = 1;
move16();
}
- length = idiv1616( sts[ch]->hTcxEnc->L_frameTCX, n_sb );
- IF( GT_16( q_spec, q_powSpec[ch] ) )
+ length = idiv1616( sts[ch]->hTcxEnc->L_frameTCX, n_sb ); /* Q0 */
+ IF( NE_16( q_spec, q_comm ) )
{
- Scale_sig32( sts[ch]->hTcxEnc->spectrum_fx[n], length, sub( q_powSpec[ch], q_spec ) );
- Scale_sig32( inv_spectrum_fx[ch][n], length, sub( q_powSpec[ch], q_spec ) );
- 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] ) );
- Scale_sig32( powerSpecMsInv_fx[ch][0], L_subframeTCX, sub( q_spec, q_powSpec[ch] ) );
+ 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];
@@ -628,8 +652,8 @@ void stereo_mdct_core_enc_fx(
hIGFEnc[1]->spec_be_igf_e = p_orig_spectrum_e[1];
move16();
ProcessStereoIGF_fx( hStereoMdct, sts, ms_mask,
- orig_spectrum_fx,
- p_powerSpec_fx, powerSpecMsInv_fx, inv_spectrum_fx, n, hCPE->hCoreCoder[0]->sp_aud_decision0, hCPE->hCoreCoder[0]->element_brate );
+ orig_spectrum_fx, sub( Q31, p_orig_spectrum_e[0] ), sub( Q31, p_orig_spectrum_e[1] ),
+ p_powerSpec_fx, powerSpecMsInv_fx, inv_spectrum_fx, n, hCPE->hCoreCoder[0]->sp_aud_decision0, hCPE->hCoreCoder[0]->element_brate, 0 );
}
ELSE
{
@@ -641,17 +665,19 @@ void stereo_mdct_core_enc_fx(
{
st->hBstr->ind_list = sts[0]->hBstr->ind_list + sts[0]->hBstr->nb_ind_tot;
}
- L_subframeTCX = idiv1616( st->hTcxEnc->L_frameTCX, nSubframes );
+ L_subframeTCX = idiv1616( st->hTcxEnc->L_frameTCX, nSubframes ); /* Q0 */
Word16 q_spectrum;
q_spectrum = sub( Q31, p_orig_spectrum_e[ch] );
IF( st->hIGFEnc )
{
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 = sub( Q31, st->hTcxEnc->spectrum_e[n] );
- ProcessIGF_ivas_fx( st, st->hTcxEnc->spectrum_fx[n], orig_spectrum_fx[ch][n], &q_spectrum, &powerSpec_fx[ch][n * L_subframeTCX], &q_powSpec[ch], st->core == TCX_20_CORE, n, hCPE->hCoreCoder[0]->sp_aud_decision0, 0 );
+
+ 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 );
}
}
}
@@ -681,16 +707,18 @@ void stereo_mdct_core_enc_fx(
FOR( n = 0; n < nSubframes; n++ )
{
Word16 q_spectrum;
- L_subframeTCX = idiv1616( st->hTcxEnc->L_frameTCX, nSubframes );
+ L_subframeTCX = idiv1616( st->hTcxEnc->L_frameTCX, nSubframes ); /* Q0 */
q_spectrum = sub( Q31, p_orig_spectrum_e[ch] );
IF( st->hIGFEnc )
{
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 = sub( Q31, st->hTcxEnc->spectrum_e[n] );
- ProcessIGF_ivas_fx( st, st->hTcxEnc->spectrum_fx[n], orig_spectrum_fx[ch][n], &q_spectrum, &powerSpec_fx[ch][n * L_subframeTCX], &q_powSpec[ch], st->core == TCX_20_CORE, n, hCPE->hCoreCoder[0]->sp_aud_decision0, 0 );
+
+ 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 );
}
}
}
@@ -709,7 +737,7 @@ void stereo_mdct_core_enc_fx(
move16();
IF( !hStereoMdct->isSBAStereoMode )
{
- stereo_bits = write_stereo_to_bitstream( hStereoMdct, sts, ms_mask, 0, hBstr );
+ stereo_bits = write_stereo_to_bitstream_fx( hStereoMdct, sts, ms_mask, 0, hBstr ); /* Q0 */
}
ELSE
{
@@ -731,11 +759,11 @@ void stereo_mdct_core_enc_fx(
n_sb = 1;
move16();
}
- L_subframeTCX = idiv1616( sts[ch]->hTcxEnc->L_frameTCX, n_sb );
+ L_subframeTCX = idiv1616( sts[ch]->hTcxEnc->L_frameTCX, n_sb ); /* Q0 */
FOR( n = 0; n <= ( ( sts[ch]->hTcxEnc->tcxMode == TCX_20 ) ? 1 : NB_DIV ) - 1; n++ )
{
q_com = L_norm_arr( sts[ch]->hTcxEnc->spectrum_fx[n], L_subframeTCX );
- Scale_sig32( sts[ch]->hTcxEnc->spectrum_fx[n], L_subframeTCX, q_com );
+ Scale_sig32( sts[ch]->hTcxEnc->spectrum_fx[n], L_subframeTCX, q_com ); /* Q31 - sts[ch]->hTcxEnc->spectrum_e + q_com */
sts[ch]->hTcxEnc->spectrum_e[n] = sub( sts[ch]->hTcxEnc->spectrum_e[n], q_com );
}
}
@@ -760,7 +788,7 @@ void stereo_mdct_core_enc_fx(
FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
{
- sts[ch]->total_brate = imult3216( L_deposit_l( add( sts[ch]->bits_frame_channel, sts[ch]->side_bits_frame_channel ) ), FRAMES_PER_SEC );
+ sts[ch]->total_brate = imult3216( L_deposit_l( add( sts[ch]->bits_frame_channel, sts[ch]->side_bits_frame_channel ) ), FRAMES_PER_SEC ); /* Q0 */
move32();
}
stereo_bits = add( stereo_bits, SMDCT_NBBITS_SPLIT_RATIO );
diff --git a/lib_enc/ivas_stereo_mdct_igf_enc.c b/lib_enc/ivas_stereo_mdct_igf_enc.c
index c200a748caf06abb39b9164a83d085cd4ea0f4c8..190255fd9be4f9e4b839cfdf2dc91f3f421be480 100644
--- a/lib_enc/ivas_stereo_mdct_igf_enc.c
+++ b/lib_enc/ivas_stereo_mdct_igf_enc.c
@@ -64,10 +64,10 @@ static Word16 calcCoh_fx( // Q15
const Word32 *sig1_fx, // Q( q_sig )
const Word32 *sig2_fx, // Q( q_sig )
const Word16 q_sig,
- const Word16 nSamples,
- Word32 *corr,
+ const Word16 nSamples, /* Q0 */
+ Word32 *corr, /* Q31-corr_e */
Word16 *corr_e,
- Word16 *predCoeff,
+ Word16 *predCoeff, /* Q31-predCoeff_e */
Word16 *predCoeff_e )
{
Word32 ener1_fx, ener2_fx, cEner_fx, cc_fx;
@@ -82,13 +82,13 @@ static Word16 calcCoh_fx( // Q15
move16();
q_cc = q_ener1;
move16();
- ener1_fx = dotp_fixed_o( sig1_fx, sig1_fx, nSamples, gB, &q_ener1 );
- ener2_fx = dotp_fixed_o( sig2_fx, sig2_fx, nSamples, gB, &q_ener2 );
- cEner_fx = Mpy_32_32( ener1_fx, ener2_fx );
+ ener1_fx = dotp_fixed_o( sig1_fx, sig1_fx, nSamples, gB, &q_ener1 ); /* q_ener1 */
+ ener2_fx = dotp_fixed_o( sig2_fx, sig2_fx, nSamples, gB, &q_ener2 ); /* q_ener2 */
+ cEner_fx = Mpy_32_32( ener1_fx, ener2_fx ); /* q_ener1+q_ener2-31 */
q_cEner = sub( 62, add( q_ener1, q_ener2 ) );
- cEner_fx = Sqrt32( cEner_fx, &q_cEner );
+ cEner_fx = Sqrt32( cEner_fx, &q_cEner ); /* Q31-q_cEner */
q_cEner = sub( Q31, q_cEner );
- cc_fx = dotp_fixed_o( sig1_fx, sig2_fx, nSamples, gB, &q_cc );
+ cc_fx = dotp_fixed_o( sig1_fx, sig2_fx, nSamples, gB, &q_cc ); /* q_cc */
IF( corr != NULL )
{
@@ -100,7 +100,7 @@ static Word16 calcCoh_fx( // Q15
IF( cEner_fx > 0 )
{
- coh_fx = BASOP_Util_Divide3232_Scale( cc_fx, cEner_fx, &coh_e );
+ coh_fx = BASOP_Util_Divide3232_Scale( cc_fx, cEner_fx, &coh_e ); /* Q15-coh_e */
coh_e = add( coh_e, sub( q_cEner, q_cc ) );
coh_fx = shl_sat( coh_fx, coh_e ); // Q15
}
@@ -111,7 +111,7 @@ static Word16 calcCoh_fx( // Q15
move32();
IF( ener1_fx > 0 )
{
- *predCoeff = BASOP_Util_Divide3232_Scale( cc_fx, ener1_fx, predCoeff_e );
+ *predCoeff = BASOP_Util_Divide3232_Scale( cc_fx, ener1_fx, predCoeff_e ); /* Q31-predCoeff_e */
move32();
*predCoeff_e = add( *predCoeff_e, sub( q_ener1, q_cc ) );
move16();
@@ -131,12 +131,12 @@ static Word16 calcCoh_fx( // Q15
static void IGF_MsStereoDecision_fx(
STEREO_MDCT_BAND_PARAMETERS *sfbParam,
H_IGF_GRID hGrid,
- const Word32 *specL_fx,
- const Word32 *specR_fx,
+ const Word32 *specL_fx, /* q_spec */
+ const Word32 *specR_fx, /* q_spec */
Word16 q_spec,
- Word16 *igfStereoMode, /* output*/
- Word16 *msMask, /* output*/
- const Word16 mdct_stereo_mode )
+ Word16 *igfStereoMode, /* output Q0*/
+ Word16 *msMask, /* output Q0*/
+ const Word16 mdct_stereo_mode /* Q0 */ )
{
Word16 sfb;
Word16 msMaskTrueSomewhere, msMaskFalseSomewhere;
@@ -150,18 +150,18 @@ static void IGF_MsStereoDecision_fx(
if ( EQ_16( mdct_stereo_mode, SMDCT_MS_FULL ) )
{
- thresh = 13762; /* lower threshold if core is already MS */
+ thresh = 13762; /* lower threshold if core is already MS TARGET_COH_THRESHOLD_FX*(0.7 in Q15)*/
move16();
}
FOR( tile_idx = 0; tile_idx < hGrid->nTiles; tile_idx++ )
{
- strt_cpy = hGrid->sbWrap[tile_idx];
+ strt_cpy = hGrid->sbWrap[tile_idx]; /* Q0 */
move16();
FOR( sfb = hGrid->sfbWrap[tile_idx]; sfb < hGrid->sfbWrap[tile_idx + 1]; sfb++ )
{
- Word16 width = sub( hGrid->swb_offset[sfb + 1], hGrid->swb_offset[sfb] );
+ Word16 width = sub( hGrid->swb_offset[sfb + 1], hGrid->swb_offset[sfb] ); /* Q0 */
Word32 cc_src_fx, cc_target_fx;
Word16 cc_src_e, cc_target_e;
Word16 pc_target_fx, pc_src_fx;
@@ -177,10 +177,10 @@ static void IGF_MsStereoDecision_fx(
Word16 coh_src = calcCoh_fx( &specL_fx[strt_cpy], &specR_fx[strt_cpy], q_spec, width, &cc_src_fx, &cc_src_e, &pc_src_fx, &pc_src_e );
Word16 coh_target = calcCoh_fx( &specL_fx[hGrid->swb_offset[sfb]], &specR_fx[hGrid->swb_offset[sfb]], q_spec, width, &cc_target_fx, &cc_target_e, &pc_target_fx, &pc_target_e );
- tmp1_e = BASOP_Util_Add_MantExp( pc_target_fx, pc_target_e, negate( pc_src_fx ), pc_src_e, &tmp1 );
- tmp2_e = BASOP_Util_Add_MantExp( pc_target_fx, pc_target_e, -16384, 1, &tmp2 );
+ tmp1_e = BASOP_Util_Add_MantExp( pc_target_fx, pc_target_e, negate( pc_src_fx ), pc_src_e, &tmp1 ); /* Q15-tmp1_e */
+ tmp2_e = BASOP_Util_Add_MantExp( pc_target_fx, pc_target_e, -16384, 1, &tmp2 ); /* Q15-tmp2_e */
- strt_cpy = add( strt_cpy, width );
+ strt_cpy = add( strt_cpy, width ); /* Q0 */
IF( GT_16( abs_s( coh_target ), thresh ) )
{
/* target is very coherent */
@@ -236,14 +236,14 @@ static void IGF_MsStereoDecision_fx(
case IGF_PATCH_LR:
msMask[sfb] = 0;
move16();
- numMsMaskFalse = add( numMsMaskFalse, 1 );
+ numMsMaskFalse = add( numMsMaskFalse, 1 ); /* Q0 */
msMaskFalseSomewhere = 1;
move16();
break;
case IGF_PATCH_MS:
msMask[sfb] = 1;
move16();
- numMsMaskTrue = add( numMsMaskTrue, 1 );
+ numMsMaskTrue = add( numMsMaskTrue, 1 ); /* Q0 */
msMaskTrueSomewhere = 1;
move16();
break;
@@ -302,14 +302,14 @@ static void IGF_MsStereoDecision_fx(
void IGFEncStereoEncoder_fx(
STEREO_MDCT_BAND_PARAMETERS *sfbParam, /* i/o: sfb parameters for the right channel */
const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : IGF handle */
- const Word32 *mdctSpectrumL_fx, /* i : left spectrum */
- const Word32 *mdctSpectrumR_fx, /* i : right spectrum */
+ const Word32 *mdctSpectrumL_fx, /* i : left spectrum q_mdctSpectrum*/
+ const Word32 *mdctSpectrumR_fx, /* i : right spectrum q_mdctSpectrum*/
Word16 q_mdctSpectrum,
- Word16 *msMask, /* i/o: MS mask */
- Word16 *igfStereoMode, /* o : IGF stereo mode */
- const Word16 mdct_stereo_mode, /* i : MDCT stereo mode */
- const Word16 isTCX20, /* i : flag for indicating TCX20 */
- const Word16 isTransition /* i : flag for transtition */
+ Word16 *msMask, /* i/o: MS mask Q0*/
+ Word16 *igfStereoMode, /* o : IGF stereo mode Q0*/
+ const Word16 mdct_stereo_mode, /* i : MDCT stereo mode Q0*/
+ const Word16 isTCX20, /* i : flag for indicating TCX20 Q0*/
+ const Word16 isTransition /* i : flag for transtition Q0*/
)
{
Word16 igfGridIdx;
diff --git a/lib_enc/ivas_stereo_mdct_stereo_enc.c b/lib_enc/ivas_stereo_mdct_stereo_enc.c
index b69883930fbdca711d76911d6d5aef4cfc62c2a5..4c73ba2e72f9b30f911376a6b6f285dd242152f5 100644
--- a/lib_enc/ivas_stereo_mdct_stereo_enc.c
+++ b/lib_enc/ivas_stereo_mdct_stereo_enc.c
@@ -77,7 +77,7 @@ static void MsStereoDecision_fx( STEREO_MDCT_BAND_PARAMETERS *sfbParam, Word32 *
static void dft_ana_init_fx(
DFT_ANA_HANDLE hDft_ana, /*i : DFT analysis handle */
- const Word32 input_Fs /*i : Input sampling frequency */
+ const Word32 input_Fs /*i : Input sampling frequency Q0*/
)
{
hDft_ana->N = extract_l( Mpy_32_16_1( input_Fs, 656 /* STEREO_DFT_HOP_MAX_ENC / 48000 in Q15 */ ) );
@@ -89,29 +89,29 @@ static void dft_ana_init_fx(
hDft_ana->dft_zp = extract_l( Mpy_32_16_1( input_Fs, 185 /* STEREO_DFT_ZP_MAX_ENC / 48000 in Q15 */ ) );
move16();
- hDft_ana->dft_trigo_32k_fx = dft_trigo_32k_fx;
+ hDft_ana->dft_trigo_32k_fx = dft_trigo_32k_fx; /* Q15 */
IF( EQ_32( input_Fs, 16000 ) )
{
- hDft_ana->dft_trigo_fx = dft_trigo_32k_fx;
+ hDft_ana->dft_trigo_fx = dft_trigo_32k_fx; /* Q15 */
hDft_ana->dft_trigo_step = STEREO_DFT_TRIGO_SRATE_16k_STEP;
move16();
- hDft_ana->win_ana_fx = win_ana_16k_fx;
+ hDft_ana->win_ana_fx = win_ana_16k_fx; /* Q15 */
}
ELSE IF( EQ_32( input_Fs, 32000 ) )
{
- hDft_ana->dft_trigo_fx = dft_trigo_32k_fx;
+ hDft_ana->dft_trigo_fx = dft_trigo_32k_fx; /* Q15 */
hDft_ana->dft_trigo_step = STEREO_DFT_TRIGO_SRATE_32k_STEP;
move16();
- hDft_ana->win_ana_fx = win_ana_32k_fx;
+ hDft_ana->win_ana_fx = win_ana_32k_fx; /* Q15 */
}
ELSE
{
assert( input_Fs == 48000 );
- hDft_ana->dft_trigo_fx = dft_trigo_48k_fx;
+ hDft_ana->dft_trigo_fx = dft_trigo_48k_fx; /* Q15 */
hDft_ana->dft_trigo_step = STEREO_DFT_TRIGO_SRATE_48k_STEP;
move16();
- hDft_ana->win_ana_fx = win_ana_48k_fx;
+ hDft_ana->win_ana_fx = win_ana_48k_fx; /* Q15 */
}
return;
@@ -139,7 +139,7 @@ static void write_itd_data_fx(
IF( hItd->itd_fx[k_offset] != 0 )
{
- itd = hItd->itd_index[k_offset];
+ itd = hItd->itd_index[k_offset]; /* Q0 */
IF( GT_16( itd, 255 ) )
{
itd = sub( itd, 256 );
@@ -184,14 +184,14 @@ static void write_itd_data_fx(
void stereo_coder_tcx_fx(
STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: Stereo MDCT encoder structure */
Encoder_State **sts, /* i/o: encoder state structure */
- Word16 ms_mask[NB_DIV][MAX_SFB], /* i : bandwise MS mask */
+ Word16 ms_mask[NB_DIV][MAX_SFB], /* i : bandwise MS mask Q0*/
Word32 *mdst_spectrum_fx[CPE_CHANNELS][NB_DIV],
/* i/o: MDST spectrum */ // Q( q_spec ) (same as spectrum buffer in hTcxEnc)
Word32 *inv_spectrum_fx[CPE_CHANNELS][NB_DIV],
/* i/o: inverse spectrum */ // Q( q_spec ) (same as spectrum buffer in hTcxEnc)
Word32 *inv_mdst_spectrum_fx[CPE_CHANNELS][NB_DIV],
/* i/o: inverse MDST spectrum */ // Q( q_spec ) (same as spectrum buffer in hTcxEnc)
- const Word16 mct_on, /* i : flag mct block (1) or stereo (0) */
+ const Word16 mct_on, /* i : flag mct block (1) or stereo (0) Q0*/
Word16 q_spec )
{
STEREO_MDCT_BAND_PARAMETERS *sfbConf = NULL;
@@ -208,7 +208,7 @@ void stereo_coder_tcx_fx(
set16_fx( nAvailBitsMS, 0, NB_DIV );
nSubframes = ( sts[0]->core == TCX_20_CORE && sts[1]->core == TCX_20_CORE ) ? 1 : NB_DIV;
- L_frameTCX = sts[0]->hTcxEnc->L_frameTCX / nSubframes;
+ L_frameTCX = idiv1616( sts[0]->hTcxEnc->L_frameTCX, nSubframes );
set16_fx( &ms_mask[0][0], 0, MAX_SFB );
set16_fx( &ms_mask[1][0], 0, MAX_SFB );
@@ -224,7 +224,7 @@ void stereo_coder_tcx_fx(
hStereoMdct->global_ild[k] = s_max( 1, s_min( SMDCT_ILD_RANGE - 1, round_fx( L_mult( SMDCT_ILD_RANGE, nonQNrgRatio_fx[k] ) ) ) );
move16();
- nrgRatio_fx[k] = L_deposit_h( BASOP_Util_Divide1616_Scale( sub( SMDCT_ILD_RANGE, hStereoMdct->global_ild[k] ), hStereoMdct->global_ild[k], &nrgRatio_e[k] ) );
+ nrgRatio_fx[k] = L_deposit_h( BASOP_Util_Divide1616_Scale( sub( SMDCT_ILD_RANGE, hStereoMdct->global_ild[k] ), hStereoMdct->global_ild[k], &nrgRatio_e[k] ) ); /* Q31-nrgRatio_e[k] */
move32();
/*nonQNrgRatio[k] = max( 0.5f / SMDCT_ILD_RANGE, min( ( SMDCT_ILD_RANGE - 0.5f ) / SMDCT_ILD_RANGE, nonQNrgRatio[k] ) );
nonQNrgRatio[k] = 1.0f / nonQNrgRatio[k] - 1.0f;*/
@@ -233,11 +233,11 @@ void stereo_coder_tcx_fx(
}
ELSE
{
- nonQNrgRatio_fx[0] = nonQNrgRatio_fx[1] = GetChannelEnergyRatio_fx( sts, 0, nSubframes - 1, 1 );
+ nonQNrgRatio_fx[0] = nonQNrgRatio_fx[1] = GetChannelEnergyRatio_fx( sts, 0, nSubframes - 1, 1 ); /* Q15 */
move16();
hStereoMdct->global_ild[0] = s_max( 1, s_min( SMDCT_ILD_RANGE - 1, round_fx( L_mult( SMDCT_ILD_RANGE, nonQNrgRatio_fx[0] ) ) ) );
move16();
- nrgRatio_fx[0] = nrgRatio_fx[1] = L_deposit_h( BASOP_Util_Divide1616_Scale( sub( SMDCT_ILD_RANGE, hStereoMdct->global_ild[0] ), hStereoMdct->global_ild[0], &nrgRatio_e[0] ) ); /* nrgRatio = nrg[1]/nrg[0] */
+ nrgRatio_fx[0] = nrgRatio_fx[1] = L_deposit_h( BASOP_Util_Divide1616_Scale( sub( SMDCT_ILD_RANGE, hStereoMdct->global_ild[0] ), hStereoMdct->global_ild[0], &nrgRatio_e[0] ) ); /* nrgRatio = nrg[1]/nrg[0] (Q31-nrgRatio_e[0])*/
move32();
nrgRatio_e[1] = nrgRatio_e[0];
move16();
@@ -250,24 +250,24 @@ void stereo_coder_tcx_fx(
{
IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( nrgRatio_fx[k], nrgRatio_e[k], ONE_IN_Q27, 4 ), 1 ) && LT_16( k, ( EQ_16( sts[1]->core, TCX_20_CORE ) ? 1 : NB_DIV ) ) )
{
- L_frameTCX = add( sts[1]->hTcxEnc->L_frameTCX, ( ( sts[1]->last_core == 0 ) ? shr( sts[1]->hTcxEnc->L_frameTCX, 2 ) : 0 ) );
- L_frameTCX = idiv1616( L_frameTCX, ( sts[1]->core == TCX_20_CORE ) ? 1 : NB_DIV );
+ L_frameTCX = add( sts[1]->hTcxEnc->L_frameTCX, ( ( sts[1]->last_core == 0 ) ? shr( sts[1]->hTcxEnc->L_frameTCX, 2 ) : 0 ) ); /* Q0 */
+ L_frameTCX = idiv1616( L_frameTCX, ( sts[1]->core == TCX_20_CORE ) ? 1 : NB_DIV ); /* Q0 */
e_tmp = nrgRatio_e[k];
- tmp = Inv16( extract_h( nrgRatio_fx[k] ), &e_tmp );
- tmp = shl( tmp, e_tmp );
+ tmp = Inv16( extract_h( nrgRatio_fx[k] ), &e_tmp ); /* Q15-e_tmp */
+ tmp = shl( tmp, e_tmp ); /* Q15 */
- v_multc_fixed_16( sts[1]->hTcxEnc->spectrum_fx[k], tmp, sts[1]->hTcxEnc->spectrum_fx[k], L_frameTCX );
- v_multc_fixed_16( mdst_spectrum_fx[1][k], tmp, mdst_spectrum_fx[1][k], L_frameTCX );
+ v_multc_fixed_16( sts[1]->hTcxEnc->spectrum_fx[k], tmp, sts[1]->hTcxEnc->spectrum_fx[k], L_frameTCX ); /* Q31-spectrum_e[k] */
+ v_multc_fixed_16( mdst_spectrum_fx[1][k], tmp, mdst_spectrum_fx[1][k], L_frameTCX ); /* q_spec */
}
ELSE IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( nrgRatio_fx[k], nrgRatio_e[k], ONE_IN_Q27, 4 ), -1 ) && LT_16( k, EQ_16( sts[0]->core, TCX_20_CORE ) ? 1 : NB_DIV ) )
{
- L_frameTCX = add( sts[0]->hTcxEnc->L_frameTCX, EQ_16( sts[0]->last_core, 0 ) ? shr( sts[0]->hTcxEnc->L_frameTCX, 2 ) : 0 );
- L_frameTCX = idiv1616( L_frameTCX, ( sts[0]->core == TCX_20_CORE ) ? 1 : NB_DIV );
+ L_frameTCX = add( sts[0]->hTcxEnc->L_frameTCX, EQ_16( sts[0]->last_core, 0 ) ? shr( sts[0]->hTcxEnc->L_frameTCX, 2 ) : 0 ); /* Q0 */
+ L_frameTCX = idiv1616( L_frameTCX, ( sts[0]->core == TCX_20_CORE ) ? 1 : NB_DIV ); /* Q0 */
/* This operation is resulting in some high MLDs in fixed point. */
- v_multc_fixed_16( sts[0]->hTcxEnc->spectrum_fx[k], extract_l( L_shr( nrgRatio_fx[k], 16 - nrgRatio_e[k] ) ), sts[0]->hTcxEnc->spectrum_fx[k], L_frameTCX );
- v_multc_fixed_16( mdst_spectrum_fx[0][k], extract_l( L_shr( nrgRatio_fx[k], 16 - nrgRatio_e[k] ) ), mdst_spectrum_fx[0][k], L_frameTCX );
+ v_multc_fixed_16( sts[0]->hTcxEnc->spectrum_fx[k], extract_l( L_shr( nrgRatio_fx[k], 16 - nrgRatio_e[k] ) ), sts[0]->hTcxEnc->spectrum_fx[k], L_frameTCX ); /* Q31-spectrum_e[k] */
+ v_multc_fixed_16( mdst_spectrum_fx[0][k], extract_l( L_shr( nrgRatio_fx[k], 16 - nrgRatio_e[k] ) ), mdst_spectrum_fx[0][k], L_frameTCX ); /* q_spec */
}
}
}
@@ -352,9 +352,9 @@ void stereo_coder_tcx_fx(
FOR( sfb--; sfb < sfbConf->nBandsStereoCore; sfb++ ) /* start one SFB early for the fade-in */
{
- const Word16 startLine = sfbConf->sfbOffset[sfb];
+ const Word16 startLine = sfbConf->sfbOffset[sfb]; /* Q0 */
move16();
- const Word16 endLine = sfbConf->sfbOffset[sfb + 1];
+ const Word16 endLine = sfbConf->sfbOffset[sfb + 1]; /* Q0 */
move16();
const Word16 sfbWidth = sub( endLine, startLine );
@@ -362,9 +362,9 @@ void stereo_coder_tcx_fx(
move16();
move16();
- nrgRatio_fx[0] = sum2_32_fx( &sts[0]->hTcxEnc->spectrum_fx[k][startLine], sfbWidth, &nrgRatio_e[0] );
+ nrgRatio_fx[0] = sum2_32_fx( &sts[0]->hTcxEnc->spectrum_fx[k][startLine], sfbWidth, &nrgRatio_e[0] ); /* Q31-nrgRatio_e[0] */
move32();
- nrgRatio_fx[1] = sum2_32_fx( &sts[1]->hTcxEnc->spectrum_fx[k][startLine], sfbWidth, &nrgRatio_e[1] );
+ nrgRatio_fx[1] = sum2_32_fx( &sts[1]->hTcxEnc->spectrum_fx[k][startLine], sfbWidth, &nrgRatio_e[1] ); /* Q31-nrgRatio_e[1] */
move32();
test();
@@ -373,29 +373,29 @@ void stereo_coder_tcx_fx(
Word32 tmp_fx;
Word16 tmp_e;
tmp_e = sub( Q31, q_spec );
- tmp_fx = sum2_32_fx( &mdst_spectrum_fx[0][k][startLine], sfbWidth, &tmp_e );
- nrgRatio_fx[0] = BASOP_Util_Add_Mant32Exp( nrgRatio_fx[0], nrgRatio_e[0], tmp_fx, tmp_e, &nrgRatio_e[0] );
+ tmp_fx = sum2_32_fx( &mdst_spectrum_fx[0][k][startLine], sfbWidth, &tmp_e ); /* Q31-tmp_e */
+ nrgRatio_fx[0] = BASOP_Util_Add_Mant32Exp( nrgRatio_fx[0], nrgRatio_e[0], tmp_fx, tmp_e, &nrgRatio_e[0] ); /* Q31-nrgRatio_e[0] */
tmp_e = sub( Q31, q_spec );
- tmp_fx = sum2_32_fx( &mdst_spectrum_fx[1][k][startLine], sfbWidth, &tmp_e );
- nrgRatio_fx[1] = BASOP_Util_Add_Mant32Exp( nrgRatio_fx[1], nrgRatio_e[1], tmp_fx, tmp_e, &nrgRatio_e[1] );
+ tmp_fx = sum2_32_fx( &mdst_spectrum_fx[1][k][startLine], sfbWidth, &tmp_e ); /* Q31-tmp_e */
+ nrgRatio_fx[1] = BASOP_Util_Add_Mant32Exp( nrgRatio_fx[1], nrgRatio_e[1], tmp_fx, tmp_e, &nrgRatio_e[1] ); /* Q31-nrgRatio_e[1] */
}
IF( ( nrgRatio_fx[0] > 0 ) && ( nrgRatio_fx[1] > 0 ) && BASOP_Util_Cmp_Mant32Exp( nrgRatio_fx[0], nrgRatio_e[0], nrgRatio_fx[1], nrgRatio_e[1] ) )
{
Word16 fTemp_e, tmp_e;
- Word32 fTemp_fx = BASOP_Util_Add_Mant32Exp( nrgRatio_fx[0], nrgRatio_e[0], nrgRatio_fx[1], nrgRatio_e[1], &fTemp_e );
+ Word32 fTemp_fx = BASOP_Util_Add_Mant32Exp( nrgRatio_fx[0], nrgRatio_e[0], nrgRatio_fx[1], nrgRatio_e[1], &fTemp_e ); /* Q31-fTemp_e */
fTemp_e = sub( fTemp_e, 1 );
- nrgRatio_fx[0] = BASOP_Util_Divide3232_Scale_cadence( fTemp_fx, nrgRatio_fx[0], &tmp_e );
+ nrgRatio_fx[0] = BASOP_Util_Divide3232_Scale_cadence( fTemp_fx, nrgRatio_fx[0], &tmp_e ); /* Q31 - tmp_e - fTemp_e + nrgRatio_e[0] */
move32();
nrgRatio_e[0] = add( tmp_e, sub( fTemp_e, nrgRatio_e[0] ) );
move16();
- nrgRatio_fx[0] = Sqrt32( nrgRatio_fx[0], &nrgRatio_e[0] );
+ nrgRatio_fx[0] = Sqrt32( nrgRatio_fx[0], &nrgRatio_e[0] ); /* Q31-nrgRatio_e[0] */
move32();
- nrgRatio_fx[1] = BASOP_Util_Divide3232_Scale_cadence( fTemp_fx, nrgRatio_fx[1], &tmp_e );
+ nrgRatio_fx[1] = BASOP_Util_Divide3232_Scale_cadence( fTemp_fx, nrgRatio_fx[1], &tmp_e ); /* Q31 - tmp_e - fTemp_e + nrgRatio_e[1] */
move32();
nrgRatio_e[1] = add( tmp_e, sub( fTemp_e, nrgRatio_e[1] ) );
move16();
- nrgRatio_fx[1] = Sqrt32( nrgRatio_fx[1], &nrgRatio_e[1] );
+ nrgRatio_fx[1] = Sqrt32( nrgRatio_fx[1], &nrgRatio_e[1] ); /* Q31-nrgRatio_e[1] */
move32();
nrgRatio_fx[0] = L_max( ONE_IN_Q27, L_shl_sat( nrgRatio_fx[0], sub( nrgRatio_e[0], 2 ) ) ); // max( 0.25f, min( 4.f, nrgRatio[0] ) );
@@ -409,16 +409,16 @@ void stereo_coder_tcx_fx(
IF( ( LT_16( sfbWidth, 12 ) && LT_16( add( sfb, 1 ), sfbConf->nBandsStereoCore ) ) || GT_32( sts[0]->element_brate, IVAS_48k ) ) /* attenuate ILD alignment in the first SFB or at 64k */
{
- nrgRatio_fx[0] = BASOP_Util_fPow( nrgRatio_fx[0], nrgRatio_e[0], ONE_IN_Q29, 0, &nrgRatio_e[0] );
+ nrgRatio_fx[0] = BASOP_Util_fPow( nrgRatio_fx[0], nrgRatio_e[0], ONE_IN_Q29, 0, &nrgRatio_e[0] ); /* Q31-nrgRatio_e[0] */
move32();
- nrgRatio_fx[1] = BASOP_Util_fPow( nrgRatio_fx[1], nrgRatio_e[1], ONE_IN_Q29, 0, &nrgRatio_e[1] );
+ nrgRatio_fx[1] = BASOP_Util_fPow( nrgRatio_fx[1], nrgRatio_e[1], ONE_IN_Q29, 0, &nrgRatio_e[1] ); /* Q31-nrgRatio_e[1] */
move32();
}
ELSE
{
- nrgRatio_fx[0] = Sqrt32( nrgRatio_fx[0], &nrgRatio_e[0] );
+ nrgRatio_fx[0] = Sqrt32( nrgRatio_fx[0], &nrgRatio_e[0] ); /* Q31-nrgRatio_e[0] */
move32();
- nrgRatio_fx[1] = Sqrt32( nrgRatio_fx[1], &nrgRatio_e[1] );
+ nrgRatio_fx[1] = Sqrt32( nrgRatio_fx[1], &nrgRatio_e[1] ); /* Q31-nrgRatio_e[1] */
move32();
}
@@ -428,15 +428,15 @@ void stereo_coder_tcx_fx(
move32();
- v_multc_fixed( &sts[0]->hTcxEnc->spectrum_fx[k][startLine], nrgRatio_fx[0], &sts[0]->hTcxEnc->spectrum_fx[k][startLine], sfbWidth );
- v_multc_fixed( &mdst_spectrum_fx[0][k][startLine], nrgRatio_fx[0], &mdst_spectrum_fx[0][k][startLine], sfbWidth );
- scale_sig32( &sts[0]->hTcxEnc->spectrum_fx[k][startLine], sfbWidth, Q1 ); // Scaling back to q_spec
- scale_sig32( &mdst_spectrum_fx[0][k][startLine], sfbWidth, Q1 ); // Scaling back to q_spec
+ v_multc_fixed( &sts[0]->hTcxEnc->spectrum_fx[k][startLine], nrgRatio_fx[0], &sts[0]->hTcxEnc->spectrum_fx[k][startLine], sfbWidth ); /* q_spec+30-31 */
+ v_multc_fixed( &mdst_spectrum_fx[0][k][startLine], nrgRatio_fx[0], &mdst_spectrum_fx[0][k][startLine], sfbWidth ); /* q_spec+30-31 */
+ scale_sig32( &sts[0]->hTcxEnc->spectrum_fx[k][startLine], sfbWidth, Q1 ); // Scaling back to q_spec
+ scale_sig32( &mdst_spectrum_fx[0][k][startLine], sfbWidth, Q1 ); // Scaling back to q_spec
- v_multc_fixed( &sts[1]->hTcxEnc->spectrum_fx[k][startLine], nrgRatio_fx[1], &sts[1]->hTcxEnc->spectrum_fx[k][startLine], sfbWidth );
- v_multc_fixed( &mdst_spectrum_fx[1][k][startLine], nrgRatio_fx[1], &mdst_spectrum_fx[1][k][startLine], sfbWidth );
- scale_sig32( &sts[1]->hTcxEnc->spectrum_fx[k][startLine], sfbWidth, Q1 ); // Scaling back to q_spec
- scale_sig32( &mdst_spectrum_fx[1][k][startLine], sfbWidth, Q1 ); // Scaling back to q_spec
+ v_multc_fixed( &sts[1]->hTcxEnc->spectrum_fx[k][startLine], nrgRatio_fx[1], &sts[1]->hTcxEnc->spectrum_fx[k][startLine], sfbWidth ); /* q_spec+30-31 */
+ v_multc_fixed( &mdst_spectrum_fx[1][k][startLine], nrgRatio_fx[1], &mdst_spectrum_fx[1][k][startLine], sfbWidth ); /* q_spec+30-31 */
+ scale_sig32( &sts[1]->hTcxEnc->spectrum_fx[k][startLine], sfbWidth, Q1 ); // Scaling back to q_spec
+ scale_sig32( &mdst_spectrum_fx[1][k][startLine], sfbWidth, Q1 ); // Scaling back to q_spec
}
}
}
@@ -445,30 +445,30 @@ void stereo_coder_tcx_fx(
set16_fx( &ms_mask[k][0], 0, MAX_SFB );
IF( mct_on )
{
- nAvailBitsMS[k] = shl( sts[0]->bits_frame_channel, 1 );
+ nAvailBitsMS[k] = shl( sts[0]->bits_frame_channel, 1 ); /* Q0 */
move16();
}
ELSE
{
- nAvailBitsMS[k] = sts[0]->bits_frame_nominal;
+ nAvailBitsMS[k] = sts[0]->bits_frame_nominal; /* Q0 */
move16();
}
- nAvailBitsMS[k] = sub( nAvailBitsMS[k], add( sts[0]->side_bits_frame_channel, sts[1]->side_bits_frame_channel ) );
+ nAvailBitsMS[k] = sub( nAvailBitsMS[k], add( sts[0]->side_bits_frame_channel, sts[1]->side_bits_frame_channel ) ); /* Q0 */
move16();
IF( EQ_16( nSubframes, 2 ) )
{
- nAvailBitsMS[k] = sub( nAvailBitsMS[k], OFFSET_BITS_TCX10 );
+ nAvailBitsMS[k] = sub( nAvailBitsMS[k], OFFSET_BITS_TCX10 ); /* Q0 */
move16();
}
ELSE
{
- nAvailBitsMS[k] = sub( nAvailBitsMS[k], OFFSET_BITS_TCX20 );
+ nAvailBitsMS[k] = sub( nAvailBitsMS[k], OFFSET_BITS_TCX20 ); /* Q0 */
move16();
}
- nAvailBitsMS[k] = idiv1616( nAvailBitsMS[k], nSubframes );
+ nAvailBitsMS[k] = idiv1616( nAvailBitsMS[k], nSubframes ); /* Q0 */
move16();
MsStereoDecision_fx( sfbConf, sts[0]->hTcxEnc->spectrum_fx[k], sts[1]->hTcxEnc->spectrum_fx[k], inv_spectrum_fx[0][k], inv_spectrum_fx[1][k], q_spec, &hStereoMdct->mdct_stereo_mode[k], &ms_mask[k][0], nAvailBitsMS[k] );
@@ -512,21 +512,21 @@ void stereo_coder_tcx_fx(
FOR( k = 0; k < nSubframes; k++ )
{
sfbConf = EQ_16( sts[0]->core, TCX_20_CORE ) ? &hStereoMdct->stbParamsTCX20 : &hStereoMdct->stbParamsTCX10;
- ms_bands[k] = sum_s( ms_mask[k], sfbConf->nBandsStereoCore );
+ ms_bands[k] = sum_s( ms_mask[k], sfbConf->nBandsStereoCore ); /* Q0 */
move16();
- sw_uncorr[k] = sub( 32767, div_s( ms_bands[k], sfbConf->nBandsStereoCore ) );
+ sw_uncorr[k] = sub( 32767 /*Q15*/, div_s( ms_bands[k], sfbConf->nBandsStereoCore ) ); /* Q15 */
move16();
}
IF( EQ_16( sts[0]->core, TCX_20_CORE ) )
{
- sw_uncorr_mean = sw_uncorr[0];
+ sw_uncorr_mean = sw_uncorr[0]; /* Q15 */
move16();
}
ELSE
{
- sw_uncorr_mean = add( shr( sw_uncorr[0], 1 ), shr( sw_uncorr[1], 1 ) );
+ sw_uncorr_mean = add( shr( sw_uncorr[0], 1 ), shr( sw_uncorr[1], 1 ) ); /* Q15 */
}
- hStereoMdct->sw_uncorr = extract_l( GT_16( sw_uncorr_mean, 19661 ) );
+ hStereoMdct->sw_uncorr = extract_l( GT_16( sw_uncorr_mean, 19661 /*0.6 in Q15*/ ) );
move16();
}
@@ -543,13 +543,13 @@ void stereo_coder_tcx_fx(
void ms_processing_fx(
STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: Stereo MDCT encoder structure */
Encoder_State **sts, /* i/o: Encoder state structure */
- Word16 ms_mask[NB_DIV][MAX_SFB], /* i : bandwise MS mask */
- const int16_t iSubframe, /* i : subframe number */
+ Word16 ms_mask[NB_DIV][MAX_SFB], /* i : bandwise MS mask Q0*/
+ const Word16 iSubframe, /* i : subframe number Q0*/
Word32 x_0_fx[],
/* i/o: spectrum 1 */ // Q( q_x )
Word32 x_1_fx[],
/* i/o: spectrum 1 */ // Q( q_x )
- Word16 maxSfb /* i : number of stereo frequency bands*/
+ Word16 maxSfb /* i : number of stereo frequency bands Q0*/
)
{
Word16 sfb;
@@ -565,7 +565,7 @@ void ms_processing_fx(
if ( EQ_16( maxSfb, -1 ) )
{
- maxSfb = sfbConf->sfbCnt;
+ maxSfb = sfbConf->sfbCnt; /* Q0 */
move16();
}
@@ -589,8 +589,8 @@ void ms_processing_fx(
void ms_inv_mask_processing_fx(
STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: Stereo MDCT encoder structure */
Encoder_State **sts, /* i/o: Encoder state structure */
- Word16 ms_mask[NB_DIV][MAX_SFB], /* i : bandwise MS mask */
- const Word16 iSubframe, /* i : subframe number */
+ Word16 ms_mask[NB_DIV][MAX_SFB], /* i : bandwise MS mask Q0*/
+ const Word16 iSubframe, /* i : subframe number Q0*/
const Word32 x_0_fx[],
/* i : spectrum 1 */ // Q( q_x )
const Word32 x_1_fx[],
@@ -599,7 +599,7 @@ void ms_inv_mask_processing_fx(
/* o : inverse spectrum 1 */ // Q( q_x )
Word32 x_inv_1_fx[],
/* o : inverse spectrum 2 */ // Q( q_x )
- Word16 maxSfb /* i : number of stereo frequency bands*/
+ Word16 maxSfb /* i : number of stereo frequency bands Q0*/
)
{
Word16 sfb;
@@ -607,7 +607,7 @@ void ms_inv_mask_processing_fx(
Word16 nSubframes, L_subframeTCX;
nSubframes = ( sts[0]->hTcxEnc->tcxMode == TCX_20 ) ? 1 : NB_DIV;
- L_subframeTCX = idiv1616( sts[0]->hTcxEnc->L_frameTCX, nSubframes );
+ L_subframeTCX = idiv1616( sts[0]->hTcxEnc->L_frameTCX, nSubframes ); /* Q0 */
sfbConf = ( sts[0]->core == TCX_20_CORE ) ? &hStereoMdct->stbParamsTCX20 : &hStereoMdct->stbParamsTCX10;
IF( EQ_16( sts[0]->last_core, ACELP_CORE ) )
@@ -618,14 +618,14 @@ void ms_inv_mask_processing_fx(
IF( EQ_16( maxSfb, -1 ) )
{
- maxSfb = sfbConf->sfbCnt;
+ maxSfb = sfbConf->sfbCnt; /* Q0 */
move16();
}
FOR( sfb = 0; sfb < maxSfb; sfb++ )
{
- Copy32( &x_0_fx[sfbConf->sfbOffset[sfb]], &x_inv_0_fx[sfbConf->sfbOffset[sfb]], sfbConf->sfbOffset[sfb + 1] - sfbConf->sfbOffset[sfb] );
- Copy32( &x_1_fx[sfbConf->sfbOffset[sfb]], &x_inv_1_fx[sfbConf->sfbOffset[sfb]], sfbConf->sfbOffset[sfb + 1] - sfbConf->sfbOffset[sfb] );
+ Copy32( &x_0_fx[sfbConf->sfbOffset[sfb]], &x_inv_0_fx[sfbConf->sfbOffset[sfb]], sfbConf->sfbOffset[sfb + 1] - sfbConf->sfbOffset[sfb] ); /* q_x */
+ Copy32( &x_1_fx[sfbConf->sfbOffset[sfb]], &x_inv_1_fx[sfbConf->sfbOffset[sfb]], sfbConf->sfbOffset[sfb + 1] - sfbConf->sfbOffset[sfb] ); /* q_x */
IF( EQ_16( ms_mask[iSubframe][sfb], 0 ) )
{
@@ -650,12 +650,12 @@ void ms_inv_mask_processing_fx(
*
*-------------------------------------------------------------------*/
-Word16 write_stereo_to_bitstream(
- STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: Stereo MDCT encoder structure */
- Encoder_State **sts, /* i/o: Encoder state structure */
- Word16 ms_mask[NB_DIV][MAX_SFB], /* i : bandwise MS mask */
- const Word16 mct_on, /* i : flag mct block (1) or stereo (0)*/
- BSTR_ENC_HANDLE hBstr /* i/o: bitstream handle */
+Word16 write_stereo_to_bitstream_fx(
+ STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: Stereo MDCT encoder structure */
+ Encoder_State **sts, /* i/o: Encoder state structure */
+ Word16 ms_mask[NB_DIV][MAX_SFB], /* i : bandwise MS mask Q0*/
+ const Word16 mct_on, /* i : flag mct block (1) or stereo (0) Q0*/
+ BSTR_ENC_HANDLE hBstr /* i/o: bitstream handle */
)
{
Word16 i, k, nSubframes;
@@ -787,8 +787,8 @@ Word16 write_stereo_to_bitstream(
*-------------------------------------------------------------------*/
static void convertToBwMS_fx(
- const Word16 startLine, /* i : start line of sfb */
- const Word16 stopLine, /* i : stop line of sfb */
+ const Word16 startLine, /* i : start line of sfb Q0*/
+ const Word16 stopLine, /* i : stop line of sfb Q0*/
Word32 x0[],
/* i/o: mid/left channel coefficients */ /* Q_x */
Word32 x1[],
@@ -801,11 +801,11 @@ static void convertToBwMS_fx(
FOR( j = startLine; j < stopLine; j++ )
{
- tmpValue_fx = x0[j];
+ tmpValue_fx = x0[j]; /*Q_x*/
move32();
- x0[j] = Mpy_32_32( L_add( x0[j], x1[j] ), norm_fac );
+ x0[j] = Mpy_32_32( L_add( x0[j], x1[j] ), norm_fac ); /* Q_x */
move32();
- x1[j] = Mpy_32_32( L_sub( tmpValue_fx, x1[j] ), norm_fac );
+ x1[j] = Mpy_32_32( L_sub( tmpValue_fx, x1[j] ), norm_fac ); /* Q_x */
move32();
}
@@ -819,12 +819,10 @@ static void convertToBwMS_fx(
*-------------------------------------------------------------------*/
void convertToMS_fx(
- const Word16 L_frame, /* i : frame length */
- Word32 x0[],
- /* i/o: mid/left channel coefficients */ // Q(q_x)
- Word32 x1[],
- /* i/o: side/right channel coefficients */ // Q(q_x)
- const Word32 norm_fac /* i : normalization factor */ // Q31
+ const Word16 L_frame, /* i : frame length Q0*/
+ Word32 x0[], /* i/o: mid/left channel coefficients Q(q_x)*/
+ Word32 x1[], /* i/o: side/right channel coefficients Q(q_x)*/
+ const Word32 norm_fac /* i : normalization factor Q31*/
)
{
convertToBwMS_fx( 0, L_frame, x0, x1, norm_fac );
@@ -840,14 +838,12 @@ void convertToMS_fx(
/*! r: SQ gain */
static Word32 SQ_gain_estimate_stereo_fx( // e_res
- Word32 xL_fx[],
- /* i : L vector to quantize */ // e_xL
+ Word32 xL_fx[], /* i : L vector to quantize Q31-e_xL*/
Word16 e_xL,
- Word32 xR_fx[],
- /* i : R vector to quantize */ // e_xR
+ Word32 xR_fx[], /* i : R vector to quantize Q31-e_xR*/
Word16 e_xR,
- const Word16 nbitsSQ, /* i : number of bits targeted */
- const Word16 lg, /* i : vector size (2048 max) */
+ const Word16 nbitsSQ, /* i : number of bits targeted Q0*/
+ const Word16 lg, /* i : vector size (2048 max) Q0*/
Word16 *e_res )
{
Word16 i, q, iter, e_ener, e_tmp;
@@ -855,24 +851,24 @@ static Word32 SQ_gain_estimate_stereo_fx( // e_res
Word32 en_fx[N_MAX / 2]; // Q(26)
Word16 lg2, lg_4, lg2_4;
- lg_4 = shr( lg, 2 );
- lg2_4 = shl( lg_4, 1 );
- lg2 = shl( lg2_4, 2 );
+ lg_4 = shr( lg, 2 ); /* Q0 */
+ lg2_4 = shl( lg_4, 1 ); /* Q0 */
+ lg2 = shl( lg2_4, 2 ); /* Q0 */
i = 0;
move16();
- set32_fx( en_fx, 21474836 /* 0.01 in Q31 */, N_MAX / 2 );
+ set32_fx( en_fx, 21474836 /* 0.01 in Q31 */, idiv1616( N_MAX, 2 ) );
/* energy of quadruples with 9dB offset */
/* ignore that we may take no all lines into account, max. 3 lines at the upper end of the spectrum can be missed (if lg is not a multiple of 4, happens also in SQGain()*/
FOR( q = 0; q < lg_4; q++ )
{
- ener_fx = BASOP_Util_Add_Mant32Exp( 21474836, 0, Mpy_32_32( xL_fx[i], xL_fx[i] ), e_xL * 2, &e_ener );
- ener_fx = BASOP_Util_Add_Mant32Exp( ener_fx, e_ener, Mpy_32_32( xL_fx[i + 1], xL_fx[i + 1] ), e_xL * 2, &e_ener );
- ener_fx = BASOP_Util_Add_Mant32Exp( ener_fx, e_ener, Mpy_32_32( xL_fx[i + 2], xL_fx[i + 2] ), e_xL * 2, &e_ener );
- ener_fx = BASOP_Util_Add_Mant32Exp( ener_fx, e_ener, Mpy_32_32( xL_fx[i + 3], xL_fx[i + 3] ), e_xL * 2, &e_ener );
- en_fx[q] = BASOP_Util_Log2( ener_fx ); /* saves a MAC */
+ ener_fx = BASOP_Util_Add_Mant32Exp( 21474836 /*0.01 in Q15*/, 0, Mpy_32_32( xL_fx[i], xL_fx[i] ), e_xL * 2, &e_ener ); /* Q31-e_ener */
+ ener_fx = BASOP_Util_Add_Mant32Exp( ener_fx, e_ener, Mpy_32_32( xL_fx[i + 1], xL_fx[i + 1] ), e_xL * 2, &e_ener ); /* Q31-e_ener */
+ ener_fx = BASOP_Util_Add_Mant32Exp( ener_fx, e_ener, Mpy_32_32( xL_fx[i + 2], xL_fx[i + 2] ), e_xL * 2, &e_ener ); /* Q31-e_ener */
+ ener_fx = BASOP_Util_Add_Mant32Exp( ener_fx, e_ener, Mpy_32_32( xL_fx[i + 3], xL_fx[i + 3] ), e_xL * 2, &e_ener ); /* Q31-e_ener */
+ en_fx[q] = BASOP_Util_Log2( ener_fx ); /* saves a MAC */
move32();
en_fx[q] = Mpy_32_16_1( L_add( e_ener * ONE_IN_Q25, en_fx[q] ), 9864 /* log10(2) in Q15 */ ); // Q(25)
move32();
@@ -881,11 +877,11 @@ static Word32 SQ_gain_estimate_stereo_fx( // e_res
i = 0;
FOR( ; q < lg2_4; q++ )
{
- ener_fx = BASOP_Util_Add_Mant32Exp( 21474836, 0, Mpy_32_32( xR_fx[i], xR_fx[i] ), e_xR * 2, &e_ener );
- ener_fx = BASOP_Util_Add_Mant32Exp( ener_fx, e_ener, Mpy_32_32( xR_fx[i + 1], xR_fx[i + 1] ), e_xR * 2, &e_ener );
- ener_fx = BASOP_Util_Add_Mant32Exp( ener_fx, e_ener, Mpy_32_32( xR_fx[i + 2], xR_fx[i + 2] ), e_xR * 2, &e_ener );
- ener_fx = BASOP_Util_Add_Mant32Exp( ener_fx, e_ener, Mpy_32_32( xR_fx[i + 3], xR_fx[i + 3] ), e_xR * 2, &e_ener );
- en_fx[q] = BASOP_Util_Log2( ener_fx ); /* saves a MAC */
+ ener_fx = BASOP_Util_Add_Mant32Exp( 21474836 /*0.01 Q15*/, 0, Mpy_32_32( xR_fx[i], xR_fx[i] ), e_xR * 2, &e_ener ); /* Q31-e_ener */
+ ener_fx = BASOP_Util_Add_Mant32Exp( ener_fx, e_ener, Mpy_32_32( xR_fx[i + 1], xR_fx[i + 1] ), e_xR * 2, &e_ener ); /* Q31-e_ener */
+ ener_fx = BASOP_Util_Add_Mant32Exp( ener_fx, e_ener, Mpy_32_32( xR_fx[i + 2], xR_fx[i + 2] ), e_xR * 2, &e_ener ); /* Q31-e_ener */
+ ener_fx = BASOP_Util_Add_Mant32Exp( ener_fx, e_ener, Mpy_32_32( xR_fx[i + 3], xR_fx[i + 3] ), e_xR * 2, &e_ener ); /* Q31-e_ener */
+ en_fx[q] = BASOP_Util_Log2( ener_fx ); /* saves a MAC */
move32();
en_fx[q] = Mpy_32_16_1( L_add( e_ener * ONE_IN_Q25, en_fx[q] ), 9864 /* log10(2) in Q15 */ ); // Q(25)
move32();
@@ -896,14 +892,14 @@ static Word32 SQ_gain_estimate_stereo_fx( // e_res
target_fx = L_mult( 19660 /* 0.15 in Q17 */, sub( nbitsSQ, shr( lg2, 4 ) ) ); // Q(18)
fac_fx = 429496729; /* 12.8 in Q25 */
move32();
- offset_fx = fac_fx;
+ offset_fx = fac_fx; /* Q25 */
move32();
/* find offset (0 to 128 dB with step of 0.125dB) */
FOR( iter = 0; iter < 10; iter++ )
{
- fac_fx = L_shr( fac_fx, 1 );
- offset_fx = L_sub( offset_fx, fac_fx );
+ fac_fx = L_shr( fac_fx, 1 ); /* Q25 */
+ offset_fx = L_sub( offset_fx, fac_fx ); /* Q25 */
ener_fx = 0;
move32();
e_ener = 0;
@@ -911,19 +907,19 @@ static Word32 SQ_gain_estimate_stereo_fx( // e_res
FOR( i = 0; i < lg2_4; i++ )
{
- tmp_32 = L_sub( en_fx[i], offset_fx );
+ tmp_32 = L_sub( en_fx[i], offset_fx ); /* Q25 */
e_tmp = 6;
move16();
/* avoid SV with 1 bin of amp < 0.5f */
- IF( GT_32( tmp_32, 10066329 ) )
+ IF( GT_32( tmp_32, 10066329 /*0.3 Q25*/ ) )
{
- ener_fx = BASOP_Util_Add_Mant32Exp( ener_fx, e_ener, tmp_32, e_tmp, &e_ener );
+ ener_fx = BASOP_Util_Add_Mant32Exp( ener_fx, e_ener, tmp_32, e_tmp, &e_ener ); /* Q31-e_ener */
/* if ener is above target -> break and increase offset */
IF( L_shl_sat( ener_fx, sub( e_ener, Q13 ) ) > target_fx )
{
- offset_fx = L_add( offset_fx, fac_fx );
+ offset_fx = L_add( offset_fx, fac_fx ); /* Q25 */
BREAK;
}
}
@@ -933,7 +929,7 @@ static Word32 SQ_gain_estimate_stereo_fx( // e_res
/* return gain */
tmp_32 = L_add( 12539858, Mpy_32_16_1( offset_fx, 13606 ) ); // Q23
- return BASOP_util_Pow2( tmp_32, Q8, e_res );
+ return BASOP_util_Pow2( tmp_32, Q8, e_res ); /* Q31-e_res */
}
/*-------------------------------------------------------------------*
@@ -943,23 +939,23 @@ static Word32 SQ_gain_estimate_stereo_fx( // e_res
*-------------------------------------------------------------------*/
static Word16 QuantSpecEstimateBits_fx(
- Word32 *spec_fx,
+ Word32 *spec_fx, /* Q15-spec_e */
Word16 spec_e,
- Word16 G_fx,
+ Word16 G_fx, /* Q15-G_e */
Word16 G_e,
- const Word16 length,
- const Word16 nBitsAvailable,
- Word16 sqQ[] )
+ const Word16 length, /* Q0 */
+ const Word16 nBitsAvailable, /* Q0 */
+ Word16 sqQ[] /* Q0 */ )
{
Word16 stop, sqBits, nEncoded;
Word16 lastnz;
- tcx_scalar_quantization_ivas_fx( spec_fx, spec_e, sqQ, length, G_fx, G_e, 16384, NULL, 1 );
+ tcx_scalar_quantization_ivas_fx( spec_fx, spec_e, sqQ, length, G_fx, G_e, 16384 /*Q15*/, NULL, 1 );
stop = 0;
move16();
- sqBits = RCcontextMapping_encode2_estimate_no_mem_s17_LCS( sqQ, length, &lastnz, &nEncoded, nBitsAvailable, &stop, 0, NULL );
+ sqBits = RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( sqQ, length, &lastnz, &nEncoded, nBitsAvailable, &stop, 0, NULL ); /*Q0*/
if ( stop != 0 )
{
@@ -976,15 +972,15 @@ static Word16 QuantSpecEstimateBits_fx(
*
*-------------------------------------------------------------------*/
-static void context_update(
+static void context_update_fx(
HANDLE_RC_CONTEXT_MEM ctxSrc,
HANDLE_RC_CONTEXT_MEM ctxTarget,
- const Word16 endLine )
+ const Word16 endLine /*Q0*/ )
{
Word16 last_nz;
/* check if last_nz of target is smaller than endLine, save and update */
- last_nz = s_max( ctxTarget->lastnz, endLine );
+ last_nz = s_max( ctxTarget->lastnz, endLine ); /* Q0 */
mvc2c( (UWord8 *) ctxSrc, (UWord8 *) ctxTarget, sizeof( RC_CONTEXT_MEM ) );
ctxTarget->lastnz = last_nz;
@@ -1003,7 +999,7 @@ static Word16 GetChannelEnergyRatio_fx( // Q15
Encoder_State **sts, /* i/o: Encoder state structure */
const Word16 iFirstSubframe,
const Word16 iLastSubframe,
- const UWord8 ratioInRmsDomain )
+ const UWord8 ratioInRmsDomain /* Q0 */ )
{
Word16 ch, n, i;
Word32 nrg_fx[2];
@@ -1023,11 +1019,11 @@ static Word16 GetChannelEnergyRatio_fx( // Q15
move16();
}
- Word16 L_subframeTCX = shr( st->hTcxEnc->L_frameTCX, sub( nSubframes, 1 ) );
+ Word16 L_subframeTCX = shr( st->hTcxEnc->L_frameTCX, sub( nSubframes, 1 ) ); /* Q0 */
if ( st->last_core == ACELP_CORE )
{
- L_subframeTCX = add( L_subframeTCX, shr( L_subframeTCX, 2 ) );
+ L_subframeTCX = add( L_subframeTCX, shr( L_subframeTCX, 2 ) ); /* Q0 */
}
assert( iFirstSubframe >= 0 && ( iFirstSubframe <= iLastSubframe ) );
@@ -1040,28 +1036,28 @@ static Word16 GetChannelEnergyRatio_fx( // Q15
{
FOR( i = 0; i < L_subframeTCX; i++ )
{
- nrg_fx[ch] = BASOP_Util_Add_Mant32Exp( nrg_fx[ch], nrg_e[ch], Mpy_32_32( st->hTcxEnc->spectrum_fx[n][i], st->hTcxEnc->spectrum_fx[n][i] ), shl( st->hTcxEnc->spectrum_e[n], 1 ), &nrg_e[ch] );
+ nrg_fx[ch] = BASOP_Util_Add_Mant32Exp( nrg_fx[ch], nrg_e[ch], Mpy_32_32( st->hTcxEnc->spectrum_fx[n][i], st->hTcxEnc->spectrum_fx[n][i] ), shl( st->hTcxEnc->spectrum_e[n], 1 ), &nrg_e[ch] ); /* Q31-nrg_e */
move32();
}
}
IF( ratioInRmsDomain && nrg_fx[ch] )
{
- nrg_fx[ch] = Sqrt32( nrg_fx[ch], &nrg_e[ch] );
+ nrg_fx[ch] = Sqrt32( nrg_fx[ch], &nrg_e[ch] ); /* Q31-nrg_e */
move32();
}
}
IF( L_add_sat( nrg_fx[0], nrg_fx[1] ) )
{
- nrg_fx[1] = BASOP_Util_Add_Mant32Exp( nrg_fx[0], nrg_e[0], nrg_fx[1], nrg_e[1], &nrg_e[1] );
+ nrg_fx[1] = BASOP_Util_Add_Mant32Exp( nrg_fx[0], nrg_e[0], nrg_fx[1], nrg_e[1], &nrg_e[1] ); /* Q31-nrg_e[1] */
move32();
IF( NE_16( nrg_e[1], nrg_e[0] ) )
{
- nrg_fx[0] = L_shr( nrg_fx[0], sub( nrg_e[1], nrg_e[0] ) );
+ nrg_fx[0] = L_shr( nrg_fx[0], sub( nrg_e[1], nrg_e[0] ) ); /* Q31-nrg_e[1] */
move32();
}
- return divide3232( nrg_fx[0], nrg_fx[1] );
+ return divide3232( nrg_fx[0], nrg_fx[1] ); /* Q15 */
}
return MIN_16;
@@ -1090,21 +1086,21 @@ void FindSplitRatio_fx(
IF( ratio_fx >= 0 )
{
- hCPE->hStereoMdct->split_ratio = round_fx( L_mult( SMDCT_BITRATE_RATIO_RANGE, ratio_fx ) );
+ hCPE->hStereoMdct->split_ratio = round_fx( L_mult( SMDCT_BITRATE_RATIO_RANGE, ratio_fx ) ); /* Q0 */
move16();
/* Tuning to get closer to the optimal split ratio */
IF( LT_32( L_mult0( 9, ratio_fx ), 8 * ONE_IN_Q15 ) && GT_16( hCPE->hStereoMdct->split_ratio, SMDCT_EQUAL_RATIO_RANGE + ( SMDCT_BITRATE_RATIO_RANGE >> 4 ) ) )
{
- hCPE->hStereoMdct->split_ratio = sub( hCPE->hStereoMdct->split_ratio, SMDCT_BITRATE_RATIO_RANGE >> 3 );
+ hCPE->hStereoMdct->split_ratio = sub( hCPE->hStereoMdct->split_ratio, SMDCT_BITRATE_RATIO_RANGE >> 3 ); /* Q0 */
move16();
}
IF( GT_32( L_mult0( 9, ratio_fx ), 1 * ONE_IN_Q15 ) && LT_16( hCPE->hStereoMdct->split_ratio, SMDCT_EQUAL_RATIO_RANGE - ( SMDCT_BITRATE_RATIO_RANGE >> 4 ) ) )
{
- hCPE->hStereoMdct->split_ratio = add( hCPE->hStereoMdct->split_ratio, SMDCT_BITRATE_RATIO_RANGE >> 3 );
+ hCPE->hStereoMdct->split_ratio = add( hCPE->hStereoMdct->split_ratio, SMDCT_BITRATE_RATIO_RANGE >> 3 ); /* Q0 */
move16();
}
- hCPE->hStereoMdct->split_ratio = s_min( SMDCT_BITRATE_RATIO_RANGE - 1, s_max( 1, hCPE->hStereoMdct->split_ratio ) );
+ hCPE->hStereoMdct->split_ratio = s_min( SMDCT_BITRATE_RATIO_RANGE - 1, s_max( 1, hCPE->hStereoMdct->split_ratio ) ); /* Q0 */
move16();
}
@@ -1126,11 +1122,11 @@ static void MsStereoDecision_fx(
Word32 *specS_fx,
/* scratch buffer for M, use buffer for inverse MS mask spectrum */ /* Q( q_spec ) */
Word16 q_spec,
- Word16 *mdct_stereo_mode, /* output */
- Word16 *msMask, /* output */
- const Word16 nBitsAvailable )
+ Word16 *mdct_stereo_mode, /* output Q0*/
+ Word16 *msMask, /* output Q0*/
+ const Word16 nBitsAvailable /*Q0*/ )
{
- Word16 length = sfbParam->sfbOffset[sfbParam->nBandsStereoCore];
+ Word16 length = sfbParam->sfbOffset[sfbParam->nBandsStereoCore]; /* Q0 */
Word16 bitsL, bitsR, bitsM, bitsS;
Word16 bitsBW, bitsLR, bitsMS;
@@ -1163,7 +1159,7 @@ static void MsStereoDecision_fx(
specM_e = sub( Q31, q_spec );
specS_e = sub( Q31, q_spec );
- GLR_fx = SQ_gain_estimate_stereo_fx( specL_fx, specL_e, specR_fx, specR_e, nBitsAvailable, length, &e_GLR );
+ GLR_fx = SQ_gain_estimate_stereo_fx( specL_fx, specL_e, specR_fx, specR_e, nBitsAvailable, length, &e_GLR ); /* Q31-e_GLR */
FOR( i = 0; i < length; i++ )
{
@@ -1173,12 +1169,12 @@ static void MsStereoDecision_fx(
move32();
}
- G_fx = extract_h( GLR_fx ); /* seems to be favourable to underestimate a bit */
+ G_fx = extract_h( GLR_fx ); /* seems to be favourable to underestimate a bit Q15-e_GLR*/
G_e = sub( e_GLR, 1 );
/* do the full spectrum estimates already here, as side effect we get the quantized spectra... */
- bitsLR = add( QuantSpecEstimateBits_fx( specL_fx, specL_e, G_fx, G_e, length, nBitsAvailable, quantSpecL ), QuantSpecEstimateBits_fx( specR_fx, specR_e, G_fx, G_e, length, nBitsAvailable, quantSpecR ) );
- bitsMS = add( QuantSpecEstimateBits_fx( specM_fx, specM_e, G_fx, G_e, length, nBitsAvailable, quantSpecM ), QuantSpecEstimateBits_fx( specS_fx, specS_e, G_fx, G_e, length, nBitsAvailable, quantSpecS ) );
+ bitsLR = add( QuantSpecEstimateBits_fx( specL_fx, specL_e, G_fx, G_e, length, nBitsAvailable, quantSpecL ), QuantSpecEstimateBits_fx( specR_fx, specR_e, G_fx, G_e, length, nBitsAvailable, quantSpecR ) ); /* Q0 */
+ bitsMS = add( QuantSpecEstimateBits_fx( specM_fx, specM_e, G_fx, G_e, length, nBitsAvailable, quantSpecM ), QuantSpecEstimateBits_fx( specS_fx, specS_e, G_fx, G_e, length, nBitsAvailable, quantSpecS ) ); /* Q0 */
/* clean-up MS scratch buffers */
set32_fx( specM_fx, 0, length );
@@ -1189,11 +1185,11 @@ static void MsStereoDecision_fx(
bitsBW = 0;
move16();
- RCcontextMapping_encode2_estimate_bandWise_start( quantSpecL, length, nBitsAvailable, ctxL );
- RCcontextMapping_encode2_estimate_bandWise_start( quantSpecR, length, nBitsAvailable, ctxR );
+ RCcontextMapping_encode2_estimate_bandWise_start_fx( quantSpecL, length, nBitsAvailable, ctxL );
+ RCcontextMapping_encode2_estimate_bandWise_start_fx( quantSpecR, length, nBitsAvailable, ctxR );
- bitsBW = add( bitsBW, RCcontextMapping_encode2_estimate_bandWise_start( quantSpecM, length, nBitsAvailable, ctxM ) );
- bitsBW = add( bitsBW, RCcontextMapping_encode2_estimate_bandWise_start( quantSpecS, length, nBitsAvailable, ctxS ) );
+ bitsBW = add( bitsBW, RCcontextMapping_encode2_estimate_bandWise_start_fx( quantSpecM, length, nBitsAvailable, ctxM ) ); /* Q0 */
+ bitsBW = add( bitsBW, RCcontextMapping_encode2_estimate_bandWise_start_fx( quantSpecS, length, nBitsAvailable, ctxS ) ); /* Q0 */
/*find_max_lastnz(ctxL,ctxR,ctxM,ctxS);*/
@@ -1204,32 +1200,32 @@ static void MsStereoDecision_fx(
const Word16 endline = sfbParam->sfbOffset[sfb + 1];
move16();
- bitsL = RCcontextMapping_encode2_estimate_bandWise( quantSpecL, startline, endline, ctxL );
- bitsR = RCcontextMapping_encode2_estimate_bandWise( quantSpecR, startline, endline, ctxR );
- bitsM = RCcontextMapping_encode2_estimate_bandWise( quantSpecM, startline, endline, ctxM );
- bitsS = RCcontextMapping_encode2_estimate_bandWise( quantSpecS, startline, endline, ctxS );
+ bitsL = RCcontextMapping_encode2_estimate_bandWise_fx( quantSpecL, startline, endline, ctxL );
+ bitsR = RCcontextMapping_encode2_estimate_bandWise_fx( quantSpecR, startline, endline, ctxR );
+ bitsM = RCcontextMapping_encode2_estimate_bandWise_fx( quantSpecM, startline, endline, ctxM );
+ bitsS = RCcontextMapping_encode2_estimate_bandWise_fx( quantSpecS, startline, endline, ctxS );
IF( LE_16( add( bitsM, bitsS ), add( bitsL, bitsR ) ) )
{
msMask[sfb] = 1;
move16();
nMSOn = add( nMSOn, 1 );
- context_update( ctxM, ctxL, endline );
- context_update( ctxS, ctxR, endline );
- bitsBW = add( bitsBW, add( bitsM, bitsS ) );
+ context_update_fx( ctxM, ctxL, endline );
+ context_update_fx( ctxS, ctxR, endline );
+ bitsBW = add( bitsBW, add( bitsM, bitsS ) ); /* Q0 */
}
ELSE
{
msMask[sfb] = 0;
move16();
- context_update( ctxL, ctxM, endline );
- context_update( ctxR, ctxS, endline );
- bitsBW = add( bitsBW, add( bitsL, bitsR ) );
+ context_update_fx( ctxL, ctxM, endline );
+ context_update_fx( ctxR, ctxS, endline );
+ bitsBW = add( bitsBW, add( bitsL, bitsR ) ); /* Q0 */
}
}
- bitsBW = add( bitsBW, sfbParam->nBandsStereoCore ); /* Signaling bits */
+ bitsBW = add( bitsBW, sfbParam->nBandsStereoCore ); /* Signaling bits Q0*/
IF( LT_16( bitsLR, bitsBW ) )
{
@@ -1273,17 +1269,17 @@ static void MsStereoDecision_fx(
void initMdctStereoEncData_fx(
STEREO_MDCT_ENC_DATA *hStereoMdct, /* i/o: mdct stereo parameters structure */
const IVAS_FORMAT ivas_format, /* i : IVAS format */
- const Word16 element_mode, /* i : element mode */
- const Word32 element_brate, /* i : element bitrate */
- const Word16 bwidth, /* i : bandwidth */
- const Word16 igf, /* i : flag indicating IGF activity */
+ const Word16 element_mode, /* i : element mode Q0*/
+ const Word32 element_brate, /* i : element bitrate Q0*/
+ const Word16 bwidth, /* i : bandwidth Q0*/
+ const Word16 igf, /* i : flag indicating IGF activity Q0*/
const H_IGF_GRID hIgfGrid, /* i : IGF grid setup */
- const Word16 mem_init /* i : initialize memory after malloc */
+ const Word16 mem_init /* i : initialize memory after malloc Q0*/
)
{
Word16 tcx_coded_lines;
- tcx_coded_lines = getNumTcxCodedLines( bwidth );
+ tcx_coded_lines = getNumTcxCodedLines( bwidth ); /* Q0 */
/*initialize mdct stereo mode*/
set16_fx( hStereoMdct->mdct_stereo_mode, -1, 2 );
@@ -1301,7 +1297,7 @@ void initMdctStereoEncData_fx(
set16_fx( hStereoMdct->IGFStereoMode, -1, 2 );
- hStereoMdct->split_ratio = SMDCT_EQUAL_RATIO_RANGE;
+ hStereoMdct->split_ratio = SMDCT_EQUAL_RATIO_RANGE; /* Q0 */
move16();
set16_fx( hStereoMdct->global_ild, SMDCT_ILD_RANGE >> 1, 2 );
@@ -1340,9 +1336,11 @@ void initMdctStereoEncData_fx(
ivas_error initMdctItdHandling_fx(
STEREO_MDCT_ENC_DATA *hStereoMdct, /* i/o: mdct stereo parameters structure */
- const Word32 input_Fs /* i : input sampling rate */
+ const Word32 input_Fs /* i : input sampling rate Q0*/
)
{
+ test();
+ test();
IF( hStereoMdct->hItd == NULL )
{
IF( ( hStereoMdct->hItd = (ITD_DATA_HANDLE) malloc( sizeof( ITD_DATA ) ) ) == NULL )
@@ -1351,6 +1349,8 @@ ivas_error initMdctItdHandling_fx(
}
}
+ test();
+ test();
IF( hStereoMdct->hDft_ana == NULL )
{
IF( ( hStereoMdct->hDft_ana = (DFT_ANA_HANDLE) malloc( sizeof( DFT_ANA ) ) ) == NULL )
diff --git a/lib_enc/ivas_stereo_switching_enc.c b/lib_enc/ivas_stereo_switching_enc.c
index ba84be1a2000f4ada3bb3b6fc5e901d993dae781..a1e5592e530ba3eb58a1308473ff2151c020dbf8 100644
--- a/lib_enc/ivas_stereo_switching_enc.c
+++ b/lib_enc/ivas_stereo_switching_enc.c
@@ -54,7 +54,7 @@ static ivas_error allocate_CoreCoder_enc_fx(
ENC_CORE_HANDLE st /* i/o: Core encoder state structure */
)
{
- IF( st->hLPDmem == NULL && st->element_mode != IVAS_CPE_MDCT )
+ IF( st->hLPDmem == NULL && NE_16( st->element_mode, IVAS_CPE_MDCT ) )
{
IF( ( st->hLPDmem = (LPD_state_HANDLE) malloc( sizeof( LPD_state ) ) ) == NULL )
{
@@ -63,7 +63,7 @@ static ivas_error allocate_CoreCoder_enc_fx(
LPDmem_enc_init_ivas_fx( st->hLPDmem );
}
- IF( st->hGSCEnc == NULL && st->element_mode != IVAS_CPE_MDCT )
+ IF( st->hGSCEnc == NULL && NE_16( st->element_mode, IVAS_CPE_MDCT ) )
{
IF( ( st->hGSCEnc = (GSC_ENC_HANDLE) malloc( sizeof( GSC_ENC_DATA ) ) ) == NULL )
{
@@ -221,10 +221,10 @@ static void deallocate_CoreCoder_enc_fx(
ivas_error stereo_memory_enc_fx(
CPE_ENC_HANDLE hCPE, /* i : CPE encoder structure */
- const Word32 input_Fs, /* i : input sampling rate */
- const Word16 max_bwidth, /* i : maximum audio bandwidth */
+ const Word32 input_Fs, /* i : input sampling rate Q0*/
+ const Word16 max_bwidth, /* i : maximum audio bandwidth Q0*/
const IVAS_FORMAT ivas_format, /* i : ivas format */
- const Word16 nchan_transport /* i : number transport chans */
+ const Word16 nchan_transport /* i : number transport chans Q0*/
)
{
Encoder_State *st;
@@ -241,7 +241,16 @@ ivas_error stereo_memory_enc_fx(
test();
IF( hCPE->hStereoTCA != NULL && EQ_16( hCPE->last_element_mode, IVAS_CPE_DFT ) )
{
+#ifdef FIX_1132_STACK_CORRUPTION
+ Word16 tmp = extract_h( abs( hCPE->hStereoDft->hItd->itd_fx[1] ) );
+ if ( hCPE->hStereoDft->hItd->itd_fx[1] < 0 )
+ {
+ tmp = negate( tmp );
+ }
+ set16_fx( hCPE->hStereoTCA->prevCorrLagStats, tmp, 3 );
+#else
set16_fx( hCPE->hStereoTCA->prevCorrLagStats, extract_h( hCPE->hStereoDft->hItd->itd_fx[1] ), 3 );
+#endif
IF( hCPE->hStereoDft->hItd->itd_fx[1] >= 0 )
{
hCPE->hStereoTCA->prevRefChanIndx = L_CH_INDX;
@@ -517,8 +526,8 @@ ivas_error stereo_memory_enc_fx(
// st->hTcxEnc->spectrum[0] = st->hTcxEnc->spectrum_long;
// st->hTcxEnc->spectrum[1] = st->hTcxEnc->spectrum_long + N_TCX10_MAX;
- st->hTcxEnc->spectrum_fx[0] = st->hTcxEnc->spectrum_long_fx;
- st->hTcxEnc->spectrum_fx[1] = st->hTcxEnc->spectrum_long_fx + N_TCX10_MAX;
+ st->hTcxEnc->spectrum_fx[0] = st->hTcxEnc->spectrum_long_fx; /* Q31-st->hTcxEnc->spectrum_e[0] */
+ st->hTcxEnc->spectrum_fx[1] = st->hTcxEnc->spectrum_long_fx + N_TCX10_MAX; /* Q31-st->hTcxEnc->spectrum_e[1] */
st->hTcxEnc->spectrum_e[0] = st->hTcxEnc->spectrum_e[1] = 0;
move16();
move16();
@@ -527,6 +536,8 @@ ivas_error stereo_memory_enc_fx(
set32_fx( st->hTcxEnc->spectrum_long_fx, 0, N_MAX );
st->hTcxEnc->spectrum_long_e = 0;
st->hTcxEnc->tfm_mem_fx = 1610612736; /* 0.75 in Q31 */
+ move16();
+ move32();
IF( EQ_16( hCPE->last_element_mode, IVAS_CPE_DFT ) )
{
@@ -560,6 +571,7 @@ ivas_error stereo_memory_enc_fx(
test();
hCPE->hStereoMdct->isSBAStereoMode = ( EQ_32( ivas_format, SBA_FORMAT ) && EQ_16( nchan_transport, 2 ) );
+ move16();
test();
test();
@@ -625,17 +637,17 @@ ivas_error stereo_memory_enc_fx(
}
static void v_multc_fixed_32_16(
- const Word16 x[], /* i : Input vector */
- const Word32 c, /* i : Constant */
- Word32 y[], /* o : Output vector that contains c*x */
- const Word16 N /* i : Vector length */
+ const Word16 x[], /* i : Input vector Qx*/
+ const Word32 c, /* i : Constant Q31*/
+ Word32 y[], /* o : Output vector that contains c*x Qx*/
+ const Word16 N /* i : Vector length Q0*/
)
{
Word16 i;
FOR( i = 0; i < N; i++ )
{
- y[i] = Mpy_32_16_1( c, x[i] );
+ y[i] = Mpy_32_16_1( c, x[i] ); /* Q16+Qx */
move32();
}
@@ -649,8 +661,8 @@ static void v_multc_fixed_32_16(
void stereo_switching_enc_fx(
CPE_ENC_HANDLE hCPE, /* i : CPE encoder structure */
- Word16 old_input_signal_pri[], /* i : old input signal of primary channel */
- const Word16 input_frame, /* i : input frame length */
+ Word16 old_input_signal_pri[], /* i : old input signal of primary channel q_inp*/
+ const Word16 input_frame, /* i : input frame length Q0*/
const Word16 q_inp )
{
Word16 i, n, dft_ovl, offset;
@@ -668,16 +680,16 @@ void stereo_switching_enc_fx(
{
FOR( n = 0; n < CPE_CHANNELS; n++ )
{
- Copy( sts[n]->input_fx + input_frame - dft_ovl, hCPE->input_mem_fx[n], dft_ovl );
+ Copy( sts[n]->input_fx + input_frame - dft_ovl, hCPE->input_mem_fx[n], dft_ovl ); /* sts[n]->q_inp */
}
}
/* save original stereo input (MDCT overlap part) for both channels in unused old input of right channel for possible DFT->MDCT transition */
IF( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) )
{
- Copy( sts[0]->input_fx + sub( (Word16) Mpy_32_32( sts[0]->input_Fs, 42949673 /* 1/50 in Q31*/ ), sts[0]->encoderLookahead_FB ), sts[1]->input_fx - shl( sts[0]->encoderLookahead_FB, 1 ), sts[0]->encoderLookahead_FB );
+ Copy( sts[0]->input_fx + sub( (Word16) Mpy_32_32( sts[0]->input_Fs, 42949673 /* 1/50 in Q31*/ ), sts[0]->encoderLookahead_FB ), sts[1]->input_fx - shl( sts[0]->encoderLookahead_FB, 1 ), sts[0]->encoderLookahead_FB ); /* sts[0]->q_inp */
- Copy( sts[1]->input_fx + sub( (Word16) Mpy_32_32( sts[1]->input_Fs, 42949673 /* 1/50 in Q31*/ ), sts[1]->encoderLookahead_FB ), sts[1]->input_fx - sts[1]->encoderLookahead_FB, sts[1]->encoderLookahead_FB );
+ Copy( sts[1]->input_fx + sub( (Word16) Mpy_32_32( sts[1]->input_Fs, 42949673 /* 1/50 in Q31*/ ), sts[1]->encoderLookahead_FB ), sts[1]->input_fx - sts[1]->encoderLookahead_FB, sts[1]->encoderLookahead_FB ); /* sts[1]->q_inp */
}
@@ -688,7 +700,7 @@ void stereo_switching_enc_fx(
/* window DFT synthesis overlap memory @input_Fs, primary channel */
FOR( i = 0; i < dft_ovl; i++ )
{
- hCPE->hStereoDft->output_mem_dmx_fx[i] = L_shr( Mpy_32_16_r( hCPE->hStereoDft->win_fx[dft_ovl - 1 - i], old_input_signal_pri[input_frame - dft_ovl + i] ), q_inp ); // ( ( Q31 + q_inp ) - Q15 ) - Q16 ) -> Q16
+ hCPE->hStereoDft->output_mem_dmx_fx[i] = L_shr( Mpy_32_16_r( hCPE->hStereoDft->win_fx[dft_ovl - 1 - i], old_input_signal_pri[input_frame - dft_ovl + i] ), add( q_inp, 1 ) ); // Q31 + q_inp - Q15 - (q_inp + 1) -> Q15
move32();
}
/* reset 48kHz BWE overlap memory */
@@ -710,7 +722,7 @@ void stereo_switching_enc_fx(
tmp_fx = usdequant_fx( hCPE->hStereoTCA->indx_ica_gD, STEREO_TCA_GDMIN_FX, STEREO_TCA_GDSTEP_FX );
FOR( i = 0; i < STEREO_DFT_BAND_MAX; i++ )
{
- hCPE->hStereoDft->side_gain_fx[STEREO_DFT_BAND_MAX + i] = L_deposit_h( tmp_fx );
+ hCPE->hStereoDft->side_gain_fx[STEREO_DFT_BAND_MAX + i] = L_deposit_h( tmp_fx ); /* Q31 */
move32();
}
}
@@ -722,22 +734,22 @@ void stereo_switching_enc_fx(
/* update DFT synthesis overlap memory @12.8kHz */
FOR( i = 0; i < STEREO_DFT_OVL_12k8; i++ )
{
- hCPE->hStereoDft->output_mem_dmx_12k8_fx[i] = L_shr( Mpy_32_16_r( hCPE->hStereoDft->win_12k8_fx[STEREO_DFT_OVL_12k8 - 1 - i], sts[0]->buf_speech_enc[L_FRAME32k + L_FRAME - STEREO_DFT_OVL_12k8 + i] ), q_inp );
+ hCPE->hStereoDft->output_mem_dmx_12k8_fx[i] = L_shr( Mpy_32_16_r( hCPE->hStereoDft->win_12k8_fx[STEREO_DFT_OVL_12k8 - 1 - i], sts[0]->buf_speech_enc[L_FRAME32k + L_FRAME - STEREO_DFT_OVL_12k8 + i] ), q_inp + 1 ); /* Q15 */
move32();
}
- Word16 q_dmx = Q16;
+ Word16 q_dmx = Q15;
move16();
/* update DFT synthesis overlap memory @16kHz, primary channel only */
L_lerp_fx( hCPE->hStereoDft->output_mem_dmx_fx, hCPE->hStereoDft->output_mem_dmx_16k_fx, STEREO_DFT_OVL_16k, dft_ovl, &q_dmx );
FOR( i = 0; i < STEREO_DFT_OVL_16k; i++ )
{
- hCPE->hStereoDft->output_mem_dmx_16k_fx[i] = L_shl( hCPE->hStereoDft->output_mem_dmx_16k_fx[i], sub( Q16, q_dmx ) ); // Q16
+ hCPE->hStereoDft->output_mem_dmx_16k_fx[i] = L_shl( hCPE->hStereoDft->output_mem_dmx_16k_fx[i], sub( Q15, q_dmx ) ); // Q15
move32();
}
FOR( i = 0; i < STEREO_DFT_OVL_MAX; i++ )
{
- hCPE->hStereoDft->output_mem_dmx_fx[i] = L_shl( hCPE->hStereoDft->output_mem_dmx_fx[i], sub( Q16, q_dmx ) ); // Q16
+ hCPE->hStereoDft->output_mem_dmx_fx[i] = L_shl( hCPE->hStereoDft->output_mem_dmx_fx[i], sub( Q15, q_dmx ) ); // Q15
move32();
}
@@ -782,7 +794,8 @@ void stereo_switching_enc_fx(
set_zero_fx( sts[1]->input32_fx - input_frame, input_frame );
set16_zero_fx( sts[1]->input_fx - input_frame, input_frame );
sts[1]->q_old_inp = Q15;
- hCPE->hStereoTD->tdm_last_ratio_fx = tdm_ratio_tabl_fx[LRTD_STEREO_LEFT_IS_PRIM];
+ hCPE->hStereoTD->tdm_last_ratio_fx = tdm_ratio_tabl_fx[LRTD_STEREO_LEFT_IS_PRIM]; /* Q31 */
+ move16();
move32();
hCPE->hStereoTD->tdm_last_ratio_idx = LRTD_STEREO_LEFT_IS_PRIM;
@@ -790,9 +803,9 @@ void stereo_switching_enc_fx(
test();
test();
- IF( LT_32( hCPE->hStereoTCA->instTargetGain_fx, 26843546 ) && ( hCPE->hCoreCoder[0]->vad_flag || hCPE->hCoreCoder[1]->vad_flag ) ) /* but if there is no content in the L channel -> the primary channel is forced to right */
+ IF( LT_32( hCPE->hStereoTCA->instTargetGain_fx, 26843546 /*Q29*/ ) && ( hCPE->hCoreCoder[0]->vad_flag || hCPE->hCoreCoder[1]->vad_flag ) ) /* but if there is no content in the L channel -> the primary channel is forced to right */
{
- hCPE->hStereoTD->tdm_last_ratio_fx = tdm_ratio_tabl_fx[LRTD_STEREO_RIGHT_IS_PRIM];
+ hCPE->hStereoTD->tdm_last_ratio_fx = tdm_ratio_tabl_fx[LRTD_STEREO_RIGHT_IS_PRIM]; /* Q31 */
move32();
hCPE->hStereoTD->tdm_last_ratio_idx = LRTD_STEREO_RIGHT_IS_PRIM;
move16();
@@ -806,10 +819,10 @@ void stereo_switching_enc_fx(
{
IF( sts[0]->cldfbAnaEnc != NULL )
{
- offset = sub( sts[0]->cldfbAnaEnc->p_filter_length, sts[0]->cldfbAnaEnc->no_channels );
+ offset = sub( sts[0]->cldfbAnaEnc->p_filter_length, sts[0]->cldfbAnaEnc->no_channels ); /* Q0 */
FOR( i = 0; i < offset; i++ )
{
- sts[0]->cldfbAnaEnc->cldfb_state_fx[i] = L_deposit_h( old_input_signal_pri[input_frame - offset - NS2SA( input_frame * FRAMES_PER_SEC, L_MEM_RECALC_TBE_NS ) + i] );
+ sts[0]->cldfbAnaEnc->cldfb_state_fx[i] = L_deposit_h( old_input_signal_pri[input_frame - offset - NS2SA( input_frame * FRAMES_PER_SEC, L_MEM_RECALC_TBE_NS ) + i] ); /* Q16+q_inp */
move32();
}
sts[0]->cldfbAnaEnc->Q_cldfb_state = add( Q16, q_inp );
@@ -819,7 +832,7 @@ void stereo_switching_enc_fx(
IF( sts[0]->cldfbSynTd != NULL )
{
cldfb_reset_memory_fx( sts[0]->cldfbSynTd );
- sts[0]->currEnergyLookAhead_fx = 130996;
+ sts[0]->currEnergyLookAhead_fx = 130996; /* Q31 */
move32();
}
@@ -831,7 +844,7 @@ void stereo_switching_enc_fx(
test();
IF( hCPE->hStereoTD != NULL && EQ_16( hCPE->hStereoTD->tdm_last_ratio_idx, LRTD_STEREO_LEFT_IS_PRIM ) )
{
- v_multc_fixed_32_16( hCPE->hCoreCoder[1]->old_input_signal_fx + sub( input_frame, add( offset, NS2SA( input_frame * FRAMES_PER_SEC, L_MEM_RECALC_TBE_NS ) ) ), -MAX_32, sts[1]->cldfbAnaEnc->cldfb_state_fx, offset );
+ v_multc_fixed_32_16( hCPE->hCoreCoder[1]->old_input_signal_fx + sub( input_frame, add( offset, NS2SA( input_frame * FRAMES_PER_SEC, L_MEM_RECALC_TBE_NS ) ) ), -MAX_32, sts[1]->cldfbAnaEnc->cldfb_state_fx, offset ); /* Q16+q_inp */
sts[1]->cldfbAnaEnc->Q_cldfb_state = add( Q16, q_inp );
move16();
}
@@ -839,7 +852,7 @@ void stereo_switching_enc_fx(
{
FOR( i = 0; i < offset; i++ )
{
- sts[1]->cldfbAnaEnc->cldfb_state_fx[i] = L_shr( L_deposit_h( hCPE->hCoreCoder[1]->old_input_signal_fx[input_frame - offset - NS2SA( input_frame * FRAMES_PER_SEC, L_MEM_RECALC_TBE_NS ) + i] ), 5 );
+ sts[1]->cldfbAnaEnc->cldfb_state_fx[i] = L_shr( L_deposit_h( hCPE->hCoreCoder[1]->old_input_signal_fx[input_frame - offset - NS2SA( input_frame * FRAMES_PER_SEC, L_MEM_RECALC_TBE_NS ) + i] ), 5 ); /* Q11+q_inp */
move32();
}
sts[1]->cldfbAnaEnc->Q_cldfb_state = add( Q16 - 5, q_inp );
@@ -849,7 +862,7 @@ void stereo_switching_enc_fx(
IF( sts[1]->cldfbSynTd != NULL )
{
cldfb_reset_memory_fx( sts[1]->cldfbSynTd );
- sts[1]->currEnergyLookAhead_fx = 130996;
+ sts[1]->currEnergyLookAhead_fx = 130996; /* Q31 */
move32();
}
}
@@ -909,32 +922,32 @@ void stereo_switching_enc_fx(
{
Copy( sts[0]->hLPDmem->old_exc, sts[1]->hLPDmem->old_exc, L_EXC_MEM );
}
- Copy( sts[0]->lsf_old_fx, sts[1]->lsf_old_fx, M );
- Copy( sts[0]->lsp_old_fx, sts[1]->lsp_old_fx, M );
- Copy( sts[0]->lsf_old1_fx, sts[1]->lsf_old1_fx, M );
- Copy( sts[0]->lsp_old1_fx, sts[1]->lsp_old1_fx, M );
+ Copy( sts[0]->lsf_old_fx, sts[1]->lsf_old_fx, M ); /* Qlog2(2.56) */
+ Copy( sts[0]->lsp_old_fx, sts[1]->lsp_old_fx, M ); /* Q15 */
+ Copy( sts[0]->lsf_old1_fx, sts[1]->lsf_old1_fx, M ); /* Qlog2(2.56) */
+ Copy( sts[0]->lsp_old1_fx, sts[1]->lsp_old1_fx, M ); /* Q15 */
sts[1]->GSC_noisy_speech = 0;
move16();
IF( EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) )
{
/* cross-fade overlap region of DFT Stereo downmix and original stereo channels */
- tmp_fx = div_s( 64, shl( sts[0]->encoderLookahead_FB, Q6 ) );
+ tmp_fx = div_s( 64, shl( sts[0]->encoderLookahead_FB, Q6 ) ); /* Q15 */
FOR( i = 0; i < sts[0]->encoderLookahead_FB; i++ )
{
- sts[1]->input32_fx[-sts[0]->encoderLookahead_FB + i] = L_shr( Mpy_32_16_1( L_add( Mpy_32_16_1( sts[0]->input32_fx[-sts[0]->encoderLookahead_FB + i], sts[0]->encoderLookahead_FB - i ), Mpy_32_16_1( sts[1]->input32_fx[-sts[0]->encoderLookahead_FB + i], i ) ), tmp_fx ), 13 );
+ sts[1]->input32_fx[-sts[0]->encoderLookahead_FB + i] = L_shr( Mpy_32_16_1( L_add( Mpy_32_16_1( sts[0]->input32_fx[-sts[0]->encoderLookahead_FB + i], sts[0]->encoderLookahead_FB - i ), Mpy_32_16_1( sts[1]->input32_fx[-sts[0]->encoderLookahead_FB + i], i ) ), tmp_fx ), 13 ); /* q_inp32+0-15+15-15-13 */
move32();
- sts[0]->input32_fx[-sts[0]->encoderLookahead_FB + i] = L_shr( Mpy_32_16_1( L_add( Mpy_32_16_1( sts[0]->input32_fx[-sts[0]->encoderLookahead_FB + i], sts[0]->encoderLookahead_FB - i ), Mpy_32_16_1( sts[1]->input32_fx[-2 * sts[0]->encoderLookahead_FB + i], i ) ), tmp_fx ), 13 );
+ sts[0]->input32_fx[-sts[0]->encoderLookahead_FB + i] = L_shr( Mpy_32_16_1( L_add( Mpy_32_16_1( sts[0]->input32_fx[-sts[0]->encoderLookahead_FB + i], sts[0]->encoderLookahead_FB - i ), Mpy_32_16_1( sts[1]->input32_fx[-2 * sts[0]->encoderLookahead_FB + i], i ) ), tmp_fx ), 13 ); /* q_inp32+0-15+15-15-13 */
move32();
}
/* restore continuous signal in right channel (part of old_output was used to store original left channel) */
- Copy32( sts[0]->input32_fx - sts[0]->hTcxEnc->L_frameTCX, sts[1]->input32_fx - sts[0]->hTcxEnc->L_frameTCX, sts[0]->hTcxEnc->L_frameTCX - sts[0]->encoderLookahead_FB );
+ Copy32( sts[0]->input32_fx - sts[0]->hTcxEnc->L_frameTCX, sts[1]->input32_fx - sts[0]->hTcxEnc->L_frameTCX, sub( sts[0]->hTcxEnc->L_frameTCX, sts[0]->encoderLookahead_FB ) ); /* sts[0]->q_inp32 */
- sts[1]->last_core = sts[0]->last_core;
+ sts[1]->last_core = sts[0]->last_core; /* Q0 */
move16();
- sts[1]->last_coder_type = sts[0]->last_coder_type;
+ sts[1]->last_coder_type = sts[0]->last_coder_type; /* Q0 */
move16();
- sts[1]->last_bwidth = sts[0]->last_bwidth;
+ sts[1]->last_bwidth = sts[0]->last_bwidth; /* Q0 */
move16();
}
}
@@ -949,7 +962,7 @@ void stereo_switching_enc_fx(
test();
IF( EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) && NE_16( hCPE->last_element_mode, IVAS_CPE_MDCT ) )
{
- sts[1]->hTcxCfg->last_aldo = sts[0]->hTcxCfg->last_aldo;
+ sts[1]->hTcxCfg->last_aldo = sts[0]->hTcxCfg->last_aldo; /* Q0 */
move16();
sts[1]->hTcxCfg->tcx_curr_overlap_mode = sts[0]->hTcxCfg->tcx_curr_overlap_mode;
move16();
diff --git a/lib_enc/ivas_stereo_td_analysis.c b/lib_enc/ivas_stereo_td_analysis.c
index fdf53370e97239e1b7f5e94d5c0e0c55d6db3c51..58e72c91e38992ca05fab77506bbfdfa492344d5 100644
--- a/lib_enc/ivas_stereo_td_analysis.c
+++ b/lib_enc/ivas_stereo_td_analysis.c
@@ -114,23 +114,23 @@
* Local function prototypes
*-------------------------------------------------------------------*/
-static Word16 stereo_tdm_ener_analysis_SM_fx( CPE_ENC_HANDLE hCPE, Encoder_State **sts, const Word16 input_frame, Word16 *tdm_SM_flag );
+static Word16 stereo_tdm_ener_analysis_SM_fx( CPE_ENC_HANDLE hCPE, Encoder_State **sts, const Word16 input_frame /*Q0*/, Word16 *tdm_SM_flag /*Q0*/ );
-static void Get_corr_n_fx( const Word16 L[], const Word16 R[], Word32 *ic_Lm, Word16 *q_ic_Lm, Word32 *ic_Rm, Word16 *q_ic_Rm, const Word16 len, Word32 *es_em, const Word16 tdm_SM_calc_flag );
+static void Get_corr_n_fx( const Word16 L[] /*q_in*/, const Word16 R[] /*q_in*/, Word32 *ic_Lm, Word16 *q_ic_Lm, Word32 *ic_Rm, Word16 *q_ic_Rm, const Word16 len, Word32 *es_em, const Word16 tdm_SM_calc_flag );
static Word16 stereo_smooth_LR_transition_fx( Word16 *tdm_prev_stable_idx, Word16 *tdm_ratio_transition_mov_flag, Word16 tdm_last_ratio_idx, Word16 *tdm_prev_desired_idx, Word16 *tdm_ratio_transition_cnt, const Word16 tdm_SM_flag, Word16 desired_idx );
-static Word16 limit_idx_Dwnmix_fx( const Word16 idx_in, const Word16 unclr_decision, const Word16 inst_idx, const Word16 previous_idx, const Word16 tdm_last_LRTD_PriCh_cnt, const Word16 tdm_last_LRTD_frame_cnt );
+static Word16 limit_idx_Dwnmix_fx( const Word16 idx_in /*Q0*/, const Word16 unclr_decision /*Q0*/, const Word16 inst_idx /*Q0*/, const Word16 previous_idx /*Q0*/, const Word16 tdm_last_LRTD_PriCh_cnt /*Q0*/, const Word16 tdm_last_LRTD_frame_cnt /*Q0*/ );
-static Word16 limit_idx_NoDwnmix_fx( const Word16 idx_in, const Word16 side_can_change, const Word32 d_lt_corr_raw, const Word16 q_d_lt_corr_raw );
+static Word16 limit_idx_NoDwnmix_fx( const Word16 idx_in /*Q0*/, const Word16 side_can_change /*Q0*/, const Word32 d_lt_corr_raw, const Word16 q_d_lt_corr_raw );
-static void Get_LR_rms_fx( const Word16 *Left_in, const Word16 *Right_in, const Word16 input_frame, Word32 *rms_L, Word16 *q_rms_L, Word32 *rms_R, Word16 *q_rms_R );
+static void Get_LR_rms_fx( const Word16 *Left_in /*q_inp*/, const Word16 *Right_in /*q_inp*/, const Word16 input_frame, Word32 *rms_L, Word16 *q_rms_L, Word32 *rms_R, Word16 *q_rms_R );
-static Word16 Get_dt_lt_ener_fx( CPE_ENC_HANDLE hCPE, const Word16 IsSideMono, const Word16 input_frame, const Word16 tdm_last_SM_flag, const Word32 rms_L, const Word16 q_rms_L, const Word32 rms_R, const Word16 q_rms_R, Word32 *tdm_lt_rms_L, Word32 *tdm_lt_rms_R, Word32 *tdm_last_ener_lt_L, Word32 *tdm_last_ener_lt_R, Word32 *tdm_LT_es_em, Word16 *tdm_hyst_cnt, Word16 *tdm_NOOP_SM_flag_loc, Word32 *ener_R_dt, Word32 *ener_L_dt, Word32 *corr_LM, Word16 *q_corr_LM, Word32 *corr_RM, Word16 *q_corr_RM );
+static Word16 Get_dt_lt_ener_fx( CPE_ENC_HANDLE hCPE, const Word16 IsSideMono, const Word16 input_frame, const Word16 tdm_last_SM_flag, const Word32 rms_L, const Word16 q_rms_L, const Word32 rms_R, const Word16 q_rms_R, Word32 *tdm_lt_rms_L /*Q16*/, Word32 *tdm_lt_rms_R /*Q16*/, Word32 *tdm_last_ener_lt_L /*Q16*/, Word32 *tdm_last_ener_lt_R /*Q16*/, Word32 *tdm_LT_es_em /*Q21*/, Word16 *tdm_hyst_cnt, Word16 *tdm_NOOP_SM_flag_loc, Word32 *ener_R_dt /*Q16*/, Word32 *ener_L_dt /*Q16*/, Word32 *corr_LM, Word16 *q_corr_LM, Word32 *corr_RM, Word16 *q_corr_RM );
-static void NOOP_decision_fx( CPE_ENC_HANDLE hCPE, const Word16 tdm_NOOP_flag_loc, const Word16 tmp_SM_flag, const Word32 rms_L, const Word16 q_rms_L, const Word32 rms_R, const Word16 q_rms_R, Word16 *tdm_SM_flag_loc );
+static void NOOP_decision_fx( CPE_ENC_HANDLE hCPE, const Word16 tdm_NOOP_flag_loc /*Q0*/, const Word16 tmp_SM_flag /*Q0*/, const Word32 rms_L, const Word16 q_rms_L, const Word32 rms_R, const Word16 q_rms_R, Word16 *tdm_SM_flag_loc /*Q0*/ );
-static Word32 Comp_diff_lt_corr_fx( CPE_ENC_HANDLE hCPE, const Word16 IsSideMono, const Word32 rms_L, const Word16 q_rms_L, const Word32 rms_R, const Word16 q_rms_R, const Word32 ener_L_dt, const Word32 ener_R_dt, Word32 corr_LM, Word16 q_corr_LM, Word32 corr_RM, Word16 q_corr_RM, const Word32 tdm_lt_rms_L, const Word32 tdm_lt_rms_R, Word32 *tdm_lt_corr_LM, Word32 *tdm_lt_corr_RM, Word32 *tdm_last_diff_lt_corr, Word16 *q_tdm_last_diff_lt_corr, Word32 *inst_ratio_L_out, Word32 *diff_lt_corr, Word16 *q_d_lt_corr_raw );
+static Word32 Comp_diff_lt_corr_fx( CPE_ENC_HANDLE hCPE, const Word16 IsSideMono /*Q0*/, const Word32 rms_L, const Word16 q_rms_L, const Word32 rms_R, const Word16 q_rms_R, const Word32 ener_L_dt /*Q16*/, const Word32 ener_R_dt /*Q16*/, Word32 corr_LM, Word16 q_corr_LM, Word32 corr_RM, Word16 q_corr_RM, const Word32 tdm_lt_rms_L /*Q16*/, const Word32 tdm_lt_rms_R /*Q16*/, Word32 *tdm_lt_corr_LM /*Q24*/, Word32 *tdm_lt_corr_RM /*Q24*/, Word32 *tdm_last_diff_lt_corr, Word16 *q_tdm_last_diff_lt_corr, Word32 *inst_ratio_L_out /*Q24*/, Word32 *diff_lt_corr, Word16 *q_d_lt_corr_raw );
/*-------------------------------------------------------------------*
@@ -140,9 +140,9 @@ static Word32 Comp_diff_lt_corr_fx( CPE_ENC_HANDLE hCPE, const Word16 IsSideMono
Word16 stereo_tdm_ener_analysis_fx(
const Word16 ivas_format, /* i : IVAS format */
CPE_ENC_HANDLE hCPE, /* i : CPE structure */
- const Word16 input_frame, /* i : Number of samples */
- Word16 *tdm_SM_or_LRTD_Pri, /* o : channel combination scheme flag in TD stereo OR LRTD primary channel */
- Word16 *tdm_ratio_idx_SM /* o : TDM ratio index for SM mode */
+ const Word16 input_frame, /* i : Number of samples Q0*/
+ Word16 *tdm_SM_or_LRTD_Pri, /* o : channel combination scheme flag in TD stereo OR LRTD primary channel Q0*/
+ Word16 *tdm_ratio_idx_SM /* o : TDM ratio index for SM mode Q0*/
)
{
Word32 diff_lt_corr_fx /*Q24*/;
@@ -189,7 +189,7 @@ Word16 stereo_tdm_ener_analysis_fx(
* - evolution of the L and R to Mono gain
*----------------------------------------------------------------*/
- tdm_SM_flag_loc = hStereoTD->tdm_last_SM_flag;
+ tdm_SM_flag_loc = hStereoTD->tdm_last_SM_flag; /* Q0 */
move16();
tmp_SM_flag = Get_dt_lt_ener_fx( hCPE, 0, input_frame, hStereoTD->tdm_last_SM_flag, rms_L_fx, q_rms_L, rms_R_fx, q_rms_R,
@@ -218,7 +218,7 @@ Word16 stereo_tdm_ener_analysis_fx(
IF( GT_16( q_d_lt_corr_raw, 31 ) )
{
- d_lt_corr_raw_fx = L_shr( d_lt_corr_raw_fx, sub( q_d_lt_corr_raw, Q31 ) );
+ d_lt_corr_raw_fx = L_shr( d_lt_corr_raw_fx, sub( q_d_lt_corr_raw, Q31 ) ); /* Q31 */
q_d_lt_corr_raw = Q31;
move16();
}
@@ -232,7 +232,7 @@ Word16 stereo_tdm_ener_analysis_fx(
xtalk_classifier_td_fx( hCPE );
/* switch to LRTD on cross-talk segments where two speakers are weakly correlated */
- hStereoTD->prev_fr_LRTD_TD_dec = hCPE->hStereoClassif->lrtd_mode;
+ hStereoTD->prev_fr_LRTD_TD_dec = hCPE->hStereoClassif->lrtd_mode; /* Q0 */
move16();
/*----------------------------------------------------------------*
@@ -251,7 +251,7 @@ Word16 stereo_tdm_ener_analysis_fx(
}
}
- rms_thd_fx = RMS_MIN_Q16;
+ rms_thd_fx = RMS_MIN_Q16; /* Q16 */
move32();
IF( EQ_16( hCPE->hStereoClassif->lrtd_mode, 1 ) )
{
@@ -326,7 +326,7 @@ Word16 stereo_tdm_ener_analysis_fx(
move16();
}
- if ( NE_16( hCPE->last_element_mode, IVAS_CPE_TD ) )
+ IF( NE_16( hCPE->last_element_mode, IVAS_CPE_TD ) )
{
side_can_change = 1;
move16();
@@ -353,8 +353,8 @@ Word16 stereo_tdm_ener_analysis_fx(
test();
test();
test();
- if ( ( ( LT_32( rms_L_fx, RMS_THR_Q16 ) && LT_32( rms_R_fx, RMS_THR_Q16 ) && LT_32( L_abs( L_sub( rms_R_fx, rms_L_fx ) ), RMS_THR_Q16 / 2 ) && GT_32( L_abs( d_lt_corr_raw_fx ), L_shr( 644245094 /*0.3f in Q31*/, sub( Q31, q_d_lt_corr_raw ) ) ) ) ||
- ( LT_16( abs_s( sub( sts[0]->old_corr_fx, sts[1]->old_corr_fx ) ), 4915 /*0.15f in Q15*/ ) && GT_16( sts[0]->old_corr_fx, 22937 /*0.7f in Q15*/ ) && LT_16( sts[0]->old_corr_fx, 27853 /*0.85f in Q15*/ ) && LT_32( L_abs( L_sub( rms_L_fx, rms_R_fx ) ), rms_thd_fx ) && GT_32( L_abs( d_lt_corr_raw_fx ), L_shr( 644245094 /*0.3f in Q31*/, sub( Q31, q_d_lt_corr_raw ) ) ) ) ) /* Both channels are low energy, clean background switching is allowed */
+ IF( ( ( LT_32( rms_L_fx, RMS_THR_Q16 ) && LT_32( rms_R_fx, RMS_THR_Q16 ) && LT_32( L_abs( L_sub( rms_R_fx, rms_L_fx ) ), RMS_THR_Q16 / 2 ) && GT_32( L_abs( d_lt_corr_raw_fx ), L_shr( 644245094 /*0.3f in Q31*/, sub( Q31, q_d_lt_corr_raw ) ) ) ) ||
+ ( LT_16( abs_s( sub( sts[0]->old_corr_fx, sts[1]->old_corr_fx ) ), 4915 /*0.15f in Q15*/ ) && GT_16( sts[0]->old_corr_fx, 22937 /*0.7f in Q15*/ ) && LT_16( sts[0]->old_corr_fx, 27853 /*0.85f in Q15*/ ) && LT_32( L_abs( L_sub( rms_L_fx, rms_R_fx ) ), rms_thd_fx ) && GT_32( L_abs( d_lt_corr_raw_fx ), L_shr( 644245094 /*0.3f in Q31*/, sub( Q31, q_d_lt_corr_raw ) ) ) ) ) /* Both channels are low energy, clean background switching is allowed */
)
{
side_can_change = 1;
@@ -388,7 +388,7 @@ Word16 stereo_tdm_ener_analysis_fx(
test();
test();
- if ( GE_32( hCPE->hStereoClassif->xtalk_wscore_fx, 107374182 /*0.05f in Q31*/ ) && hStereoTD->prev_fr_LRTD_TD_dec == 0 && EQ_16( hCPE->hStereoClassif->lrtd_mode, 1 ) )
+ IF( GE_32( hCPE->hStereoClassif->xtalk_wscore_fx, 107374182 /*0.05f in Q31*/ ) && hStereoTD->prev_fr_LRTD_TD_dec == 0 && EQ_16( hCPE->hStereoClassif->lrtd_mode, 1 ) )
{
side_can_change = 0;
move16();
@@ -478,9 +478,9 @@ Word16 stereo_tdm_ener_analysis_fx(
{
test();
test();
- if ( GE_32( hCPE->element_brate, IVAS_48k ) && sts[0]->hVAD->hangover_cnt != 0 && LT_32( L_max( hStereoTD->tdm_lt_rms_L_fx, hStereoTD->tdm_lt_rms_R_fx ), 33554432 /* 512.0f */ ) )
+ IF( GE_32( hCPE->element_brate, IVAS_48k ) && sts[0]->hVAD->hangover_cnt != 0 && LT_32( L_max( hStereoTD->tdm_lt_rms_L_fx, hStereoTD->tdm_lt_rms_R_fx ), 33554432 /* 512.0f */ ) )
{
- ratio_L_fx = check_bounds_l( ratio_L_fx, 644245094 /*0.3f in Q31*/, 1503238554 /*0.7f in Q31*/ );
+ ratio_L_fx = check_bounds_l( ratio_L_fx, 644245094 /*0.3f in Q31*/, 1503238554 /*0.7f in Q31*/ ); /* Q31 */
}
test();
@@ -512,7 +512,7 @@ Word16 stereo_tdm_ener_analysis_fx(
}
}
- idx = stereo_smooth_LR_transition_fx( &hStereoTD->tdm_prev_stable_idx, &hStereoTD->tdm_ratio_transition_mov_flag, hStereoTD->tdm_last_ratio_idx, &hStereoTD->tdm_prev_desired_idx, &hStereoTD->tdm_ratio_transition_cnt, tdm_SM_flag_loc, desired_idx );
+ idx = stereo_smooth_LR_transition_fx( &hStereoTD->tdm_prev_stable_idx, &hStereoTD->tdm_ratio_transition_mov_flag, hStereoTD->tdm_last_ratio_idx, &hStereoTD->tdm_prev_desired_idx, &hStereoTD->tdm_ratio_transition_cnt, tdm_SM_flag_loc, desired_idx ); /* Q0 */
/* Change the switching level in case of dual mono (in case the scenario still accept left right switching */
/* This logic is needed in case the content is exactly the same in the 2 channel and it is expected to get back to LRTD, to prevent the secondary channel to be completely empty */
@@ -577,19 +577,19 @@ Word16 stereo_tdm_ener_analysis_fx(
Word16 idx_offet;
idx_offet = 5;
move16();
- if ( GT_16( desired_idx, LRTD_STEREO_MID_IS_PRIM ) ) /* slightly Favor the 2nd channel */
+ IF( GT_16( desired_idx, LRTD_STEREO_MID_IS_PRIM ) ) /* slightly Favor the 2nd channel */
{
idx_offet = negate( idx_offet );
}
desired_idx = add( desired_idx, idx_offet );
- desired_idx = check_bounds_s_fx( desired_idx, 0, 30 );
+ desired_idx = check_bounds_s_fx( desired_idx, 0, 30 ); /* Q0 */
}
}
test();
IF( sts[1]->clas != UNVOICED_CLAS || sts[0]->clas != UNVOICED_CLAS )
{
- desired_idx = check_bounds_s_fx( desired_idx, 5, 25 );
+ desired_idx = check_bounds_s_fx( desired_idx, 5, 25 ); /* Q0 */
}
hStereoTD->tdm_inst_ratio_idx = desired_idx;
@@ -673,9 +673,9 @@ Word16 stereo_tdm_ener_analysis_fx(
move32();
hStereoTD->tdm_lt_corr_LM_SM_fx = 167772 /*0.01f Q24*/;
move32();
- hStereoTD->tdm_last_ratio_SM_fx = hStereoTD->tdm_last_ratio_fx;
+ hStereoTD->tdm_last_ratio_SM_fx = hStereoTD->tdm_last_ratio_fx; /* Q31 */
move32();
- hStereoTD->tdm_last_ratio_idx_SM = hStereoTD->tdm_last_ratio_idx;
+ hStereoTD->tdm_last_ratio_idx_SM = hStereoTD->tdm_last_ratio_idx; /* Q0 */
move16();
hStereoTD->tdm_lt_rms_L_SM_fx = 2621440; // 40.0f Q16
move32();
@@ -706,7 +706,7 @@ Word16 stereo_tdm_ener_analysis_fx(
move16();
}
- *tdm_ratio_idx_SM = stereo_tdm_ener_analysis_SM_fx( hCPE, sts, input_frame, &tdm_NOOP_flag );
+ *tdm_ratio_idx_SM = stereo_tdm_ener_analysis_SM_fx( hCPE, sts, input_frame, &tdm_NOOP_flag ); /* Q0 */
move16();
}
ELSE
@@ -723,15 +723,15 @@ Word16 stereo_tdm_ener_analysis_fx(
move16();
/* set channel combination scheme flag */
- *tdm_SM_or_LRTD_Pri = tdm_SM_flag_loc;
+ *tdm_SM_or_LRTD_Pri = tdm_SM_flag_loc; /* Q0 */
move16();
if ( EQ_16( hCPE->hStereoTD->tdm_LRTD_flag, 1 ) )
{
- *tdm_SM_or_LRTD_Pri = tdm_LRTD_pri_side;
+ *tdm_SM_or_LRTD_Pri = tdm_LRTD_pri_side; /* Q0 */
move16();
}
- hCPE->hStereoClassif->ratio_L_fx = ratio_L_fx;
+ hCPE->hStereoClassif->ratio_L_fx = ratio_L_fx; /* Q15 */
move32();
return idx;
@@ -744,12 +744,12 @@ Word16 stereo_tdm_ener_analysis_fx(
*-------------------------------------------------------------------*/
static void Get_LR_rms_fx(
- const Word16 *Left_in,
- const Word16 *Right_in,
- const Word16 input_frame,
- Word32 *rms_L,
+ const Word16 *Left_in, /* q_inp */
+ const Word16 *Right_in, /* q_inp */
+ const Word16 input_frame, /* Q0 */
+ Word32 *rms_L, /* q_rms_L */
Word16 *q_rms_L,
- Word32 *rms_R,
+ Word32 *rms_R, /* q_rms_R */
Word16 *q_rms_R )
{
Word32 ener_l, ener_r;
@@ -763,9 +763,9 @@ static void Get_LR_rms_fx(
move64();
W_ener_r_tmp = 0;
move64();
- ener_l = ONE_BY_100_Q31;
+ ener_l = ONE_BY_100_Q31; /* Q31 */
move32();
- ener_r = ONE_BY_100_Q31;
+ ener_r = ONE_BY_100_Q31; /* Q31 */
move32();
guard_bits = sub( 32, find_guarded_bits_fx( input_frame ) );
@@ -778,12 +778,12 @@ static void Get_LR_rms_fx(
ener_l_tmp = W_extract_h( W_shl( W_ener_l_tmp, guard_bits ) ); // guard_bits - 32
ener_r_tmp = W_extract_h( W_shl( W_ener_r_tmp, guard_bits ) ); // guard_bits - 32
- ener_l = BASOP_Util_Add_Mant32Exp( ener_l, 0, ener_l_tmp, sub( Q31, sub( guard_bits, 32 ) ), &exp_out_l );
- ener_r = BASOP_Util_Add_Mant32Exp( ener_r, 0, ener_r_tmp, sub( Q31, sub( guard_bits, 32 ) ), &exp_out_r );
+ ener_l = BASOP_Util_Add_Mant32Exp( ener_l, 0, ener_l_tmp, sub( Q31, sub( guard_bits, 32 ) ), &exp_out_l ); /* Q31-exp_out_l */
+ ener_r = BASOP_Util_Add_Mant32Exp( ener_r, 0, ener_r_tmp, sub( Q31, sub( guard_bits, 32 ) ), &exp_out_r ); /* Q31-exp_out_r */
- ener_l_tmp = BASOP_Util_Divide3232_Scale( ener_l, input_frame, &exp_diff );
+ ener_l_tmp = BASOP_Util_Divide3232_Scale( ener_l, input_frame, &exp_diff ); /* Q31- exp_out_l*/
exp_out_l = sub( add( exp_diff, exp_out_l ), Q15 );
- ener_r_tmp = BASOP_Util_Divide3232_Scale( ener_r, input_frame, &exp_diff );
+ ener_r_tmp = BASOP_Util_Divide3232_Scale( ener_r, input_frame, &exp_diff ); /* Q31-exp_out_r */
exp_out_r = sub( add( exp_diff, exp_out_r ), Q15 );
*rms_L = Sqrt32( ener_l_tmp, &exp_out_l ); // Q31 - exp_out_l
@@ -811,25 +811,25 @@ static void Get_LR_rms_fx(
static Word16 Get_dt_lt_ener_fx(
CPE_ENC_HANDLE hCPE,
- const Word16 IsSideMono,
- const Word16 input_frame,
- const Word16 tdm_last_SM_flag,
- const Word32 rms_L,
+ const Word16 IsSideMono, /* Q0 */
+ const Word16 input_frame, /* Q0 */
+ const Word16 tdm_last_SM_flag, /* Q0 */
+ const Word32 rms_L, /* q_rms_L */
const Word16 q_rms_L,
- const Word32 rms_R,
+ const Word32 rms_R, /* q_rms_R */
const Word16 q_rms_R,
- Word32 *tdm_lt_rms_L,
- Word32 *tdm_lt_rms_R,
- Word32 *tdm_last_ener_lt_L,
- Word32 *tdm_last_ener_lt_R,
- Word32 *tdm_LT_es_em,
- Word16 *tdm_hyst_cnt,
- Word16 *tdm_NOOP_SM_flag_loc,
- Word32 *ener_R_dt,
- Word32 *ener_L_dt,
- Word32 *corr_LM,
+ Word32 *tdm_lt_rms_L, /* Q16 */
+ Word32 *tdm_lt_rms_R, /* Q16 */
+ Word32 *tdm_last_ener_lt_L, /* Q16 */
+ Word32 *tdm_last_ener_lt_R, /* Q16 */
+ Word32 *tdm_LT_es_em, /* Q21 */
+ Word16 *tdm_hyst_cnt, /* Q0 */
+ Word16 *tdm_NOOP_SM_flag_loc, /* Q0 */
+ Word32 *ener_R_dt, /* Q16 */
+ Word32 *ener_L_dt, /* Q16 */
+ Word32 *corr_LM, /* q_corr_LM */
Word16 *q_corr_LM,
- Word32 *corr_RM,
+ Word32 *corr_RM, /* q_corr_RM */
Word16 *q_corr_RM )
{
Encoder_State **sts;
@@ -841,27 +841,27 @@ static Word16 Get_dt_lt_ener_fx(
sts = hCPE->hCoreCoder;
- Left_in_fx = sts[0]->input_fx; /* Left channel */
- Right_in_fx = sts[1]->input_fx; /* Right channel */
+ Left_in_fx = sts[0]->input_fx; /* Left channel sts[0]->q_inp*/
+ Right_in_fx = sts[1]->input_fx; /* Right channel sts[1]->q_inp*/
tmp = sub( getScaleFactor16( sts[0]->input_fx, input_frame ), 1 );
- Scale_sig( sts[0]->input_fx, input_frame, tmp );
+ Scale_sig( sts[0]->input_fx, input_frame, tmp ); /* sts[0]->q_inp + tmp */
sts[0]->q_inp = add( tmp, sts[0]->q_inp );
move16();
tmp = getScaleFactor16( sts[1]->input_fx, input_frame );
- Scale_sig( sts[1]->input_fx, input_frame, tmp );
+ Scale_sig( sts[1]->input_fx, input_frame, tmp ); /* sts[1]->q_inp + tmp */
sts[1]->q_inp = add( tmp, sts[1]->q_inp );
move16();
- Scale_sig( sts[0]->input_fx, input_frame, sub( s_min( sts[0]->q_inp, sts[1]->q_inp ), sts[0]->q_inp ) );
- Scale_sig( sts[1]->input_fx, input_frame, sub( s_min( sts[0]->q_inp, sts[1]->q_inp ), sts[1]->q_inp ) );
+ Scale_sig( sts[0]->input_fx, input_frame, sub( s_min( sts[0]->q_inp, sts[1]->q_inp ), sts[0]->q_inp ) ); /* s_min( sts[0]->q_inp, sts[1]->q_inp ) */
+ Scale_sig( sts[1]->input_fx, input_frame, sub( s_min( sts[0]->q_inp, sts[1]->q_inp ), sts[1]->q_inp ) ); /* s_min( sts[0]->q_inp, sts[1]->q_inp ) */
sts[1]->q_inp = s_min( sts[0]->q_inp, sts[1]->q_inp );
move16();
sts[0]->q_inp = sts[1]->q_inp;
move16();
- tdm_SM_flag_loc = tdm_last_SM_flag;
+ tdm_SM_flag_loc = tdm_last_SM_flag; /* Q0 */
move16();
test();
@@ -916,7 +916,7 @@ static Word16 Get_dt_lt_ener_fx(
Get_corr_n_fx( Left_in_fx, Right_in_fx, corr_LM, q_corr_LM, corr_RM, q_corr_RM, input_frame, &es_em_fx, IsSideMono );
- hCPE->hStereoClassif->xtalk_fv_fx[E_diff_corrLM_corrRM] = BASOP_Util_Add_Mant32Exp( *corr_LM, sub( Q31, *q_corr_LM ), L_negate( *corr_RM ), sub( Q31, *q_corr_RM ), &exp_diff );
+ hCPE->hStereoClassif->xtalk_fv_fx[E_diff_corrLM_corrRM] = BASOP_Util_Add_Mant32Exp( *corr_LM, sub( Q31, *q_corr_LM ), L_negate( *corr_RM ), sub( Q31, *q_corr_RM ), &exp_diff ); /* Q31-exp_diff */
move32();
hCPE->hStereoClassif->xtalk_fv_fx[E_diff_corrLM_corrRM] = L_shl( hCPE->hStereoClassif->xtalk_fv_fx[E_diff_corrLM_corrRM], sub( Q15, sub( Q31, exp_diff ) ) ); // Q15
move32();
@@ -937,8 +937,15 @@ static Word16 Get_dt_lt_ener_fx(
tmp_SM_flag = 0;
move16();
- if ( LT_16( s_min( sts[0]->old_corr_fx, sts[1]->old_corr_fx ), 27853 /* 0.85f in Q15 */ ) && LT_16( s_max( sts[0]->old_corr_fx, sts[1]->old_corr_fx ), 30147 /* 0.92f in Q15 */ ) &&
- ( GT_32( *tdm_LT_es_em, ONE_IN_Q22 /* 2.0f in Q21 */ ) || GT_32( es_em_fx, 5242880 /* 2.5f in Q21 */ ) ) && ( LE_16( sts[0]->hVAD->hangover_cnt, 1 ) && LE_16( sts[1]->hVAD->hangover_cnt, 3 ) && sts[0]->tdm_LRTD_flag == 0 ) )
+
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( LT_16( s_min( sts[0]->old_corr_fx, sts[1]->old_corr_fx ), 27853 /* 0.85f in Q15 */ ) && LT_16( s_max( sts[0]->old_corr_fx, sts[1]->old_corr_fx ), 30147 /* 0.92f in Q15 */ ) &&
+ ( GT_32( *tdm_LT_es_em, ONE_IN_Q22 /* 2.0f in Q21 */ ) || GT_32( es_em_fx, 5242880 /* 2.5f in Q21 */ ) ) && ( LE_16( sts[0]->hVAD->hangover_cnt, 1 ) && LE_16( sts[1]->hVAD->hangover_cnt, 3 ) && sts[0]->tdm_LRTD_flag == 0 ) )
{
tmp_SM_flag = 1;
move16();
@@ -951,6 +958,9 @@ static Word16 Get_dt_lt_ener_fx(
IF( NE_16( tmp_SM_flag, tdm_SM_flag_loc ) )
{
+ test();
+ test();
+ test();
IF( GE_16( *tdm_hyst_cnt, 2 ) && EQ_16( tmp_SM_flag, 1 ) && ( GT_16( sts[0]->tdm_pc, PC_LIMIT ) || GT_16( sts[1]->tdm_pc, PC_LIMIT ) ) )
{
tdm_hyst_cnt++;
@@ -975,7 +985,7 @@ static Word16 Get_dt_lt_ener_fx(
move16();
}
- return tmp_SM_flag;
+ return tmp_SM_flag; /* Q0 */
}
@@ -987,13 +997,13 @@ static Word16 Get_dt_lt_ener_fx(
static void NOOP_decision_fx(
CPE_ENC_HANDLE hCPE,
- const Word16 tdm_NOOP_flag_loc,
- const Word16 tmp_SM_flag,
- const Word32 rms_L,
+ const Word16 tdm_NOOP_flag_loc, /* Q0 */
+ const Word16 tmp_SM_flag, /* Q0 */
+ const Word32 rms_L, /* q_rms_L */
const Word16 q_rms_L,
- const Word32 rms_R,
+ const Word32 rms_R, /* q_rms_R */
const Word16 q_rms_R,
- Word16 *tdm_SM_flag_loc )
+ Word16 *tdm_SM_flag_loc /* Q0 */ )
{
Word16 tdm_NOOP_switch_flag;
STEREO_TD_ENC_DATA_HANDLE hStereoTD;
@@ -1008,6 +1018,14 @@ static void NOOP_decision_fx(
move16();
IF( hCPE->hCoreCoder[0]->sp_aud_decision0 == 0 )
{
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
IF( ( ( GT_16( hStereoTD->tdm_SM_last2_clas[0], VOICED_TRANSITION ) && ( hStereoTD->tdm_SM_last_clas[0] == UNVOICED_CLAS || EQ_16( hStereoTD->tdm_SM_last_clas[0], VOICED_TRANSITION ) ) ) ||
( GT_16( hStereoTD->tdm_SM_last2_clas[1], VOICED_TRANSITION ) && ( hStereoTD->tdm_SM_last_clas[1] == UNVOICED_CLAS || EQ_16( hStereoTD->tdm_SM_last_clas[1], VOICED_TRANSITION ) ) ) ) &&
( !( EQ_16( sts[0]->last_coder_type_raw, VOICED ) || EQ_16( sts[1]->last_coder_type_raw, VOICED ) ) && GT_16( hStereoTD->tdm_NOOP_cnt, 5 ) ) )
@@ -1082,6 +1100,8 @@ static void NOOP_decision_fx(
}
}
+ test();
+ test();
IF( GT_16( hStereoTD->tdm_SM_flag, 0 ) && EQ_16( tdm_NOOP_switch_flag, 1 ) && NE_16( *tdm_SM_flag_loc, tmp_SM_flag ) )
{
*tdm_SM_flag_loc = !( *tdm_SM_flag_loc );
@@ -1130,25 +1150,25 @@ static void NOOP_decision_fx(
static Word32 Comp_diff_lt_corr_fx(
CPE_ENC_HANDLE hCPE,
- const Word16 IsSideMono,
- const Word32 rms_L,
+ const Word16 IsSideMono, /* Q0 */
+ const Word32 rms_L, /* q_rms_L */
const Word16 q_rms_L,
- const Word32 rms_R,
+ const Word32 rms_R, /* q_rms_R */
const Word16 q_rms_R,
- const Word32 ener_L_dt,
- const Word32 ener_R_dt,
- Word32 corr_LM,
+ const Word32 ener_L_dt, /* Q16 */
+ const Word32 ener_R_dt, /* Q16 */
+ Word32 corr_LM, /* q_corr_LM */
Word16 q_corr_LM,
- Word32 corr_RM,
+ Word32 corr_RM, /* q_corr_RM */
Word16 q_corr_RM,
- const Word32 tdm_lt_rms_L,
- const Word32 tdm_lt_rms_R,
- Word32 *tdm_lt_corr_LM,
- Word32 *tdm_lt_corr_RM,
- Word32 *tdm_last_diff_lt_corr,
+ const Word32 tdm_lt_rms_L, /* Q16 */
+ const Word32 tdm_lt_rms_R, /* Q16 */
+ Word32 *tdm_lt_corr_LM, /* Q24 */
+ Word32 *tdm_lt_corr_RM, /* Q24 */
+ Word32 *tdm_last_diff_lt_corr, /* q_tdm_last_diff_lt_corr */
Word16 *q_tdm_last_diff_lt_corr,
- Word32 *inst_ratio_L_out,
- Word32 *diff_lt_corr,
+ Word32 *inst_ratio_L_out, /* Q24 */
+ Word32 *diff_lt_corr, /* q_d_lt_corr_raw */
Word16 *q_d_lt_corr_raw )
{
Encoder_State **sts;
@@ -1177,7 +1197,9 @@ static Word32 Comp_diff_lt_corr_fx(
* adaptation rate factor is lower. This prevent stereo image
* move on speech offset
*----------------------------------------------------------------*/
-
+ test();
+ test();
+ test();
IF( IsSideMono == 0 && EQ_16( hCPE->hStereoClassif->lrtd_mode, 1 ) && ( GT_32( L_shr( tdm_lt_rms_R, Q1 ), tdm_lt_rms_L ) || GT_32( L_shr( tdm_lt_rms_L, Q1 ), tdm_lt_rms_R ) ) )
{
adaprate_fx = L_add( Mpy_32_32( M_ADAP_FX_Q31, L_max( tdm_lt_rms_R, tdm_lt_rms_L ) ), B_ADAP_FX_Q16 ); // Q16
@@ -1193,7 +1215,10 @@ static Word32 Comp_diff_lt_corr_fx(
* In case of unvoiced content (expect when it is part of an onset),
* the adaptation rate is minimal.
*----------------------------------------------------------------*/
-
+ test();
+ test();
+ test();
+ test();
IF( GT_16( sts[0]->ini_frame, 2 ) &&
( ( LE_16( sts[0]->last_clas, VOICED_TRANSITION ) && sts[0]->hVAD->hangover_cnt == 0 ) ||
( LE_16( sts[1]->last_clas, VOICED_TRANSITION ) && sts[1]->hVAD->hangover_cnt == 0 ) ) )
@@ -1203,9 +1228,14 @@ static Word32 Comp_diff_lt_corr_fx(
d_lt_corr_raw_fx = 0;
move32();
+
IF( IsSideMono == 0 )
{
- if ( NE_16( hCPE->last_element_mode, IVAS_CPE_TD ) || ( ( LT_32( tdm_lt_rms_R, ONE_IN_Q16 ) || LT_32( tdm_lt_rms_L, ONE_IN_Q16 ) ) && EQ_16( hCPE->hStereoClassif->lrtd_mode, 1 ) && LT_32( L_max( tdm_lt_rms_R, tdm_lt_rms_L ), TEN_IN_Q16 ) ) )
+ test();
+ test();
+ test();
+ test();
+ IF( NE_16( hCPE->last_element_mode, IVAS_CPE_TD ) || ( ( LT_32( tdm_lt_rms_R, ONE_IN_Q16 ) || LT_32( tdm_lt_rms_L, ONE_IN_Q16 ) ) && EQ_16( hCPE->hStereoClassif->lrtd_mode, 1 ) && LT_32( L_max( tdm_lt_rms_R, tdm_lt_rms_L ), TEN_IN_Q16 ) ) )
{
adaprate_fx = 64225; /* 0.98f in Q16 */ /* speed up the adaptation of the long term values to the current values after coming from DFT */
move32();
@@ -1242,13 +1272,13 @@ static Word32 Comp_diff_lt_corr_fx(
corr_LM = BASOP_Util_Add_Mant32Exp( Mpy_32_32( adaprate_fx, corr_LM ), sub( Q31, sub( q_corr_LM, Q15 ) ), Mpy_32_32( madaprate_fx, *tdm_lt_corr_LM ), Q31 - Q9, &exp_diff ); // Q31 - exp_diff
q_corr_LM = sub( Q31, exp_diff );
- L_tmp = Mpy_32_32( ALP_REF_FX_Q31, *tdm_lt_corr_LM ); // Q24
- L_tmp1 = Mpy_32_32( BET_REF_FX_Q31, corr_LM ); // q_corr_LM
- diff_lt_corr_LM_tmp_fx = BASOP_Util_Add_Mant32Exp( L_tmp, Q31 - Q24, L_tmp1, sub( Q31, q_corr_LM ), &exp_diff );
+ L_tmp = Mpy_32_32( ALP_REF_FX_Q31, *tdm_lt_corr_LM ); // Q24
+ L_tmp1 = Mpy_32_32( BET_REF_FX_Q31, corr_LM ); // q_corr_LM
+ diff_lt_corr_LM_tmp_fx = BASOP_Util_Add_Mant32Exp( L_tmp, Q31 - Q24, L_tmp1, sub( Q31, q_corr_LM ), &exp_diff ); /* Q31-exp_diff */
q_diff_lt_corr_LM_tmp = sub( Q31, exp_diff );
- L_tmp = Mpy_32_32( ALP_REF_FX_Q31, *tdm_lt_corr_RM ); // Q24
- L_tmp1 = Mpy_32_32( BET_REF_FX_Q31, corr_RM ); // q_corr_RM
- diff_lt_corr_RM_tmp_fx = BASOP_Util_Add_Mant32Exp( L_tmp, Q31 - Q24, L_tmp1, sub( Q31, q_corr_RM ), &exp_diff );
+ L_tmp = Mpy_32_32( ALP_REF_FX_Q31, *tdm_lt_corr_RM ); // Q24
+ L_tmp1 = Mpy_32_32( BET_REF_FX_Q31, corr_RM ); // q_corr_RM
+ diff_lt_corr_RM_tmp_fx = BASOP_Util_Add_Mant32Exp( L_tmp, Q31 - Q24, L_tmp1, sub( Q31, q_corr_RM ), &exp_diff ); /* Q31-exp_diff */
q_diff_lt_corr_RM_tmp = sub( Q31, exp_diff );
diff_lt_corr_tmp_fx = BASOP_Util_Add_Mant32Exp( diff_lt_corr_LM_tmp_fx, sub( Q31, q_diff_lt_corr_LM_tmp ), L_negate( diff_lt_corr_RM_tmp_fx ), sub( Q31, q_diff_lt_corr_RM_tmp ), &exp_diff ); // (Q31 - exp_diff)
q_diff_lt_corr_tmp = sub( Q31, exp_diff );
@@ -1267,7 +1297,7 @@ static Word32 Comp_diff_lt_corr_fx(
move16();
shift = sub( q_d_lt_corr, Q31 );
}
- *tdm_last_diff_lt_corr = diff_lt_corr_tmp_fx;
+ *tdm_last_diff_lt_corr = diff_lt_corr_tmp_fx; /* q_tdm_last_diff_lt_corr */
move32();
*q_tdm_last_diff_lt_corr = q_diff_lt_corr_tmp;
move16();
@@ -1275,7 +1305,18 @@ static Word32 Comp_diff_lt_corr_fx(
/*----------------------------------------------------------------*
* Correct the estimation depending of channels energies evolution
*----------------------------------------------------------------*/
-
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
IF( EQ_16( IsSideMono, 1 ) &&
( ( LT_32( L_shl( rms_L, sub( Q21, q_rms_L ) ), RMS_MIN2_FX_Q21 ) &&
LT_32( L_shl( rms_R, sub( Q21, q_rms_R ) ), RMS_MIN2_FX_Q21 ) ) &&
@@ -1307,9 +1348,9 @@ static Word32 Comp_diff_lt_corr_fx(
)
{
/* Use estimated results */
- *tdm_lt_corr_LM = L_shl( diff_lt_corr_LM_tmp_fx, sub( Q24, q_diff_lt_corr_LM_tmp ) );
+ *tdm_lt_corr_LM = L_shl( diff_lt_corr_LM_tmp_fx, sub( Q24, q_diff_lt_corr_LM_tmp ) ); /* Q24 */
move32();
- *tdm_lt_corr_RM = L_shl( diff_lt_corr_RM_tmp_fx, sub( Q24, q_diff_lt_corr_RM_tmp ) );
+ *tdm_lt_corr_RM = L_shl( diff_lt_corr_RM_tmp_fx, sub( Q24, q_diff_lt_corr_RM_tmp ) ); /* Q24 */
move32();
}
ELSE
@@ -1340,23 +1381,26 @@ static Word32 Comp_diff_lt_corr_fx(
*-------------------------------------------------------------------*/
static Word16 limit_idx_Dwnmix_fx(
- const Word16 idx_in,
- const Word16 unclr_decision,
- const Word16 inst_idx,
- const Word16 previous_idx,
- const Word16 tdm_last_LRTD_PriCh_cnt,
- const Word16 tdm_last_LRTD_frame_cnt )
+ const Word16 idx_in, /* Q0 */
+ const Word16 unclr_decision, /* Q0 */
+ const Word16 inst_idx, /* Q0 */
+ const Word16 previous_idx, /* Q0 */
+ const Word16 tdm_last_LRTD_PriCh_cnt, /* Q0 */
+ const Word16 tdm_last_LRTD_frame_cnt /* Q0 */ )
{
Word16 idx;
idx = idx_in;
move16();
- idx = check_bounds_s_fx( idx, 1, 29 );
+ idx = check_bounds_s_fx( idx, 1, 29 ); /* Q0 */
+ test();
IF( EQ_16( unclr_decision, 1 ) && GT_16( tdm_last_LRTD_frame_cnt, 1 ) )
{
IF( tdm_last_LRTD_PriCh_cnt > 0 )
{
+ test();
+ test();
IF( LE_16( idx, LRTD_STEREO_MID_IS_PRIM ) && LT_16( inst_idx, LRTD_STEREO_MID_IS_PRIM + 2 ) )
{
idx = s_min( 1, idx );
@@ -1386,7 +1430,7 @@ static Word16 limit_idx_Dwnmix_fx(
}
}
- return idx;
+ return idx; /* Q0 */
}
@@ -1396,9 +1440,9 @@ static Word16 limit_idx_Dwnmix_fx(
*-------------------------------------------------------------------*/
static Word16 limit_idx_NoDwnmix_fx(
- const Word16 idx_in, /* i : Index */
- const Word16 side_can_change, /* i : Primary and secondary channel allowed to change ? */
- const Word32 d_lt_corr_raw, /* i : Raw corrrelation differences */
+ const Word16 idx_in, /* i : Index Q0*/
+ const Word16 side_can_change, /* i : Primary and secondary channel allowed to change ? Q0*/
+ const Word32 d_lt_corr_raw, /* i : Raw corrrelation differences q_d_lt_corr_raw*/
const Word16 q_d_lt_corr_raw /* i : Q-factor of Raw corrrelation differences */
)
{
@@ -1406,11 +1450,14 @@ static Word16 limit_idx_NoDwnmix_fx(
idx = idx_in;
move16();
+
+ test();
+ test();
IF( side_can_change == 0 && GT_16( idx_in, 10 ) && LT_16( idx_in, 20 ) )
{
idx = 30;
move16();
- if ( LT_32( d_lt_corr_raw, L_negate( L_shl( 214748365 /* 0.1f in Q31 */, sub( q_d_lt_corr_raw, Q31 ) ) ) ) )
+ IF( LT_32( d_lt_corr_raw, L_negate( L_shl( 214748365 /* 0.1f in Q31 */, sub( q_d_lt_corr_raw, Q31 ) ) ) ) )
{
idx = 0;
move16();
@@ -1430,7 +1477,7 @@ static Word16 limit_idx_NoDwnmix_fx(
}
}
- return idx;
+ return idx; /* Q0 */
}
@@ -1443,8 +1490,8 @@ static Word16 limit_idx_NoDwnmix_fx(
static Word16 stereo_tdm_ener_analysis_SM_fx(
CPE_ENC_HANDLE hCPE, /* i : CPE encoder structure */
Encoder_State **sts, /* i/o: Encoder static variables structure */
- const Word16 input_frame, /* i : Number of samples */
- Word16 *tdm_SM_flag /* i/o: channel combination scheme flag */
+ const Word16 input_frame, /* i : Number of samples Q0*/
+ Word16 *tdm_SM_flag /* i/o: channel combination scheme flag Q0*/
)
{
Word32 rms_R_fx, rms_L_fx;
@@ -1473,7 +1520,7 @@ static Word16 stereo_tdm_ener_analysis_SM_fx(
*----------------------------------------------------------------*/
/* Simple logic to set SM flag, should be done in the frequency domain for low SM correlation signal, especially for music item such as Music_1_org_s */
- tdm_SM_flag_loc = hStereoTD->tdm_last_SM_flag_noop;
+ tdm_SM_flag_loc = hStereoTD->tdm_last_SM_flag_noop; /* Q0 */
move16();
/*----------------------------------------------------------------*
@@ -1515,27 +1562,38 @@ static Word16 stereo_tdm_ener_analysis_SM_fx(
* When the energies of channels are low enough, compute the ratio
* of L and R needed to create new mono/side signals
*----------------------------------------------------------------*/
-
+ test();
+ test();
+ test();
IF( ( LE_32( L_shl( hStereoTD->tdm_lt_rms_L_SM_fx, Q20 - Q24 ), RMS_MIN_FX_Q20 ) && LE_32( L_shl( hStereoTD->tdm_lt_rms_R_SM_fx, Q19 /* adjusted for 2 in RHS */ - Q24 ), RMS_MIN_FX_Q20 ) ) ||
- ( LE_32( L_shl( hStereoTD->tdm_lt_rms_R_SM_fx, Q20 - Q24 ), RMS_MIN_FX_Q20 ) && LE_32( L_shl( hStereoTD->tdm_lt_rms_L_SM_fx, Q19 /* adjusted for 2 in RHS */ - Q24 ), RMS_MIN_FX_Q20 ) ) )
+ ( LE_32( L_shl( hStereoTD->tdm_lt_rms_R_SM_fx, Q20 - Q24 ), RMS_MIN_FX_Q20 ) && LE_32( L_shl( hStereoTD->tdm_lt_rms_L_SM_fx, Q19 /* adjusted for 2 in RHS */ - Q24 ), RMS_MIN_FX_Q20 ) ) ) /* Q20 */
{
- if ( ( LT_16( sts[0]->old_corr_fx, CORR_THRES_FX_Q15 ) && LT_16( sts[1]->old_corr_fx, CORR_THRES_FX_Q15 ) ) ||
- ( LE_32( L_shl( hStereoTD->tdm_lt_rms_L_SM_fx, Q21 - Q24 ), RMS_MIN2_FX_Q21 ) && LE_32( L_shl( hStereoTD->tdm_lt_rms_R_SM_fx, Q21 - Q24 ), RMS_MIN2_FX_Q21 ) ) )
+ test();
+ test();
+ test();
+ IF( ( LT_16( sts[0]->old_corr_fx, CORR_THRES_FX_Q15 ) && LT_16( sts[1]->old_corr_fx, CORR_THRES_FX_Q15 ) ) ||
+ ( LE_32( L_shl( hStereoTD->tdm_lt_rms_L_SM_fx, Q21 - Q24 ), RMS_MIN2_FX_Q21 ) && LE_32( L_shl( hStereoTD->tdm_lt_rms_R_SM_fx, Q21 - Q24 ), RMS_MIN2_FX_Q21 ) ) )
{
side_can_change = 1;
move16();
}
}
+ test();
+ test();
+ test();
IF( ( LE_32( L_shl( hStereoTD->tdm_lt_rms_L_SM_fx, Q21 - Q24 ), RMS_MIN2_FX_Q21 ) && LE_32( L_shl( hStereoTD->tdm_lt_rms_R_SM_fx, Q20 /* adjusted for 2 in RHS */ - Q24 ), RMS_MIN2_FX_Q21 ) ) ||
- ( LE_32( L_shl( hStereoTD->tdm_lt_rms_R_SM_fx, Q21 - Q24 ), RMS_MIN2_FX_Q21 ) && LE_32( L_shl( hStereoTD->tdm_lt_rms_L_SM_fx, Q20 /* adjusted for 2 in RHS */ - Q24 ), RMS_MIN2_FX_Q21 ) ) )
+ ( LE_32( L_shl( hStereoTD->tdm_lt_rms_R_SM_fx, Q21 - Q24 ), RMS_MIN2_FX_Q21 ) && LE_32( L_shl( hStereoTD->tdm_lt_rms_L_SM_fx, Q20 /* adjusted for 2 in RHS */ - Q24 ), RMS_MIN2_FX_Q21 ) ) ) /* Q21 */
{
+ test();
+ test();
+ test();
IF( ( ( NE_16( hStereoTD->tdm_last_SM_flag_noop, tdm_SM_flag_loc ) ) && hStereoTD->tdm_noop_cnt == 0 ) ||
EQ_16( hStereoTD->tdm_noop_mov_flag, 1 ) || NE_16( hStereoTD->tdm_prev_desired_idx_SM, hStereoTD->tdm_prev_stable_idx_SM ) )
{
hStereoTD->tdm_noop_mov_flag = 1;
move16();
- if ( hStereoTD->tdm_last_ratio_idx_SM != 0 && NE_16( hStereoTD->tdm_last_ratio_idx_SM, ( TDM_NQ - 1 ) ) )
+ IF( hStereoTD->tdm_last_ratio_idx_SM != 0 && NE_16( hStereoTD->tdm_last_ratio_idx_SM, ( TDM_NQ - 1 ) ) )
{
side_can_change = 1;
move16();
@@ -1543,7 +1601,8 @@ static Word16 stereo_tdm_ener_analysis_SM_fx(
}
}
- if ( side_can_change == 0 && EQ_16( tdm_SM_flag_loc, 1 ) && GT_32( es_em_fx, 31457280 /* 15.0f in Q21 */ ) )
+ test();
+ IF( side_can_change == 0 && EQ_16( tdm_SM_flag_loc, 1 ) && GT_32( es_em_fx, 31457280 /* 15.0f in Q21 */ ) )
{
side_can_change = 1;
move16();
@@ -1584,7 +1643,7 @@ static Word16 stereo_tdm_ener_analysis_SM_fx(
}
}
- idx = stereo_smooth_LR_transition_fx( &hStereoTD->tdm_prev_stable_idx_SM, &hStereoTD->tdm_noop_mov_flag, hStereoTD->tdm_last_ratio_idx_SM, &hStereoTD->tdm_prev_desired_idx_SM, &hStereoTD->tdm_noop_cnt, tdm_SM_flag_loc, desired_idx );
+ idx = stereo_smooth_LR_transition_fx( &hStereoTD->tdm_prev_stable_idx_SM, &hStereoTD->tdm_noop_mov_flag, hStereoTD->tdm_last_ratio_idx_SM, &hStereoTD->tdm_prev_desired_idx_SM, &hStereoTD->tdm_noop_cnt, tdm_SM_flag_loc, desired_idx ); /* Q0 */
idx = extract_l( L_add( Mpy_32_32( 1717986918 /* 0.8f in Q31 */, idx ), Mpy_32_32( 429496729 /* 0.2f in Q31 */, hStereoTD->tdm_last_ratio_idx_SM ) ) ); // (Q31, Q0) -> Q0
@@ -1598,6 +1657,9 @@ static Word16 stereo_tdm_ener_analysis_SM_fx(
move16();
}
+ test();
+ test();
+ test();
IF( ( EQ_16( hStereoTD->tdm_noop_mov_flag, 1 ) && GE_16( hStereoTD->tdm_noop_cnt, 31 ) ) || ( ( EQ_16( hStereoTD->tdm_last_SM_flag_noop, tdm_SM_flag_loc ) ) && ( EQ_16( idx, hStereoTD->tdm_prev_stable_idx_SM ) ) ) )
{
hStereoTD->tdm_noop_cnt = 0;
@@ -1606,6 +1668,7 @@ static Word16 stereo_tdm_ener_analysis_SM_fx(
move16();
}
+ test();
if ( hStereoTD->tdm_noop_mov_flag == 0 || tdm_SM_flag_loc == 0 )
{
hStereoTD->tdm_prev_stable_idx_SM = idx;
@@ -1634,11 +1697,11 @@ Word16 tdm_lp_comparison_fx(
Word32 *speech_buff, /* i : Current speech frame Q_speech */
const Word16 *A_PCh_fx, /* i : primary channel LP coefficients Q12*/
const Word16 *A_SCh_fx, /* i : secondary channel LP coeff. Q12*/
- const Word16 m, /* i : filter length */
+ const Word16 m, /* i : filter length Q0*/
const Word16 *isp_PCh_fx, /* i : primary channel LSPs Q15 */
const Word16 *isp_SCh_fx, /* i : secondary channel LSPs Q15 */
- const Word16 L_frame, /* i : frame length */
- const Word32 element_brate_wo_meta, /* i : element bitrate without metadata*/
+ const Word16 L_frame, /* i : frame length Q0*/
+ const Word32 element_brate_wo_meta, /* i : element bitrate without metadata Q0*/
Word16 Q_speech )
{
Word32 ener_sig_fx, pred_gain_reuse_PCh_fx, log10_fx, predgain_SCh_fx;
@@ -1657,7 +1720,7 @@ 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 );
+ scale_sig32( speech_buff, L_FRAME + M, gb1 ); /* Q_speech + gb1 */
Word16 exp = sub( 31, 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*/
@@ -1666,28 +1729,28 @@ Word16 tdm_lp_comparison_fx(
exp = -5;
move16();
}
- sum2_value = BASOP_Util_Add_Mant32Exp( sum2_value, exp, 328, Q31 - Q15, &exp );
- Word32 temp32_log = L_add( BASOP_Util_Log2( sum2_value ), L_shl( sub( Q31, sub( 31, exp ) ), Q25 ) );
- ener_sig_fx = Mpy_32_32( temp32_log, 646456623 ); // Q25
+ sum2_value = BASOP_Util_Add_Mant32Exp( sum2_value, exp, 328, Q16, &exp ); /* Q31-exp */
+ 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 ) );
- 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, Q31 - Q15, &exp );
- temp32_log = L_add( BASOP_Util_Log2( sum2_value ), L_shl( sub( Q31, sub( 31, exp ) ), Q25 ) );
- log10_fx = Mpy_32_32( temp32_log, 646456623 ); // Q25
- predgain_SCh_fx = Mpy_32_32( L_sub( ener_sig_fx, log10_fx ), 1342177280 ); // Q27+Q25-31 = Q21
+ 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 */
+ log10_fx = Mpy_32_32( temp32_log, 646456623 ); // Q25
+ predgain_SCh_fx = Mpy_32_32( L_sub( ener_sig_fx, log10_fx ), 1342177280 ); // Q27+Q25-31 = Q21
// pred_gain_reuse_PCh = 10.0f * ( ener_sig - log10f( sum2_f( res, L_frame ) + 0.01f ) );
// predgain_SCh = 10.0f * ( ener_sig - log10f( sum2_f( res, L_frame ) + 0.01f ) );
/* 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 ) );
+ scale_sig32( speech_buff, L_FRAME + M, negate( gb1 ) ); /* 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 ) );
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, Q31 - Q15, &exp );
- temp32_log = L_add( BASOP_Util_Log2( sum2_value ), L_shl( sub( Q31, sub( 31, exp ) ), Q25 ) );
- log10_fx = Mpy_32_32( temp32_log, 646456623 ); // Q25
+ 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 */
+ log10_fx = Mpy_32_32( temp32_log, 646456623 ); // Q25
pred_gain_reuse_PCh_fx = Mpy_32_32( L_sub( ener_sig_fx, log10_fx ), 1342177280 ); // Q27+Q25-31 = Q21
// pred_gain_reuse_PCh = 10.0f * ( ener_sig - log10f( sum2_f( res, L_frame ) + 0.01f ) );
@@ -1699,7 +1762,7 @@ Word16 tdm_lp_comparison_fx(
FOR( i = 0; i < m; i++ )
{
// ftmp = isp_SCh[i] - isp_PCh[i];
- ftmp_fx = L_deposit_h( sub( isp_SCh_fx[i], isp_PCh_fx[i] ) );
+ ftmp_fx = L_deposit_h( sub( isp_SCh_fx[i], isp_PCh_fx[i] ) ); /* Q31 */
// dist += ftmp * ftmp;
dist_fx = L_add( dist_fx, L_shr( Mpy_32_32( ftmp_fx, ftmp_fx ), gb ) ); // Q31-gb
}
@@ -1738,9 +1801,9 @@ Word16 tdm_lp_comparison_fx(
test();
test();
- if ( ( GE_32( element_brate_wo_meta, IVAS_48k ) && !( GE_32( pred_gain_reuse_PCh_fx, Mpy_32_32( RATIO_PG_HR_FX, predgain_SCh_fx ) ) && LT_32( dist_fx, L_shr( EUCLDST_FX, gb ) ) ) ) ||
- ( EQ_16( hStereoClassif->lrtd_mode, 1 ) && LT_32( element_brate_wo_meta, IVAS_16k4 ) && !( GE_32( pred_gain_reuse_PCh_fx, Mpy_32_32( RATIO_PG_HR_FX, predgain_SCh_fx ) ) && LT_32( dist_fx, L_shr( EUCLDST_FX, add( gb, 1 ) ) ) ) ) ||
- ( EQ_16( hStereoClassif->lrtd_mode, 1 ) && GE_32( element_brate_wo_meta, IVAS_16k4 ) && !( GE_32( pred_gain_reuse_PCh_fx, Mpy_32_32( RATIO_PG_LRTD_FX, predgain_SCh_fx ) ) && LT_32( dist_fx, L_shr( EUCLDST_FX, gb + 2 ) ) ) ) || st->tc_cnt > 0 )
+ IF( ( GE_32( element_brate_wo_meta, IVAS_48k ) && !( GE_32( pred_gain_reuse_PCh_fx, Mpy_32_32( RATIO_PG_HR_FX, predgain_SCh_fx ) ) && LT_32( dist_fx, L_shr( EUCLDST_FX, gb ) ) ) ) ||
+ ( EQ_16( hStereoClassif->lrtd_mode, 1 ) && LT_32( element_brate_wo_meta, IVAS_16k4 ) && !( GE_32( pred_gain_reuse_PCh_fx, Mpy_32_32( RATIO_PG_HR_FX, predgain_SCh_fx ) ) && LT_32( dist_fx, L_shr( EUCLDST_FX, add( gb, 1 ) ) ) ) ) ||
+ ( EQ_16( hStereoClassif->lrtd_mode, 1 ) && GE_32( element_brate_wo_meta, IVAS_16k4 ) && !( GE_32( pred_gain_reuse_PCh_fx, Mpy_32_32( RATIO_PG_LRTD_FX, predgain_SCh_fx ) ) && LT_32( dist_fx, L_shr( EUCLDST_FX, gb + 2 ) ) ) ) || st->tc_cnt > 0 )
{
LP_mode = 0;
move16();
@@ -1776,14 +1839,14 @@ void tdm_ol_pitch_comparison_fx(
st0 = hCPE->hCoreCoder[0]; /* Encoder structure - primary channel */
st1 = hCPE->hCoreCoder[1]; /* Encoder structure - secondary channel */
- if ( GT_32( hCPE->element_brate, IVAS_13k2 ) )
+ IF( GT_32( hCPE->element_brate, IVAS_13k2 ) )
{
diff_thr = 3;
move16();
}
test();
- if ( GE_32( hCPE->element_brate, IVAS_48k ) || EQ_16( hCPE->hStereoTD->tdm_LRTD_flag, 1 ) )
+ IF( GE_32( hCPE->element_brate, IVAS_48k ) || EQ_16( hCPE->hStereoTD->tdm_LRTD_flag, 1 ) )
{
diff_thr = 1;
move16();
@@ -1819,12 +1882,12 @@ void tdm_ol_pitch_comparison_fx(
test();
IF( GE_16( voicmin[0], 29491 /* 0.9f in Q15 */ ) && GE_16( voicmin[1], 29491 /* 0.9f in Q15 */ ) && GE_16( voicmin[2], 27853 /* 0.85f in Q15 */ ) && GE_16( voicmin[3], 27853 /* 0.85f in Q15 */ ) )
{
- tmp_diff = add( abs_s( sub( st0->pitch[0], st1->pitch[0] ) ), add( abs_s( sub( st0->pitch[1], st1->pitch[1] ) ), abs_s( sub( st0->pitch[2], st1->pitch[2] ) ) ) );
+ tmp_diff = add( abs_s( sub( st0->pitch[0], st1->pitch[0] ) ), add( abs_s( sub( st0->pitch[1], st1->pitch[1] ) ), abs_s( sub( st0->pitch[2], st1->pitch[2] ) ) ) ); /* Q0 */
}
}
ELSE
{
- tmp_diff = abs_s( sub( add( st0->pitch[0], add( st0->pitch[1], st0->pitch[2] ) ), add( st1->pitch[0], add( st1->pitch[1], st1->pitch[2] ) ) ) );
+ tmp_diff = abs_s( sub( add( st0->pitch[0], add( st0->pitch[1], st0->pitch[2] ) ), add( st1->pitch[0], add( st1->pitch[1], st1->pitch[2] ) ) ) ); /* Q0 */
}
IF( LE_16( tmp_diff, diff_thr ) )
@@ -1833,23 +1896,23 @@ void tdm_ol_pitch_comparison_fx(
move16();
/* 1/4 pitch precision update*/
- Copy( st0->pitch, st1->pitch, 3 );
- Copy( st0->voicing_fx, st1->voicing_fx, 3 );
+ Copy( st0->pitch, st1->pitch, 3 ); /* Q0 */
+ Copy( st0->voicing_fx, st1->voicing_fx, 3 ); /* Q15 */
/* Update some parameters accordingly */
- st1->old_corr_fx = st0->old_corr_fx;
- st1->old_thres_fx = st0->old_thres_fx;
- st1->delta_pit = st0->delta_pit;
+ st1->old_corr_fx = st0->old_corr_fx; /* Q15 */
+ st1->old_thres_fx = st0->old_thres_fx; /* Q15 */
+ st1->delta_pit = st0->delta_pit; /* Q0 */
move16();
move16();
move16();
/* Updates for adaptive lag window memory */
- st1->old_pitch_la = st0->old_pitch_la;
+ st1->old_pitch_la = st0->old_pitch_la; /* Q0 */
move16();
/* 1/4 pitch precision update*/
- Copy( pitch_fr[0], pitch_fr[1], NB_SUBFR );
- Copy( voicing_fr[0], voicing_fr[1], NB_SUBFR );
+ Copy( pitch_fr[0], pitch_fr[1], NB_SUBFR ); /* Q6 */
+ Copy( voicing_fr[0], voicing_fr[1], NB_SUBFR ); /* Q15 */
}
}
@@ -1863,15 +1926,15 @@ void tdm_ol_pitch_comparison_fx(
*-------------------------------------------------------------------*/
static void Get_corr_n_fx(
- const Word16 L[], /* i : Left signal */
- const Word16 R[], /* i : Right signal */
- Word32 *ic_Lm, /* o : Left signal */
+ const Word16 L[], /* i : Left signal q_in*/
+ const Word16 R[], /* i : Right signal q_in*/
+ Word32 *ic_Lm, /* o : Left signal q_ic_Lm*/
Word16 *q_ic_Lm, /* o : Q factor of Left signal */
- Word32 *ic_Rm, /* o : Right signal */
+ Word32 *ic_Rm, /* o : Right signal q_ic_Rm*/
Word16 *q_ic_Rm, /* o : Q factor of Right signal */
- const Word16 len, /* i : segment length */
+ const Word16 len, /* i : segment length Q0*/
Word32 *es_em, /* o : return the difference between the side and mono energy */
- const Word16 tdm_SM_calc_flag /* i : Flag that indicates that it is for SM mode */
+ const Word16 tdm_SM_calc_flag /* i : Flag that indicates that it is for SM mode Q0*/
)
{
Word32 corrL, corrR, ener;
@@ -1892,7 +1955,7 @@ static void Get_corr_n_fx(
move64();
W_ener_side = EPSILON_FX;
move64();
- guard_bits = sub( 32, find_guarded_bits_fx( len ) );
+ guard_bits = sub( 32, find_guarded_bits_fx( len ) ); /* Q0 */
/*----------------------------------------------------------------*
* Find the normalized correlation between: left/mono and right/mono based
@@ -1910,8 +1973,8 @@ static void Get_corr_n_fx(
W_ener_side = W_mac0_16_16( W_ener_side, side_i, side_i ); // (q_in + q_in )
}
/* Scaling back to the original proposal */
- corrL = W_extract_h( W_shl( W_corrL, guard_bits ) );
- corrR = W_extract_h( W_shl( W_corrR, guard_bits ) );
+ corrL = W_extract_h( W_shl( W_corrL, guard_bits ) ); /* 2*q_in + guard_bits - 32 */
+ corrR = W_extract_h( W_shl( W_corrR, guard_bits ) ); /* 2*q_in + guard_bits - 32 */
ener = W_extract_h( W_shl( W_ener, guard_bits ) );
ener_side = W_extract_h( W_shl( W_ener_side, guard_bits ) );
}
@@ -1927,8 +1990,8 @@ static void Get_corr_n_fx(
W_ener_side = W_mac0_16_16( W_ener_side, side_i, side_i ); // (q_in + q_in )
}
/* Scaling back to the original proposal */
- corrL = W_extract_h( W_shl( W_corrL, guard_bits ) );
- corrR = W_extract_h( W_shl( W_corrR, guard_bits ) );
+ corrL = W_extract_h( W_shl( W_corrL, guard_bits ) ); /* 2*q_in + guard_bits - 32 */
+ corrR = W_extract_h( W_shl( W_corrR, guard_bits ) ); /* 2*q_in + guard_bits - 32 */
ener = W_extract_h( W_shl( W_ener, guard_bits ) );
ener_side = W_extract_h( W_shl( W_ener_side, guard_bits ) );
}
@@ -1976,9 +2039,9 @@ static void Get_corr_n_fx(
/* *es_em = 10 * ( log10f( sqrtf( ener_side / len ) ) - log10f( sqrtf( ener / len ) ) );
is simplified to
*es_em = 10 * ( log10f( sqrtf( ener_side / ener ) ) ); */
- L_tmp = BASOP_Util_Divide3232_Scale_cadence( ener_side, ener, &exp_diff ); // (Q31 - exp_diff)
- L_tmp = Sqrt32( L_tmp, &exp_diff );
- L_tmp = BASOP_Util_Log2( L_tmp );
+ L_tmp = BASOP_Util_Divide3232_Scale_cadence( ener_side, ener, &exp_diff ); // (Q31 - exp_diff)
+ L_tmp = Sqrt32( L_tmp, &exp_diff ); /* (Q31 - exp_diff) */
+ L_tmp = BASOP_Util_Log2( L_tmp ); /* Q25 */
*es_em = Mpy_32_32( Mpy_32_32( L_add( L_tmp, L_shl( exp_diff, Q25 ) ), LOG10_2_Q31 ), TEN_IN_Q27 ); // (Q25, Q27) -> Q21
move32();
}
@@ -1994,24 +2057,24 @@ static void Get_corr_n_fx(
/*! r: smoothed position */
static Word16 stereo_smooth_LR_transition_fx(
- Word16 *tdm_prev_stable_idx, /* i/o: Previous Transmitted ratio index */
- Word16 *tdm_ratio_transition_mov_flag, /* i/o: Flag that indicates that L-R energy is changing */
- Word16 tdm_last_ratio_idx, /* i : last TDM ratio index */
- Word16 *tdm_prev_desired_idx, /* i/o: Previous Transmitted ratio index */
- Word16 *tdm_ratio_transition_cnt, /* i/o: Counter */
- const Word16 tdm_SM_flag, /* i : channel combination scheme flag for current frame */
- Word16 desired_idx /* i : desired final position */
+ Word16 *tdm_prev_stable_idx, /* i/o: Previous Transmitted ratio index Q0*/
+ Word16 *tdm_ratio_transition_mov_flag, /* i/o: Flag that indicates that L-R energy is changing Q0*/
+ Word16 tdm_last_ratio_idx, /* i : last TDM ratio index Q0*/
+ Word16 *tdm_prev_desired_idx, /* i/o: Previous Transmitted ratio index Q0*/
+ Word16 *tdm_ratio_transition_cnt, /* i/o: Counter Q0*/
+ const Word16 tdm_SM_flag, /* i : channel combination scheme flag for current frame Q0*/
+ Word16 desired_idx /* i : desired final position Q0*/
)
{
Word16 idx;
- if ( EQ_16( tdm_SM_flag, 1 ) )
+ IF( EQ_16( tdm_SM_flag, 1 ) )
{
desired_idx = 15;
move16();
}
- if ( NE_16( desired_idx, *tdm_prev_stable_idx ) )
+ IF( NE_16( desired_idx, *tdm_prev_stable_idx ) )
{
*tdm_ratio_transition_mov_flag = 1;
move16();
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 b944816a9d18dc9bd1d78318126c41ab82e54c40..f993c8e28b9fe8adf62dd5d298e811440cb09734 100644
--- a/lib_enc/ivas_tcx_core_enc.c
+++ b/lib_enc/ivas_tcx_core_enc.c
@@ -347,7 +347,7 @@ void stereo_tcx_core_enc(
*--------------------------------------------------------------------------------*/
/* TCX20/TCX10 and coder type */
- writeTCXMode( st, hBstr, 0, /* MCT_flag */ &nbits_start );
+ writeTCXMode_fx( st, hBstr, 0, /* MCT_flag */ &nbits_start );
/* write last_core for error concealment */
q_ind_val = 0;
@@ -361,10 +361,10 @@ void stereo_tcx_core_enc(
push_next_indice( hBstr, q_ind_val, 1 );
/* write TCX overlap mode (1 bit: full, 2 bits: half or no overlap) */
- writeTCXWindowing( hBstr, st->hTcxCfg->tcx_curr_overlap_mode );
+ writeTCXWindowing_fx( hBstr, st->hTcxCfg->tcx_curr_overlap_mode );
IF( EQ_16( st->core, TCX_10_CORE ) )
{
- writeTCXWindowing( hBstr, st->hTcxCfg->tcx_last_overlap_mode );
+ writeTCXWindowing_fx( hBstr, st->hTcxCfg->tcx_last_overlap_mode );
}
assert( nbits_header == ( hBstr->nb_bits_tot - nbits_start ) );
@@ -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,13 +579,15 @@ 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 )
{
Scale_sig( st->hTdCngEnc->cng_exc2_buf, HO_HIST_SIZE * L_FFT, sub( add( shl( Q_new, 1 ), s ), Q_exc ) );
}
Q_exc = add( shl( Q_new, 1 ), s ); // 2 * Q_new + s
+ st->hLPDmem->q_lpd_old_exc = Q_exc;
+ move16();
IF( st->enableTcxLpc )
{
@@ -712,12 +714,10 @@ void stereo_tcx_core_enc(
move16();
Scale_sig( st->hLPDmem->mem_syn1_fx, M, sub( s_min( curr_q_syn, st->hLPDmem->q_mem_syn ), st->hLPDmem->q_mem_syn ) );
Scale_sig( st->hLPDmem->mem_syn3, M, sub( s_min( curr_q_syn, st->hLPDmem->q_mem_syn ), st->hLPDmem->q_mem_syn ) );
- st->hLPDmem->q_mem_syn = sub( Q_new, 1 );
+ st->hLPDmem->q_mem_syn = s_min( curr_q_syn, st->hLPDmem->q_mem_syn );
move16();
st->hLPDmem->q_lpd_syn = Q_new;
move16();
- st->hLPDmem->q_lpd_old_exc = Q_new;
- move16();
IF( st->hTdCngEnc != NULL )
{
FOR( Word16 ii = 0; ii < HO_HIST_SIZE; ii++ )
@@ -810,6 +810,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 +872,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 / 2 - 1 - i] = st->hTcxCfg->tcx_mdct_window[i].v.re; // Q15
+ move16();
+ window_fx[i] = st->hTcxCfg->tcx_mdct_window[i].v.im; // Q15
+ move16();
+ }
+#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 +888,7 @@ Word16 ivas_acelp_tcx20_switching_fx(
window_fx[i] = st->hTcxCfg->tcx_mdct_window[i].v.im; // Q15
move16();
}
+#endif
}
ELSE
{
@@ -1060,6 +1077,8 @@ Word16 ivas_acelp_tcx20_switching_fx(
ener = Mpy_32_16_1( Mpy_32_16_1( ener, 0x78AE ), getInvFrameLen( L_frame ) ); /* 0x78AE -> sqrt(2)/12 (Q18) */
ener_e = sub( s, 9 );
+ x_fx = hTcxEnc->spectrum_long_fx;
+
IF( !flag_16k_smc )
{
const Word16 *bands;
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 aa1b6e32b7157d3cf1b90a91f3b9f0d4e2cf6e84..c78fbe10799918dfa6ad4568f8106e6a95e4d51a 100644
--- a/lib_enc/lib_enc.c
+++ b/lib_enc/lib_enc.c
@@ -150,7 +150,7 @@ ivas_error IVAS_ENC_Open(
init_encoder_config( st_ivas->hEncoderConfig );
/* initialize pointers to handles to NULL */
- ivas_initialize_handles_enc( st_ivas );
+ ivas_initialize_handles_enc_fx( st_ivas );
st_ivas->ind_list = NULL;
st_ivas->ind_list_metadata = NULL;
@@ -216,7 +216,7 @@ ivas_error IVAS_ENC_Open_fx(
init_encoder_config( st_ivas->hEncoderConfig );
/* initialize pointers to handles to NULL */
- ivas_initialize_handles_enc( st_ivas );
+ ivas_initialize_handles_enc_fx( st_ivas );
st_ivas->ind_list = NULL;
st_ivas->ind_list_metadata = NULL;
@@ -246,7 +246,7 @@ void IVAS_ENC_Close(
if ( ( *phIvasEnc )->isConfigured )
{
- ivas_destroy_enc( ( *phIvasEnc )->st_ivas );
+ ivas_destroy_enc_fx( ( *phIvasEnc )->st_ivas );
}
else
{
@@ -2690,9 +2690,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 1fd4e0ad06cc523f1125b52761a5fa8ac4ca3894..c23f56df9fe0f33b70c5f0aea620a17003a618e9 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,
IVAS_ENC_FORCE_UNFORCED,
IVAS_ENC_FORCE_UNDEFINED = 0xffff
diff --git a/lib_enc/lp_exc_e_fx.c b/lib_enc/lp_exc_e_fx.c
index 8b9cb113e98d08f0eafbf693ab39722cc3d25917..5afca51365058fb72e26d4760309fa7a683b8f78 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 */
@@ -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..d30f2c24903b67c4f891c7b44bcc45e1c9a7efb5 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 );
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..641c3597988b9854bf2fceb800b79fac1a36dd8f 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] );
@@ -562,11 +548,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 +574,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 +599,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] );
diff --git a/lib_enc/nelp_enc_fx.c b/lib_enc/nelp_enc_fx.c
index 259987bba43611a9f4c89041ea1a1ce51cc65533..a0f123b20e513b3b3c5705c03802cc7b7d6e1de5 100644
--- a/lib_enc/nelp_enc_fx.c
+++ b/lib_enc/nelp_enc_fx.c
@@ -129,13 +129,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 */
@@ -191,25 +186,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 )
{
/*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
}
}
@@ -403,11 +388,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 +404,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 +420,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 +436,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 +450,16 @@ 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
}
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,18 +473,10 @@ 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
IF( EQ_16( reduce_gains, 1 ) )
{
FOR( i = 0; i < 10; i++ )
@@ -641,13 +590,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 );
@@ -694,11 +638,7 @@ 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;
}
@@ -765,11 +705,7 @@ void nelp_encoder_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 = 2 * qGain + 1;
move16();
@@ -831,11 +767,7 @@ 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
}
qf1 = qGain;
@@ -850,11 +782,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 +791,7 @@ 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
}
qf = qGain;
@@ -882,11 +806,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();
@@ -897,12 +817,8 @@ void nelp_encoder_fx(
exp2 = 30 - exp2 - qEL1;
move16();
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
@@ -917,12 +833,8 @@ void nelp_encoder_fx(
exp2 = 30 - ( 30 + qEL1 - qEL2 - exp1 + exp2 );
move16();
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 );
}
@@ -933,12 +845,8 @@ void nelp_encoder_fx(
exp2 = 30 - exp2 - qEH2;
move16();
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
@@ -953,12 +861,8 @@ void nelp_encoder_fx(
exp2 = 30 - ( 30 + qEH1 - qEH2 - exp1 + exp2 );
move16();
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 );
}
@@ -1227,11 +1131,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 +1146,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 +1162,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();
@@ -1286,11 +1178,7 @@ void nelp_encoder_ivas_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); */
@@ -1304,17 +1192,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 +1202,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 +1216,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 +1332,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 +1380,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 +1452,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 +1511,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 +1527,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 +1535,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 +1551,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 +1560,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 +1575,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 +1586,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 +1601,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 );
}
diff --git a/lib_enc/nois_est_fx.c b/lib_enc/nois_est_fx.c
index 2b8bded71038a4a6429a3d3c4721f502e5fe4c25..be86c057424913f23ea51dade79fac65582373e7 100644
--- a/lib_enc/nois_est_fx.c
+++ b/lib_enc/nois_est_fx.c
@@ -92,11 +92,7 @@ static Word16 noise_est_ln_q8_fx(
Flag Overflow = 0;
#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 */
@@ -671,11 +667,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 ) );
@@ -699,11 +691,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*/
@@ -748,6 +736,119 @@ void noise_est_down_fx(
return;
}
+void noise_est_down_ivas_fx(
+ const Word32 fr_bands[], /* i : per band input energy (contains 2 vectors) q_fr_bands */
+ const Word16 q_fr_bands, /* i : Q of fr_bands */
+ Word32 bckr[], /* i/o: per band background noise energy estimate q_fr_bands */
+ Word32 tmpN[], /* o : temporary noise update q_fr_bands */
+ Word32 enr[], /* o : averaged energy over both subframes */
+ const Word16 min_band, /* i : minimum critical band */
+ const Word16 max_band, /* i : maximum critical band */
+ Word16 *totalNoise, /* o : noise estimate over all critical bands */
+ Word16 Etot, /* i : Energy of current frame */
+ Word16 *Etot_last, /* i/o: Energy of last frame Q8 */
+ Word16 *Etot_v_h2 /* i/o: Energy variations of noise frames Q8 */
+)
+
+{
+ Word32 Ltmp, L_tmp;
+ const Word32 *pt1, *pt2;
+ Word16 i;
+ Word16 e_Noise, f_Noise;
+ Word32 e_min;
+ Word32 totalNoise_temp;
+ Word32 L_Etot, L_Etot_last, L_Etot_v_h2, L_Etot_v;
+ Word64 sum;
+ Word16 q_sum;
+
+ e_min = L_shl( E_MIN_FXQ31, sub( q_fr_bands, Q31 ) ); // q_fr_bands
+
+ L_Etot = L_shl( Etot, 16 ); /*Q24 for later AR1 computations*/
+ L_Etot_last = L_shl( *Etot_last, 16 );
+ L_Etot_v_h2 = L_shl( *Etot_v_h2, 16 );
+
+ /*-----------------------------------------------------------------*
+ * Estimate total noise energy
+ *-----------------------------------------------------------------*/
+
+ totalNoise_temp = L_deposit_l( 0 );
+ sum = 0;
+ move64();
+ FOR( i = min_band; i <= max_band; i++ )
+ {
+ sum = W_mac_32_16( sum, bckr[i], 1 ); // q_fr_bands+1
+ }
+ q_sum = add( q_fr_bands, 1 );
+ IF( sum == 0 )
+ {
+ sum = W_mult0_32_32( E_MIN_FXQ31, add( sub( max_band, min_band ), 1 ) ); // Q31
+ q_sum = Q31;
+ move16();
+ }
+ e_Noise = W_norm( sum );
+ totalNoise_temp = W_extract_h( W_shl( sum, e_Noise ) ); // q_sum+e_Noise-32
+ e_Noise = sub( 63, add( e_Noise, q_sum ) ); // 31-(q_sum+e_Noise-32)
+
+ /*totalNoise = 10.0f * (float)log10( *totalNoise );*/
+ f_Noise = Log2_norm_lc( totalNoise_temp ); // exponent of log => 30-0 = 30
+ e_Noise = sub( e_Noise, 1 ); // 30-(31-e_Noise) = e_Noise-1
+ Ltmp = L_mac( L_deposit_h( e_Noise ), f_Noise, 1 ); // Q16
+ Ltmp = Mpy_32_16_1( Ltmp, LG10 ); // Q14 (16+13-15)
+ Ltmp = L_shl( Ltmp, 10 ); // Q26
+ *totalNoise = round_fx( Ltmp ); /*Q8*/
+ move16();
+
+ /*-----------------------------------------------------------------*
+ * Average energy per frame for each frequency band
+ *-----------------------------------------------------------------*/
+
+ pt1 = fr_bands;
+ pt2 = fr_bands + NB_BANDS;
+
+ FOR( i = 0; i < NB_BANDS; i++ )
+ {
+ /* enr[i] = 0.5f * ( *pt1++ + *pt2++ ); */
+ enr[i] = W_extract_h( W_mac_32_32( W_mult_32_32( *pt1, ONE_IN_Q30 ), *pt2, ONE_IN_Q30 ) ); // q_fr_bands+30+1-32+1 = q_fr_bands
+ move32();
+ pt1++;
+ pt2++;
+ }
+
+ /*-----------------------------------------------------------------*
+ * Background noise energy update
+ *-----------------------------------------------------------------*/
+
+ FOR( i = 0; i < NB_BANDS; i++ )
+ {
+ /* tmpN[i] = (1-ALPHA) * bckr[i] + ALPHA * enr[i]; */
+ /* handle div by zero in find_tilt_fx */
+ tmpN[i] = L_max( Madd_32_16( Mpy_32_16_1( bckr[i], ALPHAM1_FX ), enr[i], ALPHA_FX ), e_min ); // q_fr_bands
+ move32();
+
+ /* if( tmpN[i] < bckr[i] ) { bckr[i] = tmpN[i]; }*/
+ /* Defend to increase noise estimate: keep as it is or decrease */
+ bckr[i] = L_max( L_min( bckr[i], tmpN[i] ), e_min ); // q_fr_bands
+ move32();
+ }
+
+ /*------------------------------------------------------------------*
+ * Energy variation update
+ *------------------------------------------------------------------*/
+ /*Etot_v = (float) fabs(*Etot_last - Etot);*/
+ L_Etot_v = L_abs( L_sub( L_Etot_last, L_Etot ) ); /* Q24 */
+
+ /* *Etot_v_h2 = (1.0f-0.02f) * *Etot_v_h2 + 0.02f * min(3.0f, Etot_v); */
+ L_tmp = L_min( 50331648 /* 3.0f in Q24 */, L_Etot_v ); // Q24
+ L_tmp = Mult_32_16( L_tmp, 655 /*.02 in Q15 */ ); // Q24
+ L_Etot_v_h2 = Madd_32_16( L_tmp, L_Etot_v_h2, 32113 /* 0.98 in Q15 */ ); // Q24
+
+ /* if (*Etot_v_h2 < 0.1f) { *Etot_v_h2 = 0.1f; } */
+ *Etot_v_h2 = s_max( round_fx( L_Etot_v_h2 ), 26 /* 0.1 in Q8*/ ); // Q8
+ move16();
+
+ return;
+}
+
/*-----------------------------------------------------------------*
* noise_est_fx()
*
@@ -940,13 +1041,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();
@@ -1000,11 +1096,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 )
{
@@ -1060,11 +1152,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 )
{
@@ -1086,11 +1174,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 */
@@ -1131,13 +1215,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*/
@@ -1172,14 +1252,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 */
{
@@ -1198,11 +1273,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 */
@@ -1222,14 +1293,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 );
@@ -1241,11 +1308,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]
@@ -1267,11 +1330,7 @@ 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();
@@ -1286,11 +1345,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*/
{
@@ -1299,11 +1354,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 */
}
}
@@ -1408,13 +1459,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 */
@@ -1451,15 +1498,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 */
@@ -1581,11 +1623,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 */
@@ -2149,27 +2187,27 @@ void noise_est_ivas_fx(
Encoder_State *st_fx, /* i/o: state structure */
const Word16 old_pitch1, /* i : previous frame OL pitch[1] */
const Word32 tmpN[], /* i : temporary noise update Q_new + QSCALE */
- const Word16 epsP_h[], /* i : msb prediction error energies Q_r-1 */
- const Word16 epsP_l[], /* i : msb prediction error energies Q_r-1 */
+ const Word32 epsP[], /* i : msb prediction error energies Qx */
const Word16 Etot, /* i : total channel E (see find_enr_fx.c) Q8 */
const Word16 relE, /* i : (VA_CHECK addition) relative frame energy Q8? */
const Word16 corr_shift, /* i : normalized correlation correction Q15 */
- const Word32 enr[], /* i : averaged energy over both subframes Q_new + Q_SCALE */
- Word32 fr_bands[], /* i : spectrum per critical bands of the current frame Q_new + Q_SCALE */
+ const Word32 enr[], /* i : averaged energy over both subframes q_enr */
+ const Word16 q_enr, /* i : q_enr of enr Q0 */
+ Word32 fr_bands[], /* i : spectrum per critical bands of the current frame q_fr_bands */
+ Word16 q_fr_bands, /* i : Q of q_fr_bands */
Word16 *cor_map_sum, /* o : Q8 */
Word16 *ncharX, /* o : Q11 */
Word16 *sp_div, /* o : Q_sp_div */
Word16 *Q_sp_div, /* o : Q factor for sp_div */
Word16 *non_staX, /* o : non-stationarity for sp/mus classifier Q8 */
Word16 *loc_harm, /* o : multi-harmonicity flag for UV classifier */
- const Word32 *lf_E, /* i : per bin energy for low frequencies Q_new + Q_SCALE -2 */
+ const Word32 *lf_E, /* i : per bin energy for low frequencies q_lf_E */
+ const Word16 q_lf_E, /* i : Q of lf_E Q0 */
Word16 *st_harm_cor_cnt, /* i/o : 1st harm correlation timer Q0 */
const Word16 Etot_l_lp, /* i : Smoothed low energy Q8 */
const Word16 Etot_v_h2, /* i : Energy variations Q8 */
Word16 *bg_cnt, /* i : Background burst length timer Q0 */
Word16 EspecdB[], /* i/o: log E spectrum (with f=0) of the current frame Q7 for multi harm */
- Word16 Q_new, /* i : SCaling of current frame */
- const Word32 Le_min_scaled, /*i : Minimum energy value in Q_new + Q_SCALE */
Word16 *sp_floor, /* o : noise floor estimate Q7 */
Word16 S_map[], /* o : short-term correlation map Q7 */
STEREO_CLASSIF_HANDLE hStereoClassif, /* i/o: stereo classifier structure */
@@ -2179,9 +2217,9 @@ void noise_est_ivas_fx(
{
Word16 alpha, alpha2, alpha2m1, alpham1;
Word16 cor_min, cor_max, num, den, ExpNum, ExpDen, noise_chartmp;
- Word16 wtmp1, wtmp, ExpLmax, ExpLmax2, tmpExp, nchar_thr, cor_tmp;
+ Word16 wtmp1, wtmp, nchar_thr, cor_tmp;
Word16 i, tmp_pc, pc, th_eps;
- Word32 th_sta, Lnum, Lden, non_sta, LepsP, Ltmpden;
+ Word32 th_sta, Lnum, Lden, non_sta, LepsP;
Word16 e_ener, f_ener;
Word32 Ltmp, Ltmp1, Lsum_num, Lsum_den, *pt1, *pt2, Ltmp2, Lnon_sta2;
Word64 w_sum_num, w_tmp;
@@ -2200,23 +2238,32 @@ void noise_est_ivas_fx(
Word16 enr_bgd, cns_bgd, lp_bgd, ns_mask;
Word16 lt_haco_mask, bg_haco_mask;
- Word16 SD_1, SD_1_inv, bg_bgd3, PD_1, PD_2, PD_3, PD_4, PD_5;
+ Word16 SD_1, bg_bgd3, PD_1, PD_2, PD_3, PD_4, PD_5;
Word16 non_staB; /* Q8 */
- Word32 L_tmp_enr, L_tmp_ave_enr, L_tmp_ave_enr2;
- Word16 tmp_Q;
+ Word32 L_tmp_enr, L_tmp_ave, L_tmp_ave2;
Word16 tmp, tmp2; /* general temp registers */
Word16 tmp_enr, tmp_floor; /* constants in Q8 */
Word16 vad_bwidth_fx; /* vad ns control variabel for input bwidth from teh BWD */
/* for DTX operation */
- Word16 vad_2nd_stage_fx;
Word16 lim_Etot_fx; /* Q8 */
Word16 lim_Etot_sq_fx; /* Q2 */
Word16 st_E_var_est_fx; /* Q2 */
NOISE_EST_HANDLE hNoiseEst;
SP_MUS_CLAS_HANDLE hSpMusClas;
+ Word32 Le_min_scaled;
+ Word64 temp;
hSpMusClas = st_fx->hSpMusClas;
+
+ Le_min_scaled = L_shl( E_MIN_FXQ31, sub( q_fr_bands, Q31 ) ); // q_fr_bands
+
+ GSC_ENC_HANDLE hGSCEnc = st_fx->hGSCEnc;
+#ifdef BASOP_NOGLOB_DECLARE_LOCAL
+ Flag Overflow = 0;
+ move32();
+#endif
+
/* Check if LR-VAD */
IF( hFrontVad != NULL )
{
@@ -2227,56 +2274,61 @@ void noise_est_ivas_fx(
hNoiseEst = st_fx->hNoiseEst;
}
- GSC_ENC_HANDLE hGSCEnc = st_fx->hGSCEnc;
-#ifdef BASOP_NOGLOB_DECLARE_LOCAL
- Flag Overflow = 0;
- move32();
-#endif
-
/*-----------------------------------------------------------------*
* Initialization
*-----------------------------------------------------------------*/
vad_bwidth_fx = st_fx->input_bwidth;
move16();
- /*st_fx->ener_RAT = 10.0f * (float)log10( mean(lf_E, 8));*/
+ /*st_fx->ener_RAT = 10.0f * (float)log10( mean(lf_E, 8));*/
+ temp = 0;
+ move64();
IF( hFrontVad == NULL )
{
- if ( hSpMusClas != NULL )
+ IF( hSpMusClas != NULL )
{
- Ltmp = L_shr( lf_E[0], 3 );
- FOR( i = 1; i < 8; i++ )
+ /* E = mean( lf_E, 8 ); */
+ FOR( i = 0; i < 8; i++ )
{
- Ltmp = L_add( Ltmp, L_shr( lf_E[i], 3 ) );
+ temp = W_mac_32_16( temp, lf_E[i], 1 ); // q_lf_E+1
}
- IF( LT_32( Ltmp, L_shl( 1, add( Q_new, Q_SCALE - 2 ) ) ) )
+ /* (temp / 8) */
+ Ltmp = W_extract_l( W_shr( temp, 4 ) ); // q_lf_E+1 -> q_lf_E
+
+ IF( LT_32( Ltmp, L_shl_sat( 1, q_lf_E ) ) )
{
hSpMusClas->ener_RAT_fx = 0;
- // PMT("hSpMusClas->ener_RAT_fx = 0, that should be validated")
}
ELSE
{
- Ltmp = L_max( Ltmp, (Word32) 1L ); /* make sure log2_norm_lc does not cause table reading out of bounds */
e_ener = norm_l( Ltmp );
f_ener = Log2_norm_lc( L_shl( Ltmp, e_ener ) );
e_ener = sub( 30, e_ener );
- e_ener = sub( e_ener, sub( add( Q_new, QSCALE ), 2 ) );
- Ltmp = Mpy_32_16( e_ener, f_ener, LG10 );
- wtmp = round_fx( L_shl( Ltmp, 10 ) ); /*Q8*/
-
- /* st_fx->ener_RAT /= (Etot + 0.01f); */
- wtmp1 = add( Etot, 3 ); /*3 is 0.01 in Q8 */
- /* st_fx->ener_RAT_fx = wtmp/wtmp1 */
+ e_ener = sub( e_ener, q_lf_E );
+ Ltmp = L_mac( L_deposit_h( e_ener ), f_ener, 1 ); // Q16
+ Ltmp = Mpy_32_16_1( Ltmp, LG10 ); // Q14 (16+13-15)
+ Ltmp = L_shl( Ltmp, 10 ); // Q24
+ wtmp = round_fx( Ltmp ); /*Q8*/
+
+ /* st_fx->ener_RAT /= (Etot + 0.01f);
+ if ( st->hSpMusClas->ener_RAT > 1.0 )
+ {
+ st->hSpMusClas->ener_RAT = 1.0f;
+ }
+ */
+
+ wtmp1 = add( Etot, 3 ); /* 0.01f in Q8 */
hSpMusClas->ener_RAT_fx = 0;
move16();
IF( wtmp > 0 )
{
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();
}
}
}
@@ -2290,7 +2342,7 @@ void noise_est_ivas_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*/
@@ -2326,13 +2378,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();
@@ -2361,95 +2408,115 @@ void noise_est_ivas_fx(
/*-----------------------------------------------------------------*
* Detection of frames with non-stationary spectral content
*-----------------------------------------------------------------*/
-
/* weighted sum of spectral changes per critical bands */
w_sum_num = 0;
move64();
Lsum_den = L_deposit_l( 0 );
- /* Find a proper scaling to prevent overflow, but acheiving good computation on low level signals */
- tmpExp = 0;
- move16();
- ExpLmax = sub( 30, norm_l( fr_bands[10] ) );
- ExpLmax2 = sub( 30, norm_l( hNoiseEst->fr_bands2_fx[10] ) );
- tmpExp = s_max( tmpExp, sub( shl( s_max( ExpLmax, ExpLmax2 ), 1 ), s_min( ExpLmax, ExpLmax2 ) ) );
- FOR( i = 11; i <= st_fx->max_band; i++ )
- {
- ExpLmax = sub( 30, norm_l( fr_bands[i] ) );
- ExpLmax2 = sub( 30, norm_l( hNoiseEst->fr_bands2_fx[i] ) );
- tmpExp = s_max( tmpExp, sub( shl( s_max( ExpLmax, ExpLmax2 ), 1 ), s_min( ExpLmax, ExpLmax2 ) ) );
- }
- tmpExp = sub( tmpExp, 30 - 4 - 4 ); /* 4bits for internal summation and 4 bits for comparaison */
-
pt1 = fr_bands + 10;
pt2 = hNoiseEst->fr_bands2_fx + 10;
+ Word64 w_sum_den;
+ Word16 exp, exp2;
+ w_sum_den = 0;
+ move64();
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 )
+ Lnum = L_max( *pt1, *pt2 );
+ Lden = L_min( *pt1, *pt2 );
+
+ w_sum_den = W_mac_32_16( w_sum_den, Lnum, 1 ); // q_fr_bands+1
+
+ exp = sub( norm_l( Lnum ), 1 );
+ Lnum = L_shl( Lnum, exp ); // q_fr_bands+exp
+ num = extract_h( Mpy_32_32( Lnum, Lnum ) ); // 2*(q_fr_bands+exp)-31-16
+ ExpNum = add( sub( shl( q_fr_bands, 1 ), 47 ), shl( exp, 1 ) );
+
+
+ den = E_MIN_FXQ31 >> 8; // 29360, 0.0035f in Q23
+ ExpDen = Q23;
+ move32();
+ move16();
+
+ IF( Lden != 0 )
{
- Ltmpden = L_add( Ltmpden, 1 );
+ exp = norm_l( Lden );
+ den = extract_h( L_shl( Lden, exp ) ); // q_fr_bands+ExpDen-16
+ ExpDen = sub( add( q_fr_bands, exp ), Q16 );
}
- ExpNum = sub( norm_l( Lnum ), 1 );
- num = extract_h( L_shl( Lnum, ExpNum ) );
- num = mult_r( num, num );
- ExpDen = norm_l( Ltmpden );
- den = extract_h( L_shl( Ltmpden, ExpDen ) );
- num = div_s( num, den );
- w_tmp = W_shr( num, add( sub( sub( shl( ExpNum, 1 ), ExpDen ), 15 + 1 ), tmpExp ) );
+
+ num = div_s( num, den ); // Q15+ExpNum-ExpDen
+ w_tmp = W_shl( num, sub( q_fr_bands, sub( ExpNum, ExpDen ) ) ); // q_fr_bands+15
w_sum_num = W_add( w_sum_num, w_tmp );
pt1++;
pt2++;
}
- Lsum_den = L_shr( Lsum_den, tmpExp );
ExpNum = W_norm( w_sum_num );
- Lsum_num = W_extract_h( W_shl( w_sum_num, ExpNum ) );
- ExpNum = sub( ExpNum, 32 );
+ Lsum_num = W_extract_h( W_shl( w_sum_num, ExpNum ) ); // q_fr_bands+15+ExpNum-32
+ ExpNum = add( q_fr_bands, sub( ExpNum, 17 ) );
+
+ ExpDen = W_norm( w_sum_den );
+ Lsum_den = W_extract_h( W_shl( w_sum_den, ExpDen ) ); // q_fr_bands+1+ExpDen-32
+ ExpDen = add( add( q_fr_bands, 1 ), sub( ExpDen, 32 ) );
/* calculation of spectral diversity */
/* THR_SPDIV_FX = 5 , 1/5 Q15 = 6554 */
spec_div = 0;
move16();
- if ( GT_32( Mult_32_16( Lsum_num, 6554 ), L_shl_sat( Lsum_den, ExpNum ) ) ) /* Qx+Q15+1-16 ==> Qx */
+ if ( GT_32( Mult_32_16( Lsum_num, 6554 ), L_shl_sat( Lsum_den, sub( ExpNum, ExpDen ) ) ) ) /* Qx+Q15+1-16 ==> Qx */
{
spec_div = 1;
move16();
}
/* *sp_div = Lsum_num / (Lsum_den + 1e-5f); */
- Lsum_den = L_add( Lsum_den, 1 );
- Word16 exp = 0;
+ IF( Lsum_den == 0 )
+ {
+ Lsum_den = 1407374884; // 1e-5 in Q47
+ ExpDen = 47;
+ move32();
+ move16();
+ }
+
*sp_div = BASOP_Util_Divide3232_Scale( Lsum_num, Lsum_den, &exp );
move16();
-
- *Q_sp_div = add( sub( 15, exp ), ExpNum );
+ *Q_sp_div = add( sub( 15, exp ), sub( ExpNum, ExpDen ) );
move16();
/*-----------------------------------------------------------------*
* Detection of frames with high energy content in high frequencies
*-----------------------------------------------------------------*/
+ pt1 = &fr_bands[st_fx->min_band];
+ pt2 = &fr_bands[10];
+ w_sum_num = 0;
+ w_sum_den = 0;
+ move64();
+ move64();
+
/* calculation of energy in first 10 critical bands */
- Ltmp = sum32_fx( &fr_bands[st_fx->min_band], sub( 10, st_fx->min_band ) );
+ FOR( i = 0; i < sub( 10, st_fx->min_band ); i++ )
+ {
+ w_sum_den = W_mac_32_16( w_sum_den, *pt1, 1 ); // q_fr_bands+1
+ pt1++;
+ }
+ exp = W_norm( w_sum_den );
+ Ltmp = W_extract_h( W_shl( w_sum_den, exp ) ); // q_fr_bands+1+exp-32
+ exp = sub( add( q_fr_bands, exp ), 31 );
/* calculation of energy in the rest of bands */
- Ltmp2 = sum32_fx( &fr_bands[10], sub( st_fx->max_band, 9 ) );
+ FOR( i = 0; i < sub( st_fx->max_band, 9 ); i++ )
+ {
+ w_sum_num = W_mac_32_16( w_sum_num, *pt2, 1 );
+ pt2++;
+ }
+ exp2 = sub( W_norm( w_sum_num ), 1 );
+ Ltmp2 = W_extract_h( W_shl( w_sum_num, exp2 ) ); // q_fr_bands+1+exp2-32
+ exp2 = sub( add( q_fr_bands, exp2 ), 31 );
-#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 */
test();
- IF( L_msu( Ltmp, 100, wtmp ) < 0 || L_msu( Ltmp2, 100, wtmp ) < 0 )
+ IF( LT_32( L_shr( Ltmp, exp ), 100 ) || LT_32( L_shr( Ltmp2, exp2 ), 100 ) )
{
noise_chartmp = 0;
move16();
@@ -2457,17 +2524,8 @@ void noise_est_ivas_fx(
ELSE
{
/* ftemp2 /= ftemp */
- ExpNum = sub( norm_l( Ltmp2 ), 1 );
- num = extract_h( L_shl( Ltmp2, ExpNum ) );
-
- 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 */
+ 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
}
if ( ncharX != NULL )
@@ -2494,16 +2552,16 @@ void noise_est_ivas_fx(
}
}
- noise_chartmp = s_min( noise_chartmp, (Word16) 10 << 11 ); /* Q11 */
+ noise_chartmp = s_min( noise_chartmp, 10 << 11 ); /* Q11 */
/* update LT value of the final parameter */
/* *st_noise_char = M_ALPHA * *st_noise_char + (1-M_ALPHA) * noise_chartmp */
hNoiseEst->noise_char_fx = mac_r( L_mult( M_ALPHA_FX, hNoiseEst->noise_char_fx ), ONE_MINUS_M_ALPHA, noise_chartmp );
-
+ move16();
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 */
@@ -2518,8 +2576,8 @@ void noise_est_ivas_fx(
}
/* save the 2 last spectra per crit. bands for the future */
- Copy32( hNoiseEst->fr_bands1_fx, hNoiseEst->fr_bands2_fx, NB_BANDS );
- Copy32( fr_bands + NB_BANDS, hNoiseEst->fr_bands1_fx, NB_BANDS );
+ Copy32( hNoiseEst->fr_bands1_fx, hNoiseEst->fr_bands2_fx, NB_BANDS ); // q_fr_bands
+ Copy32( fr_bands + NB_BANDS, hNoiseEst->fr_bands1_fx, NB_BANDS ); // q_fr_bands
/*-----------------------------------------------------------------*
* Non-stationarity estimation for each band
@@ -2532,13 +2590,8 @@ void noise_est_ivas_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 = Madd_32_16( 12582912 /* 0.75 in Q24*/, 137438953, tmp ); // 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*/
@@ -2560,60 +2613,55 @@ void noise_est_ivas_fx(
alpha2m1 = 32767;
move16();
}
- Lnon_sta2 = L_deposit_l( 1 << 10 );
+ Lnon_sta2 = L_deposit_l( 1 << 10 ); // Q10
- non_sta = L_deposit_l( 1 << 10 );
+ non_sta = L_deposit_l( 1 << 10 ); // Q10
*non_staX = 0;
move16();
non_staB = 0;
move16();
+ Le_min_scaled = L_shl( E_MIN_FXQ31, sub( q_enr, Q31 ) ); // q_enr
+
FOR( i = st_fx->min_band; i <= st_fx->max_band; i++ )
{
+ Ltmp = L_shl( 1, q_enr ); // q_enr
/* + 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
- 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 */
+ L_tmp_enr = L_add( enr[i], Ltmp ); // q_enr
+
+ IF( LE_32( non_sta, th_sta ) ) /* Just to limit the saturation */
{
+ L_tmp_ave = L_add( hNoiseEst->ave_enr_fx[i], Ltmp ); // q_enr
+
/* if( enr[i] > st_ave_enr2[i] ) */
/* non_sta2 = non_sta2 * ((enr[i]+1) / (st_ave_enr2[i]+1)) */
- Lnum = L_max( L_tmp_enr, L_tmp_ave_enr );
+ Lnum = L_max( L_tmp_enr, L_tmp_ave ); // q_enr
/* else */
/* non_sta2 = non_sta2 * ((st_ave_enr2[i]+1) / (enr[i]+1)) */
- Lden = L_min( L_tmp_enr, L_tmp_ave_enr );
+ Lden = L_min( L_tmp_enr, L_tmp_ave ); // q_enr
if ( Lden == 0 )
{
- Lden = L_add( Lden, EPSILON_FX );
+ Lden = L_max( Ltmp, EPSILON_FX ); // q_enr
}
ExpNum = sub( norm_l( Lnum ), 1 );
- num = extract_h( L_shl( Lnum, ExpNum ) );
- Lnum = L_shl( Lnum, ExpNum );
+ num = extract_h( L_shl( Lnum, ExpNum ) ); // q_enr+ExpNum-16
+
ExpDen = norm_l( Lden );
- 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 */
+ 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
+ non_sta = L_shr_o( Ltmp1, sub( ExpNum, ExpDen ), &Overflow ); /* Q10 */
}
/* st->ave_enr[i] = alpha * st->ave_enr[i] + (1-alpha) * enr[i];*/ /* update long-term average */
- Ltmp = Mult_32_16( hNoiseEst->ave_enr_fx[i], alpha );
- Ltmp = L_add_sat( Ltmp, Mult_32_16( enr[i], alpham1 ) );
- hNoiseEst->ave_enr_fx[i] = L_max( Le_min_scaled, Ltmp );
+ Ltmp1 = Mult_32_16( hNoiseEst->ave_enr_fx[i], alpha ); // q_enr
+ Ltmp1 = Madd_32_16( Ltmp1, enr[i], alpham1 ); // q_enr
+ hNoiseEst->ave_enr_fx[i] = L_max( Le_min_scaled, Ltmp1 ); // q_enr
move32();
/* calculation of another non-stationarity measure (following attacks) */
@@ -2627,41 +2675,32 @@ void noise_est_ivas_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
- 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 */
{
- Lnum = L_max( L_tmp_enr, L_tmp_ave_enr2 );
- Lden = L_min( L_tmp_enr, L_tmp_ave_enr2 );
+ L_tmp_ave2 = L_add( hNoiseEst->ave_enr2_fx[i], Ltmp ); // q_enr
+ Lnum = L_max( L_tmp_enr, L_tmp_ave2 ); // q_enr
+ Lden = L_min( L_tmp_enr, L_tmp_ave2 ); // q_enr
+
if ( Lden == 0 )
{
- Lden = L_add( Lden, EPSILON_FX );
+ Lden = L_max( Ltmp, EPSILON_FX ); // q_enr
}
ExpNum = sub( norm_l( Lnum ), 1 );
- num = extract_h( L_shl( Lnum, ExpNum ) );
- Lnum = L_shl( Lnum, ExpNum );
+ num = extract_h( L_shl( Lnum, ExpNum ) ); // q_enr+ExpNum-16
+
ExpDen = norm_l( Lden );
- den = extract_h( L_shl( Lden, ExpDen ) );
- num = div_s( num, den );
- Ltmp1 = Mult_32_16( Lnon_sta2, num );
-#ifdef BASOP_NOGLOB
+ 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
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]) */
- Ltmp1 = Mult_32_16( hNoiseEst->ave_enr2_fx[i], alpha2 );
- Ltmp1 = L_add( Ltmp1, Mult_32_16( enr[i], alpha2m1 ) );
- hNoiseEst->ave_enr2_fx[i] = L_max( Le_min_scaled, Ltmp1 );
+ /* st_ave_enr2[i] = (float)alpha2 * st_ave_enr2[i] + (1.0f - alpha2) * (enr[i]) */
+ Ltmp1 = Mult_32_16( hNoiseEst->ave_enr2_fx[i], alpha2 ); // q_enr
+ Ltmp1 = Madd_32_16( Ltmp1, enr[i], alpha2m1 ); // q_enr
+ hNoiseEst->ave_enr2_fx[i] = L_max( Le_min_scaled, Ltmp1 ); // q_enr
move32();
/* calculation of non-stationarity measure for speech/music classification */
@@ -2672,51 +2711,62 @@ void noise_est_ivas_fx(
IF( GE_16( i, START_BAND_SPMUS ) && LT_16( i, NB_BANDS_SPMUS + START_BAND_SPMUS ) && st_fx->hSpMusClas != NULL )
{
/* log_enr = (float)ln_fx(enr[i]); */
- log_enr16 = noise_est_ln_q8_fx( enr[i], 0, tmp_Q );
+ Ltmp1 = L_max( enr[i], 1 );
+ e_ener = norm_l( Ltmp1 );
+ f_ener = Log2_norm_lc( L_shl( Ltmp1, e_ener ) );
+ e_ener = sub( sub( 30, e_ener ), q_enr );
+ Ltmp1 = L_mac( f_ener, e_ener, ONE_IN_Q14 ); // Q15
+ 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();
}
}
+
+ test();
IF( GE_16( i, 2 ) && LE_16( i, 16 ) )
{
- IF( GE_16( ini_frame, 100 ) )
+ tmp_enr = LN_E_MIN_PLUS_ONE_FX; // Q8
+ move16();
+ IF( enr[i] != 0 )
{
- /* calculate non-stationarity feature relative background */
- tmp_enr = noise_est_ln_q8_fx( enr[i], 1, tmp_Q ); /* 1.0f added */
- 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 */
+ Ltmp1 = L_add( enr[i], Ltmp ); // q_enr
+ e_ener = norm_l( Ltmp1 );
+ f_ener = Log2_norm_lc( L_shl( Ltmp1, e_ener ) );
+ e_ener = sub( sub( 30, e_ener ), q_enr );
+ Ltmp1 = L_mac( f_ener, e_ener, ONE_IN_Q14 ); // Q15
+ Ltmp1 = Mpy_32_16_1( Ltmp1, 22713 ); // Q15
+ tmp_enr = round_fx( L_shl( Ltmp1, 9 ) ); /* Q8 */
+ }
+
+ IF( LT_16( ini_frame, 100 ) )
+ {
+ non_staB = add_o( non_staB, abs_s( sub( tmp_enr, LN_E_MIN_PLUS_ONE_FX ) ), &Overflow ); /* Q8 */
}
ELSE /*ini_frame < 100*/
{
- /* calculate non-stationarity feature relative background */
- tmp_enr = noise_est_ln_q8_fx( enr[i], 1, tmp_Q ); /* 1.0f added */
- 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
+ tmp_floor = LN_E_MIN_PLUS_ONE_FX; // Q8
+ move16();
+ IF( hNoiseEst->bckr_fx[i] != 0 )
+ {
+ Ltmp1 = L_add( hNoiseEst->bckr_fx[i], L_shl( 1, hNoiseEst->q_bckr ) ); // hNoiseEst->q_bckr
+ e_ener = norm_l( Ltmp1 );
+ f_ener = Log2_norm_lc( L_shl( Ltmp1, e_ener ) );
+ e_ener = sub( sub( 30, e_ener ), hNoiseEst->q_bckr );
+ Ltmp1 = L_mac( f_ener, e_ener, ONE_IN_Q14 ); // Q15
+ Ltmp1 = Mpy_32_16_1( Ltmp1, 22713 ); // Q15
+ tmp_floor = round_fx( L_shl( Ltmp1, 9 ) ); /* Q8 */
+ }
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 */
}
}
} /* end of band loop FOR( i = st_fx->min_band; i <= st_fx->max_band; i++ ) */
- IF( LT_16( Etot, -1280 ) )
+ IF( LT_16( Etot, -1280 /* -5.0f in Q8 */ ) )
{
non_sta = L_deposit_l( 1024 ); /* 1.0 in Q10 */
Lnon_sta2 = L_deposit_l( 1024 ); /* 1.0 in Q10 */
@@ -2729,55 +2779,55 @@ void noise_est_ivas_fx(
{
/* 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; */
- hNoiseEst->Etot_st_est_fx = mac_r( L_mult( 8192, lim_Etot_fx ), 24576, hNoiseEst->Etot_st_est_fx );
+ hNoiseEst->Etot_st_est_fx = mac_r( L_mult( 8192, lim_Etot_fx ), 24576, hNoiseEst->Etot_st_est_fx ); // Q8
move16();
/* st->Etot_sq_st_est = 0.25f * lim_Etot * lim_Etot + (1.0f-0.25f) * st->Etot_sq_st_est; */
- hNoiseEst->Etot_sq_st_est_fx = mac_r( L_mult( 8192, lim_Etot_sq_fx ), 24576, hNoiseEst->Etot_sq_st_est_fx );
+ hNoiseEst->Etot_sq_st_est_fx = mac_r( L_mult( 8192, lim_Etot_sq_fx ), 24576, hNoiseEst->Etot_sq_st_est_fx ); // Q2
move16();
}
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 );
+ hNoiseEst->Etot_st_est_fx = mac_r( L_mult( 8192, lim_Etot_fx ), 24576, hNoiseEst->Etot_st_est_fx ); // Q8
move16();
/* st->Etot_sq_st_est = 0.25f * lim_Etot * lim_Etot + (1.0f-0.25f) * st->Etot_sq_st_est; */
- hNoiseEst->Etot_sq_st_est_fx = mac_r( L_mult( 8192, lim_Etot_sq_fx ), 24576, hNoiseEst->Etot_sq_st_est_fx );
+ hNoiseEst->Etot_sq_st_est_fx = mac_r( L_mult( 8192, lim_Etot_sq_fx ), 24576, hNoiseEst->Etot_sq_st_est_fx ); // Q2
move16();
}
- st_E_var_est_fx = sub( hNoiseEst->Etot_sq_st_est_fx, extract_h( L_shl_r( L_mult( hNoiseEst->Etot_st_est_fx, hNoiseEst->Etot_st_est_fx ), 1 ) ) );
+ st_E_var_est_fx = sub( hNoiseEst->Etot_sq_st_est_fx, extract_h( L_shl_r( L_mult( hNoiseEst->Etot_st_est_fx, hNoiseEst->Etot_st_est_fx ), 1 ) ) ); // Q2
/*-----------------------------------------------------------------*
* Count frames since last correlation or harmonic event
*-----------------------------------------------------------------*/
- Ltmp = L_mult( st_fx->voicing_fx[0], 16384 );
- Ltmp = L_mac( Ltmp, st_fx->voicing_fx[1], 16384 );
+ Ltmp = L_mult( st_fx->voicing_fx[0], 16384 /* 0.5 in Q15 */ ); // Q31
+ Ltmp = L_mac( Ltmp, st_fx->voicing_fx[1], 16384 /* 0.5 in Q15 */ ); // Q31
- test();
- test();
*st_harm_cor_cnt = add( *st_harm_cor_cnt, 1 );
- if ( ( Etot > 0 ) && ( ( *loc_harm > 0 ) || ( GT_16( round_fx( Ltmp ), COR_MAX_NNE_FX ) ) ) )
+ move16();
+ test();
+ test();
+ if ( ( Etot > 0 ) && ( ( *loc_harm > 0 ) || ( GT_32( Ltmp, 1825361101 /* 0.85 in Q31 */ ) ) ) )
{
*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;
+ move16();
}
- 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 */
- )
+ 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 )) ; */
*st_harm_cor_cnt = s_max( 1, shr( add( *st_harm_cor_cnt, 2 ), 2 ) );
move16();
@@ -2815,23 +2865,20 @@ void noise_est_ivas_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_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
+ exp = sub( norm_l( epsP[0] ), 1 );
+ num = extract_h( L_shl( epsP[0], exp ) ); // Qx+exp-16
- epsP_0_2 = s_max( 0, epsP_0_2 ); /* min value is 0 , Q12 */
+ exp2 = norm_l( epsP[2] );
+ den = extract_h( L_shl( epsP[2], exp2 ) ); // Qx+exp2-16
+ /* max(0, min(8, epsP[0] / epsP[2])) */
+ epsP_0_2 = div_s( num, den ); // Q15+exp-exp2
+ epsP_0_2 = shr_sat( epsP_0_2, add( sub( exp, exp2 ), 3 ) ); // Q12
+ epsP_0_2 = s_max( 0, epsP_0_2 ); /* min value is 0 , Q12 */
/* st->epsP_0_2_lp = 0.15f * epsP_0_2 + (1.0f-0.15f) * st->epsP_0_2_lp; */
- 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 );
+ hNoiseEst->epsP_0_2_lp_fx = mac_r( L_mult( epsP_0_2, 4915 /* 0.15 in Q15*/ ), hNoiseEst->epsP_0_2_lp_fx, 27853 /* 0.85 in Q15*/ ); // Q12
+ 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 */
@@ -2841,13 +2888,17 @@ void noise_est_ivas_fx(
} else {
st->epsP_0_2_ad_lp = 0.2f * epsP_0_2_ad + (1.0f - 0.2f) * st->epsP_0_2_ad_lp;
} */
- alpha = 6554;
- move16(); /* 0.2 Q15 */
- if ( LT_16( epsP_0_2_ad, hNoiseEst->epsP_0_2_ad_lp_fx ) )
+
+ IF( LT_16( epsP_0_2_ad, hNoiseEst->epsP_0_2_ad_lp_fx ) )
{
- alpha = shr( alpha, 1 ); /* 0.1 Q15 */
+ hNoiseEst->epsP_0_2_ad_lp_fx = mac_r( L_mult( epsP_0_2_ad, 3277 /* 0.1 in Q15*/ ), hNoiseEst->epsP_0_2_ad_lp_fx, 29491 /* 0.9 in Q15*/ ); // Q12
+ move16();
+ }
+ ELSE
+ {
+ hNoiseEst->epsP_0_2_ad_lp_fx = mac_r( L_mult( epsP_0_2_ad, 6554 /* 0.2 in Q15*/ ), hNoiseEst->epsP_0_2_ad_lp_fx, 26214 /* 0.8 in Q15*/ ); // Q12
+ move16();
}
- hNoiseEst->epsP_0_2_ad_lp_fx = noise_est_AR1_Qx( epsP_0_2_ad, hNoiseEst->epsP_0_2_ad_lp_fx, alpha );
/* 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 */
@@ -2857,57 +2908,55 @@ void noise_est_ivas_fx(
* Linear predition efficiency 2 to 16 order
*-----------------------------------------------------------------*/
- /* 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_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 = max(0 , min(8, epsP[2] / epsP[16])); */
+ exp = sub( norm_l( epsP[2] ), 1 );
+ num = extract_h( L_shl( epsP[2], exp ) ); // Qx+exp-16
- epsP_2_16 = s_max( 0, epsP_2_16 ); /* min value is 0 , Q12 */
+ exp2 = norm_l( epsP[16] );
+ den = extract_h( L_shl( epsP[16], exp2 ) ); // Qx+exp2-16
+ epsP_2_16 = div_s( num, den ); // Q15+exp-exp2
+ epsP_2_16 = shr_sat( epsP_2_16, add( sub( exp, exp2 ), 3 ) ); // Q12
+ epsP_2_16 = s_max( 0, epsP_2_16 ); /* min value is 0 , Q12 */
/* if (epsP_2_16 > st->epsP_2_16_lp){
st->epsP_2_16_lp = 0.2f * epsP_2_16 + (1.0f-0.2f) * st->epsP_2_16_lp;
} else {
st->epsP_2_16_lp = 0.03f * epsP_2_16 + (1.0f-0.03f) * st->epsP_2_16_lp;
- }
-
- st->epsP_2_16_lp2 = 0.02f * epsP_2_16 + (1.0f-0.02f) * st->epsP_2_16_lp2; */
+ } */
- alpha = 983;
- move16(); /* 0.03 Q15 */
- if ( GT_16( epsP_2_16, hNoiseEst->epsP_2_16_lp_fx ) )
+ IF( GT_16( epsP_2_16, hNoiseEst->epsP_2_16_lp_fx ) )
{
- alpha = 6554;
- move16(); /* 0.2 Q15 */
+ hNoiseEst->epsP_2_16_lp_fx = mac_r( L_mult( epsP_2_16, 6554 /* 0.2 in Q15*/ ), hNoiseEst->epsP_2_16_lp_fx, 26214 /* 0.8 in Q15*/ ); // Q12
+ move16();
+ }
+ ELSE
+ {
+ hNoiseEst->epsP_2_16_lp_fx = mac_r( L_mult( epsP_2_16, 983 /* 0.03 in Q15*/ ), hNoiseEst->epsP_2_16_lp_fx, 31785 /* 0.97 in Q15*/ ); // Q12
+ move16();
}
- hNoiseEst->epsP_2_16_lp_fx = noise_est_AR1_Qx( epsP_2_16, hNoiseEst->epsP_2_16_lp_fx, alpha );
- hNoiseEst->epsP_2_16_lp2_fx = noise_est_AR1_Qx( epsP_2_16, hNoiseEst->epsP_2_16_lp2_fx, 655 ); /* 0.02 */
+ hNoiseEst->epsP_2_16_lp2_fx = mac_r( L_mult( epsP_2_16, 655 /* 0.02 in Q15*/ ), hNoiseEst->epsP_2_16_lp2_fx, 32113 /* 0.98 in Q15*/ ); // Q12
+ move16();
epsP_2_16_dlp = sub( hNoiseEst->epsP_2_16_lp_fx, hNoiseEst->epsP_2_16_lp2_fx );
-
/* if (epsP_2_16_dlp < st->epsP_2_16_dlp_lp2 ) {
st->epsP_2_16_dlp_lp2 = 0.02f * epsP_2_16_dlp + (1.0f-0.02f) * st->epsP_2_16_dlp_lp2;
} else {
st->epsP_2_16_dlp_lp2 = 0.05f * epsP_2_16_dlp + (1.0f-0.05f) * st->epsP_2_16_dlp_lp2;
}*/
- alpha = 1638;
- move16(); /* 0.05 Q15 */
- if ( LT_16( epsP_2_16_dlp, hNoiseEst->epsP_2_16_dlp_lp2_fx ) )
+
+ IF( LT_16( epsP_2_16_dlp, hNoiseEst->epsP_2_16_dlp_lp2_fx ) )
{
- alpha = 655;
- move16(); /* 0.02 Q15 */
+ hNoiseEst->epsP_2_16_dlp_lp2_fx = mac_r( L_mult( epsP_2_16_dlp, 655 /* 0.02 in Q15*/ ), hNoiseEst->epsP_2_16_dlp_lp2_fx, 32113 /* 0.98 in Q15*/ ); // Q12
+ move16();
+ }
+ ELSE
+ {
+ hNoiseEst->epsP_2_16_dlp_lp2_fx = mac_r( L_mult( epsP_2_16_dlp, 1638 /* 0.05 in Q15*/ ), hNoiseEst->epsP_2_16_dlp_lp2_fx, 31130 /* 0.95 in Q15*/ ); // Q12
+ move16();
}
- hNoiseEst->epsP_2_16_dlp_lp2_fx = noise_est_AR1_Qx( epsP_2_16_dlp, hNoiseEst->epsP_2_16_dlp_lp2_fx, alpha );
/* 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 );
@@ -2925,14 +2974,17 @@ void noise_est_ivas_fx(
tmp2 = 32767;
move16();
}
- hNoiseEst->lt_tn_track_fx = noise_est_AR1_Qx( tmp2, hNoiseEst->lt_tn_track_fx, 983 ); /*0.03 in Q15 ,Q15 state*/
+ hNoiseEst->lt_tn_track_fx = mac_r( L_mult( tmp2, 983 /* 0.03 in Q15*/ ), hNoiseEst->lt_tn_track_fx, 31785 /* 0.97 in Q15*/ ); // Q12
+ 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*/
+ hNoiseEst->lt_tn_dist_fx = mac_r( L_mult( tmp, 983 /* 0.03 in Q15*/ ), hNoiseEst->lt_tn_dist_fx, 31785 /* 0.97 in Q15*/ ); // Q8
+ 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*/
+ tmp = sub( Etot, hNoiseEst->Etot_l_lp_fx ); /* Q8 */
+ hNoiseEst->lt_Ellp_dist_fx = mac_r( L_mult( tmp, 983 /* 0.03 in Q15*/ ), hNoiseEst->lt_Ellp_dist_fx, 31785 /* 0.97 in Q15*/ ); // Q8
+ move16();
/* if (st->harm_cor_cnt == 0) {
@@ -2942,29 +2994,30 @@ void noise_est_ivas_fx(
} */
IF( *st_harm_cor_cnt == 0 )
{
- hNoiseEst->lt_haco_ev_fx = noise_est_AR1_Qx( (Word16) 32767, hNoiseEst->lt_haco_ev_fx, 983 ); /*.03 in Q15 , Q15 state */
+ hNoiseEst->lt_haco_ev_fx = mac_r( 64424509 /* 0.03 in Q32*/, hNoiseEst->lt_haco_ev_fx, 31785 /* 0.97 in Q15*/ ); // Q15
+ move16();
}
ELSE
{
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++;
} else {
st->low_tn_track_cnt=0;
}*/
- tmp = 0;
- move16();
- move16();
- if ( LT_16( hNoiseEst->lt_tn_track_fx, 1638 ) ) /* 0.05 in Q15*/
+ IF( LT_16( hNoiseEst->lt_tn_track_fx, 1638 ) ) /* 0.05 in Q15*/
{
- tmp = add( hNoiseEst->low_tn_track_cnt, 1 );
+ hNoiseEst->low_tn_track_cnt = add( hNoiseEst->low_tn_track_cnt, 1 );
+ move16();
+ }
+ ELSE
+ {
+ hNoiseEst->low_tn_track_cnt = 0;
+ move16();
}
- hNoiseEst->low_tn_track_cnt = tmp;
- move16();
-
/* update of the long-term non-stationarity measure (between 0 and 1) */
/* if ( (non_sta > th_sta) || (*loc_harm > 0) ) {
@@ -2972,35 +3025,21 @@ void noise_est_ivas_fx(
} else {
st->act_pred = M_GAMMA * st->act_pred + (1-M_GAMMA) * 0;
}*/
- Ltmp = L_mult( M_GAMMA_FX, hNoiseEst->act_pred_fx ); /*Q15*Q15+1 --> Q31 , 32440= .99 Q15 */
- tmp = round_fx( Ltmp ); /* Q15 */
test();
- if ( ( GT_32( non_sta, th_sta ) ) /* float th_sta NB 5e10 , WB 3.5e10*/
- || ( *loc_harm > 0 ) )
+ IF( ( GT_32( non_sta, th_sta ) ) || ( *loc_harm > 0 ) )
{
- tmp = mac_r( Ltmp, ( -32768 + M_GAMMA_FX ), -32768 ); /* (-0.01)*(-1.0) */
+ hNoiseEst->act_pred_fx = mac_r( 21474836 /* 1 - M_GAMMA in Q31 */, M_GAMMA_FX, hNoiseEst->act_pred_fx ); // Q31
+ move16();
+ }
+ ELSE
+ {
+ hNoiseEst->act_pred_fx = mult_r( M_GAMMA_FX, hNoiseEst->act_pred_fx ); /*Q15*Q15+1 --> Q31 , 32440= .99 Q15 */
+ move16();
}
- hNoiseEst->act_pred_fx = tmp;
- move16();
-
/*-----------------------------------------------------------------*
* Background noise adaptation enable flag
*-----------------------------------------------------------------*/
- 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 */
- /* note this epsP2/eps16 is not limited to 8 as, epsP_2_16 is !! */
-
- vad_2nd_stage_fx = 0;
- move16(); /* background noise present - decrement counter */
/*
if( ( (*st_harm_cor_cnt < 3*HC_CNT_SLOW )
&& ( ( non_sta > th_sta ) ||
@@ -3022,6 +3061,16 @@ void noise_est_ivas_fx(
cor_tmp = 0;
move16();
}
+ /* epsP[2] / epsP[16] */
+ exp = sub( norm_l( epsP[2] ), 1 );
+ num = extract_h( L_shl( epsP[2], exp ) ); // Qx+exp-16
+
+ exp2 = norm_l( epsP[16] );
+ den = extract_h( L_shl( epsP[16], exp2 ) ); // Qx+exp2-16
+
+ LepsP = extract_l( div_s( num, den ) ); // Q15+exp-exp2
+ LepsP = L_shr( LepsP, add( sub( exp, exp2 ), 4 ) ); // Q11
+
test();
test();
@@ -3033,31 +3082,35 @@ void noise_est_ivas_fx(
test();
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 ) ) || ( GT_16( noise_char, 0 ) ) ) ) ||
- ( ( GT_16( st_fx->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 ) ) ||
- ( ( GT_16( hNoiseEst->act_pred_fx, 26214 ) ) && ( GT_32( Lnon_sta2, th_sta ) ) ) /*act_pred in Q15 , th_sta in Q10 */
+ 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( cor_tmp, cor_max ) ) || /* Q15 */
+ ( GT_32( LepsP, th_eps ) ) || /* Q11 */
+ ( GT_16( *loc_harm, 0 ) ) ||
+ ( ( GT_16( hNoiseEst->act_pred_fx, 26214 ) ) && ( GT_32( Lnon_sta2, th_sta ) ) ) /*act_pred in Q15 , th_sta in Q10 */
)
{
- vad_2nd_stage_fx = 1;
- move16(); /* active signal present - increment counter */
+ /* hNoiseEst->aEn = hNoiseEst->aEn + 2; */
+ hNoiseEst->aEn = add( hNoiseEst->aEn, 2 ); /* active signal present - increment counter */
+ move16();
}
-
- tmp = 2;
- move16(); /* Signal present */
- if ( vad_2nd_stage_fx == 0 )
+ ELSE
{
- tmp = -1;
- move16(); /* Background present */
+ /* hNoiseEst->aEn = hNoiseEst->aEn - 1; */
+ hNoiseEst->aEn = add( hNoiseEst->aEn, -1 ); /* background noise present - decrement counter */
+ move16();
}
- hNoiseEst->aEn = add( hNoiseEst->aEn, tmp );
+ hNoiseEst->aEn = s_max( s_min( hNoiseEst->aEn, 6 ), 0 );
+ move16();
- hNoiseEst->aEn = s_min( hNoiseEst->aEn, 6 );
- hNoiseEst->aEn = s_max( hNoiseEst->aEn, 0 );
+ IF( LE_16( hNoiseEst->aEn, 1 ) )
+ {
+ hNoiseEst->aEn_inac_cnt = add( hNoiseEst->aEn_inac_cnt, 1 );
+ hNoiseEst->aEn_inac_cnt = s_min( hNoiseEst->aEn_inac_cnt, 128 );
+ move16();
+ move16();
+ }
/*-----------------------------------------------------------------*
* Stereo classifier - save raw aEn
*-----------------------------------------------------------------*/
@@ -3069,33 +3122,25 @@ void noise_est_ivas_fx(
( 0.5f * ( st->voicing[0] + st->voicing[1] ) > cor_max ) ||
( epsP[2] / epsP[16] > th_eps ) ||
( ( hNoiseEst->act_pred > 0.8f ) && ( non_sta2 > th_sta ) ) )*/
+ wtmp = sub( hStereoClassif->aEn_raw[st_fx->idchan], 1 );
test();
test();
test();
test();
test();
- IF( ( GT_32( non_sta, th_sta ) ) || ( LT_16( tmp_pc, TH_PC_FX ) ) ||
- ( GT_16( cor_tmp, cor_max ) ) ||
- ( GT_32( LepsP, th_eps ) ) ||
- ( ( GT_16( hNoiseEst->act_pred_fx, 26214 ) ) && ( GT_32( Lnon_sta2, th_sta ) ) ) ) /*act_pred in Q15 , th_sta in Q10 */
+ if ( ( GT_32( non_sta, th_sta ) ) || ( LT_16( tmp_pc, TH_PC_FX ) ) ||
+ ( GT_16( cor_tmp, cor_max ) ) ||
+ ( GT_32( LepsP, th_eps ) ) ||
+ ( ( GT_16( hNoiseEst->act_pred_fx, 26214 ) ) && ( GT_32( Lnon_sta2, th_sta ) ) ) ) /*act_pred in Q15 , th_sta in Q10 */
{
/* active signal present - increment counter */
- hStereoClassif->aEn_raw[st_fx->idchan] = hStereoClassif->aEn_raw[st_fx->idchan] + 2;
- }
- ELSE
- {
- /* background noise present - decrement counter */
- hStereoClassif->aEn_raw[st_fx->idchan] = hStereoClassif->aEn_raw[st_fx->idchan] - 1;
+ wtmp = add( hStereoClassif->aEn_raw[st_fx->idchan], 2 );
}
+ hStereoClassif->aEn_raw[st_fx->idchan] = wtmp;
move16();
- if ( GT_16( hStereoClassif->aEn_raw[st_fx->idchan], 6 ) )
- {
- hStereoClassif->aEn_raw[st_fx->idchan] = 6;
- }
- else if ( hStereoClassif->aEn_raw[st_fx->idchan] < 0 )
- {
- hStereoClassif->aEn_raw[st_fx->idchan] = 0;
- }
+
+ wtmp = s_min( hStereoClassif->aEn_raw[st_fx->idchan], 6 );
+ hStereoClassif->aEn_raw[st_fx->idchan] = s_max( wtmp, 0 );
move16();
}
@@ -3104,7 +3149,7 @@ void noise_est_ivas_fx(
/* comb_ahc_epsP = max(max(st->act_pred, st->lt_haco_ev), epsP_2_16_dlp); */
/* Q15 Q15 Q12 */
- comb_ahc_epsP = s_max( s_max( shr( hNoiseEst->act_pred_fx, 15 - 12 ), shr( hNoiseEst->lt_haco_ev_fx, 15 - 12 ) ), epsP_2_16_dlp ); /* Q12 */
+ comb_ahc_epsP = s_max( shr( s_max( hNoiseEst->act_pred_fx, hNoiseEst->lt_haco_ev_fx ), 15 - 12 ), epsP_2_16_dlp ); /* Q12 */
/* comb_hcm_epsP = max(max(st->lt_haco_ev,epsP_2_16_dlp_max),epsP_0_2_ad_lp_max); */
@@ -3116,7 +3161,7 @@ void noise_est_ivas_fx(
move16();
if ( *st_harm_cor_cnt == 0 )
{
- tmp = (Word16) 32767;
+ tmp = 32767;
move16();
}
haco_ev_max = s_max( tmp, hNoiseEst->lt_haco_ev_fx ); /* Q15 */
@@ -3164,7 +3209,7 @@ void noise_est_ivas_fx(
/* ns_mask = non_sta < 1e5f; */
ns_mask = 0;
move16();
- if ( LT_32( non_sta, (Word32) 102400000L ) ) /* (1e5f in Q10)*/
+ if ( LT_32( non_sta, 102400000 ) ) /* (1e5f in Q10)*/
{
ns_mask = 1;
move16(); /* Q0 */
@@ -3200,14 +3245,18 @@ void noise_est_ivas_fx(
SD_1 = 1;
move16(); /* Q0 */
}
- SD_1_inv = sub( 1, SD_1 ); /* Q0 */
/* NB "STL::test()"; has a cost of 2, using bitwise "s_and" , "s_or" at a cost of 1 */
/* NB only lowest bit position is used, result is always 0 or 1 */
/* bg_bgd3 = enr_bgd || ( ( cns_bgd || lp_bgd ) && ns_mask && lt_haco_mask && SD_1==0 ); */
- tmp = s_and( s_and( s_and( s_or( cns_bgd, lp_bgd ), ns_mask ), lt_haco_mask ), SD_1_inv );
- bg_bgd3 = s_or( enr_bgd, tmp );
+ test();
+ test();
+ test();
+ test();
+ test();
+ bg_bgd3 = enr_bgd || ( ( cns_bgd || lp_bgd ) && ns_mask && lt_haco_mask && ( SD_1 == 0 ) );
+ move16();
/*PD_1 = (epsP_2_16_dlp_max < 0.10f ) ; */
PD_1 = 0;
@@ -3273,21 +3322,19 @@ void noise_est_ivas_fx(
|| ( (Etot < 55.0f) && (SD_1==0)
&& ( ( PD_3 && (PD_1 || PD_2 ) ) || ( PD_4 || PD_5 ) ) ); */
PAU = 0;
- move16(); /*Q0*/
- if ( hNoiseEst->aEn == 0 )
+ move16();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ if ( ( hNoiseEst->aEn == 0 ) || ( LT_16( Etot, 55 * 256 ) && ( SD_1 == 0 ) && ( ( PD_3 && ( PD_1 || PD_2 ) ) || ( PD_4 || PD_5 ) ) ) )
{
PAU = 1;
- move16(); /*Q0*/
- }
- tmp = 0;
- move16(); /*Q0*/
- if ( LT_16( Etot, 55 * 256 ) ) /*55.0 in Q8 */
- {
- tmp = 1;
- move16(); /*Q0*/
+ move16();
}
- tmp = s_and( tmp, SD_1_inv );
- PAU = s_or( PAU, s_and( tmp, s_or( s_and( PD_3, s_or( PD_1, PD_2 ) ), s_or( PD_4, PD_5 ) ) ) );
/* NEW_POS_BG = (PAU | BG_1) & bg_bgd3; note bitwise logic in float */
@@ -3303,7 +3350,6 @@ void noise_est_ivas_fx(
move16();
}
-
/* When the signal dynamics is high and the energy is close to the background estimate */
/* sd1_bgd = (st->sign_dyn_lp > 15)
&& (Etot - st->Etot_l_lp ) < 2*st->Etot_v_h2
@@ -3326,34 +3372,27 @@ void noise_est_ivas_fx(
st->lt_haco_ev < 0.15f ||
non_staB < 50.0f ||
aE_bgd );*/
-
- tmp = 0;
+ tn_ini = 0;
move16();
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 */
- || ( ( 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 */
- ) )
- {
- tmp = 1;
- move16();
- }
-
- tn_ini = 0;
- move16();
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 ) ) )
+ test();
+ test();
+ test();
+ test();
+ test();
+ 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 */ ) &&
+ ( ( 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 */ ) ) ) )
{
tn_ini = 1;
move16();
@@ -3374,15 +3413,12 @@ void noise_est_ivas_fx(
move16(); /* Q15 */
/*if (( bg_bgd2 && ( aE_bgd || sd1_bgd || st->lt_tn_track >0.90f || NEW_POS_BG ) )
|| tn_ini ) */
- tmp = 0;
- move16();
- if ( GT_16( hNoiseEst->lt_tn_track_fx, 29491 ) ) /* .90 in Q15 */
- {
- tmp = 1;
- move16();
- }
-
- IF( s_or( s_and( bg_bgd2, s_or( aE_bgd, s_or( sd1_bgd, s_or( tmp, NEW_POS_BG ) ) ) ), tn_ini ) )
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( ( bg_bgd2 && ( aE_bgd || sd1_bgd || GT_16( hNoiseEst->lt_tn_track_fx, 29491 /* 0.90 in Q15 */ ) || NEW_POS_BG ) ) || tn_ini )
{
/*if( ( ( st->act_pred < 0.85f )
&& (aE_bgd !=0)
@@ -3425,20 +3461,15 @@ void noise_est_ivas_fx(
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*/
- && ( LT_16( sub( Etot, hNoiseEst->totalNoise_fx ), 10 * 256 ) ) /* 10.0 in Q8*/
- ) ||
- ( ( hNoiseEst->first_noise_updt == 0 ) && ( GT_16( hNoiseEst->harm_cor_cnt, 80 ) ) && ( aE_bgd != 0 ) && ( GT_16( hNoiseEst->lt_aEn_zero_fx, 16384 ) ) /*.5 in Q15*/
- ) ||
- ( ( tn_ini != 0 ) && ( ( aE_bgd != 0 ) || ( LT_16( non_staB, 10 * 256 ) ) || ( GT_16( hNoiseEst->harm_cor_cnt, 80 ) ) ) /* 10.0 in Q8*/
- ) )
-
+ IF( ( LT_16( hNoiseEst->act_pred_fx, 27853 /* 0.85 in Q15 */ ) && ( aE_bgd != 0 ) && ( LT_16( hNoiseEst->lt_Ellp_dist_fx, 10 * 256 /* 10 in Q8*/ ) || ( sd1_bgd != 0 ) ) && ( LT_16( hNoiseEst->lt_tn_dist_fx, 40 * 256 ) ) /* 40.0 in Q8*/
+ && LT_16( sub( Etot, hNoiseEst->totalNoise_fx ), 10 * 256 /* 10 in Q8 */ ) /* 10.0 in Q8*/ ) ||
+ ( ( hNoiseEst->first_noise_updt == 0 ) && GT_16( hNoiseEst->harm_cor_cnt, 80 ) && ( aE_bgd != 0 ) && GT_16( hNoiseEst->lt_aEn_zero_fx, 16384 /* 0.5 in Q15 */ ) ) ||
+ ( ( tn_ini != 0 ) && ( ( aE_bgd != 0 ) || LT_16( non_staB, 10 * 256 /* 10 in Q8*/ ) || GT_16( hNoiseEst->harm_cor_cnt, 80 ) ) ) )
{
updt_step = 32767;
move16();
hNoiseEst->first_noise_updt = 1;
+ move16();
FOR( i = 0; i < NB_BANDS; i++ )
{
hNoiseEst->bckr_fx[i] = tmpN[i];
@@ -3452,21 +3483,14 @@ void noise_est_ivas_fx(
( st->harm_cor_cnt > 50 && st->first_noise_updt > 30 && aE_bgd && st->lt_aEn_zero>0.5f )
|| tn_ini
) */
- ELSE IF( ( ( LT_16( hNoiseEst->act_pred_fx, 26214 ) ) /* .8 in Q15*/
- && ( ( aE_bgd != 0 ) || ( PAU != 0 ) ) && ( LT_16( hNoiseEst->lt_haco_ev_fx, 3277 ) ) ) /* .10 in q15*/
- || ( ( LT_16( hNoiseEst->act_pred_fx, 22938 ) ) /* 0.70 in Q15 */
- && ( ( aE_bgd != 0 ) || ( LT_16( non_staB, 17 * 256 ) ) ) /* 17.0 in Q8 */
- && ( PAU != 0 ) && ( LT_16( hNoiseEst->lt_haco_ev_fx, 4915 ) ) /* 0.15 in Q15 */
- ) ||
- ( ( GT_16( hNoiseEst->harm_cor_cnt, 80 ) ) && ( GT_16( hNoiseEst->totalNoise_fx, 5 * 256 ) ) /* 5.0 in Q8 */
- && ( LT_16( Etot, s_max( (Word16) 1 * 256, add( Etot_l_lp, add( hNoiseEst->Etot_v_h2_fx, shr( hNoiseEst->Etot_v_h2_fx, 1 ) ) ) ) ) ) /* 1.5= 1.0+.5 */
- ) ||
- ( ( GT_16( hNoiseEst->harm_cor_cnt, 50 ) ) && ( GT_16( hNoiseEst->first_noise_updt, 30 ) ) && ( aE_bgd != 0 ) && ( GT_16( hNoiseEst->lt_aEn_zero_fx, 16384 ) ) ) /*.5 in Q15*/
- || ( tn_ini != 0 ) )
-
+ ELSE IF( ( LT_16( hNoiseEst->act_pred_fx, 26214 /* 0.8 in Q15*/ ) && ( ( aE_bgd != 0 ) || ( PAU != 0 ) ) && ( LT_16( hNoiseEst->lt_haco_ev_fx, 3277 /* 0.1 in q15*/ ) ) ) ||
+ ( ( LT_16( hNoiseEst->act_pred_fx, 22938 /* 0.70 in Q15 */ ) ) && ( ( aE_bgd != 0 ) || ( LT_16( non_staB, 17 * 256 /* 17.0 in Q8 */ ) ) ) && ( PAU != 0 ) && ( LT_16( hNoiseEst->lt_haco_ev_fx, 4915 /* 0.15 in Q15 */ ) ) ) ||
+ ( GT_16( hNoiseEst->harm_cor_cnt, 80 ) && GT_16( hNoiseEst->totalNoise_fx, 5 * 256 /* 5.0 in Q8 */ ) && LT_16( Etot, s_max( 1 * 256, add( Etot_l_lp, add( hNoiseEst->Etot_v_h2_fx, shr( hNoiseEst->Etot_v_h2_fx, 1 ) ) /* 1.5= 1.0+.5 */ ) ) ) ) ||
+ ( GT_16( hNoiseEst->harm_cor_cnt, 50 ) && GT_16( hNoiseEst->first_noise_updt, 30 ) && ( aE_bgd != 0 ) && GT_16( hNoiseEst->lt_aEn_zero_fx, 16384 /*.5 in Q15*/ ) ) || ( tn_ini != 0 ) )
{
updt_step = 3277;
move16(); /* 0.1 in Q15 */
+
/* if ( !aE_bgd && st->harm_cor_cnt < 50
&& ( (st->act_pred > 0.6f)
|| ( (tn_ini==0) && (Etot_l_lp - st->totalNoise < 10.0f) && non_staB > 8.0f )
@@ -3478,36 +3502,31 @@ void noise_est_ivas_fx(
test();
test();
test();
- IF( ( aE_bgd == 0 ) && ( LT_16( hNoiseEst->harm_cor_cnt, 50 ) ) && ( ( GT_16( hNoiseEst->act_pred_fx, 19661 ) ) /* 0.6 in Q15*/
- || ( ( tn_ini == 0 ) && ( LT_16( sub( Etot_l_lp, hNoiseEst->totalNoise_fx ), 10 * 256 ) ) /* 10.0 in Q8 */
- && ( GT_16( non_staB, 8 * 256 ) ) /* 8.0 in in Q8*/
- ) ) )
+ if ( ( aE_bgd == 0 ) && LT_16( hNoiseEst->harm_cor_cnt, 50 ) &&
+ ( GT_16( hNoiseEst->act_pred_fx, 19661 /* 0.6 in Q15*/ ) ||
+ ( ( tn_ini == 0 ) && LT_16( sub( Etot_l_lp, hNoiseEst->totalNoise_fx ), 10 * 256 /* 10.0 in Q8 */ ) && GT_16( non_staB, 8 * 256 /* 8.0 in in Q8*/ ) ) ) )
{
updt_step = 328;
move16(); /* 0.01 Q15 */
}
- /*
- IF (updt_step > 0 )
- {
- */
+
hNoiseEst->first_noise_updt = 1;
move16();
FOR( i = 0; i < NB_BANDS; i++ )
{
/* st->bckr[i] = st->bckr[i] + updt_step * (tmpN[i]-st->bckr[i]);*/
/* 32 bit state update */
- Ltmp = L_sub( tmpN[i], hNoiseEst->bckr_fx[i] ); /*Q_new+Q_SCALE*/
- Ltmp = Mult_32_16( Ltmp, updt_step ); /* Q_new+Q_SCALE+15+1 -16*/
- hNoiseEst->bckr_fx[i] = L_add( Ltmp, hNoiseEst->bckr_fx[i] );
+ Ltmp = L_sub( tmpN[i], hNoiseEst->bckr_fx[i] ); // hNoiseEst->q_bckr
+ Ltmp = Mult_32_16( Ltmp, updt_step );
+ hNoiseEst->bckr_fx[i] = L_add( Ltmp, hNoiseEst->bckr_fx[i] ); // hNoiseEst->q_bckr
move32();
}
- /*
- } */
}
/*else if (aE_bgd || st->harm_cor_cnt > 100 )*/
- ELSE IF( ( aE_bgd != 0 ) || ( GT_16( hNoiseEst->harm_cor_cnt, 100 ) ) )
+ ELSE IF( ( aE_bgd != 0 ) || GT_16( hNoiseEst->harm_cor_cnt, 100 ) )
{
hNoiseEst->first_noise_updt = add( hNoiseEst->first_noise_updt, 1 );
+ move16();
}
}
ELSE
@@ -3515,18 +3534,17 @@ void noise_est_ivas_fx(
/* If in music lower bckr to drop further */
test();
test();
- IF( ( GT_16( hNoiseEst->low_tn_track_cnt, 300 ) ) && ( GT_16( hNoiseEst->lt_haco_ev_fx, 29491 ) ) /*.9 in Q15 */
- && ( hNoiseEst->totalNoise_fx > 0 ) )
+ IF( GT_16( hNoiseEst->low_tn_track_cnt, 300 ) && GT_16( hNoiseEst->lt_haco_ev_fx, 29491 /* 0.9 in Q15 */ ) && ( hNoiseEst->totalNoise_fx > 0 ) )
{
updt_step = -655;
move16(); /* for debug purposes */
FOR( i = 0; i < NB_BANDS; i++ )
{
- IF( GT_32( hNoiseEst->bckr_fx[i], L_shl( Le_min_scaled, 1L ) ) ) /* 2*E_MIN(float) in float, here we use 2*Le_min_scaled Q_new+Q_SCALE */
+ IF( GT_32( hNoiseEst->bckr_fx[i], L_shl_sat( E_MIN_FXQ31, sub( hNoiseEst->q_bckr, Q30 ) ) /* 2*E_MIN */ ) )
{
/* st->bckr[i] = 0.98f*st->bckr[i]; */
- hNoiseEst->bckr_fx[i] = Mult_32_16( hNoiseEst->bckr_fx[i], 32113 ); /* .98 in Q15 */
- move32(); /* move to array */
+ hNoiseEst->bckr_fx[i] = Mult_32_16( hNoiseEst->bckr_fx[i], 32113 /* .98 in Q15 */ ); // hNoiseEst->q_bckr
+ move32(); /* move to array */
}
}
}
@@ -3537,10 +3555,12 @@ void noise_est_ivas_fx(
move16();
if ( hNoiseEst->aEn == 0 )
{
- tmp = 32767;
+ tmp = 6554; // 0.2 in Q15
move16();
}
- hNoiseEst->lt_aEn_zero_fx = noise_est_AR1_Qx( tmp, hNoiseEst->lt_aEn_zero_fx, 6554 ); /* alpha=0.2 , Q15 */
+ hNoiseEst->lt_aEn_zero_fx = mac_r( tmp, hNoiseEst->lt_aEn_zero_fx, 26214 /* 0.8 in Q15*/ ); // Q15
+ move16();
+
IF( st_fx->element_mode > EVS_MONO )
{
test();
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/peak_vq_enc_fx.c b/lib_enc/peak_vq_enc_fx.c
index 81a83c7f3d59407d852000ce35e30bbd4c48c61c..9ea1af949121921157f3952fb153362c7ddb243a 100644
--- a/lib_enc/peak_vq_enc_fx.c
+++ b/lib_enc/peak_vq_enc_fx.c
@@ -135,16 +135,18 @@ Word16 peak_vq_enc_ivas_fx(
logqnorm_ivas_fx( &nf_gains[i], 12, &indx, 32, 1, &thren_HQ_fx[0] );
/* De-quantization */
- acc = L_add( dicn_fx[indx], 0 ); /* Q14 */
+ acc = dicn_fx[indx]; /* Q14 */
+ move32();
nf_gains[i] = L_shr( acc, 1 + 2 ); /* nf_gains in Q12. dicn_fx is in Q14. Need extra shift +2. */
move32();
- push_indice( hBstr, IND_HVQ_NF_GAIN, (int) indx, 5 );
+
+ push_indice( hBstr, IND_HVQ_NF_GAIN, indx, 5 );
bits = add( bits, 5 );
}
/* Signal number of peaks */
i = sub( max_peaks, vq_peaks );
- push_indice( hBstr, IND_NUM_PEAKS, (int) i, 5 );
+ push_indice( hBstr, IND_NUM_PEAKS, i, 5 );
bits = add( bits, 5 );
/* Identify position of first peak and arrange peak gains by position */
@@ -258,8 +260,8 @@ Word16 peak_vq_enc_ivas_fx(
move16();
}
- push_indice( hBstr, IND_FLAGN, (int) FlagN, 1 );
- push_indice( hBstr, IND_PG_IDX, (int) pgain_difidx[0], GAIN0_BITS );
+ push_indice( hBstr, IND_FLAGN, FlagN, 1 );
+ push_indice( hBstr, IND_PG_IDX, pgain_difidx[0], GAIN0_BITS );
IF( FlagN )
{
@@ -273,7 +275,7 @@ Word16 peak_vq_enc_ivas_fx(
r = pgain_huffsizn[j];
move16();
- push_indice( hBstr, IND_PG_IDX, (int) m, r );
+ push_indice( hBstr, IND_PG_IDX, m, r );
}
}
ELSE
@@ -281,7 +283,7 @@ Word16 peak_vq_enc_ivas_fx(
pPgainDifIdx = &pgain_difidx[1];
FOR( i = 0; i < vqPeaksMinus1; i++ )
{
- push_indice( hBstr, IND_PG_IDX, (int) ( *pPgainDifIdx++ ), GAINI_BITS );
+ push_indice( hBstr, IND_PG_IDX, ( *pPgainDifIdx++ ), GAINI_BITS );
}
}
@@ -298,6 +300,7 @@ Word16 peak_vq_enc_ivas_fx(
IF( pos_vec[indx] < 0 )
{
peak_gains[i] = L_negate( peak_gains[i] ); /* Q12 */
+ move32();
}
}
@@ -307,13 +310,13 @@ Word16 peak_vq_enc_ivas_fx(
num_overlap_bins = sub( 5, sub( vq_peak_idx[i + 1], vq_peak_idx[i] ) );
indx = sub( vq_peak_idx[i], 2 );
quant_peaks_ivas_fx( hBstr, &coefs[indx], &coefs_out[indx], &peak_gains[i], &vq_cb_idx, num_overlap_bins, core_brate, vq_peaks );
- push_indice( hBstr, IND_HVQ_PEAKS, (UWord16) vq_cb_idx, 8 );
+ push_indice( hBstr, IND_HVQ_PEAKS, vq_cb_idx, 8 );
bits = add( bits, 9 );
}
indx = sub( vq_peak_idx[i], 2 );
quant_peaks_ivas_fx( hBstr, &coefs[indx], &coefs_out[indx], &peak_gains[i], &vq_cb_idx, 0, core_brate, vq_peaks );
- push_indice( hBstr, IND_HVQ_PEAKS, (UWord16) vq_cb_idx, 8 );
+ push_indice( hBstr, IND_HVQ_PEAKS, vq_cb_idx, 8 );
bits = add( bits, 9 );
/* Quantize peak positions and sign with HVQ */
@@ -392,6 +395,7 @@ Word16 peak_vq_enc_ivas_fx(
FOR( k = 0; k < pvq_bands; k++ )
{
indx = pvq_norm[k];
+ move16();
tmp1 = ratio( gopt[k], fg_pred[k], &exp1 );
tmp1 = shr( tmp1, sub( 1, exp1 ) ); /* Q13 */
Mpy_32_16_ss( dicn_fx[indx], tmp1, &normq, &dontCare16 ); /* dicn_fx in Q14, sorted_pvq_gain_pred_err_fx in Q13. */
@@ -412,7 +416,8 @@ Word16 peak_vq_enc_ivas_fx(
move16();
indx = pvq_norm[k];
move16();
- normq = L_add( dicn_fx[indx], 0 ); /* in Q14 */
+ normq = dicn_fx[indx]; /* in Q14 */
+ move32();
j = 0;
move16();
IF( GE_16( k, sub( pvq_bands, n_sel_bnds ) ) )
@@ -551,15 +556,17 @@ Word16 peak_vq_enc_fx(
logqnorm_fx( &nf_gains[i], 12, &indx, 32, 1, 0 );
/* De-quantization */
- acc = L_add( dicn_fx[indx], 0 ); /* Q14 */
+ acc = dicn_fx[indx]; /* Q14 */
+ move32();
nf_gains[i] = L_shr( acc, 1 + 2 ); /* nf_gains in Q12. dicn_fx is in Q14. Need extra shift +2. */
- push_indice_fx( hBstr, IND_HVQ_NF_GAIN, (int) indx, 5 );
+ move32();
+ push_indice_fx( hBstr, IND_HVQ_NF_GAIN, indx, 5 );
bits = add( bits, 5 );
}
/* Signal number of peaks */
i = sub( max_peaks, vq_peaks );
- push_indice_fx( hBstr, IND_NUM_PEAKS, (int) i, 5 );
+ push_indice_fx( hBstr, IND_NUM_PEAKS, i, 5 );
bits = add( bits, 5 );
/* Identify position of first peak and arrange peak gains by position */
@@ -650,6 +657,7 @@ Word16 peak_vq_enc_fx(
/* Huffman coding */
hcode_l = 0;
+ move16();
pPgainDifIdx = &pgain_difidx[1];
FOR( i = 0; i < vqPeaksMinus1; i++ )
{
@@ -670,8 +678,8 @@ Word16 peak_vq_enc_fx(
move16();
}
- push_indice_fx( hBstr, IND_FLAGN, (int) FlagN, 1 );
- push_indice_fx( hBstr, IND_PG_IDX, (int) pgain_difidx[0], GAIN0_BITS );
+ push_indice_fx( hBstr, IND_FLAGN, FlagN, 1 );
+ push_indice_fx( hBstr, IND_PG_IDX, pgain_difidx[0], GAIN0_BITS );
IF( FlagN )
{
@@ -685,7 +693,7 @@ Word16 peak_vq_enc_fx(
r = pgain_huffsizn[j];
move16();
- push_indice_fx( hBstr, IND_PG_IDX, (int) m, r );
+ push_indice_fx( hBstr, IND_PG_IDX, m, r );
}
}
ELSE
@@ -693,7 +701,7 @@ Word16 peak_vq_enc_fx(
pPgainDifIdx = &pgain_difidx[1];
FOR( i = 0; i < vqPeaksMinus1; i++ )
{
- push_indice_fx( hBstr, IND_PG_IDX, (int) ( *pPgainDifIdx++ ), GAINI_BITS );
+ push_indice_fx( hBstr, IND_PG_IDX, ( *pPgainDifIdx++ ), GAINI_BITS );
}
}
@@ -710,6 +718,7 @@ Word16 peak_vq_enc_fx(
IF( pos_vec[indx] < 0 )
{
peak_gains[i] = L_negate( peak_gains[i] ); /* Q12 */
+ move32();
}
}
@@ -719,13 +728,13 @@ Word16 peak_vq_enc_fx(
num_overlap_bins = sub( 5, sub( vq_peak_idx[i + 1], vq_peak_idx[i] ) );
indx = sub( vq_peak_idx[i], 2 );
quant_peaks_fx( hBstr, &coefs[indx], &coefs_out[indx], &peak_gains[i], &vq_cb_idx, num_overlap_bins, core_brate, vq_peaks );
- push_indice_fx( hBstr, IND_HVQ_PEAKS, (UWord16) vq_cb_idx, 8 );
+ push_indice_fx( hBstr, IND_HVQ_PEAKS, vq_cb_idx, 8 );
bits = add( bits, 9 );
}
indx = sub( vq_peak_idx[i], 2 );
quant_peaks_fx( hBstr, &coefs[indx], &coefs_out[indx], &peak_gains[i], &vq_cb_idx, 0, core_brate, vq_peaks );
- push_indice_fx( hBstr, IND_HVQ_PEAKS, (UWord16) vq_cb_idx, 8 );
+ push_indice_fx( hBstr, IND_HVQ_PEAKS, vq_cb_idx, 8 );
bits = add( bits, 9 );
/* Quantize peak positions and sign with HVQ */
@@ -757,6 +766,7 @@ Word16 peak_vq_enc_fx(
pCoefsOut = coefs_out + i;
}
k_sort[k] = k;
+ move16();
j = 0;
move16();
pPvqVectorBandStart = pPvqVector;
@@ -803,12 +813,14 @@ Word16 peak_vq_enc_fx(
FOR( k = 0; k < pvq_bands; k++ )
{
indx = pvq_norm[k];
+ move16();
tmp1 = ratio( gopt[k], fg_pred[k], &exp1 );
tmp1 = shr( tmp1, sub( 1, exp1 ) ); /* Q13 */
Mpy_32_16_ss( dicn_fx[indx], tmp1, &normq, &dontCare16 ); /* dicn_fx in Q14, sorted_pvq_gain_pred_err_fx in Q13. */
logqnorm_fx( &normq, 12, &pvq_norm[k], 40, 1, 0 ); /* normq in Q(14+(16+13)+1-32)=Q12 */
pvq_norm[k] = sub( pvq_norm[k], 8 );
+ move16();
IF( pvq_norm[k] < 0 )
{
pvq_norm[k] = 0;
@@ -819,7 +831,7 @@ Word16 peak_vq_enc_fx(
pvq_bits = add( pvq_bits, HVQ_PVQ_GAIN_BITS );
pvq_norm[k] = add( pvq_norm[k], 8 );
-
+ move16();
indx = pvq_norm[k];
move16();
normq = L_add( dicn_fx[indx], 0 ); /* in Q14 */
@@ -839,6 +851,7 @@ Word16 peak_vq_enc_fx(
tmp16 = extract_h( acc ); /* in Q(28 - 16 = 12) */
Mpy_32_16_ss( normq, tmp16, &acc, &dontCare16 ); /* acc(Q11), normq(Q14), tmp16(Q12) */
*pCoefsOut = L_shl( acc, 12 - 11 ); /* Q12 */
+ move32();
j = add( j, 1 );
}
pCoefsOut++;
@@ -1064,12 +1077,14 @@ static void quant_peaks_fx(
x[i] = div_s( manIn, manPeakGain ); /* in Q(15+expIn-expPeakGain) */
Qx_vec[i] = add( 15, sub( expIn, expPeakGain ) );
+ move16();
Qx = s_min( Qx, Qx_vec[i] );
/* Restore the sign destroyed by abs operations. */
if ( L_xor( vectIn, *peak_gain ) < 0 ) /* Check the sign bits (MSB). */
{
x[i] = negate( x[i] );
+ move16();
}
}
FOR( i = 0; i < 4; i++ )
@@ -1077,6 +1092,7 @@ static void quant_peaks_fx(
IF( NE_16( Qx_vec[i], Qx ) )
{
x[i] = shr( x[i], sub( Qx_vec[i], Qx ) ); /* Qx */
+ move16();
}
}
absPeakGain = L_abs( peak_gain[0] );
@@ -1132,25 +1148,31 @@ static void quant_peaks_fx(
IF( cb_class == 0 )
{
*vq_idx = w_vquant_fx( x, Qx, weights, xq, hvq_peak_cb_fx, cbSize, 0 );
+ move16();
push_indice_fx( hBstr, IND_HVQ_PEAKS, 0, 1 );
}
ELSE IF( EQ_16( cb_class, 1 ) )
{
indx = sub( HVQ_CB_SIZE * 2, shl( search_overlap, 2 ) );
*vq_idx = w_vquant_fx( x, Qx, weights, xq, &hvq_peak_cb_fx[indx], cbSize, 0 );
+ move16();
*vq_idx = add( *vq_idx, sub( HVQ_CB_SIZE / 2, search_overlap ) );
+ move16();
push_indice_fx( hBstr, IND_HVQ_PEAKS, 0, 1 );
}
ELSE IF( EQ_16( cb_class, 2 ) )
{
indx = sub( HVQ_CB_SIZE * 2, shl( search_overlap, 2 ) );
*vq_idx = w_vquant_fx( x, Qx, weights, xq, &hvq_peak_cb_fx[indx], cbSize, 1 );
+ move16();
*vq_idx = add( *vq_idx, sub( HVQ_CB_SIZE / 2, search_overlap ) );
+ move16();
push_indice_fx( hBstr, IND_HVQ_PEAKS, 1, 1 );
}
ELSE
{
*vq_idx = w_vquant_fx( x, Qx, weights, xq, hvq_peak_cb_fx, cbSize, 1 );
+ move16();
push_indice_fx( hBstr, IND_HVQ_PEAKS, 1, 1 );
}
@@ -1239,7 +1261,7 @@ static Word16 sparse_code_pos_fx(
FOR( i = 0; i < HVQ_CP_MAP_IDX_LEN; i++ )
{
result[bits++] = shr( s_and( idx, mask ), sub( HVQ_CP_MAP_IDX_LEN - 1, i ) );
- mask >>= 1;
+ mask = shr( mask, 1 );
}
}
}
@@ -1409,6 +1431,7 @@ static Word16 hvq_code_pos_fx(
FOR( i = 1; i < num_peaks; i++ )
{
delta[i] = sub( sub( peak_idx[i], peak_idx[i - 1] ), HVQ_CP_HUFF_OFFSET );
+ move16();
if ( LT_16( delta_max, delta[i] ) )
{
delta_max = delta[i];
diff --git a/lib_enc/pit_enc_fx.c b/lib_enc/pit_enc_fx.c
index ea09805be3b3cdaf5cdf45ff52fbf2a35c491850..3793ee00d82899ddec7774fd6371e670a13bd84a 100644
--- a/lib_enc/pit_enc_fx.c
+++ b/lib_enc/pit_enc_fx.c
@@ -90,11 +90,14 @@ Word16 pit_encode_fx( /* o : Fractional pitc
if ( EQ_16( L_subfr, 2 * L_SUBFR ) )
{
L_sufr_sft = 7;
+ move16();
}
/*----------------------------------------------------------------*
* convert pitch values to 16kHz domain
*----------------------------------------------------------------*/
+ test();
+ test();
IF( EQ_16( L_frame, L_FRAME ) || ( tdm_Pri_pitch_buf != NULL && tdm_Pri_pitch_buf[0] < 0 ) )
{
Copy( pitch, T_op, 2 );
@@ -183,7 +186,8 @@ Word16 pit_encode_fx( /* o : Fractional pitc
move16();
IF( NE_16( coder_type, AUDIO ) )
{
- nBits = pitch_bits[shr( i_subfr, L_sufr_sft )];
+ nBits = pitch_bits[i_subfr >> L_sufr_sft];
+ move16();
}
IF( EQ_16( coder_type, AUDIO ) )
{
@@ -196,7 +200,7 @@ Word16 pit_encode_fx( /* o : Fractional pitc
move16();
test();
test();
- if ( EQ_16( L_subfr, L_frame / 2 ) && i_subfr != 0 && EQ_16( L_frame, L_FRAME ) )
+ if ( EQ_16( L_subfr, shr( L_frame, 1 ) ) && i_subfr != 0 && EQ_16( L_frame, L_FRAME ) )
{
pit_flag = L_SUBFR;
move16();
@@ -225,7 +229,7 @@ Word16 pit_encode_fx( /* o : Fractional pitc
/* search and encode the closed loop pitch period */
*T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_MAX, PIT_MAX, L_FRAME, L_subfr );
-
+ move16();
pit_Q_enc_fx( hBstr, 0, nBits, delta, pit_flag, *limit_flag, *T0, *T0_frac, T0_min, T0_max );
}
ELSE IF( EQ_16( coder_type, VOICED ) )
@@ -249,7 +253,7 @@ Word16 pit_encode_fx( /* o : Fractional pitc
}
/* search and encode the closed loop pitch period */
- test();
+
test();
IF( EQ_16( nBits, 9 ) || EQ_16( nBits, 5 ) )
{
@@ -336,10 +340,12 @@ Word16 pit_encode_fx( /* o : Fractional pitc
IF( *limit_flag == 0 )
{
*T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *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[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_MIN_EXTEND, PIT_FR1_EXTEND_8b, L_FRAME, L_SUBFR );
+ move16();
}
}
ELSE IF( EQ_16( nBits, 9 ) || EQ_16( nBits, 6 ) )
@@ -347,15 +353,18 @@ Word16 pit_encode_fx( /* o : Fractional pitc
IF( *limit_flag == 0 )
{
*T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_FR2_9b, PIT_FR1_9b, L_FRAME, L_SUBFR );
+ move16();
}
ELSE
{
*T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_FR2_EXTEND_9b, PIT_FR1_EXTEND_9b, L_FRAME, L_SUBFR );
+ move16();
}
}
ELSE IF( EQ_16( nBits, 10 ) )
{
*T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_MAX, PIT_MAX, L_FRAME, L_SUBFR );
+ move16();
}
pit_Q_enc_fx( hBstr, 0, nBits, delta, pit_flag, *limit_flag, *T0, *T0_frac, T0_min, T0_max );
@@ -366,10 +375,12 @@ Word16 pit_encode_fx( /* o : Fractional pitc
IF( EQ_16( nBits, 9 ) || EQ_16( nBits, 6 ) )
{
*T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT16k_FR2_EXTEND_9b, PIT16k_FR1_EXTEND_9b, L_FRAME16k, L_SUBFR );
+ move16();
}
- ELSE IF( nBits == 10 )
+ ELSE IF( EQ_16( nBits, 10 ) )
{
*T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT16k_FR2_EXTEND_10b, PIT16k_MAX, L_FRAME16k, L_SUBFR );
+ move16();
}
pit16k_Q_enc_fx( hBstr, nBits, *limit_flag, *T0, *T0_frac, T0_min, T0_max );
@@ -410,6 +421,7 @@ Word16 pit_encode_fx( /* o : Fractional pitc
/* search and encode the closed loop pitch period */
*T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_MIN, PIT_FR1_8b, L_FRAME, L_SUBFR );
+ move16();
}
ELSE IF( EQ_32( core_brate, ACELP_8k85 ) )
{
@@ -432,6 +444,7 @@ Word16 pit_encode_fx( /* o : Fractional pitc
/* search and encode the closed loop pitch period */
*T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_MIN, PIT_FR1_8b, L_FRAME, L_SUBFR );
+ move16();
}
ELSE
{
@@ -458,6 +471,7 @@ Word16 pit_encode_fx( /* o : Fractional pitc
/* search and encode the closed loop pitch period */
*T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *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, 1, nBits, delta, pit_flag, *limit_flag, *T0, *T0_frac, T0_min, T0_max );
@@ -505,11 +519,14 @@ Word16 pit_encode_ivas_fx( /* o : Fractional
if ( EQ_16( L_subfr, 2 * L_SUBFR ) )
{
L_sufr_sft = 7;
+ move16();
}
/*----------------------------------------------------------------*
* convert pitch values to 16kHz domain
*----------------------------------------------------------------*/
+ test();
+ test();
IF( EQ_16( L_frame, L_FRAME ) || ( tdm_Pri_pitch_buf != NULL && tdm_Pri_pitch_buf[0] < 0 ) )
{
Copy( pitch, T_op, 2 );
@@ -598,7 +615,7 @@ Word16 pit_encode_ivas_fx( /* o : Fractional
move16();
IF( NE_16( coder_type, AUDIO ) )
{
- nBits = pitch_bits[shr( i_subfr, L_sufr_sft )];
+ nBits = pitch_bits[i_subfr >> L_sufr_sft];
}
IF( EQ_16( coder_type, AUDIO ) )
{
@@ -640,7 +657,7 @@ Word16 pit_encode_ivas_fx( /* o : Fractional
/* search and encode the closed loop pitch period */
*T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_MAX, PIT_MAX, L_FRAME, L_subfr );
-
+ move16();
pit_Q_enc_ivas_fx( hBstr, 0, nBits, delta, pit_flag, *limit_flag, *T0, *T0_frac, T0_min, T0_max );
}
ELSE IF( EQ_16( coder_type, VOICED ) )
@@ -665,7 +682,6 @@ Word16 pit_encode_ivas_fx( /* o : Fractional
/* search and encode the closed loop pitch period */
test();
- test();
IF( EQ_16( nBits, 9 ) || EQ_16( nBits, 5 ) )
{
*T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_FR2_DOUBLEEXTEND_9b, PIT_FR1_DOUBLEEXTEND_9b, L_FRAME, L_SUBFR );
@@ -716,6 +732,7 @@ Word16 pit_encode_ivas_fx( /* o : Fractional
{
/* search and encode the closed loop pitch period */
*T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_MIN, PIT_FR1_8b, L_FRAME, L_SUBFR );
+ move16();
IF( EQ_16( delta, 8 ) )
{
*T0_frac = 0;
@@ -762,10 +779,12 @@ Word16 pit_encode_ivas_fx( /* o : Fractional
IF( *limit_flag == 0 )
{
*T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *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[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_MIN_EXTEND, PIT_FR1_EXTEND_8b, L_FRAME, L_SUBFR );
+ move16();
}
}
ELSE IF( EQ_16( nBits, 9 ) || EQ_16( nBits, 6 ) )
@@ -773,15 +792,17 @@ Word16 pit_encode_ivas_fx( /* o : Fractional
IF( *limit_flag == 0 )
{
*T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_FR2_9b, PIT_FR1_9b, L_FRAME, L_SUBFR );
+ move16();
}
ELSE
{
*T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_FR2_EXTEND_9b, PIT_FR1_EXTEND_9b, L_FRAME, L_SUBFR );
+ move16();
}
}
ELSE IF( EQ_16( nBits, 10 ) )
{
- *T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_MAX, PIT_MAX, L_FRAME, L_SUBFR );
+ *T0 = pitch_fr4_ivas_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_MAX, PIT_MAX, L_FRAME, L_SUBFR );
}
pit_Q_enc_ivas_fx( hBstr, 0, nBits, delta, pit_flag, *limit_flag, *T0, *T0_frac, T0_min, T0_max );
@@ -792,10 +813,12 @@ Word16 pit_encode_ivas_fx( /* o : Fractional
IF( EQ_16( nBits, 9 ) || EQ_16( nBits, 6 ) )
{
*T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT16k_FR2_EXTEND_9b, PIT16k_FR1_EXTEND_9b, L_FRAME16k, L_SUBFR );
+ move16();
}
- ELSE IF( nBits == 10 )
+ ELSE IF( EQ_16( nBits, 10 ) )
{
*T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT16k_FR2_EXTEND_10b, PIT16k_MAX, L_FRAME16k, L_SUBFR );
+ move16();
}
pit16k_Q_enc_ivas_fx( hBstr, nBits, *limit_flag, *T0, *T0_frac, T0_min, T0_max );
@@ -836,6 +859,7 @@ Word16 pit_encode_ivas_fx( /* o : Fractional
/* search and encode the closed loop pitch period */
*T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_MIN, PIT_FR1_8b, L_FRAME, L_SUBFR );
+ move16();
}
ELSE IF( EQ_32( core_brate, ACELP_8k85 ) )
{
@@ -858,6 +882,7 @@ Word16 pit_encode_ivas_fx( /* o : Fractional
/* search and encode the closed loop pitch period */
*T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_MIN, PIT_FR1_8b, L_FRAME, L_SUBFR );
+ move16();
}
ELSE
{
@@ -884,6 +909,7 @@ Word16 pit_encode_ivas_fx( /* o : Fractional
/* search and encode the closed loop pitch period */
*T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *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, 1, nBits, delta, pit_flag, *limit_flag, *T0, *T0_frac, T0_min, T0_max );
@@ -1105,6 +1131,7 @@ Word16 delta_pit_enc_fx( /* o : pitch index
)
{
Word16 pitch_index = 0;
+ move16();
IF( fr_steps == 0 )
{
@@ -1129,7 +1156,196 @@ Word16 delta_pit_enc_fx( /* o : pitch index
*
* Find the closed loop pitch period with 1/4 subsample resolution.
*-------------------------------------------------------------------*/
+Word16 pitch_fr4_ivas_fx( /* o : chosen integer pitch lag */
+ const Word16 exc[], /* i : excitation buffer Q_new*/
+ const Word16 xn[], /* i : target signal Q_new-1+shift*/
+ const Word16 h[], /* i : weighted synthesis filter impulse response Q(14+shift)*/
+ const Word16 t0_min, /* i : minimum value in the searched range. Q0*/
+ const Word16 t0_max, /* i : maximum value in the searched range. Q0*/
+ Word16 *pit_frac, /* o : chosen fraction (0, 1, 2 or 3) */
+ const Word16 i_subfr, /* i : flag to first subframe */
+ const Word16 limit_flag, /* i : flag for limits (0=restrained, 1=extended) */
+ const Word16 t0_fr2, /* i : minimum value for resolution 1/2 */
+ const Word16 t0_fr1, /* i : minimum value for resolution 1 */
+ const Word16 L_frame, /* i : length of the frame */
+ const Word16 L_subfr /* i : size of subframe */
+)
+{
+ Word16 i;
+ Word16 t_min, t_max;
+ Word16 max_val, t0, t1, fraction, step, temp;
+ Word16 *corr;
+ Word16 corr_v[15 + 2 * L_INTERPOL1 + 1]; /* Total length = t0_max-t0_min+1+2*L_inter */
+ Word16 pit_min;
+ Word16 cor_max;
+
+ /* initialization */
+ IF( limit_flag == 0 )
+ {
+ IF( EQ_16( L_frame, L_FRAME ) )
+ {
+ pit_min = PIT_MIN;
+ move16();
+ }
+ ELSE /* L_frame == L_FRAME16k */
+ {
+ pit_min = PIT16k_MIN;
+ move16();
+ }
+ }
+ ELSE
+ {
+ IF( EQ_16( L_frame, L_FRAME ) )
+ {
+ pit_min = PIT_MIN_EXTEND;
+ move16();
+ IF( EQ_16( limit_flag, 2 ) )
+ {
+ pit_min = PIT_MIN_DOUBLEEXTEND;
+ move16();
+ }
+ }
+ ELSE /* L_frame == L_FRAME16k */
+ {
+ pit_min = PIT16k_MIN_EXTEND;
+ move16();
+ }
+ }
+
+ /*-----------------------------------------------------------------*
+ * - Find interval to compute normalized correlation
+ * - allocate memory to normalized correlation vector
+ * - Compute normalized correlation between target and filtered
+ * excitation
+ *-----------------------------------------------------------------*/
+
+ t_min = sub( t0_min, L_INTERPOL1 );
+ t_max = add( t0_max, L_INTERPOL1 );
+ corr = &corr_v[-t_min];
+ move16();
+ move16(); /* corr[t_min..t_max] */
+
+ norm_corr_ivas_fx( exc, xn, h, t_min, t_max, corr, L_subfr );
+
+ /*-----------------------------------------------------------------*
+ * Find integer pitch
+ *-----------------------------------------------------------------*/
+
+ max_val = corr[t0_min];
+ move16();
+ t0 = t0_min;
+ move16();
+
+ FOR( i = add( t0_min, 1 ); i <= t0_max; i++ )
+ {
+ if ( corr[i] >= max_val )
+ {
+ t0 = i;
+ move16();
+ }
+ max_val = s_max( corr[i], max_val );
+ }
+
+ IF( EQ_16( t0_fr1, pit_min ) )
+ {
+ /* don't search fraction (for 7b/4b quant) */
+ test();
+ IF( ( i_subfr == 0 ) && ( GE_16( t0, t0_fr2 ) ) )
+ {
+ i = shl( shr( t0, 1 ), 1 ); /* 2 samples resolution */
+ if ( GT_16( add( i, 2 ), PIT_MAX ) )
+ {
+ i = sub( i, 2 );
+ }
+ IF( GT_16( corr[i], corr[i + 2] ) )
+ {
+ t0 = i;
+ move16();
+ }
+ ELSE
+ {
+ t0 = add( i, 2 );
+ }
+ }
+ *pit_frac = 0;
+ move16();
+
+ return ( t0 );
+ }
+
+ test();
+ IF( ( i_subfr == 0 ) && ( GE_16( t0, t0_fr1 ) ) )
+ {
+ *pit_frac = 0;
+ move16();
+
+ return ( t0 );
+ }
+
+ /*------------------------------------------------------------------*
+ * Search fractionnal pitch with 1/4 subsample resolution.
+ * search the fractions around t0 and choose the one which maximizes
+ * the interpolated normalized correlation.
+ *-----------------------------------------------------------------*/
+
+ t1 = t0;
+ move16();
+ step = 1;
+ move16(); /* 1/4 subsample resolution */
+ fraction = 1;
+ move16();
+ test();
+ test();
+ IF( ( ( i_subfr == 0 ) && ( GE_16( t0, t0_fr2 ) ) ) || ( EQ_16( t0_fr2, pit_min ) ) )
+ {
+ step = 2;
+ move16(); /* 1/2 subsample resolution */
+ fraction = 2;
+ move16();
+ }
+
+ IF( EQ_16( t0, t0_min ) ) /* Limit case */
+ {
+ fraction = 0;
+ move16();
+ cor_max = Interpol_4( &corr[t0], fraction );
+ }
+ ELSE
+ {
+ t0 = sub( t0, 1 );
+ cor_max = Interpol_4( &corr[t0], fraction );
+ FOR( i = add( fraction, step ); i <= 3; i = (Word16) ( i + step ) )
+ {
+ temp = Interpol_4( &corr[t0], i );
+ IF( GT_16( temp, cor_max ) )
+ {
+ cor_max = temp;
+ move16();
+ fraction = i;
+ move16();
+ }
+ }
+ }
+
+ FOR( i = 0; i <= 3; i = (Word16) ( i + step ) )
+ {
+ temp = Interpol_4( &corr[t1], i );
+ IF( GT_16( temp, cor_max ) )
+ {
+ cor_max = temp;
+ move16();
+ fraction = i;
+ move16();
+ t0 = t1;
+ move16();
+ }
+ }
+
+ *pit_frac = fraction;
+ move16();
+ return ( t0 );
+}
Word16 pitch_fr4_fx( /* o : chosen integer pitch lag */
const Word16 exc[], /* i : excitation buffer Q_new*/
const Word16 xn[], /* i : target signal Q_new-1+shift*/
@@ -1196,8 +1412,7 @@ Word16 pitch_fr4_fx( /* o : chosen integer pitch lag
t_min = sub( t0_min, L_INTERPOL1 );
t_max = add( t0_max, L_INTERPOL1 );
corr = &corr_v[-t_min];
- move16();
- move16(); /* corr[t_min..t_max] */
+ /* corr[t_min..t_max] */
norm_corr_fx( exc, xn, h, t_min, t_max, corr, L_subfr );
@@ -1210,9 +1425,9 @@ Word16 pitch_fr4_fx( /* o : chosen integer pitch lag
t0 = t0_min;
move16();
- FOR( i = add( t0_min, 1 ); i <= t0_max; i++ )
+ FOR( i = t0_min + 1; i <= t0_max; i++ )
{
- if ( corr[i] >= max_val )
+ if ( GE_16( corr[i], max_val ) )
{
t0 = i;
move16();
@@ -1227,7 +1442,7 @@ Word16 pitch_fr4_fx( /* o : chosen integer pitch lag
IF( ( i_subfr == 0 ) && ( GE_16( t0, t0_fr2 ) ) )
{
i = shl( shr( t0, 1 ), 1 ); /* 2 samples resolution */
- if ( GT_16( add( i, 2 ), PIT_MAX ) )
+ IF( GT_16( add( i, 2 ), PIT_MAX ) )
{
i = sub( i, 2 );
}
@@ -1288,7 +1503,7 @@ Word16 pitch_fr4_fx( /* o : chosen integer pitch lag
{
t0 = sub( t0, 1 );
cor_max = Interpol_4( &corr[t0], fraction );
- FOR( i = add( fraction, step ); i <= 3; i = (Word16) ( i + step ) )
+ FOR( i = fraction + step; i <= 3; i = ( i + step ) )
{
temp = Interpol_4( &corr[t0], i );
IF( GT_16( temp, cor_max ) )
@@ -1301,7 +1516,7 @@ Word16 pitch_fr4_fx( /* o : chosen integer pitch lag
}
}
- FOR( i = 0; i <= 3; i = (Word16) ( i + step ) )
+ FOR( i = 0; i <= 3; i = ( i + step ) )
{
temp = Interpol_4( &corr[t1], i );
IF( GT_16( temp, cor_max ) )
@@ -1329,6 +1544,99 @@ Word16 pitch_fr4_fx( /* o : chosen integer pitch lag
* excitation divided by the square root of energy of filtered
* excitation)
*---------------------------------------------------------------------*/
+void norm_corr_ivas_fx(
+ const Word16 exc[], /* i : excitation buffer Q_new*/
+ const Word16 xn[], /* i : target signal Q_new-1+shift*/
+ const Word16 h[], /* i : weighted synthesis filter impulse response Q(14+shift)*/
+ const Word16 t_min, /* i : minimum value of searched range */
+ const Word16 t_max, /* i : maximum value of searched range */
+ Word16 ncorr[], /* o : normalized correlation Q15 */
+ const Word16 L_subfr /* i : subframe size */
+)
+{
+ Word16 i, k, t;
+ Word16 corr, exp_corr, norm, exp_norm, exp, scale;
+ Word16 excf[L_FRAME16k];
+ Word32 L_tmp;
+ Word64 W_tmp;
+#ifdef BASOP_NOGLOB_DECLARE_LOCAL
+ Flag Overflow = 0;
+#endif
+
+ k = negate( t_min );
+
+ /*-----------------------------------------------------------------*
+ * compute the filtered excitation for the first delay t_min
+ *-----------------------------------------------------------------*/
+
+ conv_fx( &exc[k], h, excf, L_subfr );
+
+ /* Compute rounded down 1/sqrt(energy of xn[]) */
+ L_tmp = L_mac_o( 1, xn[0], xn[0], &Overflow );
+ FOR( i = 1; i < L_subfr; i++ )
+ {
+ L_tmp = L_mac_o( L_tmp, xn[i], xn[i], &Overflow );
+ }
+ exp = norm_l( L_tmp );
+ exp = sub( 30, exp );
+
+ exp = add( exp, 2 ); /* energy of xn[] x 2 + rounded up */
+ scale = negate( shr( exp, 1 ) ); /* (1< 0; i-- )
+ {
+ /* saturation can occur in add() */
+ /*excf[i] = add(mult(exc[k], h[i]), excf[i - 1]); move16(); */
+ excf[i] = round_fx_sat( L_mac_sat( L_mult( excf[i - 1], 32767 ), exc[k], h[i] ) );
+ }
+ excf[0] = mult_r( exc[k], h[0] );
+ move16();
+ }
+ }
+
+ return;
+}
void norm_corr_fx(
const Word16 exc[], /* i : excitation buffer Q_new*/
@@ -1346,6 +1654,7 @@ void norm_corr_fx(
Word32 L_tmp;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
k = negate( t_min );
@@ -1357,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 );
@@ -1387,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 );
@@ -1402,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 );
@@ -1418,27 +1711,19 @@ 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 ) )
{
k--;
- FOR( i = (Word16) ( L_subfr - 1 ); i > 0; i-- )
+ FOR( i = ( L_subfr - 1 ); i > 0; i-- )
{
/* 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] );
move16();
@@ -1899,7 +2184,7 @@ void Mode2_pit_encode_fx(
{
Word16 pit_res_max2 = pit_res_max;
- if ( EQ_16( pit_min, PIT_MIN_16k ) )
+ IF( EQ_16( pit_min, PIT_MIN_16k ) )
{
pit_res_max2 = shr( pit_res_max, 1 );
}
@@ -1928,7 +2213,7 @@ void Mode2_pit_encode_fx(
ELSE IF( coder_type == 4 ) /* 9/6/9/6 (AMRWB) */
{
Word16 pit_res_max2 = pit_res_max;
- if ( EQ_16( pit_min, PIT_MIN_16k ) )
+ IF( EQ_16( pit_min, PIT_MIN_16k ) )
{
pit_res_max2 = shr( pit_res_max, 1 );
}
@@ -1943,6 +2228,7 @@ void Mode2_pit_encode_fx(
}
*T0 = E_GAIN_closed_loop_search_fx( exc, xn, h1, *T0_min, *T0_min_frac, *T0_max, *T0_max_frac, pit_res_max2, T0_frac, T0_res, pit_res_max,
pit_flag, pit_min, pit_fr2, pit_fr1, L_SUBFR );
+ move16();
IF( pit_flag == 0 ) /* if 1st/3rd/5th subframe */
{
Mode2_abs_pit_enc_fx( *T0, *T0_frac, pt_indice, pit_min, pit_fr1, pit_fr2, pit_res_max );
@@ -1964,6 +2250,7 @@ void Mode2_pit_encode_fx(
}
*T0 = E_GAIN_closed_loop_search_fx( exc, xn, h1, *T0_min, *T0_min_frac, *T0_max, *T0_max_frac, shr( pit_res_max, 1 ), T0_frac, T0_res, pit_res_max,
i_subfr, pit_min, pit_min, pit_fr1b, L_SUBFR );
+ move16();
IF( i_subfr == 0 )
{
@@ -1986,6 +2273,7 @@ void Mode2_pit_encode_fx(
}
*T0 = E_GAIN_closed_loop_search_fx( exc, xn, h1, *T0_min, *T0_min_frac, *T0_max, *T0_max_frac, shr( pit_res_max, 1 ), T0_frac, T0_res, pit_res_max,
i_subfr, pit_min, pit_min, pit_fr1b, L_SUBFR );
+ move16();
IF( i_subfr == 0 )
{
@@ -2046,6 +2334,7 @@ static void limit_T0_voiced2(
if ( LT_16( temp1, t ) )
{
temp1 = t;
+ move16();
}
temp2 = mult( temp1, inv_T0_res[res2] );
@@ -2092,16 +2381,19 @@ static void limit_T0_voiced2(
move16();
*T0_max_frac = sub( temp1, i_mult2( temp2, res ) );
+ move16();
IF( GT_16( *T0_max, pit_max ) )
{
*T0_max = pit_max;
*T0_max_frac = sub( res, 1 );
+ move16();
+ move16();
temp1 = add( sub( i_mult2( *T0_max, res ), 64 ), res );
temp2 = mult( temp1, inv_T0_res[res2] );
- if ( EQ_16( res, 6 ) )
+ IF( EQ_16( res, 6 ) )
{
temp2 = shr( temp2, 1 );
}
@@ -2137,14 +2429,17 @@ void Mode2_abs_pit_enc_fx(
IF( LT_16( T0, pit_fr2 ) )
{
**pt_indice = add( i_mult2( T0, pit_res_max ), sub( T0_frac, i_mult2( pit_min, pit_res_max ) ) );
+ move16();
}
ELSE IF( LT_16( T0, pit_fr1 ) )
{
**pt_indice = add( sub( add( i_mult2( T0, pit_res_max_half ), T0_frac ), i_mult2( pit_fr2, pit_res_max_half ) ), i_mult2( sub( pit_fr2, pit_min ), pit_res_max ) );
+ move16();
}
ELSE
{
**pt_indice = add( add( sub( T0, pit_fr1 ), i_mult2( sub( pit_fr2, pit_min ), pit_res_max ) ), i_mult2( sub( pit_fr1, pit_fr2 ), pit_res_max_half ) );
+ move16();
}
( *pt_indice )++;
diff --git a/lib_enc/pitch_ol2.c b/lib_enc/pitch_ol2.c
index 4e4277eef53dad8cbbdae27ed9fcd105103e7fb3..1ce646476840c491bc6205d31d3cc110101aa032 100644
--- a/lib_enc/pitch_ol2.c
+++ b/lib_enc/pitch_ol2.c
@@ -66,17 +66,18 @@
void StableHighPitchDetect_ivas_fx(
Word16 *flag_spitch, /* o : flag to indicate very short stable pitch */
Word16 pitch[], /* i/o: OL pitch buffer */
- const Word16 voicing[], /* i : OL pitch gains */
- const Word16 wsp[], /* i : weighted speech */
+ const Word16 voicing[], /* i : OL pitch gains Q15 */
+ const Word16 wsp[], /* i : weighted speech Qx */
const Word16 localVAD, /* i : local VAD flag */
Word16 *voicing_sm, /* i/o: smoothed open-loop pitch gains */
Word16 *voicing0_sm, /* i/o: smoothed high pitch gains */
- Word16 *LF_EnergyRatio_sm, /* i/o: smoothed [0, 300Hz] relative peak energy*/
+ Word16 *LF_EnergyRatio_sm, /* i/o: smoothed [0, 300Hz] relative peak energy Q7*/
Word16 *predecision_flag, /* i/o: predecision flag */
- Word32 *diff_sm, /* i/o: smoothed pitch frequency difference */
- Word32 *energy_sm, /* i/o: smoothed energy around pitch frequency */
+ Word32 *diff_sm, /* i/o: smoothed pitch frequency difference Q7*/
+ Word32 *energy_sm, /* i/o: smoothed energy around pitch frequency Q7*/
Word16 Q_new,
- Word16 EspecdB[] )
+ Word16 EspecdB[] /*Q8*/
+)
{
Word16 i, pitch_freq_point;
Word16 T, Tp, pit_min;
@@ -92,16 +93,12 @@ void StableHighPitchDetect_ivas_fx(
#endif
/*voicing = (voicing[0] + voicing[1] + voicing[2] )/3;*/
- L_tmp = L_mult( voicing[0], 10923 );
- L_tmp = L_mac( L_tmp, voicing[1], 10923 );
- L_tmp = L_mac( L_tmp, voicing[2], 10923 );
-#ifdef BASOP_NOGLOB
+ 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*/ );
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 ), voicing_m, 8192 ) );
+ *voicing_sm = round_fx( L_mac( L_mult( *voicing_sm, 24576 /*0.75f Q15*/ ), voicing_m, 8192 /*0.25f Q15*/ ) );
move16();
/* pitch_freq_point = (short)(L_FFT/(mult_fact*T_op[1])+0.5f);*/
@@ -131,10 +128,10 @@ void StableHighPitchDetect_ivas_fx(
L_tmp = Mult_32_16( sum_energy, tmp1 );
sum_energy = L_shl( L_tmp, sub( exp, 14 ) );
/**diff_sm = 0.2f * diff + 0.8f * *diff_sm;*/
- *diff_sm = L_add( Mult_32_16( diff, 6554 ), Mult_32_16( *diff_sm, 26214 ) );
+ *diff_sm = L_add( Mult_32_16( diff, 6554 /*.2f Q15*/ ), Mult_32_16( *diff_sm, 26214 /*.8f Q15*/ ) );
move32();
/**energy_sm = 0.2f * sum_energy + 0.8f * *energy_sm;*/
- *energy_sm = L_add( Mult_32_16( sum_energy, 6554 ), Mult_32_16( *energy_sm, 26214 ) );
+ *energy_sm = L_add( Mult_32_16( sum_energy, 6554 /*.2f Q15*/ ), Mult_32_16( *energy_sm, 26214 /*.8f Q15*/ ) );
move32();
/*diff /= sum_energy;*/
@@ -148,53 +145,33 @@ 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();
- IF( LT_32( *diff_sm, -1280 ) && LT_32( *energy_sm, 4928 ) && LT_16( diff16, -26214 ) )
+ IF( LT_32( *diff_sm, -1280 /*-10.0f Q7*/ ) && LT_32( *energy_sm, 4928 /*38.5f Q7*/ ) && LT_16( diff16, -26214 /*-.8f Q15*/ ) )
{
*predecision_flag = 1;
move16();
}
test();
test();
- if ( GT_32( *diff_sm, 1280 ) && GT_32( *energy_sm, 10624 ) && GT_16( diff16, 16384 ) )
+ if ( GT_32( *diff_sm, 1280 /*10.0f Q7*/ ) && GT_32( *energy_sm, 10624 /*83.0f Q7*/ ) && GT_16( diff16, 16384 /*.5 Q15*/ ) )
{
*predecision_flag = 0;
move16();
@@ -222,13 +199,13 @@ void StableHighPitchDetect_ivas_fx(
*LF_EnergyRatio_sm = round_fx( L_tmp );
move16();
test();
- if ( GT_16( *LF_EnergyRatio_sm, 4480 ) || GT_16( ratio, 6400 ) )
+ if ( GT_16( *LF_EnergyRatio_sm, 4480 /*35.0f Q7*/ ) || GT_16( ratio, 6400 /*50.0f Q7*/ ) )
{
*predecision_flag = 1;
move16();
}
- if ( LT_16( *LF_EnergyRatio_sm, 2048 ) )
+ if ( LT_16( *LF_EnergyRatio_sm, 2048 /*16.0f Q7*/ ) )
{
*predecision_flag = 0;
move16();
@@ -269,13 +246,9 @@ 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, *voicing0_sm ), 8192, cor_max16 ) );
+ *voicing0_sm = round_fx( L_mac( L_mult( 24576 /*.75f Q15*/, *voicing0_sm ), 8192 /*.25f Q15*/, cor_max16 ) );
move16();
/* final short pitch detection */
@@ -285,7 +258,7 @@ void StableHighPitchDetect_ivas_fx(
*flag_spitch = 0;
move16();
IF( ( EQ_16( localVAD, 1 ) ) && ( EQ_16( *predecision_flag, 1 ) ) &&
- ( GT_16( *voicing0_sm, 16384 ) ) && ( GT_16( *voicing0_sm, mult_r( *voicing_sm, 21299 ) ) ) )
+ ( GT_16( *voicing0_sm, 21299 /*.65f in Q15*/ ) ) && ( GT_16( *voicing0_sm, mult_r( *voicing_sm, 22938 /*.7f in Q15*/ ) ) ) )
{
*flag_spitch = 1;
move16();
diff --git a/lib_enc/pitch_ol2_fx.c b/lib_enc/pitch_ol2_fx.c
index bd66fda139e28f53c4564560776f148ba8d5e4d2..5d68216c934793aa5e0cc6c1d9835d10358e0ec3 100644
--- a/lib_enc/pitch_ol2_fx.c
+++ b/lib_enc/pitch_ol2_fx.c
@@ -51,6 +51,7 @@ void pitch_ol2_fx(
Word16 pit_max;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/* initialization */
@@ -80,13 +81,9 @@ 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();
}
pt_cor_fx = cor_fx + L_INTERPOL1;
@@ -94,7 +91,7 @@ void pitch_ol2_fx(
move16();
t1s = t0_min;
move16();
- FOR( t = add( t0_min, 1 ); t <= t0_max; t++ )
+ FOR( t = t0_min + 1; t <= t0_max; t++ )
{
if ( GT_16( *pt_cor_fx, cor_max_fx ) )
{
@@ -123,8 +120,7 @@ void pitch_ol2_fx(
{
t0s = sub( t0s, 1 );
cor_max_fx = Interpol_4( &pt_cor_fx[t0s], fraction );
- move16();
- FOR( i = add( fraction, step ); i <= 3; i += step )
+ FOR( i = fraction + step; i <= 3; i += step )
{
temp_fx = Interpol_4( &pt_cor_fx[t0s], i );
if ( GT_16( temp_fx, cor_max_fx ) )
@@ -145,7 +141,6 @@ void pitch_ol2_fx(
FOR( i = 0; i <= 3; i += step ) /* Process positive fractions */
{
temp_fx = Interpol_4( &pt_cor_fx[t1s], i );
- move16();
IF( GT_16( temp_fx, cor_max_fx ) )
{
@@ -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,12 @@ 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
{
@@ -258,22 +237,20 @@ void StableHighPitchDetect_fx(
Word16 Top;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/*voicing = (voicing[0] + voicing[1] + voicing[2] )/3;*/
- L_tmp = L_mult( voicing[0], 10923 );
- L_tmp = L_mac( L_tmp, voicing[1], 10923 );
- L_tmp = L_mac( L_tmp, voicing[2], 10923 );
-#ifdef BASOP_NOGLOB
+ 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*/ );
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 ), voicing_m, 8192 ) );
-
+ *voicing_sm = round_fx( L_mac( L_mult( *voicing_sm, 24576 /*0.75f Q15*/ ), voicing_m, 8192 /*0.25f Q15*/ ) );
+ move16();
/* pitch_freq_point = (short)(L_FFT/(mult_fact*T_op[1])+0.5f);*/
Top = pitch[1];
+ move16();
exp = norm_s( Top );
tmp = div_s( shl( 1, sub( 14, exp ) ), Top ); /*Q(29 - exp)*/
L_tmp = L_mult0( tmp, L_FFT ); /*Q(29 - exp)*/
@@ -309,53 +286,33 @@ 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();
- IF( LT_32( *diff_sm, -1280 ) && LT_32( *energy_sm, 4928 ) && LT_16( diff16, -26214 ) )
+ if ( LT_32( *diff_sm, -1280 /*-10.0f Q7*/ ) && LT_32( *energy_sm, 4928 /*38.5f Q7*/ ) && LT_16( diff16, -26214 /*-.8f Q15*/ ) )
{
*predecision_flag = 1;
move16();
}
test();
test();
- if ( GT_32( *diff_sm, 1280 ) && GT_32( *energy_sm, 10624 ) && GT_16( diff16, 16384 ) )
+ if ( GT_32( *diff_sm, 1280 /*10.0f Q7*/ ) && GT_32( *energy_sm, 10624 /*83.0f Q7*/ ) && GT_16( diff16, 16384 /*.5 Q15*/ ) )
{
*predecision_flag = 0;
move16();
@@ -372,14 +329,15 @@ void StableHighPitchDetect_fx(
L_tmp = L_mult( ratio, 2048 );
L_tmp = L_mac( L_tmp, *LF_EnergyRatio_sm, 30720 );
*LF_EnergyRatio_sm = round_fx( L_tmp );
+ move16();
test();
- if ( GT_16( *LF_EnergyRatio_sm, 4480 ) || GT_16( ratio, 6400 ) )
+ if ( GT_16( *LF_EnergyRatio_sm, 4480 /*35.0f Q7*/ ) || GT_16( ratio, 6400 /*50.0f Q7*/ ) )
{
*predecision_flag = 1;
move16();
}
- if ( LT_16( *LF_EnergyRatio_sm, 2048 ) )
+ if ( LT_16( *LF_EnergyRatio_sm, 2048 /*16.0f Q7*/ ) )
{
*predecision_flag = 0;
move16();
@@ -420,13 +378,10 @@ 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, *voicing0_sm ), 8192, cor_max16 ) );
+ *voicing0_sm = round_fx( L_mac( L_mult( 24576 /*.75f Q15*/, *voicing0_sm ), 8192 /*.25f Q15*/, cor_max16 ) );
+ move16();
/* final short pitch detection */
test();
diff --git a/lib_enc/pitch_ol_fx.c b/lib_enc/pitch_ol_fx.c
index 82b00ead0b1b92e3a5ec90ed7fbc5389dc8eab07..91181714af9242f49697b8f221c167f31d525faf 100644
--- a/lib_enc/pitch_ol_fx.c
+++ b/lib_enc/pitch_ol_fx.c
@@ -46,21 +46,6 @@
/*-----------------------------------------------------------------*
* Local function prototypes
*-----------------------------------------------------------------*/
-static Word32 Dot_product12_o_ivas( /* (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) */
- Flag *Overflow_out /* o : propagating the Overflow flag to upper level, set to NULL to ignore internal overflows */
-);
-static Word32 Dot_product12_ivas( /* (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) */
-);
-static Word32 Dot_product12_OL_ivas( Word16 *sum1, const Word16 x[], const Word16 y[], const Word16 lg, const Word16 lg2, Word16 *exp, Word16 *exp2 );
-static Word32 Dot_product12_OL_back_ivas( Word16 *sum1, const Word16 x[], const Word16 y[], const Word16 lg, const Word16 lg2, Word16 *exp, Word16 *exp2 );
static void LP_Decim2_Copy( const Word16 x[], Word16 y[], Word16 l, Word16 mem[] );
@@ -73,191 +58,7 @@ static Word16 pitch_coherence_fx( Word16 pitch0, Word16 pitch1, Word16 fac_max,
static Word32 Dot_product12_OL( Word16 *sum1, const Word16 x[], const Word16 y[], const Word16 lg, const Word16 lg2, Word16 *exp, Word16 *exp2 );
static Word32 Dot_product12_OL_back( Word16 *sum1, const Word16 x[], const Word16 y[], const Word16 lg, const Word16 lg2, Word16 *exp, Word16 *exp2 );
-#ifdef BASOP_NOGLOB
-static Word32 Dot_product12_o_ivas( /* (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) */
- Flag *Overflow_out /* o : propagating the Overflow flag to upper level, set to NULL to ignore internal overflows */
-)
-#else /* BASOP_NOGLOB */
-Word32 Dot_product12_ivas( /* (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( 0, 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 */
-
- sft = norm_l( L_sum );
- L_sum = L_shl( L_sum, sft );
-
- *exp = sub( 30, sft );
- move16(); /* exponent = 0..30 */
-
- return L_sum;
-}
-
-static Word32 Dot_product12_ivas( /* (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) */
-)
-{
- /* Ignore internal overflows */
- return Dot_product12_o_ivas( x, y, lg, exp, NULL );
-}
-/*---------------------------------------------------------------------*
- * Dot_product12_OL_back()
- *
- * two different length dot products of x and y, computed backward
- *---------------------------------------------------------------------*/
-static Word32 Dot_product12_OL_back_ivas( /* o : Q31: normalized result (1 < val <= -1) */
- Word16 *sum1, /* o : Q31: normalized result 2 */
- const Word16 x[], /* i : 12bits: x vector */
- const Word16 y[], /* i : 12bits: y vector */
- const Word16 lg, /* i : vector length */
- const Word16 lg2, /* i : vector length 2 */
- Word16 *exp, /* o : exponent of result (0..+30) */
- Word16 *exp2 /* o : exponent of result 2 (0..+30) */
-)
-{
- Word16 i, sft;
- Word32 L_sum, L_sum2;
- Flag Overflow_ignored = 0;
-
- L_sum = L_mac( 0, x[0], y[0] );
- IF( LE_16( lg, lg2 ) )
- {
- FOR( i = 1; i < lg; i++ )
- {
- L_sum = L_mac_o( L_sum, x[-i], y[-i], &Overflow_ignored );
- }
- /* sets to 'L_sum' in 1 clock */
- L_sum2 = L_sum;
- move32();
- FOR( ; i < lg2; i++ )
- {
- L_sum2 = L_mac_o( L_sum2, x[-i], y[-i], &Overflow_ignored );
- }
- }
- ELSE
- {
- FOR( i = 1; i < lg2; i++ )
- {
- L_sum = L_mac_o( L_sum, x[-i], y[-i], &Overflow_ignored );
- }
- /* sets to 'L_sum' in 1 clock */
- L_sum2 = L_sum;
- move32();
- FOR( ; i < lg; i++ )
- {
- L_sum = L_mac_o( L_sum, x[-i], y[-i], &Overflow_ignored );
- }
- }
-
- /* Q31 */
- sft = norm_l( L_sum );
- L_sum = L_shl( L_sum, sft );
- *exp = sub( 30, sft );
- move16(); /* exponent = 0..30 */
-
- sft = norm_l( L_sum2 );
- L_sum2 = L_shl( L_sum2, sft );
- *exp2 = sub( 30, sft );
- move16(); /* exponent = 0..30 */
-
- *sum1 = extract_h( L_shr( L_sum2, 1 ) );
-
- return L_sum;
-}
-/*---------------------------------------------------------------------*
- * Dot_product12_OL
- *
- * two different length dot products of x and y
- *---------------------------------------------------------------------*/
-static Word32 Dot_product12_OL_ivas( /* o : Q31: normalized result (1 < val <= -1) */
- Word16 *sum1, /* o : Q31: normalized result 2 */
- const Word16 x[], /* i : 12bits: x vector */
- const Word16 y[], /* i : 12bits: y vector */
- const Word16 lg, /* i : vector length */
- const Word16 lg2, /* i : vector length 2 */
- Word16 *exp, /* o : exponent of result (0..+30) */
- Word16 *exp2 /* o : exponent of result 2 (0..+30) */
-)
-{
- Word16 i, sft;
- Word32 L_sum, L_sum2;
- Flag Overflow_ignored = 0;
- L_sum = L_mac( 0, x[0], y[0] );
- IF( LE_16( lg, lg2 ) )
- {
- FOR( i = 1; i < lg; i++ )
- {
- L_sum = L_mac_o( L_sum, x[i], y[i], &Overflow_ignored );
- }
- /* sets to 'L_sum' in 1 clock */
- L_sum2 = L_sum;
- move32();
- FOR( ; i < lg2; i++ )
- {
- L_sum2 = L_mac_o( L_sum2, x[i], y[i], &Overflow_ignored );
- }
- }
- ELSE
- {
- FOR( i = 1; i < lg2; i++ )
- {
- L_sum = L_mac_o( L_sum, x[i], y[i], &Overflow_ignored );
- }
- /* sets to 'L_sum' in 1 clock */
- L_sum2 = L_sum;
- move32();
- FOR( ; i < lg; i++ )
- {
- L_sum = L_mac_o( L_sum, x[i], y[i], &Overflow_ignored );
- }
- }
-
- /* Q31 */
- sft = norm_l( L_sum );
- L_sum = L_shl( L_sum, sft );
- *exp = sub( 30, sft );
- move16(); /* exponent = 0..30 */
-
- sft = norm_l( L_sum2 );
- L_sum2 = L_shl( L_sum2, sft );
- *exp2 = sub( 30, sft );
- move16(); /* exponent = 0..30 */
- *sum1 = extract_h( L_shr( L_sum2, 1 ) );
-
- return L_sum;
-}
/*-----------------------------------------------------------------*
* pitch_ol_init()
*
@@ -461,9 +262,9 @@ void pitch_ol_fx(
tmp_mem[2] = mem_decim2[2];
move16();
- LP_Decim2_Copy( &wsp[L_FRAME], &wsp2[shr( L_FRAME, 1 )], L_LOOK_12k8, tmp_mem ); /* shr() used instead of division by OPL_DECIM*/
+ LP_Decim2_Copy( &wsp[L_FRAME], &wsp2[( L_FRAME / 2 )], L_LOOK_12k8, tmp_mem ); /* shr() used instead of division by OPL_DECIM*/
- Copy( &old_wsp2[shr( L_FRAME, 1 )], st_old_wsp2, ( L_WSP_MEM - L_INTERPOL ) / OPL_DECIM );
+ Copy( &old_wsp2[L_FRAME / 2], st_old_wsp2, ( L_WSP_MEM - L_INTERPOL ) / OPL_DECIM );
/*-----------------------------------------------------------------*
* Attenuate the correlation correction factor due to noise.
@@ -936,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 );
@@ -954,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();
@@ -980,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 );
@@ -999,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();
@@ -1083,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 */
@@ -1101,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 */
@@ -1287,7 +1064,7 @@ void pitch_ol_ivas_fx(
Word16 *old_pitch, /* i/o: pitch of the 2nd half-frame of previous frame (i.e. pitch[1]) Q0 */
Word16 *old_corr, /* i/o: correlation of old_pitch (i.e. voicing[1] or corr_mean) Q15 */
Word16 corr_shift, /* i : normalized correlation correction Q15 */
- Word16 *old_thres, /* i/o: maximum correlation weighting with respect to past frame pitch Q15 */
+ Word16 *old_thres, /* i/o: maximum correlation weighting with respect to past frame pitch Q14 */
Word16 *delta_pit, /* i/o: old pitch extrapolation correction in range [-14,+14] Q0 */
Word16 *st_old_wsp2, /* i/o: weighted speech memory qwsp */
const Word16 *wsp, /* i : weighted speech for current frame and look-ahead qwsp */
@@ -1295,7 +1072,8 @@ void pitch_ol_ivas_fx(
const Word16 relE, /* i : relative frame energy Q8 */
const Word16 last_class, /* i : frame classification of last frame */
const Word16 bwidth, /* i : bandwidth */
- const Word16 Opt_SC_VBR /* i : SC-VBR flag */
+ const Word16 Opt_SC_VBR, /* i : SC-VBR flag */
+ Word16 qwsp /* i : Q factor for wsp Q0 */
)
{
Word16 ftmp, old_wsp2[( L_WSP - L_INTERPOL ) / OPL_DECIM], *wsp2;
@@ -1303,11 +1081,11 @@ void pitch_ol_ivas_fx(
Word16 scale1[2 * DELTA_COH - 1];
Word16 scaled_buf[2 * LEN_X + 3 * ( DELTA_COH - 1 )];
- Word16 scaled_buf_exp[2 * LEN_X + 3 * ( DELTA_COH - 1 )], exp_sect[8], exp_sect1[8], exp_sect0;
- Word16 cor_buf[2 * LEN_X];
- Word16 *pt_exp1, *pt_exp2, *pt_exp3, *pt_exp4;
+ Word16 scaled_buf_exp[2 * LEN_X + 3 * ( DELTA_COH - 1 )];
+ Word16 cor_buf[2 * LEN_X], cor_buf_exp[2 * LEN_X];
Word16 *pt1, *pt2, *pt3, *pt4, *pt5, *pt6;
- Word16 *pt_cor0, *pt_cor1, *pt_cor2, *pt_cor3, *pt_cor4, *pt_cor5, *pt_cor6;
+ Word16 *pt_cor0, *pt_cor1, *pt_cor2, *pt_cor3, *pt_cor4;
+ Word16 *pt_cor0_exp, *pt_cor1_exp, *pt_cor2_exp, *pt_cor3_exp, *pt_cor4_exp;
Word16 thres1[6];
Word16 diff, cnt, ind, ind1, offset, offset1, offset_la, offset_la1, coh_flag, coh_flag1;
Word16 ind_corX, ind1_corX;
@@ -1316,10 +1094,11 @@ void pitch_ol_ivas_fx(
Word16 len_temp;
Word16 pitchX[NHFR][2 * NSECT], pitch_tmp[2 * NHFR], ind_tmp[2 * NHFR], tmp_buf[NHFR + 1];
- Word16 enr0[NSECT], enr0_exp[NSECT], enr0_1[NSECT], enr0_1_exp[NSECT], enr1, enr1_exp, enr2_exp;
- Word32 enr, enr2, Ltmp;
+ Word16 enr0_exp[NSECT], enr0_1_exp[NSECT], enr1_exp;
+ Word32 enr0[NSECT], enr0_1[NSECT], enr1;
+ Word64 temp, temp1;
+ Word32 Ltmp;
Word16 fac, tmp16, tmp16_2;
- Word16 qCorX, qScaledX;
Word16 scaledX[NHFR][2 * NSECT], corX[NHFR][2 * NSECT], cor_tmp[2 * NHFR], cor_mean;
const Word16 *len, *len1, *sublen, *sublen1, *pit_max, *sec_length, *sec_length1;
@@ -1327,6 +1106,8 @@ void pitch_ol_ivas_fx(
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
#endif
+ Word16 new_q;
+ new_q = sub( 63, shl( qwsp, 1 ) );
/*--------------------------------------------------------------*
* Initialization
@@ -1354,7 +1135,7 @@ void pitch_ol_ivas_fx(
test();
test();
IF( ( ( NE_16( bwidth, NB ) ) && ( GT_16( *old_pitch, PIT_MIN ) ) ) ||
- ( ( EQ_16( bwidth, NB ) ) && ( ( GT_16( *old_pitch, PIT_MIN2_1 ) ) || ( LT_16( *old_thres, 3277 ) ) ) ) ) /* 0.1 inQ15*/
+ ( ( EQ_16( bwidth, NB ) ) && ( ( GT_16( *old_pitch, PIT_MIN2_1 ) ) || ( LT_16( *old_thres, 1638 /* 0.1 in Q14*/ ) ) ) ) )
{
pit_min = PIT_MIN / OPL_DECIM;
move16();
@@ -1403,9 +1184,9 @@ void pitch_ol_ivas_fx(
tmp_mem[2] = mem_decim2[2];
move16();
- LP_Decim2_Copy( &wsp[L_FRAME], &wsp2[shr( L_FRAME, 1 )], L_LOOK_12k8, tmp_mem ); /* shr() used instead of division by OPL_DECIM*/
+ LP_Decim2_Copy( &wsp[L_FRAME], &wsp2[L_FRAME / 2], L_LOOK_12k8, tmp_mem ); /* shr() used instead of division by OPL_DECIM*/
- Copy( &old_wsp2[shr( L_FRAME, 1 )], st_old_wsp2, ( L_WSP_MEM - L_INTERPOL ) / OPL_DECIM );
+ Copy( &old_wsp2[L_FRAME / 2], st_old_wsp2, ( L_WSP_MEM - L_INTERPOL ) / OPL_DECIM );
/*-----------------------------------------------------------------*
* Attenuate the correlation correction factor due to noise.
@@ -1423,21 +1204,16 @@ void pitch_ol_ivas_fx(
pt1 = scale1 + DELTA_COH - 1;
pt2 = pt1;
- tmp16 = mult( negate( *old_thres ), MAX_16 / DELTA_COH );
- k = *old_thres;
- move16();
+ tmp16 = mult( *old_thres, -32768 / DELTA_COH ); // Q14
+ k = add( *old_thres, ONE_IN_Q14 ); // Q14
FOR( i = 0; i < DELTA_COH; i++ )
{
- /*
- * *pt1 = ( -(*old_thres)/DELTA_COH * i + *old_thres+1.0f );
- * To keep Q15 values, the following code does not add 1 to the result.
- * A scaling factor must be applied accordingly (see next use of scale1)
- */
- *pt1 = k;
+ *pt1 = k; // Q14
+ *pt2-- = *pt1++; // Q14
move16();
- k = add( k, tmp16 );
- *pt2-- = *pt1++;
move16();
+
+ k = add( k, tmp16 ); // Q14
}
/*-----------------------------------------------------------------------------*
@@ -1454,9 +1230,13 @@ void pitch_ol_ivas_fx(
* Loop for all three half-frames (current frame + look-ahead)
*-----------------------------------------------------------------*/
pt_cor0 = scaled_buf + DELTA_COH - 1;
+ pt_cor0_exp = scaled_buf_exp + DELTA_COH - 1;
pt_cor2 = pt_cor0 - pit_min + old_tmp;
+ pt_cor2_exp = pt_cor0_exp - pit_min + old_tmp;
+
pt_cor4 = pt_cor0 - pit_min1 + old_tmp + ( DELTA_COH - 1 ) + len_x;
+ pt_cor4_exp = pt_cor0_exp - pit_min1 + old_tmp + ( DELTA_COH - 1 ) + len_x;
FOR( i = 0; i < NHFR; i++ ) /* i = 0, 1, 2 */
{
@@ -1464,15 +1244,14 @@ void pitch_ol_ivas_fx(
pt2 = pt1 - pit_min; /* *pt2 -> Q12 */
pt4 = pt1 - pit_min1; /* *pt4 -> Q12 */
- enr = 0;
+ temp = 0;
+ move64();
pt_cor1 = pt_cor0;
- pt_cor3 = pt_cor0 + ( DELTA_COH - 1 ) + len_x;
+ pt_cor1_exp = pt_cor0_exp;
- pt_exp1 = scaled_buf_exp + DELTA_COH - 1;
- pt_exp2 = pt_exp1;
- pt_exp3 = scaled_buf_exp + 2 * ( DELTA_COH - 1 ) + len_x;
- pt_exp4 = pt_exp3;
+ pt_cor3 = pt_cor0 + ( DELTA_COH - 1 ) + len_x;
+ pt_cor3_exp = pt_cor0_exp + ( DELTA_COH - 1 ) + len_x;
IF( LT_16( i, NHFR - 1 ) ) /* First two half-frames (current frame) */
{
@@ -1488,72 +1267,83 @@ void pitch_ol_ivas_fx(
/* 1st set */
k = (Word16) ( pt1 - pt3 );
move16();
- Flag overflow = 0;
FOR( k = add( k, len[j] ); k > 0; k-- )
{
- enr = L_mac0_o( enr, *pt3, *pt3, &overflow );
+ temp = W_mac0_16_16( temp, *pt3, *pt3 ); // 2*qwsp
pt3++;
}
- /* keep Q15 normalized result */
- cnt = norm_l( enr );
- enr0[j] = extract_h( L_shl( enr, cnt ) );
- enr0_exp[j] = sub( 30, cnt );
- move16();
+ IF( temp == 0 )
+ {
+ enr0[j] = 21474836; // 0.01 in Q31
+ enr0_exp[j] = 0;
+ move32();
+ move16();
+ }
+ ELSE
+ {
+ cnt = W_norm( temp );
+ enr0[j] = W_extract_h( W_shl( temp, cnt ) ); // 2*qwsp+cnt-32
+ enr0_exp[j] = sub( new_q, cnt ); // 31-(2*qwsp+cnt-32)
+ move32();
+ move16();
+ }
/* Reduce complexity (length of 'enr2' section is equal or larger than 'enr') */
pt5 = pt3;
- enr2 = enr; /* sets to 'enr' in 1 clock */
- move32();
/* 2nd set */
k = (Word16) ( pt1 - pt5 );
move16();
- FOR( k = add( k, len1[j] ); k > 0; k-- )
+ temp1 = temp;
+ move64();
+ FOR( k = ( k + len1[j] ); k > 0; k-- )
{
- enr2 = L_mac0_o( enr2, *pt5, *pt5, &overflow );
+ temp1 = W_mac0_16_16( temp1, *pt5, *pt5 ); // 2*qwsp
pt5++;
}
- cnt = norm_l( enr2 );
- enr0_1[j] = extract_h( L_shl( enr2, cnt ) );
- enr0_1_exp[j] = sub( 30, cnt );
- move16();
+ IF( temp1 == 0 )
+ {
+ enr0_1[j] = 21474836; // 0.01 in Q31
+ enr0_1_exp[j] = 0;
+ move32();
+ move16();
+ }
+ ELSE
+ {
+ cnt = W_norm( temp1 );
+ enr0_1[j] = W_extract_h( W_shl( temp1, cnt ) ); // 2*qwsp+cnt-32
+ enr0_1_exp[j] = sub( new_q, cnt ); // 31-(2*qwsp+cnt-32)
+ move32();
+ move16();
+ }
}
/*----------------------------------------------------------*
* Find correlation for the non-overlapping pitch lag values
*----------------------------------------------------------*/
- exp_sect[subsect0] = 0;
- move16();
- pt_cor5 = pt_cor1;
- pt_cor6 = pt_cor3;
-
- tmp16 = exp_sect[subsect0];
- move16();
k = (Word16) ( pt2 - pt1 + pit_max[subsect0] );
+ move16();
- IF( k >= 0 )
+ FOR( ; k >= 0; k-- )
{
- len_temp = sublen[0];
- move16();
-
- FOR( ; k >= 0; k-- )
+ temp = 0;
+ move64();
+ FOR( m = 0; m < sublen[0]; m++ )
{
- /* Keep Q15 normalized result */
- /* shr by 1 to make room for scaling in the neighbourhood of the extrapolated pitch */
- /* Update exponent to reflect shr by 1 */
- *pt_cor1 = extract_h( L_shr( Dot_product12_ivas( pt1, pt2--, len_temp, pt_exp1 ), 1 ) );
-
- /* save the biggest exponent */
- tmp16 = s_max( tmp16, *pt_exp1 );
-
- pt_cor1++;
- pt_exp1++;
+ temp = W_mac0_16_16( temp, pt1[m], pt2[m] ); // 2*qwsp
}
+ cnt = W_norm( temp );
+ *pt_cor1 = extract_h( W_extract_h( W_shl( temp, cnt ) ) ); // 2*qwsp+cnt-32-16
+ *pt_cor1_exp = sub( new_q, cnt ); // 15-(2*qwsp+cnt-32-16)
+ move16();
+ move16();
+
+ pt2--;
+ pt_cor1++;
+ pt_cor1_exp++;
}
- exp_sect[subsect0] = tmp16;
- move16();
/*----------------------------------------------------------*
* For each subsection, find the correlation
@@ -1566,44 +1356,73 @@ void pitch_ol_ivas_fx(
k = (Word16) ( pt2 - pt1 );
move16();
k = add( k, pit_max[j + 1] );
- exp_sect[j + 1] = 0;
- move16();
- exp_sect1[j] = 0;
- move16();
- IF( k >= 0 )
+ /* Keep Q15 normalized result */
+ IF( LT_16( sublen[j], sublen1[j] ) )
{
- ind = exp_sect[j + 1];
- move16();
- ind1 = exp_sect1[j];
- move16();
+ FOR( ; k >= 0; k-- )
+ {
+ temp = W_mult0_16_16( pt1[0], pt2[0] ); // 2*qwsp
+ FOR( m = 1; m < sublen[j]; m++ )
+ {
+ temp = W_mac0_16_16( temp, pt1[m], pt2[m] ); // 2*qwsp
+ }
+ cnt = W_norm( temp );
+ *pt_cor1 = extract_h( W_extract_h( W_shl( temp, cnt ) ) ); // 2*qwsp+cnt-32-16
+ *pt_cor1_exp = sub( new_q, cnt );
+ move16();
+ move16();
+ FOR( ; m < sublen1[j]; m++ )
+ {
+ temp = W_mac0_16_16( temp, pt1[m], pt2[m] ); // 2*qwsp
+ }
+ cnt = W_norm( temp );
+ *pt_cor3 = extract_h( W_extract_h( W_shl( temp, cnt ) ) ); // 2*qwsp+cnt-32-16
+ *pt_cor3_exp = sub( new_q, cnt );
+ move16();
+ move16();
+
+ pt_cor1++;
+ pt_cor1_exp++;
+ pt_cor3++;
+ pt_cor3_exp++;
+ pt2--;
+ }
+ }
+ ELSE
+ {
FOR( ; k >= 0; k-- )
{
- /* Keep Q15 normalized result */
- /* shr by 1 to make room for scaling in the neighbourhood of the extrapolated pitch */
- /* Update exponent to reflect shr by 1 (done in Dot_product12_OL() for pt_cor3/pt_exp3) */
- *pt_cor1 = extract_h( L_shr( Dot_product12_OL_ivas( pt_cor3, pt1, pt2--, sublen[j], sublen1[j], pt_exp1, pt_exp3 ), 1 ) );
- /* The line above replaces:
- * *pt_cor1 = shr(extract_h(Dot_product12(pt1, pt2, Sublen[j], pt_exp1)),1); move16();
- * *pt_cor3 = shr(extract_h(Dot_product12(pt1, pt2--, Sublen1[j+i*7], pt_exp3)),1); move16();
- */
+ temp = W_mult0_16_16( pt1[0], pt2[0] ); // 2*qwsp
+ FOR( m = 1; m < sublen1[j]; m++ )
+ {
+ temp = W_mac0_16_16( temp, pt1[m], pt2[m] ); // 2*qwsp
+ }
+ cnt = W_norm( temp );
+ *pt_cor3 = extract_h( W_extract_h( W_shl( temp, cnt ) ) ); // 2*qwsp+cnt-32-16
+ *pt_cor3_exp = sub( new_q, cnt );
+ move16();
+ move16();
- /* save the biggest exponent */
- ind = s_max( ind, *pt_exp1 );
- ind1 = s_max( ind1, *pt_exp3 );
+ FOR( ; m < sublen[j]; m++ )
+ {
+ temp = W_mac0_16_16( temp, pt1[m], pt2[m] ); // 2*qwsp
+ }
+ cnt = W_norm( temp );
+ *pt_cor1 = extract_h( W_extract_h( W_shl( temp, cnt ) ) ); // 2*qwsp+cnt-32-16
+ *pt_cor1_exp = sub( new_q, cnt );
+ move16();
+ move16();
pt_cor1++;
- pt_exp1++;
+ pt_cor1_exp++;
pt_cor3++;
- pt_exp3++;
+ pt_cor3_exp++;
+ pt2--;
}
- exp_sect[j + 1] = ind;
- move16();
- exp_sect1[j] = ind1;
- move16();
- } /* IF (k >= 0) */
- } /* FOR (j = subsect0; ... */
+ }
+ } /* FOR (j = subsect0; ... */
}
ELSE /* 3rd half-frame (look-ahead) */
{
@@ -1614,7 +1433,6 @@ void pitch_ol_ivas_fx(
/*-----------------------------------------------------------------*
* For each section in both sets, find fixed vector energy
*-----------------------------------------------------------------*/
- Flag overflow = 0;
FOR( j = sect0; j < NSECT; j++ ) /* loop for each section */
{
/* 1st set */
@@ -1623,93 +1441,91 @@ void pitch_ol_ivas_fx(
FOR( k = add( k, len[j] ); k > 0; k-- )
{
- enr = L_mac0_o( enr, *pt3, *pt3, &overflow );
+ temp = W_mac0_16_16( temp, *pt3, *pt3 );
pt3--;
}
-
- cnt = norm_l( enr );
- enr0[j] = extract_h( L_shl( enr, cnt ) ); /*qwsp+cnt-16*/
- enr0_exp[j] = sub( 30, cnt );
- move16();
+ IF( temp == 0 )
+ {
+ enr0[j] = 21474836; // 0.01 in Q31
+ enr0_exp[j] = 0;
+ move32();
+ move16();
+ }
+ ELSE
+ {
+ cnt = W_norm( temp );
+ enr0[j] = W_extract_h( W_shl( temp, cnt ) ); // 2*qwsp+cnt-32
+ enr0_exp[j] = sub( new_q, cnt ); // 31-(2*qwsp+cnt-32)
+ move32();
+ move16();
+ }
/* Reduce complexity (length of 'enr2' section is equal or larger than 'enr') */
pt5 = pt3;
- enr2 = enr;
- move16();
+ temp1 = temp;
+ move64();
/* 2nd set */
k = (Word16) ( pt5 - pt6 );
move16();
-
FOR( k = add( k, len1[j] ); k > 0; k-- )
{
- enr2 = L_mac0_o( enr2, *pt5, *pt5, &overflow );
+ temp1 = W_mac0_16_16( temp1, *pt5, *pt5 ); // 2*qwsp
pt5--;
}
-
- cnt = norm_l( enr2 );
- enr0_1[j] = extract_h( L_shl( enr2, cnt ) ); /*qwsp+cnt-16*/
- enr0_1_exp[j] = sub( 30, cnt );
- move16();
+ IF( temp1 == 0 )
+ {
+ enr0_1[j] = 21474836; // 0.01 in Q31
+ enr0_1_exp[j] = 0;
+ move32();
+ move16();
+ }
+ ELSE
+ {
+ cnt = W_norm( temp1 );
+ temp1 = W_shl( temp1, cnt ); // 2*qwsp+cnt
+ enr0_1[j] = W_extract_h( temp1 ); // 2*qwsp+cnt-32
+ enr0_1_exp[j] = sub( new_q, cnt ); // 31-(2*qwsp+cnt-32)
+ move32();
+ move16();
+ }
}
- /* Set pointers */
+ /* Set pointers: same as IF/ELSE block */
+ pt2 = pt6 - pit_min;
+ k = 2;
+ move16();
IF( sect0 != 0 )
{
pt2 = pt6 - add( pit_max[1], 1 );
k = sub( pit_max[2], pit_max[1] );
move16();
}
- ELSE
- {
- pt2 = pt6 - pit_min;
- k = 2;
- move16();
- }
/*-----------------------------------------------------------------*
* Find correlation for the non-overlapping pitch lag values
*-----------------------------------------------------------------*/
- exp_sect[subsect0] = 0;
- move16();
- pt_cor5 = pt_cor1;
- pt_cor6 = pt_cor3;
- tmp16 = exp_sect[subsect0];
+ len_temp = sublen[0];
move16();
- IF( k > 0 )
+ FOR( ; k > 0; k-- )
{
- len_temp = sublen[0];
- move16();
-
- FOR( ; k > 0; k-- )
+ temp = 0;
+ move64();
+ FOR( m = 0; m < len_temp; m++ )
{
- /* Following lines are equivalent of Dot_product12() but with a backward incrementing */
- Ltmp = L_deposit_l( 1 );
- FOR( m = 0; m < len_temp; m++ )
- {
- Ltmp = L_mac_o( Ltmp, pt6[-m], pt2[-m], &overflow );
- }
-
- /* Normalize acc in Q31 */
- tmp16_2 = norm_l( Ltmp );
- Ltmp = L_shl( Ltmp, tmp16_2 );
- *pt_exp1 = sub( 30, tmp16_2 );
- move16(); /* exponent = 0..30 */
-
- /* Save result */
- *pt_cor1 = extract_h( L_shr( Ltmp, 1 ) );
-
- /* Save the biggest exponent */
- tmp16 = s_max( tmp16, *pt_exp1 );
-
- pt_cor1++;
- pt_exp1++;
- pt2--;
+ temp = W_mac0_16_16( temp, pt6[-m], pt2[-m] ); // 2*qwsp
}
- exp_sect[subsect0] = tmp16;
+ tmp16_2 = W_norm( temp );
+ *pt_cor1 = extract_h( W_extract_h( W_shl( temp, tmp16_2 ) ) ); // 2*qwsp+tmp16_2
+ *pt_cor1_exp = sub( new_q, tmp16_2 ); // 2*qwsp+tmp16_2-32-16
move16();
+ move16();
+
+ pt_cor1++;
+ pt_cor1_exp++;
+ pt2--;
}
/*-----------------------------------------------------------------*
@@ -1718,125 +1534,115 @@ void pitch_ol_ivas_fx(
FOR( j = subsect0; j < NSUBSECT; j++ )
{
- exp_sect[j + 1] = 0;
- move16();
- exp_sect1[j] = 0;
- move16();
-
- ind = exp_sect[j + 1];
- move16();
- ind1 = exp_sect1[j];
- move16();
-
k = sub( pit_max[j + 1], pit_max[j] );
- FOR( ; k > 0; k-- )
+ IF( LT_16( sublen[j], sublen1[j] ) )
{
- *pt_cor1 = extract_h( L_shr( Dot_product12_OL_back_ivas( pt_cor3, pt6, pt2--, sublen[j], sublen1[j], pt_exp1, pt_exp3 ), 1 ) );
-
- /* Save the biggest exponent */
- ind = s_max( ind, *pt_exp1 );
- ind1 = s_max( ind1, *pt_exp3 );
-
- pt_cor1++;
- pt_exp1++;
- pt_cor3++;
- pt_exp3++;
- }
- exp_sect[j + 1] = ind;
- move16();
- exp_sect1[j] = ind1;
- move16();
- }
- } /* 3rd half-frame (look-ahead) */
+ FOR( ; k > 0; k-- )
+ {
+ temp = W_mult0_16_16( pt6[0], pt2[0] ); // 2*qwsp
+ FOR( m = 1; m < sublen[j]; m++ )
+ {
+ temp = W_mac0_16_16( temp, pt6[-m], pt2[-m] ); // 2*qwsp
+ }
+ cnt = W_norm( temp );
+ *pt_cor1 = extract_h( W_extract_h( W_shl( temp, cnt ) ) ); // 2*qwsp+cnt-32-16
+ *pt_cor1_exp = sub( new_q, cnt );
+ move16();
+ move16();
- /* Scale all values in each section to the same exponent for upcoming Find_max() */
- offset = 0;
- move16();
- offset1 = 0;
- move16();
- exp_sect1[7] = 0; /* padding */
- move16();
- FOR( j = sect0; j < NSECT; j++ )
- {
- exp_sect0 = s_max( exp_sect[j * 2], exp_sect[j * 2 + 1] );
+ FOR( ; m < sublen1[j]; m++ )
+ {
+ temp = W_mac0_16_16( temp, pt6[-m], pt2[-m] ); // 2*qwsp
+ }
+ cnt = W_norm( temp );
+ *pt_cor3 = extract_h( W_extract_h( W_shl( temp, cnt ) ) ); // 2*qwsp+cnt-32-16
+ *pt_cor3_exp = sub( new_q, cnt );
+ move16();
+ move16();
- /* scaling of exp for track 1 */
- offset = add( offset, sec_length[j] );
- k = (Word16) ( pt_cor0 - pt_cor5 );
- move16();
- FOR( k = add( k, offset ); k > 0; k-- )
- {
- cnt = sub( exp_sect0, *pt_exp2 );
- tmp16 = s_min( 15, cnt );
- if ( cnt > 0 )
- {
- tmp16 = shr( *pt_cor5, tmp16 );
+ pt_cor1++;
+ pt_cor1_exp++;
+ pt_cor3++;
+ pt_cor3_exp++;
+ pt2--;
+ }
}
- if ( cnt > 0 )
+ ELSE
{
- *pt_cor5 = tmp16;
- move16();
- }
- *pt_exp2 = s_max( *pt_exp2, exp_sect0 );
- move16();
- pt_cor5++;
- pt_exp2++;
- }
+ FOR( ; k > 0; k-- )
+ {
+ temp = W_mult0_16_16( pt6[0], pt2[0] ); // 2*qwsp
+ FOR( m = 1; m < sublen1[j]; m++ )
+ {
+ temp = W_mac0_16_16( temp, pt6[-m], pt2[-m] ); // 2*qwsp
+ }
+ cnt = W_norm( temp );
+ *pt_cor3 = extract_h( W_extract_h( W_shl( temp, cnt ) ) ); // 2*qwsp+cnt-32-16
+ *pt_cor3_exp = sub( new_q, cnt );
+ move16();
+ move16();
- exp_sect0 = s_max( exp_sect1[j * 2], exp_sect1[j * 2 + 1] );
+ FOR( ; m < sublen[j]; m++ )
+ {
+ temp = W_mac0_16_16( temp, pt6[-m], pt2[-m] ); // 2*qwsp
+ }
+ cnt = W_norm( temp );
+ *pt_cor1 = extract_h( W_extract_h( W_shl( temp, cnt ) ) ); // 2*qwsp+cnt-32-16
+ *pt_cor1_exp = sub( new_q, cnt );
+ move16();
+ move16();
- /* scaling of exp for track 2 */
- offset1 = add( offset1, sec_length1[j] );
- k = (Word16) ( pt_cor0 - pt_cor6 + ( DELTA_COH - 1 ) );
- move16();
- k = add( k, len_x );
- FOR( k = add( k, offset1 ); k > 0; k-- )
- {
- cnt = sub( exp_sect0, *pt_exp4 );
- tmp16 = s_min( 15, cnt );
- if ( cnt > 0 )
- {
- tmp16 = shr( *pt_cor6, tmp16 );
- }
- if ( cnt > 0 )
- {
- *pt_cor6 = tmp16;
- move16();
+ pt_cor1++;
+ pt_cor1_exp++;
+ pt_cor3++;
+ pt_cor3_exp++;
+ pt2--;
+ }
}
- *pt_exp4 = s_max( *pt_exp4, exp_sect0 );
- move16();
- pt_cor6++;
- pt_exp4++;
}
- } /* FOR (j = sect0; ... */
+ } /* 3rd half-frame (look-ahead) */
- Copy( pt_cor0, cor_buf, len_x ); /* Save unscaled correlation vector */
+ /* Scale all values in each section to the same exponent for upcoming Find_max() */
+ Copy( pt_cor0, cor_buf, len_x ); /* Save unscaled correlation vector */
+ Copy( pt_cor0_exp, cor_buf_exp, len_x ); /* Save unscaled correlation vector */
Copy( pt_cor0 + ( DELTA_COH - 1 ) + len_x, cor_buf + len_x, len_x1 );
+ Copy( pt_cor0_exp + ( DELTA_COH - 1 ) + len_x, cor_buf_exp + len_x, len_x1 );
/*-----------------------------------------------------------------*
* Scale correlation function in the neighbourhood of
* the extrapolated pitch
*-----------------------------------------------------------------*/
pt_cor1 = pt_cor2 - ( DELTA_COH - 1 );
+ pt_cor1_exp = pt_cor2_exp - ( DELTA_COH - 1 );
pt_cor3 = pt_cor4 - ( DELTA_COH - 1 );
+ pt_cor3_exp = pt_cor4_exp - ( DELTA_COH - 1 );
pt2 = scale1;
FOR( k = 0; k < 2 * DELTA_COH - 1; k++ )
{
- /* all Q15 here */
- *pt_cor1 = add( *pt_cor1, mult( *pt_cor1, *pt2 ) );
+ *pt_cor1 = mult( *pt_cor1, *pt2 ); // *pt_cor1_exp+1
+ *pt_cor1_exp = add( *pt_cor1_exp, 1 ); // *pt_cor1_exp+1
+ move16();
+ move16();
+
+ *pt_cor3 = mult( *pt_cor3, *pt2++ ); // *pt_cor3_exp+1
+ *pt_cor3_exp = add( *pt_cor3_exp, 1 ); // *pt_cor1_exp+1
move16();
- *pt_cor3 = add( *pt_cor3, mult( *pt_cor3, *pt2++ ) );
move16();
pt_cor1++;
+ pt_cor1_exp++;
pt_cor3++;
+ pt_cor3_exp++;
}
/* Update for next half-frame & look-ahead */
pt_cor2 = pt_cor0 - pit_min + old_tmp1;
+ pt_cor2_exp = pt_cor0_exp - pit_min + old_tmp1;
+
pt_cor4 = pt_cor0 - pit_min1 + old_tmp1 + ( DELTA_COH - 1 ) + len_x;
+ pt_cor4_exp = pt_cor0_exp - pit_min1 + old_tmp1 + ( DELTA_COH - 1 ) + len_x;
/*-----------------------------------------------------------------*
* For each section, find maximum correlation and compute
@@ -1844,11 +1650,11 @@ void pitch_ol_ivas_fx(
*-----------------------------------------------------------------*/
pt_cor1 = pt_cor0;
- pt_exp1 = scaled_buf_exp + DELTA_COH - 1;
+ pt_cor1_exp = pt_cor0_exp;
offset = 0;
move16();
pt_cor3 = pt_cor0 + ( DELTA_COH - 1 ) + len_x;
- pt_exp3 = scaled_buf_exp + 2 * ( DELTA_COH - 1 ) + len_x;
+ pt_cor3_exp = pt_cor0_exp + ( DELTA_COH - 1 ) + len_x;
offset1 = 0;
move16();
@@ -1871,93 +1677,80 @@ void pitch_ol_ivas_fx(
}
/* 1st set of candidates */
- ind = add( maximum_fx( pt_cor1, sec_length[j], &ftmp ), offset );
+ ind = add( maximum_exp_fx( pt_cor1, pt_cor1_exp, sec_length[j] ), offset );
pitchX[i][j] = add( ind, pit_min );
move16();
pt2 = pt1 - pitchX[i][j] + /*-*/ offset_la; /* selected moving vector */
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 );
- enr2 = L_shl( enr2, enr2_exp );
- enr2_exp = sub( 31, add( sub( 28, add( enr0_exp[j], enr1_exp ) ), add( enr2_exp, 1 ) ) );
+ /* enr1 = dotp( pt2, pt2, len[j] ) + 0.01f; */
+ temp = 167772 /*0.01f in Q24*/;
+ move64();
+ FOR( m = 0; m < len[j]; m++ )
+ {
+ temp = W_mac0_16_16( temp, pt2[m], pt2[m] ); // 2*qwsp
+ }
+ temp = W_shl( temp, sub( Q24, shl( qwsp, 1 ) ) ); // Q24
+ enr1_exp = W_norm( temp );
+ enr1 = W_extract_h( W_shl( temp, enr1_exp ) ); // enr1_exp+24-32
+ enr1_exp = sub( 39, enr1_exp ); // 31-(enr1_exp+24-32)
- enr2 = Isqrt_lc( enr2, &enr2_exp ); /* 1/sqrt(energy) */ /*31-enr2_exp*/
- enr1_exp = norm_l( enr2 );
- enr1 = extract_h( L_shl( enr2, enr1_exp ) ); /*31-enr2_exp+enr1_exp-16*/
- enr1_exp = sub( enr2_exp, enr1_exp ); /*15-enr1_exp*/
+ enr1 = Mpy_32_32( enr0[j], enr1 );
+ enr1_exp = add( enr0_exp[j], enr1_exp );
- 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;
+ enr1 = ISqrt32( enr1, &enr1_exp ); /* 1/sqrt(energy) */ /*31-enr2_exp*/
+
+ Ltmp = Mpy_32_16_1( enr1, cor_buf[ind] );
+ corX[i][j] = extract_h( L_shl_o( Ltmp, add( enr1_exp, cor_buf_exp[ind] ), &Overflow ) ); // Q15
move16();
- Ltmp = L_mult0( pt_cor0[ind], enr1 );
- qScaledX = add( sub( 15, enr1_exp ), sub( 14, pt_exp1[ind] ) );
- scaledX[i][j] = round_fx( L_shl( Ltmp, sub( 16 + 12, qScaledX ) ) );
- qScaledX = 12;
+ Ltmp = Mpy_32_16_1( enr1, pt_cor0[ind] );
+ scaledX[i][j] = round_fx( L_shl( Ltmp, sub( add( enr1_exp, pt_cor0_exp[ind] ), 3 ) ) ); // Q12
move16();
pt_cor1 += sec_length[j];
- move16();
+ pt_cor1_exp += sec_length[j];
offset = add( offset, sec_length[j] );
/* 2nd set of candidates */
- ind1 = add( maximum_fx( pt_cor3, sec_length1[j], &ftmp ), offset1 );
+ ind1 = add( maximum_exp_fx( pt_cor3, pt_cor3_exp, sec_length1[j] ), offset1 );
pitchX[i][j + NSECT] = add( ind1, pit_min1 );
move16();
pt4 = pt1 - pitchX[i][j + NSECT] + /*-*/ offset_la1;
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 );
- enr2 = L_shl( enr2, enr2_exp );
+ /* enr1 = dotp(pt4, pt4, len1[j]) + 0.01f; */
+ temp = 167772 /*0.01f in Q24*/;
+ move64();
+ FOR( m = 0; m < len1[j]; m++ )
+ {
+ temp = W_mac0_16_16( temp, pt4[m], pt4[m] ); // 2*qwsp
+ }
+ temp = W_shl( temp, sub( Q24, shl( qwsp, 1 ) ) ); // Q24
+ enr1_exp = W_norm( temp );
+ enr1 = W_extract_h( W_shl( temp, enr1_exp ) ); // enr1_exp+24-32
+ enr1_exp = sub( 39, enr1_exp ); // 31-(enr1_exp+24-32)
- enr2_exp = sub( 31, add( sub( 28, add( enr0_1_exp[j], enr1_exp ) ), add( enr2_exp, 1 ) ) );
- enr2 = Isqrt_lc( enr2, &enr2_exp ); /* 1/sqrt(energy) */ /*31-enr2_exp*/
- enr1_exp = norm_l( enr2 );
- enr1 = extract_h( L_shl( enr2, enr1_exp ) ); /*31-enr2_exp+enr1_exp-16*/
- enr1_exp = sub( enr2_exp, enr1_exp ); /*15-enr1_exp*/
+ enr1 = Mpy_32_32( enr0_1[j], enr1 );
+ enr1_exp = add( enr0_1_exp[j], enr1_exp );
- Ltmp = L_mult0( cor_buf[ind1 + len_x], enr1 );
+ enr1 = ISqrt32( enr1, &enr1_exp ); /* 1/sqrt(energy) */ /*31-enr1_exp*/
- 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;
+ Ltmp = Mpy_32_16_1( enr1, cor_buf[ind1 + len_x] );
+ corX[i][j + NSECT] = extract_h( L_shl_o( Ltmp, add( enr1_exp, cor_buf_exp[ind1 + len_x] ), &Overflow ) ); // Q15
move16();
- Ltmp = L_mult0( pt_cor0[ind1 + ( DELTA_COH - 1 ) + len_x], enr1 );
- qScaledX = add( sub( 15, enr1_exp ), sub( 14, pt_exp3[ind1] ) );
- scaledX[i][j + NSECT] = round_fx( L_shl( Ltmp, sub( 16 + 12, qScaledX ) ) );
- /*scaledX[i][j+NSECT] = saturate(L_shr(Ltmp, qScaledX-12));*/
- qScaledX = 12;
+ Ltmp = Mpy_32_16_1( enr1, pt_cor0[ind1 + ( DELTA_COH - 1 ) + len_x] );
+ scaledX[i][j + NSECT] = round_fx( L_shl( Ltmp, sub( add( enr1_exp, pt_cor0_exp[ind1 + ( DELTA_COH - 1 ) + len_x] ), 3 ) ) ); // Q12
move16();
+ /*scaledX[i][j+NSECT] = saturate(L_shr(Ltmp, qScaledX-12));*/
pt_cor3 += sec_length1[j];
- move16();
+ pt_cor3_exp += sec_length1[j];
offset1 = add( offset1, sec_length1[j] );
} /* FOR j < NSECT */
@@ -2025,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 */
@@ -2043,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 */
@@ -2109,8 +1894,8 @@ void pitch_ol_ivas_fx(
/* all Q15 here */
/* cor_mean = 0.5f * (voicing[0] + voicing[1]) + corr_shift; */
- Ltmp = L_mult( voicing[0], 16384 );
- Ltmp = L_mac( Ltmp, voicing[1], 16384 );
+ Ltmp = L_mult( voicing[0], 16384 /*.5 Q15*/ );
+ Ltmp = L_mac( Ltmp, voicing[1], 16384 /*.5 Q15*/ );
cor_mean = round_fx( L_add( Ltmp, corr_shift ) );
/* pitch unstable in present frame or from previous frame or normalized correlation too low */
@@ -2132,10 +1917,11 @@ void pitch_ol_ivas_fx(
{
/* The threshold increase is directly dependent on normalized correlation */
/* *old_thres += (0.16f * cor_mean); */
- *old_thres = round_fx( L_mac( L_deposit_h( *old_thres ), 5243, cor_mean ) );
+ *old_thres = round_fx( L_mac0( L_deposit_h( *old_thres ), 5243 /* 0.16f in Q15 */, cor_mean ) ); // Q14
+ move16();
}
- *old_thres = s_min( *old_thres, THRES3 );
+ *old_thres = s_min( *old_thres, 11469 /* 0.7f in Q14 */ ); // Q14
move16();
IF( GT_16( voicing[1], voicing[0] ) )
@@ -2194,13 +1980,13 @@ void pitch_ol_ivas_fx(
/* *delta_pit /= 3; */
if ( k < 0 )
{
- *delta_pit = mult( *delta_pit, -32768 );
+ *delta_pit = mult( *delta_pit, -32768 /*-1 Q15*/ );
move16();
}
- tmp16 = mult( *delta_pit, 10923 );
+ tmp16 = mult( *delta_pit, 10923 /*1/3 Q15*/ );
if ( k < 0 )
{
- tmp16 = mult( tmp16, -32768 );
+ tmp16 = mult( tmp16, -32768 /*-1 Q15*/ );
}
*delta_pit = tmp16;
move16();
@@ -2254,7 +2040,7 @@ static void find_mult_fx(
L_tmp = L_shl( L_mult( *corr, *fac ), 3 );
/* if ( *old_corr < 0.6f || (float)pitch0 > (float)*old_pitch * 0.4f ) */
- IF( s_max( sub( 19660, *old_corr ), sub( pitch0, mult( *old_pitch, 13107 ) ) ) > 0 )
+ IF( s_max( sub( 19660 /*.6 Q15*/, *old_corr ), sub( pitch0, mult( *old_pitch, 13107 /*.4 Q15*/ ) ) ) > 0 )
{
/* reinforce the normalized correlation */
/* operands are Q12, result is Q12 */
@@ -2325,7 +2111,7 @@ static void pitch_neighbour_fx(
{
/* corr[i][k] *= ( -thres1[j]/DELTA1 * 0.625f * delta + 0.625f * thres1[j] +1.0f ); */
fac = mult( negate( thres1[j] ), 20479 / DELTA_COH );
- fac = add( i_mult2( fac, delta ), mult( 20479, thres1[j] ) );
+ fac = add( i_mult2( fac, delta ), mult( 20479 /*.625 Q15*/, thres1[j] ) );
}
corr[i][k] = add_sat( corr[i][k], mult( fac, corr[i][k] ) );
move16();
@@ -2448,7 +2234,7 @@ static void LP_Decim2_Copy(
*p_x++ = x[i];
move16();
}
- if ( l & 1 ) /* Fix for valgrind error in case l is odd. Anyway this function will be removed. */
+ if ( s_and( l, 1 ) ) /* Fix for valgrind error in case l is odd. Anyway this function will be removed. */
{
*p_x = *( p_x - 1 );
move16();
@@ -2472,6 +2258,7 @@ static void LP_Decim2_Copy(
p_x += 2;
y[j++] = round_fx( L_tmp );
+ move16();
}
}
/*---------------------------------------------------------------------*
@@ -2534,7 +2321,7 @@ static Word32 Dot_product12_OL( /* o : Q31: normalized result
move16(); /* exponent = 0..30 */
*sum1 = extract_h( L_shr( L_sum2, 1 ) );
-
+ move16();
return L_sum;
}
@@ -2598,7 +2385,7 @@ static Word32 Dot_product12_OL_back( /* o : Q31: normalized r
move16(); /* exponent = 0..30 */
*sum1 = extract_h( L_shr( L_sum2, 1 ) );
-
+ move16();
return L_sum;
}
diff --git a/lib_enc/plc_enc_ext_fx.c b/lib_enc/plc_enc_ext_fx.c
index 56598be2f5ab0342173145bfc314929340d29f4e..97e3fd4bc44ca91ab63acb69b5f914d01f747e93 100644
--- a/lib_enc/plc_enc_ext_fx.c
+++ b/lib_enc/plc_enc_ext_fx.c
@@ -82,6 +82,9 @@ void init_PLC_enc_fx(
hPlcExt->lsf_con[itr] = add( lsf_init_fx[itr], shr( lsf_init_fx[itr], 2 ) );
hPlcExt->last_lsf_ref[itr] = add( lsf_init_fx[itr], shr( lsf_init_fx[itr], 2 ) );
hPlcExt->last_lsf_con[itr] = add( lsf_init_fx[itr], shr( lsf_init_fx[itr], 2 ) );
+ move16();
+ move16();
+ move16();
}
}
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 2001f296664bf8854fbb33f99f1f72f15d9690fd..bc08aae244a8686c9681c6b2e2ed81b54fd4b2de 100644
--- a/lib_enc/prot_fx_enc.h
+++ b/lib_enc/prot_fx_enc.h
@@ -46,21 +46,21 @@
*----------------------------------------------------------------------------------*/
ivas_error acelp_core_enc_fx(
Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word16 inp_fx[], /* i : i signal of the current frame */
- const Word32 ener_fx, /* i : residual energy from Levinson-Durbin*/
- Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes*/
- Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes*/
- const Word16 epsP_h_fx[M + 1], /* i : LP prediction errors */
- const Word16 epsP_l_fx[M + 1], /* i : LP prediction errors */
- Word16 lsp_new_fx[M], /* i : LSPs at the end of the frame */
- Word16 lsp_mid_fx[M], /* i : LSPs in the middle of the frame */
- Word16 vad_hover_flag_fx, /* i : VAD hangover flag */
- const Word16 attack_flag, /* i : attack flag (GSC or TC) */
- Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation */
- Word16 *voice_factors_fx, /* o : voicing factors */
- Word16 old_syn_12k8_16k_fx[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE */
- Word16 pitch_buf_fx[NB_SUBFR16k], /* o : floating pitch for each subframe */
- Word16 *unbits_fx, /* o : number of unused bits */
+ const Word16 inp_fx[], /* i : input signal of the current frame Q_new*/
+ const Word32 ener_fx, /* i : residual energy from Levinson-Durbin Q6*/
+ Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12*/
+ Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes Q12*/
+ const Word16 epsP_h_fx[M + 1], /* i : LP prediction errors Qx*/
+ const Word16 epsP_l_fx[M + 1], /* i : LP prediction errors Qx*/
+ Word16 lsp_new_fx[M], /* i : LSPs at the end of the frame Q15*/
+ Word16 lsp_mid_fx[M], /* i : LSPs in the middle of the frame Q15*/
+ Word16 vad_hover_flag_fx, /* i : VAD hangover flag Q0*/
+ const Word16 attack_flag, /* i : attack flag (GSC or TC) Q0*/
+ Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation st->prev_Q_bwe_exc*/
+ Word16 *voice_factors_fx, /* o : voicing factors Q15*/
+ Word16 old_syn_12k8_16k_fx[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE q_old_syn*/
+ Word16 pitch_buf_fx[NB_SUBFR16k], /* o : floating pitch for each subframe Q6*/
+ Word16 *unbits_fx, /* o : number of unused bits Q0*/
const Word16 Q_new,
const Word16 shift
#ifdef ADD_LRTD
@@ -88,20 +88,20 @@ void analy_lp_ivas_fx(
Word16 *Q_r /*stores q for ener*/ );
void analy_lp_fx(
- const Word16 speech[], /* i : pointer to the speech frame */
- const Word16 L_frame, /* i : length of the frame */
- const Word16 L_look, /* i : look-ahead */
- Word32 *ener, /* o : residual energy from Levinson-Durbin */
- Word16 A[], /* o : A(z) filter coefficients */
- Word16 epsP_h[], /* o : LP analysis residual energies for each iteration */
- Word16 epsP_l[], /* o : LP analysis residual energies for each iteration */
- Word16 lsp_new[], /* o : current frame LSPs */
- Word16 lsp_mid[], /* o : current mid-frame LSPs */
- Word16 lsp_old[], /* i/o: previous frame unquantized LSPs */
- const Word16 Top[2], /* i : open loop pitch lag */
- const Word16 Tnc[2], /* i : open loop pitch gain */
- const Word32 Core_sr, /* i : Internal core sampling rate */
- const Word16 sec_chan_low_rate, /* i : flag to signal second channel */
+ const Word16 speech[], /* i : pointer to the speech frame Q_new*/
+ const Word16 L_frame, /* i : length of the frame Q0*/
+ const Word16 L_look, /* i : look-ahead Q0*/
+ Word32 *ener, /* o : residual energy from Levinson-Durbin Q_r*/
+ Word16 A[], /* o : A(z) filter coefficients Q14*/
+ Word16 epsP_h[], /* o : LP analysis residual energies for each iteration Q_r*/
+ Word16 epsP_l[], /* o : LP analysis residual energies for each iteration Q_r*/
+ Word16 lsp_new[], /* o : current frame LSPs Q15*/
+ Word16 lsp_mid[], /* o : current mid-frame LSPs Q15*/
+ Word16 lsp_old[], /* i/o: previous frame unquantized LSPs Q15*/
+ const Word16 Top[2], /* i : open loop pitch lag Q0*/
+ const Word16 Tnc[2], /* i : open loop pitch gain Q15*/
+ const Word32 Core_sr, /* i : Internal core sampling rate Q0*/
+ const Word16 sec_chan_low_rate, /* i : flag to signal second channel Q0*/
Word16 Q_new,
Word16 *Q_r );
@@ -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*/
@@ -226,70 +229,75 @@ Word16 ffr_getSfWord32(
const Word16 len /*!< Length of i vector */
);
void find_tilt_ivas_fx(
- const Word32 fr_bands[], /* i : energy in frequency bands Q_new*/
- const Word32 bckr[], /* i : per band background noise energy estimate Q_new*/
- Word32 ee[2], /* o : lf/hf E ration for present frame Q6*/
+ const Word32 fr_bands[], /* i : energy in frequency bands q_fr_bands*/
+ const Word16 q_fr_bands, /* i : Q of fr_bands Q0*/
+ const Word32 bckr[], /* i : per band background noise energy estimate q_bckr*/
+ const Word16 q_bckr, /* i : Q of bckr Q0*/
+ Word32 ee[2], /* o : lf/hf E ration for present frame Q_bckr*/
const Word16 pitch[3], /* i : open loop pitch values for 3 half-frames Q0*/
const Word16 voicing[3], /* i : normalized correlation for 3 half-frames Q15*/
- const Word32 *lf_E, /* i : per bin energy for low frequencies Q_new - 2*/
+ const Word32 *lf_E, /* i : per bin energy for low frequencies q_lf_E*/
+ const Word16 q_lf_E, /* i : Q of lf_E */
const Word16 corr_shift, /* i : normalized correlation correction Q15*/
const Word16 bwidth, /* i : i signal bandwidth */
const Word16 max_band, /* i : maximum critical band */
Word32 hp_E[], /* o : energy in HF Q_new*/
const Word16 codec_mode, /* i : MODE1 or MODE2 */
- const Word16 Q_new, /* i : scaling factor */
Word32 *bckr_tilt_lt,
Word16 Opt_vbr_mode );
void find_tilt_fx(
- const Word32 fr_bands[], /* i : energy in frequency bands Q_new + Q_SCALE*/
- const Word32 bckr[], /* i : per band background noise energy estimate Q_new + Q_SCALE*/
- Word32 ee[2], /* o : lf/hf E ration for present frame Q6*/
- const Word16 pitch[3], /* i : open loop pitch values for 3 half-frames Q0*/
- const Word16 voicing[3], /* i : normalized correlation for 3 half-frames Q15*/
+ const Word32 fr_bands[], /* i : energy in frequency bands Q_new + Q_SCALE*/
+ const Word32 bckr[], /* i : per band background noise energy estimate Q_new + Q_SCALE*/
+ Word32 ee[2], /* o : lf/hf E ration for present frame Q6*/
+ const Word16 pitch[3], /* i : open loop pitch values for 3 half-frames Q0*/
+ const Word16 voicing[3], /* i : normalized correlation for 3 half-frames Q15*/
const Word32 *lf_E, /* i : per bin energy for low frequencies Q_new + Q_SCALE - 2*/
- const Word16 corr_shift, /* i : normalized correlation correction Q15*/
- const Word16 bwidth, /* i : i signal bandwidth */
- const Word16 max_band, /* i : maximum critical band */
+ const Word16 corr_shift, /* i : normalized correlation correction Q15*/
+ const Word16 bwidth, /* i : input signal bandwidth Q0*/
+ const Word16 max_band, /* i : maximum critical band Q0*/
Word32 hp_E[], /* o : energy in HF Q_new + Q_SCALE*/
- const Word16 codec_mode, /* i : MODE1 or MODE2 */
- const Word16 Q_new, /* i : scaling factor */
- Word32 *bckr_tilt_lt,
- Word16 Opt_vbr_mode );
+ const Word16 codec_mode, /* i : MODE1 or MODE2 Q0*/
+ const Word16 Q_new, /* i : scaling factor */
+ Word32 *bckr_tilt_lt /* i/o: lf/hf E ratio of background noise Q16*/
+ ,
+ Word16 Opt_vbr_mode /* Q0 */
+);
Word16 find_uv_ivas_fx( /* o : coding type */
Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word16 *T_op_fr, /* i : pointer to adjusted fractional pitch (4 val.) Q6 */
- const Word16 *voicing_fr, /* i : refined correlation for each subframes Q15 */
- const Word16 *speech, /* i : pointer to speech signal for E computation Q_new */
- const Word32 *ee, /* i : lf/hf Energy ratio for present frame Q6 */
- Word32 *dE1X, /* o : sudden energy increase for S/M classifier */
- const Word16 corr_shift, /* i : normalized correlation correction in noise Q15 */
- const Word16 relE, /* i : relative frame energy Q8 */
- const Word16 Etot, /* i : total energy Q8 */
- const Word32 hp_E[], /* i : energy in HF Q_new */
- Word16 *flag_spitch, /* i/o: flag to indicate very short stable pitch and high correlation */
- const Word16 last_core_orig, /* i : original last core */
+ const Word16 *T_op_fr, /* i : pointer to adjusted fractional pitch (4 val.) Q6*/
+ const Word16 *voicing_fr, /* i : refined correlation for each subframes Q15*/
+ const Word16 *speech, /* i : pointer to speech signal for E computation Q_new*/
+ const Word32 *ee, /* i : lf/hf Energy ratio for present frame Q6*/
+ Word32 *dE1X, /* o : sudden energy increase for S/M classifier Q13*/
+ const Word16 corr_shift, /* i : normalized correlation correction in noise Q15*/
+ const Word16 relE, /* i : relative frame energy Q8*/
+ const Word16 Etot, /* i : total energy Q8*/
+ const Word32 hp_E[], /* i : energy in HF q_hp_E*/
+ Word16 *flag_spitch, /* i/o: flag to indicate very short stable pitch and high correlation Q0*/
+ const Word16 last_core_orig, /* i : original last core Q0*/
STEREO_CLASSIF_HANDLE hStereoClassif, /* i/o: stereo classifier structure */
const Word16 Q_new,
const Word16 q_hp_E );
+
Word16 find_uv_fx( /* o : coding type */
- Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word16 *T_op_fr, /* i : pointer to adjusted fractional pitch (4 val.) Q6*/
- const Word16 *voicing_fr, /* i : refined correlation for each subframes Q15*/
- const Word16 *speech, /* i : pointer to speech signal for E computation Q_new*/
- const Word32 *ee, /* i : lf/hf Energy ratio for present frame Q6*/
+ Encoder_State *st_fx, /* i/o: encoder state structure */
+ const Word16 *T_op_fr, /* i : pointer to adjusted fractional pitch (4 val.) Q6*/
+ const Word16 *voicing_fr, /* i : refined correlation for each subframes Q15*/
+ const Word16 *speech, /* i : pointer to speech signal for E computation Q_new*/
+ const Word32 *ee, /* i : lf/hf Energy ratio for present frame Q6*/
#ifdef IVAS_CODE
Word32 *dE1X, /* o : sudden energy increase for S/M classifier */
#endif
- const Word16 corr_shift, /* i : normalized correlation correction in noise Q15*/
- const Word16 relE, /* i : relative frame energy Q8*/
- const Word16 Etot, /* i : total energy Q8*/
- const Word32 hp_E[], /* i : energy in HF Q_new + Q_SCALE*/
+ const Word16 corr_shift, /* i : normalized correlation correction in noise Q15*/
+ const Word16 relE, /* i : relative frame energy Q8*/
+ const Word16 Etot, /* i : total energy Q8*/
+ const Word32 hp_E[], /* i : energy in HF Q_new + Q_SCALE*/
const Word16 Q_new,
- Word16 *flag_spitch, /* i/o: flag to indicate very short stable pitch and high correlation */
+ Word16 *flag_spitch, /* i/o: flag to indicate very short stable pitch and high correlation Q0*/
const Word16 shift,
- const Word16 last_core_orig /* i : original last core */
+ const Word16 last_core_orig /* i : original last core Q0*/
#ifdef IVAS_CODE
,
STEREO_CLASSIF_HANDLE hStereoClassif /* i/o: stereo classifier structure */
@@ -308,10 +316,10 @@ void fine_gain_quant_fx(
void hq_core_enc_fx(
Encoder_State *st_fx,
const Word16 *audio, /* i : i audio signal Q0 */
- const Word16 input_frame_orig, /* i : frame length */
- const Word16 hq_core_type, /* i : HQ core type */
- const Word16 Voicing_flag, /* i : Voicing flag for FER method selection */
- const Word16 vad_hover_flag /* i : VAD hangover flag */
+ const Word16 input_frame_orig, /* i : frame length Q0*/
+ const Word16 hq_core_type, /* i : HQ core type Q0*/
+ const Word16 Voicing_flag, /* i : Voicing flag for FER method selection Q0*/
+ const Word16 vad_hover_flag /* i : VAD hangover flag Q0*/
);
void long_enr_fx(
@@ -353,6 +361,20 @@ void noise_est_down_fx(
const Word32 e_min /* i : minimum energy scaled Q_new + QSCALE */
);
+void noise_est_down_ivas_fx(
+ const Word32 fr_bands[], /* i : per band i energy (contains 2 vectors) */
+ const Word16 q_fr_bands, /* i : Q of fr_bands */
+ Word32 bckr[], /* i/o: per band background noise energy estimate */
+ Word32 tmpN[], /* o : temporary noise update */
+ Word32 enr[], /* o : averaged energy over both subframes */
+ const Word16 min_band, /* i : minimum critical band */
+ const Word16 max_band, /* i : maximum critical band */
+ Word16 *totalNoise, /* o : noise estimate over all critical bands */
+ Word16 Etot, /* i : Energy of current frame */
+ Word16 *Etot_last, /* i/o: Energy of last frame Q8 */
+ Word16 *Etot_v_h2 /* i/o: Energy variations of noise frames Q8 */
+);
+
void noise_est_fx(
Encoder_State *st_fx, /* i/o: state structure */
const Word16 old_pitch1, /* i : previous frame OL pitch[1] */
@@ -390,27 +412,27 @@ void noise_est_ivas_fx(
Encoder_State *st_fx, /* i/o: state structure */
const Word16 old_pitch1, /* i : previous frame OL pitch[1] */
const Word32 tmpN[], /* i : temporary noise update Q_new + QSCALE */
- const Word16 epsP_h[], /* i : msb prediction error energies Q_r-1 */
- const Word16 epsP_l[], /* i : msb prediction error energies Q_r-1 */
+ const Word32 epsP[], /* i : msb prediction error energies Qx */
const Word16 Etot, /* i : total channel E (see find_enr_fx.c) Q8 */
const Word16 relE, /* i : (VA_CHECK addition) relative frame energy Q8? */
const Word16 corr_shift, /* i : normalized correlation correction Q15 */
- const Word32 enr[], /* i : averaged energy over both subframes Q_new + Q_SCALE */
- Word32 fr_bands[], /* i : spectrum per critical bands of the current frame Q_new + Q_SCALE */
+ const Word32 enr[], /* i : averaged energy over both subframes q_enr */
+ const Word16 q_enr, /* i : q_enr of enr Q0 */
+ Word32 fr_bands[], /* i : spectrum per critical bands of the current frame q_fr_bands */
+ Word16 q_fr_bands, /* i : Q of q_fr_bands */
Word16 *cor_map_sum, /* o : Q8 */
Word16 *ncharX, /* o : Q11 */
Word16 *sp_div, /* o : Q_sp_div */
Word16 *Q_sp_div, /* o : Q factor for sp_div */
Word16 *non_staX, /* o : non-stationarity for sp/mus classifier */
Word16 *loc_harm, /* o : multi-harmonicity flag for UV classifier */
- const Word32 *lf_E, /* i : per bin energy for low frequencies Q_new + Q_SCALE -2 */
+ const Word32 *lf_E, /* i : per bin energy for low frequencies q_lf_E */
+ const Word16 q_lf_E, /* i : Q of lf_E Q0 */
Word16 *st_harm_cor_cnt, /* i/o : 1st harm correlation timer Q0 */
const Word16 Etot_l_lp, /* i : Smoothed low energy Q8 */
const Word16 Etot_v_h2, /* i : Energy variations Q8 */
Word16 *bg_cnt, /* i : Background burst length timer Q0 */
Word16 EspecdB[], /* i/o: log E spectrum (with f=0) of the current frame Q7 for multi harm */
- Word16 Q_new, /* i : SCaling of current frame */
- const Word32 Le_min_scaled, /*i : Minimum energy value in Q_new + Q_SCALE */
Word16 *sp_floor, /* o : noise floor estimate Q7 */
Word16 S_map[], /* o : short-term correlation map Q7 */
STEREO_CLASSIF_HANDLE hStereoClassif, /* i/o: stereo classifier structure */
@@ -464,7 +486,8 @@ void pitch_ol_ivas_fx(
const Word16 relE, /* i : relative frame energy Q8 */
const Word16 last_class, /* i : frame classification of last frame */
const Word16 bwidth, /* i : bandwidth */
- const Word16 Opt_SC_VBR /* i : SC-VBR flag */
+ const Word16 Opt_SC_VBR, /* i : SC-VBR flag */
+ Word16 qwsp /* i : Q factor for wsp Q0 */
);
void pitch_ol_fx(
@@ -492,17 +515,17 @@ void pitch_ol_init_fx(
);
void Preemph_scaled(
- Word16 new_speech[], /* i : Speech to scale already on 14 bits*/
- Word16 *Q_new, /* o : Scaling factor */
- Word16 *mem_preemph, /* i/o: Preemph memory */
- Word16 *Q_max, /* i/o: Q_new limitation */
- const Word16 Preemph_factor, /* i : Preemphasis factor Q15 */
- const Word16 bits, /* i : Bit to remove from the output to (15-bits)*/
- const Word16 bit1, /* i : Limit the output scaling to ((15-bits)-bit1) bits */
- const Word16 L_Q_mem, /* i : Number of old scaling to take into account */
- const Word16 Lframe, /* i : Frame length */
- const Word16 last_coder_type, /* i : coder_type */
- const Word16 Search_scaling /* i : enable the search of a proper scaling factor*/
+ Word16 new_speech[], /* i : Speech to scale already on 14 bits Q_new*/
+ Word16 *Q_new, /* o : Scaling factor */
+ Word16 *mem_preemph, /* i/o: Preemph memory Q(-1)*/
+ Word16 *Q_max, /* i/o: Q_new limitation */
+ const Word16 Preemph_factor, /* i : Preemphasis factor Q15*/
+ const Word16 bits, /* i : Bit to remove from the output to (15-bits) */
+ const Word16 bit1, /* i : Limit the output scaling to ((15-bits)-bit1) bits */
+ const Word16 L_Q_mem, /* i : Number of old scaling to take into account Q0*/
+ const Word16 Lframe, /* i : Frame length Q0*/
+ const Word16 last_coder_type, /* i : coder_type Q0*/
+ const Word16 Search_scaling /* i : enable the search of a proper scaling factor Q0*/
);
void Scale_mem_enc(
@@ -518,17 +541,17 @@ void Scale_mem_enc(
Word16 *old_input_lp );
Word32 Scale_mem_pre_proc( /* o : Min energy scaled */
- Word16 ini_frame_fx, /* i : Frame number */
+ Word16 ini_frame_fx, /* i : Frame number Q0*/
Word16 Q_exp, /* i : Diff scaling factor */
Word16 *Q_new, /* i/o: Absolute scaling factor */
Word16 *old_speech, /* i/o: Speech memory */
- Word16 *mem_wsp, /* i/o: wsp vector memory */
- Word32 *enrO, /* i/o: Enr mem */
- Word32 *bckr, /* i/o: Back ground_fx ener mem */
- Word32 *ave_enr, /* i/o: Ave_enr mem */
- Word32 *ave_enr2, /* i/o: Ave_enr2 mem */
- Word32 *st_fr_bands1, /* i/o: spectrum per critical bands of the previous frame */
- Word32 *st_fr_bands2, /* i/o: spectrum per critical bands 2 frames ago */
+ Word16 *mem_wsp, /* i/o: wsp vector memory st->mem_wsp_q*/
+ Word32 *enrO, /* i/o: Enr mem q_enrO*/
+ Word32 *bckr, /* i/o: Back ground_fx ener mem q_bckr*/
+ Word32 *ave_enr, /* i/o: Ave_enr mem Q_new + QSCALE*/
+ Word32 *ave_enr2, /* i/o: Ave_enr2 mem Q_new + QSCALE*/
+ Word32 *st_fr_bands1, /* i/o: spectrum per critical bands of the previous frame Q_new + QSCALE*/
+ Word32 *st_fr_bands2, /* i/o: spectrum per critical bands 2 frames ago Q_new + QSCALE*/
Word32 *st_Bin_E_old );
void Scale_wsp(
@@ -540,7 +563,7 @@ void Scale_wsp(
Word16 *old_wsp, /* i/o: Old weighted speech buffer */
Word16 *mem_decim2, /* i/o: Decimation buffer */
Word16 *old_wsp12k8, /* i/o: wsp memory @ 12.8 kHz used in pitol2 */
- const Word16 Len_p_look /* i : L_frame + look ahead */
+ const Word16 Len_p_look /* i : L_frame + look ahead Q0*/
);
Word16 signal_clas_fx( /* o : classification for current frames */
@@ -783,28 +806,28 @@ 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_new+QSCALE*/
+ const Word32 fr_bands[], /* i : per band i energy (contains 2 vectors) q_fr_bands*/
+ 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 */
Word16 *NB_speech_HO, /* o : SC-VBR NB speech HO flag */
Word16 *snr_sum_he, /* o : Output snr_sum as weighted spectral measure*/
Word16 *localVAD_HE_SAD,
Word16 *flag_noisy_speech_snr, /* o : */
- 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, /* i : long term active speech energy average */
Word16 lp_noise /* i : long term noise energy */
);
-Word32 construct_snr_thresh_fx( Word16 sp_center[], /*(i) spectral center*/
- Word32 snr_flux, /*(i) snr flux*/
- Word32 lt_snr, /*(i) long time time domain snr*/
- Word32 l_snr, /*(i) long time frequency domain snr*/
- Word32 continuous_speech_num, /*(i) amount of continuous speech frames*/
- Word16 continuous_noise_num, /*(i) amount of continuous noise frames*/
- Word32 fg_energy_est_start, /*(i) whether if estimated energy*/
- Word16 bw_index /*(i) band width index*/
+Word32 construct_snr_thresh_fx( Word16 sp_center[], /*(i) spectral center Q10*/
+ Word32 snr_flux, /*(i) snr flux Q25*/
+ Word32 lt_snr, /*(i) long time time domain snr Q25*/
+ Word32 l_snr, /*(i) long time frequency domain snr Q25*/
+ Word32 continuous_speech_num, /*(i) amount of continuous speech frames Q0*/
+ Word16 continuous_noise_num, /*(i) amount of continuous noise frames Q0*/
+ Word32 fg_energy_est_start, /*(i) whether if estimated energy Q0*/
+ Word16 bw_index /*(i) band width index Q0*/
);
void sc_vbr_enc_init_fx(
@@ -825,14 +848,12 @@ 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[], const PulseConfig *config, Word16 num_tracks, Word16 prm[] );
-void fcb_pulse_track_joint_fx( UWord16 *idxs, Word16 wordcnt, UWord32 *index_n, Word16 *pulse_num, Word16 track_num );
+Word16 E_ACELP_indexing_fx( const Word16 code[] /*Q9*/, const PulseConfig *config, Word16 num_tracks /*Q0*/, Word16 prm[] /*Q(shift_bits)*/ );
+void fcb_pulse_track_joint_fx( UWord16 *idxs /*Q0*/, Word16 wordcnt /*Q0*/, UWord32 *index_n /*Q0*/, Word16 *pulse_num /*Q0*/, Word16 track_num /*Q0*/ );
Word16 gain_quant_fx( /* o: quantization index */
Word32 *gain, /* i/o: quantized gain */
@@ -933,20 +954,28 @@ void norm_corr_fx(
Word16 ncorr[], /* o : normalized correlation Q15 */
const Word16 L_subfr /* i : subframe size */
);
-
+void norm_corr_ivas_fx(
+ const Word16 exc[], /* i : excitation buffer Q_new*/
+ const Word16 xn[], /* i : target signal Q_new-1+shift*/
+ const Word16 h[], /* i : weighted synthesis filter impulse response Q(14+shift)*/
+ const Word16 t_min, /* i : minimum value of searched range */
+ const Word16 t_max, /* i : maximum value of searched range */
+ Word16 ncorr[], /* o : normalized correlation Q15 */
+ const Word16 L_subfr /* i : subframe size */
+);
Word16 peak_avrg_ratio_fx(
- const Word32 total_brate,
- const Word32 *input_hi_fx, /* i : i signal */
- const Word16 length, /* i : number of coefficients */
- Word16 *mode_count, /* i/o: HQ_HARMONIC mode count */
- Word16 *mode_count1, /* i/o: HQ_NORMAL mode count */
+ const Word32 total_brate, /* Q0 */
+ const Word32 *input_hi_fx, /* i : i signal Q_coeff*/
+ const Word16 length, /* i : number of coefficients Q0*/
+ Word16 *mode_count, /* i/o: HQ_HARMONIC mode count Q0*/
+ Word16 *mode_count1, /* i/o: HQ_NORMAL mode count Q0*/
Word16 Q_coeff );
Word16 peak_avrg_ratio_ivas_fx(
- const Word32 total_brate,
- const Word32 *input_hi_fx, /* i : i signal */
- const Word16 length, /* i : number of coefficients */
- Word16 *mode_count, /* i/o: HQ_HARMONIC mode count */
- Word16 *mode_count1, /* i/o: HQ_NORMAL mode count */
+ const Word32 total_brate, /* Q0 */
+ const Word32 *input_hi_fx, /* i : i signal Q_coeff*/
+ const Word16 length, /* i : number of coefficients Q0*/
+ Word16 *mode_count, /* i/o: HQ_HARMONIC mode count Q0*/
+ Word16 *mode_count1, /* i/o: HQ_NORMAL mode count Q0*/
Word16 Q_coeff );
void hvq_classifier_ivas_fx(
const Word32 *input, /* i : input signal Q12 */
@@ -995,6 +1024,20 @@ Word16 pitch_fr4_fx( /* o : chosen integer pitch lag
const Word16 L_frame, /* i : length of the frame */
const Word16 L_subfr /* i : size of subframe */
);
+Word16 pitch_fr4_ivas_fx( /* o : chosen integer pitch lag */
+ const Word16 exc[], /* i : excitation buffer Q_new*/
+ const Word16 xn[], /* i : target signal Q_new-1+shift*/
+ const Word16 h[], /* i : weighted synthesis filter impulse response Q(14+shift)*/
+ const Word16 t0_min, /* i : minimum value in the searched range. Q0*/
+ const Word16 t0_max, /* i : maximum value in the searched range. Q0*/
+ Word16 *pit_frac, /* o : chosen fraction (0, 1, 2 or 3) */
+ const Word16 i_subfr, /* i : flag to first subframe */
+ const Word16 limit_flag, /* i : flag for limits (0=restrained, 1=extended) */
+ const Word16 t0_fr2, /* i : minimum value for resolution 1/2 */
+ const Word16 t0_fr1, /* i : minimum value for resolution 1 */
+ const Word16 L_frame, /* i : length of the frame */
+ const Word16 L_subfr /* i : size of subframe */
+);
void pit_Q_enc_fx(
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
@@ -1237,6 +1280,18 @@ void AnalyzePowerSpectrum_fx(
Word32 powerSpec[], /* o : Power spectrum. Can point to signal */
Word16 *powerSpec_e );
+void AnalyzePowerSpectrum_ivas_fx(
+ Encoder_State *st, /* i/o: encoder states */
+ Word16 L_frame, /* i : frame length */
+ Word16 L_frameTCX, /* i : full band frame length */
+ Word16 left_overlap, /* i : left overlap length */
+ Word16 right_overlap, /* i : right overlap length */
+ Word32 const mdctSpectrum[], /* i : MDCT spectrum */
+ Word16 mdctSpectrum_e,
+ Word16 const signal[], /* i : windowed signal corresponding to mdctSpectrum */
+ Word32 powerSpec[], /* o : Power spectrum. Can point to signal */
+ Word16 powerSpec_e[] );
+
void AdaptLowFreqEmph_fx( Word32 x[],
Word16 x_e,
Word16 xq[],
@@ -1253,6 +1308,13 @@ Word16 SQ_gain_fx( /* o : SQ gain */
Word16 lg, /* i : vector size (2048 max) */
Word16 *gain_e ); /* o : SQ gain exponent */
+Word16 SQ_gain_ivas_fx( /* o : SQ gain */
+ Word32 x[], /* i : vector to quantize */
+ Word16 x_e, /* i : exponent */
+ Word16 nbitsSQ, /* i : number of bits targeted */
+ Word16 lg, /* i : vector size (2048 max) */
+ Word16 *gain_e ); /* o : SQ gain exponent */
+
Word16 SQ_gain_estimate_fx( /* o : SQ gain */
Word32 x[], /* i : vector to quantize */
Word16 x_e, /* i : exponent */
@@ -1445,34 +1507,34 @@ void ComputeSpectrumNoiseMeasure_fx( const Word32 *powerSpec,
void lpc_quantization_fx(
Encoder_State *st,
- const Word16 lsp[],
- const Word16 lspmid[],
- Word16 lsp_q[],
- Word16 lsf_q[], /* 14Q1*1.28 */
- Word16 lspmid_q[],
- Word16 lspq_ind[],
- Word16 clip_var[],
- const Word16 coder_type,
- const Word16 acelp_midLpc,
- Word16 param_lpc[],
- Word16 nbits_lpc[],
- Word16 *bits_param_lpc,
- Word16 *no_param_lpc,
+ const Word16 lsp[], /* Q15 */
+ const Word16 lspmid[], /* Q15 */
+ Word16 lsp_q[], /* Q15 */
+ Word16 lsf_q[], /* 14Q1*1.28 */
+ Word16 lspmid_q[], /* Q15 */
+ Word16 lspq_ind[], /* Q15 */
+ Word16 clip_var[], /* [2.56x,Q14,Q8,Q0,Q14,Q14] */
+ const Word16 coder_type, /* Q0 */
+ const Word16 acelp_midLpc, /* Q0 */
+ Word16 param_lpc[], /* Q0 */
+ Word16 nbits_lpc[], /* Q0 */
+ Word16 *bits_param_lpc, /* Q0 */
+ Word16 *no_param_lpc, /* Q0 */
const Word16 Q_ener );
void lpc_quantization_ivas_fx(
Encoder_State *st,
- const Word16 lsp[], /* Q15 */
- const Word16 lspmid[], /* Q15 */
- Word16 lsp_q[], /* Q15 */
- Word16 lsf_q[], /* 14Q1*1.28 */
- Word16 lspmid_q[], /* Q15 */
- const Word16 coder_type,
- const Word16 acelp_midLpc,
- Word16 param_lpc[],
- Word16 nbits_lpc[],
- Word16 *bits_param_lpc,
- Word16 *no_param_lpc,
+ const Word16 lsp[], /* Q15 */
+ const Word16 lspmid[], /* Q15 */
+ Word16 lsp_q[], /* Q15 */
+ Word16 lsf_q[], /* 14Q1*1.28 */
+ Word16 lspmid_q[], /* Q15 */
+ const Word16 coder_type, /* Q0 */
+ const Word16 acelp_midLpc, /* Q0 */
+ Word16 param_lpc[], /* Q0 */
+ Word16 nbits_lpc[], /* Q0 */
+ Word16 *bits_param_lpc, /* Q0 */
+ Word16 *no_param_lpc, /* Q0 */
const Word16 Q_ener );
void Mode2_pit_encode_fx(
@@ -1496,15 +1558,19 @@ void Mode2_pit_encode_fx(
Word16 pit_fr2,
Word16 pit_max,
Word16 pit_res_max );
-void E_ACELP_4tsearch_fx( Word16 dn[], const Word16 cn[], const Word16 H[], Word16 code[], const PulseConfig *config, Word16 ind[], Word16 y[] );
+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[],
+ Word16 dn[], /* Qdn */
Word16 cn[] /* Q_xn */,
- Word16 H[],
- Word16 R[],
+ Word16 H[], /* Q12 */
+ Word16 R[], /* Qx */
Word8 acelpautoc,
- Word16 code[],
+ Word16 code[], /* Q9 */
Word16 cdk_index,
Word16 _index[],
const Word16 L_frame,
@@ -1514,12 +1580,12 @@ void E_ACELP_4t_fx(
const Word16 cmpl_flag );
void E_ACELP_4t_ivas_fx(
- Word16 dn[],
+ Word16 dn[], /* Qdn */
Word16 cn[] /* Q_xn */,
- Word16 H[],
- Word16 R[],
+ Word16 H[], /* Q12 */
+ Word16 R[], /* Qx */
Word8 acelpautoc,
- Word16 code[],
+ Word16 code[], /* Q9 */
Word16 cdk_index,
Word16 _index[],
const Word16 L_frame,
@@ -1556,8 +1622,9 @@ void E_ACELP_innovative_codebook_fx(
void CalculateTnsFilt_fx(
STnsConfig const *pTnsConfig, /* i : TNS Configuration struct */
const Word32 pSpectrum[], /* i : MDCT spectrum Qx*/
- STnsData *pTnsData, /* o : TNS data struct */
- Word16 *predictionGain /* o : TNS prediction gain Q7*/
+ const Word16 pSpectrum_e,
+ STnsData *pTnsData, /* o : TNS data struct */
+ Word16 *predictionGain /* o : TNS prediction gain Q7*/
);
/** Detect TNS parameters.
@@ -1636,7 +1703,13 @@ void subband_FFT_fx(
Word32 Offset, /*(i) offset of the CLDFB*/
Word16 *fftoQ /*(o) the Scaling */
);
-Word16 E_ACELP_toeplitz_mul_fx( const Word16 R[], const Word16 c[], Word16 d[], const Word16 L_subfr, const Word16 highrate );
+Word16 E_ACELP_toeplitz_mul_fx(
+ const Word16 R[], /* Q9 */
+ const Word16 c[], /* Qx */
+ Word16 d[], /* exp(j) */
+ const Word16 L_subfr, /* Q0 */
+ const Word16 highrate /* Q0 */
+);
Word16 E_ACELP_code43bit_fx( const Word16 code[], UWord32 *ps, Word16 *p, UWord16 idxs[] );
void tc_classif_enc_fx(
const Word16 Q_new, /* i : scaling factor */
@@ -1686,21 +1759,22 @@ void ari_copy_states_fx(
TastatEnc *dest );
Word16 ari_encode_14bits_ext_fx(
- Word16 *ptr,
- Word16 bp,
+ Word16 *ptr, /* Q0 */
+ Word16 bp, /* Q0 */
TastatEnc *s,
- Word32 symbol,
- UWord16 const *cum_freq );
+ Word32 symbol, /* Q0 */
+ UWord16 const *cum_freq /* Q0 */
+);
Word16 ari_put_bit_plus_follow(
- Word16 ptr[], /* o: bit-stream */
- Word16 bp, /* i: bit-stream position */
- Word16 bits_to_follow, /* i: number of opposite bits to follow 'bit' */
- Word16 bit /* i: bit to send */
+ Word16 ptr[], /* o: bit-stream Q0*/
+ Word16 bp, /* i: bit-stream position Q0*/
+ Word16 bits_to_follow, /* i: number of opposite bits to follow 'bit' Q0*/
+ Word16 bit /* i: bit to send Q0*/
);
Word16 ari_done_encoding_14bits_fx(
- Word16 *ptr,
- Word16 bp,
+ Word16 *ptr, /* Q0 */
+ Word16 bp, /* Q0 */
TastatEnc *s );
void reset_rf_indices_fx(
@@ -1745,22 +1819,22 @@ void generate_comfort_noise_enc_fx( Encoder_State *stcod,
Word16 gen_exc );
Word16 cng_energy_fx(
- const Word16 element_mode, /* i : element mode */
- const Word16 bwidth, /* i : audio bandwidh */
- const Word16 CNG_mode, /* i : mode for DTX configuration */
- const Word16 CNG_att, /* i : attenuation factor for CNG */
- const Word16 *exc, /* i : i signal */
- const Word16 len, /* i : vector length */
+ const Word16 element_mode, /* i : element mode Q0*/
+ const Word16 bwidth, /* i : audio bandwidh Q0*/
+ const Word16 CNG_mode, /* i : mode for DTX configuration Q0*/
+ const Word16 CNG_att, /* i : attenuation factor for CNG Q7*/
+ const Word16 *exc, /* i : input signal Q_new*/
+ const Word16 len, /* i : vector length Q0*/
const Word16 Q_new /* i : Input scaling */
);
void CNG_reset_enc_fx(
- Encoder_State *st_fx, /* i/o: encoder state structure */
- LPD_state_HANDLE hLPDmemm, /* i/o: acelp memories */
- Word16 *pitch_buf, /* o : floating pitch for each subframe */
- Word16 *voice_factors /* o : voicing factors */
- ,
- Word16 VBR_cng_reset_flag );
+ Encoder_State *st_fx, /* i/o: encoder state structure */
+ LPD_state_HANDLE hLPDmem, /* i/o: acelp memories */
+ Word16 *pitch_buf, /* o : floating pitch for each subframe Q6*/
+ Word16 *voice_factors, /* o : voicing factors Q15*/
+ Word16 VBR_cng_reset_flag /* Q0 */
+);
void lsf_enc_fx(
Encoder_State *st_fx, /* i/o: state structure */
@@ -1787,86 +1861,97 @@ void lsf_enc_ivas_fx(
const Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */
const Word16 Q_new );
void Es_pred_enc_fx(
- Word16 *Es_pred, /* o : predicited scaled innovation energy Q8 */
- Word16 *indice, /* o : indice of quantization */
- const Word16 L_frame, /* i : length of the frame */
- const Word16 *res, /* i : residual signal */
- const Word16 *voicing, /* i : normalized correlation in three 1/2frames */
- const Word16 nb_bits, /* i : allocated number of bits */
- const Word16 no_ltp, /* i : no_ltp flag */
- Word16 Q_new /* i : Scaling in speech Q0 */
+ Word16 *Es_pred, /* o : predicited scaled innovation energy Q8*/
+ Word16 *indice, /* o : indice of quantization Q0*/
+ const Word16 L_frame, /* i : length of the frame Q0*/
+ const Word16 *res, /* i : residual signal Q_new*/
+ const Word16 *voicing, /* i : normalized correlation in three 1/2frames Q15*/
+ const Word16 nb_bits, /* i : allocated number of bits Q0*/
+ const Word16 no_ltp, /* i : no_ltp flag Q0*/
+ Word16 Q_new /* i : Scaling in speech Q0*/
);
void encod_nelp_fx(
Encoder_State *st_fx, /* i/o: state structure */
- const Word16 *speech_fx, /* i : i speech */
- const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes */
- const Word16 Aq_fx[], /* i : 12k8 Lp coefficient */
- Word16 *res_fx, /* o : residual signal */
- Word16 *synth_fx, /* o : core synthesis */
- Word16 *tmp_noise_fx, /* o : long-term noise energy */
- Word16 *exc_fx, /* i/o: current non-enhanced excitation */
- Word16 *exc2_fx, /* i/o: current enhanced excitation */
- Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */
- Word16 *voice_factors_fx, /* o : voicing factors */
- Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */
+ const Word16 *speech_fx, /* i : input speech Q_new-1*/
+ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/
+ const Word16 Aq_fx[], /* i : 12k8 Lp coefficient Q12*/
+ Word16 *res_fx, /* o : residual signal Q_new*/
+ Word16 *synth_fx, /* o : core synthesis Q_new*/
+ Word16 *tmp_noise_fx, /* o : long-term noise energy Q0*/
+ Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/
+ Word16 *exc2_fx, /* i/o: current enhanced excitation Q_new*/
+ Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6*/
+ Word16 *voice_factors_fx, /* o : voicing factors Q15*/
+ Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q_new*/
Word16 Q_new,
Word16 shift
);
void encod_nelp_ivas_fx(
- Encoder_State *st_fx, /* i/o: state structure */
- const Word16 *speech_fx, /* i : input speech */
- const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes */
- const Word16 Aq_fx[], /* i : 12k8 Lp coefficient */
- Word16 *res_fx, /* o : residual signal */
- Word16 *synth_fx, /* o : core synthesis */
- Word16 *tmp_noise_fx, /* o : long-term noise energy */
- Word16 *exc_fx, /* i/o: current non-enhanced excitation */
- Word16 *exc2_fx, /* i/o: current enhanced excitation */
- Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */
- Word16 *voice_factors_fx, /* o : voicing factors */
- Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */
+ Encoder_State *st_fx, /* i/o: state structure */
+ const Word16 *speech_fx,
+ /* i : input speech */ /* Q_new-1 */
+ const Word16 Aw_fx[],
+ /* i : weighted A(z) unquantized for subframes */ /*exp(norm_s(Aw_fx[0])+1)*/
+ const Word16 Aq_fx[],
+ /* i : 12k8 Lp coefficient */ /*exp(norm_s(Aw_fx[0])+1)*/
+ Word16 *res_fx,
+ /* o : residual signal */ /* Q_new */
+ Word16 *synth_fx,
+ /* o : core synthesis */ /* Q_new */
+ Word16 *tmp_noise_fx,
+ /* o : long-term noise energy */ /* Q8 */
+ Word16 *exc_fx,
+ /* i/o: current non-enhanced excitation */ /* Q_new */
+ Word16 *exc2_fx,
+ /* i/o: current enhanced excitation */ /* Q_new */
+ Word16 *pitch_buf_fx,
+ /* o : floating pitch values for each subframe */ /* Q6 */
+ Word16 *voice_factors_fx,
+ /* o : voicing factors */ /* Q15 */
+ Word16 *bwe_exc_fx,
+ /* o : excitation for SWB TBE */ /* Q_new */
Word16 Q_new,
Word16 shift );
Word16 encod_tran_fx(
- Encoder_State *st_fx, /* i/o: state structure */
- const Word16 speech_fx[], /* i : i speech */
- const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes */
- const Word16 Aq_fx[], /* i : 12k8 Lp coefficient */
- const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */
- const Word16 *res_fx, /* i : residual signal */
- Word16 *syn_fx, /* i/o: core synthesis */
- Word16 *exc_fx, /* i/o: current non-enhanced excitation */
- Word16 *exc2_fx, /* i/o: current enhanced excitation */
- Word16 *pitch_buf_fx, /* i/o: floating pitch values for each subframe */
- Word16 *voice_factors, /* o : voicing factors */
- Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE */
- Word16 tc_subfr, /* i/o: TC subframe classification */
- Word16 position, /* i : maximum of residual signal index */
- Word16 *unbits, /* i/o: number of unused bits */
- const Word16 shift, /* i : Scaling to get 12 bits */
- const Word16 Q_new /* i : Input scaling */
+ Encoder_State *st_fx, /* i/o: state structure */
+ const Word16 speech_fx[], /* i : input speech Q0*/
+ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/
+ const Word16 Aq_fx[], /* i : 12k8 Lp coefficient Q12*/
+ const Word16 Es_pred_fx, /* i : predicted scaled innov. energy Q8*/
+ const Word16 *res_fx, /* i : residual signal Q_new*/
+ Word16 *syn_fx, /* i/o: core synthesis Q_new*/
+ Word16 *exc_fx, /* i/o: current non-enhanced excitation Q0*/
+ Word16 *exc2_fx, /* i/o: current enhanced excitation Q0*/
+ Word16 *pitch_buf_fx, /* i/o: floating pitch values for each subframe Q6*/
+ Word16 *voice_factors, /* o : voicing factors Q15*/
+ Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE Q0*/
+ Word16 tc_subfr, /* i/o: TC subframe classification Q0*/
+ Word16 position, /* i : maximum of residual signal index Q0*/
+ Word16 *unbits, /* i/o: number of unused bits Q0*/
+ const Word16 shift, /* i : Scaling to get 12 bits */
+ const Word16 Q_new /* i : Input scaling */
);
Word16 encod_tran_ivas_fx(
Encoder_State *st_fx, /* i/o: state structure */
- const Word16 speech_fx[], /* i : input speech */
- const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes */
- const Word16 Aq_fx[], /* i : 12k8 Lp coefficient */
- const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */
- const Word16 *res_fx, /* i : residual signal */
- Word16 *syn_fx, /* i/o: core synthesis */
- Word16 *exc_fx, /* i/o: current non-enhanced excitation */
- Word16 *exc2_fx, /* i/o: current enhanced excitation */
- Word16 *pitch_buf_fx, /* i/o: floating pitch values for each subframe */
- Word16 *voice_factors, /* o : voicing factors */
- Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE */
- Word16 tc_subfr, /* i/o: TC subframe classification */
- Word16 position, /* i : maximum of residual signal index */
- Word16 *unbits, /* i/o: number of unused bits */
+ const Word16 speech_fx[], /* i : input speech Q0*/
+ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/
+ const Word16 Aq_fx[], /* i : 12k8 Lp coefficient Q12*/
+ const Word16 Es_pred_fx, /* i : predicted scaled innov. energy Q8*/
+ const Word16 *res_fx, /* i : residual signal Q_new*/
+ Word16 *syn_fx, /* i/o: core synthesis Q_new*/
+ Word16 *exc_fx, /* i/o: current non-enhanced excitation Q0*/
+ Word16 *exc2_fx, /* i/o: current enhanced excitation Q0*/
+ Word16 *pitch_buf_fx, /* i/o: floating pitch values for each subframe Q6*/
+ Word16 *voice_factors, /* o : voicing factors Q15*/
+ Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE Q0*/
+ Word16 tc_subfr, /* i/o: TC subframe classification Q0*/
+ Word16 position, /* i : maximum of residual signal index Q0*/
+ Word16 *unbits, /* i/o: number of unused bits Q0*/
const Word16 shift, /* i : Scaling to get 12 bits */
const Word16 Q_new /* i : Input scaling */
);
@@ -1876,61 +1961,66 @@ void deleteFdCngEnc_fx( HANDLE_FD_CNG_ENC *hFdCngEnc );
void coder_acelp_rf_fx(
ACELP_config *acelp_cfg_rf, /*i /o : configuration of the ACELP coding*/
- const Word16 coder_type, /* i : coding type */
- const Word16 A[], /* i : coefficients 4xAz[M+1] */
- const Word16 Aq[], /* i : coefficients 4xAz_q[M+1] */
- Word16 speech[], /* i : speech[-M..lg] */
- const Word16 voicing[], /* i : open-loop LTP gain */
- const Word16 T_op[], /* i : open-loop LTP lag */
- Word16 stab_fac,
+ const Word16 coder_type, /* input: coding type Q0*/
+ const Word16 A[], /* input: coefficients 4xAz[M+1] Q12*/
+ const Word16 Aq[], /* input: coefficients 4xAz_q[M+1] Q12*/
+ Word16 speech[], /* input: speech[-M..lg] Q_new-1*/
+ const Word16 voicing[], /* input: open-loop LTP gain Q15*/
+ const Word16 T_op[], /* input: open-loop LTP lag Q0*/
+ Word16 stab_fac, /* Q15 */
Encoder_State *st,
- Word16 target_bits, /* i/o : coder memory state */
- const Word16 rf_frame_type, /* i : rf_frame_type */
- Word16 *exc_rf, /* i/o: pointer to RF excitation */
- Word16 *syn_rf, /* i/o: pointer to RF synthesis */
+ Word16 target_bits, /* i/o : coder memory state Q0*/
+ const Word16 rf_frame_type, /* i : rf_frame_type Q0*/
+ Word16 *exc_rf, /* i/o: pointer to RF excitation Q_new*/
+ Word16 *syn_rf, /* i/o: pointer to RF synthesis Q_new-1*/
Word16 Q_new,
Word16 shift );
/* Create an instance of type FD_CNG */
void createFdCngEnc_fx( HANDLE_FD_CNG_ENC *hFdCngEnc );
-void initFdCngEnc_fx( HANDLE_FD_CNG_ENC hsEnc, Word32 input_Fs, Word16 scale );
+void initFdCngEnc_fx(
+ HANDLE_FD_CNG_ENC hsEnc,
+ Word32 input_Fs, /* Q0 */
+ Word16 scale );
/* Configure CLDFB-CNG */
void configureFdCngEnc_fx( HANDLE_FD_CNG_ENC hs, /* i/o: Contains the variables related to the CLDFB-based CNG process */
- Word16 bandwidth, /* i: bandwidth */
- Word32 bitrate );
+ Word16 bandwidth, /* i: bandwidth Q0*/
+ Word32 bitrate /* Q0 */
+);
/* Perform noise estimation */
void perform_noise_estimation_enc_fx(
- Word32 *band_energies, /* i: energy in critical bands without minimum noise floor MODE2_E_MIN */
+ Word32 *band_energies, /* i: energy in critical bands without minimum noise floor MODE2_E_MIN exp_band_energies*/
Word16 exp_band_energies,
- Word32 *enerBuffer,
+ Word32 *enerBuffer, /* enerBuffer_exp */
Word16 enerBuffer_exp,
HANDLE_FD_CNG_ENC st ); /* i/o: FD_CNG structure containing all buffers and variables */
void perform_noise_estimation_enc_ivas_fx(
- Word32 *band_energies, /* i: energy in critical bands without minimum noise floor MODE2_E_MIN */
+ Word32 *band_energies, /* i: energy in critical bands without minimum noise floor MODE2_E_MIN band_energies_exp*/
Word16 band_energies_exp,
- Word32 *enerBuffer,
+ Word32 *enerBuffer, /* enerBuffer_exp */
Word16 enerBuffer_exp,
HANDLE_FD_CNG_ENC hFdCngEnc, /* i/o: CNG structure containing all buffers and variables */
- const Word32 input_Fs, /* i : input sampling rate */
+ const Word32 input_Fs, /* i : input sampling rate Q0*/
CPE_ENC_HANDLE hCPE /* i : CPE encoder structure */
);
/* Adjust the noise estimator at the beginning of each CNG phase (encoder-side) */
-Word16
-AdjustFirstSID_fx( Word16 npart,
- Word32 *msPeriodog,
- Word16 msPeriodog_exp,
- Word32 *energy_ho,
- Word16 *energy_ho_exp,
- Word32 *msNoiseEst,
- Word16 *msNoiseEst_exp,
- Word32 *msNoiseEst_old,
- Word16 *msNoiseEst_old_exp,
- Word16 *active_frame_counter,
- Encoder_State *stcod );
+Word16 AdjustFirstSID_fx(
+ Word16 npart, /* i : number of parts Q0*/
+ Word32 *msPeriodog, /* i : pointer to periodog vector msPeriodog_exp */
+ Word16 msPeriodog_exp, /* i : exponent of periodog vector */
+ Word32 *energy_ho, /* i/o : pointer to energy energy_ho_exp*/
+ Word16 *energy_ho_exp, /* i/o : pointer to exponent of energy */
+ Word32 *msNoiseEst, /* i/o : pointer to estimated noise msNoiseEst_exp*/
+ Word16 *msNoiseEst_exp, /* i/o : pointer to exponent of estimated noise */
+ Word32 *msNoiseEst_old, /* i/o : pointer to old estimated noise msNoiseEst_old_exp*/
+ Word16 *msNoiseEst_old_exp, /* i/o : pointer to exponent of old estimated noise */
+ Word16 *active_frame_counter, /* i/o : pointer to active frame counter Q0*/
+ Encoder_State *stcod /* i : pointer to Coder_State_Plus structure */
+);
void FdCng_encodeSID_ivas_fx(
Encoder_State *st /* i/o: encoder state structure */
@@ -1940,113 +2030,113 @@ void resetFdCngEnc_fx( Encoder_State *st );
void encod_unvoiced_fx(
Encoder_State *st_fx, /* i/o: state structure */
- const Word16 *speech_fx, /* i : Input speech */
- const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes */
- const Word16 *Aq_fx, /* i : 12k8 Lp coefficient */
- const Word16 Es_pred, /* i : predicted scaled innov. energy */
- const Word16 uc_two_stage_flag, /* i : flag indicating two-stage UC */
- const Word16 *res_fx, /* i : residual signal */
- Word16 *syn_fx, /* o : core synthesis */
- Word16 *tmp_noise_fx, /* o : long-term noise energy */
- Word16 *exc_fx, /* i/o: current non-enhanced excitation */
- Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */
- Word16 *voice_factors_fx, /* o : voicing factors */
- Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE */
+ const Word16 *speech_fx, /* i : Input speech Q_new*/
+ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/
+ const Word16 *Aq_fx, /* i : 12k8 Lp coefficient Q12*/
+ const Word16 Es_pred, /* i : predicted scaled innov. energy Q8*/
+ const Word16 uc_two_stage_flag, /* i : flag indicating two-stage UC Q0*/
+ const Word16 *res_fx, /* i : residual signal Q_new*/
+ Word16 *syn_fx, /* o : core synthesis Q_new*/
+ Word16 *tmp_noise_fx, /* o : long-term noise energy Q0*/
+ Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/
+ Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6*/
+ Word16 *voice_factors_fx, /* o : voicing factors Q15*/
+ Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE Q_exc*/
const Word16 Q_new,
const Word16 shift );
void encod_unvoiced_ivas_fx(
Encoder_State *st_fx, /* i/o: state structure */
- const Word16 *speech_fx, /* i : Input speech */
- const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes */
- const Word16 *Aq_fx, /* i : 12k8 Lp coefficient */
- const Word16 Es_pred, /* i : predicted scaled innov. energy */
- const Word16 uc_two_stage_flag, /* i : flag indicating two-stage UC */
- const Word16 *res_fx, /* i : residual signal */
- Word16 *syn_fx, /* o : core synthesis */
- Word16 *tmp_noise_fx, /* o : long-term noise energy */
- Word16 *exc_fx, /* i/o: current non-enhanced excitation */
- Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */
- Word16 *voice_factors_fx, /* o : voicing factors */
- Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE */
+ const Word16 *speech_fx, /* i : Input speech Q_new*/
+ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/
+ const Word16 *Aq_fx, /* i : 12k8 Lp coefficient Q12*/
+ const Word16 Es_pred, /* i : predicted scaled innov. energy Q8*/
+ const Word16 uc_two_stage_flag, /* i : flag indicating two-stage UC Q0*/
+ const Word16 *res_fx, /* i : residual signal Q_new*/
+ Word16 *syn_fx, /* o : core synthesis Q_new*/
+ Word16 *tmp_noise_fx, /* o : long-term noise energy Q0*/
+ Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/
+ Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6*/
+ Word16 *voice_factors_fx, /* o : voicing factors Q15*/
+ Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE Q_exc*/
const Word16 Q_new,
const Word16 shift );
void enc_acelp_tcx_main_fx(
- const Word16 new_samples[], /* i : new samples */
- Encoder_State *st, /* i/o: encoder state structure */
- Word16 Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes*/
- const Word16 lsp_new[M], /* i : LSPs at the end of the frame */
- const Word16 lsp_mid[M], /* i : LSPs at the middle of the frame */
- Word32 bwe_exc_extended[], /* i/o: bandwidth extended excitation */
- Word16 *voice_factors, /* o : voicing factors */
- Word16 pitch_buf[], /* o : floating pitch for each subframe */
- Word16 vad_hover_flag, /* i : VAD hangover flag */
+ const Word16 new_samples[], /* i : new samples Q15*/
+ Encoder_State *st, /* i/o: encoder state structure */
+ Word16 Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes Q12*/
+ const Word16 lsp_new[M], /* i : LSPs at the end of the frame Q15*/
+ const Word16 lsp_mid[M], /* i : LSPs at the middle of the frame Q15*/
+ Word32 bwe_exc_extended[], /* i/o: bandwidth extended excitation Q_new*/
+ Word16 *voice_factors, /* o : voicing factors Q15*/
+ Word16 pitch_buf[], /* o : floating pitch for each subframe Q6*/
+ Word16 vad_hover_flag, /* i : VAD hangover flag Q0*/
Word16 *Q_new,
Word16 *shift );
ivas_error encod_ppp_fx(
Encoder_State *st_fx, /* i/o: state structure */
- const Word16 speech_fx[], /* i : i speech Q_new*/
- const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes */
- const Word16 Aq_fx[], /* i : 12k8 Lp coefficient */
- Word16 *res_fx, /* i : residual signal Q_new*/
- Word16 *synth_fx, /* o : core synthesis Q-1*/
- Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/
- Word16 *exc2_fx, /* o : current enhanced excitation Q0*/
- Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6*/
- Word16 *voice_factors, /* o : voicing factors */
- Word16 *bwe_exc, /* o : excitation for SWB TBE */
+ const Word16 speech_fx[], /* i : input speech Q_new*/
+ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/
+ const Word16 Aq_fx[], /* i : 12k8 Lp coefficient Q14*/
+ Word16 *res_fx, /* i : residual signal Q_new*/
+ Word16 *synth_fx, /* o : core synthesis Q-1*/
+ Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/
+ Word16 *exc2_fx, /* o : current enhanced excitation Q0*/
+ Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6*/
+ Word16 *voice_factors, /* o : voicing factors Q15*/
+ Word16 *bwe_exc, /* o : excitation for SWB TBE Q_new*/
Word16 Q_new,
Word16 shift );
ivas_error encod_ppp_ivas_fx(
Encoder_State *st_fx, /* i/o: state structure */
- const Word16 speech_fx[], /* i : input speech Q_new*/
- const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes */
- const Word16 Aq_fx[], /* i : 12k8 Lp coefficient */
- Word16 *res_fx, /* i : residual signal Q_new*/
- Word16 *synth_fx, /* o : core synthesis Q-1*/
- Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/
- Word16 *exc2_fx, /* o : current enhanced excitation Q0*/
- Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6*/
- Word16 *voice_factors, /* o : voicing factors */
- Word16 *bwe_exc, /* o : excitation for SWB TBE */
+ const Word16 speech_fx[], /* i : input speech Q_new*/
+ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/
+ const Word16 Aq_fx[], /* i : 12k8 Lp coefficient Q12*/
+ Word16 *res_fx, /* i : residual signal Q_new*/
+ Word16 *synth_fx, /* o : core synthesis Q-1*/
+ Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/
+ Word16 *exc2_fx, /* o : current enhanced excitation Q0*/
+ Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6*/
+ Word16 *voice_factors, /* o : voicing factors Q15*/
+ Word16 *bwe_exc, /* o : excitation for SWB TBE Q_new*/
Word16 Q_new,
Word16 shift );
void encod_gen_voic_fx(
Encoder_State *st_fx, /* i/o: state structure */
- const Word16 speech_fx[], /* i : i speech */
- const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes */
- const Word16 Aq_fx[], /* i : 12k8 Lp coefficient */
- const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */
- const Word16 *res_fx, /* i : residual signal */
- Word16 *syn_fx, /* i/o: core synthesis */
- Word16 *exc_fx, /* i/o: current non-enhanced excitation */
- Word16 *exc2_fx, /* i/o: current enhanced excitation */
- Word16 *pitch_buf_fx, /* i/o: floating pitch values for each subframe */
- Word16 *voice_factors_fx, /* o : voicing factors */
- Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */
- Word16 *unbits_fx, /* i/o: number of unused bits */
- const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
- const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer */
+ const Word16 speech_fx[], /* i : i speech Q0*/
+ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/
+ const Word16 Aq_fx[], /* i : 12k8 Lp coefficient Q12*/
+ const Word16 Es_pred_fx, /* i : predicted scaled innov. energy Q8*/
+ const Word16 *res_fx, /* i : residual signal Q_new*/
+ Word16 *syn_fx, /* i/o: core synthesis Q_new*/
+ Word16 *exc_fx, /* i/o: current non-enhanced excitation Q0*/
+ Word16 *exc2_fx, /* i/o: current enhanced excitation Q0*/
+ Word16 *pitch_buf_fx, /* i/o: floating pitch values for each subframe Q6*/
+ Word16 *voice_factors_fx, /* o : voicing factors Q15*/
+ Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q0*/
+ Word16 *unbits_fx, /* i/o: number of unused bits Q0*/
+ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/
+ const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/
Word16 shift,
Word16 Q_new );
void encod_gen_voic_ivas_fx(
Encoder_State *st_fx, /* i/o: state structure */
- const Word16 speech_fx[], /* i : input speech */
- const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes */
- const Word16 Aq_fx[], /* i : 12k8 Lp coefficient */
- const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */
- const Word16 *res_fx, /* i : residual signal */
- Word16 *syn_fx, /* i/o: core synthesis */
- Word16 *exc_fx, /* i/o: current non-enhanced excitation */
- Word16 *exc2_fx, /* i/o: current enhanced excitation */
- Word16 *pitch_buf_fx, /* i/o: floating pitch values for each subframe */
- Word16 *voice_factors_fx, /* o : voicing factors */
- Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */
- Word16 *unbits_fx, /* i/o: number of unused bits */
- const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
- const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer */
+ const Word16 speech_fx[], /* i : input speech Q0*/
+ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/
+ const Word16 Aq_fx[], /* i : 12k8 Lp coefficient Q12*/
+ const Word16 Es_pred_fx, /* i : predicted scaled innov. energy Q8*/
+ const Word16 *res_fx, /* i : residual signal Q_new*/
+ Word16 *syn_fx, /* i/o: core synthesis Q_new*/
+ Word16 *exc_fx, /* i/o: current non-enhanced excitation Q0*/
+ Word16 *exc2_fx, /* i/o: current enhanced excitation Q0*/
+ Word16 *pitch_buf_fx, /* i/o: floating pitch values for each subframe Q6*/
+ Word16 *voice_factors_fx, /* o : voicing factors Q15*/
+ Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q0*/
+ Word16 *unbits_fx, /* i/o: number of unused bits Q0*/
+ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/
+ const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/
Word16 shift,
Word16 Q_new );
@@ -2130,46 +2220,31 @@ void analy_sp_fx(
Word32 *band_energies, /* o : energy in critical frequency bands without minimum noise floor MODE2_E_MIN */
Word16 *fft_buff /* o : FFT coefficients */
);
-void ivas_analy_sp_fx(
- const Word16 element_mode, /* i : element mode */
- CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
- const Word32 input_Fs, /* i : input sampling rate */
- Word16 *speech, /* i : speech buffer Q_new - preemph_bits */
- const Word16 Q_new, /* i : current scaling exp Q0 */
- Word32 *fr_bands, /* o : energy in critical frequency bands Q_new + QSCALE */
- Word32 *lf_E, /* o : per bin E for first... Q_new + QSCALE - 2*/
- Word16 *Etot, /* o : total input energy Q8 */
- const Word16 min_band, /* i : minimum critical band Q0 */
- const Word16 max_band, /* i : maximum critical band Q0 */
- const Word32 e_min_scaled, /* i : minimum energy scaled Q_new + QSCALE */
- Word16 Scale_fac[2], /* o : FFT scales factors (2 values by frame) Q0 */
- Word32 *Bin_E, /* o : per-bin energy spectrum Q7 */
- Word32 *Bin_E_old, /* o : per-bin energy spectrum of the previous frame Q7 */
- Word32 *PS, /* o : per-bin energy spectrum Q_new + QSCALE */
- Word16 *EspecdB, /* o : per-bin log energy spectrum (with f=0) Q7 */
- Word32 *band_energies, /* o : energy in critical frequency bands without minimum noise floor MODE2_E_MIN (Q_new + QSCALE + 2)*/
- Word16 *fft_buff /* o : FFT coefficients (Q_new + QSCALE + 2) */
-);
-void ivas_analy_sp_fx_front(
+void ivas_analy_sp_fx(
const Word16 element_mode, /* i : element mode */
CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
const Word32 input_Fs, /* i : input sampling rate */
Word16 *speech, /* i : speech buffer Q_new - preemph_bits */
const Word16 Q_new, /* i : current scaling exp Q0 */
- Word32 *fr_bands, /* o : energy in critical frequency bands Q_new + QSCALE */
- Word32 *lf_E, /* o : per bin E for first... Q_new + QSCALE - 2*/
+ Word32 *fr_bands, /* o : energy in critical frequency bands q_fr_bands */
+ Word16 *q_fr_bands, /* o : Q of energy in critical frequency bands Q0 */
+ Word32 *lf_E, /* o : per bin E for first... Q0 */
+ Word16 *q_lf_E, /* o : Q of per bin E for first... q_lf_E */
Word16 *Etot, /* o : total input energy Q8 */
const Word16 min_band, /* i : minimum critical band Q0 */
const Word16 max_band, /* i : maximum critical band Q0 */
- const Word32 e_min_scaled, /* i : minimum energy scaled Q_new + QSCALE */
- Word16 Scale_fac[2], /* o : FFT scales factors (2 values by frame) Q0 */
- Word32 *Bin_E, /* o : per-bin energy spectrum Q7 */
- Word32 *Bin_E_old, /* o : per-bin energy spectrum of the previous frame Q7 */
- Word32 *PS, /* o : per-bin energy spectrum Q_new + QSCALE - 2 */
+ Word32 *Bin_E, /* o : per-bin energy spectrum q_Bin_E */
+ Word16 *q_Bin_E, /* o : Q of per-bin energy spectrum Q0 */
+ Word32 *Bin_E_old, /* o : per-bin energy spectrum of the previous frame q_Bin_E_old */
+ Word16 *q_Bin_E_old, /* o : Q of per-bin energy spectrum of the previous frame Q0 */
+ Word32 *PS, /* o : per-bin energy spectrum q_PS */
+ Word16 *q_PS, /* o : Q of per-bin energy spectrum Q0 */
Word16 *EspecdB, /* o : per-bin log energy spectrum (with f=0) Q7 */
- Word32 *band_energies, /* o : energy in critical frequency bands without minimum noise floor MODE2_E_MIN (Q_new + QSCALE)*/
- Word16 *fft_buff /* o : FFT coefficients (Q_new + Scale_fac[i_subfr]) */
+ Word32 *band_energies, /* o : energy in critical frequency bands without minimum noise floor MODE2_E_MIN (q_band_energies)*/
+ Word16 *q_band_energies, /* o : Q of energy in critical frequency bands without minimum noise floor MODE2_E_MIN */
+ Word16 *fft_buff, /* o : FFT coefficients (q_fft_buff) */
+ Word16 *q_fft_buff /* o : Q of FFT coefficients Q0 */
);
void find_wsp_fx(
const Word16 Az[],
@@ -2186,9 +2261,26 @@ void find_wsp_fx(
);
Word16 ari_encode_overflow_fx( TastatEnc *s );
-Word16 ari_encode_14bits_range_fx( Word16 *ptr, Word16 bp, Word16 bits, TastatEnc *s, Word16 cum_freq_low, Word16 cum_freq_high );
-Word16 ari_encode_14bits_sign_fx( Word16 *ptr, Word16 bp, Word16 bits, TastatEnc *s, Word16 sign );
-Word16 ari_done_cbr_encoding_14bits_fx( Word16 *ptr, Word16 bp, Word16 bits, TastatEnc *s );
+Word16 ari_encode_14bits_range_fx(
+ Word16 *ptr, /* Q0 */
+ Word16 bp, /* Q0 */
+ Word16 bits, /* Q0 */
+ TastatEnc *s,
+ Word16 cum_freq_low, /* Q0 */
+ Word16 cum_freq_high /* Q0 */
+);
+Word16 ari_encode_14bits_sign_fx(
+ Word16 *ptr, /* Q0 */
+ Word16 bp, /* Q0 */
+ Word16 bits, /* Q0 */
+ TastatEnc *s,
+ Word16 sign /* Q0 */
+);
+Word16 ari_done_cbr_encoding_14bits_fx(
+ Word16 *ptr, /* Q0 */
+ Word16 bp, /* Q0 */
+ Word16 bits, /* Q0 */
+ TastatEnc *s );
void tcx_hm_analyse_fx(
const Word32 abs_spectrum[], /* i: absolute spectrum Q31-e */
@@ -2202,75 +2294,74 @@ void tcx_hm_analyse_fx(
const Word16 LtpGain, /* i: LTP gain Q15 */
Word16 *hm_bits_out /* o: bit consumption Q0 */
);
-void E_ACELP_4tsearchx_fx( Word16 dn[], const Word16 cn[], Word16 Rw[], Word16 code[], const PulseConfig *config, Word16 ind[] );
+void E_ACELP_4tsearchx_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_new*/, Word16 Rw[] /*Q9*/, Word16 code[] /*Q9*/, const PulseConfig *config, Word16 ind[] /*Q0*/ );
void E_ACELP_4tsearchx_ivas_fx(
- Word16 dn[],
- const Word16 cn[],
- Word16 Rw[],
- Word16 code[],
+ Word16 dn[], /*Qdn*/
+ const Word16 cn[], /*Q_new*/
+ Word16 Rw[], /*Q9*/
+ Word16 code[], /*Q9*/
const PulseConfig *config,
- Word16 ind[],
+ Word16 ind[], /*Q0*/
Word16 element_mode );
void E_ACELP_weighted_code(
- const Word16 code[], /* i: code */
- const Word16 H[], /* i: impulse response */
- Word16 Q, /* i: Q format of H */
- Word16 y[] /* o: weighted code */
+ const Word16 code[], /* i: code Q9*/
+ const Word16 H[], /* i: impulse response Q*/
+ Word16 Q, /* i: Q format of H */
+ Word16 y[] /* o: weighted code Q9*/
);
void find_targets_fx(
const Word16 *speech, /* i : pointer to the speech frame Q_new-1*/
const Word16 *mem_syn, /* i : memory of the synthesis filter Q_new-1*/
- const Word16 i_subfr, /* i : subframe index */
+ const Word16 i_subfr, /* i : subframe index Q0*/
Word16 *mem_w0, /* i/o: weighting filter denominator memory Q_new-1*/
const Word16 *p_Aq, /* i : interpolated quantized A(z) filter Q12*/
const Word16 *res, /* i : residual signal Q_new*/
- const Word16 L_subfr, /* i : length of vectors for gain quantization */
+ const Word16 L_subfr, /* i : length of vectors for gain quantization Q0*/
const Word16 *Ap, /* i : unquantized A(z) filter with bandwidth expansion Q12*/
- Word16 tilt_fac, /* i : tilt factor Q15 */
+ Word16 tilt_fac, /* i : tilt factor Q15*/
Word16 *xn, /* o : Close-loop Pitch search target vector Q_new-1*/
- Word16 *cn /* o : target vector in residual domain Q_new*/
- ,
- Word16 *h1 /* Q14 ?*/
+ Word16 *cn, /* o : target vector in residual domain Q_new*/
+ Word16 *h1 /* o : impulse response of weighted synthesis filter Q14*/
);
void find_targets_ivas_fx(
const Word16 *speech, /* i : pointer to the speech frame Q_new-1*/
const Word16 *mem_syn, /* i : memory of the synthesis filter Q_new-1*/
- const Word16 i_subfr, /* i : subframe index */
+ const Word16 i_subfr, /* i : subframe index Q0*/
Word16 *mem_w0, /* i/o: weighting filter denominator memory Q_new-1*/
const Word16 *p_Aq, /* i : interpolated quantized A(z) filter Q12*/
const Word16 *res, /* i : residual signal Q_new*/
- const Word16 L_subfr, /* i : length of vectors for gain quantization */
+ const Word16 L_subfr, /* i : length of vectors for gain quantization Q0*/
const Word16 *Ap, /* i : unquantized A(z) filter with bandwidth expansion Q12*/
- Word16 tilt_fac, /* i : tilt factor Q15 */
+ Word16 tilt_fac, /* i : tilt factor Q15*/
Word16 *xn, /* o : Close-loop Pitch search target vector Q_new-1*/
Word16 *cn, /* o : target vector in residual domain Q_new*/
- Word16 *h1 /* o : impulse response of weighted synthesis filter */
+ Word16 *h1 /* o : impulse response of weighted synthesis filter Q14*/
);
void E_ACELP_adaptive_codebook(
- Word16 *exc, /* i : pointer to the excitation frame */
- Word16 T0, /* i : integer pitch lag */
- Word16 T0_frac, /* i : fraction of lag */
- Word16 T0_res, /* i : pitch resolution */
- Word16 T0_res_max, /* i : maximum pitch resolution */
- Word16 mode, /* i : filtering mode (0: no, 1: yes, 2: adaptive) */
- Word16 i_subfr, /* i : subframe index */
- Word16 L_subfr, /* i : subframe length */
- Word16 L_frame, /* i : subframe length */
- Word16 *h1, /* i : impulse response of weighted synthesis filter */
- Word16 clip_gain,
- Word16 *xn, /* i : Close-loop Pitch search target vector */
- Word16 *y1, /* o : zero-memory filtered adaptive excitation */
+ Word16 *exc, /* i : pointer to the excitation frame Q_new */
+ Word16 T0, /* i : integer pitch lag Q0 */
+ Word16 T0_frac, /* i : fraction of lag Q0 */
+ Word16 T0_res, /* i : pitch resolution Q0 */
+ Word16 T0_res_max, /* i : maximum pitch resolution Q0 */
+ Word16 mode, /* i : filtering mode (0: no, 1: yes, 2: adaptive) Q0 */
+ Word16 i_subfr, /* i : subframe index */
+ Word16 L_subfr, /* i : subframe length Q0 */
+ Word16 L_frame, /* i : subframe length Q0 */
+ Word16 *h1, /* i : impulse response of weighted synthesis filter 1Q14+shift */
+ Word16 clip_gain, /* Q14 */
+ Word16 *xn, /* i : Close-loop Pitch search target vector Q_xn */
+ Word16 *y1, /* o : zero-memory filtered adaptive excitation Q_xn */
ACELP_CbkCorr *g_corr, /* o : ACELP correlation values */
Word16 **pt_indice, /* i/o: quantization indices pointer */
- Word16 *pitch_gain, /* o : adaptive codebook gain */
+ Word16 *pitch_gain, /* o : adaptive codebook gain 1Q14 */
Word16 exp_xn,
Word16 rf_mode,
Word16 use_prev_sf_pit_gain,
Word16 *lp_select );
-void E_ACELP_xy2_corr( Word16 xn[], Word16 y1[], Word16 y2[], ACELP_CbkCorr *g_corr, Word16 L_subfr, Word16 exp_xn );
+void E_ACELP_xy2_corr( Word16 xn[] /*Q_xn*/, Word16 y1[] /*Q_xn*/, Word16 y2[] /*Q9*/, ACELP_CbkCorr *g_corr, Word16 L_subfr /*Q0*/, Word16 exp_xn );
void gauss_L2_fx(
const Word16 h[], /* i : weighted LP filter impulse response Q14+s */
@@ -2314,12 +2405,12 @@ Word16 SearchPeriodicityIndex_fx(
);
Word16 ACcontextMapping_encode2_estimate_no_mem_s17_LC_fx(
- const Word16 *x,
- Word16 nt,
- Word16 *lastnz,
- Word16 *nEncoded,
- Word16 target,
- Word16 *stop,
+ const Word16 *x, /* Q0 */
+ Word16 nt, /* Q0 */
+ Word16 *lastnz_out, /* Q0 */
+ Word16 *nEncoded, /* Q0 */
+ Word16 target, /* Q0 */
+ Word16 *stop, /* Q0 */
CONTEXT_HM_CONFIG *hm_cfg );
void tcx_arith_encode_envelope_fx(
@@ -2352,38 +2443,38 @@ void QuantizeGain( Word16 n, Word16 *pGain, Word16 *pGain_e, Word16 *pQuantizedG
void core_signal_analysis_high_bitrate_fx(
const Word16 *new_samples, /*i: 0Q15*/
- const Word16 T_op[3], /* i : open-loop pitch values for quantiz. */
- Word16 lsp_new[],
- Word16 lsp_mid[],
+ const Word16 T_op[3], /* i : open-loop pitch values for quantiz. Q0*/
+ Word16 lsp_new[], /* Q15 */
+ Word16 lsp_mid[], /* Q15 */
Encoder_State *st,
- Word16 pTnsSize[],
- Word16 pTnsBits[],
- Word16 param_core[],
- Word16 *ltpBits,
- const Word16 L_frame,
- const Word16 L_frameTCX,
- const Word16 last_element_mode,
- const Word16 vad_hover_flag, /* i : VAD hangover flag */
- Word32 **spectrum,
+ Word16 pTnsSize[], /* Q0 */
+ Word16 pTnsBits[], /* Q0 */
+ Word16 param_core[], /* Q0 */
+ Word16 *ltpBits, /* Q0 */
+ const Word16 L_frame, /* Q0 */
+ const Word16 L_frameTCX, /* Q0 */
+ const Word16 last_element_mode, /* Q0 */
+ const Word16 vad_hover_flag, /* i : VAD hangover flag Q0*/
+ Word32 **spectrum, /* spectrum_e */
Word16 *spectrum_e,
Word16 *Q_new );
void core_signal_analysis_high_bitrate_ivas_fx(
const Word16 *new_samples, /*i: Q0 */
- const Word16 T_op[3], /* i : open-loop pitch values for quantiz. */
+ const Word16 T_op[3], /* i : open-loop pitch values for quantiz. Q0*/
Word16 lsp_new[], /* Q15 */
Word16 lsp_mid[], /* Q15 */
Encoder_State *st,
- Word16 pTnsSize[],
- Word16 pTnsBits[],
- Word16 param_core[],
- Word16 *ltpBits,
- Word32 *windowed_samples,
- const Word16 L_frame,
- const Word16 L_frameTCX,
- const Word16 last_element_mode,
- const Word16 vad_hover_flag, /* i : VAD hangover flag */
- Word32 **spectrum,
+ Word16 pTnsSize[], /* Q0 */
+ Word16 pTnsBits[], /* Q0 */
+ Word16 param_core[], /* Q0 */
+ Word16 *ltpBits, /* Q0 */
+ Word32 *windowed_samples, /* q_win */
+ const Word16 L_frame, /* Q0 */
+ const Word16 L_frameTCX, /* Q0 */
+ const Word16 last_element_mode, /* Q0 */
+ const Word16 vad_hover_flag, /* i : VAD hangover flag Q0*/
+ Word32 **spectrum, /* exp(spectrum_e) */
Word16 *spectrum_e,
Word16 *Q_new,
Word16 *q_win );
@@ -2439,7 +2530,7 @@ void QuantizeTCXSpectrum_fx(
Encoder_State *st, /* i : state handle */
const Word16 frame_cnt, /* i : frame counter in the super_frame Q0 */
Word32 *x_orig_fx, /* i : shaped MDCT spectrum */
- const Word16 x_orig_e, /* i : exp of shaped MDCT spectrum */
+ Word16 x_orig_e, /* i : exp of shaped MDCT spectrum */
Word16 *gainlpc_fx, /* i : FDNS gains */
Word16 *gainlpc_e, /* i : exp of FDNS gains */
const Word16 *Aqind, /* i : frame-independent quantized coefficients (M+1) Q0 */
@@ -2662,36 +2753,36 @@ void enc_prm_rf_fx(
void enc_prm_rf_ivas_fx( Encoder_State *st,
const Word16 rf_frame_type,
const Word16 fec_offset );
-void E_ACELP_pulsesign( const Word16 cn[], Word16 dn[], Word16 dn2[], Word16 sign[], Word16 vec[], const Word16 alp, Word16 const sign_val, const Word16 L_subfr );
+void E_ACELP_pulsesign( const Word16 cn[] /*Q_xn*/, Word16 dn[] /*Qdn*/, Word16 dn2[] /*Qdn2*/, Word16 sign[] /*Q13*/, Word16 vec[] /*Q15*/, const Word16 alp /*Q13*/, Word16 const sign_val /*Q15*/, const Word16 L_subfr /*Q0*/ );
-void E_ACELP_findcandidates( Word16 dn2[], Word16 dn2_pos[], Word16 pos_max[] );
+void E_ACELP_findcandidates( Word16 dn2[] /*Qx*/, Word16 dn2_pos[] /*Q0*/, Word16 pos_max[] /*Q0*/ );
void E_ACELP_setup_pulse_search_pos(
- const PulseConfig *config, /* i: pulse configuration */
- Word16 k, /* i: interation number */
- UWord8 ipos[] /* o: pulse search positions */
+ const PulseConfig *config, /* i: pulse configuration */
+ Word16 k, /* i: interation number Q0*/
+ UWord8 ipos[] /* o: pulse search positions Q0*/
);
void E_ACELP_build_code(
- Word16 nb_pulse, /* i */
- const Word16 codvec[], /* i */
- const Word16 sign[], /* i */
- Word16 code[], /* o */
- Word16 ind[] /* o */
+ Word16 nb_pulse, /* i Q0*/
+ const Word16 codvec[], /* i Q0*/
+ const Word16 sign[], /* i Q0*/
+ Word16 code[], /* o Q9*/
+ Word16 ind[] /* o Q0*/
);
void E_UTIL_f_convolve( const Word16 x[], const Word16 h[], Word16 y[], const Word16 size );
void E_ACELP_conv(
- const Word16 xn2[], /* i */
- const Word16 h2[], /* i */
- Word16 cn2[] /* o */
+ const Word16 xn2[], /* i Qx*/
+ const Word16 h2[], /* i Q12*/
+ Word16 cn2[] /* o Q0*/
);
-void E_ACELP_conv_ivas(
- const Word16 xn2[], /* i */
- const Word16 h2[], /* i */
- Word16 cn2[] /* o */
+void E_ACELP_conv_ivas_fx(
+ const Word16 xn2[], /* i Qx*/
+ const Word16 h2[], /* i Q12*/
+ Word16 cn2[] /* o Q0*/
);
void gPLC_encInfo_fx(
@@ -2761,18 +2852,18 @@ Word16 enc_lsf_tcxlpc_ivas_fx(
Word16 encode_lpc_avq_fx(
BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
- const Word16 numlpc, /* i : Number of sets of lpc */
- const Word16 *param_lpc, /* i : lpc parameters */
- const Word16 core, /* i : core */
- const Word16 element_mode /* i : element mode - decides between SNS and LPC coding */
+ const Word16 numlpc, /* i : Number of sets of lpc Q0*/
+ const Word16 *param_lpc, /* i : lpc parameters Q0*/
+ const Word16 core, /* i : core Q0*/
+ const Word16 element_mode /* i : element mode - decides between SNS and LPC coding Q0*/
);
Word16 encode_lpc_avq_ivas_fx(
BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
- const Word16 numlpc, /* i : Number of sets of lpc */
- const Word16 *param_lpc, /* i : lpc parameters */
- const Word16 core, /* i : core */
- const Word16 element_mode /* i : element mode - decides between SNS and LPC coding */
+ const Word16 numlpc, /* i : Number of sets of lpc Q0*/
+ const Word16 *param_lpc, /* i : lpc parameters Q0*/
+ const Word16 core, /* i : core Q0*/
+ const Word16 element_mode /* i : element mode - decides between SNS and LPC coding Q0*/
);
Word16 lsf_bctcvq_encprm_fx(
@@ -2815,11 +2906,11 @@ Word16 IGFEncWriteBitstream_fx( /**< ou
void ACcontextMapping_encode2_no_mem_s17_LC_fx(
BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
- Word16 *x,
- Word16 nt,
- Word16 lastnz,
- Word16 nbbits,
- Word16 resQMaxBits,
+ Word16 *x, /* Q0 */
+ Word16 nt, /* Q0 */
+ Word16 lastnz, /* Q0 */
+ Word16 nbbits, /* Q0 */
+ Word16 resQMaxBits, /* Q0 */
CONTEXT_HM_CONFIG *hm_cfg );
Word16 IGFEncWriteConcatenatedBitstream_fx( /**< out: Q0 | total number of bits written */
@@ -2909,11 +3000,11 @@ void qlpc_avq_fx(
const Word16 *lsfmid, /* i : Input LSF vectors (14Q1*1.28) */
Word16 *lsf_q, /* o : Quantized LFS vectors (14Q1*1.28) */
Word16 *lsfmid_q, /* o : Quantized LFS vectors (14Q1*1.28) */
- Word16 *index, /* o : Quantization indices */
- Word16 *nb_indices, /* o : Number of quantization indices */
- Word16 *nbbits, /* o : Number of quantization bits */
- const Word16 core, /* i : TCX10 or TCX20 */
- const Word32 sr_core /* i : internal sampling rate */
+ Word16 *index, /* o : Quantization indices Q0 */
+ Word16 *nb_indices, /* o : Number of quantization indices Q0 */
+ Word16 *nbbits, /* o : Number of quantization bits Q0 */
+ const Word16 core, /* i : TCX10 or TCX20 Q0 */
+ const Word32 sr_core /* i : internal sampling rate Q0 */
);
/* ivas_tcx_core_enc.c */
@@ -2945,6 +3036,15 @@ 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( Word16 *highPassEner_exp, /**< out: | exponent of highPassEner */
+ 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 */
@@ -2962,7 +3062,7 @@ void IGFEncApplyMono_ivas_fx( Encoder_State *st, /* i : Encoder st
Word32 *pMDCTSpectrum_fx, /* i/o: MDCT spectrum */
Word16 e_mdct, /* i : exponent of pMDCTspectrum */
Word32 *pPowerSpectrum_fx, /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */
- Word16 e_ps, /* i : exponent of pPowerSpectrum */
+ Word16 *e_ps, /* i : exponent of pPowerSpectrum */
const int16_t isTCX20, /* i : flag indicating if the input is TCX20 or TCX10/2xTCX5 */
const int8_t isTNSActive, /* i : flag indicating if the TNS is active */
const int16_t sp_aud_decision0, /* i : first stage switching decision */
@@ -3021,33 +3121,32 @@ Word16 vad_proc_fx(
);
void calc_lf_snr_fx(
- Word32 *lf_snr_smooth, /* o : smoothed lf_snr*/
- Word32 *lf_snr, /* o : long time frequency domain
- SNR calculated by l_speech_snr and l_silence_snr*/
- const Word32 l_speech_snr, /* i : sum of active frames snr */
- const Word32 l_speech_snr_count, /* i : amount of the active frame */
- const Word32 l_silence_snr, /* i : sum of the nonactive frames snr*/
- const Word32 l_silence_snr_count, /* i : amount of the nonactive frame */
- const Word16 fg_energy_count, /* i : amount of the foreground energy frame */
- const Word16 bg_energy_count, /* i : amount of the background energy frame */
- const Word16 bw_index /* i : band width index*/
+ Word32 *lf_snr_smooth, /* o : smoothed lf_snr Q25*/
+ Word32 *lf_snr, /* o : long time frequency domain SNR calculated by l_speech_snr and l_silence_snr Q25*/
+ const Word32 l_speech_snr, /* i : sum of active frames snr Q16*/
+ const Word32 l_speech_snr_count, /* i : amount of the active frame Q0*/
+ const Word32 l_silence_snr, /* i : sum of the nonactive frames snr Q16*/
+ const Word32 l_silence_snr_count, /* i : amount of the nonactive frame Q0*/
+ const Word16 fg_energy_count, /* i : amount of the foreground energy frame Q0*/
+ const Word16 bg_energy_count, /* i : amount of the background energy frame Q0*/
+ const Word16 bw_index /* i : band width index Q0*/
);
void calc_lt_snr_fx(
VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */
- Word32 *lt_snr_org_fp, /* o : original long time SNR*/
- Word32 *lt_snr_fp, /* o : long time SNR calculated by fg_energy and bg_energy*/
- Word32 fg_energy, /* i : foreground energy sum */
- Word16 fg_energy_count, /* i : amount of the foreground energy frame */
- Word32 bg_energy, /* i : background energy sum */
- Word16 bg_energy_count, /* i : amount of the background energy frame */
- Word16 bw_index, /* i : band width index*/
- Word16 lt_noise_sp_center0 /* i : long time noise spectral center by 0*/
+ Word32 *lt_snr_org_fp, /* o : original long time SNR Q25*/
+ Word32 *lt_snr_fp, /* o : long time SNR calculated by fg_energy and bg_energy Q25*/
+ Word32 fg_energy, /* i : foreground energy sum Qx*/
+ Word16 fg_energy_count, /* i : amount of the foreground energy frame Q0*/
+ Word32 bg_energy, /* i : background energy sum Qx*/
+ Word16 bg_energy_count, /* i : amount of the background energy frame Q0*/
+ Word16 bw_index, /* i : band width index Q0*/
+ Word16 lt_noise_sp_center0 /* i : long time noise spectral center by 0 Q10*/
);
-void calc_snr_flux_fx( Word32 tsnr_fix, /*(i) time-domain SNR*/
- Word32 *pre_snr, /*(io)time-domain SNR storage*/
- Word32 *snr_flux /*(o) average tsnr*/
+void calc_snr_flux_fx( Word32 tsnr_fix, /*(i) time-domain SNR Q25*/
+ Word32 *pre_snr, /*(io)time-domain SNR storage Q25*/
+ Word32 *snr_flux /*(o) average tsnr Q25*/
);
Word16 vlpc_2st_cod_fx( /* o : number of allocated bits */
@@ -3093,9 +3192,9 @@ void spec_flatness_fx( Word32 *spec_amp, /*(i) spectral amplitude*/
void SetModeIndex_fx(
Encoder_State *st,
- Word32 last_total_brate,
- const Word16 last_element_mode,
- const Word16 is_mct,
+ Word32 last_total_brate, /* Q0 */
+ const Word16 last_element_mode, /* Q0 */
+ const Word16 is_mct, /* Q0 */
const Word16 shift );
void MDCT_selector_fx(
@@ -3154,39 +3253,40 @@ void IGFSCFEncoderRestoreContextState_fx(
);
void frame_spec_dif_cor_rate_fx(
- VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */
- Word32 *spec_amp, /* i : spectral amplitude*/
- Word16 sacle, /* i : the scaling of spec_amp*/
- Word16 f_tonality_rate[3] /* o : tonality rate*/
+ VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */
+ Word32 *spec_amp, /* i : spectral amplitude scale*/
+ Word16 sacle, /* i : the scaling of spec_amp */
+ Word16 f_tonality_rate[3] /* o : tonality rate Qx*/
);
void est_energy_fx(
- Word32 enerBuffer[CLDFB_NO_CHANNELS_MAX], /* i : energy vector per band */
- Word16 enerBuffer_exp, /* i : exponent of energy vector */
- Word32 *frame_sb_energy, /* o : energy of sub-band divided non-uniformly*/
- Word32 *frame_energy2_p, /* o : frame energy 2*/
- Word32 *HB_Power_p, /* o : high frequency energy*/
- Word32 *frame_energy_p, /* o : frame energy 1*/
- Word16 *sb_power_Q, /* o : the scaling of sb_power*/
- Word16 *frame_energy2_Q, /* o : the scaling of frame_energy*/
- Word16 *HB_Power_Q, /* o : the scaling of HB_Power*/
- Word16 *frame_energy_Q, /* o : the Scaling of frame_energy*/
- Word16 *frame_sb_energy_scale, /* o : the Scaling of frame_sb_energy[]*/
- const Word32 bandwidth /* i : band width*/
+ Word32 enerBuffer[CLDFB_NO_CHANNELS_MAX], /* i : energy vector per band enerBuffer_exp*/
+ Word16 enerBuffer_exp, /* i : exponent of energy vector */
+ Word32 *frame_sb_energy, /* o : energy of sub-band divided non-uniformly frame_sb_energy_scale*/
+ Word32 *frame_energy2_p, /* o : frame energy 2 frame_energy2_Q*/
+ Word32 *HB_Power_p, /* o : high frequency energy HB_Power_Q*/
+ Word32 *frame_energy_p, /* o : frame energy 1 frame_energy_Q*/
+ Word16 *sb_power_Q, /* o : the scaling of sb_power */
+ Word16 *frame_energy2_Q, /* o : the scaling of frame_energy */
+ Word16 *HB_Power_Q, /* o : the scaling of HB_Power */
+ Word16 *frame_energy_Q, /* o : the Scaling of frame_energy */
+ Word16 *frame_sb_energy_scale, /* o : the Scaling of frame_sb_energy[] */
+ const Word32 bandwidth /* i : band width Q0*/
);
void background_update_fx(
- VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */
- Word16 scale, /* i : the scaling of frame energy*/
- Word32 frame_energy, /* i : current frame energy*/
- Word32 update_flag, /* i : update flag*/
- Word16 music_backgound_f, /* i : background music flag*/
- Word32 snr );
+ VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */
+ Word16 scale, /* i : the scaling of frame energy */
+ Word32 frame_energy, /* i : current frame energy scale*/
+ Word32 update_flag, /* i : update flag Q0*/
+ Word16 music_backgound_f, /* i : background music flag Q0*/
+ Word32 snr /* Q25 */
+);
/* enc_gain.c */
-Word16 E_GAIN_closed_loop_search_fx( Word16 exc[],
- Word16 xn[],
- Word16 h[],
+Word16 E_GAIN_closed_loop_search_fx( Word16 exc[], /*Q_new*/
+ Word16 xn[], /*Q_xn*/
+ Word16 h[], /* Q14+shift */
Word16 t0_min,
Word16 t0_min_frac,
Word16 t0_max,
@@ -3230,26 +3330,26 @@ void amr_wb_enc_init_fx(
);
void snr_calc(
- VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */
- const Word16 sacle_sbpower, /* i : the Scaling of sbpower*/
- Word32 *snr, /* o : frequency domain SNR */
- Word32 *tsnr, /* o : time domain SNR */
- const Word32 frame_energy, /* i : current frame energy */
- const Word32 bwidth /* i : audio band width*/
+ VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */
+ const Word16 sacle_sbpower, /* i : the Scaling of sbpower */
+ Word32 *snr, /* o : frequency domain SNR Q25*/
+ Word32 *tsnr, /* o : time domain SNR Q25*/
+ const Word32 frame_energy, /* i : current frame energy sacle_sbpower*/
+ const Word32 bwidth /* i : audio band width Q0*/
);
void FEC_encode_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const ACELP_config acelp_cfg, /* i/o: configuration of the ACELP */
- const Word16 *synth, /* i : pointer to synthesized speech for E computation */
- const Word16 coder_type, /* i : type of coder */
- Word16 clas, /* i : signal clas for current frame */
- const Word16 *fpit, /* i : close loop fractional pitch buffer */
- const Word16 *res, /* i : LP residual signal frame */
- Word16 *last_pulse_pos, /* i/o: Position of the last pulse */
- const Word16 L_frame, /* i : Frame length */
- const Word32 total_brate, /* i : total codec bitrate */
- const Word16 Q_new, /* i : i scaling */
- const Word16 shift /* i : scaling to get 12bits */
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ const ACELP_config acelp_cfg, /* i/o: configuration of the ACELP */
+ const Word16 *synth, /* i : pointer to synthesized speech for E computation Q_synth*/
+ const Word16 coder_type, /* i : type of coder Q0*/
+ Word16 clas, /* i : signal clas for current frame Q0*/
+ const Word16 *fpit, /* i : close loop fractional pitch buffer Q6*/
+ const Word16 *res, /* i : LP residual signal frame Qx*/
+ Word16 *last_pulse_pos, /* i/o: Position of the last pulse Q0*/
+ const Word16 L_frame, /* i : Frame length Q0*/
+ const Word32 total_brate, /* i : total codec bitrate Q0*/
+ const Word16 Q_new, /* i : i scaling */
+ const Word16 shift /* i : scaling to get 12bits */
);
void updt_enc_fx(
@@ -3338,7 +3438,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 */
@@ -3403,44 +3503,44 @@ Word16 inov_encode_ivas_fx(
void gain_enc_mless_fx(
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const Word16 gains_mode[], /* i : gain bits */
- const Word16 element_mode, /* i : element mode */
- const Word16 L_frame, /* i : length of the frame */
- const Word16 i_subfr, /* i : subframe index */
- const Word16 tc_subfr, /* i : TC subframe index */
- const Word16 *xn, /* i : target vector */
- const Word16 *y1, /* i : zero-memory filtered adaptive excitation */
- const Word16 Q_xn, /* i : xn and y1 scaling */
- const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation */
- const Word16 *code, /* i : algebraic excitation */
- const Word16 Es_pred, /* i : predicted scaled innovation energy */
- Word16 *gain_pit, /* o : quantized pitch gain */
- Word32 *gain_code, /* o : quantized codebook gain */
- Word16 *gain_inov, /* o : gain of the innovation (used for normalization) */
- Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation */
- Word16 *g_corr, /* i/o: correlations , -2,, -2 and 2 */
- const Word16 clip_gain /* i : gain pitch clipping flag (1 = clipping) */
+ const Word16 gains_mode[], /* i : gain bits Q0*/
+ const Word16 element_mode, /* i : element mode Q0*/
+ const Word16 L_frame, /* i : length of the frame Q0*/
+ const Word16 i_subfr, /* i : subframe index Q0*/
+ const Word16 tc_subfr, /* i : TC subframe index Q0*/
+ const Word16 *xn, /* i : target vector Q_xn*/
+ const Word16 *y1, /* i : zero-memory filtered adaptive excitation Q_xn*/
+ const Word16 Q_xn, /* i : xn and y1 scaling */
+ const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9*/
+ const Word16 *code, /* i : algebraic excitation Q9*/
+ const Word16 Es_pred, /* i : predicted scaled innovation energy Q8*/
+ Word16 *gain_pit, /* o : quantized pitch gain Q14*/
+ Word32 *gain_code, /* o : quantized codebook gain Q16*/
+ Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/
+ Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/
+ Word16 *g_corr, /* i/o: correlations , -2,, -2 and 2 Qx*/
+ const Word16 clip_gain /* i : gain pitch clipping flag (1 = clipping) Q0*/
);
void gain_enc_mless_ivas_fx(
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const Word16 gains_mode[], /* i : gain bits */
- const Word16 element_mode, /* i : element mode */
- const Word16 L_frame, /* i : length of the frame */
- const Word16 i_subfr, /* i : subframe index */
- const Word16 tc_subfr, /* i : TC subframe index */
- const Word16 *xn, /* i : target vector */
- const Word16 *y1, /* i : zero-memory filtered adaptive excitation */
- const Word16 Q_xn, /* i : xn and y1 scaling */
- const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation */
- const Word16 *code, /* i : algebraic excitation */
- const Word16 Es_pred, /* i : predicted scaled innovation energy */
- Word16 *gain_pit, /* o : quantized pitch gain */
- Word32 *gain_code, /* o : quantized codebook gain */
- Word16 *gain_inov, /* o : gain of the innovation (used for normalization) */
- Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation */
- Word16 *g_corr, /* i/o: correlations , -2,, -2 and 2 */
- const Word16 clip_gain /* i : gain pitch clipping flag (1 = clipping) */
+ const Word16 gains_mode[], /* i : gain bits Q0*/
+ const Word16 element_mode, /* i : element mode Q0*/
+ const Word16 L_frame, /* i : length of the frame Q0*/
+ const Word16 i_subfr, /* i : subframe index Q0*/
+ const Word16 tc_subfr, /* i : TC subframe index Q0*/
+ const Word16 *xn, /* i : target vector Q_xn*/
+ const Word16 *y1, /* i : zero-memory filtered adaptive excitation Q_xn*/
+ const Word16 Q_xn, /* i : xn and y1 scaling */
+ const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9*/
+ const Word16 *code, /* i : algebraic excitation Q9*/
+ const Word16 Es_pred, /* i : predicted scaled innovation energy Q8*/
+ Word16 *gain_pit, /* o : quantized pitch gain Q14*/
+ Word32 *gain_code, /* o : quantized codebook gain Q16*/
+ Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/
+ Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/
+ Word16 *g_corr, /* i/o: correlations , -2,, -2 and 2 Qx*/
+ const Word16 clip_gain /* i : gain pitch clipping flag (1 = clipping) Q0*/
);
void updt_IO_switch_enc_fx(
Encoder_State *st, /* i/o: state structure */
@@ -3456,39 +3556,39 @@ void hf_cod_init_fx(
);
void analy_lp_AMR_WB_fx(
- const Word16 speech[], /* i : pointer to the speech frame */
- Word32 *ener, /* o : residual energy from Levinson-Durbin */
- Word16 A[], /* o : A(z) filter coefficients */
- Word16 epsP_h[], /* o : LP analysis residual energies for each iteration */
- Word16 epsP_l[], /* o : LP analysis residual energies for each iteration */
- Word16 isp_new[], /* o : current frame ISPs */
- Word16 isp_old[], /* i/o: previous frame unquantized ISPs */
- Word16 isf_new[], /* o : current frame ISPs */
- Word16 Top, /* i : open loop pitch lag */
- Word16 Tnc, /* i : open loop pitch gain */
+ const Word16 speech[], /* i : pointer to the speech frame Q_new*/
+ Word32 *ener, /* o : residual energy from Levinson-Durbin Q_r*/
+ Word16 A[], /* o : A(z) filter coefficients Q14*/
+ Word16 epsP_h[], /* o : LP analysis residual energies for each iteration Q_r*/
+ Word16 epsP_l[], /* o : LP analysis residual energies for each iteration Q_r*/
+ Word16 isp_new[], /* o : current frame ISPs Q15*/
+ Word16 isp_old[], /* i/o: previous frame unquantized ISPs Q15*/
+ Word16 isf_new[], /* o : current frame ISPs Q15*/
+ Word16 Top, /* i : open loop pitch lag Q0*/
+ Word16 Tnc, /* i : open loop pitch gain Qx*/
Word16 Q_new,
Word16 *Q_r );
void encod_amr_wb_fx(
Encoder_State *st, /* i/o: state structure */
- const Word16 speech[], /* i : i speech */
- const Word16 Aw[], /* i : weighted A(z) unquantized for subframes */
- const Word16 Aq[], /* i : 12k8 Lp coefficient */
- const Word16 *res, /* i : residual signal */
- Word16 *syn, /* i/o: core synthesis */
- Word16 *exc, /* i/o: current non-enhanced excitation */
- Word16 *exc2, /* i/o: current enhanced excitation */
- Word16 *pitch_buf, /* i/o: floating pitch values for each subframe */
- Word16 hf_gain_fx[NB_SUBFR], /* o : decoded HF gain */
- const Word16 *speech16k_fx, /* i : i speech @16kHz */
+ const Word16 speech[], /* i : i speech Q_new-1*/
+ const Word16 Aw[], /* i : weighted A(z) unquantized for subframes Q12*/
+ const Word16 Aq[], /* i : 12k8 Lp coefficient Q12*/
+ const Word16 *res, /* i : residual signal Q_new*/
+ Word16 *syn, /* i/o: core synthesis st->Q_syn*/
+ Word16 *exc, /* i/o: current non-enhanced excitation Q_new*/
+ Word16 *exc2, /* i/o: current enhanced excitation Q_new*/
+ Word16 *pitch_buf, /* i/o: floating pitch values for each subframe Q6*/
+ Word16 hf_gain_fx[NB_SUBFR], /* o : decoded HF gain Q0*/
+ const Word16 *speech16k_fx, /* i : i speech @16kHz Qx*/
Word16 shift,
Word16 Q_new );
void re8_cod_fx(
- Word16 x[], /* i : point in RE8 (8-dimensional integer vector) */
- Word16 *n, /* i : codebook number (*n is an integer defined in {0,2,3,4,..,n_max}) */
- UWord16 *I, /* o : index of c (pointer to unsigned 16-bit word) */
- Word16 k[] /* o : index of v (8-dimensional vector of binary indices) = Voronoi index */
+ Word16 x[], /* i : point in RE8 (8-dimensional integer vector) Q0*/
+ Word16 *n, /* i : codebook number (*n is an integer defined in {0,2,3,4,..,n_max}) Q0*/
+ UWord16 *I, /* o : index of c (pointer to unsigned 16-bit word) Q0*/
+ Word16 k[] /* o : index of v (8-dimensional vector of binary indices) = Voronoi index Q0*/
);
void TBEreset_enc_fx(
@@ -3513,20 +3613,20 @@ void acelp_core_switch_enc_ivas_fx(
Word16 Q_new );
void gain_enc_amr_wb_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const Word16 *xn, /* i : target vector */
- const Word16 Q_xn, /* i : xn and yy1 format Q0 */
- const Word16 *yy1, /* i : zero-memory filtered adaptive excitation */
- const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation */
- const Word16 *code, /* i : algebraic excitation */
- const Word32 core_brate, /* i : core bitrate */
- Word16 *gain_pit, /* i/o: pitch gain / Quantized pitch gain */
- Word32 *gain_code, /* o : quantized codebook gain */
- Word16 *gain_inov, /* o : gain of the innovation (used for normalization) */
- Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation */
- Word16 *g_coeff, /* i/o: correlations , -2,, -2 and 2 */
- const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) */
- Word16 *past_qua_en /* i/o: gain quantization memory (4 words) */
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ const Word16 *xn, /* i : target vector Q_xn*/
+ const Word16 Q_xn, /* i : xn and yy1 format */
+ const Word16 *yy1, /* i : zero-memory filtered adaptive excitation Q_xn*/
+ const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9*/
+ const Word16 *code, /* i : algebraic excitation Q9*/
+ const Word32 core_brate, /* i : core bitrate Q0*/
+ Word16 *gain_pit, /* i/o: pitch gain / Quantized pitch gain Q14*/
+ Word32 *gain_code, /* o : quantized codebook gain Q16*/
+ Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/
+ Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/
+ Word16 *g_coeff, /* i/o: correlations , -2,, -2 and 2 Qx*/
+ const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) Q0*/
+ Word16 *past_qua_en /* i/o: gain quantization memory (4 words) Q10*/
);
@@ -3549,59 +3649,59 @@ void hf_cod_fx(
void transf_cdbk_enc_fx(
Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word16 harm_flag_acelp, /* i : harmonic flag for higher rates ACELP */
- const Word16 i_subfr, /* i : subframe index */
- Word16 cn[], /* i/o: target vector in residual domain */
- Word16 exc[], /* i/o: pointer to excitation signal frame */
- const Word16 *p_Aq, /* i : 12k8 Lp coefficient */
- const Word16 Ap[], /* i : weighted LP filter coefficients */
- const Word16 h1[], /* i : weighted filter i response */
- Word16 xn[], /* i/o: target vector */
- Word16 xn2[], /* i/o: target vector for innovation search */
- Word16 y1[], /* i/o: zero-memory filtered adaptive excitation */
- const Word16 y2[], /* i : zero-memory filtered innovative excitation */
- const Word16 Es_pred, /* i : predicited scaled innovation energy */
- Word16 *gain_pit, /* i/o: adaptive excitation gain */
- const Word32 gain_code, /* i : innovative excitation gain */
- Word16 g_corr[], /* o : ACELP correlation values */
- const Word16 clip_gain, /* i : adaptive gain clipping flag */
- Word16 *gain_preQ, /* o : prequantizer excitation gain */
- Word16 code_preQ[], /* o : prequantizer excitation */
- Word16 *unbits, /* o : number of AVQ unused bits */
+ const Word16 harm_flag_acelp, /* i : harmonic flag for higher rates ACELP Q0*/
+ const Word16 i_subfr, /* i : subframe index Q0*/
+ Word16 cn[], /* i/o: target vector in residual domain Q_new*/
+ Word16 exc[], /* i/o: pointer to excitation signal frame Q_new*/
+ const Word16 *p_Aq, /* i : 12k8 Lp coefficient Q12*/
+ const Word16 Ap[], /* i : weighted LP filter coefficients Q12*/
+ const Word16 h1[], /* i : weighted filter input response Q15*/
+ Word16 xn[], /* i/o: target vector Q_new + shift -1*/
+ Word16 xn2[], /* i/o: target vector for innovation search Q_new + shift -1*/
+ Word16 y1[], /* i/o: zero-memory filtered adaptive excitation Q_new + shift -1*/
+ const Word16 y2[], /* i : zero-memory filtered innovative excitation Q9*/
+ const Word16 Es_pred, /* i : predicited scaled innovation energy Q8*/
+ Word16 *gain_pit, /* i/o: adaptive excitation gain Q14*/
+ const Word32 gain_code, /* i : innovative excitation gain Q16*/
+ Word16 g_corr[], /* o : ACELP correlation values Q15*/
+ const Word16 clip_gain, /* i : adaptive gain clipping flag Q0*/
+ Word16 *gain_preQ, /* o : prequantizer excitation gain Q2*/
+ Word16 code_preQ[], /* o : prequantizer excitation Q_AVQ_OUT_DEC*/
+ Word16 *unbits, /* o : number of AVQ unused bits Q0*/
const Word16 Q_new, /* i : Current frame scaling */
const Word16 shift /* i : shifting applied to y1, xn,... */
);
void transf_cdbk_enc_ivas_fx(
Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word16 harm_flag_acelp, /* i : harmonic flag for higher rates ACELP */
- const Word16 i_subfr, /* i : subframe index */
- Word16 cn[], /* i/o: target vector in residual domain */
- Word16 exc[], /* i/o: pointer to excitation signal frame */
- const Word16 *p_Aq, /* i : 12k8 Lp coefficient */
- const Word16 Ap[], /* i : weighted LP filter coefficients */
- const Word16 h1[], /* i : weighted filter input response */
- Word16 xn[], /* i/o: target vector */
- Word16 xn2[], /* i/o: target vector for innovation search */
- Word16 y1[], /* i/o: zero-memory filtered adaptive excitation */
- const Word16 y2[], /* i : zero-memory filtered innovative excitation */
- const Word16 Es_pred, /* i : predicited scaled innovation energy */
- Word16 *gain_pit, /* i/o: adaptive excitation gain */
- const Word32 gain_code, /* i : innovative excitation gain */
- Word16 g_corr[], /* o : ACELP correlation values */
- const Word16 clip_gain, /* i : adaptive gain clipping flag */
- Word16 *gain_preQ, /* o : prequantizer excitation gain */
- Word16 code_preQ[], /* o : prequantizer excitation */
- Word16 *unbits, /* o : number of AVQ unused bits */
+ const Word16 harm_flag_acelp, /* i : harmonic flag for higher rates ACELP Q0*/
+ const Word16 i_subfr, /* i : subframe index Q0*/
+ Word16 cn[], /* i/o: target vector in residual domain Q_new*/
+ Word16 exc[], /* i/o: pointer to excitation signal frame Q_new*/
+ const Word16 *p_Aq, /* i : 12k8 Lp coefficient Q12*/
+ const Word16 Ap[], /* i : weighted LP filter coefficients Q12*/
+ const Word16 h1[], /* i : weighted filter input response Q15*/
+ Word16 xn[], /* i/o: target vector Q_new + shift -1*/
+ Word16 xn2[], /* i/o: target vector for innovation search Q_new + shift -1*/
+ Word16 y1[], /* i/o: zero-memory filtered adaptive excitation Q_new + shift -1*/
+ const Word16 y2[], /* i : zero-memory filtered innovative excitation Q9*/
+ const Word16 Es_pred, /* i : predicited scaled innovation energy Q8*/
+ Word16 *gain_pit, /* i/o: adaptive excitation gain Q14*/
+ const Word32 gain_code, /* i : innovative excitation gain Q16*/
+ Word16 g_corr[], /* o : ACELP correlation values Q15*/
+ const Word16 clip_gain, /* i : adaptive gain clipping flag Q0*/
+ Word16 *gain_preQ, /* o : prequantizer excitation gain Q2*/
+ Word16 code_preQ[], /* o : prequantizer excitation Q_AVQ_OUT_DEC*/
+ Word16 *unbits, /* o : number of AVQ unused bits Q0*/
const Word16 Q_new, /* i : Current frame scaling */
const Word16 shift /* i : shifting applied to y1, xn,... */
);
void gain_enc_lbr_fx(
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const Word16 gains_mode[], /* i : gain bits */
- const Word16 coder_type, /* i : coding type */
- const Word16 i_subfr, /* i : subframe index */
+ const Word16 gains_mode[], /* i : gain bits Q0*/
+ const Word16 coder_type, /* i : coding type Q0*/
+ const Word16 i_subfr, /* i : subframe index Q0*/
const Word16 *xn, /* i : target vector Q_xn*/
const Word16 *y1, /* i : zero-memory filtered adaptive excitation Q_xn*/
const Word16 Q_xn, /* i : xn and y1 format */
@@ -3612,17 +3712,17 @@ void gain_enc_lbr_fx(
Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/
Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/
Word16 *g_corr, /* i/o: correlations , -2,, -2 and 2 mant/exp*/
- Word32 gc_mem[], /* i/o: gain_code from previous subframes */
- Word16 gp_mem[], /* i/o: gain_pitch from previous subframes */
- const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) */
- const Word16 L_subfr /* i : subframe length */
+ Word32 gc_mem[], /* i/o: gain_code from previous subframes Q16*/
+ Word16 gp_mem[], /* i/o: gain_pitch from previous subframes Q14*/
+ const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) Q0*/
+ const Word16 L_subfr /* i : subframe length Q0*/
);
void gain_enc_lbr_ivas_fx(
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const Word16 gains_mode[], /* i : gain bits */
- const Word16 coder_type, /* i : coding type */
- const Word16 i_subfr, /* i : subframe index */
+ const Word16 gains_mode[], /* i : gain bits Q0*/
+ const Word16 coder_type, /* i : coding type Q0*/
+ const Word16 i_subfr, /* i : subframe index Q0*/
const Word16 *xn, /* i : target vector Q_xn*/
const Word16 *y1, /* i : zero-memory filtered adaptive excitation Q_xn*/
const Word16 Q_xn, /* i : xn and y1 format */
@@ -3633,46 +3733,46 @@ void gain_enc_lbr_ivas_fx(
Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/
Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/
Word16 *g_corr, /* i/o: correlations , -2,, -2 and 2 mant/exp*/
- Word32 gc_mem[], /* i/o: gain_code from previous subframes */
- Word16 gp_mem[], /* i/o: gain_pitch from previous subframes */
- const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) */
- const int16_t L_subfr /* i : subframe length */
+ Word32 gc_mem[], /* i/o: gain_code from previous subframes Q16*/
+ Word16 gp_mem[], /* i/o: gain_pitch from previous subframes Q14*/
+ const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) Q0*/
+ const Word16 L_subfr /* i : subframe length Q0*/
);
void gain_enc_SQ_fx(
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const Word16 gains_mode[], /* i : gain bits */
- const Word16 i_subfr, /* i : subframe index */
- const Word16 *xn, /* i : target vector Q_xn */
- const Word16 *yy1, /* i : zero-memory filtered adaptive excitation Q_xn */
- const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9 */
- const Word16 *code, /* i : algebraic excitation Q9 */
- const Word16 Es_pred, /* i : predicted scaled innovation energy Q8 */
- Word16 *gain_pit, /* o : quantized pitch gain Q14 */
- Word32 *gain_code, /* o : quantized codebook gain Q16 */
- Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12 */
- Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16 */
- Word16 *g_corr, /* i/o: correlations , ,, -2 and 2 */
- const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) */
- const Word16 Q_xn /* i : xn and y1 scaling */
+ const Word16 gains_mode[], /* i : gain bits Q0*/
+ const Word16 i_subfr, /* i : subframe index Q0*/
+ const Word16 *xn, /* i : target vector Q_xn*/
+ const Word16 *yy1, /* i : zero-memory filtered adaptive excitation Q_xn*/
+ const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9*/
+ const Word16 *code, /* i : algebraic excitation Q9*/
+ const Word16 Es_pred, /* i : predicted scaled innovation energy Q8*/
+ Word16 *gain_pit, /* o : quantized pitch gain Q14*/
+ Word32 *gain_code, /* o : quantized codebook gain Q16*/
+ Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/
+ Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/
+ Word16 *g_corr, /* i/o: correlations , ,, -2 and 2 Qx*/
+ const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) Q0*/
+ const Word16 Q_xn /* i : xn and y1 scaling */
);
void gain_enc_SQ_ivas_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const Word16 gains_mode[], /* i : gain bits */
- const Word16 i_subfr, /* i : subframe index */
- const Word16 *xn, /* i : target vector Q_xn */
- const Word16 *yy1, /* i : zero-memory filtered adaptive excitation Q_xn */
- const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9 */
- const Word16 *code, /* i : algebraic excitation Q9 */
- const Word16 Es_pred, /* i : predicted scaled innovation energy Q8 */
- Word16 *gain_pit, /* o : quantized pitch gain Q14 */
- Word32 *gain_code, /* o : quantized codebook gain Q16 */
- Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12 */
- Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16 */
- Word16 *g_corr, /* i/o: correlations , ,, -2 and 2 */
- const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) */
- const Word16 Q_xn /* i : xn and y1 scaling */
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ const Word16 gains_mode[], /* i : gain bits Q0*/
+ const Word16 i_subfr, /* i : subframe index Q0*/
+ const Word16 *xn, /* i : target vector Q_xn*/
+ const Word16 *yy1, /* i : zero-memory filtered adaptive excitation Q_xn*/
+ const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9*/
+ const Word16 *code, /* i : algebraic excitation Q9*/
+ const Word16 Es_pred, /* i : predicted scaled innovation energy Q8*/
+ Word16 *gain_pit, /* o : quantized pitch gain Q14*/
+ Word32 *gain_code, /* o : quantized codebook gain Q16*/
+ Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/
+ Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/
+ Word16 *g_corr, /* i/o: correlations , ,, -2 and 2 Qx*/
+ const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) Q0*/
+ const Word16 Q_xn /* i : xn and y1 scaling */
);
void updt_tar_fx(
@@ -3691,11 +3791,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*/
@@ -3775,98 +3871,74 @@ void transition_enc_ivas_fx(
);
-void transf_cdbk_enc_fx(
- Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word16 harm_flag_acelp, /* i : harmonic flag for higher rates ACELP */
- const Word16 i_subfr, /* i : subframe index */
- Word16 cn[], /* i/o: target vector in residual domain */
- Word16 exc[], /* i/o: pointer to excitation signal frame */
- const Word16 *p_Aq, /* i : 12k8 Lp coefficient */
- const Word16 Ap[], /* i : weighted LP filter coefficients */
- const Word16 h1[], /* i : weighted filter i response */
- Word16 xn[], /* i/o: target vector */
- Word16 xn2[], /* i/o: target vector for innovation search */
- Word16 y1[], /* i/o: zero-memory filtered adaptive excitation */
- const Word16 y2[], /* i : zero-memory filtered innovative excitation */
- const Word16 Es_pred, /* i : predicited scaled innovation energy */
- Word16 *gain_pit, /* i/o: adaptive excitation gain */
- const Word32 gain_code, /* i : innovative excitation gain */
- Word16 g_corr[], /* o : ACELP correlation values */
- const Word16 clip_gain, /* i : adaptive gain clipping flag */
- Word16 *gain_preQ, /* o : prequantizer excitation gain */
- Word16 code_preQ[], /* o : prequantizer excitation */
- Word16 *unbits, /* o : number of AVQ unused bits */
- const Word16 Q_new, /* i : Current frame scaling */
- const Word16 shift /* i : shifting applied to y1, xn,... */
-);
void gain_enc_tc_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const Word16 gains_mode[], /* i : gain bits */
- const Word16 i_subfr, /* i : subframe index */
- const Word16 xn_fx[], /* i : target vector */
- const Word16 y2_fx[], /* i : zero-memory filtered algebraic codebook excitation */
- const Word16 code_fx[], /* i : algebraic excitation */
- const Word16 Es_pred_fx, /* i : predicted scaled innovation energy */
- Word16 *gain_pit_fx, /* o : Pitch gain / Quantized pitch gain */
- Word32 *gain_code_fx, /* o : quantized codebook gain */
- Word16 *gain_inov_fx, /* o : innovation gain */
- Word32 *norm_gain_code_fx, /* o : norm. gain of the codebook excitation */
- const Word16 Q_xn /* i : xn and y1 scaling Q0 */
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ const Word16 gains_mode[], /* i : gain bits Q0*/
+ const Word16 i_subfr, /* i : subframe index Q0*/
+ const Word16 xn_fx[], /* i : target vector Q_xn*/
+ const Word16 y2_fx[], /* i : zero-memory filtered algebraic codebook excitation Q_xn*/
+ const Word16 code_fx[], /* i : algebraic excitation Q9*/
+ const Word16 Es_pred_fx, /* i : predicted scaled innovation energy Q8*/
+ Word16 *gain_pit_fx, /* o : Pitch gain / Quantized pitch gain Q14*/
+ Word32 *gain_code_fx, /* o : quantized codebook gain Q16*/
+ Word16 *gain_inov_fx, /* o : innovation gain Q12*/
+ Word32 *norm_gain_code_fx, /* o : norm. gain of the codebook excitation Q16*/
+ const Word16 Q_xn /* i : xn and y1 scaling */
);
void gain_enc_tc_ivas_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const Word16 gains_mode[], /* i : gain bits */
- const Word16 i_subfr, /* i : subframe index */
- const Word16 xn_fx[], /* i : target vector */
- const Word16 y2_fx[], /* i : zero-memory filtered algebraic codebook excitation */
- const Word16 code_fx[], /* i : algebraic excitation */
- const Word16 Es_pred_fx, /* i : predicted scaled innovation energy */
- Word16 *gain_pit_fx, /* o : Pitch gain / Quantized pitch gain */
- Word32 *gain_code_fx, /* o : quantized codebook gain */
- Word16 *gain_inov_fx, /* o : innovation gain */
- Word32 *norm_gain_code_fx, /* o : norm. gain of the codebook excitation */
- const Word16 Q_xn /* i : xn and y1 scaling Q0 */
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ const Word16 gains_mode[], /* i : gain bits Q0*/
+ const Word16 i_subfr, /* i : subframe index Q0*/
+ const Word16 xn_fx[], /* i : target vector Q_xn*/
+ const Word16 y2_fx[], /* i : zero-memory filtered algebraic codebook excitation Q_xn*/
+ const Word16 code_fx[], /* i : algebraic excitation Q9*/
+ const Word16 Es_pred_fx, /* i : predicted scaled innovation energy Q8*/
+ Word16 *gain_pit_fx, /* o : Pitch gain / Quantized pitch gain Q14*/
+ Word32 *gain_code_fx, /* o : quantized codebook gain Q16*/
+ Word16 *gain_inov_fx, /* o : innovation gain Q12*/
+ Word32 *norm_gain_code_fx, /* o : norm. gain of the codebook excitation Q6*/
+ const Word16 Q_xn /* i : xn and y1 scaling */
);
Word16 gaus_encode_fx(
Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word16 i_subfr, /* i : subframe index */
- const Word16 *h1, /* i : weighted filter i response */
- const Word16 *xn, /* i : target vector */
- Word16 *exc, /* o : pointer to excitation signal frame */
- Word16 *mem_w0, /* o : weighting filter denominator memory */
- Word16 *clip_gain, /* o : memory of gain of pitch clipping algorithm */
- Word16 *tilt_code, /* o : synthesis excitation spectrum tilt */
- Word16 *code, /* o : algebraic excitation Q9 */
- Word32 *gain_code, /* o : Code gain. Q16 */
- Word16 *y2, /* o : zero-memory filtered adaptive excitation Q9 */
- Word16 *gain_inov, /* o : innovation gain Q12 */
- Word16 *voice_fac, /* o : voicing factor Q15 */
- Word16 *gain_pit, /* o : adaptive excitation gain Q14 */
- const Word16 Q_new, /* i : scaling factor */
- const Word16 shift, /* i : scaling factor */
- Word32 *norm_gain_code /* o : normalized innovative cb. gain Q16 */
+ const Word16 i_subfr, /* i : subframe index Q0*/
+ const Word16 *h1, /* i : weighted filter input response Q14*/
+ const Word16 *xn, /* i : target vector Q12*/
+ Word16 *exc, /* o : pointer to excitation signal frame Q_new*/
+ Word16 *mem_w0, /* o : weighting filter denominator memory Q_new*/
+ Word16 *clip_gain, /* o : memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/
+ Word16 *tilt_code, /* o : synthesis excitation spectrum tilt Q15*/
+ Word16 *code, /* o : algebraic excitation Q9*/
+ Word32 *gain_code, /* o : Code gain. Q16*/
+ Word16 *y2, /* o : zero-memory filtered adaptive excitation Q9*/
+ Word16 *gain_inov, /* o : innovation gain Q12*/
+ Word16 *voice_fac, /* o : voicing factor Q15*/
+ Word16 *gain_pit, /* o : adaptive excitation gain Q14*/
+ const Word16 Q_new, /* i : scaling factor */
+ const Word16 shift, /* i : scaling factor */
+ Word32 *norm_gain_code /* o : normalized innovative cb. gain Q16*/
);
Word16 gaus_encode_ivas_fx(
Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word16 i_subfr, /* i : subframe index */
- const Word16 *h1, /* i : weighted filter input response */
- const Word16 *xn, /* i : target vector */
- Word16 *exc, /* o : pointer to excitation signal frame */
- Word16 *mem_w0, /* o : weighting filter denominator memory */
- Word16 *clip_gain, /* o : memory of gain of pitch clipping algorithm */
- Word16 *tilt_code, /* o : synthesis excitation spectrum tilt */
- Word16 *code, /* o : algebraic excitation Q9 */
- Word32 *gain_code, /* o : Code gain. Q16 */
- Word16 *y2, /* o : zero-memory filtered adaptive excitation Q9 */
- Word16 *gain_inov, /* o : innovation gain Q12 */
- Word16 *voice_fac, /* o : voicing factor Q15 */
- Word16 *gain_pit, /* o : adaptive excitation gain Q14 */
- const Word16 Q_new, /* i : scaling factor */
- const Word16 shift, /* i : scaling factor */
- Word32 *norm_gain_code /* o : normalized innovative cb. gain Q16 */
+ const Word16 i_subfr, /* i : subframe index Q0*/
+ const Word16 *h1, /* i : weighted filter input response Q14*/
+ const Word16 *xn, /* i : target vector Q12*/
+ Word16 *exc, /* o : pointer to excitation signal frame Q_new*/
+ Word16 *mem_w0, /* o : weighting filter denominator memory Q_new*/
+ Word16 *clip_gain, /* o : memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/
+ Word16 *tilt_code, /* o : synthesis excitation spectrum tilt Q15*/
+ Word16 *code, /* o : algebraic excitation Q9*/
+ Word32 *gain_code, /* o : Code gain. Q16*/
+ Word16 *y2, /* o : zero-memory filtered adaptive excitation Q9*/
+ Word16 *gain_inov, /* o : innovation gain Q12*/
+ Word16 *voice_fac, /* o : voicing factor Q15*/
+ Word16 *gain_pit, /* o : adaptive excitation gain Q14*/
+ const Word16 Q_new, /* i : scaling factor */
+ const Word16 shift, /* i : scaling factor */
+ Word32 *norm_gain_code /* o : normalized innovative cb. gain Q16*/
);
void pre_proc_fx(
@@ -3910,68 +3982,68 @@ void swb_bwe_enc_hr_fx(
);
Word16 gain_enc_gaus_fx( /* o : Return index of quantization */
- Word32 *gain, /* i/o: Code gain to quantize */
- const Word16 bits, /* i : number of bits to quantize */
- const Word16 lowBound, /* i : lower bound of quantizer (dB) Q8 */
- const Word16 stepSize, /* i : Step size choice Q14 */
- const Word16 inv_stepSize /* i : Step size choice Q15 */
+ Word32 *gain, /* i/o: Code gain to quantize Q16*/
+ const Word16 bits, /* i : number of bits to quantize Q0*/
+ const Word16 lowBound, /* i : lower bound of quantizer (dB) Q8*/
+ const Word16 stepSize, /* i : Step size choice Q14*/
+ const Word16 inv_stepSize /* i : Step size choice Q15*/
);
void enc_pit_exc_fx(
Encoder_State *st_fx, /* i/o: State structure */
- const Word16 *speech, /* i : Input speech */
- const Word16 Aw[], /* i : weighted A(z) unquantized for subframes */
- const Word16 Aq[], /* i : 12k8 Lp coefficient */
- const Word16 Es_pred, /* i : predicted scaled innov. energy */
- const Word16 *res, /* i : residual signal */
- Word16 *synth, /* i/o: core synthesis */
- Word16 *exc, /* i/o: current non-enhanced excitation */
- Word16 *T0, /* i/o: close loop integer pitch */
- Word16 *T0_frac, /* i/o: close-loop pitch period - fractional part */
- Word16 *pitch_buf, /* i/o: Fractionnal per subframe pitch */
- const Word16 nb_subfr, /* i : Number of subframe considered */
- Word16 *gpit, /* o : pitch mean gpit */
- Word16 *saved_bit_pos, /* o : saved position in the bitstream before pitch contribution */
- const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
- const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer */
+ const Word16 *speech, /* i : Input speech Q_new-1*/
+ const Word16 Aw[], /* i : weighted A(z) unquantized for subframes Q12*/
+ const Word16 Aq[], /* i : 12k8 Lp coefficient Q12*/
+ const Word16 Es_pred, /* i : predicted scaled innov. energy Q8*/
+ const Word16 *res, /* i : residual signal Q_new*/
+ Word16 *synth, /* i/o: core synthesis Q_new*/
+ Word16 *exc, /* i/o: current non-enhanced excitation Q_new*/
+ Word16 *T0, /* i/o: close loop integer pitch Q0*/
+ Word16 *T0_frac, /* i/o: close-loop pitch period - fractional part Q0*/
+ Word16 *pitch_buf, /* i/o: Fractionnal per subframe pitch Q6*/
+ const Word16 nb_subfr, /* i : Number of subframe considered Q0*/
+ Word16 *gpit, /* o : pitch mean gpit Q15*/
+ Word16 *saved_bit_pos, /* o : saved position in the bitstream before pitch contribution Q0*/
+ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/
+ const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/
Word16 Q_new,
Word16 shift );
void enc_pit_exc_ivas_fx(
Encoder_State *st_fx, /* i/o: State structure */
- const Word16 *speech, /* i : Input speech */
- const Word16 Aw[], /* i : weighted A(z) unquantized for subframes */
- const Word16 Aq[], /* i : 12k8 Lp coefficient */
- const Word16 Es_pred, /* i : predicted scaled innov. energy */
- const Word16 *res, /* i : residual signal */
- Word16 *synth, /* i/o: core synthesis */
- Word16 *exc, /* i/o: current non-enhanced excitation */
- Word16 *T0, /* i/o: close loop integer pitch */
- Word16 *T0_frac, /* i/o: close-loop pitch period - fractional part */
- Word16 *pitch_buf, /* i/o: Fractionnal per subframe pitch */
- const Word16 nb_subfr, /* i : Number of subframe considered */
- Word16 *gpit, /* o : pitch mean gpit */
- Word16 *saved_bit_pos, /* o : saved position in the bitstream before pitch contribution */
- const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
- const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer */
+ const Word16 *speech, /* i : Input speech Q_new-1*/
+ const Word16 Aw[], /* i : weighted A(z) unquantized for subframes Q12*/
+ const Word16 Aq[], /* i : 12k8 Lp coefficient Q12*/
+ const Word16 Es_pred, /* i : predicted scaled innov. energy Q8*/
+ const Word16 *res, /* i : residual signal Q_new*/
+ Word16 *synth, /* i/o: core synthesis Q_new*/
+ Word16 *exc, /* i/o: current non-enhanced excitation Q_new*/
+ Word16 *T0, /* i/o: close loop integer pitch Q0*/
+ Word16 *T0_frac, /* i/o: close-loop pitch period - fractional part Q0*/
+ Word16 *pitch_buf, /* i/o: Fractionnal per subframe pitch Q6*/
+ const Word16 nb_subfr, /* i : Number of subframe considered Q0*/
+ Word16 *gpit, /* o : pitch mean gpit Q15*/
+ Word16 *saved_bit_pos, /* o : saved position in the bitstream before pitch contribution Q0*/
+ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/
+ const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/
Word16 Q_new,
Word16 shift );
Word16 Pit_exc_contribution_len_fx( /* o : bin where pitch contribution is significant */
Encoder_State *st_fx, /* i/o: state structure */
- const Word16 *dct_res, /* i : DCT of residual */
- Word16 *dct_pitex, /* i/o: DCT of pitch contribution */
- Word16 *pitch_buf, /* i/o: Pitch per subframe */
- const Word16 nb_subfr, /* i : Number of subframe considered */
- Word16 *hangover, /* i : hangover for the time contribution switching */
+ const Word16 *dct_res, /* i : DCT of residual Qnew*/
+ Word16 *dct_pitex, /* i/o: DCT of pitch contribution Qnew*/
+ Word16 *pitch_buf, /* i/o: Pitch per subframe Q6*/
+ const Word16 nb_subfr, /* i : Number of subframe considered Q0*/
+ Word16 *hangover, /* i : hangover for the time contribution switching Q0*/
Word16 Qnew );
Word16 Pit_exc_contribution_len_ivas_fx( /* o : bin where pitch contribution is significant */
Encoder_State *st_fx, /* i/o: state structure */
- const Word16 *dct_res, /* i : DCT of residual */
- Word16 *dct_pitex, /* i/o: DCT of pitch contribution */
- Word16 *pitch_buf, /* i/o: Pitch per subframe */
- const Word16 nb_subfr, /* i : Number of subframe considered */
- Word16 *hangover, /* i : hangover for the time contribution switching */
+ const Word16 *dct_res, /* i : DCT of residual Qnew*/
+ Word16 *dct_pitex, /* i/o: DCT of pitch contribution Qnew*/
+ Word16 *pitch_buf, /* i/o: Pitch per subframe Q6*/
+ const Word16 nb_subfr, /* i : Number of subframe considered Q0*/
+ Word16 *hangover, /* i : hangover for the time contribution switching Q0*/
Word16 Qnew );
Word16 pvq_core_enc_fx(
@@ -4036,7 +4108,7 @@ void hq_hr_enc_fx(
const Word16 length, /* i : length of spectrum Q0 */
Word16 *num_bits, /* i : number of available bits Q0 */
const Word16 is_transient, /* i : transient flag Q0 */
- const Word16 vad_hover_flag /* i : VAD hangover flag */
+ const Word16 vad_hover_flag /* i : VAD hangover flag Q0 */
);
void hq_hr_enc_ivas_fx(
@@ -4045,7 +4117,7 @@ void hq_hr_enc_ivas_fx(
const Word16 length, /* i : length of spectrum Q0 */
Word16 *num_bits, /* i : number of available bits Q0 */
const Word16 is_transient, /* i : transient flag Q0 */
- const Word16 vad_hover_flag /* i : VAD hangover flag */
+ const Word16 vad_hover_flag /* i : VAD hangover flag Q0 */
);
void reordernorm_fx(
@@ -4094,7 +4166,7 @@ void diff_envelope_coding_fx(
);
Word16 encode_envelope_indices_ivas_fx( /* o : Number of bits if flag_pack=0,0 if flag_pack=1 Q0 */
- BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream */
+ BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream Q0 */
const Word16 num_sfm, /* i : Number of subbands Q0 */
const Word16 numnrmibits, /* i : Bitrate of fall-back coding mode Q0 */
Word16 *difidx, /* i/o: Diff indices/encoded diff indices Q0 */
@@ -4217,7 +4289,7 @@ ivas_error tcq_core_LR_enc_ivas_fx(
const Word16 is_transient );
Word16 encode_envelope_indices_fx( /* o : Number of bits if flag_pack=0,0 if flag_pack=1 Q0 */
- BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream */
+ BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream Q0 */
const Word16 num_sfm, /* i : Number of subbands Q0 */
const Word16 numnrmibits, /* i : Bitrate of fall-back coding mode Q0 */
Word16 *difidx, /* i/o: Diff indices/encoded diff indices Q0 */
@@ -4288,7 +4360,7 @@ void InitSWBencBuffer_ivas_fx(
void ResetSHBbuffer_Enc_fx(
Encoder_State *st_fx /* i/o: SHB encoder structure */
);
-Word16 E_ACELP_hh_corr( Word16 *x, Word16 *y, Word16 L_subfr, Word16 bits );
+Word16 E_ACELP_hh_corr( Word16 *x /*Q11*/, Word16 *y /*Qy*/, Word16 L_subfr /*Q0*/, Word16 bits /*Q0*/ );
void acelp_1t64_fx(
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
@@ -4353,10 +4425,10 @@ Word16 acelp_4t64_ivas_fx(
Word16 element_mode );
ivas_error evs_enc_fx(
- Encoder_State *st, /* i/o: encoder state structure */
- const Word16 *data, /* i : i signal */
- Word32 *mem_hp20_in_fx, /* i/o: hp20 filter memory */
- const Word16 n_samples /* i : number of i samples */
+ Encoder_State *st, /* i/o: encoder state structure */
+ const Word16 *data, /* i : input signal Q0*/
+ Word32 *mem_hp20_in_fx, /* i/o: hp20 filter memory Qx*/
+ const Word16 n_samples /* i : number of input samples Q0*/
);
/* y(n)(Qx) = alpha(Q15) * x(Qx) + (1.0f-alpha)* y(n-1) (Qx) */
@@ -4366,8 +4438,8 @@ Word16 noise_est_AR1_Qx( /* o: Qx y(n) */
Word16 alpha /*i : Q15 scaling of driving x(n) */
);
void FEC_lsf_estim_enc_fx(
- Encoder_State *st_fx, /* i : Encoder static memory */
- Word16 *lsf /* o : estimated LSF vector */
+ Encoder_State *st_fx, /* i : Encoder static memory */
+ Word16 *lsf /* o : estimated LSF vector Qlog2(2.56)*/
);
Word32 mslvq_cng_fx(
@@ -4391,14 +4463,14 @@ Word32 mslvq_cng_ivas_fx(
);
void Unified_weighting_fx(
- const Word32 Bin_Ener_128_fx[], /* i : FFT Bin energy 128 bins in two sets Q_ener */
+ const Word32 Bin_Ener_128_fx[], /* i : FFT Bin energy 128 bins in two sets Q_ener */
Word16 Q_ener,
- const Word16 lsf_fx[], /* i : LSF vector x2.56 */
- Word16 w_fx[], /* o : LP weighting filter (numerator) Q8 */
- const Word16 narrowBand, /* i : flag for Narrowband */
- const Word16 unvoiced, /* i : flag for Unvoiced frame */
- const Word32 sr_core, /* i : sampling rate of core-coder */
- const Word16 order /* i : LP order */
+ const Word16 lsf_fx[], /* i : LSF vector x2.56 */
+ Word16 w_fx[], /* o : LP weighting filter (numerator) Q8 */
+ const Word16 narrowBand, /* i : flag for Narrowband Q0*/
+ const Word16 unvoiced, /* i : flag for Unvoiced frame Q0*/
+ const Word32 sr_core, /* i : sampling rate of core-coder Q0*/
+ const Word16 order /* i : LP order Q0*/
);
Word32 qlsf_ARSN_tcvq_Enc_16k_fx(
@@ -4527,7 +4599,7 @@ void pvq_encode_ivas_fx(
);
void rc_enc_init_fx(
PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */
- Word16 tot_bits /* i : Total bit budget */
+ Word16 tot_bits /* i : Total bit budget Q0*/
);
void rc_enc_finish_fx(
@@ -4540,43 +4612,43 @@ void rc_enc_finish_ivas_fx(
);
void rc_encode_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */
- UWord32 cum_freq, /* i : Cumulative frequency up to symbol */
- UWord32 sym_freq, /* i : Symbol probability */
- UWord32 tot /* i : Total cumulative frequency */
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */
+ UWord32 cum_freq, /* i : Cumulative frequency up to symbol Q0*/
+ UWord32 sym_freq, /* i : Symbol probability Q0*/
+ UWord32 tot /* i : Total cumulative frequency Q0*/
);
void rc_encode_ivas_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */
- UWord32 cum_freq, /* i : Cumulative frequency up to symbol */
- UWord32 sym_freq, /* i : Symbol probability */
- UWord32 tot /* i : Total cumulative frequency */
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */
+ UWord32 cum_freq, /* i : Cumulative frequency up to symbol Q0*/
+ UWord32 sym_freq, /* i : Symbol probability Q0*/
+ UWord32 tot /* i : Total cumulative frequency Q0*/
);
void rc_enc_uniform_ivas_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */
- UWord32 value, /* i : Value to encode */
- UWord32 tot /* i : Maximum value */
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */
+ UWord32 value, /* i : Value to encode Q0*/
+ UWord32 tot /* i : Maximum value Q0*/
);
void rc_enc_uniform_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */
- UWord32 value, /* i : Value to encode */
- UWord32 tot /* i : Maximum value */
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */
+ UWord32 value, /* i : Value to encode Q0*/
+ UWord32 tot /* i : Maximum value Q0*/
);
void rc_enc_bits_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */
- UWord32 value, /* i : Value to encode */
- Word16 bits /* i : Number of bits used */
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */
+ UWord32 value, /* i : Value to encode Q0*/
+ Word16 bits /* i : Number of bits used Q0*/
);
void rc_enc_bits_ivas_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */
- UWord32 value, /* i : Value to encode */
- Word16 bits /* i : Number of bits used */
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */
+ UWord32 value, /* i : Value to encode Q0*/
+ Word16 bits /* i : Number of bits used Q0*/
);
void re8_compute_base_index_fx(
const Word16 *x, /* i : Elemen of Q2, Q3 or Q4 */
@@ -4596,14 +4668,14 @@ Word16 delta_pit_enc_fx( /* o : pitch index
);
void set_impulse_fx(
- const Word16 xn_fx[], /* i : target signal */
- const Word16 h_orig_fx[], /* i : impulse response of weighted synthesis filter */
- Word16 exc_fx[], /* o : adaptive codebook excitation */
- Word16 yy1_fx[], /* o : filtered adaptive codebook excitation */
- Word16 *imp_shape, /* o : adaptive codebook index */
- Word16 *imp_pos, /* o : position of the glotal impulse center index */
- Word32 *gain_trans_fx, /* o : transition gain Q7 */
- Word16 Q_new /* i : Current scaling */
+ const Word16 xn_fx[], /* i : target signal Q_new-1+shift*/
+ const Word16 h_orig_fx[], /* i : impulse response of weighted synthesis filter Q(14+shift)*/
+ Word16 exc_fx[], /* o : adaptive codebook excitation Q_new*/
+ Word16 yy1_fx[], /* o : filtered adaptive codebook excitation Q_new*/
+ Word16 *imp_shape, /* o : adaptive codebook index Q0*/
+ Word16 *imp_pos, /* o : position of the glottal impulse center index Q0*/
+ Word32 *gain_trans_fx, /* o : transition gain Q7*/
+ Word16 Q_new /* i : Current scaling */
);
Word16 abs_pit_enc_fx( /* o : pitch index */
@@ -4652,9 +4724,9 @@ ivas_error init_encoder_fx(
);
void copy_encoder_config_fx(
- Encoder_Struct *st_ivas, /* i : IVAS encoder structure */
- Encoder_State *st, /* o : encoder state structure */
- const Word16 flag_all /* i : flag 1==update all, 0=partial update*/
+ Encoder_Struct *st_ivas, /* i : IVAS encoder structure */
+ Encoder_State *st, /* o : encoder state structure */
+ const Word16 flag_all /* i : flag 1==update all, 0=partial update Q0*/
);
void destroy_encoder_fx(
@@ -4663,8 +4735,8 @@ void destroy_encoder_fx(
void amr_wb_enc_fx(
Encoder_State *st, /* i/o: encoder state structure */
- const Word16 input_sp[], /* i : i signal */
- const Word16 n_samples /* i : number of i samples */
+ const Word16 input_sp[], /* i : i signal Q0*/
+ const Word16 n_samples /* i : number of i samples Q0*/
);
void writeLPCparam_fx(
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_avq_fx.c b/lib_enc/qlpc_avq_fx.c
index b3b126876ce5b858466290261984f152bbd4325e..13e0a3cf7e196cb86b31882c04a719a52bd8d1f0 100644
--- a/lib_enc/qlpc_avq_fx.c
+++ b/lib_enc/qlpc_avq_fx.c
@@ -23,11 +23,11 @@ void qlpc_avq_fx(
const Word16 *lsfmid, /* i : Input LSF vectors (14Q1*1.28) */
Word16 *lsf_q, /* o : Quantized LFS vectors (14Q1*1.28) */
Word16 *lsfmid_q, /* o : Quantized LFS vectors (14Q1*1.28) */
- Word16 *index, /* o : Quantization indices */
- Word16 *nb_indices, /* o : Number of quantization indices */
- Word16 *nbbits, /* o : Number of quantization bits */
- const Word16 core, /* i : TCX10 or TCX20 */
- const Word32 sr_core /* i : internal sampling rate */
+ Word16 *index, /* o : Quantization indices Q0 */
+ Word16 *nb_indices, /* o : Number of quantization indices Q0 */
+ Word16 *nbbits, /* o : Number of quantization bits Q0 */
+ const Word16 core, /* i : TCX10 or TCX20 Q0 */
+ const Word32 sr_core /* i : internal sampling rate Q0 */
)
{
Word16 i;
@@ -37,25 +37,25 @@ void qlpc_avq_fx(
/* Init */
- tmp_index = &index[0];
+ tmp_index = &index[0]; // Q0
*nb_indices = 0;
move16();
- tmp_index[0] = vlpc_1st_cod_fx( lsf, lsf_q, dummy, 0 );
+ tmp_index[0] = vlpc_1st_cod_fx( lsf, lsf_q, dummy, 0 ); // Q0
- nbt = vlpc_2st_cod_fx( lsf, lsf_q, &tmp_index[1], 0, sr_core );
+ nbt = vlpc_2st_cod_fx( lsf, lsf_q, &tmp_index[1], 0, sr_core ); // Q0
/*nit = 1 + 2 + index[1] + index[2]; nit < NPRM_LPC_NEW(=50) */
- nit = add( add( 3, index[1] ), index[2] );
+ nit = add( add( 3, index[1] ), index[2] ); // Q0
assert( nit < NPRM_LPC_NEW );
/*tmp_index += nit;*/
tmp_index = tmp_index + nit;
/**nb_indices += nit;*/
- *nb_indices = add( *nb_indices, nit );
+ *nb_indices = add( *nb_indices, nit ); // Q0
move16();
/*nbbits[0] = 8 + nbt;*/
- nbbits[0] = add( 8, nbt );
+ nbbits[0] = add( 8, nbt ); // Q0
move16();
*tmp_index = 0;
@@ -70,51 +70,51 @@ void qlpc_avq_fx(
/* Quantize intermediate LPC (512 framing) */
tmp_index++;
/**nb_indices +=1;*/
- *nb_indices = add( *nb_indices, 1 );
+ *nb_indices = add( *nb_indices, 1 ); // Q0
move16();
/* LPC2: Abs? */
- tmp_index[0] = vlpc_1st_cod_fx( lsfmid, lsfmid_q, dummy, 0 );
+ tmp_index[0] = vlpc_1st_cod_fx( lsfmid, lsfmid_q, dummy, 0 ); // Q0
- nbits = vlpc_2st_cod_fx( lsfmid, lsfmid_q, &tmp_index[1], 0, sr_core );
+ nbits = vlpc_2st_cod_fx( lsfmid, lsfmid_q, &tmp_index[1], 0, sr_core ); // Q0
/*nbt = 8 + nbits;*/
nbt = add( 8, nbits );
/*nit = 1 + 2 + tmp_index[1] + tmp_index[2];*/
- nit = add( add( 3, tmp_index[1] ), tmp_index[2] );
+ nit = add( add( 3, tmp_index[1] ), tmp_index[2] ); // Q0
/* LPC2: RelR? */
FOR( i = 0; i < M; i++ )
{
- lsfmid_q0[i] = lsf_q[i];
+ lsfmid_q0[i] = lsf_q[i]; /* 14Q1*1.28 */
move16();
}
- nbits = vlpc_2st_cod_fx( lsfmid, lsfmid_q0, indxt, 3, sr_core );
+ nbits = vlpc_2st_cod_fx( lsfmid, lsfmid_q0, indxt, 3, sr_core ); // Q0
IF( LT_16( nbits, nbt ) )
{
- nbt = nbits;
+ nbt = nbits; // Q0
move16();
/*nit = 2 + indxt[0] + indxt[1];*/
- nit = add( add( 2, indxt[0] ), indxt[1] );
+ nit = add( add( 2, indxt[0] ), indxt[1] ); // Q0
tmp_index[-1] = 1;
move16();
FOR( i = 0; i < M; i++ )
{
- lsfmid_q[i] = lsfmid_q0[i];
+ lsfmid_q[i] = lsfmid_q0[i]; /* 14Q1*1.28 */
move16();
}
FOR( i = 0; i < nit; i++ )
{
- tmp_index[i] = indxt[i];
+ tmp_index[i] = indxt[i]; // Q0
move16();
}
}
tmp_index += nit;
/**nb_indices += nit;*/
- *nb_indices = add( *nb_indices, nit );
+ *nb_indices = add( *nb_indices, nit ); // Q0
move16();
/*nbbits[1] = 1 + nbt;*/
nbbits[1] = add( 1, nbt );
@@ -129,7 +129,9 @@ void qlpc_avq_fx(
*
*--------------------------------------------------------------------*/
-static Word16 unary_code( Word16 ind, BSTR_ENC_HANDLE hBstr )
+static Word16 unary_code(
+ Word16 ind, /* Q0 */
+ BSTR_ENC_HANDLE hBstr )
{
Word16 nb_bits;
@@ -142,7 +144,7 @@ static Word16 unary_code( Word16 ind, BSTR_ENC_HANDLE hBstr )
FOR( ; ind > 0; ind-- )
{
push_next_indice_fx( hBstr, 1, 1 );
- nb_bits = add( nb_bits, 1 );
+ nb_bits = add( nb_bits, 1 ); // Q0
}
/* Stop bit */
@@ -150,7 +152,9 @@ static Word16 unary_code( Word16 ind, BSTR_ENC_HANDLE hBstr )
return ( nb_bits );
}
-static Word16 unary_code_ivas_fx( Word16 ind, BSTR_ENC_HANDLE hBstr )
+static Word16 unary_code_ivas_fx(
+ Word16 ind, /* Q0 */
+ BSTR_ENC_HANDLE hBstr )
{
Word16 nb_bits;
@@ -158,18 +162,18 @@ static Word16 unary_code_ivas_fx( Word16 ind, BSTR_ENC_HANDLE hBstr )
nb_bits = 1;
/* Index bits */
- ind = sub( ind, 1 );
+ ind = sub( ind, 1 ); // Q0
WHILE( ind >= 16 )
{
push_next_indice( hBstr, 0xffffU, 16 );
- nb_bits = add( nb_bits, 16 );
+ nb_bits = add( nb_bits, 16 ); // Q0
ind = sub( ind, 16 );
}
IF( ind > 0 )
{
push_next_indice( hBstr, ( 1U << ind ) - 1, ind );
- nb_bits = add( nb_bits, ind );
+ nb_bits = add( nb_bits, ind ); // Q0
}
/* Stop bit */
@@ -182,7 +186,10 @@ static Word16 unary_code_ivas_fx( Word16 ind, BSTR_ENC_HANDLE hBstr )
*
*
*--------------------------------------------------------------------*/
-static Word16 unpack4bits( Word16 nbits, const Word16 *prm, BSTR_ENC_HANDLE hBstr )
+static Word16 unpack4bits(
+ Word16 nbits, /* Q0 */
+ const Word16 *prm, /* Q0 */
+ BSTR_ENC_HANDLE hBstr )
{
Word16 i;
@@ -208,7 +215,10 @@ static Word16 unpack4bits( Word16 nbits, const Word16 *prm, BSTR_ENC_HANDLE hBst
return ( i );
}
-static Word16 unpack4bits_ivas_fx( Word16 nbits, const Word16 *prm, BSTR_ENC_HANDLE hBstr )
+static Word16 unpack4bits_ivas_fx(
+ Word16 nbits, /* Q0 */
+ const Word16 *prm, /* Q0 */
+ BSTR_ENC_HANDLE hBstr )
{
Word16 i;
@@ -242,10 +252,10 @@ static Word16 unpack4bits_ivas_fx( Word16 nbits, const Word16 *prm, BSTR_ENC_HAN
Word16 encode_lpc_avq_fx(
BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
- const Word16 numlpc, /* i : Number of sets of lpc */
- const Word16 *param_lpc, /* i : lpc parameters */
- const Word16 core, /* i : core */
- const Word16 element_mode /* i : element mode - decides between SNS and LPC coding */
+ const Word16 numlpc, /* i : Number of sets of lpc Q0*/
+ const Word16 *param_lpc, /* i : lpc parameters Q0*/
+ const Word16 core, /* i : core Q0*/
+ const Word16 element_mode /* i : element mode - decides between SNS and LPC coding Q0*/
)
{
Word16 k, j;
@@ -281,13 +291,13 @@ Word16 encode_lpc_avq_fx(
if ( k != 0 )
{
move16();
- q_type = param_lpc[j];
+ q_type = param_lpc[j]; // Q0
j = add( j, 1 );
}
test();
if ( EQ_16( element_mode, IVAS_CPE_MDCT ) && k == 0 )
{
- stereo_mode = param_lpc[j];
+ stereo_mode = param_lpc[j]; // Q0
move16();
j = add( j, 1 );
}
@@ -298,17 +308,19 @@ Word16 encode_lpc_avq_fx(
if ( q_type == 0 )
{
move16();
- st1 = param_lpc[j++];
+ st1 = param_lpc[j++]; // Q0
}
move16();
move16();
- qn1 = param_lpc[j++];
- qn2 = param_lpc[j++];
+ qn1 = param_lpc[j++]; // Q0
+ qn2 = param_lpc[j++]; // Q0
IF( EQ_16( qn1, SNS_LOW_BR_MODE ) )
{
nb_ind = add( qn1, qn2 );
}
+ test();
+ test();
IF( k == 0 || ( EQ_16( k, 1 ) && NE_16( core, TCX_20_CORE ) ) )
{
/* Encode quantizer type */
@@ -317,12 +329,13 @@ Word16 encode_lpc_avq_fx(
IF( k != 0 )
{
nb = 1;
+ move16();
push_next_indice_fx( hBstr, q_type, nb );
}
- nb_bits = add( nb_bits, nb );
+ nb_bits = add( nb_bits, nb ); // Q0
/* Encode quantizer data */
-#if 1 // IVAS_CODE
+ test();
test();
test();
test();
@@ -330,7 +343,7 @@ Word16 encode_lpc_avq_fx(
{
/* Absolute quantizer with 1st stage stochastic codebook */
push_next_indice_fx( hBstr, st1, bits_for_abs_quant );
- nb_bits = add( nb_bits, bits_for_abs_quant );
+ nb_bits = add( nb_bits, bits_for_abs_quant ); // Q0
}
test();
@@ -338,21 +351,16 @@ Word16 encode_lpc_avq_fx(
IF( EQ_16( element_mode, IVAS_CPE_MDCT ) && EQ_16( stereo_mode, 3 ) && st1 < 0 )
{
push_next_indice_fx( hBstr, add( st1, 2 ), 1 );
- nb_bits = add( nb_bits, 1 );
- }
-#else
- IF( q_type == 0 )
- {
- /* Absolute quantizer with 1st stage stochastic codebook */
- push_next_indice_fx( hBstr, st1, 8 );
- nb_bits = add( nb_bits, 8 );
+ nb_bits = add( nb_bits, 1 ); // Q0
}
-#endif
+
+ test();
+ test();
IF( NE_16( element_mode, IVAS_CPE_MDCT ) || ( NE_16( st1, -2 ) && NE_16( qn1, SNS_LOW_BR_MODE ) ) )
{
/* 2 bits to specify Q2,Q3,Q4,ext */
- nb_bits = add( nb_bits, 4 );
+ nb_bits = add( nb_bits, 4 ); // Q0
i = sub( qn1, 2 );
if ( s_or( i < 0, (Word16) GT_16( i, 3 ) ) )
@@ -399,18 +407,18 @@ Word16 encode_lpc_avq_fx(
{
unary_code( nb, hBstr );
}
- nb_bits = add( nb_bits, nb );
+ nb_bits = add( nb_bits, nb ); // Q0
move16();
nb = qn2;
IF( GT_16( nb, 6 ) )
{
- nb = sub( nb, 3 );
+ nb = sub( nb, 3 ); // Q0
}
ELSE IF( GT_16( nb, 4 ) )
{
- nb = sub( nb, 4 );
+ nb = sub( nb, 4 ); // Q0
}
ELSE IF( nb == 0 )
{
@@ -427,17 +435,17 @@ Word16 encode_lpc_avq_fx(
{
unary_code( nb, hBstr );
}
- nb_bits = add( nb_bits, nb );
+ nb_bits = add( nb_bits, nb ); // Q0
avqBits = shl( qn1, 2 );
unpack4bits( avqBits, ¶m_lpc[j], hBstr );
j = add( j, qn1 );
- nb_bits = add( nb_bits, avqBits );
+ nb_bits = add( nb_bits, avqBits ); // Q0
avqBits = shl( qn2, 2 );
unpack4bits( avqBits, ¶m_lpc[j], hBstr );
j = add( j, qn2 );
- nb_bits = add( nb_bits, avqBits );
+ nb_bits = add( nb_bits, avqBits ); // Q0
}
}
ELSE
@@ -451,10 +459,10 @@ Word16 encode_lpc_avq_fx(
Word16 encode_lpc_avq_ivas_fx(
BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
- const Word16 numlpc, /* i : Number of sets of lpc */
- const Word16 *param_lpc, /* i : lpc parameters */
- const Word16 core, /* i : core */
- const Word16 element_mode /* i : element mode - decides between SNS and LPC coding */
+ const Word16 numlpc, /* i : Number of sets of lpc Q0*/
+ const Word16 *param_lpc, /* i : lpc parameters Q0*/
+ const Word16 core, /* i : core Q0*/
+ const Word16 element_mode /* i : element mode - decides between SNS and LPC coding Q0*/
)
{
Word16 k, j;
@@ -490,13 +498,13 @@ Word16 encode_lpc_avq_ivas_fx(
IF( k != 0 )
{
move16();
- q_type = param_lpc[j];
+ q_type = param_lpc[j]; // Q0
j = add( j, 1 );
}
test();
IF( EQ_16( element_mode, IVAS_CPE_MDCT ) && k == 0 )
{
- stereo_mode = param_lpc[j];
+ stereo_mode = param_lpc[j]; // Q0
move16();
j = add( j, 1 );
}
@@ -507,18 +515,18 @@ Word16 encode_lpc_avq_ivas_fx(
IF( q_type == 0 )
{
move16();
- st1 = param_lpc[j];
+ st1 = param_lpc[j]; // Q0
j = add( j, 1 );
}
move16();
move16();
- qn1 = param_lpc[j];
+ qn1 = param_lpc[j]; // Q0
j = add( j, 1 );
- qn2 = param_lpc[j];
+ qn2 = param_lpc[j]; // Q0
j = add( j, 1 );
IF( NE_16( qn1, SNS_LOW_BR_MODE ) )
{
- nb_ind = add( nb_ind, add( qn1, qn2 ) );
+ nb_ind = add( nb_ind, add( qn1, qn2 ) ); // Q0
}
test();
@@ -534,7 +542,7 @@ Word16 encode_lpc_avq_ivas_fx(
move16();
push_next_indice( hBstr, q_type, nb );
}
- nb_bits = add( nb_bits, nb );
+ nb_bits = add( nb_bits, nb ); // Q0
/* Encode quantizer data */
test();
@@ -545,7 +553,7 @@ Word16 encode_lpc_avq_ivas_fx(
{
/* Absolute quantizer with 1st stage stochastic codebook */
push_next_indice( hBstr, st1, bits_for_abs_quant );
- nb_bits = add( nb_bits, bits_for_abs_quant );
+ nb_bits = add( nb_bits, bits_for_abs_quant ); // Q0
}
test();
@@ -553,7 +561,7 @@ Word16 encode_lpc_avq_ivas_fx(
IF( EQ_16( element_mode, IVAS_CPE_MDCT ) && EQ_16( stereo_mode, 3 ) && st1 < 0 )
{
push_next_indice( hBstr, add( st1, 2 ), 1 );
- nb_bits = add( nb_bits, 1 );
+ nb_bits = add( nb_bits, 1 ); // Q0
}
test();
@@ -642,12 +650,12 @@ Word16 encode_lpc_avq_ivas_fx(
avqBits = shl( qn1, 2 );
unpack4bits_ivas_fx( avqBits, ¶m_lpc[j], hBstr );
j = add( j, qn1 );
- nb_bits = add( nb_bits, avqBits );
+ nb_bits = add( nb_bits, avqBits ); // Q0
avqBits = shl( qn2, 2 );
unpack4bits_ivas_fx( avqBits, ¶m_lpc[j], hBstr );
j = add( j, qn2 );
- nb_bits = add( nb_bits, avqBits );
+ nb_bits = add( nb_bits, avqBits ); // Q0
}
}
ELSE
diff --git a/lib_enc/qlpc_stoch.c b/lib_enc/qlpc_stoch.c
deleted file mode 100644
index bb488002d71e75a2e34c66942bb1e8f1fc8762ca..0000000000000000000000000000000000000000
--- a/lib_enc/qlpc_stoch.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 "rom_com.h"
-#include "rom_enc.h"
-#include "basop_proto_func.h"
-#include "wmc_auto.h"
diff --git a/lib_enc/qlpc_stoch_fx.c b/lib_enc/qlpc_stoch_fx.c
index 1750528b3d433010d0e4905c32413f978b7f1149..d6f0b504f8f2c5ebc0aea689ff87b5eaac0a7ad0 100644
--- a/lib_enc/qlpc_stoch_fx.c
+++ b/lib_enc/qlpc_stoch_fx.c
@@ -30,19 +30,19 @@
*--------------------------------------------------------------------*/
void lpc_quantization_fx(
Encoder_State *st,
- const Word16 lsp[],
- const Word16 lspmid[],
- Word16 lsp_q[],
- Word16 lsf_q[], /* 14Q1*1.28 */
- Word16 lspmid_q[],
- Word16 lspq_ind[],
- Word16 clip_var[],
- const Word16 coder_type,
- const Word16 acelp_midLpc,
- Word16 param_lpc[],
- Word16 nbits_lpc[],
- Word16 *bits_param_lpc,
- Word16 *no_param_lpc,
+ const Word16 lsp[], /* Q15 */
+ const Word16 lspmid[], /* Q15 */
+ Word16 lsp_q[], /* Q15 */
+ Word16 lsf_q[], /* 14Q1*1.28 */
+ Word16 lspmid_q[], /* Q15 */
+ Word16 lspq_ind[], /* Q15 */
+ Word16 clip_var[], /* [2.56x,Q14,Q8,Q0,Q14,Q14] */
+ const Word16 coder_type, /* Q0 */
+ const Word16 acelp_midLpc, /* Q0 */
+ Word16 param_lpc[], /* Q0 */
+ Word16 nbits_lpc[], /* Q0 */
+ Word16 *bits_param_lpc, /* Q0 */
+ Word16 *no_param_lpc, /* Q0 */
const Word16 Q_ener )
{
Word16 nb_indices;
@@ -114,7 +114,9 @@ void lpc_quantization_fx(
IF( EQ_16( st->next_force_safety_net, 1 ) && EQ_16( st->Opt_RF_ON, 1 ) )
{
force_sf = 1;
+ move16();
st->next_force_safety_net = 0;
+ move16();
}
test();
@@ -123,14 +125,16 @@ void lpc_quantization_fx(
lsf_end_enc_fx( st, lsf, lsf_q, ENDLSF_NBITS, GENERIC, Q_ener,
force_sf, param_lpc, no_param_lpc, bits_param_lpc, GENERIC );
- nb_indices = *no_param_lpc;
+ nb_indices = *no_param_lpc; // Q0
+ move16();
}
ELSE
{
lsf_end_enc_fx( st, lsf, lsf_q, ENDLSF_NBITS, coder_type, Q_ener,
force_sf, param_lpc, no_param_lpc, bits_param_lpc, coder_type );
- nb_indices = *no_param_lpc;
+ nb_indices = *no_param_lpc; // Q0
+ move16();
}
@@ -147,6 +151,7 @@ void lpc_quantization_fx(
( EQ_16( coder_type, VOICED ) || EQ_16( coder_type, GENERIC ) ) && EQ_16( st->Opt_RF_ON, 1 ) )
{
st->next_force_safety_net = 1;
+ move16();
}
lsf2lsp_fx( lsf_q, lsp_q, M, st->sr_core );
@@ -168,7 +173,7 @@ void lpc_quantization_fx(
move16();
FOR( i = nb_indices - 1; i >= 0; i-- )
{
- st->seed_acelp = extract_l( L_mac0( L_mac0( 13849, shr( st->seed_acelp, 1 ), 31821 ), param_lpc[i], 31821 ) );
+ st->seed_acelp = extract_l( L_mac0( L_mac0( 13849, shr( st->seed_acelp, 1 ), 31821 ), param_lpc[i], 31821 ) ); // Q0
move16();
}
@@ -183,7 +188,7 @@ void lpc_quantization_fx(
lsp2lsf_fx( lspmid, lsfmid, M, extract_l( st->sr_core ) );
midlsf_enc_fx( st->lsf_old_fx, lsf_q, lsfmid, &lsfmid_idx, M, st->Bin_E_old_fx, Q_ener, (Word8) st->narrowBand, st->sr_core, coder_type );
- param_lpc[nb_indices++] = lsfmid_idx;
+ param_lpc[nb_indices++] = lsfmid_idx; // Q0
move16();
midlsf_dec( st->lsf_old_fx, lsf_q, lsfmid_idx, lsfmid_q, coder_type, NULL, 0, 1 );
@@ -203,17 +208,17 @@ void lpc_quantization_fx(
void lpc_quantization_ivas_fx(
Encoder_State *st,
- const Word16 lsp[], /* Q15 */
- const Word16 lspmid[], /* Q15 */
- Word16 lsp_q[], /* Q15 */
- Word16 lsf_q[], /* 14Q1*1.28 */
- Word16 lspmid_q[], /* Q15 */
- const Word16 coder_type,
- const Word16 acelp_midLpc,
- Word16 param_lpc[],
- Word16 nbits_lpc[],
- Word16 *bits_param_lpc,
- Word16 *no_param_lpc,
+ const Word16 lsp[], /* Q15 */
+ const Word16 lspmid[], /* Q15 */
+ Word16 lsp_q[], /* Q15 */
+ Word16 lsf_q[], /* 14Q1*1.28 */
+ Word16 lspmid_q[], /* Q15 */
+ const Word16 coder_type, /* Q0 */
+ const Word16 acelp_midLpc, /* Q0 */
+ Word16 param_lpc[], /* Q0 */
+ Word16 nbits_lpc[], /* Q0 */
+ Word16 *bits_param_lpc, /* Q0 */
+ Word16 *no_param_lpc, /* Q0 */
const Word16 Q_ener )
{
Word16 nb_indices;
@@ -262,7 +267,7 @@ void lpc_quantization_ivas_fx(
/*Force safety net when possible in case of transitions*/
test();
test();
- IF( st->tc_cnt >= 1 || LE_32( st->last_core_brate, SID_2k40 ) || ( EQ_16( st->next_force_safety_net, 1 ) ) )
+ IF( GE_32( st->tc_cnt, 1 ) || LE_32( st->last_core_brate, SID_2k40 ) || ( EQ_16( st->next_force_safety_net, 1 ) ) )
{
force_sf = 1;
move16();
@@ -285,7 +290,7 @@ void lpc_quantization_ivas_fx(
lsf_end_enc_ivas_fx( st, lsf, lsf_q, ENDLSF_NBITS, GENERIC, Q_ener,
force_sf, param_lpc, no_param_lpc, bits_param_lpc, GENERIC, NULL );
- nb_indices = *no_param_lpc;
+ nb_indices = *no_param_lpc; // Q0
move16();
}
ELSE
@@ -293,7 +298,7 @@ void lpc_quantization_ivas_fx(
lsf_end_enc_ivas_fx( st, lsf, lsf_q, ENDLSF_NBITS, coder_type, Q_ener,
force_sf, param_lpc, no_param_lpc, bits_param_lpc, coder_type, NULL );
- nb_indices = *no_param_lpc;
+ nb_indices = *no_param_lpc; // Q0
move16();
}
@@ -328,7 +333,7 @@ void lpc_quantization_ivas_fx(
move16();
FOR( i = nb_indices - 1; i >= 0; i-- )
{
- st->seed_acelp = extract_l( L_mac0( L_mac0( 13849, shr( st->seed_acelp, 1 ), 31821 ), param_lpc[i], 31821 ) );
+ st->seed_acelp = extract_l( L_mac0( L_mac0( 13849, shr( st->seed_acelp, 1 ), 31821 ), param_lpc[i], 31821 ) ); // Q0
move16();
}
@@ -343,7 +348,7 @@ void lpc_quantization_ivas_fx(
lsp2lsf_fx( lspmid, lsfmid, M, extract_l( st->sr_core ) );
midlsf_enc_fx( st->lsf_old_fx, lsf_q, lsfmid, &lsfmid_idx, M, st->Bin_E_old_fx, Q_ener, (Word8) st->narrowBand, st->sr_core, coder_type );
- param_lpc[nb_indices] = lsfmid_idx;
+ param_lpc[nb_indices] = lsfmid_idx; // Q0
move16();
nb_indices = add( nb_indices, 1 );
midlsf_dec( st->lsf_old_fx, lsf_q, lsfmid_idx, lsfmid_q, coder_type, NULL, 0, 1 );
@@ -355,7 +360,7 @@ void lpc_quantization_ivas_fx(
{
param_lpc[nb_indices] = 0;
move16();
- nb_indices = add( nb_indices, 1 );
+ nb_indices = add( nb_indices, 1 ); // Q0
}
}
@@ -371,14 +376,14 @@ void lpc_quantization_ivas_fx(
*-------------------------------------------------------------------*/
void Unified_weighting_fx(
- const Word32 Bin_Ener_128_fx[], /* i : FFT Bin energy 128 bins in two sets Q_ener */
+ const Word32 Bin_Ener_128_fx[], /* i : FFT Bin energy 128 bins in two sets Q_ener */
Word16 Q_ener,
- const Word16 lsf_fx[], /* i : LSF vector x2.56 */
- Word16 w_fx[], /* o : LP weighting filter (numerator) Q8 */
- const Word16 narrowBand, /* i : flag for Narrowband */
- const Word16 unvoiced, /* i : flag for Unvoiced frame */
- const Word32 sr_core, /* i : sampling rate of core-coder */
- const Word16 order /* i : LP order */
+ const Word16 lsf_fx[], /* i : LSF vector x2.56 */
+ Word16 w_fx[], /* o : LP weighting filter (numerator) Q8 */
+ const Word16 narrowBand, /* i : flag for Narrowband Q0*/
+ const Word16 unvoiced, /* i : flag for Unvoiced frame Q0*/
+ const Word32 sr_core, /* i : sampling rate of core-coder Q0*/
+ const Word16 order /* i : LP order Q0*/
)
{
Word16 i;
@@ -396,67 +401,64 @@ void Unified_weighting_fx(
const Word32 *Freq_w_Table_fx, *Bin_Ener_fx;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/*Config. weighting*/
IF( narrowBand )
{
- ptr_lsf_fit_model = lsf_unified_fit_model_nb;
- nf_fx = 16384;
- move16(); /* x2.56 */
+ ptr_lsf_fit_model = lsf_unified_fit_model_nb; // Q0
+ nf_fx = 16384; /* 6400 in x2.56 */
+ move16();
last_bin = 127;
move16();
- Bin_Ener_fx = Bin_Ener_128_fx;
+ Bin_Ener_fx = Bin_Ener_128_fx; /* Q_ener */
}
ELSE IF( EQ_32( sr_core, INT_FS_12k8 ) )
{
ptr_lsf_fit_model = lsf_unified_fit_model_wb;
- nf_fx = 16384;
- move16(); /* x2.56 */
+ nf_fx = 16384; /* 6400 in x2.56 */
+ move16();
last_bin = 127;
move16();
- Bin_Ener_fx = Bin_Ener_128_fx;
+ Bin_Ener_fx = Bin_Ener_128_fx; /* Q_ener */
}
ELSE
{
ptr_lsf_fit_model = lsf_unified_fit_model_wbhb;
- nf_fx = 20480;
- move16(); /* x2.56 */
+ nf_fx = 20480; /* 8000 in x2.56 */
+ move16();
/* Fill the missing part (128~159) of the bin energy */
last_bin = 159;
move16();
- Copy32( Bin_Ener_128_fx, Bin_Ener_160_fx, L_FFT / 2 );
+ Copy32( Bin_Ener_128_fx, Bin_Ener_160_fx, L_FFT / 2 ); /* Q_ener */
/* Find average bin energy (32 Energy) */
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 );
-#else
- L_tmp = L_add( L_tmp, Bin_Ener_160_fx[i] );
-#endif
+ L_tmp = L_add_o( L_tmp, Bin_Ener_160_fx[i], &Overflow ); /* Q_ener */
}
L_tmp = L_shr( L_tmp, 5 );
FOR( i = 127; i < 160; i++ )
{
- Bin_Ener_160_fx[i] = L_tmp;
+ Bin_Ener_160_fx[i] = L_tmp; /* Q_ener */
move32();
}
- Bin_Ener_fx = Bin_Ener_160_fx;
+ Bin_Ener_fx = Bin_Ener_160_fx; /* Q_ener */
}
/* 1) FFT weights*/
- Freq_w_Table_fx = Freq_Weight_Com_fx;
+ Freq_w_Table_fx = Freq_Weight_Com_fx; /* Q31 */
if ( unvoiced )
{
- Freq_w_Table_fx = Freq_Weight_UV_fx;
+ Freq_w_Table_fx = Freq_Weight_UV_fx; /* Q31 */
}
/* Use Envelope */
@@ -506,7 +508,7 @@ void Unified_weighting_fx(
if ( LT_16( w_fft_fx[i], min_fx ) )
{
- min_fx = w_fft_fx[i];
+ min_fx = w_fft_fx[i]; // Q8
move16();
}
}
@@ -520,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 );
@@ -541,21 +539,21 @@ void Unified_weighting_fx(
FOR( i = 0; i < order; i++ )
{
/* 2) IHM weights*/
- tmp1_fx = lsf_fx[i];
+ tmp1_fx = lsf_fx[i]; /* x2.56 */
move16();
if ( i > 0 )
{
- tmp1_fx = sub( tmp1_fx, lsf_fx[i - 1] );
+ tmp1_fx = sub( tmp1_fx, lsf_fx[i - 1] ); /* x2.56 */
}
tmp2_fx = nf_fx;
move16();
- if ( NE_16( i, order - 1 ) )
+ if ( NE_16( i, sub( order, 1 ) ) )
{
- tmp2_fx = lsf_fx[i + 1];
+ tmp2_fx = lsf_fx[i + 1]; /* x2.56 */
move16();
}
- tmp2_fx = sub( tmp2_fx, lsf_fx[i] );
+ tmp2_fx = sub( tmp2_fx, lsf_fx[i] ); /* x2.56 */
s1 = 15;
move16();
@@ -564,15 +562,17 @@ void Unified_weighting_fx(
if ( tmp1_fx == 0 )
{
tmp1_fx = 8;
+ move16();
}
tmp1_fx = Inv16( tmp1_fx, &s1 );
if ( tmp2_fx == 0 )
{
tmp2_fx = 8;
+ move16();
}
tmp2_fx = Inv16( tmp2_fx, &s2 );
s1 = BASOP_Util_Add_MantExp( tmp1_fx, s1, tmp2_fx, s2, &tmp1_fx ); /* x * 2.56 / pow(2.0, 15 + |s1|) */
- tmp_fx = mult_r( nf_fx, 10430 );
+ tmp_fx = mult_r( nf_fx, 10430 /* 0.31 in Q15*/ );
s2 = norm_s( tmp_fx );
tmp_fx = shl( tmp_fx, s2 );
s1 = sub( s1, s2 );
@@ -589,7 +589,7 @@ void Unified_weighting_fx(
IF( LT_32( L_shl( L_tmp, 5 ), InvIntTable[i + 1] ) )
{
- w_fx[i] = shr( InvIntTable[i + 1], 7 );
+ w_fx[i] = shr( InvIntTable[i + 1], 7 ); // Q8
move16();
}
ELSE
@@ -601,7 +601,8 @@ void Unified_weighting_fx(
}
ELSE
{
- w_fx[i] = extract_l( L_shr( L_tmp, 2 ) );
+ w_fx[i] = extract_l( L_shr( L_tmp, 2 ) ); // Q8
+ move16();
}
}
}
diff --git a/lib_enc/range_enc.c b/lib_enc/range_enc.c
deleted file mode 100644
index fd4f3cb7c53af6bc1a4a149c6db6799b8f39655e..0000000000000000000000000000000000000000
--- a/lib_enc/range_enc.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 "rom_com.h"
-#include "prot.h"
-#include "wmc_auto.h"
diff --git a/lib_enc/range_enc_fx.c b/lib_enc/range_enc_fx.c
index da325b2bd232a5fa22087054352ad2c5f3e941cb..05916e8013e76d05abec274e198c039c9e23c48e 100644
--- a/lib_enc/range_enc_fx.c
+++ b/lib_enc/range_enc_fx.c
@@ -26,7 +26,7 @@ static void rc_enc_write_ivas_fx( BSTR_ENC_HANDLE hBstr, Word16 byte, Word16 bit
void rc_enc_init_fx(
PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */
- Word16 tot_bits /* i : Total bit budget */
+ Word16 tot_bits /* i : Total bit budget Q0*/
)
{
hPVQ->rc_low = L_deposit_l( 0 );
@@ -40,7 +40,7 @@ void rc_enc_init_fx(
move16();
hPVQ->rc_num_bits = 0;
move16();
- hPVQ->rc_tot_bits = tot_bits;
+ hPVQ->rc_tot_bits = tot_bits; // Q0
move16();
hPVQ->rc_offset = 0;
move16();
@@ -54,37 +54,37 @@ void rc_enc_init_fx(
* Encode symbol with range coder
*-------------------------------------------------------------------*/
void rc_encode_ivas_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */
- UWord32 cum_freq, /* i : Cumulative frequency up to symbol */
- UWord32 sym_freq, /* i : Symbol probability */
- UWord32 tot /* i : Total cumulative frequency */
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */
+ UWord32 cum_freq, /* i : Cumulative frequency up to symbol Q0*/
+ UWord32 sym_freq, /* i : Symbol probability Q0*/
+ UWord32 tot /* i : Total cumulative frequency Q0*/
)
{
UWord32 r, tmp, inv_tot, lsb;
Word16 exp;
UWord16 carry;
- inv_tot = UL_inverse( tot, &exp );
+ inv_tot = UL_inverse( tot, &exp ); // Q0
Mpy_32_32_uu( hPVQ->rc_range, inv_tot, &tmp, &lsb ); /*0+exp-32 */
r = UL_lshr( tmp, sub( exp, 32 ) ); /* exp-32-exp3+32 = 0 */
tmp = UL_Mpy_32_32( r, cum_freq );
- hPVQ->rc_low = UL_addNs( hPVQ->rc_low, tmp, &carry );
+ hPVQ->rc_low = UL_addNs( hPVQ->rc_low, tmp, &carry ); // Q0
move32();
if ( carry != 0 )
{
- hPVQ->rc_carry = carry;
+ hPVQ->rc_carry = carry; // Q0
move16();
}
- hPVQ->rc_range = UL_Mpy_32_32( r, sym_freq );
+ hPVQ->rc_range = UL_Mpy_32_32( r, sym_freq ); // Q0
move32();
WHILE( LT_64( hPVQ->rc_range, 1 << 24 ) )
{
- hPVQ->rc_range = UL_lshl( hPVQ->rc_range, 8 );
+ hPVQ->rc_range = UL_lshl( hPVQ->rc_range, 8 ); // Q0
move32();
- hPVQ->rc_num_bits = add( hPVQ->rc_num_bits, 8 );
+ hPVQ->rc_num_bits = add( hPVQ->rc_num_bits, 8 ); // Q0
move16();
rc_enc_shift_ivas_fx( hBstr, hPVQ );
}
@@ -92,36 +92,36 @@ void rc_encode_ivas_fx(
return;
}
void rc_encode_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */
- UWord32 cum_freq, /* i : Cumulative frequency up to symbol */
- UWord32 sym_freq, /* i : Symbol probability */
- UWord32 tot /* i : Total cumulative frequency */
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */
+ UWord32 cum_freq, /* i : Cumulative frequency up to symbol Q0*/
+ UWord32 sym_freq, /* i : Symbol probability Q0*/
+ UWord32 tot /* i : Total cumulative frequency Q0*/
)
{
UWord32 r, tmp, inv_tot, lsb;
Word16 exp;
UWord16 carry;
- inv_tot = UL_inverse( tot, &exp );
+ inv_tot = UL_inverse( tot, &exp ); // Q0
Mpy_32_32_uu( hPVQ->rc_range, inv_tot, &tmp, &lsb ); /*0+exp-32 */
r = UL_lshr( tmp, sub( exp, 32 ) ); /* exp-32-exp3+32 = 0 */
tmp = UL_Mpy_32_32( r, cum_freq );
- hPVQ->rc_low = UL_addNs( hPVQ->rc_low, tmp, &carry );
+ hPVQ->rc_low = UL_addNs( hPVQ->rc_low, tmp, &carry ); // Q0
if ( carry != 0 )
{
- hPVQ->rc_carry = carry;
+ hPVQ->rc_carry = carry; // Q0
move16();
}
- hPVQ->rc_range = UL_Mpy_32_32( r, sym_freq );
+ hPVQ->rc_range = UL_Mpy_32_32( r, sym_freq ); // Q0
WHILE( hPVQ->rc_range < 1 << 24 )
{
- L_sub( 0, 0 ); /* Comparison in while */
- hPVQ->rc_range = UL_lshl( hPVQ->rc_range, 8 );
- hPVQ->rc_num_bits = add( hPVQ->rc_num_bits, 8 );
+ L_sub( 0, 0 ); /* Comparison in while */
+ hPVQ->rc_range = UL_lshl( hPVQ->rc_range, 8 ); // Q0
+ hPVQ->rc_num_bits = add( hPVQ->rc_num_bits, 8 ); // Q0
rc_enc_shift_fx( hBstr, hPVQ );
}
@@ -146,8 +146,8 @@ void rc_enc_finish_ivas_fx(
bits = add( norm_ul( hPVQ->rc_range ), 1 );
mask = UL_lshr( 0xffffffff, bits );
- val = UL_addNs( hPVQ->rc_low, mask, &over1 );
- high = UL_addNs( hPVQ->rc_low, hPVQ->rc_range, &over2 );
+ val = UL_addNs( hPVQ->rc_low, mask, &over1 ); // Q0
+ high = UL_addNs( hPVQ->rc_low, hPVQ->rc_range, &over2 ); // Q0
val = L_and( val, ~mask );
L_xor( 0, 0 ); /* For bit not */
@@ -157,13 +157,13 @@ void rc_enc_finish_ivas_fx(
L_sub( 0, 0 ); /* For comparision in if */
IF( UL_addNsD( val, mask ) >= high )
{
- bits = add( bits, 1 );
- mask = UL_lshr( mask, 1 );
- val = UL_and( UL_addNsD( hPVQ->rc_low, mask ), ~mask );
- L_xor( 0, 0 ); /* For bit not */
+ bits = add( bits, 1 ); // Q0
+ mask = UL_lshr( mask, 1 ); // Q0
+ val = UL_and( UL_addNsD( hPVQ->rc_low, mask ), ~mask ); // Q0
+ L_xor( 0, 0 ); /* For bit not */
}
- if ( LT_32( val, hPVQ->rc_low ) )
+ if ( LT_64( val, hPVQ->rc_low ) )
{
hPVQ->rc_carry = 1;
move16();
@@ -175,10 +175,10 @@ void rc_enc_finish_ivas_fx(
IF( GT_16( bits, sub( hPVQ->rc_tot_bits, hPVQ->rc_num_bits ) ) )
{
- bits = sub( hPVQ->rc_tot_bits, hPVQ->rc_num_bits );
+ bits = sub( hPVQ->rc_tot_bits, hPVQ->rc_num_bits ); // Q0
}
- hPVQ->rc_num_bits = add( hPVQ->rc_num_bits, bits );
+ hPVQ->rc_num_bits = add( hPVQ->rc_num_bits, bits ); // Q0
move16();
FOR( ; bits > 0; bits -= 8 )
{
@@ -201,7 +201,7 @@ void rc_enc_finish_ivas_fx(
rc_enc_write_ivas_fx( hBstr, lshr( add( hPVQ->rc_cache, hPVQ->rc_carry ), sub( 8, bits ) ), bits );
}
- bits = hPVQ->rc_num_bits;
+ bits = hPVQ->rc_num_bits; // Q0
move16();
WHILE( LT_16( bits, sub( hPVQ->rc_tot_bits, 16 ) ) )
{
@@ -209,7 +209,7 @@ void rc_enc_finish_ivas_fx(
bits = add( bits, 16 );
}
- bits = sub( hPVQ->rc_tot_bits, bits );
+ bits = sub( hPVQ->rc_tot_bits, bits ); // Q0
IF( bits > 0 )
{
rc_enc_write_ivas_fx( hBstr, 0, bits );
@@ -227,11 +227,11 @@ void rc_enc_finish_fx(
Word16 bits;
UWord16 over1, over2;
- bits = add( norm_ul( hPVQ->rc_range ), 1 );
+ bits = add( norm_ul( hPVQ->rc_range ), 1 ); // Q0
mask = UL_lshr( 0xffffffff, bits );
- val = UL_addNs( hPVQ->rc_low, mask, &over1 );
- high = UL_addNs( hPVQ->rc_low, hPVQ->rc_range, &over2 );
+ val = UL_addNs( hPVQ->rc_low, mask, &over1 ); // Q0
+ high = UL_addNs( hPVQ->rc_low, hPVQ->rc_range, &over2 ); // Q0
val = L_and( val, ~mask );
L_xor( 0, 0 ); /* For bit not */
@@ -241,10 +241,10 @@ void rc_enc_finish_fx(
L_sub( 0, 0 ); /* For comparision in if */
IF( UL_addNsD( val, mask ) >= high )
{
- bits = add( bits, 1 );
- mask = UL_lshr( mask, 1 );
- val = UL_and( UL_addNsD( hPVQ->rc_low, mask ), ~mask );
- L_xor( 0, 0 ); /* For bit not */
+ bits = add( bits, 1 ); // Q0
+ mask = UL_lshr( mask, 1 ); // Q0
+ val = UL_and( UL_addNsD( hPVQ->rc_low, mask ), ~mask ); // Q0
+ L_xor( 0, 0 ); /* For bit not */
}
if ( val < hPVQ->rc_low )
@@ -259,10 +259,10 @@ void rc_enc_finish_fx(
IF( GT_16( bits, sub( hPVQ->rc_tot_bits, hPVQ->rc_num_bits ) ) )
{
- bits = sub( hPVQ->rc_tot_bits, hPVQ->rc_num_bits );
+ bits = sub( hPVQ->rc_tot_bits, hPVQ->rc_num_bits ); // Q0
}
- hPVQ->rc_num_bits = add( hPVQ->rc_num_bits, bits );
+ hPVQ->rc_num_bits = add( hPVQ->rc_num_bits, bits ); // Q0
FOR( ; bits > 0; bits -= 8 )
{
rc_enc_shift_fx( hBstr, hPVQ );
@@ -284,7 +284,7 @@ void rc_enc_finish_fx(
rc_enc_write_fx( hBstr, lshr( add( hPVQ->rc_cache, hPVQ->rc_carry ), sub( 8, bits ) ), bits );
}
- bits = hPVQ->rc_num_bits;
+ bits = hPVQ->rc_num_bits; // Q0
move16();
WHILE( LT_16( bits, sub( hPVQ->rc_tot_bits, 16 ) ) )
{
@@ -323,7 +323,7 @@ static void rc_enc_shift_ivas_fx(
WHILE( hPVQ->rc_carry_count > 0 )
{
rc_enc_write_ivas_fx( hBstr, s_and( add( hPVQ->rc_carry, 0xff ), 255 ), 8 );
- hPVQ->rc_carry_count = sub( hPVQ->rc_carry_count, 1 );
+ hPVQ->rc_carry_count = sub( hPVQ->rc_carry_count, 1 ); // Q0
move16();
}
@@ -333,7 +333,7 @@ static void rc_enc_shift_ivas_fx(
}
ELSE
{
- hPVQ->rc_carry_count = add( hPVQ->rc_carry_count, 1 );
+ hPVQ->rc_carry_count = add( hPVQ->rc_carry_count, 1 ); // Q0
move16();
}
hPVQ->rc_low = UL_lshl( hPVQ->rc_low, 8 );
@@ -357,7 +357,7 @@ static void rc_enc_shift_fx(
WHILE( hPVQ->rc_carry_count > 0 )
{
rc_enc_write_fx( hBstr, s_and( add( hPVQ->rc_carry, 0xff ), 255 ), 8 );
- hPVQ->rc_carry_count = sub( hPVQ->rc_carry_count, 1 );
+ hPVQ->rc_carry_count = sub( hPVQ->rc_carry_count, 1 ); // Q0
}
hPVQ->rc_cache = u_extract_l( UL_lshr( hPVQ->rc_low, 24 ) );
@@ -366,9 +366,9 @@ static void rc_enc_shift_fx(
}
ELSE
{
- hPVQ->rc_carry_count = add( hPVQ->rc_carry_count, 1 );
+ hPVQ->rc_carry_count = add( hPVQ->rc_carry_count, 1 ); // Q0
}
- hPVQ->rc_low = UL_lshl( hPVQ->rc_low, 8 );
+ hPVQ->rc_low = UL_lshl( hPVQ->rc_low, 8 ); // Q0
return;
}
@@ -379,29 +379,29 @@ static void rc_enc_shift_fx(
*
*-------------------------------------------------------------------*/
void rc_enc_bits_ivas_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */
- UWord32 value, /* i : Value to encode */
- Word16 bits /* i : Number of bits used */
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */
+ UWord32 value, /* i : Value to encode Q0*/
+ Word16 bits /* i : Number of bits used Q0*/
)
{
IF( LE_16( add( rc_get_bits2_fx( hPVQ->rc_num_bits, hPVQ->rc_range ), bits ), hPVQ->rc_tot_bits ) )
{
- hPVQ->rc_num_bits = add( hPVQ->rc_num_bits, bits );
+ hPVQ->rc_num_bits = add( hPVQ->rc_num_bits, bits ); // Q0
move16();
IF( GT_16( bits, 16 ) )
{
push_indice( hBstr, sub( IND_RC_END, hPVQ->rc_offset ), u_extract_l( UL_lshr( value, 16 ) ), sub( bits, 16 ) );
- hPVQ->rc_offset = add( hPVQ->rc_offset, 1 );
+ hPVQ->rc_offset = add( hPVQ->rc_offset, 1 ); // Q0
move16();
push_indice( hBstr, sub( IND_RC_END, hPVQ->rc_offset ), u_extract_l( UL_and( value, 0x0000ffff ) ), 16 );
- hPVQ->rc_offset = add( hPVQ->rc_offset, 1 );
+ hPVQ->rc_offset = add( hPVQ->rc_offset, 1 ); // Q0
move16();
}
ELSE
{
push_indice( hBstr, sub( IND_RC_END, hPVQ->rc_offset ), u_extract_l( value ), bits );
- hPVQ->rc_offset = add( hPVQ->rc_offset, 1 );
+ hPVQ->rc_offset = add( hPVQ->rc_offset, 1 ); // Q0
move16();
}
}
@@ -412,27 +412,27 @@ void rc_enc_bits_ivas_fx(
return;
}
void rc_enc_bits_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */
- UWord32 value, /* i : Value to encode */
- Word16 bits /* i : Number of bits used */
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */
+ UWord32 value, /* i : Value to encode Q0*/
+ Word16 bits /* i : Number of bits used Q0*/
)
{
IF( LE_16( add( rc_get_bits2_fx( hPVQ->rc_num_bits, hPVQ->rc_range ), bits ), hPVQ->rc_tot_bits ) )
{
- hPVQ->rc_num_bits = add( hPVQ->rc_num_bits, bits );
+ hPVQ->rc_num_bits = add( hPVQ->rc_num_bits, bits ); // Q0
IF( GT_16( bits, 16 ) )
{
push_indice_fx( hBstr, sub( IND_RC_END, hPVQ->rc_offset ), u_extract_l( UL_lshr( value, 16 ) ), sub( bits, 16 ) );
- hPVQ->rc_offset = add( hPVQ->rc_offset, 1 );
+ hPVQ->rc_offset = add( hPVQ->rc_offset, 1 ); // Q0
push_indice_fx( hBstr, sub( IND_RC_END, hPVQ->rc_offset ), u_extract_l( UL_and( value, 0x0000ffff ) ), 16 );
- hPVQ->rc_offset = add( hPVQ->rc_offset, 1 );
+ hPVQ->rc_offset = add( hPVQ->rc_offset, 1 ); // Q0
}
ELSE
{
push_indice_fx( hBstr, sub( IND_RC_END, hPVQ->rc_offset ), u_extract_l( value ), bits );
- hPVQ->rc_offset = add( hPVQ->rc_offset, 1 );
+ hPVQ->rc_offset = add( hPVQ->rc_offset, 1 ); // Q0
}
}
ELSE
@@ -448,10 +448,10 @@ void rc_enc_bits_fx(
* Encode with uniform distribution
*-------------------------------------------------------------------*/
void rc_enc_uniform_ivas_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */
- UWord32 value, /* i : Value to encode */
- UWord32 tot /* i : Maximum value */
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */
+ UWord32 value, /* i : Value to encode Q0*/
+ UWord32 tot /* i : Maximum value Q0*/
)
{
Word16 n;
@@ -472,15 +472,15 @@ void rc_enc_uniform_ivas_fx(
return;
}
void rc_enc_uniform_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */
- UWord32 value, /* i : Value to encode */
- UWord32 tot /* i : Maximum value */
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */
+ UWord32 value, /* i : Value to encode Q0*/
+ UWord32 tot /* i : Maximum value Q0*/
)
{
Word16 n;
- n = sub( 32, norm_ul( UL_subNsD( tot, 1 ) ) );
+ n = sub( 32, norm_ul( UL_subNsD( tot, 1 ) ) ); // Q0
IF( LE_16( n, 8 ) )
{
@@ -488,7 +488,7 @@ void rc_enc_uniform_fx(
}
ELSE
{
- n = sub( n, 8 );
+ n = sub( n, 8 ); // Q0
rc_encode_fx( hBstr, hPVQ, UL_lshr( value, n ), 1, UL_addNsD( UL_lshr( tot, n ), 1 ) );
rc_enc_bits_fx( hBstr, hPVQ, UL_and( value, UL_subNsD( UL_lshl( 1, n ), 1 ) ), n );
}
@@ -502,9 +502,9 @@ void rc_enc_uniform_fx(
* Write a byte to bitstream
*-------------------------------------------------------------------*/
static void rc_enc_write_ivas_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- Word16 byte, /* i : Byte to write */
- Word16 bits /* i : Number of bits */
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ Word16 byte, /* i : Byte to write Q0*/
+ Word16 bits /* i : Number of bits Q0*/
)
{
push_indice( hBstr, IND_RC_START, byte, bits );
@@ -512,9 +512,9 @@ static void rc_enc_write_ivas_fx(
return;
}
static void rc_enc_write_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- Word16 byte, /* i : Byte to write */
- Word16 bits /* i : Number of bits */
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ Word16 byte, /* i : Byte to write Q0*/
+ Word16 bits /* i : Number of bits Q0*/
)
{
push_indice_fx( hBstr, IND_RC_START, byte, bits );
diff --git a/lib_enc/re8_cod.c b/lib_enc/re8_cod.c
deleted file mode 100644
index e748899a9667996f0776eb65127752b66796a660..0000000000000000000000000000000000000000
--- a/lib_enc/re8_cod.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/re8_cod_fx.c b/lib_enc/re8_cod_fx.c
index e035baf57ccfbd988bbb2596722035453751371f..d43dbbf57aa184d18022f519071e0e3df1c0a9b8 100644
--- a/lib_enc/re8_cod_fx.c
+++ b/lib_enc/re8_cod_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 */
@@ -17,10 +16,10 @@
*--------------------------------------------------------------------------*/
void re8_cod_fx(
- Word16 x[], /* i : point in RE8 (8-dimensional integer vector) */
- Word16 *n, /* i : codebook number (*n is an integer defined in {0,2,3,4,..,n_max}) */
- UWord16 *I, /* o : index of c (pointer to unsigned 16-bit word) */
- Word16 k[] /* o : index of v (8-dimensional vector of binary indices) = Voronoi index */
+ Word16 x[], /* i : point in RE8 (8-dimensional integer vector) Q0*/
+ Word16 *n, /* i : codebook number (*n is an integer defined in {0,2,3,4,..,n_max}) Q0*/
+ UWord16 *I, /* o : index of c (pointer to unsigned 16-bit word) Q0*/
+ Word16 k[] /* o : index of v (8-dimensional vector of binary indices) = Voronoi index Q0*/
)
{
Word16 ka_fx, c_fx[8];
diff --git a/lib_enc/reordernorm.c b/lib_enc/reordernorm.c
deleted file mode 100644
index 4922b9e4cac63a8b7e0bad323eeb65ac2b6706ba..0000000000000000000000000000000000000000
--- a/lib_enc/reordernorm.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 "cnst.h"
-#include "rom_com.h"
-#include "wmc_auto.h"
diff --git a/lib_enc/reordernorm_fx.c b/lib_enc/reordernorm_fx.c
index 40f12ffb8bec38ed8ecbc01a358e73bd0db34972..176b54f8e586150bc57f8f4e6f404d3c9724d994 100644
--- a/lib_enc/reordernorm_fx.c
+++ b/lib_enc/reordernorm_fx.c
@@ -7,7 +7,6 @@
#include "cnst.h" /* Common constants */
#include "rom_com_fx.h"
#include "rom_com.h"
-//#include "prot_fx.h"
#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
@@ -32,25 +31,25 @@ void reordernorm_fx(
SWITCH( nb_sfm )
{
case NB_SFM:
- order = norm_order_48;
+ order = norm_order_48; // Q0
BREAK;
case SFM_N_SWB:
- order = norm_order_32;
+ order = norm_order_32; // Q0
BREAK;
case SFM_N_WB:
- order = norm_order_16;
+ order = norm_order_16; // Q0
BREAK;
default:
- order = norm_order_48;
+ order = norm_order_48; // Q0
BREAK;
}
FOR( i = 0; i < nb_sfm; i++ )
{
- idxbuf[i] = ynrm[order[i]];
+ idxbuf[i] = ynrm[order[i]]; // Q0
move16();
move16();
- normbuf[i] = normqlg2[order[i]];
+ normbuf[i] = normqlg2[order[i]]; // Q0
move16();
move16();
}
diff --git a/lib_enc/rom_enc.c b/lib_enc/rom_enc.c
index aabc7deefae8579778101ee7e4615ecdb18b95bd..e1f2442bc515d332408866e04caec69df6653d19 100644
--- a/lib_enc/rom_enc.c
+++ b/lib_enc/rom_enc.c
@@ -46,12 +46,12 @@
* VAD ROM tables
*----------------------------------------------------------------------------------*/
-const int16_t hangover_hd_tbl[3] = {1, 1, 3};
-const int16_t hangover_sf_tbl[6] = {1, 3, 4, 1, 1, 2};
-const int16_t bwd_start_bin[BWD_N_BINS_MAX] = {1, 3, 6, 11};
-const int16_t bwd_end_bin[BWD_N_BINS_MAX] = {1, 4, 9, 12};
+const Word16 hangover_hd_tbl[3] = {1, 1, 3}; // Q0
+const Word16 hangover_sf_tbl[6] = {1, 3, 4, 1, 1, 2}; // Q0
+const Word16 bwd_start_bin[BWD_N_BINS_MAX] = {1, 3, 6, 11}; // Q0
+const Word16 bwd_end_bin[BWD_N_BINS_MAX] = {1, 4, 9, 12}; // Q0
-const int16_t BAND_NUM_TAB[5] = {10,10,20,40,60}; /* {OFFSET, NB, WB, SWB, FB} */
+const Word16 BAND_NUM_TAB[5] = {10,10,20,40,60}; /* {OFFSET, NB, WB, SWB, FB} Q0*/
typedef struct
{
Word16 r;
@@ -76,16 +76,16 @@ const Word16 M_Wi_fix16[16] =
32609/* 9.9518473e-001f Q15 */,31356/* 9.5694034e-001f Q15 */,28898/* 8.8192126e-001f Q15 */,25329/* 7.7301045e-001f Q15 */,20787/* 6.3439328e-001f Q15 */,15446/* 4.7139674e-001f Q15 */, 9512/* 2.9028468e-001f Q15 */, 3212/* 9.8017140e-002f Q15 */
};
-const int16_t SP_CENTER_BAND_NUM_TAB[5] = {10, 10, 20, 24, 24};
+const Word16 SP_CENTER_BAND_NUM_TAB[5] = {10, 10, 20, 24, 24}; // Q0
/* 107374184.f = 32768.f * 32768.f * 0.1 */
-const int16_t NREGION_INDEX_NB[9] = {0,1,2,3,4,5,6,7, 9};
-const int16_t NREGION_INDEX_WB[13] = {0,1,2,3,4,5,6,8,10,12,16};
-const int16_t NREGION_INDEX_SWB[16] = {0,1,2,3,4,5,6,8,10,12,16,24,36};
-const int16_t NREGION_INDEX_FB[16] = {0,1,2,3,4,5,6,8,10,12,16,24,36};
+const Word16 NREGION_INDEX_NB[9] = {0,1,2,3,4,5,6,7, 9}; // Q0
+const Word16 NREGION_INDEX_WB[13] = {0,1,2,3,4,5,6,8,10,12,16}; // Q0
+const Word16 NREGION_INDEX_SWB[16] = {0,1,2,3,4,5,6,8,10,12,16,24,36}; // Q0
+const Word16 NREGION_INDEX_FB[16] = {0,1,2,3,4,5,6,8,10,12,16,24,36}; // Q0
const Word16 NREGION_PREOFF[12] = { 0,0,0,0,0,0,1,1,1,2,3,4 };
-const int16_t ENERGY_BAND_NUM[4] = {8,10,12,MAX_SUBBAND_NUM};
-const int16_t * const REGION_INDEX[4] = {NREGION_INDEX_NB, NREGION_INDEX_WB,NREGION_INDEX_SWB,NREGION_INDEX_FB};
+const Word16 ENERGY_BAND_NUM[4] = {8,10,12,MAX_SUBBAND_NUM}; // Q0
+const Word16 * const REGION_INDEX[4] = {NREGION_INDEX_NB, NREGION_INDEX_WB,NREGION_INDEX_SWB,NREGION_INDEX_FB}; // Q0
const Word32 MAX_LF_SNR_TAB_FX[5] = { 26843545/* 0.8 Q25 */,26843545/* 0.8 Q25 */,53687090/* 1.6 Q25 */,26843545/* 0.8 Q25 */,26843545/* 0.8 Q25 */ };
const Word32 COMVAD_INIT_SNR_DELTA_FX[5] = { 33554431/* 1.0 Q25 */, 20132659/* 0.6 Q25 */, 28856811/* 0.86 Q25 */, 38923139/* 1.16 Q25 */, 33554431/* 1.0 Q25 */ };
const Word32 LT_MIN_SILENCE_SNR_FX[4] = { 150994940/* 4.5 Q25 */, 150994940/* 4.5 Q25 */, 150994940/* 4.5 Q25 */,150994940/* 4.5 Q25 */ };
@@ -106,12 +106,12 @@ const Word16 sqrt_han_window_fx[L_FFT / 2 + 1] =
31785, 31880, 31971, 32057, 32137, 32213, 32285, 32351, 32412,
32469, 32521, 32567, 32609, 32646, 32678, 32705, 32728, 32745,
32757, 32765, 32767
-};
+}; // Q15
/*----------------------------------------------------------------------------------*
* Starting points for pulse position search in Algebraic innovation codebook
*----------------------------------------------------------------------------------*/
-const int16_t tipos[40] =
+const Word16 tipos[40] =
{
0, 1, 2, 3, /* starting point &ipos[0], 1st iter */
1, 2, 3, 0, /* starting point &ipos[4], 2nd iter */
@@ -123,22 +123,22 @@ const int16_t tipos[40] =
3, 0, 1, 2,
0, 1, 2, 3,
1, 2, 3, 0 /* end point for 28 pulses &ipos[39], 4th iter */
-};
+}; // Q0
/*----------------------------------------------------------------------------------*
* Open-loop pitch tables
*----------------------------------------------------------------------------------*/
-const int16_t nb_sect_12k8[3] = { 4, 4, 4 };
-const int16_t nb_subsect_12k8[3] = { 7, 7, 7 };
-const int16_t pit_max_12k8[8] = { 11, 16, 21, 31, 40, 61, 77, 115};
+const Word16 nb_sect_12k8[3] = { 4, 4, 4 }; // Q0
+const Word16 nb_subsect_12k8[3] = { 7, 7, 7 }; // Q0
+const Word16 pit_max_12k8[8] = { 11, 16, 21, 31, 40, 61, 77, 115}; // Q0
-const int16_t len_12k8[4] = { 40, 40, 62, 115 };
-const int16_t len1_12k8[4] = { 40, 50, 80, 115 };
-const int16_t sublen_12k8[7] = { 40, 40, 40, 62, 62, 115, 115 };
-const int16_t sublen1_12k8[7] = { 40, 40, 50, 50, 80, 80, 115 };
-const int16_t sec_length_12k8[4] = { 7, 15, 30, 54 };
-const int16_t sec_length1_12k8[4] = { 10, 19, 37, 38 };
-const Word16 h_fir_fx[] = { 4260, 7536, 9175, 7536, 4260 };
+const Word16 len_12k8[4] = { 40, 40, 62, 115 }; // Q0
+const Word16 len1_12k8[4] = { 40, 50, 80, 115 }; // Q0
+const Word16 sublen_12k8[7] = { 40, 40, 40, 62, 62, 115, 115 }; // Q0
+const Word16 sublen1_12k8[7] = { 40, 40, 50, 50, 80, 80, 115 }; // Q0
+const Word16 sec_length_12k8[4] = { 7, 15, 30, 54 }; // Q0
+const Word16 sec_length1_12k8[4] = { 10, 19, 37, 38 }; // Q0
+const Word16 h_fir_fx[] = { 4260, 7536, 9175, 7536, 4260 }; // Q15
const Word16 W_HIST_FX[DTX_HIST_SIZE] = { 13107, 10486, 8389, 6711, 5369, 4295, 3436, 687 }; /* Q16 */
const Word16 W_HIST_S_FX[DTX_HIST_SIZE] = { 20480, 11378, 8393, 6938, 6092, 5551, 5183, 5115 }; /* Q12 */
@@ -148,32 +148,32 @@ const Word16 preemphCompensation_fx[NB_BANDS] = { 19960/*9.7461f Q11*/, 19493/*
* LSF quantizer
*----------------------------------------------------------------------------------*/
-const int16_t lsf_numlevels[TCXLPC_NUMSTAGES] = { 32, 16, 16 };
-const int16_t lsf_ind_numlevels[TCXLPC_IND_NUMSTAGES] = { 4 };
+const Word16 lsf_numlevels[TCXLPC_NUMSTAGES] = { 32, 16, 16 }; // Q0
+const Word16 lsf_ind_numlevels[TCXLPC_IND_NUMSTAGES] = { 4 }; // Q0
-const int16_t lsf_unified_fit_model_nb[4][16] =
+const Word16 lsf_unified_fit_model_nb[4][16] =
{
{12506 , -17641 , -6444 , -6646 , -3523 , -2132 , -511 , -92 , 699 , 1062 , 2578 , 3564 , 3200 , -285 , 2928 , -250},
{20383 , 18855 , 8494 , 8062 , 8105 , 6211 , 5068 , 4408 , 3741 , 3458 , 2732 , 3174 , 2412 , 17421 , -21717 , 0},
{-717 , -617 , -144 , -117 , -229 , -144 , -141 , -98 , -92 , -69 , -51 , -87 , -37 , -3019 , 19864 , 8034},
{-2424 , 8999 , 5723 , 5629 , 4239 , 3423 , 2507 , 2019 , 1245 , 736 , -907 , -2237 , -2558 , -1979 , -652 , 1657}
-};
+}; // Q0
-const int16_t lsf_unified_fit_model_wb[4][16] =
+const Word16 lsf_unified_fit_model_wb[4][16] =
{
{8323 , -567 , 3402 , 1389 , 1437 , 1820 , 1407 , 1299 , 1292 , 1206 , 1031 , 928 , 898 , 832 , 840 , 681},
{24635 , 19605 , 9294 , 7407 , 6419 , 5459 , 4966 , 4189 , 3394 , 2964 , 2425 , 2110 , 2140 , 1972 , 1540 , 2252},
{-867 , -666 , -168 , -114 , -90 , -122 , -129 , -101 , -65 , -56 , -39 , -35 , -40 , -42 , -35 , -56},
{-2313 , 3035 , 1677 , 2854 , 2334 , 1232 , 1347 , 1034 , 863 , 707 , 886 , 891 , 432 , 357 , 206 , -310}
-};
+}; // Q0
-const int16_t lsf_unified_fit_model_wbhb[4][16] =
+const Word16 lsf_unified_fit_model_wbhb[4][16] =
{
{5312 , 1967 , 2914 , 1438 , 2595 , 1848 , 1980 , 2021 , 1535 , 1489 , 1651 , 1502 , 1447 , 1311 , 1353 , 1202},
{28135 , 16053 , 10129 , 7366 , 5898 , 5341 , 3290 , 2780 , 3146 , 2423 , 1613 , 1370 , 1294 , 1635 , 1105 , 1431},
{-615 , -308 , -147 , -119 , -104 , -105 , -30 , -28 , -50 , -39 , -15 , -14 , -14 , -21 , -19 , -29},
{1534 , 3569 , 3138 , 4023 , 2105 , 2023 , 2046 , 1264 , 1340 , 1067 , 780 , 547 , 188 , -540 , -722 , -479}
-};
+}; // Q0
const Word32 Freq_Weight_Com_fx[160] = /*Q31 */
{
1073741824, 1351646720, 1610612736, 1832992000, 2003629568, 2110896768, 2147483647, 2147483647,
@@ -240,7 +240,7 @@ const Word32 sm_means_fx[N_SMC_FEATURES] =
{
114371648, 762918, 258533, 305622, 877131, 1071555, 1272603, 67350312,
1296274, -2461829, 1882791, -41135, -306269, 641721, 5859343,
-};
+}; // Q20
const Word32 sm_scale_fx[N_SMC_FEATURES] =
{//Q20
46789116, 166914, 66905, 70898, 117576, 108472, 96226, 17324576,
@@ -257,12 +257,12 @@ const Word32 bcox_add_cnst_fx[N_SMC_FEATURES] =
{
0, 0, -1886955264, -1559167616, 0, 0, 0, 0,
-1672874752, 0, 0, 0, 0, 0, 0,
-};
+}; // Q31
const Word32 bcox_lmbd_fx[N_SMC_FEATURES] =
{
0, 0, -1426534784, -907320448, 0, 0, 0, 0,
-1362524672, 0, 0, 0, 0, 0, 0,
-};
+}; // Q31
const Word32 pca_mean_fx[N_SMC_FEATURES] =
{
0, 0, 0, 0, 0, 0, 0, 0,
@@ -310,13 +310,8 @@ const Word32 means_speech_fx[N_SMC_MIXTURES*N_PCA_COEF] =
401886, 142397, -185738, 101340, -281425, -159212, -106902,
};
const Word32 log_det_chol_speech_fx[N_SMC_MIXTURES] =
-{//Q19
- 3408173,
- 3068506,
- 2925146,
- 3487906,
- 2491427,
- 2798882,
+{//Q18
+ 1704087, 1534253, 1462573, 1743953, 1245714, 1399441
};
const Word32 prec_chol_speech_fx[N_SMC_MIXTURES*(N_PCA_COEF*N_PCA_COEF + N_PCA_COEF) / 2] =
{
@@ -396,13 +391,8 @@ const Word32 means_music_fx[N_SMC_MIXTURES*N_PCA_COEF] =
-254348, -119888, 187975, 89841, -1729, -280392, 30281,
};
const Word32 log_det_chol_music_fx[N_SMC_MIXTURES] =
-{//Q19
- 1696729,
- 1843978,
- 2975523,
- 1507561,
- -1171774,
- 4174141,
+{//Q18
+ 848365, 921989, 1487762, 753781, -585887, 2087071,
};
const Word32 prec_chol_music_fx[N_SMC_MIXTURES*(N_PCA_COEF*N_PCA_COEF + N_PCA_COEF) / 2] =
{
@@ -482,13 +472,8 @@ const Word32 means_noise_fx[N_SMC_MIXTURES*N_PCA_COEF] =
-566101, 252900, 1677892, -314852, 1285163, 84872, -242426,
};
const Word32 log_det_chol_noise_fx[N_SMC_MIXTURES] =
-{//Q19
- 6227573,
- 6829164,
- 6727211,
- 3722206,
- 6943115,
- 6238179,
+{//Q18
+ 3113787, 3414582, 3363606, 1861103, 3471558, 3119090
};
const Word32 prec_chol_noise_fx[N_SMC_MIXTURES*(N_PCA_COEF*N_PCA_COEF + N_PCA_COEF) / 2] =
{
@@ -828,15 +813,15 @@ const Word32 lvm_noise_fx[N_MIXTURES] =
};
/* Mel filterbank */
-const int16_t mel_fb_start[NB_MEL_BANDS] =
+const Word16 mel_fb_start[NB_MEL_BANDS] =
{
1, 1, 2, 3, 4, 5, 5, 7, 8, 9, 10, 11, 13, 14, 16, 17, 19, 21, 23, 25, 28, 30, 33, 35, 38, 41, 45, 48, 52, 56, 60, 65, 69, 74, 80, 86, 92, 98, 105, 112
-};
+}; // Q0
-const int16_t mel_fb_len[NB_MEL_BANDS] =
+const Word16 mel_fb_len[NB_MEL_BANDS] =
{
1, 2, 2, 2, 1, 2, 3, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 5, 5, 5, 5, 5, 6, 7, 7, 7, 8, 8, 9, 9, 9, 11, 12, 12, 12, 13, 14, 15, 16
-};
+}; // Q0
const Word32 mel_fb_fx[246] =
{
1306887040, 840596608, 701826176, 1445657472, 297866656, 1849617024, 67613584, 2079870080,
@@ -870,7 +855,7 @@ const Word32 mel_fb_fx[246] =
1556051584, 1278092800, 1002327744, 728722176, 457242624, 187856208, 28791110, 311244128,
591432000, 869390912, 1145155968, 1418761472, 1690241024, 1959627392, 2068014592, 1802719104,
1539422848, 1278095872, 1018709056, 761233728, 505641920, 251906256,
-};
+}; // Q30
const Word32 dct_mtx_fx[NB_MEL_BANDS * NB_MEL_COEF] =
{ //Q31
479821728, 476863456, 470965184, 462163232, 450511904, 436083040, 418965536, 399264992,
@@ -987,61 +972,61 @@ const Word32 thren_pg_fx[44] =
3444,
};
/* Huffmann coding - searching thresholds for quantization of peak gains */
-const int16_t huffnorm_e[32] =
+const Word16 huffnorm_e[32] =
{
1062, 550, 314, 274, 273, 272, 156, 79, 69, 38,
18, 40, 5, 3, 0, 1, 3, 4, 11, 21,
41, 32, 35, 67, 133, 264, 530, 315, 551, 2126, 4254, 4255
-};
+}; // Q0
-const int16_t huffnorm_n[32] =
+const Word16 huffnorm_n[32] =
{
14831, 14830, 7414, 3706, 593, 927, 462, 297, 230, 116,
50, 36, 13, 8, 5, 1, 0, 2, 6, 7,
15, 19, 24, 56, 59, 51, 114, 117, 75, 149, 592, 1852
-};
+}; // Q0
-const int16_t huffsizn_e[32] =
+const Word16 huffsizn_e[32] =
{
13, 12, 11, 11, 11, 11, 10, 9, 9, 8,
7, 6, 5, 4, 3, 2, 2, 3, 4, 5,
6, 8, 8, 9, 10, 11, 12, 11, 12, 14, 15, 15
-};
+}; // Q0
-const int16_t huffsizn_n[32] =
+const Word16 huffsizn_n[32] =
{
14, 14, 13, 12, 10, 10, 9, 9, 8, 7,
7, 6, 5, 4, 3, 3, 3, 3, 3, 4,
4, 5, 6, 6, 6, 7, 7, 7, 7, 8, 10, 11
-};
+}; // Q0
-const int16_t resize_huffnorm[32] =
+const Word16 resize_huffnorm[32] =
{
0, 0, 0, 0, 0, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0,
2, 5, 11, 23, 47, 95, 191, 383, 767, 2047, 0, 0, 0, 0, 0, 0
-};
+}; // Q0
-const int16_t huffnorm[32] =
+const Word16 huffnorm[32] =
{
26, 58, 90, 122, 27, 59, 91, 123, 12, 28, 44, 60, 2, 6, 4, 6,
0, 2, 10, 14, 14, 30, 46, 62, 30, 62, 94, 126, 31, 63, 95, 127
-};
+}; // Q0
-const int16_t pgain_huffnorm[32] =
+const Word16 pgain_huffnorm[32] =
{
1, 1, 2, 3, 3, 2, 2, 2, 3, 3, 4, 5, 6, 7, 8, 9,
10, 11, 12, 13, 14, 15, 4, 5, 3, 2, 3, 3, 4, 5, 0, 1
-};
+}; // Q0
-const int16_t hessize[8]=
+const Word16 hessize[8]=
{
7, 5, 3, 2, 1, 4, 6, 7
-};
+}; // Q0
-const int16_t hescode[8]=
+const Word16 hescode[8]=
{
11, 3, 1, 1, 1, 0, 4, 10
-};
+}; // Q0
/*----------------------------------------------------------------------------------*
* BWD
@@ -1068,15 +1053,15 @@ const Word16 hann_window_320_fx[BWD_TOTAL_WIDTH / 2] =
7761, 7796, 7830, 7863, 7894, 7923, 7951, 7978,
8003, 8026, 8048, 8068, 8087, 8105, 8121, 8135,
8147, 8158, 8168, 8176, 8182, 8187, 8190, 8192
-};
+}; // Q13
/*----------------------------------------------------------------------------------*
* Starting line for the noise measurement in TCX.
*----------------------------------------------------------------------------------*/
-const int16_t startLineWB[N_TCX_STARTLINE_NOISE_WB] = { 8, 23, 36, 45, 66, 128 /* 13.2kbps */, 200, 320, 320, 320 /* 48kbps */, 320 };
+const Word16 startLineWB[N_TCX_STARTLINE_NOISE_WB] = { 8, 23, 36, 45, 66, 128 /* 13.2kbps */, 200, 320, 320, 320 /* 48kbps */, 320 }; // Q0
-const int16_t startLineSWB[N_TCX_STARTLINE_NOISE_SWB] = { 8, 44, 96 /* 13.2kbps */, 160, 320, 320, 256 /* 48kbps */, 341, 640 };
+const Word16 startLineSWB[N_TCX_STARTLINE_NOISE_SWB] = { 8, 44, 96 /* 13.2kbps */, 160, 320, 320, 256 /* 48kbps */, 341, 640 }; // Q0
const Word32 LS_MIN_SILENCE_SNR[4] = { 251658233/* 7.5 Q25 */, 251658233/* 7.5 Q25 */, 228170137/* 6.8 Q25 */,228170137/* 6.8 Q25 */ };
@@ -1096,7 +1081,7 @@ const UWord8 E_ROM_tipos[40] =
3, 0, 1, 2,
0, 1, 2, 3, /* end point for 24 pulses &ipos[35], 4th iter */
1, 2, 3, 0 /* end point for 36 pulses &ipos[39], 2nd iter */
-};
+}; // Q0
/* pow(3 * i + 1, 0.3) / pow(256 - 1, 0.3) */
const Word16 Weight[86] =
@@ -1109,7 +1094,7 @@ const Word16 Weight[86] =
0x7D61, 0x7DDA, 0x7E51, 0x7EC8, 0x7F3E, 0x7FB3, 0x7FFF
};
-const Word16 BAND_SCALE_AJ[5] = { 3,3,5,6,6 }; /* {OFFSET, NB, WB, SWB, FB} */
+const Word16 BAND_SCALE_AJ[5] = { 3,3,5,6,6 }; /* {OFFSET, NB, WB, SWB, FB} Q0*/
/* Inv possible delta used in gaus_enc (1.0/(1.0+delta*delta)) and delta = [1,7] */
const Word16 inv_delta_tab[7] = /*Q15*/
@@ -1210,4 +1195,4 @@ const complex_16 wnk_table_16[16] = {
/* integer square (i*i) */
const Word16 int_sqr[17] = {
0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256
-};
+}; // Q0
diff --git a/lib_enc/rom_enc.h b/lib_enc/rom_enc.h
index 8479d5b4b296cf15d83c50212e6a6a48f0b0bc09..bad6e9f8644c7ac770aae1b9ff4ea3c1c63d66b5 100644
--- a/lib_enc/rom_enc.h
+++ b/lib_enc/rom_enc.h
@@ -45,141 +45,141 @@
/*----------------------------------------------------------------------------------*
* General tables
*----------------------------------------------------------------------------------*/
-extern const Word16 sqrt_han_window_fx[]; /* Half of the square root hanning window */
-extern const int16_t tipos[]; /* Starting points for pulse position search in Algebraic innovation codebook */
-extern const Word16 W_HIST_FX[DTX_HIST_SIZE]; /* CNG & DTX - table for calculation of average excitation energy */
-extern const Word16 W_HIST_S_FX[DTX_HIST_SIZE]; /* CNG & DTX - table for calculation of average excitation energy */
+extern const Word16 sqrt_han_window_fx[]; /* Half of the square root hanning window Q15*/
+extern const Word16 tipos[]; /* Starting points for pulse position search in Algebraic innovation codebook Q0*/
+extern const Word16 W_HIST_FX[DTX_HIST_SIZE]; /* CNG & DTX - table for calculation of average excitation energy Q16*/
+extern const Word16 W_HIST_S_FX[DTX_HIST_SIZE]; /* CNG & DTX - table for calculation of average excitation energy Q12*/
-extern const int16_t bwd_start_bin[];
-extern const int16_t bwd_end_bin[];
-extern const float h_fir[]; /* 2nd order fir filter for wsp, decimation by 2 */
-extern const Word16 h_fir_fx[]; /* 2nd order fir filter for wsp, decimation by 2 */
-extern const Word16 preemphCompensation_fx[];
+extern const Word16 bwd_start_bin[]; // Q0
+extern const Word16 bwd_end_bin[]; // Q0
+extern const float h_fir[]; /* 2nd order fir filter for wsp, decimation by 2 */
+extern const Word16 h_fir_fx[]; /* 2nd order fir filter for wsp, decimation by 2 Q15*/
+extern const Word16 preemphCompensation_fx[]; // Q11
/*----------------------------------------------------------------------------------*
* VAD tables
*----------------------------------------------------------------------------------*/
-extern const int16_t hangover_hd_tbl[3];
-extern const int16_t hangover_sf_tbl[6];
+extern const Word16 hangover_hd_tbl[3]; // Q0
+extern const Word16 hangover_sf_tbl[6]; // Q0
/*----------------------------------------------------------------------------------*
* Open-loop pitch search tables
*----------------------------------------------------------------------------------*/
-extern const int16_t nb_sect_12k8[];
-extern const int16_t nb_subsect_12k8[];
-extern const int16_t len_12k8[];
-extern const int16_t len1_12k8[];
-extern const int16_t sublen_12k8[];
-extern const int16_t sublen1_12k8[];
-extern const int16_t pit_max_12k8[];
-extern const int16_t sec_length_12k8[];
-extern const int16_t sec_length1_12k8[];
+extern const Word16 nb_sect_12k8[]; // Q0
+extern const Word16 nb_subsect_12k8[]; // Q0
+extern const Word16 len_12k8[]; // Q0
+extern const Word16 len1_12k8[]; // Q0
+extern const Word16 sublen_12k8[]; // Q0
+extern const Word16 sublen1_12k8[]; // Q0
+extern const Word16 pit_max_12k8[]; // Q0
+extern const Word16 sec_length_12k8[]; // Q0
+extern const Word16 sec_length1_12k8[]; // Q0
/*----------------------------------------------------------------------------------*
* LSF quantizer
*----------------------------------------------------------------------------------*/
-extern const int16_t lsf_numlevels[TCXLPC_NUMSTAGES];
-extern const int16_t lsf_ind_numlevels[TCXLPC_IND_NUMSTAGES];
+extern const Word16 lsf_numlevels[TCXLPC_NUMSTAGES]; // Q0
+extern const Word16 lsf_ind_numlevels[TCXLPC_IND_NUMSTAGES]; // Q0
-extern const int16_t lsf_unified_fit_model_nb[4][16];
-extern const int16_t lsf_unified_fit_model_wb[4][16];
-extern const int16_t lsf_unified_fit_model_wbhb[4][16];
-extern const Word32 Freq_Weight_Com_fx[160];
-extern const Word32 Freq_Weight_UV_fx[160];
+extern const Word16 lsf_unified_fit_model_nb[4][16]; // Q0
+extern const Word16 lsf_unified_fit_model_wb[4][16]; // Q0
+extern const Word16 lsf_unified_fit_model_wbhb[4][16]; // Q0
+extern const Word32 Freq_Weight_Com_fx[160]; // Q31
+extern const Word32 Freq_Weight_UV_fx[160]; // Q31
/*----------------------------------------------------------------------------------*
* Speech/music classification
*----------------------------------------------------------------------------------*/
-extern const Word16 w_spmus_fx[HANG_LEN][HANG_LEN];
-extern const Word32 pca_components_fx[];
+extern const Word16 w_spmus_fx[HANG_LEN][HANG_LEN]; // Q15
+extern const Word32 pca_components_fx[]; // Q31
extern const Word32 pca_mean_fx[];
-extern const Word32 sm_means_fx[];
-extern const Word32 sm_scale_fx[];
-extern const Word32 bcox_lmbd_fx[N_SMC_FEATURES];
-extern const Word32 hout_intervals_fx[];
-extern const Word32 bcox_add_cnst_fx[N_SMC_FEATURES];
-extern const Word32 prec_chol_speech_fx[];
-extern const Word32 prec_chol_music_fx[];
-extern const Word32 prec_chol_noise_fx[];
-extern const Word32 means_speech_fx[]; // Q20
-extern const Word32 means_music_fx[]; // Q20
-extern const Word32 means_noise_fx[]; // Q20
-extern const Word32 mel_fb_fx[];
-extern const Word32 dct_mtx_fx[];
-extern const Word32 log_det_chol_speech_fx[]; // Q19
-extern const Word32 log_det_chol_music_fx[]; // Q19
-extern const Word32 log_det_chol_noise_fx[]; // Q19
-extern const Word16 m_speech_fx[];
-extern const Word32 invV_speech_fx[];
-extern const Word32 lvm_speech_fx[];
-
-extern const Word32 prec_chol_speech_fx[];
-extern const Word32 prec_chol_music_fx[];
-extern const Word32 prec_chol_noise_fx[];
-extern const Word16 m_music_fx[];
-extern const Word32 invV_music_fx[];
-extern const Word32 lvm_music_fx[];
-extern const Word16 m_noise_fx[];
-extern const Word32 invV_noise_fx[];
-extern const Word32 lvm_noise_fx[];
-
-extern const int16_t mel_fb_start[];
-extern const int16_t mel_fb_len[];
-extern const Word16 hann_window_320_fx[];
+extern const Word32 sm_means_fx[]; // Q20
+extern const Word32 sm_scale_fx[]; // Q20
+extern const Word32 bcox_lmbd_fx[N_SMC_FEATURES]; // Q31
+extern const Word32 hout_intervals_fx[]; // Q20
+extern const Word32 bcox_add_cnst_fx[N_SMC_FEATURES]; // Q31
+extern const Word32 prec_chol_speech_fx[]; // Q28
+extern const Word32 prec_chol_music_fx[]; // Q28
+extern const Word32 prec_chol_noise_fx[]; // Q28
+extern const Word32 means_speech_fx[]; // Q20
+extern const Word32 means_music_fx[]; // Q20
+extern const Word32 means_noise_fx[]; // Q20
+extern const Word32 mel_fb_fx[]; // Q30
+extern const Word32 dct_mtx_fx[]; // Q31
+extern const Word32 log_det_chol_speech_fx[]; // Q19
+extern const Word32 log_det_chol_music_fx[]; // Q19
+extern const Word32 log_det_chol_noise_fx[]; // Q19
+extern const Word16 m_speech_fx[]; // Q15
+extern const Word32 invV_speech_fx[]; // Q10
+extern const Word32 lvm_speech_fx[]; // Q10
+
+extern const Word32 prec_chol_speech_fx[]; // Q28
+extern const Word32 prec_chol_music_fx[]; // Q28
+extern const Word32 prec_chol_noise_fx[]; // Q28
+extern const Word16 m_music_fx[]; // Q15
+extern const Word32 invV_music_fx[]; // Q10
+extern const Word32 lvm_music_fx[]; // Q10
+extern const Word16 m_noise_fx[]; // Q15
+extern const Word32 invV_noise_fx[]; // Q10
+extern const Word32 lvm_noise_fx[]; // Q10
+
+extern const Word16 mel_fb_start[]; // Q0
+extern const Word16 mel_fb_len[]; // Q0
+extern const Word16 hann_window_320_fx[]; // Q13
/*----------------------------------------------------------------------------------*
* Huffman coding
*----------------------------------------------------------------------------------*/
-extern const int16_t huffsizn_e[32];
-extern const int16_t huffsizn_n[32];
+extern const Word16 huffsizn_e[32]; // Q0
+extern const Word16 huffsizn_n[32]; // Q0
-extern const int16_t huffnorm_e[32];
-extern const int16_t huffnorm_n[32];
-extern const int16_t hessize[8];
-extern const int16_t hescode[8];
+extern const Word16 huffnorm_e[32]; // Q0
+extern const Word16 huffnorm_n[32]; // Q0
+extern const Word16 hessize[8]; // Q0
+extern const Word16 hescode[8]; // Q0
/*----------------------------------------------------------------------------------*
* VAD
*----------------------------------------------------------------------------------*/
-extern const int16_t BAND_NUM_TAB[5];
+extern const Word16 BAND_NUM_TAB[5]; // Q0
extern const complex_16 M_in_fix16[16];
-extern const Word16 M_Wr_fix16[16];
-extern const Word16 M_Wi_fix16[16];
-extern const int16_t SP_CENTER_BAND_NUM_TAB[5];
-extern const int16_t NREGION_INDEX_NB[9];
-extern const int16_t NREGION_INDEX_WB[13];
-extern const int16_t NREGION_INDEX_SWB[16];
-extern const int16_t NREGION_INDEX_FB[16];
-extern const Word16 NREGION_PREOFF[16];
-extern const int16_t ENERGY_BAND_NUM[4];
-extern const int16_t *REGION_INDEX[4];
-extern const Word32 MAX_LF_SNR_TAB_FX[4];
-extern const Word32 COMVAD_INIT_SNR_DELTA_FX[5];
-extern const Word32 LT_MIN_SILENCE_SNR_FX[4];
+extern const Word16 M_Wr_fix16[16]; // Q15
+extern const Word16 M_Wi_fix16[16]; // Q15
+extern const Word16 SP_CENTER_BAND_NUM_TAB[5]; // Q0
+extern const Word16 NREGION_INDEX_NB[9]; // Q0
+extern const Word16 NREGION_INDEX_WB[13]; // Q0
+extern const Word16 NREGION_INDEX_SWB[16]; // Q0
+extern const Word16 NREGION_INDEX_FB[16]; // Q0
+extern const Word16 NREGION_PREOFF[16]; // Q0
+extern const Word16 ENERGY_BAND_NUM[4]; // Q0
+extern const Word16 *REGION_INDEX[4]; // Q0
+extern const Word32 MAX_LF_SNR_TAB_FX[4]; // Q25
+extern const Word32 COMVAD_INIT_SNR_DELTA_FX[5]; // Q25
+extern const Word32 LT_MIN_SILENCE_SNR_FX[4]; // Q25
/*----------------------------------------------------------------------------------*
* Starting line for the noise measurement in TCX.
*----------------------------------------------------------------------------------*/
-extern const int16_t startLineWB[N_TCX_STARTLINE_NOISE_WB];
-extern const int16_t startLineSWB[N_TCX_STARTLINE_NOISE_SWB];
+extern const Word16 startLineWB[N_TCX_STARTLINE_NOISE_WB]; // Q0
+extern const Word16 startLineSWB[N_TCX_STARTLINE_NOISE_SWB]; // Q0
// EVS basop
-extern const Word32 LS_MIN_SILENCE_SNR[4];
-extern const Word16 SNR_SUB_BAND_NUM[4];
-extern const Word16 BAND_MUL[4];
+extern const Word32 LS_MIN_SILENCE_SNR[4]; // Q25
+extern const Word16 SNR_SUB_BAND_NUM[4]; // Q0
+extern const Word16 BAND_MUL[4]; // Q15
-extern const UWord8 E_ROM_tipos[]; /* ACELP indexing */
+extern const UWord8 E_ROM_tipos[]; /* ACELP indexing Q0*/
extern const Word16 Weight[86];
-extern const Word16 BAND_SCALE_AJ[5];
-extern const Word16 inv_delta_tab[7];
+extern const Word16 BAND_SCALE_AJ[5]; // Q0
+extern const Word16 inv_delta_tab[7]; // Q15
extern const Word16 i_t_1[10];
extern const Word16 i_t_2[23];
extern const Word16 SF_mult_fx[N_FEATURES];
diff --git a/lib_enc/rst_enc.c b/lib_enc/rst_enc.c
deleted file mode 100644
index fd4f3cb7c53af6bc1a4a149c6db6799b8f39655e..0000000000000000000000000000000000000000
--- a/lib_enc/rst_enc.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 "rom_com.h"
-#include "prot.h"
-#include "wmc_auto.h"
diff --git a/lib_enc/rst_enc_fx.c b/lib_enc/rst_enc_fx.c
index 85821ef0b028b6e360b6a57d40979f86ecd85985..d519bc12f9db4e464b977c66e13b329713fb216e 100644
--- a/lib_enc/rst_enc_fx.c
+++ b/lib_enc/rst_enc_fx.c
@@ -20,14 +20,15 @@
void CNG_reset_enc_fx(
Encoder_State *st_fx, /* i/o: encoder state structure */
LPD_state_HANDLE hLPDmem, /* i/o: acelp memories */
- Word16 *pitch_buf, /* o : floating pitch for each subframe */
- Word16 *voice_factors, /* o : voicing factors */
- Word16 VBR_cng_reset_flag )
+ Word16 *pitch_buf, /* o : floating pitch for each subframe Q6*/
+ Word16 *voice_factors, /* o : voicing factors Q15*/
+ Word16 VBR_cng_reset_flag /* Q0 */
+)
{
TD_CNG_ENC_HANDLE hTdCngEnc = st_fx->hTdCngEnc;
init_gp_clip_fx( st_fx->clip_var_fx );
- Copy( UVWB_Ave_fx, st_fx->mem_AR_fx, M );
+ Copy( UVWB_Ave_fx, st_fx->mem_AR_fx, M ); /* Qlog2(2.56) */
set16_fx( st_fx->mem_MA_fx, 0, M );
hLPDmem->mem_w0 = 0;
move16();
diff --git a/lib_enc/scale_enc_fx.c b/lib_enc/scale_enc_fx.c
index cfb3568bb669ed9fa5279c0f59236dfc84d98689..76eae22b7b1f21cc40f7593b1cf4e5fcff81da16 100644
--- a/lib_enc/scale_enc_fx.c
+++ b/lib_enc/scale_enc_fx.c
@@ -24,7 +24,7 @@ void Scale_wsp(
Word16 *old_wsp, /* i/o: Old weighted speech buffer */
Word16 *mem_decim2, /* i/o: Decimation buffer */
Word16 *old_wsp12k8, /* i/o: wsp memory @ 12.8 kHz used in pitol2 */
- const Word16 Len_p_look /* i : L_frame + look ahead */
+ const Word16 Len_p_look /* i : L_frame + look ahead Q0*/
)
{
Word16 max, i, tmp;
@@ -69,17 +69,17 @@ void Scale_wsp(
* Find scaled preemphasis vector and its scaling factor
*-------------------------------------------------------------------*/
void Preemph_scaled(
- Word16 new_speech[], /* i : Speech to scale already on 14 bits*/
- Word16 *Q_new, /* o : Scaling factor */
- Word16 *mem_preemph, /* i/o: Preemph memory */
- Word16 *Q_max, /* i/o: Q_new limitation */
- const Word16 Preemph_factor, /* i : Preemphasis factor Q15 */
- const Word16 bits, /* i : Bit to remove from the output to (15-bits)*/
- const Word16 bit1, /* i : Limit the output scaling to ((15-bits)-bit1) bits */
- const Word16 L_Q_mem, /* i : Number of old scaling to take into account */
- const Word16 Lframe, /* i : Frame length */
- const Word16 last_coder_type, /* i : coder_type */
- const Word16 Search_scaling /* i : enable the search of a proper scaling factor*/
+ Word16 new_speech[], /* i : Speech to scale already on 14 bits Q_new*/
+ Word16 *Q_new, /* o : Scaling factor */
+ Word16 *mem_preemph, /* i/o: Preemph memory Q(-1)*/
+ Word16 *Q_max, /* i/o: Q_new limitation */
+ const Word16 Preemph_factor, /* i : Preemphasis factor Q15*/
+ const Word16 bits, /* i : Bit to remove from the output to (15-bits) */
+ const Word16 bit1, /* i : Limit the output scaling to ((15-bits)-bit1) bits */
+ const Word16 L_Q_mem, /* i : Number of old scaling to take into account Q0*/
+ const Word16 Lframe, /* i : Frame length Q0*/
+ const Word16 last_coder_type, /* i : coder_type Q0*/
+ const Word16 Search_scaling /* i : enable the search of a proper scaling factor Q0*/
)
{
Word16 i, tmp_fixed;
@@ -88,6 +88,7 @@ void Preemph_scaled(
Word16 Q_min;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/*---------------------------------------------------------------*
@@ -96,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) */
@@ -110,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++ )
@@ -122,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 );
}
@@ -170,35 +159,21 @@ void Preemph_scaled(
* Done backwards to save storage space
*---------------------------------------------------------------*/
- tmp_fixed = new_speech[Lframe - 1];
+ tmp_fixed = new_speech[Lframe - 1]; // Q_new
move16();
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 );
-#else
- new_speech[i] = round_fx( L_tmp );
-#endif
+ new_speech[i] = round_fx_sat( L_tmp ); // Q_new
}
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();
}
@@ -208,17 +183,17 @@ void Preemph_scaled(
* Rescale memories
*-------------------------------------------------------------------*/
Word32 Scale_mem_pre_proc( /* o : Min energy scaled */
- Word16 ini_frame_fx, /* i : Frame number */
+ Word16 ini_frame_fx, /* i : Frame number Q0*/
Word16 Q_exp, /* i : Diff scaling factor */
Word16 *Q_new, /* i/o: Absolute scaling factor */
Word16 *old_speech, /* i/o: Speech memory */
- Word16 *mem_wsp, /* i/o: wsp vector memory */
- Word32 *enrO, /* i/o: Enr mem */
- Word32 *bckr, /* i/o: Back ground_fx ener mem */
- Word32 *ave_enr, /* i/o: Ave_enr mem */
- Word32 *ave_enr2, /* i/o: Ave_enr2 mem */
- Word32 *st_fr_bands1, /* i/o: spectrum per critical bands of the previous frame */
- Word32 *st_fr_bands2, /* i/o: spectrum per critical bands 2 frames ago */
+ Word16 *mem_wsp, /* i/o: wsp vector memory st->mem_wsp_q*/
+ Word32 *enrO, /* i/o: Enr mem q_enrO*/
+ Word32 *bckr, /* i/o: Back ground_fx ener mem q_bckr*/
+ Word32 *ave_enr, /* i/o: Ave_enr mem Q_new + QSCALE*/
+ Word32 *ave_enr2, /* i/o: Ave_enr2 mem Q_new + QSCALE*/
+ Word32 *st_fr_bands1, /* i/o: spectrum per critical bands of the previous frame Q_new + QSCALE*/
+ Word32 *st_fr_bands2, /* i/o: spectrum per critical bands 2 frames ago Q_new + QSCALE*/
Word32 *st_Bin_E_old )
{
Word16 i;
@@ -254,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.c b/lib_enc/set_impulse.c
deleted file mode 100644
index fd4f3cb7c53af6bc1a4a149c6db6799b8f39655e..0000000000000000000000000000000000000000
--- a/lib_enc/set_impulse.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 "rom_com.h"
-#include "prot.h"
-#include "wmc_auto.h"
diff --git a/lib_enc/set_impulse_fx.c b/lib_enc/set_impulse_fx.c
index ebdfe868973b39312baa154696c596ea89192f0c..9ad5f4a2cdb9a4bab773a1008a6b70cb948771af 100644
--- a/lib_enc/set_impulse_fx.c
+++ b/lib_enc/set_impulse_fx.c
@@ -47,14 +47,14 @@ static void convolve_tc2_fx( const Word16 g[], const Word16 h[], Word16 y[], con
* *
*---------------------------------------------------------------------------------------*/
void set_impulse_fx(
- const Word16 xn_fx[], /* i : target signal */
- const Word16 h_orig_fx[], /* i : impulse response of weighted synthesis filter */
- Word16 exc_fx[], /* o : adaptive codebook excitation */
- Word16 yy1_fx[], /* o : filtered adaptive codebook excitation */
- Word16 *imp_shape, /* o : adaptive codebook index */
- Word16 *imp_pos, /* o : position of the glottal impulse center index */
- Word32 *gain_trans_fx, /* o : transition gain Q7 */
- Word16 Q_new /* i : Current scaling */
+ const Word16 xn_fx[], /* i : target signal Q_new-1+shift*/
+ const Word16 h_orig_fx[], /* i : impulse response of weighted synthesis filter Q(14+shift)*/
+ Word16 exc_fx[], /* o : adaptive codebook excitation Q_new*/
+ Word16 yy1_fx[], /* o : filtered adaptive codebook excitation Q_new*/
+ Word16 *imp_shape, /* o : adaptive codebook index Q0*/
+ Word16 *imp_pos, /* o : position of the glottal impulse center index Q0*/
+ Word32 *gain_trans_fx, /* o : transition gain Q7*/
+ Word16 Q_new /* i : Current scaling */
)
{
Word16 i, j, m;
@@ -67,6 +67,7 @@ void set_impulse_fx(
const Word16 *pt_Glt;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
krit_max_fx = -32768;
move16();
@@ -78,7 +79,7 @@ void set_impulse_fx(
/* set searching ranges */
IF( LT_16( *imp_pos, L_SUBFR - INPOL ) )
{
- end1 = add( *imp_pos, INPOL );
+ end1 = add( *imp_pos, INPOL ); // Q0
}
ELSE
{
@@ -87,7 +88,7 @@ void set_impulse_fx(
}
IF( GT_16( *imp_pos, INPOL ) )
{
- start1 = sub( *imp_pos, INPOL );
+ start1 = sub( *imp_pos, INPOL ); // Q0
}
ELSE
{
@@ -118,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 );
- Ldd = L_mac_o( Ldd, gh_fx[i], xn_fx[i], &Overflow );
-#else
- Lrr = L_mac( Lrr, gh_fx[i], gh_fx[i] );
- Ldd = L_mac( Ldd, gh_fx[i], xn_fx[i] );
-#endif
+ 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
}
rr_fx[start1] = Lrr;
move32();
-#ifdef BASOP_NOGLOB
- dd_fx[start1] = round_fx_o( Ldd, &Overflow );
-#else
- dd_fx[start1] = round_fx( Ldd );
-#endif
+ dd_fx[start1] = round_fx_o( Ldd, &Overflow ); // Q11
rr_fx[start1] = L_max( rr_fx[start1], 1 );
FOR( i = add( start1, 1 ); i < L_IMPULSE2; i++ )
@@ -144,28 +136,17 @@ void set_impulse_fx(
{
/* gh_fx[j] = gh_fx[j-1] + glottal_cdbk[m*L_IMPULSE+L_IMPULSE2-i]*h_orig_fx[j] */
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] );
+ 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 );
- Ldd = L_mac_o( Ldd, gh_fx[j], xn_fx[j], &Overflow );
-#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 */
+ 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
}
- gh_fx[0] = mult_r( Glottal_cdbk_fx[m * L_IMPULSE + L_IMPULSE2 - i], h_orig_fx[0] );
+ 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 );
- Ldd = L_mac_o( Ldd, gh_fx[0], xn_fx[0], &Overflow );
- dd_fx[i] = round_fx_sat( Ldd );
-#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
+ 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
rr_fx[i] = L_max( Lrr, 1 );
move32();
/* move rr and dd into rr[i] and dd[i] */
@@ -175,7 +156,7 @@ void set_impulse_fx(
FOR( j = L_SUBFR - 1; j > 0; j-- )
{
gh_fx[j] = mac_r( L_deposit_h( gh_fx[j - 1] ),
- Glottal_cdbk_fx[m * L_IMPULSE], h_orig_fx[j] );
+ Glottal_cdbk_fx[m * L_IMPULSE], h_orig_fx[j] ); // Q13
}
}
ELSE
@@ -186,15 +167,11 @@ void set_impulse_fx(
IF( GE_16( end1, start2 ) )
{
/* DEnominator row */
- Lrr = L_mult( gh_fx[0], gh_fx[0] );
+ Lrr = L_mult( gh_fx[0], gh_fx[0] ); // Q27
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] );
-#else
- Lrr = L_mac( Lrr, gh_fx[j], gh_fx[j] );
-#endif
+ Lrr = L_mac_sat( Lrr, gh_fx[j], gh_fx[j] ); // Q27
}
rr_fx[L_SUBFR - 1] = Lrr;
move32();
@@ -202,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 );
-#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
+ gh_fx[L_SUBFR + L_IMPULSE2 - 1 - i], &Overflow ); // Q27
move32();
}
/* nominator rows */
@@ -229,15 +201,11 @@ 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 ) )
{
- krit_max_fx = krit_fx;
+ krit_max_fx = krit_fx; // Q18
move16();
*imp_pos = i;
move16();
@@ -254,7 +222,7 @@ void set_impulse_fx(
set16_fx( exc_fx, 0, L_SUBFR );
set16_fx( yy1_fx, 0, L_SUBFR );
tmp16 = sub( extract_l( L_mac0( L_IMPULSE2, *imp_shape, L_IMPULSE ) ), *imp_pos );
- pt_Glt = &Glottal_cdbk_fx[tmp16];
+ pt_Glt = &Glottal_cdbk_fx[tmp16]; // Q13
move16();
j = add( *imp_pos, L_IMPULSE2 );
FOR( i = sub( *imp_pos, L_IMPULSE2 ); i <= j; i++ )
@@ -290,9 +258,9 @@ void set_impulse_fx(
gain16 = div_s( num, den );
i = add( exp_num, sub( Q_new, 1 + 1 + 3 ) );
- i = sub( i, exp_den ); /* Gain_trans in Q7 */
- gain16 = i_mult2( gain16, tmp16 ); /* apply sign */
- *gain_trans_fx = L_shr( L_deposit_l( gain16 ), i );
+ i = sub( i, exp_den ); /* Gain_trans in Q7 */
+ gain16 = i_mult2( gain16, tmp16 ); /* apply sign */
+ *gain_trans_fx = L_shr( L_deposit_l( gain16 ), i ); // Q7
move32();
}
/*-------------------------------------------------------------------*
@@ -304,8 +272,8 @@ static void convolve_tc_fx(
const Word16 g[], /* i : input vector Qx */
const Word16 h[], /* i : impulse response (or second input vector) Q15 */
Word16 y[], /* o : output vector (result of convolution) 12 bits */
- const Word16 L_1, /* i : vector h size */
- const Word16 L_2 /* i : vector g size */
+ const Word16 L_1, /* i : vector h size Q0 */
+ const Word16 L_2 /* i : vector g size Q0 */
)
{
Word16 i, n, len;
@@ -314,13 +282,13 @@ static void convolve_tc_fx(
FOR( n = 0; n < L_2; n++ )
{
len = s_min( add( n, 1 ), L_1 );
- L_sum = L_mult( g[0], h[n] );
+ L_sum = L_mult( g[0], h[n] ); /* Qx */
FOR( i = 1; i < len; i++ )
{
- L_sum = L_mac( L_sum, g[i], h[n - i] );
+ L_sum = L_mac( L_sum, g[i], h[n - i] ); /* Qx + 16 */
}
- y[n] = round_fx( L_sum ); /* Q12*/
+ y[n] = round_fx( L_sum ); /* Qx */
}
}
/*-------------------------------------------------------------------*
@@ -332,29 +300,29 @@ static void convolve_tc2_fx(
const Word16 g[], /* i : input vector Qx */
const Word16 h[], /* i : impulse response (or second input vector) Q15 */
Word16 y[], /* o : output vector (result of convolution) 12 bits */
- const Word16 pos_max /* o : artificial impulse position */
+ const Word16 pos_max /* o : artificial impulse position Q0 */
)
{
Word32 temp;
Word16 i, n;
Word16 i_start, i_end, i_end2;
- i_start = sub( pos_max, L_IMPULSE2 );
+ i_start = sub( pos_max, L_IMPULSE2 ); // Q0
i_start = s_max( i_start, 0 );
- i_end = add( pos_max, L_IMPULSE );
+ i_end = add( pos_max, L_IMPULSE ); // Q0
i_end = s_min( i_end, L_SUBFR );
FOR( n = i_start; n < L_SUBFR; n++ )
{
- temp = L_mult( g[0], h[n] );
+ temp = L_mult( g[0], h[n] ); /* Qx + 16 */
i_end2 = s_min( add( n, 1 ), i_end );
FOR( i = 1; i < i_end2; i++ )
{
- temp = L_mac( temp, g[i], h[n - i] );
+ temp = L_mac( temp, g[i], h[n - i] ); // Qx + 16
}
- y[n] = round_fx( temp );
+ y[n] = round_fx( temp ); // Qx
}
}
/*-------------------------------------------------------------------*
@@ -363,12 +331,12 @@ static void convolve_tc2_fx(
* correlation for different vectors' lengths
*-------------------------------------------------------------------*/
static void correlate_tc_fx(
- const Word16 *x, /* i: target signal */
- Word16 *y, /* o: correlation between x[] and h[] -Q3 */
- const Word16 *h, /* i: impulse response (of weighted synthesis filter) */
- const Word16 start, /* i: index of iterest */
- const Word16 L_1, /* i: vector size */
- const Word16 L_2 /* i: index of interest */
+ const Word16 *x, /* i: target signal Qx*/
+ Word16 *y, /* o: correlation between x[] and h[] -Q3*/
+ const Word16 *h, /* i: impulse response (of weighted synthesis filter) Q15*/
+ const Word16 start, /* i: index of iterest Q0*/
+ const Word16 L_1, /* i: vector size Q0*/
+ const Word16 L_2 /* i: index of interest Q0*/
)
{
Word16 i, j;
@@ -379,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] );
-#else
- s = L_mac( s, x[j], h[j - i] );
-#endif
+ s = L_mac_sat( s, x[j], h[j - i] ); /* Qx + 16 */
}
-#ifdef BASOP_NOGLOB
- y[i] = round_fx_sat( s );
-#else
- y[i] = round_fx( s );
-#endif
+ y[i] = round_fx_sat( s ); /* Qx */
}
}
diff --git a/lib_enc/setmodeindex.c b/lib_enc/setmodeindex.c
index 8c2130280a4b05b2e28e395bc076bb63ed98778f..1cc6168c38f3cdd3925f9c0cb17afa3e21aefa0b 100644
--- a/lib_enc/setmodeindex.c
+++ b/lib_enc/setmodeindex.c
@@ -54,12 +54,12 @@
void SetModeIndex_ivas_fx(
Encoder_State *st, /* i : Encoder state */
- const Word32 last_total_brate, /* i : last total bitrate */
- const Word16 last_element_mode, /* i : last IVAS element mode */
- const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) */
+ const Word32 last_total_brate, /* i : last total bitrate Q0*/
+ const Word16 last_element_mode, /* i : last IVAS element mode Q0*/
+ const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) Q0*/
)
{
- Word16 ini_frame_loc = st->ini_frame;
+ Word16 ini_frame_loc = st->ini_frame; // Q0
move16();
test();
@@ -85,12 +85,12 @@ void SetModeIndex_ivas_fx(
( EQ_16( st->last_codec_mode, MODE1 ) && EQ_16( st->element_mode, EVS_MONO ) ) ||
( ( NE_16( st->last_core, TCX_20_CORE ) && NE_16( st->last_core, TCX_10_CORE ) ) && GT_16( st->element_mode, EVS_MONO ) ) ||
( NE_16( st->rf_mode_last, st->rf_mode ) ) ||
- ( GT_16( st->element_mode, EVS_MONO ) && st->ini_frame == 0 ) )
+ ( st->element_mode > EVS_MONO && st->ini_frame == 0 ) )
{
core_coder_mode_switch_ivas_fx( st, last_total_brate, MCT_flag );
}
- st->ini_frame = ini_frame_loc;
+ st->ini_frame = ini_frame_loc; // Q0
move16();
return;
diff --git a/lib_enc/setmodeindex_fx.c b/lib_enc/setmodeindex_fx.c
index dff13ec8964ba2be52e6649edb3e78c08ff5fdfa..fc3025f5132805d4827637794a00375fb9202f2d 100644
--- a/lib_enc/setmodeindex_fx.c
+++ b/lib_enc/setmodeindex_fx.c
@@ -4,7 +4,6 @@
#include
#include "options.h"
-//#include "prot_fx.h"
#include "cnst.h"
#include "rom_com_fx.h"
#include "rom_enc.h"
@@ -23,12 +22,12 @@
void SetModeIndex_fx(
Encoder_State *st,
- Word32 last_total_brate,
- const Word16 last_element_mode,
- const Word16 is_mct,
+ Word32 last_total_brate, /* Q0 */
+ const Word16 last_element_mode, /* Q0 */
+ const Word16 is_mct, /* Q0 */
const Word16 shift )
{
- Word16 ini_frame_loc = st->ini_frame;
+ Word16 ini_frame_loc = st->ini_frame; // Q0
test();
test();
@@ -52,7 +51,7 @@ void SetModeIndex_fx(
{
core_coder_mode_switch_fx( st, last_total_brate, is_mct, shift );
}
- st->ini_frame = ini_frame_loc;
+ st->ini_frame = ini_frame_loc; // Q0
return;
}
diff --git a/lib_enc/sig_clas.c b/lib_enc/sig_clas.c
deleted file mode 100644
index 0828accec986944779b557c4d45118d355476c85..0000000000000000000000000000000000000000
--- a/lib_enc/sig_clas.c
+++ /dev/null
@@ -1,59 +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
- *---------------------------------------------------------------------*/
-
-#define K_COR_ENC 2.857f
-#define C_COR_ENC -1.286f
-#define K_EE_ENC 0.04167f
-#define C_EE_ENC 0.0f
-#define K_ZC_ENC -0.04f
-#define C_ZC_ENC 2.4f
-#define K_RELE_ENC 0.05f
-#define C_RELE_ENC 0.45f
-#define K_PC_ENC -0.07143f
-#define C_PC_ENC 1.857f
-#define K_SNR_ENC 0.1111f
-#define C_SNR_ENC -0.3333f
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 6f8fba9f1e49c0fc7f74d14ca84ab9f1a4522b38..32b521ef46060a8c68b6bdcc932f9220f458847f 100644
--- a/lib_enc/speech_music_classif_fx.c
+++ b/lib_enc/speech_music_classif_fx.c
@@ -32,7 +32,7 @@
#define LOG_PROB_CONST 11292 /*0.5f * N_FEATURES * LOG_PI2 in Q10 */
#define DLP_BIAS 0.138121f
-#define DLP_BIAS_FX 72415 /*Q19*/
+#define DLP_BIAS_FX 36208 /*Q18*/
#define TON_ALPHA_FX 31130 /* 0.95f in Q15 */
#define THR_MASS_MAX_FX 3565158 /* 0.85f in Q22 */
@@ -69,30 +69,15 @@ static Word16 attack_det_fx( const Word16 *inp, const Word16 Qx, const Word16 la
static void order_spectrum_fx( Word16 *vec, Word16 len );
static void detect_sparseness_fx( Encoder_State *st_fx, const Word16 localVAD_HE_SAD, const Word16 voi_fv );
-// Q19
+// Q18
Word32 log_weights_speech_compute[N_SMC_MIXTURES] = {
- -1156091,
- -966805,
- -946740,
- -936304,
- -758939,
- -946469,
+ -578045, -483403, -473370, -468152, -379470, -473234
};
Word32 log_weights_music_compute[N_SMC_MIXTURES] = {
- -973594,
- -1045660,
- -631047,
- -859997,
- -1551963,
- -954511,
+ -486797, -522830, -315523, -429999, -775981, -477255
};
Word32 log_weights_noise_compute[N_SMC_MIXTURES] = {
- -879882,
- -1153486,
- -538486,
- -1290903,
- -1058455,
- -1084391,
+ -439941, -576743, -269243, -645452, -529228, -542196
};
/*---------------------------------------------------------------------*
* speech_music_clas_init_fx()
@@ -104,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;
@@ -218,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 );
@@ -283,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;
@@ -404,8 +392,13 @@ 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;
+ move16();
+
hSpMusClas->last_strong_attack = 0;
move16();
hSpMusClas->tdm_lt_Etot_fx = 3; /* 0.01f in Q8 */
@@ -522,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 );
@@ -594,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
@@ -611,6 +602,7 @@ void speech_music_classif_fx(
ELSE
{
st->sp_aud_decision0 = st->sp_aud_decision1;
+ move16();
}
@@ -661,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
/*------------------------------------------------------------------*
@@ -697,6 +704,7 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis
ELSE
{
*pFV++ = round_fx( L_tmp );
+ move16();
}
/* [1] voicing Q15 */
@@ -712,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*/
@@ -739,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();
@@ -798,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++ )
@@ -817,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 );
@@ -891,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 );
@@ -907,21 +898,29 @@ 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 */
- ps_sta = L_add( ps_sta, L_tmp ); /*Q16 */
+#ifdef FIX_ISSUE_1151
+ ps_sta = L_add_sat( ps_sta, L_tmp ); /*Q16 */
+#else
+ ps_sta = L_add( ps_sta, L_tmp ); /*Q16 */
+#endif
}
}
/**pFV++ = (float)log(ps_sta + 1e-5f);*/
+#ifdef FIX_ISSUE_1151
+ ps_sta = L_add_sat( ps_sta, 336 );
+#else
ps_sta = L_add( ps_sta, 336 );
+#endif
e_tmp = norm_l( ps_sta );
f_tmp = Log2_norm_lc( L_shl( ps_sta, e_tmp ) );
e_tmp = sub( 30 - 16, e_tmp );
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 );
@@ -938,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;
@@ -953,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++;
}
@@ -987,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 */
}
@@ -1007,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 */
}
@@ -1026,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 */
}
@@ -1044,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 */
@@ -1056,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;
@@ -1392,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();
@@ -1406,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();
@@ -1421,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();
}
}
@@ -1446,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();
@@ -1486,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();
@@ -1530,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;
@@ -1547,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;
@@ -1561,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();
@@ -1575,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 */
@@ -1596,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 */
@@ -1692,8 +1649,8 @@ static Word16 attack_det_fx( /* o : attack flag
}
#ifdef IVAS_CODE
*last_strong_attack = 0;
-#endif
move16();
+#endif
}
return attack;
@@ -1752,6 +1709,7 @@ Word16 ivas_smc_gmm_fx(
Word32 temp32_log1, temp32_log2;
Word16 temp16;
Word16 dotp_exp = 0;
+ move16();
/*------------------------------------------------------------------*
* Initialization
*------------------------------------------------------------------*/
@@ -1810,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 ) )
{
@@ -1829,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;
@@ -1899,8 +1859,8 @@ Word16 ivas_smc_gmm_fx(
ELSE
{
hSpMusClas->relE_attack_cnt = 0;
- relE_attack_flag = 0;
move16();
+ relE_attack_flag = 0;
move16();
}
@@ -1944,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] );
@@ -1998,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)*/
@@ -2015,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++ )
{
@@ -2039,25 +2007,42 @@ 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();
FOR( i = LOWEST_FBIN; i < HIGHEST_FBIN; i++ )
{
- sum_PS_fx = BASOP_Util_Add_Mant32Exp( sum_PS_fx, sum_PS_e, PS_fx[i], sub( 31, Qfact_PS ), &sum_PS_e ); // sum_PS_e
+ sum = W_mac_32_32( sum, PS_fx[i], 1 ); // Qfact_PS+1
+ }
+ IF( sum == 0 )
+ {
+ sum_PS_fx = 1407374884; // 1e-5 in Q47
+ move32();
+ sum_PS_e = -16;
+ move16();
+ }
+ ELSE
+ {
+ sum_PS_e = W_norm( sum );
+ sum_PS_fx = W_extract_h( W_shl( sum, sum_PS_e ) ); // Qfact_PS+1+sum_PS_e-32
+ sum_PS_e = sub( 62, add( Qfact_PS, sum_PS_e ) ); // 31-(Qfact_PS+1+sum_PS_e-32)
}
- sum_PS_e = add( sum_PS_e, 1 ); // to avoid overflow
- sum_PS_fx = L_add( L_shr( sum_PS_fx, 1 ), L_shr( 21475 /*1 e-5 q31*/, sum_PS_e ) ); // 31-sum_PS_e
FOR( i = LOWEST_FBIN; i < HIGHEST_FBIN; i++ )
{
@@ -2089,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 );
}
}
@@ -2124,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();
}
@@ -2143,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;
@@ -2180,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();
@@ -2201,6 +2190,7 @@ Word16 ivas_smc_gmm_fx(
ELSE
{
*pFV_fx++ = *pFV_st_fx++;
+ move32();
}
}
@@ -2215,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 ) );
@@ -2234,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];
}
@@ -2253,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];*/
@@ -2281,25 +2277,25 @@ Word16 ivas_smc_gmm_fx(
lprob_exp = 0;
move16();
lprob_fx = dot_product_cholesky_fixed( fvm_fx, &prec_chol_speech_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF, fvm_exp, 31 - 28, &lprob_exp );
- ps_fx[m] = L_sub( L_sub( L_add( log_weights_speech_compute[m], log_det_chol_speech_fx[m] ), L_shl( lprob_fx, sub( Q19 - 1, sub( Q31, lprob_exp ) ) ) ), HALF_N_PCA_COEF_LOG_P12_Q19 ); // Q19
+ ps_fx[m] = L_sub( L_sub( L_add( log_weights_speech_compute[m], log_det_chol_speech_fx[m] ), L_shl( lprob_fx, sub( Q18 - 1, sub( Q31, lprob_exp ) ) ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18
move32();
v_sub32_fx( FV_fx, &means_music_fx[m * N_PCA_COEF], fvm_fx, N_PCA_COEF );
lprob_exp = 0;
move16();
lprob_fx = dot_product_cholesky_fixed( fvm_fx, &prec_chol_music_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF, fvm_exp, 31 - 28, &lprob_exp );
- pm_fx[m] = L_sub( L_sub( L_add( log_weights_music_compute[m], log_det_chol_music_fx[m] ), L_shl( lprob_fx, sub( Q19 - 1, sub( Q31, lprob_exp ) ) ) ), HALF_N_PCA_COEF_LOG_P12_Q19 ); // Q19
+ pm_fx[m] = L_sub( L_sub( L_add( log_weights_music_compute[m], log_det_chol_music_fx[m] ), L_shl( lprob_fx, sub( Q18 - 1, sub( Q31, lprob_exp ) ) ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18
move32();
v_sub32_fx( FV_fx, &means_noise_fx[m * N_PCA_COEF], fvm_fx, N_PCA_COEF );
lprob_exp = 0;
move16();
lprob_fx = dot_product_cholesky_fixed( fvm_fx, &prec_chol_noise_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF, fvm_exp, 31 - 28, &lprob_exp );
- pn_fx[m] = L_sub( L_sub( L_add( log_weights_noise_compute[m], log_det_chol_noise_fx[m] ), L_shl( lprob_fx, sub( Q19 - 1, sub( Q31, lprob_exp ) ) ) ), HALF_N_PCA_COEF_LOG_P12_Q19 ); // Q19
+ pn_fx[m] = L_sub( L_sub( L_add( log_weights_noise_compute[m], log_det_chol_noise_fx[m] ), L_shl( lprob_fx, sub( Q18 - 1, sub( Q31, lprob_exp ) ) ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18
move32();
}
- lps_fx = logsumexp_fx( ps_fx, sub( 31, Q19 ), N_SMC_MIXTURES );
- lpm_fx = logsumexp_fx( pm_fx, sub( 31, Q19 ), N_SMC_MIXTURES );
- lpn_fx = logsumexp_fx( pn_fx, sub( 31, Q19 ), 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 ) )
@@ -2308,14 +2304,17 @@ Word16 ivas_smc_gmm_fx(
move32();
}
- hSpMusClas->lpm_fx = extract_l( L_shr( lpm_fx, 12 ) ); // Q7
- hSpMusClas->lps_fx = extract_l( L_shr( lps_fx, 12 ) ); // Q7
- hSpMusClas->lpn_fx = extract_l( L_shr( lpn_fx, 12 ) ); // Q7
+ hSpMusClas->lpm_fx = extract_l( L_shr( lpm_fx, 11 ) ); // Q7
+ move16();
+ hSpMusClas->lps_fx = extract_l( L_shr( lps_fx, 11 ) ); // Q7
+ move16();
+ hSpMusClas->lpn_fx = extract_l( L_shr( lpn_fx, 11 ) ); // Q7
+ move16();
/* determine HQ Generic speech class */
IF( st->hHQ_core != NULL )
{
- IF( GT_32( lps_fx, L_add( lpm_fx, ONE_IN_Q18 ) ) )
+ IF( GT_32( lps_fx, L_add( lpm_fx, ONE_IN_Q17 ) ) )
{
st->hHQ_core->hq_generic_speech_class = 1;
}
@@ -2344,6 +2343,7 @@ Word16 ivas_smc_gmm_fx(
ELSE
{
dlp_fx = L_add( L_sub( lpm_fx, lps_fx ), DLP_BIAS_FX );
+ dlp_fx = L_shl( dlp_fx, 1 ); // Q19
IF( GT_32( dlp_fx, 15728640 ) ) /*30.0f in Q19*/
{
@@ -2357,12 +2357,10 @@ 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) */
- Word16 Qio = Q24;
- move16();
- wrelE_fx = lin_interp32_fx( L_deposit_h( relE_fx ), 15 << 24, 15099494 /*0.9 q24*/, -( 15 << 24 ), 16609443 /*0.99 q24*/, 1, &Qio ); // Q25
- wrelE_fx = L_shr( wrelE_fx, sub( Qio, 25 ) );
+ 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
/* calculate weight based on drops of dlp (close to 1 during sudden drops of dlp, close to 0 otherwise) */
// hSpMusClas->dlp_mean_ST = 0.8f * hSpMusClas->dlp_mean_ST + 0.2f * dlp;
hSpMusClas->dlp_mean_ST_fx = L_add( Mpy_32_32( 1717986918, hSpMusClas->dlp_mean_ST_fx ), Mpy_32_32( 429496729, dlp_fx ) );
@@ -2372,26 +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();
}
- Qio = Q25;
- move16();
- wdrop_fx = lin_interp32_fx( L_deposit_h( hSpMusClas->wdrop_fx ), 503316480, 23488102, 0, ONE_IN_Q25, 1, &Qio );
- wdrop_fx = L_shr( wdrop_fx, sub( Qio, 25 ) );
+ 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 )
{
@@ -2401,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
{
@@ -2409,21 +2409,18 @@ Word16 ivas_smc_gmm_fx(
}
- Qio = Q25;
- move16();
- wrise_fx = lin_interp32_fx( L_deposit_h( hSpMusClas->wrise_fx ), 167772160, 31876710, 0, ONE_IN_Q25, 1, &Qio );
- wrise_fx = L_shr( wrise_fx, sub( Qio, 25 ) );
+ wrise_fx = lin_interp32_fx( L_deposit_h( hSpMusClas->wrise_fx ), 167772160, 2040109466 /* 0.95 in Q31 */, 0, ONE_IN_Q31 /* 1.0f in Q31 */, 1 ); /* Q31 */
/* combine weights into one */
// wght = wrelE * wdrop * wrise;
- wght_fx = Mpy_32_32( Mpy_32_32( wrelE_fx, wdrop_fx ), wrise_fx ); // Q13
+ wght_fx = Mpy_32_32( Mpy_32_32( wrelE_fx, wdrop_fx ), wrise_fx ); /* Q31 */
test();
/* ratio of delta means vs. delta variances */
IF( hSpMusClas->sp_mus_state > 0 && LT_16( hSpMusClas->sp_mus_state, HANG_LEN ) )
{
hSpMusClas->dlp_mean_LT_fx = dlp_fx;
- hSpMusClas->dlp_var_LT_fx = 0;
move32();
+ hSpMusClas->dlp_var_LT_fx = 0;
move32();
}
@@ -2434,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
@@ -2469,34 +2466,34 @@ Word16 ivas_smc_gmm_fx(
IF( GT_32( L_deposit_l( dlp_mean2var_fx ), L_shl( 15, dlp_mean2var_q ) ) )
{
/* decrease the weight little bit when the classifier indicates "strong speech" or "strong music" */
- // wght *= 0.9f;
- wght_fx = Mpy_32_32( wght_fx, 1932735283 ); // Q13
+ wght_fx = Mpy_32_32( wght_fx, 1932735283 /* 0.9f in Q31 */ ); /* Q31 */
}
- IF( GT_32( wght_fx, ONE_IN_Q13 ) )
+ IF( GT_32( wght_fx, ONE_IN_Q31 ) )
{
- wght_fx = ONE_IN_Q13;
+ wght_fx = ONE_IN_Q31; /* 1.0f in Q31 */
}
- ELSE IF( LT_32( wght_fx, 82 ) )
+ ELSE IF( LT_32( wght_fx, 21474836 /* 0.01f in Q31 */ ) )
{
- wght_fx = 82;
+ wght_fx = 21474836; /* 0.01f in Q31 */
}
move32();
- if ( LT_16( Etot_fx, 2560 ) )
+ if ( LT_16( Etot_fx, 2560 /* 10f in Q8 */ ) )
{
/* silence */
- wght_fx = 7537;
+ wght_fx = 1975684956; /* 0.92f in Q31 */
move32();
}
/* calculate weighted decision */
// hSpMusClas->wdlp_0_95_sp = wght * hSpMusClas->wdlp_0_95_sp + ( 1 - wght ) * dlp;
- hSpMusClas->wdlp_0_95_sp_32fx = L_add( Mpy_32_32( L_shl( wght_fx /*q13*/, 18 ), hSpMusClas->wdlp_0_95_sp_32fx /*q24*/ ), Mpy_32_32( L_shl( L_sub( ONE_IN_Q13, wght_fx /*q13*/ ), Q18 ), L_shl( dlp_fx /*q19*/, 5 ) ) ); // Q24
+ hSpMusClas->wdlp_0_95_sp_32fx = L_add( Mpy_32_32( wght_fx, hSpMusClas->wdlp_0_95_sp_32fx /*q24*/ ), Mpy_32_32( L_sub( ONE_IN_Q31, wght_fx ), L_shl( dlp_fx /*q19*/, 5 ) ) ); // Q24
move32();
/* xtalk classifier: apply long hysteresis to prevent LRTD on music */
- hSpMusClas->wdlp_xtalk_fx = L_add( Mpy_32_32( 2136746229, hSpMusClas->wdlp_xtalk_fx ), Mpy_32_32( 10737418, dlp_fx ) );
+ hSpMusClas->wdlp_xtalk_fx = Madd_32_32( Mpy_32_32( 2136746230 /* 0.995f in Q31*/, hSpMusClas->wdlp_xtalk_fx /* Q25*/ ), 687194767 /* 0.005f in Q37 */, dlp_fx /* Q19*/ ); // Q25
+ move32();
/*------------------------------------------------------------------*
* Final speech/music decision
@@ -2510,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 )
@@ -2522,11 +2520,10 @@ 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, L_shl( 2, 25 ) ) )
+ IF( GT_32( temp32, 2 << 25 ) )
{
- IF( GT_32( dlp_fx, L_shl( 2, 19 ) ) )
+ IF( GT_32( dlp_fx, 2 << 19 ) )
{
dec = 2;
}
@@ -2660,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();
@@ -2689,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 */
)
{
@@ -2698,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;
@@ -2721,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;
@@ -2736,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 ) )
{
@@ -2748,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 */
@@ -2769,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 */
@@ -2825,19 +2807,24 @@ static Word16 attack_det_ivas_fx( /* o : attack flag
Copy32( finc, finc_prev, attack1 );
/* compute mean energy before the attack */
- etmp = L_shr( sum32_fx( finc_prev, ATT_NSEG ), 5 ); /*ATT_NSEG == 32*/
+ Word64 W_etmp = W_deposit32_l( finc_prev[0] );
+ FOR( Word16 idx = 1; idx < ATT_NSEG; idx++ )
+ {
+ W_etmp = W_add( W_etmp, W_deposit32_l( finc_prev[idx] ) );
+ }
+ W_etmp = W_shr( W_etmp, 5 ); /*ATT_NSEG == 32*/
etmp2 = finc[attack1];
move32();
test();
test();
- if ( ( LT_32( L_shl( etmp, 4 ), etmp2 ) ) || ( LT_32( L_add( L_shl( etmp, 3 ), L_shl( etmp, 2 ) ), etmp2 ) && EQ_16( last_clas, UNVOICED_CLAS ) ) )
+ if ( ( LT_64( W_shl( W_etmp, 4 ), W_deposit32_l( etmp2 ) ) ) || ( LT_64( W_add( W_shl( W_etmp, 3 ), W_shl( W_etmp, 2 ) ), W_deposit32_l( etmp2 ) ) && EQ_16( last_clas, UNVOICED_CLAS ) ) )
{
attack = attack1;
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();
@@ -2869,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;
}
@@ -2934,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 */
}
@@ -3003,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 */
@@ -3021,7 +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 */
- 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 );
+ IF( NE_16( shl( Q_new, 1 ), hSpMusClas->q_finc_prev ) )
+ {
+ 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->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
@@ -3063,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();
@@ -3140,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
@@ -3150,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 ) )
@@ -3161,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();
}
}
@@ -3177,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();
}
@@ -3246,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) */
@@ -3401,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++ )
@@ -3676,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 )
{
@@ -3754,6 +3749,7 @@ static void spec_analysis_fx(
Word16 p2v[65];
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/* find spectral peaks */
@@ -3837,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 );
}
}
@@ -3873,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 */
@@ -3964,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();
@@ -3977,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();
@@ -4007,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;
@@ -4113,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 );
@@ -4176,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 */
@@ -4191,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();
@@ -4240,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 ) )
@@ -4283,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
{
@@ -4318,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
{
@@ -4352,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
{
@@ -4368,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 ) )
{
@@ -4396,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] ) );
@@ -4473,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 */
@@ -4484,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 );
@@ -4495,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 );
@@ -4535,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 */
@@ -4572,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 */
@@ -4618,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 );
@@ -4753,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();
@@ -4853,6 +4847,7 @@ static void detect_sparseness_fx(
if ( EQ_16( st_fx->bwidth, WB ) )
{
tmp = 90;
+ move16();
}
IF( GT_16( sparse, tmp ) )
@@ -4915,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 73cb96e15ba3e502148ea05cc0347b59c7c8eeaf..6440c1d64e1c88320f58959a4d489ca41311a1a4 100644
--- a/lib_enc/stat_enc.h
+++ b/lib_enc/stat_enc.h
@@ -585,10 +585,11 @@ 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 */
- Word32 wdlp_xtalk_fx; /* Q19 */
+ Word32 wdlp_xtalk_fx; /* Q25 */
Word16 sp_mus_state;
Word16 past_dec[HANG_LEN - 1]; /* Speech/music classifier - buffer of past binary decisions */
Word16 past_dlp_fx[HANG_LEN - 1]; /* Speech/music classifier - buffer of past non-binary decisions Q9 */
@@ -640,8 +641,10 @@ 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_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 */
Word16 Q_tod_lt_Bin_E;
@@ -1005,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;
@@ -1384,7 +1390,7 @@ typedef struct enc_core_structure
int16_t coder_type_raw; /* raw coder_type (before UNVOICED is lost) */
int16_t last_coder_type_raw; /* raw last_coder_type (coming from the sigal classification) */
int16_t last_coder_type; /* previous coding type */
- Word16 old_thres_fx; /* normalized correlation weighting in open-loop pitch Q15 */
+ Word16 old_thres_fx; /* normalized correlation weighting in open-loop pitch Q14 */
Word16 old_corr_fx; /* normalized correlation in previous frame (mean value) Q15 */
int16_t old_pitch; /* previous pitch for open-loop pitch search */
int16_t delta_pit; /* open-loop pitch extrapolation correction */
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 ef16b333c8ba897e299e4bfa8a3b6f88d9f4ec51..60c6504a6fb909493157943e66c159d9722f0ed2 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
{
@@ -3232,11 +3127,7 @@ static Word16 SWB_BWE_encoding_ivas_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 ) ) )
@@ -3306,11 +3197,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 +3220,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();
}
}
@@ -3349,7 +3232,11 @@ static Word16 SWB_BWE_encoding_ivas_fx(
expn = sub( sub( 30, expn ), sub( shl( Q_insig_lp, 1 ), 7 ) );
expd = norm_l( WB_tenv_syn_fx );
+#ifdef FIX_ISSUE_1156
+ den = round_fx_o( L_shl( WB_tenv_syn_fx, expd ), &Overflow );
+#else
den = round_fx( L_shl( WB_tenv_syn_fx, expd ) );
+#endif
expd = sub( sub( 30, expd ), sub( shl( st_fx->Q_syn2, 1 ), 7 ) );
scale = shr( sub( den, num ), 15 );
@@ -3362,11 +3249,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
{
@@ -3376,12 +3259,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 ) )
{
@@ -3447,11 +3326,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] ) )
@@ -3470,21 +3345,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();
}
}
@@ -3793,13 +3660,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] );
@@ -4009,26 +3871,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 )
@@ -4076,7 +3930,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;
@@ -4084,6 +3938,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 ) )
{
@@ -4108,6 +3963,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 );
}
@@ -4117,7 +3973,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] ) ) )
{
@@ -4126,7 +3982,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 */
@@ -4144,6 +4000,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
{
@@ -4167,7 +4024,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 */
@@ -4183,12 +4040,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();
}
}
@@ -4199,13 +4057,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();
}
}
@@ -4223,6 +4083,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 );
@@ -4252,11 +4113,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();
}
@@ -4264,13 +4122,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();
}
}
@@ -4288,6 +4147,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
@@ -4410,6 +4273,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
{
@@ -4449,13 +4313,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();
}
}
@@ -4473,7 +4337,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();
}
}
@@ -4491,15 +4355,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 );
@@ -4529,11 +4393,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();
}
@@ -4542,13 +4402,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