diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 945de8500cc97016d2f89647d5c49d38f30075ca..e110e0aed539ab44b949526f88132f322bc5e2e4 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,10 +1,11 @@
variables:
# note: GitLab cannot reference variables defined by users in the include ref:, we need to use a YAML anchor for this
# see https://docs.gitlab.com/ci/yaml/includes/#use-variables-with-include for more information
- IVAS_CODEC_CI_REF: &IVAS_CODEC_CI_REF 74a8d426730ed21183fe047503e7097262fcb796
+ IVAS_CODEC_CI_REF: &IVAS_CODEC_CI_REF 41186736915f5c0a857ac92e8ab438c434e5247d
include:
- local: .gitlab-ci/variables.yml
+ - local: .gitlab-ci/rules-basis.yml
- project: ivas-codec-pc/ivas-codec-ci
ref: *IVAS_CODEC_CI_REF
file: main.yml
@@ -37,6 +38,9 @@ workflow:
- if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'pytest-compare-long'
variables:
IVAS_PIPELINE_NAME: 'Run comparison tools against float ref (long test vectors): $CI_COMMIT_BRANCH'
+ - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'pytest-compare-long-fx-fx'
+ variables:
+ IVAS_PIPELINE_NAME: 'Run comparison tools against float ref FX-FX (long test vectors): $CI_COMMIT_BRANCH'
- if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'pytest-compare-to-input'
variables:
IVAS_PIPELINE_NAME: 'Run comparison tools against input (pass-through only): $CI_COMMIT_BRANCH'
@@ -132,6 +136,15 @@ workflow:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
when: never
+.rules-pytest-long-fx-fx:
+ rules:
+ - if: $PYTEST_MLD_LONG_FX_FX # Set by scheduled pipeline
+ - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "pytest-compare-long-fx-fx"
+ - if: $CI_PIPELINE_SOURCE == 'push'
+ when: never
+ - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
+ when: never
+
.rules-coverage:
rules:
- if: $COVERAGE_TEST # Set by scheduled pipeline
@@ -183,7 +196,7 @@ workflow:
.ivas-pytest-anchor: &ivas-pytest-anchor
stage: test
needs: ["build-codec-linux-make"]
- timeout: "360 minutes"
+ timeout: "15 hours"
variables:
# keep "mld" in artifact name for backwards compatibility reasons
CSV_ARTIFACT_NAME: "mld--$CI_JOB_NAME-$CI_JOB_ID--sha-$CI_COMMIT_SHORT_SHA.csv"
@@ -326,10 +339,6 @@ workflow:
- rm -rf tests/dut tests/ref
variables:
USE_LTV: 0
- DUT_ENCODER_PATH: ./IVAS_cod_ref
- DUT_DECODER_PATH: ./IVAS_dec_ref
- MERGE_TARGET_ENCODER_PATH: ./IVAS_cod_ref
- MERGE_TARGET_DECODER_PATH: ./IVAS_dec_ref
.check-be-to-target-job:
extends:
@@ -448,9 +457,6 @@ workflow:
extends:
- .check-be-job
stage: test
- needs:
- - job: "check-be-to-target-short-enc-0db"
- artifacts: true
timeout: "300 minutes"
variables:
XML_REPORT_BRANCH: "report-junit-branch-$CI_JOB_NAME--sha-$CI_COMMIT_SHORT_SHA.xml"
@@ -645,8 +651,6 @@ workflow:
- report-junit.xml
.ivas-pytest-compare-to-input-anchor: &ivas-pytest-compare-to-input-anchor
- extends:
- - .job-linux
stage: test
needs: ["build-codec-linux-make"]
timeout: "360 minutes"
@@ -839,7 +843,7 @@ build-codec-linux-make:
when: never
extends:
- .build-job-linux
- timeout: "10 minutes"
+ timeout: "100 minutes"
script:
- bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/print-common-info.sh
- *activate-Werror-linux
@@ -856,7 +860,7 @@ build-codec-linux-instrumented-make:
when: never
extends:
- .build-job-linux
- timeout: "10 minutes"
+ timeout: "100 minutes"
script:
- bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/print-common-info.sh
- bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/update-scripts-repo.sh
@@ -873,7 +877,7 @@ build-codec-linux-debugging-make:
when: never
extends:
- .build-job-linux
- timeout: "10 minutes"
+ timeout: "100 minutes"
variables:
BUILD_WITH_DEBUG_MODE_INFO: "true"
script:
@@ -911,6 +915,9 @@ check-be-to-target-short-enc-0db:
TEST_SUITE: "$SHORT_TEST_SUITE_ENCODER"
# -/-0dB
LEVEL_SCALING: "1.0"
+ # overwrite decoder with float reference one
+ DUT_DECODER_PATH: "$REF_DECODER_PATH"
+ MERGE_TARGET_DECODER_PATH: "$REF_DECODER_PATH"
check-be-to-target-short-enc-+10db:
extends:
@@ -919,6 +926,9 @@ check-be-to-target-short-enc-+10db:
TEST_SUITE: "$SHORT_TEST_SUITE_ENCODER"
# +10dB
LEVEL_SCALING: "3.162"
+ # overwrite decoder with float reference one
+ DUT_DECODER_PATH: "$REF_DECODER_PATH"
+ MERGE_TARGET_DECODER_PATH: "$REF_DECODER_PATH"
check-be-to-target-short-enc--10db:
extends:
@@ -927,6 +937,9 @@ check-be-to-target-short-enc--10db:
TEST_SUITE: "$SHORT_TEST_SUITE_ENCODER"
# -10dB
LEVEL_SCALING: "0.3162"
+ # overwrite decoder with float reference one
+ DUT_DECODER_PATH: "$REF_DECODER_PATH"
+ MERGE_TARGET_DECODER_PATH: "$REF_DECODER_PATH"
check-be-to-target-short-dec-0db:
extends:
@@ -935,6 +948,9 @@ check-be-to-target-short-dec-0db:
TEST_SUITE: "$SHORT_TEST_SUITE"
# +/-0dB
LEVEL_SCALING: "1.0"
+ # overwrite encoder with float reference one
+ DUT_ENCODER_PATH: "$REF_ENCODER_PATH"
+ MERGE_TARGET_ENCODER_PATH: "$REF_ENCODER_PATH"
check-be-to-target-short-dec-+10db:
extends:
@@ -943,6 +959,9 @@ check-be-to-target-short-dec-+10db:
TEST_SUITE: "$SHORT_TEST_SUITE"
# +10dB
LEVEL_SCALING: "3.162"
+ # overwrite encoder with float reference one
+ DUT_ENCODER_PATH: "$REF_ENCODER_PATH"
+ MERGE_TARGET_ENCODER_PATH: "$REF_ENCODER_PATH"
check-be-to-target-short-dec--10db:
extends:
@@ -951,55 +970,94 @@ check-be-to-target-short-dec--10db:
TEST_SUITE: "$SHORT_TEST_SUITE"
# -10dB
LEVEL_SCALING: "0.3162"
+ # overwrite encoder with float reference one
+ DUT_ENCODER_PATH: "$REF_ENCODER_PATH"
+ MERGE_TARGET_ENCODER_PATH: "$REF_ENCODER_PATH"
### jobs that check for regressions on non-BE testcases
check-regressions-short-enc-0db:
extends:
- .check-regressions-pytest-job
+ needs:
+ - job: "check-be-to-target-short-enc-0db"
+ artifacts: true
variables:
TEST_SUITE: "$SHORT_TEST_SUITE_ENCODER"
# +/-0dB
LEVEL_SCALING: "1.0"
+ # overwrite decoder with float reference one
+ DUT_DECODER_PATH: "$REF_DECODER_PATH"
+ MERGE_TARGET_DECODER_PATH: "$REF_DECODER_PATH"
check-regressions-short-enc-+10db:
extends:
- .check-regressions-pytest-job
+ needs:
+ - job: "check-be-to-target-short-enc-+10db"
+ artifacts: true
variables:
TEST_SUITE: "$SHORT_TEST_SUITE_ENCODER"
# +10dB
LEVEL_SCALING: "3.162"
+ # overwrite decoder with float reference one
+ DUT_DECODER_PATH: "$REF_DECODER_PATH"
+ MERGE_TARGET_DECODER_PATH: "$REF_DECODER_PATH"
check-regressions-short-enc--10db:
extends:
- .check-regressions-pytest-job
+ needs:
+ - job: "check-be-to-target-short-enc--10db"
+ artifacts: true
variables:
TEST_SUITE: "$SHORT_TEST_SUITE_ENCODER"
# -10dB
LEVEL_SCALING: "0.3162"
+ # overwrite decoder with float reference one
+ DUT_DECODER_PATH: "$REF_DECODER_PATH"
+ MERGE_TARGET_DECODER_PATH: "$REF_DECODER_PATH"
check-regressions-short-dec-0db:
extends:
- .check-regressions-pytest-job
+ needs:
+ - job: "check-be-to-target-short-dec-0db"
+ artifacts: true
variables:
TEST_SUITE: "$SHORT_TEST_SUITE"
# +/-0dB
LEVEL_SCALING: "1"
+ # overwrite encoder with float reference one
+ DUT_ENCODER_PATH: "$REF_ENCODER_PATH"
+ MERGE_TARGET_ENCODER_PATH: "$REF_ENCODER_PATH"
check-regressions-short-dec-+10db:
extends:
- .check-regressions-pytest-job
+ needs:
+ - job: "check-be-to-target-short-dec-+10db"
+ artifacts: true
variables:
TEST_SUITE: "$SHORT_TEST_SUITE"
# +10dB
LEVEL_SCALING: "3.162"
+ # overwrite encoder with float reference one
+ DUT_ENCODER_PATH: "$REF_ENCODER_PATH"
+ MERGE_TARGET_ENCODER_PATH: "$REF_ENCODER_PATH"
check-regressions-short-dec--10db:
extends:
- .check-regressions-pytest-job
+ needs:
+ - job: "check-be-to-target-short-dec--10db"
+ artifacts: true
variables:
TEST_SUITE: "$SHORT_TEST_SUITE"
# -10dB
LEVEL_SCALING: "0.3162"
+ # overwrite encoder with float reference one
+ DUT_ENCODER_PATH: "$REF_ENCODER_PATH"
+ MERGE_TARGET_ENCODER_PATH: "$REF_ENCODER_PATH"
check-be-between-renderer-framesizes:
extends:
@@ -1271,7 +1329,10 @@ ivas-pytest-compare_ref-long-enc:
ivas-pytest-compare_ref-long-dec:
extends:
- .rules-pytest-long
- - .test-job-linux
+ - .test-job-linux
+ tags:
+ - ivas-basop-linux
+ - high-memory-capacity
before_script:
- USE_LTV=1
- DUT_ENCODER_PATH=./$REF_ENCODER_PATH
@@ -1283,7 +1344,7 @@ ivas-pytest-compare_ref-long-dec:
ivas-pytest-compare_ref-long-enc-lev-10:
extends:
- .rules-pytest-long
- - .test-job-linux
+ - .test-job-linux
before_script:
- USE_LTV=1
- DUT_DECODER_PATH=./$REF_DECODER_PATH
@@ -1295,7 +1356,10 @@ ivas-pytest-compare_ref-long-enc-lev-10:
ivas-pytest-compare_ref-long-dec-lev-10:
extends:
- .rules-pytest-long
- - .test-job-linux
+ - .test-job-linux
+ tags:
+ - ivas-basop-linux
+ - high-memory-capacity
before_script:
- USE_LTV=1
- DUT_ENCODER_PATH=./$REF_ENCODER_PATH
@@ -1319,7 +1383,10 @@ ivas-pytest-compare_ref-long-enc-lev+10:
ivas-pytest-compare_ref-long-dec-lev+10:
extends:
- .rules-pytest-long
- - .test-job-linux
+ - .test-job-linux
+ tags:
+ - ivas-basop-linux
+ - high-memory-capacity
before_script:
- USE_LTV=1
- DUT_ENCODER_PATH=./$REF_ENCODER_PATH
@@ -1328,6 +1395,49 @@ ivas-pytest-compare_ref-long-dec-lev+10:
- SPLIT_COMPARISON="true"
<<: *ivas-pytest-anchor
+ivas-pytest-compare_ref-long-fx-fx:
+ extends:
+ - .rules-pytest-long-fx-fx
+ - .test-job-linux
+ tags:
+ - ivas-linux
+ before_script:
+ - USE_LTV=1
+ - REF_ENCODER_PATH=./$DUT_ENCODER_PATH
+ - TEST_SUITE="$LONG_TEST_SUITE_NO_RENDERER"
+ - LEVEL_SCALING=1.0
+ - SPLIT_COMPARISON="true"
+ <<: *ivas-pytest-anchor
+
+ivas-pytest-compare_ref-long-fx-fx-lev-10:
+ extends:
+ - .rules-pytest-long-fx-fx
+ - .test-job-linux
+ tags:
+ - ivas-linux
+ before_script:
+ - USE_LTV=1
+ - REF_ENCODER_PATH=./$DUT_ENCODER_PATH
+ - TEST_SUITE="$LONG_TEST_SUITE_NO_RENDERER"
+ - LEVEL_SCALING=0.3162
+ - SPLIT_COMPARISON="true"
+ <<: *ivas-pytest-anchor
+
+ivas-pytest-compare_ref-long-fx-fx-lev+10:
+ extends:
+ - .rules-pytest-long-fx-fx
+ - .test-job-linux
+ tags:
+ - ivas-linux
+ before_script:
+ - USE_LTV=1
+ - REF_ENCODER_PATH=./$DUT_ENCODER_PATH
+ - TEST_SUITE="$LONG_TEST_SUITE_NO_RENDERER"
+ - LEVEL_SCALING=3.162
+ - SPLIT_COMPARISON="true"
+ <<: *ivas-pytest-anchor
+
+
ivas-smoke-test-saturation:
extends:
- .rules-pytest-saturation-smoke-test
@@ -1596,6 +1706,7 @@ voip-be-on-merge-request:
GET_WMOPS_ARGS: "mem_only"
timeout: 3 hours 30 minutes
before_script:
+ - !reference [ .test-job-linux, before_script ]
- bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/print-common-info.sh
- bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/update-scripts-repo.sh
- bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/update-ltv-repo.sh
diff --git a/.gitlab-ci/rules-basis.yml b/.gitlab-ci/rules-basis.yml
new file mode 100644
index 0000000000000000000000000000000000000000..c650f574a59d41dc67aaa32f7250fcf73f906848
--- /dev/null
+++ b/.gitlab-ci/rules-basis.yml
@@ -0,0 +1,53 @@
+# overwrites the default rules in the IVAS CI repository
+# should be refactored and unified
+.rules-basis:
+ rules:
+ # see https://docs.gitlab.com/ee/ci/yaml/workflow.html#switch-between-branch-pipelines-and-merge-request-pipelines
+ - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS && $CI_PIPELINE_SOURCE == "push"
+ when: never
+ - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
+ variables:
+ IVAS_PIPELINE_NAME: 'MR pipeline: $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME'
+ ### disabled for now because pipeline cd is redundant with MR pipeline with current workflow
+ # - if: $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH # Pushes to main
+ # variables:
+ # IVAS_PIPELINE_NAME: 'Push pipeline: $CI_COMMIT_BRANCH'
+ - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'default' # for testing
+ variables:
+ IVAS_PIPELINE_NAME: 'Web run pipeline: $CI_COMMIT_BRANCH'
+ - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'pytest-compare'
+ variables:
+ IVAS_PIPELINE_NAME: 'Run comparison tools against float ref: $CI_COMMIT_BRANCH'
+ - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'pytest-compare-enc-dmx'
+ variables:
+ IVAS_PIPELINE_NAME: 'Run encoder dmx comparison against float ref: $CI_COMMIT_BRANCH'
+ - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'pytest-compare-long'
+ variables:
+ IVAS_PIPELINE_NAME: 'Run comparison tools against float ref (long test vectors): $CI_COMMIT_BRANCH'
+ - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'pytest-compare-to-input'
+ variables:
+ IVAS_PIPELINE_NAME: 'Run comparison tools against input (pass-through only): $CI_COMMIT_BRANCH'
+ - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'pytest-saturation-smoke-test'
+ variables:
+ IVAS_PIPELINE_NAME: 'Run saturation smoke-test: $CI_COMMIT_BRANCH'
+ - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'evs-26444'
+ variables:
+ IVAS_PIPELINE_NAME: 'EVS 26.444 test: $CI_COMMIT_BRANCH'
+ - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'sanitizer'
+ variables:
+ IVAS_PIPELINE_NAME: 'Short testvectors sanitizers'
+ - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'pytest-renderer'
+ variables:
+ IVAS_PIPELINE_NAME: 'Renderer test: $CI_COMMIT_BRANCH'
+ - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'complexity'
+ variables:
+ IVAS_PIPELINE_NAME: 'Complexity Measurement on $CI_COMMIT_BRANCH'
+ - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'voip-be-test'
+ variables:
+ IVAS_PIPELINE_NAME: 'Voip BE test on $CI_COMMIT_BRANCH'
+ - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'peaq-enc-passthrough'
+ variables:
+ IVAS_PIPELINE_NAME: 'PEAQ encoder pass-through test: $CI_COMMIT_BRANCH'
+ - if: $CI_PIPELINE_SOURCE == 'schedule' # Scheduled in any branch
+ variables:
+ IVAS_PIPELINE_NAME: 'Scheduled pipeline: $CI_COMMIT_BRANCH'
diff --git a/.gitlab-ci/variables.yml b/.gitlab-ci/variables.yml
index 94bb71fb347b5349d9933564dbd35964e9daa0b7..0c212d3121dfa022cae3f2f98ae5a7f44557a7b4 100644
--- a/.gitlab-ci/variables.yml
+++ b/.gitlab-ci/variables.yml
@@ -54,6 +54,7 @@ variables:
- 'pytest-compare'
- 'pytest-compare-enc-dmx'
- 'pytest-compare-long'
+ - 'pytest-compare-long-fx-fx'
- 'pytest-compare-to-input'
- 'pytest-saturation-smoke-test'
- 'evs-26444'
diff --git a/Workspace_msvc/lib_com.vcxproj b/Workspace_msvc/lib_com.vcxproj
index 7a2aa8a7f66bcdd6ec2164f382b709a8b43cc925..91401ee2eee0f92a849121f0e223522948614061 100644
--- a/Workspace_msvc/lib_com.vcxproj
+++ b/Workspace_msvc/lib_com.vcxproj
@@ -136,14 +136,14 @@
-
-
+
+
-
+
-
-
-
+
+
+
@@ -153,21 +153,19 @@
-
-
-
-
+
+
+
+
-
-
-
-
+
+
@@ -175,7 +173,6 @@
-
@@ -183,20 +180,18 @@
-
-
-
+
-
-
-
+
+
+
@@ -207,7 +202,7 @@
-
+
@@ -235,8 +230,8 @@
-
-
+
+
@@ -248,9 +243,7 @@
-
-
@@ -258,7 +251,6 @@
-
@@ -283,9 +275,9 @@
-
+
-
+
@@ -297,7 +289,6 @@
-
diff --git a/Workspace_msvc/lib_com.vcxproj.filters b/Workspace_msvc/lib_com.vcxproj.filters
index 89b47a3fcf9b04744c7ba3e9fd1cfec159c27ca9..3b781aa40a612fac63d7840abe2371ba83d72a7b 100644
--- a/Workspace_msvc/lib_com.vcxproj.filters
+++ b/Workspace_msvc/lib_com.vcxproj.filters
@@ -115,9 +115,6 @@
common_all_c
-
- common_all_c
-
common_all_c
@@ -133,9 +130,6 @@
common_all_c
-
- common_all_c
-
common_all_c
@@ -301,21 +295,9 @@
common_all_c
-
- common_all_c
-
common_all_c
-
- common_all_c
-
-
- common_all_c
-
-
- common_all_c
-
common_all_c
@@ -325,30 +307,6 @@
common_all_c
-
- common_all_c
-
-
- common_all_c
-
-
- common_all_c
-
-
- common_all_c
-
-
- common_all_c
-
-
- common_all_c
-
-
- common_all_c
-
-
- common_all_c
-
common_all_c
@@ -361,33 +319,12 @@
common_all_c
-
- common_all_c
-
common_all_c
common_all_c
-
- common_all_c
-
-
- common_all_c
-
-
- common_all_c
-
-
- common_all_c
-
-
- common_all_c
-
-
- common_all_c
-
common_ivas_c
@@ -403,45 +340,21 @@
common_ivas_c
-
- common_all_c
-
-
- common_all_c
-
common_all_c
-
- common_all_c
-
-
- common_all_c
-
common_all_c
-
- common_all_c
-
common_all_c
common_all_c
-
- common_all_c
-
-
- common_all_c
-
common_all_c
-
- common_all_c
-
common_all_c
@@ -481,9 +394,6 @@
common_ivas_c
-
- common_ivas_c
-
common_ivas_c
@@ -535,6 +445,69 @@
common_ivas_c
+
+ common_all_c
+
+
+ common_all_c
+
+
+ common_all_c
+
+
+ common_all_c
+
+
+ common_all_c
+
+
+ common_all_c
+
+
+ common_all_c
+
+
+ common_all_c
+
+
+ common_all_c
+
+
+ common_all_c
+
+
+ common_all_c
+
+
+ common_all_c
+
+
+ common_all_c
+
+
+ common_all_c
+
+
+ common_all_c
+
+
+ common_all_c
+
+
+ common_ivas_c
+
+
+ common_all_c
+
+
+ common_all_c
+
+
+ common_all_c
+
+
+ common_all_c
+
diff --git a/Workspace_msvc/lib_dec.vcxproj b/Workspace_msvc/lib_dec.vcxproj
index 2d06d29aa90604e44237a3feaf6dc21c57fa4850..1ae8c4d9313f4bb22ebde33891db01a72ddcdf78 100644
--- a/Workspace_msvc/lib_dec.vcxproj
+++ b/Workspace_msvc/lib_dec.vcxproj
@@ -139,15 +139,12 @@
false
-
- false
-
-
+
-
+
@@ -218,7 +215,6 @@
-
@@ -248,7 +244,7 @@
-
+
@@ -257,8 +253,7 @@
-
-
+
@@ -273,13 +268,13 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
@@ -296,7 +291,7 @@
-
+
diff --git a/Workspace_msvc/lib_dec.vcxproj.filters b/Workspace_msvc/lib_dec.vcxproj.filters
index 8a4fc4605a1170b9da66c90a81b8bdd4134573c7..170eada9ad30e017f4f3652be5ee6f08f2080937 100644
--- a/Workspace_msvc/lib_dec.vcxproj.filters
+++ b/Workspace_msvc/lib_dec.vcxproj.filters
@@ -74,12 +74,6 @@
decoder_ivas_c
-
- decoder_ivas_c
-
-
- decoder_ivas_c
-
decoder_ivas_c
@@ -89,9 +83,6 @@
decoder_ivas_c
-
- decoder_ivas_c
-
decoder_ivas_c
@@ -101,12 +92,6 @@
decoder_ivas_c
-
- decoder_ivas_c
-
-
- decoder_ivas_c
-
decoder_ivas_c
@@ -119,18 +104,9 @@
decoder_all_c
-
- decoder_all_c
-
-
- decoder_all_c
-
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
@@ -269,27 +245,6 @@
decoder_all_c
-
- decoder_all_c
-
-
- decoder_all_c
-
-
- decoder_all_c
-
-
- decoder_all_c
-
-
- decoder_all_c
-
-
- decoder_all_c
-
-
- decoder_all_c
-
decoder_all_c
@@ -329,9 +284,6 @@
decoder_all_c
-
- decoder_all_c
-
decoder_all_c
@@ -518,18 +470,48 @@
decoder_ivas_c
+
+ decoder_all_c
+
+
+ decoder_all_c
+
+
+ decoder_ivas_c
+
+
+ decoder_all_c
+
+
+ decoder_ivas_c
+
+
+ decoder_ivas_c
+
+
+ decoder_all_c
+
+
+ decoder_all_c
+
+
+ decoder_all_c
+
+
+ decoder_all_c
+
+
+ decoder_all_c
+
+
+ decoder_all_c
+
+
+ decoder_all_c
+
-
- decoder_h
-
-
- decoder_h
-
-
- decoder_h
-
decoder_h
@@ -557,6 +539,15 @@
decoder_h
+
+ decoder_h
+
+
+ decoder_h
+
+
+ decoder_h
+
diff --git a/Workspace_msvc/lib_enc.vcxproj b/Workspace_msvc/lib_enc.vcxproj
index 86dcef90541be79286704dffc2160960a9846d2c..af16efedf05580910fc85d674935bdf647c43421 100644
--- a/Workspace_msvc/lib_enc.vcxproj
+++ b/Workspace_msvc/lib_enc.vcxproj
@@ -239,7 +239,7 @@
-
+
@@ -274,11 +274,10 @@
-
+
-
@@ -318,7 +317,7 @@
-
+
diff --git a/Workspace_msvc/lib_enc.vcxproj.filters b/Workspace_msvc/lib_enc.vcxproj.filters
index 8990971637ef90b8f3a11fbd672278a29d3f89da..e8f429f4914dace1f3d9efa63afe65a713d5bf25 100644
--- a/Workspace_msvc/lib_enc.vcxproj.filters
+++ b/Workspace_msvc/lib_enc.vcxproj.filters
@@ -1,7 +1,6 @@
-
encoder_evs_c
@@ -152,9 +151,6 @@
encoder_all_c
-
- encoder_all_c
-
encoder_all_c
@@ -287,9 +283,6 @@
encoder_all_c
-
- encoder_all_c
-
encoder_all_c
@@ -347,9 +340,6 @@
encoder_all_c
-
- encoder_all_c
-
encoder_all_c
@@ -602,6 +592,13 @@
encoder_ivas_c
+
+ encoder_all_c
+
+
+
+ encoder_all_c
+
diff --git a/Workspace_msvc/lib_rend.vcxproj b/Workspace_msvc/lib_rend.vcxproj
index e47858ae380f169b2bf53e720d1c3abf23c29224..0a00f9331a9fe92ff4a71bfea4a4798059aa2b9b 100644
--- a/Workspace_msvc/lib_rend.vcxproj
+++ b/Workspace_msvc/lib_rend.vcxproj
@@ -142,7 +142,6 @@
-
@@ -159,7 +158,7 @@
-
+
@@ -176,7 +175,7 @@
-
+
diff --git a/Workspace_msvc/lib_rend.vcxproj.filters b/Workspace_msvc/lib_rend.vcxproj.filters
index 5c4a4901111136b5ce1c1406701ffe10e156b86b..820a5c044354c8b35ceabc1855256052b4915b24 100644
--- a/Workspace_msvc/lib_rend.vcxproj.filters
+++ b/Workspace_msvc/lib_rend.vcxproj.filters
@@ -1,13 +1,6 @@
-
-
- rend_c
-
-
- rend_c
-
rend_c
@@ -122,6 +115,10 @@
rend_c
+
+ rend_c
+
+
diff --git a/apps/decoder.c b/apps/decoder.c
index 1c59a02e743cd3716e2299e9c39fed891a0441d0..2cc639e6aaf7bac9e7e60af9a00cbdfa893c195e 100644
--- a/apps/decoder.c
+++ b/apps/decoder.c
@@ -2462,7 +2462,14 @@ static ivas_error decodeVoIP(
}
vec_pos_update = ( vec_pos_update + 1 ) % vec_pos_len;
frame++;
+#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE
+ if ( vec_pos_update == 0 )
+ {
+ systemTime_ms += vec_pos_len * systemTimeInc_ms;
+ }
+#else
systemTime_ms += systemTimeInc_ms;
+#endif
#ifdef WMOPS
update_mem();
@@ -2470,6 +2477,94 @@ static ivas_error decodeVoIP(
#endif
}
+
+#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE
+ int16_t nSamplesFlushed = 0;
+
+ /* decode and get samples */
+#ifdef SPLIT_REND_WITH_HEAD_ROT
+ if ( ( error = IVAS_DEC_Flush( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, &nSamplesFlushed ) ) != IVAS_ERR_OK )
+#else
+ if ( ( error = IVAS_DEC_Flush( hIvasDec, nOutSamples, pcmBuf, &nSamplesFlushed ) ) != IVAS_ERR_OK )
+#endif
+ {
+ fprintf( stderr, "\nError in IVAS_DEC_VoIP_Flush: %s\n", IVAS_DEC_GetErrorMessage( error ) );
+ goto cleanup;
+ }
+
+ if ( nSamplesFlushed )
+ {
+ /* Write current frame */
+ if ( ( error = AudioFileWriter_write( afWriter, pcmBuf, nSamplesFlushed * nOutChannels ) ) != IVAS_ERR_OK )
+ {
+ fprintf( stderr, "\nOutput audio file writer error\n" );
+ goto cleanup;
+ }
+
+ /* Write ISm metadata to external file(s) */
+ if ( decodedGoodFrame && arg.outputConfig == IVAS_AUDIO_CONFIG_EXTERNAL )
+ {
+ if ( bsFormat == IVAS_DEC_BS_OBJ || bsFormat == IVAS_DEC_BS_MASA_ISM || bsFormat == IVAS_DEC_BS_SBA_ISM )
+ {
+ if ( ( error = IVAS_DEC_GetNumObjects( hIvasDec, &numObj ) ) != IVAS_ERR_OK )
+ {
+ fprintf( stderr, "\nError in IVAS_DEC_GetNumObjects: %s\n", IVAS_DEC_GetErrorMessage( error ) );
+ goto cleanup;
+ }
+
+ for ( i = 0; i < numObj; ++i )
+ {
+ IVAS_ISM_METADATA IsmMetadata;
+
+ if ( ( error = IVAS_DEC_GetObjectMetadata( hIvasDec, &IsmMetadata, 0, i ) ) != IVAS_ERR_OK )
+ {
+ fprintf( stderr, "\nError in IVAS_DEC_GetObjectMetadata: %s\n", IVAS_DEC_GetErrorMessage( error ) );
+ goto cleanup;
+ }
+
+ if ( ( IsmFileWriter_writeFrame( IsmMetadata, ismWriters[i] ) ) != IVAS_ERR_OK )
+ {
+ fprintf( stderr, "\nError writing ISM metadata to file %s\n", IsmFileWriter_getFilePath( ismWriters[i] ) );
+ goto cleanup;
+ }
+ }
+ }
+
+ if ( bsFormat == IVAS_DEC_BS_MASA || bsFormat == IVAS_DEC_BS_MASA_ISM )
+ {
+ IVAS_MASA_DECODER_EXT_OUT_META_HANDLE hMasaExtOutMeta;
+#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
+ int16_t fullDelayNumSamples[3];
+ float delayMs;
+
+ /* delayNumSamples is zeroed, and delayNumSamples_orig is updated only on first good frame, so need to re-fetch delay info */
+ if ( ( error = IVAS_DEC_GetDelay( hIvasDec, fullDelayNumSamples, &delayTimeScale ) ) != IVAS_ERR_OK )
+ {
+ fprintf( stderr, "\nUnable to get delay of decoder: %s\n", ivas_error_to_string( error ) );
+ }
+#endif
+ if ( ( error = IVAS_DEC_GetMasaMetadata( hIvasDec, &hMasaExtOutMeta, 0 ) ) != IVAS_ERR_OK )
+ {
+ fprintf( stderr, "\nError in IVAS_DEC_GetMasaMetadata: %s\n", IVAS_DEC_GetErrorMessage( error ) );
+ goto cleanup;
+ }
+
+#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
+ delayMs = (float) ( fullDelayNumSamples[0] ) / (float) ( delayTimeScale );
+ if ( ( error = MasaFileWriter_writeFrame( masaWriter, hMasaExtOutMeta, &delayMs ) ) != IVAS_ERR_OK )
+#else
+ if ( ( error = MasaFileWriter_writeFrame( masaWriter, hMasaExtOutMeta ) ) != IVAS_ERR_OK )
+#endif
+ {
+ fprintf( stderr, "\nError writing MASA metadata to file: %s\n", MasaFileWriter_getFilePath( masaWriter ) );
+ goto cleanup;
+ }
+ }
+ }
+ }
+#endif
+
+
/*------------------------------------------------------------------------------------------*
* Add zeros at the end to have equal length of synthesized signals
*------------------------------------------------------------------------------------------*/
diff --git a/apps/encoder.c b/apps/encoder.c
index af9554589d813007f8b04ec2df6f4f6a0369fe4c..0d557ede89cfeb0bd9b455419b0c13105f0a8da5 100644
--- a/apps/encoder.c
+++ b/apps/encoder.c
@@ -758,7 +758,12 @@ int main(
}
/* *** Encode one frame *** */
- if ( ( error = IVAS_ENC_EncodeFrameToSerial( hIvasEnc, pcmBuf, pcmBufSize, bitStream, &numBits ) ) != IVAS_ERR_OK )
+ if ( ( error = IVAS_ENC_EncodeFrameToSerial( hIvasEnc, pcmBuf, pcmBufSize, bitStream, &numBits
+#ifdef DBG_BITSTREAM_ANALYSIS
+ ,
+ frame
+#endif
+ ) ) != IVAS_ERR_OK )
{
fprintf( stderr, "\nencodeFrame failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) );
goto cleanup;
diff --git a/apps/renderer.c b/apps/renderer.c
index 47548d438f9d3ae4e8e409c60d14051f256e24b0..317713c055bb9bbb60e751e956ed7e86b7e8ac32 100644
--- a/apps/renderer.c
+++ b/apps/renderer.c
@@ -149,7 +149,7 @@ typedef struct
int32_t sampleRate;
InputConfig inConfig;
OutputConfig outConfig;
- char inMetadataFilePaths[RENDERER_MAX_ISM_INPUTS][RENDERER_MAX_CLI_ARG_LENGTH];
+ char inMetadataFilePaths[RENDERER_MAX_ISM_INPUTS + RENDERER_MAX_MASA_INPUTS][RENDERER_MAX_CLI_ARG_LENGTH];
int16_t numInMetadataFiles;
char headRotationFilePath[RENDERER_MAX_CLI_ARG_LENGTH];
char referenceVectorFilePath[RENDERER_MAX_CLI_ARG_LENGTH];
@@ -217,13 +217,13 @@ static const CmdLnParser_Option cliOptions[] = {
.id = CmdLnOptionId_inputFormat,
.match = "input_format",
.matchShort = "if",
- .description = "Audio format of input file (e.g. 5_1 or HOA3 or META, use -l for a list)",
+ .description = "Audio format of input file (e.g. 5_1 or HOA3 or META,\nuse -l for a list)",
},
{
.id = CmdLnOptionId_inputMetadata,
.match = "input_metadata",
.matchShort = "im",
- .description = "Space-separated list of path to metadata files for ISM or MASA inputs",
+ .description = "Space-separated list of path to metadata files for ISM/MASA/OMASA/\nOSBA inputs. \nFor OMASA, ISM files must be specified first.",
},
{
.id = CmdLnOptionId_outputFile,
@@ -241,57 +241,59 @@ static const CmdLnParser_Option cliOptions[] = {
.id = CmdLnOptionId_sampleRate,
.match = "sample_rate",
.matchShort = "fs",
- .description = "Input sampling rate in kHz (16, 32, 48) - required only with raw PCM inputs",
+ .description = "Input sampling rate in kHz (16, 32, 48) - required only with raw\nPCM inputs",
},
{
.id = CmdLnOptionId_trajFile,
.match = "trajectory_file",
.matchShort = "T",
- .description = "Head rotation trajectory file for simulation of head tracking (only for binaural outputs)",
+ .description = "Head rotation trajectory file for simulation of head tracking\n(only for binaural outputs)",
},
{
.id = CmdLnOptionId_refRotFile,
.match = "reference_rotation_file",
.matchShort = "rf",
- .description = "Reference rotation trajectory file for simulation of head tracking (only for binaural outputs)",
+ .description = "Reference rotation trajectory file for simulation of head tracking\n(only for binaural outputs)",
},
{
.id = CmdLnOptionId_customHrtfFile,
.match = "custom_hrtf",
.matchShort = "hrtf",
- .description = "Custom HRTF file for binaural rendering (only for binaural outputs)",
+ .description = "Custom HRTF file for binaural rendering\n(only for binaural outputs)",
},
{
.id = CmdLnOptionId_renderConfigFile,
.match = "render_config_parameters",
.matchShort = "render_config",
- .description = "Binaural renderer configuration parameters in file (only for binaural outputs)",
+ .description = "Binaural renderer configuration parameters in file\n(only for binaural outputs)",
},
{
.id = CmdLnOptionId_nonDiegeticPan,
.match = "non_diegetic_panning",
.matchShort = "non_diegetic_pan",
- .description = "Panning mono non diegetic sound to stereo -90<= pan <= 90\nleft or l or 90->left, right or r or -90->right, center or c or 0 ->middle\n",
+ .description = "Panning mono non diegetic sound to stereo -90<= pan <= 90\nleft or l or 90->left, right or r or -90->right,\ncenter or c or 0 ->middle",
},
{
.id = CmdLnOptionId_orientationTracking,
.match = "tracking_type",
.matchShort = "otr",
- .description = "Head orientation tracking type: 'none', 'ref', 'avg' or `ref_vec` or `ref_vec_lev` (only for binaural outputs)",
+ .description = "Head orientation tracking type: 'none', 'ref', 'avg' or `ref_vec`\nor `ref_vec_lev` (only for binaural outputs)",
},
{
.id = CmdlnOptionId_lfePosition,
.match = "lfe_position",
.matchShort = "lp",
- .description = "Output LFE position. Comma-delimited triplet of [gain, azimuth, elevation] where gain is linear (like --gain, -g) and azimuth, elevation are in degrees.\nIf specified, overrides the default behavior which attempts to map input to output LFE channel(s)",
+ .description = "Output LFE position. Comma-delimited triplet of [gain, azimuth,\nelevation] where gain is linear (like --gain, -g) and azimuth,\nelevation are in degrees. If specified, overrides the default\nbehavior which attempts to map input to output LFE channel(s)",
+ },
+ {
+ .id = CmdlnOptionId_lfeMatrix,
+ .match = "lfe_matrix",
+ .matchShort = "lm",
+ .description = "LFE panning matrix. File (CSV table) containing a matrix of\ndimensions [ num_input_lfe x num_output_channels ] with elements\nspecifying linear routing gain (like --gain, -g). If specified,\noverrides the output LFE position option and the default\nbehavior which attempts to map input to output LFE channel(s)",
},
- { .id = CmdlnOptionId_lfeMatrix,
- .match = "lfe_matrix",
- .matchShort = "lm",
- .description = "LFE panning matrix. File (CSV table) containing a matrix of dimensions [ num_input_lfe x num_output_channels ] with elements specifying linear routing gain (like --gain, -g). \nIf specified, overrides the output LFE position option and the default behavior which attempts to map input to output LFE channel(s)" },
{
.id = CmdLnOptionId_noDelayCmp,
- .match = "no_delay_comparison",
+ .match = "no_delay_compensation",
.matchShort = "no_delay_cmp",
.description = "[flag] Turn off delay compensation",
},
@@ -299,7 +301,7 @@ static const CmdLnParser_Option cliOptions[] = {
.id = CmdLnOptionId_complexityLevel,
.match = "complexity_level",
.matchShort = "level",
- .description = "Complexity level, level = (1, 2, 3), will be defined after characterisation.",
+ .description = "Complexity level, level = (1, 2, 3), will be defined after\ncharacterisation.",
},
{
.id = CmdLnOptionId_quietModeEnabled,
@@ -323,13 +325,13 @@ static const CmdLnParser_Option cliOptions[] = {
.id = CmdLnOptionId_referenceVectorFile,
.match = "reference_vector_file",
.matchShort = "rvf",
- .description = "Reference vector trajectory file for simulation of head tracking (only for binaural outputs)",
+ .description = "Reference vector trajectory file for simulation of head tracking\n(only for binaural outputs)",
},
{
.id = CmdLnOptionId_exteriorOrientationFile,
.match = "exterior_orientation_file",
.matchShort = "exof",
- .description = "External orientation trajectory file for simulation of external orientations",
+ .description = "External orientation trajectory file for simulation of external\norientations",
},
{
.id = CmdLnOptionId_framing,
@@ -341,19 +343,19 @@ static const CmdLnParser_Option cliOptions[] = {
.id = CmdLnOptionId_syncMdDelay,
.match = "sync_md_delay",
.matchShort = "smd",
- .description = "Metadata Synchronization Delay in ms, Default is 0. Quantized by 5ms subframes for TDRenderer (13ms -> 10ms -> 2subframes)",
+ .description = "Metadata Synchronization Delay in ms, Default is 0. Quantized by\n5ms subframes for TDRenderer (13ms -> 10ms -> 2subframes)",
},
{
.id = CmdLnOptionId_directivityPatternId,
.match = "ism_directivity_pattern_id",
.matchShort = "dpid",
- .description = "Directivity pattern ID(s) = [ID1, ID2, ID3, ID4]. Space-separated list of up to 4 numbers (unsigned integers) can be specified for BINAURAL and BINAURAL_ROOM_REVERB output configuration.\nID1, ID2, ID3, ID4 specify the directivity pattern IDs used for ISMs 1,2,3 and 4 respectively.\nThis options needs to be accompanied by a render_config file, otherwise a default directivity pattern is used.",
+ .description = "Directivity pattern ID(s) = [ID1, ID2, ID3, ID4]. Space-separated\nlist of up to 4 numbers (unsigned integers) can be specified for\nBINAURAL and BINAURAL_ROOM_REVERB output.\nID1, ID2, ID3, ID4 specify the directivity pattern IDs used for\nISMs 1,2,3 and 4 respectively. \nThis option needs to be accompanied by a render_config file,\notherwise a default directivity pattern is used.",
},
{
.id = CmdLnOptionId_acousticEnvironmentId,
.match = "acoustic_environment_id",
.matchShort = "aeid",
- .description = "Acoustic environment ID (number >= 0) for BINAURAL_ROOM_REVERB output configuration",
+ .description = "Acoustic environment ID (number >= 0) for BINAURAL_ROOM_REVERB output.",
},
};
@@ -368,6 +370,8 @@ static IVAS_AUDIO_CONFIG ambisonicsOrderToEnum( const int16_t order );
static void parseSceneDescriptionFile( char *path, char *audioFilePath, InputConfig *inConfig, IsmPositionProvider *positionProvider, MasaFileReader **masaReaders, LfeRoutingConfig **lfeRoutingConfigs );
+static void parseCombinedFormatInput( InputConfig *inConfig, char **configString );
+
static ivas_error parseCustomLayoutFile( const char *filePath, IVAS_CUSTOM_LS_DATA *pLsSetupCustom );
static CmdlnArgs parseCmdlnArgs( const int argc, char **argv );
@@ -584,25 +588,7 @@ static void setupWithSingleFormatInput(
strncpy( audioFilePath, args.inputFilePath, FILENAME_MAX - 1 );
/* Depending on input format, prepare metadata reading for ISM or MASA */
- if ( args.inConfig.numMasaBuses != 0 )
- {
- if ( args.inConfig.numMasaBuses != args.numInMetadataFiles )
- {
- fprintf( stderr, "Error: all MASA inputs must have a corresponding metadata file" );
- exit( -1 );
- }
-
- for ( int16_t i = 0; i < args.numInMetadataFiles; ++i )
- {
- masaReaders[i] = MasaFileReader_open( args.inMetadataFilePaths[i] );
- if ( masaReaders[i] == NULL )
- {
- fprintf( stderr, "Could not open MASA metadata file %s\n", args.inMetadataFilePaths[i] );
- exit( -1 );
- }
- }
- }
- else if ( args.inConfig.numAudioObjects != 0 )
+ if ( args.inConfig.numAudioObjects != 0 )
{
positionProvider->numObjects = args.inConfig.numAudioObjects;
for ( int16_t i = 0; i < positionProvider->numObjects; ++i )
@@ -625,6 +611,26 @@ static void setupWithSingleFormatInput(
}
}
}
+ if ( args.inConfig.numMasaBuses != 0 )
+ {
+ if ( args.inConfig.numMasaBuses != ( args.numInMetadataFiles - args.inConfig.numAudioObjects ) )
+ {
+ fprintf( stderr, "Error: all MASA inputs must have a corresponding metadata file" );
+ exit( -1 );
+ }
+
+ int16_t reader_idx = 0;
+ for ( int16_t i = args.inConfig.numAudioObjects; i < args.numInMetadataFiles; ++i )
+ {
+ reader_idx = i - args.inConfig.numAudioObjects;
+ masaReaders[reader_idx] = MasaFileReader_open( args.inMetadataFilePaths[i] );
+ if ( masaReaders[reader_idx] == NULL )
+ {
+ fprintf( stderr, "Could not open MASA metadata file %s\n", args.inMetadataFilePaths[i] );
+ exit( -1 );
+ }
+ }
+ }
return;
}
@@ -1804,16 +1810,11 @@ static bool parseInConfig(
inConfig->masaBuses[0].gain_dB = 0.0f;
break;
case IVAS_AUDIO_CONFIG_OBA:
- /* If input format is objects, parse the characters after "ISM" to get number of objects */
+ /* If input format is objects, parse the characters after "ISM" to get
+ * number of objects and check for combined formats. */
{
char *ptr = NULL;
inConfig->numAudioObjects = (uint16_t) strtol( inFormatStr + 3, &ptr, 10 );
- if ( ptr == NULL || *ptr != '\0' )
- {
- /* Failed to parse string as a number */
- fprintf( stderr, "Cannot parse string \"%s\" as a valid input format", inFormatStr );
- return false;
- }
if ( inConfig->numAudioObjects > RENDERER_MAX_ISM_INPUTS )
{
fprintf( stderr, "Too many objects at input. Max %d supported.", RENDERER_MAX_ISM_INPUTS );
@@ -1825,6 +1826,17 @@ static bool parseInConfig(
inConfig->audioObjects[i].inputChannelIndex = i;
inConfig->audioObjects[i].gain_dB = 0.0f;
}
+ if ( *ptr != '\0' )
+ {
+ /* Try to parse combined format */
+ parseCombinedFormatInput( inConfig, &ptr );
+ }
+ if ( ptr == NULL || *ptr != '\0' )
+ {
+ /* Failed to parse string as a number */
+ fprintf( stderr, "Cannot parse string \"%s\" as a valid input format", inFormatStr );
+ return false;
+ }
}
break;
case IVAS_AUDIO_CONFIG_INVALID:
@@ -2255,7 +2267,7 @@ static void parseOption(
}
break;
case CmdLnOptionId_inputMetadata:
- assert( numOptionValues <= RENDERER_MAX_ISM_INPUTS );
+ assert( numOptionValues <= RENDERER_MAX_ISM_INPUTS + RENDERER_MAX_MASA_INPUTS );
for ( int16_t i = 0; i < numOptionValues; ++i )
{
strncpy( args->inMetadataFilePaths[i], optionValues[i], RENDERER_MAX_CLI_ARG_LENGTH - 1 );
@@ -3086,6 +3098,41 @@ static void parseMasa(
return;
}
+static void parseCombinedFormatInput(
+ InputConfig *inConfig,
+ char **configString )
+{
+ IVAS_AUDIO_CONFIG audioConfig;
+ audioConfig = parseAudioConfig( *configString );
+
+ if ( audioConfig == IVAS_AUDIO_CONFIG_FOA || audioConfig == IVAS_AUDIO_CONFIG_HOA2 || audioConfig == IVAS_AUDIO_CONFIG_HOA3 )
+ {
+ /* OSBA */
+ inConfig->numAmbisonicsBuses = 1;
+ inConfig->ambisonicsBuses[0].audioConfig = audioConfig;
+ inConfig->ambisonicsBuses[0].inputChannelIndex = inConfig->numAudioObjects;
+ inConfig->ambisonicsBuses[0].gain_dB = -6.f;
+ *configString += 4;
+
+ /* Modify input gain for objects too */
+ for ( int16_t i = 0; i < inConfig->numAudioObjects; ++i )
+ {
+ inConfig->audioObjects[i].gain_dB = -6.f;
+ }
+ }
+ else if ( audioConfig == IVAS_AUDIO_CONFIG_MASA1 || audioConfig == IVAS_AUDIO_CONFIG_MASA2 )
+ {
+ /* OMASA */
+ inConfig->numMasaBuses = 1;
+ inConfig->masaBuses[0].audioConfig = audioConfig;
+ inConfig->masaBuses[0].inputChannelIndex = inConfig->numAudioObjects;
+ inConfig->masaBuses[0].gain_dB = 0.0f;
+ *configString += 5;
+ }
+
+ return;
+}
+
static ivas_error parseCustomLayoutFile(
const char *filePath,
IVAS_CUSTOM_LS_DATA *pLsSetupCustom )
@@ -3302,10 +3349,13 @@ static void printSupportedAudioConfigs( void )
"HOA2",
"HOA3",
"ISMx (input only)",
+ "ISMxSBAy (OSBA, input only)",
+ "ISMxMASAy (OMASA, input only)",
"MASAx",
"BINAURAL (output only)",
"BINAURAL_ROOM_IR (output only)",
"BINAURAL_ROOM_REVERB (output only)",
+ "META (Scene description, input only)",
};
fprintf( stdout, "Supported audio formats:\n" );
@@ -3313,6 +3363,7 @@ static void printSupportedAudioConfigs( void )
{
fprintf( stdout, "%s\n", supportedFormats[i] );
}
+ fprintf( stdout, "\n" );
return;
}
diff --git a/lib_com/basop_util.c b/lib_com/basop_util.c
index ec15e9769bde64635ccb2196c7ec7932c6d08e5d..3d6324783201b56b9dcc849ceab2b8dd2ee0b6c3 100644
--- a/lib_com/basop_util.c
+++ b/lib_com/basop_util.c
@@ -1409,16 +1409,11 @@ Word32 BASOP_Util_Divide3232_Scale_newton( Word32 x, Word32 y, Word16 *s )
*s = 0;
return ( (Word32) 0 );
}
-
-#if 0
- sign = L_xor( x, y ); /* check (sign < 0) for result negation */
-
- if ( x < 0 )
- {
- x = L_negate( x );
- }
+#ifdef FIX_USAN_BASOP_UTIL_DIVIDE3232
+ IF( EQ_32( y, (Word32) 0x80000000 ) )
#else
IF( EQ_32( y, 0x80000000 ) )
+#endif
{
/* Division by -1.0: same as negation of numerator */
/* Return normalized negated numerator */
@@ -1429,7 +1424,6 @@ Word32 BASOP_Util_Divide3232_Scale_newton( Word32 x, Word32 y, Word16 *s )
}
sign = y;
move32();
-#endif
if ( y < 0 )
{
y = L_negate( y );
@@ -2650,10 +2644,16 @@ Word32 BASOP_Util_Add_Mant32Exp /* o : normalized result mantissa */
*/
if ( !a_m )
- a_e = add( b_e, 0 );
+ {
+ a_e = b_e;
+ move16();
+ }
if ( !b_m )
- b_e = add( a_e, 0 );
+ {
+ b_e = a_e;
+ move16();
+ }
shift = sub( a_e, b_e );
shift = s_max( -31, shift );
@@ -2674,7 +2674,10 @@ Word32 BASOP_Util_Add_Mant32Exp /* o : normalized result mantissa */
if ( shift )
L_tmp = L_shl( L_tmp, shift );
if ( L_tmp == 0 )
- a_e = add( 0, 0 );
+ {
+ a_e = 0;
+ move16();
+ }
if ( L_tmp != 0 )
a_e = sub( a_e, shift );
*ptr_e = a_e;
diff --git a/lib_com/bits_alloc_fx.c b/lib_com/bits_alloc_fx.c
index e9abb7651e854e529e6ebfbb5a43857cb5d4696a..3bfcd0c20a7a8696fbc479e6363951de2f377807 100644
--- a/lib_com/bits_alloc_fx.c
+++ b/lib_com/bits_alloc_fx.c
@@ -434,174 +434,12 @@ static Word16 fcb_table(
}
/*-------------------------------------------------------------------*
- * acelp_FCB_allocator()
+ * acelp_FCB_allocator_fx()
*
* Routine to allocate fixed innovation codebook bit-budget
*--------------------------------------------------------------------*/
-#ifndef REMOVE_EVS_DUPLICATES
-static ivas_error acelp_FCB_allocator(
- Word16 *nBits, /* i/o: available bit-budget */
- Word16 fixed_cdk_index[], /* o : codebook index Q0 */
- Word16 nb_subfr, /* i : number of subframes */
- const Word16 L_subfr, /* i : subframe length */
- const Word16 coder_type, /* i : coder type */
- const Word16 tc_subfr, /* i : TC subframe index */
- const Word16 fix_first /* i : flag to indicate whether the first subframe bit-budget was fixed */
-)
-{
- Word16 cdbk, sfr, step;
- Word16 nBits_tmp;
- Word16 *p_fixed_cdk_index;
- Word16 max_n;
- ivas_error error;
- // PMT("Not floating point computation, but fixed point operator are still missing ")
-
- error = IVAS_ERR_OK;
- move32();
-
- cdbk = coder_type; /* just to avoid warning when DEBUGGING is deactivated */
- move16();
-
- p_fixed_cdk_index = fixed_cdk_index;
-
- /* TRANSITION coding: first subframe bit-budget was already fixed, glottal pulse not in the first subframe */
- test();
- IF( GE_16( tc_subfr, L_SUBFR ) && fix_first )
- {
- Word16 i;
-
- FOR( i = 0; i < nb_subfr; i++ )
- {
- *nBits = sub( *nBits, ACELP_FIXED_CDK_BITS( fixed_cdk_index[i] ) );
- move16();
- }
- return error;
- }
-
- /* TRANSITION coding: first subframe bit-budget was already fixed, glottal pulse in the first subframe */
- sfr = 0;
- move16();
- IF( fix_first )
- {
- *nBits = sub( *nBits, ACELP_FIXED_CDK_BITS( fixed_cdk_index[0] ) );
- move16();
- sfr = 1;
- move16();
- p_fixed_cdk_index++;
- nb_subfr = 3;
- move16();
- }
-
- /* distribute the bit-budget equally between subframes */
- IF( GT_16( L_subfr, L_SUBFR ) ) /* access fast_FCB_bits_2sfr */
- {
- max_n = 6;
- move16();
- }
- ELSE
- {
- max_n = ACELP_FIXED_CDK_NB;
- move16();
- }
- FOR( cdbk = 0; cdbk < max_n; cdbk++ )
- {
- IF( GT_32( L_mult0( fcb_table( cdbk, L_subfr ), nb_subfr ), L_deposit_l( *nBits ) ) )
- {
- BREAK;
- }
- }
- cdbk = sub( cdbk, 1 );
-
-#ifdef DEBUGGING
- if ( cdbk < 0 && coder_type != TRANSITION )
- {
- return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error: Too low bit-budget for fixed innovation codebook (frame = %d). Exiting! \n" );
- }
- if ( ( L_subfr == L_SUBFR && cdbk >= ACELP_FIXED_CDK_NB ) || ( L_subfr == 2 * L_SUBFR && fcb_table( cdbk, L_subfr ) == 128 /*stop value*/ ) )
- {
- return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error: Too high bit-budget for fixed innovation codebook (frame = %d). Exiting! \n" );
- }
-#endif
-
- set16_fx( p_fixed_cdk_index, cdbk, nb_subfr );
- nBits_tmp = 0;
- move16();
- IF( cdbk >= 0 )
- {
- nBits_tmp = fcb_table( cdbk, L_subfr );
- }
- ELSE
- {
- nBits_tmp = 0;
- move16();
- }
- *nBits = sub( *nBits, i_mult( nBits_tmp, nb_subfr ) );
- move16();
-
- /* try to increase the FCB bit-budget of the first subframe(s) */
- IF( LT_16( cdbk, ACELP_FIXED_CDK_NB - 1 ) )
- {
- step = sub( fcb_table( add( cdbk, 1 ), L_subfr ), nBits_tmp );
- WHILE( *nBits >= step )
- {
- ( *p_fixed_cdk_index )++;
- *nBits = sub( *nBits, step );
- move16();
- p_fixed_cdk_index++;
- }
-
- /* try to increase the FCB of the first subframe in cases when the next step is lower than the current step */
- step = sub( fcb_table( add( fixed_cdk_index[sfr], 1 ), L_subfr ), fcb_table( fixed_cdk_index[sfr], L_subfr ) );
- test();
- IF( GE_16( *nBits, step ) && cdbk >= 0 )
- {
- fixed_cdk_index[sfr] = add( fixed_cdk_index[sfr], 1 );
- move16();
- *nBits = sub( *nBits, step );
- move16();
- test();
- IF( GE_16( *nBits, step ) && EQ_16( fixed_cdk_index[sfr + 1], sub( fixed_cdk_index[sfr], 1 ) ) )
- {
- sfr = add( sfr, 1 );
- fixed_cdk_index[sfr] = add( fixed_cdk_index[sfr], 1 );
- move16();
- *nBits = sub( *nBits, step );
- move16();
- }
- }
- }
- /* TRANSITION coding: allocate highest FCBQ bit-budget to the subframe with the glottal-shape codebook */
- IF( GE_16( tc_subfr, L_SUBFR ) )
- {
- Word16 tempr;
-
- SWAP( fixed_cdk_index[0], fixed_cdk_index[tc_subfr / L_SUBFR] );
-
- /* TRANSITION coding: allocate second highest FCBQ bit-budget to the last subframe */
- IF( idiv1616( tc_subfr, L_SUBFR ) < sub( nb_subfr, 1 ) )
- {
- SWAP( fixed_cdk_index[( tc_subfr - L_SUBFR ) / L_SUBFR], fixed_cdk_index[nb_subfr - 1] );
- }
- }
-
- /* when subframe length > L_SUBFR, number of bits instead of codebook index is signalled */
- IF( GT_16( L_subfr, L_SUBFR ) )
- {
- Word16 i, j;
- FOR( i = 0; i < nb_subfr; i++ )
- {
- j = fixed_cdk_index[i];
- move16();
- fixed_cdk_index[i] = fast_FCB_bits_2sfr[j];
- move16();
- }
- }
-
- return error;
-}
-#endif
-static ivas_error acelp_FCB_allocator_ivas(
+static ivas_error acelp_FCB_allocator_fx(
Word16 *nBits, /* i/o: available bit-budget */
Word16 fixed_cdk_index[], /* o : codebook index Q0 */
Word16 nb_subfr, /* i : number of subframes */
@@ -754,1141 +592,16 @@ static ivas_error acelp_FCB_allocator_ivas(
return error;
}
+
/*-------------------------------------------------------------------*
- * config_acelp1()
+ * config_acelp1_fx()
*
* Configure ACELP bit allocation
* - should be in range of <6700; 24350> for ACELP@12.8kHz
* - per channel bitrate minimum is 13250 kbps for ACELP@16kHz
*--------------------------------------------------------------------*/
-#ifndef REMOVE_EVS_DUPLICATES
-ivas_error config_acelp1(
- const Word16 enc_dec, /* i : encoder/decoder flag */
- const Word32 total_brate, /* i : total bitrate */
- const Word32 core_brate_inp, /* i : core bitrate */
- const Word16 core, /* i : core */
- const Word16 extl, /* i : extension layer */
- const Word32 extl_brate, /* i : extension layer bitrate */
- const Word16 L_frame, /* i : frame length at internal Fs */
- const Word16 GSC_noisy_speech, /* i : GSC on SWB noisy speech flag */
- ACELP_config *acelp_cfg, /* i : ACELP bit-allocation */
- const Word16 signalling_bits, /* i : number of signalling bits */
- const Word16 coder_type, /* i : coder type */
- const Word16 inactive_coder_type_flag, /* i : AVQ (0) or GSC (1) IC flag */
- const Word16 tc_subfr, /* i : TC subfr ID */
- const Word16 tc_call, /* i : TC call number (0,1,2,3,5(DEC)) */
- Word16 *nBits_es_Pred, /* o : number of bits for Es_pred Q */
- Word16 *unbits, /* o : number of unused bits */
- const Word16 element_mode, /* i : element mode */
- Word16 *uc_two_stage_flag, /* o : flag undicating two-stage UC */
- const Word16 tdm_lp_reuse_flag, /* i : LPC reuse flag (can be 1 only with secondary channel */
- const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag */
- const Word16 idchan, /* i : stereo channel ID */
- const Word16 active_cnt, /* i : Active frame counter */
- const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag*/
- const Word16 tdm_LRTD_flag, /* i : LRTD stereo mode flag */
- const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */
-)
-{
- Word16 i, bits, nb_subfr;
- Word16 flag_hardcoded, coder_type_sw, fix_first;
- Word32 core_brate;
-#ifdef DEBUGGING
- (void) active_cnt;
-#endif
- ivas_error error;
-
- error = IVAS_ERR_OK;
- move32();
- // PMT("Not floating point computation, but fixed point operator are still missing ")
- /*-----------------------------------------------------------------*
- * Set the flag indicating two-stage Unvoiced (UC) frame
- *-----------------------------------------------------------------*/
-
- *uc_two_stage_flag = 0;
- move16();
- IF( EQ_16( coder_type, UNVOICED ) )
- {
- test();
- test();
- test();
- test();
- test();
- if ( GE_32( total_brate, MIN_UNVOICED_TWO_STAGE_BRATE ) && element_mode > EVS_MONO && ( idchan == 0 || ( ( GE_32( total_brate, 8500 ) || extl_brate == 0 ) && EQ_16( tdm_LRTD_flag, 1 ) ) ) )
- {
- *uc_two_stage_flag = 1;
- move16();
- }
- }
-
- /*-----------------------------------------------------------------*
- * Set the number of subframes
- *-----------------------------------------------------------------*/
-
- IF( EQ_16( L_frame, L_FRAME ) )
- {
- nb_subfr = NB_SUBFR;
- move16();
-
-#ifdef DEBUGGING
- if ( ( ( core_brate_inp < 5900 && coder_type > UNVOICED ) && !( core_brate_inp < MIN_TC_BRATE && coder_type == TRANSITION ) ) && !( idchan > 0 && element_mode == IVAS_CPE_TD ) && !( element_mode == IVAS_SCE && tdm_low_rate_mode ) )
- {
- return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error: Too low bitrate (%d bps) for ACELP@12k8 in frame %d. Exiting!\n", core_brate_inp );
- }
-
- if ( core_brate_inp > ACELP_12k8_HIGH_LIMIT && core == ACELP_CORE )
- {
- return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error: Too high bitrate (%d bps) for ACELP@12k8 in frame %d. Exiting!\n", core_brate_inp );
- }
-#endif
- }
- ELSE /* L_frame == L_FRAME16k */
- {
- nb_subfr = NB_SUBFR16k;
- move16();
-
-#ifdef DEBUGGING
- if ( core_brate_inp < ACELP_16k_LOW_LIMIT && core == ACELP_CORE )
- {
- return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error: Too low bitrate (%d bps) for ACELP@16k in frame %d. Exiting!\n", core_brate_inp );
- }
-#endif
- }
-
- coder_type_sw = coder_type;
- move16();
- IF( core != ACELP_CORE )
- {
- /* used in acelp_core_switch_enc() */
- nb_subfr = 1;
- move16();
- if ( EQ_16( L_frame, L_FRAME ) )
- {
- coder_type_sw = TRANSITION;
- move16();
- }
- }
-
- /*-----------------------------------------------------------------*
- * Check if the core_brate is hard coded (to keep BE for mono core) or not
- *-----------------------------------------------------------------*/
-
- flag_hardcoded = 0;
- move16();
- i = 0;
- move16();
-
- WHILE( i < SIZE_BRATE_INTERMED_TBL )
- {
- IF( EQ_32( core_brate_inp, brate_intermed_tbl[i] ) )
- {
- flag_hardcoded = 1;
- move16();
- BREAK;
- }
-
- IF( LT_32( core_brate_inp, brate_intermed_tbl[i] ) )
- {
- flag_hardcoded = 0;
- move16();
- BREAK;
- }
-
- i = add( i, 1 );
- }
-
- test();
- test();
- test();
- IF( EQ_16( element_mode, IVAS_CPE_TD ) && EQ_16( coder_type, AUDIO ) &&
- LE_32( core_brate_inp, STEREO_GSC_BIT_RATE_ALLOC ) && EQ_32( brate_intermed_tbl[i], ACELP_9k60 ) ) /* Bit allocation should be mapped to 8 kb/s instead of 9.6 kb/s in this case */
- {
- i = sub( i, 1 );
- }
-
- core_brate = brate_intermed_tbl[i];
- move32();
-
- if ( element_mode > EVS_MONO )
- {
- flag_hardcoded = 0; /* use automatic and flexible ACELP bit-budget allocation */
- move16();
- }
-
- test();
- if ( ( core != ACELP_CORE ) && ( element_mode == EVS_MONO ) ) /* needed for mode1 core switching in EVS mono */
- {
- flag_hardcoded = 1;
- move16();
- }
-
- /*-----------------------------------------------------------------*
- * ACELP bit allocation
- *-----------------------------------------------------------------*/
- test();
- test();
- IF( !( EQ_16( coder_type, TRANSITION ) && NE_16( tc_subfr, -1 ) ) || EQ_16( enc_dec, DEC ) )
- {
- /* Set the bit-budget */
- bits = extract_l( Mpy_32_32( core_brate_inp, ONE_BY_FRAMES_PER_SEC_Q31 ) ); // Q0
-
- test();
- test();
- IF( EQ_16( coder_type, TRANSITION ) && EQ_16( enc_dec, DEC ) && EQ_16( tc_call, 1 ) )
- {
- bits = add( bits, *nBits_es_Pred ); /* equalize for 4th signaling bit estimated at the encoder in TC_0_192 */
- }
-
- /* Subtract signalling bits */
- test();
- test();
- IF( EQ_16( enc_dec, DEC ) && EQ_16( idchan, 1 ) && element_mode > EVS_MONO )
- {
- bits = sub( bits, TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS );
-
- IF( EQ_16( tdm_LRTD_flag, 1 ) )
- {
- bits = add( bits, STEREO_BITS_TCA );
- }
-
- /* subtract TBE/BWE flag */
- test();
- test();
- test();
- test();
- test();
- test();
- IF( extl_brate > 0 && ( EQ_16( extl, WB_TBE ) || EQ_16( extl, SWB_TBE ) || EQ_16( extl, FB_TBE ) || EQ_16( extl, WB_BWE ) || EQ_16( extl, SWB_BWE ) || EQ_16( extl, FB_BWE ) ) )
- {
- bits = sub( bits, 1 );
- }
- }
- ELSE
- {
- /* Subtract signalling bits */
- bits = sub( bits, signalling_bits );
- }
-
- test();
- test();
- test();
- test();
- test();
- test();
- IF( extl_brate > 0 && ( EQ_16( extl, WB_TBE ) || EQ_16( extl, SWB_TBE ) || EQ_16( extl, FB_TBE ) || EQ_16( extl, WB_BWE ) || EQ_16( extl, SWB_BWE ) || EQ_16( extl, FB_BWE ) ) )
- {
- /* extension layer signalling bit is counted in the extension layer bitbudget */
- bits = add( bits, 1 );
- }
-
- /*-----------------------------------------------------------------*
- * LSF Q bit-budget
- *-----------------------------------------------------------------*/
- test();
- test();
- test();
- IF( !tdm_lp_reuse_flag || idchan == 0 )
- {
- /* LSF Q bit-budget */
- acelp_cfg->lsf_bits = LSF_bits_tbl[LSF_BIT_ALLOC_IDX_fx( core_brate, coder_type )];
- move16();
-
- IF( !flag_hardcoded )
- {
- IF( EQ_16( L_frame, L_FRAME ) )
- {
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- IF( EQ_16( element_mode, IVAS_SCE ) && tdm_low_rate_mode )
- {
- acelp_cfg->lsf_bits = LSF_bits_tbl[LSF_BIT_ALLOC_IDX_fx( core_brate, coder_type )];
- move16();
- }
- ELSE IF( ( LT_32( total_brate, 7200 ) || coder_type == INACTIVE || EQ_16( coder_type, AUDIO ) ) && EQ_16( idchan, 1 ) )
- {
- /* TD stereo, secondary channel: do nothing */
- acelp_cfg->lsf_bits = LSF_bits_tbl[LSF_BIT_ALLOC_IDX_fx( core_brate, coder_type )];
- move16();
- }
- ELSE IF( element_mode > EVS_MONO && EQ_16( coder_type, AUDIO ) && LT_32( brate_intermed_tbl[i], ACELP_9k60 ) )
- {
- /* primary channel: do nothing */
- }
- ELSE IF( element_mode > EVS_MONO && EQ_16( coder_type, AUDIO ) /*&& brate_intermed_tbl[i] >= ACELP_9k60*/ )
- {
- acelp_cfg->lsf_bits = 42;
- move16();
- }
- ELSE IF( LE_32( total_brate, 9600 ) || EQ_16( coder_type, UNVOICED ) )
- {
- acelp_cfg->lsf_bits = 31;
- move16();
- }
- ELSE IF( LE_32( total_brate, 20000 ) )
- {
- acelp_cfg->lsf_bits = 36;
- move16();
- }
- ELSE
- {
- acelp_cfg->lsf_bits = 41;
- move16();
- }
- }
- ELSE /* L_frame == L_FRAME16k */
- {
- acelp_cfg->lsf_bits = 41;
- move16();
- }
- }
-
- bits = sub( bits, acelp_cfg->lsf_bits );
-
- /* mid-LSF Q bit-budget */
- acelp_cfg->mid_lsf_bits = mid_LSF_bits_tbl[LSF_BIT_ALLOC_IDX_fx( core_brate, coder_type )];
- move16();
-
- test();
- if ( element_mode > EVS_MONO && EQ_16( coder_type, AUDIO ) /*&& brate_intermed_tbl[i] < ACELP_9k60*/ )
- {
- acelp_cfg->mid_lsf_bits = 5;
- move16();
- /* primary channel: do nothing */
- }
-
- bits = sub( bits, acelp_cfg->mid_lsf_bits );
- }
- ELSE IF( EQ_16( tdm_lp_reuse_flag, 1 ) && EQ_16( idchan, 1 ) && NE_16( active_cnt, 1 ) )
- {
- bits = sub( bits, TDM_IC_LSF_PRED_BITS );
- }
- /* gain Q bit-budget - part 1: 'Es_pred' of memory-less gain Q */
- test();
- test();
- test();
- test();
- test();
- test();
- IF( ( NE_16( coder_type, UNVOICED ) && NE_16( coder_type, AUDIO ) && coder_type != INACTIVE && !( LE_32( core_brate, ACELP_8k00 ) && NE_16( coder_type, TRANSITION ) ) ) /* mid bitrates in GC and VC, low+mid bitrates in TC */ ||
- ( coder_type == INACTIVE && !inactive_coder_type_flag ) /* AVQ inactive */
- )
- {
- *nBits_es_Pred = Es_pred_bits_tbl[BIT_ALLOC_IDX_fx( core_brate, coder_type, -1, -1 )];
- move16();
- bits = sub( bits, *nBits_es_Pred );
- }
- ELSE IF( *uc_two_stage_flag )
- {
- *nBits_es_Pred = 4;
- move16();
- bits = sub( bits, *nBits_es_Pred );
- }
- }
- ELSE
- {
- bits = *unbits;
- move16();
- }
-
- test();
- IF( EQ_16( coder_type, TRANSITION ) && tc_call == 0 )
- {
- *unbits = bits;
- return error;
- }
-
- /*-----------------------------------------------------------------*
- * Low-rate mode - bits are allocated in tdm_low_rate_enc()
- *-----------------------------------------------------------------*/
- test();
- IF( EQ_16( element_mode, IVAS_SCE ) && tdm_low_rate_mode )
- {
- acelp_cfg->FEC_mode = 0;
- acelp_cfg->ltf_mode = FULL_BAND;
- *nBits_es_Pred = 0;
- *unbits = 0;
- acelp_cfg->ubits = 0;
- move16();
- move16();
- move16();
- move16();
- move16();
-
- return error;
- }
-
- /*-----------------------------------------------------------------*
- * Supplementary information for FEC
- *-----------------------------------------------------------------*/
-
- acelp_cfg->FEC_mode = 0;
- move16();
- test();
- test();
- IF( GE_32( core_brate, ACELP_11k60 ) && ( idchan == 0 || element_mode == EVS_MONO ) )
- {
- acelp_cfg->FEC_mode = 1;
- move16();
-
- test();
- test();
- IF( GT_16( coder_type, UNVOICED ) && LT_16( coder_type, AUDIO ) && NE_16( coder_type, VOICED ) )
- {
- bits = sub( bits, FEC_BITS_CLS );
- }
-
- IF( NE_16( coder_type, TRANSITION ) )
- {
- IF( GE_32( total_brate, ACELP_16k40 ) )
- {
- acelp_cfg->FEC_mode = 2;
- move16();
- test();
- IF( GT_16( coder_type, UNVOICED ) && LT_16( coder_type, AUDIO ) )
- {
- bits = sub( bits, FEC_BITS_ENR );
- }
- }
-
- IF( GE_32( total_brate, ACELP_32k ) )
- {
- acelp_cfg->FEC_mode = 3;
- move16();
-
- test();
- IF( GT_16( coder_type, UNVOICED ) && LT_16( coder_type, AUDIO ) )
- {
- bits = sub( bits, FEC_BITS_POS );
- }
- }
- }
- }
-
- /*-----------------------------------------------------------------*
- * LP filtering of the adaptive excitation
- *-----------------------------------------------------------------*/
- test();
- test();
- test();
- test();
- test();
- test();
- IF( idchan > 0 && element_mode > EVS_MONO )
- {
- acelp_cfg->ltf_mode = FULL_BAND;
- move16();
- }
- ELSE IF( EQ_16( coder_type, UNVOICED ) )
- {
- acelp_cfg->ltf_mode = FULL_BAND;
- move16();
- }
- ELSE IF( ( EQ_16( coder_type, GENERIC ) || EQ_16( coder_type, TRANSITION ) ) && LT_32( core_brate, ACELP_11k60 ) )
- {
- acelp_cfg->ltf_mode = LOW_PASS;
- move16();
- }
- ELSE IF( GE_32( core_brate, ACELP_11k60 ) && ( NE_16( coder_type, AUDIO ) && !( coder_type == INACTIVE && EQ_16( L_frame, L_FRAME ) ) ) )
- {
- test();
- test();
- IF( coder_type == INACTIVE && EQ_16( L_frame, L_FRAME16k ) && inactive_coder_type_flag ) /* GSC Inactive @16kHz */
- {
- acelp_cfg->ltf_mode = FULL_BAND;
- move16();
- }
- ELSE
- {
- acelp_cfg->ltf_mode = NORMAL_OPERATION;
- move16();
- IF( coder_type != TRANSITION )
- {
- bits = sub( bits, nb_subfr );
- }
- }
- }
- ELSE
- {
- acelp_cfg->ltf_mode = FULL_BAND;
- move16();
- }
-
- /*-----------------------------------------------------------------*
- * UC bit-budget
- *-----------------------------------------------------------------*/
- test();
- test();
- test();
- test();
- test();
- test();
- IF( ( ( EQ_16( coder_type, UNVOICED ) && !( *uc_two_stage_flag ) ) || ( coder_type == INACTIVE && LE_32( core_brate, ACELP_9k60 ) ) ) && ( idchan == 0 || element_mode == EVS_MONO ) )
- {
- bits = sub( bits, NBITS_NOISENESS ); /* noiseness */
- }
- IF( EQ_16( coder_type, UNVOICED ) && !( *uc_two_stage_flag ) )
- {
- bits = sub( bits, 3 * NB_SUBFR ); /* tilt factor */
- }
-
- /*-----------------------------------------------------------------*
- * TC bit-budget
- *-----------------------------------------------------------------*/
-
- fix_first = 0;
- move16();
- IF( EQ_16( coder_type, TRANSITION ) )
- {
- if ( EQ_16( tc_call, 2 ) )
- {
- fix_first = 1;
- move16();
- }
-
- /* TC signalling */
- IF( EQ_16( L_frame, L_FRAME ) )
- {
- IF( EQ_16( tc_subfr, TC_0_0 ) )
- {
- IF( enc_dec == ENC )
- {
- bits = sub( bits, 1 ); /* TC signalling */
- }
-
- IF( EQ_16( acelp_cfg->ltf_mode, NORMAL_OPERATION ) )
- {
- bits = sub( bits, 3 ); /* LP filtering flag */
- }
- }
- ELSE IF( EQ_16( tc_subfr, TC_0_64 ) )
- {
- IF( enc_dec == ENC )
- {
- bits = sub( bits, 4 ); /* TC signalling */
- }
-
- IF( EQ_16( acelp_cfg->ltf_mode, NORMAL_OPERATION ) )
- {
- bits = sub( bits, 3 ); /* LP filtering flag */
- }
- }
- ELSE IF( EQ_16( tc_subfr, TC_0_128 ) )
- {
- IF( enc_dec == ENC )
- {
- bits = sub( bits, 4 ); /* TC signalling */
- }
-
- IF( EQ_16( acelp_cfg->ltf_mode, NORMAL_OPERATION ) )
- {
- bits = sub( bits, 2 ); /* LP filtering flag */
- }
- }
- ELSE IF( EQ_16( tc_subfr, TC_0_192 ) )
- {
- IF( enc_dec == ENC )
- {
- bits = sub( bits, 3 ); /* TC signalling */
- }
-
- IF( EQ_16( acelp_cfg->ltf_mode, NORMAL_OPERATION ) )
- {
- bits = sub( bits, 1 ); /* LP filtering flag */
- }
- }
- ELSE IF( EQ_16( tc_subfr, L_SUBFR ) )
- {
- IF( enc_dec == ENC )
- {
- bits = sub( bits, 3 ); /* TC signalling */
- }
-
- IF( EQ_16( acelp_cfg->ltf_mode, NORMAL_OPERATION ) )
- {
- bits = sub( bits, idiv1616( sub( L_FRAME - L_SUBFR, tc_subfr ), L_SUBFR ) ); /* LP filtering flag */
- }
- }
- ELSE
- {
- IF( enc_dec == ENC )
- {
- bits = sub( bits, 4 ); /* TC signalling */
- }
-
- IF( EQ_16( acelp_cfg->ltf_mode, NORMAL_OPERATION ) )
- {
- bits = sub( bits, idiv1616_1( sub( L_FRAME - L_SUBFR, tc_subfr ), L_SUBFR ) ); /* LP filtering flag */
- }
- }
- }
- ELSE /* L_frame == L_FRAME16k */
- {
- IF( enc_dec == ENC )
- {
- IF( LE_16( tc_subfr, 2 * L_SUBFR ) )
- {
- bits = sub( bits, 2 ); /* TC signalling */
- }
- ELSE
- {
- bits = sub( bits, 3 ); /* TC signalling */
- }
- }
-
- // bits -= ( L_FRAME16k - tc_subfr - L_SUBFR ) / L_SUBFR; /* LP filtering flag */
- bits = sub( bits, idiv1616_1( sub( L_FRAME16k - L_SUBFR, tc_subfr ), L_SUBFR ) ); /* LP filtering flag */
- }
-
- /* glottal-shape codebook bits */
- bits = sub( bits, 3 + 6 + 1 + 3 );
- }
-
- /*-----------------------------------------------------------------*
- * pitch, innovation, gains bit-budget
- *-----------------------------------------------------------------*/
-
- acelp_cfg->fcb_mode = 0;
- move16();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- IF( EQ_16( element_mode, IVAS_CPE_TD ) && EQ_16( tdm_low_rate_mode, 1 ) && ( coder_type != INACTIVE ) && NE_16( coder_type, UNVOICED ) ) /* GENERIC low rate mode for secondary channel */
- {
- set16_fx( acelp_cfg->pitch_bits, 0, NB_SUBFR16k );
- set16_fx( acelp_cfg->gains_mode, 0, NB_SUBFR16k );
-
- FOR( i = 0; i < 2; i++ )
- {
- acelp_cfg->pitch_bits[i] = 0;
- move16();
- IF( tdm_Pitch_reuse_flag == 0 )
- {
- acelp_cfg->pitch_bits[i] = ACB_bits_tbl[BIT_ALLOC_IDX_fx( ACELP_7k20, GENERIC, i_mult( 2 * L_SUBFR, i ), TC_SUBFR2IDX_fx( tc_subfr ) )];
- move16();
- bits = sub( bits, acelp_cfg->pitch_bits[i] );
- }
- acelp_cfg->gains_mode[i] = gain_bits_tbl[BIT_ALLOC_IDX_fx( ACELP_7k20, GENERIC, i_mult( i, L_SUBFR ), TC_SUBFR2IDX_fx( tc_subfr ) )];
- move16();
- bits = sub( bits, acelp_cfg->gains_mode[i] );
- }
- acelp_cfg->fcb_mode = 1;
- move16();
-
-#ifdef DEBUGGING
- if ( bits >= 55 )
- {
- printf( "too much bits -> %d, LPC = %d and pitch = %d\n", bits, tdm_lp_reuse_flag, tdm_Pitch_reuse_flag );
- acelp_FCB_allocator( &bits, acelp_cfg->fixed_cdk_index, 2, 2 * L_SUBFR, GENERIC, -1, 0 );
- }
- else
-#endif
- IF( GE_16( bits, 16 ) )
- {
- acelp_FCB_allocator( &bits, acelp_cfg->fixed_cdk_index, 2, 2 * L_SUBFR, GENERIC, -1, 0 );
- }
- ELSE
- {
- acelp_FCB_allocator( &bits, acelp_cfg->fixed_cdk_index, 2, 2 * L_SUBFR, GENERIC, -1, 0 );
- acelp_cfg->fixed_cdk_index[1] = -1;
- move16();
- }
- acelp_cfg->fixed_cdk_index[2] = -1;
- move16();
- acelp_cfg->fixed_cdk_index[3] = -1;
- move16();
- }
- ELSE IF( ( coder_type != INACTIVE && EQ_16( nb_subfr, NB_SUBFR ) && NE_16( coder_type, AUDIO ) ) || /* @12.8kHz core except of GSC */
- ( EQ_16( nb_subfr, NB_SUBFR16k ) && ( !inactive_coder_type_flag || coder_type != INACTIVE ) ) /* @16kHz core GC, TC, AVQ inactive */ ||
- EQ_16( core, HQ_CORE ) /* ACELP -> HQ switching in EVS */
- )
- {
- /* pitch Q & gain Q bit-budget - part 2*/
- FOR( i = 0; i < nb_subfr; i++ )
- {
- IF( EQ_16( L_frame, L_FRAME ) )
- {
- test();
- IF( EQ_16( tdm_Pitch_reuse_flag, 1 ) && EQ_16( idchan, 1 ) )
- {
- acelp_cfg->pitch_bits[i] = 0;
- move16();
- }
- ELSE
- {
- acelp_cfg->pitch_bits[i] = ACB_bits_tbl[BIT_ALLOC_IDX_fx( core_brate, coder_type, i_mult( i, L_SUBFR ), TC_SUBFR2IDX_fx( tc_subfr ) )];
- move16();
- }
- acelp_cfg->gains_mode[i] = gain_bits_tbl[BIT_ALLOC_IDX_fx( core_brate, coder_type_sw, i_mult( i, L_SUBFR ), TC_SUBFR2IDX_fx( tc_subfr ) )];
- move16();
- }
- ELSE /* L_frame == L_FRAME16k */
- {
- test();
- IF( EQ_16( tdm_Pitch_reuse_flag, 1 ) && EQ_16( idchan, 1 ) )
- {
- acelp_cfg->pitch_bits[i] = 0;
- move16();
- }
- ELSE
- {
- acelp_cfg->pitch_bits[i] = ACB_bits_16kHz_tbl[BIT_ALLOC_IDX_16KHZ_fx( core_brate, coder_type, i_mult( i, L_SUBFR ), TC_SUBFR2IDX_16KHZ_fx( tc_subfr ) )];
- move16();
- }
- acelp_cfg->gains_mode[i] = gain_bits_16kHz_tbl[BIT_ALLOC_IDX_16KHZ_fx( core_brate, coder_type_sw, i_mult( i, L_SUBFR ), TC_SUBFR2IDX_16KHZ_fx( tc_subfr ) )];
- move16();
- }
-
- bits = sub( bits, acelp_cfg->pitch_bits[i] );
-
- test();
- IF( coder_type == INACTIVE && EQ_16( acelp_cfg->gains_mode[i], 6 ) /* VQ vs. SQ threshold @32 kbps */ )
- {
- bits = sub( bits, 5 );
- }
- ELSE
- {
- if ( EQ_16( *uc_two_stage_flag, 1 ) )
- {
- acelp_cfg->gains_mode[i] = 7;
- move16();
- }
-
- bits = sub( bits, acelp_cfg->gains_mode[i] );
- }
- }
-
- /* algebraic codebook bit-budget */
- test();
- test();
- test();
- test();
- test();
- test();
- IF( flag_hardcoded /* EVS */ ||
- ( GE_32( core_brate_inp, MIN_BRATE_AVQ_EXC ) && coder_type != INACTIVE ) /* high-birate ACELP except IC */ ||
- ( !inactive_coder_type_flag && coder_type == INACTIVE ) /* AVQ inactive */ )
- {
- FOR( i = 0; i < nb_subfr; i++ )
- {
- IF( EQ_16( L_frame, L_FRAME ) )
- {
- acelp_cfg->fixed_cdk_index[i] = FCB_bits_tbl[BIT_ALLOC_IDX_fx( core_brate, coder_type, i_mult( i, L_SUBFR ), TC_SUBFR2IDX_fx( tc_subfr ) )];
- move16();
- }
- ELSE /* L_frame == L_FRAME16k */
- {
- acelp_cfg->fixed_cdk_index[i] = FCB_bits_16kHz_tbl[BIT_ALLOC_IDX_16KHZ_fx( core_brate, coder_type, i_mult( i, L_SUBFR ), TC_SUBFR2IDX_16KHZ_fx( tc_subfr ) )];
- move16();
- }
- bits = sub( bits, acelp_cfg->fixed_cdk_index[i] );
- }
- }
- ELSE IF( !( EQ_16( coder_type, UNVOICED ) && EQ_16( tdm_low_rate_mode, 1 ) && EQ_16( element_mode, IVAS_CPE_TD ) ) )
- {
- test();
- IF( EQ_16( coder_type, UNVOICED ) && !( *uc_two_stage_flag ) )
- {
- i = idiv1616( bits, NB_SUBFR );
- IF( s_and( i, 1 ) == 0 )
- {
- i = sub( i, 1 ); /* must be odd */
- }
- i = s_min( i, 13 );
-#ifdef DEBUG_MODE_TD
- if ( i < 0 )
- IVAS_ERROR( IVAS_ERR_INTERNAL, "ERROR::: UC negative index should not happen at frame %d\n" );
-#endif
- i = s_max( i, 0 ); /* If i == 0-> random noise generator will be used as FCB */
- set16_fx( acelp_cfg->fixed_cdk_index, i, NB_SUBFR );
- bits = sub( bits, i_mult( i, NB_SUBFR ) );
- }
- ELSE
- {
-
- acelp_cfg->fcb_mode = 1;
- move16();
- test();
- test();
- IF( EQ_16( element_mode, IVAS_CPE_TD ) )
- {
- IF( GE_16( bits, i_mult( ACELP_FIXED_CDK_BITS( 0 ), ( nb_subfr ) ) ) ) /* enough bits for all fcb */
- {
- acelp_FCB_allocator( &bits, acelp_cfg->fixed_cdk_index, nb_subfr, L_SUBFR, coder_type, tc_subfr, fix_first );
- }
- ELSE IF( GE_16( bits, i_mult( ACELP_FIXED_CDK_BITS( 0 ), sub( nb_subfr, 1 ) ) ) )
- {
- acelp_FCB_allocator( &bits, acelp_cfg->fixed_cdk_index, nb_subfr - 1, L_SUBFR, coder_type, tc_subfr, fix_first );
- acelp_cfg->fixed_cdk_index[3] = -1;
- move16();
- }
- ELSE IF( GE_16( bits, i_mult( ACELP_FIXED_CDK_BITS( 0 ), sub( nb_subfr, 2 ) ) ) )
- {
- acelp_FCB_allocator( &bits, acelp_cfg->fixed_cdk_index, sub( nb_subfr, 2 ), L_SUBFR, coder_type, tc_subfr, fix_first );
- acelp_cfg->fixed_cdk_index[2] = acelp_cfg->fixed_cdk_index[1];
- move16();
- acelp_cfg->fixed_cdk_index[1] = -1;
- move16();
- acelp_cfg->fixed_cdk_index[3] = -1;
- move16();
- }
- ELSE IF( GE_16( bits, ACELP_FIXED_CDK_BITS( 0 ) ) )
- {
- acelp_FCB_allocator( &bits, acelp_cfg->fixed_cdk_index, 1, L_SUBFR, coder_type, tc_subfr, fix_first );
- acelp_cfg->fixed_cdk_index[1] = acelp_cfg->fixed_cdk_index[0];
- move16();
- acelp_cfg->fixed_cdk_index[0] = -1;
- move16();
- acelp_cfg->fixed_cdk_index[2] = -1;
- move16();
- acelp_cfg->fixed_cdk_index[3] = -1;
- move16();
- }
- ELSE /* No FCB */
- {
-#ifdef DEBUGGING
- IVAS_ERROR( IVAS_ERR_INTERNAL, "WARNING!!!, No bit allocated to FCB, check frame %d\n" );
-#endif
- acelp_cfg->fixed_cdk_index[0] = -1;
- move16();
- acelp_cfg->fixed_cdk_index[1] = -1;
- move16();
- acelp_cfg->fixed_cdk_index[2] = -1;
- move16();
- acelp_cfg->fixed_cdk_index[3] = -1;
- move16();
- }
- }
- ELSE IF( NE_16( element_mode, IVAS_CPE_TD ) && GSC_IVAS_mode > 0 && EQ_16( L_frame, L_FRAME16k ) )
- {
- bits = 100; /* 9 kbps for fcb */
- move16();
- acelp_FCB_allocator( &bits, acelp_cfg->fixed_cdk_index, nb_subfr, L_SUBFR, coder_type, tc_subfr, fix_first );
- }
- ELSE
- {
- acelp_FCB_allocator( &bits, acelp_cfg->fixed_cdk_index, nb_subfr, L_SUBFR, coder_type, tc_subfr, fix_first );
- }
- }
- }
-
- /* AVQ codebook */
- test();
- test();
- test();
- IF( ( GE_32( core_brate_inp, MIN_BRATE_AVQ_EXC ) && coder_type != INACTIVE ) /* high-birate ACELP except IC */ ||
- ( !inactive_coder_type_flag && coder_type == INACTIVE ) /* AVQ inactive */ )
- {
- FOR( i = 0; i < nb_subfr; i++ )
- {
- IF( flag_hardcoded )
- {
- acelp_cfg->AVQ_cdk_bits[i] = AVQ_bits_16kHz_tbl[BIT_ALLOC_IDX_16KHZ_fx( core_brate, coder_type, i_mult( i, L_SUBFR ), TC_SUBFR2IDX_16KHZ_fx( tc_subfr ) )];
- move16();
- {
- bits = sub( bits, acelp_cfg->AVQ_cdk_bits[i] );
- }
- }
-
- bits = sub( bits, G_AVQ_BITS );
- }
-
- test();
- test();
- IF( GE_32( core_brate_inp, MIN_BRATE_AVQ_EXC ) && LE_32( core_brate_inp, MAX_BRATE_AVQ_EXC_TD ) && EQ_16( coder_type, GENERIC ) )
- {
- /* harm. flag ACELP AVQ */
- bits = sub( bits, 1 );
- }
-
- IF( !flag_hardcoded )
- {
- Word16 bit_tmp;
-
- bit_tmp = idiv1616( bits, nb_subfr );
- set16_fx( acelp_cfg->AVQ_cdk_bits, bit_tmp, nb_subfr );
- bits = sub( bits, i_mult( bit_tmp, nb_subfr ) );
-
- bit_tmp = bits % nb_subfr;
- move16();
- acelp_cfg->AVQ_cdk_bits[0] = add( acelp_cfg->AVQ_cdk_bits[0], bit_tmp );
- move16();
- bits = sub( bits, bit_tmp );
- }
- }
- }
- ELSE IF( ( EQ_16( coder_type, UNVOICED ) && EQ_16( tdm_low_rate_mode, 1 ) && EQ_16( element_mode, IVAS_CPE_TD ) ) /* LBR secondary channel in TD stereo */ ||
- ( ( coder_type == INACTIVE || EQ_16( coder_type, AUDIO ) ) && EQ_16( nb_subfr, NB_SUBFR ) ) /* GSC @12.8kHz */ ||
- ( coder_type == INACTIVE && inactive_coder_type_flag ) /* AVQ inactive */ )
- {
- Word32 Local_BR, Pitch_BR;
- Word16 Pitch_CT;
-
- /* as defined at the beginning of [enc,dec]_pit_exc() */
- test();
- test();
- IF( GSC_IVAS_mode > 0 && ( GSC_noisy_speech || GT_32( core_brate, GSC_H_RATE_STG ) ) )
- {
- Local_BR = ACELP_8k00;
- move32();
- Pitch_CT = GENERIC;
- move16();
- Pitch_BR = ACELP_8k00;
- move32();
- IF( EQ_16( L_frame, L_FRAME16k ) )
- {
- Local_BR = ACELP_14k80;
- move32();
- test();
- if ( GSC_IVAS_mode > 0 && LT_32( core_brate, IVAS_24k4 ) )
- {
- Local_BR = ACELP_9k60;
- move32();
- }
- Pitch_BR = core_brate;
- move32();
- }
- }
- ELSE IF( GSC_noisy_speech )
- {
- Local_BR = ACELP_7k20;
- move32();
- Pitch_CT = GENERIC;
- move16();
- Pitch_BR = ACELP_7k20;
- move32();
- if ( EQ_16( L_frame, L_FRAME16k ) )
- {
- Pitch_BR = core_brate;
- move32();
- }
- }
- ELSE
- {
- Local_BR = ACELP_7k20;
- move32();
- Pitch_CT = AUDIO;
- move16();
- Pitch_BR = core_brate;
- move32();
-
- IF( EQ_16( L_frame, L_FRAME16k ) )
- {
- Local_BR = ACELP_13k20;
- move32();
- Pitch_CT = GENERIC;
- move16();
- }
- }
-
- FOR( i = 0; i < nb_subfr; i++ )
- {
- IF( EQ_16( L_frame, L_FRAME16k ) )
- {
- acelp_cfg->pitch_bits[i] = ACB_bits_16kHz_tbl[BIT_ALLOC_IDX_16KHZ_fx( Pitch_BR, Pitch_CT, i_mult( i, L_SUBFR ), 0 )];
- move16();
- acelp_cfg->fixed_cdk_index[i] = FCB_bits_tbl[BIT_ALLOC_IDX_fx( Local_BR, LOCAL_CT, i_mult( i, L_SUBFR ), 0 )];
- move16();
- }
- ELSE
- {
- acelp_cfg->pitch_bits[i] = ACB_bits_tbl[BIT_ALLOC_IDX_fx( Pitch_BR, Pitch_CT, i_mult( i, L_SUBFR ), 0 )];
- move16();
- acelp_cfg->fixed_cdk_index[i] = FCB_bits_tbl[BIT_ALLOC_IDX_fx( Local_BR, LOCAL_CT, i_mult( i, L_SUBFR ), 0 )];
- move16();
- acelp_cfg->gains_mode[i] = gain_bits_tbl[BIT_ALLOC_IDX_fx( ACELP_7k20, LOCAL_CT, i_mult( i, L_SUBFR ), 0 )];
- move16();
- }
- }
- }
-
- test();
- test();
- test();
- IF( EQ_16( coder_type, TRANSITION ) && ( EQ_16( tc_call, 1 ) && tc_subfr == 0 && EQ_16( L_frame, L_FRAME ) ) )
- {
- return error;
- }
-
- /*-----------------------------------------------------------------*
- * unused bits handling
- *-----------------------------------------------------------------*/
-
- acelp_cfg->ubits = 0; /* these bits could be reused for something else */
- move16();
-
- test();
- IF( flag_hardcoded && NE_32( core_brate, PPP_NELP_2k80 ) )
- {
- test();
- test();
- /* unused bits */
- IF( EQ_16( coder_type, AUDIO ) || ( coder_type == INACTIVE && LE_32( core_brate, ACELP_24k40 ) ) )
- {
- acelp_cfg->ubits = 0;
- move16();
- }
- ELSE IF( EQ_16( L_frame, L_FRAME ) )
- {
- acelp_cfg->ubits = reserved_bits_tbl[BIT_ALLOC_IDX_fx( core_brate, coder_type, -1, TC_SUBFR2IDX_fx( tc_subfr ) )];
- move16();
- }
- ELSE
- {
- acelp_cfg->ubits = 0;
- move16();
- }
-
- bits = sub( bits, acelp_cfg->ubits );
- }
-
- /* sanity check */
- test();
- test();
- test();
- IF( ( coder_type != INACTIVE && EQ_16( nb_subfr, NB_SUBFR ) && NE_16( coder_type, AUDIO ) ) || EQ_16( nb_subfr, NB_SUBFR16k ) )
- {
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- IF( ( EQ_16( L_frame, L_FRAME16k ) && coder_type == INACTIVE && inactive_coder_type_flag ) /* GSC Inactive @16kHz */ ||
- ( GSC_IVAS_mode > 0 && EQ_16( L_frame, L_FRAME16k ) ) ) /* IVAS GSC @16kHz */
- {
- acelp_cfg->ubits = 0;
- move16();
- }
- ELSE IF( flag_hardcoded && core == ACELP_CORE && bits != 0 )
- {
-#ifdef DEBUGGING
- IVAS_ERROR( IVAS_ERR_INTERNAL, "ERROR: bit-budget incorrect (%d bits) in frame %d.\n", (Word32) bits );
-#endif
- }
- ELSE IF( bits > 0 && !( EQ_16( coder_type, UNVOICED ) && EQ_16( tdm_low_rate_mode, 1 ) && EQ_16( element_mode, IVAS_CPE_TD ) ) )
- {
- test();
- test();
- test();
- test();
- IF( idchan > 0 && EQ_16( element_mode, IVAS_CPE_TD ) )
- {
- IF( !tdm_lp_reuse_flag )
- {
- acelp_cfg->lsf_bits = add( acelp_cfg->lsf_bits, bits ); /* increase LSF Q bits */
- move16();
- bits = 0;
- move16();
- }
- ELSE
- {
- Word16 nb_prm = 4;
- move16();
- if ( EQ_16( tdm_low_rate_mode, 1 ) )
- {
- nb_prm = 2;
- move16();
- }
- /* First add remaining bits on gains */
- bits = sub( bits, allocate_unused( core_brate, coder_type, bits, nb_prm, 0, GAINSPRM, acelp_cfg->gains_mode ) );
-
- /* Then, Increase pitch bit budget */
- test();
- IF( tdm_Pitch_reuse_flag == 0 && bits > 0 )
- {
- bits = sub( bits, allocate_unused( core_brate, coder_type, bits, nb_prm, 0, PITCHPRM, acelp_cfg->pitch_bits ) );
- }
-
- /* Increase mid-lsf bit budget */
- test();
- IF( tdm_lp_reuse_flag == 0 && bits > 0 )
- {
- bits = sub( bits, allocate_unused( core_brate, coder_type, bits, 1, 0, MID_LSFSPRM, &acelp_cfg->mid_lsf_bits ) );
- bits = sub( bits, allocate_unused( core_brate, coder_type, bits, 1, 0, LSFPRM, &acelp_cfg->lsf_bits ) );
- }
- }
-
-#ifdef DEBUGGING
- if ( idchan > 0 && bits > 0 && ( coder_type > UNVOICED || tdm_low_rate_mode == 0 ) )
- {
- IVAS_ERROR( IVAS_ERR_INTERNAL, "WARNING !! Unused bits in secondary channel at frame %d\n" );
- }
-#endif
- }
-
- ELSE IF( core == ACELP_CORE && GE_16( coder_type, UNVOICED ) && LE_16( coder_type, GENERIC ) && EQ_16( L_frame, L_FRAME ) )
- {
- acelp_cfg->lsf_bits = add( acelp_cfg->lsf_bits, bits ); /* increase LSF Q bits */
- move16();
-
- test();
- IF( GT_16( acelp_cfg->lsf_bits, 46 ) )
- {
- acelp_cfg->ubits = sub( acelp_cfg->lsf_bits, 46 );
- move16();
- acelp_cfg->lsf_bits = 46;
- move16();
- }
- ELSE IF( GT_16( acelp_cfg->lsf_bits, 42 ) && EQ_16( L_frame, L_FRAME ) )
- {
- acelp_cfg->ubits = sub( acelp_cfg->lsf_bits, 42 );
- move16();
- acelp_cfg->lsf_bits = 42;
- move16();
- }
- }
- ELSE
- {
- acelp_cfg->ubits = bits;
- move16();
- }
- }
- ELSE IF( bits < 0 && !( EQ_16( coder_type, UNVOICED ) && EQ_16( tdm_low_rate_mode, 1 ) && EQ_16( element_mode, IVAS_CPE_TD ) ) )
- {
-#ifdef DEBUGGING
- IVAS_ERROR( IVAS_ERR_INTERNAL, "ERROR: bit-budget incorrect (%d bits) in frame %d.\n", (Word32) bits );
-#endif
- }
- }
-
- return error;
-}
-
-/*-------------------------------------------------------------------*
- * config_acelp1_IVAS()
- *
- * Configure ACELP bit allocation
- * - should be in range of <6700; 24350> for ACELP@12.8kHz
- * - per channel bitrate minimum is 13250 kbps for ACELP@16kHz
- *--------------------------------------------------------------------*/
-#endif
-ivas_error config_acelp1_IVAS(
+ivas_error config_acelp1_fx(
const Word16 enc_dec, /* i : encoder/decoder flag */
const Word32 total_brate, /* i : total bitrate */
const Word32 core_brate_inp, /* i : core bitrate */
@@ -2511,11 +1224,11 @@ ivas_error config_acelp1_IVAS(
IF( GE_16( bits, 16 ) )
{
- acelp_FCB_allocator_ivas( &bits, acelp_cfg->fixed_cdk_index, 2, 2 * L_SUBFR, GENERIC, -1, 0 );
+ acelp_FCB_allocator_fx( &bits, acelp_cfg->fixed_cdk_index, 2, 2 * L_SUBFR, GENERIC, -1, 0 );
}
ELSE
{
- acelp_FCB_allocator_ivas( &bits, acelp_cfg->fixed_cdk_index, 2, 2 * L_SUBFR, GENERIC, -1, 0 );
+ acelp_FCB_allocator_fx( &bits, acelp_cfg->fixed_cdk_index, 2, 2 * L_SUBFR, GENERIC, -1, 0 );
acelp_cfg->fixed_cdk_index[1] = -1;
move16();
}
@@ -2634,17 +1347,17 @@ ivas_error config_acelp1_IVAS(
{
IF( GE_16( bits, imult1616( ACELP_FIXED_CDK_BITS( 0 ), nb_subfr ) ) ) /* enough bits for all fcb */
{
- acelp_FCB_allocator_ivas( &bits, acelp_cfg->fixed_cdk_index, nb_subfr, L_SUBFR, coder_type, tc_subfr, fix_first );
+ acelp_FCB_allocator_fx( &bits, acelp_cfg->fixed_cdk_index, nb_subfr, L_SUBFR, coder_type, tc_subfr, fix_first );
}
ELSE IF( GE_16( bits, imult1616( ACELP_FIXED_CDK_BITS( 0 ), sub( nb_subfr, 1 ) ) ) )
{
- acelp_FCB_allocator_ivas( &bits, acelp_cfg->fixed_cdk_index, sub( nb_subfr, 1 ), L_SUBFR, coder_type, tc_subfr, fix_first );
+ acelp_FCB_allocator_fx( &bits, acelp_cfg->fixed_cdk_index, sub( nb_subfr, 1 ), L_SUBFR, coder_type, tc_subfr, fix_first );
acelp_cfg->fixed_cdk_index[3] = -1;
move16();
}
ELSE IF( GE_32( bits, imult1616( ACELP_FIXED_CDK_BITS( 0 ), sub( nb_subfr, 2 ) ) ) )
{
- acelp_FCB_allocator_ivas( &bits, acelp_cfg->fixed_cdk_index, sub( nb_subfr, 2 ), L_SUBFR, coder_type, tc_subfr, fix_first );
+ acelp_FCB_allocator_fx( &bits, acelp_cfg->fixed_cdk_index, sub( nb_subfr, 2 ), L_SUBFR, coder_type, tc_subfr, fix_first );
acelp_cfg->fixed_cdk_index[2] = acelp_cfg->fixed_cdk_index[1];
move16();
acelp_cfg->fixed_cdk_index[1] = -1;
@@ -2654,7 +1367,7 @@ ivas_error config_acelp1_IVAS(
}
ELSE IF( GE_32( bits, ACELP_FIXED_CDK_BITS( 0 ) ) )
{
- acelp_FCB_allocator_ivas( &bits, acelp_cfg->fixed_cdk_index, 1, L_SUBFR, coder_type, tc_subfr, fix_first );
+ acelp_FCB_allocator_fx( &bits, acelp_cfg->fixed_cdk_index, 1, L_SUBFR, coder_type, tc_subfr, fix_first );
acelp_cfg->fixed_cdk_index[1] = acelp_cfg->fixed_cdk_index[0];
move16();
acelp_cfg->fixed_cdk_index[0] = -1;
@@ -2680,11 +1393,11 @@ ivas_error config_acelp1_IVAS(
{
bits = 100; /* 9 kbps for fcb */
move16();
- acelp_FCB_allocator_ivas( &bits, acelp_cfg->fixed_cdk_index, nb_subfr, L_SUBFR, coder_type, tc_subfr, fix_first );
+ acelp_FCB_allocator_fx( &bits, acelp_cfg->fixed_cdk_index, nb_subfr, L_SUBFR, coder_type, tc_subfr, fix_first );
}
ELSE
{
- acelp_FCB_allocator_ivas( &bits, acelp_cfg->fixed_cdk_index, nb_subfr, L_SUBFR, coder_type, tc_subfr, fix_first );
+ acelp_FCB_allocator_fx( &bits, acelp_cfg->fixed_cdk_index, nb_subfr, L_SUBFR, coder_type, tc_subfr, fix_first );
}
}
}
diff --git a/lib_com/bitstream.c b/lib_com/bitstream.c
index d8d4563ed3a60fdf6325d71a81a73384c100f911..8ebfd6fa7059531fe0a087bacc7d5cfbed840e13 100644
--- a/lib_com/bitstream.c
+++ b/lib_com/bitstream.c
@@ -48,7 +48,9 @@
#include "wmc_auto.h"
#include "ivas_prot_fx.h"
#include "prot_fx_enc.h"
-
+#ifdef DBG_BITSTREAM_ANALYSIS
+#include
+#endif
#define STEP_MAX_NUM_INDICES 100 /* increase the maximum number of allowed indices in the list by this amount */
@@ -100,7 +102,7 @@ static Word16 rate2AMRWB_IOmode(
*-------------------------------------------------------------------*/
Word16 rate2EVSmode_float(
const Word32 brate, /* i : bitrate */
- int16_t *is_amr_wb /* o : (flag) does the bitrate belong to AMR-WB? Can be NULL */
+ Word16 *is_amr_wb /* o : (flag) does the bitrate belong to AMR-WB? Can be NULL */
)
{
if ( is_amr_wb != NULL )
@@ -199,6 +201,9 @@ ivas_error ind_list_realloc(
{
new_ind_list[i].id = old_ind_list[i].id;
new_ind_list[i].value = old_ind_list[i].value;
+#ifdef DBG_BITSTREAM_ANALYSIS
+ strncpy( new_ind_list[i].function_name, old_ind_list[i].function_name, 100 );
+#endif
move16();
move16();
}
@@ -210,6 +215,9 @@ ivas_error ind_list_realloc(
FOR( ; i < max_num_indices; i++ )
{
new_ind_list[i].nb_bits = -1;
+#ifdef DBG_BITSTREAM_ANALYSIS
+ sprintf( new_ind_list[i].function_name, "RESET in ind_list_realloc" );
+#endif
move16();
}
@@ -575,8 +583,8 @@ Word16 get_ivas_max_num_indices_fx(
*-----------------------------------------------------------------------*/
/*! r: maximum number of indices */
-int16_t get_BWE_max_num_indices(
- const int32_t extl_brate /* i : extensiona layer bitrate */
+Word16 get_BWE_max_num_indices(
+ const Word32 extl_brate /* i : extensiona layer bitrate */
)
{
/* set the maximum number of indices in the BWE */
@@ -787,10 +795,10 @@ Word16 get_ivas_max_num_indices_metadata_fx(
void move_indices(
INDICE_HANDLE old_ind_list, /* i/o: old location of indices */
INDICE_HANDLE new_ind_list, /* i/o: new location of indices */
- const int16_t nb_indices /* i : number of moved indices */
+ const Word16 nb_indices /* i : number of moved indices */
)
{
- int16_t i;
+ Word16 i;
if ( new_ind_list < old_ind_list )
{
@@ -800,6 +808,9 @@ void move_indices(
new_ind_list[i].value = old_ind_list[i].value;
new_ind_list[i].nb_bits = old_ind_list[i].nb_bits;
+#ifdef DBG_BITSTREAM_ANALYSIS
+ strncpy( new_ind_list[i].function_name, old_ind_list[i].function_name, 100 );
+#endif
old_ind_list[i].nb_bits = -1;
}
}
@@ -810,8 +821,14 @@ void move_indices(
new_ind_list[i].id = old_ind_list[i].id;
new_ind_list[i].value = old_ind_list[i].value;
new_ind_list[i].nb_bits = old_ind_list[i].nb_bits;
+#ifdef DBG_BITSTREAM_ANALYSIS
+ strncpy( new_ind_list[i].function_name, old_ind_list[i].function_name, 100 );
+#endif
old_ind_list[i].nb_bits = -1;
+#ifdef DBG_BITSTREAM_ANALYSIS
+ sprintf( old_ind_list[i].function_name, "RESET in move_indices" );
+#endif
}
}
@@ -880,6 +897,1881 @@ ivas_error check_ind_list_limits(
return error;
}
+#ifdef DBG_BITSTREAM_ANALYSIS
+const char *named_indices_table[] = {
+ "IND_IVAS_FORMAT",
+ "IND_SMODE_OMASA",
+ "IND_SMODE",
+ "IND_SID_TYPE",
+ "IND_BWIDTH",
+ "IND_CORE",
+ "IND_PPP_NELP_MODE",
+ "IND_ACELP_16KHZ",
+ "IND_ACELP_SIGNALLING",
+ "IND_SHARP_FLAG",
+ "IND_MDCT_CORE",
+ "IND_TCX_CORE",
+ "IND_BWE_FLAG",
+ "IND_HQ_SWITCHING_FLG",
+ "IND_LAST_L_FRAME",
+ "IND_VAD_FLAG",
+ "IND_HQ_BWIDTH",
+ "IND_TC_SUBFR",
+ "IND_TC_SUBFR",
+ "IND_TC_SUBFR",
+ "IND_TC_SUBFR",
+ "IND_GSC_IVAS_SP",
+ "IND_LSF_PREDICTOR_SELECT_BIT",
+ "IND_LSF",
+ "IND_LSF",
+ "IND_LSF",
+ "IND_LSF",
+ "IND_LSF",
+ "IND_LSF",
+ "IND_LSF",
+ "IND_LSF",
+ "IND_LSF",
+ "IND_LSF",
+ "IND_LSF",
+ "IND_LSF",
+ "IND_LSF",
+ "IND_LSF",
+ "IND_LSF",
+ "IND_LSF",
+ "IND_LSF",
+ "IND_MID_FRAME_LSF_INDEX",
+ "IND_ISF_0_0",
+ "IND_ISF_0_1",
+ "IND_ISF_0_2",
+ "IND_ISF_0_3",
+ "IND_ISF_0_4",
+ "IND_ISF_1_0",
+ "IND_ISF_1_1",
+ "IND_ISF_1_2",
+ "IND_ISF_1_3",
+ "IND_ISF_1_4",
+ "IND_IC_LSF_PRED",
+ "IND_GSC_ATTACK",
+ "IND_GSC_SWB_SPEECH",
+ "IND_NOISE_LEVEL",
+ "IND_HF_NOISE",
+ "IND_PIT_CONTR_IDX",
+ "IND_FEC_CLAS",
+ "IND_FEC_ENR",
+ "IND_FEC_POS",
+ "IND_ES_PRED",
+ "IND_HARM_FLAG_ACELP",
+ "IND_ALG_CDBK_4T64_2_24KBIT",
+ "IND_ALG_CDBK_4T64_2_24KBIT",
+ "IND_ALG_CDBK_4T64_2_24KBIT",
+ "IND_ALG_CDBK_4T64_2_24KBIT",
+ "IND_ALG_CDBK_4T64_2_24KBIT",
+ "IND_ALG_CDBK_4T64_2_24KBIT",
+ "IND_ALG_CDBK_4T64_2_24KBIT",
+ "IND_ALG_CDBK_4T64_2_24KBIT",
+ "IND_ALG_CDBK_4T64_2_24KBIT",
+ "IND_ALG_CDBK_4T64_2_24KBIT",
+ "IND_ALG_CDBK_4T64_2_24KBIT",
+ "IND_ALG_CDBK_4T64_2_24KBIT",
+ "IND_ALG_CDBK_4T64_2_24KBIT",
+ "IND_ALG_CDBK_4T64_2_24KBIT",
+ "IND_ALG_CDBK_4T64_2_24KBIT",
+ "IND_ALG_CDBK_4T64_2_24KBIT",
+ "IND_ALG_CDBK_4T64_2_24KBIT",
+ "IND_ALG_CDBK_4T64_2_24KBIT",
+ "IND_ALG_CDBK_4T64_2_24KBIT",
+ "IND_ALG_CDBK_4T64_2_24KBIT",
+ "IND_ALG_CDBK_4T64_2_24KBIT",
+ "IND_ALG_CDBK_4T64_2_24KBIT",
+ "IND_ALG_CDBK_4T64_2_24KBIT",
+ "IND_ALG_CDBK_4T64_2_24KBIT",
+ "IND_ALG_CDBK_4T64_2_24KBIT",
+ "IND_ALG_CDBK_4T64_2_24KBIT",
+ "IND_ALG_CDBK_4T64_2_24KBIT",
+ "IND_ALG_CDBK_4T64_2_24KBIT",
+ "IND_ALG_CDBK_4T64_2_24KBIT",
+ "IND_ALG_CDBK_4T64_2_24KBIT",
+ "IND_ALG_CDBK_4T64_2_24KBIT",
+ "IND_ALG_CDBK_4T64_2_24KBIT",
+ "IND_ALG_CDBK_4T64_2_24KBIT",
+ "IND_ALG_CDBK_4T64_2_24KBIT",
+ "IND_ALG_CDBK_4T64_2_24KBIT",
+ "IND_ALG_CDBK_4T64_2_24KBIT",
+ "IND_ALG_CDBK_4T64_2_24KBIT",
+ "IND_ALG_CDBK_4T64_2_24KBIT",
+ "IND_ALG_CDBK_4T64_2_24KBIT",
+ "IND_ALG_CDBK_4T64_2_24KBIT",
+ "TAG_ALG_CDBK_4T64_24KBIT_END",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "IND_HF_GAIN_MODIFICATION",
+ "TAG_ACELP_SUBFR_LOOP_END",
+ "IND_MEAN_GAIN2",
+ "IND_MEAN_GAIN2",
+ "IND_MEAN_GAIN2",
+ "IND_MEAN_GAIN2",
+ "IND_MEAN_GAIN2",
+ "IND_MEAN_GAIN2",
+ "IND_MEAN_GAIN2",
+ "IND_MEAN_GAIN2",
+ "IND_MEAN_GAIN2",
+ "IND_MEAN_GAIN2",
+ "IND_MEAN_GAIN2",
+ "IND_MEAN_GAIN2",
+ "IND_MEAN_GAIN2",
+ "IND_MEAN_GAIN2",
+ "IND_MEAN_GAIN2",
+ "IND_MEAN_GAIN2",
+ "IND_MEAN_GAIN2",
+ "IND_MEAN_GAIN2",
+ "IND_MEAN_GAIN2",
+ "IND_MEAN_GAIN2",
+ "IND_MEAN_GAIN2",
+ "IND_MEAN_GAIN2",
+ "IND_MEAN_GAIN2",
+ "IND_MEAN_GAIN2",
+ "IND_MEAN_GAIN2",
+ "IND_MEAN_GAIN2",
+ "IND_MEAN_GAIN2",
+ "IND_MEAN_GAIN2",
+ "IND_MEAN_GAIN2",
+ "IND_MEAN_GAIN2",
+ "IND_MEAN_GAIN2",
+ "IND_MEAN_GAIN2",
+ "IND_Y_GAIN_TMP",
+ "IND_Y_GAIN_TMP",
+ "IND_Y_GAIN_TMP",
+ "IND_Y_GAIN_TMP",
+ "IND_Y_GAIN_TMP",
+ "IND_Y_GAIN_TMP",
+ "IND_Y_GAIN_TMP",
+ "IND_Y_GAIN_TMP",
+ "IND_Y_GAIN_TMP",
+ "IND_Y_GAIN_TMP",
+ "IND_Y_GAIN_TMP",
+ "IND_Y_GAIN_TMP",
+ "IND_Y_GAIN_TMP",
+ "IND_Y_GAIN_TMP",
+ "IND_Y_GAIN_TMP",
+ "IND_Y_GAIN_TMP",
+ "IND_Y_GAIN_TMP",
+ "IND_Y_GAIN_TMP",
+ "IND_Y_GAIN_TMP",
+ "IND_Y_GAIN_TMP",
+ "IND_Y_GAIN_TMP",
+ "IND_Y_GAIN_TMP",
+ "IND_Y_GAIN_TMP",
+ "IND_Y_GAIN_TMP",
+ "IND_Y_GAIN_TMP",
+ "IND_Y_GAIN_TMP",
+ "IND_Y_GAIN_TMP",
+ "IND_Y_GAIN_TMP",
+ "IND_Y_GAIN_TMP",
+ "IND_Y_GAIN_TMP",
+ "IND_Y_GAIN_TMP",
+ "IND_Y_GAIN_TMP",
+ "IND_Y_GAIN_HF",
+ "IND_HQ_VOICING_FLAG",
+ "IND_HQ_SWB_CLAS",
+ "IND_NF_IDX",
+ "IND_LC_MODE",
+ "IND_YNRM",
+ "IND_YNRM",
+ "IND_YNRM",
+ "IND_YNRM",
+ "IND_YNRM",
+ "IND_YNRM",
+ "IND_YNRM",
+ "IND_YNRM",
+ "IND_YNRM",
+ "IND_YNRM",
+ "IND_YNRM",
+ "IND_YNRM",
+ "IND_YNRM",
+ "IND_YNRM",
+ "IND_YNRM",
+ "IND_YNRM",
+ "IND_YNRM",
+ "IND_YNRM",
+ "IND_YNRM",
+ "IND_YNRM",
+ "IND_YNRM",
+ "IND_YNRM",
+ "IND_YNRM",
+ "IND_YNRM",
+ "IND_YNRM",
+ "IND_YNRM",
+ "IND_YNRM",
+ "IND_YNRM",
+ "IND_YNRM",
+ "IND_YNRM",
+ "IND_YNRM",
+ "IND_YNRM",
+ "IND_YNRM",
+ "IND_YNRM",
+ "IND_YNRM",
+ "IND_YNRM",
+ "IND_YNRM",
+ "IND_YNRM",
+ "IND_YNRM",
+ "IND_YNRM",
+ "IND_YNRM",
+ "IND_YNRM",
+ "IND_YNRM",
+ "IND_YNRM",
+ "IND_SWB_FENV_HQ",
+ "IND_SWB_FENV_HQ",
+ "IND_SWB_FENV_HQ",
+ "IND_SWB_FENV_HQ",
+ "IND_SWB_FENV_HQ",
+ "IND_FB_FENV_HQ",
+ "IND_FB_FENV_HQ",
+ "IND_FB_FENV_HQ",
+ "IND_FB_FENV_HQ",
+ "IND_FB_FENV_HQ",
+ "IND_DELTA_ENV_HQ",
+ "IND_HVQ_BWE_NL",
+ "IND_HVQ_BWE_NL",
+ "IND_NUM_PEAKS",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_POS_IDX",
+ "IND_FLAGN",
+ "IND_PG_IDX",
+ "IND_PG_IDX",
+ "IND_PG_IDX",
+ "IND_PG_IDX",
+ "IND_PG_IDX",
+ "IND_PG_IDX",
+ "IND_PG_IDX",
+ "IND_PG_IDX",
+ "IND_PG_IDX",
+ "IND_PG_IDX",
+ "IND_PG_IDX",
+ "IND_PG_IDX",
+ "IND_PG_IDX",
+ "IND_PG_IDX",
+ "IND_PG_IDX",
+ "IND_PG_IDX",
+ "IND_PG_IDX",
+ "IND_PG_IDX",
+ "IND_PG_IDX",
+ "IND_PG_IDX",
+ "IND_PG_IDX",
+ "IND_PG_IDX",
+ "IND_PG_IDX",
+ "IND_PG_IDX",
+ "IND_PG_IDX",
+ "IND_PG_IDX",
+ "IND_PG_IDX",
+ "IND_PG_IDX",
+ "IND_PG_IDX",
+ "IND_PG_IDX",
+ "IND_PG_IDX",
+ "IND_PG_IDX",
+ "IND_PG_IDX",
+ "IND_PG_IDX",
+ "IND_PG_IDX",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_PEAKS",
+ "IND_HVQ_NF_GAIN",
+ "IND_HVQ_NF_GAIN",
+ "IND_HQ2_SWB_CLAS",
+ "IND_HQ2_DENG_MODE",
+ "IND_HQ2_DENG_8SMODE",
+ "IND_HQ2_DENG_8SMODE_N0",
+ "IND_HQ2_DENG_8SMODE_N1",
+ "IND_HQ2_DENG_8SPOS",
+ "IND_HQ2_DENG_8SDEPTH",
+ "IND_HQ2_DENG_HMODE",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_DIFF_ENERGY",
+ "IND_HQ2_P2A_FLAGS",
+ "IND_HQ2_P2A_FLAGS",
+ "IND_HQ2_P2A_FLAGS",
+ "IND_HQ2_P2A_FLAGS",
+ "IND_HQ2_P2A_FLAGS",
+ "IND_HQ2_P2A_FLAGS",
+ "IND_HQ2_P2A_FLAGS",
+ "IND_HQ2_P2A_FLAGS",
+ "IND_HQ2_P2A_FLAGS",
+ "IND_HQ2_P2A_FLAGS",
+ "IND_HQ2_P2A_FLAGS",
+ "IND_HQ2_P2A_FLAGS",
+ "IND_HQ2_P2A_FLAGS",
+ "IND_HQ2_P2A_FLAGS",
+ "IND_HQ2_P2A_FLAGS",
+ "IND_HQ2_P2A_FLAGS",
+ "IND_HQ2_P2A_FLAGS",
+ "IND_HQ2_P2A_FLAGS",
+ "IND_HQ2_P2A_FLAGS",
+ "IND_HQ2_P2A_FLAGS",
+ "IND_HQ2_P2A_FLAGS",
+ "IND_HQ2_P2A_FLAGS",
+ "IND_HQ2_P2A_FLAGS",
+ "IND_HQ2_P2A_FLAGS",
+ "IND_HQ2_P2A_FLAGS",
+ "IND_HQ2_P2A_FLAGS",
+ "IND_HQ2_P2A_FLAGS",
+ "IND_HQ2_P2A_FLAGS",
+ "IND_HQ2_P2A_FLAGS",
+ "IND_HQ2_P2A_FLAGS",
+ "IND_HQ2_P2A_FLAGS",
+ "IND_HQ2_P2A_FLAGS",
+ "IND_HQ2_P2A_FLAGS",
+ "IND_HQ2_P2A_FLAGS",
+ "IND_HQ2_P2A_FLAGS",
+ "IND_HQ2_P2A_FLAGS",
+ "IND_HQ2_P2A_FLAGS",
+ "IND_HQ2_P2A_FLAGS",
+ "IND_HQ2_P2A_FLAGS",
+ "IND_HQ2_P2A_FLAGS",
+ "IND_HQ2_P2A_FLAGS",
+ "IND_HQ2_P2A_FLAGS",
+ "IND_HQ2_P2A_FLAGS",
+ "IND_HQ2_P2A_FLAGS",
+ "IND_HQ2_P2A_FLAGS",
+ "IND_HQ2_P2A_FLAGS",
+ "IND_HQ2_P2A_FLAGS",
+ "IND_HQ2_P2A_FLAGS",
+ "IND_HQ2_P2A_FLAGS",
+ "IND_HQ2_P2A_FLAGS",
+ "IND_HQ2_P2A_FLAGS",
+ "IND_HQ2_P2A_FLAGS",
+ "IND_HQ2_P2A_FLAGS",
+ "IND_HQ2_P2A_FLAGS",
+ "IND_HQ2_P2A_FLAGS",
+ "IND_HQ2_P2A_FLAGS",
+ "IND_HQ2_P2A_FLAGS",
+ "IND_HQ2_P2A_FLAGS",
+ "IND_HQ2_P2A_FLAGS",
+ "IND_HQ2_P2A_FLAGS",
+ "IND_HQ2_LAST_BA_MAX_BAND",
+ "IND_HQ2_LAST_BA_MAX_BAND",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_START",
+ "IND_RC_END",
+ "IND_HVQ_PVQ_GAIN",
+ "IND_HVQ_PVQ_GAIN",
+ "IND_HVQ_PVQ_GAIN",
+ "IND_HVQ_PVQ_GAIN",
+ "IND_HVQ_PVQ_GAIN",
+ "IND_HVQ_PVQ_GAIN",
+ "IND_HVQ_PVQ_GAIN",
+ "IND_HVQ_PVQ_GAIN",
+ "IND_NOISINESS",
+ "IND_ENERGY",
+ "IND_CNG_HO",
+ "IND_SID_BW",
+ "IND_CNG_ENV1",
+ "IND_WB_FENV",
+ "IND_WB_CLASS",
+ "IND_IG1",
+ "IND_IG2A",
+ "IND_IG2B",
+ "IND_NELP_FID",
+ "IND_DELTALAG",
+ "IND_POWER",
+ "IND_AMP0",
+ "IND_AMP1",
+ "IND_GLOBAL_ALIGNMENT",
+ "IND_PVQ_FINE_GAIN",
+ "IND_UV_FLAG",
+ "IND_UV_FLAG",
+ "IND_UV_FLAG",
+ "IND_UV_FLAG",
+ "IND_UV_FLAG",
+ "IND_UV_FLAG",
+ "IND_UV_FLAG",
+ "IND_UV_FLAG",
+ "IND_UV_FLAG",
+ "IND_UV_FLAG",
+ "IND_UV_FLAG",
+ "IND_UV_FLAG",
+ "IND_UV_FLAG",
+ "IND_UV_FLAG",
+ "IND_UV_FLAG",
+ "IND_UV_FLAG",
+ "IND_UV_FLAG",
+ "IND_UV_FLAG",
+ "IND_UV_FLAG",
+ "IND_UV_FLAG",
+ "IND_UV_FLAG",
+ "IND_UV_FLAG",
+ "IND_UV_FLAG",
+ "IND_UV_FLAG",
+ "IND_UV_FLAG",
+ "IND_UV_FLAG",
+ "IND_UV_FLAG",
+ "IND_UV_FLAG",
+ "IND_UV_FLAG",
+ "IND_UV_FLAG",
+ "IND_UV_FLAG",
+ "IND_UV_FLAG",
+ "IND_UV_FLAG",
+ "IND_UV_FLAG",
+ "IND_UV_FLAG",
+ "IND_UV_FLAG",
+ "IND_UV_FLAG",
+ "IND_UV_FLAG",
+ "IND_UV_FLAG",
+ "IND_UV_FLAG",
+ "IND_UV_FLAG",
+ "IND_UV_FLAG",
+ "IND_UV_FLAG",
+ "IND_SHB_SUBGAIN",
+ "IND_SHB_FRAMEGAIN",
+ "IND_STEREO_ICBWE_MSFLAG",
+ "IND_SHB_ENER_SF",
+ "IND_SHB_RES_GS",
+ "IND_SHB_RES_GS",
+ "IND_SHB_RES_GS",
+ "IND_SHB_RES_GS",
+ "IND_SHB_RES_GS",
+ "IND_SHB_VF",
+ "IND_SHB_LSF",
+ "IND_SHB_LSF",
+ "IND_SHB_LSF",
+ "IND_SHB_LSF",
+ "IND_SHB_LSF",
+ "IND_SHB_MIRROR",
+ "IND_SHB_GRID",
+ "IND_SWB_CLASS",
+ "IND_SWB_TENV",
+ "IND_SWB_TENV",
+ "IND_SWB_TENV",
+ "IND_SWB_TENV",
+ "IND_SWB_FENV",
+ "IND_SWB_FENV",
+ "IND_SWB_FENV",
+ "IND_SWB_FENV",
+ "IND_SHB_CNG_GAIN",
+ "IND_DITHERING",
+ "IND_FB_SLOPE",
+ "IND_HQ2_SPT_SHORTEN",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_TCQ",
+ "IND_HQ2_SUBBAND_GAIN",
+ "IND_HQ2_SUBBAND_GAIN",
+ "IND_HQ2_SUBBAND_GAIN",
+ "IND_HQ2_SUBBAND_GAIN",
+ "IND_HQ2_SUBBAND_GAIN",
+ "IND_HQ2_SUBBAND_GAIN",
+ "IND_HQ2_SUBBAND_GAIN",
+ "IND_HQ2_SUBBAND_GAIN",
+ "IND_HQ2_SUBBAND_GAIN",
+ "IND_HQ2_SUBBAND_GAIN",
+ "IND_HQ2_SUBBAND_GAIN",
+ "IND_HQ2_SUBBAND_GAIN",
+ "IND_HQ2_SUBBAND_GAIN",
+ "IND_HQ2_SUBBAND_GAIN",
+ "IND_HQ2_SUBBAND_GAIN",
+ "IND_HQ2_SUBBAND_GAIN",
+ "IND_HQ2_SUBBAND_GAIN",
+ "IND_HQ2_SUBBAND_GAIN",
+ "IND_HQ2_SUBBAND_GAIN",
+ "IND_HQ2_SUBBAND_GAIN",
+ "IND_HQ2_DUMMY",
+ "IND_LAGINDICES",
+ "IND_NOISEG",
+ "IND_AUDIO_GAIN",
+ "IND_AUDIO_DELAY",
+ "IND_AUDIO_DELAY",
+ "IND_AUDIO_DELAY",
+ "IND_AUDIO_DELAY",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "IND_NQ2",
+ "TAG_HR_BWE_LOOP_END",
+ "IND_CORE_SWITCHING_CELP_SUBFRAME",
+ "IND_CORE_SWITCHING_CELP_SUBFRAME",
+ "IND_CORE_SWITCHING_CELP_SUBFRAME",
+ "IND_CORE_SWITCHING_CELP_SUBFRAME",
+ "IND_CORE_SWITCHING_CELP_SUBFRAME",
+ "IND_CORE_SWITCHING_CELP_SUBFRAME",
+ "IND_CORE_SWITCHING_CELP_SUBFRAME",
+ "IND_CORE_SWITCHING_CELP_SUBFRAME",
+ "IND_CORE_SWITCHING_CELP_SUBFRAME",
+ "IND_CORE_SWITCHING_CELP_SUBFRAME",
+ "IND_CORE_SWITCHING_CELP_SUBFRAME",
+ "IND_CORE_SWITCHING_CELP_SUBFRAME",
+ "IND_CORE_SWITCHING_CELP_SUBFRAME",
+ "IND_CORE_SWITCHING_CELP_SUBFRAME",
+ "IND_CORE_SWITCHING_CELP_SUBFRAME",
+ "IND_CORE_SWITCHING_CELP_SUBFRAME",
+ "IND_CORE_SWITCHING_CELP_SUBFRAME",
+ "IND_CORE_SWITCHING_CELP_SUBFRAME",
+ "IND_CORE_SWITCHING_CELP_SUBFRAME",
+ "IND_CORE_SWITCHING_CELP_SUBFRAME",
+ "IND_CORE_SWITCHING_AUDIO_DELAY",
+ "IND_CORE_SWITCHING_AUDIO_GAIN",
+ "IND_STEREO_ICBWE_REF",
+ "IND_STEREO_ICBWE_SP",
+ "IND_STEREO_ICBWE_GS",
+ "IND_STEREO_REFCHAN",
+ "IND_STEREO_CORRSTATS",
+ "IND_STEREO_GD",
+ "IND_STEREO_LRTD_FLAG",
+ "IND_STEREO_LPC_REUSE",
+ "IND_STEREO_TD_ALPHA",
+ "IND_STEREO_2ND_CODER_T",
+ "IND_UNUSED"
+};
+#endif
+
/*-------------------------------------------------------------------*
* push_indice()
@@ -925,6 +2817,9 @@ ivas_error push_indice(
hBstr->ind_list[j].id = hBstr->ind_list[j - 1].id;
hBstr->ind_list[j].nb_bits = hBstr->ind_list[j - 1].nb_bits;
hBstr->ind_list[j].value = hBstr->ind_list[j - 1].value;
+#ifdef DBG_BITSTREAM_ANALYSIS
+ strncpy( hBstr->ind_list[j].function_name, hBstr->ind_list[j - 1].function_name, 100 );
+#endif
move16();
move16();
move16();
@@ -936,6 +2831,9 @@ ivas_error push_indice(
hBstr->ind_list[i].id = id;
hBstr->ind_list[i].value = value;
hBstr->ind_list[i].nb_bits = nb_bits;
+#ifdef DBG_BITSTREAM_ANALYSIS
+ strncpy( hBstr->ind_list[i].function_name, named_indices_table[id], 100 );
+#endif
move16();
move16();
move16();
@@ -954,7 +2852,14 @@ ivas_error push_indice(
*
* Push a new indice into the buffer at the next position
*-------------------------------------------------------------------*/
+#ifdef DBG_BITSTREAM_ANALYSIS
+ivas_error push_next_indice_(
+#else
ivas_error push_next_indice(
+#endif
+#ifdef DBG_BITSTREAM_ANALYSIS
+ const char *caller,
+#endif
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
UWord16 value, /* i : value of the quantized indice */
Word16 nb_bits /* i : number of bits used to quantize the indice */
@@ -992,6 +2897,10 @@ ivas_error push_next_indice(
move16();
move16();
+#ifdef DBG_BITSTREAM_ANALYSIS
+ strncpy( hBstr->ind_list[hBstr->nb_ind_tot].function_name, caller, 100 );
+#endif
+
/* updates */
hBstr->nb_ind_tot = add( hBstr->nb_ind_tot, 1 );
hBstr->nb_bits_tot = add( hBstr->nb_bits_tot, nb_bits );
@@ -1005,7 +2914,14 @@ ivas_error push_next_indice(
* push_next_bits()
* Push a bit buffer into the buffer at the next position
*-------------------------------------------------------------------*/
+#ifdef DBG_BITSTREAM_ANALYSIS
+ivas_error push_next_bits_(
+#else
ivas_error push_next_bits(
+#endif
+#ifdef DBG_BITSTREAM_ANALYSIS
+ const char *caller,
+#endif
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
const UWord16 bits[], /* i : bit buffer to pack, sequence of single bits */
const Word16 nb_bits /* i : number of bits to pack */
@@ -1049,6 +2965,9 @@ ivas_error push_next_bits(
ptr->value = code;
ptr->nb_bits = 16;
ptr->id = prev_id;
+#ifdef DBG_BITSTREAM_ANALYSIS
+ strncpy( ptr->function_name, caller, 100 );
+#endif
hBstr->nb_ind_tot = add( hBstr->nb_ind_tot, 1 );
move16();
move16();
@@ -1070,6 +2989,9 @@ ivas_error push_next_bits(
ptr->value = bits[i];
ptr->nb_bits = 1;
ptr->id = prev_id;
+#ifdef DBG_BITSTREAM_ANALYSIS
+ strncpy( ptr->function_name, caller, 100 );
+#endif
hBstr->nb_ind_tot = add( hBstr->nb_ind_tot, 1 );
move16();
move16();
@@ -1092,14 +3014,14 @@ ivas_error push_next_bits(
*-------------------------------------------------------------------*/
/*! r: result: index of the indice in the list, -1 if not found */
-int16_t find_indice(
+Word16 find_indice(
BSTR_ENC_HANDLE hBstr, /* i : encoder bitstream handle */
- const int16_t id, /* i : ID of the indice */
- uint16_t *value, /* o : value of the quantized indice */
- int16_t *nb_bits /* o : number of bits used to quantize the indice */
+ const Word16 id, /* i : ID of the indice */
+ UWord16 *value, /* o : value of the quantized indice */
+ Word16 *nb_bits /* o : number of bits used to quantize the indice */
)
{
- int16_t i;
+ Word16 i;
for ( i = 0; i < hBstr->nb_ind_tot; i++ )
{
@@ -1122,12 +3044,12 @@ int16_t find_indice(
*-------------------------------------------------------------------*/
/*! r: number of deleted indices */
-uint16_t delete_indice(
+UWord16 delete_indice(
BSTR_ENC_HANDLE hBstr, /* i : encoder bitstream handle */
- const int16_t id /* i : ID of the indice */
+ const Word16 id /* i : ID of the indice */
)
{
- int16_t i, j;
+ Word16 i, j;
j = 0;
for ( i = 0; i < hBstr->nb_ind_tot; i++ )
@@ -1144,6 +3066,9 @@ uint16_t delete_indice(
hBstr->ind_list[j].id = hBstr->ind_list[i].id;
hBstr->ind_list[j].value = hBstr->ind_list[i].value;
hBstr->ind_list[j].nb_bits = hBstr->ind_list[i].nb_bits;
+#ifdef DBG_BITSTREAM_ANALYSIS
+ strncpy( hBstr->ind_list[j].function_name, hBstr->ind_list[i].function_name, 100 );
+#endif
}
j++;
@@ -1155,6 +3080,9 @@ uint16_t delete_indice(
{
/* reset the shifted indices at the end of the list */
hBstr->ind_list[j].nb_bits = -1;
+#ifdef DBG_BITSTREAM_ANALYSIS
+ sprintf( hBstr->ind_list[j].function_name, "RESET in delete_indice" );
+#endif
}
return i - j;
@@ -1168,14 +3096,14 @@ uint16_t delete_indice(
*-------------------------------------------------------------------*/
/*! r: value of the indice */
-uint16_t get_next_indice(
+UWord16 get_next_indice(
Decoder_State *st, /* i/o: decoder state structure */
- int16_t nb_bits /* i : number of bits that were used to quantize the indice */
+ Word16 nb_bits /* i : number of bits that were used to quantize the indice */
)
{
- uint16_t value;
- int16_t i;
- int32_t nbits_total;
+ UWord16 value;
+ Word16 i;
+ Word32 nbits_total;
assert( nb_bits <= 16 );
@@ -1207,11 +3135,11 @@ uint16_t get_next_indice(
*-------------------------------------------------------------------*/
/*! r: value of the indice */
-uint16_t get_next_indice_1(
+UWord16 get_next_indice_1(
Decoder_State *st /* i/o: decoder state structure */
)
{
- int32_t nbits_total;
+ Word32 nbits_total;
nbits_total = st->total_brate / FRAMES_PER_SEC;
/* detect corrupted bitstream */
if ( ( st->next_bit_pos + 1 > nbits_total && st->codec_mode == MODE1 ) ||
@@ -1233,7 +3161,7 @@ uint16_t get_next_indice_1(
void get_next_indice_tmp(
Decoder_State *st, /* o : decoder state structure */
- int16_t nb_bits /* i : number of bits that were used to quantize the indice */
+ Word16 nb_bits /* i : number of bits that were used to quantize the indice */
)
{
/* update the position in the bitstream */
@@ -1249,15 +3177,15 @@ void get_next_indice_tmp(
*-------------------------------------------------------------------*/
/*! r: value of the indice */
-uint16_t get_indice(
+UWord16 get_indice(
Decoder_State *st, /* i/o: decoder state structure */
- int16_t pos, /* i : absolute position in the bitstream (update after the read) */
- int16_t nb_bits /* i : number of bits that were used to quantize the indice */
+ Word16 pos, /* i : absolute position in the bitstream (update after the read) */
+ Word16 nb_bits /* i : number of bits that were used to quantize the indice */
)
{
- uint16_t value;
- int16_t i;
- int32_t nbits_total;
+ UWord16 value;
+ Word16 i;
+ Word32 nbits_total;
assert( nb_bits <= 16 );
@@ -1391,6 +3319,10 @@ static ivas_error write_indices_element_fx(
UWord16 **pt_stream, /* i : pointer to bitstream buffer */
const Word16 is_SCE, /* i : flag to distingusih SCE and CPE */
const Word16 element_id /* i : id of the SCE or CPE */
+#ifdef DBG_BITSTREAM_ANALYSIS
+ ,
+ int32_t frame
+#endif
)
{
Word16 ch;
@@ -1497,6 +3429,73 @@ static ivas_error write_indices_element_fx(
}
}
+#ifdef DBG_BITSTREAM_ANALYSIS
+ if ( is_SCE ) /* EVS and SCE */
+ {
+ static FILE *f1 = 0;
+
+ if ( f1 == 0 )
+ f1 = fopen( "bitstream_text", "w" );
+
+ for ( int16_t i = 0; i < sts[0]->hBstr->nb_ind_tot; i++ )
+ {
+ Indice *ind_list = sts[0]->hBstr->ind_list;
+ int16_t value = ind_list[i].value;
+ int16_t nb_bits = ind_list[i].nb_bits;
+ char *function_name = ind_list[i].function_name;
+
+ fprintf( f1, "%d %d %d %s %d %d\n", frame, element_id, i, function_name, nb_bits, value );
+ }
+
+ if ( st_ivas->hSCE[element_id]->hMetaData != NULL )
+ {
+ for ( int16_t i = 0; i < st_ivas->hSCE[element_id]->hMetaData->nb_ind_tot; i++ )
+ {
+ Indice *ind_list = st_ivas->hSCE[element_id]->hMetaData->ind_list;
+ int16_t value = ind_list[i].value;
+ int16_t nb_bits = ind_list[i].nb_bits;
+ char *function_name = ind_list[i].function_name;
+
+ fprintf( f1, "%d %d %d %s %d %d\n", frame, element_id, i, function_name, nb_bits, value );
+ }
+ }
+ }
+ else
+ {
+ static FILE *f1 = 0;
+
+ if ( f1 == 0 )
+ f1 = fopen( "bitstream_text", "w" );
+
+
+ for ( n = 0; n < n_channels; n++ )
+ {
+ for ( int16_t i = 0; i < sts[n]->hBstr->nb_ind_tot; i++ )
+ {
+ Indice *ind_list = sts[n]->hBstr->ind_list;
+ int16_t value = ind_list[i].value;
+ int16_t nb_bits = ind_list[i].nb_bits;
+ char *function_name = ind_list[i].function_name;
+
+ fprintf( f1, "%d %d %d %d %s %d %d\n", frame, element_id, n, i, function_name, nb_bits, value );
+ }
+ }
+
+ if ( st_ivas->hCPE[element_id]->hMetaData != NULL )
+ {
+ for ( int16_t i = 0; i < st_ivas->hCPE[element_id]->hMetaData->nb_ind_tot; i++ )
+ {
+ Indice *ind_list = st_ivas->hCPE[element_id]->hMetaData->ind_list;
+ int16_t value = ind_list[i].value;
+ int16_t nb_bits = ind_list[i].nb_bits;
+ char *function_name = ind_list[i].function_name;
+
+ fprintf( f1, "%d %d %d %d %s %d %d\n", frame, element_id, -1, i, function_name, nb_bits, value );
+ }
+ }
+ }
+#endif
+
/*----------------------------------------------------------------*
* Clearing of indices
* Reset index pointers
@@ -1540,6 +3539,10 @@ ivas_error write_indices_ivas_fx(
Encoder_Struct *st_ivas, /* i/o: encoder state structure */
UWord16 *bit_stream, /* i/o: output bitstream */
UWord16 *num_bits /* i : number of indices written to output */
+#ifdef DBG_BITSTREAM_ANALYSIS
+ ,
+ int32_t frame
+#endif
)
{
Word16 i, n;
@@ -1563,12 +3566,22 @@ ivas_error write_indices_ivas_fx(
FOR( n = 0; n < st_ivas->nSCE; n++ )
{
- write_indices_element_fx( st_ivas, &pt_stream, 1, n );
+ write_indices_element_fx( st_ivas, &pt_stream, 1, n
+#ifdef DBG_BITSTREAM_ANALYSIS
+ ,
+ frame
+#endif
+ );
}
FOR( n = 0; n < st_ivas->nCPE; n++ )
{
- write_indices_element_fx( st_ivas, &pt_stream, 0, n );
+ write_indices_element_fx( st_ivas, &pt_stream, 0, n
+#ifdef DBG_BITSTREAM_ANALYSIS
+ ,
+ frame
+#endif
+ );
}
*num_bits = (UWord16) ( pt_stream - bit_stream );
@@ -1584,9 +3597,9 @@ ivas_error write_indices_ivas_fx(
*-------------------------------------------------------------------*/
static void decoder_selectCodec(
- Decoder_State *st, /* i/o: decoder state structure */
- const int32_t total_brate, /* i : total bitrate */
- const int16_t bit0 /* i : first bit */
+ Decoder_State *st, /* i/o: decoder state structure */
+ const Word32 total_brate, /* i : total bitrate */
+ const Word16 bit0 /* i : first bit */
)
{
/* set the AMR-WB IO flag */
@@ -1724,7 +3737,7 @@ void ivas_set_bitstream_pointers(
Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
)
{
- int16_t k, num_bits;
+ Word16 k, num_bits;
Decoder_State **sts;
num_bits = 0;
@@ -1734,7 +3747,7 @@ void ivas_set_bitstream_pointers(
{
sts = st_ivas->hSCE[k]->hCoreCoder;
sts[0]->bit_stream = st_ivas->bit_stream + num_bits;
- num_bits += (int16_t) ( st_ivas->hSCE[k]->element_brate / FRAMES_PER_SEC );
+ num_bits += (Word16) ( st_ivas->hSCE[k]->element_brate / FRAMES_PER_SEC );
}
/* set bitstream pointers for CPEs */
@@ -1742,7 +3755,7 @@ void ivas_set_bitstream_pointers(
{
sts = st_ivas->hCPE[k]->hCoreCoder;
sts[0]->bit_stream = st_ivas->bit_stream + num_bits;
- num_bits += (int16_t) ( st_ivas->hCPE[k]->element_brate / FRAMES_PER_SEC );
+ num_bits += (Word16) ( st_ivas->hCPE[k]->element_brate / FRAMES_PER_SEC );
}
return;
diff --git a/lib_com/bitstream_fx.c b/lib_com/bitstream_fx.c
index 07a6a632fc43a787473c42f94b849dda8c876540..2b66f92cd7ba3352cf0979ffa6b6a23896ac9199 100644
--- a/lib_com/bitstream_fx.c
+++ b/lib_com/bitstream_fx.c
@@ -52,8 +52,7 @@
int16_t FEC_seed = 12558; /* Seed for random FEC generator */
FILE *FEC_pattern = NULL; /* FEC pattern file (for simulation of FEC) */
-#ifndef IVAS_CODE
-float FEC_random = 0; /* FEC rate in percent (for simulation of FEC) */
+float FEC_random = 0; /* FEC rate in percent (for simulation of FEC) */
/*-------------------------------------------------------------------*
* file_read_FECpattern()
*
@@ -109,7 +108,6 @@ static int16_t file_read_FECpattern( void )
return bfi;
}
#endif
-#endif
/*-------------------------------------------------------------------*
* pack_bit()
*
diff --git a/lib_com/cldfb_evs.c b/lib_com/cldfb_evs_fx.c
similarity index 99%
rename from lib_com/cldfb_evs.c
rename to lib_com/cldfb_evs_fx.c
index c28a534d63b01c63d73249732fba395ba4311f79..51c9ee6f9568dbc05a9f19927fa53fa7bfcca3f2 100644
--- a/lib_com/cldfb_evs.c
+++ b/lib_com/cldfb_evs_fx.c
@@ -981,10 +981,6 @@ ivas_error openCldfb(
const Word16 type, /*!< analysis or synthesis */
const Word16 maxCldfbBands, /*!< number of cldfb bands */
const Word16 frameSize /*!< FrameSize */
-#ifdef ADD_IVAS_CLDFB
- ,
- CLDFB_PROTOTYPE prototype /* i : CLDFB version (1.25ms/5ms delay) */
-#endif
)
{
HANDLE_CLDFB_FILTER_BANK hs;
@@ -996,9 +992,6 @@ ivas_error openCldfb(
}
hs->type = type;
-#ifdef ADD_IVAS_CLDFB
- hs->prototype = prototype;
-#endif
move16();
IF( type == CLDFB_ANALYSIS )
diff --git a/lib_com/cldfb.c b/lib_com/cldfb_fx.c
similarity index 70%
rename from lib_com/cldfb.c
rename to lib_com/cldfb_fx.c
index 6a9581498674393c2a698b645299d354c29f2a9c..6c29d2a57f53812f9e42178ecc386e5b3d7e7db1 100644
--- a/lib_com/cldfb.c
+++ b/lib_com/cldfb_fx.c
@@ -60,6 +60,19 @@ static void cldfb_init_proto_and_twiddles( HANDLE_CLDFB_FILTER_BANK hs );
static void cldfb_init_proto_and_twiddles_enc_fx( HANDLE_CLDFB_FILTER_BANK hs );
+static void GetEnergyCldfb_ivas_fx( Word32 *energyLookahead, /*!< o: Q(*sf_energyLookahead) | pointer to the result in the core look-ahead slot */
+ Word16 *sf_energyLookahead, /*!< o: pointer to the scalefactor of the result in the core look-ahead slot */
+ const Word16 numLookahead, /*!< i: Q0 the number of look-ahead time-slots */
+ Word16 **realValues, /*!< i: Q(sf_Values) | the real part of the CLDFB subsamples */
+ Word16 **imagValues, /*!< i: Q(sf_Values) | the imaginary part of the CLDFB subsamples */
+ Word16 sf_Values, /*!< i: scalefactor of the CLDFB subcamples - apply as a negated Exponent */
+ Word16 numberBands, /*!< i: Q0 | number of CLDFB bands */
+ Word16 numberCols, /*!< i: Q0 | number of CLDFB subsamples */
+ Word32 *energyHF, /*!< o: Q31 | pointer to HF energy */
+ Word16 *energyHF_Exp, /*!< o: pointer to exponent of HF energy */
+ Word32 *energyValuesSum, /*!< o: Q(2*sf_Values-4) | pointer to sum array of energy values, not initialized*/
+ Word16 *energyValuesSum_Exp, /*!< o: pointer to exponents of energyValuesSum, not initialized */
+ TEC_ENC_HANDLE hTecEnc );
/*-------------------------------------------------------------------*
* cplxMult()
@@ -91,8 +104,12 @@ void cldfbAnalysis_ivas_fx(
Word32 iBuffer_fx[2 * CLDFB_NO_CHANNELS_MAX];
const Word32 *rot_vctr_re_fx;
const Word32 *rot_vctr_im_fx;
+#ifdef OPT_IVAS_FILTER_ROM
+ const Word32 *ptr_pf_fx;
+#else /* OPT_IVAS_FILTER_ROM */
const Word16 *ptr_pf_fx;
Word16 ptr_pf_sf;
+#endif /* OPT_IVAS_FILTER_ROM */
Word32 *timeBuffer_fx, buffer_fx[( CLDFB_NO_CHANNELS_MAX * CLDFB_NO_COL_MAX ) + ( 9 * CLDFB_NO_CHANNELS_MAX )];
Word16 offset, frameSize;
@@ -134,8 +151,12 @@ void cldfbAnalysis_ivas_fx(
rot_vctr_re_fx = h_cldfb->rot_vec_ana_re_fx;
rot_vctr_im_fx = h_cldfb->rot_vec_ana_im_fx;
+#ifdef OPT_IVAS_FILTER_ROM
+ ptr_pf_fx = h_cldfb->p_filter_32;
+#else /* OPT_IVAS_FILTER_ROM */
ptr_pf_fx = h_cldfb->p_filter;
- ptr_pf_sf = h_cldfb->p_filter_sf; // Q14
+ ptr_pf_sf = h_cldfb->p_filter_sf; // Q14
+#endif /* OPT_IVAS_FILTER_ROM */
move16();
FOR( i = 0; i < no_col; i++ )
@@ -143,6 +164,32 @@ void cldfbAnalysis_ivas_fx(
FOR( k = 0; k < M4; k++ )
{
/* prototype filter */
+#ifdef OPT_IVAS_FILTER_ROM
+ r1_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // Qx
+ r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // Qx
+ r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // Qx
+ r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // Qx
+ r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // Qx
+
+ r2_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 0 * L2 )] ); // Qx
+ r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 1 * L2 )] ); // Qx
+ r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 2 * L2 )] ); // Qx
+ r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 3 * L2 )] ); // Qx
+ r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 4 * L2 )] ); // Qx
+
+ i1_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )] ); // Qx
+ i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )] ); // Qx
+ i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )] ); // Qx
+ i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )] ); // Qx
+ i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )] ); // Qx
+
+ i2_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // Qx
+ i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // Qx
+ i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // Qx
+ i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // Qx
+ i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // Qx
+
+#else /* OPT_IVAS_FILTER_ROM */
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 )] ); // Qx
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 )] ); // Qx
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 )] ); // Qx
@@ -167,10 +214,11 @@ void cldfbAnalysis_ivas_fx(
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 )] ); // Qx
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 )] ); // Qx
- r1_fx = Mpy_32_16_1( r1_fx, ptr_pf_sf ); // Qx - 1
- r2_fx = Mpy_32_16_1( r2_fx, ptr_pf_sf ); // Qx - 1
- i1_fx = Mpy_32_16_1( i1_fx, ptr_pf_sf ); // Qx - 1
- i2_fx = Mpy_32_16_1( i2_fx, ptr_pf_sf ); // Qx - 1
+ r1_fx = Mpy_32_16_1( r1_fx, ptr_pf_sf ); // Qx - 1
+ r2_fx = Mpy_32_16_1( r2_fx, ptr_pf_sf ); // Qx - 1
+ i1_fx = Mpy_32_16_1( i1_fx, ptr_pf_sf ); // Qx - 1
+ i2_fx = Mpy_32_16_1( i2_fx, ptr_pf_sf ); // Qx - 1
+#endif /* OPT_IVAS_FILTER_ROM */
/* folding + pre modulation of DST IV */
rr12_fx = L_sub( r1_fx, r2_fx ); // Qx - 1
@@ -194,6 +242,31 @@ void cldfbAnalysis_ivas_fx(
FOR( k = M4; k < M2; k++ )
{
/* prototype filter */
+#ifdef OPT_IVAS_FILTER_ROM
+ r1_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // Qx
+ r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // Qx
+ r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // Qx
+ r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // Qx
+ r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // Qx
+
+ r2_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - 5 * M2 + ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 0 * L2 )] ); // Qx
+ r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - 5 * M2 + ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 1 * L2 )] ); // Qx
+ r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - 5 * M2 + ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 2 * L2 )] ); // Qx
+ r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - 5 * M2 + ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 3 * L2 )] ); // Qx
+ r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - 5 * M2 + ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 4 * L2 )] ); // Qx
+
+ i1_fx = Msub_32_32( 0, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // Qx
+ i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // Qx
+ i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // Qx
+ i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // Qx
+ i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // Qx
+
+ i2_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )] ); // Qx
+ i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )] ); // Qx
+ i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )] ); // Qx
+ i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )] ); // Qx
+ i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )] ); // Qx
+#else /* OPT_IVAS_FILTER_ROM */
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 )] ); // Qx
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 )] ); // Qx
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 )] ); // Qx
@@ -222,6 +295,7 @@ void cldfbAnalysis_ivas_fx(
r2_fx = Mpy_32_16_1( r2_fx, ptr_pf_sf ); // Qx - 1
i1_fx = Mpy_32_16_1( i1_fx, ptr_pf_sf ); // Qx - 1
i2_fx = Mpy_32_16_1( i2_fx, ptr_pf_sf ); // Qx - 1
+#endif /* OPT_IVAS_FILTER_ROM */
/* folding + pre modulation of DST IV */
rr12_fx = L_add( r1_fx, r2_fx ); // Qx - 1
@@ -310,8 +384,12 @@ void cldfbAnalysis_ts_fx(
const Word32 *rot_vctr_im_fx;
const Word32 *rot_vctr_delay_re_fx;
const Word32 *rot_vctr_delay_im_fx;
+#ifdef OPT_IVAS_FILTER_ROM
+ const Word32 *ptr_pf_fx;
+#else /* OPT_IVAS_FILTER_ROM */
const Word16 *ptr_pf_fx;
Word16 ptr_pf_sf;
+#endif /* OPT_IVAS_FILTER_ROM */
Word32 *timeBuffer_fx, buffer_fx[( CLDFB_NO_CHANNELS_MAX * CLDFB_NO_COL_MAX ) + ( 9 * CLDFB_NO_CHANNELS_MAX )];
Word16 offset, frameSize;
@@ -358,8 +436,12 @@ void cldfbAnalysis_ts_fx(
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
+#ifdef OPT_IVAS_FILTER_ROM
+ ptr_pf_fx = h_cldfb->p_filter_32;
+#else /* OPT_IVAS_FILTER_ROM */
ptr_pf_fx = h_cldfb->p_filter;
- ptr_pf_sf = h_cldfb->p_filter_sf; // Q14
+ ptr_pf_sf = h_cldfb->p_filter_sf; // Q14
+#endif /* OPT_IVAS_FILTER_ROM */
move16();
FOR( i = 0; i < no_col; i++ )
@@ -367,6 +449,31 @@ void cldfbAnalysis_ts_fx(
FOR( k = 0; k < M4; k++ )
{
/* prototype filter */
+#ifdef OPT_IVAS_FILTER_ROM
+ r1_fx = Msub_32_32( 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_32( 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_32( 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_32( 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_32( 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_32( 0, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 0 * L2 )] ); // q
+ r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 1 * L2 )] ); // q
+ r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 2 * L2 )] ); // q
+ r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 3 * L2 )] ); // q
+ r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 4 * L2 )] ); // q
+
+ i1_fx = Msub_32_32( 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_32( 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_32( 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_32( 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_32( 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_32( 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_32( 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_32( 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_32( 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_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // q
+#else /* OPT_IVAS_FILTER_ROM */
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
@@ -391,10 +498,11 @@ void cldfbAnalysis_ts_fx(
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
+ 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
+#endif /* OPT_IVAS_FILTER_ROM */
/* folding + pre modulation of DST IV */
rr12_fx = L_sub( r1_fx, r2_fx ); // q -1
@@ -404,8 +512,8 @@ void cldfbAnalysis_ts_fx(
rBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), ri12_fx, rot_vctr_im_fx[k] ); // q - 3
rBuffer_fx[2 * k + 1] = Madd_32_32( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), ri12_fx, rot_vctr_re_fx[k] ); // q - 3
#else /* OPT_AVOID_STATE_BUF_RESCALE */
- rBuffer_fx[2 * k] = L_sub( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_im_fx[k] ) ); // q - 3
- rBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_re_fx[k] ) ); // q - 3
+ rBuffer_fx[2 * k] = L_sub( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_im_fx[k] ) ); // q - 3
+ rBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_re_fx[k] ) ); // q - 3
#endif /* OPT_AVOID_STATE_BUF_RESCALE */
move32();
move32();
@@ -418,8 +526,8 @@ void cldfbAnalysis_ts_fx(
iBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), ii12_fx, rot_vctr_im_fx[k] ); // q - 3
iBuffer_fx[2 * k + 1] = Madd_32_32( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), ii12_fx, rot_vctr_re_fx[k] ); // q - 3
#else /* OPT_AVOID_STATE_BUF_RESCALE */
- iBuffer_fx[2 * k] = L_sub( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_im_fx[k] ) ); // q - 3
- iBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_re_fx[k] ) ); // q - 3
+ iBuffer_fx[2 * k] = L_sub( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_im_fx[k] ) ); // q - 3
+ iBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_re_fx[k] ) ); // q - 3
#endif /* OPT_AVOID_STATE_BUF_RESCALE */
move32();
move32();
@@ -428,6 +536,31 @@ void cldfbAnalysis_ts_fx(
FOR( k = M4; k < M2; k++ )
{
/* prototype filter */
+#ifdef OPT_IVAS_FILTER_ROM
+ r1_fx = Msub_32_32( 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_32( 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_32( 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_32( 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_32( 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_32( 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_32( 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_32( 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_32( 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_32( 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_32( 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_32( 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_32( 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_32( 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_32( 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_32( 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_32( 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_32( 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_32( 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_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )] ); // q
+#else /* OPT_IVAS_FILTER_ROM */
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
@@ -452,10 +585,11 @@ void cldfbAnalysis_ts_fx(
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
+ 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
+#endif /* OPT_IVAS_FILTER_ROM */
/* folding + pre modulation of DST IV */
rr12_fx = L_add( r1_fx, r2_fx ); // q - 1
@@ -465,8 +599,8 @@ void cldfbAnalysis_ts_fx(
rBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), ri12_fx, rot_vctr_im_fx[k] ); // q - 3
rBuffer_fx[2 * k + 1] = Madd_32_32( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), ri12_fx, rot_vctr_re_fx[k] ); // q - 3
#else /* OPT_AVOID_STATE_BUF_RESCALE */
- rBuffer_fx[2 * k] = L_sub( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_im_fx[k] ) ); // q - 3
- rBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_re_fx[k] ) ); // q - 3
+ rBuffer_fx[2 * k] = L_sub( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_im_fx[k] ) ); // q - 3
+ rBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_re_fx[k] ) ); // q - 3
#endif /* OPT_AVOID_STATE_BUF_RESCALE */
move32();
move32();
@@ -479,8 +613,8 @@ void cldfbAnalysis_ts_fx(
iBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), ii12_fx, rot_vctr_im_fx[k] ); // q - 3
iBuffer_fx[2 * k + 1] = Madd_32_32( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), ii12_fx, rot_vctr_re_fx[k] ); // q - 3
#else /* OPT_AVOID_STATE_BUF_RESCALE */
- iBuffer_fx[2 * k] = L_sub( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_im_fx[k] ) ); // q - 3
- iBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_re_fx[k] ) ); // q - 3
+ iBuffer_fx[2 * k] = L_sub( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_im_fx[k] ) ); // q - 3
+ iBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_re_fx[k] ) ); // q - 3
#endif /* OPT_AVOID_STATE_BUF_RESCALE */
move32();
move32();
@@ -506,6 +640,7 @@ void cldfbAnalysis_ts_fx(
}
fft_cldfb_fx( rBuffer_fx, M2 );
+#ifndef FIX_1733_CLDFB_BUG
/* post modulation of DST IV */
FOR( k = 0; k < M2; k++ )
{
@@ -520,6 +655,7 @@ void cldfbAnalysis_ts_fx(
move32();
move32();
}
+#endif
*q_cldfb = sub( *q_cldfb, 2 );
move16();
@@ -540,6 +676,23 @@ void cldfbAnalysis_ts_fx(
move32();
}
+#ifdef FIX_1733_CLDFB_BUG
+ /* 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]);*/
+#ifdef OPT_AVOID_STATE_BUF_RESCALE
+ realBuffer_fx[( ( M1 - 1 ) - ( k * 2 ) )] = Msub_32_32( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_re_fx[k] ), rBuffer_fx[2 * k + 1], rot_vctr_im_fx[k] ); // q - 5
+ realBuffer_fx[2 * k] = Madd_32_32( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_im_fx[k] ), rBuffer_fx[2 * k + 1], rot_vctr_re_fx[k] ); // q - 5
+#else /* OPT_AVOID_STATE_BUF_RESCALE */
+ realBuffer_fx[( ( M1 - 1 ) - ( k * 2 ) )] = L_sub( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_re_fx[k] ), Mpy_32_32( rBuffer_fx[2 * k + 1], rot_vctr_im_fx[k] ) ); // q - 5
+ realBuffer_fx[2 * k] = L_add( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_im_fx[k] ), Mpy_32_32( rBuffer_fx[2 * k + 1], rot_vctr_re_fx[k] ) ); // q - 5
+#endif /* OPT_AVOID_STATE_BUF_RESCALE */
+ move32();
+ move32();
+ }
+
+#endif
/* post modulation of DCT IV */
FOR( k = 0; k < M2; k++ )
{
@@ -549,8 +702,8 @@ void cldfbAnalysis_ts_fx(
imagBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_re_fx[k] ), iBuffer_fx[2 * k + 1], rot_vctr_im_fx[k] ); // q - 5
imagBuffer_fx[( M1 - 1 ) - ( k * 2 )] = Madd_32_32( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_im_fx[k] ), iBuffer_fx[2 * k + 1], rot_vctr_re_fx[k] ); // q - 5
#else /* OPT_AVOID_STATE_BUF_RESCALE */
- imagBuffer_fx[2 * k] = L_sub( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_re_fx[k] ), Mpy_32_32( iBuffer_fx[2 * k + 1], rot_vctr_im_fx[k] ) ); // q - 5
- imagBuffer_fx[( M1 - 1 ) - ( k * 2 )] = L_add( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_im_fx[k] ), Mpy_32_32( iBuffer_fx[2 * k + 1], rot_vctr_re_fx[k] ) ); // q - 5
+ imagBuffer_fx[2 * k] = L_sub( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_re_fx[k] ), Mpy_32_32( iBuffer_fx[2 * k + 1], rot_vctr_im_fx[k] ) ); // q - 5
+ imagBuffer_fx[( M1 - 1 ) - ( k * 2 )] = L_add( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_im_fx[k] ), Mpy_32_32( iBuffer_fx[2 * k + 1], rot_vctr_re_fx[k] ) ); // q - 5
#endif /* OPT_AVOID_STATE_BUF_RESCALE */
move32();
move32();
@@ -576,8 +729,8 @@ void cldfbAnalysis_ts_fx(
cplx_aux_fx = Msub_32_32( Mpy_32_32( realBuffer_fx[k], rot_vctr_delay_re_fx[k] ), imagBuffer_fx[k], rot_vctr_delay_im_fx[k] ); // q - 5
imagBuffer_fx[k] = Madd_32_32( Mpy_32_32( realBuffer_fx[k], rot_vctr_delay_im_fx[k] ), imagBuffer_fx[k], rot_vctr_delay_re_fx[k] ); // q - 5
#else /* OPT_AVOID_STATE_BUF_RESCALE */
- cplx_aux_fx = L_sub( Mpy_32_32( realBuffer_fx[k], rot_vctr_delay_re_fx[k] ), Mpy_32_32( imagBuffer_fx[k], rot_vctr_delay_im_fx[k] ) ); // q - 5
- imagBuffer_fx[k] = L_add( Mpy_32_32( realBuffer_fx[k], rot_vctr_delay_im_fx[k] ), Mpy_32_32( imagBuffer_fx[k], rot_vctr_delay_re_fx[k] ) ); // q - 5
+ cplx_aux_fx = L_sub( Mpy_32_32( realBuffer_fx[k], rot_vctr_delay_re_fx[k] ), Mpy_32_32( imagBuffer_fx[k], rot_vctr_delay_im_fx[k] ) ); // q - 5
+ imagBuffer_fx[k] = L_add( Mpy_32_32( realBuffer_fx[k], rot_vctr_delay_im_fx[k] ), Mpy_32_32( imagBuffer_fx[k], rot_vctr_delay_re_fx[k] ) ); // q - 5
#endif /* OPT_AVOID_STATE_BUF_RESCALE */
realBuffer_fx[k] = cplx_aux_fx;
move32();
@@ -627,8 +780,12 @@ void cldfbAnalysis_ts_fx_var_q(
const Word32 *rot_vctr_im_fx;
const Word32 *rot_vctr_delay_re_fx;
const Word32 *rot_vctr_delay_im_fx;
+#ifdef OPT_IVAS_FILTER_ROM
+ const Word32 *ptr_pf_fx;
+#else /* OPT_IVAS_FILTER_ROM */
const Word16 *ptr_pf_fx;
Word16 ptr_pf_sf;
+#endif /* OPT_IVAS_FILTER_ROM */
Word32 *timeBuffer_fx, buffer_fx[( CLDFB_NO_CHANNELS_MAX * CLDFB_NO_COL_MAX ) + ( 9 * CLDFB_NO_CHANNELS_MAX )];
Word16 offset, frameSize;
@@ -692,8 +849,12 @@ void cldfbAnalysis_ts_fx_var_q(
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
+#ifdef OPT_IVAS_FILTER_ROM
+ ptr_pf_fx = h_cldfb->p_filter_32;
+#else /* OPT_IVAS_FILTER_ROM */
ptr_pf_fx = h_cldfb->p_filter;
- ptr_pf_sf = h_cldfb->p_filter_sf; // Q14
+ ptr_pf_sf = h_cldfb->p_filter_sf; // Q14
+#endif /* OPT_IVAS_FILTER_ROM */
move16();
FOR( i = 0; i < no_col; i++ )
@@ -701,6 +862,31 @@ void cldfbAnalysis_ts_fx_var_q(
FOR( k = 0; k < M4; k++ )
{
/* prototype filter */
+#ifdef OPT_IVAS_FILTER_ROM
+ r1_fx = Msub_32_32( 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_32( 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_32( 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_32( 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_32( 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_32( 0, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 0 * L2 )] ); // q
+ r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 1 * L2 )] ); // q
+ r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 2 * L2 )] ); // q
+ r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 3 * L2 )] ); // q
+ r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 4 * L2 )] ); // q
+
+ i1_fx = Msub_32_32( 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_32( 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_32( 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_32( 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_32( 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_32( 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_32( 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_32( 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_32( 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_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // q
+#else /* OPT_IVAS_FILTER_ROM */
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
@@ -725,10 +911,11 @@ void cldfbAnalysis_ts_fx_var_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
+ 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
+#endif /* OPT_IVAS_FILTER_ROM */
/* folding + pre modulation of DST IV */
rr12_fx = L_sub( r1_fx, r2_fx ); // q -1
@@ -752,6 +939,32 @@ void cldfbAnalysis_ts_fx_var_q(
FOR( k = M4; k < M2; k++ )
{
/* prototype filter */
+#ifdef OPT_IVAS_FILTER_ROM
+ r1_fx = Msub_32_32( 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_32( 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_32( 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_32( 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_32( 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_32( 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_32( 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_32( 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_32( 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_32( 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_32( 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_32( 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_32( 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_32( 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_32( 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_32( 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_32( 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_32( 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_32( 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_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )] ); // q
+
+#else /* OPT_IVAS_FILTER_ROM */
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
@@ -780,6 +993,7 @@ void cldfbAnalysis_ts_fx_var_q(
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
+#endif /* OPT_IVAS_FILTER_ROM */
/* folding + pre modulation of DST IV */
rr12_fx = L_add( r1_fx, r2_fx ); // q - 1
@@ -898,8 +1112,12 @@ void cldfbAnalysis_ts_fx_fixed_q(
const Word32 *rot_vctr_im_fx;
const Word32 *rot_vctr_delay_re_fx;
const Word32 *rot_vctr_delay_im_fx;
+#ifdef OPT_IVAS_FILTER_ROM
+ const Word32 *ptr_pf_fx;
+#else /* OPT_IVAS_FILTER_ROM */
const Word16 *ptr_pf_fx;
Word16 ptr_pf_sf;
+#endif /* OPT_IVAS_FILTER_ROM */
Word32 *timeBuffer_fx, buffer_fx[( CLDFB_NO_CHANNELS_MAX * CLDFB_NO_COL_MAX ) + ( 9 * CLDFB_NO_CHANNELS_MAX )];
Word16 offset, frameSize, gb, hr, shift;
@@ -945,8 +1163,12 @@ void cldfbAnalysis_ts_fx_fixed_q(
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
+#ifdef OPT_IVAS_FILTER_ROM
+ ptr_pf_fx = h_cldfb->p_filter_32;
+#else /* OPT_IVAS_FILTER_ROM */
ptr_pf_fx = h_cldfb->p_filter;
- ptr_pf_sf = h_cldfb->p_filter_sf; // Q14
+ ptr_pf_sf = h_cldfb->p_filter_sf; // Q14
+#endif /* OPT_IVAS_FILTER_ROM */
move16();
FOR( i = 0; i < no_col; i++ )
@@ -954,6 +1176,31 @@ void cldfbAnalysis_ts_fx_fixed_q(
FOR( k = 0; k < M4; k++ )
{
/* prototype filter */
+#ifdef OPT_IVAS_FILTER_ROM
+ r1_fx = Msub_32_32( 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_32( 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_32( 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_32( 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_32( 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_32( 0, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 0 * L2 )] ); // q
+ r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 1 * L2 )] ); // q
+ r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 2 * L2 )] ); // q
+ r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 3 * L2 )] ); // q
+ r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 4 * L2 )] ); // q
+
+ i1_fx = Msub_32_32( 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_32( 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_32( 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_32( 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_32( 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_32( 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_32( 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_32( 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_32( 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_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // q
+#else /* OPT_IVAS_FILTER_ROM */
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
@@ -978,10 +1225,11 @@ void cldfbAnalysis_ts_fx_fixed_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
+ 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
+#endif /* OPT_IVAS_FILTER_ROM */
/* folding + pre modulation of DST IV */
rr12_fx = L_sub( r1_fx, r2_fx ); // q -1
@@ -1005,6 +1253,31 @@ void cldfbAnalysis_ts_fx_fixed_q(
FOR( k = M4; k < M2; k++ )
{
/* prototype filter */
+#ifdef OPT_IVAS_FILTER_ROM
+ r1_fx = Msub_32_32( 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_32( 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_32( 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_32( 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_32( 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_32( 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_32( 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_32( 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_32( 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_32( 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_32( 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_32( 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_32( 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_32( 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_32( 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_32( 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_32( 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_32( 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_32( 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_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )] ); // q
+#else /* OPT_IVAS_FILTER_ROM */
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
@@ -1033,6 +1306,7 @@ void cldfbAnalysis_ts_fx_fixed_q(
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
+#endif /* OPT_IVAS_FILTER_ROM */
/* folding + pre modulation of DST IV */
rr12_fx = L_add( r1_fx, r2_fx ); // q - 1
@@ -1190,8 +1464,12 @@ void cldfbSynthesis_ivas_fx(
Word32 new_samples_fx[2 * CLDFB_NO_CHANNELS_MAX];
Word32 *ptr_time_out_fx;
+#ifdef OPT_IVAS_FILTER_ROM
+ const Word32 *p_filter_32;
+#else /* OPT_IVAS_FILTER_ROM */
const Word16 *p_filter;
Word16 p_filter_sf;
+#endif /* OPT_IVAS_FILTER_ROM */
Word32 accu0, accu1, accu2, accu3, accu4;
Word16 no_col = h_cldfb->no_col;
@@ -1221,9 +1499,12 @@ void cldfbSynthesis_ivas_fx(
synthesisBuffer_fx = buffer_fx;
Copy32( h_cldfb->cldfb_state_fx, synthesisBuffer_fx + i_mult( M1, no_col ), h_cldfb->p_filter_length );
+#ifdef OPT_IVAS_FILTER_ROM
+ p_filter_32 = h_cldfb->p_filter_32;
+#else /* OPT_IVAS_FILTER_ROM */
p_filter = h_cldfb->p_filter;
- p_filter_sf = h_cldfb->p_filter_sf; // Q14
- move16();
+ p_filter_sf = h_cldfb->p_filter_sf; // Q14
+#endif /* OPT_IVAS_FILTER_ROM */
ptr_time_out_fx = timeOut_fx;
/*synthesisBuffer += M1 * h_cldfb->no_col;*/
@@ -1334,11 +1615,19 @@ void cldfbSynthesis_ivas_fx(
{
FOR( i = 0; i < L2; i++ )
{
+#ifdef OPT_IVAS_FILTER_ROM
+ accu0 = Madd_32_32( synthesisBuffer_fx[i], new_samples_fx[L2 - 1 - i], p_filter_32[i] ); // Qx - 1
+ accu1 = Madd_32_32( synthesisBuffer_fx[1 * L2 + i], new_samples_fx[L2 - 1 - i], p_filter_32[( 1 * L2 + i )] ); // Qx - 1
+ accu2 = Madd_32_32( synthesisBuffer_fx[2 * L2 + i], new_samples_fx[L2 - 1 - i], p_filter_32[( 2 * L2 + i )] ); // Qx - 1
+ accu3 = Madd_32_32( synthesisBuffer_fx[3 * L2 + i], new_samples_fx[L2 - 1 - i], p_filter_32[( 3 * L2 + i )] ); // Qx - 1
+ accu4 = Madd_32_32( synthesisBuffer_fx[4 * L2 + i], new_samples_fx[L2 - 1 - i], p_filter_32[( 4 * L2 + i )] ); // Qx - 1
+#else /* OPT_IVAS_FILTER_ROM */
accu0 = Madd_32_16( synthesisBuffer_fx[i], Mpy_32_16_1( new_samples_fx[L2 - 1 - i], p_filter[i] ), p_filter_sf ); // Qx - 1
accu1 = Madd_32_16( synthesisBuffer_fx[1 * L2 + i], Mpy_32_16_1( new_samples_fx[L2 - 1 - i], p_filter[( 1 * L2 + i )] ), p_filter_sf ); // Qx - 1
accu2 = Madd_32_16( synthesisBuffer_fx[2 * L2 + i], Mpy_32_16_1( new_samples_fx[L2 - 1 - i], p_filter[( 2 * L2 + i )] ), p_filter_sf ); // Qx - 1
accu3 = Madd_32_16( synthesisBuffer_fx[3 * L2 + i], Mpy_32_16_1( new_samples_fx[L2 - 1 - i], p_filter[( 3 * L2 + i )] ), p_filter_sf ); // Qx - 1
accu4 = Madd_32_16( synthesisBuffer_fx[4 * L2 + i], Mpy_32_16_1( new_samples_fx[L2 - 1 - i], p_filter[( 4 * L2 + i )] ), p_filter_sf ); // Qx - 1
+#endif /* OPT_IVAS_FILTER_ROM */
synthesisBuffer_fx[i] = accu0;
move32();
@@ -1357,12 +1646,21 @@ void cldfbSynthesis_ivas_fx(
FOR( i = 0; i < L2; i++ )
{
+#ifdef OPT_IVAS_FILTER_ROM
+ Word32 prod = L_shl_sat( ( new_samples_fx[L2 - 1 - i] ), shift );
+ accu0 = Madd_32_32( synthesisBuffer_fx[i], prod, p_filter_32[i] ); // Qx -1 + shift
+ accu1 = Madd_32_32( synthesisBuffer_fx[1 * L2 + i], prod, p_filter_32[( 1 * L2 + i )] ); // Qx -1 + shift
+ accu2 = Madd_32_32( synthesisBuffer_fx[2 * L2 + i], prod, p_filter_32[( 2 * L2 + i )] ); // Qx -1 + shift
+ accu3 = Madd_32_32( synthesisBuffer_fx[3 * L2 + i], prod, p_filter_32[( 3 * L2 + i )] ); // Qx -1 + shift
+ accu4 = Madd_32_32( synthesisBuffer_fx[4 * L2 + i], prod, p_filter_32[( 4 * L2 + i )] ); // Qx -1 + shift
+#else /* OPT_IVAS_FILTER_ROM */
Word32 prod = L_shl_sat( Mpy_32_16_1( new_samples_fx[L2 - 1 - i], p_filter_sf ), shift );
accu0 = Madd_32_16( synthesisBuffer_fx[i], prod, p_filter[i] ); // Qx -1 + shift
accu1 = Madd_32_16( synthesisBuffer_fx[1 * L2 + i], prod, p_filter[( 1 * L2 + i )] ); // Qx -1 + shift
accu2 = Madd_32_16( synthesisBuffer_fx[2 * L2 + i], prod, p_filter[( 2 * L2 + i )] ); // Qx -1 + shift
accu3 = Madd_32_16( synthesisBuffer_fx[3 * L2 + i], prod, p_filter[( 3 * L2 + i )] ); // Qx -1 + shift
accu4 = Madd_32_16( synthesisBuffer_fx[4 * L2 + i], prod, p_filter[( 4 * L2 + i )] ); // Qx -1 + shift
+#endif /* OPT_IVAS_FILTER_ROM */
synthesisBuffer_fx[i] = accu0;
move32();
@@ -1552,6 +1850,168 @@ void resampleCldfb_ivas_fx(
return;
}
+static void GetEnergyCldfb_ivas_fx( Word32 *energyLookahead, /*!< o: Q(*sf_energyLookahead) | pointer to the result in the core look-ahead slot */
+ Word16 *sf_energyLookahead, /*!< o: pointer to the scalefactor of the result in the core look-ahead slot */
+ const Word16 numLookahead, /*!< i: Q0 the number of look-ahead time-slots */
+ Word16 **realValues, /*!< i: Q(sf_Values) | the real part of the CLDFB subsamples */
+ Word16 **imagValues, /*!< i: Q(sf_Values) | the imaginary part of the CLDFB subsamples */
+ Word16 sf_Values, /*!< i: scalefactor of the CLDFB subcamples - apply as a negated Exponent */
+ Word16 numberBands, /*!< i: Q0 | number of CLDFB bands */
+ Word16 numberCols, /*!< i: Q0 | number of CLDFB subsamples */
+ Word32 *energyHF, /*!< o: Q31 | pointer to HF energy */
+ Word16 *energyHF_Exp, /*!< o: pointer to exponent of HF energy */
+ Word32 *energyValuesSum, /*!< o: Q(2*sf_Values-4) | pointer to sum array of energy values, not initialized*/
+ Word16 *energyValuesSum_Exp, /*!< o: pointer to exponents of energyValuesSum, not initialized */
+ TEC_ENC_HANDLE hTecEnc )
+{
+ Word16 j;
+ Word16 k;
+ Word16 s;
+ Word16 sm;
+ Word32 nrg;
+ Word16 numberColsL;
+ Word16 numberBandsM;
+ Word16 numberBandsM20;
+ Word32 energyValues[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
+ Word16 energyValuesSumE[CLDFB_NO_CHANNELS_MAX];
+ // Word16 freqTable[2] = {20, 40};
+#ifdef BASOP_NOGLOB_DECLARE_LOCAL
+ Flag Overflow = 0;
+ move32();
+#endif
+
+ FOR( k = 0; k < numberCols; k++ )
+ {
+ FOR( j = 0; j < numberBands; j++ )
+ {
+ nrg = L_mult0( realValues[k][j], realValues[k][j] ); // Q(2*sf_Values)
+ nrg = L_mac0( nrg, imagValues[k][j], imagValues[k][j] ); // Q(2*sf_Values)
+
+ energyValues[k][j] = nrg;
+ move32();
+ }
+ }
+
+ IF( GE_16( numberBands, freqTable[1] ) && hTecEnc != NULL )
+ {
+ Word32 *tempEnergyValuesArry[CLDFB_NO_COL_MAX];
+ Word16 ScaleX2;
+ assert( numberCols == CLDFB_NO_COL_MAX );
+ FOR( j = 0; j < numberCols; j++ )
+ {
+ tempEnergyValuesArry[j] = &energyValues[j][0];
+ }
+
+ ScaleX2 = shl( sf_Values, 1 );
+ calcHiEnvLoBuff_Fix(
+ numberCols,
+ freqTable,
+ 1,
+ tempEnergyValuesArry,
+ hTecEnc->loBuffer,
+ hTecEnc->hiTempEnv,
+ ScaleX2 );
+ }
+
+ FOR( j = 0; j < numberBands; j++ )
+ {
+ energyValuesSum[j] = 0;
+ move32();
+ energyValuesSumE[j] = 31;
+ move16();
+ FOR( k = 0; k < CLDFB_NO_COL_MAX; k++ )
+ {
+ nrg = L_shr_r( energyValues[k][j], sub( energyValuesSumE[j], 31 ) ); // Q(2*sf_Values - (energyValuesSumE[j]-31))
+ IF( LT_32( L_sub( maxWord32, nrg ), energyValuesSum[j] ) )
+ {
+ energyValuesSumE[j] = add( energyValuesSumE[j], 1 );
+ move16();
+ energyValuesSum[j] = L_shr_r( energyValuesSum[j], 1 );
+ move32();
+ nrg = L_shr_r( nrg, 1 );
+ }
+ energyValuesSum[j] = L_add( energyValuesSum[j], nrg );
+ move32();
+ }
+ test();
+ if ( j == 0 || GT_16( energyValuesSumE[j], *energyValuesSum_Exp ) )
+ {
+ *energyValuesSum_Exp = energyValuesSumE[j];
+ move16();
+ }
+ }
+ FOR( j = 0; j < numberBands; j++ )
+ {
+ energyValuesSum[j] = L_shr_r( energyValuesSum[j], sub( *energyValuesSum_Exp, energyValuesSumE[j] ) ); // Q(energyValuesSum_Exp - (2*sf_Values))
+ move32();
+ }
+ *energyValuesSum_Exp = sub( *energyValuesSum_Exp, shl( sf_Values, 1 ) );
+ move16();
+
+ IF( GT_16( numberBands, 20 ) )
+ {
+ numberBandsM = s_min( numberBands, 40 );
+ numberBandsM20 = sub( numberBandsM, 20 );
+
+ numberColsL = sub( numberCols, numLookahead );
+
+ /* sum up CLDFB energy above 8 kHz */
+ s = BASOP_util_norm_s_bands2shift( i_mult( numberColsL, numberBandsM20 ) );
+ s = sub( s, 4 );
+ nrg = 0;
+ move32();
+ FOR( k = 0; k < numberColsL; k++ )
+ {
+ FOR( j = 20; j < numberBandsM; j++ )
+ {
+ nrg = L_add_o( nrg, L_shr_o( energyValues[k][j], s, &Overflow ), &Overflow );
+ }
+ }
+
+ s = sub( sub( shl( sf_Values, 1 ), 1 ), s );
+ sm = sub( s_min( s, *sf_energyLookahead ), 1 );
+
+ *energyHF = L_add( L_shr( nrg, limitScale32( sub( s, sm ) ) ),
+ L_shr( *energyLookahead, sub( *sf_energyLookahead, sm ) ) ); // Q(31-(-nm))
+ move32();
+
+ *energyHF_Exp = negate( sm );
+ move16();
+
+ /* process look-ahead region */
+ s = BASOP_util_norm_s_bands2shift( i_mult( numLookahead, numberBandsM20 ) );
+ s = sub( s, 2 );
+ nrg = 0;
+ move32();
+ FOR( k = numberColsL; k < numberCols; k++ )
+ {
+ FOR( j = 20; j < numberBandsM; j++ )
+ {
+ nrg = L_add_o( nrg, L_shr_o( energyValues[k][j], s, &Overflow ), &Overflow );
+ }
+ }
+
+ s = sub( shl( sf_Values, 1 ), s );
+ sm = sub( s_min( s, 44 ), 1 );
+ BASOP_SATURATE_WARNING_OFF_EVS
+ /* nrg + 6.1e-5f => value 0x40000000, scale 44 */
+ *energyLookahead = L_add_sat( L_shr_sat( nrg, sub( s, sm ) ),
+ L_shr_sat( 0x40000000, s_max( -31, s_min( 31, sub( 44, sm ) ) ) ) );
+ move32();
+ BASOP_SATURATE_WARNING_ON_EVS
+ *sf_energyLookahead = sm;
+ move16();
+
+ return;
+ }
+
+
+ *energyHF = 0x40000000;
+ move32();
+ *energyHF_Exp = 17;
+ move16();
+}
+
void analysisCldfbEncoder_ivas_fx(
Encoder_State *st, /* i/o: encoder state structure */
@@ -1613,7 +2073,7 @@ void analysisCldfbEncoder_ivas_fx(
AnalysisPostSpectrumScaling_Fx( st->cldfbAnaEnc, ppBuf_Real, ppBuf_Imag, ppBuf_Real16, ppBuf_Imag16, &enerScale.lb_scale16 );
- GetEnergyCldfb( &st->energyCoreLookahead_Fx, &st->sf_energyCoreLookahead_Fx, 1, ppBuf_Real16, ppBuf_Imag16, enerScale.lb_scale16, st->cldfbAnaEnc->no_channels, st->cldfbAnaEnc->no_col, &st->currEnergyHF_fx, &st->currEnergyHF_e_fx, ppBuf_Ener, enerBuffSum_exp, st->hTECEnc );
+ GetEnergyCldfb_ivas_fx( &st->energyCoreLookahead_Fx, &st->sf_energyCoreLookahead_Fx, 1, ppBuf_Real16, ppBuf_Imag16, enerScale.lb_scale16, st->cldfbAnaEnc->no_channels, st->cldfbAnaEnc->no_col, &st->currEnergyHF_fx, &st->currEnergyHF_e_fx, ppBuf_Ener, enerBuffSum_exp, st->hTECEnc );
return;
}
@@ -1673,8 +2133,12 @@ static void cldfb_init_proto_and_twiddles(
hs->rot_vec_ana_delay_im_fx = NULL;
hs->rot_vec_syn_delay_im_fx = NULL;
hs->rot_vec_syn_delay_re_fx = NULL;
- hs->p_filter_sf = (Word16) 17036; // Q14
+#ifdef OPT_IVAS_FILTER_ROM
+ hs->p_filter_32 = CLDFB80_10_fx;
+#else /* OPT_IVAS_FILTER_ROM */
+ hs->p_filter_sf = (Word16) 17036; // Q14
hs->p_filter = CLDFB80_10_fx;
+#endif /* OPT_IVAS_FILTER_ROM */
hs->scale = CLDFB80_10_SCALE_FX_Q8;
}
ELSE IF( EQ_32( hs->prototype, CLDFB_PROTOTYPE_5_00MS ) )
@@ -1685,8 +2149,12 @@ static void cldfb_init_proto_and_twiddles(
hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx;
hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx;
hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx;
+#ifdef OPT_IVAS_FILTER_ROM
+ hs->p_filter_32 = LDQMF_10_fx;
+#else /* OPT_IVAS_FILTER_ROM */
hs->p_filter_sf = (Word16) 15388; // Q14
hs->p_filter = LDQMF_10_fx;
+#endif /* OPT_IVAS_FILTER_ROM */
hs->scale = LDQMF_10_SCALE_FX_Q8;
}
BREAK;
@@ -1704,8 +2172,12 @@ static void cldfb_init_proto_and_twiddles(
hs->rot_vec_ana_delay_im_fx = NULL;
hs->rot_vec_syn_delay_im_fx = NULL;
hs->rot_vec_syn_delay_re_fx = NULL;
+#ifdef OPT_IVAS_FILTER_ROM
+ hs->p_filter_32 = CLDFB80_16_fx;
+#else /* OPT_IVAS_FILTER_ROM */
hs->p_filter_sf = (Word16) 17051; // Q14
hs->p_filter = CLDFB80_16_fx;
+#endif /* OPT_IVAS_FILTER_ROM */
hs->scale = CLDFB80_16_SCALE_FX_Q8;
}
ELSE IF( EQ_32( hs->prototype, CLDFB_PROTOTYPE_5_00MS ) )
@@ -1716,8 +2188,12 @@ static void cldfb_init_proto_and_twiddles(
hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx;
hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx;
hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx;
+#ifdef OPT_IVAS_FILTER_ROM
+ hs->p_filter_32 = LDQMF_16_fx;
+#else /* OPT_IVAS_FILTER_ROM */
hs->p_filter_sf = (Word16) 15388; // Q14
hs->p_filter = LDQMF_16_fx;
+#endif /* OPT_IVAS_FILTER_ROM */
hs->scale = LDQMF_16_SCALE_FX_Q8;
}
BREAK;
@@ -1735,8 +2211,12 @@ static void cldfb_init_proto_and_twiddles(
hs->rot_vec_ana_delay_im_fx = NULL;
hs->rot_vec_syn_delay_im_fx = NULL;
hs->rot_vec_syn_delay_re_fx = NULL;
+#ifdef OPT_IVAS_FILTER_ROM
+ hs->p_filter_32 = CLDFB80_20_fx;
+#else /* OPT_IVAS_FILTER_ROM */
hs->p_filter_sf = (Word16) 17050; // Q14
hs->p_filter = CLDFB80_20_fx;
+#endif /* OPT_IVAS_FILTER_ROM */
hs->scale = CLDFB80_20_SCALE_FX_Q8;
}
ELSE IF( EQ_32( hs->prototype, CLDFB_PROTOTYPE_5_00MS ) )
@@ -1747,8 +2227,12 @@ static void cldfb_init_proto_and_twiddles(
hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx;
hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx;
hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx;
+#ifdef OPT_IVAS_FILTER_ROM
+ hs->p_filter_32 = LDQMF_20_fx;
+#else /* OPT_IVAS_FILTER_ROM */
hs->p_filter_sf = (Word16) 15390; // Q14
hs->p_filter = LDQMF_20_fx;
+#endif /* OPT_IVAS_FILTER_ROM */
hs->scale = LDQMF_20_SCALE_FX_Q8;
}
BREAK;
@@ -1766,8 +2250,12 @@ static void cldfb_init_proto_and_twiddles(
hs->rot_vec_ana_delay_im_fx = NULL;
hs->rot_vec_syn_delay_im_fx = NULL;
hs->rot_vec_syn_delay_re_fx = NULL;
+#ifdef OPT_IVAS_FILTER_ROM
+ hs->p_filter_32 = CLDFB80_30_fx;
+#else /* OPT_IVAS_FILTER_ROM */
hs->p_filter_sf = (Word16) 17051; // Q14
hs->p_filter = CLDFB80_30_fx;
+#endif /* OPT_IVAS_FILTER_ROM */
hs->scale = CLDFB80_30_SCALE_FX_Q8;
}
ELSE IF( EQ_32( hs->prototype, CLDFB_PROTOTYPE_5_00MS ) )
@@ -1778,8 +2266,12 @@ static void cldfb_init_proto_and_twiddles(
hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx;
hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx;
hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx;
+#ifdef OPT_IVAS_FILTER_ROM
+ hs->p_filter_32 = LDQMF_30_fx;
+#else /* OPT_IVAS_FILTER_ROM */
hs->p_filter_sf = (Word16) 15388; // Q14
hs->p_filter = LDQMF_30_fx;
+#endif /* OPT_IVAS_FILTER_ROM */
hs->scale = LDQMF_30_SCALE_FX_Q8;
}
BREAK;
@@ -1797,8 +2289,12 @@ static void cldfb_init_proto_and_twiddles(
hs->rot_vec_ana_delay_im_fx = NULL;
hs->rot_vec_syn_delay_im_fx = NULL;
hs->rot_vec_syn_delay_re_fx = NULL;
+#ifdef OPT_IVAS_FILTER_ROM
+ hs->p_filter_32 = CLDFB80_32_fx;
+#else /* OPT_IVAS_FILTER_ROM */
hs->p_filter_sf = (Word16) 17050; // Q14
hs->p_filter = CLDFB80_32_fx;
+#endif /* OPT_IVAS_FILTER_ROM */
hs->scale = CLDFB80_32_SCALE_FX_Q8;
}
ELSE IF( EQ_32( hs->prototype, CLDFB_PROTOTYPE_5_00MS ) )
@@ -1809,8 +2305,12 @@ static void cldfb_init_proto_and_twiddles(
hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx;
hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx;
hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx;
+#ifdef OPT_IVAS_FILTER_ROM
+ hs->p_filter_32 = LDQMF_32_fx;
+#else /* OPT_IVAS_FILTER_ROM */
hs->p_filter_sf = (Word16) 15392; // Q14
hs->p_filter = LDQMF_32_fx;
+#endif /* OPT_IVAS_FILTER_ROM */
hs->scale = LDQMF_32_SCALE_FX_Q8;
}
BREAK;
@@ -1828,8 +2328,12 @@ static void cldfb_init_proto_and_twiddles(
hs->rot_vec_ana_delay_im_fx = NULL;
hs->rot_vec_syn_delay_im_fx = NULL;
hs->rot_vec_syn_delay_re_fx = NULL;
+#ifdef OPT_IVAS_FILTER_ROM
+ hs->p_filter_32 = CLDFB80_40_fx;
+#else /* OPT_IVAS_FILTER_ROM */
hs->p_filter_sf = (Word16) 17051; // Q14
hs->p_filter = CLDFB80_40_fx;
+#endif /* OPT_IVAS_FILTER_ROM */
hs->scale = CLDFB80_40_SCALE_FX_Q8;
}
ELSE IF( EQ_32( hs->prototype, CLDFB_PROTOTYPE_5_00MS ) )
@@ -1840,8 +2344,12 @@ static void cldfb_init_proto_and_twiddles(
hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx;
hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx;
hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx;
+#ifdef OPT_IVAS_FILTER_ROM
+ hs->p_filter_32 = LDQMF_40_fx;
+#else /* OPT_IVAS_FILTER_ROM */
hs->p_filter_sf = (Word16) 15391; // Q14
hs->p_filter = LDQMF_40_fx;
+#endif /* OPT_IVAS_FILTER_ROM */
hs->scale = LDQMF_40_SCALE_FX_Q8;
}
BREAK;
@@ -1859,8 +2367,12 @@ static void cldfb_init_proto_and_twiddles(
hs->rot_vec_ana_delay_im_fx = NULL;
hs->rot_vec_syn_delay_re_fx = NULL;
hs->rot_vec_syn_delay_im_fx = NULL;
+#ifdef OPT_IVAS_FILTER_ROM
+ hs->p_filter_32 = CLDFB80_60_fx;
+#else /* OPT_IVAS_FILTER_ROM */
hs->p_filter_sf = (Word16) 17051; // Q14
hs->p_filter = CLDFB80_60_fx;
+#endif /* OPT_IVAS_FILTER_ROM */
hs->scale = CLDFB80_60_SCALE_FX_Q8;
}
ELSE IF( EQ_32( hs->prototype, CLDFB_PROTOTYPE_5_00MS ) )
@@ -1871,8 +2383,12 @@ static void cldfb_init_proto_and_twiddles(
hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx;
hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx;
hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx;
+#ifdef OPT_IVAS_FILTER_ROM
+ hs->p_filter_32 = LDQMF_60_fx;
+#else /* OPT_IVAS_FILTER_ROM */
hs->p_filter_sf = (Word16) 15391; // Q14
hs->p_filter = LDQMF_60_fx;
+#endif /* OPT_IVAS_FILTER_ROM */
hs->scale = LDQMF_60_SCALE_FX_Q8;
}
BREAK;
@@ -1919,11 +2435,15 @@ static void cldfb_init_proto_and_twiddles_enc_fx(
hs->rot_vec_ana_delay_im_fx = NULL;
hs->rot_vec_syn_delay_re_fx = NULL;
hs->rot_vec_syn_delay_im_fx = NULL;
- hs->p_filter_sf = (Word16) 17036; // Q14
hs->scale = cldfb_scale_2_5ms[0];
move16();
move16();
+#ifdef OPT_IVAS_FILTER_ROM
+ hs->p_filter_32 = CLDFB80_10_fx;
+#else /* OPT_IVAS_FILTER_ROM */
+ hs->p_filter_sf = (Word16) 17036; // Q14
hs->p_filter = CLDFB80_10_fx;
+#endif /* OPT_IVAS_FILTER_ROM */
}
ELSE IF( EQ_16( hs->prototype, CLDFB_PROTOTYPE_5_00MS ) )
{
@@ -1935,8 +2455,12 @@ static void cldfb_init_proto_and_twiddles_enc_fx(
hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx;
hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx;
hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx;
+#ifdef OPT_IVAS_FILTER_ROM
+ hs->p_filter_32 = LDQMF_10_fx;
+#else /* OPT_IVAS_FILTER_ROM */
hs->p_filter_sf = (Word16) 15388; // Q14
hs->p_filter = LDQMF_10_fx;
+#endif /* OPT_IVAS_FILTER_ROM */
hs->scale = cldfb_scale_5_0ms[0];
move16();
move16();
@@ -1964,8 +2488,12 @@ static void cldfb_init_proto_and_twiddles_enc_fx(
hs->rot_vec_ana_delay_im_fx = NULL;
hs->rot_vec_syn_delay_re_fx = NULL;
hs->rot_vec_syn_delay_im_fx = NULL;
+#ifdef OPT_IVAS_FILTER_ROM
+ hs->p_filter_32 = CLDFB80_16_fx;
+#else /* OPT_IVAS_FILTER_ROM */
hs->p_filter_sf = (Word16) 17051; // Q14
hs->p_filter = CLDFB80_16_fx;
+#endif /* OPT_IVAS_FILTER_ROM */
hs->scale = cldfb_scale_2_5ms[1];
move16();
move16();
@@ -1980,8 +2508,12 @@ static void cldfb_init_proto_and_twiddles_enc_fx(
hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx;
hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx;
hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx;
+#ifdef OPT_IVAS_FILTER_ROM
+ hs->p_filter_32 = LDQMF_16_fx;
+#else /* OPT_IVAS_FILTER_ROM */
hs->p_filter_sf = (Word16) 15388; // Q14
hs->p_filter = LDQMF_16_fx;
+#endif /* OPT_IVAS_FILTER_ROM */
hs->scale = cldfb_scale_5_0ms[1];
move16();
move16();
@@ -2016,8 +2548,12 @@ static void cldfb_init_proto_and_twiddles_enc_fx(
hs->rot_vec_ana_delay_im_fx = NULL;
hs->rot_vec_syn_delay_re_fx = NULL;
hs->rot_vec_syn_delay_im_fx = NULL;
+#ifdef OPT_IVAS_FILTER_ROM
+ hs->p_filter_32 = CLDFB80_20_fx;
+#else /* OPT_IVAS_FILTER_ROM */
hs->p_filter_sf = (Word16) 17050; // Q14
hs->p_filter = CLDFB80_20_fx;
+#endif /* OPT_IVAS_FILTER_ROM */
hs->scale = cldfb_scale_2_5ms[2];
move16();
move16();
@@ -2032,8 +2568,12 @@ static void cldfb_init_proto_and_twiddles_enc_fx(
hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx;
hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx;
hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx;
+#ifdef OPT_IVAS_FILTER_ROM
+ hs->p_filter_32 = LDQMF_20_fx;
+#else /* OPT_IVAS_FILTER_ROM */
hs->p_filter_sf = (Word16) 15390; // Q14
hs->p_filter = LDQMF_20_fx;
+#endif /* OPT_IVAS_FILTER_ROM */
hs->scale = cldfb_scale_5_0ms[2];
move16();
move16();
@@ -2067,9 +2607,13 @@ static void cldfb_init_proto_and_twiddles_enc_fx(
hs->rot_vec_ana_delay_im_fx = NULL;
hs->rot_vec_syn_delay_re_fx = NULL;
hs->rot_vec_syn_delay_im_fx = NULL;
- hs->p_filter_sf = (Word16) 17051; // Q14
hs->scale = cldfb_scale_2_5ms[6];
+#ifdef OPT_IVAS_FILTER_ROM
+ hs->p_filter_32 = CLDFB80_30_fx;
+#else /* OPT_IVAS_FILTER_ROM */
hs->p_filter = CLDFB80_30_fx;
+ hs->p_filter_sf = (Word16) 17051; // Q14
+#endif /* OPT_IVAS_FILTER_ROM */
}
ELSE IF( EQ_16( hs->prototype, CLDFB_PROTOTYPE_5_00MS ) )
{
@@ -2081,9 +2625,13 @@ static void cldfb_init_proto_and_twiddles_enc_fx(
hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx;
hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx;
hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx;
- hs->p_filter_sf = (Word16) 15388; // Q14
hs->scale = cldfb_scale_5_0ms[6];
+#ifdef OPT_IVAS_FILTER_ROM
+ hs->p_filter_32 = LDQMF_30_fx;
+#else /* OPT_IVAS_FILTER_ROM */
hs->p_filter = LDQMF_30_fx;
+ hs->p_filter_sf = (Word16) 15388; // Q14
+#endif /* OPT_IVAS_FILTER_ROM */
move16();
move16();
}
@@ -2110,8 +2658,12 @@ static void cldfb_init_proto_and_twiddles_enc_fx(
hs->rot_vec_ana_delay_im_fx = NULL;
hs->rot_vec_syn_delay_re_fx = NULL;
hs->rot_vec_syn_delay_im_fx = NULL;
+#ifdef OPT_IVAS_FILTER_ROM
+ hs->p_filter_32 = CLDFB80_32_fx;
+#else /* OPT_IVAS_FILTER_ROM */
hs->p_filter_sf = (Word16) 17050; // Q14
hs->p_filter = CLDFB80_32_fx;
+#endif /* OPT_IVAS_FILTER_ROM */
hs->scale = cldfb_scale_2_5ms[3];
move16();
move16();
@@ -2126,9 +2678,13 @@ static void cldfb_init_proto_and_twiddles_enc_fx(
hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx;
hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx;
hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx;
- hs->p_filter_sf = (Word16) 15392; // Q14
hs->scale = cldfb_scale_5_0ms[3];
+#ifdef OPT_IVAS_FILTER_ROM
+ hs->p_filter_32 = LDQMF_32_fx;
+#else /* OPT_IVAS_FILTER_ROM */
hs->p_filter = LDQMF_32_fx;
+ hs->p_filter_sf = (Word16) 15392; // Q14
+#endif /* OPT_IVAS_FILTER_ROM */
move16();
move16();
}
@@ -2161,9 +2717,13 @@ static void cldfb_init_proto_and_twiddles_enc_fx(
hs->rot_vec_ana_delay_im_fx = NULL;
hs->rot_vec_syn_delay_re_fx = NULL;
hs->rot_vec_syn_delay_im_fx = NULL;
- hs->p_filter_sf = (Word16) 17051; // Q14
hs->scale = cldfb_scale_2_5ms[4];
+#ifdef OPT_IVAS_FILTER_ROM
+ hs->p_filter_32 = CLDFB80_40_fx;
+#else /* OPT_IVAS_FILTER_ROM */
hs->p_filter = CLDFB80_40_fx;
+ hs->p_filter_sf = (Word16) 17051; // Q14
+#endif /* OPT_IVAS_FILTER_ROM */
move16();
move16();
}
@@ -2177,8 +2737,12 @@ static void cldfb_init_proto_and_twiddles_enc_fx(
hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx;
hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx;
hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx;
+#ifdef OPT_IVAS_FILTER_ROM
+ hs->p_filter_32 = LDQMF_40_fx;
+#else /* OPT_IVAS_FILTER_ROM */
hs->p_filter_sf = (Word16) 15391; // Q14
hs->p_filter = LDQMF_40_fx;
+#endif /* OPT_IVAS_FILTER_ROM */
hs->scale = cldfb_scale_5_0ms[4];
move16();
move16();
@@ -2212,8 +2776,12 @@ static void cldfb_init_proto_and_twiddles_enc_fx(
hs->rot_vec_ana_delay_im_fx = NULL;
hs->rot_vec_syn_delay_re_fx = NULL;
hs->rot_vec_syn_delay_im_fx = NULL;
+#ifdef OPT_IVAS_FILTER_ROM
+ hs->p_filter_32 = CLDFB80_60_fx;
+#else /* OPT_IVAS_FILTER_ROM */
hs->p_filter_sf = (Word16) 17051; // Q14
hs->p_filter = CLDFB80_60_fx;
+#endif /* OPT_IVAS_FILTER_ROM */
hs->scale = cldfb_scale_2_5ms[5];
move16();
move16();
@@ -2228,8 +2796,12 @@ static void cldfb_init_proto_and_twiddles_enc_fx(
hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx;
hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx;
hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx;
+#ifdef OPT_IVAS_FILTER_ROM
+ hs->p_filter_32 = LDQMF_60_fx;
+#else /* OPT_IVAS_FILTER_ROM */
hs->p_filter_sf = (Word16) 15391; // Q14
hs->p_filter = LDQMF_60_fx;
+#endif /* OPT_IVAS_FILTER_ROM */
hs->scale = cldfb_scale_5_0ms[5];
move16();
move16();
diff --git a/lib_com/cng_exc_fx.c b/lib_com/cng_exc_fx.c
index b314357adee7954c8797853f405db0296b5df6ee..e335e943511d142b8a5a164981d00825edc9bb01 100644
--- a/lib_com/cng_exc_fx.c
+++ b/lib_com/cng_exc_fx.c
@@ -598,11 +598,6 @@ void cng_params_postupd_fx(
const Word16 *const cng_Qexc_buf, /* i : Q_exc buffer Q0 */
const Word32 *const cng_brate_buf, /* i : bit rate buffer Q0 */
Word32 ho_env_circ[] /* i/o: Envelope buffer Q6 */
-#ifdef IVAS_CODE_CNG_COM
- ,
- const Word16 element_mode, /* i : Element mode */
- const Word16 bwidth /* i : Audio bandwidth */
-#endif
)
{
Word16 i, j;
@@ -662,15 +657,6 @@ void cng_params_postupd_fx(
}
Copy32( sp, env, NUM_ENV_CNG );
-#ifdef IVAS_CODE_CNG_COM
- if ( element_mode == IVAS_SCE || element_mode == IVAS_CPE_DFT )
- {
- att = 0.0f;
- apply_scale( &att, bwidth, last_active_brate, scaleTableStereo, SIZE_SCALE_TABLE_STEREO );
- att = powf( 10, att / 10.0f );
- }
- else
-#endif
{
CNG_mode = get_cng_mode( last_active_brate );
@@ -860,11 +846,6 @@ void cng_params_upd_fx(
Word16 cng_Qexc_buf[], /* i/o: Q_exc buffer Q0 */
Word32 cng_brate_buf[], /* i/o: last_active_brate buffer Q0 */
const Word32 last_active_brate /* i : Last active bit rate Q0 */
-#ifdef IVAS_CODE_CNG_COM
- ,
- const Word16 element_mode, /* i : Element mode */
- const Word16 bwidth /* i : Audio bandwidth */
-#endif
)
{
Word32 L_ener, L_tmp;
@@ -986,15 +967,6 @@ void cng_params_upd_fx(
}
Copy32( sp, env, NUM_ENV_CNG );
-#ifdef IVAS_CODE_CNG_COM
- if ( element_mode == IVAS_SCE || element_mode == IVAS_CPE_DFT )
- {
- att = 0.0f;
- apply_scale( &att, bwidth, last_active_brate, scaleTableStereo, SIZE_SCALE_TABLE_STEREO );
- att = powf( 10, att / 10.0f );
- }
- else
-#endif
{
CNG_mode = get_cng_mode( last_active_brate );
/* att = 1/pow(2,ENR_ATT_fx[CNG_mode]); */
diff --git a/lib_com/cnst.h b/lib_com/cnst.h
index ae84dbd2c9285d5219b4e7d6b48ed787bb1d3be3..17dbc31c4392fce7232ba2c2040e7ebad91abe9d 100644
--- a/lib_com/cnst.h
+++ b/lib_com/cnst.h
@@ -45,20 +45,22 @@
#define MATRIX_CONSTANT (759250113)
#define NUM_SAMPLES_960 (960)
#define NUM_SAMPLES_720 (720)
+#define NUM_SAMPLES_640 (640)
#define NUM_SAMPLES_320 (320)
#define NUM_SAMPLES_160 (160)
#define L_SUBFRAME_48k (240)
#define L_SUBFRAME_32k (180)
#define L_SUBFRAME_16k (80)
#define L_SUBFRAME_8k (40)
-#define Q31_BY_NUM_SAMPLES_960 ( 2239294 )
-#define Q31_BY_NUM_SAMPLES_720 ( 2986764 )
-#define Q31_BY_NUM_SAMPLES_320 ( 6731924 )
-#define Q31_BY_NUM_SAMPLES_160 ( 13506186 )
-#define Q31_BY_SUB_FRAME_240 ( 8985287 )
-#define Q31_BY_SUB_FRAME_180 ( 11997115 )
-#define Q31_BY_SUB_FRAME_80 ( 27183337 )
-#define Q31_BY_SUB_FRAME_40 ( 55063683 )
+#define Q31_BY_NUM_SAMPLES_960 ( 2239294 ) /* 1/959 in Q31 */
+#define Q31_BY_NUM_SAMPLES_720 ( 2986764 ) /* 1/719 in Q31 */
+#define Q31_BY_NUM_SAMPLES_640 ( 3360694 ) /* 1/639 in Q31 */
+#define Q31_BY_NUM_SAMPLES_320 ( 6731924 ) /* 1/319 in Q31 */
+#define Q31_BY_NUM_SAMPLES_160 ( 13506186 ) /* 1/159 in Q31 */
+#define Q31_BY_SUB_FRAME_240 ( 8985287 ) /* 1/239 in Q31 */
+#define Q31_BY_SUB_FRAME_180 ( 11997115 ) /* 1/179 in Q31 */
+#define Q31_BY_SUB_FRAME_80 ( 27183337 ) /* 1/79 in Q31 */
+#define Q31_BY_SUB_FRAME_40 ( 55063683 ) /* 1/39 in Q31 */
/*----------------------------------------------------------------------------------*
@@ -537,7 +539,6 @@ enum
IND_SHB_RES_GS2,
IND_SHB_RES_GS3,
IND_SHB_RES_GS4,
- IND_SHB_RES_GS5,
IND_SHB_VF,
#else
IND_SHB_VF = IND_SHB_RES_GS + 5,
@@ -760,6 +761,7 @@ enum
#define PIT_FIR_SIZE6_2 ( PIT_UP_SAMP6 * PIT_L_INTERPOL6_2 + 1 )
#define E_MIN 0.0035f /* minimum allowable energy */
#define E_MIN_Q11_FX 7 /* minimum allowable energy in Q11*/
+#define E_MIN_Q27_FX 469762 /* minimum allowable energy in Q27*/
#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 */
diff --git a/lib_com/codec_tcx_common.c b/lib_com/codec_tcx_common_fx.c
similarity index 81%
rename from lib_com/codec_tcx_common.c
rename to lib_com/codec_tcx_common_fx.c
index 1ebc2829c15493506950bd608ca397162826847c..52c7d0614ec4d935e71187ad9967a14eea1b6017 100644
--- a/lib_com/codec_tcx_common.c
+++ b/lib_com/codec_tcx_common_fx.c
@@ -469,140 +469,6 @@ void tcxInvertWindowGrouping(
}
}
-#ifdef IVAS_CODE_TCX_COM
-
-/*-------------------------------------------------------------------*
- * tcx5SpectrumInterleaving()
- *
- *
- *-------------------------------------------------------------------*/
-
-void tcx5SpectrumInterleaving(
- const int16_t tcx5Size,
- float *spectrum )
-{
- int16_t i;
- float interleaveBuf[N_TCX10_MAX];
-
- set_f( interleaveBuf, 0.0f, N_TCX10_MAX );
-
- /* group sub-windows: interleave bins according to their frequencies */
- for ( i = 0; i < tcx5Size; i++ )
- {
- interleaveBuf[2 * i] = spectrum[i];
- interleaveBuf[2 * i + 1] = spectrum[tcx5Size + i];
- }
-
- mvr2r( interleaveBuf, spectrum, 2 * tcx5Size );
-
- return;
-}
-
-
-/*-------------------------------------------------------------------*
- * tcx5SpectrumDeinterleaving()
- *
- *
- *-------------------------------------------------------------------*/
-
-void tcx5SpectrumDeinterleaving(
- const int16_t tcx5Size,
- float *spectrum )
-{
- int16_t i;
- float interleaveBuf[N_TCX10_MAX];
-
- set_f( interleaveBuf, 0.0f, N_TCX10_MAX );
-
- /* ungroup sub-windows: interleave bins according to their frequencies */
- for ( i = 0; i < tcx5Size; i++ )
- {
- interleaveBuf[i] = spectrum[2 * i];
- interleaveBuf[tcx5Size + i] = spectrum[2 * i + 1];
- }
-
- mvr2r( interleaveBuf, spectrum, 2 * tcx5Size );
-
- return;
-}
-
-
-/*-------------------------------------------------------------------*
- * tcx5TnsGrouping()
- *
- *
- *-------------------------------------------------------------------*/
-
-void tcx5TnsGrouping(
- const int16_t L_frame, /* i : frame length (TCX5) */
- const int16_t L_spec, /* i : coded spec length (TCX5, derived from filter borders*/
- float *spectrum )
-{
- /* rearrange LF sub-window lines prior to TNS synthesis filtering */
- if ( L_spec < L_frame )
- {
- mvr2r( spectrum + 8, spectrum + 16, L_spec - 8 );
- mvr2r( spectrum + L_frame, spectrum + 8, 8 );
- mvr2r( spectrum + L_frame + 8, spectrum + L_spec + 8, L_spec - 8 );
- }
- else
- {
- float buff[8]; /* Buffer for the rearrangement of LF TCX5 */
- mvr2r( spectrum + L_spec, buff, 8 );
- mvr2r( spectrum + 8, spectrum + 16, L_spec - 8 );
- mvr2r( buff, spectrum + 8, 8 );
- }
-
- return;
-}
-
-
-/*-------------------------------------------------------------------*
- * tcx5TnsUngrouping()
- *
- *
- *-------------------------------------------------------------------*/
-
-void tcx5TnsUngrouping(
- const int16_t L_frame, /* i : frame length (TCX5) */
- const int16_t L_spec, /* i : coded spec length (TCX5, derived from filter borders*/
- float *spectrum,
- const int16_t enc_dec /* i : 0: encoder, else decoder */
-)
-{
- /* undo rearrangement of LF sub-window lines prior to TNS analysis */
- if ( L_spec < L_frame )
- {
- mvr2r( spectrum + L_spec + 8, spectrum + L_frame + 8, L_spec - 8 );
- mvr2r( spectrum + 8, spectrum + L_frame, 8 );
- mvr2r( spectrum + 16, spectrum + 8, L_spec - 8 );
- set_zero( spectrum + L_spec, L_frame - L_spec );
- set_zero( spectrum + L_frame + L_spec, L_frame - L_spec );
- }
- else
- {
- float buff[8]; /* Buffer for the rearrangement of LF TCX5 */
-
- mvr2r( spectrum + 8, buff, 8 );
-
- if ( enc_dec == ENC )
- {
- mvr2r( spectrum + 16, spectrum + 8, L_frame - 8 );
- mvr2r( buff, spectrum + L_frame, 8 );
- }
- else
- {
- mvr2r( spectrum + 16, spectrum + 8, L_spec - 8 );
- mvr2r( buff, spectrum + L_spec, 8 );
- }
- }
-
- return;
-}
-
-#endif
-
-
/*-------------------------------------------------------------------*
* tcx5SpectrumInterleaving()
*
diff --git a/lib_com/core_com_config.c b/lib_com/core_com_config_fx.c
similarity index 96%
rename from lib_com/core_com_config.c
rename to lib_com/core_com_config_fx.c
index f0ee8efd8d12c038c78487a8f39ba71dc21a3b9c..152870be74c567dab70a0d331ddc6401f123d394 100644
--- a/lib_com/core_com_config.c
+++ b/lib_com/core_com_config_fx.c
@@ -246,67 +246,18 @@ Word16 getTcxonly_ivas_fx(
}
Word16 getTcxonly(
-#ifdef IVAS_CODE_SWITCHING
- const Word16 element_mode, /* i : IVAS element mode */
-#endif
const Word32 total_brate /* i : total bitrate */
-#ifdef IVAS_CODE_SWITCHING
- ,
- const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0)*/
- const int16_t is_ism_format /* i : flag indicating ISM format */
-#endif
)
{
Word16 tcxonly;
tcxonly = 0;
move16();
-#ifdef IVAS_CODE_SWITCHING
- SWITCH( element_mode )
+ if ( GT_32( total_brate, 32000 ) )
{
- case EVS_MONO:
-#endif
- if ( GT_32( total_brate, 32000 ) )
- {
- tcxonly = 1;
- move16();
- }
-#ifdef IVAS_CODE_SWITCHING
- break;
- case IVAS_SCE:
- if ( is_ism_format )
- {
- if ( total_brate > MAX_ACELP_BRATE_ISM )
- {
- tcxonly = 1;
- }
- }
- else
- {
- if ( total_brate > MAX_ACELP_BRATE )
- {
- tcxonly = 1;
- }
- }
- break;
-
- case IVAS_CPE_DFT:
- case IVAS_CPE_TD:
- if ( total_brate > MAX_ACELP_BRATE )
- {
- tcxonly = 1;
- }
- break;
- case IVAS_CPE_MDCT:
- if ( total_brate >= ( MCT_flag ? IVAS_32k : IVAS_48k ) )
- {
- tcxonly = 1;
- }
- break;
-#endif
-#ifdef IVAS_CODE_SWITCHING
+ tcxonly = 1;
+ move16();
}
-#endif
return tcxonly; /*Q0*/
}
@@ -541,12 +492,12 @@ Word16 sr2fscale_fx(
return extract_l( Mpy_32_16_1( sr_core, FSCALE_DENOM_BY_12800_Q15 ) ); /*Q0*/
}
-int16_t sr2fscale(
- const int32_t sr_core /* i : internal sampling rate */
+Word16 sr2fscale(
+ const Word32 sr_core /* i : internal sampling rate */
)
{
- return (int16_t) ( ( FSCALE_DENOM * sr_core ) / 12800 );
+ return (Word16) ( ( FSCALE_DENOM * sr_core ) / 12800 );
}
Word32 getCoreSamplerateMode2(
diff --git a/lib_com/deemph.c b/lib_com/deemph_fx.c
similarity index 100%
rename from lib_com/deemph.c
rename to lib_com/deemph_fx.c
diff --git a/lib_com/delay_comp.c b/lib_com/delay_comp_fx.c
similarity index 100%
rename from lib_com/delay_comp.c
rename to lib_com/delay_comp_fx.c
diff --git a/lib_com/enhancer_fx.c b/lib_com/enhancer_fx.c
index 7df474a5d6ab88a9f6ca0ae8f706f590ae0affe7..620904d08e6f6a299b6ae0adcb5e1f0ceeea078c 100644
--- a/lib_com/enhancer_fx.c
+++ b/lib_com/enhancer_fx.c
@@ -299,10 +299,11 @@ void enhancer_fx(
/* RETURN ARGUMENTS : */
/* _ None */
/*======================================================================================*/
+
void enhancer_ivas_fx(
- const Word16 codec_mode, /* i : flag indicating Codec Mode */
- const Word32 core_brate, /* i : decoder bitrate */
- const Word16 cbk_index, /* i : */
+ const Word16 codec_mode, /* i : flag indicating Codec Mode */
+ const Word32 core_brate, /* i : decoder bitrate */
+ const Word16 cbk_index,
const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
const Word16 coder_type, /* i : coder type */
const Word16 i_subfr, /* i : subframe number */
@@ -322,9 +323,11 @@ void enhancer_ivas_fx(
Word16 tmp, fac, *pt_exc2;
Word16 i;
Word32 L_tmp;
+ Word32 L_tmp1, L_tmp2;
Word16 gain_code_hi;
Word16 pit_sharp, tmp16;
Word16 excp[L_SUBFR], sc;
+ Word64 w_temp;
pit_sharp = gain_pit;
@@ -400,215 +403,6 @@ void enhancer_ivas_fx(
phase_dispersion_fx( norm_gain_code, gain_pit, code, i, dm_fx );
- /*------------------------------------------------------------
- * noise enhancer
- *
- * - Enhance excitation on noise. (modify gain of code)
- * If signal is noisy and LPC filter is stable, move gain
- * of code 1.5 dB toward gain of code threshold.
- * This decreases by 3 dB noise energy variation.
- *-----------------------------------------------------------*/
-
- /* tmp = 0.5f * (1.0f - voice_fac) */
- tmp = msu_r_sat( 0x40000000 /*0.5.Q31*/, voice_fac, 16384 /*0.5.Q14*/ ); /*Q15 */ /* 1=unvoiced, 0=voiced */
- /* fac = stab_fac * tmp */
- fac = mult( stab_fac, tmp ); /*Q15*/
-
- IF( LT_32( norm_gain_code, *gc_threshold ) )
- {
- L_tmp = Madd_32_16( norm_gain_code, norm_gain_code, 6226 /*0.19.Q15*/ ); /*Q16 */
- L_tmp = L_min( L_tmp, *gc_threshold ); /*Q16 */
- }
- ELSE
- {
- L_tmp = Mult_32_16( norm_gain_code, 27536 /*0.84.Q15*/ ); /*Q16 */
- L_tmp = L_max( L_tmp, *gc_threshold ); /*Q16 */
- }
- *gc_threshold = L_tmp;
- move32(); /*Q16 */
-
- /* gain_code = (fac * tmp) + (1.0 - fac) * gain_code ==> fac * (tmp - gain_code) + gain_code */
- L_tmp = L_sub( L_tmp, norm_gain_code ); /*Q16 */
- norm_gain_code = Madd_32_16( norm_gain_code, L_tmp, fac ); /*Q16 */
-
- /* gain_code *= gain_inov - Inverse the normalization */
- L_tmp = Mult_32_16( norm_gain_code, gain_inov ); /*Q13*/ /* gain_inov in Q12 */
-
- sc = 6;
- move16();
-
- gain_code_hi = round_fx( L_shl( L_tmp, add( Q_exc, 3 ) ) ); /* in Q_exc */
-
- /*------------------------------------------------------------*
- * pitch enhancer
- *
- * - Enhance excitation on voiced. (HP filtering of code)
- * On voiced signal, filtering of code by a smooth fir HP
- * filter to decrease energy of code at low frequency.
- *------------------------------------------------------------*/
- test();
- IF( !Opt_AMR_WB && EQ_16( coder_type, UNVOICED ) )
- {
- /* Copy(code, exc2, L_SUBFR) */
- FOR( i = 0; i < L_SUBFR; i++ )
- {
- pt_exc2[i] = round_fx( L_shl( L_mult( gain_code_hi, code[i] ), sc ) ); /*Q0 */ /* code in Q12 (Q9 for encoder) */
- move16();
- }
- }
- ELSE
- {
- test();
- test();
- IF( Opt_AMR_WB && ( EQ_32( core_brate, ACELP_8k85 ) || EQ_32( core_brate, ACELP_6k60 ) ) )
- {
- pit_sharp = shl_sat( gain_pit, 1 ); /* saturation can occur here Q14 -> Q15 */
- /* saturation takes care of "if (pit_sharp > 1.0) { pit_sharp=1.0; }" */
- IF( GT_16( pit_sharp, 16384 /*0.5.Q15*/ ) )
- {
- tmp16 = mult( pit_sharp, 8192 /*0.25.Q15*/ );
- FOR( i = 0; i < L_SUBFR; i++ )
- {
- /* excp[i] = pt_exc2[i] * pit_sharp * 0.25 */
- excp[i] = mult_r( pt_exc2[i], tmp16 );
- move16();
- }
- }
- }
-
- IF( EQ_16( L_frame, L_FRAME16k ) )
- {
- /* tmp = 0.150 * (1.0 + voice_fac) */
- /* 0.30=voiced, 0=unvoiced */
- tmp = mac_r( 0x13333333L /*0.150.Q31*/, voice_fac, 4915 /*0.150.Q15*/ ); /*Q15 */
- }
- ELSE
- {
- /* tmp = 0.125 * (1.0 + voice_fac) */
- /* 0.25=voiced, 0=unvoiced */
- tmp = mac_r( 0x10000000L /*0.125.Q31*/, voice_fac, 4096 ); /*Q15 */
- }
-
- /*-----------------------------------------------------------------
- * Do a simple noncasual "sharpening": effectively an FIR
- * filter with coefs [-tmp 1.0 -tmp] where tmp=0...0.25.
- * This is applied to code and add_fxed to exc2
- *-----------------------------------------------------------------*/
- /* 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 */
- 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(); /* in Q_exc */
-
- 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 );
- 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_sat( L_tmp, -32768, pt_exc2[i] );
- move16(); /* in Q_exc */
- }
-
- /* 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 );
- pt_exc2[L_SUBFR - 1] = msu_r( L_tmp, -32768, pt_exc2[L_SUBFR - 1] );
- move16(); /* in Q_exc */
- test();
- test();
- IF( Opt_AMR_WB && ( EQ_32( core_brate, ACELP_8k85 ) || EQ_32( core_brate, ACELP_6k60 ) ) )
- {
- IF( GT_16( pit_sharp, 16384 /*0.5.Q14*/ ) )
- {
- FOR( i = 0; i < L_SUBFR; i++ )
- {
- /* excp[i] += pt_exc2[i] */
- excp[i] = add( excp[i], pt_exc2[i] );
- move16();
- }
- agc2_fx( pt_exc2, excp, L_SUBFR );
- Copy( excp, pt_exc2, L_SUBFR );
- }
- }
- }
-}
-
-void enhancer_ivas_fx2(
- const Word32 core_brate, /* i : decoder bitrate */
- const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
- const Word16 coder_type, /* i : coder type */
- const Word16 i_subfr, /* i : subframe number */
- const Word16 L_frame, /* i : frame size */
- const Word16 voice_fac, /* i : subframe voicing estimation Q15 */
- const Word16 stab_fac, /* i : LP filter stablility measure Q15 */
- Word32 norm_gain_code, /* i : normalised innovative cb. gain Q16 */
- const Word16 gain_inov, /* i : gain of the unscaled innovation Q12 */
- Word32 *gc_threshold, /* i/o: gain code threshold Q16 */
- Word16 *code, /* i/o: innovation Q12 */
- Word16 *exc2, /* i/o: adapt. excitation/total exc. Q_exc*/
- const Word16 gain_pit, /* i : quantized pitch gain Q14 */
- struct dispMem_fx *dm_fx, /* i/o: phase dispersion algorithm memory */
- const Word16 Q_exc /* i : Q of the excitation */
-)
-{
- Word16 tmp, fac, *pt_exc2;
- Word16 i;
- Word32 L_tmp;
- Word32 L_tmp1, L_tmp2;
- Word16 gain_code_hi;
- Word16 pit_sharp, tmp16;
- Word16 excp[L_SUBFR], sc;
- Word64 w_temp;
-
-
- pit_sharp = gain_pit;
- move16(); /* to remove gcc warning */
- pt_exc2 = exc2 + i_subfr;
-
- /*------------------------------------------------------------*
- * Phase dispersion to enhance noise at low bit rate
- *------------------------------------------------------------*/
-
- i = 2;
- move16(); /* no dispersion */
- IF( Opt_AMR_WB )
- {
- IF( LE_32( core_brate, ACELP_6k60 ) )
- {
- i = 0;
- move16(); /* high dispersion */
- }
- ELSE IF( LE_32( core_brate, ACELP_8k85 ) )
- {
- i = 1;
- move16(); /* low dispersion */
- }
- }
- ELSE IF( NE_16( coder_type, UNVOICED ) )
-
- {
- test();
- test();
- test();
- test();
- IF( LE_32( core_brate, ACELP_7k20 ) )
- {
- i = 0;
- move16(); /* high dispersion */
- }
- ELSE IF( ( EQ_16( coder_type, GENERIC ) || EQ_16( coder_type, TRANSITION ) || EQ_16( coder_type, AUDIO ) || coder_type == INACTIVE ) && LE_32( core_brate, ACELP_9k60 ) )
- {
- i = 1;
- move16(); /* low dispersion */
- }
- }
-
- phase_dispersion_fx( norm_gain_code, gain_pit, code, i, dm_fx );
-
/*------------------------------------------------------------
* noise enhancer
*
@@ -656,7 +450,8 @@ void enhancer_ivas_fx2(
* filter to decrease energy of code at low frequency.
*------------------------------------------------------------*/
test();
- IF( !Opt_AMR_WB && EQ_16( coder_type, UNVOICED ) )
+ test();
+ IF( !Opt_AMR_WB && EQ_16( codec_mode, MODE1 ) && EQ_16( coder_type, UNVOICED ) )
{
/* Copy(code, exc2, L_SUBFR) */
FOR( i = 0; i < L_SUBFR; i++ )
diff --git a/lib_com/enr_1_az.c b/lib_com/enr_1_az_fx.c
similarity index 100%
rename from lib_com/enr_1_az.c
rename to lib_com/enr_1_az_fx.c
diff --git a/lib_com/env_adj.c b/lib_com/env_adj_fx.c
similarity index 100%
rename from lib_com/env_adj.c
rename to lib_com/env_adj_fx.c
diff --git a/lib_com/env_stab.c b/lib_com/env_stab_fx.c
similarity index 100%
rename from lib_com/env_stab.c
rename to lib_com/env_stab_fx.c
diff --git a/lib_com/env_stab_trans.c b/lib_com/env_stab_trans_fx.c
similarity index 100%
rename from lib_com/env_stab_trans.c
rename to lib_com/env_stab_trans_fx.c
diff --git a/lib_com/fd_cng_com_fx.c b/lib_com/fd_cng_com_fx.c
index 78809ed2c6a0dd5a4ca9ba595896388b03106c75..7cc536822c4a22bee728319810e48db7dc5dea76 100644
--- a/lib_com/fd_cng_com_fx.c
+++ b/lib_com/fd_cng_com_fx.c
@@ -120,6 +120,8 @@ void ivas_initFdCngCom_fx( HANDLE_FD_CNG_COM hFdCngCom, Word16 scale )
move16();
hFdCngCom->CngBitrate = -1;
move16();
+ hFdCngCom->olapBufferSynth_exp = 0;
+ move16();
/* Initialize noise estimation algorithm */
set32_fx( hFdCngCom->periodog, 0, PERIODOGLEN );
@@ -481,6 +483,54 @@ void expand_range(
move16();
}
+void expand_range_fx(
+ Word32 *in, // Q25
+ Word32 *out, // exp:out_exp
+ Word16 *out_exp,
+ const Word16 len )
+{
+ Word16 i, tmp_e;
+ Word32 maxVal, tmp32;
+ Word16 maxOutExp;
+
+ const Word32 low_lim = 726940; /* 0.0003385080526823181f in Q31 */
+ move32();
+
+ /* Find max possible output exponent. */
+ maxVal = 0;
+ move32();
+ FOR( i = 0; i < len; i++ )
+ {
+ maxVal = L_max( maxVal, in[i] );
+ }
+ tmp32 = BASOP_util_Pow2( maxVal, Q31 - Q25, &tmp_e );
+ maxOutExp = tmp_e;
+ move16();
+
+ /* out = (2^(in) - 1) */
+ FOR( i = 0; i < len; i++ )
+ {
+ tmp32 = BASOP_util_Pow2( in[i], Q31 - Q25, &tmp_e ); // 2^x
+ tmp32 = L_sub( tmp32, L_shl( 1, sub( 31, tmp_e ) ) ); // 2^x - 1
+ tmp32 = L_shr( tmp32, sub( maxOutExp, tmp_e ) ); // make exp same as maxExpOut
+
+ out[i] = tmp32;
+ move32();
+
+ Word32 tmp_low_lim = L_shr( low_lim, maxOutExp );
+ if ( LT_32( out[i], tmp_low_lim ) )
+ {
+ out[i] = tmp_low_lim;
+ move32();
+ }
+ }
+
+ *out_exp = maxOutExp;
+ move16();
+
+ return;
+}
+
/*-------------------------------------------------------------------
* expand_range_var_e()
*
@@ -1109,12 +1159,6 @@ void minimum_statistics(
move16();
}
}
-#ifdef IVAS_CODE_CNG_COM
- if ( enc_dec == DEC && element_mode == IVAS_CPE_TD )
- {
- v_multc( msNoiseEst, 1.4125f, msNoiseEst, NPART_SHAPING );
- }
-#endif
/* Collect buffers */
Copy( msPeriodog, msPeriodogBuf + len * ( *msPeriodogBufPtr ), len );
@@ -1149,10 +1193,10 @@ void minimum_statistics(
void minimum_statistics_fx(
Word16 len, /* i : Total number of partitions (CLDFB or FFT) */
Word16 lenFFT, /* i : Number of FFT partitions */
- Word16 *psize, /* i : Partition sizes, fractional */
+ Word16 *psize, /* i : Partition sizes, fractional Q9*/
Word16 *msPeriodog, /* i : Periodogram (energies) */
- Word16 *msNoiseFloor, /* i/o: Noise floors (energies) */
- Word16 *msNoiseEst, /* i/o: Noise estimates (energies) */
+ Word32 *msNoiseFloor, /* i/o: Noise floors (energies) Q25*/
+ Word32 *msNoiseEst, /* i/o: Noise estimates (energies) Q25*/
Word32 *msAlpha, /* i/o: Forgetting factors */
Word16 *msPsd, /* i/o: Power Spectral Density (smoothed periodogram => energies) */
Word16 *msPsdFirstMoment, /* i/o: PSD statistics of 1st order (energy means) */
@@ -1226,10 +1270,10 @@ void minimum_statistics_fx(
/* No minimum statistics at initialization */
IF( LT_16( hFdCngCom->msFrCnt_init_counter, hFdCngCom->msFrCnt_init_thresh ) )
{
- Copy( msPeriodog, msPsd, len ); /* 6Q9 */
- Copy( msPeriodog, msNoiseFloor, len ); /* 6Q9 */
- Copy( msPeriodog, msNoiseEst, len ); /* 6Q9 */
- Copy( msPeriodog, msPsdFirstMoment, len ); /* 6Q9 */
+ Copy( msPeriodog, msPsd, len ); /* 6Q9 */
+ Copy_Scale_sig_16_32_no_sat( msPeriodog, msNoiseFloor, len, Q16 ); /* Q25 */
+ Copy_Scale_sig_16_32_no_sat( msPeriodog, msNoiseEst, len, Q16 ); /* Q25 */
+ Copy( msPeriodog, msPsdFirstMoment, len ); /* 6Q9 */
set32_fx( msPsdSecondMoment, 0l /*0.0 Q31*/, len );
msPeriodogSum[0] = dotp_s_fx( msPeriodog, psize, lenFFT, CNG_HS );
@@ -1339,7 +1383,16 @@ void minimum_statistics_fx(
/* Compute SNR */
/* msPeriodogSum[cnt] with format 16Q15 */
- snr = dotp_s_fx( msNoiseFloor + start, psize + start, current_len, CNG_HS );
+ Word16 msNoiseFloor16tmp[NPART_SHAPING];
+ IF( enc_dec == ENC )
+ {
+ Copy_Scale_sig32_16( msNoiseFloor, msNoiseFloor16tmp, NPART, 0 );
+ }
+ ELSE
+ {
+ Copy_Scale_sig32_16( msNoiseFloor, msNoiseFloor16tmp, NPART_SHAPING, 0 );
+ }
+ snr = dotp_s_fx( &msNoiseFloor16tmp[start], psize + start, current_len, CNG_HS );
IF( GT_32( L_shr( Mpy_32_16_1( msPsdSum[cnt], 18431 /*0.56246299817 Q15*/ ), 13 ), snr ) )
{
@@ -1370,16 +1423,16 @@ void minimum_statistics_fx(
/* calculate scalar2 with normalized msNoiseFloor[j], exponent -2*s1 */
s1 = WORD16_BITS - 1;
move16();
- if ( msNoiseFloor[j] != 0 )
+ if ( msNoiseFloor16tmp[j] != 0 )
{
- s1 = norm_s( msNoiseFloor[j] );
+ s1 = norm_s( msNoiseFloor16tmp[j] );
}
- msNoiseFloor16 = shl( msNoiseFloor[j], s1 );
+ msNoiseFloor16 = shl( msNoiseFloor16tmp[j], s1 );
scalar2 = L_mult( msNoiseFloor16, msNoiseFloor16 );
/* calculate difference, both elements in 6Q9 format, use absolute value
to avoid -1.0 x -1.0 multiplications later */
- scalar316 = abs_s( sub( msPsd[j], msNoiseFloor[j] ) );
+ scalar316 = abs_s( sub( msPsd[j], msNoiseFloor16tmp[j] ) );
s2 = WORD16_BITS - 1;
move16();
@@ -1479,7 +1532,7 @@ void minimum_statistics_fx(
IF( msNoiseFloor[j] != 0 /*0.0 Q15*/ )
{
- tmp = L_mult( msNoiseFloor[j], msNoiseFloor[j] );
+ tmp = Mpy_32_32( msNoiseFloor[j], msNoiseFloor[j] );
tmp16 = BASOP_Util_Divide3232_uu_1616_Scale( msPsdSecondMoment[j], tmp, &s );
/* consider factor of 2 */
s = s_min( s_max( sub( s, 1 ), -( WORD16_BITS - 1 ) ), ( WORD16_BITS - 1 ) );
@@ -1590,7 +1643,7 @@ void minimum_statistics_fx(
}
}
/* Get the current noise floor */
- Copy_Scale_sig_32_16( msCurrentMinOut, msNoiseFloor, len, -16 );
+ Copy32( msCurrentMinOut, msNoiseFloor, len );
}
ELSE /* sub window complete */
{
@@ -1648,7 +1701,7 @@ void minimum_statistics_fx(
set32_fx( msCurrentMin, 2147483647l /*1.0 Q31*/, len );
/* Get the current noise floor */
- Copy_Scale_sig_32_16( msCurrentMinOut, msNoiseFloor, len, -16 );
+ Copy32( msCurrentMinOut, msNoiseFloor, len );
}
}
@@ -1705,18 +1758,19 @@ void minimum_statistics_fx(
hFdCngCom->msFrCnt = add( hFdCngCom->msFrCnt, 1 );
move16();
}
-
+ Word64 tmp64;
/* Smooth noise estimate during CNG phases */
FOR( j = 0; j < len; j++ )
{
- msNoiseEst[j] = round_fx( L_mac( L_mult( 31130 /*0.95 Q15*/, msNoiseEst[j] ), 1638 /*0.05 Q15*/, msNoiseFloor[j] ) );
- move16();
+ tmp64 = W_add( W_mult_32_16( msNoiseEst[j], 31130 /*0.95 Q15*/ ), W_mult_32_16( msNoiseFloor[j], 1638 /*0.05 Q15*/ ) );
+ msNoiseEst[j] = W_extract_h( W_shl( tmp64, 16 ) ); // Q25
+ move32();
}
}
IF( EQ_16( enc_dec, DEC ) && EQ_16( element_mode, IVAS_CPE_TD ) )
{
// v_multc(msNoiseEst, 1.4125f, msNoiseEst, NPART_SHAPING);
- v_multc_att( msNoiseEst, 23142, msNoiseEst, NPART_SHAPING );
+ v_multc_att32( msNoiseEst, 23142, msNoiseEst, NPART_SHAPING );
}
/* Collect buffers */
Copy( msPeriodog, msPeriodogBuf + len * ( *msPeriodogBufPtr ), len );
@@ -1738,17 +1792,15 @@ void minimum_statistics_fx(
{
scalar = L_mac( scalar, msPeriodogBuf[i], 6554 /*1.0/MSBUFLEN Q15*/ );
}
- scalar16 = round_fx( scalar );
- if ( GT_16( msNoiseEst[j], scalar16 ) /*0.0 Q15*/ )
+ if ( GT_32( msNoiseEst[j], scalar ) /*0.0 Q15*/ )
{
- msNoiseEst[j] = scalar16;
- move16();
+ msNoiseEst[j] = scalar;
+ move32();
}
assert( msNoiseEst[j] >= 0 /*0.0 Q15*/ );
}
}
-
/*-------------------------------------------------------------------
* apply_scale()
*
@@ -2624,18 +2676,6 @@ void SynthesisSTFT(
move16();
}
/* Generate excitation */
-#ifdef IVAS_CODE_CNG_COM
- PME()
- if ( ( element_mode == IVAS_CPE_TD || element_mode == IVAS_CPE_DFT ) && nchan_out == 2 )
- {
- for ( i = 0; i < hFdCngCom->frameSize / 2; i++ )
- {
- buf[i + ( M + 1 )] += olapBuffer[i + hFdCngCom->frameSize / 4];
- }
- v_multc( buf, (float) ( hFdCngCom->fftlen / 2 ), buf, M + 1 + hFdCngCom->frameSize );
- }
- else
-#endif
{
FOR( i = 0; i < M + 1 + hFdCngCom->frameSize; i++ )
{
@@ -2671,9 +2711,10 @@ void SynthesisSTFT_ivas_fx(
const Word16 nchan_out /* i : number of output channels */
)
{
- Word16 i, len, scale, tmp;
+ Word16 i, len, scale, tmp, sft, exp, tmp1;
Word16 len2, len3, len4;
Word16 buf[M + 1 + L_FRAME16k];
+ Word32 L_olapBuffer[FFTLEN];
/* Perform IFFT */
@@ -2684,6 +2725,12 @@ void SynthesisSTFT_ivas_fx(
hFdCngCom->fftBuffer_exp = fftBufferExp;
move16();
+ sft = getScaleFactor32( fftBuffer, hFdCngCom->fftlen );
+ scale_sig32( fftBuffer, hFdCngCom->fftlen, sft );
+ fftBufferExp = sub( fftBufferExp, sft );
+ hFdCngCom->fftBuffer_exp = fftBufferExp;
+ move16();
+
fftBufferExp = add( fftBufferExp, hFdCngCom->fftlenShift );
/* Perform overlap-add */
@@ -2697,48 +2744,58 @@ void SynthesisSTFT_ivas_fx(
}
ELSE
{
- Copy( olapBuffer + hFdCngCom->frameSize, olapBuffer, hFdCngCom->frameSize );
+ Copy_Scale_sig_16_32_no_sat( olapBuffer + hFdCngCom->frameSize, L_olapBuffer, hFdCngCom->frameSize, add( sub( hFdCngCom->olapBufferSynth_exp, sub( 15, hFdCngCom->fftlenShift ) ), 16 ) ); /* exp: hFdCngCom->olapBufferSynth_exp -> (15 - fftlenShift) */
set16_fx( olapBuffer + hFdCngCom->frameSize, 0, hFdCngCom->frameSize );
}
len2 = shr( hFdCngCom->fftlen, 2 );
len4 = shr( hFdCngCom->fftlen, 3 );
len3 = add( len2, len4 );
len = add( hFdCngCom->frameSize, len4 );
+ tmp1 = sub( fftBufferExp, 15 );
IF( tcx_transition )
{
FOR( i = 0; i < len; i++ )
{
- olapBuffer[i] = round_fx_sat( L_shl_sat( fftBuffer[i], fftBufferExp - 15 ) ); // Q(15 - fftBufferExp)
- move16();
+ L_olapBuffer[i] = L_shl_sat( fftBuffer[i], tmp1 ); /* Q(31 - (15 - fftlenShift) ) */
+ move32();
}
}
ELSE
{
FOR( i = 0; i < len4; i++ )
{
- olapBuffer[i + 1 * len4] = add_sat( olapBuffer[i + 1 * len4], mult_r( round_fx_sat( L_shl_sat( fftBuffer[i + 1 * len4], fftBufferExp - 15 ) ), olapWin[i].v.im ) );
- move16();
- olapBuffer[i + 2 * len4] = add_sat( olapBuffer[i + 2 * len4], mult_r( round_fx_sat( L_shl_sat( fftBuffer[i + 2 * len4], fftBufferExp - 15 ) ), olapWin[len4 - 1 - i].v.re ) );
- move16();
+ L_olapBuffer[i + 1 * len4] = Madd_32_16( L_olapBuffer[i + 1 * len4], L_shl_sat( fftBuffer[i + 1 * len4], tmp1 ), olapWin[i].v.im ); /* Q(31 - (15 - fftlenShift) ) */
+ move32();
+ L_olapBuffer[i + 2 * len4] = Madd_32_16( L_olapBuffer[i + 2 * len4], L_shl_sat( fftBuffer[i + 2 * len4], tmp1 ), olapWin[len4 - 1 - i].v.re ); /* Q(31 - (15 - fftlenShift) ) */
+ move32();
}
FOR( i = len3; i < len; i++ )
{
- olapBuffer[i] = round_fx_sat( L_shl_sat( fftBuffer[i], fftBufferExp - 15 ) );
+ L_olapBuffer[i] = L_shl_sat( fftBuffer[i], tmp1 ); /* Q(31 - (15 - fftlenShift) ) */
+ move32();
}
}
FOR( i = 0; i < len4; i++ )
{
- olapBuffer[i + 5 * len4] = mult_r( round_fx_sat( L_shl_sat( fftBuffer[i + 5 * len4], fftBufferExp - 15 ) ), olapWin[i].v.re );
- move16();
- olapBuffer[i + 6 * len4] = mult_r( round_fx_sat( L_shl_sat( fftBuffer[i + 6 * len4], fftBufferExp - 15 ) ), olapWin[len4 - 1 - i].v.im );
- move16();
+ L_olapBuffer[i + 5 * len4] = Mpy_32_16_1( L_shl_sat( fftBuffer[i + 5 * len4], tmp1 ), olapWin[i].v.re ); /* Q(31 - (15 - fftlenShift) ) */
+ move32();
+ L_olapBuffer[i + 6 * len4] = Mpy_32_16_1( L_shl_sat( fftBuffer[i + 6 * len4], tmp1 ), olapWin[len4 - 1 - i].v.im ); /* Q(31 - (15 - fftlenShift) ) */
+ move32();
}
len = add( len, len2 );
FOR( i = len; i < hFdCngCom->fftlen; i++ )
{
- olapBuffer[i] = 0;
+ L_olapBuffer[i] = 0;
+ move32();
+ }
+
+ sft = L_norm_arr( L_olapBuffer, hFdCngCom->fftlen );
+ IF( NE_16( sft, 31 ) )
+ {
+ Copy_Scale_sig32_16( L_olapBuffer, olapBuffer, hFdCngCom->fftlen, sft );
+ hFdCngCom->olapBufferSynth_exp = sub( sub( 15, hFdCngCom->fftlenShift ), sft );
move16();
}
@@ -2749,112 +2806,31 @@ void SynthesisSTFT_ivas_fx(
move16();
}
/* Generate excitation */
-#ifdef IVAS_CODE_CNG_COM
- PME()
- if ( ( element_mode == IVAS_CPE_TD || element_mode == IVAS_CPE_DFT ) && nchan_out == 2 )
- {
- for ( i = 0; i < hFdCngCom->frameSize / 2; i++ )
- {
- buf[i + ( M + 1 )] += olapBuffer[i + hFdCngCom->frameSize / 4];
- }
- v_multc( buf, (float) ( hFdCngCom->fftlen / 2 ), buf, M + 1 + hFdCngCom->frameSize );
- }
- else
-#endif
{
FOR( i = 0; i < M + 1 + hFdCngCom->frameSize; i++ )
{
buf[i] = mult_r( olapBuffer[i + len4 - M - 1], hFdCngCom->fftlenFac );
move16();
}
+ exp = add( hFdCngCom->olapBufferSynth_exp, hFdCngCom->fftlenShift );
tmp = buf[0];
}
IF( EQ_16( gen_exc, 1 ) )
{
- Word16 s = getScaleFactor16( buf + 1, M + hFdCngCom->frameSize );
- if ( GT_16( *Q_new, s ) )
- {
- *Q_new = s;
- move16();
- }
-
- E_UTIL_f_preemph2( *Q_new - 1, buf + 1, PREEMPH_FAC, M + hFdCngCom->frameSize, &tmp );
- Residu3_fx( hFdCngCom->A_cng, buf + 1 + M, hFdCngCom->exc_cng, hFdCngCom->frameSize, 1 );
+ E_UTIL_f_preemph2( 0, buf + 1, PREEMPH_FAC, add( M, hFdCngCom->frameSize ), &tmp );
+ Residu3_fx( hFdCngCom->A_cng, buf + 1 + M, hFdCngCom->exc_cng, hFdCngCom->frameSize, 0 );
+ *Q_new = sub( 15, exp );
+ move16();
}
IF( EQ_16( gen_exc, 2 ) )
{
- *Q_new = E_UTIL_f_preemph3( buf + 1, PREEMPH_FAC, M + hFdCngCom->frameSize, &tmp, 1 );
- Residu3_fx( hFdCngCom->A_cng, buf + 1 + M, hFdCngCom->exc_cng, hFdCngCom->frameSize, 1 );
- }
-}
-
-#ifdef IVAS_CODE_CNG_COM
-/*-------------------------------------------------------------------
- * SynthesisSTFT_dirac()
- *
- * STFT synthesis filterbank
- *-------------------------------------------------------------------*/
-
-void SynthesisSTFT_dirac(
- float *fftBuffer, /* i : FFT bins */
- float *timeDomainOutput,
- float *olapBuffer,
- const float *olapWin,
- const int16_t samples_out,
- HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */
-)
-{
- int16_t i;
- float buf[M + 1 + 320], tmp;
-
- /* Perform IFFT */
- RFFTN( fftBuffer, hFdCngCom->fftSineTab, hFdCngCom->fftlen, 1 );
-
- /* Handle overlap in P/S domain for stereo */
- mvr2r( olapBuffer + hFdCngCom->frameSize, olapBuffer, hFdCngCom->frameSize );
- set_f( olapBuffer + hFdCngCom->frameSize, 0.0f, hFdCngCom->frameSize ); /*olapBuffer, fftBuffer, olapWin*/
-
- for ( i = hFdCngCom->frameSize / 4; i < 3 * hFdCngCom->frameSize / 4; i++ )
- {
- olapBuffer[i] += fftBuffer[i] * olapWin[i - hFdCngCom->frameSize / 4];
- }
- for ( ; i < 5 * hFdCngCom->frameSize / 4; i++ )
- {
- olapBuffer[i] = fftBuffer[i];
- }
-
- for ( ; i < 7 * hFdCngCom->frameSize / 4; i++ )
- {
- olapBuffer[i] = fftBuffer[i];
- }
-
- for ( ; i < hFdCngCom->fftlen; i++ )
- {
- olapBuffer[i] = 0;
- }
-
- /* Get time-domain signal */
- v_multc( olapBuffer + hFdCngCom->frameSize / 4, (float) ( hFdCngCom->fftlen / 2 ), timeDomainOutput, samples_out );
-
- /* Get excitation */
- v_multc( olapBuffer + hFdCngCom->frameSize / 4 - ( M + 1 ), (float) ( hFdCngCom->fftlen / 2 ), buf, M + 1 + hFdCngCom->frameSize );
- tmp = buf[0];
- preemph( buf + 1, PREEMPH_FAC, M + hFdCngCom->frameSize, &tmp );
- residu( hFdCngCom->A_cng, M, buf + 1 + M, hFdCngCom->exc_cng, hFdCngCom->frameSize );
-
- /* update and window olapBuf if we have a output frame that is shorter than the default frame size...*/
- if ( samples_out < hFdCngCom->frameSize )
- {
- mvr2r( olapBuffer + samples_out, olapBuffer + hFdCngCom->frameSize, 3 * hFdCngCom->frameSize / 4 );
- }
- for ( i = 5 * hFdCngCom->frameSize / 4; i < 7 * hFdCngCom->frameSize / 4; i++ )
- {
- olapBuffer[i] *= olapWin[i - 3 * hFdCngCom->frameSize / 4];
+ *Q_new = E_UTIL_f_preemph3( buf + 1, PREEMPH_FAC, add( M, hFdCngCom->frameSize ), &tmp, 0 );
+ move16();
+ Residu3_fx( hFdCngCom->A_cng, buf + 1 + M, hFdCngCom->exc_cng, hFdCngCom->frameSize, negate( *Q_new ) );
+ *Q_new = sub( 15, exp );
+ move16();
}
-
- return;
}
-#endif
/**************************************************************************************
* Compute some values used in the bias correction of the minimum statistics algorithm *
diff --git a/lib_com/fft.c b/lib_com/fft.c
deleted file mode 100644
index e262f3909f179ea67b91c160866b1f62cd2b411a..0000000000000000000000000000000000000000
--- a/lib_com/fft.c
+++ /dev/null
@@ -1,366 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository. All Rights Reserved.
-
- This software is protected by copyright law and by international treaties.
- The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository retain full ownership rights in their respective contributions in
- the software. This notice grants no license of any kind, including but not limited to patent
- license, nor is any license granted by implication, estoppel or otherwise.
-
- Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
- contributions.
-
- This software is provided "AS IS", without any express or implied warranties. The software is in the
- development stage. It is intended exclusively for experts who have experience with such software and
- solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
- and fitness for a particular purpose are hereby disclaimed and excluded.
-
- Any dispute, controversy or claim arising under or in relation to providing this software shall be
- submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
- accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
- the United Nations Convention on Contracts on the International Sales of Goods.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include
-#include "options.h"
-#include
-#include "cnst.h"
-#include "prot_fx.h"
-#include "rom_com.h"
-#include "wmc_auto.h"
-
-#ifdef _MSC_VER
-#pragma warning( disable : 4310 )
-#endif
-
-/*-----------------------------------------------------------------*
- * Low-complexity implementation of FFT
- *-----------------------------------------------------------------*/
-
-#define WMC_TOOL_SKIP
-
-#define SHC( x ) ( (Word16) x )
-#define FFTC( x ) WORD322WORD16( (Word32) x )
-
-#define C81_FX ( FFTC( 0x5a82799a ) ) /* FL2WORD32( 7.071067811865475e-1) */
-#define C82_FX ( FFTC( 0xa57d8666 ) ) /* FL2WORD32(-7.071067811865475e-1) */
-
-#define cplxMpy4_8_0( re, im, a, b, c, d ) \
- re = L_shr( L_sub( Mpy_32_16_1( a, c ), Mpy_32_16_1( b, d ) ), 1 ); \
- im = L_shr( L_add( Mpy_32_16_1( a, d ), Mpy_32_16_1( b, c ) ), 1 );
-
-#define cplxMpy4_8_1( re, im, a, b ) \
- re = L_shr( a, 1 ); \
- im = L_shr( b, 1 );
-
-
-/**
- * \brief Twiddle factors are unscaled
- */
-/*-----------------------------------------------------------------*
- * BASOP_fft8()
- *
- * Function performs a complex 8-point FFT
- * The FFT is performed inplace. The result of the FFT
- * is scaled by SCALEFACTOR8 bits.
- *
- * WOPS with 32x16 bit multiplications: 108 cycles
- *-----------------------------------------------------------------*/
-
-static void BASOP_fft8(
- Word32 *re,
- Word32 *im,
- Word16 s )
-{
- Word32 x00, x01, x02, x03, x04, x05, x06, x07;
- Word32 x08, x09, x10, x11, x12, x13, x14, x15;
- Word32 t00, t01, t02, t03, t04, t05, t06, t07;
- Word32 t08, t09, t10, t11, t12, t13, t14, t15;
- Word32 s00, s01, s02, s03, s04, s05, s06, s07;
- Word32 s08, s09, s10, s11, s12, s13, s14, s15;
-
-
- /* Pre-additions */
-
- x00 = L_shr( re[s * 0], SCALEFACTOR8 );
- x01 = L_shr( im[s * 0], SCALEFACTOR8 );
- x02 = L_shr( re[s * 1], SCALEFACTOR8 );
- x03 = L_shr( im[s * 1], SCALEFACTOR8 );
- x04 = L_shr( re[s * 2], SCALEFACTOR8 );
- x05 = L_shr( im[s * 2], SCALEFACTOR8 );
- x06 = L_shr( re[s * 3], SCALEFACTOR8 );
- x07 = L_shr( im[s * 3], SCALEFACTOR8 );
- x08 = L_shr( re[s * 4], SCALEFACTOR8 );
- x09 = L_shr( im[s * 4], SCALEFACTOR8 );
- x10 = L_shr( re[s * 5], SCALEFACTOR8 );
- x11 = L_shr( im[s * 5], SCALEFACTOR8 );
- x12 = L_shr( re[s * 6], SCALEFACTOR8 );
- x13 = L_shr( im[s * 6], SCALEFACTOR8 );
- x14 = L_shr( re[s * 7], SCALEFACTOR8 );
- x15 = L_shr( im[s * 7], SCALEFACTOR8 );
-
- t00 = L_add( x00, x08 );
- t02 = L_sub( x00, x08 );
- t01 = L_add( x01, x09 );
- t03 = L_sub( x01, x09 );
- t04 = L_add( x02, x10 );
- t06 = L_sub( x02, x10 );
- t05 = L_add( x03, x11 );
- t07 = L_sub( x03, x11 );
- t08 = L_add( x04, x12 );
- t10 = L_sub( x04, x12 );
- t09 = L_add( x05, x13 );
- t11 = L_sub( x05, x13 );
- t12 = L_add( x06, x14 );
- t14 = L_sub( x06, x14 );
- t13 = L_add( x07, x15 );
- t15 = L_sub( x07, x15 );
-
- /* Pre-additions and core multiplications */
-
- s00 = L_add( t00, t08 );
- s04 = L_sub( t00, t08 );
- s01 = L_add( t01, t09 );
- s05 = L_sub( t01, t09 );
- s08 = L_sub( t02, t11 );
- s10 = L_add( t02, t11 );
- s09 = L_add( t03, t10 );
- s11 = L_sub( t03, t10 );
- s02 = L_add( t04, t12 );
- s07 = L_sub( t04, t12 );
- s03 = L_add( t05, t13 );
- s06 = L_sub( t13, t05 );
-
- t01 = L_add( t06, t14 );
- t02 = L_sub( t06, t14 );
- t00 = L_add( t07, t15 );
- t03 = L_sub( t07, t15 );
-
- s12 = Mpy_32_16_1( L_add( t00, t02 ), C81_FX );
- s14 = Mpy_32_16_1( L_sub( t00, t02 ), C81_FX );
- s13 = Mpy_32_16_1( L_sub( t03, t01 ), C81_FX );
- s15 = Mpy_32_16_1( L_add( t01, t03 ), C82_FX );
-
- /* Post-additions */
-
- re[s * 0] = L_add( s00, s02 );
- move32();
- re[s * 4] = L_sub( s00, s02 );
- move32();
- im[s * 0] = L_add( s01, s03 );
- move32();
- im[s * 4] = L_sub( s01, s03 );
- move32();
- re[s * 2] = L_sub( s04, s06 );
- move32();
- re[s * 6] = L_add( s04, s06 );
- move32();
- im[s * 2] = L_sub( s05, s07 );
- move32();
- im[s * 6] = L_add( s05, s07 );
- move32();
- re[i_mult( s, 3 )] = L_add( s08, s14 );
- move32();
- re[i_mult( s, 7 )] = L_sub( s08, s14 );
- move32();
- im[i_mult( s, 3 )] = L_add( s09, s15 );
- move32();
- im[i_mult( s, 7 )] = L_sub( s09, s15 );
- move32();
- re[s * 1] = L_add( s10, s12 );
- move32();
- re[i_mult( s, 5 )] = L_sub( s10, s12 );
- move32();
- im[s * 1] = L_add( s11, s13 );
- move32();
- im[i_mult( s, 5 )] = L_sub( s11, s13 );
- move32();
-
- return;
-}
-
-
-/*-----------------------------------------------------------------*
- * fftN2()
- *
- * Combined FFT
- *-----------------------------------------------------------------*/
-
-static void BASOP_fftN2(
- Word32 *re, /* i/o: real part */
- Word32 *im, /* i/o: imag part */
- const Word16 *W, /* i : rotation factor */
- Word16 dim1, /* i : length of fft1 */
- Word16 dim2, /* i : length of fft2 */
- Word16 sx, /* i : stride real and imag part */
- Word16 sc, /* i : stride phase rotation coefficients */
- Word32 *x, /* tmp: 32-bit workbuffer */
- Word16 Woff /* i : offset for addressing the rotation vector table */
-)
-{
- Word16 i, j;
- Word32 x00, x01, x02, x03, x04, x05, x06, x07, x08, x09, x10, x11, x12, x13, x14, x15;
- Word32 t00, t01, t02, t03, t04, t05, t06, t07, t08, t09, t10, t11, t12, t13, t14, t15;
- Word32 s00, s01, s02, s03, s04, s05, s06, s07, s08, s09, s10, s11, s12, s13, s14, s15;
-
- FOR( i = 0; i < dim2; i++ )
- {
- FOR( j = 0; j < dim1; j++ )
- {
- x[2 * i * dim1 + 2 * j] = re[sx * i + sx * j * dim2];
- move32();
- x[2 * i * dim1 + 2 * j + 1] = im[sx * i + sx * j * dim2];
- move32();
- }
- }
-
- /* dim1 == 8 */
- FOR( i = 0; i < dim2; i++ )
- {
- BASOP_fft8( &x[i * 2 * dim1], &x[i * 2 * dim1 + 1], 2 );
- }
-
- /* dim2 == 8 */
- FOR( i = 0; i < dim1; i++ )
- {
- cplxMpy4_8_1( x00, x01, x[2 * i + 2 * 0 * dim1], x[2 * i + 2 * 0 * dim1 + 1] );
-
- IF( i == 0 )
- {
- cplxMpy4_8_1( x02, x03, x[add( shl( i, 1 ), i_mult( 2 * 1, dim1 ) )], x[add( add( shl( i, 1 ), i_mult( 2 * 1, dim1 ) ), 1 )] );
- cplxMpy4_8_1( x04, x05, x[add( shl( i, 1 ), i_mult( 2 * 2, dim1 ) )], x[add( add( shl( i, 1 ), i_mult( 2 * 2, dim1 ) ), 1 )] );
- cplxMpy4_8_1( x06, x07, x[add( shl( i, 1 ), i_mult( 2 * 3, dim1 ) )], x[add( add( shl( i, 1 ), i_mult( 2 * 3, dim1 ) ), 1 )] );
- cplxMpy4_8_1( x08, x09, x[add( shl( i, 1 ), i_mult( 2 * 4, dim1 ) )], x[add( add( shl( i, 1 ), i_mult( 2 * 4, dim1 ) ), 1 )] );
- cplxMpy4_8_1( x10, x11, x[add( shl( i, 1 ), i_mult( 2 * 5, dim1 ) )], x[add( add( shl( i, 1 ), i_mult( 2 * 5, dim1 ) ), 1 )] );
- cplxMpy4_8_1( x12, x13, x[add( shl( i, 1 ), i_mult( 2 * 6, dim1 ) )], x[add( add( shl( i, 1 ), i_mult( 2 * 6, dim1 ) ), 1 )] );
- cplxMpy4_8_1( x14, x15, x[add( shl( i, 1 ), i_mult( 2 * 7, dim1 ) )], x[add( add( shl( i, 1 ), i_mult( 2 * 7, dim1 ) ), 1 )] );
- }
- ELSE
- {
- cplxMpy4_8_0( x02, x03, x[add( shl( i, 1 ), i_mult( 2 * 1, dim1 ) )], x[add( add( shl( i, 1 ), i_mult( 2 * 1, dim1 ) ), 1 )], W[sub( add( i_mult( sc, i ), i_mult( sc, i_mult( 1, dim1 ) ) ), Woff )], W[sub( add( add( i_mult( sc, i ), i_mult( sc, i_mult( 1, dim1 ) ) ), 1 ), Woff )] );
- cplxMpy4_8_0( x04, x05, x[add( shl( i, 1 ), i_mult( 2 * 2, dim1 ) )], x[add( add( shl( i, 1 ), i_mult( 2 * 2, dim1 ) ), 1 )], W[sub( add( i_mult( sc, i ), i_mult( sc, i_mult( 2, dim1 ) ) ), Woff )], W[sub( add( add( i_mult( sc, i ), i_mult( sc, i_mult( 2, dim1 ) ) ), 1 ), Woff )] );
- cplxMpy4_8_0( x06, x07, x[add( shl( i, 1 ), i_mult( 2 * 3, dim1 ) )], x[add( add( shl( i, 1 ), i_mult( 2 * 3, dim1 ) ), 1 )], W[sub( add( i_mult( sc, i ), i_mult( sc, i_mult( 3, dim1 ) ) ), Woff )], W[sub( add( add( i_mult( sc, i ), i_mult( sc, i_mult( 3, dim1 ) ) ), 1 ), Woff )] );
- cplxMpy4_8_0( x08, x09, x[add( shl( i, 1 ), i_mult( 2 * 4, dim1 ) )], x[add( add( shl( i, 1 ), i_mult( 2 * 4, dim1 ) ), 1 )], W[sub( add( i_mult( sc, i ), i_mult( sc, i_mult( 4, dim1 ) ) ), Woff )], W[sub( add( add( i_mult( sc, i ), i_mult( sc, i_mult( 4, dim1 ) ) ), 1 ), Woff )] );
- cplxMpy4_8_0( x10, x11, x[add( shl( i, 1 ), i_mult( 2 * 5, dim1 ) )], x[add( add( shl( i, 1 ), i_mult( 2 * 5, dim1 ) ), 1 )], W[sub( add( i_mult( sc, i ), i_mult( sc, i_mult( 5, dim1 ) ) ), Woff )], W[sub( add( add( i_mult( sc, i ), i_mult( sc, i_mult( 5, dim1 ) ) ), 1 ), Woff )] );
- cplxMpy4_8_0( x12, x13, x[add( shl( i, 1 ), i_mult( 2 * 6, dim1 ) )], x[add( add( shl( i, 1 ), i_mult( 2 * 6, dim1 ) ), 1 )], W[sub( add( i_mult( sc, i ), i_mult( sc, i_mult( 6, dim1 ) ) ), Woff )], W[sub( add( add( i_mult( sc, i ), i_mult( sc, i_mult( 6, dim1 ) ) ), 1 ), Woff )] );
- cplxMpy4_8_0( x14, x15, x[add( shl( i, 1 ), i_mult( 2 * 7, dim1 ) )], x[add( add( shl( i, 1 ), i_mult( 2 * 7, dim1 ) ), 1 )], W[sub( add( i_mult( sc, i ), i_mult( sc, i_mult( 7, dim1 ) ) ), Woff )], W[sub( add( add( i_mult( sc, i ), i_mult( sc, i_mult( 7, dim1 ) ) ), 1 ), Woff )] );
- }
- t00 = L_shr( L_add( x00, x08 ), SCALEFACTORN2 - 1 );
- t02 = L_shr( L_sub( x00, x08 ), SCALEFACTORN2 - 1 );
- t01 = L_shr( L_add( x01, x09 ), SCALEFACTORN2 - 1 );
- t03 = L_shr( L_sub( x01, x09 ), SCALEFACTORN2 - 1 );
- t04 = L_shr( L_add( x02, x10 ), SCALEFACTORN2 - 1 );
- t06 = L_sub( x02, x10 );
- t05 = L_shr( L_add( x03, x11 ), SCALEFACTORN2 - 1 );
- t07 = L_sub( x03, x11 );
- t08 = L_shr( L_add( x04, x12 ), SCALEFACTORN2 - 1 );
- t10 = L_shr( L_sub( x04, x12 ), SCALEFACTORN2 - 1 );
- t09 = L_shr( L_add( x05, x13 ), SCALEFACTORN2 - 1 );
- t11 = L_shr( L_sub( x05, x13 ), SCALEFACTORN2 - 1 );
- t12 = L_shr( L_add( x06, x14 ), SCALEFACTORN2 - 1 );
- t14 = L_sub( x06, x14 );
- t13 = L_shr( L_add( x07, x15 ), SCALEFACTORN2 - 1 );
- t15 = L_sub( x07, x15 );
-
- s00 = L_add( t00, t08 );
- s04 = L_sub( t00, t08 );
- s01 = L_add( t01, t09 );
- s05 = L_sub( t01, t09 );
- s08 = L_sub( t02, t11 );
- s10 = L_add( t02, t11 );
- s09 = L_add( t03, t10 );
- s11 = L_sub( t03, t10 );
- s02 = L_add( t04, t12 );
- s07 = L_sub( t04, t12 );
- s03 = L_add( t05, t13 );
- s06 = L_sub( t13, t05 );
-
- t01 = L_shr( L_add( t06, t14 ), SCALEFACTORN2 - 1 );
- t02 = L_shr( L_sub( t06, t14 ), SCALEFACTORN2 - 1 );
- t00 = L_shr( L_add( t07, t15 ), SCALEFACTORN2 - 1 );
- t03 = L_shr( L_sub( t07, t15 ), SCALEFACTORN2 - 1 );
-
- s12 = Mpy_32_16_1( L_add( t00, t02 ), C81_FX );
- s14 = Mpy_32_16_1( L_sub( t00, t02 ), C81_FX );
- s13 = Mpy_32_16_1( L_sub( t03, t01 ), C81_FX );
- s15 = Mpy_32_16_1( L_add( t01, t03 ), C82_FX );
-
- re[add( i_mult( sx, i ), i_mult( sx, i_mult( 0, dim1 ) ) )] = L_add( s00, s02 );
- move32();
- im[add( i_mult( sx, i ), i_mult( sx, i_mult( 0, dim1 ) ) )] = L_add( s01, s03 );
- move32();
- re[add( i_mult( sx, i ), i_mult( sx, i_mult( 1, dim1 ) ) )] = L_add( s10, s12 );
- move32();
- im[add( i_mult( sx, i ), i_mult( sx, i_mult( 1, dim1 ) ) )] = L_add( s11, s13 );
- move32();
- re[add( i_mult( sx, i ), i_mult( sx, i_mult( 2, dim1 ) ) )] = L_sub( s04, s06 );
- move32();
- im[add( i_mult( sx, i ), i_mult( sx, i_mult( 2, dim1 ) ) )] = L_sub( s05, s07 );
- move32();
- re[add( i_mult( sx, i ), i_mult( sx, i_mult( 3, dim1 ) ) )] = L_add( s08, s14 );
- move32();
- im[add( i_mult( sx, i ), i_mult( sx, i_mult( 3, dim1 ) ) )] = L_add( s09, s15 );
- move32();
- re[add( i_mult( sx, i ), i_mult( sx, i_mult( 4, dim1 ) ) )] = L_sub( s00, s02 );
- move32();
- im[add( i_mult( sx, i ), i_mult( sx, i_mult( 4, dim1 ) ) )] = L_sub( s01, s03 );
- move32();
- re[add( i_mult( sx, i ), i_mult( sx, i_mult( 5, dim1 ) ) )] = L_sub( s10, s12 );
- move32();
- im[add( i_mult( sx, i ), i_mult( sx, i_mult( 5, dim1 ) ) )] = L_sub( s11, s13 );
- move32();
- re[add( i_mult( sx, i ), i_mult( sx, i_mult( 6, dim1 ) ) )] = L_add( s04, s06 );
- move32();
- im[add( i_mult( sx, i ), i_mult( sx, i_mult( 6, dim1 ) ) )] = L_add( s05, s07 );
- move32();
- re[add( i_mult( sx, i ), i_mult( sx, i_mult( 7, dim1 ) ) )] = L_sub( s08, s14 );
- move32();
- im[add( i_mult( sx, i ), i_mult( sx, i_mult( 7, dim1 ) ) )] = L_sub( s09, s15 );
- move32();
- }
-
- return;
-}
-
-
-/*-----------------------------------------------------------------*
- * BASOP_cfft_ivas()
- *
- * Complex valued FFT
- *-----------------------------------------------------------------*/
-
-void BASOP_cfft_ivas(
- Word32 *re, /* i/o: real part */
- Word32 *im, /* i/o: imag part */
- Word16 s, /* i : stride real and imag part */
- Word16 *scale /* i : scalefactor */
-)
-{
- Word32 x[2 * 64];
-
- /* FFT for len = FDNS_NPTS */
- BASOP_fftN2( re, im, RotVector_256, 8, 8, s, 8, x, 64 );
- s = add( *scale, SCALEFACTOR64 );
-
- *scale = s;
- move16();
-
- return;
-}
-
-
-#undef WMC_TOOL_SKIP
diff --git a/lib_com/fft_fx.c b/lib_com/fft_fx.c
index 5ee5098797c3b57caf6c91e826bcc76dd1fdf850..40c9780148ac85d1a202be1a623309ed24095c1b 100644
--- a/lib_com/fft_fx.c
+++ b/lib_com/fft_fx.c
@@ -44,9 +44,7 @@
#include "options.h"
#include
#include "cnst.h"
-// #include "prot_fx.h"
#include "prot_fx.h"
-//#include "cnst_fx.h"
#include "rom_com.h"
#include "rom_com_fx.h"
#include "wmc_auto.h"
@@ -7555,3 +7553,317 @@ void rfft_fx(
return;
}
+
+
+#define WMC_TOOL_SKIP
+
+#define SHC( x ) ( (Word16) x )
+#define FFTC( x ) WORD322WORD16( (Word32) x )
+
+#define C81_FX ( FFTC( 0x5a82799a ) ) /* FL2WORD32( 7.071067811865475e-1) */
+#define C82_FX ( FFTC( 0xa57d8666 ) ) /* FL2WORD32(-7.071067811865475e-1) */
+
+#define cplxMpy4_8_0( re, im, a, b, c, d ) \
+ re = L_shr( L_sub( Mpy_32_16_1( a, c ), Mpy_32_16_1( b, d ) ), 1 ); \
+ im = L_shr( L_add( Mpy_32_16_1( a, d ), Mpy_32_16_1( b, c ) ), 1 );
+
+#define cplxMpy4_8_1( re, im, a, b ) \
+ re = L_shr( a, 1 ); \
+ im = L_shr( b, 1 );
+
+
+/**
+ * \brief Twiddle factors are unscaled
+ */
+/*-----------------------------------------------------------------*
+ * BASOP_fft8()
+ *
+ * Function performs a complex 8-point FFT
+ * The FFT is performed inplace. The result of the FFT
+ * is scaled by SCALEFACTOR8 bits.
+ *
+ * WOPS with 32x16 bit multiplications: 108 cycles
+ *-----------------------------------------------------------------*/
+
+static void BASOP_fft8(
+ Word32 *re,
+ Word32 *im,
+ Word16 s )
+{
+ Word32 x00, x01, x02, x03, x04, x05, x06, x07;
+ Word32 x08, x09, x10, x11, x12, x13, x14, x15;
+ Word32 t00, t01, t02, t03, t04, t05, t06, t07;
+ Word32 t08, t09, t10, t11, t12, t13, t14, t15;
+ Word32 s00, s01, s02, s03, s04, s05, s06, s07;
+ Word32 s08, s09, s10, s11, s12, s13, s14, s15;
+
+
+ /* Pre-additions */
+
+ x00 = L_shr( re[s * 0], SCALEFACTOR8 );
+ x01 = L_shr( im[s * 0], SCALEFACTOR8 );
+ x02 = L_shr( re[s * 1], SCALEFACTOR8 );
+ x03 = L_shr( im[s * 1], SCALEFACTOR8 );
+ x04 = L_shr( re[s * 2], SCALEFACTOR8 );
+ x05 = L_shr( im[s * 2], SCALEFACTOR8 );
+ x06 = L_shr( re[s * 3], SCALEFACTOR8 );
+ x07 = L_shr( im[s * 3], SCALEFACTOR8 );
+ x08 = L_shr( re[s * 4], SCALEFACTOR8 );
+ x09 = L_shr( im[s * 4], SCALEFACTOR8 );
+ x10 = L_shr( re[s * 5], SCALEFACTOR8 );
+ x11 = L_shr( im[s * 5], SCALEFACTOR8 );
+ x12 = L_shr( re[s * 6], SCALEFACTOR8 );
+ x13 = L_shr( im[s * 6], SCALEFACTOR8 );
+ x14 = L_shr( re[s * 7], SCALEFACTOR8 );
+ x15 = L_shr( im[s * 7], SCALEFACTOR8 );
+
+ t00 = L_add( x00, x08 );
+ t02 = L_sub( x00, x08 );
+ t01 = L_add( x01, x09 );
+ t03 = L_sub( x01, x09 );
+ t04 = L_add( x02, x10 );
+ t06 = L_sub( x02, x10 );
+ t05 = L_add( x03, x11 );
+ t07 = L_sub( x03, x11 );
+ t08 = L_add( x04, x12 );
+ t10 = L_sub( x04, x12 );
+ t09 = L_add( x05, x13 );
+ t11 = L_sub( x05, x13 );
+ t12 = L_add( x06, x14 );
+ t14 = L_sub( x06, x14 );
+ t13 = L_add( x07, x15 );
+ t15 = L_sub( x07, x15 );
+
+ /* Pre-additions and core multiplications */
+
+ s00 = L_add( t00, t08 );
+ s04 = L_sub( t00, t08 );
+ s01 = L_add( t01, t09 );
+ s05 = L_sub( t01, t09 );
+ s08 = L_sub( t02, t11 );
+ s10 = L_add( t02, t11 );
+ s09 = L_add( t03, t10 );
+ s11 = L_sub( t03, t10 );
+ s02 = L_add( t04, t12 );
+ s07 = L_sub( t04, t12 );
+ s03 = L_add( t05, t13 );
+ s06 = L_sub( t13, t05 );
+
+ t01 = L_add( t06, t14 );
+ t02 = L_sub( t06, t14 );
+ t00 = L_add( t07, t15 );
+ t03 = L_sub( t07, t15 );
+
+ s12 = Mpy_32_16_1( L_add( t00, t02 ), C81_FX );
+ s14 = Mpy_32_16_1( L_sub( t00, t02 ), C81_FX );
+ s13 = Mpy_32_16_1( L_sub( t03, t01 ), C81_FX );
+ s15 = Mpy_32_16_1( L_add( t01, t03 ), C82_FX );
+
+ /* Post-additions */
+
+ re[s * 0] = L_add( s00, s02 );
+ move32();
+ re[s * 4] = L_sub( s00, s02 );
+ move32();
+ im[s * 0] = L_add( s01, s03 );
+ move32();
+ im[s * 4] = L_sub( s01, s03 );
+ move32();
+ re[s * 2] = L_sub( s04, s06 );
+ move32();
+ re[s * 6] = L_add( s04, s06 );
+ move32();
+ im[s * 2] = L_sub( s05, s07 );
+ move32();
+ im[s * 6] = L_add( s05, s07 );
+ move32();
+ re[i_mult( s, 3 )] = L_add( s08, s14 );
+ move32();
+ re[i_mult( s, 7 )] = L_sub( s08, s14 );
+ move32();
+ im[i_mult( s, 3 )] = L_add( s09, s15 );
+ move32();
+ im[i_mult( s, 7 )] = L_sub( s09, s15 );
+ move32();
+ re[s * 1] = L_add( s10, s12 );
+ move32();
+ re[i_mult( s, 5 )] = L_sub( s10, s12 );
+ move32();
+ im[s * 1] = L_add( s11, s13 );
+ move32();
+ im[i_mult( s, 5 )] = L_sub( s11, s13 );
+ move32();
+
+ return;
+}
+
+
+/*-----------------------------------------------------------------*
+ * fftN2()
+ *
+ * Combined FFT
+ *-----------------------------------------------------------------*/
+
+static void BASOP_fftN2(
+ Word32 *re, /* i/o: real part */
+ Word32 *im, /* i/o: imag part */
+ const Word16 *W, /* i : rotation factor */
+ Word16 dim1, /* i : length of fft1 */
+ Word16 dim2, /* i : length of fft2 */
+ Word16 sx, /* i : stride real and imag part */
+ Word16 sc, /* i : stride phase rotation coefficients */
+ Word32 *x, /* tmp: 32-bit workbuffer */
+ Word16 Woff /* i : offset for addressing the rotation vector table */
+)
+{
+ Word16 i, j;
+ Word32 x00, x01, x02, x03, x04, x05, x06, x07, x08, x09, x10, x11, x12, x13, x14, x15;
+ Word32 t00, t01, t02, t03, t04, t05, t06, t07, t08, t09, t10, t11, t12, t13, t14, t15;
+ Word32 s00, s01, s02, s03, s04, s05, s06, s07, s08, s09, s10, s11, s12, s13, s14, s15;
+
+ FOR( i = 0; i < dim2; i++ )
+ {
+ FOR( j = 0; j < dim1; j++ )
+ {
+ x[2 * i * dim1 + 2 * j] = re[sx * i + sx * j * dim2];
+ move32();
+ x[2 * i * dim1 + 2 * j + 1] = im[sx * i + sx * j * dim2];
+ move32();
+ }
+ }
+
+ /* dim1 == 8 */
+ FOR( i = 0; i < dim2; i++ )
+ {
+ BASOP_fft8( &x[i * 2 * dim1], &x[i * 2 * dim1 + 1], 2 );
+ }
+
+ /* dim2 == 8 */
+ FOR( i = 0; i < dim1; i++ )
+ {
+ cplxMpy4_8_1( x00, x01, x[2 * i + 2 * 0 * dim1], x[2 * i + 2 * 0 * dim1 + 1] );
+
+ IF( i == 0 )
+ {
+ cplxMpy4_8_1( x02, x03, x[add( shl( i, 1 ), i_mult( 2 * 1, dim1 ) )], x[add( add( shl( i, 1 ), i_mult( 2 * 1, dim1 ) ), 1 )] );
+ cplxMpy4_8_1( x04, x05, x[add( shl( i, 1 ), i_mult( 2 * 2, dim1 ) )], x[add( add( shl( i, 1 ), i_mult( 2 * 2, dim1 ) ), 1 )] );
+ cplxMpy4_8_1( x06, x07, x[add( shl( i, 1 ), i_mult( 2 * 3, dim1 ) )], x[add( add( shl( i, 1 ), i_mult( 2 * 3, dim1 ) ), 1 )] );
+ cplxMpy4_8_1( x08, x09, x[add( shl( i, 1 ), i_mult( 2 * 4, dim1 ) )], x[add( add( shl( i, 1 ), i_mult( 2 * 4, dim1 ) ), 1 )] );
+ cplxMpy4_8_1( x10, x11, x[add( shl( i, 1 ), i_mult( 2 * 5, dim1 ) )], x[add( add( shl( i, 1 ), i_mult( 2 * 5, dim1 ) ), 1 )] );
+ cplxMpy4_8_1( x12, x13, x[add( shl( i, 1 ), i_mult( 2 * 6, dim1 ) )], x[add( add( shl( i, 1 ), i_mult( 2 * 6, dim1 ) ), 1 )] );
+ cplxMpy4_8_1( x14, x15, x[add( shl( i, 1 ), i_mult( 2 * 7, dim1 ) )], x[add( add( shl( i, 1 ), i_mult( 2 * 7, dim1 ) ), 1 )] );
+ }
+ ELSE
+ {
+ cplxMpy4_8_0( x02, x03, x[add( shl( i, 1 ), i_mult( 2 * 1, dim1 ) )], x[add( add( shl( i, 1 ), i_mult( 2 * 1, dim1 ) ), 1 )], W[sub( add( i_mult( sc, i ), i_mult( sc, i_mult( 1, dim1 ) ) ), Woff )], W[sub( add( add( i_mult( sc, i ), i_mult( sc, i_mult( 1, dim1 ) ) ), 1 ), Woff )] );
+ cplxMpy4_8_0( x04, x05, x[add( shl( i, 1 ), i_mult( 2 * 2, dim1 ) )], x[add( add( shl( i, 1 ), i_mult( 2 * 2, dim1 ) ), 1 )], W[sub( add( i_mult( sc, i ), i_mult( sc, i_mult( 2, dim1 ) ) ), Woff )], W[sub( add( add( i_mult( sc, i ), i_mult( sc, i_mult( 2, dim1 ) ) ), 1 ), Woff )] );
+ cplxMpy4_8_0( x06, x07, x[add( shl( i, 1 ), i_mult( 2 * 3, dim1 ) )], x[add( add( shl( i, 1 ), i_mult( 2 * 3, dim1 ) ), 1 )], W[sub( add( i_mult( sc, i ), i_mult( sc, i_mult( 3, dim1 ) ) ), Woff )], W[sub( add( add( i_mult( sc, i ), i_mult( sc, i_mult( 3, dim1 ) ) ), 1 ), Woff )] );
+ cplxMpy4_8_0( x08, x09, x[add( shl( i, 1 ), i_mult( 2 * 4, dim1 ) )], x[add( add( shl( i, 1 ), i_mult( 2 * 4, dim1 ) ), 1 )], W[sub( add( i_mult( sc, i ), i_mult( sc, i_mult( 4, dim1 ) ) ), Woff )], W[sub( add( add( i_mult( sc, i ), i_mult( sc, i_mult( 4, dim1 ) ) ), 1 ), Woff )] );
+ cplxMpy4_8_0( x10, x11, x[add( shl( i, 1 ), i_mult( 2 * 5, dim1 ) )], x[add( add( shl( i, 1 ), i_mult( 2 * 5, dim1 ) ), 1 )], W[sub( add( i_mult( sc, i ), i_mult( sc, i_mult( 5, dim1 ) ) ), Woff )], W[sub( add( add( i_mult( sc, i ), i_mult( sc, i_mult( 5, dim1 ) ) ), 1 ), Woff )] );
+ cplxMpy4_8_0( x12, x13, x[add( shl( i, 1 ), i_mult( 2 * 6, dim1 ) )], x[add( add( shl( i, 1 ), i_mult( 2 * 6, dim1 ) ), 1 )], W[sub( add( i_mult( sc, i ), i_mult( sc, i_mult( 6, dim1 ) ) ), Woff )], W[sub( add( add( i_mult( sc, i ), i_mult( sc, i_mult( 6, dim1 ) ) ), 1 ), Woff )] );
+ cplxMpy4_8_0( x14, x15, x[add( shl( i, 1 ), i_mult( 2 * 7, dim1 ) )], x[add( add( shl( i, 1 ), i_mult( 2 * 7, dim1 ) ), 1 )], W[sub( add( i_mult( sc, i ), i_mult( sc, i_mult( 7, dim1 ) ) ), Woff )], W[sub( add( add( i_mult( sc, i ), i_mult( sc, i_mult( 7, dim1 ) ) ), 1 ), Woff )] );
+ }
+ t00 = L_shr( L_add( x00, x08 ), SCALEFACTORN2 - 1 );
+ t02 = L_shr( L_sub( x00, x08 ), SCALEFACTORN2 - 1 );
+ t01 = L_shr( L_add( x01, x09 ), SCALEFACTORN2 - 1 );
+ t03 = L_shr( L_sub( x01, x09 ), SCALEFACTORN2 - 1 );
+ t04 = L_shr( L_add( x02, x10 ), SCALEFACTORN2 - 1 );
+ t06 = L_sub( x02, x10 );
+ t05 = L_shr( L_add( x03, x11 ), SCALEFACTORN2 - 1 );
+ t07 = L_sub( x03, x11 );
+ t08 = L_shr( L_add( x04, x12 ), SCALEFACTORN2 - 1 );
+ t10 = L_shr( L_sub( x04, x12 ), SCALEFACTORN2 - 1 );
+ t09 = L_shr( L_add( x05, x13 ), SCALEFACTORN2 - 1 );
+ t11 = L_shr( L_sub( x05, x13 ), SCALEFACTORN2 - 1 );
+ t12 = L_shr( L_add( x06, x14 ), SCALEFACTORN2 - 1 );
+ t14 = L_sub( x06, x14 );
+ t13 = L_shr( L_add( x07, x15 ), SCALEFACTORN2 - 1 );
+ t15 = L_sub( x07, x15 );
+
+ s00 = L_add( t00, t08 );
+ s04 = L_sub( t00, t08 );
+ s01 = L_add( t01, t09 );
+ s05 = L_sub( t01, t09 );
+ s08 = L_sub( t02, t11 );
+ s10 = L_add( t02, t11 );
+ s09 = L_add( t03, t10 );
+ s11 = L_sub( t03, t10 );
+ s02 = L_add( t04, t12 );
+ s07 = L_sub( t04, t12 );
+ s03 = L_add( t05, t13 );
+ s06 = L_sub( t13, t05 );
+
+ t01 = L_shr( L_add( t06, t14 ), SCALEFACTORN2 - 1 );
+ t02 = L_shr( L_sub( t06, t14 ), SCALEFACTORN2 - 1 );
+ t00 = L_shr( L_add( t07, t15 ), SCALEFACTORN2 - 1 );
+ t03 = L_shr( L_sub( t07, t15 ), SCALEFACTORN2 - 1 );
+
+ s12 = Mpy_32_16_1( L_add( t00, t02 ), C81_FX );
+ s14 = Mpy_32_16_1( L_sub( t00, t02 ), C81_FX );
+ s13 = Mpy_32_16_1( L_sub( t03, t01 ), C81_FX );
+ s15 = Mpy_32_16_1( L_add( t01, t03 ), C82_FX );
+
+ re[add( i_mult( sx, i ), i_mult( sx, i_mult( 0, dim1 ) ) )] = L_add( s00, s02 );
+ move32();
+ im[add( i_mult( sx, i ), i_mult( sx, i_mult( 0, dim1 ) ) )] = L_add( s01, s03 );
+ move32();
+ re[add( i_mult( sx, i ), i_mult( sx, i_mult( 1, dim1 ) ) )] = L_add( s10, s12 );
+ move32();
+ im[add( i_mult( sx, i ), i_mult( sx, i_mult( 1, dim1 ) ) )] = L_add( s11, s13 );
+ move32();
+ re[add( i_mult( sx, i ), i_mult( sx, i_mult( 2, dim1 ) ) )] = L_sub( s04, s06 );
+ move32();
+ im[add( i_mult( sx, i ), i_mult( sx, i_mult( 2, dim1 ) ) )] = L_sub( s05, s07 );
+ move32();
+ re[add( i_mult( sx, i ), i_mult( sx, i_mult( 3, dim1 ) ) )] = L_add( s08, s14 );
+ move32();
+ im[add( i_mult( sx, i ), i_mult( sx, i_mult( 3, dim1 ) ) )] = L_add( s09, s15 );
+ move32();
+ re[add( i_mult( sx, i ), i_mult( sx, i_mult( 4, dim1 ) ) )] = L_sub( s00, s02 );
+ move32();
+ im[add( i_mult( sx, i ), i_mult( sx, i_mult( 4, dim1 ) ) )] = L_sub( s01, s03 );
+ move32();
+ re[add( i_mult( sx, i ), i_mult( sx, i_mult( 5, dim1 ) ) )] = L_sub( s10, s12 );
+ move32();
+ im[add( i_mult( sx, i ), i_mult( sx, i_mult( 5, dim1 ) ) )] = L_sub( s11, s13 );
+ move32();
+ re[add( i_mult( sx, i ), i_mult( sx, i_mult( 6, dim1 ) ) )] = L_add( s04, s06 );
+ move32();
+ im[add( i_mult( sx, i ), i_mult( sx, i_mult( 6, dim1 ) ) )] = L_add( s05, s07 );
+ move32();
+ re[add( i_mult( sx, i ), i_mult( sx, i_mult( 7, dim1 ) ) )] = L_sub( s08, s14 );
+ move32();
+ im[add( i_mult( sx, i ), i_mult( sx, i_mult( 7, dim1 ) ) )] = L_sub( s09, s15 );
+ move32();
+ }
+
+ return;
+}
+
+
+/*-----------------------------------------------------------------*
+ * BASOP_cfft_ivas()
+ *
+ * Complex valued FFT
+ *-----------------------------------------------------------------*/
+
+void BASOP_cfft_ivas(
+ Word32 *re, /* i/o: real part */
+ Word32 *im, /* i/o: imag part */
+ Word16 s, /* i : stride real and imag part */
+ Word16 *scale /* i : scalefactor */
+)
+{
+ Word32 x[2 * 64];
+
+ /* FFT for len = FDNS_NPTS */
+ BASOP_fftN2( re, im, RotVector_256, 8, 8, s, 8, x, 64 );
+ s = add( *scale, SCALEFACTOR64 );
+
+ *scale = s;
+ move16();
+
+ return;
+}
+
+#undef WMC_TOOL_SKIP
diff --git a/lib_com/fft_rel.c b/lib_com/fft_rel.c
deleted file mode 100644
index 1d020cabdd7d013f554eeb3d0a697e73682881d9..0000000000000000000000000000000000000000
--- a/lib_com/fft_rel.c
+++ /dev/null
@@ -1,878 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository. All Rights Reserved.
-
- This software is protected by copyright law and by international treaties.
- The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository retain full ownership rights in their respective contributions in
- the software. This notice grants no license of any kind, including but not limited to patent
- license, nor is any license granted by implication, estoppel or otherwise.
-
- Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
- contributions.
-
- This software is provided "AS IS", without any express or implied warranties. The software is in the
- development stage. It is intended exclusively for experts who have experience with such software and
- solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
- and fitness for a particular purpose are hereby disclaimed and excluded.
-
- Any dispute, controversy or claim arising under or in relation to providing this software shall be
- submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
- accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
- the United Nations Convention on Contracts on the International Sales of Goods.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include "prot_fx.h"
-#include "rom_com.h"
-#include "wmc_auto.h"
-
-/*---------------------------------------------------------------------*
- * Local constants
- *---------------------------------------------------------------------*/
-
-#define N_MAX_FFT 1024
-#define N_MAX_DIV2 ( N_MAX_FFT >> 1 )
-#define N_MAX_DIV4 ( N_MAX_DIV2 >> 1 )
-#define INV_SQR2_FX 23170
-#define N_MAX_SAS 256
-/*---------------------------------------------------------------------*
- * fft_rel()
- *
- * Computes the split-radix FFT in place for the real-valued
- * signal x of length n. The algorithm has been ported from
- * the Fortran code of [1].
- *
- * The function needs sine and cosine tables t_sin and t_cos,
- * and the constant N_MAX_FFT. The table entries are defined as
- * sin(2*pi*i) and cos(2*pi*i) for i = 0, 1, ..., N_MAX_FFT-1. The
- * implementation assumes that any entry will not be needed
- * outside the tables. Therefore, N_MAX_FFT and n must be properly
- * set. The function has been tested with the values n = 16,
- * 32, 64, 128, 256, and N_MAX_FFT = 1280.
- *
- * References
- * [1] H.V. Sorensen, D.L. Jones, M.T. Heideman, C.S. Burrus,
- * "Real-valued fast Fourier transform algorithm," IEEE
- * Trans. on Signal Processing, Vol.35, No.6, pp 849-863,
- * 1987.
- *
- * OUTPUT
- * x[0:n-1] Transform coeffients in the order re[0], re[1],
- * ..., re[n/2], im[n/2-1], ..., im[1].
- *---------------------------------------------------------------------*/
-
-void fft_rel(
- float x[], /* i/o: input/output vector */
- const int16_t n, /* i : vector length */
- const int16_t m /* i : log2 of vector length */
-)
-{
- int16_t i, j, k, n1, n2, n4;
- int16_t step;
- float xt, t1, t2;
- float *x0, *x1, *x2;
- float *xi2, *xi3, *xi4, *xi1;
- const float *s, *c;
- const int16_t *idx;
-
- /* !!!! NMAX = 256 is hardcoded here (similar optimizations should be done for NMAX > 256) !!! */
-
- float *x2even, *x2odd;
- float temp[512];
-
- if ( n == 128 || n == 256 || n == 512 )
- {
- idx = fft256_read_indexes;
-
- /* Combined Digit reverse counter & Length two butterflies */
- if ( n == 128 )
- {
- x2 = temp;
- for ( i = 0; i < 64; i++ )
- {
- j = *idx++;
- k = *idx++;
-
- *x2++ = x[j >> 1] + x[k >> 1];
- *x2++ = x[j >> 1] - x[k >> 1];
- }
- }
- else if ( n == 256 )
- {
- x2 = temp;
- for ( i = 0; i < 128; i++ )
- {
- j = *idx++;
- k = *idx++;
-
- *x2++ = x[j] + x[k];
- *x2++ = x[j] - x[k];
- }
- }
- else if ( n == 512 )
- {
- x2even = temp;
- x2odd = temp + 256;
-
- for ( i = 0; i < 128; i++ )
- {
- j = 2 * *idx++;
- k = 2 * *idx++;
-
- *x2even++ = x[j] + x[k];
- *x2even++ = x[j] - x[k];
- *x2odd++ = x[++j] + x[++k];
- *x2odd++ = x[j] - x[k];
- }
- }
-
- /*-----------------------------------------------------------------*
- * 1st Stage Loop has been Unrolled because n4 is '1' and that
- * allows the elimination of the 'for_ (j = 1; j < n4; j++)' loop
- * and the associated pointers initialization.
- * Also, it allows to Put the Data from 'temp' back into 'x' due
- * to the previous Combined Digit Reverse and Length two butterflies
- *-----------------------------------------------------------------*/
-
- /*for_ (k = 2; k < 3; k++)*/
- {
- x0 = temp;
- x1 = x0 + 2;
- x2 = x;
-
- for ( i = 0; i < n; i += 4 )
- {
- *x2++ = *x0++ + *x1; /* x[i] = xt + x[i+n2]; */
- *x2++ = *x0;
- *x2++ = *--x0 - *x1++; /* x[i+n2] = xt - x[i+n2]; */
- *x2++ = -*x1; /* x[i+n2+n4] = -x[i+n2+n4]; */
-
- x0 += 4;
- x1 += 3; /* x1 has already advanced */
- }
- }
- }
- else
- {
- /*-----------------------------------------------------------------*
- * Digit reverse counter
- *-----------------------------------------------------------------*/
-
- j = 0;
- x0 = &x[0];
- for ( i = 0; i < n - 1; i++ )
- {
- if ( i < j )
- {
- xt = x[j];
- x[j] = *x0;
- *x0 = xt;
- }
- x0++;
- k = n / 2;
- while ( k <= j )
- {
- j -= k;
- k = k >> 1;
- }
- j += k;
- }
-
- /*-----------------------------------------------------------------*
- * Length two butterflies
- *-----------------------------------------------------------------*/
-
- x0 = &x[0];
- x1 = &x[1];
- for ( i = 0; i < n / 2; i++ )
- {
- *x1 = *x0 - *x1;
- *x0 = *x0 * 2 - *x1;
-
- x0++;
- x0++;
- x1++;
- x1++;
- }
-
- /*-----------------------------------------------------------------*
- * 1st Stage Loop has been Unrolled because n4 is '1' and that
- * allows the elimination of the 'for_ (j = 1; j < n4; j++)' loop
- * and the associated pointers initialization.
- *-----------------------------------------------------------------*/
-
- /* for_ (k = 2; k < 3; k++) */
- {
- x0 = x;
- x1 = x0 + 2;
-
- for ( i = 0; i < n; i += 4 )
- {
- *x1 = *x0 - *x1; /* x[i+n2] = xt - x[i+n2]; */
- *x0 = *x0 * 2 - *x1++; /* x[i] = xt + x[i+n2]; */
- *x1 = -*x1; /* x[i+n2+n4] = -x[i+n2+n4]; */
-
- x0 += 4;
- x1 += 3; /* x1 has already advanced */
- }
- }
- }
-
- /*-----------------------------------------------------------------*
- * Other butterflies
- *
- * The implementation described in [1] has been changed by using
- * table lookup for evaluating sine and cosine functions. The
- * variable ind and its increment step are needed to access table
- * entries. Note that this implementation assumes n4 to be so
- * small that ind will never exceed the table. Thus the input
- * argument n and the constant N_MAX_FFT must be set properly.
- *-----------------------------------------------------------------*/
-
- n4 = 1;
- n2 = 2;
- n1 = 4;
-
- step = N_MAX_DIV4;
-
- for ( k = 3; k <= m; k++ )
- {
- step >>= 1;
- n4 <<= 1;
- n2 <<= 1;
- n1 <<= 1;
-
- x0 = x;
- x1 = x0 + n2;
- x2 = x1 + n4;
-
- for ( i = 0; i < n; i += n1 )
- {
- *x1 = *x0 - *x1; /* x[i+n2] = xt - x[i+n2]; */
- *x0 = *x0 * 2 - *x1; /* x[i] = xt + x[i+n2]; */
- *x2 = -*x2; /* x[i+n2+n4] = -x[i+n2+n4]; */
-
- s = sincos_t_ext;
- c = s + N_MAX_FFT / 4; /* 1024/4 = 256, 256/4=64 */
- xi1 = x0;
- xi3 = xi1 + n2;
- xi2 = xi3;
- x0 += n1;
- xi4 = x0;
-
- for ( j = 1; j < n4; j++ )
- {
- xi3++;
- xi1++;
- xi4--;
- xi2--;
- c += step;
- s += step; /* autoincrement by ar0 */
-
- t1 = *xi3 * *c + *xi4 * *s; /* t1 = *xi3**(pt_c+ind) + *xi4**(pt_s+ind); */
- t2 = *xi3 * *s - *xi4 * *c; /* t2 = *xi3**(pt_s+ind) - *xi4**(pt_c+ind); */
-
- *xi4 = *xi2 - t2;
- *xi2 = *xi1 - t1;
- *xi1 = *xi1 * 2 - *xi2;
- *xi3 = -2 * t2 - *xi4;
- }
-
- x1 += n1;
- x2 += n1;
- }
- }
-
- return;
-}
-
-void fft_rel_16_32fx(
- Word16 x[], /* i/o: input/output vector Qx */
- Word16 *q_x, /* extra scaling added on speech buffer*/
- Word16 i_subfr,
- const Word16 n, /* i : vector length */
- const Word16 m /* i : log2 of vector length */
-)
-{
- Word16 i, j, k, n1, n2, n4;
- Word16 step;
- Word32 xt, t1, t2;
- Word32 *x0, *x1, *x2;
- const Word16 *s, *c;
- Word32 *xi2, *xi3, *xi4, *xi1;
-
- Word32 fft_bff32[L_FFT];
- Copy_Scale_sig_16_32_no_sat( x, fft_bff32, L_FFT, 0 ); // copying x to fft_bff32 without scaling
-
- /*-----------------------------------------------------------------*
- * Digit reverse counter
- *-----------------------------------------------------------------*/
-
- j = 0;
- move16();
- x0 = &fft_bff32[0]; // Qx
- FOR( i = 0; i < n - 1; i++ )
- {
- IF( LT_16( i, j ) )
- {
- xt = fft_bff32[j]; // Qx
- move32();
- fft_bff32[j] = *x0; // Qx
- move32();
- *x0 = xt; // Qx
- move32();
- }
- x0++;
- k = shr( n, 1 );
- WHILE( ( k <= j ) )
- {
- j = sub( j, k );
- k = shr( k, 1 );
- }
- j = add( j, k );
- }
-
- /*-----------------------------------------------------------------*
- * Length two butterflies
- *-----------------------------------------------------------------*/
-
- x0 = &fft_bff32[0];
- x1 = &fft_bff32[1];
- FOR( i = 0; i < ( n >> 1 ); i++ )
- {
- xt = *x0;
- move32();
- *x0 = L_add( xt, *x1 );
- move32();
- *x1 = L_sub( xt, *x1 );
- move32();
- x0++;
- x0++;
- x1++;
- x1++;
- }
-
- /*-----------------------------------------------------------------*
- * Other butterflies
- *
- * The implementation described in [1] has been changed by using
- * table lookup for evaluating sine and cosine functions. The
- * variable ind and its increment step are needed to access table
- * entries. Note that this implementation assumes n4 to be so
- * small that ind will never exceed the table. Thus the input
- * argument n and the constant N_MAX_SAS must be set properly.
- *-----------------------------------------------------------------*/
-
- n2 = 1;
- move16();
- /* step = N_MAX_SAS/4; */
- FOR( k = 2; k <= m; k++ )
- {
- n4 = n2;
- move16();
- n2 = shl( n4, 1 );
- n1 = shl( n2, 1 );
-
- step = idiv1616( N_MAX_SAS, n1 );
-
- x0 = fft_bff32;
- x1 = fft_bff32 + n2;
- x2 = fft_bff32 + add( n2, n4 );
- FOR( i = 0; i < n; i += n1 )
- {
- xt = *x0;
- move32(); /* xt = x[i]; */
- *x0 = L_add( xt, *x1 );
- move32(); /* x[i] = xt + x[i+n2]; */
- *x1 = L_sub( xt, *x1 );
- move32(); /* x[i+n2] = xt - x[i+n2]; */
- *x2 = L_negate( *x2 );
- move32(); /* x[i+n2+n4] = -x[i+n2+n4]; */
-
-
- s = sincos_t_fx + step; // Q15
- c = s + 64; // Q15
- xi1 = fft_bff32 + add( i, 1 );
- xi3 = xi1 + n2;
- xi2 = xi3 - 2;
- xi4 = xi1 + sub( n1, 2 );
-
- FOR( j = 1; j < n4; j++ )
- {
- t1 = L_add( Mpy_32_16_1( *xi3, *c ), Mpy_32_16_1( *xi4, *s ) ); /* t1 = *xi3**(pt_c+ind) + *xi4**(pt_s+ind); Qx */
- t2 = L_sub( Mpy_32_16_1( *xi3, *s ), Mpy_32_16_1( *xi4, *c ) ); /* t2 = *xi3**(pt_s+ind) - *xi4**(pt_c+ind); Qx */
- *xi4 = L_sub( *xi2, t2 );
- move32();
- *xi3 = L_negate( L_add( *xi2, t2 ) );
- move32();
- *xi2 = L_sub( *xi1, t1 );
- move32();
- *xi1 = L_add( *xi1, t1 );
- move32();
-
- xi4--;
- xi2--;
- xi3++;
- xi1++;
- c += step;
- s += step; /* autoincrement by ar0 */
- }
-
- x0 += n1;
- x1 += n1;
- x2 += n1;
- }
- /* step = shr(step, 1); */
- }
- Word16 norm = L_norm_arr( fft_bff32, L_FFT );
- IF( i_subfr == 0 )
- {
- Copy_Scale_sig32_16( fft_bff32, x, L_FFT, norm );
- *q_x = sub( norm, 16 );
- move16();
- }
- ELSE
- {
- IF( LT_16( sub( norm, 16 ), *q_x ) )
- {
- scale_sig( x - L_FFT, L_FFT, sub( sub( norm, 16 ), *q_x ) );
- Copy_Scale_sig32_16( fft_bff32, x, L_FFT, norm );
- *q_x = sub( norm, 16 );
- move16();
- }
- ELSE
- {
- Copy_Scale_sig32_16( fft_bff32, x, L_FFT, add( 16, *q_x ) );
- }
- }
-
- return;
-}
-
-void fft_rel_fx(
- Word16 x[], /* i/o: input/output vector Qx */
- const Word16 n, /* i : vector length */
- const Word16 m /* i : log2 of vector length */
-)
-{
- Word16 i, j, k, n1, n2, n4;
- Word16 step;
- Word16 xt, t1, t2;
- Word16 *x0, *x1, *x2;
- const Word16 *s, *c;
- Word16 *xi2, *xi3, *xi4, *xi1;
-#ifdef BASOP_NOGLOB_DECLARE_LOCAL
- Flag Overflow = 0;
- move32();
-#endif
-
-
- /*-----------------------------------------------------------------*
- * Digit reverse counter
- *-----------------------------------------------------------------*/
-
- j = 0;
- move16();
- x0 = &x[0]; // Qx
- move16();
- FOR( i = 0; i < n - 1; i++ )
- {
- IF( LT_16( i, j ) )
- {
- xt = x[j]; // Qx
- move16();
- x[j] = *x0; // Qx
- move16();
- *x0 = xt; // Qx
- move16();
- }
- x0++;
- k = shr( n, 1 );
- WHILE( ( k <= j ) )
- {
- j = sub( j, k );
- k = shr( k, 1 );
- }
- j = add( j, k );
- }
-
- /*-----------------------------------------------------------------*
- * Length two butterflies
- *-----------------------------------------------------------------*/
-
- x0 = &x[0];
- move16();
- x1 = &x[1];
- move16();
- FOR( i = 0; i < ( n >> 1 ); i++ )
- {
- xt = *x0;
- move16();
- *x0 = add_o( xt, *x1, &Overflow );
- move16();
- *x1 = sub_o( xt, *x1, &Overflow );
- move16();
- x0++;
- x0++;
- x1++;
- x1++;
- }
-
- /*-----------------------------------------------------------------*
- * Other butterflies
- *
- * The implementation described in [1] has been changed by using
- * table lookup for evaluating sine and cosine functions. The
- * variable ind and its increment step are needed to access table
- * entries. Note that this implementation assumes n4 to be so
- * small that ind will never exceed the table. Thus the input
- * argument n and the constant N_MAX_SAS must be set properly.
- *-----------------------------------------------------------------*/
-
- n2 = 1;
- move16();
- /* step = N_MAX_SAS/4; */
- FOR( k = 2; k <= m; k++ )
- {
- n4 = n2;
- move16();
- n2 = shl( n4, 1 );
- n1 = shl( n2, 1 );
-
- step = idiv1616( N_MAX_SAS, n1 );
-
- x0 = x;
- x1 = x + n2;
- x2 = x + add( n2, n4 );
- FOR( i = 0; i < n; i += n1 )
- {
- xt = *x0;
- move16(); /* xt = x[i]; */
- *x0 = add_o( xt, *x1, &Overflow );
- move16(); /* x[i] = xt + x[i+n2]; */
- *x1 = sub_o( xt, *x1, &Overflow );
- move16(); /* x[i+n2] = xt - x[i+n2]; */
- *x2 = negate( *x2 );
- move16(); /* x[i+n2+n4] = -x[i+n2+n4]; */
-
-
- s = sincos_t_fx + step; // Q15
- c = s + 64; // Q15
- xi1 = x + add( i, 1 );
- xi3 = xi1 + n2;
- xi2 = xi3 - 2;
- xi4 = xi1 + sub( n1, 2 );
-
- FOR( j = 1; j < n4; j++ )
- {
- 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 );
- move16();
- *xi3 = negate( add_o( *xi2, t2, &Overflow ) );
- move16();
- *xi2 = sub_o( *xi1, t1, &Overflow );
- move16();
- *xi1 = add_o( *xi1, t1, &Overflow );
- move16();
-
- xi4--;
- xi2--;
- xi3++;
- xi1++;
- c += step;
- s += step; /* autoincrement by ar0 */
- }
-
- x0 += n1;
- x1 += n1;
- x2 += n1;
- }
- /* step = shr(step, 1); */
- }
-
- return;
-}
-
-void fft_rel_fx32(
- Word32 x[], /* i/o: input/output vector Qx */
- const Word16 n, /* i : vector length */
- const Word16 m /* i : log2 of vector length */
-)
-{
- Word16 i, j, k, n1, n2, n4;
- Word16 step;
- Word32 xt, t1, t2;
- Word32 *x0, *x1, *x2;
- Word32 *xi2, *xi3, *xi4, *xi1;
- const Word16 *s, *c;
- const Word16 *idx;
-
- /* !!!! NMAX = 256 is hardcoded here (similar optimizations should be done for NMAX > 256) !!! */
-
- Word32 *x2even, *x2odd;
- Word32 temp[512];
-
- test();
- test();
- IF( EQ_16( n, 128 ) || EQ_16( n, 256 ) || EQ_16( n, 512 ) )
- {
- idx = fft256_read_indexes;
-
- /* Combined Digit reverse counter & Length two butterflies */
- IF( EQ_16( n, 128 ) )
- {
- x2 = temp;
- FOR( i = 0; i < 64; i++ )
- {
- j = *idx++;
- move16();
- k = *idx++;
- move16();
-
- *x2++ = L_add( x[( j >> 1 )], x[( k >> 1 )] ); // Qx
- move16();
- *x2++ = L_sub( x[( j >> 1 )], x[( k >> 1 )] ); // Qx
- move16();
- }
- }
- ELSE IF( EQ_16( n, 256 ) )
- {
- x2 = temp;
- FOR( i = 0; i < 128; i++ )
- {
- j = *idx++;
- move16();
- k = *idx++;
- move16();
-
- *x2++ = L_add( x[j], x[k] ); // Qx
- move16();
- *x2++ = L_sub( x[j], x[k] ); // Qx
- move16();
- }
- }
- ELSE IF( EQ_16( n, 512 ) )
- {
- x2even = temp;
- x2odd = temp + 256;
-
- FOR( i = 0; i < 128; i++ )
- {
- j = shl( *idx, 1 );
- idx++;
- k = shl( *idx, 1 );
- idx++;
-
- *x2even++ = L_add( x[j], x[k] ); // Qx
- move16();
- *x2even++ = L_sub( x[j], x[k] ); // Qx
- move16();
- j = add( j, 1 );
- k = add( k, 1 );
- *x2odd++ = L_add( x[j], x[k] ); // Qx
- move16();
- *x2odd++ = L_sub( x[j], x[k] ); // Qx
- move16();
- }
- }
-
- /*-----------------------------------------------------------------*
- * 1st Stage Loop has been Unrolled because n4 is '1' and that
- * allows the elimination of the 'for_ (j = 1; j < n4; j++)' loop
- * and the associated pointers initialization.
- * Also, it allows to Put the Data from 'temp' back into 'x' due
- * to the previous Combined Digit Reverse and Length two butterflies
- *-----------------------------------------------------------------*/
-
- /*for_ (k = 2; k < 3; k++)*/
- {
- x0 = temp;
- x1 = x0 + 2;
- x2 = x; // Qx
-
- FOR( i = 0; i < n; i += 4 )
- {
- *x2++ = L_add( *x0++, *x1 ); /* x[i] = xt + x[i+n2]; */
- move16();
- *x2++ = *x0;
- move16();
- x0--;
- *x2++ = L_sub( *x0, *x1 ); /* x[i+n2] = xt - x[i+n2]; */
- move16();
- x1++;
- *x2++ = L_negate( *x1 ); /* x[i+n2+n4] = -x[i+n2+n4]; */
- move16();
-
- x0 += 4;
- x1 += 3; /* x1 has already advanced */
- }
- }
- }
- ELSE
- {
- /*-----------------------------------------------------------------*
- * Digit reverse counter
- *-----------------------------------------------------------------*/
-
- j = 0;
- move16();
- x0 = &x[0]; // Qx
- FOR( i = 0; i < ( n - 1 ); i++ )
- {
- IF( LT_16( i, j ) )
- {
- xt = x[j]; // Qx
- move32();
- x[j] = *x0;
- move32();
- *x0 = xt;
- move32();
- }
- x0++;
- k = shr( n, 1 );
- WHILE( ( k <= j ) )
- {
- j = sub( j, k );
- k = shr( k, 1 );
- }
- j = add( j, k );
- }
-
- /*-----------------------------------------------------------------*
- * Length two butterflies
- *-----------------------------------------------------------------*/
-
- x0 = &x[0]; // Qx
- x1 = &x[1]; // Qx
- FOR( i = 0; i < ( n >> 1 ); i++ )
- {
- *x1 = L_sub( *x0, *x1 ); // Qx
- move32();
- *x0 = L_sub( L_shl( *x0, 1 ), *x1 ); //*x0 * 2 - *x1 (Qx)
- move32();
-
- x0++;
- x0++;
- x1++;
- x1++;
- }
-
- /*-----------------------------------------------------------------*
- * 1st Stage Loop has been Unrolled because n4 is '1' and that
- * allows the elimination of the 'for_ (j = 1; j < n4; j++)' loop
- * and the associated pointers initialization.
- *-----------------------------------------------------------------*/
-
- /* for_ (k = 2; k < 3; k++) */
- {
- x0 = x; // Qx
- x1 = x0 + 2;
-
- FOR( i = 0; i < n; i += 4 )
- {
- *x1 = L_sub( *x0, *x1 ); /* x[i+n2] = xt - x[i+n2]; Qx*/
- move32();
- *x0 = L_sub( L_shl( *x0, 1 ), *x1++ ); /* x[i] = xt + x[i+n2]; */ /**x0 * 2 - *x1 (Qx)*/
- move32();
- *x1 = L_negate( *x1 ); /* x[i+n2+n4] = -x[i+n2+n4]; Qx*/
- move32();
-
- x0 += 4;
- x1 += 3; /* x1 has already advanced */
- }
- }
- }
-
- /*-----------------------------------------------------------------*
- * Other butterflies
- *
- * The implementation described in [1] has been changed by using
- * table lookup for evaluating sine and cosine functions. The
- * variable ind and its increment step are needed to access table
- * entries. Note that this implementation assumes n4 to be so
- * small that ind will never exceed the table. Thus the input
- * argument n and the constant N_MAX_FFT must be set properly.
- *-----------------------------------------------------------------*/
-
- n4 = 1;
- move16();
- n2 = 2;
- move16();
- n1 = 4;
- move16();
-
- step = N_MAX_DIV4;
- move16();
-
- FOR( k = 3; k <= m; k++ )
- {
- step = shr( step, 1 );
- n4 = shl( n4, 1 );
- n2 = shl( n2, 1 );
- n1 = shl( n1, 1 );
-
- x0 = x;
- x1 = x0 + n2;
- x2 = x1 + n4;
-
- FOR( i = 0; i < n; i += n1 )
- {
- *x1 = L_sub( *x0, *x1 ); /* x[i+n2] = xt - x[i+n2]; */
- move32();
- *x0 = L_sub( L_shl( *x0, 1 ), *x1 ); /* x[i] = xt + x[i+n2]; */ /**x0 * 2 - *x1 (Qx)*/
- move32();
- *x2 = L_negate( *x2 ); /* x[i+n2+n4] = -x[i+n2+n4]; Qx */
- move32();
-
- s = sincos_t_ext_fx; // Q15
- c = s + N_MAX_FFT / 4; /* 1024/4 = 256, 256/4=64 Q15*/
- xi1 = x0;
- xi3 = xi1 + n2;
- xi2 = xi3;
- x0 += n1;
- xi4 = x0;
-
- FOR( j = 1; j < n4; j++ )
- {
- xi3++;
- xi1++;
- xi4--;
- xi2--;
- c += step;
- s += step; /* autoincrement by ar0 */
-
- t1 = L_add( Mpy_32_16_1( *xi3, *c ), Mpy_32_16_1( *xi4, *s ) ); /* t1 = *xi3**(pt_c+ind) + *xi4**(pt_s+ind); Qx*/
- t2 = L_sub( Mpy_32_16_1( *xi3, *s ), Mpy_32_16_1( *xi4, *c ) ); /* t2 = *xi3**(pt_s+ind) - *xi4**(pt_c+ind); Qx*/
-
- *xi4 = L_sub( *xi2, t2 );
- move32();
- *xi2 = L_sub( *xi1, t1 );
- move32();
- *xi1 = L_sub( L_shl( *xi1, 1 ), *xi2 ); // Qx
- move32();
- *xi3 = L_negate( L_add( L_shl( t2, 1 ), *xi4 ) ); // Qx
- move32();
- }
-
- x1 += n1;
- x2 += n1;
- }
- }
-
- return;
-}
diff --git a/lib_com/fft_rel_fx.c b/lib_com/fft_rel_fx.c
index 5461ce55baae37f1bfdd25c36fac6607fd69e0c1..a0905cc1689e11358c49e235afd5c5c498cbdd96 100644
--- a/lib_com/fft_rel_fx.c
+++ b/lib_com/fft_rel_fx.c
@@ -2,11 +2,24 @@
EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
====================================================================================*/
+#include
#include "options.h" /* Compilation switches */
#include "prot_fx.h" /* Function prototypes */
#include "rom_com.h" /* Static table prototypes */
#include "stl.h"
#include "stdint.h"
+#include "wmc_auto.h"
+
+/*---------------------------------------------------------------------*
+ * Local constants
+ *---------------------------------------------------------------------*/
+
+#define N_MAX_FFT 1024
+#define N_MAX_DIV2 ( N_MAX_FFT >> 1 )
+#define N_MAX_DIV4 ( N_MAX_DIV2 >> 1 )
+#define INV_SQR2_FX 23170
+#define N_MAX_SAS 256
+
/*------------------------------------------------------------------
*
* This is an implementation of decimation-in-time FFT algorithm for
@@ -427,3 +440,832 @@ void r_fft_fx_lc(
c_fft_fx( phs_tbl, SIZE, NUM_STAGE, temp, out_ptr, isign );
}
}
+
+
+/*---------------------------------------------------------------------*
+ * fft_rel()
+ *
+ * Computes the split-radix FFT in place for the real-valued
+ * signal x of length n. The algorithm has been ported from
+ * the Fortran code of [1].
+ *
+ * The function needs sine and cosine tables t_sin and t_cos,
+ * and the constant N_MAX_FFT. The table entries are defined as
+ * sin(2*pi*i) and cos(2*pi*i) for i = 0, 1, ..., N_MAX_FFT-1. The
+ * implementation assumes that any entry will not be needed
+ * outside the tables. Therefore, N_MAX_FFT and n must be properly
+ * set. The function has been tested with the values n = 16,
+ * 32, 64, 128, 256, and N_MAX_FFT = 1280.
+ *
+ * References
+ * [1] H.V. Sorensen, D.L. Jones, M.T. Heideman, C.S. Burrus,
+ * "Real-valued fast Fourier transform algorithm," IEEE
+ * Trans. on Signal Processing, Vol.35, No.6, pp 849-863,
+ * 1987.
+ *
+ * OUTPUT
+ * x[0:n-1] Transform coeffients in the order re[0], re[1],
+ * ..., re[n/2], im[n/2-1], ..., im[1].
+ *---------------------------------------------------------------------*/
+
+void fft_rel(
+ float x[], /* i/o: input/output vector */
+ const int16_t n, /* i : vector length */
+ const int16_t m /* i : log2 of vector length */
+)
+{
+ int16_t i, j, k, n1, n2, n4;
+ int16_t step;
+ float xt, t1, t2;
+ float *x0, *x1, *x2;
+ float *xi2, *xi3, *xi4, *xi1;
+ const float *s, *c;
+ const int16_t *idx;
+
+ /* !!!! NMAX = 256 is hardcoded here (similar optimizations should be done for NMAX > 256) !!! */
+
+ float *x2even, *x2odd;
+ float temp[512];
+
+ if ( n == 128 || n == 256 || n == 512 )
+ {
+ idx = fft256_read_indexes;
+
+ /* Combined Digit reverse counter & Length two butterflies */
+ if ( n == 128 )
+ {
+ x2 = temp;
+ for ( i = 0; i < 64; i++ )
+ {
+ j = *idx++;
+ k = *idx++;
+
+ *x2++ = x[j >> 1] + x[k >> 1];
+ *x2++ = x[j >> 1] - x[k >> 1];
+ }
+ }
+ else if ( n == 256 )
+ {
+ x2 = temp;
+ for ( i = 0; i < 128; i++ )
+ {
+ j = *idx++;
+ k = *idx++;
+
+ *x2++ = x[j] + x[k];
+ *x2++ = x[j] - x[k];
+ }
+ }
+ else if ( n == 512 )
+ {
+ x2even = temp;
+ x2odd = temp + 256;
+
+ for ( i = 0; i < 128; i++ )
+ {
+ j = 2 * *idx++;
+ k = 2 * *idx++;
+
+ *x2even++ = x[j] + x[k];
+ *x2even++ = x[j] - x[k];
+ *x2odd++ = x[++j] + x[++k];
+ *x2odd++ = x[j] - x[k];
+ }
+ }
+
+ /*-----------------------------------------------------------------*
+ * 1st Stage Loop has been Unrolled because n4 is '1' and that
+ * allows the elimination of the 'for_ (j = 1; j < n4; j++)' loop
+ * and the associated pointers initialization.
+ * Also, it allows to Put the Data from 'temp' back into 'x' due
+ * to the previous Combined Digit Reverse and Length two butterflies
+ *-----------------------------------------------------------------*/
+
+ /*for_ (k = 2; k < 3; k++)*/
+ {
+ x0 = temp;
+ x1 = x0 + 2;
+ x2 = x;
+
+ for ( i = 0; i < n; i += 4 )
+ {
+ *x2++ = *x0++ + *x1; /* x[i] = xt + x[i+n2]; */
+ *x2++ = *x0;
+ *x2++ = *--x0 - *x1++; /* x[i+n2] = xt - x[i+n2]; */
+ *x2++ = -*x1; /* x[i+n2+n4] = -x[i+n2+n4]; */
+
+ x0 += 4;
+ x1 += 3; /* x1 has already advanced */
+ }
+ }
+ }
+ else
+ {
+ /*-----------------------------------------------------------------*
+ * Digit reverse counter
+ *-----------------------------------------------------------------*/
+
+ j = 0;
+ x0 = &x[0];
+ for ( i = 0; i < n - 1; i++ )
+ {
+ if ( i < j )
+ {
+ xt = x[j];
+ x[j] = *x0;
+ *x0 = xt;
+ }
+ x0++;
+ k = n / 2;
+ while ( k <= j )
+ {
+ j -= k;
+ k = k >> 1;
+ }
+ j += k;
+ }
+
+ /*-----------------------------------------------------------------*
+ * Length two butterflies
+ *-----------------------------------------------------------------*/
+
+ x0 = &x[0];
+ x1 = &x[1];
+ for ( i = 0; i < n / 2; i++ )
+ {
+ *x1 = *x0 - *x1;
+ *x0 = *x0 * 2 - *x1;
+
+ x0++;
+ x0++;
+ x1++;
+ x1++;
+ }
+
+ /*-----------------------------------------------------------------*
+ * 1st Stage Loop has been Unrolled because n4 is '1' and that
+ * allows the elimination of the 'for_ (j = 1; j < n4; j++)' loop
+ * and the associated pointers initialization.
+ *-----------------------------------------------------------------*/
+
+ /* for_ (k = 2; k < 3; k++) */
+ {
+ x0 = x;
+ x1 = x0 + 2;
+
+ for ( i = 0; i < n; i += 4 )
+ {
+ *x1 = *x0 - *x1; /* x[i+n2] = xt - x[i+n2]; */
+ *x0 = *x0 * 2 - *x1++; /* x[i] = xt + x[i+n2]; */
+ *x1 = -*x1; /* x[i+n2+n4] = -x[i+n2+n4]; */
+
+ x0 += 4;
+ x1 += 3; /* x1 has already advanced */
+ }
+ }
+ }
+
+ /*-----------------------------------------------------------------*
+ * Other butterflies
+ *
+ * The implementation described in [1] has been changed by using
+ * table lookup for evaluating sine and cosine functions. The
+ * variable ind and its increment step are needed to access table
+ * entries. Note that this implementation assumes n4 to be so
+ * small that ind will never exceed the table. Thus the input
+ * argument n and the constant N_MAX_FFT must be set properly.
+ *-----------------------------------------------------------------*/
+
+ n4 = 1;
+ n2 = 2;
+ n1 = 4;
+
+ step = N_MAX_DIV4;
+
+ for ( k = 3; k <= m; k++ )
+ {
+ step >>= 1;
+ n4 <<= 1;
+ n2 <<= 1;
+ n1 <<= 1;
+
+ x0 = x;
+ x1 = x0 + n2;
+ x2 = x1 + n4;
+
+ for ( i = 0; i < n; i += n1 )
+ {
+ *x1 = *x0 - *x1; /* x[i+n2] = xt - x[i+n2]; */
+ *x0 = *x0 * 2 - *x1; /* x[i] = xt + x[i+n2]; */
+ *x2 = -*x2; /* x[i+n2+n4] = -x[i+n2+n4]; */
+
+ s = sincos_t_ext;
+ c = s + N_MAX_FFT / 4; /* 1024/4 = 256, 256/4=64 */
+ xi1 = x0;
+ xi3 = xi1 + n2;
+ xi2 = xi3;
+ x0 += n1;
+ xi4 = x0;
+
+ for ( j = 1; j < n4; j++ )
+ {
+ xi3++;
+ xi1++;
+ xi4--;
+ xi2--;
+ c += step;
+ s += step; /* autoincrement by ar0 */
+
+ t1 = *xi3 * *c + *xi4 * *s; /* t1 = *xi3**(pt_c+ind) + *xi4**(pt_s+ind); */
+ t2 = *xi3 * *s - *xi4 * *c; /* t2 = *xi3**(pt_s+ind) - *xi4**(pt_c+ind); */
+
+ *xi4 = *xi2 - t2;
+ *xi2 = *xi1 - t1;
+ *xi1 = *xi1 * 2 - *xi2;
+ *xi3 = -2 * t2 - *xi4;
+ }
+
+ x1 += n1;
+ x2 += n1;
+ }
+ }
+
+ return;
+}
+
+void fft_rel_16_32fx(
+ Word16 x[], /* i/o: input/output vector Qx */
+ Word16 *q_x, /* extra scaling added on speech buffer*/
+ Word16 i_subfr,
+ const Word16 n, /* i : vector length */
+ const Word16 m /* i : log2 of vector length */
+)
+{
+ Word16 i, j, k, n1, n2, n4;
+ Word16 step;
+ Word32 xt, t1, t2;
+ Word32 *x0, *x1, *x2;
+ const Word16 *s, *c;
+ Word32 *xi2, *xi3, *xi4, *xi1;
+
+ Word32 fft_bff32[L_FFT];
+ Copy_Scale_sig_16_32_no_sat( x, fft_bff32, L_FFT, 0 ); // copying x to fft_bff32 without scaling
+
+ /*-----------------------------------------------------------------*
+ * Digit reverse counter
+ *-----------------------------------------------------------------*/
+
+ j = 0;
+ move16();
+ x0 = &fft_bff32[0]; // Qx
+ FOR( i = 0; i < n - 1; i++ )
+ {
+ IF( LT_16( i, j ) )
+ {
+ xt = fft_bff32[j]; // Qx
+ move32();
+ fft_bff32[j] = *x0; // Qx
+ move32();
+ *x0 = xt; // Qx
+ move32();
+ }
+ x0++;
+ k = shr( n, 1 );
+ WHILE( ( k <= j ) )
+ {
+ j = sub( j, k );
+ k = shr( k, 1 );
+ }
+ j = add( j, k );
+ }
+
+ /*-----------------------------------------------------------------*
+ * Length two butterflies
+ *-----------------------------------------------------------------*/
+
+ x0 = &fft_bff32[0];
+ x1 = &fft_bff32[1];
+ FOR( i = 0; i < ( n >> 1 ); i++ )
+ {
+ xt = *x0;
+ move32();
+ *x0 = L_add( xt, *x1 );
+ move32();
+ *x1 = L_sub( xt, *x1 );
+ move32();
+ x0++;
+ x0++;
+ x1++;
+ x1++;
+ }
+
+ /*-----------------------------------------------------------------*
+ * Other butterflies
+ *
+ * The implementation described in [1] has been changed by using
+ * table lookup for evaluating sine and cosine functions. The
+ * variable ind and its increment step are needed to access table
+ * entries. Note that this implementation assumes n4 to be so
+ * small that ind will never exceed the table. Thus the input
+ * argument n and the constant N_MAX_SAS must be set properly.
+ *-----------------------------------------------------------------*/
+
+ n2 = 1;
+ move16();
+ /* step = N_MAX_SAS/4; */
+ FOR( k = 2; k <= m; k++ )
+ {
+ n4 = n2;
+ move16();
+ n2 = shl( n4, 1 );
+ n1 = shl( n2, 1 );
+
+ step = idiv1616( N_MAX_SAS, n1 );
+
+ x0 = fft_bff32;
+ x1 = fft_bff32 + n2;
+ x2 = fft_bff32 + add( n2, n4 );
+ FOR( i = 0; i < n; i += n1 )
+ {
+ xt = *x0;
+ move32(); /* xt = x[i]; */
+ *x0 = L_add( xt, *x1 );
+ move32(); /* x[i] = xt + x[i+n2]; */
+ *x1 = L_sub( xt, *x1 );
+ move32(); /* x[i+n2] = xt - x[i+n2]; */
+ *x2 = L_negate( *x2 );
+ move32(); /* x[i+n2+n4] = -x[i+n2+n4]; */
+
+
+ s = sincos_t_fx + step; // Q15
+ c = s + 64; // Q15
+ xi1 = fft_bff32 + add( i, 1 );
+ xi3 = xi1 + n2;
+ xi2 = xi3 - 2;
+ xi4 = xi1 + sub( n1, 2 );
+
+ FOR( j = 1; j < n4; j++ )
+ {
+ t1 = L_add( Mpy_32_16_1( *xi3, *c ), Mpy_32_16_1( *xi4, *s ) ); /* t1 = *xi3**(pt_c+ind) + *xi4**(pt_s+ind); Qx */
+ t2 = L_sub( Mpy_32_16_1( *xi3, *s ), Mpy_32_16_1( *xi4, *c ) ); /* t2 = *xi3**(pt_s+ind) - *xi4**(pt_c+ind); Qx */
+ *xi4 = L_sub( *xi2, t2 );
+ move32();
+ *xi3 = L_negate( L_add( *xi2, t2 ) );
+ move32();
+ *xi2 = L_sub( *xi1, t1 );
+ move32();
+ *xi1 = L_add( *xi1, t1 );
+ move32();
+
+ xi4--;
+ xi2--;
+ xi3++;
+ xi1++;
+ c += step;
+ s += step; /* autoincrement by ar0 */
+ }
+
+ x0 += n1;
+ x1 += n1;
+ x2 += n1;
+ }
+ /* step = shr(step, 1); */
+ }
+ Word16 norm = L_norm_arr( fft_bff32, L_FFT );
+ IF( i_subfr == 0 )
+ {
+ Copy_Scale_sig32_16( fft_bff32, x, L_FFT, norm );
+ *q_x = sub( norm, 16 );
+ move16();
+ }
+ ELSE
+ {
+ IF( LT_16( sub( norm, 16 ), *q_x ) )
+ {
+ scale_sig( x - L_FFT, L_FFT, sub( sub( norm, 16 ), *q_x ) );
+ Copy_Scale_sig32_16( fft_bff32, x, L_FFT, norm );
+ *q_x = sub( norm, 16 );
+ move16();
+ }
+ ELSE
+ {
+ Copy_Scale_sig32_16( fft_bff32, x, L_FFT, add( 16, *q_x ) );
+ }
+ }
+
+ return;
+}
+
+void fft_rel_fx(
+ Word16 x[], /* i/o: input/output vector Qx */
+ const Word16 n, /* i : vector length */
+ const Word16 m /* i : log2 of vector length */
+)
+{
+ Word16 i, j, k, n1, n2, n4;
+ Word16 step;
+ Word16 xt, t1, t2;
+ Word16 *x0, *x1, *x2;
+ const Word16 *s, *c;
+ Word16 *xi2, *xi3, *xi4, *xi1;
+#ifdef BASOP_NOGLOB_DECLARE_LOCAL
+ Flag Overflow = 0;
+ move32();
+#endif
+
+
+ /*-----------------------------------------------------------------*
+ * Digit reverse counter
+ *-----------------------------------------------------------------*/
+
+ j = 0;
+ move16();
+ x0 = &x[0]; // Qx
+ move16();
+ FOR( i = 0; i < n - 1; i++ )
+ {
+ IF( LT_16( i, j ) )
+ {
+ xt = x[j]; // Qx
+ move16();
+ x[j] = *x0; // Qx
+ move16();
+ *x0 = xt; // Qx
+ move16();
+ }
+ x0++;
+ k = shr( n, 1 );
+ WHILE( ( k <= j ) )
+ {
+ j = sub( j, k );
+ k = shr( k, 1 );
+ }
+ j = add( j, k );
+ }
+
+ /*-----------------------------------------------------------------*
+ * Length two butterflies
+ *-----------------------------------------------------------------*/
+
+ x0 = &x[0];
+ move16();
+ x1 = &x[1];
+ move16();
+ FOR( i = 0; i < ( n >> 1 ); i++ )
+ {
+ xt = *x0;
+ move16();
+ *x0 = add_o( xt, *x1, &Overflow );
+ move16();
+ *x1 = sub_o( xt, *x1, &Overflow );
+ move16();
+ x0++;
+ x0++;
+ x1++;
+ x1++;
+ }
+
+ /*-----------------------------------------------------------------*
+ * Other butterflies
+ *
+ * The implementation described in [1] has been changed by using
+ * table lookup for evaluating sine and cosine functions. The
+ * variable ind and its increment step are needed to access table
+ * entries. Note that this implementation assumes n4 to be so
+ * small that ind will never exceed the table. Thus the input
+ * argument n and the constant N_MAX_SAS must be set properly.
+ *-----------------------------------------------------------------*/
+
+ n2 = 1;
+ move16();
+ /* step = N_MAX_SAS/4; */
+ FOR( k = 2; k <= m; k++ )
+ {
+ n4 = n2;
+ move16();
+ n2 = shl( n4, 1 );
+ n1 = shl( n2, 1 );
+
+ step = idiv1616( N_MAX_SAS, n1 );
+
+ x0 = x;
+ x1 = x + n2;
+ x2 = x + add( n2, n4 );
+ FOR( i = 0; i < n; i += n1 )
+ {
+ xt = *x0;
+ move16(); /* xt = x[i]; */
+ *x0 = add_o( xt, *x1, &Overflow );
+ move16(); /* x[i] = xt + x[i+n2]; */
+ *x1 = sub_o( xt, *x1, &Overflow );
+ move16(); /* x[i+n2] = xt - x[i+n2]; */
+ *x2 = negate( *x2 );
+ move16(); /* x[i+n2+n4] = -x[i+n2+n4]; */
+
+
+ s = sincos_t_fx + step; // Q15
+ c = s + 64; // Q15
+ xi1 = x + add( i, 1 );
+ xi3 = xi1 + n2;
+ xi2 = xi3 - 2;
+ xi4 = xi1 + sub( n1, 2 );
+
+ FOR( j = 1; j < n4; j++ )
+ {
+ 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 );
+ move16();
+ *xi3 = negate( add_o( *xi2, t2, &Overflow ) );
+ move16();
+ *xi2 = sub_o( *xi1, t1, &Overflow );
+ move16();
+ *xi1 = add_o( *xi1, t1, &Overflow );
+ move16();
+
+ xi4--;
+ xi2--;
+ xi3++;
+ xi1++;
+ c += step;
+ s += step; /* autoincrement by ar0 */
+ }
+
+ x0 += n1;
+ x1 += n1;
+ x2 += n1;
+ }
+ /* step = shr(step, 1); */
+ }
+
+ return;
+}
+
+void fft_rel_fx32(
+ Word32 x[], /* i/o: input/output vector Qx */
+ const Word16 n, /* i : vector length */
+ const Word16 m /* i : log2 of vector length */
+)
+{
+ Word16 i, j, k, n1, n2, n4;
+ Word16 step;
+ Word32 xt, t1, t2;
+ Word32 *x0, *x1, *x2;
+ Word32 *xi2, *xi3, *xi4, *xi1;
+ const Word16 *s, *c;
+ const Word16 *idx;
+
+ /* !!!! NMAX = 256 is hardcoded here (similar optimizations should be done for NMAX > 256) !!! */
+
+ Word32 *x2even, *x2odd;
+ Word32 temp[512];
+
+ test();
+ test();
+ IF( EQ_16( n, 128 ) || EQ_16( n, 256 ) || EQ_16( n, 512 ) )
+ {
+ idx = fft256_read_indexes;
+
+ /* Combined Digit reverse counter & Length two butterflies */
+ IF( EQ_16( n, 128 ) )
+ {
+ x2 = temp;
+ FOR( i = 0; i < 64; i++ )
+ {
+ j = *idx++;
+ move16();
+ k = *idx++;
+ move16();
+
+ *x2++ = L_add( x[( j >> 1 )], x[( k >> 1 )] ); // Qx
+ move16();
+ *x2++ = L_sub( x[( j >> 1 )], x[( k >> 1 )] ); // Qx
+ move16();
+ }
+ }
+ ELSE IF( EQ_16( n, 256 ) )
+ {
+ x2 = temp;
+ FOR( i = 0; i < 128; i++ )
+ {
+ j = *idx++;
+ move16();
+ k = *idx++;
+ move16();
+
+ *x2++ = L_add( x[j], x[k] ); // Qx
+ move16();
+ *x2++ = L_sub( x[j], x[k] ); // Qx
+ move16();
+ }
+ }
+ ELSE IF( EQ_16( n, 512 ) )
+ {
+ x2even = temp;
+ x2odd = temp + 256;
+
+ FOR( i = 0; i < 128; i++ )
+ {
+ j = shl( *idx, 1 );
+ idx++;
+ k = shl( *idx, 1 );
+ idx++;
+
+ *x2even++ = L_add( x[j], x[k] ); // Qx
+ move16();
+ *x2even++ = L_sub( x[j], x[k] ); // Qx
+ move16();
+ j = add( j, 1 );
+ k = add( k, 1 );
+ *x2odd++ = L_add( x[j], x[k] ); // Qx
+ move16();
+ *x2odd++ = L_sub( x[j], x[k] ); // Qx
+ move16();
+ }
+ }
+
+ /*-----------------------------------------------------------------*
+ * 1st Stage Loop has been Unrolled because n4 is '1' and that
+ * allows the elimination of the 'for_ (j = 1; j < n4; j++)' loop
+ * and the associated pointers initialization.
+ * Also, it allows to Put the Data from 'temp' back into 'x' due
+ * to the previous Combined Digit Reverse and Length two butterflies
+ *-----------------------------------------------------------------*/
+
+ /*for_ (k = 2; k < 3; k++)*/
+ {
+ x0 = temp;
+ x1 = x0 + 2;
+ x2 = x; // Qx
+
+ FOR( i = 0; i < n; i += 4 )
+ {
+ *x2++ = L_add( *x0++, *x1 ); /* x[i] = xt + x[i+n2]; */
+ move16();
+ *x2++ = *x0;
+ move16();
+ x0--;
+ *x2++ = L_sub( *x0, *x1 ); /* x[i+n2] = xt - x[i+n2]; */
+ move16();
+ x1++;
+ *x2++ = L_negate( *x1 ); /* x[i+n2+n4] = -x[i+n2+n4]; */
+ move16();
+
+ x0 += 4;
+ x1 += 3; /* x1 has already advanced */
+ }
+ }
+ }
+ ELSE
+ {
+ /*-----------------------------------------------------------------*
+ * Digit reverse counter
+ *-----------------------------------------------------------------*/
+
+ j = 0;
+ move16();
+ x0 = &x[0]; // Qx
+ FOR( i = 0; i < ( n - 1 ); i++ )
+ {
+ IF( LT_16( i, j ) )
+ {
+ xt = x[j]; // Qx
+ move32();
+ x[j] = *x0;
+ move32();
+ *x0 = xt;
+ move32();
+ }
+ x0++;
+ k = shr( n, 1 );
+ WHILE( ( k <= j ) )
+ {
+ j = sub( j, k );
+ k = shr( k, 1 );
+ }
+ j = add( j, k );
+ }
+
+ /*-----------------------------------------------------------------*
+ * Length two butterflies
+ *-----------------------------------------------------------------*/
+
+ x0 = &x[0]; // Qx
+ x1 = &x[1]; // Qx
+ FOR( i = 0; i < ( n >> 1 ); i++ )
+ {
+ *x1 = L_sub( *x0, *x1 ); // Qx
+ move32();
+ *x0 = L_sub( L_shl( *x0, 1 ), *x1 ); //*x0 * 2 - *x1 (Qx)
+ move32();
+
+ x0++;
+ x0++;
+ x1++;
+ x1++;
+ }
+
+ /*-----------------------------------------------------------------*
+ * 1st Stage Loop has been Unrolled because n4 is '1' and that
+ * allows the elimination of the 'for_ (j = 1; j < n4; j++)' loop
+ * and the associated pointers initialization.
+ *-----------------------------------------------------------------*/
+
+ /* for_ (k = 2; k < 3; k++) */
+ {
+ x0 = x; // Qx
+ x1 = x0 + 2;
+
+ FOR( i = 0; i < n; i += 4 )
+ {
+ *x1 = L_sub( *x0, *x1 ); /* x[i+n2] = xt - x[i+n2]; Qx*/
+ move32();
+ *x0 = L_sub( L_shl( *x0, 1 ), *x1++ ); /* x[i] = xt + x[i+n2]; */ /**x0 * 2 - *x1 (Qx)*/
+ move32();
+ *x1 = L_negate( *x1 ); /* x[i+n2+n4] = -x[i+n2+n4]; Qx*/
+ move32();
+
+ x0 += 4;
+ x1 += 3; /* x1 has already advanced */
+ }
+ }
+ }
+
+ /*-----------------------------------------------------------------*
+ * Other butterflies
+ *
+ * The implementation described in [1] has been changed by using
+ * table lookup for evaluating sine and cosine functions. The
+ * variable ind and its increment step are needed to access table
+ * entries. Note that this implementation assumes n4 to be so
+ * small that ind will never exceed the table. Thus the input
+ * argument n and the constant N_MAX_FFT must be set properly.
+ *-----------------------------------------------------------------*/
+
+ n4 = 1;
+ move16();
+ n2 = 2;
+ move16();
+ n1 = 4;
+ move16();
+
+ step = N_MAX_DIV4;
+ move16();
+
+ FOR( k = 3; k <= m; k++ )
+ {
+ step = shr( step, 1 );
+ n4 = shl( n4, 1 );
+ n2 = shl( n2, 1 );
+ n1 = shl( n1, 1 );
+
+ x0 = x;
+ x1 = x0 + n2;
+ x2 = x1 + n4;
+
+ FOR( i = 0; i < n; i += n1 )
+ {
+ *x1 = L_sub( *x0, *x1 ); /* x[i+n2] = xt - x[i+n2]; */
+ move32();
+ *x0 = L_sub( L_shl( *x0, 1 ), *x1 ); /* x[i] = xt + x[i+n2]; */ /**x0 * 2 - *x1 (Qx)*/
+ move32();
+ *x2 = L_negate( *x2 ); /* x[i+n2+n4] = -x[i+n2+n4]; Qx */
+ move32();
+
+ s = sincos_t_ext_fx; // Q15
+ c = s + N_MAX_FFT / 4; /* 1024/4 = 256, 256/4=64 Q15*/
+ xi1 = x0;
+ xi3 = xi1 + n2;
+ xi2 = xi3;
+ x0 += n1;
+ xi4 = x0;
+
+ FOR( j = 1; j < n4; j++ )
+ {
+ xi3++;
+ xi1++;
+ xi4--;
+ xi2--;
+ c += step;
+ s += step; /* autoincrement by ar0 */
+
+ t1 = L_add( Mpy_32_16_1( *xi3, *c ), Mpy_32_16_1( *xi4, *s ) ); /* t1 = *xi3**(pt_c+ind) + *xi4**(pt_s+ind); Qx*/
+ t2 = L_sub( Mpy_32_16_1( *xi3, *s ), Mpy_32_16_1( *xi4, *c ) ); /* t2 = *xi3**(pt_s+ind) - *xi4**(pt_c+ind); Qx*/
+
+ *xi4 = L_sub( *xi2, t2 );
+ move32();
+ *xi2 = L_sub( *xi1, t1 );
+ move32();
+ *xi1 = L_sub( L_shl( *xi1, 1 ), *xi2 ); // Qx
+ move32();
+ *xi3 = L_negate( L_add( L_shl( t2, 1 ), *xi4 ) ); // Qx
+ move32();
+ }
+
+ x1 += n1;
+ x2 += n1;
+ }
+ }
+
+ return;
+}
diff --git a/lib_com/fill_spectrum.c b/lib_com/fill_spectrum_fx.c
similarity index 100%
rename from lib_com/fill_spectrum.c
rename to lib_com/fill_spectrum_fx.c
diff --git a/lib_com/findpulse.c b/lib_com/findpulse_fx.c
similarity index 100%
rename from lib_com/findpulse.c
rename to lib_com/findpulse_fx.c
diff --git a/lib_com/gs_gains.c b/lib_com/gs_gains.c
deleted file mode 100644
index 8fa7694755c7c5ac9f912f26abdff9211895ff07..0000000000000000000000000000000000000000
--- a/lib_com/gs_gains.c
+++ /dev/null
@@ -1,425 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository. All Rights Reserved.
-
- This software is protected by copyright law and by international treaties.
- The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository retain full ownership rights in their respective contributions in
- the software. This notice grants no license of any kind, including but not limited to patent
- license, nor is any license granted by implication, estoppel or otherwise.
-
- Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
- contributions.
-
- This software is provided "AS IS", without any express or implied warranties. The software is in the
- development stage. It is intended exclusively for experts who have experience with such software and
- solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
- and fitness for a particular purpose are hereby disclaimed and excluded.
-
- Any dispute, controversy or claim arising under or in relation to providing this software shall be
- submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
- accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
- the United Nations Convention on Contracts on the International Sales of Goods.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include
-#include "cnst.h"
-#include "rom_com.h"
-#include "prot_fx.h"
-#include "wmc_auto.h"
-
-static void GSC_gain_DQ_fx(
- const Word16 element_mode, /* i : element mode */
- const Word16 enc_dec, /* i : encoder/decoder flag */
- const Word16 coder_type, /* i : Coder type */
- const Word16 Mbands_gn, /* i : Number of band */
- const Word32 core_brate, /* i : Core bitrate */
- const Word16 mean_g, /* i : Average gain Q12 */
- const Word16 *Gain_in, /* i : Unquantized gain vector Q12 */
- Word16 *Gain_out /* o : Level adjusted unquantized gain vector Q12 */
-)
-{
- Word16 Gain_off;
- Word16 i;
-
- /* Gain adjustment to fit ACELP generic inactive coding gain at low rate */
- Gain_off = 0;
- move16();
-
- test();
- IF( coder_type == INACTIVE || EQ_16( coder_type, UNVOICED ) )
- {
- test();
- IF( LE_32( core_brate, ACELP_5k00 ) && EQ_16( coder_type, UNVOICED ) )
- {
- Gain_off = 1843; // 9/20 in Q12
- move16();
- }
- ELSE IF( LE_32( core_brate, ACELP_7k20 ) )
- {
- Gain_off = 1638; // 8/20 in Q12; /* 0 dB */
- move16();
- }
- ELSE IF( LE_32( core_brate, ACELP_8k00 ) )
- {
- Gain_off = 1351; // 6.6f/20 in Q12 /* ~-3.3 dB */
- move16();
- }
- ELSE IF( LE_32( core_brate, ACELP_9k60 ) )
- {
- Gain_off = 983; // 4.8f/20 in Q12 /* ~-2.4 dB */
- move16();
- }
- ELSE IF( LE_32( core_brate, ACELP_11k60 ) )
- {
- Gain_off = 717; // 3.5f/20 in Q12 /* ~-2.4 dB */
- move16();
- }
- ELSE IF( LE_32( core_brate, ACELP_13k20 ) )
- {
- Gain_off = 614; // 3.0f/20 in Q12 /* ~-2.4 dB */
- move16();
- }
- }
-
- test();
- IF( coder_type != INACTIVE && NE_16( coder_type, UNVOICED ) )
- {
- FOR( i = 0; i < Mbands_gn; i++ )
- {
- Gain_out[i] = add( Gain_in[i], mean_g ); // Q12
- move16();
- }
- }
- ELSE
- {
- /*mimic ACELP decay of energy for low rates*/
- test();
- IF( element_mode == EVS_MONO && EQ_16( enc_dec, DEC ) )
- {
- /* This is to keep EVS mono bit-exact with the standard (there might be a small desynchronization between encoder and decoder but there is no real quality or interop. issue) */
- FOR( i = 0; i < Mbands_gn; i++ )
- {
- Gain_out[i] = add( Gain_out[i], sub( mean_g, mult( Gain_off, div_s( i, Mbands_gn ) ) ) ); // Q12
- move16();
- // Gain_out[i] += mean_g - i * ( Gain_off / 20.f ) / ( (float) Mbands_gn );
- }
- }
- ELSE
- {
- FOR( i = 0; i < Mbands_gn; i++ )
- {
- Gain_out[i] = add( Gain_in[i], sub( mean_g, mult( Gain_off, div_s( i, Mbands_gn ) ) ) ); // Q12
- move16();
- // Gain_out[i] = Gain_in[i] + mean_g - ( i * ( Gain_off / 20.f ) / ( (float) Mbands_gn ) );
- }
- }
- }
-
- return;
-}
-
-Word16 gsc_gainQ_ivas_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const Word16 element_mode, /* i : element mode */
- const Word16 idchan, /* i : channel ID */
- const Word16 y_gain4[],
- /* i : Energy per band */ // Q12
- Word16 y_gainQ[],
- /* o : quantized energy per band */ // Q12
- const Word32 core_brate, /* i : Core rate */
- const Word16 coder_type, /* i : coding type */
- const Word16 bwidth, /* i : input signal bandwidth */
- const Word16 L_frame, /* i : frame length */
- const Word16 tdm_LRTD_flag, /* i : LRTD stereo mode flag */
- const Word32 core_brate_inp /* i : true core bitrate */
-)
-{
- Word16 y_gain_tmp[MBANDS_GN16k];
- Word16 y_gain_tmp2[MBANDS_GN16k];
- Word16 i, idx_g = 0;
- move16();
- Word16 mean_4g_fx[1], ftmp1_fx;
- Word16 Mbands_gn = MBANDS_GN;
- move16();
- Word16 y_gain_tmp3[MBANDS_GN];
- Word32 L_tmp;
-
- if ( EQ_16( L_frame, L_FRAME16k ) )
- {
- Mbands_gn = MBANDS_GN16k;
- move16();
- }
-
- mean_4g_fx[0] = 0;
- move32();
-
- test();
- test();
- IF( ( EQ_16( coder_type, AUDIO ) || coder_type == INACTIVE ) && bwidth == NB )
- {
- L_tmp = 0;
- move32();
- FOR( i = 0; i < 10; i++ )
- {
- L_tmp = L_add( L_tmp, y_gain4[i] );
- }
- L_tmp = L_sub( Mpy_32_16_1( L_tmp, 3277 /* (1/10.0f) in Q15 */ ), 2457 /* 0.6f in Q12 */ ); // Q12
- ftmp1_fx = extract_l( L_tmp );
- FOR( i = 0; i < Mbands_gn; i++ )
- {
- IF( LT_16( y_gain4[i], ftmp1_fx ) )
- {
- y_gain_tmp2[i] = ftmp1_fx; /*Q12*/
- }
- ELSE
- {
- y_gain_tmp2[i] = y_gain4[i]; /*Q12*/
- }
- move16();
- }
-
- /* Quantized mean gain without clipping */
- L_tmp = 0;
- move32();
- FOR( i = 0; i < 10; i++ )
- {
- L_tmp = L_add( L_tmp, y_gain4[i] );
- }
- L_tmp = Mpy_32_16_1( L_tmp, 3277 /* (1/10.0f) in Q15 */ ); // Q12
- mean_4g_fx[0] = extract_l( L_tmp ); // Q12
- move16();
- idx_g = vquant_fx( mean_4g_fx, Gain_meanNB_fx, mean_4g_fx, Gain_mean_dicNB_fx, 1, 64 );
- push_indice( hBstr, IND_MEAN_GAIN2, idx_g, 6 );
-
- FOR( i = 0; i < Mbands_gn; i++ )
- {
- y_gain_tmp[i] = sub( y_gain_tmp2[i], mean_4g_fx[0] ); // Q12
- move16();
- }
-
- if ( LT_16( y_gain_tmp[9], -1229 /* -0.3f in Q12 */ ) )
- {
- y_gain_tmp[9] = -1229; /* -0.3f in Q12 */
- move16();
- }
-
- set16_fx( y_gain_tmp + 10, 0, MBANDS_GN - 10 );
- idx_g = vquant_fx( y_gain_tmp, Mean_dic_NB_fx, y_gain_tmp, Gain_dic1_NB_fx, 3, 64 );
- push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 6 );
-
- IF( LT_32( core_brate, ACELP_9k60 ) )
- {
- idx_g = vquant_fx( y_gain_tmp + 3, Mean_dic_NB_fx + 3, y_gain_tmp + 3, Gain_dic2_NB_fx, 3, 32 );
- push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 );
-
- idx_g = vquant_fx( y_gain_tmp + 6, Mean_dic_NB_fx + 6, y_gain_tmp + 6, Gain_dic3_NB_fx, 4, 16 );
- push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 4 );
- }
- ELSE
- {
- idx_g = vquant_fx( y_gain_tmp + 3, Mean_dic_NB_fx + 3, y_gain_tmp + 3, Gain_dic2_NBHR_fx, 3, 64 );
- push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 6 );
-
- idx_g = vquant_fx( y_gain_tmp + 6, Mean_dic_NB_fx + 6, y_gain_tmp + 6, Gain_dic3_NBHR_fx, 4, 128 );
- push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 7 );
- }
-
- test();
- IF( LE_32( core_brate, ACELP_9k60 ) && coder_type == INACTIVE )
- {
- /* Some energy is needed in high band for stat_noise_uv_enc() to be functional in inactive speech */
- y_gain_tmp[10] = mean_fx( y_gain_tmp + 6, 3 ); /*Q12*/
- move16();
- y_gain_tmp[11] = mean_fx( y_gain_tmp + 7, 3 ); /*Q12*/
- move16();
- y_gain_tmp[12] = mean_fx( y_gain_tmp + 8, 3 ); /*Q12*/
- move16();
- y_gain_tmp[13] = mean_fx( y_gain_tmp + 9, 3 ); /*Q12*/
- move16();
- y_gain_tmp[14] = mean_fx( y_gain_tmp + 10, 3 ); /*Q12*/
- move16();
- y_gain_tmp[15] = mean_fx( y_gain_tmp + 11, 3 ); /*Q12*/
- move16();
- }
- ELSE
- {
- set16_fx( y_gain_tmp + 10, 0, MBANDS_GN - 10 );
- }
- }
- ELSE
- {
- L_tmp = 0;
- move32();
- FOR( i = 0; i < 16; i++ )
- {
- L_tmp = L_add( L_tmp, y_gain4[i] );
- }
- L_tmp = Mpy_32_16_1( L_tmp, 2048 /* (1/16.f) in Q15 */ ); // Q12
- ftmp1_fx = extract_l( L_tmp );
- FOR( i = 0; i < Mbands_gn; i++ )
- {
- IF( LT_16( y_gain4[i], sub( ftmp1_fx, 2457 /* 0.6 in Q12*/ ) ) )
- {
- y_gain_tmp2[i] = sub( ftmp1_fx, 2457 /* 0.6 in Q12*/ );
- }
- ELSE IF( GT_16( y_gain4[i], add( ftmp1_fx, 2457 /* 0.6 in Q12*/ ) ) )
- {
- y_gain_tmp2[i] = add( ftmp1_fx, 2457 /* 0.6 in Q12*/ );
- }
- ELSE
- {
- y_gain_tmp2[i] = y_gain4[i];
- }
- move16();
- }
-
- L_tmp = 0;
- move32();
- FOR( i = 0; i < 16; i++ )
- {
- L_tmp = L_add( L_tmp, y_gain_tmp2[i] );
- }
- L_tmp = Mpy_32_16_1( L_tmp, 2048 /* (1/16.f) in Q15 */ ); // Q12
- mean_4g_fx[0] = extract_l( L_tmp ); // Q12
- move16();
- idx_g = vquant_fx( mean_4g_fx, mean_m_fx, mean_4g_fx, mean_gain_dic_fx, 1, 64 );
- push_indice( hBstr, IND_MEAN_GAIN2, idx_g, 6 );
-
- /* Subtraction of the average gain */
- FOR( i = 0; i < Mbands_gn; i++ )
- {
- y_gain_tmp[i] = sub( y_gain_tmp2[i], mean_4g_fx[0] ); // Q12
- move16();
- }
-
- IF( LT_32( core_brate, ACELP_9k60 ) )
- {
- /* prediction and quantization of the average gain */
-
- /*--------------------------------------------------------------------------------------*
- * Quantization of the first 8 bands
- * Keep only 4 bands out of the last 8 bands
- *--------------------------------------------------------------------------------------*/
-
- Copy( y_gain_tmp, y_gain_tmp2, 8 );
-
- y_gain_tmp2[8] = y_gain_tmp[8];
- move16();
- y_gain_tmp2[9] = y_gain_tmp[10];
- move16();
- y_gain_tmp2[10] = y_gain_tmp[12];
- move16();
- y_gain_tmp2[11] = y_gain_tmp[14];
- move16();
-
- idx_g = 0;
- move16();
- idx_g = vquant_fx( y_gain_tmp2, YGain_mean_LR_fx, y_gain_tmp2, YGain_dic1_LR_fx, 3, 32 );
- push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 );
-
- test();
- test();
- test();
- IF( !( coder_type == INACTIVE && tdm_LRTD_flag == 0 && EQ_16( idchan, 1 ) ) || GT_32( core_brate_inp, GSC_LRES_GAINQ_LIMIT ) )
- {
- idx_g = vquant_fx( y_gain_tmp2 + 3, YGain_mean_LR_fx + 3, y_gain_tmp2 + 3, YGain_dic2_LR_fx, 4, 32 );
- push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 );
-
- /*----------------------------------------------------------------------*
- * Vector quantization of the first 8 bands + quantization of the 4 bands out of the last 8
- * Interpolation of the last 4 bands Q to create bands 8-16
- *----------------------------------------------------------------------*/
-
- idx_g = vquant_fx( y_gain_tmp2 + 7, YGain_mean_LR_fx + 7, y_gain_tmp2 + 7, YGain_dic3_LR_fx, 5, 32 );
- push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 );
-
- set16_fx( y_gain_tmp2 + 12, 0, MBANDS_GN - 12 );
-
- /* Update to quantized vector */
- Copy( y_gain_tmp2, y_gain_tmp, 8 );
-
- Copy( y_gain_tmp2 + 8, y_gain_tmp3, 4 );
- set16_fx( y_gain_tmp + 8, 0, 8 );
- fft_rel_fx( y_gain_tmp2 + 8, 4, 2 );
-
- Copy( y_gain_tmp2 + 8, y_gain_tmp + 8, 3 );
- y_gain_tmp[15] = y_gain_tmp2[11];
- move16();
- ifft_rel_fx( y_gain_tmp + 8, 8, 3 );
-
- FOR( i = 8; i < 16; i++ )
- {
- y_gain_tmp[i] = shl( mult( y_gain_tmp[i], 23101 /* 1.41 in Q14 */ ), 1 ); /*Q12*/
- move16();
- }
-
- y_gain_tmp[8] = y_gain_tmp3[0];
- move16();
- y_gain_tmp[10] = y_gain_tmp3[1];
- move16();
- y_gain_tmp[12] = y_gain_tmp3[2];
- move16();
- y_gain_tmp[14] = y_gain_tmp3[3];
- move16();
- }
- ELSE
- {
- Copy( y_gain_tmp2, y_gain_tmp, 3 );
- set16_fx( y_gain_tmp + 3, 0, MBANDS_GN16k - 3 );
- }
- }
- ELSE
- {
- IF( EQ_16( L_frame, L_FRAME ) )
- {
- idx_g = vquant_fx( y_gain_tmp, YG_mean16_fx, y_gain_tmp, YG_dicMR_1_fx, 4, 64 );
- push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 6 );
-
- idx_g = vquant_fx( y_gain_tmp + 4, YG_mean16_fx + 4, y_gain_tmp + 4, YG_dicMR_2_fx, 4, 32 );
- push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 );
-
- idx_g = vquant_fx( y_gain_tmp + 8, YG_mean16_fx + 8, y_gain_tmp + 8, YG_dicMR_3_fx, 4, 32 );
- push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 );
-
- idx_g = vquant_fx( y_gain_tmp + 12, YG_mean16_fx + 12, y_gain_tmp + 12, YG_dicMR_4_fx, 4, 16 );
- push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 4 );
- }
- ELSE
- {
- idx_g = vquant_fx( y_gain_tmp, YG_mean16HR_fx, y_gain_tmp, YG_dicHR_1_fx, 4, 128 );
- push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 7 );
-
- idx_g = vquant_fx( y_gain_tmp + 4, YG_mean16HR_fx + 4, y_gain_tmp + 4, YG_dicHR_2_fx, 4, 64 );
- push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 6 );
-
- idx_g = vquant_fx( y_gain_tmp + 8, YG_mean16HR_fx + 8, y_gain_tmp + 8, YG_dicHR_3_fx, 4, 64 );
- push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 6 );
-
- idx_g = vquant_fx( y_gain_tmp + 12, YG_mean16HR_16kHz_fx, y_gain_tmp + 12, YG_dicHR_4_16kHz_fx, 4, 64 );
- push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 6 );
-
- idx_g = vquant_fx( y_gain_tmp + 16, YG_meanL2G_16kHz_fx, y_gain_tmp + 16, YG_dicL2G_16kHz_fx, 2, 8 );
- push_indice( hBstr, IND_Y_GAIN_HF, idx_g, 3 );
- }
- }
- }
-
- GSC_gain_DQ_fx( element_mode, ENC, coder_type, Mbands_gn, core_brate, mean_4g_fx[0], y_gain_tmp, y_gainQ );
-
- return mean_4g_fx[0];
-}
diff --git a/lib_com/gs_gains_fx.c b/lib_com/gs_gains_fx.c
index ecfe9aae0f28d32e24ac362414cc1f52f47b58b4..f28af742fe673950c979fde8de6c8835711ebe89 100644
--- a/lib_com/gs_gains_fx.c
+++ b/lib_com/gs_gains_fx.c
@@ -34,11 +34,14 @@
EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
====================================================================================*/
+#include
+#include
#include "options.h" /* Compilation switches */
#include "cnst.h" /* Common constants */
#include "rom_com.h" /* Static table prototypes */
#include "prot_fx.h"
#include "stl.h"
+#include "wmc_auto.h"
/*-------------------------------------------------------------------*
* Local constants
@@ -66,6 +69,7 @@ static Word16 VDQ_vec_fx( Word16 *Qvec_out_fx, const Word16 *mean_dic_fx, const
/* RETURN ARGUMENTS : */
/* _ None */
/*========================================================================*/
+
void Comp_and_apply_gain_fx(
Word16 exc_diffQ[], /* i/o: Quantized excitation */
Word16 Ener_per_bd_iQ[], /* i : Target ener per band Q13 */
@@ -264,6 +268,7 @@ void Comp_and_apply_gain_ivas_fx(
/* RETURN ARGUMENTS : */
/* _ None */
/*========================================================================*/
+
static Word16 Comp_band_log_ener( /* o : Band gain Q12 */
const Word16 *pt_fx, /* i : Dct input Q_sc */
const Word16 Len, /* i : Lenght en energy accumulation */
@@ -363,127 +368,14 @@ void Ener_per_band_comp_ivas_fx(
return;
}
-void Ener_per_band_comp_ivas_fx_2(
- const Word16 exc_diff[], /* i : target signal Q_exc */
- Word16 y_gain4[], /* o : Energy per band to quantize Q12 */
- const Word16 Q_exc,
- const Word16 Mband, /* i : Max band */
- const Word16 Eflag, /* i : flag of highest band */
- const Word16 L_frame /* i : frame length */
-)
-{
- Word32 etmp, L_tmp;
- Word16 etmp_e;
- const Word16 *pt;
- Word16 i, j, tmp;
- tmp = add( shl( sub( Q15, Q_exc ), 1 ), 1 );
- pt = exc_diff;
- FOR( j = 0; j < 2; j++ )
- {
- y_gain4[j] = 0;
- move16();
- etmp = 42949673; /* 0.02 in Q31 */
- move32();
- etmp_e = 0;
- move16();
-
- pt = exc_diff + shl( j, 3 );
- FOR( i = 0; i < 8; i++ )
- {
- etmp = BASOP_Util_Add_Mant32Exp( etmp, etmp_e, L_mult0( *pt, *pt ), tmp, &etmp_e );
- pt++;
- }
-
- /* normalized to 16 bins to easy the quantization */
- etmp_e = add( etmp_e, 1 );
- etmp = Sqrt32( etmp, &etmp_e );
- etmp = BASOP_Util_Log10( etmp, etmp_e ); // Q25
- y_gain4[j] = extract_h( L_shl( etmp, 3 ) ); // Q12
- move16();
- }
-
- FOR( j = 1; j < Mband - 2; j++ )
- {
- etmp = 21474836; /* 0.01 in Q31 */
- move32();
- etmp_e = 0;
- move16();
-
- pt = exc_diff + shl( j, 4 );
- FOR( i = 0; i < 16; i++ )
- {
- etmp = BASOP_Util_Add_Mant32Exp( etmp, etmp_e, L_mult0( *pt, *pt ), tmp, &etmp_e );
- pt++;
- }
-
- etmp = Sqrt32( etmp, &etmp_e );
- etmp = BASOP_Util_Log10( etmp, etmp_e ); // Q25
- y_gain4[j + 1] = extract_h( L_shl( etmp, 3 ) ); // Q12
- move16();
- }
-
- IF( EQ_16( Eflag, 1 ) )
- {
- etmp = 21474836; /* 0.01 in Q31 */
- move32();
- etmp_e = 0;
- move16();
-
- pt = exc_diff + shl( j, 4 );
- FOR( i = 0; i < 32; i++ )
- {
- etmp = BASOP_Util_Add_Mant32Exp( etmp, etmp_e, L_mult0( *pt, *pt ), tmp, &etmp_e );
- pt++;
- }
-
- etmp_e = sub( etmp_e, 1 );
- etmp = Sqrt32( etmp, &etmp_e );
- etmp = BASOP_Util_Log10( etmp, etmp_e ); // Q25
- y_gain4[j + 1] = extract_h( L_shl( etmp, 3 ) ); // Q12
- move16();
- }
-
- IF( EQ_16( L_frame, L_FRAME16k ) )
- {
- etmp = 21474836; /* 0.01 in Q31 */
- move32();
- etmp_e = 0;
- move16();
-
- FOR( i = 0; i < 32; i++ )
- {
- etmp = BASOP_Util_Add_Mant32Exp( etmp, etmp_e, L_mult0( *pt, *pt ), tmp, &etmp_e );
- pt++;
- }
-
- Word16 tmp2 = sub( etmp_e, 1 );
- L_tmp = Sqrt32( etmp, &tmp2 );
- L_tmp = BASOP_Util_Log10( L_tmp, tmp2 ); // Q25
- y_gain4[j + 2] = extract_h( L_shl( L_tmp, 3 ) ); // Q12
- move16();
-
- FOR( i = 0; i < 32; i++ )
- {
- etmp = BASOP_Util_Add_Mant32Exp( etmp, etmp_e, L_mult0( *pt, *pt ), tmp, &etmp_e );
- pt++;
- }
-
- etmp_e = sub( etmp_e, 1 );
- etmp = Sqrt32( etmp, &etmp_e );
- etmp = BASOP_Util_Log10( etmp, etmp_e ); // Q25
- y_gain4[j + 3] = extract_h( L_shl( etmp, 3 ) ); // Q12
- move16();
- }
-
- return;
-}
/*-------------------------------------------------------------------*
* gsc_gainQ()
*
* Quantization of the energy per band
*-------------------------------------------------------------------*/
+
static void GSC_gain_adj(
const Word16 coder_type, /* i : Coder type */
const Word32 core_brate, /* i : Bit rate */
@@ -550,11 +442,13 @@ static void GSC_gain_adj(
return;
}
+
/*-------------------------------------------------------------------*
* GSC_gain_adj_ivas_fx()
*
* Quantization of the energy per band
*-------------------------------------------------------------------*/
+
static void GSC_gain_adj_ivas_fx(
const Word16 coder_type, /* i : Coder type */
const Word16 Mbands_gn, /* i : Number of band */
@@ -629,6 +523,404 @@ static void GSC_gain_adj_ivas_fx(
return;
}
+
+/*-------------------------------------------------------------------*
+ * GSC_gain_DQ()
+ *
+ * Form the final vector after gain quantization/Dequantization
+ * Common to both encoder and decoder
+ *-------------------------------------------------------------------*/
+
+static void GSC_gain_DQ_fx(
+ const Word16 element_mode, /* i : element mode */
+ const Word16 enc_dec, /* i : encoder/decoder flag */
+ const Word16 coder_type, /* i : Coder type */
+ const Word16 Mbands_gn, /* i : Number of band */
+ const Word32 core_brate, /* i : Core bitrate */
+ const Word16 mean_g, /* i : Average gain Q12 */
+ const Word16 *Gain_in, /* i : Unquantized gain vector Q12 */
+ Word16 *Gain_out /* o : Level adjusted unquantized gain vector Q12 */
+)
+{
+ Word16 Gain_off;
+ Word16 i;
+
+ /* Gain adjustment to fit ACELP generic inactive coding gain at low rate */
+ Gain_off = 0;
+ move16();
+
+ test();
+ IF( coder_type == INACTIVE || EQ_16( coder_type, UNVOICED ) )
+ {
+ test();
+ IF( LE_32( core_brate, ACELP_5k00 ) && EQ_16( coder_type, UNVOICED ) )
+ {
+ Gain_off = 1843; // 9/20 in Q12
+ move16();
+ }
+ ELSE IF( LE_32( core_brate, ACELP_7k20 ) )
+ {
+ Gain_off = 1638; // 8/20 in Q12; /* 0 dB */
+ move16();
+ }
+ ELSE IF( LE_32( core_brate, ACELP_8k00 ) )
+ {
+ Gain_off = 1351; // 6.6f/20 in Q12 /* ~-3.3 dB */
+ move16();
+ }
+ ELSE IF( LE_32( core_brate, ACELP_9k60 ) )
+ {
+ Gain_off = 983; // 4.8f/20 in Q12 /* ~-2.4 dB */
+ move16();
+ }
+ ELSE IF( LE_32( core_brate, ACELP_11k60 ) )
+ {
+ Gain_off = 717; // 3.5f/20 in Q12 /* ~-2.4 dB */
+ move16();
+ }
+ ELSE IF( LE_32( core_brate, ACELP_13k20 ) )
+ {
+ Gain_off = 614; // 3.0f/20 in Q12 /* ~-2.4 dB */
+ move16();
+ }
+ }
+
+ test();
+ IF( coder_type != INACTIVE && NE_16( coder_type, UNVOICED ) )
+ {
+ FOR( i = 0; i < Mbands_gn; i++ )
+ {
+ Gain_out[i] = add( Gain_in[i], mean_g ); // Q12
+ move16();
+ }
+ }
+ ELSE
+ {
+ /*mimic ACELP decay of energy for low rates*/
+ test();
+ IF( element_mode == EVS_MONO && EQ_16( enc_dec, DEC ) )
+ {
+ /* This is to keep EVS mono bit-exact with the standard (there might be a small desynchronization between encoder and decoder but there is no real quality or interop. issue) */
+ FOR( i = 0; i < Mbands_gn; i++ )
+ {
+ Gain_out[i] = add( Gain_out[i], sub( mean_g, mult( Gain_off, div_s( i, Mbands_gn ) ) ) ); // Q12
+ move16();
+ // Gain_out[i] += mean_g - i * ( Gain_off / 20.f ) / ( (float) Mbands_gn );
+ }
+ }
+ ELSE
+ {
+ FOR( i = 0; i < Mbands_gn; i++ )
+ {
+ Gain_out[i] = add( Gain_in[i], sub( mean_g, mult( Gain_off, div_s( i, Mbands_gn ) ) ) ); // Q12
+ move16();
+ // Gain_out[i] = Gain_in[i] + mean_g - ( i * ( Gain_off / 20.f ) / ( (float) Mbands_gn ) );
+ }
+ }
+ }
+
+ return;
+}
+
+
+/*-------------------------------------------------------------------*
+ * gsc_gainQ()
+ *
+ * Quantization of the energy per band
+ *-------------------------------------------------------------------*/
+
+Word16 gsc_gainQ_ivas_fx(
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ const Word16 element_mode, /* i : element mode */
+ const Word16 idchan, /* i : channel ID */
+ const Word16 y_gain4[],
+ /* i : Energy per band */ // Q12
+ Word16 y_gainQ[],
+ /* o : quantized energy per band */ // Q12
+ const Word32 core_brate, /* i : Core rate */
+ const Word16 coder_type, /* i : coding type */
+ const Word16 bwidth, /* i : input signal bandwidth */
+ const Word16 L_frame, /* i : frame length */
+ const Word16 tdm_LRTD_flag, /* i : LRTD stereo mode flag */
+ const Word32 core_brate_inp /* i : true core bitrate */
+)
+{
+ Word16 y_gain_tmp[MBANDS_GN16k];
+ Word16 y_gain_tmp2[MBANDS_GN16k];
+ Word16 i, idx_g = 0;
+ move16();
+ Word16 mean_4g_fx[1], ftmp1_fx;
+ Word16 Mbands_gn = MBANDS_GN;
+ move16();
+ Word16 y_gain_tmp3[MBANDS_GN];
+ Word32 L_tmp;
+
+ if ( EQ_16( L_frame, L_FRAME16k ) )
+ {
+ Mbands_gn = MBANDS_GN16k;
+ move16();
+ }
+
+ mean_4g_fx[0] = 0;
+ move32();
+
+ test();
+ test();
+ IF( ( EQ_16( coder_type, AUDIO ) || coder_type == INACTIVE ) && bwidth == NB )
+ {
+ L_tmp = 0;
+ move32();
+ FOR( i = 0; i < 10; i++ )
+ {
+ L_tmp = L_add( L_tmp, y_gain4[i] );
+ }
+ L_tmp = L_sub( Mpy_32_16_1( L_tmp, 3277 /* (1/10.0f) in Q15 */ ), 2457 /* 0.6f in Q12 */ ); // Q12
+ ftmp1_fx = extract_l( L_tmp );
+ FOR( i = 0; i < Mbands_gn; i++ )
+ {
+ IF( LT_16( y_gain4[i], ftmp1_fx ) )
+ {
+ y_gain_tmp2[i] = ftmp1_fx; /*Q12*/
+ }
+ ELSE
+ {
+ y_gain_tmp2[i] = y_gain4[i]; /*Q12*/
+ }
+ move16();
+ }
+
+ /* Quantized mean gain without clipping */
+ L_tmp = 0;
+ move32();
+ FOR( i = 0; i < 10; i++ )
+ {
+ L_tmp = L_add( L_tmp, y_gain4[i] );
+ }
+ L_tmp = Mpy_32_16_1( L_tmp, 3277 /* (1/10.0f) in Q15 */ ); // Q12
+ mean_4g_fx[0] = extract_l( L_tmp ); // Q12
+ move16();
+ idx_g = vquant_fx( mean_4g_fx, Gain_meanNB_fx, mean_4g_fx, Gain_mean_dicNB_fx, 1, 64 );
+ push_indice( hBstr, IND_MEAN_GAIN2, idx_g, 6 );
+
+ FOR( i = 0; i < Mbands_gn; i++ )
+ {
+ y_gain_tmp[i] = sub( y_gain_tmp2[i], mean_4g_fx[0] ); // Q12
+ move16();
+ }
+
+ if ( LT_16( y_gain_tmp[9], -1229 /* -0.3f in Q12 */ ) )
+ {
+ y_gain_tmp[9] = -1229; /* -0.3f in Q12 */
+ move16();
+ }
+
+ set16_fx( y_gain_tmp + 10, 0, MBANDS_GN - 10 );
+ idx_g = vquant_fx( y_gain_tmp, Mean_dic_NB_fx, y_gain_tmp, Gain_dic1_NB_fx, 3, 64 );
+ push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 6 );
+
+ IF( LT_32( core_brate, ACELP_9k60 ) )
+ {
+ idx_g = vquant_fx( y_gain_tmp + 3, Mean_dic_NB_fx + 3, y_gain_tmp + 3, Gain_dic2_NB_fx, 3, 32 );
+ push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 );
+
+ idx_g = vquant_fx( y_gain_tmp + 6, Mean_dic_NB_fx + 6, y_gain_tmp + 6, Gain_dic3_NB_fx, 4, 16 );
+ push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 4 );
+ }
+ ELSE
+ {
+ idx_g = vquant_fx( y_gain_tmp + 3, Mean_dic_NB_fx + 3, y_gain_tmp + 3, Gain_dic2_NBHR_fx, 3, 64 );
+ push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 6 );
+
+ idx_g = vquant_fx( y_gain_tmp + 6, Mean_dic_NB_fx + 6, y_gain_tmp + 6, Gain_dic3_NBHR_fx, 4, 128 );
+ push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 7 );
+ }
+
+ test();
+ IF( LE_32( core_brate, ACELP_9k60 ) && coder_type == INACTIVE )
+ {
+ /* Some energy is needed in high band for stat_noise_uv_enc() to be functional in inactive speech */
+ y_gain_tmp[10] = mean_fx( y_gain_tmp + 6, 3 ); /*Q12*/
+ move16();
+ y_gain_tmp[11] = mean_fx( y_gain_tmp + 7, 3 ); /*Q12*/
+ move16();
+ y_gain_tmp[12] = mean_fx( y_gain_tmp + 8, 3 ); /*Q12*/
+ move16();
+ y_gain_tmp[13] = mean_fx( y_gain_tmp + 9, 3 ); /*Q12*/
+ move16();
+ y_gain_tmp[14] = mean_fx( y_gain_tmp + 10, 3 ); /*Q12*/
+ move16();
+ y_gain_tmp[15] = mean_fx( y_gain_tmp + 11, 3 ); /*Q12*/
+ move16();
+ }
+ ELSE
+ {
+ set16_fx( y_gain_tmp + 10, 0, MBANDS_GN - 10 );
+ }
+ }
+ ELSE
+ {
+ L_tmp = 0;
+ move32();
+ FOR( i = 0; i < 16; i++ )
+ {
+ L_tmp = L_add( L_tmp, y_gain4[i] );
+ }
+ L_tmp = Mpy_32_16_1( L_tmp, 2048 /* (1/16.f) in Q15 */ ); // Q12
+ ftmp1_fx = extract_l( L_tmp );
+ FOR( i = 0; i < Mbands_gn; i++ )
+ {
+ IF( LT_16( y_gain4[i], sub( ftmp1_fx, 2457 /* 0.6 in Q12*/ ) ) )
+ {
+ y_gain_tmp2[i] = sub( ftmp1_fx, 2457 /* 0.6 in Q12*/ );
+ }
+ ELSE IF( GT_16( y_gain4[i], add( ftmp1_fx, 2457 /* 0.6 in Q12*/ ) ) )
+ {
+ y_gain_tmp2[i] = add( ftmp1_fx, 2457 /* 0.6 in Q12*/ );
+ }
+ ELSE
+ {
+ y_gain_tmp2[i] = y_gain4[i];
+ }
+ move16();
+ }
+
+ L_tmp = 0;
+ move32();
+ FOR( i = 0; i < 16; i++ )
+ {
+ L_tmp = L_add( L_tmp, y_gain_tmp2[i] );
+ }
+ L_tmp = Mpy_32_16_1( L_tmp, 2048 /* (1/16.f) in Q15 */ ); // Q12
+ mean_4g_fx[0] = extract_l( L_tmp ); // Q12
+ move16();
+ idx_g = vquant_fx( mean_4g_fx, mean_m_fx, mean_4g_fx, mean_gain_dic_fx, 1, 64 );
+ push_indice( hBstr, IND_MEAN_GAIN2, idx_g, 6 );
+
+ /* Subtraction of the average gain */
+ FOR( i = 0; i < Mbands_gn; i++ )
+ {
+ y_gain_tmp[i] = sub( y_gain_tmp2[i], mean_4g_fx[0] ); // Q12
+ move16();
+ }
+
+ IF( LT_32( core_brate, ACELP_9k60 ) )
+ {
+ /* prediction and quantization of the average gain */
+
+ /*--------------------------------------------------------------------------------------*
+ * Quantization of the first 8 bands
+ * Keep only 4 bands out of the last 8 bands
+ *--------------------------------------------------------------------------------------*/
+
+ Copy( y_gain_tmp, y_gain_tmp2, 8 );
+
+ y_gain_tmp2[8] = y_gain_tmp[8];
+ move16();
+ y_gain_tmp2[9] = y_gain_tmp[10];
+ move16();
+ y_gain_tmp2[10] = y_gain_tmp[12];
+ move16();
+ y_gain_tmp2[11] = y_gain_tmp[14];
+ move16();
+
+ idx_g = 0;
+ move16();
+ idx_g = vquant_fx( y_gain_tmp2, YGain_mean_LR_fx, y_gain_tmp2, YGain_dic1_LR_fx, 3, 32 );
+ push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 );
+
+ test();
+ test();
+ test();
+ IF( !( coder_type == INACTIVE && tdm_LRTD_flag == 0 && EQ_16( idchan, 1 ) ) || GT_32( core_brate_inp, GSC_LRES_GAINQ_LIMIT ) )
+ {
+ idx_g = vquant_fx( y_gain_tmp2 + 3, YGain_mean_LR_fx + 3, y_gain_tmp2 + 3, YGain_dic2_LR_fx, 4, 32 );
+ push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 );
+
+ /*----------------------------------------------------------------------*
+ * Vector quantization of the first 8 bands + quantization of the 4 bands out of the last 8
+ * Interpolation of the last 4 bands Q to create bands 8-16
+ *----------------------------------------------------------------------*/
+
+ idx_g = vquant_fx( y_gain_tmp2 + 7, YGain_mean_LR_fx + 7, y_gain_tmp2 + 7, YGain_dic3_LR_fx, 5, 32 );
+ push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 );
+
+ set16_fx( y_gain_tmp2 + 12, 0, MBANDS_GN - 12 );
+
+ /* Update to quantized vector */
+ Copy( y_gain_tmp2, y_gain_tmp, 8 );
+
+ Copy( y_gain_tmp2 + 8, y_gain_tmp3, 4 );
+ set16_fx( y_gain_tmp + 8, 0, 8 );
+ fft_rel_fx( y_gain_tmp2 + 8, 4, 2 );
+
+ Copy( y_gain_tmp2 + 8, y_gain_tmp + 8, 3 );
+ y_gain_tmp[15] = y_gain_tmp2[11];
+ move16();
+ ifft_rel_fx( y_gain_tmp + 8, 8, 3 );
+
+ FOR( i = 8; i < 16; i++ )
+ {
+ y_gain_tmp[i] = shl( mult( y_gain_tmp[i], 23101 /* 1.41 in Q14 */ ), 1 ); /*Q12*/
+ move16();
+ }
+
+ y_gain_tmp[8] = y_gain_tmp3[0];
+ move16();
+ y_gain_tmp[10] = y_gain_tmp3[1];
+ move16();
+ y_gain_tmp[12] = y_gain_tmp3[2];
+ move16();
+ y_gain_tmp[14] = y_gain_tmp3[3];
+ move16();
+ }
+ ELSE
+ {
+ Copy( y_gain_tmp2, y_gain_tmp, 3 );
+ set16_fx( y_gain_tmp + 3, 0, MBANDS_GN16k - 3 );
+ }
+ }
+ ELSE
+ {
+ IF( EQ_16( L_frame, L_FRAME ) )
+ {
+ idx_g = vquant_fx( y_gain_tmp, YG_mean16_fx, y_gain_tmp, YG_dicMR_1_fx, 4, 64 );
+ push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 6 );
+
+ idx_g = vquant_fx( y_gain_tmp + 4, YG_mean16_fx + 4, y_gain_tmp + 4, YG_dicMR_2_fx, 4, 32 );
+ push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 );
+
+ idx_g = vquant_fx( y_gain_tmp + 8, YG_mean16_fx + 8, y_gain_tmp + 8, YG_dicMR_3_fx, 4, 32 );
+ push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 );
+
+ idx_g = vquant_fx( y_gain_tmp + 12, YG_mean16_fx + 12, y_gain_tmp + 12, YG_dicMR_4_fx, 4, 16 );
+ push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 4 );
+ }
+ ELSE
+ {
+ idx_g = vquant_fx( y_gain_tmp, YG_mean16HR_fx, y_gain_tmp, YG_dicHR_1_fx, 4, 128 );
+ push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 7 );
+
+ idx_g = vquant_fx( y_gain_tmp + 4, YG_mean16HR_fx + 4, y_gain_tmp + 4, YG_dicHR_2_fx, 4, 64 );
+ push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 6 );
+
+ idx_g = vquant_fx( y_gain_tmp + 8, YG_mean16HR_fx + 8, y_gain_tmp + 8, YG_dicHR_3_fx, 4, 64 );
+ push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 6 );
+
+ idx_g = vquant_fx( y_gain_tmp + 12, YG_mean16HR_16kHz_fx, y_gain_tmp + 12, YG_dicHR_4_16kHz_fx, 4, 64 );
+ push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 6 );
+
+ idx_g = vquant_fx( y_gain_tmp + 16, YG_meanL2G_16kHz_fx, y_gain_tmp + 16, YG_dicL2G_16kHz_fx, 2, 8 );
+ push_indice( hBstr, IND_Y_GAIN_HF, idx_g, 3 );
+ }
+ }
+ }
+
+ GSC_gain_DQ_fx( element_mode, ENC, coder_type, Mbands_gn, core_brate, mean_4g_fx[0], y_gain_tmp, y_gainQ );
+
+ return mean_4g_fx[0];
+}
+
+
/*==========================================================================*/
/* FUNCTION : Word16 gsc_gaindec_fx () */
/*--------------------------------------------------------------------------*/
@@ -649,6 +941,7 @@ static void GSC_gain_adj_ivas_fx(
/* RETURN ARGUMENTS : */
/* _ (Word16) : average frequency gain */
/*==========================================================================*/
+
Word16 gsc_gaindec_fx( /* o : average frequency gain */
Decoder_State *st_fx, /* i/o: decoder state structure */
Word16 y_gainQ_fx[], /* o : quantized gain per band */
@@ -786,6 +1079,7 @@ Word16 gsc_gaindec_fx( /* o : average frequency gai
return mean_4g_fx;
}
+
/*==========================================================================*/
/* FUNCTION : Word16 gsc_gaindec_ivas_fx () */
/*--------------------------------------------------------------------------*/
@@ -806,6 +1100,7 @@ Word16 gsc_gaindec_fx( /* o : average frequency gai
/* RETURN ARGUMENTS : */
/* _ (Word16) : average frequency gain */
/*==========================================================================*/
+
Word16 gsc_gaindec_ivas_fx( /* o : average frequency gain */
Decoder_State *st_fx, /* i/o: decoder state structure */
Word16 y_gainQ_fx[], /* o : quantized gain per band Q12 */
@@ -970,11 +1265,13 @@ Word16 gsc_gaindec_ivas_fx( /* o : average frequenc
return mean_4g_fx;
}
+
/*-------------------------------------------------------------------*
* gsc_gainQ()
*
* Quantization of the energy per band
*-------------------------------------------------------------------*/
+
Word16 gsc_gainQ_fx( /*Q12*/
BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
const Word16 y_gain4[], /* i : Energy per band Q12 */
@@ -1200,11 +1497,14 @@ Word16 gsc_gainQ_fx( /*Q12*/
return mean_4g[0]; /*Q12*/
}
+
+
/*-------------------------------------------------------------------*
* VDQ_vec()
*
* Return the dequantized vector of index
*-------------------------------------------------------------------*/
+
static Word16 VDQ_vec_fx(
Word16 *Qvec_out_fx, /* o: Quanitzed vector */
const Word16 *mean_dic_fx, /* i: average codebook */
diff --git a/lib_com/gs_inact_switching_fx.c b/lib_com/gs_inact_switching_fx.c
index 582fd3c8a763b3b305570f79ea874eab67d1e067..119811275e34a99e7b2f22226dc8385c9709fc6f 100644
--- a/lib_com/gs_inact_switching_fx.c
+++ b/lib_com/gs_inact_switching_fx.c
@@ -33,144 +33,24 @@
/*------------------------------------------------------------------------*/
/* OUTPUT ARGUMENTS : */
/*------------------------------------------------------------------------*/
-
/*------------------------------------------------------------------------*/
/* RETURN ARGUMENTS : */
/* _ None */
/*========================================================================*/
-#ifndef REMOVE_EVS_DUPLICATES
-void Inac_swtch_ematch_fx(
- Word16 exc2[], /* i/o: CELP/GSC excitation buffer Q_exc*/
- Word16 dct_exc_tmp[], /* i : GSC excitation in DCT domain */
- Word16 lt_ener_per_band[], /* i/o: Long term energy per band Q12 */
- const Word16 coder_type, /* i : Coding mode */
- const Word16 L_frame, /* i : Frame lenght */
- const Word32 core_brate, /* i : Core bit rate */
- const Word16 Q_exc /* i : input and output format of exc2 */
- ,
- const Word16 bfi /* i : frame lost indicator */
- ,
- const Word16 last_core, /* i : Last core used */
- const Word16 last_codec_mode /* i : Last codec mode */
-)
-{
- Word16 Ener_per_bd[MBANDS_GN];
- Word16 ftmp;
- Word16 *pt_exc;
- Word16 j, i;
-
- Word16 exp, frac;
- Word32 L_tmp;
-
- /*--------------------------------------------------------------------------
- * average energy per band
- *--------------------------------------------------------------------------*/
-
- test();
- test();
- test();
- test();
- test();
- test();
- IF( EQ_16( coder_type, AUDIO ) && bfi == 0 )
- {
- Ener_per_band_comp_fx( dct_exc_tmp, Ener_per_bd, Q_exc, MBANDS_GN, 1 );
-
- /* reset long-term energy per band */
- FOR( i = 0; i < MBANDS_GN; i++ )
- {
- lt_ener_per_band[i] = Ener_per_bd[i];
- move16();
- }
- }
- ELSE IF( EQ_16( coder_type, VOICED ) || EQ_16( coder_type, GENERIC ) || EQ_16( coder_type, TRANSITION ) || ( last_core != ACELP_CORE ) || NE_16( last_codec_mode, MODE1 ) )
- {
- /* Find spectrum and energy per band for GC and VC frames */
- edct_16fx( exc2, dct_exc_tmp, L_frame, 5, EVS_MONO );
-
- Ener_per_band_comp_fx( dct_exc_tmp, Ener_per_bd, Q_exc, MBANDS_GN, 1 );
-
- /* reset long-term energy per band */
- FOR( i = 0; i < MBANDS_GN; i++ )
- {
- lt_ener_per_band[i] = Ener_per_bd[i];
- move16();
- }
- }
- ELSE IF( ( coder_type == INACTIVE ) && LE_32( core_brate, ACELP_24k40 ) )
- {
- /* Find spectrum and energy per band for inactive frames */
- edct_16fx( exc2, dct_exc_tmp, L_frame, 5, EVS_MONO );
- Ener_per_band_comp_fx( dct_exc_tmp, Ener_per_bd, Q_exc, MBANDS_GN, 1 );
-
- /* More agressive smoothing in the first 50 frames */
- pt_exc = dct_exc_tmp;
- move16();
- FOR( i = 0; i < MBANDS_GN; i++ )
- {
- /* Compute smoothing gain to apply with gain limitation */
- L_tmp = L_mult( ALPHA0_FX, lt_ener_per_band[i] ); /*Q(15+12+1)=Q(28) */
- L_tmp = L_mac( L_tmp, BETA0_FX, Ener_per_bd[i] ); /*Q28 */
- lt_ener_per_band[i] = round_fx( L_tmp ); /*Q12 */
- move16();
-
- ftmp = sub( lt_ener_per_band[i], Ener_per_bd[i] ); /*Q12 */
-
- /* ftmp = (float)pow(10, ftmp);= pow(2,3.321928*ftmp);*/
-
- L_tmp = L_mult( 27213, ftmp ); /*Q(13+12+1)=Q26 ; 27213=3.321928 in Q13 */
- L_tmp = L_shr( L_tmp, 10 ); /* From Q26 to Q16 */
- frac = L_Extract_lc( L_tmp, &exp ); /* Extract exponent of ftmp */
- ftmp = extract_l( Pow2( 14, frac ) ); /* Put 14 as exponent so that */
- /* output of Pow2() will be: */
- /* 16384 < Pow2() <= 32767 */
-
- exp = sub( exp, 14 );
- IF( LT_16( i, 2 ) )
- {
- FOR( j = 0; j < 8; j++ )
- {
- 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 );
- move16();
- pt_exc++;
- }
- }
- ELSE
- {
- FOR( j = 0; j < 16; j++ )
- {
- 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*/
- move16();
- pt_exc++;
- }
- }
- }
-
- /* Going back to time */
- edct_16fx( dct_exc_tmp, exc2, L_frame, 5, EVS_MONO );
- }
-
- return;
-}
-#endif
-void Inac_switch_ematch_ivas_fx(
+void Inac_switch_ematch_fx(
Word16 exc2[], /* i/o: CELP/GSC excitation buffer Q_exc*/
Word16 dct_exc_tmp[], /* i : GSC excitation in DCT domain */
Word16 lt_ener_per_band[], /* i/o: Long term energy per band Q12 */
const Word16 coder_type, /* i : Coding mode */
- const Word16 inactive_coder_type_flag, /* i : AVQ (0) or GSC (1) IC flag */
+ const Word16 inactive_coder_type_flag, /* i : AVQ (0) or GSC (1) IC flag */
const Word16 L_frame, /* i : Frame lenght */
const Word16 Q_exc, /* i : input and output format of exc2 */
const Word16 bfi, /* i : frame lost indicator */
const Word16 last_core, /* i : Last core used */
const Word16 last_codec_mode, /* i : Last codec mode */
- const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag*/
- const Word16 element_mode /* i : element mode */
+ const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag */
+ const Word16 element_mode /* i : element mode */
)
{
Word16 Ener_per_bd[MBANDS_GN16k];
@@ -251,7 +131,6 @@ void Inac_switch_ematch_ivas_fx(
exp = sub( exp, 14 );
IF( LT_16( i, 2 ) )
{
-#ifdef REMOVE_EVS_DUPLICATES
IF( EQ_16( element_mode, EVS_MONO ) )
{
FOR( j = 0; j < 8; j++ )
@@ -264,7 +143,6 @@ void Inac_switch_ematch_ivas_fx(
}
}
ELSE
-#endif
{
FOR( j = 0; j < 8; j++ )
{
@@ -278,7 +156,6 @@ void Inac_switch_ematch_ivas_fx(
}
ELSE
{
-#ifdef REMOVE_EVS_DUPLICATES
IF( EQ_16( element_mode, EVS_MONO ) )
{
FOR( j = 0; j < 16; j++ )
@@ -291,7 +168,6 @@ void Inac_switch_ematch_ivas_fx(
}
}
ELSE
-#endif
{
FOR( j = 0; j < 16; j++ )
{
@@ -306,9 +182,7 @@ void Inac_switch_ematch_ivas_fx(
}
/* Going back to time */
-#ifdef REMOVE_EVS_DUPLICATES
IF( GT_16( element_mode, EVS_MONO ) )
-#endif
{
Scale_sig( dct_exc_tmp, 240, 1 ); // Q_exc
Scale_sig( exc2, 240, 1 ); // Q_exc
diff --git a/lib_com/gs_noisefill_fx.c b/lib_com/gs_noisefill_fx.c
index 61aa1333c1426b3362ddd3a552ba811aa9db4220..208f205693ce9d67d04e96870bfcf4a15ea12d12 100644
--- a/lib_com/gs_noisefill_fx.c
+++ b/lib_com/gs_noisefill_fx.c
@@ -1332,8 +1332,6 @@ void highband_exc_dct_in_ivas_fx(
}
}
-
-#ifdef REMOVE_EVS_DUPLICATES
IF( EQ_16( element_mode, EVS_MONO ) )
{
Comp_and_apply_gain_fx( exc_diffQ, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 0, Qexc_diffQ, *Q_exc );
@@ -1346,7 +1344,6 @@ void highband_exc_dct_in_ivas_fx(
}
ELSE
{
-#endif
Word16 Q_tmp = *Q_exc;
move16();
Word16 Q_old = *Q_exc;
@@ -1373,9 +1370,7 @@ void highband_exc_dct_in_ivas_fx(
{
Scale_sig( exc_dct_in, L_frame, sub( *Q_exc, Q_old ) );
}
-#ifdef REMOVE_EVS_DUPLICATES
}
-#endif
/*--------------------------------------------------------------------------------------*
* add the correction layer to the LF bins,
@@ -1416,12 +1411,10 @@ void highband_exc_dct_in_ivas_fx(
Q_hb_exc = 0;
move16();
envelop_modify_fx( exc_diffQ, seed_tcx, last_bin, Ener_per_bd_iQ, *Q_exc, &Q_hb_exc );
-#ifdef REMOVE_EVS_DUPLICATES
+
test();
- IF( GT_16( *Q_exc, Q_hb_exc ) && GT_16( element_mode, EVS_MONO ) )
-#else
- IF( GT_16( *Q_exc, Q_hb_exc ) )
-#endif
+ test();
+ IF( GT_16( *Q_exc, Q_hb_exc ) && GT_16( element_mode, EVS_MONO ) && exc_wo_nf != NULL )
{
Scale_sig( exc_wo_nf, L_frame, sub( Q_hb_exc, *Q_exc ) );
*Q_exc = Q_hb_exc;
diff --git a/lib_com/hq2_core_com.c b/lib_com/hq2_core_com.c
deleted file mode 100644
index 121dae06a1ef18c4cd878c09921758a9d0ced65e..0000000000000000000000000000000000000000
--- a/lib_com/hq2_core_com.c
+++ /dev/null
@@ -1,177 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository. All Rights Reserved.
-
- This software is protected by copyright law and by international treaties.
- The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository retain full ownership rights in their respective contributions in
- the software. This notice grants no license of any kind, including but not limited to patent
- license, nor is any license granted by implication, estoppel or otherwise.
-
- Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
- contributions.
-
- This software is provided "AS IS", without any express or implied warranties. The software is in the
- development stage. It is intended exclusively for experts who have experience with such software and
- solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
- and fitness for a particular purpose are hereby disclaimed and excluded.
-
- Any dispute, controversy or claim arising under or in relation to providing this software shall be
- submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
- accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
- the United Nations Convention on Contracts on the International Sales of Goods.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include
-#include "cnst.h"
-#include "rom_com.h"
-#include "prot_fx.h"
-#include "basop_util.h"
-#include "basop_proto_func.h"
-#include "wmc_auto.h"
-
-
-#define WMC_TOOL_SKIP
-void bit_allocation_second_fx2(
- Word32 *Rk, /* Q16 */
- Word32 *Rk_sort, /* Q16 */
- Word16 BANDS, /* Q0 */
- const Word16 *band_width, /* Q0 */
- Word16 *k_sort, /* Q0 */
- Word16 *k_num, /* Q0 */
- const Word16 *p2a_flags, /* Q0 */
- const Word16 p2a_bands, /* Q0 */
- const Word16 *last_bitalloc, /* Q0 */
- const Word16 input_frame /* Q0 */
-)
-{
- Word16 k, k2 = 0;
- Word16 ever_bits[BANDS_MAX], ever_sort[BANDS_MAX]; /*Q12 */
- Word16 class_flag = 0;
- Word16 rk_temp = 32767, ever_temp = 32767; /*Q12 */
- Word16 exp;
- Word16 tmp;
- Word32 L_tmp;
- move16();
- move16();
- move16();
- move16();
-
-
- FOR( k = 0; k < BANDS; k++ )
- {
- test();
- test();
- IF( ( ( sub( k_sort[k], sub( BANDS, p2a_bands ) ) >= 0 ) && ( sub( p2a_flags[k_sort[k]], 1 ) == 0 ) ) ||
- ( ( sub( k_sort[k], ( BANDS - 2 ) ) >= 0 ) && ( sub( last_bitalloc[k_sort[k] - ( BANDS - 2 )], 1 ) == 0 ) ) )
- {
- exp = norm_s( band_width[k_sort[k]] );
- tmp = shl( band_width[k_sort[k]], exp ); /*Q(exp) */
- tmp = div_s( 16384, tmp ); /*Q(15+14-exp = 29-exp) */
- L_tmp = Mult_32_16( Rk_sort[k], tmp ); /* Q(16+29-exp-15 = 30-exp) */
- tmp = sub( 18, exp );
- ever_bits[k] = extract_l( L_shr( L_tmp, tmp ) ); /*Q12 */
- if ( sub( ever_bits[k], rk_temp ) < 0 )
- {
- rk_temp = ever_bits[k]; /* Q12 */
- k2 = k;
- move16();
- move16();
- }
- class_flag = 1;
- move16();
- }
- }
- IF( class_flag == 0 || sub( input_frame, L_FRAME8k ) == 0 )
- {
- FOR( k = 0; k < BANDS; k++ )
- {
- test();
- IF( sub( k_sort[k], sub( BANDS, p2a_bands ) ) < 0 && Rk_sort[k] > 0 )
- {
- exp = norm_s( band_width[k_sort[k]] );
- tmp = shl( band_width[k_sort[k]], exp ); /*Q(exp) */
- tmp = div_s( 16384, tmp ); /*Q(15+14-exp = 29-exp) */
- L_tmp = Mult_32_16( Rk_sort[k], tmp ); /* Q(16+29-exp-15 = 30-exp) */
- tmp = sub( 18, exp );
- ever_sort[k] = extract_l( L_shr( L_tmp, tmp ) ); /*Q12 */
- move16();
- IF( sub( ever_sort[k], ever_temp ) < 0 )
- {
- ever_temp = ever_sort[k]; /* Q12 */
- move16();
- k2 = k;
- move16();
- }
- }
- }
- }
-
- k_num[0] = k2;
- move16();
- IF( sub( k_sort[k2], sub( BANDS, 1 ) ) == 0 )
- {
- FOR( k = 0; k < BANDS; k++ )
- {
- IF( sub( k_sort[k], sub( k_sort[k2], 1 ) ) == 0 )
- {
- k_num[1] = k; /* Q0 */
- move16();
- }
- }
- }
- ELSE IF( k_sort[k2] == 0 )
- {
- FOR( k = 0; k < BANDS; k++ )
- {
- IF( sub( k_sort[k], add( k_sort[k2], 1 ) ) == 0 )
- {
- k_num[1] = k; /* Q0 */
- move16();
- }
- }
- }
- ELSE
- {
- IF( L_sub( Rk[sub( k_sort[k2], 1 )], Rk[add( k_sort[k2], 1 )] ) < 0 )
- {
- FOR( k = 0; k < BANDS; k++ )
- {
- IF( sub( k_sort[k], sub( k_sort[k2], 1 ) ) == 0 )
- {
- k_num[1] = k; /* Q0 */
- move16();
- }
- }
- }
- ELSE
- {
- FOR( k = 0; k < BANDS; k++ )
- {
- IF( sub( k_sort[k], add( k_sort[k2], 1 ) ) == 0 )
- {
- k_num[1] = k; /* Q0 */
- move16();
- }
- }
- }
- }
-
- return;
-}
-
-#undef WMC_TOOL_SKIP
diff --git a/lib_com/hq_conf.c b/lib_com/hq_conf.c
deleted file mode 100644
index 90a256ceab3e43b00c51885fe3e3ac35efea1113..0000000000000000000000000000000000000000
--- a/lib_com/hq_conf.c
+++ /dev/null
@@ -1,303 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository. All Rights Reserved.
-
- This software is protected by copyright law and by international treaties.
- The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository retain full ownership rights in their respective contributions in
- the software. This notice grants no license of any kind, including but not limited to patent
- license, nor is any license granted by implication, estoppel or otherwise.
-
- Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
- contributions.
-
- This software is provided "AS IS", without any express or implied warranties. The software is in the
- development stage. It is intended exclusively for experts who have experience with such software and
- solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
- and fitness for a particular purpose are hereby disclaimed and excluded.
-
- Any dispute, controversy or claim arising under or in relation to providing this software shall be
- submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
- accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
- the United Nations Convention on Contracts on the International Sales of Goods.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include "cnst.h"
-#include "rom_com.h"
-#include "prot_fx.h"
-#include "wmc_auto.h"
-
-
-void hq_configure_fx(
- const Word16 length, /* i : Frame length Q0 */
- const Word16 hqswb_clas, /* i : HQ SWB class Q0 */
- const Word32 core_brate, /* i : Codec bitrate Q0 */
- Word16 *num_sfm, /* o : Total number of subbands Q0 */
- Word16 *nb_sfm, /* o : Total number of coded bands Q0 */
- Word16 *start_norm, /* o : First norm to be SDE encoded Q0 */
- Word16 *num_env_bands, /* o : Number coded envelope bands Q0 */
- Word16 *numnrmibits, /* o : Number of bits in fall-back norm encoding Q0 */
- Word16 *hq_generic_offset, /* o : Freq offset for HQ GENERIC Q0 */
- Word16 *sfmsize, /* o : Subband bandwidths Q0 */
- Word16 *sfm_start, /* o : Subband start coefficients Q0 */
- Word16 *sfm_end /* o : Subband end coefficients Q0 */
-)
-{
- const Word16 *p_sfmsize;
- const Word16 *p_sfm_start;
- const Word16 *p_sfm_end;
- Word16 i, bw_ext;
-
- bw_ext = 0;
- move16();
-
- *start_norm = 0;
- move16();
-
- IF( EQ_16( length, L_SPEC48k ) )
- {
- IF( EQ_16( hqswb_clas, HQ_GEN_FB ) )
- {
- *num_sfm = NB_SFM;
- move16();
- p_sfmsize = band_len_HQ; /* Q0 */
- p_sfm_start = band_start_HQ; /* Q0 */
- p_sfm_end = band_end_HQ; /* Q0 */
-
- IF( GE_32( core_brate, HQ_32k ) )
- {
- *hq_generic_offset = HQ_GENERIC_FOFFSET_32K;
- move16();
- *num_env_bands = SFM_N_STA_10k;
- move16();
- }
- ELSE /*IF(EQ_32(core_brate, HQ_16k40) || EQ_32(core_brate, HQ_24k40))*/
- {
- *hq_generic_offset = HQ_GENERIC_FOFFSET_24K4;
- *num_env_bands = SFM_N_STA_8k;
- move16();
- move16();
- }
- *nb_sfm = *num_sfm;
- move16();
- }
- ELSE
- {
- IF( EQ_16( hqswb_clas, HQ_HARMONIC ) )
- {
- *num_sfm = SFM_N_HARM_FB;
- move16();
- *nb_sfm = SFM_N_HARM_FB;
- move16();
- *num_env_bands = SFM_N_HARM_FB;
- move16();
-
- p_sfmsize = band_len_harm; /* Q0 */
- p_sfm_start = band_start_harm; /* Q0 */
- p_sfm_end = band_end_harm; /* Q0 */
- }
- ELSE IF( EQ_16( hqswb_clas, HQ_HVQ ) )
- {
- IF( LT_32( core_brate, HQ_BWE_CROSSOVER_BRATE ) )
- {
- *num_sfm = SFM_N_HARM_FB;
- move16();
- *nb_sfm = HVQ_THRES_SFM_24k;
- move16();
- *num_env_bands = sub( *num_sfm, *nb_sfm );
- move16();
- *start_norm = HVQ_THRES_SFM_24k;
- move16();
- }
- ELSE
- {
- *num_sfm = SFM_N_HARM_FB;
- move16();
- *nb_sfm = HVQ_THRES_SFM_32k;
- move16();
- *num_env_bands = sub( *num_sfm, *nb_sfm );
- move16();
- *start_norm = HVQ_THRES_SFM_32k;
- move16();
- }
- p_sfmsize = band_len_harm; /* Q0 */
- p_sfm_start = band_start_harm; /* Q0 */
- p_sfm_end = band_end_harm; /* Q0 */
- }
- ELSE
- {
- *num_sfm = NB_SFM;
- move16();
- *nb_sfm = *num_sfm; /* Q0 */
- move16();
- *num_env_bands = NB_SFM;
- move16();
-
- p_sfmsize = band_len_HQ; /* Q0 */
- p_sfm_start = band_start_HQ; /* Q0 */
- p_sfm_end = band_end_HQ; /* Q0 */
- }
- }
- }
- ELSE IF( EQ_16( length, L_SPEC32k ) )
- {
- IF( EQ_16( hqswb_clas, HQ_HARMONIC ) )
- {
- *num_sfm = SFM_N_HARM;
- move16();
- *nb_sfm = SFM_N_HARM;
- move16();
- *num_env_bands = SFM_N_HARM;
- move16();
-
- p_sfmsize = band_len_harm; /* Q0 */
- p_sfm_start = band_start_harm; /* Q0 */
- p_sfm_end = band_end_harm; /* Q0 */
- }
- ELSE IF( EQ_16( hqswb_clas, HQ_HVQ ) )
- {
- IF( LT_32( core_brate, HQ_BWE_CROSSOVER_BRATE ) )
- {
- *num_sfm = SFM_N_HARM;
- move16();
- *nb_sfm = HVQ_THRES_SFM_24k;
- move16();
- *num_env_bands = sub( *num_sfm, *nb_sfm ); /* Q0 */
- move16();
-
- *start_norm = HVQ_THRES_SFM_24k;
- move16();
- }
- ELSE
- {
- *num_sfm = SFM_N_HARM;
- move16();
- *nb_sfm = HVQ_THRES_SFM_32k;
- move16();
- *num_env_bands = sub( *num_sfm, *nb_sfm ); /* Q0 */
- move16();
-
- *start_norm = HVQ_THRES_SFM_32k;
- move16();
- }
- p_sfmsize = band_len_harm;
- p_sfm_start = band_start_harm;
- p_sfm_end = band_end_harm;
- }
- ELSE IF( EQ_16( hqswb_clas, HQ_GEN_SWB ) )
- {
- *num_sfm = SFM_N_SWB;
- move16();
- p_sfmsize = band_len_HQ; /* Q0 */
- p_sfm_start = band_start_HQ; /* Q0 */
- p_sfm_end = band_end_HQ; /* Q0 */
-
- IF( GE_32( core_brate, HQ_32k ) )
- {
- *hq_generic_offset = HQ_GENERIC_FOFFSET_32K;
- move16();
- *num_env_bands = SFM_N_STA_10k;
- move16();
- }
- ELSE /*if( EQ_32(core_brate, HQ_24k40))*/
- {
- *hq_generic_offset = HQ_GENERIC_FOFFSET_24K4;
- move16();
- *num_env_bands = SFM_N_STA_8k;
- move16();
- }
-
- *nb_sfm = *num_sfm;
- move16();
- }
- ELSE
- {
- /* HQ_NORMAL and HQ_TRANSIENT */
- *num_sfm = SFM_N_SWB;
- move16();
- *nb_sfm = *num_sfm;
- move16();
- *num_env_bands = SFM_N_SWB;
- move16();
-
- p_sfmsize = band_len_HQ; /* Q0 */
- p_sfm_start = band_start_HQ; /* Q0 */
- p_sfm_end = band_end_HQ; /* Q0 */
- }
- }
- ELSE IF( EQ_16( length, L_SPEC48k_EXT ) )
- {
- bw_ext = 1;
- p_sfmsize = band_len_HQ; /* Q0 */
- p_sfm_start = band_start_HQ; /* Q0 */
- p_sfm_end = band_end_HQ; /* Q0 */
- *num_sfm = NB_SFM;
- }
- ELSE IF( EQ_16( length, L_SPEC16k_EXT ) )
- {
- bw_ext = 1;
- move16();
- p_sfmsize = band_len_wb; /* Q0 */
- p_sfm_start = band_start_wb; /* Q0 */
- p_sfm_end = band_end_wb; /* Q0 */
- *num_sfm = SFM_N_WB;
- move16();
- }
- ELSE
- {
- *num_sfm = SFM_N_WB;
- move16();
- *nb_sfm = *num_sfm; /* Q0 */
- move16();
- *num_env_bands = SFM_N_WB;
- move16();
-
- p_sfmsize = band_len_wb; /* Q0 */
- p_sfm_start = band_start_wb; /* Q0 */
- p_sfm_end = band_end_wb; /* Q0 */
- }
- IF( bw_ext )
- {
- FOR( i = 0; i < *num_sfm; i++ )
- {
- /*sfmsize[i] = (int16_t)(1.25f * p_sfmsize[i]);*/
- sfmsize[i] = mult_r( shl( p_sfmsize[i], 1 ), 20480 /* 1.25 in Q14 */ ); /* Q0 */
- move16();
- /*sfm_start[i] = (int16_t)(1.25f * p_sfm_start[i]);*/
- sfm_start[i] = mult_r( shl( p_sfm_start[i], 1 ), 20480 /* 1.25 in Q14 */ ); /* Q0 */
- move16();
- /*sfm_end[i] = (int16_t)(1.25f * p_sfm_end[i]);*/
- sfm_end[i] = mult_r( shl( p_sfm_end[i], 1 ), 20480 /* 1.25 in Q14 */ ); /* Q0 */
- move16();
- }
- *nb_sfm = *num_sfm; /* Q0 */
- *num_env_bands = *num_sfm; /* Q0 */
- move16();
- move16();
- }
- ELSE
- {
- Copy( p_sfmsize, sfmsize, *num_sfm );
- Copy( p_sfm_start, sfm_start, *num_sfm );
- Copy( p_sfm_end, sfm_end, *num_sfm );
- }
-
- *numnrmibits = extract_l( L_mult0( sub( *num_env_bands, 1 ), NORMI_BITS ) );
- move16();
-
- return;
-}
diff --git a/lib_com/hq_conf_fx.c b/lib_com/hq_conf_fx.c
index 503975363a6fa1a3480f1d55b15ad4d06e919962..b400624487bfbb9c5b3bd897c1d88f791382cbb2 100644
--- a/lib_com/hq_conf_fx.c
+++ b/lib_com/hq_conf_fx.c
@@ -8,6 +8,7 @@
#include "rom_com.h" /* Static table prototypes */
#include "prot_fx.h" /* Function prototypes */
#include "ivas_prot_fx.h"
+#include "wmc_auto.h"
/*--------------------------------------------------------------------------*
* hq_configure()
@@ -303,11 +304,7 @@ void hq_configure_evs_fx(
*start_norm = 0;
move16();
-#ifndef SOLVED_COMP_ENC_DEC
IF( EQ_16( length, L_FRAME48k ) ) /*tbv SOLVED_COMP_ENC_DEC*/
-#else
- IF( EQ_16( length, L_SPEC48k ) )
-#endif
{
IF( EQ_16( hqswb_clas, HQ_GEN_FB ) )
{
@@ -542,3 +539,263 @@ void hq_configure_evs_fx(
return;
}
+
+void hq_configure_fx(
+ const Word16 length, /* i : Frame length Q0 */
+ const Word16 hqswb_clas, /* i : HQ SWB class Q0 */
+ const Word32 core_brate, /* i : Codec bitrate Q0 */
+ Word16 *num_sfm, /* o : Total number of subbands Q0 */
+ Word16 *nb_sfm, /* o : Total number of coded bands Q0 */
+ Word16 *start_norm, /* o : First norm to be SDE encoded Q0 */
+ Word16 *num_env_bands, /* o : Number coded envelope bands Q0 */
+ Word16 *numnrmibits, /* o : Number of bits in fall-back norm encoding Q0 */
+ Word16 *hq_generic_offset, /* o : Freq offset for HQ GENERIC Q0 */
+ Word16 *sfmsize, /* o : Subband bandwidths Q0 */
+ Word16 *sfm_start, /* o : Subband start coefficients Q0 */
+ Word16 *sfm_end /* o : Subband end coefficients Q0 */
+)
+{
+ const Word16 *p_sfmsize;
+ const Word16 *p_sfm_start;
+ const Word16 *p_sfm_end;
+ Word16 i, bw_ext;
+
+ bw_ext = 0;
+ move16();
+
+ *start_norm = 0;
+ move16();
+
+ IF( EQ_16( length, L_SPEC48k ) )
+ {
+ IF( EQ_16( hqswb_clas, HQ_GEN_FB ) )
+ {
+ *num_sfm = NB_SFM;
+ move16();
+ p_sfmsize = band_len_HQ; /* Q0 */
+ p_sfm_start = band_start_HQ; /* Q0 */
+ p_sfm_end = band_end_HQ; /* Q0 */
+
+ IF( GE_32( core_brate, HQ_32k ) )
+ {
+ *hq_generic_offset = HQ_GENERIC_FOFFSET_32K;
+ move16();
+ *num_env_bands = SFM_N_STA_10k;
+ move16();
+ }
+ ELSE /*IF(EQ_32(core_brate, HQ_16k40) || EQ_32(core_brate, HQ_24k40))*/
+ {
+ *hq_generic_offset = HQ_GENERIC_FOFFSET_24K4;
+ *num_env_bands = SFM_N_STA_8k;
+ move16();
+ move16();
+ }
+ *nb_sfm = *num_sfm;
+ move16();
+ }
+ ELSE
+ {
+ IF( EQ_16( hqswb_clas, HQ_HARMONIC ) )
+ {
+ *num_sfm = SFM_N_HARM_FB;
+ move16();
+ *nb_sfm = SFM_N_HARM_FB;
+ move16();
+ *num_env_bands = SFM_N_HARM_FB;
+ move16();
+
+ p_sfmsize = band_len_harm; /* Q0 */
+ p_sfm_start = band_start_harm; /* Q0 */
+ p_sfm_end = band_end_harm; /* Q0 */
+ }
+ ELSE IF( EQ_16( hqswb_clas, HQ_HVQ ) )
+ {
+ IF( LT_32( core_brate, HQ_BWE_CROSSOVER_BRATE ) )
+ {
+ *num_sfm = SFM_N_HARM_FB;
+ move16();
+ *nb_sfm = HVQ_THRES_SFM_24k;
+ move16();
+ *num_env_bands = sub( *num_sfm, *nb_sfm );
+ move16();
+ *start_norm = HVQ_THRES_SFM_24k;
+ move16();
+ }
+ ELSE
+ {
+ *num_sfm = SFM_N_HARM_FB;
+ move16();
+ *nb_sfm = HVQ_THRES_SFM_32k;
+ move16();
+ *num_env_bands = sub( *num_sfm, *nb_sfm );
+ move16();
+ *start_norm = HVQ_THRES_SFM_32k;
+ move16();
+ }
+ p_sfmsize = band_len_harm; /* Q0 */
+ p_sfm_start = band_start_harm; /* Q0 */
+ p_sfm_end = band_end_harm; /* Q0 */
+ }
+ ELSE
+ {
+ *num_sfm = NB_SFM;
+ move16();
+ *nb_sfm = *num_sfm; /* Q0 */
+ move16();
+ *num_env_bands = NB_SFM;
+ move16();
+
+ p_sfmsize = band_len_HQ; /* Q0 */
+ p_sfm_start = band_start_HQ; /* Q0 */
+ p_sfm_end = band_end_HQ; /* Q0 */
+ }
+ }
+ }
+ ELSE IF( EQ_16( length, L_SPEC32k ) )
+ {
+ IF( EQ_16( hqswb_clas, HQ_HARMONIC ) )
+ {
+ *num_sfm = SFM_N_HARM;
+ move16();
+ *nb_sfm = SFM_N_HARM;
+ move16();
+ *num_env_bands = SFM_N_HARM;
+ move16();
+
+ p_sfmsize = band_len_harm; /* Q0 */
+ p_sfm_start = band_start_harm; /* Q0 */
+ p_sfm_end = band_end_harm; /* Q0 */
+ }
+ ELSE IF( EQ_16( hqswb_clas, HQ_HVQ ) )
+ {
+ IF( LT_32( core_brate, HQ_BWE_CROSSOVER_BRATE ) )
+ {
+ *num_sfm = SFM_N_HARM;
+ move16();
+ *nb_sfm = HVQ_THRES_SFM_24k;
+ move16();
+ *num_env_bands = sub( *num_sfm, *nb_sfm ); /* Q0 */
+ move16();
+
+ *start_norm = HVQ_THRES_SFM_24k;
+ move16();
+ }
+ ELSE
+ {
+ *num_sfm = SFM_N_HARM;
+ move16();
+ *nb_sfm = HVQ_THRES_SFM_32k;
+ move16();
+ *num_env_bands = sub( *num_sfm, *nb_sfm ); /* Q0 */
+ move16();
+
+ *start_norm = HVQ_THRES_SFM_32k;
+ move16();
+ }
+ p_sfmsize = band_len_harm;
+ p_sfm_start = band_start_harm;
+ p_sfm_end = band_end_harm;
+ }
+ ELSE IF( EQ_16( hqswb_clas, HQ_GEN_SWB ) )
+ {
+ *num_sfm = SFM_N_SWB;
+ move16();
+ p_sfmsize = band_len_HQ; /* Q0 */
+ p_sfm_start = band_start_HQ; /* Q0 */
+ p_sfm_end = band_end_HQ; /* Q0 */
+
+ IF( GE_32( core_brate, HQ_32k ) )
+ {
+ *hq_generic_offset = HQ_GENERIC_FOFFSET_32K;
+ move16();
+ *num_env_bands = SFM_N_STA_10k;
+ move16();
+ }
+ ELSE /*if( EQ_32(core_brate, HQ_24k40))*/
+ {
+ *hq_generic_offset = HQ_GENERIC_FOFFSET_24K4;
+ move16();
+ *num_env_bands = SFM_N_STA_8k;
+ move16();
+ }
+
+ *nb_sfm = *num_sfm;
+ move16();
+ }
+ ELSE
+ {
+ /* HQ_NORMAL and HQ_TRANSIENT */
+ *num_sfm = SFM_N_SWB;
+ move16();
+ *nb_sfm = *num_sfm;
+ move16();
+ *num_env_bands = SFM_N_SWB;
+ move16();
+
+ p_sfmsize = band_len_HQ; /* Q0 */
+ p_sfm_start = band_start_HQ; /* Q0 */
+ p_sfm_end = band_end_HQ; /* Q0 */
+ }
+ }
+ ELSE IF( EQ_16( length, L_SPEC48k_EXT ) )
+ {
+ bw_ext = 1;
+ p_sfmsize = band_len_HQ; /* Q0 */
+ p_sfm_start = band_start_HQ; /* Q0 */
+ p_sfm_end = band_end_HQ; /* Q0 */
+ *num_sfm = NB_SFM;
+ }
+ ELSE IF( EQ_16( length, L_SPEC16k_EXT ) )
+ {
+ bw_ext = 1;
+ move16();
+ p_sfmsize = band_len_wb; /* Q0 */
+ p_sfm_start = band_start_wb; /* Q0 */
+ p_sfm_end = band_end_wb; /* Q0 */
+ *num_sfm = SFM_N_WB;
+ move16();
+ }
+ ELSE
+ {
+ *num_sfm = SFM_N_WB;
+ move16();
+ *nb_sfm = *num_sfm; /* Q0 */
+ move16();
+ *num_env_bands = SFM_N_WB;
+ move16();
+
+ p_sfmsize = band_len_wb; /* Q0 */
+ p_sfm_start = band_start_wb; /* Q0 */
+ p_sfm_end = band_end_wb; /* Q0 */
+ }
+ IF( bw_ext )
+ {
+ FOR( i = 0; i < *num_sfm; i++ )
+ {
+ /*sfmsize[i] = (int16_t)(1.25f * p_sfmsize[i]);*/
+ sfmsize[i] = mult_r( shl( p_sfmsize[i], 1 ), 20480 /* 1.25 in Q14 */ ); /* Q0 */
+ move16();
+ /*sfm_start[i] = (int16_t)(1.25f * p_sfm_start[i]);*/
+ sfm_start[i] = mult_r( shl( p_sfm_start[i], 1 ), 20480 /* 1.25 in Q14 */ ); /* Q0 */
+ move16();
+ /*sfm_end[i] = (int16_t)(1.25f * p_sfm_end[i]);*/
+ sfm_end[i] = mult_r( shl( p_sfm_end[i], 1 ), 20480 /* 1.25 in Q14 */ ); /* Q0 */
+ move16();
+ }
+ *nb_sfm = *num_sfm; /* Q0 */
+ *num_env_bands = *num_sfm; /* Q0 */
+ move16();
+ move16();
+ }
+ ELSE
+ {
+ Copy( p_sfmsize, sfmsize, *num_sfm );
+ Copy( p_sfm_start, sfm_start, *num_sfm );
+ Copy( p_sfm_end, sfm_end, *num_sfm );
+ }
+
+ *numnrmibits = extract_l( L_mult0( sub( *num_env_bands, 1 ), NORMI_BITS ) );
+ move16();
+
+ return;
+}
diff --git a/lib_com/ifft_rel.c b/lib_com/ifft_rel_fx.c
similarity index 100%
rename from lib_com/ifft_rel.c
rename to lib_com/ifft_rel_fx.c
diff --git a/lib_com/int_lsp.c b/lib_com/int_lsp_fx.c
similarity index 100%
rename from lib_com/int_lsp.c
rename to lib_com/int_lsp_fx.c
diff --git a/lib_com/interleave_spectrum.c b/lib_com/interleave_spectrum_fx.c
similarity index 97%
rename from lib_com/interleave_spectrum.c
rename to lib_com/interleave_spectrum_fx.c
index 5c4c98e291e33db70a7fa6a8763926f963fe485c..e8bb728ff891278b5eb24adb7f15f4d6ba001ed3 100644
--- a/lib_com/interleave_spectrum.c
+++ b/lib_com/interleave_spectrum_fx.c
@@ -63,11 +63,7 @@ void interleave_spectrum_fx(
/* Common inits */
p1 = coefs; /*Q12*/
p_out = coefs_out;
-#ifdef SOLVED_COMP_ENC_DEC
- IF( EQ_16( length, L_SPEC48k ) )
-#else
IF( EQ_16( length, L_FRAME48k ) )
-#endif
{
bw = intl_bw_48; /*Q0*/
cnt = intl_cnt_48; /*Q0*/
@@ -337,20 +333,12 @@ void de_interleave_spectrum_fx(
p1 = coefs_out;
l_frame = length;
move16();
-#ifdef SOLVED_COMP_ENC_DEC
- IF( EQ_16( length, L_SPEC48k ) )
-#else
IF( EQ_16( length, L_FRAME48k ) )
-#endif
{
bw = intl_bw_48; /*Q0*/
cnt = intl_cnt_48; /*Q0*/
grps = N_INTL_GRP_48;
move16();
-#ifdef SOLVED_COMP_ENC_DEC
- l_frame = L_FRAME48k;
- move16();
-#endif
p2 = coefs_out + sublen[2]; /* 240, length/4 */
p3 = coefs_out + sublen[4]; /* 480, 2*length/4 */
p4 = coefs_out + sublen[5]; /* 720, 3*length/4 */
diff --git a/lib_com/interpol.c b/lib_com/interpol_fx.c
similarity index 98%
rename from lib_com/interpol.c
rename to lib_com/interpol_fx.c
index a490a755269c9fa7d3f9bdeb440b60bf7f483253..030d417359a34f3d61c7948d4cbde3c2fad9b949 100644
--- a/lib_com/interpol.c
+++ b/lib_com/interpol_fx.c
@@ -70,9 +70,14 @@ Word32 Interpol_lc_fx( /* o : interpolated value
c2 += up_samp; /* move16() not needed, since the coefficient can be rearrange in bit exact way */
c1 += up_samp;
}
+#ifdef OPT_SBA_ENC_V2_BE
+ L_sum = W_shl_sat_l( L_sum64, 1 ); /*Q15*/
+ }
+#else
L_sum = W_sat_l( L_sum64 ); /*Q14*/
}
L_sum = L_shl_sat( L_sum, 1 ); /*Q15*/
+#endif
return L_sum;
}
diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h
index 9243b3f508b02be0f20e6006f8c768413d4b37ce..d3e52ec16775dd7abbb033a08b3a2801f65e77a6 100644
--- a/lib_com/ivas_cnst.h
+++ b/lib_com/ivas_cnst.h
@@ -383,7 +383,7 @@ typedef enum
#define PARAM_ISM_MAX_CHAN 16
#define PARAM_ISM_HYS_BUF_SIZE 10
-#define STEP_PARAM_ISM_POW_RATIO_NBITS_Q15 (4681) /* 1.0f / (float)((1 << PARAM_ISM_POW_RATIO_NBITS) - 1) */
+#define STEP_PARAM_ISM_POW_RATIO_NBITS_Q31 (306783378) /* 1.0f / (float)((1 << PARAM_ISM_POW_RATIO_NBITS) - 1) */
/* ISM DTX */
#define ISM_Q_STEP_FX ( 10485760 ) // Q22
@@ -509,8 +509,8 @@ enum
#define STEREO_DFT32MS_N_NS FRAME_SIZE_NS /* 20 ms */
#define STEREO_DFT32MS_OVL_NS 3125000L /* 3.125ms - Overlap for the outer edges of windows on decoder */
#define STEREO_DFT32MS_OVL2_NS 9375000L /* 9.375ms - Overlap for the inner edges of windows on decoder */
-#define STEREO_DFT32MS_WIN_CENTER_NS ( int32_t )( ( FRAME_SIZE_NS + STEREO_DFT32MS_OVL_NS ) * 0.5f ) /* 11.5625ms - mid point of the two windows wrt the left edge of overlap */
-#define STEREO_DFT32MS_ZP_NS ( int32_t )( 0.5f * ( STEREO_DFT32MS_N_NS - STEREO_DFT32MS_WIN_CENTER_NS - ( STEREO_DFT32MS_OVL2_NS * 0.5f ) ) ) /* 2 sided zp calculated such that window size is satisfied */
+#define STEREO_DFT32MS_WIN_CENTER_NS ( Word32 )( ( FRAME_SIZE_NS + STEREO_DFT32MS_OVL_NS ) * 0.5f ) /* 11.5625ms - mid point of the two windows wrt the left edge of overlap */
+#define STEREO_DFT32MS_ZP_NS ( Word32 )( 0.5f * ( STEREO_DFT32MS_N_NS - STEREO_DFT32MS_WIN_CENTER_NS - ( STEREO_DFT32MS_OVL2_NS * 0.5f ) ) ) /* 2 sided zp calculated such that window size is satisfied */
#define STEREO_DFT32MS_OVL_MAX NS2SA( 48000, STEREO_DFT32MS_OVL_NS )
#define STEREO_DFT32MS_OVL2_MAX NS2SA( 48000, STEREO_DFT32MS_OVL2_NS )
@@ -799,7 +799,7 @@ enum fea_names
#define L_DEC_MEM_LEN_ICA L_NCSHIFTMAX + ( N_MAX_SHIFT_CHANGE + 1 ) + SINC_ORDER1 / INTERP_FACTOR1
#define L_FRAME_DS NS2SA( CORR_INTER_FS, FRAME_SIZE_NS )
#define L_XCORRMEM_DS NS2SA( CORR_INTER_FS, 2 * ( ACELP_LOOK_NS ) )
-#define L_NCSHIFT_DS ( int16_t )( ( ( int32_t )(CORR_INTER_FS) *L_NCSHIFTMAX ) / 48000L )
+#define L_NCSHIFT_DS ( Word16 )( ( ( Word32 )(CORR_INTER_FS) *L_NCSHIFTMAX ) / 48000L )
#define L_SAMPLES_LA_NS 625000L
#define L_MEM_RECALC_TBE_16K NS2SA( 16000, L_MEM_RECALC_TBE_NS )
@@ -1446,7 +1446,7 @@ typedef struct {
typedef struct {
Word32 value[81];
- unsigned short length[81];
+ UWord16 length[81];
} HUFF_ELEMENTS;
typedef struct {
diff --git a/lib_com/ivas_dirac_com_fx.c b/lib_com/ivas_dirac_com_fx.c
index 4279065b043f8ebf4767bccca68e997997ac77c6..14dd6c1484c1b454c76081e00de84f7aeabd1864 100644
--- a/lib_com/ivas_dirac_com_fx.c
+++ b/lib_com/ivas_dirac_com_fx.c
@@ -608,8 +608,7 @@ 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*/
Word16 *i_e_band )
{
Word16 i;
@@ -783,122 +782,6 @@ void computeDirectionVectors_fx(
*
*
*------------------------------------------------------------------------*/
-
-void computeDiffuseness_fx(
- Word32 *buffer_intensity[DIRAC_NUM_DIMS][DIRAC_NO_COL_AVG_DIFF], // i: Q(q_factor_intensity)
- const Word32 *buffer_energy, // i: Q(q_factor_energy)
- const Word16 num_freq_bands,
- Word32 *diffuseness, // o: exp(out_exp)
- Word16 q_factor_intensity,
- Word16 q_factor_energy,
- Word16 *out_exp /*Ouput Q*/
-)
-{
- Word32 intensity_slow[DIRAC_NUM_DIMS * CLDFB_NO_CHANNELS_MAX];
- Word32 intensity_slow_abs[CLDFB_NO_CHANNELS_MAX];
- Word32 energy_slow[CLDFB_NO_CHANNELS_MAX];
- Word16 i, j, k;
- Word32 tmp = 0, tmp_1;
- move32();
- Word32 *p_tmp;
- const Word32 *p_tmp_c;
-
- /* Compute Intensity slow and energy slow */
-
- set32_fx( intensity_slow, 0, DIRAC_NUM_DIMS * CLDFB_NO_CHANNELS_MAX );
- set32_fx( intensity_slow_abs, 0, CLDFB_NO_CHANNELS_MAX );
- set32_fx( energy_slow, 0, CLDFB_NO_CHANNELS_MAX );
-
- FOR( i = 0; i < DIRAC_NO_COL_AVG_DIFF; ++i )
- {
- /* Energy slow */
- p_tmp_c = buffer_energy + i * num_freq_bands;
- FOR( k = 0; k < num_freq_bands; k++ )
- {
- energy_slow[k] = L_add( *( p_tmp_c++ ), energy_slow[k] ); // Q(q_factor_energy)
- move32();
- }
-
- /* Intensity slow */
- 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( *( p_tmp++ ), intensity_slow[j * num_freq_bands + k] );
- move32();
- }
- }
- }
-
- /* intensity_slow.^2 + intensity_slow_abs*/
- FOR( j = 0; j < DIRAC_NUM_DIMS; ++j )
- {
- p_tmp = intensity_slow + j * num_freq_bands;
-
- FOR( k = 0; k < num_freq_bands; k++ )
- {
- *( p_tmp ) = Mpy_32_32( *p_tmp, *( p_tmp ) ); // Q( 2*(q_factor_intensity + scale_fact - 1) -31 )
- intensity_slow_abs[k] = L_add( *( p_tmp++ ), intensity_slow_abs[k] );
- move32();
- move32();
- }
- }
- Word16 init_exp = sub( 62, shl( q_factor_intensity, 1 ) ); // 31 - ( 2 * q_factor_intensity - 31 )
- Word16 exp;
-
- Word16 exp1 = 0, exp2;
- move16();
- /* Compute Diffuseness */
- p_tmp = intensity_slow_abs;
- FOR( i = 0; i < num_freq_bands; ++i )
- {
- exp = init_exp;
- move16();
- Word32 temp = *( p_tmp++ );
- move32();
- tmp_1 = Sqrt32( temp, &exp );
- tmp = L_deposit_h( BASOP_Util_Divide3232_Scale( tmp_1, L_add( energy_slow[i], 1 ), &exp1 ) );
- exp2 = add( sub( 31, exp1 ), sub( sub( 31, exp ), q_factor_energy ) );
- IF( GT_32( exp2, 30 ) )
- {
- tmp = L_shr( tmp, sub( exp2, 30 ) );
- exp2 = sub( exp2, sub( exp2, 30 ) );
- }
- tmp = L_sub( L_shl( 1, exp2 ), tmp );
- // diffuseness[i] = ( ( tmp < L_shl( 1, exp2 ) ) ? ( ( tmp < 0 ) ? 0 : tmp ) : L_shl( 1, exp2 ) );
-
- IF( LT_32( tmp, L_shl( 1, exp2 ) ) )
- {
- IF( tmp < 0 )
- {
- diffuseness[i] = 0;
- }
- ELSE
- {
- diffuseness[i] = tmp;
- }
- }
- ELSE
- {
- diffuseness[i] = L_shl( 1, exp2 );
- }
- out_exp[i] = exp2;
-
- move32();
- move16();
- }
- return;
-}
-
-
-/*-------------------------------------------------------------------------
- * computeDiffuseness()
- *
- *
- *------------------------------------------------------------------------*/
-
void computeDiffuseness_fixed(
Word32 *buffer_intensity[DIRAC_NUM_DIMS][DIRAC_NO_COL_AVG_DIFF], // i: Q(q_factor_intensity)
const Word32 *buffer_energy, // i: Q(q_factor_energy)
@@ -911,6 +794,8 @@ void computeDiffuseness_fixed(
{
Word32 intensity_slow[DIRAC_NUM_DIMS * CLDFB_NO_CHANNELS_MAX];
Word32 intensity_slow_abs[CLDFB_NO_CHANNELS_MAX];
+ Word64 intensity_slow_abs_64[CLDFB_NO_CHANNELS_MAX];
+ Word16 intensity_slow_abs_q[CLDFB_NO_CHANNELS_MAX];
Word32 energy_slow[CLDFB_NO_CHANNELS_MAX];
Word16 i, j, k;
Word32 tmp = 0;
@@ -918,7 +803,7 @@ void computeDiffuseness_fixed(
Word32 *p_tmp;
const Word32 *p_tmp_c;
Word16 min_q_shift1, min_q_shift2, exp1, exp2, q_tmp;
- Word16 q_ene, q_intensity, q_intensity_slow;
+ Word16 q_ene, q_intensity;
/* Compute Intensity slow and energy slow buffer_intensity and buffer_energy */
@@ -1011,19 +896,29 @@ void computeDiffuseness_fixed(
min_q_shift1 = sub( min_q_shift1, idiv1616( add( find_guarded_bits_fx( DIRAC_NUM_DIMS ), 1 ), 2 ) );
scale_sig32( intensity_slow, i_mult( DIRAC_NUM_DIMS, num_freq_bands ), min_q_shift1 );
q_intensity = add( q_intensity, min_q_shift1 );
+ FOR( k = 0; k < num_freq_bands; k++ )
+ {
+ intensity_slow_abs_64[k] = 0;
+ move64();
+ }
/* intensity_slow.^2 + intensity_slow_abs*/
FOR( j = 0; j < DIRAC_NUM_DIMS; ++j )
{
p_tmp = intensity_slow + j * num_freq_bands;
-
FOR( k = 0; k < num_freq_bands; k++ )
{
- intensity_slow_abs[k] = Madd_32_32( intensity_slow_abs[k], p_tmp[k], p_tmp[k] );
- move32();
+ intensity_slow_abs_64[k] = W_add( intensity_slow_abs_64[k], W_mult_32_32( p_tmp[k], p_tmp[k] ) ); // 2*q_intensity+1
}
}
- q_intensity_slow = sub( add( q_intensity, q_intensity ), 31 );
+ FOR( k = 0; k < num_freq_bands; k++ )
+ {
+ Word16 shift = W_norm( intensity_slow_abs_64[k] );
+ intensity_slow_abs[k] = W_extract_h( W_shl( intensity_slow_abs_64[k], shift ) );
+ move32();
+ intensity_slow_abs_q[k] = sub( add( add( q_intensity, q_intensity ), shift ), 31 );
+ move16();
+ }
/* Compute Diffuseness */
p_tmp = intensity_slow_abs;
@@ -1031,7 +926,7 @@ void computeDiffuseness_fixed(
move16();
FOR( i = 0; i < num_freq_bands; ++i )
{
- exp1 = sub( 31, q_intensity_slow );
+ exp1 = sub( 31, intensity_slow_abs_q[i] );
tmp = Sqrt32( p_tmp[i], &exp1 );
tmp = BASOP_Util_Divide3232_Scale_newton( tmp, L_add( energy_slow[i], EPSILLON_FX ), &exp2 );
@@ -1070,7 +965,6 @@ void computeDiffuseness_fixed(
return;
}
-
Word32 deindex_azimuth_fx( /* o : output Q22 */
Word16 id_phi, /* i : index */
const Word16 no_bits, /* i : number of bits for the spherical grid */
diff --git a/lib_com/ivas_fb_mixer_fx.c b/lib_com/ivas_fb_mixer_fx.c
index d5cd8d4f17875b44cbcecb447e9bf0463a25f056..0d8a74514326453362b8dc6ff4c2d0ace00929e0 100644
--- a/lib_com/ivas_fb_mixer_fx.c
+++ b/lib_com/ivas_fb_mixer_fx.c
@@ -759,6 +759,13 @@ void ivas_fb_mixer_process_fx(
pMdft_out_fx[0] = Mdft_out_0_fx;
pMdft_out_fx[1] = Mdft_out_1_fx;
+#ifdef OPT_SBA_ENC_V1_BE
+ Word16 total_guard = find_guarded_bits_fx( num_bands );
+ Word16 total_guard_2 = find_guarded_bits_fx( shl( frame_len, 1 ) );
+ Word16 tmp_q = sub( sub( *q_mixer_mat_fx, total_guard ), 32 ); // Q30 + hFbMixer->q_prior_mixer_fx - 31 - total_guard - 31
+ Word16 len = shl( frame_len, 1 );
+ Word16 res_q, q_check;
+#endif
FOR( ch = ( hFbMixer->fb_cfg->active_w_mixing == 0 ); ch < hFbMixer->fb_cfg->num_out_chans; ch++ )
{
/* Run a loop of 2 to calculate current frame's filterbank output and prev frame's output */
@@ -773,6 +780,12 @@ void ivas_fb_mixer_process_fx(
IF( in_out_mixer_map[ch][j] != 0 )
{
+#ifdef OPT_SBA_ENC_V1_BE
+ res_q = add( tmp_q, hFbMixer->q_ppFilterbank_inFR[j] );
+ q_check = s_min( q_pOut_fr_fx, res_q );
+ scale_sig32( pOut_fr_re_fx, frame_len, sub( q_check, q_pOut_fr_fx ) );
+ scale_sig32( pOut_fr_im_fx, frame_len, sub( q_check, q_pOut_fr_fx ) );
+#endif
Word32 filterbank_mixer_bins_re_fx[L_FRAME48k];
Word32 filterbank_mixer_bins_im_fx[L_FRAME48k];
Word32 *pFb_inFR_re_fx = hFbMixer->ppFilterbank_inFR_re_fx[j]; // Q(hFbMixer->q_ppFilterbank_inFR_re_fx)
@@ -781,8 +794,10 @@ void ivas_fb_mixer_process_fx(
set_zero_fx( filterbank_mixer_bins_re_fx, frame_len );
set_zero_fx( filterbank_mixer_bins_im_fx, frame_len );
+#ifndef OPT_SBA_ENC_V1_BE
Word16 total_guard = find_guarded_bits_fx( num_bands );
move16();
+#endif
FOR( i = 0; i < num_bands; i++ )
{
Word16 start_offset = pFb->fb_consts.pFilterbank_bins_start_offset[i];
@@ -808,15 +823,19 @@ void ivas_fb_mixer_process_fx(
hFbMixer->prior_mixer_fx[ch][j][i] = mixer_mat_fx[ch][j][i]; // Q(q_mixer_mat_fx)
move32();
}
+#ifndef OPT_SBA_ENC_V1_BE
Word16 res_q = 0;
move16();
+#endif
FOR( k = 0; k < frame_len; k++ )
{
Word32 temp_out_re_fx, temp_out_im_fx;
ivas_cmult_fix( filterbank_mixer_bins_re_fx[k], filterbank_mixer_bins_im_fx[k], pFb_inFR_re_fx[k],
pFb_inFR_im_fx[k], &temp_out_re_fx, &temp_out_im_fx );
+#ifndef OPT_SBA_ENC_V1_BE
res_q = sub( add( sub( sub( add( 30, *q_mixer_mat_fx ), 31 ), total_guard ), hFbMixer->q_ppFilterbank_inFR[j] ), 31 );
+
Word16 q_check = s_min( q_pOut_fr_fx, res_q );
IF( NE_16( q_check, q_pOut_fr_fx ) )
{
@@ -825,31 +844,48 @@ void ivas_fb_mixer_process_fx(
pOut_fr_im_fx[k] = L_shr( pOut_fr_im_fx[k], sub( q_pOut_fr_fx, q_check ) ); // q_pOut_fr_fx -> q_check
move32();
}
+#endif
IF( NE_16( q_check, res_q ) )
{
temp_out_re_fx = L_shr( temp_out_re_fx, sub( res_q, q_check ) ); // res_q -> q_check
temp_out_im_fx = L_shr( temp_out_im_fx, sub( res_q, q_check ) ); // res_q -> q_check
}
+#ifndef OPT_SBA_ENC_V1_BE
res_q = q_check;
move16();
+#endif
+
pOut_fr_re_fx[k] = L_add_sat( pOut_fr_re_fx[k], temp_out_re_fx ); // res_q
move32();
pOut_fr_im_fx[k] = L_add_sat( pOut_fr_im_fx[k], temp_out_im_fx ); // res_q
move32();
}
+#ifdef OPT_SBA_ENC_V1_BE
+ q_pOut_fr_fx = q_check;
+#else
q_pOut_fr_fx = res_q;
move16();
+#endif
}
}
+#ifndef OPT_SBA_ENC_V1_BE
Word16 scale = sub( s_min( L_norm_arr( pOut_fr_re_fx, frame_len ), L_norm_arr( pOut_fr_im_fx, frame_len ) ), find_guarded_bits_fx( shl( frame_len, 1 ) ) );
+#else
+ Word16 scale = sub( s_min( L_norm_arr( pOut_fr_re_fx, frame_len ), L_norm_arr( pOut_fr_im_fx, frame_len ) ), total_guard_2 );
+#endif
scale_sig32( pOut_fr_re_fx, frame_len, scale );
scale_sig32( pOut_fr_im_fx, frame_len, scale );
ivas_imdft_fx( pOut_fr_re_fx, pOut_fr_im_fx, pMdft_out_fx[hist], frame_len );
q_pMdft_out_fx[hist] = add( q_pOut_fr_fx, scale );
move16();
}
+#ifdef OPT_SBA_ENC_V1_BE
+ scale_sig32( pMdft_out_fx[0], len, sub( s_min( q_pMdft_out_fx[0], q_pMdft_out_fx[1] ), q_pMdft_out_fx[0] ) );
+ scale_sig32( pMdft_out_fx[1], len, sub( s_min( q_pMdft_out_fx[0], q_pMdft_out_fx[1] ), q_pMdft_out_fx[1] ) );
+#else
scale_sig32( pMdft_out_fx[0], shl( frame_len, 1 ), sub( s_min( q_pMdft_out_fx[0], q_pMdft_out_fx[1] ), q_pMdft_out_fx[0] ) );
scale_sig32( pMdft_out_fx[1], shl( frame_len, 1 ), sub( s_min( q_pMdft_out_fx[0], q_pMdft_out_fx[1] ), q_pMdft_out_fx[1] ) );
+#endif
ivas_fb_mixer_cross_fading_fx( hFbMixer, ppOut_pcm_fx, pMdft_out_fx[0], pMdft_out_fx[1], ch, frame_len, frame_len );
q_ppOut_pcm_fx[ch] = s_min( q_pMdft_out_fx[0], q_pMdft_out_fx[1] );
move16();
diff --git a/lib_com/ivas_masa_com_fx.c b/lib_com/ivas_masa_com_fx.c
index cfed06357fe908e6c3fda28720aa7272ca67adb0..a691fb390380b8f2f12c1510fcf719432fc09d25 100644
--- a/lib_com/ivas_masa_com_fx.c
+++ b/lib_com/ivas_masa_com_fx.c
@@ -1308,7 +1308,7 @@ Word16 valid_ratio_index_fx(
void reconstruct_ism_ratios_fx(
Word16 *ratio_ism_idx, /* i : index vector Q0 */
const Word16 nchan_ism, /* i : number of components/objects Q0 */
- const Word16 step, /* i : quantization step Q15 */
+ const Word32 step, /* i : quantization step Q31 */
Word32 *q_energy_ratio_ism /* o : reconstructed ISM values Q30 */
)
{
@@ -1320,7 +1320,7 @@ void reconstruct_ism_ratios_fx(
FOR( i = 0; i < nchan_ism - 1; i++ )
{
- q_energy_ratio_ism[i] = L_shl( L_mult( ratio_ism_idx[i], step ), 14 ); // q0 + q15 + 1 + 14 = q30;
+ q_energy_ratio_ism[i] = W_extract_l( W_shr( W_mult_32_16( step, ratio_ism_idx[i] ), 2 ) ); // q0 + q31 + 1 - 2 = q30;
move32();
sum = L_add( sum, q_energy_ratio_ism[i] ); // Q30
diff --git a/lib_com/ivas_mcmasa_com-fx.c b/lib_com/ivas_mcmasa_com_fx.c
similarity index 100%
rename from lib_com/ivas_mcmasa_com-fx.c
rename to lib_com/ivas_mcmasa_com_fx.c
diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h
index 17566e3cb20bf02778690228d2fe096a13fdbbb6..71d090a53d8f9765001a71ec4236e6d730732cdc 100644
--- a/lib_com/ivas_prot_fx.h
+++ b/lib_com/ivas_prot_fx.h
@@ -115,7 +115,7 @@ ivas_error ivas_masa_dec_reconfigure_fx(
void reconstruct_ism_ratios_fx(
Word16 *ratio_ism_idx, /* i : index vector Q0 */
const Word16 nchan_ism, /* i : number of components/objects Q0 */
- const Word16 step, /* i : quantization step Q15 */
+ const Word32 step, /* i : quantization step Q31 */
Word32 *q_energy_ratio_ism /* o : reconstructed ISM values Q30 */
);
@@ -1092,10 +1092,14 @@ void ivas_mct_dec_mct_fx(
);
void apply_MCT_dec_fx(
- MCT_DEC_HANDLE hMCT, /* i/o: MCT decoder structure */
- Decoder_State **sts, /* i/o: decoder state structure */
- Word32 *x[MCT_MAX_CHANNELS][NB_DIV], /* i/o: decoded and dequan. spect. input to MCT */
- Word16 q_x[MCT_MAX_CHANNELS] );
+ MCT_DEC_HANDLE hMCT, /* i/o: MCT decoder structure */
+ Decoder_State **sts, /* i/o: decoder state structure */
+ Word32 *x[MCT_MAX_CHANNELS][NB_DIV] /* i/o: decoded and dequan. spect. input to MCT */
+#ifndef OPT_SBA_DEC_PATH
+ ,
+ Word16 q_x[MCT_MAX_CHANNELS]
+#endif /* OPT_SBA_DEC_PATH */
+);
void mctStereoIGF_dec_fx(
MCT_DEC_HANDLE hMCT, /* i/o: MCT decoder structure */
@@ -1129,9 +1133,13 @@ void stereo_decoder_tcx_fx(
const Word16 mct_on, /* i : flag mct block (1) or stereo (0) */
const Word16 last_core_l, /* i : last core for left channel */
const Word16 last_core_r, /* i : last core for right channel */
- const Word16 tmp_plc_upmix, /* i : indicates temp upmix for PLC decision */
+ const Word16 tmp_plc_upmix /* i : indicates temp upmix for PLC decision */
+#ifndef OPT_SBA_DEC_PATH
+ ,
Word16 *q_x_ch2,
- Word16 *q_x_ch1 );
+ Word16 *q_x_ch1
+#endif /* OPT_SBA_DEC_PATH */
+);
void v_multc_acc_32_16(
const Word32 x[], /* i : Input vector */
@@ -2127,13 +2135,6 @@ void small_reduction_direction_fx(
const Word16 raw_flag[MASA_MAXIMUM_CODING_SUBBANDS],
Word16 *diff );
-
-void sort_desc_ind_16_fx(
- Word16 *s, /* i/o: vector to be sorted Qx*/
- const Word16 len, /* i : vector length */
- Word16 *ind /* o : array of indices */
-);
-
void sort_desc_ind_32_fx(
Word32 *s, /* i/o: vector to be sorted Qx*/
const Word16 len, /* i : vector length */
@@ -2967,7 +2968,7 @@ Word16 ivas_acelp_tcx20_switching_fx(
Word16 *inp_fx, /* i : new input signal */
Word16 q_inp, /* i : i/p Q */
Word16 *wsp, /* i : input weighted signal */
- Word16 non_staX, /* i : unbound non-stationarity for sp/mu clas */
+ Word32 non_staX, /* i : unbound non-stationarity for sp/mu clas */
Word16 *pitch_fr, /* i : fraction pitch values */
Word16 *voicing_fr, /* i : fractional voicing values */
Word32 currFlatness, /* i : flatness */
@@ -3237,8 +3238,7 @@ 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*/
Word16 *i_e_band );
@@ -3300,8 +3300,7 @@ void computeReferencePower_enc_fx(
Word16 ref_power_w, /* i : use 0 if hodirac is enabled */
const Word16 nchan_ana, /* i : number of analysis channels */
Word16 inp_q, /* i : q of cld buffers */
- Word16 *ref_q /* i : output q */
-);
+ Word16 q_reference_power[DIRAC_NO_FB_BANDS_MAX] );
void computeReferencePower_enc_fx_dirac(
const Word16 *band_grouping, /* i : Band grouping for estimation */
@@ -3341,7 +3340,7 @@ void mctStereoIGF_enc_fx(
Word32 powerSpec_fx[MCT_MAX_CHANNELS][L_FRAME48k], /* i/o: MDCT^2 + MDST^2 spectrum,or estimate */
Word16 q_powerSpec[MCT_MAX_CHANNELS], /* i : Q for powSpec_fx */
Word32 *powerSpecMsInv_fx[MCT_MAX_CHANNELS][NB_DIV], /* i : same as powerSpec_fx but for inverse spect.*/
- Word16 q_powerSpecMsInv[MCT_MAX_CHANNELS], /* i : Q for powSpecMsInv_fx */
+ Word16 *q_powerSpecMsInv[MCT_MAX_CHANNELS][NB_DIV], /* i : Q for powSpecMsInv_fx */
Word32 *inv_spectrum_fx[MCT_MAX_CHANNELS][NB_DIV], /* i : inverse spectrum */
const Word16 sp_aud_decision0[MCT_MAX_CHANNELS] /* i : speech audio decision */
);
@@ -3968,7 +3967,7 @@ ivas_error ivas_core_dec_fx(
const Word16 sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */
);
-void decod_gen_2sbfr_ivas_fx(
+void decod_gen_2sbfr_fx(
Decoder_State *st, /* i/o: decoder static memory */
const Word16 sharpFlag, /* i : formant sharpening flag `Q0*/
const Word16 *Aq, /* i : LP filter coefficient Q12*/
@@ -3991,7 +3990,7 @@ Word16 ivas_smc_gmm_fx(
const Word16 cor_map_sum_fx, /* i : correlation map sum (from multi-harmonic anal.) Q8 */
const Word32 epsP_fx[M + 1], /* i : LP prediciton error */
const Word32 PS_fx[], /* i : energy spectrum */
- const Word16 non_sta_fx, /* i : unbound non-stationarity Q8 */
+ const Word32 non_sta_fx, /* i : unbound non-stationarity Q20 */
const Word16 relE_fx, /* i : relative frame energy Q8 */
Word16 *high_lpn_flag, /* i/o: sp/mus LPN flag */
const Word16 flag_spitch, /* i : flag to indicate very short stable pitch */
@@ -4746,7 +4745,7 @@ ivas_error stereo_memory_enc_fx(
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 */
+ Word32 old_input_signal_pri[], /* i : old input signal of primary channel */
const Word16 input_frame, /* i : input frame length */
const Word16 q_inp );
@@ -4958,18 +4957,6 @@ void computeDirectionVectors_fx(
Word32 *direction_vector_z,
Word16 *q_factor );
-
-void computeDiffuseness_fx(
- Word32 *buffer_intensity[DIRAC_NUM_DIMS][DIRAC_NO_COL_AVG_DIFF],
- const Word32 *buffer_energy,
- const Word16 num_freq_bands,
- Word32 *diffuseness,
- Word16 q_factor_intensity,
- Word16 q_factor_energy,
- Word16 *out_exp
-
-);
-
void computeDiffuseness_fixed(
Word32 *buffer_intensity[DIRAC_NUM_DIMS][DIRAC_NO_COL_AVG_DIFF],
const Word32 *buffer_energy,
@@ -6205,7 +6192,7 @@ void ivas_param_ism_compute_noisy_speech_flag_fx(
* DFT Stereo prototypes
*----------------------------------------------------------------------------------*/
-void stereo_dft_dec_destroy(
+void stereo_dft_dec_destroy_fx(
STEREO_DFT_DEC_DATA_HANDLE *hStereoDft /* i/o: decoder DFT stereo handle */
);
diff --git a/lib_com/ivas_rom_com_fx.c b/lib_com/ivas_rom_com_fx.c
index ffb18d6d225b55471411e19b08a31ee25dc7bba0..e7ee30e8d54ce02c2ff4f261dceb3d806c2f1d40 100644
--- a/lib_com/ivas_rom_com_fx.c
+++ b/lib_com/ivas_rom_com_fx.c
@@ -1604,15 +1604,22 @@ const Word16 coherence_cb0_masa_Q14[DIRAC_DIFFUSE_LEVELS * 2 * MASA_NO_CV_COH] =
// q = 21
const Word32 coherence_cb0_masa_fx[DIRAC_DIFFUSE_LEVELS * 2 * MASA_NO_CV_COH] = {
- 100243, 534144, 1156579, 2068840, 2846464, 3531184, 4125936, 0, 253965, 864655, 1467377,
- 2129448, 2977326, 3768791, 0, 0, 338480, 1189924, 2035915, 2872888, 3640026, 0, 0, 0,
- 492621, 1532179, 2527278, 3470157, 0, 0, 0, 0, 499331, 1506803, 2465831, 3425697, 0,
- 0, 0, 0, 503316, 1473668, 2392221, 3406404, 0, 0, 0, 0, 737778, 1970903, 3450654, 0, 0,
- 0, 0, 0, 2097152, 0, 0, 0, 0, 0, 0, 0, 303038, 719742, 1122186, 1577897, 2117075, 2770337,
- 3648834, 0, 419849, 932603, 1440533, 2011797, 2745172, 3571240, 0, 0, 548824, 1165177,
- 1812987, 2555379, 3366138, 0, 0, 0, 695835, 1428160, 2190475, 3084910, 0, 0, 0, 0, 697093,
- 1381603, 2092957, 2970406, 0, 0, 0, 0, 708417, 1396283, 2099039, 2992426, 0, 0, 0, 0, 835924,
- 1728892, 2836607, 0, 0, 0, 0, 0, 2097152, 0, 0, 0, 0, 0, 0, 0
+ 100244, 534145, 1156579, 2068841, 2846465, 3531185, 4125937, 0,
+ 253965, 864656, 1467377, 2129448, 2977327, 3768792, 0, 0,
+ 338480, 1189924, 2035915, 2872889, 3640027, 0, 0, 0,
+ 492621, 1532179, 2527278, 3470158, 0, 0, 0, 0,
+ 499332, 1506804, 2465831, 3425698, 0, 0, 0, 0,
+ 503316, 1473669, 2392221, 3406404, 0, 0, 0, 0,
+ 737778, 1970904, 3450654, 0, 0, 0, 0, 0,
+ 2097152, 0, 0, 0, 0, 0, 0, 0,
+ 303038, 719743, 1122186, 1577897, 2117075, 2770338, 3648835, 0,
+ 419850, 932604, 1440534, 2011798, 2745172, 3571240, 0, 0,
+ 548825, 1165178, 1812988, 2555380, 3366139, 0, 0, 0,
+ 695835, 1428161, 2190475, 3084911, 0, 0, 0, 0,
+ 697093, 1381604, 2092958, 2970406, 0, 0, 0, 0,
+ 708418, 1396284, 2099040, 2992426, 0, 0, 0, 0,
+ 835925, 1728892, 2836608, 0, 0, 0, 0, 0,
+ 2097152, 0, 0, 0, 0, 0, 0, 0
};
// q = 15
@@ -1626,9 +1633,11 @@ const Word16 coherence_cb1_masa_Q15[MASA_NO_CV_COH1 * MASA_MAXIMUM_CODING_SUBBAN
// q = 21
const Word32 coherence_cb1_masa_fx[MASA_NO_CV_COH1 * MASA_MAXIMUM_CODING_SUBBANDS] = {
- -3984, 544630, -565392, 1314704, -1320157, -11534, 541484, -583847, 1357486, -1371118,
- -6081, 525546, -551551, 1362729, -1371537, -838, 533934, -540855, 1436758, -1414109,
- 3565, 528692, -519883, 1513514, -1500931
+ -3985, 544630, -565392, 1314705, -1320157,
+ -11534, 541485, -583847, 1357487, -1371118,
+ -6082, 525546, -551551, 1362729, -1371537,
+ -839, 533935, -540856, 1436759, -1414110,
+ 3565, 528692, -519884, 1513515, -1500932
};
/* Multi-channel input and output setups */
diff --git a/lib_com/ivas_spar_com_fx.c b/lib_com/ivas_spar_com_fx.c
index c2ad11e2614664529fae09ba2f0bb0256349b627..15a529149f6b89f7d806ace9bdcf031c32930d20 100644
--- a/lib_com/ivas_spar_com_fx.c
+++ b/lib_com/ivas_spar_com_fx.c
@@ -1995,15 +1995,23 @@ static void ivas_calc_post_pred_per_band_enc_fx(
Word16 *q_postpred_cov_re )
{
Word16 i, j, k;
+#ifndef OPT_SBA_ENC_V1_BE
Word32 dmx_mat_conj[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH];
- Word32 temp_mat[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH];
- Word16 temp_mat_e[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH];
Word16 q_postpred_cov_re_buf[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH];
Word16 min_val;
+#else
+ Word16 max_val;
+ Word16 temp;
+ Word32 temp_add;
+ Word16 e_postpred_cov_re_buf[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH];
+#endif
+ Word32 temp_mat[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH];
+ Word16 temp_mat_e[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH];
Word32 tmp_re;
Word16 tmp_q;
Word16 tmp_e;
+#ifndef OPT_SBA_ENC_V1_BE
FOR( i = 0; i < num_ch; i++ )
{
FOR( j = 0; j < num_ch; j++ )
@@ -2013,25 +2021,40 @@ static void ivas_calc_post_pred_per_band_enc_fx(
}
}
+
FOR( i = 0; i < num_ch; i++ )
{
set32_fx( temp_mat[i], 0, num_ch );
set32_fx( postpred_cov_re[i], 0, num_ch );
}
+#endif
+#ifdef OPT_SBA_ENC_V1_BE
+ max_val = MIN16B;
+ move16();
+ temp = sub( 62, q_mixer_mat );
+#else
min_val = MAX16B;
move16();
+#endif
+
/* num_ch x num_ch mult */
FOR( i = 0; i < num_ch; i++ )
{
FOR( j = 0; j < num_ch; j++ )
{
+#ifndef OPT_SBA_ENC_V1_BE
temp_mat[i][j] = 0;
+#else
+ temp_add = 0;
+#endif
move32();
temp_mat_e[i][j] = 0;
move16();
+
FOR( k = 0; k < num_ch; k++ )
{
+#ifndef OPT_SBA_ENC_V1_BE
tmp_re = Mpy_32_32( cov_real[i][k][band_idx], dmx_mat_conj[k][j] );
tmp_e = sub( 62, add( q_cov_real[i][k][band_idx], q_mixer_mat ) );
IF( tmp_re )
@@ -2039,34 +2062,71 @@ static void ivas_calc_post_pred_per_band_enc_fx(
temp_mat[i][j] = BASOP_Util_Add_Mant32Exp( temp_mat[i][j], temp_mat_e[i][j], tmp_re, tmp_e, &temp_mat_e[i][j] );
move32();
}
+#else
+ tmp_re = Mpy_32_32( cov_real[i][k][band_idx], mixer_mat[j][k][band_idx] );
+ tmp_e = sub( temp, q_cov_real[i][k][band_idx] );
+ IF( tmp_re )
+ {
+ temp_add = BASOP_Util_Add_Mant32Exp( temp_add, temp_mat_e[i][j], tmp_re, tmp_e, &temp_mat_e[i][j] );
+ }
+#endif
}
+#ifdef OPT_SBA_ENC_V1_BE
+ temp_mat[i][j] = temp_add;
+ move32();
+#endif
}
}
+ tmp_e = sub( Q31, q_mixer_mat );
/* num_ch x num_ch mult */
FOR( i = 0; i < num_ch; i++ )
{
FOR( j = i; j < num_ch; j++ )
{
+#ifdef OPT_SBA_ENC_V1_BE
+ temp_add = 0;
+ move32();
+ e_postpred_cov_re_buf[i][j] = sub( 31, *q_postpred_cov_re );
+#else
q_postpred_cov_re_buf[i][j] = *q_postpred_cov_re;
+#endif
move16();
FOR( k = 0; k < num_ch; k++ )
{
tmp_re = Mpy_32_32( mixer_mat[i][k][band_idx], temp_mat[k][j] );
+#ifdef OPT_SBA_ENC_V1_BE
+ tmp_q = add( tmp_e, temp_mat_e[k][j] );
+#else
tmp_q = sub( q_mixer_mat, temp_mat_e[k][j] );
+#endif
IF( tmp_re )
{
+#ifndef OPT_SBA_ENC_V1_BE
tmp_e = sub( 31, q_postpred_cov_re_buf[i][j] );
postpred_cov_re[i][j] = BASOP_Util_Add_Mant32Exp( postpred_cov_re[i][j], tmp_e, tmp_re, sub( Q31, tmp_q ), &tmp_e );
move32();
q_postpred_cov_re_buf[i][j] = sub( 31, tmp_e );
move16();
+#else
+ temp_add = BASOP_Util_Add_Mant32Exp( temp_add, e_postpred_cov_re_buf[i][j], tmp_re, tmp_q, &e_postpred_cov_re_buf[i][j] );
+#endif
}
}
+#ifndef OPT_SBA_ENC_V1_BE
IF( postpred_cov_re[i][j] )
{
min_val = s_min( min_val, q_postpred_cov_re_buf[i][j] );
+#else
+ if ( temp_add )
+ {
+ max_val = s_max( max_val, e_postpred_cov_re_buf[i][j] );
+#endif
}
+#ifdef OPT_SBA_ENC_V1_BE
+ postpred_cov_re[i][j] = temp_add;
+ move32();
+#endif
}
}
@@ -2077,7 +2137,11 @@ static void ivas_calc_post_pred_per_band_enc_fx(
{
IF( postpred_cov_re[i][j] )
{
+#ifdef OPT_SBA_ENC_V1_BE
+ postpred_cov_re[i][j] = L_shr( postpred_cov_re[i][j], sub( max_val, e_postpred_cov_re_buf[i][j] ) );
+#else
postpred_cov_re[i][j] = L_shl( postpred_cov_re[i][j], sub( min_val, q_postpred_cov_re_buf[i][j] ) );
+#endif
move32();
}
}
@@ -2092,13 +2156,21 @@ static void ivas_calc_post_pred_per_band_enc_fx(
move32();
}
}
-
+#ifdef OPT_SBA_ENC_V1_BE
+ if ( EQ_16( max_val, MIN16B ) )
+ {
+ max_val = 0;
+ move16();
+ }
+ *q_postpred_cov_re = sub( Q31, max_val );
+#else
if ( EQ_16( min_val, MAX16B ) )
{
min_val = Q31;
move16();
}
*q_postpred_cov_re = min_val;
+#endif
move16();
return;
@@ -2289,18 +2361,30 @@ static void ivas_calc_p_coeffs_per_band_enc_fx(
Word32 re1, re2;
W_tmp = W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[0][0], cov_dd_re[0][0] ); /*q_cov_dd_re+ pSparMd->band_coeffs[b_ts_idx].q_C_re_fx*/
+#ifdef OPT_SBA_ENC_V2_BE
+ q_tmp1 = sub( W_norm( W_tmp ), 32 );
+ re1 = W_shl_sat_l( W_tmp, q_tmp1 ); /*q_cov_dd_re+ q_C_re+q_tmp1*/
+ q_tmp1 = add( add( q_C_re, q_tmp1 ), q_cov_dd_re );
+#else
q_tmp1 = W_norm( W_tmp );
re1 = W_extract_h( W_shl( W_tmp, q_tmp1 ) ); /*q_cov_dd_re+ q_C_re+q_tmp1-32*/
q_tmp1 = sub( add( add( q_C_re, q_tmp1 ), q_cov_dd_re ), 32 );
+#endif
if ( W_tmp == 0 )
{
q_tmp1 = 31;
move16();
}
W_tmp = W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[1][0], cov_dd_re[0][0] ); /*q_cov_dd_re+ q_C_re*/
+#ifdef OPT_SBA_ENC_V2_BE
+ q_tmp = sub( W_norm( W_tmp ), 32 );
+ re2 = W_shl_sat_l( W_tmp, q_tmp ); /*q_cov_dd_re+ q_C_re+q_tmp*/
+ q_tmp = add( add( q_C_re, q_tmp ), q_cov_dd_re );
+#else
q_tmp = W_norm( W_tmp );
re2 = W_extract_h( W_shl( W_tmp, q_tmp ) ); /*q_cov_dd_re+ q_C_re+q_tmp-32*/
q_tmp = sub( add( add( q_C_re, q_tmp ), q_cov_dd_re ), 32 );
+#endif
if ( W_tmp == 0 )
{
q_tmp = 31;
@@ -2308,12 +2392,20 @@ static void ivas_calc_p_coeffs_per_band_enc_fx(
}
W_tmp = W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[0][0], re1 ); // q_tmp1+q_C_re
+#ifdef OPT_SBA_ENC_V2_BE
+ q_factor = sub( W_norm( W_tmp ), 32 );
+ recon_uu_re[0][0] = W_shl_sat_l( W_tmp, q_factor ); // q_tmp1+q_C_re+q_recon_uu_re[0][0]
+ move32();
+ q_recon_uu_re[0][0] = add( add( q_C_re, q_factor ), q_tmp1 );
+ move16();
+#else
q_recon_uu_re[0][0] = W_norm( W_tmp );
move16();
recon_uu_re[0][0] = W_extract_h( W_shl( W_tmp, q_recon_uu_re[0][0] ) ); // q_tmp1+q_C_re+q_recon_uu_re[0][0]-32
move32();
q_recon_uu_re[0][0] = sub( add( add( q_C_re, q_recon_uu_re[0][0] ), q_tmp1 ), 32 );
move16();
+#endif
if ( W_tmp == 0 )
{
q_recon_uu_re[0][0] = 31;
@@ -2321,12 +2413,20 @@ static void ivas_calc_p_coeffs_per_band_enc_fx(
}
W_tmp = W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[1][0], re1 ); // q_C_re+q_tmp1
+#ifdef OPT_SBA_ENC_V2_BE
+ q_factor = sub( W_norm( W_tmp ), 32 );
+ recon_uu_re[0][1] = W_shl_sat_l( W_tmp, q_factor ); // q_C_re+q_tmp1+q_recon_uu_re[0][1]
+ move32();
+ q_recon_uu_re[0][1] = add( add( q_C_re, q_factor ), q_tmp1 );
+ move16();
+#else
q_recon_uu_re[0][1] = W_norm( W_tmp );
move16();
recon_uu_re[0][1] = W_extract_h( W_shl( W_tmp, q_recon_uu_re[0][1] ) ); // q_C_re+q_tmp1+q_recon_uu_re[0][1]-32
move32();
q_recon_uu_re[0][1] = sub( add( add( q_C_re, q_recon_uu_re[0][1] ), q_tmp1 ), 32 );
move16();
+#endif
if ( W_tmp == 0 )
{
q_recon_uu_re[0][1] = 31;
@@ -2334,12 +2434,20 @@ static void ivas_calc_p_coeffs_per_band_enc_fx(
}
W_tmp = W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[0][0], re2 ); // q_C_re+q_tmp
+#ifdef OPT_SBA_ENC_V2_BE
+ q_factor = sub( W_norm( W_tmp ), 32 );
+ recon_uu_re[1][0] = W_shl_sat_l( W_tmp, q_factor ); // q_C_re+q_tmp+q_recon_uu_re[1][0]
+ move32();
+ q_recon_uu_re[1][0] = add( add( q_C_re, q_factor ), q_tmp );
+ move16();
+#else
q_recon_uu_re[1][0] = W_norm( W_tmp );
move16();
recon_uu_re[1][0] = W_extract_h( W_shl( W_tmp, q_recon_uu_re[1][0] ) ); // q_C_re+q_tmp+q_recon_uu_re[1][0]-32
move32();
q_recon_uu_re[1][0] = sub( add( add( q_C_re, q_recon_uu_re[1][0] ), q_tmp ), 32 );
move16();
+#endif
if ( W_tmp == 0 )
{
q_recon_uu_re[1][0] = 31;
@@ -2347,12 +2455,20 @@ static void ivas_calc_p_coeffs_per_band_enc_fx(
}
W_tmp = W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[1][0], re2 ); // q_C_re+q_tmp
+#ifdef OPT_SBA_ENC_V2_BE
+ q_factor = sub( W_norm( W_tmp ), 32 );
+ recon_uu_re[1][1] = W_shl_sat_l( W_tmp, q_factor ); // q_C_re+q_tmp+q_recon_uu_re[1][1]
+ move32();
+ q_recon_uu_re[1][1] = add( add( q_C_re, q_factor ), q_tmp );
+ move16();
+#else
q_recon_uu_re[1][1] = W_norm( W_tmp );
move16();
recon_uu_re[1][1] = W_extract_h( W_shl( W_tmp, q_recon_uu_re[1][1] ) ); // q_C_re+q_tmp+q_recon_uu_re[1][1]-32
move32();
q_recon_uu_re[1][1] = sub( add( add( q_C_re, q_recon_uu_re[1][1] ), q_tmp ), 32 );
move16();
+#endif
if ( W_tmp == 0 )
{
q_recon_uu_re[1][1] = 31;
@@ -2369,12 +2485,18 @@ static void ivas_calc_p_coeffs_per_band_enc_fx(
}
}
q_tmp = sub( s_min( q_tmp, q_cov_uu_re ), 1 );
-
+#ifdef OPT_SBA_ENC_V2_BE
+ q_factor = sub( q_cov_uu_re, q_tmp );
+#endif
FOR( i = 0; i < 2; i++ )
{
FOR( j = 0; j < 2; j++ )
{
+#ifdef OPT_SBA_ENC_V2_BE
+ cov_uu_re[i][j] = L_sub( L_shr( cov_uu_re[i][j], q_factor ), L_shr( recon_uu_re[i][j], sub( q_recon_uu_re[i][j], q_tmp ) ) ); // q_tmp
+#else
cov_uu_re[i][j] = L_sub( L_shr( cov_uu_re[i][j], sub( q_cov_uu_re, q_tmp ) ), L_shr( recon_uu_re[i][j], sub( q_recon_uu_re[i][j], q_tmp ) ) ); // q_tmp
+#endif
move32();
}
}
@@ -2394,9 +2516,15 @@ static void ivas_calc_p_coeffs_per_band_enc_fx(
{
Word32 re;
W_tmp = W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[0][k], cov_dd_re[k][j] ); // q_C_re+q_cov_dd_re
+#ifdef OPT_SBA_ENC_V2_BE
+ q_tmp = sub( W_norm( W_tmp ), 33 );
+ re = W_shl_sat_l( W_tmp, q_tmp ); // q_C_re+q_cov_dd_re+q_tmp
+ q_tmp = add( add( q_C_re, q_tmp ), q_cov_dd_re );
+#else
q_tmp = sub( W_norm( W_tmp ), 1 );
re = W_extract_h( W_shl( W_tmp, q_tmp ) ); // q_C_re+q_cov_dd_re+q_tmp-32
q_tmp = sub( add( add( q_C_re, q_tmp ), q_cov_dd_re ), 32 );
+#endif
if ( W_tmp == 0 )
{
q_tmp = 31;
@@ -2420,9 +2548,15 @@ static void ivas_calc_p_coeffs_per_band_enc_fx(
}
W_tmp = W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[0][0], re1[0] ); // q_C_re+q_re1[0]
+#ifdef OPT_SBA_ENC_V2_BE
+ q_tmp = sub( W_norm( W_tmp ), 33 );
+ re2 = W_shl_sat_l( W_tmp, q_tmp ); // q_C_re+q_re1[0]+q_tmp
+ q_tmp = add( add( q_C_re, q_tmp ), q_re1[0] );
+#else
q_tmp = sub( W_norm( W_tmp ), 1 );
re2 = W_extract_h( W_shl( W_tmp, q_tmp ) ); // q_C_re+q_re1[0]+q_tmp-32
q_tmp = sub( add( add( q_C_re, q_tmp ), q_re1[0] ), 32 );
+#endif
if ( W_tmp == 0 )
{
q_tmp = 31;
@@ -2432,9 +2566,15 @@ static void ivas_calc_p_coeffs_per_band_enc_fx(
move32();
W_tmp = W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[0][1], re1[1] ); // q_C_re+q_re1[1]
+#ifdef OPT_SBA_ENC_V2_BE
+ q_tmp1 = sub( W_norm( W_tmp ), 33 );
+ re2 = W_shl_sat_l( W_tmp, q_tmp1 ); // q_C_re+q_re1[1]+q_tmp1
+ q_tmp1 = add( add( q_C_re, q_tmp1 ), q_re1[1] );
+#else
q_tmp1 = sub( W_norm( W_tmp ), 1 );
re2 = W_extract_h( W_shl( W_tmp, q_tmp1 ) ); // q_C_re+q_re1[1]+q_tmp1-32
q_tmp1 = sub( add( add( q_C_re, q_tmp1 ), q_re1[1] ), 32 );
+#endif
if ( W_tmp == 0 )
{
q_tmp1 = 31;
@@ -2513,9 +2653,15 @@ static void ivas_calc_p_coeffs_per_band_enc_fx(
FOR( k = 0; k < num_dmx - 1; k++ )
{
W_tmp = W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[i][k], cov_dd_re[k][m] ); // q_C_re+q_cov_dd_re
+#ifdef OPT_SBA_ENC_V2_BE
+ q_tmp = sub( W_norm( W_tmp ), 34 );
+ re = W_shl_sat_l( W_tmp, q_tmp ); // q_C_re+q_cov_dd_re+q_tmp
+ q_tmp = add( add( q_C_re, q_tmp ), q_cov_dd_re );
+#else
q_tmp = sub( W_norm( W_tmp ), 2 );
re = W_extract_h( W_shl( W_tmp, q_tmp ) ); // q_C_re+q_cov_dd_re+q_tmp-32
q_tmp = sub( add( add( q_C_re, q_tmp ), q_cov_dd_re ), 32 );
+#endif
if ( W_tmp == 0 )
{
q_tmp = 31;
@@ -2555,9 +2701,15 @@ static void ivas_calc_p_coeffs_per_band_enc_fx(
FOR( m = 0; m < num_dmx - 1; m++ )
{
W_tmp = W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[j][m], re1[m] ); // q_C_re+q_re1[m]
+#ifdef OPT_SBA_ENC_V2_BE
+ q_tmp = sub( W_norm( W_tmp ), 34 );
+ re = W_shl_sat_l( W_tmp, q_tmp ); // q_C_re+q_re1[m]+q_tmp
+ q_tmp = add( add( q_C_re, q_tmp ), q_re1[m] );
+#else
q_tmp = sub( W_norm( W_tmp ), 2 );
re = W_extract_h( W_shl( W_tmp, q_tmp ) ); // q_C_re+q_re1[m]+q_tmp-32
q_tmp = sub( add( add( q_C_re, q_tmp ), q_re1[m] ), 32 );
+#endif
if ( W_tmp == 0 )
{
q_tmp = 31;
@@ -2642,9 +2794,15 @@ static void ivas_calc_p_coeffs_per_band_enc_fx(
move16();
IF( trace != 0 )
{
+#ifdef OPT_SBA_ENC_V2_BE
+ q_factor = sub( W_norm( trace ), 32 );
+ tmp = Mpy_32_32( p_norm_scaling, W_shl_sat_l( trace, q_factor ) ); // q_cov_uu_re+q_factor
+ q_factor = add( q_cov_uu_re, q_factor );
+#else
q_factor = W_norm( trace );
tmp = Mpy_32_32( p_norm_scaling, W_extract_h( W_shl( trace, q_factor ) ) ); // q_cov_uu_re+q_factor-32
q_factor = sub( add( q_cov_uu_re, q_factor ), 32 );
+#endif
IF( GT_16( q_factor, q_postpred_cov_re ) )
{
tmp = L_shr( tmp, sub( q_factor, q_postpred_cov_re ) ); // q_postpred_cov_re
diff --git a/lib_com/lag_wind.c b/lib_com/lag_wind_fx.c
similarity index 100%
rename from lib_com/lag_wind.c
rename to lib_com/lag_wind_fx.c
diff --git a/lib_com/lerp.c b/lib_com/lerp_fx.c
similarity index 100%
rename from lib_com/lerp.c
rename to lib_com/lerp_fx.c
diff --git a/lib_com/longarith.c b/lib_com/longarith.c
index 72a763de3dc933db4fae6d7de78b0893b436a2c9..c5ace652c336a07802482ef76ace28690b51b749 100644
--- a/lib_com/longarith.c
+++ b/lib_com/longarith.c
@@ -64,14 +64,14 @@ void longadd(
assert( lena >= lenb );
for ( h = 0; h < lenb; h++ )
{
- carry += ( (uint32_t) a[h] ) + ( (uint32_t) b[h] );
+ carry += ( (UWord32) a[h] ) + ( (UWord32) b[h] );
a[h] = (UWord16) carry;
carry = carry >> 16;
}
for ( ; h < lena; h++ )
{
- carry = ( (uint32_t) a[h] ) + carry;
+ carry = ( (UWord32) a[h] ) + carry;
a[h] = (UWord16) carry;
carry = carry >> 16;
}
diff --git a/lib_com/lpc_tools_fx.c b/lib_com/lpc_tools_fx.c
index bde05b4f4ebc1d9ab7a4ac99776af5f25b97036d..1035f017a5b95b59efef409b5dead1f1e95ea326 100644
--- a/lib_com/lpc_tools_fx.c
+++ b/lib_com/lpc_tools_fx.c
@@ -1114,7 +1114,7 @@ static void lsp_reorder(
{
lsp[i] = s_max( lsp[i], lsp_min );
move16();
- lsp_min = add( lsp[i], min_dist );
+ lsp_min = add_sat( lsp[i], min_dist );
}
/* Reverify the LSF ordering and minimum GAP in the reverse order (security) */
diff --git a/lib_com/lsf_tools_fx.c b/lib_com/lsf_tools_fx.c
index 5f0b3b57b404d1ade2874fcc232fe4e9e245f9bd..a41e10713968dd99b7d8fac5b16f4f448eb24163 100644
--- a/lib_com/lsf_tools_fx.c
+++ b/lib_com/lsf_tools_fx.c
@@ -2863,40 +2863,39 @@ Word16 qlsf_ARSN_tcvq_Dec_16k_fx(
}
/*======================================================================*/
-/* FUNCTION : lsf_syn_mem_backup_fx */
+/* FUNCTION : lsf_syn_mem_backup_fx */
/*----------------------------------------------------------------------*/
/* PURPOSE : back-up synthesis filter memory and LSF qunatizer memories */
/*----------------------------------------------------------------------*/
-/* INPUT ARGUMENTS : */
-/* _ (Word16*) lsp_new : LSP vector to quantize */
-/* _ (Word16*) lsf_new : quantized LSF vector */
-/* _ (Word16*) lsp_mid : mid-frame LSP vector */
-/* _ (Encoder_State) st_fx : Encoder state Structure */
-/*-----------------------------------------------------------------------*/
-/* INPUT/OUTPUT ARGUMENTS : */
-/* _None */
-/*-----------------------------------------------------------------------*/
-/* OUTPUT ARGUMENTS : */
-/* _ (Word16) clip_var : pitch clipping state var */
-/* _ (Word16*) mem_AR : quantizer memory for AR model */
-/* _ (Word16*) mem_MA : quantizer memory for MA model */
-/* _ (Word16*) lsp_new_bck : LSP vector to quantize- backup */
-/* _ (Word16*) lsf_new_bck : quantized LSF vector - backup */
-/* _ (Word16*) lsp_mid_bck : mid-frame LSP vector - backup */
+/* INPUT ARGUMENTS : */
+/* _ (Word16*) lsp_new : LSP vector to quantize */
+/* _ (Word16*) lsf_new : quantized LSF vector */
+/* _ (Word16*) lsp_mid : mid-frame LSP vector */
+/* _ (Encoder_State) st_fx : Encoder state Structure */
+/*----------------------------------------------------------------------*/
+/* INPUT/OUTPUT ARGUMENTS : */
+/* _None */
+/*----------------------------------------------------------------------*/
+/* OUTPUT ARGUMENTS : */
+/* _ (Word16) clip_var : pitch clipping state var */
+/* _ (Word16*) mem_AR : quantizer memory for AR model */
+/* _ (Word16*) mem_MA : quantizer memory for MA model */
+/* _ (Word16*) lsp_new_bck : LSP vector to quantize- backup */
+/* _ (Word16*) lsf_new_bck : quantized LSF vector - backup */
+/* _ (Word16*) lsp_mid_bck : mid-frame LSP vector - backup */
/* _ (Word16) mCb1 :counter for stationary frame after a transition frame */
-/* _ (Word32*) Bin_E : FFT Bin energy 128 *2 sets */
-/* _ (Word32*) Bin_E_old : FFT Bin energy 128 *2 sets */
-/* _ (Word16*) mem_syn_bck : synthesis filter memory */
-/* _ (Word16) mem_w0_bck : memory of the weighting filter */
-/* _ (Word16) streaklimit : LSF quantizer */
-/* _ (Word16) pstreaklen : LSF quantizer */
-/*-----------------------------------------------------------------------*/
-
-/* _ None */
-/*-----------------------------------------------------------------------*/
-/* RETURN ARGUMENTS : */
-/* _ None */
-/*=======================================================================*/
+/* _ (Word32*) Bin_E : FFT Bin energy 128 *2 sets */
+/* _ (Word32*) Bin_E_old : FFT Bin energy 128 *2 sets */
+/* _ (Word16*) mem_syn_bck : synthesis filter memory */
+/* _ (Word16) mem_w0_bck : memory of the weighting filter */
+/* _ (Word16) streaklimit : LSF quantizer */
+/* _ (Word16) pstreaklen : LSF quantizer */
+/*----------------------------------------------------------------------*/
+/* _ None */
+/*----------------------------------------------------------------------*/
+/* RETURN ARGUMENTS : */
+/* _ None */
+/*======================================================================*/
void lsf_syn_mem_backup_fx(
Encoder_State *st_fx, /* o: state structure */
@@ -2904,23 +2903,22 @@ void lsf_syn_mem_backup_fx(
Word32 *gc_threshold_fx, /* i: Q16 */
Word16 *clip_var_bck_fx, /* i: Q(2.56), Q14, Q7, Q0, Q14, Q14 */
Word16 *next_force_sf_bck_fx, /* i: */
-
- Word16 *lsp_new, /* o: LSP vector to quantize Q15 */
- Word16 *lsf_new, /* i: quantized LSF vector Q15 */
- Word16 *lsp_mid, /* o: mid-frame LSP vector Q15 */
- Word16 *clip_var, /* i: pitch clipping state var Q(2.56) */
- Word16 *mem_AR, /* i: quantizer memory for AR model 2.56 */
- Word16 *mem_MA, /* i: quantizer memory for MA model 2.56 */
- Word16 *lsp_new_bck, /* i: LSP vector to quantize- backup Q15 */
- Word16 *lsf_new_bck, /* o: quantized LSF vector - backup Q15 */
- Word16 *lsp_mid_bck, /* i: mid-frame LSP vector - backup Q15 */
- Word16 *mCb1, /* o: counter for stationary frame after a transition frame */
- Word32 *Bin_E, /* i: FFT Bin energy 128 *2 sets q_bin */
- Word32 *Bin_E_old, /* i: FFT Bin energy 128 sets q_bin */
- Word16 *mem_syn_bck, /* i: synthesis filter memory q */
- Word16 *mem_w0_bck, /* i: memory of the weighting filter q */
- Word16 *streaklimit, /* i:LSF quantizer Q15 */
- Word16 *pstreaklen /* i:LSF quantizer */
+ Word16 *lsp_new, /* o: LSP vector to quantize Q15 */
+ Word16 *lsf_new, /* i: quantized LSF vector Q15 */
+ Word16 *lsp_mid, /* o: mid-frame LSP vector Q15 */
+ Word16 *clip_var, /* i: pitch clipping state var Q(2.56) */
+ Word16 *mem_AR, /* i: quantizer memory for AR model 2.56 */
+ Word16 *mem_MA, /* i: quantizer memory for MA model 2.56 */
+ Word16 *lsp_new_bck, /* i: LSP vector to quantize- backup Q15 */
+ Word16 *lsf_new_bck, /* o: quantized LSF vector - backup Q15 */
+ Word16 *lsp_mid_bck, /* i: mid-frame LSP vector - backup Q15 */
+ Word16 *mCb1, /* o: counter for stationary frame after a transition frame */
+ Word32 *Bin_E, /* i: FFT Bin energy 128 *2 sets q_bin */
+ Word32 *Bin_E_old, /* i: FFT Bin energy 128 sets q_bin */
+ Word16 *mem_syn_bck, /* i: synthesis filter memory q */
+ Word16 *mem_w0_bck, /* i: memory of the weighting filter q */
+ Word16 *streaklimit, /* i:LSF quantizer Q15 */
+ Word16 *pstreaklen /* i:LSF quantizer */
)
{
Word16 i;
@@ -2985,25 +2983,31 @@ void lsf_syn_mem_backup_fx(
return;
}
+
+/*-------------------------------------------------------------------*
+ * lsf_syn_mem_backup_fx()
+ *
+ *
+ *--------------------------------------------------------------------*/
+
void lsf_syn_mem_backup_ivas_fx(
Encoder_State *st_fx, /* i: state structure */
Word16 *btilt_code_fx, /* i: tilt code Q15 */
Word32 *gc_threshold_fx, /* i: Q16 */
Word16 *clip_var_bck_fx, /* o: Q(2.56), Q14, Q7, Q0, Q14, Q14 */
Word16 *next_force_sf_bck_fx, /* o: */
-
- Word16 *lsp_new, /* i: LSP vector to quantize Q15 */
- Word16 *lsp_mid, /* i: mid-frame LSP vector Q15 */
- Word16 *clip_var, /* o: pitch clipping state var Q(2.56) */
- Word16 *mem_AR, /* o: quantizer memory for AR model Q(2.56) */
- Word16 *mem_MA, /* o: quantizer memory for AR model Q(2.56) */
- Word16 *lsp_new_bck, /* o: LSP vector to quantize- backup Q15 */
- Word16 *lsp_mid_bck, /* o: mid-frame LSP vector - backup Q15 */
- Word32 *Bin_E, /* o: FFT Bin energy 128 *2 sets Q_new + Q_SCALE - 2 */
- Word32 *Bin_E_old, /* o: FFT Bin energy 128 sets Q_new + Q_SCALE - 2 */
- Word16 *mem_syn_bck, /* o: synthesis filter memory ( 15 - st_fx->hLPDmem->e_mem_syn ) */
- Word16 *mem_w0_bck, /* o: memory of the weighting filter ( 15 - st_fx->hLPDmem->e_mem_syn ) */
- Word16 *streaklimit, /* Q15 */
+ Word16 *lsp_new, /* i: LSP vector to quantize Q15 */
+ Word16 *lsp_mid, /* i: mid-frame LSP vector Q15 */
+ Word16 *clip_var, /* o: pitch clipping state var Q(2.56) */
+ Word16 *mem_AR, /* o: quantizer memory for AR model Q(2.56) */
+ Word16 *mem_MA, /* o: quantizer memory for AR model Q(2.56) */
+ Word16 *lsp_new_bck, /* o: LSP vector to quantize- backup Q15 */
+ Word16 *lsp_mid_bck, /* o: mid-frame LSP vector - backup Q15 */
+ Word32 *Bin_E, /* o: FFT Bin energy 128 *2 sets Q_new + Q_SCALE - 2 */
+ Word32 *Bin_E_old, /* o: FFT Bin energy 128 sets Q_new + Q_SCALE - 2 */
+ Word16 *mem_syn_bck, /* o: synthesis filter memory ( 15 - st_fx->hLPDmem->e_mem_syn ) */
+ Word16 *mem_w0_bck, /* o: memory of the weighting filter ( 15 - st_fx->hLPDmem->e_mem_syn ) */
+ Word16 *streaklimit, /* Q15 */
Word16 *pstreaklen )
{
Word16 i;
@@ -3079,66 +3083,68 @@ void lsf_update_memory(
move16();
mem_MA[i] = sub( sub( qlsf[i], lsf_means[narrowband][i] ), mult_r( MU_MA_FX, old_mem_MA[i] ) );
}
+
+ return;
}
+
/*======================================================================*/
-/* FUNCTION : lsf_syn_mem_restore_fx */
+/* FUNCTION : lsf_syn_mem_restore_fx */
/*----------------------------------------------------------------------*/
/* PURPOSE : restore synthesis filter memory and LSF quantizer memories*/
/*----------------------------------------------------------------------*/
-/* INPUT ARGUMENTS : */
-/* _ (Word16) clip_var : pitch clipping state var */
-/* _ (Word16*) mem_AR : quantizer memory for AR model */
-/* _ (Word16*) mem_MA : quantizer memory for MA model */
-/* _ (Word16*) lsp_new_bck : LSP vector to quantize- backup */
-/* _ (Word16*) lsf_new_bck : quantized LSF vector - backup */
-/* _ (Word16*) lsp_mid_bck : mid-frame LSP vector - backup */
+/* INPUT ARGUMENTS : */
+/* _ (Word16) clip_var : pitch clipping state var */
+/* _ (Word16*) mem_AR : quantizer memory for AR model */
+/* _ (Word16*) mem_MA : quantizer memory for MA model */
+/* _ (Word16*) lsp_new_bck : LSP vector to quantize- backup */
+/* _ (Word16*) lsf_new_bck : quantized LSF vector - backup */
+/* _ (Word16*) lsp_mid_bck : mid-frame LSP vector - backup */
/* _ (Word16) mCb1 :counter for stationary frame after a transition frame */
-/* _ (Word32*) Bin_E : FFT Bin energy 128 *2 sets */
-/* _ (Word32*) Bin_E_old : FFT Bin energy 128 *2 sets */
-/* _ (Word16*) mem_syn_bck : synthesis filter memory */
-/* _ (Word16) mem_w0_bck : memory of the weighting filter */
-/* _ (Word16) streaklimit : LSF quantizer */
-/* _ (Word16) pstreaklen : LSF quantizer */
-/*-----------------------------------------------------------------------*/
-/* INPUT/OUTPUT ARGUMENTS : */
-/* _None */
-/*-----------------------------------------------------------------------*/
-/* OUTPUT ARGUMENTS : */
-/* _ (Word16*) lsp_new : LSP vector to quantize */
-/* _ (Word16*) lsf_new : quantized LSF vector */
-/* _ (Word16*) lsp_mid : mid-frame LSP vector */
-/* _ (Encoder_State) st_fx : Encoder state Structure */
-/*-----------------------------------------------------------------------*/
-
-/* _ None */
-/*-----------------------------------------------------------------------*/
-/* RETURN ARGUMENTS : */
-/* _ None */
-/*=======================================================================*/
+/* _ (Word32*) Bin_E : FFT Bin energy 128 *2 sets */
+/* _ (Word32*) Bin_E_old : FFT Bin energy 128 *2 sets */
+/* _ (Word16*) mem_syn_bck : synthesis filter memory */
+/* _ (Word16) mem_w0_bck : memory of the weighting filter */
+/* _ (Word16) streaklimit : LSF quantizer */
+/* _ (Word16) pstreaklen : LSF quantizer */
+/*----------------------------------------------------------------------*/
+/* INPUT/OUTPUT ARGUMENTS : */
+/* _None */
+/*----------------------------------------------------------------------*/
+/* OUTPUT ARGUMENTS : */
+/* _ (Word16*) lsp_new : LSP vector to quantize */
+/* _ (Word16*) lsf_new : quantized LSF vector */
+/* _ (Word16*) lsp_mid : mid-frame LSP vector */
+/* _ (Encoder_State) st_fx : Encoder state Structure */
+/*----------------------------------------------------------------------*/
+/* _ None */
+/*----------------------------------------------------------------------*/
+/* RETURN ARGUMENTS : */
+/* _ None */
+/*======================================================================*/
+
void lsf_syn_mem_restore_fx(
Encoder_State *st_fx, /* o: state structure */
Word16 btilt_code_fx, /* i: Q15 */
Word32 gc_threshold_fx, /* i: Q16 */
Word16 *clip_var_bck_fx, /* i: Q(2.56), Q14, Q7, Q0, Q14, Q14 */
Word16 next_force_sf_bck_fx, /* i: */
-
- Word16 *lsp_new, /* o: LSP vector to quantize Q15 */
- Word16 *lsf_new, /* o: quantized LSF vector Q15 */
- Word16 *lsp_mid, /* o: mid-frame LSP vector Q15 */
- Word16 clip_var, /* i: pitch clipping state var Q(2.56) */
- Word16 *mem_AR, /* i: quantizer memory for AR model Q15 */
- Word16 *mem_MA, /* i: quantizer memory for MA model Q15 */
- Word16 *lsp_new_bck, /* i: LSP vector to quantize- backup Q15 */
- Word16 *lsf_new_bck, /* i: quantized LSF vector - backup Q15 */
- Word16 *lsp_mid_bck, /* i: mid-frame LSP vector - backup Q15 */
- Word16 mCb1, /* i: counter for stationary frame after a transition frame */
- Word32 *Bin_E, /* i: FFT Bin energy 128 *2 sets Q_new + Q_SCALE - 2 */
- Word32 *Bin_E_old, /* i: FFT Bin energy 128 sets Q_new + Q_SCALE - 2 */
- Word16 *mem_syn_bck, /* i: synthesis filter memory ( 15 - st_fx->hLPDmem->e_mem_syn ) */
- Word16 mem_w0_bck, /* i: memory of the weighting filter ( 15 - st_fx->hLPDmem->e_mem_syn ) */
- Word16 streaklimit, /* i:LSF quantizer Q15 */
- Word16 pstreaklen /* i:LSF quantizer */
+ Word16 *lsp_new, /* o: LSP vector to quantize Q15 */
+ Word16 *lsf_new, /* o: quantized LSF vector Q15 */
+ Word16 *lsp_mid, /* o: mid-frame LSP vector Q15 */
+ Word16 clip_var, /* i: pitch clipping state var Q(2.56) */
+ Word16 *mem_AR, /* i: quantizer memory for AR model Q15 */
+ Word16 *mem_MA, /* i: quantizer memory for MA model Q15 */
+ Word16 *lsp_new_bck, /* i: LSP vector to quantize- backup Q15 */
+ Word16 *lsf_new_bck, /* i: quantized LSF vector - backup Q15 */
+ Word16 *lsp_mid_bck, /* i: mid-frame LSP vector - backup Q15 */
+ Word16 mCb1, /* i: counter for stationary frame after a transition frame */
+ Word32 *Bin_E, /* i: FFT Bin energy 128 *2 sets Q_new + Q_SCALE - 2 */
+ Word32 *Bin_E_old, /* i: FFT Bin energy 128 sets Q_new + Q_SCALE - 2 */
+ Word16 *mem_syn_bck, /* i: synthesis filter memory ( 15 - st_fx->hLPDmem->e_mem_syn ) */
+ Word16 mem_w0_bck, /* i: memory of the weighting filter ( 15 - st_fx->hLPDmem->e_mem_syn ) */
+ Word16 streaklimit, /* i:LSF quantizer Q15 */
+ Word16 pstreaklen /* i:LSF quantizer */
)
{
Word16 i;
@@ -3301,71 +3307,6 @@ Word16 tcxlpc_get_cdk(
return cdk;
}
-#ifdef IVAS_MSVQ
-/*--------------------------------------------------------------------------*
- * dec_FDCNG_MSVQ_stage1()
- *
- *
- *--------------------------------------------------------------------------*/
-
-void dec_FDCNG_MSVQ_stage1(
- int16_t j_full, /* i : index full range */
- int16_t n, /* i : dimension to generate */
- const float *invTrfMatrix, /* i : IDCT matrix for synthesis */
- const DCTTYPE idcttype, /* i : specify which IDCT */
- float *uq, /* o : synthesized stage1 vector */
- Word16 *uq_ind /* o : synthesized stage1 vector in BASOP */
-)
-{
- int16_t col, segm_ind, j;
- float dct_vec[FDCNG_VQ_MAX_LEN];
- float idct_vec[FDCNG_VQ_MAX_LEN];
- const Word8 *cbpW8;
- const Word16 *dct_col_shift_tab;
-
- assert( n <= FDCNG_VQ_MAX_LEN );
- assert( n >= FDCNG_VQ_DCT_MINTRUNC );
-
- segm_ind = 0;
- for ( col = 1; col <= FDCNG_VQ_DCT_NSEGM; col++ )
- {
- if ( j_full >= cdk1_ivas_cum_entries_per_segment[col] )
- {
- segm_ind++;
- }
- }
-
- j = j_full - cdk1_ivas_cum_entries_per_segment[segm_ind]; /* j is the local segment index */
-
- assert( j < cdk1_ivas_entries_per_segment[segm_ind] );
-
- /* Word8 column variable Qx storage*/
- cbpW8 = cdk_37bits_ivas_stage1_W8Qx_dct_sections[segm_ind]; /* Word8 storage fixed ptr_init */
- cbpW8 += j * cdk1_ivas_cols_per_segment[segm_ind]; /* adaptive ptr init */
- dct_col_shift_tab = stage1_dct_col_syn_shift[segm_ind];
-
- for ( col = 0; col < cdk1_ivas_cols_per_segment[segm_ind]; col++ )
- {
- dct_vec[col] = (float) shl( (Word16) cbpW8[col], dct_col_shift_tab[col] );
- /* LOGIC( 1 ) , SHIFT( 1 );
- in BASOP: s_and(for W8->W16), shl()
- */
- }
- dctT2_N_apply_matrix( (const float *) dct_vec, idct_vec, cdk1_ivas_cols_per_segment[segm_ind], n, invTrfMatrix, FDCNG_VQ_DCT_MAXTRUNC, idcttype );
-
- /*scale down to original fdcngvq domain and move to Q0 */
- v_multc( idct_vec, fdcng_dct_scaleF[1], idct_vec, n );
- /* fdcng_dct_scaleF[1] --> 0.0625-->scale down from search Q4 domain to Q0 ,
- not really relevant for BASOP loop */
-
- /*add common mid fdcng vector, in fdcng bands domain */
- v_add( idct_vec, cdk1r_tr_midQ_truncQ, uq, n );
- assert( uq_ind == NULL );
-
- return;
-}
-
-#endif
void msvq_dec(
const Word16 *const *cb, /* i : Codebook (indexed cb[*stages][levels][p]) (14Q1*1.28)*/
const Word16 dims[], /* i : Dimension of each codebook stage (NULL: full dim.) */
@@ -3374,11 +3315,7 @@ void msvq_dec(
const Word16 N, /* i : Vector dimension */
const Word16 maxN, /* i : Codebook dimension */
const Word16 Idx[], /* i : Indices */
-#ifdef IVAS_MSVQ
- const int16_t applyIDCT_flag, /* i : applyIDCT flag */
- const float *invTrfMatrix, /* i : matrix for IDCT synthesis */
-#endif
- Word16 *uq /* o : quantized vector (14Q1*1.28)*/
+ Word16 *uq /* o : quantized vector (14Q1*1.28)*/
)
{
Word16 i, j, offset;
@@ -3414,15 +3351,6 @@ void msvq_dec(
start = offs[i];
move16();
}
-#ifdef IVAS_MSVQ
- test();
- IF( i == 0 && applyIDCT_flag != 0 )
- {
- assert( start == 0 );
- dec_FDCNG_MSVQ_stage1( Idx[0], N, invTrfMatrix, IDCT_T2_XX_24, uq, uq_ind ); /* IDCT_T2 N=24 used for all synthesis */
- }
- ELSE
-#endif
{
/*vr_add( uq+start, cb[i]+Idx[i]*maxn, uq+start, n );, where uq = a zero vector*/
offset = i_mult2( Idx[i], N34 );
@@ -4499,217 +4427,3 @@ void create_IDCT_N_Matrix_fx(
return;
}
-#ifdef IVAS_MSVQ
-
-/*-------------------------------------------------------------------*
- * dctT2_N_apply_matrix()
- *
- * dct/idct truncated matrix appl. for DCT basis vector lengths of N
- *-------------------------------------------------------------------*/
-
-void dctT2_N_apply_matrix(
- const float *input, /* i : input in fdcng or DCT(fdcng) domain */
- float *output, /* o : output in DCT(fdcng) or fdcng ordomain */
- const int16_t dct_dim, /* i : dct processing dim possibly truncated */
- const int16_t fdcngvq_dim, /* i : fdcng domain length */
- const float *matrix, /* i : IDCT matrix */
- const int16_t matrix_row_dim, /* i : */
- const DCTTYPE dcttype /* i : matrix operation type */
-)
-{
- int16_t i, j, dim_in, dim_out;
- int16_t mat_step_col, mat_step_row, mat_step_col_flag;
- const float *pt_x, *pt_A;
- float tmp_y[FDCNG_VQ_MAX_LEN];
- float *pt_y;
-
- /* non-square DCT_N and IDCT_N matrix application,
- using a stored format of an IDCT_Nx(FDCNG_VQ_DCT_MAXTRUNC) matrix */
- /* efficiently parallelized in SIMD */
-
- assert( dct_dim <= FDCNG_VQ_DCT_MAXTRUNC );
- assert( fdcngvq_dim <= FDCNG_VQ_MAX_LEN );
-
- if ( ( dcttype & 1 ) == 0 ) /* even entries are DCTs */
- {
- /* DCT_typeII 24,21 -> XX in worst case */
- dim_in = fdcngvq_dim;
- dim_out = dct_dim;
- mat_step_col = matrix_row_dim; /* matrix maximum storage size dependent, width of first row in matrix */
- mat_step_row = 0;
- mat_step_col_flag = 1;
- assert( dcttype == DCT_T2_21_XX || dcttype == DCT_T2_24_XX );
- }
- else
- {
- assert( ( dcttype & 1 ) != 0 ); /* idct */
- dim_in = dct_dim;
- dim_out = fdcngvq_dim;
- mat_step_col = 1;
- mat_step_row = matrix_row_dim;
- mat_step_col_flag = 0;
- assert( dcttype == IDCT_T2_XX_24 );
- }
-
- pt_y = tmp_y;
- for ( i = 0; i < dim_out; i++ )
- {
- pt_x = input;
- *pt_y = 0;
-
- /* +i(DCT) or +i*maxTrunc(IDCT) */
-#define WMC_TOOL_SKIP
- pt_A = &( matrix[i * ( mat_step_row + mat_step_col_flag )] ); /* ptr indexing */
- PTR_INIT( 1 );
-#undef WMC_TOOL_SKIP
- for ( j = 0; j < dim_in; j++ )
- {
-#define WMC_TOOL_SKIP
- *pt_y += ( *pt_x++ ) * ( *pt_A );
- pt_A += mat_step_col; /* step +maxtrunc or +1 */ /* ptr indexing*/
- MAC( 1 );
-#undef WMC_TOOL_SKIP
- }
- pt_y++;
- }
-
- mvr2r( tmp_y, output, dim_out );
-
- return;
-}
-
-
-/*-------------------------------------------------------------------*
- * extend_dctN_input()
- *
- * (inputN, dctN) -> idct(N_ext) idct_N matrix application loop for
- * extending, extrapolating a DCT basis vector length of N to N_ext
- *-------------------------------------------------------------------*/
-
-void extend_dctN_input(
- const float *input, /* i : input in fdcng domain */
- const float *dct_input, /* i : input in dctN(fdcng) domain */
- const int16_t in_dim, /* i : in_dim == N */
- float *ext_sig, /* o : extended output in fdcng domain */
- const int16_t out_dim, /* i : output total dim */
- float *matrix, /* i : idct synthesis matrix N rows, n_cols columns */
- const int16_t n_cols, /* i : number of columns == DCT truncation length */
- const DCTTYPE dcttype /* i : matrix operation type */
-)
-{
- int16_t i, j, i_rev;
- const float( *ptr )[FDCNG_VQ_DCT_MAXTRUNC] = (void *) matrix;
-
- /* stored format is an IDCT_Nx(FDCNG_VQ_DCT_MAXTRUNC) matrix */
- assert( in_dim < FDCNG_VQ_MAX_LEN );
- assert( out_dim <= FDCNG_VQ_MAX_LEN );
- assert( out_dim > in_dim );
- assert( n_cols == FDCNG_VQ_DCT_MAXTRUNC ); /* for *ptr[MAX_TRUNC] adressing*/
- assert( ( dcttype & 1 ) != 0 ); /* idct tables always in use for this basis vector extension */
-
- mvr2r( input, ext_sig, in_dim ); /* copy initial part, i.e. only last/tail parts are extended */
- set_f( &( ext_sig[in_dim] ), 0.0, out_dim - in_dim );
-
- i_rev = in_dim; /*ptr init*/
- for ( i = in_dim; i < out_dim; i++ )
- { /* for each extension sample */
- /* i = 21 22 23;
- i_rev = 20 19 18; for odd dctII reflect basis vector
- */
- i_rev--;
-
- for ( j = 0; j < n_cols; j++ ) /* for each available DCT coeff */
- {
- /* DCTcoeff * reflected basis vector */
-#define WMC_TOOL_SKIP
- /* pure ptr MAC operations */
- ext_sig[i] += dct_input[j] * ptr[i_rev][j]; /* sum up scaled and extended basis vector */
- MAC( 1 );
-#undef WMC_TOOL_SKIP
- }
- }
-
- return;
-}
-
-
-/*-------------------------------------------------------------------*
- * create_IDCT_N_Matrix()
- *
- * inititate idct24 FDCNG_VQ_DCT_MAXTRUNCx N matrix in
- * RAM from a quantized compressed ROM format
- *-------------------------------------------------------------------*/
-
-void create_IDCT_N_Matrix(
- float *inv_matrixFloatQ, /* i/o: RAM buffer */
- const int16_t N, /* i : DCT length, number of time samples */
- const int16_t n_cols, /* i : number of dct coeffs (as DCT may be truncated) */
- const int16_t alloc_size /* i : RAM buffer size in elements */
-)
-{
- int16_t c, c1, r, r_flip, W16_val;
- int16_t len;
- int16_t mat_cpy_size;
- const Word16 *absval_ptr;
- const Word8 *idx_ptr;
- Word16 idx;
- float( *ptr )[FDCNG_VQ_DCT_MAXTRUNC] = (void *) inv_matrixFloatQ; /* fixed number of columns pointers, to simplifies adressing in ANSIC */
-
- absval_ptr = unique_idctT2_24coeffsQ16;
- idx_ptr = idctT2_24_compressed_idx;
- len = FDCNG_VQ_MAX_LEN;
-
- if ( N == FDCNG_VQ_MAX_LEN_WB )
- {
- absval_ptr = unique_idctT2_21coeffsQ16;
- idx_ptr = idctT2_21_compressed_idx;
- len = N;
- }
-
- assert( alloc_size >= ( n_cols * len ) ); /* enough space for the full expanded IDCT matrix */
- assert( N <= len );
-
- mat_cpy_size = ( n_cols ) * ( len >> 1 ); /* NB integer division of "len" */
-
- if ( ( len & 1 ) != 0 )
- { /* odd sized DCT with a non-reflected center row */
- mat_cpy_size += n_cols;
- }
-
- for ( c = 0; c < mat_cpy_size; c++ )
- {
- idx = (Word16) ( idx_ptr[c] );
- W16_val = absval_ptr[abs( idx )];
-
- if ( idx < 0 )
- {
- W16_val = -( W16_val );
- }
- inv_matrixFloatQ[c] = ( +1.52587890625e-05f ) * ( (float) W16_val ); /* 1.0/2.^16 scaling to a float-"Q0" , a scaling that is not done in BASOP */
- }
-
- /* for even number of coeffs DCT24,
- flip symmetry for odd, even is used to save 50% IDCT Table ROM */
- /* for an odd DCT center is not flipped e.g for DCT21 */
-
- assert( n_cols == FDCNG_VQ_DCT_MAXTRUNC );
- assert( ( n_cols & 1 ) == 0 );
-
- for ( c = 0; c < ( n_cols ); c += 2 )
- {
- c1 = c + 1;
- r_flip = len - 1;
- for ( r = 0; r < ( len / 2 ); r++, r_flip-- )
- {
-#define WMC_TOOL_SKIP
- ptr[r_flip][c] = ptr[r][c]; /* flipped */
- ptr[r_flip][c1] = -( ptr[r][c1] ); /* flipped and sign swapped */
- MOVE( 2 );
- MULT( 1 ); /* for negate */
-#undef WMC_TOOL_SKIP
- }
- }
-
- return;
-}
-#endif
diff --git a/lib_com/modif_fs.c b/lib_com/modif_fs.c
deleted file mode 100644
index 10e64a57deb9efbc548a2416db10d1ec550d66cf..0000000000000000000000000000000000000000
--- a/lib_com/modif_fs.c
+++ /dev/null
@@ -1,469 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository. All Rights Reserved.
-
- This software is protected by copyright law and by international treaties.
- The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository retain full ownership rights in their respective contributions in
- the software. This notice grants no license of any kind, including but not limited to patent
- license, nor is any license granted by implication, estoppel or otherwise.
-
- Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
- contributions.
-
- This software is provided "AS IS", without any express or implied warranties. The software is in the
- development stage. It is intended exclusively for experts who have experience with such software and
- solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
- and fitness for a particular purpose are hereby disclaimed and excluded.
-
- Any dispute, controversy or claim arising under or in relation to providing this software shall be
- submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
- accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
- the United Nations Convention on Contracts on the International Sales of Goods.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include
-#include "cnst.h"
-#include "prot_fx.h"
-#include "rom_com.h"
-#include "wmc_auto.h"
-
-
-/* IVAS 32-bit variant */
-void Interpolate_allpass_steep_fx32(
- const Word32 *in_fx, /* i : input array of size N Qx */
- Word32 *mem_fx, /* i/o: memory Qx */
- const Word16 N, /* i : number of input samples */
- Word32 *out_fx /* o : output array of size 2*N Qx */
-)
-{
- Word16 n, k;
- Word32 temp_fx[ALLPASSSECTIONS_STEEP - 1];
-
- /* upper allpass filter chain */
- FOR( k = 0; k < N; k++ )
- {
- temp_fx[0] = Madd_32_16( mem_fx[0], in_fx[k], AP2_STEEP_FX[0] ); // Qx
- move32();
- mem_fx[0] = Msub_32_16( in_fx[k], temp_fx[0], AP2_STEEP_FX[0] ); // Qx
- move32();
-
- /* for better performance, unroll this loop */
- FOR( n = 1; n < ALLPASSSECTIONS_STEEP - 1; n++ )
- {
- temp_fx[n] = Madd_32_16( mem_fx[n], temp_fx[n - 1], AP2_STEEP_FX[n] ); // Qx
- move32();
- mem_fx[n] = Msub_32_16( temp_fx[n - 1], temp_fx[n], AP2_STEEP_FX[n] ); // Qx
- move32();
- }
-
- out_fx[2 * k + 1] = Madd_32_16( mem_fx[ALLPASSSECTIONS_STEEP - 1], temp_fx[ALLPASSSECTIONS_STEEP - 2], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ); // Qx
- move32();
- mem_fx[ALLPASSSECTIONS_STEEP - 1] = Msub_32_16( temp_fx[ALLPASSSECTIONS_STEEP - 2], out_fx[2 * k + 1], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ); // Qx
- move32();
- }
-
- /* lower allpass filter chain */
- FOR( k = 0; k < N; k++ )
- {
- temp_fx[0] = Madd_32_16( mem_fx[ALLPASSSECTIONS_STEEP], in_fx[k], AP1_STEEP_FX[0] ); // Qx
- move32();
- mem_fx[ALLPASSSECTIONS_STEEP] = Msub_32_16( in_fx[k], temp_fx[0], AP1_STEEP_FX[0] ); // Qx
- move32();
-
- /* for better performance, unroll this loop */
- FOR( n = 1; n < ALLPASSSECTIONS_STEEP - 1; n++ )
- {
- temp_fx[n] = Madd_32_16( mem_fx[ALLPASSSECTIONS_STEEP + n], temp_fx[n - 1], AP1_STEEP_FX[n] ); // Qx
- move32();
- mem_fx[ALLPASSSECTIONS_STEEP + n] = Msub_32_16( temp_fx[n - 1], temp_fx[n], AP1_STEEP_FX[n] ); // Qx
- move32();
- }
-
- out_fx[2 * k] = Madd_32_16( mem_fx[2 * ALLPASSSECTIONS_STEEP - 1], temp_fx[ALLPASSSECTIONS_STEEP - 2], AP1_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ); // Qx
- move32();
- mem_fx[2 * ALLPASSSECTIONS_STEEP - 1] = Msub_32_16( temp_fx[ALLPASSSECTIONS_STEEP - 2], out_fx[2 * k], AP1_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ); // Qx
- move32();
- }
-
- return;
-}
-
-/* IVAS 32-bit variant */
-void Decimate_allpass_steep_fx32(
- const Word32 *in, /* i : input array of size N Qx */
- Word32 *mem, /* i/o: memory Qx */
- const Word16 N, /* i : number of input samples */
- Word32 *out /* o : output array of size N/2 Qx */
-)
-{
- Word16 n, k;
- Word32 temp[ALLPASSSECTIONS_STEEP];
-
- /* upper allpass filter chain */
- FOR( k = 0; k < N / 2; k++ )
- {
-#ifdef OPT_STEREO_32KBPS_V1
- temp[0] = Madd_32_16( mem[0], in[2 * k], AP1_STEEP_FX[0] ); // Qx
- move32();
- mem[0] = Msub_32_16( in[2 * k], temp[0], AP1_STEEP_FX[0] ); // Qx
- move32();
-
- temp[1] = Madd_32_16( mem[1], temp[0], AP1_STEEP_FX[1] ); // Qx
- move32();
- mem[1] = Msub_32_16( temp[0], temp[1], AP1_STEEP_FX[1] ); // Qx
- move32();
-
- out[k] = Madd_32_16( mem[ALLPASSSECTIONS_STEEP - 1], temp[ALLPASSSECTIONS_STEEP - 2], AP1_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ); // Qx
- move32();
- mem[ALLPASSSECTIONS_STEEP - 1] = Msub_32_16( temp[ALLPASSSECTIONS_STEEP - 2], out[k], AP1_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ); // Qx
- move32();
-#else /* OPT_STEREO_32KBPS_V1 */
- temp[0] = L_add( mem[0], Mpy_32_16_1( in[2 * k], AP1_STEEP_FX[0] ) ); // Qx
- move32();
- mem[0] = L_sub( in[2 * k], Mpy_32_16_1( temp[0], AP1_STEEP_FX[0] ) ); // Qx
- move32();
-
- temp[1] = L_add( mem[1], Mpy_32_16_1( temp[0], AP1_STEEP_FX[1] ) ); // Qx
- move32();
- mem[1] = L_sub( temp[0], Mpy_32_16_1( temp[1], AP1_STEEP_FX[1] ) ); // Qx
- move32();
-
- out[k] = L_add( mem[ALLPASSSECTIONS_STEEP - 1], Mpy_32_16_1( temp[ALLPASSSECTIONS_STEEP - 2], AP1_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ) ); // Qx
- move32();
- mem[ALLPASSSECTIONS_STEEP - 1] = L_sub( temp[ALLPASSSECTIONS_STEEP - 2], Mpy_32_16_1( out[k], AP1_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ) ); // Qx
- move32();
-#endif /* OPT_STEREO_32KBPS_V1 */
- }
-
- /* lower allpass filter chain */
-#ifdef OPT_STEREO_32KBPS_V1
- temp[0] = Madd_32_16( mem[ALLPASSSECTIONS_STEEP], mem[2 * ALLPASSSECTIONS_STEEP], AP2_STEEP_FX[0] ); // Qx
- move32();
- mem[ALLPASSSECTIONS_STEEP] = Msub_32_16( mem[2 * ALLPASSSECTIONS_STEEP], temp[0], AP2_STEEP_FX[0] ); // Qx
- move32();
-#else /* OPT_STEREO_32KBPS_V1 */
- temp[0] = L_add( mem[ALLPASSSECTIONS_STEEP], Mpy_32_16_1( mem[2 * ALLPASSSECTIONS_STEEP], AP2_STEEP_FX[0] ) ); // Qx
- move32();
- mem[ALLPASSSECTIONS_STEEP] = L_sub( mem[2 * ALLPASSSECTIONS_STEEP], Mpy_32_16_1( temp[0], AP2_STEEP_FX[0] ) ); // Qx
- move32();
-#endif /* OPT_STEREO_32KBPS_V1 */
-
- /* for better performance, unroll this loop */
- FOR( n = 1; n < ALLPASSSECTIONS_STEEP - 1; n++ )
- {
-#ifdef OPT_STEREO_32KBPS_V1
- temp[n] = Madd_32_16( mem[ALLPASSSECTIONS_STEEP + n], temp[n - 1], AP2_STEEP_FX[n] ); // Qx
- move32();
- mem[ALLPASSSECTIONS_STEEP + 1] = Msub_32_16( temp[n - 1], temp[n], AP2_STEEP_FX[n] ); // Qx
- move32();
-#else /* OPT_STEREO_32KBPS_V1 */
- temp[n] = L_add( mem[ALLPASSSECTIONS_STEEP + n], Mpy_32_16_1( temp[n - 1], AP2_STEEP_FX[n] ) ); // Qx
- move32();
- /*if ( fabs( temp[n] ) < 1e-12 )
- {
- temp[n] = sign( temp[n] ) * 1e-12f;
- }*/
- mem[ALLPASSSECTIONS_STEEP + 1] = L_sub( temp[n - 1], Mpy_32_16_1( temp[n], AP2_STEEP_FX[n] ) ); // Qx
- move32();
-#endif /* OPT_STEREO_32KBPS_V1 */
- }
-
-#ifdef OPT_STEREO_32KBPS_V1
- temp[ALLPASSSECTIONS_STEEP - 1] = Madd_32_16( mem[2 * ALLPASSSECTIONS_STEEP - 1], temp[ALLPASSSECTIONS_STEEP - 2], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ); // Qx
- move32();
-
- mem[2 * ALLPASSSECTIONS_STEEP - 1] = Msub_32_16( temp[ALLPASSSECTIONS_STEEP - 2], temp[ALLPASSSECTIONS_STEEP - 1], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ); // Qx
- move32();
-#else /* OPT_STEREO_32KBPS_V1 */
- temp[ALLPASSSECTIONS_STEEP - 1] = L_add( mem[2 * ALLPASSSECTIONS_STEEP - 1], Mpy_32_16_1( temp[ALLPASSSECTIONS_STEEP - 2], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ) ); // Qx
- move32();
-
- mem[2 * ALLPASSSECTIONS_STEEP - 1] = L_sub( temp[ALLPASSSECTIONS_STEEP - 2], Mpy_32_16_1( temp[ALLPASSSECTIONS_STEEP - 1], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ) ); // Qx
- move32();
-#endif /* OPT_STEREO_32KBPS_V1 */
- out[0] = W_round48_L( W_mac_32_16( W_mult_32_16( out[0], 16384 /*0.5 in Q15*/ ), temp[ALLPASSSECTIONS_STEEP - 1], 16384 /*0.5 in Q15*/ ) ); // Qx
- move32();
-
- FOR( k = 1; k < N / 2; k++ )
- {
-#ifdef OPT_STEREO_32KBPS_V1
- temp[0] = Madd_32_16( mem[ALLPASSSECTIONS_STEEP], in[2 * k - 1], AP2_STEEP_FX[0] ); // Qx
- move32();
- mem[ALLPASSSECTIONS_STEEP] = Msub_32_16( in[2 * k - 1], temp[0], AP2_STEEP_FX[0] ); // Qx
- move32();
-#else /* OPT_STEREO_32KBPS_V1 */
- temp[0] = L_add( mem[ALLPASSSECTIONS_STEEP], Mpy_32_16_1( in[sub( shl( k, 1 ), 1 )], AP2_STEEP_FX[0] ) ); // Qx
- move32();
- mem[ALLPASSSECTIONS_STEEP] = L_sub( in[sub( shl( k, 1 ), 1 )], Mpy_32_16_1( temp[0], AP2_STEEP_FX[0] ) ); // Qx
- move32();
-#endif /* OPT_STEREO_32KBPS_V1 */
-
- /* for better performance, unroll this loop */
- FOR( n = 1; n < ALLPASSSECTIONS_STEEP - 1; n++ )
- {
-#ifdef OPT_STEREO_32KBPS_V1
- temp[n] = Madd_32_16( mem[ALLPASSSECTIONS_STEEP + n], temp[n - 1], AP2_STEEP_FX[n] ); // Qx
- move32();
- mem[ALLPASSSECTIONS_STEEP + n] = Msub_32_16( temp[n - 1], temp[n], AP2_STEEP_FX[n] ); // Qx
- move32();
-#else /* OPT_STEREO_32KBPS_V1 */
- temp[n] = L_add( mem[ALLPASSSECTIONS_STEEP + n], Mpy_32_16_1( temp[n - 1], AP2_STEEP_FX[n] ) ); // Qx
- move32();
- /*if ( fabs( temp[n] ) < 1e-12 )
- {
- temp[n] = sign( temp[n] ) * 1e-12f;
- }*/
- mem[ALLPASSSECTIONS_STEEP + n] = L_sub( temp[n - 1], Mpy_32_16_1( temp[n], AP2_STEEP_FX[n] ) ); // Qx
- move32();
-#endif /* OPT_STEREO_32KBPS_V1 */
- }
-
-#ifdef OPT_STEREO_32KBPS_V1
- temp[ALLPASSSECTIONS_STEEP - 1] = Madd_32_16( mem[2 * ALLPASSSECTIONS_STEEP - 1], temp[ALLPASSSECTIONS_STEEP - 2], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ); // Qx
- move32();
- mem[2 * ALLPASSSECTIONS_STEEP - 1] = Msub_32_16( temp[ALLPASSSECTIONS_STEEP - 2], temp[ALLPASSSECTIONS_STEEP - 1], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ); // Qx
- move32();
-#else /* OPT_STEREO_32KBPS_V1 */
- temp[ALLPASSSECTIONS_STEEP - 1] = L_add( mem[2 * ALLPASSSECTIONS_STEEP - 1], Mpy_32_16_1( temp[ALLPASSSECTIONS_STEEP - 2], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ) ); // Qx
- move32();
- mem[2 * ALLPASSSECTIONS_STEEP - 1] = L_sub( temp[ALLPASSSECTIONS_STEEP - 2], Mpy_32_16_1( temp[ALLPASSSECTIONS_STEEP - 1], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ) ); // Qx
- move32();
-#endif /* OPT_STEREO_32KBPS_V1 */
- out[k] = W_round48_L( W_mac_32_16( W_mult_32_16( out[k], 16384 /*0.5 in Q15*/ ), temp[ALLPASSSECTIONS_STEEP - 1], 16384 /*0.5 in Q15*/ ) ); // Qx
- move32();
- }
-
- /* z^(-1) */
- mem[2 * ALLPASSSECTIONS_STEEP] = in[N - 1];
- move32();
-
- return;
-}
-
-/* IVAS 32-bit variant */
-void interpolate_3_over_2_allpass_fx32(
- const Word32 *input, /* i : input signal Qx*/
- const Word16 len, /* i : number of input samples */
- Word32 *out, /* o : output signal Qx*/
- Word32 *mem /* i/o: memory Qx*/
-)
-{
- Word16 i, loop_len;
- Word32 Vu[2], Vm[2], Vl[2]; /* Outputs of three cascaded allpass stages (upper, middle, and lower) */
- Word32 out1_buff[L_FRAME32k * 3];
- Word32 *out1;
- Word32 mem_temp;
- const Word16 *filt_coeff = allpass_poles_3_ov_2; // Q15
-
- out1 = out1_buff;
-
- FOR( i = 0; i < len; i++ )
- {
- /* Upper branch */
-#ifdef OPT_STEREO_32KBPS_V1
- Vu[0] = Madd_32_16( mem[0], L_sub( input[i], mem[1] ), filt_coeff[0] ); // Qx + Q15 - Q15 -> Qx
- move32();
- Vu[1] = Madd_32_16( mem[1], L_sub( Vu[0], mem[2] ), filt_coeff[1] ); // Qx + Q15 - Q15 -> Qx
- move32();
- mem[3] = Madd_32_16( mem[2], L_sub( Vu[1], mem[3] ), filt_coeff[2] ); // Qx + Q15 - Q15 -> Qx
- move32();
-#else /* OPT_STEREO_32KBPS_V1 */
- Vu[0] = L_add( mem[0], Mpy_32_16_1( L_sub( input[i], mem[1] ), filt_coeff[0] ) ); // Qx + Q15 - Q15 -> Qx
- move32();
- Vu[1] = L_add( mem[1], Mpy_32_16_1( L_sub( Vu[0], mem[2] ), filt_coeff[1] ) ); // Qx + Q15 - Q15 -> Qx
- move32();
- mem[3] = L_add( mem[2], Mpy_32_16_1( L_sub( Vu[1], mem[3] ), filt_coeff[2] ) ); // Qx + Q15 - Q15 -> Qx
- move32();
-#endif /* OPT_STEREO_32KBPS_V1 */
-
- mem[1] = Vu[0]; // Qx
- move32();
- mem[2] = Vu[1]; // Qx
- move32();
- *out1++ = mem[3]; // Qx
- move32();
-
- /* Middle branch */
-#ifdef OPT_STEREO_32KBPS_V1
- Vm[0] = Madd_32_16( mem[0], L_sub( input[i], mem[4] ), filt_coeff[3] ); // Qx + Q15 - Q15 -> Qx
- move32();
- Vm[1] = Madd_32_16( mem[4], L_sub( Vm[0], mem[5] ), filt_coeff[4] ); // Qx + Q15 - Q15 -> Qx
- move32();
- mem[6] = Madd_32_16( mem[5], L_sub( Vm[1], mem[6] ), filt_coeff[5] ); // Qx + Q15 - Q15 -> Qx
- move32();
-#else /* OPT_STEREO_32KBPS_V1 */
- Vm[0] = L_add( mem[0], Mpy_32_16_1( L_sub( input[i], mem[4] ), filt_coeff[3] ) ); // Qx + Q15 - Q15 -> Qx
- move32();
- Vm[1] = L_add( mem[4], Mpy_32_16_1( L_sub( Vm[0], mem[5] ), filt_coeff[4] ) ); // Qx + Q15 - Q15 -> Qx
- move32();
- mem[6] = L_add( mem[5], Mpy_32_16_1( L_sub( Vm[1], mem[6] ), filt_coeff[5] ) ); // Qx + Q15 - Q15 -> Qx
- move32();
-#endif /* OPT_STEREO_32KBPS_V1 */
-
- mem[4] = Vm[0]; // Qx
- move32();
- mem[5] = Vm[1]; // Qx
- move32();
- *out1++ = mem[6]; // Qx
- move32();
-
- /* Lower branch */
-#ifdef OPT_STEREO_32KBPS_V1
- Vl[0] = Madd_32_16( mem[0], L_sub( input[i], mem[7] ), filt_coeff[6] ); // Qx + Q15 - Q15 -> Qx
- move32();
- Vl[1] = Madd_32_16( mem[7], L_sub( Vl[0], mem[8] ), filt_coeff[7] ); // Qx + Q15 - Q15 -> Qx
- move32();
- mem[9] = Madd_32_16( mem[8], L_sub( Vl[1], mem[9] ), filt_coeff[8] ); // Qx + Q15 - Q15 -> Qx
- move32();
-#else /* OPT_STEREO_32KBPS_V1 */
- Vl[0] = L_add( mem[0], Mpy_32_16_1( L_sub( input[i], mem[7] ), filt_coeff[6] ) ); // Qx + Q15 - Q15 -> Qx
- move32();
- Vl[1] = L_add( mem[7], Mpy_32_16_1( L_sub( Vl[0], mem[8] ), filt_coeff[7] ) ); // Qx + Q15 - Q15 -> Qx
- move32();
- mem[9] = L_add( mem[8], Mpy_32_16_1( L_sub( Vl[1], mem[9] ), filt_coeff[8] ) ); // Qx + Q15 - Q15 -> Qx
- move32();
-#endif /* OPT_STEREO_32KBPS_V1 */
-
- mem[0] = input[i]; // Qx
- move32();
- mem[7] = Vl[0]; // Qx
- move32();
- mem[8] = Vl[1]; // Qx
- move32();
- *out1++ = mem[9]; // Qx
- move32();
- }
-
- loop_len = shr( i_mult( len, 3 ), 1 );
-
- /*decimate by 2 and LPF*/
- FOR( i = 0; i < loop_len; i++ )
- {
- mem_temp = out1_buff[2 * i];
- move32();
-#ifdef OPT_STEREO_32KBPS_V1
- out[i] = Madd_32_16( Mpy_32_16_1( L_add( mem_temp, mem[10] ), 1550 ), L_add( mem[11], mem[14] ), -4965 ); // Qx + Q15 - Q15 -> Qx
- // 0.0473147f in Q15 -> 1550, -0.151521f in Q15 -> -4965
- out[i] = Madd_32_16( out[i], L_add( mem[12], mem[13] ), 20125 );
- // 0.614152f in Q15 -> 20125
-#else /* OPT_STEREO_32KBPS_V1 */
- out[i] = L_add( Mpy_32_16_1( L_add( mem_temp, mem[10] ), 1550 ), Mpy_32_16_1( L_add( mem[11], mem[14] ), -4965 ) ); // Qx + Q15 - Q15 -> Qx
- // 0.0473147f in Q15 -> 1550, -0.151521f in Q15 -> -4965
- out[i] = L_add( out[i], Mpy_32_16_1( L_add( mem[12], mem[13] ), 20125 ) );
- // 0.614152f in Q15 -> 20125
-#endif /* OPT_STEREO_32KBPS_V1 */
- mem[10] = mem[11]; // Qx
- move32();
- mem[11] = mem[12]; // Qx
- move32();
- mem[12] = mem[13]; // Qx
- move32();
- mem[13] = mem[14]; // Qx
- move32();
- mem[14] = mem_temp; // Qx
- move32();
- }
-
- return;
-}
-
-/* IVAS 32-bit variant */
-void interpolate_3_over_1_allpass_fx32(
- const Word32 *input, /* i : input signal Qx */
- const Word16 len, /* i : number of input samples */
- Word32 *out, /* o : output signal */
- Word32 *mem /* i/o: memory */
-)
-{
- Word16 i, tmp16;
- Word32 Vu[2], Vm[2], Vl[2]; /* Outputs of three cascaded allpass stages (upper, middle, and lower) */
- Word32 *out1;
- Word32 mem_temp;
- const Word16 *filt_coeff = allpass_poles_3_ov_2; // Qx
-
- out1 = &out[0];
-
- FOR( i = 0; i < len; i++ )
- {
- /* Upper branch */
- Vu[0] = L_add_sat( mem[0], Mpy_32_16_1( L_sub( input[i], mem[1] ), filt_coeff[0] ) ); // Qx
- move32();
- Vu[1] = L_add_sat( mem[1], Mpy_32_16_1( L_sub( Vu[0], mem[2] ), filt_coeff[1] ) ); // Qx
- move32();
- mem[3] = L_add_sat( mem[2], Mpy_32_16_1( L_sub( Vu[1], mem[3] ), filt_coeff[2] ) ); // Qx
- move32();
-
- mem[1] = Vu[0]; // Qx
- move32();
- mem[2] = Vu[1]; // Qx
- move32();
- *out1++ = mem[3]; // Qx
- move32();
-
- /* Middle branch */
- Vm[0] = L_add_sat( mem[0], Mpy_32_16_1( L_sub( input[i], mem[4] ), filt_coeff[3] ) ); // Qx
- move32();
- Vm[1] = L_add_sat( mem[4], Mpy_32_16_1( L_sub( Vm[0], mem[5] ), filt_coeff[4] ) ); // Qx
- move32();
- mem[6] = L_add_sat( mem[5], Mpy_32_16_1( L_sub( Vm[1], mem[6] ), filt_coeff[5] ) ); // Qx
- move32();
-
- mem[4] = Vm[0]; // Qx
- move32();
- mem[5] = Vm[1]; // Qx
- move32();
- *out1++ = mem[6]; // Qx
- move32();
-
- /* Lower branch */
- Vl[0] = L_add_sat( mem[0], Mpy_32_16_1( L_sub( input[i], mem[7] ), filt_coeff[6] ) ); // Qx
- move32();
- Vl[1] = L_add_sat( mem[7], Mpy_32_16_1( L_sub( Vl[0], mem[8] ), filt_coeff[7] ) ); // Qx
- move32();
- mem[9] = L_add_sat( mem[8], Mpy_32_16_1( L_sub( Vl[1], mem[9] ), filt_coeff[8] ) ); // Qx
- move32();
-
- mem[0] = input[i]; // Qx
- move32();
- mem[7] = Vl[0]; // Qx
- move32();
- mem[8] = Vl[1]; // Qx
- move32();
- *out1++ = mem[9]; // Qx
- move32();
- }
-
- /*LPF*/
- tmp16 = imult1616( len, 3 );
- FOR( i = 0; i < tmp16; i++ )
- {
- mem_temp = out[i]; // Qx
- move32();
- out[i] = L_sub_sat( Mpy_32_16_1( L_add_sat( mem[12], mem[11] ), 18768 ), Mpy_32_16_1( L_add_sat( mem_temp, mem[10] ), 2424 ) ); // Qx
- // 0.572769 in Q15 -> 18768, 0.074005 in Q15 -> 2424
- move32();
- mem[10] = mem[11]; // Qx
- move32();
- mem[11] = mem[12]; // Qx
- move32();
- mem[12] = mem_temp; // Qx
- move32();
- }
-
- return;
-}
diff --git a/lib_com/modif_fs_fx.c b/lib_com/modif_fs_fx.c
index bcbff13d57bebe95c3159b1b75e34fdc517fad79..2e39af523138f176abf849628d6f8ea46e6b6a29 100644
--- a/lib_com/modif_fs_fx.c
+++ b/lib_com/modif_fs_fx.c
@@ -3,6 +3,7 @@
====================================================================================*/
#include
+#include
#include "options.h" /* Compilation switches */
#include "cnst.h" /* Common constants */
#include "prot_fx.h"
@@ -11,6 +12,8 @@
#include "rom_enc.h" /* prototypes */
#include "basop_util.h"
#include "ivas_prot_fx.h"
+#include "wmc_auto.h"
+
/*-----------------------------------------------------------------*
* Local functions
@@ -39,6 +42,7 @@
/*------------------------------------------------------------------------------*/
/* CALLED FROM : TX/RX */
/*==============================================================================*/
+
Word16 modify_Fs_ivas_fx( /* o : length of output Q0 */
const Word16 sigIn_fx[], /* i : signal to decimate Q0 */
Word16 lg, /* i : length of input Q0 */
@@ -323,6 +327,7 @@ Word16 modify_Fs_ivas_fx( /* o : length of output Q
return lg_out;
}
+
Word16 modify_Fs_fx( /* o : length of output Q0 */
const Word16 sigIn_fx[], /* i : signal to decimate Q0 */
Word16 lg, /* i : length of input Q0 */
@@ -599,6 +604,7 @@ Word16 modify_Fs_fx( /* o : length of output Q0 */
return lg_out;
}
+
/*-------------------------------------------------------------------*
* modify_Fs_intcub3m_sup()
*
@@ -911,7 +917,6 @@ Word16 modify_Fs_intcub3m_sup_fx( /* o : length of output
/* RETURN ARGUMENTS : _ None. */
/*===================================================================*/
-
void Decimate_allpass_steep_fx(
const Word16 *in_fx,
Word16 mem[], /* array of size: 2*ALLPASSSECTIONS_STEEP+1 */
@@ -1040,6 +1045,158 @@ void Decimate_allpass_steep_fx(
move16(); /* Qx */
}
+/* IVAS 32-bit variant */
+void Decimate_allpass_steep_fx32(
+ const Word32 *in, /* i : input array of size N Qx */
+ Word32 *mem, /* i/o: memory Qx */
+ const Word16 N, /* i : number of input samples */
+ Word32 *out /* o : output array of size N/2 Qx */
+)
+{
+ Word16 n, k;
+ Word32 temp[ALLPASSSECTIONS_STEEP];
+
+ /* upper allpass filter chain */
+ FOR( k = 0; k < N / 2; k++ )
+ {
+#ifdef OPT_STEREO_32KBPS_V1
+ temp[0] = Madd_32_16( mem[0], in[2 * k], AP1_STEEP_FX[0] ); // Qx
+ move32();
+ mem[0] = Msub_32_16( in[2 * k], temp[0], AP1_STEEP_FX[0] ); // Qx
+ move32();
+
+ temp[1] = Madd_32_16( mem[1], temp[0], AP1_STEEP_FX[1] ); // Qx
+ move32();
+ mem[1] = Msub_32_16( temp[0], temp[1], AP1_STEEP_FX[1] ); // Qx
+ move32();
+
+ out[k] = Madd_32_16( mem[ALLPASSSECTIONS_STEEP - 1], temp[ALLPASSSECTIONS_STEEP - 2], AP1_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ); // Qx
+ move32();
+ mem[ALLPASSSECTIONS_STEEP - 1] = Msub_32_16( temp[ALLPASSSECTIONS_STEEP - 2], out[k], AP1_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ); // Qx
+ move32();
+#else /* OPT_STEREO_32KBPS_V1 */
+ temp[0] = L_add( mem[0], Mpy_32_16_1( in[2 * k], AP1_STEEP_FX[0] ) ); // Qx
+ move32();
+ mem[0] = L_sub( in[2 * k], Mpy_32_16_1( temp[0], AP1_STEEP_FX[0] ) ); // Qx
+ move32();
+
+ temp[1] = L_add( mem[1], Mpy_32_16_1( temp[0], AP1_STEEP_FX[1] ) ); // Qx
+ move32();
+ mem[1] = L_sub( temp[0], Mpy_32_16_1( temp[1], AP1_STEEP_FX[1] ) ); // Qx
+ move32();
+
+ out[k] = L_add( mem[ALLPASSSECTIONS_STEEP - 1], Mpy_32_16_1( temp[ALLPASSSECTIONS_STEEP - 2], AP1_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ) ); // Qx
+ move32();
+ mem[ALLPASSSECTIONS_STEEP - 1] = L_sub( temp[ALLPASSSECTIONS_STEEP - 2], Mpy_32_16_1( out[k], AP1_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ) ); // Qx
+ move32();
+#endif /* OPT_STEREO_32KBPS_V1 */
+ }
+
+ /* lower allpass filter chain */
+#ifdef OPT_STEREO_32KBPS_V1
+ temp[0] = Madd_32_16( mem[ALLPASSSECTIONS_STEEP], mem[2 * ALLPASSSECTIONS_STEEP], AP2_STEEP_FX[0] ); // Qx
+ move32();
+ mem[ALLPASSSECTIONS_STEEP] = Msub_32_16( mem[2 * ALLPASSSECTIONS_STEEP], temp[0], AP2_STEEP_FX[0] ); // Qx
+ move32();
+#else /* OPT_STEREO_32KBPS_V1 */
+ temp[0] = L_add( mem[ALLPASSSECTIONS_STEEP], Mpy_32_16_1( mem[2 * ALLPASSSECTIONS_STEEP], AP2_STEEP_FX[0] ) ); // Qx
+ move32();
+ mem[ALLPASSSECTIONS_STEEP] = L_sub( mem[2 * ALLPASSSECTIONS_STEEP], Mpy_32_16_1( temp[0], AP2_STEEP_FX[0] ) ); // Qx
+ move32();
+#endif /* OPT_STEREO_32KBPS_V1 */
+
+ /* for better performance, unroll this loop */
+ FOR( n = 1; n < ALLPASSSECTIONS_STEEP - 1; n++ )
+ {
+#ifdef OPT_STEREO_32KBPS_V1
+ temp[n] = Madd_32_16( mem[ALLPASSSECTIONS_STEEP + n], temp[n - 1], AP2_STEEP_FX[n] ); // Qx
+ move32();
+ mem[ALLPASSSECTIONS_STEEP + 1] = Msub_32_16( temp[n - 1], temp[n], AP2_STEEP_FX[n] ); // Qx
+ move32();
+#else /* OPT_STEREO_32KBPS_V1 */
+ temp[n] = L_add( mem[ALLPASSSECTIONS_STEEP + n], Mpy_32_16_1( temp[n - 1], AP2_STEEP_FX[n] ) ); // Qx
+ move32();
+ /*if ( fabs( temp[n] ) < 1e-12 )
+ {
+ temp[n] = sign( temp[n] ) * 1e-12f;
+ }*/
+ mem[ALLPASSSECTIONS_STEEP + 1] = L_sub( temp[n - 1], Mpy_32_16_1( temp[n], AP2_STEEP_FX[n] ) ); // Qx
+ move32();
+#endif /* OPT_STEREO_32KBPS_V1 */
+ }
+
+#ifdef OPT_STEREO_32KBPS_V1
+ temp[ALLPASSSECTIONS_STEEP - 1] = Madd_32_16( mem[2 * ALLPASSSECTIONS_STEEP - 1], temp[ALLPASSSECTIONS_STEEP - 2], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ); // Qx
+ move32();
+
+ mem[2 * ALLPASSSECTIONS_STEEP - 1] = Msub_32_16( temp[ALLPASSSECTIONS_STEEP - 2], temp[ALLPASSSECTIONS_STEEP - 1], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ); // Qx
+ move32();
+#else /* OPT_STEREO_32KBPS_V1 */
+ temp[ALLPASSSECTIONS_STEEP - 1] = L_add( mem[2 * ALLPASSSECTIONS_STEEP - 1], Mpy_32_16_1( temp[ALLPASSSECTIONS_STEEP - 2], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ) ); // Qx
+ move32();
+
+ mem[2 * ALLPASSSECTIONS_STEEP - 1] = L_sub( temp[ALLPASSSECTIONS_STEEP - 2], Mpy_32_16_1( temp[ALLPASSSECTIONS_STEEP - 1], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ) ); // Qx
+ move32();
+#endif /* OPT_STEREO_32KBPS_V1 */
+ out[0] = W_round48_L( W_mac_32_16( W_mult_32_16( out[0], 16384 /*0.5 in Q15*/ ), temp[ALLPASSSECTIONS_STEEP - 1], 16384 /*0.5 in Q15*/ ) ); // Qx
+ move32();
+
+ FOR( k = 1; k < N / 2; k++ )
+ {
+#ifdef OPT_STEREO_32KBPS_V1
+ temp[0] = Madd_32_16( mem[ALLPASSSECTIONS_STEEP], in[2 * k - 1], AP2_STEEP_FX[0] ); // Qx
+ move32();
+ mem[ALLPASSSECTIONS_STEEP] = Msub_32_16( in[2 * k - 1], temp[0], AP2_STEEP_FX[0] ); // Qx
+ move32();
+#else /* OPT_STEREO_32KBPS_V1 */
+ temp[0] = L_add( mem[ALLPASSSECTIONS_STEEP], Mpy_32_16_1( in[sub( shl( k, 1 ), 1 )], AP2_STEEP_FX[0] ) ); // Qx
+ move32();
+ mem[ALLPASSSECTIONS_STEEP] = L_sub( in[sub( shl( k, 1 ), 1 )], Mpy_32_16_1( temp[0], AP2_STEEP_FX[0] ) ); // Qx
+ move32();
+#endif /* OPT_STEREO_32KBPS_V1 */
+
+ /* for better performance, unroll this loop */
+ FOR( n = 1; n < ALLPASSSECTIONS_STEEP - 1; n++ )
+ {
+#ifdef OPT_STEREO_32KBPS_V1
+ temp[n] = Madd_32_16( mem[ALLPASSSECTIONS_STEEP + n], temp[n - 1], AP2_STEEP_FX[n] ); // Qx
+ move32();
+ mem[ALLPASSSECTIONS_STEEP + n] = Msub_32_16( temp[n - 1], temp[n], AP2_STEEP_FX[n] ); // Qx
+ move32();
+#else /* OPT_STEREO_32KBPS_V1 */
+ temp[n] = L_add( mem[ALLPASSSECTIONS_STEEP + n], Mpy_32_16_1( temp[n - 1], AP2_STEEP_FX[n] ) ); // Qx
+ move32();
+ /*if ( fabs( temp[n] ) < 1e-12 )
+ {
+ temp[n] = sign( temp[n] ) * 1e-12f;
+ }*/
+ mem[ALLPASSSECTIONS_STEEP + n] = L_sub( temp[n - 1], Mpy_32_16_1( temp[n], AP2_STEEP_FX[n] ) ); // Qx
+ move32();
+#endif /* OPT_STEREO_32KBPS_V1 */
+ }
+
+#ifdef OPT_STEREO_32KBPS_V1
+ temp[ALLPASSSECTIONS_STEEP - 1] = Madd_32_16( mem[2 * ALLPASSSECTIONS_STEEP - 1], temp[ALLPASSSECTIONS_STEEP - 2], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ); // Qx
+ move32();
+ mem[2 * ALLPASSSECTIONS_STEEP - 1] = Msub_32_16( temp[ALLPASSSECTIONS_STEEP - 2], temp[ALLPASSSECTIONS_STEEP - 1], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ); // Qx
+ move32();
+#else /* OPT_STEREO_32KBPS_V1 */
+ temp[ALLPASSSECTIONS_STEEP - 1] = L_add( mem[2 * ALLPASSSECTIONS_STEEP - 1], Mpy_32_16_1( temp[ALLPASSSECTIONS_STEEP - 2], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ) ); // Qx
+ move32();
+ mem[2 * ALLPASSSECTIONS_STEEP - 1] = L_sub( temp[ALLPASSSECTIONS_STEEP - 2], Mpy_32_16_1( temp[ALLPASSSECTIONS_STEEP - 1], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ) ); // Qx
+ move32();
+#endif /* OPT_STEREO_32KBPS_V1 */
+ out[k] = W_round48_L( W_mac_32_16( W_mult_32_16( out[k], 16384 /*0.5 in Q15*/ ), temp[ALLPASSSECTIONS_STEEP - 1], 16384 /*0.5 in Q15*/ ) ); // Qx
+ move32();
+ }
+
+ /* z^(-1) */
+ mem[2 * ALLPASSSECTIONS_STEEP] = in[N - 1];
+ move32();
+
+ return;
+}
+
/*-------------------------------------------------------------------*
* Interpolate_allpass_steep()
@@ -1122,6 +1279,66 @@ void Interpolate_allpass_steep_fx(
return;
}
+/* IVAS 32-bit variant */
+void Interpolate_allpass_steep_fx32(
+ const Word32 *in_fx, /* i : input array of size N Qx */
+ Word32 *mem_fx, /* i/o: memory Qx */
+ const Word16 N, /* i : number of input samples */
+ Word32 *out_fx /* o : output array of size 2*N Qx */
+)
+{
+ Word16 n, k;
+ Word32 temp_fx[ALLPASSSECTIONS_STEEP - 1];
+
+ /* upper allpass filter chain */
+ FOR( k = 0; k < N; k++ )
+ {
+ temp_fx[0] = Madd_32_16( mem_fx[0], in_fx[k], AP2_STEEP_FX[0] ); // Qx
+ move32();
+ mem_fx[0] = Msub_32_16( in_fx[k], temp_fx[0], AP2_STEEP_FX[0] ); // Qx
+ move32();
+
+ /* for better performance, unroll this loop */
+ FOR( n = 1; n < ALLPASSSECTIONS_STEEP - 1; n++ )
+ {
+ temp_fx[n] = Madd_32_16( mem_fx[n], temp_fx[n - 1], AP2_STEEP_FX[n] ); // Qx
+ move32();
+ mem_fx[n] = Msub_32_16( temp_fx[n - 1], temp_fx[n], AP2_STEEP_FX[n] ); // Qx
+ move32();
+ }
+
+ out_fx[2 * k + 1] = Madd_32_16( mem_fx[ALLPASSSECTIONS_STEEP - 1], temp_fx[ALLPASSSECTIONS_STEEP - 2], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ); // Qx
+ move32();
+ mem_fx[ALLPASSSECTIONS_STEEP - 1] = Msub_32_16( temp_fx[ALLPASSSECTIONS_STEEP - 2], out_fx[2 * k + 1], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ); // Qx
+ move32();
+ }
+
+ /* lower allpass filter chain */
+ FOR( k = 0; k < N; k++ )
+ {
+ temp_fx[0] = Madd_32_16( mem_fx[ALLPASSSECTIONS_STEEP], in_fx[k], AP1_STEEP_FX[0] ); // Qx
+ move32();
+ mem_fx[ALLPASSSECTIONS_STEEP] = Msub_32_16( in_fx[k], temp_fx[0], AP1_STEEP_FX[0] ); // Qx
+ move32();
+
+ /* for better performance, unroll this loop */
+ FOR( n = 1; n < ALLPASSSECTIONS_STEEP - 1; n++ )
+ {
+ temp_fx[n] = Madd_32_16( mem_fx[ALLPASSSECTIONS_STEEP + n], temp_fx[n - 1], AP1_STEEP_FX[n] ); // Qx
+ move32();
+ mem_fx[ALLPASSSECTIONS_STEEP + n] = Msub_32_16( temp_fx[n - 1], temp_fx[n], AP1_STEEP_FX[n] ); // Qx
+ move32();
+ }
+
+ out_fx[2 * k] = Madd_32_16( mem_fx[2 * ALLPASSSECTIONS_STEEP - 1], temp_fx[ALLPASSSECTIONS_STEEP - 2], AP1_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ); // Qx
+ move32();
+ mem_fx[2 * ALLPASSSECTIONS_STEEP - 1] = Msub_32_16( temp_fx[ALLPASSSECTIONS_STEEP - 2], out_fx[2 * k], AP1_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ); // Qx
+ move32();
+ }
+
+ return;
+}
+
/*-------------------------------------------------------------------*
* interpolate_3_over_2_allpass_fx()
@@ -1250,6 +1467,133 @@ void interpolate_3_over_2_allpass_fx(
return;
}
+/* IVAS 32-bit variant */
+void interpolate_3_over_2_allpass_fx32(
+ const Word32 *input, /* i : input signal Qx*/
+ const Word16 len, /* i : number of input samples */
+ Word32 *out, /* o : output signal Qx*/
+ Word32 *mem /* i/o: memory Qx*/
+)
+{
+ Word16 i, loop_len;
+ Word32 Vu[2], Vm[2], Vl[2]; /* Outputs of three cascaded allpass stages (upper, middle, and lower) */
+ Word32 out1_buff[L_FRAME32k * 3];
+ Word32 *out1;
+ Word32 mem_temp;
+ const Word16 *filt_coeff = allpass_poles_3_ov_2; // Q15
+
+ out1 = out1_buff;
+
+ FOR( i = 0; i < len; i++ )
+ {
+ /* Upper branch */
+#ifdef OPT_STEREO_32KBPS_V1
+ Vu[0] = Madd_32_16( mem[0], L_sub( input[i], mem[1] ), filt_coeff[0] ); // Qx + Q15 - Q15 -> Qx
+ move32();
+ Vu[1] = Madd_32_16( mem[1], L_sub( Vu[0], mem[2] ), filt_coeff[1] ); // Qx + Q15 - Q15 -> Qx
+ move32();
+ mem[3] = Madd_32_16( mem[2], L_sub( Vu[1], mem[3] ), filt_coeff[2] ); // Qx + Q15 - Q15 -> Qx
+ move32();
+#else /* OPT_STEREO_32KBPS_V1 */
+ Vu[0] = L_add( mem[0], Mpy_32_16_1( L_sub( input[i], mem[1] ), filt_coeff[0] ) ); // Qx + Q15 - Q15 -> Qx
+ move32();
+ Vu[1] = L_add( mem[1], Mpy_32_16_1( L_sub( Vu[0], mem[2] ), filt_coeff[1] ) ); // Qx + Q15 - Q15 -> Qx
+ move32();
+ mem[3] = L_add( mem[2], Mpy_32_16_1( L_sub( Vu[1], mem[3] ), filt_coeff[2] ) ); // Qx + Q15 - Q15 -> Qx
+ move32();
+#endif /* OPT_STEREO_32KBPS_V1 */
+
+ mem[1] = Vu[0]; // Qx
+ move32();
+ mem[2] = Vu[1]; // Qx
+ move32();
+ *out1++ = mem[3]; // Qx
+ move32();
+
+ /* Middle branch */
+#ifdef OPT_STEREO_32KBPS_V1
+ Vm[0] = Madd_32_16( mem[0], L_sub( input[i], mem[4] ), filt_coeff[3] ); // Qx + Q15 - Q15 -> Qx
+ move32();
+ Vm[1] = Madd_32_16( mem[4], L_sub( Vm[0], mem[5] ), filt_coeff[4] ); // Qx + Q15 - Q15 -> Qx
+ move32();
+ mem[6] = Madd_32_16( mem[5], L_sub( Vm[1], mem[6] ), filt_coeff[5] ); // Qx + Q15 - Q15 -> Qx
+ move32();
+#else /* OPT_STEREO_32KBPS_V1 */
+ Vm[0] = L_add( mem[0], Mpy_32_16_1( L_sub( input[i], mem[4] ), filt_coeff[3] ) ); // Qx + Q15 - Q15 -> Qx
+ move32();
+ Vm[1] = L_add( mem[4], Mpy_32_16_1( L_sub( Vm[0], mem[5] ), filt_coeff[4] ) ); // Qx + Q15 - Q15 -> Qx
+ move32();
+ mem[6] = L_add( mem[5], Mpy_32_16_1( L_sub( Vm[1], mem[6] ), filt_coeff[5] ) ); // Qx + Q15 - Q15 -> Qx
+ move32();
+#endif /* OPT_STEREO_32KBPS_V1 */
+
+ mem[4] = Vm[0]; // Qx
+ move32();
+ mem[5] = Vm[1]; // Qx
+ move32();
+ *out1++ = mem[6]; // Qx
+ move32();
+
+ /* Lower branch */
+#ifdef OPT_STEREO_32KBPS_V1
+ Vl[0] = Madd_32_16( mem[0], L_sub( input[i], mem[7] ), filt_coeff[6] ); // Qx + Q15 - Q15 -> Qx
+ move32();
+ Vl[1] = Madd_32_16( mem[7], L_sub( Vl[0], mem[8] ), filt_coeff[7] ); // Qx + Q15 - Q15 -> Qx
+ move32();
+ mem[9] = Madd_32_16( mem[8], L_sub( Vl[1], mem[9] ), filt_coeff[8] ); // Qx + Q15 - Q15 -> Qx
+ move32();
+#else /* OPT_STEREO_32KBPS_V1 */
+ Vl[0] = L_add( mem[0], Mpy_32_16_1( L_sub( input[i], mem[7] ), filt_coeff[6] ) ); // Qx + Q15 - Q15 -> Qx
+ move32();
+ Vl[1] = L_add( mem[7], Mpy_32_16_1( L_sub( Vl[0], mem[8] ), filt_coeff[7] ) ); // Qx + Q15 - Q15 -> Qx
+ move32();
+ mem[9] = L_add( mem[8], Mpy_32_16_1( L_sub( Vl[1], mem[9] ), filt_coeff[8] ) ); // Qx + Q15 - Q15 -> Qx
+ move32();
+#endif /* OPT_STEREO_32KBPS_V1 */
+
+ mem[0] = input[i]; // Qx
+ move32();
+ mem[7] = Vl[0]; // Qx
+ move32();
+ mem[8] = Vl[1]; // Qx
+ move32();
+ *out1++ = mem[9]; // Qx
+ move32();
+ }
+
+ loop_len = shr( i_mult( len, 3 ), 1 );
+
+ /*decimate by 2 and LPF*/
+ FOR( i = 0; i < loop_len; i++ )
+ {
+ mem_temp = out1_buff[2 * i];
+ move32();
+#ifdef OPT_STEREO_32KBPS_V1
+ out[i] = Madd_32_16( Mpy_32_16_1( L_add( mem_temp, mem[10] ), 1550 ), L_add( mem[11], mem[14] ), -4965 ); // Qx + Q15 - Q15 -> Qx
+ // 0.0473147f in Q15 -> 1550, -0.151521f in Q15 -> -4965
+ out[i] = Madd_32_16( out[i], L_add( mem[12], mem[13] ), 20125 );
+ // 0.614152f in Q15 -> 20125
+#else /* OPT_STEREO_32KBPS_V1 */
+ out[i] = L_add( Mpy_32_16_1( L_add( mem_temp, mem[10] ), 1550 ), Mpy_32_16_1( L_add( mem[11], mem[14] ), -4965 ) ); // Qx + Q15 - Q15 -> Qx
+ // 0.0473147f in Q15 -> 1550, -0.151521f in Q15 -> -4965
+ out[i] = L_add( out[i], Mpy_32_16_1( L_add( mem[12], mem[13] ), 20125 ) );
+ // 0.614152f in Q15 -> 20125
+#endif /* OPT_STEREO_32KBPS_V1 */
+ mem[10] = mem[11]; // Qx
+ move32();
+ mem[11] = mem[12]; // Qx
+ move32();
+ mem[12] = mem[13]; // Qx
+ move32();
+ mem[13] = mem[14]; // Qx
+ move32();
+ mem[14] = mem_temp; // Qx
+ move32();
+ }
+
+ return;
+}
+
/*-------------------------------------------------------------------*
* interpolate_3_over_1_allpass_fx()
@@ -1445,6 +1789,92 @@ void interpolate_3_over_1_allpass_fx(
return;
}
+/* IVAS 32-bit variant */
+void interpolate_3_over_1_allpass_fx32(
+ const Word32 *input, /* i : input signal Qx */
+ const Word16 len, /* i : number of input samples */
+ Word32 *out, /* o : output signal */
+ Word32 *mem /* i/o: memory */
+)
+{
+ Word16 i, tmp16;
+ Word32 Vu[2], Vm[2], Vl[2]; /* Outputs of three cascaded allpass stages (upper, middle, and lower) */
+ Word32 *out1;
+ Word32 mem_temp;
+ const Word16 *filt_coeff = allpass_poles_3_ov_2; // Qx
+
+ out1 = &out[0];
+
+ FOR( i = 0; i < len; i++ )
+ {
+ /* Upper branch */
+ Vu[0] = L_add_sat( mem[0], Mpy_32_16_1( L_sub( input[i], mem[1] ), filt_coeff[0] ) ); // Qx
+ move32();
+ Vu[1] = L_add_sat( mem[1], Mpy_32_16_1( L_sub( Vu[0], mem[2] ), filt_coeff[1] ) ); // Qx
+ move32();
+ mem[3] = L_add_sat( mem[2], Mpy_32_16_1( L_sub( Vu[1], mem[3] ), filt_coeff[2] ) ); // Qx
+ move32();
+
+ mem[1] = Vu[0]; // Qx
+ move32();
+ mem[2] = Vu[1]; // Qx
+ move32();
+ *out1++ = mem[3]; // Qx
+ move32();
+
+ /* Middle branch */
+ Vm[0] = L_add_sat( mem[0], Mpy_32_16_1( L_sub( input[i], mem[4] ), filt_coeff[3] ) ); // Qx
+ move32();
+ Vm[1] = L_add_sat( mem[4], Mpy_32_16_1( L_sub( Vm[0], mem[5] ), filt_coeff[4] ) ); // Qx
+ move32();
+ mem[6] = L_add_sat( mem[5], Mpy_32_16_1( L_sub( Vm[1], mem[6] ), filt_coeff[5] ) ); // Qx
+ move32();
+
+ mem[4] = Vm[0]; // Qx
+ move32();
+ mem[5] = Vm[1]; // Qx
+ move32();
+ *out1++ = mem[6]; // Qx
+ move32();
+
+ /* Lower branch */
+ Vl[0] = L_add_sat( mem[0], Mpy_32_16_1( L_sub( input[i], mem[7] ), filt_coeff[6] ) ); // Qx
+ move32();
+ Vl[1] = L_add_sat( mem[7], Mpy_32_16_1( L_sub( Vl[0], mem[8] ), filt_coeff[7] ) ); // Qx
+ move32();
+ mem[9] = L_add_sat( mem[8], Mpy_32_16_1( L_sub( Vl[1], mem[9] ), filt_coeff[8] ) ); // Qx
+ move32();
+
+ mem[0] = input[i]; // Qx
+ move32();
+ mem[7] = Vl[0]; // Qx
+ move32();
+ mem[8] = Vl[1]; // Qx
+ move32();
+ *out1++ = mem[9]; // Qx
+ move32();
+ }
+
+ /*LPF*/
+ tmp16 = imult1616( len, 3 );
+ FOR( i = 0; i < tmp16; i++ )
+ {
+ mem_temp = out[i]; // Qx
+ move32();
+ out[i] = L_sub_sat( Mpy_32_16_1( L_add_sat( mem[12], mem[11] ), 18768 ), Mpy_32_16_1( L_add_sat( mem_temp, mem[10] ), 2424 ) ); // Qx
+ // 0.572769 in Q15 -> 18768, 0.074005 in Q15 -> 2424
+ move32();
+ mem[10] = mem[11]; // Qx
+ move32();
+ mem[11] = mem[12]; // Qx
+ move32();
+ mem[12] = mem_temp; // Qx
+ move32();
+ }
+
+ return;
+}
+
/*-------------------------------------------------------------------*
* decimate_3_over_2_allpass_fx()
diff --git a/lib_com/mslvq_com.c b/lib_com/mslvq_com.c
deleted file mode 100644
index 12234a4c055664712312c284ce500a2a019c119a..0000000000000000000000000000000000000000
--- a/lib_com/mslvq_com.c
+++ /dev/null
@@ -1,208 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository. All Rights Reserved.
-
- This software is protected by copyright law and by international treaties.
- The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository retain full ownership rights in their respective contributions in
- the software. This notice grants no license of any kind, including but not limited to patent
- license, nor is any license granted by implication, estoppel or otherwise.
-
- Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
- contributions.
-
- This software is provided "AS IS", without any express or implied warranties. The software is in the
- development stage. It is intended exclusively for experts who have experience with such software and
- solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
- and fitness for a particular purpose are hereby disclaimed and excluded.
-
- Any dispute, controversy or claim arising under or in relation to providing this software shall be
- submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
- accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
- the United Nations Convention on Contracts on the International Sales of Goods.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include "cnst.h"
-#include "rom_com.h"
-#include "prot_fx.h"
-#include "wmc_auto.h"
-#include "ivas_prot_fx.h"
-
-/*-----------------------------------------------------------------*
- * Local function prototypes
- *-----------------------------------------------------------------*/
-
-static void make_offset_scale(
- const UWord32 tab_no_cv[],
- const Word8 *no_ld,
- const Word16 no_scl,
- UWord32 *offset_scale )
-{
- Word16 i;
-
- offset_scale[0] = 1;
- move32();
- FOR( i = 1; i <= no_scl; i++ )
- {
- offset_scale[i] = UL_addNsD( offset_scale[i - 1], tab_no_cv[(Word16) no_ld[i - 1]] );
- move32();
- }
-
- return;
-}
-
-/*-----------------------------------------------------------------*
- * create_offset()
- *
- *
- *-----------------------------------------------------------------*/
-
-void create_offset(
- UWord32 *offset_scale1,
- UWord32 *offset_scale2,
- const Word16 mode,
- const Word16 prediction_flag )
-{
- Word16 tmp, tmp1;
-
- if ( prediction_flag == 0 )
- {
- /* safety_net */
- tmp = no_lead_idx[mode][0];
- if ( ( tmp <= LIMIT_LEADER ) && ( tmp < no_lead_idx[mode][1] - 2 ) )
- {
- tmp += DELTA_LEADER;
- }
- make_offset_scale( table_no_cv, leaders_short[tmp], MAX_NO_SCALES, offset_scale1 );
- make_offset_scale( table_no_cv, leaders_short[no_lead_idx[mode][1]], MAX_NO_SCALES, offset_scale2 );
- }
- else
- {
- tmp = no_lead_p_idx[mode][0];
- tmp1 = no_lead_p_idx[mode][1];
- if ( ( tmp <= LIMIT_LEADER ) && ( tmp < tmp1 - 2 ) )
- {
- tmp += DELTA_LEADER;
- }
-
- if ( ( tmp == LIMIT_LEADER ) && ( tmp1 == 0 ) )
- {
- tmp += DELTA_LEADER;
- tmp1 = DELTA_LEADER;
- }
-
- make_offset_scale( table_no_cv, leaders_short[tmp], MAX_NO_SCALES, offset_scale1 );
- make_offset_scale( table_no_cv, leaders_short[tmp1], MAX_NO_SCALES, offset_scale2 );
- }
-
- return;
-}
-
-/*-----------------------------------------------------------------*
- * sort_desc_ind()
- *
- * sorts in descending order and computes indices in the sorted vector
- *-----------------------------------------------------------------*/
-void sort_desc_ind_16_fx(
- Word16 *s, /* i/o: vector to be sorted Qx*/
- const Word16 len, /* i : vector length */
- Word16 *ind /* o : array of indices */
-)
-{
- Word16 i, k, sorted, a;
- Word16 t;
-
- FOR( i = 0; i < len; i++ )
- {
- ind[i] = i;
- move16();
- }
- sorted = 0;
- move16();
- FOR( k = len - 1; k && !sorted; k-- )
- {
- sorted = 1;
- move16();
- FOR( i = 0; i < k; i++ )
- {
- IF( LT_16( s[i], s[i + 1] ) )
- {
- sorted = 0;
- move16();
- t = s[i];
- move16();
- s[i] = s[i + 1];
- move16();
- s[i + 1] = t;
- move16();
- a = ind[i];
- move16();
- ind[i] = ind[i + 1];
- move16();
- ind[i + 1] = a;
- move16();
- }
- }
- }
-
- return;
-}
-
-void sort_desc_ind_32_fx(
- Word32 *s, /* i/o: vector to be sorted Qx*/
- const Word16 len, /* i : vector length */
- Word16 *ind /* o : array of indices */
-)
-{
- Word16 i, k, sorted, a;
- Word32 t;
-
- FOR( i = 0; i < len; i++ )
- {
- ind[i] = i;
- move16();
- }
- sorted = 0;
- move16();
- FOR( k = len - 1; k && !sorted; k-- )
- {
- sorted = 1;
- move16();
- FOR( i = 0; i < k; i++ )
- {
- IF( LT_32( s[i], s[i + 1] ) )
- {
- sorted = 0;
- move16();
- t = s[i];
- move16();
- s[i] = s[i + 1];
- move16();
- s[i + 1] = t;
- move16();
- a = ind[i];
- move16();
- ind[i] = ind[i + 1];
- move16();
- ind[i + 1] = a;
- move16();
- }
- }
- }
-
- return;
-}
diff --git a/lib_com/mslvq_com_fx.c b/lib_com/mslvq_com_fx.c
index 7fcf36bfcfb81b1250315991a080644d2b49a6a0..8d5e8adf2c394a7799a75085ccaff97cf9b698e9 100644
--- a/lib_com/mslvq_com_fx.c
+++ b/lib_com/mslvq_com_fx.c
@@ -30,11 +30,16 @@
*******************************************************************************************************/
+#include
#include "options.h"
+#include "cnst.h"
#include "prot_fx.h"
#include "ivas_cnst.h"
#include "stl.h"
#include "rom_com.h"
+#include "ivas_prot_fx.h"
+#include "wmc_auto.h"
+
/*-----------------------------------------------------------------*
* Local functions
@@ -260,6 +265,25 @@ static void make_offset_scale_fx(
return;
}
+static void make_offset_scale(
+ const UWord32 tab_no_cv[],
+ const Word8 *no_ld,
+ const Word16 no_scl,
+ UWord32 *offset_scale )
+{
+ Word16 i;
+
+ offset_scale[0] = 1;
+ move32();
+ FOR( i = 1; i <= no_scl; i++ )
+ {
+ offset_scale[i] = UL_addNsD( offset_scale[i - 1], tab_no_cv[(Word16) no_ld[i - 1]] );
+ move32();
+ }
+
+ return;
+}
+
void init_offset_fx(
Word32 offset_scale1[][MAX_NO_SCALES + 1], /* o: lattice truncation index offset for the first LSF subvector - safety net structures*/
Word32 offset_scale2[][MAX_NO_SCALES + 1], /* o: lattice truncation index offset for the second LSF subvector - safety net structures*/
@@ -1310,6 +1334,104 @@ static void put_value_fx(
return;
}
+/*-----------------------------------------------------------------*
+ * create_offset()
+ *
+ *
+ *-----------------------------------------------------------------*/
+
+void create_offset(
+ UWord32 *offset_scale1,
+ UWord32 *offset_scale2,
+ const Word16 mode,
+ const Word16 prediction_flag )
+{
+ Word16 tmp, tmp1;
+
+ if ( prediction_flag == 0 )
+ {
+ /* safety_net */
+ tmp = no_lead_idx[mode][0];
+ if ( ( tmp <= LIMIT_LEADER ) && ( tmp < no_lead_idx[mode][1] - 2 ) )
+ {
+ tmp += DELTA_LEADER;
+ }
+ make_offset_scale( table_no_cv, leaders_short[tmp], MAX_NO_SCALES, offset_scale1 );
+ make_offset_scale( table_no_cv, leaders_short[no_lead_idx[mode][1]], MAX_NO_SCALES, offset_scale2 );
+ }
+ else
+ {
+ tmp = no_lead_p_idx[mode][0];
+ tmp1 = no_lead_p_idx[mode][1];
+ if ( ( tmp <= LIMIT_LEADER ) && ( tmp < tmp1 - 2 ) )
+ {
+ tmp += DELTA_LEADER;
+ }
+
+ if ( ( tmp == LIMIT_LEADER ) && ( tmp1 == 0 ) )
+ {
+ tmp += DELTA_LEADER;
+ tmp1 = DELTA_LEADER;
+ }
+
+ make_offset_scale( table_no_cv, leaders_short[tmp], MAX_NO_SCALES, offset_scale1 );
+ make_offset_scale( table_no_cv, leaders_short[tmp1], MAX_NO_SCALES, offset_scale2 );
+ }
+
+ return;
+}
+
+/*-----------------------------------------------------------------*
+ * sort_desc_ind()
+ *
+ * sorts in descending order and computes indices in the sorted vector
+ *-----------------------------------------------------------------*/
+
+void sort_desc_ind_32_fx(
+ Word32 *s, /* i/o: vector to be sorted Qx*/
+ const Word16 len, /* i : vector length */
+ Word16 *ind /* o : array of indices */
+)
+{
+ Word16 i, k, sorted, a;
+ Word32 t;
+
+ FOR( i = 0; i < len; i++ )
+ {
+ ind[i] = i;
+ move16();
+ }
+ sorted = 0;
+ move16();
+ FOR( k = len - 1; k && !sorted; k-- )
+ {
+ sorted = 1;
+ move16();
+ FOR( i = 0; i < k; i++ )
+ {
+ IF( LT_32( s[i], s[i + 1] ) )
+ {
+ sorted = 0;
+ move16();
+ t = s[i];
+ move16();
+ s[i] = s[i + 1];
+ move16();
+ s[i + 1] = t;
+ move16();
+ a = ind[i];
+ move16();
+ ind[i] = ind[i + 1];
+ move16();
+ ind[i + 1] = a;
+ move16();
+ }
+ }
+ }
+
+ return;
+}
+
void deindex_lvq_SHB_fx(
UWord32 index,
Word16 *out,
diff --git a/lib_com/options.h b/lib_com/options.h
index 673fcae4d5532ae2fde5eba705c7450ce62f38eb..3196495e7b33c5a37566fa82ac031b4c46d0d346 100644
--- a/lib_com/options.h
+++ b/lib_com/options.h
@@ -43,22 +43,24 @@
/*#define DEBUGGING*/ /* Allows debugging message to be printed out during runtime */
#ifdef DEBUGGING
+/*#define DBG_BITSTREAM_ANALYSIS*/ /* Write bitstream with annotations to a text file */
#define DEBUG_MODE_INFO /* Define to output most important parameters to the subdirectory "res/" */
#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 DEBUG_FORCE_DIR*/ /* Force modes/parameters by reading from external binary files */
/*#define DBG_WAV_WRITER*/ /* Enable dbgwrite_wav() function for generating ".wav" files */
#define SUPPORT_FORCE_TCX10_TCX20 /* VA: Enable -force tcx10|tcx20 command-line option */
+/*#define DEBUG_MODE_JBM */ /* define to output JBM relevant parameters */
#endif
#define SUPPORT_JBM_TRACEFILE /* Support for JBM tracefile, which is needed for 3GPP objective/subjective testing, but not relevant for real-world implementations */
-/*#define WMOPS*/ /* Activate complexity and memory counters */
+/*#define WMOPS*/ /* Activate complexity and memory counters */
#ifdef WMOPS
-/*#define WMOPS_PER_FRAME*/ /* Output per-frame complexity (writes one float value per frame to the file "wmops_analysis") */
-/*#define WMOPS_DETAIL*/ /* Output detailed complexity printout for every function. Increases runtime overhead */
-/*#define WMOPS_WC_FRAME_ANALYSIS*/ /* Output detailed complexity analysis for the worst-case frame */
-/*#define MEM_COUNT_DETAILS*/ /* Output detailed memory analysis for the worst-case frame (writes to the file "mem_analysis.csv") */
+#define WMOPS_PER_FRAME /* Output per-frame complexity (writes one float value per frame to the file "wmops_analysis") */
+#define WMOPS_DETAIL /* Output detailed complexity printout for every function. Increases runtime overhead */
+#define WMOPS_WC_FRAME_ANALYSIS /* Output detailed complexity analysis for the worst-case frame */
+/*define MEM_COUNT_DETAILS*/ /* Output detailed memory analysis for the worst-case frame (writes to the file "mem_analysis.csv") */
#endif
/*#define DISABLE_LIMITER*/
@@ -68,6 +70,7 @@
#ifndef BASOP_NOGLOB_DEV_USE_GLOBALS
#define BASOP_NOGLOB_DECLARE_LOCAL
#endif
+#define FIX_732_MS_PERIODOG_FLOOR /* Eri: Issue-732: Dynamic range of msPeriodog leads to minimum value 1e-5 being truncated to zero. This uses the smallest non-zero value instead. */
#define FIX_867_CLDFB_NRG_SCALE
@@ -76,8 +79,18 @@
#define FIX_1379_MASA_ANGLE_ROUND
/* Note: each compile switch (FIX_1101_...) is independent from the other ones */
+#define OPT_MCT_ENC_V1_NBE
+#define OPT_SBA_REND_V1_BE
+#define OPT_HEAD_ROT_REND_V1_BE
+#define OPT_SBA_DEC_V2_BE
+#define OPT_SBA_ENC_V2_BE
+#define OPT_SBA_ENC_V1_BE
+#define OPT_BIN_RENDERER_V1
+#define OPT_BIN_RENDERER_V2
#define OPT_STEREO_32KBPS_V1 /* Optimization made in stereo decoding path for 32kbps decoding */
#define OPT_AVOID_STATE_BUF_RESCALE /* Optimization made to avoid rescale of synth state buffer */
+#define OPT_SBA_DEC_PATH /* Optimization made in SBA decoding path */
+#define OPT_IVAS_FILTER_ROM /* Optimization made in IVAS filter table */
#define FIX_1310_SPEEDUP_ivas_dirac_dec_get_response_fx /*FhG: WMOPS tuning, nonbe*/
#define FIX_1310_SPEEDUP_ivas_dirac_dec_output_synthesis_process_slot /*FhG: WMOPS tuning, nonbe*/
/* Both following 2 macros (IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST*) are independent from each other, they refer to different code blocks */
@@ -88,17 +101,27 @@
//#define HARM_SCE_INIT
#define DIV32_OPT_NEWTON /* FhG: faster 32 by 32 bit division */
#define MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE /* FhG: reduce WMOPS of Cy calculation in ivas_param_mc_param_est_enc_fx() by using 64 Bit addition. Obsoletes IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_NONBE. */
+#define MERGE_REQUEST_1472_SPEEDUP_ivas_mc_param_enc_fx_NONBE /* FhG: reduce WMOPS of dmx calculation in ivas_param_mc_param_est_enc_fx() by using 64 Bit addition. Requires MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE. */
+#define MERGE_REQUEST_1564_SPEEDUP_ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx_NONBE /* FhG: reduce WMOPS by inlining the matrix multiplications for the smoothing operation. */
#define FIX_1439_SPEEDUP_Copy_Scale_sig_16_32_no_sat /*FhG: reduces WMOPS - bit-exact*/
#define FIX_1439_SPEEDUP_stereo_icBWE_dec_fx /*FhG: reduces WMOPS - bit-exact*/
#define FIX_1439_SPEEDUP_ivas_swb_tbe_dec_fx /*FhG: reduces WMOPS - bit-exact*/
-#define FIX_1439_SPEEDUP_synthesise_fb_high_band_fx /*FhG: reduces WMOPS - bit-exact*/
#define FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic /*FhG: reduces maintenance complexity & reduces WMOPS & prepares STAGE2 patch*/
#define FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2 /*FhG: reduces WMOPS*/
#define FIX_1481_HARDCODE_DIV /* FhG: hardcode division results in stereo_dmx_evs_init_encoder_fx() */
#define VEC_ARITH_OPT_v1
#define FIX_1486_IND_SHB_RES /* VA: Fix for issue 1486: align the usage of IND_SHB_RES_GS indices with float code */
+#define FIX_1511_POC_RENORM /* NTT: Fix for issue 1511: Renorm for POC. */
#define TEST_HR
#define REMOVE_EVS_DUPLICATES /* remove core-coder duplicated functions, ACELP low-band decoder */
+#define FIX_1713_EXP /* VA: proposed correction to exp in ic-BWE*/
+#define FIX_USAN_BASOP_UTIL_DIVIDE3232 /* Eri: Fix USAN error in BASOP_Util_Divide3232_Scale_newton by adding explicit type cast for -1 in hex */
+
+#define FIX_1733_CLDFB_BUG
+#define FIX_1740_MISING_POP_WMOPS /* VA: fix issue 1740: missing pop_wmops() */
+
+#define NONBE_FIX_864_JBM_RENDER_FRAMESIZE /* FhG: issue #864: fix different behaviour of JBM TSM with different render frame sizes */
+
#endif
diff --git a/lib_com/phase_dispersion_fx.c b/lib_com/phase_dispersion_fx.c
index 723d173bcd2bda0a3699a95b67f46997665660f5..3103723becabab50ac704ec5634594e73531e5b3 100644
--- a/lib_com/phase_dispersion_fx.c
+++ b/lib_com/phase_dispersion_fx.c
@@ -114,12 +114,12 @@ void phase_dispersion(
scale2 = getScaleFactor32( x32, L_subfr );
FOR( i = 0; i < L_subfr / 2 - 1; i++ )
{
- code[i] = round_fx_sat( L_shl_sat( x32[2 * i + 0], scale2 ) );
+ code[i] = round_fx_sat( L_shl_sat( x32[2 * i], scale2 ) );
code[L_subfr - 1 - i] = round_fx_sat( L_shl_sat( x32[2 * i + 3], scale2 ) );
}
- code[L_subfr / 2 - 1] = round_fx( L_shl( x32[L_subfr - 2], scale2 ) );
- code[L_subfr / 2] = round_fx( L_shl( x32[1], scale2 ) );
+ code[L_subfr / 2 - 1] = round_fx_sat( L_shl_sat( x32[L_subfr - 2], scale2 ) );
+ code[L_subfr / 2] = round_fx_sat( L_shl_sat( x32[1], scale2 ) );
j = sub( j, scale2 );
diff --git a/lib_com/pred_lt4_fx.c b/lib_com/pred_lt4_fx.c
index 4f8dd871289b8fc78c85678a24cb737da7378c84..465138bde1fd083c8ed2a0beade5da3fa290ea2f 100644
--- a/lib_com/pred_lt4_fx.c
+++ b/lib_com/pred_lt4_fx.c
@@ -20,6 +20,63 @@
* (adaptive codebook excitation) *
*-------------------------------------------------------------------*/
+void pred_lt4_ivas_fx(
+ const Word16 excI[], /* in : excitation buffer Q_exc*/
+ Word16 excO[], /* out: excitation buffer Q_exc*/
+ const Word16 T0, /* input : integer pitch lag Q0*/
+ Word16 frac, /* input : fraction of lag Q0*/
+ const Word16 L_subfr, /* input : subframe size Q0*/
+ const Word32 *win, /* i : interpolation window Q31*/
+ const Word16 nb_coef, /* i : nb of filter coef Q0*/
+ const Word16 up_sample /* i : up_sample Q0*/
+)
+{
+ Word16 i, j;
+ Word32 s;
+ const Word16 *x0, *x1, *x2;
+ const Word32 *c1, *c2;
+#ifdef BASOP_NOGLOB_DECLARE_LOCAL
+ Flag Overflow = 0;
+ move32();
+#endif
+ x0 = &excI[-T0];
+
+ frac = negate( frac );
+
+ IF( frac < 0 )
+ {
+ frac = add( frac, up_sample ); /* Q0 */
+ x0--;
+ }
+
+ FOR( j = 0; j < L_subfr; j++ )
+ {
+ x1 = x0++; /* Q_exc */
+ x2 = x1 + 1; /* Q_exc */
+ c1 = ( &win[frac] ); /* Q14 */
+ c2 = ( &win[up_sample - frac] ); /* Q14 */
+
+ {
+ Word64 s64 = 0;
+ move64();
+ FOR( i = 0; i < nb_coef; i++ )
+ {
+ /*s += (*x1--) * (*c1) + (*x2++) * (*c2);*/
+ s64 = W_mac_32_32( s64, L_deposit_l( *x1-- ), ( *c1 ) ); /* Q_exc + Q32 */
+ s64 = W_mac_32_32( s64, L_deposit_l( *x2++ ), ( *c2 ) ); /* Q_exc + Q32 */
+
+ c1 += up_sample;
+ c2 += up_sample;
+ }
+ s = W_sat_l( W_shr( s64, 16 ) ); /* Q_exc + Q16 */
+ }
+
+ excO[j] = round_fx_o( s, &Overflow ); /* Q_exc */
+ move16();
+ }
+ return;
+}
+
void pred_lt4(
const Word16 excI[], /* in : excitation buffer Q_exc*/
Word16 excO[], /* out: excitation buffer Q_exc*/
diff --git a/lib_com/preemph.c b/lib_com/preemph.c
deleted file mode 100644
index 9ebc0f72a81c39542312ff9e6bbd3d76b5a49197..0000000000000000000000000000000000000000
--- a/lib_com/preemph.c
+++ /dev/null
@@ -1,72 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository. All Rights Reserved.
-
- This software is protected by copyright law and by international treaties.
- The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository retain full ownership rights in their respective contributions in
- the software. This notice grants no license of any kind, including but not limited to patent
- license, nor is any license granted by implication, estoppel or otherwise.
-
- Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
- contributions.
-
- This software is provided "AS IS", without any express or implied warranties. The software is in the
- development stage. It is intended exclusively for experts who have experience with such software and
- solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
- and fitness for a particular purpose are hereby disclaimed and excluded.
-
- Any dispute, controversy or claim arising under or in relation to providing this software shall be
- submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
- accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
- the United Nations Convention on Contracts on the International Sales of Goods.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include "prot_fx.h"
-#include "wmc_auto.h"
-
-/*-------------------------------------------------------------*
- * preemph_ivas_fx()
- *
- * Preemphasis: filtering through 1 - mu z^-1
- *-------------------------------------------------------------*/
-
-void preemph_ivas_fx(
- Word32 *signal, /* i/o: signal Qx*/
- const Word16 mu, /* i : preemphasis factor Q15*/
- const Word16 L, /* i : vector size Q0*/
- Word32 *mem /* i/o: memory (x[-1]) Qx*/
-)
-{
- Word16 i;
- Word32 temp;
-
- temp = signal[L - 1]; /* Qx */
- move32();
- FOR( i = L - 1; i > 0; i-- )
- {
- signal[i] = L_sub( signal[i], Mpy_32_16_1( signal[i - 1], mu ) ); /* Qx */
- move32();
- }
-
- signal[0] = L_sub( signal[0], Mpy_32_16_1( *mem, mu ) ); /* Qx */
- move32();
- *mem = temp; /* Qx */
- move32();
-
- return;
-}
diff --git a/lib_com/preemph_fx.c b/lib_com/preemph_fx.c
index 0790f6c3f2c8fdda954347962a335a029e7057f1..b7886cb65324d5bfb77d84fe104b24ff7abb7e33 100644
--- a/lib_com/preemph_fx.c
+++ b/lib_com/preemph_fx.c
@@ -1,14 +1,18 @@
/*====================================================================================
EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
====================================================================================*/
+
#include
#include "options.h" /* Compilation switches */
#include "prot_fx.h"
+#include "wmc_auto.h"
+
/*-------------------------------------------------------------*
* preemph_copy_fx()
*
* Preemphasis: filtering through 1 - mu z^-1
*-------------------------------------------------------------*/
+
void preemph_copy_fx(
const Word16 x[], /* i : input signal Qx */
Word16 y[], /* o : output signal Qx */
@@ -63,6 +67,38 @@ void preemph_copy_32fx(
move16();
}
+/*-------------------------------------------------------------*
+ * preemph_ivas_fx()
+ *
+ * Preemphasis: filtering through 1 - mu z^-1
+ *-------------------------------------------------------------*/
+
+void preemph_ivas_fx(
+ Word32 *signal, /* i/o: signal Qx*/
+ const Word16 mu, /* i : preemphasis factor Q15*/
+ const Word16 L, /* i : vector size Q0*/
+ Word32 *mem /* i/o: memory (x[-1]) Qx*/
+)
+{
+ Word16 i;
+ Word32 temp;
+
+ temp = signal[L - 1]; /* Qx */
+ move32();
+ FOR( i = L - 1; i > 0; i-- )
+ {
+ signal[i] = L_sub( signal[i], Mpy_32_16_1( signal[i - 1], mu ) ); /* Qx */
+ move32();
+ }
+
+ signal[0] = L_sub( signal[0], Mpy_32_16_1( *mem, mu ) ); /* Qx */
+ move32();
+ *mem = temp; /* Qx */
+ move32();
+
+ return;
+}
+
/*
* E_UTIL_f_preemph2
*
diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h
index 86b5ec0b70dc62f4645763ea9e9f8cae0ff46b7b..d533c5612793b60e37b237a1d5acf379829e4271 100644
--- a/lib_com/prot_fx.h
+++ b/lib_com/prot_fx.h
@@ -72,9 +72,6 @@
#define max( x, y ) ( ( x ) > ( y ) ? ( x ) : ( y ) )
#endif
-#define log_base_2( x ) ( (double) log( (double) ( x ) ) * 1.4426950408889634074f )
-#define round_f( x ) ( ( ( x ) > 0 ) ? (int32_t) ( ( x ) + 0.5f ) : ( -(int32_t) ( ( -x ) + 0.5f ) ) )
-
#ifndef ABSVAL
#define ABSVAL( a ) ( ( a ) >= 0 ? ( a ) : ( -( a ) ) )
#endif
@@ -916,11 +913,7 @@ void msvq_dec(
const Word16 N, /* i : Vector dimension */
const Word16 maxN, /* i : Codebook dimension */
const Word16 Idx[], /* i : Indices */
-#ifdef IVAS_MSVQ
- const int16_t applyIDCT_flag, /* i : applyIDCT flag */
- const float *invTrfMatrix, /* i : matrix for IDCT synthesis */
-#endif
- Word16 *uq /* o : quantized vector (3Q12) */
+ Word16 *uq /* o : quantized vector (3Q12) */
);
Word16 tcxlpc_get_cdk(
@@ -1580,19 +1573,19 @@ Word16 gsc_gainQ_fx(
);
Word16 gsc_gainQ_ivas_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const int16_t element_mode, /* i : element mode */
- const int16_t idchan, /* i : channel ID */
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ const Word16 element_mode, /* i : element mode */
+ const Word16 idchan, /* i : channel ID */
const Word16 y_gain4[],
/* i : Energy per band */ // Q12
Word16 y_gainQ[],
/* o : quantized energy per band */ // Q12
- const int32_t core_brate, /* i : Core rate */
- const int16_t coder_type, /* i : coding type */
- const int16_t bwidth, /* i : input signal bandwidth */
- const int16_t L_frame, /* i : frame length */
- const int16_t tdm_LRTD_flag, /* i : LRTD stereo mode flag */
- const int32_t core_brate_inp /* i : true core bitrate */
+ const Word32 core_brate, /* i : Core rate */
+ const Word16 coder_type, /* i : coding type */
+ const Word16 bwidth, /* i : input signal bandwidth */
+ const Word16 L_frame, /* i : frame length */
+ const Word16 tdm_LRTD_flag, /* i : LRTD stereo mode flag */
+ const Word32 core_brate_inp /* i : true core bitrate */
);
// frame_ener.c
@@ -1783,15 +1776,9 @@ void Ener_per_band_comp_ivas_fx(
const Word16 Q_exc, /* i : frame length */
const Word16 Mband, /* i : Max band */
const Word16 Eflag, /* i : flag of highest band */
- const int16_t L_frame /* i : frame length */
+ const Word16 L_frame /* i : frame length */
);
-void Ener_per_band_comp_ivas_fx_2(
- const Word16 exc_diff_fx[], /* i : target signal Q_exc_diff */
- Word16 y_gain4_fx[], /* o : Energy per band to quantize Q12 */
- const Word16 Q_exc, /* i : frame length */
- const Word16 Mband, /* i : Max band */
- const Word16 Eflag, /* i : flag of highest band */
- const Word16 L_frame );
+
void Comp_and_apply_gain_fx(
Word16 exc_diffQ[], /* i/o: Quantized excitation */
Word16 Ener_per_bd_iQ[], /* i : Target ener per band Q13 */
@@ -1851,17 +1838,6 @@ void wtda_fx(
const Word16 L /* i : length */
);
-void wtda_ivas_fx(
- Word16 *new_audio, /* i : input audio Q0 */
- Word16 *Q, /* i/o : Q of input/Output Audio */
- Word16 *wtda_audio, /* o : windowed audio Qout */
- Word16 *old_wtda, /* i/o: windowed audio from previous frame Qout */
- Word16 *Qold_wtda,
- 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 */
-);
-
void wtda_ext_fx(
const Word16 *new_audio, /* i : input audio (Q_in) */
Word16 *wtda_audio, /* o : windowed audio (Q_in) */
@@ -2637,7 +2613,7 @@ void Interpolate_allpass_steep_fx(
void Interpolate_allpass_steep_fx32(
const Word32 *in_fx, /* i : input array of size N */
Word32 *mem_fx, /* i/o: memory */
- const int16_t N, /* i : number of input samples */
+ const Word16 N, /* i : number of input samples */
Word32 *out_fx /* o : output array of size 2*N */
);
@@ -2651,7 +2627,7 @@ void interpolate_3_over_2_allpass_fx(
void interpolate_3_over_2_allpass_fx32(
const Word32 *input, /* i : input signal Qx */
- const int16_t len, /* i : number of input samples */
+ const Word16 len, /* i : number of input samples */
Word32 *out, /* o : output signal */
Word32 *mem /* i/o: memory */
);
@@ -2935,16 +2911,16 @@ void tbe_celp_exc(
);
void tbe_celp_exc_ivas(
- const int16_t element_mode, /* i : element mode */
- const int16_t idchan, /* i : channel ID */
- const Word16 L_frame_fx, /* i : Frame lenght */
- const int16_t L_subfr, /* i : subframe length */
- const Word16 i_subfr_fx, /* i : sub frame */
- const Word16 T0_fx, /* i : Integer pitch */
- const Word16 T0_frac_fx, /* i : Fractional part of the pitch */
- Word16 *error_fx, /* i/o: Error */
- Word16 *bwe_exc_fx, /* i/o: bandwitdh extension signal */
- const int16_t tdm_LRTD_flag /* i : LRTD stereo mode flag */
+ const Word16 element_mode, /* i : element mode */
+ const Word16 idchan, /* i : channel ID */
+ const Word16 L_frame_fx, /* i : Frame lenght */
+ const Word16 L_subfr, /* i : subframe length */
+ const Word16 i_subfr_fx, /* i : sub frame */
+ const Word16 T0_fx, /* i : Integer pitch */
+ const Word16 T0_frac_fx, /* i : Fractional part of the pitch */
+ Word16 *error_fx, /* i/o: Error */
+ Word16 *bwe_exc_fx, /* i/o: bandwitdh extension signal */
+ const Word16 tdm_LRTD_flag /* i : LRTD stereo mode flag */
);
void flip_and_downmix_generic_fx(
@@ -3061,22 +3037,7 @@ void GenShapedSHBExcitation_fx(
Word16 n_mem2, /* i : n_mem2 scale factor to adjust 24.4/32kbps memories */
Word16 prev_Q_bwe_syn, /* i : st_fx->prev_Q_bwe_syn */
const Word32 bitrate,
- const Word16 prev_bfi
-#ifdef ADD_IVAS_TBE_CODE
- , /* i : previous frame was concealed */
- const Word16 element_mode, /* i : element mode */
- const Word16 flag_ACELP16k, /* i : ACELP@16kHz flag */
- Word16 *nlExc16k, /* i/o: NL exc for IC-BWE */
- Word16 *mixExc16k, /* i/o: exc spreading for IC-BWE */
- const Word32 extl_brate, /* i : extension layer bitarte */
- const Word16 MSFlag, /* i : Multi Source flag */
- Word16 EnvSHBres_4k[], /* i/o: TD envelope of the SHB residual signal */
- Word16 *prev_pow_exc16kWhtnd, /* i/o: power of the LB excitation signal in the previous frame */
- Word16 *prev_mix_factor, /* i/o: mixing factor in the previous frame */
- Word16 *Env_error, /* o : error in SHB residual envelope modelling*/
- Word16 Env_error_part[] /* o : per-segment error in SHB residual envelope modelling */
-#endif
-);
+ const Word16 prev_bfi );
void GenShapedSHBExcitation_ivas_enc_fx(
Word16 *excSHB, /* o : synthesized shaped shb excitation Q_bwe_exc*/
@@ -3151,9 +3112,7 @@ void GenShapedSHBExcitation_ivas_dec_fx(
Word16 n_mem2, /* i : n_mem2 scale factor to adjust 24.4/32kbps memories */
Word16 prev_Q_bwe_syn, /* i : st_fx->prev_Q_bwe_syn */
const Word32 bitrate,
- const Word16 prev_bfi
-#if 1 // def ADD_IVAS_TBE_CODE
- , /* i : previous frame was concealed */
+ const Word16 prev_bfi, /* i : previous frame was concealed */
const Word16 element_mode, /* i : element mode */
const Word16 flag_ACELP16k, /* i : ACELP@16kHz flag */
Word16 *nlExc16k, /* i/o: NL exc for IC-BWE */
@@ -3165,7 +3124,6 @@ void GenShapedSHBExcitation_ivas_dec_fx(
Word16 *prev_mix_factor, /* i/o: mixing factor in the previous frame */
Word16 *Env_error, /* o : error in SHB residual envelope modelling*/
Word16 Env_error_part[] /* o : per-segment error in SHB residual envelope modelling */
-#endif
);
void GenSHBSynth_fx(
@@ -3181,8 +3139,8 @@ void GenSHBSynth_fx32(
Word32 *shb_syn_speech_32k, /* o : output highband component */
Word32 Hilbert_Mem[], /* i/o: memory */
Word32 state_lsyn_filt_shb_local[], /* i/o: memory */
- const int16_t L_frame, /* i : ACELP frame length */
- int16_t *syn_dm_phase );
+ const Word16 L_frame, /* i : ACELP frame length */
+ Word16 *syn_dm_phase );
void ScaleShapedSHB_fx(
const Word16 length, /* i : SHB overlap length */
@@ -3267,7 +3225,7 @@ void wb_tbe_extras_reset_synth_fx( Word16 state_lsyn_filt_shb[], Word16 state_ls
#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic
void elliptic_bpf_48k_generic_fx(
#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2
- const int16_t element_mode,
+ const Word16 element_mode,
#endif
Word16 IsUpsampled3,
Word16 input_fx[], /* i : input signal Q_input_fx*/
@@ -3302,71 +3260,37 @@ void synthesise_fb_high_band_fx(
Word16 Qout
#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2
,
- int16_t element_mode
+ Word16 element_mode
#endif
);
-#ifndef REMOVE_EVS_DUPLICATES
void prep_tbe_exc_fx(
- const Word16 L_frame_fx, /* i : length of the frame */
-#ifdef ADD_IVAS_TBE_CODE
- const Word16 L_subfr,
-#endif
- const Word16 i_subfr_fx, /* i : subframe index */
- const Word16 gain_pit_fx, /* i : Pitch gain Q14*/
- const Word32 gain_code_fx, /* i : algebraic codebook gain 16+Q_exc*/
- const Word16 code_fx[], /* i : algebraic excitation Q9*/
- const Word16 voice_fac_fx, /* i : voicing factor Q15*/
- Word16 *voice_factors_fx, /* o : TBE voicing factor Q15*/
- Word16 bwe_exc_fx[], /* i/o: excitation for TBE Q_exc*/
- const Word16 gain_preQ_fx, /* i : prequantizer excitation gain */
- const Word16 code_preQ_fx[], /* i : prequantizer excitation */
- const Word16 Q_exc, /* i : Excitation, bwe_exc Q-factor */
- Word16 T0, /* i : integer pitch variables Q0 */
- Word16 T0_frac, /* i : Fractional pitch variables Q0*/
- const Word16 coder_type, /* i : coding type */
- Word32 core_brate /* i :core bitrate */
-#ifdef ADD_IVAS_TBE_CODE
- ,
- const Word16 element_mode, /* i : element mode */
- const Word16 idchan, /* i : channel ID */
- const Word16 flag_TD_BWE, /* i : flag indicating whether hTD_BWE exists */
- const Word16 tdm_LRTD_flag /* i : LRTD stereo mode flag */
-#endif
-);
-#endif
-
-void prep_tbe_exc_ivas_fx(
- const Word16 L_frame_fx, /* i : length of the frame */
-#if 1 // def ADD_IVAS_TBE_CODE
- const Word16 L_subfr,
-#endif
- const Word16 i_subfr_fx, /* i : subframe index */
- const Word16 gain_pit_fx, /* i : Pitch gain Q14*/
- const Word32 gain_code_fx, /* i : algebraic codebook gain 16+Q_exc*/
- const Word16 code_fx[], /* i : algebraic excitation Q9*/
- const Word16 voice_fac_fx, /* i : voicing factor Q15*/
- Word16 *voice_factors_fx, /* o : TBE voicing factor Q15*/
- Word16 bwe_exc_fx[], /* i/o: excitation for TBE Q_exc*/
- const Word16 gain_preQ_fx, /* i : prequantizer excitation gain */
- const Word16 code_preQ_fx[], /* i : prequantizer excitation */
- const Word16 Q_exc, /* i : Excitation, bwe_exc Q-factor */
- Word16 T0, /* i : integer pitch variables Q0 */
- Word16 T0_frac, /* i : Fractional pitch variables Q0*/
- const Word16 coder_type, /* i : coding type */
- Word32 core_brate
-#if 1 // def ADD_IVAS_TBE_CODE
- , /* i : core bitrate */
- const Word16 element_mode, /* i : element mode */
- const Word16 idchan, /* i : channel ID */
- const Word16 flag_TD_BWE, /* i : flag indicating whether hTD_BWE exists */
- const Word16 tdm_LRTD_flag /* i : LRTD stereo mode flag */
-#endif
-);
-
-Word16 swb_formant_fac_fx( /* o : Formant filter strength [0,1] */
- const Word16 lpc_shb2, /* Q12 i : 2nd HB LPC coefficient */
- Word16 *tilt_mem /* i/o: Tilt smoothing memory */
+ const Word16 L_frame_fx, /* i : length of the frame */
+ const Word16 L_subfr, /* i : subframe length */
+ const Word16 i_subfr_fx, /* i : subframe index */
+ const Word16 gain_pit_fx, /* i : Pitch gain Q14*/
+ const Word32 gain_code_fx, /* i : algebraic codebook gain 16+Q_exc*/
+ const Word16 code_fx[], /* i : algebraic excitation Q9*/
+ const Word16 voice_fac_fx, /* i : voicing factor Q15*/
+ Word16 *voice_factors_fx, /* o : TBE voicing factor Q15*/
+ Word16 bwe_exc_fx[], /* i/o: excitation for TBE Q_exc*/
+ const Word16 gain_preQ_fx, /* i : prequantizer excitation gain */
+ const Word16 code_preQ_fx[], /* i : prequantizer excitation */
+ const Word16 Q_exc, /* i : Excitation, bwe_exc Q-factor */
+ const Word16 T0, /* i : integer pitch variables Q0 */
+ const Word16 T0_frac, /* i : Fractional pitch variables Q0*/
+ const Word16 coder_type, /* i : coding type */
+ const Word32 core_brate, /* i : core bitrate */
+ const Word16 element_mode, /* i : element mode */
+ const Word16 idchan, /* i : channel ID */
+ const Word16 flag_TD_BWE, /* i : flag indicating whether hTD_BWE exists */
+ const Word16 tdm_LRTD_flag /* i : LRTD stereo mode flag */
+);
+
+/*! r: Formant filter strength [0,1] */
+Word16 swb_formant_fac_fx(
+ const Word16 lpc_shb2, /* Q12 i : 2nd HB LPC coefficient */
+ Word16 *tilt_mem /* i/o: Tilt smoothing memory */
);
void wb_tbe_extras_reset_fx(
@@ -3803,8 +3727,8 @@ void const *GetTnsEnabledSingleFilter( void const *p, const Word16 index, Word16
void *SetTnsEnabledSingleFilter( void *p, const Word16 index, const Word16 value );
-void const *GetTnsOnWhite( void const *p, const int16_t index, int16_t *pValue );
-void *SetTnsOnWhite( void *p, const int16_t index, const int16_t value );
+void const *GetTnsOnWhite( void const *p, const Word16 index, Word16 *pValue );
+void *SetTnsOnWhite( void *p, const Word16 index, const Word16 value );
/*tns_base.h*/
/** Reset TNS data.
@@ -4169,8 +4093,8 @@ void cng_params_upd_ivas_fx(
const Word16 element_mode, /* i : Element mode */
const Word16 bwidth /* i : Audio bandwidth */
);
-int16_t get_cng_mode(
- const int32_t last_active_brate /* i : last active bitrate */
+Word16 get_cng_mode(
+ const Word32 last_active_brate /* i : last active bitrate */
);
// core_com_config.c
@@ -4180,15 +4104,7 @@ Word16 get_codec_mode(
);
Word16 getTcxonly(
-#ifdef IVAS_CODE_SWITCHING
- const Word16 element_mode, /* i : IVAS element mode */
-#endif
const Word32 total_brate /* i : total bitrate */
-#ifdef IVAS_CODE_SWITCHING
- ,
- const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0)*/
- const int16_t is_ism_format /* i : flag indicating ISM format */
-#endif
);
Word16 getTcxonly_fx(
@@ -4365,12 +4281,12 @@ void lpc2mdct(
void lpc2mdct_2(
Word16 *lpcCoeffs,
- const int16_t lpcOrder,
+ const Word16 lpcOrder,
Word16 mdct_gains_fx[],
Word16 mdct_gains_e[],
Word16 mdct_inv_gains_fx[],
Word16 mdct_inv_gains_e[],
- const int16_t length );
+ const Word16 length );
void mdct_shaping(
Word32 x[],
@@ -4730,6 +4646,7 @@ Word16 get_min_scalefactor( Word32 x, Word32 y );
Flag is_zero_arr( Word32 *arr, Word16 size );
Flag is_zero_arr16( Word16 *arr, Word16 size );
+Flag is_zero_arr64( Word64 *arr, Word16 size );
void edct2_fx_ivas(
const Word16 n,
@@ -4878,35 +4795,6 @@ Word16 BITS_ALLOC_config_acelp(
const Word16 narrowband,
const Word16 nb_subfr );
-#ifndef REMOVE_EVS_DUPLICATES
-ivas_error config_acelp1(
- const Word16 enc_dec, /* i : encoder/decoder flag */
- const Word32 total_brate, /* i : total bitrate */
- const Word32 core_brate_inp, /* i : core bitrate */
- const Word16 core, /* i : core */
- const Word16 extl, /* i : extension layer */
- const Word32 extl_brate, /* i : extension layer bitrate */
- const Word16 L_frame, /* i : frame length at internal Fs */
- const Word16 GSC_noisy_speech, /* i : GSC on SWB noisy speech flag */
- ACELP_config *acelp_cfg, /* i : ACELP bit-allocation */
- const Word16 signalling_bits, /* i : number of signalling bits */
- const Word16 coder_type, /* i : coder type */
- const Word16 inactive_coder_type_flag, /* i : AVQ (0) or GSC (1) IC flag */
- const Word16 tc_subfr, /* i : TC subfr ID */
- const Word16 tc_call, /* i : TC call number (0,1,2,3,5(DEC)) */
- Word16 *nBits_es_Pred, /* o : number of bits for Es_pred Q */
- Word16 *unbits, /* o : number of unused bits */
- const Word16 element_mode, /* i : element mode */
- Word16 *uc_two_stage_flag, /* o : flag undicating two-stage UC */
- const Word16 tdm_lp_reuse_flag, /* i : LPC reuse flag (can be 1 only with secondary channel */
- const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag */
- const Word16 idchan, /* i : stereo channel ID */
- const Word16 active_cnt, /* i : Active frame counter */
- const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag*/
- const Word16 tdm_LRTD_flag, /* i : LRTD stereo mode flag */
- const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */
-);
-#endif
Word16 set_ACELP_flag(
const Word16 element_mode, /* i : element mode */
const Word32 element_brate, /* i : element bitrate */
@@ -5034,25 +4922,25 @@ void cb_shape_fx(
// longarith.c
void longadd(
- uint16_t a[], /* i/o: vector of the length lena */
- const uint16_t b[], /* i/o: vector of the length lenb */
- const int16_t lena, /* i/o: length of vector a[] */
- const int16_t lenb /* i/o: length of vector b[] */
+ UWord16 a[], /* i/o: vector of the length lena */
+ const UWord16 b[], /* i/o: vector of the length lenb */
+ const Word16 lena, /* i/o: length of vector a[] */
+ const Word16 lenb /* i/o: length of vector b[] */
);
void longshiftright(
- uint16_t a[], /* i : vector of the length lena */
- const int16_t b, /* i : number of bit positions to shift right */
- uint16_t d[], /* o : vector of the length lend */
- int16_t lena, /* i : length of vector a[] */
- const int16_t lend /* i : length of vector d[] */
+ UWord16 a[], /* i : vector of the length lena */
+ const Word16 b, /* i : number of bit positions to shift right */
+ UWord16 d[], /* o : vector of the length lend */
+ Word16 lena, /* i : length of vector a[] */
+ const Word16 lend /* i : length of vector d[] */
);
void longshiftleft(
- const uint16_t a[], /* i : vector of the length len */
- const int16_t b, /* i : number of bit positions to shift left */
- uint16_t d[], /* o : vector of the length len */
- const int16_t len /* i : length of vector a[] and d[] */
+ const UWord16 a[], /* i : vector of the length len */
+ const Word16 b, /* i : number of bit positions to shift left */
+ UWord16 d[], /* o : vector of the length len */
+ const Word16 len /* i : length of vector a[] and d[] */
);
void longshr(
@@ -5275,6 +5163,12 @@ void expand_range(
Word16 *out_exp,
const Word16 len );
+void expand_range_fx(
+ Word32 *in, // Q25
+ Word32 *out, // exp:out_exp
+ Word16 *out_exp,
+ const Word16 len );
+
void expand_range_var_exp(
Word16 *in,
Word16 in_exp,
@@ -5310,8 +5204,8 @@ void minimum_statistics_fx(
Word16 lenFFT, /* i : Number of FFT partitions */
Word16 *psize, /* i : Partition sizes, fractional */
Word16 *msPeriodog, /* i : Periodogram (energies) */
- Word16 *msNoiseFloor, /* i/o: Noise floors (energies) */
- Word16 *msNoiseEst, /* i/o: Noise estimates (energies) */
+ Word32 *msNoiseFloor, /* i/o: Noise floors (energies) Q25*/
+ Word32 *msNoiseEst, /* i/o: Noise estimates (energies) Q25*/
Word32 *msAlpha, /* i/o: Forgetting factors */
Word16 *msPsd, /* i/o: Power Spectral Density (smoothed periodogram => energies) */
Word16 *msPsdFirstMoment, /* i/o: PSD statistics of 1st order (energy means) */
@@ -5728,27 +5622,9 @@ void enhancer_fx(
);
void enhancer_ivas_fx(
- const Word16 codec_mode, /* i : flag indicating Codec Mode */
- const Word32 core_brate, /* i : decoder bitrate */
- const int16_t cbk_index, /* i : */
- const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
- const Word16 coder_type, /* i : coder type */
- const Word16 i_subfr, /* i : subframe number */
- const Word16 L_frame, /* i : frame size */
- const Word16 voice_fac, /* i : subframe voicing estimation Q15 */
- const Word16 stab_fac, /* i : LP filter stablility measure Q15 */
- Word32 norm_gain_code, /* i : normalised innovative cb. gain Q16 */
- const Word16 gain_inov, /* i : gain of the unscaled innovation Q12 */
- Word32 *gc_threshold, /* i/o: gain code threshold Q16 */
- Word16 *code, /* i/o: innovation Q12 */
- Word16 *exc2, /* i/o: adapt. excitation/total exc. Q_exc*/
- const Word16 gain_pit, /* i : quantized pitch gain Q14 */
- struct dispMem_fx *dm_fx, /* i/o: phase dispersion algorithm memory */
- const Word16 Q_exc /* i : Q of the excitation */
-);
-
-void enhancer_ivas_fx2(
+ const Word16 codec_mode, /* i : flag indicating Codec Mode */
const Word32 core_brate, /* i : decoder bitrate */
+ const Word16 cbk_index, /* i : */
const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
const Word16 coder_type, /* i : coder type */
const Word16 i_subfr, /* i : subframe number */
@@ -5853,35 +5729,19 @@ void tcx_ltp_post_fx32(
Word32 *tcx_buf, /* sig_q */
Word16 sig_q );
-#ifndef REMOVE_EVS_DUPLICATES
-// gs_inact_switching_fx.c
-void Inac_swtch_ematch_fx(
- Word16 exc2[], /* i/o: CELP/GSC excitation buffer Q_exc*/
- Word16 dct_exc_tmp[], /* i : GSC excitation in DCT domain */
- Word16 lt_ener_per_band[], /* i/o: Long term energy per band Q12 */
- const Word16 coder_type, /* i : Coding mode */
- const Word16 L_frame, /* i : Frame lenght */
- const Word32 core_brate, /* i : Core bit rate */
- const Word16 Q_exc, /* i : i and output format of exc2 */
- const Word16 bfi, /* i : frame lost indicator */
- const short last_core, /* i : Last core used */
- const short last_codec_mode /* i : Last codec mode */
-);
-#endif
-
-void Inac_switch_ematch_ivas_fx(
+void Inac_switch_ematch_fx(
Word16 exc2[], /* i/o: CELP/GSC excitation buffer Q_exc*/
Word16 dct_exc_tmp[], /* i : GSC excitation in DCT domain */
Word16 lt_ener_per_band[], /* i/o: Long term energy per band Q12 */
const Word16 coder_type, /* i : Coding mode */
- const Word16 inactive_coder_type_flag, /* i : AVQ (0) or GSC (1) IC flag */
+ const Word16 inactive_coder_type_flag, /* i : AVQ (0) or GSC (1) IC flag */
const Word16 L_frame, /* i : Frame lenght */
const Word16 Q_exc, /* i : input and output format of exc2 */
const Word16 bfi, /* i : frame lost indicator */
const Word16 last_core, /* i : Last core used */
const Word16 last_codec_mode, /* i : Last codec mode */
- const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag*/
- const Word16 element_mode /* i : element mode */
+ const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag */
+ const Word16 element_mode /* i : element mode */
);
// igf_base_fx.c
@@ -6114,32 +5974,16 @@ void td_bwe_dec_init_fx(
const Word32 output_Fs /* i : output sampling rate */
);
-#ifndef REMOVE_EVS_DUPLICATES
-// lsf_dec_fx.c
void lsf_dec_fx(
- Decoder_State *st_fx, /* i/o: State structure */
- const Word16 tc_subfr, /* i : TC subframe index Q0*/
- Word16 *Aq, /* o : quantized A(z) for 4 subframes Q12*/
- Word16 *LSF_Q_prediction, /* o : LSF prediction mode Q0*/
- Word16 *lsf_new, /* o : de-quantized LSF vector Q(x2.56)*/
- Word16 *lsp_new, /* o : de-quantized LSP vector Q15*/
- Word16 *lsp_mid, /* o : de-quantized mid-frame LSP vector Q15*/
- const Word16 tdm_low_rate_mode /* i : secondary channel low rate mode flag Q0*/
- ,
- const Word16 tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel Qx*/
-);
-#endif
-void lsf_dec_ivas_fx(
- Decoder_State *st_fx, /* i/o: State structure */
- const Word16 tc_subfr, /* i : TC subframe index Q0*/
- Word16 *Aq, /* o : quantized A(z) for 4 subframes Q12*/
- Word16 *LSF_Q_prediction, /* o : LSF prediction mode Q0*/
- Word16 *lsf_new, /* o : de-quantized LSF vector Q(x2.56)*/
- Word16 *lsp_new, /* o : de-quantized LSP vector Q15*/
- Word16 *lsp_mid, /* o : de-quantized mid-frame LSP vector Q15*/
- const Word16 tdm_low_rate_mode /* i : secondary channel low rate mode flag Q0*/
- ,
- const Word16 tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel Qx*/
+ Decoder_State *st_fx, /* i/o: State structure */
+ const Word16 tc_subfr, /* i : TC subframe index Q0*/
+ Word16 *Aq, /* o : quantized A(z) for 4 subframes Q12*/
+ Word16 *LSF_Q_prediction, /* o : LSF prediction mode Q0*/
+ Word16 *lsf_new, /* o : de-quantized LSF vector Q(x2.56)*/
+ Word16 *lsp_new, /* o : de-quantized LSP vector Q15*/
+ Word16 *lsp_mid, /* o : de-quantized mid-frame LSP vector Q15*/
+ const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag Q0*/
+ const Word16 tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel Qx*/
);
/*! r: index of the maximum value in the input vector */
@@ -6302,21 +6146,9 @@ void lsf_mid_dec_fx(
Word16 lsp_mid[] /* o : quantized LSPs Q15*/
);
-#ifndef REMOVE_EVS_DUPLICATES
-// cng_dec_fx.c
void CNG_dec_fx(
Decoder_State *st_fx, /* i/o: State structure */
- const Word16 last_element_mode, /* i : last element mode Q0 */
- Word16 Aq[], /* o : LP coefficients Q12 */
- Word16 *lsp_new, /* i/o: current frame LSPs Q15 */
- Word16 *lsf_new, /* i/o: current frame LSFs Qlog2(2.56) */
- Word16 *allow_cn_step, /* o : allow CN step Q0 */
- Word16 *sid_bw, /* i : 0-NB/WB, 1-SWB SID Q0 */
- Word32 *q_env );
-#endif
-void CNG_dec_ivas_fx(
- Decoder_State *st_fx, /* i/o: State structure */
- const Word16 last_element_mode, /* i : last element mode Q0 */
+ const Word16 last_element_mode, /* i : last element mode Q0 */
Word16 Aq[], /* o : LP coefficients Q12 */
Word16 *lsp_new, /* i/o: current frame LSPs Q15 */
Word16 *lsf_new, /* i/o: current frame LSFs Qlog2(2.56) */
@@ -6490,12 +6322,7 @@ void DetectTonalComponents(
const Word16 nSamples,
const Word16 nSamplesCore,
Word16 floorPowerSpectrum, /* i: lower limit for power spectrum bins */
- Word16 element_mode
-#ifdef IVAS_CODE_MDCT_GSHAPE
- ,
- const PsychoacousticParameters *psychParamsCurrent
-#endif
-);
+ Word16 element_mode );
void RefineTonalComponents(
Word16 indexOfTonalPeak[],
@@ -6515,12 +6342,7 @@ void RefineTonalComponents(
const Word16 nSamples,
const Word16 nSamplesCore,
const Word16 floorPowerSpectrum, /* i: lower limit for power spectrum bins */
- Word16 element_mode
-#ifdef IVAS_CODE_MDCT_GSHAPE
- ,
- const PsychoacousticParameters *psychParamsCurrent
-#endif
-);
+ Word16 element_mode );
void ivas_RefineTonalComponents_fx(
Word16 indexOfTonalPeak[],
@@ -6545,11 +6367,11 @@ void ivas_RefineTonalComponents_fx(
const PsychoacousticParameters *psychParamsCurrent );
ivas_error PsychoacousticParameters_Init(
- const int32_t sr_core, /* i : sampling rate of core-coder */
- const int16_t nBins, /* i : Number of bins (spectral lines) */
- const int8_t nBands, /* i : Number of spectrum subbands */
- const int16_t isTCX20, /* i : Flag indicating if the subband division is for TCX20 or TCX10 */
- const int16_t isWarped, /* i : Flag indicating if the scale is linear or warped */
+ const Word32 sr_core, /* i : sampling rate of core-coder */
+ const Word16 nBins, /* i : Number of bins (spectral lines) */
+ const Word8 nBands, /* i : Number of spectrum subbands */
+ const Word16 isTCX20, /* i : Flag indicating if the subband division is for TCX20 or TCX10 */
+ const Word16 isWarped, /* i : Flag indicating if the scale is linear or warped */
PsychoacousticParameters *pPsychParams );
// TonalIMDCTconcealment_fx.c
@@ -6577,12 +6399,7 @@ void TonalMDCTConceal_SaveFreqSignal(
Word16 nNewSamplesCore,
const Word16 *scaleFactors,
const Word16 *scaleFactors_exp,
- const Word16 gain_tcx_exp
-#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
- ,
- const Word16 infoIGFStartLine
-#endif
-);
+ const Word16 gain_tcx_exp );
void TonalMDCTConceal_SaveFreqSignal_ivas_fx(
TonalMDCTConcealPtr hTonalMDCTConc,
@@ -6607,20 +6424,13 @@ void TonalMDCTConceal_Detect(
const Word32 pitchLag, /*IN */
Word16 *umIndices, /*OUT*/
Word16 element_mode /* IN */
-#ifdef IVAS_CODE_MDCT_GSHAPE
- ,
- const PsychoacousticParameters *psychParamsCurrent
-#endif
);
void TonalMDCTConceal_Apply(
- const TonalMDCTConcealPtr hTonalMDCTConc, /*IN */
- Word32* mdctSpectrum, /*IN/OUT*/
- Word16* mdctSpectrum_exp /*IN */
-#ifdef IVAS_CODE_MDCT_GSHAPE
- , const PsychoacousticParameters* psychParamsCurrent)
-#endif
- );
+ const TonalMDCTConcealPtr hTonalMDCTConc, /*IN */
+ Word32 *mdctSpectrum, /*IN/OUT*/
+ Word16 *mdctSpectrum_exp /*IN */
+);
void TonalMDCTConceal_Apply_ivas_fx(
TonalMDCTConcealPtr hTonalMDCTConc, /*IN */
@@ -6650,9 +6460,6 @@ void TonalMDCTConceal_InsertNoise(
Word16 *pSeed, /*IN/OUT*/
const Word16 tiltCompFactor,
Word16 crossfadeGain,
-#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
- const Word16concealment_noise[L_FRAME48k],
-#endif
const Word16 crossOverFreq );
void TonalMDCTConceal_SaveTimeSignal(
@@ -6694,6 +6501,18 @@ void hf_synth_fx(
const Word16 Q_syn2 /* i : synthesis scaling */
);
+void hf_synth_ivas_fx(
+ ZERO_BWE_DEC_HANDLE hBWE_zero, /* i/o: handle to 0 bit BWE parameters */
+ const Word32 core_brate, /* i : core bitrate Q0*/
+ const Word16 output_frame, /* i : output frame length Q0*/
+ const Word16 *Aq, /* i : quantized Az Q12*/
+ const Word16 *exc, /* i : excitation at 12.8 kHz Q_exc*/
+ Word16 *synth, /* i : 12.8kHz synthesis signal Q_syn2*/
+ Word16 *synth16k, /* o : 16kHz synthesis signal Q_syn2*/
+ const Word16 Q_exc, /* i : excitation scaling */
+ const Word16 Q_syn2 /* i : synthesis scaling */
+);
+
void hf_synth_amr_wb_init_fx(
AMRWB_IO_DEC_HANDLE hAmrwb_IO /* i/o: AMR-WB IO data handle */
);
@@ -6726,12 +6545,12 @@ void hf_synth_amr_wb_fx(
// dec_post_fx
void Init_post_filter_fx(
PFSTAT_HANDLE hPFstat /* i : core decoder parameters */
-); /* (i) : core decoder parameters */
+); /* i : core decoder parameters */
void nb_post_filt_fx(
const Word16 L_frame, /* i : frame length */
- PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */
+ PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */
Word16 *psf_lp_noise, /* i : Long term noise Q8 */
const Word16 tmp_noise, /* i : noise energy Q0 */
Word16 *Synth, /* i : 12k8 synthesis Qsyn */
@@ -6742,27 +6561,15 @@ void nb_post_filt_fx(
const Word16 disable_hpf /* i : flag to diabled HPF */
);
-#ifndef REMOVE_EVS_DUPLICATES
void formant_post_filt_fx(
- PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */
+ PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */
Word16 *synth_in, /* i : 12k8 synthesis */
- Word16 *Aq, /* i : LP filter coefficient */
- Word16 *synth_out, /* i/o: i signal */
- Word16 L_frame,
- Word32 lp_noise, /* (i) : background noise energy (15Q16) */
- Word32 rate, /* (i) : bit-rate */
- const Word16 off_flag /* i : off flag */
-);
-#endif
-void formant_post_filt_ivas_fx(
- PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */
- Word16 *synth_in, /* i : 12k8 synthesis */
- Word16 *Aq, /* i : LP filter coefficient */
- Word16 *synth_out, /* i/o: i signal */
- Word16 L_frame,
- Word32 lp_noise, /* (i) : background noise energy (15Q16) */
- Word32 rate, /* (i) : bit-rate */
- const Word16 off_flag /* i : off flag */
+ Word16 *Aq, /* i : LP filter coefficient Q12 */
+ Word16 *synth_out, /* i/o: input signal */
+ const Word16 L_frame, /* i : frame length */
+ const Word32 lp_noise, /* (i) : background noise energy (15Q16) */
+ const Word32 brate, /* (i) : bit-rate */
+ const Word16 off_flag /* i : off flag */
);
void Filt_mu_fx(
Word16 *sig_in, /* i : signal (beginning at sample -1) */
@@ -6928,65 +6735,34 @@ void PulseResynchronization_fx(
Word32 /*float*/ const pitchEnd /*i Q16*/
);
-#ifndef REMOVE_EVS_DUPLICATES
-// gs_dec_fx.c
void decod_audio_fx(
- Decoder_State *st_fx, /* i/o: decoder static memory */
- Word16 dct_epit[], /* o : GSC excitation in DCT domain Qx*/
- const Word16 *Aq, /* i : LP filter coefficient Q12*/
- Word16 *pitch_buf, /* o : floating pitch values for each subframe Q6*/
- Word16 *voice_factors, /* o : voicing factors Q15*/
- Word16 *exc, /* i/o: adapt. excitation exc Q_exc*/
- Word16 *exc2, /* i/o: adapt. excitation/total exc Q_exc*/
- Word16 *bwe_exc, /* o : excitation for SWB TBE Q_exc*/
- Word16 *lsf_new /* i : ISFs at the end of the frame Qx*/
- ,
- Word16 *gain_buf /*Q14*/
-);
-#endif
-void decod_audio_ivas_fx(
- Decoder_State *st_fx, /* i/o: decoder static memory */
- Word16 dct_epit[], /* o : GSC excitation in DCT domain Qx*/
- const Word16 *Aq, /* i : LP filter coefficient Q12*/
- Word16 *pitch_buf, /* o : Word16 pitch values for each subframe Q6*/
- Word16 *voice_factors, /* o : voicing factors Q15*/
- Word16 *exc, /* i/o: adapt. excitation exc Q_exc*/
- Word16 *exc2, /* i/o: adapt. excitation/total exc Q_exc*/
- Word16 *bwe_exc, /* o : excitation for SWB TBE Q_exc*/
- Word16 *lsf_new /* i : ISFs at the end of the frame Qx*/
- ,
- Word16 *gain_buf, /*Q14*/
+ Decoder_State *st_fx, /* i/o: decoder static memory */
+ Word16 dct_epit[], /* o : GSC excitation in DCT domain Qx*/
+ const Word16 *Aq, /* i : LP filter coefficient Q12*/
+ Word16 *pitch_buf, /* o : Word16 pitch values for each subframe Q6*/
+ Word16 *voice_factors, /* o : voicing factors Q15*/
+ Word16 *exc, /* i/o: adapt. excitation exc Q_exc*/
+ Word16 *exc2, /* i/o: adapt. excitation/total exc Q_exc*/
+ Word16 *bwe_exc, /* o : excitation for SWB TBE Q_exc*/
+ Word16 *lsf_new, /* i : ISFs at the end of the frame Qx*/
+ Word16 *gain_buf, /* o : Word16 pitch gain for each subframe Q14*/
const Word16 tdm_lp_reuse_flag, /* i : LPC reuse flag Q0*/
const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag 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*/
);
-#ifndef REMOVE_EVS_DUPLICATES
void gsc_dec_fx(
- Decoder_State *st_fx, /* i/o: State structure */
- Word16 exc_dct_in[], /* i/o: dct of pitch-only excitation / total excitation Q_exc*/
- const Word16 pit_band_idx, /* i : bin position of the cut-off frequency Q0*/
- const Word16 Diff_len, /* i : Lenght of the difference signal (before pure spectral) Q0*/
- const Word16 bits_used, /* i : Number of bit used before frequency Q Q0*/
- const Word16 nb_subfr, /* i : Number of subframe considered Q0*/
- const Word16 coder_type, /* i : coding type Q0*/
- Word16 *last_bin, /* i : last bin of bit allocation Q0*/
- const Word16 *lsf_new, /* i : ISFs at the end of the frame Qx*/
- Word16 *exc_wo_nf, /* o : excitation (in f domain) without noisefill Q_exc*/
- Word16 Q_exc );
-#endif
-void gsc_dec_ivas_fx(
- Decoder_State *st_fx, /* i/o: State structure */
- Word16 exc_dct_in[], /* i/o: dct of pitch-only excitation / total excitation Q_exc*/
+ Decoder_State *st_fx, /* i/o: State structure */
+ Word16 exc_dct_in[], /* i/o: dct of pitch-only excitation / total excitation Q_exc*/
const Word16 pit_band_idx, /* i : bin position of the cut-off frequency ` Q0*/
const Word16 Diff_len, /* i : Lenght of the difference signal (before pure spectral) Q0*/
const Word16 bits_used, /* i : Number of bit used before frequency Q Q0*/
const Word16 nb_subfr, /* i : Number of subframe considered Q0*/
const Word16 coder_type, /* i : coding type Q0*/
Word16 *last_bin, /* i : last bin of bit allocation Q0*/
- const Word16 *lsf_new, /* i : ISFs at the end of the frame Qx*/
- Word16 *exc_wo_nf, /* o : excitation (in f domain) without noisefill Q_exc*/
+ const Word16 *lsf_new, /* i : ISFs at the end of the frame Qx*/
+ Word16 *exc_wo_nf, /* o : excitation (in f domain) without noisefill Q_exc*/
Word16 *Q_exc );
void GSC_dec_init(
@@ -6997,18 +6773,15 @@ void GSC_dec_init_ivas_fx(
GSC_DEC_HANDLE hGSCDec /* i/o: GSC data handle */
);
-
-// gain_dec_fx.c
-
void Es_pred_dec_fx(
- Word16 *Es_pred, /* o : predicited scaled innovation energy Q8*/
- const Word16 enr_idx, /* i : indice */
- const Word16 nb_bits, /* i : number of bits */
- const Word16 no_ltp /* i : no LTP flag */
+ Word16 *Es_pred, /* o : predicited scaled innovation energy Q8*/
+ const Word16 enr_idx, /* i : indice */
+ const Word16 nb_bits, /* i : number of bits */
+ const Word16 no_ltp /* i : no LTP flag */
);
void gain_dec_tc_fx(
- Decoder_State *st_fx, /* i/o: decoder state structure */
+ Decoder_State *st_fx, /* i/o: decoder state structure */
const Word16 *code_fx, /* i : algebraic code excitation */
const Word16 i_subfr_fx, /* i : subframe number */
const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */
@@ -7043,7 +6816,6 @@ void gain_dec_mless_fx(
Word32 *norm_gain_code_fx /* o : norm. gain of the codebook excitation Q16*/
);
-#ifndef REMOVE_EVS_DUPLICATES
void gain_dec_lbr_fx(
Decoder_State *st_fx, /* i/o: decoder state structure */
const Word16 coder_type, /* i : coding type */
@@ -7054,25 +6826,8 @@ void gain_dec_lbr_fx(
Word16 *gain_inov_fx, /* o : gain of the innovation (used for normalization) Q12*/
Word32 *norm_gain_code_fx, /* o : norm. gain of the codebook excitation Q16*/
Word32 gc_mem[], /* i/o: gain_code from previous subframes */
- Word16 gp_mem[] /* i/o: gain_pitch from previous subframes */
- ,
- const Word16 L_subfr /* i : subfr lenght */
-);
-#endif
-
-void gain_dec_lbr_ivas_fx(
- Decoder_State *st_fx, /* i/o: decoder state structure */
- const Word16 coder_type, /* i : coding type */
- const Word16 i_subfr, /* i : subframe index */
- const Word16 *code_fx, /* i : algebraic excitation Q9 */
- Word16 *gain_pit_fx, /* o : quantized pitch gain Q14*/
- Word32 *gain_code_fx, /* o : quantized codebook gain Q16*/
- Word16 *gain_inov_fx, /* o : gain of the innovation (used for normalization) Q12*/
- Word32 *norm_gain_code_fx, /* o : norm. gain of the codebook excitation Q16*/
- Word32 gc_mem[], /* i/o: gain_code from previous subframes */
- Word16 gp_mem[] /* i/o: gain_pitch from previous subframes */
- ,
- const Word16 L_subfr /* i : subfr lenght */
+ Word16 gp_mem[], /* i/o: gain_pitch from previous subframes */
+ const Word16 L_subfr /* i : subfr lenght */
);
void lp_gain_updt_fx(
@@ -7093,13 +6848,14 @@ void lp_gain_updt_ivas_fx(
const Word16 L_frame /* i : length of the frame */
);
-Word32 gain_dec_gaus_fx( /* o : quantized codebook gain Q16 */
- Word16 index, /* i : quantization index */
- const Word16 bits, /* i : number of bits to quantize */
- const Word16 lowBound, /* i : lower bound of quantizer (dB) */
- const Word16 topBound, /* i : upper bound of quantizer (dB) */
- const Word16 inv_gain_inov, /* o : unscaled innovation gain Q12 */
- Word32 *L_norm_gain_code /* o : gain of normalized gaussian excitation Q16 */
+/*! r: quantized codebook gain Q16 */
+Word32 gain_dec_gaus_fx(
+ Word16 index, /* i : quantization index */
+ const Word16 bits, /* i : number of bits to quantize */
+ const Word16 lowBound, /* i : lower bound of quantizer (dB) */
+ const Word16 topBound, /* i : upper bound of quantizer (dB) */
+ const Word16 inv_gain_inov, /* o : unscaled innovation gain Q12 */
+ Word32 *L_norm_gain_code /* o : gain of normalized gaussian excitation Q16 */
);
void gain_dec_SQ_fx(
@@ -7193,23 +6949,7 @@ void re8_PPV_fx(
Word16 y[] /* o : point in RE8 (8-dimensional integer vector) Q0 */
);
-#ifndef REMOVE_EVS_DUPLICATES
-// dec_pit_exc_fx.c
void dec_pit_exc_fx(
- Decoder_State *st_fx, /* i/o: decoder static memory */
- const Word16 *Aq_fx, /* i : LP filter coefficient */
- const Word16 coder_type, /* i : coding type */
- const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */
- Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */
- Word16 *code_fx, /* o : innovation */
- Word16 *exc_fx, /* i/o: adapt. excitation exc */
- Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */
- const Word16 nb_subfr_fx /* i : Number of subframe considered */
- ,
- Word16 *gain_buf /*Q14*/
-);
-#endif
-void dec_pit_exc_ivas_fx(
Decoder_State *st_fx, /* i/o: decoder static memory */
const Word16 *Aq_fx, /* i : LP filter coefficient */
const Word16 coder_type, /* i : coding type */
@@ -7219,7 +6959,7 @@ void dec_pit_exc_ivas_fx(
Word16 *exc_fx, /* i/o: adapt. excitation exc */
Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */
const Word16 nb_subfr_fx, /* i : Number of subframe considered */
- Word16 *gain_buf, /*Q14*/
+ Word16 *gain_buf, /* o : Word16 pitch gain for each subframe Q14*/
const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */
);
@@ -7263,24 +7003,8 @@ void Mode2_delta_pit_dec(
Word16 **pt_indice /* i/o: pointer to Vector of Q indexes */
);
-#ifndef REMOVE_EVS_DUPLICATES
-Word16 pit_decode_fx( /* o : floating pitch value */
- Decoder_State *st_fx, /* i/o: decoder state structure */
- const Word32 core_brate, /* i : core bitrate */
- const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
- const Word16 L_frame, /* i : length of the frame */
- Word16 i_subfr, /* i : subframe index */
- const Word16 coder_type, /* i : coding type */
- Word16 *limit_flag, /* i/o: restrained(0) or extended(1) Q limits */
- Word16 *T0, /* o : close loop integer pitch */
- Word16 *T0_frac, /* o : close loop fractional part of the pitch */
- Word16 *T0_min, /* i/o: delta search min for sf 2 & 4 */
- Word16 *T0_max, /* i/o: delta search max for sf 2 & 4 */
- const Word16 L_subfr /* i : subframe length */
-);
-#endif
/* o : floating pitch value */
-Word16 pit_decode_ivas_fx(
+Word16 pit_decode_fx(
Decoder_State *st_fx, /* i/o: decoder state structure */
const Word32 core_brate, /* i : core bitrate */
const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
@@ -7459,6 +7183,16 @@ void pred_lt4(
const Word16 up_sample /* i : up_sample Q0*/
);
+void pred_lt4_ivas_fx(
+ const Word16 excI[], /* in : excitation buffer Q_exc*/
+ Word16 excO[], /* out: excitation buffer Q_exc*/
+ const Word16 T0, /* input : integer pitch lag Q0*/
+ Word16 frac, /* input : fraction of lag Q0*/
+ const Word16 L_subfr, /* input : subframe size Q0*/
+ const Word32 *win, /* i : interpolation window Q31*/
+ const Word16 nb_coef, /* i : nb of filter coef Q0*/
+ const Word16 up_sample /* i : up_sample Q0*/
+);
void pred_lt4_tc_fx(
Word16 exc[], /* i/o: excitation buffer Q0*/
@@ -7641,22 +7375,7 @@ void configureFdCngDec_fx(
const Word16 Last_L_frame,
const Word16 element_mode );
-#ifndef REMOVE_EVS_DUPLICATES
-/* Apply the CLDFB-based CNG */
Word16 ApplyFdCng_fx(
- Word16 *timeDomainInput, /* i : pointer to time domain i */
- Word16 Q,
-#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
- Word16 *powerSpectrum,
-#endif
- Word32 **cldfbBufferReal, /* i/o: real part of the CLDFB buffer */
- Word32 **cldfbBufferImag, /* i/o: imaginary part of the CLDFB buffer */
- Word16 *cldfbBufferScale, /* o : pointer to the scalefactor for real and imaginary part of the CLDFB buffer */
- Decoder_State *st,
- const Word16 concealWholeFrame, /* i : binary flag indicating frame loss */
- Word16 is_music );
-#endif
-Word16 ApplyFdCng_ivas_fx(
Word16 *timeDomainInput, /* i : pointer to time domain input */
Word16 Q,
Word32 *powerSpectrum,
@@ -7672,9 +7391,6 @@ Word16 ApplyFdCng_ivas_fx(
void perform_noise_estimation_dec_fx(
const Word16 *timeDomainInput, /* i: pointer to time domain i */
const Word16 Q,
-#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
- float *power_spectrum,
-#endif
HANDLE_FD_CNG_DEC hFdCngDec /* i/o: FD_CNG structure containing all buffers and variables */
);
@@ -8248,14 +7964,11 @@ void FEC_pitch_estim_fx(
const Word32 old_pitch_buf[], /* i : buffer of old subframe pitch values 15Q16 */
Word16 *bfi_pitch, /* i/o: update of the estimated pitch for FEC */
Word16 *bfi_pitch_frame, /* o : frame length when pitch was updated */
- Word16 *upd_cnt /* i/o: update counter */
- ,
- const Word16 coder_type, /* i : coder_type */
- Word16 element_mode /* i : element mode */
+ Word16 *upd_cnt, /* i/o: update counter */
+ const Word16 coder_type, /* i : coder_type */
+ Word16 element_mode /* i : element mode */
);
-#ifndef REMOVE_EVS_DUPLICATES
-// FEC_scale_sync_fx.c
void FEC_scale_syn_fx(
const Word16 L_frame, /* i : length of the frame */
Word16 *update_flg, /* o: flag indicating re-synthesis after scaling*/
@@ -8282,69 +7995,37 @@ void FEC_scale_syn_fx(
Word16 *mem_syn, /* o: initial synthesis filter states */
Word16 Q_exc,
Word16 Q_syn,
+ const Word16 element_mode, /* i : element mode */
const Word16 avoid_lpc_burst_on_recovery, /* i : if true the excitation energy is limited if LP has big gain */
- const Word16 force_scaling /* i: force scaling */
-);
-#endif
-void FEC_scale_syn_ivas_fx(
- const Word16 L_frame, /* i : length of the frame */
- Word16 *update_flg, /* o: flag indicating re-synthesis after scaling*/
- Word16 clas, /* i/o: frame classification */
- const Word16 last_good, /* i: last good frame classification */
- Word16 *synth, /* i/o: synthesized speech at Fs = 12k8 Hz */
- const Word16 *pitch, /* i: pitch values for each subframe */
- Word32 L_enr_old, /* i: energy at the end of previous frame */
- Word32 L_enr_q, /* i: transmitted energy for current frame */
- const Word16 coder_type, /* i: coder type */
- const Word16 LSF_Q_prediction, /* i : LSF prediction mode */
- Word16 *scaling_flag, /* i/o: flag to indicate energy control of syn */
- Word32 *lp_ener_FEC_av, /* i/o: averaged voiced signal energy */
- Word32 *lp_ener_FEC_max, /* i/o: averaged voiced signal energy */
- const Word16 bfi, /* i: current frame BFI */
- const Word32 total_brate, /* i: total bitrate */
- const Word16 prev_bfi, /* i: previous frame BFI */
- const Word32 last_core_brate, /* i: previous frame core bitrate */
- Word16 *exc, /* i/o: excitation signal without enhancement */
- Word16 *exc2, /* i/o: excitation signal with enhancement */
- Word16 Aq[], /* i/o: LP filter coefs (can be modified if BR) */
- Word16 *old_enr_LP, /* i/o: LP filter E of last good voiced frame */
- const Word16 *mem_tmp, /* i: temp. initial synthesis filter states */
- Word16 *mem_syn, /* o: initial synthesis filter states */
- Word16 Q_exc,
- Word16 Q_syn,
-#ifdef REMOVE_EVS_DUPLICATES
- const Word16 element_mode, /* i : element mode */
-#endif
- const Word16 avoid_lpc_burst_on_recovery, /* i : if true the excitation energy is limited if LP has big gain */
- const Word16 force_scaling /* i: force scaling */
+ const Word16 force_scaling /* i : force scaling */
);
// LD_music_post_filter_fx.c
void LD_music_post_filter_fx(
- MUSIC_POSTFILT_HANDLE hMusicPF, /* i/o: LD music postfilter handle */
- const Word16 dtc_in[], /* i : i synthesis Qdct */
- Word16 dtc_out[], /* o : output synthesis Qdct */
- const Word32 core_brate, /* i : core bitrate Q0 */
- Word16 *Old_ener_Q, /* i/o : Old energy scaling factor */
- const Word16 coder_type, /* i : Coder type : -1 in case of IO Q0 */
- const Word16 Last_coder_type, /* i : i scaling Q0 */
- const Word16 Qdct /* i : i scaling Q0 */
+ MUSIC_POSTFILT_HANDLE hMusicPF, /* i/o: LD music postfilter handle */
+ const Word16 dtc_in[], /* i : i synthesis Qdct */
+ Word16 dtc_out[], /* o : output synthesis Qdct */
+ const Word32 core_brate, /* i : core bitrate Q0 */
+ Word16 *Old_ener_Q, /* i/o: Old energy scaling factor */
+ const Word16 coder_type, /* i : Coder type : -1 in case of IO Q0 */
+ const Word16 Last_coder_type, /* i : i scaling Q0 */
+ const Word16 Qdct /* i : i scaling Q0 */
);
void Prep_music_postP_fx(
- Word16 exc_buffer_in[], /* i/o: excitation buffer Q_exc*/
- Word16 dct_buffer_out[], /* o : DCT output buffer (qdct)*/
- Word16 filt_lfE[], /* i/o: long term spectrum energy Q15 */
- const Word16 last_core, /* i : last core */
- const Word16 element_mode, /* i : element mode */
- const Word16 *pitch_buf, /* i : current frame pitch information Q6*/
- Word16 *LDm_enh_lp_gbin, /* o : smoothed suppression gain, per bin FFT Q15*/
- const Word16 Q_exc, /* i : excitation scaling */
- Word16 *qdct /* o : Scaling factor of dct coefficient */
+ Word16 exc_buffer_in[], /* i/o: excitation buffer Q_exc*/
+ Word16 dct_buffer_out[], /* o : DCT output buffer (qdct)*/
+ Word16 filt_lfE[], /* i/o: long term spectrum energy Q15 */
+ const Word16 last_core, /* i : last core */
+ const Word16 element_mode, /* i : element mode */
+ const Word16 *pitch_buf, /* i : current frame pitch information Q6*/
+ Word16 *LDm_enh_lp_gbin, /* o : smoothed suppression gain, per bin FFT Q15*/
+ const Word16 Q_exc, /* i : excitation scaling */
+ Word16 *qdct /* o : Scaling factor of dct coefficient */
);
void Post_music_postP_fx(
- Word16 dct_buffer_in[], /* i/o: excitation buffer */
+ Word16 dct_buffer_in[], /* i/o: excitation buffer */
Word16 *exc2, /* i/o: Current excitation to be overwriten */
const Word16 *mem_tmp, /* i : previous frame synthesis memory */
Word16 *st_mem_syn2, /* i/o: current frame synthesis memory */
@@ -8354,15 +8035,14 @@ void Post_music_postP_fx(
Word16 *prev_Q_syn, /* i : previsous frame synthesis scaling */
Word16 *Q_syn, /* i : Current frame synthesis scaling */
Word16 *mem_syn_clas_estim_fx, /* i : old 12k8 synthesis used for frame classification*/
- const Word16 IsIO, /* i: Flag to indicate IO mode */
- Word16 *mem_deemph, /* i/o: speech deemph filter memory */
- Word16 *st_pst_old_syn_fx, /* i/o: psfiler */
- Word16 *st_pst_mem_deemp_err_fx, /* i/o: psfiler */
+ const Word16 IsIO, /* i : Flag to indicate IO mode */
+ Word16 *mem_deemph, /* i/o: speech deemph filter memory */
+ Word16 *st_pst_old_syn_fx, /* i/o: psfiler */
+ Word16 *st_pst_mem_deemp_err_fx, /* i/o: psfiler */
Word16 *mem_agc,
- PFSTAT *pf_stat, /* i/o: All memories related to NB post filter */
- const Word16 *tmp_buffer /* tmp_buffer in Q-1 */
- ,
- Word16 *mem_tmp2 /* Temporary memory used with scale_syn */
+ PFSTAT *pf_stat, /* i/o: All memories related to NB post filter */
+ const Word16 *tmp_buffer, /* tmp_buffer in Q-1 */
+ Word16 *mem_tmp2 /* Temporary memory used with scale_syn */
);
void music_postfilt_init(
@@ -8389,10 +8069,6 @@ void improv_amr_wb_gs_fx(
const Word16 Last_ener_fx, /* i : Last energy (Q8) Q0*/
const Word16 rate_switching_reset, /* i : rate switching reset flag Q0*/
const Word16 last_coder_type /* i : Last coder_type Q0*/
-#ifdef ADD_IVAS_GS_DEC_IMPR
- ,
- const Word16 VeryLowRateSTflag /* i : Enable the noise enhancement for very low rate stereo generic mode */
-#endif
);
// dec_amr_wb_fx.c
@@ -8444,18 +8120,7 @@ ivas_error ppp_quarter_decoder_fx(
void open_decoder_LPD_fx(
Decoder_State *st,
const Word32 total_brate, /* Q0 */
-#ifdef NEW_IVAS_OPEN_DEC
- const Word32 last_total_brate,
-#endif
- const Word16 bwidth /* Q0 */
-#ifdef NEW_IVAS_OPEN_DEC
- ,
- const Word16 is_mct, /* i : MCT mode flag */
-#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
- const Word16 last_element_mode,
-#endif
- const Word16 is_init /* i : indicate call from init_decoder() to avoid double TC initialization */
-#endif
+ const Word16 bwidth /* Q0 */
);
void open_decoder_LPD_ivas_fx(
Decoder_State *st, /* i/o: decoder state structure */
@@ -8560,7 +8225,7 @@ void stat_noise_uv_mod_ivas_fx(
const Word16 *lsp_mid, /* i : LSP vector at 2nd sfr Q=15*/
Word16 *Aq, /* o : A(z) quantized for the 4 subframes Q=12*/
Word16 *exc2, /* i/o: excitation buffer Q=Q_exc*/
- Word16 Q_exc, /* i : Q of exc2 excitation buffer [11..-1] expected */
+ Word16 *Q_exc, /* i : Q of exc2 excitation buffer [11..-1] expected */
const Word16 bfi, /* i : Bad frame indicator */
Word32 *ge_sm, /* i/o: smoothed excitation gain Q=Q_stat_noise_ge (6)*/
Word16 *uv_count, /* i/o: unvoiced counter */
@@ -8594,40 +8259,28 @@ Word16 FEC_enhACB_fx(
const Word16 puls_pos, /* i : decoder position of the last glottal pulses decoded in the previous frame */
const Word16 bfi_pitch /* i : Q6 pitch used for concealment */
);
-Word16 FEC_synchro_exc_fx( /* o : do_WI flag */
- const Word16 L_frame, /* i : length of the frame */
- Word16 *exc, /* i/o: exc vector to modify */
- const Word16 desire_puls_pos, /* i : Pulse position send by the encoder */
- const Word16 true_puls_pos, /* i : Present pulse location */
- const Word16 Old_pitch /* i : Pitch use to create temporary adaptive codebook */
+
+/*! r: do_WI flag */
+Word16 FEC_synchro_exc_fx(
+ const Word16 L_frame, /* i : length of the frame */
+ Word16 *exc, /* i/o: exc vector to modify */
+ const Word16 desire_puls_pos, /* i : Pulse position send by the encoder */
+ const Word16 true_puls_pos, /* i : Present pulse location */
+ const Word16 Old_pitch /* i : Pitch use to create temporary adaptive codebook */
);
-#ifndef REMOVE_EVS_DUPLICATES
-// dec_uv_fx.c
void decod_unvoiced_fx(
- Decoder_State *st_fx, /* i/o: decoder static memory */
- const Word16 *Aq_fx, /* Q12 i : LP filter coefficient */
- const Word16 coder_type, /* Q0 i : coding type */
- Word16 *tmp_noise_fx, /* Q5 o : long term temporary noise energy */
- Word16 *pitch_buf_fx, /* Q6 o : floating pitch values for each subframe */
- Word16 *voice_factors_fx, /* Q15 o : voicing factors */
- Word16 *exc_fx, /* Q_X o : adapt. excitation exc */
- Word16 *exc2_fx, /* Q_X o : adapt. excitation/total exc */
- Word16 *bwe_exc_fx, /* Q_X i/o: excitation for SWB TBE */
- Word16 *gain_buf );
-#endif
-void decod_unvoiced_ivas_fx(
- Decoder_State *st_fx, /* i/o: decoder static memory */
- const Word16 *Aq_fx, /* Q12 i : LP filter coefficient */
- const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */
- const int16_t uc_two_stage_flag, /* i : flag indicating two-stage UC */
- const Word16 coder_type, /* Q0 i : coding type */
- Word16 *tmp_noise_fx, /* Q0 o : long term temporary noise energy */
- Word16 *pitch_buf_fx, /* Q6 o : floating pitch values for each subframe*/
- Word16 *voice_factors_fx, /* Q15 o : voicing factors */
- Word16 *exc_fx, /* Q_X o : adapt. excitation exc */
- Word16 *exc2_fx, /* Q_X o : adapt. excitation/total exc */
- Word16 *bwe_exc_fx, /* Q_X i/o: excitation for SWB TBE */
+ Decoder_State *st_fx, /* i/o: decoder static memory */
+ const Word16 *Aq_fx, /* Q12 i : LP filter coefficient */
+ const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */
+ const Word16 uc_two_stage_flag, /* i : flag indicating two-stage UC */
+ const Word16 coder_type, /* Q0 i : coding type */
+ Word16 *tmp_noise_fx, /* Q0 o : long term temporary noise energy */
+ Word16 *pitch_buf_fx, /* Q6 o : floating pitch values for each subframe*/
+ Word16 *voice_factors_fx, /* Q15 o : voicing factors */
+ Word16 *exc_fx, /* Q_X o : adapt. excitation exc */
+ Word16 *exc2_fx, /* Q_X o : adapt. excitation/total exc */
+ Word16 *bwe_exc_fx, /* Q_X i/o: excitation for SWB TBE */
Word16 *gain_buf );
// gaus_dec_fx.c
@@ -8659,38 +8312,20 @@ void gaus_L2_dec(
Word16 *seed_acelp /*i/o : random seed Q0 */
);
-#ifndef REMOVE_EVS_DUPLICATES
-// dec_gen_voic_fx.c
ivas_error decod_gen_voic_fx(
- Decoder_State *st_fx, /* i/o: decoder static memory */
- const Word16 L_frame_fx, /* i : length of the frame */
- const Word16 sharpFlag_fx, /* i : formant sharpening flag */
- const Word16 *Aq_fx, /* i : LP filter coefficient */
- const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */
- const Word16 do_WI_fx, /* i : do interpolation after a FER */
- Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */
- Word16 *voice_factors_fx, /* o : voicing factors */
- Word16 *exc_fx, /* i/o: adapt. excitation exc */
- Word16 *exc2_fx, /* i/o: adapt. excitation/total exc */
- Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */
- Word16 *unbits, /* number of unused bits */
- Word16 *gain_buf /*Q14*/
-);
-#endif
-ivas_error decod_gen_voic_ivas_fx(
- Decoder_State *st_fx, /* i/o: decoder static memory */
- const Word16 L_frame, /* i : length of the frame */
- const Word16 sharpFlag_fx, /* i : formant sharpening flag */
- const Word16 *Aq_fx, /* i : LP filter coefficient */
- const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */
- const Word16 do_WI_fx, /* i : do interpolation after a FER */
- Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */
- Word16 *voice_factors_fx, /* o : voicing factors */
- Word16 *exc_fx, /* i/o: adapt. excitation exc */
- Word16 *exc2_fx, /* i/o: adapt. excitation/total exc */
- Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */
- Word16 *unbits, /* number of unused bits */
- Word16 *gain_buf,
+ Decoder_State *st_fx, /* i/o: decoder static memory */
+ const Word16 L_frame, /* i : length of the frame */
+ const Word16 sharpFlag_fx, /* i : formant sharpening flag */
+ const Word16 *Aq_fx, /* i : LP filter coefficient */
+ const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */
+ const Word16 do_WI_fx, /* i : do interpolation after a FER */
+ Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */
+ Word16 *voice_factors_fx, /* o : voicing factors */
+ Word16 *exc_fx, /* i/o: adapt. excitation exc */
+ Word16 *exc2_fx, /* i/o: adapt. excitation/total exc */
+ Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */
+ Word16 *unbits, /* number of unused bits */
+ Word16 *gain_buf, /* o : Word16 pitch gain for each subframe Q14*/
const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */
);
@@ -8829,10 +8464,10 @@ void mode_switch_decoder_LPD_ivas_fx(
// ari_hm_dec.c
-int16_t DecodeIndex(
+Word16 DecodeIndex(
Decoder_State *st,
- const int16_t Bandwidth, /* o : NB, 1: (S)WB */
- int16_t *PeriodicityIndex );
+ const Word16 Bandwidth, /* o : NB, 1: (S)WB */
+ Word16 *PeriodicityIndex );
Word16
DecodeIndex_fx(
Decoder_State *st,
@@ -8909,7 +8544,7 @@ void IGFSCFDecoderReset(
void IGFSCFDecoderDecode(
IGFSCFDEC_INSTANCE_HANDLE hPublicData, /* i/o: handle to public data or NULL in case there was no instance created */
Decoder_State *st, /* i/o: pointer to decoder state */
- int16_t *sfe, /* o : ptr to an array which will contain the decoded quantized coefficients */
+ Word16 *sfe, /* o : ptr to an array which will contain the decoded quantized coefficients */
const Word16 igfGridIdx, /* i : igf grid index see declaration of IGF_GRID_IDX for details */
const Word16 indepFlag /* i : if 1 on input the decoder will be forced to reset,
if 0 on input the decoder will be forced to encode without a reset */
@@ -9010,28 +8645,18 @@ void tcx_hm_modify_envelope(
);
// tns_base_dec_fx.c
-#ifdef IVAS_CODE
-void
-#else
Word16
-#endif
ReadTnsData( STnsConfig const *pTnsConfig,
Decoder_State *st,
Word16 *pnBits,
Word16 *stream,
Word16 *pnSize );
-#define IVAS_CODE
-#ifdef IVAS_CODE
-void
-#else
-Word16
-#endif
-ReadTnsData_ivas_fx( STnsConfig const *pTnsConfig,
- Decoder_State *st,
- Word16 *pnBits,
- Word16 *stream,
- Word16 *pnSize );
-#undef IVAS_CODE
+
+void ReadTnsData_ivas_fx( STnsConfig const *pTnsConfig,
+ Decoder_State *st,
+ Word16 *pnBits,
+ Word16 *stream,
+ Word16 *pnSize );
Word16 DecodeTnsData( STnsConfig const *pTnsConfig,
Word16 const *stream,
@@ -9047,11 +8672,11 @@ Word16 DecodeTnsData_ivas_fx(
// parametr_bitmapping.c using ivas
void GetParameters(
ParamsBitMap const *paramsBitMap,
- const int16_t nParams,
+ const Word16 nParams,
void const *pParameter,
- int16_t **pStream,
- int16_t *pnSize,
- int16_t *pnBits );
+ Word16 **pStream,
+ Word16 *pnSize,
+ Word16 *pnBits );
void GetParameters_fx(
ParamsBitMap const *paramsBitMap,
@@ -9071,10 +8696,10 @@ void EncodeTnsData_ivas_fx(
void SetParameters(
ParamsBitMap const *paramsBitMap,
- const int16_t nParams,
+ const Word16 nParams,
void *pParameter,
- const int16_t **pStream,
- int16_t *pnSize );
+ const Word16 **pStream,
+ Word16 *pnSize );
void SetParameters_fx(
ParamsBitMap const *paramsBitMap,
@@ -9085,18 +8710,18 @@ void SetParameters_fx(
void WriteToBitstream(
ParamsBitMap const *paramsBitMap,
- const int16_t nParams,
- const int16_t **pStream,
- int16_t *pnSize,
+ const Word16 nParams,
+ const Word16 **pStream,
+ Word16 *pnSize,
BSTR_ENC_HANDLE hBstr,
- int16_t *pnBits );
+ Word16 *pnBits );
void ReadFromBitstream(
ParamsBitMap const *paramsBitMap,
- const int16_t nArrayLength,
+ const Word16 nArrayLength,
Decoder_State *st,
- int16_t **pStream,
- int16_t *pnSize );
+ Word16 **pStream,
+ Word16 *pnSize );
void ReadFromBitstream_fx(
ParamsBitMap const *paramsBitMap,
@@ -9217,15 +8842,8 @@ Word16 decode_lpc_avq_fx(
Decoder_State *st, /* i/o: decoder state structure */
const Word16 numlpc, /* i : Number of sets of lpc */
Word16 *param_lpc /* o : lpc parameters */
-#ifdef IVAS_CODE_AVQ_LPC
- ,
- const Word16 ch, /* i : channel */
- const Word16 element_mode, /* i : element mode */
- const Word16 sns_low_br_mode /* i : SNS low-bitrate mode */
-#endif
);
-// decode_lpc_avq_ivas_fx declaration with IVAS_CODE_AVQ_LPC enabled
Word16 decode_lpc_avq_ivas_fx(
Decoder_State *st, /* i/o: decoder state structure */
const Word16 numlpc, /* i : Number of sets of lpc */
@@ -9449,17 +9067,6 @@ void modify_lsf(
void con_tcx_fx(
Decoder_State *st, /* i/o: coder memory state */
Word16 synth[] /* i/o: synth[] */ /*Q0 */
-#ifdef IVAS_CODE_CON_TCX
- ,
- const Word16 coh, /* i : coherence of stereo signal */
- Word16 *noise_seed, /* i/o: noise seed for stereo */
- const Word16 only_left /* i : TD-PLC only in left channel */
-#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
- ,
- const float *A_cng /* i : CNG LP filter coefficients */
-#endif
-#endif
-
);
// er_scale_sync.c
@@ -9620,33 +9227,6 @@ void d_gain_pred_fx(
Word16 **pt_indice /* i/o: pointer to the buffer of indices */
);
-#ifndef REMOVE_EVS_DUPLICATES
-// acelp_core_dec_fx.c
-ivas_error acelp_core_dec_fx(
- Decoder_State *st_fx, /* i/o: decoder state structure */
- Word16 output[], /* o : synthesis @internal Fs */
- Word16 synth_out[], /* o : synthesis */
- Word16 save_hb_synth[], /* o : HB synthesis */
- Word32 bwe_exc_extended[], /* i/o: bandwidth extended excitation */
- Word16 *voice_factors, /* o : voicing factors */
- Word16 old_syn_12k8_16k[], /* o : intermediate ACELP synthesis for SWB BWE */
- Word16 sharpFlag,
- Word16 pitch_buf_fx[NB_SUBFR16k], /* o : floating pitch for each subframe */
- Word16 *unbits, /* o : number of unused bits */
- Word16 *sid_bw /* o : 0-NB/WB, 1-SWB SID */
- ,
- STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i/o: TD stereo decoder handle */
- const Word16 tdm_lspQ_PCh[M], /* i : Q LSPs for primary channel */
- const Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */
- const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */
- const Word16 last_element_mode, /* i : last element mode */
- const Word32 last_element_brate, /* i : last element bitrate */
- const Word16 flag_sec_CNA, /* i : CNA flag for secondary channel */
- const Word16 nchan_out, /* i : number of output channels */
- STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */
- const Word16 read_sid_info /* i : read SID info flag */
-);
-#endif
// evs_dec_fx.c
ivas_error evs_dec_fx(
Decoder_State *st_fx, /* i/o : Decoder state structure */
@@ -9700,7 +9280,7 @@ void v_add_fx(
const Word32 x1[], /* i : Input vector 1 */
const Word32 x2[], /* i : Input vector 2 */
Word32 y[], /* o : Output vector that contains vector 1 + vector 2 */
- const int16_t N /* i : Vector length */
+ const Word16 N /* i : Vector length */
);
void v_shr_16(
@@ -9754,10 +9334,10 @@ void configureCldfb_ivas_fx(
);
// dec4t64.c
void dec_acelp_fast_fx(
- Decoder_State *st, /* i/o: decoder state structure */
- const int16_t cdk_index, /* i : codebook index */
- Word16 code[], /* o : algebraic (fixed) codebook excitation */
- const int16_t L_subfr /* i : subframe length */
+ Decoder_State *st, /* i/o: decoder state structure */
+ const Word16 cdk_index, /* i : codebook index */
+ Word16 code[], /* o : algebraic (fixed) codebook excitation */
+ const Word16 L_subfr /* i : subframe length */
);
// codec_tcx_common.c
void tcx5SpectrumInterleaving_fx(
@@ -9795,7 +9375,7 @@ void cldfbAnalysis_ivas_fx(
const Word32 *timeIn_fx, /* i : time buffer Qx */
Word32 **realBuffer_fx, /* o : real value buffer Qx - 5*/
Word32 **imagBuffer_fx, /* o : imag value buffer QX - 5*/
- const int16_t samplesToProcess, /* i : samples to process */
+ const Word16 samplesToProcess, /* i : samples to process */
HANDLE_CLDFB_FILTER_BANK h_cldfb /* i : filterbank state */
);
@@ -9814,7 +9394,7 @@ void cldfbSynthesis_ivas_fx(
// bass_psfilter.c
void addBassPostFilter_ivas_fx(
const Word32 *harm_timeIn_fx,
- const int16_t samplesToProcess,
+ const Word16 samplesToProcess,
Word32 **rAnalysis_fx,
Word32 **iAnalysis_fx,
HANDLE_CLDFB_FILTER_BANK cldfb );
@@ -9974,8 +9554,8 @@ void fd_bwe_dec_init_fx(
void stereo_dft_dec_open(
STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */
- const int32_t output_Fs, /* i : output sampling rate */
- const int16_t nchan_transport /* i : number of transport channels */
+ const Word32 output_Fs, /* i : output sampling rate */
+ const Word16 nchan_transport /* i : number of transport channels */
);
void ivas_bw_switching_pre_proc_fx(
@@ -10053,6 +9633,12 @@ Word16 usdequant_fx( /* Qx*/
const Word16 delta /* i: quantization step Qy*/
);
+Word32 usdequant32_fx( /* Qx*/
+ const Word16 idx, /* i: quantizer index Q0*/
+ const Word32 qlow, /* i: lowest codebook entry (index 0) Qx*/
+ const Word32 delta /* i: quantization step Qy*/
+);
+
Word16 usquant_fx( /* o: index of the winning codeword */
const Word16 x, /* i: scalar value to quantize Qx*/
Word16 *xq, /* o: quantized value Qx*/
@@ -10564,6 +10150,12 @@ void hp400_12k8_fx(
Word16 mem[] /* i/o: filter memory [6] */
);
+void hp400_12k8_ivas_fx(
+ Word16 signal[], /* i/o: input signal / output is divided by 16 */
+ const Word16 lg, /* i : lenght of signal */
+ Word16 mem[] /* i/o: filter memory [6] */
+);
+
Word16 dot_prod_satcontr( const Word16 *x, const Word16 *y, Word16 qx, Word16 qy, Word16 *qo, Word16 len );
void E_UTIL_f_convolve( const Word16 x[], const Word16 h[], Word16 y[], const Word16 size );
@@ -10665,8 +10257,8 @@ void dctT2_N_apply_matrix_fx(
);
Word32 sum2_f_32_fx(
- const Word32 *vec, /* i : input vector */
- const int16_t lvec, /* i : length of input vector */
+ const Word32 *vec, /* i : input vector */
+ const Word16 lvec, /* i : length of input vector */
Word16 gb );
Word32 sum2_32_fx(
@@ -10716,7 +10308,7 @@ Word16 swb_bwe_dec_fx32(
Word16 output_frame /* i : frame length */
);
-ivas_error acelp_core_dec_ivas_fx(
+ivas_error acelp_core_dec_fx(
Decoder_State *st, /* i/o: decoder state structure */
Word16 output_fx[], /* o : synthesis @internal Fs */
Word16 synth_fx16[], /* o : synthesis */
@@ -10816,10 +10408,10 @@ void generate_stereo_masking_noise_fx(
Word16 Q_syn,
Decoder_State *st, /* i/o: decoder state structure */
STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i : TD stereo structure */
- const int16_t flag_sec_CNA, /* i : CNA flag for secondary channel */
- const int16_t fadeOut, /* i : only fade out of previous state */
+ const Word16 flag_sec_CNA, /* i : CNA flag for secondary channel */
+ const Word16 fadeOut, /* i : only fade out of previous state */
STEREO_CNG_DEC_HANDLE hStereoCng, /* i : Stereo CNG handle */
- const int16_t nchan_out /* i : number of output channels */
+ const Word16 nchan_out /* i : number of output channels */
);
void SynthesisSTFT_fx(
@@ -10827,10 +10419,10 @@ void SynthesisSTFT_fx(
Word32 *timeDomainOutput,
Word32 *olapBuffer,
const Word16 *olapWin,
- const int16_t tcx_transition,
+ const Word16 tcx_transition,
HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */
- const int16_t element_mode, /* i : element mode */
- const int16_t nchan_out /* i : number of output channels */
+ const Word16 element_mode, /* i : element mode */
+ const Word16 nchan_out /* i : number of output channels */
);
void FdCng_decodeSID_ivas_fx(
@@ -10919,32 +10511,32 @@ void ProcessStereoIGF_fx(
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 */
- Word16 exp_pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: exp of pPowerSpectrum_fx */
- Word32 *pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i : inverse power spectrum */
- Word16 exp_pPowerSpectrumMsInv_fx[CPE_CHANNELS], /* i/o: exp of pPowerSpectrumMsInv_fx */
- Word32 *inv_spectrum_fx[CPE_CHANNELS][NB_DIV], /* i : inverse spectrum */
- Word16 exp_inv_spectrum_fx[CPE_CHANNELS], /* i/o: exp of inv_spectrum_fx */
- const Word16 frameno, /* i : flag indicating index of current subfr. */
- const Word16 sp_aud_decision0, /* i : sp_aud_decision0 */
- const Word32 element_brate, /* i : element bitrate */
+ Word32 *pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */
+ Word16 *exp_pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: exp of pPowerSpectrum_fx */
+ Word32 *pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i : inverse power spectrum */
+ Word16 *q_pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i/o: Q of pPowerSpectrumMsInv_fx */
+ Word32 *inv_spectrum_fx[CPE_CHANNELS][NB_DIV], /* i : inverse spectrum */
+ Word16 exp_inv_spectrum_fx[CPE_CHANNELS], /* i/o: exp of inv_spectrum_fx */
+ const Word16 frameno, /* i : flag indicating index of current subfr. */
+ const Word16 sp_aud_decision0, /* i : sp_aud_decision0 */
+ const Word32 element_brate, /* i : element bitrate */
const Word16 mct_on );
/*igf_enc.c*/
void IGFEncApplyStereo_fx(
- STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: MDCT stereo encoder structure */
- Word16 ms_mask[2][MAX_SFB], /* i : bandwise MS mask */
- const IGF_ENC_INSTANCE_HANDLE hIGFEnc[CPE_CHANNELS], /* i : instance handle of IGF Encoder */
- const Word16 igfGridIdx, /* i : IGF grid index */
- Encoder_State *sts[CPE_CHANNELS], /* i : Encoder state */
- Word32 *pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */
- Word16 exp_pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: exp of pPowerSpectrum_fx */
- Word32 *pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i/o: inverse power spectrum */
- Word16 exp_pPowerSpectrumMsInv_fx[CPE_CHANNELS], /* i/o: exp of pPowerSpectrumMsInv_fx */
- Word32 *inv_spectrum_fx[CPE_CHANNELS][NB_DIV], /* i : inverse spectrum */
- Word16 exp_inv_spectrum_fx[CPE_CHANNELS], /* i : exp of inverse spectrum */
- const Word16 frameno, /* i : flag indicating index of current subfr. */
- const Word16 sp_aud_decision0, /* i : sp_aud_decision0 */
- const Word32 element_brate, /* i : element bitrate */
+ STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: MDCT stereo encoder structure */
+ Word16 ms_mask[2][MAX_SFB], /* i : bandwise MS mask */
+ const IGF_ENC_INSTANCE_HANDLE hIGFEnc[CPE_CHANNELS], /* i : instance handle of IGF Encoder */
+ const Word16 igfGridIdx, /* i : IGF grid index */
+ Encoder_State *sts[CPE_CHANNELS], /* i : Encoder state */
+ Word32 *pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */
+ Word16 *exp_pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: exp of pPowerSpectrum_fx */
+ Word32 *pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i/o: inverse power spectrum */
+ Word16 *q_pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i/o: Q of pPowerSpectrumMsInv_fx */
+ Word32 *inv_spectrum_fx[CPE_CHANNELS][NB_DIV], /* i : inverse spectrum */
+ Word16 exp_inv_spectrum_fx[CPE_CHANNELS], /* i : exp of inverse spectrum */
+ const Word16 frameno, /* i : flag indicating index of current subfr. */
+ const Word16 sp_aud_decision0, /* i : sp_aud_decision0 */
+ const Word32 element_brate, /* i : element bitrate */
const Word16 mct_on );
void IGFSaveSpectrumForITF_ivas_fx(
@@ -11013,6 +10605,7 @@ Word16 ari_decode_14bits_pow_ivas(
Word16 *res,
Tastat *s,
UWord16 base );
+
Word16 ari_decode_14bits_sign_ivas(
Word16 *ptr,
Word16 bp,
@@ -11026,22 +10619,21 @@ void lsf_syn_mem_backup_ivas_fx(
Word32 *gc_threshold_fx, /* i: Q16 */
Word16 *clip_var_bck_fx, /* o: Q(2.56), Q14, Q7, Q0, Q14, Q14 */
Word16 *next_force_sf_bck_fx, /* o: */
-
- Word16 *lsp_new, /* i: LSP vector to quantize Q15 */
- Word16 *lsp_mid, /* i: mid-frame LSP vector Q15 */
- Word16 *clip_var, /* o: pitch clipping state var Q(2.56) */
- Word16 *mem_AR, /* o: quantizer memory for AR model Q(2.56) */
- Word16 *mem_MA, /* o: quantizer memory for AR model Q(2.56) */
- Word16 *lsp_new_bck, /* o: LSP vector to quantize- backup Q15 */
- Word16 *lsp_mid_bck, /* o: mid-frame LSP vector - backup Q15 */
- Word32 *Bin_E, /* o: FFT Bin energy 128 *2 sets Q_new + Q_SCALE - 2 */
- Word32 *Bin_E_old, /* o: FFT Bin energy 128 sets Q_new + Q_SCALE - 2 */
- Word16 *mem_syn_bck, /* o: synthesis filter memory ( 15 - st_fx->hLPDmem->e_mem_syn ) */
- Word16 *mem_w0_bck, /* o: memory of the weighting filter ( 15 - st_fx->hLPDmem->e_mem_syn ) */
- Word16 *streaklimit, /* Q15 */
+ Word16 *lsp_new, /* i: LSP vector to quantize Q15 */
+ Word16 *lsp_mid, /* i: mid-frame LSP vector Q15 */
+ Word16 *clip_var, /* o: pitch clipping state var Q(2.56) */
+ Word16 *mem_AR, /* o: quantizer memory for AR model Q(2.56) */
+ Word16 *mem_MA, /* o: quantizer memory for AR model Q(2.56) */
+ Word16 *lsp_new_bck, /* o: LSP vector to quantize- backup Q15 */
+ Word16 *lsp_mid_bck, /* o: mid-frame LSP vector - backup Q15 */
+ Word32 *Bin_E, /* o: FFT Bin energy 128 *2 sets Q_new + Q_SCALE - 2 */
+ Word32 *Bin_E_old, /* o: FFT Bin energy 128 sets Q_new + Q_SCALE - 2 */
+ Word16 *mem_syn_bck, /* o: synthesis filter memory ( 15 - st_fx->hLPDmem->e_mem_syn ) */
+ Word16 *mem_w0_bck, /* o: memory of the weighting filter ( 15 - st_fx->hLPDmem->e_mem_syn ) */
+ Word16 *streaklimit, /* Q15 */
Word16 *pstreaklen );
-ivas_error config_acelp1_IVAS(
+ivas_error config_acelp1_fx(
const Word16 enc_dec, /* i : encoder/decoder flag */
const Word32 total_brate, /* i : total bitrate */
const Word32 core_brate_inp, /* i : core bitrate */
@@ -11069,13 +10661,32 @@ ivas_error config_acelp1_IVAS(
const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */
);
+#ifdef DBG_BITSTREAM_ANALYSIS
+#define push_next_indice( ... ) push_next_indice_( __func__, __VA_ARGS__ )
+#define push_next_bits( ... ) push_next_bits_( __func__, __VA_ARGS__ );
+#endif
+
+#ifdef DBG_BITSTREAM_ANALYSIS
+ivas_error push_next_indice_(
+#else
ivas_error push_next_indice(
+#endif
+#ifdef DBG_BITSTREAM_ANALYSIS
+ const char *caller,
+#endif
BSTR_ENC_HANDLE hBstr,
UWord16 value, /* i : value of the quantized indice */
Word16 nb_bits /* i : number of bits used to quantize the indice */
);
+#ifdef DBG_BITSTREAM_ANALYSIS
+ivas_error push_next_bits_(
+#else
ivas_error push_next_bits(
+#endif
+#ifdef DBG_BITSTREAM_ANALYSIS
+ const char *caller,
+#endif
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
const UWord16 bits[], /* i : bit buffer to pack, sequence of single bits */
const Word16 nb_bits /* i : number of bits to pack */
@@ -11212,7 +10823,7 @@ Word16 msvq_stage1_dct_recalc_candidates_fdcng_wb_fx(
const Word16 st1_syn_vec_e, /* i : exp for IDCT24 synthesis vectors */
const Word32 *u_fx, /* i : target signal */
const Word16 u_e, /* i : exp for target signal */
- const int16_t maxC_st1, /* i : number of candidates in stage1 */
+ const Word16 maxC_st1, /* i : number of candidates in stage1 */
Word32 *dist_ptr_fx, /* i/o: updated MSE vector for stage1 */
Word16 *dist_ptr_e /* i/o: exp for updated MSE vector for stage1 */
);
@@ -11285,69 +10896,42 @@ void WriteToBitstream_ivas_fx(
* MODE1 prototypes
*----------------------------------------------------------------------------------*/
-/*! r: inverse square root of input value */
-float inv_sqrt(
- const float x /* i : input value */
-);
-
/*! r: output random value */
-int16_t own_random(
- int16_t *seed /* i/o: random seed */
-);
-
-/*! r: sign of x (+1/-1) */
-float sign(
- const float x /* i : input value of x */
-);
-
-/*! r: logarithm2 of x */
-float log2_f(
- const float x /* i : input value of x */
+Word16 own_random(
+ Word16 *seed /* i/o: random seed */
);
-int16_t norm_ul_float(
- uint32_t UL_var1 );
+Word16 norm_ul_float(
+ UWord32 UL_var1 );
/*! r: sum of all vector elements */
-int16_t sum_s(
- const int16_t *vec, /* i : input vector */
- const int16_t lvec /* i : length of input vector */
+Word16 sum_s(
+ const Word16 *vec, /* i : input vector */
+ const Word16 lvec /* i : length of input vector */
);
/*! r: sum of all vector elements */
-int32_t sum_l(
- const int32_t *vec, /* i : input vector */
- const int16_t lvec /* i : length of input vector */
-);
-
-/*! r: sum of all squared vector elements */
-float sum2_f(
- const float *vec, /* i : input vector */
- const int16_t lvec /* i : length of input vector */
+Word32 sum_l(
+ const Word32 *vec, /* i : input vector */
+ const Word16 lvec /* i : length of input vector */
);
void set_c(
- int8_t y[], /* i/o: Vector to set */
- const int8_t a, /* i : Value to set the vector to */
- const int32_t N /* i : Length of the vector */
+ Word8 y[], /* i/o: Vector to set */
+ const Word8 a, /* i : Value to set the vector to */
+ const Word32 N /* i : Length of the vector */
);
void set_s(
- int16_t y[], /* i/o: Vector to set */
- const int16_t a, /* i : Value to set the vector to */
- const int16_t N /* i : Lenght of the vector */
+ Word16 y[], /* i/o: Vector to set */
+ const Word16 a, /* i : Value to set the vector to */
+ const Word16 N /* i : Lenght of the vector */
);
void set_l(
- int32_t y[], /* i/o: Vector to set */
- const int32_t a, /* i : Value to set the vector to */
- const int16_t N /* i : Length of the vector */
-);
-
-void set_f(
- float y[], /* i/o: Vector to set */
- const float a, /* i : Value to set the vector to */
- const int16_t N /* i : Lenght of the vector */
+ Word32 y[], /* i/o: Vector to set */
+ const Word32 a, /* i : Value to set the vector to */
+ const Word16 N /* i : Length of the vector */
);
void set_zero_fx(
@@ -11364,52 +10948,26 @@ void set16_zero_fx(
);
void set_zero(
- float *vec, /* o : input vector */
- const int16_t lvec /* i : length of the vector */
+ float *vec, /* o : input vector */
+ const Word16 lvec /* i : length of the vector */
);
void mvr2r(
const float x[], /* i : input vector */
float y[], /* o : output vector */
- const int16_t n /* i : vector size */
+ const Word16 n /* i : vector size */
);
void mvs2s(
- const int16_t x[], /* i : input vector */
- int16_t y[], /* o : output vector */
- const int16_t n /* i : vector size */
-);
-
-uint32_t mvr2s(
- const float x[], /* i : input vector */
- int16_t y[], /* o : output vector */
- const int16_t n /* i : vector size */
-);
-
-void mvs2r(
- const int16_t x[], /* i : input vector */
- float y[], /* o : output vector */
- const int16_t n /* i : vector size */
+ const Word16 x[], /* i : input vector */
+ Word16 y[], /* o : output vector */
+ const Word16 n /* i : vector size */
);
void mvl2l(
- const int32_t x[], /* i : input vector */
- int32_t y[], /* o : output vector */
- const int16_t n /* i : vector size */
-);
-
-
-/*! r: index of the maximum value in the input vector */
-int16_t maximum(
- const float *vec, /* i : input vector */
- const int16_t lvec, /* i : length of input vector */
- float *max_val /* o : maximum value in the input vector */
-);
-/*! r: index of the maximum value in the input vector */
-int16_t maximumAbs(
- const float *vec, /* i : input vector */
- const int16_t lvec, /* i : length of input vector */
- float *max_val /* o : maximum value in the input vector */
+ const Word32 x[], /* i : input vector */
+ Word32 y[], /* o : output vector */
+ const Word16 n /* i : vector size */
);
Word16 maximumAbs_l(
@@ -11419,63 +10977,22 @@ Word16 maximumAbs_l(
);
/*! r: index of the minimum value in the input vector */
-int16_t minimum(
- const float *vec, /* i : input vector */
- const int16_t lvec, /* i : length of input vector */
- float *min_val /* o : minimum value in the input vector */
-);
-
-/*! r: index of the minimum value in the input vector */
-int16_t minimum_s(
- const int16_t *vec, /* i : Input vector */
- const int16_t lvec, /* i : Vector length */
- int16_t *min_val /* o : minimum value in the input vector */
-);
-
-/*! r: return index with max energy value in vector */
-int16_t emaximum(
- const float *vec, /* i : input vector */
- const int16_t lvec, /* i : length of input vector */
- float *ener_max /* o : maximum energy value */
-);
-
-/*! r: vector mean */
-float mean(
- const float *vec, /* i : input vector */
- const int16_t lvec /* i : length of input vector */
-);
-
-/*! r: dot product of x[] and y[] */
-float dotp(
- const float x[], /* i : vector x[] */
- const float y[], /* i : vector y[] */
- const int16_t n /* i : vector length */
-);
-
-void v_add(
- const float x1[], /* i : Input vector 1 */
- const float x2[], /* i : Input vector 2 */
- float y[], /* o : Output vector that contains vector 1 + vector 2 */
- const int16_t N /* i : Vector length */
-);
-
-void v_sub(
- const float x1[], /* i : Input vector 1 */
- const float x2[], /* i : Input vector 2 */
- float y[], /* o : Output vector that contains vector 1 - vector 2 */
- const int16_t N /* i : Vector length */
+Word16 minimum_s(
+ const Word16 *vec, /* i : Input vector */
+ const Word16 lvec, /* i : Vector length */
+ Word16 *min_val /* o : minimum value in the input vector */
);
/*! r: dequanzited gain */
float usdequant(
- const int16_t idx, /* i : quantizer index */
- const float qlow, /* i : lowest codebook entry (index 0) */
- const float delta /* i : quantization step */
+ const Word16 idx, /* i : quantizer index */
+ const float qlow, /* i : lowest codebook entry (index 0) */
+ const float delta /* i : quantization step */
);
void sort(
- uint16_t *x, /* i/o: Vector to be sorted */
- uint16_t len /* i/o: vector length */
+ UWord16 *x, /* i/o: Vector to be sorted */
+ UWord16 len /* i/o: vector length */
);
void sort_l(
@@ -11486,18 +11003,24 @@ void sort_l(
ivas_error push_indice(
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- int16_t id, /* i : ID of the indice */
- uint16_t value, /* i : value of the quantized indice */
- int16_t nb_bits /* i : number of bits used to quantize the indice */
+ Word16 id, /* i : ID of the indice */
+ UWord16 value, /* i : value of the quantized indice */
+ Word16 nb_bits /* i : number of bits used to quantize the indice */
);
-ivas_error push_next_indice(
+ivas_error push_next_indice_(
+#ifdef DBG_BITSTREAM_ANALYSIS
+ const char *caller,
+#endif
BSTR_ENC_HANDLE hBstr,
UWord16 value, /* i : value of the quantized indice */
Word16 nb_bits /* i : number of bits used to quantize the indice */
);
-ivas_error push_next_bits(
+ivas_error push_next_bits_(
+#ifdef DBG_BITSTREAM_ANALYSIS
+ const char *caller,
+#endif
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
const UWord16 bits[], /* i : bit buffer to pack, sequence of single bits */
const Word16 nb_bits /* i : number of bits to pack */
@@ -11510,8 +11033,8 @@ Word16 get_ivas_max_num_indices_fx(
);
/*! r: maximum number of indices */
-int16_t get_BWE_max_num_indices(
- const int32_t extl_brate /* i : extensiona layer bitrate */
+Word16 get_BWE_max_num_indices(
+ const Word32 extl_brate /* i : extensiona layer bitrate */
);
/*! r: maximum number of indices */
@@ -11520,9 +11043,9 @@ Word16 get_ivas_max_num_indices_metadata_fx(
const Word32 ivas_total_brate /* i : IVAS total bitrate */
);
ivas_error ind_list_realloc(
- INDICE_HANDLE old_ind_list, /* i : pointer to the beginning of the old buffer of indices */
- const int16_t max_num_indices, /* i : new maximum number of allowed indices in the list */
- Encoder_Struct *st_ivas /* i : IVAS encoder structure */
+ INDICE_HANDLE old_ind_list, /* i : pointer to the beginning of the old buffer of indices */
+ const Word16 max_num_indices, /* i : new maximum number of allowed indices in the list */
+ Encoder_Struct *st_ivas /* i : IVAS encoder structure */
);
ivas_error check_ind_list_limits(
@@ -11532,44 +11055,44 @@ ivas_error check_ind_list_limits(
void move_indices(
INDICE_HANDLE old_ind_list, /* i/o: old location of indices */
INDICE_HANDLE new_ind_list, /* i/o: new location of indices */
- const int16_t nb_indices /* i : number of moved indices */
+ const Word16 nb_indices /* i : number of moved indices */
);
/*! r: index of the indice in the list, -1 if not found */
-int16_t find_indice(
+Word16 find_indice(
BSTR_ENC_HANDLE hBstr, /* i : encoder bitstream handle */
- const int16_t id, /* i : ID of the indice */
- uint16_t *value, /* o : value of the quantized indice */
- int16_t *nb_bits /* o : number of bits used to quantize the indice */
+ const Word16 id, /* i : ID of the indice */
+ UWord16 *value, /* o : value of the quantized indice */
+ Word16 *nb_bits /* o : number of bits used to quantize the indice */
);
/*! r: number of deleted indices */
-uint16_t delete_indice(
+UWord16 delete_indice(
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const int16_t id /* i : ID of the indice */
+ const Word16 id /* i : ID of the indice */
);
/*! r: value of the indice */
-uint16_t get_next_indice(
+UWord16 get_next_indice(
Decoder_State *st, /* i/o: decoder state structure */
- int16_t nb_bits /* i : number of bits that were used to quantize the indice */
+ Word16 nb_bits /* i : number of bits that were used to quantize the indice */
);
/*! r: value of the indice */
-uint16_t get_next_indice_1(
+UWord16 get_next_indice_1(
Decoder_State *st /* i/o: decoder state structure */
);
void get_next_indice_tmp(
Decoder_State *st, /* o : decoder state structure */
- int16_t nb_bits /* i : number of bits that were used to quantize the indice */
+ Word16 nb_bits /* i : number of bits that were used to quantize the indice */
);
/*! r: value of the indice */
-uint16_t get_indice(
+UWord16 get_indice(
Decoder_State *st, /* i/o: decoder state structure */
- int16_t pos, /* i : absolute position in the bitstream */
- int16_t nb_bits /* i : number of bits that were used to quantize the indice */
+ Word16 pos, /* i : absolute position in the bitstream */
+ Word16 nb_bits /* i : number of bits that were used to quantize the indice */
);
void reset_indices_dec(
@@ -11578,7 +11101,7 @@ void reset_indices_dec(
Word16 rate2EVSmode_float(
const Word32 brate, /* i : bitrate */
- int16_t *is_amr_wb /* o : (flag) does the bitrate belong to AMR-WB? Can be NULL */
+ Word16 *is_amr_wb /* o : (flag) does the bitrate belong to AMR-WB? Can be NULL */
);
@@ -11605,13 +11128,13 @@ void mdct_switching_dec_fx(
Decoder_State *st /* i/o: decoder state structure */
);
-int16_t print_disclaimer(
+Word16 print_disclaimer(
FILE *fPtr );
void fft_rel(
- float x[], /* i/o: input/output vector */
- const int16_t n, /* i : vector length */
- const int16_t m /* i : log2 of vector length */
+ float x[], /* i/o: input/output vector */
+ const Word16 n, /* i : vector length */
+ const Word16 m /* i : log2 of vector length */
);
void preemph_ivas_fx(
@@ -11624,8 +11147,8 @@ void preemph_ivas_fx(
void create_offset(
UWord32 *offset_scale1,
UWord32 *offset_scale2,
- const int16_t mode,
- const int16_t prediction_flag );
+ const Word16 mode,
+ const Word16 prediction_flag );
void BASOP_cfft_ivas(
Word32 *re, /* i/o: real part */
@@ -11646,31 +11169,6 @@ Word32 Mult_32_32(
Word32 a,
Word32 b );
-
-void bit_allocation_second_fx2(
- Word32 *Rk,
- Word32 *Rk_sort,
- Word16 BANDS,
- const Word16 *band_width,
- Word16 *k_sort,
- Word16 *k_num,
- const Word16 *p2a_flags,
- const Word16 p2a_bands,
- const Word16 *last_bitalloc,
- const Word16 input_frame );
-
-void bit_allocation_second_fx2(
- Word32 *Rk,
- Word32 *Rk_sort,
- Word16 BANDS,
- const Word16 *band_width,
- Word16 *k_sort,
- Word16 *k_num,
- const Word16 *p2a_flags,
- const Word16 p2a_bands,
- const Word16 *last_bitalloc,
- const Word16 input_frame );
-
#ifdef DEBUGGING
void read_next_force(
int16_t *force, /* i/o: force value (0/1, 0 = speech, 1 = music)*/
@@ -11870,31 +11368,31 @@ void writeTCXWindowing_fx(
);
void writeLPCparam(
- Encoder_State *st, /* i/o: encoder state structure */
- BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
- const int16_t param_lpc[], /* i : LPC parameters to write */
- const int16_t bits_param_lpc[], /* i : bits per LPC parameter */
- const int16_t no_param_lpc, /* i : number of LPC parameters */
- int16_t *nbits_lpc /* o : LPC bits written */
+ 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 */
);
-void const *GetTnsOnWhite( void const *p, const int16_t index, int16_t *pValue );
-void *SetTnsOnWhite( void *p, const int16_t index, const int16_t value );
-void const *GetNumOfTnsFilters_flt( void const *p, const int16_t index, int16_t *pValue );
-void *SetNumOfTnsFilters_flt( void *p, const int16_t index, const int16_t value );
+void const *GetTnsOnWhite( void const *p, const Word16 index, Word16 *pValue );
+void *SetTnsOnWhite( void *p, const Word16 index, const Word16 value );
+void const *GetNumOfTnsFilters_flt( void const *p, const Word16 index, Word16 *pValue );
+void *SetNumOfTnsFilters_flt( void *p, const Word16 index, const Word16 value );
-int16_t DecodeSWBTCX10TnsFilterCoeff_flt( Decoder_State *st, const int16_t index, int16_t *pValue );
-int16_t DecodeSWBTCX20TnsFilterCoeff_flt( Decoder_State *st, const int16_t index, int16_t *pValue );
+Word16 DecodeSWBTCX10TnsFilterCoeff_flt( Decoder_State *st, const Word16 index, Word16 *pValue );
+Word16 DecodeSWBTCX20TnsFilterCoeff_flt( Decoder_State *st, const Word16 index, Word16 *pValue );
-int16_t DecodeWBTCX20TnsFilterCoeff_flt( Decoder_State *st, const int16_t index, int16_t *pValue );
+Word16 DecodeWBTCX20TnsFilterCoeff_flt( Decoder_State *st, const Word16 index, Word16 *pValue );
-int16_t DecodeTnsFilterOrderSWBTCX10_flt( Decoder_State *st, const int16_t index, int16_t *pValue );
-int16_t DecodeTnsFilterOrderSWBTCX20_flt( Decoder_State *st, const int16_t index, int16_t *pValue );
+Word16 DecodeTnsFilterOrderSWBTCX10_flt( Decoder_State *st, const Word16 index, Word16 *pValue );
+Word16 DecodeTnsFilterOrderSWBTCX20_flt( Decoder_State *st, const Word16 index, Word16 *pValue );
-int16_t EncodeTnsFilterOrderSWBTCX10_flt( const int16_t value, const int16_t index );
+Word16 EncodeTnsFilterOrderSWBTCX10_flt( const Word16 value, const Word16 index );
-int16_t GetTnsFilterOrderBitsSWBTCX10_flt( const int16_t value, const int16_t index );
-int16_t DecodeTnsFilterOrder_flt( Decoder_State *st, const int16_t index, int16_t *pValue );
+Word16 GetTnsFilterOrderBitsSWBTCX10_flt( const Word16 value, const Word16 index );
+Word16 DecodeTnsFilterOrder_flt( Decoder_State *st, const Word16 index, Word16 *pValue );
void ResetTnsData_flt(
STnsData *pTnsData );
@@ -11947,7 +11445,7 @@ void analysisCldfbEncoder_ivas_fx(
ivas_error openCldfb_ivas(
HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: filter bank handle */
CLDFB_TYPE type, /* i : analysis or synthesis */
- const int32_t sampling_rate, /* i : sampling rate */
+ const Word32 sampling_rate, /* i : sampling rate */
CLDFB_PROTOTYPE prototype /* i : CLDFB version (1.25ms/5ms delay) */
);
diff --git a/lib_com/rom_com.c b/lib_com/rom_com.c
index a5c8a3b7c65d8747e20b83f4afa8205438fe54ac..1f43b3d1f571026c56005c607b2062463e00cb74 100644
--- a/lib_com/rom_com.c
+++ b/lib_com/rom_com.c
@@ -1273,28 +1273,6 @@ const Word16 sin_table256_fx[] =
* 1/4 resolution interpolation filter (-3 dB at 0.913*fs/2)
*----------------------------------------------------------------------------------*/
-
-const Word16 inter4_2_fx_Q15[65] =
-{//Q15
- 30801,
- 28062, 20718, 11061, 1935,
- -4294, -6533, -5195, -1846,
- 1559, 3497, 3398, 1705,
- -497, -2087, -2413, -1523,
- -32, 1252, 1741, 1312,
- 305, -710, -1237, -1087,
- -426, 350, 848, 862,
- 452, -119, -550, -650,
- -418, -17, 330, 462,
- 349, 85, -175, -306,
- -265, -104, 76, 184,
- 182, 93, -20, -98,
- -110, -66, -3, 43,
- 55, 37, 8, -13,
- -20, -14, -4, 2,
- 3, 1, 0, 0,
-};
-
const Word16 inter4_2_fx[] =
{//evs table , some mismatch in values compared to float is observed
0, 1, 2, 1,
@@ -1332,6 +1310,18 @@ const Word16 inter4_2_fx[] =
};
/* 1/4 resolution interpolation filter (-3 dB at 0.856*fs/2) */
+const Word32 L_pitch_inter4_2[PIT_FIR_SIZE2] = { /* Q31 */
+ 2018634624, 1839083520, 1357785216, 724904576, 126856152, -281447072,
+ -428193216, -340524320, -121030032, 102233104, 229241728, 222704784,
+ 111802296, -32603096, -136805440, -158183648, -99851544, -2110976,
+ 82091856, 114123720, 86026048, 19988778, -46544560, -81104016,
+ -71266392, -27977416, 22982370, 55621972, 56517476, 29680372,
+ -7827578, -36105644, -42638288, -27414776, -1138166, 21646636,
+ 30326764, 22885734, 5570572, -11516955, -20066088, -17396766,
+ -6833293, 5003637, 12101070, 11944304, 6107443, -1346472, -6427418,
+ -7219840, -4389456, -249108, 2823941, 3633542, 2471753, 556198,
+ -895500, -1327144, -932007, -285615, 135291, 210453, 103079, 15032, 0
+};
const Word16 pitch_inter4_2[PIT_FIR_SIZE2] =
{
/* cut-off frequency at 0.94*fs/2 */
@@ -1354,6 +1344,13 @@ const Word16 pitch_inter4_2[PIT_FIR_SIZE2] =
3/*0.000098f Q15*/, 2/*0.000048f Q15*/, 0/*0.000007f Q15*/, 0/*0.000000f Q15*/
};
/* 1/4 resolution interpolation filter (-3 dB at 0.791*fs/2) */
+const Word32 L_pitch_inter4_1[UP_SAMP * L_INTERPOL1 + 1] = /* Q31 */
+{
+ 1932735283, 1758701061, 1298905484, 711630983, 180298432, -162768528,
+ -280712608, -226956816, -100446400, 9592809, 59676424, 55065776,
+ 26996016, 4138201, -3373696, -1617055, 0
+};
+/* 1/4 resolution interpolation filter (-3 dB at 0.791*fs/2) */
const Word16 pitch_inter4_1[UP_SAMP * L_INTERPOL1 + 1] =
{
29491/*0.900000F Q15*/,
@@ -5197,6 +5194,7 @@ const Word16 freqTable[2] = {20, 40}; // Q0
/* SNR: 109.44, PHASE: 3.500000000000000 */
/* SNR: 109.44, PHASE: 3.500000000000000 */
+#ifndef OPT_IVAS_FILTER_ROM
const Word16 CLDFB80_10_fx[100] = // q = 15 sf = 17036 qsf = 14
{
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -7, -2, 0, 0, 0, -1, 0, 0, 0, -8, -31,
@@ -5432,6 +5430,778 @@ const Word16 LDQMF_60_fx[] = // q = 15 sf = 15391 qsf = 14
-142, -123, -104, -88, -72, -57, -44, -28,
};
+#else /* OPT_IVAS_FILTER_ROM */
+
+const Word32 CLDFB80_10_fx[100] = // q = 30
+{
+ 3584, -2501, -707, 157, -1170, -1038,
+-11, -1944, -1380, 1837, 14727, -9096,
+-1691, -267, 3897, -4705, 419, 4651,
+5275, -6639, -243747, -72521, -17071, 14831,
+-23632, -38285, 18452, -20885, -6245, -281515,
+-1070487, -153329, -20195, -4338, -209848, 194011,
+24972, -5106, -34468, 1151402, -2164680, -832327,
+376720, 1686598, 1844777, 1697325, 2356308, 3037447,
+3248821, 1779296, -1533240, -1713947, 833816, 2751563,
+2421812, 284255, -3540922, -6991555, -10248264, -14642952,
+20031906, 26043234, 34417552, 45928496, 60756732, 78698864,
+98151832, 116245496, 129823136, 136344976, 134601568, 122059576,
+95304000, 53433792, -3371365, -74987256, -160511088, -258343120,
+-366360320, -481533344, 599091264, 714631872, 823505600, 920768896,
+1001735168, 1062249792, 1100603392, 1116473216, 1114030976, 1091249536,
+1031959808, 939413760, 835792512, 727712064, 614651648, 499141824,
+382288320, 266885408, 148867680, 44714176
+};
+
+
+/* SNR: 292.49, PHASE: 2.000000000000000 */
+const Word32 CLDFB80_16_fx[160] = // q = 30
+{ 592, -824, -251, 104, 64, -2,
+-19, 2357, 3222, -18, -2, 75,
+37, -82, -596, 808, 2242, -3035,
+-755, 254, 126, -435, 107, -19350,
+26445, -100, 482, -149, -91, 247,
+2196, -3062, -344117, -158537, -67240, -47926,
+-21715, 16231, 6227, 48320, 46494, 5449,
+17932, -33783, -26258, -13467, -97911, -469416,
+-1317171, -563405, -199456, -118497, -43264, 11679,
+-61886, 64706, -248886, 55869, 3768, 67211,
+64791, 39611, 345778, 1796799, -2314105, -1658358,
+-815220, -115680, 761413, 1616443, 1931089, 1230669,
+1712206, 1949652, 2418775, 2970521, 3179526, 3272216,
+2739046, 1383591, -1186345, -2091284, -1594461, -20541,
+1561481, 2685864, 2822045, 2243697, 1007270, -1321111,
+-3774214, -5979353, -7970747, -10025660, -12576468, -15588057,
+19092548, 22464968, 26489252, 31480652, 37681832, 45115060,
+53868456, 63884792, 75139712, 87185504, 99355152, 110921760,
+121117896, 129158840, 134480400, 136595408, 135565040, 130704096,
+120827352, 105296200, 83827480, 56486836, 23319760, -15680647,
+-60454808, -110775264, -166285472, -226570624, -291114656, -359358976,
+-430528992, -503583200, 577127680, 650096768, 721690560, 790528896,
+855345280, 915113088, 968648896, 1014713216, 1052549440, 1081848192,
+1102232576, 1113723648, 1117499392, 1114694144, 1104247168, 1084392960,
+1047294336, 993703296, 933123072, 868665920, 802559168, 734628416,
+664562240, 593135168, 520952544, 448011680, 375024864, 302909728,
+230463232, 156264608, 85568040, 29877076
+};
+
+
+/* SNR: 89.77, PHASE: 1.500000000000000 */
+const Word32 CLDFB80_20_fx[200] = // q = 30
+{ 1767, -5032, -88, -196, 26, 203,
+-254, -755, -8, 5224, 7569, 3,
+161, -101, 462, -85, -115, 1651,
+-2694, 4755, 4946, -22236, -524, -658,
+65, 469, -402, -1021, 719, -9362,
+12273, -828, -312, 170, -1089, 201,
+407, -7058, 12038, -3893, -327043, -222151,
+-35479, -70712, -44739, -22286, -4950, 10391,
+-6975, 55398, 27635, -7373, 3144, -22481,
+-20586, -25326, -30793, 63871, -118589, -531211,
+-1262671, -706692, -140675, -191397, -107627, -49946,
+-20212, 30609, -145958, 302172, -516943, 139838,
+-27637, 62099, 52144, 58317, 81974, -160536,
+375017, 1963206, -2140127, -2009648, -925313, -652848,
+-36271, 664400, 1339893, 1799274, 1945125, 831665,
+1777056, 1828829, 2078398, 2585601, 2993432, 3154609,
+3289693, 3034094, 2356141, 1146722, -993260, -1911082,
+-2021484, -1182252, 157141, 1427332, 2466905, 2979250,
+2692828, 2193128, 1283653, -616499, -2589952, -4472529,
+-6187298, -7776617, -9380603, -11192438, -13438549, -15899665,
+18725886, 21392202, 24336266, 27874318, 32044188, 37006492,
+42749912, 49318540, 56747120, 64938688, 73960840, 83528888,
+93302528, 102923904, 112017456, 120184144, 127010856, 132191136,
+135478896, 136610544, 135791440, 132663544, 126439184, 116783968,
+103416816, 86239880, 65299188, 40633116, 12229525, -19893306,
+-55715672, -95119752, -137902624, -183892768, -232841840, -284483936,
+-338536576, -394642624, -452297696, -510956224, 569805312, 628294144,
+686151296, 742695360, 797209408, 849073920, 897777728, 942743488,
+983299712, 1018874944, 1049145600, 1073975296, 1093176448, 1106582656,
+1114420736, 1117424512, 1116238848, 1110577792, 1099271424, 1081958528,
+1052270720, 1010577920, 964128448, 914037760, 862118336, 809238464,
+755241024, 699830528, 643231744, 585949312, 528205504, 469954944,
+411440896, 353300032, 295721536, 237791168, 178588864, 119772248,
+66882256, 25081918
+};
+
+
+/* SNR: 89.29, PHASE: 0.833333333333333 */
+const Word32 CLDFB80_30_fx[300] = // q = 30
+{ -298, 3584, 1941, -855, -2501, -18,
+108, -707, 31, 15, 157, 303,
+46, -1170, 5206, 7621, -1038, 39,
+476, -11, -29, -11, -1944, 58,
+-3, -1380, -660, 1053, 1837, -2898,
+-12992, 14727, 8112, -3476, -9096, -22,
+265, -1691, 46, -32, -267, 593,
+210, 3897, 9064, -12976, -4705, -177,
+-1102, 419, 158, 60, 4651, -142,
+-11, 5275, 2753, -4425, -6639, 19639,
+-341195, -243747, -157895, -76329, -72521, -65719,
+-49275, -17071, -21325, -4817, 14831, 27866,
+-1522, -23632, 5019, -51348, -38285, -878,
+59536, 18452, -11251, -36822, -20885, -26546,
+-28596, -6245, -16613, -92408, -281515, -679650,
+-1089989, -1070487, -687312, -252030, -153329, -178007,
+-122647, -20195, -41359, -29533, -4338, 53191,
+-112253, -209848, 617831, -803951, 194011, 106901,
+-106999, 24972, 64775, 70954, -5106, 66493,
+77725, -34468, 24005, 399486, 1151402, 2091330,
+-1945866, -2164680, -1871142, -1133490, -832327, -560635,
+-144700, 376720, 793103, 1258629, 1686598, 1843272,
+1942367, 1844777, 286874, 1790714, 1697325, 1882734,
+2048236, 2356308, 2670961, 2960784, 3037447, 3187788,
+3282834, 3248821, 2972461, 2561469, 1779296, 779690,
+-670109, -1533240, -2023874, -2068454, -1713947, -979306,
+-79112, 833816, 1606493, 2311180, 2751563, 2948543,
+2758276, 2421812, 2144318, 1669907, 284255, -925661,
+-2240403, -3540922, -4767759, -5909822, -6991555, -8035796,
+-9103931, -10248264, -11549851, -13052389, -14642952, -16334399,
+18220558, 20031906, 21872604, 23814234, 26043234, 28516756,
+31295850, 34417552, 37909524, 41736344, 45928496, 50500180,
+55453996, 60756732, 66352956, 72392624, 78698864, 85151696,
+91671536, 98151832, 104484224, 110553528, 116245496, 121424144,
+125981624, 129823136, 132872256, 135069696, 136344976, 136548112,
+135995744, 134601568, 131846392, 127706624, 122059576, 114818808,
+105909512, 95304000, 83010216, 69049472, 53433792, 36159948,
+17222988, -3371365, -25594396, -49478012, -74987256, -102019216,
+-130543792, -160511088, -191851984, -224489536, -258343120, -293333280,
+-329374368, -366360320, -404158112, -442603456, -481533344, -520813312,
+560055680, 599091264, 637996480, 676579264, 714631872, 751940864,
+788293056, 823505600, 857424640, 889902848, 920768896, 949826944,
+976873792, 1001735168, 1024295104, 1044475456, 1062249792, 1077572608,
+1090377088, 1100603392, 1108260608, 1113474048, 1116473216, 1117510400,
+1116725248, 1114030976, 1109119488, 1101598848, 1091249536, 1078932736,
+1059134272, 1031959808, 1003169408, 972174976, 939413760, 905472960,
+870845632, 835792512, 800328576, 764335744, 727712064, 690466496,
+652724672, 614651648, 576357376, 537862912, 499141824, 460206112,
+421184800, 382288320, 343676096, 305305440, 266885408, 228014720,
+188521408, 148867680, 110353960, 74971128, 44714176, 18455688
+};
+
+
+const Word32 CLDFB80_32_fx[320] = // q = 30
+{
+ -1093, 2020, -1500, 75, -3259, -200,
+2, 86, -307, -6, -372, -406,
+686, 39, -1685, 4713, 6814, -1488,
+47, 778, -40, -130, 24, -872,
+225, -5, -116, -556, -123, -751,
+1334, -5815, -17696, 8208, -6989, 239,
+-11912, -669, 1, 206, -738, 0,
+-579, -811, 1617, 569, 3828, 10109,
+-14335, -4601, -628, -1935, 180, 186,
+-69, 2086, -538, 14, 408, 1524,
+585, 3601, -4502, 26170, -348871, -274413,
+-191283, -101650, -55023, -71745, -57839, -39470,
+-16489, -17154, -4618, 1542, 27531, -4838,
+-24078, -6041, -61576, -45939, -4350, 52992,
+-21467, -30551, -47624, -16879, -16327, -28526,
+-30774, 45781, -47861, -103961, -321282, -704888,
+-1065517, -1123685, -707166, -371532, -86309, -196314,
+-147630, -95796, -26567, -30201, -12085, -23646,
+30175, -133297, -186726, 644643, -823106, 165914,
+127129, -77847, 76139, 59764, 84597, 13696,
+44921, 72597, 82827, -180230, 163871, 385660,
+1272552, 2097220, -1940583, -2216918, -1963534, -1312195,
+-811283, -684818, -332127, 81208, 566324, 995811,
+1374732, 1743252, 1885233, 1944746, 1791356, 230889,
+1776037, 1693755, 1848743, 2021967, 2237951, 2554532,
+2866858, 3010232, 3111818, 3235821, 3289505, 3179984,
+2912034, 2438977, 1724392, 733947, -625866, -1486531,
+-1958890, -2094028, -1863598, -1255187, -454123, 425746,
+1212702, 1901282, 2517750, 2869908, 2908450, 2719155,
+2384774, 2140992, 1717492, 398307, -731735, -1939480,
+-3196994, -4359654, -5453402, -6492968, -7485701, -8462297,
+-9485345, -10586349, -11872517, -13293064, -14799378, -16391634,
+18159074, 19878216, 21572990, 23372214, 25384474, 27638258,
+30127980, 32911950, 36012916, 39421380, 43135868, 47172528,
+51552328, 56259572, 61272356, 66530936, 72196904, 78102488,
+84136944, 90243120, 96340328, 102334376, 108124720, 113633800,
+118743656, 123354504, 127384760, 130768192, 133428752, 135331936,
+136411184, 136532064, 136012736, 134791376, 132367184, 128735088,
+123803096, 117494272, 109734136, 100486232, 89749032, 77539936,
+63866580, 48743548, 32160198, 14114131, -5387419, -26313940,
+-48704924, -72531920, -97696000, -124178280, -151940320, -180929216,
+-211078752, -242327632, -274608448, -307853568, -341987136, -376916512,
+-412518528, -448658976, -485200704, -522047808, 558838528, 595432000,
+631934592, 668176768, 703995904, 739213504, 773652800, 807151808,
+839574912, 870801792, 900704320, 929133248, 955922048, 980906240,
+1003949120, 1024962240, 1043881152, 1060686784, 1075342592, 1087794688,
+1097989248, 1105913344, 1111637504, 1115325568, 1117191552, 1117410816,
+1116024960, 1112890624, 1107711872, 1100166016, 1090143104, 1078585600,
+1060024128, 1034545088, 1007817280, 979127552, 948772416, 917237312,
+884973248, 852271488, 819225472, 785777536, 751820160, 717295872,
+682246976, 646793792, 611070144, 575157504, 539069056, 502781984,
+466300064, 429718016, 393203360, 356913536, 320878656, 284927936,
+248740064, 212036736, 174863904, 137843808, 102263632, 69872776,
+42173520, 17586372
+};
+
+
+/* SNR: 81.55, PHASE: 0.500000000000000 */
+const Word32 CLDFB80_40_fx[400] = // q = 30
+{
+-4459, -419, -3627, 1424, -337, -2077,
+303, 18, 81, 159, -711, 9,
+12, -289, -782, 599, -26, 261,
+-439, 2799, 3758, -185, 230, -43,
+682, -21, -75, -29, -55, -1950,
+416, 56, 16, 233, 887, -479,
+680, -2718, -569, -16448, -33103, -1653,
+-16424, 6275, -1401, -7536, 1256, 82,
+202, 378, -1703, -5, -27, -665,
+-1194, 1295, -18, 118, -11445, 11396,
+-15922, 16043, 175, 78, -1655, 102,
+374, 132, 161, 4663, -995, -137,
+-67, -970, -4393, 2058, -3082, 11739,
+-993, 52507, -372470, -339964, -238020, -154668,
+-91227, -39704, -68193, -63466, -52270, -36721,
+-12972, -20431, -6925, 7426, -2361, 29241,
+920, -11369, 13936, -42084, -90219, 4460,
+-7456, 295, 60570, -36066, -9836, -23630,
+-40550, -22839, -11573, -27317, -28142, -21799,
+74247, -37443, -94761, -175261, -418504, -781461,
+-995765, -1274142, -822204, -644197, -320592, -79371,
+-211045, -170432, -131251, -90676, -8615, -38865,
+-25806, 10490, -21115, 43834, -93771, -212052,
+-80067, 687824, -841077, -28319, 196054, 89800,
+-98757, 81413, 22561, 71310, 76947, -1234,
+38817, 69237, 75947, 74313, -220677, 108139,
+388007, 614410, 1602908, 2104013, -1945962, -2345233,
+-2073811, -1788974, -1237042, -801097, -773094, -511061,
+-205272, 126459, 548962, 854332, 1215260, 1516757,
+1754373, 1867886, 1938796, 1938332, 1525725, 104199,
+1696967, 1687208, 1745905, 1910502, 2033618, 2194668,
+2472078, 2712787, 2937869, 3012596, 3095693, 3204093,
+3274808, 3283756, 3148592, 2939051, 2641685, 2031332,
+1549503, 597843, -490013, -1328870, -1713436, -2059616,
+-2084878, -1903964, -1464478, -873102, -195311, 513856,
+1135793, 1697317, 2228107, 2629045, 2909611, 2926214,
+2785543, 2569874, 2293850, 2134485, 1852516, 752397,
+-164140, -1082527, -2067571, -3082101, -4010647, -4913513,
+-5770452, -6592737, -7388101, -8166445, -8966356, -9806266,
+-10700961, -11733450, -12861255, -14030459, -15273330, -16566203,
+17977196, 19420796, 20683474, 22109952, 23560036, 25167814,
+26942868, 28845886, 30930688, 33206692, 35686848, 38368864,
+41237952, 44313740, 47594052, 51099240, 54815852, 58726668,
+62834600, 67067844, 71610536, 76321632, 81103048, 85964624,
+90855304, 95735248, 100552568, 105257896, 109812680, 114164760,
+118253480, 122029112, 125449296, 128468360, 131068744, 133194984,
+134844544, 135983552, 136548480, 136476080, 136056288, 135290432,
+133727152, 131405624, 128303264, 124356992, 119537688, 113797504,
+107116320, 99479544, 90889712, 81356080, 70886368, 59482072,
+47150368, 33884192, 19681098, 4546190, -11521655, -28482206,
+-46395036, -65246120, -84945856, -105504280, -126897840, -149107856,
+-172107808, -195862240, -220341504, -245510512, -271335616, -297782912,
+-324814976, -352387008, -380449280, -408931776, -437767552, -466890752,
+-496221408, -525752320, 555187200, 584450368, 613710272, 642840512,
+671780800, 700438528, 728721728, 756541312, 783807872, 810444608,
+836384512, 861566464, 885927424, 909395008, 931888896, 953321728,
+973609216, 992677120, 1010468928, 1026949632, 1042084096, 1055868544,
+1068286464, 1079312512, 1088916480, 1097072128, 1103772032, 1109042176,
+1112948608, 1115590912, 1117080960, 1117511680, 1116923264, 1115280512,
+1112471040, 1108330880, 1102691712, 1095455872, 1086748672, 1077537920,
+1062688064, 1042243712, 1021432192, 999408768, 976158720, 951869952,
+926793472, 901173760, 875200384, 848982208, 822546624, 795860992,
+768868224, 741522368, 713812928, 685772416, 657463808, 628958848,
+600314432, 571556608, 542686272, 513690592, 484561600, 455329056,
+426060320, 396846880, 367771776, 338869952, 310096864, 281325184,
+252379520, 223109248, 193485184, 163693120, 134192648, 105710896,
+79151352, 55383672, 34725716, 14899882
+};
+
+
+/* SNR: 85.15, PHASE: 0.166666666666667 */
+const Word32 CLDFB80_60_fx[600] = // q = 30
+{ -11638, 1767, -122, 1628, -5032, -196,
+161, -88, -3545, 137, -196, 21,
+36, 26, 132, -1128, 203, 12,
+-29, -254, -97, -286, -755, 689,
+-55, -8, 215, -1583, 5224, -169,
+-595, 7569, -1361, 190, 3, -67,
+788, 161, -43, -20, -101, -32,
+-10, 462, -3064, 321, -85, 24,
+12, -115, 151, -968, 1651, -22,
+-258, -2694, -28, 68, 4755, -32803,
+-51846, 4946, -596, 6086, -22236, -388,
+578, -524, -12974, 673, -658, 65,
+91, 65, 314, -2699, 469, 12,
+-69, -402, -518, -689, -1021, 1669,
+-23, 719, 449, -2322, -9362, 9537,
+-13566, 12273, 3730, -157, -828, 61,
+-1978, -312, 206, 462, 170, 84,
+41, -1089, 7330, -768, 201, -60,
+-41, 407, -660, 3231, -7058, 161,
+771, 12038, 198, -1291, -3893, 106546,
+-387363, -327043, -319712, -213953, -222151, -158504,
+-105319, -35479, -59682, -66733, -70712, -61610,
+-55171, -44739, -31711, -9900, -22286, -19252,
+-9917, -4950, 14172, 3111, 10391, 26566,
+4086, -6975, -13332, -9892, 55398, -89244,
+-120822, 27635, -30751, -9363, -7373, 2810,
+49557, 3144, -15960, 10651, -22481, -39335,
+-43081, -20586, -29742, -8098, -25326, -28071,
+-28128, -30793, -15878, 36414, 63871, -51035,
+-98423, -118589, -196780, -380753, -531211, -867079,
+-924260, -1262671, -1211187, -909700, -706692, -590140,
+-387713, -140675, -90592, -207147, -191397, -163116,
+-139419, -107627, -77449, 8620, -49946, -36329,
+-21446, -20212, 13295, -23389, 30609, 24765,
+-73159, -145958, -228347, -136170, 302172, 622362,
+-742756, -516943, 79533, 208728, 139838, 68780,
+-69177, -27637, 72365, 6204, 62099, 78720,
+81230, 52144, -15436, 27781, 58317, 71170,
+74613, 81974, 55368, -164496, -160536, 180918,
+362005, 375017, 795458, 1461875, 1963206, 2095155,
+-1983049, -2140127, -2301661, -2078197, -2009648, -1702455,
+-1336746, -925313, -815553, -803613, -652848, -461551,
+-265137, -36271, 196856, 518314, 664400, 915382,
+1166217, 1339893, 1585569, 1738976, 1799274, 1890535,
+1933937, 1945125, 1923994, 1665861, 831665, 77564,
+1488037, 1777056, 1688417, 1721975, 1828829, 1937199,
+2017937, 2078398, 2252451, 2437196, 2585601, 2754365,
+2909842, 2993432, 3016599, 3074266, 3154609, 3219375,
+3265044, 3289693, 3277126, 3189837, 3034094, 2902602,
+2709099, 2356141, 1938986, 1632226, 1146722, 418214,
+-305018, -993260, -1403823, -1653092, -1911082, -2083225,
+-2096449, -2021484, -1849083, -1552144, -1182252, -764155,
+-310625, 157141, 627282, 1032601, 1427332, 1788414,
+2142931, 2466905, 2666629, 2856089, 2979250, 2902477,
+2810289, 2692828, 2523008, 2330296, 2193128, 2132550,
+2001086, 1283653, 592123, -15236, -616499, -1241115,
+-1897102, -2589952, -3235046, -3852858, -4472529, -5058432,
+-5630304, -6187298, -6725206, -7257095, -7776617, -8297675,
+-8829816, -9380603, -9952123, -10548511, -11192438, -11919065,
+-12671172, -13438549, -14232061, -15062200, -15899665, -16802572,
+17739412, 18725886, 19625418, 20458448, 21392202, 22346532,
+23310144, 24336266, 25457146, 26639572, 27874318, 29180440,
+30570936, 32044188, 33604364, 35257056, 37006492, 38833420,
+40745368, 42749912, 44846596, 47032812, 49318540, 51704112,
+54183000, 56747120, 59397304, 62137772, 64938688, 67793344,
+70831448, 73960840, 77111768, 80298224, 83528888, 86778376,
+90039080, 93302528, 96541856, 99755032, 102923904, 106027616,
+109066040, 112017456, 114866184, 117592440, 120184144, 122624224,
+124905544, 127010856, 128931552, 130666344, 132191136, 133505016,
+134605360, 135478896, 136120576, 136498544, 136610544, 136390896,
+136106368, 135791440, 135081680, 134039064, 132663544, 130943336,
+128876128, 126439184, 123615464, 120403880, 116783968, 112750168,
+108296544, 103416816, 98114136, 92387688, 86239880, 79676032,
+72697184, 65299188, 57491652, 49271324, 40633116, 31582262,
+22113356, 12229525, 1933215, -8779568, -19893306, -31396530,
+-43338216, -55715672, -68469528, -81601800, -95119752, -109012544,
+-123274624, -137902624, -152887216, -168220960, -183892768, -199892672,
+-216212560, -232841840, -249770272, -266987040, -284483936, -302248800,
+-320270592, -338536576, -357031680, -375740448, -394642624, -413715328,
+-432939744, -452297696, -471766976, -491319872, -510956224, -530689568,
+550314688, 569805312, 589331520, 608841280, 628294144, 647679424,
+666974528, 686151296, 705180416, 724037376, 742695360, 761126400,
+779305216, 797209408, 814818048, 832112192, 849073920, 865685504,
+881927232, 897777728, 913213888, 928211072, 942743488, 956784768,
+970310720, 983299712, 995732352, 1007593856, 1018874944, 1029566592,
+1039655360, 1049145600, 1058033856, 1066312576, 1073975296, 1081012992,
+1087415680, 1093176448, 1098289920, 1102755712, 1106582656, 1109785856,
+1112388096, 1114420736, 1115916544, 1116907776, 1117424512, 1117484800,
+1117091968, 1116238848, 1114897920, 1113026048, 1110577792, 1107500160,
+1103739520, 1099271424, 1094099328, 1088271360, 1081958528, 1076012800,
+1066112832, 1052270720, 1038832960, 1024980800, 1010577920, 995613248,
+980113280, 964128448, 947737280, 931017344, 914037760, 896864896,
+879548544, 862118336, 844591360, 826968768, 809238464, 791384896,
+773390848, 755241024, 736928896, 718455680, 699830528, 681070912,
+662197568, 643231744, 624193216, 605096768, 585949312, 566752640,
+547506176, 528205504, 508844544, 489425088, 469954944, 450450944,
+430937408, 411440896, 391989376, 372605984, 353300032, 334067616,
+314888448, 295721536, 276517248, 257224080, 237791168, 218193616,
+198443888, 178588864, 158737840, 139063920, 119772248, 101121944,
+83411368, 66882256, 51724928, 38009000, 25081918, 11097560
+};
+
+
+/* 5ms delay prototype */
+const Word32 LDQMF_10_fx[] = // q = 30
+{
+ 136778, 68195, -70890, -226890, -352352, -420072,
+-436802, -444543, -506661, -672815, -980068, -1367880,
+-1747442, -2041059, -2171766, -2084001, -1756846, -1205000,
+-470033, 391658, -1352314, -2311012, -3225024, -4068760,
+-4825637, -5483931, -6033975, -6472204, -6808585, -7075060,
+-7325812, -7636335, -8074047, -8676456, -9424478, -10219283,
+-10865228, -11073811, -10475044, -8652076, 5180201, -339904,
+-8224782, -18673422, -31726070, -47229416, -64809980, -83846512,
+-103451368, -122477480, -139540384, -153063904, -161342016, -162639632,
+-155309920, -137908720, -109304704, -68777832, -16099735, 48410956,
+-123867744, -208812656, -301278944, -398795360, -498505440, -597277184,
+-691834048, -778907776, -855407232, -918606592, -966152640, -996390080,
+-1008509056, -1002265344, -978191040, -937540800, -882190336, -814525888,
+-737309056, -653527872, 566225280, 478344672, 392910464, 312395584,
+238918544, 174094816, 118926376, 73749168, 38239292, 11438051,
+-6809585, -17473586, -23179288, -24893300, -23497172, -19904868,
+-15070633, -9938406, -5364481, -2000462
+};
+
+
+const Word32 LDQMF_16_fx[] = // q = 30
+{
+135840, 119105, 61025, -23300, -120396, -217572,
+-303688, -369787, -411986, -431913, -436960, -439365,
+-455121, -500073, -585815, -716339, -910646, -1146410,
+-1392576, -1634245, -1852285, -2026746, -2138911, -2173116,
+-2118583, -1970211, -1728614, -1399460, -992562, -520340,
+3268, 562389, -1169900, -1774888, -2369781, -2945925,
+-3497147, -4018445, -4506032, -4956920, -5368526, -5738270,
+-6064626, -6347064, -6587229, -6790047, -6964112, -7121373,
+-7276728, -7449880, -7659373, -7920485, -8244154, -8633965,
+-9083566, -9574508, -10074442, -10534940, -10894573, -11076715,
+-10992408, -10543848, -9627864, -8139161, 5976364, 3037887,
+-760649, -5491840, -11209240, -17943616, -25700144, -34454400,
+-44150032, -54695840, -65964980, -77789648, -89960896, -102229872,
+-114308392, -125871952, -136561440, -145990880, -153753088, -159424128,
+-162577504, -162794960, -159676832, -152853360, -141995744, -126825840,
+-107126032, -82747424, -53617472, -19744928, 18775524, 61761592,
+-108947912, -159965984, -214394832, -271716064, -331337920, -392605120,
+-454808224, -517194272, -578978880, -639359104, -697528768, -752693376,
+-804086912, -850989824, -892747136, -928791232, -958536704, -981563328,
+-997684800, -1006698432, -1008520640, -1003187328, -990852800, -971782976,
+-946346880, -915003328, -878295040, -836832960, -791284544, -742359104,
+-690793664, -637338560, 582754624, 527645440, 472906400, 419190784,
+367113152, 317241312, 270082016, 226065808, 185534960, 148735312,
+115810224, 86800312, 61646000, 40190228, 22181636, 7245162,
+-4169367, -12156084, -17964338, -21866804, -24101958, -24886370,
+-24433336, -22962478, -20701850, -17885954, -14749119, -11519968,
+-8412224, -5619924, -3298610, -1524161
+};
+
+
+const Word32 LDQMF_20_fx[] = // q = 30
+{
+132095, 130054, 94118, 37811, -32619, -110471,
+-188997, -262715, -325880, -375095, -408842, -427924,
+-435582, -437285, -440062, -452482, -482692, -537287,
+-620381, -731564, -887814, -1074239, -1268925, -1466394,
+-1657422, -1832122, -1980124, -2091724, -2157946, -2171782,
+-2128230, -2024638, -1860817, -1638685, -1362085, -1036418,
+-668022, -263994, 167952, 619489, -1109006, -1594302,
+-2074063, -2544892, -3002259, -3443307, -3865450, -4266665,
+-4645248, -4999899, -5329217, -5631869, -5906959, -6153951,
+-6372928, -6565001, -6732690, -6880012, -7012401, -7136777,
+-7260809, -7394870, -7549043, -7731644, -7949919, -8208793,
+-8510223, -8852171, -9227619, -9624792, -10025312, -10404401,
+-10731825, -10971712, -11081824, -11015548, -10722771, -10150872,
+-9246198, -7954792, 6226194, 4006049, 1251053, -2079213,
+-6018496, -10592059, -15815707, -21694928, -28223572, -35382820,
+-43140436, -51449560, -60249600, -69462792, -78994976, -88734976,
+-98555328, -108312432, -117847120, -126986608, -135542896, -143318016,
+-150106768, -155693424, -159859744, -162387488, -163062224, -161676800,
+-158034768, -151954128, -143271408, -131843832, -117553208, -100308496,
+-80048728, -56744644, -30400730, -1056328, 31212950, 66296312,
+-104051416, -144280880, -186784688, -231313168, -277585056, -325290400,
+-374093504, -423635840, -473540064, -523412928, -572850304, -621440576,
+-668770368, -714429248, -758014656, -799138176, -837430848, -872549376,
+-904183040, -932063424, -955866112, -975368256, -990502784, -1001141248,
+-1007204608, -1008661952, -1005531712, -997881088, -985824192, -969518976,
+-949164608, -924995776, -897283008, -866326016, -832450624, -796003264,
+-757347840, -716859456, -674920448, -631918336, 588261568, 544170240,
+500187776, 456655456, 413899520, 372230592, 331939808, 293293792,
+256529792, 221851008, 189423392, 159373024, 131783696, 106697088,
+84113256, 63991576, 46252108, 30775584, 17400960, 5897692,
+-3242832, -10003035, -15315395, -19324048, -22161874, -23947232,
+-24790774, -24801182, -24088950, -22768174, -20956786, -18774960,
+-16343248, -13780261, -11200397, -8711802, -6413878, -4393110,
+-2713518, -1364255
+};
+
+
+const Word32 LDQMF_30_fx[] = // q = 30
+{
+ 121571, 136778, 125655, 101704, 68195, 26875,
+-20212, -70890, -123705, -176138, -226890, -274106,
+-316253, -352352, -381787, -404297, -420072, -429892,
+-434876, -436802, -437431, -439163, -444543, -456066,
+-476087, -506661, -549091, -604538, -672815, -752814,
+-858037, -980068, -1106184, -1235998, -1367880, -1498945,
+-1626464, -1747442, -1858910, -1957741, -2041059, -2106142,
+-2150372, -2171766, -2168618, -2139643, -2084001, -2001495,
+-1892255, -1756846, -1596236, -1411745, -1205000, -977797,
+-732072, -470033, -193708, 94399, 391658, 694989,
+-1028102, -1352314, -1674661, -1994503, -2311012, -2622127,
+-2927093, -3225024, -3515027, -3796480, -4068760, -4331384,
+-4583784, -4825637, -5056603, -5276176, -5483931, -5679645,
+-5863044, -6033975, -6192384, -6338348, -6472204, -6594554,
+-6706284, -6808585, -6902959, -6991107, -7075060, -7157331,
+-7239857, -7325812, -7418951, -7521577, -7636335, -7765375,
+-7910813, -8074047, -8256089, -8457071, -8676456, -8912695,
+-9163169, -9424478, -9691922, -9959316, -10219283, -10463412,
+-10682245, -10865228, -11000298, -11074417, -11073811, -10983892,
+-10789539, -10475044, -10024687, -9422374, -8652076, -7698111,
+6547450, 5180201, 3585185, 1749124, -339904, -2692689,
+-5318487, -8224782, -11417230, -14899579, -18673422, -22738288,
+-27091010, -31726070, -36635292, -41807760, -47229416, -52884028,
+-58751904, -64809980, -71032152, -77388632, -83846512, -90369776,
+-96918936, -103451368, -109921528, -116280640, -122477480, -128458624,
+-134165992, -139540384, -144523760, -149052944, -153063904, -156492352,
+-159273296, -161342016, -162634320, -163087360, -162639632, -161231616,
+-158806368, -155309920, -150691824, -144905568, -137908720, -129663752,
+-120138088, -109304704, -97142448, -83636416, -68777832, -52564528,
+-35001268, -16099735, 4121304, 25635912, 48410956, 72407360,
+-97584200, -123867744, -151213264, -179552912, -208812656, -238912112,
+-269764832, -301278944, -333357440, -365898336, -398795360, -431938528,
+-465214080, -498505440, -531693760, -564658432, -597277184, -629427584,
+-660987072, -691834048, -721848128, -750911168, -778907776, -805726528,
+-831260224, -855407232, -878071616, -899164800, -918606592, -936328128,
+-952202112, -966152640, -978197888, -988289792, -996390080, -1002471040,
+-1006513664, -1008509056, -1008457600, -1006369728, -1002265344, -996173888,
+-988133504, -978191040, -966401920, -952828672, -937540800, -920615360,
+-902135488, -882190336, -860873664, -838284672, -814525888, -789704064,
+-763927872, -737309056, -709960000, -681994880, -653527872, -624673024,
+595607552, 566225280, 536822976, 507495872, 478344672, 449466912,
+420958208, 392910464, 365412224, 338547584, 312395584, 287029856,
+262517344, 238918544, 216286160, 194665808, 174094816, 154602160,
+136208672, 118926376, 102759984, 87704592, 73749168, 60872400,
+49048000, 38239292, 28404982, 19492542, 11438051, 4150853,
+-1959299, -6809585, -10983833, -14524688, -17473586, -19875174,
+-21764768, -23179288, -24150308, -24711158, -24893300, -24729546,
+-24252922, -23497172, -22497182, -21287720, -19904868, -18383770,
+-16760795, -15070633, -13348427, -11626766, -9938406, -8313092,
+-6779951, -5364481, -4088471, -2966834, -2000462, -1134160
+};
+
+
+const Word32 LDQMF_32_fx[] = // q = 30
+{
+119697, 137151, 128520, 107723, 78400, 41836,
+-442, -46740, -95597, -145201, -193804, -240598,
+-283800, -322316, -355411, -382593, -403699, -418862,
+-428699, -434120, -436480, -437237, -438149, -441391,
+-449045, -463039, -485346, -517326, -560092, -614348,
+-679872, -755580, -854379, -968457, -1086190, -1207329,
+-1330799, -1454135, -1575271, -1691704, -1801098, -1900763,
+-1988263, -2061316, -2117677, -2155275, -2172543, -2168111,
+-2140952, -2090356, -2016155, -1918414, -1797519, -1654212,
+-1489464, -1304576, -1100939, -880095, -643755, -393648,
+-131597, 140303, 419876, 704520, -1017921, -1322020,
+-1624457, -1924758, -2222508, -2515835, -2804014, -3086295,
+-3361992, -3630425, -3891163, -4143616, -4387487, -4622276,
+-4847761, -5063642, -5269495, -5464963, -5649876, -5823971,
+-5987172, -6139337, -6280537, -6410931, -6530943, -6641149,
+-6742439, -6835855, -6922708, -7004445, -7082802, -7159902,
+-7237256, -7317480, -7403834, -7498178, -7602711, -7719257,
+-7849652, -7995245, -8157013, -8335469, -8530447, -8741283,
+-8966383, -9203373, -9449370, -9700315, -9951033, -10195449,
+-10426707, -10637019, -10818085, -10960053, -11052529, -11084311,
+-11043675, -10918394, -10695736, -10362793, -9906464, -9313511,
+-8570674, -7665161, 6586647, 5317833, 3849979, 2171972,
+273875, -1853535, -4218327, -6827112, -9685347, -12796811,
+-16163952, -19787344, -23665996, -27796800, -32174812, -36793016,
+-41642268, -46710992, -51985904, -57451192, -63088408, -68876552,
+-74792144, -80808992, -86898528, -93029584, -99168576, -105279432,
+-111323816, -117260928, -123048216, -128641440, -133992400, -139052160,
+-143773440, -148104208, -151991888, -155383600, -158225792, -160465072,
+-162048320, -162923104, -163038096, -162343200, -160789920, -158332016,
+-154925376, -150528912, -145104496, -138617152, -131035664, -122332640,
+-112485024, -101474136, -89286032, -75911456, -61346324, -45591780,
+-28653996, -10544916, 8718141, 29112362, 50609392, 73176464,
+-96780680, -121357544, -146873168, -173272304, -200494976, -228475968,
+-257145792, -286430368, -316251616, -346527296, -377172096, -408096800,
+-439210240, -470417824, -501623072, -532727936, -563632832, -594237184,
+-624439872, -654140096, -683237312, -711632192, -739226496, -765924288,
+-791632320, -816260416, -839722176, -861935360, -882823040, -902313408,
+-920341952, -936853184, -951735680, -964924736, -976443584, -986251200,
+-994314944, -1000609792, -1005117952, -1007828864, -1008739392, -1007854080,
+-1005185024, -1000751488, -994580096, -986704064, -977163328, -966004416,
+-953279168, -939044864, -923364608, -906306368, -887942656, -868349888,
+-847608448, -825801792, -803016512, -779341120, -754867072, -729686080,
+-703891520, -677576896, -650837184, -623766656, 596524928, 568982144,
+541414592, 513899552, 486520032, 459356832, 432489472, 405994688,
+379947008, 354417408, 329473600, 305178976, 281592608, 258768368,
+236754960, 215594992, 195325728, 175977920, 157575920, 140137536,
+123674336, 108191456, 93687496, 80154992, 67580128, 55943780,
+45219876, 35377480, 26377892, 18179138, 10724362, 3937154,
+-1793747, -6383129, -10375463, -13802420, -16701194, -19108980,
+-21056298, -22573612, -23687536, -24425978, -24814642, -24880884,
+-24650790, -24152456, -23413234, -22462376, -21328340, -20040900,
+-18629038, -17122794, -15550818, -13942058, -12323783, -10723672,
+-9166937, -7678115, -6278687, -4990172, -3829056, -2807491,
+-1918388, -1103400
+};
+
+
+const Word32 LDQMF_40_fx[] = // q = 30
+{
+113206, 137254, 134425, 123146, 105211, 81666,
+53560, 21302, -14069, -51499, -90644, -130324,
+-169687, -208133, -245093, -279677, -311296, -339564,
+-364227, -384972, -401866, -414904, -424383, -430758,
+-434462, -436342, -437086, -437526, -438798, -441921,
+-448029, -458055, -473038, -493889, -521096, -555299,
+-596905, -645667, -701531, -764070, -843495, -933719,
+-1026835, -1122239, -1219597, -1318430, -1417239, -1515133,
+-1610824, -1702996, -1790556, -1872015, -1946188, -2011806,
+-2067738, -2112859, -2146050, -2166539, -2173557, -2166437,
+-2144725, -2108000, -2056211, -1989295, -1907357, -1810628,
+-1699503, -1574446, -1436054, -1285028, -1122103, -948052,
+-763730, -570121, -367947, -158284, 57837, 279329,
+505114, 733496, -987128, -1230885, -1473412, -1714779,
+-1954662, -2192913, -2428356, -2660607, -2889345, -3114179,
+-3334742, -3550687, -3761781, -3967793, -4168400, -4363503,
+-4552806, -4736194, -4913551, -5084693, -5249383, -5407420,
+-5558753, -5703241, -5840790, -5971350, -6094838, -6211308,
+-6320774, -6423390, -6519396, -6609079, -6692852, -6771222,
+-6844809, -6914280, -6980363, -7043921, -7105964, -7167616,
+-7229469, -7292854, -7359781, -7431209, -7508135, -7591745,
+-7682927, -7782628, -7891680, -8010673, -8140087, -8280182,
+-8430924, -8592083, -8763179, -8943293, -9131195, -9325472,
+-9524332, -9725493, -9926142, -10123188, -10313198, -10492333,
+-10656603, -10801577, -10922158, -11013175, -11068951, -11083709,
+-11051345, -10965628, -10820070, -10607987, -10322919, -9958035,
+-9506509, -8961670, -8316717, -7565184, 6702942, 5718827,
+4609517, 3369113, 1992225, 473872, -1190731, -3005819,
+-4975066, -7101637, -9388180, -11836610, -14448347, -17224060,
+-20163764, -23266722, -26531342, -29955288, -33535422, -37267720,
+-41147260, -45168140, -49323552, -53606284, -58007508, -62517548,
+-67125584, -71820016, -76587808, -81415152, -86287160, -91187832,
+-96100320, -101006496, -105887512, -110723520, -115493552, -120176040,
+-124748632, -129188288, -133469680, -137567456, -141458352, -145116032,
+-148513808, -151624560, -154421360, -156876704, -158963328, -160653808,
+-161921024, -162738128, -163078752, -162916896, -162227280, -160985216,
+-159167008, -156749920, -153712208, -150033328, -145694224, -140676912,
+-134964928, -128543672, -121399776, -113521832, -104900488, -95527920,
+-85398544, -74508560, -62856444, -50442808, -37270156, -23343566,
+-8670189, 6740502, 22876916, 39724980, 57268860, 75490816,
+-94376496, -113883272, -134001320, -154702832, -175958544, -197737504,
+-220006032, -242729312, -265870144, -289389664, -313247648, -337401888,
+-361809024, -386424256, -411201216, -436093120, -461051360, -486026816,
+-510969600, -535829088, -560554240, -585093440, -609395008, -633407296,
+-657078592, -680357568, -703193408, -725535424, -747334272, -768541184,
+-789108672, -808990656, -828142272, -846520832, -864084928, -880795968,
+-896616960, -911514304, -925457216, -938417536, -950324992, -961141376,
+-970896128, -979566976, -987136576, -993587776, -998908288, -1003088128,
+-1006120192, -1008000960, -1008729280, -1008307648, -1006741504, -1004039168,
+-1000212096, -995274560, -989243584, -982139008, -973983296, -964801472,
+-954620608, -943470016, -931381312, -918388608, -904527488, -889835648,
+-874352128, -858117568, -841174400, -823565824, -805336512, -786531904,
+-767198144, -747382720, -727132672, -706495808, -685520512, -664254656,
+-642746560, -621047616, 599273536, 577248256, 555196416, 533150944,
+511154144, 489249568, 467478368, 445881248, 424498464, 403368608,
+382529632, 362017792, 341868224, 322114240, 302787552, 283917824,
+265532592, 247657504, 230315568, 213527440, 197311648, 181683920,
+166657488, 152242496, 138447232, 125276624, 112733328, 100817520,
+89526080, 78854768, 68795096, 59337532, 50469688, 42175888,
+34440516, 27241264, 20558124, 14361678, 8619497, 3303077,
+-1288525, -5070930, -8454926, -11459781, -14115485, -16433949,
+-18436136, -20138626, -21555150, -22702724, -23593500, -24242222,
+-24662498, -24867088, -24870766, -24686354, -24328404, -23811232,
+-23148884, -22356736, -21449164, -20441404, -19348716, -18185774,
+-16968062, -15710186, -14426756, -13132428, -11840736, -10565599,
+-9320040, -8115962, -6965903, -5879984, -4867950, -3939393,
+-3097321, -2346408, -1680052, -1007771
+};
+
+
+const Word32 LDQMF_60_fx[] = // q = 30
+{
+ 102336, 132095, 137435, 135349, 130054, 120487,
+108540, 94118, 77297, 58570, 37811, 15643,
+-7974, -32619, -57897, -84046, -110471, -136942,
+-163210, -188997, -214438, -239091, -262715, -285164,
+-306247, -325880, -343923, -360378, -375095, -388054,
+-399325, -408842, -416725, -423037, -427924, -431547,
+-434000, -435582, -436522, -437005, -437285, -437644,
+-438481, -440062, -442703, -446767, -452482, -460182,
+-470154, -482692, -497967, -516093, -537287, -561715,
+-589463, -620381, -654511, -691825, -731564, -775911,
+-829205, -887814, -949148, -1011179, -1074239, -1138341,
+-1203246, -1268925, -1334921, -1400802, -1466394, -1531260,
+-1595082, -1657422, -1717943, -1776350, -1832122, -1884921,
+-1934396, -1980124, -2021834, -2059138, -2091724, -2119241,
+-2141378, -2157946, -2168655, -2173353, -2171782, -2163852,
+-2149388, -2128230, -2100421, -2065896, -2024638, -1976676,
+-1922048, -1860817, -1793099, -1719008, -1638685, -1552286,
+-1460012, -1362085, -1258676, -1150050, -1036418, -918024,
+-795131, -668022, -536993, -402188, -263994, -122679,
+21420, 167952, 316690, 467104, 619489, 773430,
+-945239, -1109006, -1271451, -1433050, -1594302, -1754861,
+-1914784, -2074063, -2232363, -2389328, -2544892, -2698989,
+-2851488, -3002259, -3151251, -3298296, -3443307, -3586211,
+-3726943, -3865450, -4001599, -4135335, -4266665, -4395461,
+-4521664, -4645248, -4766175, -4884420, -4999899, -5112604,
+-5222404, -5329217, -5433113, -5533999, -5631869, -5726641,
+-5818340, -5906959, -5992421, -6074745, -6153951, -6230036,
+-6303010, -6372928, -6439843, -6503845, -6565001, -6623435,
+-6679269, -6732690, -6783804, -6832855, -6880012, -6925506,
+-6969547, -7012401, -7054336, -7095680, -7136777, -7177903,
+-7219120, -7260809, -7303731, -7348340, -7394870, -7443617,
+-7494881, -7549043, -7606393, -7667166, -7731644, -7800142,
+-7872827, -7949919, -8031501, -8117779, -8208793, -8304570,
+-8405066, -8510223, -8619935, -8734017, -8852171, -8974106,
+-9099397, -9227619, -9358364, -9490965, -9624792, -9759051,
+-9892867, -10025312, -10155439, -10282162, -10404401, -10520844,
+-10630426, -10731825, -10823502, -10903968, -10971712, -11025073,
+-11062346, -11081824, -11081759, -11060277, -11015548, -10945697,
+-10848751, -10722771, -10565739, -10375810, -10150872, -9888970,
+-9588053, -9246198, -8861297, -8431401, -7954792, -7429283,
+6854949, 6226194, 5542800, 4803353, 4006049, 3149248,
+2231398, 1251053, 206700, -902968, -2079213, -3323232,
+-4636016, -6018496, -7471561, -8995894, -10592059, -12260527,
+-14001671, -15815707, -17702624, -19662438, -21694928, -23799650,
+-25976100, -28223572, -30541232, -32928052, -35382820, -37904240,
+-40490688, -43140436, -45851544, -48621904, -51449560, -54331840,
+-57266136, -60249600, -63279032, -66351236, -69462792, -72609920,
+-75788648, -78994976, -82224448, -85472704, -88734976, -92006232,
+-95281520, -98555328, -101822272, -105076584, -108312432, -111523680,
+-114704032, -117847120, -120946376, -123995120, -126986608, -129913560,
+-132768248, -135542896, -138230992, -140825344, -143318016, -145701104,
+-147966688, -150106768, -152113232, -153978192, -155693424, -157250816,
+-158642336, -159859744, -160895152, -161740352, -162387488, -162828688,
+-163056176, -163062224, -162839296, -162379936, -161676800, -160722816,
+-159511024, -158034768, -156287280, -154262480, -151954128, -149356496,
+-146464032, -143271408, -139773568, -135965808, -131843832, -127403488,
+-122641048, -117553208, -112136840, -106389392, -100308496, -93892368,
+-87139520, -80048728, -72619504, -64851416, -56744644, -48299972,
+-39518100, -30400730, -20949652, -11167261, -1056328, 9379870,
+20137698, 31212950, 42601076, 54297248, 66296312, 78593112,
+-91185600, -104051416, -117194704, -130607064, -144280880, -158207776,
+-172378736, -186784688, -201415824, -216262032, -231313168, -246558128,
+-261985952, -277585056, -293343616, -309249600, -325290400, -341453376,
+-357725472, -374093504, -390543744, -407062432, -423635840, -440249504,
+-456889088, -473540064, -490187584, -506816896, -523412928, -539960640,
+-556444864, -572850304, -589161600, -605363456, -621440576, -637377600,
+-653159232, -668770368, -684195712, -699420352, -714429248, -729207616,
+-743740992, -758014656, -772014784, -785727168, -799138176, -812234496,
+-825002880, -837430848, -849505856, -861215872, -872549376, -883495616,
+-894043456, -904183040, -913905152, -923200640, -932063424, -940477696,
+-948417216, -955866112, -962841216, -969345024, -975368256, -980905536,
+-985952256, -990502784, -994553344, -998100544, -1001141248, -1003673344,
+-1005694720, -1007204608, -1008202304, -1008687808, -1008661952, -1008125952,
+-1007081664, -1005531712, -1003479040, -1000927424, -997881088, -994344832,
+-990323904, -985824192, -980852096, -975414528, -969518976, -963173312,
+-956385600, -949164608, -941519424, -933459776, -924995776, -916137728,
+-906896448, -897283008, -887308928, -876985984, -866326016, -855341824,
+-844045696, -832450624, -820569472, -808415936, -796003264, -783345088,
+-770455104, -757347840, -744036608, -730535808, -716859456, -703022272,
+-689038016, -674920448, -660685696, -646345600, -631918336, -617424704,
+602927232, 588261568, 573575488, 558872576, 544170240, 529480224,
+514815008, 500187776, 485610624, 471095904, 456655456, 442301536,
+428045760, 413899520, 399874240, 385981024, 372230592, 358633472,
+345199872, 331939808, 318862624, 305977728, 293293792, 280819232,
+268562016, 256529792, 244729552, 233167968, 221851008, 210784624,
+199973840, 189423392, 179137440, 169119664, 159373024, 149900064,
+140703152, 131783696, 123142424, 114780232, 106697088, 98892400,
+91364808, 84113256, 77135992, 70429688, 63991576, 57819020,
+51907328, 46252108, 40848248, 35691672, 30775584, 26091894,
+21637068, 17400960, 13374445, 9548629, 5897692, 2475272,
+-592184, -3242832, -5659970, -7917455, -10003035, -11926348,
+-13696880, -15315395, -16789184, -18123694, -19324048, -20394110,
+-21338122, -22161874, -22868630, -23462238, -23947232, -24327810,
+-24607834, -24790774, -24881324, -24883598, -24801182, -24638338,
+-24399474, -24088950, -23710470, -23268668, -22768174, -22213084,
+-21607820, -20956786, -20264828, -19536176, -18774960, -17986262,
+-17174228, -16343248, -15497611, -14641749, -13780261, -12916498,
+-12055168, -11200397, -10355588, -9525147, -8711802, -7920384,
+-7153632, -6413878, -5706099, -5031208, -4393110, -3792571,
+-3230785, -2713518, -2227977, -1784736, -1364255, -871387
+};
+#endif /* OPT_IVAS_FILTER_ROM */
+
const Word32 rot_vec_delay_re_LDQMF_fx[60] = // q = 31
{
-1518500224, 1518500224, 1518500224, -1518500224, -1518500224, 1518500224, 1518500224, -1518500224, -1518500224, 1518500224, 1518500224, -1518500224, -1518500224, 1518500224,
@@ -20441,42 +21211,42 @@ const Word16 qGains[2][1 << kTcxHmNumGainBits] =
const struct TnsParameters tnsParametersIGF32kHz_LowBR[1] =
{
- { 600, 3, /*1.85f, 0.075f, 4.4f,*/ 237/*1.85f Q7*/, 2458/*0.075f Q15*/,563 /*4.4f Q7*/ }
+ { 600, 3, /*1.85f, 0.075f, 4.4f,*/ 237/*1.85f Q7*/, 15518925/*1.85f Q23*/, 2458/*0.075f Q15*/,563 /*4.4f Q7*/ }
};
const struct TnsParameters tnsParameters32kHz[2] =
{
- { 4500, 3, /*1.35f, 0.0300f, 1.0f ,*/ 173/*1.35f Q7*/, 983/*0.0300f Q15*/, 128/*1.0f Q7*/},
- { 600, 1, /*1.75f, 0.0625f, 4.4f ,*/ 224/*1.75f Q7*/, 2048/*0.0625f Q15*/, 563 /*4.4f Q7*/ }
+ { 4500, 3, /*1.35f, 0.0300f, 1.0f ,*/ 173/*1.35f Q7*/,11324621/*1.35f Q23*/, 983/*0.0300f Q15*/, 128/*1.0f Q7*/},
+ { 600, 1, /*1.75f, 0.0625f, 4.4f ,*/ 224/*1.75f Q7*/,14680064/*1.75f Q23*/, 2048/*0.0625f Q15*/, 563 /*4.4f Q7*/ }
};
const struct TnsParameters tnsParameters32kHz_grouped[2] =
{
- { 8400, 3, /*1.375f, 0.03125f, 1.0f ,*/ 176/*1.375f Q7*/, 1024/*0.03125f Q15*/ , 128/*1.0f Q7*/ },
- { 800, 3, /*1.375f, 0.03125f, 1.0f ,*/ 176/*1.375f Q7*/, 1024/*0.03125f Q15*/ , 128/*1.0f Q7*/}
+ { 8400, 3, /*1.375f, 0.03125f, 1.0f ,*/ 176/*1.375f Q7*/,11534336/*1.375f Q23*/, 1024/*0.03125f Q15*/ , 128/*1.0f Q7*/ },
+ { 800, 3, /*1.375f, 0.03125f, 1.0f ,*/ 176/*1.375f Q7*/,11534336/*1.375f Q23*/, 1024/*0.03125f Q15*/ , 128/*1.0f Q7*/}
};
const struct TnsParameters tnsParameters16kHz[1] =
{
- { 600, 3, /*1.5f, 0.05f, 4.4f,*/ 192/*1.5f Q7*/, 1638/*0.05f Q15*/ ,563 /*4.4f Q7*/ }
+ { 600, 3, /*1.5f, 0.05f, 4.4f,*/ 192/*1.5f Q7*/, 12582912/*1.5f Q23*/, 1638/*0.05f Q15*/ ,563 /*4.4f Q7*/ }
};
const struct TnsParameters tnsParameters16kHz_grouped[2] =
{
- { 4400, 3, /*1.5f, 0.05f, 1.0f,*/ 192/*1.5f Q7*/, 1638/*0.05f Q15*/ , 128/*1.0f Q7*/},
- { 800, 3, /*1.5f, 0.05f, 1.0f,*/ 192/*1.5f Q7*/, 1638/*0.05f Q15*/ , 128/*1.0f Q7*/}
+ { 4400, 3, /*1.5f, 0.05f, 1.0f,*/ 192/*1.5f Q7*/, 12582912/*1.5f Q23*/, 1638/*0.05f Q15*/ , 128/*1.0f Q7*/},
+ { 800, 3, /*1.5f, 0.05f, 1.0f,*/ 192/*1.5f Q7*/, 12582912/*1.5f Q23*/, 1638/*0.05f Q15*/ , 128/*1.0f Q7*/}
};
const struct TnsParameters tnsParameters48kHz_grouped[2] =
{
- { 10400, 3, /*1.375f, 0.03125f, 1.0f,*/ 176/*1.375f Q7*/, 1024/*0.03125f Q15*/ , 128/*1.0f Q7*/},
- { 800, 3, /*1.375f, 0.03125f, 1.0f,*/ 176/*1.375f Q7*/, 1024/*0.03125f Q15*/ , 128/*1.0f Q7*/ }
+ { 10400, 3, /*1.375f, 0.03125f, 1.0f,*/ 176/*1.375f Q7*/,11534336/*1.375f Q23*/, 1024/*0.03125f Q15*/ , 128/*1.0f Q7*/},
+ { 800, 3, /*1.375f, 0.03125f, 1.0f,*/ 176/*1.375f Q7*/,11534336/*1.375f Q23*/, 1024/*0.03125f Q15*/ , 128/*1.0f Q7*/ }
};
const struct TnsParameters tnsParameters32kHz_Stereo[2]=
{
- { 4500, 3, /*1.35f, 0.0300f, 1.0f ,*/ 173/*1.35f Q7*/, 983/*0.0300f Q15*/ , 128/*1.0f Q7*/},
- { 600, 3, /*1.75f, 0.0625f, 4.4f ,*/ 224/*1.75f Q7*/, 2048/*0.0625f Q15*/ ,563 /*4.4f Q7*/ }
+ { 4500, 3, /*1.35f, 0.0300f, 1.0f ,*/ 173/*1.35f Q7*/, 11324621/*1.35f Q23*/, 983/*0.0300f Q15*/ , 128/*1.0f Q7*/},
+ { 600, 3, /*1.75f, 0.0625f, 4.4f ,*/ 224/*1.75f Q7*/,14680064/*1.75f Q23*/, 2048/*0.0625f Q15*/ ,563 /*4.4f Q7*/ }
};
const Word16 tnsAcfWindow_fx[TNS_MAX_FILTER_ORDER] =
diff --git a/lib_com/rom_com.h b/lib_com/rom_com.h
index 73156b9892df5be8df2ea273d450acaf492e1fdc..a0a388bc68d79beea91164fd40e2785ca8472859 100644
--- a/lib_com/rom_com.h
+++ b/lib_com/rom_com.h
@@ -172,15 +172,16 @@ extern const Word32 crit_bands_fx[];
extern const float sincos_t_ext[]; // fft_rel dep
extern const Word16 sincos_t_rad3_fx[]; // Q15
extern const Word16 fft256_read_indexes[]; /* FFT Q0*/
-extern const Word16 inter4_2_fx_Q15[]; // Q15 /* 1/4 resolution interpolation filter */
extern const Word16 inter4_2_fx[];
-extern const Word16 pitch_inter4_1[UP_SAMP * L_INTERPOL1 + 1]; /*1Q14*/
-extern const Word16 pitch_inter4_2[PIT_FIR_SIZE2]; /*1Q14*/
-extern const Word16 Assym_window_W16fx[]; // Q15
-extern const Word16 assym_window_16k_fx[]; // Q15
-extern const Word16 grid50_fx[( GRID50_POINTS - 1 ) / 2 - 1]; // Q15
-extern const Word16 grid40_fx[( GRID40_POINTS - 1 ) / 2 - 1]; // Q15
-extern const Word32 crit_bands_fx[]; /* Table of critical bands Q0*/
+extern const Word16 pitch_inter4_1[UP_SAMP * L_INTERPOL1 + 1]; /*1Q14*/
+extern const Word16 pitch_inter4_2[PIT_FIR_SIZE2]; /*Q15*/
+extern const Word32 L_pitch_inter4_1[UP_SAMP * L_INTERPOL1 + 1]; /*Q31*/
+extern const Word32 L_pitch_inter4_2[PIT_FIR_SIZE2]; /*Q31*/
+extern const Word16 Assym_window_W16fx[]; // Q15
+extern const Word16 assym_window_16k_fx[]; // Q15
+extern const Word16 grid50_fx[( GRID50_POINTS - 1 ) / 2 - 1]; // Q15
+extern const Word16 grid40_fx[( GRID40_POINTS - 1 ) / 2 - 1]; // Q15
+extern const Word32 crit_bands_fx[]; /* Table of critical bands Q0*/
extern const Word16 wind_sss_fx[LEN_WIN_SSS]; // Q15 /*window for modify_sf ana*/
extern const Word16 filter5_39s320_120_fx[]; // Q15
diff --git a/lib_com/rom_com_fx.h b/lib_com/rom_com_fx.h
index 29e7637574ac2d2085f44ff635a71493440b7444..9bf335aac1b8bac51a45ccafc1cc847a0dba6500 100644
--- a/lib_com/rom_com_fx.h
+++ b/lib_com/rom_com_fx.h
@@ -70,7 +70,7 @@ extern const Word16 sin_twiddle_table_25_5_5[25]; // Q15
extern const Word16 cos_twiddle_table_16_8_2[16]; // Q15
extern const Word16 sin_twiddle_table_16_8_2[16]; // Q15
-
+#ifndef OPT_IVAS_FILTER_ROM
extern const Word16 CLDFB80_10_fx[100]; // Q15
extern const Word16 CLDFB80_16_fx[160]; // Q15
extern const Word16 CLDFB80_20_fx[200]; // Q15
@@ -87,6 +87,25 @@ extern const Word16 LDQMF_30_fx[300]; // Q15
extern const Word16 LDQMF_32_fx[320]; // Q15
extern const Word16 LDQMF_40_fx[400]; // Q15
extern const Word16 LDQMF_60_fx[600]; // Q15
+#else /* OPT_IVAS_FILTER_ROM */
+
+extern const Word32 CLDFB80_10_fx[100]; // Q30
+extern const Word32 CLDFB80_16_fx[160]; // Q30
+extern const Word32 CLDFB80_20_fx[200]; // Q30
+extern const Word32 CLDFB80_30_fx[300]; // Q30
+extern const Word32 CLDFB80_32_fx[320]; // Q30
+extern const Word32 CLDFB80_40_fx[400]; // Q30
+extern const Word32 CLDFB80_60_fx[600]; // Q30
+
+/*5ms delay*/
+extern const Word32 LDQMF_10_fx[100]; // Q30
+extern const Word32 LDQMF_16_fx[160]; // Q30
+extern const Word32 LDQMF_20_fx[200]; // Q30
+extern const Word32 LDQMF_30_fx[300]; // Q30
+extern const Word32 LDQMF_32_fx[320]; // Q30
+extern const Word32 LDQMF_40_fx[400]; // Q30
+extern const Word32 LDQMF_60_fx[600]; // Q30
+#endif /* OPT_IVAS_FILTER_ROM */
/* Not used anywhere
extern const Word16 LDQMF_10_enc_fx[100];
extern const Word16 LDQMF_16_enc_fx[160];
diff --git a/lib_com/stat_com.h b/lib_com/stat_com.h
index f99d498027a98db71cfbed521e46712659506917..506d2d1cd7b828ecfbe8d863db3973f0646d87b9 100644
--- a/lib_com/stat_com.h
+++ b/lib_com/stat_com.h
@@ -377,7 +377,8 @@ typedef struct
Word16 *olapBufferAna; /* q_olapBufferAna */ /* points to FD_CNG_DEC->olapBufferAna[FFTLEN] in case of decoder */
Word16 olapBufferAna_fx[FFTLEN]; /* q_olapBufferAna_fx */ /* points to FD_CNG_DEC->olapBufferAna[FFTLEN] in case of decoder */
Word16 olapBufferSynth[FFTLEN]; /* q_olapBuffer */
- Word16 *olapBufferSynth2; /*Q_syn*/ /* points to FD_CNG_DEC->olapBufferSynth2[FFTLEN] in case of decoder */
+ Word16 olapBufferSynth_exp;
+ Word16 *olapBufferSynth2; /*Q_syn*/ /* points to FD_CNG_DEC->olapBufferSynth2[FFTLEN] in case of decoder */
const PWord16 *olapWinAna;
const PWord16 *olapWinSyn;
@@ -557,11 +558,12 @@ typedef struct ParamsBitMap
struct TnsParameters
{
/* Parameters for each TNS filter */
- Word16 startLineFrequency; /* Starting lower frequency of the TNS filter [20..16000] */
- Word16 nSubdivisions; /* Number of spectrum subdivisions in which the filter operates [1..8) */
- Word16 minPredictionGain; /* Minimum prediction gain required to turn on the TNS filter. Exponent = PRED_GAIN_E */
- Word16 minAvgSqrCoef; /* Minimum average square of coefficients required to turn on the TNS filter. Exponent = 0 */
- Word16 minEnergyChange; /* Minimum energy change required to turn on the TNS filter. Exponent = 8 */
+ Word16 startLineFrequency; /* Starting lower frequency of the TNS filter [20..16000] */
+ Word16 nSubdivisions; /* Number of spectrum subdivisions in which the filter operates [1..8) */
+ Word16 minPredictionGain; /* Minimum prediction gain required to turn on the TNS filter. Exponent = PRED_GAIN_E */
+ Word32 minPredictionGain_32; /* Minimum prediction gain required to turn on the TNS filter. Exponent = PRED_GAIN_E */
+ Word16 minAvgSqrCoef; /* Minimum average square of coefficients required to turn on the TNS filter. Exponent = 0 */
+ Word16 minEnergyChange; /* Minimum energy change required to turn on the TNS filter. Exponent = 8 */
};
/**********************************************/
@@ -617,8 +619,11 @@ typedef struct cldfb_filter_bank_struct
Word16 da; /* delay analysis */
CLDFB_PROTOTYPE prototype;
const Word16 *p_filter; /*!< Pointer to filter coefficients */ // Q15
- Word16 p_filter_sf; // Q0
-
+#ifdef OPT_IVAS_FILTER_ROM
+ const Word32 *p_filter_32; /*!< Pointer to filter coefficients */ // Q15
+#else /* OPT_IVAS_FILTER_ROM */
+ Word16 p_filter_sf; // Q0
+#endif /* OPT_IVAS_FILTER_ROM */
/* rotation vectors */
const Word32 *rot_vec_syn_re_fx; // Q29
diff --git a/lib_com/stat_noise_uv_mod_fx.c b/lib_com/stat_noise_uv_mod_fx.c
index 67ca21cd29c3dd2ffae186785dfcd32794b3201f..c259745f2a7266bffbe33207cac60e540cfbc577 100644
--- a/lib_com/stat_noise_uv_mod_fx.c
+++ b/lib_com/stat_noise_uv_mod_fx.c
@@ -330,7 +330,6 @@ void stat_noise_uv_mod_fx(
}
}
}
-
/*--------------------------------------------------------------------*
* stat_noise_uv_mod()
*
@@ -345,7 +344,7 @@ void stat_noise_uv_mod_ivas_fx(
const Word16 *lsp_mid, /* i : LSP vector at 2nd sfr Q=15*/
Word16 *Aq, /* o : A(z) quantized for the 4 subframes Q=12*/
Word16 *exc2, /* i/o: excitation buffer Q=Q_exc*/
- Word16 Q_exc, /* i : Q of exc2 excitation buffer [11..-1] expected */
+ Word16 *Q_exc, /* i : Q of exc2 excitation buffer [11..-1] expected */
const Word16 bfi, /* i : Bad frame indicator */
Word32 *ge_sm, /* i/o: smoothed excitation gain Q=Q_stat_noise_ge (6)*/
Word16 *uv_count, /* i/o: unvoiced counter */
@@ -370,8 +369,9 @@ void stat_noise_uv_mod_ivas_fx(
Word16 oldlsp_mix[M];
Word16 midlsp_mix[M];
Word16 newlsp_mix[M];
- Word16 beta; /* Q15 */
- Word16 Noimix_fract; /* (noimix_fac - 1.0) in Q15 */
+ Word16 beta; /* Q15 */
+ Word16 Noimix_fract; /* (noimix_fac - 1.0) in Q15 */
+ Word32 L_Noimix_fract; /* (noimix_fac - 1.0) in Q15 */
/* noimix_fax * x <-> x + Noimix_fract * x */
Word16 i_subfr;
Word16 i, k;
@@ -382,7 +382,8 @@ void stat_noise_uv_mod_ivas_fx(
Word32 L_tmp_res, L_tmp, L_tmp3, L_Ge;
Word16 En_shift, Tmp;
- Word16 Exc2_local[L_FRAME]; /* local_copy in scaled Q_local*/
+ Word16 Exc2_local[L_FRAME]; /* local_copy in scaled Q_local*/
+ Word32 L_Exc2_local[L_FRAME]; /* local_copy in scaled Q_local*/
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
move32();
@@ -437,9 +438,9 @@ void stat_noise_uv_mod_ivas_fx(
Copy( exc2, Exc2_local, L_FRAME );
/* bound Q for internal use, optimization possible */
- Q_local = s_min( 11, s_max( -1, Q_exc ) );
+ Q_local = s_min( 11, s_max( -1, *Q_exc ) );
/* local excitation Q and incoming excitation Q*/
- Qdiff = sub( Q_local, Q_exc );
+ Qdiff = sub( Q_local, *Q_exc );
/* only shift if incoming Q is outside [11..-1] shift is done in energy calculations aswell */
Scale_sig( Exc2_local, L_FRAME, Qdiff );
/* current excitation Q and previous stat_noise states Q */
@@ -539,14 +540,11 @@ void stat_noise_uv_mod_ivas_fx(
L_tmp_res = L_mac( 0, alpha, alpha );
L_tmp_res = L_mac( L_tmp_res, alpha_m1, alpha_m1 );
tmp_den = round_fx( L_Frac_sqrtQ31( L_tmp_res ) );
-
- tmp_nom = sub( 32767, tmp_den );
- tmp_shift = norm_s( tmp_den );
- tmp_den = shl( tmp_den, tmp_shift );
- tmp_res = div_s( tmp_nom, tmp_den );
-
- Noimix_fract = shr( tmp_res, tmp_shift ); /* float value is in range 0.0 to 0.42 */
-
+ Word16 exp_sqr = 0;
+ move16();
+ tmp_res = BASOP_Util_Divide1616_Scale( 32767, tmp_den, &exp_sqr ); // 15-exp_sqr
+ Noimix_fract = tmp_res; // 15-exp_sqr
+ move16();
/* L_Ge might be 0 in unvoiced WB */
L_Ge = L_max( L_Ge, 1 );
tmp_shift = norm_l( L_Ge );
@@ -555,9 +553,7 @@ void stat_noise_uv_mod_ivas_fx(
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 */
- 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 */
+ L_Noimix_fract = Mult_32_16( L_tmp_res, Noimix_fract ); /*15+15-exp_sqr-15 =15-exp_sqr */
FOR( i = 0; i < L_FRAME; i++ )
{
@@ -573,18 +569,27 @@ 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 */
- L_tmp = L_add_sat( L_tmp3, L_shl_sat( Mult_32_16( L_tmp, tmp_res ), 1 ) ); /* Q_local+16+14-15+1 */
- Exc2_local[i] = extract_h( L_tmp ); /*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_32( L_tmp, L_Noimix_fract ); /* Q_local+16+15-exp_sqr-15 =Q_local +1 */
+ L_Exc2_local[i] = L_add( L_shr( L_tmp3, 1 ), Mpy_32_32( L_tmp, L_tmp_res ) ); // Q_local + 16 +15 -31 = Q_local
+ move32();
+ }
+ Word32 max_val;
+ maximum_abs_32_fx( L_Exc2_local, L_FRAME, &max_val );
+ Word16 shift = 0;
+ move16();
+ IF( GT_32( max_val, ONE_IN_Q15 ) )
+ {
+ shift = norm_l( max_val );
+ shift = sub( Q31 - Q15, shift );
+ *Q_exc = sub( Q_local, shift ); // Q_exc = Q_local -shift
move16();
}
*Q_stat_noise = Q_local; /* update for next call, routine can only be called once every frame */
move16();
- Qdiff = sub( Q_exc, Q_local ); /* local excitation and incoming excitation */
- Scale_sig( Exc2_local, L_FRAME, Qdiff );
- Copy( Exc2_local, exc2, L_FRAME );
+
+ Copy_Scale_sig_32_16( L_Exc2_local, exc2, L_FRAME, negate( shift ) ); // Q_exc
/*--------------------------------------------------------------------*
* Generate low-pass filtered version of ISP coefficients
@@ -635,6 +640,7 @@ void stat_noise_uv_mod_ivas_fx(
}
}
}
+
/*---------------------------------------------------------------------------*
* calc_tilt()
*
diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c
index 5631dfa9420b19ea52b80aa60b7c4ff74fe2354c..2cb51ae93dd6279229e166e17b066b2962e2bee3 100644
--- a/lib_com/swb_tbe_com_fx.c
+++ b/lib_com/swb_tbe_com_fx.c
@@ -2102,22 +2102,7 @@ void GenShapedSHBExcitation_fx(
Word16 n_mem2, /* i : n_mem2 scale factor to adjust 24.4/32kbps memories */
Word16 prev_Q_bwe_syn, /* i : st_fx->prev_Q_bwe_syn */
const Word32 bitrate,
- const Word16 prev_bfi
-#ifdef ADD_IVAS_TBE_CODE
- , /* i : previous frame was concealed */
- const Word16 element_mode, /* i : element mode */
- const Word16 flag_ACELP16k, /* i : ACELP@16kHz flag */
- Word16 *nlExc16k, /* i/o: NL exc for IC-BWE */
- Word16 *mixExc16k, /* i/o: exc spreading for IC-BWE */
- const Word32 extl_brate, /* i : extension layer bitarte */
- const Word16 MSFlag, /* i : Multi Source flag */
- Word16 EnvSHBres_4k[], /* i/o: TD envelope of the SHB residual signal */
- Word16 *prev_pow_exc16kWhtnd, /* i/o: power of the LB excitation signal in the previous frame */
- Word16 *prev_mix_factor, /* i/o: mixing factor in the previous frame */
- Word16 *Env_error, /* o : error in SHB residual envelope modelling*/
- Word16 Env_error_part[] /* o : per-segment error in SHB residual envelope modelling */
-#endif
-)
+ const Word16 prev_bfi )
{
Word16 i, j, k;
Word16 wht_fil_mem[LPC_WHTN_ORDER];
@@ -2160,20 +2145,6 @@ void GenShapedSHBExcitation_fx(
Word16 Q_temp;
Word16 prev_Q_bwe_exc_fb;
-#ifdef ADD_IVAS_TBE_CODE
- Word32 tempD;
- Word16 alpha, step, mem_csfilt_left, mem_csfilt_right, excNoisyEnvLeft[L_FRAME16k], excNoisyEnvRight[L_FRAME16k];
- Word16 cbsize;
- Word16 mix_factor, old_fact, new_fact, fact, old_scale, new_scale, step_scale;
- Word16 c0, c1, c2, c3, c4, c5, g1, g2, g, den;
- Word16 EnvWhiteExc16k[L_FRAME16k], EnvExc16kWhtnd[L_FRAME16k];
- Word16 EnvWhiteExc16k_4k[L_FRAME4k] = { 0 }, EnvExc16kWhtnd_4k[L_FRAME4k] = { 0 };
- Word16 flag_plosive;
- Word16 delta;
- Word16 c0_part[NUM_SHB_SUBGAINS], c1_part[NUM_SHB_SUBGAINS], c2_part[NUM_SHB_SUBGAINS], c3_part[NUM_SHB_SUBGAINS], c4_part[NUM_SHB_SUBGAINS], c5_part[NUM_SHB_SUBGAINS];
-
- mix_factor = 0.0f;
-#endif
set16_fx( zero_mem, 0, LPC_SHB_ORDER );
set16_fx( wht_fil_mem, 0, LPC_WHTN_ORDER );
@@ -2205,12 +2176,7 @@ void GenShapedSHBExcitation_fx(
/* i: exc16k in Q_bwe_exc */
/* o: exc16kWhtnd in Q_bwe_exc */
-
-#ifdef ADD_IVAS_TBE_CODE
- IF( GE_32( extl_brate, SWB_TBE_2k8 ) )
-#else
IF( GE_32( bitrate, ACELP_24k40 ) )
-#endif
{
temp2 = 0;
move16();
@@ -2244,11 +2210,7 @@ void GenShapedSHBExcitation_fx(
Q_pow1 = shl( *Q_bwe_exc, 1 );
test();
-#ifdef ADD_IVAS_TBE_CODE
- IF( EQ_16( flag_ACELP16k, 0 ) )
-#else
IF( ( LE_32( bitrate, ACELP_13k20 ) ) && ( GE_32( bitrate, ACELP_7k20 ) ) )
-#endif
{
/* varEnvShape = mean_fx(voice_factors, 4); */
/* unroll the loop */
@@ -2294,11 +2256,7 @@ void GenShapedSHBExcitation_fx(
test();
test();
test();
-#ifdef ADD_IVAS_TBE_CODE
- IF( EQ_16( element_mode, EVS_MONO ) && *mem_csfilt == 0 && ( ( EQ_32( bitrate, ACELP_9k60 ) ) || ( EQ_32( bitrate, ACELP_16k40 ) ) || ( EQ_32( bitrate, ACELP_24k40 ) ) ) )
-#else
IF( *mem_csfilt == 0 && ( ( EQ_32( bitrate, ACELP_9k60 ) ) || ( EQ_32( bitrate, ACELP_16k40 ) ) || ( EQ_32( bitrate, ACELP_24k40 ) ) ) )
-#endif
{
/* pre-init smoothing filter to avoid energy drop outs */
L_tmp = L_mult( excTmp2[0], 1638 );
@@ -2325,42 +2283,6 @@ void GenShapedSHBExcitation_fx(
*mem_csfilt = Mult_32_16( L_tmp, varEnvShape );
move32();
}
-#ifdef ADD_IVAS_TBE_CODE
- if ( MSFlag > 0 )
- {
- varEnvShape = 0.995f;
- csfilt_num2[0] = 1.0f - varEnvShape;
- csfilt_den2[1] = -varEnvShape;
- }
-
- White_exc16k = exc16k;
-
- /* Track the low band envelope */
- if ( element_mode == IVAS_CPE_TD || element_mode == IVAS_CPE_DFT )
- {
- if ( extl_brate != SWB_TBE_1k10 && extl_brate != SWB_TBE_1k75 )
- {
- mem_csfilt_left = 0.0f;
- mem_csfilt_right = 0.0f;
- for ( k = 0; k < L_FRAME16k; k++ )
- {
- excNoisyEnvLeft[k] = mem_csfilt_left + csfilt_num2[0] * excTmp2[k];
- mem_csfilt_left = -csfilt_den2[1] * excNoisyEnvLeft[k];
- excNoisyEnvRight[L_FRAME16k - k - 1] = mem_csfilt_right + csfilt_num2[0] * excTmp2[L_FRAME16k - k - 1];
- mem_csfilt_right = -csfilt_den2[1] * excNoisyEnvRight[L_FRAME16k - k - 1];
- }
-
- alpha = 0.0f;
- step = 1.0f / L_FRAME16k;
- for ( k = 0; k < L_FRAME16k; k++ )
- {
- excNoisyEnv[k] = alpha * excNoisyEnvLeft[k] + ( 1 - alpha ) * excNoisyEnvRight[k];
- alpha += step;
- }
- }
- }
- else
-#endif
{
/* Track the low band envelope */
L_tmp = *mem_csfilt;
@@ -2376,21 +2298,6 @@ void GenShapedSHBExcitation_fx(
*mem_csfilt = L_tmp;
move32();
}
-#ifdef ADD_IVAS_TBE_CODE
- if ( extl_brate == SWB_TBE_1k10 || extl_brate == SWB_TBE_1k75 )
- {
- /* generate gaussian (white) excitation */
- for ( k = 0; k < L_FRAME16k; k++ )
- {
- White_exc16k[k] = (float) own_random( &bwe_seed[0] );
- }
-
- /* normalize the amplitude of the gaussian excitation to that of the LB exc. */
- pow22 = POW_EXC16k_WHTND;
- v_multc( White_exc16k, (float) sqrt( pow1 / pow22 ), White_exc16k, L_FRAME16k );
- }
- else
-#endif
{
/* create a random excitation - Reuse exc16k memory */
White_exc16k = exc16k;
@@ -2439,98 +2346,10 @@ void GenShapedSHBExcitation_fx(
Q_pow22 = shl( sub( *Q_bwe_exc, NOISE_QADJ ), 1 );
}
-#ifdef ADD_IVAS_TBE_CODE
- flag_plosive = 0;
- move16();
- test();
- test();
- test();
- IF(GE_32(extl_brate, SWB_TBE_2k8) || EQ_32(extl_brate, SWB_TBE_1k10) || EQ_32(extl_brate, SWB_TBE_1k75)))
-#else
IF( GE_32( bitrate, ACELP_24k40 ) )
-#endif
{
IF( EQ_16( *vf_ind, 20 ) ) /* encoder side */
{
-#ifdef ADD_IVAS_TBE_CODE
- if ( extl_brate == SWB_TBE_1k10 || extl_brate == SWB_TBE_1k75 )
- {
- /* calculate TD envelopes of exc16kWhtnd and White_exc16k */
- find_td_envelope( White_exc16k, L_FRAME16k, 20, NULL, EnvWhiteExc16k );
- find_td_envelope( exc16kWhtnd, L_FRAME16k, 20, NULL, EnvExc16kWhtnd );
-
- for ( k = 0; k < L_FRAME4k; k++ )
- {
- EnvWhiteExc16k_4k[k] = EnvWhiteExc16k[4 * k];
- EnvExc16kWhtnd_4k[k] = EnvExc16kWhtnd[4 * k];
- }
-
- /* calculate the optimal mix factor */
- c0 = c1 = c2 = c3 = c4 = c5 = 0.0f;
- for ( i = 0; i < NUM_SHB_SUBGAINS; i++ )
- {
- c0_part[i] = sum2_f( &EnvExc16kWhtnd_4k[i * L_FRAME4k / NUM_SHB_SUBGAINS], L_FRAME4k / NUM_SHB_SUBGAINS );
- c1_part[i] = -2.0f * dotp( &EnvSHBres_4k[i * L_FRAME4k / NUM_SHB_SUBGAINS], &EnvExc16kWhtnd_4k[i * L_FRAME4k / NUM_SHB_SUBGAINS], L_FRAME4k / NUM_SHB_SUBGAINS );
- c2_part[i] = sum2_f( &EnvWhiteExc16k_4k[i * L_FRAME4k / NUM_SHB_SUBGAINS], L_FRAME4k / NUM_SHB_SUBGAINS );
- c3_part[i] = -2.0f * dotp( &EnvSHBres_4k[i * L_FRAME4k / NUM_SHB_SUBGAINS], &EnvWhiteExc16k_4k[i * L_FRAME4k / NUM_SHB_SUBGAINS], L_FRAME4k / NUM_SHB_SUBGAINS );
- c4_part[i] = 2.0f * dotp( &EnvExc16kWhtnd_4k[i * L_FRAME4k / NUM_SHB_SUBGAINS], &EnvWhiteExc16k_4k[i * L_FRAME4k / NUM_SHB_SUBGAINS], L_FRAME4k / NUM_SHB_SUBGAINS );
- c5_part[i] = sum2_f( &EnvSHBres_4k[i * L_FRAME4k / NUM_SHB_SUBGAINS], L_FRAME4k / NUM_SHB_SUBGAINS );
-
- c0 += c0_part[i];
- c1 += c1_part[i];
- c2 += c2_part[i];
- c3 += c3_part[i];
- c4 += c4_part[i];
- c5 += c5_part[i];
- }
-
- den = 4.0f * c0 * c2 - c4 * c4;
- g1 = ( c3 * c4 - 2 * c1 * c2 ) / den;
- g2 = ( c1 * c4 - 2 * c0 * c3 ) / den;
-
- *Env_error = 0.0f;
- flag_plosive = 0;
- for ( i = 0; i < NUM_SHB_SUBGAINS; i++ )
- {
- Env_error_part[i] = c5_part[i] + g1 * g1 * c0_part[i] + g1 * c1_part[i] + g2 * g2 * c2_part[i] + g2 * c3_part[i] + g1 * g2 * c4_part[i];
- *Env_error += Env_error_part[i];
-
- if ( Env_error_part[i] > THR_ENV_ERROR_PLOSIVE )
- {
- /* envelope error is too high -> likely a plosive */
- flag_plosive = 1;
- }
- }
-
- if ( flag_plosive )
- {
- /* plosive detected -> set the mixing factor to 0 */
- *vf_ind = 0;
- mix_factor = 0.0f;
- }
- else
- {
- /* normalize gain */
- g = g2 / ( g1 + g2 );
-
- /* quantization of the mixing factor */
- cbsize = 1 << NUM_BITS_SHB_VF;
- delta = 1.0f / ( cbsize - 1 );
- if ( g > 1.0f )
- {
- g = 1.0f;
- }
- else if ( g < delta )
- {
- /* prevent low gains to be quantized to 0 as this is reserved for plosives */
- g = delta;
- }
-
- *vf_ind = usquant( g, &mix_factor, 0.0f, 1.0f / ( cbsize - 1 ), cbsize );
- }
- }
- else
-#endif
{
Estimate_mix_factors_fx( shb_res, Q_shb, exc16kWhtnd, *Q_bwe_exc, White_exc16k,
( *Q_bwe_exc - NOISE_QADJ ), pow1, Q_pow1, pow22, Q_pow22, voiceFacEst, vf_ind );
@@ -2546,331 +2365,257 @@ void GenShapedSHBExcitation_fx(
}
}
ELSE /* decoder side */
- {
-#ifdef ADD_IVAS_TBE_CODE
- if ( extl_brate == SWB_TBE_1k10 || extl_brate == SWB_TBE_1k75 )
- {
- if ( *vf_ind == 0 )
- {
- mix_factor = 0.0f;
- flag_plosive = 1;
- }
- else
- {
- mix_factor = usdequant( *vf_ind, 0.0f, 1.0f / ( ( 1 << NUM_BITS_SHB_VF ) - 1 ) );
- }
- }
- else
-#endif
{
- /* *vf_ind is an integer scale by 0.125f*/
- tmp = shl( *vf_ind, ( 15 - 3 ) );
- tmp2 = MAX_16;
- move16();
- if ( LE_16( tmp, 22938 /*0.7f Q15*/ ) )
- {
- tmp2 = 26214 /*0.8f Q15*/;
- move16();
- }
- }
- }
-#ifdef ADD_IVAS_TBE_CODE
- IF( NE_32( extl_brate, SWB_TBE_1k10 ) && NE_32( extl_brate, SWB_TBE_1k75 ) )
-#endif
+ { /* *vf_ind is an integer scale by 0.125f*/
+ tmp = shl( *vf_ind, ( 15 - 3 ) );
+ tmp2 = MAX_16;
+ move16();
+ if ( LE_16( tmp, 22938 /*0.7f Q15*/ ) )
{
- voice_factors[0] = mult_r( voice_factors[0], tmp2 );
- move16();
- voice_factors[1] = mult_r( voice_factors[1], tmp2 );
- move16();
- voice_factors[2] = mult_r( voice_factors[2], tmp2 );
- move16();
- voice_factors[3] = mult_r( voice_factors[3], tmp2 );
- move16();
- voice_factors[4] = mult_r( voice_factors[4], tmp2 );
+ tmp2 = 26214 /*0.8f Q15*/;
move16();
}
}
-#ifdef ADD_IVAS_TBE_CODE
- if ( element_mode >= IVAS_CPE_DFT && nlExc16k != NULL )
- {
- /* save buffers for IC-BWE */
- mvr2r( exc16kWhtnd, nlExc16k, L_FRAME16k );
- v_multc( White_exc16k, (float) sqrt( pow1 / pow22 ), mixExc16k, L_FRAME16k );
- }
-#endif
-
- tmp = sub( Q_temp, 3 );
- FOR( k = 0; k < L_FRAME16k; k++ )
- {
- White_exc16k_FB[k] = round_fx( L_shl( White_exc16k_32[k], tmp ) ); /* Q_bwe_exc +5 +1 +Q_temp -16 -3 */
- }
- prev_Q_bwe_exc_fb = *Q_bwe_exc_fb;
+}
+{
+ voice_factors[0] = mult_r( voice_factors[0], tmp2 );
move16();
- *Q_bwe_exc_fb = sub( add( *Q_bwe_exc, Q_temp ), 13 );
+ voice_factors[1] = mult_r( voice_factors[1], tmp2 );
move16();
- deemph_fx( White_exc16k, PREEMPH_FAC, L_FRAME16k, tbe_demph );
- /* i/o: White_exc16k (Q_bwe_exc-NOISE_QADJ) */
- /* i: tbe_demph (Q_bwe_exc-NOISE_QADJ) */
-#ifdef ADD_IVAS_TBE_CODE
- if ( extl_brate == SWB_TBE_1k10 || extl_brate == SWB_TBE_1k75 )
+ voice_factors[2] = mult_r( voice_factors[2], tmp2 );
+ move16();
+ voice_factors[3] = mult_r( voice_factors[3], tmp2 );
+ move16();
+ voice_factors[4] = mult_r( voice_factors[4], tmp2 );
+ move16();
+}
+}
+
+tmp = sub( Q_temp, 3 );
+FOR( k = 0; k < L_FRAME16k; k++ )
+{
+ White_exc16k_FB[k] = round_fx( L_shl( White_exc16k_32[k], tmp ) ); /* Q_bwe_exc +5 +1 +Q_temp -16 -3 */
+}
+prev_Q_bwe_exc_fb = *Q_bwe_exc_fb;
+move16();
+*Q_bwe_exc_fb = sub( add( *Q_bwe_exc, Q_temp ), 13 );
+move16();
+deemph_fx( White_exc16k, PREEMPH_FAC, L_FRAME16k, tbe_demph );
+/* i/o: White_exc16k (Q_bwe_exc-NOISE_QADJ) */
+/* i: tbe_demph (Q_bwe_exc-NOISE_QADJ) */
+{
+ IF( EQ_16( coder_type, UNVOICED ) )
{
- if ( !flag_plosive ) /* use only LB excitation in case of plosives */
+ L_tmp = root_a_over_b_fx( pow1, Q_pow1, pow22, Q_pow22, &exp );
+ scale = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /*Q15 */
+ FOR( k = 0; k < L_FRAME16k; k++ )
{
- /* re-scale gaussian excitation at the beginning to gradually move from old energy to new energy */
- old_scale = (float) sqrt( *prev_pow_exc16kWhtnd / pow1 );
- new_scale = 1.0f;
- step_scale = ( new_scale - old_scale ) / ( L_FRAME16k / 2 );
- scale = old_scale;
-
- /* interpolate between the old and the new value of the mixing factor */
- old_fact = *prev_mix_factor;
- new_fact = mix_factor;
- step = ( new_fact - old_fact ) / ( L_FRAME16k / 2 );
- fact = old_fact;
-
- /* mixing of LB and gaussian excitation in the first half of the frame */
- for ( k = 0; k < L_FRAME16k / 2; k++ )
- {
- exc16kWhtnd[k] = (float) fact * ( White_exc16k[k] * scale ) + (float) ( 1 - fact ) * exc16kWhtnd[k];
- fact += step;
- scale += step_scale;
- }
-
- /* mixing of LB and gaussian excitation in the second half of the frame */
- for ( ; k < L_FRAME16k; k++ )
- {
- exc16kWhtnd[k] = (float) new_fact * White_exc16k[k] + (float) ( 1 - new_fact ) * exc16kWhtnd[k];
- }
+ /* White_exc16k: (Q_bwe_exc-NOISE_QADJ), scale: Q15 */
+ L_tmp = L_mult( White_exc16k[k], scale );
+ /* L_tmp: (Q_bwe_exc-NOISE_QADJ) + 15 + 1 */
+ exc16kWhtnd[k] = round_fx( L_shl( L_tmp, NOISE_QADJ ) );
+ move16();
+ /* exc16kWhtnd: Q_bwe_exc */
}
- preemph( exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph );
+ PREEMPH_FX( exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph );
+ /* i/o: exc16kWhtnd (Q_bwe_exc) */
+ /* i/o: tbe_premph (Q_bwe_exc) */
}
- else
-#endif
+ ELSE
{
-#ifdef ADD_IVAS_TBE_CODE
- if ( coder_type == UNVOICED || MSFlag == 1 )
-#else
- IF( EQ_16( coder_type, UNVOICED ) )
-#endif
+ Word16 nbSubFr, lSubFr;
+ Word16 tempQ15;
+ Word32 tempQ31;
+ /*nbSubFr = ( bitrate < ACELP_24k40 )? NB_SUBFR : NB_SUBFR16k;*/
+ nbSubFr = NB_SUBFR16k;
+ lSubFr = ( L_FRAME16k / NB_SUBFR16k );
+ IF( LT_32( bitrate, ACELP_24k40 ) )
{
- L_tmp = root_a_over_b_fx( pow1, Q_pow1, pow22, Q_pow22, &exp );
- scale = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /*Q15 */
- FOR( k = 0; k < L_FRAME16k; k++ )
- {
- /* White_exc16k: (Q_bwe_exc-NOISE_QADJ), scale: Q15 */
- L_tmp = L_mult( White_exc16k[k], scale );
- /* L_tmp: (Q_bwe_exc-NOISE_QADJ) + 15 + 1 */
- exc16kWhtnd[k] = round_fx( L_shl( L_tmp, NOISE_QADJ ) );
- move16();
- /* exc16kWhtnd: Q_bwe_exc */
- }
- PREEMPH_FX( exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph );
- /* i/o: exc16kWhtnd (Q_bwe_exc) */
- /* i/o: tbe_premph (Q_bwe_exc) */
+ nbSubFr = NB_SUBFR;
+ move16();
+ lSubFr = ( L_FRAME16k / NB_SUBFR );
+ move16();
}
- ELSE
+ k = 0;
+ FOR( i = 0; i < nbSubFr; i++ )
{
- Word16 nbSubFr, lSubFr;
- Word16 tempQ15;
- Word32 tempQ31;
- /*nbSubFr = ( bitrate < ACELP_24k40 )? NB_SUBFR : NB_SUBFR16k;*/
- nbSubFr = NB_SUBFR16k;
- lSubFr = ( L_FRAME16k / NB_SUBFR16k );
- IF( LT_32( bitrate, ACELP_24k40 ) )
+ test();
+ IF( EQ_16( coder_type, VOICED ) && ( LT_32( bitrate, ACELP_24k40 ) ) )
{
- nbSubFr = NB_SUBFR;
+ exp = 0;
move16();
- lSubFr = ( L_FRAME16k / NB_SUBFR );
+ tempQ15 = Sqrt16( voice_factors[i], &exp ); /* Q15 */
+ temp = shl( tempQ15, exp ); /* Q15 exc16kWhtnd scale factor */
+ exp = 0;
move16();
+ tempQ15 = Sqrt16( temp, &exp ); /* Q15 */
+ temp1 = shl( tempQ15, exp ); /* Q15 exc16kWhtnd scale factor */
+
+ /*temp2 = root_a_over_b_fx( pow1 * (1.0f - temp), pow22 ); */
+ 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 );
+ temp2 = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q15 whiteEnvShapedExc scale factor */
}
- k = 0;
- FOR( i = 0; i < nbSubFr; i++ )
+ ELSE
{
- test();
- IF( EQ_16( coder_type, VOICED ) && ( LT_32( bitrate, ACELP_24k40 ) ) )
- {
- exp = 0;
- move16();
- tempQ15 = Sqrt16( voice_factors[i], &exp ); /* Q15 */
- temp = shl( tempQ15, exp ); /* Q15 exc16kWhtnd scale factor */
- exp = 0;
- move16();
- tempQ15 = Sqrt16( temp, &exp ); /* Q15 */
- temp1 = shl( tempQ15, exp ); /* Q15 exc16kWhtnd scale factor */
-
- /*temp2 = root_a_over_b_fx( pow1 * (1.0f - temp), pow22 ); */
- 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 );
- temp2 = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q15 whiteEnvShapedExc scale factor */
- }
- ELSE
- {
- /* Adjust noise mixing for formant sharpening filter */
- tempQ15 = mult_r( SWB_NOISE_MIX_FAC_FX, formant_fac );
- /* vf_tmp = voice_factors[i] * (1.0f - vf_tmp); */
- vf_tmp = sub( MAX_16, tempQ15 );
- vf_tmp = mult_r( voice_factors[i], vf_tmp );
-
- exp = 0;
- move16();
- tempQ15 = Sqrt16( vf_tmp, &exp ); /* Q15 */
- temp1 = shl( tempQ15, exp ); /* Q15 exc16kWhtnd scale factor */
-
- /*temp2 = root_a_over_b(pow1 * (1.0f - vf_tmp), pow22); */
- 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 );
- temp2 = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q15 whiteEnvShapedExc scale factor */
- }
+ /* Adjust noise mixing for formant sharpening filter */
+ tempQ15 = mult_r( SWB_NOISE_MIX_FAC_FX, formant_fac );
+ /* vf_tmp = voice_factors[i] * (1.0f - vf_tmp); */
+ vf_tmp = sub( MAX_16, tempQ15 );
+ vf_tmp = mult_r( voice_factors[i], vf_tmp );
- FOR( j = 0; j < lSubFr; j++ )
- {
- /*exc16kWhtnd[k+j] = temp1 * exc16kWhtnd[k+j] + temp2 * White_exc16k[k+j]; */
- L_tmp = L_mult( temp2, White_exc16k[k + j] ); /* 16+(Q_bwe_exc-NOISE_QADJ)*/
- L_tmp = L_shl_sat( L_tmp, NOISE_QADJ ); /* 16+(Q_bwe_exc) */
- exc16kWhtnd[k + j] = mac_r_sat( L_tmp, temp1, exc16kWhtnd[k + j] );
- move16();
- /* Q_bwe_exc */
- }
- k = add( k, lSubFr );
-
- /* estimate the pre-emph factor */
- tempQ15 = sub( MAX_16, voice_factors[i] );
exp = 0;
move16();
- temp = Sqrt16( tempQ15, &exp );
- temp = shl( temp, exp - 1 );
-
- temp2 = add( temp, shl( temp1, -1 ) ); /* shift right by 1 to avoid overflow */
- temp = div_s( temp, temp2 ); /* Q15 */
- temp = mult_r( PREEMPH_FAC, temp );
+ tempQ15 = Sqrt16( vf_tmp, &exp ); /* Q15 */
+ temp1 = shl( tempQ15, exp ); /* Q15 exc16kWhtnd scale factor */
+
+ /*temp2 = root_a_over_b(pow1 * (1.0f - vf_tmp), pow22); */
+ 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 );
+ temp2 = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q15 whiteEnvShapedExc scale factor */
+ }
- PREEMPH_FX( &exc16kWhtnd[i * lSubFr], temp, lSubFr, tbe_premph );
- /* exc16kWhtnd: Q_bwe_exc;
- tbe_premph: Q_bwe_exc*/
+ FOR( j = 0; j < lSubFr; j++ )
+ {
+ /*exc16kWhtnd[k+j] = temp1 * exc16kWhtnd[k+j] + temp2 * White_exc16k[k+j]; */
+ L_tmp = L_mult( temp2, White_exc16k[k + j] ); /* 16+(Q_bwe_exc-NOISE_QADJ)*/
+ L_tmp = L_shl_sat( L_tmp, NOISE_QADJ ); /* 16+(Q_bwe_exc) */
+ exc16kWhtnd[k + j] = mac_r_sat( L_tmp, temp1, exc16kWhtnd[k + j] );
+ move16();
+ /* Q_bwe_exc */
}
- }
- }
+ k = add( k, lSubFr );
-#ifdef ADD_IVAS_TBE_CODE
- IF( LT_32( extl_brate, SWB_TBE_2k8 ) )
-#else
- IF( LT_32( bitrate, ACELP_24k40 ) )
-#endif
- {
- Syn_filt_s( 0, lpc_shb, LPC_SHB_ORDER, exc16kWhtnd, excSHB, L_FRAME16k, state_lpc_syn, 1 );
- /* i: exc16kWhtnd in Q_bwe_exc */
- /* o: excSHB in Q_bwe_exc */
+ /* estimate the pre-emph factor */
+ tempQ15 = sub( MAX_16, voice_factors[i] );
+ exp = 0;
+ move16();
+ temp = Sqrt16( tempQ15, &exp );
+ temp = shl( temp, exp - 1 );
+
+ temp2 = add( temp, shl( temp1, -1 ) ); /* shift right by 1 to avoid overflow */
+ temp = div_s( temp, temp2 ); /* Q15 */
+ temp = mult_r( PREEMPH_FAC, temp );
+
+ PREEMPH_FX( &exc16kWhtnd[i * lSubFr], temp, lSubFr, tbe_premph );
+ /* exc16kWhtnd: Q_bwe_exc;
+ tbe_premph: Q_bwe_exc*/
+ }
}
- ELSE
- {
- set16_fx( zero_mem, 0, LPC_SHB_ORDER );
+}
- Syn_filt_s( 0, lpc_shb_sf, LPC_SHB_ORDER, exc16kWhtnd, tempSHB, 80, zero_mem, 1 );
- syn_shb_ener_sf[0] = L_shr( sum2_fx( tempSHB, 80 ), 3 );
- move32();
+IF( LT_32( bitrate, ACELP_24k40 ) )
+{
+ 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 */
+}
+ELSE
+{
+ set16_fx( zero_mem, 0, LPC_SHB_ORDER );
- Syn_filt_s( 0, lpc_shb_sf + ( LPC_SHB_ORDER + 1 ), LPC_SHB_ORDER, exc16kWhtnd + 80, tempSHB, 80, zero_mem, 1 );
- syn_shb_ener_sf[1] = L_shr( sum2_fx( tempSHB, 80 ), 3 );
- move32();
+ Syn_filt_s( 0, lpc_shb_sf, LPC_SHB_ORDER, exc16kWhtnd, tempSHB, 80, zero_mem, 1 );
+ syn_shb_ener_sf[0] = L_shr( sum2_fx( tempSHB, 80 ), 3 );
+ move32();
- Syn_filt_s( 0, lpc_shb_sf + 2 * ( LPC_SHB_ORDER + 1 ), LPC_SHB_ORDER, exc16kWhtnd + 160, tempSHB, 80, zero_mem, 1 );
- syn_shb_ener_sf[2] = L_shr( sum2_fx( tempSHB, 80 ), 3 );
- move32();
+ Syn_filt_s( 0, lpc_shb_sf + ( LPC_SHB_ORDER + 1 ), LPC_SHB_ORDER, exc16kWhtnd + 80, tempSHB, 80, zero_mem, 1 );
+ syn_shb_ener_sf[1] = L_shr( sum2_fx( tempSHB, 80 ), 3 );
+ move32();
- Syn_filt_s( 0, lpc_shb_sf + 3 * ( LPC_SHB_ORDER + 1 ), LPC_SHB_ORDER, exc16kWhtnd + 240, tempSHB, 80, zero_mem, 1 );
- syn_shb_ener_sf[3] = L_shr( sum2_fx( tempSHB, 80 ), 3 );
- move32();
+ Syn_filt_s( 0, lpc_shb_sf + 2 * ( LPC_SHB_ORDER + 1 ), LPC_SHB_ORDER, exc16kWhtnd + 160, tempSHB, 80, zero_mem, 1 );
+ syn_shb_ener_sf[2] = L_shr( sum2_fx( tempSHB, 80 ), 3 );
+ move32();
- /* i: exc16kWhtnd in Q_bwe_exc */
- /* o: tempSHB in Q_bwe_exc */
- /* o: syn_shb_ener_sf in (2*Q_bwe_exc+1) */
- IF( LE_32( bitrate, ACELP_32k ) )
- {
- L_tmp = sum32_fx( syn_shb_ener_sf, 4 );
+ Syn_filt_s( 0, lpc_shb_sf + 3 * ( LPC_SHB_ORDER + 1 ), LPC_SHB_ORDER, exc16kWhtnd + 240, tempSHB, 80, zero_mem, 1 );
+ syn_shb_ener_sf[3] = L_shr( sum2_fx( tempSHB, 80 ), 3 );
+ move32();
- /* find root_a(tempSHB[0]) = root_a_over_b(shb_ener_sf[0]), L_tmp) */
- tmp = shl( Q_shb, 1 );
- tmp2 = add( shl( *Q_bwe_exc, 1 ), 1 );
- L_tmp2 = root_a_over_b_fx( shb_ener_sf_32, tmp, L_tmp, tmp2, &exp ); /* L_tmp2 in (Q31-exp) */
+ /* i: exc16kWhtnd in Q_bwe_exc */
+ /* o: tempSHB in Q_bwe_exc */
+ /* o: syn_shb_ener_sf in (2*Q_bwe_exc+1) */
+ IF( LE_32( bitrate, ACELP_32k ) )
+ {
+ L_tmp = sum32_fx( syn_shb_ener_sf, 4 );
- *Q_bwe_exc = sub( *Q_bwe_exc, exp );
- move16(); /* compensate for the exp shift */
- tmp2 = add( prev_Q_bwe_syn, n_mem2 );
- IF( GT_16( *Q_bwe_exc, tmp2 ) )
- {
- L_tmp2 = L_shl( L_tmp2, sub( tmp2, *Q_bwe_exc ) );
- *Q_bwe_exc = tmp2;
- move16();
- }
- FOR( i = 0; i < L_FRAME16k; i++ )
- {
- L_tmp3 = Mult_32_16( L_tmp2, exc16kWhtnd[i] ); /* *Q_bwe_exc + (31-exp) - 15 */
- exc16kWhtnd[i] = round_fx( L_tmp3 ); /* *Q_bwe_exc - exp */
- move16();
- }
- }
- /* i: L_tmp2 in (Q31-exp) */
- /* i: exc16kWhtnd in Q_bwe_exc */
- /* o: exc16kWhtnd in Q_bwe_exc: (Q_bwe_exc-exp) */
+ /* find root_a(tempSHB[0]) = root_a_over_b(shb_ener_sf[0]), L_tmp) */
+ tmp = shl( Q_shb, 1 );
+ tmp2 = add( shl( *Q_bwe_exc, 1 ), 1 );
+ L_tmp2 = root_a_over_b_fx( shb_ener_sf_32, tmp, L_tmp, tmp2, &exp ); /* L_tmp2 in (Q31-exp) */
- /* Rescale the past memories: LP synth and SHB look ahead buffers */
- tmp = sub( *Q_bwe_exc, prev_Q_bwe_syn );
- FOR( i = 0; i < LPC_SHB_ORDER; i++ )
+ *Q_bwe_exc = sub( *Q_bwe_exc, exp );
+ move16(); /* compensate for the exp shift */
+ tmp2 = add( prev_Q_bwe_syn, n_mem2 );
+ IF( GT_16( *Q_bwe_exc, tmp2 ) )
{
- state_lpc_syn[i] = shl( state_lpc_syn[i], tmp );
+ L_tmp2 = L_shl( L_tmp2, sub( tmp2, *Q_bwe_exc ) );
+ *Q_bwe_exc = tmp2;
move16();
}
- FOR( i = -L_SHB_LAHEAD; i < 0; i++ )
+ FOR( i = 0; i < L_FRAME16k; i++ )
{
- excSHB[i] = shl( excSHB[i], tmp );
+ L_tmp3 = Mult_32_16( L_tmp2, exc16kWhtnd[i] ); /* *Q_bwe_exc + (31-exp) - 15 */
+ exc16kWhtnd[i] = round_fx( L_tmp3 ); /* *Q_bwe_exc - exp */
move16();
}
- /* Do mem_stp_swb_fx scaling before PostShortTerm_fx */
-
- Syn_filt_s( 0, lpc_shb_sf, LPC_SHB_ORDER, exc16kWhtnd, excSHB, 80, state_lpc_syn, 1 );
- Syn_filt_s( 0, lpc_shb_sf + ( LPC_SHB_ORDER + 1 ), LPC_SHB_ORDER, exc16kWhtnd + 80, excSHB + 80, 80, state_lpc_syn, 1 );
- Syn_filt_s( 0, lpc_shb_sf + 2 * ( LPC_SHB_ORDER + 1 ), LPC_SHB_ORDER, exc16kWhtnd + 160, excSHB + 160, 80, state_lpc_syn, 1 );
- Syn_filt_s( 0, lpc_shb_sf + 3 * ( LPC_SHB_ORDER + 1 ), LPC_SHB_ORDER, exc16kWhtnd + 240, excSHB + 240, 80, state_lpc_syn, 1 );
- /* i: exc16kWhtnd in (Q_bwe_exc) */
- /* o: excSHB in (Q_bwe_exc) */
}
+ /* i: L_tmp2 in (Q31-exp) */
+ /* i: exc16kWhtnd in Q_bwe_exc */
+ /* o: exc16kWhtnd in Q_bwe_exc: (Q_bwe_exc-exp) */
- IF( EQ_16( extl, FB_TBE ) )
+ /* Rescale the past memories: LP synth and SHB look ahead buffers */
+ tmp = sub( *Q_bwe_exc, prev_Q_bwe_syn );
+ FOR( i = 0; i < LPC_SHB_ORDER; i++ )
{
- tmp = sub( add( *Q_bwe_exc_fb, 20 ), prev_Q_bwe_exc_fb );
- Scale_sig( fb_state_lpc_syn, LPC_SHB_ORDER, tmp );
- Scale_sig( fb_tbe_demph, 1, tmp );
- Syn_filt_s( 0, lpc_shb, LPC_SHB_ORDER, White_exc16k_FB, White_exc16k_FB_temp, L_FRAME16k, fb_state_lpc_syn, 1 );
- /* i: White_exc16k_FB in (14-n2) */
- /* o: White_exc16k_FB_temp in (14-n2) */
+ state_lpc_syn[i] = shl( state_lpc_syn[i], tmp );
+ move16();
+ }
+ FOR( i = -L_SHB_LAHEAD; i < 0; i++ )
+ {
+ excSHB[i] = shl( excSHB[i], tmp );
+ move16();
+ }
+ /* Do mem_stp_swb_fx scaling before PostShortTerm_fx */
+
+ Syn_filt_s( 0, lpc_shb_sf, LPC_SHB_ORDER, exc16kWhtnd, excSHB, 80, state_lpc_syn, 1 );
+ Syn_filt_s( 0, lpc_shb_sf + ( LPC_SHB_ORDER + 1 ), LPC_SHB_ORDER, exc16kWhtnd + 80, excSHB + 80, 80, state_lpc_syn, 1 );
+ Syn_filt_s( 0, lpc_shb_sf + 2 * ( LPC_SHB_ORDER + 1 ), LPC_SHB_ORDER, exc16kWhtnd + 160, excSHB + 160, 80, state_lpc_syn, 1 );
+ Syn_filt_s( 0, lpc_shb_sf + 3 * ( LPC_SHB_ORDER + 1 ), LPC_SHB_ORDER, exc16kWhtnd + 240, excSHB + 240, 80, state_lpc_syn, 1 );
+ /* i: exc16kWhtnd in (Q_bwe_exc) */
+ /* o: excSHB in (Q_bwe_exc) */
+}
+
+IF( EQ_16( extl, FB_TBE ) )
+{
+ tmp = sub( add( *Q_bwe_exc_fb, 20 ), prev_Q_bwe_exc_fb );
+ Scale_sig( fb_state_lpc_syn, LPC_SHB_ORDER, tmp );
+ Scale_sig( fb_tbe_demph, 1, tmp );
+ Syn_filt_s( 0, lpc_shb, LPC_SHB_ORDER, White_exc16k_FB, White_exc16k_FB_temp, L_FRAME16k, fb_state_lpc_syn, 1 );
+ /* i: White_exc16k_FB in (14-n2) */
+ /* o: White_exc16k_FB_temp in (14-n2) */
- FOR( i = 0; i < 10; i++ )
+ FOR( i = 0; i < 10; i++ )
+ {
+ FOR( j = 0; j < 32; ++j )
{
- FOR( j = 0; j < 32; ++j )
- {
- White_exc16k_FB_temp[i * 32 + j] = mult_r( White_exc16k_FB_temp[i * 32 + j], cos_fb_exc_fx[j] );
- move16();
- }
+ White_exc16k_FB_temp[i * 32 + j] = mult_r( White_exc16k_FB_temp[i * 32 + j], cos_fb_exc_fx[j] );
+ move16();
}
+ }
- *Q_bwe_exc_fb = add( *Q_bwe_exc_fb, 20 );
- move16(); /**Q_bwe_exc_fb +35 +1 -16*/
- flip_spectrum_fx( White_exc16k_FB_temp, White_exc16k_FB, L_FRAME16k );
+ *Q_bwe_exc_fb = add( *Q_bwe_exc_fb, 20 );
+ move16(); /**Q_bwe_exc_fb +35 +1 -16*/
+ flip_spectrum_fx( White_exc16k_FB_temp, White_exc16k_FB, L_FRAME16k );
- deemph_fx( White_exc16k_FB, fb_deemph_fac, L_FRAME16k, fb_tbe_demph );
- }
- ELSE
- {
- set16_fx( White_exc16k_FB, 0, L_FRAME16k );
- }
+ deemph_fx( White_exc16k_FB, fb_deemph_fac, L_FRAME16k, fb_tbe_demph );
+}
+ELSE
+{
+ set16_fx( White_exc16k_FB, 0, L_FRAME16k );
+}
-#ifdef ADD_IVAS_TBE_CODE
- *prev_pow_exc16kWhtnd = pow1;
- *prev_mix_factor = mix_factor;
-#endif
- return;
+return;
}
void GenShapedSHBExcitation_ivas_enc_fx(
@@ -3288,7 +3033,6 @@ void GenShapedSHBExcitation_ivas_enc_fx(
{
IF( EQ_16( *vf_ind, 20 ) ) /* encoder side */
{
-#ifndef ADD_IVAS_TBE_CODE // BELOW PART WILL NEED TO BE CONVERTED FOR ENCODER!!
test();
IF( EQ_32( extl_brate, SWB_TBE_1k10 ) || EQ_32( extl_brate, SWB_TBE_1k75 ) )
{
@@ -3474,33 +3218,6 @@ void GenShapedSHBExcitation_ivas_enc_fx(
}
}
ELSE
-#else
- UNUSED_PARAM( Env_error_part );
- UNUSED_PARAM( Env_error );
- UNUSED_PARAM( EnvSHBres_4k );
- UNUSED_PARAM( c5_part );
- UNUSED_PARAM( c1 );
- UNUSED_PARAM( den );
- UNUSED_PARAM( c3_part );
- UNUSED_PARAM( c0 );
- UNUSED_PARAM( delta );
- UNUSED_PARAM( c3 );
- UNUSED_PARAM( c2_part );
- UNUSED_PARAM( c1_part );
- UNUSED_PARAM( EnvWhiteExc16k );
- UNUSED_PARAM( g2 );
- UNUSED_PARAM( c5 );
- UNUSED_PARAM( c4_part );
- UNUSED_PARAM( EnvWhiteExc16k_4k );
- UNUSED_PARAM( c2 );
- UNUSED_PARAM( g );
- UNUSED_PARAM( cbsize );
- UNUSED_PARAM( g1 );
- UNUSED_PARAM( EnvExc16kWhtnd );
- UNUSED_PARAM( c0_part );
- UNUSED_PARAM( EnvExc16kWhtnd_4k );
- UNUSED_PARAM( c4 );
-#endif
{
Estimate_mix_factors_fx( shb_res, Q_shb, exc16kWhtnd, *Q_bwe_exc, White_exc16k,
Q_White_exc16k, pow1, Q_pow1, pow22, Q_pow22, voiceFacEst, vf_ind );
@@ -3592,6 +3309,9 @@ void GenShapedSHBExcitation_ivas_enc_fx(
move16();
move16();
+ scale_sig( White_exc16k, L_FRAME16k, -1 /* guard bit to prevent saturation in deemph*/ );
+ Q_White_exc16k = sub( Q_White_exc16k, 1 );
+
Word16 tbe_demph_fx = shl_sat( *tbe_demph, sub( Q_White_exc16k, *Q_bwe_exc ) ); // Q_White_exc16k
deemph_fx( White_exc16k, PREEMPH_FAC, L_FRAME16k, &tbe_demph_fx );
@@ -4003,7 +3723,6 @@ void GenShapedSHBExcitation_ivas_dec_fx(
move16();
move32();
-#if 1 // def ADD_IVAS_TBE_CODE
Word16 alpha, step, mem_csfilt_left, mem_csfilt_right, excNoisyEnvLeft[L_FRAME16k], excNoisyEnvRight[L_FRAME16k];
Word16 cbsize;
Word16 mix_factor, old_fact, new_fact, fact, old_scale, new_scale, step_scale;
@@ -4018,7 +3737,7 @@ void GenShapedSHBExcitation_ivas_dec_fx(
mix_factor = 0; /* Q15 */
move16();
-#endif
+
set16_fx( zero_mem, 0, LPC_SHB_ORDER );
set16_fx( wht_fil_mem, 0, LPC_WHTN_ORDER );
FOR( i = 0; i < L_FRAME32k; i = i + 2 )
@@ -4050,11 +3769,7 @@ void GenShapedSHBExcitation_ivas_dec_fx(
/* i: exc16k in Q_bwe_exc */
/* o: exc16kWhtnd in Q_bwe_exc */
-#if 1 // def ADD_IVAS_TBE_CODE
IF( GE_32( extl_brate, SWB_TBE_2k8 ) )
-#else
- IF( GE_32( bitrate, ACELP_24k40 ) )
-#endif
{
temp2 = 0;
move16();
@@ -4089,11 +3804,8 @@ void GenShapedSHBExcitation_ivas_dec_fx(
Q_pow1 = shl( *Q_bwe_exc, 1 );
test();
-#if 1 // ADD_IVAS_TBE_CODE
+
IF( flag_ACELP16k == 0 )
-#else
- IF( ( LE_32( bitrate, ACELP_13k20 ) ) && ( GE_32( bitrate, ACELP_7k20 ) ) )
-#endif
{
/* varEnvShape = mean_fx(voice_factors, 4); */
/* unroll the loop */
@@ -4139,12 +3851,8 @@ void GenShapedSHBExcitation_ivas_dec_fx(
test();
test();
test();
-#if 1 // def ADD_IVAS_TBE_CODE
- test();
+
IF( EQ_16( element_mode, EVS_MONO ) && *mem_csfilt == 0 && ( ( EQ_32( bitrate, ACELP_9k60 ) ) || ( EQ_32( bitrate, ACELP_16k40 ) ) || ( EQ_32( bitrate, ACELP_24k40 ) ) ) )
-#else
- IF( *mem_csfilt == 0 && ( ( EQ_32( bitrate, ACELP_9k60 ) ) || ( EQ_32( bitrate, ACELP_16k40 ) ) || ( EQ_32( bitrate, ACELP_24k40 ) ) ) )
-#endif
{
/* pre-init smoothing filter to avoid energy drop outs */
L_tmp = L_mult( excTmp2[0], 1638 );
@@ -4171,7 +3879,7 @@ void GenShapedSHBExcitation_ivas_dec_fx(
*mem_csfilt = Mult_32_16( L_tmp, varEnvShape );
move32();
}
-#if 1 // def ADD_IVAS_TBE_CODE
+
IF( MSFlag > 0 )
{
// varEnvShape = 0.995f;
@@ -4231,7 +3939,7 @@ void GenShapedSHBExcitation_ivas_dec_fx(
}
}
ELSE
-#endif
+
{
/* Track the low band envelope */
L_tmp = L_shl( *mem_csfilt, sub( Q_excTmp2, *Q_bwe_exc ) );
@@ -4257,7 +3965,6 @@ void GenShapedSHBExcitation_ivas_dec_fx(
*mem_csfilt = L_shr( L_tmp, sub( Q_excTmp2, *Q_bwe_exc ) );
move32();
}
-#if 1 // def ADD_IVAS_TBE_CODE
test();
IF( EQ_32( extl_brate, SWB_TBE_1k10 ) || EQ_32( extl_brate, SWB_TBE_1k75 ) )
{
@@ -4303,7 +4010,6 @@ void GenShapedSHBExcitation_ivas_dec_fx(
}
}
ELSE
-#endif
{
/* create a random excitation - Reuse exc16k memory */
White_exc16k = exc16k;
@@ -4352,20 +4058,15 @@ void GenShapedSHBExcitation_ivas_dec_fx(
Q_White_exc16k = add( Q_White_exc16k, sub( Q_excTmp2, 10 ) );
}
-#if 1 // def ADD_IVAS_TBE_CODE
flag_plosive = 0;
move16();
test();
test();
test();
IF( GE_32( extl_brate, SWB_TBE_2k8 ) || EQ_32( extl_brate, SWB_TBE_1k10 ) || EQ_32( extl_brate, SWB_TBE_1k75 ) )
-#else
- IF( GE_32( bitrate, ACELP_24k40 ) )
-#endif
{
IF( EQ_16( *vf_ind, 20 ) ) /* encoder side */
{
-#ifndef ADD_IVAS_TBE_CODE // BELOW PART WILL NEED TO BE CONVERTED FOR ENCODER!!
test();
IF( EQ_32( extl_brate, SWB_TBE_1k10 ) || EQ_32( extl_brate, SWB_TBE_1k75 ) )
{
@@ -4544,33 +4245,6 @@ void GenShapedSHBExcitation_ivas_dec_fx(
}
}
ELSE
-#else
- UNUSED_PARAM( Env_error_part );
- UNUSED_PARAM( Env_error );
- UNUSED_PARAM( EnvSHBres_4k );
- UNUSED_PARAM( c5_part );
- UNUSED_PARAM( c1 );
- UNUSED_PARAM( den );
- UNUSED_PARAM( c3_part );
- UNUSED_PARAM( c0 );
- UNUSED_PARAM( delta );
- UNUSED_PARAM( c3 );
- UNUSED_PARAM( c2_part );
- UNUSED_PARAM( c1_part );
- UNUSED_PARAM( EnvWhiteExc16k );
- UNUSED_PARAM( g2 );
- UNUSED_PARAM( c5 );
- UNUSED_PARAM( c4_part );
- UNUSED_PARAM( EnvWhiteExc16k_4k );
- UNUSED_PARAM( c2 );
- UNUSED_PARAM( g );
- UNUSED_PARAM( cbsize );
- UNUSED_PARAM( g1 );
- UNUSED_PARAM( EnvExc16kWhtnd );
- UNUSED_PARAM( c0_part );
- UNUSED_PARAM( EnvExc16kWhtnd_4k );
- UNUSED_PARAM( c4 );
-#endif
{
Estimate_mix_factors_fx( shb_res, Q_shb, exc16kWhtnd, *Q_bwe_exc, White_exc16k,
( *Q_bwe_exc - NOISE_QADJ ), pow1, Q_pow1, pow22, Q_pow22, voiceFacEst, vf_ind );
@@ -4588,7 +4262,6 @@ void GenShapedSHBExcitation_ivas_dec_fx(
ELSE /* decoder side */
{
test();
-#if 1 // def ADD_IVAS_TBE_CODE
IF( EQ_32( extl_brate, SWB_TBE_1k10 ) || EQ_32( extl_brate, SWB_TBE_1k75 ) )
{
IF( *vf_ind == 0 )
@@ -4606,7 +4279,6 @@ void GenShapedSHBExcitation_ivas_dec_fx(
}
}
ELSE
-#endif
{
/* *vf_ind is an integer scale by 0.125f*/
tmp = shl( *vf_ind, ( 15 - 3 ) );
@@ -4619,10 +4291,8 @@ void GenShapedSHBExcitation_ivas_dec_fx(
}
}
}
-#if 1 // def ADD_IVAS_TBE_CODE
test();
IF( NE_32( extl_brate, SWB_TBE_1k10 ) && NE_32( extl_brate, SWB_TBE_1k75 ) )
-#endif
{
voice_factors[0] = mult_r( voice_factors[0], tmp2 );
move16();
@@ -4979,10 +4649,8 @@ void GenShapedSHBExcitation_ivas_dec_fx(
set16_fx( White_exc16k_FB, 0, L_FRAME16k );
}
-#if 1 // def ADD_IVAS_TBE_CODE
*prev_pow_exc16kWhtnd = L_shr_sat( pow1, Q_pow1 ); // power goes above MAX_32
*prev_mix_factor = mix_factor;
-#endif
return;
}
@@ -6306,7 +5974,7 @@ void non_linearity_ivas_fx(
}
- IF( GT_16( max_val, shl( 1, Q_inp ) ) )
+ IF( GT_16( max_val, shl_sat( 1, Q_inp ) ) )
{
exp = norm_s( max_val );
tmp = div_s( shl( 1, sub( 14, exp ) ), max_val ); /* Q(29-exp-Q_inp) */
@@ -6380,7 +6048,7 @@ void non_linearity_ivas_fx(
max_val = s_max( max_val, tmp );
}
- IF( GT_16( max_val, shl( 1, Q_inp ) ) )
+ IF( GT_16( max_val, shl_sat( 1, Q_inp ) ) )
{
exp = norm_s( max_val );
tmp = div_s( shl( 1, sub( 14, exp ) ), max_val ); /* Q(29-exp-Q_inp) */
@@ -6701,7 +6369,7 @@ void wb_tbe_extras_reset_synth_fx(
void elliptic_bpf_48k_generic_fx(
#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2
- int16_t element_mode,
+ const int16_t element_mode,
#endif
#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic
Word16 IsUpsampled3,
@@ -7314,6 +6982,7 @@ void synthesise_fb_high_band_fx(
elliptic_bpf_48k_generic_fx( excitation_in_interp3, &exp_tmp, tmp, bpf_memory, bpf_memory_Q, full_band_bpf_1_fx );
#endif
}
+ /* temp1 = sum2_f( tmp, L_FRAME48k ) + 0.001f */
temp1 = sum2_fx_mod( tmp, L_FRAME48k );
L_tmp = L_max( 1, fb_exc_energy ); /*Q(2*Q_fb_exc + 1)*/
@@ -7322,9 +6991,33 @@ void synthesise_fb_high_band_fx(
tmp1 = sub( add( Q_fb_exc, Q_fb_exc ), 8 ); /* 1-9*/
exp = sub( sub( 31, tmp1 ), exp );
- exp2 = norm_l( temp1 );
- tmp2 = extract_h( L_shl( temp1, exp2 ) );
- exp2 = sub( sub( 31, sub( shl( exp_tmp, 1 ), 8 ) ), exp2 ); /* in Q15 (temp1 in Q9)*/
+ IF( element_mode != EVS_MONO )
+ {
+ Word16 sft, t_Q;
+ Word64 P_ONE = 33; /* 0.001f in Q15 */
+ move64();
+ Word64 W_temp;
+
+ t_Q = sub( shl( exp_tmp, 1 ), 8 );
+ P_ONE = W_shl( P_ONE, sub( t_Q, 15 ) );
+
+ W_temp = W_add( P_ONE, temp1 );
+
+ sft = W_norm( W_temp );
+ W_temp = W_shl( W_temp, sft );
+
+ temp1 = W_extract_h( W_temp );
+ t_Q = sub( add( t_Q, sft ), 32 );
+
+ tmp2 = extract_h( temp1 );
+ exp2 = sub( 31, t_Q );
+ }
+ ELSE
+ {
+ exp2 = norm_l( temp1 );
+ tmp2 = extract_h( L_shl( temp1, exp2 ) );
+ exp2 = sub( sub( 31, sub( shl( exp_tmp, 1 ), 8 ) ), exp2 ); /* in Q15 (temp1 in Q9)*/
+ }
exp = sub( exp2, exp ); /* Denormalize and substract */
IF( GT_16( tmp2, tmp3 ) )
@@ -7358,50 +7051,6 @@ void synthesise_fb_high_band_fx(
tmp3 = add( sub( Qout, add( sub( 1, exp ), exp_tmp ) ), 16 ); /*Qout - (1 -exp +exp_tmp) + 16 */
FOR( i = 0; i < L_FRAME48k; i++ )
{
-#ifdef FIX_1439_SPEEDUP_synthesise_fb_high_band_fx
- L_tmp = Mult_32_16( ratio2, tmp[i] ); /* Q(16-exp+exp_tmp-15 = 1-exp+exp_tmp) */
- Word32 L_tmp32;
- Word16 tmp16;
-
- // if (L_tmp < 0)
- if ( L_tmp < 0 )
- {
- L_tmp32 = L_negate( L_tmp );
- }
- if ( L_tmp < 0 )
- {
- L_tmp32 = L_shl_sat( L_tmp32, tmp3 );
- }
- if ( L_tmp < 0 )
- {
- tmp16 = extract_h( L_tmp32 );
- }
- if ( L_tmp < 0 )
- {
- tmp16 = negate( tmp16 );
- }
-
- // if (L_tmp == 0)
- if ( L_tmp == 0 )
- {
- tmp16 = 0;
- move16();
- }
-
- // if (L_tmp > 0)
- if ( L_tmp > 0 )
- {
- L_tmp32 = L_shl_sat( L_tmp, tmp3 );
- }
- if ( L_tmp > 0 )
- {
- tmp16 = extract_h( L_tmp32 );
- }
-
- output[i] = tmp16;
- move16();
-
-#else
L_tmp = Mult_32_16( ratio2, tmp[i] ); /* Q(16-exp+exp_tmp-15 = 1-exp+exp_tmp) */
IF( L_tmp < 0 )
{
@@ -7413,7 +7062,6 @@ void synthesise_fb_high_band_fx(
output[i] = extract_h( L_shl_sat( L_tmp, tmp3 ) ); /*Qout*/
move16();
}
-#endif
}
return;
}
@@ -7566,56 +7214,7 @@ void Estimate_mix_factors_fx(
return;
}
-#ifdef ADD_IVAS_TBE_CODE
-/*-------------------------------------------------------------------*
- * tbe_celp_exc() *
- * *
- * Prepare adaptive part of TBE excitation *
- *-------------------------------------------------------------------*/
-
-void tbe_celp_exc(
- const int16_t element_mode, /* i : element mode */
- const int16_t idchan, /* i : channel ID */
- float *bwe_exc, /* i/o: BWE excitation */
- const int16_t L_frame, /* i : frame length */
- const int16_t L_subfr, /* i : subframe length */
- const int16_t i_subfr, /* i : subframe index */
- const int16_t T0, /* i : integer pitch lag */
- const int16_t T0_frac, /* i : fraction of lag */
- float *error, /* i/o: error */
- const int16_t tdm_LRTD_flag /* i : LRTD stereo mode flag */
-)
-{
- int16_t i, offset;
-
- if ( element_mode == IVAS_CPE_TD && idchan == 1 && !tdm_LRTD_flag )
- {
- return;
- }
-
- if ( L_frame == L_FRAME )
- {
- offset = tbe_celp_exc_offset( T0, T0_frac );
-
- for ( i = 0; i < L_subfr * HIBND_ACB_L_FAC; i++ )
- {
- bwe_exc[i + i_subfr * HIBND_ACB_L_FAC] = bwe_exc[i + i_subfr * HIBND_ACB_L_FAC - offset + (int16_t) *error];
- }
- *error += (float) offset - (float) T0 * HIBND_ACB_L_FAC - 0.25f * HIBND_ACB_L_FAC * (float) T0_frac;
- }
- else
- {
- offset = T0 * 2 + (int16_t) ( (float) T0_frac * 0.5f + 4 + 0.5f ) - 4;
- for ( i = 0; i < L_subfr * 2; i++ )
- {
- bwe_exc[i + i_subfr * 2] = bwe_exc[i + i_subfr * 2 - offset + (int16_t) *error];
- }
- *error += (float) offset - (float) T0 * 2 - 0.5f * (float) T0_frac;
- }
- return;
-}
-#endif
/*======================================================================================*/
/* FUNCTION : prep_tbe_exc_fx() */
/*--------------------------------------------------------------------------------------*/
@@ -7637,209 +7236,34 @@ void tbe_celp_exc(
/* INPUT/OUTPUT ARGUMENTS : */
/* _ (Word16[]) bwe_exc_fx : excitation for TBE (Q_exc) */
/*--------------------------------------------------------------------------------------*/
-
/* _ None */
/*--------------------------------------------------------------------------------------*/
/* RETURN ARGUMENTS : */
/* _ None */
/*======================================================================================*/
-#ifndef REMOVE_EVS_DUPLICATES
void prep_tbe_exc_fx(
- const Word16 L_frame_fx, /* i : length of the frame */
-#ifdef ADD_IVAS_TBE_CODE
- const Word16 L_subfr,
-#endif
- const Word16 i_subfr_fx, /* i : subframe index */
- const Word16 gain_pit_fx, /* i : Pitch gain Q14*/
- const Word32 gain_code_fx, /* i : algebraic codebook gain 16+Q_exc*/
- const Word16 code_fx[], /* i : algebraic excitation Q9*/
- const Word16 voice_fac_fx, /* i : voicing factor Q15*/
- Word16 *voice_factors_fx, /* o : TBE voicing factor Q15*/
- Word16 bwe_exc_fx[], /* i/o: excitation for TBE Q_exc*/
- const Word16 gain_preQ_fx, /* i : prequantizer excitation gain */
- const Word16 code_preQ_fx[], /* i : prequantizer excitation */
- const Word16 Q_exc, /* i : Excitation, bwe_exc Q-factor */
- Word16 T0, /* i : integer pitch variables Q0 */
- Word16 T0_frac, /* i : Fractional pitch variables Q0*/
- const Word16 coder_type, /* i : coding type */
- Word32 core_brate
-#ifdef ADD_IVAS_TBE_CODE
- , /* i : core bitrate */
- const int16_t element_mode, /* i : element mode */
- const int16_t idchan, /* i : channel ID */
- const int16_t flag_TD_BWE, /* i : flag indicating whether hTD_BWE exists */
- const int16_t tdm_LRTD_flag /* i : LRTD stereo mode flag */
-#endif
-)
-{
- Word16 i;
- Word16 tmp_code_fx[2 * L_SUBFR * HIBND_ACB_L_FAC];
- Word16 tmp_code_preInt_fx[L_SUBFR];
- Word16 gain_code16 = 0;
- move16();
- Word16 tmp /*, tmp1, tmp2*/;
- /*Word16 random_code[L_SUBFR * HIBND_ACB_L_FAC];*/
- Word16 pitch;
-
- Word32 L_tmp, Ltemp1, Ltemp2;
- Word32 tempQ31;
- Word16 tempQ15;
-#ifndef ADD_IVAS_TBE_CODE
- Word16 L_subfr = L_SUBFR;
- move16();
-#endif
-#ifdef BASOP_NOGLOB_DECLARE_LOCAL
- Flag Overflow = 0;
- move32();
-#endif
-
- /**voice_factors = VF_0th_PARAM + VF_1st_PARAM * voice_fac + VF_2nd_PARAM * voice_fac * voice_fac;
- = VF_0th_PARAM + voice_fac * (VF_1st_PARAM + VF_2nd_PARAM * voice_fac )
- *voice_factors = min( max_val(0.0f, *voice_factors), 1.0f); */
- tempQ31 = L_deposit_h( VF_1st_PARAM_FX );
- tempQ15 = mac_r( tempQ31, VF_2nd_PARAM_FX, voice_fac_fx );
- tempQ31 = L_deposit_h( VF_0th_PARAM_FX );
- *voice_factors_fx = mac_r( tempQ31, voice_fac_fx, tempQ15 );
- move16();
- tmp = MAX_16;
- move16();
-
- pitch = shl_o( add( shl_o( T0, 2, &Overflow ), T0_frac ), 5, &Overflow ); /* Q7 */
-
- test();
- test();
- IF( ( ( EQ_16( coder_type, VOICED ) ) || ( GT_16( pitch, 14784 /* 115.5 in Q7 */ ) ) ) && ( GT_32( core_brate, ACELP_8k00 ) ) )
- {
- tmp = MAX_16;
- move16();
- *voice_factors_fx = mult_r( *voice_factors_fx, tmp );
- move16();
- }
-
- *voice_factors_fx = s_min( s_max( *voice_factors_fx, 0 ), MAX_16 );
- move16();
-#ifdef ADD_IVAS_TBE_CODE
- IF( EQ_16( element_mode, IVAS_CPE_TD ) && EQ_16( idchan, 1 ) && !tdm_LRTD_flag )
- {
- IF( flag_TD_BWE && i_subfr == 0 )
- {
- set16_fx( bwe_exc, 0, L_FRAME32k );
- }
- return;
- }
-
-#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 */
- gain_code16 = round_fx_o( L_shl_o( gain_code_fx, Q_exc, &Overflow ), &Overflow ); /*Q_exc */
- 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_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 */
- 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();
- }
- }
- ELSE
- {
- IF( gain_preQ_fx != 0 )
- {
- 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 */
- Ltemp2 = L_mult( gain_preQ_fx, code_preQ_fx[i] ); /*Q2 * Q10 -> Q12 */
-
- 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
- {
- 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 */
- 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();
- }
- }
-
- 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 */
- 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();
- }
- }
-
- return;
-}
-
-/*======================================================================================*/
-/* FUNCTION : prep_tbe_exc_ivas_fx() */
-/*--------------------------------------------------------------------------------------*/
-/* PURPOSE : Prepare TBE excitation */
-/*--------------------------------------------------------------------------------------*/
-/* INPUT ARGUMENTS : */
-/* _ (Word16) L_frame_fx : length of the frame */
-/* _ (Word16) i_subfr_fx : subframe index */
-/* _ (Word16) gain_pit_fx : Pitch gain (14) */
-/* _ (Word32) gain_code_fx : algebraic codebook gain (Q(16+Q_exc)) */
-/* _ (Word16*[]) code_fx : algebraic excitation (Q9) */
-/* _ (Word16) voice_fac_fx : voicing factor (Q15) */
-/* _ (Word16) gain_preQ_fx : prequantizer excitation gain */
-/* _ (Word16[]) code_preQ_fx : prequantizer excitation */
-/*--------------------------------------------------------------------------------------*/
-/* OUTPUT ARGUMENTS : */
-/* _ (Word16*[]) voice_factors_fx : TBE voicing factor (Q15) */
-/*--------------------------------------------------------------------------------------*/
-/* INPUT/OUTPUT ARGUMENTS : */
-/* _ (Word16[]) bwe_exc_fx : excitation for TBE (Q_exc) */
-/*--------------------------------------------------------------------------------------*/
+ const Word16 L_frame_fx, /* i : length of the frame */
+ const Word16 L_subfr, /* i : subframe length */
+ const Word16 i_subfr_fx, /* i : subframe index */
+ const Word16 gain_pit_fx, /* i : Pitch gain Q14*/
+ const Word32 gain_code_fx, /* i : algebraic codebook gain 16+Q_exc*/
+ const Word16 code_fx[], /* i : algebraic excitation Q9*/
+ const Word16 voice_fac_fx, /* i : voicing factor Q15*/
+ Word16 *voice_factors_fx, /* o : TBE voicing factor Q15*/
+ Word16 bwe_exc_fx[], /* i/o: excitation for TBE Q_exc*/
+ const Word16 gain_preQ_fx, /* i : prequantizer excitation gain */
+ const Word16 code_preQ_fx[], /* i : prequantizer excitation */
+ const Word16 Q_exc, /* i : Excitation, bwe_exc Q-factor */
+ const Word16 T0, /* i : integer pitch variables Q0 */
+ const Word16 T0_frac, /* i : Fractional pitch variables Q0*/
+ const Word16 coder_type, /* i : coding type */
+ const Word32 core_brate, /* i : core bitrate */
+ const Word16 element_mode, /* i : element mode */
+ const Word16 idchan, /* i : channel ID */
+ const Word16 flag_TD_BWE, /* i : flag indicating whether hTD_BWE exists */
+ const Word16 tdm_LRTD_flag /* i : LRTD stereo mode flag */
-/* _ None */
-/*--------------------------------------------------------------------------------------*/
-/* RETURN ARGUMENTS : */
-/* _ None */
-/*======================================================================================*/
-#endif
-void prep_tbe_exc_ivas_fx(
- const Word16 L_frame_fx, /* i : length of the frame */
-#if 1 // def ADD_IVAS_TBE_CODE
- const Word16 L_subfr,
-#endif
- const Word16 i_subfr_fx, /* i : subframe index */
- const Word16 gain_pit_fx, /* i : Pitch gain Q14*/
- const Word32 gain_code_fx, /* i : algebraic codebook gain 16+Q_exc*/
- const Word16 code_fx[], /* i : algebraic excitation Q9*/
- const Word16 voice_fac_fx, /* i : voicing factor Q15*/
- Word16 *voice_factors_fx, /* o : TBE voicing factor Q15*/
- Word16 bwe_exc_fx[], /* i/o: excitation for TBE Q_exc*/
- const Word16 gain_preQ_fx, /* i : prequantizer excitation gain */
- const Word16 code_preQ_fx[], /* i : prequantizer excitation */
- const Word16 Q_exc, /* i : Excitation, bwe_exc Q-factor */
- Word16 T0, /* i : integer pitch variables Q0 */
- Word16 T0_frac, /* i : Fractional pitch variables Q0*/
- const Word16 coder_type, /* i : coding type */
- Word32 core_brate
-#if 1 // def ADD_IVAS_TBE_CODE
- , /* i : core bitrate */
- const Word16 element_mode, /* i : element mode */
- const Word16 idchan, /* i : channel ID */
- const Word16 flag_TD_BWE, /* i : flag indicating whether hTD_BWE exists */
- const Word16 tdm_LRTD_flag /* i : LRTD stereo mode flag */
-#endif
)
{
Word16 i;
@@ -7885,7 +7309,7 @@ void prep_tbe_exc_ivas_fx(
*voice_factors_fx = s_min( s_max( *voice_factors_fx, 0 ), MAX_16 );
move16();
-#if 1 // def ADD_IVAS_TBE_CODE
+
test();
test();
IF( EQ_16( element_mode, IVAS_CPE_TD ) && EQ_16( idchan, 1 ) && !tdm_LRTD_flag )
@@ -7898,7 +7322,6 @@ void prep_tbe_exc_ivas_fx(
return;
}
-#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 */
@@ -7957,6 +7380,7 @@ void prep_tbe_exc_ivas_fx(
return;
}
+
/*=============================================================================*/
/* FUNCTION : void swb_formant_fac_fx ( ) */
/*------------------------------------------------------------------------------*/
@@ -7976,9 +7400,10 @@ void prep_tbe_exc_ivas_fx(
/* CALLED FROM : */
/*==============================================================================*/
-Word16 swb_formant_fac_fx( /* o : Formant filter strength [0,1] */
- const Word16 lpc_shb2, /* Q12 i : 2nd HB LPC coefficient */
- Word16 *tilt_mem /* i/o: Tilt smoothing memory (Q12) */
+/*! r: Formant filter strength [0,1] */
+Word16 swb_formant_fac_fx(
+ const Word16 lpc_shb2, /* Q12 i : 2nd HB LPC coefficient */
+ Word16 *tilt_mem /* i/o: Tilt smoothing memory (Q12) */
)
{
Word16 formant_fac;
@@ -7998,7 +7423,6 @@ Word16 swb_formant_fac_fx( /* o : Formant filter strength
tmp = sub( tmp, SWB_TILT_LOW_FX ); /* Q12 */
formant_fac = mult_r( tmp, SWB_TILT_DELTA_FX ); /* Q12 */
-
IF( GT_16( formant_fac, 4096 /* 1 in Q12 */ ) )
{
formant_fac = 4096; /* 1 in Q12 */
@@ -8018,6 +7442,12 @@ Word16 swb_formant_fac_fx( /* o : Formant filter strength
}
+/*-------------------------------------------------------------------*
+ * wb_tbe_extras_reset_fx()
+ *
+ *
+ *-------------------------------------------------------------------*/
+
void wb_tbe_extras_reset_fx(
Word16 mem_genSHBexc_filt_down_wb2[],
Word16 mem_genSHBexc_filt_down_wb3[] )
@@ -8034,7 +7464,6 @@ void wb_tbe_extras_reset_fx(
* Determine TBE bit consumption per frame from bitrate *
*-------------------------------------------------------------------*/
-
Word16 get_tbe_bits_fx(
const Word32 total_brate, /* o : TBE bit consumption per frame */
const Word16 bwidth, /* i : overall bitrate */
diff --git a/lib_com/tcx_mdct_window.c b/lib_com/tcx_mdct_window_fx.c
similarity index 90%
rename from lib_com/tcx_mdct_window.c
rename to lib_com/tcx_mdct_window_fx.c
index 44ce806f73305390709b042c43728ab19ae3aab0..0316ec5827ecd13a1d174b67fb89d18eacdf521b 100644
--- a/lib_com/tcx_mdct_window.c
+++ b/lib_com/tcx_mdct_window_fx.c
@@ -123,9 +123,6 @@ void mdct_window_sine(
Word16 n /* Q0 */
)
{
-#ifdef IVAS_CODE
- if ( element_mode == EVS_MONO )
-#endif
{
const PWord16 *table;
table = getSineWindowTable( n );
@@ -138,42 +135,6 @@ void mdct_window_sine(
}
// PMT("getSineWindowTable needs to be updated for IVAS")
}
-#ifdef IVAS_CODE
- else
- {
- const float *window_table = 0;
- Word16 buf_in_size = 0;
- switch ( window_type )
- {
- case FULL_OVERLAP:
- window_table = tcx_mdct_window_48;
- buf_in_size = 420;
- break;
- case HALF_OVERLAP:
- window_table = tcx_mdct_window_half_48;
- buf_in_size = 180;
- break;
- case TRANSITION_OVERLAP:
- case MIN_OVERLAP:
- window_table = tcx_mdct_window_trans_48;
- buf_in_size = 60;
- break;
-
- default:
- assert( 0 && "Unsupported window type" );
- break;
- }
-
- if ( Fs == 48000 )
- {
- mvr2r( window_table, window, n );
- }
- else
- {
- lerp( window_table, window, n, buf_in_size );
- }
- }
-#endif
}
diff --git a/lib_com/tec_com.c b/lib_com/tec_com_fx.c
similarity index 100%
rename from lib_com/tec_com.c
rename to lib_com/tec_com_fx.c
diff --git a/lib_com/tns_base.c b/lib_com/tns_base.c
index 101bc1df8b6552407c352786dc2e08dd79ec5ec0..5e18430be5631649c80cbd2524996ee7f008a419 100644
--- a/lib_com/tns_base.c
+++ b/lib_com/tns_base.c
@@ -96,10 +96,8 @@ void InitTnsConfiguration(
Word32 nSampleRate;
Word16 s1;
Word16 s2;
-#ifndef ADD_IVAS_TNS
(void) ( element_mode );
(void) ( is_mct );
-#endif
nSampleRate = bwMode2fs[bwidth];
move32();
startLineFilter = &pTnsConfig->iFilterBorders[1];
@@ -138,21 +136,6 @@ void InitTnsConfiguration(
ELSE
IF( GT_32( nSampleRate, INT_FS_16k ) )
{
-#ifdef ADD_IVAS_TNS
- if ( ( element_mode > IVAS_SCE ) && ( total_brate >= ( is_mct ? IVAS_32k : IVAS_48k ) ) )
- {
- pTnsConfig->nMaxFilters = sizeof( tnsParameters32kHz_Stereo ) / sizeof( tnsParameters32kHz_Stereo[0] );
- if ( nSampleRate == 100 * frameLength ) /* sub-frame length is <= 10 ms */
- {
- pTnsConfig->pTnsParameters = tnsParameters32kHz_grouped;
- }
- else
- {
- pTnsConfig->pTnsParameters = tnsParameters32kHz_Stereo;
- }
- }
- else
-#endif
{
move16();
@@ -212,9 +195,6 @@ void InitTnsConfiguration(
move16();
pTnsConfig->iFilterBorders[0] = frameLength;
}
-#ifdef ADD_IVAS_TNS
- pTnsConfig->allowTnsOnWhite = 0;
-#endif
return; /*TNS_NO_ERROR;*/
}
@@ -829,43 +809,19 @@ static Word16 DecodeUsingTable( Decoder_State *st, Word16 *pValue /*Q0*/, const
/* TNS filter coefficients */
-int16_t DecodeSWBTCX20TnsFilterCoeff_flt( Decoder_State *st, const int16_t index, int16_t *pValue )
+Word16 DecodeSWBTCX20TnsFilterCoeff_flt( Decoder_State *st, const Word16 index, Word16 *pValue )
{
assert( ( index >= 0 ) && ( index < nTnsCoeffTables ) );
return DecodeUsingTable( st, pValue, codesTnsCoeffSWBTCX20[index], nTnsCoeffCodes );
}
-// int16_t GetSWBTCX10TnsFilterCoeffBits_flt( const int16_t value, const int16_t index )
-//{
-// assert( ( index >= 0 ) && ( index < nTnsCoeffTables ) );
-// return GetBitsFromTable( value, codesTnsCoeffSWBTCX10[index], nTnsCoeffCodes );
-// }
-
-// int16_t EncodeSWBTCX10TnsFilterCoeff_flt( const int16_t value, const int16_t index )
-//{
-// assert( ( index >= 0 ) && ( index < nTnsCoeffTables ) );
-// return EncodeUsingTable( value, codesTnsCoeffSWBTCX10[index], nTnsCoeffCodes );
-// }
-
-int16_t DecodeSWBTCX10TnsFilterCoeff_flt( Decoder_State *st, const int16_t index, int16_t *pValue )
+Word16 DecodeSWBTCX10TnsFilterCoeff_flt( Decoder_State *st, const Word16 index, Word16 *pValue )
{
assert( ( index >= 0 ) && ( index < nTnsCoeffTables ) );
return DecodeUsingTable( st, pValue, codesTnsCoeffSWBTCX10[index], nTnsCoeffCodes );
}
-// int16_t GetWBTCX20TnsFilterCoeffBits_flt( const int16_t value, const int16_t index )
-//{
-// assert( ( index >= 0 ) && ( index < nTnsCoeffTables ) );
-// return GetBitsFromTable( value, codesTnsCoeffWBTCX20[index], nTnsCoeffCodes );
-// }
-
-// int16_t EncodeWBTCX20TnsFilterCoeff_flt( const int16_t value, const int16_t index )
-//{
-// assert( ( index >= 0 ) && ( index < nTnsCoeffTables ) );
-// return EncodeUsingTable( value, codesTnsCoeffWBTCX20[index], nTnsCoeffCodes );
-// }
-
-int16_t DecodeWBTCX20TnsFilterCoeff_flt( Decoder_State *st, const int16_t index, int16_t *pValue )
+Word16 DecodeWBTCX20TnsFilterCoeff_flt( Decoder_State *st, const Word16 index, Word16 *pValue )
{
assert( ( index >= 0 ) && ( index < nTnsCoeffTables ) );
return DecodeUsingTable( st, pValue, codesTnsCoeffWBTCX20[index], nTnsCoeffCodes );
@@ -874,49 +830,25 @@ int16_t DecodeWBTCX20TnsFilterCoeff_flt( Decoder_State *st, const int16_t index,
/* TNS filter order */
-// void const *GetTnsFilterOrder_flt( void const *p, const int16_t index, int16_t *pValue )
-//{
-// *pValue = ( (STnsFilter const *) p )[index].order;
-// return ( (STnsFilter const *) p )[index].coefIndex;
-// }
-
-// void *SetTnsFilterOrder_flt( void *p, const int16_t index, const int16_t value )
-//{
-// ( (STnsFilter *) p )[index].order = value;
-// return ( (STnsFilter *) p )[index].coefIndex;
-// }
-
-// int16_t GetTnsFilterOrderBitsSWBTCX20_flt( const int16_t value, const int16_t index )
-//{
-// (void) index;
-// return GetBitsFromTable( value - 1, codesTnsOrderTCX20, nTnsOrderCodes );
-// }
-
-// int16_t EncodeTnsFilterOrderSWBTCX20_flt( const int16_t value, const int16_t index )
-//{
-// (void) index;
-// return EncodeUsingTable( value - 1, codesTnsOrderTCX20, nTnsOrderCodes );
-// }
-
-int16_t DecodeTnsFilterOrderSWBTCX20_flt( Decoder_State *st, const int16_t index, int16_t *pValue )
+Word16 DecodeTnsFilterOrderSWBTCX20_flt( Decoder_State *st, const Word16 index, Word16 *pValue )
{
(void) index;
return DecodeUsingTable( st, pValue, codesTnsOrderTCX20, nTnsOrderCodes );
}
-int16_t GetTnsFilterOrderBitsSWBTCX10_flt( const int16_t value, const int16_t index )
+Word16 GetTnsFilterOrderBitsSWBTCX10_flt( const Word16 value, const Word16 index )
{
(void) index;
return GetBitsFromTable( value - 1, codesTnsOrderTCX10, nTnsOrderCodes );
}
-int16_t EncodeTnsFilterOrderSWBTCX10_flt( const int16_t value, const int16_t index )
+Word16 EncodeTnsFilterOrderSWBTCX10_flt( const Word16 value, const Word16 index )
{
(void) index;
return EncodeUsingTable( value - 1, codesTnsOrderTCX10, nTnsOrderCodes );
}
-int16_t DecodeTnsFilterOrderSWBTCX10_flt( Decoder_State *st, const int16_t index, int16_t *pValue )
+Word16 DecodeTnsFilterOrderSWBTCX10_flt( Decoder_State *st, const Word16 index, Word16 *pValue )
{
(void) index;
return DecodeUsingTable( st, pValue, codesTnsOrderTCX10, nTnsOrderCodes );
@@ -1125,42 +1057,36 @@ void *SetTnsEnabled( void *p, const Word16 index, const Word16 value )
/* Number of TNS filters */
-void const *GetNumOfTnsFilters_flt( void const *p, const int16_t index, int16_t *pValue )
+void const *GetNumOfTnsFilters_flt( void const *p, const Word16 index, Word16 *pValue )
{
- *pValue = (int16_t) abs( ( (STnsData const *) p )[index].nFilters );
+ *pValue = (Word16) abs( ( (STnsData const *) p )[index].nFilters );
return ( (STnsData const *) p )[index].filter;
}
-void *SetNumOfTnsFilters_flt( void *p, const int16_t index, const int16_t value )
+void *SetNumOfTnsFilters_flt( void *p, const Word16 index, const Word16 value )
{
- ( (STnsData *) p )[index].nFilters = (int16_t) abs( value );
+ ( (STnsData *) p )[index].nFilters = (Word16) abs( value );
return ( (STnsData *) p )[index].filter;
}
-int16_t DecodeTnsFilterOrder_flt( Decoder_State *st, const int16_t index, int16_t *pValue )
+Word16 DecodeTnsFilterOrder_flt( Decoder_State *st, const Word16 index, Word16 *pValue )
{
(void) index;
return DecodeUsingTable( st, pValue, codesTnsOrder, nTnsOrderCodes );
}
/* TNS on whitened spectra flag */
-void const *GetTnsOnWhite( void const *p, const int16_t index, int16_t *pValue )
+void const *GetTnsOnWhite( void const *p, const Word16 index, Word16 *pValue )
{
*pValue = ( (STnsData const *) p )[index].tnsOnWhitenedSpectra > 0 ? 1 : 0;
return NULL;
}
-void *SetTnsOnWhite( void *p, const int16_t index, const int16_t value )
+void *SetTnsOnWhite( void *p, const Word16 index, const Word16 value )
{
( (STnsData *) p )[index].tnsOnWhitenedSpectra = value;
return NULL;
}
-// void const *GetTnsEnabledSingleFilter( void const *p, const int16_t index, int16_t *pValue )
-//{
-// *pValue = ( (STnsData const *) p )[index].nFilters != 0 ? 1 : 0;
-// return ( (STnsData const *) p )[index].filter;
-// }
-
void const *GetTnsEnabledSingleFilter( void const *p, const Word16 index, Word16 *pValue )
{
move16();
diff --git a/lib_com/tools.c b/lib_com/tools.c
index f7303c6f3231373d0790f6f2a3b44ed3b8e83f2b..9166d16eb4226e03503dca05ee5e1937f06336bd 100644
--- a/lib_com/tools.c
+++ b/lib_com/tools.c
@@ -47,51 +47,23 @@
*------------------------------------------------------------------*/
/*! r: output random value */
-int16_t own_random(
- int16_t *seed /* i/o: random seed */
+Word16 own_random(
+ Word16 *seed /* i/o: random seed */
)
{
- *seed = (int16_t) ( *seed * 31821L + 13849L );
+ *seed = (Word16) ( *seed * 31821L + 13849L );
return ( *seed );
}
/*---------------------------------------------------------------------
- * sign()
+ * norm_ul_float()
*
*---------------------------------------------------------------------*/
-/*! r: sign of x (+1/-1) */
-float sign(
- const float x /* i : input value of x */
-)
+Word16 norm_ul_float( UWord32 UL_var1 )
{
- if ( x < 0.0f )
- {
- return -1.0f;
- }
- else
- {
- return 1.0f;
- }
-}
-
-/*---------------------------------------------------------------------
- * log2_f()
- *
- *---------------------------------------------------------------------*/
-
-/*! r: logarithm2 of x */
-float log2_f(
- const float x /* i : input value of x */
-)
-{
- return (float) ( log( x ) / log( 2.0f ) );
-}
-
-int16_t norm_ul_float( uint32_t UL_var1 )
-{
- int16_t var_out;
+ Word16 var_out;
if ( UL_var1 == 0 )
{
@@ -99,7 +71,7 @@ int16_t norm_ul_float( uint32_t UL_var1 )
}
else
{
- for ( var_out = 0; UL_var1 < (uint32_t) 0x80000000U; var_out++ )
+ for ( var_out = 0; UL_var1 < (UWord32) 0x80000000U; var_out++ )
{
UL_var1 <<= 1;
}
@@ -118,13 +90,13 @@ int16_t norm_ul_float( uint32_t UL_var1 )
*---------------------------------------------------------------------*/
/*! r: sum of all vector elements */
-int16_t sum_s(
- const int16_t *vec, /* i : input vector */
- const int16_t lvec /* i : length of input vector */
+Word16 sum_s(
+ const Word16 *vec, /* i : input vector */
+ const Word16 lvec /* i : length of input vector */
)
{
- int16_t i;
- int16_t tmp;
+ Word16 i;
+ Word16 tmp;
tmp = 0;
for ( i = 0; i < lvec; i++ )
@@ -182,7 +154,7 @@ Word32 sum2_f_16_gb_fx(
const Word16 lvec, /* i : length of input vector */
Word16 gb )
{
- int16_t i;
+ Word16 i;
Word32 tmp;
tmp = 0;
@@ -311,7 +283,6 @@ Word32 sum2_32_fx(
/*-------------------------------------------------------------------*
* set_c()
* set_s()
- * set_f()
* set_l()
* set_d()
*
@@ -319,12 +290,12 @@ Word32 sum2_32_fx(
*-------------------------------------------------------------------*/
void set_c(
- int8_t y[], /* i/o: Vector to set */
- const int8_t a, /* i : Value to set the vector to */
- const int32_t N /* i : Length of the vector */
+ Word8 y[], /* i/o: Vector to set */
+ const Word8 a, /* i : Value to set the vector to */
+ const Word32 N /* i : Length of the vector */
)
{
- int16_t i;
+ Word16 i;
for ( i = 0; i < N; i++ )
{
@@ -336,12 +307,12 @@ void set_c(
void set_s(
- int16_t y[], /* i/o: Vector to set */
- const int16_t a, /* i : Value to set the vector to */
- const int16_t N /* i : Length of the vector */
+ Word16 y[], /* i/o: Vector to set */
+ const Word16 a, /* i : Value to set the vector to */
+ const Word16 N /* i : Length of the vector */
)
{
- int16_t i;
+ Word16 i;
for ( i = 0; i < N; i++ )
{
@@ -353,28 +324,12 @@ void set_s(
void set_l(
- int32_t y[], /* i/o: Vector to set */
- const int32_t a, /* i : Value to set the vector to */
- const int16_t N /* i : Length of the vector */
-)
-{
- int16_t i;
-
- for ( i = 0; i < N; i++ )
- {
- y[i] = a;
- }
-
- return;
-}
-
-void set_f(
- float y[], /* i/o: Vector to set */
- const float a, /* i : Value to set the vector to */
- const int16_t N /* i : Lenght of the vector */
+ Word32 y[], /* i/o: Vector to set */
+ const Word32 a, /* i : Value to set the vector to */
+ const Word16 N /* i : Length of the vector */
)
{
- int16_t i;
+ Word16 i;
for ( i = 0; i < N; i++ )
{
@@ -391,11 +346,11 @@ void set_f(
*---------------------------------------------------------------------*/
void set_zero(
- float *vec, /* o : input vector */
- const int16_t lvec /* i : length of the vector */
+ float *vec, /* o : input vector */
+ const Word16 lvec /* i : length of the vector */
)
{
- int16_t i;
+ Word16 i;
for ( i = 0; i < lvec; i++ )
{
@@ -409,8 +364,6 @@ void set_zero(
/*---------------------------------------------------------------------*
* mvr2r()
* mvs2s()
- * mvr2s()
- * mvs2r()
* mvr2d()
* mvd2r()
*
@@ -420,10 +373,10 @@ void set_zero(
void mvr2r(
const float x[], /* i : input vector */
float y[], /* o : output vector */
- const int16_t n /* i : vector size */
+ const Word16 n /* i : vector size */
)
{
- int16_t i;
+ Word16 i;
if ( n <= 0 )
{
@@ -450,12 +403,12 @@ void mvr2r(
}
void mvs2s(
- const int16_t x[], /* i : input vector */
- int16_t y[], /* o : output vector */
- const int16_t n /* i : vector size */
+ const Word16 x[], /* i : input vector */
+ Word16 y[], /* o : output vector */
+ const Word16 n /* i : vector size */
)
{
- int16_t i;
+ Word16 i;
if ( n <= 0 )
{
@@ -482,12 +435,12 @@ void mvs2s(
}
void mvl2l(
- const int32_t x[], /* i : input vector */
- int32_t y[], /* o : output vector */
- const int16_t n /* i : vector size */
+ const Word32 x[], /* i : input vector */
+ Word32 y[], /* o : output vector */
+ const Word16 n /* i : vector size */
)
{
- int16_t i;
+ Word16 i;
if ( n <= 0 )
{
@@ -687,32 +640,6 @@ Word16 minimum_l(
return ind;
}
-/*---------------------------------------------------------------------*
- * dotp()
- *
- * Dot product of vector x[] and vector y[]
- *---------------------------------------------------------------------*/
-
-/*! r: dot product of x[] and y[] */
-float dotp(
- const float x[], /* i : vector x[] */
- const float y[], /* i : vector y[] */
- const int16_t n /* i : vector length */
-)
-{
- int16_t i;
- float suma;
-
- suma = x[0] * y[0];
-
- for ( i = 1; i < n; i++ )
- {
- suma += x[i] * y[i];
- }
-
- return suma;
-}
-
/*---------------------------------------------------------------------*
* dotp()
*
@@ -800,20 +727,6 @@ Word32 dotp_fixed_32(
return W_extract_l( suma );
}
-/*---------------------------------------------------------------------*
- * inv_sqrt()
- *
- * Find the inverse square root of the input value
- *---------------------------------------------------------------------*/
-
-/*! r: inverse square root of input value */
-float inv_sqrt(
- const float x /* i : input value */
-)
-{
- return (float) ( 1.0 / sqrt( x ) );
-}
-
/*-------------------------------------------------------------------*
* v_add_w64()
*
@@ -839,32 +752,8 @@ void v_add_w64(
return;
}
-
-/*-------------------------------------------------------------------*
- * v_sub()
- *
- * Subtraction of two vectors sample by sample
- *-------------------------------------------------------------------*/
-
-void v_sub(
- const float x1[], /* i : Input vector 1 */
- const float x2[], /* i : Input vector 2 */
- float y[], /* o : Output vector that contains vector 1 - vector 2 */
- const int16_t N /* i : Vector length */
-)
-{
- int16_t i;
-
- for ( i = 0; i < N; i++ )
- {
- y[i] = x1[i] - x2[i];
- }
-
- return;
-}
-
/*-------------------------------------------------------------------*
- * v_sub()
+ * v_sub_fixed()
*
* Subtraction of two vectors sample by sample
*-------------------------------------------------------------------*/
@@ -977,9 +866,9 @@ void v_multc_fixed_16_16(
*-------------------------------------------------------------------*/
float usdequant(
- const int16_t idx, /* i : quantizer index */
- const float qlow, /* i : lowest codebook entry (index 0) */
- const float delta /* i : quantization step */
+ const Word16 idx, /* i : quantizer index */
+ const float qlow, /* i : lowest codebook entry (index 0) */
+ const float delta /* i : quantization step */
)
{
float g;
diff --git a/lib_com/tools_fx.c b/lib_com/tools_fx.c
index 44a86b0ebd8e63ff6a8194689245f95b35378d4f..137e2a40e4830b8176d11bc9f82944119d18aedf 100644
--- a/lib_com/tools_fx.c
+++ b/lib_com/tools_fx.c
@@ -241,9 +241,9 @@ void fix2f_16( Word16 *var_fix, float *var_flt, Word32 expo )
#undef WMC_TOOL_SKIP
-int16_t norm_ul( uint32_t UL_var1 )
+Word16 norm_ul( UWord32 UL_var1 )
{
- int16_t var_out;
+ Word16 var_out;
if ( UL_var1 == 0 )
{
@@ -251,7 +251,7 @@ int16_t norm_ul( uint32_t UL_var1 )
}
else
{
- for ( var_out = 0; UL_var1 < (uint32_t) 0x80000000U; var_out++ )
+ for ( var_out = 0; UL_var1 < (UWord32) 0x80000000U; var_out++ )
{
UL_var1 <<= 1;
}
@@ -284,6 +284,30 @@ Word16 usdequant_fx( /* Qx*/
return ( g );
}
+Word32 usdequant32_fx( /* Qx*/
+ const Word16 idx, /* i: quantizer index Q0*/
+ const Word32 qlow, /* i: lowest codebook entry (index 0) Qx*/
+ const Word32 delta /* i: quantization step Qx-1*/
+)
+{
+ Word32 g;
+ Word64 L_tmp;
+
+ /*g = idx * delta + qlow;*/
+ L_tmp = W_deposit32_l( qlow ); /*Qx */
+ L_tmp = W_mac_32_16( L_tmp, delta, idx );
+ IF( GE_64( L_tmp, MAX_32 ) )
+ {
+ g = MAX_32;
+ move32();
+ }
+ ELSE
+ {
+ g = W_extract_l( L_tmp ); /*Qx */
+ }
+ return ( g );
+}
+
/*-------------------------------------------------------------------*
* usquant()
*
@@ -973,7 +997,7 @@ void scale_sig(
}
/*---------------------------------------------------------------------*
- * mean()
+ * mean_fx()
*
*---------------------------------------------------------------------*/
Word16 mean_fx( /* o : mean of vector */
@@ -2147,7 +2171,7 @@ Word16 own_random2_fx( Word16 seed )
}
/*---------------------------------------------------------------------
- * sign()
+ * sign_fx()
*
*---------------------------------------------------------------------*/
@@ -3840,6 +3864,58 @@ void hp400_12k8_fx(
return;
}
+void hp400_12k8_ivas_fx(
+ Word16 signal[], /* i/o: input signal / output is divided by 16 */
+ const Word16 lg, /* i : lenght of signal */
+ Word16 mem[] /* i/o: filter memory [6] */
+)
+{
+ Word16 i;
+ Word16 x0, x1, x2;
+ Word32 L_tmp, yy1, y2;
+
+ yy1 = L_Comp( mem[2], mem[3] ); /* Q_syn + 13 */
+ y2 = L_Comp( mem[0], mem[1] ); /* Q_syn + 13 */
+ x0 = mem[4]; /* Q_syn */
+ move16();
+ x1 = mem[5]; /* Q_syn */
+ move16();
+
+ FOR( i = 0; i < lg; i++ )
+ {
+ x2 = x1; /* Q_syn */
+ move16();
+ x1 = x0; /* Q_syn */
+ move16();
+ x0 = signal[i]; /* Q_syn */
+ move16();
+
+ L_tmp = Mpy_32_16_1( yy1, a_hp400_ivas_fx[1] ); /*yy1 * a_hp400[1]*/ /* Qx(Q_of_yy1) + 10 ---->( (Q_syn+13) + 12 - 15)*/
+ L_tmp = Madd_32_16( L_tmp, y2, a_hp400_ivas_fx[2] ); /*y2 * a_hp400[2]*/ /* Qx + 10 ---->( (Q_syn+13) + 12 - 15)*/
+ L_tmp = L_shl( L_tmp, 3 ); /* shifting by 3 to maintain same Q (Q_syn+13) */
+
+ L_tmp = L_mac( L_tmp, x0, b_hp400_fx[0] ); /* Q_syn + 13 */
+ L_tmp = L_mac( L_tmp, x1, b_hp400_fx[1] ); /* Q_syn + 13 */
+ L_tmp = L_mac( L_tmp, x2, b_hp400_fx[2] ); /* Q_syn + 13 */
+
+ y2 = yy1; /* Q_syn + 13 */
+ move32();
+ yy1 = L_tmp; /* Q_syn + 13 */
+ move32();
+
+ signal[i] = round_fx( L_tmp ); /* Q_syn - 3 */
+ move16();
+ }
+
+ L_Extract( yy1, &mem[2], &mem[3] );
+ L_Extract( y2, &mem[0], &mem[1] );
+ mem[4] = x0; /* Q_syn */
+ mem[5] = x1; /* Q_syn */
+ move16();
+ move16();
+ return;
+}
+
Word16 dot_prod_satcontr( const Word16 *x, const Word16 *y, Word16 qx, Word16 qy, Word16 *qo, Word16 len )
{
Word16 tmp_tab_x[L_FRAME16k];
@@ -4183,7 +4259,7 @@ Word16 lin_interp_ivas_fx(
}
/*---------------------------------------------------------------------
- * sign()
+ * sign_l()
*
*---------------------------------------------------------------------*/
@@ -4221,7 +4297,7 @@ void v_mult16_fixed(
}
/*---------------------------------------------------------------------*
- * set_zero()
+ * set_zero_fx()
*
* Set a vector vec[] of dimension lvec to zero
*---------------------------------------------------------------------*/
@@ -4714,6 +4790,18 @@ Flag is_zero_arr16( Word16 *arr, Word16 size )
return 1;
}
+Flag is_zero_arr64( Word64 *arr, Word16 size )
+{
+ FOR( Word16 i = 0; i < size; i++ )
+ {
+ IF( arr[i] != 0 )
+ {
+ return 0;
+ }
+ }
+ return 1;
+}
+
void Scale_sig64(
Word64 x[], /* i/o: signal to scale Qx */
Word16 len, /* i : size of x[] Q0 */
diff --git a/lib_com/wtda.c b/lib_com/wtda.c
deleted file mode 100644
index 3fb40813816c7b4462bdcc3ec82b8df2314fb845..0000000000000000000000000000000000000000
--- a/lib_com/wtda.c
+++ /dev/null
@@ -1,219 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository. All Rights Reserved.
-
- This software is protected by copyright law and by international treaties.
- The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository retain full ownership rights in their respective contributions in
- the software. This notice grants no license of any kind, including but not limited to patent
- license, nor is any license granted by implication, estoppel or otherwise.
-
- Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
- contributions.
-
- This software is provided "AS IS", without any express or implied warranties. The software is in the
- development stage. It is intended exclusively for experts who have experience with such software and
- solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
- and fitness for a particular purpose are hereby disclaimed and excluded.
-
- Any dispute, controversy or claim arising under or in relation to providing this software shall be
- submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
- accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
- the United Nations Convention on Contracts on the International Sales of Goods.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include "cnst.h"
-#include "prot_fx.h"
-#include "rom_com.h"
-#include
-#include "wmc_auto.h"
-
-
-void wtda_fx32(
- const Word32 *new_audio, /* i : input audio Q11 */
- Word32 *wtda_audio, /* o : windowed audio Q11 */
- Word32 *old_wtda, /* i/o: windowed audio from previous frame */
- 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 */
-)
-{
- Word16 i, decimate, decay;
- Word16 idx1, idx2, idx3, idx4;
- Word16 n, windecay48, windecay16;
- const Word32 *allsig_l, *allsig_r;
- Word16 win_right[R2_48];
- Word16 win_int_left[R1_16];
- Word16 win_left[R1_48];
- Word16 win_int_right[R2_16];
-
- tcx_get_windows_mode1( left_mode, right_mode, win_left, win_right, win_int_left, win_int_right, L );
-
- decimate = 1; /* L_FRAME 48k */
- move16();
- decay = 0;
- move16();
- windecay48 = extract_l( WINDECAY48 ); // (int16_t)(2 * ((float)L_FRAME48k * N_ZERO_MDCT_NS / FRAME_SIZE_NS)) + R1_48
-
- test();
- IF( EQ_16( L, L_FRAME32k ) || EQ_16( L, L_FRAME16k ) )
- {
- decimate = 3;
- move16();
- decay = 1;
- move16();
- }
- ELSE IF( EQ_16( L, L_FRAME8k ) )
- {
- decimate = 6;
- move16();
- decay = 2;
- move16();
- }
-
- SWITCH( L ) // (int16_t)((float)L * N_ZERO_MDCT_NS / FRAME_SIZE_NS)
- {
- case L_FRAME16k:
- n = 90;
- move16();
- BREAK;
- case L_FRAME32k:
- n = 180;
- move16();
- BREAK;
- case L_FRAME48k:
- n = 270;
- move16();
- BREAK;
- default:
- n = (Word16) ( ( L * N_ZERO_MDCT_NS ) / FRAME_SIZE_NS );
- move16();
- BREAK;
- }
-
- windecay16 = extract_l( WINDECAY16 ); // (int16_t)(2 * ((float)L_FRAME16k * N_ZERO_MDCT_NS / FRAME_SIZE_NS)) + R1_16;
-
- /* algorithmic delay reduction */
- i = 0;
- move16();
-
- IF( old_wtda == NULL )
- {
- allsig_r = new_audio + n;
- allsig_l = new_audio + n - L;
- }
- ELSE
- {
- allsig_r = new_audio + n;
- allsig_l = old_wtda + n;
- }
-
- IF( EQ_16( L, L_FRAME32k ) )
- {
- FOR( i = 0; i < ( L / 2 - n ); i += 2 )
- {
- idx1 = sub( sub( shr( L, 1 ), i ), 1 );
- idx2 = sub( sub( 3 * L_FRAME16k / 2 - 1, shr( i, 1 ) ), windecay16 );
- idx3 = add( shr( L, 1 ), i );
- idx4 = sub( add( 3 * L_FRAME16k / 2, shr( i, 1 ) ), windecay16 );
- wtda_audio[i] = L_sub_sat( Mpy_32_16_1( -allsig_r[idx1], win_int_right[idx2] ), Mpy_32_16_1( allsig_r[idx3], win_int_right[idx4] ) );
- move32();
-
- idx1 = sub( sub( shr( L, 1 ), add( i, 1 ) ), 1 );
- idx2 = sub( add( i_mult( ( sub( sub( 3 * L_FRAME16k / 2, shr( i, 1 ) ), 1 ) ), decimate ), decay ), windecay48 );
- idx3 = add( add( shr( L, 1 ), i ), 1 );
- idx4 = sub( sub( sub( i_mult( ( add( 3 * L_FRAME16k / 2 + 1, shr( i, 1 ) ) ), decimate ), decay ), 1 ), windecay48 );
- wtda_audio[i + 1] = L_sub_sat( Mpy_32_16_1( -allsig_r[idx1], win_right[idx2] ), Mpy_32_16_1( allsig_r[idx3], win_right[idx4] ) );
- move32();
- }
-
- FOR( i = L / 2 - n; i < L / 2; i += 2 )
- {
- wtda_audio[i] = L_negate( allsig_r[( ( ( L >> 1 ) - i ) - 1 )] );
- move32();
- wtda_audio[i + 1] = L_negate( allsig_r[( ( ( L >> 1 ) - ( i + 1 ) ) - 1 )] );
- move32();
- }
- FOR( i = 0; i < n; i += 2 )
- {
- wtda_audio[( i + ( L >> 1 ) )] = L_sub_sat( Mpy_32_16_1( allsig_l[i], win_left[( ( ( i >> 1 ) * decimate ) + decay )] ), new_audio[( ( n - i ) - 1 )] );
- move32();
- wtda_audio[( ( i + ( L >> 1 ) ) + 1 )] = L_sub_sat( Mpy_32_16_1( allsig_l[i + 1], win_int_left[i / 2] ), new_audio[( ( n - ( i + 1 ) ) - 1 )] );
- move32();
- }
-
- FOR( i = n; i < L / 2; i += 2 )
- {
- idx1 = i;
- move16();
- idx2 = add( i_mult( shr( i, 1 ), decimate ), decay );
- idx3 = sub( sub( L, i ), 1 );
- idx4 = sub( sub( i_mult( sub( shr( L, 1 ), shr( i, 1 ) ), decimate ), 1 ), decay );
- wtda_audio[( i + ( L >> 1 ) )] = L_sub_sat( Mpy_32_16_1( allsig_l[idx1], win_left[idx2] ), Mpy_32_16_1( allsig_l[idx3], win_left[idx4] ) );
- move32();
-
- idx1 = add( i, 1 );
- idx2 = shr( i, 1 );
- idx3 = sub( sub( L, add( i, 1 ) ), 1 );
- idx4 = sub( sub( shr( L, 1 ), shr( i, 1 ) ), 1 );
- wtda_audio[( ( i + ( L >> 1 ) ) + 1 )] = L_sub_sat( Mpy_32_16_1( allsig_l[idx1], win_int_left[idx2] ), Mpy_32_16_1( allsig_l[idx3], win_int_left[idx4] ) );
- move32();
- }
- }
- ELSE
- {
- FOR( i = 0; i < L / 2 - n; i++ )
- {
- idx1 = sub( sub( shr( L, 1 ), i ), 1 );
- idx2 = sub( add( sub( i_mult( i_mult( 3, shr( L, 1 ) ), decimate ), i_mult( add( i, 1 ), decimate ) ), decay ), windecay48 );
- idx3 = add( shr( L, 1 ), i );
- idx4 = sub( sub( add( sub( i_mult( i_mult( 3, shr( L, 1 ) ), decimate ), 1 ), i_mult( add( i, 1 ), decimate ) ), decay ), windecay48 );
- wtda_audio[i] = L_sub_sat( Mpy_32_16_1( -allsig_r[idx1], win_right[idx2] ), Mpy_32_16_1( allsig_r[idx3], win_right[idx4] ) );
- move32();
- }
-
- FOR( i = L / 2 - n; i < L / 2; i++ )
- {
- wtda_audio[i] = L_negate( allsig_r[( ( ( L >> 1 ) - i ) - 1 )] );
- move32();
- }
-
- FOR( i = 0; i < n; i++ )
- {
- wtda_audio[( i + ( L >> 1 ) )] = L_sub_sat( Mpy_32_16_1( allsig_l[i], win_left[( ( i * decimate ) + decay )] ), new_audio[( ( n - i ) - 1 )] );
- move32();
- }
-
- FOR( i = n; i < L / 2; i++ )
- {
- idx1 = i;
- move16();
- idx2 = add( i_mult( i, decimate ), decay );
- idx3 = sub( sub( L, i ), 1 );
- idx4 = sub( sub( sub( i_mult( L, decimate ), i_mult( i, decimate ) ), 1 ), decay );
- wtda_audio[( i + ( L >> 1 ) )] = L_sub_sat( Mpy_32_16_1( allsig_l[idx1], win_left[idx2] ), Mpy_32_16_1( allsig_l[idx3], win_left[idx4] ) );
- move32();
- }
- }
-
- IF( old_wtda != NULL )
- {
- Copy32( new_audio, old_wtda, L );
- }
-
- return;
-}
diff --git a/lib_com/wtda_fx.c b/lib_com/wtda_fx.c
index e060984dff14eb316ed1d965e06830487eb1624b..7943a87c5fc11a276127169b3e0dd8ee8f88895a 100644
--- a/lib_com/wtda_fx.c
+++ b/lib_com/wtda_fx.c
@@ -2,11 +2,14 @@
EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
====================================================================================*/
#include
+#include
#include "options.h" /* Compilation switches */
#include "cnst.h" /* Common constants */
#include "rom_com.h" /* Static table prototypes */
#include "prot_fx.h" /* required by wmc_tool */
#include "stat_com.h"
+#include "wmc_auto.h"
+
/*--------------------------------------------------------------------------*
* mvr2r_inv()
*
@@ -412,21 +415,19 @@ void wtda_fx(
return;
}
-
-void wtda_ivas_fx(
- Word16 *new_audio, /* i : input audio Q0 */
- Word16 *Q, /* i/o : Q of input/Output Audio */
- Word16 *wtda_audio, /* o : windowed audio Qout */
- Word16 *old_wtda, /* i/o: windowed audio from previous frame Qout */
- Word16 *Qold_wtda,
+void wtda_fx32(
+ const Word32 *new_audio, /* i : input audio Q11 */
+ Word32 *wtda_audio, /* o : windowed audio Q11 */
+ Word32 *old_wtda, /* i/o: windowed audio from previous frame */
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 */
)
{
Word16 i, decimate, decay;
+ Word16 idx1, idx2, idx3, idx4;
Word16 n, windecay48, windecay16;
- const Word16 *allsig_l, *allsig_r;
+ const Word32 *allsig_l, *allsig_r;
Word16 win_right[R2_48];
Word16 win_int_left[R1_16];
Word16 win_left[R1_48];
@@ -434,12 +435,11 @@ void wtda_ivas_fx(
tcx_get_windows_mode1( left_mode, right_mode, win_left, win_right, win_int_left, win_int_right, L );
- decimate = 1; /* L_FRAME48k */
+ decimate = 1; /* L_FRAME 48k */
move16();
decay = 0;
move16();
- windecay48 = ( 2 * ( (Word64) L_FRAME48k * N_ZERO_MDCT_NS / FRAME_SIZE_NS ) ) + R1_48;
- move16();
+ windecay48 = extract_l( WINDECAY48 ); // (int16_t)(2 * ((float)L_FRAME48k * N_ZERO_MDCT_NS / FRAME_SIZE_NS)) + R1_48
test();
IF( EQ_16( L, L_FRAME32k ) || EQ_16( L, L_FRAME16k ) )
@@ -457,10 +457,27 @@ void wtda_ivas_fx(
move16();
}
- n = extract_l( Mpy_32_32( L, 603979776 /* N_ZERO_MDCT_NS / FRAME_SIZE_NS in Q31 */ ) );
+ SWITCH( L ) // (int16_t)((float)L * N_ZERO_MDCT_NS / FRAME_SIZE_NS)
+ {
+ case L_FRAME16k:
+ n = 90;
+ move16();
+ BREAK;
+ case L_FRAME32k:
+ n = 180;
+ move16();
+ BREAK;
+ case L_FRAME48k:
+ n = 270;
+ move16();
+ BREAK;
+ default:
+ n = (Word16) ( ( L * N_ZERO_MDCT_NS ) / FRAME_SIZE_NS );
+ move16();
+ BREAK;
+ }
- windecay16 = ( 2 * ( L_FRAME16k * N_ZERO_MDCT_NS / FRAME_SIZE_NS ) ) + R1_16;
- move16();
+ windecay16 = extract_l( WINDECAY16 ); // (int16_t)(2 * ((float)L_FRAME16k * N_ZERO_MDCT_NS / FRAME_SIZE_NS)) + R1_16;
/* algorithmic delay reduction */
i = 0;
@@ -473,103 +490,106 @@ void wtda_ivas_fx(
}
ELSE
{
- /* Rescale signals if Q are not identical */
- IF( GT_16( *Qold_wtda, *Q ) )
- {
- Copy_Scale_sig( old_wtda, old_wtda, L, sub( *Q, *Qold_wtda ) );
- *Qold_wtda = *Q;
- move16();
- }
- ELSE IF( LT_16( *Qold_wtda, *Q ) )
- {
- Copy_Scale_sig( new_audio, new_audio, L, sub( *Qold_wtda, *Q ) );
- *Q = *Qold_wtda;
- move16();
- }
-
allsig_r = new_audio + n;
allsig_l = old_wtda + n;
}
IF( EQ_16( L, L_FRAME32k ) )
{
- FOR( i = 0; i < L / 2 - n; i += 2 )
+ 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] ) );
- 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] ) );
- move16();
+ idx1 = sub( sub( shr( L, 1 ), i ), 1 );
+ idx2 = sub( sub( 3 * L_FRAME16k / 2 - 1, shr( i, 1 ) ), windecay16 );
+ idx3 = add( shr( L, 1 ), i );
+ idx4 = sub( add( 3 * L_FRAME16k / 2, shr( i, 1 ) ), windecay16 );
+ wtda_audio[i] = L_sub_sat( Mpy_32_16_1( -allsig_r[idx1], win_int_right[idx2] ), Mpy_32_16_1( allsig_r[idx3], win_int_right[idx4] ) );
+ move32();
+
+ idx1 = sub( sub( shr( L, 1 ), add( i, 1 ) ), 1 );
+ idx2 = sub( add( i_mult( ( sub( sub( 3 * L_FRAME16k / 2, shr( i, 1 ) ), 1 ) ), decimate ), decay ), windecay48 );
+ idx3 = add( add( shr( L, 1 ), i ), 1 );
+ idx4 = sub( sub( sub( i_mult( ( add( 3 * L_FRAME16k / 2 + 1, shr( i, 1 ) ) ), decimate ), decay ), 1 ), windecay48 );
+ wtda_audio[i + 1] = L_sub_sat( Mpy_32_16_1( -allsig_r[idx1], win_right[idx2] ), Mpy_32_16_1( allsig_r[idx3], win_right[idx4] ) );
+ move32();
}
FOR( i = L / 2 - n; i < L / 2; i += 2 )
{
- wtda_audio[i] = shr( negate( allsig_r[L / 2 - i - 1] ), 1 );
- move16();
- wtda_audio[i + 1] = shr( negate( allsig_r[L / 2 - ( i + 1 ) - 1] ), 1 );
- move16();
+ wtda_audio[i] = L_negate( allsig_r[( ( ( L >> 1 ) - i ) - 1 )] );
+ move32();
+ wtda_audio[i + 1] = L_negate( allsig_r[( ( ( L >> 1 ) - ( i + 1 ) ) - 1 )] );
+ move32();
}
-
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 ) );
- 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 ) );
- move16();
+ wtda_audio[( i + ( L >> 1 ) )] = L_sub_sat( Mpy_32_16_1( allsig_l[i], win_left[( ( ( i >> 1 ) * decimate ) + decay )] ), new_audio[( ( n - i ) - 1 )] );
+ move32();
+ wtda_audio[( ( i + ( L >> 1 ) ) + 1 )] = L_sub_sat( Mpy_32_16_1( allsig_l[i + 1], win_int_left[i / 2] ), new_audio[( ( n - ( i + 1 ) ) - 1 )] );
+ move32();
}
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] ) );
- 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] ) );
+ idx1 = i;
move16();
+ idx2 = add( i_mult( shr( i, 1 ), decimate ), decay );
+ idx3 = sub( sub( L, i ), 1 );
+ idx4 = sub( sub( i_mult( sub( shr( L, 1 ), shr( i, 1 ) ), decimate ), 1 ), decay );
+ wtda_audio[( i + ( L >> 1 ) )] = L_sub_sat( Mpy_32_16_1( allsig_l[idx1], win_left[idx2] ), Mpy_32_16_1( allsig_l[idx3], win_left[idx4] ) );
+ move32();
+
+ idx1 = add( i, 1 );
+ idx2 = shr( i, 1 );
+ idx3 = sub( sub( L, add( i, 1 ) ), 1 );
+ idx4 = sub( sub( shr( L, 1 ), shr( i, 1 ) ), 1 );
+ wtda_audio[( ( i + ( L >> 1 ) ) + 1 )] = L_sub_sat( Mpy_32_16_1( allsig_l[idx1], win_int_left[idx2] ), Mpy_32_16_1( allsig_l[idx3], win_int_left[idx4] ) );
+ move32();
}
}
ELSE
{
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] ) );
- move16();
+ idx1 = sub( sub( shr( L, 1 ), i ), 1 );
+ idx2 = sub( add( sub( i_mult( i_mult( 3, shr( L, 1 ) ), decimate ), i_mult( add( i, 1 ), decimate ) ), decay ), windecay48 );
+ idx3 = add( shr( L, 1 ), i );
+ idx4 = sub( sub( add( sub( i_mult( i_mult( 3, shr( L, 1 ) ), decimate ), 1 ), i_mult( add( i, 1 ), decimate ) ), decay ), windecay48 );
+ wtda_audio[i] = L_sub_sat( Mpy_32_16_1( -allsig_r[idx1], win_right[idx2] ), Mpy_32_16_1( allsig_r[idx3], win_right[idx4] ) );
+ move32();
}
FOR( i = L / 2 - n; i < L / 2; i++ )
{
- wtda_audio[i] = shr( negate( allsig_r[L / 2 - i - 1] ), 1 );
- move16();
+ wtda_audio[i] = L_negate( allsig_r[( ( ( L >> 1 ) - i ) - 1 )] );
+ move32();
}
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 ) );
- move16();
+ wtda_audio[( i + ( L >> 1 ) )] = L_sub_sat( Mpy_32_16_1( allsig_l[i], win_left[( ( i * decimate ) + decay )] ), new_audio[( ( n - i ) - 1 )] );
+ move32();
}
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] ) );
+ idx1 = i;
move16();
+ idx2 = add( i_mult( i, decimate ), decay );
+ idx3 = sub( sub( L, i ), 1 );
+ idx4 = sub( sub( sub( i_mult( L, decimate ), i_mult( i, decimate ) ), 1 ), decay );
+ wtda_audio[( i + ( L >> 1 ) )] = L_sub_sat( Mpy_32_16_1( allsig_l[idx1], win_left[idx2] ), Mpy_32_16_1( allsig_l[idx3], win_left[idx4] ) );
+ move32();
}
}
IF( old_wtda != NULL )
{
- Copy( new_audio, old_wtda, L );
+ Copy32( new_audio, old_wtda, L );
}
return;
}
-
void wtda_ext_fx(
const Word16 *new_audio, /* i : input audio (Q_in) */
Word16 *wtda_audio, /* o : windowed audio (Q_in - 1) */
diff --git a/lib_debug/debug.c b/lib_debug/debug.c
index aafc1b66332ef261ec444a0c2ca4cd269cb1a325..ee6040fafc840e9ff52aac4e3418b02a6c8935cb 100644
--- a/lib_debug/debug.c
+++ b/lib_debug/debug.c
@@ -788,7 +788,7 @@ char *fname(
#ifdef DEBUG_FORCE_DIR
size_t len;
len = strlen( tmp_fname );
- if (tmp_fname[len - 1] != '/' && tmp_fname[len - 1] != '\\' )
+ if ( tmp_fname[len - 1] != '/' && tmp_fname[len - 1] != '\\' )
{
/* add trailing '/' slash */
strcat( tmp_fname, "/" );
diff --git a/lib_debug/wmc_auto.c b/lib_debug/wmc_auto.c
index d357c03dd7d09ed3721a2fd735b48c26978e6fec..9a4b371fc5fa8cd7bb9147da17355d409ae0819b 100644
--- a/lib_debug/wmc_auto.c
+++ b/lib_debug/wmc_auto.c
@@ -1018,7 +1018,7 @@ int push_stack( const char *filename, const char *fctname )
}
/* Check, if This is the New Worst-Case RAM (stack + heap) */
- current_stack_size = ( int32_t )( ( ( ptr_base_stack - ptr_current_stack ) * sizeof( int16_t ) ) );
+ current_stack_size = (int32_t) ( ( ( ptr_base_stack - ptr_current_stack ) * sizeof( int16_t ) ) );
if ( current_stack_size < 0 )
{
@@ -1226,7 +1226,7 @@ void *mem_alloc(
current_heap_size += ptr_record->block_size;
/* Check, if this is the new Worst-Case RAM (stack + heap) */
- current_stack_size = ( int32_t )( ( ( ptr_base_stack - ptr_current_stack ) * sizeof( int16_t ) ) );
+ current_stack_size = (int32_t) ( ( ( ptr_base_stack - ptr_current_stack ) * sizeof( int16_t ) ) );
if ( current_stack_size + current_heap_size > wc_ram_size )
{
wc_ram_size = current_stack_size + current_heap_size;
@@ -2416,7 +2416,7 @@ int EQ_64( long long int L64_var1, long long int L64_var2 )
#endif
return F_ret;
}
-int NE_64( long long int L64_var1, long long int L64_var2 )
+int NE_64( long long int L64_var1, long long int L64_var2 )
{
int F_ret = 0;
@@ -2503,7 +2503,7 @@ void Reset_BASOP_WMOPS_counter( unsigned int counterId )
/* reset the current BASOP operation counter */
ptr = (unsigned int *) &multiCounter[counterId];
- for ( i = 0; i < (int) (sizeof(BASIC_OP) / sizeof(unsigned int)); i++ )
+ for ( i = 0; i < (int) ( sizeof( BASIC_OP ) / sizeof( unsigned int ) ); i++ )
{
*ptr++ = 0;
}
diff --git a/lib_debug/wmc_auto.h b/lib_debug/wmc_auto.h
index 59bbc5bbf72f54a9ab64216be94d3c5f4ce57800..8c6396313f36143655da2a1e1e4d8613cec6cee8 100644
--- a/lib_debug/wmc_auto.h
+++ b/lib_debug/wmc_auto.h
@@ -34,7 +34,7 @@
#define ENH_64_BIT_OPERATOR
#define ENH_U_32_BIT_OPERATOR
#define COMPLEX_OPERATOR
-#define CONTROL_CODE_OPS /* enable control code operators such as LT_16, GT_16, ... */
+#define CONTROL_CODE_OPS /* enable control code operators such as LT_16, GT_16, ... */
#define WMOPS_DISABLE_FCN_CALL_PENALIZATION /* do not count the complexity of function calls */
#ifdef WMOPS
@@ -258,7 +258,7 @@ void update_mem( void );
{ \
ops_cnt += ( 2 * _TRANS_C * ( x ) ); \
inst_cnt[_TRANS] += ( x ); \
- }
+ }
#else
@@ -335,29 +335,29 @@ extern int cntr_push_pop;
#endif
/* Define all Macros without '{' & '}' (None of these should be called externally!) */
-#define ABS_( x ) OP_COUNT_( _ABS, ( x ) )
-#define ADD_( x ) OP_COUNT_( _ADD, ( x ) )
-#define MULT_( x ) OP_COUNT_( _MULT, ( x ) )
-#define MAC_( x ) OP_COUNT_( _MAC, ( x ) )
-#define MOVE_( x ) OP_COUNT_( _MOVE, ( x ) )
-#define STORE_( x ) OP_COUNT_( _STORE, ( x ) )
-#define LOGIC_( x ) OP_COUNT_( _LOGIC, ( x ) )
-#define SHIFT_( x ) OP_COUNT_( _SHIFT, ( x ) )
-#define BRANCH_( x ) OP_COUNT_( _BRANCH, ( x ) )
-#define DIV_( x ) OP_COUNT_( _DIV, ( x ) )
-#define SQRT_( x ) OP_COUNT_( _SQRT, ( x ) )
-#define TRANS_( x ) OP_COUNT_( _TRANS, ( x ) )
+#define ABS_( x ) OP_COUNT_( _ABS, ( x ) )
+#define ADD_( x ) OP_COUNT_( _ADD, ( x ) )
+#define MULT_( x ) OP_COUNT_( _MULT, ( x ) )
+#define MAC_( x ) OP_COUNT_( _MAC, ( x ) )
+#define MOVE_( x ) OP_COUNT_( _MOVE, ( x ) )
+#define STORE_( x ) OP_COUNT_( _STORE, ( x ) )
+#define LOGIC_( x ) OP_COUNT_( _LOGIC, ( x ) )
+#define SHIFT_( x ) OP_COUNT_( _SHIFT, ( x ) )
+#define BRANCH_( x ) OP_COUNT_( _BRANCH, ( x ) )
+#define DIV_( x ) OP_COUNT_( _DIV, ( x ) )
+#define SQRT_( x ) OP_COUNT_( _SQRT, ( x ) )
+#define TRANS_( x ) OP_COUNT_( _TRANS, ( x ) )
#define POWER_( x ) TRANS_( x )
#define LOG_( x ) TRANS_( x )
-#define LOOP_( x ) OP_COUNT_( _LOOP, ( x ) )
-#define INDIRECT_( x ) OP_COUNT_( _INDIRECT, ( x ) )
-#define PTR_INIT_( x ) OP_COUNT_( _PTR_INIT, ( x ) )
+#define LOOP_( x ) OP_COUNT_( _LOOP, ( x ) )
+#define INDIRECT_( x ) OP_COUNT_( _INDIRECT, ( x ) )
+#define PTR_INIT_( x ) OP_COUNT_( _PTR_INIT, ( x ) )
#ifdef WMOPS_DISABLE_FCN_CALL_PENALIZATION
-#define FUNC_( x ) ( x )
+#define FUNC_( x ) ( x )
#else
-#define FUNC_( x ) ( OP_COUNT_( _MOVE, ( x ) ), OP_COUNT_( _FUNC, 1 ) )
+#define FUNC_( x ) ( OP_COUNT_( _MOVE, ( x ) ), OP_COUNT_( _FUNC, 1 ) )
#endif
-#define MISC_( x ) ABS_( x )
+#define MISC_( x ) ABS_( x )
/* Math Operations */
#define abs_ OP_COUNT_WRAPPER1_( ABS_( 1 ), abs )
@@ -401,8 +401,8 @@ extern int cntr_push_pop;
#define frexp_ OP_COUNT_WRAPPER1_( MISC_( 2 ), frexp )
#define frexpf_ OP_COUNT_WRAPPER1_( MISC_( 2 ), frexpf )
-/* the macros below are instrumented versions of user-defined macros that might be used in the source code
- representing some well-known and recognized mathematical operations (that are not defined in math.h)
+/* the macros below are instrumented versions of user-defined macros that might be used in the source code
+ representing some well-known and recognized mathematical operations (that are not defined in math.h)
Note: the 'wmc_flag_=wmc_flag_' is used to avoid warning: left-hand operand of comma expression has no effect with gcc */
#define min_( a, b ) OP_COUNT_WRAPPER1_( MISC_( 1 ), min( ( a ), ( b ) ) )
@@ -928,7 +928,7 @@ typedef struct
unsigned int Madd_32_32_r; /* Complexity Weight of 1 */
unsigned int Msub_32_32; /* Complexity Weight of 1 */
unsigned int Msub_32_32_r; /* Complexity Weight of 1 */
-#endif /* #ifdef ENH_32_BIT_OPERATOR */
+#endif /* #ifdef ENH_32_BIT_OPERATOR */
#ifdef ENH_U_32_BIT_OPERATOR
unsigned int UL_addNs; /* Complexity Weight of 1 */
@@ -938,7 +938,7 @@ typedef struct
unsigned int Mpy_32_16_uu; /* Complexity Weight of 2 */
unsigned int norm_ul_float; /* Complexity Weight of 1 */
unsigned int UL_deposit_l; /* Complexity Weight of 1 */
-#endif /* #ifdef ENH_U_32_BIT_OPERATOR */
+#endif /* #ifdef ENH_U_32_BIT_OPERATOR */
#ifdef CONTROL_CODE_OPS
unsigned int LT_16; /* Complexity Weight of 1 */
@@ -1095,7 +1095,9 @@ void incrIf( const char *func_name );
#ifndef WMOPS
#define ELSE else
#else /* ifndef WMOPS */
-#define ELSE else if ( incrElse( __func__ ), 0 ); else
+#define ELSE \
+ else if ( incrElse( __func__ ), 0 ); \
+ else
void incrElse( const char *func_name );
#endif /* ifndef WMOPS */
diff --git a/lib_dec/ACcontextMapping_dec_fx.c b/lib_dec/ACcontextMapping_dec_fx.c
index 22e9fff0114f1f5c0d3b5057744a446f95a0a0bb..acf372565408b238d2a86c40b85a396f5660b5ae 100644
--- a/lib_dec/ACcontextMapping_dec_fx.c
+++ b/lib_dec/ACcontextMapping_dec_fx.c
@@ -328,9 +328,6 @@ Word16 ACcontextMapping_decode2_no_mem_s17_LC(
return resQBits;
}
-#define IVAS_CONTEXT_MAPPING
-#ifdef IVAS_CONTEXT_MAPPING
-
/*-------------------------------------------------------------------*
* RCcontextMapping_decode2_no_mem_s17_LCS()
*
@@ -737,6 +734,3 @@ Word16 RCcontextMapping_decode2_no_mem_s17_LCS_fx(
return resQBits;
}
-
-#endif
-#undef IVAS_CONTEXT_MAPPING
diff --git a/lib_dec/FEC_HQ_phase_ecu_fx.c b/lib_dec/FEC_HQ_phase_ecu_fx.c
index ef09c3de3272be34c95156d3f9d7d17033284ec2..ad2f8607311a94fdc8a81ec9955dd2e16e97bb04 100644
--- a/lib_dec/FEC_HQ_phase_ecu_fx.c
+++ b/lib_dec/FEC_HQ_phase_ecu_fx.c
@@ -64,26 +64,11 @@ static void windowing( const Word16 *, Word16 *, const Word16 *, const Word16, c
static void windowing_ROM_optimized( const Word16 *, Word16 *, const Word16, const Word16, const Word16 );
static void fft_spec2_fx( const Word16[], Word32[], const Word16 );
static void trans_ana_fx( const Word16 *, Word16 *, Word16 *, Word16 *, const Word16, const Word16, const Word16, const Word16, Word16 *, Word16 *, Word16 *, Word16 * );
-static void peakfinder_fx( const Word16 *, const Word16, Word16 *, Word16 *, const Word16
-#ifdef IVAS_FEC_ECU_TO_COMPLETE
- ,
- const Word16 endpoints /* i : Flag to include endpoints in peak search */
-#endif
-);
+static void peakfinder_fx( const Word16 *, const Word16, Word16 *, Word16 *, const Word16 );
static Word16 imax_fx( const Word16 *, const Word16 );
-static void spec_ana_fx( const Word16 *prevsynth, Word16 *plocs, Word32 *plocsi, Word16 *num_plocs, Word16 *X_sav, const Word16 output_frame, const Word16 bwidth_fx, Word16 *Q
-#ifdef IVAS_FEC_ECU_TO_COMPLETE
- ,
- const Word16 element_mode,
- Word16 *noise_fac,
- const Word16 pcorr
-#endif
-);
+static void spec_ana_fx( const Word16 *prevsynth, Word16 *plocs, Word32 *plocsi, Word16 *num_plocs, Word16 *X_sav, const Word16 output_frame, const Word16 bwidth_fx, Word16 *Q );
static void subst_spec_fx( const Word16 *, const Word32 *, Word16 *, const Word16, Word16 *, const Word16 *, const Word16, const Word16 *, const Word16, Word16 *, const Word16 *, const Word16 *, Word16, const Word16 * );
static Word16 rand_phase_fx( const Word16 seed, Word16 *sin_F, Word16 *cos_F );
-#ifdef IVAS_FEC_ECU_TO_COMPLETE
-static float imax2_jacobsen_mag( const float *y_re, const float *y_im );
-#endif
/*------------------------------------------------------------------*
* rand_phase()
@@ -666,9 +651,6 @@ static void ivas_peakfinder_fx(
move16();
}
len0Minus2 = sub( len0, 2 );
-#ifdef IVAS_FEC_ECU_TO_COMPLETE
- PMT( "\nlen0Minus2 = sub(len0, 2) is it still correct if IVAS_FEC_ECU_TO_COMPLETE is activated\n" )
-#endif
FOR( i = 0; i < len0Minus2; i++ )
{
@@ -912,10 +894,6 @@ static void peakfinder_fx(
Word16 *plocs, /* o : the indices of the identified peaks in x0 Q0 */
Word16 *cInd, /* o : number of identified peaks Q0 */
const Word16 sel /* i : The amount above surrounding data for a peak to be identified */
-#ifdef IVAS_FEC_ECU_TO_COMPLETE
- ,
- const Word16 endpoints /* i : Flag to include endpoints in peak search */
-#endif
)
{
const Word16 *pX0;
@@ -951,11 +929,6 @@ static void peakfinder_fx(
pInd = indarr;
pDx01 = dx0;
pDx0 = pDx01 + 1;
-#ifdef IVAS_FEC_ECU_TO_COMPLETE
- len = 0;
- move16();
- IF( endpoints )
-#endif
{
*pX++ = *pX0++;
move16();
@@ -965,9 +938,6 @@ static void peakfinder_fx(
move16();
}
len0Minus2 = sub( len0, 2 );
-#ifdef IVAS_FEC_ECU_TO_COMPLETE
- PMT( "\nlen0Minus2 = sub(len0, 2) is it still correct if IVAS_FEC_ECU_TO_COMPLETE is activated\n" )
-#endif
FOR( i = 0; i < len0Minus2; i++ )
{
@@ -981,9 +951,6 @@ static void peakfinder_fx(
}
pX0++;
}
-#ifdef IVAS_FEC_ECU_TO_COMPLETE
- IF( endpoints )
-#endif
{
*pInd = len0Minus1;
move16();
@@ -994,13 +961,7 @@ static void peakfinder_fx(
minimum_fx( x, len, &minMag );
pInd = indarr;
-#ifdef IVAS_FEC_ECU_TO_COMPLETE
- test();
- test();
- IF( GT_16( len, 2 ) || ( !endpoints && ( len > 0 ) ) )
-#else
IF( GT_16( len, 2 ) )
-#endif
{
/* Set initial parameters for loop */
tempMag = minMag;
@@ -1011,9 +972,6 @@ static void peakfinder_fx(
move16();
threshold = add( leftMin, sel );
-#ifdef IVAS_FEC_ECU_TO_COMPLETE
- IF( len > 0 )
-#endif
{
/* Deal with first point a little differently since tacked it on
Calculate the sign of the derivative since we took the first point
@@ -1060,20 +1018,6 @@ static void peakfinder_fx(
}
pX--; /* After decrement, pX points to either x[-1] or x[0]. */
}
-#ifdef IVAS_FEC_ECU_TO_COMPLETE
- ELSE
- {
- PMTE()
- ii = -1; /* First point is a peak */
- if ( len >= 2 )
- {
- if ( x[1] >= x[0] )
- {
- ii = 0; /* First point is a valley, skip it */
- }
- }
- }
-#endif
*cInd = 0;
move16();
/*Loop through extrema which should be peaks and then valleys*/
@@ -1179,9 +1123,6 @@ static void peakfinder_fx(
}
ELSE /* This is a monotone function where an endpoint is the only peak */
{
-#ifdef IVAS_FEC_ECU_TO_COMPLETE
- IF( endpoints )
-#endif
{
xInd = 1;
move16();
@@ -1206,13 +1147,6 @@ static void peakfinder_fx(
move16();
}
}
-#ifdef IVAS_FEC_ECU_TO_COMPLETE
- ELSE
- { /* Input constant or all zeros -- no peaks found */
- *cInd = 0;
- move16();
- }
-#endif
}
}
@@ -1709,12 +1643,6 @@ static void spec_ana_fx(
const Word16 output_frame, /* i : Frame length Q0 */
const Word16 bwidth_fx, /* i : Encoded bandwidth index Q0 */
Word16 *Q /* o : Q value of the fft spectrum */
-#ifdef IVAS_FEC_ECU_TO_COMPLETE
- ,
- const Word16 element_mode, /* i : IVAS element mode */
- Word16 *noise_fac, /* o : for few peaks zeroing valleys decision making */
- const Word16 pcorr
-#endif
)
{
Word16 Lprot, LprotLog2Minus1, hamm_len2, Lprot2, Lprot2_1, m, n;
@@ -1782,52 +1710,18 @@ static void spec_ana_fx(
IF( EQ_16( output_frame, L_FRAME48k ) )
{
/* Apply hamming-rect window */
-#ifdef IVAS_FEC_ECU_TO_COMPLETE
- IF( EQ_16( element_mode, EVS_MONO ) )
-#endif
{
windowing( xfp, xfp, w_hamm_sana48k_2_fx, rectLength, hamm_len2 );
}
-#ifdef IVAS_FEC_ECU_TO_COMPLETE
- ELSE
- {
- PMTE()
- // window_corr = w_hamm[0];
- // window_corr_step = w_hamm[0] / hamm_len2;
- // for (i = 0; i < hamm_len2; i++)
- //{
- // xfp[i] = prevsynth[i] * (w_hamm[i] - window_corr);
- // xfp[Lprot - i - 1] = prevsynth[Lprot - i - 1] * (w_hamm[i] - window_corr);
- // window_corr -= window_corr_step;
- // }
- }
-#endif
/* Spectrum */
fft3_fx( xfp, xfp, Lprot );
}
ELSE
{
-#ifdef IVAS_FEC_ECU_TO_COMPLETE
- IF( EQ_16( element_mode, EVS_MONO ) )
-#endif
{
/* Apply hamming-rect window */
windowing_ROM_optimized( xfp, xfp, sinTblOffset, rectLength, hamm_len2 );
}
-#ifdef IVAS_FEC_ECU_TO_COMPLETE
- ELSE
- {
- PMTE()
- // window_corr = w_hamm[0];
- // window_corr_step = w_hamm[0] / hamm_len2;
- // for (i = 0; i < hamm_len2; i++)
- //{
- // xfp[i] = prevsynth[i] * (w_hamm[i] - window_corr);
- // xfp[Lprot - i - 1] = prevsynth[Lprot - i - 1] * (w_hamm[i] - window_corr);
- // window_corr -= window_corr_step;
- // }
- }
-#endif
/* Spectrum */
r_fft_fx_lc( pFftTbl, Lprot, Lprot2, LprotLog2Minus1, xfp, xfp, 1 );
}
@@ -1880,35 +1774,12 @@ static void spec_ana_fx(
/* Find maximum and minimum. */
maximum_fx( xfp, Lprot2_1, &Xmax );
minimum_fx( xfp, Lprot2_1, &Xmin );
-#ifdef IVAS_FEC_ECU_TO_COMPLETE
- IF( EQ_16( element_mode, EVS_MONO ) )
-#endif
{
sel = mult_r( sub( Xmax, Xmin ), CMPLMNT_PFIND_SENS_FX );
}
-#ifdef IVAS_FEC_ECU_TO_COMPLETE
- ELSE
- {
- sel = ( Xmax - Xmin ) * ( 1.0f - ST_PFIND_SENS );
- }
-#endif
- peakfinder_fx( xfp, Lprot2_1, plocs, num_plocs, sel
-#ifdef IVAS_FEC_ECU_TO_COMPLETE
- ,
- endpoints
-#endif
- );
-
+ peakfinder_fx( xfp, Lprot2_1, plocs, num_plocs, sel );
-#ifdef IVAS_FEC_ECU_TO_COMPLETE
- /* Currently not the pitch correlation but some LF correlation */
- if ( element_mode != EVS_MONO && *num_plocs > 50 && pcorr < 0.6f )
- {
- *num_plocs = 0;
- }
- IF( EQ_16( element_mode, EVS_MONO ) )
-#endif
{
/* Refine peaks */
@@ -1955,105 +1826,6 @@ static void spec_ana_fx(
move32(); /* in Q16. Append the fractional part to the integral part. */
}
}
-#ifdef IVAS_FEC_ECU_TO_COMPLETE
- ELSE
- {
- Lprot2p1 = Lprot / 2 + 1;
-
- /* Refine peaks */
- pPlocsi = plocsi;
- pPlocs = plocs;
- n = *num_plocs; /* number of peaks to process */
-
- /* Special case-- The very 1st peak if it is at 0 index position (DC) */
- /* With DELTA_CORR_F0_INT == 2 one needs to handle both *pPlocs==0 and *pPlocs==1 */
- if ( n > 0 && *pPlocs == 0 ) /* Very 1st peak position possible to have a peak at 0/DC index position. */
- {
- *pPlocsi++ = *pPlocs + imax_pos( &xfp[*pPlocs] );
- pPlocs++;
- n = n - 1;
- }
-
- if ( n > 0 && *pPlocs == 1 ) /* Also 2nd peak position uses DC which makes jacobsen unsuitable. */
- {
- *pPlocsi++ = *pPlocs - 1 + imax_pos( &xfp[*pPlocs - 1] );
- currPlocs = *pPlocs++;
- n = n - 1;
- }
-
- /* All remaining peaks except the very last two possible integer positions */
- currPlocs = *pPlocs++;
- endPlocs = Lprot2p1 - DELTA_CORR_F0_INT; /* last *pPlocs position for Jacobsen */
-
- /* precompute number of turns based on endpoint integer location and make into a proper for loop */
- if ( n > 0 )
- {
- nJacob = n;
- if ( sub( endPlocs, plocs[sub( *num_plocs, 1 )] ) <= 0 )
- {
- nJacob = sub( nJacob, 1 );
- }
-
- for ( k = 0; k < nJacob; k++ )
- {
- *pPlocsi++ = currPlocs + imax2_jacobsen_mag( &( X_sav[currPlocs - 1] ), &( X_sav[Lprot - 1 - currPlocs] ) );
- currPlocs = *pPlocs++;
- }
- n = n - nJacob;
- }
-
- /* At this point there should at most two plocs left to process */
- /* the position before fs/2 and fs/2 both use the same magnitude points */
- if ( n > 0 )
- {
- /* [ . . . . . . . ] Lprot/2+1 positions */
- /* | | | */
- /* 0 (Lprot/2-2) (Lprot/2) */
-
- if ( currPlocs == ( Lprot2p1 - DELTA_CORR_F0_INT ) ) /* Also 2nd last peak position uses fs/2 which makes jacobsen less suitable. */
- {
- *pPlocsi++ = currPlocs - 1 + imax_pos( &xfp[currPlocs - 1] );
- currPlocs = *pPlocs++;
- n = n - 1;
- }
-
- /* Here the only remaining point would be a fs/2 plocs */
- /* pXfp = xfp + sub(Lprot2,1); already set just a reminder where it
- * whould point */
- if ( n > 0 ) /* fs/2 which makes special case . */
- {
- *pPlocsi++ = currPlocs - 2 + imax_pos( &xfp[currPlocs - 2] );
- currPlocs = *pPlocs++;
- n = n - 1;
- }
- }
-
- /* For few peaks decide noise floor attenuation */
- if ( *num_plocs < 3 && *num_plocs > 0 )
- {
- sig = sum_f( xfp, Lprot2_1 ) + EPSILON;
-
- /*excluding peaks and neighboring bins*/
- for ( i = 0; i < *num_plocs; i++ )
- {
- st_point = max( 0, plocs[i] - DELTA_CORR );
- end_point = min( Lprot2_1 - 1, plocs[i] + DELTA_CORR );
- set_f( &xfp[st_point], 0.0f, end_point - st_point + 1 );
- }
- noise = sum_f( xfp, Lprot2_1 ) + EPSILON;
- nsr = noise / sig;
-
- if ( nsr < 0.03f )
- {
- *noise_fac = 0.5f;
- }
- else
- {
- *noise_fac = 1.0f;
- }
- }
- }
-#endif
}
/*-------------------------------------------------------------------*
@@ -2474,12 +2246,6 @@ static void subst_spec_fx(
const Word16 *beta, /* i : Magnitude modification factors for fade to average Q15 */
Word16 beta_mute, /* i : Factor for long-term mute Q15 */
const Word16 *Xavg /* i : Frequency group averages to fade to Q0 */
-#ifdef IVAS_FEC_ECU_TO_COMPLETE
- ,
- const Word16 element_mode, /* i : IVAS element mode */
- const Word16 ph_ecu_lookahead, /* i : Phase ECU lookahead */
- const Word16 noise_fac /* i : noise factor */
-#endif
)
{
Word16 Xph_short;
@@ -2500,11 +2266,6 @@ static void subst_spec_fx(
Word16 alpha_local;
Word16 beta_local;
Word16 expo;
-#ifdef IVAS_FEC_ECU_TO_COMPLETE
- Word16 one_peak_flag_mask;
- Word16 alpha_local;
- Word16 beta_local;
-#endif
Word16 mag_chg_local; /*for peak attenuation in burst */
Lprot = 512;
@@ -2560,21 +2321,6 @@ static void subst_spec_fx(
move32();
}
}
-#ifdef IVAS_FEC_ECU_TO_COMPLETE
- one_peak_flag_mask = 1; /* all ones mask -> keep */
- IF( NE_16( element_mode, EVS_MONO ) )
- {
- if ( ( *num_plocs > 0 ) && sub( *num_plocs, 3 ) < 0 )
- {
- one_peak_flag_mask = noise_fac; /* all zeroes mask -> zero */
- }
- if ( *num_plocs == 0 )
- {
- X[0] = 0; /* reset DC if there are no peaks */
- X[shr( Lprot, 1 )] = 0; /* also reset fs/2 if there are no peaks */
- }
- }
-#endif
lprotBy2Minus1 = sub( shr( Lprot, 1 ), 1 );
i = 1;
move16();
@@ -2635,21 +2381,10 @@ static void subst_spec_fx(
move16();
im = *pImX;
move16();
-#ifdef IVAS_FEC_ECU_TO_COMPLETE
- IF( EQ_16( element_mode, EVS_MONO ) )
-#endif
{
tmp = sub( mult_r( re, cos_F ), mult_r( im, sin_F ) );
im = add( mult_r( re, sin_F ), mult_r( im, cos_F ) );
}
-#ifdef IVAS_FEC_ECU_TO_COMPLETE
- ELSE
- {
- PMTE()
- // tmp = one_peak_flag_mask * (X[i] * cos_F - X[im_ind] * sin_F);
- // X[im_ind] = one_peak_flag_mask * (X[i] * sin_F + X[im_ind] * cos_F);
- }
-#endif
IF( LT_16( alpha[k], 32766 ) )
{
*seed = rand_phase_fx( *seed, &sin_F, &cos_F );
@@ -2766,21 +2501,10 @@ static void subst_spec_fx(
move16();
im = *pImX;
move16();
-#ifdef IVAS_FEC_ECU_TO_COMPLETE
- IF( EQ_16( element_mode, EVS_MONO ) )
-#endif
{
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 ) );
}
-#ifdef IVAS_FEC_ECU_TO_COMPLETE
- ELSE
- {
- PMTE()
- // tmp = one_peak_flag_mask * (X[i] * cos_F - X[im_ind] * sin_F);
- // X[im_ind] = one_peak_flag_mask * (X[i] * sin_F + X[im_ind] * cos_F);
- }
-#endif
IF( LT_16( alpha[k], 32766 ) )
{
alpha_local = mag_chg_local;
@@ -3032,97 +2756,7 @@ static void rec_wtda_fx(
Word16 *p_ecu;
Word16 g;
Word16 tbl_delta;
-#ifdef IVAS_FEC_ECU_TO_COMPLETE
- float xsubst_[2 * L_FRAME48k];
- const float *w_hamm;
- float *pX_start, *pX_end;
- float tmp;
- int16_t hamm_len2;
- float *pNew;
- const float *pOldW, *pNewW;
- float xfwin[NS2SA( L_FRAME48k * FRAMES_PER_SEC, N_ZERO_MDCT_NS - ( 2 * FRAME_SIZE_NS - L_PROT_NS ) / 2 )];
- const float *pOld;
- int16_t copy_len;
- int16_t ola_len;
-
- copy_len = NS2SA( output_frame * FRAMES_PER_SEC, ( 2 * FRAME_SIZE_NS - L_PROT_NS ) / 2 ); /* prototype fill on each side of xsubst to fill MDCT Frame */
- ola_len = NS2SA( output_frame * FRAMES_PER_SEC, N_ZERO_MDCT_NS - ( 2 * FRAME_SIZE_NS - L_PROT_NS ) / 2 ); /* remaining lengt of LA_ZEROS to overlap add decoded with xsubst */
-
- if ( output_frame == L_FRAME48k )
- {
- w_hamm = w_hamm_sana48k_2;
- hamm_len2 = L_PROT_HAMM_LEN2_48k;
- }
- else if ( output_frame == L_FRAME32k )
- {
- w_hamm = w_hamm_sana32k_2;
- hamm_len2 = L_PROT_HAMM_LEN2_32k;
- }
- else
- {
- w_hamm = w_hamm_sana16k_2;
- hamm_len2 = L_PROT_HAMM_LEN2_16k;
- }
-
- if ( element_mode != EVS_MONO && *num_p > 0 && plocs[0] > 3 )
- {
- /* Perform inverse windowing of hammrect */
- pX_start = X;
- pX_end = X + Lprot - 1;
- for ( i = 0; i < hamm_len2; i++ )
- {
- tmp = 1.0f / *w_hamm;
- *pX_start *= tmp;
- *pX_end *= tmp;
- pX_start++;
- pX_end--;
- w_hamm++;
- }
- }
-
- /* extract reconstructed frame with aldo window */
- timesh = NS2SA( output_frame * FRAMES_PER_SEC, N_ZERO_MDCT_NS ) - ( 2 * output_frame - Lprot ) / 2;
-
- set_f( xsubst_, 0.0f, 2 * output_frame - Lprot + timesh );
- mvr2r( X, xsubst_ + 2 * output_frame - Lprot + timesh, Lprot - timesh );
-
- /* Copy and OLA look ahead zero part of MDCT window from decoded signal */
- if ( element_mode != EVS_MONO )
- {
- mvr2r( old_dec, xsubst_ + NS2SA( output_frame * FRAMES_PER_SEC, N_ZERO_MDCT_NS ), copy_len ); /* also need to scale to Q0 ?? */
- pOld = old_dec + copy_len;
- pNew = xsubst_ + copy_len + NS2SA( output_frame * FRAMES_PER_SEC, N_ZERO_MDCT_NS );
- sinq( EVS_PI / ( ola_len * 2 ), 0.0f, ola_len, xfwin );
- v_mult( xfwin, xfwin, xfwin, ola_len ); /* xfwin = sin^2 of 0..pi/4 */
- pOldW = xfwin + ola_len - 1;
- pNewW = xfwin;
- for ( i = 0; i < ola_len; i++ )
- {
- *pNew = *pOld * *pOldW + *pNew * *pNewW;
- pOld += 1;
- pNew += 1;
- pOldW -= 1;
- pNewW += 1;
- }
- }
- else
- {
- /* Smoothen onset of ECU frame */
- xf_len = (int16_t) ( (float) output_frame * N_ZERO_MDCT_NS / FRAME_SIZE_NS ) - ( output_frame - Lprot / 2 );
- p_ecu = xsubst_ + 2 * output_frame - Lprot + timesh;
- tbl_delta = 64.f / xf_len; /* 64 samples = 1/4 cycle in sincos_t */
- for ( i = 0; i < xf_len; i++, p_ecu++ )
- {
- g = sincos_t[( (int16_t) ( i * tbl_delta ) )];
- g *= g;
- *p_ecu = g * ( *p_ecu );
- }
- }
-
- /* Apply TDA and windowing to ECU frame */
- wtda( xsubst_ + output_frame, ecu_rec, NULL, ALDO_WINDOW, ALDO_WINDOW, output_frame );
-#else
// PMTE()
xsubst_ = rec_buf + output_frame;
Lprot2 = shr( Lprot, 1 );
@@ -3175,7 +2809,6 @@ static void rec_wtda_fx(
out_ptr = rec_buf + sub( shl( output_frame, 1 ), timesh );
wtda_fx( out_ptr, &Qin, ecu_rec, NULL, 0, ALDO_WINDOW, ALDO_WINDOW, /* window overlap of current frame (0: full, 2: none, or 3: half) */
output_frame );
-#endif
return;
}
@@ -3239,15 +2872,7 @@ static void rec_frame_fx(
Word16 *X, /* i : FFT spectrum */
Word32 *ecu_rec, /* o : Reconstructed frame in tda domain */
const Word16 output_frame, /* i : Frame length */
- const Word16 Q
-#ifdef IVAS_FEC_ECU_TO_COMPLETE
- ,
- const float *old_dec, /* i : end of last decoded for OLA before tda and itda */
- const int16_t element_mode, /* i : IVAS element mode */
- const int16_t *num_p, /* i : Number of peaks */
- const int16_t *plocs /* i : Peak locations */
-#endif
-)
+ const Word16 Q )
{
const Word16 *pFftTbl;
Word16 Lprot, lprotLog2Minus1;
@@ -4034,28 +3659,11 @@ static void fec_ecu_dft_fx(
Word16 *Tf_abs, /*Qout */
Word16 *Nfft,
Word16 *exp /*Qout = Qin+exp */
-#ifdef IVAS_FEC_ECU_TO_COMPLETE
- ,
- const int16_t element_mode /* i : IVAS element mode */
-#endif
)
{
Word32 L_tmp, Tmp, Tfr32[512], Tfi32[512], fac, *Pt1, *Pt2;
Word16 i, tmp, tmp_short, N_LP, target[2 * L_FRAME48k], Tfr16[FEC_FFT_MAX_SIZE], *pt1, *pt2, *pt3;
Word16 tmp_loop;
-#ifdef IVAS_FEC_ECU_TO_COMPLETE
- int16_t alignment_point;
-
- Lon20 = (int16_t) 160 / 20;
- if ( element_mode == EVS_MONO )
- {
- alignment_point = 2 * 160 - 3 * Lon20;
- }
- else
- {
- alignment_point = 2 * 160;
- }
-#endif
tmp = sub( 296, N );
Copy( &prevsynth_LP[tmp], target, N );
@@ -4588,11 +4196,6 @@ static void fec_noise_filling_fx(
const Word16 N,
const Word16 HqVoicing,
Word16 *gapsynth_fx /*Qsynth */
-#ifdef IVAS_FEC_ECU_TO_COMPLETE
- ,
- const int16_t element_mode, /* i : IVAS element mode */
- const float *old_out
-#endif
)
{
@@ -4607,22 +4210,6 @@ static void fec_noise_filling_fx(
Word32 L_tmp;
const Word16 *sinq_tab;
-#ifdef IVAS_FEC_ECU_TO_COMPLETE
-
- const float *p_mdct_ola;
- int16_t alignment_point;
- PMTE()
- if ( element_mode == EVS_MONO )
- {
- alignment_point = 2 * L - 3 * L / 20;
- }
- else
- {
- alignment_point = 2 * L;
- }
- mvr2r( prevsynth + alignment_point - N, noisevect, N );
-#endif
-
IF( EQ_16( L, L_FRAME32k ) )
{
sinq_tab = sinq_32k;
@@ -4693,18 +4280,6 @@ static void fec_noise_filling_fx(
tmp_fx = div_s( 1, Rnd_N_noise ); /*Q15 */
tmp_fx = round_fx_sat( L_shl_sat( L_mult( tmp_fx, 25736 ), 2 ) ); /*Q15 */
-#ifdef IVAS_FEC_ECU_TO_COMPLETE
- if ( element_mode == EVS_MONO )
- {
- kk = 7 * L / 20;
- p_mdct_ola = prevsynth + 37 * L / 20;
- }
- else
- {
- kk = NS2SA( L * FRAMES_PER_SEC, N_ZERO_MDCT_NS );
- p_mdct_ola = old_out + kk;
- }
-#endif
sinq_fx( shr( tmp_fx, 1 ), shr( tmp_fx, 2 ), Rnd_N_noise, SS_fx );
@@ -4812,11 +4387,6 @@ static void fec_alg_fx(
const Word16 decimatefactor,
const Word16 HqVoicing,
Word16 *gapsynth /*Qin */
-#ifdef IVAS_FEC_ECU_TO_COMPLETE
- ,
- const Word16 element_mode, /* i : IVAS element mode */
- const Word16 *old_out
-#endif
)
{
Word16 Nfft;
@@ -4828,21 +4398,11 @@ static void fec_alg_fx(
Word16 exp;
Word16 n, Q;
- fec_ecu_dft_fx( prevsynth_LP, N, Tfr, Tfi, &sum_Tf_abs, Tf_abs, &Nfft, &exp
-#ifdef IVAS_FEC_ECU_TO_COMPLETE
- ,
- element_mode
-#endif
- );
+ fec_ecu_dft_fx( prevsynth_LP, N, Tfr, Tfi, &sum_Tf_abs, Tf_abs, &Nfft, &exp );
sinusoidal_synthesis_fx( Tfr, Tfi, Tf_abs, N, output_frame, decimatefactor, Nfft, sum_Tf_abs, synthesis, HqVoicing, exp );
- fec_noise_filling_fx( prevsynth, synthesis, ni_seed_forfec, output_frame, i_mult2( N, decimatefactor ), HqVoicing, gapsynth
-#ifdef IVAS_FEC_ECU_TO_COMPLETE
- ,
- element_mode, old_out
-#endif
- );
+ fec_noise_filling_fx( prevsynth, synthesis, ni_seed_forfec, output_frame, i_mult2( N, decimatefactor ), HqVoicing, gapsynth );
n = R1_48 - R2_48;
move16();
@@ -5018,11 +4578,6 @@ static void hq_phase_ecu_fx(
Word16 *beta_mute, /* o : Factor for long-term mute Q15 */
const Word16 bwidth_fx, /* i : Encoded bandwidth */
const Word16 output_frame /* i : frame length */
-#ifdef IVAS_FEC_ECU_TO_COMPLETE
- ,
- const Word16 pcorr,
- const Word16 element_mode /* i : IVAS element mode */
-#endif
)
{
Word16 lprot, offset;
@@ -5030,22 +4585,6 @@ static void hq_phase_ecu_fx(
Word16 seed;
Word16 alpha[LGW_MAX], beta[LGW_MAX];
-#ifdef IVAS_FEC_ECU_TO_COMPLETE
- const float *old_dec;
- float noise_fac;
- int16_t ph_ecu_lookahead;
-
- noise_fac = 1.0f;
-
- if ( element_mode == EVS_MONO )
- {
- ph_ecu_lookahead = NS2SA( output_frame * FRAMES_PER_SEC, PH_ECU_LOOKAHEAD_NS );
- }
- else
- {
- ph_ecu_lookahead = 0;
- }
-#endif
IF( EQ_16( output_frame, L_FRAME48k ) )
{
lprot = L_PROT48k; /* 1536 = (2*output_frame)*1024/1280 */
@@ -5074,30 +4613,17 @@ static void hq_phase_ecu_fx(
{
test();
// PMT("verify condition compared to float")
-#ifdef IVAS_FEC_ECU_TO_COMPLETE
- IF( !( prev_bfi != 0 && *last_fec != 0 ) && EQ_16( element_mode == EVS_MONO ) )
-#else
if ( !( prev_bfi != 0 && *last_fec != 0 ) )
-#endif
{
*time_offs = 0;
move16();
}
-#ifdef IVAS_FEC_ECU_TO_COMPLETE
- offset = add( sub( sub( shl( output_frame, 1 ), lprot ), *time_offs ), ph_ecu_lookahead );
-#else
offset = sub( sub( shl( output_frame, 1 ), lprot ), *time_offs );
-#endif
trans_ana_fx( prevsynth + offset, mag_chg, &ph_dith, mag_chg_1st, output_frame, *time_offs, env_stab,
*last_fec, alpha, beta, beta_mute, Xavg );
- spec_ana_fx( prevsynth + offset, plocs, plocsi, num_p, X_sav, output_frame, bwidth_fx, Q_spec
-#ifdef IVAS_FEC_ECU_TO_COMPLETE
- ,
- element_mode, noise_fac, pcorr
-#endif
- );
+ spec_ana_fx( prevsynth + offset, plocs, plocsi, num_p, X_sav, output_frame, bwidth_fx, Q_spec );
test();
IF( prev_bfi != 0 && *last_fec != 0 )
@@ -5127,23 +4653,10 @@ static void hq_phase_ecu_fx(
}
subst_spec_fx( plocs, plocsi, num_p, *time_offs, X, mag_chg, ph_dith, old_is_transient, output_frame, &seed,
- alpha, beta, *beta_mute, Xavg
-#ifdef IVAS_FEC_ECU_TO_COMPLETE
- ,
- element_mode, ph_ecu_lookahead, noise_fac
-#endif
- );
+ alpha, beta, *beta_mute, Xavg );
/* reconstructed frame in tda domain */
-#ifdef IVAS_FEC_ECU_TO_COMPLETE
- old_dec = prevsynth + 2 * output_frame - NS2SA( output_frame * FRAMES_PER_SEC, N_ZERO_MDCT_NS );
-#endif
- rec_frame_fx( X, ecu_rec, output_frame, *Q_spec
-#ifdef IVAS_FEC_ECU_TO_COMPLETE
- ,
- old_dec, element_mode, num_p, plocs
-#endif
- );
+ rec_frame_fx( X, ecu_rec, output_frame, *Q_spec );
*last_fec = 0;
move16();
@@ -5297,22 +4810,6 @@ void hq_ecu_fx(
Word16 decimatefactor;
Word16 corr; /*Q15 */
Word16 prevsynth_LP[2 * L_FRAME8k];
-#ifdef IVAS_FEC_ECU_TO_COMPLETE
- HQ_DEC_HANDLE hHQ_core;
- const float *fec_alg_input;
- int16_t evs_mode_selection;
- int16_t ivas_mode_selection;
-
- hHQ_core = st->hHQ_core;
- if ( st->element_mode == EVS_MONO )
- {
- fec_alg_input = prevsynth + NS2SA( output_frame * FRAMES_PER_SEC, ACELP_LOOK_NS / 2 - PH_ECU_LOOKAHEAD_NS );
- }
- else
- {
- fec_alg_input = prevsynth - NS2SA( output_frame * FRAMES_PER_SEC, PH_ECU_LOOKAHEAD_NS );
- }
-#endif
/* init (values ar changed after) */
decimatefactor = 4;
move16();
@@ -5323,11 +4820,7 @@ void hq_ecu_fx(
IF( !( LT_16( output_frame, L_FRAME16k ) ) )
{
-#ifdef IVAS_FEC_ECU_TO_COMPLETE
- fec_ecu_pitch_fx( fec_alg_input, prevsynth_LP, output_frame, &N, &corr, &decimatefactor, ph_ecu_HqVoicing );
-#else
fec_ecu_pitch_fx( prevsynth + NS2SA_FX2( L_mult0( output_frame, 50 ), ACELP_LOOK_NS / 2 - PH_ECU_LOOKAHEAD_NS ), prevsynth_LP, output_frame, &N, &corr, &decimatefactor, ph_ecu_HqVoicing );
-#endif
}
ELSE
{
@@ -5350,32 +4843,6 @@ void hq_ecu_fx(
test();
test();
test();
-#if defined IVAS_FEC_ECU_TO_COMPLETE
- evs_mode_selection = ( st->total_brate >= 48000 && ( output_frame >= L_FRAME16k && !prev_bfi && ( !old_is_transient[0] || old_is_transient[1] ) &&
- ( ph_ecu_HqVoicing || ( ( ( hHQ_core->env_stab_plc > 0.5 ) && ( corr < 0.6 ) ) || ( hHQ_core->env_stab_plc < 0.5 && ( corr > 0.85 ) ) ) ) ) ) ||
- ( st->total_brate < 48000 && ( ( ph_ecu_HqVoicing || corr > 0.85 ) && !prev_bfi && ( !old_is_transient[0] || old_is_transient[1] ) ) );
-
- ivas_mode_selection = ( N < PH_ECU_N_LIMIT ) || ( corr < PH_ECU_CORR_LIMIT );
- if ( ( ( st->element_mode == EVS_MONO ) && evs_mode_selection ) ||
- ( ( st->element_mode != EVS_MONO ) && evs_mode_selection && ivas_mode_selection ) )
-
- {
- fec_alg_fx( fec_alg_input, prevsynth_LP, ecu_rec, output_frame, N, decimatefactor, ph_ecu_HqVoicing, gapsynth, &hHQ_core->ni_seed_forfec, st->element_mode, st->hHQ_core->old_out );
- *last_fec = 1;
- *ph_ecu_active = 0;
- move16();
- *time_offs = output_frame;
- move16();
- ;
- }
- else
- {
- hq_phase_ecu( prevsynth - NS2SA( output_frame * FRAMES_PER_SEC, PH_ECU_LOOKAHEAD_NS ), ecu_rec, time_offs, X_sav, num_p, plocs, plocsi, env_stab, last_fec, prev_bfi, old_is_transient, mag_chg_1st, Xavg, beta_mute, st->bwidth, output_frame, corr, st->element_mode );
-
- *last_fec = 0;
- *ph_ecu_active = 1;
- }
-#else
IF( ( GE_32( st_fx->total_brate, 48000 ) &&
( GE_16( output_frame, L_FRAME16k ) && !prev_bfi && ( !old_is_transient[0] || old_is_transient[1] ) && ( NE_16( ph_ecu_HqVoicing, 0 ) || ( ( ( NE_16( st_fx->hHQ_core->env_stab_plc_fx, 0 ) ) && ( LT_16( corr, 19661 ) ) ) || ( !( NE_16( st_fx->hHQ_core->env_stab_plc_fx, 0 ) ) && ( GT_16( corr, 27853 ) ) ) ) ) ) ) ||
( LT_32( st_fx->total_brate, 48000 ) && ( ( ph_ecu_HqVoicing || GT_16( corr, 27853 ) ) && !prev_bfi && ( !old_is_transient[0] || old_is_transient[1] ) ) ) )
@@ -5395,7 +4862,6 @@ void hq_ecu_fx(
env_stab, last_fec, ph_ecu_active, prev_bfi, old_is_transient,
mag_chg_1st, Xavg, beta_mute, st_fx->bwidth, output_frame );
}
-#endif
return;
}
diff --git a/lib_dec/FEC_clas_estim_fx.c b/lib_dec/FEC_clas_estim_fx.c
index e56a77be12f49bf6522a1b129d91eaa0edbe4bb9..2bd38153a3c533568ec9b21792b3d21df478853b 100644
--- a/lib_dec/FEC_clas_estim_fx.c
+++ b/lib_dec/FEC_clas_estim_fx.c
@@ -285,7 +285,17 @@ void FEC_clas_estim_fx(
Corre( &pt1[pos], &pt1[pos - T0], T0, &cor_max[0] );
- T0 = mult_r_sat( add_sat( pitch[2], pitch[3] ), 256 );
+ IF( NE_16( st_fx->element_mode, EVS_MONO ) )
+ {
+ IF( LT_16( sub( pos, T0 ), sub( L_frame, L_SUBFR ) ) )
+ {
+ T0 = mult_r_sat( add_sat( pitch[2], pitch[3] ), 256 );
+ }
+ }
+ ELSE
+ {
+ T0 = mult_r_sat( add_sat( pitch[2], pitch[3] ), 256 );
+ }
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] );
@@ -725,8 +735,8 @@ void FEC_clas_estim_fx(
} /* Do the classification only
- - MODE1: when the class is not transmitted in the bitstream
- - MODE2: on good frames (classifier is also called for bfi=1) */
+ - MODE1: when the class is not transmitted in the bitstream
+ - MODE2: on good frames (classifier is also called for bfi=1) */
/* update the memory of synthesis for frame class estimation */
diff --git a/lib_dec/FEC_fx.c b/lib_dec/FEC_fx.c
index a23c9aa90bf6b582ad1425094a242689ec6f4058..48d91a87a1956594ba84a662e33c8cc73d52d89f 100644
--- a/lib_dec/FEC_fx.c
+++ b/lib_dec/FEC_fx.c
@@ -510,19 +510,10 @@ void FEC_exc_estim_fx(
move16();
/* st_fx->L_frame / L_SUBFR */
tmp = shr( st_fx->L_frame, 6 );
+
/* Replication of the last spectrum, with a slight downscaling of its dynamic */
-#ifdef REMOVE_EVS_DUPLICATES
- gsc_dec_ivas_fx( st_fx, exc_dct_in, hGSCDec->Last_GSC_pit_band_idx, Diff_len, 0, tmp, st_fx->last_coder_type, &last_bin_fx, lsf_new, NULL, &st_fx->Q_exc );
-#else
- IF( st_fx->element_mode == EVS_MONO )
- {
- gsc_dec_fx( st_fx, exc_dct_in, hGSCDec->Last_GSC_pit_band_idx, Diff_len, 0, tmp, st_fx->last_coder_type, &last_bin_fx, lsf_new, NULL, st_fx->Q_exc );
- }
- ELSE
- {
- gsc_dec_ivas_fx( st_fx, exc_dct_in, hGSCDec->Last_GSC_pit_band_idx, Diff_len, 0, tmp, st_fx->last_coder_type, &last_bin_fx, lsf_new, NULL, &st_fx->Q_exc );
- }
-#endif
+ gsc_dec_fx( st_fx, exc_dct_in, hGSCDec->Last_GSC_pit_band_idx, Diff_len, 0, tmp, st_fx->last_coder_type, &last_bin_fx, lsf_new, NULL, &st_fx->Q_exc );
+
*tmp_noise = shr_r( st_fx->lp_gainc_fx, 3 ); /*Q0*/
move16();
/* Transform back to time domain */
diff --git a/lib_dec/FEC_scale_syn_fx.c b/lib_dec/FEC_scale_syn_fx.c
index 714a60166865e38fd8efe3676fef761aa8b67345..7f4586083e938d9eecb623b325a54dcecad9e71a 100644
--- a/lib_dec/FEC_scale_syn_fx.c
+++ b/lib_dec/FEC_scale_syn_fx.c
@@ -50,7 +50,6 @@
/* _ None */
/*========================================================================*/
-#ifndef REMOVE_EVS_DUPLICATES
void FEC_scale_syn_fx(
const Word16 L_frame, /* i : length of the frame */
Word16 *update_flg, /* o: flag indicating re-synthesis after scaling*/
@@ -77,574 +76,7 @@ void FEC_scale_syn_fx(
Word16 *mem_syn, /* o: initial synthesis filter states Q_syn*/
Word16 Q_exc,
Word16 Q_syn,
- const Word16 avoid_lpc_burst_on_recovery, /* i : if true the excitation energy is limited if LP has big gain */
- const Word16 force_scaling /* i: force scaling */
-)
-{
- Word16 i;
- Word32 L_enr1, L_enr2;
- Word16 gain1, gain2, enr_LP;
- Word16 tmp, tmp2, exp, exp2;
- Word16 tmp3;
- Word32 L_tmp;
- Word16 scaling;
- Word32 ener_max, L_enr2_av, L_ener2_max;
- Word16 h1[L_FRAME / 2], tilt, pitch_dist, mean_pitch;
- Word16 k;
- Word32 L_mean_pitch;
-
- enr_LP = 0;
- move16();
- gain2 = 0;
- move16();
- gain1 = 0;
- move16();
- *update_flg = 0;
- move16();
- L_enr_old = L_max( 1, L_enr_old ); /* to avoid division by zero (*L_enr_old is always >= 0) */
- scaling = 16384;
- move16(); /* Q14*/
-
- /*-----------------------------------------------------------------*
- * Find the synthesis filter impulse response on voiced
- *-----------------------------------------------------------------*/
- test();
- IF( GE_16( clas, VOICED_TRANSITION ) && LT_16( clas, INACTIVE_CLAS ) )
- {
- IF( EQ_16( L_frame, L_FRAME ) )
- {
- enr_LP = Enr_1_Az_fx( Aq + ( NB_SUBFR - 1 ) * ( M + 1 ), L_SUBFR );
- }
- ELSE /* L_frame == L_FRAME16k */
- {
- enr_LP = Enr_1_Az_fx( Aq + ( NB_SUBFR16k - 1 ) * ( M + 1 ), L_SUBFR ); /*Q3*/
- }
- }
-
- /*-----------------------------------------------------------------*
- * Define when to scale the synthesis
- *-----------------------------------------------------------------*/
-
- IF( bfi )
- {
- *scaling_flag = 1;
- move16(); /* Always check synthesis on bad frames */
- }
- ELSE IF( prev_bfi )
- {
- test();
- IF( ( EQ_16( LSF_Q_prediction, AUTO_REGRESSIVE ) ) || ( EQ_16( LSF_Q_prediction, MOVING_AVERAGE ) ) )
- {
- *scaling_flag = 2;
- move16(); /* Decoded LSFs affected */
- }
- ELSE IF( NE_16( coder_type, TRANSITION ) )
- {
- *scaling_flag = 1;
- move16(); /* SN, but not TC mode - LSF still affected by the interpolation */
- }
- ELSE
- {
- *scaling_flag = 0;
- move16(); /* LSF still possibly affected due to interpolation */
- }
- scaling = 24576; /*1.5 Q14*/
- move16();
- }
- ELSE
- {
- test();
- IF( ( EQ_16( LSF_Q_prediction, AUTO_REGRESSIVE ) ) && ( EQ_16( *scaling_flag, 2 ) ) )
- {
- *scaling_flag = 2;
- move16(); /* Continue with energy control till the end of AR prediction */
- }
- ELSE IF( *scaling_flag > 0 )
- {
- ( *scaling_flag ) = sub( *scaling_flag, 1 ); /* If scaling flag was equal to 2, add one control frame to account for the LSF interpolation */
- move16();
- }
- scaling = 32767; /*2.0 Q14*/
- move16();
- }
-
- /*-----------------------------------------------------------------*
- * Find the energy/gain at the end of the frame
- *-----------------------------------------------------------------*/
-
- frame_ener_fx( L_frame, clas, synth, pitch[( L_frame >> 6 ) - 1], &L_enr2 /*Q0*/, 1, Q_syn, 3, 0 );
-
-
- test();
- test();
- IF( bfi || ( EQ_32( total_brate, ACELP_7k20 ) ) || ( EQ_32( total_brate, ACELP_8k00 ) ) )
- {
- /* previous frame erased and no TC frame */
- IF( *scaling_flag > 0 )
- {
- /*enr2 += 0.01f;*/
- L_enr2 = L_max( L_enr2, 1 ); /* L_enr2 is in Q0 */
-
- IF( bfi ) /* In all bad frames, limit the gain to 1 */
- {
- /* gain2 = (float)sqrt( enr_old / enr2 );*/
- L_tmp = Sqrt_Ratio32( L_enr_old, 0, L_enr2, 0, &exp2 );
- gain2 = round_fx_sat( L_shl_sat( L_tmp, sub( exp2, 1 ) ) ); /* in Q14 */
-
- /*if( gain2 > 1.0f )gain2 = 1.0f;*/
- gain2 = s_min( gain2, 16384 );
-
- /* find the energy/gain at the beginning of the frame */
- frame_ener_fx( L_frame, clas, synth, pitch[0], &L_enr1 /*Q0*/, 1, Q_syn, 3, 0 );
-
- /*enr1 += 0.1f;*/
- L_enr1 = L_max( L_enr1, 1 ); /* L_enr2 is in Q0 */
-
- /*gain1 = (float)sqrt( enr_old / enr1 );*/
- L_tmp = Sqrt_Ratio32( L_enr_old, 0, L_enr1, 0, &exp2 );
- gain1 = round_fx_sat( L_shl_sat( L_tmp, sub( exp2, 1 ) ) ); /* in Q14 */
-
- /*if( gain1 > 1.0f )gain1 = 1.0f;*/
- gain1 = s_min( gain1, 16384 ); /*Q14*/
- }
- ELSE /* good frame */
- {
- IF( L_enr_q == 0 ) /* If E info (FEC protection bits) is not available in the bitstream */
- {
- L_enr_q = L_enr2; /*Q0*/
- set16_fx( h1, 0, L_FRAME / 2 );
- h1[0] = 1024; /*1.0f in Q10*/
- move16();
- /*syn_filt( Aq+(3*(M+1)), M, h1, h1, L_FRAME/2, h1+(M+1), 0 );*/
- E_UTIL_synthesis( 1, Aq + ( 3 * ( M + 1 ) ), h1, h1, L_FRAME / 2, h1 + ( M + 1 ), 0, M );
-
- /*Compute tilt */
- /*rr0 = dotp( h1, h1, L_FRAME/2-1 ) + 0.1f;*/
- /*rr1 = dotp( h1, h1+1, L_FRAME/2-1 );*/
- /*tilt = rr1 / rr0;*/
- tilt = extract_h( L_shl_sat( get_gain( h1 + 1, h1, L_FRAME / 2 - 1 ), 15 ) ); /*Q15*/
- pitch_dist = 0;
- move16();
- L_mean_pitch = L_mult( pitch[0], 8192 /*1.0f in Q13*/ ); /*Q14*/
- FOR( k = 0; k < ( NB_SUBFR - 1 ); k++ )
- {
- pitch_dist = add( pitch_dist, abs_s( sub( pitch[k + 1], pitch[k] ) ) ); /*Q0*/
- L_mean_pitch = L_mac( L_mean_pitch, pitch[k + 1], 8192 ); /*Q14*/
- }
- /*pitch_dist /= (float)(NB_SUBFR-1); */
- pitch_dist = mult_r( shl( pitch_dist, 4 ), 10923 /*1/(float)(NB_SUBFR-1) in Q15*/ ); /*Q4*/
- /*mean_pitch /= (float)(NB_SUBFR);*/
- mean_pitch = extract_h( L_shl( L_mean_pitch, 4 ) ); /*Q4*/
-
-
- test();
- test();
- test();
- test();
- test();
- test();
- IF( ( GT_16( tilt, 22938 ) ) && /* HF resonnant filter */
- ( ( GT_16( pitch_dist, 8 << 4 ) ) || ( LT_16( mean_pitch, PIT_MIN << 4 ) ) ) && /* pitch unstable or very short */
- ( ( 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;}*/
- L_enr_q = L_min( L_enr_q, L_shl_sat( Mult_32_16( L_enr_old, scaling ), 1 ) ); /* scaling in Q14*/
- }
- ELSE
- {
- ener_max = *lp_ener_FEC_max; /*Q0*/
- move32();
- test();
- if ( EQ_16( clas, VOICED_TRANSITION ) || ( GE_16( clas, INACTIVE_CLAS ) ) )
- {
- ener_max = *lp_ener_FEC_av; /*Q0*/
- move32();
- }
- /*if( enr_old > ener_max )ener_max = enr_old;*/
- ener_max = L_max( ener_max, L_enr_old );
-
- /*if( enr_q > scaling * ener_max ){enr_q = scaling * ener_max;}*/
- L_enr_q = L_min( L_enr_q, L_shl_sat( Mult_32_16( ener_max, scaling ), 1 ) ); /* scaling in Q14*/
- }
- }
- /*gain2 = (float)sqrt( enr_q / enr2 );*/
- L_enr_q = L_max( L_enr_q, 1 ); /* L_enr2 is in Q0 */
- L_tmp = Sqrt_Ratio32( L_enr_q, 0, L_enr2, 0, &exp2 );
- gain2 = round_fx( L_shl( L_tmp, sub( exp2, 1 ) ) ); /* in Q14 */
-
- /*-----------------------------------------------------------------*
- * Find the energy/gain at the beginning of the frame to ensure smooth transition after erasure(s)
- *-----------------------------------------------------------------*/
-
- test();
- test();
- test();
- test();
- test();
- test();
- IF( ( ( GE_16( last_good, VOICED_TRANSITION ) && LT_16( last_good, INACTIVE_CLAS ) && ( clas == UNVOICED_CLAS || EQ_16( clas, INACTIVE_CLAS ) ) ) ||
- EQ_32( last_core_brate, SID_1k75 ) || EQ_32( last_core_brate, SID_2k40 ) || last_core_brate == FRAME_NO_DATA ) &&
- prev_bfi )
- {
- /* voiced -> unvoiced signal transition */
- /* CNG -> active signal transition */
- gain1 = gain2; /*Q14*/
- move16();
- }
- ELSE
- {
- /* find the energy at the beginning of the frame */
- frame_ener_fx( L_frame, clas, synth, pitch[0], &L_enr1 /*Q0*/, 1, Q_syn, 3, 0 );
-
- /*enr1 += 0.1f;*/
- L_enr1 = L_max( L_enr1, 1 ); /* L_enr1 is in Q0 */
-
- /*gain1 = (float)sqrt( enr_old / enr1 );*/
- L_tmp = Sqrt_Ratio32( L_enr_old, 0, L_enr1, 0, &exp2 );
- gain1 = round_fx_sat( L_shl_sat( L_tmp, sub( exp2, 1 ) ) ); /* in Q14 */
-
- /*if( gain1 > 1.2f )gain1 = 1.2f;*/
- /* prevent clipping */
- gain1 = s_min( gain1, 19661 /*1.2f in Q14*/ );
-
- /* prevent amplifying the unvoiced or inactive part of the frame in case an offset is followed by an onset */
- test();
- test();
- if ( EQ_16( clas, ONSET ) && GT_16( gain1, gain2 ) && prev_bfi )
- {
- gain1 = gain2; /*Q14*/
- move16();
- }
- }
-
- L_enr2 = L_enr_q; /*Q0*/
- move32(); /* Set the end frame energy to the scaled energy, to be used in the lp_ener_FEC */
- }
-
- /*------------------------------------------------------------------------------*
- * Smooth the energy evolution by exponentially evolving from gain1 to gain2
- *------------------------------------------------------------------------------*/
-
- /*gain2 *= ( 1.0f - AGC );*/
- L_tmp = L_mult( gain2, (Word16) ( 32768 /*Q15*/ - AGC_FX ) ); /*Q30*/
- FOR( i = 0; i < L_frame; i++ )
- {
- /*gain1 = gain1 * AGC + gain2;*/
- gain1 = mac_r( L_tmp, gain1, AGC_FX ); /* in Q14 */
- /*exc[i] *= gain1;*/
- exc[i] = mac_r( L_mult( exc[i], gain1 ), exc[i], gain1 );
- move16();
- /*exc2[i] *= gain1;*/
- exc2[i] = mac_r_sat( L_mult( exc2[i], gain1 ), exc2[i], gain1 );
- move16();
- }
- /* smoothing is done in excitation domain, so redo synthesis */
- Copy( mem_tmp, mem_syn, M ); /* Q_syn */
- syn_12k8_fx( L_frame, Aq, exc2, synth, mem_syn, 1, Q_exc, Q_syn );
- *update_flg = 1;
- move16();
- }
- }
- ELSE
- {
- /* previous frame erased and no TC frame */
- test();
- IF( prev_bfi && NE_16( coder_type, TRANSITION ) )
- {
- IF( L_enr_q == 0 )
- {
- L_enr_q = L_max( 1, L_enr2 ); /* sets to 'L_enr2' in 1 clock */
- set16_fx( h1, 0, L_FRAME / 2 );
- h1[0] = 1024; /*1.0f in Q10*/
- move16();
- /*syn_filt( Aq+(3*(M+1)), M, h1, h1, L_FRAME/2, h1+(M+1), 0 );*/
- E_UTIL_synthesis( 1, Aq + ( 3 * ( M + 1 ) ), h1, h1, L_FRAME / 2, h1 + ( M + 1 ), 0, M );
- /*Compute tilt */
- /*rr0 = dotp( h1, h1, L_FRAME/2-1 ) + 0.1f;*/
- /*rr1 = dotp( h1, h1+1, L_FRAME/2-1 );*/
- /*tilt = rr1 / rr0;*/
- tilt = extract_h( L_shl_sat( get_gain( h1 + 1, h1, L_FRAME / 2 - 1 ), 15 ) ); /*Q15*/
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- IF( ( ( ( EQ_32( total_brate, ACELP_13k20 ) ) || ( EQ_32( total_brate, ACELP_12k85 ) ) || ( EQ_32( total_brate, ACELP_12k15 ) ) || ( EQ_32( total_brate, ACELP_11k60 ) ) ||
- ( EQ_32( total_brate, ACELP_9k60 ) ) ) &&
- ( GT_16( tilt, 22938 ) ) && /* HF resonnant filter */
- ( ( ( clas == UNVOICED_CLAS ) ) || ( EQ_16( clas, INACTIVE_CLAS ) ) ) ) ) /* unvoiced classification */
- {
- /*if( enr_q > scaling * enr_old )enr_q = scaling * enr_old;*/
- L_enr_q = L_min( L_enr_q, L_shl_sat( Mult_32_16( L_enr_old, scaling ), 1 ) ); /* scaling in Q14*/
- }
- 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();
- IF( *old_enr_LP != 0 && GT_16( enr_LP, shl_sat( *old_enr_LP, 1 ) ) )
- {
- /* enr_q /= enr_LP */
- exp = norm_l( L_enr_q );
- tmp = extract_h( L_shl( L_enr_q, exp ) );
-
- exp2 = norm_s( enr_LP );
- tmp2 = shl( enr_LP, exp2 );
-
- exp = sub( exp2, exp );
-
- tmp3 = sub( tmp, tmp2 );
- IF( tmp3 > 0 )
- {
- tmp = shr( tmp, 1 );
- exp = add( exp, 1 );
- }
- tmp = div_s( tmp, tmp2 );
-
- /* L_enr_q *= 2 * *old_enr_LP */
- L_enr_q = L_shl( L_mult( tmp, shl( *old_enr_LP, 1 ) ), exp );
- }
-
- ELSE
- {
- test();
- IF( avoid_lpc_burst_on_recovery && GT_16( enr_LP, 160 /*20.0f in Q3*/ ) )
- {
- exp = norm_s( enr_LP );
- tmp = shl( enr_LP, exp );
-
- exp2 = 7;
- move16();
- tmp2 = 160 << 7; /* 160 = 20.0f in Q3 */
- move16();
- exp = sub( exp2, exp );
-
- IF( GT_16( tmp, tmp2 ) )
- {
- tmp = shr( tmp, 1 );
- exp = add( exp, 1 );
- }
- tmp = div_s( tmp, tmp2 ); /* tmp*2^exp = enr_LP/20.0 */
- L_tmp = Isqrt_lc( L_deposit_h( tmp ), &exp ); /* L_tmp*2^exp = sqrt(20.0/enr_LP) */
- L_enr_q = L_shl( Mpy_32_32( L_enr_q, L_tmp ), exp );
- }
- }
- }
-
- test();
- test();
- test();
- test();
- IF( ( GE_16( last_good, VOICED_TRANSITION ) && LT_16( last_good, INACTIVE_CLAS ) && GE_16( clas, VOICED_TRANSITION ) && LT_16( clas, INACTIVE_CLAS ) ) || force_scaling )
- {
-
- IF( GT_32( L_enr_q, L_enr_old ) ) /* Prevent energy to increase on voiced */
- {
- L_enr_q = L_add( Mpy_32_16_1( L_enr_old, 32767 - SCLSYN_LAMBDA ), Mpy_32_16_1( L_enr_q, SCLSYN_LAMBDA ) ); /*Q0*/
- }
- }
- }
-
- L_enr_q = L_max( 1, L_enr_q );
-
- /* gain2 = (float)sqrt( enr_q / enr2 );*/
- exp = norm_l( L_enr_q );
- tmp = extract_h( L_shl( L_enr_q, exp ) );
-
- exp2 = norm_l( L_enr2 );
- tmp2 = extract_h( L_shl( L_enr2, exp2 ) );
-
- exp2 = sub( exp, exp2 ); /* Denormalize and substract */
-
- tmp3 = sub( tmp2, tmp );
- IF( tmp3 > 0 )
- {
- tmp2 = shr( tmp2, 1 );
- exp2 = add( exp2, 1 );
- }
-
- tmp = div_s( tmp2, tmp );
-
- L_tmp = L_deposit_h( tmp );
- L_tmp = Isqrt_lc( L_tmp, &exp2 );
- gain2 = round_fx_sat( L_shl_sat( L_tmp, sub( exp2, 1 ) ) ); /* in Q14 */
- /*-----------------------------------------------------------------*
- * Clipping of the smoothing gain at the frame end
- *-----------------------------------------------------------------*/
-
- gain2 = s_min( gain2, 19661 /*1.2f in Q14*/ ); /* Gain modification clipping */
- if ( LT_32( L_enr_q, 2 ) )
- {
- gain2 = s_min( gain2, 16384 /*1.0f in Q14*/ ); /* Gain modification clipping */
- }
-
- /*-----------------------------------------------------------------*
- * Find the energy/gain at the beginning of the frame to ensure smooth transition after erasure(s)
- *-----------------------------------------------------------------*/
-
- test();
- test();
- test();
- test();
- test();
- test();
- IF( EQ_16( clas, SIN_ONSET ) ) /* slow increase */
- {
- gain1 = shr( gain2, 1 ); /*0.5f * gain2*/
- }
- /*------------------------------------------------------------*
- * voiced->unvoiced transition recovery
- *------------------------------------------------------------*/
- ELSE IF( ( GE_16( last_good, VOICED_TRANSITION ) && LT_16( last_good, INACTIVE_CLAS ) && ( clas == UNVOICED_CLAS || EQ_16( clas, INACTIVE_CLAS ) ) ) || /* voiced->unvoiced transition recovery */
- EQ_32( last_core_brate, SID_1k75 ) || EQ_32( last_core_brate, SID_2k40 ) || last_core_brate == FRAME_NO_DATA ) /* CNG -> active signal transition */
- {
- gain1 = gain2; /*Q14*/
- move16();
- }
- ELSE
- {
- /*--------------------------------------------------------*
- * Find the energy at the beginning of the frame
- *--------------------------------------------------------*/
- tmp = frame_ener_fx( L_frame, clas, synth, pitch[0], &L_enr1, 0, Q_syn, 3, 0 );
-
- /*gain1 = (float)sqrt( enr_old / enr1 );*/
- exp = norm_l( L_enr_old );
- tmp = extract_h( L_shl( L_enr_old, exp ) );
- exp2 = norm_l( L_enr1 );
- tmp2 = extract_h( L_shl( L_enr1, exp2 ) );
-
- exp2 = sub( exp, exp2 ); /* Denormalize and substract */
-
- tmp3 = sub( tmp2, tmp );
-
- IF( tmp3 > 0 )
- {
- tmp2 = shr( tmp2, 1 );
- exp2 = add( exp2, 1 );
- }
-
- tmp = div_s( tmp2, tmp );
-
- L_tmp = L_deposit_h( tmp );
- L_tmp = Isqrt_lc( L_tmp, &exp2 );
- gain1 = round_fx_sat( L_shl_sat( L_tmp, sub( exp2, 1 ) ) ); /* in Q14 */
- /* exp2 is always <= 1 */
-
- gain1 = s_min( gain1, 19661 /*1.2F in Q14*/ );
-
- test();
- test();
- if ( avoid_lpc_burst_on_recovery && ( GT_16( enr_LP, 160 ) ) && ( LE_16( enr_LP, shl_sat( *old_enr_LP, 1 ) ) ) )
- {
- gain1 = s_min( gain1, 16384 /*1.0f in Q14*/ );
- }
-
- /*--------------------------------------------------------*
- * Prevent a catastrophy in case of offset followed by onset
- *--------------------------------------------------------*/
- test();
- if ( ( EQ_16( clas, ONSET ) ) && ( GT_16( gain1, gain2 ) ) )
- {
- gain1 = gain2; /*Q14*/
- move16();
- }
- }
- /*-----------------------------------------------------------------*
- * Smooth the energy evolution by exponentially evolving from
- * gain1 to gain2
- *-----------------------------------------------------------------*/
-
- L_tmp = L_mult( gain2, (Word16) ( 32768 /*Q15*/ - AGC_FX ) );
-
- FOR( i = 0; i < L_frame; i++ )
- {
- gain1 = mac_r( L_tmp, gain1, AGC_FX ); /* in Q14 */
- 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 );
- move16();
- }
-
- Copy( mem_tmp, mem_syn, M ); /* Q_syn */
- syn_12k8_fx( L_frame, Aq, exc2, synth, mem_syn, 1, Q_exc, Q_syn );
- *update_flg = 1;
- move16();
- }
- }
- /*-----------------------------------------------------------------*
- * Update low-pass filtered energy for voiced frames
- *-----------------------------------------------------------------*/
-
- test();
- test();
- IF( !bfi && ( GE_16( clas, VOICED_TRANSITION ) && LT_16( clas, INACTIVE_CLAS ) ) )
- {
- IF( EQ_16( clas, VOICED_TRANSITION ) )
- {
- L_enr2_av = L_enr2; /*Q0*/
- move32();
- frame_ener_fx( L_frame, VOICED_CLAS, synth, pitch[sub( shr( L_frame, 6 ), 1 )], &L_ener2_max /*Q0*/, 1, Q_syn, 3, 0 );
- }
- ELSE
- {
- L_ener2_max = L_enr2; /*Q0*/
- move32();
- frame_ener_fx( L_frame, UNVOICED_CLAS, synth, pitch[sub( shr( L_frame, 6 ), 1 )], &L_enr2_av /*Q0*/, 1, Q_syn, 3, 0 );
- }
-
- /**lp_ener_FEC_av = 0.2f * enr2_av + 0.8f * *lp_ener_FEC_av; move32();*/
- *lp_ener_FEC_av = Madd_32_16( Mult_32_16( *lp_ener_FEC_av, 31130 /*0.95f in Q15*/ ), L_enr2_av, 1638 /*0.05F Q15*/ ); /*Q0*/
- move32();
- /**lp_ener_FEC_max = 0.2f * enr2_max + 0.8f * *lp_ener_FEC_max; move32();*/
- *lp_ener_FEC_max = Madd_32_16( Mult_32_16( *lp_ener_FEC_max, 31130 /*0.95f in Q15*/ ), L_ener2_max, 1638 /*0.05F Q15*/ ); /*Q0*/
- move32();
- }
-
- /*-----------------------------------------------------------------*
- * Update the LP filter energy for voiced frames
- *-----------------------------------------------------------------*/
- test();
- if ( GE_16( clas, VOICED_TRANSITION ) && LT_16( clas, INACTIVE_CLAS ) )
- {
- *old_enr_LP = enr_LP; /*Q3*/
- move16();
- }
-
- return;
-}
-#endif
-void FEC_scale_syn_ivas_fx(
- const Word16 L_frame, /* i : length of the frame */
- Word16 *update_flg, /* o: flag indicating re-synthesis after scaling*/
- Word16 clas, /* i/o: frame classification */
- const Word16 last_good, /* i: last good frame classification */
- Word16 *synth, /* i/o: synthesized speech at Fs = 12k8 Hz Q_syn*/
- const Word16 *pitch, /* i: pitch values for each subframe Q0*/
- Word32 L_enr_old, /* i: energy at the end of previous frame */
- Word32 L_enr_q, /* i: transmitted energy for current frame */
- const Word16 coder_type, /* i: coder type */
- const Word16 LSF_Q_prediction, /* i : LSF prediction mode */
- Word16 *scaling_flag, /* i/o: flag to indicate energy control of syn */
- Word32 *lp_ener_FEC_av, /* i/o: averaged voiced signal energy Q0*/
- Word32 *lp_ener_FEC_max, /* i/o: averaged voiced signal energy Q0*/
- const Word16 bfi, /* i: current frame BFI */
- const Word32 total_brate, /* i: total bitrate */
- const Word16 prev_bfi, /* i: previous frame BFI */
- const Word32 last_core_brate, /* i: previous frame core bitrate */
- Word16 *exc, /* i/o: excitation signal without enhancement */
- Word16 *exc2, /* i/o: excitation signal with enhancement */
- Word16 Aq[], /* i/o: LP filter coefs (can be modified if BR) Q12*/
- Word16 *old_enr_LP, /* i/o: LP filter E of last good voiced frame Q3*/
- const Word16 *mem_tmp, /* i: temp. initial synthesis filter states Q_syn*/
- Word16 *mem_syn, /* o: initial synthesis filter states Q_syn*/
- Word16 Q_exc,
- Word16 Q_syn,
-#ifdef REMOVE_EVS_DUPLICATES
- const Word16 element_mode, /* i : element mode */
-#endif
+ const Word16 element_mode, /* i : element mode */
const Word16 avoid_lpc_burst_on_recovery, /* i : if true the excitation energy is limited if LP has big gain */
const Word16 force_scaling /* i: force scaling */
)
@@ -742,12 +174,8 @@ void FEC_scale_syn_ivas_fx(
tmp = sub( 3, getScaleFactor16( synth, L_frame ) );
-#ifdef REMOVE_EVS_DUPLICATES
test();
IF( tmp > 0 && GT_16( element_mode, EVS_MONO ) )
-#else
- IF( tmp > 0 )
-#endif
{
Word16 synth_tmp[L_FRAME16k];
Copy_Scale_sig( synth, synth_tmp, L_frame, -tmp ); // Q_synth - tmp
diff --git a/lib_dec/LD_music_post_filter_fx.c b/lib_dec/LD_music_post_filter_fx.c
index 5b48ab47225f7355d8f46111c86dd939b2fc7461..12a13a4ec141ed145ab1cc55be02b3d825875768 100644
--- a/lib_dec/LD_music_post_filter_fx.c
+++ b/lib_dec/LD_music_post_filter_fx.c
@@ -832,7 +832,14 @@ void Prep_music_postP_fx(
* Extrapolation of the last future part and windowing
*------------------------------------------------------------*/
pt1 = exc_buffer_in + DCT_L_POST - OFFSET2; /*Q_exc*/
- pred_lt4( pt1, pt1, s_pit, fr_pit, OFFSET2, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ IF( element_mode != EVS_MONO )
+ {
+ pred_lt4_ivas_fx( pt1, pt1, s_pit, fr_pit, OFFSET2, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ }
+ ELSE
+ {
+ pred_lt4( pt1, pt1, s_pit, fr_pit, OFFSET2, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ }
/*------------------------------------------------------------*
* windowing right side
*------------------------------------------------------------*/
diff --git a/lib_dec/TonalComponentDetection_fx.c b/lib_dec/TonalComponentDetection_fx.c
index e820f1399780d3fca13070925d67b8d76e443140..409b975f5c18312785f64650e5bfda0631cb6d75 100644
--- a/lib_dec/TonalComponentDetection_fx.c
+++ b/lib_dec/TonalComponentDetection_fx.c
@@ -140,33 +140,13 @@ void DetectTonalComponents(
const Word16 nSamples,
const Word16 nSamplesCore,
Word16 floorPowerSpectrum, /* i: lower limit for power spectrum bins Q0*/
- Word16 element_mode
-#ifdef IVAS_CODE_MDCT_GSHAPE
- ,
- const PsychoacousticParameters *psychParamsCurrent
-#endif
-)
+ Word16 element_mode )
{
Word16 F0;
Word16 thresholdModification[L_FRAME_MAX], lastMDCTSpect_exp;
Word32 pScaledMdctSpectrum[L_FRAME_MAX];
-#ifdef IVAS_CODE_MDCT_GSHAPE
- Word16 nBands;
- IF( psychParamsCurrent == NULL )
- {
- nBands = FDNS_NPTS;
- PMT( "add nBands argument to mdct_shaping_16" )
-#endif
- mdct_shaping_16( lastMDCTSpectrum, nSamplesCore, nSamples, scaleFactors, scaleFactors_exp, scaleFactors_max_e, pScaledMdctSpectrum );
-#ifdef IVAS_CODE_MDCT_GSHAPE
- }
- ELSE
- {
- sns_shape_spectrum( pScaledMdctSpectrum, psychParamsCurrent, scaleFactors, nSamplesCore );
- nBands = psychParamsCurrent->nBands;
- }
-#endif
+ mdct_shaping_16( lastMDCTSpectrum, nSamplesCore, nSamples, scaleFactors, scaleFactors_exp, scaleFactors_max_e, pScaledMdctSpectrum );
lastMDCTSpect_exp = add( lastMDCTSpectrum_exp, scaleFactors_max_e );
@@ -208,12 +188,7 @@ void RefineTonalComponents(
const Word16 nSamples,
const Word16 nSamplesCore,
const Word16 floorPowerSpectrum, /* i: lower limit for power spectrum bins Q0*/
- Word16 element_mode
-#ifdef IVAS_CODE_MDCT_GSHAPE
- ,
- const PsychoacousticParameters *psychParamsCurrent
-#endif
-)
+ Word16 element_mode )
{
Word16 newIndexOfTonalPeak[MAX_NUMBER_OF_IDX]; /*Q0*/
Word16 newLowerIndex[MAX_NUMBER_OF_IDX]; /*Q0*/
@@ -224,12 +199,7 @@ void RefineTonalComponents(
DetectTonalComponents( newIndexOfTonalPeak, newLowerIndex, newUpperIndex, &newNumIndexes, lastPitchLag, currentPitchLag, lastMDCTSpectrum,
- lastMDCTSpectrum_exp, scaleFactors, scaleFactors_exp, scaleFactors_max_e, secondLastPowerSpectrum, nSamples, nSamplesCore, floorPowerSpectrum, element_mode
-#ifdef IVAS_CODE_MDCT_GSHAPE
- ,
- psychParamsCurrent
-#endif
- );
+ lastMDCTSpectrum_exp, scaleFactors, scaleFactors_exp, scaleFactors_max_e, secondLastPowerSpectrum, nSamples, nSamplesCore, floorPowerSpectrum, element_mode );
nPreservedPeaks = 0;
move16();
@@ -740,15 +710,6 @@ static void CorrectF0(
Word16 tmp;
-#ifdef IVAS_CODE
- FOR( i = 0; i < MAX_PEAKS_FROM_PITCH - 1; i++ )
- {
- diff[i] = 0;
- sortedDiff[i] = 0;
- move16));
- move16));
- }
-#endif
F0 = *pF0; /*Q10*/
test();
diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c
index 0fbedff60385b942088c7d38fff83ad9ef0c1e65..847e165948ea8d866449541728ebb0f39ddbdd81 100644
--- a/lib_dec/acelp_core_dec_fx.c
+++ b/lib_dec/acelp_core_dec_fx.c
@@ -1,156 +1,233 @@
+/******************************************************************************************************
+
+ (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
+ Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
+ Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
+ contributors to this repository. All Rights Reserved.
+
+ This software is protected by copyright law and by international treaties.
+ The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
+ Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
+ Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
+ Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
+ contributors to this repository retain full ownership rights in their respective contributions in
+ the software. This notice grants no license of any kind, including but not limited to patent
+ license, nor is any license granted by implication, estoppel or otherwise.
+
+ Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
+ contributions.
+
+ This software is provided "AS IS", without any express or implied warranties. The software is in the
+ development stage. It is intended exclusively for experts who have experience with such software and
+ solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
+ and fitness for a particular purpose are hereby disclaimed and excluded.
+
+ Any dispute, controversy or claim arising under or in relation to providing this software shall be
+ submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
+ accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
+ the United Nations Convention on Contracts on the International Sales of Goods.
+
+*******************************************************************************************************/
+
/*====================================================================================
- EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ 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" /* Compilation switches */
-#include "rom_com.h" /* Static table prototypes */
-#include "prot_fx.h" /* Function prototypes */
+#include
+#include "options.h"
+#include "cnst.h"
+#include "rom_com.h"
+#include "prot_fx.h"
+#include "ivas_cnst.h"
+#include "ivas_rom_com.h"
+#include "wmc_auto.h"
#include "ivas_prot_fx.h"
-#include "ivas_cnst.h" /* Common constants */
-#include "cnst.h" /* Common constants */
-
-#ifndef REMOVE_EVS_DUPLICATES
-/*==========================================================================*/
-/* FUNCTION : void acelp_core_dec_fx () */
-/*--------------------------------------------------------------------------*/
-/* PURPOSE : ACELP core decoder */
-/*--------------------------------------------------------------------------*/
-/* INPUT ARGUMENTS : */
-/* _ Word16 coder_type i : coder type */
-
-/*--------------------------------------------------------------------------*/
-/* OUTPUT ARGUMENTS : */
-/* _ Word16 *voice_factors o : voicing factors Q15 */
-/* _ Word16 old_syn_12k8_16k[] o : intermediate ACELP Q_syn2-1 */
-/* synthesis at 12.8kHz or 16kHz to be used by SWB BWE */
-/* _ Word16 synth_out[] o : synthesis Q_syn2-1 */
-/*--------------------------------------------------------------------------*/
-/* INPUT/OUTPUT ARGUMENTS : */
-/* _ Decoder_State_fx *st_fx: */
-/* _ Word16 bwe_exc_extended[] i/o: bandwidth extended excitation Q0*/
-/*--------------------------------------------------------------------------*/
-/* RETURN ARGUMENTS : */
-/* _ None */
-/*--------------------------------------------------------------------------*/
-/* CALLED FROM : RX */
-/*==========================================================================*/
+
+
+/*-------------------------------------------------------------------*
+ * acelp_core_dec_fx()
+ *
+ * ACELP core decoder
+ *-------------------------------------------------------------------*/
ivas_error acelp_core_dec_fx(
- Decoder_State *st_fx, /* i/o: decoder state structure */
- Word16 output[], /* o : synthesis @internal Fs */
- Word16 synth_out[], /* o : synthesis Q_syn2-1*/
- Word16 save_hb_synth[], /* o : HB synthesis */
- Word32 bwe_exc_extended[], /* i/o: bandwidth extended excitation Q0*/
- Word16 *voice_factors, /* o : voicing factors Q15 */
- Word16 old_syn_12k8_16k[], /* o : intermediate ACELP synthesis for SWB BWE Q_syn2-1*/
- Word16 sharpFlag,
- Word16 pitch_buf_fx[NB_SUBFR16k], /* o : floating pitch for each subframe Q6*/
- Word16 *unbits, /* o : number of unused bits */
- Word16 *sid_bw, /* o : 0-NB/WB, 1-SWB SID */
- STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i/o: TD stereo decoder handle */
- const Word16 tdm_lspQ_PCh[M], /* i : Q LSPs for primary channel */
- const Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */
- const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */
- const Word16 last_element_mode, /* i : last element mode */
- const Word32 last_element_brate, /* i : last element bitrate */
- const Word16 flag_sec_CNA, /* i : CNA flag for secondary channel */
- const Word16 nchan_out, /* i : number of output channels */
- STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */
- const Word16 read_sid_info /* i : read SID info flag */
+ Decoder_State *st, /* i/o: decoder state structure */
+ Word16 output_fx[], /* o : synthesis @internal Fs Q_syn*/
+ Word16 synth_fx16[], /* o : synthesis Q_syn2*/
+ Word16 save_hb_synth_fx16[], /* o : HB synthesis Q0*/
+ Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation 2*Q_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_syn2-1*/
+ const Word16 sharpFlag, /* i : formant sharpening flag */
+ Word16 pitch_buf_fx[NB_SUBFR16k], /* o : Word16 pitch for each subframe Q6*/
+ Word16 *unbits, /* o : number of unused bits */
+ Word16 *sid_bw, /* o : 0-NB/WB, 1-SWB SID */
+ STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i/o: TD stereo decoder handle Qlog2(2.56)*/
+ const Word16 tdm_lspQ_PCh_fx[M], /* i : Q LSPs for primary channel Q15*/
+ const Word16 tdm_lsfQ_PCh_fx[M], /* i : Q LSFs for primary channel */
+ const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */
+ const Word16 last_element_mode, /* i : last element mode */
+ const Word32 last_element_brate, /* i : last element bitrate */
+ const Word16 flag_sec_CNA, /* i : CNA flag for secondary channel */
+ const Word16 nchan_out, /* i : number of output channels */
+ STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */
+ const Word16 read_sid_info /* i : read SID info flag */
)
{
- Word16 old_exc_fx[L_EXC_DEC] = { 0 }, *exc_fx; /* excitation signal buffer (Q0) */
- Word16 syn_fx_tmp[L_FRAME_16k + L_SUBFR], *syn_fx; /* synthesis signal buffer */
- Word16 temp_buf[L_FRAME16k + L_SYN_MEM];
- Word16 output_frame; /* frame length at output sampling freq. */
- Word16 mem_tmp_fx[M]; /* temporary synthesis filter memory */
- Word32 enr_q_fx; /* E information for FER protection */
- Word16 tmp_noise_fx; /* Long term temporary noise energy */
- Word16 i, int_fs;
- Word16 tc_subfr_fx;
- Word16 allow_cn_step_fx;
+ Word32 synth_fx[960], save_hb_synth_fx[960] /*, bwe_exc_extended_fx[L_FRAME32k + NL_BUFF_OFFSET]*/;
+ Word16 old_exc_fx[L_EXC_DEC], *exc_fx; /* excitation signal buffer */
+ Word16 syn_tmp_fx[L_FRAME16k + L_SUBFR], *psyn_fx; /* synthesis signal buffer */
+ Word16 output_frame; /* frame length at output sampling freq. */
+ Word16 lsf_new_fx[M]; /* LSFs at the end of the frame Qlog2(2.56) */
+ Word16 lsp_new_fx[M]; /* LSPs at the end of the frame Q15 */
+ Word16 lsp_mid_fx[M]; /* LSPs in the middle of the frame */
+ Word16 Aq_fx[NB_SUBFR16k * ( M + 1 )]; /* A(q) quantized for the 4 subframes */
+ Word16 old_exc2_fx[L_FRAME16k + L_EXC_MEM], *exc2_fx; /* total excitation buffer */
+ Word16 mem_tmp_fx[M]; /* temporary synthesis filter memory */
+ Word32 enr_q_fx; /* E information for FER protection */
+ Word16 tmp_noise_fx; /* Long term temporary noise energy */
+ Word16 Es_pred_fx; /* predicted scaled innov. energy Q8 */
+ Word16 FEC_pitch_fx; /* FEC pitch */
+ Word16 old_bwe_exc_fx[( ( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2 )]; /* excitation buffer */
+ Word16 *bwe_exc_fx; /* Excitation for SWB TBE */
+ Word16 i, j, int_fs;
+ Word16 tc_subfr;
+ Word16 allow_cn_step;
Word16 temp_buf_fx[L_FRAME16k + L_SYN_MEM];
-
- Word16 Aq_fx[NB_SUBFR16k * ( M + 1 )] = { 0 }; /*Q12*/
- Word16 Es_pred_fx; /*Q8*/
- Word16 old_bwe_exc_fx[( ( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2 )] = { 0 }; /* excitation buffer Q_exc*/
- Word16 old_exc2_fx[L_FRAME16k + L_EXC_MEM], *exc2_fx; /* total excitation buffer */
- Word16 *bwe_exc_fx;
- Word16 lsf_new_fx[M]; /* LSFs at the end of the frame */
- Word16 lsp_new_fx[M]; /* LSPs at the end of the frame */
- Word16 lsp_mid_fx[M]; /* LSPs in the middle of the frame */
- Word16 FEC_pitch_fx; /*Q6*/
Word16 last_pulse_pos;
Word16 T0_tmp;
- Word16 do_WI_fx;
+ Word16 do_WI;
Word16 dct_buffer_fx[DCT_L_POST];
Word16 exc_buffer_fx[DCT_L_POST];
- Word16 dct_exc_tmp[L_FRAME16k];
- Word16 qdct;
- Word16 delta_mem_scale;
- Word16 bpf_error_signal[L_FRAME16k];
- CLDFB_SCALE_FACTOR scaleFactor;
- Word32 workBuffer[128 * 3];
- Word32 q_env[20];
- Word16 exc3_fx[L_FRAME16k];
- Word16 syn1_fx_tmp[L_FRAME16k + 2], *syn1_fx;
- Word32 *realBuffer[CLDFB_NO_COL_MAX], *imagBuffer[CLDFB_NO_COL_MAX];
- Word16 gain_buf[NB_SUBFR16k]; /*Q14*/
+ Word16 dct_exc_tmp_fx[L_FRAME16k];
+ Word16 nb_bits; /* number of bits */
+ Word16 indice; /* parameter indices to write */
+ Word16 gain_buf_fx[NB_SUBFR16k];
Word16 syn_fx_tmp2[L_FRAME_16k];
Word16 pitch_buf_tmp[NB_SUBFR16k];
- Word16 k;
Word16 update_flg;
- Word32 realBufferTmp[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
- Word32 imagBufferTmp[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
- Word16 LSF_Q_prediction; /* o : LSF prediction mode */
+ Word32 q_env_fx[20];
+ Word16 exc3_fx[L_FRAME16k];
+ Word16 syn1_tmp_fx[L_FRAME16k + 2], *syn1_fx;
+ Word32 *realBuffer_fx[CLDFB_NO_COL_MAX], *imagBuffer_fx[CLDFB_NO_COL_MAX];
+ Word32 realBufferTmp_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
+ Word32 imagBufferTmp_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
+ Word16 LSF_Q_prediction; /* LSF prediction mode */
Word16 avoid_lpc_burst_on_recovery;
- Word16 uc_two_stage_flag, dec;
- Word16 nb_bits, indice;
+ Word16 tmpF_fx;
+ Word16 uc_two_stage_flag;
Word16 tdm_lp_reuse_flag, tdm_low_rate_mode, tdm_Pitch_reuse_flag;
- MUSIC_POSTFILT_HANDLE hMusicPF;
- BPF_DEC_HANDLE hBPF;
- TD_BWE_DEC_HANDLE hBWE_TD;
- FD_BWE_DEC_HANDLE hBWE_FD;
- TCX_DEC_HANDLE hTcxDec;
+ Word16 *old_exc_s_fx; /* Start of last excitation frame */
+ Word16 *p_tdm_Pri_pitch_buf_fx;
+ Word16 tmp, exp, local_element_mode;
ivas_error error;
- (void) ( tdm_lspQ_PCh );
- (void) ( tdm_lsfQ_PCh );
- (void) ( use_cldfb_for_dft );
- (void) ( last_element_mode );
- (void) ( last_element_brate );
- (void) ( flag_sec_CNA );
- (void) ( nchan_out );
- (void) ( save_hb_synth );
- (void) ( output );
- (void) ( read_sid_info );
- (void) hStereoCng;
- hMusicPF = st_fx->hMusicPF;
- hBPF = st_fx->hBPF;
- hBWE_TD = st_fx->hBWE_TD;
- hBWE_FD = st_fx->hBWE_FD;
- hTcxDec = st_fx->hTcxDec;
+ Word32 bpf_error_signal_fx[L_FRAME16k];
+ Word16 bpf_error_signal_16fx[L_FRAME16k];
+ Word16 Q_real;
+ Word32 max_real, max_imag, max_val;
+
+ set32_fx( bpf_error_signal_fx, 0, L_FRAME16k );
+ set16_fx( bpf_error_signal_16fx, 0, L_FRAME16k );
+ set16_fx( Aq_fx, 0, NB_SUBFR16k * ( M + 1 ) );
+ set16_fx( old_bwe_exc_fx, 0, ( ( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2 ) );
+
error = IVAS_ERR_OK;
move32();
- // IF ( EQ_16(st_fx->element_mode, IVAS_CPE_MDCT) && EQ_16(nchan_out, 1) && EQ_16(st_fx->idchan, 1) && LE_32(last_element_brate, IVAS_SID_4k4) )
+
test();
test();
test();
- IF( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) && EQ_16( nchan_out, 1 ) && EQ_16( st_fx->idchan, 1 ) && LE_32( last_element_brate, IVAS_SID_5k2 ) )
+ IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && EQ_16( nchan_out, 1 ) && EQ_16( st->idchan, 1 ) && LE_32( last_element_brate, IVAS_SID_5k2 ) )
{
/* In MDCT-Stereo DTX with mono output, we can skip CNG for the second channel, except for the first inactive frame following an active period */
return error;
}
+ push_wmops( "acelp_core_dec" );
+
+ /* output_frame = (int16_t) ( st->output_Fs / FRAMES_PER_SEC ); */
+ output_frame = extract_l( Mpy_32_32( st->output_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) );
+
+ /*----------------------------------------------------------------*
+ * stereo SID and CNG frames processing
+ *----------------------------------------------------------------*/
+
+ test();
+ test();
+ IF( LE_32( st->core_brate, SID_2k40 ) && EQ_16( st->element_mode, IVAS_CPE_DFT ) && EQ_16( nchan_out, 2 ) )
+ {
+ IF( EQ_16( st->cng_type, FD_CNG ) )
+ {
+ configureFdCngDec_fx( st->hFdCngDec, st->bwidth, ACELP_14k25, st->L_frame, st->last_L_frame, st->element_mode );
+
+ Word16 old_NoiseEstExp;
+ old_NoiseEstExp = st->hFdCngDec->hFdCngCom->sidNoiseEstExp;
+ move16();
+
+ /* Only run parameter decoding in SID frames */
+ IF( EQ_32( st->core_brate, SID_2k40 ) )
+ {
+ FdCng_decodeSID_ivas_fx( st );
+
+ Word16 n1, n2;
+ n1 = L_norm_arr( st->hFdCngDec->hFdCngCom->sidNoiseEst, NPART );
+ n2 = L_norm_arr( st->hFdCngDec->hFdCngCom->sidNoiseEstLp, NPART );
+
+ Word16 common_e = s_max( sub( old_NoiseEstExp, n2 ), sub( st->hFdCngDec->hFdCngCom->sidNoiseEstExp, n1 ) );
+ scale_sig32( st->hFdCngDec->hFdCngCom->sidNoiseEst, NPART, sub( st->hFdCngDec->hFdCngCom->sidNoiseEstExp, common_e ) );
+ scale_sig32( st->hFdCngDec->hFdCngCom->sidNoiseEstLp, NPART, sub( old_NoiseEstExp, common_e ) );
+ st->hFdCngDec->hFdCngCom->sidNoiseEstExp = common_e;
+ move16();
+ }
+
+ FOR( i = 0; i < NPART; i++ )
+ {
+ st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] = Madd_32_32( Mpy_32_32( STEREO_DFT_FD_FILT_Q31, st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] ),
+ STEREO_DFT_FD_FILT_COMP_Q31, st->hFdCngDec->hFdCngCom->sidNoiseEst[i] );
+ move32();
+ }
+
+ ApplyFdCng_fx( NULL, 0, NULL, 0, NULL, NULL, NULL, st, 0, 0 );
+ }
+ ELSE
+ {
+ configureFdCngDec_fx( st->hFdCngDec, st->bwidth, ACELP_14k25, st->L_frame, st->last_L_frame, st->element_mode );
+
+ /* decode CNG parameters */
+ CNG_dec_fx( st, last_element_mode, Aq_fx, lsp_new_fx, lsf_new_fx, &allow_cn_step, sid_bw, q_env_fx );
+
+ /* comfort noise generation */
+ CNG_exc_fx( st->core_brate, st->L_frame, &st->hTdCngDec->Enew_fx, &st->hTdCngDec->cng_seed, NULL, NULL, &st->lp_ener_fx, st->last_core_brate, &st->first_CNG, &( st->hTdCngDec->cng_ener_seed ), NULL, allow_cn_step, &st->hTdCngDec->last_allow_cn_step, st->prev_Q_exc, st->Q_exc, st->hTdCngDec->num_ho, q_env_fx, st->hTdCngDec->lp_env_fx, st->hTdCngDec->old_env_fx, st->hTdCngDec->exc_mem_fx, st->hTdCngDec->exc_mem1_fx, sid_bw, &st->hTdCngDec->cng_ener_seed1, NULL, st->Opt_AMR_WB, st->element_mode );
+
+ Copy( Aq_fx, st->Aq_cng, M + 1 ); /*Q12*/
+
+ /* update old LSP and LSF vector */
+ Copy( lsf_new_fx, st->lsf_old_fx, M ); /*Qlog2(2.56)*/
+ Copy( lsp_new_fx, st->lsp_old_fx, M ); /*Q15*/
+ }
+
+ set16_fx( output_fx, 0, output_frame ); /* output and synth are not used in DFT domain CNG generation and the decoder output is unaffected if they are left uninitalized */
+ set16_fx( synth_fx16, 0, output_frame ); /* They are however read in a few places which causes errors in the valgrind tests. Simplest solution from a code perspective was to set them to zero. */
+
+ /* CN generation done in DFT domain */
+ pop_wmops();
+
+ return error;
+ }
+
+ /*----------------------------------------------------------------*
+ * Active frames processing
+ *----------------------------------------------------------------*/
+
+ /* open CLDFB buffer up to CLDFB_NO_CHANNELS_MAX bands for 48kHz */
FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
{
- set32_fx( realBufferTmp[i], 0, CLDFB_NO_CHANNELS_MAX );
- set32_fx( imagBufferTmp[i], 0, CLDFB_NO_CHANNELS_MAX );
- realBuffer[i] = realBufferTmp[i];
- move32();
- imagBuffer[i] = imagBufferTmp[i];
- move32();
+ set32_fx( realBufferTmp_fx[i], 0, CLDFB_NO_CHANNELS_MAX );
+ set32_fx( imagBufferTmp_fx[i], 0, CLDFB_NO_CHANNELS_MAX );
+ realBuffer_fx[i] = realBufferTmp_fx[i];
+ imagBuffer_fx[i] = imagBufferTmp_fx[i];
}
/*----------------------------------------------------------------*
@@ -159,54 +236,61 @@ ivas_error acelp_core_dec_fx(
LSF_Q_prediction = -1;
move16();
- set16_fx( syn_fx_tmp, 0, L_SUBFR );
- syn_fx = syn_fx_tmp + L_SUBFR;
- syn1_fx_tmp[0] = 0;
+ set16_fx( syn_tmp_fx, 0, L_SUBFR );
+ psyn_fx = syn_tmp_fx + L_SUBFR;
+ syn1_tmp_fx[0] = 0;
move16();
- syn1_fx_tmp[1] = 0;
+ syn1_tmp_fx[1] = 0;
move16();
- syn1_fx = syn1_fx_tmp + 2;
- /*output_frame = (Word16)(st_fx->output_Fs_fx / 50); move16();*/
- output_frame = st_fx->output_frame_fx;
- move16();
- st_fx->bpf_off = 0;
+ syn1_fx = syn1_tmp_fx + 2;
+ st->bpf_off = 0;
move16();
+
test();
test();
test();
test();
test();
test();
- IF( EQ_16( st_fx->last_core, HQ_CORE ) || EQ_16( st_fx->last_core, TCX_20_CORE ) || EQ_16( st_fx->last_core, TCX_10_CORE ) || ( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) && LE_32( st_fx->last_core_brate, SID_2k40 ) ) || ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) && LE_32( st_fx->last_core_brate, SID_2k40 ) ) )
+ IF( EQ_16( st->last_core, HQ_CORE ) || EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) || ( EQ_16( st->element_mode, IVAS_CPE_DFT ) && LE_32( st->last_core_brate, SID_2k40 ) ) || ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && LE_32( st->last_core_brate, SID_2k40 ) ) )
{
/* in case of HQ->ACELP switching, do not apply BPF */
- st_fx->bpf_off = 1;
+ st->bpf_off = 1;
move16();
- /* in case of core switching, reset post-filter memories */
- if ( st_fx->hPFstat != NULL )
+ if ( st->hPFstat != NULL )
{
- st_fx->hPFstat->on = 0;
+ /* in case of core switching, reset post-filter memories */
+ st->hPFstat->on = 0;
move16();
}
- /* reset the GSC pre echo energy threshold in case of switching */
- if ( st_fx->hGSCDec != NULL )
+ if ( st->hGSCDec != NULL )
{
- st_fx->hGSCDec->Last_frame_ener_fx = MAX_32;
+ /* reset the GSC pre echo energy threshold in case of switching */
+ st->hGSCDec->Last_frame_ener_fx = MAX_32;
move32();
}
}
- IF( st_fx->prev_bfi > 0 )
+
+ test();
+ if ( st->hGSCDec != NULL && ( st->prev_bfi > 0 ) )
{
/* reset the GSC pre echo energy threshold in case of FEC */
- if ( st_fx->hGSCDec != NULL )
- {
- st_fx->hGSCDec->Last_frame_ener_fx = MAX_32;
- move32();
- }
+ st->hGSCDec->Last_frame_ener_fx = MAX_32;
+ move32();
+ }
+
+ test();
+ test();
+ test();
+ test();
+ IF( st->hFdCngDec != NULL && ( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) && ( EQ_32( st->last_core_brate, SID_2k40 ) || st->last_core_brate == FRAME_NO_DATA ) )
+ {
+ set16_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2, 0, FFTLEN );
+ set16_fx( hStereoCng->olapBufferSynth22_fx, 0, FFTLEN );
}
- st_fx->clas_dec = st_fx->last_good;
+ st->clas_dec = st->last_good;
move16();
enr_q_fx = 0;
move32();
@@ -214,21 +298,22 @@ ivas_error acelp_core_dec_fx(
move16();
tmp_noise_fx = 0;
move16();
- Copy( st_fx->old_exc_fx, old_exc_fx, L_EXC_MEM_DEC ); // Q_exc
+ Copy( st->old_exc_fx, old_exc_fx, L_EXC_MEM_DEC ); /*Q_exc*/
exc_fx = old_exc_fx + L_EXC_MEM_DEC;
- IF( st_fx->hWIDec != NULL )
+ IF( st->hWIDec != NULL )
{
- Copy( st_fx->hWIDec->old_exc2_fx, old_exc2_fx, L_EXC_MEM );
+ Copy( st->hWIDec->old_exc2_fx, old_exc2_fx, L_EXC_MEM );
}
ELSE
{
set16_fx( old_exc2_fx, 0, L_EXC_MEM );
}
exc2_fx = old_exc2_fx + L_EXC_MEM;
- IF( st_fx->hBWE_TD != NULL )
+
+ IF( st->hBWE_TD != NULL )
{
- Copy( hBWE_TD->old_bwe_exc_fx, old_bwe_exc_fx, PIT16k_MAX * 2 ); // Q_exc
+ Copy( st->hBWE_TD->old_bwe_exc_fx, old_bwe_exc_fx, PIT16k_MAX * 2 ); /*Q_exc*/
bwe_exc_fx = old_bwe_exc_fx + PIT16k_MAX * 2;
}
ELSE
@@ -238,271 +323,270 @@ ivas_error acelp_core_dec_fx(
last_pulse_pos = 0;
move16();
- do_WI_fx = 0;
+ do_WI = 0;
move16();
- st_fx->GSC_noisy_speech = 0;
+ st->GSC_noisy_speech = 0;
move16();
- st_fx->relax_prev_lsf_interp = 0;
+ st->relax_prev_lsf_interp = 0;
move16();
+ set16_fx( gain_buf_fx, 0, NB_SUBFR16k );
- set16_fx( gain_buf, 0, NB_SUBFR16k );
- IF( EQ_16( st_fx->L_frame, L_FRAME ) )
+ IF( EQ_16( st->L_frame, L_FRAME ) )
{
- st_fx->gamma = GAMMA1;
+ st->gamma = GAMMA1;
move16();
- st_fx->preemph_fac = PREEMPH_FAC;
+ st->inv_gamma = GAMMA1_INV;
move16();
- int_fs = INT_FS_FX;
+ st->preemph_fac = PREEMPH_FAC;
+ move16();
+ int_fs = INT_FS_12k8;
move16();
}
ELSE
{
- st_fx->gamma = GAMMA16k;
+ st->gamma = GAMMA16k;
+ move16();
+ st->inv_gamma = GAMMA16k_INV;
move16();
- st_fx->preemph_fac = PREEMPH_FAC_16k;
+ st->preemph_fac = PREEMPH_FAC_16k;
move16();
int_fs = INT_FS_16k;
move16();
}
- /* reset post-filter in case post-filtering was off in previous frame */
- IF( st_fx->hPFstat != NULL )
+ test();
+ /* reset post-filter in case of switching */
+ if ( st->hPFstat != NULL && ( st->hPFstat->on == 0 ) )
{
- if ( st_fx->hPFstat->on == 0 )
- {
- st_fx->hPFstat->reset = 1;
- move16();
- }
+ st->hPFstat->reset = 1;
+ move16();
}
+
avoid_lpc_burst_on_recovery = 0;
move16();
test();
test();
- if ( st_fx->last_con_tcx && NE_16( st_fx->L_frameTCX_past, st_fx->L_frame ) && st_fx->last_core != 0 )
+ if ( st->last_con_tcx && NE_16( st->L_frameTCX_past, st->L_frame ) && ( st->last_core != 0 ) )
{
avoid_lpc_burst_on_recovery = 1;
move16();
}
- /* TD stereo parameters */
test();
- IF( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) && st_fx->idchan == 1 )
+
+ /* TD stereo parameters */
+ 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;
- move16();
move16();
+ tdm_low_rate_mode = hStereoTD->tdm_low_rate_mode;
move16();
+ tdm_Pitch_reuse_flag = hStereoTD->tdm_Pitch_reuse_flag;
move16();
+ p_tdm_Pri_pitch_buf_fx = hStereoTD->tdm_Pri_pitch_buf_fx;
}
ELSE
{
tdm_lp_reuse_flag = 0;
- tdm_low_rate_mode = 0;
move16();
+ tdm_low_rate_mode = 0;
move16();
test();
- if ( EQ_16( st_fx->element_mode, IVAS_SCE ) && st_fx->low_rate_mode )
+ if ( EQ_16( st->element_mode, IVAS_SCE ) && st->low_rate_mode )
{
tdm_low_rate_mode = 1;
move16();
}
tdm_Pitch_reuse_flag = 0;
move16();
+ p_tdm_Pri_pitch_buf_fx = NULL;
}
+
/*----------------------------------------------------------------*
* Updates in case of internal sampling rate switching
*----------------------------------------------------------------*/
+
test();
test();
- IF( NE_16( st_fx->last_L_frame, st_fx->L_frame ) && ( st_fx->last_core == ACELP_CORE || EQ_16( st_fx->last_core, AMR_WB_CORE ) ) )
+ IF( NE_16( st->last_L_frame, st->L_frame ) && ( st->last_core == ACELP_CORE || EQ_16( st->last_core, AMR_WB_CORE ) ) )
{
- IF( st_fx->hPFstat->on != 0 )
+ Word16 dec;
+
+ IF( ( st->hPFstat->on != 0 ) )
{
Word16 mem_syn_r_size_old, mem_syn_r_size_new;
-
- mem_syn_r_size_old = shr( st_fx->last_L_frame, 4 );
- mem_syn_r_size_new = shr( st_fx->L_frame, 4 );
- lerp( st_fx->hPFstat->mem_stp + L_SYN_MEM - mem_syn_r_size_old, st_fx->hPFstat->mem_stp + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old );
- lerp( st_fx->hPFstat->mem_pf_in + L_SYN_MEM - mem_syn_r_size_old, st_fx->hPFstat->mem_pf_in + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old );
+ mem_syn_r_size_old = mult_r( 2048, st->last_L_frame ); /* 1.25/20.f = 2048 (Q15)*/
+ mem_syn_r_size_new = mult_r( 2048, st->L_frame ); /* 1.25/20.f = 2048 (Q15)*/
+ lerp( st->hPFstat->mem_stp + sub( L_SYN_MEM, mem_syn_r_size_old ), st->hPFstat->mem_stp + sub( L_SYN_MEM, mem_syn_r_size_new ), mem_syn_r_size_new, mem_syn_r_size_old );
+ lerp( st->hPFstat->mem_pf_in + sub( L_SYN_MEM, mem_syn_r_size_old ), st->hPFstat->mem_pf_in + sub( L_SYN_MEM, mem_syn_r_size_new ), mem_syn_r_size_new, mem_syn_r_size_old );
}
+
/* convert quantized LSP vector */
- st_fx->rate_switching_reset = lsp_convert_poly_fx( st_fx->lsp_old_fx, st_fx->L_frame, 0 );
+ st->rate_switching_reset = lsp_convert_poly_fx( st->lsp_old_fx, st->L_frame, 0 );
move16();
+
/* convert old quantized LSF vector */
- lsp2lsf_fx( st_fx->lsp_old_fx, st_fx->lsf_old_fx, M, int_fs );
+ lsp2lsf_fx( st->lsp_old_fx, st->lsf_old_fx, M, int_fs );
/* FEC - update adaptive LSF mean vector */
- Copy( st_fx->lsf_old_fx, st_fx->lsfoldbfi1_fx, M ); // Qlog2(2.56)
- Copy( st_fx->lsf_old_fx, st_fx->lsfoldbfi0_fx, M ); // Qlog2(2.56)
- Copy( st_fx->lsf_old_fx, st_fx->lsf_adaptive_mean_fx, M ); // Qlog2(2.56)
+ Copy( st->lsf_old_fx, st->lsfoldbfi1_fx, M ); /*Qlog2(2.56)*/
+ Copy( st->lsf_old_fx, st->lsfoldbfi0_fx, M ); /*Qlog2(2.56)*/
+ Copy( st->lsf_old_fx, st->lsf_adaptive_mean_fx, M ); /*Qlog2(2.56)*/
/* Reset LPC mem */
- IF( EQ_32( st_fx->sr_core, INT_FS_16k ) )
+ IF( EQ_32( st->sr_core, INT_FS_16k ) )
{
- Copy( GEWB2_Ave_fx, st_fx->mem_AR_fx, M ); // Qlog2(2.56)
+ Copy( GEWB2_Ave_fx, st->mem_AR_fx, M ); /*Qlog2(2.56)*/
}
ELSE
{
- Copy( GEWB_Ave_fx, st_fx->mem_AR_fx, M ); // Qlog2(2.56)
+ Copy( GEWB_Ave_fx, st->mem_AR_fx, M ); /*Qlog2(2.56)*/
}
- set16_fx( st_fx->mem_MA_fx, 0, M );
+ set16_fx( st->mem_MA_fx, 0, M );
+ /* update synthesis filter memories */
dec = DEC;
move16();
- IF( NE_16( st_fx->element_mode, EVS_MONO ) )
+ if ( st->element_mode != EVS_MONO )
{
dec = DEC_IVAS;
move16();
}
-
- /* update synthesis filter memories */
- synth_mem_updt2( st_fx->L_frame, st_fx->last_L_frame, st_fx->old_exc_fx, st_fx->mem_syn_r, st_fx->mem_syn2_fx, NULL, dec );
-
- Copy( st_fx->old_exc_fx, old_exc_fx, L_EXC_MEM_DEC ); // Q_exc
- Copy_Scale_sig( st_fx->mem_syn2_fx, st_fx->mem_syn1_fx, M, sub( -1, st_fx->Q_syn ) ); /*Q-1*/
-
- Copy( st_fx->mem_syn2_fx, st_fx->mem_syn3_fx, M );
+ ivas_synth_mem_updt2_fx( st->L_frame, st->last_L_frame, st->old_exc_fx, st->mem_syn_r, st->mem_syn2_fx, NULL, dec );
+ Copy( st->old_exc_fx, old_exc_fx, L_EXC_MEM_DEC ); /*Q_exc*/
+ Copy_Scale_sig( st->mem_syn2_fx, st->mem_syn1_fx, M, sub( -1, st->Q_syn ) ); /*Q-1*/
+ Copy( st->mem_syn2_fx, st->mem_syn3_fx, M ); /*Q_syn*/
}
- IF( NE_16( st_fx->last_L_frame, st_fx->L_frame ) )
+ /* update buffer of old subframe pitch values */
+ IF( NE_16( st->last_L_frame, st->L_frame ) )
{
- /* update buffer of old subframe pitch values */
- IF( EQ_16( st_fx->L_frame, L_FRAME ) )
+ IF( EQ_16( st->L_frame, L_FRAME ) )
{
-
- IF( EQ_16( st_fx->last_L_frame, L_FRAME32k ) )
+ IF( EQ_16( st->last_L_frame, L_FRAME32k ) )
{
- /* (float)12800/(float)32000; */
- k = 13107; // Q15
+ tmpF_fx = 13107; // Q15
move16();
}
- ELSE IF( EQ_16( st_fx->last_L_frame, 512 ) )
+ ELSE IF( EQ_16( st->last_L_frame, 512 ) )
{
- /* (float)12800/(float)25600; */
- k = 16384; // Q15
+ tmpF_fx = 16384; // Q15
move16();
}
ELSE /* st->last_L_frame == L_FRAME16k */
{
- /* (float)12800/(float)16000; */
- k = 26214; // Q15
+ tmpF_fx = 26214; // Q15
move16();
}
FOR( i = NB_SUBFR16k - NB_SUBFR; i < NB_SUBFR16k; i++ )
{
- st_fx->old_pitch_buf_fx[i - 1] = Mpy_32_16_1( st_fx->old_pitch_buf_fx[i], k ); // Q(15+15+1-16)
+ st->old_pitch_buf_fx[i - 1] = Mpy_32_16_1( st->old_pitch_buf_fx[i], tmpF_fx ); // Q16
move32();
}
FOR( i = 2 * NB_SUBFR16k - NB_SUBFR; i < 2 * NB_SUBFR16k; i++ )
{
- st_fx->old_pitch_buf_fx[i - 2] = Mpy_32_16_1( st_fx->old_pitch_buf_fx[i], k ); // Q15
+ st->old_pitch_buf_fx[i - 2] = Mpy_32_16_1( st->old_pitch_buf_fx[i], tmpF_fx ); // Q16
move32();
}
}
ELSE
{
-
- IF( EQ_16( st_fx->last_L_frame, L_FRAME32k ) )
+ exp = 0;
+ move16();
+ IF( EQ_16( st->last_L_frame, L_FRAME32k ) )
{
- /* (float)16000/(float)32000; */
- k = -16384; // -0.5 in Q15
+ tmpF_fx = 16384; // Q15
move16();
}
- ELSE IF( EQ_16( st_fx->last_L_frame, 512 ) )
+ ELSE IF( EQ_16( st->last_L_frame, 512 ) )
{
- /* tmpF = (float)16000/(float)25600; */
- k = -12288; //-0.375 in Q15
+ tmpF_fx = 20480; // Q15
move16();
}
ELSE /* st->last_L_frame == L_FRAME12k8 */
{
- /* tmpF = (float)16000/(float)12800; */
- k = 8192; //.25 in Q15
+ tmpF_fx = 20480; // Q14
+ move16();
+ exp = 1;
move16();
}
-
FOR( i = 2 * NB_SUBFR - 1; i >= NB_SUBFR; i-- )
{
- st_fx->old_pitch_buf_fx[i + 2] = L_add( st_fx->old_pitch_buf_fx[i], Mpy_32_16_1( st_fx->old_pitch_buf_fx[i], k ) ); // Q15
+ st->old_pitch_buf_fx[i + 2] = Mpy_32_16_1( L_shl( st->old_pitch_buf_fx[i], exp ), tmpF_fx ); // Q15
move32();
}
- st_fx->old_pitch_buf_fx[NB_SUBFR + 1] = st_fx->old_pitch_buf_fx[NB_SUBFR + 2];
+ st->old_pitch_buf_fx[NB_SUBFR + 1] = st->old_pitch_buf_fx[NB_SUBFR + 2];
move32();
FOR( i = NB_SUBFR - 1; i >= 0; i-- )
{
- st_fx->old_pitch_buf_fx[i + 1] = L_add( st_fx->old_pitch_buf_fx[i], Mpy_32_16_1( st_fx->old_pitch_buf_fx[i], k ) ); // Q15
+ st->old_pitch_buf_fx[i + 1] = Mpy_32_16_1( L_shl( st->old_pitch_buf_fx[i], exp ), tmpF_fx ); // Q15
move32();
}
- st_fx->old_pitch_buf_fx[0] = st_fx->old_pitch_buf_fx[1];
+ st->old_pitch_buf_fx[0] = st->old_pitch_buf_fx[1];
move32();
}
}
- IF( NE_16( st_fx->bfi_pitch_frame, st_fx->L_frame ) )
+ IF( NE_16( st->bfi_pitch_frame, st->L_frame ) )
{
- IF( EQ_16( st_fx->L_frame, L_FRAME ) )
+ IF( EQ_16( st->L_frame, L_FRAME ) )
{
-
- IF( EQ_16( st_fx->bfi_pitch_frame, L_FRAME32k ) )
+ IF( EQ_16( st->bfi_pitch_frame, L_FRAME32k ) )
{
- /* (float)12800/(float)32000; */
- k = 13107; // Q15
+ tmpF_fx = 13107; // Q15
move16();
}
- ELSE IF( EQ_16( st_fx->bfi_pitch_frame, 512 ) )
+ ELSE IF( EQ_16( st->bfi_pitch_frame, 512 ) )
{
- /* (float)12800/(float)25600; */
- k = 16384; // Q15
+ tmpF_fx = 16384; // Q15
move16();
}
ELSE /* st->bfi_pitch_frame == L_FRAME16k */
{
- /* (float)12800/(float)16000; */
- k = 26214; // Q15
+ tmpF_fx = 26214; // Q15
move16();
}
- st_fx->bfi_pitch_fx = mult_r( k, st_fx->bfi_pitch_fx );
+ st->bfi_pitch_fx = mult_r( st->bfi_pitch_fx, tmpF_fx );
move16();
- st_fx->bfi_pitch_frame = L_FRAME;
+ st->bfi_pitch_frame = L_FRAME;
move16();
}
ELSE
{
-
- IF( EQ_16( st_fx->bfi_pitch_frame, L_FRAME32k ) )
+ exp = 0;
+ move16();
+ IF( EQ_16( st->bfi_pitch_frame, L_FRAME32k ) )
{
- /* (float)16000/(float)32000; */
- k = -16384; //-0.5 in Q15
+ tmpF_fx = 16384; // Q15
move16();
}
- ELSE IF( EQ_16( st_fx->bfi_pitch_frame, 512 ) )
+ ELSE IF( EQ_16( st->bfi_pitch_frame, 512 ) )
{
- /* tmpF = (float)16000/(float)25600; */
- k = -12288; // -0.375 in Q15
+ tmpF_fx = 20480; // Q15
move16();
}
ELSE /* st->bfi_pitch_frame == L_FRAME12k8 */
{
- /* tmpF = (float)16000/(float)12800; */
- k = 8192; // .25 in Q15
+ tmpF_fx = 20480; // Q14
+ move16();
+ exp = 1;
move16();
}
- st_fx->bfi_pitch_fx = add( st_fx->bfi_pitch_fx, mult_r( st_fx->bfi_pitch_fx, k ) );
+
+ st->bfi_pitch_fx = mult_r( shl_sat( st->bfi_pitch_fx, exp ), tmpF_fx );
move16();
- st_fx->bfi_pitch_frame = L_FRAME16k;
+ st->bfi_pitch_frame = L_FRAME16k;
move16();
}
}
test();
test();
- if ( EQ_16( st_fx->last_bwidth, NB ) && NE_16( st_fx->bwidth, NB ) && st_fx->ini_frame != 0 )
+ if ( EQ_16( st->last_bwidth, NB ) && NE_16( st->bwidth, NB ) && ( st->ini_frame != 0 ) )
{
- st_fx->rate_switching_reset = 1;
+ st->rate_switching_reset = 1;
move16();
}
@@ -510,36 +594,35 @@ ivas_error acelp_core_dec_fx(
* GOOD frame
*----------------------------------------------------------------------*/
- IF( !st_fx->bfi )
+ IF( !st->bfi )
{
/*----------------------------------------------------------------*
* Decoding of TC subframe classification
*----------------------------------------------------------------*/
- tc_subfr_fx = -1;
+ tc_subfr = -1;
move16();
- IF( EQ_16( st_fx->coder_type, TRANSITION ) )
+ IF( EQ_16( st->coder_type, TRANSITION ) )
{
- tc_subfr_fx = tc_classif_fx( st_fx, st_fx->L_frame );
+ tc_subfr = tc_classif_fx( st, st->L_frame );
}
/*----------------------------------------------------------------*
* Decoding of GSC IVAS mode
*----------------------------------------------------------------*/
- st_fx->GSC_IVAS_mode = 0;
- move16();
+
test();
test();
test();
test();
- IF( ( st_fx->element_mode > EVS_MONO ) && st_fx->idchan == 0 && !( ( st_fx->core_brate == FRAME_NO_DATA ) || EQ_32( st_fx->core_brate, SID_2k40 ) ) && !tdm_low_rate_mode )
+ IF( st->element_mode > EVS_MONO && st->idchan == 0 && !( st->core_brate == FRAME_NO_DATA || EQ_32( st->core_brate, SID_2k40 ) ) && !tdm_low_rate_mode )
{
test();
test();
- IF( EQ_16( st_fx->coder_type, AUDIO ) || ( ( st_fx->coder_type == INACTIVE ) && LE_32( st_fx->total_brate, MAX_GSC_INACTIVE_BRATE ) ) )
+ IF( EQ_16( st->coder_type, AUDIO ) || ( EQ_16( st->coder_type, INACTIVE ) && EQ_16( st->inactive_coder_type_flag, 1 ) ) )
{
- st_fx->GSC_IVAS_mode = get_next_indice( st_fx, 2 );
+ st->GSC_IVAS_mode = get_next_indice_fx( st, 2 );
move16();
}
}
@@ -547,88 +630,215 @@ ivas_error acelp_core_dec_fx(
/*----------------------------------------------------------------*
* Decoding of inactive CNG frames
*----------------------------------------------------------------*/
+
test();
- IF( st_fx->core_brate == FRAME_NO_DATA || EQ_32( st_fx->core_brate, SID_2k40 ) )
+ IF( st->core_brate == FRAME_NO_DATA || EQ_32( st->core_brate, SID_2k40 ) )
{
/* decode CNG parameters */
- IF( st_fx->cng_type == LP_CNG )
+ IF( st->cng_type == LP_CNG )
{
-
- CNG_dec_fx( st_fx, EVS_MONO, Aq_fx, lsp_new_fx, lsf_new_fx, &allow_cn_step_fx, sid_bw, q_env );
+ CNG_dec_fx( st, last_element_mode, Aq_fx, lsp_new_fx, lsf_new_fx, &allow_cn_step, sid_bw, q_env_fx );
+ Copy( Aq_fx, st->Aq_cng, add( M, 1 ) );
/* comfort noise generation */
- CNG_exc_fx( st_fx->core_brate, st_fx->L_frame, &st_fx->hTdCngDec->Enew_fx, &st_fx->hTdCngDec->cng_seed, exc_fx, exc2_fx, &st_fx->lp_ener_fx, st_fx->last_core_brate,
- &st_fx->first_CNG, &( st_fx->hTdCngDec->cng_ener_seed ), bwe_exc_fx, allow_cn_step_fx, &st_fx->hTdCngDec->last_allow_cn_step, st_fx->prev_Q_exc, st_fx->Q_exc, st_fx->hTdCngDec->num_ho,
- q_env, st_fx->hTdCngDec->lp_env_fx, st_fx->hTdCngDec->old_env_fx, st_fx->hTdCngDec->exc_mem_fx, st_fx->hTdCngDec->exc_mem1_fx, sid_bw, &st_fx->hTdCngDec->cng_ener_seed1, exc3_fx, st_fx->Opt_AMR_WB, st_fx->element_mode );
+ local_element_mode = st->element_mode;
+ move16();
- Copy( Aq_fx, st_fx->Aq_cng, M + 1 ); // Q12
+ test();
+ test();
+ if ( ( EQ_16( nchan_out, 1 ) && EQ_16( st->element_mode, IVAS_CPE_DFT ) ) || EQ_16( st->masa_sid_format, 1 ) )
+ {
+ local_element_mode = IVAS_SCE; /* For DFT Stereo mono decoding, run CNG_exc as in SCE */
+ move16();
+ }
+ CNG_exc_fx( st->core_brate, st->L_frame, &st->hTdCngDec->Enew_fx, &st->hTdCngDec->cng_seed, exc_fx, exc2_fx, &st->lp_ener_fx, st->last_core_brate, &st->first_CNG, &( st->hTdCngDec->cng_ener_seed ), bwe_exc_fx, allow_cn_step, &st->hTdCngDec->last_allow_cn_step, st->prev_Q_exc, st->Q_exc, st->hTdCngDec->num_ho, q_env_fx, st->hTdCngDec->lp_env_fx, st->hTdCngDec->old_env_fx, st->hTdCngDec->exc_mem_fx, st->hTdCngDec->exc_mem1_fx, sid_bw, &st->hTdCngDec->cng_ener_seed1, exc3_fx, st->Opt_AMR_WB, local_element_mode );
}
ELSE
{
test();
- IF( EQ_32( st_fx->core_brate, SID_2k40 ) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) )
+ IF( EQ_32( st->core_brate, SID_2k40 ) && NE_16( st->element_mode, IVAS_CPE_MDCT ) )
{
- FdCng_decodeSID_fx( st_fx->hFdCngDec->hFdCngCom, st_fx );
+ IF( EQ_16( st->element_mode, EVS_MONO ) )
+ {
+ FdCng_decodeSID_fx( st->hFdCngDec->hFdCngCom, st );
+ }
+ ELSE
+ {
+ Word16 old_NoiseEstExp = st->hFdCngDec->hFdCngCom->sidNoiseEstExp;
+ move16();
+
+ FdCng_decodeSID_ivas_fx( st );
+
+ Scale_sig32( st->hFdCngDec->hFdCngCom->sidNoiseEstLp, NPART, sub( old_NoiseEstExp, st->hFdCngDec->hFdCngCom->sidNoiseEstExp ) );
+ Scale_sig( st->hFdCngDec->hFdCngCom->A_cng, M + 1, sub( norm_s( st->hFdCngDec->hFdCngCom->A_cng[0] ), Q2 ) ); // Qx
+ }
+
*sid_bw = 0;
move16();
}
- generate_comfort_noise_dec_fx( NULL, NULL, NULL, st_fx, &( st_fx->Q_exc ), 2, -1 );
+ IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) )
+ {
+ assert( nchan_out == 1 );
+
+ FOR( i = 0; i < NPART; i++ )
+ {
+ st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] = Madd_32_32( Mpy_32_32( STEREO_DFT_FD_FILT_Q31, st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] ),
+ STEREO_DFT_FD_FILT_COMP_Q31, st->hFdCngDec->hFdCngCom->sidNoiseEst[i] );
+ move32();
+ }
+
+ ApplyFdCng_fx( psyn_fx, st->Q_syn, NULL, 0, realBuffer_fx, imagBuffer_fx, NULL, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) );
+
+ Word16 new_sidNoiseEstExp = 31 - Q4;
+ move16();
+ Scale_sig32( st->hFdCngDec->hFdCngCom->sidNoiseEstLp, NPART, sub( st->hFdCngDec->hFdCngCom->sidNoiseEstExp, new_sidNoiseEstExp ) ); // Q(31-sidNoiseEstExp)
+ Scale_sig32( st->hFdCngDec->hFdCngCom->sidNoiseEst, NPART, sub( st->hFdCngDec->hFdCngCom->sidNoiseEstExp, new_sidNoiseEstExp ) ); // Q(31-sidNoiseEstExp)
+ st->hFdCngDec->hFdCngCom->sidNoiseEstExp = new_sidNoiseEstExp;
+ move16();
+ Word16 new_cngNoiseLevelExp = 31 - Q4;
+ move16();
+ Scale_sig32( st->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, sub( st->hFdCngDec->hFdCngCom->cngNoiseLevelExp, new_cngNoiseLevelExp ) ); // Q(31-cngNoiseLevelExp)
+ st->hFdCngDec->hFdCngCom->cngNoiseLevelExp = new_cngNoiseLevelExp;
+ move16();
+
+ test();
+ ApplyFdCng_fx( psyn_fx, st->Q_syn, NULL, 0, realBuffer_fx, imagBuffer_fx, NULL, st, 0, ( EQ_16( st->coder_type, AUDIO ) && !st->GSC_noisy_speech ) );
+
+ IF( st->hFdCngDec->hFdCngCom->cngNoiseLevelExp < 0 )
+ {
+ Scale_sig32( st->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, st->hFdCngDec->hFdCngCom->cngNoiseLevelExp ); // Q(31-cngNoiseLevelExp)
+ st->hFdCngDec->hFdCngCom->cngNoiseLevelExp = 0;
+ move16();
+ }
+ }
+
+ IF( !read_sid_info )
+ {
+ Word32 noise_lvl_highest_fx;
+
+ noise_lvl_highest_fx = st->hFdCngDec->hFdCngCom->cngNoiseLevel[( st->hFdCngDec->hFdCngCom->stopFFTbin - st->hFdCngDec->hFdCngCom->startBand ) - 1];
+ move32();
+
+ FOR( Word16 b = ( st->hFdCngDec->hFdCngCom->stopFFTbin - st->hFdCngDec->hFdCngCom->startBand ); b < st->hFdCngDec->hFdCngCom->stopBand; b++ )
+ {
+ st->hFdCngDec->hFdCngCom->cngNoiseLevel[b] = noise_lvl_highest_fx;
+ move32();
+ }
+ }
+
+ IF( EQ_16( st->element_mode, EVS_MONO ) )
+ {
+ generate_comfort_noise_dec_fx( NULL, NULL, NULL, st, &( st->Q_exc ), 2, -1 );
+ }
+ ELSE
+ {
+ generate_comfort_noise_dec_ivas_fx( NULL, NULL, NULL, st, &( st->Q_exc ), 1, nchan_out );
+ }
- FdCng_exc( st_fx->hFdCngDec->hFdCngCom, &st_fx->CNG_mode, st_fx->L_frame, st_fx->lsp_old_fx, st_fx->first_CNG, st_fx->lspCNG_fx, Aq_fx, lsp_new_fx, lsf_new_fx, exc_fx, exc2_fx, bwe_exc_fx );
+ FdCng_exc( st->hFdCngDec->hFdCngCom, &st->CNG_mode, st->L_frame, st->lsp_old_fx, st->first_CNG, st->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->L_frame );
}
- delta_mem_scale = 3;
+ Word16 delta_mem_scale = 3;
move16();
test();
- if ( LT_32( st_fx->lp_ener_fx, 40 ) && ( st_fx->cng_type == LP_CNG ) ) /* very low energy frames, less than 0.3125 */
+ if ( LT_32( st->lp_ener_fx, 40 ) && st->cng_type == LP_CNG ) /* very low energy frames, less than 0.3125 */
{
delta_mem_scale = 0;
move16();
}
- i = st_fx->Q_exc;
+ i = st->Q_exc;
move16();
- Rescale_exc( hMusicPF->dct_post_old_exc_fx, exc_fx, bwe_exc_fx, st_fx->hGSCDec->last_exc_dct_in_fx, st_fx->L_frame,
- st_fx->L_frame * HIBND_ACB_L_FAC, 0, &( st_fx->Q_exc ), st_fx->Q_subfr, NULL, 0, INACTIVE );
- Rescale_mem( st_fx->Q_exc, &st_fx->prev_Q_syn, &st_fx->Q_syn, st_fx->mem_syn2_fx, st_fx->mem_syn_clas_estim_fx, delta_mem_scale,
- &st_fx->mem_deemph_fx, hBPF->pst_old_syn_fx, &hBPF->pst_mem_deemp_err_fx, &st_fx->agc_mem_fx[1], st_fx->hPFstat, 0, 0, NULL );
- Copy_Scale_sig( exc2_fx, exc2_fx, st_fx->L_frame, sub( st_fx->Q_exc, i ) ); // Q_exc
+
+ test();
+ IF( st->hMusicPF && st->hGSCDec )
+ {
+ IF( EQ_16( st->element_mode, EVS_MONO ) )
+ {
+ // VE: TBV: should 'st_fx->L_frame * HIBND_ACB_L_FAC' be corrected in EVS?
+ Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, exc_fx, bwe_exc_fx, st->hGSCDec->last_exc_dct_in_fx, st->L_frame,
+ st->L_frame * HIBND_ACB_L_FAC, 0, &( st->Q_exc ), st->Q_subfr, NULL, 0, INACTIVE );
+ }
+ ELSE
+ {
+ Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, exc_fx, bwe_exc_fx, st->hGSCDec->last_exc_dct_in_fx, st->L_frame,
+ L_FRAME32k, 0, &( st->Q_exc ), st->Q_subfr, NULL, 0, INACTIVE );
+ }
+ }
+
+ IF( st->hPFstat != NULL )
+ {
+ Rescale_mem( st->Q_exc, &st->prev_Q_syn, &st->Q_syn, st->mem_syn2_fx, st->mem_syn_clas_estim_fx, delta_mem_scale,
+ &st->mem_deemph_fx, st->hBPF->pst_old_syn_fx, &st->hBPF->pst_mem_deemp_err_fx, &st->agc_mem_fx[1], st->hPFstat, 0, 0, NULL );
+ }
+ ELSE
+ {
+ Rescale_mem( st->Q_exc, &st->prev_Q_syn, &st->Q_syn, st->mem_syn2_fx, st->mem_syn_clas_estim_fx, delta_mem_scale,
+ &st->mem_deemph_fx, NULL, NULL, &st->agc_mem_fx[1], NULL, 0, 0, NULL );
+ }
+
+ Copy_Scale_sig( exc2_fx, exc2_fx, st->L_frame, sub( st->Q_exc, i ) ); // Q_exc
/* update past excitation signals for LD music post-filter */
- IF( hMusicPF != NULL )
+ IF( st->hMusicPF != NULL )
{
- Copy( hMusicPF->dct_post_old_exc_fx + L_FRAME, hMusicPF->dct_post_old_exc_fx, DCT_L_POST - L_FRAME - OFFSET2 );
- Copy( exc2_fx, hMusicPF->dct_post_old_exc_fx + ( DCT_L_POST - L_FRAME - OFFSET2 ), L_FRAME );
+ Copy( st->hMusicPF->dct_post_old_exc_fx + L_FRAME, st->hMusicPF->dct_post_old_exc_fx, DCT_L_POST - L_FRAME - OFFSET2 );
+ Copy( exc2_fx, st->hMusicPF->dct_post_old_exc_fx + ( DCT_L_POST - L_FRAME - OFFSET2 ), L_FRAME );
+
/* Update music post processing values */
/* Filter energies update */
- FOR( i = 0; i < DCT_L_POST; i++ )
+ IF( EQ_16( st->element_mode, EVS_MONO ) )
{
- /*st_fx->filt_lfE_fx[i] = 0.3f + 0.7f * st_fx->filt_lfE_fx[i];*/
- hMusicPF->filt_lfE_fx[i] = round_fx( L_mac( ( 1228 << ( 16 ) ), 22938, hMusicPF->filt_lfE_fx[i] ) );
- move16();
+ FOR( i = 0; i < DCT_L_POST; i++ )
+ {
+ st->hMusicPF->filt_lfE_fx[i] = round_fx( L_mac( ( 1228 << ( 16 ) ), 22938, st->hMusicPF->filt_lfE_fx[i] ) );
+ move16();
+ }
+ }
+ ELSE
+ {
+ FOR( i = 0; i < DCT_L_POST; i++ )
+ {
+ st->hMusicPF->filt_lfE_fx[i] = add( 9830, mult_r( 22937, st->hMusicPF->filt_lfE_fx[i] ) ); // Q15, 9830 =.3f in Q15, 22937=.7f in Q15
+ move16();
+ }
}
}
+
/* synthesis at 12.8kHz sampling rate */
- syn_12k8_fx( st_fx->L_frame, Aq_fx, exc2_fx, syn_fx, st_fx->mem_syn2_fx, 1, st_fx->Q_exc, st_fx->Q_syn );
- syn_12k8_fx( st_fx->L_frame, Aq_fx, exc3_fx, syn1_fx, st_fx->mem_syn3_fx, 1, st_fx->Q_exc, st_fx->Q_syn );
+ move16();
+ syn_12k8_fx( st->L_frame, Aq_fx, exc2_fx, psyn_fx, st->mem_syn2_fx, 1, st->Q_exc, st->Q_syn );
+ syn_12k8_fx( st->L_frame, Aq_fx, exc3_fx, syn1_fx, st->mem_syn3_fx, 1, st->Q_exc, st->Q_syn );
/* reset the decoder */
- CNG_reset_dec_fx( st_fx, pitch_buf_fx, voice_factors );
+ CNG_reset_dec_fx( st, pitch_buf_fx, voice_factors_fx );
+
+ IF( EQ_16( st->element_mode, EVS_MONO ) )
+ {
+ /* update st_fx->mem_syn1 for ACELP core switching */
+ Copy( st->mem_syn3_fx, st->mem_syn1_fx, M );
+ }
+ ELSE
+ {
+ st->Q_syn_cng = st->Q_syn;
+ move16();
+ st->Q_exc_cng = st->Q_exc;
+ move16();
- /* update st_fx->mem_syn1 for ACELP core switching */
- Copy( st_fx->mem_syn3_fx, st_fx->mem_syn1_fx, M );
+ /* update st->mem_syn1 for ACELP core switching */
+ Copy_Scale_sig( st->mem_syn3_fx, st->mem_syn1_fx, M, sub( -1, st->Q_syn ) ); // Q(-1)
+ }
/* update old synthesis for classification */
- Copy( syn1_fx + st_fx->L_frame - L_SYN_MEM_CLAS_ESTIM, st_fx->mem_syn_clas_estim_fx, L_SYN_MEM_CLAS_ESTIM );
-
+ Copy( syn1_fx + st->L_frame - L_SYN_MEM_CLAS_ESTIM, st->mem_syn_clas_estim_fx, L_SYN_MEM_CLAS_ESTIM );
/* save and delay synthesis to be used by SWB BWE */
- Copy_Scale_sig( syn1_fx, temp_buf_fx, st_fx->L_frame, sub( -1, st_fx->Q_syn ) ); // Q_syn -> Q(-1)
- IF( hBWE_FD != NULL )
+ Copy_Scale_sig( syn1_fx, temp_buf_fx, st->L_frame, sub( -1, st->Q_syn ) ); // Q_syn -> Q(-1)
+ IF( st->hBWE_FD != NULL )
{
- save_old_syn_fx( st_fx->L_frame, temp_buf_fx, old_syn_12k8_16k, hBWE_FD->old_syn_12k8_16k_fx, st_fx->preemph_fac, &hBWE_FD->mem_deemph_old_syn_fx );
+ save_old_syn_fx( st->L_frame, temp_buf_fx, old_syn_12k8_16k_fx, st->hBWE_FD->old_syn_12k8_16k_fx, st->preemph_fac, &st->hBWE_FD->mem_deemph_old_syn_fx );
}
}
@@ -638,21 +848,24 @@ ivas_error acelp_core_dec_fx(
ELSE
{
+
/*-----------------------------------------------------------------*
* Configure ACELP bit allocation
*-----------------------------------------------------------------*/
+
nb_bits = 0;
- st_fx->acelp_cfg.FEC_mode = 0;
- uc_two_stage_flag = 0;
move16();
+ st->acelp_cfg.FEC_mode = 0;
move16();
+ uc_two_stage_flag = 0;
move16();
+
test();
- IF( !st_fx->nelp_mode_dec && !st_fx->ppp_mode_dec )
+ IF( !st->nelp_mode_dec && !st->ppp_mode_dec )
{
Word16 tc_subfr_tmp;
- tc_subfr_tmp = tc_subfr_fx;
+ tc_subfr_tmp = tc_subfr;
move16();
if ( LT_16( tc_subfr_tmp, L_SUBFR ) )
{
@@ -660,19 +873,19 @@ ivas_error acelp_core_dec_fx(
move16();
}
- if ( EQ_16( tc_subfr_fx, TC_0_192 ) )
+ if ( EQ_16( tc_subfr, TC_0_192 ) )
{
nb_bits = -1;
move16();
}
- config_acelp1( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, st_fx->inactive_coder_type_flag, tc_subfr_tmp, 1, &nb_bits, unbits, st_fx->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
+ config_acelp1_fx( DEC, st->total_brate, st->core_brate, st->core, st->extl_orig, st->extl_brate_orig, st->L_frame, st->GSC_noisy_speech, &( st->acelp_cfg ), st->next_bit_pos, st->coder_type, st->inactive_coder_type_flag, tc_subfr_tmp, 1, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode );
test();
test();
- IF( EQ_16( st_fx->coder_type, TRANSITION ) && LT_16( tc_subfr_fx, L_SUBFR ) && EQ_16( st_fx->L_frame, L_FRAME ) )
+ IF( EQ_16( st->coder_type, TRANSITION ) && LT_16( tc_subfr, L_SUBFR ) && EQ_16( st->L_frame, L_FRAME ) )
{
- config_acelp1( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, -1, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, TRANSITION, -1, tc_subfr_fx, 2, &nb_bits, unbits, st_fx->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
+ config_acelp1_fx( DEC, st->total_brate, st->core_brate, st->core, st->extl_orig, st->extl_brate_orig, st->L_frame, -1, &( st->acelp_cfg ), st->next_bit_pos, TRANSITION, -1, tc_subfr, 2, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode );
}
}
@@ -682,51 +895,126 @@ ivas_error acelp_core_dec_fx(
test();
test();
- IF( st_fx->hTdCngDec != NULL && ( st_fx->last_core_brate == FRAME_NO_DATA || EQ_32( st_fx->last_core_brate, SID_2k40 ) ) )
+ IF( st->hTdCngDec != NULL && ( st->last_core_brate == FRAME_NO_DATA || EQ_32( st->last_core_brate, SID_2k40 ) ) )
{
- Copy( st_fx->lspCNG_fx, st_fx->lsp_old_fx, M ); // Q15
-
- lsp2lsf_fx( st_fx->lspCNG_fx, st_fx->lsf_old_fx, M, int_fs );
+ Copy( st->lspCNG_fx, st->lsp_old_fx, M ); /*Q15*/
+ lsp2lsf_fx( st->lspCNG_fx, st->lsf_old_fx, M, int_fs );
}
/*-----------------------------------------------------------------*
* Reset higher ACELP pre-quantizer in case of switching
*-----------------------------------------------------------------*/
- IF( !st_fx->use_acelp_preq )
+ IF( !st->use_acelp_preq )
{
- st_fx->mem_preemp_preQ_fx = 0;
+ st->mem_preemp_preQ_fx = 0;
move16();
- st_fx->last_nq_preQ = 0;
+ st->last_nq_preQ = 0;
+ move16();
+ st->last_code_preq = 0;
move16();
}
- st_fx->use_acelp_preq = 0;
+ st->use_acelp_preq = 0;
move16();
/*-----------------------------------------------------------------*
* LSF de-quantization and interpolation
*-----------------------------------------------------------------*/
- lsf_dec_fx( st_fx, tc_subfr_fx, Aq_fx, &LSF_Q_prediction, lsf_new_fx, lsp_new_fx, lsp_mid_fx, tdm_low_rate_mode,
- tdm_lsfQ_PCh );
+ IF( !tdm_lp_reuse_flag )
+ {
+ lsf_dec_fx( st, tc_subfr, Aq_fx, &LSF_Q_prediction, lsf_new_fx, lsp_new_fx, lsp_mid_fx, tdm_low_rate_mode, tdm_lsfQ_PCh_fx );
+ }
+ ELSE
+ {
+ const Word16 *pt_interp_2_fx;
+
+ IF( NE_16( st->active_cnt, 1 ) )
+ {
+ Word16 beta_index;
+
+ beta_index = get_next_indice_fx( st, TDM_IC_LSF_PRED_BITS );
+ tdm_SCh_lsf_reuse_fx( DEC, st->element_brate, lsf_new_fx, lsp_new_fx, tdm_lsfQ_PCh_fx, NULL, &beta_index );
+ }
+ ELSE
+ {
+ Copy( tdm_lspQ_PCh_fx, lsp_new_fx, M );
+ Copy( tdm_lsfQ_PCh_fx, lsf_new_fx, M );
+ }
+
+ IF( st->rate_switching_reset )
+ {
+ /* extrapolation in case of unstable LSF convert */
+ Copy( lsp_new_fx, st->lsp_old_fx, M );
+ Copy( lsf_new_fx, st->lsf_old_fx, M );
+ }
+
+ pt_interp_2_fx = interpol_frac_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_fx, st->lsp_old_fx, M );
+ lsp2lsf_fx( lsp_new_fx, st->lsf_old_fx, M, st->sr_core );
+ }
+
+ /* LSP interpolation and conversion of LSPs to A(z) */
+ int_lsp_fx( st->L_frame, st->lsp_old_fx, lsp_new_fx, Aq_fx, M, pt_interp_2_fx, 0 );
+
+ /* Check LSF stability (distance between old LSFs and current LSFs) */
+ st->stab_fac_fx = lsf_stab_ivas_fx( lsf_new_fx, st->lsf_old_fx, 0, st->L_frame );
+ move16();
+ }
+
+ test();
+ IF( EQ_16( st->last_core, HQ_CORE ) && st->element_mode > EVS_MONO )
+ {
+ /* Prepare ACB memory from last HQ frame */
+ old_exc_s_fx = st->old_exc_fx + sub( L_EXC_MEM_DEC, st->L_frame );
+ tmpF_fx = *old_exc_s_fx;
+ st->mem_deemph_fx = shl_sat( old_exc_s_fx[st->L_frame - 1], st->Q_syn ); /* Q0 -> Q_syn */
+ move16();
+ PREEMPH_FX( old_exc_s_fx, st->preemph_fac, L_FRAME16k, &tmpF_fx );
+ Copy( old_exc_s_fx + sub( st->L_frame, M ), st->mem_syn2_fx, M );
+ Scale_sig( st->mem_syn2_fx, M, st->Q_syn ); /* Q0 -> Q_syn */
+ Residu3_fx( Aq_fx, old_exc_s_fx, old_exc_fx + sub( L_EXC_MEM_DEC, st->L_frame ), st->L_frame, 0 );
+ Scale_sig( old_exc_fx + sub( L_EXC_MEM_DEC, st->L_frame ), st->L_frame, st->Q_exc ); /* Q0 -> Q_exc */
+ }
+
+ 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 << 1, L_EXC_MEM_DEC );
+ }
+ }
/*-----------------------------------------------------------------*
* FEC - first good frame after lost frame(s) (possibility to correct the ACB)
*-----------------------------------------------------------------*/
- IF( st_fx->acelp_cfg.FEC_mode > 0 )
+ IF( st->acelp_cfg.FEC_mode > 0 )
{
last_pulse_pos = 0;
move16();
/* decode the last glottal pulse position */
- T0_tmp = FEC_pos_dec_fx( st_fx, &last_pulse_pos, &enr_q_fx, nb_bits );
-
+ T0_tmp = FEC_pos_dec_fx( st, &last_pulse_pos, &enr_q_fx, nb_bits );
test();
test();
- IF( NE_16( st_fx->last_core, HQ_CORE ) || ( EQ_16( st_fx->last_core, HQ_CORE ) && st_fx->last_con_tcx ) )
+ IF( NE_16( st->last_core, HQ_CORE ) || ( EQ_16( st->last_core, HQ_CORE ) && st->last_con_tcx ) )
{
test();
test();
@@ -734,16 +1022,13 @@ ivas_error acelp_core_dec_fx(
test();
test();
test();
- test();
- IF( EQ_16( st_fx->clas_dec, SIN_ONSET ) && last_pulse_pos != 0 && EQ_16( st_fx->prev_bfi, 1 ) )
+ IF( EQ_16( st->clas_dec, SIN_ONSET ) && last_pulse_pos != 0 && EQ_16( st->prev_bfi, 1 ) )
{
- st_fx->Q_exc =
- FEC_SinOnset_fx( old_exc_fx + L_EXC_MEM_DEC - L_EXC_MEM, last_pulse_pos, T0_tmp, enr_q_fx, Aq_fx, st_fx->L_frame, st_fx->Q_exc );
- move16();
+ FEC_SinOnset_fx( old_exc_fx + L_EXC_MEM_DEC - L_EXC_MEM, last_pulse_pos, T0_tmp, enr_q_fx, Aq_fx, st->L_frame, st->Q_exc );
}
- ELSE IF( ( EQ_16( st_fx->coder_type, GENERIC ) || EQ_16( st_fx->coder_type, VOICED ) ) && last_pulse_pos != 0 && EQ_16( st_fx->old_bfi_cnt, 1 ) && EQ_16( output_frame, L_FRAME16k ) && st_fx->hWIDec != NULL )
+ ELSE IF( ( EQ_16( st->coder_type, GENERIC ) || EQ_16( st->coder_type, VOICED ) ) && last_pulse_pos != 0 && EQ_16( st->old_bfi_cnt, 1 ) && st->hWIDec != NULL )
{
- do_WI_fx = FEC_enhACB_fx( st_fx->L_frame, st_fx->last_L_frame, old_exc_fx + L_EXC_MEM_DEC - L_EXC_MEM, T0_tmp, last_pulse_pos, st_fx->bfi_pitch_fx );
+ do_WI = FEC_enhACB_fx( st->L_frame, st->last_L_frame, old_exc_fx + L_EXC_MEM_DEC - L_EXC_MEM, T0_tmp, last_pulse_pos, st->bfi_pitch_fx );
}
}
}
@@ -752,16 +1037,16 @@ ivas_error acelp_core_dec_fx(
* In case of first frame after an erasure and transition from voiced to unvoiced or inactive
* redo the LPC interpolation
*------------------------------------------------------------*/
+
test();
test();
test();
test();
test();
test();
- IF( st_fx->stab_fac_fx == 0 && st_fx->old_bfi_cnt > 0 && NE_16( st_fx->clas_dec, VOICED_CLAS ) && NE_16( st_fx->clas_dec, ONSET ) &&
- st_fx->relax_prev_lsf_interp == 0 && !( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) && EQ_16( st_fx->idchan, 1 ) ) )
+ IF( ( st->stab_fac_fx == 0 ) && ( st->old_bfi_cnt > 0 ) && NE_16( st->clas_dec, VOICED_CLAS ) && NE_16( st->clas_dec, ONSET ) && ( st->relax_prev_lsf_interp == 0 ) && !( EQ_16( st->element_mode, IVAS_CPE_TD ) && EQ_16( st->idchan, 1 ) ) )
{
- int_lsp4_fx( st_fx->L_frame, st_fx->lsp_old_fx, lsp_mid_fx, lsp_new_fx, Aq_fx, M, 2 );
+ int_lsp4_ivas_fx( st->L_frame, st->lsp_old_fx, lsp_mid_fx, lsp_new_fx, Aq_fx, M, 2 );
}
/*---------------------------------------------------------------*
@@ -770,7 +1055,7 @@ ivas_error acelp_core_dec_fx(
IF( nb_bits > 0 )
{
- indice = get_next_indice( st_fx, nb_bits );
+ indice = get_next_indice_fx( st, nb_bits );
Es_pred_dec_fx( &Es_pred_fx, indice, nb_bits, uc_two_stage_flag );
}
@@ -780,79 +1065,113 @@ ivas_error acelp_core_dec_fx(
test();
test();
- IF( EQ_16( st_fx->nelp_mode_dec, 1 ) )
+ IF( tdm_low_rate_mode ) /* tdm stereo low rate mode */
{
- /* SC-VBR - NELP frames */
- Scale_sig( exc_fx - L_EXC_MEM, L_EXC_MEM, negate( st_fx->Q_exc ) ); // Q0
- st_fx->Q_exc = 0;
+ IF( LE_16( st->coder_type, UNVOICED ) )
+ {
+ tdm_low_rate_dec_fx( st, dct_exc_tmp_fx /*, &tmp_noise*/, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, lsf_new_fx );
+ tmp_noise_fx = shr_r( st->lp_gainc_fx, 3 ); /*Q0*/
+ }
+ ELSE /* GENERIC */
+ {
+ decod_gen_2sbfr_fx( st, sharpFlag, Aq_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, gain_buf_fx, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf_fx );
+
+ IF( EQ_16( st->element_mode, IVAS_CPE_TD ) )
+ {
+ tmp_noise_fx = shr_r( st->lp_gainc_fx, 3 ); /*Q0*/
+ }
+ }
+ }
+ ELSE IF( st->nelp_mode_dec )
+ {
+ Scale_sig( exc_fx - L_EXC_MEM, L_EXC_MEM, negate( st->Q_exc ) ); // Q0
+ st->Q_exc = 0;
move16();
- decod_nelp_fx( st_fx, &tmp_noise_fx, pitch_buf_fx, exc_fx, exc2_fx, voice_factors, bwe_exc_fx, &st_fx->Q_exc, st_fx->bfi, gain_buf );
- Rescale_exc( hMusicPF->dct_post_old_exc_fx, exc_fx, NULL, st_fx->hGSCDec->last_exc_dct_in_fx, L_FRAME, 0, (Word32) 0, &( st_fx->Q_exc ), st_fx->Q_subfr, exc2_fx, L_FRAME, st_fx->coder_type );
+ /* SC-VBR - NELP frames */
+ decod_nelp_fx( st, &tmp_noise_fx, pitch_buf_fx, exc_fx, exc2_fx, voice_factors_fx, bwe_exc_fx, &st->Q_exc, st->bfi, gain_buf_fx );
+
+ Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, exc_fx, NULL, st->hGSCDec->last_exc_dct_in_fx, L_FRAME, 0, (Word32) 0, &( st->Q_exc ), st->Q_subfr, exc2_fx, L_FRAME, st->coder_type );
}
- ELSE IF( EQ_16( st_fx->coder_type, UNVOICED ) )
+ ELSE IF( EQ_16( st->coder_type, UNVOICED ) )
{
/* UNVOICED frames */
- decod_unvoiced_fx( st_fx, Aq_fx, st_fx->coder_type, &tmp_noise_fx, pitch_buf_fx, voice_factors, exc_fx, exc2_fx, bwe_exc_fx, gain_buf );
+ decod_unvoiced_fx( st, Aq_fx, Es_pred_fx, uc_two_stage_flag, st->coder_type, &tmp_noise_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, gain_buf_fx );
+
+ tmp_noise_fx = shr_r( st->lp_gainc_fx, 3 ); /*Q0*/
}
- ELSE IF( EQ_16( st_fx->ppp_mode_dec, 1 ) )
+ ELSE IF( st->ppp_mode_dec )
{
- Scale_sig( exc_fx - L_EXC_MEM, L_EXC_MEM, negate( st_fx->Q_exc ) ); // Q0
- st_fx->Q_exc = 0;
+ Scale_sig( exc_fx - L_EXC_MEM, L_EXC_MEM, negate( st->Q_exc ) ); // Q0
+ st->Q_exc = 0;
move16();
+
/* SC-VBR - PPP frames */
- IF( NE_32( ( error = decod_ppp_fx( st_fx, Aq_fx, pitch_buf_fx, exc_fx, exc2_fx, st_fx->bfi, gain_buf, voice_factors, bwe_exc_fx ) ), IVAS_ERR_OK ) )
+ IF( NE_32( ( error = decod_ppp_fx( st, Aq_fx, pitch_buf_fx, exc_fx, exc2_fx, st->bfi, gain_buf_fx, voice_factors_fx, bwe_exc_fx ) ), IVAS_ERR_OK ) )
{
return error;
}
- Rescale_exc( hMusicPF->dct_post_old_exc_fx, exc_fx, NULL, st_fx->hGSCDec->last_exc_dct_in_fx, L_FRAME, 0, (Word32) 0, &( st_fx->Q_exc ), st_fx->Q_subfr, exc2_fx, L_FRAME, st_fx->coder_type );
+ Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, exc_fx, NULL, st->hGSCDec->last_exc_dct_in_fx, L_FRAME, 0, (Word32) 0, &( st->Q_exc ), st->Q_subfr, exc2_fx, L_FRAME, st->coder_type );
}
- ELSE IF( EQ_16( st_fx->coder_type, TRANSITION ) )
+ ELSE IF( EQ_16( st->coder_type, TRANSITION ) )
{
- decod_tran_fx( st_fx, st_fx->L_frame, tc_subfr_fx, Aq_fx, Es_pred_fx, pitch_buf_fx, voice_factors, exc_fx, exc2_fx, bwe_exc_fx, unbits, sharpFlag, gain_buf );
+ decod_tran_fx( st, st->L_frame, tc_subfr, Aq_fx, Es_pred_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, unbits, sharpFlag, gain_buf_fx );
}
- ELSE IF( EQ_16( st_fx->coder_type, AUDIO ) || ( ( st_fx->coder_type == INACTIVE ) && LE_32( st_fx->core_brate, MAX_GSC_INACTIVE_BRATE ) ) )
+ ELSE IF( EQ_16( st->coder_type, AUDIO ) || ( ( st->coder_type == INACTIVE ) && st->inactive_coder_type_flag ) )
{
- decod_audio_fx( st_fx, dct_exc_tmp, Aq_fx, pitch_buf_fx, voice_factors, exc_fx, exc2_fx, bwe_exc_fx, lsf_new_fx, gain_buf );
- tmp_noise_fx = shr_r( st_fx->lp_gainc_fx, 3 ); /*Q0*/
+ /* AUDIO and INACTIVE frames (coded by GSC technology) */
+ decod_audio_fx( st, dct_exc_tmp_fx, Aq_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, lsf_new_fx, gain_buf_fx,
+ tdm_lp_reuse_flag, tdm_low_rate_mode, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf_fx );
+
+ tmp_noise_fx = shr_r( st->lp_gainc_fx, 3 ); /*Q0*/
}
ELSE
{
- IF( NE_32( ( error = decod_gen_voic_fx( st_fx, st_fx->L_frame, sharpFlag, Aq_fx, Es_pred_fx, do_WI_fx, pitch_buf_fx, voice_factors, exc_fx, exc2_fx, bwe_exc_fx, unbits, gain_buf /*, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf*/ ) ), IVAS_ERR_OK ) )
+ /* GENERIC, VOICED and INACTIVE frames (coded by AVQ technology) */
+ IF( NE_32( ( error = decod_gen_voic_fx( st, st->L_frame, sharpFlag, Aq_fx, Es_pred_fx, do_WI, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, unbits, gain_buf_fx, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf_fx ) ), IVAS_ERR_OK ) )
{
return error;
}
- IF( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) )
+ IF( EQ_16( st->element_mode, IVAS_CPE_TD ) )
{
- tmp_noise_fx = shr_r( st_fx->lp_gainc_fx, 3 ); /*Q0*/
+ tmp_noise_fx = shr_r( st->lp_gainc_fx, 3 ); /*Q0*/
}
}
/* synthesis for ACELP core switching and SWB BWE */
- syn_12k8_fx( st_fx->L_frame, Aq_fx, exc_fx, temp_buf_fx, st_fx->mem_syn1_fx, 1, st_fx->Q_exc, -1 );
+ syn_12k8_fx( st->L_frame, Aq_fx, exc_fx, temp_buf_fx, st->mem_syn1_fx, 1, st->Q_exc, -1 );
+
/* save and delay synthesis to be used by SWB BWE */
- IF( hBWE_FD != NULL )
+ IF( st->hBWE_FD != NULL )
{
- save_old_syn_fx( st_fx->L_frame, temp_buf_fx, old_syn_12k8_16k, hBWE_FD->old_syn_12k8_16k_fx, st_fx->preemph_fac, &hBWE_FD->mem_deemph_old_syn_fx );
+ save_old_syn_fx( st->L_frame, temp_buf_fx, old_syn_12k8_16k_fx, st->hBWE_FD->old_syn_12k8_16k_fx, st->preemph_fac, &st->hBWE_FD->mem_deemph_old_syn_fx );
}
/*-----------------------------------------------------------------*
* Apply energy matching when switching to inactive frames
*-----------------------------------------------------------------*/
- Inac_swtch_ematch_fx( exc2_fx, dct_exc_tmp, st_fx->hGSCDec->lt_ener_per_band_fx, st_fx->coder_type, st_fx->L_frame, st_fx->core_brate, st_fx->Q_exc, st_fx->bfi, st_fx->last_core, st_fx->last_codec_mode );
+ Inac_switch_ematch_fx( exc2_fx, dct_exc_tmp_fx, st->hGSCDec->lt_ener_per_band_fx, st->coder_type, st->inactive_coder_type_flag, st->L_frame, st->Q_exc, st->bfi, st->last_core, st->last_codec_mode, tdm_low_rate_mode, st->element_mode );
+
/*------------------------------------------------------------*
* Decode information and modify the excitation signal of stationary unvoiced frames
*------------------------------------------------------------*/
+
test();
test();
test();
test();
- IF( !( EQ_16( st_fx->idchan, 1 ) && EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) && NE_16( st_fx->nelp_mode_dec, 1 ) && !( EQ_16( st_fx->element_mode, IVAS_SCE ) && tdm_low_rate_mode ) )
+ IF( !( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) ) && NE_16( st->nelp_mode_dec, 1 ) && !( EQ_16( st->element_mode, IVAS_SCE ) && tdm_low_rate_mode ) )
{
- stat_noise_uv_dec_fx( st_fx, lsp_new_fx, lsp_mid_fx, Aq_fx, exc2_fx, uc_two_stage_flag );
+ Word16 temp_q_exc = st->Q_exc;
+ move16();
+ stat_noise_uv_dec_fx( st, lsp_new_fx, lsp_mid_fx, Aq_fx, exc2_fx, uc_two_stage_flag );
+ IF( NE_16( temp_q_exc, st->Q_exc ) )
+ {
+ scale_sig( exc_fx - L_EXC_MEM, L_EXC_MEM + st->L_frame, sub( st->Q_exc, temp_q_exc ) );
+ }
}
/*------------------------------------------------------------*
@@ -861,80 +1180,92 @@ ivas_error acelp_core_dec_fx(
*------------------------------------------------------------*/
/* update past excitation signals for LD music post-filter */
- IF( hMusicPF != NULL )
+ IF( st->hMusicPF != NULL )
{
- Copy( hMusicPF->dct_post_old_exc_fx + L_FRAME, hMusicPF->dct_post_old_exc_fx, DCT_L_POST - L_FRAME - OFFSET2 );
- Copy( exc2_fx, hMusicPF->dct_post_old_exc_fx + ( DCT_L_POST - L_FRAME - OFFSET2 ), L_FRAME );
- Copy( hMusicPF->dct_post_old_exc_fx, exc_buffer_fx, DCT_L_POST - OFFSET2 );
+ Copy( st->hMusicPF->dct_post_old_exc_fx + L_FRAME, st->hMusicPF->dct_post_old_exc_fx, DCT_L_POST - L_FRAME - OFFSET2 );
+ Copy( exc2_fx, st->hMusicPF->dct_post_old_exc_fx + ( DCT_L_POST - L_FRAME - OFFSET2 ), L_FRAME );
+ Copy( st->hMusicPF->dct_post_old_exc_fx, exc_buffer_fx, DCT_L_POST - OFFSET2 );
}
+
test();
test();
test();
- test();
- IF( hMusicPF != NULL && ( ( EQ_16( st_fx->coder_type, AUDIO ) && st_fx->GSC_noisy_speech == 0 ) || ( GE_16( st_fx->GSC_IVAS_mode, 1 ) && EQ_16( st_fx->L_frame, L_FRAME ) ) ) )
+ IF( ( EQ_16( st->coder_type, AUDIO ) && !st->GSC_noisy_speech ) || ( GE_16( st->GSC_IVAS_mode, 1 ) && EQ_16( st->L_frame, L_FRAME ) ) )
{
-
- Word16 last_coder_type = st_fx->last_coder_type;
+ Word16 last_coder_type = st->last_coder_type;
move16();
+
test();
test();
test();
- if ( ( EQ_16( st_fx->idchan, 1 ) && EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) || ( GE_16( st_fx->GSC_IVAS_mode, 1 ) && st_fx->GSC_noisy_speech == 0 ) )
+ if ( ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) ) || ( GE_16( st->GSC_IVAS_mode, 1 ) && ( st->GSC_noisy_speech == 0 ) ) )
{
last_coder_type = AUDIO;
move16();
}
- /* Extrapolation of the last future part, windowing and high resolution DCT transform */
- qdct = 0;
+
+ Word16 qdct = 0;
move16();
-#ifdef _DIFF_FLOAT_FIX_ /* FLoat point using last_core which fits with the inner part of the function */
- Prep_music_postP_fx( exc_buffer_fx, dct_buffer_fx, hMusicPF->filt_lfE_fx, st_fx->last_core, st_fx->element_mode, pitch_buf_fx,
- hMusicPF->LDm_enh_lp_gbin_fx, st_fx->Q_exc, &qdct );
-#else
- Prep_music_postP_fx( exc_buffer_fx, dct_buffer_fx, hMusicPF->filt_lfE_fx, st_fx->last_coder_type, st_fx->element_mode, pitch_buf_fx,
- hMusicPF->LDm_enh_lp_gbin_fx, st_fx->Q_exc, &qdct );
-#endif
+
+ /* Extrapolation of the last future part, windowing and high resolution DCT transform */
+ IF( EQ_16( st->element_mode, EVS_MONO ) )
+ {
+ // VE: TBV: this is likely a bug in EVS - 'st->last_coder_type' should be replaced by 'st->core_brate'
+ Prep_music_postP_fx( exc_buffer_fx, dct_buffer_fx, st->hMusicPF->filt_lfE_fx, st->last_coder_type, st->element_mode, pitch_buf_fx,
+ st->hMusicPF->LDm_enh_lp_gbin_fx, st->Q_exc, &qdct );
+ }
+ ELSE
+ {
+ Prep_music_postP_fx( exc_buffer_fx, dct_buffer_fx, st->hMusicPF->filt_lfE_fx, st->last_core, st->element_mode, pitch_buf_fx, st->hMusicPF->LDm_enh_lp_gbin_fx, st->Q_exc, &qdct );
+ }
+
/* LD music post-filter */
- LD_music_post_filter_fx( hMusicPF, dct_buffer_fx, dct_buffer_fx, st_fx->core_brate,
- &hMusicPF->Old_ener_Q, AUDIO, last_coder_type, qdct );
+ LD_music_post_filter_fx( st->hMusicPF, dct_buffer_fx, dct_buffer_fx, st->core_brate, &st->hMusicPF->Old_ener_Q, AUDIO, last_coder_type, qdct );
/* Inverse DCT transform, retrieval of the aligned excitation, re-synthesis */
- Post_music_postP_fx( dct_buffer_fx, exc2_fx, st_fx->mem_syn2_fx, st_fx->mem_syn2_fx, Aq_fx, syn_fx, &st_fx->Q_exc, &st_fx->prev_Q_syn,
- &st_fx->Q_syn, st_fx->mem_syn_clas_estim_fx, 0, &st_fx->mem_deemph_fx, hBPF->pst_old_syn_fx,
- &hBPF->pst_mem_deemp_err_fx, &st_fx->agc_mem_fx[1], st_fx->hPFstat, temp_buf_fx, mem_tmp_fx );
+ IF( NE_16( st->element_mode, EVS_MONO ) ) // VE: TBC whether needed in IVAS
+ {
+ Copy( st->mem_syn2_fx, mem_tmp_fx, M ); /*Q_syn*/
+ }
+
+ Post_music_postP_fx( dct_buffer_fx, exc2_fx, st->mem_syn2_fx, st->mem_syn2_fx, Aq_fx, psyn_fx, &st->Q_exc, &st->prev_Q_syn,
+ &st->Q_syn, st->mem_syn_clas_estim_fx, 0, &st->mem_deemph_fx, st->hBPF->pst_old_syn_fx,
+ &st->hBPF->pst_mem_deemp_err_fx, &st->agc_mem_fx[1], st->hPFstat, temp_buf_fx, mem_tmp_fx );
}
ELSE
{
/* Core synthesis at 12.8kHz or 16kHz */
i = 1;
move16();
- if ( st_fx->coder_type == INACTIVE )
+ test();
+ if ( st->coder_type == INACTIVE && st->element_mode == EVS_MONO )
{
i = 0;
move16();
}
+
/* add extra headroom in case a CNA addition is likely (i.e. st_fx->psf_lp_noise_fx is close to the threshold) */
- k = 0;
+ Word16 k = 0;
move16();
test();
test();
- if ( ( st_fx->coder_type == INACTIVE ) && st_fx->flag_cna && GE_16( round_fx( L_shl( st_fx->lp_noise, 1 ) ), 15 << 7 ) )
+ if ( st->coder_type == INACTIVE && st->flag_cna && GE_16( round_fx( L_shl( st->lp_noise, 1 ) ), 15 << 7 ) )
{
k = 1;
move16();
}
- Rescale_mem( st_fx->Q_exc, &st_fx->prev_Q_syn, &st_fx->Q_syn, st_fx->mem_syn2_fx, st_fx->mem_syn_clas_estim_fx, 4, &st_fx->mem_deemph_fx,
- hBPF->pst_old_syn_fx, &hBPF->pst_mem_deemp_err_fx, &st_fx->agc_mem_fx[1], st_fx->hPFstat, i, k, temp_buf_fx );
- Copy( st_fx->mem_syn2_fx, mem_tmp_fx, M ); // Q_syn
+ Rescale_mem( st->Q_exc, &st->prev_Q_syn, &st->Q_syn, st->mem_syn2_fx, st->mem_syn_clas_estim_fx, 4, &st->mem_deemph_fx,
+ st->hBPF->pst_old_syn_fx, &st->hBPF->pst_mem_deemp_err_fx, &st->agc_mem_fx[1], st->hPFstat, i, k, temp_buf_fx );
+
+ Copy( st->mem_syn2_fx, mem_tmp_fx, M ); /*Q_syn*/
+ syn_12k8_fx( st->L_frame, Aq_fx, exc2_fx, psyn_fx, st->mem_syn2_fx, 1, st->Q_exc, st->Q_syn );
- syn_12k8_fx( st_fx->L_frame, Aq_fx, exc2_fx, syn_fx, st_fx->mem_syn2_fx, 1, st_fx->Q_exc, st_fx->Q_syn );
- IF( hMusicPF != NULL )
+ IF( st->hMusicPF != NULL )
{
FOR( i = 0; i < DCT_L_POST; i++ )
{
- /*st_fx->filt_lfE_fx[i] = 0.3f + 0.7f * st_fx->filt_lfE_fx[i];*/
- hMusicPF->filt_lfE_fx[i] = round_fx( L_mac( ( 1228 << ( 16 ) ), 22938, hMusicPF->filt_lfE_fx[i] ) );
+ st->hMusicPF->filt_lfE_fx[i] = round_fx( L_mac( ( 1228 << ( 16 ) ), 22938, st->hMusicPF->filt_lfE_fx[i] ) );
move16();
}
}
@@ -944,43 +1275,35 @@ ivas_error acelp_core_dec_fx(
* FEC - Estimate the classification information
*------------------------------------------------------------*/
- FEC_clas_estim_fx( st_fx, st_fx->Opt_AMR_WB, st_fx->L_frame, &st_fx->clas_dec, st_fx->coder_type, pitch_buf_fx,
- syn_fx, &st_fx->lp_ener_FER_fx, &st_fx->decision_hyst,
- NULL, NULL, NULL, NULL, 0, NULL, st_fx->Q_syn, temp_buf_fx,
- st_fx->mem_syn_clas_estim_fx, &st_fx->classifier_Q_mem_syn,
- 0, 0, 0, st_fx->last_core_brate, st_fx->acelp_cfg.FEC_mode );
+ FEC_clas_estim_fx( st, st->Opt_AMR_WB, st->L_frame, &st->clas_dec, st->coder_type, pitch_buf_fx, psyn_fx, &st->lp_ener_FER_fx, &st->decision_hyst,
+ NULL, NULL, NULL, NULL, 0, NULL, st->Q_syn, temp_buf_fx, st->mem_syn_clas_estim_fx, &st->classifier_Q_mem_syn, 0, 0, 0, st->last_core_brate, st->acelp_cfg.FEC_mode );
+
/*------------------------------------------------------------*
* FEC - Estimate pitch
*------------------------------------------------------------*/
- FEC_pitch_estim_fx( st_fx->Opt_AMR_WB, st_fx->last_core, st_fx->L_frame, st_fx->clas_dec, st_fx->last_good, pitch_buf_fx, st_fx->old_pitch_buf_fx,
- &st_fx->bfi_pitch_fx, &st_fx->bfi_pitch_frame, &st_fx->upd_cnt, st_fx->coder_type, st_fx->element_mode );
+ FEC_pitch_estim_fx( st->Opt_AMR_WB, st->last_core, st->L_frame, st->clas_dec, st->last_good, pitch_buf_fx, st->old_pitch_buf_fx,
+ &st->bfi_pitch_fx, &st->bfi_pitch_frame, &st->upd_cnt, st->coder_type, st->element_mode );
/*------------------------------------------------------------*
* FEC - Smooth the speech energy evolution when recovering after a BAD frame
* (smoothing is performed in the excitation domain and signal is resynthesized after)
*------------------------------------------------------------*/
- k = 0;
- move16();
- FOR( i = 0; i < st_fx->L_frame; i += L_SUBFR )
- {
- pitch_buf_tmp[k] = mult_r( pitch_buf_fx[k], 512 ); // Q0(6+9-15) , (512 = 1.0f in Q9)
- move16();
- k = add( k, 1 );
- }
+ Copy_Scale_sig( pitch_buf_fx, pitch_buf_tmp, st->nb_subfr, -Q6 ); // Q0
- FEC_scale_syn_fx( st_fx->L_frame, &update_flg, st_fx->clas_dec, st_fx->last_good, syn_fx, pitch_buf_tmp, st_fx->enr_old_fx, enr_q_fx, st_fx->coder_type, LSF_Q_prediction,
- &st_fx->scaling_flag, &st_fx->lp_ener_FEC_av, &st_fx->lp_ener_FEC_max, st_fx->bfi, st_fx->total_brate, st_fx->prev_bfi, st_fx->last_core_brate,
- exc_fx, exc2_fx, Aq_fx, &st_fx->old_enr_LP, mem_tmp_fx, st_fx->mem_syn2_fx, st_fx->Q_exc, st_fx->Q_syn, avoid_lpc_burst_on_recovery, 0 );
+ FEC_scale_syn_fx( st->L_frame, &update_flg, st->clas_dec, st->last_good, psyn_fx, pitch_buf_tmp, st->enr_old_fx, enr_q_fx, st->coder_type, LSF_Q_prediction,
+ &st->scaling_flag, &st->lp_ener_FEC_av, &st->lp_ener_FEC_max, st->bfi, st->total_brate, st->prev_bfi, st->last_core_brate,
+ exc_fx, exc2_fx, Aq_fx, &st->old_enr_LP, mem_tmp_fx, st->mem_syn2_fx, st->Q_exc, st->Q_syn, st->element_mode, avoid_lpc_burst_on_recovery, 0 );
test();
test();
test();
test();
- IF( ( EQ_16( st_fx->idchan, 1 ) && EQ_16( st_fx->element_mode, IVAS_CPE_TD ) && LE_32( st_fx->total_brate, ACELP_7k20 ) ) || ( EQ_32( st_fx->total_brate, ACELP_7k20 ) ) || ( EQ_32( st_fx->total_brate, ACELP_8k00 ) ) )
+ /* estimate the pitch-synchronous speech energy per sample to be used when normal operation recovers */
+ IF( ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) && LE_32( st->total_brate, ACELP_7k20 ) ) || EQ_32( st->total_brate, ACELP_7k20 ) || EQ_32( st->total_brate, ACELP_8k00 ) )
{
- frame_ener_fx( st_fx->L_frame, st_fx->clas_dec, syn_fx, pitch_buf_tmp[sub( shr( st_fx->L_frame, 6 ), 1 )], &st_fx->enr_old_fx, st_fx->L_frame, st_fx->Q_syn, 3, 0 );
+ frame_ener_fx( st->L_frame, st->clas_dec, psyn_fx, pitch_buf_tmp[( ( st->L_frame ) >> 6 ) - 1], &st->enr_old_fx, st->L_frame, st->Q_syn, 3, 0 );
}
}
@@ -989,206 +1312,188 @@ ivas_error acelp_core_dec_fx(
/*----------------------------------------------------------------*
* BAD frame
*----------------------------------------------------------------*/
+
ELSE
{
/* SC-VBR */
- if ( EQ_16( st_fx->last_nelp_mode_dec, 1 ) )
+ if ( EQ_16( st->last_nelp_mode_dec, 1 ) )
{
- st_fx->nelp_mode_dec = 1;
+ st->nelp_mode_dec = 1;
move16();
}
- /* long burst frame erasures */
test();
test();
- if ( GT_16( st_fx->nbLostCmpt, 5 ) && GE_16( st_fx->clas_dec, VOICED_CLAS ) && LT_16( st_fx->clas_dec, INACTIVE_CLAS ) )
+ /* long burst frame erasures */
+ if ( GT_16( st->nbLostCmpt, 5 ) && GE_16( st->clas_dec, VOICED_CLAS ) && LT_16( st->clas_dec, INACTIVE_CLAS ) )
{
- st_fx->last_good = VOICED_TRANSITION;
+ st->last_good = VOICED_TRANSITION;
move16();
}
/* LSF estimation and A(z) calculation */
- lsf_dec_bfi( MODE1, lsf_new_fx, st_fx->lsf_old_fx, st_fx->lsf_adaptive_mean_fx, NULL, st_fx->mem_MA_fx, st_fx->mem_AR_fx,
- st_fx->stab_fac_fx, st_fx->last_coder_type, st_fx->L_frame, st_fx->last_good,
- st_fx->nbLostCmpt, 0, NULL, NULL, NULL, st_fx->hGSCDec->Last_GSC_pit_band_idx, st_fx->Opt_AMR_WB, 0, st_fx->bwidth );
-
- FEC_lsf2lsp_interp( st_fx, st_fx->L_frame, Aq_fx, lsf_new_fx, lsp_new_fx );
+ lsf_dec_bfi( MODE1, lsf_new_fx, st->lsf_old_fx, st->lsf_adaptive_mean_fx, NULL, st->mem_MA_fx, st->mem_AR_fx, st->stab_fac_fx, st->last_coder_type, st->L_frame, st->last_good, st->nbLostCmpt, 0, NULL, NULL, NULL, st->hGSCDec->Last_GSC_pit_band_idx, st->Opt_AMR_WB, 0, st->bwidth );
- IF( EQ_16( st_fx->nelp_mode_dec, 1 ) )
+ FEC_lsf2lsp_interp( st, st->L_frame, Aq_fx, lsf_new_fx, lsp_new_fx );
+ IF( EQ_16( st->nelp_mode_dec, 1 ) )
{
/* SC-VBR */
- Scale_sig( exc_fx - L_EXC_MEM, L_EXC_MEM, negate( st_fx->Q_exc ) ); // Q0
- st_fx->Q_exc = 0;
+ Scale_sig( exc_fx - L_EXC_MEM, L_EXC_MEM, negate( st->Q_exc ) ); // Q0
+ st->Q_exc = 0;
move16();
- decod_nelp_fx( st_fx, &tmp_noise_fx, pitch_buf_fx, exc_fx, exc2_fx, voice_factors, bwe_exc_fx, &st_fx->Q_exc, st_fx->bfi, gain_buf );
+ decod_nelp_fx( st, &tmp_noise_fx, pitch_buf_fx, exc_fx, exc2_fx, voice_factors_fx, bwe_exc_fx, &st->Q_exc, st->bfi, gain_buf_fx );
FEC_pitch_fx = pitch_buf_fx[3];
move16();
-
- Rescale_exc( hMusicPF->dct_post_old_exc_fx, exc_fx, NULL, st_fx->hGSCDec->last_exc_dct_in_fx, L_FRAME, 0, (Word32) 0, &( st_fx->Q_exc ), st_fx->Q_subfr, exc2_fx, L_FRAME, st_fx->coder_type );
+ Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, exc_fx, NULL, st->hGSCDec->last_exc_dct_in_fx, L_FRAME, 0, (Word32) 0, &( st->Q_exc ), st->Q_subfr, exc2_fx, L_FRAME, st->coder_type );
}
ELSE
{
/* calculation of excitation signal */
+ FEC_exc_estim_fx( st, st->L_frame, exc_fx, exc2_fx, dct_exc_tmp_fx, pitch_buf_fx, voice_factors_fx, &FEC_pitch_fx, bwe_exc_fx, lsf_new_fx, &st->Q_exc, &tmp_noise_fx );
- FEC_exc_estim_fx( st_fx, st_fx->L_frame, exc_fx, exc2_fx, dct_exc_tmp, pitch_buf_fx, voice_factors, &FEC_pitch_fx, bwe_exc_fx, lsf_new_fx, &st_fx->Q_exc, &tmp_noise_fx );
-
- Rescale_exc( NULL, exc_fx, bwe_exc_fx, st_fx->hGSCDec->last_exc_dct_in_fx, st_fx->L_frame, L_FRAME32k, (Word32) 0,
- &( st_fx->Q_exc ), st_fx->Q_subfr, exc2_fx, st_fx->L_frame, st_fx->last_coder_type );
+ Rescale_exc( NULL, exc_fx, bwe_exc_fx, st->hGSCDec->last_exc_dct_in_fx, st->L_frame, L_FRAME32k, (Word32) 0,
+ &( st->Q_exc ), st->Q_subfr, exc2_fx, st->L_frame, st->last_coder_type );
- tmp_noise_fx = shr_r( st_fx->lp_gainc_fx, 3 ); /*Q0*/
+ tmp_noise_fx = shr_r( st->lp_gainc_fx, 3 ); /*Q0*/
/* SC-VBR */
- st_fx->prev_gain_pit_dec_fx = st_fx->lp_gainp_fx;
- move16(); /*Q14*/
+ st->prev_gain_pit_dec_fx = st->lp_gainp_fx;
+ move16();
}
/* synthesis for ACELP core switching and SWB BWE */
- syn_12k8_fx( st_fx->L_frame, Aq_fx, exc_fx, temp_buf_fx, st_fx->mem_syn1_fx, 1, st_fx->Q_exc, -1 ); /*old_syn_12k8_16k directly in q-1*/
+ syn_12k8_fx( st->L_frame, Aq_fx, exc_fx, temp_buf_fx, st->mem_syn1_fx, 1, st->Q_exc, -1 );
/* save and delay synthesis to be used by SWB BWE */
- IF( hBWE_FD != NULL )
+ IF( st->hBWE_FD != NULL )
{
- save_old_syn_fx( st_fx->L_frame, temp_buf_fx, old_syn_12k8_16k, hBWE_FD->old_syn_12k8_16k_fx, st_fx->preemph_fac, &hBWE_FD->mem_deemph_old_syn_fx );
+ save_old_syn_fx( st->L_frame, temp_buf_fx, old_syn_12k8_16k_fx, st->hBWE_FD->old_syn_12k8_16k_fx, st->preemph_fac, &st->hBWE_FD->mem_deemph_old_syn_fx );
}
+
/* Apply energy matching when switching to inactive frames */
- Inac_swtch_ematch_fx( exc2_fx, dct_exc_tmp, st_fx->hGSCDec->lt_ener_per_band_fx, st_fx->coder_type, st_fx->L_frame, st_fx->core_brate, st_fx->Q_exc, st_fx->bfi, st_fx->last_core, st_fx->last_codec_mode );
+ Inac_switch_ematch_fx( exc2_fx, dct_exc_tmp_fx, st->hGSCDec->lt_ener_per_band_fx, st->coder_type, st->inactive_coder_type_flag, st->L_frame, st->Q_exc, st->bfi, st->last_core, st->last_codec_mode, tdm_low_rate_mode, st->element_mode );
- /* udate past excitation signals for LD music post-filter */
- IF( hMusicPF != NULL )
+ /* update past excitation signals for LD music post-filter */
+ IF( st->hMusicPF != NULL )
{
- Copy( hMusicPF->dct_post_old_exc_fx + L_FRAME, hMusicPF->dct_post_old_exc_fx, DCT_L_POST - L_FRAME - OFFSET2 );
- Copy( exc2_fx, hMusicPF->dct_post_old_exc_fx + ( DCT_L_POST - L_FRAME - OFFSET2 ), L_FRAME );
+ Copy( st->hMusicPF->dct_post_old_exc_fx + L_FRAME, st->hMusicPF->dct_post_old_exc_fx, DCT_L_POST - L_FRAME - OFFSET2 );
+ Copy( exc2_fx, st->hMusicPF->dct_post_old_exc_fx + ( DCT_L_POST - L_FRAME - OFFSET2 ), L_FRAME );
+
/* Update music post processing values */
/* Filter energies update */
FOR( i = 0; i < DCT_L_POST; i++ )
{
- /*st_fx->filt_lfE_fx[i] = 0.3f + 0.7f * st_fx->filt_lfE_fx[i];*/
- hMusicPF->filt_lfE_fx[i] = round_fx( L_mac( ( 1228 << ( 16 ) ), 22938, hMusicPF->filt_lfE_fx[i] ) );
+ st->hMusicPF->filt_lfE_fx[i] = round_fx( L_mac( 1228 << 16, 22938, st->hMusicPF->filt_lfE_fx[i] ) );
move16();
}
+
/* Update circular buffer, keep last energy difference unchanged */
FOR( i = 1; i < MAX_LT; i++ )
{
- hMusicPF->LDm_lt_diff_etot_fx[i - 1] = hMusicPF->LDm_lt_diff_etot_fx[i];
+ st->hMusicPF->LDm_lt_diff_etot_fx[i - 1] = st->hMusicPF->LDm_lt_diff_etot_fx[i];
move16();
}
}
+
/* synthesis at 12k8 Hz sampling rate */
/* add extra headroom in case a CNA addition is likely (i.e. st_fx->psf_lp_noise_fx is close to the threshold) */
- k = 0;
+ Word16 k = 0;
move16();
test();
test();
- if ( ( st_fx->coder_type == INACTIVE ) && st_fx->flag_cna && GE_16( round_fx( L_shl( st_fx->lp_noise, 1 ) ), 15 << 7 ) )
+ if ( st->coder_type == INACTIVE && st->flag_cna && GE_16( round_fx( L_shl( st->lp_noise, 1 ) ), 15 << 7 ) )
{
k = 1;
move16();
}
- Rescale_mem( st_fx->Q_exc, &st_fx->prev_Q_syn, &st_fx->Q_syn, st_fx->mem_syn2_fx, st_fx->mem_syn_clas_estim_fx, 4, &st_fx->mem_deemph_fx,
- hBPF->pst_old_syn_fx, &hBPF->pst_mem_deemp_err_fx, &st_fx->agc_mem_fx[1], st_fx->hPFstat, 1, k, temp_buf_fx );
+ Rescale_mem( st->Q_exc, &st->prev_Q_syn, &st->Q_syn, st->mem_syn2_fx, st->mem_syn_clas_estim_fx, 4, &st->mem_deemph_fx,
+ st->hBPF->pst_old_syn_fx, &st->hBPF->pst_mem_deemp_err_fx, &st->agc_mem_fx[1], st->hPFstat, 1, k, temp_buf_fx );
test();
- IF( ( EQ_32( st_fx->total_brate, ACELP_7k20 ) ) || ( EQ_32( st_fx->total_brate, ACELP_8k00 ) ) )
+ IF( EQ_32( st->total_brate, ACELP_7k20 ) || EQ_32( st->total_brate, ACELP_8k00 ) )
{
- Copy( st_fx->mem_syn2_fx, mem_tmp_fx, M ); // Q_syn
+ Copy( st->mem_syn2_fx, mem_tmp_fx, M );
}
- syn_12k8_fx( st_fx->L_frame, Aq_fx, exc2_fx, syn_fx, st_fx->mem_syn2_fx, 1, st_fx->Q_exc, st_fx->Q_syn );
+ syn_12k8_fx( st->L_frame, Aq_fx, exc2_fx, psyn_fx, st->mem_syn2_fx, 1, st->Q_exc, st->Q_syn );
/* update buffer for classifier */
- IF( st_fx->hWIDec != NULL )
+ IF( st->hWIDec != NULL )
{
- Copy( exc2_fx + st_fx->L_frame - L_EXC_MEM, st_fx->hWIDec->old_exc2_fx, L_EXC_MEM );
- Copy( syn_fx + st_fx->L_frame - L_EXC_MEM, st_fx->hWIDec->old_syn2_fx, L_EXC_MEM );
+ Copy( exc2_fx + sub( st->L_frame, L_EXC_MEM ), st->hWIDec->old_exc2_fx, L_EXC_MEM );
+ Copy( psyn_fx + sub( st->L_frame, L_EXC_MEM ), st->hWIDec->old_syn2_fx, L_EXC_MEM );
}
- st_fx->prev_Q_exc_fr = st_fx->Q_exc;
+ st->prev_Q_exc_fr = st->Q_exc;
move16();
- st_fx->prev_Q_syn_fr = st_fx->Q_syn;
+ st->prev_Q_syn_fr = st->Q_syn;
move16();
+ Copy( psyn_fx + sub( st->L_frame, L_SYN_MEM_CLAS_ESTIM ), st->mem_syn_clas_estim_fx, L_SYN_MEM_CLAS_ESTIM );
- Copy( syn_fx + st_fx->L_frame - L_SYN_MEM_CLAS_ESTIM, st_fx->mem_syn_clas_estim_fx, L_SYN_MEM_CLAS_ESTIM );
+ /*------------------------------------------------------------*
+ * FEC - Smooth the speech energy evolution when recovering after a BAD frame
+ * (smoothing is performed in the excitation domain and signal is resynthesized after)
+ *------------------------------------------------------------*/
test();
- IF( ( EQ_32( st_fx->total_brate, ACELP_7k20 ) ) || ( EQ_32( st_fx->total_brate, ACELP_8k00 ) ) )
+ IF( EQ_32( st->total_brate, ACELP_7k20 ) || EQ_32( st->total_brate, ACELP_8k00 ) )
{
- k = 0;
- move16();
- FOR( i = 0; i < st_fx->L_frame; i += L_SUBFR )
- {
- pitch_buf_tmp[k] = mult_r( pitch_buf_fx[k], 512 ); // Q0(6+9-15) , (512 = 1.0f in Q9)
- move16();
- k = add( k, 1 );
- }
+ Copy_Scale_sig( pitch_buf_fx, pitch_buf_tmp, st->nb_subfr, -Q6 ); // Q0
- /*------------------------------------------------------------*
- * FEC - Smooth the speech energy evolution when recovering after a BAD frame
- * (smoothing is performed in the excitation domain and signal is resynthesized after)
- *------------------------------------------------------------*/
-
- FEC_scale_syn_fx( st_fx->L_frame, &update_flg, st_fx->clas_dec, st_fx->last_good, syn_fx, pitch_buf_tmp, st_fx->enr_old_fx, enr_q_fx, st_fx->coder_type, LSF_Q_prediction,
- &st_fx->scaling_flag, &st_fx->lp_ener_FEC_av, &st_fx->lp_ener_FEC_max, st_fx->bfi, st_fx->total_brate, st_fx->prev_bfi, st_fx->last_core_brate,
- exc_fx, exc2_fx, Aq_fx, &st_fx->old_enr_LP, mem_tmp_fx, st_fx->mem_syn2_fx, st_fx->Q_exc, st_fx->Q_syn, avoid_lpc_burst_on_recovery, 0 );
+ FEC_scale_syn_fx( st->L_frame, &update_flg, st->clas_dec, st->last_good, psyn_fx, pitch_buf_tmp, st->enr_old_fx, enr_q_fx, st->coder_type, LSF_Q_prediction,
+ &st->scaling_flag, &st->lp_ener_FEC_av, &st->lp_ener_FEC_max, st->bfi, st->total_brate, st->prev_bfi, st->last_core_brate,
+ exc_fx, exc2_fx, Aq_fx, &st->old_enr_LP, mem_tmp_fx, st->mem_syn2_fx, st->Q_exc, st->Q_syn, st->element_mode, avoid_lpc_burst_on_recovery, 0 );
}
/* estimate the pitch-synchronous speech energy per sample to be used when normal operation recovers */
- /* fer_energy( st_fx->L_frame, st_fx->last_good, syn_fx, FEC_pitch_fx, &st_fx->enr_old_fx, st_fx->L_frame ); */
- frame_ener_fx( st_fx->L_frame, st_fx->last_good, syn_fx, shr( add( FEC_pitch_fx, 32 ), 6 ), &st_fx->enr_old_fx, st_fx->L_frame, st_fx->Q_syn, 3, 0 );
+ frame_ener_fx( st->L_frame, st->last_good, psyn_fx, shr( add( FEC_pitch_fx, 32 ), 6 ), &st->enr_old_fx, st->L_frame, st->Q_syn, 3, 0 );
- IF( st_fx->nelp_mode_dec != 1 )
+ IF( NE_16( st->nelp_mode_dec, 1 ) )
{
/* modify the excitation signal of stationary unvoiced frames */
- stat_noise_uv_mod_fx( st_fx->coder_type, 0, st_fx->lsp_old_fx, lsp_new_fx, lsp_new_fx, Aq_fx, exc2_fx, st_fx->Q_exc, 1, &st_fx->ge_sm_fx,
- &st_fx->uv_count, &st_fx->act_count, st_fx->lspold_s_fx, &st_fx->noimix_seed, &st_fx->min_alpha_fx,
- &st_fx->exc_pe_fx, st_fx->core_brate, st_fx->bwidth, &st_fx->Q_stat_noise, &st_fx->Q_stat_noise_ge );
+ stat_noise_uv_mod_fx( st->coder_type, 0, st->lsp_old_fx, lsp_new_fx, lsp_new_fx, Aq_fx, exc2_fx, st->Q_exc, 1, &st->ge_sm_fx,
+ &st->uv_count, &st->act_count, st->lspold_s_fx, &st->noimix_seed, &st->min_alpha_fx,
+ &st->exc_pe_fx, st->core_brate, st->bwidth, &st->Q_stat_noise, &st->Q_stat_noise_ge );
}
-
- /* SC-VBR */
- st_fx->hSC_VBR->FadeScale_fx = mult( st_fx->hSC_VBR->FadeScale_fx, 24576 ); /*24576 in Q15*/
- move16();
}
- IF( hBWE_TD != NULL )
+
+ IF( st->hBWE_TD != NULL )
{
- IF( EQ_16( st_fx->L_frame, L_FRAME ) )
+ IF( EQ_16( st->L_frame, L_FRAME ) )
{
- Copy( Aq_fx + 2 * ( M + 1 ), hBWE_TD->cur_sub_Aq_fx, ( M + 1 ) ); // Q12
+ Copy( Aq_fx + 2 * ( M + 1 ), st->hBWE_TD->cur_sub_Aq_fx, ( M + 1 ) );
}
ELSE
{
- Copy( Aq_fx + 3 * ( M + 1 ), hBWE_TD->cur_sub_Aq_fx, ( M + 1 ) ); // Q12
+ Copy( Aq_fx + 3 * ( M + 1 ), st->hBWE_TD->cur_sub_Aq_fx, ( M + 1 ) );
}
}
+
/*--------------------------------------------------------*
* Apply NB postfilter in case of 8kHz output
*--------------------------------------------------------*/
+
test();
- IF( EQ_16( st_fx->last_bwidth, NB ) && st_fx->hPFstat != NULL )
+ IF( st->last_bwidth == NB && st->hPFstat != NULL )
{
- k = 0;
- move16();
- FOR( i = 0; i < st_fx->L_frame; i += L_SUBFR )
- {
- pitch_buf_tmp[k] = mult_r( pitch_buf_fx[k], 512 ); // Q0(6+9-15) , (512 = 1.0f in Q9)
- move16();
- k = add( k, 1 );
- }
+ Copy_Scale_sig( pitch_buf_fx, pitch_buf_tmp, st->nb_subfr, -Q6 ); // Q0
- IF( EQ_16( st_fx->bwidth, NB ) )
+ IF( st->bwidth == NB )
{
- st_fx->hPFstat->on = 1;
+ st->hPFstat->on = 1;
move16();
- nb_post_filt_fx( st_fx->L_frame, st_fx->hPFstat, &st_fx->psf_lp_noise_fx, tmp_noise_fx, syn_fx, Aq_fx, pitch_buf_tmp, st_fx->coder_type, st_fx->BER_detect, 0 );
+ nb_post_filt_fx( st->L_frame, st->hPFstat, &st->psf_lp_noise_fx, tmp_noise_fx, psyn_fx, Aq_fx, pitch_buf_tmp, st->coder_type, st->BER_detect, 0 );
}
ELSE
{
- st_fx->hPFstat->on = 0;
+ st->hPFstat->on = 0;
move16();
- nb_post_filt_fx( st_fx->L_frame, st_fx->hPFstat, &st_fx->psf_lp_noise_fx, tmp_noise_fx, syn_fx, Aq_fx, pitch_buf_tmp, AUDIO, st_fx->BER_detect, 0 );
+ nb_post_filt_fx( st->L_frame, st->hPFstat, &st->psf_lp_noise_fx, tmp_noise_fx, psyn_fx, Aq_fx, pitch_buf_tmp, AUDIO, st->BER_detect, 0 );
}
}
ELSE
{
- st_fx->psf_lp_noise_fx = round_fx( L_shl( st_fx->lp_noise, 1 ) );
+ st->psf_lp_noise_fx = round_fx( L_shl( st->lp_noise, 1 ) );
move16();
}
@@ -1196,142 +1501,255 @@ ivas_error acelp_core_dec_fx(
* Perform fixed deemphasis through 1/(1 - g*z^-1)
*-----------------------------------------------------------------*/
- /* Update old synthesis buffer - needed for ACELP internal sampling rate switching */
- Copy( syn_fx + st_fx->L_frame - L_SYN_MEM, st_fx->mem_syn_r, L_SYN_MEM );
- deemph_fx( syn_fx, st_fx->preemph_fac, st_fx->L_frame, &( st_fx->mem_deemph_fx ) );
- unscale_AGC( syn_fx, st_fx->Q_syn, syn_fx_tmp2, st_fx->agc_mem_fx, st_fx->L_frame );
- Copy( syn_fx_tmp2, syn_fx, st_fx->L_frame );
-
- /* Update MODE2 memories*/
- IF( hTcxDec != NULL )
+ /* update old synthesis buffer - needed for ACELP internal sampling rate switching */
+ Copy( psyn_fx + sub( st->L_frame, L_SYN_MEM ), st->mem_syn_r, L_SYN_MEM );
+ deemph_fx( psyn_fx, st->preemph_fac, st->L_frame, &( st->mem_deemph_fx ) );
+ unscale_AGC( psyn_fx, st->Q_syn, syn_fx_tmp2, st->agc_mem_fx, st->L_frame );
+ Copy( syn_fx_tmp2, psyn_fx, st->L_frame );
+ IF( st->hTcxDec != NULL )
{
- Copy_Scale_sig( syn_fx + shr( st_fx->L_frame, 1 ), hTcxDec->old_syn_Overl, shr( st_fx->L_frame, 1 ), sub( -1, st_fx->Q_syn ) ); /*Q-1*/
+ Copy_Scale_sig( psyn_fx + shr( st->L_frame, 1 ), st->hTcxDec->old_syn_Overl, shr( st->L_frame, 1 ), sub( -1, st->Q_syn ) ); /*Q-1*/
+ st->hTcxDec->Q_old_syn_Overl = -1;
}
- Copy_Scale_sig( syn_fx + st_fx->L_frame - M - 1, st_fx->syn, M + 1, sub( 0, st_fx->Q_syn ) ); /*Q0*/
+ Copy_Scale_sig( psyn_fx + sub( st->L_frame, M + 1 ), st->syn, M + 1, sub( 0, st->Q_syn ) ); /*Q0*/
/*------------------------------------------------------------------*
* Formant post-filter
*-----------------------------------------------------------------*/
- IF( st_fx->hPFstat != NULL )
+ test();
+ test();
+ test();
+ test();
+ IF( st->hPFstat != NULL && GE_16( st->last_bwidth, WB ) && ( GT_32( st->core_brate, ACELP_24k40 ) || st->element_mode > EVS_MONO ) && LE_32( st->core_brate, ACELP_32k ) )
{
- test();
- test();
- test();
- IF( GE_16( st_fx->last_bwidth, WB ) && ( GT_32( st_fx->core_brate, ACELP_24k40 ) || ( st_fx->element_mode > EVS_MONO ) ) && LE_32( st_fx->core_brate, ACELP_32k ) )
- {
- Copy( syn_fx, temp_buf + L_SYN_MEM, L_FRAME16k );
- st_fx->hPFstat->on = 1;
- move16();
- formant_post_filt_fx( st_fx->hPFstat, temp_buf + L_SYN_MEM, Aq_fx, syn_fx, L_FRAME16k, st_fx->lp_noise, st_fx->total_brate, 0 );
- }
- ELSE IF( GE_16( st_fx->last_bwidth, WB ) )
+ st->hPFstat->on = 1;
+ move16();
+ Copy( psyn_fx, temp_buf_fx + L_SYN_MEM, L_FRAME16k );
+ set16_fx( st->hPFstat->mem_zero, 0, M );
+
+ formant_post_filt_fx( st->hPFstat, temp_buf_fx + L_SYN_MEM, Aq_fx, psyn_fx, st->L_frame, st->lp_noise, st->total_brate, 0 );
+ }
+ ELSE IF( st->hPFstat != NULL && GE_16( st->last_bwidth, WB ) )
+ {
+ IF( st->hPFstat->on )
{
- IF( st_fx->hPFstat->on )
- {
- Copy( st_fx->hPFstat->mem_pf_in + L_SYN_MEM - M, temp_buf, M );
- Copy( syn_fx, temp_buf + M, L_SUBFR );
- Residu3_fx( Aq_fx, temp_buf + M, temp_buf + M + L_SUBFR, L_SUBFR, 1 );
- E_UTIL_synthesis( 1, Aq_fx, temp_buf + M + L_SUBFR, temp_buf, L_SUBFR, st_fx->hPFstat->mem_stp + L_SYN_MEM - M, 0, M );
- scale_st_fx( syn_fx, temp_buf, &st_fx->hPFstat->gain_prec, L_SUBFR );
- Copy( temp_buf, syn_fx, L_SUBFR / 2 );
- blend_subfr2_fx( temp_buf + L_SUBFR / 2, syn_fx + L_SUBFR / 2, syn_fx + L_SUBFR / 2 );
- }
- st_fx->hPFstat->on = 0;
- move16();
+ Copy( st->hPFstat->mem_pf_in + L_SYN_MEM - M, temp_buf_fx, M );
+ Copy( psyn_fx, temp_buf_fx + M, L_SUBFR );
+
+ Residu3_fx( Aq_fx, temp_buf_fx + M, temp_buf_fx + M + L_SUBFR, L_SUBFR, 1 );
+ E_UTIL_synthesis( 1, Aq_fx, temp_buf_fx + M + L_SUBFR, temp_buf_fx, L_SUBFR, st->hPFstat->mem_stp + L_SYN_MEM - M, 0, M );
+ scale_st_fx( psyn_fx, temp_buf_fx, &st->hPFstat->gain_prec, L_SUBFR );
+ Copy( temp_buf_fx, psyn_fx, ( L_SUBFR >> 1 ) );
+ blend_subfr2_fx( temp_buf_fx + L_SUBFR / 2, psyn_fx + L_SUBFR / 2, psyn_fx + L_SUBFR / 2 );
}
+ st->hPFstat->on = 0;
+ move16();
}
+
/*----------------------------------------------------------------*
* Comfort noise addition
*----------------------------------------------------------------*/
test();
test();
- IF( ( st_fx->hFdCngDec != NULL || EQ_16( st_fx->idchan, 1 ) ) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) )
+ IF( ( st->hFdCngDec != NULL || EQ_16( st->idchan, 1 ) ) && NE_16( st->element_mode, IVAS_CPE_MDCT ) )
{
test();
test();
test();
test();
test();
- IF( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) || st_fx->flag_cna || ( EQ_16( st_fx->cng_type, FD_CNG ) && LE_32( st_fx->total_brate, ACELP_32k ) ) || ( ( st_fx->cng_type == LP_CNG ) && LE_32( st_fx->total_brate, SID_2k40 ) ) )
+ IF( EQ_16( st->element_mode, IVAS_CPE_TD ) || st->flag_cna || ( EQ_16( st->cng_type, FD_CNG ) && LE_32( st->total_brate, ACELP_32k ) ) || ( st->cng_type == LP_CNG && LE_32( st->core_brate, SID_2k40 ) ) )
{
/*VAD only for non inactive frame*/
test();
- st_fx->VAD = st_fx->VAD && ( st_fx->coder_type != INACTIVE );
+ st->VAD = st->VAD && st->coder_type != INACTIVE;
move16();
test();
test();
test();
test();
test();
- IF( st_fx->idchan == 0 && ( st_fx->flag_cna || ( EQ_16( st_fx->cng_type, FD_CNG ) && LE_32( st_fx->total_brate, ACELP_32k ) ) ||
- ( EQ_16( st_fx->cng_type, LP_CNG ) && LE_32( st_fx->total_brate, SID_2k40 ) ) ) )
+ IF( st->idchan == 0 && ( st->flag_cna || ( EQ_16( st->cng_type, FD_CNG ) && LE_32( st->total_brate, ACELP_32k ) ) || ( st->cng_type == LP_CNG && LE_32( st->core_brate, SID_2k40 ) ) ) )
{
/*Noisy speech detector*/
- noisy_speech_detection_fx( st_fx->hFdCngDec, st_fx->VAD, syn_fx, st_fx->Q_syn );
+ noisy_speech_detection_fx( st->hFdCngDec, st->VAD, psyn_fx, st->Q_syn );
- st_fx->hFdCngDec->hFdCngCom->likelihood_noisy_speech = mult_r( st_fx->hFdCngDec->hFdCngCom->likelihood_noisy_speech, 32440 /*0.99 Q15*/ );
+ st->hFdCngDec->hFdCngCom->likelihood_noisy_speech = mult_r( st->hFdCngDec->hFdCngCom->likelihood_noisy_speech, 32440 /*0.99 Q15*/ );
move16();
- IF( st_fx->hFdCngDec->hFdCngCom->flag_noisy_speech != 0 )
+ IF( st->hFdCngDec->hFdCngCom->flag_noisy_speech != 0 )
{
- st_fx->hFdCngDec->hFdCngCom->likelihood_noisy_speech = add( st_fx->hFdCngDec->hFdCngCom->likelihood_noisy_speech, 328 /*0.01 Q15*/ );
+ st->hFdCngDec->hFdCngCom->likelihood_noisy_speech = add( st->hFdCngDec->hFdCngCom->likelihood_noisy_speech, 328 /*0.01 Q15*/ );
move16();
}
+ move32();
}
- if ( st_fx->idchan == 0 )
+
+ if ( st->idchan == 0 )
{
- st_fx->lp_noise = st_fx->hFdCngDec->lp_noise;
+ st->lp_noise = st->hFdCngDec->lp_noise;
move32();
}
- /*Noise estimate*/
- IF( NE_16( st_fx->element_mode, IVAS_CPE_TD ) /* && !st->cng_ism_flag IVAS_CODE */ )
+
+ test();
+ IF( NE_16( st->element_mode, IVAS_CPE_TD ) && !st->cng_ism_flag )
{
-#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
- PMT( "Code for IVAS_CODE_CNG_FIX185_PLC_FADEOUT not done" )
- ApplyFdCng_fx( syn, st_fx->Q_syn, NULL, realBuffer, imagBuffer, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) );
-#else
- ApplyFdCng_fx( syn_fx, st_fx->Q_syn, realBuffer, imagBuffer, NULL, st_fx, 0, ( EQ_16( st_fx->coder_type, AUDIO ) && st_fx->GSC_noisy_speech == 0 ) );
-#endif
+ /* Noise estimate */
+ ApplyFdCng_fx( psyn_fx, st->Q_syn, NULL, 0, realBuffer_fx, imagBuffer_fx, NULL, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) );
}
- /* CNA: Generate additional comfort noise to mask potential coding artefacts */
- }
- test();
- test();
- test();
- test();
- IF( st_fx->flag_cna && NE_16( st_fx->coder_type, AUDIO ) )
- {
- generate_masking_noise_fx( syn_fx, st_fx->Q_syn, st_fx->hFdCngDec->hFdCngCom, st_fx->hFdCngDec->hFdCngCom->frameSize, 0 );
- }
- ELSE IF( st_fx->flag_cna && EQ_16( st_fx->coder_type, AUDIO ) && st_fx->last_core == ACELP_CORE && NE_16( st_fx->last_coder_type, AUDIO ) )
- {
- FOR( i = 0; i < st_fx->hFdCngDec->hFdCngCom->frameSize / 2; i++ )
+ IF( !st->cna_dirac_flag )
{
- syn_fx[i] = add( syn_fx[i], shr_r( mult_r( st_fx->hFdCngDec->hFdCngCom->olapBufferSynth2[i + 5 * st_fx->hFdCngDec->hFdCngCom->frameSize / 4], st_fx->hFdCngDec->hFdCngCom->fftlenFac ), -st_fx->Q_syn ) );
- move16();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ /* CNA: Generate additional comfort noise to mask potential coding artefacts */
+ IF( st->flag_cna && !( EQ_16( st->coder_type, AUDIO ) && !( st->element_mode > EVS_MONO && st->GSC_noisy_speech ) ) )
+ {
+ test();
+ IF( EQ_16( st->element_mode, IVAS_CPE_TD ) && EQ_16( nchan_out, 2 ) )
+ {
+ IF( hStereoCng->flag_cna_fade )
+ {
+ generate_stereo_masking_noise_fx( psyn_fx, st->Q_syn, st, hStereoTD, flag_sec_CNA, 1, hStereoCng, nchan_out );
+ hStereoCng->flag_cna_fade = 0;
+ move16();
+ }
+ ELSE
+ {
+ test();
+ IF( NE_16( st->element_mode, last_element_mode ) && ( st->idchan == 0 ) )
+ {
+ /* Clear memory for secondary channel CNA */
+ set16_fx( hStereoCng->olapBufferSynth22_fx, 0, shr( st->hFdCngDec->hFdCngCom->frameSize, 1 ) );
+ }
+
+ generate_stereo_masking_noise_fx( psyn_fx, st->Q_syn, st, hStereoTD, flag_sec_CNA, 0, hStereoCng, nchan_out );
+ }
+ }
+ ELSE IF( NE_16( st->element_mode, IVAS_CPE_DFT ) )
+ {
+ IF( EQ_16( st->element_mode, EVS_MONO ) )
+ {
+ generate_masking_noise_fx( psyn_fx, st->Q_syn, st->hFdCngDec->hFdCngCom, st->hFdCngDec->hFdCngCom->frameSize, 0 );
+ }
+ ELSE
+ {
+ IF( st->idchan == 0 )
+ {
+ IF( NE_16( st->element_mode, last_element_mode ) )
+ {
+ set16_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2, 0, st->hFdCngDec->hFdCngCom->fftlen );
+ }
+
+ Word32 psyn_32_fx[L_FRAME16k];
+ Copy_Scale_sig_16_32_no_sat( psyn_fx, psyn_32_fx, st->hFdCngDec->hFdCngCom->frameSize, sub( Q6, st->Q_syn ) ); // Q6
+ Copy_Scale_sig_16_32_no_sat( st->hFdCngDec->hFdCngCom->olapBufferSynth2, st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, shl( st->hFdCngDec->hFdCngCom->frameSize, 1 ), Q15 ); // Q15
+
+ generate_masking_noise_ivas_fx( psyn_32_fx, &exp, st->hFdCngDec->hFdCngCom, st->hFdCngDec->hFdCngCom->frameSize, 0, 0, 0, st->element_mode, hStereoCng, nchan_out );
+
+ Copy_Scale_sig_32_16( psyn_32_fx, psyn_fx, st->hFdCngDec->hFdCngCom->frameSize, sub( st->Q_syn, exp ) ); // Q = st->Q_syn
+ Copy_Scale_sig_32_16( st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth2, shl( st->hFdCngDec->hFdCngCom->frameSize, 1 ), -Q15 ); // Q0
+ }
+ }
+ }
+ }
+ ELSE IF( st->flag_cna && EQ_16( st->coder_type, AUDIO ) && ( ( st->last_core == ACELP_CORE && !( EQ_16( st->last_coder_type, AUDIO ) && !( st->element_mode > EVS_MONO && st->Last_GSC_noisy_speech_flag ) ) ) || EQ_16( st->last_core, TCX_20_CORE ) ) )
+ {
+ test();
+ IF( EQ_16( st->element_mode, IVAS_CPE_TD ) && EQ_16( nchan_out, 2 ) )
+ {
+ generate_stereo_masking_noise_fx( psyn_fx, st->Q_syn, st, hStereoTD, flag_sec_CNA, 1, hStereoCng, nchan_out );
+ hStereoCng->flag_cna_fade = 1;
+ move16();
+ }
+ ELSE
+ {
+ FOR( i = 0; i < ( st->hFdCngDec->hFdCngCom->frameSize ) / 2; i++ )
+ {
+ psyn_fx[i] = add( psyn_fx[i], shr_r( mult_r( st->hFdCngDec->hFdCngCom->olapBufferSynth2[i + 5 * ( st->hFdCngDec->hFdCngCom->frameSize / 4 )], st->hFdCngDec->hFdCngCom->fftlenFac ), negate( st->Q_syn ) ) );
+ move16();
+ }
+ }
+ }
+ ELSE
+ {
+ IF( hStereoCng != NULL )
+ {
+ hStereoCng->flag_cna_fade = 1;
+ move16();
+ hStereoCng->enableSecCNA = 0;
+ move16();
+ }
+ }
+
+ IF( EQ_16( st->element_mode, IVAS_CPE_TD ) )
+ {
+ test();
+ test();
+ test();
+ /*Noise estimate*/
+ IF( ( st->idchan == 0 ) && ( EQ_16( nchan_out, 2 ) || ( st->core_brate != FRAME_NO_DATA && NE_32( st->core_brate, SID_2k40 ) ) ) )
+ {
+ ApplyFdCng_fx( psyn_fx, st->Q_syn, NULL, 0, realBuffer_fx, imagBuffer_fx, NULL, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) );
+ }
+ }
}
}
- test();
- test();
- test();
- test();
- test();
- IF( st_fx->flag_cna == 0 && EQ_16( st_fx->L_frame, L_FRAME16k ) && EQ_16( st_fx->last_flag_cna, 1 ) && ( ( st_fx->last_core == ACELP_CORE && NE_16( st_fx->last_coder_type, AUDIO ) ) || EQ_16( st_fx->last_core, AMR_WB_CORE ) ) )
+ IF( !st->cna_dirac_flag )
{
- FOR( i = 0; i < st_fx->L_frame / 2; i++ )
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( ( st->flag_cna == 0 ) && EQ_16( st->L_frame, L_FRAME16k ) && EQ_16( st->last_flag_cna, 1 ) && ( ( st->last_core == ACELP_CORE && !( EQ_16( st->last_coder_type, AUDIO ) && !( st->element_mode > EVS_MONO && st->Last_GSC_noisy_speech_flag ) ) ) || EQ_16( st->last_core, AMR_WB_CORE ) ) )
{
- syn_fx[i] = add( syn_fx[i], shr_r( st_fx->hFdCngDec->hFdCngCom->olapBufferSynth2[i + 5 * st_fx->L_frame / 4], negate( st_fx->Q_syn ) ) );
- move16();
+ IF( EQ_16( st->element_mode, EVS_MONO ) )
+ {
+ // VE: TBV - is it correct in EVS? in FLP, it is:
+ // v_multc( st->hFdCngDec->hFdCngCom->olapBufferSynth2 + 5 * st->L_frame / 4, 256.f, temp_buf, st->L_frame / 2 );
+ // v_add( temp_buf, syn, syn, st->L_frame / 2 );
+ FOR( i = 0; i < st->L_frame / 2; i++ )
+ {
+ psyn_fx[i] = add( psyn_fx[i], shr_r( st->hFdCngDec->hFdCngCom->olapBufferSynth2[i + 5 * st->L_frame / 4], negate( st->Q_syn ) ) );
+ move16();
+ }
+ }
+ ELSE
+ {
+ FOR( i = 0; i < ( st->hFdCngDec->hFdCngCom->frameSize ) / 2; i++ )
+ {
+ psyn_fx[i] = add( psyn_fx[i], shr_r( mult_r( st->hFdCngDec->hFdCngCom->olapBufferSynth2[i + 5 * ( st->hFdCngDec->hFdCngCom->frameSize / 4 )], st->hFdCngDec->hFdCngCom->fftlenFac ), -st->Q_syn ) );
+ move16();
+ }
+ }
}
- }
- test();
- IF( st_fx->flag_cna == 0 || EQ_16( st_fx->coder_type, AUDIO ) )
- {
- set16_fx( st_fx->hFdCngDec->hFdCngCom->olapBufferSynth2, 0, st_fx->hFdCngDec->hFdCngCom->fftlen );
+ test();
+ test();
+ test();
+ IF( ( st->flag_cna == 0 ) || ( EQ_16( st->coder_type, AUDIO ) && !( st->element_mode > EVS_MONO && st->GSC_noisy_speech ) ) )
+ {
+ IF( st->idchan == 0 )
+ {
+ set16_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2, 0, st->hFdCngDec->hFdCngCom->fftlen );
+ }
+ IF( hStereoCng != NULL && ( st->idchan == 0 ) )
+ {
+ set16_fx( hStereoCng->olapBufferSynth22_fx, 0, st->hFdCngDec->hFdCngCom->fftlen );
+ }
+ }
}
}
@@ -1340,45 +1758,44 @@ ivas_error acelp_core_dec_fx(
* Bass post-filter
*----------------------------------------------------------------*/
- /* check if the CLDFB works on the right sample rate */
- IF( ( st_fx->cldfbAna->usb * st_fx->cldfbAna->no_col ) != st_fx->L_frame )
+ IF( EQ_16( st->element_mode, EVS_MONO ) )
{
- /* resample to ACELP internal sampling rate */
- Word16 newCldfbBands = CLDFB_getNumChannels( L_mult0( st_fx->L_frame, FRAMES_PER_SEC ) );
- resampleCldfb( st_fx->cldfbAna, newCldfbBands, st_fx->L_frame, 0 );
- resampleCldfb( st_fx->cldfbBPF, newCldfbBands, st_fx->L_frame, 0 );
+ CLDFB_SCALE_FACTOR scaleFactor;
+ Word32 workBuffer[128 * 3];
- IF( st_fx->ini_frame > 0 )
+ /* check if the CLDFB works on the right sample rate */
+ IF( ( st->cldfbAna->usb * st->cldfbAna->no_col ) != st->L_frame )
{
- st_fx->cldfbSyn->bandsToZero = sub( st_fx->cldfbSyn->no_channels, st_fx->cldfbAna->no_channels );
- move16();
+ /* resample to ACELP internal sampling rate */
+ Word16 newCldfbBands = CLDFB_getNumChannels( L_mult0( st->L_frame, FRAMES_PER_SEC ) );
+ resampleCldfb( st->cldfbAna, newCldfbBands, st->L_frame, 0 );
+ resampleCldfb( st->cldfbBPF, newCldfbBands, st->L_frame, 0 );
+
+ IF( st->ini_frame > 0 )
+ {
+ st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->cldfbAna->no_channels );
+ move16();
+ }
}
- }
- test();
- IF( !( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) && st_fx->bpf_off ) )
- {
test();
- IF( NE_16( st_fx->L_frame, st_fx->last_L_frame ) && NE_16( st_fx->last_codec_mode, MODE2 ) )
+ IF( NE_16( st->L_frame, st->last_L_frame ) && NE_16( st->last_codec_mode, MODE2 ) )
{
- IF( EQ_16( st_fx->L_frame, L_FRAME ) )
+ IF( EQ_16( st->L_frame, L_FRAME ) )
{
- retro_interp5_4_fx( hBPF->pst_old_syn_fx );
+ retro_interp5_4_fx( st->hBPF->pst_old_syn_fx );
}
- ELSE IF( EQ_16( st_fx->L_frame, L_FRAME16k ) )
+ ELSE IF( EQ_16( st->L_frame, L_FRAME16k ) )
{
- retro_interp4_5_fx( syn_fx, hBPF->pst_old_syn_fx );
+ retro_interp4_5_fx( psyn_fx, st->hBPF->pst_old_syn_fx );
}
}
- bass_psfilter_fx( st_fx->hBPF, st_fx->Opt_AMR_WB, syn_fx, st_fx->L_frame, pitch_buf_fx, st_fx->bpf_off,
- st_fx->stab_fac_fx, &st_fx->stab_fac_smooth_fx, st_fx->coder_type, st_fx->Q_syn, bpf_error_signal );
- }
- test();
- IF( NE_16( st_fx->element_mode, IVAS_CPE_DFT ) || use_cldfb_for_dft )
- {
+ bass_psfilter_fx( st->hBPF, st->Opt_AMR_WB, psyn_fx, st->L_frame, pitch_buf_fx, st->bpf_off,
+ st->stab_fac_fx, &st->stab_fac_smooth_fx, st->coder_type, st->Q_syn, bpf_error_signal_16fx );
+
/* analysis of the synthesis at internal sampling rate */
- cldfbAnalysis_fx( st_fx->cldfbAna, realBuffer, imagBuffer, &scaleFactor, syn_fx, negate( st_fx->Q_syn ), CLDFB_NO_COL_MAX, workBuffer );
+ cldfbAnalysis_fx( st->cldfbAna, realBuffer_fx, imagBuffer_fx, &scaleFactor, psyn_fx, negate( st->Q_syn ), CLDFB_NO_COL_MAX, workBuffer );
scaleFactor.hb_scale = scaleFactor.lb_scale;
move16();
@@ -1386,25 +1803,26 @@ ivas_error acelp_core_dec_fx(
/* analysis and add the BPF error signal */
i = 0;
move16();
- if ( st_fx->bpf_off == 0 )
+ if ( st->bpf_off == 0 )
{
i = CLDFB_NO_COL_MAX;
move16();
}
- addBassPostFilter_fx( bpf_error_signal, realBuffer, imagBuffer, st_fx->cldfbBPF, workBuffer, negate( st_fx->Q_syn ),
- i, st_fx->cldfbAna->no_col, st_fx->cldfbAna->no_channels, &scaleFactor );
+
+ addBassPostFilter_fx( bpf_error_signal_16fx, realBuffer_fx, imagBuffer_fx, st->cldfbBPF, workBuffer, negate( st->Q_syn ),
+ i, st->cldfbAna->no_col, st->cldfbAna->no_channels, &scaleFactor );
/* set output mask for upsampling */
- IF( EQ_16( st_fx->bwidth, NB ) )
+ IF( EQ_16( st->bwidth, NB ) )
{
/* set NB mask for upsampling */
- st_fx->cldfbSyn->bandsToZero = sub( st_fx->cldfbSyn->no_channels, 10 );
+ st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, 10 );
move16();
}
- ELSE IF( NE_16( st_fx->cldfbSyn->bandsToZero, sub( st_fx->cldfbSyn->no_channels, st_fx->cldfbAna->no_channels ) ) )
+ ELSE IF( NE_16( st->cldfbSyn->bandsToZero, sub( st->cldfbSyn->no_channels, st->cldfbAna->no_channels ) ) )
{
/* in case of BW switching, re-init to default */
- st_fx->cldfbSyn->bandsToZero = sub( st_fx->cldfbSyn->no_channels, st_fx->cldfbAna->no_channels );
+ st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->cldfbAna->no_channels );
move16();
}
@@ -1412,47 +1830,447 @@ ivas_error acelp_core_dec_fx(
scaleFactor.hb_scale = scaleFactor.lb_scale;
move16();
+ test();
+ test();
+ test();
+ IF( ( ( st->core_brate == FRAME_NO_DATA ) || EQ_32( st->core_brate, SID_2k40 ) ) && ( EQ_16( st->cng_type, FD_CNG ) ) && ( LT_16( st->hFdCngDec->hFdCngCom->numCoreBands, st->cldfbSyn->no_channels ) ) )
+ {
+ generate_comfort_noise_dec_hf_fx( realBuffer_fx, imagBuffer_fx, &scaleFactor.hb_scale, st );
+
+ st->cldfbSyn->bandsToZero = 0;
+ move16();
+ IF( LT_16( st->hFdCngDec->hFdCngCom->regularStopBand, st->cldfbSyn->no_channels ) )
+ {
+ st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->hFdCngDec->hFdCngCom->regularStopBand );
+ move16();
+ }
+ st->cldfbSyn->lsb = st->cldfbAna->no_channels;
+ move16();
+ }
+
+ /* synthesis of the combined signal */
+ st->Q_syn2 = st->Q_syn;
+ move16();
+ cldfbSynthesis_fx( st->cldfbSyn, realBuffer_fx, imagBuffer_fx, &scaleFactor, synth_fx16, negate( st->Q_syn2 ), CLDFB_NO_COL_MAX, workBuffer );
+
+ /* Bring CLDFB output to Q0 */
+ Scale_sig( synth_fx16, output_frame, negate( st->Q_syn2 ) );
+ st->Q_syn2 = 0;
+ move16();
+
+ /* save synthesis - needed in case of core switching */
+ Copy( synth_fx16, st->previoussynth_fx, output_frame );
+ }
+ ELSE
+ {
+ /* check if the CLDFB works on the right sample rate */
+ IF( NE_16( imult1616( st->cldfbAna->no_channels, st->cldfbAna->no_col ), st->L_frame ) )
+ {
+ resampleCldfb_ivas_fx( st->cldfbAna, L_mult0( st->L_frame, FRAMES_PER_SEC ) );
+ resampleCldfb_ivas_fx( st->cldfbBPF, L_mult0( st->L_frame, FRAMES_PER_SEC ) );
+
+ IF( st->ini_frame > 0 )
+ {
+ st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->cldfbAna->no_channels );
+ move16();
+ }
+ }
+
+ /* analyze pitch coherence for bass post-filter */
+ Word32 pitch_buf_fx_q20[12];
+ Scale_sig32( st->old_pitch_buf_fx, 2 * NB_SUBFR16k + 2, Q4 ); // Q(x+4)
+ Word16 lim = shr( st->L_frame, 6 );
+ FOR( Word16 lp = 0; lp < lim; lp++ )
+ {
+ pitch_buf_fx_q20[lp] = L_shl( pitch_buf_fx[lp], Q14 );
+ move32();
+ }
+ bpf_pitch_coherence_ivas_fx( st, pitch_buf_fx_q20 );
+ Scale_sig32( st->old_pitch_buf_fx, 2 * NB_SUBFR16k + 2, -Q4 ); // Qx
test();
- IF( !st_fx->cng_sba_flag || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) )
+ IF( !( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && st->bpf_off ) )
{
test();
- test();
- test();
- IF( ( ( st_fx->core_brate == FRAME_NO_DATA ) || EQ_32( st_fx->core_brate, SID_2k40 ) ) && ( EQ_16( st_fx->cng_type, FD_CNG ) ) && ( LT_16( st_fx->hFdCngDec->hFdCngCom->numCoreBands, st_fx->cldfbSyn->no_channels ) ) )
+ IF( NE_16( st->L_frame, st->last_L_frame ) && NE_16( st->last_codec_mode, MODE2 ) )
+ {
+ IF( EQ_16( st->L_frame, L_FRAME ) )
+ {
+ retro_interp5_4_fx( st->hBPF->pst_old_syn_fx );
+ }
+ ELSE IF( EQ_16( st->L_frame, L_FRAME16k ) )
+ {
+ retro_interp4_5_fx( psyn_fx, st->hBPF->pst_old_syn_fx );
+ }
+ }
+
+ bass_psfilter_fx( st->hBPF, st->Opt_AMR_WB, psyn_fx, st->L_frame, pitch_buf_fx, st->bpf_off,
+ st->stab_fac_fx, &st->stab_fac_smooth_fx, st->coder_type, st->Q_syn, bpf_error_signal_16fx );
+ }
+
+ Word32 syn_tmp_32_fx[L_FRAME16k + L_SUBFR], *syn_32_fx;
+ set32_fx( syn_tmp_32_fx, 0, L_FRAME16k + L_SUBFR );
+ syn_32_fx = syn_tmp_32_fx + L_SUBFR;
+ test();
+ IF( NE_16( st->element_mode, IVAS_CPE_DFT ) || use_cldfb_for_dft )
+ {
+ /* analysis of the synthesis at internal sampling rate */
+ Word32 realBufferSave_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
+ Word32 imagBufferSave_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
+ Word32 *pRealSave_fx[CLDFB_NO_COL_MAX], *pImagSave_fx[CLDFB_NO_COL_MAX];
+ FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
+ {
+ pRealSave_fx[i] = realBufferSave_fx[i];
+ pImagSave_fx[i] = imagBufferSave_fx[i];
+ }
+ IF( st->p_bpf_noise_buf_32 )
{
- generate_comfort_noise_dec_hf_fx( realBuffer, imagBuffer, &scaleFactor.hb_scale, st_fx );
+ 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
+ }
+
+ FOR( i = 0; i < st->L_frame; i++ )
+ {
+ syn_32_fx[i] = L_shr( L_deposit_h( psyn_fx[i] ), add( 4, st->Q_syn ) ); // Q12
+ move32();
+ }
+
+ Word16 offset = sub( st->cldfbAna->p_filter_length, st->cldfbAna->no_channels );
+ Scale_sig32( st->cldfbAna->cldfb_state_fx, offset, 1 ); // Q12
+ st->cldfbAna->Q_cldfb_state = Q12;
+ move16();
+
+ cldfbAnalysis_ivas_fx( syn_32_fx, realBuffer_fx, imagBuffer_fx, -1, st->cldfbAna );
+
+ Scale_sig32( st->cldfbAna->cldfb_state_fx, offset, -1 ); // Q11
+ st->cldfbAna->Q_cldfb_state = Q11;
+ move16();
+ /* analysis and add the BPF error signal */
+ Word32 tmp_bpf_error_signal_fx[L_FRAME16k];
+ Word16 q_bpf_error_signal;
+ Word16 cldfb_state_offset = sub( st->cldfbBPF->p_filter_length, st->cldfbBPF->no_channels );
- st_fx->cldfbSyn->bandsToZero = 0;
+ q_bpf_error_signal = Q6;
+ move16();
+ 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
+ FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
+ {
+ Scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7 ); // Q0
+ Scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7 ); // Q0
+ }
+ Scale_sig32( st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, sub( q_bpf_error_signal, Q10 ) ); // q_bpf_error_signal (Q6)
+ st->cldfbBPF->Q_cldfb_state = q_bpf_error_signal;
+ move16();
+ tmp = -1;
+ move16();
+ if ( st->bpf_off )
+ {
+ tmp = 0;
+ move16();
+ }
+
+ addBassPostFilter_ivas_fx( tmp_bpf_error_signal_fx, tmp, realBuffer_fx, imagBuffer_fx, st->cldfbBPF );
+
+ Scale_sig32( st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, negate( ( sub( q_bpf_error_signal, Q10 ) ) ) ); // Q10
+ st->cldfbBPF->Q_cldfb_state = Q10;
+ move16();
+ /* set output mask for upsampling */
+ IF( EQ_16( st->bwidth, NB ) )
+ {
+ /* set NB mask for upsampling */
+ st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, 10 );
+ move16();
+ }
+ ELSE IF( NE_16( st->cldfbSyn->bandsToZero, sub( st->cldfbSyn->no_channels, st->cldfbAna->no_channels ) ) )
+ {
+ /* in case of BW switching, re-init to default */
+ st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->cldfbAna->no_channels );
move16();
- IF( LT_16( st_fx->hFdCngDec->hFdCngCom->regularStopBand, st_fx->cldfbSyn->no_channels ) )
+ }
+ test();
+ IF( !st->cng_sba_flag || EQ_16( st->element_mode, IVAS_CPE_MDCT ) )
+ {
+ test();
+ test();
+ test();
+ /*WB/SWB-FD_CNG*/
+ IF( ( st->core_brate == FRAME_NO_DATA || EQ_32( st->core_brate, SID_2k40 ) ) && ( EQ_16( st->cng_type, FD_CNG ) ) && ( LT_16( st->hFdCngDec->hFdCngCom->numCoreBands, st->cldfbSyn->no_channels ) ) )
{
- st_fx->cldfbSyn->bandsToZero = sub( st_fx->cldfbSyn->no_channels, st_fx->hFdCngDec->hFdCngCom->regularStopBand );
+ Word16 tmpBufferScale = 0;
move16();
+ generate_comfort_noise_dec_hf_ivas_fx( realBuffer_fx, imagBuffer_fx, /*realBuffer, imagBuffer,*/ &tmpBufferScale, st->hFdCngDec->hFdCngCom, st->cng_ism_flag );
+
+ FOR( i = 0; i < st->hFdCngDec->hFdCngCom->numSlots; i++ )
+ {
+ Scale_sig32( realBuffer_fx[i] + st->hFdCngDec->hFdCngCom->numCoreBands, sub( st->hFdCngDec->hFdCngCom->regularStopBand, st->hFdCngDec->hFdCngCom->numCoreBands ), sub( add( tmpBufferScale, 15 ), Q31 ) ); // Q0
+ Scale_sig32( imagBuffer_fx[i] + st->hFdCngDec->hFdCngCom->numCoreBands, sub( st->hFdCngDec->hFdCngCom->regularStopBand, st->hFdCngDec->hFdCngCom->numCoreBands ), sub( add( tmpBufferScale, 15 ), Q31 ) ); // Q0
+ }
+
+ IF( LT_16( st->hFdCngDec->hFdCngCom->regularStopBand, st->cldfbSyn->no_channels ) )
+ {
+ st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->hFdCngDec->hFdCngCom->regularStopBand );
+ move16();
+ }
+ ELSE
+ {
+ st->cldfbSyn->bandsToZero = 0;
+ move16();
+ }
}
- st_fx->cldfbSyn->lsb = st_fx->cldfbAna->no_channels;
+ }
+
+ IF( save_hb_synth_fx16 != NULL )
+ {
+ /* save and then zero-out lowband */
+ max_real = 0;
+ max_imag = 0;
+ move32();
+ move32();
+ FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
+ {
+ FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ )
+ {
+ max_real = L_max( max_real, L_abs( realBuffer_fx[i][j] ) );
+ max_imag = L_max( max_imag, L_abs( imagBuffer_fx[i][j] ) );
+ }
+ }
+ max_val = L_max( max_real, max_imag );
+ Q_real = sub( norm_l( max_val ), 3 ) /* Guard bits */;
+ FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
+ {
+ scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real
+ scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real
+ }
+#ifndef OPT_AVOID_STATE_BUF_RESCALE
+#ifdef OPT_STEREO_32KBPS_V1
+ scale_sig32( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->p_filter_length, sub( Q_real, Q11 ) ); // Q10 - > (Q_real-1)
+#else /* OPT_STEREO_32KBPS_V1 */
+ scale_sig32_r( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); // (Q_real-1)
+#endif /* OPT_STEREO_32KBPS_V1 */
+ st->cldfbSynHB->Q_cldfb_state = sub( Q_real, 1 );
+ move16();
+#endif /* OPT_AVOID_STATE_BUF_RESCALE */
+
+ FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ )
+ {
+ FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
+ {
+ realBufferSave_fx[i][j] = realBuffer_fx[i][j];
+ imagBufferSave_fx[i][j] = imagBuffer_fx[i][j];
+ move32();
+ move32();
+ IF( LT_16( j, st->hFdCngDec->hFdCngCom->numCoreBands ) && LT_16( i, st->hFdCngDec->hFdCngCom->numSlots ) )
+ {
+ realBuffer_fx[i][j] = 0;
+ imagBuffer_fx[i][j] = 0;
+ move32();
+ move32();
+ }
+ }
+ }
+
+#ifdef OPT_AVOID_STATE_BUF_RESCALE
+ cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, save_hb_synth_fx, -1, sub( Q11, Q_real ), -10, st->cldfbSynHB );
+#else /* OPT_AVOID_STATE_BUF_RESCALE */
+ cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, save_hb_synth_fx, -1, 0, st->cldfbSynHB );
+#endif /* OPT_AVOID_STATE_BUF_RESCALE */
+
+#ifndef OPT_AVOID_STATE_BUF_RESCALE
+ Scale_sig32( save_hb_synth_fx, L_FRAME48k, negate( ( sub( Q_real, 1 ) ) ) ); // Q0
+ Scale_sig32( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10
+ st->cldfbSynHB->Q_cldfb_state = Q10;
+ move16();
+#endif /* OPT_AVOID_STATE_BUF_RESCALE */
+ /* restore lowband */
+ FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ )
+ {
+ FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
+ {
+ realBuffer_fx[i][j] = realBufferSave_fx[i][j];
+ imagBuffer_fx[i][j] = imagBufferSave_fx[i][j];
+ move32();
+ move32();
+ }
+ }
+#ifndef OPT_AVOID_STATE_BUF_RESCALE
+ Scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); // Q_real-1
+ st->cldfbSynHB->Q_cldfb_state = sub( Q_real, 1 );
+ move16();
+#endif /* OPT_AVOID_STATE_BUF_RESCALE */
+
+#ifdef OPT_AVOID_STATE_BUF_RESCALE
+ cldfbSynthesis_ivas_fx( pRealSave_fx, pImagSave_fx, synth_fx, -1, sub( Q11, Q_real ), -10, st->cldfbSyn );
+#else /* OPT_AVOID_STATE_BUF_RESCALE */
+ cldfbSynthesis_ivas_fx( pRealSave_fx, pImagSave_fx, synth_fx, -1, 0, st->cldfbSyn );
+ Scale_sig32( synth_fx, L_FRAME48k, negate( sub( Q_real, 1 ) ) ); // Q0
+ Scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10
+ st->cldfbSynHB->Q_cldfb_state = Q10;
+ move16();
+#endif /* OPT_AVOID_STATE_BUF_RESCALE */
+ }
+ ELSE
+ {
+ /* synthesis of the combined signal */
+ max_real = 0;
+ max_imag = 0;
+ move32();
+ move32();
+ FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
+ {
+ FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ )
+ {
+ max_real = L_max( max_real, L_abs( realBuffer_fx[i][j] ) );
+ max_imag = L_max( max_imag, L_abs( imagBuffer_fx[i][j] ) );
+ }
+ }
+ max_val = L_max( max_real, max_imag );
+ Q_real = sub( norm_l( max_val ), 3 ) /* Guard bits */;
+ FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
+ {
+ scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real
+ scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real
+ }
+#ifdef OPT_STEREO_32KBPS_V1
+ scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q_real, Q11 ) ); // Q10 - > (Q_real-1)
+#else /* OPT_STEREO_32KBPS_V1 */
+ scale_sig32_r( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); //(Q_real - 1)
+#endif /* OPT_STEREO_32KBPS_V1 */
+ st->cldfbSyn->Q_cldfb_state = sub( Q_real, 1 );
+ move16();
+
+#ifdef OPT_AVOID_STATE_BUF_RESCALE
+ cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx, -1, 0, 0, st->cldfbSyn );
+#else /* OPT_AVOID_STATE_BUF_RESCALE */
+ cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx, -1, 0, st->cldfbSyn );
+#endif /* OPT_AVOID_STATE_BUF_RESCALE */
+ scale_sig32( synth_fx, output_frame, negate( sub( Q_real, 1 ) ) ); // Q0
+ scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10
+ st->cldfbSyn->Q_cldfb_state = Q10;
move16();
}
+
+ /* save synthesis - needed in case of core switching */
+ Copy32( synth_fx, st->previoussynth_fx_32, output_frame ); // Q0
}
- /* synthesis of the combined signal */
- st_fx->Q_syn2 = st_fx->Q_syn;
- move16();
+ ELSE
+ {
+ Word16 nSamples = NS2SA_FX2( i_mult( st->L_frame, FRAMES_PER_SEC ), FRAME_SIZE_NS /*DELAY_CLDFB_NS*/ ); /* IVAS-64: optimization is likely possible here (don't resample the whole frame) */
+
+ /* analysis of the synthesis at internal sampling rate - needed for DFT stereo -> TD stereo switching */
+ FOR( i = 0; i < st->L_frame; i++ )
+ {
+ syn_32_fx[i] = L_shr( L_deposit_h( psyn_fx[i] ), add( 4, st->Q_syn ) );
+ move32();
+ }
+
+ Word16 offset = sub( st->cldfbAna->p_filter_length, st->cldfbAna->no_channels );
+ Scale_sig32( st->cldfbAna->cldfb_state_fx, offset, 1 ); // Q12
+ st->cldfbAna->Q_cldfb_state = Q12;
+ move16();
+
+ cldfbAnalysis_ivas_fx( syn_32_fx + sub( st->L_frame, nSamples ), realBuffer_fx, imagBuffer_fx, nSamples, st->cldfbAna );
+
+ Scale_sig32( st->cldfbAna->cldfb_state_fx, offset, -1 ); // Q11
+ st->cldfbAna->Q_cldfb_state = Q11;
+ move16(); /* analysis and add the BPF error signal - needed for DFT stereo -> TD stereo switching */
+ Word32 tmp_bpf_error_signal_fx[L_FRAME16k];
+ Word16 q_bpf_error_signal;
+ Word16 cldfb_state_offset;
+ cldfb_state_offset = sub( st->cldfbBPF->p_filter_length, st->cldfbBPF->no_channels );
+
+ // Get Q-factor
+ q_bpf_error_signal = Q6;
+ move16();
+ 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
+ FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
+ {
+ Scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7 ); // Q0
+ Scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7 ); // Q0
+ }
+ Scale_sig32( st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, sub( q_bpf_error_signal, Q10 ) ); // q_bpf_error_signal (Q6)
+ st->cldfbBPF->Q_cldfb_state = q_bpf_error_signal;
+ move16();
+ tmp = 0;
+ move16();
+ if ( !st->bpf_off )
+ {
+ tmp = nSamples;
+ move16();
+ }
+
+ addBassPostFilter_ivas_fx( tmp_bpf_error_signal_fx + sub( st->L_frame, nSamples ), tmp, realBuffer_fx, imagBuffer_fx, st->cldfbBPF );
+
+ Scale_sig32( st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, negate( sub( q_bpf_error_signal, Q10 ) ) ); // Q10
+ st->cldfbBPF->Q_cldfb_state = Q10;
+ move16();
+ /* synthesis of the combined signal - needed for DFT stereo -> TD stereo switching */
+ max_real = 0;
+ max_imag = 0;
+ move32();
+ move32();
+ FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
+ {
+ FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ )
+ {
+ max_real = L_max( max_real, L_abs( realBuffer_fx[i][j] ) );
+ max_imag = L_max( max_imag, L_abs( imagBuffer_fx[i][j] ) );
+ }
+ }
+ max_val = L_max( max_real, max_imag );
+ Q_real = sub( norm_l( max_val ), 3 ) /* Guard bits */;
+ FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
+ {
+ scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real
+ scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real
+ }
+#ifndef OPT_AVOID_STATE_BUF_RESCALE
+#ifdef OPT_STEREO_32KBPS_V1
+ scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q_real, Q11 ) ); // Q10 - > (Q_real-1)
+#else /* OPT_STEREO_32KBPS_V1 */
+ scale_sig32_r( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); //(Q_real - 1)
+#endif /* OPT_STEREO_32KBPS_V1 */
+#endif /* OPT_AVOID_STATE_BUF_RESCALE */
+
+#ifdef OPT_AVOID_STATE_BUF_RESCALE
+ cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx /*dummy*/, NS2SA_FX2( st->output_Fs, FRAME_SIZE_NS /*DELAY_CLDFB_NS*/ ), sub( Q10, sub( Q_real, 1 ) ), -10, st->cldfbSyn );
+#else /* OPT_AVOID_STATE_BUF_RESCALE */
+ cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx /*dummy*/, NS2SA_FX2( st->output_Fs, FRAME_SIZE_NS /*DELAY_CLDFB_NS*/ ), 0, st->cldfbSyn );
+#endif /* OPT_AVOID_STATE_BUF_RESCALE */
+
+#ifndef OPT_AVOID_STATE_BUF_RESCALE
+ Scale_sig32( synth_fx, output_frame, negate( sub( Q_real, 1 ) ) ); // Q0
+ Scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10
+ st->cldfbSyn->Q_cldfb_state = Q10;
+ move16();
+#endif /* OPT_AVOID_STATE_BUF_RESCALE */
+ IF( st->p_bpf_noise_buf_32 )
+ {
+ Copy_Scale_sig_16_32_DEPREC( bpf_error_signal_16fx, bpf_error_signal_fx, st->L_frame, -1 ); // Q_syn-1
+ 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
+ }
+
+ set32_fx( synth_fx, 0, output_frame );
+ }
+
+ /* Copy output signal */
+ Scale_sig( syn_tmp_fx, add( st->L_frame, L_SUBFR ), negate( st->Q_syn ) ); // Q0
+ IF( st->element_mode > EVS_MONO )
{
- cldfbSynthesis_fx( st_fx->cldfbSyn, realBuffer, imagBuffer, &scaleFactor, synth_out, negate( st_fx->Q_syn2 ), CLDFB_NO_COL_MAX, workBuffer );
+ Copy( psyn_fx, output_fx, st->L_frame ); /*Q_syn*/
}
- /* Bring CLDFB output to Q0 */
- Scale_sig( synth_out, output_frame, negate( st_fx->Q_syn2 ) );
- st_fx->Q_syn2 = 0;
- move16();
- /* save synthesis - needed in case of core switching */
- Copy( synth_out, st_fx->previoussynth_fx, output_frame );
+ st->Q_syn2 = 0;
+ move16();
}
/*-----------------------------------------------------------------*
* Bandwidth extension 6kHz-7kHz
*-----------------------------------------------------------------*/
- IF( st_fx->hBWE_zero != NULL )
+
+ IF( st->hBWE_zero != NULL )
{
test();
test();
@@ -1461,14 +2279,27 @@ ivas_error acelp_core_dec_fx(
test();
test();
test();
- IF( ( EQ_16( st_fx->L_frame, L_FRAME ) && NE_16( st_fx->bwidth, NB ) && GE_16( output_frame, L_FRAME16k ) &&
- ( EQ_16( st_fx->extl, -1 ) || EQ_16( st_fx->extl, SWB_CNG ) || ( EQ_16( st_fx->extl, WB_BWE ) && st_fx->extl_brate == 0 && NE_16( st_fx->coder_type, AUDIO ) ) ) ) )
+ IF( ( EQ_16( st->L_frame, L_FRAME ) && ( st->bwidth != NB ) && GE_16( output_frame, L_FRAME16k ) &&
+ ( EQ_16( st->extl, -1 ) || EQ_16( st->extl, SWB_CNG ) || ( EQ_16( st->extl, WB_BWE ) && st->extl_brate == 0 && NE_16( st->coder_type, AUDIO ) ) ) ) )
{
- hf_synth_fx( st_fx->hBWE_zero, st_fx->core_brate, output_frame, Aq_fx, exc2_fx, syn_fx, synth_out, st_fx->Q_exc, st_fx->Q_syn2 );
+ IF( EQ_16( st->element_mode, EVS_MONO ) )
+ {
+ hf_synth_fx( st->hBWE_zero, st->core_brate, output_frame, Aq_fx, exc2_fx, psyn_fx, synth_fx16, st->Q_exc, st->Q_syn2 );
+ }
+ ELSE
+ {
+ Copy_Scale_sig_32_16( synth_fx, synth_fx16, output_frame, 0 ); // Q0
+ hf_synth_ivas_fx( st->hBWE_zero, st->core_brate, output_frame, Aq_fx, exc2_fx, psyn_fx, synth_fx16, st->Q_exc, st->Q_syn2 );
+ Copy_Scale_sig_16_32_DEPREC( synth_fx16, synth_fx, output_frame, 0 );
+ }
}
ELSE
{
- hf_synth_reset_fx( st_fx->hBWE_zero );
+ hf_synth_reset_fx( st->hBWE_zero );
+ IF( NE_16( st->element_mode, EVS_MONO ) ) // VE: TBV: tmp hack - it is a bug in EVS but condition is here to keep EVS bit-exact for the moment
+ {
+ set16_fx( st->hBWE_zero->mem_hp400_fx, 0, 6 );
+ }
}
}
@@ -1476,8 +2307,7 @@ ivas_error acelp_core_dec_fx(
* Populate parameters for SWB TBE
*-----------------------------------------------------------------*/
- /* Apply a non linearity to the SHB excitation */
- IF( hBWE_TD != NULL )
+ IF( st->hBWE_TD != NULL )
{
test();
test();
@@ -1491,11 +2321,16 @@ ivas_error acelp_core_dec_fx(
test();
test();
test();
- IF( ( !st_fx->bfi && ( st_fx->prev_bfi ) ) || ( ( EQ_16( st_fx->last_vbr_hw_BWE_disable_dec, 1 ) ) && ( st_fx->vbr_hw_BWE_disable_dec == 0 ) ) || ( ( EQ_16( st_fx->extl, SWB_TBE ) || EQ_16( st_fx->extl, WB_TBE ) || EQ_16( st_fx->extl, FB_TBE ) ) && NE_16( st_fx->last_extl, SWB_TBE ) && NE_16( st_fx->last_extl, WB_TBE ) && NE_16( st_fx->last_extl, FB_TBE ) ) || ( EQ_16( st_fx->idchan, 1 ) && EQ_16( st_fx->element_mode, IVAS_CPE_TD ) && !st_fx->tdm_LRTD_flag ) )
+ IF( ( !st->bfi && st->prev_bfi ) || ( EQ_16( st->last_vbr_hw_BWE_disable_dec, 1 ) && ( st->vbr_hw_BWE_disable_dec == 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 ) )
{
- hBWE_TD->bwe_non_lin_prev_scale_fx = L_deposit_l( 0 );
+ st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0;
move32();
- set16_fx( hBWE_TD->old_bwe_exc_extended_fx, 0, NL_BUFF_OFFSET );
+ set16_fx( st->hBWE_TD->old_bwe_exc_extended_fx, 0, NL_BUFF_OFFSET );
+ if ( NE_16( st->element_mode, EVS_MONO ) )
+ {
+ st->hBWE_TD->q_old_bwe_exc_extended_fx = Q15;
+ move16();
+ }
}
test();
@@ -1503,42 +2338,73 @@ ivas_error acelp_core_dec_fx(
test();
test();
test();
- IF( !st_fx->ppp_mode_dec && ( st_fx->idchan == 0 || NE_16( st_fx->element_mode, IVAS_CPE_TD ) || ( EQ_16( st_fx->idchan, 1 ) && EQ_16( st_fx->element_mode, IVAS_CPE_TD ) && st_fx->tdm_LRTD_flag ) ) )
+ 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 ) ) )
{
- non_linearity_fx( bwe_exc_fx, bwe_exc_extended, L_FRAME32k, &hBWE_TD->bwe_non_lin_prev_scale_fx, st_fx->Q_exc,
- st_fx->coder_type, voice_factors, st_fx->L_frame );
+ IF( EQ_16( st->element_mode, EVS_MONO ) )
+ {
+ non_linearity_fx( bwe_exc_fx, bwe_exc_extended_fx, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors_fx, st->L_frame );
+ }
+ ELSE
+ {
+ 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 ), st->hBWE_TD->q_old_bwe_exc_extended_fx ) ) ); /* Q(q_old_bwe_exc_extended_fx) -> Q(2 * Q_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, st->Q_exc, st->coder_type, voice_factors_fx, st->L_frame );
+ exp = sub( L_norm_arr( bwe_exc_extended_fx + L_FRAME32k, NL_BUFF_OFFSET ), 16 );
+ Copy_Scale_sig_32_16( bwe_exc_extended_fx + L_FRAME32k, st->hBWE_TD->old_bwe_exc_extended_fx, NL_BUFF_OFFSET, exp ); /* Q(2 * Q_exc) -> Q(q_old_bwe_exc_extended_fx) */
+ st->hBWE_TD->q_old_bwe_exc_extended_fx = add( shl( st->Q_exc, 1 ), exp );
+ move16();
+ }
}
test();
- IF( ( st_fx->core_brate == FRAME_NO_DATA ) || EQ_32( st_fx->core_brate, SID_2k40 ) )
+ if ( st->core_brate == FRAME_NO_DATA || EQ_32( st->core_brate, SID_2k40 ) )
{
- hBWE_TD->bwe_non_lin_prev_scale_fx = L_deposit_l( 0 );
+ st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0;
move32();
}
}
+
/*----------------------------------------------------------------------*
* Updates
*----------------------------------------------------------------------*/
- updt_dec_fx( st_fx, old_exc_fx, pitch_buf_fx, Es_pred_fx, Aq_fx, lsf_new_fx, lsp_new_fx, voice_factors, old_bwe_exc_fx, gain_buf );
+ updt_dec_fx( st, old_exc_fx, pitch_buf_fx, Es_pred_fx, Aq_fx, lsf_new_fx, lsp_new_fx, voice_factors_fx, old_bwe_exc_fx, gain_buf_fx );
test();
test();
- IF( GT_32( st_fx->core_brate, SID_2k40 ) && st_fx->hTdCngDec != NULL && st_fx->hFdCngDec != NULL )
+ IF( GT_32( st->core_brate, SID_2k40 ) && st->hTdCngDec != NULL && st->hFdCngDec != NULL )
{
/* update CNG parameters in active frames */
- cng_params_upd_fx( lsp_new_fx, exc_fx, st_fx->L_frame, &st_fx->hTdCngDec->ho_circ_ptr, st_fx->hTdCngDec->ho_ener_circ_fx, &st_fx->hTdCngDec->ho_circ_size, st_fx->hTdCngDec->ho_lsp_circ_fx,
- st_fx->Q_exc, DEC, st_fx->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st_fx->last_active_brate );
+ IF( EQ_16( st->element_mode, EVS_MONO ) )
+ {
+ cng_params_upd_fx( lsp_new_fx, exc_fx, st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx,
+ st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate );
+ }
+ ELSE
+ {
+ cng_params_upd_ivas_fx( lsp_new_fx, exc_fx, st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size,
+ st->hTdCngDec->ho_lsp_circ_fx, st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate, st->element_mode,
+ st->hFdCngDec->hFdCngCom->CngBandwidth );
+ }
+
/* Set 16k LSP flag for CNG buffer */
- st_fx->hTdCngDec->ho_16k_lsp[st_fx->hTdCngDec->ho_circ_ptr] = 0;
+ st->hTdCngDec->ho_16k_lsp[st->hTdCngDec->ho_circ_ptr] = 0;
move16();
- if ( NE_16( st_fx->L_frame, L_FRAME ) )
+ if ( NE_16( st->L_frame, L_FRAME ) )
{
- st_fx->hTdCngDec->ho_16k_lsp[st_fx->hTdCngDec->ho_circ_ptr] = 1;
+ st->hTdCngDec->ho_16k_lsp[st->hTdCngDec->ho_circ_ptr] = 1;
move16();
}
}
- return IVAS_ERR_OK;
+ IF( NE_16( st->element_mode, EVS_MONO ) )
+ {
+ IF( save_hb_synth_fx16 )
+ {
+ Copy_Scale_sig_32_16( save_hb_synth_fx, save_hb_synth_fx16, L_FRAME48k, 0 ); // Q0
+ }
+ Copy_Scale_sig_32_16( synth_fx, synth_fx16, output_frame, 0 ); // Q_syn2
+ }
+
+ pop_wmops();
+ return error;
}
-#endif
diff --git a/lib_dec/acelp_core_dec_ivas_fx.c b/lib_dec/acelp_core_dec_ivas_fx.c
deleted file mode 100644
index ad8ca9b504ddd874b3086a35b4517494ecda4b9d..0000000000000000000000000000000000000000
--- a/lib_dec/acelp_core_dec_ivas_fx.c
+++ /dev/null
@@ -1,2429 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository. All Rights Reserved.
-
- This software is protected by copyright law and by international treaties.
- The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository retain full ownership rights in their respective contributions in
- the software. This notice grants no license of any kind, including but not limited to patent
- license, nor is any license granted by implication, estoppel or otherwise.
-
- Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
- contributions.
-
- This software is provided "AS IS", without any express or implied warranties. The software is in the
- development stage. It is intended exclusively for experts who have experience with such software and
- solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
- and fitness for a particular purpose are hereby disclaimed and excluded.
-
- Any dispute, controversy or claim arising under or in relation to providing this software shall be
- submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
- accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
- the United Nations Convention on Contracts on the International Sales of Goods.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-#include
-#include
-#include
-#include "options.h"
-#include "cnst.h"
-#include "rom_com.h"
-#include "prot_fx.h"
-#include "ivas_cnst.h"
-#include "ivas_rom_com.h"
-#include "wmc_auto.h"
-#include "ivas_prot_fx.h"
-
-
-/*-------------------------------------------------------------------*
- * acelp_core_dec_ivas_fx()
- *
- * ACELP core decoder
- *-------------------------------------------------------------------*/
-
-ivas_error acelp_core_dec_ivas_fx(
- Decoder_State *st, /* i/o: decoder state structure */
- Word16 output_fx[], /* o : synthesis @internal Fs Q_syn*/
- Word16 synth_fx16[], /* o : synthesis Q_syn2*/
- Word16 save_hb_synth_fx16[], /* o : HB synthesis Q0*/
- Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation 2*Q_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_syn2-1*/
- const Word16 sharpFlag, /* i : formant sharpening flag */
- Word16 pitch_buf_fx[NB_SUBFR16k], /* o : Word16 pitch for each subframe Q6*/
- Word16 *unbits, /* o : number of unused bits */
- Word16 *sid_bw, /* o : 0-NB/WB, 1-SWB SID */
- STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i/o: TD stereo decoder handle Qlog2(2.56)*/
- const Word16 tdm_lspQ_PCh_fx[M], /* i : Q LSPs for primary channel Q15*/
- const Word16 tdm_lsfQ_PCh_fx[M], /* i : Q LSFs for primary channel */
- const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */
- const Word16 last_element_mode, /* i : last element mode */
- const Word32 last_element_brate, /* i : last element bitrate */
- const Word16 flag_sec_CNA, /* i : CNA flag for secondary channel */
- const Word16 nchan_out, /* i : number of output channels */
- STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */
- const Word16 read_sid_info /* i : read SID info flag */
-)
-{
- Word32 synth_fx[960], save_hb_synth_fx[960] /*, bwe_exc_extended_fx[L_FRAME32k + NL_BUFF_OFFSET]*/;
- Word16 old_exc_fx[L_EXC_DEC], *exc_fx; /* excitation signal buffer */
- Word16 syn_tmp_fx[L_FRAME16k + L_SUBFR], *psyn_fx; /* synthesis signal buffer */
- Word16 output_frame; /* frame length at output sampling freq. */
- Word16 lsf_new_fx[M]; /* LSFs at the end of the frame Qlog2(2.56) */
- Word16 lsp_new_fx[M]; /* LSPs at the end of the frame Q15 */
- Word16 lsp_mid_fx[M]; /* LSPs in the middle of the frame */
- Word16 Aq_fx[NB_SUBFR16k * ( M + 1 )]; /* A(q) quantized for the 4 subframes */
- Word16 old_exc2_fx[L_FRAME16k + L_EXC_MEM], *exc2_fx; /* total excitation buffer */
- Word16 mem_tmp_fx[M]; /* temporary synthesis filter memory */
- Word32 enr_q_fx; /* E information for FER protection */
- Word16 tmp_noise_fx; /* Long term temporary noise energy */
- Word16 Es_pred_fx; /* predicted scaled innov. energy Q8 */
- Word16 FEC_pitch_fx; /* FEC pitch */
- Word16 old_bwe_exc_fx[( ( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2 )]; /* excitation buffer */
- Word16 *bwe_exc_fx; /* Excitation for SWB TBE */
- Word16 i, j, int_fs;
- Word16 tc_subfr;
- Word16 allow_cn_step;
- Word16 temp_buf_fx[L_FRAME16k + L_SYN_MEM];
- Word16 last_pulse_pos;
- Word16 T0_tmp;
- Word16 do_WI;
- Word16 dct_buffer_fx[DCT_L_POST];
- Word16 exc_buffer_fx[DCT_L_POST];
- Word16 dct_exc_tmp_fx[L_FRAME16k];
- Word16 nb_bits; /* number of bits */
- Word16 indice; /* parameter indices to write */
- Word16 gain_buf_fx[NB_SUBFR16k];
- Word16 syn_fx_tmp2[L_FRAME_16k];
- Word16 pitch_buf_tmp[NB_SUBFR16k];
- Word16 update_flg;
- Word32 q_env_fx[20];
- Word16 exc3_fx[L_FRAME16k];
- Word16 syn1_tmp_fx[L_FRAME16k + 2], *syn1_fx;
- Word32 *realBuffer_fx[CLDFB_NO_COL_MAX], *imagBuffer_fx[CLDFB_NO_COL_MAX];
- Word32 realBufferTmp_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
- Word32 imagBufferTmp_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
- Word16 LSF_Q_prediction; /* LSF prediction mode */
- Word16 avoid_lpc_burst_on_recovery;
- Word16 tmpF_fx;
- Word16 uc_two_stage_flag;
- Word16 tdm_lp_reuse_flag, tdm_low_rate_mode, tdm_Pitch_reuse_flag;
- Word16 *old_exc_s_fx; /* Start of last excitation frame */
- Word16 *p_tdm_Pri_pitch_buf_fx;
- Word16 tmp, exp, local_element_mode;
- ivas_error error;
- Word32 bpf_error_signal_fx[L_FRAME16k];
- Word16 bpf_error_signal_16fx[L_FRAME16k];
- Word16 Q_real;
- Word32 max_real, max_imag, max_val;
-
- set32_fx( bpf_error_signal_fx, 0, L_FRAME16k );
- set16_fx( bpf_error_signal_16fx, 0, L_FRAME16k );
- set16_fx( Aq_fx, 0, NB_SUBFR16k * ( M + 1 ) );
- set16_fx( old_bwe_exc_fx, 0, ( ( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2 ) );
-
- error = IVAS_ERR_OK;
- move32();
-
- test();
- test();
- test();
- IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && EQ_16( nchan_out, 1 ) && EQ_16( st->idchan, 1 ) && LE_32( last_element_brate, IVAS_SID_5k2 ) )
- {
- /* In MDCT-Stereo DTX with mono output, we can skip CNG for the second channel, except for the first inactive frame following an active period */
- return error;
- }
-
- push_wmops( "acelp_core_dec" );
-
- /* output_frame = (int16_t) ( st->output_Fs / FRAMES_PER_SEC ); */
- output_frame = extract_l( Mpy_32_32( st->output_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) );
-
- /*----------------------------------------------------------------*
- * stereo SID and CNG frames processing
- *----------------------------------------------------------------*/
-
- test();
- test();
- IF( LE_32( st->core_brate, SID_2k40 ) && EQ_16( st->element_mode, IVAS_CPE_DFT ) && EQ_16( nchan_out, 2 ) )
- {
- IF( EQ_16( st->cng_type, FD_CNG ) )
- {
- configureFdCngDec_fx( st->hFdCngDec, st->bwidth, ACELP_14k25, st->L_frame, st->last_L_frame, st->element_mode );
-
- Word16 old_NoiseEstExp;
- old_NoiseEstExp = st->hFdCngDec->hFdCngCom->sidNoiseEstExp;
- move16();
-
- /* Only run parameter decoding in SID frames */
- IF( EQ_32( st->core_brate, SID_2k40 ) )
- {
- FdCng_decodeSID_ivas_fx( st );
-
- Word16 n1, n2;
- n1 = L_norm_arr( st->hFdCngDec->hFdCngCom->sidNoiseEst, NPART );
- n2 = L_norm_arr( st->hFdCngDec->hFdCngCom->sidNoiseEstLp, NPART );
-
- Word16 common_e = s_max( sub( old_NoiseEstExp, n2 ), sub( st->hFdCngDec->hFdCngCom->sidNoiseEstExp, n1 ) );
- scale_sig32( st->hFdCngDec->hFdCngCom->sidNoiseEst, NPART, sub( st->hFdCngDec->hFdCngCom->sidNoiseEstExp, common_e ) );
- scale_sig32( st->hFdCngDec->hFdCngCom->sidNoiseEstLp, NPART, sub( old_NoiseEstExp, common_e ) );
- st->hFdCngDec->hFdCngCom->sidNoiseEstExp = common_e;
- move16();
- }
- FOR( i = 0; i < NPART; i++ )
- {
- st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] = Madd_32_32( Mpy_32_32( STEREO_DFT_FD_FILT_Q31, st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] ),
- STEREO_DFT_FD_FILT_COMP_Q31, st->hFdCngDec->hFdCngCom->sidNoiseEst[i] );
- move32();
- }
-
- ApplyFdCng_ivas_fx( NULL, 0, NULL, 0, NULL, NULL, NULL, st, 0, 0 );
- }
- ELSE
- {
- configureFdCngDec_fx( st->hFdCngDec, st->bwidth, ACELP_14k25, st->L_frame, st->last_L_frame, st->element_mode );
-
- /* decode CNG parameters */
- CNG_dec_ivas_fx( st, last_element_mode, Aq_fx, lsp_new_fx, lsf_new_fx, &allow_cn_step, sid_bw, q_env_fx );
-
- /* comfort noise generation */
- CNG_exc_fx( st->core_brate, st->L_frame, &st->hTdCngDec->Enew_fx, &st->hTdCngDec->cng_seed, NULL, NULL, &st->lp_ener_fx, st->last_core_brate, &st->first_CNG, &( st->hTdCngDec->cng_ener_seed ), NULL, allow_cn_step, &st->hTdCngDec->last_allow_cn_step, st->prev_Q_exc, st->Q_exc, st->hTdCngDec->num_ho, q_env_fx, st->hTdCngDec->lp_env_fx, st->hTdCngDec->old_env_fx, st->hTdCngDec->exc_mem_fx, st->hTdCngDec->exc_mem1_fx, sid_bw, &st->hTdCngDec->cng_ener_seed1, NULL, st->Opt_AMR_WB, st->element_mode );
-
- Copy( Aq_fx, st->Aq_cng, M + 1 ); /*Q12*/
-
- /* update old LSP and LSF vector */
- Copy( lsf_new_fx, st->lsf_old_fx, M ); /*Qlog2(2.56)*/
- Copy( lsp_new_fx, st->lsp_old_fx, M ); /*Q15*/
- }
-
- set16_fx( output_fx, 0, output_frame ); /* output and synth are not used in DFT domain CNG generation and the decoder output is unaffected if they are left uninitalized */
- set16_fx( synth_fx16, 0, output_frame ); /* They are however read in a few places which causes errors in the valgrind tests. Simplest solution from a code perspective was to set them to zero. */
-
- /* CN generation done in DFT domain */
- pop_wmops();
-
- return error;
- }
-
- /*----------------------------------------------------------------*
- * Active frames processing
- *----------------------------------------------------------------*/
-
- /* open CLDFB buffer up to CLDFB_NO_CHANNELS_MAX bands for 48kHz */
- FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
- {
- set32_fx( realBufferTmp_fx[i], 0, CLDFB_NO_CHANNELS_MAX );
- set32_fx( imagBufferTmp_fx[i], 0, CLDFB_NO_CHANNELS_MAX );
- realBuffer_fx[i] = realBufferTmp_fx[i];
- imagBuffer_fx[i] = imagBufferTmp_fx[i];
- }
-
- /*----------------------------------------------------------------*
- * Initialization
- *----------------------------------------------------------------*/
-
- LSF_Q_prediction = -1;
- move16();
- set16_fx( syn_tmp_fx, 0, L_SUBFR );
- psyn_fx = syn_tmp_fx + L_SUBFR;
- syn1_tmp_fx[0] = 0;
- move16();
- syn1_tmp_fx[1] = 0;
- move16();
- syn1_fx = syn1_tmp_fx + 2;
- st->bpf_off = 0;
- move16();
-
- test();
- test();
- test();
- test();
- test();
- test();
- IF( EQ_16( st->last_core, HQ_CORE ) || EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) || ( EQ_16( st->element_mode, IVAS_CPE_DFT ) && LE_32( st->last_core_brate, SID_2k40 ) ) || ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && LE_32( st->last_core_brate, SID_2k40 ) ) )
- {
- /* in case of HQ->ACELP switching, do not apply BPF */
- st->bpf_off = 1;
- move16();
- if ( st->hPFstat != NULL )
- {
- /* in case of core switching, reset post-filter memories */
- st->hPFstat->on = 0;
- move16();
- }
-
- if ( st->hGSCDec != NULL )
- {
- /* reset the GSC pre echo energy threshold in case of switching */
- st->hGSCDec->Last_frame_ener_fx = MAX_32;
- move32();
- }
- }
-
- test();
- if ( st->hGSCDec != NULL && ( st->prev_bfi > 0 ) )
- {
- /* reset the GSC pre echo energy threshold in case of FEC */
- st->hGSCDec->Last_frame_ener_fx = MAX_32;
- move32();
- }
-
- test();
- test();
- test();
- test();
- IF( st->hFdCngDec != NULL && ( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) && ( EQ_32( st->last_core_brate, SID_2k40 ) || st->last_core_brate == FRAME_NO_DATA ) )
- {
- set16_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2, 0, FFTLEN );
- set16_fx( hStereoCng->olapBufferSynth22_fx, 0, FFTLEN );
- }
-
- st->clas_dec = st->last_good;
- move16();
- enr_q_fx = 0;
- move32();
- Es_pred_fx = 0;
- move16();
- tmp_noise_fx = 0;
- move16();
- Copy( st->old_exc_fx, old_exc_fx, L_EXC_MEM_DEC ); /*Q_exc*/
- exc_fx = old_exc_fx + L_EXC_MEM_DEC;
-
- IF( st->hWIDec != NULL )
- {
- Copy( st->hWIDec->old_exc2_fx, old_exc2_fx, L_EXC_MEM );
- }
- ELSE
- {
- set16_fx( old_exc2_fx, 0, L_EXC_MEM );
- }
- exc2_fx = old_exc2_fx + L_EXC_MEM;
-
- IF( st->hBWE_TD != NULL )
- {
- Copy( st->hBWE_TD->old_bwe_exc_fx, old_bwe_exc_fx, PIT16k_MAX * 2 ); /*Q_exc*/
- bwe_exc_fx = old_bwe_exc_fx + PIT16k_MAX * 2;
- }
- ELSE
- {
- bwe_exc_fx = NULL;
- }
-
- last_pulse_pos = 0;
- move16();
- do_WI = 0;
- move16();
- st->GSC_noisy_speech = 0;
- move16();
- st->relax_prev_lsf_interp = 0;
- move16();
- set16_fx( gain_buf_fx, 0, NB_SUBFR16k );
-
- IF( EQ_16( st->L_frame, L_FRAME ) )
- {
- st->gamma = GAMMA1;
- move16();
- st->inv_gamma = GAMMA1_INV;
- move16();
- st->preemph_fac = PREEMPH_FAC;
- move16();
- int_fs = INT_FS_12k8;
- move16();
- }
- ELSE
- {
- st->gamma = GAMMA16k;
- move16();
- st->inv_gamma = GAMMA16k_INV;
- move16();
- st->preemph_fac = PREEMPH_FAC_16k;
- move16();
- int_fs = INT_FS_16k;
- move16();
- }
-
- test();
- /* reset post-filter in case of switching */
- if ( st->hPFstat != NULL && ( st->hPFstat->on == 0 ) )
- {
- st->hPFstat->reset = 1;
- move16();
- }
-
- avoid_lpc_burst_on_recovery = 0;
- move16();
- test();
- test();
- if ( st->last_con_tcx && NE_16( st->L_frameTCX_past, st->L_frame ) && ( st->last_core != 0 ) )
- {
- avoid_lpc_burst_on_recovery = 1;
- move16();
- }
- test();
-
- /* TD stereo parameters */
- IF( EQ_16( st->element_mode, IVAS_CPE_TD ) && EQ_16( st->idchan, 1 ) )
- {
- tdm_lp_reuse_flag = hStereoTD->tdm_lp_reuse_flag;
- move16();
- tdm_low_rate_mode = hStereoTD->tdm_low_rate_mode;
- move16();
- tdm_Pitch_reuse_flag = hStereoTD->tdm_Pitch_reuse_flag;
- move16();
- p_tdm_Pri_pitch_buf_fx = hStereoTD->tdm_Pri_pitch_buf_fx;
- }
- ELSE
- {
- tdm_lp_reuse_flag = 0;
- move16();
- tdm_low_rate_mode = 0;
- 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();
- p_tdm_Pri_pitch_buf_fx = NULL;
- }
-
- /*----------------------------------------------------------------*
- * Updates in case of internal sampling rate 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 ) ) )
- {
- Word16 dec;
-
- IF( ( st->hPFstat->on != 0 ) )
- {
- Word16 mem_syn_r_size_old, mem_syn_r_size_new;
- mem_syn_r_size_old = mult_r( 2048, st->last_L_frame ); /* 1.25/20.f = 2048 (Q15)*/
- mem_syn_r_size_new = mult_r( 2048, st->L_frame ); /* 1.25/20.f = 2048 (Q15)*/
- lerp( st->hPFstat->mem_stp + sub( L_SYN_MEM, mem_syn_r_size_old ), st->hPFstat->mem_stp + sub( L_SYN_MEM, mem_syn_r_size_new ), mem_syn_r_size_new, mem_syn_r_size_old );
- lerp( st->hPFstat->mem_pf_in + sub( L_SYN_MEM, mem_syn_r_size_old ), st->hPFstat->mem_pf_in + sub( L_SYN_MEM, mem_syn_r_size_new ), mem_syn_r_size_new, mem_syn_r_size_old );
- }
-
- /* convert quantized LSP vector */
- st->rate_switching_reset = lsp_convert_poly_fx( st->lsp_old_fx, st->L_frame, 0 );
- move16();
-
- /* convert old quantized LSF vector */
- lsp2lsf_fx( st->lsp_old_fx, st->lsf_old_fx, M, int_fs );
-
- /* FEC - update adaptive LSF mean vector */
- Copy( st->lsf_old_fx, st->lsfoldbfi1_fx, M ); /*Qlog2(2.56)*/
- Copy( st->lsf_old_fx, st->lsfoldbfi0_fx, M ); /*Qlog2(2.56)*/
- Copy( st->lsf_old_fx, st->lsf_adaptive_mean_fx, M ); /*Qlog2(2.56)*/
-
- /* Reset LPC mem */
- IF( EQ_32( st->sr_core, INT_FS_16k ) )
- {
- Copy( GEWB2_Ave_fx, st->mem_AR_fx, M ); /*Qlog2(2.56)*/
- }
- ELSE
- {
- Copy( GEWB_Ave_fx, st->mem_AR_fx, M ); /*Qlog2(2.56)*/
- }
- set16_fx( st->mem_MA_fx, 0, M );
-
- /* update synthesis filter memories */
- dec = DEC;
- move16();
- if ( st->element_mode != EVS_MONO )
- {
- dec = DEC_IVAS;
- move16();
- }
- ivas_synth_mem_updt2_fx( st->L_frame, st->last_L_frame, st->old_exc_fx, st->mem_syn_r, st->mem_syn2_fx, NULL, dec );
- Copy( st->old_exc_fx, old_exc_fx, L_EXC_MEM_DEC ); /*Q_exc*/
- Copy_Scale_sig( st->mem_syn2_fx, st->mem_syn1_fx, M, sub( -1, st->Q_syn ) ); /*Q-1*/
- Copy( st->mem_syn2_fx, st->mem_syn3_fx, M ); /*Q_syn*/
- }
-
- /* update buffer of old subframe pitch values */
- IF( NE_16( st->last_L_frame, st->L_frame ) )
- {
- IF( EQ_16( st->L_frame, L_FRAME ) )
- {
- IF( EQ_16( st->last_L_frame, L_FRAME32k ) )
- {
- tmpF_fx = 13107; // Q15
- move16();
- }
- ELSE IF( EQ_16( st->last_L_frame, 512 ) )
- {
- tmpF_fx = 16384; // Q15
- move16();
- }
- ELSE /* st->last_L_frame == L_FRAME16k */
- {
- tmpF_fx = 26214; // Q15
- move16();
- }
-
- FOR( i = NB_SUBFR16k - NB_SUBFR; i < NB_SUBFR16k; i++ )
- {
- st->old_pitch_buf_fx[i - 1] = Mpy_32_16_1( st->old_pitch_buf_fx[i], tmpF_fx ); // Q16
- move32();
- }
-
- FOR( i = 2 * NB_SUBFR16k - NB_SUBFR; i < 2 * NB_SUBFR16k; i++ )
- {
- st->old_pitch_buf_fx[i - 2] = Mpy_32_16_1( st->old_pitch_buf_fx[i], tmpF_fx ); // Q16
- move32();
- }
- }
- ELSE
- {
- exp = 0;
- move16();
- IF( EQ_16( st->last_L_frame, L_FRAME32k ) )
- {
- tmpF_fx = 16384; // Q15
- move16();
- }
- ELSE IF( EQ_16( st->last_L_frame, 512 ) )
- {
- tmpF_fx = 20480; // Q15
- move16();
- }
- ELSE /* st->last_L_frame == L_FRAME12k8 */
- {
- tmpF_fx = 20480; // Q14
- move16();
- exp = 1;
- move16();
- }
- FOR( i = 2 * NB_SUBFR - 1; i >= NB_SUBFR; i-- )
- {
- st->old_pitch_buf_fx[i + 2] = Mpy_32_16_1( L_shl( st->old_pitch_buf_fx[i], exp ), tmpF_fx ); // Q15
- move32();
- }
- st->old_pitch_buf_fx[NB_SUBFR + 1] = st->old_pitch_buf_fx[NB_SUBFR + 2];
- move32();
-
- FOR( i = NB_SUBFR - 1; i >= 0; i-- )
- {
- st->old_pitch_buf_fx[i + 1] = Mpy_32_16_1( L_shl( st->old_pitch_buf_fx[i], exp ), tmpF_fx ); // Q15
- move32();
- }
- st->old_pitch_buf_fx[0] = st->old_pitch_buf_fx[1];
- move32();
- }
- }
-
- IF( NE_16( st->bfi_pitch_frame, st->L_frame ) )
- {
- IF( EQ_16( st->L_frame, L_FRAME ) )
- {
- IF( EQ_16( st->bfi_pitch_frame, L_FRAME32k ) )
- {
- tmpF_fx = 13107; // Q15
- move16();
- }
- ELSE IF( EQ_16( st->bfi_pitch_frame, 512 ) )
- {
- tmpF_fx = 16384; // Q15
- move16();
- }
- ELSE /* st->bfi_pitch_frame == L_FRAME16k */
- {
- tmpF_fx = 26214; // Q15
- move16();
- }
- st->bfi_pitch_fx = mult_r( st->bfi_pitch_fx, tmpF_fx );
- move16();
- st->bfi_pitch_frame = L_FRAME;
- move16();
- }
- ELSE
- {
- exp = 0;
- move16();
- IF( EQ_16( st->bfi_pitch_frame, L_FRAME32k ) )
- {
- tmpF_fx = 16384; // Q15
- move16();
- }
- ELSE IF( EQ_16( st->bfi_pitch_frame, 512 ) )
- {
- tmpF_fx = 20480; // Q15
- move16();
- }
- ELSE /* st->bfi_pitch_frame == L_FRAME12k8 */
- {
- tmpF_fx = 20480; // Q14
- move16();
- exp = 1;
- move16();
- }
-
- st->bfi_pitch_fx = mult_r( shl_sat( st->bfi_pitch_fx, exp ), tmpF_fx );
- move16();
- st->bfi_pitch_frame = L_FRAME16k;
- move16();
- }
- }
-
- test();
- test();
- if ( EQ_16( st->last_bwidth, NB ) && NE_16( st->bwidth, NB ) && ( st->ini_frame != 0 ) )
- {
- st->rate_switching_reset = 1;
- move16();
- }
-
- /*----------------------------------------------------------------------*
- * GOOD frame
- *----------------------------------------------------------------------*/
-
- IF( !st->bfi )
- {
-
- /*----------------------------------------------------------------*
- * Decoding of TC subframe classification
- *----------------------------------------------------------------*/
-
- tc_subfr = -1;
- move16();
- IF( EQ_16( st->coder_type, TRANSITION ) )
- {
- tc_subfr = tc_classif_fx( st, st->L_frame );
- }
-
- /*----------------------------------------------------------------*
- * Decoding of GSC IVAS mode
- *----------------------------------------------------------------*/
-
- test();
- test();
- test();
- test();
- IF( st->element_mode > EVS_MONO && st->idchan == 0 && !( st->core_brate == FRAME_NO_DATA || EQ_32( st->core_brate, SID_2k40 ) ) && !tdm_low_rate_mode )
- {
- test();
- test();
- IF( EQ_16( st->coder_type, AUDIO ) || ( EQ_16( st->coder_type, INACTIVE ) && EQ_16( st->inactive_coder_type_flag, 1 ) ) )
- {
- st->GSC_IVAS_mode = get_next_indice_fx( st, 2 );
- move16();
- }
- }
-
- /*----------------------------------------------------------------*
- * Decoding of inactive CNG frames
- *----------------------------------------------------------------*/
-
- test();
- IF( st->core_brate == FRAME_NO_DATA || EQ_32( st->core_brate, SID_2k40 ) )
- {
- /* decode CNG parameters */
- IF( st->cng_type == LP_CNG )
- {
- CNG_dec_ivas_fx( st, last_element_mode, Aq_fx, lsp_new_fx, lsf_new_fx, &allow_cn_step, sid_bw, q_env_fx );
- Copy( Aq_fx, st->Aq_cng, add( M, 1 ) );
-
- /* comfort noise generation */
- local_element_mode = st->element_mode;
- move16();
-
- test();
- test();
- if ( ( EQ_16( nchan_out, 1 ) && EQ_16( st->element_mode, IVAS_CPE_DFT ) ) || EQ_16( st->masa_sid_format, 1 ) )
- {
- local_element_mode = IVAS_SCE; /* For DFT Stereo mono decoding, run CNG_exc as in SCE */
- move16();
- }
- CNG_exc_fx( st->core_brate, st->L_frame, &st->hTdCngDec->Enew_fx, &st->hTdCngDec->cng_seed, exc_fx, exc2_fx, &st->lp_ener_fx, st->last_core_brate, &st->first_CNG, &( st->hTdCngDec->cng_ener_seed ), bwe_exc_fx, allow_cn_step, &st->hTdCngDec->last_allow_cn_step, st->prev_Q_exc, st->Q_exc, st->hTdCngDec->num_ho, q_env_fx, st->hTdCngDec->lp_env_fx, st->hTdCngDec->old_env_fx, st->hTdCngDec->exc_mem_fx, st->hTdCngDec->exc_mem1_fx, sid_bw, &st->hTdCngDec->cng_ener_seed1, exc3_fx, st->Opt_AMR_WB, local_element_mode );
- }
- ELSE
- {
- test();
- IF( EQ_32( st->core_brate, SID_2k40 ) && NE_16( st->element_mode, IVAS_CPE_MDCT ) )
- {
-#ifdef REMOVE_EVS_DUPLICATES
- IF( EQ_16( st->element_mode, EVS_MONO ) )
- {
- FdCng_decodeSID_fx( st->hFdCngDec->hFdCngCom, st );
- }
- ELSE
-#endif
- {
- Word16 old_NoiseEstExp = st->hFdCngDec->hFdCngCom->sidNoiseEstExp;
- move16();
-
- FdCng_decodeSID_ivas_fx( st );
-
- Scale_sig32( st->hFdCngDec->hFdCngCom->sidNoiseEstLp, NPART, sub( old_NoiseEstExp, st->hFdCngDec->hFdCngCom->sidNoiseEstExp ) );
- Scale_sig( st->hFdCngDec->hFdCngCom->A_cng, M + 1, sub( norm_s( st->hFdCngDec->hFdCngCom->A_cng[0] ), Q2 ) ); // Qx
- }
-
- *sid_bw = 0;
- move16();
- }
-
- IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) )
- {
- assert( nchan_out == 1 );
-
- FOR( i = 0; i < NPART; i++ )
- {
- st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] = Madd_32_32( Mpy_32_32( STEREO_DFT_FD_FILT_Q31, st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] ),
- STEREO_DFT_FD_FILT_COMP_Q31, st->hFdCngDec->hFdCngCom->sidNoiseEst[i] );
- move32();
- }
-
- ApplyFdCng_ivas_fx( psyn_fx, st->Q_syn, NULL, 0, realBuffer_fx, imagBuffer_fx, NULL, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) );
-
- Word16 new_sidNoiseEstExp = 31 - Q4;
- move16();
- Scale_sig32( st->hFdCngDec->hFdCngCom->sidNoiseEstLp, NPART, sub( st->hFdCngDec->hFdCngCom->sidNoiseEstExp, new_sidNoiseEstExp ) ); // Q(31-sidNoiseEstExp)
- Scale_sig32( st->hFdCngDec->hFdCngCom->sidNoiseEst, NPART, sub( st->hFdCngDec->hFdCngCom->sidNoiseEstExp, new_sidNoiseEstExp ) ); // Q(31-sidNoiseEstExp)
- st->hFdCngDec->hFdCngCom->sidNoiseEstExp = new_sidNoiseEstExp;
- move16();
- Word16 new_cngNoiseLevelExp = 31 - Q4;
- move16();
- Scale_sig32( st->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, sub( st->hFdCngDec->hFdCngCom->cngNoiseLevelExp, new_cngNoiseLevelExp ) ); // Q(31-cngNoiseLevelExp)
- st->hFdCngDec->hFdCngCom->cngNoiseLevelExp = new_cngNoiseLevelExp;
- move16();
-
- test();
- ApplyFdCng_ivas_fx( psyn_fx, st->Q_syn, NULL, 0, realBuffer_fx, imagBuffer_fx, NULL, st, 0, ( EQ_16( st->coder_type, AUDIO ) && !st->GSC_noisy_speech ) );
-
- IF( st->hFdCngDec->hFdCngCom->cngNoiseLevelExp < 0 )
- {
- Scale_sig32( st->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, st->hFdCngDec->hFdCngCom->cngNoiseLevelExp ); // Q(31-cngNoiseLevelExp)
- st->hFdCngDec->hFdCngCom->cngNoiseLevelExp = 0;
- move16();
- }
- }
-
- IF( !read_sid_info )
- {
- Word32 noise_lvl_highest_fx;
-
- noise_lvl_highest_fx = st->hFdCngDec->hFdCngCom->cngNoiseLevel[( st->hFdCngDec->hFdCngCom->stopFFTbin - st->hFdCngDec->hFdCngCom->startBand ) - 1];
- move32();
-
- FOR( Word16 b = ( st->hFdCngDec->hFdCngCom->stopFFTbin - st->hFdCngDec->hFdCngCom->startBand ); b < st->hFdCngDec->hFdCngCom->stopBand; b++ )
- {
- st->hFdCngDec->hFdCngCom->cngNoiseLevel[b] = noise_lvl_highest_fx;
- move32();
- }
- }
-
-#ifdef REMOVE_EVS_DUPLICATES
- IF( EQ_16( st->element_mode, EVS_MONO ) )
- {
- generate_comfort_noise_dec_fx( NULL, NULL, NULL, st, &( st->Q_exc ), 2, -1 );
- }
- ELSE
-#endif
- {
- generate_comfort_noise_dec_ivas_fx( NULL, NULL, NULL, st, &( st->Q_exc ), 1, nchan_out );
- }
-
- FdCng_exc( st->hFdCngDec->hFdCngCom, &st->CNG_mode, st->L_frame, st->lsp_old_fx, st->first_CNG, st->lspCNG_fx, Aq_fx, lsp_new_fx, lsf_new_fx, exc_fx, exc2_fx, bwe_exc_fx );
-
- Copy( exc2_fx, exc3_fx, st->L_frame );
- }
-
- Word16 delta_mem_scale = 3;
- move16();
- test();
- if ( LT_32( st->lp_ener_fx, 40 ) && st->cng_type == LP_CNG ) /* very low energy frames, less than 0.3125 */
- {
- delta_mem_scale = 0;
- move16();
- }
- i = st->Q_exc;
- move16();
-
- test();
- IF( st->hMusicPF && st->hGSCDec )
- {
-#ifdef REMOVE_EVS_DUPLICATES
- IF( EQ_16( st->element_mode, EVS_MONO ) )
- {
- // VE: TBV: should 'st_fx->L_frame * HIBND_ACB_L_FAC' be corrected in EVS?
- Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, exc_fx, bwe_exc_fx, st->hGSCDec->last_exc_dct_in_fx, st->L_frame,
- st->L_frame * HIBND_ACB_L_FAC, 0, &( st->Q_exc ), st->Q_subfr, NULL, 0, INACTIVE );
- }
- ELSE
-#endif
- {
- Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, exc_fx, bwe_exc_fx, st->hGSCDec->last_exc_dct_in_fx, st->L_frame,
- L_FRAME32k, 0, &( st->Q_exc ), st->Q_subfr, NULL, 0, INACTIVE );
- }
- }
-
- IF( st->hPFstat != NULL )
- {
- Rescale_mem( st->Q_exc, &st->prev_Q_syn, &st->Q_syn, st->mem_syn2_fx, st->mem_syn_clas_estim_fx, delta_mem_scale,
- &st->mem_deemph_fx, st->hBPF->pst_old_syn_fx, &st->hBPF->pst_mem_deemp_err_fx, &st->agc_mem_fx[1], st->hPFstat, 0, 0, NULL );
- }
- ELSE
- {
- Rescale_mem( st->Q_exc, &st->prev_Q_syn, &st->Q_syn, st->mem_syn2_fx, st->mem_syn_clas_estim_fx, delta_mem_scale,
- &st->mem_deemph_fx, NULL, NULL, &st->agc_mem_fx[1], NULL, 0, 0, NULL );
- }
-
- Copy_Scale_sig( exc2_fx, exc2_fx, st->L_frame, sub( st->Q_exc, i ) ); // Q_exc
-
- /* update past excitation signals for LD music post-filter */
- IF( st->hMusicPF != NULL )
- {
- Copy( st->hMusicPF->dct_post_old_exc_fx + L_FRAME, st->hMusicPF->dct_post_old_exc_fx, DCT_L_POST - L_FRAME - OFFSET2 );
- Copy( exc2_fx, st->hMusicPF->dct_post_old_exc_fx + ( DCT_L_POST - L_FRAME - OFFSET2 ), L_FRAME );
-
- /* Update music post processing values */
- /* Filter energies update */
-#ifdef REMOVE_EVS_DUPLICATES
- IF( EQ_16( st->element_mode, EVS_MONO ) )
- {
- FOR( i = 0; i < DCT_L_POST; i++ )
- {
- st->hMusicPF->filt_lfE_fx[i] = round_fx( L_mac( ( 1228 << ( 16 ) ), 22938, st->hMusicPF->filt_lfE_fx[i] ) );
- move16();
- }
- }
- ELSE
-#endif
- {
- FOR( i = 0; i < DCT_L_POST; i++ )
- {
- st->hMusicPF->filt_lfE_fx[i] = add( 9830, mult_r( 22937, st->hMusicPF->filt_lfE_fx[i] ) ); // Q15, 9830 =.3f in Q15, 22937=.7f in Q15
- move16();
- }
- }
- }
-
- /* synthesis at 12.8kHz sampling rate */
- move16();
- syn_12k8_fx( st->L_frame, Aq_fx, exc2_fx, psyn_fx, st->mem_syn2_fx, 1, st->Q_exc, st->Q_syn );
- syn_12k8_fx( st->L_frame, Aq_fx, exc3_fx, syn1_fx, st->mem_syn3_fx, 1, st->Q_exc, st->Q_syn );
-
- /* reset the decoder */
- CNG_reset_dec_fx( st, pitch_buf_fx, voice_factors_fx );
-
-
-#ifdef REMOVE_EVS_DUPLICATES
- IF( EQ_16( st->element_mode, EVS_MONO ) )
- {
- /* update st_fx->mem_syn1 for ACELP core switching */
- Copy( st->mem_syn3_fx, st->mem_syn1_fx, M );
- }
- ELSE
-#endif
- {
- st->Q_syn_cng = st->Q_syn;
- move16();
- st->Q_exc_cng = st->Q_exc;
- move16();
-
- /* update st->mem_syn1 for ACELP core switching */
- Copy_Scale_sig( st->mem_syn3_fx, st->mem_syn1_fx, M, sub( -1, st->Q_syn ) ); // Q(-1)
- }
-
- /* update old synthesis for classification */
- Copy( syn1_fx + st->L_frame - L_SYN_MEM_CLAS_ESTIM, st->mem_syn_clas_estim_fx, L_SYN_MEM_CLAS_ESTIM );
-
- /* save and delay synthesis to be used by SWB BWE */
- Copy_Scale_sig( syn1_fx, temp_buf_fx, st->L_frame, sub( -1, st->Q_syn ) ); // Q_syn -> Q(-1)
- IF( st->hBWE_FD != NULL )
- {
- save_old_syn_fx( st->L_frame, temp_buf_fx, old_syn_12k8_16k_fx, st->hBWE_FD->old_syn_12k8_16k_fx, st->preemph_fac, &st->hBWE_FD->mem_deemph_old_syn_fx );
- }
- }
-
- /*----------------------------------------------------------------*
- * Decoding of all other frames
- *----------------------------------------------------------------*/
-
- ELSE
- {
-
- /*-----------------------------------------------------------------*
- * Configure ACELP bit allocation
- *-----------------------------------------------------------------*/
-
- nb_bits = 0;
- move16();
- st->acelp_cfg.FEC_mode = 0;
- move16();
- uc_two_stage_flag = 0;
- move16();
-
- test();
- IF( !st->nelp_mode_dec && !st->ppp_mode_dec )
- {
- Word16 tc_subfr_tmp;
-
- tc_subfr_tmp = tc_subfr;
- move16();
- if ( LT_16( tc_subfr_tmp, L_SUBFR ) )
- {
- tc_subfr_tmp = 0;
- move16();
- }
-
- if ( EQ_16( tc_subfr, TC_0_192 ) )
- {
- nb_bits = -1;
- move16();
- }
-
- config_acelp1_IVAS( DEC, st->total_brate, st->core_brate, st->core, st->extl_orig, st->extl_brate_orig, st->L_frame, st->GSC_noisy_speech, &( st->acelp_cfg ), st->next_bit_pos, st->coder_type, st->inactive_coder_type_flag, tc_subfr_tmp, 1, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode );
-
- test();
- test();
- IF( EQ_16( st->coder_type, TRANSITION ) && LT_16( tc_subfr, L_SUBFR ) && EQ_16( st->L_frame, L_FRAME ) )
- {
- config_acelp1_IVAS( DEC, st->total_brate, st->core_brate, st->core, st->extl_orig, st->extl_brate_orig, st->L_frame, -1, &( st->acelp_cfg ), st->next_bit_pos, TRANSITION, -1, tc_subfr, 2, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode );
- }
- }
-
- /*-----------------------------------------------------------------*
- * After CNG period, use the most up-to-date LSPs
- *-----------------------------------------------------------------*/
-
- test();
- test();
- IF( st->hTdCngDec != NULL && ( st->last_core_brate == FRAME_NO_DATA || EQ_32( st->last_core_brate, SID_2k40 ) ) )
- {
- Copy( st->lspCNG_fx, st->lsp_old_fx, M ); /*Q15*/
- lsp2lsf_fx( st->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_preemp_preQ_fx = 0;
- move16();
- st->last_nq_preQ = 0;
- move16();
- st->last_code_preq = 0;
- move16();
- }
-
- st->use_acelp_preq = 0;
- move16();
-
- /*-----------------------------------------------------------------*
- * LSF de-quantization and interpolation
- *-----------------------------------------------------------------*/
-
- IF( !tdm_lp_reuse_flag )
- {
- lsf_dec_ivas_fx( st, tc_subfr, Aq_fx, &LSF_Q_prediction, lsf_new_fx, lsp_new_fx, lsp_mid_fx, tdm_low_rate_mode, tdm_lsfQ_PCh_fx );
- }
- ELSE
- {
- const Word16 *pt_interp_2_fx;
-
- IF( NE_16( st->active_cnt, 1 ) )
- {
- Word16 beta_index;
-
- beta_index = get_next_indice_fx( st, TDM_IC_LSF_PRED_BITS );
- tdm_SCh_lsf_reuse_fx( DEC, st->element_brate, lsf_new_fx, lsp_new_fx, tdm_lsfQ_PCh_fx, NULL, &beta_index );
- }
- ELSE
- {
- Copy( tdm_lspQ_PCh_fx, lsp_new_fx, M );
- Copy( tdm_lsfQ_PCh_fx, lsf_new_fx, M );
- }
-
- IF( st->rate_switching_reset )
- {
- /* extrapolation in case of unstable LSF convert */
- Copy( lsp_new_fx, st->lsp_old_fx, M );
- Copy( lsf_new_fx, st->lsf_old_fx, M );
- }
-
- pt_interp_2_fx = interpol_frac_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_fx, st->lsp_old_fx, M );
- lsp2lsf_fx( lsp_new_fx, st->lsf_old_fx, M, st->sr_core );
- }
-
- /* LSP interpolation and conversion of LSPs to A(z) */
- int_lsp_fx( st->L_frame, st->lsp_old_fx, lsp_new_fx, Aq_fx, M, pt_interp_2_fx, 0 );
-
- /* Check LSF stability (distance between old LSFs and current LSFs) */
- st->stab_fac_fx = lsf_stab_ivas_fx( lsf_new_fx, st->lsf_old_fx, 0, st->L_frame );
- move16();
- }
-
- test();
- IF( EQ_16( st->last_core, HQ_CORE ) && st->element_mode > EVS_MONO )
- {
- /* Prepare ACB memory from last HQ frame */
- old_exc_s_fx = st->old_exc_fx + sub( L_EXC_MEM_DEC, st->L_frame );
- tmpF_fx = *old_exc_s_fx;
- st->mem_deemph_fx = shl_sat( old_exc_s_fx[st->L_frame - 1], st->Q_syn ); /* Q0 -> Q_syn */
- move16();
- PREEMPH_FX( old_exc_s_fx, st->preemph_fac, L_FRAME16k, &tmpF_fx );
- Copy( old_exc_s_fx + sub( st->L_frame, M ), st->mem_syn2_fx, M );
- Scale_sig( st->mem_syn2_fx, M, st->Q_syn ); /* Q0 -> Q_syn */
- Residu3_fx( Aq_fx, old_exc_s_fx, old_exc_fx + sub( L_EXC_MEM_DEC, st->L_frame ), st->L_frame, 0 );
- Scale_sig( old_exc_fx + sub( L_EXC_MEM_DEC, st->L_frame ), st->L_frame, st->Q_exc ); /* Q0 -> Q_exc */
- }
-
- 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 << 1, L_EXC_MEM_DEC );
- }
- }
-
- /*-----------------------------------------------------------------*
- * FEC - first good frame after lost frame(s) (possibility to correct the ACB)
- *-----------------------------------------------------------------*/
-
- IF( st->acelp_cfg.FEC_mode > 0 )
- {
- last_pulse_pos = 0;
- move16();
-
- /* decode the last glottal pulse position */
- T0_tmp = FEC_pos_dec_fx( st, &last_pulse_pos, &enr_q_fx, nb_bits );
-
- test();
- test();
- IF( NE_16( st->last_core, HQ_CORE ) || ( EQ_16( st->last_core, HQ_CORE ) && st->last_con_tcx ) )
- {
- test();
- test();
- test();
- test();
- test();
- test();
- IF( EQ_16( st->clas_dec, SIN_ONSET ) && last_pulse_pos != 0 && EQ_16( st->prev_bfi, 1 ) )
- {
- FEC_SinOnset_fx( old_exc_fx + L_EXC_MEM_DEC - L_EXC_MEM, last_pulse_pos, T0_tmp, enr_q_fx, Aq_fx, st->L_frame, st->Q_exc );
- }
- ELSE IF( ( EQ_16( st->coder_type, GENERIC ) || EQ_16( st->coder_type, VOICED ) ) && last_pulse_pos != 0 && EQ_16( st->old_bfi_cnt, 1 ) && st->hWIDec != NULL )
- {
- do_WI = FEC_enhACB_fx( st->L_frame, st->last_L_frame, old_exc_fx + L_EXC_MEM_DEC - L_EXC_MEM, T0_tmp, last_pulse_pos, st->bfi_pitch_fx );
- }
- }
- }
-
- /*------------------------------------------------------------*
- * In case of first frame after an erasure and transition from voiced to unvoiced or inactive
- * redo the LPC interpolation
- *------------------------------------------------------------*/
-
- test();
- test();
- test();
- test();
- test();
- test();
- IF( ( st->stab_fac_fx == 0 ) && ( st->old_bfi_cnt > 0 ) && NE_16( st->clas_dec, VOICED_CLAS ) && NE_16( st->clas_dec, ONSET ) && ( st->relax_prev_lsf_interp == 0 ) && !( EQ_16( st->element_mode, IVAS_CPE_TD ) && EQ_16( st->idchan, 1 ) ) )
- {
- int_lsp4_ivas_fx( st->L_frame, st->lsp_old_fx, lsp_mid_fx, lsp_new_fx, Aq_fx, M, 2 );
- }
-
- /*---------------------------------------------------------------*
- * Decoding of the scaled predicted innovation energy
- *---------------------------------------------------------------*/
-
- IF( nb_bits > 0 )
- {
- indice = get_next_indice_fx( st, nb_bits );
- Es_pred_dec_fx( &Es_pred_fx, indice, nb_bits, uc_two_stage_flag );
- }
-
- /*------------------------------------------------------------*
- * Decode 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_dec_fx( st, dct_exc_tmp_fx /*, &tmp_noise*/, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, lsf_new_fx );
- tmp_noise_fx = shr_r( st->lp_gainc_fx, 3 ); /*Q0*/
- }
- ELSE /* GENERIC */
- {
- decod_gen_2sbfr_ivas_fx( st, sharpFlag, Aq_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, gain_buf_fx, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf_fx );
-
- IF( EQ_16( st->element_mode, IVAS_CPE_TD ) )
- {
- tmp_noise_fx = shr_r( st->lp_gainc_fx, 3 ); /*Q0*/
- }
- }
- }
- ELSE IF( st->nelp_mode_dec )
- {
- Scale_sig( exc_fx - L_EXC_MEM, L_EXC_MEM, negate( st->Q_exc ) ); // Q0
- st->Q_exc = 0;
- move16();
-
- /* SC-VBR - NELP frames */
- decod_nelp_fx( st, &tmp_noise_fx, pitch_buf_fx, exc_fx, exc2_fx, voice_factors_fx, bwe_exc_fx, &st->Q_exc, st->bfi, gain_buf_fx );
-
- Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, exc_fx, NULL, st->hGSCDec->last_exc_dct_in_fx, L_FRAME, 0, (Word32) 0, &( st->Q_exc ), st->Q_subfr, exc2_fx, L_FRAME, st->coder_type );
- }
- ELSE IF( EQ_16( st->coder_type, UNVOICED ) )
- {
- /* UNVOICED frames */
- decod_unvoiced_ivas_fx( st, Aq_fx, Es_pred_fx, uc_two_stage_flag, st->coder_type, &tmp_noise_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, gain_buf_fx );
-
- tmp_noise_fx = shr_r( st->lp_gainc_fx, 3 ); /*Q0*/
- }
- ELSE IF( st->ppp_mode_dec )
- {
- Scale_sig( exc_fx - L_EXC_MEM, L_EXC_MEM, negate( st->Q_exc ) ); // Q0
- st->Q_exc = 0;
- move16();
-
- /* SC-VBR - PPP frames */
- IF( NE_32( ( error = decod_ppp_fx( st, Aq_fx, pitch_buf_fx, exc_fx, exc2_fx, st->bfi, gain_buf_fx, voice_factors_fx, bwe_exc_fx ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, exc_fx, NULL, st->hGSCDec->last_exc_dct_in_fx, L_FRAME, 0, (Word32) 0, &( st->Q_exc ), st->Q_subfr, exc2_fx, L_FRAME, st->coder_type );
- }
- ELSE IF( EQ_16( st->coder_type, TRANSITION ) )
- {
- decod_tran_fx( st, st->L_frame, tc_subfr, Aq_fx, Es_pred_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, unbits, sharpFlag, gain_buf_fx );
- }
- ELSE IF( EQ_16( st->coder_type, AUDIO ) || ( ( st->coder_type == INACTIVE ) && st->inactive_coder_type_flag ) )
- {
- /* AUDIO and INACTIVE frames (coded by GSC technology) */
- decod_audio_ivas_fx( st, dct_exc_tmp_fx, Aq_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, lsf_new_fx, gain_buf_fx,
- tdm_lp_reuse_flag, tdm_low_rate_mode, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf_fx );
-
- tmp_noise_fx = shr_r( st->lp_gainc_fx, 3 ); /*Q0*/
- }
- ELSE
- {
- /* GENERIC, VOICED and INACTIVE frames (coded by AVQ technology) */
- IF( NE_32( ( error = decod_gen_voic_ivas_fx( st, st->L_frame, sharpFlag, Aq_fx, Es_pred_fx, do_WI, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, unbits, gain_buf_fx, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf_fx ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- IF( EQ_16( st->element_mode, IVAS_CPE_TD ) )
- {
- tmp_noise_fx = shr_r( st->lp_gainc_fx, 3 ); /*Q0*/
- }
- }
-
- /* synthesis for ACELP core switching and SWB BWE */
- syn_12k8_fx( st->L_frame, Aq_fx, exc_fx, temp_buf_fx, st->mem_syn1_fx, 1, st->Q_exc, -1 );
-
- /* save and delay synthesis to be used by SWB BWE */
- IF( st->hBWE_FD != NULL )
- {
- save_old_syn_fx( st->L_frame, temp_buf_fx, old_syn_12k8_16k_fx, st->hBWE_FD->old_syn_12k8_16k_fx, st->preemph_fac, &st->hBWE_FD->mem_deemph_old_syn_fx );
- }
-
- /*-----------------------------------------------------------------*
- * Apply energy matching when switching to inactive frames
- *-----------------------------------------------------------------*/
-
- Inac_switch_ematch_ivas_fx( exc2_fx, dct_exc_tmp_fx, st->hGSCDec->lt_ener_per_band_fx, st->coder_type, st->inactive_coder_type_flag, st->L_frame, st->Q_exc, st->bfi, st->last_core, st->last_codec_mode, tdm_low_rate_mode, st->element_mode );
-
- /*------------------------------------------------------------*
- * Decode information and modify the excitation signal of stationary unvoiced frames
- *------------------------------------------------------------*/
-
- test();
- test();
- test();
- test();
- IF( !( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) ) && NE_16( st->nelp_mode_dec, 1 ) && !( EQ_16( st->element_mode, IVAS_SCE ) && tdm_low_rate_mode ) )
- {
- stat_noise_uv_dec_fx( st, lsp_new_fx, lsp_mid_fx, Aq_fx, exc2_fx, uc_two_stage_flag );
- }
-
- /*------------------------------------------------------------*
- * Save filter memory in case the synthesis is redone after scaling
- * Synthesis at 12k8 Hz sampling rate
- *------------------------------------------------------------*/
-
- /* update past excitation signals for LD music post-filter */
- IF( st->hMusicPF != NULL )
- {
- Copy( st->hMusicPF->dct_post_old_exc_fx + L_FRAME, st->hMusicPF->dct_post_old_exc_fx, DCT_L_POST - L_FRAME - OFFSET2 );
- Copy( exc2_fx, st->hMusicPF->dct_post_old_exc_fx + ( DCT_L_POST - L_FRAME - OFFSET2 ), L_FRAME );
- Copy( st->hMusicPF->dct_post_old_exc_fx, exc_buffer_fx, DCT_L_POST - OFFSET2 );
- }
-
- test();
- test();
- test();
- IF( ( EQ_16( st->coder_type, AUDIO ) && !st->GSC_noisy_speech ) || ( GE_16( st->GSC_IVAS_mode, 1 ) && EQ_16( st->L_frame, L_FRAME ) ) )
- {
- Word16 last_coder_type = st->last_coder_type;
- move16();
-
- test();
- test();
- test();
- if ( ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) ) || ( GE_16( st->GSC_IVAS_mode, 1 ) && ( st->GSC_noisy_speech == 0 ) ) )
- {
- last_coder_type = AUDIO;
- move16();
- }
-
- Word16 qdct = 0;
- move16();
-
- /* Extrapolation of the last future part, windowing and high resolution DCT transform */
-#ifdef REMOVE_EVS_DUPLICATES
- IF( EQ_16( st->element_mode, EVS_MONO ) )
- {
- // VE: TBV: this is likely a bug in EVS - 'st->last_coder_type' should be replaced by 'st->core_brate'
- Prep_music_postP_fx( exc_buffer_fx, dct_buffer_fx, st->hMusicPF->filt_lfE_fx, st->last_coder_type, st->element_mode, pitch_buf_fx,
- st->hMusicPF->LDm_enh_lp_gbin_fx, st->Q_exc, &qdct );
- }
- ELSE
-#endif
- {
- Prep_music_postP_fx( exc_buffer_fx, dct_buffer_fx, st->hMusicPF->filt_lfE_fx, st->last_core, st->element_mode, pitch_buf_fx, st->hMusicPF->LDm_enh_lp_gbin_fx, st->Q_exc, &qdct );
- }
-
- /* LD music post-filter */
- LD_music_post_filter_fx( st->hMusicPF, dct_buffer_fx, dct_buffer_fx, st->core_brate, &st->hMusicPF->Old_ener_Q, AUDIO, last_coder_type, qdct );
-
- /* Inverse DCT transform, retrieval of the aligned excitation, re-synthesis */
-#ifdef REMOVE_EVS_DUPLICATES
- IF( NE_16( st->element_mode, EVS_MONO ) ) // VE: TBC whether needed in IVAS
-#endif
- {
- Copy( st->mem_syn2_fx, mem_tmp_fx, M ); /*Q_syn*/
- }
-
- Post_music_postP_fx( dct_buffer_fx, exc2_fx, st->mem_syn2_fx, st->mem_syn2_fx, Aq_fx, psyn_fx, &st->Q_exc, &st->prev_Q_syn,
- &st->Q_syn, st->mem_syn_clas_estim_fx, 0, &st->mem_deemph_fx, st->hBPF->pst_old_syn_fx,
- &st->hBPF->pst_mem_deemp_err_fx, &st->agc_mem_fx[1], st->hPFstat, temp_buf_fx, mem_tmp_fx );
- }
- ELSE
- {
- /* Core synthesis at 12.8kHz or 16kHz */
- i = 1;
- move16();
- test();
- if ( st->coder_type == INACTIVE && st->element_mode == EVS_MONO )
- {
- i = 0;
- move16();
- }
-
- /* add extra headroom in case a CNA addition is likely (i.e. st_fx->psf_lp_noise_fx is close to the threshold) */
- Word16 k = 0;
- move16();
- test();
- test();
- if ( st->coder_type == INACTIVE && st->flag_cna && GE_16( round_fx( L_shl( st->lp_noise, 1 ) ), 15 << 7 ) )
- {
- k = 1;
- move16();
- }
-
- Rescale_mem( st->Q_exc, &st->prev_Q_syn, &st->Q_syn, st->mem_syn2_fx, st->mem_syn_clas_estim_fx, 4, &st->mem_deemph_fx,
- st->hBPF->pst_old_syn_fx, &st->hBPF->pst_mem_deemp_err_fx, &st->agc_mem_fx[1], st->hPFstat, i, k, temp_buf_fx );
-
- Copy( st->mem_syn2_fx, mem_tmp_fx, M ); /*Q_syn*/
- syn_12k8_fx( st->L_frame, Aq_fx, exc2_fx, psyn_fx, st->mem_syn2_fx, 1, st->Q_exc, st->Q_syn );
-
- IF( st->hMusicPF != NULL )
- {
- FOR( i = 0; i < DCT_L_POST; i++ )
- {
- st->hMusicPF->filt_lfE_fx[i] = round_fx( L_mac( ( 1228 << ( 16 ) ), 22938, st->hMusicPF->filt_lfE_fx[i] ) );
- move16();
- }
- }
- }
-
- /*------------------------------------------------------------*
- * FEC - Estimate the classification information
- *------------------------------------------------------------*/
-
- FEC_clas_estim_fx( st, st->Opt_AMR_WB, st->L_frame, &st->clas_dec, st->coder_type, pitch_buf_fx, psyn_fx, &st->lp_ener_FER_fx, &st->decision_hyst,
- NULL, NULL, NULL, NULL, 0, NULL, st->Q_syn, temp_buf_fx, st->mem_syn_clas_estim_fx, &st->classifier_Q_mem_syn, 0, 0, 0, st->last_core_brate, st->acelp_cfg.FEC_mode );
-
- /*------------------------------------------------------------*
- * FEC - Estimate pitch
- *------------------------------------------------------------*/
-
- FEC_pitch_estim_fx( st->Opt_AMR_WB, st->last_core, st->L_frame, st->clas_dec, st->last_good, pitch_buf_fx, st->old_pitch_buf_fx,
- &st->bfi_pitch_fx, &st->bfi_pitch_frame, &st->upd_cnt, st->coder_type, st->element_mode );
-
- /*------------------------------------------------------------*
- * FEC - Smooth the speech energy evolution when recovering after a BAD frame
- * (smoothing is performed in the excitation domain and signal is resynthesized after)
- *------------------------------------------------------------*/
-
- Copy_Scale_sig( pitch_buf_fx, pitch_buf_tmp, st->nb_subfr, -Q6 ); // Q0
-
- FEC_scale_syn_ivas_fx( st->L_frame, &update_flg, st->clas_dec, st->last_good, psyn_fx, pitch_buf_tmp, st->enr_old_fx, enr_q_fx, st->coder_type, LSF_Q_prediction,
- &st->scaling_flag, &st->lp_ener_FEC_av, &st->lp_ener_FEC_max, st->bfi, st->total_brate, st->prev_bfi, st->last_core_brate,
-#ifdef REMOVE_EVS_DUPLICATES
- exc_fx, exc2_fx, Aq_fx, &st->old_enr_LP, mem_tmp_fx, st->mem_syn2_fx, st->Q_exc, st->Q_syn, st->element_mode, avoid_lpc_burst_on_recovery, 0 );
-#else
- exc_fx, exc2_fx, Aq_fx, &st->old_enr_LP, mem_tmp_fx, st->mem_syn2_fx, st->Q_exc, st->Q_syn, avoid_lpc_burst_on_recovery, 0 );
-#endif
-
- test();
- test();
- test();
- test();
- /* estimate the pitch-synchronous speech energy per sample to be used when normal operation recovers */
- IF( ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) && LE_32( st->total_brate, ACELP_7k20 ) ) || EQ_32( st->total_brate, ACELP_7k20 ) || EQ_32( st->total_brate, ACELP_8k00 ) )
- {
- frame_ener_fx( st->L_frame, st->clas_dec, psyn_fx, pitch_buf_tmp[( ( st->L_frame ) >> 6 ) - 1], &st->enr_old_fx, st->L_frame, st->Q_syn, 3, 0 );
- }
- }
-
- } /* End of GOOD FRAME */
-
- /*----------------------------------------------------------------*
- * BAD frame
- *----------------------------------------------------------------*/
-
- ELSE
- {
- /* SC-VBR */
- if ( EQ_16( st->last_nelp_mode_dec, 1 ) )
- {
- st->nelp_mode_dec = 1;
- move16();
- }
-
- test();
- test();
- /* long burst frame erasures */
- if ( GT_16( st->nbLostCmpt, 5 ) && GE_16( st->clas_dec, VOICED_CLAS ) && LT_16( st->clas_dec, INACTIVE_CLAS ) )
- {
- st->last_good = VOICED_TRANSITION;
- move16();
- }
-
- /* LSF estimation and A(z) calculation */
- lsf_dec_bfi( MODE1, lsf_new_fx, st->lsf_old_fx, st->lsf_adaptive_mean_fx, NULL, st->mem_MA_fx, st->mem_AR_fx, st->stab_fac_fx, st->last_coder_type, st->L_frame, st->last_good, st->nbLostCmpt, 0, NULL, NULL, NULL, st->hGSCDec->Last_GSC_pit_band_idx, st->Opt_AMR_WB, 0, st->bwidth );
-
- FEC_lsf2lsp_interp( st, st->L_frame, Aq_fx, lsf_new_fx, lsp_new_fx );
- IF( EQ_16( st->nelp_mode_dec, 1 ) )
- {
- /* SC-VBR */
- Scale_sig( exc_fx - L_EXC_MEM, L_EXC_MEM, negate( st->Q_exc ) ); // Q0
- st->Q_exc = 0;
- move16();
-
- decod_nelp_fx( st, &tmp_noise_fx, pitch_buf_fx, exc_fx, exc2_fx, voice_factors_fx, bwe_exc_fx, &st->Q_exc, st->bfi, gain_buf_fx );
- FEC_pitch_fx = pitch_buf_fx[3];
- move16();
- Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, exc_fx, NULL, st->hGSCDec->last_exc_dct_in_fx, L_FRAME, 0, (Word32) 0, &( st->Q_exc ), st->Q_subfr, exc2_fx, L_FRAME, st->coder_type );
- }
- ELSE
- {
- /* calculation of excitation signal */
- FEC_exc_estim_fx( st, st->L_frame, exc_fx, exc2_fx, dct_exc_tmp_fx, pitch_buf_fx, voice_factors_fx, &FEC_pitch_fx, bwe_exc_fx, lsf_new_fx, &st->Q_exc, &tmp_noise_fx );
-
- Rescale_exc( NULL, exc_fx, bwe_exc_fx, st->hGSCDec->last_exc_dct_in_fx, st->L_frame, L_FRAME32k, (Word32) 0,
- &( st->Q_exc ), st->Q_subfr, exc2_fx, st->L_frame, st->last_coder_type );
-
- tmp_noise_fx = shr_r( st->lp_gainc_fx, 3 ); /*Q0*/
-
- /* SC-VBR */
- st->prev_gain_pit_dec_fx = st->lp_gainp_fx;
- move16();
- }
-
- /* synthesis for ACELP core switching and SWB BWE */
- syn_12k8_fx( st->L_frame, Aq_fx, exc_fx, temp_buf_fx, st->mem_syn1_fx, 1, st->Q_exc, -1 );
-
- /* save and delay synthesis to be used by SWB BWE */
- IF( st->hBWE_FD != NULL )
- {
- save_old_syn_fx( st->L_frame, temp_buf_fx, old_syn_12k8_16k_fx, st->hBWE_FD->old_syn_12k8_16k_fx, st->preemph_fac, &st->hBWE_FD->mem_deemph_old_syn_fx );
- }
-
- /* Apply energy matching when switching to inactive frames */
- Inac_switch_ematch_ivas_fx( exc2_fx, dct_exc_tmp_fx, st->hGSCDec->lt_ener_per_band_fx, st->coder_type, st->inactive_coder_type_flag, st->L_frame, st->Q_exc, st->bfi, st->last_core, st->last_codec_mode, tdm_low_rate_mode, st->element_mode );
-
- /* update past excitation signals for LD music post-filter */
- IF( st->hMusicPF != NULL )
- {
- Copy( st->hMusicPF->dct_post_old_exc_fx + L_FRAME, st->hMusicPF->dct_post_old_exc_fx, DCT_L_POST - L_FRAME - OFFSET2 );
- Copy( exc2_fx, st->hMusicPF->dct_post_old_exc_fx + ( DCT_L_POST - L_FRAME - OFFSET2 ), L_FRAME );
-
- /* Update music post processing values */
- /* Filter energies update */
- FOR( i = 0; i < DCT_L_POST; i++ )
- {
- st->hMusicPF->filt_lfE_fx[i] = round_fx( L_mac( 1228 << 16, 22938, st->hMusicPF->filt_lfE_fx[i] ) );
- move16();
- }
-
- /* Update circular buffer, keep last energy difference unchanged */
- FOR( i = 1; i < MAX_LT; i++ )
- {
- st->hMusicPF->LDm_lt_diff_etot_fx[i - 1] = st->hMusicPF->LDm_lt_diff_etot_fx[i];
- move16();
- }
- }
-
- /* synthesis at 12k8 Hz sampling rate */
- /* add extra headroom in case a CNA addition is likely (i.e. st_fx->psf_lp_noise_fx is close to the threshold) */
- Word16 k = 0;
- move16();
- test();
- test();
- if ( st->coder_type == INACTIVE && st->flag_cna && GE_16( round_fx( L_shl( st->lp_noise, 1 ) ), 15 << 7 ) )
- {
- k = 1;
- move16();
- }
-
- Rescale_mem( st->Q_exc, &st->prev_Q_syn, &st->Q_syn, st->mem_syn2_fx, st->mem_syn_clas_estim_fx, 4, &st->mem_deemph_fx,
- st->hBPF->pst_old_syn_fx, &st->hBPF->pst_mem_deemp_err_fx, &st->agc_mem_fx[1], st->hPFstat, 1, k, temp_buf_fx );
-
- test();
- IF( EQ_32( st->total_brate, ACELP_7k20 ) || EQ_32( st->total_brate, ACELP_8k00 ) )
- {
- Copy( st->mem_syn2_fx, mem_tmp_fx, M );
- }
- syn_12k8_fx( st->L_frame, Aq_fx, exc2_fx, psyn_fx, st->mem_syn2_fx, 1, st->Q_exc, st->Q_syn );
-
- /* update buffer for classifier */
- IF( st->hWIDec != NULL )
- {
- Copy( exc2_fx + sub( st->L_frame, L_EXC_MEM ), st->hWIDec->old_exc2_fx, L_EXC_MEM );
- Copy( psyn_fx + sub( st->L_frame, L_EXC_MEM ), st->hWIDec->old_syn2_fx, L_EXC_MEM );
- }
- st->prev_Q_exc_fr = st->Q_exc;
- move16();
- st->prev_Q_syn_fr = st->Q_syn;
- move16();
- Copy( psyn_fx + sub( st->L_frame, L_SYN_MEM_CLAS_ESTIM ), st->mem_syn_clas_estim_fx, L_SYN_MEM_CLAS_ESTIM );
-
- /*------------------------------------------------------------*
- * FEC - Smooth the speech energy evolution when recovering after a BAD frame
- * (smoothing is performed in the excitation domain and signal is resynthesized after)
- *------------------------------------------------------------*/
-
- test();
- IF( EQ_32( st->total_brate, ACELP_7k20 ) || EQ_32( st->total_brate, ACELP_8k00 ) )
- {
- Copy_Scale_sig( pitch_buf_fx, pitch_buf_tmp, st->nb_subfr, -Q6 ); // Q0
-
- FEC_scale_syn_ivas_fx( st->L_frame, &update_flg, st->clas_dec, st->last_good, psyn_fx, pitch_buf_tmp, st->enr_old_fx, enr_q_fx, st->coder_type, LSF_Q_prediction,
- &st->scaling_flag, &st->lp_ener_FEC_av, &st->lp_ener_FEC_max, st->bfi, st->total_brate, st->prev_bfi, st->last_core_brate,
-#ifdef REMOVE_EVS_DUPLICATES
- exc_fx, exc2_fx, Aq_fx, &st->old_enr_LP, mem_tmp_fx, st->mem_syn2_fx, st->Q_exc, st->Q_syn, st->element_mode, avoid_lpc_burst_on_recovery, 0 );
-#else
- exc_fx, exc2_fx, Aq_fx, &st->old_enr_LP, mem_tmp_fx, st->mem_syn2_fx, st->Q_exc, st->Q_syn, avoid_lpc_burst_on_recovery, 0 );
-#endif
- }
-
- /* estimate the pitch-synchronous speech energy per sample to be used when normal operation recovers */
- frame_ener_fx( st->L_frame, st->last_good, psyn_fx, shr( add( FEC_pitch_fx, 32 ), 6 ), &st->enr_old_fx, st->L_frame, st->Q_syn, 3, 0 );
-
- IF( NE_16( st->nelp_mode_dec, 1 ) )
- {
- /* modify the excitation signal of stationary unvoiced frames */
- stat_noise_uv_mod_fx( st->coder_type, 0, st->lsp_old_fx, lsp_new_fx, lsp_new_fx, Aq_fx, exc2_fx, st->Q_exc, 1, &st->ge_sm_fx,
- &st->uv_count, &st->act_count, st->lspold_s_fx, &st->noimix_seed, &st->min_alpha_fx,
- &st->exc_pe_fx, st->core_brate, st->bwidth, &st->Q_stat_noise, &st->Q_stat_noise_ge );
- }
- }
-
- IF( st->hBWE_TD != NULL )
- {
- IF( EQ_16( st->L_frame, L_FRAME ) )
- {
- Copy( Aq_fx + 2 * ( M + 1 ), st->hBWE_TD->cur_sub_Aq_fx, ( M + 1 ) );
- }
- ELSE
- {
- Copy( Aq_fx + 3 * ( M + 1 ), st->hBWE_TD->cur_sub_Aq_fx, ( M + 1 ) );
- }
- }
-
- /*--------------------------------------------------------*
- * Apply NB postfilter in case of 8kHz output
- *--------------------------------------------------------*/
-
- test();
- IF( st->last_bwidth == NB && st->hPFstat != NULL )
- {
- Copy_Scale_sig( pitch_buf_fx, pitch_buf_tmp, st->nb_subfr, -Q6 ); // Q0
-
- IF( st->bwidth == NB )
- {
- st->hPFstat->on = 1;
- move16();
- nb_post_filt_fx( st->L_frame, st->hPFstat, &st->psf_lp_noise_fx, tmp_noise_fx, psyn_fx, Aq_fx, pitch_buf_tmp, st->coder_type, st->BER_detect, 0 );
- }
- ELSE
- {
- st->hPFstat->on = 0;
- move16();
- nb_post_filt_fx( st->L_frame, st->hPFstat, &st->psf_lp_noise_fx, tmp_noise_fx, psyn_fx, Aq_fx, pitch_buf_tmp, AUDIO, st->BER_detect, 0 );
- }
- }
- ELSE
- {
- st->psf_lp_noise_fx = round_fx( L_shl( st->lp_noise, 1 ) );
- move16();
- }
-
- /*------------------------------------------------------------------*
- * Perform fixed deemphasis through 1/(1 - g*z^-1)
- *-----------------------------------------------------------------*/
-
- /* update old synthesis buffer - needed for ACELP internal sampling rate switching */
- Copy( psyn_fx + sub( st->L_frame, L_SYN_MEM ), st->mem_syn_r, L_SYN_MEM );
- deemph_fx( psyn_fx, st->preemph_fac, st->L_frame, &( st->mem_deemph_fx ) );
- unscale_AGC( psyn_fx, st->Q_syn, syn_fx_tmp2, st->agc_mem_fx, st->L_frame );
- Copy( syn_fx_tmp2, psyn_fx, st->L_frame );
- IF( st->hTcxDec != NULL )
- {
- Copy_Scale_sig( psyn_fx + shr( st->L_frame, 1 ), st->hTcxDec->old_syn_Overl, shr( st->L_frame, 1 ), sub( -1, st->Q_syn ) ); /*Q-1*/
- st->hTcxDec->Q_old_syn_Overl = -1;
- }
- Copy_Scale_sig( psyn_fx + sub( st->L_frame, M + 1 ), st->syn, M + 1, sub( 0, st->Q_syn ) ); /*Q0*/
-
- /*------------------------------------------------------------------*
- * Formant post-filter
- *-----------------------------------------------------------------*/
-
- test();
- test();
- test();
- test();
- IF( st->hPFstat != NULL && GE_16( st->last_bwidth, WB ) && ( GT_32( st->core_brate, ACELP_24k40 ) || st->element_mode > EVS_MONO ) && LE_32( st->core_brate, ACELP_32k ) )
- {
- st->hPFstat->on = 1;
- move16();
- Copy( psyn_fx, temp_buf_fx + L_SYN_MEM, L_FRAME16k );
- set16_fx( st->hPFstat->mem_zero, 0, M );
-
- formant_post_filt_ivas_fx( st->hPFstat, temp_buf_fx + L_SYN_MEM, Aq_fx, psyn_fx, st->L_frame, st->lp_noise, st->total_brate, 0 );
- }
- ELSE IF( st->hPFstat != NULL && GE_16( st->last_bwidth, WB ) )
- {
- IF( st->hPFstat->on )
- {
- Copy( st->hPFstat->mem_pf_in + L_SYN_MEM - M, temp_buf_fx, M );
- Copy( psyn_fx, temp_buf_fx + M, L_SUBFR );
-
- Residu3_fx( Aq_fx, temp_buf_fx + M, temp_buf_fx + M + L_SUBFR, L_SUBFR, 1 );
- E_UTIL_synthesis( 1, Aq_fx, temp_buf_fx + M + L_SUBFR, temp_buf_fx, L_SUBFR, st->hPFstat->mem_stp + L_SYN_MEM - M, 0, M );
- scale_st_fx( psyn_fx, temp_buf_fx, &st->hPFstat->gain_prec, L_SUBFR );
- Copy( temp_buf_fx, psyn_fx, ( L_SUBFR >> 1 ) );
- blend_subfr2_fx( temp_buf_fx + L_SUBFR / 2, psyn_fx + L_SUBFR / 2, psyn_fx + L_SUBFR / 2 );
- }
- st->hPFstat->on = 0;
- move16();
- }
-
- /*----------------------------------------------------------------*
- * Comfort noise addition
- *----------------------------------------------------------------*/
-
- test();
- test();
- IF( ( st->hFdCngDec != NULL || EQ_16( st->idchan, 1 ) ) && NE_16( st->element_mode, IVAS_CPE_MDCT ) )
- {
- test();
- test();
- test();
- test();
- test();
- IF( EQ_16( st->element_mode, IVAS_CPE_TD ) || st->flag_cna || ( EQ_16( st->cng_type, FD_CNG ) && LE_32( st->total_brate, ACELP_32k ) ) || ( st->cng_type == LP_CNG && LE_32( st->core_brate, SID_2k40 ) ) )
- {
- /*VAD only for non inactive frame*/
- test();
- st->VAD = st->VAD && st->coder_type != INACTIVE;
- move16();
- test();
- test();
- test();
- test();
- test();
- IF( st->idchan == 0 && ( st->flag_cna || ( EQ_16( st->cng_type, FD_CNG ) && LE_32( st->total_brate, ACELP_32k ) ) || ( st->cng_type == LP_CNG && LE_32( st->core_brate, SID_2k40 ) ) ) )
- {
- /*Noisy speech detector*/
- noisy_speech_detection_fx( st->hFdCngDec, st->VAD, psyn_fx, st->Q_syn );
-
- st->hFdCngDec->hFdCngCom->likelihood_noisy_speech = mult_r( st->hFdCngDec->hFdCngCom->likelihood_noisy_speech, 32440 /*0.99 Q15*/ );
- move16();
- IF( st->hFdCngDec->hFdCngCom->flag_noisy_speech != 0 )
- {
- st->hFdCngDec->hFdCngCom->likelihood_noisy_speech = add( st->hFdCngDec->hFdCngCom->likelihood_noisy_speech, 328 /*0.01 Q15*/ );
- move16();
- }
- move32();
- }
-
- if ( st->idchan == 0 )
- {
- st->lp_noise = st->hFdCngDec->lp_noise;
- move32();
- }
-
- test();
- IF( NE_16( st->element_mode, IVAS_CPE_TD ) && !st->cng_ism_flag )
- {
- /* Noise estimate */
- ApplyFdCng_ivas_fx( psyn_fx, st->Q_syn, NULL, 0, realBuffer_fx, imagBuffer_fx, NULL, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) );
- }
-
- IF( !st->cna_dirac_flag )
- {
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- /* CNA: Generate additional comfort noise to mask potential coding artefacts */
- IF( st->flag_cna && !( EQ_16( st->coder_type, AUDIO ) && !( st->element_mode > EVS_MONO && st->GSC_noisy_speech ) ) )
- {
- test();
- IF( EQ_16( st->element_mode, IVAS_CPE_TD ) && EQ_16( nchan_out, 2 ) )
- {
- IF( hStereoCng->flag_cna_fade )
- {
- generate_stereo_masking_noise_fx( psyn_fx, st->Q_syn, st, hStereoTD, flag_sec_CNA, 1, hStereoCng, nchan_out );
- hStereoCng->flag_cna_fade = 0;
- move16();
- }
- ELSE
- {
- test();
- IF( NE_16( st->element_mode, last_element_mode ) && ( st->idchan == 0 ) )
- {
- /* Clear memory for secondary channel CNA */
- set16_fx( hStereoCng->olapBufferSynth22_fx, 0, shr( st->hFdCngDec->hFdCngCom->frameSize, 1 ) );
- }
-
- generate_stereo_masking_noise_fx( psyn_fx, st->Q_syn, st, hStereoTD, flag_sec_CNA, 0, hStereoCng, nchan_out );
- }
- }
- ELSE IF( NE_16( st->element_mode, IVAS_CPE_DFT ) )
- {
-#ifdef REMOVE_EVS_DUPLICATES
- IF( EQ_16( st->element_mode, EVS_MONO ) )
- {
- generate_masking_noise_fx( psyn_fx, st->Q_syn, st->hFdCngDec->hFdCngCom, st->hFdCngDec->hFdCngCom->frameSize, 0 );
- }
- ELSE
-#endif
- {
- IF( st->idchan == 0 )
- {
- IF( NE_16( st->element_mode, last_element_mode ) )
- {
- set16_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2, 0, st->hFdCngDec->hFdCngCom->fftlen );
- }
- Word32 psyn_32_fx[L_FRAME16k];
- Copy_Scale_sig_16_32_no_sat( psyn_fx, psyn_32_fx, st->hFdCngDec->hFdCngCom->frameSize, sub( Q6, st->Q_syn ) ); // Q6
- Copy_Scale_sig_16_32_no_sat( st->hFdCngDec->hFdCngCom->olapBufferSynth2, st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, shl( st->hFdCngDec->hFdCngCom->frameSize, 1 ), Q15 ); // Q15
- generate_masking_noise_ivas_fx( psyn_32_fx, &exp, st->hFdCngDec->hFdCngCom, st->hFdCngDec->hFdCngCom->frameSize, 0, 0, 0, st->element_mode, hStereoCng, nchan_out );
- Copy_Scale_sig_32_16( psyn_32_fx, psyn_fx, st->hFdCngDec->hFdCngCom->frameSize, sub( st->Q_syn, exp ) ); // Q = st->Q_syn
- Copy_Scale_sig_32_16( st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth2, shl( st->hFdCngDec->hFdCngCom->frameSize, 1 ), -Q15 ); // Q0
- }
- }
- }
- }
- ELSE IF( st->flag_cna && EQ_16( st->coder_type, AUDIO ) && ( ( st->last_core == ACELP_CORE && !( EQ_16( st->last_coder_type, AUDIO ) && !( st->element_mode > EVS_MONO && st->Last_GSC_noisy_speech_flag ) ) ) || EQ_16( st->last_core, TCX_20_CORE ) ) )
- {
- test();
- IF( EQ_16( st->element_mode, IVAS_CPE_TD ) && EQ_16( nchan_out, 2 ) )
- {
- generate_stereo_masking_noise_fx( psyn_fx, st->Q_syn, st, hStereoTD, flag_sec_CNA, 1, hStereoCng, nchan_out );
- hStereoCng->flag_cna_fade = 1;
- move16();
- }
- ELSE
- {
- FOR( i = 0; i < ( st->hFdCngDec->hFdCngCom->frameSize ) / 2; i++ )
- {
- psyn_fx[i] = add( psyn_fx[i], shr_r( mult_r( st->hFdCngDec->hFdCngCom->olapBufferSynth2[i + 5 * ( st->hFdCngDec->hFdCngCom->frameSize / 4 )], st->hFdCngDec->hFdCngCom->fftlenFac ), negate( st->Q_syn ) ) );
- move16();
- }
- }
- }
- ELSE
- {
- IF( hStereoCng != NULL )
- {
- hStereoCng->flag_cna_fade = 1;
- move16();
- hStereoCng->enableSecCNA = 0;
- move16();
- }
- }
-
- IF( EQ_16( st->element_mode, IVAS_CPE_TD ) )
- {
- test();
- test();
- test();
- /*Noise estimate*/
- IF( ( st->idchan == 0 ) && ( EQ_16( nchan_out, 2 ) || ( st->core_brate != FRAME_NO_DATA && NE_32( st->core_brate, SID_2k40 ) ) ) )
- {
- ApplyFdCng_ivas_fx( psyn_fx, st->Q_syn, NULL, 0, realBuffer_fx, imagBuffer_fx, NULL, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) );
- }
- }
- }
- }
-
- IF( !st->cna_dirac_flag )
- {
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- IF( ( st->flag_cna == 0 ) && EQ_16( st->L_frame, L_FRAME16k ) && EQ_16( st->last_flag_cna, 1 ) && ( ( st->last_core == ACELP_CORE && !( EQ_16( st->last_coder_type, AUDIO ) && !( st->element_mode > EVS_MONO && st->Last_GSC_noisy_speech_flag ) ) ) || EQ_16( st->last_core, AMR_WB_CORE ) ) )
- {
-#ifdef REMOVE_EVS_DUPLICATES
- IF( EQ_16( st->element_mode, EVS_MONO ) )
- {
- // VE: TBV - is it correct in EVS? in FLP, it is:
- // v_multc( st->hFdCngDec->hFdCngCom->olapBufferSynth2 + 5 * st->L_frame / 4, 256.f, temp_buf, st->L_frame / 2 );
- // v_add( temp_buf, syn, syn, st->L_frame / 2 );
- FOR( i = 0; i < st->L_frame / 2; i++ )
- {
- psyn_fx[i] = add( psyn_fx[i], shr_r( st->hFdCngDec->hFdCngCom->olapBufferSynth2[i + 5 * st->L_frame / 4], negate( st->Q_syn ) ) );
- move16();
- }
- }
- ELSE
-#endif
- {
- FOR( i = 0; i < ( st->hFdCngDec->hFdCngCom->frameSize ) / 2; i++ )
- {
- psyn_fx[i] = add( psyn_fx[i], shr_r( mult_r( st->hFdCngDec->hFdCngCom->olapBufferSynth2[i + 5 * ( st->hFdCngDec->hFdCngCom->frameSize / 4 )], st->hFdCngDec->hFdCngCom->fftlenFac ), -st->Q_syn ) );
- move16();
- }
- }
- }
-
- test();
- test();
- test();
- IF( ( st->flag_cna == 0 ) || ( EQ_16( st->coder_type, AUDIO ) && !( st->element_mode > EVS_MONO && st->GSC_noisy_speech ) ) )
- {
- IF( st->idchan == 0 )
- {
- set16_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2, 0, st->hFdCngDec->hFdCngCom->fftlen );
- }
- IF( hStereoCng != NULL && ( st->idchan == 0 ) )
- {
- set16_fx( hStereoCng->olapBufferSynth22_fx, 0, st->hFdCngDec->hFdCngCom->fftlen );
- }
- }
- }
- }
-
- /*----------------------------------------------------------------*
- * Resample to the output sampling rate (8/16/32/48 kHz)
- * Bass post-filter
- *----------------------------------------------------------------*/
-
-#ifdef REMOVE_EVS_DUPLICATES
- IF( EQ_16( st->element_mode, EVS_MONO ) )
- {
- CLDFB_SCALE_FACTOR scaleFactor;
- Word32 workBuffer[128 * 3];
-
- /* check if the CLDFB works on the right sample rate */
- IF( ( st->cldfbAna->usb * st->cldfbAna->no_col ) != st->L_frame )
- {
- /* resample to ACELP internal sampling rate */
- Word16 newCldfbBands = CLDFB_getNumChannels( L_mult0( st->L_frame, FRAMES_PER_SEC ) );
- resampleCldfb( st->cldfbAna, newCldfbBands, st->L_frame, 0 );
- resampleCldfb( st->cldfbBPF, newCldfbBands, st->L_frame, 0 );
-
- IF( st->ini_frame > 0 )
- {
- st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->cldfbAna->no_channels );
- move16();
- }
- }
-
- test();
- IF( NE_16( st->L_frame, st->last_L_frame ) && NE_16( st->last_codec_mode, MODE2 ) )
- {
- IF( EQ_16( st->L_frame, L_FRAME ) )
- {
- retro_interp5_4_fx( st->hBPF->pst_old_syn_fx );
- }
- ELSE IF( EQ_16( st->L_frame, L_FRAME16k ) )
- {
- retro_interp4_5_fx( psyn_fx, st->hBPF->pst_old_syn_fx );
- }
- }
-
- bass_psfilter_fx( st->hBPF, st->Opt_AMR_WB, psyn_fx, st->L_frame, pitch_buf_fx, st->bpf_off,
- st->stab_fac_fx, &st->stab_fac_smooth_fx, st->coder_type, st->Q_syn, bpf_error_signal_16fx );
-
- /* analysis of the synthesis at internal sampling rate */
- cldfbAnalysis_fx( st->cldfbAna, realBuffer_fx, imagBuffer_fx, &scaleFactor, psyn_fx, negate( st->Q_syn ), CLDFB_NO_COL_MAX, workBuffer );
-
- scaleFactor.hb_scale = scaleFactor.lb_scale;
- move16();
-
- /* analysis and add the BPF error signal */
- i = 0;
- move16();
- if ( st->bpf_off == 0 )
- {
- i = CLDFB_NO_COL_MAX;
- move16();
- }
-
- addBassPostFilter_fx( bpf_error_signal_16fx, realBuffer_fx, imagBuffer_fx, st->cldfbBPF, workBuffer, negate( st->Q_syn ),
- i, st->cldfbAna->no_col, st->cldfbAna->no_channels, &scaleFactor );
-
- /* set output mask for upsampling */
- IF( EQ_16( st->bwidth, NB ) )
- {
- /* set NB mask for upsampling */
- st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, 10 );
- move16();
- }
- ELSE IF( NE_16( st->cldfbSyn->bandsToZero, sub( st->cldfbSyn->no_channels, st->cldfbAna->no_channels ) ) )
- {
- /* in case of BW switching, re-init to default */
- st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->cldfbAna->no_channels );
- move16();
- }
-
- /*WB/SWB-FD_CNG*/
- scaleFactor.hb_scale = scaleFactor.lb_scale;
- move16();
-
- test();
- test();
- test();
- IF( ( ( st->core_brate == FRAME_NO_DATA ) || EQ_32( st->core_brate, SID_2k40 ) ) && ( EQ_16( st->cng_type, FD_CNG ) ) && ( LT_16( st->hFdCngDec->hFdCngCom->numCoreBands, st->cldfbSyn->no_channels ) ) )
- {
- generate_comfort_noise_dec_hf_fx( realBuffer_fx, imagBuffer_fx, &scaleFactor.hb_scale, st );
-
- st->cldfbSyn->bandsToZero = 0;
- move16();
- IF( LT_16( st->hFdCngDec->hFdCngCom->regularStopBand, st->cldfbSyn->no_channels ) )
- {
- st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->hFdCngDec->hFdCngCom->regularStopBand );
- move16();
- }
- st->cldfbSyn->lsb = st->cldfbAna->no_channels;
- move16();
- }
-
- /* synthesis of the combined signal */
- st->Q_syn2 = st->Q_syn;
- move16();
- cldfbSynthesis_fx( st->cldfbSyn, realBuffer_fx, imagBuffer_fx, &scaleFactor, synth_fx16, negate( st->Q_syn2 ), CLDFB_NO_COL_MAX, workBuffer );
-
- /* Bring CLDFB output to Q0 */
- Scale_sig( synth_fx16, output_frame, negate( st->Q_syn2 ) );
- st->Q_syn2 = 0;
- move16();
-
- /* save synthesis - needed in case of core switching */
- Copy( synth_fx16, st->previoussynth_fx, output_frame );
- }
- ELSE
-#endif
- {
- /* check if the CLDFB works on the right sample rate */
- IF( NE_16( imult1616( st->cldfbAna->no_channels, st->cldfbAna->no_col ), st->L_frame ) )
- {
- resampleCldfb_ivas_fx( st->cldfbAna, L_mult0( st->L_frame, FRAMES_PER_SEC ) );
- resampleCldfb_ivas_fx( st->cldfbBPF, L_mult0( st->L_frame, FRAMES_PER_SEC ) );
-
- IF( st->ini_frame > 0 )
- {
- st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->cldfbAna->no_channels );
- move16();
- }
- }
-
- /* analyze pitch coherence for bass post-filter */
-
- Word32 pitch_buf_fx_q20[12];
-
- Scale_sig32( st->old_pitch_buf_fx, 2 * NB_SUBFR16k + 2, Q4 ); // Q(x+4)
- Word16 lim = shr( st->L_frame, 6 );
- FOR( Word16 lp = 0; lp < lim; lp++ )
- {
- pitch_buf_fx_q20[lp] = L_shl( pitch_buf_fx[lp], Q14 );
- move32();
- }
- bpf_pitch_coherence_ivas_fx( st, pitch_buf_fx_q20 );
- Scale_sig32( st->old_pitch_buf_fx, 2 * NB_SUBFR16k + 2, -Q4 ); // Qx
-
- test();
- IF( !( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && st->bpf_off ) )
- {
- test();
- IF( NE_16( st->L_frame, st->last_L_frame ) && NE_16( st->last_codec_mode, MODE2 ) )
- {
- IF( EQ_16( st->L_frame, L_FRAME ) )
- {
- retro_interp5_4_fx( st->hBPF->pst_old_syn_fx );
- }
- ELSE IF( EQ_16( st->L_frame, L_FRAME16k ) )
- {
- retro_interp4_5_fx( psyn_fx, st->hBPF->pst_old_syn_fx );
- }
- }
-
- bass_psfilter_fx( st->hBPF, st->Opt_AMR_WB, psyn_fx, st->L_frame, pitch_buf_fx, st->bpf_off,
- st->stab_fac_fx, &st->stab_fac_smooth_fx, st->coder_type, st->Q_syn, bpf_error_signal_16fx );
- }
-
- Word32 syn_tmp_32_fx[L_FRAME16k + L_SUBFR], *syn_32_fx;
- set32_fx( syn_tmp_32_fx, 0, L_FRAME16k + L_SUBFR );
- syn_32_fx = syn_tmp_32_fx + L_SUBFR;
- test();
- IF( NE_16( st->element_mode, IVAS_CPE_DFT ) || use_cldfb_for_dft )
- {
- /* analysis of the synthesis at internal sampling rate */
- Word32 realBufferSave_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
- Word32 imagBufferSave_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
- Word32 *pRealSave_fx[CLDFB_NO_COL_MAX], *pImagSave_fx[CLDFB_NO_COL_MAX];
- FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
- {
- pRealSave_fx[i] = realBufferSave_fx[i];
- pImagSave_fx[i] = imagBufferSave_fx[i];
- }
- IF( st->p_bpf_noise_buf_32 )
- {
- Copy_Scale_sig_16_32_DEPREC( bpf_error_signal_16fx, bpf_error_signal_fx, st->L_frame, -1 ); // Q_syn-1
- 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
- }
-
- FOR( i = 0; i < st->L_frame; i++ )
- {
- syn_32_fx[i] = L_shr( L_deposit_h( psyn_fx[i] ), add( 4, st->Q_syn ) ); // Q12
- move32();
- }
-
- Word16 offset = sub( st->cldfbAna->p_filter_length, st->cldfbAna->no_channels );
- Scale_sig32( st->cldfbAna->cldfb_state_fx, offset, 1 ); // Q12
- st->cldfbAna->Q_cldfb_state = Q12;
- move16();
- cldfbAnalysis_ivas_fx( syn_32_fx, realBuffer_fx, imagBuffer_fx, -1, st->cldfbAna );
- Scale_sig32( st->cldfbAna->cldfb_state_fx, offset, -1 ); // Q11
- st->cldfbAna->Q_cldfb_state = Q11;
- move16();
- /* analysis and add the BPF error signal */
- Word32 tmp_bpf_error_signal_fx[L_FRAME16k];
- Word16 q_bpf_error_signal;
- Word16 cldfb_state_offset = sub( st->cldfbBPF->p_filter_length, st->cldfbBPF->no_channels );
-
- q_bpf_error_signal = Q6;
- move16();
- 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
- FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
- {
- Scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7 ); // Q0
- Scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7 ); // Q0
- }
- Scale_sig32( st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, sub( q_bpf_error_signal, Q10 ) ); // q_bpf_error_signal (Q6)
- st->cldfbBPF->Q_cldfb_state = q_bpf_error_signal;
- move16();
- tmp = -1;
- move16();
- if ( st->bpf_off )
- {
- tmp = 0;
- move16();
- }
-
- addBassPostFilter_ivas_fx( tmp_bpf_error_signal_fx, tmp, realBuffer_fx, imagBuffer_fx, st->cldfbBPF );
- Scale_sig32( st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, negate( ( sub( q_bpf_error_signal, Q10 ) ) ) ); // Q10
- st->cldfbBPF->Q_cldfb_state = Q10;
- move16();
- /* set output mask for upsampling */
- IF( EQ_16( st->bwidth, NB ) )
- {
- /* set NB mask for upsampling */
- st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, 10 );
- move16();
- }
- ELSE IF( NE_16( st->cldfbSyn->bandsToZero, sub( st->cldfbSyn->no_channels, st->cldfbAna->no_channels ) ) )
- {
- /* in case of BW switching, re-init to default */
- st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->cldfbAna->no_channels );
- move16();
- }
- test();
- IF( !st->cng_sba_flag || EQ_16( st->element_mode, IVAS_CPE_MDCT ) )
- {
- test();
- test();
- test();
- /*WB/SWB-FD_CNG*/
- IF( ( st->core_brate == FRAME_NO_DATA || EQ_32( st->core_brate, SID_2k40 ) ) && ( EQ_16( st->cng_type, FD_CNG ) ) && ( LT_16( st->hFdCngDec->hFdCngCom->numCoreBands, st->cldfbSyn->no_channels ) ) )
- {
- Word16 tmpBufferScale = 0;
- move16();
- generate_comfort_noise_dec_hf_ivas_fx( realBuffer_fx, imagBuffer_fx, /*realBuffer, imagBuffer,*/ &tmpBufferScale, st->hFdCngDec->hFdCngCom, st->cng_ism_flag );
-
- FOR( i = 0; i < st->hFdCngDec->hFdCngCom->numSlots; i++ )
- {
- Scale_sig32( realBuffer_fx[i] + st->hFdCngDec->hFdCngCom->numCoreBands, sub( st->hFdCngDec->hFdCngCom->regularStopBand, st->hFdCngDec->hFdCngCom->numCoreBands ), sub( add( tmpBufferScale, 15 ), Q31 ) ); // Q0
- Scale_sig32( imagBuffer_fx[i] + st->hFdCngDec->hFdCngCom->numCoreBands, sub( st->hFdCngDec->hFdCngCom->regularStopBand, st->hFdCngDec->hFdCngCom->numCoreBands ), sub( add( tmpBufferScale, 15 ), Q31 ) ); // Q0
- }
-
- IF( LT_16( st->hFdCngDec->hFdCngCom->regularStopBand, st->cldfbSyn->no_channels ) )
- {
- st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->hFdCngDec->hFdCngCom->regularStopBand );
- move16();
- }
- ELSE
- {
- st->cldfbSyn->bandsToZero = 0;
- move16();
- }
- }
- }
-
- IF( save_hb_synth_fx16 != NULL )
- {
- /* save and then zero-out lowband */
- max_real = 0;
- max_imag = 0;
- move32();
- move32();
- FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
- {
- FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ )
- {
- max_real = L_max( max_real, L_abs( realBuffer_fx[i][j] ) );
- max_imag = L_max( max_imag, L_abs( imagBuffer_fx[i][j] ) );
- }
- }
- max_val = L_max( max_real, max_imag );
- Q_real = sub( norm_l( max_val ), 3 ) /* Guard bits */;
- FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
- {
- scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real
- scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real
- }
-#ifndef OPT_AVOID_STATE_BUF_RESCALE
-#ifdef OPT_STEREO_32KBPS_V1
- scale_sig32( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->p_filter_length, sub( Q_real, Q11 ) ); // Q10 - > (Q_real-1)
-#else /* OPT_STEREO_32KBPS_V1 */
- scale_sig32_r( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); // (Q_real-1)
-#endif /* OPT_STEREO_32KBPS_V1 */
- st->cldfbSynHB->Q_cldfb_state = sub( Q_real, 1 );
- move16();
-#endif /* OPT_AVOID_STATE_BUF_RESCALE */
-
- FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ )
- {
- FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
- {
- realBufferSave_fx[i][j] = realBuffer_fx[i][j];
- imagBufferSave_fx[i][j] = imagBuffer_fx[i][j];
- move32();
- move32();
- IF( LT_16( j, st->hFdCngDec->hFdCngCom->numCoreBands ) && LT_16( i, st->hFdCngDec->hFdCngCom->numSlots ) )
- {
- realBuffer_fx[i][j] = 0;
- imagBuffer_fx[i][j] = 0;
- move32();
- move32();
- }
- }
- }
-
-#ifdef OPT_AVOID_STATE_BUF_RESCALE
- cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, save_hb_synth_fx, -1, sub( Q11, Q_real ), -10, st->cldfbSynHB );
-#else /* OPT_AVOID_STATE_BUF_RESCALE */
- cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, save_hb_synth_fx, -1, 0, st->cldfbSynHB );
-#endif /* OPT_AVOID_STATE_BUF_RESCALE */
-
-#ifndef OPT_AVOID_STATE_BUF_RESCALE
- Scale_sig32( save_hb_synth_fx, L_FRAME48k, negate( ( sub( Q_real, 1 ) ) ) ); // Q0
- Scale_sig32( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10
- st->cldfbSynHB->Q_cldfb_state = Q10;
- move16();
-#endif /* OPT_AVOID_STATE_BUF_RESCALE */
- /* restore lowband */
- FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ )
- {
- FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
- {
- realBuffer_fx[i][j] = realBufferSave_fx[i][j];
- imagBuffer_fx[i][j] = imagBufferSave_fx[i][j];
- move32();
- move32();
- }
- }
-#ifndef OPT_AVOID_STATE_BUF_RESCALE
- Scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); // Q_real-1
- st->cldfbSynHB->Q_cldfb_state = sub( Q_real, 1 );
- move16();
-#endif /* OPT_AVOID_STATE_BUF_RESCALE */
-
-#ifdef OPT_AVOID_STATE_BUF_RESCALE
- cldfbSynthesis_ivas_fx( pRealSave_fx, pImagSave_fx, synth_fx, -1, sub( Q11, Q_real ), -10, st->cldfbSyn );
-#else /* OPT_AVOID_STATE_BUF_RESCALE */
- cldfbSynthesis_ivas_fx( pRealSave_fx, pImagSave_fx, synth_fx, -1, 0, st->cldfbSyn );
- Scale_sig32( synth_fx, L_FRAME48k, negate( sub( Q_real, 1 ) ) ); // Q0
- Scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10
- st->cldfbSynHB->Q_cldfb_state = Q10;
- move16();
-#endif /* OPT_AVOID_STATE_BUF_RESCALE */
- }
- ELSE
- {
- /* synthesis of the combined signal */
- max_real = 0;
- max_imag = 0;
- move32();
- move32();
- FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
- {
- FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ )
- {
- max_real = L_max( max_real, L_abs( realBuffer_fx[i][j] ) );
- max_imag = L_max( max_imag, L_abs( imagBuffer_fx[i][j] ) );
- }
- }
- max_val = L_max( max_real, max_imag );
- Q_real = sub( norm_l( max_val ), 3 ) /* Guard bits */;
- FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
- {
- scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real
- scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real
- }
-#ifdef OPT_STEREO_32KBPS_V1
- scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q_real, Q11 ) ); // Q10 - > (Q_real-1)
-#else /* OPT_STEREO_32KBPS_V1 */
- scale_sig32_r( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); //(Q_real - 1)
-#endif /* OPT_STEREO_32KBPS_V1 */
- st->cldfbSyn->Q_cldfb_state = sub( Q_real, 1 );
- move16();
-
-#ifdef OPT_AVOID_STATE_BUF_RESCALE
- cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx, -1, 0, 0, st->cldfbSyn );
-#else /* OPT_AVOID_STATE_BUF_RESCALE */
- cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx, -1, 0, st->cldfbSyn );
-#endif /* OPT_AVOID_STATE_BUF_RESCALE */
- scale_sig32( synth_fx, output_frame, negate( sub( Q_real, 1 ) ) ); // Q0
- scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10
- st->cldfbSyn->Q_cldfb_state = Q10;
- move16();
- }
-
- /* save synthesis - needed in case of core switching */
- Copy32( synth_fx, st->previoussynth_fx_32, output_frame ); // Q0
- }
- ELSE
- {
- Word16 nSamples = NS2SA_FX2( i_mult( st->L_frame, FRAMES_PER_SEC ), FRAME_SIZE_NS /*DELAY_CLDFB_NS*/ ); /* IVAS-64: optimization is likely possible here (don't resample the whole frame) */
-
- /* analysis of the synthesis at internal sampling rate - needed for DFT stereo -> TD stereo switching */
- FOR( i = 0; i < st->L_frame; i++ )
- {
- syn_32_fx[i] = L_shr( L_deposit_h( psyn_fx[i] ), add( 4, st->Q_syn ) );
- move32();
- }
-
- Word16 offset = sub( st->cldfbAna->p_filter_length, st->cldfbAna->no_channels );
- Scale_sig32( st->cldfbAna->cldfb_state_fx, offset, 1 ); // Q12
- st->cldfbAna->Q_cldfb_state = Q12;
- move16();
- cldfbAnalysis_ivas_fx( syn_32_fx + sub( st->L_frame, nSamples ), realBuffer_fx, imagBuffer_fx, nSamples, st->cldfbAna );
-
- Scale_sig32( st->cldfbAna->cldfb_state_fx, offset, -1 ); // Q11
- st->cldfbAna->Q_cldfb_state = Q11;
- move16(); /* analysis and add the BPF error signal - needed for DFT stereo -> TD stereo switching */
- Word32 tmp_bpf_error_signal_fx[L_FRAME16k];
- Word16 q_bpf_error_signal;
- Word16 cldfb_state_offset;
- cldfb_state_offset = sub( st->cldfbBPF->p_filter_length, st->cldfbBPF->no_channels );
-
- // Get Q-factor
- q_bpf_error_signal = Q6;
- move16();
- 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
- FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
- {
- Scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7 ); // Q0
- Scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7 ); // Q0
- }
- Scale_sig32( st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, sub( q_bpf_error_signal, Q10 ) ); // q_bpf_error_signal (Q6)
- st->cldfbBPF->Q_cldfb_state = q_bpf_error_signal;
- move16();
- tmp = 0;
- move16();
- if ( !st->bpf_off )
- {
- tmp = nSamples;
- move16();
- }
- addBassPostFilter_ivas_fx( tmp_bpf_error_signal_fx + sub( st->L_frame, nSamples ), tmp, realBuffer_fx, imagBuffer_fx, st->cldfbBPF );
-
-
- Scale_sig32( st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, negate( sub( q_bpf_error_signal, Q10 ) ) ); // Q10
- st->cldfbBPF->Q_cldfb_state = Q10;
- move16();
- /* synthesis of the combined signal - needed for DFT stereo -> TD stereo switching */
- max_real = 0;
- max_imag = 0;
- move32();
- move32();
- FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
- {
- FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ )
- {
- max_real = L_max( max_real, L_abs( realBuffer_fx[i][j] ) );
- max_imag = L_max( max_imag, L_abs( imagBuffer_fx[i][j] ) );
- }
- }
- max_val = L_max( max_real, max_imag );
- Q_real = sub( norm_l( max_val ), 3 ) /* Guard bits */;
- FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
- {
- scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real
- scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real
- }
-#ifndef OPT_AVOID_STATE_BUF_RESCALE
-#ifdef OPT_STEREO_32KBPS_V1
- scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q_real, Q11 ) ); // Q10 - > (Q_real-1)
-#else /* OPT_STEREO_32KBPS_V1 */
- scale_sig32_r( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); //(Q_real - 1)
-#endif /* OPT_STEREO_32KBPS_V1 */
-#endif /* OPT_AVOID_STATE_BUF_RESCALE */
-
-#ifdef OPT_AVOID_STATE_BUF_RESCALE
- cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx /*dummy*/, NS2SA_FX2( st->output_Fs, FRAME_SIZE_NS /*DELAY_CLDFB_NS*/ ), sub( Q10, sub( Q_real, 1 ) ), -10, st->cldfbSyn );
-#else /* OPT_AVOID_STATE_BUF_RESCALE */
- cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx /*dummy*/, NS2SA_FX2( st->output_Fs, FRAME_SIZE_NS /*DELAY_CLDFB_NS*/ ), 0, st->cldfbSyn );
-#endif /* OPT_AVOID_STATE_BUF_RESCALE */
-
-#ifndef OPT_AVOID_STATE_BUF_RESCALE
- Scale_sig32( synth_fx, output_frame, negate( sub( Q_real, 1 ) ) ); // Q0
- Scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10
- st->cldfbSyn->Q_cldfb_state = Q10;
- move16();
-#endif /* OPT_AVOID_STATE_BUF_RESCALE */
- IF( st->p_bpf_noise_buf_32 )
- {
- Copy_Scale_sig_16_32_DEPREC( bpf_error_signal_16fx, bpf_error_signal_fx, st->L_frame, -1 ); // Q_syn-1
- 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
- }
-
- set32_fx( synth_fx, 0, output_frame );
- }
-
- /* Copy output signal */
- Scale_sig( syn_tmp_fx, add( st->L_frame, L_SUBFR ), negate( st->Q_syn ) ); // Q0
- IF( st->element_mode > EVS_MONO )
- {
- Copy( psyn_fx, output_fx, st->L_frame ); /*Q_syn*/
- }
-
- st->Q_syn2 = 0;
- move16();
- }
-
- /*-----------------------------------------------------------------*
- * Bandwidth extension 6kHz-7kHz
- *-----------------------------------------------------------------*/
-
- IF( st->hBWE_zero != NULL )
- {
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- IF( ( EQ_16( st->L_frame, L_FRAME ) && ( st->bwidth != NB ) && GE_16( output_frame, L_FRAME16k ) &&
- ( EQ_16( st->extl, -1 ) || EQ_16( st->extl, SWB_CNG ) || ( EQ_16( st->extl, WB_BWE ) && st->extl_brate == 0 && NE_16( st->coder_type, AUDIO ) ) ) ) )
- {
-#ifdef REMOVE_EVS_DUPLICATES
- IF( EQ_16( st->element_mode, EVS_MONO ) )
- {
- hf_synth_fx( st->hBWE_zero, st->core_brate, output_frame, Aq_fx, exc2_fx, psyn_fx, synth_fx16, st->Q_exc, st->Q_syn2 );
- }
- ELSE
-#endif
- {
- Copy_Scale_sig_32_16( synth_fx, synth_fx16, output_frame, 0 ); // Q0
- hf_synth_fx( st->hBWE_zero, st->core_brate, output_frame, Aq_fx, exc2_fx, psyn_fx, synth_fx16, st->Q_exc, st->Q_syn2 );
- Copy_Scale_sig_16_32_DEPREC( synth_fx16, synth_fx, output_frame, 0 );
- }
- }
- ELSE
- {
- hf_synth_reset_fx( st->hBWE_zero );
-#ifdef REMOVE_EVS_DUPLICATES
- IF( NE_16( st->element_mode, EVS_MONO ) ) // VE: TBV: tmp hack - it is a bug in EVS but condition is here to keep EVS bit-exact for the moment
-#endif
- {
- set16_fx( st->hBWE_zero->mem_hp400_fx, 0, 6 );
- }
- }
- }
-
- /*-----------------------------------------------------------------*
- * Populate parameters for SWB TBE
- *-----------------------------------------------------------------*/
-
- IF( st->hBWE_TD != NULL )
- {
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- IF( ( !st->bfi && st->prev_bfi ) || ( EQ_16( st->last_vbr_hw_BWE_disable_dec, 1 ) && ( st->vbr_hw_BWE_disable_dec == 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;
- move32();
- set16_fx( st->hBWE_TD->old_bwe_exc_extended_fx, 0, NL_BUFF_OFFSET );
- }
-
- test();
- test();
- test();
- test();
- test();
- IF( !st->ppp_mode_dec && ( st->idchan == 0 || NE_16( st->element_mode, IVAS_CPE_TD ) || ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) && st->tdm_LRTD_flag ) ) )
- {
-#ifdef REMOVE_EVS_DUPLICATES
- IF( EQ_16( st->element_mode, EVS_MONO ) )
- {
- non_linearity_fx( bwe_exc_fx, bwe_exc_extended_fx, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors_fx, st->L_frame );
- }
- ELSE
-#endif
- {
- 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
- 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
- }
- }
-
- test();
- if ( st->core_brate == FRAME_NO_DATA || EQ_32( st->core_brate, SID_2k40 ) )
- {
- st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0;
- move32();
- }
- }
-
- /*----------------------------------------------------------------------*
- * Updates
- *----------------------------------------------------------------------*/
-
- updt_dec_fx( st, old_exc_fx, pitch_buf_fx, Es_pred_fx, Aq_fx, lsf_new_fx, lsp_new_fx, voice_factors_fx, old_bwe_exc_fx, gain_buf_fx );
-
- test();
- test();
- IF( GT_32( st->core_brate, SID_2k40 ) && st->hTdCngDec != NULL && st->hFdCngDec != NULL )
- {
- /* update CNG parameters in active frames */
-#ifdef REMOVE_EVS_DUPLICATES
- IF( EQ_16( st->element_mode, EVS_MONO ) )
- {
- cng_params_upd_fx( lsp_new_fx, exc_fx, st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx,
- st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate );
- }
- ELSE
-#endif
- {
- cng_params_upd_ivas_fx( lsp_new_fx, exc_fx, st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size,
- st->hTdCngDec->ho_lsp_circ_fx, st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate, st->element_mode,
- st->hFdCngDec->hFdCngCom->CngBandwidth );
- }
-
- /* Set 16k LSP flag for CNG buffer */
- st->hTdCngDec->ho_16k_lsp[st->hTdCngDec->ho_circ_ptr] = 0;
- move16();
- if ( NE_16( st->L_frame, L_FRAME ) )
- {
- st->hTdCngDec->ho_16k_lsp[st->hTdCngDec->ho_circ_ptr] = 1;
- move16();
- }
- }
-
-#ifdef REMOVE_EVS_DUPLICATES
- IF( NE_16( st->element_mode, EVS_MONO ) )
-#endif
- {
- IF( save_hb_synth_fx16 )
- {
- Copy_Scale_sig_32_16( save_hb_synth_fx, save_hb_synth_fx16, L_FRAME48k, 0 ); // Q0
- }
- Copy_Scale_sig_32_16( synth_fx, synth_fx16, output_frame, 0 ); // Q_syn2
- }
-
- pop_wmops();
- return error;
-}
diff --git a/lib_dec/acelp_core_switch_dec_fx.c b/lib_dec/acelp_core_switch_dec_fx.c
index 6d3d0b381d267a6ab7cf897abbe95b921fb96043..b126823858db562e01e384e307083c48888e3d2d 100644
--- a/lib_dec/acelp_core_switch_dec_fx.c
+++ b/lib_dec/acelp_core_switch_dec_fx.c
@@ -128,11 +128,7 @@ ivas_error acelp_core_switch_dec_fx(
* Excitation decoding
*----------------------------------------------------------------*/
-#ifdef REMOVE_EVS_DUPLICATES
- config_acelp1_IVAS( DEC, st_fx->total_brate, cbrate, st_fx->core, -1, -1, st_fx->last_L_frame, -1, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, GENERIC, st_fx->inactive_coder_type_flag, -1, -1, &decode_bwe /* dummy */, &i, st_fx->element_mode, &i /*dummy*/, 0, 0, st_fx->idchan, st_fx->active_cnt, 0, 0, 0 );
-#else
- config_acelp1( DEC, st_fx->total_brate, cbrate, st_fx->core, -1, -1, st_fx->last_L_frame, -1, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, GENERIC, st_fx->inactive_coder_type_flag, -1, -1, &decode_bwe /* dummy */, &i, st_fx->element_mode, &i /*dummy*/, 0, 0, st_fx->idchan, st_fx->active_cnt, 0, 0, 0 );
-#endif
+ config_acelp1_fx( DEC, st_fx->total_brate, cbrate, st_fx->core, -1, -1, st_fx->last_L_frame, -1, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, GENERIC, st_fx->inactive_coder_type_flag, -1, -1, &decode_bwe /* dummy */, &i, st_fx->element_mode, &i /*dummy*/, 0, 0, st_fx->idchan, st_fx->active_cnt, 0, 0, 0 );
decod_gen_voic_core_switch_fx( st_fx, L_frame_for_cs, 0, Aq, exc, cbrate, &st_fx->Q_exc );
@@ -920,18 +916,19 @@ static void decod_gen_voic_core_switch_fx(
* Decode pitch lag
*----------------------------------------------------------------------*/
-#ifdef REMOVE_EVS_DUPLICATES
- pitch = pit_decode_ivas_fx( st_fx, core_brate, 0, L_frame, 0, GENERIC, &pitch_limit_flag, &T0, &T0_frac, &T0_min, &T0_max, L_SUBFR, 0, NULL ); /*Q6*/
-#else
- pitch = pit_decode_fx( st_fx, core_brate, 0, L_frame, 0, GENERIC, &pitch_limit_flag, &T0, &T0_frac, &T0_min, &T0_max, L_SUBFR ); /*Q6*/
-#endif
+ pitch = pit_decode_fx( st_fx, core_brate, 0, L_frame, 0, GENERIC, &pitch_limit_flag, &T0, &T0_frac, &T0_min, &T0_max, L_SUBFR, 0, NULL ); /*Q6*/
/*--------------------------------------------------------------*
* Find the adaptive codebook vector.
*--------------------------------------------------------------*/
-
- pred_lt4( &exc[0], &exc[0], T0, T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
-
+ IF( st_fx->element_mode != EVS_MONO )
+ {
+ pred_lt4_ivas_fx( &exc[0], &exc[0], T0, T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ }
+ ELSE
+ {
+ pred_lt4( &exc[0], &exc[0], T0, T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ }
/*--------------------------------------------------------------*
* LP filtering of the adaptive excitation
*--------------------------------------------------------------*/
@@ -999,8 +996,14 @@ static void decod_gen_voic_core_switch_fx(
/*-----------------------------------------------------------------*
* long term prediction on the 2nd sub frame
*-----------------------------------------------------------------*/
-
- pred_lt4( &exc[L_SUBFR], &exc[L_SUBFR], T0, T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ IF( st_fx->element_mode != EVS_MONO )
+ {
+ pred_lt4_ivas_fx( &exc[L_SUBFR], &exc[L_SUBFR], T0, T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ }
+ ELSE
+ {
+ pred_lt4( &exc[L_SUBFR], &exc[L_SUBFR], T0, T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ }
pt1 = exc + L_SUBFR;
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 c1c1e61436e16b7b28b144a282dde7a61259fe19..96ae82ddee71c1e6a9a0115bce5ce2e84dea8334 100644
--- a/lib_dec/amr_wb_dec_fx.c
+++ b/lib_dec/amr_wb_dec_fx.c
@@ -373,11 +373,7 @@ ivas_error amr_wb_dec_fx(
IF( EQ_32( st_fx->core_brate, FRAME_NO_DATA ) || EQ_32( st_fx->core_brate, SID_1k75 ) )
{
/* decode CNG parameters */
-#ifdef REMOVE_EVS_DUPLICATES
- CNG_dec_ivas_fx( st_fx, EVS_MONO, Aq_fx, lsp_new_fx, lsf_new_fx, &allow_cn_step, &sid_bw, q_env );
-#else
CNG_dec_fx( st_fx, EVS_MONO, Aq_fx, lsp_new_fx, lsf_new_fx, &allow_cn_step, &sid_bw, q_env );
-#endif
/* comfort noise generation */
CNG_exc_fx( st_fx->core_brate, L_FRAME, &st_fx->hTdCngDec->Enew_fx, &st_fx->hTdCngDec->cng_seed, exc_fx, exc2_fx, &st_fx->lp_ener_fx, st_fx->last_core_brate,
@@ -630,15 +626,9 @@ ivas_error amr_wb_dec_fx(
move16();
}
-#ifdef REMOVE_EVS_DUPLICATES
- FEC_scale_syn_ivas_fx( L_FRAME, &update_flg, st_fx->clas_dec, st_fx->last_good, syn_fx, pitch_buf_tmp, st_fx->enr_old_fx, L_enr_q_fx, -1, MOVING_AVERAGE,
- &st_fx->scaling_flag, &st_fx->lp_ener_FEC_av, &st_fx->lp_ener_FEC_max, st_fx->bfi, st_fx->total_brate, st_fx->prev_bfi, st_fx->last_core_brate,
- exc_fx, exc2_fx, Aq_fx, &st_fx->old_enr_LP, mem_tmp_fx, st_fx->mem_syn2_fx, st_fx->Q_exc, st_fx->Q_syn, EVS_MONO, avoid_lpc_burst_on_recovery, 0 );
-#else
FEC_scale_syn_fx( L_FRAME, &update_flg, st_fx->clas_dec, st_fx->last_good, syn_fx, pitch_buf_tmp, st_fx->enr_old_fx, L_enr_q_fx, -1, MOVING_AVERAGE,
&st_fx->scaling_flag, &st_fx->lp_ener_FEC_av, &st_fx->lp_ener_FEC_max, st_fx->bfi, st_fx->total_brate, st_fx->prev_bfi, st_fx->last_core_brate,
- exc_fx, exc2_fx, Aq_fx, &st_fx->old_enr_LP, mem_tmp_fx, st_fx->mem_syn2_fx, st_fx->Q_exc, st_fx->Q_syn, avoid_lpc_burst_on_recovery, 0 );
-#endif
+ exc_fx, exc2_fx, Aq_fx, &st_fx->old_enr_LP, mem_tmp_fx, st_fx->mem_syn2_fx, st_fx->Q_exc, st_fx->Q_syn, EVS_MONO, avoid_lpc_burst_on_recovery, 0 );
frame_ener_fx( L_FRAME, st_fx->clas_dec, syn_fx, pitch_buf_tmp[3], &st_fx->enr_old_fx, L_FRAME, st_fx->Q_syn, 3, 0 );
}
@@ -717,17 +707,10 @@ ivas_error amr_wb_dec_fx(
* (smoothing is performed in the excitation domain and signal is resynthesized after)
*------------------------------------------------------------*/
-#ifdef REMOVE_EVS_DUPLICATES
- FEC_scale_syn_ivas_fx( L_FRAME, &update_flg, st_fx->clas_dec, st_fx->last_good, syn_fx, pitch_buf_tmp, st_fx->enr_old_fx, L_enr_q_fx, -1,
- MOVING_AVERAGE, &st_fx->scaling_flag, &st_fx->lp_ener_FEC_av, &st_fx->lp_ener_FEC_max, st_fx->bfi, st_fx->total_brate,
- st_fx->prev_bfi, st_fx->last_core_brate, exc_fx, exc2_fx, Aq_fx, &st_fx->old_enr_LP, mem_tmp_fx, st_fx->mem_syn2_fx,
- st_fx->Q_exc, st_fx->Q_syn, EVS_MONO, 0, 0 );
-#else
FEC_scale_syn_fx( L_FRAME, &update_flg, st_fx->clas_dec, st_fx->last_good, syn_fx, pitch_buf_tmp, st_fx->enr_old_fx, L_enr_q_fx, -1,
MOVING_AVERAGE, &st_fx->scaling_flag, &st_fx->lp_ener_FEC_av, &st_fx->lp_ener_FEC_max, st_fx->bfi, st_fx->total_brate,
st_fx->prev_bfi, st_fx->last_core_brate, exc_fx, exc2_fx, Aq_fx, &st_fx->old_enr_LP, mem_tmp_fx, st_fx->mem_syn2_fx,
- st_fx->Q_exc, st_fx->Q_syn, 0, 0 );
-#endif
+ st_fx->Q_exc, st_fx->Q_syn, EVS_MONO, 0, 0 );
/* estimate the pitch-synchronous speech energy per sample to be used when normal operation recovers */
frame_ener_fx( L_FRAME, st_fx->last_good, syn_fx, shr( FEC_pitch_fx, 6 ), &st_fx->enr_old_fx, L_FRAME, st_fx->Q_syn, 3, 0 );
@@ -785,11 +768,7 @@ ivas_error amr_wb_dec_fx(
st_fx->hPFstat->on = 1;
move16();
test();
-#ifdef REMOVE_EVS_DUPLICATES
- formant_post_filt_ivas_fx( st_fx->hPFstat, tmp_buffer_fx + L_SYN_MEM, Aq_fx, syn_fx, L_FRAME, L_shl( st_fx->psf_lp_noise_fx, 15 ), st_fx->total_brate, sub( amr_io_class, AUDIO_CLAS ) == 0 );
-#else
formant_post_filt_fx( st_fx->hPFstat, tmp_buffer_fx + L_SYN_MEM, Aq_fx, syn_fx, L_FRAME, L_shl( st_fx->psf_lp_noise_fx, 15 ), st_fx->total_brate, sub( amr_io_class, AUDIO_CLAS ) == 0 );
-#endif
}
/*----------------------------------------------------------------*
@@ -813,16 +792,9 @@ ivas_error amr_wb_dec_fx(
st_fx->VAD = 0;
move16();
}
-#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
- PMT( "Fixed point not done here " )
- ApplyFdCng_fx( syn, NULL, NULL, NULL, st, 0, 0 );
-#else
-#ifdef REMOVE_EVS_DUPLICATES
- ApplyFdCng_ivas_fx( syn_fx, st_fx->Q_syn, NULL, 0, NULL, NULL, NULL, st_fx, 0, 0 );
-#else
- ApplyFdCng_fx( syn_fx, st_fx->Q_syn, NULL, NULL, NULL, st_fx, 0, 0 );
-#endif
-#endif
+
+ ApplyFdCng_fx( syn_fx, st_fx->Q_syn, NULL, 0, NULL, NULL, NULL, st_fx, 0, 0 );
+
st_fx->hFdCngDec->hFdCngCom->frame_type_previous = st_fx->m_frame_type;
move16();
diff --git a/lib_dec/ari_hm_dec.c b/lib_dec/ari_hm_dec_fx.c
similarity index 100%
rename from lib_dec/ari_hm_dec.c
rename to lib_dec/ari_hm_dec_fx.c
diff --git a/lib_dec/bass_psfilter_fx.c b/lib_dec/bass_psfilter_fx.c
index 45cf7feed026f9c1ef1b419d1f21e5fb08b2691a..4a5ef932892437f9d1ac7662c765c3aece88f343 100644
--- a/lib_dec/bass_psfilter_fx.c
+++ b/lib_dec/bass_psfilter_fx.c
@@ -1124,110 +1124,3 @@ void bpf_pitch_coherence_ivas_fx(
return;
}
-
-
-#ifdef ADD_BPF_ADAPT
-/*---------------------------------------------------------------------*
- * res_bpf_adapt()
- *
- * Analyze BPF output and decide if it should be applied on DFT stereo
- * residual signal
- *---------------------------------------------------------------------*/
-
-/*! r: Decision to enable or disable BPF on DFT stereo residual */
-int16_t res_bpf_adapt(
- STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: DFT stereo decoder handle */
- const float *bpf_error_signal_8k, /* i : BPF modification signal */
- float res_buf[STEREO_DFT_BUF_MAX] /* i : residual buffer */
-)
-{
- float error_nrg;
- float tmp;
- float res_hb_nrg;
- float bpf_error_ratio;
- int16_t res_bpf_flag;
- int16_t i;
- int16_t i_start;
- int16_t i_end;
- float bw_inv;
-
- if ( hStereoDft->res_cod_band_max == 6 )
- {
- i_start = 39;
- i_end = 64;
- bw_inv = 0.04f; /* 1/(64 - 39) */
- }
- else
- {
- i_start = 28;
- i_end = 40;
- bw_inv = 0.083f; /* 1/(40 - 28) */
- }
-
- /* Measure energy of high frequency band in MDCT domain */
- res_hb_nrg = EPSILON;
- for ( i = i_start; i < i_end; i++ )
- {
- res_hb_nrg += res_buf[i] * res_buf[i];
- }
- res_hb_nrg *= bw_inv;
- res_hb_nrg = STEREO_DFT_BPF_ADAPT_ALPHA * res_hb_nrg + ( 1 - STEREO_DFT_BPF_ADAPT_ALPHA ) * hStereoDft->res_hb_nrg_mem;
- hStereoDft->res_hb_nrg_mem = res_hb_nrg;
-
- /* Measure energy of discontinuities at subframe boundaries */
- error_nrg = 0;
- for ( i = 0; i < L_FRAME8k; i += STEREO_DFT_L_SUBFR_8k )
- {
- tmp = bpf_error_signal_8k[i] - hStereoDft->bpf_error_signal_last;
- error_nrg += tmp * tmp;
- hStereoDft->bpf_error_signal_last = bpf_error_signal_8k[i + STEREO_DFT_L_SUBFR_8k - 1];
- }
- error_nrg *= 0.2f; /* Division by 5 for average value */
- bpf_error_ratio = min( 2, error_nrg / res_hb_nrg ); /* Form decision variable and apply limit */
- bpf_error_ratio = STEREO_DFT_BPF_ADAPT_BETA * bpf_error_ratio + ( 1 - STEREO_DFT_BPF_ADAPT_BETA ) * hStereoDft->bpf_error_ratio_mem;
- hStereoDft->bpf_error_ratio_mem = bpf_error_ratio;
-
- res_bpf_flag = bpf_error_ratio < 1;
-
- return res_bpf_flag;
-}
-
-/*---------------------------------------------------------------------*
- * bpf_pitch_coherence()
- *
- * Analyse pitch coherence
- *---------------------------------------------------------------------*/
-void bpf_pitch_coherence(
- Decoder_State *st, /* i/o: decoder state structure */
- const float pitch_buf[] /* i : pitch for every subfr [0,1,2,3] */
-)
-{
- int16_t nb_subfr;
- float pc, pcn1, pcn2, pcn3;
-
- nb_subfr = st->L_frame / L_SUBFR;
-
- if ( st->clas_dec > UNVOICED_CLAS && st->element_mode != EVS_MONO )
- {
- pc = (float) fabs( st->old_pitch_buf[nb_subfr + 3] + st->old_pitch_buf[nb_subfr + 2] - st->old_pitch_buf[nb_subfr] - st->old_pitch_buf[nb_subfr + 1] ) * 256.0f / (float) st->L_frame;
- pcn1 = K_PC_DEC * pc + C_PC_DEC;
- pcn1 = max( min( pcn1, 1.0f ), 0.0f );
-
- pc = (float) fabs( pitch_buf[nb_subfr - 1] + pitch_buf[nb_subfr - 2] - pitch_buf[1] - pitch_buf[0] ) * 256.0f / (float) st->L_frame;
- pcn2 = K_PC_DEC * pc + C_PC_DEC;
- pcn2 = max( min( pcn2, 1.0f ), 0.0f );
-
- pc = (float) fabs( st->old_pitch_buf[nb_subfr + 3] + st->old_pitch_buf[nb_subfr + 2] - pitch_buf[1] - pitch_buf[0] ) * 256.0f / (float) st->L_frame;
- pcn3 = K_PC_DEC * pc + C_PC_DEC;
- pcn3 = max( min( pcn3, 1.0f ), 0.0f );
-
- if ( pcn1 + pcn2 + pcn3 < 2.5f )
- {
- st->hBPF->psf_att = 0.4f;
- set_s( &st->hBPF->Track_on_hist[L_TRACK_HIST - nb_subfr], 1, nb_subfr );
- }
- }
-
- return;
-}
-#endif
diff --git a/lib_dec/cng_dec_fx.c b/lib_dec/cng_dec_fx.c
index ce6ad65683a6cbb3e6a2ab5844fcfb94678c0f20..fdb6488db8232ce7f77edebb2a5ea5fbb61a84b6 100644
--- a/lib_dec/cng_dec_fx.c
+++ b/lib_dec/cng_dec_fx.c
@@ -22,19 +22,19 @@ static void shb_CNG_decod_fx( Decoder_State *st_fx, const Word16 *synth_fx, Word
static void shb_CNG_decod_ivas_fx( Decoder_State *st_fx, const Word16 *synth_fx, Word16 *shb_synth_fx, const Word16 sid_bw, const Word16 Qsyn );
/*-----------------------------------------------------------------*
+ * CNG_dec_fx()
+ *
* Decode residual signal energy
*-----------------------------------------------------------------*/
-#ifndef REMOVE_EVS_DUPLICATES
void CNG_dec_fx(
Decoder_State *st_fx, /* i/o: State structure */
- const Word16 last_element_mode, /* i : last element mode Q0 */
+ const Word16 last_element_mode, /* i : last element mode Q0 */
Word16 Aq[], /* o : LP coefficients Q12 */
Word16 *lsp_new, /* i/o: current frame LSPs Q15 */
Word16 *lsf_new, /* i/o: current frame LSFs Qlog2(2.56) */
Word16 *allow_cn_step, /* o : allow CN step Q0 */
- Word16 *sid_bw /* i : 0-NB/WB, 1-SWB SID Q0 */
- ,
+ Word16 *sid_bw, /* i : 0-NB/WB, 1-SWB SID Q0 */
Word32 *q_env )
{
Word16 istep;
@@ -72,7 +72,6 @@ void CNG_dec_fx(
Word16 exp_pow;
Word16 tmp_loop;
Word16 enr_new, Aq_tmp[M + 1];
-
Word16 LSF_Q_prediction; /* o : LSF prediction mode - just temporary variable in CNG */
TD_CNG_DEC_HANDLE hTdCngDec;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
@@ -108,681 +107,9 @@ void CNG_dec_fx(
}
ELSE
{
- lsf_dec_fx( st_fx, 0, Aq, &LSF_Q_prediction, lsf_new, lsp_new, 0, 0,
- NULL );
- /* check IF LSPs may trigger too much synthesis energy */
-
- E_LPC_f_lsp_a_conversion( lsp_new, Aq_tmp, M );
- enr_new = Enr_1_Az_fx( Aq_tmp, 2 * L_SUBFR );
-
- IF( shr( enr_new, 14 ) > 0 )
- {
- /* Use old LSP vector */
- Copy( st_fx->lsp_old_fx, lsp_new, M ); /* Q15 */
- Copy( st_fx->lsf_old_fx, lsf_new, M ); /* Q2.56 */
- }
- }
- }
- ELSE
- {
- /* Use old LSP vector */
- Copy( st_fx->lsp_old_fx, lsp_new, M ); /* Q15 */
- Copy( st_fx->lsf_old_fx, lsf_new, M ); /* Q2.56 */
- }
-
- /* Initialize the CNG spectral envelope in case of the very first CNG frame */
- IF( st_fx->first_CNG == 0 )
- {
- Copy( st_fx->lsp_old_fx, st_fx->lspCNG_fx, M ); /* Q15 */
- }
-
- /*-----------------------------------------------------------------*
- * Decode residual signal energy
- *-----------------------------------------------------------------*/
-
- *allow_cn_step = 0;
- move16();
- test();
- IF( EQ_32( st_fx->core_brate, SID_1k75 ) || EQ_32( st_fx->core_brate, SID_2k40 ) )
- {
- istep = ISTEP_AMR_WB_SID_FX; /* Q15 */
- move16();
- if ( EQ_32( st_fx->core_brate, SID_2k40 ) )
- {
- istep = ISTEP_SID_FX; /* Q15 */
- move16();
- }
-
- /* initialize the energy quantization parameters */
- num_bits = 6;
- move16();
- if ( st_fx->Opt_AMR_WB == 0 )
- {
- num_bits = 7;
- move16();
- }
-
- /* decode the energy index */
- L_enr_index = get_next_indice_fx( st_fx, num_bits );
-
- IF( LE_32( st_fx->last_core_brate, SID_2k40 ) || EQ_16( st_fx->prev_bfi, 1 ) )
- {
- tmp1 = add( hTdCngDec->old_enr_index, 20 );
- }
- ELSE
- {
- tmp1 = add( hTdCngDec->old_enr_index, 40 );
- }
- IF( GT_16( L_enr_index, tmp1 ) && hTdCngDec->old_enr_index >= 0 ) /* Likely bit error and not startup */
- {
- L_enr_index = tmp1;
- move16();
- L_enr_index = s_min( L_enr_index, 127 ); /* Q0 */
- IF( st_fx->Opt_AMR_WB )
- {
- L_enr_index = s_min( L_enr_index, 63 ); /* Q0 */
- }
- }
-
- test();
- test();
- test();
- IF( GT_32( st_fx->last_core_brate, SID_1k75 ) &&
- NE_16( st_fx->first_CNG, 0 ) &&
- GE_16( hTdCngDec->old_enr_index, 0 ) &&
- GT_16( L_enr_index, add( hTdCngDec->old_enr_index, 1 ) ) )
- {
- *allow_cn_step = 1;
- move16();
- }
-
- hTdCngDec->old_enr_index = L_enr_index;
- move16();
- if ( !L_enr_index )
- {
- L_enr_index = -5;
- move16();
- }
- /* st_fx->Enew = L_enr_index / step - 2.0f;*/
- L_ener = L_mult( L_enr_index, istep ); /* Q16 (0+15) */
- /* subtract by 2 not done to leave Energy in Q2 */
-
- /* extract integral and fractional parts */
- ener_fra = L_Extract_lc( L_ener, &ener_int );
- ener_int = add( ener_int, 4 ); /* Q2 to Q6 */
-
- /* find the new energy value */
- hTdCngDec->Enew_fx = Pow2( ener_int, ener_fra );
- move32();
-
- IF( EQ_32( st_fx->core_brate, SID_2k40 ) )
- {
- burst_ho_cnt = get_next_indice_fx( st_fx, 3 ); /* 3bit */
-
- *sid_bw = get_next_indice_fx( st_fx, 1 );
- move16();
- IF( *sid_bw == 0 )
- {
- env_idx[0] = get_next_indice_fx( st_fx, 6 );
- move16();
-
- /* get quantized res_env_details */
- FOR( i = 0; i < NUM_ENV_CNG; i++ )
- {
- q_env[i] = L_deposit_l( CNG_details_codebook_fx[env_idx[0]][i] );
- move32();
- }
- }
- }
- /* Reset CNG history IF CNG frame length is changed */
- test();
- test();
- IF( EQ_16( st_fx->bwidth, WB ) && NE_16( st_fx->first_CNG, 0 ) && NE_16( st_fx->L_frame, st_fx->last_CNG_L_frame ) )
- {
- hTdCngDec->ho_hist_size = 0;
- move16();
- }
- }
-
- /*---------------------------------------------------------------------*
- * CNG spectral envelope update
- * Find A(z) coefficients
- *---------------------------------------------------------------------*/
- test();
- test();
- test();
- IF( LE_32( st_fx->last_core_brate, SID_2k40 ) )
- {
- /* Reset hangover counter if not first SID period */
- if ( GT_32( st_fx->core_brate, FRAME_NO_DATA ) )
- {
- hTdCngDec->num_ho = 0;
- move16();
- }
- /* Update LSPs IF last SID energy not outliers or insufficient number of hangover frames */
- test();
- IF( LT_16( hTdCngDec->num_ho, 3 ) || LT_32( Mult_32_16( hTdCngDec->Enew_fx, 21845 /*1/1.5f, Q15*/ ), st_fx->lp_ener_fx ) )
- {
- FOR( i = 0; i < M; i++ )
- {
- /* AR low-pass filter */
- st_fx->lspCNG_fx[i] = mac_r( L_mult( CNG_ISF_FACT_FX, st_fx->lspCNG_fx[i] ), 32768 - CNG_ISF_FACT_FX, lsp_new[i] );
- move16(); /* Q15 (15+15+1-16) */
- }
- }
- }
- ELSE
- {
- /* Update CNG_mode IF allowed */
- test();
- test();
- test();
- IF( ( st_fx->Opt_AMR_WB || EQ_16( st_fx->bwidth, WB ) ) && ( !st_fx->first_CNG || GE_16( hTdCngDec->act_cnt2, MIN_ACT_CNG_UPD ) ) )
- {
- IF( GT_32( st_fx->last_active_brate, ACELP_16k40 ) )
- {
- st_fx->CNG_mode = -1;
- move16();
- }
- ELSE
- {
- st_fx->CNG_mode = get_cng_mode( st_fx->last_active_brate );
- move16();
- }
- }
-
- /* If first sid after active burst update LSF history from circ buffer */
- burst_ho_cnt = s_min( burst_ho_cnt, hTdCngDec->ho_circ_size ); /* MODE1_DTX_IN_CODEC_B_FIX Q0*/
- hTdCngDec->act_cnt = 0;
- move16();
- s_ptr = add( sub( hTdCngDec->ho_circ_ptr, burst_ho_cnt ), 1 );
- IF( s_ptr < 0 )
- {
- s_ptr = add( s_ptr, hTdCngDec->ho_circ_size );
- }
-
- FOR( ll = burst_ho_cnt; ll > 0; ll-- )
- {
- hTdCngDec->ho_hist_ptr = add( hTdCngDec->ho_hist_ptr, 1 ); /* Q0 */
- move16();
- if ( EQ_16( hTdCngDec->ho_hist_ptr, HO_HIST_SIZE ) )
- {
- hTdCngDec->ho_hist_ptr = 0;
- move16();
- }
-
- /* Conversion between 12.8k and 16k LSPs */
- test();
- test();
- test();
- IF( ( EQ_16( st_fx->L_frame, L_FRAME16k ) && hTdCngDec->ho_16k_lsp[s_ptr] == 0 ) || ( EQ_16( st_fx->L_frame, L_FRAME ) && EQ_16( hTdCngDec->ho_16k_lsp[s_ptr], 1 ) ) )
- {
- /* Conversion from 16k LPSs to 12k8 */
- lsp_convert_poly_fx( &( hTdCngDec->ho_lsp_circ_fx[s_ptr * M] ), st_fx->L_frame, 0 );
- }
- /* update the circular buffers */
- Copy( &( hTdCngDec->ho_lsp_circ_fx[s_ptr * M] ), &( hTdCngDec->ho_lsp_hist_fx[hTdCngDec->ho_hist_ptr * M] ), M ); /* Qx */
- Copy32( &( hTdCngDec->ho_ener_circ_fx[s_ptr] ), &( hTdCngDec->ho_ener_hist_fx[hTdCngDec->ho_hist_ptr] ), 1 ); /* Q6 */
- hTdCngDec->ho_sid_bw = L_shl( L_and( hTdCngDec->ho_sid_bw, (Word32) 0x3fffffffL ), 1 );
- move32();
- Copy32( &( hTdCngDec->ho_env_circ_fx[s_ptr * NUM_ENV_CNG] ), &( hTdCngDec->ho_env_hist_fx[hTdCngDec->ho_hist_ptr * NUM_ENV_CNG] ), NUM_ENV_CNG ); /* Qx */
-
- hTdCngDec->ho_hist_size = add( hTdCngDec->ho_hist_size, 1 );
- move16();
-
- if ( GT_16( hTdCngDec->ho_hist_size, HO_HIST_SIZE ) )
- {
- hTdCngDec->ho_hist_size = HO_HIST_SIZE;
- move16();
- }
-
- s_ptr = add( s_ptr, 1 );
- if ( EQ_16( s_ptr, hTdCngDec->ho_circ_size ) )
- {
- s_ptr = 0;
- move16();
- }
- }
-
- IF( hTdCngDec->ho_hist_size > 0 ) /* can be -1 at init MODE1_DTX_IN_CODEC_B_FIX */
- {
- /* *allow_cn_step |= ( st_fx->ho_ener_hist[st_fx->ho_hist_ptr] > 4.0f * st_fx->lp_ener );*/
- L_tmp1 = L_shr( hTdCngDec->ho_ener_hist_fx[hTdCngDec->ho_hist_ptr], 2 );
- L_tmp1 = L_sub( L_tmp1, st_fx->lp_ener_fx );
+ lsf_dec_fx( st_fx, 0, Aq, &LSF_Q_prediction, lsf_new, lsp_new, 0, 0, NULL );
- test();
- test();
- IF( ( L_tmp1 > 0 && ( st_fx->first_CNG || st_fx->element_mode == EVS_MONO ) ) )
- {
- *allow_cn_step = s_or( *allow_cn_step, 1 );
- move16();
- }
- }
- IF( EQ_16( last_element_mode, IVAS_CPE_TD ) )
- {
- *allow_cn_step = 1;
- move16();
- }
- test();
- IF( EQ_16( *allow_cn_step, 0 ) && GT_16( hTdCngDec->ho_hist_size, 0 ) )
- {
- /* Use average of energies below last energy */
- ptr = hTdCngDec->ho_hist_ptr;
- move16();
- Copy( &( hTdCngDec->ho_lsp_hist_fx[ptr * M] ), tmp, M ); /* Qx */
- m1 = 0;
- move16();
- IF( L_and( hTdCngDec->ho_sid_bw, (Word32) 0x1 ) == 0 )
- {
- Copy32( &hTdCngDec->ho_env_hist_fx[ptr * NUM_ENV_CNG], tmp_env, NUM_ENV_CNG );
- m1 = 1;
- move16();
- }
- L_enr = Mult_32_16( hTdCngDec->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 < hTdCngDec->ho_hist_size; k++ )
- {
- ptr--;
- if ( ptr < 0 )
- {
- ptr = HO_HIST_SIZE - 1;
- move16();
- }
-
- test();
- IF( LT_32( Mult_32_16( hTdCngDec->ho_ener_hist_fx[ptr], ONE_OVER_BUF_H_NRG_FX ), hTdCngDec->ho_ener_hist_fx[hTdCngDec->ho_hist_ptr] ) &&
- GT_32( hTdCngDec->ho_ener_hist_fx[ptr], Mult_32_16( hTdCngDec->ho_ener_hist_fx[hTdCngDec->ho_hist_ptr], BUF_L_NRG_FX ) ) )
- {
- /*enr += W_DTX_HO[k] * st_fx->ho_ener_hist[ptr];*/
- L_tmp1 = Mult_32_16( hTdCngDec->ho_ener_hist_fx[ptr], W_DTX_HO_FX[k] ); /* Q6+15-15->Q6 */
- L_enr = L_add( L_enr, L_tmp1 ); /* Q6 */
-
- /*weights += W_DTX_HO[k];*/
- weights = add( weights, W_DTX_HO_FX[k] ); /* Q15 */
-
- Copy( &hTdCngDec->ho_lsp_hist_fx[ptr * M], &tmp[m * M], M ); /* Qx */
- IF( EQ_32( L_and( hTdCngDec->ho_sid_bw, L_shl( (Word32) 0x1, k ) ), 0 ) )
- {
- Copy32( &hTdCngDec->ho_env_hist_fx[ptr * NUM_ENV_CNG], &tmp_env[m1 * NUM_ENV_CNG], NUM_ENV_CNG ); /* Qx */
- m1++;
- }
- m++;
- }
- }
-
- /*enr /= weights;*/
- exp = norm_s( weights );
- tmp1 = div_s( shl( 1, sub( 14, exp ) ), weights ); /* Q(15+14-exp-15) */
- L_tmp1 = Mult_32_16( L_enr, tmp1 ); /* Q(14-exp+6-15)->Q(5-exp) */
- L_enr = L_shl( L_tmp1, add( exp, 1 ) ); /* Q6 */
-
- st_fx->lp_ener_fx = L_enr; /* Q6 */
- move32();
- set32_fx( max_val, 0, 2 );
- set16_fx( max_idx, 0, 2 );
-
- FOR( i = 0; i < m; i++ )
- {
- IF( EQ_16( st_fx->L_frame, L_FRAME ) )
- {
- lsp2lsf_fx( &tmp[i * M], lsf_tmp, M, INT_FS_FX );
- ftmp_fx = 964;
- move16(); /*X2.56 */
- tmpv = sub( 16384, add( lsf_tmp[M - 1], ftmp_fx ) ); /*QX2.56*/
- L_tmp = L_mult0( tmpv, tmpv ); /*QX6.5536*/
- }
- ELSE
- {
- lsp2lsf_fx( &tmp[i * M], lsf_tmp, M, INT_FS_16k_FX );
- ftmp_fx = 1205;
- move16(); /*QX2.56*/
- tmpv = sub( 20480, add( lsf_tmp[M - 1], ftmp_fx ) ); /*QX2.56*/
- L_tmp = L_mult0( tmpv, tmpv ); /*QX6.5536*/
- }
-
- tmpv = sub( lsf_tmp[0], ftmp_fx ); /*QX2.56*/
- L_tmp = L_mac0( L_tmp, tmpv, tmpv ); /*QX6.5536*/
- FOR( j = 0; j < M - 1; j++ )
- {
- tmpv = sub( sub( lsf_tmp[j + 1], lsf_tmp[j] ), ftmp_fx ); /*QX2.56*/
- L_tmp = L_mac0( L_tmp, tmpv, tmpv ); /*QX6.5536*/
- }
-
- C[i] = Mpy_32_16_1( L_tmp, 1928 ); /*QX6.5536*/
- move32();
-
- IF( GT_32( C[i], max_val[0] ) )
- {
- max_val[1] = max_val[0];
- move32();
- max_idx[1] = max_idx[0];
- move16();
- max_val[0] = C[i];
- move32();
- max_idx[0] = i;
- move16();
- }
- ELSE IF( GT_32( C[i], max_val[1] ) )
- {
- max_val[1] = C[i];
- move32();
- max_idx[1] = i;
- move16();
- }
- }
-
- IF( EQ_16( m, 1 ) )
- {
- Copy( tmp, lsp_tmp, M ); /* Qx */
- }
- ELSE IF( LT_16( m, 4 ) )
- {
- FOR( i = 0; i < M; i++ )
- {
- L_tmp1 = 0;
- move32();
- FOR( j = 0; j < m; j++ )
- {
- L_tmp1 = L_add( L_tmp1, L_deposit_l( tmp[j * M + i] ) );
- }
-
- L_tmp1 = L_sub( L_tmp1, L_deposit_l( tmp[max_idx[0] * M + i] ) );
- tmpv = div_s( 1, sub( m, 1 ) ); /*Q15*/
- L_tmp1 = Mpy_32_16_1( L_tmp1, tmpv ); /*Q15*/
- lsp_tmp[i] = extract_l( L_tmp1 ); /*Q15*/
- move16();
- }
- }
- ELSE
- {
- FOR( i = 0; i < M; i++ )
- {
- L_tmp1 = 0;
- move32();
- FOR( j = 0; j < m; j++ )
- {
- L_tmp1 = L_add( L_tmp1, L_deposit_l( tmp[j * M + i] ) );
- }
-
- L_tmp1 = L_sub( L_tmp1, 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_tmp1 = Mpy_32_16_1( L_tmp1, tmpv ); /*Q15*/
- lsp_tmp[i] = extract_l( L_tmp1 ); /*Q15*/
- move16();
- }
- }
-
- dist = 0;
- move16(); /*Q15*/
- max_dev = 0;
- move16(); /*Q15*/
- FOR( i = 0; i < M; i++ )
- {
- dev = abs_s( sub( lsp_tmp[i], lsp_new[i] ) ); /*Q15*/
- dist = add_o( dist, dev, &Overflow ); /*Q15*/
- if ( GT_16( dev, max_dev ) )
- {
- max_dev = dev;
- move16();
- }
- }
-
- test();
- IF( GT_16( dist, 13107 ) || GT_16( max_dev, 3277 ) ) /* 0.4 and 0.1 in Q15 */
- {
- FOR( i = 0; i < M; i++ )
- {
- st_fx->lspCNG_fx[i] = lsp_tmp[i];
- move16(); /*Q15*/
- }
- }
- ELSE
- {
- FOR( i = 0; i < M; i++ )
- {
- /* AR low-pass filter */
- st_fx->lspCNG_fx[i] = add( mult_r( 26214, lsp_tmp[i] ), mult_r( 6554, lsp_new[i] ) ); /* Q15 */
- move16();
- }
- }
- IF( m1 > 0 )
- {
- FOR( i = 0; i < NUM_ENV_CNG; i++ )
- {
- L_tmp = L_deposit_l( 0 );
- FOR( j = 0; j < m1; j++ )
- {
- /* env[i] += tmp_env[j*NUM_ENV_CNG+i];*/
- L_tmp = L_add_sat( L_tmp, tmp_env[j * NUM_ENV_CNG + i] );
- }
- /* env[i] /= (float)m1; */
- /* env[i] = env[i] - 2*st_fx->lp_ener_fx; */
- IF( EQ_16( m1, 1 ) )
- {
- L_tmp = L_sub_sat( L_tmp, L_add_sat( st_fx->lp_ener_fx, st_fx->lp_ener_fx ) ); /* Q6 */
- }
- ELSE
- {
- tmp1 = div_s( 1, m1 );
- 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 */
- }
- env[i] = L_tmp; /* Q6 */
- move32();
- }
-
- Copy32( env, hTdCngDec->lp_env_fx, NUM_ENV_CNG ); /* Q6 */
- }
- }
- ELSE
- {
- Copy( lsp_new, st_fx->lspCNG_fx, M ); /* use newly analyzed ISFs */ /* Q15 */
- }
- }
-
- test();
- IF( EQ_32( st_fx->core_brate, SID_1k75 ) || EQ_32( st_fx->core_brate, SID_2k40 ) )
- {
- /* Update hangover memory during CNG */
- test();
- 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 ) ) ) )
- {
- /* update the pointer to circular buffer of old LSP vectors */
- hTdCngDec->ho_hist_ptr++;
- move16();
- if ( EQ_16( hTdCngDec->ho_hist_ptr, HO_HIST_SIZE ) )
- {
- hTdCngDec->ho_hist_ptr = 0;
- move16();
- }
-
- /* update the circular buffer of old LSP vectors with the new LSP vector */
- Copy( lsp_new, &( hTdCngDec->ho_lsp_hist_fx[( hTdCngDec->ho_hist_ptr ) * M] ), M ); /* Q15 */
-
- /* update the hangover energy buffer */
- hTdCngDec->ho_ener_hist_fx[hTdCngDec->ho_hist_ptr] = hTdCngDec->Enew_fx; /* Q6 */
- move32();
- test();
- IF( EQ_32( st_fx->core_brate, SID_2k40 ) && ( *sid_bw == 0 ) )
- {
- /* enr1 = (float)log10( st->Enew*L_frame + 0.1f ) / (float)log10( 2.0f );*/
- 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)*/
- 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 );
- L_tmp = L_Comp( exp, fra );
- enr1 = L_shr( L_tmp, 10 ); /* Q6 */
-
- FOR( i = 0; i < NUM_ENV_CNG; i++ )
- {
- /* get quantized envelope */
- /* env[i] = pow(2.0f,(enr1 - q_env[i])) + 2*st->Enew;*/
- L_tmp = L_sub( enr1, q_env[i] ); /* Q6 */
- L_tmp = L_shl( L_tmp, 10 ); /* 16 */
- temp_lo_fx = L_Extract_lc( L_tmp, &temp_hi_fx );
-
- exp_pow = sub( 14, temp_hi_fx );
- L_tmp = Pow2( 14, temp_lo_fx ); /* Qexp_pow */
- env[i] = L_shl( L_tmp, sub( 6, exp_pow ) ); /* Q6 */
- move32();
- L_tmp = L_add( hTdCngDec->Enew_fx, hTdCngDec->Enew_fx );
- env[i] = L_add( env[i], L_tmp ); /* Q6 */
- move32();
- }
- hTdCngDec->ho_sid_bw = L_shl( L_and( hTdCngDec->ho_sid_bw, (Word32) 0x3fffffffL ), 1 ); /* Q0 */
- move32();
- Copy32( env, &( hTdCngDec->ho_env_hist_fx[hTdCngDec->ho_hist_ptr * NUM_ENV_CNG] ), NUM_ENV_CNG ); /* Q6 */
- }
- ELSE IF( ( *sid_bw != 0 ) )
- {
- hTdCngDec->ho_sid_bw = L_shl( L_and( hTdCngDec->ho_sid_bw, (Word32) 0x3fffffffL ), 1 ); /* Q0 */
- move32();
- hTdCngDec->ho_sid_bw = L_or( hTdCngDec->ho_sid_bw, 0x1L ); /* Q0 */
- move32();
- }
-
- hTdCngDec->ho_hist_size = add( hTdCngDec->ho_hist_size, 1 );
- move16();
- if ( GT_16( hTdCngDec->ho_hist_size, HO_HIST_SIZE ) )
- {
- hTdCngDec->ho_hist_size = HO_HIST_SIZE;
- move16();
- }
- }
- /* Update the frame length memory */
- st_fx->last_CNG_L_frame = st_fx->L_frame;
- move16();
-
- if ( NE_32( st_fx->core_brate, SID_1k75 ) )
- {
- hTdCngDec->num_ho = m;
- move16();
- }
- }
-
- IF( st_fx->element_mode == EVS_MONO )
- {
- st_fx->last_CNG_L_frame = st_fx->L_frame;
- move16();
-
- IF( NE_32( st_fx->core_brate, SID_1k75 ) )
- {
- hTdCngDec->num_ho = m;
- move16();
- }
- }
- IF( st_fx->Opt_AMR_WB )
- {
- E_LPC_f_isp_a_conversion( st_fx->lspCNG_fx, Aq, M );
- }
- ELSE
- {
- E_LPC_f_lsp_a_conversion( st_fx->lspCNG_fx, Aq, M );
- }
-
- tmp_loop = shr( st_fx->L_frame, 6 );
- FOR( i = 1; i < tmp_loop; i++ ) /* L_frame/L_SUBFR */
- {
- Copy( Aq, &Aq[i * ( M + 1 )], add( M, 1 ) ); /* Q12 */
- }
-
- return;
-}
-#endif
-void CNG_dec_ivas_fx(
- Decoder_State *st_fx, /* i/o: State structure */
- const Word16 last_element_mode, /* i : last element mode Q0 */
- Word16 Aq[], /* o : LP coefficients Q12 */
- Word16 *lsp_new, /* i/o: current frame LSPs Q15 */
- Word16 *lsf_new, /* i/o: current frame LSFs Qlog2(2.56) */
- Word16 *allow_cn_step, /* o : allow CN step Q0 */
- Word16 *sid_bw /* i : 0-NB/WB, 1-SWB SID Q0 */
- ,
- Word32 *q_env )
-{
- Word16 istep;
- Word16 i, L_enr_index;
- Word32 L_ener;
- Word16 ener_fra, ener_int;
- Word16 num_bits;
- Word16 weights, ptr, j, k;
- Word16 m1;
- Word16 m = 0;
- move16();
- Word16 tmp[HO_HIST_SIZE * M];
- Word16 burst_ho_cnt = 0;
- move16();
- Word16 ll, s_ptr;
- Word32 L_enr, L_tmp1;
- Word16 tmp1, exp;
- Word16 lsf_tmp[M];
- Word32 C[M];
- Word32 max_val[2];
- Word16 max_idx[2];
- Word16 ftmp_fx;
- Word16 lsp_tmp[M];
- Word16 dev;
- Word16 max_dev;
- Word16 dist;
- Word16 tmpv;
- Word16 env_idx[2];
- Word32 enr1;
- Word32 env[NUM_ENV_CNG];
- Word32 tmp_env[HO_HIST_SIZE * NUM_ENV_CNG];
- Word32 L_tmp;
- Word16 fra;
- Word16 temp_lo_fx, temp_hi_fx;
- Word16 exp_pow;
- Word16 tmp_loop;
- Word16 enr_new, Aq_tmp[M + 1];
-
- Word16 LSF_Q_prediction; /* o : LSF prediction mode - just temporary variable in CNG */
- TD_CNG_DEC_HANDLE hTdCngDec;
-#ifdef BASOP_NOGLOB_DECLARE_LOCAL
- Flag Overflow = 0;
- move32();
-#endif
- hTdCngDec = st_fx->hTdCngDec;
-
- m = 0;
- move16();
- /*-----------------------------------------------------------------*
- * Decode CNG spectral envelope (only in SID frame)
- *-----------------------------------------------------------------*/
- test();
- IF( EQ_32( st_fx->core_brate, SID_1k75 ) || EQ_32( st_fx->core_brate, SID_2k40 ) )
- {
- /* de-quantize the LSF vector */
- IF( st_fx->Opt_AMR_WB != 0 )
- {
- /* Flt function */
- isf_dec_amr_wb_fx( st_fx, Aq, lsf_new, lsp_new );
- /* check IF ISPs may trigger too much synthesis energy */
-
- E_LPC_f_isp_a_conversion( lsp_new, Aq_tmp, M );
- enr_new = Enr_1_Az_fx( Aq_tmp, 2 * L_SUBFR );
-
- IF( ( shr( enr_new, 14 ) > 0 ) )
- {
- /* Use old LSP vector */
- Copy( st_fx->lsp_old_fx, lsp_new, M ); /* Q15 */
- Copy( st_fx->lsf_old_fx, lsf_new, M ); /* Q2.56 */
- }
- }
- ELSE
- {
- lsf_dec_ivas_fx( st_fx, 0, Aq, &LSF_Q_prediction, lsf_new, lsp_new, 0, 0,
- NULL );
/* check IF LSPs may trigger too much synthesis energy */
-
E_LPC_f_lsp_a_conversion( lsp_new, Aq_tmp, M );
enr_new = Enr_1_Az_fx( Aq_tmp, 2 * L_SUBFR );
diff --git a/lib_dec/core_dec_init_fx.c b/lib_dec/core_dec_init_fx.c
index 967a93bfbb1a0f63da3846387ed0f3b0ccfb998e..eb34e1bc1e4ad06bdf2fa06d34dfe06806550b3e 100644
--- a/lib_dec/core_dec_init_fx.c
+++ b/lib_dec/core_dec_init_fx.c
@@ -20,18 +20,7 @@
void open_decoder_LPD_fx(
Decoder_State *st,
const Word32 total_brate, /* Q0 */
-#ifdef NEW_IVAS_OPEN_DEC
- const Word32 last_total_brate,
-#endif
- const Word16 bwidth /* Q0 */
-#ifdef NEW_IVAS_OPEN_DEC
- ,
- const Word16 is_mct, /* i : MCT mode flag */
-#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
- const Word16 last_element_mode,
-#endif
- const Word16 is_init /* i : indicate call from init_decoder() to avoid double TC initialization */
-#endif
+ const Word16 bwidth /* Q0 */
)
{
Word16 i;
@@ -50,10 +39,8 @@ void open_decoder_LPD_fx(
hTcxLtpDec = st->hTcxLtpDec;
hTcxDec = st->hTcxDec;
-#ifndef NEW_IVAS_OPEN_DEC
st->total_brate = total_brate;
move32();
-#endif
if ( NE_16( st->codec_mode, MODE1 ) ) /*already updated in MODE1*/
{
@@ -70,40 +57,18 @@ void open_decoder_LPD_fx(
/* initializing variables for frame lengths etc. right in the beginning */
st->L_frame = extract_l( Mult_32_16( st->sr_core, 0x0290 ) );
move16();
-#ifndef NEW_IVAS_OPEN_DEC
hTcxDec->L_frameTCX = extract_l( Mult_32_16( st->output_Fs, 0x0290 ) );
move16();
-#endif
IF( st->ini_frame == 0 )
{
st->last_L_frame = st->L_frame_past = st->L_frame;
move16();
move16();
-#ifndef NEW_IVAS_OPEN_DEC
st->L_frameTCX_past = hTcxDec->L_frameTCX;
-#endif
move16();
}
-#ifdef NEW_IVAS_OPEN_DEC
- IF( st->hTcxDec != NULL )
- {
- hTcxDec->L_frameTCX = extract_l( Mult_32_16( st->output_Fs, 0x0290 ) );
- IF( st->ini_frame == 0 )
- {
- st->L_frameTCX_past = st->hTcxDec->L_frameTCX;
- move16();
- }
- }
-#endif
st->tcxonly = getTcxonly(
-#ifdef IVAS_CODE_SWITCHING
- st->element_mode,
-#endif
st->total_brate
-#ifdef IVAS_CODE_SWITCHING
- ,
- is_mct
-#endif
/*, st->is_ism_format Needed in the last version of float IVAS */
);
move16();
@@ -155,9 +120,6 @@ void open_decoder_LPD_fx(
// st->pit_res_max = initPitchLagParameters(12800, &st->pit_min, &st->pit_fr1, &st->pit_fr1b, &st->pit_fr2, &st->pit_max);
// hTcxDec->pit_max_TCX = (int16_t)(st->pit_max * st->output_Fs / 12800);
// hTcxDec->pit_min_TCX = (int16_t)(st->pit_min * st->output_Fs / 12800);
-#if 0
- PMT("Fixed point to be verified here")
-#endif
i = mult_r( hTcxDec->L_frameTCX, getInvFrameLen( L_FRAME ) ); /* Q6 */
hTcxDec->pit_max_TCX = extract_l( L_shr( L_mult( st->pit_max, i ), 7 ) ); /* Q0 */
move16();
@@ -243,7 +205,6 @@ void open_decoder_LPD_fx(
}
/*TCX config*/
-#ifndef NEW_IVAS_OPEN_DEC
st->hTcxCfg->preemph_fac = st->preemph_fac;
move16();
st->hTcxCfg->tcx_mdct_window_length_old = st->hTcxCfg->tcx_mdct_window_length;
@@ -304,34 +265,6 @@ void open_decoder_LPD_fx(
}
resetTecDec_Fx( st->hTECDec );
-
-#else
- if ( st->hIGFDec != NULL )
- {
- PMT( "To be done" )
- // IF (!is_init || st->element_mode != IVAS_CPE_MDCT)
- //{
- // init_tcx_cfg(st->hTcxCfg, total_brate, st->sr_core, st->output_Fs, st->L_frame, st->bwidth, st->hTcxDec->L_frameTCX, st->fscale, encoderLookahead, encoderLookaheadFB, st->preemph_fac, st->tcxonly, st->rf_flag, st->igf, st->hIGFDec->infoIGFStopFreq, st->element_mode, st->ini_frame, MCT_flag);
- // }
- // else
- //{
- // st->hTcxCfg->tcx_curr_overlap_mode = st->hTcxCfg->tcx_last_overlap_mode = ALDO_WINDOW;
- // st->hTcxCfg->last_aldo = 1;
- // }
- }
- /*Constraint for adaptive BPF, otherwise parameter estimation and post-processing not time aligned*/
- IF( st->tcxonly == 0 )
- {
- assert( 0 == ( st->hTcxCfg->lfacNext > 0 ? st->hTcxCfg->lfacNext : 0 ) );
- }
- // IF (st->tecDec_fx != NULL)
- {
- resetTecDec_Fx( &( st->tecDec_fx ) );
- }
-
-#endif
-
-
/* Initialize decoder delay */
@@ -447,7 +380,6 @@ void open_decoder_LPD_fx(
move16();
/*PLC*/
-#ifndef NEW_IVAS_OPEN_DEC
IF( st->prev_bfi != 0 )
{
PWord16 const *w;
@@ -498,10 +430,6 @@ void open_decoder_LPD_fx(
hTcxDec->Q_syn_Overl_TDAC = hHQ_core->Q_old_wtda_LB;
move16();
}
-#else
- PMT( "acelp_plc_mdct_transition is missing" )
- // acelp_plc_mdct_transition(st);
-#endif
}
test();
@@ -545,9 +473,6 @@ void open_decoder_LPD_fx(
set16_fx( hTcxDec->syn_Overl_TDAC, 0, L_FRAME32k / 2 ); /*HQ-CORE(bfi)->TCX don't need it*/ /* Q_syn_Overl_TDAC */
set16_fx( hTcxDec->syn_Overl_TDACFB, 0, L_FRAME_MAX / 2 ); /*HQ-CORE(bfi)->TCX don't need it*/ /* Q_syn_Overl_TDACFB */
set16_fx( hTcxDec->syn_Overl, 0, L_FRAME32k / 2 ); /*HQ-CORE(bfi)->TCX don't need it*/ /* Q_syn_Overl */
-#if 0
- PMT("to be moved to reset_tcx_overl_buf")
-#endif
}
IF( st->hTcxCfg != NULL )
{
@@ -575,15 +500,6 @@ void open_decoder_LPD_fx(
cldfb_reset_memory( st->cldfbAna );
cldfb_reset_memory( st->cldfbBPF );
cldfb_reset_memory( st->cldfbSyn );
-#ifndef NEW_IVAS_OPEN_DEC
-#if 0
- PMT("cldfbSynHB is missing ")
-#endif
- // IF (st->cldfbSynHB != NULL)
- //{
- // cldfb_reset_memory(st->cldfbSynHB);
- // }
-#endif
}
ELSE IF( ( NE_16( st->L_frame, st->last_L_frame ) ) && ( LE_16( st->L_frame, L_FRAME16k ) ) && ( LE_16( st->last_L_frame, L_FRAME16k ) ) ) /* Rate switching between 12.8 and 16 kHz*/
{
@@ -817,10 +733,6 @@ void open_decoder_LPD_fx(
test();
IF( EQ_16( st->core, ACELP_CORE ) && EQ_16( st->last_core, HQ_CORE ) )
{
- /*_DIFF_FLOAT_FIX_*/
-#if 0
- PMT("floating point is using L_frameTCX instead of output_frame, is it ok?")
-#endif
frame_ener_fx( st->output_frame_fx, UNVOICED_CLAS, st->previoussynth_fx, -1, &st->enr_old_fx, 1, 0, 0, 0 );
}
}
@@ -840,20 +752,6 @@ void open_decoder_LPD_fx(
move16();
if ( st->hTcxDec != NULL )
{
-#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
- /* Todo: should be considered for other stereo modes as well */
- IF( is_init || MCT_flag || !( st->element_mode == IVAS_CPE_MDCT && st->element_mode == last_element_mode ) )
- {
- PMT( "Fixed point to be done" )
- st->hTcxDec->CngLevelBackgroundTrace_bfi = PLC_MIN_CNG_LEV;
- st->hTcxDec->NoiseLevelIndex_bfi = PLC_MIN_STAT_BUFF_SIZE - 1;
- st->hTcxDec->CurrLevelIndex_bfi = 0;
- st->hTcxDec->LastFrameLevel_bfi = PLC_MIN_CNG_LEV;
- set_f( st->hTcxDec->NoiseLevelMemory_bfi, PLC_MIN_CNG_LEV, PLC_MIN_STAT_BUFF_SIZE );
-
- st->hTcxDec->cummulative_damping_tcx = 1.0f;
- }
-#else
hTcxDec->conCngLevelBackgroundTrace = PLC_MIN_CNG_LEV_Q21; /*Q21*/
move16();
hTcxDec->conNoiseLevelIndex = PLC_MIN_STAT_BUFF_SIZE - 1; /* Q0 */
@@ -871,7 +769,6 @@ void open_decoder_LPD_fx(
hTcxDec->cummulative_damping_tcx = 32767 /*1.0f Q15*/;
move16();
-#endif
}
st->cummulative_damping = 32767 /*1.0f Q15*/;
move16();
@@ -891,10 +788,8 @@ void open_decoder_LPD_fx(
st->old_fpitch = L_deposit_h( st->pit_min );
move32();
-#ifndef NEW_IVAS_OPEN_DEC
st->old_fpitchFB = L_deposit_h( hTcxDec->pit_min_TCX );
move32();
-#endif
st->rate_switching_init = 1;
move16();
@@ -924,9 +819,6 @@ void open_decoder_LPD_fx(
test();
IF( hTcxLtpDec != NULL && ( EQ_16( st->ini_frame, 0 ) || ( EQ_16( st->last_codec_mode, MODE1 ) && st->element_mode == EVS_MONO ) ) )
{
-#if 0
- PMT("TO be verify, update seems to differ from float")
-#endif
hTcxLtpDec->tcxltp_pitch_int = st->pit_max; /* Q0 */
move16();
hTcxLtpDec->tcxltp_pitch_fr = 0; /* Q0 */
@@ -1059,12 +951,6 @@ void open_decoder_LPD_fx(
move16();
st->second_last_core = -1;
move16();
-#ifdef NEW_IVAS_OPEN_DEC
- IF( st->hTcxCfg != NULL && st->element_mode != EVS_MONO )
- {
- st->hTcxCfg->fIsTNSAllowed = getTnsAllowed( is_init ? total_brate : st->bits_frame_nominal * FRAMES_PER_SEC, st->igf );
- }
-#endif
IF( hTcxDec != NULL )
{
hTcxDec->tcxltp_second_last_pitch = st->old_fpitch; /*15Q16*/
@@ -1105,10 +991,8 @@ void open_decoder_LPD_fx(
hTcxDec->tcx_hm_LtpPitchLag = -1;
move16();
}
-#ifndef NEW_IVAS_OPEN_DEC
st->hTcxCfg->na_scale = 32767 /*1.0f Q15*/;
move16();
-#endif
if ( hTcxLtpDec != NULL )
{
hTcxLtpDec->tcxltp_gain = 0; /* Q15 */
diff --git a/lib_dec/core_dec_switch_fx.c b/lib_dec/core_dec_switch_fx.c
index 63c35f876e3da1d41836c8b99f588463a42c8502..94b6efb1bd051fd5f71bf9fab7d3a5c68025d7a2 100644
--- a/lib_dec/core_dec_switch_fx.c
+++ b/lib_dec/core_dec_switch_fx.c
@@ -10,21 +10,10 @@
#include "rom_com.h"
void mode_switch_decoder_LPD_fx(
- Decoder_State *st, /* i/o: decoder state structure */
- Word16 bwidth, /* i : audio bandwidth Q0*/
- Word32 total_brate, /* i : total bitrate Q0*/
-#ifdef IVAS_CODE_SWITCHING
- const Word32 last_total_brate, /* i : last frame total bitrate */
-#endif
+ Decoder_State *st, /* i/o: decoder state structure */
+ Word16 bwidth, /* i : audio bandwidth Q0*/
+ Word32 total_brate, /* i : total bitrate Q0*/
Word16 frame_size_index /* i : index determining the frame size Q0*/
-#ifdef IVAS_CODE_SWITCHING
- ,
- const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0)*/
-#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
- ,
- const Word16 last_element_mode
-#endif
-#endif
)
{
Word16 fscale, switchWB;
@@ -100,15 +89,7 @@ void mode_switch_decoder_LPD_fx(
test();
IF( NE_16( fscale, st->fscale ) || ( switchWB != 0 ) || ( bSwitchFromAmrwbIO != 0 ) || EQ_16( st->last_codec_mode, MODE1 ) || st->force_lpd_reset )
{
-#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
- open_decoder_LPD_fx( st, total_brate, last_total_brate, bwidth, MCT_flag, last_element_mode, 0 );
-#else
-#ifdef IVAS_CODE
- open_decoder_LPD_fx( st, total_brate, last_total_brate, bwidth, is_mct, 0 );
-#else
open_decoder_LPD_fx( st, total_brate, bwidth );
-#endif
-#endif
}
ELSE
{
@@ -153,9 +134,6 @@ void mode_switch_decoder_LPD_fx(
IF( ( st->hTcxCfg->fIsTNSAllowed != 0 ) && st->hIGFDec != NULL )
{
InitTnsConfigs( bwidth, st->hTcxCfg->tcx_coded_lines, st->hTcxCfg->tnsConfig, st->hIGFDec->infoIGFStopFreq, total_brate, st->element_mode, 0 /* 0 should be replaced with MCT_flag*/ );
-#ifdef IVAS_CODE
- SetAllowTnsOnWhite( st->hTcxCfg->tnsConfig, st->element_mode == IVAS_CPE_MDCT );
-#endif
}
}
}
diff --git a/lib_dec/dec_LPD_fx.c b/lib_dec/dec_LPD_fx.c
index f53234deda56be19c4a99d212ca765afbd27981e..b638a36e55bbc3de081e4667c74e8cc8c5be9b66 100644
--- a/lib_dec/dec_LPD_fx.c
+++ b/lib_dec/dec_LPD_fx.c
@@ -556,11 +556,7 @@ void decoder_LPD_fx(
move16();
}
-#ifdef REMOVE_EVS_DUPLICATES
int_lsp4_ivas_fx( L_frame, &lsp[0], lspmid, &lsp[M], Aq, M, st->relax_prev_lsf_interp );
-#else
- int_lsp4_fx( L_frame, &lsp[0], lspmid, &lsp[M], Aq, M, st->relax_prev_lsf_interp );
-#endif
}
ELSE
{
@@ -574,11 +570,7 @@ void decoder_LPD_fx(
IF( bfi != 0 && ( st->last_core != ACELP_CORE ) )
{
/* PLC: [TCX: TD PLC] */
-#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
- con_tcx_fx( st, &synthFB[0], -1.f, NULL, 0, NULL );
-#else
con_tcx_fx( st, &synthFB[0] );
-#endif
lerp( synthFB, synth, st->L_frame, hTcxDec->L_frameTCX );
st->con_tcx = 1;
move16();
@@ -778,11 +770,7 @@ void decoder_LPD_fx(
{
TonalMDCTConceal_SaveTimeSignal( st->hTonalMDCTConc, synthFB, L_frameTCX );
}
-#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
- decoder_tcx_post_fx( st, synth, synthFB, Aq, bfi, 0 );
-#else
decoder_tcx_post_fx( st, synth, synthFB, Aq, bfi );
-#endif
IF( EQ_16( st->core, TCX_20_CORE ) )
{
/* LPC Interpolation for BWE/post-processing */
diff --git a/lib_dec/dec_ace_fx.c b/lib_dec/dec_ace_fx.c
index 16f7491561541fdad810d6b6faa0fb735419a0c4..9c366e3f3190c2138e9940a69e30a447609a0d1f 100644
--- a/lib_dec/dec_ace_fx.c
+++ b/lib_dec/dec_ace_fx.c
@@ -532,35 +532,24 @@ void decoder_acelp_fx(
move16();
IF( st->igf != 0 )
{
-#ifdef REMOVE_EVS_DUPLICATES
- prep_tbe_exc_ivas_fx( st->L_frame, L_SUBFR, i_subfr, gain_pit, gain_code, code, st->voice_fac, &voice_factors[idx], bwe_exc,
- gain_preQ, code_preQ, st->Q_exc, T0, T0_frac, st->coder_type, st->core_brate, st->element_mode, st->idchan, st->hBWE_TD != NULL, 0 );
-#else
- prep_tbe_exc_fx( st->L_frame,
-#ifdef ADD_IVAS_TBE_CODE
- L_SUBFR,
-#endif
- i_subfr, gain_pit, gain_code, code, st->voice_fac, &voice_factors[idx], bwe_exc,
- gain_preQ, code_preQ, st->Q_exc, T0, T0_frac, st->coder_type, st->core_brate
-#ifdef ADD_IVAS_TBE_CODE
- ,
- st->element_mode, st->idchan, st->hBWE_TD != NULL, 0
-#endif
- );
-#endif
+ prep_tbe_exc_fx( st->L_frame, L_SUBFR, i_subfr, gain_pit, gain_code, code, st->voice_fac, &voice_factors[idx], bwe_exc,
+ gain_preQ, code_preQ, st->Q_exc, T0, T0_frac, st->coder_type, st->core_brate, st->element_mode, st->idchan, st->hBWE_TD != NULL, 0 );
}
/*---------------------------------------------------------*
* Enhance the excitation *
*---------------------------------------------------------*/
+
E_UTIL_enhancer( st->voice_fac, stab_fac, st->past_gcode, gain_inov, &( st->gc_threshold_fx ), code, &exc2[i_subfr],
gain_pit, &st->dm_fx.prev_gain_code, st->dm_fx.prev_gain_pit, &st->dm_fx.prev_state, st->coder_type,
acelp_cfg.fixed_cdk_index[idx], L_SUBFR, st->L_frame, st->Q_exc );
} /* !RF_NELP frame partial copy */
+
/*----------------------------------------------------------*
* - compute the synthesis speech *
*----------------------------------------------------------*/
+
rescale_mem( &st->Q_exc, &prev_Q_syn, &st->Q_syn, mem_syn, syn, M, i_subfr );
E_UTIL_synthesis( sub( st->Q_exc, st->Q_syn ), p_A, &exc2[i_subfr], &syn[i_subfr], L_SUBFR, mem_syn, 1, M );
@@ -686,16 +675,11 @@ void decoder_acelp_fx(
move16();
}
-#ifdef REMOVE_EVS_DUPLICATES
- FEC_scale_syn_ivas_fx( st->L_frame, &update_flg, st->clas_dec, st->last_good, syn, pBuf_scaleSyn, st->enr_old_fx, 0,
- st->coder_type, LSF_Q_prediction, &st->scaling_flag, &st->lp_ener_FEC_av, &st->lp_ener_FEC_max, st->bfi, st->total_brate, st->prev_bfi, st->last_core_brate,
- exc, exc2, A, &( st->old_enr_LP ), mem_back, mem_syn, st->Q_exc, st->Q_syn, EVS_MONO, avoid_lpc_burst_on_recovery, force_scale_syn );
-#else
FEC_scale_syn_fx( st->L_frame, &update_flg, st->clas_dec, st->last_good, syn, pBuf_scaleSyn, st->enr_old_fx, 0,
st->coder_type, LSF_Q_prediction, &st->scaling_flag, &st->lp_ener_FEC_av, &st->lp_ener_FEC_max, st->bfi, st->total_brate, st->prev_bfi, st->last_core_brate,
- exc, exc2, A, &( st->old_enr_LP ), mem_back, mem_syn, st->Q_exc, st->Q_syn, avoid_lpc_burst_on_recovery, force_scale_syn );
-#endif
+ exc, exc2, A, &( st->old_enr_LP ), mem_back, mem_syn, st->Q_exc, st->Q_syn, EVS_MONO, avoid_lpc_burst_on_recovery, force_scale_syn );
}
+
/* update ACELP synthesis memory */
Copy( mem_syn, st->mem_syn2_fx, M );
Copy( syn + st->L_frame - L_SYN_MEM, st->mem_syn_r, L_SYN_MEM );
diff --git a/lib_dec/dec_acelp_tcx_main_fx.c b/lib_dec/dec_acelp_tcx_main_fx.c
index 04a41ed46c9a3ca1b4f0110d3eb3b60872886ffa..eea558914c2af6701f3cca58975eaa6ed3a5a4d7 100644
--- a/lib_dec/dec_acelp_tcx_main_fx.c
+++ b/lib_dec/dec_acelp_tcx_main_fx.c
@@ -208,11 +208,7 @@ static void decode_frame_type_fx( Decoder_State *st )
move16();
/* Reconf Core */
-#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
- mode_switch_decoder_LPD_fx( st, st->bwidth, st->total_brate, st->last_total_brate, frame_size_index, 0, st->element_mode );
-#else
mode_switch_decoder_LPD_fx( st, st->bwidth, st->total_brate, frame_size_index );
-#endif
/* Reconf CLDFB */
IF( NE_16( i_mult( st->cldfbAna->no_channels, st->cldfbAna->no_col ), st->L_frame ) )
{
@@ -368,7 +364,7 @@ Word16 dec_acelp_tcx_frame_fx(
{
/* Copy back parameters from previous frame, because there is a high risk they are corrupt
* DO concealment with configuration used in previous frame */
- st->m_frame_type = (uint8_t) m_frame_type;
+ st->m_frame_type = (UWord8) m_frame_type;
move16();
st->bwidth = bwidth;
move16();
diff --git a/lib_dec/dec_amr_wb_fx.c b/lib_dec/dec_amr_wb_fx.c
index b03b6d69ce178133505548a585ae5cdb7f18cd9c..500fe34bab921a2c385caf751d34616d63e0045f 100644
--- a/lib_dec/dec_amr_wb_fx.c
+++ b/lib_dec/dec_amr_wb_fx.c
@@ -71,11 +71,7 @@ void decod_amr_wb_fx(
* Decode pitch lag
*----------------------------------------------------------------------*/
-#ifdef REMOVE_EVS_DUPLICATES
- *pt_pitch_fx = pit_decode_ivas_fx( st_fx, st_fx->core_brate, 1, L_FRAME, i_subfr, -1, &pitch_limit_flag, &T0, &T0_frac, &T0_min, &T0_max, L_SUBFR, 0, NULL );
-#else
- *pt_pitch_fx = pit_decode_fx( st_fx, st_fx->core_brate, 1, L_FRAME, i_subfr, -1, &pitch_limit_flag, &T0, &T0_frac, &T0_min, &T0_max, L_SUBFR );
-#endif
+ *pt_pitch_fx = pit_decode_fx( st_fx, st_fx->core_brate, 1, L_FRAME, i_subfr, -1, &pitch_limit_flag, &T0, &T0_frac, &T0_min, &T0_max, L_SUBFR, 0, NULL );
/*--------------------------------------------------------------*
* Find the adaptive codebook vector
diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c
index 7411d59f208638edf6ce07eaec052efb33052555..14d9d1772700242840bc8cbfb1bc39769d9d08bf 100644
--- a/lib_dec/dec_gen_voic_fx.c
+++ b/lib_dec/dec_gen_voic_fx.c
@@ -18,8 +18,7 @@
/*----------------------------------------------------------------------*/
/* GLOBAL INPUT ARGUMENTS : */
/* _ (Struct) st_fx : decoder static memory */
-/* _ (Word16) L_frame : length of the frame */
-
+/* _ (Word16) L_frame : length of the frame */
/* _ (Word16[]) Aq_fx : LP filter coefficient Q12 */
/* _ (Word16) Es_pred_fx : predicted scaled innov. energy Q8 */
/* _ (Word16[]) pitch_buf_fx : floating pitch values for each subframe Q6*/
@@ -29,503 +28,30 @@
/* _ (Word16[]) exc_fx : adapt. excitation exc (Q_exc) */
/* _ (Word16[]) exc2_fx : adapt. excitation/total exc (Q_exc) */
/*----------------------------------------------------------------------*/
-
-
/*----------------------------------------------------------------------*/
/* RETURN ARGUMENTS : */
/* _ None */
/*======================================================================*/
-#ifndef REMOVE_EVS_DUPLICATES
ivas_error decod_gen_voic_fx(
- Decoder_State *st_fx, /* i/o: decoder static memory */
- const Word16 L_frame, /* i : length of the frame */
- const Word16 sharpFlag_fx, /* i : formant sharpening flag */
- const Word16 *Aq_fx, /* i : LP filter coefficient Q12 */
- const Word16 Es_pred_fx, /* i : predicted scaled innov. energy Q8 */
- const Word16 do_WI_fx, /* i : do interpolation after a FER */
- Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6 */
- Word16 *voice_factors_fx, /* o : voicing factors Q15 */
- Word16 *exc_fx, /* i/o: adapt. excitation exc Q_exc */
- Word16 *exc2_fx, /* i/o: adapt. excitation/total exc Q_exc */
- Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q_exc */
- Word16 *unbits, /* number of unused bits */
- Word16 *gain_buf /*Q14*/
+ Decoder_State *st_fx, /* i/o: decoder static memory */
+ const Word16 L_frame, /* i : length of the frame */
+ const Word16 sharpFlag_fx, /* i : formant sharpening flag */
+ const Word16 *Aq_fx, /* i : LP filter coefficient Q12 */
+ const Word16 Es_pred_fx, /* i : predicted scaled innov. energy Q8 */
+ const Word16 do_WI_fx, /* i : do interpolation after a FER */
+ Word16 *pitch_buf_fx, /* o : Word16 pitch values for each subframe Q6 */
+ Word16 *voice_factors_fx, /* o : voicing factors Q15 */
+ Word16 *exc_fx, /* i/o: adapt. excitation exc Q_exc */
+ Word16 *exc2_fx, /* i/o: adapt. excitation/total exc Q_exc */
+ Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q_exc */
+ Word16 *unbits, /* number of unused bits */
+ Word16 *gain_buf, /* o : Word16 pitch gain for each subframe Q14 */
+ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
+ const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer Q6 */
)
{
-
-
- Word16 T0_fx, T0_frac_fx, T0_min_fx, T0_max_fx; /* integer pitch variables */
- Word16 gain_pit_fx = 0; /* pitch gain Q14 */
- move16();
- Word32 gain_code_fx = 0; /* gain/normalized gain of the algebraic excitation Q16 */
- move32();
- Word32 norm_gain_code_fx = 0; /* normalized gain of the algebraic excitation Q16 */
- move32();
- Word16 gain_inov_fx = 0; /* Innovation gain Q12 */
- move16();
- Word32 gc_mem[NB_SUBFR - 1]; /* gain_code from previous subframes */
- Word16 gp_mem[NB_SUBFR - 1]; /* gain_pitch from previous subframes */
- Word16 voice_fac_fx; /* voicing factor Q15 */
- Word16 code_fx[L_SUBFR]; /* algebraic codevector Q12 */
-
- const Word16 *p_Aq_fx; /* Pointer to frame LP coefficient Q12 */
- Word16 *pt_pitch_fx; /* pointer to floating pitch Q6 */
- Word16 i_subfr_fx, i; /* tmp variables */
- Word16 error_fx = 0;
- move16();
- Word16 gain_preQ_fx = 0; /* Gain of prequantizer excitation */
- move16();
- Word16 code_preQ_fx[L_SUBFR]; /* Prequantizer excitation */
- Word32 norm_gain_preQ_fx;
- Word16 pitch_limit_flag_fx;
-
- Word16 tmp1_fx, gain_code16;
- Word32 L_tmp_GC;
- Word32 L_tmp;
-
- Word16 harm_flag_acelp;
-
- Word16 shft_prev, ph_offset_fx;
- Word32 prev_res_nrg;
- Word32 prev_spch_nrg;
- Word32 curr_res_nrg;
- Word32 curr_spch_nrg;
- Word16 rint_bfi_pitch, rint_pitch;
- Word16 fraca, fracb, expa, expb, scale, exp1;
- Word16 *p_exc;
- Word16 mem_tmp_fx[M];
- Word16 syn_tmp_fx[L_FRAME16k];
- Word16 shft_curr;
- Word16 *p_syn;
- Word16 sp_enratio, Qsp_enratio;
- Word16 enratio, Qenratio;
- DTFS_STRUCTURE *PREVP, *CURRP;
- Word16 S_fx[PIT_MAX * 4 + 1], C_fx[PIT_MAX * 4 + 1];
- Word16 dummy2[2];
- Word16 out_fx[L_FRAME16k];
-
- Word16 pf_temp1[MAXLAG_WI]; /*may not need more than MAXLAG_WI/2+1 */
- Word16 pf_temp2[MAXLAG_WI];
- Word16 pf_temp[MAXLAG_WI];
- Word16 pf_n2[MAXLAG_WI];
- MUSIC_POSTFILT_HANDLE hMusicPF;
-#ifdef BASOP_NOGLOB_DECLARE_LOCAL
- Flag Overflow = 0;
- move32();
-#endif
-
- hMusicPF = st_fx->hMusicPF;
-
- GSC_DEC_HANDLE hGSCDec;
- hGSCDec = st_fx->hGSCDec;
- ivas_error error;
-
- error = IVAS_ERR_OK;
- move32();
-
- T0_fx = PIT_MIN;
- move16();
- T0_frac_fx = 0;
- move16();
-
- /* read harmonicity flag */
- harm_flag_acelp = 0;
- move16();
- test();
- test();
- IF( ( GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) && LE_32( st_fx->core_brate, MAX_BRATE_AVQ_EXC_TD ) ) && EQ_16( st_fx->coder_type, GENERIC ) )
- {
- harm_flag_acelp = (Word16) get_next_indice( st_fx, 1 );
- }
-
- /*------------------------------------------------------------------*
- * ACELP subframe loop
- *------------------------------------------------------------------*/
-
- p_Aq_fx = Aq_fx; /* pointer to interpolated LPC parameters */
- pt_pitch_fx = pitch_buf_fx; /* pointer to the pitch buffer */
- norm_gain_preQ_fx = 0;
- move32();
- gain_preQ_fx = 0;
- move16();
- set16_fx( code_preQ_fx, 0, L_SUBFR );
-
- FOR( i_subfr_fx = 0; i_subfr_fx < L_frame; i_subfr_fx += L_SUBFR )
- {
- /*----------------------------------------------------------------------*
- * Decode pitch lag
- *----------------------------------------------------------------------*/
-
- *pt_pitch_fx = pit_decode_fx( st_fx, st_fx->core_brate, 0, L_frame, i_subfr_fx, st_fx->coder_type, &pitch_limit_flag_fx,
- &T0_fx, &T0_frac_fx, &T0_min_fx, &T0_max_fx, L_SUBFR );
- move16(); /*Q6*/
-
- /*--------------------------------------------------------------*
- * Find the adaptive codebook vector
- *--------------------------------------------------------------*/
-
- pred_lt4( &exc_fx[i_subfr_fx], &exc_fx[i_subfr_fx], T0_fx, T0_frac_fx, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
-
- tbe_celp_exc( L_frame, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx );
-
- /*--------------------------------------------------------------*
- * LP filtering of the adaptive excitation
- *--------------------------------------------------------------*/
- lp_filt_exc_dec_fx( st_fx, MODE1, i_subfr_fx, L_SUBFR, L_frame, st_fx->acelp_cfg.ltf_mode, exc_fx );
- /*-----------------------------------------------------------------*
- * Transform-domain contribution decoding (active frames)
- *-----------------------------------------------------------------*/
-
- test();
- IF( GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) && ( st_fx->coder_type != INACTIVE ) )
- {
- gain_code_fx = 0;
- move16();
- transf_cdbk_dec_fx( st_fx, harm_flag_acelp, i_subfr_fx, Es_pred_fx, gain_code_fx, &gain_preQ_fx, &norm_gain_preQ_fx, code_preQ_fx, unbits );
- }
-
- /*--------------------------------------------------------------*
- * Innovation decoding
- *--------------------------------------------------------------*/
-
- inov_decode_fx( st_fx, st_fx->core_brate, 0, L_frame, sharpFlag_fx, i_subfr_fx, p_Aq_fx, st_fx->tilt_code_fx, *pt_pitch_fx, code_fx, L_SUBFR );
-
- /*--------------------------------------------------------------*
- * Gain decoding
- * Estimate spectrum tilt and voicing
- *--------------------------------------------------------------*/
-
- IF( LE_32( st_fx->core_brate, ACELP_8k00 ) )
- {
- gain_dec_lbr_fx( st_fx, st_fx->coder_type, i_subfr_fx, code_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, gc_mem, gp_mem, L_SUBFR );
- }
- ELSE IF( GT_32( st_fx->core_brate, ACELP_32k ) )
- {
- gain_dec_SQ_fx( st_fx, i_subfr_fx, code_fx, Es_pred_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx );
- }
- ELSE
- {
- gain_dec_mless_fx( st_fx, L_frame, st_fx->coder_type, i_subfr_fx, -1, code_fx, Es_pred_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx );
- }
- st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc ); // Q15
- move16();
-
- /*-----------------------------------------------------------------*
- * Transform domain contribution decoding
- *-----------------------------------------------------------------*/
- test();
- IF( GE_32( st_fx->core_brate, MAX_GSC_INACTIVE_BRATE ) && ( st_fx->coder_type == INACTIVE ) )
- {
- transf_cdbk_dec_fx( st_fx, harm_flag_acelp, i_subfr_fx, Es_pred_fx, gain_code_fx, &gain_preQ_fx, &norm_gain_preQ_fx, code_preQ_fx, unbits );
- }
-
- /* update LP filtered gains for the case of frame erasures */
- lp_gain_updt_fx( i_subfr_fx, gain_pit_fx, L_add( norm_gain_code_fx, norm_gain_preQ_fx ), &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_frame );
-
- /*----------------------------------------------------------------------*
- * Find the total excitation
- *----------------------------------------------------------------------*/
-
- IF( EQ_16( L_frame, L_FRAME ) ) /* Rescaling for 12.8k core */
- {
- Rescale_exc( hMusicPF->dct_post_old_exc_fx, &exc_fx[i_subfr_fx], &bwe_exc_fx[i_subfr_fx * HIBND_ACB_L_FAC], hGSCDec->last_exc_dct_in_fx,
- L_SUBFR, L_SUBFR * HIBND_ACB_L_FAC, gain_code_fx, &( st_fx->Q_exc ), st_fx->Q_subfr, exc2_fx, i_subfr_fx, st_fx->coder_type );
- }
- ELSE /* Rescaling for 16k core */
- {
-
- L_tmp_GC = L_max( gain_code_fx, L_shl( gain_preQ_fx, 16 ) ); /* Chose the maximum of gain_code or the prequantizer excitation x4 to keep some room*/
- Rescale_exc( hMusicPF->dct_post_old_exc_fx, &exc_fx[i_subfr_fx], &bwe_exc_fx[i_subfr_fx * 2], hGSCDec->last_exc_dct_in_fx,
- L_SUBFR, L_SUBFR * 2, L_tmp_GC, &( st_fx->Q_exc ), st_fx->Q_subfr, exc2_fx, i_subfr_fx, st_fx->coder_type );
- }
-
- gain_code16 = round_fx( L_shl( gain_code_fx, st_fx->Q_exc ) ); /*Q_exc*/
-
- /*-----------------------------------------------------------------*
- * Add the ACELP pre-quantizer contribution
- *-----------------------------------------------------------------*/
-
- IF( gain_preQ_fx != 0 )
- {
- IF( st_fx->element_mode == EVS_MONO )
- {
- tmp1_fx = add( 15 - Q_AVQ_OUT_DEC - 2, st_fx->Q_exc );
- }
- ELSE
- {
- tmp1_fx = add( 15 - Q_AVQ_OUT - 2, st_fx->Q_exc );
- }
- FOR( i = 0; i < L_SUBFR; i++ )
- {
- Word32 Ltmp1;
- /* Contribution from AVQ layer */
- Ltmp1 = L_mult( gain_preQ_fx, code_preQ_fx[i] ); /* Q2 + Q6 -> Q9*/
- Ltmp1 = L_shl_sat( Ltmp1, tmp1_fx ); /* Q16 + Q_exc */
-
- /* Compute exc2 */
- 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
- move16();
- /* gain_pit in Q14 */
- 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
- {
- Acelp_dec_total_exc( exc_fx, exc2_fx, gain_code16, gain_pit_fx, i_subfr_fx, code_fx, L_SUBFR );
- }
-
- /*-----------------------------------------------------------------*
- * Prepare TBE excitation
- *-----------------------------------------------------------------*/
-
- Word16 idx = 0;
- move16();
- IF( i_subfr_fx != 0 )
- {
- idx = idiv1616( i_subfr_fx, L_SUBFR );
- }
-
- prep_tbe_exc_fx( L_frame, i_subfr_fx, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx,
- &voice_factors_fx[idx], bwe_exc_fx, gain_preQ_fx, code_preQ_fx,
- st_fx->Q_exc, T0_fx, T0_frac_fx, st_fx->coder_type, st_fx->core_brate );
-
-
- /*----------------------------------------------------------------*
- * Excitation enhancements (update of total excitation signal)
- *----------------------------------------------------------------*/
-
- test();
- IF( GT_32( st_fx->core_brate, ACELP_32k ) || ( st_fx->coder_type == INACTIVE ) )
- {
- Copy( exc_fx + i_subfr_fx, exc2_fx + i_subfr_fx, L_SUBFR );
- }
- ELSE
- {
- enhancer_fx( st_fx->core_brate, 0, st_fx->coder_type, i_subfr_fx, L_frame, voice_fac_fx, st_fx->stab_fac_fx,
- norm_gain_code_fx, gain_inov_fx, &st_fx->gc_threshold_fx, code_fx, exc2_fx, gain_pit_fx, &( st_fx->dm_fx ), st_fx->Q_exc );
- }
-
- p_Aq_fx += ( M + 1 );
- pt_pitch_fx++;
- gain_buf[idx] = gain_pit_fx; // Q14
- move16();
- }
-
- /* FEC fast recovery */
-
- IF( do_WI_fx )
- {
- /* shft_prev = L_EXC_MEM - rint_new_fx(st_fx->bfi_pitch_fx);*/
- L_tmp = L_shl( L_deposit_l( st_fx->bfi_pitch_fx ), 10 ); /*Q16*/
- rint_bfi_pitch = rint_new_fx( L_tmp ); /*Q0*/
- shft_prev = sub( L_EXC_MEM, rint_bfi_pitch ); /*Q0*/
-
- p_exc = st_fx->hWIDec->old_exc2_fx + shft_prev;
- p_syn = st_fx->hWIDec->old_syn2_fx + shft_prev;
- move16();
- move16();
-
- prev_res_nrg = L_deposit_l( 1 );
- prev_spch_nrg = L_deposit_l( 1 );
- FOR( i = 0; i < rint_bfi_pitch; i++ )
- {
- 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 */
- p_exc++;
- p_syn++;
- }
-
- Copy( st_fx->mem_syn2_fx, mem_tmp_fx, M );
-
- syn_12k8_fx( st_fx->L_frame, Aq_fx, exc2_fx, syn_tmp_fx, mem_tmp_fx, 1, st_fx->Q_exc, st_fx->Q_syn );
-
- L_tmp = L_shl( L_deposit_l( pitch_buf_fx[NB_SUBFR16k - 1] ), 10 ); /*Q16*/
- rint_pitch = rint_new_fx( L_tmp ); /*Q0*/
- shft_curr = sub( st_fx->L_frame, rint_pitch ); /*Q0*/
-
- p_exc = exc2_fx + shft_curr;
- p_syn = syn_tmp_fx + shft_curr;
-
- curr_res_nrg = L_deposit_l( 1 );
- curr_spch_nrg = L_deposit_l( 1 );
- FOR( i = 0; i < rint_pitch; i++ )
- {
- 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 */
- p_exc++;
- p_syn++;
- }
-
- /* enratio = (curr_res_nrg / prev_res_nrg); */
- IF( prev_res_nrg > 0 )
- {
- expa = norm_l( prev_res_nrg );
- fraca = extract_h( L_shl( prev_res_nrg, expa ) ); /* 2*st_fx->prev_Q_exc_fr -16+expa +1*/
- expa = sub( 30, add( expa, ( shl( st_fx->prev_Q_exc_fr, 1 ) ) ) );
-
- expb = norm_l( curr_res_nrg );
- fracb = round_fx_sat( L_shl_sat( curr_res_nrg, expb ) ); /* 2*st_fx->Q_exc +expb+1 -16*/
- expb = sub( 30, add( expb, shl( st_fx->Q_exc, 1 ) ) );
-
- scale = shr( sub( fraca, fracb ), 15 );
- fracb = shl( fracb, scale ); // Q(15-expb)+scale
- expb = sub( expb, scale );
-
- enratio = div_s( fracb, fraca ); // Q(15-(expb-expa))
- exp1 = sub( expb, expa );
- Qenratio = sub( 15, exp1 );
- }
- ELSE
- {
- enratio = 0;
- move16();
- Qenratio = 0;
- move16();
- }
-
- /* sp_enratio = curr_spch_nrg/prev_spch_nrg */
- IF( prev_spch_nrg > 0 )
- {
- expa = norm_l( prev_spch_nrg );
- fraca = extract_h( L_shl( prev_spch_nrg, expa ) ); /* 2*st_fx->prev_Q_syn_fr +expa+1-16*/
- expa = sub( 30, add( expa, shl( st_fx->prev_Q_syn_fr, 1 ) ) );
-
- expb = norm_l( curr_spch_nrg );
- fracb = round_fx_sat( L_shl_sat( curr_spch_nrg, expb ) ); /* 2*st_fx->Q_syn +expb-16 */
- expb = sub( 30, add( expb, shl( st_fx->Q_syn, 1 ) ) );
-
- scale = shr( sub( fraca, fracb ), 15 );
- fracb = shl( fracb, scale ); // Q(15-expb) +scale
- expb = sub( expb, scale );
-
- sp_enratio = div_s( fracb, fraca ); // Q(15-(expb-expa))
- exp1 = sub( expb, expa );
- Qsp_enratio = sub( 15, exp1 );
- }
- ELSE
- {
- sp_enratio = 0;
- move16();
- Qsp_enratio = 0;
- move16();
- }
-
- test();
- test();
- test();
- test();
- 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*/
- {
- IF( NE_32( ( error = DTFS_new_fx( &PREVP ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- IF( NE_32( ( error = DTFS_new_fx( &CURRP ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- GetSinCosTab_fx( rint_bfi_pitch, S_fx, C_fx );
- DTFS_to_fs_fx( st_fx->hWIDec->old_exc2_fx + shft_prev, rint_bfi_pitch, PREVP, (Word16) st_fx->output_Fs, do_WI_fx, S_fx, C_fx );
- PREVP->Q = add( PREVP->Q, st_fx->prev_Q_exc_fr );
- move16();
-
- GetSinCosTab_fx( rint_pitch, S_fx, C_fx );
- DTFS_to_fs_fx( exc2_fx + shft_curr, rint_pitch, CURRP, (Word16) st_fx->output_Fs, do_WI_fx, S_fx, C_fx );
- CURRP->Q = add( CURRP->Q, st_fx->Q_exc );
- move16();
-
- ph_offset_fx = 0;
- move16();
- IF( NE_32( ( error = WIsyn_fx( *PREVP, CURRP, dummy2, &( ph_offset_fx ), out_fx, (Word16) st_fx->L_frame, 1, S_fx, C_fx, pf_temp1, pf_temp2, pf_temp, pf_n2 ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
-
- Copy_Scale_sig( out_fx, exc2_fx, st_fx->L_frame, st_fx->Q_exc ); // Q_exc
- Copy_Scale_sig( out_fx, exc_fx, st_fx->L_frame, st_fx->Q_exc ); // Q_exc
-
- /* update bwe_exc for SWB-TBE */
- FOR( i_subfr_fx = 0; i_subfr_fx < L_frame; i_subfr_fx += L_SUBFR )
- {
- interp_code_4over2_fx( exc_fx + i_subfr_fx, bwe_exc_fx + shl( i_subfr_fx, 1 ), L_SUBFR );
- }
-
- free( PREVP );
- free( CURRP );
- }
- }
-
- /* SC-VBR */
- st_fx->prev_gain_pit_dec_fx = gain_pit_fx;
- move16(); /*Q14*/
- st_fx->prev_tilt_code_dec_fx = st_fx->tilt_code_fx;
- move16(); /*Q15*/
-
- return error;
-}
-
-/*======================================================================*/
-/* FUNCTION : decod_gen_voic_ivas_fx() */
-/*----------------------------------------------------------------------*/
-/* PURPOSE : Decode generic (GC), voiced (VC) and AMR-WB IO frames */
-/* */
-/*----------------------------------------------------------------------*/
-/* GLOBAL INPUT ARGUMENTS : */
-/* _ (Struct) st_fx : decoder static memory */
-/* _ (Word16) L_frame : length of the frame */
-
-/* _ (Word16[]) Aq_fx : LP filter coefficient Q12 */
-/* _ (Word16) Es_pred_fx : predicted scaled innov. energy Q8 */
-/* _ (Word16[]) pitch_buf_fx : floating pitch values for each subframe Q6*/
-/* _ (Word16[]) voice_factors_fx: frame error rate Q15 */
-/*----------------------------------------------------------------------*/
-/* OUTPUT ARGUMENTS : */
-/* _ (Word16[]) exc_fx : adapt. excitation exc (Q_exc) */
-/* _ (Word16[]) exc2_fx : adapt. excitation/total exc (Q_exc) */
-/*----------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------*/
-/* RETURN ARGUMENTS : */
-/* _ None */
-/*======================================================================*/
-#endif
-ivas_error decod_gen_voic_ivas_fx(
- Decoder_State *st_fx, /* i/o: decoder static memory */
- const Word16 L_frame, /* i : length of the frame */
- const Word16 sharpFlag_fx, /* i : formant sharpening flag */
- const Word16 *Aq_fx, /* i : LP filter coefficient Q12*/
- const Word16 Es_pred_fx, /* i : predicted scaled innov. energy Q8 */
- const Word16 do_WI_fx, /* i : do interpolation after a FER */
- Word16 *pitch_buf_fx, /* o : Word16 pitch values for each subframe Q6*/
- Word16 *voice_factors_fx, /* o : voicing factors Q15 */
- Word16 *exc_fx, /* i/o: adapt. excitation exc Q_exc */
- Word16 *exc2_fx, /* i/o: adapt. excitation/total exc Q_exc */
- Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q_exc */
- Word16 *unbits, /* number of unused bits */
- Word16 *gain_buf,
- const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
- const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer Q6 */
-)
-{
-
-
- Word16 T0_fx, T0_frac_fx, T0_min_fx, T0_max_fx; /* integer pitch variables */
+ Word16 T0_fx, T0_frac_fx, T0_min_fx, T0_max_fx; /* integer pitch variables */
Word16 gain_pit_fx; /* pitch gain Q14 */
Word32 gain_code_fx; /* gain/normalized gain of the algebraic excitation Q16 */
Word32 norm_gain_code_fx; /* normalized gain of the algebraic excitation Q16 */
@@ -536,7 +62,7 @@ ivas_error decod_gen_voic_ivas_fx(
Word16 code_fx[L_SUBFR]; /* algebraic codevector Q12 */
const Word16 *p_Aq_fx; /* Pointer to frame LP coefficient Q12 */
- Word16 *pt_pitch_fx; /* pointer to Word16 pitch Q6 */
+ Word16 *pt_pitch_fx; /* pointer to Word16 pitch Q6 */
Word16 i_subfr_fx, i; /* tmp variables */
Word16 error_fx;
Word16 gain_preQ_fx; /* Gain of prequantizer excitation */
@@ -633,17 +159,21 @@ ivas_error decod_gen_voic_ivas_fx(
* Decode pitch lag
*----------------------------------------------------------------------*/
- /**pt_pitch_fx = pit_decode_fx(st_fx, st_fx->core_brate, 0, L_frame, i_subfr_fx, st_fx->coder_type, &pitch_limit_flag_fx,
- &T0_fx, &T0_frac_fx, &T0_min_fx, &T0_max_fx, L_SUBFR);*/
- *pt_pitch_fx = pit_decode_ivas_fx( st_fx, st_fx->core_brate, 0, L_frame, i_subfr_fx, st_fx->coder_type, &pitch_limit_flag_fx,
- &T0_fx, &T0_frac_fx, &T0_min_fx, &T0_max_fx, L_SUBFR, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf );
+ *pt_pitch_fx = pit_decode_fx( st_fx, st_fx->core_brate, 0, L_frame, i_subfr_fx, st_fx->coder_type, &pitch_limit_flag_fx,
+ &T0_fx, &T0_frac_fx, &T0_min_fx, &T0_max_fx, L_SUBFR, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf );
move16(); /*Q6*/
/*--------------------------------------------------------------*
* Find the adaptive codebook vector
*--------------------------------------------------------------*/
-
- pred_lt4( &exc_fx[i_subfr_fx], &exc_fx[i_subfr_fx], T0_fx, T0_frac_fx, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ IF( st_fx->element_mode != EVS_MONO )
+ {
+ pred_lt4_ivas_fx( &exc_fx[i_subfr_fx], &exc_fx[i_subfr_fx], T0_fx, T0_frac_fx, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ }
+ ELSE
+ {
+ pred_lt4( &exc_fx[i_subfr_fx], &exc_fx[i_subfr_fx], T0_fx, T0_frac_fx, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ }
// 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 );
@@ -677,7 +207,7 @@ ivas_error decod_gen_voic_ivas_fx(
IF( LE_32( st_fx->core_brate, ACELP_8k00 ) )
{
- gain_dec_lbr_ivas_fx( st_fx, st_fx->coder_type, i_subfr_fx, code_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, gc_mem, gp_mem, L_SUBFR );
+ gain_dec_lbr_fx( st_fx, st_fx->coder_type, i_subfr_fx, code_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, gc_mem, gp_mem, L_SUBFR );
}
ELSE IF( GT_32( st_fx->core_brate, ACELP_32k ) )
{
@@ -700,13 +230,11 @@ ivas_error decod_gen_voic_ivas_fx(
}
/* update LP filtered gains for the case of frame erasures */
-#ifdef REMOVE_EVS_DUPLICATES
IF( EQ_16( st_fx->element_mode, EVS_MONO ) )
{
lp_gain_updt_fx( i_subfr_fx, gain_pit_fx, L_add( norm_gain_code_fx, norm_gain_preQ_fx ), &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_frame );
}
ELSE
-#endif
{
lp_gain_updt_ivas_fx( i_subfr_fx, gain_pit_fx, L_add( norm_gain_code_fx, norm_gain_preQ_fx ), &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_frame );
}
@@ -790,10 +318,6 @@ ivas_error decod_gen_voic_ivas_fx(
* Prepare TBE excitation
*-----------------------------------------------------------------*/
- /*prep_tbe_exc_fx(L_frame, i_subfr_fx, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx,
- &voice_factors_fx[i_subfr_fx / L_SUBFR], bwe_exc_fx, gain_preQ_fx, code_preQ_fx,
- st_fx->Q_exc, T0_fx, T0_frac_fx, st_fx->coder_type, st_fx->core_brate);*/
-
Word16 idx;
idx = 0;
move16();
@@ -802,10 +326,10 @@ ivas_error decod_gen_voic_ivas_fx(
idx = idiv1616( i_subfr_fx, L_SUBFR );
}
- prep_tbe_exc_ivas_fx( L_frame, L_SUBFR, i_subfr_fx, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx,
- &voice_factors_fx[idx], bwe_exc_fx, gain_preQ_fx, code_preQ_fx,
- st_fx->Q_exc, T0_fx, T0_frac_fx, st_fx->coder_type, st_fx->core_brate,
- st_fx->element_mode, st_fx->idchan, st_fx->hBWE_TD != NULL, st_fx->tdm_LRTD_flag );
+ prep_tbe_exc_fx( L_frame, L_SUBFR, i_subfr_fx, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx,
+ &voice_factors_fx[idx], bwe_exc_fx, gain_preQ_fx, code_preQ_fx,
+ st_fx->Q_exc, T0_fx, T0_frac_fx, st_fx->coder_type, st_fx->core_brate,
+ st_fx->element_mode, st_fx->idchan, st_fx->hBWE_TD != NULL, st_fx->tdm_LRTD_flag );
/*----------------------------------------------------------------*
@@ -819,17 +343,15 @@ ivas_error decod_gen_voic_ivas_fx(
}
ELSE
{
-#ifdef REMOVE_EVS_DUPLICATES
IF( EQ_16( st_fx->element_mode, EVS_MONO ) )
{
enhancer_fx( st_fx->core_brate, 0, st_fx->coder_type, i_subfr_fx, L_frame, voice_fac_fx, st_fx->stab_fac_fx,
norm_gain_code_fx, gain_inov_fx, &st_fx->gc_threshold_fx, code_fx, exc2_fx, gain_pit_fx, &( st_fx->dm_fx ), st_fx->Q_exc );
}
ELSE
-#endif
{
- enhancer_ivas_fx2( st_fx->core_brate, 0, st_fx->coder_type, i_subfr_fx, L_frame, voice_fac_fx, st_fx->stab_fac_fx,
- norm_gain_code_fx, gain_inov_fx, &st_fx->gc_threshold_fx, code_fx, exc2_fx, gain_pit_fx, &( st_fx->dm_fx ), st_fx->Q_exc );
+ enhancer_ivas_fx( MODE1, st_fx->core_brate, -1, 0, st_fx->coder_type, i_subfr_fx, L_frame, voice_fac_fx, st_fx->stab_fac_fx,
+ norm_gain_code_fx, gain_inov_fx, &st_fx->gc_threshold_fx, code_fx, exc2_fx, gain_pit_fx, &( st_fx->dm_fx ), st_fx->Q_exc );
}
}
diff --git a/lib_dec/dec_higher_acelp_fx.c b/lib_dec/dec_higher_acelp_fx.c
index aff7e56564e134e0492ba56f92bed3e6882af87b..6144765a8707dec75df9f6ffd037cb64681ddb17 100644
--- a/lib_dec/dec_higher_acelp_fx.c
+++ b/lib_dec/dec_higher_acelp_fx.c
@@ -8,7 +8,6 @@
#include "prot_fx.h" /* Function prototypes */
#include "rom_com.h" /* Static table prototypes */
-#define IVAS_CODE_AVQ
/*-----------------------------------------------------------------*
* transf_cdbk_dec()
* Transform domain contribution decoding
@@ -129,7 +128,6 @@ void transf_cdbk_dec_fx(
* Demultiplex and decode subvectors from bit-stream
*--------------------------------------------------------------*/
-#ifdef IVAS_CODE_AVQ
AVQ_demuxdec_fx( st_fx, code_preQ, &nBits, 8, nq, avq_bit_sFlag, trgtSvPos );
Word16 q_Code_preQ;
IF( ( st_fx->element_mode == EVS_MONO ) )
@@ -142,9 +140,6 @@ void transf_cdbk_dec_fx(
q_Code_preQ = Q_AVQ_OUT;
move16();
}
-#else
- AVQ_demuxdec_fx( st_fx, code_preQ, &nBits, 8, nq );
-#endif
FOR( i = 0; i < L_SUBFR; i++ )
{
code_preQ[i] = shl_o( code_preQ[i], q_Code_preQ, &Overflow );
@@ -185,7 +180,6 @@ void transf_cdbk_dec_fx(
st_fx->last_nq_preQ = nq[7];
move16();
-#ifdef IVAS_CODE_AVQ
/* TD pre-quantizer: in extreme cases at subframe boundaries, lower the preemphasis memory to avoid a saturation */
test();
test();
@@ -209,7 +203,6 @@ void transf_cdbk_dec_fx(
st_fx->last_code_preq = code_preQ[L_SUBFR - 1]; // q_Code_preQ
move16();
-#endif
PREEMPH_FX( code_preQ, FAC_PRE_AVQ_FX, L_SUBFR, &st_fx->mem_preemp_preQ_fx );
/*--------------------------------------------------------------*
* Compute normalized prequantizer excitation gain for FEC
diff --git a/lib_dec/dec_pit_exc_fx.c b/lib_dec/dec_pit_exc_fx.c
index fe7d2daafc2174eaadae31ab929f3b1e57b176fa..ca6660fabe33908ad18c9f466f60afa9a3c88848 100644
--- a/lib_dec/dec_pit_exc_fx.c
+++ b/lib_dec/dec_pit_exc_fx.c
@@ -14,13 +14,13 @@
/*--------------------------------------------------------------------------*/
/* INPUT ARGUMENTS : */
/* _ (Word16*) Aq_fx : LP filter coefficient Q12 */
-/* _ (Word16) coder_type : coding type Q0 */
+/* _ (Word16) coder_type : coding type Q0 */
/* _ (Word16) nb_subfr_fx :Number of subframe considered */
/* _ (Word16) Es_pred_fx :predicted scaled innov. energy */
/*--------------------------------------------------------------------------*/
/* OUTPUT ARGUMENTS : */
/* _ (Word16*) pitch_buf_fx : floating pitch values for each subframe Q6 */
-/* _ (Word16*) code_fx : innovation Q12 */
+/* _ (Word16*) code_fx : innovation Q12 */
/*--------------------------------------------------------------------------*/
/* INPUT/OUTPUT ARGUMENTS : */
/* Decoder_State_fx *st_fx : decoder state structure */
@@ -30,438 +30,29 @@
/* _ None */
/*==========================================================================*/
-#ifndef REMOVE_EVS_DUPLICATES
void dec_pit_exc_fx(
- Decoder_State *st_fx, /* i/o: decoder static memory */
- const Word16 *Aq_fx, /* i : LP filter coefficient */
- const Word16 coder_type, /* i : coding type */
- const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */
- Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */
- Word16 *code_fx, /* o : innovation */
- Word16 *exc_fx, /* i/o: adapt. excitation exc */
- Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */
- const Word16 nb_subfr_fx /* i : Number of subframe considered */
- ,
- Word16 *gain_buf /*Q14*/
-)
-{
- Word16 T0_fx, T0_frac_fx, T0_min_fx, T0_max_fx; /* integer pitch variables */
- Word16 gain_pit_fx; /* pitch gain Q14 */
- Word32 gain_code_fx; /* gain/normalized gain of the algebraic excitation Q16 */
- Word32 norm_gain_code_fx; /* normalized gain of the algebraic excitation Q16 */
- Word16 gain_inov_fx; /* Innovation gain Q12 */
- Word16 voice_fac_fx; /* voicing factor Q15 */
- Word16 L_subfr_fx, pit_idx_fx;
- const Word16 *p_Aq_fx; /* Pointer to frame LP coefficient Q12 */
- Word16 *pt_pitch_fx; /* pointer to floating pitch Q6 */
- Word16 i_subfr_fx, i; /* tmp variables */
- Word32 Local_BR_fx, Pitch_BR_fx;
- Word16 pitch_limit_flag, Pitch_CT_fx;
- Word16 exc2_bidon[L_SUBFR];
- Word16 *pt_gain; /* Pointer to floating gain values for each subframe */
-
- Word16 gain_code16, gain_pitx2;
- Word32 L_tmp;
- Word16 nbits;
- GSC_DEC_HANDLE hGSCDec;
- gain_pit_fx = 0;
- move16();
- hGSCDec = st_fx->hGSCDec;
-
- MUSIC_POSTFILT_HANDLE hMusicPF;
- hMusicPF = st_fx->hMusicPF;
-
- Word16 use_fcb;
- Word32 gc_mem[NB_SUBFR - 1]; /* gain_code from previous subframes */
- Word16 gp_mem[NB_SUBFR - 1]; /* gain_pitch from previous subframes */
-#ifdef BASOP_NOGLOB_DECLARE_LOCAL
- Flag Overflow = 0;
- move16();
-#endif
-
- use_fcb = 0;
- move16();
- test();
- test();
- IF( ( st_fx->GSC_IVAS_mode > 0 ) && ( EQ_16( st_fx->GSC_noisy_speech, 1 ) || GT_32( st_fx->core_brate, GSC_H_RATE_STG ) ) )
- {
- Local_BR_fx = ACELP_8k00;
- Pitch_CT_fx = GENERIC;
- Pitch_BR_fx = ACELP_8k00;
- move32();
- move32();
- move16();
- IF( EQ_16( st_fx->L_frame, L_FRAME16k ) )
- {
- Local_BR_fx = ACELP_14k80;
- move32();
- if ( st_fx->GSC_IVAS_mode > 0 )
- {
- Local_BR_fx = ACELP_9k60;
- move32();
- }
- Pitch_BR_fx = st_fx->core_brate;
- move32();
- }
- }
- ELSE IF( EQ_16( st_fx->GSC_noisy_speech, 1 ) )
- {
- Local_BR_fx = ACELP_7k20;
- move32();
- Pitch_CT_fx = GENERIC;
- move16();
- Pitch_BR_fx = ACELP_7k20;
- move32();
- if ( EQ_16( st_fx->L_frame, L_FRAME16k ) )
- {
- Pitch_BR_fx = st_fx->core_brate;
- move32();
- }
- }
- ELSE
- {
- Local_BR_fx = ACELP_7k20;
- move32();
- Pitch_CT_fx = AUDIO;
- move16();
- Pitch_BR_fx = st_fx->core_brate;
- move32();
- IF( EQ_16( st_fx->L_frame, L_FRAME16k ) )
- {
- Pitch_BR_fx = ACELP_13k20;
- move32();
- Pitch_CT_fx = GENERIC;
- move16();
- }
- }
- L_subfr_fx = mult_r( st_fx->L_frame, div_s( 1, nb_subfr_fx ) ); /* TV2Opt : this could be less complex with 2 ifs*/
-
-
- gain_code_fx = 0;
- move16();
- pitch_limit_flag = 1;
- move16(); /* always extended pitch Q range */
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- IF( ( ( GE_32( st_fx->core_brate, MIN_RATE_FCB ) || ( EQ_16( st_fx->GSC_noisy_speech, 1 ) && ( ( EQ_16( st_fx->L_frame, L_FRAME ) && GE_32( st_fx->core_brate, ACELP_13k20 ) ) || ( EQ_16( st_fx->L_frame, L_FRAME16k ) && GE_32( st_fx->core_brate, GSC_H_RATE_STG ) ) || st_fx->GSC_IVAS_mode == 0 ) ) ) && EQ_16( L_subfr_fx, L_SUBFR ) ) )
- {
- use_fcb = 1;
- move16();
- }
- ELSE IF( ( st_fx->GSC_IVAS_mode > 0 ) && EQ_16( L_subfr_fx, 2 * L_SUBFR ) && LT_16( st_fx->GSC_IVAS_mode, 3 ) )
- {
- use_fcb = 2;
- st_fx->acelp_cfg.fcb_mode = 1;
- move16();
- move16();
- set16_fx( st_fx->acelp_cfg.gains_mode, 6, 4 );
- set16_fx( st_fx->acelp_cfg.pitch_bits, 9, 4 );
- set16_fx( st_fx->acelp_cfg.fixed_cdk_index, 14, 5 );
- }
- /*------------------------------------------------------------------*
- * ACELP subframe loop
- *------------------------------------------------------------------*/
- p_Aq_fx = Aq_fx; /* pointer to interpolated LPC parameters */
- pt_pitch_fx = pitch_buf_fx; /* pointer to the pitch buffer */
- pt_gain = gain_buf; /* pointer to the gain buffer */
- FOR( i_subfr_fx = 0; i_subfr_fx < st_fx->L_frame; i_subfr_fx += L_subfr_fx )
- {
- /*----------------------------------------------------------------------*
- * Decode pitch lag
- *----------------------------------------------------------------------*/
- *pt_pitch_fx = pit_decode_fx( st_fx, Pitch_BR_fx, 0, st_fx->L_frame, i_subfr_fx, Pitch_CT_fx, &pitch_limit_flag, &T0_fx, &T0_frac_fx, &T0_min_fx, &T0_max_fx, L_subfr_fx );
- move16();
-
- /*--------------------------------------------------------------*
- * Find the adaptive codebook vector.
- *--------------------------------------------------------------*/
-
- pred_lt4( &exc_fx[i_subfr_fx], &exc_fx[i_subfr_fx], T0_fx, T0_frac_fx, L_subfr_fx + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
-
- /*--------------------------------------------------------------*
- * Innovation decoding
- *--------------------------------------------------------------*/
-
- IF( EQ_16( use_fcb, 1 ) )
- {
- inov_decode_fx( st_fx, Local_BR_fx, 0, st_fx->L_frame, 1, i_subfr_fx, p_Aq_fx, st_fx->tilt_code_fx, *pt_pitch_fx, code_fx, L_subfr_fx );
- /*--------------------------------------------------------------*
- * Gain decoding
- * Estimate spectrum tilt and voicing
- *--------------------------------------------------------------*/
-
- gain_dec_mless_fx( st_fx, st_fx->L_frame, LOCAL_CT, i_subfr_fx, -1, code_fx, Es_pred_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx );
-
- st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, 0 );
- move16();
- }
- ELSE IF( EQ_16( use_fcb, 2 ) ) /* IVAS only */
- {
- inov_decode_fx( st_fx, Local_BR_fx, 0, st_fx->L_frame, 1, i_subfr_fx, p_Aq_fx, st_fx->tilt_code_fx, *pt_pitch_fx, code_fx, L_subfr_fx );
- /*--------------------------------------------------------------*
- * Gain decoding
- * Estimate spectrum tilt and voicing
- *--------------------------------------------------------------*/
-
- gain_dec_lbr_fx( st_fx, GENERIC, i_subfr_fx, code_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, gc_mem, gp_mem, L_subfr_fx );
-
- st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, 0 );
- move16();
- }
- ELSE
- {
- nbits = 5;
- move16();
- if ( LT_32( st_fx->core_brate, MIN_RATE_FCB ) )
- {
- nbits = 4;
- move16();
- }
-
- set16_fx( code_fx, 0, L_SUBFR );
- gain_code_fx = L_deposit_l( 0 );
- st_fx->tilt_code_fx = 0;
- move16();
- pit_idx_fx = (Word16) get_next_indice( st_fx, nbits );
- move16();
-
- gain_pit_fx = add( 9590, dic_gp_fx[pit_idx_fx] );
- move16(); /*Q14 0.5853 in Q14 9590*/
-
- if ( st_fx->BER_detect ) /* Bitstream is corrupted, use the past pitch gain */
- {
- gain_pit_fx = st_fx->lp_gainp_fx;
- move16();
- }
- 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*/
- }
-
- /*----------------------------------------------------------------------*
- * Find the total excitation
- *----------------------------------------------------------------------*/
-
- Rescale_exc( hMusicPF->dct_post_old_exc_fx, &exc_fx[i_subfr_fx], &bwe_exc_fx[( i_subfr_fx * ( 2 * HIBND_ACB_L_FAC ) ) / 2], hGSCDec->last_exc_dct_in_fx,
- L_subfr_fx, shr( imult1616( L_subfr_fx, 2 * HIBND_ACB_L_FAC ), 1 ), gain_code_fx, &( st_fx->Q_exc ), st_fx->Q_subfr, NULL, i_subfr_fx, coder_type );
-
- gain_code16 = round_fx( L_shl( gain_code_fx, st_fx->Q_exc ) ); /*Q_exc*/
-
- IF( use_fcb != 0 )
- {
- Acelp_dec_total_exc( exc_fx, exc2_bidon - i_subfr_fx, gain_code16, gain_pit_fx, i_subfr_fx, code_fx, L_subfr_fx );
- }
- ELSE
- {
- IF( norm_s( s_or( gain_pit_fx, 1 ) ) == 0 )
- {
- FOR( i = 0; i < L_subfr_fx; i++ )
- {
- 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*/
- move16();
- }
- }
- ELSE
- {
- gain_pitx2 = shl( gain_pit_fx, 1 ); /*Q15*/
-
- FOR( i = 0; i < L_subfr_fx; i++ )
- {
- L_tmp = L_mult( gain_pitx2, exc_fx[i + i_subfr_fx] ); /*Q16+Q_exc*/
- exc_fx[i + i_subfr_fx] = round_fx_sat( L_tmp ); /*Q_exc*/
- move16();
- }
- }
- }
-
- IF( EQ_16( L_subfr_fx, L_FRAME16k ) )
- {
- /* update gains for FEC - equivalent to lp_gain_updt() */
- st_fx->lp_gainp_fx = gain_pit_fx;
- move16();
- st_fx->lp_gainc_fx = 0;
- move32();
-
- pt_pitch_fx++;
- *pt_pitch_fx = *( pt_pitch_fx - 1 );
- pt_pitch_fx++;
- *pt_pitch_fx = *( pt_pitch_fx - 1 );
- pt_pitch_fx++;
- *pt_pitch_fx = *( pt_pitch_fx - 1 );
- pt_pitch_fx++;
- *pt_pitch_fx = *( pt_pitch_fx - 1 );
- pt_pitch_fx++;
- move16();
- move16();
- move16();
- move16();
- p_Aq_fx += 5 * ( M + 1 );
- }
- ELSE IF( EQ_16( L_subfr_fx, L_FRAME16k / 2 ) )
- {
- IF( i_subfr_fx == 0 )
- {
- pt_pitch_fx++;
- *pt_pitch_fx = *( pt_pitch_fx - 1 );
- pt_pitch_fx++;
- p_Aq_fx += 2 * ( M + 1 );
- move16();
-
- /* update gains for FEC - equivalent to lp_gain_updt() */
- st_fx->lp_gainp_fx = extract_h( L_mult( 6554, gain_pit_fx ) ); /*Q14 (3/15 in Q15 9830)*/
- st_fx->lp_gainc_fx = 0;
- move16();
- move16();
- }
- ELSE
- {
- pt_pitch_fx++;
- *pt_pitch_fx = *( pt_pitch_fx - 1 );
- pt_pitch_fx++;
- *pt_pitch_fx = *( pt_pitch_fx - 1 );
- pt_pitch_fx++;
- p_Aq_fx += 3 * ( M + 1 );
- move16();
- move16();
-
- /* update gains for FEC - equivalent to lp_gain_updt() */
- st_fx->lp_gainp_fx = extract_h( L_mult( 26214, gain_pit_fx ) ); /*Q14 (12/15 in Q15 9830)*/
- st_fx->lp_gainc_fx = 0;
- move16();
- move16();
- }
- }
- ELSE IF( EQ_16( L_subfr_fx, 128 ) ) /*2*L_SUBFR*/
- {
- p_Aq_fx += 2 * ( M + 1 );
- pt_pitch_fx++;
- *pt_pitch_fx = *( pt_pitch_fx - 1 );
- move16();
- pt_pitch_fx++;
- *pt_gain = gain_pit_fx;
- move16();
- pt_gain++;
- *pt_gain = *( pt_gain - 1 );
- move16();
- pt_gain++;
- IF( i_subfr_fx == 0 )
- {
- /* update gains for FEC - equivalent to lp_gain_updt() */
- st_fx->lp_gainp_fx = extract_h( L_mult( 9830, gain_pit_fx ) ); /*Q14 (3/10 in Q15 9830)*/
- st_fx->lp_gainc_fx = 0;
- move16();
- move16();
- }
- ELSE
- {
- /* update gains for FEC - equivalent to lp_gain_updt() */
- st_fx->lp_gainp_fx = extract_h( L_mult( 22938, gain_pit_fx ) ); /*Q14 (7/10 in Q15 22938)*/
- st_fx->lp_gainc_fx = 0;
- move16();
- move16();
- }
- }
- ELSE IF( EQ_16( L_subfr_fx, 256 ) ) /*4*L_SUBFR*/
- {
- pt_pitch_fx++;
- *pt_pitch_fx = *( pt_pitch_fx - 1 );
- move16();
- pt_pitch_fx++;
- *pt_pitch_fx = *( pt_pitch_fx - 1 );
- move16();
- pt_pitch_fx++;
- *pt_pitch_fx = *( pt_pitch_fx - 1 );
- move16();
- pt_pitch_fx++;
- *pt_gain = gain_pit_fx;
- move16();
- pt_gain++;
- *pt_gain = *( pt_gain - 1 );
- move16();
- pt_gain++;
- *pt_gain = *( pt_gain - 1 );
- move16();
- pt_gain++;
- *pt_gain = *( pt_gain - 1 );
- move16();
- pt_gain++;
- p_Aq_fx += 4 * ( M + 1 );
-
- /* update gains for FEC - equivalent to lp_gain_updt() */
- st_fx->lp_gainp_fx = gain_pit_fx;
- move16();
- st_fx->lp_gainc_fx = 0;
- move16();
- }
- ELSE
- {
- p_Aq_fx += ( M + 1 );
- move16();
- pt_pitch_fx++;
- move16();
- *pt_gain = gain_pit_fx;
- move16();
- pt_gain++;
-
- lp_gain_updt_fx( i_subfr_fx, gain_pit_fx, 0, &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, st_fx->L_frame );
- }
- }
-
- return;
-}
-
-/*==========================================================================*/
-/* FUNCTION : void dec_pit_exc_ivas_fx() */
-/*--------------------------------------------------------------------------*/
-/* PURPOSE : Decode pitch only contribution */
-/*--------------------------------------------------------------------------*/
-/* INPUT ARGUMENTS : */
-/* _ (Word16*) Aq_fx : LP filter coefficient Q12 */
-/* _ (Word16) coder_type : coding type Q0 */
-/* _ (Word16) nb_subfr_fx :Number of subframe considered */
-/* _ (Word16) Es_pred_fx :predicted scaled innov. energy */
-/*--------------------------------------------------------------------------*/
-/* OUTPUT ARGUMENTS : */
-/* _ (Word16*) pitch_buf_fx : Word16 pitch values for each subframe Q6 */
-/* _ (Word16*) code_fx : innovation */
-/*--------------------------------------------------------------------------*/
-/* INPUT/OUTPUT ARGUMENTS : */
-/* Decoder_State_fx *st_fx : decoder state structure */
-/* _ (Word16*) exc_fx : adapt. excitation exc */
-/*--------------------------------------------------------------------------*/
-/* RETURN ARGUMENTS : */
-/* _ None */
-/*==========================================================================*/
-#endif
-void dec_pit_exc_ivas_fx(
Decoder_State *st_fx, /* i/o: decoder static memory */
const Word16 *Aq_fx, /* i : LP filter coefficient */
const Word16 coder_type, /* i : coding type */
const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */
- Word16 *pitch_buf_fx, /* o : Word16 pitch values for each subframe */
+ Word16 *pitch_buf_fx, /* o : Word16 pitch values for each subframe */
Word16 *code_fx, /* o : innovation */
Word16 *exc_fx, /* i/o: adapt. excitation exc */
Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */
const Word16 nb_subfr_fx, /* i : Number of subframe considered */
- Word16 *gain_buf, /*Q14*/
+ Word16 *gain_buf, /* o : Word16 pitch gain for each subframe Q14*/
const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */
)
{
- Word16 T0_fx, T0_frac_fx, T0_min_fx, T0_max_fx; /* integer pitch variables */
- Word16 gain_pit_fx; /* pitch gain Q14 */
- Word32 gain_code_fx; /* gain/normalized gain of the algebraic excitation Q16 */
+ Word16 T0_fx, T0_frac_fx, T0_min_fx, T0_max_fx; /* integer pitch variables */
+ Word16 gain_pit_fx; /* pitch gain Q14 */
+ Word32 gain_code_fx; /* gain/normalized gain of the algebraic excitation Q16 */
Word32 norm_gain_code_fx; /* normalized gain of the algebraic excitation Q16 */
- Word16 gain_inov_fx; /* Innovation gain Q12 */
+ Word16 gain_inov_fx; /* Innovation gain Q12 */
Word16 voice_fac_fx; /* voicing factor Q15 */
Word16 L_subfr_fx, pit_idx_fx;
- const Word16 *p_Aq_fx; /* Pointer to frame LP coefficient Q12 */
+ const Word16 *p_Aq_fx; /* Pointer to frame LP coefficient Q12 */
Word16 *pt_pitch_fx; /* pointer to Word16 pitch Q6 */
Word16 i_subfr_fx, i; /* tmp variables */
Word32 Local_BR_fx, Pitch_BR_fx;
@@ -578,20 +169,27 @@ void dec_pit_exc_ivas_fx(
p_Aq_fx = Aq_fx; /* pointer to interpolated LPC parameters */
pt_pitch_fx = pitch_buf_fx; /* pointer to the pitch buffer */
pt_gain = gain_buf; /* pointer to the gain buffer */
+
FOR( i_subfr_fx = 0; i_subfr_fx < st_fx->L_frame; i_subfr_fx += L_subfr_fx )
{
/*----------------------------------------------------------------------*
* Decode pitch lag
*----------------------------------------------------------------------*/
- *pt_pitch_fx = pit_decode_ivas_fx( st_fx, Pitch_BR_fx, 0, st_fx->L_frame, i_subfr_fx, Pitch_CT_fx, &pitch_limit_flag, &T0_fx, &T0_frac_fx, &T0_min_fx, &T0_max_fx, L_subfr_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf );
+ *pt_pitch_fx = pit_decode_fx( st_fx, Pitch_BR_fx, 0, st_fx->L_frame, i_subfr_fx, Pitch_CT_fx, &pitch_limit_flag, &T0_fx, &T0_frac_fx, &T0_min_fx, &T0_max_fx, L_subfr_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf );
move16();
/*--------------------------------------------------------------*
* Find the adaptive codebook vector.
*--------------------------------------------------------------*/
-
- pred_lt4( &exc_fx[i_subfr_fx], &exc_fx[i_subfr_fx], T0_fx, T0_frac_fx, L_subfr_fx + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ IF( st_fx->element_mode != EVS_MONO )
+ {
+ pred_lt4_ivas_fx( &exc_fx[i_subfr_fx], &exc_fx[i_subfr_fx], T0_fx, T0_frac_fx, L_subfr_fx + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ }
+ ELSE
+ {
+ pred_lt4( &exc_fx[i_subfr_fx], &exc_fx[i_subfr_fx], T0_fx, T0_frac_fx, L_subfr_fx + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ }
/*--------------------------------------------------------------*
* Innovation decoding
@@ -621,7 +219,7 @@ void dec_pit_exc_ivas_fx(
* Estimate spectrum tilt and voicing
*--------------------------------------------------------------*/
- gain_dec_lbr_ivas_fx( st_fx, GENERIC, i_subfr_fx, code_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, gc_mem, gp_mem, L_subfr_fx );
+ gain_dec_lbr_fx( st_fx, GENERIC, i_subfr_fx, code_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, gc_mem, gp_mem, L_subfr_fx );
st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, 0, L_subfr_fx, 0 );
move16();
diff --git a/lib_dec/dec_post_fx.c b/lib_dec/dec_post_fx.c
index 281281ed6ae0cf151cb9e18a59eb45fcd86aff86..37d088a8f98d7049e8ed7d130e26f5e2deab8e22 100644
--- a/lib_dec/dec_post_fx.c
+++ b/lib_dec/dec_post_fx.c
@@ -33,10 +33,7 @@ static void calc_st_filt_local_fx( Word16 *apond2, Word16 *apond1, Word16 *parco
static void modify_pst_param_fx( const Word16 lp_noise, Word16 *g1, Word16 *g2, const Word16 coder_type, Word16 *gain_factor );
-#ifndef REMOVE_EVS_DUPLICATES
static void Dec_formant_postfilt_fx( PFSTAT_HANDLE hPFstat, Word16 *signal_ptr, Word16 *coeff, Word16 *sig_out, Word16 gamma1, Word16 gamma2 );
-#endif
-static void Dec_formant_postfilt_ivas_fx( PFSTAT_HANDLE hPFstat, Word16 *signal_ptr, Word16 *coeff, Word16 *sig_out, Word16 gamma1, Word16 gamma2 );
static void calc_st_filt_ivas_fx( Word16 *apond2, Word16 *apond1, Word16 *parcor0, Word16 *sig_ltp_ptr, Word16 *mem_zero, const Word16 extl );
@@ -82,7 +79,7 @@ void Init_post_filter_fx(
*--------------------------------------------------------------------------*/
void nb_post_filt_fx(
const Word16 L_frame, /* i : frame length */
- PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */
+ PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */
Word16 *psf_lp_noise, /* i : Long term noise Q8 */
const Word16 tmp_noise, /* i : noise energy Q0 */
Word16 *Synth, /* i : 12k8 synthesis Qsyn */
@@ -257,22 +254,20 @@ static void Dec_postfilt_fx(
* Main routine to perform formant post filtering
*--------------------------------------------------------------------------*/
-#ifndef REMOVE_EVS_DUPLICATES
void formant_post_filt_fx(
- PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */
+ PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */
Word16 *synth_in, /* i : 12k8 synthesis */
- Word16 *Aq, /* i : LP filter coefficient Q12 */
+ Word16 *Aq, /* i : LP filter coefficient Q12 */
Word16 *synth_out, /* i/o: input signal */
- Word16 L_frame,
- Word32 lp_noise, /* (i) : background noise energy (15Q16) */
- Word32 brate, /* (i) : bit-rate */
- const Word16 off_flag /* i : off flag */
+ const Word16 L_frame, /* i : frame length */
+ const Word32 lp_noise, /* (i) : background noise energy (15Q16) */
+ const Word32 brate, /* (i) : bit-rate */
+ const Word16 off_flag /* i : off flag */
)
{
Word16 i_subfr;
Word16 *p_Aq;
- Word16 post_G1, post_G2; // Q15
-
+ Word16 post_G1, post_G2;
/*default parameter for noisy speech and high bit-rates*/
IF( EQ_16( L_frame, L_FRAME ) )
@@ -381,134 +376,13 @@ void formant_post_filt_fx(
Dec_formant_postfilt_fx( hPFstat, &synth_in[i_subfr], p_Aq, &synth_out[i_subfr], post_G1, post_G2 );
p_Aq += ( M + 1 );
}
-}
-#endif
-void formant_post_filt_ivas_fx(
- PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */
- Word16 *synth_in, /* i : 12k8 synthesis */
- Word16 *Aq, /* i : LP filter coefficient Q12 */
- Word16 *synth_out, /* i/o: input signal */
- Word16 L_frame,
- Word32 lp_noise, /* (i) : background noise energy (15Q16) */
- Word32 brate, /* (i) : bit-rate */
- const Word16 off_flag /* i : off flag */
-)
-{
- Word16 i_subfr;
- Word16 *p_Aq;
- Word16 post_G1, post_G2;
-
-
- /*default parameter for noisy speech and high bit-rates*/
- IF( EQ_16( L_frame, L_FRAME ) )
- {
- post_G2 = 22938 /*0.7f Q15*/;
- move16();
- IF( LT_32( lp_noise, LP_NOISE_THRESH ) )
- {
- /*Clean speech*/
- IF( LT_32( brate, ACELP_13k20 ) )
- {
- /*Low rates*/
-
- post_G1 = 26214 /*0.8f Q15*/;
- move16();
- }
- ELSE IF( LT_32( brate, ACELP_24k40 ) )
- {
- /*Low rates*/
-
- post_G1 = 24576 /*0.75f Q15*/;
- move16();
- }
- ELSE
- {
- post_G1 = 23593 /*0.72f Q15*/;
- move16();
- }
- }
- ELSE /*Noisy speech*/
- {
- post_G1 = 22938 /*0.7f Q15*/;
- move16();
- if ( LT_32( brate, ACELP_15k85 ) )
- {
- /*Low rates*/
- post_G1 = 24576 /*0.75f Q15*/;
- move16();
- }
- }
- }
- ELSE
- {
- post_G2 = 24904 /*0.76f Q15*/;
- move16();
- test();
- IF( GE_32( lp_noise, LP_NOISE_THRESH ) )
- {
- post_G1 = 24904 /*0.76f Q15*/;
- }
- ELSE IF( EQ_32( brate, ACELP_13k20 ) )
- {
- post_G1 = 26870 /*0.82f Q15*/;
- move16();
- }
- ELSE IF( EQ_32( brate, ACELP_16k40 ) )
- {
- post_G1 = 26214 /*0.80f Q15*/;
- move16();
- }
- ELSE IF( EQ_32( brate, ACELP_24k40 ) || EQ_32( brate, ACELP_32k ) )
- {
- post_G1 = 25559 /*0.78f Q15*/;
- move16();
- }
- ELSE
- {
- post_G1 = 24904 /*0.76f Q15*/;
- move16();
- }
- }
- /* Switch off post-filter */
- if ( off_flag != 0 )
- {
- post_G1 = post_G2;
- move16();
- }
-
- /* Reset post filter */
- IF( hPFstat->reset != 0 )
- {
- post_G1 = MAX16B;
- move16();
- post_G2 = MAX16B;
- move16();
- hPFstat->reset = 0;
- move16();
- Copy( &synth_in[L_frame - L_SYN_MEM], hPFstat->mem_pf_in, L_SYN_MEM );
- Copy( &synth_in[L_frame - L_SYN_MEM], hPFstat->mem_stp, L_SYN_MEM );
- hPFstat->gain_prec = 16384; // 1.Q14
- move16();
- Copy( synth_in, synth_out, L_frame );
-
- return;
- }
+ return;
+}
- /* input memory*/
- Copy( hPFstat->mem_pf_in, synth_in - L_SYN_MEM, L_SYN_MEM );
- Copy( &synth_in[L_frame - L_SYN_MEM], hPFstat->mem_pf_in, L_SYN_MEM );
- move16();
- p_Aq = Aq; // Q12
- FOR( i_subfr = 0; i_subfr < L_frame; i_subfr += L_SUBFR )
- {
- Dec_formant_postfilt_ivas_fx( hPFstat, &synth_in[i_subfr], p_Aq, &synth_out[i_subfr], post_G1, post_G2 );
- p_Aq += ( M + 1 );
- }
-}
/*----------------------------------------------------------------------------
- * Dec_formant_postfilt_fx
+ * Dec_formant_postfilt_fx()
*
* Post - adaptive postfilter main function
* Short term postfilter :
@@ -522,93 +396,14 @@ void formant_post_filt_ivas_fx(
* k1 = 1st parcor calculated on {hi}
* gamma3 = gamma3_minus if k1<0, gamma3_plus if k1>0
*----------------------------------------------------------------------------*/
-#ifndef REMOVE_EVS_DUPLICATES
-static void Dec_formant_postfilt_fx(
- PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */
- Word16 *signal_ptr, /* i : input signal (pointer to current subframe Q14*/
- Word16 *coeff, /* i : LPC coefficients for current subframe Q12 */
- Word16 *sig_out, /* o : postfiltered output */
- Word16 gamma1, /* i : short term postfilt. den. weighting factor Q15*/
- Word16 gamma2 /* i : short term postfilt. num. weighting factor Q15*/
-)
-{
- /* Local variables and arrays */
- Word16 apond1[M + 1]; /* s.t. denominator coeff. Q12*/
- Word16 apond2[LONG_H_ST]; // Q12
- Word16 res2[L_SUBFR]; // Q14
- Word16 resynth[L_SUBFR + 1]; // Qy
- Word16 parcor0; // Q15
- Word16 i, max;
- Word16 scale_down;
-
- /* Compute weighted LPC coefficients */
- weight_a_fx( coeff, apond1, gamma1, M );
- weight_a_fx( coeff, apond2, gamma2, M );
- set16_fx( &apond2[M + 1], 0, LONG_H_ST - ( M + 1 ) );
- max = abs_s( signal_ptr[0] ); // Q14
- FOR( i = 1; i < L_SUBFR; i++ )
- {
- max = s_max( max, abs_s( signal_ptr[i] ) );
- }
- scale_down = 0;
- move16();
- if ( GT_16( max, 16384 /*1.Q14*/ ) )
- {
- scale_down = 1;
- move16();
- }
-
- /* Compute A(gamma2) residual */
- IF( !scale_down )
- {
- Residu3_fx( apond2, signal_ptr, res2, L_SUBFR, 1 );
- }
- ELSE
- {
- Residu3_fx( apond2, signal_ptr, res2, L_SUBFR, 0 );
- Scale_sig( hPFstat->mem_stp, L_SYN_MEM, -1 );
- }
-
- /* Controls short term pst filter gain and compute parcor0 */
- calc_st_filt_local_fx( apond2, apond1, &parcor0, res2, hPFstat->mem_zero );
-
- /* 1/A(gamma1) filtering, mem_stp is updated */
- resynth[0] = *( hPFstat->mem_stp + sub( L_SYN_MEM, 1 ) );
- move16();
-
- E_UTIL_synthesis( 1, apond1, res2, &( resynth[1] ), L_SUBFR, hPFstat->mem_stp + L_SYN_MEM - M, 0, M );
-
- IF( !scale_down )
- {
- Copy( &( resynth[1] ) + L_SUBFR - L_SYN_MEM, hPFstat->mem_stp, L_SYN_MEM );
- }
- ELSE
- {
- Copy_Scale_sig( &( resynth[1] ) + L_SUBFR - L_SYN_MEM, hPFstat->mem_stp, L_SYN_MEM, 1 );
- }
-
- /* Tilt filtering */
- Filt_mu_fx( resynth, sig_out, parcor0, L_SUBFR );
- IF( scale_down )
- {
- Scale_sig( sig_out, L_SUBFR, 1 );
- }
-
- /* Gain control */
- scale_st_fx( signal_ptr, sig_out, &hPFstat->gain_prec, L_SUBFR );
-
-
- return;
-}
-#endif
-static void Dec_formant_postfilt_ivas_fx(
- PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */
- Word16 *signal_ptr, /* i : input signal (pointer to current subframe Q14*/
- Word16 *coeff, /* i : LPC coefficients for current subframe Q12 */
- Word16 *sig_out, /* o : postfiltered output */
- Word16 gamma1, /* i : short term postfilt. den. weighting factor Q15*/
- Word16 gamma2 /* i : short term postfilt. num. weighting factor Q15*/
+static void Dec_formant_postfilt_fx(
+ PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */
+ Word16 *signal_ptr, /* i : input signal (pointer to current subframe Q14*/
+ Word16 *coeff, /* i : LPC coefficients for current subframe Q12 */
+ Word16 *sig_out, /* o : postfiltered output */
+ Word16 gamma1, /* i : short term postfilt. den. weighting factor Q15*/
+ Word16 gamma2 /* i : short term postfilt. num. weighting factor Q15*/
)
{
/* Local variables and arrays */
diff --git a/lib_dec/dec_ppp_fx.c b/lib_dec/dec_ppp_fx.c
index 4849e147a04c9f10f351aa1c9ae5d89750637be4..4b3f4f554ec8100ae08fb5f6f7bac0383f398224 100644
--- a/lib_dec/dec_ppp_fx.c
+++ b/lib_dec/dec_ppp_fx.c
@@ -6,6 +6,7 @@
#include
#include "options.h" /* Compilation switches */
#include "prot_fx.h" /* Function prototypes */
+
/*===================================================================*/
/* FUNCTION : void decod_ppp_fx () */
/*-------------------------------------------------------------------*/
@@ -45,20 +46,20 @@
/*-------------------------------------------------------------------*/
/* CALLED FROM : RX */
/*===================================================================*/
+
ivas_error decod_ppp_fx(
- Decoder_State *st_fx, /* i/o: state structure */
- const Word16 Aq_fx[], /* i : 12k8 Lp coefficient */
- Word16 *pitch_buf_fx, /* i/o: fixed pitch values for each subframe */
- Word16 *exc_fx, /* i/o: current non-enhanced excitation */
- Word16 *exc2_fx, /* i/o: current enhanced excitation */
- Word16 bfi, /* i : bad frame indicator */
- Word16 *gain_buf,
+ Decoder_State *st_fx, /* i/o: state structure */
+ const Word16 Aq_fx[], /* i : 12k8 Lp coefficient */
+ Word16 *pitch_buf_fx, /* i/o: fixed pitch values for each subframe */
+ Word16 *exc_fx, /* i/o: current non-enhanced excitation */
+ Word16 *exc2_fx, /* i/o: current enhanced excitation */
+ Word16 bfi, /* i : bad frame indicator */
+ Word16 *gain_buf, /* o : Word16 pitch gain for each subframe Q14*/
Word16 *voice_factors, /* o : voicing factors */
Word16 *bwe_exc_fx /* o : excitation for SWB TBE */
)
{
Word16 k;
-
Word16 LPC_de_curr_fx[M + 1], p_Aq_curr_fx[M], p_Aq_old_fx[M + 1];
Word16 excQ_ppp_fx[L_FRAME], pitch_fx[NB_SUBFR], LPC_de_old_fx[M + 1];
ivas_error error;
diff --git a/lib_dec/dec_prm_fx.c b/lib_dec/dec_prm_fx.c
index 3d277807d2fed95764ba8e3c4992662fd26eac4b..16e588396b547fb2f56c6e88a6f44d616bbed3bc 100644
--- a/lib_dec/dec_prm_fx.c
+++ b/lib_dec/dec_prm_fx.c
@@ -1003,12 +1003,7 @@ void dec_prm_fx(
{
IF( st->lpcQuantization == 0 )
{
- decode_lpc_avq_fx( st, st->numlpc, param_lpc
-#ifdef IVAS_CODE_AVQ_LPC
- ,
- , ,
-#endif
- );
+ decode_lpc_avq_fx( st, st->numlpc, param_lpc );
move16();
}
ELSE IF( EQ_16( st->lpcQuantization, 1 ) )
diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c
index af80ee1f54e8672c19b05e6c29432d91639ccd3f..41c3f974094e9635d3776fc4f769b851a06102b4 100644
--- a/lib_dec/dec_tcx_fx.c
+++ b/lib_dec/dec_tcx_fx.c
@@ -893,9 +893,6 @@ void decoder_tcx_fx(
TonalMDCTConceal_InsertNoise( st->hTonalMDCTConc, x, &x_e, st->tonal_mdct_plc_active, &st->seed_tcx_plc,
noiseTiltFactor, f,
-#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
- concealment_noise,
-#endif
infoIGFStartLine );
}
}
@@ -2637,9 +2634,16 @@ void IMDCT_ivas_fx(
Word32 fac;
// fac = shl_sat( mult_r( extract_h( L_shr_sat( hTcxDec->conceal_eof_gain32, sub( 1, hTcxDec->conceal_eof_gain_e ) ) ), st->last_concealed_gain_syn_deemph ), 1 );
fac = Mpy_32_16_1( hTcxDec->conceal_eof_gain32, st->last_concealed_gain_syn_deemph ); // q = 31 - hTcxDec->conceal_eof_gain_e - last_concealed_gain_syn_deemph_e
+#ifdef OPT_SBA_DEC_V2_BE
+ Word16 eff_e = add( hTcxDec->conceal_eof_gain_e, st->last_concealed_gain_syn_deemph_e );
+#endif /* OPT_SBA_DEC_V2_BE */
FOR( Word16 ind = 0; ind < overlap; ind++ )
{
+#ifdef OPT_SBA_DEC_V2_BE
+ old_syn_overl_fx[ind] = extract_h( L_shl_sat( Mpy_32_16_1( fac, old_syn_overl_fx[ind] ), eff_e ) ); // Q(-2)
+#else /* OPT_SBA_DEC_V2_BE */
old_syn_overl_fx[ind] = extract_h( L_shl_sat( Mpy_32_16_1( fac, old_syn_overl_fx[ind] ), add( hTcxDec->conceal_eof_gain_e, st->last_concealed_gain_syn_deemph_e ) ) ); // Q(-2)
+#endif /* OPT_SBA_DEC_V2_BE */
move16();
}
}
@@ -2882,7 +2886,7 @@ void IMDCT_ivas_fx(
{
Word16 q_old_out = q_win;
move16();
- edct_fx( x_fx, xn_buf_fx_32 + add( shr( overlap, 1 ), nz ), L_frame, &q_xn_buf_fx_32 );
+ edct_ivas_fx( x_fx, xn_buf_fx_32 + add( shr( overlap, 1 ), nz ), L_frame, &q_xn_buf_fx_32 );
Word16 res_m, res_e;
res_e = 0;
move16();
@@ -4716,9 +4720,16 @@ void decoder_tcx_noiseshaping_igf_fx(
{
/* If the exponent on the spec side (i>L_frame) is lesser, then shift all the values in the
spec side by the difference to make both sides have the same exponent. */
+#ifdef OPT_SBA_DEC_V2_BE
+ Word16 diff_e = sub( frame_side_x_e, spec_side_x_e );
+#endif /* OPT_SBA_DEC_V2_BE */
FOR( i = L_frame; i < L_spec; i++ )
{
+#ifdef OPT_SBA_DEC_V2_BE
+ x_fx[i] = L_shr( x_fx[i], diff_e );
+#else /* OPT_SBA_DEC_V2_BE */
x_fx[i] = L_shr( x_fx[i], sub( frame_side_x_e, spec_side_x_e ) );
+#endif /* OPT_SBA_DEC_V2_BE */
move32();
}
}
@@ -4726,9 +4737,16 @@ void decoder_tcx_noiseshaping_igf_fx(
{
/* If the exponent on the spec side (i>L_frame) is greater, then shift all the values in the
frame side (iQ_exc, T0, T0_frac, st_fx->coder_type, st_fx->core_brate,
- st_fx->element_mode, st_fx->idchan, st_fx->hBWE_TD != NULL, st_fx->tdm_LRTD_flag );
-#else
- prep_tbe_exc_fx( L_frame_fx, i_subfr, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx,
+ prep_tbe_exc_fx( L_frame_fx, L_SUBFR, i_subfr, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx,
&voice_factors_fx[tmp_idx_2], bwe_exc_fx, gain_preQ_fx, code_preQ_fx,
- st_fx->Q_exc, T0, T0_frac, st_fx->coder_type, st_fx->core_brate );
-#endif
+ st_fx->Q_exc, T0, T0_frac, st_fx->coder_type, st_fx->core_brate,
+ st_fx->element_mode, st_fx->idchan, st_fx->hBWE_TD != NULL, st_fx->tdm_LRTD_flag );
/*----------------------------------------------------------------*
* Excitation enhancements (update of total excitation signal)
diff --git a/lib_dec/dec_uv_fx.c b/lib_dec/dec_uv_fx.c
index fcc2600a3eefe302fc6cfb62c79dc5ca481d75eb..f1ba21979228b1e0634efef8bf139c511869fc4f 100644
--- a/lib_dec/dec_uv_fx.c
+++ b/lib_dec/dec_uv_fx.c
@@ -25,96 +25,7 @@ static void gain_dec_gacelp_uv_fx(
* Decode unvoiced (UC) frames
*-------------------------------------------------------------------*/
-#ifndef REMOVE_EVS_DUPLICATES
void decod_unvoiced_fx(
- Decoder_State *st_fx, /* i/o: decoder static memory */
- const Word16 *Aq_fx, /* Q12 i : LP filter coefficient */
- const Word16 coder_type, /* Q0 i : coding type */
- Word16 *tmp_noise_fx, /* Q0 o : long term temporary noise energy */
- Word16 *pitch_buf_fx, /* Q6 o : floating pitch values for each subframe*/
- Word16 *voice_factors_fx, /* Q15 o : voicing factors */
- Word16 *exc_fx, /* Q_X o : adapt. excitation exc */
- Word16 *exc2_fx, /* Q_X o : adapt. excitation/total exc */
- Word16 *bwe_exc_fx, /* Q_X i/o: excitation for SWB TBE */
- Word16 *gain_buf )
-{
- Word16 gain_pit_fx; /* Quantized pitch gain */
- Word32 gain_code_fx; /* Quantized algebraic codeebook gain */
- Word16 gain_inov_fx; /* inovation gain */
- Word32 norm_gain_code_fx; /* normalized algebraic codeebook gain */
- Word16 voice_fac_fx; /* Voicing factor */
- Word16 code_fx[L_SUBFR]; /* algebraic codevector */
- Word16 i_subfr_fx;
- const Word16 *p_Aq_fx;
- Word16 *pt_pitch_fx;
-
- gain_pit_fx = 0;
- move16();
-
- test();
- IF( EQ_16( st_fx->last_ppp_mode_dec, 1 ) || EQ_16( st_fx->last_nelp_mode_dec, 1 ) )
- {
- /* SC_VBR - reset the decoder, to avoid memory not updated issue for this unrealistic case */
- CNG_reset_dec_fx( st_fx, pitch_buf_fx, voice_factors_fx );
- }
-
- p_Aq_fx = Aq_fx;
- move16(); /*Q12*/ /* pointer to interpolated LPC parameters */
- pt_pitch_fx = pitch_buf_fx;
- move16(); /* pointer to the pitch buffer */
-
- FOR( i_subfr_fx = 0; i_subfr_fx < L_FRAME; i_subfr_fx += L_SUBFR )
- {
- /*----------------------------------------------------------------*
- * Unvoiced subframe processing
- *----------------------------------------------------------------*/
-
- gaus_dec_fx( st_fx, i_subfr_fx, code_fx, &norm_gain_code_fx, &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, &gain_inov_fx, &st_fx->tilt_code_fx,
- &voice_fac_fx, &gain_pit_fx, pt_pitch_fx, exc_fx, &gain_code_fx, exc2_fx, bwe_exc_fx, &( st_fx->Q_exc ), st_fx->Q_subfr );
-
- *tmp_noise_fx = extract_h( norm_gain_code_fx ); /*Q16*/
- move16();
-
- /*----------------------------------------------------------------*
- * Excitation enhancements (update of total excitation signal)
- *----------------------------------------------------------------*/
-
- enhancer_fx( st_fx->core_brate, 0, coder_type, i_subfr_fx, L_FRAME, voice_fac_fx, st_fx->stab_fac_fx,
- norm_gain_code_fx, gain_inov_fx, &st_fx->gc_threshold_fx, code_fx, exc2_fx, gain_pit_fx, &( st_fx->dm_fx ), st_fx->Q_exc );
-
- Word16 tmp_idx = 0;
- move16();
- IF( i_subfr_fx != 0 )
- {
- tmp_idx = idiv1616( i_subfr_fx, L_SUBFR );
- }
- voice_factors_fx[tmp_idx] = 0;
- move16();
-
- interp_code_5over2_fx( &exc_fx[i_subfr_fx], &bwe_exc_fx[( ( i_subfr_fx * 2 * HIBND_ACB_L_FAC ) >> 1 )], L_SUBFR );
-
- p_Aq_fx += ( M + 1 );
- pt_pitch_fx++;
- st_fx->tilt_code_dec_fx[tmp_idx] = st_fx->tilt_code_fx;
- move16();
- }
-
- /* SC-VBR */
- st_fx->prev_gain_pit_dec_fx = gain_pit_fx;
- move16();
-
- set16_fx( gain_buf, 0, NB_SUBFR );
-
- return;
-}
-
-/*-------------------------------------------------------------------*
- * decod_unvoiced()
- *
- * Decode unvoiced (UC) frames
- *-------------------------------------------------------------------*/
-#endif
-void decod_unvoiced_ivas_fx(
Decoder_State *st_fx, /* i/o: decoder static memory */
const Word16 *Aq_fx, /* Q12 i : LP filter coefficient */
const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */
@@ -208,13 +119,11 @@ void decod_unvoiced_ivas_fx(
move16();
/* update LP filtered gains for the case of frame erasures */
-#ifdef REMOVE_EVS_DUPLICATES
IF( EQ_16( st_fx->element_mode, EVS_MONO ) )
{
lp_gain_updt_fx( i_subfr_fx, gain_pit_fx, norm_gain_code_fx, &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_FRAME );
}
ELSE
-#endif
{
lp_gain_updt_ivas_fx( i_subfr_fx, gain_pit_fx, norm_gain_code_fx, &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_FRAME );
}
@@ -250,6 +159,7 @@ void decod_unvoiced_ivas_fx(
}
// Scale_sig(code_fx, L_SUBFR, 3); //Q12
}
+
*tmp_noise_fx = extract_h( norm_gain_code_fx ); /*Q16*/
move16();
@@ -257,14 +167,12 @@ void decod_unvoiced_ivas_fx(
* Excitation enhancements (update of total excitation signal)
*----------------------------------------------------------------*/
-#ifdef REMOVE_EVS_DUPLICATES
IF( EQ_16( st_fx->element_mode, EVS_MONO ) )
{
enhancer_fx( st_fx->core_brate, 0, coder_type, i_subfr_fx, L_FRAME, voice_fac_fx, st_fx->stab_fac_fx,
norm_gain_code_fx, gain_inov_fx, &st_fx->gc_threshold_fx, code_fx, exc2_fx, gain_pit_fx, &( st_fx->dm_fx ), st_fx->Q_exc );
}
ELSE
-#endif
{
enhancer_ivas_fx( MODE1, st_fx->core_brate, uc_two_stage_flag, 0, coder_type, i_subfr_fx, L_FRAME, voice_fac_fx, st_fx->stab_fac_fx,
norm_gain_code_fx, gain_inov_fx, &st_fx->gc_threshold_fx, code_fx /*Q9/Q12?*/, exc2_fx, gain_pit_fx, &( st_fx->dm_fx ), st_fx->Q_exc );
@@ -276,12 +184,6 @@ void decod_unvoiced_ivas_fx(
IF( i_subfr_fx != 0 )
{
tmp_idx = idiv1616( i_subfr_fx, L_SUBFR );
-#ifdef REMOVE_EVS_DUPLICATES
- IF( EQ_16( st_fx->element_mode, EVS_MONO ) )
- {
- tmp_idx = idiv1616( i_subfr_fx, L_SUBFR );
- }
-#endif
}
voice_factors_fx[tmp_idx] = 0;
move16();
diff --git a/lib_dec/dlpc_avq_fx.c b/lib_dec/dlpc_avq_fx.c
index 3d9a00b7f1bbbb7be3c76f639125fe0913d033f3..07f1ea6f21206fa6b7d77d2886afc525462e6f85 100644
--- a/lib_dec/dlpc_avq_fx.c
+++ b/lib_dec/dlpc_avq_fx.c
@@ -149,20 +149,11 @@ Word16 decode_lpc_avq_fx(
Decoder_State *st, /* i/o: decoder state structure */
const Word16 numlpc, /* i : Number of sets of lpc */
Word16 *param_lpc /* o : lpc parameters */
-#ifdef IVAS_CODE_AVQ_LPC
- ,
- const Word16 ch, /* i : channel */
- const Word16 element_mode, /* i : element mode */
- const Word16 sns_low_br_mode /* i : SNS low-bitrate mode */
-#endif
)
{
Word16 k, j;
Word16 nb, qn1, qn2, avqBits, q_type;
Word16 start_bit_pos;
-#ifdef IVAS_CODE_AVQ_LPC
- Word16 stereo_mode = 0;
-#endif
move16();
move16();
move16();
@@ -189,41 +180,11 @@ Word16 decode_lpc_avq_fx(
param_lpc[j] = q_type;
j = add( j, 1 );
}
-#ifdef IVAS_CODE_AVQ_LPC
- test();
- IF( EQ_16( element_mode, IVAS_CPE_MDCT ) && k == 0 )
- {
- stereo_mode = ch;
- move16();
- if ( ch == 0 )
- {
- stereo_mode = param_lpc[j];
- move16();
- }
- param_lpc[j++] = stereo_mode;
- move16();
- }
-#endif
/* Decode quantization indices */
IF( q_type == 0 )
{
/* Absolute quantizer with 1st stage stochastic codebook */
-#ifdef IVAS_CODE_AVQ_LPC
- IF( EQ_16( element_mode, IVAS_CPE_MDCT ) )
- {
- IF( NE_16( stereo_mode, 3 ) )
- {
- param_lpc[j] = get_next_indice_fx( st, SNS_ABS_QUANT_BITS );
- }
- ELSE
- {
- param_lpc[j] = sub( get_next_indice_fx( st, 1 ), 2 );
- }
- move16();
- }
- ELSE
-#endif
{
move16();
param_lpc[j] = get_next_indice_fx( st, 8 );
@@ -235,9 +196,6 @@ Word16 decode_lpc_avq_fx(
* - we are in low bitrate mode and no joint SNS coding is used
* - OR the side-SNS-is-zero flag is set for joint SNS
*/
-#ifdef IVAS_CODE_AVQ_LPC
- IF( NE_16( element_mode, IVAS_CPE_MDCT ) || ( !( sns_low_br_mode && ( EQ_16( stereo_mode, 0 ) || EQ_16( stereo_mode, 1 ) ) && !( EQ_16( q_type, 0 ) && EQ_16( param_lpc[j - 1], -2 ) ) ) ) )
-#endif
{
/* 2 bits to specify Q2,Q3,Q4,ext */
qn1 = add( 2, get_next_indice_fx( st, 2 ) );
@@ -321,21 +279,11 @@ Word16 decode_lpc_avq_fx(
pack4bits_fx( avqBits, st, ¶m_lpc[j] );
j = add( j, qn2 );
}
-#ifdef IVAS_CODE_AVQ_LPC
- ELSE
- {
- param_lpc[j] = 0;
- j = add( j, 1 );
- param_lpc[j] = 0;
- j = add( j, 1 );
- move16();
- move16();
- }
-#endif
}
return sub( st->next_bit_pos, start_bit_pos );
}
+
Word16 decode_lpc_avq_ivas_fx(
Decoder_State *st, /* i/o: decoder state structure */
const Word16 numlpc, /* i : Number of sets of lpc */
diff --git a/lib_dec/er_dec_acelp_fx.c b/lib_dec/er_dec_acelp_fx.c
index e30553d388e32c0a53b2b903aa763b120af22ab0..b6e5f31711327a47d27ed1fcb85c40249c4addf1 100644
--- a/lib_dec/er_dec_acelp_fx.c
+++ b/lib_dec/er_dec_acelp_fx.c
@@ -557,7 +557,7 @@ void con_acelp_fx(
tmp_32 = Mpy_32_16_1( st->Mode2_lp_gainc /*Q16*/, alpha /*Q14*/ ); /*Q31-16 = Q15*/
s_32 = norm_l( tmp_32 );
tmp_32 = L_shl( tmp_32, s_32 );
- tmp_16 = round_fx( tmp_32 );
+ tmp_16 = round_fx_sat( tmp_32 );
s_16 = negate( s_32 );
s_16 = sub( s_16, -1 - 15 ); /*->Q15*/
diff --git a/lib_dec/er_dec_tcx_fx.c b/lib_dec/er_dec_tcx_fx.c
index e804d200927334135725f05bc7294f3e4da06dce..3d0eab8153845c06cda2e6562038b4da91a1b2c2 100644
--- a/lib_dec/er_dec_tcx_fx.c
+++ b/lib_dec/er_dec_tcx_fx.c
@@ -121,17 +121,6 @@ con_tcx
void con_tcx_fx(
Decoder_State *st, /* i/o: coder memory state */
Word16 synth[] /* i/o: synth[] Q0*/
-#ifdef IVAS_CODE_CON_TCX
- ,
- const Word16 coh, /* i : coherence of stereo signal Q14*/
- Word16 *noise_seed, /* i/o: noise seed for stereo Q0*/
- const Word16 only_left /* i : TD-PLC only in left channel Q0*/
-#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
- ,
- const float *A_cng /* i : CNG LP filter coefficients Q14*/
-#endif
-#endif
-
)
{
Word16 i, s, c, L_frame, L_subfr, fLowPassFilter, T0;
@@ -489,19 +478,7 @@ void con_tcx_fx(
move16();
/* PLC: calculate damping factor */
-#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
- alpha = 1.0f;
- if ( st->element_mode == IVAS_CPE_MDCT && st->nbLostCmpt >= MDCT_ST_PLC_FADEOUT_START_FRAME )
- {
- alpha = Damping_fact_fx( st->core_ext_mode, st->nbLostCmpt - MDCT_ST_PLC_FADEOUT_START_FRAME, st->last_good, st->stab_fac, &( st->lp_gainp ), 0 );
- }
- else if ( st->element_mode != IVAS_CPE_MDCT )
- {
- alpha = Damping_fact_fx( st->core_ext_mode, st->nbLostCmpt, st->last_good, st->stab_fac, &( st->lp_gainp ), 0 );
- }
-#else
alpha = Damping_fact_fx( st->core_ext_mode, st->nbLostCmpt, st->last_good, st->stab_fac_fx, &( st->Mode2_lp_gainp ), 0 ); /*Q14*/
-#endif
IF( EQ_16( st->nbLostCmpt, 1 ) )
{
st->cummulative_damping = 32767 /*1.f Q15*/;
@@ -566,63 +543,15 @@ void con_tcx_fx(
{
calcGainc2_fx( &exc[0], Q_exc, L_subfr, &( st->Mode2_lp_gainc ) );
}
- set32_fx( pitch_buf, L_deposit_h( L_SUBFR ), st->nb_subfr ); /*Q16*/
- /* PLC: calculate damping factor */
-#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
- alpha = 1.0f;
- if ( st->element_mode == IVAS_CPE_MDCT && st->nbLostCmpt >= MDCT_ST_PLC_FADEOUT_START_FRAME )
- {
- alpha = Damping_fact_fx( st->core_ext_mode, st->nbLostCmpt - MDCT_ST_PLC_FADEOUT_START_FRAME, st->last_good, st->stab_fac, &( st->lp_gainp ), 0 );
- }
- else if ( st->element_mode != IVAS_CPE_MDCT )
- {
- alpha = Damping_fact_fx( st->core_ext_mode, st->nbLostCmpt, st->last_good, st->stab_fac, &( st->lp_gainp ), 0 );
- }
-#else
+ set32_fx( pitch_buf, L_deposit_h( L_SUBFR ), st->nb_subfr ); /*Q16*/
+ /* PLC: calculate damping factor */
alpha = Damping_fact_fx( st->core_ext_mode, st->nbLostCmpt, st->last_good, st->stab_fac_fx, &( st->Mode2_lp_gainp ), 0 ); /*Q14*/
-#endif
}
/*-----------------------------------------------------------------*
* Construct the random part of excitation
*-----------------------------------------------------------------*/
-#ifdef IVAS_CODE_CON_TCX
- if ( coh != -1.f )
- {
- int16_t tmpSeed1;
- float alpha_coh;
- float random1, random2;
- tmpSeed1 = *noise_seed;
- noise = buf;
-
- alpha_coh = sqrtf( ( 1 - coh ) / ( 1 + coh ) );
- if ( st->idchan == 1 )
- {
- alpha_coh = -alpha_coh;
- }
-
- for ( i = 0; i < L_frame + L_FIR_FER2 - 1; i++ )
- {
- random1 = (float) own_random( &tmpSeed1 );
- random2 = (float) own_random( &tmpSeed1 );
- noise[i] = random1 + alpha_coh * random2;
- }
-
- if ( st->idchan == 1 || only_left )
- {
- *noise_seed = tmpSeed1;
- }
-
- for ( ; i < L_frame + ( L_frame / 2 ) + 2 * L_FIR_FER2; i++ )
- {
- random1 = (float) own_random( &tmpSeed1 );
- random2 = (float) own_random( &tmpSeed1 );
- noise[i] = random1 + alpha_coh * random2;
- }
- }
- else
-#endif /*IVAS_CODE_CON_TCX*/
{
tmpSeed = st->seed_acelp;
move16();
@@ -707,20 +636,9 @@ void con_tcx_fx(
}
/* PLC: [TCX: Fade-out] retrieve background level */
-#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
- if ( A_cng != NULL )
- {
- gainSynthDeemph = getLevelSynDeemph_fx( &( tmp ), A_cng, L_frame / 4, st->preemph_fac, 1 ) / 4.f;
- }
- else
- {
- gainSynthDeemph = getLevelSynDeemph_fx( &( tmp ), A_local, L_frame / 4, st->preemph_fac, 1 );
- }
-#else
tmp16 = 32767;
move16();
- gainSynthDeemph = getLevelSynDeemph_fx( &( tmp16 ), A_local, M, shr( L_frame, 2 ), st->preemph_fac, 1, &gainSynthDeemph_e ); /*Q5*/
-#endif
+ gainSynthDeemph = getLevelSynDeemph_fx( &( tmp16 ), A_local, M, shr( L_frame, 2 ), st->preemph_fac, 1, &gainSynthDeemph_e ); /*Q5*/
IF( st->tcxonly != 0 )
{
/* gainCNG = st->conCngLevelBackgroundTrace/gainSynthDeemph; */
@@ -728,19 +646,6 @@ void con_tcx_fx(
hTcxDec->conCngLevelBackgroundTrace_e,
gainSynthDeemph, gainSynthDeemph_e,
&gainCNG, &gainCNG_e );
-#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
- if ( st->element_mode == IVAS_CPE_MDCT && A_cng != NULL )
- {
- if ( st->nbLostCmpt > MDCT_ST_PLC_FADEOUT_MAX_CONC_FRAME + MDCT_ST_PLC_FADEOUT_TO_ZERO_LEN )
- {
- gainCNG = 0.f;
- }
- else if ( st->nbLostCmpt > MDCT_ST_PLC_FADEOUT_MAX_CONC_FRAME )
- {
- gainCNG *= 1.f - (float) ( st->nbLostCmpt - MDCT_ST_PLC_FADEOUT_MAX_CONC_FRAME ) / MDCT_ST_PLC_FADEOUT_TO_ZERO_LEN;
- }
- }
-#endif
}
ELSE
{
@@ -907,34 +812,6 @@ void con_tcx_fx(
/*buf[OLD_EXC_SIZE_DEC;3/2 L_frame] Q1: exc*/
/*buf[0;M] Q0: mem_syn*/
-#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
- if ( A_cng != NULL )
- {
- float alpha_delayed;
-
- alpha_delayed = 1.0f;
- if ( st->nbLostCmpt > MDCT_ST_PLC_FADEOUT_DELAY_4_LSP_FADE )
- {
- alpha_delayed = Damping_fact_fx( st->core_ext_mode, st->nbLostCmpt - MDCT_ST_PLC_FADEOUT_DELAY_4_LSP_FADE, st->last_good, st->stab_fac, &( st->lp_gainp ), ACELP_CORE );
- }
-
- if ( st->plcBackgroundNoiseUpdated && alpha_delayed != 1.0f )
- {
- float lsp_local[M], lsp_fade[M], alpha_inv;
-
- alpha_inv = 1.0f - alpha_delayed;
-
- a2lsp_stab( A_local, lsp_local, lsp_local );
-
- for ( i = 0; i < M; i++ )
- {
- lsp_fade[i] = alpha_delayed * lsp_local[i] + alpha_inv * st->lspold_cng[i];
- }
-
- lsp2a_stab( lsp_fade, A_local, M );
- }
- }
-#endif
E_UTIL_synthesis(
sub( Q_exc, Q_syn ),
A_local,
@@ -1434,19 +1311,7 @@ void con_tcx_ivas_fx(
move16();
/* PLC: calculate damping factor */
-#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
- alpha = 1.0f;
- if ( st->element_mode == IVAS_CPE_MDCT && st->nbLostCmpt >= MDCT_ST_PLC_FADEOUT_START_FRAME )
- {
- alpha = Damping_fact_fx( st->core_ext_mode, st->nbLostCmpt - MDCT_ST_PLC_FADEOUT_START_FRAME, st->last_good, st->stab_fac, &( st->lp_gainp ), 0 );
- }
- else if ( st->element_mode != IVAS_CPE_MDCT )
- {
- alpha = Damping_fact_fx( st->core_ext_mode, st->nbLostCmpt, st->last_good, st->stab_fac, &( st->lp_gainp ), 0 );
- }
-#else
alpha = Damping_fact_fx( st->core_ext_mode, st->nbLostCmpt, st->last_good, st->stab_fac_fx, &( st->Mode2_lp_gainp ), 0 ); /*Q14*/
-#endif
IF( EQ_16( st->nbLostCmpt, 1 ) )
{
st->cummulative_damping = 32767 /*1.f Q15*/;
@@ -1511,27 +1376,15 @@ void con_tcx_ivas_fx(
{
calcGainc2_fx( &exc[0], Q_exc, L_subfr, &( st->Mode2_lp_gainc ) );
}
- set32_fx( pitch_buf, L_deposit_h( L_SUBFR ), st->nb_subfr ); /*Q16*/
- /* PLC: calculate damping factor */
-#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
- alpha = 1.0f;
- if ( st->element_mode == IVAS_CPE_MDCT && st->nbLostCmpt >= MDCT_ST_PLC_FADEOUT_START_FRAME )
- {
- alpha = Damping_fact_fx( st->core_ext_mode, st->nbLostCmpt - MDCT_ST_PLC_FADEOUT_START_FRAME, st->last_good, st->stab_fac, &( st->lp_gainp ), 0 );
- }
- else if ( st->element_mode != IVAS_CPE_MDCT )
- {
- alpha = Damping_fact_fx( st->core_ext_mode, st->nbLostCmpt, st->last_good, st->stab_fac, &( st->lp_gainp ), 0 );
- }
-#else
+ set32_fx( pitch_buf, L_deposit_h( L_SUBFR ), st->nb_subfr ); /*Q16*/
+ /* PLC: calculate damping factor */
alpha = Damping_fact_fx( st->core_ext_mode, st->nbLostCmpt, st->last_good, st->stab_fac_fx, &( st->Mode2_lp_gainp ), 0 ); /*Q14*/
-#endif
}
/*-----------------------------------------------------------------*
* Construct the random part of excitation
*-----------------------------------------------------------------*/
-#ifndef IVAS_CODE_CON_TCX
+
IF( NE_16( coh, -16384 ) )
{
Word16 tmpSeed1;
@@ -1581,7 +1434,6 @@ void con_tcx_ivas_fx(
}
}
ELSE
-#endif /*IVAS_CODE_CON_TCX*/
{
tmpSeed = st->seed_acelp; /*Q0*/
move16();
@@ -1666,7 +1518,6 @@ void con_tcx_ivas_fx(
}
/* PLC: [TCX: Fade-out] retrieve background level */
-#ifndef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
tmp16 = 32767;
move16();
IF( A_cng != NULL )
@@ -1677,11 +1528,6 @@ void con_tcx_ivas_fx(
{
gainSynthDeemph = getLevelSynDeemph_fx( &( tmp16 ), A_local, M, shr( L_frame, 2 ), st->preemph_fac, 1, &gainSynthDeemph_e ); /*Q13*/
}
-#else
- tmp16 = 32767;
- move16();
- gainSynthDeemph = getLevelSynDeemph_fx( &( tmp16 ), A_local, M, shr( L_frame, 2 ), st->preemph_fac, 1, &gainSynthDeemph_e );
-#endif
IF( st->tcxonly != 0 )
{
/* gainCNG = st->conCngLevelBackgroundTrace/gainSynthDeemph; */
@@ -1689,7 +1535,6 @@ void con_tcx_ivas_fx(
hTcxDec->conCngLevelBackgroundTrace_e,
gainSynthDeemph, gainSynthDeemph_e,
&gainCNG, &gainCNG_e );
-#ifndef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
test();
IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && A_cng != NULL )
{
@@ -1705,7 +1550,6 @@ void con_tcx_ivas_fx(
gainCNG = extract_l( Mpy_32_32( gainCNG, L_tmp ) ); /*Q15-gainCNG_e*/
}
}
-#endif
}
ELSE
{
@@ -1882,7 +1726,6 @@ void con_tcx_ivas_fx(
/*buf[OLD_EXC_SIZE_DEC;3/2 L_frame] Q1: exc*/
/*buf[0;M] Q0: mem_syn*/
-#ifndef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
IF( A_cng != NULL )
{
Word16 alpha_delayed;
@@ -1914,7 +1757,6 @@ void con_tcx_ivas_fx(
E_LPC_f_lsp_a_conversion( lsp_fade, A_local, M );
}
}
-#endif
E_UTIL_synthesis(
sub( Q_exc, Q_syn ),
diff --git a/lib_dec/er_util_fx.c b/lib_dec/er_util_fx.c
index 9735129ec14bc56a1aed50c894ac3cf27a087b6a..cecbad2943bb83dc1528388e365cec92fa40c75e 100644
--- a/lib_dec/er_util_fx.c
+++ b/lib_dec/er_util_fx.c
@@ -579,12 +579,7 @@ Word16 GetPLCModeDecision_fx(
pitch = L_add( st->old_fpitch, 0 ); /*Q16*/
}
- TonalMDCTConceal_Detect( st->hTonalMDCTConc, pitch, &numIndices, st->element_mode
-#ifdef IVAS_CODE_MDCT_GSHAPE
- ,
- ( st->element_mode == IVAS_CPE_MDCT ? &( st->hTcxCfg->psychParamsTCX20 ) : st->hTcxCfg->psychParamsCurrent )
-#endif
- );
+ TonalMDCTConceal_Detect( st->hTonalMDCTConc, pitch, &numIndices, st->element_mode );
test();
test();
diff --git a/lib_dec/evs_dec_fx.c b/lib_dec/evs_dec_fx.c
index 090409b4ce1d02f39a17eeeb03adf95d331b96c8..9c81fddf347529f42c78a49bbaae321ffc589306 100644
--- a/lib_dec/evs_dec_fx.c
+++ b/lib_dec/evs_dec_fx.c
@@ -332,11 +332,7 @@ ivas_error evs_dec_fx(
IF( EQ_16( st_fx->core, ACELP_CORE ) )
{
/* ACELP core decoder */
-#ifdef REMOVE_EVS_DUPLICATES
- IF( ( error = acelp_core_dec_ivas_fx( st_fx, NULL, synth_fx, NULL, bwe_exc_extended_fx, voice_factors_fx, old_syn_12k8_16k_fx, sharpFlag, pitch_buf_fx, &unbits, &sid_bw, NULL, NULL, NULL, 0, EVS_MONO, 0, 0, 1, NULL, 1 ) ) != IVAS_ERR_OK )
-#else
IF( ( error = acelp_core_dec_fx( st_fx, NULL, synth_fx, NULL, bwe_exc_extended_fx, voice_factors_fx, old_syn_12k8_16k_fx, sharpFlag, pitch_buf_fx, &unbits, &sid_bw, NULL, NULL, NULL, 0, EVS_MONO, 0, 0, 1, NULL, 1 ) ) != IVAS_ERR_OK )
-#endif
{
return error;
}
@@ -957,15 +953,9 @@ ivas_error evs_dec_fx(
}
st_fx->lp_noise = hFdCngDec->lp_noise; /*Q9.23*/
move32();
-#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
- ApplyFdCng_fx( output, NULL, realBuffer, imagBuffer, st, concealWholeFrame, 0 );
-#else
-#ifdef REMOVE_EVS_DUPLICATES
- ApplyFdCng_ivas_fx( output_sp, 0, NULL, 0, realBuffer, imagBuffer, &st_fx->scaleFactor.hb_scale, st_fx, concealWholeFrame, 0 );
-#else
- ApplyFdCng_fx( output_sp, 0, realBuffer, imagBuffer, &st_fx->scaleFactor.hb_scale, st_fx, concealWholeFrame, 0 );
-#endif
-#endif
+
+ ApplyFdCng_fx( output_sp, 0, NULL, 0, realBuffer, imagBuffer, &st_fx->scaleFactor.hb_scale, st_fx, concealWholeFrame, 0 );
+
/* Generate additional comfort noise to mask potential coding artefacts */
test();
IF( EQ_16( st_fx->m_frame_type, ACTIVE_FRAME ) && st_fx->flag_cna )
@@ -1155,7 +1145,7 @@ ivas_error evs_dec_fx(
FOR( i = 0; i < tmps; i++ )
{
- 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*/
+ output_sp[i + delay_comp] = msu_r_sat( L_mult_sat( output_sp[i + delay_comp], alpha ), shr_sat( hHQ_core->old_out_fx[i + nz], timeIn_e ), add( alpha, -32768 ) ); /*timeIn_e*/
move16();
alpha = add( alpha, step );
}
diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c
index 47a61a26e8097e5bdd543ea676b16fad7e87ee7a..adf838f42066905f3d6054ba5f55b036807a91c9 100644
--- a/lib_dec/fd_cng_dec_fx.c
+++ b/lib_dec/fd_cng_dec_fx.c
@@ -117,7 +117,7 @@ void initFdCngDec_ivas_fx(
set16_fx( hFdCngDec->msPsd, 0, NPART_SHAPING );
set32_fx( hFdCngDec->msPsd_fx, 0, NPART_SHAPING );
- set16_fx( hFdCngDec->msNoiseFloor, 0, NPART_SHAPING );
+ set32_fx( hFdCngDec->msNoiseFloor_32fx, 0, NPART_SHAPING );
set32_fx( hFdCngDec->msNoiseEst, 0, NPART_SHAPING );
set16_fx( &hFdCngDec->msNoiseEst_exp, 0, 1 );
@@ -142,7 +142,7 @@ void initFdCngDec_ivas_fx(
move16();
set16_fx( hFdCngDec->msLogPeriodog, 0, NPART_SHAPING );
- set16_fx( hFdCngDec->msLogNoiseEst, 0, NPART_SHAPING );
+ set32_fx( hFdCngDec->msLogNoiseEst_32fx, 0, NPART_SHAPING );
set16_fx( hFdCngDec->psize_shaping, 0, NPART_SHAPING );
hFdCngDec->nFFTpart_shaping = 0;
@@ -465,661 +465,97 @@ void configureFdCngDec_fx(
move16();
hsCom->CLDFBpsize_inv[j] = hsCom->psize_inv[( j + hsCom->nFFTpart )]; /*Q15*/
move16();
- }
-
- stopBandFR = 1000 / 25;
- move16();
- if ( GT_16( stopBandFR, hsCom->stopFFTbin ) )
- {
- stopBandFR = hsCom->stopFFTbin; /*Q0*/
- move16();
- }
- initPartitions( hsCom->FdCngSetup.shapingPartitions, hsCom->FdCngSetup.numShapingPartitions,
- hsCom->startBand, hsCom->stopFFTbin, hFdCngDec->part_shaping, &hFdCngDec->npart_shaping, hFdCngDec->midband_shaping,
- hFdCngDec->psize_shaping, hFdCngDec->psize_shaping_norm, &hFdCngDec->psize_shaping_norm_exp, hFdCngDec->psize_inv_shaping,
- stopBandFR );
- hFdCngDec->nFFTpart_shaping = hFdCngDec->npart_shaping; /*Q0*/
- move16();
-
- SWITCH( hsCom->fftlen )
- {
- case 512:
- hsCom->fftlenShift = 8;
- move16();
- hsCom->fftlenFac = 32767 /*1.0 Q15*/;
- move16();
- BREAK;
- case 640:
- hsCom->fftlenShift = 9;
- move16();
- hsCom->fftlenFac = 20480 /*0.625 Q15*/;
- move16();
- BREAK;
- default:
- assert( !"Unsupported FFT length for FD-based CNG" );
- BREAK;
- }
- BASOP_getTables( &hsCom->olapWinAna, NULL, NULL, shr( hsCom->fftlen, 1 ) );
- BASOP_getTables( &hsCom->olapWinSyn, NULL, NULL, shr( hsCom->fftlen, 2 ) );
- hsCom->frameSize = shr( hsCom->fftlen, 1 );
- move16();
-}
-
-
-/*
- deleteFdCngDec_fx
-
- Parameters:
-
- hFdCngDec i/0 : pointer to cng decoder structure
-
- Function:
- delete the instance of type FD_CNG
-
- Returns:
- void
-*/
-void deleteFdCngDec_fx( HANDLE_FD_CNG_DEC *hFdCngDec )
-{
- HANDLE_FD_CNG_DEC hsDec = *hFdCngDec;
-
- IF( hsDec != NULL )
- {
- deleteFdCngCom_fx( &( hsDec->hFdCngCom ) );
- free( hsDec );
- *hFdCngDec = NULL;
- }
-}
-
-
-/*
- ApplyFdCng_fx
-
- Parameters:
-
- timeDomainInput, i : pointer to time domain input
- cldfbBufferReal i/o: real part of the CLDFB buffer
- cldfbBufferImag i/o: imaginary part of the CLDFB buffer
- cldfbBufferScale o : pointer to the scalefactor for real and imaginary part of the CLDFB buffer
- st i/o: pointer to FD_CNG structure containing all buffers and variables
- m_frame_type i : type of frame at the decoder side
- stcod i : pointer to Coder_State structure
- st i : pointer to Decoder_State structure
- bitrate i : bitrate
- concealWholeFrame i : binary flag indicating frame loss
-
- Function:
- apply the CLDFB-based CNG at the decoder
-
- Returns:
- error
-*/
-
-#ifndef REMOVE_EVS_DUPLICATES
-Word16 ApplyFdCng_fx(
- Word16 *timeDomainInput, /* i : pointer to time domain input Q*/
- Word16 Q,
-#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
- Word16 *powerSpectrum,
-#endif
- Word32 **cldfbBufferReal, /* i/o: real part of the CLDFB buffer cldfbBufferScale*/
- Word32 **cldfbBufferImag, /* i/o: imaginary part of the CLDFB buffer cldfbBufferScale*/
- Word16 *cldfbBufferScale, /* o : pointer to the scalefactor for real and imaginary part of the CLDFB buffer */
- Decoder_State *st,
- const Word16 concealWholeFrame, /* i : binary flag indicating frame loss Q0*/
- Word16 is_music /*Q0*/ )
-{
- Word16 j, k, nBins;
- Word16 s, s1, s2, num, denom;
- Word32 *cngNoiseLevel;
- Word16 *cngNoiseLevel_exp;
- Word32 L_tmp;
- Word16 L_tmp_exp;
- Word16 facTab[NPART];
- Word16 facTabExp[NPART];
- Word16 tmp_loop;
- Word32 L_c;
- Word16 lsp_cng[M];
- HANDLE_FD_CNG_DEC hFdCngDec;
- HANDLE_FD_CNG_COM hFdCngCom;
-#ifdef BASOP_NOGLOB_DECLARE_LOCAL
- Flag Overflow = 0;
- Flag Carry = 0;
- move16();
- move16();
-#endif
-#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
- int16_t L_frame, last_L_frame;
- int32_t sr_core;
-
- PMT( "Fix point code missing for IVAS_CODE_CNG_FIX185_PLC_FADEOUT" )
- /* limit L_frame and core fs values for MDCT-Stereo modes which can have higher core sampling than 16kHz, but use a downsampled buffer */
- L_frame = min( st->L_frame, L_FRAME16k );
- last_L_frame = min( st->last_L_frame, L_FRAME16k );
- sr_core = min( st->sr_core, INT_FS_16k );
-#endif
-
- hFdCngDec = st->hFdCngDec;
- hFdCngCom = hFdCngDec->hFdCngCom;
-
-
- if ( EQ_16( hFdCngCom->frame_type_previous, ACTIVE_FRAME ) )
- {
- hFdCngCom->inactive_frame_counter = 0;
- move16();
- }
- IF( EQ_16( st->element_mode, IVAS_CPE_TD ) )
- {
- hFdCngDec->flag_dtx_mode = hFdCngDec->flag_dtx_mode || st->first_CNG;
- test();
- move16();
- }
- cngNoiseLevel = hFdCngCom->cngNoiseLevel; /*Q31 - hFdCngCom->cngNoiseLevelExp*/
- move32();
- cngNoiseLevel_exp = &hFdCngCom->cngNoiseLevelExp;
- move16();
- nBins = sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand );
-
- SWITCH( st->m_frame_type )
- {
- case ACTIVE_FRAME:
-
- /**************************
- * ACTIVE_FRAME at DECODER *
- **************************/
-
- hFdCngCom->inactive_frame_counter = 0;
- move16();
- hFdCngCom->sid_frame_counter = 0;
- move16();
-
- /* set noise estimation inactive during concealment, as no update with noise generated by concealment should be performed. */
- /* set noise estimation inactive during concealment, no update with noise generated by concealment should be performed. */
-
-#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- if ( concealWholeFrame == 0 &&
- ( timeDomainInput == NULL ||
- ( *timeDomainInput( -FLT_MAX ) &&
- *( timeDomainInput + hFdCngCom->frameSize - 1 ) < FLT_MAX &&
- *( timeDomainInput + hFdCngCom->frameSize - 1 ) > ( -FLT_MAX ) ) ) &&
- ( ( ( ( st->element_mode != IVAS_CPE_TD && st->element_mode != IVAS_CPE_DFT && hFdCngDec->flag_dtx_mode ) || !st->VAD ) &&
- !( st->cng_type == LP_CNG && hFdCngDec->flag_dtx_mode ) && ( is_music == 0 ) ) ||
- ( st->element_mode == IVAS_CPE_TD ) ) &&
- ( !st->BER_detect ) )
-#else
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- IF(
- ( concealWholeFrame == 0 ) &&
- ( LT_16( *timeDomainInput, MAXVAL_WORD16 ) ) && GT_16( *timeDomainInput, MINVAL_WORD16 ) && ( LT_16( *( timeDomainInput + sub( hFdCngCom->frameSize, 1 ) ), MAXVAL_WORD16 ) ) && GT_16( *( timeDomainInput + sub( hFdCngCom->frameSize, 1 ) ), MINVAL_WORD16 ) && ( ( ( hFdCngDec->flag_dtx_mode == 0 ) && ( st->VAD != 0 ) ) == 0 ) && ( ( ( st->cng_type == LP_CNG ) && ( hFdCngDec->flag_dtx_mode != 0 ) ) == 0 ) && ( is_music == 0 ) && ( st->BER_detect == 0 ) )
-#endif
- {
- /* Perform noise estimation at the decoder */
-#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
- perform_noise_estimation_dec_fx( timeDomainInput, powerSpectrum, hFdCngDec, st->element_mode, st->bwidth, L_frame, last_L_frame, st->last_core_brate, st->VAD );
-#else
- perform_noise_estimation_dec_fx( timeDomainInput, Q, hFdCngDec );
-#endif
-
- /* Update the shaping parameters */
- test();
- IF( NE_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->element_mode, IVAS_CPE_DFT ) )
- {
- scalebands( hFdCngDec->msNoiseEst, hFdCngDec->part_shaping, hFdCngDec->nFFTpart_shaping, hFdCngDec->midband_shaping, hFdCngDec->nFFTpart_shaping, nBins, hFdCngDec->bandNoiseShape, 1 );
- }
- hFdCngDec->bandNoiseShape_exp = hFdCngDec->msNoiseEst_exp;
- move16();
-
-
- /* Update CNG levels */
- test();
- IF( hFdCngDec->flag_dtx_mode != 0 && EQ_16( st->cng_type, FD_CNG ) )
- {
- /* This needs to be done only once per inactive phase */
- bandcombinepow(
- hFdCngDec->bandNoiseShape,
- hFdCngDec->bandNoiseShape_exp,
- nBins,
- hFdCngCom->part,
- hFdCngCom->nFFTpart,
- hFdCngCom->psize_inv,
- hFdCngDec->partNoiseShape,
- &hFdCngDec->partNoiseShape_exp );
-
-
- j = 0;
- move16();
- s2 = -( WORD32_BITS - 1 );
- move16();
- FOR( k = 0; k < hFdCngCom->nFFTpart; k++ )
- {
- assert( hFdCngDec->partNoiseShape[k] >= 0 );
- assert( hFdCngCom->sidNoiseEst[k] >= 0 );
-
- /* add DELTA as it is done in FLC version, in order to avoid num > denom */
- facTab[k] = 0;
- move16();
- IF( hFdCngDec->partNoiseShape[k] != 0 )
- {
- s1 = norm_l( hFdCngCom->sidNoiseEst[k] );
- L_tmp = L_shl( hFdCngCom->sidNoiseEst[k], s1 ); /*Q31 - hFdCngCom->sidNoiseEstExp + s1*/
- L_tmp_exp = sub( hFdCngCom->sidNoiseEstExp, s1 );
- L_tmp = BASOP_Util_Add_Mant32Exp( L_tmp, L_tmp_exp, DELTA_MANTISSA_W32, DELTA_EXPONENT, &L_tmp_exp );
- L_tmp = L_shr( L_tmp, 1 );
- s = add( L_tmp_exp, 1 );
- num = extract_h( L_tmp ); /*Q15 - L_tmp_exp*/
-
- s1 = norm_l( hFdCngDec->partNoiseShape[k] );
- L_tmp = L_shl( hFdCngDec->partNoiseShape[k], s1 ); /*Q31 - hFdCngDec->partNoiseShape_exp + s1*/
- L_tmp_exp = sub( hFdCngDec->partNoiseShape_exp, s1 );
- L_tmp = BASOP_Util_Add_Mant32Exp( L_tmp, L_tmp_exp, DELTA_MANTISSA_W32, DELTA_EXPONENT, &L_tmp_exp );
- s = sub( s, L_tmp_exp );
- denom = extract_h( L_tmp ); /*Q15 - L_tmp_exp*/
-
- facTab[k] = div_s( num, denom ); /*Q15 - s*/
- move16();
- facTabExp[k] = s;
- move16();
- }
- /* Set unique exponent, if mantissa is equal to zero */
- if ( facTab[k] == 0 )
- {
- facTabExp[k] = -( WORD32_BITS - 1 );
- move16();
- }
- s2 = s_max( s2, facTabExp[k] );
- }
-
- FOR( k = 0; k < hFdCngCom->nFFTpart; k++ )
- {
- s = sub( facTabExp[k], s2 );
- s = s_max( s_min( s, WORD32_BITS - 1 ), -( WORD32_BITS - 1 ) );
- FOR( ; j <= hFdCngCom->part[k]; j++ )
- {
- cngNoiseLevel[j] = L_shl( Mpy_32_16_1( hFdCngDec->bandNoiseShape[j], facTab[k] ), s ); /*Q31 - hFdCngDec->bandNoiseShape_exp*/
- move32();
- }
- }
-
- /* adapt scaling for rest of the buffer */
- IF( NE_16( s2, -( WORD32_BITS - 1 ) ) )
- {
- s = sub( *cngNoiseLevel_exp, add( hFdCngDec->bandNoiseShape_exp, s2 ) );
- FOR( ; k < hFdCngCom->npart; k++ )
- {
- FOR( ; j <= hFdCngCom->part[k]; j++ )
- {
- cngNoiseLevel[j] = L_shl( cngNoiseLevel[j], s ); /*Q31 - hFdCngDec->bandNoiseShape_exp + s*/
- move32();
- }
- }
-
- *cngNoiseLevel_exp = add( hFdCngDec->bandNoiseShape_exp, s2 );
- move16();
- }
- }
- ELSE
- {
- /* This sets the new CNG levels until a SID update overwrites it */
- test();
- test();
- test();
- IF( !( EQ_16( st->element_mode, IVAS_CPE_TD ) ) || ( EQ_16( st->element_mode, IVAS_CPE_TD ) && !hFdCngDec->flag_dtx_mode && !st->VAD ) )
- {
- Copy32( hFdCngDec->bandNoiseShape, cngNoiseLevel, nBins ); /*Q31 - hFdCngDec->bandNoiseShape_exp*/
- *cngNoiseLevel_exp = hFdCngDec->bandNoiseShape_exp;
- move16();
- }
- }
-#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
- if ( st->element_mode == IVAS_CPE_MDCT && timeDomainInput == NULL )
- {
- st->hTcxDec->CngLevelBackgroundTrace_bfi = sqrtf( sum_f( cngNoiseLevel, hFdCngCom->stopFFTbin - hFdCngCom->startBand ) / NORM_MDCT_FACTOR );
- }
- else
- {
- st->hTcxDec->CngLevelBackgroundTrace_bfi = (float) sqrt( ( sum_f( cngNoiseLevel, hFdCngCom->stopFFTbin - hFdCngCom->startBand ) / 2 * hFdCngCom->fftlen ) / L_frame );
- }
-#endif
- /*st->cngTDLevel = (float)sqrt( (sumFLOAT(cngNoiseLevel, hFdCngCom->stopFFTbin - hFdCngCom->startBand) / 2 * hFdCngCom->fftlen) / st->Mode2_L_frame);*/
- tmp_loop = sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand );
- L_tmp = L_deposit_h( 0 );
- L_c = L_deposit_h( 0 );
- FOR( j = 0; j < tmp_loop; j++ )
- {
-
- Carry = 0;
- move16();
- L_tmp = L_add_co( L_tmp, *( cngNoiseLevel + j ), &Carry, &Overflow ); /*Q31*/
- Overflow = 0;
- move16();
-
- IF( *( cngNoiseLevel + j ) < 0 )
- {
- L_c = L_msuNs( L_c, 0, 0 ); /*Q-1*/
- }
- IF( *( cngNoiseLevel + j ) >= 0 )
- {
- L_c = L_macNs_co( L_c, 0, 0, &Carry, &Overflow ); /*Q-1*/
- }
- }
- 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 );
-
- L_tmp = Mpy_32_16_1( L_tmp, hFdCngCom->fftlen ); /*Q16 - L_tmp_exp*/
-
- L_tmp = Mpy_32_16_1( L_tmp, T_DIV_L_Frame[L_shl( L_mac( -28000, st->L_frame, 95 ), 1 - 15 )] ); /*Q16,exp -7*/
- 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*/
-
- st->cngTDLevel = round_fx_sat( Sqrt32( L_tmp, &L_tmp_exp ) ); /*Q15 - L_tmp_exp*/
- st->cngTDLevel_e = L_tmp_exp;
- move16();
- }
- ELSE IF( EQ_16( st->element_mode, IVAS_CPE_TD ) || EQ_16( st->element_mode, IVAS_CPE_DFT ) )
- {
- IF( hFdCngCom->active_frame_counter > 0 )
- {
- /* Perform noise estimation in active frames in the decoder for downward updates */
-#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
- perform_noise_estimation_dec_fx( timeDomainInput, powerSpectrum, hFdCngDec, st->element_mode, st->bwidth, L_frame, last_L_frame, st->last_core_brate, st->VAD );
-#else
- perform_noise_estimation_dec_fx( timeDomainInput, Q, hFdCngDec );
-#endif
- }
- }
- test();
- test();
- L_tmp = 0;
- FOR( j = hFdCngCom->startBand; j < hFdCngCom->stopFFTbin; j++ )
- {
- L_tmp = L_add( L_tmp, L_shr( cngNoiseLevel[j], 16 ) );
- }
- L_tmp_exp = add( *cngNoiseLevel_exp, 16 );
- test();
- test();
- 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*/ ) )
- {
- /* 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
- lpc_from_spectrum( hFdCngCom, hFdCngCom->startBand, hFdCngCom->stopFFTbin, 0 );
- E_LPC_a_lsp_conversion( hFdCngCom->A_cng, lsp_cng, st->lspold_cng, M );
- Copy( lsp_cng, st->lspold_cng, M ); /*Q15*/
-
- lsp2lsf_fx( lsp_cng, st->lsf_cng, M, st->sr_core );
-#else
- if ( st->element_mode == IVAS_CPE_MDCT && st->core != ACELP_CORE )
- {
- float scf[SNS_NPTS];
- float scf_int[FDNS_NPTS];
- float whitenend_noise_shape[L_FRAME16k];
- int16_t inc, start_idx, stop_idx;
- float *noiseLevelPtr;
-
-
- inc = ( st->core > TCX_20 ) ? 2 : 1;
- start_idx = hFdCngCom->startBand / inc;
- stop_idx = L_frame / inc;
- noiseLevelPtr = cngNoiseLevel;
-
- set_zero( whitenend_noise_shape, start_idx );
- for ( j = start_idx; j < stop_idx; j++, noiseLevelPtr += inc )
- {
- whitenend_noise_shape[j] = *noiseLevelPtr;
- }
- if ( st->core == TCX_20_CORE )
- {
- st->hTonalMDCTConc->psychParams = &st->hTonalMDCTConc->psychParamsTCX20;
- }
- else
- {
- st->hTonalMDCTConc->psychParams = &st->hTonalMDCTConc->psychParamsTCX10;
- }
-
- sns_compute_scf( whitenend_noise_shape, st->hTonalMDCTConc->psychParams, L_frame, scf );
- sns_interpolate_scalefactors( scf_int, scf, ENC );
- sns_interpolate_scalefactors( st->hTonalMDCTConc->scaleFactorsBackground_flt, scf, DEC );
- sns_shape_spectrum( whitenend_noise_shape, st->hTonalMDCTConc->psychParams, scf_int, L_frame );
-
- mvr2r( whitenend_noise_shape + start_idx, cngNoiseLevel, stop_idx - start_idx );
- wmops_sub_end();
- }
- else if ( st->element_mode != IVAS_CPE_MDCT )
- {
- lpc_from_spectrum( hFdCngCom, hFdCngCom->startBand, hFdCngCom->stopFFTbin, 0.f );
- a2lsp_stab( hFdCngCom->A_cng, lsp_cng, st->lspold_cng );
- mvr2r( lsp_cng, st->lspold_cng, M );
- lsp2lsf( lsp_cng, st->lsf_cng, M, sr_core );
- }
-
-#endif
- st->plcBackgroundNoiseUpdated = 1;
- move16();
- }
- BREAK;
-
- case SID_FRAME:
-
- hFdCngDec->flag_dtx_mode = 1;
- move16();
- /* no break */
-
- case ZERO_FRAME:
-
- test();
- IF( st != NULL && st->cng_type == LP_CNG )
- {
- /* Perform noise estimation on inactive phase at the decoder */
-#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
- perform_noise_estimation_dec_fx( timeDomainInput, powerSpectrum, hFdCngDec, st->element_mode, st->bwidth, L_frame, last_L_frame, st->last_core_brate, st->VAD );
-#else
- perform_noise_estimation_dec_fx( timeDomainInput, Q, hFdCngDec );
-#endif
- /* Update the shaping parameters */
-
- test();
- IF( NE_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->element_mode, IVAS_CPE_DFT ) )
- {
- scalebands( hFdCngDec->msNoiseEst, hFdCngDec->part_shaping, hFdCngDec->nFFTpart_shaping, hFdCngDec->midband_shaping, hFdCngDec->nFFTpart_shaping, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ), hFdCngDec->bandNoiseShape, 1 );
- }
- hFdCngDec->bandNoiseShape_exp = hFdCngDec->msNoiseEst_exp;
- move16();
- /* This sets the new CNG levels until a SID update overwrites it */
- Copy32( hFdCngDec->bandNoiseShape, cngNoiseLevel, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ) ); /* This sets the new CNG levels until a SID update overwrites it Q31 - hFdCngDec->bandNoiseShape_exp*/
- *cngNoiseLevel_exp = hFdCngDec->bandNoiseShape_exp;
- move16();
-#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
- st->cngTDLevel = (float) sqrt( ( sum_f( cngNoiseLevel, hFdCngCom->stopFFTbin - hFdCngCom->startBand ) / 2 * hFdCngCom->fftlen ) / L_frame );
-#else
- /*st->cngTDLevel = (float)sqrt( (sumFLOAT(cngNoiseLevel, hFdCngCom->stopFFTbin - hFdCngCom->startBand) / 2 * hFdCngCom->fftlen) / st->Mode2_L_frame);*/
- tmp_loop = sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand );
- L_tmp = L_deposit_h( 0 );
- L_c = L_deposit_h( 0 );
- FOR( j = 0; j < tmp_loop; j++ )
- {
-
- Carry = 0;
- move16();
- L_tmp = L_add_co( L_tmp, *( cngNoiseLevel + j ), &Carry, &Overflow ); /*Q31*/
- Overflow = 0;
- move16();
-
- IF( *( cngNoiseLevel + j ) < 0 )
- {
- L_c = L_msuNs_co( L_c, 0, 0, &Carry, &Overflow ); /*Q-1*/
- }
- IF( *( cngNoiseLevel + j ) >= 0 )
- {
- L_c = L_macNs_co( L_c, 0, 0, &Carry, &Overflow ); /*Q-1*/
- }
- }
- 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 );
-
- L_tmp = Mpy_32_16_1( L_tmp, hFdCngCom->fftlen ); /*Q16 - L_tmp_exp*/
-
- L_tmp = Mpy_32_16_1( L_tmp, T_DIV_L_Frame[L_shl( L_mac( -28000, st->L_frame, 95 ), 1 - 15 )] ); /*Q16,exp -7*/
- 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*/
+ }
- st->cngTDLevel = round_fx_o( Sqrt32( L_tmp, &L_tmp_exp ), &Overflow ); /*Q15 - L_tmp_exp*/
- move16();
- st->cngTDLevel_e = L_tmp_exp;
- move16();
-#endif
- BREAK;
- }
- hFdCngCom->inactive_frame_counter = add( hFdCngCom->inactive_frame_counter, 1 );
+ stopBandFR = 1000 / 25;
+ move16();
+ if ( GT_16( stopBandFR, hsCom->stopFFTbin ) )
+ {
+ stopBandFR = hsCom->stopFFTbin; /*Q0*/
+ move16();
+ }
+ initPartitions( hsCom->FdCngSetup.shapingPartitions, hsCom->FdCngSetup.numShapingPartitions,
+ hsCom->startBand, hsCom->stopFFTbin, hFdCngDec->part_shaping, &hFdCngDec->npart_shaping, hFdCngDec->midband_shaping,
+ hFdCngDec->psize_shaping, hFdCngDec->psize_shaping_norm, &hFdCngDec->psize_shaping_norm_exp, hFdCngDec->psize_inv_shaping,
+ stopBandFR );
+ hFdCngDec->nFFTpart_shaping = hFdCngDec->npart_shaping; /*Q0*/
+ move16();
+
+ SWITCH( hsCom->fftlen )
+ {
+ case 512:
+ hsCom->fftlenShift = 8;
+ move16();
+ hsCom->fftlenFac = 32767 /*1.0 Q15*/;
+ move16();
+ BREAK;
+ case 640:
+ hsCom->fftlenShift = 9;
+ move16();
+ hsCom->fftlenFac = 20480 /*0.625 Q15*/;
move16();
+ BREAK;
+ default:
+ assert( !"Unsupported FFT length for FD-based CNG" );
+ BREAK;
+ }
+ BASOP_getTables( &hsCom->olapWinAna, NULL, NULL, shr( hsCom->fftlen, 1 ) );
+ BASOP_getTables( &hsCom->olapWinSyn, NULL, NULL, shr( hsCom->fftlen, 2 ) );
+ hsCom->frameSize = shr( hsCom->fftlen, 1 );
+ move16();
+}
- /*************************************
- * SID_FRAME or ZERO_FRAME at DECODER *
- *************************************/
- /* Detect first non-active frame */
- IF( EQ_16( hFdCngCom->inactive_frame_counter, 1 ) )
- {
- /* Compute the fine spectral structure of the comfort noise shape using the decoder-side noise estimates */
- bandcombinepow(
- hFdCngDec->bandNoiseShape,
- hFdCngDec->bandNoiseShape_exp,
- nBins,
- hFdCngCom->part,
- hFdCngCom->nFFTpart,
- hFdCngCom->psize_inv,
- hFdCngDec->partNoiseShape,
- &hFdCngDec->partNoiseShape_exp );
- }
+/*
+ deleteFdCngDec_fx
- IF( EQ_16( st->m_frame_type, SID_FRAME ) )
- {
- IF( LT_32( hFdCngCom->msFrCnt_init_counter, L_deposit_l( hFdCngCom->msFrCnt_init_thresh ) ) )
- {
- /* At initialization, interpolate the bin/band-wise levels from the partition levels */
- scalebands( hFdCngCom->sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband,
- hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), cngNoiseLevel, 1 );
- *cngNoiseLevel_exp = hFdCngCom->sidNoiseEstExp;
- move16();
- }
- ELSE
- {
- if ( EQ_16( st->element_mode, IVAS_CPE_DFT ) )
- {
- }
+ Parameters:
- /* Interpolate the CLDFB band levels from the SID (partition) levels */
- IF( GT_16( hFdCngCom->regularStopBand, hFdCngCom->numCoreBands ) )
- {
- scalebands( hFdCngCom->sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband,
- hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), cngNoiseLevel, 0 );
- *cngNoiseLevel_exp = hFdCngCom->sidNoiseEstExp;
- move16();
- }
+ hFdCngDec i/0 : pointer to cng decoder structure
- s2 = -( WORD32_BITS - 1 );
- move16();
- /* Shape the SID noise levels in each FFT bin */
- j = 0;
- move16();
- FOR( k = 0; k < hFdCngCom->nFFTpart; k++ )
- {
- assert( hFdCngDec->partNoiseShape[k] >= 0 );
+ Function:
+ delete the instance of type FD_CNG
- /* add DELTA as it is done in FLC version, in order to avoid num > denom */
- facTab[k] = 0;
- move16();
- IF( hFdCngDec->partNoiseShape[k] != 0 )
- {
- s1 = norm_l( hFdCngCom->sidNoiseEst[k] );
- L_tmp = L_shl( hFdCngCom->sidNoiseEst[k], s1 ); /*Q31 - hFdCngCom->sidNoiseEstExp + s1*/
- L_tmp_exp = sub( hFdCngCom->sidNoiseEstExp, s1 );
- L_tmp = BASOP_Util_Add_Mant32Exp( hFdCngCom->sidNoiseEst[k], hFdCngCom->sidNoiseEstExp, DELTA_MANTISSA_W32, DELTA_EXPONENT, &L_tmp_exp );
- L_tmp = L_shr( L_tmp, 1 );
- s = add( L_tmp_exp, 1 );
- num = extract_h( L_tmp ); /*Q15 - L_tmp_exp*/
+ Returns:
+ void
+*/
+void deleteFdCngDec_fx( HANDLE_FD_CNG_DEC *hFdCngDec )
+{
+ HANDLE_FD_CNG_DEC hsDec = *hFdCngDec;
- s1 = norm_l( hFdCngDec->partNoiseShape[k] );
- L_tmp = L_shl( hFdCngDec->partNoiseShape[k], s1 ); /*Q31 - hFdCngDec->partNoiseShape_exp + s1*/
- L_tmp_exp = sub( hFdCngDec->partNoiseShape_exp, s1 );
- L_tmp = BASOP_Util_Add_Mant32Exp( L_tmp, L_tmp_exp, DELTA_MANTISSA_W32, DELTA_EXPONENT, &L_tmp_exp );
- s = sub( s, L_tmp_exp );
- denom = extract_h( L_tmp ); /*Q15 - L_tmp_exp*/
+ IF( hsDec != NULL )
+ {
+ deleteFdCngCom_fx( &( hsDec->hFdCngCom ) );
+ free( hsDec );
+ *hFdCngDec = NULL;
+ }
+}
- facTab[k] = div_s( num, denom ); /*Q15 - s*/
- move16();
- facTabExp[k] = s;
- move16();
- }
- /* Set unique exponent, if mantissa is equal to zero */
- if ( facTab[k] == 0 )
- {
- facTabExp[k] = -( WORD32_BITS - 1 );
- move16();
- }
- s2 = s_max( s2, facTabExp[k] );
- }
- FOR( k = 0; k < hFdCngCom->nFFTpart; k++ )
- {
- s = sub( facTabExp[k], s2 );
- s = s_max( s_min( s, WORD32_BITS - 1 ), -( WORD32_BITS - 1 ) );
- FOR( ; j <= hFdCngCom->part[k]; j++ )
- {
- cngNoiseLevel[j] = L_shl( Mpy_32_16_1( hFdCngDec->bandNoiseShape[j], facTab[k] ), s ); /*Q31 - hFdCngDec->bandNoiseShape_exp*/
- move32();
- }
- }
- /* adapt scaling for rest of the buffer */
- s = sub( *cngNoiseLevel_exp, add( hFdCngDec->bandNoiseShape_exp, s2 ) );
- FOR( ; k < hFdCngCom->npart; k++ )
- {
- FOR( ; j <= hFdCngCom->part[k]; j++ )
- {
- cngNoiseLevel[j] = L_shl( cngNoiseLevel[j], s ); /*Q31 - hFdCngDec->bandNoiseShape_exp + s*/
- move32();
- }
- }
- *cngNoiseLevel_exp = add( hFdCngDec->bandNoiseShape_exp, s2 );
- move16();
- }
- }
+/*
+ ApplyFdCng_fx
- IF( EQ_16( st->codec_mode, MODE2 ) )
- {
- /* Generate comfort noise during SID or zero frames */
- generate_comfort_noise_dec_fx( cldfbBufferReal, cldfbBufferImag, cldfbBufferScale, st, &( st->Q_exc ), 2, -1 );
- }
+ Parameters:
- BREAK;
+ timeDomainInput, i : pointer to time domain input
+ cldfbBufferReal i/o: real part of the CLDFB buffer
+ cldfbBufferImag i/o: imaginary part of the CLDFB buffer
+ cldfbBufferScale o : pointer to the scalefactor for real and imaginary part of the CLDFB buffer
+ st i/o: pointer to FD_CNG structure containing all buffers and variables
+ m_frame_type i : type of frame at the decoder side
+ stcod i : pointer to Coder_State structure
+ st i : pointer to Decoder_State structure
+ bitrate i : bitrate
+ concealWholeFrame i : binary flag indicating frame loss
- default:
- return -1;
- }
+ Function:
+ apply the CLDFB-based CNG at the decoder
+ Returns:
+ error
+*/
- return 0;
-}
-#endif
-Word16 ApplyFdCng_ivas_fx(
+Word16 ApplyFdCng_fx(
Word16 *timeDomainInput, /* i : pointer to time domain input Q*/
Word16 Q,
Word32 *powerSpectrum, /*Q_power_spectrum*/
@@ -1221,27 +657,22 @@ Word16 ApplyFdCng_ivas_fx(
( !st->BER_detect ) )
{
/* Perform noise estimation at the decoder */
-#ifdef REMOVE_EVS_DUPLICATES
IF( EQ_16( st->element_mode, EVS_MONO ) )
{
perform_noise_estimation_dec_fx( timeDomainInput, Q, hFdCngDec );
}
ELSE
-#endif
{
perform_noise_estimation_dec_ivas_fx( timeDomainInput, Q, powerSpectrum, Q_power_spectrum, hFdCngDec, st->element_mode, st->bwidth, L_frame, last_L_frame, st->last_core_brate, st->VAD );
}
/* Update the shaping parameters */
test();
-#ifdef REMOVE_EVS_DUPLICATES
IF( EQ_16( st->element_mode, EVS_MONO ) )
{
scalebands( hFdCngDec->msNoiseEst, hFdCngDec->part_shaping, hFdCngDec->nFFTpart_shaping, hFdCngDec->midband_shaping, hFdCngDec->nFFTpart_shaping, nBins, hFdCngDec->bandNoiseShape, 1 );
}
- ELSE
-#endif
- IF( NE_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->element_mode, IVAS_CPE_DFT ) )
+ ELSE IF( NE_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->element_mode, IVAS_CPE_DFT ) )
{
scalebands_fx( hFdCngDec->msNoiseEst, hFdCngDec->part_shaping, hFdCngDec->nFFTpart_shaping, hFdCngDec->midband_shaping, hFdCngDec->nFFTpart_shaping, nBins, hFdCngDec->bandNoiseShape, 1 );
}
@@ -1477,13 +908,11 @@ Word16 ApplyFdCng_ivas_fx(
IF( hFdCngCom->active_frame_counter > 0 )
{
/* Perform noise estimation in active frames in the decoder for downward updates */
-#ifdef REMOVE_EVS_DUPLICATES
IF( EQ_16( st->element_mode, EVS_MONO ) )
{
perform_noise_estimation_dec_fx( timeDomainInput, Q, hFdCngDec );
}
ELSE
-#endif
{
perform_noise_estimation_dec_ivas_fx( timeDomainInput, Q, powerSpectrum, Q_power_spectrum, hFdCngDec, st->element_mode, st->bwidth, L_frame, last_L_frame, st->last_core_brate, st->VAD );
}
@@ -1544,44 +973,37 @@ Word16 ApplyFdCng_ivas_fx(
IF( st != NULL && EQ_16( st->cng_type, LP_CNG ) )
{
/* Perform noise estimation on inactive phase at the decoder */
-#ifdef REMOVE_EVS_DUPLICATES
IF( EQ_16( st->element_mode, EVS_MONO ) )
{
perform_noise_estimation_dec_fx( timeDomainInput, Q, hFdCngDec );
}
ELSE
-#endif
{
perform_noise_estimation_dec_ivas_fx( timeDomainInput, Q, powerSpectrum, Q_power_spectrum, hFdCngDec, st->element_mode, st->bwidth, L_frame, last_L_frame, st->last_core_brate, st->VAD );
}
/* Update the shaping parameters */
-
test();
-#ifdef REMOVE_EVS_DUPLICATES
IF( EQ_16( st->element_mode, EVS_MONO ) )
{
scalebands( hFdCngDec->msNoiseEst, hFdCngDec->part_shaping, hFdCngDec->nFFTpart_shaping, hFdCngDec->midband_shaping, hFdCngDec->nFFTpart_shaping, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ), hFdCngDec->bandNoiseShape, 1 );
}
- ELSE
-#endif
- IF( NE_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->element_mode, IVAS_CPE_DFT ) )
+ ELSE IF( NE_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->element_mode, IVAS_CPE_DFT ) )
{
scalebands_fx( hFdCngDec->msNoiseEst, hFdCngDec->part_shaping, hFdCngDec->nFFTpart_shaping, hFdCngDec->midband_shaping, hFdCngDec->nFFTpart_shaping, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ), hFdCngDec->bandNoiseShape, 1 );
}
hFdCngDec->bandNoiseShape_exp = hFdCngDec->msNoiseEst_exp;
move16();
+
/* This sets the new CNG levels until a SID update overwrites it */
Copy32( hFdCngDec->bandNoiseShape, cngNoiseLevel, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ) ); /* This sets the new CNG levels until a SID update overwrites it */ /*Q31 - hFdCngDec->bandNoiseShape_exp*/
-#ifdef REMOVE_EVS_DUPLICATES
IF( EQ_16( st->element_mode, EVS_MONO ) )
{
*cngNoiseLevel_exp = hFdCngDec->bandNoiseShape_exp;
move16();
}
ELSE
-#endif
{
Word16 shift1 = L_norm_arr( cngNoiseLevel, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ) );
Word16 shift2 = L_norm_arr( cngNoiseLevel + sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ), sub( FFTCLDFBLEN, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ) ) );
@@ -1662,16 +1084,15 @@ Word16 ApplyFdCng_ivas_fx(
IF( LT_32( hFdCngCom->msFrCnt_init_counter, L_deposit_l( hFdCngCom->msFrCnt_init_thresh ) ) )
{
/* At initialization, interpolate the bin/band-wise levels from the partition levels */
-#ifdef REMOVE_EVS_DUPLICATES
IF( EQ_16( st->element_mode, EVS_MONO ) )
{
scalebands( hFdCngCom->sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), cngNoiseLevel, 1 );
}
ELSE
-#endif
{
scalebands_fx( hFdCngCom->sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), cngNoiseLevel, 1 );
}
+
*cngNoiseLevel_exp = hFdCngCom->sidNoiseEstExp;
move16();
}
@@ -1684,13 +1105,11 @@ Word16 ApplyFdCng_ivas_fx(
/* Interpolate the CLDFB band levels from the SID (partition) levels */
IF( GT_16( hFdCngCom->regularStopBand, hFdCngCom->numCoreBands ) )
{
-#ifdef REMOVE_EVS_DUPLICATES
IF( EQ_16( st->element_mode, EVS_MONO ) )
{
scalebands( sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), cngNoiseLevel, 0 );
}
ELSE
-#endif
{
scalebands_fx( sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), cngNoiseLevel, 0 );
}
@@ -1757,7 +1176,6 @@ Word16 ApplyFdCng_ivas_fx(
}
}
-#ifdef REMOVE_EVS_DUPLICATES
IF( EQ_16( st->element_mode, EVS_MONO ) )
{
/* adapt scaling for rest of the buffer */
@@ -1774,7 +1192,6 @@ Word16 ApplyFdCng_ivas_fx(
move16();
}
ELSE
-#endif
{
Word16 shift1 = L_norm_arr( cngNoiseLevel, j );
Word16 shift2 = L_norm_arr( &cngNoiseLevel[j], sub( FFTCLDFBLEN, j ) );
@@ -1863,13 +1280,11 @@ Word16 ApplyFdCng_ivas_fx(
IF( EQ_16( st->codec_mode, MODE2 ) )
{
/* Generate comfort noise during SID or zero frames */
-#ifdef REMOVE_EVS_DUPLICATES
IF( EQ_16( st->element_mode, EVS_MONO ) )
{
generate_comfort_noise_dec_fx( cldfbBufferReal, cldfbBufferImag, cldfbBufferScale, st, &( st->Q_exc ), 2, -1 );
}
ELSE
-#endif
{
generate_comfort_noise_dec_ivas_fx( cldfbBufferReal, cldfbBufferImag, cldfbBufferScale, st, &( st->Q_exc ), 2, -1 );
}
@@ -1903,9 +1318,6 @@ Word16 ApplyFdCng_ivas_fx(
void perform_noise_estimation_dec_fx(
const Word16 *timeDomainInput, /* i: pointer to time domain input Q*/
const Word16 Q,
-#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
- float *power_spectrum,
-#endif
HANDLE_FD_CNG_DEC hFdCngDec /* i/o: FD_CNG structure containing all buffers and variables */
)
{
@@ -1936,53 +1348,11 @@ void perform_noise_estimation_dec_fx(
move16();
/* Perform STFT analysis */
-#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
- IF( !( EQ_16( element_mode, IVAS_CPE_MDCT ) && power_spectrum != NULL ) )
- {
- /* Perform STFT analysis */
- AnalysisSTFT( timeDomainInput, Q, fftBuffer, &fftBuffer_exp, hFdCngDec->hFdCngCom );
- }
-#else
/* Perform STFT analysis */
AnalysisSTFT( timeDomainInput, Q, fftBuffer, &fftBuffer_exp, hFdCngDec->hFdCngCom );
-#endif
fftBuffer_exp = add( fftBuffer_exp, WORD16_BITS - 1 );
{
-#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
- if ( element_mode == IVAS_CPE_MDCT && power_spectrum != NULL )
- {
- /* use power spectrum calculated in the MDCT-domain instead of calculating new power spectrum */
- periodog = power_spectrum;
- }
- else
- {
- /* Compute the squared magnitude in each FFT bin */
- if ( startBand == 0 )
- {
- ( *ptr_per ) = fftBuffer[0] * fftBuffer[0]; /* DC component */
- ptr_per++;
- ptr_r = fftBuffer + 2;
- }
- else
- {
- ptr_r = fftBuffer + 2 * startBand;
- }
-
- ptr_i = ptr_r + 1;
-
- for ( ; ptr_per < periodog + stopFFTbin - startBand; ptr_per++ )
- {
- ( *ptr_per ) = ( *ptr_r ) * ( *ptr_r ) + ( *ptr_i ) * ( *ptr_i );
- ptr_r += 2;
- ptr_i += 2;
- }
- /* Nyquist frequency is discarded */
-
- /* Rescale to get energy/sample: it should be 2*(1/N)*(2/N), parseval relation with 1/N,*2 for nrg computed till Nyquist only, 2/N as windowed samples correspond to half a frame*/
- v_multc( periodog, 4.f / (float) ( hFdCngDec->hFdCngCom->fftlen * hFdCngDec->hFdCngCom->fftlen ), periodog, stopFFTbin - startBand );
- }
-#else
assert( startBand != 0 );
len = sub( stopFFTbin, startBand );
@@ -2062,7 +1432,6 @@ void perform_noise_estimation_dec_fx(
}
hFdCngDec->hFdCngCom->periodog_exp = add( hFdCngDec->hFdCngCom->periodog_exp, sub( 2, s ) );
move16();
-#endif
/* Adjust to the desired frequency resolution by averaging over spectral partitions for SID transmission */
bandcombinepow( periodog, hFdCngDec->hFdCngCom->periodog_exp, sub( stopFFTbin, startBand ), part, npart, psize_inv, hFdCngDec->msPeriodog, &hFdCngDec->msPeriodog_exp );
@@ -2131,6 +1500,9 @@ void perform_noise_estimation_dec_ivas_fx(
Word32 enr, enr_tot, enr_tot0;
Word16 enr_e, enr_ratio, alpha;
Word32 *msPeriodog;
+#ifdef FIX_732_MS_PERIODOG_FLOOR
+ Word32 msPeriodog_floor;
+#endif
Word32 *msNoiseEst;
Word32 *reIter;
Word32 rescale_fac = 0;
@@ -2139,6 +1511,10 @@ void perform_noise_estimation_dec_ivas_fx(
Word16 q_shift;
Word32 max_l;
Word16 norm_shift;
+#ifdef FIX_732_MS_PERIODOG_FLOOR
+ Word16 check = 0;
+ move16();
+#endif
/* pointer initialization */
periodog = hFdCngDec->hFdCngCom->periodog; /*Q31 - hFdCngDec->hFdCngCom->periodog_exp*/
@@ -2337,12 +1713,38 @@ void perform_noise_estimation_dec_ivas_fx(
msPeriodog[p] = L_add( msPeriodog[p], L_tmp ); /*Q31 - hFdCngDec->msPeriodog_exp*/
move32();
+#ifdef FIX_732_MS_PERIODOG_FLOOR
+ msPeriodog_floor = L_max( 1, L_shr( 21474 /*Q31*/, hFdCngDec->msPeriodog_exp ) ); /*Q31 - hFdCngDec->msPeriodog_exp*/
+ IF( LT_32( msPeriodog[p], msPeriodog_floor ) )
+#else
IF( LT_32( msPeriodog[p], L_shr( 21474 /*Q31*/, hFdCngDec->msPeriodog_exp ) ) )
+#endif
{
+#ifdef FIX_732_MS_PERIODOG_FLOOR
+ msPeriodog[p] = msPeriodog_floor;
+ move32();
+#else
msPeriodog[p] = L_shr( 21474 /*Q31*/, hFdCngDec->msPeriodog_exp ); /*Q31 - hFdCngDec->msPeriodog_exp*/
move32();
+#endif
+ }
+ }
+#ifdef FIX_732_MS_PERIODOG_FLOOR
+ FOR( p = 0; p < npart; p++ )
+ {
+ IF( GT_32( msPeriodog[p], 1 ) )
+ {
+ check = 1;
+ move16();
+ BREAK;
}
}
+ IF( check == 0 )
+ {
+ hFdCngDec->msPeriodog_exp = 14; /* msPeriodog buffer will have minimum value as 1e-5f */
+ move16();
+ }
+#endif
}
/* calculate total energy (short-term and long-term) */
@@ -2862,8 +2264,8 @@ void perform_noise_estimation_dec_ivas_fx(
nFFTpart,
psize_norm,
hFdCngDec->msLogPeriodog,
- hFdCngDec->msNoiseFloor,
- hFdCngDec->msLogNoiseEst,
+ hFdCngDec->msNoiseFloor_32fx,
+ hFdCngDec->msLogNoiseEst_32fx,
hFdCngDec->msAlpha,
hFdCngDec->msPsd,
hFdCngDec->msPsdFirstMoment,
@@ -2890,7 +2292,7 @@ void perform_noise_estimation_dec_ivas_fx(
move16();
/* Expand MS outputs */
- expand_range( hFdCngDec->msLogNoiseEst, hFdCngDec->msNoiseEst, &hFdCngDec->msNoiseEst_exp, npart );
+ expand_range_fx( hFdCngDec->msLogNoiseEst_32fx, hFdCngDec->msNoiseEst, &hFdCngDec->msNoiseEst_exp, npart );
}
}
@@ -3599,7 +3001,9 @@ void generate_comfort_noise_dec_ivas_fx(
Word32 tmp1, tmp2;
Word16 scaleCldfb;
Word32 *fftBuffer = hFdCngCom->fftBuffer; /*hFdCngCom->fftBuffer_exp*/
- Word16 fftBuffer_exp = hFdCngCom->fftBuffer_exp;
+ Word16 fftBuffer_exp, fftBuffer_exp2;
+ fftBuffer_exp = hFdCngCom->fftBuffer_exp;
+ move16();
Word16 fftBuffer_temp_exp[FFTLEN];
Word16 *timeDomainOutput = hFdCngCom->timeDomainBuffer;
Word16 temp;
@@ -3632,6 +3036,8 @@ void generate_comfort_noise_dec_ivas_fx(
hFdCngCom->fftBuffer_exp = fftBuffer_exp;
move16();
set16_fx( fftBuffer_temp_exp, fftBuffer_exp, FFTLEN );
+ fftBuffer_exp2 = fftBuffer_exp;
+ move16();
fftBuffer_exp = 0;
move16();
@@ -3789,9 +3195,16 @@ void generate_comfort_noise_dec_ivas_fx(
/* Perform STFT synthesis */
SynthesisSTFT_ivas_fx( fftBuffer, fftBuffer_exp, timeDomainOutput, hFdCngCom->olapBufferSynth, hFdCngCom->olapWinSyn,
- tcx_transition, hFdCngCom, gen_exc, Q_new, st->element_mode, nchan_out );
- scale_sig32( fftBuffer + hFdCngCom->fftlen, sub( FFTLEN, hFdCngCom->fftlen ), sub( fftBuffer_exp, hFdCngCom->fftBuffer_exp ) ); /*Q31 - fftBuffer_exp*/
-
+ tcx_transition, hFdCngCom, gen_exc, Q_new, st->element_mode, nchan_out ); /* fftBuffer in hfDCngCom->fftBuffer_exp */
+ /* fftBuffer now in different Qs [0 to fftlen - 1] = hfDCngCom->fftBuffer_exp and [fftlen to FFTLEN(640)] = fftBuffer_exp2, bringing it in common exponent */
+ Word16 shift1 = L_norm_arr( fftBuffer, hFdCngCom->fftlen );
+ Word16 shift2 = L_norm_arr( fftBuffer + hFdCngCom->fftlen, sub( FFTLEN, hFdCngCom->fftlen ) );
+ Word16 shift = s_max( sub( hFdCngCom->fftBuffer_exp, shift1 ), sub( fftBuffer_exp2, shift2 ) );
+
+ scale_sig32( fftBuffer, hFdCngCom->fftlen, sub( hFdCngCom->fftBuffer_exp, shift ) );
+ scale_sig32( fftBuffer + hFdCngCom->fftlen, sub( FFTLEN, hFdCngCom->fftlen ), sub( fftBuffer_exp2, shift ) );
+ hFdCngCom->fftBuffer_exp = shift;
+ move16();
{
Word32 Lener, att;
Word16 exp;
diff --git a/lib_dec/gain_dec_fx.c b/lib_dec/gain_dec_fx.c
index 00eca187d71f2ca2891b1ee44c4af13bf099355c..db325cd80b92a8be09722e96ce43d699613736e6 100644
--- a/lib_dec/gain_dec_fx.c
+++ b/lib_dec/gain_dec_fx.c
@@ -602,7 +602,6 @@ void gain_dec_mless_fx(
/* _ None */
/*==================================================================================*/
-#ifndef REMOVE_EVS_DUPLICATES
void gain_dec_lbr_fx(
Decoder_State *st_fx, /* i/o: decoder state structure */
const Word16 coder_type, /* i : coding type */
@@ -653,375 +652,6 @@ void gain_dec_lbr_fx(
ctype = shl( sub( coder_type, 1 ), 1 );
- /*-----------------------------------------------------------------*
- * calculate prediction of gcode
- * search for the best codeword
- *-----------------------------------------------------------------*/
- IF( i_subfr == 0 )
- {
- b_fx = b_1sfr_fx;
- move16();
- n_pred = 2;
- move16();
- cdbk_fx = gp_gamma_1sfr_6b_fx;
- SWITCH( nBits )
- {
- case 8:
- {
- cdbk_fx = gp_gamma_1sfr_8b_fx; /* Q14/Q9*/
- BREAK;
- }
- case 7:
- {
- cdbk_fx = gp_gamma_1sfr_7b_fx; /* Q14/Q9*/
- BREAK;
- }
- case 6:
- {
- cdbk_fx = gp_gamma_1sfr_6b_fx; /* Q14/Q9*/
- BREAK;
- }
- }
-
- /* calculate predicted gain */
- aux_fx[0] = 4096; /*Q12*/
- move16();
- aux_fx[1] = shl( ctype, 12 ); /*Q12*/
- 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));
- gcode0 = (float)pow(10, 0.05(20 * dotp(b, aux, n_pred) - 10 * (float)log10(Ecode))); */
-
- e_tmp = norm_l( L_tmp2 );
- f_tmp = Log2_norm_lc( L_shl( L_tmp2, 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*/
-
- L_tmp = Dot_product( b_fx, aux_fx, n_pred ); /*Q25*/
- L_tmp = Mult_32_16( L_tmp, 160 ); /*Q13, 20 in Q3*/
- L_tmp = L_sub( L_tmp, L_tmp1 ); /*Q13*/
-
- gcode0_fx = round_fx( L_shl( L_tmp, 11 ) ); /* Q8 */
-
-
- /*-----------------------------------------------------------------*
- * gcode0 = pow(10.0, gcode0/20)
- * = pow(2, 3.321928*gcode0/20)
- * = pow(2, 0.166096*gcode0)
- *-----------------------------------------------------------------*/
-
- L_tmp = L_mult( gcode0_fx, 21771 ); /* *0.166096 in Q17 -> Q26 */
- L_tmp = L_shr( L_tmp, 10 ); /* From Q26 to Q16 */
- frac = L_Extract_lc( L_tmp, &exp_gcode0 ); /* Extract exponent of gcode0 */
-
- gcode0_fx = extract_l( Pow2( 14, frac ) ); /* Put 14 as exponent so that */
- /* output of Pow2() will be: */
- /* 16384 < Pow2() <= 32767 */
- exp_gcode0 = sub( exp_gcode0, 14 );
-
- /* retrieve the codebook index and calculate both gains */
- /*index = (Word16)get_indice( st_fx,"gain", i_subfr, ACELP_CORE);move16();*/
- index = (Word16) get_next_indice_fx( st_fx, nBits ); /*Q0*/
- move16();
-
- *gain_pit_fx = cdbk_fx[index * 2]; /*Q14*/
- move16();
-
- L_tmp = L_mult( cdbk_fx[( ( index * 2 ) + 1 )], gcode0_fx ); /* Q9*Q0 -> Q10 */
- *gain_code_fx = L_shl_sat( L_tmp, add( exp_gcode0, 6 ) ); /* Q10 -> Q16*/
- move16();
-
- gc_mem[0] = *gain_code_fx; /*Q16*/
- move32();
- gp_mem[0] = *gain_pit_fx; /*Q14*/
- move16();
- }
- ELSE IF( EQ_16( i_subfr, L_SUBFR ) || EQ_16( L_subfr, 2 * L_SUBFR ) )
- {
- b_fx = b_2sfr_fx; /*Q12*/
- move16();
- n_pred = 4;
- move16();
-
- cdbk_fx = gp_gamma_1sfr_6b_fx; /*Q14/Q9 */
- SWITCH( nBits )
- {
- case 7:
- {
- cdbk_fx = gp_gamma_2sfr_7b_fx; /* Q14/Q9*/
- BREAK;
- }
- case 6:
- {
- cdbk_fx = gp_gamma_2sfr_6b_fx; /* Q14/Q9*/
- BREAK;
- }
- }
-
- /* calculate predicted gain */
- aux_fx[0] = 4096; /*Q12*/
- move16();
- aux_fx[1] = shl( ctype, 12 ); /*Q12*/
- move16();
-
- /*aux_fx[2] = (float)log10(gc_mem[0]);
- = log2(gc_mem[0])*log10(2);*/
- e_tmp = norm_l( gc_mem[0] );
- f_tmp = Log2_norm_lc( L_shl( gc_mem[0], e_tmp ) ); /*Q15*/
- e_tmp = sub( sub( 30, e_tmp ), 16 ); /*Q_format(gc_mem[0])=16*/
- L_tmp1 = Mpy_32_16( e_tmp, f_tmp, 9864 ); /* Q16 */
- aux_fx[2] = round_fx( L_shl( L_tmp1, 12 ) ); /* Q12 */
- move16();
-
- aux_fx[3] = shr( gp_mem[0], 2 ); /*Q12*/
- move16();
-
- /*-----------------------------------------------------------------*
- * gcode0 = pow(10.0, dotp(b, aux, n_pred)
- * = pow(2, 3.321928*dotp(b, aux, n_pred)
- *-----------------------------------------------------------------*/
- L_tmp = Dot_product( b_fx, aux_fx, n_pred ); /*Q25*/
- L_tmp = Mult_32_16( L_tmp, 27213 ); /* *3.321928 in Q13 -> Q23 */
- L_tmp = L_shr( L_tmp, 7 ); /* From Q23 to Q16 */
- frac = L_Extract_lc( L_tmp, &exp_gcode0 ); /* Extract exponent of gcode0 */
-
- gcode0_fx = extract_l( Pow2( 14, frac ) ); /* Put 14 as exponent so that */
- /* output of Pow2() will be: */
- /* 16384 < Pow2() <= 32767 */
- exp_gcode0 = sub( exp_gcode0, 14 );
-
- /* retrieve the codebook index and calculate both gains */
- index = (Word16) get_next_indice_fx( st_fx, nBits ); /*Q0*/
- move16();
-
- *gain_pit_fx = cdbk_fx[index * 2]; /*Q14*/
- move16();
-
- L_tmp = L_mult( cdbk_fx[( ( index * 2 ) + 1 )], gcode0_fx ); /* Q9*Q0 -> Q10 */
- *gain_code_fx = L_shl_sat( L_tmp, add( exp_gcode0, 6 ) ); /*Q16*/
- move16();
-
- gc_mem[1] = *gain_code_fx; /*Q16*/
- move32();
- gp_mem[1] = *gain_pit_fx; /*Q14*/
- move16();
- }
- ELSE IF( EQ_16( i_subfr, 2 * L_SUBFR ) )
- {
- b_fx = b_3sfr_fx;
- move16();
- n_pred = 6;
- move16();
-
- cdbk_fx = gp_gamma_3sfr_6b_fx; /*Q14/Q9 */
-
- if ( EQ_16( nBits, 7 ) )
- {
- cdbk_fx = gp_gamma_3sfr_7b_fx; /*Q14*/
- // PMT("verify if gp_gamma_3sfr_7b_fx is correct")
- }
-
- /* calculate predicted gain */
- aux_fx[0] = 4096; /*Q12*/
- move16();
- aux_fx[1] = shl( ctype, 12 ); /*Q12*/
- move16();
-
- /*aux_fx[2] = (float)log10(gc_mem[0]);
- = log2(gc_mem[0])*log10(2);*/
- e_tmp = norm_l( gc_mem[0] );
- f_tmp = Log2_norm_lc( L_shl( gc_mem[0], e_tmp ) ); /*Q15*/
- e_tmp = sub( sub( 30, e_tmp ), 16 ); /*Q_format(gc_mem[0])=16*/
- L_tmp1 = Mpy_32_16( e_tmp, f_tmp, 9864 ); /* Q16 */
- aux_fx[2] = round_fx( L_shl( L_tmp1, 12 ) ); /* Q12 */
- move16();
-
- /*aux[3] = (float)log10(gc_mem[1]);
- = log2(gc_mem[1])*log10(2);*/
- e_tmp = norm_l( gc_mem[1] );
- f_tmp = Log2_norm_lc( L_shl( gc_mem[1], e_tmp ) ); /*Q15*/
- e_tmp = sub( sub( 30, e_tmp ), 16 ); /*Q_format(gc_mem[1])=16*/
- L_tmp1 = Mpy_32_16( e_tmp, f_tmp, 9864 ); /* Q16 */
- aux_fx[3] = round_fx( L_shl( L_tmp1, 12 ) ); /* Q12 */
- move16();
-
- aux_fx[4] = shr( gp_mem[0], 2 ); /*Q12*/
- move16();
- aux_fx[5] = shr( gp_mem[1], 2 ); /*Q12*/
- move16();
-
- /*-----------------------------------------------------------------*
- * gcode0 = pow(10.0, dotp(b, aux, n_pred)
- * = pow(2, 3.321928*dotp(b, aux, n_pred)
- *-----------------------------------------------------------------*/
- L_tmp = Dot_product( b_fx, aux_fx, n_pred ); /*Q25*/
- L_tmp = Mult_32_16( L_tmp, 27213 ); /* *3.321928 in Q13 -> Q23 */
- L_tmp = L_shr( L_tmp, 7 ); /* From Q23 to Q16 */
- frac = L_Extract_lc( L_tmp, &exp_gcode0 ); /* Extract exponent of gcode0 */
-
- gcode0_fx = extract_l( Pow2( 14, frac ) ); /* Put 14 as exponent so that */
- /* output of Pow2() will be: */
- /* 16384 < Pow2() <= 32767 */
- exp_gcode0 = sub( exp_gcode0, 14 );
-
- /* retrieve the codebook index and calculate both gains */
- index = (Word16) get_next_indice_fx( st_fx, nBits );
- move16();
-
- *gain_pit_fx = cdbk_fx[( index * 2 )]; /*Q14*/
- move16();
-
- L_tmp = L_mult( cdbk_fx[( ( index * 2 ) + 1 )], gcode0_fx ); /* Q9*Q0 -> Q10 */
- *gain_code_fx = L_shl_sat( L_tmp, add( exp_gcode0, 6 ) ); /* Q10 -> Q16*/
- move32();
- gc_mem[2] = *gain_code_fx; /*Q16*/
- move32();
- gp_mem[2] = *gain_pit_fx; /*Q14*/
- move16();
- }
- ELSE IF( EQ_16( i_subfr, 3 * L_SUBFR ) )
- {
- b_fx = b_4sfr_fx; /*Q12*/
- n_pred = 8;
- move16();
-
-
- cdbk_fx = gp_gamma_4sfr_6b_fx; /*Q14*/
-#ifdef IVAS_GAIN_MOD
- IF( EQ_16( nBits, 7 ) )
- {
- cdbk_fx = gp_gamma_4sfr_7b_fx;
- PMT( "verify if gp_gamma_4sfr_7b_fx is correct" )
- }
-#endif
-
- /* calculate predicted gain */
- aux_fx[0] = 4096; /*Q12*/
- move16();
- aux_fx[1] = shl( ctype, 12 ); /*Q12*/
- move16();
-
- /*aux[2] = (float)log10(gc_mem[0]);
- = log2(gc_mem[0])*log10(2);*/
- e_tmp = norm_l( gc_mem[0] );
- f_tmp = Log2_norm_lc( L_shl( gc_mem[0], e_tmp ) ); /*Q15*/
- e_tmp = sub( sub( 30, e_tmp ), 16 ); /*Q_format(gc_mem[0])=16*/
- L_tmp1 = Mpy_32_16( e_tmp, f_tmp, 9864 ); /* Q16 */
- aux_fx[2] = round_fx( L_shl( L_tmp1, 12 ) ); /* Q12 */
- move16();
-
- /*aux[3] = (float)log10(gc_mem[1]);
- = log2(gc_mem[1])*log10(2);*/
- e_tmp = norm_l( gc_mem[1] );
- f_tmp = Log2_norm_lc( L_shl( gc_mem[1], e_tmp ) ); /*Q15*/
- e_tmp = sub( sub( 30, e_tmp ), 16 ); /*Q_format(gc_mem[1])=16*/
- L_tmp1 = Mpy_32_16( e_tmp, f_tmp, 9864 ); /* Q16 */
- aux_fx[3] = round_fx( L_shl( L_tmp1, 12 ) ); /* Q12 */
- move16();
-
- /*aux[4] = (float)log10(gc_mem[2]);
- = log2(gc_mem[2])*log10(2);*/
- e_tmp = norm_l( gc_mem[2] );
- f_tmp = Log2_norm_lc( L_shl( gc_mem[2], e_tmp ) ); /*Q15*/
- e_tmp = sub( sub( 30, e_tmp ), 16 ); /*Q_format(gc_mem[2])=16*/
- L_tmp1 = Mpy_32_16( e_tmp, f_tmp, 9864 ); /* Q16 */
- aux_fx[4] = round_fx( L_shl( L_tmp1, 12 ) ); /* Q12 */
- move16();
-
- aux_fx[5] = shr( gp_mem[0], 2 ); /*Q12*/
- move16();
- aux_fx[6] = shr( gp_mem[1], 2 ); /*Q12*/
- move16();
- aux_fx[7] = shr( gp_mem[2], 2 ); /*Q12*/
- move16();
-
- /*-----------------------------------------------------------------*
- * gcode0 = pow(10.0, dotp(b, aux, n_pred)
- * = pow(2, 3.321928*dotp(b, aux, n_pred)
- *-----------------------------------------------------------------*/
- L_tmp = Dot_product( b_fx, aux_fx, n_pred ); /*Q25*/
- L_tmp = Mult_32_16( L_tmp, 27213 ); /* *3.321928 in Q13 -> Q23 */
- L_tmp = L_shr( L_tmp, 7 ); /* From Q23 to Q16 */
- frac = L_Extract_lc( L_tmp, &exp_gcode0 ); /* Extract exponent of gcode0 */
-
- gcode0_fx = extract_l( Pow2( 14, frac ) ); /* Put 14 as exponent so that */
- /* output of Pow2() will be: */
- /* 16384 < Pow2() <= 32767 */
- exp_gcode0 = sub( exp_gcode0, 14 );
-
- /* retrieve the codebook index and calculate both gains */
- index = (Word16) get_next_indice_fx( st_fx, nBits ); /*Q0*/
- move16();
- *gain_pit_fx = cdbk_fx[( index * 2 )]; /*Q14*/
- move16();
-
- L_tmp = L_mult( cdbk_fx[( ( index * 2 ) + 1 )], gcode0_fx ); /* Q9*Q0 -> Q10 */
- *gain_code_fx = L_shl_sat( L_tmp, add( exp_gcode0, 6 ) ); /*Q16*/
- move32();
- }
-
- /* *norm_gain_code = *gain_code / *gain_inov; */
- expg = sub( norm_s( *gain_inov_fx ), 1 );
- expg = s_max( expg, 0 );
-
- tmp_fx = div_s( shr( 8192, expg ), *gain_inov_fx ); /*Q15*/
- *norm_gain_code_fx = L_shr( Mult_32_16( *gain_code_fx, tmp_fx ), sub( 1, expg ) ); /*Q16*/
- move32();
-
- return;
-}
-#endif
-void gain_dec_lbr_ivas_fx(
- Decoder_State *st_fx, /* i/o: decoder state structure */
- const Word16 coder_type, /* i : coding type */
- const Word16 i_subfr, /* i : subframe index */
- const Word16 *code_fx, /* i : algebraic excitation Q9 */
- Word16 *gain_pit_fx, /* o : quantized pitch gain Q14*/
- Word32 *gain_code_fx, /* o : quantized codebook gain Q16*/
- Word16 *gain_inov_fx, /* o : gain of the innovation (used for normalization) Q12*/
- Word32 *norm_gain_code_fx, /* o : norm. gain of the codebook excitation Q16*/
- Word32 gc_mem[], /* i/o: gain_code from previous subframes Q16*/
- Word16 gp_mem[], /* i/o: gain_pitch from previous subframes Q14*/
- const Word16 L_subfr /* i : subfr lenght */
-)
-{
- Word16 index, nBits, n_pred, ctype;
- Word16 gcode0_fx, aux_fx[10];
- Word32 L_tmp, L_tmp1, L_tmp2;
- Word16 expg, expg2, e_tmp, exp_gcode0, f_tmp, frac, tmp_fx;
- const Word16 *b_fx, *cdbk_fx = 0;
- /* Ecode = ( dotp( code, code, L_SUBFR ) + 0.01f ) / L_SUBFR;
- *gain_inov = 1.0f / (float)sqrt(Ecode); */
- Word16 shift_L_subfr;
- shift_L_subfr = 6;
- move16(); // for *cdbk_fx
- move16();
- if ( GT_16( L_subfr, L_SUBFR ) )
- {
- shift_L_subfr = add( shift_L_subfr, 1 );
- }
- L_tmp = Dot_product12( code_fx, code_fx, L_subfr, &expg ); /*Q31 - expg*/
- expg = sub( expg, add( 18, shift_L_subfr ) ); /* exp: -18 (code in Q9), -6 (/L_SUBFR) */
-
- expg2 = expg;
- move16();
- L_tmp2 = 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_sat( L_tmp, sub( expg, 3 ) ) ); /* gain_inov in Q12 */
- move16();
-
- /*-----------------------------------------------------------------*
- * select the codebook, size and number of bits
- * set the gains searching range
- *-----------------------------------------------------------------*/
- nBits = st_fx->acelp_cfg.gains_mode[shr( i_subfr, shift_L_subfr )];
- move16();
-
- ctype = shl( sub( coder_type, 1 ), 1 );
-
/*-----------------------------------------------------------------*
* calculate prediction of gcode
* search for the best codeword
@@ -1583,24 +1213,28 @@ void lp_gain_updt_ivas_fx(
}
/*-------------------------------------------------*
- * Gain_dec_gaus_vbr
+ * gain_dec_gaus_fx()
*
* Decode gains of purely unvoiced sounds
*-------------------------------------------------*/
-Word32 gain_dec_gaus_fx( /* o : quantized codebook gain Q16 */
- Word16 index, /* i : quantization index */
- const Word16 bits, /* i : number of bits to quantize */
- const Word16 lowBound, /* i : lower bound of quantizer (dB) */
- const Word16 topBound, /* i : upper bound of quantizer (dB) */
- const Word16 inv_gain_inov, /* o : unscaled innovation gain Q12 */
- Word32 *L_norm_gain_code /* o : gain of normalized gaussian excitation Q16 */
+
+/*! r: quantized codebook gain Q16 */
+Word32 gain_dec_gaus_fx(
+ Word16 index, /* i : quantization index */
+ const Word16 bits, /* i : number of bits to quantize */
+ const Word16 lowBound, /* i : lower bound of quantizer (dB) */
+ const Word16 topBound, /* i : upper bound of quantizer (dB) */
+ const Word16 inv_gain_inov, /* o : unscaled innovation gain Q12 */
+ Word32 *L_norm_gain_code /* o : gain of normalized gaussian excitation Q16 */
)
{
Word16 stepSize, gain, expg, frac, expi, tmp_igi;
Word32 L_tmp, L_enr_q, L_gain;
Word16 stepSize_Exp;
+
stepSize_Exp = 14;
move16();
+
/*------------------------------------------------------------------------------------------*
* Quantize linearly the log E
*------------------------------------------------------------------------------------------*/
diff --git a/lib_dec/gs_dec_amr_wb_fx.c b/lib_dec/gs_dec_amr_wb_fx.c
index 65e9eaa87c777a89fa575441dfc820f571d521d5..eea37431a865aba1ec1ddcc180a859525f672e45 100644
--- a/lib_dec/gs_dec_amr_wb_fx.c
+++ b/lib_dec/gs_dec_amr_wb_fx.c
@@ -24,9 +24,6 @@
#define NORMALIZE_SPECS_Q_OUT 6
#define ENER_FX_Q_GUARD 1
-#ifdef ADD_IVAS_GS_DEC_IMPR
-#define CONTR_LIMIT 3012 to be verified for fixed point /* Threshold to allow an increase in the contribution length */
-#endif
/*-------------------------------------------------------------------*
* Local functions
*-------------------------------------------------------------------*/
@@ -34,12 +31,7 @@ static void NoiseFill_fx( Word16 *exc_diffQ_fx, Word16 *seed_tcx, const Word16 M
static void Ener_per_band_fx( const Word16 exc_diff_fx[], const Word16 exc_diff_exp, Word32 y_gain4_fx[] );
static void Apply_gain_fx( Word16 exc_diffQ_fx[], Word32 L_Ener_per_bd_iQ[], Word32 L_Ener_per_bd_yQ[], const Word16 Q_out );
static void normalize_spec_fx( Word16 fac_up_fx, Word16 fy_norm_fx[], const Word16 L_frame, const Word16 Q_out );
-static void gs_dec_amr_wb_fx( const long core_brate, Word16 *seed_tcx, const Word16 dct_in_fx[], const Word16 Q_dct_in, Word16 dct_out_fx[], Word16 Q_dct_out, const Word16 pitch_fx[], const Word16 voice_fac, const Word16 clas, const Word16 coder_type
-#ifdef ADD_IVAS_GS_DEC_IMPR
- ,
- const Word16 VeryLowRateSTflag
-#endif
-);
+static void gs_dec_amr_wb_fx( const long core_brate, Word16 *seed_tcx, const Word16 dct_in_fx[], const Word16 Q_dct_in, Word16 dct_out_fx[], Word16 Q_dct_out, const Word16 pitch_fx[], const Word16 voice_fac, const Word16 clas, const Word16 coder_type );
/*-------------------------------------------------------------------*
* NoiseFill_fx()
@@ -223,10 +215,6 @@ static void gs_dec_amr_wb_fx(
const Word16 voice_fac, /* i : gain pitch Q15*/
const Word16 clas, /* i : signal frame class Q0*/
const Word16 coder_type /* i : coder type Q0*/
-#ifdef ADD_IVAS_GS_DEC_IMPR
- ,
- const Word16 VeryLowRateSTflag /* i : Enable the noise enhancement for very low rate stereo generic mode */
-#endif
)
{
Word16 i, mDiff_len;
@@ -280,13 +268,7 @@ static void gs_dec_amr_wb_fx(
temp = Invert16( temp, &exp ); /* Q15 */
L_temp = L_mult( temp, 12800 ); /* Q15 */
L_temp = L_shl( L_temp, sub( 3, exp ) ); /* *8.0f */ /* Q15 */
-#ifdef ADD_IVAS_GS_DEC_IMPR
- test();
- test();
- IF( L_temp <= CONTR_LIMIT && ( VeryLowRateSTflag || GE_32( core_brate, ACELP_12k65 ) ) )
-#else
if ( GE_32( core_brate, ACELP_12k65 ) )
-#endif
{
L_temp = L_shl( L_temp, 1 ); /* Q16 */
}
@@ -311,16 +293,6 @@ static void gs_dec_amr_wb_fx(
mDiff_len = s_max( round_fx( L_temp ), BIN_1k2 ); /* Q0 */
-#ifdef ADD_IVAS_GS_DEC_IMPR
- IF( ( VeryLowRateSTflag && ( EQ_16( clas, VOICED_CLAS ) || EQ_16( clas, AUDIO_CLAS ) ) ) ) /* Do not apply normalization on VOICED signal in case of stereo */
- {
- Copy( dct_in_fx, exc_diffQ, L_FRAME );
-
- /* normalization of the spectrum and noise fill */
- normalize_spec_fx( 1 * 256, exc_diffQ + mDiff_len, sub( L_FRAME, mDiff_len ), NORMALIZE_SPECS_Q_OUT );
- }
- ELSE
-#endif
{
Copy( dct_in_fx, exc_diffQ_fx, mDiff_len ); /* Q_dct_in */
set16_fx( exc_diffQ_fx + mDiff_len, 0, sub( L_FRAME, mDiff_len ) );
@@ -387,10 +359,6 @@ void improv_amr_wb_gs_fx(
const Word16 Last_ener_fx, /* i : Last energy (Q8) Q0*/
const Word16 rate_switching_reset, /* i : rate switching reset flag Q0*/
const Word16 last_coder_type /* i : Last coder_type Q0*/
-#ifdef ADD_IVAS_GS_DEC_IMPR
- ,
- const Word16 VeryLowRateSTflag /* i : Enable the noise enhancement for very low rate stereo generic mode */
-#endif
)
{
Word16 i, exp_a, exp_b, exp_diff, j;
@@ -413,18 +381,10 @@ void improv_amr_wb_gs_fx(
test();
test();
test();
-#ifdef ADD_IVAS_GS_DEC_IMPR
- IF( VeryLowRateSTflag ||
- ( ( locattack == 0 && LE_32( core_brate, ACELP_12k65 ) ) &&
- ( ( LT_32( core_brate, ACELP_8k85 ) && NE_16( clas, AUDIO_CLAS ) &&
- ( EQ_16( clas, UNVOICED_CLAS ) || EQ_16( clas, VOICED_TRANSITION ) ) ) ||
- EQ_16( coder_type, INACTIVE ) ) ) )
-#else
IF( ( locattack == 0 && LE_32( core_brate, ACELP_12k65 ) ) &&
( ( LT_32( core_brate, ACELP_8k85 ) && NE_16( clas, AUDIO_CLAS ) &&
( ( clas == UNVOICED_CLAS ) || EQ_16( clas, VOICED_TRANSITION ) ) ) ||
( EQ_16( coder_type, INACTIVE ) ) ) )
-#endif
{
/*------------------------------------------------------------*
* two differents paths:
@@ -494,12 +454,7 @@ void improv_amr_wb_gs_fx(
* Go back to time domain -> Overwrite exctiation
*------------------------------------------------------------*/
edct_16fx( exc2_fx, dct_exc_in_fx, L_FRAME, 6, EVS_MONO );
- gs_dec_amr_wb_fx( core_brate, seed_tcx, dct_exc_in_fx, Q_exc2, dct_exc_out_fx, Q_exc2, pitch_buf_fx, lt_voice_fac_fx, clas, coder_type
-#ifdef ADD_IVAS_GS_DEC_IMPR
- ,
- VeryLowRateSTflag
-#endif
- );
+ gs_dec_amr_wb_fx( core_brate, seed_tcx, dct_exc_in_fx, Q_exc2, dct_exc_out_fx, Q_exc2, pitch_buf_fx, lt_voice_fac_fx, clas, coder_type );
edct_16fx( dct_exc_out_fx, exc2_fx, L_FRAME, 6, EVS_MONO );
/*------------------------------------------------------------*
diff --git a/lib_dec/gs_dec_fx.c b/lib_dec/gs_dec_fx.c
index cf0fabc7647160864d050f62946949c15a7cd602..70639810c96f45a36538bd07ca0c86d911e3e6fa 100644
--- a/lib_dec/gs_dec_fx.c
+++ b/lib_dec/gs_dec_fx.c
@@ -23,7 +23,7 @@
/* _ (Word16[]) voice_factors_fx: frame error rate Q15 */
/*--------------------------------------------------------------------------*/
/* INPUT/OUTPUT ARGUMENTS : */
-/* Decoder_State *st_fx : decoder memory structure */
+/* Decoder_State *st_fx : decoder memory structure */
/* _ (Word16[]) exc_fx : adapt. excitation exc (Q_exc) */
/* _ (Word16[]) exc2_fx : adapt. excitation/total exc (Q_exc) */
/*--------------------------------------------------------------------------*/
@@ -31,439 +31,17 @@
/* _ None */
/*==========================================================================*/
-#ifndef REMOVE_EVS_DUPLICATES
void decod_audio_fx(
- Decoder_State *st_fx, /* i/o: decoder static memory */
- Word16 dct_epit[], /* o : GSC excitation in DCT domain Qx*/
- const Word16 *Aq, /* i : LP filter coefficient Q12*/
- Word16 *pitch_buf, /* o : floating pitch values for each subframe Q6*/
- Word16 *voice_factors, /* o : voicing factors Q15*/
- Word16 *exc, /* i/o: adapt. excitation exc Q_exc*/
- Word16 *exc2, /* i/o: adapt. excitation/total exc Q_exc*/
- Word16 *bwe_exc, /* o : excitation for SWB TBE Q_exc*/
- Word16 *lsf_new /* i : ISFs at the end of the frame Qx*/
- ,
- Word16 *gain_buf /*Q14*/
-)
-{
- Word16 tmp_nb_bits_tot, pit_band_idx;
- Word16 code[4 * L_SUBFR];
- Word16 Diff_len, nb_subfr, i;
- Word16 nb_frame_flg;
- Word16 Es_pred = 0;
- Word16 Len, max_len;
- Word16 gsc_attack_flag;
-
- Word16 low_pit;
- Word16 last_bin;
- Word16 nbits;
-
- Word16 exc_wo_nf[L_FRAME16k];
- GSC_DEC_HANDLE hGSCDec;
- hGSCDec = st_fx->hGSCDec;
-
-
- /*---------------------------------------------------------------*
- * Initialization
- *---------------------------------------------------------------*/
- move16(); // corresponding to initialization of Es_pred
- Diff_len = 0;
- move16();
-
- /* decode GSC attack flag (used to reduce possible pre-echo) */
- gsc_attack_flag = (Word16) get_next_indice_fx( st_fx, 1 ); /* Q0 */
- move16();
-
- /* decode GSC SWB speech flag */
- test();
- IF( st_fx->coder_type != INACTIVE && GE_32( st_fx->total_brate, ACELP_13k20 ) )
- {
- st_fx->GSC_noisy_speech = (Word16) get_next_indice_fx( st_fx, 1 ); /* Q0 */
- move16();
- }
-
- /* safety check in case of bit errors */
- test();
- test();
- IF( st_fx->GSC_noisy_speech && LT_16( st_fx->bwidth, SWB ) && st_fx->GSC_IVAS_mode == 0 )
- {
- st_fx->BER_detect = 1; /* Q0 */
- move16();
- st_fx->GSC_noisy_speech = 0; /* Q0 */
- move16();
- }
-
- /* set bit-allocation */
-#ifdef REMOVE_EVS_DUPLICATES
- config_acelp1_IVAS( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, st_fx->inactive_coder_type_flag, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, 0, 0, st_fx->idchan, st_fx->active_cnt, 0, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
-#else
- config_acelp1( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, st_fx->inactive_coder_type_flag, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, 0, 0, st_fx->idchan, st_fx->active_cnt, 0, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
-#endif
-
- /*---------------------------------------------------------------*
- * Decode energy dynamics
- *---------------------------------------------------------------*/
-
- IF( EQ_16( st_fx->GSC_noisy_speech, 1 ) )
- {
- nb_subfr = NB_SUBFR; /* Q0 */
- move16();
- hGSCDec->cor_strong_limit = 0;
- move16();
- hGSCDec->noise_lev = NOISE_LEVEL_SP3; /* Q0 */
- move16();
- }
- ELSE
- {
- IF( LE_32( st_fx->core_brate, ACELP_8k00 ) )
- {
- hGSCDec->noise_lev = add( (Word16) get_next_indice_fx( st_fx, 2 ), NOISE_LEVEL_SP2 ); /* Q0 */
- move16();
- }
- ELSE
- {
- hGSCDec->noise_lev = add( (Word16) get_next_indice_fx( st_fx, 3 ), NOISE_LEVEL_SP0 ); /* Q0 */
- move16();
- }
-
- /*---------------------------------------------------------------*
- * Decode number of subframes
- *---------------------------------------------------------------*/
-
-
- hGSCDec->cor_strong_limit = 1; /* Q0 */
- move16();
- nb_subfr = SWNB_SUBFR;
- move16();
-
- IF( GE_32( st_fx->core_brate, ACELP_9k60 ) )
- {
- nbits = 1;
- move16();
- nb_frame_flg = (Word16) get_next_indice_fx( st_fx, nbits ); /* Q0 */
- move16();
-
- IF( s_and( nb_frame_flg, 0x1 ) == 0 )
- {
- nb_subfr = 2 * SWNB_SUBFR; /* Q0 */
- move16();
- hGSCDec->cor_strong_limit = 0;
- move16();
- }
- }
- }
-
- /*---------------------------------------------------------------*
- * Decode the last band where the adaptive (pitch) contribution is significant
- *---------------------------------------------------------------*/
-
- IF( LT_32( st_fx->core_brate, CFREQ_BITRATE ) )
- {
- nbits = 3; /* Q0 */
- move16();
- test();
- if ( LT_32( st_fx->core_brate, ACELP_9k60 ) && st_fx->coder_type == INACTIVE )
- {
- nbits = 1; /* Q0 */
- move16();
- }
- }
- ELSE
- {
- nbits = 4; /* Q0 */
- move16();
- }
- test();
- IF( LT_32( st_fx->core_brate, ACELP_9k60 ) && st_fx->coder_type != INACTIVE )
- {
- pit_band_idx = 1; /* Q0 */
- move16();
- }
- ELSE
- {
- pit_band_idx = (Word16) get_next_indice_fx( st_fx, nbits ); /* Q0 */
- move16();
- }
-
- IF( pit_band_idx != 0 )
- {
- IF( LT_32( st_fx->core_brate, ACELP_9k60 ) )
- {
- pit_band_idx = 7 + BAND1k2; /* Q0 */
- move16(); /* At low rate, if pitch model is chosen, then for to be use on extented and constant frequency range */
- }
- ELSE
- {
- pit_band_idx = add( pit_band_idx, BAND1k2 ); /* Q0 */
- }
-
- /* detect bit errors in the bitstream */
- IF( GT_16( pit_band_idx, 13 ) ) /* The maximum decodable index is 10 + BAND1k2 (3) = 13 */
- {
- pit_band_idx = 13; /* Q0 */
- move16();
- st_fx->BER_detect = 1; /* Q0 */
- move16();
- }
- Diff_len = mfreq_loc_div_25[pit_band_idx]; /* Q0 */
- move16();
- }
- hGSCDec->Last_GSC_pit_band_idx = pit_band_idx; /* Q0 */
- move16();
-
-
- /*--------------------------------------------------------------------------------------*
- * Decode adaptive (pitch) excitation contribution
- * Reset unvaluable part of the adaptive (pitch) excitation contribution
- *--------------------------------------------------------------------------------------*/
- IF( GT_16( pit_band_idx, BAND1k2 ) )
- {
- /*---------------------------------------------------------------*
- * Decode adaptive (pitch) excitation contribution
- *---------------------------------------------------------------*/
- test();
- IF( EQ_16( st_fx->GSC_noisy_speech, 1 ) && EQ_16( nb_subfr, NB_SUBFR ) )
- {
- Word16 indice;
- nbits = Es_pred_bits_tbl[BIT_ALLOC_IDX_fx( st_fx->core_brate, GENERIC, -1, -1 )]; /* Q0 */
- move16();
- if ( st_fx->element_mode > EVS_MONO )
- {
- nbits = 5;
- move16();
- }
-
- indice = get_next_indice_fx( st_fx, nbits ); /* Q0 */
-
- Es_pred_dec_fx( &Es_pred, indice, nbits, 0 );
- }
-
- dec_pit_exc_fx( st_fx, Aq, st_fx->coder_type, Es_pred, pitch_buf, code, exc, bwe_exc, nb_subfr, gain_buf );
-
- IF( LT_32( st_fx->core_brate, ACELP_9k60 ) )
- {
- minimum_fx( pitch_buf, shr( st_fx->L_frame, 6 ), &low_pit );
- low_pit = shr( low_pit, 6 ); /*Q6 -> Q0 */
-
- IF( LT_16( low_pit, 64 ) )
- {
- pit_band_idx = 9 + BAND1k2; /* Q0 */
- move16();
- if ( st_fx->bwidth == NB )
- {
- pit_band_idx = 7 + BAND1k2; /* Q0 */
- move16();
- }
- }
- ELSE IF( LT_16( low_pit, 128 ) )
- {
- pit_band_idx = 5 + BAND1k2; /* Q0 */
- move16();
- }
- ELSE
- {
- pit_band_idx = 3 + BAND1k2; /* Q0 */
- move16();
- }
-
- Diff_len = mfreq_loc_div_25[pit_band_idx]; /* Q0 */
- move16();
- hGSCDec->Last_GSC_pit_band_idx = pit_band_idx; /* Q0 */
- move16();
- }
-
- /*---------------------------------------------------------------*
- * DCT transform
- *---------------------------------------------------------------*/
- edct_16fx( exc, dct_epit, st_fx->L_frame, 7, st_fx->element_mode );
-
- /*---------------------------------------------------------------*
- * Reset unvaluable part of the adaptive (pitch) excitation contribution
- *---------------------------------------------------------------*/
-
- max_len = sub( st_fx->L_frame, Diff_len ); /* Q0 */
-
- if ( st_fx->bwidth == NB )
- {
- max_len = sub( 160, Diff_len ); /* Q0 */
- }
-
- Len = 80;
- move16();
- if ( LT_16( max_len, 80 ) )
- {
- Len = max_len; /* Q0 */
- move16();
- }
-
- test();
- IF( EQ_32( st_fx->core_brate, ACELP_8k00 ) && NE_16( st_fx->bwidth, NB ) )
- {
- FOR( i = 0; i < max_len; i++ )
- {
- dct_epit[i + Diff_len] = 0;
- move16();
- }
- }
- ELSE
- {
- FOR( i = 0; i < Len; i++ )
- {
- dct_epit[i + Diff_len] = mult_r( dct_epit[i + Diff_len], sm_table_fx[i] ); /* Qx */
- move16();
- }
-
- FOR( ; i < max_len; i++ )
- {
- dct_epit[i + Diff_len] = 0;
- move16();
- }
- }
- // PMT("in the rare case of 4 subfr, bfi_pitch_fx might be wrong")
- st_fx->bfi_pitch_fx = mean_fx( pitch_buf, nb_subfr ); /* Q6 */
- move16();
- st_fx->bfi_pitch_frame = st_fx->L_frame; /* Q0 */
- move16();
-
- Diff_len = add( Diff_len, 1 ); /* Q0 */
- st_fx->bpf_off = 0;
- move16();
- }
- ELSE
- {
- /* No adaptive (pitch) excitation contribution */
- st_fx->bpf_off = 1; /* Q0 */
- move16();
- set16_fx( dct_epit, 0, st_fx->L_frame );
-
- IF( EQ_16( st_fx->L_frame, L_FRAME16k ) )
- {
- set16_fx( pitch_buf, L_SUBFR16k * 64, NB_SUBFR16k );
- }
- ELSE
- {
- set16_fx( pitch_buf, L_SUBFR * 64, NB_SUBFR );
- }
-
- set16_fx( gain_buf, 0, NB_SUBFR16k );
-
- st_fx->bfi_pitch_fx = L_SUBFR * 64;
- move16();
- st_fx->bfi_pitch_frame = st_fx->L_frame; /* Q0 */
- move16();
- st_fx->lp_gainp_fx = 0;
- move16();
- st_fx->lp_gainc_fx = 0;
- move16();
- st_fx->tilt_code_fx = 0;
- move16();
- pit_band_idx = 0;
- move16();
- Diff_len = 0;
- move16();
- }
-
- /*--------------------------------------------------------------------------------------*
- * GSC decoder
- *--------------------------------------------------------------------------------------*/
-
- /* find the current total number of bits used */
-
- tmp_nb_bits_tot = st_fx->next_bit_pos; /* Q0 */
- move16();
-
- if ( st_fx->extl_brate > 0 )
- {
- /* subtract 1 bit for TBE/BWE BWE flag (bit counted in extl_brate) */
- tmp_nb_bits_tot = sub( tmp_nb_bits_tot, 1 ); /* Q0 */
- }
-
- test();
- if ( st_fx->coder_type == INACTIVE && LE_32( st_fx->core_brate, ACELP_9k60 ) )
- {
- tmp_nb_bits_tot = add( tmp_nb_bits_tot, 5 ); /* Q0 */
- }
-
- gsc_dec_fx( st_fx, dct_epit, pit_band_idx, Diff_len, tmp_nb_bits_tot, nb_subfr, st_fx->coder_type, &last_bin, lsf_new, exc_wo_nf, st_fx->Q_exc );
- /*--------------------------------------------------------------------------------------*
- * iDCT transform
- *--------------------------------------------------------------------------------------*/
-
- edct_16fx( dct_epit, exc, st_fx->L_frame, 7, st_fx->element_mode );
- edct_16fx( exc_wo_nf, exc_wo_nf, st_fx->L_frame, 7, st_fx->element_mode );
- /*----------------------------------------------------------------------*
- * Remove potential pre-echo in case an onset has been detected
- *----------------------------------------------------------------------*/
-
- pre_echo_att_fx( &hGSCDec->Last_frame_ener_fx, exc, gsc_attack_flag, st_fx->Q_exc, st_fx->last_coder_type, st_fx->L_frame );
-
- /*--------------------------------------------------------------------------------------*
- * Update BWE excitation
- *--------------------------------------------------------------------------------------*/
-
- IF( st_fx->hBWE_TD != NULL )
- {
- set16_fx( voice_factors, 0, NB_SUBFR16k );
- IF( EQ_16( st_fx->L_frame, L_FRAME16k ) )
- {
- interp_code_4over2_fx( exc, bwe_exc, st_fx->L_frame );
- }
- ELSE
- {
- interp_code_5over2_fx( exc, bwe_exc, L_FRAME );
- }
- }
- /*--------------------------------------------------------------------------------------*
- * Updates
- *--------------------------------------------------------------------------------------*/
-
- Copy( exc, exc2, st_fx->L_frame ); /* Q_exc */
- Copy( exc_wo_nf, exc, st_fx->L_frame ); /* Q_exc */
-
- /*--------------------------------------------------------------------------------------*
- * Channel aware mode parameters
- *--------------------------------------------------------------------------------------*/
-
- set16_fx( st_fx->tilt_code_dec_fx, 0, NB_SUBFR16k );
-
- return;
-}
-
-/*=========================================================================*/
-/* FUNCTION : void decod_audio_ivas_fx(); */
-/*-------------------------------------------------------------------------*/
-/* PURPOSE : Decode audio (AC) frames */
-/*-------------------------------------------------------------------------*/
-/* INPUT ARGUMENTS : */
-/* _ (Word16[]) Aq : LP filter coefficient Q12 */
-/* _ (Word16) coder_type : coding type Q0 */
-/* _(Word16) Q_exc :Q format of excitation */
-/*-------------------------------------------------------------------------*/
-/* OUTPUT ARGUMENTS : */
-/* _ (Word16[]) pitch_buf_fx : Word16 pitch values for each subframe Q6*/
-/* _ (Word16[]) voice_factors_fx: frame error rate Q15 */
-/*--------------------------------------------------------------------------*/
-/* INPUT/OUTPUT ARGUMENTS : */
-/* Decoder_State *st_fx : decoder memory structure */
-/* _ (Word16[]) exc_fx : adapt. excitation exc (Q_exc) */
-/* _ (Word16[]) exc2_fx : adapt. excitation/total exc (Q_exc) */
-/*--------------------------------------------------------------------------*/
-/* RETURN ARGUMENTS : */
-/* _ None */
-/*==========================================================================*/
-#endif
-void decod_audio_ivas_fx(
- Decoder_State *st_fx, /* i/o: decoder static memory */
- Word16 dct_epit[], /* o : GSC excitation in DCT domain Qx*/
- const Word16 *Aq, /* i : LP filter coefficient Q12*/
- Word16 *pitch_buf, /* o : Word16 pitch values for each subframe Q6*/
- Word16 *voice_factors, /* o : voicing factors Q15*/
- Word16 *exc, /* i/o: adapt. excitation exc Q_exc*/
- Word16 *exc2, /* i/o: adapt. excitation/total exc Q_exc*/
- Word16 *bwe_exc, /* o : excitation for SWB TBE Q_exc*/
- Word16 *lsf_new /* i : ISFs at the end of the frame Qx*/
- ,
- Word16 *gain_buf, /*Q14*/
+ Decoder_State *st_fx, /* i/o: decoder static memory */
+ Word16 dct_epit[], /* o : GSC excitation in DCT domain Qx*/
+ const Word16 *Aq, /* i : LP filter coefficient Q12*/
+ Word16 *pitch_buf, /* o : Word16 pitch values for each subframe Q6*/
+ Word16 *voice_factors, /* o : voicing factors Q15*/
+ Word16 *exc, /* i/o: adapt. excitation exc Q_exc*/
+ Word16 *exc2, /* i/o: adapt. excitation/total exc Q_exc*/
+ Word16 *bwe_exc, /* o : excitation for SWB TBE Q_exc*/
+ Word16 *lsf_new, /* i : ISFs at the end of the frame Qx*/
+ Word16 *gain_buf, /* o : Word16 pitch gain for each subframe Q14*/
const Word16 tdm_lp_reuse_flag, /* i : LPC reuse flag Q0*/
const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag Q0*/
const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/
@@ -525,7 +103,7 @@ void decod_audio_ivas_fx(
}
/* set bit-allocation */
- config_acelp1_IVAS( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, st_fx->inactive_coder_type_flag, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
+ config_acelp1_fx( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, st_fx->inactive_coder_type_flag, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
/*---------------------------------------------------------------*
* Decode energy dynamics
@@ -735,7 +313,7 @@ void decod_audio_ivas_fx(
Es_pred_dec_fx( &Es_pred, indice, nbits, 0 );
}
- dec_pit_exc_ivas_fx( st_fx, Aq, st_fx->coder_type, Es_pred, pitch_buf, code, exc, bwe_exc, nb_subfr, gain_buf, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf );
+ dec_pit_exc_fx( st_fx, Aq, st_fx->coder_type, Es_pred, pitch_buf, code, exc, bwe_exc, nb_subfr, gain_buf, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf );
IF( LT_32( st_fx->core_brate, ACELP_9k60 ) )
{
@@ -894,7 +472,7 @@ void decod_audio_ivas_fx(
Word16 Q_exc_old = st_fx->Q_exc;
move16();
- gsc_dec_ivas_fx( st_fx, dct_epit, pit_band_idx, Diff_len, tmp_nb_bits_tot, nb_subfr, st_fx->coder_type, &last_bin, lsf_new, exc_wo_nf, &st_fx->Q_exc );
+ gsc_dec_fx( st_fx, dct_epit, pit_band_idx, Diff_len, tmp_nb_bits_tot, nb_subfr, st_fx->coder_type, &last_bin, lsf_new, exc_wo_nf, &st_fx->Q_exc );
IF( NE_16( Q_exc_old, st_fx->Q_exc ) )
{
@@ -976,250 +554,17 @@ void decod_audio_ivas_fx(
/* _None */
/*==========================================================================*/
-#ifndef REMOVE_EVS_DUPLICATES
void gsc_dec_fx(
- Decoder_State *st_fx, /* i/o: State structure */
- Word16 exc_dct_in[], /* i/o: dct of pitch-only excitation / total excitation Q_exc*/
- const Word16 pit_band_idx, /* i : bin position of the cut-off frequency Q0*/
- const Word16 Diff_len, /* i : Lenght of the difference signal (before pure spectral) Q0*/
- const Word16 bits_used, /* i : Number of bit used before frequency Q Q0*/
- const Word16 nb_subfr, /* i : Number of subframe considered Q0*/
- const Word16 coder_type, /* i : coding type Q0*/
- Word16 *last_bin, /* i : last bin of bit allocation Q0*/
- const Word16 *lsf_new, /* i : ISFs at the end of the frame Qx*/
- Word16 *exc_wo_nf, /* o : excitation (in f domain) without noisefill Q_exc*/
- Word16 Q_exc )
-{
- Word16 i, j, bit, nb_subbands, pvq_len;
- Word16 bitallocation_band[MBANDS_GN_BITALLOC16k];
- Word16 bitallocation_exc[2];
- Word16 Ener_per_bd_iQ[MBANDS_GN_BITALLOC16k];
- Word16 max_ener_band[MBANDS_GN_BITALLOC16k];
- Word16 exc_diffQ[L_FRAME16k];
- Word16 bits_per_bands[MBANDS_GN_BITALLOC16k];
- Word16 concat_out[L_FRAME16k];
- Word16 inpulses_fx[NB_SFM];
- Word16 imaxpulse_fx[NB_SFM];
- Word16 mean_gain;
- Word16 Mbands_gn = 16;
- Word16 Qexc_diffQ = Q_PVQ_OUT;
- Word32 L_tmp;
- Word16 Q_tmp;
- Word16 seed_init;
- GSC_DEC_HANDLE hGSCDec;
- hGSCDec = st_fx->hGSCDec;
- move16();
- move16();
-
- move16(); // for Mbands_gn
- move16(); // for Qexc_diffQ
- set16_fx( inpulses_fx, 0, NB_SFM );
- set16_fx( imaxpulse_fx, 0, NB_SFM );
-
- /*--------------------------------------------------------------------------------------*
- * Initialization
- *--------------------------------------------------------------------------------------*/
- bit = bits_used;
- move16();
-
- set16_fx( exc_diffQ, 0, st_fx->L_frame );
-
- /*--------------------------------------------------------------------------------------*
- * Gain decoding
- *--------------------------------------------------------------------------------------*/
-
- test();
- IF( st_fx->bfi || st_fx->BER_detect )
- {
- /* copy old gain */
- Copy( hGSCDec->old_y_gain_fx, Ener_per_bd_iQ, Mbands_gn ); /* Q_old_gain */
- mean_gain = mult_r( st_fx->lp_gainc_fx, 3277 ); /*Q3*/
- FOR( i = 0; i < Mbands_gn; i++ )
- {
- Ener_per_bd_iQ[i] = add( Ener_per_bd_iQ[i], shl( mean_gain, 9 ) ); /*Q12*/
- move16();
- }
-
- st_fx->lp_gainc_fx = mult_r( st_fx->lp_gainc_fx, 32112 ); /*Q3*/
- move16();
- }
- ELSE
- {
- mean_gain = gsc_gaindec_fx( st_fx, Ener_per_bd_iQ, st_fx->core_brate, hGSCDec->old_y_gain_fx, coder_type, st_fx->bwidth ); /* Q12 */
-
- st_fx->lp_gainc_fx = mult_r( 640, mean_gain ); /*10 in Q6 x Q12 -> lp_gainc in Q3 */
- move16();
- }
-
- *last_bin = 0;
- move16();
- test();
- IF( EQ_32( st_fx->core_brate, ACELP_8k00 ) && st_fx->bwidth != NB )
- {
- bitallocation_exc[0] = 0;
- move16();
- bitallocation_exc[1] = 0;
- move16();
- }
-
- set16_fx( bitallocation_band, 0, MBANDS_GN );
-
- test();
- IF( ( EQ_16( st_fx->bfi, 1 ) ) || st_fx->BER_detect )
- {
- /*--------------------------------------------------------------------------------------*
- * Copy old spectrum
- * reduce spectral dynamic
- * save spectrum
- *--------------------------------------------------------------------------------------*/
-
- test();
- IF( EQ_16( st_fx->last_good, INACTIVE_CLAS ) || EQ_16( st_fx->Last_GSC_noisy_speech_flag, 1 ) )
- {
- FOR( i = 0; i < st_fx->L_frame; i++ )
- {
- L_tmp = L_shr( L_mult( Random( &hGSCDec->seed_tcx ), 26214 ), 5 ); /*Q10*/
- L_tmp = L_mac( L_tmp, hGSCDec->Last_GSC_spectrum_fx[i], 6554 ); /* Q10 */
- hGSCDec->Last_GSC_spectrum_fx[i] = round_fx( L_tmp ); /*Q10*/
- move16();
- }
- }
-
- Copy( hGSCDec->Last_GSC_spectrum_fx, exc_diffQ, st_fx->L_frame ); /* Q10 */
-
- FOR( i = 0; i < st_fx->L_frame; i++ )
- {
- hGSCDec->Last_GSC_spectrum_fx[i] = mult_r( hGSCDec->Last_GSC_spectrum_fx[i], 24576 ); /*Q10*/
- move16();
- }
- }
- ELSE
- {
- /*--------------------------------------------------------------------------------------*
- * PVQ decoder
- *--------------------------------------------------------------------------------------*/
-
- bands_and_bit_alloc_fx( hGSCDec->cor_strong_limit, hGSCDec->noise_lev, st_fx->core_brate, Diff_len, bit, &bit, Ener_per_bd_iQ,
- max_ener_band, bits_per_bands, &nb_subbands, NULL, NULL, &pvq_len, coder_type, st_fx->bwidth, st_fx->GSC_noisy_speech,
- st_fx->L_frame, st_fx->element_mode, st_fx->GSC_IVAS_mode );
-
- {
- pvq_core_dec_fx( st_fx, gsc_sfm_start, gsc_sfm_end, gsc_sfm_size, concat_out, &Q_tmp, bit, nb_subbands, bits_per_bands, NULL, inpulses_fx, imaxpulse_fx, ACELP_CORE );
- Scale_sig( concat_out, gsc_sfm_end[nb_subbands - 1], sub( Q_PVQ_OUT, Q_tmp ) ); /* Q_PVQ_OUT */
- }
- seed_init = 0;
- move16();
-
- /* Reorder Q bands */
- FOR( j = 0; j < nb_subbands; j++ )
- {
- Copy( concat_out + shl( j, 4 ), exc_diffQ + shl( max_ener_band[j], 4 ), 16 ); /* Q_PVQ_OUT */
-
- *last_bin = s_max( *last_bin, max_ener_band[j] ); /* Q0 */
- move16();
-
- bitallocation_band[max_ener_band[j]] = 1; /* Q0 */
- move16();
-
- seed_init = add( seed_init, inpulses_fx[j] ); /* Q0 */
- }
- test();
- IF( NE_16( st_fx->last_coder_type, AUDIO ) /* First audio frame */
- && NE_16( st_fx->last_coder_type, UNVOICED ) ) /* last_coder_type == INACTIVE is overwritten in update_dec to UNVOICED */
- {
- FOR( j = 0; j < nb_subbands * 16; j++ )
- {
- IF( concat_out[j] > 0 )
- {
- seed_init = extract_l( L_shl( seed_init, 3 ) ); /* Q0 */
- }
- if ( concat_out[j] < 0 )
- {
- seed_init = add( seed_init, 3 ); /* Q0 */
- move16();
- }
- }
-
- hGSCDec->seed_tcx = seed_init; /* Q0 */
- move16();
- }
- test();
- IF( EQ_32( st_fx->core_brate, ACELP_8k00 ) && st_fx->bwidth != NB )
- {
- if ( exc_diffQ[L_FRAME8k - 2] != 0 )
- {
- bitallocation_exc[0] = 1; /* Q0 */
- move16();
- }
-
- if ( exc_diffQ[L_FRAME8k - 1] != 0 )
- {
- bitallocation_exc[1] = 1; /* Q0 */
- move16();
- }
- }
-
- Copy( exc_diffQ, hGSCDec->Last_GSC_spectrum_fx, st_fx->L_frame ); /* Q_PVQ_OUT */
-
- /*--------------------------------------------------------------------------------------*
- * Skip adaptive (pitch) contribution frequency band (no noise added over the time contribution)
- * Find x pulses between 1.6-3.2kHz to code in the spectrum of the residual signal
- * Gain is based on the inter-correlation gain between the pulses found and residual signal
- *--------------------------------------------------------------------------------------*/
-
- freq_dnw_scaling_fx( hGSCDec->cor_strong_limit, st_fx->coder_type, hGSCDec->noise_lev, st_fx->core_brate, exc_diffQ, Qexc_diffQ, st_fx->L_frame );
- }
-
- /*--------------------------------------------------------------------------------------*
- * Estimate noise level
- *--------------------------------------------------------------------------------------*/
-
- highband_exc_dct_in_fx( st_fx->core_brate, mfreq_bindiv_loc, *last_bin, Diff_len, hGSCDec->noise_lev, pit_band_idx, exc_diffQ,
- &hGSCDec->seed_tcx, Ener_per_bd_iQ, nb_subfr, exc_dct_in, st_fx->last_coder_type, bitallocation_band, lsf_new,
- hGSCDec->last_exc_dct_in_fx, &hGSCDec->last_ener_fx, hGSCDec->last_bitallocation_band, bitallocation_exc, st_fx->bfi, coder_type,
- st_fx->bwidth, exc_wo_nf, Qexc_diffQ, Q_exc, st_fx->GSC_noisy_speech, hGSCDec->lt_ener_per_band_fx, st_fx->L_frame, st_fx->element_mode, st_fx->GSC_IVAS_mode );
-
- exc_dct_in[0] = 0;
- move16();
-
- return;
-}
-
-/*==========================================================================*/
-/* FUNCTION : void gsc_dec_ivas_fx () */
-/*--------------------------------------------------------------------------*/
-/* PURPOSE : Generic audio signal decoder */
-/*--------------------------------------------------------------------------*/
-/* INPUT ARGUMENTS : */
-/* _ (Word16) pit_band_idx : bin position of the cut-off frequency Q0 */
-/* _ (Word16) Diff_len : Lenght of the difference signal Q0 */
-/* _ (Word16) coder_type : coding type Q0 */
-/* _ (Word16) bits_used : Number of bit used before frequency Q Q0 */
-/* _ (Word16) nb_subfr : Number of subframe considered Q0 */
-/* _ (Word16) Qexc : Q format of exc_dct_in */
-/*--------------------------------------------------------------------------*/
-/* OUTPUT ARGUMENTS : */
-/* _ None */
-/*--------------------------------------------------------------------------*/
-/* INPUT/OUTPUT ARGUMENTS : */
-/* Decoder_State *st_fx:Decoder State Structure */
-/* _ (Word16[]) exc_dct_in : dctof pitch-only excitation / total excitation Qexc*/
-/*--------------------------------------------------------------------------*/
-/* RETURN ARGUMENTS : */
-/* _None */
-/*==========================================================================*/
-#endif
-void gsc_dec_ivas_fx(
- Decoder_State *st_fx, /* i/o: State structure */
- Word16 exc_dct_in[], /* i/o: dct of pitch-only excitation / total excitation Q_exc*/
+ Decoder_State *st_fx, /* i/o: State structure */
+ Word16 exc_dct_in[], /* i/o: dct of pitch-only excitation / total excitation Q_exc*/
const Word16 pit_band_idx, /* i : bin position of the cut-off frequency ` Q0*/
const Word16 Diff_len, /* i : Lenght of the difference signal (before pure spectral) Q0*/
const Word16 bits_used, /* i : Number of bit used before frequency Q Q0*/
const Word16 nb_subfr, /* i : Number of subframe considered Q0*/
const Word16 coder_type, /* i : coding type Q0*/
Word16 *last_bin, /* i : last bin of bit allocation Q0*/
- const Word16 *lsf_new, /* i : ISFs at the end of the frame Qx*/
- Word16 *exc_wo_nf, /* o : excitation (in f domain) without noisefill Q_exc*/
+ const Word16 *lsf_new, /* i : ISFs at the end of the frame Qx*/
+ Word16 *exc_wo_nf, /* o : excitation (in f domain) without noisefill Q_exc*/
Word16 *Q_exc )
{
Word16 i, j, bit, nb_subbands, pvq_len;
@@ -1310,13 +655,11 @@ void gsc_dec_ivas_fx(
i--;
}
-#ifdef REMOVE_EVS_DUPLICATES
IF( EQ_16( st_fx->element_mode, EVS_MONO ) )
{
mean_gain = gsc_gaindec_fx( st_fx, Ener_per_bd_iQ, brate_intermed_tbl[i], hGSCDec->old_y_gain_fx, coder_type, st_fx->bwidth ); /* Q3 */
}
ELSE
-#endif
{
mean_gain = gsc_gaindec_ivas_fx( st_fx, Ener_per_bd_iQ, brate_intermed_tbl[i], hGSCDec->old_y_gain_fx, coder_type, st_fx->bwidth ); /* Q3 */
}
diff --git a/lib_dec/hf_synth_fx.c b/lib_dec/hf_synth_fx.c
index 94c7d4c6282edf47fa8278add6362ece82625d00..27d768f631bb7b007adeeae34f78ffe698833ad7 100644
--- a/lib_dec/hf_synth_fx.c
+++ b/lib_dec/hf_synth_fx.c
@@ -21,6 +21,7 @@
static void filt_6k_7k_scale_fx( Word16 signal[], Word16 lg, Word16 mem[], Word16 fact, Word16 exp );
static void hf_synthesis_fx( ZERO_BWE_DEC_HANDLE hBWE_zero, const Word32 core_brate, const Word16 output_subfr, const Word16 Aq[], const Word16 exc[], const Word16 Q_exc, Word16 synth[], Word16 synth16k[], const Word16 Q_syn );
+static void hf_synthesis_ivas_fx( ZERO_BWE_DEC_HANDLE hBWE_zero, const Word32 core_brate, const Word16 output_subfr, const Word16 Aq[], const Word16 exc[], const Word16 Q_exc, Word16 synth[], Word16 synth16k[], const Word16 Q_syn );
static void hf_synthesis_amr_wb_fx( const Word32 core_brate, const Word16 output_subfr, const Word16 Ap[], Word16 exc16k[], Word16 synth_out[], Word16 *mem_syn_hf, Word16 *delay_syn_hf, Word16 *mem_hp_interp, Word16 p_r, Word16 HF_corr_gain, Word16 til, Word16 voice_factors, const Word16 exc[], const Word16 Q_exc, const Word16 Q_out, Word16 qhf );
static void envelope_fx( AMRWB_IO_DEC_HANDLE hAmrwb_IO, const Word32 core_brate, const Word16 Aq[], Word16 Ap[], Word16 *r, Word16 tilt0, Word16 tilt, Word16 voice_factor );
static void AdaptiveStartBand_fx( Word16 *start_band, const Word32 rate, const Word16 *lsf, const Word16 voicing_fac, const Word16 clas, Word16 *voicing_flag, Word16 *start_band_old, Word32 *OptCrit_old );
@@ -182,11 +183,7 @@ static void hf_synthesis_fx(
* calculate energy scaling factor to respect tilt of synth12k8
* (tilt: 1=voiced, -1=unvoiced)
*-----------------------------------------------------------------*/
-#ifdef EVS_MONO
hp400_12k8_fx( synth, L_SUBFR, hBWE_zero->mem_hp400_fx );
-#else
- hp400_12k8_ivas_fx( synth, L_SUBFR, hBWE_zero->mem_hp400_fx );
-#endif
/* i: mem_hp400 in Q_syn */
/* i: synth in Q_syn */
/* o: synth in Q_syn-3 */
@@ -295,7 +292,213 @@ static void hf_synthesis_fx(
{
Copy( HF_syn, upsampled_HF_syn, L_SUBFR16k ); /* Q_syn */
}
+ Vr_add( synth16k, upsampled_HF_syn, synth16k, output_subfr );
+
+ return;
+}
+
+void hf_synth_ivas_fx(
+ ZERO_BWE_DEC_HANDLE hBWE_zero, /* i/o: handle to 0 bit BWE parameters */
+ const Word32 core_brate, /* i : core bitrate Q0*/
+ const Word16 output_frame, /* i : output frame length Q0*/
+ const Word16 *Aq, /* i : quantized Az Q12*/
+ const Word16 *exc, /* i : excitation at 12.8 kHz Q_exc*/
+ Word16 *synth, /* i : 12.8kHz synthesis signal Q_syn2*/
+ Word16 *synth16k, /* o : 16kHz synthesis signal Q_syn2*/
+ const Word16 Q_exc, /* i : excitation scaling */
+ const Word16 Q_syn2 /* i : synthesis scaling */
+)
+{
+ const Word16 *p_Aq;
+ Word16 i_subfr, output_subfr;
+
+ output_subfr = shr( output_frame, 2 );
+
+ p_Aq = Aq; /* Q12 */
+ FOR( i_subfr = 0; i_subfr < L_FRAME; i_subfr += L_SUBFR )
+ {
+ hf_synthesis_ivas_fx( hBWE_zero, core_brate, output_subfr, p_Aq, &exc[i_subfr], Q_exc, &synth[i_subfr], &synth16k[i_subfr * output_subfr / L_SUBFR], Q_syn2 );
+
+ p_Aq += ( M + 1 ); /* Q12 */
+ }
+
+ return;
+}
+
+static void hf_synthesis_ivas_fx(
+ ZERO_BWE_DEC_HANDLE hBWE_zero,
+ const Word32 core_brate, /* i : core bitrate Q0*/
+ const Word16 output_subfr, /* i : output sub-frame length Q0*/
+ const Word16 Aq[], /* i : quantized Az Q12*/
+ const Word16 exc[], /* i : excitation at 12.8 kHz Q_exc*/
+ const Word16 Q_exc, /* i : excitation scaling */
+ Word16 synth[], /* i : 12.8kHz synthesis signal Q_syn*/
+ Word16 synth16k[], /* i/o: 16kHz synthesis signal Q_syn*/
+ const Word16 Q_syn /* i : synthesis scaling */
+)
+{
+ Word16 i, s;
+ Word16 HF_syn[L_SUBFR16k], upsampled_HF_syn[L_FRAME48k / NB_SUBFR];
+ Word16 HF_exc[L_SUBFR16k];
+ Word16 exp1, exp2, scale, tmp, ener, Q_tmp, Q_ener, sft;
+ Word32 L_tmp, ONE, P_ONE;
+ Word16 Ap[M16k + 1];
+ Word64 prod;
+
+ /*-----------------------------------------------------------------*
+ * generate white noise vector
+ *-----------------------------------------------------------------*/
+
+ Random_Fill( &hBWE_zero->seed2, L_SUBFR16k, HF_exc, 3 ); /* 3 = Shift Right by 3 */
+
+ /* o: HF_exc in Q(-3) */
+
+ /*-----------------------------------------------------------------*
+ * calculate energy scaling factor so that white noise would have the
+ * same energy as exc12k8
+ *-----------------------------------------------------------------*/
+
+ /*ener = sum2_f( exc, L_SUBFR ) + 0.01f*/
+ ener = extract_h( Dot_product12( exc, exc, L_SUBFR, &exp2 ) );
+ exp2 = sub( exp2, add( Q_exc, Q_exc ) ); // ener exponent
+
+ /*tmp = round_fx(Dot_product12(HF_exc, HF_exc, output_subfr, &exp1)); */
+ L_tmp = Dot_product12( HF_exc, HF_exc, L_SUBFR16k, &exp1 );
+ tmp = round_fx( L_tmp );
+ exp1 = add( exp1, 6 ); /* tmp exponent */
+
+ ener = shr( ener, 1 ); /* to avoid the assertion in div_s() further*/
+ exp2 = add( exp2, 1 );
+
+ tmp = div_s( ener, tmp );
+ exp1 = sub( exp2, exp1 );
+
+ scale = Sqrt16( tmp, &exp1 ); /* scale exponent = exp1 */
+
+ /*-----------------------------------------------------------------*
+ * calculate energy scaling factor to respect tilt of synth12k8
+ * (tilt: 1=voiced, -1=unvoiced)
+ *-----------------------------------------------------------------*/
+
+ hp400_12k8_ivas_fx( synth, L_SUBFR, hBWE_zero->mem_hp400_fx );
+
+ /* i: mem_hp400 in Q_syn */
+ /* i: synth in Q_syn */
+ /* o: synth in Q_syn-3 */
+ prod = W_mac0_16_16( 1L, synth[0], synth[0] ); /* 2*(Q_syn-3) */
+ FOR( i = 1; i < L_SUBFR; i++ )
+ {
+ prod = W_mac0_16_16( prod, synth[i], synth[i] ); /* 2*(Q_syn-3) */
+ }
+ sft = W_norm( prod );
+ ener = extract_h( W_extract_h( W_shl( prod, sft ) ) );
+ Q_ener = sub( add( shl( sub( Q_syn, 3 ), 1 ), sft ), 48 );
+ prod = W_mac0_16_16( 1L, synth[1], synth[0] ); /* 2*(Q_syn-3) */
+ FOR( i = 2; i < L_SUBFR; i++ )
+ {
+ prod = W_mac0_16_16( prod, synth[i], synth[i - 1] ); /* 2*(Q_syn-3) */
+ }
+ sft = sub( W_norm( prod ), 1 );
+ tmp = extract_h( W_extract_h( W_shl( prod, sft ) ) );
+ Q_tmp = sub( add( shl( sub( Q_syn, 3 ), 1 ), sft ), 48 );
+
+ tmp = s_max( 0, tmp );
+ IF( tmp > 0 )
+ {
+ tmp = div_s( tmp, ener );
+ Q_tmp = add( 15, sub( Q_tmp, Q_ener ) );
+ }
+
+ /*-----------------------------------------------------------------*
+ * modify energy of white noise according to synthesis tilt
+ *-----------------------------------------------------------------*/
+ /* tmp = 1.0 - fac */
+ ONE = L_shl( 1, Q_tmp );
+ P_ONE = L_shl( 3277 /* 0.1 in Q15 */, sub( Q_tmp, 15 ) );
+ L_tmp = L_msu0( ONE, tmp, 1 );
+ test();
+ if ( core_brate == FRAME_NO_DATA || EQ_32( core_brate, SID_2k40 ) )
+ {
+ /* emphasize HF noise in CNG */
+ /*fac *= 2.0f;*/
+ L_tmp = L_add( L_tmp, L_tmp );
+ }
+ L_tmp = L_max( L_tmp, P_ONE );
+ L_tmp = L_min( L_tmp, ONE );
+
+ sft = norm_l( L_tmp );
+ L_tmp = L_shl( L_tmp, sft );
+
+ tmp = round_fx( L_tmp );
+ Q_tmp = sub( add( Q_tmp, sft ), 16 );
+
+ /*scale *= fac;*/
+ tmp = mult_r( scale, tmp ); /* Q = (15 - exp1) + Q_tmp - 15 */
+ Q_tmp = sub( Q_tmp, exp1 );
+ /*-----------------------------------------------------------------*
+ * modify HF excitation according to both calculated scaling factors
+ * high pass filtering (0.94ms of delay)
+ *-----------------------------------------------------------------*/
+
+ exp2 = sub( hBWE_zero->memExp1, exp1 );
+ hBWE_zero->memExp1 = exp1;
+ move16();
+
+ filt_6k_7k_scale_fx( HF_exc, L_SUBFR16k, hBWE_zero->mem_hf_fx, tmp, exp2 );
+ /* i: HF_exc in Q(-3) */
+ /* o: HF_exc in ((-3) + Q_tmp - 17) */
+ /* o: hBWE_zero->mem_hf_fx in Q(HF_exc)-2 */
+
+ /*-----------------------------------------------------------------*
+ * synthesis of noise: 4.8kHz..5.6kHz --> 6kHz..7kHz
+ *-----------------------------------------------------------------*/
+
+ /*weight_a( Aq, Ap, 0.6f, M );*/
+ weight_a_lc_fx( Aq, Ap, Gamma_19661_Tbl_fx, M );
+ /* o: Ap in Q14 */
+
+ Syn_filt_s( 0, Ap, M, HF_exc, HF_syn, L_SUBFR16k, hBWE_zero->mem_syn_hf_fx, 1 );
+ /* o: HF_syn in same Q as HF_exc */
+ /* o: mem_syn_hf_fx same Q as HF_syn */
+
+ Scale_sig( HF_syn, L_SUBFR16k, ( add( Q_syn, exp1 ) ) ); /* bring HF_syn to (Q_syn+exp1) */
+
+ /*-----------------------------------------------------------------*
+ * add filtered HF noise to speech synthesis
+ *-----------------------------------------------------------------*/
+
+ /* delay by 5 samples @16kHz to compensate CLDFB resampling delay (20samples) and HP filtering delay (roughly 15 samples) */
+ delay_signal_fx( HF_syn, L_SUBFR16k, hBWE_zero->delay_syn_hf_fx, NS2SA_FX2( 16000, DELAY_CLDFB_NS ) - 15 );
+
+ /* interpolate the HF synthesis */
+ IF( EQ_16( output_subfr, L_SUBFR48k ) ) /* 48kHz sampled output */
+ {
+ s = s_max( s_min( sub( s_min( Find_Max_Norm16( HF_syn, L_SUBFR16k ), Find_Max_Norm16( hBWE_zero->mem_hp_interp_fx, INTERP_3_1_MEM_LEN - 3 ) ), 3 ),
+ sub( Find_Max_Norm16( hBWE_zero->mem_hp_interp_fx + INTERP_3_1_MEM_LEN - 3, 3 ), 1 ) ),
+ 0 );
+ Scale_sig( HF_syn, L_SUBFR16k, s ); /* Q_syn+exp1+s */
+ Scale_sig( hBWE_zero->mem_hp_interp_fx, INTERP_3_1_MEM_LEN, s ); /* Qx + s */
+ interpolate_3_over_1_allpass_fx( HF_syn, L_SUBFR16k, upsampled_HF_syn, hBWE_zero->mem_hp_interp_fx );
+ Scale_sig( upsampled_HF_syn, 3 * L_SUBFR16k, -s ); /* Q_syn + exp1 + s */
+ Scale_sig( hBWE_zero->mem_hp_interp_fx, INTERP_3_1_MEM_LEN, -s ); /* Qx */
+ Scale_sig( HF_syn, L_SUBFR16k, -s ); /* Q_syn+exp1 */
+ Scale_sig( upsampled_HF_syn, L_SUBFR48k, -1 );
+ }
+ ELSE IF( EQ_16( output_subfr, L_SUBFR32k ) ) /* 32kHz sampled output */
+ {
+ s = s_max( sub( s_min( Find_Max_Norm16( HF_syn, L_SUBFR16k ), Find_Max_Norm16( hBWE_zero->mem_hp_interp_fx, 2 * ALLPASSSECTIONS_STEEP ) ), 2 ), 0 );
+ Scale_sig( HF_syn, L_SUBFR16k, s ); /* Q_syn+exp1+s */
+ Scale_sig( hBWE_zero->mem_hp_interp_fx, 2 * ALLPASSSECTIONS_STEEP, s ); /* Qx + s */
+ Interpolate_allpass_steep_fx( HF_syn, hBWE_zero->mem_hp_interp_fx, L_SUBFR16k, upsampled_HF_syn );
+ Scale_sig( upsampled_HF_syn, 2 * L_SUBFR16k, -s ); /* Q_syn + exp1 */
+ Scale_sig( hBWE_zero->mem_hp_interp_fx, 2 * ALLPASSSECTIONS_STEEP, -s ); /* Qx */
+ Scale_sig( HF_syn, L_SUBFR16k, -s ); /* Q_syn+exp1 */
+ }
+ ELSE /* 16kHz sampled output */
+ {
+ Copy( HF_syn, upsampled_HF_syn, L_SUBFR16k ); /* Q_syn */
+ }
Vr_add( synth16k, upsampled_HF_syn, synth16k, output_subfr );
return;
diff --git a/lib_dec/hq_classifier_dec_fx.c b/lib_dec/hq_classifier_dec_fx.c
index 5ff5dec58465b055c583514bb15712e079cbb800..c8dac0a0bc934199a60e6bf05c50e91235d4e3fc 100644
--- a/lib_dec/hq_classifier_dec_fx.c
+++ b/lib_dec/hq_classifier_dec_fx.c
@@ -99,17 +99,11 @@ Word16 hq_classifier_dec_fx( /* o : Consumed bits
max_brate = HQ_48k; /* Q0 */
move32();
}
-#ifndef SOLVED_COMP_ENC_DEC
test();
test();
test();
test();
IF( ( EQ_16( length, L_SPEC32k ) || EQ_16( length, L_FRAME48k ) ) && LE_32( core_brate, max_brate ) )
-#else
- /*_DIFF_FLOAT_FIX_ -> could this modification break the interoperability with EVS ?? */
- test();
- IF( ( EQ_16( length, L_SPEC32k ) || EQ_16( length, L_SPEC48k ) ) && LE_32( core_brate, max_brate ) )
-#endif
{
*hqswb_clas = get_next_indice( st_fx, 2 ); /* Q0 */
move16();
@@ -147,11 +141,7 @@ Word16 hq_classifier_dec_fx( /* o : Consumed bits
*hqswb_clas = HQ_GEN_SWB; /* Q0 */
move16();
}
-#ifndef SOLVED_COMP_ENC_DEC
ELSE IF( EQ_16( length, L_FRAME48k ) )
-#else
- ELSE IF( EQ_16( length, L_SPEC48k ) )
-#endif
{
*hqswb_clas = HQ_GEN_FB; /* Q0 */
move16();
diff --git a/lib_dec/hq_core_dec_fx.c b/lib_dec/hq_core_dec_fx.c
index 4d1ef677471054485e43ff9c2a27c3b2058f86d3..3c2cd5a8092c7c385a6916eae760689d1996e8b8 100644
--- a/lib_dec/hq_core_dec_fx.c
+++ b/lib_dec/hq_core_dec_fx.c
@@ -78,22 +78,10 @@ void hq_core_dec_fx(
/*num_bits = (short)(st->total_brate / 50); */
Mpy_32_16_ss( st_fx->total_brate, 5243, &L_tmp, &lsb ); /* 5243 is 1/50 in Q18. (0+18-15=3) */
num_bits = extract_l( L_shr( L_tmp, 3 ) ); /*Q0 */
-
-#ifdef ADD_IVAS_HQ_CODE_L_SPEC
- /* Set default spectrum length */
- L_spec = l_spec_tbl[st_fx->bwidth];
-#endif
IF( !st_fx->bfi )
{
IF( EQ_16( core_switching_flag, 1 ) )
{
-#ifdef ADD_IVAS_HQ_CODE_L_SPEC
- IF( NE_16( st_fx->element_mode, EVS_MONO ) )
- {
- L_spec = l_spec_ext_tbl[st_fx->bwidth];
- }
- ELSE
-#endif
{
core_switching_hq_prepare_dec_fx( st_fx, &num_bits, output_frame );
@@ -105,12 +93,6 @@ void hq_core_dec_fx(
}
}
}
-#ifdef ADD_IVAS_HQ_CODE
- IF( hq_recovery_flag )
- {
- acelp_plc_mdct_transition( st );
- }
-#endif
/* subtract signalling bits */
num_bits = sub( num_bits, st_fx->next_bit_pos ); /* Q0 */
@@ -145,9 +127,7 @@ void hq_core_dec_fx(
/* set inner frame (== coded bandwidth) length */
inner_frame = inner_frame_tbl[st_fx->bwidth]; /* Q0 */
move16();
-#ifndef ADD_IVAS_HQ_CODE_L_SPEC
L_spec = inner_frame; /* Q0 */
-#endif
move16();
IF( st_fx->bfi == 0 )
@@ -233,12 +213,6 @@ void hq_core_dec_fx(
move16();
}
-#ifdef ADD_IVAS_HQ_CODE
- test();
- test();
- test();
- IF( EQ_16( st_fx->element_mode, EVS_MONO ) || ( !core_switching_flag && !hq_recovery_flag ) )
-#endif
{
/* scaling (coefficients are in nominal level) */
IF( NE_16( output_frame, NORM_MDCT_FACTOR ) )
@@ -322,59 +296,6 @@ void hq_core_dec_fx(
* Overlap-add
* Pre-echo reduction
*--------------------------------------------------------------------------*/
-#ifdef ADD_IVAS_HQ_CODE
- if ( st->element_mode > EVS_MONO && ( core_switching_flag || hq_recovery_flag ) )
- {
- /* Initializations for TCX MDCT framework, to be used for switching frame */
- tcx_cfg = st->hTcxCfg;
- L_frameTCX_glob = hTcxDec->L_frameTCX;
- L_frame_glob = st->L_frame;
- L_spec = hTcxDec->L_frameTCX;
- st->fscale = sr2fscale( st->sr_core );
- fscaleFB = sr2fscale( st->output_Fs );
- encoderLookahead = ( L_LOOK_12k8 * st->fscale ) / FSCALE_DENOM;
- encoderLookaheadFB = ( L_LOOK_12k8 * fscaleFB ) / FSCALE_DENOM;
- mdctWindowLength = getMdctWindowLength( st->fscale );
- mdctWindowLengthFB = (int16_t) ( mdctWindowLength * st->output_Fs / st->sr_core );
- if ( core_switching_flag )
- {
- tcx_cfg->tcx_last_overlap_mode = TRANSITION_OVERLAP;
- tcx_cfg->tcx_curr_overlap_mode = FULL_OVERLAP;
- }
- else
- {
- tcx_cfg->tcx_last_overlap_mode = ALDO_WINDOW;
- tcx_cfg->tcx_curr_overlap_mode = ALDO_WINDOW;
- st->last_core = HQ_CORE; /* Needed to decode non-transition frame */
- }
-
- init_tcx_window_cfg( tcx_cfg, st->sr_core, st->output_Fs, st->L_frame, hTcxDec->L_frameTCX, encoderLookahead, encoderLookaheadFB, mdctWindowLength, mdctWindowLengthFB, st->element_mode );
-
- init_tcx_info( st, L_frame_glob, L_frameTCX_glob, 0, st->bfi, &tcx_offset, &tcx_offsetFB, &L_frame, &L_frameTCX, &left_rect, &L_spec );
-
- overlap = tcx_cfg->tcx_mdct_window_length;
- overlapFB = tcx_cfg->tcx_mdct_window_lengthFB;
- index = tcx_cfg->tcx_last_overlap_mode;
-
- /* LB synthesis */
- IMDCT_fx( t_audio_q, hTcxDec->syn_Overl, hTcxDec->syn_Overl_TDAC, wtda_audio, tcx_cfg->tcx_aldo_window_1_trunc, tcx_cfg->tcx_aldo_window_2, tcx_cfg->tcx_mdct_window_half, tcx_cfg->tcx_mdct_window_minimum, tcx_cfg->tcx_mdct_window_trans, tcx_cfg->tcx_mdct_window_half_length, tcx_cfg->tcx_mdct_window_min_length, index,
- MDCT_IV, left_rect, tcx_offset, overlap, L_frame, L_frameTCX, max( L_frameTCX, L_spec ) >> 1, L_frame_glob, 0, st->bfi, hHQ_core->old_outLB, 0, st, 0, acelp_zir );
-
- mvr2r( wtda_audio + ( overlap >> 1 ) - tcx_offset, output, L_frame_glob );
-
- /* FB synthesis */
- IMDCT_fx( t_audio_q, hTcxDec->syn_OverlFB, hTcxDec->syn_Overl_TDACFB, wtda_audio, tcx_cfg->tcx_aldo_window_1_FB_trunc, tcx_cfg->tcx_aldo_window_2_FB, tcx_cfg->tcx_mdct_window_halfFB, tcx_cfg->tcx_mdct_window_minimumFB, tcx_cfg->tcx_mdct_window_transFB, tcx_cfg->tcx_mdct_window_half_lengthFB, tcx_cfg->tcx_mdct_window_min_lengthFB, index,
- MDCT_IV, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, max( L_frameTCX, L_spec ) >> 1, L_frameTCX_glob, 0, st->bfi, hHQ_core->old_out, 1, st, FSCALE_DENOM * L_frameTCX_glob / L_frame_glob, acelp_zir );
-
- mvr2r( wtda_audio + ( overlapFB >> 1 ) - tcx_offsetFB, synth, L_frameTCX_glob );
-
- if ( !core_switching_flag )
- {
- st->last_core = ACELP_CORE; /* Restore last core */
- }
- }
- else
-#endif
{
test();
IF( EQ_16( output_frame, L_FRAME8k ) || st_fx->bfi == 0 )
@@ -392,24 +313,6 @@ void hq_core_dec_fx(
move16();
}
}
-#ifdef ADD_IVAS_HQ_CODE
- if ( st->element_mode > EVS_MONO )
- {
- if ( st->bfi )
- {
- /* Rough resampling, but reduces energy loss in case of switch to ACELP in first good frame */
- lerp( t_audio_q, wtda_audio_LB, st->L_frame, inner_frame );
- v_multc( t_audio_q, 0.5f, wtda_audio_LB, st->L_frame );
- }
- else
- {
- /* LB synthesis for potential switch to ACELP */
- ener_match = (float) sqrt( (float) st->L_frame / (float) output_frame );
- v_multc( t_audio_q, ener_match, t_audio_q, inner_frame );
- inverse_transform( t_audio_q, wtda_audio_LB, is_transient, st->L_frame, inner_frame, st->element_mode );
- }
- }
-#endif
IF( EQ_16( output_frame, L_FRAME8k ) )
{
test();
@@ -465,13 +368,6 @@ void hq_core_dec_fx(
window_ola_fx( wtda_audio, synth, Q_synth, hHQ_core->old_out_fx, &hHQ_core->Q_old_wtda, output_frame,
st_fx->hTcxCfg->tcx_last_overlap_mode, st_fx->hTcxCfg->tcx_curr_overlap_mode, st_fx->prev_bfi && !hHQ_core->ph_ecu_active, hHQ_core->oldHqVoicing, hHQ_core->oldgapsynth_fx );
}
-#ifdef ADD_IVAS_HQ_CODE
- if ( st->element_mode > EVS_MONO )
- {
- /* LB synthesis for potential switch to ACELP */
- window_ola( wtda_audio_LB, output, hHQ_core->old_outLB, L_FRAME16k, st->hTcxCfg->tcx_last_overlap_mode, st->hTcxCfg->tcx_curr_overlap_mode, st->prev_bfi && !hHQ_core->ph_ecu_active, hHQ_core->oldHqVoicing, hHQ_core->oldgapsynth );
- }
-#endif
test();
test();
IF( ( st_fx->bfi == 0 && st_fx->prev_bfi == 0 ) || !( GE_16( output_frame, L_FRAME16k ) ) )
@@ -561,13 +457,6 @@ void hq_core_dec_fx(
Copy( &st_fx->mem_pitch_gain[2], &st_fx->mem_pitch_gain[nbsubfr + 2], nbsubfr ); /* Q14 */
set16_fx( &st_fx->mem_pitch_gain[2], 0, nbsubfr );
}
-#ifdef ADD_IVAS_HQ_CODE
- /* Move LB excitation to old_exc memory in case of switch HQ->ACELP */
- if ( st->element_mode > EVS_MONO )
- {
- mvr2r( output, st->old_exc + L_EXC_MEM_DEC - st->L_frame, st->L_frame );
- }
-#endif
return;
}
diff --git a/lib_dec/hq_hr_dec_fx.c b/lib_dec/hq_hr_dec_fx.c
index 89864bc3b7f272c2c992b4f253242c0d7217b5e5..6423015bc4f8afe008e206801dc367770e8d32d8 100644
--- a/lib_dec/hq_hr_dec_fx.c
+++ b/lib_dec/hq_hr_dec_fx.c
@@ -46,7 +46,6 @@ void ivas_hq_pred_hb_bws_fx(
}
ELSE
{
- // EVS_FUNC_MODIFIED
st_fx->prev_ener_shb_fx = 0;
move16();
L_tmp = L_deposit_l( 0 );
diff --git a/lib_dec/igf_dec_fx.c b/lib_dec/igf_dec_fx.c
index 0010b94668299937580aa4295e95febfcaa76d1a..511d8a9777607d64bd9a16695bc8af931c66a99a 100644
--- a/lib_dec/igf_dec_fx.c
+++ b/lib_dec/igf_dec_fx.c
@@ -244,7 +244,7 @@ static void IGF_replaceTCXNoise_2( Word32 *in, /**< in
g = getSqrtWord32( L_mult( divide3232( totalNoiseNrg, rE ), 8192 /*1.0f / 4.0f Q15*/ ) ); // ((Q15 + Q15 + Q1) / 2) -> Q15
- g = shl( g, 1 ); // Q16
+ g = shl_sat( g, 1 ); // Q16
FOR( sb = start; sb < stop; sb++ )
{
diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_dec/ivas_binRenderer_internal_fx.c
index c05b8beb206ec94c7d38340bc9c9c80abb1b02c1..908d3b79b112063d4ed84826840d67c67317f289 100644
--- a/lib_dec/ivas_binRenderer_internal_fx.c
+++ b/lib_dec/ivas_binRenderer_internal_fx.c
@@ -54,7 +54,137 @@
*
*
*-------------------------------------------------------------------------*/
+#ifdef OPT_BIN_RENDERER_V2
+static void ivas_binRenderer_filterModule_fx(
+ Word32 out_Conv_CLDFB_real[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : real part of Binaural signals Q6 */
+ Word32 out_Conv_CLDFB_imag[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : imag part of Binaural signals Q6 */
+ Word32 CLDFB_real[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : real part of LS signals Q_curr*/
+ Word32 CLDFB_imag[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : imag part of LS signals Q_curr*/
+ const Word16 numTimeSlots, /* i : number of time slots to process */
+ BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: fastconv binaural renderer handle */
+ Word16 Q_curr )
+{
+ Word16 bandIdx, k, chIdx, tapIdx;
+ Word32 *filterStatesLeftRealPtr_fx, *filterStatesLeftImagPtr_fx;
+ Word16 Q_filterStates;
+ const Word32 *filterTapsLeftRealPtr_fx, *filterTapsLeftImagPtr_fx, *filterTapsRightRealPtr_fx, *filterTapsRightImagPtr_fx;
+ Word16 shift_q;
+ Word16 shift_q6 = sub( -29 + 6, Q_curr );
+ Q_filterStates = hBinRenderer->hBinRenConvModule->Q_filterStatesLeft;
+ move16();
+ // to be checked: feasibility with 32 bit buffers
+ Word64 Cldfb_RealBuffer_64fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES];
+ Word64 Cldfb_ImagBuffer_64fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES];
+
+ FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ )
+ {
+ set64_fx( &Cldfb_RealBuffer_64fx[0][0], 0, BINAURAL_CHANNELS * MAX_PARAM_SPATIAL_SUBFRAMES );
+ set64_fx( &Cldfb_ImagBuffer_64fx[0][0], 0, BINAURAL_CHANNELS * MAX_PARAM_SPATIAL_SUBFRAMES );
+
+ FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ )
+ {
+ filterStatesLeftRealPtr_fx = (Word32 *) &( hBinRenderer->hBinRenConvModule->filterStatesLeftReal_fx[bandIdx][chIdx][0] );
+ filterStatesLeftImagPtr_fx = (Word32 *) &( hBinRenderer->hBinRenConvModule->filterStatesLeftImag_fx[bandIdx][chIdx][0] );
+
+ filterTapsLeftRealPtr_fx = hBinRenderer->hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx]; // Q29
+ filterTapsLeftImagPtr_fx = hBinRenderer->hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx]; // Q29
+ filterTapsRightRealPtr_fx = hBinRenderer->hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx]; // Q29
+ filterTapsRightImagPtr_fx = hBinRenderer->hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx]; // Q29
+
+ FOR( k = 0; k < numTimeSlots; k++ )
+ {
+ Word64 outRealLeft_fx = 0, outRealRight_fx = 0, outImagLeft_fx = 0, outImagRight_fx = 0;
+ move64();
+ move64();
+ move64();
+ move64();
+
+ FOR( tapIdx = hBinRenderer->hBinRenConvModule->numTapsArray[bandIdx] - 1; tapIdx > 0; tapIdx-- )
+ {
+ filterStatesLeftRealPtr_fx[tapIdx] = filterStatesLeftRealPtr_fx[tapIdx - 1];
+ move32();
+ filterStatesLeftImagPtr_fx[tapIdx] = filterStatesLeftImagPtr_fx[tapIdx - 1];
+ move32();
+ Word32 neg_filterStatesLeftImagPtr_fx = L_negate( filterStatesLeftImagPtr_fx[tapIdx] );
+
+
+ outRealLeft_fx = W_mac_32_32( outRealLeft_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsLeftRealPtr_fx[tapIdx] ); // Q30 + Q_filterStates
+ outRealLeft_fx = W_mac_32_32( outRealLeft_fx, neg_filterStatesLeftImagPtr_fx, filterTapsLeftImagPtr_fx[tapIdx] ); // Q30 + Q_filterStates
+
+ outImagLeft_fx = W_mac_32_32( outImagLeft_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsLeftImagPtr_fx[tapIdx] ); // Q30 + Q_filterStates
+ outImagLeft_fx = W_mac_32_32( outImagLeft_fx, filterStatesLeftImagPtr_fx[tapIdx], filterTapsLeftRealPtr_fx[tapIdx] ); // Q30 + Q_filterStates
+
+ outRealRight_fx = W_mac_32_32( outRealRight_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsRightRealPtr_fx[tapIdx] ); // Q30 + Q_filterStates
+ outRealRight_fx = W_mac_32_32( outRealRight_fx, neg_filterStatesLeftImagPtr_fx, filterTapsRightImagPtr_fx[tapIdx] ); // Q30 + Q_filterStates
+
+ outImagRight_fx = W_mac_32_32( outImagRight_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsRightImagPtr_fx[tapIdx] ); // Q30 + Q_filterStates
+ outImagRight_fx = W_mac_32_32( outImagRight_fx, filterStatesLeftImagPtr_fx[tapIdx], filterTapsRightRealPtr_fx[tapIdx] ); // Q30 + Q_filterStates
+ }
+
+ shift_q = add( sub( Q_filterStates, Q_curr ), 1 );
+
+ IF( shift_q != 0 )
+ {
+ outRealLeft_fx = W_shr( outRealLeft_fx, shift_q ); // Q_curr + Q29
+ outImagLeft_fx = W_shr( outImagLeft_fx, shift_q ); // Q_curr + Q29
+ outRealRight_fx = W_shr( outRealRight_fx, shift_q ); // Q_curr + Q29
+ outImagRight_fx = W_shr( outImagRight_fx, shift_q ); // Q_curr + Q29
+ hBinRenderer->hBinRenConvModule->Q_filterStatesLeft = Q_curr;
+ move16();
+ }
+
+ filterStatesLeftRealPtr_fx[0] = CLDFB_real[chIdx][k][bandIdx];
+ move32();
+ filterStatesLeftImagPtr_fx[0] = CLDFB_imag[chIdx][k][bandIdx];
+ move32();
+
+
+ /* Left Real and Imag */
+
+ Word32 temp1 = L_shr( filterStatesLeftRealPtr_fx[0], 1 ); // Q_curr -1
+ Word32 temp2 = L_shr( filterStatesLeftImagPtr_fx[0], 1 ); // Q_curr -1
+ Word32 neg_temp2 = L_negate( temp2 ); // Q_curr -1
+
+
+ outRealLeft_fx = W_mac_32_32( outRealLeft_fx, temp1, filterTapsLeftRealPtr_fx[0] );
+ outRealLeft_fx = W_mac_32_32( outRealLeft_fx, neg_temp2, filterTapsLeftImagPtr_fx[0] );
+ Cldfb_RealBuffer_64fx[0][k] = W_add( Cldfb_RealBuffer_64fx[0][k], outRealLeft_fx ); // Q29 + Q_curr
+ move64();
+
+ outImagLeft_fx = W_mac_32_32( outImagLeft_fx, temp1, filterTapsLeftImagPtr_fx[0] );
+ outImagLeft_fx = W_mac_32_32( outImagLeft_fx, temp2, filterTapsLeftRealPtr_fx[0] );
+ Cldfb_ImagBuffer_64fx[0][k] = W_add( Cldfb_ImagBuffer_64fx[0][k], outImagLeft_fx ); // Q29 + Q_curr
+ move64();
+
+ /* Right Real and Imag */
+ outRealRight_fx = W_mac_32_32( outRealRight_fx, temp1, filterTapsRightRealPtr_fx[0] );
+ outRealRight_fx = W_mac_32_32( outRealRight_fx, neg_temp2, filterTapsRightImagPtr_fx[0] );
+ Cldfb_RealBuffer_64fx[1][k] = W_add( Cldfb_RealBuffer_64fx[1][k], outRealRight_fx ); // Q29 + Q_curr
+ move64();
+
+ outImagRight_fx = W_mac_32_32( outImagRight_fx, temp1, filterTapsRightImagPtr_fx[0] );
+ outImagRight_fx = W_mac_32_32( outImagRight_fx, temp2, filterTapsRightRealPtr_fx[0] );
+ Cldfb_ImagBuffer_64fx[1][k] = W_add( Cldfb_ImagBuffer_64fx[1][k], outImagRight_fx ); // Q29 + Q_curr
+ move64();
+ }
+ }
+ FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ )
+ {
+ FOR( k = 0; k < MAX_PARAM_SPATIAL_SUBFRAMES; k++ )
+ {
+ out_Conv_CLDFB_real[chIdx][k][bandIdx] = W_shl_sat_l( Cldfb_RealBuffer_64fx[chIdx][k], shift_q6 ); // Q6
+ move32();
+ out_Conv_CLDFB_imag[chIdx][k][bandIdx] = W_shl_sat_l( Cldfb_ImagBuffer_64fx[chIdx][k], shift_q6 ); // Q6
+ move32();
+ }
+ }
+ }
+
+
+ return;
+}
+#else /* OPT_BIN_RENDERER_V2 */
static void ivas_binRenderer_filterModule_fx(
Word64 out_Conv_CLDFB_real[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : real part of Binaural signals Q29 */
Word64 out_Conv_CLDFB_imag[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : imag part of Binaural signals Q29 */
@@ -164,6 +294,7 @@ static void ivas_binRenderer_filterModule_fx(
return;
}
+#endif /* OPT_BIN_RENDERER_V2 */
/*-------------------------------------------------------------------------
* ivas_binRenderer_convModuleOpen()
@@ -1482,23 +1613,29 @@ void ivas_binRenderer_fx(
)
{
Word16 chIdx, i, j, k;
+#ifndef OPT_BIN_RENDERER_V2
// to be checked: feasibility with 32 bit buffers
Word64 Cldfb_RealBuffer_Binaural_64fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX];
Word64 Cldfb_ImagBuffer_Binaural_64fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX];
+#endif /* OPT_BIN_RENDERER_V2 */
push_wmops( "fastconv_binaural_rendering" );
/* Compute Convolution */
/* memory reset for the binaural output */
+#ifndef OPT_SBA_DEC_V2_BE
FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ )
{
FOR( k = 0; k < numTimeSlots; k++ )
{
set32_fx( Cldfb_RealBuffer_Binaural_fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX );
set32_fx( Cldfb_ImagBuffer_Binaural_fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX );
+#ifndef OPT_BIN_RENDERER_V2
set64_fx( Cldfb_RealBuffer_Binaural_64fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX );
set64_fx( Cldfb_ImagBuffer_Binaural_64fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX );
+#endif /* OPT_BIN_RENDERER_V2 */
}
}
+#endif /* OPT_SBA_DEC_V2_BE */
/* Head rotation in HOA3 or CICPx */
test();
@@ -1536,6 +1673,9 @@ void ivas_binRenderer_fx(
ivas_sba2mc_cldfb_fixed( *( hBinRenderer->hInputSetup ), RealBuffer_fx, ImagBuffer_fx,
hBinRenderer->nInChannels, hBinRenderer->conv_band, numTimeSlots, hBinRenderer->hoa_dec_mtx );
}
+#ifdef OPT_BIN_RENDERER_V2
+ ivas_binRenderer_filterModule_fx( Cldfb_RealBuffer_Binaural_fx, Cldfb_ImagBuffer_Binaural_fx, RealBuffer_fx, ImagBuffer_fx, numTimeSlots, hBinRenderer, *Q_in );
+#else /* OPT_BIN_RENDERER_V2 */
ivas_binRenderer_filterModule_fx( Cldfb_RealBuffer_Binaural_64fx, Cldfb_ImagBuffer_Binaural_64fx, RealBuffer_fx, ImagBuffer_fx, numTimeSlots, hBinRenderer, *Q_in );
FOR( i = 0; i < BINAURAL_CHANNELS; i++ )
@@ -1551,6 +1691,7 @@ void ivas_binRenderer_fx(
}
}
}
+#endif /* OPT_BIN_RENDERER_V2 */
/* Obtain the binaural dmx and compute the reverb */
IF( hBinRenderer->hReverb != NULL )
{
@@ -1597,6 +1738,19 @@ void ivas_binRenderer_fx(
}
}
}
+
+#ifdef OPT_SBA_DEC_V2_BE
+ Word16 len = sub( CLDFB_NO_CHANNELS_MAX, hBinRenderer->conv_band );
+
+ FOR( k = 0; k < numTimeSlots; k++ )
+ {
+ set32_fx( &Cldfb_RealBuffer_Binaural_fx[0][k][hBinRenderer->conv_band], 0, len );
+ set32_fx( &Cldfb_RealBuffer_Binaural_fx[1][k][hBinRenderer->conv_band], 0, len );
+ set32_fx( &Cldfb_ImagBuffer_Binaural_fx[0][k][hBinRenderer->conv_band], 0, len );
+ set32_fx( &Cldfb_ImagBuffer_Binaural_fx[1][k][hBinRenderer->conv_band], 0, len );
+ }
+#endif /* OPT_SBA_DEC_V2_BE */
+
pop_wmops();
return;
}
diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c
index 38ec5b943407e373e2c2ad240e48d8987892cf30..40012175640da7963da6eb8fbda62bc83507ad23 100644
--- a/lib_dec/ivas_core_dec_fx.c
+++ b/lib_dec/ivas_core_dec_fx.c
@@ -516,7 +516,7 @@ ivas_error ivas_core_dec_fx(
Scale_sig( st->hFdCngDec->hFdCngCom->A_cng, add( M, 1 ), sub( norm_s( sub( st->hFdCngDec->hFdCngCom->A_cng[0], 1 ) ), 3 ) ); // Qx
}
- IF( NE_32( ( error = acelp_core_dec_ivas_fx( st, output_16_fx[n], synth_16_fx[n], save_hb_synth_16_fx, bwe_exc_extended_fx[n], voice_factors_fx[n], old_syn_12k8_16k_fx_16, sharpFlag[n], pitch_buf_fx[n], &unbits[n], &sid_bw[n], hStereoTD, tdm_lspQ_PCh_fx, tdm_lsfQ_PCh_fx, use_cldfb_for_dft, last_element_mode, last_element_brate, flag_sec_CNA, nchan_out, hStereoCng, read_sid_info ) ), IVAS_ERR_OK ) )
+ IF( NE_32( ( error = acelp_core_dec_fx( st, output_16_fx[n], synth_16_fx[n], save_hb_synth_16_fx, bwe_exc_extended_fx[n], voice_factors_fx[n], old_syn_12k8_16k_fx_16, sharpFlag[n], pitch_buf_fx[n], &unbits[n], &sid_bw[n], hStereoTD, tdm_lspQ_PCh_fx, tdm_lsfQ_PCh_fx, use_cldfb_for_dft, last_element_mode, last_element_brate, flag_sec_CNA, nchan_out, hStereoCng, read_sid_info ) ), IVAS_ERR_OK ) )
{
return error;
}
diff --git a/lib_dec/ivas_cpe_dec_fx.c b/lib_dec/ivas_cpe_dec_fx.c
index c10c6beda022acd7c4dbefdb47d957741647b4c4..e26a56c1bb44b72f62e6c4bd06cc37c0619618f3 100644
--- a/lib_dec/ivas_cpe_dec_fx.c
+++ b/lib_dec/ivas_cpe_dec_fx.c
@@ -1264,7 +1264,7 @@ void destroy_cpe_dec(
IF( hCPE->hStereoDft != NULL )
{
- stereo_dft_dec_destroy( &( hCPE->hStereoDft ) );
+ stereo_dft_dec_destroy_fx( &( hCPE->hStereoDft ) );
hCPE->hStereoDft = NULL;
}
diff --git a/lib_dec/ivas_dirac_dec_fx.c b/lib_dec/ivas_dirac_dec_fx.c
index 7fecb7ca7042e0d0cf4fb8ad6038c963d51f42e4..a778424dd37420b7e61fd86c88e5d6b236a8b4d0 100644
--- a/lib_dec/ivas_dirac_dec_fx.c
+++ b/lib_dec/ivas_dirac_dec_fx.c
@@ -1750,31 +1750,68 @@ void ivas_qmetadata_to_dirac_fx(
}
ELSE
{
+#ifndef OPT_SBA_DEC_PATH
Word16 tmp1, tmp4;
+#endif /* OPT_SBA_DEC_PATH */
Word16 a, b_tmp;
Word16 exp_factor = 0;
move16();
a = rand_triangular_signed_fx( seed_ptr, &exp_factor ); // q = exp_factor
+#ifndef OPT_SBA_DEC_PATH
tmp1 = mult( a, dirac_dithering_azi_scale_fx[diff_idx] ); // exp_factor + 5
Word32 tmp1_32 = L_deposit_h( tmp1 );
+#else /* OPT_SBA_DEC_PATH */
+ Word32 tmp1_32 = L_mult( a, dirac_dithering_azi_scale_fx[diff_idx] ); // exp_factor + 5
+#endif /* OPT_SBA_DEC_PATH */
Word16 final_1_exp;
- Word32 final_1_32 = BASOP_Util_Add_Mant32Exp( azimuth_fx, 9, tmp1_32, exp_factor + 5, &final_1_exp );
- b_tmp = rand_triangular_signed_fx( seed_ptr, &exp_factor ); // q = exp_factor
+ Word32 final_1_32;
+#ifndef OPT_SBA_DEC_PATH
+ final_1_32 = BASOP_Util_Add_Mant32Exp( azimuth_fx, 9, tmp1_32, add( exp_factor, 5 ), &final_1_exp );
+#else /* OPT_SBA_DEC_PATH */
+ Word16 norm_op1 = norm_l( azimuth_fx );
+ Word16 norm_op2 = norm_l( tmp1_32 );
+ Word16 op2_e = add( exp_factor, 5 );
+ final_1_exp = add( s_max( s_max( sub( 9, norm_op1 ), sub( op2_e, norm_op2 ) ), 0 ), 2 ); // 2 for headroom
+ final_1_32 = L_add( L_shr( azimuth_fx, sub( final_1_exp, 9 ) ), L_shr( tmp1_32, sub( final_1_exp, op2_e ) ) );
+
+#endif /* OPT_SBA_DEC_PATH */
+ b_tmp = rand_triangular_signed_fx( seed_ptr, &exp_factor ); // q = exp_factor
+#ifndef OPT_SBA_DEC_PATH
tmp4 = mult( b_tmp, dirac_dithering_ele_scale_fx[diff_idx] ); // exp_factor + 4
Word32 tmp4_32 = L_deposit_h( tmp4 );
- Word16 final_2_exp;
- Word32 final_2_32 = BASOP_Util_Add_Mant32Exp( elevation_fx, 9, tmp4_32, exp_factor + 4, &final_2_exp );
-
+#else /* OPT_SBA_DEC_PATH */
+ Word32 tmp4_32 = L_mult( b_tmp, dirac_dithering_ele_scale_fx[diff_idx] ); // exp_factor + 4
+#endif /* OPT_SBA_DEC_PATH */
+ Word16 final_2_exp;
+ Word32 final_2_32;
+#ifndef OPT_SBA_DEC_PATH
+ final_2_32 = BASOP_Util_Add_Mant32Exp( elevation_fx, 9, tmp4_32, add( exp_factor, 4 ), &final_2_exp );
+#else /* OPT_SBA_DEC_PATH */
+ norm_op1 = norm_l( elevation_fx );
+ norm_op2 = norm_l( tmp4_32 );
+ op2_e = add( exp_factor, 4 );
+ final_2_exp = add( s_max( s_max( sub( 9, norm_op1 ), sub( op2_e, norm_op2 ) ), 0 ), 2 ); // 2 for headroom
+ final_2_32 = L_add( L_shr( elevation_fx, sub( final_2_exp, 9 ) ), L_shr( tmp4_32, sub( final_2_exp, op2_e ) ) );
+#endif /* OPT_SBA_DEC_PATH */
+
+#ifndef OPT_SBA_DEC_PATH
final_1_32 = BASOP_Util_Add_Mant32Exp( final_1_32, final_1_exp, ONE_IN_Q30, 0, &final_1_exp ); /*0.5 in q31*/
final_2_32 = BASOP_Util_Add_Mant32Exp( final_2_32, final_2_exp, ONE_IN_Q30, 0, &final_2_exp );
azi = extract_h( L_shr( final_1_32, sub( sub( 31, final_1_exp ), 16 ) ) );
ele = extract_h( L_shr( final_2_32, sub( sub( 31, final_2_exp ), 16 ) ) );
+#else /* OPT_SBA_DEC_PATH */
+ final_1_32 = L_add( final_1_32, L_shl( 1, sub( 30, final_1_exp ) ) ); /*0.5 in q31*/
+ final_2_32 = L_add( final_2_32, L_shl( 1, sub( 30, final_2_exp ) ) );
+ azi = extract_h( L_shr( final_1_32, sub( 15, final_1_exp ) ) );
+ ele = extract_h( L_shr( final_2_32, sub( 15, final_2_exp ) ) );
+#endif /* OPT_SBA_DEC_PATH */
+
/*addition of one to compensate precision loss*/
if ( azi < 0 )
@@ -2217,25 +2254,6 @@ void ivas_dirac_dec_render_sf_fx(
move16();
move16();
-
- FOR( i = 0; i < MAX_OUTPUT_CHANNELS; i++ )
- {
- FOR( Word16 j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ )
- {
- set32_fx( Cldfb_RealBuffer_fx[i][j], 0, CLDFB_NO_CHANNELS_MAX );
- set32_fx( Cldfb_ImagBuffer_fx[i][j], 0, CLDFB_NO_CHANNELS_MAX );
- }
- }
-
- FOR( i = 0; i < BINAURAL_CHANNELS; i++ )
- {
- FOR( Word16 j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ )
- {
- set32_fx( Cldfb_RealBuffer_Binaural_fx[i][j], 0, CLDFB_NO_CHANNELS_MAX );
- set32_fx( Cldfb_RealBuffer_Binaural_fx[i][j], 0, CLDFB_NO_CHANNELS_MAX );
- }
- }
-
/* local copies of azi, ele, diffuseness */
Word16 azimuth[CLDFB_NO_CHANNELS_MAX];
Word16 elevation[CLDFB_NO_CHANNELS_MAX];
@@ -2286,6 +2304,27 @@ void ivas_dirac_dec_render_sf_fx(
push_wmops( "ivas_dirac_dec_render" );
/* Initialize aux buffers */
+
+ FOR( i = 0; i < MAX_OUTPUT_CHANNELS; i++ )
+ {
+ FOR( Word16 j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ )
+ {
+ set32_fx( Cldfb_RealBuffer_fx[i][j], 0, CLDFB_NO_CHANNELS_MAX );
+ set32_fx( Cldfb_ImagBuffer_fx[i][j], 0, CLDFB_NO_CHANNELS_MAX );
+ }
+ }
+
+#ifndef OPT_BIN_RENDERER_V2
+ FOR( i = 0; i < BINAURAL_CHANNELS; i++ )
+ {
+ FOR( Word16 j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ )
+ {
+ set32_fx( Cldfb_RealBuffer_Binaural_fx[i][j], 0, CLDFB_NO_CHANNELS_MAX );
+ set32_fx( Cldfb_ImagBuffer_Binaural_fx[i][j], 0, CLDFB_NO_CHANNELS_MAX );
+ }
+ }
+#endif /* OPT_BIN_RENDERER_V2 */
+
hDirAC = st_ivas->hDirAC;
hDirACRend = st_ivas->hDirACRend;
hSpatParamRendCom = st_ivas->hSpatParamRendCom;
@@ -3931,8 +3970,8 @@ void ivas_dirac_dec_render_sf_fx(
const Word32 azi_fx = L_shl( az1_32, Q22 - Q16 ); // Q16 -> Q22
const Word32 ele_fx = L_shl( el1_32, Q22 - Q16 ); // Q16 -> Q22
#else
- const Word32 azi_fx = L_shl( az1, Q22 ); // Q0 -> Q22
- const Word32 ele_fx = L_shl( el1, Q22 ); // Q0 -> Q22
+ const Word32 azi_fx = L_shl( az1, Q22 ); // Q0 -> Q22
+ const Word32 ele_fx = L_shl( el1, Q22 ); // Q0 -> Q22
#endif
efap_determine_gains_fx( st_ivas->hEFAPdata, st_ivas->hIsmRendererData->gains_fx[i], azi_fx, ele_fx, EFAP_MODE_EFAP );
}
@@ -3973,9 +4012,19 @@ void ivas_dirac_dec_render_sf_fx(
{
Word32 g_fx;
w2_fx = sub( MAX16B, *w1_fx );
+#ifdef OPT_BIN_RENDERER_V2
+ g_fx = Madd_32_16( Mpy_32_16_1( gain_fx, *w1_fx ), prev_gain_fx, w2_fx ); // Q15
+#else /* OPT_BIN_RENDERER_V2 */
g_fx = L_add( Mpy_32_16_1( gain_fx, *w1_fx ), Mpy_32_16_1( prev_gain_fx, w2_fx ) ); // Q15
+#endif /* OPT_BIN_RENDERER_V2 */
FOR( l = 0; l < hSpatParamRendCom->num_freq_bands; l++ )
{
+#ifdef OPT_BIN_RENDERER_V2
+ Cldfb_RealBuffer_fx[j2][0][k * hSpatParamRendCom->num_freq_bands + l] = Madd_32_32( Cldfb_RealBuffer_fx[j2][0][k * hSpatParamRendCom->num_freq_bands + l], g_fx, *tc_re_fx );
+ move32();
+ tc_re_fx++;
+ Cldfb_ImagBuffer_fx[j2][0][k * hSpatParamRendCom->num_freq_bands + l] = Madd_32_32( Cldfb_ImagBuffer_fx[j2][0][k * hSpatParamRendCom->num_freq_bands + l], g_fx, *tc_im_fx );
+#else /* OPT_BIN_RENDERER_V2 */
Word32 tmp;
tmp = Mpy_32_32( g_fx, *tc_re_fx );
Cldfb_RealBuffer_fx[j2][0][k * hSpatParamRendCom->num_freq_bands + l] = L_add( Cldfb_RealBuffer_fx[j2][0][k * hSpatParamRendCom->num_freq_bands + l], tmp );
@@ -3983,6 +4032,7 @@ void ivas_dirac_dec_render_sf_fx(
tc_re_fx++;
tmp = Mpy_32_32( g_fx, *tc_im_fx );
Cldfb_ImagBuffer_fx[j2][0][k * hSpatParamRendCom->num_freq_bands + l] = L_add( Cldfb_ImagBuffer_fx[j2][0][k * hSpatParamRendCom->num_freq_bands + l], tmp );
+#endif /* OPT_BIN_RENDERER_V2 */
move32();
tc_re_fx++;
}
@@ -4012,8 +4062,10 @@ void ivas_dirac_dec_render_sf_fx(
Cldfb_RealBuffer_Binaural_fx, Cldfb_ImagBuffer_Binaural_fx,
Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, &input_q );
+#ifndef OPT_BIN_RENDERER_V2
Scale_sig32( Cldfb_RealBuffer_Binaural_fx[0][0], i_mult( BINAURAL_CHANNELS, i_mult( MAX_PARAM_SPATIAL_SUBFRAMES, CLDFB_NO_CHANNELS_MAX ) ), sub( Q6, input_q ) ); // Q6
Scale_sig32( Cldfb_ImagBuffer_Binaural_fx[0][0], i_mult( BINAURAL_CHANNELS, i_mult( MAX_PARAM_SPATIAL_SUBFRAMES, CLDFB_NO_CHANNELS_MAX ) ), sub( Q6, input_q ) ); // Q6
+#endif /* OPT_BIN_RENDERER_V2 */
/* Inverse CLDFB*/
FOR( ch = 0; ch < st_ivas->hDecoderConfig->nchan_out; ch++ )
diff --git a/lib_dec/ivas_dirac_output_synthesis_cov_fx.c b/lib_dec/ivas_dirac_output_synthesis_cov_fx.c
index 6d367538d26d575e27d55756a9222a5c96d5c322..45c1a38a93ac453dbbf53f6875c3d183d826e340 100644
--- a/lib_dec/ivas_dirac_output_synthesis_cov_fx.c
+++ b/lib_dec/ivas_dirac_output_synthesis_cov_fx.c
@@ -30,6 +30,7 @@
*******************************************************************************************************/
+
#include
#include
#include
@@ -516,10 +517,14 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx(
Word16 mixing_matrix_buffer_e;
Word32 input_f_real_fx[PARAM_MC_MAX_TRANSPORT_CHANS];
Word32 input_f_imag_fx[PARAM_MC_MAX_TRANSPORT_CHANS];
+#ifdef MERGE_REQUEST_1564_SPEEDUP_ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx_NONBE
+
+#else
Word32 output_f_real_fx[MAX_CICP_CHANNELS];
Word32 output_f_imag_fx[MAX_CICP_CHANNELS];
Word16 output_f_real_e;
Word16 output_f_imag_e;
+#endif
Word32 diff_f_real_fx[MAX_CICP_CHANNELS];
Word32 diff_f_imag_fx[MAX_CICP_CHANNELS];
@@ -527,8 +532,12 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx(
set_zero_fx( input_f_real_fx, PARAM_MC_MAX_TRANSPORT_CHANS );
set_zero_fx( input_f_imag_fx, PARAM_MC_MAX_TRANSPORT_CHANS );
+#ifdef MERGE_REQUEST_1564_SPEEDUP_ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx_NONBE
+
+#else
set_zero_fx( output_f_real_fx, MAX_CICP_CHANNELS );
set_zero_fx( output_f_imag_fx, MAX_CICP_CHANNELS );
+#endif
set_zero_fx( diff_f_real_fx, MAX_CICP_CHANNELS );
set_zero_fx( diff_f_imag_fx, MAX_CICP_CHANNELS );
@@ -592,6 +601,44 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx(
}
/* apply residual mixing */
+#ifdef MERGE_REQUEST_1564_SPEEDUP_ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx_NONBE
+ {
+ Word16 shifter;
+#ifdef OPT_SBA_DEC_V2_BE
+ shifter = sub( mixing_matrix_res_smooth_e, 31 );
+#else /* OPT_SBA_DEC_V2_BE */
+ shifter = 31 - mixing_matrix_res_smooth_e;
+#endif /* OPT_SBA_DEC_V2_BE */
+ FOR( ch_idx = 0; ch_idx < nY; ch_idx++ )
+ {
+ int i;
+ Word16 idx;
+ Word64 temp_real, temp_imag;
+
+
+ idx = ch_idx;
+ temp_real = 0;
+ temp_imag = 0;
+ move64();
+ move64();
+ for ( i = 0; i < nY; i++ )
+ {
+ temp_real = W_add( temp_real, W_mult0_32_32( mixing_matrix_res_smooth_fx[idx], diff_f_real_fx[i] ) );
+ temp_imag = W_add( temp_imag, W_mult0_32_32( mixing_matrix_res_smooth_fx[idx], diff_f_imag_fx[i] ) );
+ idx += nY;
+ }
+#ifdef OPT_SBA_DEC_V2_BE
+ Cldfb_RealBuffer_fx[ch_idx][slot_idx_sfr][band] = W_shl_sat_l( temp_real, shifter );
+ Cldfb_ImagBuffer_fx[ch_idx][slot_idx_sfr][band] = W_shl_sat_l( temp_imag, shifter );
+#else /* OPT_SBA_DEC_V2_BE */
+ Cldfb_RealBuffer_fx[ch_idx][slot_idx_sfr][band] = W_extract_l( W_shr( temp_real, shifter ) );
+ Cldfb_ImagBuffer_fx[ch_idx][slot_idx_sfr][band] = W_extract_l( W_shr( temp_imag, shifter ) );
+#endif /* OPT_SBA_DEC_V2_BE */
+ }
+ }
+
+
+#else
matrix_product_mant_exp_fx( mixing_matrix_res_smooth_fx, mixing_matrix_res_smooth_e, nY, nY, 0, diff_f_real_fx, 25, nY, 1, 0, output_f_real_fx, &output_f_real_e );
scale_sig32( output_f_real_fx, nY, sub( Q6, sub( Q31, output_f_real_e ) ) ); // Q6
@@ -607,6 +654,7 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx(
Cldfb_ImagBuffer_fx[ch_idx][slot_idx_sfr][band] = output_f_imag_fx[ch_idx]; // Q6
move32();
}
+#endif
}
ELSE
{
@@ -630,6 +678,36 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx(
}
/* apply mixing matrix */
+#ifdef MERGE_REQUEST_1564_SPEEDUP_ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx_NONBE
+ {
+ Word16 shifter;
+ shifter = 31 - mixing_matrix_smooth_e;
+
+ FOR( ch_idx = 0; ch_idx < nY; ch_idx++ )
+ {
+ int i;
+ Word16 idx;
+ Word64 temp_real, temp_imag;
+
+
+ idx = ch_idx;
+ temp_real = 0;
+ temp_imag = 0;
+ move64();
+ move64();
+ for ( i = 0; i < nX; i++ )
+ {
+ temp_real = W_add( temp_real, W_mult0_32_32( mixing_matrix_smooth_fx[idx], input_f_real_fx[i] ) );
+ temp_imag = W_add( temp_imag, W_mult0_32_32( mixing_matrix_smooth_fx[idx], input_f_imag_fx[i] ) );
+ idx += nY;
+ }
+ Cldfb_RealBuffer_fx[ch_idx][slot_idx_sfr][band] = L_add( Cldfb_RealBuffer_fx[ch_idx][slot_idx_sfr][band], W_extract_l( W_shr( temp_real, shifter ) ) );
+ move32();
+ Cldfb_ImagBuffer_fx[ch_idx][slot_idx_sfr][band] = L_add( Cldfb_ImagBuffer_fx[ch_idx][slot_idx_sfr][band], W_extract_l( W_shr( temp_imag, shifter ) ) );
+ move32();
+ }
+ }
+#else
matrix_product_mant_exp_fx( mixing_matrix_smooth_fx, mixing_matrix_smooth_e, nY, nX, 0, input_f_real_fx, 25, nX, 1, 0, output_f_real_fx, &output_f_real_e );
scale_sig32( output_f_real_fx, MAX_CICP_CHANNELS, sub( 6, sub( 31, output_f_real_e ) ) ); // Q6
@@ -646,6 +724,7 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx(
Cldfb_ImagBuffer_fx[ch_idx][slot_idx_sfr][band] = L_add( Cldfb_ImagBuffer_fx[ch_idx][slot_idx_sfr][band], output_f_imag_fx[ch_idx] );
move32();
}
+#endif
}
}
diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c
deleted file mode 100644
index 4770d21935134204355123ad7b3105131f63fe46..0000000000000000000000000000000000000000
--- a/lib_dec/ivas_init_dec.c
+++ /dev/null
@@ -1,3255 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository. All Rights Reserved.
-
- This software is protected by copyright law and by international treaties.
- The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository retain full ownership rights in their respective contributions in
- the software. This notice grants no license of any kind, including but not limited to patent
- license, nor is any license granted by implication, estoppel or otherwise.
-
- Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
- contributions.
-
- This software is provided "AS IS", without any express or implied warranties. The software is in the
- development stage. It is intended exclusively for experts who have experience with such software and
- solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
- and fitness for a particular purpose are hereby disclaimed and excluded.
-
- Any dispute, controversy or claim arising under or in relation to providing this software shall be
- submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
- accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
- the United Nations Convention on Contracts on the International Sales of Goods.
-
-*******************************************************************************************************/
-
-#include
-#include
-#include
-#include "options.h"
-#include "ivas_cnst.h"
-#include "ivas_prot_rend_fx.h"
-#include "rom_com.h"
-#include "ivas_rom_com.h"
-#include "ivas_stat_enc.h"
-#include "prot_fx.h"
-#include "wmc_auto.h"
-#include "ivas_prot_fx.h"
-
-
-/*-------------------------------------------------------------------*
- * Local function prototypes
- *-------------------------------------------------------------------*/
-
-static ivas_error ivas_read_format( Decoder_Struct *st_ivas, Word16 *num_bits_read );
-
-static ivas_error doSanityChecks_IVAS( Decoder_Struct *st_ivas );
-
-
-/*-------------------------------------------------------------------*
- * ivas_dec_setup()
- *
- * IVAS decoder setup
- *-------------------------------------------------------------------*/
-
-ivas_error ivas_dec_setup(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
- UWord16 *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */
- Word16 *data /* o : output synthesis signal */
-)
-{
- Word16 k, idx, num_bits_read;
- Word16 nchan_ism, element_mode_flag;
- Decoder_State *st;
- Word32 ivas_total_brate;
- ivas_error error;
-
- error = IVAS_ERR_OK;
- move32();
- num_bits_read = 0;
- move16();
- element_mode_flag = 0;
- move16();
-
- ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate;
- move32();
-
- /*-------------------------------------------------------------------*
- * Read IVAS format
- *-------------------------------------------------------------------*/
-
- ivas_read_format( st_ivas, &num_bits_read );
-
- Word16 SrcInd[MAX_NUM_TDREND_CHANNELS];
- Word16 num_src = 0;
- move16();
-
- /*-------------------------------------------------------------------*
- * Read other signling (ISM/MC mode, number of channels, etc.)
- *-------------------------------------------------------------------*/
-
- IF( is_DTXrate( ivas_total_brate ) == 0 )
- {
- /*-------------------------------------------------------------------*
- * Read IVAS format related signaling:
- * - in ISM : read number of objects
- * - in SBA : read SBA planar flag and SBA order
- * - in MASA : read number of TC
- * - in MC : read LS setup
- *-------------------------------------------------------------------*/
-
- IF( EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) )
- {
- element_mode_flag = 1;
- move16();
- }
- ELSE IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) )
- {
- /* read the number of objects */
- st_ivas->nchan_transport = 1;
- move16();
- nchan_ism = 1;
- move16();
- Word32 res_dec, res_frac;
- iDiv_and_mod_32( ivas_total_brate, FRAMES_PER_SEC, &res_dec, &res_frac, 0 );
- k = extract_l( L_sub( res_dec, 1 ) );
-
- WHILE( st_ivas->bit_stream[k] && ( nchan_ism < MAX_NUM_OBJECTS ) )
- {
- nchan_ism = add( nchan_ism, 1 );
- k = sub( k, 1 );
- }
-
- st_ivas->nchan_ism = nchan_ism;
- move16();
-
- IF( NE_32( ( error = ivas_ism_dec_config_fx( st_ivas, st_ivas->ism_mode, nSamplesRendered, data ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
- ELSE IF( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) )
- {
- /* read Ambisonic (SBA) planar flag */
- st_ivas->sba_planar = st_ivas->bit_stream[num_bits_read];
- move16();
- num_bits_read = add( num_bits_read, SBA_PLANAR_BITS );
-
- /* read Ambisonic (SBA) order */
- st_ivas->sba_order = st_ivas->bit_stream[num_bits_read + 1];
- move16();
- st_ivas->sba_order = add( st_ivas->sba_order, shl( st_ivas->bit_stream[num_bits_read], 1 ) );
- move16();
- num_bits_read = add( num_bits_read, SBA_ORDER_BITS );
- test();
- test();
- IF( st_ivas->ini_frame > 0 && NE_32( ivas_total_brate, st_ivas->last_active_ivas_total_brate ) && GT_32( ivas_total_brate, IVAS_SID_5k2 ) )
- {
- IF( NE_32( ( error = ivas_sba_dec_reconfigure_fx( st_ivas, nSamplesRendered, data ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
- ELSE
- {
- /* set Ambisonic (SBA) order used for analysis and coding */
- st_ivas->sba_analysis_order = ivas_sba_get_analysis_order_fx( ivas_total_brate, st_ivas->sba_order );
- move16();
- ivas_sba_config_fx( ivas_total_brate, st_ivas->sba_analysis_order, -1, &( st_ivas->nchan_transport ), st_ivas->sba_planar, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->element_mode_init );
- }
- }
- ELSE IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) )
- {
- /* read number of MASA transport channels */
- Word32 res_dec, res_frac;
- iDiv_and_mod_32( ivas_total_brate, FRAMES_PER_SEC, &res_dec, &res_frac, 0 );
- IF( st_ivas->bit_stream[res_dec - 1] )
- {
- st_ivas->nchan_transport = 2;
- move16();
- element_mode_flag = 1;
- move16();
- }
- ELSE
- {
- st_ivas->nchan_transport = 1;
- move16();
- }
-
- IF( st_ivas->ini_frame > 0 )
- {
- /* reconfigure in case a change of operation mode is detected */
- test();
- test();
- IF( ( GT_32( ivas_total_brate, IVAS_SID_5k2 ) && NE_32( ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate ) ) || ( st_ivas->ini_active_frame == 0 ) )
- {
- IF( EQ_32( st_ivas->last_ivas_format, MASA_FORMAT ) )
- {
- test();
- test();
- test();
- IF( ( st_ivas->ini_active_frame == 0 ) && NE_32( ivas_total_brate, FRAME_NO_DATA ) && LT_32( ivas_total_brate, MASA_STEREO_MIN_BITRATE ) && EQ_16( st_ivas->nCPE, 1 ) )
- {
- st_ivas->hCPE[0]->nchan_out = 1;
- move16();
- }
- ELSE
- {
- IF( NE_32( ( error = ivas_masa_dec_reconfigure_fx( st_ivas, nSamplesRendered, data ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
- }
- ELSE
- {
- IF( NE_32( ( error = ivas_omasa_dec_config_fx( st_ivas, nSamplesRendered, &num_src, SrcInd, data ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
- }
- }
- }
- ELSE IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) )
- {
- st_ivas->nchan_transport = 2; /* always 2 MASA transport channels */
- move16();
- /* for the DISC mode the number of objects are written at the end of the bitstream, in the MASA metadata */
-
- Word32 res_dec, res_frac;
- iDiv_and_mod_32( ivas_total_brate, FRAMES_PER_SEC, &res_dec, &res_frac, 0 );
- st_ivas->nchan_ism = add( add( shl( st_ivas->bit_stream[res_dec - 1], 1 ), st_ivas->bit_stream[res_dec - 2] ), 1 );
- move16();
- st_ivas->ism_mode = ivas_omasa_ism_mode_select_fx( ivas_total_brate, st_ivas->nchan_ism );
- move16();
- IF( st_ivas->ini_frame > 0 )
- {
- /* reconfigure in case a change of operation mode is detected */
- test();
- test();
- IF( ( GT_32( ivas_total_brate, IVAS_SID_5k2 ) && NE_32( ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate ) ) || ( st_ivas->ini_active_frame == 0 ) )
- {
- IF( NE_32( ( error = ivas_omasa_dec_config_fx( st_ivas, nSamplesRendered, &num_src, SrcInd, data ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
- }
- }
- ELSE IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) )
- {
- /* the number of objects is written at the end of the bitstream, in the SBA metadata */
- Word32 res_dec, res_frac;
- iDiv_and_mod_32( ivas_total_brate, FRAMES_PER_SEC, &res_dec, &res_frac, 0 );
- st_ivas->nchan_ism = add( add( shl( st_ivas->bit_stream[res_dec - 1], 1 ), st_ivas->bit_stream[res_dec - 2] ), 1 );
- move16();
-
- test();
- IF( LT_32( ivas_total_brate, IVAS_24k4 ) || GE_32( ivas_total_brate, IVAS_256k ) )
- {
- /* read Ambisonic (SBA) planar flag */
- st_ivas->sba_planar = st_ivas->bit_stream[num_bits_read];
- move16();
- num_bits_read = add( num_bits_read, SBA_PLANAR_BITS );
- }
-
- st_ivas->sba_order = st_ivas->bit_stream[num_bits_read + 1];
- move16();
- st_ivas->sba_order = add( st_ivas->sba_order, shl( st_ivas->bit_stream[num_bits_read], 1 ) );
- move16();
- num_bits_read = add( num_bits_read, SBA_ORDER_BITS );
-
- /* read Ambisonic (SBA) order */
- if ( LT_32( ivas_total_brate, IVAS_256k ) )
- {
- st_ivas->sba_order = 3;
- move16();
- }
-
- test();
- IF( st_ivas->ini_frame > 0 && NE_32( ivas_total_brate, st_ivas->last_active_ivas_total_brate ) )
- {
- IF( NE_32( ( error = ivas_sba_dec_reconfigure_fx( st_ivas, nSamplesRendered, data ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
- ELSE
- {
- /* set Ambisonic (SBA) order used for analysis and coding */
- st_ivas->sba_analysis_order = ivas_sba_get_analysis_order_fx( ivas_total_brate, st_ivas->sba_order );
- move16();
-
- ivas_sba_config_fx( ivas_total_brate, st_ivas->sba_analysis_order, -1, &( st_ivas->nchan_transport ), st_ivas->sba_planar, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->element_mode_init );
-
- /*correct number of CPEs for discrete ISM coding*/
- test();
- IF( st_ivas->ini_frame > 0 && EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) )
- {
- st_ivas->nCPE = add( st_ivas->nCPE, shr( add( st_ivas->nchan_ism, 1 ), 1 ) );
- move16();
- }
- }
-
- IF( GE_32( ivas_total_brate, IVAS_256k ) )
- {
- st_ivas->ism_mode = ISM_SBA_MODE_DISC;
- move32();
- }
- ELSE
- {
- st_ivas->ism_mode = ISM_MODE_NONE;
- move32();
- }
- }
- ELSE IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) )
- {
- /* read MC configuration */
- idx = 0;
- move16();
- FOR( k = 0; k < MC_LS_SETUP_BITS; k++ )
- {
- IF( st_ivas->bit_stream[num_bits_read + k] )
- {
- idx = add( idx, shl( 1, sub( ( MC_LS_SETUP_BITS - 1 ), k ) ) );
- }
- }
- num_bits_read = add( num_bits_read, MC_LS_SETUP_BITS );
-
- /* select MC format mode; reconfigure the MC format decoder */
- IF( NE_32( ( error = ivas_mc_dec_config_fx( st_ivas, idx, nSamplesRendered, data ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
-
- /*-------------------------------------------------------------------*
- * Read element mode
- *-------------------------------------------------------------------*/
-
- IF( st_ivas->ini_frame == 0 && element_mode_flag )
- {
- /* read stereo technology info */
- IF( LT_32( ivas_total_brate, MIN_BRATE_MDCT_STEREO ) )
- {
- /* 1 bit */
- IF( st_ivas->bit_stream[num_bits_read] )
- {
- st_ivas->element_mode_init = add( 1, IVAS_CPE_DFT );
- move16();
- }
- ELSE
- {
- st_ivas->element_mode_init = add( 0, IVAS_CPE_DFT );
- move16();
- }
- }
- ELSE
- {
- st_ivas->element_mode_init = IVAS_CPE_MDCT;
- move16();
- }
- }
- }
- ELSE IF( EQ_32( ivas_total_brate, IVAS_SID_5k2 ) )
- {
- SWITCH( st_ivas->sid_format )
- {
- case SID_DFT_STEREO:
- st_ivas->element_mode_init = IVAS_CPE_DFT;
- move16();
- BREAK;
- case SID_MDCT_STEREO:
- st_ivas->element_mode_init = IVAS_CPE_MDCT;
- move16();
- BREAK;
- case SID_ISM:
- st_ivas->element_mode_init = IVAS_SCE;
- move16();
- BREAK;
- case SID_MASA_1TC:
- st_ivas->element_mode_init = IVAS_SCE;
- move16();
- st_ivas->nchan_transport = 1;
- move16();
- BREAK;
- case SID_MASA_2TC:; // empyt statement for declaration
- Word32 res_dec, res_frac;
- iDiv_and_mod_32( ivas_total_brate, FRAMES_PER_SEC, &res_dec, &res_frac, 0 );
- IF( EQ_16( st_ivas->bit_stream[( res_dec - 1 ) - SID_FORMAT_NBITS], 1 ) )
- {
- st_ivas->element_mode_init = IVAS_CPE_MDCT;
- move16();
- }
- ELSE
- {
- st_ivas->element_mode_init = IVAS_CPE_DFT;
- move16();
- }
- st_ivas->nchan_transport = 2;
- move16();
- BREAK;
- case SID_SBA_1TC:
- st_ivas->element_mode_init = IVAS_SCE;
- move16();
- BREAK;
- case SID_SBA_2TC:
- st_ivas->element_mode_init = IVAS_CPE_MDCT;
- move16();
- BREAK;
- }
-
- test();
- IF( st_ivas->ini_frame > 0 && EQ_32( st_ivas->ivas_format, SBA_FORMAT ) )
- {
- Word16 nchan_transport_old, nchan_transport;
- nchan_transport_old = st_ivas->nchan_transport;
- move16();
- IF( ( EQ_16( st_ivas->sid_format, SID_SBA_2TC ) ) )
- {
- nchan_transport = 2;
- }
- ELSE
- {
- nchan_transport = 1;
- }
- move16();
-
- IF( NE_16( nchan_transport_old, nchan_transport ) )
- {
- /*Setting the default bitrate for the reconfig function*/
- IF( EQ_16( st_ivas->sid_format, SID_SBA_2TC ) )
- {
- st_ivas->hDecoderConfig->ivas_total_brate = IVAS_48k;
- move16();
- }
- ELSE
- {
- st_ivas->hDecoderConfig->ivas_total_brate = IVAS_24k4;
- move16();
- }
-
- IF( NE_32( ( error = ivas_sba_dec_reconfigure_fx( st_ivas, nSamplesRendered, data ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- st_ivas->last_active_ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate;
- move32();
- st_ivas->hDecoderConfig->ivas_total_brate = ivas_total_brate;
- move32();
- }
- }
-
- IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) )
- {
- ISM_MODE last_ism_mode = st_ivas->ism_mode;
- move32();
- /* read the number of objects */
- st_ivas->nchan_transport = 1;
- move16();
- nchan_ism = 1;
- move16();
- Word32 res_dec, res_frac;
- iDiv_and_mod_32( ivas_total_brate, FRAMES_PER_SEC, &res_dec, &res_frac, 0 );
- k = extract_l( L_sub( L_sub( res_dec, 1 ), SID_FORMAT_NBITS ) );
- move16();
-
- WHILE( st_ivas->bit_stream[k] && ( nchan_ism < MAX_NUM_OBJECTS ) )
- {
- nchan_ism = add( nchan_ism, 1 );
- k = sub( k, 1 );
- }
- k = sub( k, 1 );
-
- test();
- IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) )
- {
- return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "wrong number of objects signalled!" );
- }
-
- st_ivas->nchan_ism = nchan_ism;
- move16();
- /* read ism_mode */
- st_ivas->ism_mode = ISM_MODE_DISC;
- move32();
- IF( GT_16( nchan_ism, 2 ) )
- {
- k = sub( k, nchan_ism ); /* SID metadata flags */
- idx = st_ivas->bit_stream[k];
- move16();
- st_ivas->ism_mode = (ISM_MODE) add( idx, 1 );
- move32();
- }
-
- if ( st_ivas->ini_frame == 0 )
- {
- last_ism_mode = st_ivas->ism_mode;
- move32();
- }
-
- IF( NE_32( ( error = ivas_ism_dec_config_fx( st_ivas, last_ism_mode, nSamplesRendered, data ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
- }
-
- /*-------------------------------------------------------------------*
- * Initialize decoder in the first good frame based on IVAS format
- * and number of transport channels
- *-------------------------------------------------------------------*/
- test();
- IF( st_ivas->ini_frame == 0 && NE_32( st_ivas->ivas_format, UNDEFINED_FORMAT ) )
- {
- IF( NE_32( ( error = doSanityChecks_IVAS( st_ivas ) ), IVAS_ERR_OK ) )
- {
- return IVAS_ERROR( error, "Sanity checks failed" );
- }
-
- IF( NE_32( ( error = ivas_init_decoder_fx( st_ivas ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
-
-
- /*----------------------------------------------------------------*
- * Reset bitstream pointers
- *----------------------------------------------------------------*/
-
- ivas_set_bitstream_pointers( st_ivas );
-
- reset_elements( st_ivas );
-
- /* update bitstream buffer pointer -> take into account already read bits */
- test();
- IF( ( st_ivas->nSCE > 0 ) || ( st_ivas->nCPE > 0 ) )
- {
- IF( st_ivas->nSCE > 0 )
- {
- st = st_ivas->hSCE[0]->hCoreCoder[0];
- }
- ELSE
- {
- st = st_ivas->hCPE[0]->hCoreCoder[0];
- }
- st->next_bit_pos = num_bits_read;
- move16();
- st->total_brate = ACELP_8k00; /* only temporary initialization - this is needed for get_next_indice() in the frame following NO_DATA frame */
- move32();
- }
-
- return error;
-}
-
-
-/*-------------------------------------------------------------------*
- * ivas_read_format()
- *
- * Read IVAS format signaling
- *-------------------------------------------------------------------*/
-
-static ivas_error ivas_read_format(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
- Word16 *num_bits_read /* o : number of IVAS signaling bits read from the bitstream */
-)
-{
- Word16 k, idx;
- Word32 ivas_total_brate;
- ivas_error error;
-
- error = IVAS_ERR_OK;
- move32();
-
- ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate;
- move32();
-
- *num_bits_read = 0;
- move16();
- test();
- test();
- IF( !st_ivas->bfi && is_DTXrate( ivas_total_brate ) == 0 )
- {
- /* read IVAS format */
- k = 0;
- move16();
- if ( st_ivas->bit_stream[*num_bits_read] )
- {
- k = 1;
- move16();
- }
- k = shl( k, 1 );
- ( *num_bits_read ) = add( ( *num_bits_read ), 1 );
- move16();
- if ( st_ivas->bit_stream[*num_bits_read] )
- {
- k = add( k, 1 );
- }
- ( *num_bits_read ) = add( ( *num_bits_read ), 1 );
- move16();
- SWITCH( k )
- {
- case 0:
- st_ivas->ivas_format = STEREO_FORMAT;
- move32();
- BREAK;
- case 1:
- st_ivas->ivas_format = MC_FORMAT;
- move32();
- BREAK;
- case 2:
- st_ivas->ivas_format = ISM_FORMAT;
- move32();
-
- IF( GE_32( ivas_total_brate, IVAS_24k4 ) )
- {
- IF( st_ivas->bit_stream[*num_bits_read] )
- {
- ( *num_bits_read ) = add( ( *num_bits_read ), 1 );
- move16();
- IF( st_ivas->bit_stream[*num_bits_read] )
- {
- st_ivas->ivas_format = SBA_ISM_FORMAT;
- move32();
- }
- ELSE
- {
- st_ivas->ivas_format = MASA_ISM_FORMAT;
- move32();
- }
- }
-
- ( *num_bits_read ) = add( ( *num_bits_read ), 1 );
- move16();
- }
- BREAK;
- case 3:
- IF( st_ivas->bit_stream[*num_bits_read] )
- {
- st_ivas->ivas_format = MASA_FORMAT;
- move32();
- }
- ELSE
- {
- st_ivas->ivas_format = SBA_FORMAT;
- move32();
- /* read Ambisonic (SBA) planar flag */
- st_ivas->sba_planar = st_ivas->bit_stream[( *num_bits_read ) + 1];
- move16();
-
- /* read Ambisonic (SBA) order */
- st_ivas->sba_order = st_ivas->bit_stream[( *num_bits_read ) + 2 + SBA_PLANAR_BITS];
- move16();
- st_ivas->sba_order = add( st_ivas->sba_order, shl( st_ivas->bit_stream[( *num_bits_read ) + 1 + SBA_PLANAR_BITS], 1 ) );
- move16();
- if ( st_ivas->sba_order == 0 )
- {
- st_ivas->ivas_format = SBA_ISM_FORMAT;
- move32();
- }
- }
- ( *num_bits_read ) = add( ( *num_bits_read ), 1 );
- move16();
-
- BREAK;
- }
- }
- ELSE IF( ( st_ivas->bfi == 0 ) && EQ_32( ivas_total_brate, IVAS_SID_5k2 ) )
- {
- /* read IVAS format in SID frame */
- idx = 0;
- move16();
- FOR( k = 0; k < SID_FORMAT_NBITS; k++ )
- {
- idx += st_ivas->bit_stream[k] << ( SID_FORMAT_NBITS - 1 - k );
- }
-
- ( *num_bits_read ) = add( *num_bits_read, SID_FORMAT_NBITS );
- move16();
- st_ivas->sid_format = idx;
- move16();
-
- SWITCH( idx )
- {
- case SID_DFT_STEREO:
- case SID_MDCT_STEREO:
- st_ivas->ivas_format = STEREO_FORMAT;
- move32();
- BREAK;
- case SID_ISM:
- st_ivas->ivas_format = ISM_FORMAT;
- move32();
- BREAK;
- case SID_MULTICHANNEL:
- st_ivas->ivas_format = MC_FORMAT;
- move32();
- BREAK;
- case SID_SBA_1TC:
- st_ivas->ivas_format = SBA_FORMAT;
- move32();
- st_ivas->element_mode_init = IVAS_SCE;
- move16();
- BREAK;
- case SID_SBA_2TC:
- st_ivas->ivas_format = SBA_FORMAT;
- move32();
- st_ivas->element_mode_init = IVAS_CPE_MDCT;
- move16();
- BREAK;
- case SID_MASA_1TC:
- st_ivas->ivas_format = MASA_FORMAT;
- move32();
- st_ivas->element_mode_init = IVAS_SCE;
- move16();
- BREAK;
- case SID_MASA_2TC:
- st_ivas->ivas_format = MASA_FORMAT;
- move32();
- Word32 res_dec, res_frac;
- iDiv_and_mod_32( ivas_total_brate, FRAMES_PER_SEC, &res_dec, &res_frac, 0 );
- IF( EQ_32( st_ivas->bit_stream[res_dec - 1], 1 ) )
- {
- st_ivas->element_mode_init = IVAS_CPE_MDCT;
- move16();
- }
- ELSE
- {
- st_ivas->element_mode_init = IVAS_CPE_DFT;
- move16();
- }
- BREAK;
- default:
- /* This should actually be impossible, since only 3 bits are read, so if this happens something is broken */
- return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Invalid value %c found in SID format field.", st_ivas->sid_format );
- }
-
- IF( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) )
- {
- if ( st_ivas->sba_analysis_order == 0 )
- {
- st_ivas->sba_analysis_order = SBA_FOA_ORDER;
- move16();
- }
- }
-
- /* reset bitstream handle to avoid BER detection after reading the 2400 kbps for ch0 */
- st_ivas->bit_stream = st_ivas->bit_stream + ( *num_bits_read );
- ( *num_bits_read ) = 0;
- move16();
- }
- ELSE
- {
- /* In SID/NO_DATA frames, use the previous frame IVAS format */
- }
-
- return error;
-}
-
-
-/*-------------------------------------------------------------------*
- * getNumChanSynthesis()
- *
- * get number of output channels used for synthesis/decoding
- * (often different from number of output channels!)
- *-------------------------------------------------------------------*/
-
-/*! r: number of channels to be synthesised */
-
-Word16 getNumChanSynthesis(
- Decoder_Struct *st_ivas /* i : IVAS decoder structure */
-)
-{
- Word16 n;
-
- n = add( st_ivas->nSCE, imult1616( CPE_CHANNELS, st_ivas->nCPE ) );
- test();
- test();
- IF( st_ivas->sba_dirac_stereo_flag )
- {
- n = CPE_CHANNELS;
- move16();
- }
- ELSE IF( ( st_ivas->hMCT != NULL || EQ_32( st_ivas->ivas_format, SBA_FORMAT ) ) && NE_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) )
- {
- n = st_ivas->nchan_transport;
- move16();
- }
- ELSE IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) )
- {
- IF( EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) )
- {
- n = add( st_ivas->nchan_transport, st_ivas->nchan_ism );
- }
- ELSE
- {
- n = st_ivas->nchan_transport;
- move16();
- }
- }
-
- return n;
-}
-
-/*-------------------------------------------------------------------*
- * copy_decoder_config()
- *
- * Copy IVAS configuration structure to the CoreCoder state structure
- *-------------------------------------------------------------------*/
-
-void copy_decoder_config(
- Decoder_Struct *st_ivas, /* i : IVAS decoder structure */
- Decoder_State *st /* o : decoder state structure */
-)
-{
- st->output_Fs = st_ivas->hDecoderConfig->output_Fs;
- move32();
- st->Opt_AMR_WB = st_ivas->hDecoderConfig->Opt_AMR_WB;
- move16();
- st->codec_mode = st_ivas->codec_mode;
- move16();
- st->ini_frame = st_ivas->ini_frame;
- move16();
-
- st->bfi = st_ivas->bfi;
- move16();
-
- st->writeFECoffset = st_ivas->writeFECoffset;
- move16();
-
- st->element_mode = st_ivas->element_mode_init;
- move16();
-
- return;
-}
-
-/*-------------------------------------------------------------------*
- * ivas_init_decoder_front()
- *
- * Set decoder parameters to initial values
- *-------------------------------------------------------------------*/
-ivas_error ivas_init_decoder_front(
- Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
-)
-{
- ivas_error error;
-
- error = IVAS_ERR_OK;
- move32();
- /*-----------------------------------------------------------------*
- * Resets
- *-----------------------------------------------------------------*/
-
- st_ivas->nSCE = 0;
- move16();
- st_ivas->nCPE = 0;
- move16();
- st_ivas->nCPE_old = 0;
- move16();
- st_ivas->nchan_transport = -1;
- move16();
- st_ivas->ism_mode = ISM_MODE_NONE;
- move32();
- st_ivas->mc_mode = MC_MODE_NONE;
- move32();
- st_ivas->sba_dirac_stereo_flag = 0;
- move16();
-
- /* HRTF binauralization latency in ns */
- st_ivas->binaural_latency_ns = 0;
- move32();
-
- /*-------------------------------------------------------------------*
- * Allocate and initialize Custom loudspeaker layout handle
- *--------------------------------------------------------------------*/
-
- IF( st_ivas->hDecoderConfig->Opt_LsCustom )
- {
- IF( EQ_32( ( error = ivas_ls_custom_open_fx( &( st_ivas->hLsSetupCustom ) ) ), IVAS_ERR_OK ) )
- {
- set_zero_fx( ( st_ivas->hLsSetupCustom )->ls_azimuth_fx, MAX_OUTPUT_CHANNELS );
- set_zero_fx( ( st_ivas->hLsSetupCustom )->ls_elevation_fx, MAX_OUTPUT_CHANNELS );
- }
- ELSE
- {
- return error;
- }
- }
-
- /*-------------------------------------------------------------------*
- * Allocate and initialize Head-Tracking handle
- *--------------------------------------------------------------------*/
-
- IF( st_ivas->hDecoderConfig->Opt_Headrotation )
- {
- IF( NE_32( ( error = ivas_headTrack_open_fx( &( st_ivas->hHeadTrackData ) ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- error = ivas_orient_trk_SetTrackingType_fx( st_ivas->hHeadTrackData->OrientationTracker, st_ivas->hDecoderConfig->orientation_tracking );
- IF( NE_32( ( error ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
- /*-------------------------------------------------------------------*
- * Allocate and initialize external orientation handle
- *--------------------------------------------------------------------*/
-
- IF( st_ivas->hDecoderConfig->Opt_ExternalOrientation )
- {
- IF( NE_32( ( error = ivas_external_orientation_open( &( st_ivas->hExtOrientationData ), st_ivas->hDecoderConfig->render_framesize ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
-
- /*-------------------------------------------------------------------*
- * Allocate and initialize combined orientation handle
- *--------------------------------------------------------------------*/
- test();
- IF( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation )
- {
- IF( NE_32( ( error = ivas_combined_orientation_open( &( st_ivas->hCombinedOrientationData ), st_ivas->hDecoderConfig->output_Fs, st_ivas->hDecoderConfig->render_framesize ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
-
- /*-------------------------------------------------------------------*
- * Allocate HRTF binary handle
- *--------------------------------------------------------------------*/
-
- IF( st_ivas->hDecoderConfig->Opt_HRTF_binary )
- {
- IF( NE_32( ( error = ivas_HRTF_binary_open_fx( &( st_ivas->hHrtfTD ) ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- IF( NE_32( ( error = ivas_HRTF_CRend_binary_open_fx( &( st_ivas->hSetOfHRTF ) ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- IF( NE_32( ( error = ivas_HRTF_fastconv_binary_open_fx( &st_ivas->hHrtfFastConv ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- IF( NE_32( ( error = ivas_HRTF_parambin_binary_open_fx( &st_ivas->hHrtfParambin ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
-
- /*-------------------------------------------------------------------*
- * Allocate and initialize Binaural Renderer configuration handle
- *--------------------------------------------------------------------*/
- test();
- test();
- IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) )
- {
- IF( NE_32( ( error = ivas_render_config_open( &( st_ivas->hRenderConfig ) ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- IF( NE_32( ( error = ivas_render_config_init_from_rom_fx( &st_ivas->hRenderConfig ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
-
- return error;
-}
-
-
-/*-------------------------------------------------------------------*
- * ivas_init_decoder()
- *
- * Initialize IVAS decoder state structure
- *-------------------------------------------------------------------*/
-ivas_error ivas_init_decoder_fx(
- Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
-)
-{
- Word16 i, n, k;
- Word16 sce_id, cpe_id;
- Word16 numCldfbAnalyses, numCldfbSyntheses;
- Word16 granularity, n_channels_transport_jbm;
- Word32 output_Fs, ivas_total_brate;
- Word32 binauralization_delay_ns;
- AUDIO_CONFIG output_config;
- DECODER_CONFIG_HANDLE hDecoderConfig;
- ivas_error error;
- Word32 ism_total_brate;
-
- error = IVAS_ERR_OK;
- move32();
- output_Fs = st_ivas->hDecoderConfig->output_Fs;
- move32();
- hDecoderConfig = st_ivas->hDecoderConfig;
- output_config = hDecoderConfig->output_config;
- ivas_total_brate = hDecoderConfig->ivas_total_brate;
- move32();
- hDecoderConfig->last_ivas_total_brate = ivas_total_brate;
- move32();
- st_ivas->last_active_ivas_total_brate = ivas_total_brate;
- move32();
- /*-----------------------------------------------------------------*
- * Set number of output channels for EXTERNAL output config.
- *-----------------------------------------------------------------*/
-
- IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
- {
- IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) )
- {
- hDecoderConfig->nchan_out = audioCfg2channels( IVAS_AUDIO_CONFIG_HOA3 );
- move16();
- hDecoderConfig->nchan_out = add( hDecoderConfig->nchan_out, st_ivas->nchan_ism );
- move16();
- }
- ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) )
- {
- hDecoderConfig->nchan_out = add( st_ivas->nchan_transport, st_ivas->nchan_ism );
- move16();
- }
- ELSE IF( !EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) )
- {
- hDecoderConfig->nchan_out = st_ivas->nchan_transport;
- move16();
- }
-
- st_ivas->hOutSetup.nchan_out_woLFE = hDecoderConfig->nchan_out;
- move16();
- }
-
- /*-----------------------------------------------------------------*
- * Set output and intern setup & renderer selection
- *-----------------------------------------------------------------*/
-
- st_ivas->intern_config = output_config;
- move32();
- ivas_output_init( &( st_ivas->hOutSetup ), output_config );
- test();
- IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) )
- {
- st_ivas->hOutSetup.ambisonics_order = SBA_HOA3_ORDER;
- move16();
- st_ivas->intern_config = IVAS_AUDIO_CONFIG_7_1_4;
- move32();
- st_ivas->hOutSetup.output_config = st_ivas->intern_config;
- move32();
- st_ivas->hOutSetup.nchan_out_woLFE = audioCfg2channels( st_ivas->intern_config );
- move16();
- }
- test();
- IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
- {
- st_ivas->hOutSetup.ambisonics_order = SBA_HOA3_ORDER;
- move32();
- st_ivas->intern_config = IVAS_AUDIO_CONFIG_HOA3;
- move32();
- st_ivas->hOutSetup.output_config = IVAS_AUDIO_CONFIG_HOA3;
- move32();
- st_ivas->hOutSetup.nchan_out_woLFE = audioCfg2channels( IVAS_AUDIO_CONFIG_HOA3 );
- move16();
- }
-
- /* Only initialize transport setup if it is used */
- IF( NE_32( st_ivas->transport_config, IVAS_AUDIO_CONFIG_INVALID ) )
- {
- ivas_output_init( &( st_ivas->hTransSetup ), st_ivas->transport_config );
- }
-
- test();
- IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) && EQ_32( st_ivas->mc_mode, MC_MODE_MCMASA ) )
- {
- ivas_mcmasa_setNumTransportChannels_fx( &( st_ivas->nchan_transport ), &( st_ivas->element_mode_init ), ivas_total_brate );
-
- ivas_mcmasa_set_separate_channel_mode_fx( &( st_ivas->hOutSetup.separateChannelEnabled ), &( st_ivas->hOutSetup.separateChannelIndex ), ivas_total_brate );
- }
-
- ivas_renderer_select( st_ivas );
-
- IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
- {
- IF( EQ_16( ( error = ivas_ls_custom_output_init_fx( st_ivas ) ), IVAS_ERR_OK ) )
- {
- st_ivas->hOutSetup.ls_azimuth_fx = st_ivas->hLsSetupCustom->ls_azimuth_fx;
- move32();
- st_ivas->hOutSetup.ls_elevation_fx = st_ivas->hLsSetupCustom->ls_elevation_fx;
- move32();
- st_ivas->hIntSetup.ls_azimuth_fx = st_ivas->hLsSetupCustom->ls_azimuth_fx;
- move32();
- st_ivas->hIntSetup.ls_elevation_fx = st_ivas->hLsSetupCustom->ls_elevation_fx;
- move32();
- }
- ELSE
- {
- return error;
- }
- }
-
- ivas_output_init( &( st_ivas->hIntSetup ), st_ivas->intern_config );
-
- test();
- IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) && EQ_32( st_ivas->mc_mode, MC_MODE_MCMASA ) )
- {
- ivas_mcmasa_set_separate_channel_mode_fx( &( st_ivas->hIntSetup.separateChannelEnabled ), &( st_ivas->hIntSetup.separateChannelIndex ), ivas_total_brate );
-
- test();
- IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && st_ivas->hOutSetup.separateChannelEnabled )
- {
- st_ivas->hLsSetupCustom->separate_ch_found = 0;
- move16();
- IF( GE_16( st_ivas->hOutSetup.nchan_out_woLFE, MCMASA_MIN_SPEAKERS_SEPARATE_CENTER ) )
- {
- /* check for a speaker at (0, 0) if minimum speaker count is available */
- FOR( i = 0; i < st_ivas->hOutSetup.nchan_out_woLFE; i++ )
- {
- test();
- IF( ( L_shr( st_ivas->hOutSetup.ls_azimuth_fx[i], Q22 ) == 0 ) && ( L_shr( st_ivas->hOutSetup.ls_elevation_fx[i], Q22 ) == 0 ) )
- {
- st_ivas->hIntSetup.separateChannelIndex = i;
- move16();
- st_ivas->hLsSetupCustom->separate_ch_found = 1;
- move16();
- BREAK;
- }
- }
- }
- }
- }
-
-
- /*-----------------------------------------------------------------*
- * Allocate and initialize SCE/CPE and other handles
- *-----------------------------------------------------------------*/
-
- IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) )
- {
- st_ivas->nSCE = 1; /* in mono, there is always only one SCE */
- move16();
- st_ivas->nCPE = 0;
- move16();
- st_ivas->nCPE_old = 0;
- move16();
- st_ivas->nchan_transport = 1;
- move16();
- sce_id = 0;
- move16();
-
- IF( NE_32( ( error = create_sce_dec( st_ivas, sce_id, ivas_total_brate ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- reset_indices_dec( st_ivas->hSCE[sce_id]->hCoreCoder[0] );
- }
- ELSE IF( EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) )
- {
- st_ivas->nchan_transport = CPE_CHANNELS;
- move16();
- st_ivas->intern_config = IVAS_AUDIO_CONFIG_STEREO;
- move32();
-
- st_ivas->nSCE = 0;
- move16();
- st_ivas->nCPE = 1; /* in stereo, there is always only one CPE */
- move16();
- st_ivas->nCPE_old = 0;
- move16();
- cpe_id = 0;
- move16();
-
- IF( NE_32( ( error = create_cpe_dec( st_ivas, cpe_id, ivas_total_brate ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- FOR( n = 0; n < st_ivas->nchan_transport; n++ )
- {
- reset_indices_dec( st_ivas->hCPE[cpe_id]->hCoreCoder[n] );
- }
-
- /* init EFAP for custom LS output and set hTransSetup */
- IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
- {
- IF( NE_32( ( error = efap_init_data_fx( &( st_ivas->hEFAPdata ), st_ivas->hOutSetup.ls_azimuth_fx, st_ivas->hOutSetup.ls_elevation_fx, st_ivas->hOutSetup.nchan_out_woLFE, EFAP_MODE_EFAP ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- ivas_output_init( &( st_ivas->hTransSetup ), IVAS_AUDIO_CONFIG_STEREO );
- }
- }
- ELSE IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) )
- {
- Word32 element_brate_tmp[MAX_NUM_OBJECTS];
-
- st_ivas->nSCE = st_ivas->nchan_transport; /* "st_ivas->nchan_transport" is known from ivas_dec_setup */
- move16();
- st_ivas->nCPE = 0;
- move16();
- st_ivas->nCPE_old = 0;
- move16();
- st_ivas->ism_extmeta_active = -1;
- move16();
- st_ivas->ism_extmeta_cnt = 0;
- move16();
- IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) )
- {
- st_ivas->nchan_transport = MAX_PARAM_ISM_WAVE;
- move16();
- st_ivas->nSCE = MAX_PARAM_ISM_WAVE;
- move16();
-
- IF( NE_32( ( error = ivas_param_ism_dec_open_fx( st_ivas ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
-
- IF( NE_32( ( error = ivas_ism_metadata_dec_create_fx( st_ivas, st_ivas->nSCE, 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_dec( st_ivas, sce_id, element_brate_tmp[sce_id] ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- reset_indices_dec( st_ivas->hSCE[sce_id]->hCoreCoder[0] );
-
- st_ivas->hSCE[sce_id]->hCoreCoder[0]->is_ism_format = 1;
- move16();
- }
-
- st_ivas->hISMDTX.sce_id_dtx = 0;
- move16();
-
- IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) )
- {
- st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->seed2 = st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->seed3;
- move16();
- }
- ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MODE_DISC ) )
- {
- FOR( sce_id = 0; sce_id < st_ivas->nSCE; ++sce_id )
- {
- st_ivas->hSCE[sce_id]->hCoreCoder[0]->hFdCngDec->hFdCngCom->seed2 = add( 2, sce_id );
- move16();
- }
- }
- }
- ELSE IF( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) )
- {
- IF( NE_32( ( error = ivas_qmetadata_open_fx( &( st_ivas->hQMetaData ) ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- IF( NE_32( ( error = ivas_spar_dec_open_fx( st_ivas, 0 ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- set16_fx( st_ivas->hSpar->hFbMixer->cldfb_cross_fade_fx, 0, CLDFB_NO_COL_MAX );
- test();
- IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_DEC ) && st_ivas->hOutSetup.is_loudspeaker_setup )
- {
- IF( NE_32( ( error = ivas_sba_get_hoa_dec_matrix_fx( st_ivas->hOutSetup, &st_ivas->hoa_dec_mtx, st_ivas->hIntSetup.ambisonics_order ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
-
- Word16 hodirac_flag = ivas_get_hodirac_flag_fx( ivas_total_brate, st_ivas->sba_analysis_order );
- IF( hodirac_flag )
- {
- IF( NE_32( ( error = ivas_dirac_sba_config_fx( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, IVAS_MAX_NUM_BANDS, st_ivas->ivas_format ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
- ELSE
- {
- IF( NE_32( ( error = ivas_dirac_sba_config_fx( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, ( IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ), st_ivas->ivas_format ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
-
-
- test();
- test();
- IF( NE_32( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_FOA ) && NE_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) && NE_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_MONO ) )
- {
- IF( NE_32( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_OPEN ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- st_ivas->hSpar->enc_param_start_band = st_ivas->hDirAC->hConfig->enc_param_start_band;
- move16();
- }
- ELSE
- {
- Word16 band_grouping[IVAS_MAX_NUM_BANDS + 1];
-
- st_ivas->hSpar->enc_param_start_band = s_min( IVAS_MAX_NUM_BANDS, SPAR_DIRAC_SPLIT_START_BAND );
- move16();
- IF( ivas_get_hodirac_flag_fx( ivas_total_brate, st_ivas->sba_analysis_order ) )
- {
- st_ivas->hSpar->enc_param_start_band = 0;
- move16();
- set8_fx( (Word8 *) st_ivas->hQMetaData->twoDirBands, (Word8) 1, st_ivas->hQMetaData->q_direction[0].cfg.nbands );
- st_ivas->hQMetaData->numTwoDirBands = (UWord8) st_ivas->hQMetaData->q_direction[0].cfg.nbands;
- move16();
- }
-
- ivas_dirac_config_bands_fx( band_grouping, IVAS_MAX_NUM_BANDS, extract_l( Mpy_32_32_r( st_ivas->hDecoderConfig->output_Fs, INV_CLDFB_BANDWIDTH_Q31 ) ),
- st_ivas->hSpar->dirac_to_spar_md_bands, st_ivas->hQMetaData->useLowerBandRes, st_ivas->hSpar->enc_param_start_band, 0 );
- }
- st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas );
- move16();
- FOR( sce_id = 0; sce_id < st_ivas->nSCE; sce_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_sce_dec( st_ivas, sce_id, res_dec ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- reset_indices_dec( st_ivas->hSCE[sce_id]->hCoreCoder[0] );
- }
-
- 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_dec( st_ivas, cpe_id, (res_dec) *CPE_CHANNELS ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- FOR( n = 0; n < CPE_CHANNELS; n++ )
- {
- reset_indices_dec( st_ivas->hCPE[cpe_id]->hCoreCoder[n] );
- }
- }
-
- /* create CPE element for DFT Stereo like upmix */
- test();
- IF( st_ivas->sba_dirac_stereo_flag && ( st_ivas->nCPE == 0 ) )
- {
- Word32 res_dec, res_frac;
- iDiv_and_mod_32( ivas_total_brate, add( st_ivas->nSCE, st_ivas->nCPE ), &res_dec, &res_frac, 0 );
-
- IF( NE_32( ( error = create_cpe_dec( st_ivas, cpe_id, res_dec ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- st_ivas->hCPE[0]->hCoreCoder[0] = st_ivas->hSCE[0]->hCoreCoder[0]; /* don't allocate unnecessary core coder, simply point to core coder of SCE element */
- st_ivas->hCPE[0]->hCoreCoder[1] = NULL;
- }
-
- IF( GT_16( st_ivas->nCPE, 1 ) )
- {
- IF( NE_32( ( error = create_mct_dec_fx( st_ivas ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
-
- /* set CNA/CNG flags */
- ivas_sba_set_cna_cng_flag( st_ivas );
- }
- ELSE IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) )
- {
- /* if we start in ISM_MODE_NONE in MASA_ISM, that appears as normal MASA, but we may change to a mode with ISMs */
- st_ivas->ism_extmeta_active = -1;
- move16();
- st_ivas->ism_extmeta_cnt = 0;
- move16();
- IF( NE_32( ( error = ivas_qmetadata_open_fx( &( st_ivas->hQMetaData ) ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- IF( NE_32( ( error = ivas_masa_dec_open_fx( st_ivas ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- test();
- test();
- test();
- IF( EQ_32( st_ivas->renderer_type, RENDERER_DIRAC ) || EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) )
- {
- IF( NE_32( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_OPEN ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
-
- FOR( sce_id = 0; sce_id < st_ivas->nSCE; sce_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_sce_dec( st_ivas, sce_id, res_dec ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- reset_indices_dec( st_ivas->hSCE[sce_id]->hCoreCoder[0] );
- }
-
- 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_dec( st_ivas, cpe_id, L_shl( res_dec, 1 ) ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- FOR( n = 0; n < CPE_CHANNELS; n++ )
- {
- reset_indices_dec( st_ivas->hCPE[cpe_id]->hCoreCoder[n] );
- }
- }
-
- /* set CNA/CNG flags */
- ivas_sba_set_cna_cng_flag( st_ivas );
- }
- ELSE IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) )
- {
- Word32 temp_brate[MAX_SCE];
- st_ivas->ism_extmeta_active = -1;
- move16();
- st_ivas->ism_extmeta_cnt = 0;
- move16();
-
- st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas );
- move16();
- IF( NE_32( ( error = ivas_qmetadata_open_fx( &( st_ivas->hQMetaData ) ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- IF( NE_32( ( error = ivas_spar_dec_open_fx( st_ivas, 0 ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- test();
- IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_DEC ) && st_ivas->hOutSetup.is_loudspeaker_setup )
- {
- IF( NE_32( ( error = ivas_sba_get_hoa_dec_matrix_fx( st_ivas->hOutSetup, &st_ivas->hoa_dec_mtx, st_ivas->hIntSetup.ambisonics_order ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
-
- Word16 hodirac_flag = ivas_get_hodirac_flag_fx( ivas_total_brate, st_ivas->sba_analysis_order );
- IF( hodirac_flag )
- {
- IF( NE_32( ( error = ivas_dirac_sba_config_fx( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, IVAS_MAX_NUM_BANDS, st_ivas->ivas_format ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
- ELSE
- {
- IF( NE_32( ( error = ivas_dirac_sba_config_fx( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, ( IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ), st_ivas->ivas_format ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
-
-
- test();
- test();
- IF( NE_32( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_FOA ) && NE_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) && NE_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_MONO ) )
- {
- IF( NE_32( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_OPEN ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- st_ivas->hSpar->enc_param_start_band = st_ivas->hDirAC->hConfig->enc_param_start_band;
- move16();
- }
- ELSE
- {
- Word16 band_grouping[IVAS_MAX_NUM_BANDS + 1];
-
- st_ivas->hSpar->enc_param_start_band = s_min( IVAS_MAX_NUM_BANDS, SPAR_DIRAC_SPLIT_START_BAND );
- move16();
- IF( ivas_get_hodirac_flag_fx( ivas_total_brate, st_ivas->sba_analysis_order ) )
- {
- st_ivas->hSpar->enc_param_start_band = 0;
- move16();
- set8_fx( (Word8 *) st_ivas->hQMetaData->twoDirBands, (Word8) 1, st_ivas->hQMetaData->q_direction[0].cfg.nbands );
- st_ivas->hQMetaData->numTwoDirBands = (UWord8) st_ivas->hQMetaData->q_direction[0].cfg.nbands;
- move16();
- }
-
- ivas_dirac_config_bands_fx( band_grouping, IVAS_MAX_NUM_BANDS, extract_l( Mpy_32_32_r( st_ivas->hDecoderConfig->output_Fs, INV_CLDFB_BANDWIDTH_Q31 ) ),
- st_ivas->hSpar->dirac_to_spar_md_bands, st_ivas->hQMetaData->useLowerBandRes, st_ivas->hSpar->enc_param_start_band, 0 );
- }
-
- FOR( sce_id = 0; sce_id < st_ivas->nSCE; sce_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_sce_dec( st_ivas, sce_id, res_dec ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- reset_indices_dec( st_ivas->hSCE[sce_id]->hCoreCoder[0] );
- }
-
- IF( EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) )
- {
- st_ivas->nCPE_old = st_ivas->nCPE;
- move16();
- st_ivas->nCPE = add( st_ivas->nCPE, shr( add( st_ivas->nchan_ism, 1 ), 1 ) );
- move16();
- st_ivas->element_mode_init = IVAS_CPE_MDCT;
- move16();
- }
-
- 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_dec( st_ivas, cpe_id, L_shl( res_dec, 1 ) ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- FOR( n = 0; n < CPE_CHANNELS; n++ )
- {
- reset_indices_dec( st_ivas->hCPE[cpe_id]->hCoreCoder[n] );
- }
- }
-
- /* create CPE element for DFT Stereo like upmix */
- test();
- IF( st_ivas->sba_dirac_stereo_flag && st_ivas->nCPE == 0 )
- {
- Word32 res_dec, res_frac;
- iDiv_and_mod_32( ivas_total_brate, add( st_ivas->nSCE, st_ivas->nCPE ), &res_dec, &res_frac, 0 );
- IF( NE_32( ( error = create_cpe_dec( st_ivas, cpe_id, res_dec ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- st_ivas->hCPE[0]->hCoreCoder[0] = st_ivas->hSCE[0]->hCoreCoder[0]; /* don't allocate unnecessary core coder, simply point to core coder of SCE element */
- st_ivas->hCPE[0]->hCoreCoder[1] = NULL;
- }
-
- IF( GT_16( st_ivas->nCPE, 1 ) )
- {
- IF( NE_32( ( error = create_mct_dec_fx( st_ivas ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
-
- IF( EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) )
- {
- IF( NE_32( ( error = ivas_ism_metadata_dec_create_fx( st_ivas, st_ivas->nchan_ism, temp_brate ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- IF( NE_32( ( error = ivas_osba_data_open_fx( st_ivas ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
-
- /* set CNA/CNG flags */
- ivas_sba_set_cna_cng_flag( st_ivas );
- }
- ELSE IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) )
- {
- st_ivas->ism_extmeta_active = -1;
- move16();
- st_ivas->ism_extmeta_cnt = 0;
- move16();
-
- IF( NE_32( ( error = ivas_qmetadata_open_fx( &( st_ivas->hQMetaData ) ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- k = 0;
- move16();
- ism_total_brate = 0;
- move32();
-
- WHILE( ( k < SIZE_IVAS_BRATE_TBL ) && ( ivas_total_brate != ivas_brate_tbl[k] ) )
- {
- k = add( k, 1 );
- }
- 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 ) )
- {
- /* one separated object */
- st_ivas->nSCE = 1;
- move16();
- ism_total_brate = sep_object_brate[k - 2][0];
- move32();
- IF( NE_32( ( error = create_sce_dec( st_ivas, 0, ism_total_brate ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- reset_indices_dec( st_ivas->hSCE[0]->hCoreCoder[0] );
-
- IF( NE_32( ( error = ivas_ism_metadata_dec_create_fx( st_ivas, 1, NULL ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
- ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) )
- {
- Word32 temp_brate[MAX_SCE];
- st_ivas->nSCE = st_ivas->nchan_ism; /* number of objects */
- move16();
- FOR( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ )
- {
- temp_brate[sce_id] = sep_object_brate[k - 2][st_ivas->nSCE - 1];
- move32();
- ism_total_brate = L_add( ism_total_brate, temp_brate[sce_id] );
-
- IF( NE_32( ( error = create_sce_dec( st_ivas, sce_id, temp_brate[sce_id] ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- reset_indices_dec( st_ivas->hSCE[sce_id]->hCoreCoder[0] );
- }
-
- IF( NE_32( ( error = ivas_ism_metadata_dec_create_fx( st_ivas, st_ivas->nchan_ism, temp_brate ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
-
- IF( NE_32( ( error = ivas_masa_dec_open_fx( st_ivas ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- IF( NE_32( ( error = ivas_omasa_data_open_fx( st_ivas ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- test();
- test();
- test();
- IF( EQ_32( st_ivas->renderer_type, RENDERER_DIRAC ) || EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) )
- {
- IF( NE_32( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_OPEN ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
-
- IF( NE_32( ( error = create_cpe_dec( st_ivas, 0, ivas_total_brate - ism_total_brate ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- FOR( n = 0; n < CPE_CHANNELS; n++ )
- {
- reset_indices_dec( st_ivas->hCPE[0]->hCoreCoder[n] );
- }
- }
- ELSE IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) )
- {
- IF( EQ_32( st_ivas->mc_mode, MC_MODE_MCT ) )
- {
- /* init EFAP for custom LS setup */
- IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
- {
- IF( NE_32( ( error = efap_init_data_fx( &( st_ivas->hEFAPdata ), st_ivas->hLsSetupCustom->ls_azimuth_fx, st_ivas->hLsSetupCustom->ls_elevation_fx, st_ivas->hLsSetupCustom->num_spk, EFAP_MODE_EFAP ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
-
- st_ivas->nchan_transport = ivas_mc_ls_setup_get_num_channels_fx( ivas_mc_map_output_config_to_mc_ls_setup_fx( st_ivas->transport_config ) );
- move16();
- st_ivas->nSCE = 0;
- move16();
- st_ivas->nCPE = shr( st_ivas->nchan_transport, 1 );
- move16();
- st_ivas->nCPE_old = 0;
- move16();
- st_ivas->element_mode_init = IVAS_CPE_MDCT;
- 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( st_ivas->nchan_transport, 1 ), &res_dec, &res_frac, 0 );
- IF( NE_32( ( error = create_cpe_dec( st_ivas, cpe_id, L_shl( res_dec, 1 ) ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- FOR( n = 0; n < CPE_CHANNELS; n++ )
- {
- reset_indices_dec( st_ivas->hCPE[cpe_id]->hCoreCoder[n] );
- }
- }
-
- IF( NE_32( ( error = create_mct_dec_fx( st_ivas ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
- ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) )
- {
- /* init EFAP for custom LS setup */
- IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
- {
- IF( NE_32( ( error = efap_init_data_fx( &( st_ivas->hEFAPdata ), st_ivas->hLsSetupCustom->ls_azimuth_fx, st_ivas->hLsSetupCustom->ls_elevation_fx, st_ivas->hLsSetupCustom->num_spk, EFAP_MODE_EFAP ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
-
- st_ivas->nSCE = 0;
- move16();
- st_ivas->nCPE = MC_PARAMUPMIX_MAX_TRANSPORT_CHANS >> 1;
- move16();
- st_ivas->nCPE_old = 0;
- move16();
- st_ivas->nchan_transport = MC_PARAMUPMIX_MAX_TRANSPORT_CHANS;
- move16();
-
- IF( NE_32( ( error = ivas_mc_paramupmix_dec_open( st_ivas ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- st_ivas->element_mode_init = IVAS_CPE_MDCT;
- 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( st_ivas->nchan_transport, 1 ), &res_dec, &res_frac, 0 );
- IF( NE_32( ( error = create_cpe_dec( st_ivas, cpe_id, L_shl( res_dec, 1 ) ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- FOR( n = 0; n < CPE_CHANNELS; n++ )
- {
- reset_indices_dec( st_ivas->hCPE[cpe_id]->hCoreCoder[n] );
- }
- }
-
- IF( NE_32( ( error = create_mct_dec_fx( st_ivas ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
- ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMMC ) )
- {
- /* init EFAP for custom LS setup */
- IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
- {
- IF( NE_32( ( error = efap_init_data_fx( &( st_ivas->hEFAPdata ), st_ivas->hLsSetupCustom->ls_azimuth_fx, st_ivas->hLsSetupCustom->ls_elevation_fx, st_ivas->hLsSetupCustom->num_spk, EFAP_MODE_EFAP ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
- IF( NE_32( ( error = ivas_param_mc_dec_open_fx( st_ivas ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- st_ivas->hParamMC->proto_matrix_int_e = 0;
- move16();
- FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
- {
- Word32 res_dec, res_frac;
- iDiv_and_mod_32( ivas_total_brate, add( st_ivas->nSCE, st_ivas->nCPE ), &res_dec, &res_frac, 0 );
-
- IF( NE_32( ( error = create_cpe_dec( st_ivas, cpe_id, res_dec ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- FOR( n = 0; n < CPE_CHANNELS; n++ )
- {
- reset_indices_dec( st_ivas->hCPE[cpe_id]->hCoreCoder[n] );
- }
- }
-
- IF( GT_16( st_ivas->nCPE, 1 ) )
- {
- IF( NE_32( ( error = create_mct_dec_fx( st_ivas ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
- }
- ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_MCMASA ) )
- {
- Word32 brate_sce, brate_cpe;
-
- ivas_mcmasa_setNumTransportChannels_fx( &( st_ivas->nchan_transport ), &( st_ivas->element_mode_init ), ivas_total_brate );
-
- IF( NE_32( ( error = ivas_qmetadata_open_fx( &( st_ivas->hQMetaData ) ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- IF( NE_32( ( error = ivas_masa_dec_open_fx( st_ivas ) ), IVAS_ERR_OK ) )
-
- {
- return error;
- }
-
- st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas );
- move16();
- test();
- IF( NE_32( st_ivas->renderer_type, RENDERER_DISABLE ) && NE_32( st_ivas->renderer_type, RENDERER_MCMASA_MONO_STEREO ) )
- {
- IF( NE_32( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_OPEN ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
- test();
- test();
- IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && st_ivas->hOutSetup.separateChannelEnabled && !st_ivas->hLsSetupCustom->separate_ch_found )
- {
- /* If no speaker matching the separated channel, compute panning gains for the separated channel. */
- IF( st_ivas->hVBAPdata == NULL )
- {
- /* Distribute signal to all channels if VBAP is not properly initialized. */
- Word16 inv_sqr, sqr, exp = 15, exp_sqr;
- move16();
- IF( EQ_16( st_ivas->hLsSetupCustom->num_spk, 1 ) )
- {
- inv_sqr = 32767; // (1.0f in Q15)-1
- move16();
- }
- ELSE
- {
- sqr = Sqrt16( st_ivas->hLsSetupCustom->num_spk, &exp );
- inv_sqr = BASOP_Util_Divide1616_Scale( 32767, sqr, &exp_sqr );
- exp_sqr = sub( exp_sqr, exp );
- IF( ( exp < 0 ) )
- {
- inv_sqr = shr( inv_sqr, exp ); // exp_sqr
- }
- ELSE
- {
- inv_sqr = shl( inv_sqr, exp ); // exp_sqr
- }
- }
- set16_fx( st_ivas->hLsSetupCustom->separate_ch_gains_fx, inv_sqr, st_ivas->hLsSetupCustom->num_spk );
- }
- }
-
-
- ivas_mcmasa_split_brate_fx( st_ivas->hOutSetup.separateChannelEnabled, ivas_total_brate, st_ivas->nSCE, st_ivas->nCPE, &brate_sce, &brate_cpe );
-
- FOR( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ )
- {
- IF( NE_32( ( error = create_sce_dec( st_ivas, sce_id, brate_sce ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- reset_indices_dec( st_ivas->hSCE[sce_id]->hCoreCoder[0] );
- }
-
- FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
- {
- st_ivas->element_mode_init = IVAS_CPE_MDCT; /* element_mode_init was IVAS_SCE for SCE initialization */
- move16();
- IF( NE_32( ( error = create_cpe_dec( st_ivas, cpe_id, brate_cpe ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- FOR( n = 0; n < CPE_CHANNELS; n++ )
- {
- reset_indices_dec( st_ivas->hCPE[cpe_id]->hCoreCoder[n] );
- }
- }
-
- /* create CPE element for DFT Stereo like upmix */
- IF( st_ivas->sba_dirac_stereo_flag )
- {
- Word32 res_dec, res_frac;
- iDiv_and_mod_32( ivas_total_brate, add( st_ivas->nSCE, st_ivas->nCPE ), &res_dec, &res_frac, 0 );
- IF( NE_32( ( error = create_cpe_dec( st_ivas, cpe_id, res_dec ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- st_ivas->hCPE[0]->hCoreCoder[0] = st_ivas->hSCE[0]->hCoreCoder[0]; /* don't allocate unnecessary core coder, simply point to core coder of SCE element */
- st_ivas->hCPE[0]->hCoreCoder[1] = NULL;
- }
-
- /* set CNA/CNG flags */
- test();
- test();
- IF( EQ_16( st_ivas->nchan_transport, 1 ) && ( ( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) ) )
- {
- st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag = 1;
- move16();
- st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag = 1;
- move16();
- }
- }
- }
-
-
- /*-----------------------------------------------------------------*
- * Allocate and initialize HP20 filter memories
- *-----------------------------------------------------------------*/
-
- /* set number of output channels used for synthesis/decoding */
- n = getNumChanSynthesis( st_ivas );
-
- IF( n > 0 )
- {
- IF( ( st_ivas->mem_hp20_out_fx = (Word32 **) malloc( n * sizeof( Word32 * ) ) ) == NULL )
- {
- return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HP20 filter memory\n" ) );
- }
- }
- ELSE
- {
- st_ivas->mem_hp20_out_fx = NULL;
- }
-
- FOR( i = 0; i < n; i++ )
- {
- IF( ( st_ivas->mem_hp20_out_fx[i] = (Word32 *) malloc( ( L_HP20_MEM + 2 ) * sizeof( Word32 ) ) ) == NULL )
- {
- return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HP20 filter memory\n" ) );
- }
- set32_fx( st_ivas->mem_hp20_out_fx[i], 0, L_HP20_MEM + 2 );
- }
-
- /*-------------------------------------------------------------------*
- * Allocate and initialize rendering handles
- *--------------------------------------------------------------------*/
- test();
- test();
- test();
- test();
- test();
- test();
- IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) )
- {
- IF( NE_32( ( error = ivas_binRenderer_open_fx( st_ivas ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
- /* ParamISM is handled separately from other common config */
- ELSE IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) && ( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) || EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) ) )
- {
- IF( NE_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) )
- {
- IF( NE_32( ( error = ivas_dirac_dec_binaural_copy_hrtfs_fx( &st_ivas->hHrtfParambin ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
-
- IF( NE_32( ( error = ivas_dirac_dec_init_binaural_data_fx( st_ivas, st_ivas->hHrtfParambin ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
- ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_OBJECTS_TD ) )
- {
- Word16 SrcInd[MAX_NUM_TDREND_CHANNELS];
- Word16 num_src;
- IF( NE_32( ( error = ivas_td_binaural_open_fx( st_ivas, SrcInd, &num_src ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- Word16 nchan_rend = num_src;
- move16();
- test();
- IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) && NE_32( st_ivas->transport_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
- {
- nchan_rend = sub( nchan_rend, 1 ); /* Skip LFE channel -- added to the others */
- }
- FOR( Word16 nS = 0; nS < nchan_rend; nS++ )
- {
- TDREND_SRC_t *Src_p = st_ivas->hBinRendererTd->Sources[SrcInd[nS]];
- if ( Src_p->SrcSpatial_p != NULL )
- {
- Src_p->SrcSpatial_p->q_Pos_p = Q31;
- move16();
- }
- TDREND_SRC_SPATIAL_t *SrcSpatial_p = st_ivas->hBinRendererTd->Sources[nS]->SrcSpatial_p;
- SrcSpatial_p->q_Pos_p = Q31;
- move16();
- }
-
- IF( EQ_32( st_ivas->hIntSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) )
- {
- IF( NE_32( ( error = ivas_reverb_open_fx( &st_ivas->hReverb, st_ivas->hDecoderConfig->output_config, NULL, st_ivas->hBinRendererTd->HrFiltSet_p->lr_energy_and_iac_fx, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
-
- granularity = NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES );
-
- n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas );
-
-
- IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_RENDERER, n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, granularity ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
- ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_MC ) )
- {
- IF( NE_32( ( error = ivas_ls_setup_conversion_open_fx( st_ivas ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
- ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_MONO_DOWNMIX ) )
- {
- IF( NE_32( ( error = ivas_mono_dmx_renderer_open( st_ivas ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
- ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) )
- {
- test();
- test();
- test();
- IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) && EQ_32( st_ivas->ivas_format, MC_FORMAT ) && ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) )
- {
- IF( NE_32( ( error = efap_init_data_fx( &( st_ivas->hEFAPdata ), st_ivas->hIntSetup.ls_azimuth_fx, st_ivas->hIntSetup.ls_elevation_fx, st_ivas->hIntSetup.nchan_out_woLFE, EFAP_MODE_EFAP ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
-
- IF( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config,
- st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs ) ),
- IVAS_ERR_OK ) )
- {
- return error;
- }
-
- st_ivas->binaural_latency_ns = st_ivas->hCrendWrapper->binaural_latency_ns;
- move32();
-
- test();
- IF( ( EQ_32( st_ivas->ivas_format, MC_FORMAT ) ) && ( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) ) )
- {
- granularity = NS2SA_FX2( output_Fs, CLDFB_SLOT_NS );
-
- n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas );
-
-
- IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_RENDERER, n_channels_transport_jbm, MC_PARAMUPMIX_MAX_INPUT_CHANS, MC_PARAMUPMIX_MAX_INPUT_CHANS, granularity ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
- ELSE
- {
- granularity = NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES );
-
- n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas );
-
- IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_RENDERER, n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, granularity ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
- }
-
- IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) )
- {
- test();
- IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) && EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) )
- {
- /* Allocate TD renderer for the objects in DISC mode */
- Word16 SrcInd[MAX_NUM_TDREND_CHANNELS];
- Word16 num_src;
- IF( NE_32( ( error = ivas_td_binaural_open_fx( st_ivas, SrcInd, &num_src ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- Word16 nchan_rend = num_src;
- move16();
- test();
- if ( EQ_32( st_ivas->ivas_format, MC_FORMAT ) && NE_32( st_ivas->transport_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
- {
- nchan_rend = sub( nchan_rend, 1 ); /* Skip LFE channel -- added to the others */
- }
- FOR( Word16 nS = 0; nS < nchan_rend; nS++ )
- {
- TDREND_SRC_t *Src_p = st_ivas->hBinRendererTd->Sources[SrcInd[nS]];
- if ( Src_p->SrcSpatial_p != NULL )
- {
- Src_p->SrcSpatial_p->q_Pos_p = Q31;
- move16();
- }
- TDREND_SRC_SPATIAL_t *SrcSpatial_p = st_ivas->hBinRendererTd->Sources[nS]->SrcSpatial_p;
- SrcSpatial_p->q_Pos_p = Q31;
- move16();
- }
-
- /* Allocate 'hIsmRendererData' handle and memory for delay buffer within 'hMasaIsmData' */
- IF( NE_32( ( error = ivas_omasa_separate_object_renderer_open( st_ivas ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
-
- test();
- test();
- test();
- IF( EQ_32( st_ivas->renderer_type, RENDERER_DIRAC ) && ( 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 ) ) )
- {
- /* Allocate 'hIsmRendererData' handle and memory for delay buffer within 'hMasaIsmData' */
- IF( NE_32( ( error = ivas_omasa_separate_object_renderer_open( st_ivas ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
- }
-
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- IF( ( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) || EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) &&
- ( EQ_32( st_ivas->ism_mode, ISM_MODE_DISC ) || EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) &&
- ( EQ_32( st_ivas->renderer_type, RENDERER_TD_PANNING ) ||
- EQ_32( st_ivas->renderer_type, RENDERER_NON_DIEGETIC_DOWNMIX ) ||
- EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ||
- EQ_32( st_ivas->renderer_type, RENDERER_OSBA_STEREO ) ||
- EQ_32( st_ivas->renderer_type, RENDERER_OSBA_AMBI ) ||
- EQ_32( st_ivas->renderer_type, RENDERER_OSBA_LS ) ||
- EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) ||
- EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ||
- EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) )
- {
- IF( NE_32( ( error = ivas_ism_renderer_open_fx( st_ivas ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
-
- IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) )
- {
- test();
- test();
- IF( ( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) ) && EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) )
- {
- /* Allocate TD renderer for the objects in DISC mode */
- Word16 SrcInd[MAX_NUM_TDREND_CHANNELS];
- Word16 num_src;
- IF( NE_32( ( error = ivas_td_binaural_open_fx( st_ivas, SrcInd, &num_src ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- Word16 nchan_rend = num_src;
- move16();
-
- test();
- if ( EQ_32( st_ivas->ivas_format, MC_FORMAT ) && NE_32( st_ivas->transport_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
- {
- nchan_rend = sub( nchan_rend, 1 ); /* Skip LFE channel -- added to the others */
- }
- FOR( Word16 nS = 0; nS < nchan_rend; nS++ )
- {
- TDREND_SRC_t *Src_p = st_ivas->hBinRendererTd->Sources[SrcInd[nS]];
- if ( Src_p->SrcSpatial_p != NULL )
- {
- Src_p->SrcSpatial_p->q_Pos_p = Q31;
- move16();
- }
- TDREND_SRC_SPATIAL_t *SrcSpatial_p = st_ivas->hBinRendererTd->Sources[nS]->SrcSpatial_p;
- SrcSpatial_p->q_Pos_p = Q31;
- move16();
- }
- }
- }
-
- /*-----------------------------------------------------------------*
- * LFE handles for rendering after rendering to adjust LFE delay to binaural filter delay
- *-----------------------------------------------------------------*/
- test();
- IF( EQ_32( st_ivas->mc_mode, MC_MODE_MCT ) || EQ_32( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) )
- {
- binauralization_delay_ns = st_ivas->binaural_latency_ns;
- move32();
- IF( st_ivas->hBinRenderer != NULL )
- {
- IF( st_ivas->hBinRenderer->render_lfe )
- {
- {
- /* Account for filterbank delay */
- binauralization_delay_ns = L_add( binauralization_delay_ns, IVAS_FB_DEC_DELAY_NS );
- }
- }
- ELSE
- {
- binauralization_delay_ns = 0;
- move32();
- }
- }
-
- IF( NE_32( ( error = ivas_create_lfe_dec_fx( &st_ivas->hLFE, output_Fs, binauralization_delay_ns ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- set32_fx( st_ivas->hLFE->prevsynth_buf_fx, 0, LFE_PLC_BUFLEN );
- set32_fx( st_ivas->hLFE->prior_out_buffer_fx, 0, L_FRAME48k );
- }
-
- /*-----------------------------------------------------------------*
- * CLDFB handles for rendering
- *-----------------------------------------------------------------*/
-
- ivas_init_dec_get_num_cldfb_instances_ivas_fx( st_ivas, &numCldfbAnalyses, &numCldfbSyntheses );
-
- FOR( i = 0; i < numCldfbAnalyses; i++ )
- {
- IF( NE_32( ( error = openCldfb_ivas_fx( &( st_ivas->cldfbAnaDec[i] ), CLDFB_ANALYSIS, output_Fs, CLDFB_PROTOTYPE_5_00MS, DEC ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
- FOR( ; i < MAX_INTERN_CHANNELS; i++ )
- {
- st_ivas->cldfbAnaDec[i] = NULL;
- }
-
- FOR( i = 0; i < numCldfbSyntheses; i++ )
- {
- IF( NE_32( ( error = openCldfb_ivas_fx( &( st_ivas->cldfbSynDec[i] ), CLDFB_SYNTHESIS, output_Fs, CLDFB_PROTOTYPE_5_00MS, DEC ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
- FOR( ; i < MAX_OUTPUT_CHANNELS; i++ )
- {
- st_ivas->cldfbSynDec[i] = NULL;
- }
-
- /* CLDFB Interpolation weights */
- test();
- test();
- test();
- IF( ( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) || EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) && !st_ivas->sba_dirac_stereo_flag && NE_16( st_ivas->hDecoderConfig->nchan_out, 1 ) )
- {
- Word16 Q_cldfbSynDec = Q11;
- move16();
- ivas_spar_get_cldfb_gains_fx( st_ivas->hSpar, st_ivas->cldfbAnaDec[0], st_ivas->cldfbSynDec[0], hDecoderConfig );
-
- FOR( i = 0; i < st_ivas->cldfbAnaDec[0]->cldfb_state_length; i++ )
- {
- st_ivas->cldfbAnaDec[0]->cldfb_state_fx[i] = L_shr( st_ivas->cldfbAnaDec[0]->cldfb_state_fx[i], 16 ); // Scaling down from 27 to 11
- move32();
- }
- st_ivas->cldfbAnaDec[0]->Q_cldfb_state = Q11;
- move16();
- FOR( i = 0; i < st_ivas->cldfbSynDec[0]->cldfb_state_length; i++ )
- {
- st_ivas->cldfbSynDec[0]->cldfb_state_fx[i] = L_shr( st_ivas->cldfbSynDec[0]->cldfb_state_fx[i], sub( 21, Q_cldfbSynDec ) ); // Scaling down from 21 to Q_cldfbSynDec
- move32();
- }
- st_ivas->cldfbSynDec[0]->Q_cldfb_state = Q11;
- move16();
- }
-
- /*-----------------------------------------------------------------*
- * Allocate and initialize limiter struct
- *-----------------------------------------------------------------*/
-
- IF( NE_32( ( error = ivas_limiter_open_fx( &st_ivas->hLimiter, hDecoderConfig->nchan_out, output_Fs ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- /*-----------------------------------------------------------------*
- * Allocate and initialize JBM struct + buffer
- *-----------------------------------------------------------------*/
-
- IF( st_ivas->hTcBuffer == NULL )
-
- {
- /* no module has yet open the TC buffer, open a default one */
- n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas );
-
- IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, ivas_jbm_dec_get_tc_buffer_mode( st_ivas ), n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
-
- IF( st_ivas->hTcBuffer == NULL )
- {
- /* we need the handle anyway, but without the buffer*/
- IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_NONE, 0, 0, 0, 1 ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
-
- IF( st_ivas->hJbmMetadata == NULL )
- {
- IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
- {
- IF( NE_32( ( error = ivas_jbm_dec_metadata_open( st_ivas ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
- }
-
- /*-----------------------------------------------------------------*
- * Allocate floating-point output audio buffers
- *-----------------------------------------------------------------*/
- st_ivas->p_out_len = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate );
- move16();
- FOR( n = 0; n < ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); n++ )
- {
- /* note: these are intra-frame heap memories */
- IF( ( st_ivas->p_output_fx[n] = (Word32 *) malloc( ( 48000 / FRAMES_PER_SEC ) * sizeof( Word32 ) ) ) == NULL )
- {
- return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for floating-point output audio buffer!\n" ) );
- }
- set32_fx( st_ivas->p_output_fx[n], 0, 48000 / FRAMES_PER_SEC );
- }
-
- FOR( ; n < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; n++ )
- {
- st_ivas->p_output_fx[n] = NULL;
- }
- return error;
-}
-
-/*-------------------------------------------------------------------------
- * destroy_core_dec()
- *
- * Close core decoder handles
- *-------------------------------------------------------------------------*/
-
-void destroy_core_dec_fx(
- DEC_CORE_HANDLE hCoreCoder /* i/o: core decoder structure */
-)
-{
- IF( EQ_16( hCoreCoder->element_mode, EVS_MONO ) )
- {
- destroy_cldfb_decoder_fx( hCoreCoder );
- }
- ELSE
- {
- destroy_cldfb_decoder_ivas_fx( hCoreCoder );
- }
-
- IF( hCoreCoder->hGSCDec != NULL )
- {
- free( hCoreCoder->hGSCDec );
- hCoreCoder->hGSCDec = NULL;
- }
-
- IF( hCoreCoder->hPFstat != NULL )
- {
- free( hCoreCoder->hPFstat );
- hCoreCoder->hPFstat = NULL;
- }
-
- IF( hCoreCoder->hMusicPF != NULL )
- {
- free( hCoreCoder->hMusicPF );
- hCoreCoder->hMusicPF = NULL;
- }
-
- IF( hCoreCoder->hBPF != NULL )
- {
- free( hCoreCoder->hBPF );
- hCoreCoder->hBPF = NULL;
- }
-
- IF( hCoreCoder->hBWE_zero != NULL )
- {
- free( hCoreCoder->hBWE_zero );
- hCoreCoder->hBWE_zero = NULL;
- }
-
- IF( hCoreCoder->hTdCngDec != NULL )
- {
- free( hCoreCoder->hTdCngDec );
- hCoreCoder->hTdCngDec = NULL;
- }
-
- IF( hCoreCoder->hSC_VBR != NULL )
- {
- free( hCoreCoder->hSC_VBR );
- hCoreCoder->hSC_VBR = NULL;
- }
-
- IF( hCoreCoder->hAmrwb_IO != NULL )
- {
- free( hCoreCoder->hAmrwb_IO );
- hCoreCoder->hAmrwb_IO = NULL;
- }
-
- IF( hCoreCoder->hBWE_TD != NULL )
- {
- free( hCoreCoder->hBWE_TD );
- hCoreCoder->hBWE_TD = NULL;
- }
-
- IF( hCoreCoder->hBWE_FD != NULL )
- {
- free( hCoreCoder->hBWE_FD );
- hCoreCoder->hBWE_FD = NULL;
- }
-
- IF( hCoreCoder->hBWE_FD_HR != NULL )
- {
- free( hCoreCoder->hBWE_FD_HR );
- hCoreCoder->hBWE_FD_HR = NULL;
- }
-
- IF( hCoreCoder->hWIDec != NULL )
- {
- free( hCoreCoder->hWIDec );
- hCoreCoder->hWIDec = NULL;
- }
-
- IF( hCoreCoder->hTECDec != NULL )
- {
- free( hCoreCoder->hTECDec );
- hCoreCoder->hTECDec = NULL;
- }
-
- IF( hCoreCoder->hTcxLtpDec != NULL )
- {
- free( hCoreCoder->hTcxLtpDec );
- hCoreCoder->hTcxLtpDec = NULL;
- }
-
- IF( hCoreCoder->hTcxDec != NULL )
- {
- free( hCoreCoder->hTcxDec );
- hCoreCoder->hTcxDec = NULL;
- }
-
- IF( hCoreCoder->hTcxCfg != NULL )
- {
- free( hCoreCoder->hTcxCfg );
- hCoreCoder->hTcxCfg = NULL;
- }
-
- IF( hCoreCoder->hTonalMDCTConc != NULL )
- {
- free( hCoreCoder->hTonalMDCTConc );
- hCoreCoder->hTonalMDCTConc = NULL;
- }
-
- IF( hCoreCoder->hIGFDec != NULL )
- {
- free( hCoreCoder->hIGFDec );
- hCoreCoder->hIGFDec = NULL;
- }
-
- IF( hCoreCoder->hPlcInfo != NULL )
- {
- free( hCoreCoder->hPlcInfo );
- hCoreCoder->hPlcInfo = NULL;
- }
-
- IF( hCoreCoder->hHQ_core != NULL )
- {
- free( hCoreCoder->hHQ_core );
- hCoreCoder->hHQ_core = NULL;
- }
-
- IF( hCoreCoder->hHQ_nbfec != NULL )
- {
- free( hCoreCoder->hHQ_nbfec );
- hCoreCoder->hHQ_nbfec = NULL;
- }
-
- return;
-}
-
-/*-------------------------------------------------------------------------
- * ivas_initialize_handles_dec()
- *
- * NULL initialization of handles
- *-------------------------------------------------------------------------*/
-
-void ivas_initialize_handles_dec(
- Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
-)
-{
- Word16 i;
-
- FOR( i = 0; i < MAX_INTERN_CHANNELS; i++ )
- {
- st_ivas->cldfbAnaDec[i] = NULL;
- }
-
- FOR( i = 0; i < MAX_OUTPUT_CHANNELS; i++ )
- {
- st_ivas->cldfbSynDec[i] = NULL;
- }
-
- /* SCE handles */
- FOR( i = 0; i < MAX_SCE; i++ )
- {
- st_ivas->hSCE[i] = NULL;
- }
-
- /* CPE handles */
- FOR( i = 0; i < MAX_CPE; i++ )
- {
- st_ivas->hCPE[i] = NULL;
- }
-
- st_ivas->bit_stream = NULL;
- st_ivas->mem_hp20_out_fx = NULL;
- st_ivas->hLimiter = NULL;
-
- /* ISM metadata handles */
- FOR( i = 0; i < MAX_NUM_OBJECTS; i++ )
- {
- st_ivas->hIsmMetaData[i] = NULL;
- }
-
- /* spatial coding handles */
- st_ivas->hDirAC = NULL;
- st_ivas->hParamIsmDec = NULL;
- st_ivas->hSpar = NULL;
- st_ivas->hMasa = NULL;
- st_ivas->hQMetaData = NULL;
- st_ivas->hMCT = NULL;
- st_ivas->hMCParamUpmix = NULL;
- st_ivas->hParamMC = NULL;
- st_ivas->hLFE = NULL;
-
- /* rendering handles */
- st_ivas->hBinRenderer = NULL;
- st_ivas->hDiracDecBin = NULL;
- st_ivas->hDirACRend = NULL;
- st_ivas->hSpatParamRendCom = NULL;
- st_ivas->hLsSetUpConversion = NULL;
- st_ivas->hEFAPdata = NULL;
- st_ivas->hVBAPdata = NULL;
- st_ivas->hIsmRendererData = NULL;
- st_ivas->hBinRendererTd = NULL;
- st_ivas->hMonoDmxRenderer = NULL;
- st_ivas->hCrendWrapper = NULL;
- st_ivas->hReverb = NULL;
- st_ivas->hSetOfHRTF = NULL;
- st_ivas->hHrtfFastConv = NULL;
- st_ivas->hHrtfParambin = NULL;
- st_ivas->hoa_dec_mtx = NULL;
- st_ivas->hMasaIsmData = NULL;
- st_ivas->hSbaIsmData = NULL;
-
- st_ivas->hHeadTrackData = NULL;
- st_ivas->hHrtfTD = NULL;
- st_ivas->hLsSetupCustom = NULL;
- st_ivas->hRenderConfig = NULL;
- st_ivas->hExtOrientationData = NULL;
- st_ivas->hCombinedOrientationData = NULL;
-
-
- /* JBM handles */
- st_ivas->hTcBuffer = NULL;
- st_ivas->hJbmMetadata = NULL;
-
- /* floating-point output audio buffers */
- FOR( i = 0; i < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; i++ )
- {
- st_ivas->p_output_fx[i] = NULL;
- }
-
- return;
-}
-
-
-/*-------------------------------------------------------------------------
- * ivas_destroy_dec()
- *
- * Close IVAS decoder handles
- *-------------------------------------------------------------------------*/
-
-void ivas_destroy_dec_fx(
- Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */
-)
-{
- Word16 i;
-
- /* CLDFB handles */
- FOR( i = 0; i < MAX_INTERN_CHANNELS; i++ )
- {
- IF( st_ivas->cldfbAnaDec[i] != NULL )
- {
- deleteCldfb_ivas_fx( &( st_ivas->cldfbAnaDec[i] ) );
- }
- }
-
- FOR( i = 0; i < MAX_OUTPUT_CHANNELS; i++ )
- {
- IF( st_ivas->cldfbSynDec[i] != NULL )
- {
- deleteCldfb_ivas_fx( &( st_ivas->cldfbSynDec[i] ) );
- }
- }
-
- /* SCE handles */
- FOR( i = 0; i < MAX_SCE; i++ )
- {
- IF( st_ivas->hSCE[i] != NULL )
- {
- destroy_sce_dec( st_ivas->hSCE[i] );
- st_ivas->hSCE[i] = NULL;
- }
- }
-
- /* CPE handles */
- FOR( i = 0; i < MAX_CPE; i++ )
- {
- IF( st_ivas->hCPE[i] != NULL )
- {
- /* set pointer to NULL as core coder already deallocated in destroy_sce_dec() */
- test();
- IF( st_ivas->sba_dirac_stereo_flag && EQ_16( st_ivas->nchan_transport, 1 ) )
- {
- st_ivas->hCPE[i]->hCoreCoder[0] = NULL;
- st_ivas->hCPE[i]->hCoreCoder[1] = NULL;
- }
- destroy_cpe_dec( st_ivas->hCPE[i] );
- st_ivas->hCPE[i] = NULL;
- }
- }
-
- /* HP20 filter handles */
- IF( st_ivas->mem_hp20_out_fx != NULL )
- {
- FOR( i = 0; i < getNumChanSynthesis( st_ivas ); i++ )
- {
- free( st_ivas->mem_hp20_out_fx[i] );
- st_ivas->mem_hp20_out_fx[i] = NULL;
- }
- free( st_ivas->mem_hp20_out_fx );
- st_ivas->mem_hp20_out_fx = NULL;
- }
-
- /* ISM metadata handles */
- ivas_ism_metadata_close( st_ivas->hIsmMetaData, 0 );
-
- /* ISM renderer handle */
- ivas_ism_renderer_close( &( st_ivas->hIsmRendererData ) );
-
- /* DirAC handle */
- IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) )
- {
- ivas_param_ism_dec_close_fx( &( st_ivas->hParamIsmDec ), &( st_ivas->hSpatParamRendCom ), st_ivas->hDecoderConfig->output_config );
- }
- ELSE
- {
- ivas_dirac_rend_close_fx( &( st_ivas->hDirACRend ) );
- ivas_spat_hSpatParamRendCom_close_fx( &( st_ivas->hSpatParamRendCom ) );
- ivas_dirac_dec_close_fx( &( st_ivas->hDirAC ) );
- }
-
- /* SPAR handle */
- ivas_spar_dec_close_fx( &( st_ivas->hSpar ), st_ivas->hDecoderConfig->output_Fs, 0 );
-
- /* HOA decoder matrix */
- IF( st_ivas->hoa_dec_mtx != NULL )
- {
- free( st_ivas->hoa_dec_mtx );
- st_ivas->hoa_dec_mtx = NULL;
- }
-
- /* MASA decoder structure */
-
- ivas_masa_dec_close_fx( &( st_ivas->hMasa ) );
- /* Qmetadata handle */
- ivas_qmetadata_close_fx( &st_ivas->hQMetaData );
-
- /* MCT handle */
- ivas_mct_dec_close( &st_ivas->hMCT );
-
- /* LFE handle */
- ivas_lfe_dec_close_fx( &( st_ivas->hLFE ) );
-
- /* Param-Upmix MC handle */
- ivas_mc_paramupmix_dec_close( &( st_ivas->hMCParamUpmix ) );
-
- /* Parametric MC handle */
- ivas_param_mc_dec_close_fx( &st_ivas->hParamMC );
-
- /* EFAP handle */
- efap_free_data_fx( &st_ivas->hEFAPdata );
-
- /* VBAP handle */
- vbap_free_data_fx( &( st_ivas->hVBAPdata ) );
- /* Fastconv binaural renderer handle */
- ivas_binRenderer_close_fx( &st_ivas->hBinRenderer );
-
- /* Parametric binaural renderer handle */
- ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin );
-
- /* Crend handle */
-
- ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ) );
-
- /* Reverb handle */
- ivas_reverb_close( &st_ivas->hReverb );
-
- /* LS config converter handle */
-
- ivas_ls_setup_conversion_close_fx( &st_ivas->hLsSetUpConversion );
- /* Custom LS configuration handle */
- IF( st_ivas->hLsSetupCustom != NULL )
- {
- free( st_ivas->hLsSetupCustom );
- st_ivas->hLsSetupCustom = NULL;
- }
-
- /* Mono downmix structure */
- ivas_mono_dmx_renderer_close( &st_ivas->hMonoDmxRenderer );
-
- /* OSBA structure */
-
- ivas_osba_data_close_fx( &st_ivas->hSbaIsmData );
-
- /* OMASA structure */
- ivas_omasa_data_close_fx( &st_ivas->hMasaIsmData );
- /* Head track data handle */
- ivas_headTrack_close_fx( &st_ivas->hHeadTrackData );
-
- /* External orientation data handle */
- ivas_external_orientation_close_fx( &st_ivas->hExtOrientationData );
-
- /* Combined orientation data handle */
- ivas_combined_orientation_close_fx( &st_ivas->hCombinedOrientationData );
-
- /* Time Domain binaural renderer handle */
- IF( st_ivas->hBinRendererTd != NULL )
- {
- ivas_td_binaural_close_fx( &st_ivas->hBinRendererTd );
- }
- ELSE IF( st_ivas->hHrtfTD != NULL )
- {
- BSplineModelEvalDealloc_fx( &st_ivas->hHrtfTD->ModelParams, &st_ivas->hHrtfTD->ModelEval );
- ivas_HRTF_binary_close_fx( &st_ivas->hHrtfTD );
- }
-
- /* CRend binaural renderer handle */
- ivas_HRTF_CRend_binary_close_fx( &st_ivas->hSetOfHRTF );
-
- /* Fastconv HRTF memories */
- ivas_binaural_hrtf_close( &st_ivas->hHrtfFastConv );
-
- /* Fastconv HRTF filters */
- ivas_HRTF_fastconv_binary_close_fx( &st_ivas->hHrtfFastConv );
-
- /* Parametric binauralizer HRTF filters */
- ivas_HRTF_parambin_binary_close_fx( &st_ivas->hHrtfParambin );
-
- /* Config. Renderer */
- ivas_render_config_close( &( st_ivas->hRenderConfig ) );
-
- /* Limiter struct */
- ivas_limiter_close_fx( &( st_ivas->hLimiter ) );
-
- IF( st_ivas->hDecoderConfig != NULL )
- {
- free( st_ivas->hDecoderConfig );
- st_ivas->hDecoderConfig = NULL;
- }
-
- ivas_jbm_dec_tc_buffer_close( &st_ivas->hTcBuffer );
-
- IF( st_ivas->hJbmMetadata != NULL )
- {
- free( st_ivas->hJbmMetadata );
- st_ivas->hJbmMetadata = NULL;
- }
-
- /* floating-point output audio buffers */
- FOR( i = 0; i < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; i++ )
- {
-
- IF( st_ivas->p_output_fx[i] != NULL )
- {
- free( st_ivas->p_output_fx[i] );
- st_ivas->p_output_fx[i] = NULL;
- }
- }
-
- /* main IVAS handle */
- free( st_ivas );
-
- return;
-}
-
-
-/*-------------------------------------------------------------------*
- * ivas_init_dec_get_num_cldfb_instances()
- *
- * Return number of CLDFB analysis & synthesis instances
- *-------------------------------------------------------------------*/
-
-/*! r: number of cldfb instances */
-void ivas_init_dec_get_num_cldfb_instances(
- Decoder_Struct *st_ivas, /* i : IVAS decoder structure */
- Word16 *numCldfbAnalyses, /* o : number of needed CLDFB analysis instances */
- Word16 *numCldfbSyntheses /* o : number of needed CLDFB synthesis instances */
-)
-{
- IVAS_FORMAT ivas_format;
- *numCldfbAnalyses = st_ivas->nchan_transport;
- move16();
- *numCldfbSyntheses = st_ivas->hDecoderConfig->nchan_out;
- move16();
-
- test();
- IF( ( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_MODE_NONE ) ) )
- {
- ivas_format = SBA_FORMAT;
- move32();
- }
- ELSE
- {
- ivas_format = st_ivas->ivas_format;
- move32();
- }
-
- SWITCH( st_ivas->renderer_type )
- {
- case RENDERER_BINAURAL_PARAMETRIC:
- case RENDERER_BINAURAL_PARAMETRIC_ROOM:
- case RENDERER_STEREO_PARAMETRIC:
- IF( EQ_16( st_ivas->nchan_transport, 1 ) )
- {
- *numCldfbAnalyses = add( st_ivas->nchan_transport, 1 );
- move16();
- }
-
- test();
- IF( EQ_32( st_ivas->mc_mode, MC_MODE_MCMASA ) && st_ivas->hOutSetup.separateChannelEnabled )
- {
- *numCldfbAnalyses = add( st_ivas->nchan_transport, 1 );
- move16();
- }
-
- IF( EQ_32( ivas_format, SBA_ISM_FORMAT ) )
- {
- IF( EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) )
- {
- *numCldfbAnalyses = add( *numCldfbAnalyses, st_ivas->nchan_ism );
- move16();
- }
- }
-
- IF( EQ_32( ivas_format, MASA_ISM_FORMAT ) )
- {
- test();
- IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) )
- {
- *numCldfbAnalyses = add( *numCldfbAnalyses, st_ivas->nchan_ism );
- move16();
- }
- ELSE 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 ) )
- {
- *numCldfbAnalyses = add( st_ivas->nchan_transport, 1 );
- move16();
- }
- }
- IF( st_ivas->hDiracDecBin->useTdDecorr )
- {
- *numCldfbAnalyses = add( *numCldfbAnalyses, 2 );
- move16();
- }
- BREAK;
- case RENDERER_NON_DIEGETIC_DOWNMIX:
- case RENDERER_MONO_DOWNMIX:
- test();
- test();
- IF( EQ_32( ivas_format, ISM_FORMAT ) || EQ_32( ivas_format, MASA_ISM_FORMAT ) || EQ_32( ivas_format, SBA_ISM_FORMAT ) )
- {
- /* CLDFB not used in rendering */
- *numCldfbAnalyses = 0;
- move16();
- *numCldfbSyntheses = 0;
- move16();
- }
- BREAK;
- case RENDERER_DIRAC:
- IF( EQ_32( ivas_format, SBA_FORMAT ) )
- {
- *numCldfbAnalyses = st_ivas->hSpar->hFbMixer->fb_cfg->num_in_chans;
- move16();
-
- test();
- IF( st_ivas->hOutSetup.is_loudspeaker_setup && EQ_32( st_ivas->renderer_type, RENDERER_DIRAC ) )
- {
- *numCldfbSyntheses = st_ivas->hOutSetup.nchan_out_woLFE;
- move16();
- }
- ELSE IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_FOA ) )
- {
- *numCldfbSyntheses = st_ivas->hSpar->hFbMixer->fb_cfg->num_out_chans;
- move16();
- }
- ELSE
- {
- *numCldfbSyntheses = MAX_OUTPUT_CHANNELS;
- move16();
- }
- }
- IF( NE_32( ivas_format, SBA_FORMAT ) )
- {
- test();
- test();
- IF( GT_16( st_ivas->nchan_transport, 2 ) && ( st_ivas->sba_planar != 0 ) )
- {
- *numCldfbAnalyses = add( st_ivas->nchan_transport, 1 );
- move16();
- }
- ELSE IF( EQ_16( st_ivas->nchan_transport, 1 ) && EQ_32( st_ivas->hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) )
- {
- *numCldfbAnalyses = add( st_ivas->nchan_transport, 1 );
- move16();
- }
- }
- BREAK;
- case RENDERER_MC_PARAMMC:
- IF( LE_16( st_ivas->hDecoderConfig->nchan_out, 2 ) )
- {
- /* CLDFB not used in rendering */
- *numCldfbAnalyses = 0;
- move16();
- *numCldfbSyntheses = 0;
- move16();
- }
- ELSE
- {
- *numCldfbSyntheses = param_mc_get_num_cldfb_syntheses_fx( st_ivas );
- move16();
- }
- BREAK;
- case RENDERER_PARAM_ISM:
- /* Already correct with no exception */
- BREAK;
- case RENDERER_DISABLE:
- /* CLDFB not used */
- *numCldfbAnalyses = 0;
- move16();
- *numCldfbSyntheses = 0;
- move16();
- BREAK;
- case RENDERER_MC:
- case RENDERER_SBA_LINEAR_DEC:
- case RENDERER_TD_PANNING:
- case RENDERER_BINAURAL_OBJECTS_TD:
- case RENDERER_MCMASA_MONO_STEREO:
- case RENDERER_BINAURAL_MIXER_CONV:
- case RENDERER_BINAURAL_MIXER_CONV_ROOM:
- case RENDERER_BINAURAL_FASTCONV:
- case RENDERER_BINAURAL_FASTCONV_ROOM:
- case RENDERER_OSBA_STEREO:
- case RENDERER_OSBA_AMBI:
- case RENDERER_OSBA_LS:
- test();
- IF( EQ_32( ivas_format, SBA_FORMAT ) || EQ_32( ivas_format, SBA_ISM_FORMAT ) )
- {
- IF( st_ivas->sba_dirac_stereo_flag != 0 )
- {
- *numCldfbAnalyses = 0;
- move16();
- *numCldfbSyntheses = 0;
- move16();
- }
- ELSE
- {
- *numCldfbAnalyses = st_ivas->hSpar->hFbMixer->fb_cfg->num_in_chans;
- move16();
-
- test();
- IF( st_ivas->hOutSetup.is_loudspeaker_setup && EQ_32( st_ivas->renderer_type, RENDERER_DIRAC ) )
- {
- *numCldfbSyntheses = st_ivas->hOutSetup.nchan_out_woLFE;
- move16();
- }
- ELSE IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_FOA ) )
- {
- *numCldfbSyntheses = st_ivas->hSpar->hFbMixer->fb_cfg->num_out_chans;
- move16();
- }
- ELSE
- {
- *numCldfbSyntheses = MAX_OUTPUT_CHANNELS;
- move16();
- }
- test();
- IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) )
- {
- *numCldfbAnalyses = add( st_ivas->nchan_ism, st_ivas->hSpar->hFbMixer->fb_cfg->num_in_chans );
- move16();
- }
- }
- }
- ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMMC ) )
- {
- /* do nothing for ParamMC */
- }
- ELSE
- {
- /* CLDFB not used in rendering */
- *numCldfbAnalyses = 0;
- move16();
- *numCldfbSyntheses = 0;
- move16();
- }
- BREAK;
- case RENDERER_SBA_LINEAR_ENC:
- IF( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMMC ) )
- {
- *numCldfbSyntheses = param_mc_get_num_cldfb_syntheses_fx( st_ivas );
- move16();
- }
- ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) )
- {
- *numCldfbSyntheses = add( st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hIntSetup.num_lfe );
- move16();
- }
- ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_MCMASA ) )
- {
- *numCldfbAnalyses = st_ivas->nchan_transport;
- move16();
- *numCldfbSyntheses = add( st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hIntSetup.num_lfe );
- move16();
- }
- ELSE
- {
- /* CLDFB not used in rendering */
- *numCldfbAnalyses = 0;
- move16();
- *numCldfbSyntheses = 0;
- move16();
- }
- BREAK;
- default:
- assert( 0 && "Renderer not handled for CLDFB reservation." );
- }
- test();
- test();
- IF( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) && NE_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_MONO ) && NE_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) )
- {
- test();
- test();
- IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) || EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) )
- {
- *numCldfbAnalyses = s_max( MC_PARAMUPMIX_MAX_INPUT_CHANS, *numCldfbAnalyses );
- move16();
- }
- ELSE
- {
- *numCldfbAnalyses = s_max( MC_PARAMUPMIX_MIN_CLDFB, *numCldfbAnalyses );
- move16();
- }
- *numCldfbSyntheses = s_max( MC_PARAMUPMIX_MIN_CLDFB, *numCldfbSyntheses );
- move16();
- }
-
- return;
-}
-
-
-/*---------------------------------------------------------------------*
- * doSanityChecks_IVAS()
- *
- * Sanity checks - verify if the decoder set-up parameters are
- * not in conflict with the IVAS format
- *---------------------------------------------------------------------*/
-
-static ivas_error doSanityChecks_IVAS(
- Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
-)
-{
- Word32 output_Fs;
- AUDIO_CONFIG output_config;
-
- output_Fs = st_ivas->hDecoderConfig->output_Fs;
- move32();
- output_config = st_ivas->hDecoderConfig->output_config;
- move32();
- /*-----------------------------------------------------------------*
- * Sanity checks
- *-----------------------------------------------------------------*/
-
- IF( EQ_32( output_Fs, 8000 ) )
- {
- return IVAS_ERROR( IVAS_ERR_INVALID_SAMPLING_RATE, "8kHz output sampling rate is not supported in IVAS." );
- }
-
- assert( st_ivas->ivas_format != UNDEFINED_FORMAT && "\n IVAS format undefined" );
- assert( st_ivas->ivas_format != MONO_FORMAT && "\n Wrong IVAS format: MONO" );
-
- /* Verify output configuration compatible with non-diegetic panning */
- test();
- test();
- IF( st_ivas->hDecoderConfig->Opt_non_diegetic_pan && NE_32( st_ivas->ivas_format, MONO_FORMAT ) && NE_32( st_ivas->transport_config, IVAS_AUDIO_CONFIG_ISM1 ) )
- {
- return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Error: Non-diegetic panning not supported in this IVAS format" );
- }
-
- /* Verify stereo output configuration */
- IF( EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) )
- {
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- IF( NE_32( output_config, IVAS_AUDIO_CONFIG_MONO ) && NE_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) && NE_32( output_config, IVAS_AUDIO_CONFIG_5_1 ) && NE_32( output_config, IVAS_AUDIO_CONFIG_7_1 ) && NE_32( output_config, IVAS_AUDIO_CONFIG_5_1_2 ) && NE_32( output_config, IVAS_AUDIO_CONFIG_5_1_4 ) && NE_32( output_config, IVAS_AUDIO_CONFIG_7_1_4 ) && NE_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
- {
- return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Wrong output configuration specified for Stereo!" );
- }
- }
- ELSE IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) )
- {
- /* Verify ISM output configuration */
- IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_INVALID ) )
- {
- return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Incorrect output configuration specified for ISM" );
- }
- }
- ELSE IF( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) )
- {
- /* Verify SBA output coniguration */
- IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_INVALID ) )
- {
- return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Incorrect output configuration specified for SBA" );
- }
- }
- ELSE IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) )
- {
- IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_INVALID ) )
- {
- return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Incorrect output configuration specified for MASA!" );
- }
- }
- ELSE IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) )
- {
- /* Verify MC output configuration */
- test();
- IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_INVALID ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
- {
- return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Incorrect output configuration specified for Multi-channel" );
- }
- }
-
-
- IF( st_ivas->hDecoderConfig->Opt_Headrotation )
- {
- test();
- test();
- IF( !( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) )
- {
- return IVAS_ERROR( IVAS_ERR_HEAD_ROTATION_NOT_SUPPORTED, "Wrong set-up: Head-rotation not supported in this configuration" );
- }
- }
-
- IF( st_ivas->hDecoderConfig->Opt_ExternalOrientation )
- {
- test();
- test();
- IF( !( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) )
- {
- return IVAS_ERROR( IVAS_ERR_EXT_ORIENTATION_NOT_SUPPORTED, "Wrong set-up: External orientation not supported in this configuration" );
- }
- }
-
- IF( st_ivas->hDecoderConfig->Opt_dpid_on )
- {
- test();
- IF( !( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) )
- {
- return IVAS_ERROR( IVAS_ERR_DIRECTIVITY_NOT_SUPPORTED, "Wrong set-up: Directivity is not supported in this output configuration." );
- }
- }
-
- IF( st_ivas->hDecoderConfig->Opt_aeid_on )
- {
- IF( NE_16( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) )
- {
- return IVAS_ERROR( IVAS_ERR_ACOUSTIC_ENVIRONMENT_NOT_SUPPORTED, "Wrong set-up: Acoustic environment is not supported in this output configuration." );
- }
- }
-
- IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) )
- {
- test();
- IF( NE_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) && EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
- {
-
- return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Incorrect output configuration specified for combined MASA and ISM format" );
- }
- }
-
-
- return IVAS_ERR_OK;
-}
diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c
index ecd38aabe5cf2884d5365bd9aa09da56f1671310..463bc22fc5b242666573f76b1f26a46c9e79db62 100644
--- a/lib_dec/ivas_init_dec_fx.c
+++ b/lib_dec/ivas_init_dec_fx.c
@@ -1,4 +1,3120 @@
+/******************************************************************************************************
+
+ (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
+ Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
+ Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
+ contributors to this repository. All Rights Reserved.
+
+ This software is protected by copyright law and by international treaties.
+ The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
+ Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
+ Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
+ Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
+ contributors to this repository retain full ownership rights in their respective contributions in
+ the software. This notice grants no license of any kind, including but not limited to patent
+ license, nor is any license granted by implication, estoppel or otherwise.
+
+ Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
+ contributions.
+
+ This software is provided "AS IS", without any express or implied warranties. The software is in the
+ development stage. It is intended exclusively for experts who have experience with such software and
+ solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
+ and fitness for a particular purpose are hereby disclaimed and excluded.
+
+ Any dispute, controversy or claim arising under or in relation to providing this software shall be
+ submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
+ accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
+ the United Nations Convention on Contracts on the International Sales of Goods.
+
+*******************************************************************************************************/
+
+#include
+#include
+#include
+#include "options.h"
+#include "ivas_cnst.h"
+#include "ivas_prot_rend_fx.h"
+#include "rom_com.h"
+#include "ivas_rom_com.h"
+#include "ivas_stat_enc.h"
+#include "prot_fx.h"
+#include "wmc_auto.h"
#include "ivas_prot_fx.h"
+
+
+/*-------------------------------------------------------------------*
+ * Local function prototypes
+ *-------------------------------------------------------------------*/
+
+static ivas_error ivas_read_format( Decoder_Struct *st_ivas, Word16 *num_bits_read );
+
+static ivas_error doSanityChecks_IVAS( Decoder_Struct *st_ivas );
+
+
+/*-------------------------------------------------------------------*
+ * ivas_dec_setup()
+ *
+ * IVAS decoder setup
+ *-------------------------------------------------------------------*/
+
+ivas_error ivas_dec_setup(
+ Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
+ UWord16 *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */
+ Word16 *data /* o : output synthesis signal */
+)
+{
+ Word16 k, idx, num_bits_read;
+ Word16 nchan_ism, element_mode_flag;
+ Decoder_State *st;
+ Word32 ivas_total_brate;
+ ivas_error error;
+
+ error = IVAS_ERR_OK;
+ move32();
+ num_bits_read = 0;
+ move16();
+ element_mode_flag = 0;
+ move16();
+
+ ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate;
+ move32();
+
+ /*-------------------------------------------------------------------*
+ * Read IVAS format
+ *-------------------------------------------------------------------*/
+
+ ivas_read_format( st_ivas, &num_bits_read );
+
+ Word16 SrcInd[MAX_NUM_TDREND_CHANNELS];
+ Word16 num_src = 0;
+ move16();
+
+ /*-------------------------------------------------------------------*
+ * Read other signling (ISM/MC mode, number of channels, etc.)
+ *-------------------------------------------------------------------*/
+
+ IF( is_DTXrate( ivas_total_brate ) == 0 )
+ {
+ /*-------------------------------------------------------------------*
+ * Read IVAS format related signaling:
+ * - in ISM : read number of objects
+ * - in SBA : read SBA planar flag and SBA order
+ * - in MASA : read number of TC
+ * - in MC : read LS setup
+ *-------------------------------------------------------------------*/
+
+ IF( EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) )
+ {
+ element_mode_flag = 1;
+ move16();
+ }
+ ELSE IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) )
+ {
+ /* read the number of objects */
+ st_ivas->nchan_transport = 1;
+ move16();
+ nchan_ism = 1;
+ move16();
+ Word32 res_dec, res_frac;
+ iDiv_and_mod_32( ivas_total_brate, FRAMES_PER_SEC, &res_dec, &res_frac, 0 );
+ k = extract_l( L_sub( res_dec, 1 ) );
+
+ WHILE( st_ivas->bit_stream[k] && ( nchan_ism < MAX_NUM_OBJECTS ) )
+ {
+ nchan_ism = add( nchan_ism, 1 );
+ k = sub( k, 1 );
+ }
+
+ st_ivas->nchan_ism = nchan_ism;
+ move16();
+
+ IF( NE_32( ( error = ivas_ism_dec_config_fx( st_ivas, st_ivas->ism_mode, nSamplesRendered, data ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+ ELSE IF( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) )
+ {
+ /* read Ambisonic (SBA) planar flag */
+ st_ivas->sba_planar = st_ivas->bit_stream[num_bits_read];
+ move16();
+ num_bits_read = add( num_bits_read, SBA_PLANAR_BITS );
+
+ /* read Ambisonic (SBA) order */
+ st_ivas->sba_order = st_ivas->bit_stream[num_bits_read + 1];
+ move16();
+ st_ivas->sba_order = add( st_ivas->sba_order, shl( st_ivas->bit_stream[num_bits_read], 1 ) );
+ move16();
+ num_bits_read = add( num_bits_read, SBA_ORDER_BITS );
+ test();
+ test();
+ IF( st_ivas->ini_frame > 0 && NE_32( ivas_total_brate, st_ivas->last_active_ivas_total_brate ) && GT_32( ivas_total_brate, IVAS_SID_5k2 ) )
+ {
+ IF( NE_32( ( error = ivas_sba_dec_reconfigure_fx( st_ivas, nSamplesRendered, data ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+ ELSE
+ {
+ /* set Ambisonic (SBA) order used for analysis and coding */
+ st_ivas->sba_analysis_order = ivas_sba_get_analysis_order_fx( ivas_total_brate, st_ivas->sba_order );
+ move16();
+ ivas_sba_config_fx( ivas_total_brate, st_ivas->sba_analysis_order, -1, &( st_ivas->nchan_transport ), st_ivas->sba_planar, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->element_mode_init );
+ }
+ }
+ ELSE IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) )
+ {
+ /* read number of MASA transport channels */
+ Word32 res_dec, res_frac;
+ iDiv_and_mod_32( ivas_total_brate, FRAMES_PER_SEC, &res_dec, &res_frac, 0 );
+ IF( st_ivas->bit_stream[res_dec - 1] )
+ {
+ st_ivas->nchan_transport = 2;
+ move16();
+ element_mode_flag = 1;
+ move16();
+ }
+ ELSE
+ {
+ st_ivas->nchan_transport = 1;
+ move16();
+ }
+
+ IF( st_ivas->ini_frame > 0 )
+ {
+ /* reconfigure in case a change of operation mode is detected */
+ test();
+ test();
+ IF( ( GT_32( ivas_total_brate, IVAS_SID_5k2 ) && NE_32( ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate ) ) || ( st_ivas->ini_active_frame == 0 ) )
+ {
+ IF( EQ_32( st_ivas->last_ivas_format, MASA_FORMAT ) )
+ {
+ test();
+ test();
+ test();
+ IF( ( st_ivas->ini_active_frame == 0 ) && NE_32( ivas_total_brate, FRAME_NO_DATA ) && LT_32( ivas_total_brate, MASA_STEREO_MIN_BITRATE ) && EQ_16( st_ivas->nCPE, 1 ) )
+ {
+ st_ivas->hCPE[0]->nchan_out = 1;
+ move16();
+ }
+ ELSE
+ {
+ IF( NE_32( ( error = ivas_masa_dec_reconfigure_fx( st_ivas, nSamplesRendered, data ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+ }
+ ELSE
+ {
+ IF( NE_32( ( error = ivas_omasa_dec_config_fx( st_ivas, nSamplesRendered, &num_src, SrcInd, data ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+ }
+ }
+ }
+ ELSE IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) )
+ {
+ st_ivas->nchan_transport = 2; /* always 2 MASA transport channels */
+ move16();
+ /* for the DISC mode the number of objects are written at the end of the bitstream, in the MASA metadata */
+
+ Word32 res_dec, res_frac;
+ iDiv_and_mod_32( ivas_total_brate, FRAMES_PER_SEC, &res_dec, &res_frac, 0 );
+ st_ivas->nchan_ism = add( add( shl( st_ivas->bit_stream[res_dec - 1], 1 ), st_ivas->bit_stream[res_dec - 2] ), 1 );
+ move16();
+ st_ivas->ism_mode = ivas_omasa_ism_mode_select_fx( ivas_total_brate, st_ivas->nchan_ism );
+ move16();
+ IF( st_ivas->ini_frame > 0 )
+ {
+ /* reconfigure in case a change of operation mode is detected */
+ test();
+ test();
+ IF( ( GT_32( ivas_total_brate, IVAS_SID_5k2 ) && NE_32( ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate ) ) || ( st_ivas->ini_active_frame == 0 ) )
+ {
+ IF( NE_32( ( error = ivas_omasa_dec_config_fx( st_ivas, nSamplesRendered, &num_src, SrcInd, data ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+ }
+ }
+ ELSE IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) )
+ {
+ /* the number of objects is written at the end of the bitstream, in the SBA metadata */
+ Word32 res_dec, res_frac;
+ iDiv_and_mod_32( ivas_total_brate, FRAMES_PER_SEC, &res_dec, &res_frac, 0 );
+ st_ivas->nchan_ism = add( add( shl( st_ivas->bit_stream[res_dec - 1], 1 ), st_ivas->bit_stream[res_dec - 2] ), 1 );
+ move16();
+
+ test();
+ IF( LT_32( ivas_total_brate, IVAS_24k4 ) || GE_32( ivas_total_brate, IVAS_256k ) )
+ {
+ /* read Ambisonic (SBA) planar flag */
+ st_ivas->sba_planar = st_ivas->bit_stream[num_bits_read];
+ move16();
+ num_bits_read = add( num_bits_read, SBA_PLANAR_BITS );
+ }
+
+ st_ivas->sba_order = st_ivas->bit_stream[num_bits_read + 1];
+ move16();
+ st_ivas->sba_order = add( st_ivas->sba_order, shl( st_ivas->bit_stream[num_bits_read], 1 ) );
+ move16();
+ num_bits_read = add( num_bits_read, SBA_ORDER_BITS );
+
+ /* read Ambisonic (SBA) order */
+ if ( LT_32( ivas_total_brate, IVAS_256k ) )
+ {
+ st_ivas->sba_order = 3;
+ move16();
+ }
+
+ test();
+ IF( st_ivas->ini_frame > 0 && NE_32( ivas_total_brate, st_ivas->last_active_ivas_total_brate ) )
+ {
+ IF( NE_32( ( error = ivas_sba_dec_reconfigure_fx( st_ivas, nSamplesRendered, data ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+ ELSE
+ {
+ /* set Ambisonic (SBA) order used for analysis and coding */
+ st_ivas->sba_analysis_order = ivas_sba_get_analysis_order_fx( ivas_total_brate, st_ivas->sba_order );
+ move16();
+
+ ivas_sba_config_fx( ivas_total_brate, st_ivas->sba_analysis_order, -1, &( st_ivas->nchan_transport ), st_ivas->sba_planar, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->element_mode_init );
+
+ /*correct number of CPEs for discrete ISM coding*/
+ test();
+ IF( st_ivas->ini_frame > 0 && EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) )
+ {
+ st_ivas->nCPE = add( st_ivas->nCPE, shr( add( st_ivas->nchan_ism, 1 ), 1 ) );
+ move16();
+ }
+ }
+
+ IF( GE_32( ivas_total_brate, IVAS_256k ) )
+ {
+ st_ivas->ism_mode = ISM_SBA_MODE_DISC;
+ move32();
+ }
+ ELSE
+ {
+ st_ivas->ism_mode = ISM_MODE_NONE;
+ move32();
+ }
+ }
+ ELSE IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) )
+ {
+ /* read MC configuration */
+ idx = 0;
+ move16();
+ FOR( k = 0; k < MC_LS_SETUP_BITS; k++ )
+ {
+ IF( st_ivas->bit_stream[num_bits_read + k] )
+ {
+ idx = add( idx, shl( 1, sub( ( MC_LS_SETUP_BITS - 1 ), k ) ) );
+ }
+ }
+ num_bits_read = add( num_bits_read, MC_LS_SETUP_BITS );
+
+ /* select MC format mode; reconfigure the MC format decoder */
+ IF( NE_32( ( error = ivas_mc_dec_config_fx( st_ivas, idx, nSamplesRendered, data ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+
+ /*-------------------------------------------------------------------*
+ * Read element mode
+ *-------------------------------------------------------------------*/
+
+ IF( st_ivas->ini_frame == 0 && element_mode_flag )
+ {
+ /* read stereo technology info */
+ IF( LT_32( ivas_total_brate, MIN_BRATE_MDCT_STEREO ) )
+ {
+ /* 1 bit */
+ IF( st_ivas->bit_stream[num_bits_read] )
+ {
+ st_ivas->element_mode_init = add( 1, IVAS_CPE_DFT );
+ move16();
+ }
+ ELSE
+ {
+ st_ivas->element_mode_init = add( 0, IVAS_CPE_DFT );
+ move16();
+ }
+ }
+ ELSE
+ {
+ st_ivas->element_mode_init = IVAS_CPE_MDCT;
+ move16();
+ }
+ }
+ }
+ ELSE IF( EQ_32( ivas_total_brate, IVAS_SID_5k2 ) )
+ {
+ SWITCH( st_ivas->sid_format )
+ {
+ case SID_DFT_STEREO:
+ st_ivas->element_mode_init = IVAS_CPE_DFT;
+ move16();
+ BREAK;
+ case SID_MDCT_STEREO:
+ st_ivas->element_mode_init = IVAS_CPE_MDCT;
+ move16();
+ BREAK;
+ case SID_ISM:
+ st_ivas->element_mode_init = IVAS_SCE;
+ move16();
+ BREAK;
+ case SID_MASA_1TC:
+ st_ivas->element_mode_init = IVAS_SCE;
+ move16();
+ st_ivas->nchan_transport = 1;
+ move16();
+ BREAK;
+ case SID_MASA_2TC:; // empyt statement for declaration
+ Word32 res_dec, res_frac;
+ iDiv_and_mod_32( ivas_total_brate, FRAMES_PER_SEC, &res_dec, &res_frac, 0 );
+ IF( EQ_16( st_ivas->bit_stream[( res_dec - 1 ) - SID_FORMAT_NBITS], 1 ) )
+ {
+ st_ivas->element_mode_init = IVAS_CPE_MDCT;
+ move16();
+ }
+ ELSE
+ {
+ st_ivas->element_mode_init = IVAS_CPE_DFT;
+ move16();
+ }
+ st_ivas->nchan_transport = 2;
+ move16();
+ BREAK;
+ case SID_SBA_1TC:
+ st_ivas->element_mode_init = IVAS_SCE;
+ move16();
+ BREAK;
+ case SID_SBA_2TC:
+ st_ivas->element_mode_init = IVAS_CPE_MDCT;
+ move16();
+ BREAK;
+ }
+
+ test();
+ IF( st_ivas->ini_frame > 0 && EQ_32( st_ivas->ivas_format, SBA_FORMAT ) )
+ {
+ Word16 nchan_transport_old, nchan_transport;
+ nchan_transport_old = st_ivas->nchan_transport;
+ move16();
+ IF( ( EQ_16( st_ivas->sid_format, SID_SBA_2TC ) ) )
+ {
+ nchan_transport = 2;
+ }
+ ELSE
+ {
+ nchan_transport = 1;
+ }
+ move16();
+
+ IF( NE_16( nchan_transport_old, nchan_transport ) )
+ {
+ /*Setting the default bitrate for the reconfig function*/
+ IF( EQ_16( st_ivas->sid_format, SID_SBA_2TC ) )
+ {
+ st_ivas->hDecoderConfig->ivas_total_brate = IVAS_48k;
+ move16();
+ }
+ ELSE
+ {
+ st_ivas->hDecoderConfig->ivas_total_brate = IVAS_24k4;
+ move16();
+ }
+
+ IF( NE_32( ( error = ivas_sba_dec_reconfigure_fx( st_ivas, nSamplesRendered, data ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ st_ivas->last_active_ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate;
+ move32();
+ st_ivas->hDecoderConfig->ivas_total_brate = ivas_total_brate;
+ move32();
+ }
+ }
+
+ IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) )
+ {
+ ISM_MODE last_ism_mode = st_ivas->ism_mode;
+ move32();
+ /* read the number of objects */
+ st_ivas->nchan_transport = 1;
+ move16();
+ nchan_ism = 1;
+ move16();
+ Word32 res_dec, res_frac;
+ iDiv_and_mod_32( ivas_total_brate, FRAMES_PER_SEC, &res_dec, &res_frac, 0 );
+ k = extract_l( L_sub( L_sub( res_dec, 1 ), SID_FORMAT_NBITS ) );
+ move16();
+
+ WHILE( st_ivas->bit_stream[k] && ( nchan_ism < MAX_NUM_OBJECTS ) )
+ {
+ nchan_ism = add( nchan_ism, 1 );
+ k = sub( k, 1 );
+ }
+ k = sub( k, 1 );
+
+ test();
+ IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) )
+ {
+ return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "wrong number of objects signalled!" );
+ }
+
+ st_ivas->nchan_ism = nchan_ism;
+ move16();
+ /* read ism_mode */
+ st_ivas->ism_mode = ISM_MODE_DISC;
+ move32();
+ IF( GT_16( nchan_ism, 2 ) )
+ {
+ k = sub( k, nchan_ism ); /* SID metadata flags */
+ idx = st_ivas->bit_stream[k];
+ move16();
+ st_ivas->ism_mode = (ISM_MODE) add( idx, 1 );
+ move32();
+ }
+
+ if ( st_ivas->ini_frame == 0 )
+ {
+ last_ism_mode = st_ivas->ism_mode;
+ move32();
+ }
+
+ IF( NE_32( ( error = ivas_ism_dec_config_fx( st_ivas, last_ism_mode, nSamplesRendered, data ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+ }
+
+ /*-------------------------------------------------------------------*
+ * Initialize decoder in the first good frame based on IVAS format
+ * and number of transport channels
+ *-------------------------------------------------------------------*/
+ test();
+ IF( st_ivas->ini_frame == 0 && NE_32( st_ivas->ivas_format, UNDEFINED_FORMAT ) )
+ {
+ IF( NE_32( ( error = doSanityChecks_IVAS( st_ivas ) ), IVAS_ERR_OK ) )
+ {
+ return IVAS_ERROR( error, "Sanity checks failed" );
+ }
+
+ IF( NE_32( ( error = ivas_init_decoder_fx( st_ivas ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+
+
+ /*----------------------------------------------------------------*
+ * Reset bitstream pointers
+ *----------------------------------------------------------------*/
+
+ ivas_set_bitstream_pointers( st_ivas );
+
+ reset_elements( st_ivas );
+
+ /* update bitstream buffer pointer -> take into account already read bits */
+ test();
+ IF( ( st_ivas->nSCE > 0 ) || ( st_ivas->nCPE > 0 ) )
+ {
+ IF( st_ivas->nSCE > 0 )
+ {
+ st = st_ivas->hSCE[0]->hCoreCoder[0];
+ }
+ ELSE
+ {
+ st = st_ivas->hCPE[0]->hCoreCoder[0];
+ }
+ st->next_bit_pos = num_bits_read;
+ move16();
+ st->total_brate = ACELP_8k00; /* only temporary initialization - this is needed for get_next_indice() in the frame following NO_DATA frame */
+ move32();
+ }
+
+ return error;
+}
+
+
+/*-------------------------------------------------------------------*
+ * ivas_read_format()
+ *
+ * Read IVAS format signaling
+ *-------------------------------------------------------------------*/
+
+static ivas_error ivas_read_format(
+ Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
+ Word16 *num_bits_read /* o : number of IVAS signaling bits read from the bitstream */
+)
+{
+ Word16 k, idx;
+ Word32 ivas_total_brate;
+ ivas_error error;
+
+ error = IVAS_ERR_OK;
+ move32();
+
+ ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate;
+ move32();
+
+ *num_bits_read = 0;
+ move16();
+ test();
+ test();
+ IF( !st_ivas->bfi && is_DTXrate( ivas_total_brate ) == 0 )
+ {
+ /* read IVAS format */
+ k = 0;
+ move16();
+ if ( st_ivas->bit_stream[*num_bits_read] )
+ {
+ k = 1;
+ move16();
+ }
+ k = shl( k, 1 );
+ ( *num_bits_read ) = add( ( *num_bits_read ), 1 );
+ move16();
+ if ( st_ivas->bit_stream[*num_bits_read] )
+ {
+ k = add( k, 1 );
+ }
+ ( *num_bits_read ) = add( ( *num_bits_read ), 1 );
+ move16();
+ SWITCH( k )
+ {
+ case 0:
+ st_ivas->ivas_format = STEREO_FORMAT;
+ move32();
+ BREAK;
+ case 1:
+ st_ivas->ivas_format = MC_FORMAT;
+ move32();
+ BREAK;
+ case 2:
+ st_ivas->ivas_format = ISM_FORMAT;
+ move32();
+
+ IF( GE_32( ivas_total_brate, IVAS_24k4 ) )
+ {
+ IF( st_ivas->bit_stream[*num_bits_read] )
+ {
+ ( *num_bits_read ) = add( ( *num_bits_read ), 1 );
+ move16();
+ IF( st_ivas->bit_stream[*num_bits_read] )
+ {
+ st_ivas->ivas_format = SBA_ISM_FORMAT;
+ move32();
+ }
+ ELSE
+ {
+ st_ivas->ivas_format = MASA_ISM_FORMAT;
+ move32();
+ }
+ }
+
+ ( *num_bits_read ) = add( ( *num_bits_read ), 1 );
+ move16();
+ }
+ BREAK;
+ case 3:
+ IF( st_ivas->bit_stream[*num_bits_read] )
+ {
+ st_ivas->ivas_format = MASA_FORMAT;
+ move32();
+ }
+ ELSE
+ {
+ st_ivas->ivas_format = SBA_FORMAT;
+ move32();
+ /* read Ambisonic (SBA) planar flag */
+ st_ivas->sba_planar = st_ivas->bit_stream[( *num_bits_read ) + 1];
+ move16();
+
+ /* read Ambisonic (SBA) order */
+ st_ivas->sba_order = st_ivas->bit_stream[( *num_bits_read ) + 2 + SBA_PLANAR_BITS];
+ move16();
+ st_ivas->sba_order = add( st_ivas->sba_order, shl( st_ivas->bit_stream[( *num_bits_read ) + 1 + SBA_PLANAR_BITS], 1 ) );
+ move16();
+ if ( st_ivas->sba_order == 0 )
+ {
+ st_ivas->ivas_format = SBA_ISM_FORMAT;
+ move32();
+ }
+ }
+ ( *num_bits_read ) = add( ( *num_bits_read ), 1 );
+ move16();
+
+ BREAK;
+ }
+ }
+ ELSE IF( ( st_ivas->bfi == 0 ) && EQ_32( ivas_total_brate, IVAS_SID_5k2 ) )
+ {
+ /* read IVAS format in SID frame */
+ idx = 0;
+ move16();
+ FOR( k = 0; k < SID_FORMAT_NBITS; k++ )
+ {
+ idx += st_ivas->bit_stream[k] << ( SID_FORMAT_NBITS - 1 - k );
+ }
+
+ ( *num_bits_read ) = add( *num_bits_read, SID_FORMAT_NBITS );
+ move16();
+ st_ivas->sid_format = idx;
+ move16();
+
+ SWITCH( idx )
+ {
+ case SID_DFT_STEREO:
+ case SID_MDCT_STEREO:
+ st_ivas->ivas_format = STEREO_FORMAT;
+ move32();
+ BREAK;
+ case SID_ISM:
+ st_ivas->ivas_format = ISM_FORMAT;
+ move32();
+ BREAK;
+ case SID_MULTICHANNEL:
+ st_ivas->ivas_format = MC_FORMAT;
+ move32();
+ BREAK;
+ case SID_SBA_1TC:
+ st_ivas->ivas_format = SBA_FORMAT;
+ move32();
+ st_ivas->element_mode_init = IVAS_SCE;
+ move16();
+ BREAK;
+ case SID_SBA_2TC:
+ st_ivas->ivas_format = SBA_FORMAT;
+ move32();
+ st_ivas->element_mode_init = IVAS_CPE_MDCT;
+ move16();
+ BREAK;
+ case SID_MASA_1TC:
+ st_ivas->ivas_format = MASA_FORMAT;
+ move32();
+ st_ivas->element_mode_init = IVAS_SCE;
+ move16();
+ BREAK;
+ case SID_MASA_2TC:
+ st_ivas->ivas_format = MASA_FORMAT;
+ move32();
+ Word32 res_dec, res_frac;
+ iDiv_and_mod_32( ivas_total_brate, FRAMES_PER_SEC, &res_dec, &res_frac, 0 );
+ IF( EQ_32( st_ivas->bit_stream[res_dec - 1], 1 ) )
+ {
+ st_ivas->element_mode_init = IVAS_CPE_MDCT;
+ move16();
+ }
+ ELSE
+ {
+ st_ivas->element_mode_init = IVAS_CPE_DFT;
+ move16();
+ }
+ BREAK;
+ default:
+ /* This should actually be impossible, since only 3 bits are read, so if this happens something is broken */
+ return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Invalid value %c found in SID format field.", st_ivas->sid_format );
+ }
+
+ IF( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) )
+ {
+ if ( st_ivas->sba_analysis_order == 0 )
+ {
+ st_ivas->sba_analysis_order = SBA_FOA_ORDER;
+ move16();
+ }
+ }
+
+ /* reset bitstream handle to avoid BER detection after reading the 2400 kbps for ch0 */
+ st_ivas->bit_stream = st_ivas->bit_stream + ( *num_bits_read );
+ ( *num_bits_read ) = 0;
+ move16();
+ }
+ ELSE
+ {
+ /* In SID/NO_DATA frames, use the previous frame IVAS format */
+ }
+
+ return error;
+}
+
+
+/*-------------------------------------------------------------------*
+ * getNumChanSynthesis()
+ *
+ * get number of output channels used for synthesis/decoding
+ * (often different from number of output channels!)
+ *-------------------------------------------------------------------*/
+
+/*! r: number of channels to be synthesised */
+
+Word16 getNumChanSynthesis(
+ Decoder_Struct *st_ivas /* i : IVAS decoder structure */
+)
+{
+ Word16 n;
+
+ n = add( st_ivas->nSCE, imult1616( CPE_CHANNELS, st_ivas->nCPE ) );
+ test();
+ test();
+ IF( st_ivas->sba_dirac_stereo_flag )
+ {
+ n = CPE_CHANNELS;
+ move16();
+ }
+ ELSE IF( ( st_ivas->hMCT != NULL || EQ_32( st_ivas->ivas_format, SBA_FORMAT ) ) && NE_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) )
+ {
+ n = st_ivas->nchan_transport;
+ move16();
+ }
+ ELSE IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) )
+ {
+ IF( EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) )
+ {
+ n = add( st_ivas->nchan_transport, st_ivas->nchan_ism );
+ }
+ ELSE
+ {
+ n = st_ivas->nchan_transport;
+ move16();
+ }
+ }
+
+ return n;
+}
+
+/*-------------------------------------------------------------------*
+ * copy_decoder_config()
+ *
+ * Copy IVAS configuration structure to the CoreCoder state structure
+ *-------------------------------------------------------------------*/
+
+void copy_decoder_config(
+ Decoder_Struct *st_ivas, /* i : IVAS decoder structure */
+ Decoder_State *st /* o : decoder state structure */
+)
+{
+ st->output_Fs = st_ivas->hDecoderConfig->output_Fs;
+ move32();
+ st->Opt_AMR_WB = st_ivas->hDecoderConfig->Opt_AMR_WB;
+ move16();
+ st->codec_mode = st_ivas->codec_mode;
+ move16();
+ st->ini_frame = st_ivas->ini_frame;
+ move16();
+
+ st->bfi = st_ivas->bfi;
+ move16();
+
+ st->writeFECoffset = st_ivas->writeFECoffset;
+ move16();
+
+ st->element_mode = st_ivas->element_mode_init;
+ move16();
+
+ return;
+}
+
+/*-------------------------------------------------------------------*
+ * ivas_init_decoder_front()
+ *
+ * Set decoder parameters to initial values
+ *-------------------------------------------------------------------*/
+ivas_error ivas_init_decoder_front(
+ Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
+)
+{
+ ivas_error error;
+
+ error = IVAS_ERR_OK;
+ move32();
+ /*-----------------------------------------------------------------*
+ * Resets
+ *-----------------------------------------------------------------*/
+
+ st_ivas->nSCE = 0;
+ move16();
+ st_ivas->nCPE = 0;
+ move16();
+ st_ivas->nCPE_old = 0;
+ move16();
+ st_ivas->nchan_transport = -1;
+ move16();
+ st_ivas->ism_mode = ISM_MODE_NONE;
+ move32();
+ st_ivas->mc_mode = MC_MODE_NONE;
+ move32();
+ st_ivas->sba_dirac_stereo_flag = 0;
+ move16();
+
+ /* HRTF binauralization latency in ns */
+ st_ivas->binaural_latency_ns = 0;
+ move32();
+
+ /*-------------------------------------------------------------------*
+ * Allocate and initialize Custom loudspeaker layout handle
+ *--------------------------------------------------------------------*/
+
+ IF( st_ivas->hDecoderConfig->Opt_LsCustom )
+ {
+ IF( EQ_32( ( error = ivas_ls_custom_open_fx( &( st_ivas->hLsSetupCustom ) ) ), IVAS_ERR_OK ) )
+ {
+ set_zero_fx( ( st_ivas->hLsSetupCustom )->ls_azimuth_fx, MAX_OUTPUT_CHANNELS );
+ set_zero_fx( ( st_ivas->hLsSetupCustom )->ls_elevation_fx, MAX_OUTPUT_CHANNELS );
+ }
+ ELSE
+ {
+ return error;
+ }
+ }
+
+ /*-------------------------------------------------------------------*
+ * Allocate and initialize Head-Tracking handle
+ *--------------------------------------------------------------------*/
+
+ IF( st_ivas->hDecoderConfig->Opt_Headrotation )
+ {
+ IF( NE_32( ( error = ivas_headTrack_open_fx( &( st_ivas->hHeadTrackData ) ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ error = ivas_orient_trk_SetTrackingType_fx( st_ivas->hHeadTrackData->OrientationTracker, st_ivas->hDecoderConfig->orientation_tracking );
+ IF( NE_32( ( error ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+ /*-------------------------------------------------------------------*
+ * Allocate and initialize external orientation handle
+ *--------------------------------------------------------------------*/
+
+ IF( st_ivas->hDecoderConfig->Opt_ExternalOrientation )
+ {
+ IF( NE_32( ( error = ivas_external_orientation_open( &( st_ivas->hExtOrientationData ), st_ivas->hDecoderConfig->render_framesize ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+
+ /*-------------------------------------------------------------------*
+ * Allocate and initialize combined orientation handle
+ *--------------------------------------------------------------------*/
+ test();
+ IF( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation )
+ {
+ IF( NE_32( ( error = ivas_combined_orientation_open( &( st_ivas->hCombinedOrientationData ), st_ivas->hDecoderConfig->output_Fs, st_ivas->hDecoderConfig->render_framesize ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+
+ /*-------------------------------------------------------------------*
+ * Allocate HRTF binary handle
+ *--------------------------------------------------------------------*/
+
+ IF( st_ivas->hDecoderConfig->Opt_HRTF_binary )
+ {
+ IF( NE_32( ( error = ivas_HRTF_binary_open_fx( &( st_ivas->hHrtfTD ) ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ IF( NE_32( ( error = ivas_HRTF_CRend_binary_open_fx( &( st_ivas->hSetOfHRTF ) ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ IF( NE_32( ( error = ivas_HRTF_fastconv_binary_open_fx( &st_ivas->hHrtfFastConv ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ IF( NE_32( ( error = ivas_HRTF_parambin_binary_open_fx( &st_ivas->hHrtfParambin ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+
+ /*-------------------------------------------------------------------*
+ * Allocate and initialize Binaural Renderer configuration handle
+ *--------------------------------------------------------------------*/
+ test();
+ test();
+ IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) )
+ {
+ IF( NE_32( ( error = ivas_render_config_open( &( st_ivas->hRenderConfig ) ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ IF( NE_32( ( error = ivas_render_config_init_from_rom_fx( &st_ivas->hRenderConfig ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+
+ return error;
+}
+
+
+/*-------------------------------------------------------------------*
+ * ivas_init_decoder()
+ *
+ * Initialize IVAS decoder state structure
+ *-------------------------------------------------------------------*/
+ivas_error ivas_init_decoder_fx(
+ Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
+)
+{
+ Word16 i, n, k;
+ Word16 sce_id, cpe_id;
+ Word16 numCldfbAnalyses, numCldfbSyntheses;
+ Word16 granularity, n_channels_transport_jbm;
+ Word32 output_Fs, ivas_total_brate;
+ Word32 binauralization_delay_ns;
+ AUDIO_CONFIG output_config;
+ DECODER_CONFIG_HANDLE hDecoderConfig;
+ ivas_error error;
+ Word32 ism_total_brate;
+
+ error = IVAS_ERR_OK;
+ move32();
+ output_Fs = st_ivas->hDecoderConfig->output_Fs;
+ move32();
+ hDecoderConfig = st_ivas->hDecoderConfig;
+ output_config = hDecoderConfig->output_config;
+ ivas_total_brate = hDecoderConfig->ivas_total_brate;
+ move32();
+ hDecoderConfig->last_ivas_total_brate = ivas_total_brate;
+ move32();
+ st_ivas->last_active_ivas_total_brate = ivas_total_brate;
+ move32();
+ /*-----------------------------------------------------------------*
+ * Set number of output channels for EXTERNAL output config.
+ *-----------------------------------------------------------------*/
+
+ IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
+ {
+ IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) )
+ {
+ hDecoderConfig->nchan_out = audioCfg2channels( IVAS_AUDIO_CONFIG_HOA3 );
+ move16();
+ hDecoderConfig->nchan_out = add( hDecoderConfig->nchan_out, st_ivas->nchan_ism );
+ move16();
+ }
+ ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) )
+ {
+ hDecoderConfig->nchan_out = add( st_ivas->nchan_transport, st_ivas->nchan_ism );
+ move16();
+ }
+ ELSE IF( !EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) )
+ {
+ hDecoderConfig->nchan_out = st_ivas->nchan_transport;
+ move16();
+ }
+
+ st_ivas->hOutSetup.nchan_out_woLFE = hDecoderConfig->nchan_out;
+ move16();
+ }
+
+ /*-----------------------------------------------------------------*
+ * Set output and intern setup & renderer selection
+ *-----------------------------------------------------------------*/
+
+ st_ivas->intern_config = output_config;
+ move32();
+ ivas_output_init( &( st_ivas->hOutSetup ), output_config );
+ test();
+ IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) )
+ {
+ st_ivas->hOutSetup.ambisonics_order = SBA_HOA3_ORDER;
+ move16();
+ st_ivas->intern_config = IVAS_AUDIO_CONFIG_7_1_4;
+ move32();
+ st_ivas->hOutSetup.output_config = st_ivas->intern_config;
+ move32();
+ st_ivas->hOutSetup.nchan_out_woLFE = audioCfg2channels( st_ivas->intern_config );
+ move16();
+ }
+ test();
+ IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
+ {
+ st_ivas->hOutSetup.ambisonics_order = SBA_HOA3_ORDER;
+ move32();
+ st_ivas->intern_config = IVAS_AUDIO_CONFIG_HOA3;
+ move32();
+ st_ivas->hOutSetup.output_config = IVAS_AUDIO_CONFIG_HOA3;
+ move32();
+ st_ivas->hOutSetup.nchan_out_woLFE = audioCfg2channels( IVAS_AUDIO_CONFIG_HOA3 );
+ move16();
+ }
+
+ /* Only initialize transport setup if it is used */
+ IF( NE_32( st_ivas->transport_config, IVAS_AUDIO_CONFIG_INVALID ) )
+ {
+ ivas_output_init( &( st_ivas->hTransSetup ), st_ivas->transport_config );
+ }
+
+ test();
+ IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) && EQ_32( st_ivas->mc_mode, MC_MODE_MCMASA ) )
+ {
+ ivas_mcmasa_setNumTransportChannels_fx( &( st_ivas->nchan_transport ), &( st_ivas->element_mode_init ), ivas_total_brate );
+
+ ivas_mcmasa_set_separate_channel_mode_fx( &( st_ivas->hOutSetup.separateChannelEnabled ), &( st_ivas->hOutSetup.separateChannelIndex ), ivas_total_brate );
+ }
+
+ ivas_renderer_select( st_ivas );
+
+ IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
+ {
+ IF( EQ_16( ( error = ivas_ls_custom_output_init_fx( st_ivas ) ), IVAS_ERR_OK ) )
+ {
+ st_ivas->hOutSetup.ls_azimuth_fx = st_ivas->hLsSetupCustom->ls_azimuth_fx;
+ move32();
+ st_ivas->hOutSetup.ls_elevation_fx = st_ivas->hLsSetupCustom->ls_elevation_fx;
+ move32();
+ st_ivas->hIntSetup.ls_azimuth_fx = st_ivas->hLsSetupCustom->ls_azimuth_fx;
+ move32();
+ st_ivas->hIntSetup.ls_elevation_fx = st_ivas->hLsSetupCustom->ls_elevation_fx;
+ move32();
+ }
+ ELSE
+ {
+ return error;
+ }
+ }
+
+ ivas_output_init( &( st_ivas->hIntSetup ), st_ivas->intern_config );
+
+ test();
+ IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) && EQ_32( st_ivas->mc_mode, MC_MODE_MCMASA ) )
+ {
+ ivas_mcmasa_set_separate_channel_mode_fx( &( st_ivas->hIntSetup.separateChannelEnabled ), &( st_ivas->hIntSetup.separateChannelIndex ), ivas_total_brate );
+
+ test();
+ IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && st_ivas->hOutSetup.separateChannelEnabled )
+ {
+ st_ivas->hLsSetupCustom->separate_ch_found = 0;
+ move16();
+ IF( GE_16( st_ivas->hOutSetup.nchan_out_woLFE, MCMASA_MIN_SPEAKERS_SEPARATE_CENTER ) )
+ {
+ /* check for a speaker at (0, 0) if minimum speaker count is available */
+ FOR( i = 0; i < st_ivas->hOutSetup.nchan_out_woLFE; i++ )
+ {
+ test();
+ IF( ( L_shr( st_ivas->hOutSetup.ls_azimuth_fx[i], Q22 ) == 0 ) && ( L_shr( st_ivas->hOutSetup.ls_elevation_fx[i], Q22 ) == 0 ) )
+ {
+ st_ivas->hIntSetup.separateChannelIndex = i;
+ move16();
+ st_ivas->hLsSetupCustom->separate_ch_found = 1;
+ move16();
+ BREAK;
+ }
+ }
+ }
+ }
+ }
+
+
+ /*-----------------------------------------------------------------*
+ * Allocate and initialize SCE/CPE and other handles
+ *-----------------------------------------------------------------*/
+
+ IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) )
+ {
+ st_ivas->nSCE = 1; /* in mono, there is always only one SCE */
+ move16();
+ st_ivas->nCPE = 0;
+ move16();
+ st_ivas->nCPE_old = 0;
+ move16();
+ st_ivas->nchan_transport = 1;
+ move16();
+ sce_id = 0;
+ move16();
+
+ IF( NE_32( ( error = create_sce_dec( st_ivas, sce_id, ivas_total_brate ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ reset_indices_dec( st_ivas->hSCE[sce_id]->hCoreCoder[0] );
+ }
+ ELSE IF( EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) )
+ {
+ st_ivas->nchan_transport = CPE_CHANNELS;
+ move16();
+ st_ivas->intern_config = IVAS_AUDIO_CONFIG_STEREO;
+ move32();
+
+ st_ivas->nSCE = 0;
+ move16();
+ st_ivas->nCPE = 1; /* in stereo, there is always only one CPE */
+ move16();
+ st_ivas->nCPE_old = 0;
+ move16();
+ cpe_id = 0;
+ move16();
+
+ IF( NE_32( ( error = create_cpe_dec( st_ivas, cpe_id, ivas_total_brate ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ FOR( n = 0; n < st_ivas->nchan_transport; n++ )
+ {
+ reset_indices_dec( st_ivas->hCPE[cpe_id]->hCoreCoder[n] );
+ }
+
+ /* init EFAP for custom LS output and set hTransSetup */
+ IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
+ {
+ IF( NE_32( ( error = efap_init_data_fx( &( st_ivas->hEFAPdata ), st_ivas->hOutSetup.ls_azimuth_fx, st_ivas->hOutSetup.ls_elevation_fx, st_ivas->hOutSetup.nchan_out_woLFE, EFAP_MODE_EFAP ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ ivas_output_init( &( st_ivas->hTransSetup ), IVAS_AUDIO_CONFIG_STEREO );
+ }
+ }
+ ELSE IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) )
+ {
+ Word32 element_brate_tmp[MAX_NUM_OBJECTS];
+
+ st_ivas->nSCE = st_ivas->nchan_transport; /* "st_ivas->nchan_transport" is known from ivas_dec_setup */
+ move16();
+ st_ivas->nCPE = 0;
+ move16();
+ st_ivas->nCPE_old = 0;
+ move16();
+ st_ivas->ism_extmeta_active = -1;
+ move16();
+ st_ivas->ism_extmeta_cnt = 0;
+ move16();
+ IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) )
+ {
+ st_ivas->nchan_transport = MAX_PARAM_ISM_WAVE;
+ move16();
+ st_ivas->nSCE = MAX_PARAM_ISM_WAVE;
+ move16();
+
+ IF( NE_32( ( error = ivas_param_ism_dec_open_fx( st_ivas ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+
+ IF( NE_32( ( error = ivas_ism_metadata_dec_create_fx( st_ivas, st_ivas->nSCE, 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_dec( st_ivas, sce_id, element_brate_tmp[sce_id] ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ reset_indices_dec( st_ivas->hSCE[sce_id]->hCoreCoder[0] );
+
+ st_ivas->hSCE[sce_id]->hCoreCoder[0]->is_ism_format = 1;
+ move16();
+ }
+
+ st_ivas->hISMDTX.sce_id_dtx = 0;
+ move16();
+
+ IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) )
+ {
+ st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->seed2 = st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->seed3;
+ move16();
+ }
+ ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MODE_DISC ) )
+ {
+ FOR( sce_id = 0; sce_id < st_ivas->nSCE; ++sce_id )
+ {
+ st_ivas->hSCE[sce_id]->hCoreCoder[0]->hFdCngDec->hFdCngCom->seed2 = add( 2, sce_id );
+ move16();
+ }
+ }
+ }
+ ELSE IF( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) )
+ {
+ IF( NE_32( ( error = ivas_qmetadata_open_fx( &( st_ivas->hQMetaData ) ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ IF( NE_32( ( error = ivas_spar_dec_open_fx( st_ivas, 0 ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ set16_fx( st_ivas->hSpar->hFbMixer->cldfb_cross_fade_fx, 0, CLDFB_NO_COL_MAX );
+ test();
+ IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_DEC ) && st_ivas->hOutSetup.is_loudspeaker_setup )
+ {
+ IF( NE_32( ( error = ivas_sba_get_hoa_dec_matrix_fx( st_ivas->hOutSetup, &st_ivas->hoa_dec_mtx, st_ivas->hIntSetup.ambisonics_order ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+
+ Word16 hodirac_flag = ivas_get_hodirac_flag_fx( ivas_total_brate, st_ivas->sba_analysis_order );
+ IF( hodirac_flag )
+ {
+ IF( NE_32( ( error = ivas_dirac_sba_config_fx( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, IVAS_MAX_NUM_BANDS, st_ivas->ivas_format ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+ ELSE
+ {
+ IF( NE_32( ( error = ivas_dirac_sba_config_fx( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, ( IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ), st_ivas->ivas_format ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+
+
+ test();
+ test();
+ IF( NE_32( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_FOA ) && NE_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) && NE_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_MONO ) )
+ {
+ IF( NE_32( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_OPEN ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ st_ivas->hSpar->enc_param_start_band = st_ivas->hDirAC->hConfig->enc_param_start_band;
+ move16();
+ }
+ ELSE
+ {
+ Word16 band_grouping[IVAS_MAX_NUM_BANDS + 1];
+
+ st_ivas->hSpar->enc_param_start_band = s_min( IVAS_MAX_NUM_BANDS, SPAR_DIRAC_SPLIT_START_BAND );
+ move16();
+ IF( ivas_get_hodirac_flag_fx( ivas_total_brate, st_ivas->sba_analysis_order ) )
+ {
+ st_ivas->hSpar->enc_param_start_band = 0;
+ move16();
+ set8_fx( (Word8 *) st_ivas->hQMetaData->twoDirBands, (Word8) 1, st_ivas->hQMetaData->q_direction[0].cfg.nbands );
+ st_ivas->hQMetaData->numTwoDirBands = (UWord8) st_ivas->hQMetaData->q_direction[0].cfg.nbands;
+ move16();
+ }
+
+ ivas_dirac_config_bands_fx( band_grouping, IVAS_MAX_NUM_BANDS, extract_l( Mpy_32_32_r( st_ivas->hDecoderConfig->output_Fs, INV_CLDFB_BANDWIDTH_Q31 ) ),
+ st_ivas->hSpar->dirac_to_spar_md_bands, st_ivas->hQMetaData->useLowerBandRes, st_ivas->hSpar->enc_param_start_band, 0 );
+ }
+ st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas );
+ move16();
+ FOR( sce_id = 0; sce_id < st_ivas->nSCE; sce_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_sce_dec( st_ivas, sce_id, res_dec ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ reset_indices_dec( st_ivas->hSCE[sce_id]->hCoreCoder[0] );
+ }
+
+ 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_dec( st_ivas, cpe_id, (res_dec) *CPE_CHANNELS ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ FOR( n = 0; n < CPE_CHANNELS; n++ )
+ {
+ reset_indices_dec( st_ivas->hCPE[cpe_id]->hCoreCoder[n] );
+ }
+ }
+
+ /* create CPE element for DFT Stereo like upmix */
+ test();
+ IF( st_ivas->sba_dirac_stereo_flag && ( st_ivas->nCPE == 0 ) )
+ {
+ Word32 res_dec, res_frac;
+ iDiv_and_mod_32( ivas_total_brate, add( st_ivas->nSCE, st_ivas->nCPE ), &res_dec, &res_frac, 0 );
+
+ IF( NE_32( ( error = create_cpe_dec( st_ivas, cpe_id, res_dec ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ st_ivas->hCPE[0]->hCoreCoder[0] = st_ivas->hSCE[0]->hCoreCoder[0]; /* don't allocate unnecessary core coder, simply point to core coder of SCE element */
+ st_ivas->hCPE[0]->hCoreCoder[1] = NULL;
+ }
+
+ IF( GT_16( st_ivas->nCPE, 1 ) )
+ {
+ IF( NE_32( ( error = create_mct_dec_fx( st_ivas ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+
+ /* set CNA/CNG flags */
+ ivas_sba_set_cna_cng_flag( st_ivas );
+ }
+ ELSE IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) )
+ {
+ /* if we start in ISM_MODE_NONE in MASA_ISM, that appears as normal MASA, but we may change to a mode with ISMs */
+ st_ivas->ism_extmeta_active = -1;
+ move16();
+ st_ivas->ism_extmeta_cnt = 0;
+ move16();
+ IF( NE_32( ( error = ivas_qmetadata_open_fx( &( st_ivas->hQMetaData ) ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ IF( NE_32( ( error = ivas_masa_dec_open_fx( st_ivas ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ test();
+ test();
+ test();
+ IF( EQ_32( st_ivas->renderer_type, RENDERER_DIRAC ) || EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) )
+ {
+ IF( NE_32( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_OPEN ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+
+ FOR( sce_id = 0; sce_id < st_ivas->nSCE; sce_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_sce_dec( st_ivas, sce_id, res_dec ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ reset_indices_dec( st_ivas->hSCE[sce_id]->hCoreCoder[0] );
+ }
+
+ 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_dec( st_ivas, cpe_id, L_shl( res_dec, 1 ) ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ FOR( n = 0; n < CPE_CHANNELS; n++ )
+ {
+ reset_indices_dec( st_ivas->hCPE[cpe_id]->hCoreCoder[n] );
+ }
+ }
+
+ /* set CNA/CNG flags */
+ ivas_sba_set_cna_cng_flag( st_ivas );
+ }
+ ELSE IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) )
+ {
+ Word32 temp_brate[MAX_SCE];
+ st_ivas->ism_extmeta_active = -1;
+ move16();
+ st_ivas->ism_extmeta_cnt = 0;
+ move16();
+
+ st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas );
+ move16();
+ IF( NE_32( ( error = ivas_qmetadata_open_fx( &( st_ivas->hQMetaData ) ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ IF( NE_32( ( error = ivas_spar_dec_open_fx( st_ivas, 0 ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ test();
+ IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_DEC ) && st_ivas->hOutSetup.is_loudspeaker_setup )
+ {
+ IF( NE_32( ( error = ivas_sba_get_hoa_dec_matrix_fx( st_ivas->hOutSetup, &st_ivas->hoa_dec_mtx, st_ivas->hIntSetup.ambisonics_order ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+
+ Word16 hodirac_flag = ivas_get_hodirac_flag_fx( ivas_total_brate, st_ivas->sba_analysis_order );
+ IF( hodirac_flag )
+ {
+ IF( NE_32( ( error = ivas_dirac_sba_config_fx( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, IVAS_MAX_NUM_BANDS, st_ivas->ivas_format ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+ ELSE
+ {
+ IF( NE_32( ( error = ivas_dirac_sba_config_fx( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, ( IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ), st_ivas->ivas_format ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+
+
+ test();
+ test();
+ IF( NE_32( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_FOA ) && NE_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) && NE_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_MONO ) )
+ {
+ IF( NE_32( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_OPEN ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ st_ivas->hSpar->enc_param_start_band = st_ivas->hDirAC->hConfig->enc_param_start_band;
+ move16();
+ }
+ ELSE
+ {
+ Word16 band_grouping[IVAS_MAX_NUM_BANDS + 1];
+
+ st_ivas->hSpar->enc_param_start_band = s_min( IVAS_MAX_NUM_BANDS, SPAR_DIRAC_SPLIT_START_BAND );
+ move16();
+ IF( ivas_get_hodirac_flag_fx( ivas_total_brate, st_ivas->sba_analysis_order ) )
+ {
+ st_ivas->hSpar->enc_param_start_band = 0;
+ move16();
+ set8_fx( (Word8 *) st_ivas->hQMetaData->twoDirBands, (Word8) 1, st_ivas->hQMetaData->q_direction[0].cfg.nbands );
+ st_ivas->hQMetaData->numTwoDirBands = (UWord8) st_ivas->hQMetaData->q_direction[0].cfg.nbands;
+ move16();
+ }
+
+ ivas_dirac_config_bands_fx( band_grouping, IVAS_MAX_NUM_BANDS, extract_l( Mpy_32_32_r( st_ivas->hDecoderConfig->output_Fs, INV_CLDFB_BANDWIDTH_Q31 ) ),
+ st_ivas->hSpar->dirac_to_spar_md_bands, st_ivas->hQMetaData->useLowerBandRes, st_ivas->hSpar->enc_param_start_band, 0 );
+ }
+
+ FOR( sce_id = 0; sce_id < st_ivas->nSCE; sce_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_sce_dec( st_ivas, sce_id, res_dec ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ reset_indices_dec( st_ivas->hSCE[sce_id]->hCoreCoder[0] );
+ }
+
+ IF( EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) )
+ {
+ st_ivas->nCPE_old = st_ivas->nCPE;
+ move16();
+ st_ivas->nCPE = add( st_ivas->nCPE, shr( add( st_ivas->nchan_ism, 1 ), 1 ) );
+ move16();
+ st_ivas->element_mode_init = IVAS_CPE_MDCT;
+ move16();
+ }
+
+ 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_dec( st_ivas, cpe_id, L_shl( res_dec, 1 ) ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ FOR( n = 0; n < CPE_CHANNELS; n++ )
+ {
+ reset_indices_dec( st_ivas->hCPE[cpe_id]->hCoreCoder[n] );
+ }
+ }
+
+ /* create CPE element for DFT Stereo like upmix */
+ test();
+ IF( st_ivas->sba_dirac_stereo_flag && st_ivas->nCPE == 0 )
+ {
+ Word32 res_dec, res_frac;
+ iDiv_and_mod_32( ivas_total_brate, add( st_ivas->nSCE, st_ivas->nCPE ), &res_dec, &res_frac, 0 );
+ IF( NE_32( ( error = create_cpe_dec( st_ivas, cpe_id, res_dec ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ st_ivas->hCPE[0]->hCoreCoder[0] = st_ivas->hSCE[0]->hCoreCoder[0]; /* don't allocate unnecessary core coder, simply point to core coder of SCE element */
+ st_ivas->hCPE[0]->hCoreCoder[1] = NULL;
+ }
+
+ IF( GT_16( st_ivas->nCPE, 1 ) )
+ {
+ IF( NE_32( ( error = create_mct_dec_fx( st_ivas ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+
+ IF( EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) )
+ {
+ IF( NE_32( ( error = ivas_ism_metadata_dec_create_fx( st_ivas, st_ivas->nchan_ism, temp_brate ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ IF( NE_32( ( error = ivas_osba_data_open_fx( st_ivas ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+
+ /* set CNA/CNG flags */
+ ivas_sba_set_cna_cng_flag( st_ivas );
+ }
+ ELSE IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) )
+ {
+ st_ivas->ism_extmeta_active = -1;
+ move16();
+ st_ivas->ism_extmeta_cnt = 0;
+ move16();
+
+ IF( NE_32( ( error = ivas_qmetadata_open_fx( &( st_ivas->hQMetaData ) ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ k = 0;
+ move16();
+ ism_total_brate = 0;
+ move32();
+
+ WHILE( ( k < SIZE_IVAS_BRATE_TBL ) && ( ivas_total_brate != ivas_brate_tbl[k] ) )
+ {
+ k = add( k, 1 );
+ }
+ 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 ) )
+ {
+ /* one separated object */
+ st_ivas->nSCE = 1;
+ move16();
+ ism_total_brate = sep_object_brate[k - 2][0];
+ move32();
+ IF( NE_32( ( error = create_sce_dec( st_ivas, 0, ism_total_brate ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ reset_indices_dec( st_ivas->hSCE[0]->hCoreCoder[0] );
+
+ IF( NE_32( ( error = ivas_ism_metadata_dec_create_fx( st_ivas, 1, NULL ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+ ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) )
+ {
+ Word32 temp_brate[MAX_SCE];
+ st_ivas->nSCE = st_ivas->nchan_ism; /* number of objects */
+ move16();
+ FOR( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ )
+ {
+ temp_brate[sce_id] = sep_object_brate[k - 2][st_ivas->nSCE - 1];
+ move32();
+ ism_total_brate = L_add( ism_total_brate, temp_brate[sce_id] );
+
+ IF( NE_32( ( error = create_sce_dec( st_ivas, sce_id, temp_brate[sce_id] ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ reset_indices_dec( st_ivas->hSCE[sce_id]->hCoreCoder[0] );
+ }
+
+ IF( NE_32( ( error = ivas_ism_metadata_dec_create_fx( st_ivas, st_ivas->nchan_ism, temp_brate ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+
+ IF( NE_32( ( error = ivas_masa_dec_open_fx( st_ivas ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ IF( NE_32( ( error = ivas_omasa_data_open_fx( st_ivas ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ test();
+ test();
+ test();
+ IF( EQ_32( st_ivas->renderer_type, RENDERER_DIRAC ) || EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) )
+ {
+ IF( NE_32( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_OPEN ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+
+ IF( NE_32( ( error = create_cpe_dec( st_ivas, 0, ivas_total_brate - ism_total_brate ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ FOR( n = 0; n < CPE_CHANNELS; n++ )
+ {
+ reset_indices_dec( st_ivas->hCPE[0]->hCoreCoder[n] );
+ }
+ }
+ ELSE IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) )
+ {
+ IF( EQ_32( st_ivas->mc_mode, MC_MODE_MCT ) )
+ {
+ /* init EFAP for custom LS setup */
+ IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
+ {
+ IF( NE_32( ( error = efap_init_data_fx( &( st_ivas->hEFAPdata ), st_ivas->hLsSetupCustom->ls_azimuth_fx, st_ivas->hLsSetupCustom->ls_elevation_fx, st_ivas->hLsSetupCustom->num_spk, EFAP_MODE_EFAP ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+
+ st_ivas->nchan_transport = ivas_mc_ls_setup_get_num_channels_fx( ivas_mc_map_output_config_to_mc_ls_setup_fx( st_ivas->transport_config ) );
+ move16();
+ st_ivas->nSCE = 0;
+ move16();
+ st_ivas->nCPE = shr( st_ivas->nchan_transport, 1 );
+ move16();
+ st_ivas->nCPE_old = 0;
+ move16();
+ st_ivas->element_mode_init = IVAS_CPE_MDCT;
+ 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( st_ivas->nchan_transport, 1 ), &res_dec, &res_frac, 0 );
+ IF( NE_32( ( error = create_cpe_dec( st_ivas, cpe_id, L_shl( res_dec, 1 ) ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ FOR( n = 0; n < CPE_CHANNELS; n++ )
+ {
+ reset_indices_dec( st_ivas->hCPE[cpe_id]->hCoreCoder[n] );
+ }
+ }
+
+ IF( NE_32( ( error = create_mct_dec_fx( st_ivas ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+ ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) )
+ {
+ /* init EFAP for custom LS setup */
+ IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
+ {
+ IF( NE_32( ( error = efap_init_data_fx( &( st_ivas->hEFAPdata ), st_ivas->hLsSetupCustom->ls_azimuth_fx, st_ivas->hLsSetupCustom->ls_elevation_fx, st_ivas->hLsSetupCustom->num_spk, EFAP_MODE_EFAP ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+
+ st_ivas->nSCE = 0;
+ move16();
+ st_ivas->nCPE = MC_PARAMUPMIX_MAX_TRANSPORT_CHANS >> 1;
+ move16();
+ st_ivas->nCPE_old = 0;
+ move16();
+ st_ivas->nchan_transport = MC_PARAMUPMIX_MAX_TRANSPORT_CHANS;
+ move16();
+
+ IF( NE_32( ( error = ivas_mc_paramupmix_dec_open( st_ivas ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ st_ivas->element_mode_init = IVAS_CPE_MDCT;
+ 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( st_ivas->nchan_transport, 1 ), &res_dec, &res_frac, 0 );
+ IF( NE_32( ( error = create_cpe_dec( st_ivas, cpe_id, L_shl( res_dec, 1 ) ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ FOR( n = 0; n < CPE_CHANNELS; n++ )
+ {
+ reset_indices_dec( st_ivas->hCPE[cpe_id]->hCoreCoder[n] );
+ }
+ }
+
+ IF( NE_32( ( error = create_mct_dec_fx( st_ivas ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+ ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMMC ) )
+ {
+ /* init EFAP for custom LS setup */
+ IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
+ {
+ IF( NE_32( ( error = efap_init_data_fx( &( st_ivas->hEFAPdata ), st_ivas->hLsSetupCustom->ls_azimuth_fx, st_ivas->hLsSetupCustom->ls_elevation_fx, st_ivas->hLsSetupCustom->num_spk, EFAP_MODE_EFAP ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+ IF( NE_32( ( error = ivas_param_mc_dec_open_fx( st_ivas ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ st_ivas->hParamMC->proto_matrix_int_e = 0;
+ move16();
+ FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
+ {
+ Word32 res_dec, res_frac;
+ iDiv_and_mod_32( ivas_total_brate, add( st_ivas->nSCE, st_ivas->nCPE ), &res_dec, &res_frac, 0 );
+
+ IF( NE_32( ( error = create_cpe_dec( st_ivas, cpe_id, res_dec ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ FOR( n = 0; n < CPE_CHANNELS; n++ )
+ {
+ reset_indices_dec( st_ivas->hCPE[cpe_id]->hCoreCoder[n] );
+ }
+ }
+
+ IF( GT_16( st_ivas->nCPE, 1 ) )
+ {
+ IF( NE_32( ( error = create_mct_dec_fx( st_ivas ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+ }
+ ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_MCMASA ) )
+ {
+ Word32 brate_sce, brate_cpe;
+
+ ivas_mcmasa_setNumTransportChannels_fx( &( st_ivas->nchan_transport ), &( st_ivas->element_mode_init ), ivas_total_brate );
+
+ IF( NE_32( ( error = ivas_qmetadata_open_fx( &( st_ivas->hQMetaData ) ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ IF( NE_32( ( error = ivas_masa_dec_open_fx( st_ivas ) ), IVAS_ERR_OK ) )
+
+ {
+ return error;
+ }
+
+ st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas );
+ move16();
+ test();
+ IF( NE_32( st_ivas->renderer_type, RENDERER_DISABLE ) && NE_32( st_ivas->renderer_type, RENDERER_MCMASA_MONO_STEREO ) )
+ {
+ IF( NE_32( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_OPEN ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+ test();
+ test();
+ IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && st_ivas->hOutSetup.separateChannelEnabled && !st_ivas->hLsSetupCustom->separate_ch_found )
+ {
+ /* If no speaker matching the separated channel, compute panning gains for the separated channel. */
+ IF( st_ivas->hVBAPdata == NULL )
+ {
+ /* Distribute signal to all channels if VBAP is not properly initialized. */
+ Word16 inv_sqr, sqr, exp = 15, exp_sqr;
+ move16();
+ IF( EQ_16( st_ivas->hLsSetupCustom->num_spk, 1 ) )
+ {
+ inv_sqr = 32767; // (1.0f in Q15)-1
+ move16();
+ }
+ ELSE
+ {
+ sqr = Sqrt16( st_ivas->hLsSetupCustom->num_spk, &exp );
+ inv_sqr = BASOP_Util_Divide1616_Scale( 32767, sqr, &exp_sqr );
+ exp_sqr = sub( exp_sqr, exp );
+ IF( ( exp < 0 ) )
+ {
+ inv_sqr = shr( inv_sqr, exp ); // exp_sqr
+ }
+ ELSE
+ {
+ inv_sqr = shl( inv_sqr, exp ); // exp_sqr
+ }
+ }
+ set16_fx( st_ivas->hLsSetupCustom->separate_ch_gains_fx, inv_sqr, st_ivas->hLsSetupCustom->num_spk );
+ }
+ }
+
+
+ ivas_mcmasa_split_brate_fx( st_ivas->hOutSetup.separateChannelEnabled, ivas_total_brate, st_ivas->nSCE, st_ivas->nCPE, &brate_sce, &brate_cpe );
+
+ FOR( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ )
+ {
+ IF( NE_32( ( error = create_sce_dec( st_ivas, sce_id, brate_sce ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ reset_indices_dec( st_ivas->hSCE[sce_id]->hCoreCoder[0] );
+ }
+
+ FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
+ {
+ st_ivas->element_mode_init = IVAS_CPE_MDCT; /* element_mode_init was IVAS_SCE for SCE initialization */
+ move16();
+ IF( NE_32( ( error = create_cpe_dec( st_ivas, cpe_id, brate_cpe ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ FOR( n = 0; n < CPE_CHANNELS; n++ )
+ {
+ reset_indices_dec( st_ivas->hCPE[cpe_id]->hCoreCoder[n] );
+ }
+ }
+
+ /* create CPE element for DFT Stereo like upmix */
+ IF( st_ivas->sba_dirac_stereo_flag )
+ {
+ Word32 res_dec, res_frac;
+ iDiv_and_mod_32( ivas_total_brate, add( st_ivas->nSCE, st_ivas->nCPE ), &res_dec, &res_frac, 0 );
+ IF( NE_32( ( error = create_cpe_dec( st_ivas, cpe_id, res_dec ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ st_ivas->hCPE[0]->hCoreCoder[0] = st_ivas->hSCE[0]->hCoreCoder[0]; /* don't allocate unnecessary core coder, simply point to core coder of SCE element */
+ st_ivas->hCPE[0]->hCoreCoder[1] = NULL;
+ }
+
+ /* set CNA/CNG flags */
+ test();
+ test();
+ IF( EQ_16( st_ivas->nchan_transport, 1 ) && ( ( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) ) )
+ {
+ st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag = 1;
+ move16();
+ st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag = 1;
+ move16();
+ }
+ }
+ }
+
+
+ /*-----------------------------------------------------------------*
+ * Allocate and initialize HP20 filter memories
+ *-----------------------------------------------------------------*/
+
+ /* set number of output channels used for synthesis/decoding */
+ n = getNumChanSynthesis( st_ivas );
+
+ IF( n > 0 )
+ {
+ IF( ( st_ivas->mem_hp20_out_fx = (Word32 **) malloc( n * sizeof( Word32 * ) ) ) == NULL )
+ {
+ return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HP20 filter memory\n" ) );
+ }
+ }
+ ELSE
+ {
+ st_ivas->mem_hp20_out_fx = NULL;
+ }
+
+ FOR( i = 0; i < n; i++ )
+ {
+ IF( ( st_ivas->mem_hp20_out_fx[i] = (Word32 *) malloc( ( L_HP20_MEM + 2 ) * sizeof( Word32 ) ) ) == NULL )
+ {
+ return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HP20 filter memory\n" ) );
+ }
+ set32_fx( st_ivas->mem_hp20_out_fx[i], 0, L_HP20_MEM + 2 );
+ }
+
+ /*-------------------------------------------------------------------*
+ * Allocate and initialize rendering handles
+ *--------------------------------------------------------------------*/
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) )
+ {
+ IF( NE_32( ( error = ivas_binRenderer_open_fx( st_ivas ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+ /* ParamISM is handled separately from other common config */
+ ELSE IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) && ( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) || EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) ) )
+ {
+ IF( NE_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) )
+ {
+ IF( NE_32( ( error = ivas_dirac_dec_binaural_copy_hrtfs_fx( &st_ivas->hHrtfParambin ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+
+ IF( NE_32( ( error = ivas_dirac_dec_init_binaural_data_fx( st_ivas, st_ivas->hHrtfParambin ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+ ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_OBJECTS_TD ) )
+ {
+ Word16 SrcInd[MAX_NUM_TDREND_CHANNELS];
+ Word16 num_src;
+ IF( NE_32( ( error = ivas_td_binaural_open_fx( st_ivas, SrcInd, &num_src ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ Word16 nchan_rend = num_src;
+ move16();
+ test();
+ IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) && NE_32( st_ivas->transport_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
+ {
+ nchan_rend = sub( nchan_rend, 1 ); /* Skip LFE channel -- added to the others */
+ }
+ FOR( Word16 nS = 0; nS < nchan_rend; nS++ )
+ {
+ TDREND_SRC_t *Src_p = st_ivas->hBinRendererTd->Sources[SrcInd[nS]];
+ if ( Src_p->SrcSpatial_p != NULL )
+ {
+ Src_p->SrcSpatial_p->q_Pos_p = Q31;
+ move16();
+ }
+ TDREND_SRC_SPATIAL_t *SrcSpatial_p = st_ivas->hBinRendererTd->Sources[nS]->SrcSpatial_p;
+ SrcSpatial_p->q_Pos_p = Q31;
+ move16();
+ }
+
+ IF( EQ_32( st_ivas->hIntSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) )
+ {
+ IF( NE_32( ( error = ivas_reverb_open_fx( &st_ivas->hReverb, st_ivas->hDecoderConfig->output_config, NULL, st_ivas->hBinRendererTd->HrFiltSet_p->lr_energy_and_iac_fx, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+
+ granularity = NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES );
+
+ n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas );
+
+
+ IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_RENDERER, n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, granularity ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+ ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_MC ) )
+ {
+ IF( NE_32( ( error = ivas_ls_setup_conversion_open_fx( st_ivas ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+ ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_MONO_DOWNMIX ) )
+ {
+ IF( NE_32( ( error = ivas_mono_dmx_renderer_open( st_ivas ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+ ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) )
+ {
+ test();
+ test();
+ test();
+ IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) && EQ_32( st_ivas->ivas_format, MC_FORMAT ) && ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) )
+ {
+ IF( NE_32( ( error = efap_init_data_fx( &( st_ivas->hEFAPdata ), st_ivas->hIntSetup.ls_azimuth_fx, st_ivas->hIntSetup.ls_elevation_fx, st_ivas->hIntSetup.nchan_out_woLFE, EFAP_MODE_EFAP ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+
+ IF( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config,
+ st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs ) ),
+ IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ st_ivas->binaural_latency_ns = st_ivas->hCrendWrapper->binaural_latency_ns;
+ move32();
+
+ test();
+ IF( ( EQ_32( st_ivas->ivas_format, MC_FORMAT ) ) && ( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) ) )
+ {
+ granularity = NS2SA_FX2( output_Fs, CLDFB_SLOT_NS );
+
+ n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas );
+
+
+ IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_RENDERER, n_channels_transport_jbm, MC_PARAMUPMIX_MAX_INPUT_CHANS, MC_PARAMUPMIX_MAX_INPUT_CHANS, granularity ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+ ELSE
+ {
+ granularity = NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES );
+
+ n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas );
+
+ IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_RENDERER, n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, granularity ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+ }
+
+ IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) )
+ {
+ test();
+ IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) && EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) )
+ {
+ /* Allocate TD renderer for the objects in DISC mode */
+ Word16 SrcInd[MAX_NUM_TDREND_CHANNELS];
+ Word16 num_src;
+ IF( NE_32( ( error = ivas_td_binaural_open_fx( st_ivas, SrcInd, &num_src ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ Word16 nchan_rend = num_src;
+ move16();
+ test();
+ if ( EQ_32( st_ivas->ivas_format, MC_FORMAT ) && NE_32( st_ivas->transport_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
+ {
+ nchan_rend = sub( nchan_rend, 1 ); /* Skip LFE channel -- added to the others */
+ }
+ FOR( Word16 nS = 0; nS < nchan_rend; nS++ )
+ {
+ TDREND_SRC_t *Src_p = st_ivas->hBinRendererTd->Sources[SrcInd[nS]];
+ if ( Src_p->SrcSpatial_p != NULL )
+ {
+ Src_p->SrcSpatial_p->q_Pos_p = Q31;
+ move16();
+ }
+ TDREND_SRC_SPATIAL_t *SrcSpatial_p = st_ivas->hBinRendererTd->Sources[nS]->SrcSpatial_p;
+ SrcSpatial_p->q_Pos_p = Q31;
+ move16();
+ }
+
+ /* Allocate 'hIsmRendererData' handle and memory for delay buffer within 'hMasaIsmData' */
+ IF( NE_32( ( error = ivas_omasa_separate_object_renderer_open( st_ivas ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+
+ test();
+ test();
+ test();
+ IF( EQ_32( st_ivas->renderer_type, RENDERER_DIRAC ) && ( 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 ) ) )
+ {
+ /* Allocate 'hIsmRendererData' handle and memory for delay buffer within 'hMasaIsmData' */
+ IF( NE_32( ( error = ivas_omasa_separate_object_renderer_open( st_ivas ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+ }
+
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( ( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) || EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) &&
+ ( EQ_32( st_ivas->ism_mode, ISM_MODE_DISC ) || EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) &&
+ ( EQ_32( st_ivas->renderer_type, RENDERER_TD_PANNING ) ||
+ EQ_32( st_ivas->renderer_type, RENDERER_NON_DIEGETIC_DOWNMIX ) ||
+ EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ||
+ EQ_32( st_ivas->renderer_type, RENDERER_OSBA_STEREO ) ||
+ EQ_32( st_ivas->renderer_type, RENDERER_OSBA_AMBI ) ||
+ EQ_32( st_ivas->renderer_type, RENDERER_OSBA_LS ) ||
+ EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) ||
+ EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ||
+ EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) )
+ {
+ IF( NE_32( ( error = ivas_ism_renderer_open_fx( st_ivas ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+
+ IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) )
+ {
+ test();
+ test();
+ IF( ( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) ) && EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) )
+ {
+ /* Allocate TD renderer for the objects in DISC mode */
+ Word16 SrcInd[MAX_NUM_TDREND_CHANNELS];
+ Word16 num_src;
+ IF( NE_32( ( error = ivas_td_binaural_open_fx( st_ivas, SrcInd, &num_src ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ Word16 nchan_rend = num_src;
+ move16();
+
+ test();
+ if ( EQ_32( st_ivas->ivas_format, MC_FORMAT ) && NE_32( st_ivas->transport_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
+ {
+ nchan_rend = sub( nchan_rend, 1 ); /* Skip LFE channel -- added to the others */
+ }
+ FOR( Word16 nS = 0; nS < nchan_rend; nS++ )
+ {
+ TDREND_SRC_t *Src_p = st_ivas->hBinRendererTd->Sources[SrcInd[nS]];
+ if ( Src_p->SrcSpatial_p != NULL )
+ {
+ Src_p->SrcSpatial_p->q_Pos_p = Q31;
+ move16();
+ }
+ TDREND_SRC_SPATIAL_t *SrcSpatial_p = st_ivas->hBinRendererTd->Sources[nS]->SrcSpatial_p;
+ SrcSpatial_p->q_Pos_p = Q31;
+ move16();
+ }
+ }
+ }
+
+ /*-----------------------------------------------------------------*
+ * LFE handles for rendering after rendering to adjust LFE delay to binaural filter delay
+ *-----------------------------------------------------------------*/
+ test();
+ IF( EQ_32( st_ivas->mc_mode, MC_MODE_MCT ) || EQ_32( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) )
+ {
+ binauralization_delay_ns = st_ivas->binaural_latency_ns;
+ move32();
+ IF( st_ivas->hBinRenderer != NULL )
+ {
+ IF( st_ivas->hBinRenderer->render_lfe )
+ {
+ {
+ /* Account for filterbank delay */
+ binauralization_delay_ns = L_add( binauralization_delay_ns, IVAS_FB_DEC_DELAY_NS );
+ }
+ }
+ ELSE
+ {
+ binauralization_delay_ns = 0;
+ move32();
+ }
+ }
+
+ IF( NE_32( ( error = ivas_create_lfe_dec_fx( &st_ivas->hLFE, output_Fs, binauralization_delay_ns ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ set32_fx( st_ivas->hLFE->prevsynth_buf_fx, 0, LFE_PLC_BUFLEN );
+ set32_fx( st_ivas->hLFE->prior_out_buffer_fx, 0, L_FRAME48k );
+ }
+
+ /*-----------------------------------------------------------------*
+ * CLDFB handles for rendering
+ *-----------------------------------------------------------------*/
+
+ ivas_init_dec_get_num_cldfb_instances_ivas_fx( st_ivas, &numCldfbAnalyses, &numCldfbSyntheses );
+
+ FOR( i = 0; i < numCldfbAnalyses; i++ )
+ {
+ IF( NE_32( ( error = openCldfb_ivas_fx( &( st_ivas->cldfbAnaDec[i] ), CLDFB_ANALYSIS, output_Fs, CLDFB_PROTOTYPE_5_00MS, DEC ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+ FOR( ; i < MAX_INTERN_CHANNELS; i++ )
+ {
+ st_ivas->cldfbAnaDec[i] = NULL;
+ }
+
+ FOR( i = 0; i < numCldfbSyntheses; i++ )
+ {
+ IF( NE_32( ( error = openCldfb_ivas_fx( &( st_ivas->cldfbSynDec[i] ), CLDFB_SYNTHESIS, output_Fs, CLDFB_PROTOTYPE_5_00MS, DEC ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+ FOR( ; i < MAX_OUTPUT_CHANNELS; i++ )
+ {
+ st_ivas->cldfbSynDec[i] = NULL;
+ }
+
+ /* CLDFB Interpolation weights */
+ test();
+ test();
+ test();
+ IF( ( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) || EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) && !st_ivas->sba_dirac_stereo_flag && NE_16( st_ivas->hDecoderConfig->nchan_out, 1 ) )
+ {
+ Word16 Q_cldfbSynDec = Q11;
+ move16();
+ ivas_spar_get_cldfb_gains_fx( st_ivas->hSpar, st_ivas->cldfbAnaDec[0], st_ivas->cldfbSynDec[0], hDecoderConfig );
+
+ FOR( i = 0; i < st_ivas->cldfbAnaDec[0]->cldfb_state_length; i++ )
+ {
+ st_ivas->cldfbAnaDec[0]->cldfb_state_fx[i] = L_shr( st_ivas->cldfbAnaDec[0]->cldfb_state_fx[i], 16 ); // Scaling down from 27 to 11
+ move32();
+ }
+ st_ivas->cldfbAnaDec[0]->Q_cldfb_state = Q11;
+ move16();
+ FOR( i = 0; i < st_ivas->cldfbSynDec[0]->cldfb_state_length; i++ )
+ {
+ st_ivas->cldfbSynDec[0]->cldfb_state_fx[i] = L_shr( st_ivas->cldfbSynDec[0]->cldfb_state_fx[i], sub( 21, Q_cldfbSynDec ) ); // Scaling down from 21 to Q_cldfbSynDec
+ move32();
+ }
+ st_ivas->cldfbSynDec[0]->Q_cldfb_state = Q11;
+ move16();
+ }
+
+ /*-----------------------------------------------------------------*
+ * Allocate and initialize limiter struct
+ *-----------------------------------------------------------------*/
+
+ IF( NE_32( ( error = ivas_limiter_open_fx( &st_ivas->hLimiter, hDecoderConfig->nchan_out, output_Fs ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ /*-----------------------------------------------------------------*
+ * Allocate and initialize JBM struct + buffer
+ *-----------------------------------------------------------------*/
+
+ IF( st_ivas->hTcBuffer == NULL )
+
+ {
+ /* no module has yet open the TC buffer, open a default one */
+ n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas );
+
+ IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, ivas_jbm_dec_get_tc_buffer_mode( st_ivas ), n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+
+ IF( st_ivas->hTcBuffer == NULL )
+ {
+ /* we need the handle anyway, but without the buffer*/
+ IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_NONE, 0, 0, 0, 1 ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+
+ IF( st_ivas->hJbmMetadata == NULL )
+ {
+ IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
+ {
+ IF( NE_32( ( error = ivas_jbm_dec_metadata_open( st_ivas ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+ }
+
+ /*-----------------------------------------------------------------*
+ * Allocate floating-point output audio buffers
+ *-----------------------------------------------------------------*/
+ st_ivas->p_out_len = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate );
+ move16();
+ FOR( n = 0; n < ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); n++ )
+ {
+ /* note: these are intra-frame heap memories */
+ IF( ( st_ivas->p_output_fx[n] = (Word32 *) malloc( ( 48000 / FRAMES_PER_SEC ) * sizeof( Word32 ) ) ) == NULL )
+ {
+ return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for floating-point output audio buffer!\n" ) );
+ }
+ set32_fx( st_ivas->p_output_fx[n], 0, 48000 / FRAMES_PER_SEC );
+ }
+
+ FOR( ; n < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; n++ )
+ {
+ st_ivas->p_output_fx[n] = NULL;
+ }
+ return error;
+}
+
+/*-------------------------------------------------------------------------
+ * destroy_core_dec()
+ *
+ * Close core decoder handles
+ *-------------------------------------------------------------------------*/
+
+void destroy_core_dec_fx(
+ DEC_CORE_HANDLE hCoreCoder /* i/o: core decoder structure */
+)
+{
+ IF( EQ_16( hCoreCoder->element_mode, EVS_MONO ) )
+ {
+ destroy_cldfb_decoder_fx( hCoreCoder );
+ }
+ ELSE
+ {
+ destroy_cldfb_decoder_ivas_fx( hCoreCoder );
+ }
+
+ IF( hCoreCoder->hGSCDec != NULL )
+ {
+ free( hCoreCoder->hGSCDec );
+ hCoreCoder->hGSCDec = NULL;
+ }
+
+ IF( hCoreCoder->hPFstat != NULL )
+ {
+ free( hCoreCoder->hPFstat );
+ hCoreCoder->hPFstat = NULL;
+ }
+
+ IF( hCoreCoder->hMusicPF != NULL )
+ {
+ free( hCoreCoder->hMusicPF );
+ hCoreCoder->hMusicPF = NULL;
+ }
+
+ IF( hCoreCoder->hBPF != NULL )
+ {
+ free( hCoreCoder->hBPF );
+ hCoreCoder->hBPF = NULL;
+ }
+
+ IF( hCoreCoder->hBWE_zero != NULL )
+ {
+ free( hCoreCoder->hBWE_zero );
+ hCoreCoder->hBWE_zero = NULL;
+ }
+
+ IF( hCoreCoder->hTdCngDec != NULL )
+ {
+ free( hCoreCoder->hTdCngDec );
+ hCoreCoder->hTdCngDec = NULL;
+ }
+
+ IF( hCoreCoder->hSC_VBR != NULL )
+ {
+ free( hCoreCoder->hSC_VBR );
+ hCoreCoder->hSC_VBR = NULL;
+ }
+
+ IF( hCoreCoder->hAmrwb_IO != NULL )
+ {
+ free( hCoreCoder->hAmrwb_IO );
+ hCoreCoder->hAmrwb_IO = NULL;
+ }
+
+ IF( hCoreCoder->hBWE_TD != NULL )
+ {
+ free( hCoreCoder->hBWE_TD );
+ hCoreCoder->hBWE_TD = NULL;
+ }
+
+ IF( hCoreCoder->hBWE_FD != NULL )
+ {
+ free( hCoreCoder->hBWE_FD );
+ hCoreCoder->hBWE_FD = NULL;
+ }
+
+ IF( hCoreCoder->hBWE_FD_HR != NULL )
+ {
+ free( hCoreCoder->hBWE_FD_HR );
+ hCoreCoder->hBWE_FD_HR = NULL;
+ }
+
+ IF( hCoreCoder->hWIDec != NULL )
+ {
+ free( hCoreCoder->hWIDec );
+ hCoreCoder->hWIDec = NULL;
+ }
+
+ IF( hCoreCoder->hTECDec != NULL )
+ {
+ free( hCoreCoder->hTECDec );
+ hCoreCoder->hTECDec = NULL;
+ }
+
+ IF( hCoreCoder->hTcxLtpDec != NULL )
+ {
+ free( hCoreCoder->hTcxLtpDec );
+ hCoreCoder->hTcxLtpDec = NULL;
+ }
+
+ IF( hCoreCoder->hTcxDec != NULL )
+ {
+ free( hCoreCoder->hTcxDec );
+ hCoreCoder->hTcxDec = NULL;
+ }
+
+ IF( hCoreCoder->hTcxCfg != NULL )
+ {
+ free( hCoreCoder->hTcxCfg );
+ hCoreCoder->hTcxCfg = NULL;
+ }
+
+ IF( hCoreCoder->hTonalMDCTConc != NULL )
+ {
+ free( hCoreCoder->hTonalMDCTConc );
+ hCoreCoder->hTonalMDCTConc = NULL;
+ }
+
+ IF( hCoreCoder->hIGFDec != NULL )
+ {
+ free( hCoreCoder->hIGFDec );
+ hCoreCoder->hIGFDec = NULL;
+ }
+
+ IF( hCoreCoder->hPlcInfo != NULL )
+ {
+ free( hCoreCoder->hPlcInfo );
+ hCoreCoder->hPlcInfo = NULL;
+ }
+
+ IF( hCoreCoder->hHQ_core != NULL )
+ {
+ free( hCoreCoder->hHQ_core );
+ hCoreCoder->hHQ_core = NULL;
+ }
+
+ IF( hCoreCoder->hHQ_nbfec != NULL )
+ {
+ free( hCoreCoder->hHQ_nbfec );
+ hCoreCoder->hHQ_nbfec = NULL;
+ }
+
+ return;
+}
+
+/*-------------------------------------------------------------------------
+ * ivas_initialize_handles_dec()
+ *
+ * NULL initialization of handles
+ *-------------------------------------------------------------------------*/
+
+void ivas_initialize_handles_dec(
+ Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
+)
+{
+ Word16 i;
+
+ FOR( i = 0; i < MAX_INTERN_CHANNELS; i++ )
+ {
+ st_ivas->cldfbAnaDec[i] = NULL;
+ }
+
+ FOR( i = 0; i < MAX_OUTPUT_CHANNELS; i++ )
+ {
+ st_ivas->cldfbSynDec[i] = NULL;
+ }
+
+ /* SCE handles */
+ FOR( i = 0; i < MAX_SCE; i++ )
+ {
+ st_ivas->hSCE[i] = NULL;
+ }
+
+ /* CPE handles */
+ FOR( i = 0; i < MAX_CPE; i++ )
+ {
+ st_ivas->hCPE[i] = NULL;
+ }
+
+ st_ivas->bit_stream = NULL;
+ st_ivas->mem_hp20_out_fx = NULL;
+ st_ivas->hLimiter = NULL;
+
+ /* ISM metadata handles */
+ FOR( i = 0; i < MAX_NUM_OBJECTS; i++ )
+ {
+ st_ivas->hIsmMetaData[i] = NULL;
+ }
+
+ /* spatial coding handles */
+ st_ivas->hDirAC = NULL;
+ st_ivas->hParamIsmDec = NULL;
+ st_ivas->hSpar = NULL;
+ st_ivas->hMasa = NULL;
+ st_ivas->hQMetaData = NULL;
+ st_ivas->hMCT = NULL;
+ st_ivas->hMCParamUpmix = NULL;
+ st_ivas->hParamMC = NULL;
+ st_ivas->hLFE = NULL;
+
+ /* rendering handles */
+ st_ivas->hBinRenderer = NULL;
+ st_ivas->hDiracDecBin = NULL;
+ st_ivas->hDirACRend = NULL;
+ st_ivas->hSpatParamRendCom = NULL;
+ st_ivas->hLsSetUpConversion = NULL;
+ st_ivas->hEFAPdata = NULL;
+ st_ivas->hVBAPdata = NULL;
+ st_ivas->hIsmRendererData = NULL;
+ st_ivas->hBinRendererTd = NULL;
+ st_ivas->hMonoDmxRenderer = NULL;
+ st_ivas->hCrendWrapper = NULL;
+ st_ivas->hReverb = NULL;
+ st_ivas->hSetOfHRTF = NULL;
+ st_ivas->hHrtfFastConv = NULL;
+ st_ivas->hHrtfParambin = NULL;
+ st_ivas->hoa_dec_mtx = NULL;
+ st_ivas->hMasaIsmData = NULL;
+ st_ivas->hSbaIsmData = NULL;
+
+ st_ivas->hHeadTrackData = NULL;
+ st_ivas->hHrtfTD = NULL;
+ st_ivas->hLsSetupCustom = NULL;
+ st_ivas->hRenderConfig = NULL;
+ st_ivas->hExtOrientationData = NULL;
+ st_ivas->hCombinedOrientationData = NULL;
+
+
+ /* JBM handles */
+ st_ivas->hTcBuffer = NULL;
+ st_ivas->hJbmMetadata = NULL;
+
+ /* floating-point output audio buffers */
+ FOR( i = 0; i < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; i++ )
+ {
+ st_ivas->p_output_fx[i] = NULL;
+ }
+
+ return;
+}
+
+
+/*-------------------------------------------------------------------------
+ * ivas_destroy_dec()
+ *
+ * Close IVAS decoder handles
+ *-------------------------------------------------------------------------*/
+
+void ivas_destroy_dec_fx(
+ Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */
+)
+{
+ Word16 i;
+
+ /* CLDFB handles */
+ FOR( i = 0; i < MAX_INTERN_CHANNELS; i++ )
+ {
+ IF( st_ivas->cldfbAnaDec[i] != NULL )
+ {
+ deleteCldfb_ivas_fx( &( st_ivas->cldfbAnaDec[i] ) );
+ }
+ }
+
+ FOR( i = 0; i < MAX_OUTPUT_CHANNELS; i++ )
+ {
+ IF( st_ivas->cldfbSynDec[i] != NULL )
+ {
+ deleteCldfb_ivas_fx( &( st_ivas->cldfbSynDec[i] ) );
+ }
+ }
+
+ /* SCE handles */
+ FOR( i = 0; i < MAX_SCE; i++ )
+ {
+ IF( st_ivas->hSCE[i] != NULL )
+ {
+ destroy_sce_dec( st_ivas->hSCE[i] );
+ st_ivas->hSCE[i] = NULL;
+ }
+ }
+
+ /* CPE handles */
+ FOR( i = 0; i < MAX_CPE; i++ )
+ {
+ IF( st_ivas->hCPE[i] != NULL )
+ {
+ /* set pointer to NULL as core coder already deallocated in destroy_sce_dec() */
+ test();
+ IF( st_ivas->sba_dirac_stereo_flag && EQ_16( st_ivas->nchan_transport, 1 ) )
+ {
+ st_ivas->hCPE[i]->hCoreCoder[0] = NULL;
+ st_ivas->hCPE[i]->hCoreCoder[1] = NULL;
+ }
+ destroy_cpe_dec( st_ivas->hCPE[i] );
+ st_ivas->hCPE[i] = NULL;
+ }
+ }
+
+ /* HP20 filter handles */
+ IF( st_ivas->mem_hp20_out_fx != NULL )
+ {
+ FOR( i = 0; i < getNumChanSynthesis( st_ivas ); i++ )
+ {
+ free( st_ivas->mem_hp20_out_fx[i] );
+ st_ivas->mem_hp20_out_fx[i] = NULL;
+ }
+ free( st_ivas->mem_hp20_out_fx );
+ st_ivas->mem_hp20_out_fx = NULL;
+ }
+
+ /* ISM metadata handles */
+ ivas_ism_metadata_close( st_ivas->hIsmMetaData, 0 );
+
+ /* ISM renderer handle */
+ ivas_ism_renderer_close( &( st_ivas->hIsmRendererData ) );
+
+ /* DirAC handle */
+ IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) )
+ {
+ ivas_param_ism_dec_close_fx( &( st_ivas->hParamIsmDec ), &( st_ivas->hSpatParamRendCom ), st_ivas->hDecoderConfig->output_config );
+ }
+ ELSE
+ {
+ ivas_dirac_rend_close_fx( &( st_ivas->hDirACRend ) );
+ ivas_spat_hSpatParamRendCom_close_fx( &( st_ivas->hSpatParamRendCom ) );
+ ivas_dirac_dec_close_fx( &( st_ivas->hDirAC ) );
+ }
+
+ /* SPAR handle */
+ ivas_spar_dec_close_fx( &( st_ivas->hSpar ), st_ivas->hDecoderConfig->output_Fs, 0 );
+
+ /* HOA decoder matrix */
+ IF( st_ivas->hoa_dec_mtx != NULL )
+ {
+ free( st_ivas->hoa_dec_mtx );
+ st_ivas->hoa_dec_mtx = NULL;
+ }
+
+ /* MASA decoder structure */
+
+ ivas_masa_dec_close_fx( &( st_ivas->hMasa ) );
+ /* Qmetadata handle */
+ ivas_qmetadata_close_fx( &st_ivas->hQMetaData );
+
+ /* MCT handle */
+ ivas_mct_dec_close( &st_ivas->hMCT );
+
+ /* LFE handle */
+ ivas_lfe_dec_close_fx( &( st_ivas->hLFE ) );
+
+ /* Param-Upmix MC handle */
+ ivas_mc_paramupmix_dec_close( &( st_ivas->hMCParamUpmix ) );
+
+ /* Parametric MC handle */
+ ivas_param_mc_dec_close_fx( &st_ivas->hParamMC );
+
+ /* EFAP handle */
+ efap_free_data_fx( &st_ivas->hEFAPdata );
+
+ /* VBAP handle */
+ vbap_free_data_fx( &( st_ivas->hVBAPdata ) );
+ /* Fastconv binaural renderer handle */
+ ivas_binRenderer_close_fx( &st_ivas->hBinRenderer );
+
+ /* Parametric binaural renderer handle */
+ ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin );
+
+ /* Crend handle */
+
+ ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ) );
+
+ /* Reverb handle */
+ ivas_reverb_close( &st_ivas->hReverb );
+
+ /* LS config converter handle */
+
+ ivas_ls_setup_conversion_close_fx( &st_ivas->hLsSetUpConversion );
+ /* Custom LS configuration handle */
+ IF( st_ivas->hLsSetupCustom != NULL )
+ {
+ free( st_ivas->hLsSetupCustom );
+ st_ivas->hLsSetupCustom = NULL;
+ }
+
+ /* Mono downmix structure */
+ ivas_mono_dmx_renderer_close( &st_ivas->hMonoDmxRenderer );
+
+ /* OSBA structure */
+
+ ivas_osba_data_close_fx( &st_ivas->hSbaIsmData );
+
+ /* OMASA structure */
+ ivas_omasa_data_close_fx( &st_ivas->hMasaIsmData );
+ /* Head track data handle */
+ ivas_headTrack_close_fx( &st_ivas->hHeadTrackData );
+
+ /* External orientation data handle */
+ ivas_external_orientation_close_fx( &st_ivas->hExtOrientationData );
+
+ /* Combined orientation data handle */
+ ivas_combined_orientation_close_fx( &st_ivas->hCombinedOrientationData );
+
+ /* Time Domain binaural renderer handle */
+ IF( st_ivas->hBinRendererTd != NULL )
+ {
+ ivas_td_binaural_close_fx( &st_ivas->hBinRendererTd );
+ }
+ ELSE IF( st_ivas->hHrtfTD != NULL )
+ {
+ BSplineModelEvalDealloc_fx( &st_ivas->hHrtfTD->ModelParams, &st_ivas->hHrtfTD->ModelEval );
+ ivas_HRTF_binary_close_fx( &st_ivas->hHrtfTD );
+ }
+
+ /* CRend binaural renderer handle */
+ ivas_HRTF_CRend_binary_close_fx( &st_ivas->hSetOfHRTF );
+
+ /* Fastconv HRTF memories */
+ ivas_binaural_hrtf_close( &st_ivas->hHrtfFastConv );
+
+ /* Fastconv HRTF filters */
+ ivas_HRTF_fastconv_binary_close_fx( &st_ivas->hHrtfFastConv );
+
+ /* Parametric binauralizer HRTF filters */
+ ivas_HRTF_parambin_binary_close_fx( &st_ivas->hHrtfParambin );
+
+ /* Config. Renderer */
+ ivas_render_config_close( &( st_ivas->hRenderConfig ) );
+
+ /* Limiter struct */
+ ivas_limiter_close_fx( &( st_ivas->hLimiter ) );
+
+ IF( st_ivas->hDecoderConfig != NULL )
+ {
+ free( st_ivas->hDecoderConfig );
+ st_ivas->hDecoderConfig = NULL;
+ }
+
+ ivas_jbm_dec_tc_buffer_close( &st_ivas->hTcBuffer );
+
+ IF( st_ivas->hJbmMetadata != NULL )
+ {
+ free( st_ivas->hJbmMetadata );
+ st_ivas->hJbmMetadata = NULL;
+ }
+
+ /* floating-point output audio buffers */
+ FOR( i = 0; i < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; i++ )
+ {
+
+ IF( st_ivas->p_output_fx[i] != NULL )
+ {
+ free( st_ivas->p_output_fx[i] );
+ st_ivas->p_output_fx[i] = NULL;
+ }
+ }
+
+ /* main IVAS handle */
+ free( st_ivas );
+
+ return;
+}
+
+
+/*-------------------------------------------------------------------*
+ * ivas_init_dec_get_num_cldfb_instances()
+ *
+ * Return number of CLDFB analysis & synthesis instances
+ *-------------------------------------------------------------------*/
+
+/*! r: number of cldfb instances */
+void ivas_init_dec_get_num_cldfb_instances(
+ Decoder_Struct *st_ivas, /* i : IVAS decoder structure */
+ Word16 *numCldfbAnalyses, /* o : number of needed CLDFB analysis instances */
+ Word16 *numCldfbSyntheses /* o : number of needed CLDFB synthesis instances */
+)
+{
+ IVAS_FORMAT ivas_format;
+ *numCldfbAnalyses = st_ivas->nchan_transport;
+ move16();
+ *numCldfbSyntheses = st_ivas->hDecoderConfig->nchan_out;
+ move16();
+
+ test();
+ IF( ( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_MODE_NONE ) ) )
+ {
+ ivas_format = SBA_FORMAT;
+ move32();
+ }
+ ELSE
+ {
+ ivas_format = st_ivas->ivas_format;
+ move32();
+ }
+
+ SWITCH( st_ivas->renderer_type )
+ {
+ case RENDERER_BINAURAL_PARAMETRIC:
+ case RENDERER_BINAURAL_PARAMETRIC_ROOM:
+ case RENDERER_STEREO_PARAMETRIC:
+ IF( EQ_16( st_ivas->nchan_transport, 1 ) )
+ {
+ *numCldfbAnalyses = add( st_ivas->nchan_transport, 1 );
+ move16();
+ }
+
+ test();
+ IF( EQ_32( st_ivas->mc_mode, MC_MODE_MCMASA ) && st_ivas->hOutSetup.separateChannelEnabled )
+ {
+ *numCldfbAnalyses = add( st_ivas->nchan_transport, 1 );
+ move16();
+ }
+
+ IF( EQ_32( ivas_format, SBA_ISM_FORMAT ) )
+ {
+ IF( EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) )
+ {
+ *numCldfbAnalyses = add( *numCldfbAnalyses, st_ivas->nchan_ism );
+ move16();
+ }
+ }
+
+ IF( EQ_32( ivas_format, MASA_ISM_FORMAT ) )
+ {
+ test();
+ IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) )
+ {
+ *numCldfbAnalyses = add( *numCldfbAnalyses, st_ivas->nchan_ism );
+ move16();
+ }
+ ELSE 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 ) )
+ {
+ *numCldfbAnalyses = add( st_ivas->nchan_transport, 1 );
+ move16();
+ }
+ }
+ IF( st_ivas->hDiracDecBin->useTdDecorr )
+ {
+ *numCldfbAnalyses = add( *numCldfbAnalyses, 2 );
+ move16();
+ }
+ BREAK;
+ case RENDERER_NON_DIEGETIC_DOWNMIX:
+ case RENDERER_MONO_DOWNMIX:
+ test();
+ test();
+ IF( EQ_32( ivas_format, ISM_FORMAT ) || EQ_32( ivas_format, MASA_ISM_FORMAT ) || EQ_32( ivas_format, SBA_ISM_FORMAT ) )
+ {
+ /* CLDFB not used in rendering */
+ *numCldfbAnalyses = 0;
+ move16();
+ *numCldfbSyntheses = 0;
+ move16();
+ }
+ BREAK;
+ case RENDERER_DIRAC:
+ IF( EQ_32( ivas_format, SBA_FORMAT ) )
+ {
+ *numCldfbAnalyses = st_ivas->hSpar->hFbMixer->fb_cfg->num_in_chans;
+ move16();
+
+ test();
+ IF( st_ivas->hOutSetup.is_loudspeaker_setup && EQ_32( st_ivas->renderer_type, RENDERER_DIRAC ) )
+ {
+ *numCldfbSyntheses = st_ivas->hOutSetup.nchan_out_woLFE;
+ move16();
+ }
+ ELSE IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_FOA ) )
+ {
+ *numCldfbSyntheses = st_ivas->hSpar->hFbMixer->fb_cfg->num_out_chans;
+ move16();
+ }
+ ELSE
+ {
+ *numCldfbSyntheses = MAX_OUTPUT_CHANNELS;
+ move16();
+ }
+ }
+ IF( NE_32( ivas_format, SBA_FORMAT ) )
+ {
+ test();
+ test();
+ IF( GT_16( st_ivas->nchan_transport, 2 ) && ( st_ivas->sba_planar != 0 ) )
+ {
+ *numCldfbAnalyses = add( st_ivas->nchan_transport, 1 );
+ move16();
+ }
+ ELSE IF( EQ_16( st_ivas->nchan_transport, 1 ) && EQ_32( st_ivas->hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) )
+ {
+ *numCldfbAnalyses = add( st_ivas->nchan_transport, 1 );
+ move16();
+ }
+ }
+ BREAK;
+ case RENDERER_MC_PARAMMC:
+ IF( LE_16( st_ivas->hDecoderConfig->nchan_out, 2 ) )
+ {
+ /* CLDFB not used in rendering */
+ *numCldfbAnalyses = 0;
+ move16();
+ *numCldfbSyntheses = 0;
+ move16();
+ }
+ ELSE
+ {
+ *numCldfbSyntheses = param_mc_get_num_cldfb_syntheses_fx( st_ivas );
+ move16();
+ }
+ BREAK;
+ case RENDERER_PARAM_ISM:
+ /* Already correct with no exception */
+ BREAK;
+ case RENDERER_DISABLE:
+ /* CLDFB not used */
+ *numCldfbAnalyses = 0;
+ move16();
+ *numCldfbSyntheses = 0;
+ move16();
+ BREAK;
+ case RENDERER_MC:
+ case RENDERER_SBA_LINEAR_DEC:
+ case RENDERER_TD_PANNING:
+ case RENDERER_BINAURAL_OBJECTS_TD:
+ case RENDERER_MCMASA_MONO_STEREO:
+ case RENDERER_BINAURAL_MIXER_CONV:
+ case RENDERER_BINAURAL_MIXER_CONV_ROOM:
+ case RENDERER_BINAURAL_FASTCONV:
+ case RENDERER_BINAURAL_FASTCONV_ROOM:
+ case RENDERER_OSBA_STEREO:
+ case RENDERER_OSBA_AMBI:
+ case RENDERER_OSBA_LS:
+ test();
+ IF( EQ_32( ivas_format, SBA_FORMAT ) || EQ_32( ivas_format, SBA_ISM_FORMAT ) )
+ {
+ IF( st_ivas->sba_dirac_stereo_flag != 0 )
+ {
+ *numCldfbAnalyses = 0;
+ move16();
+ *numCldfbSyntheses = 0;
+ move16();
+ }
+ ELSE
+ {
+ *numCldfbAnalyses = st_ivas->hSpar->hFbMixer->fb_cfg->num_in_chans;
+ move16();
+
+ test();
+ IF( st_ivas->hOutSetup.is_loudspeaker_setup && EQ_32( st_ivas->renderer_type, RENDERER_DIRAC ) )
+ {
+ *numCldfbSyntheses = st_ivas->hOutSetup.nchan_out_woLFE;
+ move16();
+ }
+ ELSE IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_FOA ) )
+ {
+ *numCldfbSyntheses = st_ivas->hSpar->hFbMixer->fb_cfg->num_out_chans;
+ move16();
+ }
+ ELSE
+ {
+ *numCldfbSyntheses = MAX_OUTPUT_CHANNELS;
+ move16();
+ }
+ test();
+ IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) )
+ {
+ *numCldfbAnalyses = add( st_ivas->nchan_ism, st_ivas->hSpar->hFbMixer->fb_cfg->num_in_chans );
+ move16();
+ }
+ }
+ }
+ ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMMC ) )
+ {
+ /* do nothing for ParamMC */
+ }
+ ELSE
+ {
+ /* CLDFB not used in rendering */
+ *numCldfbAnalyses = 0;
+ move16();
+ *numCldfbSyntheses = 0;
+ move16();
+ }
+ BREAK;
+ case RENDERER_SBA_LINEAR_ENC:
+ IF( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMMC ) )
+ {
+ *numCldfbSyntheses = param_mc_get_num_cldfb_syntheses_fx( st_ivas );
+ move16();
+ }
+ ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) )
+ {
+ *numCldfbSyntheses = add( st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hIntSetup.num_lfe );
+ move16();
+ }
+ ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_MCMASA ) )
+ {
+ *numCldfbAnalyses = st_ivas->nchan_transport;
+ move16();
+ *numCldfbSyntheses = add( st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hIntSetup.num_lfe );
+ move16();
+ }
+ ELSE
+ {
+ /* CLDFB not used in rendering */
+ *numCldfbAnalyses = 0;
+ move16();
+ *numCldfbSyntheses = 0;
+ move16();
+ }
+ BREAK;
+ default:
+ assert( 0 && "Renderer not handled for CLDFB reservation." );
+ }
+ test();
+ test();
+ IF( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) && NE_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_MONO ) && NE_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) )
+ {
+ test();
+ test();
+ IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) || EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) )
+ {
+ *numCldfbAnalyses = s_max( MC_PARAMUPMIX_MAX_INPUT_CHANS, *numCldfbAnalyses );
+ move16();
+ }
+ ELSE
+ {
+ *numCldfbAnalyses = s_max( MC_PARAMUPMIX_MIN_CLDFB, *numCldfbAnalyses );
+ move16();
+ }
+ *numCldfbSyntheses = s_max( MC_PARAMUPMIX_MIN_CLDFB, *numCldfbSyntheses );
+ move16();
+ }
+
+ return;
+}
+
void ivas_init_dec_get_num_cldfb_instances_ivas_fx(
Decoder_Struct *st_ivas, /* i : IVAS decoder structure */
Word16 *numCldfbAnalyses, /* o : number of needed CLDFB analysis instances */
@@ -260,3 +3376,142 @@ void ivas_init_dec_get_num_cldfb_instances_ivas_fx(
return;
}
+
+
+/*---------------------------------------------------------------------*
+ * doSanityChecks_IVAS()
+ *
+ * Sanity checks - verify if the decoder set-up parameters are
+ * not in conflict with the IVAS format
+ *---------------------------------------------------------------------*/
+
+static ivas_error doSanityChecks_IVAS(
+ Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
+)
+{
+ Word32 output_Fs;
+ AUDIO_CONFIG output_config;
+
+ output_Fs = st_ivas->hDecoderConfig->output_Fs;
+ move32();
+ output_config = st_ivas->hDecoderConfig->output_config;
+ move32();
+ /*-----------------------------------------------------------------*
+ * Sanity checks
+ *-----------------------------------------------------------------*/
+
+ IF( EQ_32( output_Fs, 8000 ) )
+ {
+ return IVAS_ERROR( IVAS_ERR_INVALID_SAMPLING_RATE, "8kHz output sampling rate is not supported in IVAS." );
+ }
+
+ assert( st_ivas->ivas_format != UNDEFINED_FORMAT && "\n IVAS format undefined" );
+ assert( st_ivas->ivas_format != MONO_FORMAT && "\n Wrong IVAS format: MONO" );
+
+ /* Verify output configuration compatible with non-diegetic panning */
+ test();
+ test();
+ IF( st_ivas->hDecoderConfig->Opt_non_diegetic_pan && NE_32( st_ivas->ivas_format, MONO_FORMAT ) && NE_32( st_ivas->transport_config, IVAS_AUDIO_CONFIG_ISM1 ) )
+ {
+ return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Error: Non-diegetic panning not supported in this IVAS format" );
+ }
+
+ /* Verify stereo output configuration */
+ IF( EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) )
+ {
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( NE_32( output_config, IVAS_AUDIO_CONFIG_MONO ) && NE_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) && NE_32( output_config, IVAS_AUDIO_CONFIG_5_1 ) && NE_32( output_config, IVAS_AUDIO_CONFIG_7_1 ) && NE_32( output_config, IVAS_AUDIO_CONFIG_5_1_2 ) && NE_32( output_config, IVAS_AUDIO_CONFIG_5_1_4 ) && NE_32( output_config, IVAS_AUDIO_CONFIG_7_1_4 ) && NE_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
+ {
+ return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Wrong output configuration specified for Stereo!" );
+ }
+ }
+ ELSE IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) )
+ {
+ /* Verify ISM output configuration */
+ IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_INVALID ) )
+ {
+ return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Incorrect output configuration specified for ISM" );
+ }
+ }
+ ELSE IF( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) )
+ {
+ /* Verify SBA output coniguration */
+ IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_INVALID ) )
+ {
+ return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Incorrect output configuration specified for SBA" );
+ }
+ }
+ ELSE IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) )
+ {
+ IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_INVALID ) )
+ {
+ return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Incorrect output configuration specified for MASA!" );
+ }
+ }
+ ELSE IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) )
+ {
+ /* Verify MC output configuration */
+ test();
+ IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_INVALID ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
+ {
+ return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Incorrect output configuration specified for Multi-channel" );
+ }
+ }
+
+
+ IF( st_ivas->hDecoderConfig->Opt_Headrotation )
+ {
+ test();
+ test();
+ IF( !( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) )
+ {
+ return IVAS_ERROR( IVAS_ERR_HEAD_ROTATION_NOT_SUPPORTED, "Wrong set-up: Head-rotation not supported in this configuration" );
+ }
+ }
+
+ IF( st_ivas->hDecoderConfig->Opt_ExternalOrientation )
+ {
+ test();
+ test();
+ IF( !( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) )
+ {
+ return IVAS_ERROR( IVAS_ERR_EXT_ORIENTATION_NOT_SUPPORTED, "Wrong set-up: External orientation not supported in this configuration" );
+ }
+ }
+
+ IF( st_ivas->hDecoderConfig->Opt_dpid_on )
+ {
+ test();
+ IF( !( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) )
+ {
+ return IVAS_ERROR( IVAS_ERR_DIRECTIVITY_NOT_SUPPORTED, "Wrong set-up: Directivity is not supported in this output configuration." );
+ }
+ }
+
+ IF( st_ivas->hDecoderConfig->Opt_aeid_on )
+ {
+ IF( NE_16( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) )
+ {
+ return IVAS_ERROR( IVAS_ERR_ACOUSTIC_ENVIRONMENT_NOT_SUPPORTED, "Wrong set-up: Acoustic environment is not supported in this output configuration." );
+ }
+ }
+
+ IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) )
+ {
+ test();
+ IF( NE_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) && EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
+ {
+
+ return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Incorrect output configuration specified for combined MASA and ISM format" );
+ }
+ }
+
+
+ return IVAS_ERR_OK;
+}
diff --git a/lib_dec/ivas_ism_dtx_dec_fx.c b/lib_dec/ivas_ism_dtx_dec_fx.c
index 73ea5cd1f27289546002cddce0f3de1f71654c66..d5943a90cf19cc9744f181178dca2ae722ff154e 100644
--- a/lib_dec/ivas_ism_dtx_dec_fx.c
+++ b/lib_dec/ivas_ism_dtx_dec_fx.c
@@ -161,7 +161,7 @@ void ivas_ism_dtx_limit_noise_energy_for_near_silence_fx(
)
{
Word32 fac_fx, cng_noise_nrg_obj_fx, cng_noise_nrg_dominant_fx;
- Word16 ch, cng_noise_level_len, Q_cng_noise_nrg_dominant, Q_fac;
+ Word16 ch, cng_noise_level_len, Q_cng_noise_nrg_dominant, exp;
HANDLE_FD_CNG_COM hFdCngCom;
hFdCngCom = hSCE[sce_id_dtx]->hCoreCoder[0]->hFdCngDec->hFdCngCom;
cng_noise_level_len = sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand );
@@ -193,10 +193,10 @@ void ivas_ism_dtx_limit_noise_energy_for_near_silence_fx(
Q_temp = sub( Q_temp, 1 );
temp = L_shr( temp, 1 );
}
- fac_fx = getSqrtWord32( temp ); /*Resultant Q=Q_temp/2*/
- Q_fac = shr( Q_temp, 1 );
+ exp = sub( 31, Q_temp );
+ fac_fx = Sqrt32( temp, &exp );
v_multc_fixed( hFdCngCom->cngNoiseLevel, fac_fx, hFdCngCom->cngNoiseLevel, cng_noise_level_len ); /*Resultant Q of cngNoiseLevel is Q_cngNoiseLevel for ch*/
- scale_sig32( hFdCngCom->cngNoiseLevel, cng_noise_level_len, negate( sub( 31, Q_fac ) ) ); /*Restoring Q of hFdCngCom->cngNoiseLevel to Q_cngNoiseLevel */
+ scale_sig32( hFdCngCom->cngNoiseLevel, cng_noise_level_len, exp ); /*Restoring Q of hFdCngCom->cngNoiseLevel to Q_cngNoiseLevel */
}
}
}
diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c
index 3f67962dc6f29e329016854e7d6b4cc09492b293..a36982777ee4fef7b3cbed46120c3d392d4f8fdc 100644
--- a/lib_dec/ivas_jbm_dec_fx.c
+++ b/lib_dec/ivas_jbm_dec_fx.c
@@ -2617,7 +2617,7 @@ ivas_error ivas_jbm_dec_flush_renderer_fx(
move16();
move16();
- FOR( ch_idx = 0; ch_idx < MAX_CICP_CHANNELS; ch_idx++ )
+ FOR( ch_idx = 0; ch_idx < ( MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS ); ch_idx++ )
{
p_output_fx[ch_idx] = output_fx[ch_idx];
}
@@ -4032,6 +4032,13 @@ void ivas_jbm_dec_copy_tc_no_tsm_fx(
&cldfb_real_buffer_fx[slot_idx * num_freq_bands * n_ch_cldfb + cldfb_ch * num_freq_bands],
&cldfb_imag_buffer_fx[slot_idx * num_freq_bands * n_ch_cldfb + cldfb_ch * num_freq_bands],
num_freq_bands, st_ivas->cldfbAnaDec[cldfb_ch], &Q_tc );
+ IF( EQ_16( (Word16) st_ivas->ivas_format, (Word16) MC_FORMAT ) )
+ {
+ st_ivas->hParamMC->Cldfb_RealBuffer_tc_e = sub( 31, Q_tc );
+ st_ivas->hParamMC->Cldfb_ImagBuffer_tc_e = sub( 31, Q_tc );
+ move16();
+ move16();
+ }
}
}
}
diff --git a/lib_dec/ivas_masa_dec_fx.c b/lib_dec/ivas_masa_dec_fx.c
index dec4d3465771077ed36773e1f56a2085d6eddbf3..e61e51262c6392dfaaed7cec42e11370d725b44f 100644
--- a/lib_dec/ivas_masa_dec_fx.c
+++ b/lib_dec/ivas_masa_dec_fx.c
@@ -2572,13 +2572,9 @@ static void create_masa_ext_out_meta_fx(
{
FOR( b_new = bandMap[b_old]; b_new < bandMap[b_old + 1]; b_new++ )
{
- IF( EQ_32( hQMetaData->q_direction[dir].band_data[b_old].energy_ratio_fx[sf], ONE_IN_Q30 ) )
- {
- hQMetaData->q_direction[dir].band_data[b_old].energy_ratio_fx[sf]--;
- }
- UWord8 tmp = (UWord8) L_shr( hQMetaData->q_direction[dir].band_data[b_old].energy_ratio_fx[sf], Q30 - 8 ); // Q8
+ UWord8 tmp = (UWord8) W_extract_h( W_mult_32_16( hQMetaData->q_direction[dir].band_data[b_old].energy_ratio_fx[sf], UINT8_MAX << 1 ) ); // Q0
move16();
- extOutMeta->directToTotalRatio[dir][sf][b_new] = tmp; // Q8
+ extOutMeta->directToTotalRatio[dir][sf][b_new] = tmp; // Q0
move16();
}
}
@@ -2637,12 +2633,8 @@ static void create_masa_ext_out_meta_fx(
move16();
FOR( dir = 0; dir < numDirections; dir++ )
{
- /* todo: not optimal, but less invasive */
- IF( EQ_32( hQMetaData->q_direction[dir].band_data[b_old].energy_ratio_fx[sf], ONE_IN_Q30 ) )
- {
- hQMetaData->q_direction[dir].band_data[b_old].energy_ratio_fx[sf]--;
- }
- UWord8 tmp = (UWord8) L_shr( hQMetaData->q_direction[dir].band_data[b_old].energy_ratio_fx[sf], Q30 - 8 ); // Q8
+
+ UWord8 tmp = (UWord8) W_extract_h( W_mult_32_16( hQMetaData->q_direction[dir].band_data[b_old].energy_ratio_fx[sf], UINT8_MAX << 1 ) ); // Q0
move16();
extOutMeta->diffuseToTotalRatio[sf][b_new] = (UWord8) sub( extOutMeta->diffuseToTotalRatio[sf][b_new], tmp ); // Q8
move16();
@@ -3105,7 +3097,7 @@ static void decode_ism_ratios_fx(
/* reconstructed values */
FOR( band = 0; band < nbands; band++ )
{
- reconstruct_ism_ratios_fx( ratio_ism_idx[band], n_ism, STEP_PARAM_ISM_POW_RATIO_NBITS_Q15, ratio_ism[sf][band] );
+ reconstruct_ism_ratios_fx( ratio_ism_idx[band], n_ism, STEP_PARAM_ISM_POW_RATIO_NBITS_Q31, ratio_ism[sf][band] );
}
test();
diff --git a/lib_dec/ivas_mc_param_dec_fx.c b/lib_dec/ivas_mc_param_dec_fx.c
index e0671eea034cb86efb7c860a5910555fbbffd545..c25ec972fd15fd62bf8a5b39039c3b284588cd54 100644
--- a/lib_dec/ivas_mc_param_dec_fx.c
+++ b/lib_dec/ivas_mc_param_dec_fx.c
@@ -106,7 +106,7 @@ static ivas_error param_mc_get_diff_proto_info_fx( const Word32 *proto_mtx, cons
static void param_mc_update_mixing_matrices_fx( PARAM_MC_DEC_HANDLE hParamMC, Word32 *mixing_matrix[], Word16 *mixing_matrix_fx, Word32 *mixing_matrix_res[], Word16 *mixing_matrix_res_exp, const UWord16 nX, const UWord16 nY );
-static void param_mc_protoSignalComputation_fx( Word32 *RealBuffer_fx, Word32 *ImagBuffer_fx, Word32 *proto_frame_f_fx, const PARAM_MC_DIFF_PROTO_INFO *diff_proto_info, const Word16 num_freq_bands /*, Word16 RealBuffer_fx_e, Word16 ImagBuffer_fx_e, Word16 *common_e*/ );
+static void param_mc_protoSignalComputation_fx( Word32 *RealBuffer_fx, Word32 *ImagBuffer_fx, Word32 *proto_frame_f_fx, const PARAM_MC_DIFF_PROTO_INFO *diff_proto_info, const Word16 num_freq_bands, const Word16 Cldfb_Real_Imag_exp, Word16 *proto_frame_f_fx_q /* Word16 ImagBuffer_fx_e, Word16 *common_e*/ );
/*-------------------------------------------------------------------------
* ivas_param_mc_dec_open()
@@ -1983,7 +1983,7 @@ void ivas_param_mc_dec_render_fx(
param_mc_protoSignalComputation_fx( &hParamMC->Cldfb_RealBuffer_tc_fx[hParamMC->slots_rendered * nchan_transport * hParamMC->num_freq_bands],
&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 );
+ hParamMC->num_freq_bands, hParamMC->Cldfb_RealBuffer_tc_e, &hParamMC->proto_frame_f_fx_q );
/*-----------------------------------------------------------------*
* frequency domain decorrelation
*-----------------------------------------------------------------*/
@@ -1995,7 +1995,7 @@ void ivas_param_mc_dec_render_fx(
DIRAC_SYNTHESIS_COV_MC_LS,
nchan_transport,
hParamMC->proto_frame_f_fx,
- Q5,
+ hParamMC->proto_frame_f_fx_q,
hParamMC->diff_proto_info->num_protos_diff,
hParamMC->diff_proto_info->proto_index_diff,
hParamMC->proto_frame_dec_f_fx, // output
@@ -2151,6 +2151,7 @@ void ivas_param_mc_dec_render_fx(
}
}
+#ifndef OPT_BIN_RENDERER_V2
FOR( Word16 idx1 = 0; idx1 < BINAURAL_CHANNELS; idx1++ )
{
FOR( Word16 idx2 = 0; idx2 < hParamMC->subframe_nbslots[subframe_idx]; idx2++ )
@@ -2159,6 +2160,7 @@ void ivas_param_mc_dec_render_fx(
Scale_sig32( Cldfb_ImagBuffer_Binaural_fx[idx1][idx2], CLDFB_NO_CHANNELS_MAX, sub( Q6, input_q ) ); // Q6
}
}
+#endif /* OPT_BIN_RENDERER_V2 */
/* update combined orientation access index */
ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, hParamMC->num_freq_bands * hParamMC->subframe_nbslots[subframe_idx] );
}
@@ -2319,8 +2321,9 @@ static void param_mc_protoSignalComputation_fx(
Word32 *ImagBuffer_fx, /* i : CLDFB samples of the transport channels (imaginary part) */
Word32 *proto_frame_f_fx, /* o : interleaved complex prototype CLDFB samples */
const PARAM_MC_DIFF_PROTO_INFO *diff_proto_info, /* i : prototype generation information */
- const Word16 num_freq_bands /* i : number of frequency bands for the prototypes */
-)
+ const Word16 num_freq_bands, /* i : number of frequency bands for the prototypes */
+ const Word16 Cldfb_Real_Imag_exp, /*i: Exponent of real and imag buffers */
+ Word16 *proto_frame_f_fx_q )
{
Word16 band;
Word16 proto_ch_idx, source_ch_cnt;
@@ -2365,6 +2368,8 @@ static void param_mc_protoSignalComputation_fx(
move32();
p_proto_frame_fx++;
}
+ *proto_frame_f_fx_q = sub( 30, Cldfb_Real_Imag_exp );
+ move16();
}
}
diff --git a/lib_dec/ivas_mc_paramupmix_dec_fx.c b/lib_dec/ivas_mc_paramupmix_dec_fx.c
index 783b9494027c138af93c72ea4ef777b4b1494fb2..7a1ef11264aed8b90cece436cd7da8ae86087755 100644
--- a/lib_dec/ivas_mc_paramupmix_dec_fx.c
+++ b/lib_dec/ivas_mc_paramupmix_dec_fx.c
@@ -847,6 +847,7 @@ static void ivas_mc_paramupmix_dec_sf(
Cldfb_RealBuffer_subfr_fx,
Cldfb_ImagBuffer_subfr_fx, &input_q );
+#ifndef OPT_BIN_RENDERER_V2
FOR( Word16 idx1 = 0; idx1 < BINAURAL_CHANNELS; idx1++ )
{
FOR( Word16 idx2 = 0; idx2 < MAX_PARAM_SPATIAL_SUBFRAMES; idx2++ )
@@ -855,6 +856,7 @@ static void ivas_mc_paramupmix_dec_sf(
Scale_sig32( Cldfb_ImagBuffer_Binaural_fx[idx1][idx2], CLDFB_NO_CHANNELS_MAX, sub( 6, input_q ) ); // Q6
}
}
+#endif /* OPT_BIN_RENDERER_V2 */
/* Implement CLDFB synthesis */
FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ )
{
diff --git a/lib_dec/ivas_mct_core_dec_fx.c b/lib_dec/ivas_mct_core_dec_fx.c
index b42eb534b34af52b78b359306728ea7fd919f4a3..08359826a48825d19a6ef9a170789f5938b68f6a 100644
--- a/lib_dec/ivas_mct_core_dec_fx.c
+++ b/lib_dec/ivas_mct_core_dec_fx.c
@@ -198,7 +198,10 @@ void ivas_mct_core_dec(
Word16 tcx_offset;
Word16 tcx_offsetFB;
Word16 left_rect;
- Word16 L_spec, scale, tmp1, tmp2;
+ Word16 L_spec;
+#ifndef OPT_SBA_DEC_PATH
+ Word16 scale, tmp1, tmp2;
+#endif /* OPT_SBA_DEC_PATH */
#ifdef DEBUG_MCT
float nrg[MCT_MAX_CHANNELS];
#endif
@@ -218,11 +221,18 @@ void ivas_mct_core_dec(
move16();
FOR( cpe_id = 0; cpe_id < nCPE; cpe_id++ )
{
+#ifndef OPT_SBA_DEC_PATH
FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
{
sts[i] = hCPE[cpe_id]->hCoreCoder[ch];
i = add( i, 1 );
}
+#else /* OPT_SBA_DEC_PATH */
+ FOR( ch = 0; ch < CPE_CHANNELS; ( ch++, i++ ) )
+ {
+ sts[i] = hCPE[cpe_id]->hCoreCoder[ch];
+ }
+#endif /* OPT_SBA_DEC_PATH */
}
i = 0;
@@ -268,7 +278,61 @@ void ivas_mct_core_dec(
{
CONTINUE;
}
+#ifdef OPT_SBA_DEC_PATH
+ IF( EQ_16( st->core, TCX_10_CORE ) )
+ {
+ Word16 L_frame_2 = shr( st->L_frame, 1 );
+ Word16 L_frameTCX_2 = shr( st->hTcxDec->L_frameTCX, 1 );
+ nSubframes = NB_DIV; // assuming NB_DIV is 2. Below logic needs to be modified if NB_DIV changes.
+ move16();
+ FOR( k = 0; k < nSubframes; k++ )
+ {
+ L_spec = shr( st->hTcxCfg->tcx_coded_lines, 1 );
+ move32();
+ init_tcx_info_fx( st, L_frame_2, L_frameTCX_2, k, bfi, &tcx_offset, &tcx_offsetFB, &L_frame, &L_frameTCX, &left_rect, &L_spec );
+
+ Word16 x_e, x_len;
+ /* mono or dual mono IGF decoding */
+ x_e = sub( 31, q_x[ch] );
+ decoder_tcx_IGF_mono_fx( st, x_fx[ch][k], &x_e, &x_len, L_frame, left_rect, bfi, k );
+ q_x[ch] = sub( 31 - 12, x_e ); // Shift to bring x to Q12
+ move16();
+ FOR( i = 0; i < x_len; i++ )
+ {
+ x_fx[ch][k][i] = L_shr( x_fx[ch][k][i], q_x[ch] );
+ move32();
+ }
+ q_x[ch] = Q12;
+ move16();
+ }
+ }
+ ELSE
+ {
+ nSubframes = 1;
+ move16();
+ {
+ L_spec = st->hTcxCfg->tcx_coded_lines;
+ move32();
+
+ init_tcx_info_fx( st, st->L_frame, st->hTcxDec->L_frameTCX, 0, bfi, &tcx_offset, &tcx_offsetFB, &L_frame, &L_frameTCX, &left_rect, &L_spec );
+
+ Word16 x_e, x_len;
+ /* mono or dual mono IGF decoding */
+ x_e = sub( 31, q_x[ch] );
+ decoder_tcx_IGF_mono_fx( st, x_fx[ch][0], &x_e, &x_len, L_frame, left_rect, bfi, 0 );
+ q_x[ch] = sub( 31 - 12, x_e ); // Shift to bring x to Q12
+ move16();
+ FOR( i = 0; i < x_len; i++ )
+ {
+ x_fx[ch][0][i] = L_shr( x_fx[ch][0][i], q_x[ch] );
+ move32();
+ }
+ q_x[ch] = Q12;
+ move16();
+ }
+ }
+#else /* OPT_SBA_DEC_PATH */
IF( EQ_16( st->core, TCX_10_CORE ) )
{
nSubframes = NB_DIV;
@@ -304,6 +368,7 @@ void ivas_mct_core_dec(
q_x[ch] = Q12;
move16();
}
+#endif /* OPT_SBA_DEC_PATH */
}
}
ELSE
@@ -318,6 +383,9 @@ void ivas_mct_core_dec(
* MCT processing
*--------------------------------------------------------------------------------*/
+#ifdef OPT_SBA_DEC_PATH
+ apply_MCT_dec_fx( hMCT, sts, x_fx );
+#else /* OPT_SBA_DEC_PATH */
apply_MCT_dec_fx( hMCT, sts, x_fx, q_x );
FOR( ch = 0; ch < nChannels; ch++ )
{
@@ -331,6 +399,7 @@ void ivas_mct_core_dec(
q_x[ch] = Q12;
move16();
}
+#endif /* OPT_SBA_DEC_PATH */
}
pop_wmops();
diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c
index 32403b11a032c798ae52da7a70721396466c7f6f..ec7b8c697a6a5d59fbd1980cb4a0e0adcfdab15d 100644
--- a/lib_dec/ivas_mct_dec_fx.c
+++ b/lib_dec/ivas_mct_dec_fx.c
@@ -85,7 +85,7 @@ ivas_error ivas_mct_dec_fx(
set16_fx( x_len[1], 0, NB_DIV );
Decoder_State **sts;
Word32 *p_output_orig_fx[2];
- Word32 synth_32_fx[CPE_CHANNELS][L_FRAME_PLUS];
+ Word32 synth_fx_32[CPE_CHANNELS][L_FRAME_PLUS];
Word16 synth_fx[CPE_CHANNELS][L_FRAME_PLUS]; //(Q_synth)
Word32 ivas_total_brate;
ivas_error error;
@@ -168,7 +168,7 @@ ivas_error ivas_mct_dec_fx(
FOR( n = 0; n < CPE_CHANNELS; n++ )
{
p_output_orig_fx[n] = output_fx[n];
- output_fx[n] = synth_32_fx[n];
+ output_fx[n] = synth_fx_32[n];
}
}
@@ -390,7 +390,6 @@ ivas_error ivas_mct_dec_fx(
/*----------------------------------------------------------------*
* CoreCoder Post-processing and updates
*----------------------------------------------------------------*/
- Word32 synth_fx_32[CPE_CHANNELS][L_FRAME48k];
FOR( n = 0; n < CPE_CHANNELS; n++ )
{
@@ -398,7 +397,7 @@ 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_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( synth_fx[n], synth_fx_32[n], output_frame, sub( Q11, ( sub( 15, e_sig[n] ) ) ) ); // Q11
Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[n]->hHQ_core->old_out_fx, hCPE->hCoreCoder[n]->hHQ_core->old_out_fx32, output_frame, sub( Q11, hCPE->hCoreCoder[n]->hHQ_core->Q_old_wtda ) );
ivas_post_proc_fx( NULL, hCPE, n, synth_fx_32[n], NULL, output_frame, 1, Q11 );
Copy_Scale_sig_32_16( synth_fx_32[n], synth_fx[n], output_frame, sub( sub( 15, e_sig[n] ), Q11 ) ); // Q0
diff --git a/lib_dec/ivas_mct_dec_mct_fx_fx.c b/lib_dec/ivas_mct_dec_mct_fx_fx.c
index 0f20c1ec0fbdd12dc61b9d97a6d8bf256733fbb5..0d998b355f87a39a661e643ec386ac8edbfec77b 100644
--- a/lib_dec/ivas_mct_dec_mct_fx_fx.c
+++ b/lib_dec/ivas_mct_dec_mct_fx_fx.c
@@ -165,8 +165,12 @@ void ivas_mct_dec_mct_fx(
static void applyGlobalILD_fx(
Decoder_State **sts,
MCT_DEC_HANDLE hMCT,
- Word32 *x[MCT_MAX_CHANNELS][NB_DIV],
- Word16 q_x[MCT_MAX_CHANNELS] )
+ Word32 *x[MCT_MAX_CHANNELS][NB_DIV]
+#ifndef OPT_SBA_DEC_PATH
+ ,
+ Word16 q_x[MCT_MAX_CHANNELS]
+#endif /* OPT_SBA_DEC_PATH */
+)
{
Word16 ch, k;
Word16 nSubframes, L_subframeTCX;
@@ -207,9 +211,14 @@ static void applyGlobalILD_fx(
FOR( k = 0; k < nSubframes; k++ )
{
v_multc_fixed( x[ch][k], qratio, x[ch][k], L_subframeTCX ); // Qx - 5 + q_qratio
+#ifdef OPT_SBA_DEC_PATH
+ scale_sig32( x[ch][k], L_subframeTCX, sub( 5, q_qratio ) );
+#endif /* OPT_SBA_DEC_PATH */
}
+#ifndef OPT_SBA_DEC_PATH
q_x[ch] = add( sub( q_x[ch], 5 ), q_qratio );
move16();
+#endif /* OPT_SBA_DEC_PATH */
}
ELSE
{
@@ -228,10 +237,14 @@ static void applyGlobalILD_fx(
*----------------------------------------------------------*/
void apply_MCT_dec_fx(
- MCT_DEC_HANDLE hMCT, /* i/o: MCT decoder structure */
- Decoder_State **sts, /* i/o: decoder state structure */
- Word32 *x[MCT_MAX_CHANNELS][NB_DIV], /* i/o: decoded and dequan. spect. input to MCT */
- Word16 q_x[MCT_MAX_CHANNELS] )
+ MCT_DEC_HANDLE hMCT, /* i/o: MCT decoder structure */
+ Decoder_State **sts, /* i/o: decoder state structure */
+ Word32 *x[MCT_MAX_CHANNELS][NB_DIV] /* i/o: decoded and dequan. spect. input to MCT */
+#ifndef OPT_SBA_DEC_PATH
+ ,
+ Word16 q_x[MCT_MAX_CHANNELS]
+#endif /* OPT_SBA_DEC_PATH */
+)
{
Word16 pair;
MCT_DEC_BLOCK_DATA_HANDLE hBlock;
@@ -240,10 +253,18 @@ void apply_MCT_dec_fx(
{
hBlock = hMCT->hBlockData[pair];
+#ifndef OPT_SBA_DEC_PATH
stereo_decoder_tcx_fx( hBlock->hStereoMdct, hBlock->mask, &x[hBlock->ch2][0], &x[hBlock->ch1][0], &x[hBlock->ch2][0], hBlock->hStereoMdct->mdct_stereo_mode, sts[hBlock->ch1]->core, sts[hBlock->ch2]->core, sts[0]->igf, sts[0]->hTcxDec->L_frameTCX, sts[1]->hTcxDec->L_frameTCX, 1, TCX_20_CORE, TCX_20_CORE, 0, &q_x[hBlock->ch2], &q_x[hBlock->ch1] );
+#else /* OPT_SBA_DEC_PATH */
+ stereo_decoder_tcx_fx( hBlock->hStereoMdct, hBlock->mask, &x[hBlock->ch2][0], &x[hBlock->ch1][0], &x[hBlock->ch2][0], hBlock->hStereoMdct->mdct_stereo_mode, sts[hBlock->ch1]->core, sts[hBlock->ch2]->core, sts[0]->igf, sts[0]->hTcxDec->L_frameTCX, sts[1]->hTcxDec->L_frameTCX, 1, TCX_20_CORE, TCX_20_CORE, 0 );
+#endif /* OPT_SBA_DEC_PATH */
}
+#ifndef OPT_SBA_DEC_PATH
applyGlobalILD_fx( sts, hMCT, x, q_x );
+#else /* OPT_SBA_DEC_PATH */
+ applyGlobalILD_fx( sts, hMCT, x );
+#endif /* OPT_SBA_DEC_PATH */
return;
}
diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c
index fabebede4e6e468526331188d065f9086d1715c9..4e90792fba310f9b3bc3ba5fd43fc770460c6774 100644
--- a/lib_dec/ivas_mdct_core_dec_fx.c
+++ b/lib_dec/ivas_mdct_core_dec_fx.c
@@ -737,7 +737,11 @@ void ivas_mdct_core_invQ_fx(
q_r = sub( 30, sts[1]->hTonalMDCTConc->lastBlockData.spectralData_exp );
/* both input in same Q */
+#ifndef OPT_SBA_DEC_PATH
stereo_decoder_tcx_fx( hCPE->hStereoMdct, ms_mask, x_0[1], &spectralData_tmp[0], &spectralData_tmp[1], &hCPE->hStereoMdct->mdct_stereo_mode[0], sts[0]->core, sts[1]->core, sts[0]->igf, L_frameTCX[0], L_frameTCX[1], 0, sts[0]->last_core, sts[1]->last_core, 1, &q_r, &q_l );
+#else /* OPT_SBA_DEC_PATH */
+ stereo_decoder_tcx_fx( hCPE->hStereoMdct, ms_mask, x_0[1], &spectralData_tmp[0], &spectralData_tmp[1], &hCPE->hStereoMdct->mdct_stereo_mode[0], sts[0]->core, sts[1]->core, sts[0]->igf, L_frameTCX[0], L_frameTCX[1], 0, sts[0]->last_core, sts[1]->last_core, 1 );
+#endif /* OPT_SBA_DEC_PATH */
Copy_Scale_sig_32_16( spectralData_tmp[0], sts[0]->hTonalMDCTConc->lastBlockData.spectralData, L_frameTCX[0], -15 ); // q_l - 15
Copy_Scale_sig_32_16( spectralData_tmp[1], sts[1]->hTonalMDCTConc->lastBlockData.spectralData, L_frameTCX[1], -15 ); // q_r - 15
diff --git a/lib_dec/ivas_output_config_fx.c b/lib_dec/ivas_output_config_fx.c
index 3a0960960d9ed0eeef3bcc80374f9bdf45ca28a4..17999496e39f56e8b84c60feb75495912ae60951 100644
--- a/lib_dec/ivas_output_config_fx.c
+++ b/lib_dec/ivas_output_config_fx.c
@@ -239,16 +239,6 @@ void ivas_renderer_select(
move16();
}
-#if 0 // def DEBUGGING /*temp disabling this as paramMC crashes with CREND*/
- IF ( st_ivas->hRenderConfig->renderer_type_override == IVAS_RENDER_TYPE_OVERRIDE_CREND )
- {
- *renderer_type = RENDERER_BINAURAL_MIXER_CONV;
- }
- ELSE IF ( st_ivas->hRenderConfig->renderer_type_override == IVAS_RENDER_TYPE_OVERRIDE_FASTCONV )
- {
- *renderer_type = RENDERER_BINAURAL_FASTCONV;
- }
-#endif
test();
IF( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation )
{
diff --git a/lib_dec/ivas_qmetadata_dec_fx.c b/lib_dec/ivas_qmetadata_dec_fx.c
index 6e36c77657fd6e14953745bd19391bf7781d71c4..c1be6caf82100f929c75342db0b7101db89fc2b4 100644
--- a/lib_dec/ivas_qmetadata_dec_fx.c
+++ b/lib_dec/ivas_qmetadata_dec_fx.c
@@ -72,8 +72,7 @@ static Word16 read_coherence_data_fx( UWord16 *bitstream, Word16 *p_bit_pos, IVA
static Word16 ivas_qmetadata_raw_decode_dir_512_fx( IVAS_QDIRECTION *q_direction, UWord16 *bitstream, Word16 *index, const Word16 nbands, const Word16 start_band, const SPHERICAL_GRID_DATA *sph_grid16 );
static Word16 read_surround_coherence( UWord16 *bitstream, Word16 *p_bit_pos, IVAS_QMETADATA *hQMetaData );
static ivas_error read_huf( Word16 *num_bits_read, const UWord16 *bitstream, UWord16 *out, const Word16 start_pos, const Word16 len, const Word16 *huff_code, const Word16 max_len );
-const Word16 inv_dfRatio_qsteps[9] = { 0, 0, ONE_IN_Q14, 0, 5461, 0, 0, 0, 2341 }; // Q14
-
+const Word32 inv_dfRatio_qsteps[9] = { 0, 0, ONE_IN_Q30, 0, 357913941, 0, 0, 0, 153391689 }; // Q30
/*-----------------------------------------------------------------------*
* Global function definitions
@@ -223,7 +222,7 @@ Word16 ivas_qmetadata_dec_decode(
IF( EQ_16( hQMetaData->twoDirBands[b], 1 ) )
{
Word32 diffRatio_fx, dir1ratio_fx, dir2ratio_fx;
- Word16 dfRatio_fx;
+ Word32 dfRatio_fx;
Word16 dfRatio_qsteps;
diffRatio_fx = diffuseness_reconstructions_fx[hQMetaData->q_direction[0].band_data[b].energy_ratio_index[0]]; // Q30
@@ -233,17 +232,25 @@ Word16 ivas_qmetadata_dec_decode(
/* already encoded as total and ratios in HO-DirAC */
IF( hodirac_flag )
{
-
- dfRatio_fx = usdequant_fx( hQMetaData->q_direction[1].band_data[dir2band].energy_ratio_index[0], 0 /* Q15 */, inv_dfRatio_qsteps[dfRatio_qsteps] ); // Q15
+ dfRatio_fx = usdequant32_fx( hQMetaData->q_direction[1].band_data[dir2band].energy_ratio_index[0], 0 /* Q15 */, inv_dfRatio_qsteps[dfRatio_qsteps] ); // Q31
dir1ratio_fx = L_sub( ONE_IN_Q30, diffRatio_fx );
- dir2ratio_fx = L_shl( (Word32) dfRatio_fx, Q15 ); /*Q30*/
+ dir2ratio_fx = L_shr( dfRatio_fx, 1 ); /*Q30*/
}
ELSE
{
- dfRatio_fx = usdequant_fx( hQMetaData->q_direction[1].band_data[dir2band].energy_ratio_index[0], shr( MAX_16, 1 ), shr( inv_dfRatio_qsteps[dfRatio_qsteps], 1 ) ); // Q15
+ IF( EQ_16( hQMetaData->q_direction[1].band_data[dir2band].energy_ratio_index[0], sub( dfRatio_qsteps, 1 ) ) )
+ {
+ dfRatio_fx = MAX_32; // Q31
+ move16();
+ dir1ratio_fx = L_sub( ONE_IN_Q30, diffRatio_fx ); // Q30
+ }
+ ELSE
+ {
+ dfRatio_fx = usdequant32_fx( hQMetaData->q_direction[1].band_data[dir2band].energy_ratio_index[0], L_shr( MAX_32, 1 ), L_shr( inv_dfRatio_qsteps[dfRatio_qsteps], 1 ) ); // Q31
+ dir1ratio_fx = Mpy_32_32( L_sub( ONE_IN_Q30, diffRatio_fx ), dfRatio_fx ); // Q30
+ }
- dir1ratio_fx = Mpy_32_16_1( L_sub( ONE_IN_Q30, diffRatio_fx ), dfRatio_fx ); // Q30
- dir2ratio_fx = L_sub( L_sub( ONE_IN_Q30, diffRatio_fx ), dir1ratio_fx ); // Q30
+ dir2ratio_fx = L_sub( L_sub( ONE_IN_Q30, diffRatio_fx ), dir1ratio_fx ); // Q30
}
/* Requantize the 1 - dirRatio separately for each direction to obtain inverted dirRatio index. These are used in further decoding. */
diff --git a/lib_dec/ivas_rom_dec.c b/lib_dec/ivas_rom_dec_fx.c
similarity index 100%
rename from lib_dec/ivas_rom_dec.c
rename to lib_dec/ivas_rom_dec_fx.c
diff --git a/lib_dec/ivas_sba_rendering_internal_fx.c b/lib_dec/ivas_sba_rendering_internal_fx.c
index bbe63e965c4dd80be1cedec78bd8365bdd4b3a92..ba8c529d71c83365484a127b9f30b36a60e37d1e 100644
--- a/lib_dec/ivas_sba_rendering_internal_fx.c
+++ b/lib_dec/ivas_sba_rendering_internal_fx.c
@@ -77,7 +77,11 @@ void ivas_sba2mc_cldfb_fixed(
FOR( m = 0; m < nb_channels_in; m++ )
{
- g_fx = hoa_dec_mtx[( ( SBA_NHARM_HOA3 * n ) + m )]; // Q29
+#ifdef OPT_BIN_RENDERER_V2
+ g_fx = L_shl_sat( hoa_dec_mtx[( ( SBA_NHARM_HOA3 * n ) + m )], Q2 );
+#else /* OPT_BIN_RENDERER_V2 */
+ g_fx = hoa_dec_mtx[( ( SBA_NHARM_HOA3 * n ) + m )]; // Q29
+#endif /* OPT_BIN_RENDERER_V2 */
p_realOut_fx = realOut_fx[n];
p_imagOut_fx = imagOut_fx[n];
@@ -87,9 +91,15 @@ void ivas_sba2mc_cldfb_fixed(
p_imag_fx = ImagBuffer[m][iBlock]; /*Q_imag*/
FOR( iBand = 0; iBand < nb_bands; iBand++ )
{
+#ifdef OPT_BIN_RENDERER_V2
+ *p_realOut_fx = Madd_32_32( *p_realOut_fx, g_fx, *( p_real_fx++ ) ); // Q_real
+ move32();
+ *p_imagOut_fx = Madd_32_32( *p_imagOut_fx, g_fx, *( p_imag_fx++ ) ); // Q_imag
+#else /* OPT_BIN_RENDERER_V2 */
*p_realOut_fx = L_add( *p_realOut_fx, Mpy_32_32( L_shl_sat( g_fx, Q2 ), *( p_real_fx++ ) ) ); // Q_real
move32();
- *p_imagOut_fx = L_add( *p_imagOut_fx, Mpy_32_32( L_shl_sat( g_fx, Q2 ), *( p_imag_fx++ ) ) ); // Q_imag
+ *p_imagOut_fx = L_add( *p_imagOut_fx, Mpy_32_32( L_shl_sat( g_fx, Q2 ), *( p_imag_fx++ ) ) ); // Q_imag
+#endif /* OPT_BIN_RENDERER_V2 */
move32();
p_realOut_fx++;
p_imagOut_fx++;
@@ -167,7 +177,11 @@ void ivas_mc2sba_fx(
/* Add LFE to omni W with gain*/
FOR( k = 0; k < output_frame; k++ )
{
+#ifdef OPT_BIN_RENDERER_V2
+ buffer_tmp_fx[0][k] = Madd_32_16( buffer_tmp_fx[0][k], L_shl( in_buffer_td_fx[i][k], 1 ), gain_lfe_fx ); /*Q+14-15+1==Q*/
+#else /* OPT_BIN_RENDERER_V2 */
buffer_tmp_fx[0][k] = L_add( buffer_tmp_fx[0][k], L_shl( Mult_32_16( in_buffer_td_fx[i][k], gain_lfe_fx ), 1 ) ); /*Q+14-15+1==Q*/
+#endif /* OPT_BIN_RENDERER_V2 */
move32();
}
}
@@ -196,7 +210,11 @@ void ivas_mc2sba_fx(
{
FOR( k = 0; k < output_frame; k++ )
{
+#ifdef OPT_BIN_RENDERER_V2
+ buffer_tmp_fx[j][k] = Madd_32_32( buffer_tmp_fx[j][k], L_shl_sat( in_buffer_td_fx[i][k], 2 ), gains_fx[j] ); /*Q+29-31+2==Q*/
+#else /* OPT_BIN_RENDERER_V2 */
buffer_tmp_fx[j][k] = L_add( buffer_tmp_fx[j][k], L_shl( Mult_32_32( in_buffer_td_fx[i][k], gains_fx[j] ), 2 ) ); /*Q+29-31+2==Q*/
+#endif /* OPT_BIN_RENDERER_V2 */
move32();
}
}
diff --git a/lib_dec/ivas_spar_decoder_fx.c b/lib_dec/ivas_spar_decoder_fx.c
index 29a307425a79cc30eb962a6a5259b245e4dd6c60..fa5f6779f226c76a74349ef72962303548c8ddb6 100644
--- a/lib_dec/ivas_spar_decoder_fx.c
+++ b/lib_dec/ivas_spar_decoder_fx.c
@@ -1163,6 +1163,69 @@ void ivas_spar_get_parameters_fx(
move16();
Word16 add_weight_fx = sub( MAX_WORD16, weight_fx );
Word16 add_weight_20ms_fx = sub( MAX_WORD16, weight_20ms_fx );
+#ifdef OPT_SBA_DEC_V2_BE
+ Word16 out_flag[IVAS_MAX_FB_MIXER_OUT_CH];
+
+ Word32 band_bool = LT_16( split_band, IVAS_MAX_NUM_BANDS );
+
+ FOR( out_ch = 0; out_ch < num_ch_out; out_ch++ )
+ {
+ /* 20ms cross-fade for Transport channels in all frequency bands */
+ /* sub-frame processing for missing channels in all frequency bands*/
+ out_flag[out_ch] = band_bool && ( 0 == ivas_is_res_channel( out_ch, hSpar->hMdDec->spar_md_cfg.nchan_transport ) );
+ move16();
+ }
+ Word32 frame_bool = GT_16( hSpar->i_subframe, 3 );
+
+ FOR( out_ch = 0; out_ch < num_ch_out; out_ch++ )
+ {
+ IF( out_flag[out_ch] )
+ {
+ IF( frame_bool )
+ {
+ FOR( spar_band = 0; spar_band < num_spar_bands; spar_band++ )
+ {
+ FOR( in_ch = 0; in_ch < num_ch_in; in_ch++ )
+ {
+ par_mat_fx[out_ch][in_ch][spar_band] = Madd_32_16( Mpy_32_16_1( hSpar->hMdDec->mixer_mat_prev_fx[ts1][out_ch][in_ch][spar_band], weight_fx ),
+ hSpar->hMdDec->mixer_mat_prev_fx[ts0][out_ch][in_ch][spar_band], add_weight_fx );
+ move32();
+ }
+ }
+ }
+ ELSE
+ {
+
+
+ FOR( spar_band = 0; spar_band < num_spar_bands; spar_band++ )
+ {
+ FOR( in_ch = 0; in_ch < num_ch_in; in_ch++ )
+ {
+ {
+ par_mat_fx[out_ch][in_ch][spar_band] = hSpar->hMdDec->mixer_mat_fx[out_ch][in_ch][spar_band]; /*hSpar->hMdDec->Q_mixer_mat*/
+ move32();
+ }
+ }
+ }
+ }
+ }
+ ELSE
+ {
+ FOR( spar_band = 0; spar_band < num_spar_bands; spar_band++ )
+ {
+ FOR( in_ch = 0; in_ch < num_ch_in; in_ch++ )
+ {
+ /* 20ms Transport channel reconstruction with matching encoder/decoder processing */
+ Word16 prev_idx = SPAR_DIRAC_SPLIT_START_BAND < IVAS_MAX_NUM_BANDS ? 1 : 0; /* if SPAR_DIRAC_SPLIT_START_BAND == IVAS_MAX_NUM_BANDS, then the sub-frame mixer_mat delay line is not active */
+ move16();
+ par_mat_fx[out_ch][in_ch][spar_band] = Madd_32_16( Mpy_32_16_1( hSpar->hMdDec->mixer_mat_prev_fx[prev_idx][out_ch][in_ch][spar_band], add_weight_20ms_fx ),
+ hSpar->hMdDec->mixer_mat_fx[out_ch][in_ch][spar_band], weight_20ms_fx ); /*hSpar->hMdDec->Q_mixer_mat*/
+ move32();
+ }
+ }
+ }
+ }
+#else /* OPT_SBA_DEC_V2_BE */
FOR( spar_band = 0; spar_band < num_spar_bands; spar_band++ )
{
FOR( out_ch = 0; out_ch < num_ch_out; out_ch++ )
@@ -1202,7 +1265,7 @@ void ivas_spar_get_parameters_fx(
}
}
}
-
+#endif /* OPT_SBA_DEC_V2_BE */
return;
}
diff --git a/lib_dec/ivas_spar_md_dec_fx.c b/lib_dec/ivas_spar_md_dec_fx.c
index 7f487a75c272279cbc0ab168f8116743069db676..36b77732ae7e3eb7e66d842147d5a9830d7bae39 100644
--- a/lib_dec/ivas_spar_md_dec_fx.c
+++ b/lib_dec/ivas_spar_md_dec_fx.c
@@ -1318,6 +1318,14 @@ static void ivas_get_spar_matrices_fx(
tmp_C2_re_fx[0][j] = Mpy_32_32( active_w_dm_fac_fx, L_negate( hMdDec->spar_md.band_coeffs[( b + ( i_ts * IVAS_MAX_NUM_BANDS ) )].pred_re_fx[j - 1] ) ); // Q31 *Q22=Q22
move32();
}
+#ifdef OPT_SBA_DEC_V2_BE
+ re_fx1 = Madd_32_32( ONE_IN_Q13, tmp_C2_re_fx[0][1], tmp_C1_re_fx[1][0] ); // Q13+Q13
+
+ re_fx1 = Madd_32_32( re_fx1, tmp_C2_re_fx[0][2], tmp_C1_re_fx[2][0] ); // Q13+Q13
+
+ tmp_dm_re_fx[0][0] = L_shl( Madd_32_32( re_fx1, tmp_C2_re_fx[0][3], tmp_C1_re_fx[3][0] ), Q9 ); // (Q13+Q13) << Q9 = Q22;
+ //
+#else /* OPT_SBA_DEC_V2_BE */
re_fx = Mpy_32_32( tmp_C2_re_fx[0][1], tmp_C1_re_fx[1][0] ); // Q22 *Q22 =Q13
re_fx1 = L_add( ONE_IN_Q13, re_fx ); // Q13+Q13
@@ -1326,6 +1334,7 @@ static void ivas_get_spar_matrices_fx(
re_fx = Mpy_32_32( tmp_C2_re_fx[0][3], tmp_C1_re_fx[3][0] ); // Q22 *Q22 =Q13
tmp_dm_re_fx[0][0] = L_shl( L_add( re_fx1, re_fx ), Q9 ); // (Q13+Q13) << Q9 = Q22;
+#endif /* OPT_SBA_DEC_V2_BE */
move32();
IF( EQ_16( dyn_active_w_flag, 1 ) )
@@ -1401,7 +1410,11 @@ static void ivas_get_spar_matrices_fx(
{
FOR( k = dmx_ch; k < numch_out; k++ )
{
+#ifndef OPT_SBA_DEC_V2_BE
IF( EQ_16( sub( j, dmx_ch ), sub( k, dmx_ch ) ) )
+#else /* OPT_SBA_DEC_V2_BE */
+ IF( EQ_16( j, k ) )
+#endif /* OPT_SBA_DEC_V2_BE */
{
tmpP_re_fx[j][k] = hMdDec->spar_md.band_coeffs[add( b, i_mult( i_ts, IVAS_MAX_NUM_BANDS ) )].P_re_fx[sub( k, dmx_ch )]; // Q22
move32();
diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h
index 891be05be14fd4ac5fa6f6ad7804fc53d73dac77..4eb40f337f615439667a69cdfbff37ad71838330 100644
--- a/lib_dec/ivas_stat_dec.h
+++ b/lib_dec/ivas_stat_dec.h
@@ -573,7 +573,7 @@ typedef struct ivas_param_mc_dec_data_structure
Word32 *proto_matrix_int_fx;
Word16 proto_matrix_int_len;
Word16 proto_matrix_int_e;
-
+ Word16 proto_frame_f_fx_q;
/*sub-modules*/
HANDLE_DIRAC_DECORR_PARAMS h_freq_domain_decorr_ap_params;
HANDLE_DIRAC_DECORR_STATE h_freq_domain_decorr_ap_state;
diff --git a/lib_dec/ivas_stereo_cng_dec.c b/lib_dec/ivas_stereo_cng_dec_fx.c
similarity index 99%
rename from lib_dec/ivas_stereo_cng_dec.c
rename to lib_dec/ivas_stereo_cng_dec_fx.c
index 6b8a8f949435c9e234e51f8e02128cb8ba4073de..8ec147ff7edf274f9e776c99924c186ac0e6a6c3 100644
--- a/lib_dec/ivas_stereo_cng_dec.c
+++ b/lib_dec/ivas_stereo_cng_dec_fx.c
@@ -1368,8 +1368,8 @@ static void FindEmEs_fx(
temp_q = 0;
move16();
}
- log_res = BASOP_Util_Log2( square_res );
- es_em_fx = Mpy_32_32( log_res, 1616107501 ); // 25+30-31
+ log_res = L_add( BASOP_Util_Log2( square_res ), L_shl( temp_q, Q25 ) );
+ es_em_fx = Mpy_32_32( log_res, 1616107501 /* 5 * (ln(2)/ln(10)) */ ); // 25+30-31
/* long-term estimate */
*lt_es_em_fx = L_add( Mpy_32_32( 858993459, *lt_es_em_fx ), Mpy_32_32( 1288490188, es_em_fx ) ); /* Q24 */
move32();
diff --git a/lib_dec/ivas_stereo_dft_dec.c b/lib_dec/ivas_stereo_dft_dec.c
deleted file mode 100644
index 92ae9159cd99b32fcbf18839bed6508bc7bcbe70..0000000000000000000000000000000000000000
--- a/lib_dec/ivas_stereo_dft_dec.c
+++ /dev/null
@@ -1,494 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository. All Rights Reserved.
-
- This software is protected by copyright law and by international treaties.
- The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository retain full ownership rights in their respective contributions in
- the software. This notice grants no license of any kind, including but not limited to patent
- license, nor is any license granted by implication, estoppel or otherwise.
-
- Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
- contributions.
-
- This software is provided "AS IS", without any express or implied warranties. The software is in the
- development stage. It is intended exclusively for experts who have experience with such software and
- solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
- and fitness for a particular purpose are hereby disclaimed and excluded.
-
- Any dispute, controversy or claim arising under or in relation to providing this software shall be
- submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
- accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
- the United Nations Convention on Contracts on the International Sales of Goods.
-
-*******************************************************************************************************/
-
-#include
-#include
-#include "options.h"
-#include
-#include "cnst.h"
-#include "rom_com.h"
-#include "rom_dec.h"
-#include "prot_fx.h"
-#include "ivas_cnst.h"
-#include "ivas_rom_com.h"
-#include "ivas_rom_com_fx.h"
-#include "ivas_rom_dec.h"
-#include "wmc_auto.h"
-#include "ivas_prot_fx.h"
-
-/*-------------------------------------------------------------------*
- * Local constants
- *-------------------------------------------------------------------*/
-
-#define STEFI_DELAY_IND( d, buf_ind ) ( ( buf_ind ) + STEREO_DFT_PAST_MAX - ( d ) + 1 ) % STEREO_DFT_PAST_MAX
-
-#define STEREO_DFT_RES_RATIO_LIMIT_FX ( Word32 )( 0x170A3D71 )
-#define STEREO_DFT_STEFFI_DELAY_SHORT 2
-#define STEREO_DFT_STEFFI_DELAY_LONG 4
-#define STEREO_DFT_STEFFI_DELAY_OFFSET 2
-
-
-#define STEREO_DFT_BPF_SIZE 40 /* BPF: Number of weights for BPF in DFT: 40*40Hz=1.6kHz*/
-
-
-/*-------------------------------------------------------------------------
- * Local function prototypes
- *-------------------------------------------------------------------------*/
-
-
-/*-------------------------------------------------------------------------
- * stereo_dft_dec_create()
- *
- * Create DFT stereo handle
- *------------------------------------------------------------------------*/
-
-
-/*-------------------------------------------------------------------------
- * stereo_dft_dec_open()
- *
- * Open DFT decoder stereo handle
- *-------------------------------------------------------------------------*/
-
-
-/*-------------------------------------------------------------------------
- * stereo_dft_dec_reset()
- *
- * Reset DFT stereo memories
- *------------------------------------------------------------------------*/
-
-/*-------------------------------------------------------------------------
- * stereo_dft_dec_update()
- *
- * Update DFT memories for new frame
- *-------------------------------------------------------------------------*/
-
-/*-------------------------------------------------------------------------
- * stereo_dft_dec_destroy()
- *
- * destroy DFT stereo handle
- *-------------------------------------------------------------------------*/
-
-void stereo_dft_dec_destroy(
- STEREO_DFT_DEC_DATA_HANDLE *hStereoDft_glob /* i/o: decoder DFT stereo handle */
-)
-{
- STEREO_DFT_DEC_DATA_HANDLE hStereoDft;
-
- hStereoDft = *hStereoDft_glob;
-
- IF( hStereoDft->hConfig != NULL )
- {
- free( hStereoDft->hConfig );
- hStereoDft->hConfig = NULL;
- }
-
- IF( hStereoDft->hBpf != NULL )
- {
- free( hStereoDft->hBpf );
- hStereoDft->hBpf = NULL;
- }
-
- IF( hStereoDft->hTcxLtpDec != NULL )
- {
- free( hStereoDft->hTcxLtpDec );
- hStereoDft->hTcxLtpDec = NULL;
- }
-
- free( hStereoDft );
- hStereoDft = NULL;
-
- return;
-}
-
-
-/*-------------------------------------------------------------------------
- * stereo_dft_dec_analyze()
- *
- * DFT analysis on a 20ms frame
- *-------------------------------------------------------------------------*/
-
-void stereo_dft_dec_analyze_fx(
- CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */
- const Word32 *input_fx, /* i : input signal q*/
- Word32 out_DFT_fx[CPE_CHANNELS][STEREO_DFT_BUF_MAX], /* o : DFT buffers q_out_DFT*/
- const Word16 chan, /* i : channel number Q0*/
- const Word16 input_frame, /* i : input frame size Q0*/
- const Word16 output_frame, /* i : output frame size Q0*/
- const DFT_STEREO_DEC_ANA_TYPE ana_type, /* i : type of signal to analyse */
- const Word16 k_offset, /* i : offset of DFT Q0*/
- const Word16 delay, /* i : delay in samples FOR input signal Q0*/
- Word16 *q,
- Word16 *q_out_DFT )
-{
-
- Word16 i, k;
- STEREO_DFT_DEC_DATA_HANDLE hStereoDft;
- Word32 *pInput_fx, *pInput_buff_fx;
- Word32 *mem_fx, input_buff_fx[STEREO_DFT32MS_OVL_MAX + L_FRAME48k];
- Word32 DFT_fx[STEREO_DFT32MS_N_MAX], *pDFT_out_fx;
- Word16 NFFT, NFFT_core, ovl, zp;
- Word16 offset;
- Word32 fac_fx;
- const Word16 *trigo_fx, *win_left_fx, *win_right_fx, *win2_fx;
- Word16 trigo_dec_fx[STEREO_DFT32MS_N_MAX / 2 + 1];
- Word16 trigo_step;
- Word32 inputFs;
- Word16 delay_dec;
- Word16 mem_size;
- Word16 ovl2;
-
- push_wmops( "DFT_analysis" );
-
- hStereoDft = hCPE->hStereoDft;
-
- assert( output_frame == STEREO_DFT_NBDIV * hStereoDft->N );
-
- /*-----------------------------------------------------------------*
- * Initialization
- *-----------------------------------------------------------------*/
-
- IF( EQ_16( input_frame, output_frame ) )
- {
- trigo_fx = hStereoDft->dft_trigo_fx;
- trigo_step = i_mult( hStereoDft->dft_trigo_step, STEREO_DFT_TRIGO_DEC_STEP ); /* Q0 */
- win_right_fx = hStereoDft->win32ms_fx; /* Q15 */
- win_left_fx = hStereoDft->win32ms_fx; /* Q15 */
- win2_fx = hStereoDft->win232ms_fx; /* Q15 */
-
- test();
- IF( EQ_32( ana_type, DFT_STEREO_DEC_ANA_BPF ) )
- {
- assert( ( chan == 0 ) && "DFT stereo: BPF memory only FOR M channel" );
- mem_fx = hCPE->input_mem_BPF_fx[chan]; /* Q11 */
- }
- ELSE IF( EQ_32( ana_type, DFT_STEREO_DEC_ANA_LB ) || EQ_32( ana_type, DFT_STEREO_DEC_ANA_LB_ADD ) )
- {
- mem_fx = hCPE->input_mem_LB_fx[chan]; /* Q11 */
- }
- ELSE
- {
- mem_fx = hCPE->input_mem_fx[chan]; /* Q11 */
- }
- }
- ELSE IF( EQ_16( input_frame, L_FRAME ) )
- {
- trigo_fx = hStereoDft->dft_trigo_12k8_fx; /* Q15 */
- trigo_step = STEREO_DFT_TRIGO_SRATE_12k8_STEP * STEREO_DFT_TRIGO_DEC_STEP;
- move16();
- win_right_fx = hStereoDft->win32ms_12k8_fx; /* Q15 */
- win_left_fx = hStereoDft->win32ms_12k8_fx; /* Q15 */
- win2_fx = hStereoDft->win232ms_12k8_fx; /* Q15 */
-
- test();
- IF( EQ_32( ana_type, DFT_STEREO_DEC_ANA_BPF ) )
- {
- assert( ( chan == 0 ) && "DFT stereo: BPF memory only FOR M channel" );
- mem_fx = hCPE->input_mem_BPF_fx[chan]; /* Q11 */
- }
- ELSE IF( EQ_32( ana_type, DFT_STEREO_DEC_ANA_LB ) || EQ_32( ana_type, DFT_STEREO_DEC_ANA_LB_ADD ) )
- {
- mem_fx = hCPE->input_mem_LB_fx[chan]; /* Q11 */
- }
- ELSE
- {
- assert( ( chan == 1 ) && "12.8kHz sampling rate only FOR second channel, i.e. residual coding or allpass signal" );
- mem_fx = hCPE->input_mem_fx[chan]; /* Q11 */
- }
- }
- ELSE IF( EQ_16( input_frame, L_FRAME16k ) )
- {
- trigo_fx = hStereoDft->dft_trigo_16k_fx; /* Q15 */
- trigo_step = STEREO_DFT_TRIGO_SRATE_16k_STEP * STEREO_DFT_TRIGO_DEC_STEP;
- move16();
- win_right_fx = hStereoDft->win32ms_16k_fx; /* Q15 */
- win_left_fx = hStereoDft->win32ms_16k_fx; /* Q15 */
- win2_fx = hStereoDft->win232ms_16k_fx; /* Q15 */
-
- test();
- IF( EQ_32( ana_type, DFT_STEREO_DEC_ANA_BPF ) )
- {
- assert( ( chan == 0 ) && "DFT stereo: BPF memory only FOR M channel" );
- mem_fx = hCPE->input_mem_BPF_fx[chan]; /* Q11 */
- }
- ELSE IF( EQ_32( ana_type, DFT_STEREO_DEC_ANA_LB ) || EQ_32( ana_type, DFT_STEREO_DEC_ANA_LB_ADD ) )
- {
- mem_fx = hCPE->input_mem_LB_fx[chan]; /* Q11 */
- }
- ELSE
- {
- assert( ( chan == 1 ) && ( hCPE->hStereoDft->hConfig->res_pred_mode == STEREO_DFT_RESPRED_ESF ) && "16kHz sampling rate only FOR second channel with allpass signal" );
- mem_fx = hCPE->input_mem_fx[chan]; /* Q11 */
- }
- }
- ELSE IF( EQ_16( input_frame, L_FRAME8k ) )
- {
- assert( ( chan == 1 ) && "DFT stereo: 8kHz analysis only FOR residual coding" );
- trigo_fx = hStereoDft->dft_trigo_8k_fx; /* Q15 */
- trigo_step = STEREO_DFT_TRIGO_SRATE_8k_STEP * STEREO_DFT_TRIGO_DEC_STEP;
- move16();
- win_right_fx = hStereoDft->win32ms_8k_fx; /* Q15 */
- win_left_fx = hStereoDft->win32ms_8k_fx; /* Q15 */
- win2_fx = hStereoDft->win232ms_8k_fx; /* Q15 */
- mem_fx = hCPE->input_mem_fx[chan]; /* Q11 */
- }
- ELSE
- {
- IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error in DFT stereo: sampling rate not supported" );
- mem_fx = NULL; /* to avoid compilation warning */
- trigo_fx = NULL; /* to avoid compilation warning */
- trigo_step = -1; /* to avoid compilation warning */
- move16();
- win_right_fx = NULL; /* to avoid compilation warning */
- win_left_fx = NULL; /* to avoid compilation warning */
- win2_fx = NULL; /* to avoid compilation warning */
- }
-
- inputFs = L_mult0( input_frame, FRAMES_PER_SEC ); /* Q0 */
- delay_dec = NS2SA_FX2( inputFs, STEREO_DFT32MS_OVL_NS );
- move16();
- zp = NS2SA_FX2( inputFs, STEREO_DFT32MS_ZP_NS );
- move16();
- ovl = NS2SA_FX2( inputFs, STEREO_DFT32MS_OVL_NS );
- move16();
- NFFT = NS2SA_FX2( inputFs, STEREO_DFT32MS_N_NS );
- Word16 qfac_fx;
- fac_fx = BASOP_Util_Divide3232_Scale_newton( hStereoDft->NFFT, NFFT, &qfac_fx ); /* qfac_fx */
- qfac_fx = sub( 31, qfac_fx );
- ovl2 = NS2SA_FX2( inputFs, STEREO_DFT32MS_OVL2_NS );
- move16();
-
- /* Offset FOR the time buffers */
- assert( ( delay >= -NS2SA( input_frame * FRAMES_PER_SEC, STEREO_DFT_DELAY_DEC_BWE_NS + STEREO_DFT_OVL_NS / 2 ) ) && ( delay <= NS2SA( input_frame * FRAMES_PER_SEC, STEREO_DFT_OVL_NS ) ) );
- mem_size = add( delay_dec, delay );
-
- /* Update buffers */
- Copy32( mem_fx, input_buff_fx, mem_size ); /* Q11 */
- Copy32( input_fx, input_buff_fx + mem_size, input_frame ); /* q */
- Copy32( input_buff_fx + input_frame, mem_fx, mem_size ); /* q */
- pInput_buff_fx = input_buff_fx; /* q */
-
- test();
- IF( EQ_16( hCPE->nchan_out, 1 ) && ( hCPE->hStereoDft->hConfig->res_cod_mode == STEREO_DFT_RES_COD_OFF ) )
- {
- pop_wmops();
- return;
- }
-
-
- /*-----------------------------------------------------------------*
- * DFT Analysis: loop over frame
- *-----------------------------------------------------------------*/
-
- assert( ( k_offset <= STEREO_DFT_NBDIV ) );
-
- FOR( i = 0; i < NFFT / 4; i++ )
- {
- trigo_dec_fx[i] = trigo_fx[i * trigo_step];
- move16();
- trigo_dec_fx[NFFT / 2 - i] = trigo_fx[i * trigo_step];
- move16();
- }
- trigo_dec_fx[NFFT / 4] = trigo_fx[NFFT / 4 * trigo_step];
- move16();
-
- FOR( k = 0; k < STEREO_DFT_NBDIV - k_offset; k++ )
- {
- set32_fx( DFT_fx, 0, STEREO_DFT32MS_N_MAX );
- IF( k == 0 )
- {
- offset = 0;
- move16();
- }
- ELSE
- {
- /* If OVL2 = OVL offset = 10ms */
- offset = NS2SA_FX2( inputFs, STEREO_DFT32MS_WIN_CENTER_NS - STEREO_DFT32MS_OVL2_NS / 2 );
- move16();
- }
-
- pInput_fx = pInput_buff_fx + offset; /* q */
- pDFT_out_fx = out_DFT_fx[chan] + i_mult( k, STEREO_DFT32MS_N_MAX ); /* q_out_DFT */
-
- /*Forwards FFT: L and R*/
- /* Zero Padding & Flat Portion */
- Copy32( pInput_fx, DFT_fx + zp, sub( NFFT, i_mult( 2, zp ) ) ); /* q */
-
- /* Overlapping portions */
- IF( k == 0 )
- {
- FOR( i = 0; i < ovl; i++ )
- {
- DFT_fx[i + zp] = Mpy_32_16_1( DFT_fx[i + zp], win_left_fx[STEREO_DFT32MS_STEP * i] ); /* q */
- move32();
- }
- FOR( i = 0; i < ovl2; i++ )
- {
- DFT_fx[NFFT - zp - 1 - i] = Mpy_32_16_1( DFT_fx[NFFT - zp - 1 - i], win2_fx[i] ); /* q */
- move32();
- }
- }
- ELSE
- {
- FOR( i = 0; i < ovl2; i++ )
- {
- DFT_fx[i + zp] = Mpy_32_16_1( DFT_fx[i + zp], win2_fx[i] ); /* q */
- move32();
- }
- FOR( i = 0; i < ovl; i++ )
- {
- DFT_fx[NFFT - zp - i - 1] = Mpy_32_16_1( DFT_fx[NFFT - zp - i - 1], win_right_fx[STEREO_DFT32MS_STEP * i] ); /* q */
- move32();
- }
- }
- Word16 q_DFT, q_shift, guarded_bits;
- q_DFT = *q;
- move16();
- guarded_bits = find_guarded_bits_fx( NFFT );
- q_shift = sub( L_norm_arr( DFT_fx, NFFT ), guarded_bits );
-
- FOR( Word16 j = 0; j < NFFT; j++ )
- {
- DFT_fx[j] = L_shl( DFT_fx[j], q_shift ); /* q + q_shift*/
- move32();
- }
-
- q_DFT = add( q_DFT, q_shift );
-
- rfft_fx( DFT_fx, trigo_dec_fx, NFFT, -1 );
-
- q_shift = sub( L_norm_arr( DFT_fx, NFFT ), sub( 31, qfac_fx ) );
- FOR( Word16 j = 0; j < NFFT; j++ )
- {
- DFT_fx[j] = L_shl( DFT_fx[j], q_shift ); /* q + q_shift */
- move32();
- }
- q_DFT = add( q_DFT, q_shift );
- IF( sub( q_out_DFT[chan], q_DFT ) > 0 )
- {
- FOR( Word32 j = 0; j < NFFT; j++ )
- {
- out_DFT_fx[chan][j] = L_shr( out_DFT_fx[chan][j], sub( q_out_DFT[chan], q_DFT ) ); /* q_DFT */
- move32();
- }
- q_out_DFT[chan] = q_DFT;
- move16();
- }
- ELSE
- {
- FOR( Word32 j = 0; j < NFFT; j++ )
- {
- DFT_fx[j] = L_shr( DFT_fx[j], sub( q_DFT, q_out_DFT[chan] ) ); /* q_DFT */
- move32();
- }
- q_DFT = q_out_DFT[chan];
- move16();
- }
-
- /*Resampling: filtering+scaling*/
- test();
- test();
- IF( ( ana_type == DFT_STEREO_DEC_ANA_FB ) || EQ_32( ana_type, DFT_STEREO_DEC_ANA_LB ) || EQ_32( ana_type, DFT_STEREO_DEC_ANA_NOCORE ) )
- {
- pDFT_out_fx[0] = L_shl( Mpy_32_32( DFT_fx[0], fac_fx ), sub( 31, qfac_fx ) ); /*DC*/ /* qDFT */
- move32();
- IF( EQ_16( NFFT, hStereoDft->NFFT ) ) /*Nyquist*/
- {
- pDFT_out_fx[1] = L_shl( Mpy_32_32( DFT_fx[1], fac_fx ), sub( 31, qfac_fx ) ); /* qDFT */
- move32();
- }
- ELSE
- {
- pDFT_out_fx[1] = 0;
- move32();
- }
- FOR( i = 2; i < NFFT; i++ )
- {
- pDFT_out_fx[i] = L_shl( Mpy_32_32( DFT_fx[i], fac_fx ), sub( 31, qfac_fx ) ); /* qDFT */
- move32();
- }
- FOR( i = NFFT; i < hStereoDft->NFFT; i++ )
- {
- pDFT_out_fx[i] = 0; /* qDFT */
- move32();
- }
- }
- ELSE IF( EQ_32( ana_type, DFT_STEREO_DEC_ANA_BPF ) )
- {
- pDFT_out_fx[0] = L_sub( pDFT_out_fx[0], L_shl( Mpy_32_32( Mpy_32_32( DFT_fx[0], fac_fx ), dft_bpf_weights_fx[0] ), sub( 32, qfac_fx ) ) ); /* qDFT */
- move32();
-
- FOR( i = 1; i < STEREO_DFT_BPF_SIZE; i++ )
- {
- pDFT_out_fx[2 * i] = L_sub( pDFT_out_fx[2 * i], L_shl( Mpy_32_32( Mpy_32_32( DFT_fx[2 * i], fac_fx ), dft_bpf_weights_fx[i] ), sub( 32, qfac_fx ) ) ); /* qDFT */
- move32();
- pDFT_out_fx[2 * i + 1] = L_sub( pDFT_out_fx[2 * i + 1], L_shl( Mpy_32_32( Mpy_32_32( DFT_fx[2 * i + 1], fac_fx ), dft_bpf_weights_fx[i] ), sub( 32, qfac_fx ) ) ); /* qDFT */
- move32();
- }
- }
- ELSE IF( EQ_32( ana_type, DFT_STEREO_DEC_ANA_HB_ADD ) )
- {
- NFFT_core = NS2SA_FX2( L_mult0( hCPE->hCoreCoder[0]->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_N_NS ); /* Q0 */
- move16();
-
- FOR( i = NFFT_core; i < NFFT; i++ )
- {
- pDFT_out_fx[i] = L_add( L_shl( Mpy_32_32( DFT_fx[i], fac_fx ), sub( 31, qfac_fx ) ), pDFT_out_fx[i] ); /* qDFT */
- move32();
- }
- }
- ELSE
- {
- pDFT_out_fx[0] = L_add( pDFT_out_fx[0], L_shl( Mpy_32_32( DFT_fx[0], fac_fx ), sub( 31, qfac_fx ) ) ); /*DC*/ /* qDFT */
- move32();
- IF( EQ_16( NFFT, hStereoDft->NFFT ) ) /*Nyquist*/
- {
- pDFT_out_fx[1] = L_add( L_shl( Mpy_32_32( DFT_fx[1], fac_fx ), sub( 31, qfac_fx ) ), pDFT_out_fx[1] ); /* qDFT */
- move32();
- }
- FOR( i = 2; i < NFFT; i++ )
- {
- pDFT_out_fx[i] = L_add( L_shl( Mpy_32_32( DFT_fx[i], fac_fx ), sub( 31, qfac_fx ) ), pDFT_out_fx[i] ); /* qDFT */
- move32();
- }
- }
- }
-
- pop_wmops();
- return;
-}
-
-
-/*---------------------------------------------------------------
- * stereo_dft_dec_smooth_parameters()
- *
- *
- * ---------------------------------------------------------------*/
diff --git a/lib_dec/ivas_stereo_dft_dec_dmx_fx.c b/lib_dec/ivas_stereo_dft_dec_dmx_fx.c
index e82005965b6a452c7d327e89d07b42b082048c7b..cdb64e46c62c5c73343b11c8a202d9623923088b 100644
--- a/lib_dec/ivas_stereo_dft_dec_dmx_fx.c
+++ b/lib_dec/ivas_stereo_dft_dec_dmx_fx.c
@@ -102,6 +102,8 @@ void stereo_dft_unify_dmx_fx(
Word16 num_plocs;
Word32 plocsi[STEREO_DFT_RES_N_PEAKS_MAX];
+ set32_fx( DFT_PRED_RES, 0, STEREO_DFT32MS_N_32k );
+
output_frame = extract_l( Mult_32_16( st0->output_Fs, INV_FRAME_PER_SEC_Q15 ) ); /* Q0 */
samp_ratio = BASOP_Util_Divide3232_Scale( st0->sr_core, st0->output_Fs, &q_samp_ratio );
samp_ratio = shr( samp_ratio, sub( Q15 - Q12, q_samp_ratio ) );
diff --git a/lib_dec/ivas_stereo_dft_dec_fx.c b/lib_dec/ivas_stereo_dft_dec_fx.c
index 324f2b7f3a07c34f698ba7c232b91052895d4661..914c7fad17b255839f68fe1cfd598a15caef587a 100644
--- a/lib_dec/ivas_stereo_dft_dec_fx.c
+++ b/lib_dec/ivas_stereo_dft_dec_fx.c
@@ -268,7 +268,7 @@ void stereo_dft_dec_reset_fx(
}
/*-------------------------------------------------------------------------
- * stereo_dft_dec_open()
+ * stereo_dft_dec_open_fx()
*
* Open DFT decoder stereo handle
*-------------------------------------------------------------------------*/
@@ -402,6 +402,8 @@ ivas_error stereo_dft_dec_create_fx(
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TCX-LTP handle\n" ) );
}
set_zero_fx( hStereoDft_loc->hb_nrg_subr_fx, STEREO_DFT_NBDIV ); /*Setting hb_nrg_subr_fx to zero*/
+ hStereoDft_loc->q_hb_nrg_subr = Q31;
+ move16();
hStereoDft_loc->hConfig->force_mono_transmission = 0;
move16();
@@ -682,6 +684,402 @@ void stereo_dft_dec_update_fx(
return;
}
+/*-------------------------------------------------------------------------
+ * stereo_dft_dec_destroy_fx()
+ *
+ * destroy DFT stereo handle
+ *-------------------------------------------------------------------------*/
+
+void stereo_dft_dec_destroy_fx(
+ STEREO_DFT_DEC_DATA_HANDLE *hStereoDft_glob /* i/o: decoder DFT stereo handle */
+)
+{
+ STEREO_DFT_DEC_DATA_HANDLE hStereoDft;
+
+ hStereoDft = *hStereoDft_glob;
+
+ IF( hStereoDft->hConfig != NULL )
+ {
+ free( hStereoDft->hConfig );
+ hStereoDft->hConfig = NULL;
+ }
+
+ IF( hStereoDft->hBpf != NULL )
+ {
+ free( hStereoDft->hBpf );
+ hStereoDft->hBpf = NULL;
+ }
+
+ IF( hStereoDft->hTcxLtpDec != NULL )
+ {
+ free( hStereoDft->hTcxLtpDec );
+ hStereoDft->hTcxLtpDec = NULL;
+ }
+
+ free( hStereoDft );
+ hStereoDft = NULL;
+
+ return;
+}
+
+
+/*-------------------------------------------------------------------------
+ * stereo_dft_dec_analyze_fx()
+ *
+ * DFT analysis on a 20ms frame
+ *-------------------------------------------------------------------------*/
+
+void stereo_dft_dec_analyze_fx(
+ CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */
+ const Word32 *input_fx, /* i : input signal q*/
+ Word32 out_DFT_fx[CPE_CHANNELS][STEREO_DFT_BUF_MAX], /* o : DFT buffers q_out_DFT*/
+ const Word16 chan, /* i : channel number Q0*/
+ const Word16 input_frame, /* i : input frame size Q0*/
+ const Word16 output_frame, /* i : output frame size Q0*/
+ const DFT_STEREO_DEC_ANA_TYPE ana_type, /* i : type of signal to analyse */
+ const Word16 k_offset, /* i : offset of DFT Q0*/
+ const Word16 delay, /* i : delay in samples FOR input signal Q0*/
+ Word16 *q,
+ Word16 *q_out_DFT )
+{
+
+ Word16 i, k;
+ STEREO_DFT_DEC_DATA_HANDLE hStereoDft;
+ Word32 *pInput_fx, *pInput_buff_fx;
+ Word32 *mem_fx, input_buff_fx[STEREO_DFT32MS_OVL_MAX + L_FRAME48k];
+ Word32 DFT_fx[STEREO_DFT32MS_N_MAX], *pDFT_out_fx;
+ Word16 NFFT, NFFT_core, ovl, zp;
+ Word16 offset;
+ Word32 fac_fx;
+ const Word16 *trigo_fx, *win_left_fx, *win_right_fx, *win2_fx;
+ Word16 trigo_dec_fx[STEREO_DFT32MS_N_MAX / 2 + 1];
+ Word16 trigo_step;
+ Word32 inputFs;
+ Word16 delay_dec;
+ Word16 mem_size;
+ Word16 ovl2;
+
+ push_wmops( "DFT_analysis" );
+
+ hStereoDft = hCPE->hStereoDft;
+
+ assert( output_frame == STEREO_DFT_NBDIV * hStereoDft->N );
+
+ /*-----------------------------------------------------------------*
+ * Initialization
+ *-----------------------------------------------------------------*/
+
+ IF( EQ_16( input_frame, output_frame ) )
+ {
+ trigo_fx = hStereoDft->dft_trigo_fx;
+ trigo_step = i_mult( hStereoDft->dft_trigo_step, STEREO_DFT_TRIGO_DEC_STEP ); /* Q0 */
+ win_right_fx = hStereoDft->win32ms_fx; /* Q15 */
+ win_left_fx = hStereoDft->win32ms_fx; /* Q15 */
+ win2_fx = hStereoDft->win232ms_fx; /* Q15 */
+
+ test();
+ IF( EQ_32( ana_type, DFT_STEREO_DEC_ANA_BPF ) )
+ {
+ assert( ( chan == 0 ) && "DFT stereo: BPF memory only FOR M channel" );
+ mem_fx = hCPE->input_mem_BPF_fx[chan]; /* Q11 */
+ }
+ ELSE IF( EQ_32( ana_type, DFT_STEREO_DEC_ANA_LB ) || EQ_32( ana_type, DFT_STEREO_DEC_ANA_LB_ADD ) )
+ {
+ mem_fx = hCPE->input_mem_LB_fx[chan]; /* Q11 */
+ }
+ ELSE
+ {
+ mem_fx = hCPE->input_mem_fx[chan]; /* Q11 */
+ }
+ }
+ ELSE IF( EQ_16( input_frame, L_FRAME ) )
+ {
+ trigo_fx = hStereoDft->dft_trigo_12k8_fx; /* Q15 */
+ trigo_step = STEREO_DFT_TRIGO_SRATE_12k8_STEP * STEREO_DFT_TRIGO_DEC_STEP;
+ move16();
+ win_right_fx = hStereoDft->win32ms_12k8_fx; /* Q15 */
+ win_left_fx = hStereoDft->win32ms_12k8_fx; /* Q15 */
+ win2_fx = hStereoDft->win232ms_12k8_fx; /* Q15 */
+
+ test();
+ IF( EQ_32( ana_type, DFT_STEREO_DEC_ANA_BPF ) )
+ {
+ assert( ( chan == 0 ) && "DFT stereo: BPF memory only FOR M channel" );
+ mem_fx = hCPE->input_mem_BPF_fx[chan]; /* Q11 */
+ }
+ ELSE IF( EQ_32( ana_type, DFT_STEREO_DEC_ANA_LB ) || EQ_32( ana_type, DFT_STEREO_DEC_ANA_LB_ADD ) )
+ {
+ mem_fx = hCPE->input_mem_LB_fx[chan]; /* Q11 */
+ }
+ ELSE
+ {
+ assert( ( chan == 1 ) && "12.8kHz sampling rate only FOR second channel, i.e. residual coding or allpass signal" );
+ mem_fx = hCPE->input_mem_fx[chan]; /* Q11 */
+ }
+ }
+ ELSE IF( EQ_16( input_frame, L_FRAME16k ) )
+ {
+ trigo_fx = hStereoDft->dft_trigo_16k_fx; /* Q15 */
+ trigo_step = STEREO_DFT_TRIGO_SRATE_16k_STEP * STEREO_DFT_TRIGO_DEC_STEP;
+ move16();
+ win_right_fx = hStereoDft->win32ms_16k_fx; /* Q15 */
+ win_left_fx = hStereoDft->win32ms_16k_fx; /* Q15 */
+ win2_fx = hStereoDft->win232ms_16k_fx; /* Q15 */
+
+ test();
+ IF( EQ_32( ana_type, DFT_STEREO_DEC_ANA_BPF ) )
+ {
+ assert( ( chan == 0 ) && "DFT stereo: BPF memory only FOR M channel" );
+ mem_fx = hCPE->input_mem_BPF_fx[chan]; /* Q11 */
+ }
+ ELSE IF( EQ_32( ana_type, DFT_STEREO_DEC_ANA_LB ) || EQ_32( ana_type, DFT_STEREO_DEC_ANA_LB_ADD ) )
+ {
+ mem_fx = hCPE->input_mem_LB_fx[chan]; /* Q11 */
+ }
+ ELSE
+ {
+ assert( ( chan == 1 ) && ( hCPE->hStereoDft->hConfig->res_pred_mode == STEREO_DFT_RESPRED_ESF ) && "16kHz sampling rate only FOR second channel with allpass signal" );
+ mem_fx = hCPE->input_mem_fx[chan]; /* Q11 */
+ }
+ }
+ ELSE IF( EQ_16( input_frame, L_FRAME8k ) )
+ {
+ assert( ( chan == 1 ) && "DFT stereo: 8kHz analysis only FOR residual coding" );
+ trigo_fx = hStereoDft->dft_trigo_8k_fx; /* Q15 */
+ trigo_step = STEREO_DFT_TRIGO_SRATE_8k_STEP * STEREO_DFT_TRIGO_DEC_STEP;
+ move16();
+ win_right_fx = hStereoDft->win32ms_8k_fx; /* Q15 */
+ win_left_fx = hStereoDft->win32ms_8k_fx; /* Q15 */
+ win2_fx = hStereoDft->win232ms_8k_fx; /* Q15 */
+ mem_fx = hCPE->input_mem_fx[chan]; /* Q11 */
+ }
+ ELSE
+ {
+ IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error in DFT stereo: sampling rate not supported" );
+ mem_fx = NULL; /* to avoid compilation warning */
+ trigo_fx = NULL; /* to avoid compilation warning */
+ trigo_step = -1; /* to avoid compilation warning */
+ move16();
+ win_right_fx = NULL; /* to avoid compilation warning */
+ win_left_fx = NULL; /* to avoid compilation warning */
+ win2_fx = NULL; /* to avoid compilation warning */
+ }
+
+ inputFs = L_mult0( input_frame, FRAMES_PER_SEC ); /* Q0 */
+ delay_dec = NS2SA_FX2( inputFs, STEREO_DFT32MS_OVL_NS );
+ move16();
+ zp = NS2SA_FX2( inputFs, STEREO_DFT32MS_ZP_NS );
+ move16();
+ ovl = NS2SA_FX2( inputFs, STEREO_DFT32MS_OVL_NS );
+ move16();
+ NFFT = NS2SA_FX2( inputFs, STEREO_DFT32MS_N_NS );
+ Word16 qfac_fx;
+ fac_fx = BASOP_Util_Divide3232_Scale_newton( hStereoDft->NFFT, NFFT, &qfac_fx ); /* qfac_fx */
+ qfac_fx = sub( 31, qfac_fx );
+ ovl2 = NS2SA_FX2( inputFs, STEREO_DFT32MS_OVL2_NS );
+ move16();
+
+ /* Offset FOR the time buffers */
+ assert( ( delay >= -NS2SA( input_frame * FRAMES_PER_SEC, STEREO_DFT_DELAY_DEC_BWE_NS + STEREO_DFT_OVL_NS / 2 ) ) && ( delay <= NS2SA( input_frame * FRAMES_PER_SEC, STEREO_DFT_OVL_NS ) ) );
+ mem_size = add( delay_dec, delay );
+
+ /* Update buffers */
+ Copy32( mem_fx, input_buff_fx, mem_size ); /* Q11 */
+ Copy32( input_fx, input_buff_fx + mem_size, input_frame ); /* q */
+ Copy32( input_buff_fx + input_frame, mem_fx, mem_size ); /* q */
+ pInput_buff_fx = input_buff_fx; /* q */
+
+ test();
+ IF( EQ_16( hCPE->nchan_out, 1 ) && ( hCPE->hStereoDft->hConfig->res_cod_mode == STEREO_DFT_RES_COD_OFF ) )
+ {
+ pop_wmops();
+ return;
+ }
+
+
+ /*-----------------------------------------------------------------*
+ * DFT Analysis: loop over frame
+ *-----------------------------------------------------------------*/
+
+ assert( ( k_offset <= STEREO_DFT_NBDIV ) );
+
+ FOR( i = 0; i < NFFT / 4; i++ )
+ {
+ trigo_dec_fx[i] = trigo_fx[i * trigo_step];
+ move16();
+ trigo_dec_fx[NFFT / 2 - i] = trigo_fx[i * trigo_step];
+ move16();
+ }
+ trigo_dec_fx[NFFT / 4] = trigo_fx[NFFT / 4 * trigo_step];
+ move16();
+
+ FOR( k = 0; k < STEREO_DFT_NBDIV - k_offset; k++ )
+ {
+ set32_fx( DFT_fx, 0, STEREO_DFT32MS_N_MAX );
+ IF( k == 0 )
+ {
+ offset = 0;
+ move16();
+ }
+ ELSE
+ {
+ /* If OVL2 = OVL offset = 10ms */
+ offset = NS2SA_FX2( inputFs, STEREO_DFT32MS_WIN_CENTER_NS - STEREO_DFT32MS_OVL2_NS / 2 );
+ move16();
+ }
+
+ pInput_fx = pInput_buff_fx + offset; /* q */
+ pDFT_out_fx = out_DFT_fx[chan] + i_mult( k, STEREO_DFT32MS_N_MAX ); /* q_out_DFT */
+
+ /*Forwards FFT: L and R*/
+ /* Zero Padding & Flat Portion */
+ Copy32( pInput_fx, DFT_fx + zp, sub( NFFT, i_mult( 2, zp ) ) ); /* q */
+
+ /* Overlapping portions */
+ IF( k == 0 )
+ {
+ FOR( i = 0; i < ovl; i++ )
+ {
+ DFT_fx[i + zp] = Mpy_32_16_1( DFT_fx[i + zp], win_left_fx[STEREO_DFT32MS_STEP * i] ); /* q */
+ move32();
+ }
+ FOR( i = 0; i < ovl2; i++ )
+ {
+ DFT_fx[NFFT - zp - 1 - i] = Mpy_32_16_1( DFT_fx[NFFT - zp - 1 - i], win2_fx[i] ); /* q */
+ move32();
+ }
+ }
+ ELSE
+ {
+ FOR( i = 0; i < ovl2; i++ )
+ {
+ DFT_fx[i + zp] = Mpy_32_16_1( DFT_fx[i + zp], win2_fx[i] ); /* q */
+ move32();
+ }
+ FOR( i = 0; i < ovl; i++ )
+ {
+ DFT_fx[NFFT - zp - i - 1] = Mpy_32_16_1( DFT_fx[NFFT - zp - i - 1], win_right_fx[STEREO_DFT32MS_STEP * i] ); /* q */
+ move32();
+ }
+ }
+ Word16 q_DFT, q_shift, guarded_bits;
+ q_DFT = *q;
+ move16();
+ guarded_bits = find_guarded_bits_fx( NFFT );
+ q_shift = sub( L_norm_arr( DFT_fx, NFFT ), guarded_bits );
+
+ FOR( Word16 j = 0; j < NFFT; j++ )
+ {
+ DFT_fx[j] = L_shl( DFT_fx[j], q_shift ); /* q + q_shift*/
+ move32();
+ }
+
+ q_DFT = add( q_DFT, q_shift );
+
+ rfft_fx( DFT_fx, trigo_dec_fx, NFFT, -1 );
+
+ q_shift = sub( L_norm_arr( DFT_fx, NFFT ), sub( 31, qfac_fx ) );
+ FOR( Word16 j = 0; j < NFFT; j++ )
+ {
+ DFT_fx[j] = L_shl( DFT_fx[j], q_shift ); /* q + q_shift */
+ move32();
+ }
+ q_DFT = add( q_DFT, q_shift );
+ IF( sub( q_out_DFT[chan], q_DFT ) > 0 )
+ {
+ FOR( Word32 j = 0; j < NFFT; j++ )
+ {
+ out_DFT_fx[chan][j] = L_shr( out_DFT_fx[chan][j], sub( q_out_DFT[chan], q_DFT ) ); /* q_DFT */
+ move32();
+ }
+ q_out_DFT[chan] = q_DFT;
+ move16();
+ }
+ ELSE
+ {
+ FOR( Word32 j = 0; j < NFFT; j++ )
+ {
+ DFT_fx[j] = L_shr( DFT_fx[j], sub( q_DFT, q_out_DFT[chan] ) ); /* q_DFT */
+ move32();
+ }
+ q_DFT = q_out_DFT[chan];
+ move16();
+ }
+
+ /*Resampling: filtering+scaling*/
+ test();
+ test();
+ IF( ( ana_type == DFT_STEREO_DEC_ANA_FB ) || EQ_32( ana_type, DFT_STEREO_DEC_ANA_LB ) || EQ_32( ana_type, DFT_STEREO_DEC_ANA_NOCORE ) )
+ {
+ pDFT_out_fx[0] = L_shl( Mpy_32_32( DFT_fx[0], fac_fx ), sub( 31, qfac_fx ) ); /*DC*/ /* qDFT */
+ move32();
+ IF( EQ_16( NFFT, hStereoDft->NFFT ) ) /*Nyquist*/
+ {
+ pDFT_out_fx[1] = L_shl( Mpy_32_32( DFT_fx[1], fac_fx ), sub( 31, qfac_fx ) ); /* qDFT */
+ move32();
+ }
+ ELSE
+ {
+ pDFT_out_fx[1] = 0;
+ move32();
+ }
+ FOR( i = 2; i < NFFT; i++ )
+ {
+ pDFT_out_fx[i] = L_shl( Mpy_32_32( DFT_fx[i], fac_fx ), sub( 31, qfac_fx ) ); /* qDFT */
+ move32();
+ }
+ FOR( i = NFFT; i < hStereoDft->NFFT; i++ )
+ {
+ pDFT_out_fx[i] = 0; /* qDFT */
+ move32();
+ }
+ }
+ ELSE IF( EQ_32( ana_type, DFT_STEREO_DEC_ANA_BPF ) )
+ {
+ pDFT_out_fx[0] = L_sub( pDFT_out_fx[0], L_shl( Mpy_32_32( Mpy_32_32( DFT_fx[0], fac_fx ), dft_bpf_weights_fx[0] ), sub( 32, qfac_fx ) ) ); /* qDFT */
+ move32();
+
+ FOR( i = 1; i < STEREO_DFT_BPF_SIZE; i++ )
+ {
+ pDFT_out_fx[2 * i] = L_sub( pDFT_out_fx[2 * i], L_shl( Mpy_32_32( Mpy_32_32( DFT_fx[2 * i], fac_fx ), dft_bpf_weights_fx[i] ), sub( 32, qfac_fx ) ) ); /* qDFT */
+ move32();
+ pDFT_out_fx[2 * i + 1] = L_sub( pDFT_out_fx[2 * i + 1], L_shl( Mpy_32_32( Mpy_32_32( DFT_fx[2 * i + 1], fac_fx ), dft_bpf_weights_fx[i] ), sub( 32, qfac_fx ) ) ); /* qDFT */
+ move32();
+ }
+ }
+ ELSE IF( EQ_32( ana_type, DFT_STEREO_DEC_ANA_HB_ADD ) )
+ {
+ NFFT_core = NS2SA_FX2( L_mult0( hCPE->hCoreCoder[0]->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_N_NS ); /* Q0 */
+ move16();
+
+ FOR( i = NFFT_core; i < NFFT; i++ )
+ {
+ pDFT_out_fx[i] = L_add( L_shl( Mpy_32_32( DFT_fx[i], fac_fx ), sub( 31, qfac_fx ) ), pDFT_out_fx[i] ); /* qDFT */
+ move32();
+ }
+ }
+ ELSE
+ {
+ pDFT_out_fx[0] = L_add( pDFT_out_fx[0], L_shl( Mpy_32_32( DFT_fx[0], fac_fx ), sub( 31, qfac_fx ) ) ); /*DC*/ /* qDFT */
+ move32();
+ IF( EQ_16( NFFT, hStereoDft->NFFT ) ) /*Nyquist*/
+ {
+ pDFT_out_fx[1] = L_add( L_shl( Mpy_32_32( DFT_fx[1], fac_fx ), sub( 31, qfac_fx ) ), pDFT_out_fx[1] ); /* qDFT */
+ move32();
+ }
+ FOR( i = 2; i < NFFT; i++ )
+ {
+ pDFT_out_fx[i] = L_add( L_shl( Mpy_32_32( DFT_fx[i], fac_fx ), sub( 31, qfac_fx ) ), pDFT_out_fx[i] ); /* qDFT */
+ move32();
+ }
+ }
+ }
+
+ pop_wmops();
+ return;
+}
+
+
/*-------------------------------------------------------------------------
* stereo_dft_dec_synthesize_fx()
*
diff --git a/lib_dec/ivas_stereo_mdct_core_dec_fx.c b/lib_dec/ivas_stereo_mdct_core_dec_fx.c
index 890e5fc9ef6db902a60454e094612449ceac424c..85ae00c9082f3c2ebb62d5de09d2248ca324472c 100644
--- a/lib_dec/ivas_stereo_mdct_core_dec_fx.c
+++ b/lib_dec/ivas_stereo_mdct_core_dec_fx.c
@@ -465,9 +465,11 @@ void stereo_mdct_core_dec_fx(
test();
IF( ( !bfi || ( sts[0]->core != ACELP_CORE || sts[1]->core != ACELP_CORE ) ) && !hCPE->hStereoMdct->isSBAStereoMode )
{
+#ifndef OPT_SBA_DEC_PATH
Word16 q_x_1 = 11, q_x_0 = 11;
move16();
move16();
+#endif /* OPT_SBA_DEC_PATH */
FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
{
@@ -477,7 +479,11 @@ void stereo_mdct_core_dec_fx(
move16();
}
}
+#ifdef OPT_SBA_DEC_PATH
+ stereo_decoder_tcx_fx( hCPE->hStereoMdct, ms_mask, x_0_fx[1], x_fx[0], x_fx[1], &hCPE->hStereoMdct->mdct_stereo_mode[0], sts[0]->core, sts[1]->core, sts[0]->igf, L_frameTCX[0], L_frameTCX[1], 0, sts[0]->last_core, sts[1]->last_core, 0 );
+#else /* OPT_SBA_DEC_PATH */
stereo_decoder_tcx_fx( hCPE->hStereoMdct, ms_mask, x_0_fx[1], x_fx[0], x_fx[1], &hCPE->hStereoMdct->mdct_stereo_mode[0], sts[0]->core, sts[1]->core, sts[0]->igf, L_frameTCX[0], L_frameTCX[1], 0, sts[0]->last_core, sts[1]->last_core, 0, &q_x_1, &q_x_0 );
+#endif /* OPT_SBA_DEC_PATH */
}
ivas_mdct_core_tns_ns_fx( hCPE, fUseTns, tnsData, x_fx, Aq_fx_32, 0, x_e );
@@ -1097,8 +1103,8 @@ static void run_min_stats_fx(
{
arr_tmp = power_spec;
}
- ApplyFdCng_ivas_fx( NULL, 0, arr_tmp, power_spec_q, NULL, NULL, NULL, st, st->bfi, 0 );
- /*=================================================*/
+
+ ApplyFdCng_fx( NULL, 0, arr_tmp, power_spec_q, NULL, NULL, NULL, st, st->bfi, 0 );
}
/* restore VAD (see above) */
diff --git a/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c b/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c
index 8842a6792a8c866cbcc17e6b0b0a9f1a32f7392d..492060a67d4a4527180dbf4e195e7b80e68ce567 100644
--- a/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c
+++ b/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c
@@ -313,9 +313,13 @@ void stereo_decoder_tcx_fx(
const Word16 mct_on, /* i : flag mct block (1) or stereo (0) Q0*/
const Word16 last_core_l, /* i : last core for left channel Q0*/
const Word16 last_core_r, /* i : last core for right channel Q0*/
- const Word16 tmp_plc_upmix, /* i : indicates temp upmix for PLC decision Q0*/
+ const Word16 tmp_plc_upmix /* i : indicates temp upmix for PLC decision Q0*/
+#ifndef OPT_SBA_DEC_PATH
+ ,
Word16 *q_x_ch2,
- Word16 *q_x_ch1 )
+ Word16 *q_x_ch1
+#endif /* OPT_SBA_DEC_PATH */
+)
{
Word16 i, k, sfb, nSubframes;
STEREO_MDCT_BAND_PARAMETERS *sfbConf = NULL;
@@ -361,10 +365,12 @@ void stereo_decoder_tcx_fx(
}
}
inverseMS_fx( sfbConf->sfbOffset[sfbConf->nBandsStereoCore], spec_l[k], spec_r[k], SQRT2_OVER_2_FIXED );
+#ifndef OPT_SBA_DEC_PATH
*q_x_ch2 = *q_x_ch2;
move16();
*q_x_ch1 = *q_x_ch1;
move16();
+#endif /* OPT_SBA_DEC_PATH */
}
ELSE IF( EQ_16( mdct_stereo_mode[k], SMDCT_BW_MS ) )
{
@@ -381,10 +387,12 @@ void stereo_decoder_tcx_fx(
}
}
inverseBwMS_fx( sfbConf->sfbOffset[sfb], sfbConf->sfbOffset[sfb + 1], spec_l[k], spec_r[k], SQRT2_OVER_2_FIXED );
+#ifndef OPT_SBA_DEC_PATH
*q_x_ch2 = *q_x_ch2;
move16();
*q_x_ch1 = *q_x_ch1;
move16();
+#endif /* OPT_SBA_DEC_PATH */
}
}
}
@@ -402,10 +410,12 @@ void stereo_decoder_tcx_fx(
}
}
inverseMS_fx( sub( sfbConf->sfbOffset[sfbConf->sfbCnt], sfbConf->sfbOffset[sfbConf->nBandsStereoCore] ), &spec_l[k][sfbConf->sfbOffset[sfbConf->nBandsStereoCore]], &spec_r[k][sfbConf->sfbOffset[sfbConf->nBandsStereoCore]], SQRT2_OVER_2_FIXED );
+#ifndef OPT_SBA_DEC_PATH
*q_x_ch2 = *q_x_ch2;
move16();
*q_x_ch1 = *q_x_ch1;
move16();
+#endif /* OPT_SBA_DEC_PATH */
}
ELSE IF( EQ_16( hStereoMdct->IGFStereoMode[k], SMDCT_BW_MS ) )
{
@@ -422,10 +432,12 @@ void stereo_decoder_tcx_fx(
}
}
inverseBwMS_fx( sfbConf->sfbOffset[sfb], sfbConf->sfbOffset[sfb + 1], spec_l[k], spec_r[k], SQRT2_OVER_2_FIXED );
+#ifndef OPT_SBA_DEC_PATH
*q_x_ch2 = *q_x_ch2;
move16();
*q_x_ch1 = *q_x_ch1;
move16();
+#endif /* OPT_SBA_DEC_PATH */
}
}
}
@@ -483,8 +495,10 @@ void stereo_decoder_tcx_fx(
nrgRatio = L_shl( nrgRatio, shift ); /* Q26 + shift */
v_multc_fixed( spec_r[k], nrgRatio, spec_r[k], L_frameTCX_r ); /* spec_r will be in Qx + shift - Q5 */
Scale_sig32( spec_r[k], L_frameTCX_r, sub( 5, shift ) ); /* Qx */
+#ifndef OPT_SBA_DEC_PATH
*q_x_ch2 = *q_x_ch2;
move16();
+#endif /* OPT_SBA_DEC_PATH */
}
ELSE IF( ( LT_32( nrgRatio, ONE_IN_Q26 ) ) && ( LT_16( k, tmp2 ) ) )
{
@@ -492,8 +506,10 @@ void stereo_decoder_tcx_fx(
shift = sub( 5, tmp_e );
v_multc_fixed( spec_l[k], inv_nrgRatio, spec_l[k], L_frameTCX_l ); /* spec_r will be in Qx - tmp_e */
Scale_sig32( spec_l[k], L_frameTCX_l, sub( 5, shift ) ); /* Qx */
+#ifndef OPT_SBA_DEC_PATH
*q_x_ch1 = *q_x_ch1;
move16();
+#endif /* OPT_SBA_DEC_PATH */
}
}
} /* for k */
diff --git a/lib_dec/ivas_stereo_switching_dec_fx.c b/lib_dec/ivas_stereo_switching_dec_fx.c
index 677c91ef02395a546bc5d4c4a0f9043174e28175..522e741e82b87d6c3b43800adab58f3b91f170a0 100644
--- a/lib_dec/ivas_stereo_switching_dec_fx.c
+++ b/lib_dec/ivas_stereo_switching_dec_fx.c
@@ -512,7 +512,7 @@ ivas_error stereo_memory_dec_fx(
/* deallocate data structure of the previous CPE mode */
IF( hCPE->hStereoDft != NULL )
{
- stereo_dft_dec_destroy( &( hCPE->hStereoDft ) );
+ stereo_dft_dec_destroy_fx( &( hCPE->hStereoDft ) );
hCPE->hStereoDft = NULL;
}
@@ -684,7 +684,7 @@ ivas_error stereo_memory_dec_fx(
/* deallocate data structure of the previous CPE mode */
IF( hCPE->hStereoDft != NULL )
{
- stereo_dft_dec_destroy( &( hCPE->hStereoDft ) );
+ stereo_dft_dec_destroy_fx( &( hCPE->hStereoDft ) );
hCPE->hStereoDft = NULL;
}
diff --git a/lib_dec/ivas_tcx_core_dec_fx.c b/lib_dec/ivas_tcx_core_dec_fx.c
index aa5a379e87c316892f9f161dd48749c31e46ede7..0be01f7b88612b359fb0b5b88b1fda3028fdeceb 100644
--- a/lib_dec/ivas_tcx_core_dec_fx.c
+++ b/lib_dec/ivas_tcx_core_dec_fx.c
@@ -875,11 +875,11 @@ void stereo_tcx_core_dec_fx(
{
Word16 buffer[L_FRAME16k];
lerp( signal_outFB_fx, buffer, st->L_frame, hTcxDec->L_frameTCX );
- ApplyFdCng_ivas_fx( buffer, 0 /* Q of buffer */, NULL, 0, NULL, NULL, NULL, st, st->bfi, 0 );
+ ApplyFdCng_fx( buffer, 0 /* Q of buffer */, NULL, 0, NULL, NULL, NULL, st, st->bfi, 0 );
}
ELSE
{
- ApplyFdCng_ivas_fx( signal_out_fx, 0, NULL, 0, NULL, NULL, NULL, st, st->bfi, 0 );
+ ApplyFdCng_fx( signal_out_fx, 0, NULL, 0, NULL, NULL, NULL, st, st->bfi, 0 );
}
}
@@ -915,7 +915,7 @@ void stereo_tcx_core_dec_fx(
test();
IF( EQ_16( st->element_mode, IVAS_CPE_TD ) && st->idchan == 0 )
{
- ApplyFdCng_ivas_fx( signal_out_fx, 0, NULL, 0, NULL, NULL, NULL, st, st->bfi, 0 );
+ ApplyFdCng_fx( signal_out_fx, 0, NULL, 0, NULL, NULL, NULL, st, st->bfi, 0 );
}
}
@@ -923,6 +923,7 @@ void stereo_tcx_core_dec_fx(
return;
}
+
static void stereo_tcx_dec_mode_switch_reconf_ivas_fx(
Decoder_State *st, /* i/o: decoder state structure */
const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/
diff --git a/lib_dec/ivas_td_low_rate_dec_fx.c b/lib_dec/ivas_td_low_rate_dec_fx.c
index 3191a8b4abcdcd54fb80589a75dbfa64a9b3b950..fb984f11fc32947a3a8f9867e28386c7438d0a0e 100644
--- a/lib_dec/ivas_td_low_rate_dec_fx.c
+++ b/lib_dec/ivas_td_low_rate_dec_fx.c
@@ -40,6 +40,13 @@
#include "prot_fx.h"
#include "wmc_auto.h"
#include "ivas_prot_fx.h"
+
+/*-------------------------------------------------------------------*
+ * tdm_low_rate_dec_fx()
+ *
+ * Low-bitrate decoder
+ *-------------------------------------------------------------------*/
+
void tdm_low_rate_dec_fx(
Decoder_State *st, /* i/o: decoder static memory */
Word16 dct_epit[], /* o : GSC excitation in DCT domain Q_exc*/
@@ -127,7 +134,7 @@ void tdm_low_rate_dec_fx(
tmp_nb_bits_tot = sub( tmp_nb_bits_tot, 1 ); /* Q0 */
}
- gsc_dec_ivas_fx( st, dct_epit, pit_band_idx, Diff_len, tmp_nb_bits_tot, nb_subfr, st->coder_type, &last_bin, lsf_new, exc_wo_nf_fx, &st->Q_exc );
+ gsc_dec_fx( st, dct_epit, pit_band_idx, Diff_len, tmp_nb_bits_tot, nb_subfr, st->coder_type, &last_bin, lsf_new, exc_wo_nf_fx, &st->Q_exc );
/*--------------------------------------------------------------------------------------*
* iDCT transform
@@ -188,19 +195,15 @@ void tdm_low_rate_dec_fx(
return;
}
+
/*---------------------------------------------------------------------*
* decod_gen_2sbfr()
*
* Decode generic (GC), 2 subframes mode
*---------------------------------------------------------------------*/
-/*---------------------------------------------------------------------*
- * decod_gen_2sbfr_ivas_fx()
- *
- * Decode generic (GC), 2 subframes mode
- *---------------------------------------------------------------------*/
-void decod_gen_2sbfr_ivas_fx(
- Decoder_State *st, /* i/o: decoder static memory */
+void decod_gen_2sbfr_fx(
+ Decoder_State *st, /* i/o: decoder static memory */
const Word16 sharpFlag, /* i : formant sharpening flag `Q0*/
const Word16 *Aq, /* i : LP filter coefficient Q12*/
Word16 *pitch_buf, /* o : Word16 pitch values for each subframe Q6*/
@@ -222,12 +225,12 @@ void decod_gen_2sbfr_ivas_fx(
move32();
Word16 gain_inov = 0; /* Innovation gain */
move16();
- Word32 gc_mem[NB_SUBFR - 1]; /* gain_code from previous subframes */
- Word16 gp_mem[NB_SUBFR - 1]; /* gain_pitch from previous subframes */
+ Word32 gc_mem[NB_SUBFR - 1]; /* gain_code from previous subframes */
+ Word16 gp_mem[NB_SUBFR - 1]; /* gain_pitch from previous subframes */
Word16 voice_fac; /* voicing factor */
Word16 code[2 * L_SUBFR]; /* algebraic codevector */
const Word16 *p_Aq; /* Pointer to frame LP coefficient */
- Word16 *pt_pitch; /* pointer to Word16 pitch */
+ Word16 *pt_pitch; /* pointer to Word16 pitch */
Word16 i_subfr; /* tmp variables */
Word16 L_frame;
Word16 pitch_limit_flag;
@@ -263,7 +266,7 @@ void decod_gen_2sbfr_ivas_fx(
* Decode pitch lag
*----------------------------------------------------------------------*/
- *pt_pitch = pit_decode_ivas_fx( st, st->core_brate, 0, L_frame, i_subfr, GENERIC, &pitch_limit_flag, &T0, &T0_frac, &T0_min, &T0_max, 2 * L_SUBFR, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf ); /* Q6 */
+ *pt_pitch = pit_decode_fx( st, st->core_brate, 0, L_frame, i_subfr, GENERIC, &pitch_limit_flag, &T0, &T0_frac, &T0_min, &T0_max, 2 * L_SUBFR, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf ); /* Q6 */
test();
test();
@@ -275,8 +278,14 @@ void decod_gen_2sbfr_ivas_fx(
/*--------------------------------------------------------------*
* Find the adaptive codebook vector
*--------------------------------------------------------------*/
-
- pred_lt4( &exc[i_subfr], &exc[i_subfr], T0, T0_frac, 2 * L_SUBFR + 1, inter4_2_fx_Q15, L_INTERPOL2, PIT_UP_SAMP );
+ IF( st->element_mode != EVS_MONO )
+ {
+ pred_lt4_ivas_fx( &exc[i_subfr], &exc[i_subfr], T0, T0_frac, 2 * L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ }
+ ELSE
+ {
+ pred_lt4( &exc[i_subfr], &exc[i_subfr], T0, T0_frac, 2 * L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ }
/*--------------------------------------------------------------*
* LP filtering of the adaptive excitation
@@ -295,7 +304,7 @@ void decod_gen_2sbfr_ivas_fx(
* Estimate spectrum tilt and voicing
*--------------------------------------------------------------*/
- gain_dec_lbr_ivas_fx( st, GENERIC, i_subfr, code, &gain_pit, &gain_code, &gain_inov, &norm_gain_code, gc_mem, gp_mem, 2 * L_SUBFR );
+ gain_dec_lbr_fx( st, GENERIC, i_subfr, code, &gain_pit, &gain_code, &gain_inov, &norm_gain_code, gc_mem, gp_mem, 2 * L_SUBFR );
st->tilt_code_fx = est_tilt_ivas_fx( exc + i_subfr, gain_pit, code, gain_code, &voice_fac, st->Q_exc, 2 * L_SUBFR, 0 ); /* Q15 */
move16();
@@ -312,10 +321,12 @@ void decod_gen_2sbfr_ivas_fx(
Word16 gain_code16 = round_fx( L_shl( gain_code, st->Q_exc ) ); /*Q_exc*/
Acelp_dec_total_exc( exc, exc2, gain_code16, gain_pit, i_subfr, code, 2 * L_SUBFR );
+
/*-----------------------------------------------------------------*
* Prepare TBE excitation
*-----------------------------------------------------------------*/
- prep_tbe_exc_ivas_fx( L_frame, 2 * L_SUBFR, i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr / L_SUBFR /*i_subfr / L_SUBFR*/], bwe_exc, 0, NULL, st->Q_exc, T0, T0_frac, GENERIC, st->core_brate, st->element_mode, st->idchan, st->hBWE_TD != NULL, st->tdm_LRTD_flag );
+
+ prep_tbe_exc_fx( L_frame, 2 * L_SUBFR, i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr / L_SUBFR /*i_subfr / L_SUBFR*/], bwe_exc, 0, NULL, st->Q_exc, T0, T0_frac, GENERIC, st->core_brate, st->element_mode, st->idchan, st->hBWE_TD != NULL, st->tdm_LRTD_flag );
voice_factors[i_subfr / L_SUBFR + 1] = voice_factors[i_subfr / L_SUBFR /*i_subfr / L_SUBFR*/]; /* Q15 */
move16();
@@ -323,9 +334,10 @@ void decod_gen_2sbfr_ivas_fx(
* Excitation enhancements (update of total excitation signal)
* called twice because adapting it to double the subfr length would need lot of modifications
*----------------------------------------------------------------*/
- enhancer_ivas_fx2( st->core_brate, 0, GENERIC, i_subfr, L_frame, voice_fac, st->stab_fac_fx, norm_gain_code, gain_inov, &st->gc_threshold_fx, code, exc2, gain_pit, &st->dm_fx, st->Q_exc );
- enhancer_ivas_fx2( st->core_brate, 0, GENERIC, i_subfr, L_frame, voice_fac, st->stab_fac_fx, norm_gain_code, gain_inov, &st->gc_threshold_fx, code + L_SUBFR, exc2 + L_SUBFR, gain_pit, &st->dm_fx, st->Q_exc );
+ enhancer_ivas_fx( MODE1, st->core_brate, -1, 0, GENERIC, i_subfr, L_frame, voice_fac, st->stab_fac_fx, norm_gain_code, gain_inov, &st->gc_threshold_fx, code, exc2, gain_pit, &st->dm_fx, st->Q_exc );
+
+ enhancer_ivas_fx( MODE1, st->core_brate, -1, 0, GENERIC, i_subfr, L_frame, voice_fac, st->stab_fac_fx, norm_gain_code, gain_inov, &st->gc_threshold_fx, code + L_SUBFR, exc2 + L_SUBFR, gain_pit, &st->dm_fx, st->Q_exc );
p_Aq += 2 * ( M + 1 ); /* Q12 */
diff --git a/lib_dec/jbm_jb4_circularbuffer.c b/lib_dec/jbm_jb4_circularbuffer_fx.c
similarity index 100%
rename from lib_dec/jbm_jb4_circularbuffer.c
rename to lib_dec/jbm_jb4_circularbuffer_fx.c
diff --git a/lib_dec/jbm_jb4_inputbuffer.c b/lib_dec/jbm_jb4_inputbuffer_fx.c
similarity index 100%
rename from lib_dec/jbm_jb4_inputbuffer.c
rename to lib_dec/jbm_jb4_inputbuffer_fx.c
diff --git a/lib_dec/jbm_jb4_jmf.c b/lib_dec/jbm_jb4_jmf_fx.c
similarity index 100%
rename from lib_dec/jbm_jb4_jmf.c
rename to lib_dec/jbm_jb4_jmf_fx.c
diff --git a/lib_dec/jbm_jb4sb.c b/lib_dec/jbm_jb4sb_fx.c
similarity index 100%
rename from lib_dec/jbm_jb4sb.c
rename to lib_dec/jbm_jb4sb_fx.c
diff --git a/lib_dec/jbm_pcmdsp_apa.c b/lib_dec/jbm_pcmdsp_apa_fx.c
similarity index 100%
rename from lib_dec/jbm_pcmdsp_apa.c
rename to lib_dec/jbm_pcmdsp_apa_fx.c
diff --git a/lib_dec/jbm_pcmdsp_similarityestimation.c b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c
similarity index 100%
rename from lib_dec/jbm_pcmdsp_similarityestimation.c
rename to lib_dec/jbm_pcmdsp_similarityestimation_fx.c
diff --git a/lib_dec/jbm_pcmdsp_window.c b/lib_dec/jbm_pcmdsp_window_fx.c
similarity index 100%
rename from lib_dec/jbm_pcmdsp_window.c
rename to lib_dec/jbm_pcmdsp_window_fx.c
diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c
index 77deb9e7def110cf633aecc62a02ea6558d68fc6..9a60d024fcb697918dc111613aace689f7195def 100644
--- a/lib_dec/lib_dec_fx.c
+++ b/lib_dec/lib_dec_fx.c
@@ -1,4 +1,4 @@
-/******************************************************************************************************
+/******************************************************************************************************
(C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
@@ -58,6 +58,9 @@ struct IVAS_DEC_VOIP
UWord16 lastDecodedWasActive;
JB4_DATAUNIT_HANDLE hCurrentDataUnit; /* Points to the currently processed data unit */
UWord16 *bs_conversion_buf; /* Buffer for bitstream conversion from packed to serial */
+#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE
+ Word16 nSamplesRendered20ms; /* how many samples have been rendered since the last 20ms render border*/
+#endif
#ifdef SUPPORT_JBM_TRACEFILE
IVAS_JBM_TRACE_DATA JbmTraceData;
#endif
@@ -79,8 +82,11 @@ struct IVAS_DEC
bool Opt_VOIP; /* flag indicating VOIP mode with JBM */
Word16 tsm_scale; /* scale for TSM operation */
Word16 tsm_max_scaling;
- Word32 *apaExecBuffer_fx; /* Buffer for APA scaling */
+#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE
+ Word16 timeScalingDone; /* have we done already one TSM in a 20ms frame? */
+#endif
Word16 tsm_quality; /*Q14*/
+ Word32 *apaExecBuffer_fx; /* Buffer for APA scaling */
PCMDSP_APA_HANDLE hTimeScaler;
bool needNewFrame;
bool hasBeenFedFrame;
@@ -112,6 +118,9 @@ static ivas_error IVAS_DEC_RendererFeedTcSamples( IVAS_DEC_HANDLE hIvasDec, cons
static ivas_error IVAS_DEC_GetRenderedSamples( IVAS_DEC_HANDLE hIvasDec, const UWord16 nSamplesForRendering, UWord16 *nSamplesRendered, UWord16 *nSamplesAvailableNext, Word16 *pcmBuf );
static ivas_error IVAS_DEC_GetBufferedNumberOfSamples( IVAS_DEC_HANDLE hIvasDec, Word16 *nSamplesBuffered );
static Word16 get_render_frame_size_ms( IVAS_RENDER_FRAMESIZE render_framesize );
+#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE
+static void update_voip_rendered20ms( IVAS_DEC_HANDLE hIvasDec, const Word16 nSamplesRendered );
+#endif
/*---------------------------------------------------------------------*
@@ -149,6 +158,9 @@ ivas_error IVAS_DEC_Open(
hIvasDec->tsm_scale = 100;
hIvasDec->tsm_max_scaling = 0;
hIvasDec->tsm_quality = ONE_IN_Q14; /*1.f Q14*/
+#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE
+ hIvasDec->timeScalingDone = 0;
+#endif
hIvasDec->needNewFrame = false;
hIvasDec->nTransportChannelsOld = 0;
hIvasDec->nSamplesAvailableNext = 0;
@@ -171,6 +183,9 @@ ivas_error IVAS_DEC_Open(
move16();
move16();
move16();
+#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE
+ move16();
+#endif
hIvasDec->mode = mode;
move16();
@@ -805,6 +820,10 @@ ivas_error IVAS_DEC_EnableVoIP(
hIvasDec->hVoIP->hCurrentDataUnit = NULL;
hIvasDec->hVoIP->nSamplesFrame = (UWord16) Mpy_32_16_1( hDecoderConfig->output_Fs, INV_FRAME_PER_SEC_Q15 );
move16();
+#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE
+ hIvasDec->hVoIP->nSamplesRendered20ms = 0;
+ move16();
+#endif
#define WMC_TOOL_SKIP
/* Bitstream conversion is not counted towards complexity and memory usage */
@@ -1107,18 +1126,29 @@ ivas_error IVAS_DEC_GetSamples(
}
assert( LE_32( (Word32) nTimeScalerOutSamples, APA_BUF ) );
nSamplesTcsScaled = idiv1616U( extract_l( nTimeScalerOutSamples ), nTransportChannels );
+#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE
+ hIvasDec->timeScalingDone = 1;
+ move16();
+#endif
}
ELSE
{
nSamplesTcsScaled = hIvasDec->nSamplesFrame;
move16();
}
+#ifdef DEBUG_MODE_JBM
+ dbgwrite( &nTimeScalerOutSamples, sizeof( uint16_t ), 1, 1, "./res/JBM_nTimeScaleOutSamples.dat" );
+#endif
/* Feed decoded transport channels samples to the renderer */
IF( NE_32( ( error = IVAS_DEC_RendererFeedTcSamples( hIvasDec, nSamplesTcsScaled, &nResidualSamples, hIvasDec->apaExecBuffer_fx ) ), IVAS_ERR_OK ) )
{
return error;
}
+#ifdef DEBUG_MODE_JBM
+ dbgwrite( &nResidualSamples, sizeof( int16_t ), 1, 1, "./res/JBM_nResidualSamples.dat" );
+#endif
+
IF( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm )
{
@@ -1559,6 +1589,9 @@ static ivas_error IVAS_DEC_GetBufferedNumberOfSamples(
if ( hIvasDec->st_ivas->hTcBuffer != NULL )
{
*nSamplesBuffered = sub( hIvasDec->st_ivas->hTcBuffer->n_samples_buffered, hIvasDec->st_ivas->hTcBuffer->n_samples_rendered );
+#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE
+ *nSamplesBuffered = add( *nSamplesBuffered, hIvasDec->hVoIP->nSamplesRendered20ms );
+#endif
move16();
}
@@ -2685,7 +2718,9 @@ ivas_error IVAS_DEC_VoIP_GetSamples(
UWord32 extBufferedTime_ms, scale, maxScaling;
JB4_DATAUNIT_HANDLE dataUnit;
UWord16 extBufferedSamples;
+#ifndef NONBE_FIX_864_JBM_RENDER_FRAMESIZE
Word16 timeScalingDone;
+#endif
Word16 result;
ivas_error error;
Word16 nSamplesRendered;
@@ -2694,7 +2729,9 @@ ivas_error IVAS_DEC_VoIP_GetSamples(
st_ivas = hIvasDec->st_ivas;
hDecoderConfig = st_ivas->hDecoderConfig;
hVoIP = hIvasDec->hVoIP;
+#ifndef NONBE_FIX_864_JBM_RENDER_FRAMESIZE
timeScalingDone = 0;
+#endif
nOutChannels = (UWord8) st_ivas->hDecoderConfig->nchan_out;
nSamplesRendered = 0;
move16();
@@ -2722,7 +2759,12 @@ ivas_error IVAS_DEC_VoIP_GetSamples(
}
}
+#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE
+ extBufferedSamples = nSamplesBuffered;
+ move16();
+#else
extBufferedSamples = add( nSamplesRendered, nSamplesBuffered );
+#endif
Word16 exp;
extBufferedTime_ms = BASOP_Util_Divide3232_Scale( imult3216( extBufferedSamples, 1000 ), hDecoderConfig->output_Fs, &exp );
extBufferedTime_ms = (UWord32) W_shr( extBufferedTime_ms, sub( 15, exp ) ); // Q0
@@ -2745,19 +2787,33 @@ ivas_error IVAS_DEC_VoIP_GetSamples(
}
maxScaling = Mult_32_32( imult3216( hDecoderConfig->output_Fs, (Word16) maxScaling ), INV_1000_Q31 );
+#ifdef DEBUG_MODE_JBM
+ dbgwrite( &extBufferedSamples, sizeof( uint16_t ), 1, 1, "./res/JBM_extBufferedSamples.dat" );
+ dbgwrite( &systemTimestamp_ms, sizeof( uint32_t ), 1, 1, "./res/JBM_systemTimestamp.dat" );
+ dbgwrite( &scale, sizeof( uint32_t ), 1, 1, "./res/JBM_scale.dat" );
+ dbgwrite( &maxScaling, sizeof( uint32_t ), 1, 1, "./res/JBM_maxScale.dat" );
+#endif
+
/* avoid time scaling multiple times in one sound card slot */
IF( NE_64( scale, 100U ) )
+#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE
{
- IF( timeScalingDone )
+ IF( hIvasDec->timeScalingDone )
+#else
+ {
+ IF( timeScalingDone )
+#endif
{
scale = 100;
move32();
}
+#ifndef NONBE_FIX_864_JBM_RENDER_FRAMESIZE
ELSE
{
timeScalingDone = 1;
move16();
}
+#endif
}
/* limit scale to range supported by time scaler */
@@ -2850,6 +2906,9 @@ ivas_error IVAS_DEC_VoIP_GetSamples(
hIvasDec->nSamplesAvailableNext = sub( hIvasDec->nSamplesAvailableNext, nSamplesToZero );
move16();
move16();
+#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE
+ update_voip_rendered20ms( hIvasDec, nSamplesToZero );
+#endif
}
ELSE
{
@@ -2864,12 +2923,45 @@ ivas_error IVAS_DEC_VoIP_GetSamples(
}
nSamplesRendered = add( nSamplesRendered, nSamplesRendered_loop );
+#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE
+ update_voip_rendered20ms( hIvasDec, nSamplesRendered_loop );
+#endif
}
}
return IVAS_ERR_OK;
}
+#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE
+/*---------------------------------------------------------------------*
+ * update_voip_rendered20ms( )
+ *
+ * Function to flush remaining audio in VoIP
+ *---------------------------------------------------------------------*/
+
+static void update_voip_rendered20ms(
+ IVAS_DEC_HANDLE hIvasDec,
+ const Word16 nSamplesRendered )
+{
+ Word16 nSamplesRenderedTotal;
+ nSamplesRenderedTotal = add( hIvasDec->hVoIP->nSamplesRendered20ms, nSamplesRendered );
+ /* we have crossed a 20ms border, reset the time scaling done flag */
+ IF( GE_16( nSamplesRenderedTotal, hIvasDec->hVoIP->nSamplesFrame ) )
+ {
+ hIvasDec->timeScalingDone = 0;
+ move16();
+ }
+
+ /* float code was: hIvasDec->hVoIP->nSamplesRendered20ms = nSamplesRenderedTotal % hIvasDec->hVoIP->nSamplesFrame; */
+ hIvasDec->hVoIP->nSamplesRendered20ms = nSamplesRenderedTotal;
+ move16();
+ WHILE( GE_16( hIvasDec->hVoIP->nSamplesRendered20ms, hIvasDec->hVoIP->nSamplesFrame ) )
+ {
+ hIvasDec->hVoIP->nSamplesRendered20ms = sub( hIvasDec->hVoIP->nSamplesRendered20ms, hIvasDec->hVoIP->nSamplesFrame );
+ }
+}
+
+#endif
/*---------------------------------------------------------------------*
* IVAS_DEC_VoIP_Flush( )
@@ -2895,7 +2987,22 @@ ivas_error IVAS_DEC_Flush(
move16();
/* render IVAS frames */
- error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesFlushedLocal, &hIvasDec->nSamplesAvailableNext, pcmBuf );
+#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE
+ error = IVAS_ERR_OK;
+
+ test();
+ IF( GT_16( nSamplesToRender, 0 ) && NE_16( (Word16) hIvasDec->st_ivas->ivas_format, (Word16) MONO_FORMAT ) )
+ {
+#endif
+ error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesFlushedLocal, &hIvasDec->nSamplesAvailableNext, pcmBuf );
+#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE
+ }
+ ELSE
+ {
+ *nSamplesFlushed = 0;
+ move16();
+ }
+#endif
return error;
}
diff --git a/lib_dec/lsf_dec_fx.c b/lib_dec/lsf_dec_fx.c
index 9b7f77c79845d42f4fcd81d0220c0cebeb68854a..913543db8c6b90d0f51beb13a097845f34b0b746 100644
--- a/lib_dec/lsf_dec_fx.c
+++ b/lib_dec/lsf_dec_fx.c
@@ -8,9 +8,11 @@
#include "rom_com.h" /* Static table prototypes */
#include "prot_fx.h" /* Function prototypes */
#include "ivas_prot_fx.h"
+
/*-------------------------------------------------------------------*
* Local functions
*-------------------------------------------------------------------*/
+
static void dqlsf_CNG_fx( Decoder_State *st_fx, Word16 *lsf_q );
/*--------------------------------------------------------------------------------------*
@@ -88,7 +90,6 @@ static void dqlsf_CNG_fx(
/* _ (Word16*) lsp_new : LP filter coefficient Q15 */
/* _ (Word16*) lsp_mid : LP filter coefficient Q15 */
/*---------------------------------------------------------------------------*/
-
/* _ (Word16[]) st_fx->lsf_adaptive_mean_fx : FEC - adaptive mean LSF */
/* vector for FEC Q(x2.56) */
/* _ (Word16[]) st_fx->mem_AR_fx : AR memory of LSF quantizer */
@@ -99,271 +100,16 @@ static void dqlsf_CNG_fx(
/* _ None */
/*===========================================================================*/
-#ifndef REMOVE_EVS_DUPLICATES
void lsf_dec_fx(
- Decoder_State *st_fx, /* i/o: State structure */
- const Word16 tc_subfr, /* i : TC subframe index Q0*/
- Word16 *Aq, /* o : quantized A(z) for 4 subframes Q12*/
- Word16 *LSF_Q_prediction, /* o : LSF prediction mode Q0*/
- Word16 *lsf_new, /* o : de-quantized LSF vector Q(x2.56)*/
- Word16 *lsp_new, /* o : de-quantized LSP vector Q15*/
- Word16 *lsp_mid, /* o : de-quantized mid-frame LSP vector Q15*/
- const Word16 tdm_low_rate_mode /* i : secondary channel low rate mode flag Q0*/
- ,
- const Word16 tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel Qx*/
-)
-{
- Word16 i;
- Word16 no_param_lpc;
- Word16 param_lpc[NPRM_LPC_NEW];
- Word32 L_tmp;
- Word16 nBits = 0;
- move16();
- Word16 tmp_old[M + 1], tmp_new[M + 1];
- Word16 enr_old = 0, enr_new = 0;
- move16();
- move16();
- Word16 lsf_diff, coder_type;
-
- /* initialize */
- coder_type = st_fx->coder_type;
- if ( EQ_32( st_fx->core_brate, SID_2k40 ) )
- {
- coder_type = INACTIVE; /* Q0 */
- move16();
- }
- test();
- if ( EQ_16( coder_type, AUDIO ) && st_fx->GSC_IVAS_mode > 0 )
- {
- coder_type = GENERIC; /* Q0 */
- move16();
- }
- no_param_lpc = 0;
- nBits = 0;
- move16();
- move16();
-
- /* Find the number of bits for LSF quantization */
- IF( EQ_32( st_fx->core_brate, SID_2k40 ) )
- {
- nBits = LSF_BITS_CNG; /* Q0 */
- move16();
- }
- ELSE
- {
- test();
- IF( st_fx->nelp_mode_dec == 0 && st_fx->ppp_mode_dec == 0 )
- {
- nBits = st_fx->acelp_cfg.lsf_bits; /* Q0 */
- move16();
- }
- ELSE IF( EQ_16( st_fx->nelp_mode_dec, 1 ) )
- {
- IF( EQ_16( coder_type, UNVOICED ) )
- {
- nBits = 30; /* Q0 */
- move16();
- if ( st_fx->bwidth == NB )
- {
- nBits = 32; /* Q0 */
- move16();
- }
- }
- }
- ELSE IF( EQ_16( st_fx->ppp_mode_dec, 1 ) )
- {
- nBits = 26; /* Q0 */
- move16();
- }
- }
-
- /* LSF de-quantization */
- lsf_end_dec_fx( st_fx, 0, coder_type, st_fx->bwidth, nBits, lsf_new, param_lpc, LSF_Q_prediction, &no_param_lpc,
- tdm_lsfQ_PCh );
-
- /* convert quantized LSFs to LSPs */
-
- lsf2lsp_fx( lsf_new, lsp_new, M, st_fx->sr_core );
- /* set seed_acelp used in UC mode */
- test();
- IF( EQ_16( coder_type, UNVOICED ) && GT_16( st_fx->element_mode, EVS_MONO ) )
- {
- st_fx->seed_acelp = 0;
- move16();
- FOR( i = no_param_lpc - 1; i >= 0; i-- )
- {
- /* rightshift before *seed_acelp+param_lpc[i] to avoid overflows*/
- st_fx->seed_acelp = extract_l( L_add( imult3216( 31821L /* Q0 */, add( shr( ( st_fx->seed_acelp ), 1 ), param_lpc[i] ) ), 13849L /* Q0 */ ) ); /* Q0 */
- move16();
- }
- }
- IF( EQ_32( st_fx->core_brate, SID_2k40 ) )
- {
- /* return if SID frame (conversion to A(z) done in the calling function) */
- return;
- }
-
- /*-------------------------------------------------------------------------------------*
- * FEC - update adaptive LSF mean vector
- *-------------------------------------------------------------------------------------*/
-
- FOR( i = 0; i < M; i++ )
- {
- L_tmp = L_mult( lsf_new[i], 10922 ); /*Q(x2.56+16)*/
- L_tmp = L_mac( L_tmp, st_fx->lsfoldbfi1_fx[i], 10922 ); /*Q(x2.56+16)*/
- L_tmp = L_mac( L_tmp, st_fx->lsfoldbfi0_fx[i], 10922 ); /*Q(x2.56+16)*/
- st_fx->lsf_adaptive_mean_fx[i] = round_fx( L_tmp ); /*Q(x2.56)*/
- move16();
- }
-
- test();
- test();
- IF( ( st_fx->prev_bfi && ( EQ_16( coder_type, TRANSITION ) ) && ( EQ_16( tc_subfr, sub( st_fx->L_frame, L_SUBFR ) ) ) ) )
- {
- lsf_diff = 1205;
- move16(); /*int_fs / (float)(2*(M+1)); = 470.588 -> 1205 in Q2.56 */
- if ( EQ_16( st_fx->L_frame, L_FRAME ) )
- {
- lsf_diff = 964;
- move16(); /*int_fs / (float)(2*(M+1)); = 376.47 -> 964 in Q2.56 */
- }
- st_fx->lsf_old_fx[0] = lsf_diff;
- move16();
-
- FOR( i = 1; i < M; i++ )
- {
- st_fx->lsf_old_fx[i] = add( st_fx->lsf_old_fx[i - 1], lsf_diff ); /* Q2.56 */
- move16();
- }
- lsf2lsp_fx( st_fx->lsf_old_fx, st_fx->lsp_old_fx, M, st_fx->sr_core );
- }
- /*-------------------------------------------------------------------------------------*
- * Mid-frame LSF decoding
- * LSP interpolation and conversion of LSPs to A(z)
- *-------------------------------------------------------------------------------------*/
- IF( st_fx->rate_switching_reset )
- {
- /*extrapolation in case of unstable LSF convert*/
- Copy( lsp_new, st_fx->lsp_old_fx, M ); /* Q15 */
- Copy( lsf_new, st_fx->lsf_old_fx, M ); /* Q2.56 */
- }
- {
- /* Mid-frame LSF decoding */
- lsf_mid_dec_fx( st_fx, lsp_new, coder_type, lsp_mid );
- }
- test();
- test();
- IF( !( st_fx->prev_bfi && ( EQ_16( coder_type, TRANSITION ) ) && ( EQ_16( tc_subfr, sub( st_fx->L_frame, L_SUBFR ) ) ) ) )
- {
- IF( st_fx->prev_bfi )
- {
- /* check, if LSP interpolation can be relaxed */
- E_LPC_f_lsp_a_conversion( st_fx->lsp_old_fx, tmp_old, M );
- enr_old = Enr_1_Az_fx( tmp_old, 2 * L_SUBFR ); /* Q3 */
-
- E_LPC_f_lsp_a_conversion( lsp_new, tmp_new, M );
- enr_new = Enr_1_Az_fx( tmp_new, 2 * L_SUBFR ); /* Q3 */
-
- IF( LT_16( enr_new, mult_r( 9830 /*0.3 Q15*/, enr_old ) ) )
- {
- /* OLD CODE : if( st->safety_net == 1), replaced with a decision similar to MODE2 */
- st_fx->relax_prev_lsf_interp = -1;
- move16();
- test();
- test();
- test();
- test();
- if ( st_fx->clas_dec == UNVOICED_CLAS || EQ_16( st_fx->clas_dec, SIN_ONSET ) || st_fx->clas_dec == INACTIVE_CLAS || EQ_16( coder_type, GENERIC ) || EQ_16( coder_type, TRANSITION ) )
- {
- st_fx->relax_prev_lsf_interp = 1;
- move16();
- }
- }
- }
- }
- test();
- IF( EQ_16( st_fx->last_core, HQ_CORE ) && st_fx->core == ACELP_CORE )
- {
- /* update old LSPs/LSFs in case of HQ->ACELP core switching */
- Copy( lsp_mid, st_fx->lsp_old_fx, M ); /* Q15 */
- lsp2lsf_fx( lsp_mid, st_fx->lsf_old_fx, M, st_fx->sr_core ); /* Q15 */
- }
- test();
- IF( EQ_16( tdm_low_rate_mode, 1 ) && GT_16( coder_type, UNVOICED ) )
- {
- // PMT("To be verified")
- IF( EQ_16( st_fx->active_cnt, 1 ) )
- {
- Copy( lsp_mid, st_fx->lsp_old_fx, M ); /* Q15 */
- lsp2lsf_fx( lsp_mid, st_fx->lsf_old_fx, M, st_fx->sr_core ); /* Q15 */
- Copy( lsp_new, lsp_mid, M ); /* Q15 */
- }
-
- /* LSP interpolation and conversion of LSPs to A(z) - two-subframe mode */
- int_lsp4_fx( st_fx->L_frame, st_fx->lsp_old_fx, lsp_mid, lsp_new, Aq, M, -2 );
- }
- ELSE
- {
- /* LSP interpolation and conversion of LSPs to A(z) */
- int_lsp4_fx( st_fx->L_frame, st_fx->lsp_old_fx, lsp_mid, lsp_new, Aq, M, st_fx->relax_prev_lsf_interp );
- }
- /*------------------------------------------------------------------*
- * Check LSF stability (distance between old LSFs and current LSFs)
- *------------------------------------------------------------------*/
-
- IF( st_fx->element_mode == EVS_MONO )
- {
- st_fx->stab_fac_fx = lsf_stab_fx( lsf_new, st_fx->lsf_old_fx, 0, st_fx->L_frame ); /*Q15*/
- move16();
- }
- ELSE
- {
- st_fx->stab_fac_fx = lsf_stab_ivas_fx( lsf_new, st_fx->lsf_old_fx, 0, st_fx->L_frame ); /* Q15 */
- move16();
- }
-
- return;
-}
-
-/*===========================================================================*/
-/* FUNCTION : lsf_dec_ivas_fx() */
-/*---------------------------------------------------------------------------*/
-/* PURPOSE : LSF decoder */
-/*---------------------------------------------------------------------------*/
-/* INPUT ARGUMENTS : */
-/* _ (Struct) st_fx : decoder static memory */
-/* _ (Word16) L_frame : length of the frame */
-/* _ (Word16) coder_type : coding type */
-/* _ (Word16) bwidth : input signal bandwidth */
-/*---------------------------------------------------------------------------*/
-/* OUTPUT ARGUMENTS : */
-/* _ (Word16*) Aq : LP filter coefficient Q12 */
-/* _ (Word16*) lsf_new : LP filter coefficient Q(x2.56) */
-/* _ (Word16*) lsp_new : LP filter coefficient Q15 */
-/* _ (Word16*) lsp_mid : LP filter coefficient Q15 */
-/*---------------------------------------------------------------------------*/
-
-/* _ (Word16[]) st_fx->lsf_adaptive_mean_fx : FEC - adaptive mean LSF */
-/* vector for FEC Q(x2.56) */
-/* _ (Word16[]) st_fx->mem_AR_fx : AR memory of LSF quantizer */
-/* (past quantized LSFs without mean) Q(x2.56) */
-/* _ (Word16) st_fx->stab_fac_fx : LSF stability factor Q15 */
-/*---------------------------------------------------------------------------*/
-/* RETURN ARGUMENTS : */
-/* _ None */
-/*===========================================================================*/
-#endif
-void lsf_dec_ivas_fx(
- Decoder_State *st_fx, /* i/o: State structure */
- const Word16 tc_subfr, /* i : TC subframe index Q0*/
- Word16 *Aq, /* o : quantized A(z) for 4 subframes Q12*/
- Word16 *LSF_Q_prediction, /* o : LSF prediction mode Q0*/
- Word16 *lsf_new, /* o : de-quantized LSF vector Q(x2.56)*/
- Word16 *lsp_new, /* o : de-quantized LSP vector Q15*/
- Word16 *lsp_mid, /* o : de-quantized mid-frame LSP vector Q15*/
- const Word16 tdm_low_rate_mode /* i : secondary channel low rate mode flag Q0*/
- ,
- const Word16 tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel Qx*/
+ Decoder_State *st_fx, /* i/o: State structure */
+ const Word16 tc_subfr, /* i : TC subframe index Q0*/
+ Word16 *Aq, /* o : quantized A(z) for 4 subframes Q12*/
+ Word16 *LSF_Q_prediction, /* o : LSF prediction mode Q0*/
+ Word16 *lsf_new, /* o : de-quantized LSF vector Q(x2.56)*/
+ Word16 *lsp_new, /* o : de-quantized LSP vector Q15*/
+ Word16 *lsp_mid, /* o : de-quantized mid-frame LSP vector Q15*/
+ const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag Q0*/
+ const Word16 tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel Qx*/
)
{
Word16 i;
diff --git a/lib_dec/lsf_msvq_ma_dec_fx.c b/lib_dec/lsf_msvq_ma_dec_fx.c
index 61e338c9c52451d70dec2d2a8f5656b29c664682..1b5d79c6824596fad3684066b2e2f67ebca9a257 100644
--- a/lib_dec/lsf_msvq_ma_dec_fx.c
+++ b/lib_dec/lsf_msvq_ma_dec_fx.c
@@ -185,9 +185,6 @@ Word16 D_lsf_tcxlpc(
M,
M,
indices + NumIndices,
-#ifdef IVAS_MSVQ
- 0, NULL,
-#endif
lsf_q );
NumIndices = add( NumIndices, TCXLPC_NUMSTAGES ); /* Q0 */
@@ -208,9 +205,6 @@ Word16 D_lsf_tcxlpc(
M,
M,
indices + NumIndices,
-#ifdef IVAS_MSVQ
- 0, NULL,
-#endif
lsf_rem_q_ind );
NumIndices = add( NumIndices, TCXLPC_IND_NUMSTAGES ); /* Q0 */
@@ -287,9 +281,6 @@ Word16 dec_lsf_tcxlpc(
M,
M,
flag + 1,
-#ifdef IVAS_MSVQ
- 0, NULL,
-#endif
lsf_q_ind );
/* Update flag */
diff --git a/lib_dec/pit_dec_fx.c b/lib_dec/pit_dec_fx.c
index e8cebedbdd98861e9398f70087cbbd5f11f8214d..38ec41cb209c196f3333a972a2195ff8f4c0aa46 100644
--- a/lib_dec/pit_dec_fx.c
+++ b/lib_dec/pit_dec_fx.c
@@ -319,246 +319,22 @@ void Mode2_delta_pit_dec(
/* _ (Word16 ) pitch : close loop integer pitch Q6 */
/*=======================================================================*/
-#ifndef REMOVE_EVS_DUPLICATES
-Word16 pit_decode_fx( /* o : floating pitch value */
- Decoder_State *st_fx, /* i/o: decoder state structure */
- const Word32 core_brate, /* i : core bitrate */
- const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
- const Word16 L_frame, /* i : length of the frame */
- Word16 i_subfr, /* i : subframe index */
- const Word16 coder_type, /* i : coding type */
- Word16 *limit_flag, /* i/o: restrained(0) or extended(1) Q limits */
- Word16 *T0, /* o : close loop integer pitch */
- Word16 *T0_frac, /* o : close loop fractional part of the pitch */
- Word16 *T0_min, /* i/o: delta search min for sf 2 & 4 */
- Word16 *T0_max, /* i/o: delta search max for sf 2 & 4 */
- const Word16 L_subfr /* i : subframe length */
-)
-{
- Word16 pitch; /*Q2*/
- Word16 pitch_index, nBits, pit_flag;
-
- pitch_index = 0;
- move16();
-
- /*----------------------------------------------------------------*
- * Set pit_flag = 0 for every subframe with absolute pitch search
- *----------------------------------------------------------------*/
- pit_flag = i_subfr;
- move16();
-
- if ( EQ_16( i_subfr, PIT_DECODE_2XL_SUBFR ) )
- {
- pit_flag = 0;
- move16();
- }
-
- /*-------------------------------------------------------*
- * Retrieve the pitch index
- *-------------------------------------------------------*/
- IF( !Opt_AMR_WB )
- {
- /*----------------------------------------------------------------*
- * pitch Q: Set limit_flag to 0 for restrained limits, and 1 for extended limits
- *----------------------------------------------------------------*/
- test();
- test();
- IF( i_subfr == 0 )
- {
- *limit_flag = 1;
- move16();
-
- if ( EQ_16( coder_type, VOICED ) )
- {
- *limit_flag = 2;
- move16(); /* double-extended limits */
- }
- test();
- if ( EQ_16( coder_type, GENERIC ) && EQ_32( core_brate, ACELP_7k20 ) )
- {
- *limit_flag = 0;
- move16();
- }
- }
- ELSE IF( EQ_16( i_subfr, 2 * L_SUBFR ) && EQ_32( coder_type, GENERIC ) && LE_32( core_brate, ACELP_13k20 ) )
- {
- if ( GT_16( *T0, shr( add( PIT_FR1_EXTEND_8b, PIT_MIN ), 1 ) ) )
- {
- *limit_flag = 0;
- move16();
- }
- }
-
- /*-------------------------------------------------------*
- * Retrieve the number of Q bits
- *-------------------------------------------------------*/
-
- nBits = 0;
- move16();
- IF( NE_16( coder_type, AUDIO ) )
- {
- /* find the number of bits */
- nBits = st_fx->acelp_cfg.pitch_bits[shr( i_subfr, 6 )];
- move16();
- pitch_index = (Word16) get_next_indice_fx( st_fx, nBits );
- }
-
- /*-------------------------------------------------------*
- * Pitch decoding in AUDIO mode
- * (both ACELP@12k8 and ACELP@16k cores)
- *-------------------------------------------------------*/
- IF( EQ_16( coder_type, AUDIO ) )
- {
- test();
- if ( EQ_16( L_subfr, L_FRAME / 2 ) && i_subfr != 0 )
- {
- pit_flag = L_SUBFR;
- move16();
- }
- if ( pit_flag == 0 )
- {
- nBits = 10;
- move16();
- }
- if ( pit_flag != 0 )
- {
- nBits = 6;
- move16();
- }
-
- pitch_index = (Word16) get_next_indice_fx( st_fx, nBits );
-
- test();
- test();
- IF( EQ_16( L_subfr, L_FRAME / 2 ) && i_subfr != 0 && GE_16( pitch_index, 32 ) ) /* safety check in case of bit errors */
- {
- pitch_index = shr( pitch_index, 1 );
- st_fx->BER_detect = 1;
- move16();
- }
-
- pit_Q_dec_fx( 0, pitch_index, nBits, 4, pit_flag, *limit_flag, T0, T0_frac, T0_min, T0_max, &st_fx->BER_detect );
- }
- ELSE IF( EQ_16( coder_type, VOICED ) )
- {
- /*-------------------------------------------------------*
- * Pitch decoding in VOICED mode
- * (ACELP@12k8 core only)
- *-------------------------------------------------------*/
- if ( EQ_16( i_subfr, 2 * L_SUBFR ) )
- {
- pit_flag = i_subfr;
- move16();
- }
-
- pit_Q_dec_fx( 0, pitch_index, nBits, 4, pit_flag, *limit_flag, T0, T0_frac, T0_min, T0_max, &st_fx->BER_detect );
- }
- ELSE
- {
- /*-------------------------------------------------------*
- * Pitch decoding in GENERIC mode
- * (both ACELP@12k8 and ACELP@16k cores)
- *-------------------------------------------------------*/
- IF( EQ_16( L_frame, L_FRAME ) )
- {
- pit_Q_dec_fx( 0, pitch_index, nBits, 8, pit_flag, *limit_flag, T0, T0_frac, T0_min, T0_max, &st_fx->BER_detect );
- }
- ELSE
- {
- pit16k_Q_dec_fx( pitch_index, nBits, *limit_flag, T0, T0_frac, T0_min, T0_max, &st_fx->BER_detect );
- }
- }
- }
-
- /*-------------------------------------------------------*
- * Pitch decoding in AMR-WB IO mode
- *-------------------------------------------------------*/
-
- ELSE
- {
- *limit_flag = 0;
- move16();
- test();
- test();
- IF( i_subfr == 0 || ( EQ_16( i_subfr, 2 * L_SUBFR ) && EQ_32( core_brate, ACELP_8k85 ) ) )
- {
- nBits = 8;
- move16();
- }
- ELSE
- {
- nBits = 5;
- move16();
- }
- IF( GT_32( core_brate, ACELP_8k85 ) )
- {
- nBits = 6;
- move16();
- test();
- if ( i_subfr == 0 || EQ_16( i_subfr, 2 * L_SUBFR ) )
- {
- nBits = 9;
- move16();
- }
- }
-
- pitch_index = (Word16) get_next_indice_fx( st_fx, nBits );
-
- pit_Q_dec_fx( 1, pitch_index, nBits, 8, pit_flag, *limit_flag, T0, T0_frac, T0_min, T0_max, &st_fx->BER_detect );
- }
-
- /*-------------------------------------------------------*
- * Compute floating pitch output
- *-------------------------------------------------------*/
-
- pitch = shl( add( shl( *T0, 2 ), *T0_frac ), 4 ); /* save subframe pitch values Q6 */
-
- return pitch;
-}
-
-/*======================================================================*/
-/* FUNCTION : pit_decode_ivas_fx() */
-/*-----------------------------------------------------------------------*/
-/* PURPOSE : calculate pitch value */
-/* */
-/*-----------------------------------------------------------------------*/
-/* INPUT ARGUMENTS : */
-/* _ (Word32) core_brate : Core bitrate Q0 */
-/* _ (Word16) Opt_AMR_WB : flag indicating AMR-WB IO mode Q0 */
-/* _ (Word16) L_frame : length of the frame Q0 */
-/* _ (Word16) i_subfr : length of the frame Q0 */
-/* _ (Word16) coder_type : coding type Q0 */
-/* _ (Word16) L_subfr : subframe length */
-/*-----------------------------------------------------------------------*/
-/* OUTPUT ARGUMENTS : */
-/* _ (Word16 *) T0 : close loop integer pitch */
-/* _ (Word16 *) T0_frac : close loop fractional part of the pitch */
-/* _ (Word16 ) pitch : pitch value Q6 */
-/*-----------------------------------------------------------------------*/
-/* INPUT OUTPUT ARGUMENTS */
-/* _ (Word16 *) T0_min : delta search min for sf 2 & 4 */
-/* _ (Word16 *) T0_max : delta search max for sf 2 & 4 */
-/*-----------------------------------------------------------------------*/
-/* RETURN ARGUMENTS : */
-/* _ (Word16 ) pitch : close loop integer pitch Q6 */
-/*=======================================================================*/
-
-#endif
-Word16 pit_decode_ivas_fx( /* o : floating pitch value */
- Decoder_State *st_fx, /* i/o: decoder state structure */
- const Word32 core_brate, /* i : core bitrate */
- const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
- const Word16 L_frame, /* i : length of the frame */
- Word16 i_subfr, /* i : subframe index */
- const Word16 coder_type, /* i : coding type */
- Word16 *limit_flag, /* i/o: restrained(0) or extended(1) Q limits */
- Word16 *T0, /* o : close loop integer pitch */
- Word16 *T0_frac, /* o : close loop fractional part of the pitch */
- Word16 *T0_min, /* i/o: delta search min for sf 2 & 4 */
- Word16 *T0_max, /* i/o: delta search max for sf 2 & 4 */
- const Word16 L_subfr, /* i : subframe length */
- const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
- const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer Q6 */
+/*! r: floating pitch value */
+Word16 pit_decode_fx(
+ Decoder_State *st_fx, /* i/o: decoder state structure */
+ const Word32 core_brate, /* i : core bitrate */
+ const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
+ const Word16 L_frame, /* i : length of the frame */
+ Word16 i_subfr, /* i : subframe index */
+ const Word16 coder_type, /* i : coding type */
+ Word16 *limit_flag, /* i/o: restrained(0) or extended(1) Q limits */
+ Word16 *T0, /* o : close loop integer pitch */
+ Word16 *T0_frac, /* o : close loop fractional part of the pitch */
+ Word16 *T0_min, /* i/o: delta search min for sf 2 & 4 */
+ Word16 *T0_max, /* i/o: delta search max for sf 2 & 4 */
+ const Word16 L_subfr, /* i : subframe length */
+ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
+ const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer Q6 */
)
{
Word16 pitch; /*Q2*/
diff --git a/lib_dec/post_dec_fx.c b/lib_dec/post_dec_fx.c
index b5d56d8fb9359db6b4daf5012bd70cc2349ac2bf..cbcb225bc1c845d937119028fb6fcc025a19cfeb 100644
--- a/lib_dec/post_dec_fx.c
+++ b/lib_dec/post_dec_fx.c
@@ -139,21 +139,13 @@ void post_decoder(
{
st->hPFstat->on = 1;
move16();
-#ifdef REMOVE_EVS_DUPLICATES
- formant_post_filt_ivas_fx( st->hPFstat, synth, st->mem_Aq, synth2, L_frame, st->lp_noise, bitrate, 0 );
-#else
formant_post_filt_fx( st->hPFstat, synth, st->mem_Aq, synth2, L_frame, st->lp_noise, bitrate, 0 );
-#endif
}
ELSE
{
st->hPFstat->on = 0;
move16();
-#ifdef REMOVE_EVS_DUPLICATES
- formant_post_filt_ivas_fx( st->hPFstat, synth, st->mem_Aq, synth2, L_frame, st->lp_noise, bitrate, 1 );
-#else
formant_post_filt_fx( st->hPFstat, synth, st->mem_Aq, synth2, L_frame, st->lp_noise, bitrate, 1 );
-#endif
}
}
@@ -176,10 +168,10 @@ void post_decoder(
/* Update synth2 memory */
Copy( synth_buf2 + L_frame, hBPF->pst_old_syn_fx, NBPSF_PIT_MAX );
-
return;
}
+
void post_decoder_ivas_fx(
Decoder_State *st,
Word16 synth_buf[], // Q0
@@ -310,21 +302,13 @@ void post_decoder_ivas_fx(
{
st->hPFstat->on = 1;
move16();
-#ifdef REMOVE_EVS_DUPLICATES
- formant_post_filt_ivas_fx( st->hPFstat, synth, st->mem_Aq, synth2, L_frame, st->lp_noise, bitrate, 0 );
-#else
formant_post_filt_fx( st->hPFstat, synth, st->mem_Aq, synth2, L_frame, st->lp_noise, bitrate, 0 );
-#endif
}
ELSE
{
st->hPFstat->on = 0;
move16();
-#ifdef REMOVE_EVS_DUPLICATES
- formant_post_filt_ivas_fx( st->hPFstat, synth, st->mem_Aq, synth2, L_frame, st->lp_noise, bitrate, 1 );
-#else
formant_post_filt_fx( st->hPFstat, synth, st->mem_Aq, synth2, L_frame, st->lp_noise, bitrate, 1 );
-#endif
}
}
diff --git a/lib_dec/rom_dec.c b/lib_dec/rom_dec_fx.c
similarity index 100%
rename from lib_dec/rom_dec.c
rename to lib_dec/rom_dec_fx.c
diff --git a/lib_dec/stat_dec.h b/lib_dec/stat_dec.h
index fcd5142a4c11b824f0a9638e8ca0d1209ae58b37..28a97f072fa86cd9ea94c4c884a0a0c5740c1459 100644
--- a/lib_dec/stat_dec.h
+++ b/lib_dec/stat_dec.h
@@ -94,11 +94,13 @@ typedef struct
Word16 msPsdFirstMoment[NPART_SHAPING];
Word32 msPsdSecondMoment[NPART_SHAPING];
- Word16 msNoiseFloor[NPART_SHAPING]; /* Estimated noise floor */
- Word32 msNoiseEst[NPART_SHAPING]; /* Estimated noise level */
+ Word16 msNoiseFloor[NPART_SHAPING]; /* Estimated noise floor */
+ Word32 msNoiseFloor_32fx[NPART_SHAPING]; /* IVAS: Estimated noise floor Q25*/
+ Word32 msNoiseEst[NPART_SHAPING]; /* Estimated noise level */
Word16 msNoiseEst_exp;
Word16 msLogPeriodog[NPART_SHAPING];
Word16 msLogNoiseEst[NPART_SHAPING];
+ Word32 msLogNoiseEst_32fx[NPART_SHAPING]; /*IVAS: Q25*/
Word16 npart_shaping; /* Number of partitions */
Word16 nFFTpart_shaping; /* Number of hybrid spectral partitions */
@@ -820,7 +822,8 @@ typedef struct td_bwe_dec_structure
Word16 old_bwe_exc_fx[PIT16k_MAX * 2]; /*Q_exc*/
Word16 bwe_seed[2];
Word32 bwe_non_lin_prev_scale_fx;
- Word16 old_bwe_exc_extended_fx[NL_BUFF_OFFSET];
+ Word16 old_bwe_exc_extended_fx[NL_BUFF_OFFSET]; /* EVS : Q(prev_Q_bwe_exc - 16), IVAS : Q(q_old_bwe_exc_extended_fx) */
+ Word16 q_old_bwe_exc_extended_fx;
Word32 genSHBsynth_Hilbert_Mem_fx[HILBERT_MEM_SIZE];
diff --git a/lib_dec/stat_noise_uv_dec_fx.c b/lib_dec/stat_noise_uv_dec_fx.c
index d2fa36b9b17a86f29e402983d364f6a9db1e6dd5..c87e30ffec5f0f1cd5c6cb17b5562769100885bd 100644
--- a/lib_dec/stat_noise_uv_dec_fx.c
+++ b/lib_dec/stat_noise_uv_dec_fx.c
@@ -76,10 +76,20 @@ void stat_noise_uv_dec_fx(
IF( !st_fx->Opt_AMR_WB )
{
- stat_noise_uv_mod_fx( coder_type, noisiness, st_fx->lsp_old_fx, lsp_new, lsp_mid, Aq, exc2, st_fx->Q_exc, 0, &st_fx->ge_sm_fx, &st_fx->uv_count, &st_fx->act_count,
- st_fx->lspold_s_fx, &st_fx->noimix_seed, &st_fx->min_alpha_fx,
- &st_fx->exc_pe_fx, st_fx->core_brate, st_fx->bwidth,
- &st_fx->Q_stat_noise, &st_fx->Q_stat_noise_ge );
+ IF( st_fx->element_mode > EVS_MONO )
+ {
+ stat_noise_uv_mod_ivas_fx( coder_type, noisiness, st_fx->lsp_old_fx, lsp_new, lsp_mid, Aq, exc2, &st_fx->Q_exc, 0, &st_fx->ge_sm_fx, &st_fx->uv_count, &st_fx->act_count,
+ st_fx->lspold_s_fx, &st_fx->noimix_seed, &st_fx->min_alpha_fx,
+ &st_fx->exc_pe_fx, st_fx->core_brate, st_fx->bwidth,
+ &st_fx->Q_stat_noise, &st_fx->Q_stat_noise_ge );
+ }
+ ELSE
+ {
+ stat_noise_uv_mod_fx( coder_type, noisiness, st_fx->lsp_old_fx, lsp_new, lsp_mid, Aq, exc2, st_fx->Q_exc, 0, &st_fx->ge_sm_fx, &st_fx->uv_count, &st_fx->act_count,
+ st_fx->lspold_s_fx, &st_fx->noimix_seed, &st_fx->min_alpha_fx,
+ &st_fx->exc_pe_fx, st_fx->core_brate, st_fx->bwidth,
+ &st_fx->Q_stat_noise, &st_fx->Q_stat_noise_ge );
+ }
}
diff --git a/lib_dec/swb_bwe_dec_hr_fx.c b/lib_dec/swb_bwe_dec_hr_fx.c
index 9fae1ded560681fb2420b3bc487adbb7ab23ece4..ff4d8bee65b694e9b56f26b48f8324857768f25f 100644
--- a/lib_dec/swb_bwe_dec_hr_fx.c
+++ b/lib_dec/swb_bwe_dec_hr_fx.c
@@ -11,7 +11,6 @@
#define Q_GUARD 1
#define Q_32_BITS 14 /* scaling of 't_audio32' */
#define MAKE_PSEUDO_FLT( v, e ) ( ( ( (Word32) ( v ) ) << 16 ) + ( e ) )
-#define AVQ_DEMUX
/*-----------------------------------------------------------*
* Gain_Dequant_HR()
*
@@ -595,11 +594,7 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB
Nsv = ( NUM_TRANS_END_FREQ_COEF - NUM_TRANS_START_FREQ_COEF ) / WIDTH_BAND;
move16();
-#ifdef AVQ_DEMUX
AVQ_demuxdec_fx( st_fx, x_norm, &nBits, Nsv, nq, 0, sub( Nsv, 1 ) );
-#else
- AVQ_demuxdec_fx( st_fx, x_norm, &nBits, Nsv, nq );
-#endif
temp = add( len, NUM_TRANS_START_FREQ_COEF );
/* 't_audio' in Q8 */
t_audio_exp = 8;
@@ -848,11 +843,7 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB
/* Nsv = i / WIDTH_BAND */
Nsv = shr( i, 3 );
-#ifdef AVQ_DEMUX
AVQ_demuxdec_fx( st_fx, x_norm, &nBits, Nsv, nq, 0, sub( Nsv, 1 ) );
-#else
- AVQ_demuxdec_fx( st_fx, x_norm, &nBits, Nsv, nq );
-#endif
/*---------------------------------------------------------------------*
* second stage decoding
*---------------------------------------------------------------------*/
@@ -889,11 +880,7 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB
}
nBits = sub( nBits, NBITS_GLOB_GAIN_BWE_HR );
-#ifdef AVQ_DEMUX
AVQ_demuxdec_fx( st_fx, x_norm1, &nBits, Nsv2, nq2, 0, sub( Nsv2, 1 ) );
-#else
- AVQ_demuxdec_fx( st_fx, x_norm1, &nBits, Nsv2, nq2 );
-#endif
}
/*---------------------------------------------------------------------*
diff --git a/lib_dec/swb_tbe_dec_fx.c b/lib_dec/swb_tbe_dec_fx.c
index 890e0e5c894ce3e9647abed4db0c47793360f597..1234e2853225f6db45718a9340925494e8e5554c 100644
--- a/lib_dec/swb_tbe_dec_fx.c
+++ b/lib_dec/swb_tbe_dec_fx.c
@@ -56,10 +56,13 @@ static void find_max_mem_dec(
hBWE_TD = st_fx->hBWE_TD;
/* old BWE exc max */
- FOR( i = 0; i < NL_BUFF_OFFSET; i++ )
+ IF( EQ_16( st_fx->element_mode, EVS_MONO ) )
{
- tempQ15 = abs_s( hBWE_TD->old_bwe_exc_extended_fx[i] );
- max = s_max( max, tempQ15 );
+ FOR( i = 0; i < NL_BUFF_OFFSET; i++ )
+ {
+ tempQ15 = abs_s( hBWE_TD->old_bwe_exc_extended_fx[i] );
+ max = s_max( max, tempQ15 );
+ }
}
/* decimate all-pass steep memory */
@@ -232,10 +235,13 @@ static void rescale_genSHB_mem_dec(
TD_BWE_DEC_HANDLE hBWE_TD;
hBWE_TD = st_fx->hBWE_TD;
- FOR( i = 0; i < NL_BUFF_OFFSET; i++ )
+ IF( EQ_16( st_fx->element_mode, EVS_MONO ) )
{
- hBWE_TD->old_bwe_exc_extended_fx[i] = shl( hBWE_TD->old_bwe_exc_extended_fx[i], sf );
- move16();
+ FOR( i = 0; i < NL_BUFF_OFFSET; i++ )
+ {
+ hBWE_TD->old_bwe_exc_extended_fx[i] = shl( hBWE_TD->old_bwe_exc_extended_fx[i], sf );
+ move16();
+ }
}
FOR( i = 0; i < 7; i++ )
@@ -283,9 +289,12 @@ void find_max_mem_wb( Decoder_State *st_fx, Word16 *n_mem )
TD_BWE_DEC_HANDLE hBWE_TD;
hBWE_TD = st_fx->hBWE_TD;
- FOR( i = 0; i < NL_BUFF_OFFSET; i++ )
+ IF( EQ_16( st_fx->element_mode, EVS_MONO ) )
{
- max = s_max( max, abs_s( hBWE_TD->old_bwe_exc_extended_fx[i] ) );
+ FOR( i = 0; i < NL_BUFF_OFFSET; i++ )
+ {
+ max = s_max( max, abs_s( hBWE_TD->old_bwe_exc_extended_fx[i] ) );
+ }
}
FOR( i = 0; i < 7; i++ )
{
@@ -362,10 +371,13 @@ void rescale_genWB_mem( Decoder_State *st_fx, Word16 sf )
TD_BWE_DEC_HANDLE hBWE_TD;
hBWE_TD = st_fx->hBWE_TD;
- FOR( i = 0; i < NL_BUFF_OFFSET; i++ )
+ IF( EQ_16( st_fx->element_mode, EVS_MONO ) )
{
- hBWE_TD->old_bwe_exc_extended_fx[i] = shl( hBWE_TD->old_bwe_exc_extended_fx[i], sf );
- move16();
+ FOR( i = 0; i < NL_BUFF_OFFSET; i++ )
+ {
+ hBWE_TD->old_bwe_exc_extended_fx[i] = shl( hBWE_TD->old_bwe_exc_extended_fx[i], sf );
+ move16();
+ }
}
FOR( i = 0; i < 10; i++ )
@@ -418,6 +430,8 @@ static void InitSWBdecBuffer_fx(
move16();
set16_fx( hBWE_TD->old_bwe_exc_extended_fx, 0, NL_BUFF_OFFSET );
+ hBWE_TD->q_old_bwe_exc_extended_fx = Q15;
+ move16();
hBWE_TD->bwe_non_lin_prev_scale_fx = 0;
move16();
@@ -618,6 +632,7 @@ void ivas_wb_tbe_dec_fx(
move16();
Word32 dummy2[HILBERT_MEM_SIZE];
Word16 f, inc;
+ Word64 W_tmp;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
move32();
@@ -853,17 +868,20 @@ void ivas_wb_tbe_dec_fx(
move16(); /* restrict this to 21 due to the Q factor requireemnt of the random number generator (keep 1 bit headroom) */
}
- prev_pow = 0;
- move32();
+ W_tmp = 0;
+ move64();
IF( st_fx->element_mode > EVS_MONO )
{
tmp = sub( shl( sub( st_fx->prev_Q_bwe_exc, 16 ), 1 ), 31 + 16 );
- prev_pow = L_shl_sat( 1407374848l /*0.00001f Q47*/, tmp ); /*Q(2*(st_fx->prev_Q_bwe_exc-16))*/
+ W_tmp = L_shl( 1407374848l /*0.00001f Q47*/, tmp ); /*Q(2*(st_fx->prev_Q_bwe_exc-16))*/
}
FOR( i = 0; i < L_SHB_LAHEAD / 4; i++ )
{
- prev_pow = L_mac0( prev_pow, hBWE_TD->state_syn_shbexc_fx[i], hBWE_TD->state_syn_shbexc_fx[i] ); /*Q(2*(st_fx->prev_Q_bwe_exc-16))*/
+ W_tmp = W_mac_16_16( W_tmp, hBWE_TD->state_syn_shbexc_fx[i], hBWE_TD->state_syn_shbexc_fx[i] ); /*Q(2*(st_fx->prev_Q_bwe_exc-16 + 1))*/
}
+ exp = W_norm( W_tmp );
+ prev_pow = W_extract_h( W_shl( W_tmp, exp ) );
+ exp = sub( add( add( shl( sub( st_fx->prev_Q_bwe_exc, 16 ), 1 ), 1 ), exp ), 32 );
rescale_genWB_mem( st_fx, sub( Q_bwe_exc, st_fx->prev_Q_bwe_exc ) );
@@ -901,7 +919,7 @@ void ivas_wb_tbe_dec_fx(
}
Lscale = root_a_over_b_fx( curr_pow, shl_r( Q_bwe_exc_ext, 1 ), prev_pow,
- shl_r( sub( st_fx->prev_Q_bwe_exc, 16 ), 1 ), &exp );
+ exp, &exp );
FOR( i = 0; i < L_SHB_LAHEAD / 4 - 1; i++ )
{
@@ -5371,12 +5389,6 @@ static void rescale_genSHB_mem_dec_ivas(
TD_BWE_DEC_HANDLE hBWE_TD;
hBWE_TD = st_fx->hBWE_TD;
- FOR( i = 0; i < NL_BUFF_OFFSET; i++ )
- {
- hBWE_TD->old_bwe_exc_extended_fx[i] = shl( hBWE_TD->old_bwe_exc_extended_fx[i], sf );
- move16();
- }
-
FOR( i = 0; i < 7; i++ )
{
hBWE_TD->mem_genSHBexc_filt_down_shb_fx[i] = shl( hBWE_TD->mem_genSHBexc_filt_down_shb_fx[i], sf );
@@ -6143,7 +6155,7 @@ void ivas_swb_tbe_dec_fx(
/* ----- calculate optimum Q_bwe_exc and rescale memories accordingly ----- */
Lmax = 0;
move32();
- FOR( cnt = 0; cnt < L_FRAME32k; cnt++ )
+ FOR( cnt = 0; cnt < L_FRAME32k + NL_BUFF_OFFSET; cnt++ )
{
Lmax = L_max( Lmax, L_abs( bwe_exc_extended_fx[cnt] ) );
}
@@ -6173,7 +6185,7 @@ void ivas_swb_tbe_dec_fx(
/* rescale the bwe_exc_extended and bring it to 16-bit single precision with dynamic norm */
sc = sub( Q_bwe_exc, add( Q_exc, Q_exc ) );
- FOR( cnt = 0; cnt < L_FRAME32k; cnt++ )
+ FOR( cnt = 0; cnt < L_FRAME32k + NL_BUFF_OFFSET; cnt++ )
{
bwe_exc_extended_16[cnt] = round_fx_sat( L_shl_sat( bwe_exc_extended_fx[cnt], sc ) );
move16();
@@ -6462,9 +6474,9 @@ void ivas_swb_tbe_dec_fx(
{
ener_fx = s_max( 1, ener_fx );
exp_ener = norm_s( ener_fx );
- tmp = shl( ener_fx, exp_ener ); /*Q(2+exp)*/
- inv_ener = div_s( 16384, tmp ); /*Q(15+14-2-exp)*/
- prev_ener_ratio_fx = L_shr( L_mult0( st->prev_ener_shb_fx, inv_ener ), add( sub( 9, exp_ener ), 1 ) ); /*Q: 1+27-exp-9+exp-1 = 18 */
+ tmp = shl( ener_fx, exp_ener ); /*Q(2+exp)*/
+ inv_ener = div_s( 16384, tmp ); /*Q(15+14-2-exp)*/
+ prev_ener_ratio_fx = L_shr_sat( L_mult0( st->prev_ener_shb_fx, inv_ener ), add( sub( 9, exp_ener ), 1 ) ); /*Q: 1+27-exp-9+exp-1 = 18 */
}
IF( EQ_16( st->nbLostCmpt, 1 ) )
diff --git a/lib_dec/tns_base_dec_fx.c b/lib_dec/tns_base_dec_fx.c
index 13f6ca461baaf7179c0019945c0757445019bdb0..a5df034908245daa19050eef823a8701900c0bfc 100644
--- a/lib_dec/tns_base_dec_fx.c
+++ b/lib_dec/tns_base_dec_fx.c
@@ -26,11 +26,8 @@ typedef Word32 ( *TLinearPredictionFilter )( Word16 order, Word16 const parCoeff
*
*
*---------------------------------------------------------------------*/
-#ifdef IVAS_CODE
-void
-#else
+
Word16
-#endif
ReadTnsData(
STnsConfig const *pTnsConfig,
Decoder_State *st,
@@ -47,20 +44,6 @@ ReadTnsData(
IF( GT_16( pTnsConfig->nMaxFilters, 1 ) )
{
-#ifdef IVAS_CODE
- IF( pTnsConfig->allowTnsOnWhite )
- {
- IF( LT_16( pTnsConfig->iFilterBorders[0], 512 ) )
- {
- ReadFromBitstream( &tnsEnabledOnWhiteSWBTCX10BitMap, 1, st, &stream, pnSize );
- }
- ELSE
- {
- ReadFromBitstream( &tnsEnabledOnWhiteSWBTCX20BitMap, 1, st, &stream, pnSize );
- }
- }
- ELSE
-#endif
{
IF( LT_16( pTnsConfig->iFilterBorders[0], 512 ) )
@@ -81,20 +64,10 @@ ReadTnsData(
move16();
*pnBits = sub( st->next_bit_pos, start_bit_pos );
-
-#ifdef IVAS_CODE
- return;
-#else
return TNS_NO_ERROR;
-#endif
}
-#define IVAS_CODE
-#ifdef IVAS_CODE
-void
-#else
-Word16
-#endif
-ReadTnsData_ivas_fx(
+
+void ReadTnsData_ivas_fx(
STnsConfig const *pTnsConfig,
Decoder_State *st,
Word16 *pnBits, /*Q0*/
@@ -109,7 +82,6 @@ ReadTnsData_ivas_fx(
IF( GT_16( pTnsConfig->nMaxFilters, 1 ) )
{
-#ifdef IVAS_CODE
IF( pTnsConfig->allowTnsOnWhite )
{
IF( LT_16( pTnsConfig->iFilterBorders[0], 512 ) )
@@ -122,7 +94,6 @@ ReadTnsData_ivas_fx(
}
}
ELSE
-#endif
{
IF( LT_16( pTnsConfig->iFilterBorders[0], 512 ) )
@@ -143,13 +114,9 @@ ReadTnsData_ivas_fx(
move16();
*pnBits = sub( st->next_bit_pos, start_bit_pos );
-#ifdef IVAS_CODE
return;
-#else
- return TNS_NO_ERROR;
-#endif
}
-#undef IVAS_CODE
+
/*---------------------------------------------------------------------*
* DecodeTnsData()
*
@@ -169,21 +136,6 @@ Word16 DecodeTnsData(
IF( GT_16( pTnsConfig->nMaxFilters, 1 ) )
{
-
-#ifdef IVAS_CODE
- IF( pTnsConfig->allowTnsOnWhite )
- {
- IF( LT_16( pTnsConfig->iFilterBorders[0], 512 ) )
- {
- SetParameters( &tnsEnabledOnWhiteSWBTCX10BitMap, 1, pTnsData, &stream, pnSize );
- }
- ELSE
- {
- SetParameters( &tnsEnabledOnWhiteSWBTCX20BitMap, 1, pTnsData, &stream, pnSize );
- }
- }
- ELSE
-#endif
{
IF( LT_16( pTnsConfig->iFilterBorders[0], 512 ) )
{
diff --git a/lib_dec/tonalMDCTconcealment_fx.c b/lib_dec/tonalMDCTconcealment_fx.c
index bc7e1d536257616343132f5dc3090351c994cc12..fd6cf7835e410e763405e49170ac72cb81337ee2 100644
--- a/lib_dec/tonalMDCTconcealment_fx.c
+++ b/lib_dec/tonalMDCTconcealment_fx.c
@@ -103,18 +103,6 @@ ivas_error TonalMDCTConceal_Init(
hTonalMDCTConc->nScaleFactors = nScaleFactors;
move16();
-#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
- PMTE()
- set_zero( hTonalMDCTConc->scaleFactorsBackground, FDNS_NPTS );
- PsychoacousticParameters_Init( INT_FS_16k, L_FRAME16k, 64, 1, 1, &hTonalMDCTConc->psychParamsTCX20 );
- PsychoacousticParameters_Init( INT_FS_16k, L_FRAME16k / 2, 64, 0, 1, &hTonalMDCTConc->psychParamsTCX10 );
- hTonalMDCTConc->psychParams = NULL;
- hTonalMDCTConc->scf_fadeout = 1.0f;
- hTonalMDCTConc->last_block_nrg = 0.0f;
- hTonalMDCTConc->curr_noise_nrg = 0.0f;
- hTonalMDCTConc->faded_signal_nrg = 0.0f;
-
-#endif
/* Offset the pointer to the end of buffer, so that pTCI is not destroyed when
new time samples are stored in lastPcmOut */
move16();
@@ -198,9 +186,6 @@ ivas_error TonalMDCTConceal_Init_ivas_fx(
hTonalMDCTConc->nScaleFactors = nScaleFactors;
move16();
- //#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
- // PMTE()
- // To be uncommented when field of fixed type is added for scaleFactorsBackground
set32_fx( hTonalMDCTConc->scaleFactorsBackground_fx, 0, FDNS_NPTS );
hTonalMDCTConc->scf_fadeout = 16384 /*1.000000 Q14*/;
PsychoacousticParameters_Init_fx( INT_FS_16k, L_FRAME16k, 64, 1, 1, &hTonalMDCTConc->psychParamsTCX20 );
@@ -242,12 +227,7 @@ void TonalMDCTConceal_SaveFreqSignal(
Word16 nNewSamplesCore, // Q0
const Word16 *scaleFactors, // Q31-scaleFactors_exp
const Word16 *scaleFactors_exp,
- const Word16 gain_tcx_exp
-#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
- ,
- const int16_t infoIGFStartLine
-#endif
-)
+ const Word16 gain_tcx_exp )
{
Word16 *temp;
Word16 nOldSamples, tmp_exp, s, i, max_exp;
@@ -340,20 +320,6 @@ void TonalMDCTConceal_SaveFreqSignal(
test();
IF( ( nNewSamples > 0 ) && ( LE_16( nNewSamples, 2 * L_FRAME_MAX ) ) )
{
-#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
- int16_t i;
- PMTE()
- hTonalMDCTConc->last_block_nrg_flt = 0.0f;
- for ( i = 0; i < infoIGFStartLine; i++ )
- {
- hTonalMDCTConc->lastBlockData.spectralData[i] = mdctSpectrum[i];
- hTonalMDCTConc->last_block_nrg_flt += mdctSpectrum[i] * mdctSpectrum[i];
- }
- for ( ; i < nNewSamples; i++ )
- {
- hTonalMDCTConc->lastBlockData.spectralData[i] = mdctSpectrum[i];
- }
-#else
/* Store new data */
s = getScaleFactor32( mdctSpectrum, nNewSamples );
@@ -375,7 +341,6 @@ void TonalMDCTConceal_SaveFreqSignal(
move16();
}
hTonalMDCTConc->lastBlockData.spectralData_exp = sub( mdctSpectrum_exp, s );
-#endif
move16();
hTonalMDCTConc->lastBlockData.gain_tcx_exp = gain_tcx_exp;
@@ -485,17 +450,16 @@ void TonalMDCTConceal_SaveFreqSignal_ivas_fx(
IF( ( nNewSamples > 0 ) && ( LE_16( nNewSamples, 2 * L_FRAME_MAX ) ) )
{
/* Store new data */
- hTonalMDCTConc->last_block_nrg = 0;
- move32();
-
+ Word64 W_tmp = 0;
+ move64();
FOR( i = 0; i < infoIGFStartLine; i++ )
{
- Word16 tmp = extract_h( mdctSpectrum[i] );
- hTonalMDCTConc->last_block_nrg = L_add( hTonalMDCTConc->last_block_nrg,
- L_shr( L_mult0( tmp, tmp ), 16 ) ); // Q31-last_block_nrg_exp
- move32();
+ W_tmp = W_mac_32_16( W_tmp, Mpy_32_32( mdctSpectrum[i], mdctSpectrum[i] ), 1 ); // exp: mdctSpectrum_exp + mdctSpectrum_exp - 1
}
- hTonalMDCTConc->last_block_nrg_exp = sub( 31, sub( shl( sub( 15, mdctSpectrum_exp ), 1 ), 16 ) );
+ s = W_norm( W_tmp );
+ hTonalMDCTConc->last_block_nrg = W_extract_h( W_shl( W_tmp, s ) ); // exp:add( sub( shl( mdctSpectrum_exp, 1 ), s ), 31 )
+ move32();
+ hTonalMDCTConc->last_block_nrg_exp = add( sub( shl( mdctSpectrum_exp, 1 ), s ), 31 );
move16();
/* Store new data */
@@ -909,12 +873,7 @@ static void CalcPowerSpecAndDetectTonalComponents(
Word32 secondLastMDCT[], // Q31-secondLastMDCT_exp
Word16 secondLastMDCT_exp,
Word32 const pitchLag, /*15Q16*/
- Word16 element_mode
-#ifdef IVAS_CODE_MDCT_GSHAPE
- ,
- const PsychoacousticParameters *psychParamsCurrent
-#endif
-)
+ Word16 element_mode )
{
Word16 nSamples;
Word16 i;
@@ -1004,20 +963,9 @@ static void CalcPowerSpecAndDetectTonalComponents(
/* here mdct_shaping() is intentionally used rather then mdct_shaping_16() */
-#ifdef IVAS_CODE_MDCT_GSHAPE
- IF( psychParamsCurrent == NULL )
-#endif
{
mdct_shaping( powerSpectrum, hTonalMDCTConc->nSamplesCore, invScaleFactors, invScaleFactors_exp );
}
-#ifdef IVAS_CODE_MDCT_GSHAPE
- ELSE
- {
- PMTE()
- sns_shape_spectrum( powerSpectrum, psychParamsCurrent, invScaleFactors, hTonalMDCTConc->nSamplesCore );
- nBands = psychParamsCurrent->nBands;
- }
-#endif
FOR( i = hTonalMDCTConc->nSamplesCore; i < nSamples; i++ )
{
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
@@ -1070,12 +1018,7 @@ void TonalMDCTConceal_Detect(
const TonalMDCTConcealPtr hTonalMDCTConc,
const Word32 pitchLag, /*15Q16*/
Word16 *numIndices,
- Word16 element_mode
-#ifdef IVAS_CODE_MDCT_GSHAPE
- ,
- const PsychoacousticParameters *psychParamsCurrent
-#endif
-)
+ Word16 element_mode )
{
Word32 secondLastMDST[L_FRAME_MAX];
Word32 secondLastMDCT[L_FRAME_MAX];
@@ -1147,9 +1090,6 @@ void TonalMDCTConceal_Detect(
{
/* If the second last frame was also lost, it is expected that pastTimeSignal could hold a bit different signal (e.g. including fade-out) from the one stored in TonalMDCTConceal_SaveTimeSignal. */
/* That is why we reuse the already stored information about the concealed spectrum in the second last frame */
-#ifdef IVAS_CODE_MDCT_GSHAPE
- IF( psychParamsCurrent == NULL )
-#endif
{
nSamples = hTonalMDCTConc->nNonZeroSamples;
move16();
@@ -1157,13 +1097,6 @@ void TonalMDCTConceal_Detect(
hTonalMDCTConc->secondLastBlockData.scaleFactors, hTonalMDCTConc->secondLastBlockData.scaleFactors_exp,
hTonalMDCTConc->secondLastBlockData.scaleFactors_max_e, powerSpectrum );
}
-#ifdef IVAS_CODE_MDCT_GSHAPE
- ELSE
- {
- sns_shape_spectrum( powerSpectrum, psychParamsCurrent, hTonalMDCTConc->secondLastBlockData.scaleFactors, hTonalMDCTConc->nSamplesCore );
- nBands = psychParamsCurrent->nBands;
- }
-#endif
powerSpectrum_exp = getScaleFactor32( powerSpectrum, nSamples );
powerSpectrum_exp = sub( powerSpectrum_exp, 3 ); /*extra 3 bits of headroom for MA filter in getEnvelope*/
@@ -1598,9 +1531,12 @@ void TonalMDCTConceal_InsertNoise_ivas_fx(
move16();
Word32 y = concealment_noise[l]; // concealment_noise_e
move32();
- last_block_nrg_correct = L_add( last_block_nrg_correct, Mpy_32_16_1( L_msu( 0, x, fac ), x ) ); // exp = 2 * x_exp + ld
- y = L_negate( Mpy_32_32( y, y ) ); // Q31-2* concealment_noise_e
- hTonalMDCTConc->curr_noise_nrg = BASOP_Util_Add_Mant32Exp( hTonalMDCTConc->curr_noise_nrg, hTonalMDCTConc->curr_noise_nrg_exp, y, 2 * concealment_noise_e, &hTonalMDCTConc->curr_noise_nrg_exp ); // Q31- hTonalMDCTConc->curr_noise_nrg_exp
+ shift1 = norm_l( y );
+ y = L_shl( y, shift1 );
+
+ last_block_nrg_correct = L_add( last_block_nrg_correct, Mpy_32_16_1( L_msu( 0, x, fac ), x ) ); // exp = 2 * x_exp + ld
+ y = L_negate( Mpy_32_32( y, y ) ); // Q31-(2* concealment_noise_e + shift1)
+ hTonalMDCTConc->curr_noise_nrg = BASOP_Util_Add_Mant32Exp( hTonalMDCTConc->curr_noise_nrg, hTonalMDCTConc->curr_noise_nrg_exp, y, shl( sub( concealment_noise_e, shift1 ), 1 ), &hTonalMDCTConc->curr_noise_nrg_exp ); // Q31- hTonalMDCTConc->curr_noise_nrg_exp
move32();
}
}
@@ -1666,29 +1602,9 @@ void TonalMDCTConceal_InsertNoise_ivas_fx(
/* actual fadeout is done in this case */
ELSE
{
- Word32 num, den;
- Word16 exp_num, exp_den;
+ tmp = BASOP_Util_Divide3232_Scale( cngLevelBackgroundTrace_bfi, hTonalMDCTConc->curr_noise_nrg, &exp );
+ exp = add( exp, sub( cngLevelBackgroundTrace_bfi_e, hTonalMDCTConc->curr_noise_nrg_exp ) );
- exp_num = cngLevelBackgroundTrace_bfi_e;
- move16();
- exp_den = hTonalMDCTConc->curr_noise_nrg_exp;
- move16();
-
- ld = norm_l( cngLevelBackgroundTrace_bfi );
- num = L_shl( cngLevelBackgroundTrace_bfi, ld ); // Q15 - exp_num + ld
- exp_num = sub( exp_num, ld );
- ld = norm_l( hTonalMDCTConc->curr_noise_nrg );
- den = L_shl( hTonalMDCTConc->curr_noise_nrg, ld ); // Q15 - exp_den + ld
- exp_den = sub( exp_den, ld );
-
- exp = sub( exp_num, exp_den );
-
- IF( GT_32( num, den ) )
- {
- num = L_shr( num, 1 ); // Q31- exp -1
- exp = add( exp, 1 );
- }
- tmp = div_l( num, round_fx( den ) );
tmp = Sqrt16( tmp, &exp );
g = mult_r( g, tmp ); // exponent of g = exp
@@ -1817,32 +1733,12 @@ void TonalMDCTConceal_InsertNoise_ivas_fx(
test();
IF( GT_32( hTonalMDCTConc->faded_signal_nrg, 0 ) && flag )
{
- Word16 num_exp, den_exp;
- Word32 num, den;
+ Word16 num_exp;
+ Word32 num;
num = BASOP_Util_Add_Mant32Exp( hTonalMDCTConc->last_block_nrg, hTonalMDCTConc->last_block_nrg_exp, L_negate( last_block_nrg_correct ), last_block_nrg_correct_e, &num_exp ); // Q31-num_exp
-
- den = hTonalMDCTConc->faded_signal_nrg; // Q31 - hTonalMDCTConc->faded_signal_nrg_exp
- move32();
- den_exp = hTonalMDCTConc->faded_signal_nrg_exp;
- move16();
-
- ld = norm_l( num );
- num = L_shl( num, ld ); // Q31-num_exp + ld
- num_exp = sub( num_exp, ld );
-
- ld = norm_l( den );
- den = L_shl( den, ld ); // Q31-den_exp + ld
- den_exp = sub( den_exp, ld );
-
- exp = sub( num_exp, den_exp );
-
- IF( GT_32( num, den ) )
- {
- num = L_shr( num, 1 ); // Q31- exp -1
- exp = add( exp, 1 );
- }
- tmp = div_l( num, extract_h( den ) );
+ tmp = BASOP_Util_Divide3232_Scale( num, hTonalMDCTConc->faded_signal_nrg, &exp );
+ exp = add( exp, sub( num_exp, hTonalMDCTConc->faded_signal_nrg_exp ) );
tmp = Sqrt16( tmp, &exp );
FOR( i = 0; i < crossOverFreq; i++ )
@@ -2207,19 +2103,12 @@ void TonalMDCTConceal_InsertNoise(
Word16 *pSeed, /*IN/OUT*/
const Word16 tiltCompFactor, // Q15
Word16 crossfadeGain, // Q15
-#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
- const Word16concealment_noise[L_FRAME48k],
- const float cngLevelBackgroundTrace_bfi,
-#endif
const Word16 crossOverFreq )
{
Word16 i, ld, fac;
Word16 rnd, exp, exp_last, exp_noise, inv_samples, inv_exp;
Word16 g, tiltFactor, tilt, tmp;
Word32 nrgNoiseInLastFrame, nrgWhiteNoise, L_tmp, L_tmp2;
-#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
- float last_block_nrg_correct;
-#endif
g = sub( 32767 /*1.0f Q15*/, crossfadeGain );
@@ -2230,16 +2119,6 @@ void TonalMDCTConceal_InsertNoise(
rnd = *pSeed;
move16();
}
-#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
- /* based on what is done in tcx_noise_filling() */
- /* always initialize these to avoid compiler warnings */
- tiltFactor = (float) pow( max( 0.375f, tiltCompFactor ), 1.0f / hTonalMDCTConc->lastBlockData.nSamples );
- tilt = 1.0f;
- nrgNoiseInLastFrame = 0.0f;
- nrgWhiteNoise = 0.0f;
- hTonalMDCTConc->faded_signal_nrg_flt = 0.0f;
- last_block_nrg_correct = 0.0f;
-#endif
IF( hTonalMDCTConc->lastBlockData.blockIsValid == 0 )
{
/* may just become active if the very first frame is lost */
@@ -2247,199 +2126,8 @@ void TonalMDCTConceal_InsertNoise(
*mdctSpectrum_exp = SPEC_EXP_DEC;
move16();
}
-#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
- else if ( concealment_noise != NULL )
- {
- if ( !tonalConcealmentActive )
- {
- /* if fadeout has not started yet, only apply sign scrambling */
- if ( crossfadeGain == 1.0f )
- {
- for ( i = 0; i < crossOverFreq; i++ )
- {
- if ( concealment_noise[i] > 0 )
- {
- mdctSpectrum[i] = hTonalMDCTConc->lastBlockData.spectralData[i];
- }
- else
- {
- mdctSpectrum[i] = -hTonalMDCTConc->lastBlockData.spectralData[i];
- }
- }
-
- for ( l = crossOverFreq; l < hTonalMDCTConc->lastBlockData.nSamples; l++ )
- {
- mdctSpectrum[l] = hTonalMDCTConc->lastBlockData.spectralData[l];
- }
- }
- /* actual fadeout is done in this case */
- else
- {
- g *= (float) sqrt( cngLevelBackgroundTrace_bfi / hTonalMDCTConc->curr_noise_nrg_flt );
-
- for ( i = 0; i < crossOverFreq; i++ )
- {
- x = hTonalMDCTConc->lastBlockData.spectralData[i];
- y = concealment_noise[i];
-
- if ( y > 0 )
- {
- mdctSpectrum[i] = g * y + crossfadeGain * x;
- }
- else
- {
- mdctSpectrum[i] = g * y - crossfadeGain * x;
- }
-
- hTonalMDCTConc->faded_signal_nrg_flt += mdctSpectrum[i] * mdctSpectrum[i];
- }
- for ( l = crossOverFreq; l < hTonalMDCTConc->lastBlockData.nSamples; l++ )
- {
- mdctSpectrum[l] = 0.0f;
- }
- }
- }
- else
- {
- assert( hTonalMDCTConc->pTCI->numIndexes > 0 );
-
- /* initialize bins of tonal components with zero: basically not
- necessary, but currently the whole spectrum is rescaled in
- mdct_noiseShaping() and then there would be a processing of
- uninitialized values */
- for ( i = 0; i < hTonalMDCTConc->pTCI->numIndexes; i++ )
- {
- for ( l = hTonalMDCTConc->pTCI->lowerIndex[i]; l <= hTonalMDCTConc->pTCI->upperIndex[i]; l++ )
- {
- mdctSpectrum[l] = 0;
- if ( l < crossOverFreq )
- {
- last_block_nrg_correct += hTonalMDCTConc->lastBlockData.spectralData[l] * hTonalMDCTConc->lastBlockData.spectralData[l];
- hTonalMDCTConc->curr_noise_nrg_flt -= concealment_noise[l] * concealment_noise[l];
- }
- }
- }
-
- /* if fadeout has not started yet, only apply sign scrambling */
- if ( crossfadeGain == 1.0f )
- {
- for ( l = 0; l < hTonalMDCTConc->pTCI->lowerIndex[0]; l++ )
- {
- if ( concealment_noise[l] > 0 )
- {
- mdctSpectrum[l] = hTonalMDCTConc->lastBlockData.spectralData[l];
- }
- else
- {
- mdctSpectrum[l] = -hTonalMDCTConc->lastBlockData.spectralData[l];
- }
- }
- for ( i = 1; i < hTonalMDCTConc->pTCI->numIndexes; i++ )
- {
- for ( l = hTonalMDCTConc->pTCI->upperIndex[i - 1] + 1; l < hTonalMDCTConc->pTCI->lowerIndex[i]; l++ )
- {
- if ( concealment_noise[l] > 0 )
- {
- mdctSpectrum[l] = hTonalMDCTConc->lastBlockData.spectralData[l];
- }
- else
- {
- mdctSpectrum[l] = -hTonalMDCTConc->lastBlockData.spectralData[l];
- }
- }
- }
-
- for ( l = hTonalMDCTConc->pTCI->upperIndex[hTonalMDCTConc->pTCI->numIndexes - 1] + 1; l < crossOverFreq; l++ )
- {
- if ( concealment_noise[l] > 0 )
- {
- mdctSpectrum[l] = hTonalMDCTConc->lastBlockData.spectralData[l];
- }
- else
- {
- mdctSpectrum[l] = -hTonalMDCTConc->lastBlockData.spectralData[l];
- }
- }
-
- for ( l = crossOverFreq; l < hTonalMDCTConc->lastBlockData.nSamples; l++ )
- {
- mdctSpectrum[l] = hTonalMDCTConc->lastBlockData.spectralData[l];
- }
- }
- /* actual fadeout is done in this case */
- else
- {
- g *= (float) sqrt( cngLevelBackgroundTrace_bfi / hTonalMDCTConc->curr_noise_nrg_flt );
-
- for ( l = 0; l < hTonalMDCTConc->pTCI->lowerIndex[0]; l++ )
- {
- x = hTonalMDCTConc->lastBlockData.spectralData[l];
- y = concealment_noise[l];
-
- if ( y > 0 )
- {
- mdctSpectrum[l] = g * y + crossfadeGain * x;
- }
- else
- {
- mdctSpectrum[l] = g * y - crossfadeGain * x;
- }
- hTonalMDCTConc->faded_signal_nrg_flt += mdctSpectrum[l] * mdctSpectrum[l];
- }
- for ( i = 1; i < hTonalMDCTConc->pTCI->numIndexes; i++ )
- {
- for ( l = hTonalMDCTConc->pTCI->upperIndex[i - 1] + 1; l < hTonalMDCTConc->pTCI->lowerIndex[i]; l++ )
- {
- x = hTonalMDCTConc->lastBlockData.spectralData[l];
- y = concealment_noise[l];
-
- if ( y > 0 )
- {
- mdctSpectrum[l] = g * y + crossfadeGain * x;
- }
- else
- {
- mdctSpectrum[l] = g * y - crossfadeGain * x;
- }
- hTonalMDCTConc->faded_signal_nrg_flt += mdctSpectrum[l] * mdctSpectrum[l];
- }
- }
-
- for ( l = hTonalMDCTConc->pTCI->upperIndex[hTonalMDCTConc->pTCI->numIndexes - 1] + 1; l < crossOverFreq; l++ )
- {
- x = hTonalMDCTConc->lastBlockData.spectralData[l];
- y = concealment_noise[l];
-
- if ( y > 0 )
- {
- mdctSpectrum[l] = g * y + crossfadeGain * x;
- }
- else
- {
- mdctSpectrum[l] = g * y - crossfadeGain * x;
- }
- hTonalMDCTConc->faded_signal_nrg_flt += mdctSpectrum[l] * mdctSpectrum[l];
- }
-
- for ( l = crossOverFreq; l < hTonalMDCTConc->lastBlockData.nSamples; l++ )
- {
- mdctSpectrum[l] = 0.0f;
- }
- }
- }
-
- if ( hTonalMDCTConc->faded_signal_nrg_flt > 0.0f && hTonalMDCTConc->curr_noise_nrg_flt > MDCT_ST_PLC_FADEOUT_MIN_NOISE_NRG )
- {
- float nrg_corr_factor;
-
- nrg_corr_factor = sqrtf( ( hTonalMDCTConc->last_block_nrg_flt - last_block_nrg_correct ) / hTonalMDCTConc->faded_signal_nrg_flt );
- v_multc( mdctSpectrum, nrg_corr_factor, mdctSpectrum, crossOverFreq );
- }
- }
-#endif
ELSE
{
-#ifndef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
L_tmp = 805306368l /*0.375f Q31*/;
move32();
inv_exp = 15;
@@ -2456,7 +2144,6 @@ void TonalMDCTConceal_InsertNoise(
nrgNoiseInLastFrame = L_deposit_h( 0 );
nrgWhiteNoise = L_deposit_h( 0 );
exp_last = exp_noise = 0;
-#endif
move16();
move16();
IF( !tonalConcealmentActive )
@@ -2814,10 +2501,6 @@ void TonalMDCTConceal_Apply(
const TonalMDCTConcealPtr hTonalMDCTConc, /*IN */
Word32 *mdctSpectrum, // Q31-*mdctSpectrum_exp /*IN/OUT*/
Word16 *mdctSpectrum_exp /*IN */
-#ifdef IVAS_CODE_MDCT_GSHAPE
- ,
- const PsychoacousticParameters *psychParamsCurrent
-#endif
)
{
Word16 i, l, exp;
@@ -2835,22 +2518,12 @@ void TonalMDCTConceal_Apply(
move16();
assert( hTonalMDCTConc->pTCI->upperIndex[hTonalMDCTConc->pTCI->numIndexes - 1] < nSamples );
-#ifdef IVAS_CODE_MDCT_GSHAPE
- IF( psychParamsCurrent == NULL )
-#endif
{
mdct_shaping_16( hTonalMDCTConc->secondLastPowerSpectrum, hTonalMDCTConc->nSamplesCore, nSamples,
hTonalMDCTConc->secondLastBlockData.scaleFactors, hTonalMDCTConc->secondLastBlockData.scaleFactors_exp,
hTonalMDCTConc->secondLastBlockData.scaleFactors_max_e, powerSpectrum );
}
-#ifdef IVAS_CODE_MDCT_GSHAPE
- ELSE
- {
- sns_shape_spectrum( powerSpectrum, psychParamsCurrent, hTonalMDCTConc->secondLastBlockData.scaleFactors, hTonalMDCTConc->nSamplesCore );
- nBands = psychParamsCurrent->nBands;
- }
-#endif
phaseDiff = hTonalMDCTConc->pTCI->phaseDiff; /* if multiple frame loss occurs use the phase from the last frame and continue rotating */
pCurrentPhase = hTonalMDCTConc->pTCI->phase_currentFramePredicted;
@@ -3576,216 +3249,3 @@ void TonalMdctConceal_whiten_noise_shape_ivas_fx(
pop_wmops();
}
-
-
-#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
-void TonalMdctConceal_create_concealment_noise(
- float concealment_noise[L_FRAME48k],
- CPE_DEC_HANDLE hCPE,
- const int16_t L_frameTCX,
- const int16_t L_frame,
- const int16_t idchan,
- const int16_t subframe_idx,
- const int16_t core,
- const int16_t crossfade_gain,
- const TONALMDCTCONC_NOISE_GEN_MODE noise_gen_mode )
-{
- STEREO_MDCT_DEC_DATA_HANDLE hStereoMdct;
- TonalMDCTConcealPtr hTonalMDCTConc;
- Decoder_State *st;
- HANDLE_FD_CNG_COM hFdCngCom;
- int16_t *rnd_c, *rnd;
- int16_t crossOverFreq, i, save_rnd_c, max_noise_line;
- float c, c_inv;
- float noise_shape_buffer[L_FRAME48k];
- int16_t inc, start_idx, stop_idx;
- float *cngNoiseLevelPtr;
- float last_scf;
-
- wmops_sub_start( "create_conc_noise" );
-
- hStereoMdct = hCPE->hStereoMdct;
- st = hCPE->hCoreCoder[idchan];
- hTonalMDCTConc = st->hTonalMDCTConc;
- hFdCngCom = st->hFdCngDec->hFdCngCom;
- rnd = &hStereoMdct->noise_seeds_channels[idchan];
- rnd_c = &hStereoMdct->noise_seed_common;
-
- /* determine start bin for IGF */
- if ( st->igf == 0 )
- {
- if ( st->narrowBand == 0 )
- {
- /* minimum needed for output with sampling rates lower then the
- nominal sampling rate */
- crossOverFreq = min( L_frameTCX, L_frame );
- }
- else
- {
- crossOverFreq = L_frameTCX;
- }
- }
- else
- {
- crossOverFreq = min( st->hIGFDec->infoIGFStartLine, L_frameTCX );
- }
-
- /* for tonal mdct concealment with tonal components above the crossover frequency, conditionally raise the frequency index until which noise is generated */
- max_noise_line = crossOverFreq;
- if ( st->tonal_mdct_plc_active )
- {
- max_noise_line = max( max_noise_line, hTonalMDCTConc->pTCI->upperIndex[hTonalMDCTConc->pTCI->numIndexes - 1] + 1 );
- }
-
- /* first lost frame is handled separately */
- if ( !hTonalMDCTConc->lastBlockData.blockIsConcealed )
- {
- *rnd = 1977 + idchan;
- /* will be set twice when looping over two channels, but does not matter */
- *rnd_c = 1979;
- }
-
- if ( crossfade_gain == 1.0f )
- {
- /* In first frame, noise is weighted with zero anyway, we only need the random numbers for the sign scrambling */
- for ( i = 0; i < max_noise_line; i++ )
- {
- *rnd = own_random( rnd );
- concealment_noise[i] = *rnd;
- }
-
- wmops_sub_end();
-
- return;
- }
-
- save_rnd_c = *rnd_c;
-
- c = sqrtf( hStereoMdct->lastCoh );
- c_inv = sqrtf( 1 - hStereoMdct->lastCoh );
-
- /* pre-compute the noise shape for later weighting of the noise spectra */
- cngNoiseLevelPtr = &hFdCngCom->cngNoiseLevel_flt[0];
- inc = ( st->core > TCX_20_CORE ) ? 2 : 1;
- start_idx = hFdCngCom->startBand / inc;
- stop_idx = hFdCngCom->stopFFTbin / inc;
-
- for ( i = 0; i < start_idx; i++ )
- {
- noise_shape_buffer[i] = 0.0f;
- }
- for ( ; i < stop_idx; i++, cngNoiseLevelPtr += inc )
- {
- noise_shape_buffer[i] = sqrtf( *( cngNoiseLevelPtr ) );
- }
-
- last_scf = sqrtf( *( cngNoiseLevelPtr - inc ) );
-
- for ( ; i < max_noise_line; i++ )
- {
- noise_shape_buffer[i] = last_scf;
- }
-
- /* fill the noise vector */
- hTonalMDCTConc->curr_noise_nrg_flt = MDCT_ST_PLC_FADEOUT_MIN_NOISE_NRG;
- if ( noise_gen_mode == EQUAL_CORES || ( ( noise_gen_mode == TCX20_IN_0_TCX10_IN_1 && idchan == 0 ) || ( noise_gen_mode == TCX10_IN_0_TCX20_IN_1 && idchan == 1 ) ) )
- {
- /* current channel is TCX20 -> generate noise for "full-length" spectrum */
- for ( i = 0; i < max_noise_line; i++ )
- {
- *rnd = own_random( rnd );
- *rnd_c = own_random( rnd_c );
-
- concealment_noise[i] = ( c_inv * *rnd + c * *rnd_c ) * noise_shape_buffer[i];
- hTonalMDCTConc->curr_noise_nrg_flt += concealment_noise[i] * concealment_noise[i];
- }
- }
- else /* ( ( noise_gen_mode == TCX10_IN_0_TCX20_IN_1 && idchan == 0 ) || ( noise_gen_mode == TCX20_IN_0_TCX10_IN_1 && idchan == 1 ) ) */
- {
- /* current channel is TCX10 and the other is TCX20 -> generate noise for "half-length" spectrum, but "increment" mid seed twice, to have the same seed in mid as the other (TCX20) channel for next frame */
- for ( i = 0; i < max_noise_line; i++ )
- {
- *rnd = own_random( rnd );
- *rnd_c = own_random( rnd_c );
-
- concealment_noise[i] = ( c_inv * *rnd + c * *rnd_c ) * noise_shape_buffer[i];
- hTonalMDCTConc->curr_noise_nrg_flt += concealment_noise[i] * concealment_noise[i];
-
- *rnd_c = own_random( rnd_c );
- }
- }
- if ( st->tonal_mdct_plc_active )
- {
- for ( i = crossOverFreq; i < max( crossOverFreq, hTonalMDCTConc->pTCI->lowerIndex[hTonalMDCTConc->pTCI->numIndexes - 1] ); ++i )
- {
- concealment_noise[i] *= 0.0f;
- }
- }
- /* restore common seed
- - after finishing the first channel
- - after a first subframe if the current channel is TCX10 */
- if ( ( idchan == 0 && ( core == TCX_20 || ( core == TCX_10 && subframe_idx == 1 ) ) ) || ( core == TCX_10 && subframe_idx == 0 ) )
- {
- *rnd_c = save_rnd_c;
- }
- st->seed_tcx_plc = *rnd;
- wmops_sub_end();
-
- return;
-}
-void TonalMdctConceal_whiten_noise_shape(
- Decoder_State *st,
- const int16_t L_frame,
- const TONALMDCTCONC_NOISE_SHAPE_WHITENING_MODE whitening_mode )
-{
- int16_t inc, start_idx, stop_idx;
- float *noiseLevelPtr, *scfs_bg, *scfs_for_shaping;
- HANDLE_FD_CNG_COM hFdCngCom;
- float whitenend_noise_shape[L_FRAME16k];
- float scfs_int[FDNS_NPTS];
- const PsychoacousticParameters *psychParams;
-
- push_wmops( "apply_sns_on_noise_shape" );
-
- scfs_bg = &st->hTonalMDCTConc->scaleFactorsBackground_flt[0];
- psychParams = st->hTonalMDCTConc->psychParams;
- hFdCngCom = st->hFdCngDec->hFdCngCom;
-
- inc = ( ( whitening_mode == ON_FIRST_LOST_FRAME ? st->core : st->last_core ) > TCX_20_CORE ) ? 2 : 1;
- start_idx = hFdCngCom->startBand / inc;
- stop_idx = L_frame / inc;
- noiseLevelPtr = hFdCngCom->cngNoiseLevel_flt;
-
- set_zero( whitenend_noise_shape, start_idx );
- for ( int16_t j = start_idx; j < stop_idx; j++, noiseLevelPtr += inc )
- {
- whitenend_noise_shape[j] = *noiseLevelPtr;
- }
-
- if ( whitening_mode == ON_FIRST_LOST_FRAME )
- {
- float scf[SNS_NPTS];
-
- sns_compute_scf( whitenend_noise_shape, psychParams, L_frame, scf );
- sns_interpolate_scalefactors( scfs_int, scf, ENC );
- sns_interpolate_scalefactors( scfs_bg, scf, DEC );
- scfs_for_shaping = &scfs_int[0];
- }
- else /* whitening_mode == ON_FIRST_GOOD_FRAME */
- {
- scfs_for_shaping = &scfs_bg[0];
- }
-
- if ( sum_f( scfs_for_shaping, FDNS_NPTS ) > 0.0f )
- {
- sns_shape_spectrum( whitenend_noise_shape, psychParams, scfs_for_shaping, L_frame );
- mvr2r( whitenend_noise_shape + start_idx, hFdCngCom->cngNoiseLevel_flt, stop_idx - start_idx );
- }
- else
- {
- set_zero( hFdCngCom->cngNoiseLevel_flt, stop_idx - start_idx );
- }
-
- pop_wmops();
-}
-#endif
diff --git a/lib_dec/transition_dec_fx.c b/lib_dec/transition_dec_fx.c
index b9ad17fcfedb094ff24ca64463b55580d1315305..102a81b9d25868024baec7bb8b0019127d3037c5 100644
--- a/lib_dec/transition_dec_fx.c
+++ b/lib_dec/transition_dec_fx.c
@@ -209,7 +209,14 @@ void transition_dec_fx(
limit_T0_fx( L_FRAME, 8, pit_flag, limit_flag, *T0, 0, T0_min, T0_max ); /* find T0_min and T0_max */
/* Find the adaptive codebook vector - ACELP long-term prediction */
- pred_lt4( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ IF( st_fx->element_mode != EVS_MONO )
+ {
+ pred_lt4_ivas_fx( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ }
+ ELSE
+ {
+ pred_lt4( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ }
offset = tbe_celp_exc_offset( *T0, *T0_frac, L_frame );
move16();
@@ -239,7 +246,14 @@ void transition_dec_fx(
limit_T0_fx( L_FRAME, 8, pit_flag, limit_flag, *T0, 0, T0_min, T0_max ); /* find T0_min and T0_max */
/* Find the adaptive codebook vector. ACELP long-term prediction */
- pred_lt4( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ IF( st_fx->element_mode != EVS_MONO )
+ {
+ pred_lt4_ivas_fx( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ }
+ ELSE
+ {
+ pred_lt4( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ }
offset = tbe_celp_exc_offset( *T0, *T0_frac, L_frame );
move16();
move16(); /* penality for 2 ptrs initialization */
@@ -308,7 +322,14 @@ void transition_dec_fx(
}
/* Find the adaptive codebook vector. ACELP long-term prediction */
- pred_lt4( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ IF( st_fx->element_mode != EVS_MONO )
+ {
+ pred_lt4_ivas_fx( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ }
+ ELSE
+ {
+ pred_lt4( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ }
offset = tbe_celp_exc_offset( *T0, *T0_frac, L_frame );
move16();
move16(); /* penality for 2 ptrs initialization */
@@ -330,7 +351,14 @@ void transition_dec_fx(
delta_pit_dec_fx( 2, index, T0, T0_frac, *T0_min );
/* Find the adaptive codebook vector. ACELP long-term prediction */
- pred_lt4( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ IF( st_fx->element_mode != EVS_MONO )
+ {
+ pred_lt4_ivas_fx( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ }
+ ELSE
+ {
+ pred_lt4( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ }
offset = tbe_celp_exc_offset( *T0, *T0_frac, L_frame );
move16();
move16(); /* penality for 2 ptrs initialization */
@@ -351,7 +379,14 @@ void transition_dec_fx(
pit_Q_dec_fx( 0, index, nBits, 8, pit_flag, limit_flag, T0, T0_frac, T0_min, T0_max, &st_fx->BER_detect );
/* Find the adaptive codebook vector */
- pred_lt4( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ IF( st_fx->element_mode != EVS_MONO )
+ {
+ pred_lt4_ivas_fx( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ }
+ ELSE
+ {
+ pred_lt4( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ }
offset = tbe_celp_exc_offset( *T0, *T0_frac, L_frame );
move16();
move16(); /* penality for 2 ptrs initialization */
@@ -544,7 +579,14 @@ void transition_dec_fx(
ELSE
{
/* Find the adaptive codebook vector - ACELP long-term prediction */
- pred_lt4( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ IF( st_fx->element_mode != EVS_MONO )
+ {
+ pred_lt4_ivas_fx( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ }
+ ELSE
+ {
+ pred_lt4( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ }
offset = tbe_celp_exc_offset( *T0, *T0_frac, L_frame );
move16();
move16(); /* penalty for 2 ptrs initialization */
diff --git a/lib_dec/updt_dec_fx.c b/lib_dec/updt_dec_fx.c
index 0e1b951bb4afc1e1b5e636f067099700fba78b32..81046fb19c71b0ceef898d08f1e36163f092644a 100644
--- a/lib_dec/updt_dec_fx.c
+++ b/lib_dec/updt_dec_fx.c
@@ -576,23 +576,6 @@ void updt_dec_common_fx(
test();
test();
test();
-#ifdef IVAS_CODE
- /* Store long-term estimates of stab_fac and log energy diff to estimate env_stab in case of core switch ACELP/TCX->HQ */
- if ( st->element_mode != EVS_MONO )
- {
- output_frame = NS2SA( st->output_Fs, FRAME_SIZE_NS );
- log_energy = log2f( ( sum2_f( synth, output_frame ) / output_frame ) + 1.0f );
- log_energy_diff = fabsf( st->log_energy_old - log_energy );
- st->log_energy_old = log_energy;
- st->log_energy_diff_lt = ENV_SMOOTH_FAC * log_energy_diff + ( 1.0f - ENV_SMOOTH_FAC ) * st->log_energy_diff_lt;
- if ( st->core == HQ_CORE )
- {
- st->stab_fac = min( 1, ( STAB_FAC_EST1 + ( STAB_FAC_EST2 * st->hHQ_core->mem_env_delta ) + ( STAB_FAC_EST3 * st->log_energy_diff_lt ) ) );
- st->stab_fac = max( 0, st->stab_fac );
- }
- st->stab_fac_smooth_lt = ENV_SMOOTH_FAC * st->stab_fac + ( 1.0f - ENV_SMOOTH_FAC ) * st->stab_fac_smooth_lt;
- }
-#endif
IF( ( ( LE_32( st_fx->core_brate, SID_2k40 ) ) && EQ_16( st_fx->cng_type, FD_CNG ) ) || ( st_fx->tcxonly && EQ_16( st_fx->codec_mode, MODE2 ) ) )
{
@@ -964,23 +947,6 @@ void ivas_updt_dec_common_fx(
test();
test();
test();
-#ifdef IVAS_CODE
- /* Store long-term estimates of stab_fac and log energy diff to estimate env_stab in case of core switch ACELP/TCX->HQ */
- if ( st->element_mode != EVS_MONO )
- {
- output_frame = NS2SA( st->output_Fs, FRAME_SIZE_NS );
- log_energy = log2f( ( sum2_f( synth, output_frame ) / output_frame ) + 1.0f );
- log_energy_diff = fabsf( st->log_energy_old - log_energy );
- st->log_energy_old = log_energy;
- st->log_energy_diff_lt = ENV_SMOOTH_FAC * log_energy_diff + ( 1.0f - ENV_SMOOTH_FAC ) * st->log_energy_diff_lt;
- if ( st->core == HQ_CORE )
- {
- st->stab_fac = min( 1, ( STAB_FAC_EST1 + ( STAB_FAC_EST2 * st->hHQ_core->mem_env_delta ) + ( STAB_FAC_EST3 * st->log_energy_diff_lt ) ) );
- st->stab_fac = max( 0, st->stab_fac );
- }
- st->stab_fac_smooth_lt = ENV_SMOOTH_FAC * st->stab_fac + ( 1.0f - ENV_SMOOTH_FAC ) * st->stab_fac_smooth_lt;
- }
-#else
IF( st_fx->element_mode != EVS_MONO )
{
Word16 q_div = sub( Q31, shl( Qpostd, 1 ) );
@@ -1003,7 +969,6 @@ void ivas_updt_dec_common_fx(
st_fx->stab_fac_smooth_lt_fx = extract_h( L_add( L_mult( ENV_SMOOTH_FAC_FX, st_fx->stab_fac_fx ),
L_mult( sub( MAX_16, ENV_SMOOTH_FAC_FX ), st_fx->stab_fac_smooth_lt_fx ) ) ); // Q15
}
-#endif
test();
test();
diff --git a/lib_enc/ACcontextMapping_enc_fx.c b/lib_enc/ACcontextMapping_enc_fx.c
index 43bd30fd4a5a3d9514160fc45397991ee27fbfb9..a7944410b9f855c85dd7edb3d47b8b20e55e40cc 100644
--- a/lib_enc/ACcontextMapping_enc_fx.c
+++ b/lib_enc/ACcontextMapping_enc_fx.c
@@ -1249,6 +1249,11 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx(
k = 1;
move16();
+#ifdef OPT_SBA_ENC_V2_BE
+ Word16 round_bit_estimate_fx;
+ Word32 target_Q15 = L_shl( target, Q15 ); // Q15
+#endif
+
WHILE( LT_16( k, nt / 2 ) )
{
bit_estimate_fx = W_add( bit_estimate_fx, MAKE_NUMBER_QX( 1, Q23 ) );
@@ -1334,7 +1339,7 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx(
ctx = &c[L_or( p1, p2 )];
t = (UWord16) L_add( *ctx, rateFlag );
- IF( LT_16( nt_half, idx ) )
+ if ( LT_16( nt_half, idx ) )
{
t = add( t, ( 1 << NBITS_CONTEXT ) );
}
@@ -1351,6 +1356,19 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx(
/* check while condition */
/* MSBs coding */
+#ifdef OPT_SBA_ENC_V2_BE
+ FOR( ; s_max( a1, b1 ) >= A_THRES; )
+ {
+ pki = lookup[lev1]; /* ESC symbol */
+
+ bit_estimate_fx = W_add( bit_estimate_fx, ari_bit_estimate_s17_LC_fx[pki][VAL_ESC] );
+ bit_estimate_fx = W_add( bit_estimate_fx, MAKE_VARIABLE_QX( 2, Q23 ) );
+ a1 = shr( a1, 1 );
+ b1 = shr( b1, 1 );
+
+ lev1 = s_min( add( lev1, ( 1 << ( NBITS_CONTEXT + NBITS_RATEQ ) ) ), 2 << ( NBITS_CONTEXT + NBITS_RATEQ ) );
+ }
+#else
WHILE( GE_16( s_max( a1, b1 ), A_THRES ) )
{
pki = lookup[lev1]; /* ESC symbol */
@@ -1364,14 +1382,18 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx(
/* check while condition */
}
-
+#endif
pki = lookup[lev1];
symbol = add( a1, i_mult( A_THRES, b1 ) ); /* Q0 */
bit_estimate_fx = W_add( bit_estimate_fx, ari_bit_estimate_s17_LC_fx[pki][symbol] );
+#ifdef OPT_SBA_ENC_V2_BE
+ IF( GT_32( W_shl_sat_l( bit_estimate_fx, -Q8 ), target_Q15 ) ) // Q15
+#else
/* Should we truncate? */
IF( GT_32( W_extract_l( W_shr( bit_estimate_fx, Q8 ) ), L_shl( target, Q15 ) ) )
+#endif
{
stop2 = 1;
move16();
@@ -1393,6 +1415,13 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx(
{
lev1 = shr( lev1, NBITS_CONTEXT + NBITS_RATEQ );
+#ifdef OPT_SBA_ENC_V2_BE
+ t = add( 13, lev1 );
+ IF( lev1 <= 0 )
+ {
+ t = add( 1, i_mult( add( a1, b1 ), add( lev1, 2 ) ) );
+ }
+#else
IF( lev1 <= 0 )
{
t = add( 1, i_mult( add( a1, b1 ), add( lev1, 2 ) ) );
@@ -1401,6 +1430,7 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx(
{
t = add( 13, lev1 );
}
+#endif
*ctx = L_add( imult3216( L_and( *ctx, 0xf ), 16 ), t );
move32();
@@ -1425,15 +1455,21 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx(
}
} /*end of the 2-tuples loop*/
-
- total_output_bits = round_fx( W_extract_l( W_shr( bit_estimate_fx, Q7 ) ) ); /* Q23 -> Q16 -> Q0 */
-
+#ifdef OPT_SBA_ENC_V2_BE
+ total_output_bits = round_fx( W_shl_sat_l( bit_estimate_fx, -Q7 ) ); /* Q23 -> Q16 -> Q0 */
+#else
+ total_output_bits = round_fx( W_extract_l( W_shr( bit_estimate_fx, Q7 ) ) ); /* Q23 -> Q16 -> Q0 */
+#endif
IF( *stop )
{
- total_output_bits = round_fx( W_extract_l( W_shr( nbits2_fx, Q7 ) ) ); /* Q23 -> Q16 -> Q0 */
+#ifdef OPT_SBA_ENC_V2_BE
+ total_output_bits = round_fx( W_shl_sat_l( nbits2_fx, -Q7 ) ); /* Q23 -> Q16 -> Q0 */
+#else
+ total_output_bits = round_fx( W_extract_l( W_shr( nbits2_fx, Q7 ) ) ); /* Q23 -> Q16 -> Q0 */
+#endif
}
- IF( stop2 )
+ if ( stop2 )
{
stop2 = total_output_bits; /* Q0 */
move16();
@@ -1455,8 +1491,11 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx(
hm_cfg->numPeakIndices = numPeakIndicesOrig; /* Q0 */
move16();
-
+#ifdef OPT_SBA_ENC_V2_BE
+ return round_fx( L_add( W_shl_sat_l( nbits2_fx, -Q7 ), ONE_IN_Q14 ) ); /* Q0 */
+#else
return round_fx( L_add( W_extract_l( W_shr( nbits2_fx, Q7 ) ), ONE_IN_Q14 ) ); /* Q0 */
+#endif
}
ELSE /* if (!hm_cfg) */
{
@@ -1530,6 +1569,21 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx(
/* check while condition */
/* MSBs coding */
+#ifdef OPT_SBA_ENC_V2_BE
+ FOR( ; s_max( a1, b1 ) >= A_THRES; )
+ {
+ pki = lookup[( esc_nb << ( NBITS_CONTEXT + NBITS_RATEQ ) )]; /* Q0 */
+
+ bit_estimate_fx = W_add( bit_estimate_fx, ari_bit_estimate_s17_LC_fx[pki][VAL_ESC] );
+ bit_estimate_fx = W_add( bit_estimate_fx, MAKE_NUMBER_QX( 2, Q23 ) );
+
+ a1 = shr( a1, 1 );
+ b1 = shr( b1, 1 );
+
+ lev1 = add( lev1, 1 );
+ esc_nb = s_min( lev1, 3 );
+ }
+#else
WHILE( GE_16( s_max( a1, b1 ), A_THRES ) )
{
pki = lookup[( esc_nb << ( NBITS_CONTEXT + NBITS_RATEQ ) )]; /* Q0 */
@@ -1546,15 +1600,18 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx(
/* check while condition */
}
-
+#endif
pki = lookup[( esc_nb << ( NBITS_CONTEXT + NBITS_RATEQ ) )]; /* Q0 */
- move16();
symbol = add( a1, i_mult( A_THRES, b1 ) ); /* Q0 */
bit_estimate_fx = W_add( bit_estimate_fx, ari_bit_estimate_s17_LC_fx[pki][symbol] );
/* Should we truncate? */
+#ifdef OPT_SBA_ENC_V2_BE
+ IF( GT_32( W_shl_sat_l( bit_estimate_fx, -Q8 ), target_Q15 ) ) // Q15
+#else
IF( GT_32( W_extract_l( W_shr( bit_estimate_fx, Q8 ) ), L_shl( target, Q15 ) ) )
+#endif
{
overflow_flag = 1;
move16();
@@ -1570,6 +1627,14 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx(
}
}
+#ifdef OPT_SBA_ENC_V2_BE
+ /* Update context for next 2-tuple */
+ cp = add( 1, i_mult( add( a1, b1 ), add( esc_nb, 1 ) ) ); /* Q0 */
+ if ( GE_16( esc_nb, 2 ) )
+ {
+ cp = add( 12, esc_nb ); /* Q0 */
+ }
+#else
/* Update context for next 2-tuple */
IF( LT_16( esc_nb, 2 ) )
{
@@ -1579,59 +1644,94 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx(
{
cp = add( 12, esc_nb ); /* Q0 */
}
+#endif
/*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*/
+#ifdef OPT_SBA_ENC_V2_BE
+ tot_bits2 = round_fx( W_shl_sat_l( nbits2_fx, -Q7 ) ); /* Q23 -> Q16 -> Q0 */
+ round_bit_estimate_fx = round_fx( W_shl_sat_l( bit_estimate_fx, -Q7 ) ); /* Q23 -> Q16 -> Q0 */
+#else
tot_bits2 = round_fx( W_extract_l( W_shr( nbits2_fx, Q7 ) ) ); /* Q23 -> Q16 -> Q0 */
- IF( LT_16( lastnz2, lastnz ) ) /* Overflow occured because unable to code all tuples */
+#endif
+ if ( LT_16( lastnz2, lastnz ) ) /* Overflow occured because unable to code all tuples */
{
overflow_flag = 1;
move16();
}
+#ifdef OPT_SBA_ENC_V2_BE
+ if ( EQ_16( mode, -1 ) )
+ {
+ tot_bits2 = round_bit_estimate_fx;
+ move16();
+ }
+#else
IF( EQ_16( mode, -1 ) )
{
- tot_bits2 = round_fx( W_extract_l( W_shr( bit_estimate_fx, Q7 ) ) ); /* Q23 -> Q16 -> Q0 */
+ tot_bits2 = round_fx( W_shl_sat_l( bit_estimate_fx, -Q7 ) ); /* Q23 -> Q16 -> Q0 */
}
+#endif
+#ifdef OPT_SBA_ENC_V2_BE
+ if ( overflow_flag == 0 ) /* No overflow */
+ {
+ *stop = 0;
+ move16();
+ }
+ IF( overflow_flag != 0 ) /* Overflow */
+ {
+ IF( *stop )
+ {
+ *stop = tot_bits2; /* Q0 */
+ move16();
+ }
+ ELSE
+ {
+ *stop = round_bit_estimate_fx;
+ move16();
+ }
+ }
+#else
IF( overflow_flag == 0 ) /* No overflow */
{
*stop = 0;
move16();
}
ELSE /* Overflow */
+ {
+ IF( *stop )
{
- IF( *stop ){
- *stop = tot_bits2; /* Q0 */
+ *stop = tot_bits2; /* Q0 */
+ move16();
+ }
+ ELSE
+ {
+ *stop = round_fx( W_extract_l( W_shr( bit_estimate_fx, Q7 ) ) ); /* Q23 -> Q16 -> Q0 */
+ move16();
+ }
+ }
+#endif
+
+ *lastnz_out = lastnz; /* Q0 */
move16();
- }
- ELSE
- {
- *stop = round_fx( W_extract_l( W_shr( bit_estimate_fx, Q7 ) ) ); /* Q23 -> Q16 -> Q0 */
+ *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();
+ }
+ }
-*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;
}
}
-return tot_bits2;
-}
-}
-
/*-------------------------------------------------------------------*
* RCcontextMapping_encode2_estimate_bandWise_start_fx()
@@ -1743,6 +1843,15 @@ Word16 RCcontextMapping_encode2_estimate_bandWise_fx(
/* Get context */
t = add( hContextMem->ctx, hContextMem->rateFlag ); /* Q0 */
+#ifdef OPT_SBA_ENC_V2_BE
+ tmp = ( 1 << NBITS_CONTEXT );
+ move16();
+ if ( GE_16( hContextMem->nt_half, idx ) )
+ {
+ tmp = 0;
+ move16();
+ }
+#else
IF( GE_16( hContextMem->nt_half, idx ) )
{
tmp = 0;
@@ -1751,6 +1860,7 @@ Word16 RCcontextMapping_encode2_estimate_bandWise_fx(
{
tmp = ( 1 << NBITS_CONTEXT );
}
+#endif
t = add( t, tmp ); /* Q0 */
@@ -1771,15 +1881,18 @@ Word16 RCcontextMapping_encode2_estimate_bandWise_fx(
/* check while condition */
/* MSBs coding */
+#ifdef OPT_SBA_ENC_V2_BE
+ FOR( ; s_max( a1, b1 ) >= A_THRES; )
+#else
WHILE( GE_16( s_max( a1, b1 ), A_THRES ) )
+#endif
{
pki = lookup[lev1]; /* Q0 */
- move16();
hContextMem->bit_estimate_fx = W_add( hContextMem->bit_estimate_fx, ari_bit_estimate_s17_LC_fx[pki][VAL_ESC] );
hContextMem->bit_estimate_fx = W_add( hContextMem->bit_estimate_fx, MAKE_NUMBER_QX( 2, Q23 ) );
- move32();
- move32();
+ move64();
+ move64();
// hContextMem->bit_estimate = hContextMem->bit_estimate + ari_bit_estimate_s17_LC[pki][VAL_ESC];
@@ -1789,20 +1902,27 @@ Word16 RCcontextMapping_encode2_estimate_bandWise_fx(
b1 = shr( b1, 1 );
lev1 = s_min( add( lev1, ( 1 << ( NBITS_CONTEXT + NBITS_RATEQ ) ) ), 2 << ( NBITS_CONTEXT + NBITS_RATEQ ) ); /* Q0 */
- /* check while condition */
+ /* check while condition */
}
pki = lookup[lev1]; /* Q0 */
- move16();
+
symbol = add( a1, i_mult( A_THRES, b1 ) ); /* MSB symbol Q0*/
hContextMem->bit_estimate_fx = W_add( hContextMem->bit_estimate_fx, ari_bit_estimate_s17_LC_fx[pki][symbol] );
- move32();
+ move64();
// hContextMem->bit_estimate = hContextMem->bit_estimate + ari_bit_estimate_s17_LC[pki][symbol];
/* Update context */
lev1 = shr( lev1, NBITS_CONTEXT + NBITS_RATEQ );
+#ifdef OPT_SBA_ENC_V2_BE
+ t = add( 1, i_mult( add( a1, b1 ), add( lev1, 2 ) ) ); /* Q0 */
+ if ( lev1 > 0 )
+ {
+ t = add( 13, lev1 ); /* Q0 */
+ }
+#else
IF( lev1 <= 0 )
{
t = add( 1, i_mult( add( a1, b1 ), add( lev1, 2 ) ) ); /* Q0 */
@@ -1811,12 +1931,16 @@ Word16 RCcontextMapping_encode2_estimate_bandWise_fx(
{
t = add( 13, lev1 ); /* Q0 */
}
-
+#endif
hContextMem->ctx = add( i_mult( s_and( hContextMem->ctx, 0xf ), 16 ), t ); /* Q0 */
move16();
- } /*end of the 2-tuples loop*/
+ } /*end of the 2-tuples loop*/
+#ifdef OPT_SBA_ENC_V2_BE
+ total_output_bits = round_fx( W_shl_sat_l( hContextMem->bit_estimate_fx, -Q7 ) ); /* Q0 */
+#else
total_output_bits = round_fx( W_extract_l( W_shr( hContextMem->bit_estimate_fx, Q7 ) ) ); /* Q0 */
+#endif
// total_output_bits = (Word16) ( hContextMem->bit_estimate + 0.5f );
@@ -1826,519 +1950,3 @@ Word16 RCcontextMapping_encode2_estimate_bandWise_fx(
return bandBits;
}
-
-
-#ifdef IVAS_CODE_RANGE_CODER
-
-/*-------------------------------------------------------------------*
- * RCcontextMapping_encode2_estimate_no_mem_s17_LCS()
- *
- * Range coder bit-estimation
- *-------------------------------------------------------------------*/
-
-int16_t RCcontextMapping_encode2_estimate_no_mem_s17_LCS(
- int16_t *x, /* Spectral coefficients */
- const int16_t nt, /* L - size of spectrum (no. of spectral coefficients) */
- int16_t *lastnz_out,
- int16_t *nEncoded, /* No. of spectral coefficients that can be coded without an overflow occuring */
- const int16_t target, /* Target bits */
- int16_t *stop,
- int16_t mode,
- CONTEXT_HM_CONFIG *hm_cfg /* context-based harmonic model configuration */
-)
-{
- /* Common variables */
- int16_t a1, b1;
- int16_t k, pki, lev1;
- uint16_t t;
- int16_t lastnz, lastnz2;
- int16_t rateFlag;
- float bit_estimate;
- int16_t symbol;
- const uint8_t *lookup;
- float nbits2;
-
- /* Initialization */
- bit_estimate = 2.0f;
- nbits2 = 0.f;
-
- /* bits to encode lastnz */
- k = 1;
-
- while ( k < nt / 2 )
- {
- bit_estimate++;
- k = k << 1;
- /* check while condition */
- }
-
- nbits2 = bit_estimate;
-
- if ( hm_cfg )
- {
- int16_t a1_i, b1_i;
- int16_t stop2;
- int16_t total_output_bits;
- int16_t nt_half;
- int32_t c[2], *ctx;
- int32_t p1, p2;
- int16_t ii[2];
- int16_t idx1, idx2, idx;
- int16_t numPeakIndicesOrig = 0, numHoleIndices = 0; /* only to avoid compiler warning */
-
- /* Rate flag */
- if ( target > 400 )
- {
- rateFlag = 2 << NBITS_CONTEXT; /* Select context-A for higher bitrates */
- }
- else
- {
- rateFlag = 0; /* Select context-B for lower bitrates */
- }
-
- nt_half = nt >> 1;
- stop2 = 0;
- c[0] = c[1] = 0;
-
- /* Find last non-zero tuple in the mapped domain signal */
- lastnz = find_last_nz_pair( x, nt, hm_cfg );
-
- lastnz2 = 2;
-
- /* mapped domain */
- numPeakIndicesOrig = hm_cfg->numPeakIndices;
- hm_cfg->numPeakIndices = min( hm_cfg->numPeakIndices, lastnz );
- numHoleIndices = lastnz - hm_cfg->numPeakIndices;
-
- /* Mark hole indices beyond lastnz as pruned */
- for ( k = numHoleIndices; k < hm_cfg->numHoleIndices; ++k )
- {
- hm_cfg->holeIndices[k] = hm_cfg->holeIndices[k] + nt;
- }
-
- ii[0] = numPeakIndicesOrig;
- ii[1] = 0;
-
- p1 = p2 = 0; /* to avoid compilation warnings */
-
- /* Main Loop through the 2-tuples */
- for ( k = 0; k < lastnz; k += 2 )
- {
- a1_i = get_next_coeff_mapped( ii, &p1, &idx1, hm_cfg );
- b1_i = get_next_coeff_mapped( ii, &p2, &idx2, hm_cfg );
-
- idx = min( idx1, idx2 );
-
- /* Get context */
- ctx = &c[p1 | p2];
-
- t = (uint16_t) ( *ctx + rateFlag );
- t += ( nt_half >= idx ) ? 0 : ( 1 << NBITS_CONTEXT );
-
- /* Init current 2-tuple encoding */
- a1 = (int16_t) abs( x[a1_i] );
- b1 = (int16_t) abs( x[b1_i] );
- lev1 = -( 1 << ( NBITS_CONTEXT + NBITS_RATEQ ) );
-
- /* Signs Bits */
- bit_estimate += min( a1, 1 );
- bit_estimate += min( b1, 1 );
-
- /* 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 ( max( a1, b1 ) >= A_THRES )
- {
- pki = lookup[lev1]; /* ESC symbol */
-
- bit_estimate = bit_estimate + ari_bit_estimate_s17_LC[pki][VAL_ESC];
- bit_estimate += 2; /* Add 2 LSB bits corresponding to the bit-plane */
-
- ( a1 ) >>= 1;
- ( b1 ) >>= 1;
-
- lev1 = min( lev1 + ( 1 << ( NBITS_CONTEXT + NBITS_RATEQ ) ), 2 << ( NBITS_CONTEXT + NBITS_RATEQ ) );
-
- /* check while condition */
- }
-
- pki = lookup[lev1];
-
- symbol = a1 + A_THRES * b1;
- bit_estimate = bit_estimate + ari_bit_estimate_s17_LC[pki][symbol];
-
- /* Should we truncate? */
- if ( bit_estimate > target )
- {
- stop2 = 1;
-
- if ( *stop )
- {
- break;
- }
- }
- else
- {
- lastnz2 = b1_i + 1;
- nbits2 = bit_estimate;
- }
-
- /* Update context for next 2-tuple */
- if ( p1 == p2 ) /* peak-peak or hole-hole context */
- {
- lev1 >>= NBITS_CONTEXT + NBITS_RATEQ;
-
- if ( lev1 <= 0 )
- {
- t = 1 + ( a1 + b1 ) * ( lev1 + 2 );
- }
- else
- {
- t = 13 + lev1;
- }
-
- *ctx = ( *ctx & 0xf ) * 16 + t;
- }
- else
- {
- /* mixed context */
-
- if ( idx1 & 1 )
- {
- /* update first context */
- c[p1] = update_mixed_context( c[p1], (int16_t) abs( x[a1_i] ) );
- }
-
- if ( idx2 & 1 )
- {
- /* update second context */
- c[p2] = update_mixed_context( c[p2], (int16_t) abs( x[b1_i] ) );
- }
- }
-
- } /*end of the 2-tuples loop*/
-
- total_output_bits = (int16_t) ( bit_estimate + 0.5f );
- if ( *stop )
- {
- total_output_bits = (int16_t) ( nbits2 + 0.5f );
- }
-
- if ( stop2 )
- {
- stop2 = total_output_bits;
- }
- *nEncoded = lastnz2;
- *stop = stop2; /* If zero, it means no overflow occured during bit-estimation */
- *lastnz_out = lastnz;
-
- /* Restore hole indices beyond lastnz */
- for ( k = numHoleIndices; k < hm_cfg->numHoleIndices; ++k )
- {
- hm_cfg->holeIndices[k] = hm_cfg->holeIndices[k] - nt;
- }
- hm_cfg->numPeakIndices = numPeakIndicesOrig;
-
- return (int16_t) ( nbits2 + 0.5f );
- }
- else /* if (!hm_cfg) */
- {
- int16_t esc_nb, cp, rateQ;
- uint16_t s;
- int16_t tot_bits2;
- int16_t overflow_flag = 0;
-
- /* Rate flag */
- if ( target > 400 )
- {
- rateFlag = 2;
- }
- else
- {
- rateFlag = 0; /* Select context-B for lower bitrates */
- }
-
- t = 0;
- s = 0;
- cp = 0;
- lastnz = 1;
- lastnz2 = 0;
- tot_bits2 = 0;
-
- /* Find last non-zero tuple in the mapped domain signal */
- for ( lastnz = ( nt - 2 ); lastnz >= 0; lastnz -= 2 )
- {
- if ( ( x[lastnz] != 0 ) || ( x[lastnz + 1] != 0 ) )
- {
- break;
- }
- }
- lastnz += 2;
- if ( lastnz < 2 )
- {
- lastnz = 2; /* At least one tuple is coded */
- }
-
- lastnz2 = 2;
-
- /* Main Loop through the 2-tuples */
- for ( k = 0; k < lastnz; k += 2 )
- {
- /* Init current 2-tuple encoding */
- a1 = (int16_t) abs( x[k] );
- b1 = (int16_t) abs( x[k + 1] );
- lev1 = 0;
- esc_nb = 0;
- rateQ = rateFlag + ( k > ( nt >> 1 ) );
-
- /* Signs Bits */
- bit_estimate += min( a1, 1 );
- bit_estimate += min( b1, 1 );
-
- /* 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 + ( rateQ << NBITS_CONTEXT )];
-
- /* check while condition */
- /* MSBs coding */
- while ( max( a1, b1 ) >= A_THRES )
- {
- pki = lookup[( esc_nb << ( NBITS_CONTEXT + NBITS_RATEQ ) )];
-
- bit_estimate = bit_estimate + ari_bit_estimate_s17_LC[pki][VAL_ESC];
- bit_estimate += 2; /* Add 2 LSB bits corresponding to the bit-plane */
-
- ( a1 ) >>= 1;
- ( b1 ) >>= 1;
-
- lev1++;
- esc_nb = min( lev1, 3 );
-
- /* check while condition */
- }
-
- pki = lookup[( esc_nb << ( NBITS_CONTEXT + NBITS_RATEQ ) )];
-
- symbol = a1 + A_THRES * b1;
- bit_estimate = bit_estimate + ari_bit_estimate_s17_LC[pki][symbol];
-
- /* Should we truncate? */
- if ( bit_estimate > target ) /* Overflow occured */
- {
- overflow_flag = 1;
- }
- else
- {
- if ( abs( x[k] ) || abs( x[k + 1] ) ) /* No overflow & non-zero tuple */
- {
- nbits2 = bit_estimate;
- lastnz2 = k + 2;
- }
- }
-
- /* Update context for next 2-tuple */
- if ( esc_nb < 2 )
- {
- cp = 1 + ( a1 + b1 ) * ( esc_nb + 1 );
- }
- else
- {
- cp = 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 = (int16_t) ( nbits2 + 0.5f );
- if ( lastnz2 < lastnz ) /* Overflow occured because unable to code all tuples */
- {
- overflow_flag = 1;
- }
- if ( mode == -1 )
- {
- tot_bits2 = (int16_t) ( bit_estimate + 0.5f );
- }
- if ( overflow_flag == 0 ) /* No overflow */
- {
- *stop = 0;
- }
- else /* Overflow */
- {
- if ( *stop )
- {
- *stop = tot_bits2;
- }
- else
- {
- *stop = (int16_t) ( bit_estimate + 0.5f );
- }
- }
-
- *lastnz_out = lastnz;
- *nEncoded = lastnz2;
- /* Safety mechanism to avoid overflow */
- if ( lastnz2 == 2 && overflow_flag == 1 )
- {
- for ( k = 0; k < lastnz2; k++ )
- {
- x[k] = 0;
- }
- }
-
- return tot_bits2;
- }
-}
-
-/*-------------------------------------------------------------------*
- * RCcontextMapping_encode2_estimate_bandWise_start()
- *
- * Range coder - start bandwise bit-estimation
- *-------------------------------------------------------------------*/
-
-int16_t RCcontextMapping_encode2_estimate_bandWise_start(
- int16_t *x,
- const int16_t nt,
- const int16_t target,
- HANDLE_RC_CONTEXT_MEM hContextMem )
-{
- int16_t i, k;
-
- /* Rate flag */
- if ( target > 400 )
- {
- hContextMem->rateFlag = 2 << NBITS_CONTEXT;
- }
- else
- {
- hContextMem->rateFlag = 0;
- }
-
- hContextMem->bit_estimate = 2.0f;
-
- /* Init */
- hContextMem->nt_half = nt >> 1;
-
- /* bits to encode lastnz */
- k = 1;
-
- while ( k < hContextMem->nt_half )
- {
- hContextMem->bit_estimate++;
-
- k = k << 1;
- /* check while condition */
- }
-
- /* bits to encode lastnz */
- hContextMem->nbits_old = (int16_t) hContextMem->bit_estimate;
-
- hContextMem->ctx = 0;
- hContextMem->lastnz = 2;
-
- /* Find last non-zero tuple */
-
- for ( i = nt; i >= 4; i -= 2 )
- {
-
- if ( x[i - 2] != 0 || x[i - 1] != 0 )
- {
- hContextMem->lastnz = i;
- break;
- }
- }
-
- return (int16_t) hContextMem->bit_estimate;
-}
-
-/*-------------------------------------------------------------------*
- * RCcontextMapping_encode2_estimate_bandWise()
- *
- * Range coder - bandwise bit-estimation
- *-------------------------------------------------------------------*/
-
-int16_t RCcontextMapping_encode2_estimate_bandWise(
- int16_t *x,
- const int16_t start_line,
- const int16_t end_line,
- HANDLE_RC_CONTEXT_MEM hContextMem )
-{
- int16_t a1, b1, a1_i, b1_i;
- int16_t k, pki, lev1;
- uint16_t t;
- int16_t bandBits = 0;
- int16_t total_output_bits; /* No. of bits after finalization */
- int16_t symbol;
- const uint8_t *lookup;
- int16_t 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;
- b1_i = k + 1;
-
- idx = k;
-
- /* Get context */
- t = hContextMem->ctx + hContextMem->rateFlag;
- t += ( hContextMem->nt_half >= idx ) ? 0 : ( 1 << NBITS_CONTEXT );
-
- /* Init current 2-tuple encoding */
- a1 = (int16_t) abs( x[a1_i] );
- b1 = (int16_t) abs( x[b1_i] );
- lev1 = -( 1 << ( NBITS_CONTEXT + NBITS_RATEQ ) );
-
- /* Signs Bits */
- hContextMem->bit_estimate += min( a1, 1 );
- hContextMem->bit_estimate += min( b1, 1 );
-
- /* 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 ( max( a1, b1 ) >= A_THRES )
- {
- pki = lookup[lev1];
- 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 ) >>= 1;
- ( b1 ) >>= 1;
-
- lev1 = min( lev1 + ( 1 << ( NBITS_CONTEXT + NBITS_RATEQ ) ), 2 << ( NBITS_CONTEXT + NBITS_RATEQ ) );
- /* check while condition */
- }
-
- pki = lookup[lev1];
- symbol = a1 + A_THRES * b1; /* MSB symbol */
- hContextMem->bit_estimate = hContextMem->bit_estimate + ari_bit_estimate_s17_LC[pki][symbol];
-
- /* Update context */
- lev1 >>= NBITS_CONTEXT + NBITS_RATEQ;
-
- if ( lev1 <= 0 )
- {
- t = 1 + ( a1 + b1 ) * ( lev1 + 2 );
- }
- else
- {
- t = 13 + lev1;
- }
-
- hContextMem->ctx = ( hContextMem->ctx & 0xf ) * 16 + t;
-
- } /*end of the 2-tuples loop*/
- total_output_bits = (int16_t) ( hContextMem->bit_estimate + 0.5f );
-
- bandBits = total_output_bits - hContextMem->nbits_old;
- hContextMem->nbits_old = total_output_bits;
-
- return bandBits;
-}
-
-#endif
diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c
index 4c3f7152cbde53f21bea6b4713f6a276a04b3236..f942a19ffd8db288686cc7642b6d994b245bef14 100644
--- a/lib_enc/acelp_core_enc_fx.c
+++ b/lib_enc/acelp_core_enc_fx.c
@@ -38,7 +38,6 @@ ivas_error acelp_core_enc_fx(
Word16 pitch_buf_fx[NB_SUBFR16k], /* o : floating pitch for each subframe Q6*/
Word16 *unbits_fx, /* o : number of unused bits Q0*/
STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder handle */
- const float tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */
const Word16 Q_new,
const Word16 shift )
{
@@ -107,8 +106,6 @@ ivas_error acelp_core_enc_fx(
* Initialization
*------------------------------------------------------------------*/
- (void) tdm_lsfQ_PCh;
-
Es_pred_fx = 0;
move16();
@@ -394,14 +391,10 @@ ivas_error acelp_core_enc_fx(
test();
IF( !nelp_mode && !ppp_mode )
{
-#ifdef REMOVE_EVS_DUPLICATES
- config_acelp1_IVAS( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate,
-#else
- config_acelp1( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate,
-#endif
- st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, st_fx->coder_type, st_fx->inactive_coder_type_flag,
- tc_subfr_fx, 0, &nb_bits, unbits_fx, st_fx->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_fr_cnt_fx,
- tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
+ config_acelp1_fx( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate,
+ st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, st_fx->coder_type, st_fx->inactive_coder_type_flag,
+ tc_subfr_fx, 0, &nb_bits, unbits_fx, st_fx->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_fr_cnt_fx,
+ tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
}
/*-----------------------------------------------------------------*
@@ -464,19 +457,16 @@ ivas_error acelp_core_enc_fx(
{
tc_classif_enc_fx( Q_new, st_fx->L_frame, &tc_subfr_fx, &position, attack_flag, st_fx->pitch[0], res_fx );
-#ifdef REMOVE_EVS_DUPLICATES
- config_acelp1_IVAS( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, st_fx->L_frame,
-#else
- config_acelp1( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, st_fx->L_frame,
-#endif
- -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, tc_subfr_fx, 1, NULL, unbits_fx, st_fx->element_mode, &uc_two_stage_flag,
- tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_fr_cnt_fx, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
+ config_acelp1_fx( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, st_fx->L_frame,
+ -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, tc_subfr_fx, 1, NULL, unbits_fx, st_fx->element_mode, &uc_two_stage_flag,
+ tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_fr_cnt_fx, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
}
/*---------------------------------------------------------------*
* Calculation of prediction for scaled innovation energy
* (for memory-less gain quantizer)
*---------------------------------------------------------------*/
+
IF( nb_bits > 0 )
{
Es_pred_enc_fx( &Es_pred_fx, &indice, st_fx->L_frame, res_fx, st_fx->voicing_fx, nb_bits, 0, Q_new );
@@ -521,13 +511,9 @@ ivas_error acelp_core_enc_fx(
lsp_mid_bck_fx, mCb1_fx, Bin_E_fx, Bin_E_old_fx, mem_syn_bck_fx, mem_w0_bck_fx, streaklimit_fx, pstreaklen_fx );
/* Configure ACELP bit allocation */
-#ifdef REMOVE_EVS_DUPLICATES
- config_acelp1_IVAS( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, st_fx->L_frame,
-#else
- config_acelp1( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, st_fx->L_frame,
-#endif
- -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, st_fx->coder_type, st_fx->inactive_coder_type_flag, tc_subfr_fx, 0, &nb_bits, unbits_fx, 0, &uc_two_stage_flag, 0, 0,
- st_fx->idchan, st_fx->active_fr_cnt_fx, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
+ config_acelp1_fx( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, st_fx->L_frame,
+ -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, st_fx->coder_type, st_fx->inactive_coder_type_flag, tc_subfr_fx, 0, &nb_bits, unbits_fx, 0, &uc_two_stage_flag, 0, 0,
+ st_fx->idchan, st_fx->active_fr_cnt_fx, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
/* redo LSF quantization */
lsf_enc_fx( st_fx, lsf_new_fx, lsp_new_fx, lsp_mid_fx, Aq_fx, st_fx->Nb_ACELP_frames, tdm_low_rate_mode, st_fx->GSC_IVAS_mode, Q_new );
@@ -1185,7 +1171,7 @@ ivas_error acelp_core_enc_ivas_fx(
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, st->inactive_coder_type_flag, tc_subfr, 0, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode );
+ config_acelp1_fx( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, st->GSC_noisy_speech, &( st->acelp_cfg ), hBstr->nb_bits_tot, st->coder_type, st->inactive_coder_type_flag, tc_subfr, 0, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode );
}
/*-----------------------------------------------------------------*
@@ -1322,7 +1308,7 @@ ivas_error acelp_core_enc_ivas_fx(
{
tc_classif_enc_fx( Q_new, st->L_frame, &tc_subfr, &position, attack_flag, st->pitch[0], res_fx );
- config_acelp1_IVAS( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, -1, &( st->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, tc_subfr, 1, NULL, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode );
+ config_acelp1_fx( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, -1, &( st->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, tc_subfr, 1, NULL, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode );
}
/*---------------------------------------------------------------*
@@ -1381,7 +1367,7 @@ ivas_error acelp_core_enc_ivas_fx(
lsf_syn_mem_restore_ivas_fx( st, tilt_code_bck_fx, gc_threshold_bck_fx, clip_var_bck_fx, next_force_sf_bck, lsp_new, lsp_mid, clip_var_fx, mem_AR_fx, mem_MA_fx, lsp_new_bck_fx, lsp_mid_bck_fx, Bin_E_fx, Bin_E_old_fx, mem_syn_bck_fx, mem_w0_bck_fx, streaklimit_fx, pstreaklen );
/* Configure ACELP bit allocation */
- config_acelp1_IVAS( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, -1, &( st->acelp_cfg ), hBstr->nb_bits_tot, st->coder_type, st->inactive_coder_type_flag, tc_subfr, 0, &nb_bits, unbits, 0, &uc_two_stage_flag, 0, 0, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode );
+ config_acelp1_fx( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, -1, &( st->acelp_cfg ), hBstr->nb_bits_tot, st->coder_type, st->inactive_coder_type_flag, tc_subfr, 0, &nb_bits, unbits, 0, &uc_two_stage_flag, 0, 0, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode );
/* redo LSF quantization */
lsf_enc_ivas_fx( st, lsf_new_fx, lsp_new, lsp_mid, Aq, tdm_low_rate_mode, 0, NULL, Q_new );
@@ -1390,6 +1376,7 @@ ivas_error acelp_core_enc_ivas_fx(
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 );
}
@@ -1459,8 +1446,9 @@ ivas_error acelp_core_enc_ivas_fx(
{
/* 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 );
+ Word16 q_exc2 = Q_new;
+ move16();
+ stat_noise_uv_enc_ivas_fx( st, epsP, lsp_new, lsp_mid, Aq, exc2_fx, uc_two_stage_flag, &q_exc2 );
}
/*-----------------------------------------------------------------*
diff --git a/lib_enc/acelp_core_switch_enc_fx.c b/lib_enc/acelp_core_switch_enc_fx.c
index 854f0ff678858fa13aa087920b43aa5b48ada1ba..aaaf08b2670db5a724f602516ba57b80503247d3 100644
--- a/lib_enc/acelp_core_switch_enc_fx.c
+++ b/lib_enc/acelp_core_switch_enc_fx.c
@@ -6,37 +6,21 @@
#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 */
#include "basop_util.h" /* Function prototypes */
+
/*---------------------------------------------------------------------*
* Local function prototypes
*---------------------------------------------------------------------*/
-static void encod_gen_voic_core_switch_fx( Encoder_State *st_fx,
- const Word16 L_frame_fx,
- const Word16 inp_fx[],
- const Word16 Aq_fx[],
- const Word16 A_fx[],
- const Word16 T_op[],
- Word16 *exc_fx,
- const Word32 core_bitrate_fx,
- Word16 shift,
- Word16 Q_new );
-static void encod_gen_voic_core_switch_ivas_fx( Encoder_State *st_fx,
- const Word16 L_frame_fx,
- const Word16 inp_fx[],
- const Word16 Aq_fx[],
- const Word16 A_fx[],
- const Word16 T_op[],
- Word16 *exc_fx,
- const Word32 core_bitrate_fx,
- Word16 shift,
- Word16 Q_new );
+static void encod_gen_voic_core_switch_fx( Encoder_State *st_fx, const Word16 L_frame_fx, const Word16 inp_fx[], const Word16 Aq_fx[], const Word16 A_fx[], const Word16 T_op[], Word16 *exc_fx, const Word32 core_bitrate_fx, Word16 shift, Word16 Q_new );
+
+static void encod_gen_voic_core_switch_ivas_fx( Encoder_State *st_fx, const Word16 L_frame_fx, const Word16 inp_fx[], const Word16 Aq_fx[], const Word16 A_fx[], const Word16 T_op[], Word16 *exc_fx, const Word32 core_bitrate_fx, Word16 shift, Word16 Q_new );
static void bwe_switch_enc_fx( Encoder_State *st_fx, const Word16 *new_speech );
+
static void bwe_switch_enc_ivas_fx( Encoder_State *st_fx, const Word16 *new_speech );
static Word16 dotprod_satcont( const Word16 *x, const Word16 *y, Word16 qx, Word16 qy, Word16 *qo, Word16 len, Word16 delta );
@@ -151,12 +135,8 @@ void acelp_core_switch_enc_fx(
* Excitation encoding
*----------------------------------------------------------------*/
-#ifdef REMOVE_EVS_DUPLICATES
- config_acelp1_IVAS( ENC, st_fx->total_brate, cbrate, st_fx->core, -1, -1, st_fx->last_L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot,
-#else
- config_acelp1( ENC, st_fx->total_brate, cbrate, st_fx->core, -1, -1, st_fx->last_L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot,
-#endif
- GENERIC, st_fx->inactive_coder_type_flag, -1, -1, &j, &i, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, 0, 0 /*GSC_IVAS_mode*/ );
+ config_acelp1_fx( ENC, st_fx->total_brate, cbrate, st_fx->core, -1, -1, st_fx->last_L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot,
+ GENERIC, st_fx->inactive_coder_type_flag, -1, -1, &j, &i, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, 0, 0 /*GSC_IVAS_mode*/ );
encod_gen_voic_core_switch_fx( st_fx, st_fx->last_L_frame, inp, Aq, A, T_op, exc, cbrate, shift, Q_new );
@@ -279,8 +259,8 @@ void acelp_core_switch_enc_ivas_fx(
* Excitation encoding
*----------------------------------------------------------------*/
- config_acelp1_IVAS( ENC, st_fx->total_brate, cbrate, st_fx->core, -1, -1, st_fx->last_L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot,
- GENERIC, st_fx->inactive_coder_type_flag, -1, -1, &j, &i, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, 0, 0 /*GSC_IVAS_mode*/ );
+ config_acelp1_fx( ENC, st_fx->total_brate, cbrate, st_fx->core, -1, -1, st_fx->last_L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot,
+ GENERIC, st_fx->inactive_coder_type_flag, -1, -1, &j, &i, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, 0, 0 /*GSC_IVAS_mode*/ );
encod_gen_voic_core_switch_ivas_fx( st_fx, st_fx->last_L_frame, inp, Aq, A, T_op, exc, cbrate, shift, Q_new );
@@ -652,7 +632,7 @@ static void encod_gen_voic_core_switch_ivas_fx(
* Find adaptive exitation
*-----------------------------------------------------------------*/
- pred_lt4( &exc[0], &exc[0], T0, T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ pred_lt4_ivas_fx( &exc[0], &exc[0], T0, T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
/*-----------------------------------------------------------------*
* Gain clipping test to avoid unstable synthesis on frame erasure
@@ -728,7 +708,7 @@ static void encod_gen_voic_core_switch_ivas_fx(
* long term prediction on the 2nd sub frame
*-----------------------------------------------------------------*/
- pred_lt4( &exc[L_SUBFR], &exc[L_SUBFR], T0, T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ pred_lt4_ivas_fx( &exc[L_SUBFR], &exc[L_SUBFR], T0, T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
FOR( i = L_SUBFR; i < 2 * L_SUBFR; i++ )
{
diff --git a/lib_enc/acelp_enc_util_fx.c b/lib_enc/acelp_enc_util_fx.c
index 181583e91d23686fd8a753128ec344665e4e27a2..7f57b55da9f685b3d5800308105bf66c623742fe 100644
--- a/lib_enc/acelp_enc_util_fx.c
+++ b/lib_enc/acelp_enc_util_fx.c
@@ -180,9 +180,9 @@ void E_ACELP_conv(
}
void E_ACELP_conv_ivas_fx(
- const Word16 xn2[], /* i Qx*/
+ const Word16 xn2[], /* i Qnew - 1*/
const Word16 h2[], /* i Q12*/
- Word16 cn2[] /* o Q0*/
+ Word16 cn2[] /* o Qnew*/
)
{
Word16 i, k;
@@ -194,14 +194,14 @@ void E_ACELP_conv_ivas_fx(
{
/*cn2[k] = xn2[k]; */
Word64 L_tmp_64;
- L_tmp_64 = W_deposit32_l( L_mult0( xn2[k], 0x800 ) ); /* 4Q11 */
+ L_tmp_64 = W_deposit32_l( L_mult0( xn2[k], 0x800 ) ); /* Qnew -1 + 12 */
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_64 = W_msu0_16_16( L_tmp_64, cn2[i], h2[k - i] ); /*Qnew + 11*/
}
- L_tmp = W_sat_l( L_tmp_64 ); /* 4Q11 */
- cn2[k] = round_fx_o( L_shl_o( L_tmp, 5, &Overflow ), &Overflow ); /* Q0*/
+ L_tmp = W_sat_l( L_tmp_64 ); /* Qnew + 11 */
+ cn2[k] = round_fx_o( L_shl_o( L_tmp, 5, &Overflow ), &Overflow ); /* Qnew*/
move16();
}
}
diff --git a/lib_enc/analy_lp_fx.c b/lib_enc/analy_lp_fx.c
index 78a02eeecf117fbc823f78c8b250a13ccd8b3b14..9b6ff2108359dcb6242fd83232ab5972e2236e01 100644
--- a/lib_enc/analy_lp_fx.c
+++ b/lib_enc/analy_lp_fx.c
@@ -3,17 +3,16 @@
====================================================================================*/
#include
-#include "options.h" /* Compilation switches */
-#include "cnst.h" /* Common constants */
-#include "rom_com_fx.h" /* Static table prototypes */
-#include "rom_com.h" /* Static table prototypes */
-#include "rom_enc.h" /* Static table prototypes */
-//#include "prot_fx.h" /* Function prototypes */
+#include "options.h" /* Compilation switches */
+#include "cnst.h" /* Common constants */
+#include "rom_com_fx.h" /* Static table prototypes */
+#include "rom_com.h" /* Static table prototypes */
+#include "rom_enc.h" /* Static table prototypes */
#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
/*-------------------------------------------------------------------*
- * analy_lp()
+ * analy_lp_fx()
*
* Perform LP analysis
*
@@ -23,26 +22,26 @@
* - find interpolated LSPs and convert back to A(z) for all subframes
* - update LSPs for the next frame
*-------------------------------------------------------------------*/
-void analy_lp_ivas_fx(
- const Word16 speech[], /* i :(Q_new) pointer to the speech frame */
- const Word16 L_frame, /* i :(q0) length of the frame */
- const Word16 L_look, /* i :(q0) look-ahead */
- Word32 *ener, /* o :(Q_r) residual energy from Levinson-Durbin */
- Word16 A[], /* o :(q14) A(z) filter coefficients */
- Word16 epsP_h[], /* o :(high part of epsP(Q_r)) LP analysis residual energies for each iteration */
- Word16 epsP_l[], /* o :(low part of epsP(Q_r)) LP analysis residual energies for each iteration */
- Word16 lsp_new[], /* o :(q15) current frame LSPs */
- Word16 lsp_mid[], /* o :(q15) current mid-frame LSPs */
- Word16 lsp_old[], /* i/o:(q15) previous frame unquantized LSPs */
- const Word16 Top[2], /* i :(q0) open loop pitch lag */
- const Word16 Tnc[2], /* i :(q15) open loop pitch gain */
- const Word32 Core_sr, /* i :(q0) Internal core sampling rate */
-#ifdef REMOVE_EVS_DUPLICATES
- const Word16 element_mode, /* i : element mode */
-#endif
- const Word16 sec_chan_low_rate, /* i :(q0) flag to signal second channel */
- Word16 Q_new, /*i: stores Q for speech*/
- Word16 *Q_r /*stores q for ener*/ )
+
+void analy_lp_fx(
+ const Word16 speech[], /* i :(Q_new) pointer to the speech frame */
+ const Word16 L_frame, /* i :(q0) length of the frame */
+ const Word16 L_look, /* i :(q0) look-ahead */
+ Word32 *ener, /* o :(Q_r) residual energy from Levinson-Durbin */
+ Word16 A[], /* o :(q14) A(z) filter coefficients */
+ Word16 epsP_h[], /* o :(high part of epsP(Q_r)) LP analysis residual energies for each iteration */
+ Word16 epsP_l[], /* o :(low part of epsP(Q_r)) LP analysis residual energies for each iteration */
+ Word16 lsp_new[], /* o :(q15) current frame LSPs */
+ Word16 lsp_mid[], /* o :(q15) current mid-frame LSPs */
+ Word16 lsp_old[], /* i/o:(q15) previous frame unquantized LSPs */
+ const Word16 Top[2], /* i :(q0) open loop pitch lag */
+ const Word16 Tnc[2], /* i :(q15) open loop pitch gain */
+ const Word32 Core_sr, /* i :(q0) Internal core sampling rate */
+ const Word16 element_mode, /* i : element mode */
+ const Word16 sec_chan_low_rate, /* i :(q0) flag to signal second channel */
+ Word16 Q_new, /* i : stores Q for speech */
+ Word16 *Q_r /*stores q for ener*/
+)
{
Word16 r_h[M + 1]; /* Autocorrelations of windowed speech MSB */
Word16 r_l[M + 1]; /* Autocorrelations of windowed speech LSB */
@@ -77,9 +76,7 @@ void analy_lp_ivas_fx(
/* Autocorrelations */
autocorr_fx( pt, M, r_h, r_l, &Q_r[1 - i_subfr], wind_length, wind, 0, 0 );
-#ifdef REMOVE_EVS_DUPLICATES
IF( NE_16( element_mode, EVS_MONO ) )
-#endif
{
/*if ( r[0] < 100.0f && no_thr == 0 )*/
/*r[0] = 100.0f*/
@@ -132,101 +129,6 @@ void analy_lp_ivas_fx(
return;
}
-#ifndef REMOVE_EVS_DUPLICATES
-void analy_lp_fx(
- 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 )
-{
- Word16 r_h[M + 1]; /* Autocorrelations of windowed speech MSB */
- Word16 r_l[M + 1]; /* Autocorrelations of windowed speech LSB */
- Word32 LepsP[M + 1];
- Word16 i, i_subfr, wind_length = 0;
- Word16 *lsp;
- const Word16 *wind = NULL;
- const Word16 *pt;
- Word16 half_frame;
-
- IF( EQ_16( L_frame, L_FRAME ) )
- {
- wind_length = L_LP;
- move16();
- wind = Assym_window_W16fx; /* Q15 */
- }
- ELSE /* L_frame == L_FRAME16k */
- {
- wind_length = L_LP_16k;
- move16();
- wind = assym_window_16k_fx; /* Q15 */
- }
- lsp = lsp_mid; /* Q15 */
- half_frame = shr( L_frame, 1 );
-
- FOR( i_subfr = 0; i_subfr <= 1; i_subfr++ )
- {
- pt = speech + sub( add( half_frame, L_look ), wind_length );
- half_frame = shl( half_frame, 1 );
-
- /* Autocorrelations */
- autocorr_fx( pt, M, r_h, r_l, &Q_r[1 - i_subfr], wind_length, wind, 0, 0 );
-
- /* Lag windowing */
- adapt_lag_wind( r_h, r_l, M, Top[i_subfr], Tnc[i_subfr], Core_sr );
-
- /* Levinson-Durbin */
- E_LPC_lev_dur( r_h, r_l, A, LepsP, M, NULL );
- FOR( i = 0; i <= M; i++ )
- {
- L_Extract( LepsP[i], &epsP_h[i], &epsP_l[i] );
- }
- /*Q_r[... might not be needed from external...*/
- Q_r[1 - i_subfr] = add( Q_r[1 - i_subfr], shl( Q_new, 1 ) );
- move16();
-
- /* Conversion of A(z) to LSPs */
- E_LPC_a_lsp_conversion( A, lsp, lsp_old, M );
-
- lsp = lsp_new; /* Q15 */
- }
- IF( EQ_16( sec_chan_low_rate, 1 ) )
- {
- /* LSP interpolation */
-#ifdef REMOVE_EVS_DUPLICATES
- int_lsp4_ivas_fx( L_frame, lsp_old, lsp_mid, lsp_new, A, M, -2 );
-#else
- int_lsp4_fx( L_frame, lsp_old, lsp_mid, lsp_new, A, M, -2 );
-#endif
- }
- ELSE
- {
- /* LSP interpolation */
-#ifdef REMOVE_EVS_DUPLICATES
- int_lsp4_fx( L_frame, lsp_old, lsp_mid, lsp_new, A, M, 0 );
-#else
- int_lsp4_fx( L_frame, lsp_old, lsp_mid, lsp_new, A, M, 0 );
-#endif
- }
- Copy( lsp_new, lsp_old, M ); /* Q15 */
- *ener = L_Comp( epsP_h[M], epsP_l[M] ); /* Q_r */
- move32();
-
- return;
-}
-#endif
-
/*-------------------------------------------------------------------*
* analy_lp_AMR_WB()
*
diff --git a/lib_enc/analy_sp_fx.c b/lib_enc/analy_sp_fx.c
index 49bb03f57ac0f2ede5c7e801012cd246ca972686..dbd656dec391af2ae3400c8a949e8a53765054a3 100644
--- a/lib_enc/analy_sp_fx.c
+++ b/lib_enc/analy_sp_fx.c
@@ -569,6 +569,8 @@ void ivas_analy_sp_fx(
*Etot = L_shl( Ltmp, Q24 - Q21 ); // Q24
move16();
}
+ *q_band_energies = *q_fr_bands;
+ move16();
}
ELSE
{
@@ -578,10 +580,10 @@ void ivas_analy_sp_fx(
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)
+ *Etot = -193760400; // Q24
*q_fr_bands = Q31;
*q_lf_E = *q_fr_bands;
+ move32();
move16();
move16();
}
@@ -596,31 +598,30 @@ void ivas_analy_sp_fx(
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 = -838860800 /* 10.f * log10f(0.00001f) in Q24 : This is when LEtot is 0*/;
- move16();
- IF( LEtot != 0 )
- {
- 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 = L_shl( Ltmp, Q24 - Q21 ); // Q24
+ /* Average total log energy over both half-frames */
+ *Etot = -838860800 /* 10.f * log10f(0.00001f) in Q24 : This is when LEtot is 0*/;
move16();
+ IF( LEtot != 0 )
+ {
+ 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 = L_shl( Ltmp, Q24 - Q21 ); // Q24
+ move16();
+ }
}
+ *q_band_energies = *q_fr_bands;
+ 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 );
+ exp = getScaleFactor32( band_energies, 2 * NB_BANDS );
scale_sig32( band_energies, 2 * NB_BANDS, exp ); /* q_band_energies + exp */
*q_band_energies = add( *q_band_energies, exp );
move16();
@@ -860,7 +861,7 @@ static void ivas_find_enr(
* Find the total energy over the input bandwidth
*-----------------------------------------------------------------*/
- etot = *LEtot; // *q_band
+ etot = *LEtot; // *q_band+1
move64();
FOR( i = min_band; i <= max_band; i++ )
{
diff --git a/lib_enc/bw_detect_fx.c b/lib_enc/bw_detect_fx.c
index 050adbf01b0bf0adf22621c85d3fae5fa0974647..94ed49129de9c7a0e9ad3b158399d35a366c6de4 100644
--- a/lib_enc/bw_detect_fx.c
+++ b/lib_enc/bw_detect_fx.c
@@ -71,6 +71,7 @@ void bw_detect_fx(
Flag Overflow = 0;
move32();
#endif
+ Word16 lp_noise_fx;
bwd_count_wider_bw = BWD_COUNT_WIDER_BW;
move16();
@@ -532,7 +533,17 @@ void bw_detect_fx(
/*if( localVAD || st->lp_noise > 30 )*/
test();
- IF( st->localVAD || GT_16( st->lp_noise_fx, 7680 /*30 in Q8*/ ) )
+ IF( EQ_16( st->element_mode, EVS_MONO ) )
+ {
+ lp_noise_fx = st->lp_noise_fx;
+ move16();
+ }
+ ELSE
+ {
+ lp_noise_fx = extract_h( st->lp_noise_32fx );
+ }
+
+ IF( st->localVAD || GT_32( ( 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 */
diff --git a/lib_enc/cng_enc_fx.c b/lib_enc/cng_enc_fx.c
index b031ca5286e5688abb3280298481d225d47d5300..9dea812a6d01a5f464a9fb622dda064334c62c27 100644
--- a/lib_enc/cng_enc_fx.c
+++ b/lib_enc/cng_enc_fx.c
@@ -462,7 +462,6 @@ void CNG_enc_fx(
IF( hTdCngEnc->burst_ho_cnt > 0 )
{
/**allow_cn_step |= ( hTdCngEnc->ho_ener_hist_fx[hTdCngEnc->ho_hist_ptr] > 4 * hTdCngEnc->lp_ener_fx ); */
-#if 1
/*allow_cn_step |= (hDtxEnc->first_CNG || st->element_mode == EVS_MONO) && (hTdCngEnc->ho_ener_hist[hTdCngEnc->ho_hist_ptr] > lp_ener_thr_scale * hTdCngEnc->lp_ener);*/
/* (hTdCngEnc->ho_ener_hist[hTdCngEnc->ho_hist_ptr] > lp_ener_thr_scale * hTdCngEnc->lp_ener); */
L_tmp1 = L_shr( hTdCngEnc->ho_ener_hist_fx[hTdCngEnc->ho_hist_ptr], 2 );
@@ -471,10 +470,6 @@ void CNG_enc_fx(
L_tmp1 = L_add( L_tmp1, L_shr( hTdCngEnc->lp_ener_fx, 8 ) );
}
L_tmp1 = L_sub( L_tmp1, hTdCngEnc->lp_ener_fx );
-#else
- L_tmp1 = L_shr( hTdCngEnc->ho_ener_hist_fx[hTdCngEnc->ho_hist_ptr], 2 );
- L_tmp1 = L_sub( L_tmp1, hTdCngEnc->lp_ener_fx );
-#endif
test();
test();
IF( ( hDtxEnc->first_CNG > 0 || st_fx->element_mode == EVS_MONO ) && L_tmp1 > 0 )
diff --git a/lib_enc/cod4t64_fast.c b/lib_enc/cod4t64_fast_fx.c
similarity index 99%
rename from lib_enc/cod4t64_fast.c
rename to lib_enc/cod4t64_fast_fx.c
index e24f3b678add290844dd03df2a523248c5a3d169..7079f65971792963c9701841da0e9cc00e80bd54 100644
--- a/lib_enc/cod4t64_fast.c
+++ b/lib_enc/cod4t64_fast_fx.c
@@ -145,7 +145,8 @@ void acelp_fast_fx(
Word16 track_order[NB_TRACK_FCB_4T * MAX_NUM_INTER], m0_track[NB_TRACK_FCB_4T];
Word16 ind_stream[NPMAXPT * NB_TRACK_FCB_4T], idx;
Word16 G, G1, G2, G3, Gn, Gd;
- Word32 Gd32;
+ Word32 Gd32 = 0;
+ move32();
Word16 y_tmp[L_SUBFR_MAX];
Word32 dn[L_SUBFR_MAX];
Word32 crit_num, crit_den, crit_num_max, crit_den_max, L_tmp1, L_tmp2;
@@ -718,8 +719,6 @@ void acelp_fast_fx(
IF( GE_16( nb_pulse, 4 ) )
{
Gn = add( Gn, i_mult( s[2], dn_orig[m[2]] ) ); // Q_dn
- Gd32 = Gd;
- move16();
temp1 = alp[0];
move32();
temp2 = L_mult0( i_mult( shl( s[0], 1 ), s[2] ), alp[m[0] - m[2]] );
@@ -770,8 +769,6 @@ void acelp_fast_fx(
IF( GE_16( nb_pulse, 5 ) )
{
Gn = add( Gn, i_mult( s[3], dn_orig[m[3]] ) ); // Q_dn
- Gd32 = Gd;
- move16();
temp1 = alp[0];
move32();
temp2 = L_mult0( i_mult( shl( s[0], 1 ), s[3] ), alp[m[0] - m[3]] );
diff --git a/lib_enc/cod_ace_fx.c b/lib_enc/cod_ace_fx.c
index b5c18d44b7cbbba2fbaeb1cb78cdee15c7d0ac39..e1914aeb5bb7b2e51f123b8f0ca042512c174644 100644
--- a/lib_enc/cod_ace_fx.c
+++ b/lib_enc/cod_ace_fx.c
@@ -366,14 +366,9 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision *
IF( st->igf != 0 )
{
-#ifdef REMOVE_EVS_DUPLICATES
- prep_tbe_exc_ivas_fx( L_frame, L_SUBFR, i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr / L_SUBFR],
- bwe_exc, gain_preQ, code_preQ, Q_new, T0, T0_frac, st->coder_type, st->core_brate,
- st->element_mode, st->idchan, st->hBWE_TD != NULL, st->tdm_LRTD_flag );
-#else
- prep_tbe_exc_fx( L_frame, i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr / L_SUBFR],
- bwe_exc, gain_preQ, code_preQ, Q_new, T0, T0_frac, st->coder_type, st->core_brate );
-#endif
+ prep_tbe_exc_fx( L_frame, L_SUBFR, i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr / L_SUBFR],
+ bwe_exc, gain_preQ, code_preQ, Q_new, T0, T0_frac, st->coder_type, st->core_brate,
+ st->element_mode, st->idchan, st->hBWE_TD != NULL, st->tdm_LRTD_flag );
}
/*---------------------------------------------------------*
diff --git a/lib_enc/cod_tcx_fx.c b/lib_enc/cod_tcx_fx.c
index 4bb44eae27961630ea3f98bab5030ebce5fce018..27f3d2aa6697f9d88264ca14b3a8452595d9de08 100644
--- a/lib_enc/cod_tcx_fx.c
+++ b/lib_enc/cod_tcx_fx.c
@@ -138,487 +138,7 @@ void HBAutocorrelation_fx(
move32();
}
}
-#ifdef ADD_IVAS_TNS
-/*-------------------------------------------------------------------*
- * TNSAnalysisStereo()
- *
- *
- *-------------------------------------------------------------------*/
-
-#define SIMILAR_TNS_THRESHOLD ( 0.04f )
-#define TNS_GAIN_THRESHOLD_FOR_WHITE ( 3.0f )
-
-void TNSAnalysisStereo(
- Encoder_State **sts, /* i : encoder state handle */
- float *mdst_spectrum[MCT_MAX_CHANNELS][NB_DIV], /* o : MDST spectrum */
- const int16_t bWhitenedDomain, /* i : whitened domain flag */
- int16_t tnsSize[MCT_MAX_CHANNELS][NB_DIV], /* i : number of tns parameters put into prm */
- int16_t tnsBits[MCT_MAX_CHANNELS][NB_DIV], /* i : number of tns bits in the frame */
- int16_t param_core[][NB_DIV * NPRM_DIV], /* o : TNS parameters */
- const int16_t mct_on /* i : flag mct block (1) or stereo (0) */
-)
-{
- int16_t ch, k, L_spec, L_frame, nSubframes, iFilter;
- float *spectrum;
- Encoder_State *st = NULL;
- TCX_ENC_HANDLE hTcxEnc = NULL;
- int16_t individual_decision[NB_DIV];
- float maxPredictionGain = 0.f, meanPredictionGain;
-
- individual_decision[0] = 0;
- individual_decision[1] = 0;
- L_spec = -1;
- L_frame = -1;
-
- /* TNS filter analysis, loop over channels */
- for ( ch = 0; ch < CPE_CHANNELS; ch++ )
- {
- st = sts[ch];
- if ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE )
- {
- continue;
- }
-
- hTcxEnc = st->hTcxEnc;
-
- nSubframes = ( hTcxEnc->tcxMode == TCX_20 ) ? 1 : NB_DIV;
-
- for ( k = 0; k < nSubframes; k++ )
- {
- /* reset tns on whitened domain flag */
- if ( !bWhitenedDomain )
- {
- hTcxEnc->bTnsOnWhithenedSpectra[k] = 0;
- hTcxEnc->fUseTns[k] = 0;
- }
-
- if ( st->hTcxCfg->fIsTNSAllowed && ( !bWhitenedDomain || hTcxEnc->bTnsOnWhithenedSpectra[k] ) )
- {
-
- spectrum = hTcxEnc->spectrum[k];
- L_frame = hTcxEnc->L_frameTCX;
- st->hTcxCfg->pCurrentTnsConfig = &st->hTcxCfg->tnsConfig[hTcxEnc->transform_type[k] == TCX_20][( k == 0 ) && ( st->last_core == ACELP_CORE )];
- L_spec = st->hTcxCfg->pCurrentTnsConfig->iFilterBorders[0];
-
- /*-----------------------------------------------------------*
- * Temporal Noise Shaping analysis *
- *-----------------------------------------------------------*/
-
- if ( hTcxEnc->transform_type[k] == TCX_5 )
- {
- /* rearrange LF sub-window lines prior to TNS analysis & filtering */
- tcx5TnsGrouping( L_frame >> 2, L_spec >> 1, spectrum );
- }
-
- /* 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 )
- {
- break;
- }
-
- CalculateTnsFilt( st->hTcxCfg->pCurrentTnsConfig, spectrum, &hTcxEnc->tnsData[k], NULL );
- }
- }
- }
-
- if ( !mct_on )
- {
- /* TNS decision */
- /* if framing differs between channels, keep the filter decision per channel */
- if ( ( sts[0]->hTcxEnc->transform_type[0] != sts[1]->hTcxEnc->transform_type[0] &&
- sts[0]->hTcxEnc->transform_type[1] != sts[1]->hTcxEnc->transform_type[1] ) ||
- sts[0]->hTcxCfg->fIsTNSAllowed != sts[1]->hTcxCfg->fIsTNSAllowed )
- {
- individual_decision[0] = individual_decision[1] = 1;
- }
- else if ( bWhitenedDomain )
- {
- nSubframes = ( sts[0]->hTcxEnc->tcxMode == TCX_20 ) ? 1 : NB_DIV;
- for ( k = 0; k < nSubframes; k++ )
- {
- if ( sts[0]->hTcxEnc->bTnsOnWhithenedSpectra[k] != sts[1]->hTcxEnc->bTnsOnWhithenedSpectra[k] )
- {
- individual_decision[k] = 1;
- }
- }
- }
-
- /* framing equal, check for similar filters, if very similar (also indicator for and M signal),
- * use at least the same decision, maybe use the same filter
- */
- {
- int16_t isTCX10;
- isTCX10 = ( sts[0]->hTcxEnc->tcxMode == TCX_20 ) ? 0 : 1;
-
- nSubframes = ( sts[0]->hTcxEnc->tcxMode == TCX_20 ) ? 1 : NB_DIV;
-
- for ( k = 0; k < nSubframes; k++ )
- {
- if ( sts[0]->hTcxCfg->fIsTNSAllowed && individual_decision[k] != 1 && ( !bWhitenedDomain || sts[0]->hTcxEnc->bTnsOnWhithenedSpectra[k] ) )
- {
- float maxPredGain = -1.0f;
- 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 )];
-
-#ifdef DEBUGGING
- assert( sts[0]->hTcxCfg->pCurrentTnsConfig->nMaxFilters == sts[1]->hTcxCfg->pCurrentTnsConfig->nMaxFilters );
-#endif
- for ( iFilter = sts[0]->hTcxCfg->pCurrentTnsConfig->nMaxFilters - 1; iFilter >= 0; iFilter-- )
- {
- STnsFilter *pFilter[2];
- struct TnsParameters const *pTnsParameters[2];
- pFilter[0] = sts[0]->hTcxEnc->tnsData[k].filter + iFilter;
- pTnsParameters[0] = sts[0]->hTcxCfg->pCurrentTnsConfig->pTnsParameters + iFilter;
- pFilter[1] = sts[1]->hTcxEnc->tnsData[k].filter + iFilter;
- pTnsParameters[1] = sts[1]->hTcxCfg->pCurrentTnsConfig->pTnsParameters + iFilter;
-
-#ifdef DEBUGGING
- assert( pTnsParameters[0]->startLineFrequency == pTnsParameters[1]->startLineFrequency );
- assert( pTnsParameters[0]->nSubdivisions == pTnsParameters[1]->nSubdivisions );
-#endif
- /* if prediction gain and avgSqrCoef are both close we are pretty sure the filters are quite similar, use the avg of
- * both filters for the decision
- */
- meanPredictionGain = ( pFilter[0]->predictionGain + pFilter[1]->predictionGain ) * 0.5f;
- maxPredictionGain = max( maxPredictionGain, meanPredictionGain );
-
- if ( ( pFilter[0]->predictionGain > pTnsParameters[0]->minPredictionGain ) && ( sts[0]->element_brate < IVAS_80k ) &&
- ( pFilter[1]->predictionGain > pTnsParameters[1]->minPredictionGain ) && ( sts[0]->hTcxEnc->tnsData[k].nFilters == sts[1]->hTcxEnc->tnsData[k].nFilters ) )
- {
- pFilter[0]->predictionGain = pFilter[1]->predictionGain = meanPredictionGain; /* more TNS filter sync at 48kbps */
- }
- if ( ( fabs( pFilter[0]->predictionGain - pFilter[1]->predictionGain ) < SIMILAR_TNS_THRESHOLD * meanPredictionGain ) &&
- ( sts[0]->hTcxEnc->tnsData[k].nFilters == sts[1]->hTcxEnc->tnsData[k].nFilters ) )
- {
- float maxAvgSqrCoef = max( pFilter[0]->avgSqrCoef, pFilter[1]->avgSqrCoef );
- float meanLtpGain = ( sts[0]->hTcxEnc->tcxltp_gain + sts[1]->hTcxEnc->tcxltp_gain ) * 0.5f;
- maxPredGain = max( maxPredGain, meanPredictionGain );
- if ( ( meanPredictionGain > pTnsParameters[0]->minPredictionGain ) || ( maxAvgSqrCoef > pTnsParameters[0]->minAvgSqrCoef ) )
- {
- if ( sts[0]->hTcxEnc->tnsData[k].nFilters > 0 || sts[1]->hTcxEnc->tnsData[k].nFilters > 0 || isTCX10 || meanLtpGain < 0.6f )
- {
- ++sts[0]->hTcxEnc->tnsData[k].nFilters;
- pFilter[0]->filterType = TNS_FILTER_ON;
- ++sts[1]->hTcxEnc->tnsData[k].nFilters;
- pFilter[1]->filterType = TNS_FILTER_ON;
- }
- else
- {
- const float maxEnergyChange = ( GetTCXMaxenergyChange( sts[0]->hTranDet, isTCX10, NSUBBLOCKS, 3 ) + GetTCXMaxenergyChange( sts[1]->hTranDet, isTCX10, NSUBBLOCKS, 3 ) ) * 0.5f;
-
- if ( maxEnergyChange >= pTnsParameters[0]->minEnergyChange )
- {
- ++sts[0]->hTcxEnc->tnsData[k].nFilters;
- pFilter[0]->filterType = TNS_FILTER_ON;
- ++sts[1]->hTcxEnc->tnsData[k].nFilters;
- pFilter[1]->filterType = TNS_FILTER_ON;
- }
- else
- {
- pFilter[0]->filterType = TNS_FILTER_OFF;
- pFilter[1]->filterType = TNS_FILTER_OFF;
- }
- }
- }
- else if ( sts[0]->hTcxEnc->tnsData[k].nFilters > 0 && sts[1]->hTcxEnc->tnsData[k].nFilters > 0 ) /* If a previous filter is turned on */
- {
- 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;
- }
- else if ( sts[0]->hTcxEnc->tnsData[k].nFilters != sts[1]->hTcxEnc->tnsData[k].nFilters ) /* sanity check */
- {
- assert( 0 );
- }
- else
- {
- pFilter[0]->filterType = TNS_FILTER_OFF;
- pFilter[1]->filterType = TNS_FILTER_OFF;
- }
- if ( ( pFilter[0]->filterType == TNS_FILTER_ON ) && ( pFilter[1]->filterType == TNS_FILTER_ON ) && ( sts[0]->element_brate < IVAS_80k ) )
- {
- int16_t tmpIntValue = 0;
- int16_t tmpCoeff[TNS_MAX_FILTER_ORDER];
- int16_t i, maxOrder = max( pFilter[0]->order, pFilter[1]->order );
-
- set_s( tmpCoeff, 0, TNS_MAX_FILTER_ORDER );
- for ( i = 0; i < maxOrder; i++ )
- {
- tmpIntValue = (int16_t) max( tmpIntValue, abs( pFilter[0]->coefIndex[i] - pFilter[1]->coefIndex[i] ) );
- }
- if ( tmpIntValue == 1 ) /* the TNS coefficients are sufficiently similar to equalize the two filters */
- {
- for ( i = maxOrder - 1; i >= 0; i-- )
- {
- tmpCoeff[i] = ( abs( pFilter[0]->coefIndex[i] ) < abs( pFilter[1]->coefIndex[i] ) ? pFilter[0]->coefIndex[i] : pFilter[1]->coefIndex[i] );
- if ( ( tmpIntValue > 0 ) && ( tmpCoeff[i] == 0 ) )
- {
- maxOrder--;
- }
- else
- {
- tmpIntValue = 0;
- }
- }
- /* make sure that maxOrder is non zero and not all coefficients are zero (could happen in rare cases) */
- if ( maxOrder > 0 )
- {
- for ( i = TNS_MAX_FILTER_ORDER - 1; i >= 0; i-- )
- {
- pFilter[0]->coefIndex[i] = pFilter[1]->coefIndex[i] = tmpCoeff[i];
- }
-
- pFilter[0]->order = pFilter[1]->order = maxOrder;
- }
- }
- }
- }
- else
- {
- individual_decision[k] = 1;
- }
- }
-
- if ( individual_decision[k] == 0 )
- {
- sts[0]->hTcxEnc->fUseTns[k] = ( sts[0]->hTcxEnc->tnsData[k].nFilters > 0 ) ? 1 : 0;
- sts[1]->hTcxEnc->fUseTns[k] = ( sts[1]->hTcxEnc->tnsData[k].nFilters > 0 ) ? 1 : 0;
- }
- else
- {
- sts[0]->hTcxEnc->tnsData[k].nFilters = 0;
- sts[1]->hTcxEnc->tnsData[k].nFilters = 0;
- sts[0]->hTcxEnc->fUseTns[k] = 0;
- sts[1]->hTcxEnc->fUseTns[k] = 0;
- for ( iFilter = sts[0]->hTcxCfg->pCurrentTnsConfig->nMaxFilters - 1; iFilter >= 0; iFilter-- )
- {
- sts[0]->hTcxEnc->tnsData[k].filter[iFilter].filterType = TNS_FILTER_OFF;
- sts[1]->hTcxEnc->tnsData[k].filter[iFilter].filterType = TNS_FILTER_OFF;
- }
- }
-
- if ( !bWhitenedDomain && individual_decision[k] == 0 && maxPredGain < TNS_GAIN_THRESHOLD_FOR_WHITE && sts[0]->hTcxEnc->transform_type[k] != TCX_5 )
- {
- sts[0]->hTcxEnc->bTnsOnWhithenedSpectra[k] = 1;
- sts[1]->hTcxEnc->bTnsOnWhithenedSpectra[k] = 1;
- sts[0]->hTcxEnc->tnsData[k].nFilters = 0;
- sts[1]->hTcxEnc->tnsData[k].nFilters = 0;
- sts[0]->hTcxEnc->fUseTns[k] = 0;
- sts[1]->hTcxEnc->fUseTns[k] = 0;
- 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 );
- }
- }
- maxPredictionGain = max( maxPredictionGain, maxPredGain );
- }
- }
- }
- }
-
- /* individual decision for each channel */
- for ( ch = 0; ch < CPE_CHANNELS; ch++ )
- {
- if ( sts[ch]->mct_chan_mode == MCT_CHAN_MODE_IGNORE )
- {
- continue;
- }
-
- int16_t isTCX10;
- isTCX10 = ( sts[ch]->hTcxEnc->tcxMode == TCX_20 ) ? 0 : 1;
-
- nSubframes = ( sts[ch]->hTcxEnc->tcxMode == TCX_20 ) ? 1 : NB_DIV;
-
- for ( k = 0; k < nSubframes; k++ )
- {
- if ( sts[ch]->hTcxCfg->fIsTNSAllowed && ( individual_decision[k] || mct_on ) &&
- ( !bWhitenedDomain || sts[ch]->hTcxEnc->bTnsOnWhithenedSpectra[k] ) )
- {
- float maxPredGain = -1.0f;
-
- 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 = sts[ch]->hTcxCfg->pCurrentTnsConfig->nMaxFilters - 1; iFilter >= 0; iFilter-- )
- {
- STnsFilter *pFilter;
- const struct TnsParameters *pTnsParameters;
- pFilter = sts[ch]->hTcxEnc->tnsData[k].filter + iFilter;
- pTnsParameters = sts[ch]->hTcxCfg->pCurrentTnsConfig->pTnsParameters + iFilter;
- maxPredGain = max( maxPredGain, pFilter->predictionGain );
-
- if ( ( pFilter->predictionGain > pTnsParameters->minPredictionGain ) || ( pFilter->avgSqrCoef > pTnsParameters->minAvgSqrCoef ) )
- {
- if ( sts[ch]->hTcxEnc->tnsData[k].nFilters > 0 || isTCX10 || sts[ch]->hTcxEnc->tcxltp_gain < 0.6f )
- {
- ++sts[ch]->hTcxEnc->tnsData[k].nFilters;
- pFilter->filterType = TNS_FILTER_ON;
- }
- else
- {
- const float maxEnergyChange = GetTCXMaxenergyChange( sts[ch]->hTranDet, isTCX10, NSUBBLOCKS, 3 );
-
- if ( maxEnergyChange >= pTnsParameters->minEnergyChange )
- {
- ++sts[ch]->hTcxEnc->tnsData[k].nFilters;
- pFilter->filterType = TNS_FILTER_ON;
- }
- else
- {
- pFilter->filterType = TNS_FILTER_OFF;
- }
- }
- }
- else if ( sts[ch]->hTcxEnc->tnsData[k].nFilters > 0 ) /* If a previous filter is turned on */
- {
- pFilter->filterType = TNS_FILTER_ON_ZERO;
- ++sts[ch]->hTcxEnc->tnsData[k].nFilters;
- }
- else
- {
- pFilter->filterType = TNS_FILTER_OFF;
- }
- }
-
- sts[ch]->hTcxEnc->fUseTns[k] = ( sts[ch]->hTcxEnc->tnsData[k].nFilters > 0 ) ? 1 : 0;
-
- if ( !bWhitenedDomain && maxPredGain < TNS_GAIN_THRESHOLD_FOR_WHITE && sts[ch]->hTcxEnc->transform_type[k] != TCX_5 )
- {
- sts[ch]->hTcxEnc->fUseTns[k] = 0;
- sts[ch]->hTcxEnc->bTnsOnWhithenedSpectra[k] = 1;
- sts[ch]->hTcxEnc->tnsData[k].nFilters = 0;
- 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;
- }
- }
- maxPredictionGain = max( maxPredictionGain, maxPredGain );
- }
- }
- }
-
-
- /* we have the decision, set filter data accordingly */
- for ( ch = 0; ch < CPE_CHANNELS; ch++ )
- {
- if ( sts[ch]->mct_chan_mode == MCT_CHAN_MODE_IGNORE )
- {
- continue;
- }
-
- nSubframes = ( sts[ch]->hTcxEnc->tcxMode == TCX_20 ) ? 1 : NB_DIV;
-
- for ( k = 0; k < nSubframes; k++ )
- {
- if ( sts[ch]->hTcxCfg->fIsTNSAllowed && ( !bWhitenedDomain || sts[ch]->hTcxEnc->bTnsOnWhithenedSpectra[k] ) )
- {
- 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 = sts[ch]->hTcxCfg->pCurrentTnsConfig->nMaxFilters - 1; iFilter >= 0; iFilter-- )
- {
- STnsFilter *pFilter;
- pFilter = sts[ch]->hTcxEnc->tnsData[k].filter + iFilter;
- switch ( pFilter->filterType )
- {
- case TNS_FILTER_OFF:
- ClearTnsFilterCoefficients( sts[ch]->hTcxEnc->tnsData[k].filter + iFilter );
- break;
- case TNS_FILTER_ON_ZERO:
- /* Since TNS filter of order 0 is not allowed we have to signal in the stream filter of order 1 with the 0th coefficient equal to 0 */
- ClearTnsFilterCoefficients( pFilter );
- pFilter->order = 1;
- break;
- }
- }
- }
- }
- }
-
- /* Apply filters, loop over channels */
- for ( ch = 0; ch < CPE_CHANNELS; ch++ )
- {
- st = sts[ch];
- if ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE )
- {
- continue;
- }
-
- nSubframes = ( st->hTcxEnc->tcxMode == TCX_20 ) ? 1 : NB_DIV;
-
- for ( k = 0; k < nSubframes; k++ )
- {
- 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] )
- {
- int16_t equalFilterData = ( sts[0]->hTcxCfg->pCurrentTnsConfig->nMaxFilters == sts[1]->hTcxCfg->pCurrentTnsConfig->nMaxFilters &&
- sts[0]->hTcxEnc->bTnsOnWhithenedSpectra[k] == sts[1]->hTcxEnc->bTnsOnWhithenedSpectra[k] &&
- sts[0]->hTcxEnc->tnsData[k].nFilters == sts[1]->hTcxEnc->tnsData[k].nFilters )
- ? 1
- : 0;
- if ( equalFilterData )
- {
- for ( iFilter = st->hTcxCfg->pCurrentTnsConfig->nMaxFilters - 1; iFilter >= 0; iFilter-- )
- {
- const int16_t *pDataCh0 = (const int16_t *) &sts[0]->hTcxEnc->tnsData[k].filter[iFilter];
- const int16_t *pDataCh1 = (const int16_t *) &sts[1]->hTcxEnc->tnsData[k].filter[iFilter];
- int16_t i = 2 + TNS_MAX_FILTER_ORDER; /* excl. informative float data. Portable? */
-
- while ( ( i >= 0 ) && ( pDataCh0[i] == pDataCh1[i] ) )
- {
- i--;
- }
- if ( i >= 0 )
- {
- equalFilterData = 0;
- break;
- }
- }
- if ( equalFilterData )
- {
- st->hTcxEnc->tnsData[k].nFilters *= -1; /* signals common TNS */
- }
- }
- }
- if ( st->hTcxCfg->fIsTNSAllowed && ( !bWhitenedDomain || st->hTcxEnc->bTnsOnWhithenedSpectra[k] ) )
- {
- L_spec = st->hTcxCfg->pCurrentTnsConfig->iFilterBorders[0];
- spectrum = st->hTcxEnc->spectrum[k];
- /* If TNS should be used then get the residual after applying it inplace in the spectrum */
- if ( st->hTcxEnc->fUseTns[k] )
- {
- st->hTcxCfg->pCurrentTnsConfig = &st->hTcxCfg->tnsConfig[st->hTcxEnc->transform_type[k] == TCX_20][( k == 0 ) && ( st->last_core == ACELP_CORE )];
-
- ApplyTnsFilter( st->hTcxCfg->pCurrentTnsConfig, &st->hTcxEnc->tnsData[k], spectrum, 1 );
- }
-
- if ( st->hTcxEnc->transform_type[k] == TCX_5 )
- {
- tcx5TnsUngrouping( L_frame >> 2, L_spec >> 1, st->hTcxEnc->spectrum[k], ENC );
- }
-
- st->hTcxEnc->tnsData[k].tnsOnWhitenedSpectra = st->hTcxEnc->bTnsOnWhithenedSpectra[k];
-
- EncodeTnsData( st->hTcxCfg->pCurrentTnsConfig, &st->hTcxEnc->tnsData[k], param_core[ch] + k * NPRM_DIV + 1 + NOISE_FILL_RANGES + LTPSIZE, tnsSize[ch] + k, tnsBits[ch] + k );
- }
-
- if ( st->hTcxEnc->transform_type[k] == TCX_5 )
- {
- tcx5SpectrumInterleaving( st->hTcxCfg->tcx5SizeFB, st->hTcxEnc->spectrum[k] );
- tcx5SpectrumInterleaving( st->hTcxCfg->tcx5SizeFB, mdst_spectrum[ch][k] );
- }
- }
- }
-
- return;
-}
-
-
-#endif
void TNSAnalysis_fx(
TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */
Word16 L_frame, /* input: frame length */
@@ -1317,154 +837,6 @@ void ShapeSpectrum_ivas_fx(
}
}
-#ifdef ADD_IVAS_TNS
-/*-----------------------------------------------------------*
- * EstimateStereoTCXNoiseLevel()
- *
- * Estimate and quantize stereo noise factors
- *-----------------------------------------------------------*/
-
-void EstimateStereoTCXNoiseLevel(
- Encoder_State **sts, /* i : state handle */
- float *q_spectrum[CPE_CHANNELS][NB_DIV], /* i : quantized MDCT spectrum */
- float gain_tcx[][NB_DIV], /* i : global gain */
- int16_t L_frame[][NB_DIV], /* i : frame length */
- int16_t noiseFillingBorder[][NB_DIV], /* i : noise filling border */
- int16_t hm_active[][NB_DIV], /* i : flag indicating if the harmonic model is active */
- const int16_t ignore_chan[], /* i : flag indicating whether the channel should be ignored */
- float fac_ns[][NB_DIV], /* o : noise filling level */
- int16_t param_core[][NB_DIV * NPRM_DIV], /* o : quantized noise filling level */
- const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0) */
-)
-{
- int16_t ch, n;
- int16_t nSubframes, maxNfCalcBw, iStart, noiseTransWidth;
- float smooth_gain;
- float combined_q_spectrum[N_MAX];
- int16_t *fac_ns_q;
- int32_t total_brate;
-
- for ( ch = 0; ch < CPE_CHANNELS; ch++ )
- {
- Encoder_State *st = sts[ch];
- TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc;
-
- nSubframes = ( st->hTcxEnc->tcxMode == TCX_20 ) ? 1 : NB_DIV;
-
- if ( ignore_chan[ch] )
- {
- continue;
- }
- total_brate = ( st->element_mode == IVAS_CPE_MDCT && !MCT_flag ) ? st->element_brate : st->total_brate;
-
- for ( n = 0; n < nSubframes; n++ )
- {
- fac_ns_q = param_core[ch] + n * NPRM_DIV + 1;
- maxNfCalcBw = min( noiseFillingBorder[ch][n], (int16_t) ( hTcxEnc->measuredBwRatio * (float) L_frame[ch][n] + 0.5f ) );
- if ( ( total_brate >= HQ_96k && ( st->element_mode <= IVAS_SCE || st->bwidth < SWB ) ) || total_brate > IVAS_192k )
- {
- fac_ns[ch][n] = 0.0f;
- *fac_ns_q = 0;
- }
- else
- {
- iStart = L_frame[ch][n] / ( ( total_brate >= ACELP_13k20 && !st->rf_mode ) ? 6 : 8 ); /* noise filling start bin*/
-
- if ( n == 0 )
- {
- mvr2r( hTcxEnc->ltpGainMemory, &hTcxEnc->ltpGainMemory[1], N_LTP_GAIN_MEMS - 1 );
- hTcxEnc->ltpGainMemory[0] = st->hTcxEnc->tcxltp_gain;
- }
-
- smooth_gain = dotp( hTcxEnc->ltpGainMemory, nf_tw_smoothing_coeffs, N_LTP_GAIN_MEMS );
-
- noiseTransWidth = GetTransWidth( st->tcxonly, ( L_frame[ch][n] == st->L_frame >> 1 ), smooth_gain, ( st->hTcxCfg->ctx_hm && st->last_core != ACELP_CORE && hm_active[ch][n] ) );
-
- mvr2r( q_spectrum[ch][n], combined_q_spectrum, L_frame[ch][n] );
- tcx_noise_factor( hTcxEnc->spectrum[n], combined_q_spectrum, iStart, maxNfCalcBw, noiseTransWidth, L_frame[ch][n], gain_tcx[ch][n], hTcxEnc->noiseTiltFactor, &fac_ns[ch][n], fac_ns_q, st->element_mode );
-
- /* hysteresis for very tonal passages (more stationary noise filling level) */
- if ( *fac_ns_q == 1 )
- {
- hTcxEnc->noiseLevelMemory_cnt = (int16_t) min( INT16_MAX, 1 + abs( hTcxEnc->noiseLevelMemory_cnt ) ); /* update counter */
- }
- else
- {
- if ( ( *fac_ns_q == 2 ) && ( abs( hTcxEnc->noiseLevelMemory_cnt ) > 5 ) )
- {
- *fac_ns_q = 1; /* reduce noise filling level by one step */
- fac_ns[ch][n] = 0.75f / ( 1 << NBITS_NOISE_FILL_LEVEL );
-
- /* signal that noise level is changed by inverting sign of level memory */
- hTcxEnc->noiseLevelMemory_cnt = ( hTcxEnc->noiseLevelMemory_cnt < 0 ) ? 5 : -1 - hTcxEnc->noiseLevelMemory_cnt;
- }
- else
- {
- hTcxEnc->noiseLevelMemory_cnt = 0; /* reset memory since level is too different */
- }
- }
- } /* bitrate */
- }
-#ifdef DEBUG_MODE_MDCT
- dbgwrite( &smooth_gain, sizeof( float ), 1, 1, "./res/smooth_gain" );
- dbgwrite( &st->hTcxEnc->tcxltp_gain, sizeof( float ), 1, 1, "./res/tcxltp_gain" );
- dbgwrite( &noiseTransWidth, sizeof( int16_t ), 1, 1, "./res/noiseTrans" );
- dbgwrite( &fac_ns[ch][0], sizeof( float ), 2, 1, "./res/fac_ns" );
-#endif
- }
-
- return;
-}
-
-
-/*-----------------------------------------------------------*
- * DecideTonalSideInfo()
- *
- *
- *-----------------------------------------------------------*/
-
-static int16_t DecideTonalSideInfo(
- const float spectrum[],
- const int16_t L_frame_glob,
- float SFM2 )
-{
- float SFM, K, K2;
- int16_t Tonal_SideInfo;
-
- SFM = SFM_Cal( spectrum, min( 200, L_frame_glob ) );
-
- if ( L_frame_glob <= 256 )
- {
- K = 0.4f;
- K2 = 0.1f;
- }
- else if ( L_frame_glob == 320 || L_frame_glob == 512 )
- {
- K = 0.4f;
- K2 = 0.1f;
- }
- else /*FrameSize_Core == 640*/
- {
- K = 0.35f;
- K2 = 0.04f;
- }
-
-
- Tonal_SideInfo = 0;
- if ( SFM < K )
- {
- Tonal_SideInfo = 1;
- }
-
- if ( SFM2 < K2 )
- {
- Tonal_SideInfo = 1;
- }
-
- return Tonal_SideInfo;
-}
-#endif
-
/*-------------------------------------------------------------------*
* GetTransWidth()
*
@@ -5542,8 +4914,8 @@ void TNSAnalysisStereo_fx(
test();
test();
test();
- IF( GT_32( pFilter[0]->predictionGain32, L_shl_sat( L_deposit_h( pTnsParameters[0]->minPredictionGain ), sub( PRED_GAIN_E, pFilter[0]->predictionGain_e ) ) ) && LT_32( sts[0]->element_brate, IVAS_80k ) &&
- GT_32( pFilter[1]->predictionGain32, L_shl_sat( L_deposit_h( pTnsParameters[1]->minPredictionGain ), sub( PRED_GAIN_E, pFilter[1]->predictionGain_e ) ) ) && EQ_16( sts[0]->hTcxEnc->tnsData[k].nFilters, sts[1]->hTcxEnc->tnsData[k].nFilters ) )
+ IF( GT_32( pFilter[0]->predictionGain32, L_shl_sat( ( pTnsParameters[0]->minPredictionGain_32 ), sub( PRED_GAIN_E, pFilter[0]->predictionGain_e ) ) ) && LT_32( sts[0]->element_brate, IVAS_80k ) &&
+ GT_32( pFilter[1]->predictionGain32, L_shl_sat( ( pTnsParameters[1]->minPredictionGain_32 ), sub( PRED_GAIN_E, pFilter[1]->predictionGain_e ) ) ) && EQ_16( sts[0]->hTcxEnc->tnsData[k].nFilters, sts[1]->hTcxEnc->tnsData[k].nFilters ) )
{
pFilter[0]->predictionGain32 = pFilter[1]->predictionGain32 = meanPredictionGain_fx; /* more TNS filter sync at 48kbps */
move32();
@@ -5575,7 +4947,7 @@ void TNSAnalysisStereo_fx(
test();
test();
- IF( GT_32( meanPredictionGain_fx, L_shl_sat( L_deposit_h( pTnsParameters[0]->minPredictionGain ), sub( PRED_GAIN_E, meanPredictionGain_e ) ) ) || GT_16( maxAvgSqrCoef_fx, pTnsParameters[0]->minAvgSqrCoef ) )
+ IF( GT_32( meanPredictionGain_fx, L_shl_sat( ( pTnsParameters[0]->minPredictionGain_32 ), sub( PRED_GAIN_E, meanPredictionGain_e ) ) ) || GT_16( maxAvgSqrCoef_fx, pTnsParameters[0]->minAvgSqrCoef ) )
{
test();
test();
@@ -5873,7 +5245,7 @@ void TNSAnalysisStereo_fx(
}
test();
- IF( GT_32( pFilter->predictionGain32, L_shl_sat( L_deposit_h( pTnsParameters->minPredictionGain ), sub( PRED_GAIN_E, pFilter->predictionGain_e ) ) ) || GT_16( pFilter->avgSqrCoef, pTnsParameters->minAvgSqrCoef ) )
+ IF( GT_32( pFilter->predictionGain32, L_shl_sat( ( pTnsParameters->minPredictionGain_32 ), sub( PRED_GAIN_E, pFilter->predictionGain_e ) ) ) || GT_16( pFilter->avgSqrCoef, pTnsParameters->minAvgSqrCoef ) )
{
test();
test();
diff --git a/lib_enc/core_enc_init_fx.c b/lib_enc/core_enc_init_fx.c
index 05f838a3a9011ad9f854add5bc806c8f02fb962a..2f7870ab6e066e873ef432c68027ae6a763cffe3 100644
--- a/lib_enc/core_enc_init_fx.c
+++ b/lib_enc/core_enc_init_fx.c
@@ -53,15 +53,7 @@ void init_coder_ace_plus_fx(
/* Bitrate */
st->tcxonly = (Word8) getTcxonly(
-#ifdef IVAS_CODE_SWITCHING
- st->element_mode,
-#endif
- st->total_brate
-#ifdef IVAS_CODE_SWITCHING
- ,
- MCT_flag, st->is_ism_format
-#endif
- );
+ st->total_brate );
move16();
/* Core Sampling Rate */
diff --git a/lib_enc/core_enc_switch_fx.c b/lib_enc/core_enc_switch_fx.c
index 2f21f1015672d3762613434dc5f43bfbb5482074..fb5fd037a51694a3422381d0784d3368ed1f37e3 100644
--- a/lib_enc/core_enc_switch_fx.c
+++ b/lib_enc/core_enc_switch_fx.c
@@ -49,11 +49,7 @@ void core_coder_mode_switch_fx(
switchWB = 1; /*force init when coming from MODE1*/
}
-#ifdef IVAS_CODE_SWITCHING
- tcxonly_tmp = getTcxonly( st->element_mode, st->total_brate, MCT_flag, st->is_ism_format );
-#else
tcxonly_tmp = getTcxonly( st->total_brate );
-#endif
if ( NE_16( tcxonly_tmp, st->tcxonly ) )
{
@@ -71,11 +67,7 @@ void core_coder_mode_switch_fx(
move32();
st->L_frame = extract_l( Mult_32_16( st->sr_core, 0x0290 ) );
assert( st->L_frame == st->sr_core / 50 );
-#ifdef IVAS_CODE_SWITCHING
- st->tcxonly = getTcxonly( st->element_mode, st->total_brate, MCT_flag, st->is_ism_format );
-#else
st->tcxonly = (Word8) getTcxonly( st->total_brate );
-#endif
/* st->bits_frame_nominal = (int)( (float)st->L_frame/(float)st->fscale ) * (float)FSCALE_DENOM/128.0f * (float)st->bitrate/100.0f + 0.49f ; */
/* st->bits_frame_nominal = extract_l(L_shr(Mpy_32_16_1( L_shl(st->bitrate,8), mult_r(div_s(st->fscale, shl(st->L_frame,4)), FL2WORD16(FSCALE_DENOM/12800.f))), 6)); */
tmp32 = L_shl( st->total_brate, 1 ); /* (float)st->L_frame/(float)st->fscale * (float)FSCALE_DENOM/128.0f * (float)st->bitrate */
@@ -118,9 +110,6 @@ void core_coder_mode_switch_fx(
IF( st->hTcxCfg->fIsTNSAllowed != 0 )
{
InitTnsConfigs( st->bwidth, st->hTcxCfg->tcx_coded_lines, st->hTcxCfg->tnsConfig, st->hIGFEnc->infoStopFrequency, st->total_brate, st->element_mode, MCT_flag );
-#ifdef IVAS_CODE
- SetAllowTnsOnWhite( st->hTcxCfg->tnsConfig, EQ_16( st->element_mode, IVAS_CPE_MDCT ) );
-#endif
}
st->narrowBand = 0;
diff --git a/lib_enc/core_enc_updt_fx.c b/lib_enc/core_enc_updt_fx.c
index ce2681e75e3efa460b226285a570115043c4752a..dcf57738a2e71e29ffe3746110370d1aa4dbc5fa 100644
--- a/lib_enc/core_enc_updt_fx.c
+++ b/lib_enc/core_enc_updt_fx.c
@@ -48,20 +48,6 @@ void core_encode_update_fx( Encoder_State *st )
if ( hTcxEnc != NULL )
{
Copy( hTcxEnc->buf_speech_ltp + st->L_frame, hTcxEnc->buf_speech_ltp, n );
-
-#ifdef IVAS_CODE
- IF( NE_16( st->element_mode, IVAS_CPE_MDCT ) )
- {
- st->hTcxEnc->kernel_switch_corr_past = 0.f;
- st->hTcxEnc->kernel_type[0] = MDCT_IV;
- st->hTcxEnc->kernel_symmetry_past = 0;
- st->hTcxEnc->enc_ste_pre_corr_past = 0;
- move16();
- move16();
- move16();
- move16();
- }
-#endif
}
/* Update previous mode */
diff --git a/lib_enc/corr_xh_fx.c b/lib_enc/corr_xh_fx.c
index 51165d141e93973a92e5c45de7c4a803f7c80075..56b22c2069b96dd3ce2e6b283ebd2c5e7ccfb8ca 100644
--- a/lib_enc/corr_xh_fx.c
+++ b/lib_enc/corr_xh_fx.c
@@ -133,7 +133,7 @@ void corr_xh_ivas_fx(
const Word16 Qx,
Word16 dn[], /* o : correlation between x[] and h[] Qdn*/
Word16 *Qdn,
- const Word16 h[], /* i : impulse response (of weighted synthesis filter) (Q15 - norm_s(h[0]))*/
+ const Word16 h[], /* i : impulse response (of weighted synthesis filter) (Q14 - norm_s(h[0]))*/
const Word16 L_subfr /* i : length of the subframe Q0*/
)
{
@@ -152,16 +152,16 @@ void corr_xh_ivas_fx(
L_maxloc = L_deposit_l( 0 );
FOR( i = k; i < L_subfr; i += STEP )
{
- L_tmp = L_mac( 0, x[i], h[0] ); // Qx+(15 - norm_s(h[0]))
+ L_tmp = L_mac( 0, x[i], h[0] ); // Qx+(14 - norm_s(h[0])) + 1
FOR( j = i; j < L_subfr - 1; j++ )
{
- L_tmp = L_mac_o( L_tmp, x[j + 1], h[j + 1 - i], &Overflow ); // Qx+(15 - norm_s(h[0]))
+ L_tmp = L_mac_o( L_tmp, x[j + 1], h[j + 1 - i], &Overflow ); // Qx+(14 - norm_s(h[0])) + 1
}
- y32[i] = L_tmp; // Qx+(15 - norm_s(h[0]))
+ y32[i] = L_tmp; // Qx+(14 - norm_s(h[0])) + 1
move32();
L_tmp = L_abs( L_tmp );
- L_maxloc = L_max( L_tmp, L_maxloc ); // Qx+(15 - norm_s(h[0]))
+ L_maxloc = L_max( L_tmp, L_maxloc ); // Qx+(14 - norm_s(h[0])) +1
}
/* tot += 3*max / 8 */
L_maxloc = L_shr( L_maxloc, 2 );
@@ -176,11 +176,11 @@ void corr_xh_ivas_fx(
FOR( i = 0; i < L_subfr; i++ )
{
- dn[i] = round_fx( L_shl( y32[i], j ) ); // Qx+(15 - norm_s(h[0])) +j - 16
+ dn[i] = round_fx( L_shl( y32[i], j ) ); // Qx+(14 - norm_s(h[0])) + 1 +j - 16
move16();
}
- *Qdn = sub( add( add( Qx, sub( 15, norm_s( h[0] ) ) ), j ), 16 );
+ *Qdn = sub( add( add( Qx, add( sub( 14, norm_s( h[0] ) ), 1 ) ), j ), 16 );
move16();
return;
}
diff --git a/lib_enc/dtx_fx.c b/lib_enc/dtx_fx.c
index 6d8a297958fd614b8e44672ef8f64317dfb8ee45..7966fc7d890911da1911021957a5603e4a7bf973 100644
--- a/lib_enc/dtx_fx.c
+++ b/lib_enc/dtx_fx.c
@@ -95,7 +95,7 @@ void dtx_ivas_fx(
test();
test();
test();
- last_br_cng_flag = LE_32( st_fx->last_total_brate_cng, MAX_BRATE_DTX_EVS ) || LT_16( st_fx->lp_noise_fx, DTX_THR * 256 ) || ( EQ_16( st_fx->element_mode, IVAS_SCE ) && LE_32( st_fx->last_total_brate_cng, MAX_BRATE_DTX_IVAS ) );
+ last_br_cng_flag = LE_32( st_fx->last_total_brate_cng, MAX_BRATE_DTX_EVS ) || LT_32( ( st_fx->lp_noise_32fx ), DTX_THR * 16777216 ) || ( EQ_16( st_fx->element_mode, IVAS_SCE ) && LE_32( st_fx->last_total_brate_cng, MAX_BRATE_DTX_IVAS ) );
test();
test();
@@ -103,7 +103,7 @@ void dtx_ivas_fx(
last_br_flag = ( st_fx->element_mode == EVS_MONO && LE_32( st_fx->last_total_brate, MAX_BRATE_DTX_EVS ) ) ||
( st_fx->element_mode != EVS_MONO && LE_32( last_ivas_total_brate, MAX_BRATE_DTX_IVAS ) ) ||
- LT_16( st_fx->lp_noise_fx, DTX_THR * 256 );
+ LT_32( ( st_fx->lp_noise_32fx ), DTX_THR * 16777216 );
}
/* Initialization */
@@ -211,7 +211,7 @@ void dtx_ivas_fx(
test();
br_dtx_flag = ( ( st_fx->element_mode == EVS_MONO ) && LE_32( st_fx->total_brate, MAX_BRATE_DTX_EVS ) ) ||
( ( st_fx->element_mode != EVS_MONO ) && LE_32( ivas_total_brate, MAX_BRATE_DTX_IVAS ) ) ||
- LT_16( st_fx->lp_noise_fx, DTX_THR * 256 );
+ LT_16( extract_h( st_fx->lp_noise_32fx ), DTX_THR * 256 );
}
test();
test();
@@ -403,7 +403,7 @@ void dtx_ivas_fx(
st_fx->cng_type = FD_CNG;
move16();
}
- ELSE IF( EQ_16( st_fx->cng_type, FD_CNG ) && ( LT_32( st_fx->bckr_tilt_lt, fd_thresh ) ) && ( GT_16( st_fx->lp_noise_fx, 512 /* 2 in Q8 */ ) ) )
+ ELSE IF( EQ_16( st_fx->cng_type, FD_CNG ) && ( LT_32( st_fx->bckr_tilt_lt, fd_thresh ) ) && ( GT_32( st_fx->lp_noise_32fx, 67108864 /* 2 in Q24 */ ) ) )
{
st_fx->cng_type = LP_CNG;
move16();
diff --git a/lib_enc/enc_acelpx_fx.c b/lib_enc/enc_acelpx_fx.c
index 240f9859c84f2748e544432bf47a9ff619bfae59..1a17a0f9c2a7b1974c63f5e9aca4204e0dd86c40 100644
--- a/lib_enc/enc_acelpx_fx.c
+++ b/lib_enc/enc_acelpx_fx.c
@@ -623,7 +623,7 @@ void E_ACELP_4tsearchx_ivas_fx(
/* Init to avoid crash when the search does not find a solution */
FOR( k = 0; k < nb_pulse; k++ )
{
- codvec[k] = k;
+ codvec[k] = s_and( k, 3 );
move16();
}
diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c
index a60828a949891a4767b02d2859bb7a11373e08b5..da3555cdbc4f863ee2a67d857c16a478ab287b3e 100644
--- a/lib_enc/enc_gen_voic_fx.c
+++ b/lib_enc/enc_gen_voic_fx.c
@@ -363,20 +363,15 @@ void encod_gen_voic_fx(
exc_fx[i + i_subfr_fx] = round_fx_o( Ltmp, &Overflow ); /* Q0 */
}
}
+
/*-----------------------------------------------------------------*
* Prepare TBE excitation
*-----------------------------------------------------------------*/
-#ifdef REMOVE_EVS_DUPLICATES
- prep_tbe_exc_ivas_fx( L_frame, L_SUBFR, i_subfr_fx, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx,
- &voice_factors_fx[i_subfr_fx / L_SUBFR], bwe_exc_fx, gain_preQ_fx, code_preQ_fx, Q_new,
- T0_fx, T0_frac_fx, st_fx->coder_type, st_fx->core_brate,
- st_fx->element_mode, st_fx->idchan, st_fx->hBWE_TD != NULL, st_fx->tdm_LRTD_flag );
-#else
- prep_tbe_exc_fx( L_frame, i_subfr_fx, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx,
+ prep_tbe_exc_fx( L_frame, L_SUBFR, i_subfr_fx, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx,
&voice_factors_fx[i_subfr_fx / L_SUBFR], bwe_exc_fx, gain_preQ_fx, code_preQ_fx, Q_new,
- T0_fx, T0_frac_fx, st_fx->coder_type, st_fx->core_brate );
-#endif
+ T0_fx, T0_frac_fx, st_fx->coder_type, st_fx->core_brate,
+ st_fx->element_mode, st_fx->idchan, st_fx->hBWE_TD != NULL, st_fx->tdm_LRTD_flag );
/*-----------------------------------------------------------------*
* Synthesize speech to update mem_syn[].
@@ -405,9 +400,11 @@ void encod_gen_voic_fx(
hSC_VBR->prev_tilt_code_fx = hLPDmem->tilt_code; /* Q15 */
move16();
}
+
return;
}
+
void encod_gen_voic_ivas_fx(
Encoder_State *st_fx, /* i/o: state structure */
const Word16 speech_fx[], /* i : input speech Qnew -1 */
@@ -562,8 +559,8 @@ void encod_gen_voic_ivas_fx(
Copy( &res_fx[i_subfr_fx], &exc_fx[i_subfr_fx], L_SUBFR ); /*Q_new*/
- find_targets_ivas_new_fx( speech_fx, hLPDmem->mem_syn, i_subfr_fx, &hLPDmem->mem_w0, p_Aq_fx,
- res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx );
+ 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 );
q_h1 = sub( 14, norm_s( h1_fx[0] ) );
Copy_Scale_sig( h1_fx, h2_fx, L_SUBFR, sub( 11, q_h1 ) ); /*Q11*/
@@ -581,7 +578,7 @@ void encod_gen_voic_ivas_fx(
* Find adaptive exitation
*-----------------------------------------------------------------*/
- pred_lt4( &exc_fx[i_subfr_fx], &exc_fx[i_subfr_fx], T0_fx, T0_frac_fx, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ pred_lt4_ivas_fx( &exc_fx[i_subfr_fx], &exc_fx[i_subfr_fx], T0_fx, T0_frac_fx, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
/*-----------------------------------------------------------------*
* Gain clipping test to avoid unstable synthesis on frame erasure
@@ -763,10 +760,10 @@ void encod_gen_voic_ivas_fx(
* Prepare TBE excitation
*-----------------------------------------------------------------*/
- prep_tbe_exc_ivas_fx( L_frame, L_SUBFR, i_subfr_fx, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx,
- &voice_factors_fx[i_subfr_fx / L_SUBFR], bwe_exc_fx, gain_preQ_fx, code_preQ_fx, Q_new,
- T0_fx, T0_frac_fx, st_fx->coder_type, st_fx->core_brate,
- st_fx->element_mode, st_fx->idchan, st_fx->hBWE_TD != NULL, st_fx->tdm_LRTD_flag );
+ prep_tbe_exc_fx( L_frame, L_SUBFR, i_subfr_fx, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx,
+ &voice_factors_fx[i_subfr_fx / L_SUBFR], bwe_exc_fx, gain_preQ_fx, code_preQ_fx, Q_new,
+ T0_fx, T0_frac_fx, st_fx->coder_type, st_fx->core_brate,
+ st_fx->element_mode, st_fx->idchan, st_fx->hBWE_TD != NULL, st_fx->tdm_LRTD_flag );
/*-----------------------------------------------------------------*
* Synthesize speech to update mem_syn[].
diff --git a/lib_enc/enc_pit_exc_fx.c b/lib_enc/enc_pit_exc_fx.c
index 9180d73b823d3c0096b9548874617676c56baace..548e3f904125711e63a0fdd5b428049e7cafbb72 100644
--- a/lib_enc/enc_pit_exc_fx.c
+++ b/lib_enc/enc_pit_exc_fx.c
@@ -250,13 +250,8 @@ void enc_pit_exc_fx(
*----------------------------------------------------------------*/
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 ); /* Q13 */
Scale_sig( h1, L_subfr, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution */
@@ -726,8 +721,8 @@ void enc_pit_exc_ivas_fx(
Copy( &res[i_subfr], &exc[i_subfr], L_subfr ); /* Q_new */
/* condition on target (compared to float) has been put outside the loop */
- find_targets_ivas_new_fx( speech, hGSCEnc->mem_syn_tmp_fx, i_subfr, &hGSCEnc->mem_w0_tmp_fx, p_Aq,
- res, L_subfr, p_Aw, st_fx->preemph_fac, xn, cn, h1 );
+ 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 );
q_h1 = sub( 14, norm_s( h1[0] ) );
Copy_Scale_sig( h1, h2, L_subfr, sub( 11, q_h1 ) ); /*Q11*/
@@ -749,7 +744,7 @@ void enc_pit_exc_ivas_fx(
* Find adaptive exitation
*-----------------------------------------------------------------*/
- pred_lt4( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_subfr + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ pred_lt4_ivas_fx( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_subfr + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
/*-----------------------------------------------------------------*
* Gain clipping test to avoid unstable synthesis on frame erasure
* or in case of floating point encoder & fixed p. decoder
@@ -819,7 +814,7 @@ void enc_pit_exc_ivas_fx(
/*-----------------------------------------------------------------*
* Gain encoding
*-----------------------------------------------------------------*/
- gain_enc_mless_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, L_FRAME, i_subfr, -1, xn, y1, sub( shift_wsp, 1 ), y2, code, Es_pred,
+ gain_enc_mless_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, st_fx->L_frame, i_subfr, -1, xn, y1, sub( shift_wsp, 1 ), y2, code, Es_pred,
&gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, clip_gain );
}
gp_clip_test_gain_pit_fx( st_fx->element_mode, st_fx->core_brate, gain_pit, st_fx->clip_var_fx );
@@ -828,7 +823,7 @@ void enc_pit_exc_ivas_fx(
gcode16 = round_fx_sat( Lgcode );
IF( use_fcb != 0 )
{
- hLPDmem->tilt_code = est_tilt_ivas_fx( &exc[i_subfr], gain_pit, code, gain_code, &voice_fac, Q_new, L_SUBFR, 0 ); // Q15
+ 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
diff --git a/lib_enc/enc_tran_fx.c b/lib_enc/enc_tran_fx.c
index 394b22c3099bdde32fdaadc97f5e26bfa97f35fa..9802dc15b82071197c49514f3cfd2167ca4d2698 100644
--- a/lib_enc/enc_tran_fx.c
+++ b/lib_enc/enc_tran_fx.c
@@ -308,13 +308,8 @@ Word16 encod_tran_fx(
* Prepare TBE excitation
*-----------------------------------------------------------------*/
-#ifdef REMOVE_EVS_DUPLICATES
- prep_tbe_exc_ivas_fx( L_frame_fx, L_SUBFR, i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr / L_SUBFR],
- bwe_exc_fx, gain_preQ, code_preQ, Q_new, T0, T0_frac, st_fx->coder_type, st_fx->core_brate, st_fx->element_mode, st_fx->idchan, st_fx->hBWE_TD != NULL, st_fx->tdm_LRTD_flag );
-#else
- prep_tbe_exc_fx( L_frame_fx, i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr / L_SUBFR],
- bwe_exc_fx, gain_preQ, code_preQ, Q_new, T0, T0_frac, st_fx->coder_type, st_fx->core_brate );
-#endif
+ prep_tbe_exc_fx( L_frame_fx, L_SUBFR, i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr / L_SUBFR],
+ bwe_exc_fx, gain_preQ, code_preQ, Q_new, T0, T0_frac, st_fx->coder_type, st_fx->core_brate, st_fx->element_mode, st_fx->idchan, st_fx->hBWE_TD != NULL, st_fx->tdm_LRTD_flag );
/*-----------------------------------------------------------------*
* Synthesize speech to update mem_syn[].
@@ -545,6 +540,7 @@ Word16 encod_tran_ivas_fx(
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 );
@@ -555,6 +551,7 @@ Word16 encod_tran_ivas_fx(
#else
Scale_sig( h1, L_SUBFR, sub( 13, q_h1 ) );
#endif
+
/* scaling of xn[] to limit dynamic at 12 bits */
Scale_sig( xn, L_SUBFR, shift );
@@ -717,9 +714,9 @@ Word16 encod_tran_ivas_fx(
* Prepare TBE excitation
*-----------------------------------------------------------------*/
- prep_tbe_exc_ivas_fx( L_frame_fx, L_SUBFR, i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr / L_SUBFR],
- bwe_exc_fx, gain_preQ, code_preQ, Q_new, T0, T0_frac, st_fx->coder_type, st_fx->core_brate,
- st_fx->element_mode, st_fx->idchan, st_fx->hBWE_TD != NULL, st_fx->tdm_LRTD_flag );
+ prep_tbe_exc_fx( L_frame_fx, L_SUBFR, i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr / L_SUBFR],
+ bwe_exc_fx, gain_preQ, code_preQ, Q_new, T0, T0_frac, st_fx->coder_type, st_fx->core_brate,
+ st_fx->element_mode, st_fx->idchan, st_fx->hBWE_TD != NULL, st_fx->tdm_LRTD_flag );
/*-----------------------------------------------------------------*
* Synthesize speech to update mem_syn[].
diff --git a/lib_enc/enc_uv_fx.c b/lib_enc/enc_uv_fx.c
index a8612725b3a71575342f9197aeda467f235b75ad..887b4afb89415cb4b620ecf726a04924a72a21c9 100644
--- a/lib_enc/enc_uv_fx.c
+++ b/lib_enc/enc_uv_fx.c
@@ -358,7 +358,7 @@ void encod_unvoiced_ivas_fx(
// E_ACELP_innovative_codebook_fx( exc_fx, *pt_pitch_fx, 0, 1, gain_pit_fx, hLPDmem->tilt_code, acelp_cfg, i_subfr, p_Aq_fx, h1_fx, xn_fx, cn_fx, y1, y2_fx, (Word8) st_fx->acelp_autocorr, &prm, code_fx, shift, st_fx->L_frame, st_fx->last_L_frame, st_fx->total_brate, st_fx->element_mode );
inov_encode_ivas_fx( st_fx, st_fx->core_brate, 0, L_FRAME, st_fx->last_L_frame,
- UNVOICED, st_fx->bwidth, st_fx->sharpFlag, i_subfr, -1, p_Aq_fx,
+ UNVOICED, st_fx->bwidth, 1, i_subfr, -1, p_Aq_fx,
gain_pit_fx, cn_fx, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch_fx, xn_fx, code_fx, y2_fx, &unbits_PI, L_SUBFR, shift, Q_new );
E_ACELP_xy2_corr( xn_fx, y1, y2_fx, &g_corr, L_SUBFR, Q_xn );
diff --git a/lib_enc/evs_enc_fx.c b/lib_enc/evs_enc_fx.c
index 396e97c6fa5adf5d01e3b2bd3b6ebcd39dd0fbfc..8e9a82378ad94cb3d5046e9e4943f57a63ef1be7 100644
--- a/lib_enc/evs_enc_fx.c
+++ b/lib_enc/evs_enc_fx.c
@@ -169,18 +169,6 @@ ivas_error evs_enc_fx(
{
updt_IO_switch_enc_fx( st, input_frame );
set16_fx( hBWE_TD->old_speech_shb_fx, 0, L_LOOK_16k + L_SUBFR16k );
-#if defined IVAS_CODE
- PMT( "find scaling factor for prev_enr_EnvSHBres, prev_pow_exc16kWhtnd and prev_mix_factor " )
- set16_fx( st->hBWE_TD->old_speech_shb, 0, L_LOOK_16k + L_SUBFR16k );
- set16_fx( st->hBWE_TD->mem_shb_res, 0, MAX_LEN_MA_FILTER );
- set16_fx( st->hBWE_TD->old_EnvSHBres, 0, L_FRAME4k );
- st->hBWE_TD->old_mean_EnvSHBres = 0;
- st->hBWE_TD->prev_enr_EnvSHBres = 1.0f;
- st->hBWE_TD->prev_shb_env_tilt = 0;
- st->hBWE_TD->prev_pow_exc16kWhtnd = 1.0f;
- st->hBWE_TD->prev_mix_factor = 1.0f;
- st->hBWE_TD->prev_Env_error = 0;
-#endif
cldfb_reset_memory( st->cldfbAnaEnc );
cldfb_reset_memory( st->cldfbSynTd );
}
@@ -281,7 +269,7 @@ ivas_error evs_enc_fx(
IF( EQ_16( st->core, ACELP_CORE ) )
{
acelp_core_enc_fx( st, inp, ener, A, Aw, epsP_h, epsP_l, lsp_new, lsp_mid, vad_hover_flag,
- attack_flag, bwe_exc_extended, voice_factors, old_syn_12k8_16k, pitch_buf, &unbits, NULL, NULL, Q_new, shift );
+ attack_flag, bwe_exc_extended, voice_factors, old_syn_12k8_16k, pitch_buf, &unbits, NULL, Q_new, shift );
}
/*---------------------------------------------------------------------*
* HQ core encoding
@@ -466,16 +454,6 @@ ivas_error evs_enc_fx(
{
set16_fx( hBWE_TD->old_speech_shb_fx, 0, L_LOOK_16k + L_SUBFR16k );
set16_fx( shb_speech, 0, L_FRAME16k );
-#if defined IVAS_CODE
- set_f( st->hBWE_TD->mem_shb_res, 0.0f, MAX_LEN_MA_FILTER );
- set_f( st->hBWE_TD->old_EnvSHBres, 0.0f, L_FRAME4k );
- st->hBWE_TD->old_mean_EnvSHBres = 0.0f;
- st->hBWE_TD->prev_enr_EnvSHBres = 1.0f;
- st->hBWE_TD->prev_shb_env_tilt = 0.0f;
- st->hBWE_TD->prev_pow_exc16kWhtnd = 1.0f;
- st->hBWE_TD->prev_mix_factor = 1.0f;
- st->hBWE_TD->prev_Env_error = 0.0f;
-#endif
}
/* SWB TBE encoder */
diff --git a/lib_enc/ext_sig_ana_fx.c b/lib_enc/ext_sig_ana_fx.c
index eeeb294b43d27f31ba81ee9e8dfed11486645184..49d757be3054aaa7a7b2b829c14c21553ba46a77 100644
--- a/lib_enc/ext_sig_ana_fx.c
+++ b/lib_enc/ext_sig_ana_fx.c
@@ -70,24 +70,12 @@ void core_signal_analysis_high_bitrate_fx(
Word32 *tmpP32;
Word16 Q_exp;
-#ifdef IVAS_CODE
- int16_t disable_ltp = 0;
-#endif
TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc;
-#ifndef IVAS_CODE
/* dummy */
(void) vad_hover_flag;
(void) last_element_mode;
-#endif
-#ifdef IVAS_CODE
- if ( NE_16( last_element_mode, st->element_mode ) )
- {
- disable_ltp = 1; /* disable TCX-LTP in stereo switching to avoid discontinuities in synthesis */
- move16();
- }
-#endif
left_overlap = -1;
move16();
right_overlap = -1;
@@ -300,15 +288,6 @@ void core_signal_analysis_high_bitrate_fx(
WindowSignal( st->hTcxCfg, st->hTcxCfg->tcx_offsetFB, overlap_mode[frameno],
overlap_mode[frameno + 1], &left_overlap, &right_overlap, &hTcxEnc->speech_TCX[frameno * tcx10SizeFB],
&L_subframe, tcx20Win, st->element_mode != IVAS_CPE_MDCT /* truncate_aldo */, 1 );
-#ifdef IVAS_CODE
- 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 );
- windowed_samples[frameno * L_FRAME_MAX + 0] = (float) overlap_mode[frameno];
- windowed_samples[frameno * L_FRAME_MAX + 1] = (float) overlap_mode[frameno + 1];
- mvr2r( tcx20Win, windowed_samples + frameno * L_FRAME_MAX + 2, L_subframe + ( left_overlap + right_overlap ) / 2 );
- }
-#endif
}
IF( EQ_16( transform_type[frameno], TCX_5 ) )
@@ -321,15 +300,6 @@ void core_signal_analysis_high_bitrate_fx(
tcx20Win[folding_offset + i] = sub_sat( tcx20Win[folding_offset + i], tcx20Win[folding_offset - 1 - i] ); // Q0
move16();
}
-#ifdef IVAS_CODE
- if ( st->element_mode == IVAS_CPE_MDCT && frameno == 0 && overlap_mode[0] == FULL_OVERLAP && L_subframe - left_overlap > minWindowLen )
- {
- for ( i = minWindowLen; i >= 0; i-- ) /* outer left folding of shortened long ALDO slope */
- {
- tcx20Win[left_overlap + i] -= hTcxEnc->speech_TCX[-1 - i] * st->hTcxCfg->tcx_aldo_window_1_FB[left_overlap / 2 + minWindowLen - i] * st->hTcxCfg->tcx_mdct_window_minimumFB[minWindowLen - i];
- }
- }
-#endif
/* Outter right folding */
tmp = shr( right_overlap, 1 );
FOR( i = 0; i < tmp; i++ )
@@ -365,13 +335,6 @@ void core_signal_analysis_high_bitrate_fx(
tmpP16 += tcx5SizeFB;
tmpP32 += tcx5SizeFB;
-#ifdef IVAS_CODE
- /* high-band gain control in case of BWS */
- if ( st->bwidth_sw_cnt > 0 )
- {
- v_multc( hTcxEnc->spectrum[frameno] + i * tcx5SizeFB + L_FRAME16k / ( 2 * nSubframes ), (float) ( st->bwidth_sw_cnt ) / (float) BWS_TRAN_PERIOD, hTcxEnc->spectrum[frameno] + i * tcx5SizeFB + L_FRAME16k / ( 2 * nSubframes ), L_subframe - L_FRAME16k / ( 2 * nSubframes ) );
- }
-#endif
}
}
ELSE /* transform_type[frameno] != TCX_5 */
@@ -414,33 +377,12 @@ void core_signal_analysis_high_bitrate_fx(
}
ELSE
{
-#ifdef IVAS_CODE
- if ( st->element_mode == IVAS_CPE_MDCT && frameno == 0 && transform_type[0] == TCX_10 && overlap_mode[0] == FULL_OVERLAP && L_subframe - left_overlap > minWindowLen )
- {
- for ( i = minWindowLen; i >= 0; i-- ) /* outer left folding of shortened long ALDO slope */
- {
- tcx20Win[left_overlap + i] -= hTcxEnc->speech_TCX[-1 - i] * st->hTcxCfg->tcx_aldo_window_1_FB[left_overlap / 2 + minWindowLen - i] * st->hTcxCfg->tcx_mdct_window_minimumFB[minWindowLen - i];
- }
- }
-#endif
TCX_MDCT( tcx20Win, spectrum[frameno], &spectrum_e[frameno], left_overlap, sub( L_subframe, shr( add( left_overlap, right_overlap ), 1 ) ), right_overlap, st->element_mode );
}
/* For TCX20 at bitrates up to 64 kbps we need the power spectrum */
/* high-band gain control in case of BWS */
-#ifdef IVAS_CODE
- if ( st->bwidth_sw_cnt > 0 )
- {
- v_multc( hTcxEnc->spectrum[frameno] + L_FRAME16k / nSubframes, (float) ( st->bwidth_sw_cnt ) / (float) BWS_TRAN_PERIOD, hTcxEnc->spectrum[frameno] + L_FRAME16k / nSubframes, L_subframe - L_FRAME16k / nSubframes );
- }
-
- if ( st->mct_chan_mode == MCT_CHAN_MODE_LFE )
- {
- set_f( &hTcxEnc->spectrum[frameno][MCT_LFE_MAX_LINE], 0.f, L_subframe - MCT_LFE_MAX_LINE );
- st->hTcxCfg->tcx_coded_lines = MCT_LFE_MAX_LINE;
- }
-#endif
IF( NE_16( st->element_mode, IVAS_CPE_MDCT ) )
{
test();
@@ -461,94 +403,6 @@ void core_signal_analysis_high_bitrate_fx(
pMdstWin, powerSpec, &powerSpec_e );
}
}
-#ifdef IVAS_CODE
- if ( st->element_mode == IVAS_CPE_MDCT )
- {
- L_subframe = L_frameTCX / nSubframes;
-
- if ( transform_type[frameno] == TCX_20 && st->hTcxCfg->tcx_last_overlap_mode != TRANSITION_OVERLAP && st->mct_chan_mode != MCT_CHAN_MODE_LFE )
- {
- wtda_ext( hTcxEnc->new_speech_TCX, mdstWin, overlap_mode[frameno], overlap_mode[frameno + 1], L_frameTCX, 3 );
- }
- else
- {
- /* Windowing for the MDST */
- 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, 0, 1 );
- }
-
- if ( transform_type[frameno] == TCX_5 )
- {
- /* Outer left folding */
- for ( i = 0; i < left_overlap / 2; i++ )
- {
- mdstWin[left_overlap / 2 + i] += mdstWin[left_overlap / 2 - 1 - i];
- }
-
- if ( frameno == 0 && overlap_mode[0] == FULL_OVERLAP && L_subframe - left_overlap > minWindowLen )
- {
- for ( i = minWindowLen; i >= 0; i-- ) /* outer left folding of shortened long ALDO slope */
- {
- mdstWin[left_overlap + i] += hTcxEnc->speech_TCX[-1 - i] * st->hTcxCfg->tcx_aldo_window_1_FB[left_overlap / 2 + minWindowLen - i] * st->hTcxCfg->tcx_mdct_window_minimumFB[minWindowLen - i];
- }
- }
-
- /* Outer right folding */
- for ( i = 0; i < right_overlap / 2; i++ )
- {
- mdstWin[L_subframe + left_overlap / 2 - 1 - i] -= mdstWin[L_subframe + left_overlap / 2 + i];
- }
-
- /* 2xTCX5 */
- L_subframe = tcx5SizeFB;
- folding_offset = left_overlap / 2;
-
- for ( i = 0; i < 2; i++ )
- {
- assert( st->mct_chan_mode != MCT_CHAN_MODE_LFE );
- WindowSignal( st->hTcxCfg, folding_offset, i == 0 ? RECTANGULAR_OVERLAP : MIN_OVERLAP, i == 1 ? RECTANGULAR_OVERLAP : MIN_OVERLAP, &left_overlap, &right_overlap, mdstWin + i * tcx5SizeFB, &L_subframe, tcx5Win, 0, 1 );
-
- TCX_MDST( tcx5Win, mdst_spectrum[frameno] + i * tcx5SizeFB, left_overlap, L_subframe - ( left_overlap + right_overlap ) / 2, right_overlap, st->element_mode );
- /* high-band gain control in case of BWS */
- if ( st->bwidth_sw_cnt > 0 )
- {
- v_multc( mdst_spectrum[frameno] + i * tcx5SizeFB + L_FRAME16k / ( 2 * nSubframes ), (float) ( st->bwidth_sw_cnt ) / (float) BWS_TRAN_PERIOD, mdst_spectrum[frameno] + i * tcx5SizeFB + L_FRAME16k / ( 2 * nSubframes ), L_subframe - L_FRAME16k / ( 2 * nSubframes ) );
- }
- }
- }
- else /* transform_type[frameno] != TCX_5 */
- {
- if ( transform_type[frameno] == TCX_20 && st->hTcxCfg->tcx_last_overlap_mode != TRANSITION_OVERLAP && st->mct_chan_mode != MCT_CHAN_MODE_LFE )
- {
- edst( mdstWin, mdst_spectrum[frameno], L_subframe, st->element_mode );
-
- v_multc( mdst_spectrum[frameno], (float) sqrt( (float) NORM_MDCT_FACTOR / L_subframe ), mdst_spectrum[frameno], L_subframe );
- }
- else
- {
- if ( frameno == 0 && transform_type[0] == TCX_10 && overlap_mode[0] == FULL_OVERLAP && L_subframe - left_overlap > minWindowLen )
- {
- for ( i = minWindowLen; i >= 0; i-- ) /* outer left folding of shortened long ALDO slope */
- {
- mdstWin[left_overlap + i] += hTcxEnc->speech_TCX[-1 - i] * st->hTcxCfg->tcx_aldo_window_1_FB[left_overlap / 2 + minWindowLen - i] * st->hTcxCfg->tcx_mdct_window_minimumFB[minWindowLen - i];
- }
- }
-
- TCX_MDST( mdstWin, mdst_spectrum[frameno], left_overlap, L_subframe - ( left_overlap + right_overlap ) / 2, right_overlap, st->element_mode );
- }
-
- /* high-band gain control in case of BWS */
- if ( st->bwidth_sw_cnt > 0 )
- {
- v_multc( mdst_spectrum[frameno] + L_FRAME16k / nSubframes, (float) ( st->bwidth_sw_cnt ) / (float) BWS_TRAN_PERIOD, mdst_spectrum[frameno] + L_FRAME16k / nSubframes, L_subframe - L_FRAME16k / nSubframes );
- }
- }
-
- if ( st->mct_chan_mode == MCT_CHAN_MODE_LFE )
- {
- set_f( &mdst_spectrum[frameno][MCT_LFE_MAX_LINE], 0.f, L_subframe - MCT_LFE_MAX_LINE );
- }
- }
-#endif
}
IF( NE_16( st->element_mode, IVAS_CPE_MDCT ) )
@@ -559,9 +413,6 @@ void core_signal_analysis_high_bitrate_fx(
st->hTcxCfg->tcx_coded_lines,
transform_type[frameno], ( frameno == 0 ) && ( st->last_core == ACELP_CORE ),
spectrum[frameno], &hTcxEnc->tnsData[frameno], &hTcxEnc->fUseTns[frameno], NULL );
-#ifdef IVAS_CODE
- IF( st->hTcxCfg->fIsTNSAllowed )
-#endif
{
EncodeTnsData_fx( st->hTcxCfg->pCurrentTnsConfig, &hTcxEnc->tnsData[frameno],
param_core + frameno * NPRM_DIV + 1 + NOISE_FILL_RANGES + LTPSIZE, pTnsSize + frameno, pTnsBits + frameno );
@@ -583,9 +434,6 @@ void core_signal_analysis_high_bitrate_fx(
* LPC analysis
*---------------------------------------------------------------*/
-#ifdef IVAS_CODE
- IF( st->tcxonly )
-#endif
{
HBAutocorrelation_fx( st->hTcxCfg, lpc_left_overlap_mode, lpc_right_overlap_mode, &st->speech_enc_pe[frameno * tcx10Size],
shr( L_frame, sub( nSubframes, 1 ) ), r, M );
diff --git a/lib_enc/fd_cng_enc_fx.c b/lib_enc/fd_cng_enc_fx.c
index a7339e65334a0964eaeecdfd2a4fa1c3c9a35a9a..9298c863481ba068e9933d1d90336774fe3d47c6 100644
--- a/lib_enc/fd_cng_enc_fx.c
+++ b/lib_enc/fd_cng_enc_fx.c
@@ -130,8 +130,10 @@ void initFdCngEnc_fx(
move16();
set16_fx( hsEnc->msLogPeriodog_fx, 0, NPART );
set16_fx( hsEnc->msLogNoiseEst_fx, 0, NPART );
+ set32_fx( hsEnc->msLogNoiseEst_32fx, 0, NPART );
set16_fx( hsEnc->msPsd_fx, 0, NPART );
set16_fx( hsEnc->msNoiseFloor_fx, 0, NPART );
+ set32_fx( hsEnc->msNoiseFloor_32fx, 0, NPART );
set32_fx( hsEnc->msMinBuf_fx, 2147483647l /*1.0 Q31*/, MSNUMSUBFR * NPART );
set32_fx( hsEnc->msCurrentMin_fx, 2147483647l /*1.0 Q31*/, NPART );
set32_fx( hsEnc->msCurrentMinOut_fx, 2147483647l /*1.0 Q31*/, NPART );
@@ -445,8 +447,16 @@ 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 ); // Q8
- st->last_totalNoise_fx = hNoiseEst->totalNoise_fx; // Q8
+ IF( EQ_16( st->element_mode, EVS_MONO ) )
+ {
+ totalNoiseIncrease = sub( hNoiseEst->totalNoise_fx, st->last_totalNoise_fx ); // Q8
+ st->last_totalNoise_fx = hNoiseEst->totalNoise_fx; // Q8
+ }
+ ELSE
+ {
+ totalNoiseIncrease = sub( extract_h( hNoiseEst->totalNoise_32fx ), st->last_totalNoise_fx ); // Q8
+ st->last_totalNoise_fx = extract_h( hNoiseEst->totalNoise_32fx ); // Q8
+ }
move16();
IF( totalNoiseIncrease > 0 )
{
@@ -2240,12 +2250,12 @@ void perform_noise_estimation_enc_ivas_fx(
Word16 nCLDFBpart = hFdCngEnc->hFdCngCom->nCLDFBpart; /* Q0 */
move16();
- Word16 *psize = hFdCngEnc->hFdCngCom->psize; // 6Q9
+ Word16 *psize_norm = hFdCngEnc->hFdCngCom->psize_norm; // 6Q9
Word32 *msPeriodog_fx = hFdCngEnc->msPeriodog_fx;
Word32 *msNoiseEst_fx = hFdCngEnc->msNoiseEst_fx; /* exp(msNoiseEst_fx_exp) */
Word16 *msLogPeriodog_fx = hFdCngEnc->msLogPeriodog_fx;
- Word16 *msLogNoiseEst_fx = hFdCngEnc->msLogNoiseEst_fx;
+ Word32 *msLogNoiseEst_fx = hFdCngEnc->msLogNoiseEst_32fx;
Word32 scaleEB_fx = 0;
move32();
@@ -2387,12 +2397,12 @@ void perform_noise_estimation_enc_ivas_fx(
/* Call the minimum statistics routine for noise estimation */
- minimum_statistics_fx( npart, nFFTpart, psize, msLogPeriodog_fx, hFdCngEnc->msNoiseFloor_fx, msLogNoiseEst_fx, hFdCngEnc->msAlpha_fx, hFdCngEnc->msPsd_fx, hFdCngEnc->msPsdFirstMoment_fx,
+ minimum_statistics_fx( npart, nFFTpart, psize_norm, msLogPeriodog_fx, hFdCngEnc->msNoiseFloor_32fx, msLogNoiseEst_fx, hFdCngEnc->msAlpha_fx, hFdCngEnc->msPsd_fx, hFdCngEnc->msPsdFirstMoment_fx,
hFdCngEnc->msPsdSecondMoment_fx, hFdCngEnc->msMinBuf_fx, hFdCngEnc->msBminWin_fx, hFdCngEnc->msBminSubWin_fx, hFdCngEnc->msCurrentMin_fx, hFdCngEnc->msCurrentMinOut_fx, hFdCngEnc->msCurrentMinSubWindow_fx, hFdCngEnc->msLocalMinFlag, hFdCngEnc->msNewMinFlag, hFdCngEnc->msPeriodogBuf_fx, &( hFdCngEnc->msPeriodogBufPtr ), hFdCngEnc->hFdCngCom,
ENC, ( hCPE == NULL ) ? 0 : hCPE->element_mode );
/* Expand MS outputs */
- expand_range( msLogNoiseEst_fx, msNoiseEst_fx, &hFdCngEnc->msNoiseEst_fx_exp, hFdCngEnc->hFdCngCom->npart );
+ expand_range_fx( msLogNoiseEst_fx, msNoiseEst_fx, &hFdCngEnc->msNoiseEst_fx_exp, hFdCngEnc->hFdCngCom->npart );
return;
}
diff --git a/lib_enc/find_tar_fx.c b/lib_enc/find_tar_fx.c
index 4f24ec39f89d0468e5fead4014926f6e8497bf5f..989f309d2f2a5ee0305103ec476bc9ca9416ba80 100644
--- a/lib_enc/find_tar_fx.c
+++ b/lib_enc/find_tar_fx.c
@@ -173,141 +173,6 @@ void find_targets_ivas_fx(
Word16 *cn, /* o : target vector in residual domain Q_new*/
Word16 *h1 /* o : impulse response of weighted synthesis filter Q(14 - norm_s(h1[0]))*/
)
-{
- Word16 i;
- Word16 temp[M + 6 * L_SUBFR]; /* error of quantization */
- Word16 scale, scaleq, j, d, s, s2, tmp;
- Word16 Aqs[M + 1];
- Word32 h1_32[6 * L_SUBFR];
- Word16 sf;
- Word64 Ltmp64;
-#ifdef BASOP_NOGLOB_DECLARE_LOCAL
- Flag Overflow = 0;
- move16();
-#endif
- /*------------------------------------------------------------------------*
- * Find the target vector for excitation search:
- *
- * |------| res[n]
- * speech[n]---| A(z) |--------
- * |------| | |--------| error[n] |------|
- * zero -- (-)--| 1/A(z) |-----------| W(z) |-- target
- * exc |--------| |------|
- *
- * Instead of subtracting the zero-input response of filters from
- * the weighted input speech, the above configuration is used to
- * compute the target vector.
- *-----------------------------------------------------------------------*/
- FOR( i = 0; i < M; i++ )
- {
- temp[i] = sub_sat( speech[i + i_subfr - M], mem_syn[i] ); /* Q_new - 1 */
- move16();
- }
- Scale_sig( temp, M, 1 ); // scaling to make belong function output alligned //Qnew
-
- syn_filt_fx( 0, p_Aq, M, &res[i_subfr], temp + M, L_subfr, temp, 0 );
-
- Residu3_fx( Ap, temp + M, xn, L_subfr, 0 ); /* xn in Q_new */
-
- deemph_fx( xn, tilt_fac, L_subfr, mem_w0 ); /* xn in Q_new */
-
- *mem_w0 = shr( *mem_w0, 1 ); // Q_new - 1
-
- /*-----------------------------------------------------------------*
- * Find target in residual domain (cn[]) for innovation search
- *--------------------------------------------------------------*/
- IF( cn != NULL )
- {
- /* first half: xn[] --> cn[] */
- temp[0] = 0;
- move16();
- preemph_copy_fx( xn, cn, tilt_fac, shr( L_subfr, 1 ), temp );
- syn_filt_s_lc_fx( 1, Ap, cn, temp, shr( L_subfr, 1 ) ); /* Q_new -> Q_new - 1 */
- Residu3_lc_fx( p_Aq, M, temp, cn, shr( L_subfr, 1 ), 1 ); /* Q_new - 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 ) ); /* Q_new */
- }
- scale_sig( xn, L_subfr, -1 ); // Q_new - 1
-
- /*---------------------------------------------------------------*
- * Compute impulse response, h1[], of weighted synthesis filter *
- *---------------------------------------------------------------*/
-
- scale = norm_s( Ap[0] );
- scaleq = norm_s( p_Aq[0] );
- d = sub( scaleq, scale );
- IF( d >= 0 )
- {
- Copy( p_Aq, Aqs, M + 1 ); /* Q12 */
- s = add( scaleq, 1 );
- s2 = shr( 16384, d );
- }
- ELSE
- {
- Copy_Scale_sig( p_Aq, Aqs, M + 1, d ); /* Q12 */
- s = add( scale, 1 );
- s2 = 16384;
- move16();
- }
-
- set32_fx( h1_32, 0, L_subfr );
- Overflow = 0;
- move16();
- FOR( i = 0; i < M; i++ )
- {
- Ltmp64 = W_mult_16_16( Ap[i], s2 ); /* Q27 */
- FOR( j = 1; j <= i; j++ )
- {
- Ltmp64 = W_msu_16_16( Ltmp64, Aqs[j], extract_h( L_shl_o( h1_32[i - j], s, &Overflow ) ) ); /* Q27 */
- }
- h1_32[i] = W_extract_l( Ltmp64 ); /* Q27 */
- move32();
- }
-
- Ltmp64 = W_mult_16_16( Ap[i], s2 ); /* Q27 */
- FOR( j = 1; j <= M; j++ )
- {
- Ltmp64 = W_msu_16_16( Ltmp64, Aqs[j], extract_h( L_shl_o( h1_32[i - j], s, &Overflow ) ) ); /* Q27 */
- }
- h1_32[M] = W_extract_l( Ltmp64 ); /* Q27 */
- move32();
-
- FOR( i = M + 1; i < L_subfr; i++ )
- {
- Ltmp64 = W_msu_16_16( 0, Aqs[1], extract_h( L_shl_o( h1_32[i - 1], s, &Overflow ) ) ); /* Q27 */
- FOR( j = 2; j <= M; j++ )
- {
- Ltmp64 = W_msu_16_16( Ltmp64, Aqs[j], extract_h( L_shl_o( h1_32[i - j], s, &Overflow ) ) ); /* Q27 */
- }
- h1_32[i] = W_extract_l( Ltmp64 ); /* Q27 */
- move32();
- }
-
- sf = sub( L_norm_arr( h1_32, L_subfr ), 1 );
- Copy_Scale_sig32_16( h1_32, h1, L_subfr, sf ); // Q11 + sf
-
- tmp = 0;
- move16();
- Deemph2( h1, tilt_fac, L_subfr, &tmp ); // Q11 + sf - 1
-
- return;
-}
-
-void find_targets_ivas_new_fx(
- const Word16 *speech, /* i : pointer to the speech frame Q_new-1*/
- const Word16 *mem_syn, /* i : memory of the synthesis filter Q_new-1*/
- const Word16 i_subfr, /* i : subframe index Q0*/
- Word16 *mem_w0, /* i/o: weighting filter denominator memory Q_new-1*/
- const Word16 *p_Aq, /* i : interpolated quantized A(z) filter Q12*/
- const Word16 *res, /* i : residual signal Q_new*/
- const Word16 L_subfr, /* i : length of vectors for gain quantization Q0*/
- const Word16 *Ap, /* i : unquantized A(z) filter with bandwidth expansion Q12*/
- Word16 tilt_fac, /* i : tilt factor Q15*/
- Word16 *xn, /* o : Close-loop Pitch search target vector Q_new-1*/
- Word16 *cn, /* o : target vector in residual domain Q_new*/
- Word16 *h1 /* o : impulse response of weighted synthesis filter Q(14 - norm_s(h1[0]))*/
-)
{
Word16 i;
Word16 temp[M + 6 * L_SUBFR]; /* error of quantization */
@@ -354,13 +219,13 @@ void find_targets_ivas_new_fx(
/* first half: xn[] --> cn[] */
temp[0] = 0;
move16();
- preemph_copy_fx( xn, cn, tilt_fac, L_SUBFR / 2, temp );
- syn_filt_s_lc_fx( 1, Ap, cn, temp, L_SUBFR / 2 ); /* Q-1 -> Q-2 */
- Residu3_lc_fx( p_Aq, M, temp, cn, L_SUBFR / 2, 1 ); /* Q-2 -> Q-1 */
- Scale_sig( cn, L_SUBFR / 2, 1 );
+ preemph_copy_fx( xn, cn, tilt_fac, L_subfr / 2, temp );
+ syn_filt_s_lc_fx( 1, Ap, cn, temp, L_subfr / 2 ); /* Q-1 -> Q-2 */
+ Residu3_lc_fx( p_Aq, M, temp, cn, L_subfr / 2, 1 ); /* Q-2 -> Q-1 */
+ Scale_sig( cn, L_subfr / 2, 1 );
/* second half: res[] --> cn[] (approximated and faster) */
- Copy( &res[i_subfr + ( L_SUBFR / 2 )], cn + ( L_SUBFR / 2 ), L_SUBFR / 2 );
+ Copy( &res[i_subfr + ( L_subfr / 2 )], cn + ( L_subfr / 2 ), L_subfr / 2 );
}
/*---------------------------------------------------------------*
diff --git a/lib_enc/find_uv_fx.c b/lib_enc/find_uv_fx.c
index c4fe2e895db461d4cfc4a15ff6aaad577c146168..61de9ca7d6d5a41fc5ac31197d075d2d8fde199a 100644
--- a/lib_enc/find_uv_fx.c
+++ b/lib_enc/find_uv_fx.c
@@ -853,11 +853,11 @@ Word16 find_uv_ivas_fx( /* o : coding typ
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 /* 33.5f in Q24 */, 22938 /* 0.7 in Q15 */, st_fx->lp_noise_fx ); // Q24
+ L_tmp = L_mac( -562036736 /* 33.5f in Q24 */, 22938 /* 0.7 in Q15 */, extract_h( st_fx->lp_noise_32fx ) ); // 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 /* 33.5f in Q24 */, 21299 /* 0.650f in Q15 */, st_fx->lp_noise_fx ); // Q24
+ L_tmp = L_mac( -562036736 /* 33.5f in Q24 */, 21299 /* 0.650f in Q15 */, extract_h( st_fx->lp_noise_32fx ) ); // Q24
}
relE_thres = round_fx( L_tmp );
}
@@ -865,7 +865,7 @@ 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 /* 28.2f in Q24 */, 19661 /* 0.6f in Q15 */, st_fx->lp_noise_fx ); // Q24
+ L_tmp = L_mac( -473117491 /* 28.2f in Q24 */, 19661 /* 0.6f in Q15 */, extract_h( st_fx->lp_noise_32fx ) ); // Q24
relE_thres = round_fx( L_tmp );
}
relE_thres = s_max( relE_thres, -6400 /* -25.0f in Q8 */ ); /* Q8 */
diff --git a/lib_enc/gs_enc_fx.c b/lib_enc/gs_enc_fx.c
index 77470c25546c948f20e5b3acb3de766be38742b8..7bf52970d7ff5f02edcaa6417a2b8b3d89cdf2c4 100644
--- a/lib_enc/gs_enc_fx.c
+++ b/lib_enc/gs_enc_fx.c
@@ -78,13 +78,7 @@ void encod_audio_fx(
* Encode GSC attack flag (used to reduce possible pre-echo)
* Encode GSC SWB speech flag
*---------------------------------------------------------------*/
-#ifdef GSC_IVAS // TVB -->>>>>>
- test();
- IF( ( st_fx->element_mode > EVS_MONO ) && st_fx->idchan == 0 )
- {
- push_indice( hBstr, IND_GSC_IVAS_SP, st_fx->GSC_IVAS_mode, 2 );
- }
-#endif
+
IF( attack_flag > 0 )
{
push_indice( hBstr, IND_GSC_ATTACK, 1, 1 );
diff --git a/lib_enc/hq_classifier_enc_fx.c b/lib_enc/hq_classifier_enc_fx.c
index 558ae89a7bc8952a208c513dcfcff9788c4c3ea4..aa2c319f1e9a936c00473a70f6caae499410ee37 100644
--- a/lib_enc/hq_classifier_enc_fx.c
+++ b/lib_enc/hq_classifier_enc_fx.c
@@ -194,7 +194,6 @@ Word16 hq_classifier_enc_fx( /* o : Consumed bits
Word16 *hqswb_clas /* o : HQ class Q0 */
)
{
-#ifndef SOLVED_COMP_ENC_DEC
Word16 bits;
HQ_ENC_HANDLE hHQ_core = st_fx->hHQ_core;
@@ -277,88 +276,7 @@ Word16 hq_classifier_enc_fx( /* o : Consumed bits
*hqswb_clas = HQ_GEN_SWB; /* Q0 */
move16();
}
-#else
- Word16 bits;
- HQ_ENC_HANDLE hHQ_core = st_fx->hHQ_core;
- Word32 max_brate;
- Word16 harmonic_decision;
-
-
- max_brate = HQ_32k;
- move32();
- if ( st_fx->element_mode > EVS_MONO )
- {
- max_brate = HQ_48k;
- move32();
- }
-
- *hqswb_clas = HQ_NORMAL;
- bits = 1;
- move16();
- IF( EQ_16( is_transient, 1 ) )
- {
- *hqswb_clas = HQ_TRANSIENT;
- move16();
- }
-
- /* classification and limit bandwidth for bit allocation */
- test();
- IF( EQ_16( length, L_SPEC32k ) || EQ_16( length, L_SPEC48k ) )
- {
- IF( LE_32( st_fx->core_brate, max_brate ) )
- {
- test();
- IF( !is_transient && 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 );
-
-#if 0
- harmonic_decision = hf_spectrum_sparseness( st, coefs );
-#else
- harmonic_decision = 0;
- move16();
-#endif
- test();
- IF( EQ_16( *hqswb_clas, HQ_HARMONIC ) && !harmonic_decision )
- {
- *hqswb_clas = HQ_NORMAL;
- move16();
- }
- ELSE
- {
- /* 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 );
- }
- }
- bits = 2;
- move16();
- }
- }
- ELSE IF( EQ_16( length, L_SPEC16k_EXT ) || EQ_16( length, L_SPEC48k_EXT ) )
- {
- bits = 0; /* HQ_NORMAL only -- no signalling needed */
- move16();
- }
- /* write signalling info to the bitstream */
- push_indice( st_fx->hBstr, IND_HQ_SWB_CLAS, *hqswb_clas, bits );
-
- IF( LE_32( st_fx->core_brate, HQ_32k ) && EQ_16( *hqswb_clas, HQ_NORMAL ) )
- {
- IF( EQ_16( length, L_SPEC32k ) )
- {
- *hqswb_clas = HQ_GEN_SWB;
- move16();
- }
- ELSE IF( EQ_16( length, L_SPEC48k ) )
- {
- *hqswb_clas = HQ_GEN_FB;
- move16();
- }
- }
-#endif
return bits;
}
Word16 hq_classifier_enc_ivas_fx( /* o : Consumed bits Q0 */
@@ -677,11 +595,8 @@ Word16 peak_avrg_ratio_fx(
test();
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 ) ) )
-#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
{
hqswb_clas = HQ_HARMONIC;
move16();
@@ -1177,11 +1092,7 @@ void hvq_classifier_fx(
L_input_max = L_deposit_l( 0 );
set32_fx( L_thr, 0, L_FRAME16k );
-#ifndef SOLVED_COMP_ENC_DEC
IF( EQ_32( L_core_brate, HQ_24k40 ) )
-#else
- IF( LT_32( L_core_brate, HQ_BWE_CROSSOVER_BRATE ) )
-#endif
{
nsub = HVQ_NSUB_24k;
move16();
@@ -1420,7 +1331,6 @@ void hvq_classifier_fx(
num_peak_cands = add( num_peak_cands, 1 );
}
}
-#ifndef ADD_IVAS_HQ_CODE
IF( EQ_32( L_core_brate, HQ_24k40 ) )
{
peak_th = HVQ_MAX_PEAKS_24k_CLAS;
@@ -1431,9 +1341,6 @@ void hvq_classifier_fx(
peak_th = HVQ_MAX_PEAKS_32k;
move16();
}
-#else
- peak_th = (int16_t) ( ( core_brate * HVQ_PEAKS_PER_DELTA_THR + HVQ_PEAKS_PER_DELTA_THR_OFFS ) / HVQ_PEAKS_BPS_DELTA );
-#endif
/* Find peaks */
pindx = maximum_32_fx( L_input_abs, num_peak_cands, &L_m );
i = 0;
@@ -1555,7 +1462,6 @@ void hvq_classifier_fx(
move16();
}
-#ifndef ADD_IVAS_HQ_CODE
IF( EQ_32( L_core_brate, HQ_24k40 ) )
{
*Npeaks = s_min( HVQ_MAX_PEAKS_24k, *Npeaks ); /* Q0 */
@@ -1566,9 +1472,6 @@ void hvq_classifier_fx(
*Npeaks = s_min( HVQ_MAX_PEAKS_32k, *Npeaks ); /* Q0 */
move16();
}
-#else
- *Npeaks = (int16_t) ( min( ( core_brate * HVQ_PEAKS_PER_DELTA + HVQ_PEAKS_PER_DELTA_OFFS ) / HVQ_PEAKS_BPS_DELTA, *Npeaks ) );
-#endif
}
ELSE
{
@@ -1581,99 +1484,3 @@ void hvq_classifier_fx(
return;
}
-
-#ifdef ADD_IVAS_HQ_CODE
-/*--------------------------------------------------------------------------*
- * hf_spectrum_sparseness()
- *
- * Detection of sparse spectrum in high band for activation of harmonic
- * modes HQ_HARMONIC and HQ_HVQ
- *--------------------------------------------------------------------------*/
-/*! r: Harmonic decision for high band */
-static int16_t hf_spectrum_sparseness(
- Encoder_State *st, /* i/o: encoder state structure */
- const float *coefs /* i : MDCT spectrum */
-)
-{
- int16_t i;
- float thr;
- int16_t low_count;
- float A[L_SPEC_HB];
- float Amax;
- float movmean;
- float inv_rms;
- float crest;
- float crest_mod;
- const float *p_num;
- float *crest_lp;
- float *crest_mod_lp;
- int16_t result;
-
- crest_lp = &st->hHQ_core->crest_lp;
- crest_mod_lp = &st->hHQ_core->crest_mod_lp;
-
- result = TRUE;
- if ( st->element_mode != EVS_MONO )
- {
- for ( i = 0; i < L_SPEC_HB; i++ )
- {
- A[i] = (float) fabsf( coefs[i + L_SPEC_HB] );
- }
- low_count = 0;
- inv_rms = 0.0f;
- crest_mod = 0.0f;
- maximum( A, L_SPEC_HB, &Amax );
- thr = Amax * PEAK_THRESHOLD;
- movmean = 0.0f; /* avoid uninitialized warning */
- p_num = &inv_tbl[HALF_WIN_LENGTH + 1]; /* Table for division 1./(11:21) */
- for ( i = 0; i < L_SPEC_HB; i++ )
- {
- inv_rms += A[i] * A[i];
- if ( A[i] < thr )
- {
- low_count += 1;
- }
- if ( i <= HALF_WIN_LENGTH )
- {
- if ( i == 0 )
- {
- movmean = sum_f( &A[0], i + HALF_WIN_LENGTH + 1 ) * ( *p_num );
- }
- else
- {
- p_num++;
- movmean = movmean + ( A[i + HALF_WIN_LENGTH] - movmean ) * ( *p_num );
- }
- }
- else
- {
- if ( L_SPEC_HB <= i + HALF_WIN_LENGTH )
- {
- p_num--;
- movmean = movmean + ( movmean - A[i - HALF_WIN_LENGTH - 1] ) * ( *p_num );
- }
- else
- {
- movmean = movmean + ( A[i + HALF_WIN_LENGTH] - A[i - HALF_WIN_LENGTH - 1] ) * ( *p_num );
- }
- }
- if ( crest_mod < movmean )
- {
- crest_mod = movmean;
- }
- }
- inv_rms = 1.0f / (float) sqrtf( inv_rms / L_SPEC_HB );
- crest = Amax * inv_rms;
- crest_mod = crest_mod * inv_rms;
- *crest_lp = HQ_CREST_FAC_SM * ( *crest_lp ) + ( 1.0f - HQ_CREST_FAC_SM ) * crest;
- *crest_mod_lp = HQ_CREST_FAC_SM * ( *crest_mod_lp ) + ( 1.0f - HQ_CREST_FAC_SM ) * crest_mod;
-
- if ( ( ( *crest_lp ) > HQ_CREST_THRESHOLD ) && ( ( *crest_mod_lp ) > HQ_CREST_MOD_THRESHOLD ) && ( low_count > LOW_COUNT_THRESHOLD ) )
- {
- result = FALSE;
- }
- }
-
- return result;
-}
-#endif
diff --git a/lib_enc/hq_core_enc_fx.c b/lib_enc/hq_core_enc_fx.c
index 66430cb8e9d0c29403f7711e854942050f46b78a..b5e1abbca2d5383df9a9a9538635b2e2cad57058 100644
--- a/lib_enc/hq_core_enc_fx.c
+++ b/lib_enc/hq_core_enc_fx.c
@@ -35,15 +35,6 @@ void hq_core_enc_fx(
Word16 tmp;
Word32 L_tmp;
UWord16 lsb;
-#ifdef ADD_IVAS_HQ_CODE_L_SPEC
- Word16 L_spec;
-#endif
-#ifdef ADD_IVAS_HQ_CODE
- Word16 left_overlap, right_overlap;
- Word16 overlap, nz, tcx_offset, L_frame;
- Word16 Aq_old[M + 1];
- Word16 output[L_FRAME16k];
-#endif
Word16 two_frames_buffer[2 * L_FRAME48k];
BSTR_ENC_HANDLE hBstr = st_fx->hBstr;
@@ -87,37 +78,6 @@ void hq_core_enc_fx(
is_transient = detect_transient_fx( audio, input_frame, 0, st_fx ); /* Q0 */
-#ifdef ADD_IVAS_HQ_CODE
- test();
- test();
- test();
- 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
- *--------------------------------------------------------------------------*/
-
- L_spec = input_frame;
- left_overlap = -1;
- right_overlap = -1;
- move16();
- move16();
- move16();
-
- WindowSignal( &( st_fx->tcx_cfg ), st_fx->hTcxCfg->tcx_offsetFB, TRANSITION_OVERLAP, FULL_OVERLAP, &left_overlap, &right_overlap, st_fx->hTcxEnc->speech_TCX, &L_spec, wtda_audio, 1, 1 );
- Q_audio = 16;
- move16(); /*tbv inspired from core_enc_ol*/
- TCX_MDCT( wtda_audio, t_audio, &Q_audio, left_overlap, sub( L_spec, shr( add( left_overlap, right_overlap ), 1 ) ), right_overlap, st_fx->element_mode );
-
- inner_frame = inner_frame_tbl[st_fx->bwidth];
- L_spec = l_spec_ext_tbl[st_fx->bwidth];
- is_transient = 0;
- move16();
- move16();
- move16();
- }
- ELSE
-#endif
{
/*--------------------------------------------------------------------------
* Windowing and time-domain aliasing
@@ -144,10 +104,8 @@ void hq_core_enc_fx(
move16();
}
}
-#ifndef ADD_IVAS_HQ_CODE
/* subtract signalling bits */
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 );
/* scale coefficients to their nominal level (8kHz) */
@@ -174,10 +132,6 @@ void hq_core_enc_fx(
/* limit encoded band-width according to the command-line OR BWD limitation */
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];
- move16();
-#endif
IF( GT_16( input_frame, inner_frame ) )
{
IF( EQ_16( is_transient, 1 ) )
@@ -193,31 +147,10 @@ void hq_core_enc_fx(
set32_fx( t_audio + inner_frame, 0, sub( input_frame, inner_frame ) );
}
}
-#ifdef ADD_IVAS_HQ_CODE_L_SPEC
- /* subtract signalling bits */
- num_bits = sub( num_bits, hBstr->nb_bits_tot_fx );
-#endif
-
/*--------------------------------------------------------------------------
* High-band gain control in case of BWS
*--------------------------------------------------------------------------*/
-#ifdef ADD_IVAS_HQ_CODE
- IF( st_fx->bwidth_sw_cnt > 0 )
- {
- IF( is_transient )
- {
- FOR( i = 0; i < NUM_TIME_SWITCHING_BLOCKS; i++ )
- {
- v_multc( t_audio + i * inner_frame / NUM_TIME_SWITCHING_BLOCKS + L_FRAME16k / NUM_TIME_SWITCHING_BLOCKS, (float) ( st->bwidth_sw_cnt ) / (float) BWS_TRAN_PERIOD, t_audio + i * inner_frame / NUM_TIME_SWITCHING_BLOCKS + L_FRAME16k / NUM_TIME_SWITCHING_BLOCKS, inner_frame / NUM_TIME_SWITCHING_BLOCKS - L_FRAME16k / NUM_TIME_SWITCHING_BLOCKS );
- }
- }
- ELSE
- {
- v_multc( t_audio + L_FRAME16k, (float) ( st->bwidth_sw_cnt ) / (float) BWS_TRAN_PERIOD, t_audio + L_FRAME16k, L_spec - L_FRAME16k );
- }
- }
-#endif
/*--------------------------------------------------------------------------
* Classify whether to put extra bits for FER mitigation
*--------------------------------------------------------------------------*/
@@ -263,12 +196,7 @@ void hq_core_enc_fx(
t_audio[i] = L_shr( t_audio[i], sub( Q_audio, 12 ) ); /* Q12 */
move32();
}
-
-#ifdef ADD_IVAS_HQ_CODE_L_SPEC
- hq_hr_enc_fx( st_fx, t_audio, L_spec, &num_bits, is_transient, vad_hover_flag );
-#else
hq_hr_enc_fx( st_fx, t_audio, inner_frame, &num_bits, is_transient, vad_hover_flag );
-#endif
Q_audio = 12;
move16();
}
@@ -286,51 +214,6 @@ void hq_core_enc_fx(
{
push_indice( hBstr, IND_UNUSED, 0, num_bits );
}
-#ifdef ADD_IVAS_HQ_CODE
- if ( st->element_mode > EVS_MONO && ( st->last_core == ACELP_CORE || st->last_core == AMR_WB_CORE ) )
- {
- overlap = st->hTcxCfg->tcx_mdct_window_length;
- nz = NS2SA( st->sr_core, N_ZERO_MDCT_NS );
- L_frame = (int16_t) ( st->L_frame + st->hTcxCfg->tcx_offset - st->hTcxCfg->lfacNext );
- tcx_offset = st->hTcxCfg->lfacNext;
- set_f( Aq_old, 0, M + 1 ); /* Dummy filter */
- Aq_old[0] = 1;
-
- /* Code taken from InternalTCXDecoder() */
- TCX_MDCT_Inverse( t_audio, wtda_audio, overlap, L_frame - overlap, overlap, st->element_mode );
-
- /* Window current frame */
- tcx_windowing_synthesis_current_frame( wtda_audio, st->hTcxCfg->tcx_aldo_window_2, st->hTcxCfg->tcx_mdct_window_half, st->hTcxCfg->tcx_mdct_window_minimum, overlap, /*st->hTcxCfg->tcx_mdct_window_length*/ st->hTcxCfg->tcx_mdct_window_half_length, st->hTcxCfg->tcx_mdct_window_min_length, st->last_core == ACELP_CORE, st->hTcxCfg->tcx_last_overlap_mode, /*left mode*/ st->hTcxEnc->acelp_zir, st->hTcxEnc->Txnq, NULL, Aq_old, st->hTcxCfg->tcx_mdct_window_trans, st->L_frame >> 1, tcx_offset < 0 ? -tcx_offset : 0, st->last_core, 0, 0 );
-
- /*Compute windowed synthesis in case of switching to ALDO windows in next frame*/
- mvr2r( wtda_audio + L_frame - nz, st->hTcxEnc->old_out, nz + overlap );
- set_zero( st->hTcxEnc->old_out + nz + overlap, nz );
-
- tcx_windowing_synthesis_past_frame( st->hTcxEnc->old_out + 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 );
-
- for ( i = 0; i < nz; i++ )
- {
- st->hTcxEnc->old_out[nz + overlap + i] = wtda_audio[L_frame - 1 - i] * st->hTcxCfg->tcx_aldo_window_1_trunc[-1 - i];
- }
- mvr2r( wtda_audio + ( overlap >> 1 ) - tcx_offset, output, st->L_frame );
- }
- else
- {
- ener_match = (float) sqrt( (float) L_FRAME16k / (float) NORM_MDCT_FACTOR );
- v_multc( t_audio, ener_match, t_audio, inner_frame );
-
- inverse_transform( t_audio, wtda_audio, is_transient, L_FRAME16k, inner_frame, st->element_mode );
-
- window_ola( wtda_audio, output, st->hTcxEnc->old_out, L_FRAME16k, st->hTcxCfg->tcx_last_overlap_mode, st->hTcxCfg->tcx_curr_overlap_mode, 0, 0, NULL );
- }
-
- if ( st->element_mode > EVS_MONO )
- {
- /* Store LB synthesis in case of switch to ACELP */
- mvr2r( output, st->hLPDmem->old_exc, L_FRAME16k );
- }
-#endif
-
return;
}
diff --git a/lib_enc/hq_hr_enc_fx.c b/lib_enc/hq_hr_enc_fx.c
index 705db9ecdf46b08c5bf6ce41e323890bffd7d01d..05654e775965c7471130beb49e398018b3df01ef 100644
--- a/lib_enc/hq_hr_enc_fx.c
+++ b/lib_enc/hq_hr_enc_fx.c
@@ -249,20 +249,6 @@ void hq_hr_enc_fx(
move16();
/* Prepare synthesis for LB generation in case of switch to ACELP */
-#ifdef ADD_IVAS_HQ_CODE
- IF( NE_16( hqswb_clas, HQ_HVQ ) )
- {
- apply_envelope_enc( t_audio_q, ynrm, num_sfm, sfm_start, sfm_end );
- }
-
- IF( is_transient )
- {
- de_interleave_spectrum( t_audio_q, length );
- }
- Copy32( t_audio_q, t_audio, length );
-#endif
-
-
return;
}
diff --git a/lib_enc/igf_enc.c b/lib_enc/igf_enc.c
index 9769d83b6c8ba64acd1546156bbaaaba3153f65d..70b5166df6efef91583d4eb1f3df7225988b04b1 100644
--- a/lib_enc/igf_enc.c
+++ b/lib_enc/igf_enc.c
@@ -246,94 +246,6 @@ static Word16 IGF_getSFM_new_fx(
/*! r: spectral tilt value */
/* Returns value with exponent as 9 and Q as 22*/
-static Word32 IGF_getTNR_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;
- 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( L_shl( 1, sub( 15, normSpec_e ) ), L_shl( 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( 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;
-}
static Word32 IGF_getTNR_ivas_fx(
const Word32 *powerSpectrum, /* i : energies */
@@ -521,7 +433,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[sb], Q25 ) ), Q25 ) );
+ hPrivateData->logSpec[sb] = s_max( 0, extract_l( W_extract_l( W_shr( W_add( BASOP_Util_Log2( pPowerSpectrum_fx[sb] ), W_shl( e_ps[sb], Q25 ) ), Q25 ) ) ) );
move16();
}
ELSE
@@ -1000,14 +912,14 @@ static void IGF_CalculateStereoEnvelope_fx(
const Word32 *pMDCTSpectrumMsInv_fx, /* i : MDCT spectrum */
Word16 pMDCTSpectrumMsInv_e, /* i : expontent for pMDCTSpectrumMsInv_fx */
const Word32 *pPowerSpectrum_fx, /* i : MDCT^2 + MDST^2 spectrum, or estimate */
- Word16 pPowerSpectrum_e, /* i : exponent for pPowerSpectrum_fx */
+ Word16 *pPowerSpectrum_e, /* i : exponent for pPowerSpectrum_fx */
const Word32 *pPowerSpectrumMsInv_fx, /* i : inverse power spectrum */
- Word16 pPowerSpectrumMsInv_e, /* i : exponent for pPowerSpectrumMsInv_fx */
+ Word16 *q_pPowerSpectrumMsInv, /* i : Q for pPowerSpectrumMsInv_fx */
const Word16 igfGridIdx, /* i : IGF grid index */
const Word16 coreMsMask[N_MAX], /* i : line wise ms Mask */
const Word16 isTransient, /* i : flag indicating if transient is detected */
- const Word16 last_core_acelp /* i : indicator if last frame was ACELP core */
-)
+ const Word16 last_core_acelp, /* i : indicator if last frame was ACELP core */
+ const Word16 mct_on )
{
IGF_ENC_PRIVATE_DATA_HANDLE hPrivateData;
H_IGF_GRID hGrid;
@@ -1033,20 +945,46 @@ static void IGF_CalculateStereoEnvelope_fx(
Word16 sfm;
Word16 crest;
Word16 temp;
- Word16 mean_x_e, mean_y_e; /*Stores exponent for mean_x and mean_y respectively*/
- Word16 mean_xy_e, mean_x2_e; /*stores exponent for mean_xy and mean_x2 respectively*/
- Word16 tileSrcSpec_e; /*Exponent for tileSrcSpec_fx*/
- Word16 sfbEnergyTileR_e; /*Exponent for sfbEnergyTileR_fx*/
- Word16 sfbEnergyTileC_e; /*Exponent for sfbEnergyTileC_fx*/
- Word16 sfbEnergyC_e; /*Exponent for sfbEnergyC_fx*/
- Word16 gain_e; /*exponent for gain_fx*/
- Word16 crest_exp; /*stores exponent for output from crest*/
- Word16 sfm_exp; /*stores exponent for ouput from sfm*/
- Word16 tmp_tb_e; /*Stores exponent for tmp_tb_fx*/
- Word16 tmp_sb_e; /*stores exponent for tmp_sb_fx*/
- Word16 slope_e; /*stores exponent for slope_fx*/
- Word16 sfbEnergyR_e; /*stores exponent for sfbEnergyR*/
+ Word16 mean_x_e, mean_y_e; /*Stores exponent for mean_x and mean_y respectively*/
+ Word16 mean_xy_e, mean_x2_e; /*stores exponent for mean_xy and mean_x2 respectively*/
+ Word16 tileSrcSpec_e[MAX_IGF_SFB_LEN]; /*Exponent for tileSrcSpec_fx*/
+ Word16 sfbEnergyTileR_e; /*Exponent for sfbEnergyTileR_fx*/
+ Word16 sfbEnergyTileC_e; /*Exponent for sfbEnergyTileC_fx*/
+ Word16 sfbEnergyC_e; /*Exponent for sfbEnergyC_fx*/
+ Word16 gain_e; /*exponent for gain_fx*/
+ Word16 crest_exp; /*stores exponent for output from crest*/
+ Word16 sfm_exp; /*stores exponent for ouput from sfm*/
+ Word16 tmp_tb_e; /*Stores exponent for tmp_tb_fx*/
+ Word16 tmp_sb_e; /*stores exponent for tmp_sb_fx*/
+ Word16 slope_e; /*stores exponent for slope_fx*/
+ Word16 sfbEnergyR_e; /*stores exponent for sfbEnergyR*/
Word16 tmp_e;
+ Word32 temp_pPowerSpectrumMsInv[N_MAX], length;
+ Word16 q_temp_pPowerSpectrumMsInv = Q31, i;
+ move16();
+
+ IF( pPowerSpectrumMsInv_fx != NULL )
+ {
+ length = N_MAX;
+ move16();
+ if ( mct_on )
+ {
+ length = L_FRAME48k;
+ move16();
+ }
+ FOR( i = 0; i < length; i++ )
+ {
+ IF( pPowerSpectrumMsInv_fx[i] != 0 )
+ {
+ q_temp_pPowerSpectrumMsInv = s_min( q_temp_pPowerSpectrumMsInv, add( q_pPowerSpectrumMsInv[i], norm_l( pPowerSpectrumMsInv_fx[i] ) ) );
+ }
+ }
+ FOR( i = 0; i < length; i++ )
+ {
+ temp_pPowerSpectrumMsInv[i] = L_shl( pPowerSpectrumMsInv_fx[i], sub( q_temp_pPowerSpectrumMsInv, q_pPowerSpectrumMsInv[i] ) );
+ move32();
+ }
+ }
hPrivateData = &hIGFEnc->igfData;
hGrid = &hPrivateData->igfInfo.grid[(Word16) igfGridIdx];
@@ -1084,7 +1022,7 @@ static void IGF_CalculateStereoEnvelope_fx(
/*hPrivateData->logSpec[sb] = max( 0, (Word16) ( logf( max( FLT_MIN, pPowerSpectrum[sb] ) ) * INV_LOG_2 ) );*/
IF( LE_32( 1, pPowerSpectrum_fx[sb] ) )
{
- hPrivateData->logSpec[sb] = s_max( 0, (Word16) L_shr( L_add( BASOP_Util_Log2( pPowerSpectrum_fx[sb] ), L_shl( pPowerSpectrum_e, Q25 ) ), 25 ) );
+ hPrivateData->logSpec[sb] = s_max( 0, (Word16) L_shr( L_add( BASOP_Util_Log2( pPowerSpectrum_fx[sb] ), L_shl( pPowerSpectrum_e[sb], Q25 ) ), 25 ) );
}
ELSE
{
@@ -1126,25 +1064,25 @@ static void IGF_CalculateStereoEnvelope_fx(
{
IF( NE_16( coreMsMask[sb], coreMsMask[strt_cpy] ) )
{
- sfbEnergyC_fx = BASOP_Util_Add_Mant32Exp( sfbEnergyC_fx, sfbEnergyC_e, pPowerSpectrum_fx[sb], pPowerSpectrum_e, &sfbEnergyC_e ); /*resultant exponent is stored in sfbEnergyC_e*/
+ sfbEnergyC_fx = BASOP_Util_Add_Mant32Exp( sfbEnergyC_fx, sfbEnergyC_e, pPowerSpectrum_fx[sb], pPowerSpectrum_e[sb], &sfbEnergyC_e ); /*resultant exponent is stored in sfbEnergyC_e*/
norm_exp = norm_l( pMDCTSpectrumMsInv_fx[strt_cpy] );
final_exp = sub( pMDCTSpectrumMsInv_e, norm_exp );
scaled_value = L_shl( pMDCTSpectrumMsInv_fx[strt_cpy], norm_exp );
- sfbEnergyTileR_fx = BASOP_Util_Add_Mant32Exp( sfbEnergyTileR_fx, sfbEnergyTileR_e, Mult_32_32( scaled_value, scaled_value ), shl( final_exp, 1 ), &sfbEnergyTileR_e ); /*resultant exponent is stored in sfbEnergyTileR_e*/
- sfbEnergyTileC_fx = BASOP_Util_Add_Mant32Exp( sfbEnergyTileC_fx, sfbEnergyTileC_e, pPowerSpectrumMsInv_fx[strt_cpy], pPowerSpectrumMsInv_e, &sfbEnergyTileC_e ); /*resultant exponent is stored in sfbEnergyTileC_e*/
- tileSrcSpec_fx[sub( strt_cpy, tmp )] = pPowerSpectrumMsInv_fx[strt_cpy]; /*resultant exponent is stored in tileSrcSpec_e*/
- tileSrcSpec_e = pPowerSpectrumMsInv_e;
+ sfbEnergyTileR_fx = BASOP_Util_Add_Mant32Exp( sfbEnergyTileR_fx, sfbEnergyTileR_e, Mult_32_32( scaled_value, scaled_value ), shl( final_exp, 1 ), &sfbEnergyTileR_e ); /*resultant exponent is stored in sfbEnergyTileR_e*/
+ sfbEnergyTileC_fx = BASOP_Util_Add_Mant32Exp( sfbEnergyTileC_fx, sfbEnergyTileC_e, pPowerSpectrumMsInv_fx[strt_cpy], sub( 31, q_pPowerSpectrumMsInv[strt_cpy] ), &sfbEnergyTileC_e ); /*resultant exponent is stored in sfbEnergyTileC_e*/
+ tileSrcSpec_fx[strt_cpy - tmp] = temp_pPowerSpectrumMsInv[strt_cpy]; /*resultant exponent is stored in tileSrcSpec_e*/
+ tileSrcSpec_e[strt_cpy - tmp] = sub( 31, q_temp_pPowerSpectrumMsInv );
}
ELSE
{
- sfbEnergyC_fx = BASOP_Util_Add_Mant32Exp( sfbEnergyC_fx, sfbEnergyC_e, pPowerSpectrum_fx[sb], pPowerSpectrum_e, &sfbEnergyC_e ); /*resultant exponent is stored in sfbEnergyC_e*/
+ sfbEnergyC_fx = BASOP_Util_Add_Mant32Exp( sfbEnergyC_fx, sfbEnergyC_e, pPowerSpectrum_fx[sb], pPowerSpectrum_e[sb], &sfbEnergyC_e ); /*resultant exponent is stored in sfbEnergyC_e*/
norm_exp = norm_l( pMDCTSpectrum_fx[strt_cpy] );
final_exp = sub( pMDCTSpectrum_e, norm_exp );
scaled_value = L_shl( pMDCTSpectrum_fx[strt_cpy], norm_exp );
sfbEnergyTileR_fx = BASOP_Util_Add_Mant32Exp( sfbEnergyTileR_fx, sfbEnergyTileR_e, Mult_32_32( scaled_value, scaled_value ), shl( final_exp, 1 ), &sfbEnergyTileR_e ); /*resultant exponent is stored in sfbEnergyTileR_e*/
- sfbEnergyTileC_fx = BASOP_Util_Add_Mant32Exp( sfbEnergyTileC_fx, sfbEnergyTileC_e, pPowerSpectrum_fx[strt_cpy], pPowerSpectrum_e, &sfbEnergyTileC_e ); /*resultant exponent is stored in sfbEnergyTileC_e*/
- tileSrcSpec_fx[sub( strt_cpy, tmp )] = pPowerSpectrum_fx[strt_cpy]; /*resultant exponent is stored in tileSrcSpec_e*/
- tileSrcSpec_e = pPowerSpectrum_e;
+ sfbEnergyTileC_fx = BASOP_Util_Add_Mant32Exp( sfbEnergyTileC_fx, sfbEnergyTileC_e, pPowerSpectrum_fx[strt_cpy], pPowerSpectrum_e[strt_cpy], &sfbEnergyTileC_e ); /*resultant exponent is stored in sfbEnergyTileC_e*/
+ tileSrcSpec_fx[strt_cpy - tmp] = pPowerSpectrum_fx[strt_cpy]; /*resultant exponent is stored in tileSrcSpec_e*/
+ tileSrcSpec_e[strt_cpy - tmp] = pPowerSpectrum_e[strt_cpy];
}
move32();
move16();
@@ -1171,14 +1109,14 @@ static void IGF_CalculateStereoEnvelope_fx(
move16();
// tmp_tb = IGF_getSFM_ivas(pPowerSpectrum, swb_offset[sfb], swb_offset[sfb + 1]) / IGF_getCrest_ivas(pPowerSpectrum, swb_offset[sfb], swb_offset[sfb + 1]);
- sfm = IGF_getSFM_ivas_fx( &sfm_exp, pPowerSpectrum_fx, &pPowerSpectrum_e, swb_offset[sfb], swb_offset[sfb + 1] );
- crest = IGF_getCrest( &crest_exp, pPowerSpectrum_fx, pPowerSpectrum_e, swb_offset[sfb], swb_offset[sfb + 1] );
+ sfm = IGF_getSFM_ivas_fx( &sfm_exp, pPowerSpectrum_fx, pPowerSpectrum_e, swb_offset[sfb], swb_offset[sfb + 1] );
+ crest = IGF_getCrest_ivas( &crest_exp, pPowerSpectrum_fx, pPowerSpectrum_e, swb_offset[sfb], swb_offset[sfb + 1] );
tmp_tb_fx = BASOP_Util_Divide1616_Scale( sfm, crest, &tmp_e );
tmp_tb_e = add( tmp_e, sub( sfm_exp, crest_exp ) ); /*stores the resultant exponent for tmp_tb_fx*/
// tmp_sb = IGF_getSFM_ivas(tileSrcSpec, 0, strt_cpy - tmp) / IGF_getCrest_ivas(tileSrcSpec, 0, strt_cpy - tmp);
- sfm = IGF_getSFM_ivas_fx( &sfm_exp, tileSrcSpec_fx, &tileSrcSpec_e, 0, sub( strt_cpy, tmp ) );
- crest = IGF_getCrest( &crest_exp, tileSrcSpec_fx, tileSrcSpec_e, 0, sub( strt_cpy, tmp ) );
+ sfm = IGF_getSFM_ivas_fx( &sfm_exp, tileSrcSpec_fx, tileSrcSpec_e, 0, sub( strt_cpy, tmp ) );
+ crest = IGF_getCrest_ivas( &crest_exp, tileSrcSpec_fx, tileSrcSpec_e, 0, sub( strt_cpy, tmp ) );
tmp_sb_fx = BASOP_Util_Divide1616_Scale( sfm, crest, &tmp_e );
tmp_sb_e = add( tmp_e, sub( sfm_exp, crest_exp ) ); /*stores the resultant exponent for tmp_sb_fx*/
@@ -1294,7 +1232,7 @@ static void IGF_CalculateStereoEnvelope_fx(
}
ELSE
{
- y = imult1616( 20, extract_l( L_shr( Mult_32_16( ( L_add( BASOP_Util_Log2( pPowerSpectrum_fx[sb] ), L_shl( pPowerSpectrum_e, Q25 ) ) ), INV_Log2_10_Q15 ), 25 ) ) ); /*Q0*/
+ y = imult1616( 20, extract_l( L_shr( Mult_32_16( ( L_add( BASOP_Util_Log2( pPowerSpectrum_fx[sb] ), L_shl( pPowerSpectrum_e[sb], Q25 ) ) ), INV_Log2_10_Q15 ), 25 ) ) ); /*Q0*/
}
mean_y_fx = add( mean_y_fx, y ); /*Q0*/
mean_xy_fx = L_add( mean_xy_fx, L_mult0( y, x ) ); /*Q0*/
@@ -1322,8 +1260,8 @@ static void IGF_CalculateStereoEnvelope_fx(
{
Word16 shift = shr( width, 1 );
// shiftedSFM = IGF_getSFM_ivas( pPowerSpectrum, swb_offset[sfb] - shift, swb_offset[sfb + 1] - shift ) / IGF_getCrest_ivas( pPowerSpectrum, swb_offset[sfb] - shift, swb_offset[sfb + 1] - shift );
- sfm = IGF_getSFM_ivas_fx( &sfm_exp, pPowerSpectrum_fx, &pPowerSpectrum_e, sub( swb_offset[sfb], shift ), sub( swb_offset[sfb + 1], shift ) );
- crest = IGF_getCrest( &crest_exp, pPowerSpectrum_fx, pPowerSpectrum_e, sub( swb_offset[sfb], shift ), sub( swb_offset[sfb + 1], shift ) );
+ sfm = IGF_getSFM_ivas_fx( &sfm_exp, pPowerSpectrum_fx, pPowerSpectrum_e, sub( swb_offset[sfb], shift ), sub( swb_offset[sfb + 1], shift ) );
+ crest = IGF_getCrest_ivas( &crest_exp, pPowerSpectrum_fx, pPowerSpectrum_e, sub( swb_offset[sfb], shift ), sub( swb_offset[sfb + 1], shift ) );
shiftedSFM_fx = BASOP_Util_Divide1616_Scale( sfm, crest, &shiftedSFM_e );
}
ELSE IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( slope_fx, add( slope_e, 16 ), threshold_fx, add( threshold_e, 16 ) ), 1 ) && ( NE_16( sfb, sub( hGrid->sfbWrap[hGrid->nTiles], 1 ) ) ) )
@@ -1331,8 +1269,8 @@ static void IGF_CalculateStereoEnvelope_fx(
Word16 shift;
shift = shr( width, 1 );
// shiftedSFM = IGF_getSFM_ivas( pPowerSpectrum, swb_offset[sfb] + shift, swb_offset[sfb + 1] + shift ) / IGF_getCrest_ivas( pPowerSpectrum, swb_offset[sfb] + shift, swb_offset[sfb + 1] + shift );
- sfm = IGF_getSFM_ivas_fx( &sfm_exp, pPowerSpectrum_fx, &pPowerSpectrum_e, add( swb_offset[sfb], shift ), add( swb_offset[sfb + 1], shift ) );
- crest = IGF_getCrest( &crest_exp, pPowerSpectrum_fx, pPowerSpectrum_e, add( swb_offset[sfb], shift ), add( swb_offset[sfb + 1], shift ) );
+ sfm = IGF_getSFM_ivas_fx( &sfm_exp, pPowerSpectrum_fx, pPowerSpectrum_e, add( swb_offset[sfb], shift ), add( swb_offset[sfb + 1], shift ) );
+ crest = IGF_getCrest_ivas( &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 );
}
IF( shiftedSFM_fx )
@@ -1384,7 +1322,7 @@ static void IGF_CalculateStereoEnvelope_fx(
tonalToNoise_e = 9; /*stores exponent for tonalToNoise*/
move16();
adap = BASOP_Util_Divide1616_Scale( width, 30, &adap_e );
- tonalToNoise = IGF_getTNR_fx( pPowerSpectrum_fx, swb_offset[sfb], swb_offset[sfb + 1], adap, pPowerSpectrum_e, adap_e ); /*Q22*/
+ tonalToNoise = IGF_getTNR_ivas_fx( pPowerSpectrum_fx, swb_offset[sfb], swb_offset[sfb + 1], adap, pPowerSpectrum_e, 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 ) )
{
// currDampingFactor += 0.1f * ( ( 10 + adap ) - tonalToNoise );
@@ -2538,7 +2476,7 @@ void IGFEncApplyMono_ivas_fx(
Word32 common_pPowerSpectrum_fx[N_MAX + L_MDCT_OVLP_MAX];
- set32_fx( common_pPowerSpectrum_fx, 0, N_MAX + L_MDCT_OVLP_MAX );
+ set32_fx( common_pPowerSpectrum_fx, 0, N_MAX );
Word16 common_pPowerSpectrum_exp = MIN16B;
move16();
@@ -2620,28 +2558,35 @@ void IGFEncApplyMono_ivas_fx(
*-------------------------------------------------------------------*/
void IGFEncApplyStereo_fx(
- STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: MDCT stereo encoder structure */
- Word16 ms_mask[2][MAX_SFB], /* i : bandwise MS mask */
- const IGF_ENC_INSTANCE_HANDLE hIGFEnc[CPE_CHANNELS], /* i : instance handle of IGF Encoder */
- const Word16 igfGridIdx, /* i : IGF grid index */
- Encoder_State *sts[CPE_CHANNELS], /* i : Encoder state */
- Word32 *pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */
- Word16 exp_pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: exp of pPowerSpectrum_fx */
- Word32 *pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i/o: inverse power spectrum */
- Word16 exp_pPowerSpectrumMsInv_fx[CPE_CHANNELS], /* i/o: exp of pPowerSpectrumMsInv_fx */
- Word32 *inv_spectrum_fx[CPE_CHANNELS][NB_DIV], /* i : inverse spectrum */
- Word16 exp_inv_spectrum_fx[CPE_CHANNELS], /* i : exp of inverse spectrum */
- const Word16 frameno, /* i : flag indicating index of current subfr. */
- const Word16 sp_aud_decision0, /* i : sp_aud_decision0 */
- const Word32 element_brate, /* i : element bitrate */
+ STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: MDCT stereo encoder structure */
+ Word16 ms_mask[2][MAX_SFB], /* i : bandwise MS mask */
+ const IGF_ENC_INSTANCE_HANDLE hIGFEnc[CPE_CHANNELS], /* i : instance handle of IGF Encoder */
+ const Word16 igfGridIdx, /* i : IGF grid index */
+ Encoder_State *sts[CPE_CHANNELS], /* i : Encoder state */
+ Word32 *pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */
+ Word16 *exp_pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: exp of pPowerSpectrum_fx */
+ Word32 *pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i/o: inverse power spectrum */
+ Word16 *q_pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i/o: Q of pPowerSpectrumMsInv_fx */
+ Word32 *inv_spectrum_fx[CPE_CHANNELS][NB_DIV], /* i : inverse spectrum */
+ Word16 exp_inv_spectrum_fx[CPE_CHANNELS], /* i : exp of inverse spectrum */
+ const Word16 frameno, /* i : flag indicating index of current subfr. */
+ const Word16 sp_aud_decision0, /* i : sp_aud_decision0 */
+ const Word32 element_brate, /* i : element bitrate */
const Word16 mct_on )
{
- Word32 *pPowerSpectrumParameter_fx[NB_DIV]; /* If it is NULL it informs a function that specific handling is needed */
+ Word32 *pPowerSpectrumParameter_fx[NB_DIV]; /* If it is NULL it informs a function that specific handling is needed */
+ Word16 *exp_pPowerSpectrumParameter_fx[NB_DIV]; /* If it is NULL it informs a function that specific handling is needed */
Word32 *pPowerSpectrumParameterMsInv_fx[NB_DIV];
+ Word16 *q_pPowerSpectrumParameterMsInv_fx[NB_DIV];
Word16 coreMsMask[N_MAX];
Word16 sfb, ch, last_core_acelp;
STEREO_MDCT_BAND_PARAMETERS *sfbConf;
- Word16 exp_pPowerSpectrum[L_FRAME48k];
+ Word32 common_pPowerSpectrum_fx[N_MAX];
+
+ set32_fx( common_pPowerSpectrum_fx, 0, N_MAX );
+
+ Word16 common_pPowerSpectrum_exp = MIN16B;
+ move16();
/* 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)
@@ -2678,9 +2623,13 @@ void IGFEncApplyStereo_fx(
IF( EQ_16( sts[0]->core, TCX_20_CORE ) && !sts[0]->hTcxEnc->fUseTns[frameno] && !sts[1]->hTcxEnc->fUseTns[frameno] )
{
pPowerSpectrumParameter_fx[0] = &pPowerSpectrum_fx[0][0];
+ exp_pPowerSpectrumParameter_fx[0] = &exp_pPowerSpectrum_fx[0][0];
pPowerSpectrumParameter_fx[1] = &pPowerSpectrum_fx[1][0];
+ exp_pPowerSpectrumParameter_fx[1] = &exp_pPowerSpectrum_fx[1][0];
pPowerSpectrumParameterMsInv_fx[0] = pPowerSpectrumMsInv_fx[0][0];
pPowerSpectrumParameterMsInv_fx[1] = pPowerSpectrumMsInv_fx[1][0];
+ q_pPowerSpectrumParameterMsInv_fx[0] = q_pPowerSpectrumMsInv_fx[0][0];
+ q_pPowerSpectrumParameterMsInv_fx[1] = q_pPowerSpectrumMsInv_fx[1][0];
}
ELSE
{
@@ -2688,6 +2637,8 @@ void IGFEncApplyStereo_fx(
pPowerSpectrumParameter_fx[1] = NULL;
pPowerSpectrumParameterMsInv_fx[0] = NULL;
pPowerSpectrumParameterMsInv_fx[1] = NULL;
+ q_pPowerSpectrumParameterMsInv_fx[0] = NULL;
+ q_pPowerSpectrumParameterMsInv_fx[1] = NULL;
}
FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
{
@@ -2696,22 +2647,42 @@ void IGFEncApplyStereo_fx(
IGF_UpdateInfo( hIGFEnc[ch], igfGridIdx );
IGF_CalculateStereoEnvelope_fx( hIGFEnc[ch], sts[ch]->hTcxEnc->spectrum_fx[frameno], sts[ch]->hTcxEnc->spectrum_e[frameno], inv_spectrum_fx[ch][frameno],
exp_inv_spectrum_fx[ch], pPowerSpectrumParameter_fx[ch], exp_pPowerSpectrum_fx[ch], pPowerSpectrumParameterMsInv_fx[ch],
- exp_pPowerSpectrumMsInv_fx[ch], igfGridIdx, coreMsMask, sts[ch]->hTranDet->transientDetector.bIsAttackPresent, last_core_acelp );
+ q_pPowerSpectrumParameterMsInv_fx[ch], igfGridIdx, coreMsMask, sts[ch]->hTranDet->transientDetector.bIsAttackPresent, last_core_acelp, mct_on );
IF( EQ_16( sts[ch]->core, TCX_20_CORE ) )
{
pPowerSpectrumParameter_fx[ch] = pPowerSpectrum_fx[ch];
+ exp_pPowerSpectrumParameter_fx[ch] = exp_pPowerSpectrum_fx[ch];
}
ELSE
{
pPowerSpectrumParameter_fx[ch] = NULL;
}
- set16_fx( exp_pPowerSpectrum, exp_pPowerSpectrum_fx[ch], L_FRAME48k );
+ IGF_Whitening_ivas_fx( hIGFEnc[ch], pPowerSpectrumParameter_fx[ch], exp_pPowerSpectrumParameter_fx[ch], 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_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 );
+ IF( pPowerSpectrumParameter_fx[ch] )
+ {
+ Word16 length = N_MAX;
+ move16();
+ if ( mct_on )
+ {
+ length = L_FRAME48k;
+ move16();
+ }
+ FOR( Word16 i = 0; i < length; i++ )
+ {
+ common_pPowerSpectrum_exp = s_max( common_pPowerSpectrum_exp, exp_pPowerSpectrumParameter_fx[ch][i] );
+ }
- IGF_ErodeSpectrum_ivas_fx( hIGFEnc[ch], sts[ch]->hTcxEnc->spectrum_fx[frameno], pPowerSpectrumParameter_fx[ch], exp_pPowerSpectrum_fx[ch], igfGridIdx, mct_on );
+ FOR( Word16 i = 0; i < length; i++ )
+ {
+ common_pPowerSpectrum_fx[i] = L_shl( pPowerSpectrumParameter_fx[ch][i], sub( exp_pPowerSpectrumParameter_fx[ch][i], common_pPowerSpectrum_exp ) );
+ move32();
+ }
+ pPowerSpectrumParameter_fx[ch] = common_pPowerSpectrum_fx;
+ }
+ IGF_ErodeSpectrum_ivas_fx( hIGFEnc[ch], sts[ch]->hTcxEnc->spectrum_fx[frameno], pPowerSpectrumParameter_fx[ch], common_pPowerSpectrum_exp, igfGridIdx, mct_on );
}
return;
}
diff --git a/lib_enc/igf_enc_fx.c b/lib_enc/igf_enc_fx.c
index f78ad202578f0f29537006d5e6b7694c97b9fce4..a7b5eabb3f3701a86f4ab7d6e9859fcb83f37194 100644
--- a/lib_enc/igf_enc_fx.c
+++ b/lib_enc/igf_enc_fx.c
@@ -781,6 +781,87 @@ Word16 IGF_getCrest( /**< ou
return crest;
}
+Word16 IGF_getCrest_ivas( /**< out: Q15| crest factor */
+ Word16 *crest_exp, /**< out: | exponent of crest factor */
+ const Word32 *powerSpectrum, /**< in: Q31 | power spectrum */
+ const Word16 *powerSpectrum_exp, /**< in: | exponent of power spectrum */
+ const Word16 start, /**< in: Q0 | start subband index */
+ const Word16 stop /**< in: Q0 | stop subband index */
+)
+{
+ Word16 i;
+ Word16 x;
+ Word16 s;
+ Word32 x_eff32;
+ Word16 x_max;
+ Word16 crest;
+ Word16 tmp;
+ Word32 tmp32;
+
+ x_eff32 = 0;
+ move32();
+ x_max = 0;
+ move16();
+ crest = 16384 /*.5f Q15*/;
+ move16();
+ *crest_exp = 1;
+ move16();
+
+ FOR( i = start; i < stop; i++ )
+ {
+ /*x = max(0, (int)(log(powerSpectrum[i]) * INV_LOG_2));*/
+
+ /*see IGF_getSFM for more comment */
+ x = sub( sub( powerSpectrum_exp[i], norm_l( powerSpectrum[i] ) ), 1 ); /*Q0*/
+ if ( powerSpectrum[i] == 0 ) /*special case: energy is zero*/
+ {
+ x = 0;
+ move16();
+ }
+ x = s_max( 0, x );
+ x_eff32 = L_mac0( x_eff32, x, x ); /*Q0*/
+ x_max = s_max( x_max, x ); /*Q0*/
+ }
+
+ /*x_eff /= (stop - start);*/
+ x_eff32 = BASOP_Util_Divide3216_Scale( x_eff32, sub( stop, start ), &s ); /*Q-1, s*/
+ s = add( s, 32 ); /*make x_eff Q31*/
+
+ /*trunkate to int*/
+ x_eff32 = L_shr( x_eff32, sub( 31, s ) );
+ x_eff32 = L_shl( x_eff32, sub( 31, s ) );
+
+ test();
+ IF( x_eff32 > 0 && x_max > 0 )
+ {
+ /*crest = max(1.f, (float)x_max/sqrt(x_eff));*/
+ tmp32 = ISqrt32( x_eff32, &s ); /*Q31, s*/
+ tmp32 = Mpy_32_16_1( tmp32 /*Q31, s*/, x_max /*Q0*/ ); /*Q16, s*/
+ i = norm_l( tmp32 );
+ tmp32 = L_shl( tmp32, i ); /*Q31, s-i+15*/
+ crest = extract_h( tmp32 );
+ *crest_exp = add( sub( s, i ), 15 );
+ move16();
+ /* limit crest factor to a lower bound of 1, may overflow */
+ BASOP_SATURATE_WARNING_OFF_EVS
+ tmp = shl_sat( -1, sub( 15, *crest_exp ) ); /* build negative threshold */
+ tmp = add_sat( crest, tmp );
+ BASOP_SATURATE_WARNING_ON_EVS
+ if ( tmp < 0 )
+ {
+ crest = 1;
+ move16();
+ }
+ if ( tmp < 0 )
+ {
+ *crest_exp = 15;
+ move16();
+ }
+ }
+
+ return crest;
+}
+
/*************************************************************************
calculates spectral flatness measurment
**************************************************************************/
@@ -932,7 +1013,7 @@ Word16 IGF_getSFM_ivas_fx( /**< out: Q15| SFM value
/* n = sub(n,31); */ /*<- -Qx */
/* n = add(n,*energy_exp); */ /*<- +xExp */
- n = sub( sub( *energy_exp, norm_l( energy[i] ) ), 1 ); /*<-- short form*/
+ n = sub( sub( energy_exp[i], norm_l( energy[i] ) ), 1 ); /*<-- short form*/
if ( energy[i] == 0 ) /*special case: energy is zero*/
{
@@ -943,7 +1024,7 @@ Word16 IGF_getSFM_ivas_fx( /**< out: Q15| SFM value
n = s_max( 0, n );
num = L_add( num, L_deposit_l( n ) ); /*Q0*/
- denom = BASOP_Util_Add_Mant32Exp( energy[i], *energy_exp, denom, denom_exp, &denom_exp );
+ denom = BASOP_Util_Add_Mant32Exp( energy[i], energy_exp[i], denom, denom_exp, &denom_exp );
}
/* calculate SFM only if signal is present */
diff --git a/lib_enc/init_enc_fx.c b/lib_enc/init_enc_fx.c
index 98d7fe957f47adb8f9da1b1a1deea27e319e9360..ba1d47f7916b1dce1c00b4874932d67a4005a663 100644
--- a/lib_enc/init_enc_fx.c
+++ b/lib_enc/init_enc_fx.c
@@ -1,4 +1,4 @@
-/*====================================================================================
+/*====================================================================================
EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
====================================================================================*/
@@ -20,7 +20,6 @@
*
* Initialization of state variables
*-----------------------------------------------------------------------*/
-#if 1
ivas_error init_encoder_fx(
Encoder_State *st_fx /* i/o: Encoder static variables structure */
)
@@ -378,6 +377,8 @@ ivas_error init_encoder_fx(
move16();
st_fx->hVAD->L_snr_sum_vad_fx = 0;
move32();
+ st_fx->hVAD->q_L_snr_sum_vad = Q31;
+ move16();
}
ELSE
{
@@ -946,7 +947,7 @@ ivas_error init_encoder_fx(
move32();
return error;
}
-#endif
+
/*-----------------------------------------------------------------------*
* LPDmem_enc_init_fx()
*
@@ -1193,10 +1194,8 @@ ivas_error init_encoder_ivas_fx(
st->exp_mem_preemph_enc = 0;
move16();
-#if 1 // TODO: Float Initializations. To be removed later
st->active_cnt = 0;
move16();
-#endif
st->pst_mem_deemp_err_fx = 0;
move16();
@@ -1424,7 +1423,10 @@ ivas_error init_encoder_ivas_fx(
set32_fx( st->input_buff32_fx, 0, add( L_FRAME48k, add( L_FRAME48k, NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ) ) );
st->q_inp32 = Q31;
move16();
+ st->q_old_inp32 = Q31;
+ move16();
st->old_input_signal_fx = st->input_buff_fx;
+ st->old_input_signal32_fx = st->input_buff32_fx;
/* st->input_Fs / FRAMES_PER_SEC */
Word16 frame_length = extract_l( Mpy_32_32( st->input_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) );
@@ -1435,11 +1437,10 @@ ivas_error init_encoder_ivas_fx(
}
ELSE
{
- st->input32_fx = st->input_buff32_fx + Mpy_32_32( st->input_Fs, 42949673 ) /* 1/50 in Q31*/; // st->input_Fs / FRAMES_PER_SEC
+ // st->input32_fx = st->input_buff32_fx + Mpy_32_32( st->input_Fs, 42949673 ) /* 1/50 in Q31*/; // st->input_Fs / FRAMES_PER_SEC
+ st->input32_fx = st->input_buff32_fx + frame_length;
st->input_fx = st->input_buff_fx + frame_length;
}
-#if 1 // TODO: To be removed later
-#endif
}
ELSE
{
@@ -1454,8 +1455,6 @@ ivas_error init_encoder_ivas_fx(
st->buf_speech_enc = NULL;
st->buf_wspeech_enc = NULL;
st->input_buff_fx = NULL;
-#if 1
-#endif
}
/*-----------------------------------------------------------------*
@@ -1573,9 +1572,9 @@ ivas_error init_encoder_ivas_fx(
* DTX
*-----------------------------------------------------------------*/
- st->lp_speech_fx = 11520; /*Q8 (45.0) */ /* Initialize the long-term active speech level in dB */
- move16();
- st->lp_noise_fx = 0;
+ st->lp_speech_32fx = 754974720; /*Q24 (45.0) */ /* Initialize the long-term active speech level in dB */
+ move32();
+ st->lp_noise_32fx = 0;
move16();
st->flag_noisy_speech_snr = 0;
move16();
@@ -1956,12 +1955,6 @@ ivas_error init_encoder_ivas_fx(
st->hTcxEnc->spectrum_e[0] = st->hTcxEnc->spectrum_e[1] = 0;
move16();
move16();
-#if 1
- // set_f( st->hTcxEnc->spectrum_long, 0, N_MAX );
- // st->hTcxEnc->spectrum[0] = st->hTcxEnc->spectrum_long;
- // st->hTcxEnc->spectrum[1] = st->hTcxEnc->spectrum_long + N_TCX10_MAX;
- // set_f( st->hTcxEnc->old_out, 0, L_FRAME32k );
-#endif
set16_fx( st->hTcxEnc->old_out_fx, 0, L_FRAME32k );
st->hTcxEnc->Q_old_out = 0;
diff --git a/lib_enc/inov_enc_fx.c b/lib_enc/inov_enc_fx.c
index fe22ee398de7c7a3e1652e2229cdcd756af00fca..01ba794ea8bec3504d94f908c17b675afa0c9415 100644
--- a/lib_enc/inov_enc_fx.c
+++ b/lib_enc/inov_enc_fx.c
@@ -370,7 +370,7 @@ Word16 inov_encode_ivas_fx(
Word16 shift,
Word16 Q_new )
{
- Word16 dn[2 * L_SUBFR], Qdn;
+ Word16 dn[2 * L_SUBFR], Qdn, Qcn;
Word16 nBits, cmpl_flag;
Word16 stack_pulses;
Word16 g1, g2;
@@ -378,7 +378,7 @@ Word16 inov_encode_ivas_fx(
Word16 acelpautoc;
BSTR_ENC_HANDLE hBstr = st_fx->hBstr;
Word16 i, k;
- Word16 Qxn, Rw_q, j, max_xn2;
+ Word16 Qxn, max_xn2;
stack_pulses = 0;
move16();
@@ -416,20 +416,22 @@ Word16 inov_encode_ivas_fx(
test();
test();
+ Qcn = Q_new;
+ move16();
IF( GT_32( core_brate, ACELP_13k20 ) && !Opt_AMR_WB && EQ_16( L_subfr, L_SUBFR ) )
{
acelpautoc = 1;
move16();
- Word16 q_h1 = sub( 14, norm_s( h2[0] ) );
- Scale_sig( h2, L_SUBFR, sub( 11, q_h1 ) ); /* set h2[] in Q11*/
cb_shape_fx( 1, 1, 0, sharpFlag, 0, g1, g2, p_Aq, h2, tilt_code, shr( add( pt_pitch, 26 ), 6 ), 0, L_SUBFR );
/* h2: Q11, Rw: (Rw_e)Q */
- corr_hh_ivas_fx( h2, Rw, &Rw_q, L_subfr ); // Q(Rw) = Q11-2
- E_ACELP_conv_ivas_fx( xn2, h2, cn ); // Qcn = Qxn2
+ /* Rw_e = */ E_ACELP_hh_corr( h2, Rw, L_SUBFR, 3 );
+
+ E_ACELP_conv( xn2, h2, cn );
/* dn_e -> Rw_e*Q_xn */
- j = E_ACELP_toeplitz_mul_fx( Rw, cn, dn, L_SUBFR, 1 );
- Qdn = add( add( Qxn, Rw_q ), add( j, 1 ) );
+ /*dn_e = */ E_ACELP_toeplitz_mul_fx( Rw, cn, dn, L_SUBFR, 1 );
+ Qdn = Qcn;
+ move16();
}
ELSE
{
@@ -442,6 +444,18 @@ Word16 inov_encode_ivas_fx(
Scale_sig( h2, L_SUBFR, sub( 11, q_h1 ) ); /* set h2[] in Q11*/
cb_shape_fx( 1, 1, 0, sharpFlag, 0, g1, g2, p_Aq, h2, tilt_code, shr( add( pt_pitch, 26 ), 6 ), 0, L_subfr );
corr_xh_ivas_fx( xn2, Qxn, dn, &Qdn, h2, L_subfr ); // Q(dn) = Q_new+1
+ IF( LT_16( Qdn, Qcn ) )
+ {
+ scale_sig( cn, L_subfr, sub( Qdn, Qcn ) );
+ Qcn = Qdn;
+ move16();
+ }
+ ELSE
+ {
+ scale_sig( dn, L_subfr, sub( Qcn, Qdn ) );
+ Qdn = Qcn;
+ move16();
+ }
}
/*-----------------------------------------------------------------*
@@ -607,7 +621,7 @@ Word16 inov_encode_ivas_fx(
}
ELSE
{
- acelp_fast_fx( hBstr, nBits, dn, Qdn, cn, Q_new, h2, code, y2, L_subfr );
+ acelp_fast_fx( hBstr, nBits, dn, Qdn, cn, Qcn, h2, code, y2, L_subfr );
}
}
ELSE IF( ( EQ_16( st_fx->idchan, 1 ) && LE_16( st_fx->acelp_cfg.fixed_cdk_index[idx2], 7 ) ) || ( st_fx->idchan == 0 && LE_16( st_fx->acelp_cfg.fixed_cdk_index[idx2], 3 ) ) )
@@ -618,7 +632,7 @@ Word16 inov_encode_ivas_fx(
}
ELSE
{
- acelp_fast_fx( hBstr, st_fx->acelp_cfg.fixed_cdk_index[idx2], dn, Qdn, cn, Q_new, h2, code, y2, L_SUBFR );
+ acelp_fast_fx( hBstr, st_fx->acelp_cfg.fixed_cdk_index[idx2], dn, Qdn, cn, Qcn, h2, code, y2, L_SUBFR );
}
}
ELSE
@@ -647,7 +661,7 @@ Word16 inov_encode_ivas_fx(
{
FOR( k = 0; k < L_SUBFR - i; k++ )
{
- y2[i + k] = add_sat( y2[i + k], round_fx( L_shl( L_mult( code[i], h2[k] ), sh ) ) ); // Q9 Added saturation: needs to be rechecked
+ y2[i + k] = add_sat( y2[i + k], round_fx_sat( L_shl_sat( L_mult( code[i], h2[k] ), sh ) ) ); // Q9 Added saturation: needs to be rechecked
move16();
}
}
diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c
index f5d3c4d73400b17391cda39f757af1481d8ee862..5737aad2f0166089b831bd4378af4c6c4dd86841 100644
--- a/lib_enc/ivas_core_enc_fx.c
+++ b/lib_enc/ivas_core_enc_fx.c
@@ -113,7 +113,7 @@ ivas_error ivas_core_enc_fx(
Word16 diff_nBits;
ivas_error error;
Word16 max_num_indices_BWE;
- Word16 i;
+ Word16 i, shift, Q_min;
set32_fx( new_swb_speech_buffer_fx, 0, L_FRAME48k + STEREO_DFT_OVL_MAX );
set16_fx( new_swb_speech_buffer_fx_16, 0, L_FRAME48k + STEREO_DFT_OVL_MAX );
@@ -531,11 +531,16 @@ ivas_error ivas_core_enc_fx(
st->hTcxEnc->exp_buf_speech_ltp = st->exp_buf_speech_enc;
move16();
}
- Scale_sig( st->input_fx, input_frame, sub( -1, st->q_inp ) );
- Scale_sig( st->input_fx - input_frame, input_frame, sub( -1, st->q_old_inp ) );
- st->q_inp = -1;
+ shift = norm_arr( st->input_fx, input_frame );
+ Q_min = s_max( -2, add( st->q_inp, shift ) );
+ scale_sig( st->input_fx, input_frame, sub( Q_min, st->q_inp ) );
+ st->q_inp = Q_min;
move16();
- st->q_old_inp = -1;
+
+ shift = norm_arr( st->input_fx - input_frame, input_frame );
+ Q_min = s_max( -2, add( st->q_old_inp, shift ) );
+ scale_sig( st->input_fx - input_frame, input_frame, sub( Q_min, st->q_old_inp ) );
+ st->q_old_inp = Q_min;
move16();
}
@@ -675,12 +680,6 @@ ivas_error ivas_core_enc_fx(
wb_bwe_enc_ivas_fx( st, new_inp_resamp16k_fx[n] );
}
- IF( st->hBWE_FD != NULL )
- {
- Scale_sig( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k, Q1 ); // Q-1 -> Q0
- st->Q_old_wtda = add( st->Q_old_wtda, Q1 );
- move16();
- }
/*---------------------------------------------------------------------*
* SWB(FB) TBE encoding
@@ -713,7 +712,7 @@ ivas_error ivas_core_enc_fx(
Word16 Q_shb_spch_16 = Q_shb_spch;
move16();
- Word16 shift = add( getScaleFactor16( shb_speech_fx, L_FRAME16k ), Q16 );
+ shift = add( getScaleFactor16( shb_speech_fx, L_FRAME16k ), Q16 );
Copy_Scale_sig_16_32_no_sat( shb_speech_fx, shb_speech_fx32, L_FRAME16k, shift ); // Q_shb_spch
Q_shb_spch = add( Q_shb_spch, shift );
@@ -725,8 +724,6 @@ ivas_error ivas_core_enc_fx(
Scale_sig( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k, shift ); // st->Q_old_wtda
}
- Word16 q_new_swb_speech_buffer = getScaleFactor16( new_swb_speech_buffer_fx_16, L_FRAME48k + STEREO_DFT_OVL_MAX );
- Scale_sig( new_swb_speech_buffer_fx_16, L_FRAME48k + STEREO_DFT_OVL_MAX, q_new_swb_speech_buffer ); // Q0->q_new_swb_speech_buffer
/* SWB TBE encoder */
test();
@@ -750,11 +747,9 @@ ivas_error ivas_core_enc_fx(
}
ELSE IF( EQ_16( st->extl, SWB_BWE ) || EQ_16( st->extl, FB_BWE ) )
{
- Copy_Scale_sig_32_16( shb_speech_fx32, shb_speech_fx, L_FRAME16k, -Q16 ); // Q_shb_spch - 16
- Scale_sig( new_swb_speech_buffer_fx_16, L_FRAME48k + STEREO_DFT_OVL_MAX, negate( q_new_swb_speech_buffer ) ); // q_new_swb_speech_buffer -> Q0
+ Copy_Scale_sig_32_16( shb_speech_fx32, shb_speech_fx, L_FRAME16k, -Q16 ); // Q_shb_spch - 16
/* SWB(FB) BWE encoder */
- swb_bwe_enc_ivas_fx( st, last_element_mode, old_inp_12k8_fx[n], old_inp_16k_fx[n], old_syn_12k8_16k_fx[n], new_swb_speech_fx_16, shb_speech_fx, sub( Q_shb_spch, Q16 ), sub( Q_new[n], 1 ) );
- Scale_sig( new_swb_speech_buffer_fx_16, L_FRAME48k + STEREO_DFT_OVL_MAX, q_new_swb_speech_buffer ); // Q0 -> q_new_swb_speech_buffer
+ swb_bwe_enc_ivas_fx( st, last_element_mode, old_inp_12k8_fx[n], old_inp_16k_fx[n], old_syn_12k8_16k_fx[n], new_swb_speech_fx_16, st->q_inp, shb_speech_fx, sub( Q_shb_spch, Q16 ), sub( Q_new[n], 1 ) );
}
Scale_sig( old_syn_12k8_16k_fx[n], L_FRAME16k, sub( Q1, Q_new[n] ) ); // Q0
@@ -776,6 +771,9 @@ ivas_error ivas_core_enc_fx(
* Inter-channel BWE encoding
*-------------------------------------------------------------------*/
+ Word16 q_new_swb_speech_buffer = getScaleFactor16( new_swb_speech_buffer_fx_16, L_FRAME48k + STEREO_DFT_OVL_MAX );
+ Scale_sig( new_swb_speech_buffer_fx_16, L_FRAME48k + STEREO_DFT_OVL_MAX, q_new_swb_speech_buffer ); // st->q_inp+q_new_swb_speech_buffer
+ q_new_swb_speech_buffer = add( st->q_inp, q_new_swb_speech_buffer );
test();
test();
IF( n == 0 && GE_32( input_Fs, 32000 ) && hStereoICBWE != NULL )
@@ -784,7 +782,7 @@ ivas_error ivas_core_enc_fx(
stereo_icBWE_preproc_fx( hCPE, input_frame, new_swb_speech_buffer_fx_16 /*tmp buffer*/, q_new_swb_speech_buffer );
q_new_swb_speech_buffer = add( q_new_swb_speech_buffer, 16 );
- Copy_Scale_sig_16_32_no_sat( new_swb_speech_buffer_fx_16, new_swb_speech_buffer_fx, L_FRAME48k + STEREO_DFT_OVL_MAX, Q16 ); // q_new_swb_speech_buffer - 16 - > q_new_swb_speech_buffer
+ Copy_Scale_sig_16_32_no_sat( new_swb_speech_buffer_fx_16, new_swb_speech_buffer_fx, L_FRAME48k + STEREO_DFT_OVL_MAX, Q16 ); // q_new_swb_speech_buffer+st->q_inp - 16 - > q_new_swb_speech_buffer+st->q_inp
Copy_Scale_sig_16_32_no_sat( voice_factors_fx[0], voice_factors_fx32[0], NB_SUBFR16k, Q16 ); // Q31
stereo_icBWE_enc_ivas_fx( hCPE, shb_speech_fx32, sub( Q31, Q_shb_spch ), new_swb_speech_buffer_fx, sub( Q31, q_new_swb_speech_buffer ), voice_factors_fx32[0] );
diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c
index 3d7d87bc201f5819e1b2f190d42a6c29dd9c5f54..b378eabad1f8111a2abe65ff33a056cb9b3e7950 100644
--- a/lib_enc/ivas_core_pre_proc_front_fx.c
+++ b/lib_enc/ivas_core_pre_proc_front_fx.c
@@ -58,10 +58,6 @@
static void calculate_energy_buffer_ivas_fx( CPE_ENC_HANDLE hCPE, Word32 enerBuffer_dft[], const Word16 no_channels, const Word32 input_Fs, Word16 enerBuffer_dft_e[] );
-#ifdef IVAS_FIXED_ENC
-static void calculate_energy_buffer_fx( CPE_ENC_HANDLE hCPE, Word64 enerBuffer_dft_fx[], Word16 *enerBuffer_dft_q_fx, const Word16 no_channels, const Word32 input_Fs );
-#endif
-
/*-------------------------------------------------------------------*
* pre_proc_front_ivas()
*
@@ -162,7 +158,7 @@ ivas_error pre_proc_front_ivas_fx(
Word16 high_lpn_flag;
Word16 lsf_new_fx[M]; // Q2.56
Word16 localVAD_HE_SAD;
- Word16 non_staX_fx;
+ Word32 non_staX_fx;
Word16 alw_pitch_lag_12k8[2];
Word16 alw_voicing_fx[2];
Word16 last_core_orig;
@@ -195,7 +191,7 @@ ivas_error pre_proc_front_ivas_fx(
Word16 ncharX_fx;
Word16 ncharX_LR_fx; /* noise character for sp/mus classifier */
Word16 loc_harmLR_fx[CPE_CHANNELS]; /* harmonicity flag */
- Word16 non_staX_LR_fx; /* non-stationarity for sp/mus classifier */
+ Word32 non_staX_LR_fx; /* non-stationarity for sp/mus classifier */
Word16 sp_div_fx;
Word16 q_sp_div;
Word16 sp_div_LR_fx;
@@ -223,6 +219,7 @@ ivas_error pre_proc_front_ivas_fx(
Word16 res_cod_SNR_M_fx_e[STEREO_DFT_BAND_MAX];
Word16 Qfact_PS, q_lf_E_fx;
Word16 enerBuffer_fx_exp_buf[CLDFB_NO_CHANNELS_MAX];
+ Word32 bckr_temp[NB_BANDS];
#ifdef DEBUG_MODE_INFO
Word32 *in_buff_temp;
Word16 in_q_temp;
@@ -235,7 +232,7 @@ ivas_error pre_proc_front_ivas_fx(
Word16 Q_min = add( sub( 15, st->exp_old_inp_12k8 ), norm_arr( st->old_inp_12k8_fx, L_INP_MEM ) );
Word16 input_frame_full = shl( input_frame, 1 ); //(old frame input length + new frame input length)
Q_min = s_min( Q_min, sub( add( getScaleFactor32( st->input32_fx - input_frame, input_frame_full ), st->q_inp32 ), 16 ) );
- Q_min = s_max( -1, Q_min );
+ Q_min = s_max( -2, Q_min );
Copy_Scale_sig_32_16( st->input32_fx - input_frame, st->input_fx - input_frame, input_frame_full, sub( Q_min, st->q_inp32 ) ); // Q_min
st->q_inp = Q_min;
move16();
@@ -685,7 +682,7 @@ ivas_error pre_proc_front_ivas_fx(
}
st->mem_preemph_fx = shl_sat( st->mem_preemph_fx_q_inp, sub( -1, st->q_inp ) ); /*Q(-1) saturation added as float value goes above 65536 for +10 dB test (ltv48_MC512.wav and ltv48_MC51.wav) */
move16();
- st->mem_preemph_DFT_fx = shl( st->mem_preemph_DFT_fx_q_inp, sub( -1, st->q_inp ) ); /*Q(-1)*/
+ st->mem_preemph_DFT_fx = shl_sat( st->mem_preemph_DFT_fx_q_inp, sub( -1, st->q_inp ) ); /*Q(-1)*/
move16();
st->mem_preemph_q = st->q_inp;
move16();
@@ -745,7 +742,7 @@ ivas_error pre_proc_front_ivas_fx(
IF( hStereoClassif != NULL )
{
- IF( GT_32( sub( st->lp_speech_fx, extract_h( Etot_fx ) ), 25 << Q8 ) ) /*Q8*/
+ IF( GT_32( L_sub( st->lp_speech_32fx, Etot_fx ), 25 << Q24 ) ) /*Q8*/
{
hStereoClassif->silence_flag = 2;
move16();
@@ -781,21 +778,9 @@ ivas_error pre_proc_front_ivas_fx(
move16();
}
- Word16 scale = add( L_norm_arr( st->hNoiseEst->enrO_fx, NB_BANDS ), st->hNoiseEst->q_enrO );
- scale = s_min( scale, fr_bands_fx_q );
-
- scale_sig32( st->hNoiseEst->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();
-
#ifdef DEBUG_FORCE_DIR
if ( st->force_dir[0] != '\0' )
{
@@ -821,7 +806,7 @@ ivas_error pre_proc_front_ivas_fx(
test();
IF( ( hCPE != NULL && !( lr_vad_enabled && st->idchan == 0 ) ) || hSCE != NULL )
{
- *vad_flag_dtx = ivas_dtx_hangover_addition_fx( st, st->vad_flag, sub( st->lp_speech_fx, st->lp_noise_fx ), 0, vad_hover_flag, NULL, NULL, NULL ); /* Q0 */
+ *vad_flag_dtx = ivas_dtx_hangover_addition_fx( st, st->vad_flag, extract_h( L_sub( st->lp_speech_32fx, st->lp_noise_32fx ) ), 0, vad_hover_flag, NULL, NULL, NULL ); /* Q0 */
move16();
}
ELSE
@@ -919,21 +904,21 @@ ivas_error pre_proc_front_ivas_fx(
*----------------------------------------------------------------*/
noise_est_down_ivas_fx( fr_bands_fx, fr_bands_fx_q, st->hNoiseEst->bckr_fx, &st->hNoiseEst->q_bckr, tmpN_fx, &q_tmpN, tmpE_fx, &q_tmpE, st->min_band, st->max_band,
- &st->hNoiseEst->totalNoise_fx, Etot_fx, &st->hNoiseEst->Etot_last_32fx, &st->hNoiseEst->Etot_v_h2_fx );
+ &st->hNoiseEst->totalNoise_32fx, Etot_fx, &st->hNoiseEst->Etot_last_32fx, &st->hNoiseEst->Etot_v_h2_32fx );
test();
IF( lr_vad_enabled && st->idchan == 0 )
{
- noise_est_down_ivas_fx( fr_bands_LR_fx[0], fr_bands_LR_fx_q[0], hCPE->hFrontVad[0]->hNoiseEst->bckr_fx, &hCPE->hFrontVad[0]->hNoiseEst->q_bckr, tmpN_LR_fx[0], &q_tmpN_LR[0], tmpE_LR_fx[0], &q_tmpE_LR[0], st->min_band, st->max_band, &hCPE->hFrontVad[0]->hNoiseEst->totalNoise_fx, L_deposit_h( Etot_LR_fx[0] ), &hCPE->hFrontVad[0]->hNoiseEst->Etot_last_32fx, &hCPE->hFrontVad[0]->hNoiseEst->Etot_v_h2_fx );
- noise_est_down_ivas_fx( fr_bands_LR_fx[1], fr_bands_LR_fx_q[1], hCPE->hFrontVad[1]->hNoiseEst->bckr_fx, &hCPE->hFrontVad[1]->hNoiseEst->q_bckr, tmpN_LR_fx[1], &q_tmpN_LR[1], tmpE_LR_fx[1], &q_tmpE_LR[1], st->min_band, st->max_band, &hCPE->hFrontVad[1]->hNoiseEst->totalNoise_fx, L_deposit_h( Etot_LR_fx[1] ), &hCPE->hFrontVad[1]->hNoiseEst->Etot_last_32fx, &hCPE->hFrontVad[1]->hNoiseEst->Etot_v_h2_fx );
+ noise_est_down_ivas_fx( fr_bands_LR_fx[0], fr_bands_LR_fx_q[0], hCPE->hFrontVad[0]->hNoiseEst->bckr_fx, &hCPE->hFrontVad[0]->hNoiseEst->q_bckr, tmpN_LR_fx[0], &q_tmpN_LR[0], tmpE_LR_fx[0], &q_tmpE_LR[0], st->min_band, st->max_band, &hCPE->hFrontVad[0]->hNoiseEst->totalNoise_32fx, L_deposit_h( Etot_LR_fx[0] ), &hCPE->hFrontVad[0]->hNoiseEst->Etot_last_32fx, &hCPE->hFrontVad[0]->hNoiseEst->Etot_v_h2_32fx );
+ noise_est_down_ivas_fx( fr_bands_LR_fx[1], fr_bands_LR_fx_q[1], hCPE->hFrontVad[1]->hNoiseEst->bckr_fx, &hCPE->hFrontVad[1]->hNoiseEst->q_bckr, tmpN_LR_fx[1], &q_tmpN_LR[1], tmpE_LR_fx[1], &q_tmpE_LR[1], st->min_band, st->max_band, &hCPE->hFrontVad[1]->hNoiseEst->totalNoise_32fx, L_deposit_h( Etot_LR_fx[1] ), &hCPE->hFrontVad[1]->hNoiseEst->Etot_last_32fx, &hCPE->hFrontVad[1]->hNoiseEst->Etot_v_h2_32fx );
- 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
+ corr_shiftL_fx = correlation_shift_fx( extract_h( hCPE->hFrontVad[0]->hNoiseEst->totalNoise_32fx ) ); // Q15
+ corr_shiftR_fx = correlation_shift_fx( extract_h( hCPE->hFrontVad[1]->hNoiseEst->totalNoise_32fx ) ); // Q15
}
- *relE_fx = sub( extract_h( Etot_fx ), st->lp_speech_fx ); // Q8
+ *relE_fx = sub( extract_h( Etot_fx ), extract_h( st->lp_speech_32fx ) ); // Q8
move16();
- corr_shift_fx = correlation_shift_fx( st->hNoiseEst->totalNoise_fx ); /* Q15 */
+ corr_shift_fx = correlation_shift_fx( extract_h( st->hNoiseEst->totalNoise_32fx ) ); /* Q15 */
/*----------------------------------------------------------------*
* FD-CNG Noise Estimator
@@ -945,78 +930,41 @@ ivas_error pre_proc_front_ivas_fx(
test();
IF( st->idchan == 0 || EQ_16( element_mode, IVAS_CPE_MDCT ) )
{
- test();
- test();
- IF( EQ_16( element_mode, IVAS_CPE_TD ) && lr_vad_enabled && band_energies_LR_fx != NULL )
+ Word16 norm;
+ norm = L_norm_arr( st->hFdCngEnc->msPeriodog_fx, NPART );
+ IF( NE_16( norm, Q31 ) )
{
- Word16 normmsPeriodog_fx = Q31, zero_flag = 0;
- move16();
- move16();
- zero_flag = get_zero_flag( st->hFdCngEnc->msPeriodog_fx, NPART );
- IF( zero_flag )
- {
- normmsPeriodog_fx = getScaleFactor32( st->hFdCngEnc->msPeriodog_fx, NPART );
- move16();
- }
- st->hFdCngEnc->msPeriodog_fx_exp_cldfb = sub( 31, normmsPeriodog_fx );
- st->hFdCngEnc->msPeriodog_fx_exp_fft = sub( 31, normmsPeriodog_fx );
+ scale_sig32( st->hFdCngEnc->msPeriodog_fx, NPART, norm ); // exp:st->hFdCngEnc->msPeriodog_fx_exp-norm
+ st->hFdCngEnc->msPeriodog_fx_exp = sub( st->hFdCngEnc->msPeriodog_fx_exp, norm );
+ st->hFdCngEnc->msPeriodog_fx_exp_cldfb = sub( st->hFdCngEnc->msPeriodog_fx_exp_cldfb, norm );
+ st->hFdCngEnc->msPeriodog_fx_exp_fft = sub( st->hFdCngEnc->msPeriodog_fx_exp_fft, norm );
move16();
move16();
- 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();
+ }
+ norm = L_norm_arr( st->hFdCngEnc->msNoiseEst_old_fx, NPART );
+ IF( NE_16( norm, Q31 ) )
+ {
+ scale_sig32( st->hFdCngEnc->msNoiseEst_old_fx, NPART, norm ); // exp:st->hFdCngEnc->msNoiseEst_old_fx_exp-norm
+ st->hFdCngEnc->msNoiseEst_old_fx_exp = sub( st->hFdCngEnc->msNoiseEst_old_fx_exp, norm );
move16();
- zero_flag = get_zero_flag( st->hFdCngEnc->msNoiseEst_old_fx, NPART );
- IF( zero_flag )
- {
- msNoiseEst_Q = getScaleFactor32( st->hFdCngEnc->msNoiseEst_old_fx, NPART );
- scale_sig32( st->hFdCngEnc->msNoiseEst_old_fx, NPART, msNoiseEst_Q ); /* exp(st->hFdCngEnc->msNoiseEst_old_fx_exp - msNoiseEst_Q) */
- st->hFdCngEnc->msNoiseEst_old_fx_exp = sub( st->hFdCngEnc->msNoiseEst_old_fx_exp, msNoiseEst_Q );
- move16();
- }
+ }
+
+ test();
+ test();
+ IF( EQ_16( element_mode, IVAS_CPE_TD ) && lr_vad_enabled && band_energies_LR_fx != NULL )
+ {
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 );
}
ELSE
{
- Word16 normmsPeriodog_fx = Q31, zero_flag = 0;
- move16();
- move16();
- shift = getScaleFactor32( band_energies_fx, 2 * NB_BANDS );
- scale_sig32( band_energies_fx, 2 * NB_BANDS, shift );
- q_band_energies = add( q_band_energies, shift );
-
- zero_flag = get_zero_flag( st->hFdCngEnc->msPeriodog_fx, NPART ); /* Q0 */
- IF( zero_flag )
- {
- normmsPeriodog_fx = getScaleFactor32( st->hFdCngEnc->msPeriodog_fx, NPART );
- }
- st->hFdCngEnc->msPeriodog_fx_exp_cldfb = sub( 31, normmsPeriodog_fx );
- st->hFdCngEnc->msPeriodog_fx_exp_fft = sub( 31, normmsPeriodog_fx );
- move16();
- move16();
- 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_old_fx, NPART ); /* Q0 */
- IF( zero_flag )
+ norm = L_norm_arr( st->hFdCngEnc->hFdCngCom->periodog, PERIODOGLEN );
+ IF( NE_16( norm, Q31 ) )
{
- msNoiseEst_Q = getScaleFactor32( st->hFdCngEnc->msNoiseEst_old_fx, NPART );
- scale_sig32( st->hFdCngEnc->msNoiseEst_old_fx, NPART, msNoiseEst_Q ); /* exp(st->hFdCngEnc->msNoiseEst_old_fx_exp - msNoiseEst_Q) */
- st->hFdCngEnc->msNoiseEst_old_fx_exp = sub( st->hFdCngEnc->msNoiseEst_old_fx_exp, msNoiseEst_Q );
+ scale_sig32( st->hFdCngEnc->hFdCngCom->periodog, PERIODOGLEN, norm ); // exp:st->hFdCngEnc->hFdCngCom->exp_cldfb_periodog-norm
+ st->hFdCngEnc->hFdCngCom->exp_cldfb_periodog = sub( st->hFdCngEnc->hFdCngCom->exp_cldfb_periodog, norm );
move16();
}
- zero_flag = get_zero_flag( st->hFdCngEnc->hFdCngCom->periodog, PERIODOGLEN ); /* Q0 */
- Word16 normmsperiodog = 31;
- move16();
- IF( zero_flag )
- {
- normmsperiodog = getScaleFactor32( st->hFdCngEnc->hFdCngCom->periodog, PERIODOGLEN );
- }
- st->hFdCngEnc->hFdCngCom->exp_cldfb_periodog = sub( 31, normmsperiodog );
- move16();
perform_noise_estimation_enc_ivas_fx( band_energies_fx, sub( Q31, q_band_energies ), enerBuffer_fx, *enerBuffer_fx_exp, st->hFdCngEnc, input_Fs, hCPE );
}
@@ -1156,12 +1104,7 @@ ivas_error pre_proc_front_ivas_fx(
move16();
}
-#ifdef REMOVE_EVS_DUPLICATES
- analy_lp_ivas_fx( inp_12k8_fx, L_FRAME, L_look, ener_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lsp_old1_fx, alw_pitch_lag_12k8, alw_voicing_fx, INT_FS_12k8, element_mode, i, *Q_new, Q_r );
-#else
- analy_lp_ivas_fx( inp_12k8_fx, L_FRAME, L_look, ener_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lsp_old1_fx, alw_pitch_lag_12k8, alw_voicing_fx,
- INT_FS_12k8, i, *Q_new, Q_r );
-#endif
+ analy_lp_fx( inp_12k8_fx, L_FRAME, L_look, ener_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lsp_old1_fx, alw_pitch_lag_12k8, alw_voicing_fx, INT_FS_12k8, element_mode, i, *Q_new, Q_r );
FOR( Word16 idx = 0; idx < M + 1; idx++ )
{
@@ -1256,10 +1199,10 @@ ivas_error pre_proc_front_ivas_fx(
IF( LE_32( element_brate, IVAS_32k ) )
{
/* 1/4 pitch precision improvement */
- pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[0], &pitch_fr_fx[0], &voicing_fr_fx[0], 0, wsp_fx, 7 );
- pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[0], &pitch_fr_fx[1], &voicing_fr_fx[1], L_SUBFR, wsp_fx, 7 );
- pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[1], &pitch_fr_fx[2], &voicing_fr_fx[2], 2 * L_SUBFR, wsp_fx, 7 );
- pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[1], &pitch_fr_fx[3], &voicing_fr_fx[3], 3 * L_SUBFR, wsp_fx, 7 );
+ pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[0], &pitch_fr_fx[0], &voicing_fr_fx[0], 0, wsp_fx, 7, element_mode );
+ pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[0], &pitch_fr_fx[1], &voicing_fr_fx[1], L_SUBFR, wsp_fx, 7, element_mode );
+ pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[1], &pitch_fr_fx[2], &voicing_fr_fx[2], 2 * L_SUBFR, wsp_fx, 7, element_mode );
+ pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[1], &pitch_fr_fx[3], &voicing_fr_fx[3], 3 * L_SUBFR, wsp_fx, 7, element_mode );
}
ELSE
{
@@ -1286,7 +1229,7 @@ ivas_error pre_proc_front_ivas_fx(
* Update estimated noise energy and voicing cut-off frequency
*-----------------------------------------------------------------*/
- 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 ) ) ) );
+ Word16 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 ) );
@@ -1315,8 +1258,7 @@ ivas_error pre_proc_front_ivas_fx(
noise_est_ivas_fx( st, old_pitch1, tmpN_fx, epsP_fx, extract_h( 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, extract_h( st->hNoiseEst->Etot_l_lp_32fx ),
- st->hNoiseEst->Etot_v_h2_fx, &st->hNoiseEst->bg_cnt, st->lgBin_E_fx, &dummy_fx, S_map_fx,
- hStereoClassif, NULL, st->ini_frame );
+ st->hNoiseEst->Etot_v_h2_32fx, &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 )
@@ -1358,14 +1300,14 @@ ivas_error pre_proc_front_ivas_fx(
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,
- extract_h( hCPE->hFrontVad[0]->hNoiseEst->Etot_l_lp_32fx ), hCPE->hFrontVad[0]->hNoiseEst->Etot_v_h2_fx, &hCPE->hFrontVad[0]->hNoiseEst->bg_cnt,
+ extract_h( hCPE->hFrontVad[0]->hNoiseEst->Etot_l_lp_32fx ), hCPE->hFrontVad[0]->hNoiseEst->Etot_v_h2_32fx, &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 );
/* 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,
- extract_h( hCPE->hFrontVad[1]->hNoiseEst->Etot_l_lp_32fx ), hCPE->hFrontVad[1]->hNoiseEst->Etot_v_h2_fx, &hCPE->hFrontVad[1]->hNoiseEst->bg_cnt,
+ extract_h( hCPE->hFrontVad[1]->hNoiseEst->Etot_l_lp_32fx ), hCPE->hFrontVad[1]->hNoiseEst->Etot_v_h2_32fx, &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 );
}
@@ -1383,14 +1325,14 @@ ivas_error pre_proc_front_ivas_fx(
* Find spectral tilt
* UC and VC frame selection
*-----------------------------------------------------------------*/
+
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();
+ Copy_Scale_sig32( st->hNoiseEst->bckr_fx, bckr_temp, NB_BANDS, sub( scale, st->hNoiseEst->q_bckr ) );
+ fr_bands_fx_q = scale;
move16();
- 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,
+ find_tilt_ivas_fx( fr_bands_fx, fr_bands_fx_q, bckr_temp, scale, 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 );
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, extract_h( Etot_fx ), hp_E_fx,
@@ -1425,7 +1367,7 @@ 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 ); /* Q0 */
+ st->clas = signal_clas_ivas_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 );
@@ -1455,7 +1397,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 ), ( 31 - Q8 ) /* exp of cor_map_sum */, ( 31 - 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 - Q20 ) /* exp of non_staX_fx */, sub( 15, q_sp_div ) );
}
/*----------------------------------------------------------------*
@@ -1501,7 +1443,7 @@ ivas_error pre_proc_front_ivas_fx(
* Update of old per-band energy spectrum
*----------------------------------------------------------------*/
- ivas_long_enr_fx( st, extract_h( Etot_fx ), localVAD_HE_SAD, high_lpn_flag, NULL, 1, NULL, NULL );
+ 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 ); /* fr_bands_fx_q */
st->hNoiseEst->q_enrO = fr_bands_fx_q;
@@ -1510,7 +1452,7 @@ ivas_error pre_proc_front_ivas_fx(
test();
IF( lr_vad_enabled && st->idchan == 0 )
{
- ivas_long_enr_fx( st, -1, localVAD_HE_SAD, high_lpn_flag, hCPE->hFrontVad, CPE_CHANNELS, localVAD_HE_SAD_LR, Etot_LR_fx );
+ ivas_long_enr_fx( st, -16777216 /*-1 << 24*/, 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 ); // fr_bands_LR_fx_q
hCPE->hFrontVad[0]->hNoiseEst->q_enrO = fr_bands_LR_fx_q[0];
@@ -1732,69 +1674,6 @@ ivas_error pre_proc_front_ivas_fx(
return error;
}
-#ifdef IVAS_FIXED_ENC
-/*-------------------------------------------------------------------*
- * calculate_energy_buffer_fx()
- *
- * calculate DFT-based energies
- *--------------------------------------------------------------------*/
-
-static void calculate_energy_buffer_fx(
- CPE_ENC_HANDLE hCPE, /* i : CPE encoder structure */
- Word64 enerBuffer_dft_fx[], /* o : energy buffer */
- Word16 *enerBuffer_dft_q_fx,
- const Word16 no_channels, /* i : no. of used CLDFB channels */
- const Word32 input_Fs /* i : input sampling rate */
-)
-{
- Word16 i, j;
- Word64 nrg_DMX_fx[CLDFB_NO_CHANNELS_MAX];
- Word64 *p_nrg_DMX_fx;
- Word32 *pDFT_DMX_fx;
- Word16 *pDFT_DMX_q_fx;
- Word32 chan_width_bins_fx;
- Word16 band_res_dft_fx, chan_width_f_fx, start, stop;
-
- Word16 temp_q1 = 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 ) );
- chan_width_f_fx = 24000 / CLDFB_NO_CHANNELS_MAX;
- chan_width_bins_fx = L_shl( (Word32) div_s( chan_width_f_fx, band_res_dft_fx ), ( sub( add( temp_q1, 1 ), temp_q2 ) ) ); // Q16
-
- pDFT_DMX_fx = hCPE->hStereoDft->DFT_fx[0];
- pDFT_DMX_q_fx = hCPE->hStereoDft->DFT_q_fx;
- start = 1;
- p_nrg_DMX_fx = nrg_DMX_fx;
-
- *p_nrg_DMX_fx = Mpy_32_32( pDFT_DMX_fx[0], pDFT_DMX_fx[0] );
-
- FOR( i = 0; i < no_channels; i++ )
- {
- stop = (Word16) ( L_add( Mpy_32_16_1( chan_width_bins_fx, add( i, 1 ) ), 1 ) >> 1 );
- FOR( j = start; j < stop; j++ )
- {
- *p_nrg_DMX_fx = W_add( *p_nrg_DMX_fx, Mpy_32_32( pDFT_DMX_fx[2 * j], pDFT_DMX_fx[2 * j] ) );
- *p_nrg_DMX_fx = W_add( *p_nrg_DMX_fx, Mpy_32_32( pDFT_DMX_fx[2 * j + 1], pDFT_DMX_fx[2 * j + 1] ) );
- }
- enerBuffer_dft_q_fx[i] = 2 * pDFT_DMX_q_fx[i] - 31;
- start = stop;
- p_nrg_DMX_fx++;
- }
-
- FOR( i = 0; i < no_channels; i++ ) /* Consider only used channels, dependent on Fs */
- {
- enerBuffer_dft_fx[i] = nrg_DMX_fx[i] / 3;
- }
-
- /* Set remaining entries of enerBuffer to zero */
- FOR( ; i < CLDFB_NO_CHANNELS_MAX; i++ )
- {
- enerBuffer_dft_fx[i] = 0;
- }
- return;
-}
-#endif
/*-------------------------------------------------------------------*
* calculate_energy_buffer()
*
diff --git a/lib_enc/ivas_core_pre_proc_fx.c b/lib_enc/ivas_core_pre_proc_fx.c
index 6fe6b6720d17c1fd68c743c3fecdf2d309c8bc0f..623b38e6897d070920ad1d445b424c850292c7b1 100644
--- a/lib_enc/ivas_core_pre_proc_fx.c
+++ b/lib_enc/ivas_core_pre_proc_fx.c
@@ -462,7 +462,7 @@ ivas_error pre_proc_ivas_fx(
IF( EQ_16( st->coder_type, GENERIC ) || EQ_16( st->coder_type, VOICED ) || EQ_16( st->coder_type, TRANSITION ) )
{
test();
- IF( GE_32( element_brate, FRMT_SHP_MIN_BRATE_IVAS ) && GT_16( st->lp_noise_fx, FORMANT_SHARPENING_NOISE_THRESHOLD_FX ) )
+ IF( GE_32( element_brate, FRMT_SHP_MIN_BRATE_IVAS ) && GT_32( st->lp_noise_32fx, FORMANT_SHARPENING_NOISE_THRESHOLD_FX << 16 ) )
{
st->sharpFlag = 0;
move16();
@@ -886,8 +886,11 @@ ivas_error ivas_compute_core_buffers_fx(
IF( EQ_16( st->bwidth, WB ) )
{
- 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 */
+ 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) */
+ scale_sig( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k, sub( Q_old_inp_16k, st->Q_old_wtda ) ); // st->Q_old_wtda->Q_old_inp_16k
+ 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 ) );
+ st->Q_old_wtda = Q_old_inp_16k;
+ move16();
}
}
ELSE IF( EQ_16( element_mode, IVAS_CPE_TD ) )
@@ -898,8 +901,11 @@ 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, 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 */
+ 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) */
+ scale_sig( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k, sub( Q_old_inp_16k, st->Q_old_wtda ) ); // st->Q_old_wtda->Q_old_inp_16k
+ 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 ) );
+ st->Q_old_wtda = Q_old_inp_16k;
+ move16();
}
}
ELSE IF( element_mode == IVAS_SCE )
@@ -1134,20 +1140,11 @@ ivas_error ivas_compute_core_buffers_fx(
IF( Q_new )
{
-#ifdef REMOVE_EVS_DUPLICATES
- analy_lp_ivas_fx( inp_16k_fx, L_FRAME16k, L_look, ener_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lspold_enc_fx, st->pitch, st->voicing_fx, INT_FS_16k, element_mode, 0, sub( *Q_new, 1 ), Q_r );
-#else
- analy_lp_ivas_fx( inp_16k_fx, L_FRAME16k, L_look, ener_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lspold_enc_fx, st->pitch, st->voicing_fx, INT_FS_16k, 0, sub( *Q_new, 1 ), Q_r );
-#endif
+ analy_lp_fx( inp_16k_fx, L_FRAME16k, L_look, ener_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lspold_enc_fx, st->pitch, st->voicing_fx, INT_FS_16k, element_mode, 0, sub( *Q_new, 1 ), Q_r );
}
ELSE
{
-#ifdef REMOVE_EVS_DUPLICATES
- analy_lp_ivas_fx( inp_16k_fx, L_FRAME16k, L_look, ener_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lspold_enc_fx, st->pitch, st->voicing_fx, INT_FS_16k, element_mode, 0, -1, Q_r );
-
-#else
- analy_lp_ivas_fx( inp_16k_fx, L_FRAME16k, L_look, ener_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lspold_enc_fx, st->pitch, st->voicing_fx, INT_FS_16k, 0, -1, Q_r );
-#endif
+ analy_lp_fx( inp_16k_fx, L_FRAME16k, L_look, ener_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lspold_enc_fx, st->pitch, st->voicing_fx, INT_FS_16k, element_mode, 0, -1, Q_r );
}
/*--------------------------------------------------------------*
@@ -1174,11 +1171,8 @@ ivas_error ivas_compute_core_buffers_fx(
ELSE IF( GT_32( input_Fs, 8000 ) && EQ_32( sr_core, INT_FS_16k ) )
{
Copy( &old_inp_16k_fx[L_frame_tmp], st->old_inp_16k_fx, L_INP_MEM );
- IF( Q_new )
- {
- st->exp_old_inp_16k = sub( Q16, *Q_new ); //(*Q_new - 1)
- move16();
- }
+ st->exp_old_inp_16k = sub( Q16, *Q_new ); //(*Q_new - 1)
+ move16();
}
ELSE IF( GT_32( input_Fs, 8000 ) )
{
diff --git a/lib_enc/ivas_corecoder_enc_reconfig_fx.c b/lib_enc/ivas_corecoder_enc_reconfig_fx.c
index 2e09c42ed88a3f672723a0f9465157a031f56563..6a2748e1c7d1fafb83d1074ca97f07604372112f 100644
--- a/lib_enc/ivas_corecoder_enc_reconfig_fx.c
+++ b/lib_enc/ivas_corecoder_enc_reconfig_fx.c
@@ -38,6 +38,10 @@
#include "wmc_auto.h"
#include "ivas_prot_fx.h"
#include "math.h"
+#include "wmc_auto.h"
+#ifdef DBG_BITSTREAM_ANALYSIS
+#include
+#endif
/*-------------------------------------------------------------------*
* ivas_corecoder_enc_reconfig()
*
@@ -192,6 +196,9 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
move16();
temp_ind_list[i].nb_bits = hBstr->ind_list[i].nb_bits; /* Q0 */
move16();
+#ifdef DBG_BITSTREAM_ANALYSIS
+ strncpy( temp_ind_list[i].function_name, hBstr->ind_list[i].function_name, 100 );
+#endif
hBstr->ind_list[i].nb_bits = -1; /* Q0 */
move16();
}
@@ -213,24 +220,37 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
move16();
}
- Word16 q_com_sce = Q15;
+ Word16 q_com_sce = Q15, q_com_sce32 = Q31;
+ move16();
+ move16();
+ Word16 q_com_cpe = Q15, q_com_cpe32 = Q31;
move16();
- Word16 q_com_cpe = Q15;
move16();
IF( nSCE_old > 0 )
{
FOR( k = 0; k < nSCE_old; k++ )
{
shift = sub( getScaleFactor16( st_ivas->hSCE[k]->hCoreCoder[0]->old_input_signal_fx, input_frame ), Q1 );
- Scale_sig( st_ivas->hSCE[k]->hCoreCoder[0]->old_input_signal_fx, input_frame, shift ); /* st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp + shift */
+ 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 = sub( getScaleFactor16( st_ivas->hSCE[k]->hCoreCoder[0]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ) ), Q1 );
- Scale_sig( st_ivas->hSCE[k]->hCoreCoder[0]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), shift ); /* st_ivas->hSCE[k]->hCoreCoder[0]->q_inp + shift */
+ 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 );
+
+ shift = sub( getScaleFactor32( st_ivas->hSCE[k]->hCoreCoder[0]->old_input_signal32_fx, input_frame ), Q1 );
+ scale_sig32( st_ivas->hSCE[k]->hCoreCoder[0]->old_input_signal32_fx, input_frame, shift ); /* st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp + shift */
+ st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp32 = add( st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp32, shift );
+ move16();
+ q_com_sce32 = s_min( q_com_sce32, st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp32 );
+ shift = sub( getScaleFactor32( st_ivas->hSCE[k]->hCoreCoder[0]->input32_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ) ), Q1 );
+ scale_sig32( st_ivas->hSCE[k]->hCoreCoder[0]->input32_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_inp32 = add( st_ivas->hSCE[k]->hCoreCoder[0]->q_inp32, shift );
+ move16();
+ q_com_sce32 = s_min( q_com_sce32, st_ivas->hSCE[k]->hCoreCoder[0]->q_inp32 );
}
}
@@ -242,15 +262,26 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
FOR( n = 0; n < CPE_CHANNELS; n++ )
{
shift = sub( getScaleFactor16( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->old_input_signal_fx, input_frame ), Q1 );
- Scale_sig( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->old_input_signal_fx, input_frame, shift ); /* st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp + shift */
+ 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 = sub( getScaleFactor16( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ) ), Q1 );
- Scale_sig( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), shift ); /* st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp + shift */
+ 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 );
+
+ shift = sub( getScaleFactor32( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->old_input_signal32_fx, input_frame ), Q1 );
+ scale_sig32( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->old_input_signal32_fx, input_frame, shift ); /* st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp + shift */
+ st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp32 = add( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp32, shift );
+ move16();
+ q_com_cpe32 = s_min( q_com_cpe32, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp32 );
+ shift = sub( getScaleFactor32( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input32_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ) ), Q1 );
+ scale_sig32( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input32_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_inp32 = add( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp32, shift );
+ move16();
+ q_com_cpe32 = s_min( q_com_cpe32, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp32 );
}
}
}
@@ -259,14 +290,16 @@ 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 ) ); /* q_com */
+ 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 ) ); /* q_com */
+ 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_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 );
+ st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp32 = add( Q6, q_com );
+ move16();
move16();
}
}
@@ -277,14 +310,16 @@ 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 ) ); /* q_com */
+ 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 ) ); /* q_com */
+ 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_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 );
+ st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp32 = add( Q6, q_com );
+ move16();
move16();
}
}
@@ -301,7 +336,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
{
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 ); /* st_ivas->hSCE[0]->hCoreCoder[0]->q_inp32 */
- q_input_buff[0] = st_ivas->hSCE[0]->hCoreCoder[0]->q_inp32;
+ q_input_buff[0] = st_ivas->hSCE[0]->hCoreCoder[0]->q_old_inp32;
move16();
}
@@ -311,7 +346,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
IF( nCPE_old > 0 )
{
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;
+ q_input_buff[n + 1] = st_ivas->hCPE[0]->hCoreCoder[n]->q_old_inp32;
move16();
}
}
@@ -334,7 +369,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
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 ); /* st_ivas->hSCE[sce_id]->hCoreCoder[0]->q_inp32 */
- q_input_buff[sce_id] = st_ivas->hSCE[sce_id]->hCoreCoder[0]->q_inp32;
+ q_input_buff[sce_id] = st_ivas->hSCE[sce_id]->hCoreCoder[0]->q_old_inp32;
move16();
}
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 ) );
@@ -349,7 +384,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 ); /* 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;
+ q_input_buff[( cpe_id - st_ivas->nCPE ) * CPE_CHANNELS + n] = st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp32;
move16();
}
}
@@ -398,7 +433,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
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 ); /* q_input_buff[sce_id] */
- st_ivas->hSCE[sce_id]->hCoreCoder[0]->q_inp32 = q_input_buff[sce_id];
+ st_ivas->hSCE[sce_id]->hCoreCoder[0]->q_old_inp32 = q_input_buff[sce_id];
move16();
}
test();
@@ -475,7 +510,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 ); /* q_input_buff */
- st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp32 = q_input_buff[n];
+ st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp32 = q_input_buff[n];
move16();
}
}
@@ -517,6 +552,9 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
move16();
st_ivas->hSCE[0]->hCoreCoder[0]->hBstr->ind_list[i].nb_bits = temp_ind_list[i].nb_bits; /* Q0 */
move16();
+#ifdef DBG_BITSTREAM_ANALYSIS
+ strncpy( st_ivas->hSCE[0]->hCoreCoder[0]->hBstr->ind_list[i].function_name, temp_ind_list[i].function_name, 100 );
+#endif
}
nb_bits = add( nb_bits, temp_ind_list[i].nb_bits ); /* Q0 */
@@ -541,6 +579,9 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
move16();
st_ivas->hCPE[0]->hCoreCoder[0]->hBstr->ind_list[i].nb_bits = temp_ind_list[i].nb_bits; /* Q0 */
move16();
+#ifdef DBG_BITSTREAM_ANALYSIS
+ strncpy( st_ivas->hCPE[0]->hCoreCoder[0]->hBstr->ind_list[i].function_name, temp_ind_list[i].function_name, 100 );
+#endif
}
nb_bits = add( nb_bits, temp_ind_list[i].nb_bits ); /* Q0 */
@@ -560,7 +601,9 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
IF( st_ivas->nSCE )
{
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];
+ // st_ivas->hSCE[0]->hCoreCoder[0]->q_inp32 = q_input_buff[0];
+ st_ivas->hSCE[0]->hCoreCoder[0]->q_old_inp32 = q_input_buff[0];
+ move16();
move16();
}
@@ -569,7 +612,9 @@ 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 ); /* q_input_buff */
- st_ivas->hCPE[0]->hCoreCoder[n]->q_inp32 = q_input_buff[n + 1];
+ // st_ivas->hCPE[0]->hCoreCoder[n]->q_inp32 = q_input_buff[n + 1];
+ st_ivas->hCPE[0]->hCoreCoder[n]->q_old_inp32 = q_input_buff[n + 1];
+ move16();
move16();
}
}
@@ -579,7 +624,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
{
IF( NE_16( input_frame, len_inp_memory ) )
{
- Copy_Scale_sig32_16( st_ivas->hSCE[0]->hCoreCoder[0]->input_buff32_fx, st_ivas->hSCE[0]->hCoreCoder[0]->input_buff_fx, len_inp_memory, sub( add( Q16, 0 ), st_ivas->hSCE[0]->hCoreCoder[0]->q_inp32 ) ); // Q(q_data_fx) -> Q(q_input)
+ Copy_Scale_sig32_16( st_ivas->hSCE[0]->hCoreCoder[0]->input_buff32_fx, st_ivas->hSCE[0]->hCoreCoder[0]->input_buff_fx, len_inp_memory, sub( add( Q16, 0 ), st_ivas->hSCE[0]->hCoreCoder[0]->q_old_inp32 ) ); // Q(q_data_fx) -> Q(q_input)
st_ivas->hSCE[0]->hCoreCoder[0]->q_old_inp = 0;
move16();
Copy_Scale_sig32_16( st_ivas->hSCE[0]->hCoreCoder[0]->input_buff32_fx + sub( len_inp_memory, input_frame ), st_ivas->hSCE[0]->hCoreCoder[0]->input_buff_fx + sub( len_inp_memory, input_frame ), sub( len_inp_memory, input_frame ), sub( add( Q16, 0 ), st_ivas->hSCE[0]->hCoreCoder[0]->q_inp32 ) ); // Q(q_data_fx) -> Q(q_input)
@@ -588,7 +633,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
}
ELSE
{
- Copy_Scale_sig32_16( st_ivas->hSCE[0]->hCoreCoder[0]->input_buff32_fx, st_ivas->hSCE[0]->hCoreCoder[0]->input_buff_fx, len_inp_memory, sub( add( Q16, 0 ), st_ivas->hSCE[0]->hCoreCoder[0]->q_inp32 ) ); // Q(q_data_fx) -> Q(q_input)
+ Copy_Scale_sig32_16( st_ivas->hSCE[0]->hCoreCoder[0]->input_buff32_fx, st_ivas->hSCE[0]->hCoreCoder[0]->input_buff_fx, len_inp_memory, sub( add( Q16, 0 ), st_ivas->hSCE[0]->hCoreCoder[0]->q_old_inp32 ) ); // Q(q_data_fx) -> Q(q_input)
st_ivas->hSCE[0]->hCoreCoder[0]->q_old_inp = 0;
move16();
}
@@ -600,7 +645,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
{
IF( NE_16( input_frame, len_inp_memory ) )
{
- Copy_Scale_sig32_16( st_ivas->hCPE[0]->hCoreCoder[n]->input_buff32_fx, st_ivas->hCPE[0]->hCoreCoder[n]->input_buff_fx, len_inp_memory, sub( add( Q16, 0 ), st_ivas->hCPE[0]->hCoreCoder[n]->q_inp32 ) ); // Q(q_data_fx) -> Q(q_input)
+ Copy_Scale_sig32_16( st_ivas->hCPE[0]->hCoreCoder[n]->input_buff32_fx, st_ivas->hCPE[0]->hCoreCoder[n]->input_buff_fx, len_inp_memory, sub( add( Q16, 0 ), st_ivas->hCPE[0]->hCoreCoder[n]->q_old_inp32 ) ); // Q(q_data_fx) -> Q(q_input)
st_ivas->hCPE[0]->hCoreCoder[n]->q_old_inp = 0;
move16();
@@ -610,7 +655,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
}
ELSE
{
- Copy_Scale_sig32_16( st_ivas->hCPE[0]->hCoreCoder[n]->input_buff32_fx, st_ivas->hCPE[0]->hCoreCoder[n]->input_buff_fx, len_inp_memory, sub( add( Q16, 0 ), st_ivas->hCPE[0]->hCoreCoder[n]->q_inp32 ) ); // Q(q_data_fx) -> Q(q_input)
+ Copy_Scale_sig32_16( st_ivas->hCPE[0]->hCoreCoder[n]->input_buff32_fx, st_ivas->hCPE[0]->hCoreCoder[n]->input_buff_fx, len_inp_memory, sub( add( Q16, 0 ), st_ivas->hCPE[0]->hCoreCoder[n]->q_old_inp32 ) ); // Q(q_data_fx) -> Q(q_input)
st_ivas->hCPE[0]->hCoreCoder[n]->q_old_inp = 0;
move16();
}
diff --git a/lib_enc/ivas_cpe_enc_fx.c b/lib_enc/ivas_cpe_enc_fx.c
index a05493aa4680962e0f7a716c29863b6d55b20bda..0cd7532d57992f8787ac6000bfcad6f773c6cd08 100644
--- a/lib_enc/ivas_cpe_enc_fx.c
+++ b/lib_enc/ivas_cpe_enc_fx.c
@@ -113,7 +113,9 @@ 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];
+ Word32 orig_input_fx32[CPE_CHANNELS][L_FRAME48k];
Word16 Q_orig_inp[CPE_CHANNELS];
+ Word16 Q_orig_inp32[CPE_CHANNELS];
Word16 Etot_last_fx[CPE_CHANNELS];
Word32 tmp, input_Fs;
Word16 max_bwidth, ivas_format;
@@ -127,7 +129,7 @@ ivas_error ivas_cpe_enc_fx(
Word16 e_old_wsp[CPE_CHANNELS], q_old_wsp;
move16(); // Q_new
move16(); // Q_new
- Word16 q_com;
+ Word16 q_com, shift, q_min, gb;
error = IVAS_ERR_OK;
move32();
@@ -217,27 +219,32 @@ ivas_error ivas_cpe_enc_fx(
#endif
}
- Word16 Q_min = s_min( q_data_fx, add( sts[0]->q_inp32, L_norm_arr( sts[0]->input32_fx - input_frame, input_frame ) ) );
- scale_sig32( sts[0]->input32_fx - input_frame, input_frame, sub( Q_min, sts[0]->q_inp32 ) );
+ Word16 norm, Q_min = s_min( q_data_fx, add( sts[0]->q_old_inp32, L_norm_arr( sts[0]->input32_fx - input_frame, input_frame ) ) );
+ norm = L_norm_arr( data_fx_ch0, input_frame );
+ IF( data_fx_ch1 != NULL ) /*this may happen for cases with odd number of channels*/
+ {
+ Q_min = s_min( Q_min, add( sts[1]->q_old_inp32, L_norm_arr( sts[1]->input32_fx - input_frame, input_frame ) ) );
+ norm = s_min( norm, L_norm_arr( data_fx_ch1, input_frame ) );
+ }
+ scale_sig32( sts[0]->input32_fx - input_frame, input_frame, sub( Q_min, sts[0]->q_old_inp32 ) );
+ sts[0]->q_old_inp32 = Q_min;
+ move16();
Copy_Scale_sig32( data_fx_ch0, sts[0]->input32_fx, input_frame, sub( Q_min, q_data_fx ) ); // Q(Q_min)
sts[0]->q_inp32 = Q_min;
move16();
- Word16 norm = L_norm_arr( sts[0]->input32_fx, input_frame );
-
Copy_Scale_sig32_16( sts[0]->input32_fx, sts[0]->input_fx, input_frame, norm );
sts[0]->q_inp = add( sub( sts[0]->q_inp32, Q16 ), norm );
move16();
IF( data_fx_ch1 != NULL ) /*this may happen for cases with odd number of channels*/
{
- Q_min = s_min( q_data_fx, add( sts[1]->q_inp32, L_norm_arr( sts[1]->input32_fx - input_frame, input_frame ) ) );
- scale_sig32( sts[1]->input32_fx - input_frame, input_frame, sub( Q_min, sts[1]->q_inp32 ) );
+ scale_sig32( sts[1]->input32_fx - input_frame, input_frame, sub( Q_min, sts[1]->q_old_inp32 ) );
+ sts[1]->q_old_inp32 = Q_min;
+ move16();
Copy_Scale_sig32( data_fx_ch1, sts[1]->input32_fx, input_frame, sub( Q_min, q_data_fx ) ); // Q(Q_min)
sts[1]->q_inp32 = Q_min;
move16();
- norm = L_norm_arr( sts[1]->input32_fx, input_frame );
-
Copy_Scale_sig32_16( sts[1]->input32_fx, sts[1]->input_fx, input_frame, norm );
sts[1]->q_inp = add( sub( sts[1]->q_inp32, Q16 ), norm );
move16();
@@ -297,8 +304,8 @@ ivas_error ivas_cpe_enc_fx(
}
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 ) );
+ 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;
@@ -379,53 +386,44 @@ ivas_error ivas_cpe_enc_fx(
/*----------------------------------------------------------------*
* Resets/updates in case of stereo switching
*----------------------------------------------------------------*/
- Word16 shift = norm_arr( sts[1]->old_input_signal_fx, input_frame );
- Scale_sig( sts[1]->old_input_signal_fx, input_frame, shift ); /* sts[1]->q_old_inp + shift */
- sts[1]->q_old_inp = add( sts[1]->q_old_inp, shift );
- move16();
- shift = norm_arr( sts[1]->input_fx, input_frame );
- Scale_sig( sts[1]->input_fx, input_frame, shift ); /* sts[1]->q_inp + shift */
- sts[1]->q_inp = add( sts[1]->q_inp, shift );
- move16();
-
- shift = norm_arr( sts[0]->old_input_signal_fx, input_frame );
- Scale_sig( sts[0]->old_input_signal_fx, input_frame, shift ); /* sts[1]->q_old_inp + shift */
- sts[0]->q_old_inp = add( sts[0]->q_old_inp, shift );
- move16();
- shift = norm_arr( sts[0]->input_fx, input_frame );
- Scale_sig( sts[0]->input_fx, input_frame, shift ); /* sts[1]->q_inp, shift */
- sts[0]->q_inp = add( sts[0]->q_inp, shift );
- move16();
-
- 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 ) ); /* 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;
- move16();
- move16();
+ test();
+ IF( EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) && EQ_16( hCPE->last_element_mode, IVAS_CPE_DFT ) )
+ {
+ gb = find_guarded_bits_fx( sts[0]->encoderLookahead_FB );
+ shift = L_norm_arr( sts[1]->old_input_signal32_fx, shl( input_frame, 1 ) );
+ shift = s_min( shift, L_norm_arr( sts[0]->old_input_signal32_fx, shl( input_frame, 1 ) ) );
+
+ IF( LT_16( shift, gb ) )
+ {
+ shift = sub( shift, gb );
+ scale_sig32( sts[1]->input32_fx, input_frame, shift ); /* q_inp32 + shift */
+ scale_sig32( sts[0]->input32_fx, input_frame, shift ); /* q_inp32 + shift */
+ scale_sig32( sts[1]->old_input_signal32_fx, input_frame, shift ); /* q_old_inp32 + shift */
+ scale_sig32( sts[0]->old_input_signal32_fx, input_frame, shift ); /* q_old_inp32 + shift */
+ sts[1]->q_inp32 = add( sts[1]->q_inp32, shift );
+ sts[0]->q_inp32 = add( sts[0]->q_inp32, shift );
+ sts[1]->q_old_inp32 = add( sts[1]->q_old_inp32, shift );
+ sts[0]->q_old_inp32 = add( sts[0]->q_old_inp32, shift );
+ move16();
+ move16();
+ 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 ) ) ); // 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 );
+ stereo_switching_enc_fx( hCPE, sts[0]->old_input_signal32_fx, input_frame, sts[0]->q_old_inp32 );
/*----------------------------------------------------------------*
* Temporal inter-channel alignment, stereo adjustment
*----------------------------------------------------------------*/
-
- 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 );
+ shift = s_min( L_norm_arr( sts[0]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ), L_norm_arr( sts[1]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ) );
+ q_min = add( sts[0]->q_inp32, sub( shift, find_guarded_bits_fx( input_frame ) ) );
+ scale_sig32( sts[1]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), sub( q_min, sts[1]->q_inp32 ) ); /* q_min */
+ scale_sig32( sts[0]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), sub( q_min, sts[0]->q_inp32 ) ); /* q_min */
+ sts[0]->q_inp32 = sts[1]->q_inp32 = sts[0]->q_old_inp32 = sts[1]->q_old_inp32 = q_min;
+ move16();
+ move16();
move16();
- 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 );
@@ -446,9 +444,12 @@ ivas_error ivas_cpe_enc_fx(
FOR( n = 0; n < CPE_CHANNELS; n++ )
{
+ Copy32( sts[n]->input32_fx, orig_input_fx32[n], input_frame ); /* sts->q_inp32 */
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;
+ Q_orig_inp32[n] = sts[n]->q_inp32;
+ move16();
move16();
IF( hCPE->hStereoICBWE != NULL )
@@ -630,10 +631,8 @@ ivas_error ivas_cpe_enc_fx(
* Stereo processing
* Stereo down-mix
*----------------------------------------------------------------*/
- // printf("\n%f %f ", hCPE->hStereoClassif->is_speech, hCPE->hCoreCoder[0]->hSpMusClas->past_dlp[0]);
IF( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) )
{
- /*flt2fix: dft_synthesize*/
test();
if ( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) && hCPE->hStereoDft->res_cod_mode[STEREO_DFT_OFFSET] )
{
@@ -650,11 +649,12 @@ ivas_error ivas_cpe_enc_fx(
hCPE->hStereoDft->Spd_R_smooth_fx_e = sub( hCPE->hStereoDft->Spd_R_smooth_fx_e, temp );
move16();
-
+ q_com = MAX_16;
+ move16();
FOR( n = 0; n < CPE_CHANNELS; n++ )
{
- q_com = sub( add( L_norm_arr( sts[n]->input32_fx, input_frame ), sts[n]->q_inp32 ), 16 );
- q_com = s_min( q_com, add( norm_arr( sts[n]->old_input_signal_fx, input_frame ), sts[n]->q_old_inp ) );
+ q_com = s_min( q_com, sub( add( L_norm_arr( sts[n]->input32_fx, input_frame ), sts[n]->q_inp32 ), 16 ) );
+ q_com = s_min( q_com, sub( add( L_norm_arr( sts[n]->old_input_signal32_fx, input_frame ), sts[n]->q_old_inp32 ), 16 ) );
q_com = s_min( q_com, add( norm_arr( hCPE->input_mem_fx[n], hCPE->hStereoDft->dft_ovl ), hCPE->q_input_mem[n] ) );
if ( EQ_16( q_com, Q15 ) )
@@ -662,12 +662,14 @@ ivas_error ivas_cpe_enc_fx(
q_com = 0;
move16();
}
-
+ }
+ FOR( n = 0; n < CPE_CHANNELS; n++ )
+ {
Copy_Scale_sig_32_16( sts[n]->input32_fx, sts[n]->input_fx, input_frame, sub( q_com, sts[n]->q_inp32 ) );
sts[n]->q_inp = q_com;
move16();
- scale_sig( sts[n]->old_input_signal_fx, input_frame, sub( q_com, sts[n]->q_old_inp ) );
+ Copy_Scale_sig_32_16( sts[n]->old_input_signal32_fx, sts[n]->old_input_signal_fx, input_frame, sub( q_com, sts[n]->q_old_inp32 ) );
sts[n]->q_old_inp = q_com;
move16();
@@ -675,7 +677,6 @@ ivas_error ivas_cpe_enc_fx(
hCPE->q_input_mem[n] = q_com;
move16();
}
-
stereo_dft_hybrid_ITD_flag_fx( hCPE->hStereoDft->hConfig, input_Fs, hCPE->hStereoDft->hItd->hybrid_itd_max );
/* Time Domain ITD compensation using extrapolation */
@@ -751,29 +752,32 @@ ivas_error ivas_cpe_enc_fx(
sts[1]->exp_old_inp_12k8 = Q15;
move16();
}
- }
- test();
- IF( hCPE->hStereoMdct != NULL && hCPE->hStereoMdct->hItd != NULL )
- {
- Word16 q_min;
+
q_min = sts[1]->q_old_inp;
move16();
q_min = s_min( q_min, sts[1]->q_inp );
q_min = s_min( q_min, sts[0]->q_old_inp );
q_min = s_min( q_min, sts[0]->q_inp );
+ q_min = s_min( q_min, hCPE->q_input_mem[0] );
+ q_min = s_min( q_min, hCPE->q_input_mem[1] );
shift = norm_arr( sts[1]->old_input_signal_fx, input_frame );
shift = s_min( shift, norm_arr( sts[1]->input_fx, input_frame ) );
shift = s_min( shift, norm_arr( sts[0]->old_input_signal_fx, input_frame ) );
shift = s_min( shift, norm_arr( sts[0]->input_fx, input_frame ) );
+ shift = s_min( shift, norm_arr( hCPE->input_mem_fx[0], hCPE->hStereoMdct->hDft_ana->dft_ovl ) );
+ shift = s_min( shift, norm_arr( hCPE->input_mem_fx[1], hCPE->hStereoMdct->hDft_ana->dft_ovl ) );
q_min = add( q_min, shift );
- scale_sig( sts[1]->input_fx, input_frame, sub( q_min, sts[1]->q_inp ) ); /* q_min */
- scale_sig( sts[1]->old_input_signal_fx, input_frame, sub( q_min, sts[1]->q_old_inp ) ); /* q_min */
- scale_sig( sts[0]->input_fx, input_frame, sub( q_min, sts[0]->q_inp ) ); /* q_min */
- scale_sig( sts[0]->old_input_signal_fx, input_frame, sub( q_min, sts[0]->q_old_inp ) ); /* q_min */
-
+ scale_sig( sts[1]->input_fx, input_frame, sub( q_min, sts[1]->q_inp ) ); /* q_min */
+ scale_sig( sts[1]->old_input_signal_fx, input_frame, sub( q_min, sts[1]->q_old_inp ) ); /* q_min */
+ scale_sig( sts[0]->input_fx, input_frame, sub( q_min, sts[0]->q_inp ) ); /* q_min */
+ scale_sig( sts[0]->old_input_signal_fx, input_frame, sub( q_min, sts[0]->q_old_inp ) ); /* q_min */
+ scale_sig( hCPE->input_mem_fx[0], hCPE->hStereoMdct->hDft_ana->dft_ovl, sub( q_min, hCPE->q_input_mem[0] ) ); /* q_min */
+ scale_sig( hCPE->input_mem_fx[1], hCPE->hStereoMdct->hDft_ana->dft_ovl, sub( q_min, hCPE->q_input_mem[1] ) ); /* q_min */
+ hCPE->q_input_mem[1] = q_min;
+ hCPE->q_input_mem[0] = q_min;
sts[1]->q_old_inp = q_min;
sts[0]->q_old_inp = q_min;
sts[1]->q_inp = q_min;
@@ -782,12 +786,11 @@ ivas_error ivas_cpe_enc_fx(
move16();
move16();
move16();
+ move16();
+ move16();
}
stereo_td_itd_mdct_stereo_fx( hCPE, vad_flag_dtx, vad_hover_flag, input_frame );
-
- Copy_Scale_sig_16_32_no_sat( sts[0]->input_fx - input_frame, sts[0]->input32_fx - input_frame, shl( input_frame, 1 ), sub( sts[0]->q_inp32, sts[0]->q_inp ) );
- Copy_Scale_sig_16_32_no_sat( sts[1]->input_fx - input_frame, sts[1]->input32_fx - input_frame, shl( input_frame, 1 ), sub( sts[1]->q_inp32, sts[1]->q_inp ) );
}
/*----------------------------------------------------------------*
@@ -813,30 +816,28 @@ ivas_error ivas_cpe_enc_fx(
Word16 out_16k_start_ind = 0, out_16k_end_ind = 0;
move16();
move16();
+
stereo_dft_enc_synthesize_fx( hCPE->hStereoDft, sts[0]->input32_fx, &out_start_ind, &out_end_ind, 0, input_Fs, input_Fs, 0, NULL );
- Scale_sig32( sts[0]->input32_fx - input_frame, add( out_start_ind, input_frame ), sub( Q15, sts[0]->q_inp32 ) ); // scaling initial part of the input buffer
+
+ scale_sig32( sts[0]->input32_fx - input_frame, add( out_start_ind, input_frame ), sub( Q15, sts[0]->q_old_inp32 ) ); // scaling initial part of the input buffer
+ scale_sig32( sts[0]->input32_fx + out_end_ind, sub( input_frame, out_end_ind ), sub( Q15, sts[0]->q_inp32 ) ); // scaling initial part of the input buffer
sts[0]->q_inp32 = Q15;
+ sts[0]->q_old_inp32 = Q15;
move16();
-
- // Normalise the input buffer from Q15
- Word16 input_norm, q_inp32, common_q, fir_delay_len;
- input_norm = L_norm_arr( sts[0]->input32_fx + out_start_ind, sub( out_end_ind, out_start_ind ) );
- q_inp32 = add( Q15, input_norm );
- fir_delay_len = NS2SA_FX2( sts[0]->input_Fs, DELAY_FIR_RESAMPL_NS );
move16();
- // Find common Q-factor between { q_inp, q_old_inp and q_inp32-16 }
- common_q = s_min( s_min( sub( q_inp32, 16 ), sts[0]->q_inp ), sts[0]->q_old_inp );
+ // Normalise the input buffer from Q15
+ Word16 input_norm, q_inp; //, common_q, fir_delay_len;
+ input_norm = L_norm_arr( sts[0]->input32_fx - input_frame, shl( input_frame, 1 ) );
+ q_inp = sub( add( Q15, input_norm ), 16 );
// Rescale the old input, input and FIR delay section of input buffer
- scale_sig( sts[0]->old_input_signal_fx, input_frame, sub( common_q, sts[0]->q_old_inp ) ); // q_old_inp -> common_q
- Copy_Scale_sig32_16( sts[0]->input32_fx + out_start_ind, sts[0]->input_fx + out_start_ind, sub( out_end_ind, out_start_ind ), sub( add( Q16, common_q ), Q15 ) ); // Q15 -> common_q
- scale_sig( sts[0]->input_fx + out_end_ind, add( sub( input_frame, out_end_ind ), fir_delay_len ), sub( common_q, sts[0]->q_inp ) ); // q_inp -> common_q
+ Copy_Scale_sig32_16( sts[0]->input32_fx - input_frame, sts[0]->input_fx - input_frame, shl( input_frame, 1 ), sub( add( Q16, q_inp ), Q15 ) ); // Q15 -> q_inp
// Update the Q-factors
- sts[0]->q_inp = common_q;
+ sts[0]->q_inp = q_inp;
move16();
- sts[0]->q_old_inp = common_q;
+ sts[0]->q_old_inp = q_inp;
move16();
/* iDFT & resampling to 12.8kHz internal sampling rate */
@@ -846,7 +847,7 @@ ivas_error ivas_cpe_enc_fx(
/* 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, add( input_frame, STEREO_DFT_OVL_16k ) ); /* Q_inp */
+ 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 ) ); /* sts[0]->q_inp32 */
out_16k_start_ind = -STEREO_DFT_OVL_16k;
out_16k_end_ind = add( out_16k_start_ind, add( input_frame, STEREO_DFT_OVL_16k ) );
move16();
@@ -1218,12 +1219,12 @@ ivas_error ivas_cpe_enc_fx(
/* update input samples buffer */
FOR( n = 0; n < CPE_CHANNELS; n++ )
{
+ Copy32( orig_input_fx32[n], sts[n]->old_input_signal32_fx, input_frame ); /* Q_orig_inp32 */
+ sts[n]->q_old_inp32 = Q_orig_inp32[n];
+ move16();
Copy( orig_input_fx[n], sts[n]->old_input_signal_fx, input_frame ); /* Q_orig_inp */
sts[n]->q_old_inp = Q_orig_inp[n];
move16();
- Copy_Scale_sig_16_32_no_sat( sts[n]->input_fx - input_frame, sts[n]->input32_fx - input_frame, input_frame, 16 ); // duplicating the data for input32_fx
- sts[n]->q_inp32 = add( Q_orig_inp[n], 16 );
- move16();
}
}
ELSE IF( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) )
@@ -1231,7 +1232,9 @@ ivas_error ivas_cpe_enc_fx(
Copy( sts[0]->input_fx, sts[0]->old_input_signal_fx, input_frame ); /* sts[n]->q_inp */
sts[0]->q_old_inp = sts[0]->q_inp;
move16();
- Copy32( sts[0]->input32_fx, sts[0]->input32_fx - input_frame, input_frame ); /* st->q_inp32 */
+ Copy32( sts[0]->input32_fx, sts[0]->old_input_signal32_fx, input_frame ); /* st->q_inp32 */
+ sts[0]->q_old_inp32 = sts[0]->q_inp32;
+ move16();
}
ELSE IF( st_ivas->hMCT == NULL ) /* note: in MCT, input buffers are updated later in ivas_mct_enc() */
{
@@ -1241,7 +1244,9 @@ ivas_error ivas_cpe_enc_fx(
Copy( sts[n]->input_fx, sts[n]->old_input_signal_fx, input_frame ); /* sts[n]->q_inp */
sts[n]->q_old_inp = sts[n]->q_inp;
move16();
- Copy32( sts[n]->input32_fx, sts[n]->input32_fx - input_frame, input_frame ); /* st->q_inp32 */
+ Copy32( sts[n]->input32_fx, sts[n]->old_input_signal32_fx, input_frame ); /* st->q_inp32 */
+ sts[n]->q_old_inp32 = sts[n]->q_inp32;
+ move16();
}
}
diff --git a/lib_enc/ivas_dirac_enc_fx.c b/lib_enc/ivas_dirac_enc_fx.c
index 615a6f4b630124866a0aa9acc77837511514d3e6..be15b5048e9d7cf46306330025488e7b50d23804 100644
--- a/lib_enc/ivas_dirac_enc_fx.c
+++ b/lib_enc/ivas_dirac_enc_fx.c
@@ -849,16 +849,17 @@ void computeReferencePower_enc_fx(
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 */
-)
+ Word16 q_reference_power[DIRAC_NO_FB_BANDS_MAX] )
{
Word16 brange[2];
Word16 ch_idx, i, j;
- Word16 ref_Q = 63;
- move16();
+ Word16 num_bins, guard_bits, norm;
Word64 reference_power_tmp[DIRAC_MAX_NBANDS];
Word64 reference_power_W[DIRAC_MAX_NBANDS];
+
+ Word16 shift_ref_power = sub( shl( inp_q, 1 ), 31 );
+
FOR( i = 0; i < num_freq_bands; i++ )
{
brange[0] = band_grouping[i + enc_param_start_band]; /* Q0 */
@@ -871,24 +872,28 @@ void computeReferencePower_enc_fx(
move64();
reference_power_tmp[i] = 0;
move64();
+
+ num_bins = sub( brange[1], brange[0] );
+ guard_bits = find_guarded_bits_fx( num_bins );
+
FOR( j = brange[0]; j < brange[1]; j++ )
{
- // 2*inp_q + 1
- reference_power_W[i] = W_add( reference_power_W[i], W_mac_32_32( W_mult_32_32( Cldfb_RealBuffer[0][j], Cldfb_RealBuffer[0][j] ), Cldfb_ImagBuffer[0][j], Cldfb_ImagBuffer[0][j] ) );
+ reference_power_W[i] = W_add( reference_power_W[i], W_shr( W_mac_32_32( W_mult_32_32( Cldfb_RealBuffer[0][j], Cldfb_RealBuffer[0][j] ), Cldfb_ImagBuffer[0][j], Cldfb_ImagBuffer[0][j] ), guard_bits ) ); // 2*inp_q + 1 - guard_bits
move64();
}
- reference_power_tmp[i] = W_add( reference_power_tmp[i], reference_power_W[i] ); // 2*inp_q + 1
+ reference_power_tmp[i] = W_add( reference_power_tmp[i], reference_power_W[i] ); // 2*inp_q + 1 - guard_bits
move64();
FOR( ch_idx = 1; ch_idx < nchan_ana; ch_idx++ )
{
/* abs()^2 */
FOR( j = brange[0]; j < brange[1]; j++ )
{
- reference_power_tmp[i] = W_add( reference_power_tmp[i], W_mac_32_32( W_mult_32_32( Cldfb_RealBuffer[ch_idx][j], Cldfb_RealBuffer[ch_idx][j] ), Cldfb_ImagBuffer[ch_idx][j], Cldfb_ImagBuffer[ch_idx][j] ) );
+ reference_power_tmp[i] = W_add( reference_power_tmp[i], W_shr( W_mac_32_32( W_mult_32_32( Cldfb_RealBuffer[ch_idx][j], Cldfb_RealBuffer[ch_idx][j] ), Cldfb_ImagBuffer[ch_idx][j], Cldfb_ImagBuffer[ch_idx][j] ), guard_bits ) ); // 2*inp_q + 1 - guard_bits
move64();
}
- // 2*inp_q + 1
}
+ q_reference_power[i] = sub( shift_ref_power, guard_bits );
+ move16();
}
FOR( i = 0; i < num_freq_bands; i++ )
{
@@ -908,20 +913,21 @@ void computeReferencePower_enc_fx(
}
}
}
+
FOR( i = 0; i < num_freq_bands; i++ )
{
- ref_Q = s_min( ref_Q, W_norm( reference_power_tmp[i] ) );
- }
- FOR( i = 0; i < num_freq_bands; i++ )
- {
- reference_power_tmp[i] = W_shl( reference_power_tmp[i], ref_Q ); // 2*inp_q + 1 + ref_Q
- move64();
- reference_power[i] = W_extract_h( reference_power_tmp[i] ); // 2*inp_q + ref_Q - 31
+ norm = 63;
+ move16();
+ IF( reference_power_tmp[i] != 0 )
+ {
+ norm = W_norm( reference_power_tmp[i] );
+ }
+ reference_power[i] = W_extract_h( W_shl( reference_power_tmp[i], norm ) ); // 2 * inp_q + 1 - guard_bits + norm - 32
move32();
+ q_reference_power[i] = add( q_reference_power[i], norm );
+ move16();
}
- *ref_exp = sub( Q31, ( sub( add( shl( inp_q, Q1 ), ref_Q ), Q31 ) ) );
- move16();
return;
}
/*-------------------------------------------------------------------------
diff --git a/lib_enc/ivas_enc_cov_handler_fx.c b/lib_enc/ivas_enc_cov_handler_fx.c
index 59c38aa5d75c5083b99a50ab60a4122fcdfd61b6..495e6caa106cdc55a2165c5655ee104814982737 100644
--- a/lib_enc/ivas_enc_cov_handler_fx.c
+++ b/lib_enc/ivas_enc_cov_handler_fx.c
@@ -514,6 +514,9 @@ static void ivas_band_cov_fx(
Word16 q_shift, q_shift_tmp;
Word16 m, start_bin, active_bins;
Word16 num_blocks;
+#ifdef OPT_SBA_ENC_V1_BE
+ Word16 shift_conv, q_shift_cov[IVAS_MAX_NUM_BANDS][IVAS_MAX_NUM_BANDS];
+#endif
num_blocks = idiv1616( num_bins, stride ); /* Q0 */
FOR( i = 0; i < num_chans; i++ )
@@ -525,13 +528,24 @@ static void ivas_band_cov_fx(
move16();
move16();
+#ifdef OPT_SBA_ENC_V1_BE
+ q_shift = 31;
+ move16();
+#endif
FOR( k = 0; k < num_bins; k++ )
{
pV_re_64bit[k] = W_add( W_mult0_32_32( ppIn_FR_real[i1][k], ppIn_FR_real[j1][k] ),
W_mult0_32_32( ppIn_FR_imag[i1][k], ppIn_FR_imag[j1][k] ) ); //(q_In_FR[i1], q_In_FR[j1]) -> (q_In_FR[i1] + q_In_FR[j1])
move64();
+#ifdef OPT_SBA_ENC_V1_BE
+ q_shift_tmp = W_norm( pV_re_64bit[k] );
+ if ( pV_re_64bit[k] != 0 )
+ {
+ q_shift = s_min( q_shift, q_shift_tmp );
+ }
+#endif
}
-
+#ifndef OPT_SBA_ENC_V1_BE
q_shift = 31;
move16();
FOR( k = 0; k < num_bins; k++ )
@@ -542,11 +556,17 @@ static void ivas_band_cov_fx(
q_shift = s_min( q_shift, q_shift_tmp );
}
}
+#endif
q_shift_tmp = sub( q_shift, 32 );
FOR( k = 0; k < num_bins; k++ )
{
+#ifdef OPT_SBA_ENC_V1_BE
+ pV_re[k] = W_shl_sat_l( pV_re_64bit[k], q_shift_tmp ); //(q_In_FR[i1] + q_In_FR[j1]) + (q_shift - 32)
+ move32();
+#else
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();
+#endif
/* perform rounding towards lower value for negative results */
if ( pV_re[k] < 0 )
{
@@ -554,6 +574,10 @@ static void ivas_band_cov_fx(
}
}
+#ifdef OPT_SBA_ENC_V1_BE
+ q_shift_cov[i][j] = Q31;
+ move16();
+#endif
FOR( k = start_band; k < end_band; k++ )
{
Word64 temp;
@@ -575,7 +599,11 @@ static void ivas_band_cov_fx(
/* optional: add temporal weight here */
FOR( m = 0; m < active_bins; m++ )
{
+#ifdef OPT_SBA_ENC_V1_BE
+ temp = W_mac_32_32( temp, cov_ptr[m], p_bin_to_band[m] ); // ((q_In_FR[i1] + q_In_FR[j1]) + (q_shift - 32), Q22) + 1-> (q_In_FR[i1] + q_In_FR[j1] + (q_shift - 9)
+#else
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)
+#endif
}
cov_ptr += stride;
move16();
@@ -584,8 +612,19 @@ static void ivas_band_cov_fx(
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
+#ifdef OPT_SBA_ENC_V1_BE
+ shift_conv = W_norm( cov_real_64bit[i][j][k] );
+ if ( cov_real_64bit[i][j][k] != 0 )
+ {
+ q_shift_cov[i][j] = s_min( q_shift_cov[i][j], shift_conv );
+ }
+#endif
}
+#ifdef OPT_SBA_ENC_V1_BE
+ q_cov_real[i][j] = add( add( q_In_FR, q_In_FR ), sub( q_shift, Q9 ) );
+#else
q_cov_real[i][j] = add( add( q_In_FR, q_In_FR ), sub( q_shift, Q10 ) );
+#endif
move16();
}
}
@@ -594,6 +633,7 @@ static void ivas_band_cov_fx(
{
FOR( j = i; j < num_chans; j++ )
{
+#ifndef OPT_SBA_ENC_V1_BE
q_shift = 31;
move16();
FOR( k = start_band; k < end_band; k++ )
@@ -605,10 +645,19 @@ static void ivas_band_cov_fx(
}
}
q_shift_tmp = sub( q_shift, 32 );
+#else
+ q_shift_tmp = sub( q_shift_cov[i][j], 32 );
+#endif
FOR( k = start_band; k < end_band; k++ )
{
+#ifdef OPT_SBA_ENC_V1_BE
+
+ cov_real[i][j][k] = W_shl_sat_l( cov_real_64bit[i][j][k], q_shift_tmp ); /* q_cov_real[i][j] + q_shift - 32 */
+ move32();
+#else
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();
+#endif
}
q_cov_real[i][j] = add( q_cov_real[i][j], q_shift_tmp );
move16();
diff --git a/lib_enc/ivas_front_vad_fx.c b/lib_enc/ivas_front_vad_fx.c
index 124ab2996d3a05ded0d407d343ba090048a50f7b..963e363b27579a88cfeb6dab466b096f709a4ac4 100644
--- a/lib_enc/ivas_front_vad_fx.c
+++ b/lib_enc/ivas_front_vad_fx.c
@@ -241,9 +241,9 @@ ivas_error front_vad_fx(
PREEMPH_FX( hFrontVad->buffer_12k8_fx + L_FFT / 2, PREEMPH_FAC, L_FRAME, &hFrontVad->mem_preemph_fx );
- Q_new = add( sub( Q_inp, Qband ), Q_add );
- 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_new = s_min( add( add( Q_inp, Qband ), Q_add ), Q_buffer[n] );
+ 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, 3 * L_FRAME / 2 - L_FFT / 2, sub( Q_new, add( Q_inp, Qband ) ) ); /* Q_new */
Q_buffer[n] = Q_new;
move16();
@@ -282,16 +282,6 @@ ivas_error front_vad_fx(
move16();
/* wb_vad */
- 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
@@ -502,7 +492,7 @@ ivas_error front_vad_spar_fx(
Word16 sp_div_fx;
Word16 Q_sp_div;
- Word16 non_staX_fx;
+ Word32 non_staX_fx;
Word16 sp_floor;
Word16 cor_map_sum_fx;
@@ -613,9 +603,9 @@ ivas_error front_vad_spar_fx(
Word16 q_tmpN, q_tmpE;
noise_est_down_ivas_fx( fr_bands_fx[0], q_fr_bands[0], hFrontVad->hNoiseEst->bckr_fx, &hFrontVad->hNoiseEst->q_bckr, tmpN_fx, &q_tmpN, tmpE_fx, &q_tmpE, st->min_band, st->max_band,
- &hFrontVad->hNoiseEst->totalNoise_fx, Etot_fx[0], &hFrontVad->hNoiseEst->Etot_last_32fx, &hFrontVad->hNoiseEst->Etot_v_h2_fx );
+ &hFrontVad->hNoiseEst->totalNoise_32fx, L_deposit_h( Etot_fx[0] ) /*q8->q24*/, &hFrontVad->hNoiseEst->Etot_last_32fx, &hFrontVad->hNoiseEst->Etot_v_h2_32fx );
- corr_shift_fx = correlation_shift_fx( hFrontVad->hNoiseEst->totalNoise_fx ); /* Q15 */
+ corr_shift_fx = correlation_shift_fx( extract_h( hFrontVad->hNoiseEst->totalNoise_32fx ) ); /* Q15 */
dtx_ivas_fx( st, hEncoderConfig->last_ivas_total_brate, hEncoderConfig->ivas_total_brate, vad_flag_dtx[0], inp_12k8_fx, Q_inp_12k8 );
@@ -639,11 +629,7 @@ ivas_error front_vad_spar_fx(
hFrontVad->q_buffer_12k8 = Q_inp_12k8;
move16();
-#ifdef REMOVE_EVS_DUPLICATES
- analy_lp_ivas_fx( inp_12k8_fx, L_FRAME, L_LOOK_12k8, &res_energy_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lsp_old1_fx, alw_pitch_lag_12k8, alw_voicing_fx, INT_FS_12k8, st->element_mode, 0, Q_inp_12k8, Q_r );
-#else
- analy_lp_ivas_fx( inp_12k8_fx, L_FRAME, L_LOOK_12k8, &res_energy_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lsp_old1_fx, alw_pitch_lag_12k8, alw_voicing_fx, INT_FS_12k8, 0 /* <-- sec_chan_low_rate */, Q_inp_12k8, Q_r );
-#endif
+ analy_lp_fx( inp_12k8_fx, L_FRAME, L_LOOK_12k8, &res_energy_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lsp_old1_fx, alw_pitch_lag_12k8, alw_voicing_fx, INT_FS_12k8, st->element_mode, 0, Q_inp_12k8, Q_r );
FOR( Word16 i = 0; i <= M; i++ )
{
@@ -651,7 +637,7 @@ ivas_error front_vad_spar_fx(
move32();
}
- relE_fx = sub( Etot_fx[0], st->lp_speech_fx );
+ relE_fx = sub( Etot_fx[0], extract_h( st->lp_speech_32fx ) );
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 ); /* Q_inp_12k8 */
@@ -755,7 +741,7 @@ ivas_error front_vad_spar_fx(
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, extract_h( hFrontVad->hNoiseEst->Etot_l_lp_32fx ), hFrontVad->hNoiseEst->Etot_v_h2_fx,
+ lf_E_fx[0], q_lf_E[0], &hFrontVad->hNoiseEst->harm_cor_cnt, extract_h( hFrontVad->hNoiseEst->Etot_l_lp_32fx ), hFrontVad->hNoiseEst->Etot_v_h2_32fx,
&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 );
@@ -763,16 +749,15 @@ ivas_error front_vad_spar_fx(
/* 1st stage speech/music classification (GMM model) */
/* run only to get 'high_lpn_flag' parameter */
SP_MUS_CLAS_HANDLE hSpMusClas = st->hSpMusClas;
- Word16 non_sta_fx = shr( non_staX_fx, Q2 ); // Q8->Q6
Word16 Etot_fx_0 = Etot_fx[0];
move16();
scale = getScaleFactor32( PS_fx, 128 );
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 );
+ 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_staX_fx, relE_fx, &high_lpn_flag, flag_spitch, Qfact_PS, Q_esp, hSpMusClas->past_PS_Q );
/* long-term energy update */
- ivas_long_enr_fx( st, -1, localVAD_HE_SAD[0], high_lpn_flag, &hFrontVad, 1, localVAD_HE_SAD, Etot_fx );
+ ivas_long_enr_fx( st, -256 /*-1 q8*/, localVAD_HE_SAD[0], high_lpn_flag, &hFrontVad, 1, localVAD_HE_SAD, Etot_fx );
/* increase ini_frame counter */
hFrontVad->ini_frame = s_min( add( hFrontVad->ini_frame, 1 ), MAX_FRAME_COUNTER ); /* Q0 */
diff --git a/lib_enc/ivas_init_enc_fx.c b/lib_enc/ivas_init_enc_fx.c
index 04b99f039019bb15a831a85c5ef8fe516d11b782..7d88b12642a10e909e54a259de54435fe0479935 100644
--- a/lib_enc/ivas_init_enc_fx.c
+++ b/lib_enc/ivas_init_enc_fx.c
@@ -41,6 +41,9 @@
#include "wmc_auto.h"
#include "ivas_prot_fx.h"
#include "prot_fx_enc.h"
+#ifdef DBG_BITSTREAM_ANALYSIS
+#include
+#endif
/*-------------------------------------------------------------------*
@@ -1175,6 +1178,13 @@ ivas_error ivas_init_encoder_fx(
move16();
}
+#ifdef BITSTERAM_ANALYSIS
+ for ( i = 0; i < st_ivas->ivas_max_num_indices; i++ )
+ {
+ memset( st_ivas->ind_list[i].function_name, 'A', 100 * sizeof( char ) );
+ }
+#endif
+
/* 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 ); /* Q0 */
move16();
diff --git a/lib_enc/ivas_ism_dtx_enc_fx.c b/lib_enc/ivas_ism_dtx_enc_fx.c
index b06acfbac9d82312451262648f8cc39526dd1b19..bc2c83de194dbd617a94602b48940049b4ea1824 100644
--- a/lib_enc/ivas_ism_dtx_enc_fx.c
+++ b/lib_enc/ivas_ism_dtx_enc_fx.c
@@ -143,7 +143,7 @@ Word16 ivas_ism_dtx_enc_fx(
/* one of the channels is active -> no DTX */
FOR( ch = 0; ch < nchan_transport; ch++ )
{
- lp_noise_fx[ch] = hSCE[ch]->hCoreCoder[0]->lp_noise_fx; /*Q8*/
+ lp_noise_fx[ch] = extract_h( hSCE[ch]->hCoreCoder[0]->lp_noise_32fx ); /*Q8*/
move16();
}
diff --git a/lib_enc/ivas_ism_enc_fx.c b/lib_enc/ivas_ism_enc_fx.c
index 81c9e01ef8818e5f3d1976b93dd791b99b9966a1..122ea1d7590348098b464e9ae8d55a0fcc3f4d71 100644
--- a/lib_enc/ivas_ism_enc_fx.c
+++ b/lib_enc/ivas_ism_enc_fx.c
@@ -167,6 +167,8 @@ ivas_error ivas_ism_enc_fx(
*-----------------------------------------------------------------*/
Word16 Q_min = s_min( q_data, add( st->q_inp32, L_norm_arr( st->input32_fx - input_frame, input_frame ) ) );
scale_sig32( st->input32_fx - input_frame, input_frame, sub( Q_min, st->q_inp32 ) );
+ st->q_old_inp32 = Q_min;
+ move16();
Copy_Scale_sig32( data[sce_id], st->input32_fx, input_frame, sub( Q_min, q_data ) ); // Q(Q_min)
st->q_inp32 = Q_min;
move16();
@@ -474,7 +476,9 @@ ivas_error ivas_ism_enc_fx(
Copy( st->input_fx, st->old_input_signal_fx, input_frame ); /* st->q_inp */
st->q_old_inp = st->q_inp;
move16();
- Copy32( st->input32_fx, st->input32_fx - input_frame, input_frame ); /* st->q_inp32 */
+ Copy32( st->input32_fx, st->old_input_signal32_fx, input_frame ); /* st->q_inp32 */
+ st->q_old_inp32 = st->q_inp32;
+ move16();
hSCE->last_element_brate = hSCE->element_brate; /* Q0 */
move32();
diff --git a/lib_enc/ivas_ism_metadata_enc_fx.c b/lib_enc/ivas_ism_metadata_enc_fx.c
index 1efbb2123e56790854df9a4a08a641ed61d94dfa..594871b29eea64c810f95c41eaf91cd5f9d22281 100644
--- a/lib_enc/ivas_ism_metadata_enc_fx.c
+++ b/lib_enc/ivas_ism_metadata_enc_fx.c
@@ -277,7 +277,7 @@ ivas_error ivas_ism_metadata_enc_fx(
/* In case of low level noise for low bitrate inactive frames, do not sent metadata */
test();
test();
- hIsmMeta[ch]->ism_metadata_flag = vad_flag[ch] || GT_16( hSCE[ch]->hCoreCoder[0]->lp_noise_fx, 2560 /*10 Q8*/ ) || hSCE[ch]->hCoreCoder[0]->tcxonly;
+ hIsmMeta[ch]->ism_metadata_flag = vad_flag[ch] || GT_32( hSCE[ch]->hCoreCoder[0]->lp_noise_32fx, 167772160 /*10 Q24*/ ) || hSCE[ch]->hCoreCoder[0]->tcxonly;
move16();
}
diff --git a/lib_enc/ivas_masa_enc_fx.c b/lib_enc/ivas_masa_enc_fx.c
index ceb5dec1d7c40cd2a38764c512732d30c309f81d..fb86dee7a431a079183be1c31c0a5a9e86fb7d18 100644
--- a/lib_enc/ivas_masa_enc_fx.c
+++ b/lib_enc/ivas_masa_enc_fx.c
@@ -1195,12 +1195,12 @@ ivas_error ivas_masa_enc_config_fx(
test();
IF( EQ_16( st_ivas->hCPE[0]->element_mode, IVAS_CPE_DFT ) || LT_16( st_ivas->hMasa->data.hOmasaData->omasa_stereo_sw_cnt, OMASA_STEREO_SW_CNT_MAX ) )
{
- st_ivas->hMasa->data.hOmasaData->lp_noise_CPE_fx = st_ivas->hCPE[0]->hCoreCoder[0]->lp_noise_fx; /*Q8*/
+ st_ivas->hMasa->data.hOmasaData->lp_noise_CPE_fx = extract_h( st_ivas->hCPE[0]->hCoreCoder[0]->lp_noise_32fx ); /*Q8*/
}
ELSE
{
/* ( 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*/
+ st_ivas->hMasa->data.hOmasaData->lp_noise_CPE_fx = extract_h( L_mac( L_mult( extract_h( st_ivas->hCPE[0]->hCoreCoder[0]->lp_noise_32fx ), ONE_IN_Q14 ), extract_h( st_ivas->hCPE[0]->hCoreCoder[1]->lp_noise_32fx ), ONE_IN_Q14 ) ); /*Q8*/
}
move16();
}
@@ -2463,19 +2463,23 @@ static void reduce_metadata_further_fx(
}
/* Determine if to merge over frequency instead of time */
- meanRatio = 0;
- move32();
+ W_tmp = 0;
+ move64();
FOR( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES; sf++ )
{
FOR( band = 0; band < numCodingBands; band++ )
{
- meanRatio = L_add( meanRatio, Mpy_32_32( hqmetadata->q_direction[0].band_data[band].energy_ratio_fx[sf], energy[sf][band] ) ); // hMasa->data.q_energy - 1
+ W_tmp = W_mac_32_16( W_tmp, Mpy_32_32( hqmetadata->q_direction[0].band_data[band].energy_ratio_fx[sf], energy[sf][band] ), 1 ); // hMasa->data.q_energy
}
}
+ shift = W_norm( W_tmp );
+ meanRatio = W_extract_h( W_shl( W_tmp, shift ) ); // Q:sub( add( hMasa->data.q_energy, shift ), 32 )
+ shift = sub( 31, sub( add( hMasa->data.q_energy, shift ), 32 ) );
+
IF( totalEnergySum != 0 )
{
meanRatio = BASOP_Util_Divide3232_Scale_newton( meanRatio, totalEnergySum, &exp );
- exp = add( add( exp, 1 ), tmp2 ); // 31 - (hMasa->data.q_energy - 1) - 31 - hMasa->data.q_energy - tmp2 => 1 + tmp2
+ exp = add( exp, sub( shift, sub( 31, add( hMasa->data.q_energy, tmp2 ) ) ) ); // exp + (shift - (31 - hMasa->data.q_energy - tmp2)) => 1 + tmp2
}
ELSE
{
@@ -4662,7 +4666,6 @@ static void ivas_encode_masaism_metadata_fx(
UWord16 index_theta, index_phi;
Word16 ratio_ism_fx[MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS];
Word16 ratio_ism_idx[MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS], ratio_ism_idx_prev_sf[MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS];
- Word16 step;
Word32 energy_ism, energy_ism_ind[MAX_NUM_OBJECTS];
Word16 tmp, rotate, energy_ism_e, energy_ism_ind_e[MAX_NUM_OBJECTS];
Word16 n_ism_tmp, i;
@@ -4915,11 +4918,6 @@ static void ivas_encode_masaism_metadata_fx(
/* quantize ism_ratios */
IF( GT_16( nchan_ism, 1 ) )
{
- /* inv_step = ( ( 1 << PARAM_ISM_POW_RATIO_NBITS ) - 1 ); *
- * step = 1.0f / inv_step; */
- step = 4681; // 1.f / ( ( 1 << PARAM_ISM_POW_RATIO_NBITS ) - 1 ) => 1.f / 7 in Q15
- move16();
-
rotate = 0;
n_ism_tmp = 0;
move16();
@@ -4964,7 +4962,7 @@ static void ivas_encode_masaism_metadata_fx(
}
/* reconstructed values */
- reconstruct_ism_ratios_fx( ratio_ism_idx[band], nchan_ism, step, hMasa->data.hOmasaData->q_energy_ratio_ism_fx[sf][band] );
+ reconstruct_ism_ratios_fx( ratio_ism_idx[band], nchan_ism, STEP_PARAM_ISM_POW_RATIO_NBITS_Q31, hMasa->data.hOmasaData->q_energy_ratio_ism_fx[sf][band] );
}
test();
IF( GT_16( nchan_ism, 2 ) && EQ_16( idx_separated_object, sub( nchan_ism, 1 ) ) )
diff --git a/lib_enc/ivas_mc_param_enc_fx.c b/lib_enc/ivas_mc_param_enc_fx.c
index 22eacdb32b9eab6291c8a29388e2a20ca12a0cc1..ac836b67430820f89672a3e81449b36a8c1a6807 100644
--- a/lib_enc/ivas_mc_param_enc_fx.c
+++ b/lib_enc/ivas_mc_param_enc_fx.c
@@ -30,6 +30,21 @@
*******************************************************************************************************/
+// helper macros to convert the 64 bitt accumulators into the 48 bit float format
+#define CONVERT_CY( x_64, y_fx, y_e ) \
+ { \
+ Word16 norm; \
+ norm = W_norm( x_64 ); \
+ y_fx = W_extract_h( W_shl( x_64, norm ) ); \
+ y_e = sub( sub62gb, norm ); \
+ }
+#define CONVERT_DMX( x_64, y_fx, y_e ) \
+ { \
+ Word16 norm; \
+ norm = W_norm( x_64 ); \
+ y_fx = W_extract_h( W_shl( x_64, norm ) ); \
+ y_e = sub( sub35gb, norm ); \
+ }
#include
#include
#include "options.h"
@@ -649,15 +664,22 @@ static void ivas_param_mc_param_est_enc_fx(
Word32 *p_slot_frame_f_real_fx[MAX_CICP_CHANNELS]; /* Output of the MDFT FB - real part */
Word32 *p_slot_frame_f_imag_fx[MAX_CICP_CHANNELS]; /* Output of the MDFT FB - imag part */
+#ifdef MERGE_REQUEST_1472_SPEEDUP_ivas_mc_param_enc_fx_NONBE
+ Word64 dmx_real_64[PARAM_MC_MAX_TRANSPORT_CHANS];
+ Word64 dmx_imag_64[PARAM_MC_MAX_TRANSPORT_CHANS];
+#else
Word32 dmx_real_fx[PARAM_MC_MAX_TRANSPORT_CHANS]; /* Downmix channel - Real Part */
Word16 dmx_real_e[PARAM_MC_MAX_TRANSPORT_CHANS]; /* Downmix channel - Real Part */
Word32 dmx_imag_fx[PARAM_MC_MAX_TRANSPORT_CHANS]; /* Downmix channel - Imag Part */
Word16 dmx_imag_e[PARAM_MC_MAX_TRANSPORT_CHANS]; /* Downmix channel - Imag Part */
- Word32 a_fx, b_fx, c_fx, d_fx; /* Tmp complex values */
- Word16 a_e, b_e, c_e, d_e; /* Tmp complex values */
+#endif
+ Word32 a_fx, b_fx, c_fx, d_fx; /* Tmp complex values */
+ Word16 a_e, b_e, c_e, d_e; /* Tmp complex values */
#ifdef MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE
Word64 Cy_sum_real_64[PARAM_MC_MAX_PARAMETER_BANDS][MAX_CICP_CHANNELS][MAX_CICP_CHANNELS];
Word64 Cy_sum_imag_64[PARAM_MC_MAX_PARAM_BAND_ABS_COV_ENC][MAX_CICP_CHANNELS][MAX_CICP_CHANNELS];
+ Word16 sub62gb;
+ Word16 sub35gb;
#else
Word32 Cy_sum_imag_fx[PARAM_MC_MAX_PARAM_BAND_ABS_COV_ENC][MAX_CICP_CHANNELS][MAX_CICP_CHANNELS];
Word16 Cy_sum_imag_e[PARAM_MC_MAX_PARAM_BAND_ABS_COV_ENC][MAX_CICP_CHANNELS][MAX_CICP_CHANNELS];
@@ -707,8 +729,8 @@ static void ivas_param_mc_param_est_enc_fx(
#ifdef MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE
set64_fx( Cy_sum_imag_64[cur_param_band][ch_idx1], 0, MAX_CICP_CHANNELS );
#else
- set32_fx( Cy_sum_fx[cur_param_band][ch_idx1], 0, MAX_CICP_CHANNELS );
- set16_fx( Cy_sum_e[cur_param_band][ch_idx1], 0, MAX_CICP_CHANNELS );
+ set32_fx( Cy_sum_imag_fx[cur_param_band][ch_idx1], 0, MAX_CICP_CHANNELS );
+ set16_fx( Cy_sum_imag_e[cur_param_band][ch_idx1], 0, MAX_CICP_CHANNELS );
#endif
}
@@ -740,9 +762,16 @@ static void ivas_param_mc_param_est_enc_fx(
#if defined( IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_BE ) || defined( IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_NONBE )
Word16 gb = find_guarded_bits_fx( l_ts );
+#ifndef MERGE_REQUEST_1472_SPEEDUP_ivas_mc_param_enc_fx_NONBE
Word16 add20gb = add( 20, gb );
#endif
+#endif
+#ifdef MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE
+ sub35gb = sub( 32, sub( 11, find_guarded_bits_fx( l_ts ) ) ); // 31 - (((11 - gb) + 31 + norm) - 32)
+ sub62gb = sub( 63, shl( sub( 11, find_guarded_bits_fx( l_ts ) ), 1 ) ); // 31 - ((2*(11 - gb) + norm) - 32)
+#endif
+
FOR( ts = start_ts; ts < num_time_slots; ts++ )
{
#if !defined( IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_BE ) && !defined( IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_NONBE )
@@ -774,6 +803,26 @@ static void ivas_param_mc_param_est_enc_fx(
FOR( ch_idx1 = 0; ch_idx1 < nchan_transport; ++ch_idx1 )
{
+#ifdef MERGE_REQUEST_1472_SPEEDUP_ivas_mc_param_enc_fx_NONBE
+ Word64 real_64;
+ Word64 imag_64;
+
+ real_64 = 0;
+ imag_64 = 0;
+ move64();
+ move64();
+ FOR( inp_ch = 0; inp_ch < nchan_input; inp_ch++ )
+ {
+ real_64 = W_add( real_64, W_mult0_32_32( slot_frame_f_real_fx[inp_ch][cur_cldfb_band], ( *p_dmx_fac_fx ) ) );
+ imag_64 = W_add( imag_64, W_mult0_32_32( slot_frame_f_imag_fx[inp_ch][cur_cldfb_band], ( *p_dmx_fac_fx ) ) );
+ p_dmx_fac_fx++;
+ }
+ dmx_real_64[ch_idx1] = real_64;
+ dmx_imag_64[ch_idx1] = imag_64;
+ move64();
+ move64();
+
+#else
#ifndef IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_BE
dmx_real_fx[ch_idx1] = 0;
move32();
@@ -814,14 +863,24 @@ static void ivas_param_mc_param_est_enc_fx(
move16();
move32();
move16();
+#endif
+
#endif
}
/* Cx for transport channels */
FOR( ch_idx1 = 0; ch_idx1 < nchan_transport; ++ch_idx1 )
{
+#ifdef MERGE_REQUEST_1472_SPEEDUP_ivas_mc_param_enc_fx_NONBE
+ CONVERT_DMX( dmx_real_64[ch_idx1], a_fx, a_e );
+ CONVERT_DMX( dmx_imag_64[ch_idx1], b_fx, b_e );
+#endif
FOR( ch_idx2 = 0; ch_idx2 < nchan_transport; ++ch_idx2 )
{
+#ifdef MERGE_REQUEST_1472_SPEEDUP_ivas_mc_param_enc_fx_NONBE
+ CONVERT_DMX( dmx_real_64[ch_idx2], c_fx, c_e );
+ CONVERT_DMX( dmx_imag_64[ch_idx2], d_fx, d_e );
+#else
a_fx = dmx_real_fx[ch_idx1];
move32();
a_e = dmx_real_e[ch_idx1];
@@ -838,6 +897,7 @@ static void ivas_param_mc_param_est_enc_fx(
move32();
d_e = dmx_imag_e[ch_idx2];
move16();
+#endif
/* (a-ib)(c+id) = ac + bd + i(ad-bc) */
L_tmp = BASOP_Util_Add_Mant32Exp( Mpy_32_32( a_fx, c_fx ), add( a_e, c_e ), Mpy_32_32( b_fx, d_fx ), add( b_e, d_e ), &tmp_e );
@@ -858,7 +918,6 @@ static void ivas_param_mc_param_est_enc_fx(
move32();
FOR( ch_idx2 = ch_idx1; ch_idx2 < nchan_input; ++ch_idx2 )
{
- Word16 norm;
c_fx = slot_frame_f_real_fx[ch_idx2][cur_cldfb_band];
d_fx = slot_frame_f_imag_fx[ch_idx2][cur_cldfb_band];
move32();
@@ -869,11 +928,6 @@ static void ivas_param_mc_param_est_enc_fx(
Cy_sum_imag_64[cur_param_band][ch_idx1][ch_idx2] = W_add( Cy_sum_imag_64[cur_param_band][ch_idx1][ch_idx2],
W_sub( W_mult0_32_32( a_fx, d_fx ), W_mult0_32_32( b_fx, c_fx ) ) );
move64();
-
- // convert the 64 bit fixpoint back into the 48 bit float format
- norm = W_norm( Cy_sum_real_64[cur_param_band][ch_idx1][ch_idx2] );
- Cy_sum_fx[cur_param_band][ch_idx1][ch_idx2] = W_extract_h( W_shl( Cy_sum_real_64[cur_param_band][ch_idx1][ch_idx2], norm ) );
- Cy_sum_e[cur_param_band][ch_idx1][ch_idx2] = sub( sub( 62, gb ), norm );
}
}
#else
@@ -953,6 +1007,26 @@ static void ivas_param_mc_param_est_enc_fx(
FOR( ch_idx1 = 0; ch_idx1 < nchan_transport; ++ch_idx1 )
{
+#ifdef MERGE_REQUEST_1472_SPEEDUP_ivas_mc_param_enc_fx_NONBE
+ Word64 real_64;
+ Word64 imag_64;
+
+ real_64 = 0;
+ imag_64 = 0;
+ move64();
+ move64();
+
+ FOR( inp_ch = 0; inp_ch < nchan_input; inp_ch++ )
+ {
+ real_64 = W_add( real_64, W_mult0_32_32( slot_frame_f_real_fx[inp_ch][cur_cldfb_band], ( *p_dmx_fac_fx ) ) );
+ imag_64 = W_add( imag_64, W_mult0_32_32( slot_frame_f_imag_fx[inp_ch][cur_cldfb_band], ( *p_dmx_fac_fx ) ) );
+ p_dmx_fac_fx++;
+ }
+ dmx_real_64[ch_idx1] = real_64;
+ dmx_imag_64[ch_idx1] = imag_64;
+ move64();
+ move64();
+#else
#ifndef IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_BE
dmx_real_fx[ch_idx1] = 0;
move32();
@@ -997,12 +1071,18 @@ static void ivas_param_mc_param_est_enc_fx(
move32();
dmx_imag_e[ch_idx1] = imag_e;
move16();
+#endif
+
#endif
}
/* Cx for transport channels */
FOR( ch_idx1 = 0; ch_idx1 < nchan_transport; ++ch_idx1 )
{
+#ifdef MERGE_REQUEST_1472_SPEEDUP_ivas_mc_param_enc_fx_NONBE
+ CONVERT_DMX( dmx_real_64[ch_idx1], a_fx, a_e );
+ CONVERT_DMX( dmx_imag_64[ch_idx1], b_fx, b_e );
+#else
#ifdef IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_BE
a_fx = dmx_real_fx[ch_idx1];
move32();
@@ -1012,9 +1092,20 @@ static void ivas_param_mc_param_est_enc_fx(
move32();
b_e = dmx_imag_e[ch_idx1];
move16();
+#endif
+
#endif
FOR( ch_idx2 = 0; ch_idx2 < nchan_transport; ++ch_idx2 )
{
+#ifdef MERGE_REQUEST_1472_SPEEDUP_ivas_mc_param_enc_fx_NONBE
+ CONVERT_DMX( dmx_real_64[ch_idx2], c_fx, c_e );
+ CONVERT_DMX( dmx_imag_64[ch_idx2], d_fx, d_e );
+
+ /* (a-ib)(c+id) = ac + bd + i(ad-bc) */
+ L_tmp = BASOP_Util_Add_Mant32Exp( Mpy_32_32( a_fx, c_fx ), add( a_e, c_e ), Mpy_32_32( b_fx, d_fx ), add( b_e, d_e ), &tmp_e );
+ Cx_sum_fx[cur_param_band][ch_idx1][ch_idx2] = BASOP_Util_Add_Mant32Exp( Cx_sum_fx[cur_param_band][ch_idx1][ch_idx2], Cx_sum_e[cur_param_band][ch_idx1][ch_idx2], L_tmp, tmp_e,
+ &Cx_sum_e[cur_param_band][ch_idx1][ch_idx2] );
+#else
#ifndef IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_BE
a_fx = dmx_real_fx[ch_idx1];
move32();
@@ -1042,6 +1133,7 @@ static void ivas_param_mc_param_est_enc_fx(
L_tmp = BASOP_Util_Add_Mant32Exp( Mpy_32_32( a_fx, dmx_real_fx[ch_idx2] ), add( a_e, dmx_real_e[ch_idx2] ), Mpy_32_32( b_fx, dmx_imag_fx[ch_idx2] ), add( b_e, dmx_imag_e[ch_idx2] ), &tmp_e );
Cx_sum_fx[cur_param_band][ch_idx1][ch_idx2] = BASOP_Util_Add_Mant32Exp( Cx_sum_fx[cur_param_band][ch_idx1][ch_idx2], Cx_sum_e[cur_param_band][ch_idx1][ch_idx2], L_tmp, tmp_e,
&Cx_sum_e[cur_param_band][ch_idx1][ch_idx2] );
+#endif
#endif
move32();
}
@@ -1075,7 +1167,6 @@ static void ivas_param_mc_param_est_enc_fx(
move32();
FOR( ch_idx2 = ch_idx1; ch_idx2 < nchan_input; ++ch_idx2 )
{
- Word16 norm;
c_fx = slot_frame_f_real_fx[ch_idx2][cur_cldfb_band];
d_fx = slot_frame_f_imag_fx[ch_idx2][cur_cldfb_band];
move32();
@@ -1084,10 +1175,6 @@ static void ivas_param_mc_param_est_enc_fx(
Cy_sum_real_64[cur_param_band][ch_idx1][ch_idx2] = W_add( Cy_sum_real_64[cur_param_band][ch_idx1][ch_idx2],
W_add( W_mult0_32_32( a_fx, c_fx ), W_mult0_32_32( b_fx, d_fx ) ) );
move64();
- // convert the 64 bit fixpoint back into the 48 bit float format
- norm = W_norm( Cy_sum_real_64[cur_param_band][ch_idx1][ch_idx2] );
- Cy_sum_fx[cur_param_band][ch_idx1][ch_idx2] = W_extract_h( W_shl( Cy_sum_real_64[cur_param_band][ch_idx1][ch_idx2], norm ) );
- Cy_sum_e[cur_param_band][ch_idx1][ch_idx2] = sub( sub( 62, gb ), norm );
}
#else
FOR( ch_idx2 = ch_idx1; ch_idx2 < nchan_input; ++ch_idx2 )
@@ -1135,14 +1222,6 @@ static void ivas_param_mc_param_est_enc_fx(
{
FOR( ch_idx1 = 0; ch_idx1 < nchan_input; ++ch_idx1 )
{
- Cy_sum_fx[cur_param_band][hParamMC->lfe_index][ch_idx1] = 0;
- move32();
- Cy_sum_e[cur_param_band][hParamMC->lfe_index][ch_idx1] = 0;
- move16();
- Cy_sum_fx[cur_param_band][ch_idx1][hParamMC->lfe_index] = 0;
- move32();
- Cy_sum_e[cur_param_band][ch_idx1][hParamMC->lfe_index] = 0;
- move16();
#ifdef MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE
Cy_sum_real_64[cur_param_band][hParamMC->lfe_index][ch_idx1] = 0;
move64();
@@ -1153,6 +1232,14 @@ static void ivas_param_mc_param_est_enc_fx(
Cy_sum_imag_64[cur_param_band][ch_idx1][hParamMC->lfe_index] = 0;
move64();
#else
+ Cy_sum_fx[cur_param_band][hParamMC->lfe_index][ch_idx1] = 0;
+ move32();
+ Cy_sum_e[cur_param_band][hParamMC->lfe_index][ch_idx1] = 0;
+ move16();
+ Cy_sum_fx[cur_param_band][ch_idx1][hParamMC->lfe_index] = 0;
+ move32();
+ Cy_sum_e[cur_param_band][ch_idx1][hParamMC->lfe_index] = 0;
+ move16();
Cy_sum_imag_fx[cur_param_band][hParamMC->lfe_index][ch_idx1] = 0;
move32();
Cy_sum_imag_e[cur_param_band][hParamMC->lfe_index][ch_idx1] = 0;
@@ -1174,7 +1261,7 @@ static void ivas_param_mc_param_est_enc_fx(
move64();
Cy_sum_real_64[cur_param_band][ch_idx1][hParamMC->lfe_index] = 0;
move64();
-#endif
+#else
Cy_sum_fx[cur_param_band][hParamMC->lfe_index][ch_idx1] = 0;
move32();
Cy_sum_e[cur_param_band][hParamMC->lfe_index][ch_idx1] = 0;
@@ -1183,6 +1270,7 @@ static void ivas_param_mc_param_est_enc_fx(
move32();
Cy_sum_e[cur_param_band][ch_idx1][hParamMC->lfe_index] = 0;
move16();
+#endif
}
}
}
@@ -1220,11 +1308,9 @@ static void ivas_param_mc_param_est_enc_fx(
FOR( k = 0; k < nchan_input; ++k )
{
#ifdef MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE
- Word16 norm;
- // convert the 64 bit fixpoint back into the 48 bit float format
- norm = W_norm( Cy_sum_real_64[cur_param_band][k][k] );
- Nrg_fx[k] = W_extract_h( W_shl( Cy_sum_real_64[cur_param_band][k][k], norm ) );
- Nrg_e[k] = sub( sub( 62, gb ), norm );
+ CONVERT_CY( Cy_sum_real_64[cur_param_band][k][k], Nrg_fx[k], Nrg_e[k] );
+ move32();
+ move16();
#else
Nrg_fx[k] = Cy_sum_fx[cur_param_band][k][k];
move32();
@@ -1361,10 +1447,9 @@ static void ivas_param_mc_param_est_enc_fx(
{
FOR( ch_idx2 = 0; ch_idx2 < MAX_CICP_CHANNELS; ch_idx2++ )
{
- Word16 norm;
- norm = W_norm( Cy_sum_real_64[cur_param_band][ch_idx1][ch_idx2] );
- Cy_sum_fx[cur_param_band][ch_idx1][ch_idx2] = W_extract_h( W_shl( Cy_sum_real_64[cur_param_band][ch_idx1][ch_idx2], norm ) );
- Cy_sum_e[cur_param_band][ch_idx1][ch_idx2] = sub( sub( 62, gb ), norm );
+ CONVERT_CY( Cy_sum_real_64[cur_param_band][ch_idx1][ch_idx2], Cy_sum_fx[cur_param_band][ch_idx1][ch_idx2], Cy_sum_e[cur_param_band][ch_idx1][ch_idx2] );
+ move32();
+ move16();
}
}
}
@@ -1407,11 +1492,9 @@ static void ivas_param_mc_param_est_enc_fx(
FOR( ch_idx2 = ch_idx1; ch_idx2 < nchan_input; ch_idx2++ )
{
#ifdef MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE
- Word16 norm;
- // convert the 64 bit fixpoint back into the 48 bit float format
- norm = W_norm( Cy_sum_imag_64[cur_param_band][ch_idx1][ch_idx2] );
- imag_part_fx = W_extract_h( W_shl( Cy_sum_imag_64[cur_param_band][ch_idx1][ch_idx2], norm ) );
- imag_part_e = sub( sub( 62, gb ), norm );
+ CONVERT_CY( Cy_sum_imag_64[cur_param_band][ch_idx1][ch_idx2], imag_part_fx, imag_part_e );
+ move32();
+ move16();
#else
imag_part_fx = Cy_sum_imag_fx[cur_param_band][ch_idx1][ch_idx2];
move32();
@@ -1613,9 +1696,22 @@ static void ivas_param_mc_quantize_ilds_fx(
{
dmx_ener_fx = BASOP_Util_Add_Mant32Exp( dmx_ener_fx, dmx_ener_e, Cx_fx[k][k], Cx_e[k][k], &dmx_ener_e );
}
+ /* ener_fac = 10.0f * log10f( ( tot_ener + EPSILON ) / ( dmx_ener + EPSILON ) ); */
+ IF( tot_ener_fx == 0 )
+ {
+ tot_ener_fx = 9223; // 1e-15(EPSILON) in Q63
+ tot_ener_e = -32;
+ move32();
+ move16();
+ }
+ IF( dmx_ener_fx == 0 )
+ {
+ dmx_ener_fx = 9223; // 1e-15(EPSILON) in Q63
+ dmx_ener_e = -32;
+ move32();
+ move16();
+ }
- tot_ener_fx = BASOP_Util_Add_Mant32Exp( tot_ener_fx, tot_ener_e, EPSILON_FX, 0, &tot_ener_e );
- dmx_ener_fx = BASOP_Util_Add_Mant32Exp( dmx_ener_fx, dmx_ener_e, EPSILON_FX, 0, &dmx_ener_e );
L_tmp = L_deposit_h( BASOP_Util_Divide3232_Scale( tot_ener_fx, dmx_ener_fx, &tmp_e ) );
tmp_e = add( sub( tot_ener_e, dmx_ener_e ), tmp_e );
ener_fac_fx = BASOP_Util_Log10( L_tmp, tmp_e ); // Q25
diff --git a/lib_enc/ivas_mcmasa_enc_fx.c b/lib_enc/ivas_mcmasa_enc_fx.c
index 7a5718e9958d3eb7989f4168b4c8876fcc84f3c5..ab86efb8d983c46f19b72536292afa7cfed94456 100644
--- a/lib_enc/ivas_mcmasa_enc_fx.c
+++ b/lib_enc/ivas_mcmasa_enc_fx.c
@@ -81,7 +81,16 @@ static void compute_cov_mtx_fx(
CovarianceMatrix *COVls, /* o : Output matrix, contains upper part of cov mtx */
Word16 inp_exp /*Stores exponent for temp*/
);
-static void computeIntensityVector_enc_fx( const Word16 *band_grouping, Word32 Cldfb_RealBuffer[FOA_CHANNELS][DIRAC_NO_FB_BANDS_MAX], Word32 Cldfb_ImagBuffer[FOA_CHANNELS][DIRAC_NO_FB_BANDS_MAX], const Word16 enc_param_start_band, const Word16 num_frequency_bands, Word32 intensity_real[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS] );
+
+static void computeIntensityVector_enc_fx(
+ const Word16 *band_grouping,
+ Word32 Cldfb_RealBuffer[FOA_CHANNELS][DIRAC_NO_FB_BANDS_MAX],
+ Word32 Cldfb_ImagBuffer[FOA_CHANNELS][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][MASA_FREQUENCY_BANDS],
+ Word16 q_intensity_real[MASA_FREQUENCY_BANDS],
+ Word16 inp_q );
static void computeVerticalDiffuseness_fx(
Word32 **buffer_intensity, /* i : Intensity vectors */
@@ -737,7 +746,7 @@ void ivas_mcmasa_enc_fx(
move32();
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]; // Q30
+ hQMeta->q_direction[0].band_data[i].energy_ratio_fx[j] = energyRatio_fx[k][i]; // Q31
move32();
hQMeta->q_direction[0].band_data[i].distance[j] = fixedDistance;
move16();
@@ -939,6 +948,8 @@ void ivas_mcmasa_param_est_enc_fx(
Word16 renormalization_factor_coh_e[MASA_FREQUENCY_BANDS];
Word16 surroundingCoherence_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];
Word16 numAnalysisChannels;
+ Word16 q_intensity_real_fx[MASA_FREQUENCY_BANDS], q_intensity_even_real_fx[MASA_FREQUENCY_BANDS], q_reference_power_fx[DIRAC_NO_FB_BANDS_MAX];
+ Word16 c_e, ref_e, shift;
FOR( i = 0; i < MCMASA_MAX_ANA_CHANS; i++ )
{
@@ -1029,7 +1040,7 @@ void ivas_mcmasa_param_est_enc_fx(
FOR( ts = mrange[0]; ts < mrange[1]; ts++ )
{
- Word16 cr_q = MAX_16, ci_q = MAX_16, sf, c_e;
+ Word16 cr_q = MAX_16, ci_q = MAX_16, sf;
Word16 inp_q = q_inp;
move16();
move16();
@@ -1053,7 +1064,6 @@ void ivas_mcmasa_param_est_enc_fx(
scale_sig32( Chnl_ImagBuffer_fx[i], DIRAC_NO_FB_BANDS_MAX, sf ); // Q-> inp_q + sf
}
inp_q = add( inp_q, sf );
- c_e = sub( 31, inp_q );
/* Compute covariance matrix */
FOR( i = 0; i < num_freq_bands; i++ )
@@ -1168,7 +1178,9 @@ void ivas_mcmasa_param_est_enc_fx(
Foa_ImagBuffer_fx,
0,
num_freq_bands,
- intensity_real_fx );
+ intensity_real_fx,
+ q_intensity_real_fx,
+ inp_q );
computeDirectionVectors_fixed(
intensity_real_fx[0],
@@ -1178,8 +1190,9 @@ void ivas_mcmasa_param_est_enc_fx(
num_freq_bands,
direction_vector_fx[0],
direction_vector_fx[1],
- direction_vector_fx[2], c_e,
- NULL );
+ direction_vector_fx[2],
+ 0,
+ q_intensity_real_fx );
/* Power and intensity estimation for diffuseness */
computeIntensityVector_enc_fx(
@@ -1188,18 +1201,54 @@ void ivas_mcmasa_param_est_enc_fx(
FoaEven_ImagBuffer_fx,
0,
num_freq_bands,
- intensity_even_real_fx );
- Word16 ref_e = 0;
- move16();
- computeReferencePower_enc_fx( hMcMasa->band_grouping,
- FoaEven_RealBuffer_fx,
- FoaEven_ImagBuffer_fx,
- reference_power_fx[ts],
- 0,
- num_freq_bands,
- MC_FORMAT,
- 0,
- FOA_CHANNELS, inp_q, &ref_e );
+ intensity_even_real_fx,
+ q_intensity_even_real_fx,
+ inp_q );
+
+ computeReferencePower_enc_fx(
+ hMcMasa->band_grouping,
+ FoaEven_RealBuffer_fx,
+ FoaEven_ImagBuffer_fx,
+ reference_power_fx[ts],
+ 0,
+ num_freq_bands,
+ MC_FORMAT,
+ 0,
+ FOA_CHANNELS,
+ inp_q,
+ q_reference_power_fx );
+
+ minimum_fx( q_intensity_real_fx, num_freq_bands, &c_e );
+ minimum_fx( q_intensity_even_real_fx, num_freq_bands, &shift );
+ minimum_fx( q_reference_power_fx, num_freq_bands, &ref_e );
+
+ Word16 tmp;
+ FOR( i = 0; i < num_freq_bands; i++ )
+ {
+ tmp = sub( c_e, q_intensity_real_fx[i] );
+ intensity_real_fx[0][i] = L_shl( intensity_real_fx[0][i], tmp );
+ move32();
+ intensity_real_fx[1][i] = L_shl( intensity_real_fx[1][i], tmp );
+ move32();
+ intensity_real_fx[2][i] = L_shl( intensity_real_fx[2][i], tmp );
+ move32();
+
+ tmp = sub( shift, q_intensity_even_real_fx[i] );
+ intensity_even_real_fx[0][i] = L_shl( intensity_even_real_fx[0][i], tmp );
+ move32();
+ intensity_even_real_fx[1][i] = L_shl( intensity_even_real_fx[1][i], tmp );
+ move32();
+ intensity_even_real_fx[2][i] = L_shl( intensity_even_real_fx[2][i], tmp );
+ move32();
+
+ tmp = sub( ref_e, q_reference_power_fx[i] );
+ reference_power_fx[ts][i] = L_shl( reference_power_fx[ts][i], tmp );
+ move32();
+ }
+
+ c_e = sub( Q31, c_e );
+ shift = sub( Q31, shift );
+ ref_e = sub( Q31, ref_e );
/* Fill buffers of length "averaging_length" time slots for intensity and energy */
hMcMasa->index_buffer_intensity = add( ( hMcMasa->index_buffer_intensity % hMcMasa->no_col_avg_diff ), 1 ); /* averaging_length = 32 */
@@ -1211,7 +1260,7 @@ void ivas_mcmasa_param_est_enc_fx(
/* only real part needed */
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 );
+ hMcMasa->buffer_intensity_real_q[index - 1] = sub( 31, shift );
move16();
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 );
@@ -1227,7 +1276,7 @@ void ivas_mcmasa_param_est_enc_fx(
IF( !hMcMasa->isHorizontalSetup )
{
Copy32( intensity_real_fx[2], &( hMcMasa->buffer_intensity_real_vert_fx[index - 1][0] ), num_freq_bands );
- hMcMasa->buffer_intensity_real_vert_q[index - 1] = sub( shl( inp_q, 1 ), 31 );
+ hMcMasa->buffer_intensity_real_vert_q[index - 1] = sub( 31, c_e );
move16();
computeVerticalDiffuseness_fx( hMcMasa->buffer_intensity_real_vert_fx, hMcMasa->buffer_energy_fx, hMcMasa->no_col_avg_diff, num_freq_bands, vertical_diffuseness_vector_fx, hMcMasa->buffer_intensity_real_vert_q, hMcMasa->buffer_energy_q );
v_min_fx( diffuseness_vector_fx, out_exp, vertical_diffuseness_vector_fx, q_vdv, diffuseness_vector_fx, out_exp, num_freq_bands );
@@ -2036,6 +2085,41 @@ static void compute_cov_mtx_fx(
)
{
Word16 i, j;
+#ifdef OPT_MCT_ENC_V1_NBE
+ Word64 temp64_1, temp64_2;
+ Word16 tmp_16, max_exp;
+ Word16 temp_exp = shl( inp_exp, 1 );
+ FOR( i = 0; i < N; i++ )
+ {
+ FOR( j = i; j < N; j++ )
+ {
+ temp64_1 = W_mac_32_32( W_mult_32_32( sr[i][freq], sr[j][freq] ), si[i][freq], si[j][freq] ); // exp:2*inp_exp
+ temp64_2 = W_deposit32_h( COVls->xr_fx[i][j] ); // exp:COVls->xr_e[i][j]
+ max_exp = s_max( COVls->xr_e[i][j], temp_exp );
+ temp64_2 = W_shl( temp64_2, sub( COVls->xr_e[i][j], max_exp ) ); // exp:max_exp
+ temp64_1 = W_shl( temp64_1, sub( temp_exp, max_exp ) ); // exp:max_exp
+ temp64_1 = W_add( temp64_1, temp64_2 ); // exp:max_exp
+ tmp_16 = W_norm( temp64_1 );
+
+ COVls->xr_fx[i][j] = W_extract_h( W_shl( temp64_1, tmp_16 ) ); // exp:max_exp-tmp_16
+ COVls->xr_e[i][j] = sub( max_exp, tmp_16 );
+ move32();
+ move16();
+
+ temp64_1 = W_sub( W_mult_32_32( si[i][freq], sr[j][freq] ), W_mult_32_32( sr[i][freq], si[j][freq] ) ); // exp :2*inp_exp
+ temp64_2 = W_deposit32_h( COVls->xi_fx[i][j] ); // exp:COVls->xi_e[i][j]
+ max_exp = s_max( COVls->xi_e[i][j], temp_exp );
+ temp64_2 = W_shl( temp64_2, sub( COVls->xi_e[i][j], max_exp ) ); // exp:max_exp
+ temp64_1 = W_shl( temp64_1, sub( temp_exp, max_exp ) ); // exp:max_exp
+ temp64_1 = W_add( temp64_1, temp64_2 ); // exp:max_exp
+ tmp_16 = W_norm( temp64_1 );
+
+ COVls->xi_fx[i][j] = W_extract_h( W_shl( temp64_1, tmp_16 ) ); // exp:max_exp-tmp_16
+ COVls->xi_e[i][j] = sub( max_exp, tmp_16 );
+ move32();
+ }
+ }
+#else
Word32 a, b, c, d;
Word32 temp;
Word16 norm_a, norm_b, norm_c, norm_d;
@@ -2068,24 +2152,33 @@ static void compute_cov_mtx_fx(
move32();
}
}
-
+#endif
return;
}
+
static void computeIntensityVector_enc_fx(
const Word16 *band_grouping,
- Word32 Cldfb_RealBuffer[FOA_CHANNELS][DIRAC_NO_FB_BANDS_MAX],
- Word32 Cldfb_ImagBuffer[FOA_CHANNELS][DIRAC_NO_FB_BANDS_MAX],
- const Word16 enc_param_start_band, /* i : first band to process */
+ Word32 Cldfb_RealBuffer[FOA_CHANNELS][DIRAC_NO_FB_BANDS_MAX], /*inp_q*/
+ Word32 Cldfb_ImagBuffer[FOA_CHANNELS][DIRAC_NO_FB_BANDS_MAX], /*inp_q*/
+ const Word16 enc_param_start_band, /* i : first band to process */
const Word16 num_frequency_bands,
- Word32 intensity_real[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS] )
+ Word32 intensity_real[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS], /*exp: exp_intensity_real*/
+ Word16 q_intensity_real[MASA_FREQUENCY_BANDS],
+ Word16 inp_q )
{
- /* Reminder
- * X = a + ib; Y = c + id
- * X*Y = ac - bd + i(ad +bc)
- */
Word16 i, j;
Word32 real, img;
Word16 brange[2];
+ Word16 shift_intensity_real, num_bins, guard_bits, norm;
+
+ Word64 intensity_real64[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS];
+
+ FOR( i = 0; i < DIRAC_NUM_DIMS; i++ )
+ {
+ set64_fx( intensity_real64[i], 0, MASA_FREQUENCY_BANDS );
+ }
+
+ shift_intensity_real = sub( shl( inp_q, 1 ), 32 );
FOR( i = enc_param_start_band; i < enc_param_start_band + num_frequency_bands; i++ )
{
@@ -2094,6 +2187,9 @@ static void computeIntensityVector_enc_fx(
brange[1] = band_grouping[i + 1];
move16();
+ num_bins = sub( brange[1], brange[0] );
+ guard_bits = find_guarded_bits_fx( num_bins );
+
intensity_real[0][i] = 0;
move32();
intensity_real[1][i] = 0;
@@ -2108,17 +2204,43 @@ static void computeIntensityVector_enc_fx(
img = Cldfb_ImagBuffer[0][j];
move32();
/* Intensity is XYZ order, audio is WYZX order. */
- intensity_real[0][i] = L_add( intensity_real[0][i], L_add( Mpy_32_32( Cldfb_RealBuffer[3][j], real ), Mpy_32_32( Cldfb_ImagBuffer[3][j], img ) ) ); // output Q= 2* input_q -31
+ intensity_real64[0][i] = W_add( intensity_real64[0][i], W_shr( W_add( W_mult0_32_32( Cldfb_RealBuffer[3][j], real ), W_mult0_32_32( Cldfb_ImagBuffer[3][j], img ) ), guard_bits ) ); // output Q= 2* input_q - guard_bits
move32();
- intensity_real[1][i] = L_add( intensity_real[1][i], L_add( Mpy_32_32( Cldfb_RealBuffer[1][j], real ), Mpy_32_32( Cldfb_ImagBuffer[1][j], img ) ) ); // output Q= 2* input_q -31
+ intensity_real64[1][i] = W_add( intensity_real64[1][i], W_shr( W_add( W_mult0_32_32( Cldfb_RealBuffer[1][j], real ), W_mult0_32_32( Cldfb_ImagBuffer[1][j], img ) ), guard_bits ) ); // output Q= 2* input_q - guard_bits
move32();
- intensity_real[2][i] = L_add( intensity_real[2][i], L_add( Mpy_32_32( Cldfb_RealBuffer[2][j], real ), Mpy_32_32( Cldfb_ImagBuffer[2][j], img ) ) ); // output Q= 2* input_q -31
+ intensity_real64[2][i] = W_add( intensity_real64[2][i], W_shr( W_add( W_mult0_32_32( Cldfb_RealBuffer[2][j], real ), W_mult0_32_32( Cldfb_ImagBuffer[2][j], img ) ), guard_bits ) ); // output Q= 2* input_q - guard_bits
move32();
}
+
+ norm = 63;
+ move16();
+ IF( intensity_real64[0][i] != 0 )
+ {
+ norm = s_min( norm, W_norm( intensity_real64[0][i] ) );
+ }
+ IF( intensity_real64[1][i] != 0 )
+ {
+ norm = s_min( norm, W_norm( intensity_real64[1][i] ) );
+ }
+ IF( intensity_real64[2][i] != 0 )
+ {
+ norm = s_min( norm, W_norm( intensity_real64[2][i] ) );
+ }
+
+ intensity_real[0][i] = W_extract_h( W_shl( intensity_real64[0][i], norm ) ); /*2 * inp_q - guard_bits + norm - 32*/
+ move32();
+ intensity_real[1][i] = W_extract_h( W_shl( intensity_real64[1][i], norm ) ); /*2 * inp_q - guard_bits + norm - 32*/
+ move32();
+ intensity_real[2][i] = W_extract_h( W_shl( intensity_real64[2][i], norm ) ); /*2 * inp_q - guard_bits + norm - 32*/
+ move32();
+
+ q_intensity_real[i] = add( shift_intensity_real, sub( norm, guard_bits ) );
+ move16();
}
return;
}
+
static void computeVerticalDiffuseness_fx(
Word32 **buffer_intensity, /* i : Intensity vectors */
const Word32 *buffer_energy, /* i : Energy */
diff --git a/lib_enc/ivas_mct_core_enc_fx.c b/lib_enc/ivas_mct_core_enc_fx.c
index 0ab232dd9552d462eb7cc75fc22638baeea4f871..71890120bfdece03191de1ec21b2313a6f278756 100644
--- a/lib_enc/ivas_mct_core_enc_fx.c
+++ b/lib_enc/ivas_mct_core_enc_fx.c
@@ -244,8 +244,8 @@ void ivas_mct_core_enc_fx(
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];
- Word16 q_powSpec[MCT_MAX_CHANNELS], q_powerSpecMsInv[MCT_MAX_CHANNELS], q_spec, q_origSpec, tmp_s;
- Word16 tmp_q_powSpec[L_FRAME48k], tmp_q_powSpecInv[L_FRAME48k], *tmp_q_psi[2];
+ Word16 q_powSpec[MCT_MAX_CHANNELS], q_spec, q_origSpec, tmp_s;
+ Word16 tmp_q_powSpec[L_FRAME48k], tmp_q_powSpecInv[MCT_MAX_CHANNELS][L_FRAME48k], *tmp_q_psi[MCT_MAX_CHANNELS][2];
Word64 W_tmp;
Encoder_State *sts[MCT_MAX_CHANNELS];
Encoder_State *st;
@@ -285,16 +285,17 @@ void ivas_mct_core_enc_fx(
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;
+ set16_fx( tmp_q_powSpecInv[ch], 63, L_FRAME48k );
+
+ tmp_q_psi[ch][0] = tmp_q_powSpecInv[ch];
+ tmp_q_psi[ch][1] = &tmp_q_powSpecInv[ch][N_TCX10_MAX];
+
inv_spectrum_fx[ch][0] = inv_spectrum_long_fx[ch];
inv_spectrum_fx[ch][1] = inv_spectrum_long_fx[ch] + N_TCX10_MAX;
}
- set16_fx( tmp_q_powSpecInv, 63, L_FRAME48k );
set16_fx( tmp_q_powSpec, 63, L_FRAME48k );
- tmp_q_psi[0] = tmp_q_powSpecInv;
- tmp_q_psi[1] = &tmp_q_powSpecInv[N_TCX10_MAX];
-
FOR( ( cpe_id = 0, i = 0 ); cpe_id < nCPE; cpe_id++ )
{
FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
@@ -451,7 +452,7 @@ void ivas_mct_core_enc_fx(
tmp_s = W_norm( W_tmp );
W_tmp = W_shl( W_tmp, tmp_s );
powerSpecMsInv_fx[ch][n][i] = W_extract_h( W_tmp );
- tmp_q_psi[n][i] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32
+ tmp_q_psi[ch][n][i] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32
move32();
move16();
}
@@ -465,7 +466,7 @@ void ivas_mct_core_enc_fx(
tmp_s = W_norm( W_tmp );
W_tmp = W_shl( W_tmp, tmp_s );
powerSpecMsInv_fx[ch][n][0] = W_extract_h( W_tmp );
- tmp_q_psi[n][0] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32
+ tmp_q_psi[ch][n][0] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32
move32();
move16();
@@ -477,7 +478,7 @@ void ivas_mct_core_enc_fx(
tmp_s = W_norm( W_tmp );
W_tmp = W_shl( W_tmp, tmp_s );
powerSpecMsInv_fx[ch][n][i] = W_extract_h( W_tmp );
- tmp_q_psi[n][i] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32
+ tmp_q_psi[ch][n][i] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32
move32();
move16();
}
@@ -486,7 +487,7 @@ void ivas_mct_core_enc_fx(
tmp_s = W_norm( W_tmp );
W_tmp = W_shl( W_tmp, tmp_s );
powerSpecMsInv_fx[ch][n][L_subframeTCX - 1] = W_extract_h( W_tmp );
- tmp_q_psi[n][L_subframeTCX - 1] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32
+ tmp_q_psi[ch][n][L_subframeTCX - 1] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32
move32();
move16();
}
@@ -529,8 +530,6 @@ void ivas_mct_core_enc_fx(
{
q_powSpec[ch] = Q31;
move16();
- q_powerSpecMsInv[ch] = Q31;
- move16();
/* NOTE: This logic has been added because using a constant headroom while computing `powSpec` and `powSpecMsInv` leads to significant precision loss, which results in poor quality. */
FOR( i = 0; i < L_FRAME48k; i++ )
{
@@ -539,18 +538,12 @@ void ivas_mct_core_enc_fx(
q_powSpec[ch] = s_min( q_powSpec[ch], add( tmp_q_powSpec[i], norm_l( powerSpec_fx[ch][i] ) ) );
move16();
}
- IF( powerSpecMsInv_fx[ch][0][i] != 0 )
- {
- q_powerSpecMsInv[ch] = s_min( q_powerSpecMsInv[ch], add( tmp_q_powSpecInv[i], norm_l( powerSpecMsInv_fx[ch][0][i] ) ) );
- 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_powerSpecMsInv[ch] ) );
powerSpec_fx[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] ) );
move32();
move32();
@@ -609,7 +602,7 @@ void ivas_mct_core_enc_fx(
{
IF( hMCT->currBlockDataCnt > 0 )
{
- mctStereoIGF_enc_fx( hMCT, sts, orig_spectrum_fx, q_origSpec, powerSpec_fx, q_powSpec, powerSpecMsInv_fx, q_powerSpecMsInv, inv_spectrum_fx, sp_aud_decision0 );
+ mctStereoIGF_enc_fx( hMCT, sts, orig_spectrum_fx, q_origSpec, powerSpec_fx, q_powSpec, powerSpecMsInv_fx, tmp_q_psi, inv_spectrum_fx, sp_aud_decision0 );
}
ELSE
{
diff --git a/lib_enc/ivas_mct_enc_fx.c b/lib_enc/ivas_mct_enc_fx.c
index 56f5e44db890533036f9f12cb5adae4d75c8d495..ee93533790141e5ef7364b3c6a1a28e82af16415 100644
--- a/lib_enc/ivas_mct_enc_fx.c
+++ b/lib_enc/ivas_mct_enc_fx.c
@@ -484,6 +484,9 @@ ivas_error ivas_mct_enc_fx(
Copy( hCPE->hCoreCoder[n]->input_fx, hCPE->hCoreCoder[n]->old_input_signal_fx, input_frame );
hCPE->hCoreCoder[n]->q_old_inp = hCPE->hCoreCoder[n]->q_inp;
move16();
+ Copy32( hCPE->hCoreCoder[n]->input32_fx, hCPE->hCoreCoder[n]->old_input_signal32_fx, input_frame );
+ hCPE->hCoreCoder[n]->q_old_inp32 = hCPE->hCoreCoder[n]->q_inp32;
+ move16();
/* common encoder updates */
updt_enc_common_ivas_fx( hCPE->hCoreCoder[n], Q_new_out[cpe_id][n] );
diff --git a/lib_enc/ivas_mct_enc_mct_fx.c b/lib_enc/ivas_mct_enc_mct_fx.c
index 94015abb7e0ddc68de2dcb04cb1c9da8740bad42..f28adafa428cd09ad2c0eb3fbaa74e8d0ddf4214 100644
--- a/lib_enc/ivas_mct_enc_mct_fx.c
+++ b/lib_enc/ivas_mct_enc_mct_fx.c
@@ -986,25 +986,26 @@ void mctStereoIGF_enc_fx(
Word32 powerSpec_fx[MCT_MAX_CHANNELS][L_FRAME48k], /* i/o: MDCT^2 + MDST^2 spectrum,or estimate */
Word16 q_powerSpec[MCT_MAX_CHANNELS], /* i : Q for powSpec_fx */
Word32 *powerSpecMsInv_fx[MCT_MAX_CHANNELS][NB_DIV], /* i : same as powerSpec_fx but for inverse spect.*/
- Word16 q_powerSpecMsInv[MCT_MAX_CHANNELS], /* i : Q for powSpecMsInv_fx */
+ Word16 *q_powerSpecMsInv[MCT_MAX_CHANNELS][NB_DIV], /* i : Q for powSpecMsInv_fx */
Word32 *inv_spectrum_fx[MCT_MAX_CHANNELS][NB_DIV], /* i : inverse spectrum */
const Word16 sp_aud_decision0[MCT_MAX_CHANNELS] /* i : speech audio decision */
)
{
Word32 *p_powerSpecMsInv_fx[CPE_CHANNELS][NB_DIV];
+ Word16 *q_p_powerSpecMsInv_fx[CPE_CHANNELS][NB_DIV];
Word32 *p_inv_spectrum_fx[CPE_CHANNELS][NB_DIV];
Word32 *p_orig_spectrum_fx[CPE_CHANNELS][NB_DIV];
Word32 *p_powerSpec_fx[NB_DIV];
+ Word16 *p_exp_powerSpec_fx[NB_DIV];
Word16 b, nSubframes, L_subframeTCX;
Word16 p_ch[2], n, ch, ch1, ch2;
- Word16 q_pSI_ch[2];
Word16 q_pS_ch[2];
Encoder_State *p_st[NB_DIV];
Encoder_State *st;
Word16 singleChEle[MCT_MAX_CHANNELS];
Word16 q_spectrum;
- Word16 exp_powerSpec[MCT_MAX_CHANNELS][N_MAX + L_MDCT_OVLP_MAX];
+ Word16 exp_powerSpec[MCT_MAX_CHANNELS][L_FRAME48k];
L_subframeTCX = 0; /* to avoid compilation warning */
move16();
@@ -1041,8 +1042,10 @@ 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]; // q_powerSpec
+ p_powerSpec_fx[0] = powerSpec_fx[ch1]; // q_powerSpec
+ p_exp_powerSpec_fx[0] = exp_powerSpec[ch1]; // q_powerSpec
p_powerSpec_fx[1] = powerSpec_fx[ch2];
+ p_exp_powerSpec_fx[1] = exp_powerSpec[ch2];
/* Band-wise M/S for MDST */
nSubframes = NB_DIV;
@@ -1059,12 +1062,12 @@ void mctStereoIGF_enc_fx(
p_orig_spectrum_fx[1][n] = orig_spectrum_fx[ch2][n];
p_powerSpecMsInv_fx[0][n] = powerSpecMsInv_fx[ch1][n]; // q_powerSpec
p_powerSpecMsInv_fx[1][n] = powerSpecMsInv_fx[ch2][n];
+ q_p_powerSpecMsInv_fx[0][n] = q_powerSpecMsInv[ch1][n]; // q_powerSpec
+ q_p_powerSpecMsInv_fx[1][n] = q_powerSpecMsInv[ch2][n];
p_inv_spectrum_fx[0][n] = inv_spectrum_fx[ch1][n];
p_inv_spectrum_fx[1][n] = inv_spectrum_fx[ch2][n];
q_pS_ch[0] = q_powerSpec[ch1];
- q_pSI_ch[0] = q_powerSpecMsInv[ch1];
q_pS_ch[1] = q_powerSpec[ch2];
- q_pSI_ch[1] = q_powerSpecMsInv[ch2];
move16();
move16();
@@ -1072,20 +1075,17 @@ void mctStereoIGF_enc_fx(
IF( NE_16( hMCT->hBlockData[b]->hStereoMdct->mdct_stereo_mode[n], hMCT->hBlockData[b]->hStereoMdct->IGFStereoMode[n] ) ||
EQ_16( hMCT->hBlockData[b]->hStereoMdct->mdct_stereo_mode[n], SMDCT_BW_MS ) )
{
- Word16 exp_powerSpec_fx[CPE_CHANNELS], exp_powerSpecMsInv_fx[CPE_CHANNELS], exp_inv_spectrum_fx[CPE_CHANNELS];
+ Word16 exp_inv_spectrum_fx[CPE_CHANNELS];
FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
{
- exp_powerSpec_fx[ch] = sub( Q31, q_pS_ch[ch] );
- exp_powerSpecMsInv_fx[ch] = sub( Q31, q_pSI_ch[ch] );
exp_inv_spectrum_fx[ch] = p_st[ch]->hTcxEnc->spectrum_e[n];
move16();
- move16();
- move16();
}
-
- ProcessStereoIGF_fx( hMCT->hBlockData[b]->hStereoMdct, p_st, hMCT->hBlockData[b]->mask, p_orig_spectrum_fx, q_origSpec, q_origSpec, p_powerSpec_fx, exp_powerSpec_fx,
- p_powerSpecMsInv_fx, exp_powerSpecMsInv_fx, p_inv_spectrum_fx, exp_inv_spectrum_fx, n, sp_aud_decision0[ch1], p_st[0]->total_brate, 1 );
+ set16_fx( exp_powerSpec[ch1], sub( Q31, q_pS_ch[0] ), L_FRAME48k );
+ set16_fx( exp_powerSpec[ch2], sub( Q31, q_pS_ch[1] ), L_FRAME48k );
+ ProcessStereoIGF_fx( hMCT->hBlockData[b]->hStereoMdct, p_st, hMCT->hBlockData[b]->mask, p_orig_spectrum_fx, q_origSpec, q_origSpec, p_powerSpec_fx, p_exp_powerSpec_fx,
+ p_powerSpecMsInv_fx, q_p_powerSpecMsInv_fx, p_inv_spectrum_fx, exp_inv_spectrum_fx, n, sp_aud_decision0[ch1], p_st[0]->total_brate, 1 );
}
ELSE
{
@@ -1102,7 +1102,7 @@ void mctStereoIGF_enc_fx(
q_spectrum = sub( 31, st->hTcxEnc->spectrum_e[n] );
- set16_fx( exp_powerSpec[p_ch[ch]], sub( Q31, q_powerSpec[p_ch[ch]] ), N_MAX + L_MDCT_OVLP_MAX );
+ set16_fx( exp_powerSpec[p_ch[ch]], sub( Q31, q_powerSpec[p_ch[ch]] ), L_FRAME48k );
ProcessIGF_ivas_fx( st, L_FRAME48k, st->hTcxEnc->spectrum_fx[n], &q_spectrum, orig_spectrum_fx[p_ch[ch]][n], q_origSpec, &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 );
@@ -1143,7 +1143,7 @@ void mctStereoIGF_enc_fx(
{
q_spectrum = sub( 31, st->hTcxEnc->spectrum_e[n] );
- set16_fx( exp_powerSpec[ch], sub( Q31, q_powerSpec[ch] ), N_MAX + L_MDCT_OVLP_MAX );
+ set16_fx( exp_powerSpec[ch], sub( Q31, q_powerSpec[ch] ), L_FRAME48k );
ProcessIGF_ivas_fx( st, L_FRAME48k, st->hTcxEnc->spectrum_fx[n], &q_spectrum, orig_spectrum_fx[ch][n], q_origSpec, &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 );
diff --git a/lib_enc/ivas_omasa_enc_fx.c b/lib_enc/ivas_omasa_enc_fx.c
index f1187bc6cfe77f5deb5328174eececa5a15aa0cb..0b0aa90c5799949ae85de39f395a430d4a64bd71 100644
--- a/lib_enc/ivas_omasa_enc_fx.c
+++ b/lib_enc/ivas_omasa_enc_fx.c
@@ -82,13 +82,16 @@ static void ivas_omasa_dmx_fx(
Word16 prev_gains[][MASA_MAX_TRANSPORT_CHANNELS], /*o:q15*/
const Word16 interpolator[L_FRAME48k] /*i:q15*/
);
-static void computeIntensityVector_enc_fx(
- const Word16 *band_grouping, /* i : Band grouping for estimation */
- Word32 Cldfb_RealBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Real part of input signal */
- Word32 Cldfb_ImagBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Imag part of input signal */
- const Word16 num_frequency_bands, /* i : Number of frequency bands */
- Word32 intensity_real[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS], /* o : Intensity vector */
- Word16 guard_bits );
+
+void computeIntensityVector_enc_fx(
+ const Word16 *band_grouping,
+ Word32 Cldfb_RealBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /*inp_q*/
+ Word32 Cldfb_ImagBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /*inp_q*/
+ const Word16 num_frequency_bands,
+ Word32 intensity_real[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS], /*exp: exp_intensity_real*/
+ Word16 q_intensity_real[MASA_FREQUENCY_BANDS],
+ Word16 inp_q );
+
static void computeReferencePower_omasa_ivas_fx( const Word16 *band_grouping, Word32 Cldfb_RealBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], Word32 Cldfb_ImagBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], Word32 *reference_power, const Word16 enc_param_start_band, const Word16 num_freq_bands, Word16 q_Cldfb, Word16 *ref_exp );
/*--------------------------------------------------------------------------*
* ivas_omasa_enc_open()
@@ -795,7 +798,7 @@ void ivas_set_ism_importance_interformat_fx(
IF( active_flag == 0 )
{
test();
- if ( GT_16( st->lp_noise_fx, 3840 /* 15 in Q8 */ ) || LT_16( sub( lp_noise_CPE_fx, st->lp_noise_fx ), 7680 /* 30 in Q8 */ ) )
+ if ( GT_32( st->lp_noise_32fx, 251658240 /* 15 in Q24 */ ) || LT_16( sub( lp_noise_CPE_fx, extract_h( st->lp_noise_32fx ) ), 7680 /* 30 in Q8 */ ) )
{
active_flag = 1;
move16();
@@ -1036,6 +1039,7 @@ static void ivas_omasa_param_est_enc_fx(
Word16 q; /*stores q for cldfb buffers*/
Word32 temp;
Word16 temp_e;
+ Word16 q_intensity_real_fx[MASA_FREQUENCY_BANDS], q_reference_power_fx[CLDFB_NO_CHANNELS_MAX];
ref_exp = 0;
norm_buff = MAX16B;
@@ -1112,11 +1116,6 @@ static void ivas_omasa_param_est_enc_fx(
{
q = q_data;
move16();
-#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 ) );
@@ -1192,19 +1191,34 @@ static void ivas_omasa_param_est_enc_fx(
v_multc_acc_32_32( Chnl_ImagBuffer_fx[i], hOMasa->chnlToFoaMtx_fx[3][i], Foa_ImagBuffer_fx[3], num_freq_bins ); /*q*/
}
/* Direction estimation */
- norm_buff = L_norm_arr( &Foa_RealBuffer_fx[0][0], FOA_CHANNELS * CLDFB_NO_CHANNELS_MAX );
- norm_buff = s_min( norm_buff, L_norm_arr( &Foa_ImagBuffer_fx[0][0], FOA_CHANNELS * CLDFB_NO_CHANNELS_MAX ) );
- guard_bits = find_guarded_bits_fx( max_band_grouping_diff );
- guard_bits = add( guard_bits, sub( 1, norm_buff ) );
- 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 ) );
+ computeIntensityVector_enc_fx( hOMasa->band_grouping, Foa_RealBuffer_fx, Foa_ImagBuffer_fx, num_freq_bands, intensity_real_fx, q_intensity_real_fx, q );
- computeDirectionVectors_fixed( intensity_real_fx[0], intensity_real_fx[1], intensity_real_fx[2], 0, num_freq_bands, direction_vector_fx[0], direction_vector_fx[1], direction_vector_fx[2], intensity_real_e,
- NULL );
+ 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], 0, q_intensity_real_fx );
/* Power estimation for diffuseness */
- computeReferencePower_omasa_ivas_fx( hOMasa->band_grouping, Foa_RealBuffer_fx, Foa_ImagBuffer_fx, reference_power_fx[ts], 0, num_freq_bands, q, &ref_exp );
+ computeReferencePower_omasa_ivas_fx( hOMasa->band_grouping, Foa_RealBuffer_fx, Foa_ImagBuffer_fx, reference_power_fx[ts], 0, num_freq_bands, q, q_reference_power_fx );
+
+ minimum_fx( q_intensity_real_fx, num_freq_bands, &intensity_real_e );
+ minimum_fx( q_reference_power_fx, num_freq_bands, &ref_exp );
+
+ Word16 tmp;
+ FOR( i = 0; i < num_freq_bands; i++ )
+ {
+ tmp = sub( intensity_real_e, q_intensity_real_fx[i] );
+ intensity_real_fx[0][i] = L_shl( intensity_real_fx[0][i], tmp ); // intensity_real_e
+ move32();
+ intensity_real_fx[1][i] = L_shl( intensity_real_fx[1][i], tmp ); // intensity_real_e
+ move32();
+ intensity_real_fx[2][i] = L_shl( intensity_real_fx[2][i], tmp ); // intensity_real_e
+ move32();
+
+ tmp = sub( ref_exp, q_reference_power_fx[i] );
+ reference_power_fx[ts][i] = L_shl( reference_power_fx[ts][i], tmp ); // ref_exp
+ }
+
+ intensity_real_e = sub( Q31, intensity_real_e );
+ ref_exp = sub( Q31, ref_exp );
/* Fill buffers of length "averaging_length" time slots for intensity and energy */
hOMasa->index_buffer_intensity = add( ( hOMasa->index_buffer_intensity % DIRAC_NO_COL_AVG_DIFF ), 1 ); /* averaging_length = 32 */
@@ -1483,20 +1497,27 @@ static void ivas_omasa_dmx_fx(
}
void computeIntensityVector_enc_fx(
- const Word16 *band_grouping, /* i : Band grouping for estimation */
- Word32 Cldfb_RealBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Real part of input signal */
- Word32 Cldfb_ImagBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Imag part of input signal */
- const Word16 num_frequency_bands, /* i : Number of frequency bands */
- Word32 intensity_real[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS], /* o : Intensity vector */
- Word16 guard_bits )
+ const Word16 *band_grouping,
+ Word32 Cldfb_RealBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /*inp_q*/
+ Word32 Cldfb_ImagBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /*inp_q*/
+ const Word16 num_frequency_bands,
+ Word32 intensity_real[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS], /*exp: exp_intensity_real*/
+ Word16 q_intensity_real[MASA_FREQUENCY_BANDS],
+ Word16 inp_q )
{
- /* Reminder
- * X = a + ib; Y = c + id
- * X*Y = ac - bd + i(ad +bc)
- */
Word16 i, j;
Word32 real, img;
Word16 brange[2];
+ Word16 shift_intensity_real, num_bins, guard_bits, norm;
+
+ Word64 intensity_real64[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS];
+
+ FOR( i = 0; i < DIRAC_NUM_DIMS; i++ )
+ {
+ set64_fx( intensity_real64[i], 0, MASA_FREQUENCY_BANDS );
+ }
+
+ shift_intensity_real = sub( shl( inp_q, 1 ), 32 );
FOR( i = 0; i < num_frequency_bands; i++ )
{
@@ -1505,31 +1526,50 @@ void computeIntensityVector_enc_fx(
brange[1] = band_grouping[i + 1];
move16();
- intensity_real[0][i] = 0;
- move32();
- intensity_real[1][i] = 0;
- move32();
- intensity_real[2][i] = 0;
- move32();
+ num_bins = sub( brange[1], brange[0] );
+ guard_bits = find_guarded_bits_fx( num_bins );
FOR( j = brange[0]; j < brange[1]; j++ )
{
real = Cldfb_RealBuffer[0][j];
- img = Cldfb_ImagBuffer[0][j];
- /* Intensity is XYZ order, audio is WYZX order. */
- intensity_real[0][i] = L_add( intensity_real[0][i], L_add( L_shr( Mpy_32_32( Cldfb_RealBuffer[3][j], real ), guard_bits ), L_shr( Mpy_32_32( Cldfb_ImagBuffer[3][j], img ), guard_bits ) ) ); // output Q= 2* input_q -31-guard_bits
move32();
- intensity_real[1][i] = L_add( intensity_real[1][i], L_add( L_shr( Mpy_32_32( Cldfb_RealBuffer[1][j], real ), guard_bits ), L_shr( Mpy_32_32( Cldfb_ImagBuffer[1][j], img ), guard_bits ) ) ); // output Q= 2* input_q -31-guard_bits
- move32();
- intensity_real[2][i] = L_add( intensity_real[2][i], L_add( L_shr( Mpy_32_32( Cldfb_RealBuffer[2][j], real ), guard_bits ), L_shr( Mpy_32_32( Cldfb_ImagBuffer[2][j], img ), guard_bits ) ) ); // output Q= 2* input_q -31-guard_bits
+ img = Cldfb_ImagBuffer[0][j];
move32();
+ /* Intensity is XYZ order, audio is WYZX order. */
+ intensity_real64[0][i] = W_add( intensity_real64[0][i], W_shr( W_add( W_mult0_32_32( Cldfb_RealBuffer[3][j], real ), W_mult0_32_32( Cldfb_ImagBuffer[3][j], img ) ), guard_bits ) ); // output Q= 2* input_q -guard_bits
+ move64();
+ intensity_real64[1][i] = W_add( intensity_real64[1][i], W_shr( W_add( W_mult0_32_32( Cldfb_RealBuffer[1][j], real ), W_mult0_32_32( Cldfb_ImagBuffer[1][j], img ) ), guard_bits ) ); // output Q= 2* input_q - guard_bits
+ move64();
+ intensity_real64[2][i] = W_add( intensity_real64[2][i], W_shr( W_add( W_mult0_32_32( Cldfb_RealBuffer[2][j], real ), W_mult0_32_32( Cldfb_ImagBuffer[2][j], img ) ), guard_bits ) ); // output Q= 2* input_q - guard_bits
+ move64();
+ }
+ norm = 63;
+ move16();
+ IF( intensity_real64[0][i] != 0 )
+ {
+ norm = s_min( norm, W_norm( intensity_real64[0][i] ) );
+ }
+ IF( intensity_real64[1][i] != 0 )
+ {
+ norm = s_min( norm, W_norm( intensity_real64[1][i] ) );
+ }
+ IF( intensity_real64[2][i] != 0 )
+ {
+ norm = s_min( norm, W_norm( intensity_real64[2][i] ) );
}
+ intensity_real[0][i] = W_extract_h( W_shl( intensity_real64[0][i], norm ) ); // output Q = 2 * inp_q - guard_bits + norm - 32
+ move32();
+ intensity_real[1][i] = W_extract_h( W_shl( intensity_real64[1][i], norm ) ); // output Q = 2 * inp_q - guard_bits + norm - 32
+ move32();
+ intensity_real[2][i] = W_extract_h( W_shl( intensity_real64[2][i], norm ) ); // output Q = 2 * inp_q - guard_bits + norm - 32
+ move32();
+ q_intensity_real[i] = add( shift_intensity_real, sub( norm, guard_bits ) );
+ move16();
}
return;
}
-
static void computeReferencePower_omasa_ivas_fx(
const Word16 *band_grouping, /* i : Band grouping for estimation */
Word32 Cldfb_RealBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Real part of input signal Q6*/
@@ -1538,13 +1578,14 @@ static void computeReferencePower_omasa_ivas_fx(
const Word16 enc_param_start_band, /* i : first band to process */
const Word16 num_freq_bands, /* i : Number of frequency bands */
Word16 q_Cldfb,
- Word16 *ref_exp )
+ Word16 q_reference_power[CLDFB_NO_CHANNELS_MAX] )
{
Word16 brange[2];
Word16 ch_idx, i, j;
Word64 reference_power_tmp[CLDFB_NO_CHANNELS_MAX];
- Word16 ref_Q = 63;
- move16();
+ Word16 shift_ref_power, num_bins, guard_bits, norm;
+
+ shift_ref_power = sub( shl( q_Cldfb, 1 ), 30 );
FOR( i = 0; i < num_freq_bands; i++ )
{
@@ -1557,34 +1598,29 @@ static void computeReferencePower_omasa_ivas_fx(
reference_power_tmp[i] = 0;
move64();
+ num_bins = sub( brange[1], brange[0] );
+ guard_bits = find_guarded_bits_fx( num_bins );
+
FOR( ch_idx = 0; ch_idx < FOA_CHANNELS; ch_idx++ )
{
/* abs()^2 */
FOR( j = brange[0]; j < brange[1]; j++ )
{
- reference_power_tmp[i] = W_add( reference_power_tmp[i], W_mac_32_32( W_mult_32_32( Cldfb_RealBuffer[ch_idx][j], Cldfb_RealBuffer[ch_idx][j] ), Cldfb_ImagBuffer[ch_idx][j], Cldfb_ImagBuffer[ch_idx][j] ) ); // Q13 (Q6+Q6+1)
+ reference_power_tmp[i] = W_add( reference_power_tmp[i], W_shr( W_mac_32_32( W_mult_32_32( Cldfb_RealBuffer[ch_idx][j], Cldfb_RealBuffer[ch_idx][j] ), Cldfb_ImagBuffer[ch_idx][j], Cldfb_ImagBuffer[ch_idx][j] ), guard_bits ) ); // output Q = 2 * q_cldfb + 1 - guard_bits
move64();
}
}
- }
- // v_multc( reference_power, 0.5f, reference_power, num_freq_bands );
- FOR( i = 0; i < num_freq_bands; i++ )
- {
- reference_power_tmp[i] = W_shr( reference_power_tmp[i], 1 );
- move64();
- ref_Q = s_min( ref_Q, W_norm( reference_power_tmp[i] ) );
- }
-
- FOR( i = 0; i < num_freq_bands; i++ )
- {
- reference_power_tmp[i] = W_shl( reference_power_tmp[i], ref_Q ); // Q13 + ref_Q
- move64();
- reference_power[i] = W_extract_h( reference_power_tmp[i] ); // Q13 + ref_Q -32
+ norm = 63;
+ move16();
+ IF( reference_power_tmp[i] != 0 )
+ {
+ norm = W_norm( reference_power_tmp[i] );
+ }
+ reference_power[i] = W_extract_h( W_shl( reference_power_tmp[i], norm ) ); // output Q = 2 * q_cldfb + 2 - guard_bits + norm - 32
move32();
+ q_reference_power[i] = add( shift_ref_power, sub( norm, guard_bits ) );
+ move16();
}
- // ref_exp = 31- ((13+ref_Q) -32)
- *ref_exp = sub( 31, ( sub( add( ref_Q, 2 * q_Cldfb + 1 ), 32 ) ) );
- move16();
return;
}
diff --git a/lib_enc/ivas_qmetadata_enc_fx.c b/lib_enc/ivas_qmetadata_enc_fx.c
index 744d2c067bf79501c4e4df2da97931e18b79958d..9a7c4038b3e4a6a25cac5ab22478160812bca365 100644
--- a/lib_enc/ivas_qmetadata_enc_fx.c
+++ b/lib_enc/ivas_qmetadata_enc_fx.c
@@ -43,6 +43,9 @@
#include "basop_util.h"
#include "ivas_rom_com_fx.h"
+#ifdef DBG_BITSTREAM_ANALYSIS
+#include
+#endif
/*-----------------------------------------------------------------------*
* Local function prototypes
@@ -1192,14 +1195,23 @@ void reset_metadata_spatial_fx(
{
hMetaData->ind_list[i].nb_bits = -1;
move16();
+#ifdef DBG_BITSTREAM_ANALYSIS
+ sprintf( hMetaData->ind_list[i].function_name, "RESET in reset_metadata_spatial" );
+#endif
}
FOR( ( j = 0, i = next_ind_sid ); i < last_ind_sid; ( i++, j++ ) )
{
hMetaData->ind_list[j].value = hMetaData->ind_list[i].value;
hMetaData->ind_list[j].nb_bits = hMetaData->ind_list[i].nb_bits;
+#ifdef DBG_BITSTREAM_ANALYSIS
+ strncpy( hMetaData->ind_list[j].function_name, hMetaData->ind_list[i].function_name, 100 );
+#endif
hMetaData->nb_bits_tot = add( hMetaData->nb_bits_tot, hMetaData->ind_list[j].nb_bits );
hMetaData->ind_list[i].nb_bits = -1;
+#ifdef BISTREAM_ANALYSIS
+ sprintf( hMetaData->ind_list[i].function_name, "RESET in reset_metadata_spatial" );
+#endif
move16();
move16();
move16();
@@ -2007,6 +2019,9 @@ void restore_metadata_buffer_fx(
{
hMetaData->ind_list[i].nb_bits = -1;
move16();
+#ifdef DBG_BITSTREAM_ANALYSIS
+ sprintf( hMetaData->ind_list[i].function_name, "RESET in restore_metadata_buffer" );
+#endif
}
hMetaData->nb_bits_tot = bit_pos_start;
move16();
diff --git a/lib_enc/ivas_sce_enc_fx.c b/lib_enc/ivas_sce_enc_fx.c
index a578a3cfaeacc1fa9b70066613cf8549931cf6e8..f0811aea67b6c18f2cf62a213d93fe7c12bd36d5 100644
--- a/lib_enc/ivas_sce_enc_fx.c
+++ b/lib_enc/ivas_sce_enc_fx.c
@@ -124,6 +124,8 @@ ivas_error ivas_sce_enc_fx(
Word16 Q_min = s_min( q_data_fx, add( st->q_inp32, L_norm_arr( st->input32_fx - input_frame, input_frame ) ) );
scale_sig32( st->input32_fx - input_frame, input_frame, sub( Q_min, st->q_inp32 ) );
+ st->q_old_inp32 = Q_min;
+ move16();
Copy_Scale_sig32( data_fx, st->input32_fx, input_frame, sub( Q_min, q_data_fx ) ); // Q(Q_min)
st->q_inp32 = Q_min;
move16();
@@ -366,7 +368,9 @@ ivas_error ivas_sce_enc_fx(
Copy( st->input_fx, st->old_input_signal_fx, input_frame );
st->q_old_inp = st->q_inp;
move16();
- Copy32( st->input32_fx, st->input32_fx - input_frame, input_frame ); /* st->q_inp32 */
+ Copy32( st->input32_fx, st->old_input_signal32_fx, input_frame ); /* st->q_inp32 */
+ st->q_old_inp32 = st->q_inp32;
+ move16();
hSCE->last_element_brate = hSCE->element_brate;
move32();
diff --git a/lib_enc/ivas_spar_md_enc_fx.c b/lib_enc/ivas_spar_md_enc_fx.c
index 9c4fcc937163e672569f913223ec1cce692b2a20..a293b870a303feea31256274efe894ff227beeb7 100644
--- a/lib_enc/ivas_spar_md_enc_fx.c
+++ b/lib_enc/ivas_spar_md_enc_fx.c
@@ -439,7 +439,11 @@ static void write_metadata_buffer_fx(
FOR( i = 0; i < hMetaData_tmp->nb_ind_tot; i++ )
{
+#ifdef DBG_BITSTREAM_ANALYSIS
+ push_next_indice_( hMetaData_tmp->ind_list[i].function_name, hMetaData, hMetaData_tmp->ind_list[i].value, hMetaData_tmp->ind_list[i].nb_bits );
+#else
push_next_indice( hMetaData, hMetaData_tmp->ind_list[i].value, hMetaData_tmp->ind_list[i].nb_bits );
+#endif
}
return;
diff --git a/lib_enc/ivas_stereo_classifier_fx.c b/lib_enc/ivas_stereo_classifier_fx.c
index 3a040517a84649f0647394974932d5df16f9b9ed..2c1bc0317099125735d2d30683f03a2b4ff13592 100644
--- a/lib_enc/ivas_stereo_classifier_fx.c
+++ b/lib_enc/ivas_stereo_classifier_fx.c
@@ -1507,7 +1507,7 @@ void xtalk_classifier_dft_fx(
hStereoClassif->xtalk_decision = 1;
move16();
}
- ELSE IF( GE_32( hCPE->element_brate, IVAS_16k4 ) && hStereoClassif->xtalk_decision == 0 && GT_16( abs_s( itd ), STEREO_DFT_ITD_MAX ) && GT_16( sub( hCPE->hCoreCoder[0]->lp_speech_fx, hCPE->hCoreCoder[0]->lp_noise_fx ), 25 << 8 ) )
+ ELSE IF( GE_32( hCPE->element_brate, IVAS_16k4 ) && hStereoClassif->xtalk_decision == 0 && GT_16( abs_s( itd ), STEREO_DFT_ITD_MAX ) && GT_32( L_sub( hCPE->hCoreCoder[0]->lp_speech_32fx, hCPE->hCoreCoder[0]->lp_noise_32fx ), 25 << 24 ) )
{
hStereoClassif->xtalk_decision = 1;
move16();
diff --git a/lib_enc/ivas_stereo_dft_enc_fx.c b/lib_enc/ivas_stereo_dft_enc_fx.c
index 6406158b4c6cdcffb693451c44eaa9d54268f7d6..80c4b5a21c8d67576543e593b880993231f2e9b9 100644
--- a/lib_enc/ivas_stereo_dft_enc_fx.c
+++ b/lib_enc/ivas_stereo_dft_enc_fx.c
@@ -1030,7 +1030,7 @@ void stereo_dft_enc_analyze_fx(
FOR( n = 0; n < n_channels; n++ )
{
- Scale_sig( &mem[n][0], dft_ovl, sts[n]->q_inp - q_input_mem[n] ); // Q(sts[n]->q_inp)
+ Scale_sig( &mem[n][0], dft_ovl, sub( sts[n]->q_inp, q_input_mem[n] ) ); // Q(sts[n]->q_inp)
q_input_mem[n] = sts[n]->q_inp;
move16();
}
@@ -1115,8 +1115,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 Q15 */
+ Word32 *output_fx, /* o : output synthesis Q15 */
Word16 *output_start_index,
Word16 *output_end_index,
const Word16 chan, /* i : channel number */
@@ -1126,25 +1125,18 @@ Word32 stereo_dft_enc_synthesize_fx(
Word16 *nrg_out_fx_e )
{
Word16 i, j, sign;
- // float *pDFT_in;
Word32 *pDFT_in_fx;
Word16 DFT_in_fx_e;
Word16 offset, NFFT, N, ovl, zp;
Word16 temp_exp;
- // float fac;
Word32 fac_fx;
- // float *mem;
Word32 *mem_fx;
- // const float *trigo, *win, *win_ana;
const Word16 *trigo_fx;
const Word32 *win_fx;
const Word16 *win_ana_fx;
- // float tmp[STEREO_DFT_N_MAX_ENC];
Word32 tmp_fx[STEREO_DFT_N_MAX_ENC];
- // float nrg;
Word32 nrg_fx;
Word16 nrg_fx_e;
- // float trigo_enc[STEREO_DFT_N_MAX_ENC / 2 + 1];
Word16 trigo_enc_fx[STEREO_DFT_N_MAX_ENC / 2 + 1];
Word16 trigo_step;
Word16 scal_fac;
diff --git a/lib_enc/ivas_stereo_dft_enc_itd_fx.c b/lib_enc/ivas_stereo_dft_enc_itd_fx.c
index 1beacd19a265a59b2acec77ecc942480f86abe82..28bac9e8bc5baa416464a2efd783b833fc06d35c 100644
--- a/lib_enc/ivas_stereo_dft_enc_itd_fx.c
+++ b/lib_enc/ivas_stereo_dft_enc_itd_fx.c
@@ -169,7 +169,8 @@ static void stereo_dft_quantize_itd_fx(
Word16 *ind )
{
Word16 itd;
-
+ Word16 input_fs_by_stereo_dft_itd_fs = 0;
+ move16();
// itd = (int16_t) ( sign( in ) * 0.5f + in );
itd = in;
move16();
@@ -188,9 +189,30 @@ static void stereo_dft_quantize_itd_fx(
move16();
}
+ SWITCH( input_Fs )
+ {
+ case 8000:
+ input_fs_by_stereo_dft_itd_fs = 1; // Q2
+ move16();
+ BREAK;
+ case 16000:
+ input_fs_by_stereo_dft_itd_fs = 2; // Q2
+ move16();
+ BREAK;
+ case 32000:
+ input_fs_by_stereo_dft_itd_fs = 4; // Q2
+ move16();
+ BREAK;
+ case 48000:
+ input_fs_by_stereo_dft_itd_fs = 6; // Q2
+ move16();
+ BREAK;
+ default:
+ assert( 0 );
+ }
/*Convert back @ fs*/
//*out = (float) ( itd * input_Fs ) / ( (float) ( STEREO_DFT_ITD_FS ) );
- *out = Mpy_32_32( L_shl( itd * input_Fs, 2 ), 1099511628 /*Q45*/ ); // Q45+Q2-Q31 = Q16
+ *out = L_shl( L_mult( itd, input_fs_by_stereo_dft_itd_fs ), Q13 ); // Q16
move32();
return;
diff --git a/lib_enc/ivas_stereo_dft_td_itd_fx.c b/lib_enc/ivas_stereo_dft_td_itd_fx.c
index c457faa4f97bd09da06ee2738486bdab5e8aff4c..a0d49176f1426be0467bfb660b883abaf693bcb0 100644
--- a/lib_enc/ivas_stereo_dft_td_itd_fx.c
+++ b/lib_enc/ivas_stereo_dft_td_itd_fx.c
@@ -50,9 +50,9 @@
#define STEREO_DFT_CHANNEL_EXTR_LPC_ORDER 10
#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] = { // Q15
+#define FLR_FX 1073741824 // Q31
+#define ONE_HALF 24576 // Q14
+const Word16 wac_swb_h_fx[LPC_SHB_ORDER + 1] = { // Q15
32767,
32758,
32731,
@@ -95,7 +95,12 @@ static void stereo_td_get_td_itd_fx(
{
/* *td_itd is the closest integer to itd that transforms into an integer value *
* under the transform x -> (32000/fs) x. */
- Word16 d, d_e;
+ Word32 inverse_input_fs_by_16k = 0;
+ move32();
+ Word64 tmp64;
+ Word16 d = 0, shift = 0;
+ move16();
+ move16();
IF( EQ_32( input_Fs, 32000 ) )
{
@@ -106,24 +111,51 @@ static void stereo_td_get_td_itd_fx(
ELSE
{
assert( ( input_Fs % 16000 ) == 0 && "sampling frequency should be divisible by 16000" );
- Word16 temp_div, temp_e, temp_add;
- d = BASOP_Util_Divide3232_Scale( input_Fs, 16000, &d_e );
- temp_div = BASOP_Util_Divide3232_Scale( itd, L_deposit_h( d ), &temp_e );
- 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 ) );
-
- IF( itd != 0 )
+ IF( itd == 0 )
{
- *td_itd_32 = extract_l( L_shl( L_shr( L_add( temp_add, EPSILON_FX ), sub( 15, temp_e ) ), 1 ) );
+ *td_itd_32 = *td_itd = 0;
+ move16();
+ move16();
}
ELSE
{
- *td_itd_32 = shl( shr( temp_add, sub( 15, temp_e ) ), 1 );
- }
- move16();
+ SWITCH( input_Fs )
+ {
+ case 16000:
+ inverse_input_fs_by_16k = 1073741824; // Q30 /* This is in Q30, because 2147483648 cannot be represnt in Word32*/
+ move32();
+ d = 1; // Q0
+ move16();
+ shift = 1;
+ move16();
+ BREAK;
+ case 32000:
+ inverse_input_fs_by_16k = 1073741824; // Q31
+ move32();
+ d = 2; // Q0
+ move16();
+ BREAK;
+ case 48000:
+ inverse_input_fs_by_16k = 715827883; // Q31
+ move32();
+ d = 3; // Q0
+ move16();
+ if ( itd < 0 )
+ {
+ inverse_input_fs_by_16k = 715827882; /* Reducing the precision by 1 to handle multiplication of negative case*/
+ move32();
+ }
+ BREAK;
+ default:
+ assert( 0 );
+ }
+ tmp64 = W_add( W_mult0_32_32( itd, inverse_input_fs_by_16k ), W_shl( FLR_FX, sub( q_itd, shift ) ) ); // Q: q_itd - shift + 31
+ *td_itd_32 = shl( extract_l( W_extract_l( W_shr( tmp64, add( sub( q_itd, shift ), Q31 ) ) ) ), 1 ); // Q0
+ move16();
- *td_itd = i_mult( shr( *td_itd_32, 1 ), shr( d, sub( 15, d_e ) ) );
- move16();
+ *td_itd = i_mult( shr( *td_itd_32, 1 ), d ); // Q0
+ move16();
+ }
}
return;
@@ -499,8 +531,8 @@ void stereo_td_itd_fx(
Copy( shift_input, sts[ch]->input_fx, input_frame );
sts[ch]->q_inp = q_new_shift;
move16();
- /*sts[ch]->q_old_inp = q_new_shift;
- move16();*/
+ Copy_Scale_sig_16_32_no_sat( sts[ch]->input_fx, sts[ch]->input32_fx, input_frame, sub( sts[ch]->q_inp32, sts[ch]->q_inp ) );
+
IF( EQ_16( sts[0]->element_mode, IVAS_CPE_DFT ) )
{
// here shift_mem has same as input_mem, no need to update q //
@@ -512,6 +544,7 @@ void stereo_td_itd_fx(
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)
+ Copy_Scale_sig_16_32_no_sat( shift_mem, sts[ch]->old_input_signal32_fx, input_frame, sub( sts[ch]->q_old_inp32, q_shift_mem ) );
}
}
}
@@ -531,7 +564,7 @@ void stereo_td_itd_mdct_stereo_fx(
const Word16 input_frame /* i : frame length */
)
{
- Word16 i, n, q_com;
+ Word16 i;
Word32 bin_nrgL_fx[STEREO_DFT_N_32k_ENC];
Word16 bin_nrgL_e[STEREO_DFT_N_32k_ENC];
Word32 bin_nrgR_fx[STEREO_DFT_N_32k_ENC];
@@ -575,37 +608,6 @@ void stereo_td_itd_mdct_stereo_fx(
/*call ITD function*/
stereo_dft_enc_compute_itd_fx( hCPE, DFT_fx[0], DFT_tmp_e[0], DFT_fx[1], DFT_tmp_e[1], STEREO_DFT_OFFSET, input_frame, vad_flag_dtx, vad_hover_flag, bin_nrgL_fx, bin_nrgL_e, bin_nrgR_fx, bin_nrgR_e );
- q_com = MAX_16;
- move16();
-
- FOR( n = 0; n < CPE_CHANNELS; n++ )
- {
- q_com = s_min( q_com, add( norm_arr( hCPE->hCoreCoder[n]->input_fx, input_frame ), hCPE->hCoreCoder[n]->q_inp ) );
- q_com = s_min( q_com, add( norm_arr( hCPE->hCoreCoder[n]->old_input_signal_fx, input_frame ), hCPE->hCoreCoder[n]->q_old_inp ) );
- q_com = s_min( q_com, add( norm_arr( hCPE->input_mem_fx[n], hStereoMdct->hDft_ana->dft_ovl ), hCPE->q_input_mem[n] ) );
-
- if ( EQ_16( q_com, Q15 ) )
- {
- q_com = 0;
- move16();
- }
- }
-
- FOR( n = 0; n < CPE_CHANNELS; n++ )
- {
- scale_sig( hCPE->hCoreCoder[n]->input_fx, input_frame, sub( q_com, hCPE->hCoreCoder[n]->q_inp ) );
- hCPE->hCoreCoder[n]->q_inp = q_com;
- move16();
-
- scale_sig( hCPE->hCoreCoder[n]->old_input_signal_fx, input_frame, sub( q_com, hCPE->hCoreCoder[n]->q_old_inp ) );
- hCPE->hCoreCoder[n]->q_old_inp = q_com;
- move16();
-
- scale_sig( hCPE->input_mem_fx[n], hStereoMdct->hDft_ana->dft_ovl, sub( q_com, hCPE->q_input_mem[n] ) );
- hCPE->q_input_mem[n] = q_com;
- move16();
- }
-
/* Time Domain ITD compensation using extrapolation */
stereo_td_itd_fx( hStereoMdct->hItd, NULL, NULL, 1, hStereoMdct->hDft_ana->dft_ovl, hCPE->hCoreCoder, input_frame, hCPE->input_mem_fx, hCPE->q_input_mem );
}
diff --git a/lib_enc/ivas_stereo_dmx_evs_fx.c b/lib_enc/ivas_stereo_dmx_evs_fx.c
index 13ecbba003ef5a6b5d950117733f613ba111655e..f84f90e460f57ad34899f3a68b5df46d77f30ef7 100644
--- a/lib_enc/ivas_stereo_dmx_evs_fx.c
+++ b/lib_enc/ivas_stereo_dmx_evs_fx.c
@@ -98,6 +98,11 @@
#define STEREO_DMX_EVS_TRNS_EGY_FORGETTING_Q15 24576
+#ifdef FIX_1511_POC_RENORM
+#define STEREO_DMX_EVS_POC_RENORM_TH 33554432 // 65536 << 9
+#define STEREO_DMX_EVS_POC_RENORM_SHIFT 3
+#endif
+
const Word32 ipd_ff_Q31[STEREO_DMX_EVS_NB_SUBBAND_MAX] = {
2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264,
2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264,
@@ -412,6 +417,19 @@ static void calc_poc_fx(
Rr = L_add( L_add( specRr[i], Mpy_32_32_r( specLr[i], eps_cos ) ), Mpy_32_32_r( specLi[i], eps_sin ) );
Ri = L_add( L_sub( specRi[i], Mpy_32_32_r( specLr[i], eps_sin ) ), Mpy_32_32_r( specLi[i], eps_cos ) );
+#ifdef FIX_1511_POC_RENORM
+ IF( ( LT_32( L_abs( Lr ), STEREO_DMX_EVS_POC_RENORM_TH ) ) &&
+ ( LT_32( L_abs( Li ), STEREO_DMX_EVS_POC_RENORM_TH ) ) &&
+ ( LT_32( L_abs( Rr ), STEREO_DMX_EVS_POC_RENORM_TH ) ) &&
+ ( LT_32( L_abs( Ri ), STEREO_DMX_EVS_POC_RENORM_TH ) ) )
+ {
+ Lr = L_shl( Lr, STEREO_DMX_EVS_POC_RENORM_SHIFT );
+ Li = L_shl( Li, STEREO_DMX_EVS_POC_RENORM_SHIFT );
+ Rr = L_shl( Rr, STEREO_DMX_EVS_POC_RENORM_SHIFT );
+ Ri = L_shl( Ri, STEREO_DMX_EVS_POC_RENORM_SHIFT );
+ }
+#endif
+
specPOr[i] = L_add( Mpy_32_32_r( Lr, Rr ), Mpy_32_32_r( Li, Ri ) ); // 2*spec_e
move32();
specPOi[i] = L_sub( Mpy_32_32_r( Lr, Ri ), Mpy_32_32_r( Li, Rr ) ); // 2*spec_e
@@ -424,6 +442,19 @@ static void calc_poc_fx(
Rr = L_add( L_sub( specRr[j], Mpy_32_32_r( specLr[j], eps_cos ) ), Mpy_32_32_r( specLi[j], eps_sin ) );
Ri = L_sub( L_sub( specRi[j], Mpy_32_32_r( specLr[j], eps_sin ) ), Mpy_32_32_r( specLi[j], eps_cos ) );
+#ifdef FIX_1511_POC_RENORM
+ IF( ( LT_32( L_abs( Lr ), STEREO_DMX_EVS_POC_RENORM_TH ) ) &&
+ ( LT_32( L_abs( Li ), STEREO_DMX_EVS_POC_RENORM_TH ) ) &&
+ ( LT_32( L_abs( Rr ), STEREO_DMX_EVS_POC_RENORM_TH ) ) &&
+ ( LT_32( L_abs( Ri ), STEREO_DMX_EVS_POC_RENORM_TH ) ) )
+ {
+ Lr = L_shl( Lr, STEREO_DMX_EVS_POC_RENORM_SHIFT );
+ Li = L_shl( Li, STEREO_DMX_EVS_POC_RENORM_SHIFT );
+ Rr = L_shl( Rr, STEREO_DMX_EVS_POC_RENORM_SHIFT );
+ Ri = L_shl( Ri, STEREO_DMX_EVS_POC_RENORM_SHIFT );
+ }
+#endif
+
specPOr[j] = L_add( Mpy_32_32_r( Lr, Rr ), Mpy_32_32_r( Li, Ri ) ); // 2*spec_e
move32();
specPOi[j] = L_sub( Mpy_32_32_r( Lr, Ri ), Mpy_32_32_r( Li, Rr ) ); // 2*spec_e
@@ -444,6 +475,20 @@ static void calc_poc_fx(
Li = L_add( L_sub( specLi[i], Mpy_32_32_r( specRr[i], eps_sin ) ), Mpy_32_32_r( specRi[i], eps_cos ) );
Rr = L_add( L_add( specRr[i], Mpy_32_32_r( specLr[i], eps_cos ) ), Mpy_32_32_r( specLi[i], eps_sin ) );
Ri = L_add( L_sub( specRi[i], Mpy_32_32_r( specLr[i], eps_sin ) ), Mpy_32_32_r( specLi[i], eps_cos ) );
+
+#ifdef FIX_1511_POC_RENORM
+ IF( ( LT_32( L_abs( Lr ), STEREO_DMX_EVS_POC_RENORM_TH ) ) &&
+ ( LT_32( L_abs( Li ), STEREO_DMX_EVS_POC_RENORM_TH ) ) &&
+ ( LT_32( L_abs( Rr ), STEREO_DMX_EVS_POC_RENORM_TH ) ) &&
+ ( LT_32( L_abs( Ri ), STEREO_DMX_EVS_POC_RENORM_TH ) ) )
+ {
+ Lr = L_shl( Lr, STEREO_DMX_EVS_POC_RENORM_SHIFT );
+ Li = L_shl( Li, STEREO_DMX_EVS_POC_RENORM_SHIFT );
+ Rr = L_shl( Rr, STEREO_DMX_EVS_POC_RENORM_SHIFT );
+ Ri = L_shl( Ri, STEREO_DMX_EVS_POC_RENORM_SHIFT );
+ }
+#endif
+
specPOr[i] = L_add( Mpy_32_32_r( Lr, Rr ), Mpy_32_32_r( Li, Ri ) ); // 2*spec_e
move32();
specPOi[i] = L_sub( Mpy_32_32_r( Lr, Ri ), Mpy_32_32_r( Li, Rr ) ); // 2*spec_e
@@ -454,6 +499,20 @@ static void calc_poc_fx(
Li = L_sub( L_sub( specLi[j], Mpy_32_32_r( specRr[j], eps_sin ) ), Mpy_32_32_r( specRi[j], eps_cos ) );
Rr = L_add( L_sub( specRr[j], Mpy_32_32_r( specLr[j], eps_cos ) ), Mpy_32_32_r( specLi[j], eps_sin ) );
Ri = L_sub( L_sub( specRi[j], Mpy_32_32_r( specLr[j], eps_sin ) ), Mpy_32_32_r( specLi[j], eps_cos ) );
+
+#ifdef FIX_1511_POC_RENORM
+ IF( ( LT_32( L_abs( Lr ), STEREO_DMX_EVS_POC_RENORM_TH ) ) &&
+ ( LT_32( L_abs( Li ), STEREO_DMX_EVS_POC_RENORM_TH ) ) &&
+ ( LT_32( L_abs( Rr ), STEREO_DMX_EVS_POC_RENORM_TH ) ) &&
+ ( LT_32( L_abs( Ri ), STEREO_DMX_EVS_POC_RENORM_TH ) ) )
+ {
+ Lr = L_shl( Lr, STEREO_DMX_EVS_POC_RENORM_SHIFT );
+ Li = L_shl( Li, STEREO_DMX_EVS_POC_RENORM_SHIFT );
+ Rr = L_shl( Rr, STEREO_DMX_EVS_POC_RENORM_SHIFT );
+ Ri = L_shl( Ri, STEREO_DMX_EVS_POC_RENORM_SHIFT );
+ }
+#endif
+
specPOr[j] = L_add( Mpy_32_32_r( Lr, Rr ), Mpy_32_32_r( Li, Ri ) ); // 2*spec_e
move32();
specPOi[j] = L_sub( Mpy_32_32_r( Lr, Ri ), Mpy_32_32_r( Li, Rr ) ); // 2*spec_e
@@ -1144,6 +1203,7 @@ static Word32 find_poc_peak_fx(
Word16 itd_cand[CPE_CHANNELS], i, n, cnt[CPE_CHANNELS], Lh, peak_range, *on, *itdLR, prev_off[CPE_CHANNELS], eps_fx;
Word32 Q_fx[CPE_CHANNELS], aQ_fx[CPE_CHANNELS], cQ_fx[CPE_CHANNELS], width_fx, *peak_width_fx, *peakQ_fx, cconfidence_fx, *P_fx, tmpf_fx, eps2_fx;
Word16 tmpf_e = 0, eps2_e = 0, Q_e[CPE_CHANNELS], eps_e = 15, peakQ_e[CPE_CHANNELS];
+
move16();
move16();
move16();
@@ -1535,6 +1595,7 @@ static void weighted_ave_fx(
{
Word16 i, len;
Word32 gain_tmp_fx = 0, gain_sub_fx;
+
move32();
len = shr( input_frame, 4 );
gain_sub_fx = L_sub( gain_fx, old_gain_fx );
@@ -1569,6 +1630,7 @@ static void calc_energy_fx(
Word32 E_32_fx, wnd_fx, wnd_diff_fx;
Word16 i, adaptlen;
Word64 E_fx;
+
/* Initialization */
E_fx = 0;
move32();
@@ -1630,6 +1692,7 @@ static void calc_energy_fx(
// *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;
}
@@ -1696,6 +1759,7 @@ static void create_M_signal_fx(
Word32 temp32_1, temp32_2;
Word16 temp_e;
Word16 temp_e_1, temp_e_2;
+
/* Initialization */
eps_fx = 1024; // 1024.0f in Q0
move32();
@@ -1799,6 +1863,7 @@ void stereo_dmx_evs_enc_fx(
Word64 W_tmp;
Word16 W_tmp_q;
+ push_wmops( "stereo_dmx_evs_enc" );
if ( is_binaural )
{
/* use of is_binaural flag is to be considered */
@@ -2150,6 +2215,8 @@ void stereo_dmx_evs_enc_fx(
Copy_Scale_sig32_16( p_dmx_data, data, n_samples, 5 ); // Q26->Q15
+ pop_wmops();
+
return;
}
diff --git a/lib_enc/ivas_stereo_ica_enc_fx.c b/lib_enc/ivas_stereo_ica_enc_fx.c
index 6057ace6bbb1fe9fe6e9ada84627f10e2e3eb91b..d0252a1f154a32df2845bea6d5c3dc695368e2a0 100644
--- a/lib_enc/ivas_stereo_ica_enc_fx.c
+++ b/lib_enc/ivas_stereo_ica_enc_fx.c
@@ -2088,6 +2088,10 @@ void stereo_tca_enc_fx(
move16();
sts[1]->q_inp32 = sub( sts[1]->q_inp32, 2 );
move16();
+ sts[0]->q_old_inp32 = sub( sts[0]->q_old_inp32, 2 );
+ move16();
+ sts[1]->q_old_inp32 = sub( sts[1]->q_old_inp32, 2 );
+ move16();
}
/* update L/R DS memories */
@@ -2319,17 +2323,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 ) ); /* Q15 */
+ hStereoClassif->unclr_fv_fx[E_corrEst0] = L_shl_sat( corrEst[abs_s( lagSearchRange[0] )], sub( corrEst_exp, 16 ) ); /* Q15 */
move32();
- hStereoClassif->unclr_fv_fx[E_corrEstMax] = L_shl( corrEstMax, sub( corrEst_exp, 16 ) ); /* Q15 */
+ hStereoClassif->unclr_fv_fx[E_corrEstMax] = L_shl_sat( corrEstMax, sub( corrEst_exp, 16 ) ); /* Q15 */
move32();
- hStereoClassif->unclr_fv_fx[E_corrLagMax] = L_shl( corrLagMax, 15 ); /* Q15 */
+ hStereoClassif->unclr_fv_fx[E_corrLagMax] = L_shl_sat( corrLagMax, 15 ); /* Q15 */
move32();
- hStereoClassif->xtalk_fv_fx[E_corrEst0] = L_shl( corrEst[abs_s( lagSearchRange[0] )], sub( corrEst_exp, 16 ) ); /* Q15 */
+ hStereoClassif->xtalk_fv_fx[E_corrEst0] = L_shl_sat( corrEst[abs_s( lagSearchRange[0] )], sub( corrEst_exp, 16 ) ); /* Q15 */
move32();
- hStereoClassif->xtalk_fv_fx[E_corrEstMax] = L_shl( corrEstMax, sub( corrEst_exp, 16 ) ); /* Q15 */
+ hStereoClassif->xtalk_fv_fx[E_corrEstMax] = L_shl_sat( corrEstMax, sub( corrEst_exp, 16 ) ); /* Q15 */
move32();
- hStereoClassif->xtalk_fv_fx[E_corrLagMax] = L_shl( corrLagMax, 15 ); /* Q15 */
+ hStereoClassif->xtalk_fv_fx[E_corrLagMax] = L_shl_sat( corrLagMax, 15 ); /* Q15 */
move32();
/* L/M and R/M correlation */
diff --git a/lib_enc/ivas_stereo_icbwe_enc_fx.c b/lib_enc/ivas_stereo_icbwe_enc_fx.c
index eba30f7621eb97cad131d197a949d7d98704f5ee..95c49aeae8f13423959a6ec97aa6092144f4f790 100644
--- a/lib_enc/ivas_stereo_icbwe_enc_fx.c
+++ b/lib_enc/ivas_stereo_icbwe_enc_fx.c
@@ -828,7 +828,11 @@ void stereo_icBWE_enc_ivas_fx(
ELSE
{
+#ifndef FIX_1713_EXP
max_e = s_max( hStereoICBWE->mem_shb_speech_nonref_e, shb_speech_nonref_e );
+#else
+ max_e = s_max( hStereoICBWE->mem_shb_speech_ref_e, shb_speech_ref_e );
+#endif
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 );
@@ -853,9 +857,12 @@ void stereo_icBWE_enc_ivas_fx(
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 ) ) ); /* Q31-max_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 */
+#ifndef FIX_1713_EXP
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
-
+#else
+ 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_nonref_e ) ), Q16 ) ); // mem_shb_speech_ref_e
+#endif
/* core switching reset */
test();
diff --git a/lib_enc/ivas_stereo_mdct_core_enc_fx.c b/lib_enc/ivas_stereo_mdct_core_enc_fx.c
index 8acbc3e879e8d943c27f8624656c66d7b60d5542..6bb6af1b3e249e69e1fa681a5250b752bf1095ac 100644
--- a/lib_enc/ivas_stereo_mdct_core_enc_fx.c
+++ b/lib_enc/ivas_stereo_mdct_core_enc_fx.c
@@ -137,8 +137,10 @@ void stereo_mdct_core_enc_fx(
Word32 *orig_spectrum_fx[CPE_CHANNELS][NB_DIV]; /* Pointers to MDCT output for a short block (L/R) */
Word64 powerSpec64[CPE_CHANNELS][N_MAX];
Word16 exp_powerSpec64[CPE_CHANNELS][NB_DIV];
- Word32 powerSpecMsInv_long_fx[CPE_CHANNELS][N_MAX]; /* MS inv power spectrum, also inverse MDST spectrum */
+ Word32 powerSpecMsInv_long_fx[CPE_CHANNELS][N_MAX]; /* MS inv power spectrum, also inverse MDST spectrum */
+ Word16 q_powerSpecMsInv_long_fx[CPE_CHANNELS][N_MAX]; /*Q: MS inv power spectrum, also inverse MDST spectrum */
Word32 *powerSpecMsInv_fx[CPE_CHANNELS][NB_DIV];
+ Word16 *q_powerSpecMsInv_fx[CPE_CHANNELS][NB_DIV];
Word32 quantized_spectrum_long_fx[CPE_CHANNELS][N_MAX]; /* quantized MDCT spectrum, inv ms mask mdst spectrum, scratch for MS spectra in the MS decision */
Word32 *quantized_spectrum_fx[CPE_CHANNELS][NB_DIV];
Word32 *inv_mdst_spectrum_fx[CPE_CHANNELS][NB_DIV];
@@ -152,8 +154,6 @@ 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 exp_powSpecMsInv[MCT_MAX_CHANNELS];
- Word16 tmp_q_powSpecInv[N_MAX], *exp_powSpecInv[2];
Word64 W_tmp;
Encoder_State *st, **sts;
STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct;
@@ -186,11 +186,6 @@ void stereo_mdct_core_enc_fx(
set16_fx( exp_powerSpec64[ch], 0, NB_DIV );
}
- set16_fx( tmp_q_powSpecInv, 63, N_MAX );
-
- exp_powSpecInv[0] = tmp_q_powSpecInv;
- exp_powSpecInv[1] = &tmp_q_powSpecInv[N_TCX10_MAX];
-
sts = hCPE->hCoreCoder;
hStereoMdct = hCPE->hStereoMdct;
hBstr = sts[0]->hBstr;
@@ -254,6 +249,9 @@ void stereo_mdct_core_enc_fx(
{
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;
+ q_powerSpecMsInv_fx[ch][0] = q_powerSpecMsInv_long_fx[ch];
+ q_powerSpecMsInv_fx[ch][1] = q_powerSpecMsInv_long_fx[ch] + N_TCX10_MAX;
+ set16_fx( q_powerSpecMsInv_long_fx[ch], 63, N_MAX );
quantized_spectrum_fx[ch][0] = quantized_spectrum_long_fx[ch];
quantized_spectrum_fx[ch][1] = quantized_spectrum_long_fx[ch] + N_TCX10_MAX;
inv_spectrum_fx[ch][0] = quantized_spectrum_fx[ch][0];
@@ -444,7 +442,7 @@ void stereo_mdct_core_enc_fx(
W_tmp = W_mac_32_32( W_mult_32_32( imdct, imdct ), imdst, imdst ); // exp: 2*exp
norm = W_norm( W_tmp );
powerSpecMsInv_fx[ch][n][i] = W_extract_h( W_shl( W_tmp, norm ) ); // exp: 2*exp-norm
- exp_powSpecInv[n][i] = sub( shl( exp, 1 ), norm );
+ q_powerSpecMsInv_fx[ch][n][i] = sub( 31, sub( shl( exp, 1 ), norm ) );
move32();
move16();
@@ -464,7 +462,7 @@ void stereo_mdct_core_enc_fx(
W_tmp = W_mult_32_32( mdct, mdct ); // exp: 2*(sts[ch]->hTcxEnc->spectrum_e[n]+1) (exp)
norm = W_norm( W_tmp );
powerSpecMsInv_fx[ch][n][0] = W_extract_h( W_shl( W_tmp, norm ) ); // exp: 2*(sts[ch]->hTcxEnc->spectrum_e[n]+1)-norm (exp-norm)
- exp_powSpecInv[n][0] = sub( exp, norm );
+ q_powerSpecMsInv_fx[ch][n][0] = sub( 31, sub( exp, norm ) );
move32();
move16();
@@ -477,7 +475,7 @@ void stereo_mdct_core_enc_fx(
W_tmp = W_mac_32_32( W_mult_32_32( mdst, mdst ), mdct, mdct ); // exp: 2*(sts[ch]->hTcxEnc->spectrum_e[n]+1) (exp)
norm = W_norm( W_tmp );
powerSpecMsInv_fx[ch][n][i] = W_extract_h( W_shl( W_tmp, norm ) ); // exp: 2*(sts[ch]->hTcxEnc->spectrum_e[n]+1)-norm (exp-norm)
- exp_powSpecInv[n][i] = sub( exp, norm );
+ q_powerSpecMsInv_fx[ch][n][i] = sub( 31, sub( exp, norm ) );
move32();
move16();
}
@@ -486,7 +484,7 @@ void stereo_mdct_core_enc_fx(
W_tmp = W_mult_32_32( mdct, mdct ); // exp: 2*(sts[ch]->hTcxEnc->spectrum_e[n]+1) (exp)
norm = W_norm( W_tmp );
powerSpecMsInv_fx[ch][n][L_subframeTCX - 1] = W_extract_h( W_shl( W_tmp, norm ) ); // exp: 2*(sts[ch]->hTcxEnc->spectrum_e[n]+1)-norm (exp-norm)
- exp_powSpecInv[n][L_subframeTCX - 1] = sub( exp, norm );
+ q_powerSpecMsInv_fx[ch][n][L_subframeTCX - 1] = sub( 31, sub( exp, norm ) );
move32();
move16();
}
@@ -512,33 +510,6 @@ void stereo_mdct_core_enc_fx(
move16();
}
}
-
- /* Aligning the Q-factors */
- exp = MIN_16;
- move16();
- FOR( n = 0; n < nSubframes; n++ )
- {
- FOR( i = 0; i < L_subframeTCX; i++ )
- {
- if ( powerSpecMsInv_fx[ch][n][i] != 0 )
- {
- exp = s_max( exp, exp_powSpecInv[n][i] );
- }
- }
- }
- IF( NE_16( exp, MIN_16 ) )
- {
- FOR( n = 0; n < nSubframes; n++ )
- {
- FOR( i = 0; i < L_subframeTCX; i++ )
- {
- powerSpecMsInv_fx[ch][n][i] = L_shl( powerSpecMsInv_fx[ch][n][i], sub( exp_powSpecInv[n][i], exp ) );
- move32();
- }
- }
- }
- exp_powSpecMsInv[ch] = exp;
- move16();
}
FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
@@ -606,9 +577,11 @@ void stereo_mdct_core_enc_fx(
{
IGF_ENC_INSTANCE_HANDLE hIGFEnc[CPE_CHANNELS];
Word32 powerSpec_fx[CPE_CHANNELS][N_MAX], *p_powerSpec_fx[CPE_CHANNELS];
- Word16 exp_powSpec[CPE_CHANNELS];
+ Word16 exp_powSpec[CPE_CHANNELS][N_MAX], *p_exp_powSpec[CPE_CHANNELS];
p_powerSpec_fx[0] = powerSpec_fx[0];
+ p_exp_powSpec[0] = exp_powSpec[0];
p_powerSpec_fx[1] = powerSpec_fx[1];
+ p_exp_powSpec[1] = exp_powSpec[1];
{
/* Copy powerSpec values from 64 bit buffer to 32 bit buffer */
FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
@@ -627,24 +600,19 @@ void stereo_mdct_core_enc_fx(
{
length = add( length, shr( length, 2 ) );
}
- exp = sub( exp_powerSpec64[ch][0], W_norm_arr( powerSpec64[ch], length ) );
- IF( EQ_16( nsub, 2 ) )
- {
- exp = s_max( exp, sub( exp_powerSpec64[ch][1], W_norm_arr( powerSpec64[ch] + length, length ) ) );
- }
FOR( n1 = 0; n1 < nsub; n1++ )
{
- shift1 = sub( sub( exp_powerSpec64[ch][n1], exp ), 32 );
FOR( i = 0; i < length; i++ )
{
/* This doesn't result in saturation */
- powerSpec_fx[ch][i + n1 * length] = W_shl_sat_l( powerSpec64[ch][i + n1 * length], shift1 ); // exp: exp
+ shift1 = W_norm( powerSpec64[ch][i + n1 * length] );
+ powerSpec_fx[ch][i + n1 * length] = W_extract_h( W_shl( powerSpec64[ch][i + n1 * length], shift1 ) ); // exp: exp
move32();
+ exp_powSpec[ch][i + n1 * length] = sub( exp_powerSpec64[ch][n1], shift1 );
}
}
set32_fx( powerSpec_fx[ch] + length, 0, sub( N_MAX, length ) );
- exp_powSpec[ch] = exp; // exp: exp
- move16();
+ set16_fx( exp_powSpec[ch] + length, 0, sub( N_MAX, length ) );
}
}
@@ -656,13 +624,13 @@ void stereo_mdct_core_enc_fx(
move16();
ProcessStereoIGF_fx( hStereoMdct, sts, ms_mask, orig_spectrum_fx, sub( Q31, p_orig_spectrum_e[0] ), sub( Q31, p_orig_spectrum_e[1] ),
- p_powerSpec_fx, exp_powSpec, powerSpecMsInv_fx, exp_powSpecMsInv, inv_spectrum_fx, exp_inv_spectrum,
+ p_powerSpec_fx, p_exp_powSpec, powerSpecMsInv_fx, q_powerSpecMsInv_fx, inv_spectrum_fx, exp_inv_spectrum,
n, hCPE->hCoreCoder[0]->sp_aud_decision0, hCPE->hCoreCoder[0]->element_brate, 0 );
}
ELSE
{
Word32 powerSpec_fx[CPE_CHANNELS][N_MAX]; // each value has a different exponent
- Word16 exp_powerSpec[CPE_CHANNELS][N_MAX + L_MDCT_OVLP_MAX];
+ Word16 exp_powerSpec[CPE_CHANNELS][N_MAX];
{
/* Copy powerSpec values from 64 bit buffer to 32 bit buffer */
FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
@@ -694,7 +662,7 @@ void stereo_mdct_core_enc_fx(
}
}
set32_fx( powerSpec_fx[ch] + length, 0, sub( N_MAX, length ) );
- set16_fx( exp_powerSpec[ch] + length, 0, sub( N_MAX + L_MDCT_OVLP_MAX, length ) );
+ set16_fx( exp_powerSpec[ch] + length, 0, sub( N_MAX, length ) );
}
}
FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
diff --git a/lib_enc/ivas_stereo_switching_enc_fx.c b/lib_enc/ivas_stereo_switching_enc_fx.c
index 5f1208ba794687db7eb81e76deb2b7cd32935510..a54e56fb9a42651b8f8a61ea9c092cb971cd0b1d 100644
--- a/lib_enc/ivas_stereo_switching_enc_fx.c
+++ b/lib_enc/ivas_stereo_switching_enc_fx.c
@@ -628,23 +628,6 @@ ivas_error stereo_memory_enc_fx(
return error;
}
-static void v_multc_fixed_32_16(
- 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] ); /* Q16+Qx */
- move32();
- }
-
- return;
-}
/*-------------------------------------------------------------------*
* Function stereo_switching_enc()
*
@@ -653,7 +636,7 @@ 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 q_inp*/
+ Word32 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 )
{
@@ -672,8 +655,8 @@ void stereo_switching_enc_fx(
{
FOR( n = 0; n < CPE_CHANNELS; n++ )
{
- Copy( sts[n]->input_fx + input_frame - dft_ovl, hCPE->input_mem_fx[n], dft_ovl ); /* sts[n]->q_inp */
- hCPE->q_input_mem[n] = sts[n]->q_inp;
+ Copy_Scale_sig32_16( sts[n]->input32_fx + input_frame - dft_ovl, hCPE->input_mem_fx[n], dft_ovl, 0 ); /* sts[n]->q_inp32 - 16*/
+ hCPE->q_input_mem[n] = sub( sts[n]->q_inp32, 16 );
move16();
}
}
@@ -681,9 +664,9 @@ void stereo_switching_enc_fx(
/* 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 ); /* sts[0]->q_inp */
+ Copy32( sts[0]->input32_fx + sub( extract_l( Mpy_32_32( sts[0]->input_Fs, 42949673 /* 1/50 in Q31*/ ) ), sts[0]->encoderLookahead_FB ), sts[1]->input32_fx - shl( sts[0]->encoderLookahead_FB, 1 ), sts[0]->encoderLookahead_FB ); /* sts[0]->q_inp32 */
- 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 */
+ Copy32( sts[1]->input32_fx + sub( extract_l( Mpy_32_32( sts[1]->input_Fs, 42949673 /* 1/50 in Q31*/ ) ), sts[1]->encoderLookahead_FB ), sts[1]->input32_fx - sts[1]->encoderLookahead_FB, sts[1]->encoderLookahead_FB ); /* sts[1]->q_inp32 */
}
@@ -694,7 +677,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] ), add( q_inp, 1 ) ); // Q31 + q_inp - Q15 - (q_inp + 1) -> Q15
+ hCPE->hStereoDft->output_mem_dmx_fx[i] = L_shl( Mpy_32_32_r( hCPE->hStereoDft->win_fx[dft_ovl - 1 - i], old_input_signal_pri[input_frame - dft_ovl + i] ), sub( 15, q_inp ) ); // Q15
move32();
}
/* reset 48kHz BWE overlap memory */
@@ -728,7 +711,7 @@ 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 + 1 ); /* Q15 */
+ 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] ), sub( 16, sts[0]->exp_buf_speech_enc ) ); /* Q15 */
move32();
}
Word16 q_dmx = Q15;
@@ -816,10 +799,10 @@ void stereo_switching_enc_fx(
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_FX2( L_mult0( input_frame, FRAMES_PER_SEC ), L_MEM_RECALC_TBE_NS ) + i] ); /* Q16+q_inp */
+ sts[0]->cldfbAnaEnc->cldfb_state_fx[i] = old_input_signal_pri[input_frame - offset - NS2SA_FX2( L_mult0( input_frame, FRAMES_PER_SEC ), L_MEM_RECALC_TBE_NS ) + i]; /* q_inp */
move32();
}
- sts[0]->cldfbAnaEnc->Q_cldfb_state = add( Q16, q_inp );
+ sts[0]->cldfbAnaEnc->Q_cldfb_state = q_inp;
move16();
}
@@ -838,18 +821,18 @@ 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_FX2( L_mult0( 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 );
+ v_multc_fixed( hCPE->hCoreCoder[1]->old_input_signal32_fx + sub( input_frame, add( offset, NS2SA_FX2( L_mult0( 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 = q_inp;
move16();
}
ELSE
{
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_FX2( L_mult0( input_frame, FRAMES_PER_SEC ), L_MEM_RECALC_TBE_NS ) + i] ), 5 ); /* Q11+q_inp */
+ sts[1]->cldfbAnaEnc->cldfb_state_fx[i] = ( hCPE->hCoreCoder[1]->old_input_signal32_fx[input_frame - offset - NS2SA_FX2( L_mult0( input_frame, FRAMES_PER_SEC ), L_MEM_RECALC_TBE_NS ) + i] ); /* q_inp */
move32();
}
- sts[1]->cldfbAnaEnc->Q_cldfb_state = add( Q16 - 5, q_inp );
+ sts[1]->cldfbAnaEnc->Q_cldfb_state = q_inp;
move16();
}
@@ -915,6 +898,8 @@ void stereo_switching_enc_fx(
IF( sts[0]->hLPDmem != NULL )
{
Copy( sts[0]->hLPDmem->old_exc, sts[1]->hLPDmem->old_exc, L_EXC_MEM );
+ sts[1]->hLPDmem->q_lpd_old_exc = sts[0]->hLPDmem->q_lpd_old_exc;
+ move16();
}
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 */
@@ -929,9 +914,9 @@ void stereo_switching_enc_fx(
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 ); /* q_inp32+0-15+15-15-13 */
+ sts[1]->input32_fx[-sts[0]->encoderLookahead_FB + i] = ( Mpy_32_16_1( L_add( imult3216( sts[0]->input32_fx[-sts[0]->encoderLookahead_FB + i], sts[0]->encoderLookahead_FB - i ), imult3216( sts[1]->input32_fx[-sts[0]->encoderLookahead_FB + i], i ) ), tmp_fx ) ); /* sts[0]->q_inp32 */
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 ); /* q_inp32+0-15+15-15-13 */
+ sts[0]->input32_fx[-sts[0]->encoderLookahead_FB + i] = ( Mpy_32_16_1( L_add( imult3216( sts[0]->input32_fx[-sts[0]->encoderLookahead_FB + i], sts[0]->encoderLookahead_FB - i ), imult3216( sts[1]->input32_fx[-2 * sts[0]->encoderLookahead_FB + i], i ) ), tmp_fx ) ); /* sts[0]->q_inp32 */
move32();
}
/* restore continuous signal in right channel (part of old_output was used to store original left channel) */
diff --git a/lib_enc/ivas_stereo_td_analysis_fx.c b/lib_enc/ivas_stereo_td_analysis_fx.c
index 909d0c206f5dd2718f1a229b6d52ef6e42aba110..de47ea8e25afb906ebb9c9afe386c86c1f887e39 100644
--- a/lib_enc/ivas_stereo_td_analysis_fx.c
+++ b/lib_enc/ivas_stereo_td_analysis_fx.c
@@ -564,7 +564,7 @@ Word16 stereo_tdm_ener_analysis_fx(
}
}
- IF( LT_16( sub( sts[1]->lp_speech_fx, sts[1]->lp_noise_fx ), 12800 /*50.0f in Q8*/ ) ) /* likely presence of noisy content */
+ IF( LT_32( L_sub( sts[1]->lp_speech_32fx, sts[1]->lp_noise_32fx ), 838860800 /*50.0f in Q24*/ ) ) /* likely presence of noisy content */
{
/* pointing in the right direction, inverse it else do nothing */
test();
diff --git a/lib_enc/ivas_tcx_core_enc_fx.c b/lib_enc/ivas_tcx_core_enc_fx.c
index 5f2e9a8e094bc63e7bcff04b9133fe9530f4b5ff..da141f473432c7384c43abc984a1f67b800d5514 100644
--- a/lib_enc/ivas_tcx_core_enc_fx.c
+++ b/lib_enc/ivas_tcx_core_enc_fx.c
@@ -715,7 +715,7 @@ Word16 ivas_acelp_tcx20_switching_fx(
Word16 *inp_fx,
Word16 q_inp,
Word16 *wsp, /*q_inp i : input weighted signal */
- Word16 non_staX, /*Q8 i : unbound non-stationarity for sp/mu clas*/
+ Word32 non_staX, /*Q20 i : unbound non-stationarity for sp/mu clas*/
Word16 *pitch_fr, /*Q6 i : fraction pitch values */
Word16 *voicing_fr, /*Q15 i : fractional voicing values */
Word32 currFlatness, /*Q21 i : flatness */
@@ -1276,7 +1276,7 @@ Word16 ivas_acelp_tcx20_switching_fx(
test();
test();
test();
- if ( ( !flag_16k_smc ) && ( LT_32( offset_tcx, 0x18950F ) ) && GT_16( non_staX, 1280 /*5.0f Q8*/ ) && ( GE_32( snr_acelp, L_sub( tcx_snr, 262144 /*4.0f in Q16*/ ) ) ) && GE_16( st->Nb_ACELP_frames, 1 ) && ( ( GT_16( st->hSpMusClas->lps_fx, st->hSpMusClas->lpm_fx ) && GE_32( mean_voicing_fr, /* 0.3 in Q30 */ 322122547 ) ) || ( GE_16( st->Nb_ACELP_frames, 6 ) && GT_16( st->hSpMusClas->lps_fx, sub( st->hSpMusClas->lpm_fx, 192 /*1.5in Q7*/ ) ) ) ) && ( st->sp_aud_decision0 == 0 ) && st->vad_flag )
+ if ( ( !flag_16k_smc ) && ( LT_32( offset_tcx, 0x18950F ) ) && GT_32( non_staX, 5242880 /*5.0f Q20*/ ) && ( GE_32( snr_acelp, L_sub( tcx_snr, 262144 /*4.0f in Q16*/ ) ) ) && GE_16( st->Nb_ACELP_frames, 1 ) && ( ( GT_16( st->hSpMusClas->lps_fx, st->hSpMusClas->lpm_fx ) && GE_32( mean_voicing_fr, /* 0.3 in Q30 */ 322122547 ) ) || ( GE_16( st->Nb_ACELP_frames, 6 ) && GT_16( st->hSpMusClas->lps_fx, sub( st->hSpMusClas->lpm_fx, 192 /*1.5in Q7*/ ) ) ) ) && ( st->sp_aud_decision0 == 0 ) && st->vad_flag )
{
/* Fine tuned across various databases based on various metrics to detect TCX frames in speech.*/
dsnr = 262144; /*4.0f Q16*/
diff --git a/lib_enc/ivas_td_low_rate_enc_fx.c b/lib_enc/ivas_td_low_rate_enc_fx.c
index 77ddb35aaf38b39ea89084727e9e325ef7dccb92..e2c12076d416a8fb0787181cdb5b6fab2da2841e 100644
--- a/lib_enc/ivas_td_low_rate_enc_fx.c
+++ b/lib_enc/ivas_td_low_rate_enc_fx.c
@@ -285,7 +285,7 @@ void encod_gen_2sbfr(
* Find adaptive exitation
*-----------------------------------------------------------------*/
- pred_lt4( &exc[i_subfr], &exc[i_subfr], T0, T0_frac, 2 * L_SUBFR + 1, inter4_2_fx_Q15, L_INTERPOL2, PIT_UP_SAMP );
+ pred_lt4_ivas_fx( &exc[i_subfr], &exc[i_subfr], T0, T0_frac, 2 * L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
/*-----------------------------------------------------------------*
* Gain clipping test to avoid unstable synthesis on frame erasure
@@ -365,11 +365,12 @@ void encod_gen_2sbfr(
move16();
move16();
}
+
/*-----------------------------------------------------------------*
* Prepare TBE excitation
*-----------------------------------------------------------------*/
- prep_tbe_exc_ivas_fx( L_frame, L_SUBFR, i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr / L_SUBFR], bwe_exc, 0, NULL, Q_new, T0, T0_frac, coder_type, st->core_brate, st->element_mode, st->idchan, st->hBWE_TD != NULL, st->tdm_LRTD_flag );
+ prep_tbe_exc_fx( L_frame, L_SUBFR, i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr / L_SUBFR], bwe_exc, 0, NULL, Q_new, T0, T0_frac, coder_type, st->core_brate, st->element_mode, st->idchan, st->hBWE_TD != NULL, st->tdm_LRTD_flag );
voice_factors[i_subfr / L_SUBFR + 1] = voice_factors[i_subfr / L_SUBFR]; /* Q15 */
move16();
@@ -378,6 +379,7 @@ void encod_gen_2sbfr(
* Synthesize speech to update mem_syn_flt[].
* Update A(z) filters
*-----------------------------------------------------------------*/
+
Syn_filt_s( 1, p_Aq, M, &exc[i_subfr], &syn[i_subfr], 2 * L_SUBFR, hLPDmem->mem_syn, 1 );
p_Aw += 2 * ( M + 1 );
p_Aq += 2 * ( M + 1 );
diff --git a/lib_enc/lib_enc.h b/lib_enc/lib_enc.h
index 8cf6be1cd0e6ca1385d5c7ec3588583ea115ac20..16fc9fe4b1b6d07c9fd9947b0b9482b3143b23d2 100644
--- a/lib_enc/lib_enc.h
+++ b/lib_enc/lib_enc.h
@@ -302,6 +302,10 @@ ivas_error IVAS_ENC_EncodeFrameToSerial(
Word16 inputBufferSize, /* i : total number of samples in the input buffer. Related function: IVAS_ENC_GetInputBufferSize() */
UWord16 *outputBitStream, /* o : pointer to serial output bitstream. The array must already be allocated and be of size at least IVAS_MAX_BITS_PER_FRAME */
UWord16 *numOutBits /* o : number of bits written to output bitstream. Each bit is stored as a single uint16_t value */
+#ifdef DBG_BITSTREAM_ANALYSIS
+ ,
+ int32_t frame
+#endif
);
/*! r: error code */
@@ -311,6 +315,10 @@ ivas_error IVAS_ENC_EncodeFrameToCompact(
const Word16 inputBufferSize, /* i : total number of samples in the input buffer. Related function: IVAS_ENC_GetInputBufferSize() */
UWord8 *outputBitStream, /* o : pointer to compact output bitstream. The array must already be allocated. */
UWord16 *numOutBits /* o : number of bits written to output bitstream */
+#ifdef DBG_BITSTREAM_ANALYSIS
+ ,
+ int32_t frame
+#endif
);
/* Setter functions - apply changes to encoder configuration */
diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc_fx.c
similarity index 99%
rename from lib_enc/lib_enc.c
rename to lib_enc/lib_enc_fx.c
index 063f39dea165a668a6616c02bb51d7080f0d6a97..1771f875abf178a41f05452fdf1a4e7750455ac8 100644
--- a/lib_enc/lib_enc.c
+++ b/lib_enc/lib_enc_fx.c
@@ -1660,6 +1660,10 @@ ivas_error IVAS_ENC_EncodeFrameToSerial(
Word16 inputBufferSize, /* i : total number of samples in the input buffer. Related function: IVAS_ENC_GetInputBufferSize() Q0*/
UWord16 *outputBitStream, /* o : pointer to serial output bitstream. The array must already be allocated and be of size at least IVAS_MAX_BITS_PER_FRAME Q0*/
UWord16 *numOutBits /* o : number of bits written to output bitstream. Each bit is stored as a single uint16_t value Q0*/
+#ifdef DBG_BITSTREAM_ANALYSIS
+ ,
+ int32_t frame
+#endif
)
{
Encoder_Struct *st_ivas;
@@ -1783,7 +1787,12 @@ ivas_error IVAS_ENC_EncodeFrameToSerial(
st_ivas->ind_list[i].nb_bits = -1;
move16();
}
-
+#ifdef DBG_BITSTREAM_ANALYSIS
+ for ( i = 0; i < st_ivas->ivas_max_num_indices; i++ )
+ {
+ memset( st_ivas->ind_list[i].function_name, 'A', 100 * sizeof( char ) );
+ }
+#endif
/* de-allocate old buffer of metadata indices */
IF( st_ivas->ind_list_metadata != NULL )
{
@@ -1923,7 +1932,12 @@ ivas_error IVAS_ENC_EncodeFrameToSerial(
ELSE
#endif
{
- write_indices_ivas_fx( st_ivas, outputBitStream, numOutBits );
+ write_indices_ivas_fx( st_ivas, outputBitStream, numOutBits
+#ifdef DBG_BITSTREAM_ANALYSIS
+ ,
+ frame
+#endif
+ );
}
/* Reset switching flag before next call - can be set to "true" by some setters */
hIvasEnc->switchingActive = false;
@@ -2650,41 +2664,7 @@ static ivas_error sanitizeBandwidth_fx(
}
}
- IF( EQ_16( hEncoderConfig->ivas_format, MONO_FORMAT ) )
- {
-#if 0 // IVAS_fmToDo: temporary disabled to keep EVS bit-exactness -> to be verified
- if (max_bwidth_tmp == FB && hEncoderConfig->ivas_total_brate < ACELP_16k40)
- {
- if (hEncoderConfig->ivas_total_brate < ACELP_9k60)
- {
- max_bwidth_tmp = WB;
- }
- else
- {
- max_bwidth_tmp = SWB;
- }
- }
-
- if (max_bwidth_tmp == SWB && hEncoderConfig->ivas_total_brate < ACELP_9k60)
- {
- max_bwidth_tmp = WB;
- }
-
- /* in case of 8kHz input sampling or "-max_band NB", require the total bitrate to be below 24.40 kbps */
- if ((max_bwidth_tmp == NB || hEncoderConfig->input_Fs == 8000) && hEncoderConfig->ivas_total_brate > ACELP_24k40)
- {
- if (hEncoderConfig->input_Fs >= 16000)
- {
- max_bwidth_tmp = WB;
- }
- else
- {
- return IVAS_ERR_INVALID_BITRATE;
- }
- }
-#endif
- }
- ELSE
+ IF( NE_16( hEncoderConfig->ivas_format, MONO_FORMAT ) )
{
Word32 quo = 0, rem;
move32();
diff --git a/lib_enc/long_enr_fx.c b/lib_enc/long_enr_fx.c
index 60c40b3fe770908e01a5e17cb49a89bd2c45f234..93918b81e425b9c67cfdcb695fc78b273df403a4 100644
--- a/lib_enc/long_enr_fx.c
+++ b/lib_enc/long_enr_fx.c
@@ -17,7 +17,7 @@
*-------------------------------------------------------------------*/
void ivas_long_enr_fx(
Encoder_State *st_fx, /* i/o: state structure */
- const Word16 Etot, /* i : total channel E (see lib_enc\analy_sp.c) Q8 */
+ const Word32 Etot, /* i : total channel E (see lib_enc\analy_sp.c) Q24 */
const Word16 localVAD_HE_SAD, /* i : HE-SAD flag without hangover Q0*/
Word16 high_lpn_flag, /* i : sp/mus LPN flag Q0*/
FRONT_VAD_ENC_HANDLE hFrontVad[], /* i/o: front-VAD handles */
@@ -28,7 +28,7 @@ void ivas_long_enr_fx(
)
{
Word16 tmp;
- Word16 alpha;
+ Word32 alpha;
NOISE_EST_HANDLE hNoiseEst = st_fx->hNoiseEst;
/*-----------------------------------------------------------------*
@@ -42,7 +42,7 @@ void ivas_long_enr_fx(
{
FOR( n = 0; n < n_chan; n++ )
{
- hFrontVad[n]->lp_noise_fx = hFrontVad[n]->hNoiseEst->totalNoise_fx; /* Q8 */
+ hFrontVad[n]->lp_noise_fx = extract_h( hFrontVad[n]->hNoiseEst->totalNoise_32fx ); /* Q8 */
move16();
tmp = add( hFrontVad[n]->lp_noise_fx, 2560 ); /* Q8 */
@@ -74,7 +74,7 @@ void ivas_long_enr_fx(
FOR( n = 0; n < n_chan; n++ )
{
- hFrontVad[n]->lp_noise_fx = add( mult_r( smooth_prev, hFrontVad[n]->lp_noise_fx ), mult_r( smooth_curr, hFrontVad[n]->hNoiseEst->totalNoise_fx ) ); /* Q8 */
+ hFrontVad[n]->lp_noise_fx = add( mult_r( smooth_prev, hFrontVad[n]->lp_noise_fx ), mult_r( smooth_curr, extract_h( hFrontVad[n]->hNoiseEst->totalNoise_32fx ) ) ); /* Q8 */
move16();
test();
IF( localVAD_HE_SAD_LR[n] && !high_lpn_flag )
@@ -102,11 +102,11 @@ void ivas_long_enr_fx(
{
IF( LT_16( st_fx->ini_frame, 4 ) )
{
- st_fx->lp_noise_fx = hNoiseEst->totalNoise_fx; /* Q8 */
- move16();
- tmp = add( st_fx->lp_noise_fx, 2560 ); /*10.0 in Q8*/
- st_fx->lp_speech_fx = s_max( st_fx->lp_speech_fx, tmp );
- move16();
+ st_fx->lp_noise_32fx = hNoiseEst->totalNoise_32fx; /* Q24 */
+ move32();
+ Word32 tmp1 = L_add( st_fx->lp_noise_32fx, 167772160 ); /*10.0 in Q24*/
+ st_fx->lp_speech_32fx = L_max( st_fx->lp_speech_32fx, tmp1 );
+ move32();
}
ELSE
{
@@ -115,34 +115,34 @@ void ivas_long_enr_fx(
} else {
st->lp_noise = 0.98f * st->lp_noise + 0.02f * st->totalNoise;
} */
- alpha = 655; /* 0.02 Q15 */
- move16();
+ alpha = 42949673; /* 0.02 Q31 */
+ move32();
if ( LT_16( st_fx->ini_frame, 150 ) ) /* should match HE_LT_CNT_INIT_FX */
{
- alpha = 1638;
- move16(); /* 0.05 Q15 */
+ alpha = 107374182;
+ move32(); /* 0.05 Q31 */
}
- st_fx->lp_noise_fx = noise_est_AR1_Qx( hNoiseEst->totalNoise_fx, st_fx->lp_noise_fx, alpha ); /* Q8 state, alpha in Q15 */
- move16();
+ st_fx->lp_noise_32fx = noise_est_AR1_Qx_32( hNoiseEst->totalNoise_32fx, st_fx->lp_noise_32fx, alpha ); /* Q24 state, alpha in Q31 */
+ move32();
test();
IF( ( localVAD_HE_SAD != 0 ) && ( high_lpn_flag == 0 ) )
{
- IF( LT_16( sub( st_fx->lp_speech_fx, Etot ), 2560 ) ) /* 10.0 in Q8 */
+ IF( LT_32( L_sub( st_fx->lp_speech_32fx, Etot ), 167772160 ) ) /* 10.0 in Q24 */
{
/* st->lp_speech = 0.98f * st->lp_speech + 0.02f * Etot; */
- st_fx->lp_speech_fx = noise_est_AR1_Qx( Etot, st_fx->lp_speech_fx, 655 ); /* Q8 state, 0.02 in Q15 */
- move16();
+ st_fx->lp_speech_32fx = noise_est_AR1_Qx_32( Etot, st_fx->lp_speech_32fx, 42949673 ); /* Q24 state, 0.02 in Q31 */
+ move32();
}
ELSE
{
- st_fx->lp_speech_fx = sub( st_fx->lp_speech_fx, 13 ); /* st->lp_speech = st->lp_speech - 0.05f; linear decay*/
- move16();
+ st_fx->lp_speech_32fx = L_sub( st_fx->lp_speech_32fx, 838861 ); /* st->lp_speech = st->lp_speech - 0.05f; linear decay*/
+ move32();
}
}
}
/* Update */
- st_fx->hNoiseEst->Etot_last_32fx = L_deposit_h( Etot ); /* Q24 */
- move16();
+ st_fx->hNoiseEst->Etot_last_32fx = Etot; /* Q24 */
+ move32();
}
/*-----------------------------------------------------------------*
diff --git a/lib_enc/lsf_enc_fx.c b/lib_enc/lsf_enc_fx.c
index 8fe425d740baaa1f32abe09edb9ca45d3b1c7a9e..23ed7d0c2489486806792721a6538f2ce3d37f2f 100644
--- a/lib_enc/lsf_enc_fx.c
+++ b/lib_enc/lsf_enc_fx.c
@@ -289,13 +289,16 @@ void lsf_enc_fx(
{
int_lsp4_fx( st_fx->L_frame, st_fx->lsp_old_fx, lsp_mid, lsp_new, Aq, M, 0 );
}
+
/*------------------------------------------------------------------*
* Check LSF stability (distance between old LSFs and current LSFs)
*------------------------------------------------------------------*/
+
IF( NE_32( st_fx->core_brate, SID_2k40 ) )
{
st_fx->stab_fac_fx = lsf_stab_fx( lsf_new, st_fx->lsf_old_fx, 0, st_fx->L_frame );
}
+
return;
}
diff --git a/lib_enc/lsf_msvq_ma_enc.c b/lib_enc/lsf_msvq_ma_enc.c
deleted file mode 100644
index 60375ddcce113a6c5ac6236fdbd3afd55aec93e9..0000000000000000000000000000000000000000
--- a/lib_enc/lsf_msvq_ma_enc.c
+++ /dev/null
@@ -1,794 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository. All Rights Reserved.
-
- This software is protected by copyright law and by international treaties.
- The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository retain full ownership rights in their respective contributions in
- the software. This notice grants no license of any kind, including but not limited to patent
- license, nor is any license granted by implication, estoppel or otherwise.
-
- Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
- contributions.
-
- This software is provided "AS IS", without any express or implied warranties. The software is in the
- development stage. It is intended exclusively for experts who have experience with such software and
- solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
- and fitness for a particular purpose are hereby disclaimed and excluded.
-
- Any dispute, controversy or claim arising under or in relation to providing this software shall be
- submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
- accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
- the United Nations Convention on Contracts on the International Sales of Goods.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include "cnst.h"
-#include "prot_fx.h"
-#include "rom_com.h"
-#include "rom_enc.h"
-#include "basop_proto_func.h"
-#include "wmc_auto.h"
-
-#ifndef swap
-#define swap( x, y, type ) \
- { \
- type u__p; \
- u__p = x; \
- x = y; \
- y = u__p; \
- }
-#endif
-
-/*--------------------------------------------------------------------------*
- * Local constants
- *--------------------------------------------------------------------------*/
-
-#define kMaxC 8
-
-/*--------------------------------------------------------------------------*
- * msvq_encmsvq_stage1_dct_search()
- *
- * stage1 search in a segmentwise truncated dct N domain without weights
- *--------------------------------------------------------------------------*/
-
-/*! r: (p_max , best candidate sofar ) */
-Word16 msvq_stage1_dct_search_fx(
- const Word32 *u_fx, /* i : target exp : u_e */
- const Word16 u_e, /* i : exp for target Q0 */
- const Word16 N, /* i : target length and IDCT synthesis length */
- const Word16 maxC_st1, /* i : number of final stage 1 candidates to provide */
- const DCTTYPE dcttype, /* e.g. DCT_T2_16_XX, DCT_T2_24_XX; */
- const Word16 max_dct_trunc, /* i : maximum of truncation lenghts */
- Word32 *invTrfMatrix_fx, /* i : IDCT synthesis matrix for dim N Q31 */
- const Word16 *midQ_truncQ_fx, /* i : midQ vector */
- const Word32 *dct_scaleF_fx, /* i : global scale factors Q10 */
- const Word16 n_segm, /* i : number of segments */
- const Word16 *cols_per_segment, /* i : remaining length per segment */
- const Word16 *trunc_dct_cols_per_segment, /* i : trunc length per segment */
- const Word16 *entries_per_segment, /* i : number of rows per segment */
- const Word16 *cum_entries_per_segment, /* i : number of cumulative entries */
- const Word8 *const W8Qx_dct_sections[], /* i : Word8(byte) segment table ptrs */
- const Word16 *col_syn_shift[], /* i : columnwise syn shift tables */
- const Word8 *segm_neighbour_fwd, /* i : circular neighbour list fwd */
- const Word8 *segm_neighbour_rev, /* i : circular neighbour list reverse */
- const Word16 npost_check, /* i : number of neigbours to check , should be even */
- Word32 *st1_mse_ptr_fx, /* i : dynRAM buffer for MSEs exp : u_e */
- Word16 *indices_st1_local, /* o : selected cand indices */
- Word32 *st1_syn_vec_ptr_fx, /* i/o: buffer for IDCT24 synthesis i :exp : u_e */
- Word32 *dist1_ptr_fx, /* o : resulting stage 1 MSEs in DCT-N domain */
- Word16 *dist1_ptr_e )
-{
- Word32 dct_target_fx[FDCNG_VQ_DCT_MAXTRUNC]; // Q20
- Word32 u_mr_fx[FDCNG_VQ_MAX_LEN];
- Word16 dist1_ptr_e_buf[2 * LSFMBEST_MAX];
- Word64 mse_trunc_segm_fx[FDCNG_VQ_DCT_NSEGM];
- Word32 tmp_fx, check_mse;
- Word16 tmp_e, check_mse_e;
- Word64 mse_fx; /* Word64 in BASOP */
-
- Word16 p_max, c, c2, segm, j_full, j, i;
- Word16 n_ana, p_mins[2], idx_min[2];
-
- Word16 st1_mse_ptr_e[128];
-
- const Word8 *cbpW8;
- const Word16 *dct_col_shift_tab;
-
- Word32 *st1_mse_pair_fx;
- Word16 *st1_mse_pair_e;
- Word16 *st1_idx_pair;
-
- Word32 tmp2_fx;
- Word16 check_ind[FDCNG_VQ_DCT_NPOST];
- assert( ( npost_check % 2 == 0 ) && ( npost_check <= FDCNG_VQ_DCT_NPOST ) );
-
- assert( n_segm <= FDCNG_VQ_DCT_NSEGM );
-
- n_ana = N; /* VQ stage#1 core is currently always using stored DCT N coeffs */
- move16();
- assert( n_ana >= max_dct_trunc ); /* check for FDCNGVQ WB , SWB, FB operation */
-
- /* remove mid stage#1 vector, in original input domain */
- tmp_e = s_max( 12, u_e );
- FOR( i = 0; i < n_ana; i++ )
- {
- u_mr_fx[i] = L_sub( L_shl( u_fx[i], sub( u_e, tmp_e ) ), L_shl( midQ_truncQ_fx[i], sub( Q31 - Q10, tmp_e ) ) ); // tmp_e
- move32();
- }
-
- dctT2_N_apply_matrix_fx( (const Word32 *) u_mr_fx, dct_target_fx, s_min( max_dct_trunc, n_ana ), n_ana, invTrfMatrix_fx, max_dct_trunc, dcttype ); // exp : tmp_e
-
- /* init search state ptr's at the top */
- set32_fx( dist1_ptr_fx, MAX_32, maxC_st1 );
- set16_fx( dist1_ptr_e_buf, 32, maxC_st1 );
- st1_mse_pair_fx = &( dist1_ptr_fx[0] ); /* req. ptr post upd +=2 */ // st1_mse_pair_e
- st1_mse_pair_e = &( dist1_ptr_e_buf[0] ); /* req. ptr post upd +=2 */
- st1_idx_pair = &( indices_st1_local[0] ); /* req. ptr post upd +=2 */
- set64_fx( mse_trunc_segm_fx, 0, n_segm );
-
- // set16_fx( mse_trunc_segm_e, u_e, FDCNG_VQ_DCT_NSEGM );
-
- FOR( segm = 0; segm < n_segm; segm++ )
- { /* point to a new paired location for each segment */
- p_max = 0; /* req. to point to one of 1 or 0, this init can potentially be omitted here,as p_max is always 1 or 0 */
- move16();
-
- /* compute segment common trunction error in dctN domain */
-
- FOR( i = 0; i < trunc_dct_cols_per_segment[segm]; i++ )
- {
- mse_trunc_segm_fx[segm] = W_mac_32_32( mse_trunc_segm_fx[segm], dct_target_fx[cols_per_segment[segm] + i], dct_target_fx[cols_per_segment[segm] + i] ); // Q41
- move64();
- }
-
- cbpW8 = W8Qx_dct_sections[segm]; /* Word8 column variable Qx storage , table ptr init */
-
- FOR( j = 0; j < entries_per_segment[segm]; j++ )
- {
- /* unweighted segmented search DCT domain loop */
- j_full = add( j, cum_entries_per_segment[segm] ); /* or simply use j_full++ */
-
- mse_fx = mse_trunc_segm_fx[segm]; /* init mse with with common mse truncation part, in BASOP a move32() */ // Q41
- move64();
-
- dct_col_shift_tab = col_syn_shift[segm]; /* ptr init */
-
- FOR( c2 = 0; c2 < cols_per_segment[segm]; c2++ )
- {
-#define WMC_TOOL_SKIP
- tmp_fx = L_sub( dct_target_fx[c2], Mpy_32_32( L_shl( cbpW8[c2], add( sub( Q31, tmp_e ), dct_col_shift_tab[c2] ) ), dct_scaleF_fx[1] ) ); /* note: BASOP shift left defined for signed integers */
- LOGIC( 1 );
- SHIFT( 1 );
- ADD( 1 ); /* in BASOP: s_and(for W8->W16), shl(), sub()*/
-#undef WMC_TOOL_SKIP
- mse_fx = W_mac_32_32( mse_fx, tmp_fx, tmp_fx ); /* L_mac or L_mac0() square Word16 -> Word32*/ // Q41
- }
- Word16 L_tmp = W_norm( mse_fx );
- st1_mse_ptr_fx[j_full] = W_extract_h( W_lshl( mse_fx, L_tmp ) ); /* save MSE in shared dynamic RAM, move32() in BASOP */ // st1_mse_ptr_e
- move32();
- st1_mse_ptr_e[j_full] = sub( shl( tmp_e, 1 ), L_tmp );
- move16();
-
-#define WMC_TOOL_SKIP
- cbpW8 += cols_per_segment[segm]; /* fixed pointer increment for each segment */
-#undef WMC_TOOL_SKIP
-
- /* overwrite with a new worst index at p_max */
-
- /* Note: The three inner loop if's below are not 100% properly instrumented by WMC tool */
- // if ( st1_mse_ptr_fx[j_full] < st1_mse_pair_fx[p_max] ) /* L_sub */
- IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( st1_mse_ptr_fx[j_full], st1_mse_ptr_e[j_full], st1_mse_pair_fx[p_max], st1_mse_pair_e[p_max] ), -1 ) ) /* L_sub */
- {
- st1_idx_pair[p_max] = j_full; /* move16, single BASOP */
- move16();
- } /* BASOP 2 ops */
-
- IF( EQ_16( st1_idx_pair[p_max], j_full ) )
- { /* idx updated --> also update mse */
- st1_mse_pair_fx[p_max] = st1_mse_ptr_fx[j_full]; /* move32(), single BASOP */
- move32();
- st1_mse_pair_e[p_max] = st1_mse_ptr_e[j_full]; /* move32(), single BASOP */
- move16();
- } /* BASOP 3 ops */
-
- /* avoid WC costly candidate list management by always updating p_max,
- as we have only a pair in each segment to maintain */
- p_max = 0;
- move16();
- if ( EQ_16( BASOP_Util_Cmp_Mant32Exp( st1_mse_pair_fx[0], st1_mse_pair_e[0], st1_mse_pair_fx[1], st1_mse_pair_e[1] ), -1 ) ) /* L_sub()*/
- {
- p_max = 1; /* move16() */
- move16();
- } /* BASOP 3 ops ,Note 2 ops possible in BASOP with L_sub and L_lshr */
-
- /* Note: logical shift right not available in ANSI-C */
- /* p_max = (st1_mse_pair[0] - st1_mse_pair[1]) ">>>" 31; */
- /* in java logical shift right is available as >>> , in BASOP it is available as L_lshr */
-
- /* Cost: weighted sum with cond moves ('if') => 8 in float , 7 in BASOP with L_lshr */
- } /* j in section */
-
- st1_mse_pair_fx += 2; /* req. ptr init */
- st1_mse_pair_e += 2; /* req. ptr init */
- st1_idx_pair += 2; /* req. ptr init */
-
- } /* next segment */
-
- tmp_e = 0;
- move16();
- FOR( j = 0; j < maxC_st1; j++ )
- {
- /* compute_full mse using stored DCT24 domain MSE's */
- /* calculate MSE from stage1 inner using existing inner DCT domain variables */
- tmp_e = s_max( dist1_ptr_e_buf[j], tmp_e );
- }
-
- FOR( j = 0; j < maxC_st1; j++ )
- {
- /* compute_full mse using stored DCT24 domain MSE's */
- /* calculate MSE from stage1 inner using existing inner DCT domain variables */
- dist1_ptr_fx[j] = L_shr( dist1_ptr_fx[j], sub( tmp_e, dist1_ptr_e_buf[j] ) );
- move32();
- *dist1_ptr_e = tmp_e;
- move16();
- }
-
-
- assert( ( maxC_st1 >= 3 ) );
- assert( ( maxC_st1 <= 8 ) );
-
- p_max = maximum_32_fx( dist1_ptr_fx, maxC_st1, NULL ); /* establish current worst candidate for MSVQ stage#2 among all maxC_st1 candidates so far */
-
- p_mins[0] = minimum_32_fx( dist1_ptr_fx, maxC_st1, NULL ); /* find best entry among all maxC_pre */
- move16();
- tmp_fx = dist1_ptr_fx[p_mins[0]];
- move32();
- dist1_ptr_fx[p_mins[0]] = MAX_32; /* exclude 1st */
- move32();
-
- p_mins[1] = minimum_32_fx( dist1_ptr_fx, maxC_st1, NULL ); /* find 2nd best entry */
- move16();
- tmp2_fx = dist1_ptr_fx[p_mins[1]];
- move32();
- dist1_ptr_fx[p_mins[1]] = MAX_32; /* exclude 2nd */
- move32();
-
- dist1_ptr_fx[p_mins[0]] = tmp_fx; /* restore 1st */
- move32();
- dist1_ptr_fx[p_mins[1]] = tmp2_fx; /* restore 2nd */
- move32();
-
- idx_min[0] = indices_st1_local[p_mins[0]];
- move16();
- idx_min[1] = indices_st1_local[p_mins[1]];
- move16();
-
-
- /* use global exclusion list to never reselect the two (best) global MSE values sofar */
- st1_mse_ptr_fx[idx_min[0]] = MAX_32; /* move32() */
- move32();
- st1_mse_ptr_e[idx_min[0]] = MAX_16;
- move16();
- st1_mse_ptr_fx[idx_min[1]] = MAX_32; /* move32() */
- move32();
- st1_mse_ptr_e[idx_min[1]] = MAX_16;
- move16();
-
- /* circular MSE-neigbour list in use to potentially replace some segment search candidates */
- /* using both 1st and 2nd best neighbours in fwd and rev directions */
- check_ind[0] = segm_neighbour_fwd[idx_min[0]];
- move16();
- check_ind[1] = segm_neighbour_rev[idx_min[0]];
- move16();
-
- check_ind[2] = segm_neighbour_fwd[idx_min[1]];
- move16();
- check_ind[3] = segm_neighbour_rev[idx_min[1]];
- move16();
-
- check_ind[4] = segm_neighbour_fwd[check_ind[0]];
- move16();
- check_ind[5] = segm_neighbour_rev[check_ind[1]];
- move16();
-
- check_ind[6] = segm_neighbour_fwd[check_ind[2]];
- move16();
- check_ind[FDCNG_VQ_DCT_NPOST - 1] = segm_neighbour_rev[check_ind[3]];
- move16();
-
- FOR( i = 0; i < npost_check; i++ )
- {
- /* move MSE from DCT-inner loop search to input synthesis domain */
- /* multiplication by fdcng_dct_scaleF[2] to get the float outer loop scale correct in IDCT synthesis domain */
- check_mse = st1_mse_ptr_fx[check_ind[i]];
- move32();
- check_mse_e = st1_mse_ptr_e[check_ind[i]];
- move16();
-
- IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( check_mse, check_mse_e, dist1_ptr_fx[p_max], *dist1_ptr_e ), -1 ) )
- { /* new winner , replace worst */
- dist1_ptr_fx[p_max] = L_shl( check_mse, sub( check_mse_e, *dist1_ptr_e ) );
- move32();
- indices_st1_local[p_max] = check_ind[i];
- move16();
- st1_mse_ptr_fx[check_ind[i]] = MAX_32; /* exclude, BASOP: move32() */
- move32();
- st1_mse_ptr_e[check_ind[i]] = MAX_16;
- move16();
- p_max = maximum_32_fx( dist1_ptr_fx, maxC_st1, NULL ); /* establish a new current worst candidate among all maxC */
- }
- }
-
- /* extract the selected stage one vectors in DCT_N domain , apply IDCT_N and scale up */
- /* always extract full length signal(e.g. 24) to be able to update WB(e.g. N_in==21) candidate MSE values */
- /* in the case that only a part of the IDCT N vector is in final use */
-
- /* note: synthesis not yet fully parameterized/generalized for other IDCT lengths */
- assert( N == 24 );
- {
- FOR( c = 0; c < maxC_st1; c++ )
- {
- dec_FDCNG_MSVQ_stage1_fx( indices_st1_local[c], N, invTrfMatrix_fx, dcttype + 1, &( st1_syn_vec_ptr_fx[c * N] ), NULL ); // Q11 : output
- scale_sig32( &( st1_syn_vec_ptr_fx[c * N] ), N, sub( 11, s_max( u_e, 12 ) ) );
- }
- }
-
- return p_max; /*ptr to worst performing candidate */
-}
-
-
-/*--------------------------------------------------------------------------*
- * msvq_stage1_dct_recalc_candidates_fdcng_wb()
- *
- * recalc MSE for fdcng WB(0..20) coeffs ,
- essentially subtract res21^2 ,res22^2, res23^2 that was included in stage1 MSE in the DCT24 domain truncated search,
- excludes the waveform contributions at pos 21,22,23 to the MSE, important to keep the WB MSEs update for the subsequent stages
- *--------------------------------------------------------------------------*/
-
-/*! r: (updated p_max) */
-Word16 msvq_stage1_dct_recalc_candidates_fdcng_wb_fx(
- const Word32 *st1_syn_vec_ptr_fx, /* i : IDCT24 synthesis vectors st1_syn_vec_e*/
- const Word16 st1_syn_vec_e, /* i : exp for IDCT24 synthesis vectors */
- const Word32 *u_fx, /* i : target signal u_e*/
- const Word16 u_e, /* i : exp for target signal */
- const Word16 maxC_st1, /* i : number of candidates in stage1 */
- Word32 *dist_ptr_fx, /* i/o: updated MSE vector for stage1 */
- Word16 *dist_ptr_e /* i/o: exp for updated MSE vector for stage1 */
-)
-{
- Word16 i;
- Word16 p_max_local, c;
- const Word32 *p2_fx;
- Word16 tmp_e;
- Word32 res24_fx, high_diff_fx[FDCNG_VQ_MAX_LEN - FDCNG_VQ_MAX_LEN_WB];
- Word64 acc;
- Word16 res24_e[FD_CNG_maxC_37bits];
- Word16 dist_e;
-
- dist_e = *dist_ptr_e;
- move16();
- FOR( c = 0; c < maxC_st1; c++ )
- { /* point to extended synthesis part */
- p2_fx = (const Word32 *) &( st1_syn_vec_ptr_fx[c * FDCNG_VQ_MAX_LEN + FDCNG_VQ_MAX_LEN_WB] ); /* ptr init to synthesis candidate c */
- tmp_e = s_max( st1_syn_vec_e, u_e );
- tmp_e = add( tmp_e, 1 );
- /* for stage#1 use "u" instead of the shortened resid[0], to access the extended/extrapolated input target */
- FOR( i = 0; i < FDCNG_VQ_MAX_LEN - FDCNG_VQ_MAX_LEN_WB; i++ )
- {
- high_diff_fx[i] = L_sub( L_shr( p2_fx[i], sub( tmp_e, st1_syn_vec_e ) ), L_shr( u_fx[FDCNG_VQ_MAX_LEN_WB + i], sub( tmp_e, u_e ) ) ); // tmp_e
- move32();
- }
- acc = 0;
- move64();
- FOR( i = 0; i < FDCNG_VQ_MAX_LEN - FDCNG_VQ_MAX_LEN_WB; i++ )
- {
- acc = W_mac_32_32( acc, high_diff_fx[i], high_diff_fx[i] );
- }
- res24_e[c] = tmp_e;
- move16();
- tmp_e = W_norm( acc );
- res24_fx = W_extract_h( W_shl( acc, tmp_e ) );
-
- res24_e[c] = sub( shl( res24_e[c], 1 ), tmp_e );
- move16();
-
- dist_ptr_fx[c] = BASOP_Util_Add_Mant32Exp( dist_ptr_fx[c], *dist_ptr_e, L_negate( res24_fx ), res24_e[c], &res24_e[c] ); /* remove DCT24 high band error contribution */
- move32();
- dist_e = s_max( dist_e, res24_e[c] );
- move16();
- }
-
-
- FOR( c = 0; c < maxC_st1; c++ )
- {
- dist_ptr_fx[c] = L_shl( dist_ptr_fx[c], sub( res24_e[c], dist_e ) );
- move32();
- }
- *dist_ptr_e = dist_e;
- move16();
- /* finally update p_max, as it may potentially change,
- due to the core DCT24 search originally optimizing over the longer basis vectors than DCT21 */
- p_max_local = maximum_32_fx( dist_ptr_fx, maxC_st1, NULL );
-
- return p_max_local;
-}
-
-
-/*--------------------------------------------------------------------------*
- * msvq_enc()
- *
- * MSVQ encoder
- *--------------------------------------------------------------------------*/
-
-
-void msvq_enc_ivas_fx(
- const Word16 *const *cb, /* i : Codebook (indexed cb[*stages][levels][p]) Q_cb */
- const Word16 Q_cb, /* i : Codebook Q */
- const Word16 dims[], /* i : Dimension of each codebook stage (NULL: full dim.) */
- const Word16 offs[], /* i : Starting dimension of each codebook stage (NULL: 0) */
- const Word32 u_fx[], /* i : Vector to be encoded (prediction and mean removed) (exp : u_e) */
- const Word16 u_e, /* i : Exponent for Vector to be encoded */
- const Word16 *levels, /* i : Number of levels in each stage */
- const Word16 maxC, /* i : Tree search size (number of candidates kept from from one stage to the next == M-best) */
- const Word16 stages, /* i : Number of stages */
- const Word16 w[], /* i : Weights Q8 */
- const Word16 N, /* i : Vector dimension */
- const Word16 maxN, /* i : Codebook dimension */
- const Word16 applyDCT_flag, /* i : applyDCT flag */
- Word32 *invTrfMatrix_fx, /* i/o: synthesis matrix Q31 */
- Word16 Idx[] /* o : Indices */
-)
-{
- Word16 j;
- const Word16 *cbp, *cb_stage;
- Word32 resid_buf_fx[2 * LSFMBEST_MAX * M_MAX], *resid_fx[2];
- Word32 *pTmp, *p1, *p2; // pTmp_e
- Word16 pTmp_e;
- Word16 *indices[2], m, s, c, c2, p_max, i;
- Word16 idx_buf[2 * LSFMBEST_MAX * MAX_VQ_STAGES_USED], parents[LSFMBEST_MAX];
- Word32 dist_buf_fx[2 * LSFMBEST_MAX], *dist_fx[2], tmp, en, ss2, Tmp[M_MAX];
- Word16 dist_buf_e[2 * LSFMBEST_MAX], *dist_e[2];
- Word16 tmp_e, tmp_n, en_e;
- Word16 resid_e;
- Word16 n, maxn, start;
- Word64 W_acc; /*64 bit accumulator*/
-
- Word32 *st1_syn_vec_ptr_fx = &( resid_buf_fx[1 * LSFMBEST_MAX * M_MAX] ) - FDCNG_VQ_MAX_LEN * maxC;
- Word32 *st1_mse_ptr_fx = &( resid_buf_fx[1 * LSFMBEST_MAX * M_MAX] ) - ( levels[0] );
- Word16 indices_st1_local[FDCNG_VQ_DCT_NSEGM * 2];
-
- /*----------------------------------------------------------------*
- * Allocate memory for previous (parent) and current nodes.
- * Parent node is indexed [0], current node is indexed [1].
- *----------------------------------------------------------------*/
- indices[0] = idx_buf;
- indices[1] = idx_buf + maxC * stages; /*move16();*/
- /*vr_iset(0, idx_buf, 2*stages*maxC);*/
- set16_fx( idx_buf, 0, (Word16) ( 2 * stages * maxC ) );
-
- resid_fx[0] = resid_buf_fx;
- resid_fx[1] = resid_buf_fx + maxC * N; /*move16();*/
-
- dist_fx[0] = dist_buf_fx;
- dist_e[0] = dist_buf_e;
- dist_fx[1] = dist_buf_fx + maxC;
- dist_e[1] = dist_buf_e + maxC;
-
- /*vr_iset(0, parents, maxC);*/
- set16_fx( parents, 0, maxC );
-
- /*----------------------------------------------------------------*
- * LSF weights are normalized, so it is always better to multiply it first
- * Set up inital distance vector
- *----------------------------------------------------------------*/
- W_acc = W_mult_32_32( Mpy_32_16_1( u_fx[0], shl( w[0], 2 ) ), u_fx[0] ); // 2*Qu - 6 + 1
- FOR( j = 1; j < N; j++ )
- {
- W_acc = W_mac_32_32( W_acc, Mpy_32_16_1( u_fx[j], shl( w[j], 2 ) ), u_fx[j] ); // 2*Qu - 6 + 1
- }
-
- tmp_n = W_norm( W_acc );
- ss2 = W_extract_h( W_shl( W_acc, tmp_n ) );
- tmp_e = sub( add( shl( u_e, 1 ), 5 ), tmp_n );
-
- /* Set up inital error (residual) vectors */
- pTmp = resid_fx[1]; /*move16();*/
- resid_e = u_e;
- move16();
- IF( applyDCT_flag != 0 )
- {
- resid_e = s_max( u_e, 12 );
- }
- FOR( c = 0; c < maxC; c++ )
- {
- Copy32( u_fx, pTmp + c * N, N );
- test();
- IF( applyDCT_flag != 0 && LT_16( u_e, 12 ) )
- {
- scale_sig32( pTmp + c * N, N, sub( u_e, resid_e ) );
- }
- dist_fx[1][c] = ss2;
- move32();
- dist_e[1][c] = tmp_e;
- move16();
- }
-
- /* Loop over all stages */
- m = 1;
- move16();
- FOR( s = 0; s < stages; s++ )
- {
- /* codebook pointer is set to point to first stage */
- cbp = cb[s]; /*Q_cb*/
- cb_stage = cbp;
-
- /* Set up pointers to parent and current nodes */
- swap( indices[0], indices[1], Word16 * );
- move16();
- move16();
- move16();
- swap( resid_fx[0], resid_fx[1], Word32 * );
- move32();
- move32();
- move32();
- swap( dist_fx[0], dist_fx[1], Word32 * );
- swap( dist_e[0], dist_e[1], Word16 * );
- move32();
- move32();
- move32();
- move16();
- move16();
- move16();
-
- /* p_max points to maximum distortion node (worst of best) */
- p_max = 0;
- move16();
-
- n = N;
- move16();
- maxn = maxN;
- move16();
- if ( dims )
- {
- n = dims[s];
- move16();
- }
- if ( dims )
- {
- maxn = n;
- move16();
- }
-
- assert( ( maxn % 4 ) == 0 );
-
- start = 0;
- move16();
- if ( offs )
- {
- start = offs[s];
- move16();
- }
-
- set32_fx( Tmp, 0, start );
- set32_fx( Tmp + start + n, 0, sub( N, add( start, n ) ) );
-
- /* Set distortions to a large value */
- FOR( j = 0; j < maxC; j++ )
- {
- dist_fx[1][j] = MAX_32;
- move32();
- dist_e[1][j] = MAX_16 / 2;
- move16();
- }
-
- test();
- IF( !s && applyDCT_flag != 0 ) /* means: m==1 */
- {
- /* stage 1 candidates search in truncated dct24 domain without any weights */
- assert( N == FDCNG_VQ_MAX_LEN || N == FDCNG_VQ_MAX_LEN_WB ); /* 21 and 24 allowed */
- assert( maxC == 2 * FDCNG_VQ_DCT_NSEGM );
- p_max = msvq_stage1_dct_search_fx( u_fx, u_e, FDCNG_VQ_MAX_LEN, maxC, DCT_T2_24_XX, FDCNG_VQ_DCT_MAXTRUNC, (Word32 *) invTrfMatrix_fx, cdk1r_tr_midQ_truncQ_fx, fdcng_dct_scaleF_fx, FDCNG_VQ_DCT_NSEGM,
- cdk1_ivas_cols_per_segment, cdk1_ivas_trunc_dct_cols_per_segment, cdk1_ivas_entries_per_segment, cdk1_ivas_cum_entries_per_segment, cdk_37bits_ivas_stage1_W8Qx_dct_sections,
- stage1_dct_col_syn_shift, cdk1_ivas_segm_neighbour_fwd, cdk1_ivas_segm_neighbour_rev, FDCNG_VQ_DCT_NPOST, st1_mse_ptr_fx, indices_st1_local, st1_syn_vec_ptr_fx, dist_fx[1], &dist_e[1][0] );
-
- /* move established stage#1 indices to the global MSVQ list structure */
- set16_fx( dist_e[1], dist_e[1][0], maxC );
- FOR( c = 0; c < maxC; c++ )
- {
- indices[1][c * stages] = indices_st1_local[c];
- move16();
- }
- }
- ELSE
- {
- FOR( j = 0; j < levels[s]; j++ )
- {
- /* Compute weighted codebook element and its energy */
- en = 0;
- move32();
- en_e = 0;
- move16();
- W_acc = 0;
- move64();
- FOR( c2 = 0; c2 < n; c2++ )
- {
- Tmp[start + c2] = L_mult0( shl( w[start + c2], 2 ), cbp[c2] );
- move32();
- W_acc = W_mac_32_16( W_acc, Tmp[start + c2], cbp[c2] );
- }
-
- tmp_n = W_norm( W_acc );
-
- en = W_extract_h( W_shl( W_acc, tmp_n ) );
- en_e = sub( sub( 52, shl( Q_cb, 1 ) ), tmp_n );
-
- cbp += maxn; /* pointer is incremented */
-
- /* Iterate over all parent nodes */
- FOR( c = 0; c < m; c++ )
- {
- pTmp = &resid_fx[0][c * N];
- pTmp_e = resid_e;
- move16();
- /*tmp = (*pTmp++) * Tmp[0];*/
- W_acc = W_mult_32_32( pTmp[0], Tmp[0] );
-
- FOR( i = 1; i < N; i++ )
- {
- W_acc = W_mac_32_32( W_acc, pTmp[i], Tmp[i] );
- }
- tmp_n = W_norm( W_acc );
- tmp = W_extract_h( W_shl( W_acc, tmp_n ) );
- tmp_e = sub( add( pTmp_e, sub( Q31 - Q10, Q_cb ) ), tmp_n );
-
-
- tmp_n = s_max( tmp_e, en_e );
- tmp_n = s_max( dist_e[0][c], tmp_n );
-
- IF( NE_16( dist_e[0][c], MAX_16 / 2 ) )
- {
- tmp_n = add( tmp_n, 2 );
- tmp = L_sub( L_shl( en, sub( en_e, tmp_n ) ), L_shl( tmp, add( sub( tmp_e, tmp_n ), 1 ) ) );
- tmp = L_add( tmp, L_shl( dist_fx[0][c], sub( dist_e[0][c], tmp_n ) ) );
- }
- ELSE
- {
- tmp = MAX_32 - 1;
- move32();
- tmp_n = MAX_16 / 2;
- move32();
- }
-
- IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( tmp, tmp_n, dist_fx[1][p_max], dist_e[1][p_max] ), -1 ) )
- {
- /* Replace worst */
- dist_fx[1][p_max] = tmp;
- move32();
- dist_e[1][p_max] = tmp_n;
- move16();
- indices[1][p_max * stages + s] = j;
- move16();
- parents[p_max] = c;
- move16();
-
- p_max = 0;
- move16();
- tmp_e = p_max;
- move16();
-
- tmp_n = dist_e[1][0];
- move16();
- FOR( c2 = 1; c2 < maxC; c2++ )
- {
- if ( EQ_16( BASOP_Util_Cmp_Mant32Exp( dist_fx[1][c2], dist_e[1][c2], dist_fx[1][p_max], dist_e[1][p_max] ), 1 ) )
- {
- p_max = c2;
- move16();
- }
- test();
- if ( GT_16( dist_e[1][c2], tmp_n ) && NE_16( dist_e[1][c2], MAX_16 / 2 ) )
- {
- tmp_n = dist_e[1][c2];
- move16();
- }
- }
- FOR( c2 = 0; c2 < maxC; c2++ )
- {
- IF( NE_16( dist_e[1][c2], MAX_16 / 2 ) )
- {
- dist_fx[1][c2] = L_shl( dist_fx[1][c2], sub( dist_e[1][c2], tmp_n ) );
- move32();
- dist_e[1][c2] = tmp_n;
- move16();
- }
- }
- } /*IF (L_sub(tmp,dist[1][p_max]) < 0) */
- } /* FOR (c=0; c= max_dct_trunc ); /* check for FDCNGVQ WB , SWB, FB operation */
+
+ /* remove mid stage#1 vector, in original input domain */
+ tmp_e = s_max( 12, u_e );
+ FOR( i = 0; i < n_ana; i++ )
+ {
+ u_mr_fx[i] = L_sub( L_shl( u_fx[i], sub( u_e, tmp_e ) ), L_shl( midQ_truncQ_fx[i], sub( Q31 - Q10, tmp_e ) ) ); // tmp_e
+ move32();
+ }
+
+ dctT2_N_apply_matrix_fx( (const Word32 *) u_mr_fx, dct_target_fx, s_min( max_dct_trunc, n_ana ), n_ana, invTrfMatrix_fx, max_dct_trunc, dcttype ); // exp : tmp_e
+
+ /* init search state ptr's at the top */
+ set32_fx( dist1_ptr_fx, MAX_32, maxC_st1 );
+ set16_fx( dist1_ptr_e_buf, 32, maxC_st1 );
+ st1_mse_pair_fx = &( dist1_ptr_fx[0] ); /* req. ptr post upd +=2 */ // st1_mse_pair_e
+ st1_mse_pair_e = &( dist1_ptr_e_buf[0] ); /* req. ptr post upd +=2 */
+ st1_idx_pair = &( indices_st1_local[0] ); /* req. ptr post upd +=2 */
+ set64_fx( mse_trunc_segm_fx, 0, n_segm );
+
+ // set16_fx( mse_trunc_segm_e, u_e, FDCNG_VQ_DCT_NSEGM );
+
+ FOR( segm = 0; segm < n_segm; segm++ )
+ { /* point to a new paired location for each segment */
+ p_max = 0; /* req. to point to one of 1 or 0, this init can potentially be omitted here,as p_max is always 1 or 0 */
+ move16();
+
+ /* compute segment common trunction error in dctN domain */
+
+ FOR( i = 0; i < trunc_dct_cols_per_segment[segm]; i++ )
+ {
+ mse_trunc_segm_fx[segm] = W_mac_32_32( mse_trunc_segm_fx[segm], dct_target_fx[cols_per_segment[segm] + i], dct_target_fx[cols_per_segment[segm] + i] ); // Q41
+ move64();
+ }
+
+ cbpW8 = W8Qx_dct_sections[segm]; /* Word8 column variable Qx storage , table ptr init */
+
+ FOR( j = 0; j < entries_per_segment[segm]; j++ )
+ {
+ /* unweighted segmented search DCT domain loop */
+ j_full = add( j, cum_entries_per_segment[segm] ); /* or simply use j_full++ */
+
+ mse_fx = mse_trunc_segm_fx[segm]; /* init mse with with common mse truncation part, in BASOP a move32() */ // Q41
+ move64();
+
+ dct_col_shift_tab = col_syn_shift[segm]; /* ptr init */
+
+ FOR( c2 = 0; c2 < cols_per_segment[segm]; c2++ )
+ {
+#define WMC_TOOL_SKIP
+ tmp_fx = L_sub( dct_target_fx[c2], Mpy_32_32( L_shl( cbpW8[c2], add( sub( Q31, tmp_e ), dct_col_shift_tab[c2] ) ), dct_scaleF_fx[1] ) ); /* note: BASOP shift left defined for signed integers */
+ LOGIC( 1 );
+ SHIFT( 1 );
+ ADD( 1 ); /* in BASOP: s_and(for W8->W16), shl(), sub()*/
+#undef WMC_TOOL_SKIP
+ mse_fx = W_mac_32_32( mse_fx, tmp_fx, tmp_fx ); /* L_mac or L_mac0() square Word16 -> Word32*/ // Q41
+ }
+ Word16 L_tmp = W_norm( mse_fx );
+ st1_mse_ptr_fx[j_full] = W_extract_h( W_lshl( mse_fx, L_tmp ) ); /* save MSE in shared dynamic RAM, move32() in BASOP */ // st1_mse_ptr_e
+ move32();
+ st1_mse_ptr_e[j_full] = sub( shl( tmp_e, 1 ), L_tmp );
+ move16();
+
+#define WMC_TOOL_SKIP
+ cbpW8 += cols_per_segment[segm]; /* fixed pointer increment for each segment */
+#undef WMC_TOOL_SKIP
+
+ /* overwrite with a new worst index at p_max */
+
+ /* Note: The three inner loop if's below are not 100% properly instrumented by WMC tool */
+ // if ( st1_mse_ptr_fx[j_full] < st1_mse_pair_fx[p_max] ) /* L_sub */
+ IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( st1_mse_ptr_fx[j_full], st1_mse_ptr_e[j_full], st1_mse_pair_fx[p_max], st1_mse_pair_e[p_max] ), -1 ) ) /* L_sub */
+ {
+ st1_idx_pair[p_max] = j_full; /* move16, single BASOP */
+ move16();
+ } /* BASOP 2 ops */
+
+ IF( EQ_16( st1_idx_pair[p_max], j_full ) )
+ { /* idx updated --> also update mse */
+ st1_mse_pair_fx[p_max] = st1_mse_ptr_fx[j_full]; /* move32(), single BASOP */
+ move32();
+ st1_mse_pair_e[p_max] = st1_mse_ptr_e[j_full]; /* move32(), single BASOP */
+ move16();
+ } /* BASOP 3 ops */
+
+ /* avoid WC costly candidate list management by always updating p_max,
+ as we have only a pair in each segment to maintain */
+ p_max = 0;
+ move16();
+ if ( EQ_16( BASOP_Util_Cmp_Mant32Exp( st1_mse_pair_fx[0], st1_mse_pair_e[0], st1_mse_pair_fx[1], st1_mse_pair_e[1] ), -1 ) ) /* L_sub()*/
+ {
+ p_max = 1; /* move16() */
+ move16();
+ } /* BASOP 3 ops ,Note 2 ops possible in BASOP with L_sub and L_lshr */
+
+ /* Note: logical shift right not available in ANSI-C */
+ /* p_max = (st1_mse_pair[0] - st1_mse_pair[1]) ">>>" 31; */
+ /* in java logical shift right is available as >>> , in BASOP it is available as L_lshr */
+
+ /* Cost: weighted sum with cond moves ('if') => 8 in float , 7 in BASOP with L_lshr */
+ } /* j in section */
+
+ st1_mse_pair_fx += 2; /* req. ptr init */
+ st1_mse_pair_e += 2; /* req. ptr init */
+ st1_idx_pair += 2; /* req. ptr init */
+
+ } /* next segment */
+
+ tmp_e = 0;
+ move16();
+ FOR( j = 0; j < maxC_st1; j++ )
+ {
+ /* compute_full mse using stored DCT24 domain MSE's */
+ /* calculate MSE from stage1 inner using existing inner DCT domain variables */
+ tmp_e = s_max( dist1_ptr_e_buf[j], tmp_e );
+ }
+
+ FOR( j = 0; j < maxC_st1; j++ )
+ {
+ /* compute_full mse using stored DCT24 domain MSE's */
+ /* calculate MSE from stage1 inner using existing inner DCT domain variables */
+ dist1_ptr_fx[j] = L_shr( dist1_ptr_fx[j], sub( tmp_e, dist1_ptr_e_buf[j] ) );
+ move32();
+ *dist1_ptr_e = tmp_e;
+ move16();
+ }
+
+
+ assert( ( maxC_st1 >= 3 ) );
+ assert( ( maxC_st1 <= 8 ) );
+
+ p_max = maximum_32_fx( dist1_ptr_fx, maxC_st1, NULL ); /* establish current worst candidate for MSVQ stage#2 among all maxC_st1 candidates so far */
+
+ p_mins[0] = minimum_32_fx( dist1_ptr_fx, maxC_st1, NULL ); /* find best entry among all maxC_pre */
+ move16();
+ tmp_fx = dist1_ptr_fx[p_mins[0]];
+ move32();
+ dist1_ptr_fx[p_mins[0]] = MAX_32; /* exclude 1st */
+ move32();
+
+ p_mins[1] = minimum_32_fx( dist1_ptr_fx, maxC_st1, NULL ); /* find 2nd best entry */
+ move16();
+ tmp2_fx = dist1_ptr_fx[p_mins[1]];
+ move32();
+ dist1_ptr_fx[p_mins[1]] = MAX_32; /* exclude 2nd */
+ move32();
+
+ dist1_ptr_fx[p_mins[0]] = tmp_fx; /* restore 1st */
+ move32();
+ dist1_ptr_fx[p_mins[1]] = tmp2_fx; /* restore 2nd */
+ move32();
+
+ idx_min[0] = indices_st1_local[p_mins[0]];
+ move16();
+ idx_min[1] = indices_st1_local[p_mins[1]];
+ move16();
+
+
+ /* use global exclusion list to never reselect the two (best) global MSE values sofar */
+ st1_mse_ptr_fx[idx_min[0]] = MAX_32; /* move32() */
+ move32();
+ st1_mse_ptr_e[idx_min[0]] = MAX_16;
+ move16();
+ st1_mse_ptr_fx[idx_min[1]] = MAX_32; /* move32() */
+ move32();
+ st1_mse_ptr_e[idx_min[1]] = MAX_16;
+ move16();
+
+ /* circular MSE-neigbour list in use to potentially replace some segment search candidates */
+ /* using both 1st and 2nd best neighbours in fwd and rev directions */
+ check_ind[0] = segm_neighbour_fwd[idx_min[0]];
+ move16();
+ check_ind[1] = segm_neighbour_rev[idx_min[0]];
+ move16();
+
+ check_ind[2] = segm_neighbour_fwd[idx_min[1]];
+ move16();
+ check_ind[3] = segm_neighbour_rev[idx_min[1]];
+ move16();
+
+ check_ind[4] = segm_neighbour_fwd[check_ind[0]];
+ move16();
+ check_ind[5] = segm_neighbour_rev[check_ind[1]];
+ move16();
+
+ check_ind[6] = segm_neighbour_fwd[check_ind[2]];
+ move16();
+ check_ind[FDCNG_VQ_DCT_NPOST - 1] = segm_neighbour_rev[check_ind[3]];
+ move16();
+
+ FOR( i = 0; i < npost_check; i++ )
+ {
+ /* move MSE from DCT-inner loop search to input synthesis domain */
+ /* multiplication by fdcng_dct_scaleF[2] to get the float outer loop scale correct in IDCT synthesis domain */
+ check_mse = st1_mse_ptr_fx[check_ind[i]];
+ move32();
+ check_mse_e = st1_mse_ptr_e[check_ind[i]];
+ move16();
+
+ IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( check_mse, check_mse_e, dist1_ptr_fx[p_max], *dist1_ptr_e ), -1 ) )
+ { /* new winner , replace worst */
+ dist1_ptr_fx[p_max] = L_shl( check_mse, sub( check_mse_e, *dist1_ptr_e ) );
+ move32();
+ indices_st1_local[p_max] = check_ind[i];
+ move16();
+ st1_mse_ptr_fx[check_ind[i]] = MAX_32; /* exclude, BASOP: move32() */
+ move32();
+ st1_mse_ptr_e[check_ind[i]] = MAX_16;
+ move16();
+ p_max = maximum_32_fx( dist1_ptr_fx, maxC_st1, NULL ); /* establish a new current worst candidate among all maxC */
+ }
+ }
+
+ /* extract the selected stage one vectors in DCT_N domain , apply IDCT_N and scale up */
+ /* always extract full length signal(e.g. 24) to be able to update WB(e.g. N_in==21) candidate MSE values */
+ /* in the case that only a part of the IDCT N vector is in final use */
+
+ /* note: synthesis not yet fully parameterized/generalized for other IDCT lengths */
+ assert( N == 24 );
+ {
+ FOR( c = 0; c < maxC_st1; c++ )
+ {
+ dec_FDCNG_MSVQ_stage1_fx( indices_st1_local[c], N, invTrfMatrix_fx, dcttype + 1, &( st1_syn_vec_ptr_fx[c * N] ), NULL ); // Q11 : output
+ scale_sig32( &( st1_syn_vec_ptr_fx[c * N] ), N, sub( 11, s_max( u_e, 12 ) ) );
+ }
+ }
+
+ return p_max; /*ptr to worst performing candidate */
+}
+
+
+/*--------------------------------------------------------------------------*
+ * msvq_stage1_dct_recalc_candidates_fdcng_wb()
+ *
+ * recalc MSE for fdcng WB(0..20) coeffs ,
+ essentially subtract res21^2 ,res22^2, res23^2 that was included in stage1 MSE in the DCT24 domain truncated search,
+ excludes the waveform contributions at pos 21,22,23 to the MSE, important to keep the WB MSEs update for the subsequent stages
+ *--------------------------------------------------------------------------*/
+
+/*! r: (updated p_max) */
+Word16 msvq_stage1_dct_recalc_candidates_fdcng_wb_fx(
+ const Word32 *st1_syn_vec_ptr_fx, /* i : IDCT24 synthesis vectors st1_syn_vec_e*/
+ const Word16 st1_syn_vec_e, /* i : exp for IDCT24 synthesis vectors */
+ const Word32 *u_fx, /* i : target signal u_e*/
+ const Word16 u_e, /* i : exp for target signal */
+ const Word16 maxC_st1, /* i : number of candidates in stage1 */
+ Word32 *dist_ptr_fx, /* i/o: updated MSE vector for stage1 */
+ Word16 *dist_ptr_e /* i/o: exp for updated MSE vector for stage1 */
+)
+{
+ Word16 i;
+ Word16 p_max_local, c;
+ const Word32 *p2_fx;
+ Word16 tmp_e;
+ Word32 res24_fx, high_diff_fx[FDCNG_VQ_MAX_LEN - FDCNG_VQ_MAX_LEN_WB];
+ Word64 acc;
+ Word16 res24_e[FD_CNG_maxC_37bits];
+ Word16 dist_e;
+
+ dist_e = *dist_ptr_e;
+ move16();
+ FOR( c = 0; c < maxC_st1; c++ )
+ { /* point to extended synthesis part */
+ p2_fx = (const Word32 *) &( st1_syn_vec_ptr_fx[c * FDCNG_VQ_MAX_LEN + FDCNG_VQ_MAX_LEN_WB] ); /* ptr init to synthesis candidate c */
+ tmp_e = s_max( st1_syn_vec_e, u_e );
+ tmp_e = add( tmp_e, 1 );
+ /* for stage#1 use "u" instead of the shortened resid[0], to access the extended/extrapolated input target */
+ FOR( i = 0; i < FDCNG_VQ_MAX_LEN - FDCNG_VQ_MAX_LEN_WB; i++ )
+ {
+ high_diff_fx[i] = L_sub( L_shr( p2_fx[i], sub( tmp_e, st1_syn_vec_e ) ), L_shr( u_fx[FDCNG_VQ_MAX_LEN_WB + i], sub( tmp_e, u_e ) ) ); // tmp_e
+ move32();
+ }
+ acc = 0;
+ move64();
+ FOR( i = 0; i < FDCNG_VQ_MAX_LEN - FDCNG_VQ_MAX_LEN_WB; i++ )
+ {
+ acc = W_mac_32_32( acc, high_diff_fx[i], high_diff_fx[i] );
+ }
+ res24_e[c] = tmp_e;
+ move16();
+ tmp_e = W_norm( acc );
+ res24_fx = W_extract_h( W_shl( acc, tmp_e ) );
+
+ res24_e[c] = sub( shl( res24_e[c], 1 ), tmp_e );
+ move16();
+
+ dist_ptr_fx[c] = BASOP_Util_Add_Mant32Exp( dist_ptr_fx[c], *dist_ptr_e, L_negate( res24_fx ), res24_e[c], &res24_e[c] ); /* remove DCT24 high band error contribution */
+ move32();
+ dist_e = s_max( dist_e, res24_e[c] );
+ move16();
+ }
+
+
+ FOR( c = 0; c < maxC_st1; c++ )
+ {
+ dist_ptr_fx[c] = L_shl( dist_ptr_fx[c], sub( res24_e[c], dist_e ) );
+ move32();
+ }
+ *dist_ptr_e = dist_e;
+ move16();
+ /* finally update p_max, as it may potentially change,
+ due to the core DCT24 search originally optimizing over the longer basis vectors than DCT21 */
+ p_max_local = maximum_32_fx( dist_ptr_fx, maxC_st1, NULL );
+
+ return p_max_local;
+}
+
+
/*--------------------------------------------------------------------------*
* depack_mul_values_fx()
*
*--------------------------------------------------------------------------*/
+
static Word32 depack_mul_values_fx( Word16 *Tmp, const Word16 *w, const Word16 *cbp, const Word16 N )
{
Word16 i, val0, val1, val2, val3;
@@ -65,10 +440,13 @@ static Word32 depack_mul_values_fx( Word16 *Tmp, const Word16 *w, const Word16 *
return en;
}
+
+
/*--------------------------------------------------------------------------*
* depack_sub_values()
*
*--------------------------------------------------------------------------*/
+
static void depack_sub_values_fx( Word16 *pTmp, const Word16 *p1, const Word16 *cbp, const Word16 N )
{
Word16 j, val0, val1, val2, val3;
@@ -88,11 +466,14 @@ static void depack_sub_values_fx( Word16 *pTmp, const Word16 *p1, const Word16 *
move16(); /*3Q12*1.28*/
}
}
+
+
/*--------------------------------------------------------------------------*
* msvq_enc_find_p_max_8()
*
* Unroll of inner search loop for maxC == 8
*--------------------------------------------------------------------------*/
+
static Word16 msvq_enc_find_p_max_8_fx( Word32 dist[] )
{
Word16 p_max;
@@ -139,11 +520,14 @@ static Word16 msvq_enc_find_p_max_8_fx( Word32 dist[] )
BASOP_SATURATE_WARNING_ON_EVS
return p_max;
}
+
+
/*--------------------------------------------------------------------------*
* msvq_enc_find_p_max_6()
*
* Unroll of inner search loop for maxC == 6
*--------------------------------------------------------------------------*/
+
static Word16 msvq_enc_find_p_max_6_fx( Word32 dist[] )
{
Word16 p_max;
@@ -180,11 +564,14 @@ static Word16 msvq_enc_find_p_max_6_fx( Word32 dist[] )
BASOP_SATURATE_WARNING_ON_EVS
return p_max;
}
+
+
/*--------------------------------------------------------------------------*
* msvq_enc_fx()
*
* MSVQ encoder
*--------------------------------------------------------------------------*/
+
void msvq_enc_fx(
const Word16 *const *cb, /* i : Codebook (indexed cb[*stages][levels][p]) (0Q15) */
const Word16 dims[], /* i : Dimension of each codebook stage (NULL: full dim.) */
@@ -400,6 +787,449 @@ void msvq_enc_fx(
return;
}
+
+/*--------------------------------------------------------------------------*
+ * msvq_enc_ivas_fx()
+ *
+ * MSVQ encoder
+ *--------------------------------------------------------------------------*/
+
+void msvq_enc_ivas_fx(
+ const Word16 *const *cb, /* i : Codebook (indexed cb[*stages][levels][p]) Q_cb */
+ const Word16 Q_cb, /* i : Codebook Q */
+ const Word16 dims[], /* i : Dimension of each codebook stage (NULL: full dim.) */
+ const Word16 offs[], /* i : Starting dimension of each codebook stage (NULL: 0) */
+ const Word32 u_fx[], /* i : Vector to be encoded (prediction and mean removed) (exp : u_e) */
+ const Word16 u_e, /* i : Exponent for Vector to be encoded */
+ const Word16 *levels, /* i : Number of levels in each stage */
+ const Word16 maxC, /* i : Tree search size (number of candidates kept from from one stage to the next == M-best) */
+ const Word16 stages, /* i : Number of stages */
+ const Word16 w[], /* i : Weights Q8 */
+ const Word16 N, /* i : Vector dimension */
+ const Word16 maxN, /* i : Codebook dimension */
+ const Word16 applyDCT_flag, /* i : applyDCT flag */
+ Word32 *invTrfMatrix_fx, /* i/o: synthesis matrix Q31 */
+ Word16 Idx[] /* o : Indices */
+)
+{
+ Word16 j;
+ const Word16 *cbp, *cb_stage;
+ Word32 resid_buf_fx[2 * LSFMBEST_MAX * M_MAX], *resid_fx[2];
+ Word32 *pTmp, *p1, *p2; // pTmp_e
+ Word16 pTmp_e;
+ Word16 *indices[2], m, s, c, c2, p_max, i;
+ Word16 idx_buf[2 * LSFMBEST_MAX * MAX_VQ_STAGES_USED], parents[LSFMBEST_MAX];
+ Word32 dist_buf_fx[2 * LSFMBEST_MAX], *dist_fx[2], tmp, en, ss2, Tmp[M_MAX];
+ Word16 dist_buf_e[2 * LSFMBEST_MAX], *dist_e[2];
+ Word16 tmp_e, tmp_n, en_e;
+ Word16 resid_e;
+ Word16 n, maxn, start;
+ Word64 W_acc; /*64 bit accumulator*/
+
+ Word32 *st1_syn_vec_ptr_fx = &( resid_buf_fx[1 * LSFMBEST_MAX * M_MAX] ) - FDCNG_VQ_MAX_LEN * maxC;
+ Word32 *st1_mse_ptr_fx = &( resid_buf_fx[1 * LSFMBEST_MAX * M_MAX] ) - ( levels[0] );
+ Word16 indices_st1_local[FDCNG_VQ_DCT_NSEGM * 2];
+
+ /*----------------------------------------------------------------*
+ * Allocate memory for previous (parent) and current nodes.
+ * Parent node is indexed [0], current node is indexed [1].
+ *----------------------------------------------------------------*/
+ indices[0] = idx_buf;
+ indices[1] = idx_buf + maxC * stages; /*move16();*/
+ /*vr_iset(0, idx_buf, 2*stages*maxC);*/
+ set16_fx( idx_buf, 0, (Word16) ( 2 * stages * maxC ) );
+
+ resid_fx[0] = resid_buf_fx;
+ resid_fx[1] = resid_buf_fx + maxC * N; /*move16();*/
+
+ dist_fx[0] = dist_buf_fx;
+ dist_e[0] = dist_buf_e;
+ dist_fx[1] = dist_buf_fx + maxC;
+ dist_e[1] = dist_buf_e + maxC;
+
+ /*vr_iset(0, parents, maxC);*/
+ set16_fx( parents, 0, maxC );
+
+ /*----------------------------------------------------------------*
+ * LSF weights are normalized, so it is always better to multiply it first
+ * Set up inital distance vector
+ *----------------------------------------------------------------*/
+ W_acc = W_mult_32_32( Mpy_32_16_1( u_fx[0], shl( w[0], 2 ) ), u_fx[0] ); // 2*Qu - 6 + 1
+ FOR( j = 1; j < N; j++ )
+ {
+ W_acc = W_mac_32_32( W_acc, Mpy_32_16_1( u_fx[j], shl( w[j], 2 ) ), u_fx[j] ); // 2*Qu - 6 + 1
+ }
+
+ tmp_n = W_norm( W_acc );
+ ss2 = W_extract_h( W_shl( W_acc, tmp_n ) );
+ tmp_e = sub( add( shl( u_e, 1 ), 5 ), tmp_n );
+
+ /* Set up inital error (residual) vectors */
+ pTmp = resid_fx[1]; /*move16();*/
+ resid_e = u_e;
+ move16();
+ IF( applyDCT_flag != 0 )
+ {
+ resid_e = s_max( u_e, 12 );
+ }
+ FOR( c = 0; c < maxC; c++ )
+ {
+ Copy32( u_fx, pTmp + c * N, N );
+ test();
+ IF( applyDCT_flag != 0 && LT_16( u_e, 12 ) )
+ {
+ scale_sig32( pTmp + c * N, N, sub( u_e, resid_e ) );
+ }
+ dist_fx[1][c] = ss2;
+ move32();
+ dist_e[1][c] = tmp_e;
+ move16();
+ }
+
+ /* Loop over all stages */
+ m = 1;
+ move16();
+ FOR( s = 0; s < stages; s++ )
+ {
+ /* codebook pointer is set to point to first stage */
+ cbp = cb[s]; /*Q_cb*/
+ cb_stage = cbp;
+
+ /* Set up pointers to parent and current nodes */
+ swap( indices[0], indices[1], Word16 * );
+ move16();
+ move16();
+ move16();
+ swap( resid_fx[0], resid_fx[1], Word32 * );
+ move32();
+ move32();
+ move32();
+ swap( dist_fx[0], dist_fx[1], Word32 * );
+ swap( dist_e[0], dist_e[1], Word16 * );
+ move32();
+ move32();
+ move32();
+ move16();
+ move16();
+ move16();
+
+ /* p_max points to maximum distortion node (worst of best) */
+ p_max = 0;
+ move16();
+
+ n = N;
+ move16();
+ maxn = maxN;
+ move16();
+ if ( dims )
+ {
+ n = dims[s];
+ move16();
+ }
+ if ( dims )
+ {
+ maxn = n;
+ move16();
+ }
+
+ assert( ( maxn % 4 ) == 0 );
+
+ start = 0;
+ move16();
+ if ( offs )
+ {
+ start = offs[s];
+ move16();
+ }
+
+ set32_fx( Tmp, 0, start );
+ set32_fx( Tmp + start + n, 0, sub( N, add( start, n ) ) );
+
+ /* Set distortions to a large value */
+ FOR( j = 0; j < maxC; j++ )
+ {
+ dist_fx[1][j] = MAX_32;
+ move32();
+ dist_e[1][j] = MAX_16 / 2;
+ move16();
+ }
+
+ test();
+ IF( !s && applyDCT_flag != 0 ) /* means: m==1 */
+ {
+ /* stage 1 candidates search in truncated dct24 domain without any weights */
+ assert( N == FDCNG_VQ_MAX_LEN || N == FDCNG_VQ_MAX_LEN_WB ); /* 21 and 24 allowed */
+ assert( maxC == 2 * FDCNG_VQ_DCT_NSEGM );
+ p_max = msvq_stage1_dct_search_fx( u_fx, u_e, FDCNG_VQ_MAX_LEN, maxC, DCT_T2_24_XX, FDCNG_VQ_DCT_MAXTRUNC, (Word32 *) invTrfMatrix_fx, cdk1r_tr_midQ_truncQ_fx, fdcng_dct_scaleF_fx, FDCNG_VQ_DCT_NSEGM,
+ cdk1_ivas_cols_per_segment, cdk1_ivas_trunc_dct_cols_per_segment, cdk1_ivas_entries_per_segment, cdk1_ivas_cum_entries_per_segment, cdk_37bits_ivas_stage1_W8Qx_dct_sections,
+ stage1_dct_col_syn_shift, cdk1_ivas_segm_neighbour_fwd, cdk1_ivas_segm_neighbour_rev, FDCNG_VQ_DCT_NPOST, st1_mse_ptr_fx, indices_st1_local, st1_syn_vec_ptr_fx, dist_fx[1], &dist_e[1][0] );
+
+ /* move established stage#1 indices to the global MSVQ list structure */
+ set16_fx( dist_e[1], dist_e[1][0], maxC );
+ FOR( c = 0; c < maxC; c++ )
+ {
+ indices[1][c * stages] = indices_st1_local[c];
+ move16();
+ }
+ }
+ ELSE
+ {
+ FOR( j = 0; j < levels[s]; j++ )
+ {
+ /* Compute weighted codebook element and its energy */
+ en = 0;
+ move32();
+ en_e = 0;
+ move16();
+ W_acc = 0;
+ move64();
+ FOR( c2 = 0; c2 < n; c2++ )
+ {
+ Tmp[start + c2] = L_mult0( shl( w[start + c2], 2 ), cbp[c2] );
+ move32();
+ W_acc = W_mac_32_16( W_acc, Tmp[start + c2], cbp[c2] );
+ }
+
+ tmp_n = W_norm( W_acc );
+
+ en = W_extract_h( W_shl( W_acc, tmp_n ) );
+ en_e = sub( sub( 52, shl( Q_cb, 1 ) ), tmp_n );
+
+ cbp += maxn; /* pointer is incremented */
+
+ /* Iterate over all parent nodes */
+ FOR( c = 0; c < m; c++ )
+ {
+ pTmp = &resid_fx[0][c * N];
+ pTmp_e = resid_e;
+ move16();
+ /*tmp = (*pTmp++) * Tmp[0];*/
+ W_acc = W_mult_32_32( pTmp[0], Tmp[0] );
+
+ FOR( i = 1; i < N; i++ )
+ {
+ W_acc = W_mac_32_32( W_acc, pTmp[i], Tmp[i] );
+ }
+ tmp_n = W_norm( W_acc );
+ tmp = W_extract_h( W_shl( W_acc, tmp_n ) );
+ tmp_e = sub( add( pTmp_e, sub( Q31 - Q10, Q_cb ) ), tmp_n );
+
+
+ tmp_n = s_max( tmp_e, en_e );
+ tmp_n = s_max( dist_e[0][c], tmp_n );
+
+ IF( NE_16( dist_e[0][c], MAX_16 / 2 ) )
+ {
+ tmp_n = add( tmp_n, 2 );
+ tmp = L_sub( L_shl( en, sub( en_e, tmp_n ) ), L_shl( tmp, add( sub( tmp_e, tmp_n ), 1 ) ) );
+ tmp = L_add( tmp, L_shl( dist_fx[0][c], sub( dist_e[0][c], tmp_n ) ) );
+ }
+ ELSE
+ {
+ tmp = MAX_32 - 1;
+ move32();
+ tmp_n = MAX_16 / 2;
+ move32();
+ }
+
+ IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( tmp, tmp_n, dist_fx[1][p_max], dist_e[1][p_max] ), -1 ) )
+ {
+ /* Replace worst */
+ dist_fx[1][p_max] = tmp;
+ move32();
+ dist_e[1][p_max] = tmp_n;
+ move16();
+ indices[1][p_max * stages + s] = j;
+ move16();
+ parents[p_max] = c;
+ move16();
+
+ p_max = 0;
+ move16();
+ tmp_e = p_max;
+ move16();
+
+ tmp_n = dist_e[1][0];
+ move16();
+ FOR( c2 = 1; c2 < maxC; c2++ )
+ {
+ if ( EQ_16( BASOP_Util_Cmp_Mant32Exp( dist_fx[1][c2], dist_e[1][c2], dist_fx[1][p_max], dist_e[1][p_max] ), 1 ) )
+ {
+ p_max = c2;
+ move16();
+ }
+ test();
+ if ( GT_16( dist_e[1][c2], tmp_n ) && NE_16( dist_e[1][c2], MAX_16 / 2 ) )
+ {
+ tmp_n = dist_e[1][c2];
+ move16();
+ }
+ }
+ FOR( c2 = 0; c2 < maxC; c2++ )
+ {
+ IF( NE_16( dist_e[1][c2], MAX_16 / 2 ) )
+ {
+ dist_fx[1][c2] = L_shl( dist_fx[1][c2], sub( dist_e[1][c2], tmp_n ) );
+ move32();
+ dist_e[1][c2] = tmp_n;
+ move16();
+ }
+ }
+ } /*IF (L_sub(tmp,dist[1][p_max]) < 0) */
+ } /* FOR (c=0; chTcxEnc;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
#endif
test();
-#ifdef IVAS_CODE
- IF( EQ_32( st_fx->input_Fs, 32000 ) || EQ_32( st_fx->input_Fs, 48000 ) )
- {
- gain2_start = GAIN2_START_SWB;
- gain2_start_rs = GAIN2_START_SWB_RS;
- gain3_start = GAIN3_START_SWB;
- gain3_start_rs = GAIN3_START_SWB_RS;
- gain4_start = GAIN4_START_SWB;
- // gain4_start_rs = GAIN4_START_SWB_RS;
- H1_start = H1_START_SWB;
- H2_start = H2_START_SWB;
- H_length = H_LENGTH_SWB;
- move16();
- move16();
- move16();
- move16();
- move16();
- move16();
- }
- ELSE IF( EQ_32( st_fx->input_Fs, 16000 ) )
- {
- gain2_start = GAIN2_START_WB;
- gain2_start_rs = GAIN2_START_SWB_RS;
- gain3_start = GAIN3_START_WB;
- gain2_start_rs = GAIN2_START_SWB_RS;
- gain4_start = GAIN4_START_WB;
- H1_start = H1_START_WB;
- H2_start = H2_START_WB;
- H_length = H_LENGTH_WB;
- move16();
- move16();
- move16();
- move16();
- move16();
- move16();
- }
- ELSE
- {
- assert( !"Unknown sampling frequency in MDCT_classifier" );
- H1_start = -1; /* to avoid compilation warning */
- H2_start = -1; /* to avoid compilation warning */
- H_length = -1; /* to avoid compilation warning */
- gain2_start = -1; /* to avoid compilation warning */
- gain3_start = -1; /* to avoid compilation warning */
- gain4_start = -1; /* to avoid compilation warning */
- move16();
- move16();
- move16();
- move16();
- move16();
- move16();
- }
-#endif
-#ifdef IVAS_CODE
- if ( NE_16( st_fx->element_mode, IVAS_CPE_DFT ) )
-#endif
{
dft_mag_square_fx( fft_buff, magSq, 256 );
}
-#ifdef IVAS_CODE
- ELSE
- {
- float norm_val;
-
- norm_val = ( L_FFT * L_FFT ) / 4.f;
- for ( k = 0; k < 128; k++ )
- {
- X[k + 1] = st->Bin_E_old[k] * norm_val;
- }
- X[0] = X[1];
- }
-#endif
nf = L_add( magSq[0], 0 );
pe = L_add( magSq[0], 0 );
np = 0;
@@ -295,10 +222,7 @@ Word16 mdct_classifier_fx( /* o: MDCT A/B decision
gain1 = L_deposit_l( 0 );
gain2 = L_deposit_l( 0 );
gain3 = L_deposit_l( 0 );
-#ifdef IVAS_CODE
- PMT( "MDCT_classifier needs review for different sampling rate" )
-#endif
- // IVAS_CODE to adapt
+
FOR( k = 0; k < 8; k++ )
{
gain1 = L_add( gain1, L_shr( cldfbBuf_Ener[k], 3 ) );
diff --git a/lib_enc/mslvq_enc_fx.c b/lib_enc/mslvq_enc_fx.c
index 8f8dd4537e60c9085f7237e3bee200ad9c7b7d3b..4955dede80a4a7e57d285bebf54ec13d0fda2508 100644
--- a/lib_enc/mslvq_enc_fx.c
+++ b/lib_enc/mslvq_enc_fx.c
@@ -1221,10 +1221,10 @@ Word32 mslvq_ivas_16(
}
ELSE
{
- p_sigma = sigma_p_fx[mode];
+ p_sigma = sigma_p_ivas_fx[mode];
/* inverse sigma is precomputed to save complexity */
- p_inv_sigma = inv_sigma_p_fx[mode];
+ p_inv_sigma = inv_sigma_p_ivas_fx[mode];
p_scales = scales_p_ivas_fx[mode_glb];
diff --git a/lib_enc/nois_est_fx.c b/lib_enc/nois_est_fx.c
index d8131f10e9b1a8207a6c7ba8ddba6bdb41baccdd..676696fd6c8d33a518d5f27935486c0fd057e857 100644
--- a/lib_enc/nois_est_fx.c
+++ b/lib_enc/nois_est_fx.c
@@ -75,6 +75,20 @@ Word16 noise_est_AR1_Qx( /* o : Qx y(n) */
return mac_r( L_mult( y, alpham1 ), x, alpha );
}
+Word32 noise_est_AR1_Qx_32( /* o : Qx y(n) */
+ Word32 x, /* i : Qx x(n) */
+ Word32 y, /* i : Qx y(n-1) */
+ Word32 alpha /*i : Q15 scaling of driving x(n) */
+)
+{
+ Word32 alpham1;
+ /*alpham1 = negate(add((Word16)-32768, alpha)); */
+ alpham1 = L_sub( MAX_32, alpha ); /* one cycle less */
+ alpham1++;
+
+ return Madd_32_32( Mpy_32_32( y, alpham1 ), x, alpha );
+}
+
/*-----------------------------------------------------------------*
* noise_est_ln_q8_fx()
*
@@ -280,7 +294,7 @@ void noise_est_init_ivas_fx(
move32(); /*Q7//E_MIN; */
hNoiseEst->enrO_fx[i] = E_MIN_Q11_FX;
move32();
- hNoiseEst->bckr_fx[i] = E_MIN_Q11_FX;
+ hNoiseEst->bckr_fx[i] = E_MIN_Q27_FX;
move32();
hNoiseEst->ave_enr_fx[i] = E_MIN_Q11_FX;
move32();
@@ -289,14 +303,14 @@ void noise_est_init_ivas_fx(
move16(); /*1e-5f; */
hNoiseEst->q_enrO = Q11;
move16();
- hNoiseEst->q_bckr = Q11;
+ hNoiseEst->q_bckr = Q27;
move16();
hNoiseEst->ave_enr_q = Q11;
move16();
move16();
- hNoiseEst->totalNoise_fx = 0;
- move16();
+ hNoiseEst->totalNoise_32fx = 0;
+ move32();
hNoiseEst->first_noise_updt = 0;
move16();
hNoiseEst->first_noise_updt_cnt = 0;
@@ -358,16 +372,16 @@ void noise_est_init_ivas_fx(
move16();
hNoiseEst->Etot_lp_fx = 0;
hNoiseEst->Etot_h_fx = 0;
- hNoiseEst->Etot_l_fx = 0;
+ hNoiseEst->Etot_l_32fx = 0;
hNoiseEst->Etot_l_lp_32fx = 0;
hNoiseEst->Etot_last_32fx = 0;
- hNoiseEst->Etot_v_h2_fx = 0;
+ hNoiseEst->Etot_v_h2_32fx = 0;
hNoiseEst->sign_dyn_lp_fx = 0;
move16();
move16();
+ move32();
move16();
- move16();
- move16();
+ move32();
move32();
move32();
@@ -514,8 +528,8 @@ void noise_est_pre_32fx(
move32();
hNoiseEst->Etot_last_32fx = Etot; // Q24
move32();
- hNoiseEst->Etot_v_h2_fx = 0;
- move16();
+ hNoiseEst->Etot_v_h2_32fx = 0;
+ move32();
Etot_lp_32fx = Etot;
move32();
hNoiseEst->sign_dyn_lp_fx = 0;
@@ -528,7 +542,7 @@ void noise_est_pre_32fx(
Etot_h_32fx = L_sub( L_deposit_h( hNoiseEst->Etot_h_fx ), 671089 ); /* 671089=0.04 in Q24 */
Etot_h_32fx = L_max( Etot_h_32fx, Etot );
- Etot_l_32fx = L_add( L_deposit_h( hNoiseEst->Etot_l_fx ), 1342177 ); /* 1342177 = .08 in Q24 */
+ Etot_l_32fx = L_add( hNoiseEst->Etot_l_32fx, 1342177 ); /* 1342177 = .08 in Q24 */
/* Could even be higher but it also delays first entry to DTX */
IF( GT_16( hNoiseEst->harm_cor_cnt, HE_LT_CNT_PRE_FX ) )
@@ -590,10 +604,10 @@ void noise_est_pre_32fx(
move16();
}
- hNoiseEst->Etot_l_fx = extract_h( Etot_l_32fx ); // Q8
+ hNoiseEst->Etot_l_32fx = Etot_l_32fx; // Q24
hNoiseEst->Etot_h_fx = extract_h( Etot_h_32fx ); // Q8
hNoiseEst->Etot_lp_fx = extract_h( Etot_lp_32fx ); // Q8
- move16();
+ move32();
move16();
move16();
@@ -747,10 +761,10 @@ void noise_est_down_ivas_fx(
Word16 *q_enr,
const Word16 min_band, /* i : minimum critical band */
const Word16 max_band, /* i : maximum critical band */
- Word16 *totalNoise, /* o : noise estimate over all critical bands */
- Word32 Etot, /* i : Energy of current frame */
- Word32 *Etot_last, /* i/o: Energy of last frame Q8 */
- Word16 *Etot_v_h2 /* i/o: Energy variations of noise frames Q8 */
+ Word32 *totalNoise, /* o : noise estimate over all critical bands */
+ Word32 Etot, /* i : Energy of current frame Q24*/
+ Word32 *Etot_last, /* i/o: Energy of last frame Q24 */
+ Word32 *Etot_v_h2 /* i/o: Energy variations of noise frames Q24 */
)
{
@@ -773,7 +787,7 @@ void noise_est_down_ivas_fx(
L_Etot = Etot; /*Q24 for later AR1 computations*/
move32();
L_Etot_last = *Etot_last;
- L_Etot_v_h2 = L_shl( *Etot_v_h2, 16 );
+ L_Etot_v_h2 = *Etot_v_h2;
/*-----------------------------------------------------------------*
* Estimate total noise energy
@@ -803,8 +817,8 @@ void noise_est_down_ivas_fx(
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();
+ *totalNoise = ( Ltmp ); /*Q24*/
+ move32();
/*-----------------------------------------------------------------*
* Average energy per frame for each frequency band
@@ -901,7 +915,7 @@ void noise_est_down_ivas_fx(
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
+ *Etot_v_h2 = L_max( L_Etot_v_h2, 1677722 /* 0.1 in Q24*/ ); // Q24
move16();
return;
@@ -2207,13 +2221,13 @@ void noise_est_ivas_fx(
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 */
+ Word32 *non_staX, /* o : non-stationarity for sp/mus classifier Q20 */
Word16 *loc_harm, /* o : multi-harmonicity flag for UV classifier */
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 */
+ const Word32 Etot_v_h2, /* i : Energy variations Q24 */
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 *sp_floor, /* o : noise floor estimate Q7 */
@@ -2254,6 +2268,7 @@ void noise_est_ivas_fx(
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 */
+ Word32 L_tmp;
Word16 lim_Etot_fx; /* Q8 */
Word32 lim_Etot_sq_fx; /* Q16 */
@@ -2727,7 +2742,7 @@ void noise_est_ivas_fx(
Ltmp1 = Mpy_32_16_1( Ltmp1, 22713 ); // Q15
log_enr16 = round_fx( L_shl( Ltmp1, 9 ) ); /* Q8 */
wtmp = abs_s( sub( log_enr16, hSpMusClas->past_log_enr_fx[i - START_BAND_SPMUS] ) );
- *non_staX = add_o( *non_staX, wtmp, &Overflow );
+ *non_staX = L_add( *non_staX, wtmp );
move16(); /* Q8 */
hSpMusClas->past_log_enr_fx[i - START_BAND_SPMUS] = log_enr16;
move16();
@@ -2772,8 +2787,9 @@ void noise_est_ivas_fx(
}
}
- } /* end of band loop FOR( i = st_fx->min_band; i <= st_fx->max_band; i++ ) */
-
+ } /* end of band loop FOR( i = st_fx->min_band; i <= st_fx->max_band; i++ ) */
+ *non_staX = L_shl( *non_staX, 12 ); // Q20
+ move32();
IF( LT_16( Etot, -1280 /* -5.0f in Q8 */ ) )
{
non_sta = L_deposit_l( 1024 ); /* 1.0 in Q10 */
@@ -2973,7 +2989,7 @@ void noise_est_ivas_fx(
* long term extensions of frame features
*-----------------------------------------------------------------*/
- tmp = sub( Etot, hNoiseEst->totalNoise_fx ); /* Q8 */
+ tmp = sub( Etot, extract_h( hNoiseEst->totalNoise_32fx ) ); /* Q8 */
/* st->lt_tn_track = 0.03f* (Etot - st->totalNoise < 10) + 0.97f*st->lt_tn_track; */
tmp2 = 0;
move16();
@@ -3002,7 +3018,7 @@ void noise_est_ivas_fx(
} */
IF( *st_harm_cor_cnt == 0 )
{
- hNoiseEst->lt_haco_ev_fx = mac_r( 64424509 /* 0.03 in Q32*/, hNoiseEst->lt_haco_ev_fx, 31785 /* 0.97 in Q15*/ ); // Q15
+ hNoiseEst->lt_haco_ev_fx = mac_r( 64424509 /* 0.03 in Q31*/, hNoiseEst->lt_haco_ev_fx, 31785 /* 0.97 in Q15*/ ); // Q15
move16();
}
ELSE
@@ -3175,14 +3191,14 @@ void noise_est_ivas_fx(
haco_ev_max = s_max( tmp, hNoiseEst->lt_haco_ev_fx ); /* Q15 */
/* Etot_l_lp_thr = st->Etot_l_lp + (1.5f + 1.5f * (st->Etot_lp<50.0f))*st->Etot_v_h2; */
- tmp = 12288;
- move16(); /* 1.5 Q13 */
+ L_tmp = 49152; /* 1.5 Q15 */
+ move32();
if ( LT_16( hNoiseEst->Etot_lp_fx, 12800 ) ) /* 50.0 in Q8 */
{
- tmp = shl( tmp, 1 ); /*1.5 + 1.5 Q13 */
+ L_tmp = L_shl( L_tmp, 1 ); /*1.5 + 1.5 Q15 */
}
- Ltmp = hNoiseEst->Etot_l_lp_32fx;
- Etot_l_lp_thr = round_fx( L_add( Ltmp, L_shl( L_mult( tmp, Etot_v_h2 ), 2 ) ) ); /* Q13+Q8+1 +2 = Q24 -> Q8*/
+ temp = W_mac_32_32( W_mult_32_32( hNoiseEst->Etot_l_lp_32fx, ONE_IN_Q15 ), Etot_v_h2, L_tmp ); // Q40(24+15+1)
+ Etot_l_lp_thr = W_round32_s( temp ); // Q8
/* enr_bgd = Etot < Etot_l_lp_thr; */
enr_bgd = 0;
@@ -3366,8 +3382,8 @@ void noise_est_ivas_fx(
move16();
test();
test();
- if ( ( GT_16( hNoiseEst->sign_dyn_lp_fx, 15 * 256 ) ) /* 15 in Q8 */
- && ( LT_16( sub( Etot, extract_h( hNoiseEst->Etot_l_lp_32fx ) ), shl( Etot_v_h2, 1 ) ) ) /* Q8 , Etot_v_h2 has limited dynmics can be upscaled*/
+ if ( ( GT_16( hNoiseEst->sign_dyn_lp_fx, 15 * 256 ) ) /* 15 in Q8 */
+ && ( LT_32( L_sub( L_deposit_h( Etot ), hNoiseEst->Etot_l_lp_32fx ), L_shl( Etot_v_h2, 1 ) ) ) /* Q24 , Etot_v_h2 has limited dynmics can be upscaled*/
&& ( GT_16( *st_harm_cor_cnt, 20 ) ) )
{
sd1_bgd = 1;
@@ -3470,7 +3486,7 @@ void noise_est_ivas_fx(
test();
test();
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*/ ) ||
+ && LT_16( sub( Etot, extract_h( hNoiseEst->totalNoise_32fx ) ), 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 ) ) ) )
{
@@ -3493,7 +3509,7 @@ void noise_est_ivas_fx(
) */
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, 80 ) && GT_16( extract_h( hNoiseEst->totalNoise_32fx ), 5 * 256 /* 5.0 in Q8 */ ) && LT_16( Etot, s_max( 1 * 256, add( Etot_l_lp, extract_h( L_add( hNoiseEst->Etot_v_h2_32fx, L_shr( hNoiseEst->Etot_v_h2_32fx, 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;
@@ -3512,7 +3528,7 @@ void noise_est_ivas_fx(
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*/ ) ) ) )
+ ( ( tn_ini == 0 ) && LT_16( sub( Etot_l_lp, extract_h( hNoiseEst->totalNoise_32fx ) ), 10 * 256 /* 10.0 in Q8 */ ) && GT_16( non_staB, 8 * 256 /* 8.0 in in Q8*/ ) ) ) )
{
updt_step = 328;
move16(); /* 0.01 Q15 */
@@ -3542,7 +3558,7 @@ 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 /* 0.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_32fx > 0 ) )
{
updt_step = -655;
move16(); /* for debug purposes */
@@ -3559,14 +3575,14 @@ void noise_est_ivas_fx(
}
/*st->lt_aEn_zero = 0.2f * (st->aEn==0) + (1-0.2f) *st->lt_aEn_zero;*/
/* y(n+1)= alpha*tmp + (1-alpha)*y(n) */
- tmp = 0;
- move16();
+ L_tmp = 0;
+ move32();
if ( hNoiseEst->aEn == 0 )
{
- tmp = 6554; // 0.2 in Q15
- move16();
+ L_tmp = 429496730; // 0.2 in Q31
+ move32();
}
- hNoiseEst->lt_aEn_zero_fx = mac_r( tmp, hNoiseEst->lt_aEn_zero_fx, 26214 /* 0.8 in Q15*/ ); // Q15
+ hNoiseEst->lt_aEn_zero_fx = mac_r( L_tmp, hNoiseEst->lt_aEn_zero_fx, 26214 /* 0.8 in Q15*/ ); // Q15
move16();
IF( st_fx->element_mode > EVS_MONO )
diff --git a/lib_enc/pitch_ol2_fx.c b/lib_enc/pitch_ol2_fx.c
index 7ca13171ea309caea5710891b929962bcc6914b9..cbeea8f1dd818e825eb8d075f0d61df51ddd9215 100644
--- a/lib_enc/pitch_ol2_fx.c
+++ b/lib_enc/pitch_ol2_fx.c
@@ -36,7 +36,8 @@ void pitch_ol2_fx(
const Word16 pos, /* i : position in frame where to calculate the improv. */
const Word16 *wsp_fx,
/* i : weighted speech for current frame and look-ahead */ /*Q_new-1+shift*/
- const Word16 delta /* i : delta for pitch search (2 or 7) */
+ const Word16 delta, /* i : delta for pitch search (2 or 7) */
+ const Word16 element_mode /* i : EVS or IVAS */
)
{
Word16 i, t, step, fraction, t0_min, t0_max, t_min, t_max;
@@ -158,7 +159,14 @@ void pitch_ol2_fx(
IF( NE_32( t1, 1L ) )
{
- pred_lt4( pt_wsp_fx, wsp_fr_fx, t0s, fraction, L_SUBFR, pitch_inter4_1, 4, PIT_UP_SAMP );
+ IF( element_mode != EVS_MONO )
+ {
+ pred_lt4_ivas_fx( pt_wsp_fx, wsp_fr_fx, t0s, fraction, L_SUBFR, L_pitch_inter4_1, 4, PIT_UP_SAMP );
+ }
+ ELSE
+ {
+ pred_lt4( pt_wsp_fx, wsp_fr_fx, t0s, fraction, L_SUBFR, pitch_inter4_1, 4, PIT_UP_SAMP );
+ }
R0 = cor_max_fx;
move16();
diff --git a/lib_enc/pitch_ol_fx.c b/lib_enc/pitch_ol_fx.c
index 91181714af9242f49697b8f221c167f31d525faf..79c55821e723e62585ce2df46f29b494b6ddfef0 100644
--- a/lib_enc/pitch_ol_fx.c
+++ b/lib_enc/pitch_ol_fx.c
@@ -1686,13 +1686,17 @@ void pitch_ol_ivas_fx(
move16();
/* enr1 = dotp( pt2, pt2, len[j] ) + 0.01f; */
- temp = 167772 /*0.01f in Q24*/;
+ temp = 0;
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
+
+ temp = W_add( temp, 167772 ); /*0.01f in 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)
@@ -1724,13 +1728,18 @@ void pitch_ol_ivas_fx(
move16();
/* enr1 = dotp(pt4, pt4, len1[j]) + 0.01f; */
- temp = 167772 /*0.01f in Q24*/;
+ temp = 0;
+ move64();
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
+
+ temp = W_add( temp, 167772 ); /*0.01f in 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)
@@ -2416,8 +2425,8 @@ void pitchDoubling_det_fx(
IF( GE_16( T, PIT_MIN_12k8 ) )
{
- pitch_ol2_fx( PIT_MIN_SHORTER, T, &( new_op_fr[0] ), &new_voicing[0], 0, wspeech, 2 );
- pitch_ol2_fx( PIT_MIN_SHORTER, T, &( new_op_fr[1] ), &new_voicing[1], L_SUBFR, wspeech, 2 );
+ pitch_ol2_fx( PIT_MIN_SHORTER, T, &( new_op_fr[0] ), &new_voicing[0], 0, wspeech, 2, EVS_MONO );
+ pitch_ol2_fx( PIT_MIN_SHORTER, T, &( new_op_fr[1] ), &new_voicing[1], L_SUBFR, wspeech, 2, EVS_MONO );
/* IF(sub(add(new_voicing[0],new_voicing[1]),add(voicing_fr[0],voicing_fr[1]))>0 */
IF( L_msu( L_msu( L_mac( L_mult( new_voicing[0], 8192 ), new_voicing[1], 8192 ), voicing_fr[0], 8192 ), voicing_fr[1], 8192 ) > 0 )
{
@@ -2439,8 +2448,8 @@ void pitchDoubling_det_fx(
IF( GE_16( T, PIT_MIN_12k8 ) )
{
- pitch_ol2_fx( PIT_MIN_SHORTER, T, &( new_op_fr[0] ), &new_voicing[0], 2 * L_SUBFR, wspeech, 2 );
- pitch_ol2_fx( PIT_MIN_SHORTER, T, &( new_op_fr[1] ), &new_voicing[1], 3 * L_SUBFR, wspeech, 2 );
+ pitch_ol2_fx( PIT_MIN_SHORTER, T, &( new_op_fr[0] ), &new_voicing[0], 2 * L_SUBFR, wspeech, 2, EVS_MONO );
+ pitch_ol2_fx( PIT_MIN_SHORTER, T, &( new_op_fr[1] ), &new_voicing[1], 3 * L_SUBFR, wspeech, 2, EVS_MONO );
/* IF(sub(add(new_voicing[0],new_voicing[1]),add(voicing_fr[2],voicing_fr[3]))>0) */
IF( L_msu( L_msu( L_mac( L_mult( new_voicing[0], 8192 ), new_voicing[1], 8192 ), voicing_fr[2], 8192 ), voicing_fr[3], 8192 ) > 0 )
{
diff --git a/lib_enc/pre_proc_fx.c b/lib_enc/pre_proc_fx.c
index e8d4a072251e13f9a3cc95c6c33dc51dda43d0cf..dc3ec020ab1959c1ecaefabc9bea1dcbbb366f43 100644
--- a/lib_enc/pre_proc_fx.c
+++ b/lib_enc/pre_proc_fx.c
@@ -414,11 +414,7 @@ void pre_proc_fx(
alw_voicing[1] = st->voicing_fx[2];
move16();
-#ifdef REMOVE_EVS_DUPLICATES
- analy_lp_ivas_fx( inp_12k8, L_FRAME, L_look, ener, A, epsP_h, epsP_l, lsp_new, lsp_mid, st->lsp_old1_fx, alw_pitch_lag_12k8, alw_voicing, INT_FS_12k8, EVS_MONO, 0, *Q_new, Q_r );
-#else
- analy_lp_fx( inp_12k8, L_FRAME, L_look, ener, A, epsP_h, epsP_l, lsp_new, lsp_mid, st->lsp_old1_fx, alw_pitch_lag_12k8, alw_voicing, INT_FS_12k8, -1 /*IVAS_CODE !! LowRateFlag*/, *Q_new, Q_r );
-#endif
+ analy_lp_fx( inp_12k8, L_FRAME, L_look, ener, A, epsP_h, epsP_l, lsp_new, lsp_mid, st->lsp_old1_fx, alw_pitch_lag_12k8, alw_voicing, INT_FS_12k8, EVS_MONO, 0, *Q_new, Q_r );
lsp2lsf_fx( lsp_new, lsf_new, M, INT_FS_12k8 );
stab_fac = lsf_stab_fx( lsf_new, st->lsf_old1_fx, 0, L_FRAME );
@@ -462,10 +458,10 @@ void pre_proc_fx(
IF( LE_32( st->total_brate, ACELP_24k40 ) )
{
/* 1/4 pitch precision improvement */
- pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[0], &pitch_fr[0], &voicing_fr[0], 0, wsp, 7 );
- pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[0], &pitch_fr[1], &voicing_fr[1], L_SUBFR, wsp, 7 );
- pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[1], &pitch_fr[2], &voicing_fr[2], 2 * L_SUBFR, wsp, 7 );
- pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[1], &pitch_fr[3], &voicing_fr[3], 3 * L_SUBFR, wsp, 7 );
+ pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[0], &pitch_fr[0], &voicing_fr[0], 0, wsp, 7, EVS_MONO );
+ pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[0], &pitch_fr[1], &voicing_fr[1], L_SUBFR, wsp, 7, EVS_MONO );
+ pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[1], &pitch_fr[2], &voicing_fr[2], 2 * L_SUBFR, wsp, 7, EVS_MONO );
+ pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[1], &pitch_fr[3], &voicing_fr[3], 3 * L_SUBFR, wsp, 7, EVS_MONO );
}
ELSE
{
@@ -1131,11 +1127,7 @@ void pre_proc_fx(
Copy( st->lsp_old1_fx, st->lspold_enc_fx, M );
}
-#ifdef REMOVE_EVS_DUPLICATES
- analy_lp_ivas_fx( inp_16k, L_FRAME16k, L_look, ener, A, epsP_h, epsP_l, lsp_new, lsp_mid, st->lspold_enc_fx, st->pitch, st->voicing_fx, 16000, EVS_MONO, 0, *Q_new, Q_r );
-#else
- analy_lp_fx( inp_16k, L_FRAME16k, L_look, ener, A, epsP_h, epsP_l, lsp_new, lsp_mid, st->lspold_enc_fx, st->pitch, st->voicing_fx, 16000, -1 /*IVAS_CODE !! LowRateFlag*/, *Q_new, Q_r );
-#endif
+ analy_lp_fx( inp_16k, L_FRAME16k, L_look, ener, A, epsP_h, epsP_l, lsp_new, lsp_mid, st->lspold_enc_fx, st->pitch, st->voicing_fx, 16000, EVS_MONO, 0, *Q_new, Q_r );
/*--------------------------------------------------------------*
* Compute Weighted Input
diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h
index 4237aa9c3ab398dd1fa23058653550ead36bf8c9..dcdce25b67794782c84487949f5c69f24e4b41ca 100644
--- a/lib_enc/prot_fx_enc.h
+++ b/lib_enc/prot_fx_enc.h
@@ -41,9 +41,8 @@
#include "ivas_error_utils.h"
#include "complex_basop.h"
#include "ivas_stat_enc.h"
-/*----------------------------------------------------------------------------------*
- * Prototypes of RAM counting tool macros
- *----------------------------------------------------------------------------------*/
+
+
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 Q_new*/
@@ -62,63 +61,42 @@ ivas_error acelp_core_enc_fx(
Word16 pitch_buf_fx[NB_SUBFR16k], /* o : floating pitch for each subframe Q6*/
Word16 *unbits_fx, /* o : number of unused bits Q0*/
STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder handle */
- const float tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */
const Word16 Q_new,
const Word16 shift
);
-void analy_lp_ivas_fx(
- const Word16 speech[], /* i :(Q_new) pointer to the speech frame */
- const Word16 L_frame, /* i :(q0) length of the frame */
- const Word16 L_look, /* i :(q0) look-ahead */
- Word32 *ener, /* o :(Q_r) residual energy from Levinson-Durbin */
- Word16 A[], /* o :(q14) A(z) filter coefficients */
- Word16 epsP_h[], /* o :(high part of epsP(Q_r)) LP analysis residual energies for each iteration */
- Word16 epsP_l[], /* o :(low part of epsP(Q_r)) LP analysis residual energies for each iteration */
- Word16 lsp_new[], /* o :(q15) current frame LSPs */
- Word16 lsp_mid[], /* o :(q15) current mid-frame LSPs */
- Word16 lsp_old[], /* i/o:(q15) previous frame unquantized LSPs */
- const Word16 Top[2], /* i :(q0) open loop pitch lag */
- const Word16 Tnc[2], /* i :(q15) open loop pitch gain */
- const Word32 Core_sr, /* i :(q0) Internal core sampling rate */
-#ifdef REMOVE_EVS_DUPLICATES
- const Word16 element_mode, /* i : element mode */
-#endif
- const Word16 sec_chan_low_rate, /* i :(q0) flag to signal second channel */
- Word16 Q_new, /*i: stores Q for speech*/
- Word16 *Q_r /*stores q for ener*/ );
-
-#ifndef REMOVE_EVS_DUPLICATES
void analy_lp_fx(
- 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 );
-#endif
-
-void AVQ_cod_fx( /* o: comfort noise gain factor */
- const Word16 xri[], /* i: vector to quantize */
- 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) */
- const Word16 Q_in_ref /* i: Scaling i */
+ const Word16 speech[], /* i :(Q_new) pointer to the speech frame */
+ const Word16 L_frame, /* i :(q0) length of the frame */
+ const Word16 L_look, /* i :(q0) look-ahead */
+ Word32 *ener, /* o :(Q_r) residual energy from Levinson-Durbin */
+ Word16 A[], /* o :(q14) A(z) filter coefficients */
+ Word16 epsP_h[], /* o :(high part of epsP(Q_r)) LP analysis residual energies for each iteration */
+ Word16 epsP_l[], /* o :(low part of epsP(Q_r)) LP analysis residual energies for each iteration */
+ Word16 lsp_new[], /* o :(q15) current frame LSPs */
+ Word16 lsp_mid[], /* o :(q15) current mid-frame LSPs */
+ Word16 lsp_old[], /* i/o:(q15) previous frame unquantized LSPs */
+ const Word16 Top[2], /* i :(q0) open loop pitch lag */
+ const Word16 Tnc[2], /* i :(q15) open loop pitch gain */
+ const Word32 Core_sr, /* i :(q0) Internal core sampling rate */
+ const Word16 element_mode, /* i : element mode */
+ const Word16 sec_chan_low_rate, /* i :(q0) flag to signal second channel */
+ Word16 Q_new, /* i : stores Q for speech */
+ Word16 *Q_r /*stores q for ener*/
+);
+
+/*1 r: comfort noise gain factor */
+void AVQ_cod_fx(
+ const Word16 xri[], /* i: vector to quantize */
+ 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) */
+ const Word16 Q_in_ref /* i: Scaling i */
);
void AVQ_encmux_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
+ BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
const Word16 extl, /* i : extension layer */
Word16 xriq[], /* i/o: rounded subvectors [0..8*Nsv-1] followed
by rounded bit allocations [8*Nsv..8*Nsv+Nsv-1] */
@@ -130,7 +108,7 @@ void AVQ_encmux_fx(
);
void AVQ_encmux_ivas_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
+ BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
const Word16 extl, /* i : extension layer */
Word16 xriq[], /* i/o: rounded subvectors [0..8*Nsv-1] followed
by rounded bit allocations [8*Nsv..8*Nsv+Nsv-1] */
@@ -151,15 +129,15 @@ void bw_detect_fx(
const Word16 mct_on, /* i : flag MCT mode */
const Word16 Q_spec );
-void core_switching_post_enc_fx( /*done */
- Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word16 inp12k8[], /* i : i signal @12.8 kHz Qinp*/
- const Word16 inp16k[], /* i : i signal @16 kHz Qinp*/
- const Word16 A[], /* i : unquant. LP filter coefs. (Q12) */
- Word16 Qshift,
- Word16 Q_new,
- const Word16 Qsp, /* i/o : Q from acelp synthsis */
- Word16 *Qmus /* i/o : Q from mdct synthsis / Q of output synthesis */
+void core_switching_post_enc_fx(
+ Encoder_State *st_fx, /* i/o: encoder state structure */
+ const Word16 inp12k8[], /* i : i signal @12.8 kHz Qinp*/
+ const Word16 inp16k[], /* i : i signal @16 kHz Qinp*/
+ const Word16 A[], /* i : unquant. LP filter coefs. (Q12) */
+ Word16 Qshift,
+ Word16 Q_new,
+ const Word16 Qsp, /* i/o : Q from acelp synthsis */
+ Word16 *Qmus /* i/o : Q from mdct synthsis / Q of output synthesis */
);
void core_switching_pre_enc_fx(
@@ -170,8 +148,9 @@ void core_switching_pre_enc_fx(
const Word16 last_element_mode /* i : last_element_mode Q0*/
);
-Word16 correlation_shift_fx( /* o : noise dependent voicing correction Q15 */
- const Word16 totalNoise_fx /* i/o: noise estimate over all critical bands Q8 */
+/*! r: noise dependent voicing correction Q15 */
+Word16 correlation_shift_fx(
+ const Word16 totalNoise_fx /* i/o: noise estimate over all critical bands Q8 */
);
void dtx_fx(
@@ -325,7 +304,7 @@ void long_enr_fx(
Word16 high_lpn_flag );
void ivas_long_enr_fx(
Encoder_State *st_fx, /* i/o: state structure */
- const Word16 Etot, /* i : total channel E (see lib_enc\analy_sp.c) Q=8*/
+ const Word32 Etot, /* i : total channel E (see lib_enc\analy_sp.c) Q=24*/
const Word16 localVAD_HE_SAD, /* i : HE-SAD flag without hangover */
Word16 high_lpn_flag, /* i : sp/mus LPN flag */
FRONT_VAD_ENC_HANDLE hFrontVad[], /* i/o: front-VAD handles */
@@ -368,10 +347,10 @@ void noise_est_down_ivas_fx(
Word16 *q_enr,
const Word16 min_band, /* i : minimum critical band */
const Word16 max_band, /* i : maximum critical band */
- Word16 *totalNoise, /* o : noise estimate over all critical bands */
- Word32 Etot, /* i : Energy of current frame */
- Word32 *Etot_last, /* i/o: Energy of last frame Q8 */
- Word16 *Etot_v_h2 /* i/o: Energy variations of noise frames Q8 */
+ Word32 *totalNoise, /* o : noise estimate over all critical bands */
+ Word32 Etot, /* i : Energy of current frame Q24*/
+ Word32 *Etot_last, /* i/o: Energy of last frame Q24 */
+ Word32 *Etot_v_h2 /* i/o: Energy variations of noise frames Q24 */
);
void noise_est_fx(
@@ -419,13 +398,13 @@ void noise_est_ivas_fx(
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 */
+ Word32 *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_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 */
+ const Word32 Etot_v_h2, /* i : Energy variations Q24 */
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 *sp_floor, /* o : noise floor estimate Q7 */
@@ -458,13 +437,14 @@ void pitch_ol2_fx(
const Word16 pit_min, /* i : minimum pitch value (20 or 29) */
const Word16 pitch_ol, /* i : pitch to be improved */
Word16 *pitch_fr_fx,
- /* o : adjusted 1/4 fractional pitch */ /*Q7 */
+ /* o : adjusted 1/4 fractional pitch */ /*Q7*/
Word16 *voicing_fr_fx,
- /* o : adjusted 1/4 fractional voicing */ /*Q15 */
+ /* o : adjusted 1/4 fractional voicing */ /*Q15*/
const Word16 pos, /* i : position in frame where to calculate the improv. */
const Word16 *wsp_fx,
/* i : weighted speech for current frame and look-ahead */ /*Q_new-1+shift*/
- const Word16 delta /* i : delta for pitch search (2 or 7) */
+ const Word16 delta, /* i : delta for pitch search (2 or 7) */
+ const Word16 element_mode /* i : EVS or IVAS */
);
void pitch_ol_ivas_fx(
@@ -570,6 +550,15 @@ Word16 signal_clas_fx( /* o : classification for current
Word16 *uc_clas /* o : temporary classification used in music/speech class*/
);
+Word16 signal_clas_ivas_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 L_look, /* i : look-ahead */
+ Word16 *uc_clas /* o : temporary classification used in music/speech class*/
+);
+
void speech_music_classif_fx(
Encoder_State *st, /* i/o: state structure */
const Word16 *new_inp, /* i : new input signal */
@@ -639,6 +628,7 @@ void swb_bwe_enc_ivas_fx(
Word16 *old_input_16k_fx, /* i : input signal @16kHz for SWB BWE */
const Word16 *old_syn_12k8_16k_fx, /* i : ACELP core synthesis at 12.8kHz or 16kHz */
const Word16 *new_swb_speech_fx, /* i : original input signal at 32kHz */
+ const Word16 Q_new_swb_speech, /* i : Q for new_swb_speech_fx */
Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz */
Word16 Q_shb_speech,
Word16 Q_slb_speech );
@@ -2199,7 +2189,7 @@ void stat_noise_uv_enc_ivas_fx(
Word16 *Aq, /* i : A(z) quantized for the 4 subframes Q=12 */
Word16 *exc2, /* i/o: excitation buffer Q=Q_stat_noise */
const Word16 uc_two_stage_flag, /* o : flag undicating two-stage UC */
- Word16 Q_new );
+ Word16 *Q_new );
void analy_sp_fx(
const Word16 element_mode, /* i : element mode */
@@ -2324,22 +2314,8 @@ void find_targets_fx(
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 Q0*/
- Word16 *mem_w0, /* i/o: weighting filter denominator memory Q_new-1*/
- const Word16 *p_Aq, /* i : interpolated quantized A(z) filter Q12*/
- const Word16 *res, /* i : residual signal Q_new*/
- const Word16 L_subfr, /* i : length of vectors for gain quantization Q0*/
- const Word16 *Ap, /* i : unquantized A(z) filter with bandwidth expansion Q12*/
- Word16 tilt_fac, /* i : tilt factor Q15*/
- Word16 *xn, /* o : Close-loop Pitch search target vector Q_new-1*/
- Word16 *cn, /* o : target vector in residual domain Q_new*/
- Word16 *h1 /* o : impulse response of weighted synthesis filter Q(14 - norm_s(h1[0]))*/
-);
-void find_targets_ivas_new_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 Q0*/
@@ -3066,6 +3042,13 @@ Word16 IGF_getCrest( /**< out: Q15| crest factor
const Word16 start, /**< in: Q0 | start subband index */
const Word16 stop /**< in: Q0 | stop subband index */
);
+Word16 IGF_getCrest_ivas( /**< out: Q15| crest factor */
+ Word16 *crest_exp, /**< out: | exponent of crest factor */
+ const Word32 *powerSpectrum, /**< in: Q31 | power spectrum */
+ const Word16 *powerSpectrum_exp, /**< in: | exponent of power spectrum */
+ const Word16 start, /**< in: Q0 | start subband index */
+ const Word16 stop /**< in: Q0 | stop subband index */
+);
Word16 IGF_getSFM( /**< out: Q15| SFM value */
Word16 *SFM_exp, /**< out: | exponent of SFM Factor */
const Word32 *energy, /**< in: Q31| energies */
@@ -4490,6 +4473,13 @@ Word16 noise_est_AR1_Qx( /* o: Qx y(n) */
Word16 y, /* i : Qx y(n-1) */
Word16 alpha /*i : Q15 scaling of driving x(n) */
);
+
+Word32 noise_est_AR1_Qx_32( /* o: Qx y(n) */
+ Word32 x, /* i : Qx x(n) */
+ Word32 y, /* i : Qx y(n-1) */
+ Word32 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 Qlog2(2.56)*/
@@ -4833,5 +4823,9 @@ ivas_error write_indices_ivas_fx(
Encoder_Struct *st_ivas, /* i/o: encoder state structure */
UWord16 *bit_stream, /* i/o: output bitstream */
UWord16 *num_bits /* i : number of indices written to output */
+#ifdef DBG_BITSTREAM_ANALYSIS
+ ,
+ int32_t frame
+#endif
);
#endif
diff --git a/lib_enc/rom_enc.h b/lib_enc/rom_enc.h
index 35fd3027d58538bd9b81b5120e1530337cbd9060..7da1da92a8b6ee4f7c4de48692af7927ec4ce9ca 100644
--- a/lib_enc/rom_enc.h
+++ b/lib_enc/rom_enc.h
@@ -52,7 +52,6 @@ extern const Word16 W_HIST_S_FX[DTX_HIST_SIZE]; /* CNG & DTX - table for calcula
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
diff --git a/lib_enc/rom_enc.c b/lib_enc/rom_enc_fx.c
similarity index 100%
rename from lib_enc/rom_enc.c
rename to lib_enc/rom_enc_fx.c
diff --git a/lib_enc/set_impulse_fx.c b/lib_enc/set_impulse_fx.c
index 9ad5f4a2cdb9a4bab773a1008a6b70cb948771af..d4dd73abe8ea2be7536ea15ce15c6270737b279f 100644
--- a/lib_enc/set_impulse_fx.c
+++ b/lib_enc/set_impulse_fx.c
@@ -285,10 +285,10 @@ static void convolve_tc_fx(
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] ); /* Qx + 16 */
+ L_sum = L_mac_sat( L_sum, g[i], h[n - i] ); /* Qx + 16 */
}
- y[n] = round_fx( L_sum ); /* Qx */
+ y[n] = round_fx_sat( L_sum ); /* Qx */
}
}
/*-------------------------------------------------------------------*
diff --git a/lib_enc/sig_clas_fx.c b/lib_enc/sig_clas_fx.c
index cf5d31d22001c277a70040332e8c73383e4be02a..beb97514a0d139e512f3936143a461e75d89de6e 100644
--- a/lib_enc/sig_clas_fx.c
+++ b/lib_enc/sig_clas_fx.c
@@ -100,7 +100,238 @@ Word16 signal_clas_fx( /* o : classification for current
een = round_fx( L_shl( Ltmp, 16 - 5 ) ); /* Q14 -> Q9 */
een = mac_r( C_EE_FX, een, K_EE_FX );
}
+ /* compute zero crossing rate */
+ 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++ )
+ {
+ tmp16 = add( 1, tmpS );
+ pt1++;
+ tmpS = shr( *pt1, 15 ); /* pt1 >=0 ---> 0 OTHERWISE -1 */
+ Ltmp = L_msu0( Ltmp, tmpS, tmp16 );
+ }
+ zc = extract_l( Ltmp );
+
+ /* 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
+ *-----------------------------------------------------------------*/
+
+ /* corn = K_COR * mean_voi2 + C_COR */
+ Ltmp = L_mult( C_COR_FX, 32767 );
+ corn = round_fx( L_shl( L_mac( Ltmp, mean_voi2, K_COR_FX ), -4 ) ); /*Q13+Q13*Q15 =>Q13->Q9*/
+ /* Limit [0, 1] */
+ corn = s_max( corn, 0 );
+ corn = s_min( corn, 512 );
+
+ Ltmp = L_mult( C_ZC_FX, 4 ); /*Q13*Q2 -> Q16*/
+ zcn = round_fx( L_shl( L_mac( Ltmp, zc, K_ZC_FX ), 16 - 7 ) ); /*Q0*Q15 + Q16*/
+ /* Limit [0, 1] */
+ zcn = s_max( zcn, 0 );
+ zcn = s_min( zcn, 512 );
+
+ 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 );
+ relEn = s_min( relEn, 512 );
+
+ Ltmp = L_mult( C_PC_FX, 2 ); /*Q14*Q1 -> Q16*/
+ pcn = round_fx( L_shl( L_mac( Ltmp, pc, K_PC_FX ), 16 - 7 ) ); /*Q16 + Q0*Q15*/
+ /* Limit [0, 1] */
+ pcn = s_max( pcn, 0 );
+ pcn = s_min( pcn, 512 );
+
+ Ltmp = L_mult( een, 10923 );
+ Ltmp = L_mac( Ltmp, corn, 21845 );
+ Ltmp = L_mac( Ltmp, zcn, 10923 );
+ Ltmp = L_mac( Ltmp, relEn, 10923 );
+ Ltmp = L_mac( Ltmp, pcn, 10923 );
+
+ fmerit1 = round_fx_o( L_shl_o( Ltmp, 16 - 10 - 1, &Overflow ), &Overflow ); /* fmerit1 ->Q15 */
+
+ /*-----------------------------------------------------------------*
+ * FEC classification
+ *-----------------------------------------------------------------*/
+
+ st->fmerit_dt = sub( st->prev_fmerit, fmerit1 ); /*Q15*/
+ move16();
+ st->prev_fmerit = fmerit1;
+ move16();
+ /* FEC classification */
+ test();
+ test();
+ IF( st->localVAD == 0 || EQ_16( st->coder_type, UNVOICED ) || LT_16( relE, -1536 ) )
+ {
+ clas = UNVOICED_CLAS;
+ *clas_mod = clas;
+ move16();
+ move16();
+ }
+ ELSE
+ {
+ SWITCH( st->last_clas )
+ {
+ case VOICED_CLAS:
+ case ONSET:
+ case VOICED_TRANSITION:
+
+ IF( LT_16( fmerit1, 16056 ) ) /*0.49f*/
+ {
+ clas = UNVOICED_CLAS;
+ move16();
+ }
+ ELSE IF( LT_16( fmerit1, 21626 ) ) /*0.66*/
+ {
+ clas = VOICED_TRANSITION;
+ move16();
+ }
+ ELSE
+ {
+ clas = VOICED_CLAS;
+ move16();
+ }
+ IF( LT_16( fmerit1, 14745 /* 0.45f*/ ) )
+ {
+ *clas_mod = UNVOICED_CLAS;
+ move16();
+ }
+ ELSE IF( LT_16( fmerit1, 21626 /* 0.66f*/ ) )
+ {
+ *clas_mod = VOICED_TRANSITION;
+ move16();
+ }
+ ELSE
+ {
+ *clas_mod = VOICED_CLAS;
+ move16();
+ }
+ BREAK;
+
+ case UNVOICED_CLAS:
+ case UNVOICED_TRANSITION:
+ IF( GT_16( fmerit1, 20643 ) ) /*0.63*/
+ {
+ clas = ONSET;
+ move16();
+ }
+ ELSE IF( GT_16( fmerit1, 19169 ) ) /*0.585*/
+ {
+ clas = UNVOICED_TRANSITION;
+ move16();
+ }
+ ELSE
+ {
+ clas = UNVOICED_CLAS;
+ move16();
+ }
+ *clas_mod = clas;
+ move16();
+
+ BREAK;
+
+ default:
+ clas = UNVOICED_CLAS;
+ *clas_mod = clas;
+ move16();
+ move16();
+ BREAK;
+ }
+ }
+ /* Onset classification */
+
+ /* tc_cnt == -1: frame after TC frame in continuous block of GC/VC frames */
+ /* tc_cnt == 0: UC frame */
+ /* 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 ( clas == 0 )
+ {
+ st->tc_cnt = 0;
+ move16();
+ }
+
+ test();
+ IF( GE_16( clas, VOICED_TRANSITION ) && st->tc_cnt >= 0 )
+ {
+ st->tc_cnt = add( st->tc_cnt, 1 );
+ move16();
+ }
+
+ if ( GT_16( st->tc_cnt, 2 ) )
+ {
+ st->tc_cnt = -1;
+ move16();
+ }
+ return clas;
+}
+
+Word16 signal_clas_ivas_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 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 */
+)
+{
+ Word32 Ltmp;
+ Word16 mean_voi2, een, corn, zcn, relEn, pcn, fmerit1;
+ Word16 i, clas, pc, zc, exp_ee;
+ Word16 tmp16, tmpS;
+ const Word16 *pt1;
+ Word64 tmp64;
+#ifdef BASOP_NOGLOB_DECLARE_LOCAL
+ Flag Overflow = 0;
+ move32();
+#endif
+
+ /*----------------------------------------------------------------*
+ * Calculate average voicing
+ * Calculate average spectral tilt
+ * Calculate zero-crossing rate
+ * Calculate pitch stability
+ *----------------------------------------------------------------*/
+
+ /* average voicing on second half-frame and look-ahead */
+ 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 */
+ tmp64 = W_mult0_32_32( ee[0], ee[1] );
+ exp_ee = W_norm( tmp64 );
+ Ltmp = W_extract_h( W_shl( tmp64, exp_ee ) ); // Q = Q6+Q6 + exp_ee - 32
+ exp_ee = sub( 31, sub( add( Q12, exp_ee ), 32 ) );
+ IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( Ltmp, exp_ee, ONE_IN_Q31, 0 ), -1 ) )
+ {
+ een = 0;
+ move16();
+ }
+ ELSE
+ {
+ /* mean_ee2 = 0.5f * 20.0f * (float)log10( tmp ); */
+ /* een = K_EE_ENC * mean_ee2 + C_EE_ENC; */
+ Ltmp = BASOP_Util_Log10( Ltmp, exp_ee ); // Q25
+ Ltmp = Mpy_32_32( Ltmp, 671088640 /*20.f in Q25*/ ); // Q25 + Q25 -Q31 = Q19 * 0.5 = Q20
+ een = extract_l( L_shl( Mpy_32_16_1( Ltmp, K_EE_FX ), Q9 - Q20 ) ); // Q9
+
+ IF( GT_16( een, 512 ) )
+ {
+ een = 512;
+ move16();
+ }
+ ELSE IF( een < 0 )
+ {
+ een = 0;
+ move16();
+ }
+ }
/* compute zero crossing rate */
pt1 = speech + sub( L_look, 1 );
tmpS = shr( *pt1, 15 ); /* sets 'tmpS to -1 if *pt1 < 0 */
@@ -272,6 +503,7 @@ Word16 signal_clas_fx( /* o : classification for current
}
return clas;
}
+
/*-------------------------------------------------------------------*
* select_TC_fx()
*
diff --git a/lib_enc/speech_music_classif_fx.c b/lib_enc/speech_music_classif_fx.c
index 65000a7b3f444acf3256676c1840db27129c5681..fd983741b51cf4319722c01fbbcee140e09a95c5 100644
--- a/lib_enc/speech_music_classif_fx.c
+++ b/lib_enc/speech_music_classif_fx.c
@@ -1588,7 +1588,7 @@ Word16 ivas_smc_gmm_fx(
const Word16 cor_map_sum_fx, /* i : correlation map sum (from multi-harmonic anal.) Q8 */
const Word32 epsP_fx[M + 1], /* i : LP prediciton error */
const Word32 PS_fx[], /* i : energy spectrum */
- const Word16 non_sta_fx, /* i : unbound non-stationarity Q8 */
+ const Word32 non_sta_fx, /* i : unbound non-stationarity Q20 */
const Word16 relE_fx, /* i : relative frame energy Q8 */
Word16 *high_lpn_flag, /* i/o: sp/mus LPN flag */
const Word16 flag_spitch, /* i : flag to indicate very short stable pitch */
@@ -1879,7 +1879,7 @@ Word16 ivas_smc_gmm_fx(
move32();
/* [8] non_sta */
- *pFV_fx++ = L_shl( non_sta_fx, Q12 ); /*scaling from Q8 to Q20*/
+ *pFV_fx++ = non_sta_fx; /*Q20*/
move32();
/* [9] epsP */
@@ -2612,7 +2612,7 @@ static Word16 attack_det_ivas_fx( /* o : attack flag
Word16 *last_strong_attack /* i/o: last strong attack flag */
)
{
- Word16 i, j, tmp, tmp1, attack, exp1;
+ Word16 i, j, tmp, tmp1, attack, exp1, etmp_e, etmp2_e, s;
Word32 L_tmp, etmp, etmp2, finc[ATT_NSEG], mean_finc;
Word16 att_3lsub_pos;
Word16 attack1;
@@ -2665,29 +2665,42 @@ 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) */
- L_tmp = L_shr_o( finc[0], Qx, &Overflow ); /*Qx */
-
- FOR( i = 1; i < att_3lsub_pos; i++ )
+ W_tmp = 0;
+ move64();
+ FOR( i = 0; i < att_3lsub_pos; i++ )
{
- L_tmp = L_add_o( L_tmp, L_shr_o( finc[i], Qx, &Overflow ), &Overflow ); /*Qx */
+ W_tmp = W_add( W_tmp, finc[i] ); /* *q_ finc_prev */
}
- L_tmp = Mult_32_16( L_tmp, tmp ); /*Q(14-exp1+Qx) */
- etmp = L_shl( L_tmp, sub( exp1, 14 ) ); /*Qx */
+ s = W_norm( W_tmp );
+ L_tmp = W_extract_h( W_shl( W_tmp, s ) ); // *q_finc_prev + s - 32
+
+ L_tmp = Mpy_32_16_1( L_tmp, tmp ); /* *q_finc_prev + s - 32 + Q29 - exp1 - 15 => *q_finc_prev + s - exp1 - 18 */
+ etmp = L_tmp;
+ move32();
+ etmp_e = sub( 31, add( *q_finc_prev, sub( s, add( exp1, 18 ) ) ) );
+
tmp1 = sub( ATT_NSEG, attack );
exp1 = norm_s( tmp1 );
tmp = div_s( shl( 1, sub( 14, exp1 ) ), tmp1 ); /*Q(29-exp1) */
- L_tmp = L_shr_o( finc[attack], Qx, &Overflow ); /*Qx */
- FOR( i = 1; i < tmp1; i++ )
+ W_tmp = 0;
+ move64();
+ FOR( i = 0; i < tmp1; i++ )
{
- L_tmp = L_add_o( L_tmp, L_shr_o( finc[i + attack], Qx, &Overflow ), &Overflow ); /*Qx */
+ W_tmp = W_add( W_tmp, finc[i + attack] ); /* *q_finc_prev */
}
- L_tmp = Mult_32_16( L_tmp, tmp ); /*Q(14-exp1+Qx) */
- etmp2 = L_shl( L_tmp, sub( exp1, 14 ) ); /*Qx */
+ s = W_norm( W_tmp );
+ L_tmp = W_extract_h( W_shl( W_tmp, s ) ); // *q_finc_prev + s - 32
+
+ L_tmp = Mpy_32_16_1( L_tmp, tmp ); /* *q_finc_prev + s - 32 + Q29 - exp1 - 15 => *q_finc_prev + s - exp1 - 18 */
+ etmp2 = L_tmp;
+ move32();
+ etmp2_e = sub( 31, add( *q_finc_prev, sub( s, add( exp1, 18 ) ) ) );
/* and compare them */
- if ( GT_32( etmp, L_shr( etmp2, 3 ) ) )
+ /* if ( etmp * 8 > etmp2 ) */
+ if ( BASOP_Util_Cmp_Mant32Exp( etmp, add( etmp_e, 3 ), etmp2, etmp2_e ) > 0 )
{
/* stop, if the attack is not sufficiently strong */
attack = 0;
@@ -2695,7 +2708,8 @@ static Word16 attack_det_ivas_fx( /* o : attack flag
}
test();
- if ( EQ_16( last_clas, VOICED_CLAS ) && GT_32( L_add( L_shl( etmp, 4 ), L_shl( etmp, 2 ) ), etmp2 ) )
+ /* if ( last_clas == VOICED_CLAS && etmp * 20 > etmp2 ) */
+ if ( EQ_16( last_clas, VOICED_CLAS ) && BASOP_Util_Cmp_Mant32Exp( etmp, etmp_e, Mpy_32_16_1( etmp2, 1638 /* 1/20 in Q15 */ ), etmp2_e ) > 0 )
{
/* stop, if the signal was voiced and the attack is not sufficiently strong */
attack = 0;
@@ -3147,7 +3161,7 @@ void ivas_smc_mode_selection_fx(
test();
test();
test();
- if ( EQ_16( st->vad_flag, 1 ) && LE_32( element_brate, IVAS_16k4 ) && GT_16( st->lp_noise_fx, 7680 /* 30.0f in Q8 */ ) && st->sp_aud_decision1 == 0 && GE_16( st->bwidth, SWB ) && EQ_16( st->coder_type_raw, UNVOICED ) )
+ if ( EQ_16( st->vad_flag, 1 ) && LE_32( element_brate, IVAS_16k4 ) && GT_32( st->lp_noise_32fx, 503316480 /* 30.0f in Q24 */ ) && st->sp_aud_decision1 == 0 && GE_16( st->bwidth, SWB ) && EQ_16( st->coder_type_raw, UNVOICED ) )
{
st->GSC_noisy_speech = 1;
move16();
diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h
index 45ec01b3191699bf6ae8614ca9be327a3cfebc71..0647b6ebc901636f40ee389cf751a4dccc5d8c02 100644
--- a/lib_enc/stat_enc.h
+++ b/lib_enc/stat_enc.h
@@ -54,6 +54,9 @@ typedef struct
Word16 id; /* id of the indice */
UWord16 value; /* value of the quantized indice */
Word16 nb_bits; /* number of bits used for the quantization of the indice */
+#ifdef DBG_BITSTREAM_ANALYSIS
+ char function_name[100];
+#endif
} Indice, *INDICE_HANDLE;
typedef struct
@@ -224,7 +227,8 @@ typedef struct vad_structure
Word16 trigger_SID;
Word16 snr_sum_vad_fx; /*Q15 */
Word16 running_avg_fx; /*Q15 */
- Word32 L_snr_sum_vad_fx; /*Q4*/
+ Word32 L_snr_sum_vad_fx; // EVS:Q4, IVAS:q_L_snr_sum_vad
+ Word16 q_L_snr_sum_vad;
Word16 hangover_terminate_flag; /* CNG and DTX - flag indicating whether to early terminate DTX hangover */
Word16 vad_flag; /* VAD flag */
@@ -377,8 +381,9 @@ typedef struct fd_cng_enc_structure
Word16 msNewMinFlag[NPART];
Word16 msPsdFirstMoment_fx[NPART];
Word32 msPsdSecondMoment_fx[NPART];
- Word16 msNoiseFloor_fx[NPART]; /* Estimated noise floor */
- Word32 msNoiseEst_fx[NPART]; /* Estimated noise level */
+ Word16 msNoiseFloor_fx[NPART]; /* Estimated noise floor */
+ Word32 msNoiseFloor_32fx[NPART]; /* Estimated noise floor IVAS: Q25*/
+ Word32 msNoiseEst_fx[NPART]; /* Estimated noise level */
Word16 msNoiseEst_fx_exp;
Word32 energy_ho_fx[NPART];
Word16 energy_ho_fx_exp;
@@ -395,6 +400,7 @@ typedef struct fd_cng_enc_structure
Word16 partDec[NPART];
Word16 msLogPeriodog_fx[NPART];
Word16 msLogNoiseEst_fx[NPART];
+ Word32 msLogNoiseEst_32fx[NPART]; /*IVAS: Q25*/
Word32 mem_coherence_fx[4];
Word16 mem_coherence_exp[4];
@@ -536,8 +542,9 @@ typedef struct noise_estimation_structure
Word32 ave_enr_fx[NB_BANDS]; /* Q_new + Q_SCALE Noise estimator - long-term average energy per critical band ave_enr_q */
Word16 ave_enr_q;
- Word16 aEn; /* Noise estimator - noise estimator adaptation flag */
- Word16 totalNoise_fx; /* Q8 Noise estimator - total noise energy */
+ Word16 aEn; /* Noise estimator - noise estimator adaptation flag */
+ Word16 totalNoise_fx; /* Q8 Noise estimator - total noise energy */
+ Word32 totalNoise_32fx; /* Q24 Noise estimator - total noise energy */
Word16 first_noise_updt; /* Noise estimator - flag used to determine if the first noise update frame */
Word16 first_noise_updt_cnt; /* Noise estimator - counter of frame after first noise update */
@@ -545,6 +552,7 @@ typedef struct noise_estimation_structure
Word16 bg_cnt; /* Noise estimator - pause length counter */
Word16 Etot_l_fx; /* Q8 Noise estimator - Track energy from below */
Word16 Etot_h_fx; /* Q8 Noise estimator - Track energy from above */
+ Word32 Etot_l_32fx; /* Q24 Noise estimator - Track energy from below */
Word16 Etot_l_lp_fx; /* EVS- Q8 Noise estimator - Smoothed low energy */
Word32 Etot_l_lp_32fx; /* IVAS-Q24 Noise estimator - Smoothed low energy */
Word16 Etot_last_fx; /*EVS- Q8*/
@@ -564,6 +572,7 @@ typedef struct noise_estimation_structure
Word16 lt_aEn_zero_fx; /* Q15 */
Word16 Etot_v_h2_fx;
+ Word32 Etot_v_h2_32fx; /* Q24 */
Word16 sign_dyn_lp_fx; /*Q8*/
Word16 Etot_st_est_fx; /* Q8 Noise estimation - short term estimate of E{ Etot } */
@@ -1013,7 +1022,7 @@ typedef struct fd_bwe_enc_structure
{
Word16 new_input_hp_fx[NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS )]; // Q_new_input_hp
Word16 Q_new_input_hp;
- Word16 old_input_fx[NS2SA( 48000, DELAY_FD_BWE_ENC_NS + DELAY_FIR_RESAMPL_NS )]; // q0
+ Word16 old_input_fx[NS2SA( 48000, DELAY_FD_BWE_ENC_NS + DELAY_FIR_RESAMPL_NS )]; // st->q_inp
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
@@ -1457,7 +1466,9 @@ typedef struct enc_core_structure
Word16 q_inp32;
Word16 q_inp;
Word16 *old_input_signal_fx;
+ Word32 *old_input_signal32_fx;
Word16 q_old_inp;
+ Word16 q_old_inp32;
Word16 Q_old_wtda;
SIGNAL_BUFFERS_ENC_HANDLE hSignalBuf;
@@ -1512,9 +1523,11 @@ typedef struct enc_core_structure
Word16 sharpFlag;
Word16 localVAD; /* i : local VAD flag */
- Word32 bckr_tilt_lt; /* Q16 */
- Word16 lp_speech_fx; /* Q8 */
- Word16 lp_noise_fx; /* CNG and DTX - LP filtered total noise estimation Q8 */
+ Word32 bckr_tilt_lt; /* Q16 */
+ Word16 lp_speech_fx; /* Q8 */
+ Word16 lp_noise_fx; /* CNG and DTX - LP filtered total noise estimation Q24 */
+ Word32 lp_speech_32fx; /* Q24 */
+ Word32 lp_noise_32fx; /* CNG and DTX - LP filtered total noise estimation Q24 */
Word16 Opt_HE_SAD_ON_fx;
Word16 nb_active_frames_HE_SAD_fx;
Word16 voicing_old_fx;
diff --git a/lib_enc/stat_noise_uv_enc_fx.c b/lib_enc/stat_noise_uv_enc_fx.c
index 1445559a19b6d347f2d611d30167244ad4d0969f..24932542ce178bea11bb597e42f06d43d7575017 100644
--- a/lib_enc/stat_noise_uv_enc_fx.c
+++ b/lib_enc/stat_noise_uv_enc_fx.c
@@ -118,7 +118,7 @@ void stat_noise_uv_enc_ivas_fx(
Word16 *Aq, /* i : A(z) quantized for the 4 subframes Q=12 */
Word16 *exc2, /* i/o: excitation buffer Q=Q_stat_noise */
const Word16 uc_two_stage_flag, /* o : flag undicating two-stage UC */
- Word16 Q_new )
+ Word16 *Q_new )
{
Word16 noisiness = 0;
move16();
diff --git a/lib_enc/swb_bwe_enc_fx.c b/lib_enc/swb_bwe_enc_fx.c
index 1ebef740457eef7370a81d919388c7d080210f3f..6b309c3345bb12892421926486682ef51660e8a9 100644
--- a/lib_enc/swb_bwe_enc_fx.c
+++ b/lib_enc/swb_bwe_enc_fx.c
@@ -270,6 +270,7 @@ void swb_bwe_enc_ivas_fx(
Word16 *old_input_16k_fx, /* i : input signal @16kHz for SWB BWE */
const Word16 *old_syn_12k8_16k_fx, /* i : ACELP core synthesis at 12.8kHz or 16kHz */
const Word16 *new_swb_speech_fx, /* i : original input signal at 32kHz */
+ const Word16 Q_new_swb_speech, /* i : Q for new_swb_speech_fx */
Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz */
Word16 Q_shb_speech,
Word16 Q_slb_speech )
@@ -287,7 +288,7 @@ void swb_bwe_enc_ivas_fx(
Word16 old_input_lp_fx[L_FRAME16k];
Word16 new_input_hp_fx[L_FRAME16k];
Word16 yorig_fx[L_FRAME48k];
- Word16 scl, new_input_fx_exp;
+ Word16 scl, new_input_fx_q;
Word16 max;
Word16 Sample_Delay_SWB_BWE;
Word16 Sample_Delay_HP;
@@ -412,7 +413,7 @@ void swb_bwe_enc_ivas_fx(
* SWB BWE encoding
* FB BWE encoding
*---------------------------------------------------------------------*/
- new_input_fx_exp = 0;
+ new_input_fx_q = Q_new_swb_speech;
move16();
test();
IF( ( EQ_16( st_fx->idchan, 1 ) ) && ( EQ_16( last_element_mode, IVAS_CPE_DFT ) ) )
@@ -424,12 +425,12 @@ void swb_bwe_enc_ivas_fx(
}
}
/* 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,
+ wtda_fx( old_input_fx, &new_input_fx_q, 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) */
inner_frame );
/* DCT of the ACELP core synthesis */
- direct_transform_fx( L_old_input_fx, yorig_32, 0, inner_frame, &new_input_fx_exp, st_fx->element_mode );
+ direct_transform_fx( L_old_input_fx, yorig_32, 0, inner_frame, &new_input_fx_q, st_fx->element_mode );
/* high-band gain control in case of BWS */
IF( st_fx->bwidth_sw_cnt > 0 )
@@ -438,7 +439,7 @@ void swb_bwe_enc_ivas_fx(
}
/* Convert to 16 Bits (Calc Shift Required to Stay within MAX_Q_NEW_INPUT) */
- scl = sub( 16 + 8, new_input_fx_exp );
+ scl = sub( 16 + 8, new_input_fx_q );
/* Possible to Upscale? */
IF( scl > 0 )
{
@@ -449,7 +450,7 @@ void swb_bwe_enc_ivas_fx(
scl = s_min( Q_synth, scl );
}
Copy_Scale_sig32_16( yorig_32, yorig_fx, inner_frame, scl );
- Q_synth = add( sub( new_input_fx_exp, 16 ), scl );
+ Q_synth = add( sub( new_input_fx_q, 16 ), scl );
max = 0;
move16();
Q_synth_hf = 0;
@@ -558,12 +559,12 @@ void swb_bwe_enc_ivas_fx(
IF( EQ_16( st_fx->L_frame, L_FRAME16k ) )
{
SWB_BWE_encoding_ivas_fx( st_fx, old_input_fx, old_input_lp_fx, new_input_hp_fx, old_syn_12k8_16k_fx, yorig_32,
- SWB_fenv_fx, tilt_nb_fx, 80, Q_slb_speech, Q_shb, new_input_fx_exp, new_input_fx_exp );
+ SWB_fenv_fx, tilt_nb_fx, 80, Q_slb_speech, Q_shb, new_input_fx_q, new_input_fx_q );
}
ELSE
{
SWB_BWE_encoding_ivas_fx( st_fx, old_input_fx, old_input_lp_fx, new_input_hp_fx, old_syn_12k8_16k_fx, yorig_32,
- SWB_fenv_fx, tilt_nb_fx, 6, Q_slb_speech, Q_shb, new_input_fx_exp, new_input_fx_exp );
+ SWB_fenv_fx, tilt_nb_fx, 6, Q_slb_speech, Q_shb, new_input_fx_q, new_input_fx_q );
}
diff --git a/lib_enc/swb_pre_proc_fx.c b/lib_enc/swb_pre_proc_fx.c
index ba165cba418cb68d6b0680bad403d394d7b64462..0e89e16c17a0d96f74bd352d092809a4086d4a7d 100644
--- a/lib_enc/swb_pre_proc_fx.c
+++ b/lib_enc/swb_pre_proc_fx.c
@@ -778,7 +778,7 @@ void swb_pre_proc_fx(
/*full implementation pending*/
void swb_pre_proc_ivas_fx(
Encoder_State *st, /* i/o: encoder state structure */
- Word16 *new_swb_speech, /* o : original input signal at 32kHz - Q0 */
+ Word16 *new_swb_speech, /* o : original input signal at 32kHz - st->q_inp */
Word32 *new_swb_speech_fx, /* o : original input signal at 32kHz - Q - q_reImBuffer */
Word16 *shb_speech, /* o : SHB target signal (6-14kHz) at 16kHz- Q(Q_shb_spch) */
Word16 *Q_shb_spch,
@@ -846,6 +846,9 @@ void swb_pre_proc_ivas_fx(
test();
test();
+ scale_sig( hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k, sub( st->q_inp, st->Q_old_wtda ) ); // st->Q_old_wtda -> st->q_inp
+ st->Q_old_wtda = st->q_inp;
+ move16();
IF( EQ_16( st->element_mode, IVAS_CPE_TD ) && GE_16( st->bwidth, SWB ) )
{
Copy( st->input_fx - hCPE->hStereoTCA->lMemRecalc, hBWE_FD->L_old_wtda_swb_fx + L_FRAME32k - sub( hCPE->hStereoTCA->lMemRecalc, Sample_Delay_SWB_BWE ), sub( hCPE->hStereoTCA->lMemRecalc, Sample_Delay_SWB_BWE ) );
@@ -880,6 +883,8 @@ void swb_pre_proc_ivas_fx(
IF( NE_16( st->extl, WB_BWE ) )
{
Copy( old_input_fx, hBWE_FD->L_old_wtda_swb_fx, L_FRAME32k );
+ st->Q_old_wtda = st->q_inp;
+ move16();
}
}
@@ -929,6 +934,10 @@ void swb_pre_proc_ivas_fx(
test();
test();
+ scale_sig( hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k, sub( st->q_inp, st->Q_old_wtda ) ); // st->Q_old_wtda -> st->q_inp
+ st->Q_old_wtda = st->q_inp;
+ move16();
+
IF( EQ_16( st->element_mode, IVAS_CPE_TD ) && GE_16( st->bwidth, SWB ) )
{
IF( EQ_16( st->bwidth, SWB ) )
@@ -1029,6 +1038,8 @@ void swb_pre_proc_ivas_fx(
set16_fx( old_input_fx, 0, Sample_Delay_SWB_BWE );
Copy( new_swb_speech + inner_frame - Sample_Delay_SWB_BWE, hBWE_FD->old_input_fx, Sample_Delay_SWB_BWE );
Copy( old_input_fx, hBWE_FD->L_old_wtda_swb_fx, inner_frame );
+ st->Q_old_wtda = st->q_inp;
+ move16();
}
/* resample 48 kHz to 32kHz */
@@ -1057,8 +1068,9 @@ void swb_pre_proc_ivas_fx(
{
Word16 out_start_ind, out_end_ind;
stereo_dft_enc_synthesize_fx( hCPE->hStereoDft, new_swb_speech_fx, &out_start_ind, &out_end_ind, st->idchan, input_Fs, 32000, 0, NULL );
- Copy_Scale_sig32_16( new_swb_speech_fx - STEREO_DFT_OVL_MAX, new_swb_speech - STEREO_DFT_OVL_MAX, L_FRAME48k + STEREO_DFT_OVL_MAX, add( q_reImBuffer, 1 ) ); // Q0
- Copy( new_swb_speech - Sample_Delay_SWB_BWE32k, hBWE_FD->old_input_fx, Sample_Delay_SWB_BWE32k ); // Q0
+ Copy_Scale_sig32_16( new_swb_speech_fx - STEREO_DFT_OVL_MAX, new_swb_speech - STEREO_DFT_OVL_MAX, L_FRAME48k + STEREO_DFT_OVL_MAX, add( st->q_inp, add( q_reImBuffer, 1 ) ) ); // st->q_inp
+
+ Copy( new_swb_speech - Sample_Delay_SWB_BWE32k, hBWE_FD->old_input_fx, Sample_Delay_SWB_BWE32k ); // st->q_inp
}
}
}
diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c
index 903f3a46c7f62292b1922a6ff7c7a51398098549..08c920c4a6f87b6b7fac6fbc3431e29c0f2929d2 100644
--- a/lib_enc/swb_tbe_enc_fx.c
+++ b/lib_enc/swb_tbe_enc_fx.c
@@ -77,7 +77,8 @@ static void EstimateSHBGainShape_fx( const Word16 length,
const Word16 Q_synSHB,
Word16 *subgain,
const Word16 *subwin,
- Word16 *n_subfr_saturation );
+ Word16 *n_subfr_saturation,
+ const Flag limit_min_gain );
static Word32 pow_off_pk_fx( Word16 a[], Word16 len, Word16 step );
@@ -1072,7 +1073,7 @@ void wb_tbe_enc_fx(
Copy( shaped_wb_excitation + L_FRAME16k / 4, hBWE_TD->state_syn_shbexc_fx, L_SHB_LAHEAD / 4 );
EstimateSHBGainShape_fx( SHB_OVERLAP_LEN / 2, hb_frame, Q_ns,
- shaped_wb_excitation, Q_bwe_exc_ext, GainShape, subwin_wb_fx, NULL );
+ shaped_wb_excitation, Q_bwe_exc_ext, GainShape, subwin_wb_fx, NULL, 1 );
/* Gain frame adjustment factor */
test();
@@ -1707,7 +1708,7 @@ void wb_tbe_enc_ivas_fx(
Copy( shaped_wb_excitation + L_FRAME16k / 4, hBWE_TD->state_syn_shbexc_fx, L_SHB_LAHEAD / 4 );
EstimateSHBGainShape_fx( SHB_OVERLAP_LEN / 2, hb_frame, Q_ns,
- shaped_wb_excitation, Q_bwe_exc_ext, GainShape, subwin_wb_fx, NULL );
+ shaped_wb_excitation, Q_bwe_exc_ext, GainShape, subwin_wb_fx, NULL, 1 );
/* Gain frame adjustment factor */
test();
@@ -2552,7 +2553,7 @@ void swb_tbe_enc_fx(
n_subfr_saturation = 0;
move16();
EstimateSHBGainShape_fx( SHB_OVERLAP_LEN, shb_frame_fx, Q_shb, shaped_shb_excitation_fx,
- Q_bwe_exc, GainShape_fx, subwin_shb_fx, &n_subfr_saturation );
+ Q_bwe_exc, GainShape_fx, subwin_shb_fx, &n_subfr_saturation, 1 );
/* Gain shape BWS/high band low energy fix */
IF( LT_16( hBWE_TD->cldfbHBLT, 8192 /*1.0f Q13*/ ) ) /* cldfbHBLT in Q13 */
@@ -3106,6 +3107,14 @@ void swb_tbe_enc_ivas_fx(
/* stab_check = a2lsp( lsf_shb, lpc_shb, LPC_SHB_ORDER ); */
+ /* LPC to LSP conversion */
+ /* LPC: Q12, LSP: Q15 */
+ E_LPC_a_lsp_conversion( lpc_shb_fx, lsp_shb_fx, hBWE_TD->prev_lsp_shb_fx, LPC_SHB_ORDER );
+
+ /* LSP to LSF conversion */
+ /* LSP: Q15, LSF: Q15 */
+ E_LPC_lsp_lsf_conversion( lsp_shb_fx, lsf_shb_fx, LPC_SHB_ORDER );
+
test();
test();
IF( ( NE_16( st_fx->last_extl, SWB_TBE ) && NE_16( st_fx->last_extl, FB_TBE ) ) || st_fx->ini_frame == 0 )
@@ -3123,14 +3132,6 @@ void swb_tbe_enc_ivas_fx(
// mvr2r( hBWE_TD->prev_lsp_shb, lsf_shb, LPC_SHB_ORDER );
// }
- /* LPC to LSP conversion */
- /* LPC: Q12, LSP: Q15 */
- E_LPC_a_lsp_conversion( lpc_shb_fx, lsp_shb_fx, hBWE_TD->prev_lsp_shb_fx, LPC_SHB_ORDER );
-
- /* LSP to LSF conversion */
- /* LSP: Q15, LSF: Q15 */
- E_LPC_lsp_lsf_conversion( lsp_shb_fx, lsf_shb_fx, LPC_SHB_ORDER );
-
Copy( lsp_shb_fx, hBWE_TD->prev_lsp_shb_fx, LPC_SHB_ORDER );
Copy( lsf_shb_fx, lsf_shb_orig_fx, LPC_SHB_ORDER );
@@ -3857,7 +3858,7 @@ void swb_tbe_enc_ivas_fx(
n_subfr_saturation = 0;
move16();
EstimateSHBGainShape_fx( SHB_OVERLAP_LEN, shb_frame_fx, Q_shb, shaped_shb_excitation_fx,
- Q_bwe_exc, GainShape_fx, subwin_shb_fx, &n_subfr_saturation );
+ Q_bwe_exc, GainShape_fx, subwin_shb_fx, &n_subfr_saturation, 0 );
test();
IF( EQ_32( st_fx->extl_brate, SWB_TBE_1k10 ) || EQ_32( st_fx->extl_brate, SWB_TBE_1k75 ) )
@@ -4931,14 +4932,15 @@ static Word32 pow_off_pk_corrected_fx( Word16 a[], Word16 len, Word16 step )
/*--------------------------------------------------------------------------*/
static void EstimateSHBGainShape_fx(
- const Word16 length, /* i : SHB overlap length */
- const Word16 *oriSHB, /* i : target original SHB frame Q(Q_oriSHB) */
- const Word16 Q_oriSHB, /* i : Q of target original SHB frame */
- const Word16 *synSHB, /* i : shaped SHB excitation Q(Q_synSHB) */
- const Word16 Q_synSHB, /* i : Q of shaped SHB excitation */
- Word16 *subgain, /* o : estimate of gain shape Q15 */
- const Word16 *subwin, /* i : SHB subframe window Q15 */
- Word16 *n_subfr_saturation /* o : Number of subframes which saturated while calculating oriNrg */
+ const Word16 length, /* i : SHB overlap length */
+ const Word16 *oriSHB, /* i : target original SHB frame Q(Q_oriSHB) */
+ const Word16 Q_oriSHB, /* i : Q of target original SHB frame */
+ const Word16 *synSHB, /* i : shaped SHB excitation Q(Q_synSHB) */
+ const Word16 Q_synSHB, /* i : Q of shaped SHB excitation */
+ Word16 *subgain, /* o : estimate of gain shape Q15 */
+ const Word16 *subwin, /* i : SHB subframe window Q15 */
+ Word16 *n_subfr_saturation, /* o : Number of subframes which saturated while calculating oriNrg */
+ const Flag limit_min_gain /* i : gain shape limiting flag */
)
{
const Word16 *skip;
@@ -5152,11 +5154,23 @@ static void EstimateSHBGainShape_fx(
n = sub( 31, add( n, ( sub( 28, shl( n_max, 1 ) ) ) ) );
normFact = Isqrt_lc( L_sum_gain, &n );
- FOR( i = 0; i < num_gains; i++ )
+ IF( limit_min_gain )
{
- L_tmp = Mpy_32_16_1( normFact, subgain[i] ); /*Q(31-n) * Q(31-norm[i]) */ /* Q(30-n-n_max) */
- subgain[i] = s_max( round_fx_o( L_shl_o( L_tmp, add( n, n_max + 1 ), &Overflow ), &Overflow ), 3277 /*0.1f Q15*/ ); /* Q15 */
- move16();
+ FOR( i = 0; i < num_gains; i++ )
+ {
+ L_tmp = Mpy_32_16_1( normFact, subgain[i] ); /*Q(31-n) * Q(31-norm[i]) */ /* Q(30-n-n_max) */
+ subgain[i] = s_max( round_fx_o( L_shl_o( L_tmp, add( n, n_max + 1 ), &Overflow ), &Overflow ), 3277 /*0.1f Q15*/ ); /* Q15 */
+ move16();
+ }
+ }
+ ELSE
+ {
+ FOR( i = 0; i < num_gains; i++ )
+ {
+ L_tmp = Mpy_32_16_1( normFact, subgain[i] ); /*Q(31-n) * Q(31-norm[i]) */ /* Q(30-n-n_max) */
+ subgain[i] = round_fx_o( L_shl_o( L_tmp, add( n, n_max + 1 ), &Overflow ), &Overflow ); /* Q15 */
+ move16();
+ }
}
return;
@@ -7547,8 +7561,8 @@ void fb_tbe_enc_ivas_fx(
hBWE_TD->old_input_fhb_fx_Q = exp_temp;
move16();
- temp2 = sum2_fx_no_sat( input_fhb, L_FRAME48k / 2 ); // 2*q_input_fhb /* Q(2*Q_input_fhb-8) */
- temp2 = W_add( temp2, W_shl( hBWE_TD->prev_fb_energy_fx, sub( q_input_fhb, hBWE_TD->prev_fb_energy_fx_Q ) ) ); // 2*q_input_fhb
+ temp2 = sum2_fx_no_sat( input_fhb, L_FRAME48k / 2 ); // 2*q_input_fhb /* Q(2*Q_input_fhb-8) */
+ temp2 = W_add( temp2, W_shl( hBWE_TD->prev_fb_energy_fx, sub( shl( q_input_fhb, 1 ), hBWE_TD->prev_fb_energy_fx_Q ) ) ); // 2*q_input_fhb
temp1 = sum2_fx_no_sat( input_fhb + L_FRAME48k / 2, L_FRAME48k / 2 ); // 2*q_input_fhb
exp = W_norm( temp1 );
@@ -7605,7 +7619,6 @@ void fb_tbe_enc_ivas_fx(
{
push_indice( st->hBstr, IND_FB_SLOPE, idxGain, 4 );
}
-
return;
}
void tbe_write_bitstream_fx(
diff --git a/lib_enc/tcx_utils_enc_fx.c b/lib_enc/tcx_utils_enc_fx.c
index 7d5f486ccbd3c839725fbe1f115490cfc4c7449b..29154688ec4cb3391e29f27d6076014871b060c1 100644
--- a/lib_enc/tcx_utils_enc_fx.c
+++ b/lib_enc/tcx_utils_enc_fx.c
@@ -1392,25 +1392,33 @@ void tcx_scalar_quantization_ivas_fx(
s = sub( add( x_e, gain_e ), 15 );
}
- /* substract 0x8000 to affect the mac_r in the following loop
- so it acts like extract_h. the 0x4000 will be multiplied by 2
- by the mac_r to get to 0x8000 and disable the round. */
- offset = sub( offset, 0x4000 );
-
FOR( ; i >= 0; i-- )
{
- offs32 = Mpy_32_16_1( L_abs( x[i] ), gain ); /* multiply */
- offs32 = L_shl_sat( offs32, s ); /* convert to 15Q16 */
- tmp16 = mac_r_sat( offs32, offset, 1 ); /* add offset and truncate */
- IF( x[i] < 0 )
+ offs32 = Mpy_32_16_1( x[i], gain ); /* multiply */
+ offs32 = L_shl_sat( offs32, s ); /* convert to 15Q16 */
+ IF( x[i] > 0 )
{
- tmp16 = negate( tmp16 ); /* restore sign */
+ offs32 = L_add_sat( offs32, L_shl( offset, 1 ) );
+ tmp16 = extract_h( offs32 );
+ IF( GT_32( L_deposit_h( tmp16 ), offs32 ) )
+ {
+ tmp16 = sub( tmp16, 1 );
+ }
+ }
+ ELSE
+ {
+ offs32 = L_add_sat( offs32, L_shl( negate( offset ), 1 ) );
+ tmp16 = extract_h( offs32 );
+ IF( LT_32( L_deposit_h( tmp16 ), offs32 ) )
+ {
+ tmp16 = add( tmp16, 1 );
+ }
}
-
xq[i] = tmp16;
move16();
}
+
IF( alfe_flag == 0 )
{
AdaptLowFreqEmph_fx( x, x_e, xq, gain, gain_e,
@@ -3761,7 +3769,7 @@ Word16 tcx_res_Q_spec_ivas_fx(
return bits;
}
-#if 1 // TV
+
void ProcessIGF_fx(
IGF_ENC_INSTANCE_HANDLE const hInstance, /**< in: instance handle of IGF Encoder */
Encoder_State *st, /**< in: Encoder state */
@@ -3893,7 +3901,7 @@ void ProcessIGF_fx(
}
#endif
}
-#endif
+
void attenuateNbSpectrum_fx( Word16 L_frame, Word32 *spectrum )
{
Word16 i, length, att;
@@ -4029,15 +4037,15 @@ void ProcessStereoIGF_fx(
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 */
- Word16 exp_pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: exp of pPowerSpectrum_fx */
- Word32 *pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i : inverse power spectrum */
- Word16 exp_pPowerSpectrumMsInv_fx[CPE_CHANNELS], /* i/o: exp of pPowerSpectrumMsInv_fx */
- Word32 *inv_spectrum_fx[CPE_CHANNELS][NB_DIV], /* i : inverse spectrum */
- Word16 exp_inv_spectrum_fx[CPE_CHANNELS], /* i/o: exp of inv_spectrum_fx */
- const Word16 frameno, /* i : flag indicating index of current subfr. */
- const Word16 sp_aud_decision0, /* i : sp_aud_decision0 */
- const Word32 element_brate, /* i : element bitrate */
+ Word32 *pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */
+ Word16 *exp_pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: exp of pPowerSpectrum_fx */
+ Word32 *pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i : inverse power spectrum */
+ Word16 *q_pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i/o: Q of pPowerSpectrumMsInv_fx */
+ Word32 *inv_spectrum_fx[CPE_CHANNELS][NB_DIV], /* i : inverse spectrum */
+ Word16 exp_inv_spectrum_fx[CPE_CHANNELS], /* i/o: exp of inv_spectrum_fx */
+ const Word16 frameno, /* i : flag indicating index of current subfr. */
+ const Word16 sp_aud_decision0, /* i : sp_aud_decision0 */
+ const Word32 element_brate, /* i : element bitrate */
const Word16 mct_on )
{
Word16 ch, igfGridIdx, isIndepFlag, bsBits, pBsStart, curr_order;
@@ -4078,7 +4086,7 @@ void ProcessStereoIGF_fx(
IGFSaveSpectrumForITF_ivas_fx( hIGFEnc[1], igfGridIdx, pITFMDCTSpectrum_fx[1][frameno], sub( Q31, q_pITFMDCTSpectrum_2 ) );
- IGFEncApplyStereo_fx( hStereoMdct, ms_mask, hIGFEnc, igfGridIdx, sts, pPowerSpectrum_fx, exp_pPowerSpectrum_fx, pPowerSpectrumMsInv_fx, exp_pPowerSpectrumMsInv_fx,
+ IGFEncApplyStereo_fx( hStereoMdct, ms_mask, hIGFEnc, igfGridIdx, sts, pPowerSpectrum_fx, exp_pPowerSpectrum_fx, pPowerSpectrumMsInv_fx, q_pPowerSpectrumMsInv_fx,
inv_spectrum_fx, exp_inv_spectrum_fx, frameno, sp_aud_decision0, element_brate, mct_on );
FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
diff --git a/lib_enc/transient_detection_fx.c b/lib_enc/transient_detection_fx.c
index 2ade624b689754b4ec92c4f14e694158917e9428..1ad69a3302b2c79e2879d313f98413b1a7eba2fc 100644
--- a/lib_enc/transient_detection_fx.c
+++ b/lib_enc/transient_detection_fx.c
@@ -638,16 +638,6 @@ void RunTransientDetection_fx( Word16 const *input, Word16 nSamplesAvailable, Tr
/* Update the delay buffer. */
UpdateDelayBuffer( filteredInput, nSamplesAvailable, &pTransientDetection->delayBuffer );
-#ifdef IVAS_CODE
- /* compute ramp up flag */
- pSubblockEnergies->ramp_up_flag = ( ( pSubblockEnergies->ramp_up_flag << 1 ) & 0x0003 );
- e0 = dotp( filteredInput + length / 2, filteredInput + length / 2, pSubblockEnergies->pDelayBuffer->nSubblockSize / 2 ) + 0.5f * MIN_BLOCK_ENERGY;
- e1 = pSubblockEnergies->subblockNrg[pSubblockEnergies->nDelay + 4] - e0;
- if ( e1 > e0 )
- {
- pSubblockEnergies->ramp_up_flag |= 0x0001;
- }
-#endif
}
@@ -1582,72 +1572,7 @@ static void CalculateSubblockEnergies_ivas_fx( Word16 const *input, Word16 nSamp
}
}
}
-#ifdef IVAS_CODE
-/*-------------------------------------------------------------------*
- * set_transient_stereo()
- *
- *
- *-------------------------------------------------------------------*/
-
-void set_transient_stereo(
- CPE_ENC_HANDLE hCPE, /* i : CPE structure */
- float currFlatness[] /* i/o: current flatness */
-)
-{
- int16_t n, attackIsPresent;
- float currFlatnessMax;
- Encoder_State **sts;
-
- sts = hCPE->hCoreCoder;
-
- /* for DFT/TD based stereo ,map avg. flatness to individual stereo channels (M/S or X/Y) */
- maximum( currFlatness, CPE_CHANNELS, &currFlatnessMax );
- attackIsPresent = 0;
-
- for ( n = 0; n < CPE_CHANNELS; n++ )
- {
- attackIsPresent = max( attackIsPresent, sts[n]->hTranDet->transientDetector.bIsAttackPresent );
- }
-
- set_f( currFlatness, currFlatnessMax, CPE_CHANNELS );
-
- for ( n = 0; n < CPE_CHANNELS; n++ )
- {
- sts[n]->hTranDet->transientDetector.bIsAttackPresent = attackIsPresent;
- }
-
- if ( hCPE->hStereoDft != NULL )
- {
- if ( hCPE->hStereoDft->attackPresent )
- {
- hCPE->hStereoDft->wasTransient = 1;
- }
- else if ( hCPE->hStereoDft->wasTransient )
- {
- hCPE->hStereoDft->wasTransient = 0;
- }
-
- hCPE->hStereoDft->attackPresent = attackIsPresent;
- hCPE->hStereoDft->hItd->currFlatness = 0;
- for ( n = 0; n < CPE_CHANNELS; n++ )
- {
- hCPE->hStereoDft->hItd->currFlatness = max( hCPE->hStereoDft->hItd->currFlatness, currFlatness[n] );
- }
- }
-
- if ( hCPE->hStereoMdct != NULL )
- {
- hCPE->hStereoMdct->hItd->currFlatness = 0;
- for ( n = 0; n < CPE_CHANNELS; n++ )
- {
- hCPE->hStereoMdct->hItd->currFlatness = max( hCPE->hStereoMdct->hItd->currFlatness, currFlatness[n] );
- }
- }
-
- return;
-}
-#endif
/*-------------------------------------------------------------------*
* transient_analysis()
*
diff --git a/lib_enc/transition_enc_fx.c b/lib_enc/transition_enc_fx.c
index 5e50cac15b457c299b6af0828b4ac56c07497197..82e41026d0ca161e73b9a2a13c4d22a10eb8850a 100644
--- a/lib_enc/transition_enc_fx.c
+++ b/lib_enc/transition_enc_fx.c
@@ -212,13 +212,9 @@ void transition_enc_fx(
IF( EQ_16( *tc_subfr, TC_0_0 ) )
{
/* this is called only to compute unused bits */
-#ifdef REMOVE_EVS_DUPLICATES
- config_acelp1_IVAS( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate,
-#else
- config_acelp1( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate,
-#endif
- L_FRAME, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, TC_0_0, 3, NULL, unbits_ACELP,
- st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, st_fx->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/ );
+ config_acelp1_fx( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate,
+ L_FRAME, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, TC_0_0, 3, NULL, unbits_ACELP,
+ st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, st_fx->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/ );
}
*clip_gain = gp_clip_fx( st_fx->element_mode, st_fx->core_brate, st_fx->voicing_fx, i_subfr, TRANSITION, xn_fx, gp_cl_fx, sub( shift_wsp, 1 ) );
@@ -328,13 +324,9 @@ void transition_enc_fx(
IF( LE_16( sub( i_subfr, *tc_subfr ), L_SUBFR ) )
{
-#ifdef REMOVE_EVS_DUPLICATES
- config_acelp1_IVAS( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate,
-#else
- config_acelp1( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate,
-#endif
- st_fx->L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, *tc_subfr, 2, NULL,
- unbits_ACELP, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, st_fx->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/ );
+ config_acelp1_fx( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate,
+ st_fx->L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, *tc_subfr, 2, NULL,
+ unbits_ACELP, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, st_fx->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/ );
}
/*-----------------------------------------------------------------*
@@ -924,8 +916,6 @@ void transition_enc_ivas_fx(
/* set limit_flag to 0 for restrained limits, and 1 for extended limits */
limit_flag = 0;
move16();
- Word16 h1_fx_q15[L_SUBFR + ( M + 1 )];
- Copy_Scale_sig( h1_fx, h1_fx_q15, L_SUBFR + ( M + 1 ), 0 );
pit_start = PIT_MIN;
move16();
@@ -1042,14 +1032,9 @@ void transition_enc_ivas_fx(
IF( EQ_16( *tc_subfr, TC_0_0 ) )
{
/* this is called only to compute unused bits */
-
-#ifdef REMOVE_EVS_DUPLICATES
- config_acelp1_IVAS( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate,
-#else
- config_acelp1( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate,
-#endif
- L_FRAME, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, TC_0_0, 3, NULL, unbits_ACELP,
- st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, st_fx->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/
+ config_acelp1_fx( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate,
+ L_FRAME, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, TC_0_0, 3, NULL, unbits_ACELP,
+ st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, st_fx->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/
);
}
@@ -1160,13 +1145,9 @@ void transition_enc_ivas_fx(
IF( LE_16( sub( i_subfr, *tc_subfr ), L_SUBFR ) )
{
-#ifdef REMOVE_EVS_DUPLICATES
- config_acelp1_IVAS( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate,
-#else
- config_acelp1( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate,
-#endif
- st_fx->L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, *tc_subfr, 2, NULL,
- unbits_ACELP, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, st_fx->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/ );
+ config_acelp1_fx( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate,
+ st_fx->L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, *tc_subfr, 2, NULL,
+ unbits_ACELP, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, st_fx->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/ );
}
/*-----------------------------------------------------------------*
@@ -1233,7 +1214,7 @@ void transition_enc_ivas_fx(
push_indice( hBstr, IND_PITCH, index, nBits );
/* Find the adaptive codebook vector - ACELP long-term prediction */
- pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
offset = tbe_celp_exc_offset( *T0, *T0_frac, st_fx->L_frame );
@@ -1282,7 +1263,7 @@ void transition_enc_ivas_fx(
push_indice( hBstr, IND_PITCH, index, nBits );
/* Find the adaptive codebook vector - ACELP long-term prediction */
- pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
offset = tbe_celp_exc_offset( *T0, *T0_frac, st_fx->L_frame );
@@ -1346,7 +1327,7 @@ void transition_enc_ivas_fx(
push_indice( hBstr, IND_PITCH, index, nBits );
/* Find the adaptive codebook vector - ACELP long-term prediction */
- pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
offset = tbe_celp_exc_offset( *T0, *T0_frac, st_fx->L_frame );
@@ -1371,7 +1352,7 @@ void transition_enc_ivas_fx(
push_indice( hBstr, IND_PITCH, index, nBits );
/* Find the adaptive codebook vector - ACELP long-term prediction */
- pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
offset = tbe_celp_exc_offset( *T0, *T0_frac, st_fx->L_frame );
@@ -1407,7 +1388,7 @@ void transition_enc_ivas_fx(
pit_Q_enc_ivas_fx( hBstr, 0, nBits, 8, pit_flag, limit_flag, *T0, *T0_frac, T0_min, T0_max );
/* Find the adaptive codebook vector - ACELP long-term prediction */
- pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
offset = tbe_celp_exc_offset( *T0, *T0_frac, st_fx->L_frame );
@@ -1443,12 +1424,7 @@ void transition_enc_ivas_fx(
*clip_gain = gp_clip_fx( st_fx->element_mode, st_fx->core_brate, st_fx->voicing_fx, i_subfr, TRANSITION, xn_fx, gp_cl_fx, ( Q_new + shift - 1 ) );
move16();
-#ifdef TEST_HR
- Copy( h1_fx, h1_fx_q15, L_SUBFR + ( M + 1 ) );
-#else
- Copy_Scale_sig( h1_fx, h1_fx_q15, L_SUBFR + ( M + 1 ), 1 );
-#endif
- lp_select = lp_filt_exc_enc_ivas_fx( MODE1, TRANSITION, i_subfr, exc_fx, h1_fx_q15,
+ lp_select = lp_filt_exc_enc_ivas_fx( MODE1, TRANSITION, i_subfr, exc_fx, h1_fx,
xn_fx, y1_fx, xn2_fx, L_SUBFR, st_fx->L_frame, g_corr_fx, *clip_gain, gain_pit_fx, &lp_flag );
IF( EQ_16( lp_flag, NORMAL_OPERATION ) )
@@ -1663,7 +1639,7 @@ void transition_enc_ivas_fx(
ELSE
{
/* Find the adaptive codebook vector - ACELP long-term prediction */
- pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
offset = L_deposit_l( 0 );
tmp = extract_l( L_mult( *T0_frac, 32 ) ); /*Q8, 0.25 in Q7*/
@@ -1684,12 +1660,7 @@ void transition_enc_ivas_fx(
*clip_gain = gp_clip_fx( st_fx->element_mode, st_fx->core_brate, st_fx->voicing_fx, i_subfr, TRANSITION, xn_fx, gp_cl_fx, Q_new );
move16();
-#ifdef TEST_HR
- Copy( h1_fx, h1_fx_q15, L_SUBFR + ( M + 1 ) );
-#else
- Copy_Scale_sig( h1_fx, h1_fx_q15, L_SUBFR + ( M + 1 ), 1 );
-#endif
- lp_select = lp_filt_exc_enc_ivas_fx( MODE1, TRANSITION, i_subfr, exc_fx, h1_fx_q15,
+ lp_select = lp_filt_exc_enc_ivas_fx( MODE1, TRANSITION, i_subfr, exc_fx, h1_fx,
xn_fx, y1_fx, xn2_fx, L_SUBFR, st_fx->L_frame, g_corr_fx, *clip_gain, gain_pit_fx, &lp_flag );
IF( EQ_16( lp_flag, NORMAL_OPERATION ) )
{
diff --git a/lib_enc/updt_enc_fx.c b/lib_enc/updt_enc_fx.c
index 1210bfd0444a4d49af018af17dea5a8d64b96e08..aed3bf81271924fb7dbf5f7228293c5434829f37 100644
--- a/lib_enc/updt_enc_fx.c
+++ b/lib_enc/updt_enc_fx.c
@@ -204,20 +204,6 @@ void updt_IO_switch_enc_fx(
set16_fx( hBWE_TD->old_speech_wb_fx, 0, ( L_LOOK_12k8 + L_SUBFR ) * 5 / 16 );
set16_fx( hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 );
set16_fx( hBWE_TD->old_bwe_exc_extended_fx, 0, NL_BUFF_OFFSET );
-#ifdef IVAS_CODE
- set16_fx( st->hBWE_TD->mem_shb_res, 0, MAX_LEN_MA_FILTER );
- set16_fx( st->hBWE_TD->old_EnvSHBres, 0, L_FRAME4k );
- st->hBWE_TD->old_mean_EnvSHBres = 0;
- st->hBWE_TD->prev_enr_EnvSHBres = 32767;
- st->hBWE_TD->prev_pow_exc16kWhtnd = 32767;
- st->hBWE_TD->prev_mix_factor = 32767;
- st->hBWE_TD->prev_Env_error = 0;
- move16();
- move16();
- move16();
- move16();
- move16();
-#endif
hBWE_TD->bwe_non_lin_prev_scale_fx = 0;
move16();
set16_fx( hBWE_TD->decim_state1_fx, 0, ( 2 * ALLPASSSECTIONS_STEEP + 1 ) );
@@ -251,23 +237,6 @@ void updt_IO_switch_enc_fx(
st->use_acelp_preq = 0;
move16();
-#ifdef IVAS_CODE
- set16_fx( st->hSpMusClas->finc_prev, 0, ATT_NSEG );
- set16_fx( st->hSpMusClas->tod_lt_Bin_E, 0, TOD_NSPEC );
- set16_fx( st->hSpMusClas->tod_S_map_lt, 0, TOD_NSPEC );
- st->hSpMusClas->lt_finc = 0;
- st->hSpMusClas->last_strong_attack = 0;
- st->hSpMusClas->tod_thr_lt = TOD_THR_MASS;
- st->hSpMusClas->tod_weight = 0;
- st->hSpMusClas->tod_S_mass_prev = TOD_THR_MASS;
- st->hSpMusClas->tod_S_mass_lt = TOD_THR_MASS;
- move16();
- move16();
- move16();
- move16();
- move16();
- move16();
-#endif
}
ELSE /* switching to AMR-WB IO mode */
{
diff --git a/lib_enc/vad_fx.c b/lib_enc/vad_fx.c
index 1fdcb94fac335e5852dc782acc3a47dd2c9705c3..1cf7a5de8e6cea58d11cf74ec571e168bc005472 100644
--- a/lib_enc/vad_fx.c
+++ b/lib_enc/vad_fx.c
@@ -142,6 +142,8 @@ void wb_vad_init_ivas_fx(
{
hVAD->L_snr_sum_vad_fx = 0;
move32();
+ hVAD->q_L_snr_sum_vad = Q31;
+ move16();
hVAD->hangover_cnt = 0;
move16(); /* Hangover counter initialized to 0 */
hVAD->nb_active_frames = ACTIVE_FRAMES_FX;
@@ -213,6 +215,29 @@ void wb_vad_init_ivas_fx(
*
* accumulate snr_sum with significance thresholds
*-----------------------------------------------------------------*/
+static void sign_thr_snr_acc_ivas_fx(
+ Word32 *L_snr_sum, /* o: q_snr_sum */
+ Word16 *q_snr_sum,
+ Word32 L_snr, /* i: q_snr */
+ Word16 q_snr,
+ Word32 sign_thr, /* i: q_snr */
+ Word32 min_snr /* i: q_snr */
+)
+{
+ /*if( snr >= sign_thr ) */
+ Word32 L_tmp;
+ Word16 exp_snr_sum = sub( 31, *q_snr_sum );
+ L_tmp = min_snr;
+ move32();
+ IF( GE_32( L_snr, sign_thr ) )
+ {
+ L_tmp = L_add( L_snr, 0 ); /* q_snr */
+ }
+ *L_snr_sum = BASOP_Util_Add_Mant32Exp( *L_snr_sum, exp_snr_sum, L_tmp, sub( 31, q_snr ), &exp_snr_sum ); /* q_snr */
+ *q_snr_sum = sub( 31, exp_snr_sum );
+ move32();
+ move32();
+}
static void sign_thr_snr_acc_fx(
Word32 *L_snr_sum, /* o: Q4 */
Word32 L_snr, /* i: Q4 */
@@ -1895,7 +1920,8 @@ Word16 wb_vad_ivas_fx(
)
{
Word16 i, flag = 0, hangover_short;
- Word16 snr_sum, thr1 = 0, thr1_nb_mod, thr2 = 0, nk = 0, nc = 0, th_clean = 0;
+ Word16 snr_sum, thr1 = 0, thr1_nb_mod, thr2 = 0, nk = 0, th_clean = 0;
+ Word32 nc;
Word16 lp_snr; /* Q8 */
const Word32 *pt1;
const Word32 *pt2;
@@ -1904,8 +1930,8 @@ Word16 wb_vad_ivas_fx(
Word16 min_snr, sign_thr;
Word32 L_snr, L_snr_sum;
- Word32 ftmp, ftmp1, ftmp2;
- Word16 m_noise_local, e_noise, e_num, m_num, snr_tmp, shift_snr, q_snr_tmp, q_snr;
+ Word32 ener, fr_enr, ftmp, ftmp1;
+ Word16 m_noise_local, e_noise, e_num, m_num, q_snr_tmp, q_snr;
Word32 L_snr_tmp;
Word16 snr_sumt;
Word32 L_vad_thr;
@@ -1924,7 +1950,7 @@ Word16 wb_vad_ivas_fx(
Word16 nb_sig_snr; /* Q0 */
Word16 nv;
- Word16 nv_ofs; /* Q8 */
+ Word32 nv_ofs; /* Q24 */
Word32 L_snr_sum_HE_SAD; /* Q4 */
Word16 snr_sum_HE_SAD; /*Q8 log */
Word16 sign_thr_HE_SAD, min_snr_HE_SAD;
@@ -1934,13 +1960,14 @@ Word16 wb_vad_ivas_fx(
Word32 L_snr_sum_ol;
Word16 snr_sum_ol; /* Q8 log */
- Word32 L_snr_outlier;
+ Word32 L_snr_outlier, L_snr_outlier_Q4;
Word16 snr_outlier_index;
Word32 L_accum_ener_L;
Word32 L_accum_ener_H;
Word16 vad_bwidth_fx;
Word16 last_7k2_coder_type;
- Word16 q_shift;
+ Word16 q_shift, q_ener, q_diff1, q_diff2;
+ Word16 q_L_snr_sum_ol, e_snr, f_snr;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
move32();
@@ -1955,7 +1982,7 @@ Word16 wb_vad_ivas_fx(
move16(); /*thr1*/
move16(); /*thr2*/
move16(); /*nk*/
- move16(); /*nc*/
+ move32(); /*nc*/
move16(); /*th_clean*/
move16(); /*flag*/
@@ -1970,13 +1997,13 @@ Word16 wb_vad_ivas_fx(
}
if ( LT_16( lp_speech_fx, -100 * 256 ) )
{
- lp_speech_fx = st_fx->lp_speech_fx; /*Q8*/
+ lp_speech_fx = extract_h( st_fx->lp_speech_32fx ); /*Q8*/
move16();
}
if ( LT_16( lp_noise_fx, -100 * 256 ) )
{
- lp_noise_fx = st_fx->lp_noise_fx; /*Q8*/
+ lp_noise_fx = extract_h( st_fx->lp_noise_32fx ); /*Q8*/
move16();
}
@@ -2028,12 +2055,12 @@ Word16 wb_vad_ivas_fx(
{
nk = 3277;
move16(); /*0.1 Q15 */
- nc = 4122;
- move16(); /*16.1 Q8 */
- nv = 525;
- move16(); /* 2.05 Q8*/
- nv_ofs = 422;
- move16(); /* 1.65 Q8*/
+ nc = 270113178;
+ move32(); /*16.1 Q24 */
+ nv = 8397;
+ move16(); /* 2.05 Q12*/
+ nv_ofs = 27682406;
+ move32(); /* 1.65 Q24*/
th_clean = TH16_2_FX;
move16(); /* 35 Q8 */
sign_thr = 21;
@@ -2062,12 +2089,12 @@ Word16 wb_vad_ivas_fx(
// move16();
nk = 3277;
move16(); /* 0.1 Q15 */
- nc = 4096;
- move16(); /* 16.0 Q8 */
- nv = 1024;
- move16(); /* 4.0 Q8 */
- nv_ofs = 294;
- move16(); /*1.15 Q8*/
+ nc = 268435456;
+ move32(); /* 16.0 Q24 */
+ nv = 16384;
+ move16(); /* 4.0 Q12 */
+ nv_ofs = 19293798;
+ move32(); /*1.15 Q24*/
th_clean = TH8_1_FX;
move16(); /*20 Q8 */
sign_thr = 28;
@@ -2180,12 +2207,12 @@ Word16 wb_vad_ivas_fx(
nb_sig_snr = 20;
move16();
- pt1 = fr_bands;
- pt2 = fr_bands + NB_BANDS;
- pt3 = hNoiseEst->bckr_fx;
-
L_snr_sum = L_deposit_l( 0 );
L_snr_sum_HE_SAD = L_deposit_l( 0 );
+ Word16 q_snr_sum = 0;
+ Word16 q_snr_sum_HE_SAD = 0;
+ move16();
+ move16();
snr_sumt = 0;
move16();
L_mssnr_hov = L_deposit_l( 0 );
@@ -2199,81 +2226,89 @@ Word16 wb_vad_ivas_fx(
q_snr = 0;
move16();
move16();
- q_shift = add( sub( q_fr_bands, hNoiseEst->q_bckr ), 15 - 4 );
+
+ pt1 = fr_bands;
+ pt2 = fr_bands + NB_BANDS;
+ pt3 = hNoiseEst->bckr_fx;
+
+ q_ener = s_min( q_fr_bands, hNoiseEst->q_enrO );
+ q_diff1 = sub( q_ener, hNoiseEst->q_enrO );
+ q_diff2 = sub( q_ener, q_fr_bands );
+ q_shift = add( Q31 + Q1, sub( q_ener, hNoiseEst->q_bckr ) );
+
FOR( i = st_fx->min_band; i <= st_fx->max_band; i++ )
{
- ftmp = L_add( *pt1++, 0 );
- ftmp1 = L_add( *pt2++, 0 );
- ftmp2 = L_add( *pt3++, 0 );
+ ener = L_shl( hNoiseEst->enrO_fx[i], q_diff1 ); // q_ener
+ ftmp = L_shl( *pt1++, q_diff2 ); // q_ener
+ ftmp1 = L_shl( *pt2++, q_diff2 ); // q_ener
/*fr_enr = ( 0.2f * st->enrO[i] + 0.4f * ftmp + 0.4f * ftmp1 );*/
- L_tmp = Mult_32_16( hNoiseEst->enrO_fx[i], 13107 ); /* L_tmp(high word) = Qenr0fx*Q16+1 -16 -> Qener0+1 */
- L_tmp1 = Madd_32_16( L_tmp, ftmp, 26214 ); /* 26214 = .4 in Q16 */
- L_tmp1 = Madd_32_16( L_tmp1, ftmp1, 26214 ); /* L_tmp1 re_used a bit later for final snr[i]*/
-
- L_tmp2 = Madd_32_16( L_tmp, ftmp, 19661 ); /* 19661 = 0.3 in Q16 */
- L_tmp2 = Msub_32_16( L_tmp2, ftmp1, -32768 ); /* -32768= -0.5 in Q16 */
+ L_tmp = Mpy_32_16_1( ener, 13107 /* 0.2 in Q16 */ ); // q_ener+1
+ fr_enr = Madd_32_16( Madd_32_16( L_tmp, ftmp, 26214 /* 0.4 in Q16 */ ), ftmp1, 26214 /* 0.4 in Q16 */ ); // q_ener+1
IF( GT_32( ftmp, ftmp1 ) )
{
- /*snr[i] = ( 0.2f * st->enrO[i] + 0.4f * ftmp + 0.4f * ftmp1 ) / ftmp2 ;*/
- /*snr[i] = L_tmp1/(ftmp2) */
- IF( ftmp2 != 0 )
+ /* snr[i] = ( 0.2f * hNoiseEst->enrO[i] + 0.4f * ftmp + 0.4f * ftmp1 ) / *pt3++; */
+ IF( *pt3 != 0 )
{
- e_num = norm_l( L_tmp1 );
- m_num = extract_h( L_shl( L_tmp1, e_num ) ); // q_fr_bands+1+e_num-16
+ /* Since fr_enr = 0.2f * hNoiseEst->enrO[i] + 0.4f * ftmp + 0.4f * ftmp1 */
+ e_num = sub( norm_l( fr_enr ), 1 );
+ m_num = extract_h( L_shl( fr_enr, e_num ) ); // q_ener+1+e_num-16
- e_noise = norm_l( ftmp2 );
- m_noise_local = extract_h( L_shl( ftmp2, e_noise ) ); // hNoiseEst->q_bckr+e_noise-16
-
- m_num = shr( m_num, 1 ); // q_fr_bands+e_num-16
- shift_snr = add( sub( e_num, e_noise ), q_shift );
+ e_noise = norm_l( *pt3 );
+ m_noise_local = extract_h( L_shl( *pt3++, e_noise ) ); // hNoiseEst->q_bckr+e_noise-16
- snr_tmp = div_s( m_num, m_noise_local ); // q_fr_bands+e_num-hNoiseEst->q_bckr-e_noise
- L_snr = L_shr_o( snr_tmp, shift_snr, &Overflow ); /* L_snr in Q4 */
+ L_snr = L_deposit_h( div_s( m_num, m_noise_local ) ); // 31+(q_ener+1+e_num-16)-(hNoiseEst->q_bckr+e_noise-16)
+ q_snr_tmp = add( q_shift, sub( e_num, e_noise ) );
}
ELSE
{
- L_snr = L_shr_o( L_tmp1, sub( Q3, q_fr_bands ), &Overflow ); // q_fr_bands+1 -> Q4
+ L_snr = Mpy_32_16_1( fr_enr, 18286 /* (1/E_MIN) in Q6 */ ); // q_ener+1+6-15
+ q_snr_tmp = sub( q_ener, 8 );
}
}
ELSE
{
- /*snr[i] = ( 0.2f * st->enrO[i] + 0.3f * ftmp + 0.5f * ftmp1 ) / ftmp2 ;*/
- /*snr[i] =L_tmp2/( ftmp2 ) */
- IF( ftmp2 != 0 )
- {
- e_num = norm_l( L_tmp2 );
- m_num = extract_h( L_shl( L_tmp2, e_num ) ); // q_fr_bands+1+e_num-16
+ /* snr[i] = ( 0.2f * hNoiseEst->enrO[i] + 0.3f * ftmp + 0.5f * ftmp1 ) / *pt3++; */
+ /* Since, L_tmp = 0.2f * hNoiseEst->enrO[i] */
+ L_tmp = Msub_32_16( Madd_32_16( L_tmp, ftmp, 19661 /* 0.3 in Q16 */ ), ftmp1, -32768 /* -0.5 in Q16 */ ); // q_ener+1
- e_noise = norm_l( ftmp2 );
- m_noise_local = extract_h( L_shl( ftmp2, e_noise ) ); // hNoiseEst->q_bckr+e_noise-16
+ IF( *pt3 != 0 )
+ {
+ e_num = sub( norm_l( L_tmp ), 1 );
+ m_num = extract_h( L_shl( L_tmp, e_num ) ); // q_ener+1+e_num-16
- m_num = shr( m_num, 1 ); // q_fr_bands+e_num-16
- shift_snr = add( sub( e_num, e_noise ), q_shift );
+ e_noise = norm_l( *pt3 );
+ m_noise_local = extract_h( L_shl( *pt3++, e_noise ) ); // hNoiseEst->q_bckr+e_noise-16
- snr_tmp = div_s( m_num, m_noise_local ); // q_fr_bands+e_num-hNoiseEst->q_bckr-e_noise
- L_snr = L_shr_o( snr_tmp, shift_snr, &Overflow ); /* L_snr in Q4 */
+ L_snr = L_deposit_h( div_s( m_num, m_noise_local ) ); // 31+(q_ener+1+e_num-16)-(hNoiseEst->q_bckr+e_noise-16)
+ q_snr_tmp = add( q_shift, sub( e_num, e_noise ) );
}
ELSE
{
- L_snr = L_shr_o( L_tmp2, sub( Q3, q_fr_bands ), &Overflow ); // q_fr_bands+1 -> Q4
+ L_snr = Mpy_32_16_1( L_tmp, 18286 /* (1/E_MIN) in Q6 */ ); // q_ener+1+6-15
+ q_snr_tmp = sub( q_ener, 8 );
}
}
- IF( LT_32( L_snr, 2 * ( 1 << 4 ) ) )
+ if ( LT_32( L_snr, L_shl_sat( 2, q_snr_tmp ) ) )
{
nb_sig_snr = sub( nb_sig_snr, 1 ); /* nb_sig_snr--; */
}
- L_snr = L_max( L_snr, 1 * ( 1 << 4 ) ); /* if ( snr[i] < 1 ){snr[i] = 1;}*/
-
+ IF( LT_32( L_snr, L_shl_sat( 1, q_snr_tmp ) ) )
+ {
+ L_snr = ONE_IN_Q30;
+ q_snr_tmp = Q30;
+ move32();
+ move16();
+ }
/* snr[i] = (float)log10(snr[i]); */
Word16 exp = norm_l( L_snr );
Word16 val = Log2_norm_lc( L_shl( L_snr, exp ) );
- exp = sub( sub( 30, exp ), Q4 );
- L_snr = L_mac( L_deposit_h( exp ), val, 1 ); // Q16
- L_snr = Mpy_32_16_1( L_snr, 9864 /* log2 in Q15 */ ); // Q16
+ exp = sub( sub( 30, exp ), q_snr_tmp );
+ L_snr = L_mac( val, exp, ONE_IN_Q14 ); // Q15
+ L_snr = Mpy_32_16_1( L_snr, 19728 /* log2 in Q16 */ ); // Q16
/* snr_sumt += snr[i];*/
L_snr_sumt = L_add( L_snr_sumt, L_snr ); // Q16
@@ -2346,29 +2381,35 @@ Word16 wb_vad_ivas_fx(
L_mssnr_hov = BASOP_Util_Add_Mant32Exp( L_mssnr_hov, L_mssnr_hov_e, L_msnr, L_msnr_e, &L_mssnr_hov_e ); /*L_mssnr_hov_e mssnr_hov += msnr; */
/* recompute after he1 modifications */
- /* snr[i] = fr_enr / st->bckr[i] = L_tmp1/st->bckr[i];*/
+ /* snr[i] = fr_enr / st->bckr[i] ;*/
IF( hNoiseEst->bckr_fx[i] != 0 )
{
- e_num = sub( norm_l( L_tmp1 ), 1 );
- m_num = extract_h( L_shl( L_tmp1, e_num ) ); // q_fr_bands+1+e_num-16
+ e_num = sub( norm_l( fr_enr ), 1 );
+ m_num = extract_h( L_shl( fr_enr, e_num ) ); // q_ener+1+e_num-16
e_noise = norm_l( hNoiseEst->bckr_fx[i] );
m_noise_local = extract_h( L_shl( hNoiseEst->bckr_fx[i], e_noise ) ); // hNoiseEst->q_bckr+e_noise-16
- L_snr_tmp = L_deposit_h( div_s( m_num, m_noise_local ) ); // 32+q_fr_bands+e_num-hNoiseEst->q_bckr-e_noise
- q_snr_tmp = add( 32, sub( add( q_fr_bands, e_num ), add( hNoiseEst->q_bckr, e_noise ) ) );
+ L_snr_tmp = L_deposit_h( div_s( m_num, m_noise_local ) ); // 31+q_ener+1+e_num-hNoiseEst->q_bckr-e_noise
+ q_snr_tmp = add( 32, sub( add( q_ener, e_num ), add( hNoiseEst->q_bckr, e_noise ) ) );
}
ELSE
{
- L_snr_tmp = Mpy_32_16_1( L_tmp1, 18286 /* 1/E_MIN in Q6 */ ); // q_fr_bands-8
- q_snr_tmp = sub( q_fr_bands, 8 );
+ L_snr_tmp = Mpy_32_16_1( fr_enr, 18286 /* 1/E_MIN in Q6 */ ); // q_ener+1+6-15
+ q_snr_tmp = sub( q_ener, 8 );
}
/* conditional snrsum, snr_sum = snr_sum + snr[i];*/
+ IF( GT_16( q_snr_tmp, 28 ) ) // added to avoid overflow while scaling sign_thr_HE_SAD,min_snr_HE_SAD,sign_thr and min_snr while scaling to q_snr_tmp
+ {
+ L_snr_tmp = L_shl( L_snr_tmp, sub( 28, q_snr_tmp ) );
+ q_snr_tmp = 28;
+ move16();
+ }
exp = sub( Q4, q_snr_tmp );
L_snr = L_shl_sat( L_snr_tmp, exp ); // Q4
- sign_thr_snr_acc_fx( &L_snr_sum_HE_SAD, L_snr, sign_thr_HE_SAD, min_snr_HE_SAD );
- sign_thr_snr_acc_fx( &L_snr_sum, L_snr, sign_thr, min_snr );
+ sign_thr_snr_acc_ivas_fx( &L_snr_sum_HE_SAD, &q_snr_sum_HE_SAD, L_snr_tmp, q_snr_tmp, L_shl( sign_thr_HE_SAD, sub( q_snr_tmp, 4 ) ), L_shl( min_snr_HE_SAD, sub( q_snr_tmp, 4 ) ) );
+ sign_thr_snr_acc_ivas_fx( &L_snr_sum, &q_snr_sum, L_snr_tmp, q_snr_tmp, L_shl( sign_thr, sub( q_snr_tmp, 4 ) ), L_shl( min_snr, sub( q_snr_tmp, 4 ) ) );
/* if( snr[i] < 1.0f ) { snr[i] = 1.0f;} */
IF( LT_32( L_snr, 16 /* 1.0 in Q4 */ ) )
@@ -2412,10 +2453,10 @@ Word16 wb_vad_ivas_fx(
move16();
move16();
}
- } /* end of band loop */
+ } /* end of band loop */
+ L_snr_sum_HE_SAD = L_shl_o( L_snr_sum_HE_SAD, sub( 4, q_snr_sum_HE_SAD ), &Overflow ); // q_snr_sum_HE_SAD->q4
- L_snr_outlier = L_shl_sat( L_snr_outlier, sub( Q4, q_snr ) ); // q_snr -> Q4
- snr_sumt = extract_h( L_shl( L_snr_sumt, Q4 ) ); // Q16 -> Q4
+ snr_sumt = extract_h( L_shl( L_snr_sumt, Q4 ) ); // Q16 -> Q4
test();
test();
@@ -2447,51 +2488,66 @@ Word16 wb_vad_ivas_fx(
}
}
+ L_snr_outlier_Q4 = L_shl_sat( L_snr_outlier, sub( Q4, q_snr ) ); // Q4
/* Separated SNR_SUM outlier modification */
- L_snr_sum_ol = L_snr_sum; /* snr_sum_ol = snr_sum; */
+ /* snr_sum_ol = snr_sum; */
+ L_snr_sum_ol = L_snr_sum; // q_snr_sum
+ q_L_snr_sum_ol = q_snr_sum;
move32();
+ move16();
test();
test();
test();
- IF( ( EQ_16( st_fx->max_band, 19 ) ) && LT_32( L_snr_outlier, MAX_SNR_OUTLIER_3_FX ) && GT_16( snr_outlier_index, 3 ) && LT_16( snr_outlier_index, MAX_SNR_OUTLIER_IND_FX ) )
+ IF( ( EQ_16( st_fx->max_band, 19 ) ) && LT_32( L_snr_outlier_Q4, MAX_SNR_OUTLIER_3_FX ) && GT_16( snr_outlier_index, 3 ) && LT_16( snr_outlier_index, MAX_SNR_OUTLIER_IND_FX ) )
{
+ q_L_snr_sum_ol = s_min( add( norm_l( L_snr_sum_ol ), q_snr_sum ), add( norm_l( L_snr_outlier ), q_snr ) );
+ L_tmp1 = L_shl( L_snr_sum_ol, sub( q_L_snr_sum_ol, q_snr_sum ) ); // q_L_snr_sum_ol
+ L_tmp2 = L_shl( L_snr_outlier, sub( q_L_snr_sum_ol, q_snr ) ); // q_L_snr_sum_ol
test();
test();
IF( LT_32( L_accum_ener_H, Mult_32_16( L_accum_ener_L, INV_OUTLIER_THR_1_FX ) ) /* float:: (accum_ener_L*INV_OUTLIER_THR_1 > accum_ener_H ) !!! */
- || LT_32( L_snr_outlier, MAX_SNR_OUTLIER_1_FX ) )
+ || LT_32( L_snr_outlier_Q4, MAX_SNR_OUTLIER_1_FX ) )
{
- /* as weight1 is 1.0 we do not need to multiply here , i.e. no need to loose any precisison */
- L_snr_sum_ol = L_sub( L_snr_sum_ol, L_snr_outlier ); /*Q4 */
+ /* snr_sum_ol = SNR_OUTLIER_WGHT_1 * ( snr_sum_ol - snr_outlier );
+ As SNR_OUTLIER_WGHT_1 is 1.0f we do not need to multiply here , i.e. no need to loose any precisison */
+ L_snr_sum_ol = L_sub( L_tmp1, L_tmp2 ); // q_L_snr_sum_ol
}
ELSE IF( LT_32( L_accum_ener_H, Mult_32_16( L_accum_ener_L, INV_OUTLIER_THR_2_FX ) ) /* float:: (accum_ener_L *INV_OUTLIER_THR_2 > accum_ener_H ) !!! */
- || LT_32( L_snr_outlier, MAX_SNR_OUTLIER_2_FX ) )
+ || LT_32( L_snr_outlier_Q4, MAX_SNR_OUTLIER_2_FX ) )
{
- /* L_snr_sum = SNR_OUTLIER_WGHT_2 * (snr_sum - snr_outlier); */
-
- /* 1.01*x -> (1*x + 0.01*x) to not drop down to Q3 */
- L_tmp = L_sub( L_snr_sum_ol, L_snr_outlier );
- L_tmp2 = Mult_32_16( L_tmp, 20972 ); /* 0.01(in Q21)= 20972 Q4*Q21+1-16 -> Q10 */
- L_snr_sum_ol = L_add( L_tmp, L_shr( L_tmp2, 6 ) ); /* Q4 */
+ /* snr_sum_ol = SNR_OUTLIER_WGHT_2 * (snr_sum_ol - snr_outlier); */
+ L_snr_sum_ol = Mpy_32_32( 1084479242 /* 1.01f in Q30 */, L_sub( L_tmp1, L_tmp2 ) ); // q_L_snr_sum_ol+30-31
+ q_L_snr_sum_ol = sub( q_L_snr_sum_ol, 1 );
}
ELSE
{
- /* L_snr_sum = SNR_OUTLIER_WGHT_3 * (snr_sum - snr_outlier);*/
- /* 1.02*x -> (1*x + 0.02*x) to not drop down to Q3 */
- L_tmp = L_sub( L_snr_sum_ol, L_snr_outlier );
- L_tmp2 = Mult_32_16( L_tmp, 20972 ); /* 0.02(in Q20)= 20972 Q4*Q20+1-16 -> Q9 */
- L_snr_sum_ol = L_add( L_tmp, L_shr( L_tmp2, 5 ) ); /* Q4 */
+ /* snr_sum_ol = SNR_OUTLIER_WGHT_2 * (snr_sum_ol - snr_outlier); */
+ L_snr_sum_ol = Mpy_32_32( 1095216660 /* 1.02f in Q30 */, L_sub( L_tmp1, L_tmp2 ) ); // q_L_snr_sum_ol+30-31
+ q_L_snr_sum_ol = sub( q_L_snr_sum_ol, 1 );
}
}
/*st_fx->snr_sum_vad_fx = 0.5f * st->snr_sum_vad + 0.5f * snr_sum_ol;*/
- hVAD->L_snr_sum_vad_fx = L_shr( L_add_o( hVAD->L_snr_sum_vad_fx, L_snr_sum_ol, &Overflow ), 1 ); /*Q4*/
+ q_snr_tmp = s_min( add( hVAD->q_L_snr_sum_vad, norm_l( hVAD->L_snr_sum_vad_fx ) ), add( norm_l( L_snr_sum_ol ), q_L_snr_sum_ol ) );
+ /* 0.5f * st->snr_sum_vad */
+ L_tmp1 = L_shl( hVAD->L_snr_sum_vad_fx, sub( sub( q_snr_tmp, 1 ), hVAD->q_L_snr_sum_vad ) ); // q_snr_tmp
+ /* 0.5f * snr_sum_ol */
+ L_tmp2 = L_shl( L_snr_sum_ol, sub( sub( q_snr_tmp, 1 ), q_L_snr_sum_ol ) ); // q_snr_tmp
+ hVAD->L_snr_sum_vad_fx = L_add( L_tmp1, L_tmp2 ); // q_snr_tmp
+ hVAD->q_L_snr_sum_vad = q_snr_tmp;
move32();
+ move16();
/* snr_sum_ol = 10.0f * (float)log10( snr_sum_ol ); */
- snr_sum_ol = vad_snr_log_fx( L_snr_sum_ol, LG10 );
+ e_snr = norm_l( L_snr_sum_ol );
+ f_snr = Log2_norm_lc( L_shl( L_snr_sum_ol, e_snr ) ); // Q15
+ e_snr = sub( sub( 30, e_snr ), q_L_snr_sum_ol );
+ L_tmp = L_mac( f_snr, e_snr, ONE_IN_Q14 ); // Q15
+ L_snr_sum_ol = Mpy_32_16_1( L_tmp, 24660 /* 10*log(2) in Q13 */ ); // Q13
+ snr_sum_ol = extract_h( L_shl( L_snr_sum_ol, Q24 - Q13 ) ); // Q8
snr_sum = snr_sum_ol;
move16(); /* note for NB no outlier modification */
@@ -2520,9 +2576,9 @@ Word16 wb_vad_ivas_fx(
/*thr1 = nk * lp_snr + nc*1.0 + nv * ( st->Etot_v_h2 - nv_ofs); */ /* Linear function for noisy speech */
- L_tmp = L_shl( L_mult( sub( hNoiseEst->Etot_v_h2_fx, nv_ofs ), nv ), 7 ); /* Q8+Q8+1 +7 --> Q24 */
- L_tmp = L_mac( L_tmp, nc, (Word16) 32767 ); /* Q8+Q15+1 = Q24 */
- thr1 = mac_r( L_tmp, lp_snr, nk ); /* Q8+Q15+1 - 16 --> Q8 */
+ L_tmp = L_shl( Mpy_32_16_1( L_sub( hNoiseEst->Etot_v_h2_32fx, nv_ofs ), nv ), 3 ); // Q24 (24+12-15+3)
+ L_tmp = L_add( L_tmp, nc ); // Q24
+ thr1 = mac_r( L_tmp, lp_snr, nk ); // Q24
test();
IF( st_fx->element_mode > EVS_MONO && LT_16( hNoiseEst->first_noise_updt_cnt, 100 ) )
@@ -2589,33 +2645,38 @@ Word16 wb_vad_ivas_fx(
test();
IF( ( LE_16( snr_outlier_index, 4 ) && ( st_fx->last_coder_type > UNVOICED ) && !st_fx->Opt_SC_VBR ) ||
( LE_16( snr_outlier_index, 4 ) && ( last_7k2_coder_type > UNVOICED ) && st_fx->Opt_SC_VBR ) )
-
-
{
- thr1_ol = sub( thr1_ol, (Word16) ( 1 << 8 ) ); /*thr1_ol = thr1 - 1.0f ; */
+ /*thr1_ol = thr1 - 1.0f ; */
+ thr1_ol = sub( thr1, ONE_IN_Q8 ); // Q8
+
/*snr_sum_ol = 10.0f * (float)log10( hVAD->L_snr_sum_vad_fx );*/
- snr_sum_ol = vad_snr_log_fx( hVAD->L_snr_sum_vad_fx, LG10 ); /* snr in Q8 */
+ e_snr = norm_l( hVAD->L_snr_sum_vad_fx );
+ f_snr = Log2_norm_lc( L_shl( hVAD->L_snr_sum_vad_fx, e_snr ) ); // Q15
+ e_snr = sub( sub( 30, e_snr ), hVAD->q_L_snr_sum_vad );
+ L_tmp = L_mac( f_snr, e_snr, ONE_IN_Q14 ); // Q15
+ L_snr_sum_ol = Mpy_32_16_1( L_tmp, 24660 /* 10*log(2) in Q13 */ ); // Q13
+ snr_sum_ol = round_fx( L_shl( L_snr_sum_ol, Q24 - Q13 ) ); // Q8
}
- ELSE IF( ( ( LE_16( st_fx->last_coder_type, UNVOICED ) ) && ( LT_32( L_snr_outlier, MAX_SNR_OUTLIER_2_FX ) ) && ( st_fx->Opt_SC_VBR == 0 ) ) ||
- ( ( LE_16( last_7k2_coder_type, UNVOICED ) ) && ( LT_32( L_snr_outlier, MAX_SNR_OUTLIER_2_FX ) ) && ( st_fx->Opt_SC_VBR != 0 ) ) )
-
+ ELSE IF( ( ( LE_16( st_fx->last_coder_type, UNVOICED ) ) && ( LT_32( L_snr_outlier_Q4, MAX_SNR_OUTLIER_2_FX ) ) && ( st_fx->Opt_SC_VBR == 0 ) ) ||
+ ( ( LE_16( last_7k2_coder_type, UNVOICED ) ) && ( LT_32( L_snr_outlier_Q4, MAX_SNR_OUTLIER_2_FX ) ) && ( st_fx->Opt_SC_VBR != 0 ) ) )
{
/* thr1_ol = thr1 + (float)(1.0f - 0.04f * snr_outlier); */
- L_tmp2 = Msub_32_16( (Word32) ( 1 << ( 24 - 16 ) ), L_snr_outlier, 20972 ); /* (1.0)Q24(Q8 in high 32bit word) - Q4*Q19+1 */
- tmp2 = round_fx( L_shl( L_tmp2, 16 ) ); /* high word is in Q8 */
- thr1_ol = add( thr1_ol, tmp2 ); /* (Q8 , Q8) */
+ L_tmp = Mpy_32_16_1( L_snr_outlier, 20972 /*0.04f in Q19*/ ); // q_snr+19-15
+ L_tmp = L_shl( L_tmp, sub( Q24 - 4, q_snr ) ); // Q24 (24-(q_nsr+4))
+ tmp2 = round_fx( L_sub( ONE_IN_Q24, L_tmp ) ); // Q8
+ thr1_ol = add( thr1, tmp2 ); // Q8
}
ELSE
{
- /*thr1_ol = thr1 + max(0, (float)(0.6f - 0.01f * L_snr_outlier)); */
- thr1_ol = thr1;
- move16();
- L_tmp2 = Msub_32_16( (Word32) 614, L_snr_outlier, 20972 ); /* .6*1024= */ /* 0.6 Q26(Q10 in high word) - Q4*Q21+1 */
- tmp2 = round_fx( L_shl_o( L_tmp2, 14, &Overflow ) ); /* Q10(high word)+ 14 -16 --> Q8*/
- IF( L_tmp2 > 0 )
- {
- thr1_ol = add( thr1_ol, tmp2 ); /* Q24 >>16 + Q8 */
- }
+ /*thr1_ol = thr1 + max(0, (float)(0.6f - 0.01f * snr_outlier)); */
+ /* Saturation is added in the below step for 0.04f * snr_outlier in Q24.
+ In case of saturation, 0.04f * snr_outlier will be much greater than 0.6f and (0.6f - 0.01f * snr_outlier) becomes negative.
+ max(0, (float)(0.6f - 0.01f * snr_outlier)) gives zero. Hence addition of saturation has no impact */
+ L_tmp = Mpy_32_16_1( L_snr_outlier, 20972 /*0.04f in Q21*/ ); // q_snr+21-15
+ L_tmp = L_shl_sat( L_tmp, sub( Q24 - 6, q_snr ) ); // Q24 (24-(q_nsr+6))
+ tmp2 = round_fx( L_sub( 10066330 /* 0.6 in Q24*/, L_tmp ) ); // Q8
+ tmp2 = s_max( 0, tmp2 ); // Q8
+ thr1_ol = add( thr1, tmp2 ); // Q8
}
}
diff --git a/lib_rend/ivas_dirac_ana_fx.c b/lib_rend/ivas_dirac_ana_fx.c
index c2430d008f8f644170650776b450055cffa1c46b..df75d6d0a0cb1386eea1389ad2794449d96b99cb 100644
--- a/lib_rend/ivas_dirac_ana_fx.c
+++ b/lib_rend/ivas_dirac_ana_fx.c
@@ -127,7 +127,21 @@ ivas_error ivas_dirac_ana_open_fx(
}
set32_fx( hDirAC->direction_vector_m_fx[i][j], 0, MASA_FREQUENCY_BANDS );
}
+ IF( ( hDirAC->direction_vector_e[i] = (Word16 **) malloc( MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( Word16 * ) ) ) == NULL )
+ {
+ return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for OMASA data\n" ) );
+ }
+
+ FOR( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ )
+ {
+ IF( ( hDirAC->direction_vector_e[i][j] = (Word16 *) malloc( MASA_FREQUENCY_BANDS * sizeof( Word16 ) ) ) == NULL )
+ {
+ return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for OMASA data\n" ) );
+ }
+ set16_fx( hDirAC->direction_vector_e[i][j], 31, MASA_FREQUENCY_BANDS );
+ }
}
+
FOR( i = 0; i < DIRAC_NUM_DIMS; i++ )
{
FOR( j = 0; j < DIRAC_NO_COL_AVG_DIFF; j++ )
@@ -140,7 +154,8 @@ ivas_error ivas_dirac_ana_open_fx(
}
}
set32_fx( hDirAC->buffer_energy_fx, 0, DIRAC_NO_COL_AVG_DIFF * MASA_FREQUENCY_BANDS );
-
+ set16_fx( hDirAC->buffer_intensity_real_q, 31, DIRAC_NO_COL_AVG_DIFF );
+ set16_fx( hDirAC->buffer_energy_q, 31, DIRAC_NO_COL_AVG_DIFF );
hDirAC->index_buffer_intensity = 0;
move16();
@@ -194,6 +209,15 @@ void ivas_dirac_ana_close_fx(
free( ( *hDirAC )->direction_vector_m_fx[i] );
( *hDirAC )->direction_vector_m_fx[i] = NULL;
+ FOR( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ )
+ {
+ free( ( *hDirAC )->direction_vector_e[i][j] );
+ ( *hDirAC )->direction_vector_e[i][j] = NULL;
+ }
+
+ free( ( *hDirAC )->direction_vector_e[i] );
+ ( *hDirAC )->direction_vector_e[i] = NULL;
+
FOR( j = 0; j < DIRAC_NO_COL_AVG_DIFF; j++ )
{
free( ( *hDirAC )->buffer_intensity_real_fx[i][j] );
@@ -231,15 +255,11 @@ void ivas_dirac_ana_fx(
Word32 energyRatio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];
Word32 spreadCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];
Word32 surroundingCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];
- Word16 energyRatio_q, surroundingCoherence_q = 0, spreadCoherence_q = 0;
- move16();
- move16();
/* Estimate MASA parameters from the SBA signals */
ivas_dirac_param_est_ana_fx( hDirAC, data_fx, elevation_m_values, azimuth_m_values, energyRatio, spreadCoherence, surroundingCoherence, input_frame );
- energyRatio_q = 30;
- move16();
/* Create MASA metadata buffer from the estimated values */
- ivas_create_masa_out_meta_fx( hDirAC->hMasaOut, hDirAC->sph_grid16, nchan_transport, elevation_m_values, azimuth_m_values, energyRatio, spreadCoherence, surroundingCoherence, energyRatio_q, spreadCoherence_q, surroundingCoherence_q );
+
+ ivas_create_masa_out_meta_fx( hDirAC->hMasaOut, hDirAC->sph_grid16, nchan_transport, elevation_m_values, azimuth_m_values, energyRatio, spreadCoherence, surroundingCoherence, Q31, Q31, Q31 );
/* Downmix */
ivas_dirac_dmx_fx( data_fx, input_frame, nchan_transport ); // output Q of data_fx is same as that of input
@@ -255,39 +275,38 @@ void ivas_dirac_ana_fx(
/* Estimate MASA parameters from the SBA signals */
static void ivas_dirac_param_est_ana_fx(
DIRAC_ANA_HANDLE hDirAC,
- Word32 data_fx[][L_FRAME48k], /* Q7 */
- Word32 elevation_m_values[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* Q22 */
- Word32 azimuth_m_values[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* Q22 */
- Word32 energyRatio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* Q30 */
- Word32 spreadCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* Qx */
- Word32 surroundingCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* Qx */
+ Word32 data_fx[][L_FRAME48k], /* Q7 */
+ 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], /* Q30 */
+ Word32 spreadCoherence_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* Qx */
+ Word32 surroundingCoherence_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* Qx */
const Word16 input_frame )
{
Word32 reference_power_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
Word16 ts, i, d, j;
Word16 num_freq_bands, index;
- Word32 dir_v[DIRAC_NUM_DIMS];
- Word16 dir_q;
+ Word32 dir_v_fx[DIRAC_NUM_DIMS];
+ Word16 dir_v_q;
Word16 l_ts;
Word32 Foa_RealBuffer_fx[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX];
Word32 Foa_ImagBuffer_fx[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX];
Word32 intensity_real_fx[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS];
Word32 direction_vector_fx[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS];
- Word16 diffuseness_vector_exp[MASA_FREQUENCY_BANDS];
Word32 diffuseness_vector_fx[MASA_FREQUENCY_BANDS];
Word32 diffuseness_m_fx[MASA_FREQUENCY_BANDS];
-
+ Word16 diffuseness_e[MASA_FREQUENCY_BANDS];
+ Word16 diffuseness_q = 0;
+ move16();
Word16 band_m_idx, block_m_idx;
Word32 renormalization_factor_diff_fx[MASA_FREQUENCY_BANDS];
+ Word16 renormalization_factor_diff_e[MASA_FREQUENCY_BANDS];
Word32 norm_tmp_fx;
Word16 mrange[2];
Word16 brange[2];
Word16 numAnalysisChannels;
- Word16 io_q;
- Word16 scale_fact, scale_fact2;
- Word16 q_factor_intensity, q_factor_intensity_old = 0;
- Word16 q_factor_energy = 0, q_factor_energy_old = 0;
- Word16 exp = 0, exp_div = 0;
+ Word16 inp_q;
+ Word16 intensity_q, reference_power_q;
num_freq_bands = hDirAC->nbands;
/* l_ts = input_frame / CLDFB_NO_COL_MAX; */
l_ts = shr( input_frame, 4 );
@@ -317,34 +336,46 @@ static void ivas_dirac_param_est_ana_fx(
move32();
hDirAC->direction_vector_m_fx[2][block_m_idx][band_m_idx] = 0;
move32();
+
+ hDirAC->direction_vector_e[0][block_m_idx][band_m_idx] = 0;
+ move16();
+ hDirAC->direction_vector_e[1][block_m_idx][band_m_idx] = 0;
+ move16();
+ hDirAC->direction_vector_e[2][block_m_idx][band_m_idx] = 0;
+ move16();
}
/* Need to initialize renormalization_factors, and variables to be normalized */
set32_fx( renormalization_factor_diff_fx, 0, hDirAC->nbands );
+ set16_fx( renormalization_factor_diff_e, 31, hDirAC->nbands );
set32_fx( diffuseness_m_fx, 0, hDirAC->nbands );
+ set16_fx( diffuseness_e, 0, hDirAC->nbands );
set32_fx( hDirAC->energy_fx[block_m_idx], 0, MASA_FREQUENCY_BANDS );
- set32_fx( hDirAC->energy_fx[block_m_idx], 0, MASA_FREQUENCY_BANDS );
+ set16_fx( hDirAC->energy_e[block_m_idx], 0, MASA_FREQUENCY_BANDS );
FOR( ts = mrange[0]; ts < mrange[1]; ts++ )
{
+ Word16 cr_q = MAX_16, ci_q = MAX_16, sf, c_e;
+ inp_q = Q7; // Input Q of data_fx
+ move16();
+ move16();
+ move16();
FOR( i = 0; i < numAnalysisChannels; i++ )
{
- io_q = Q7; // Input Q of data_fx
+ inp_q = Q7;
move16();
- cldfbAnalysis_ts_fx_fixed_q( &( data_fx[i][imult1616( l_ts, ts )] ), Foa_RealBuffer_fx[i], Foa_ImagBuffer_fx[i], l_ts, hDirAC->cldfbAnaEnc[i], &io_q );
+ cldfbAnalysis_ts_fx_var_q( &( data_fx[i][l_ts * ts] ), Foa_RealBuffer_fx[i], Foa_ImagBuffer_fx[i], l_ts, hDirAC->cldfbAnaEnc[i], &inp_q );
+ cr_q = s_min( cr_q, getScaleFactor32( Foa_RealBuffer_fx[i], CLDFB_NO_CHANNELS_MAX ) );
+ ci_q = s_min( ci_q, getScaleFactor32( Foa_ImagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX ) );
}
- scale_fact = getScaleFactor32( (const Word32 *) Foa_RealBuffer_fx, FOA_CHANNELS * CLDFB_NO_CHANNELS_MAX );
- scale_fact = s_min( getScaleFactor32( (const Word32 *) Foa_ImagBuffer_fx, FOA_CHANNELS * CLDFB_NO_CHANNELS_MAX ), scale_fact );
- FOR( i = 0; i < DIRAC_NUM_DIMS; i++ )
+ sf = sub( s_min( cr_q, ci_q ), 4 );
+ FOR( i = 0; i < numAnalysisChannels; i++ )
{
- FOR( j = 0; j < MASA_FREQUENCY_BANDS; j++ )
- {
- Foa_RealBuffer_fx[i][j] = L_shl( Foa_RealBuffer_fx[i][j], sub( scale_fact, Q3 ) ); // Q( scale_fact + Q1 )
- move32();
- Foa_ImagBuffer_fx[i][j] = L_shl( Foa_ImagBuffer_fx[i][j], sub( scale_fact, Q3 ) ); // Q( scale_fact + Q1 )
- move32();
- }
+ scale_sig32( Foa_RealBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, sf ); // Q-> inp_q + sf
+ scale_sig32( Foa_ImagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, sf ); // Q-> inp_q + sf
}
+ inp_q = add( inp_q, sf );
+ c_e = sub( 31, inp_q );
/* Compute omni energy for metadata processing */
FOR( band_m_idx = 0; band_m_idx < num_freq_bands; band_m_idx++ )
{
@@ -354,191 +385,80 @@ static void ivas_dirac_param_est_ana_fx(
move16();
FOR( j = brange[0]; j < brange[1]; j++ )
{
- hDirAC->energy_fx[block_m_idx][band_m_idx] = ( L_add( hDirAC->energy_fx[block_m_idx][band_m_idx], L_add( Mpy_32_32( Foa_RealBuffer_fx[0][j], Foa_RealBuffer_fx[0][j] ), Mpy_32_32( Foa_ImagBuffer_fx[0][j], Foa_ImagBuffer_fx[0][j] ) ) ) ); // 2*( scale_fact + Q1 )-31
+ Word32 temp = L_add( Mult_32_32( Foa_RealBuffer_fx[0][j], Foa_RealBuffer_fx[0][j] ), Mult_32_32( Foa_ImagBuffer_fx[0][j], Foa_ImagBuffer_fx[0][j] ) ); // Q-> 2*inp_q - 31, e = 31 - (2*inp_q - 31) = 62 - 2*inp_q = 2*(31 - inp_q) = 2*c_e
+ hDirAC->energy_fx[block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hDirAC->energy_fx[block_m_idx][band_m_idx], hDirAC->energy_e[block_m_idx][band_m_idx], temp, shl( c_e, 1 ), &hDirAC->energy_e[block_m_idx][band_m_idx] );
move32();
}
}
/* Direction estimation */
- computeIntensityVector_ana_fx( hDirAC->band_grouping, Foa_RealBuffer_fx, Foa_ImagBuffer_fx, num_freq_bands, intensity_real_fx ); // 2 * ( scale_fact + Q1 ) - 31
- exp = sub( shl( sub( scale_fact, Q1 ), 1 ), 31 );
-
- computeDirectionVectors_fx( 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], &exp );
+ computeIntensityVector_ana_fx( hDirAC->band_grouping, Foa_RealBuffer_fx, Foa_ImagBuffer_fx, num_freq_bands, intensity_real_fx ); /* Q intensity_real_fx = 2*inp_q-31, e = 31 - 2*inp_q + 31 = 62 - 2*inp_q = 2*(31-inp_q)=2*c_e */
+ intensity_q = sub( 31, shl( c_e, 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], shl( c_e, 1 ), NULL );
/* Power estimation for diffuseness */
computeReferencePower_ana_fx( hDirAC->band_grouping, Foa_RealBuffer_fx, Foa_ImagBuffer_fx, reference_power_fx[ts], num_freq_bands ); //( 2 * ( scale_fact - Q1 ) - 31 - 1 ); // computeReferencePower_ana( hDirAC->band_grouping, Foa_RealBuffer, Foa_ImagBuffer, reference_power[ts], num_freq_bands );
-
+ reference_power_q = sub( shl( inp_q, 1 ), 30 );
/* Fill buffers of length "averaging_length" time slots for intensity and energy */
hDirAC->index_buffer_intensity = add( ( hDirAC->index_buffer_intensity % DIRAC_NO_COL_AVG_DIFF ), 1 ); /* averaging_length = 32 */
move16();
index = hDirAC->index_buffer_intensity;
move16();
- Word16 guard_bits = find_guarded_bits_fx( DIRAC_NO_COL_AVG_DIFF );
- scale_fact2 = getScaleFactor32( (const Word32 *) intensity_real_fx, DIRAC_NUM_DIMS * MASA_FREQUENCY_BANDS );
- IF( GT_16( guard_bits, scale_fact2 ) )
- {
- FOR( i = 0; i < DIRAC_NUM_DIMS; i++ )
- {
- FOR( j = 0; j < MASA_FREQUENCY_BANDS; j++ )
- {
- intensity_real_fx[i][j] = L_shr( intensity_real_fx[i][j], sub( guard_bits, scale_fact2 ) );
- move32();
- }
- }
- q_factor_intensity = sub( sub( shl( sub( scale_fact, 1 ), 1 ), 31 ), sub( guard_bits, scale_fact2 ) );
- }
- ELSE
- {
- FOR( i = 0; i < DIRAC_NUM_DIMS; i++ )
- {
- FOR( j = 0; j < MASA_FREQUENCY_BANDS; j++ )
- {
- intensity_real_fx[i][j] = L_shl( intensity_real_fx[i][j], sub( scale_fact2, guard_bits ) );
- move32();
- }
- }
- q_factor_intensity = add( sub( shl( sub( scale_fact, 1 ), 1 ), 31 ), sub( scale_fact2, guard_bits ) );
- }
- scale_fact2 = getScaleFactor32( reference_power_fx[ts], MASA_FREQUENCY_BANDS );
- IF( GT_16( guard_bits, scale_fact2 ) )
- {
-
- FOR( j = 0; j < MASA_FREQUENCY_BANDS; j++ )
- {
- reference_power_fx[ts][j] = L_shr( reference_power_fx[ts][j], sub( guard_bits, scale_fact2 ) );
- move32();
- }
-
- q_factor_energy = sub( sub( shl( scale_fact, 1 ), 31 ), sub( guard_bits, scale_fact2 ) );
- }
- ELSE
- {
- FOR( j = 0; j < MASA_FREQUENCY_BANDS; j++ )
- {
- reference_power_fx[ts][j] = L_shl( reference_power_fx[ts][j], sub( scale_fact2, guard_bits ) );
- move32();
- }
-
- q_factor_energy = add( sub( shl( scale_fact, 1 ), 31 ), sub( scale_fact2, guard_bits ) );
- }
-
- IF( q_factor_intensity_old != 0 )
- {
-
- IF( LT_16( q_factor_intensity_old, q_factor_intensity ) )
- {
- FOR( i = 0; i < DIRAC_NUM_DIMS; i++ )
- {
- FOR( j = 0; j < MASA_FREQUENCY_BANDS; j++ )
- {
- intensity_real_fx[i][j] = L_shr( intensity_real_fx[i][j], sub( q_factor_intensity, q_factor_intensity_old ) );
- move32();
- }
- }
- q_factor_intensity = q_factor_intensity_old;
- move16();
- }
- ELSE
- {
- FOR( i = 0; i < DIRAC_NUM_DIMS; i++ )
- {
- FOR( j = 0; j < index - 1; j++ )
- {
- /* only real part needed */
- FOR( Word16 k = 0; k < num_freq_bands; k++ )
- {
- hDirAC->buffer_intensity_real_fx[i][j][k] = L_shr( hDirAC->buffer_intensity_real_fx[i][j][k], sub( q_factor_intensity_old, q_factor_intensity ) );
- move32();
- }
- }
- }
- }
- }
- IF( q_factor_energy_old != 0 )
- {
-
- IF( LT_16( q_factor_energy_old, q_factor_energy ) )
- {
-
- FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ )
- {
- reference_power_fx[ts][j] = L_shr( reference_power_fx[ts][j], sub( q_factor_energy, q_factor_energy_old ) );
- move32();
- }
-
- q_factor_energy = q_factor_energy_old;
- move16();
- }
- ELSE
- {
- FOR( i = 0; i < index - 1; i++ )
- {
- FOR( j = 0; j < num_freq_bands; j++ )
- {
- FOR( Word16 k = 0; k < num_freq_bands; k++ )
- {
- hDirAC->buffer_energy_fx[add( imult1616( i, j ), k )] = L_shr( hDirAC->buffer_energy_fx[add( imult1616( i, j ), k )], sub( q_factor_energy_old, q_factor_energy_old ) );
- move32();
- }
- }
- }
- }
- }
-
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_q
}
- Copy32( reference_power_fx[ts], &( hDirAC->buffer_energy_fx[imult1616( sub( index, 1 ), num_freq_bands )] ), num_freq_bands );
-
- computeDiffuseness_fx( hDirAC->buffer_intensity_real_fx, hDirAC->buffer_energy_fx, num_freq_bands, diffuseness_vector_fx, q_factor_intensity, q_factor_energy, diffuseness_vector_exp );
- q_factor_intensity_old = q_factor_intensity;
+ hDirAC->buffer_intensity_real_q[index - 1] = intensity_q;
move16();
- q_factor_energy_old = q_factor_energy;
+ Copy32( reference_power_fx[ts], &( hDirAC->buffer_energy_fx[( index - 1 ) * num_freq_bands] ), num_freq_bands );
+ hDirAC->buffer_energy_q[index - 1] = reference_power_q;
move16();
- FOR( j = 0; j < MASA_FREQUENCY_BANDS; j++ )
- {
- if ( LT_16( diffuseness_vector_exp[j], 10 ) )
- {
- diffuseness_vector_fx[j] = 0;
- move16();
- }
- }
+ computeDiffuseness_fixed( hDirAC->buffer_intensity_real_fx, hDirAC->buffer_energy_fx, num_freq_bands, diffuseness_vector_fx, hDirAC->buffer_intensity_real_q, hDirAC->buffer_energy_q, &diffuseness_q );
FOR( band_m_idx = 0; band_m_idx < hDirAC->nbands; band_m_idx++ )
{
- norm_tmp_fx = Mpy_32_32( reference_power_fx[ts][band_m_idx], ( L_sub( ONE_IN_Q30, L_shr( diffuseness_vector_fx[band_m_idx], sub( 30, diffuseness_vector_exp[band_m_idx] ) ) ) ) ); // q_factor_energy-1
+ norm_tmp_fx = L_shl( Mult_32_32( reference_power_fx[ts][band_m_idx], L_sub( ONE_IN_Q30, diffuseness_vector_fx[band_m_idx] ) ), 1 ); /*2*inp_q-30*/
- hDirAC->direction_vector_m_fx[0][block_m_idx][band_m_idx] = L_add( Mpy_32_32( norm_tmp_fx, direction_vector_fx[0][band_m_idx] ), hDirAC->direction_vector_m_fx[0][block_m_idx][band_m_idx] ); // Q (q_factor_energy + exp -32)
+ 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], hDirAC->direction_vector_e[0][block_m_idx][band_m_idx], Mult_32_32( norm_tmp_fx, direction_vector_fx[0][band_m_idx] ), shl( c_e, 1 ), &hDirAC->direction_vector_e[0][block_m_idx][band_m_idx] );
move32();
- hDirAC->direction_vector_m_fx[1][block_m_idx][band_m_idx] = L_add( Mpy_32_32( norm_tmp_fx, direction_vector_fx[1][band_m_idx] ), hDirAC->direction_vector_m_fx[1][block_m_idx][band_m_idx] ); // Q (q_factor_energy + exp -32)
+ 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], hDirAC->direction_vector_e[1][block_m_idx][band_m_idx], Mult_32_32( norm_tmp_fx, direction_vector_fx[1][band_m_idx] ), shl( c_e, 1 ), &hDirAC->direction_vector_e[1][block_m_idx][band_m_idx] );
move32();
- hDirAC->direction_vector_m_fx[2][block_m_idx][band_m_idx] = L_add( Mpy_32_32( norm_tmp_fx, direction_vector_fx[2][band_m_idx] ), hDirAC->direction_vector_m_fx[2][block_m_idx][band_m_idx] ); // Q (q_factor_energy + exp -32)
+ 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], hDirAC->direction_vector_e[2][block_m_idx][band_m_idx], Mult_32_32( norm_tmp_fx, direction_vector_fx[2][band_m_idx] ), shl( c_e, 1 ), &hDirAC->direction_vector_e[2][block_m_idx][band_m_idx] );
move32();
-
- diffuseness_m_fx[band_m_idx] = L_add( diffuseness_m_fx[band_m_idx], Mpy_32_32( reference_power_fx[ts][band_m_idx], L_shr( diffuseness_vector_fx[band_m_idx], sub( 30, diffuseness_vector_exp[band_m_idx] ) ) ) ); // Qq_factor_energy-1
+ diffuseness_m_fx[band_m_idx] = BASOP_Util_Add_Mant32Exp( diffuseness_m_fx[band_m_idx], diffuseness_e[band_m_idx], L_shl( Mult_32_32( reference_power_fx[ts][band_m_idx], diffuseness_vector_fx[band_m_idx] ), 1 ), sub( shl( c_e, 1 ), 1 ), &diffuseness_e[band_m_idx] );
move32();
- renormalization_factor_diff_fx[band_m_idx] = L_add( renormalization_factor_diff_fx[band_m_idx], reference_power_fx[ts][band_m_idx] ); // Qq_factor_energy
+
+ renormalization_factor_diff_fx[band_m_idx] = BASOP_Util_Add_Mant32Exp( renormalization_factor_diff_fx[band_m_idx], renormalization_factor_diff_e[band_m_idx], reference_power_fx[ts][band_m_idx], sub( shl( c_e, 1 ), 1 ), &renormalization_factor_diff_e[band_m_idx] );
move32();
}
}
-
FOR( band_m_idx = 0; band_m_idx < hDirAC->nbands; band_m_idx++ )
{
+ Word16 max_e = MIN_16;
+ move16();
FOR( d = 0; d < DIRAC_NUM_DIMS; d++ )
{
- dir_v[d] = hDirAC->direction_vector_m_fx[d][block_m_idx][band_m_idx];
+ max_e = s_max( max_e, hDirAC->direction_vector_e[d][block_m_idx][band_m_idx] );
+ }
+ max_e = add( max_e, 1 ); /*1 as guard bit to prevent overflow*/
+ FOR( d = 0; d < DIRAC_NUM_DIMS; d++ )
+ {
+ dir_v_fx[d] = L_shr( hDirAC->direction_vector_m_fx[d][block_m_idx][band_m_idx], sub( max_e, hDirAC->direction_vector_e[d][block_m_idx][band_m_idx] ) );
move32();
}
- dir_q = add( q_factor_energy, sub( exp, 32 ) );
- ivas_qmetadata_direction_vector_to_azimuth_elevation_fx( dir_v, dir_q, &azimuth_m_values[block_m_idx][band_m_idx], &elevation_m_values[block_m_idx][band_m_idx] );
+ dir_v_q = sub( 31, max_e );
+ ivas_qmetadata_direction_vector_to_azimuth_elevation_fx( dir_v_fx, dir_v_q, &azimuth_m_values_fx[block_m_idx][band_m_idx], &elevation_m_values_fx[block_m_idx][band_m_idx] );
}
/* Determine energy ratios */
FOR( band_m_idx = 0; band_m_idx < hDirAC->nbands; band_m_idx++ )
{
+ Word16 diffuseness_m_e;
IF( GT_32( renormalization_factor_diff_fx[band_m_idx], EPSILON_FX ) )
{
- diffuseness_m_fx[band_m_idx] = BASOP_Util_Divide3232_Scale( diffuseness_m_fx[band_m_idx], renormalization_factor_diff_fx[band_m_idx], &exp_div );
+ diffuseness_m_fx[band_m_idx] = BASOP_Util_Divide3232_Scale( diffuseness_m_fx[band_m_idx], renormalization_factor_diff_fx[band_m_idx], &diffuseness_m_e );
+ move32();
+ diffuseness_m_e = add( diffuseness_m_e, sub( diffuseness_e[band_m_idx], renormalization_factor_diff_e[band_m_idx] ) );
+ diffuseness_m_fx[band_m_idx] = L_shl_sat( diffuseness_m_fx[band_m_idx], add( 16, diffuseness_m_e ) ); // Q31
move32();
}
ELSE
@@ -546,16 +466,14 @@ static void ivas_dirac_param_est_ana_fx(
diffuseness_m_fx[band_m_idx] = 0;
move32();
}
- exp_div = sub( 30, exp_div );
- energyRatio[block_m_idx][band_m_idx] = L_sub( L_shl( 1, 30 ), L_shl( diffuseness_m_fx[band_m_idx], sub( 30, exp_div ) ) ); // Q30
+ energyRatio_fx[block_m_idx][band_m_idx] = L_sub( ONE_IN_Q31, diffuseness_m_fx[band_m_idx] );
move32();
}
-
FOR( band_m_idx = 0; band_m_idx < hDirAC->nbands; band_m_idx++ )
{
- spreadCoherence[block_m_idx][band_m_idx] = 0;
+ spreadCoherence_fx[block_m_idx][band_m_idx] = 0;
move32();
- surroundingCoherence[block_m_idx][band_m_idx] = 0;
+ surroundingCoherence_fx[block_m_idx][band_m_idx] = 0;
move32();
}
}
diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c
index 922a4ef124df6d6bee92edd7fc9670cad46bfba5..c92f800af45d08fa6d57407b2af6abb837a54d6f 100644
--- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c
+++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c
@@ -694,7 +694,9 @@ static void ivas_dirac_dec_binaural_internal_fx(
move32();
move32();
move32();
-
+#ifdef OPT_BIN_RENDERER_V1
+ Word16 ch_len = s_max( 4, numInChannels );
+#endif /* OPT_BIN_RENDERER_V1 */
FOR( i = 0; i < 6; i++ )
{
FOR( j = 0; j < 4; j++ )
@@ -854,19 +856,39 @@ static void ivas_dirac_dec_binaural_internal_fx(
Scale_sig( st_ivas->hSpar->hFbMixer->cldfb_cross_fade_fx, CLDFB_NO_COL_MAX, Q15 - st_ivas->hSpar->hFbMixer->cldfb_cross_fade_q );
st_ivas->hSpar->hFbMixer->cldfb_cross_fade_q = Q15;
move16();
+#ifndef OPT_BIN_RENDERER_V1
FOR( Word16 idx = 0; idx < CLDFB_NO_CHANNELS_MAX; idx++ )
{
Scale_sig32( st_ivas->hSpar->hFbMixer->pFb->fb_bin_to_band.pp_cldfb_weights_per_spar_band_fx[idx], IVAS_MAX_NUM_FB_BANDS, Q31 - Q22 ); /*Q31 to Q22*/
}
+#endif /* OPT_BIN_RENDERER_V1 */
ivas_sba_prototype_renderer_fx( st_ivas, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, q_cldfb, subframe );
+#ifndef OPT_BIN_RENDERER_V1
FOR( Word16 idx = 0; idx < CLDFB_NO_CHANNELS_MAX; idx++ )
{
Scale_sig32( st_ivas->hSpar->hFbMixer->pFb->fb_bin_to_band.pp_cldfb_weights_per_spar_band_fx[idx], IVAS_MAX_NUM_FB_BANDS, Q22 - Q31 ); /*Q31 to Q22*/
}
+#endif /* OPT_BIN_RENDERER_V1 */
}
Word16 q_inp = Q6;
move16();
+#ifdef OPT_BIN_RENDERER_V1
+ FOR( Word16 cha = 0; cha < ch_len; cha++ )
+ {
+ FOR( slot = 0; slot < 4; slot++ )
+ {
+ Word16 q_diff = sub( q_inp, q_cldfb[cha][slot] );
+ IF( q_diff != 0 )
+ {
+ Scale_sig32( Cldfb_RealBuffer_in_fx[cha][slot], 60, q_diff ); // Q6
+ Scale_sig32( Cldfb_ImagBuffer_in_fx[cha][slot], 60, q_diff ); // Q6
+ q_cldfb[cha][slot] = 6;
+ }
+ move16();
+ }
+ }
+#else /* OPT_BIN_RENDERER_V1 */
FOR( Word16 cha = 0; cha < 6; cha++ )
{
FOR( slot = 0; slot < 4; slot++ )
@@ -877,6 +899,7 @@ static void ivas_dirac_dec_binaural_internal_fx(
move16();
}
}
+#endif /* OPT_BIN_RENDERER_V1 */
test();
test();
@@ -1265,12 +1288,14 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric
temp64 = W_add( W_mult0_32_32( tempRe, tempRe ), W_mult0_32_32( tempIm, tempIm ) ); // 2q
exp1 = W_norm( temp64 );
temp64 = W_shl( temp64, exp1 ); // 2q + exp1
- subFrameSumEne_fx[bin] = BASOP_Util_Add_Mant32Exp( subFrameSumEne_fx[bin], subFrameTotalEne_e[bin], W_extract_h( temp64 ), sub( exp /* 63 - 2q */, exp1 ) /*31 - (2q + exp1 - 32)*/, &subFrameTotalEne_e[bin] );
+ subFrameSumEne_fx[bin] = BASOP_Util_Add_Mant32Exp( subFrameSumEne_fx[bin], subFrameSumEne_e[bin], W_extract_h( temp64 ), sub( exp /* 63 - 2q */, exp1 ) /*31 - (2q + exp1 - 32)*/, &subFrameSumEne_e[bin] );
move32();
}
}
FOR( bin = 0; bin < nBins; bin++ )
{
+ subFrameTotalEne_e[bin] = sub( subFrameTotalEne_e[bin], 1 );
+ move16();
temp = L_shl_sat( subFrameTotalEne_fx[bin], sub( subFrameTotalEne_e[bin], subFrameSumEne_e[bin] ) ); // subFrameSumEne_e[bin]
IF( GT_32( subFrameSumEne_fx[bin], temp ) )
{
@@ -1851,6 +1876,76 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices_fx(
q_CrEne = Q31;
move16();
+#ifdef OPT_BIN_RENDERER_V1
+ Word16 q_diff = sub( hDiracDecBin->ChEne_e[0][bin], hDiracDecBin->ChEne_e[1][bin] );
+
+ IF( q_diff > 0 )
+ {
+ hDiracDecBin->ChEne_fx[1][bin] = L_shr( hDiracDecBin->ChEne_fx[1][bin], q_diff );
+ hDiracDecBin->q_ChEne = sub( 31, hDiracDecBin->ChEne_e[0][bin] );
+ hDiracDecBin->ChEne_e[1][bin] = hDiracDecBin->ChEne_e[0][bin];
+ }
+ ELSE
+ {
+ hDiracDecBin->ChEne_fx[0][bin] = L_shl( hDiracDecBin->ChEne_fx[0][bin], q_diff );
+ hDiracDecBin->q_ChEne = sub( 31, hDiracDecBin->ChEne_e[1][bin] );
+ hDiracDecBin->ChEne_e[0][bin] = hDiracDecBin->ChEne_e[1][bin];
+ }
+ move32();
+ move16();
+ move16();
+
+ q_diff = sub( hDiracDecBin->ChEneOut_e[0][bin], hDiracDecBin->ChEneOut_e[1][bin] );
+ IF( q_diff > 0 )
+ {
+ hDiracDecBin->ChEneOut_fx[1][bin] = L_shr( hDiracDecBin->ChEneOut_fx[1][bin], q_diff );
+ hDiracDecBin->q_ChEneOut = sub( 31, hDiracDecBin->ChEneOut_e[0][bin] );
+ hDiracDecBin->ChEneOut_e[1][bin] = hDiracDecBin->ChEneOut_e[0][bin];
+ }
+ ELSE
+ {
+ hDiracDecBin->ChEneOut_fx[0][bin] = L_shl( hDiracDecBin->ChEneOut_fx[0][bin], q_diff );
+ hDiracDecBin->q_ChEneOut = sub( 31, hDiracDecBin->ChEneOut_e[1][bin] );
+ hDiracDecBin->ChEneOut_e[0][bin] = hDiracDecBin->ChEneOut_e[1][bin];
+ }
+ move32();
+ move16();
+ move16();
+
+ q_diff = sub( hDiracDecBin->ChCrossRe_e[bin], hDiracDecBin->ChCrossIm_e[bin] );
+ IF( q_diff > 0 )
+ {
+ hDiracDecBin->ChCrossIm_fx[bin] = L_shr( hDiracDecBin->ChCrossIm_fx[bin], q_diff );
+ hDiracDecBin->q_ChCross = sub( 31, hDiracDecBin->ChCrossRe_e[bin] );
+ hDiracDecBin->ChCrossIm_e[bin] = hDiracDecBin->ChCrossRe_e[bin];
+ }
+ ELSE
+ {
+ hDiracDecBin->ChCrossRe_fx[bin] = L_shl( hDiracDecBin->ChCrossRe_fx[bin], q_diff );
+ hDiracDecBin->q_ChCross = sub( 31, hDiracDecBin->ChCrossIm_e[bin] );
+ hDiracDecBin->ChCrossRe_e[bin] = hDiracDecBin->ChCrossIm_e[bin];
+ }
+ move32();
+ move16();
+ move16();
+
+ q_diff = sub( hDiracDecBin->ChCrossReOut_e[bin], hDiracDecBin->ChCrossImOut_e[bin] );
+ IF( q_diff > 0 )
+ {
+ hDiracDecBin->ChCrossImOut_fx[bin] = L_shr( hDiracDecBin->ChCrossImOut_fx[bin], q_diff );
+ hDiracDecBin->q_ChCrossOut = sub( 31, hDiracDecBin->ChCrossReOut_e[bin] );
+ hDiracDecBin->ChCrossImOut_e[bin] = hDiracDecBin->ChCrossReOut_e[bin];
+ }
+ ELSE
+ {
+ hDiracDecBin->ChCrossReOut_fx[bin] = L_shl( hDiracDecBin->ChCrossReOut_fx[bin], q_diff );
+ hDiracDecBin->q_ChCrossOut = sub( 31, hDiracDecBin->ChCrossImOut_e[bin] );
+ hDiracDecBin->ChCrossReOut_e[bin] = hDiracDecBin->ChCrossImOut_e[bin];
+ }
+ move32();
+ move16();
+ move16();
+#else /* OPT_BIN_RENDERER_V1 */
IF( GT_16( hDiracDecBin->ChEne_e[0][bin], hDiracDecBin->ChEne_e[1][bin] ) )
{
hDiracDecBin->ChEne_fx[1][bin] = L_shr( hDiracDecBin->ChEne_fx[1][bin], sub( hDiracDecBin->ChEne_e[0][bin], hDiracDecBin->ChEne_e[1][bin] ) );
@@ -1910,6 +2005,7 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices_fx(
}
move32();
move16();
+#endif /* OPT_BIN_RENDERER_V1 */
formulate2x2MixingMatrix_fx( hDiracDecBin->ChEne_fx[0][bin], hDiracDecBin->ChEne_fx[1][bin],
hDiracDecBin->q_ChEne,
@@ -2096,6 +2192,21 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices_fx(
exp = sub( get_min_scalefactor( resultMtxRe_fx[0][0], resultMtxRe_fx[1][1] ), 2 );
tmp2 = L_add( L_shl( resultMtxRe_fx[0][0], exp ), L_shl( resultMtxRe_fx[1][1], exp ) );
q_tmp2 = add( q_res, exp );
+
+ /*Limiting value to Q63*/
+ IF( GT_16( q_tmp2, 63 ) )
+ {
+ tmp2 = L_shl( tmp2, sub( 63, q_tmp2 ) );
+ q_tmp2 = 63;
+ move16();
+ IF( EQ_32( tmp2, -1 ) )
+ {
+ tmp2 = 0;
+ move32();
+ q_tmp2 = 31;
+ move16();
+ }
+ }
IF( LT_16( q_CrEne, q_tmp2 ) )
{
realizedOutputEne_fx = L_add( tmp1, L_shr( tmp2, sub( q_tmp2, q_CrEne ) ) );
@@ -2269,9 +2380,9 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices_fx(
FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ )
{
- hDiracDecBin->processMtxRePrev_fx[chA][add( chB, 2 )][bin] = hDiracDecBin->processMtxRe_fx[chA][add( chB, 2 )][bin];
+ hDiracDecBin->processMtxRePrev_fx[chA][chB + 2][bin] = hDiracDecBin->processMtxRe_fx[chA][chB + 2][bin];
move16();
- hDiracDecBin->processMtxImPrev_fx[chA][add( chB, 2 )][bin] = hDiracDecBin->processMtxIm_fx[chA][add( chB, 2 )][bin];
+ hDiracDecBin->processMtxImPrev_fx[chA][chB + 2][bin] = hDiracDecBin->processMtxIm_fx[chA][chB + 2][bin];
move16();
}
q_processMtxPrev_SCCR[bin] = q_processMtx_bin;
@@ -2279,13 +2390,13 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices_fx(
getDirectPartGains_fx( bin, aziDeg, eleDeg, &lRealp_fx, &lImagp_fx, &rRealp_fx, &rImagp_fx, hDiracDecBin->renderStereoOutputInsteadOfBinaural, Rmat, &gainCache[chB], isHeadtracked );
- hDiracDecBin->processMtxRe_fx[0][add( chB, 2 )][bin] = extract_h( Mpy_32_32( lRealp_fx, gainFactor_fx ) );
+ hDiracDecBin->processMtxRe_fx[0][chB + 2][bin] = extract_h( Mpy_32_32( lRealp_fx, gainFactor_fx ) );
move16();
- hDiracDecBin->processMtxIm_fx[0][add( chB, 2 )][bin] = extract_h( Mpy_32_32( lImagp_fx, gainFactor_fx ) );
+ hDiracDecBin->processMtxIm_fx[0][chB + 2][bin] = extract_h( Mpy_32_32( lImagp_fx, gainFactor_fx ) );
move16();
- hDiracDecBin->processMtxRe_fx[1][add( chB, 2 )][bin] = extract_h( Mpy_32_32( rRealp_fx, gainFactor_fx ) );
+ hDiracDecBin->processMtxRe_fx[1][chB + 2][bin] = extract_h( Mpy_32_32( rRealp_fx, gainFactor_fx ) );
move16();
- hDiracDecBin->processMtxIm_fx[1][add( chB, 2 )][bin] = extract_h( Mpy_32_32( rImagp_fx, gainFactor_fx ) );
+ hDiracDecBin->processMtxIm_fx[1][chB + 2][bin] = extract_h( Mpy_32_32( rImagp_fx, gainFactor_fx ) );
move16();
q_processMtx_SCCR[bin] = sub( sub( add( Q28, q_gain ), 31 ), 16 );
move16();
@@ -2294,9 +2405,9 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices_fx(
{
FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ )
{
- hDiracDecBin->processMtxRePrev_fx[chA][add( chB, 2 )][bin] = hDiracDecBin->processMtxRe_fx[chA][add( chB, 2 )][bin];
+ hDiracDecBin->processMtxRePrev_fx[chA][chB + 2][bin] = hDiracDecBin->processMtxRe_fx[chA][chB + 2][bin];
move16();
- hDiracDecBin->processMtxImPrev_fx[chA][add( chB, 2 )][bin] = hDiracDecBin->processMtxIm_fx[chA][add( chB, 2 )][bin];
+ hDiracDecBin->processMtxImPrev_fx[chA][chB + 2][bin] = hDiracDecBin->processMtxIm_fx[chA][chB + 2][bin];
move16();
}
q_processMtxPrev_SCCR[bin] = q_processMtx_SCCR[bin];
@@ -2351,13 +2462,13 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices_fx(
{
FOR( chB = 0; chB < nchanSeparateChannels; chB++ )
{
- hDiracDecBin->processMtxRe_fx[chA][add( chB, 2 )][bin] = shr( hDiracDecBin->processMtxRe_fx[chA][add( chB, 2 )][bin], sub( q_processMtx_SCCR[bin], hDiracDecBin->q_processMtx ) ); // hDiracDecBin->q_processMtx
+ hDiracDecBin->processMtxRe_fx[chA][chB + 2][bin] = shr( hDiracDecBin->processMtxRe_fx[chA][chB + 2][bin], sub( q_processMtx_SCCR[bin], hDiracDecBin->q_processMtx ) ); // hDiracDecBin->q_processMtx
move16();
- hDiracDecBin->processMtxIm_fx[chA][add( chB, 2 )][bin] = shr( hDiracDecBin->processMtxIm_fx[chA][add( chB, 2 )][bin], sub( q_processMtx_SCCR[bin], hDiracDecBin->q_processMtx ) ); // hDiracDecBin->q_processMtx
+ hDiracDecBin->processMtxIm_fx[chA][chB + 2][bin] = shr( hDiracDecBin->processMtxIm_fx[chA][chB + 2][bin], sub( q_processMtx_SCCR[bin], hDiracDecBin->q_processMtx ) ); // hDiracDecBin->q_processMtx
move16();
- hDiracDecBin->processMtxRePrev_fx[chA][add( chB, 2 )][bin] = shr( hDiracDecBin->processMtxRePrev_fx[chA][add( chB, 2 )][bin], sub( q_processMtxPrev_SCCR[bin], hDiracDecBin->q_processMtxPrev ) ); // hDiracDecBin->q_processMtxPrev
+ hDiracDecBin->processMtxRePrev_fx[chA][chB + 2][bin] = shr( hDiracDecBin->processMtxRePrev_fx[chA][chB + 2][bin], sub( q_processMtxPrev_SCCR[bin], hDiracDecBin->q_processMtxPrev ) ); // hDiracDecBin->q_processMtxPrev
move16();
- hDiracDecBin->processMtxImPrev_fx[chA][add( chB, 2 )][bin] = shr( hDiracDecBin->processMtxImPrev_fx[chA][add( chB, 2 )][bin], sub( q_processMtxPrev_SCCR[bin], hDiracDecBin->q_processMtxPrev ) ); // hDiracDecBin->q_processMtxPrev
+ hDiracDecBin->processMtxImPrev_fx[chA][chB + 2][bin] = shr( hDiracDecBin->processMtxImPrev_fx[chA][chB + 2][bin], sub( q_processMtxPrev_SCCR[bin], hDiracDecBin->q_processMtxPrev ) ); // hDiracDecBin->q_processMtxPrev
move16();
}
}
@@ -2404,6 +2515,10 @@ static void ivas_dirac_dec_binaural_process_output_fx(
Word32 *decSlotImPointer_fx;
Word16 q_inp_mix, q_reverb = 31;
move16();
+#ifdef OPT_BIN_RENDERER_V1
+ Word16 ch_len = s_max( 4, numInChannels );
+ Word16 eff_q;
+#endif /* OPT_BIN_RENDERER_V1 */
IF( processReverb )
@@ -2417,7 +2532,11 @@ static void ivas_dirac_dec_binaural_process_output_fx(
Word16 shift = s_min( L_norm_arr( cldfbSynDec[0]->cldfb_state_fx, cldfbSynDec[0]->p_filter_length ), L_norm_arr( cldfbSynDec[1]->cldfb_state_fx, cldfbSynDec[1]->p_filter_length ) );
q_inp_mix = 31;
move16();
+#ifdef OPT_BIN_RENDERER_V1
+ FOR( Word16 i = 0; i < ch_len; i++ )
+#else /* OPT_BIN_RENDERER_V1 */
FOR( Word16 i = 0; i < 6; i++ )
+#endif /* OPT_BIN_RENDERER_V1 */
{
FOR( Word16 j = 0; j < nSlots; j++ )
{
@@ -2444,7 +2563,14 @@ static void ivas_dirac_dec_binaural_process_output_fx(
move16();
}
+
+#ifdef OPT_BIN_RENDERER_V1
+ eff_q = sub( add( q_inp_mix, q_mat ), 15 );
+
+ FOR( Word16 i = 0; i < ch_len; i++ )
+#else /* OPT_BIN_RENDERER_V1 */
FOR( Word16 i = 0; i < 6; i++ )
+#endif /* OPT_BIN_RENDERER_V1 */
{
FOR( Word16 j = 0; j < nSlots; j++ )
{
@@ -2454,8 +2580,13 @@ static void ivas_dirac_dec_binaural_process_output_fx(
test();
IF( processReverb && LT_16( i, 2 ) )
{
+#ifdef OPT_BIN_RENDERER_V1
+ scale_sig32( reverbRe_fx[i][j], CLDFB_NO_CHANNELS_MAX, eff_q ); /*q_inp_mix+q_mat-15*/
+ scale_sig32( reverbIm_fx[i][j], CLDFB_NO_CHANNELS_MAX, eff_q ); /*q_inp_mix+q_mat-15*/
+#else /* OPT_BIN_RENDERER_V1 */
scale_sig32( reverbRe_fx[i][j], CLDFB_NO_CHANNELS_MAX, sub( add( q_inp_mix, q_mat ), 15 ) ); /*q_inp_mix+q_mat-15*/
scale_sig32( reverbIm_fx[i][j], CLDFB_NO_CHANNELS_MAX, sub( add( q_inp_mix, q_mat ), 15 ) ); /*q_inp_mix+q_mat-15*/
+#endif /* OPT_BIN_RENDERER_V1 */
}
}
}
@@ -2609,17 +2740,19 @@ static void adaptTransportSignalsHeadtracked_fx(
Word16 slot, ch, bin, louderCh;
Word32 mono_factor_ILD, mono_factor;
Word32 y_val, mono_factor_rotation, ene_proc, ene_target, ILD;
+ Word16 ene_proc_e, ene_target_e;
Word16 max_band;
Word32 eqVal;
Word16 band_idx, bin_lo, bin_hi, norm, shift = 31;
- Word16 q_chEneIIR = 0, q_procChEneIIR = 0;
Word32 temp_div;
- Word16 e_div, tmp, is_zero, i;
- move16();
- move16();
+ Word16 e_div, is_zero, i;
move16();
+#ifdef OPT_BIN_RENDERER_V1
+ FOR( i = 0; i < 2; i++ )
+#else /* OPT_BIN_RENDERER_V1 */
FOR( i = 0; i < 6; i++ )
+#endif /* OPT_BIN_RENDERER_V1 */
{
FOR( Word16 j = 0; j < nSlots; j++ )
{
@@ -2658,16 +2791,17 @@ static void adaptTransportSignalsHeadtracked_fx(
shift = sub( shift, 5 );
// 5 is gaurded bits needed//
Word32 re, img, temp;
- Word16 q_temp = sub( imult1616( 2, add( q_inp, shift ) ), 31 );
+ Word16 s, q_band_nrg, q_temp[2];
FOR( band_idx = 0; band_idx < max_band; band_idx++ )
{
- Word32 ch_nrg[2]; /* storage for input signal channel energies */
+ Word32 ch_nrg[2]; /* storage for input signal channel energies */
+ Word64 W_ch_nrg[2]; /* storage for input signal channel energies */
bin_lo = MASA_band_grouping_24[band_idx];
bin_hi = s_min( MASA_band_grouping_24[band_idx + 1], (Word16) nBins );
FOR( ch = 0; ch < 2; ch++ )
{
- ch_nrg[ch] = 0;
+ W_ch_nrg[ch] = 0;
move32();
FOR( slot = 0; slot < nSlots; slot++ )
{
@@ -2676,24 +2810,31 @@ static void adaptTransportSignalsHeadtracked_fx(
re = L_shl( inRe_fx[ch][slot][bin], shift );
img = L_shl( inIm_fx[ch][slot][bin], shift );
- ch_nrg[ch] = L_add( ch_nrg[ch], ( L_add( Mpy_32_32( re, re ), Mpy_32_32( img, img ) ) ) ); // 2(q_inp +shift) -31
- move32();
+ W_ch_nrg[ch] = W_add( W_ch_nrg[ch], ( W_add( W_mult0_32_32( re, re ), W_mult0_32_32( img, img ) ) ) ); // 2(q_inp +shift)
+ move64();
}
}
+ s = W_norm( W_ch_nrg[ch] );
+ ch_nrg[ch] = W_extract_h( W_shl( W_ch_nrg[ch], s ) ); // Q: 2*(q_inp+shift) + s - 32
+ q_temp[ch] = sub( add( shl( add( q_inp, shift ), 1 ), s ), 32 );
+ move32();
+ move16();
+
hHeadTrackData->chEneIIR_fx[ch][band_idx] = Mpy_32_16_1( hHeadTrackData->chEneIIR_fx[ch][band_idx], ADAPT_HTPROTO_IIR_FAC_FX ); // q_chEneIIR
move32();
- temp = Mpy_32_16_1( ch_nrg[ch], sub( 32767, ADAPT_HTPROTO_IIR_FAC_FX ) );
- IF( LT_16( hHeadTrackData->q_chEneIIR, q_temp ) )
+ temp = Mpy_32_16_1( ch_nrg[ch], sub( 32767, ADAPT_HTPROTO_IIR_FAC_FX ) ); // q_temp[ch]
+ IF( LT_16( hHeadTrackData->q_chEneIIR[ch][band_idx], q_temp[ch] ) )
{
- hHeadTrackData->chEneIIR_fx[ch][band_idx] = L_add( L_shr( temp, sub( q_temp, hHeadTrackData->q_chEneIIR ) ), hHeadTrackData->chEneIIR_fx[ch][band_idx] );
+ hHeadTrackData->chEneIIR_fx[ch][band_idx] = L_add( L_shr( temp, sub( q_temp[ch], hHeadTrackData->q_chEneIIR[ch][band_idx] ) ), hHeadTrackData->chEneIIR_fx[ch][band_idx] ); // hHeadTrackData->q_chEneIIR[ch][band_idx]
}
ELSE
{
- hHeadTrackData->chEneIIR_fx[ch][band_idx] = L_add( L_shr( hHeadTrackData->chEneIIR_fx[ch][band_idx], sub( hHeadTrackData->q_chEneIIR, q_temp ) ), temp );
+ hHeadTrackData->chEneIIR_fx[ch][band_idx] = L_add( L_shr( hHeadTrackData->chEneIIR_fx[ch][band_idx], sub( hHeadTrackData->q_chEneIIR[ch][band_idx], q_temp[ch] ) ), temp ); // q_temp[ch]
}
move32();
+ hHeadTrackData->q_chEneIIR[ch][band_idx] = s_min( hHeadTrackData->q_chEneIIR[ch][band_idx], q_temp[ch] );
+ move16();
}
- q_chEneIIR = s_min( hHeadTrackData->q_chEneIIR, q_temp );
/* Determine ILD */
IF( EQ_32( L_max( 1, hHeadTrackData->chEneIIR_fx[0][band_idx] ), L_max( 1, hHeadTrackData->chEneIIR_fx[1][band_idx] ) ) )
@@ -2704,7 +2845,7 @@ static void adaptTransportSignalsHeadtracked_fx(
ELSE
{
temp_div = L_deposit_h( BASOP_Util_Divide3232_Scale( L_max( 1, hHeadTrackData->chEneIIR_fx[0][band_idx] ), L_max( 1, hHeadTrackData->chEneIIR_fx[1][band_idx] ), &e_div ) );
-
+ e_div = add( e_div, sub( hHeadTrackData->q_chEneIIR[1][band_idx], hHeadTrackData->q_chEneIIR[0][band_idx] ) );
temp = BASOP_Util_Log2( temp_div ); // Q25
IF( e_div > 0 )
{
@@ -2718,7 +2859,7 @@ static void adaptTransportSignalsHeadtracked_fx(
temp = Mpy_32_32( temp, 646462464 ); // logx base 10 = 0.30103* logx base 2//
ILD = L_abs( Mpy_32_16_1( temp, 20480 ) ); // Q21
}
- IF( GT_32( hHeadTrackData->chEneIIR_fx[1][band_idx], hHeadTrackData->chEneIIR_fx[0][band_idx] ) )
+ IF( BASOP_Util_Cmp_Mant32Exp( hHeadTrackData->chEneIIR_fx[1][band_idx], sub( 31, hHeadTrackData->q_chEneIIR[1][band_idx] ), hHeadTrackData->chEneIIR_fx[0][band_idx], sub( 31, hHeadTrackData->q_chEneIIR[0][band_idx] ) ) > 0 )
{
louderCh = 1;
}
@@ -2751,8 +2892,9 @@ static void adaptTransportSignalsHeadtracked_fx(
{
IF( NE_16( ch, louderCh ) )
{
- Word32 band_nrg = 0;
- move32();
+ Word32 band_nrg;
+ Word64 W_band_nrg = 0;
+ move64();
FOR( slot = 0; slot < nSlots; slot++ )
{
@@ -2763,24 +2905,31 @@ static void adaptTransportSignalsHeadtracked_fx(
inIm_fx[ch][slot][bin] = L_add( ( Mpy_32_32( mono_factor, L_add( inIm_fx[0][slot][bin], inIm_fx[1][slot][bin] ) ) ), ( Mpy_32_32( L_sub( ONE_IN_Q31, mono_factor ), inIm_fx[ch][slot][bin] ) ) );
move32();
move32();
- re = L_shl( inRe_fx[ch][slot][bin], shift ); // q_inp +shift
- img = L_shl( inIm_fx[ch][slot][bin], shift ); // q_inp +shift
- band_nrg = L_add( band_nrg, ( L_add( Mpy_32_32( re, re ), Mpy_32_32( img, img ) ) ) ); // 2(q_inp +shift) -31
+ re = L_shl( inRe_fx[ch][slot][bin], shift ); // q_inp +shift
+ img = L_shl( inIm_fx[ch][slot][bin], shift ); // q_inp +shift
+
+ W_band_nrg = W_add( W_band_nrg, ( W_add( W_mult0_32_32( re, re ), W_mult0_32_32( img, img ) ) ) ); // 2(q_inp + shift)
}
}
- hHeadTrackData->procChEneIIR_fx[ch][band_idx] = Mpy_32_16_1( hHeadTrackData->procChEneIIR_fx[ch][band_idx], ADAPT_HTPROTO_IIR_FAC_FX ); // q_procChEneIIR
+ s = W_norm( W_band_nrg );
+ band_nrg = W_extract_h( W_shl( W_band_nrg, s ) ); // Q: 2*(q_inp+shift) + s - 32
+ q_band_nrg = sub( add( shl( add( q_inp, shift ), 1 ), s ), 32 );
+
+ hHeadTrackData->procChEneIIR_fx[ch][band_idx] = Mpy_32_16_1( hHeadTrackData->procChEneIIR_fx[ch][band_idx], ADAPT_HTPROTO_IIR_FAC_FX ); // hHeadTrackData->q_procChEneIIR[ch][band_idx]
move32();
- temp = Mpy_32_16_1( band_nrg, sub( 32767, ADAPT_HTPROTO_IIR_FAC_FX ) );
- IF( LT_16( hHeadTrackData->q_procChEneIIR, q_temp ) )
+ temp = Mpy_32_16_1( band_nrg, sub( 32767, ADAPT_HTPROTO_IIR_FAC_FX ) ); // q_band_nrg
+ IF( LT_16( hHeadTrackData->q_procChEneIIR[ch][band_idx], q_band_nrg ) )
{
- hHeadTrackData->procChEneIIR_fx[ch][band_idx] = L_add( L_shr( temp, sub( q_temp, hHeadTrackData->q_procChEneIIR ) ), hHeadTrackData->procChEneIIR_fx[ch][band_idx] );
+ hHeadTrackData->procChEneIIR_fx[ch][band_idx] = L_add( L_shr( temp, sub( q_band_nrg, hHeadTrackData->q_procChEneIIR[ch][band_idx] ) ), hHeadTrackData->procChEneIIR_fx[ch][band_idx] ); // hHeadTrackData->q_procChEneIIR[ch][band_idx]
}
ELSE
{
- hHeadTrackData->procChEneIIR_fx[ch][band_idx] = L_add( L_shr( hHeadTrackData->procChEneIIR_fx[ch][band_idx], sub( hHeadTrackData->q_procChEneIIR, q_temp ) ), temp );
+ hHeadTrackData->procChEneIIR_fx[ch][band_idx] = L_add( L_shr( hHeadTrackData->procChEneIIR_fx[ch][band_idx], sub( hHeadTrackData->q_procChEneIIR[ch][band_idx], q_band_nrg ) ), temp ); // q_band_nrg
}
move32();
+ hHeadTrackData->q_procChEneIIR[ch][band_idx] = s_min( hHeadTrackData->q_procChEneIIR[ch][band_idx], q_band_nrg );
+ move16();
}
ELSE
{
@@ -2789,27 +2938,27 @@ static void adaptTransportSignalsHeadtracked_fx(
move32();
temp = Mpy_32_16_1( ch_nrg[ch], sub( 32767, ADAPT_HTPROTO_IIR_FAC_FX ) );
- IF( LT_16( hHeadTrackData->q_procChEneIIR, q_temp ) )
+ IF( LT_16( hHeadTrackData->q_procChEneIIR[ch][band_idx], q_temp[ch] ) )
{
- hHeadTrackData->procChEneIIR_fx[ch][band_idx] = L_add( L_shr( temp, sub( q_temp, hHeadTrackData->q_procChEneIIR ) ), hHeadTrackData->procChEneIIR_fx[ch][band_idx] );
+ hHeadTrackData->procChEneIIR_fx[ch][band_idx] = L_add( L_shr( temp, sub( q_temp[ch], hHeadTrackData->q_procChEneIIR[ch][band_idx] ) ), hHeadTrackData->procChEneIIR_fx[ch][band_idx] ); // hHeadTrackData->q_procChEneIIR[ch][band_idx]
}
ELSE
{
- hHeadTrackData->procChEneIIR_fx[ch][band_idx] = L_add( L_shr( hHeadTrackData->procChEneIIR_fx[ch][band_idx], sub( hHeadTrackData->q_procChEneIIR, q_temp ) ), temp );
+ hHeadTrackData->procChEneIIR_fx[ch][band_idx] = L_add( L_shr( hHeadTrackData->procChEneIIR_fx[ch][band_idx], sub( hHeadTrackData->q_procChEneIIR[ch][band_idx], q_temp[ch] ) ), temp ); // q_temp[ch]
}
move32();
+ hHeadTrackData->q_procChEneIIR[ch][band_idx] = s_min( hHeadTrackData->q_procChEneIIR[ch][band_idx], q_temp[ch] );
+ move16();
}
}
- q_procChEneIIR = s_min( hHeadTrackData->q_procChEneIIR, q_temp );
-
/* Equalize */
- ene_target = L_add( hHeadTrackData->chEneIIR_fx[0][band_idx], hHeadTrackData->chEneIIR_fx[1][band_idx] ); // q_chEneIIR//
+ ene_target = BASOP_Util_Add_Mant32Exp( hHeadTrackData->chEneIIR_fx[0][band_idx], sub( 31, hHeadTrackData->q_chEneIIR[0][band_idx] ), hHeadTrackData->chEneIIR_fx[1][band_idx], sub( 31, hHeadTrackData->q_chEneIIR[1][band_idx] ), &ene_target_e );
- ene_proc = L_add( hHeadTrackData->procChEneIIR_fx[0][band_idx], hHeadTrackData->procChEneIIR_fx[1][band_idx] ); // q_procChEneIIR//
+ ene_proc = BASOP_Util_Add_Mant32Exp( hHeadTrackData->procChEneIIR_fx[0][band_idx], sub( 31, hHeadTrackData->q_procChEneIIR[0][band_idx] ), hHeadTrackData->procChEneIIR_fx[1][band_idx], sub( 31, hHeadTrackData->q_procChEneIIR[1][band_idx] ), &ene_proc_e );
temp_div = L_deposit_h( BASOP_Util_Divide3232_Scale( ene_target, L_max( 1, ene_proc ), &e_div ) );
- e_div = add( e_div, sub( q_procChEneIIR, q_chEneIIR ) );
+ e_div = add( e_div, sub( ene_target_e, ene_proc_e ) );
eqVal = Sqrt32( temp_div, &e_div );
@@ -2859,16 +3008,8 @@ static void adaptTransportSignalsHeadtracked_fx(
}
IF( is_zero )
{
- hHeadTrackData->q_chEneIIR = 31;
- move16();
- }
- ELSE
- {
- tmp = sub( s_min( getScaleFactor32( hHeadTrackData->chEneIIR_fx[0], MASA_FREQUENCY_BANDS ), getScaleFactor32( hHeadTrackData->chEneIIR_fx[1], MASA_FREQUENCY_BANDS ) ), 1 );
- scale_sig32( hHeadTrackData->chEneIIR_fx[0], MASA_FREQUENCY_BANDS, tmp );
- scale_sig32( hHeadTrackData->chEneIIR_fx[1], MASA_FREQUENCY_BANDS, tmp );
- hHeadTrackData->q_chEneIIR = add( q_chEneIIR, tmp );
- move16();
+ set16_fx( hHeadTrackData->q_chEneIIR[0], 31, MASA_FREQUENCY_BANDS );
+ set16_fx( hHeadTrackData->q_chEneIIR[1], 31, MASA_FREQUENCY_BANDS );
}
is_zero = 1;
@@ -2885,17 +3026,10 @@ static void adaptTransportSignalsHeadtracked_fx(
}
IF( is_zero )
{
- hHeadTrackData->q_procChEneIIR = 31;
- move16();
- }
- ELSE
- {
- tmp = sub( s_min( getScaleFactor32( hHeadTrackData->procChEneIIR_fx[0], MASA_FREQUENCY_BANDS ), getScaleFactor32( hHeadTrackData->procChEneIIR_fx[1], MASA_FREQUENCY_BANDS ) ), 1 );
- scale_sig32( hHeadTrackData->procChEneIIR_fx[0], MASA_FREQUENCY_BANDS, tmp );
- scale_sig32( hHeadTrackData->procChEneIIR_fx[1], MASA_FREQUENCY_BANDS, tmp );
- hHeadTrackData->q_procChEneIIR = add( q_procChEneIIR, tmp );
- move16();
+ set16_fx( hHeadTrackData->q_procChEneIIR[0], 31, MASA_FREQUENCY_BANDS );
+ set16_fx( hHeadTrackData->q_procChEneIIR[1], 31, MASA_FREQUENCY_BANDS );
}
+
return;
}
@@ -3281,6 +3415,169 @@ static void eig2x2_fx(
move16();
move16();
+#ifdef OPT_SBA_REND_V1_BE
+ /* Eigenvectors */
+ FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ )
+ {
+ Word16 q_diff = sub( q_e, *q_D );
+ IF( q_diff > 0 )
+ {
+ tmp1 = L_sub( D_fx[ch], L_shr( e1, q_diff ) );
+ tmp2 = L_sub( D_fx[ch], L_shr( e2, q_diff ) );
+ q_tmp1 = *q_D;
+ move16();
+ }
+ ELSE
+ {
+ tmp1 = L_sub( L_shl( D_fx[ch], q_diff ), e1 );
+ tmp2 = L_sub( L_shl( D_fx[ch], q_diff ), e2 );
+ q_tmp1 = q_e;
+ move16();
+ }
+
+ IF( GT_32( L_abs( tmp2 ), L_abs( tmp1 ) ) )
+ {
+ s_fx = tmp2;
+ move32();
+ exp = sub( norm_l( s_fx ), 1 );
+ tmp2 = Mpy_32_32( s_fx, s_fx );
+ q_tmp2 = sub( add( q_tmp1, q_tmp1 ), 31 );
+
+ tmp2 = BASOP_Util_Add_Mant32Exp( crossSquare_fx, sub( 31, q_crossSquare ), tmp2, sub( 31, q_tmp2 ), &q_tmp2 );
+ q_tmp2 = sub( 31, q_tmp2 );
+
+ tmp3 = BASOP_Util_Add_Mant32Exp( tmp2, sub( 31, q_tmp2 ), epsilon_mant, epsilon_exp, &exp_tmp3 );
+
+ tmp2 = BASOP_Util_Divide3232_Scale_newton( ONE_IN_Q30, tmp3, &exp );
+ exp = sub( exp, sub( Q30, sub( 31, exp_tmp3 ) ) );
+ normVal_fx = Sqrt32( tmp2, &exp ); // q_tmp2
+ q_tmp2 = sub( 31, exp );
+
+ q_diff = sub( q_c, q_tmp1 );
+ IF( q_diff > 0 )
+ {
+ c_re = L_shr( c_re, q_diff );
+ c_im = L_shr( c_im, q_diff );
+ q_c = q_tmp1;
+ move16();
+ }
+ ELSE
+ {
+ s_fx = L_shl( s_fx, q_diff );
+ q_tmp1 = q_c;
+ move16();
+ }
+
+ Ure_fx[0][ch] = Mpy_32_32( s_fx, normVal_fx );
+ move32();
+ Ure_fx[1][ch] = Mpy_32_32( c_re, normVal_fx );
+ move32();
+ Uim_fx[1][ch] = Mpy_32_32( c_im, normVal_fx );
+ move32();
+ q_U_1 = sub( add( q_tmp1, q_tmp2 ), 31 );
+
+ IF( q_U_2 != 0 )
+ {
+ q_diff = sub( q_U_2, q_U_1 );
+ IF( q_diff > 0 )
+ {
+ Ure_fx[1][ch - 1] = L_shr( Ure_fx[1][ch - 1], q_diff );
+ Ure_fx[0][ch - 1] = L_shr( Ure_fx[0][ch - 1], q_diff );
+ Uim_fx[0][ch - 1] = L_shr( Uim_fx[0][ch - 1], q_diff );
+ q_U_2 = q_U_1;
+ move32();
+ move32();
+ move32();
+ move16();
+ }
+ ELSE IF( GT_16( q_U_1, q_U_2 ) )
+ {
+ Ure_fx[1][ch] = L_shl( Ure_fx[1][ch], q_diff );
+ Ure_fx[0][ch] = L_shl( Ure_fx[0][ch], q_diff );
+ Uim_fx[1][ch] = L_shl( Uim_fx[1][ch], q_diff );
+ q_U_1 = q_U_2;
+ move32();
+ move32();
+ move32();
+ move16();
+ }
+ }
+ q_U_2 = q_U_1;
+ move16();
+ }
+ ELSE
+ {
+ s_fx = tmp1;
+ move32();
+
+ exp = sub( norm_l( s_fx ), 1 );
+ tmp2 = Mpy_32_32( s_fx, s_fx );
+ q_tmp2 = sub( add( q_tmp1, q_tmp1 ), 31 );
+
+ tmp2 = BASOP_Util_Add_Mant32Exp( crossSquare_fx, sub( 31, q_crossSquare ), tmp2, sub( 31, q_tmp2 ), &q_tmp2 );
+ q_tmp2 = sub( 31, q_tmp2 );
+
+ tmp3 = BASOP_Util_Add_Mant32Exp( tmp2, sub( 31, q_tmp2 ), epsilon_mant, epsilon_exp, &exp_tmp3 );
+
+ tmp2 = BASOP_Util_Divide3232_Scale_newton( ONE_IN_Q30, tmp3, &exp );
+ exp = sub( exp, sub( Q30, sub( 31, exp_tmp3 ) ) );
+ normVal_fx = Sqrt32( tmp2, &exp ); // q_tmp2
+ q_tmp2 = sub( 31, exp );
+
+ q_diff = sub( q_c, q_tmp1 );
+ IF( q_diff > 0 )
+ {
+ c_re = L_shr( c_re, q_diff );
+ c_im = L_shr( c_im, q_diff );
+ q_c = q_tmp1;
+ move16();
+ }
+ ELSE
+ {
+ s_fx = L_shl( s_fx, q_diff );
+ q_tmp1 = q_c;
+ move16();
+ }
+
+ Ure_fx[1][ch] = Mpy_32_32( s_fx, normVal_fx );
+ move32();
+ Ure_fx[0][ch] = Mpy_32_32( c_re, normVal_fx );
+ move32();
+ Uim_fx[0][ch] = Mpy_32_32( L_negate( c_im ), normVal_fx );
+ move32();
+ q_U_2 = sub( add( q_tmp1, q_tmp2 ), 31 );
+
+ IF( q_U_1 != 0 )
+ {
+ q_diff = sub( q_U_2, q_U_1 );
+ IF( q_diff > 0 )
+ {
+ Ure_fx[1][ch] = L_shr( Ure_fx[1][ch], q_diff );
+ Ure_fx[0][ch] = L_shr( Ure_fx[0][ch], q_diff );
+ Uim_fx[0][ch] = L_shr( Uim_fx[0][ch], q_diff );
+ q_U_2 = q_U_1;
+ move32();
+ move32();
+ move32();
+ move16();
+ }
+ ELSE IF( GT_16( q_U_1, q_U_2 ) )
+ {
+ Ure_fx[1][ch - 1] = L_shl( Ure_fx[1][ch - 1], q_diff );
+ Ure_fx[0][ch - 1] = L_shl( Ure_fx[0][ch - 1], q_diff );
+ Uim_fx[1][ch - 1] = L_shl( Uim_fx[1][ch - 1], q_diff );
+ q_U_1 = q_U_2;
+ move32();
+ move32();
+ move32();
+ move16();
+ }
+ }
+ q_U_1 = q_U_2;
+ move16();
+ }
+ }
+#else /* OPT_SBA_REND_V1_BE */
/* Eigenvectors */
FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ )
{
@@ -3312,17 +3609,10 @@ static void eig2x2_fx(
tmp3 = BASOP_Util_Add_Mant32Exp( tmp2, sub( 31, q_tmp2 ), epsilon_mant, epsilon_exp, &exp_tmp3 );
-#if 1
tmp2 = BASOP_Util_Divide3232_Scale_newton( ONE_IN_Q30, tmp3, &exp );
exp = sub( exp, sub( Q30, sub( 31, exp_tmp3 ) ) );
normVal_fx = Sqrt32( tmp2, &exp ); // q_tmp2
q_tmp2 = sub( 31, exp );
-#else
- /* Note: This code part does not work yet, see pipeline issue for BASOP #1009 */
- /* although the same code works at other places: mantissa and q_format is fine */
- normVal_fx = ISqrt32( tmp3, &exp );
- q_tmp2 = sub( 31, exp );
-#endif
IF( LT_16( q_tmp1, q_c ) )
{
@@ -3388,17 +3678,10 @@ static void eig2x2_fx(
tmp3 = BASOP_Util_Add_Mant32Exp( tmp2, sub( 31, q_tmp2 ), epsilon_mant, epsilon_exp, &exp_tmp3 );
-#if 1
tmp2 = BASOP_Util_Divide3232_Scale_newton( ONE_IN_Q30, tmp3, &exp );
exp = sub( exp, sub( Q30, sub( 31, exp_tmp3 ) ) );
normVal_fx = Sqrt32( tmp2, &exp ); // q_tmp2
q_tmp2 = sub( 31, exp );
-#else
- /* Note: This code part does not work yet, see pipeline issue for BASOP #1009 */
- /* although the same code works at other places: mantissa and q_format is fine */
- normVal_fx = ISqrt32( tmp3, &exp_tmp3 );
- q_tmp2 = sub( 31, exp_tmp3 );
-#endif
IF( LT_16( q_tmp1, q_c ) )
{
@@ -3451,6 +3734,8 @@ static void eig2x2_fx(
move16();
}
}
+#endif /* OPT_SBA_REND_V1_BE */
+
if ( q_U_1 != 0 )
{
*q_U = q_U_1;
@@ -3583,24 +3868,53 @@ static void matrixTransp1Mul_fx(
Word16 chA, chB;
Word16 size = i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS );
+ Word64 tmp_outRe_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS];
+ Word64 tmp_outIm_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS];
+ Word16 q_tmp_outRe_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS];
+ Word16 q_tmp_outIm_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS];
+ Word64 tmp64_1, tmp64_2;
+ Word16 tmp16, q_common = 63;
+ move16();
+
+ FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ )
+ {
+ FOR( chB = 0; chB < BINAURAL_CHANNELS; chB++ )
+ {
+ tmp64_1 = W_mac_32_32( W_mult_32_32( Are_fx[0][chA], Bre_fx[0][chB] ), Are_fx[1][chA], Bre_fx[1][chB] ); // Q: add( add( q_A, q_B ), 1 )
+ tmp64_2 = W_mac_32_32( W_mult_32_32( Aim_fx[0][chA], Bim_fx[0][chB] ), Aim_fx[1][chA], Bim_fx[1][chB] ); // Q: add( add( q_A, q_B ), 1 )
+ tmp_outRe_fx[chA][chB] = W_add( tmp64_1, tmp64_2 ); // Q: add( add( q_A, q_B ), 1 )
+ move64();
+ tmp16 = W_norm( tmp_outRe_fx[chA][chB] );
+ tmp_outRe_fx[chA][chB] = W_shl( tmp_outRe_fx[chA][chB], tmp16 ); // Q:add( tmp16, add( add( q_A, q_B ), 1 ) )
+ move64();
+ q_tmp_outRe_fx[chA][chB] = add( tmp16, add( add( q_A, q_B ), 1 ) );
+ move16();
+ q_common = s_min( q_tmp_outRe_fx[chA][chB], q_common );
+
+
+ tmp64_1 = W_mac_32_32( W_mult_32_32( Are_fx[0][chA], Bim_fx[0][chB] ), Are_fx[1][chA], Bim_fx[1][chB] ); // Q: add( add( q_A, q_B ), 1 )
+ tmp64_2 = W_mac_32_32( W_mult_32_32( Aim_fx[0][chA], Bre_fx[0][chB] ), Aim_fx[1][chA], Bre_fx[1][chB] ); // Q: add( add( q_A, q_B ), 1 )
+ tmp_outIm_fx[chA][chB] = W_sub( tmp64_1, tmp64_2 ); // Q: add( add( q_A, q_B ), 1 )
+ move64();
+ tmp16 = W_norm( tmp_outIm_fx[chA][chB] );
+ tmp_outIm_fx[chA][chB] = W_shl( tmp_outIm_fx[chA][chB], tmp16 ); // Q:add( tmp16, add( add( q_A, q_B ), 1 ) )
+ move64();
+ q_tmp_outIm_fx[chA][chB] = add( tmp16, add( add( q_A, q_B ), 1 ) );
+ move16();
+ q_common = s_min( q_tmp_outIm_fx[chA][chB], q_common );
+ }
+ }
FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ )
{
FOR( chB = 0; chB < BINAURAL_CHANNELS; chB++ )
{
- outRe_fx[chA][chB] = Madd_32_32( Madd_32_32( Madd_32_32( Mpy_32_32( Are_fx[0][chA], Bre_fx[0][chB] ),
- Are_fx[1][chA], Bre_fx[1][chB] ),
- Aim_fx[0][chA], Bim_fx[0][chB] ),
- Aim_fx[1][chA], Bim_fx[1][chB] );
+ outRe_fx[chA][chB] = W_extract_h( W_shl( tmp_outRe_fx[chA][chB], sub( q_common, q_tmp_outRe_fx[chA][chB] ) ) );
move32();
- outIm_fx[chA][chB] = Msub_32_32( Msub_32_32( Madd_32_32( Mpy_32_32( Are_fx[0][chA], Bim_fx[0][chB] ),
- Are_fx[1][chA], Bim_fx[1][chB] ),
- Aim_fx[0][chA], Bre_fx[0][chB] ),
- Aim_fx[1][chA], Bre_fx[1][chB] );
+ outIm_fx[chA][chB] = W_extract_h( W_shl( tmp_outIm_fx[chA][chB], sub( q_common, q_tmp_outIm_fx[chA][chB] ) ) );
move32();
}
}
- *q_out = sub( add( q_A, q_B ), 31 );
-
+ *q_out = sub( q_common, 32 );
move16();
if ( L_and( is_zero_arr( outRe_fx[0], size ), is_zero_arr( outIm_fx[0], size ) ) )
{
@@ -3626,7 +3940,7 @@ static void matrixTransp2Mul_fx(
{
Word16 chA, chB;
Word16 min_q_shift;
- Word16 size = i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS );
+ Word16 size = BINAURAL_CHANNELS * BINAURAL_CHANNELS;
IF( Ascale == 1 )
{
@@ -4075,10 +4389,18 @@ static void formulate2x2MixingMatrix_fx(
Sx_fx[1] = Sqrt32( Sx_fx[1], &exp1 );
move32();
q_Sx = sub( 31, s_max( exp, exp1 ) );
+#ifdef OPT_BIN_RENDERER_V1
+ Word16 q_diff = sub( 31, q_Sx );
+ Sx_fx[0] = L_shr( Sx_fx[0], sub( q_diff, exp ) ); // q_Sx
+ move32();
+ Sx_fx[1] = L_shr( Sx_fx[1], sub( q_diff, exp1 ) ); // q_Sx
+ move32();
+#else /* OPT_BIN_RENDERER_V1 */
Sx_fx[0] = L_shr( Sx_fx[0], sub( sub( 31, exp ), q_Sx ) ); // q_Sx
move32();
Sx_fx[1] = L_shr( Sx_fx[1], sub( sub( 31, exp1 ), q_Sx ) ); // q_Sx
move32();
+#endif /* OPT_BIN_RENDERER_V1 */
matrixDiagMul_fx( Uxre_fx, Uxim_fx, q_Ux, Sx_fx, q_Sx, Kxre_fx, Kxim_fx, &q_Kx );
@@ -4146,11 +4468,18 @@ static void formulate2x2MixingMatrix_fx(
move32();
q_Ghat = sub( 31, s_max( exp, exp1 ) );
-
+#ifdef OPT_BIN_RENDERER_V1
+ q_diff = sub( 31, q_Ghat );
+ Ghat_fx[0] = L_shr( Ghat_fx[0], sub( q_diff, exp ) ); // q_Ghat
+ move32();
+ Ghat_fx[1] = L_shr( Ghat_fx[1], sub( q_diff, exp1 ) ); // q_Ghat
+ move32();
+#else /* OPT_BIN_RENDERER_V1 */
Ghat_fx[0] = L_shr( Ghat_fx[0], sub( sub( 31, exp ), q_Ghat ) ); // q_Ghat
move32();
Ghat_fx[1] = L_shr( Ghat_fx[1], sub( sub( 31, exp1 ), q_Ghat ) ); // q_Ghat
move32();
+#endif /* OPT_BIN_RENDERER_V1 */
/* Matrix multiplication, tmp = Ky' * G_hat * Q */
FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ )
@@ -4163,8 +4492,8 @@ static void formulate2x2MixingMatrix_fx(
q_GhatQ = sub( add( Q31, q_Ghat ), 31 );
exp = sub( s_min( L_norm_arr( KyRe_fx[0], i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ) ), L_norm_arr( KyIm_fx[0], i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ) ) ), 1 );
- scale_sig32( KyRe_fx[0], i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ), exp );
- scale_sig32( KyIm_fx[0], i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ), exp );
+ scale_sig32( KyRe_fx[0], BINAURAL_CHANNELS * BINAURAL_CHANNELS, exp );
+ scale_sig32( KyIm_fx[0], BINAURAL_CHANNELS * BINAURAL_CHANNELS, exp );
q_ky = add( q_ky, exp );
FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ )
@@ -4172,7 +4501,7 @@ static void formulate2x2MixingMatrix_fx(
FOR( chB = 0; chB < BINAURAL_CHANNELS; chB++ )
{
tmpRe_fx[chA][chB] = Madd_32_32( Mpy_32_32( KyRe_fx[0][chA], GhatQ_fx[0][chB] ), KyRe_fx[1][chA], GhatQ_fx[1][chB] );
- tmpIm_fx[chA][chB] = Msub_32_32( Mpy_32_32( -KyIm_fx[0][chA], GhatQ_fx[0][chB] ), KyIm_fx[1][chA], GhatQ_fx[1][chB] );
+ tmpIm_fx[chA][chB] = Msub_32_32( Mpy_32_32( L_negate( KyIm_fx[0][chA] ), GhatQ_fx[0][chB] ), KyIm_fx[1][chA], GhatQ_fx[1][chB] );
move32();
move32();
}
@@ -4222,6 +4551,11 @@ static void formulate2x2MixingMatrix_fx(
move32();
// 1310720000 = 10,000.0f in Q17
+#ifdef OPT_BIN_RENDERER_V1
+ Word32 thresh = L_shl_sat( 1310720000, sub( q_div, Q17 ) ); // q_div
+ div_fx[0] = L_min( div_fx[0], thresh ); // q_div
+ div_fx[1] = L_min( div_fx[1], thresh ); // q_div
+#else /* OPT_BIN_RENDERER_V1 */
IF( LT_16( q_div, Q17 ) )
{
div_fx[0] = L_min( L_shr( 1310720000, sub( Q17, q_div ) ), div_fx[0] ); // q_div
@@ -4238,6 +4572,7 @@ static void formulate2x2MixingMatrix_fx(
q_div = Q17;
move16();
}
+#endif /* OPT_BIN_RENDERER_V1 */
matrixMul_fx( Are_fx, Aim_fx, &q_A, Ure_fx, Uim_fx, &q_U, tmpRe_fx, tmpIm_fx, &q_temp );
@@ -4254,6 +4589,13 @@ static void formulate2x2MixingMatrix_fx(
W_tmp = W_mult0_32_32( tmpRe_fx[chA][chB], div_fx[chB] );
IF( W_tmp != 0 )
{
+#ifdef OPT_BIN_RENDERER_V1
+ Word16 hdrm = sub( W_norm( W_tmp ), 32 );
+ tmpRe_fx[chA][chB] = W_shl_sat_l( W_tmp, hdrm );
+ move32();
+ hdrm_re[chA][chB] = add( add( q_temp, q_div ), hdrm );
+ move16();
+#else /* OPT_BIN_RENDERER_V1 */
hdrm_re[chA][chB] = sub( W_norm( W_tmp ), 0 );
move16();
W_tmp = W_shl( W_tmp, hdrm_re[chA][chB] );
@@ -4261,6 +4603,7 @@ static void formulate2x2MixingMatrix_fx(
move32();
hdrm_re[chA][chB] = sub( add( add( q_temp, q_div ), hdrm_re[chA][chB] ), 32 );
move16();
+#endif /* OPT_BIN_RENDERER_V1 */
}
ELSE
{
@@ -4271,6 +4614,14 @@ static void formulate2x2MixingMatrix_fx(
W_tmp = W_mult0_32_32( tmpIm_fx[chA][chB], div_fx[chB] );
IF( W_tmp != 0 )
{
+#ifdef OPT_BIN_RENDERER_V1
+ Word16 hdrm = sub( W_norm( W_tmp ), 32 );
+ move16();
+ tmpIm_fx[chA][chB] = W_shl_sat_l( W_tmp, hdrm );
+ move32();
+ hdrm_im[chA][chB] = add( add( q_temp, q_div ), hdrm );
+ move16();
+#else /* OPT_BIN_RENDERER_V1 */
hdrm_im[chA][chB] = sub( W_norm( W_tmp ), 0 );
move16();
W_tmp = W_shl( W_tmp, hdrm_im[chA][chB] );
@@ -4278,6 +4629,7 @@ static void formulate2x2MixingMatrix_fx(
move32();
hdrm_im[chA][chB] = sub( add( add( q_temp, q_div ), hdrm_im[chA][chB] ), 32 );
move16();
+#endif /* OPT_BIN_RENDERER_V1 */
}
ELSE
{
@@ -4290,8 +4642,11 @@ static void formulate2x2MixingMatrix_fx(
minimum_s( hdrm_re[0], i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ), &exp );
q_temp = exp;
move16();
- minimum_s( hdrm_im[0], i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ), &exp );
+ minimum_s( hdrm_im[0], BINAURAL_CHANNELS * BINAURAL_CHANNELS, &exp );
q_temp = s_min( q_temp, exp );
+#ifdef OPT_BIN_RENDERER_V1
+ q_temp = sub( q_temp, 1 );
+#endif /* OPT_BIN_RENDERER_V1 */
FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ )
{
@@ -4305,7 +4660,11 @@ static void formulate2x2MixingMatrix_fx(
}
matrixTransp2Mul_fx( tmpRe_fx, tmpIm_fx, &q_temp, Ure_fx, Uim_fx, &q_U,
+#ifdef OPT_BIN_RENDERER_V1
+ 0 /*int Ascale*/,
+#else /* OPT_BIN_RENDERER_V1 */
1 /*int Ascale*/,
+#endif /* OPT_BIN_RENDERER_V1 */
0 /*int Bscale*/,
Pre_fx, Pim_fx, &q_P ); /* Nearest orthonormal matrix P to matrix A formulated */
@@ -4422,9 +4781,9 @@ static void formulate2x2MixingMatrix_fx(
move16();
}
#endif
- minimum_s( q_Pre[0], i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ), &exp );
+ minimum_s( q_Pre[0], BINAURAL_CHANNELS * BINAURAL_CHANNELS, &exp );
q_P = s_min( q_P, exp );
- minimum_s( q_Pim[0], i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ), &exp );
+ minimum_s( q_Pim[0], BINAURAL_CHANNELS * BINAURAL_CHANNELS, &exp );
q_P = s_min( q_P, exp );
FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ )
diff --git a/lib_rend/ivas_dirac_decorr_dec_fx.c b/lib_rend/ivas_dirac_decorr_dec_fx.c
index 1afac99c4157d81f9bba3dcdb70fd94669950391..aa4aed84cd85ed7c3792396b486c102560ab4843 100644
--- a/lib_rend/ivas_dirac_decorr_dec_fx.c
+++ b/lib_rend/ivas_dirac_decorr_dec_fx.c
@@ -63,8 +63,8 @@
* Local function prototypes
*------------------------------------------------------------------------*/
-static void get_lattice_coeffs_fx( const Word16 band_index, const Word16 channel_index, Word16 *lattice_coeffs );
-static void lattice2allpass_fx( const Word16 filter_length, const Word16 *lattice_coeffs_fx, Word16 *filter_coeffs_num_real_fx, Word16 *filter_coeffs_den_real_fx );
+static void get_lattice_coeffs_fx( const Word16 band_index, const Word16 channel_index, Word32 *lattice_coeffs );
+static void lattice2allpass_fx( const Word16 filter_length, const Word32 *lattice_coeffs_fx, Word32 *filter_coeffs_num_real_fx, Word32 *filter_coeffs_den_real_fx );
/*-------------------------------------------------------------------------
* ivas_dirac_dec_decorr_open()
@@ -90,7 +90,8 @@ ivas_error ivas_dirac_dec_decorr_open_fx(
Word16 split_frequencies_bands[DIRAC_DECORR_NUM_SPLIT_BANDS + 1] = { 0, 0, 0, 23768 };
move16();
Word16 *split_freq_ptr;
- Word16 cur_lattice_delta_phi_fx, lattice_coeffs_fx[2 * DIRAC_MAX_DECORR_FILTER_LEN];
+ Word16 cur_lattice_delta_phi_fx;
+ Word32 lattice_coeffs_fx[2 * DIRAC_MAX_DECORR_FILTER_LEN];
ivas_error error;
@@ -277,12 +278,12 @@ ivas_error ivas_dirac_dec_decorr_open_fx(
freq_domain_decorr_ap_state->q_decorr_buffer = Q31;
move16();
- IF( ( freq_domain_decorr_ap_params->filter_coeff_num_real_fx = (Word16 *) malloc( sizeof( Word16 ) * imult1616( add( ap_filter_length[split_band_index_start], 1 ), imult1616( freq_domain_decorr_ap_params->max_band_decorr, num_outputs_diff ) ) ) ) == NULL )
+ IF( ( freq_domain_decorr_ap_params->filter_coeff_num_real_fx = (Word32 *) malloc( sizeof( Word32 ) * imult1616( add( ap_filter_length[split_band_index_start], 1 ), imult1616( freq_domain_decorr_ap_params->max_band_decorr, num_outputs_diff ) ) ) ) == NULL )
{
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD decorrelator\n" ) );
}
- IF( ( freq_domain_decorr_ap_params->filter_coeff_den_real_fx = (Word16 *) malloc( sizeof( Word16 ) * imult1616( add( ap_filter_length[split_band_index_start], 1 ), imult1616( freq_domain_decorr_ap_params->max_band_decorr, num_outputs_diff ) ) ) ) == NULL )
+ IF( ( freq_domain_decorr_ap_params->filter_coeff_den_real_fx = (Word32 *) malloc( sizeof( Word32 ) * imult1616( add( ap_filter_length[split_band_index_start], 1 ), imult1616( freq_domain_decorr_ap_params->max_band_decorr, num_outputs_diff ) ) ) ) == NULL )
{
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD decorrelator\n" ) );
}
@@ -414,7 +415,7 @@ void ivas_dirac_dec_decorr_process_fx(
Word32 frame_ma_fx[2 * ( DIRAC_MAX_DECORR_FILTER_LEN + 1 )];
Word32 *p_frame_dec_fx, *decorr_buffer_fx;
Word16 *phase_coeff_real_fx, *phase_coeff_imag_fx;
- Word16 *filter_coeff_num_real_fx, *filter_coeff_den_real_fx;
+ Word32 *filter_coeff_num_real_fx, *filter_coeff_den_real_fx;
Word32 *decorr_buffer_start_ptr_fx, *decorr_buffer_ptr_fx;
Word32 input_real_fx, input_imag_fx, filter_frame_imag_fx, filter_frame_real_fx;
Word16 q_aux_buffer, q_onset_dec, q_frame_f;
@@ -481,6 +482,7 @@ void ivas_dirac_dec_decorr_process_fx(
q_shift = 0;
move16();
}
+ set32_fx( aux_buffer_fx, 0, 2 * MAX_OUTPUT_CHANNELS * CLDFB_NO_CHANNELS_MAX );
FOR( ch_idx = 0; ch_idx < num_protos_dir; ch_idx++ )
{
v_shr( &input_frame_fx[imult1616( 2, imult1616( ch_idx, num_freq_bands ) )], negate( q_shift ), &aux_buffer_fx[imult1616( 2, imult1616( ch_idx, num_freq_bands ) )], imult1616( 2, num_freq_bands ) ); // Q - q_shift
@@ -495,6 +497,11 @@ void ivas_dirac_dec_decorr_process_fx(
{
v_add_inc_fx( &aux_buffer_fx[imult1616( 2, imult1616( ch_idx, max_band_decorr_temp ) )], 2, &aux_buffer_fx[add( imult1616( 2, imult1616( ch_idx, max_band_decorr_temp ) ), 1 )], 2, &aux_buffer_fx[imult1616( ch_idx, max_band_decorr_temp )], 1, max_band_decorr_temp ); // q_aux_buffer
}
+ if ( is_zero_arr( aux_buffer_fx, 2 * MAX_OUTPUT_CHANNELS * CLDFB_NO_CHANNELS_MAX ) )
+ {
+ q_aux_buffer = 31;
+ move16();
+ }
/* compute onset filter */
max_band_decorr = h_freq_domain_decorr_ap_params->max_band_decorr;
move16();
@@ -666,8 +673,8 @@ void ivas_dirac_dec_decorr_process_fx(
/* MA part of filter impulse response */
FOR( l = 0; l < filter_length; l++ )
{
- frame_ma_fx[2 * l] = Mpy_32_16_1( input_real_fx, filter_coeff_num_real_fx[l] ); // Q_qux -3 = q_deorr
- frame_ma_fx[2 * l + 1] = Mpy_32_16_1( input_imag_fx, filter_coeff_num_real_fx[l] ); // Q_qux - 3 = q_deorr
+ frame_ma_fx[2 * l] = Mpy_32_32( input_real_fx, filter_coeff_num_real_fx[l] ); // Q_qux -3 = q_deorr
+ frame_ma_fx[2 * l + 1] = Mpy_32_32( input_imag_fx, filter_coeff_num_real_fx[l] ); // Q_qux - 3 = q_deorr
move32();
move32();
}
@@ -691,12 +698,12 @@ void ivas_dirac_dec_decorr_process_fx(
FOR( l = 1; l < filter_length; l++ )
{
// q adjustment needed//
- Word32 temp_1 = Mpy_32_16_1( filter_frame_real_fx, filter_coeff_den_real_fx[l] ); // q_decorr - 3
+ Word32 temp_1 = Mpy_32_32( filter_frame_real_fx, filter_coeff_den_real_fx[l] ); // q_decorr - 3
temp_1 = L_shl( temp_1, 3 ); // q_decorr
decorr_buffer_ptr_fx[0] = L_sub( L_add( decorr_buffer_ptr_fx[0], frame_ma_fx[2 * l] ), temp_1 ); // q_deocor
move32();
- Word32 temp_2 = Mpy_32_16_1( filter_frame_imag_fx, filter_coeff_den_real_fx[l] ); // q_decorr - 3
+ Word32 temp_2 = Mpy_32_32( filter_frame_imag_fx, filter_coeff_den_real_fx[l] ); // q_decorr - 3
temp_2 = L_shl( temp_2, 3 ); // q_decorr
decorr_buffer_ptr_fx[1] = L_sub( L_add( decorr_buffer_ptr_fx[1], frame_ma_fx[2 * l + 1] ), temp_2 ); // q_decorr
move32();
@@ -1146,16 +1153,16 @@ void ivas_dirac_dec_decorr_close_fx(
static void get_lattice_coeffs_fx(
const Word16 band_index, // Q0
const Word16 channel_index, // Q0
- Word16 *lattice_coeffs ) // Q12
+ Word32 *lattice_coeffs ) // Q31
{
Word16 k;
FOR( k = 0; k < ap_filter_length[band_index]; k++ )
{
- Word16 cur_lattice_coeff = ap_lattice_coeffs_fx[band_index][add( imult1616( channel_index, ap_filter_length[band_index] ), k )]; // Q12
- lattice_coeffs[k] = cur_lattice_coeff; // Q12
- move16();
- move16();
+ Word32 cur_lattice_coeff = ap_lattice_coeffs_fx[band_index][add( imult1616( channel_index, ap_filter_length[band_index] ), k )]; // Q31
+ lattice_coeffs[k] = cur_lattice_coeff; // Q31
+ move32();
+ move32();
}
return;
@@ -1165,40 +1172,40 @@ static void get_lattice_coeffs_fx(
/* convert lattice filter coeffs to all pass transfer function coeffs */
static void lattice2allpass_fx(
const Word16 filter_length, // Q0
- const Word16 *lattice_coeffs_fx, // Q15
- Word16 *filter_coeffs_num_real_fx, // Q12
- Word16 *filter_coeffs_den_real_fx ) // Q12
+ const Word32 *lattice_coeffs_fx, // Q31
+ Word32 *filter_coeffs_num_real_fx, // Q28
+ Word32 *filter_coeffs_den_real_fx ) // Q28
{
Word16 i, p;
- Word16 alpha_real_fx[2][DIRAC_MAX_DECORR_FILTER_LEN + 1];
- Word16 *alpha_real_p_old_fx = &alpha_real_fx[0][0];
- Word16 *alpha_real_p_fx = &alpha_real_fx[1][0];
- Word16 *tmp_fx;
+ Word32 alpha_real_fx[2][DIRAC_MAX_DECORR_FILTER_LEN + 1];
+ Word32 *alpha_real_p_old_fx = &alpha_real_fx[0][0];
+ Word32 *alpha_real_p_fx = &alpha_real_fx[1][0];
+ Word32 *tmp_fx;
FOR( i = 0; i < 2; i++ )
{
- set16_fx( alpha_real_fx[i], 0, DIRAC_MAX_DECORR_FILTER_LEN + 1 );
+ set32_fx( alpha_real_fx[i], 0, DIRAC_MAX_DECORR_FILTER_LEN + 1 );
}
- alpha_real_p_fx[0] = ONE_IN_Q12;
- move16();
- alpha_real_p_old_fx[0] = ONE_IN_Q12;
- move16();
+ alpha_real_p_fx[0] = ONE_IN_Q28;
+ move32();
+ alpha_real_p_old_fx[0] = ONE_IN_Q28;
+ move32();
/* recursion */
- Word16 lattice_alpha = 0;
- move16();
+ Word32 lattice_alpha = 0;
+ move32();
FOR( p = 1; p < filter_length; p++ )
{
- alpha_real_p_fx[p] = shr( lattice_coeffs_fx[( p - 1 )], 3 ); /* Q12 */
+ alpha_real_p_fx[p] = L_shr( lattice_coeffs_fx[( p - 1 )], 3 ); /* Q28 */
move16();
FOR( i = 1; i < p; i++ )
{
- lattice_alpha = mult( lattice_coeffs_fx[( p - 1 )], alpha_real_p_old_fx[sub( p, i )] ); /* Q12 */
- alpha_real_p_fx[i] = add( alpha_real_p_old_fx[i], lattice_alpha ); /* Q12 */
- move16();
+ lattice_alpha = Mpy_32_32( lattice_coeffs_fx[( p - 1 )], alpha_real_p_old_fx[sub( p, i )] ); /* Q28 */
+ alpha_real_p_fx[i] = L_add( alpha_real_p_old_fx[i], lattice_alpha ); /* Q28 */
+ move32();
}
/* switch pointers */
tmp_fx = alpha_real_p_old_fx;
@@ -1208,10 +1215,10 @@ static void lattice2allpass_fx(
FOR( i = 0; i < filter_length; i++ )
{
- filter_coeffs_den_real_fx[i] = alpha_real_p_old_fx[i]; /* Q12 */
- move16();
- filter_coeffs_num_real_fx[i] = alpha_real_p_old_fx[sub( sub( filter_length, i ), 1 )]; /* Q12 */
- move16();
+ filter_coeffs_den_real_fx[i] = alpha_real_p_old_fx[i]; /* Q28 */
+ move32();
+ filter_coeffs_num_real_fx[i] = alpha_real_p_old_fx[sub( sub( filter_length, i ), 1 )]; /* Q28 */
+ move32();
}
return;
diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c
index 509eec6e2430d59506bf0fa711741fe2d771afd9..c96878d553fc7654f52080b1ae514946ecc6c39f 100644
--- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c
+++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c
@@ -200,6 +200,12 @@ ivas_error ivas_dirac_dec_output_synthesis_open_fx(
}
dirac_output_synthesis_state->cy_cross_dir_smooth_prev_len = size;
move16();
+
+ IF( ( dirac_output_synthesis_state->Q_temp_cy_cross_dir_smooth_fx = (Word16 *) malloc( hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_dir * sizeof( Word32 ) ) ) == NULL )
+ {
+ return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) );
+ }
+
IF( EQ_32( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) )
{
dirac_output_synthesis_state->cy_auto_dir_smooth_prev_fx = NULL;
@@ -609,6 +615,11 @@ void ivas_dirac_dec_output_synthesis_close_fx(
free( ( dirac_output_synthesis_state )->cy_cross_dir_smooth_prev_fx );
( dirac_output_synthesis_state )->cy_cross_dir_smooth_prev_fx = NULL;
}
+ IF( ( dirac_output_synthesis_state )->Q_temp_cy_cross_dir_smooth_fx != NULL )
+ {
+ free( ( dirac_output_synthesis_state )->Q_temp_cy_cross_dir_smooth_fx );
+ ( dirac_output_synthesis_state )->Q_temp_cy_cross_dir_smooth_fx = NULL;
+ }
IF( ( dirac_output_synthesis_state )->cy_auto_diff_smooth_prev_fx != NULL )
{
free( ( dirac_output_synthesis_state )->cy_auto_diff_smooth_prev_fx );
@@ -663,7 +674,7 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx(
Word16 num_freq_bands_diff, num_channels_diff;
Word16 ch_idx;
Word32 aux_buf[CLDFB_NO_CHANNELS_MAX];
- Word16 diff_start_band, tmp16;
+ Word16 diff_start_band;
DIRAC_OUTPUT_SYNTHESIS_PARAMS *h_dirac_output_synthesis_params;
DIRAC_OUTPUT_SYNTHESIS_STATE *h_dirac_output_synthesis_state;
@@ -816,15 +827,344 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx(
ONE_IN_Q29 /*0.25f Q31*/,
h_dirac_output_synthesis_state->diffuse_power_factor_fx,
num_freq_bands ); /*h_dirac_output_synthesis_state->diffuse_power_factor_q+Q31-Q31->h_dirac_output_synthesis_state->diffuse_power_factor_q*/
+#ifdef OPT_SBA_DEC_PATH
+ /*Direct gain*/
+
+ Word16 *exp_temp_cy_cross_dir_smooth_fx = (Word16 *) malloc( num_freq_bands * num_channels_dir * sizeof( Word16 ) );
+ Word16 cy_cross_dir_smooth_e = sub( 31, h_dirac_output_synthesis_state->q_cy_cross_dir_smooth );
+
+ FOR( Word16 kk = 0; kk < ( num_freq_bands * num_channels_dir ); kk++ )
+ {
+ exp_temp_cy_cross_dir_smooth_fx[kk] = cy_cross_dir_smooth_e; // h_dirac_output_synthesis_state->q_cy_cross_dir_smooth;
+ move16();
+ }
+
+ Word16 q_temp = sub( add( shl( h_dirac_output_synthesis_state->direct_responses_q, 1 ), q_diffuseness ), 62 );
+ Word32 one_in_qdiff = L_shl( 1, q_diffuseness );
+ Word32 c1 = Madd_32_16( ONE_IN_Q29 /*1 Q29*/, L_sub( h_dirac_output_synthesis_params->diffuse_compensation_factor_decorr_fx, ONE_IN_Q29 /*1 Q29*/ ), 5461 /*1.0 / 6.0 Q15*/ ); /*Diffuseness modellling nrg compensation*/ /*Q29*/
+ Word16 q_diff_c = sub( q_diffuseness, 2 );
+
+ FOR( ch_idx = 0; ch_idx < s_min( 4, nchan_transport ); ch_idx++ )
+ {
+ Word16 k;
+ IF( ch_idx != 0 )
+ {
+ Word32 a, c;
+ Word16 b, b_exp, sqr_exp, q_diff_aab; // , q_diff_c;
+ Word32 mpy_a_a_b, mpy_diff_c, mpy_diff_aab;
+ Word32 sqr_inp, sqr;
+
+ /*Directonal sound gain nrg compensation*/
+ FOR( k = 0; k < num_freq_bands_diff; k++ )
+ {
+ a = h_dirac_output_synthesis_state->direct_responses_fx[ch_idx * num_freq_bands + k]; // Q = h_dirac_output_synthesis_state->q_direct_responses
+ move32();
+
+
+ b_exp = 0;
+ move16();
+
+ b = 0;
+ move16();
+
+ if ( 0 == reference_power[k + ( ch_idx + 1 ) * num_freq_bands] )
+ {
+ b = MAX_16;
+ move16();
+ }
+
+ test();
+ IF( reference_power[k + ( ch_idx + 1 ) * num_freq_bands] && reference_power[k + num_freq_bands] )
+ {
+ b = BASOP_Util_Divide3232_Scale( reference_power[k + num_freq_bands], reference_power[k + ( ch_idx + 1 ) * num_freq_bands], &b_exp ); /*Q(15-b_exp)*/
+ }
+
+
+ mpy_a_a_b = Mpy_32_32( a, Mpy_32_16_1( a, b ) ); // Q = (h_dirac_output_synthesis_state->q_direct_responses + (15 - b_exp) - 15) + (h_dirac_output_synthesis_state->q_direct_responses) - 31
+ mpy_diff_aab = Mpy_32_32( L_sub( one_in_qdiff, diffuseness[k] ), mpy_a_a_b ); // Q(q_diff_aab) = 2*(h_dirac_output_synthesis_state->q_direct_responses) - b_exp - 31 + q_diffuseness -31
+ mpy_diff_c = Mpy_32_32( diffuseness[k], c1 ); // Q(q_diff_c) = q_diffuseness - 2
+ q_diff_aab = sub( q_temp, b_exp ); // add( sub( add( h_dirac_output_synthesis_state->direct_responses_q, sub( 15, b_exp ) ), 15 ), add( sub( h_dirac_output_synthesis_state->direct_responses_q, 31 ), sub( q_diffuseness, 31 ) ) );
+
+ Word16 minq = sub( s_min( q_diff_aab, q_diff_c ), 1 );
+ Word32 op1 = L_shr( mpy_diff_aab, sub( q_diff_aab, minq ) );
+ Word32 op2 = L_shr( mpy_diff_c, sub( q_diff_c, minq ) );
+ sqr_inp = L_add( op1, op2 );
+ sqr_exp = sub( 31, minq );
+ sqr = Sqrt32( sqr_inp, &sqr_exp ); /*Q(31-sqr_exp)*/
+ sqr = L_shr( sqr, 2 ); /*Q(31-sqr_exp)*/
+ IF( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] != 0 )
+ {
+ IF( GT_16( sqr_exp, cy_cross_dir_smooth_e ) )
+ {
+ h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_shr( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sub( sqr_exp, cy_cross_dir_smooth_e ) ); /*h_dirac_output_synthesis_state->q_cy_cross_dir_smooth-> (31-sqr_exp) */
+ move32();
+ exp_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sqr_exp; // sub( 31, sqr_exp );
+ move16();
+ }
+ ELSE
+ {
+ sqr = L_shr( sqr, sub( cy_cross_dir_smooth_e, sqr_exp ) ); /*( 31- sqr_exp )-> h_dirac_output_synthesis_state->q_cy_cross_dir_smooth*/
+ }
+ h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*exp_temp_cy_cross_dir_smooth_fx*/
+ move32();
+ }
+ ELSE
+ {
+ h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sqr; // L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*31-sqr_exp*/
+ move32();
+ exp_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sqr_exp; // sub( 31, sqr_exp );
+ move16();
+ }
+ }
+ c = Madd_32_16( ONE_IN_Q27 /*1 Q27*/, L_sub( h_dirac_output_synthesis_params->diffuse_compensation_factor_fx, ONE_IN_Q27 /*1 Q27*/ ), 5461 ); /*Diffuseness modellling nrg compensation*/ /* 1.0 / 6.0 = 5461 in Q15*/ /*Q27*/
+ Word16 diff_c_exp = sub( q_diffuseness, 4 );
+#ifdef FIX_1310_SPEEDUP_ivas_dirac_dec_output_synthesis_process_slot
+ FOR( ; k < num_freq_bands; k++ )
+ {
+ a = h_dirac_output_synthesis_state->direct_responses_fx[ch_idx * num_freq_bands + k]; // Q = h_dirac_output_synthesis_state->q_direct_responses
+ move32();
+ IF( reference_power[k + num_freq_bands] == 0 )
+ {
+ sqr_inp = Mpy_32_32( diffuseness[k], c );
+ sqr_exp = sub( 31 + 4, q_diffuseness );
+ }
+ ELSE
+ {
+ Word16 diff_aab_exp;
+ IF( reference_power[k + ( ch_idx + 1 ) * num_freq_bands] == 0 )
+ {
+ mpy_a_a_b = Mpy_32_32( a, a ); // Q = (h_dirac_output_synthesis_state->q_direct_responses + (h_dirac_output_synthesis_state->q_direct_responses) - 31
+ mpy_diff_aab = Mpy_32_32( L_sub( one_in_qdiff, diffuseness[k] ), mpy_a_a_b ); // Q = 2*(h_dirac_output_synthesis_state->q_direct_responses) - 31 + q_diffuseness -31
+ mpy_diff_c = Mpy_32_32( diffuseness[k], c ); // Q = q_diffuseness - 4
+ diff_aab_exp = q_temp;
+ move16();
+ }
+ ELSE
+ {
+ b = BASOP_Util_Divide3232_Scale( reference_power[k + num_freq_bands], reference_power[k + ( ch_idx + 1 ) * num_freq_bands], &b_exp ); /*q(15-b_exp)*/
+
+ mpy_a_a_b = Mpy_32_32( a, Mpy_32_16_1( a, b ) ); // Q = (h_dirac_output_synthesis_state->q_direct_responses + (15 - b_exp) - 15) + (h_dirac_output_synthesis_state->q_direct_responses) - 31
+ mpy_diff_aab = Mpy_32_32( L_sub( one_in_qdiff, diffuseness[k] ), mpy_a_a_b ); // Q = 2*(h_dirac_output_synthesis_state->q_direct_responses) - b_exp - 31 + q_diffuseness -31
+ mpy_diff_c = Mpy_32_32( diffuseness[k], c ); // Q = q_diffuseness - 4
+ diff_aab_exp = sub( q_temp, b_exp ); // sub(sub(add(sub(31 + 62, h_dirac_output_synthesis_state->direct_responses_q), b_exp), h_dirac_output_synthesis_state->direct_responses_q), q_diffuseness);
+ }
+ Word16 minq = sub( s_min( diff_aab_exp, diff_c_exp ), 1 );
+ Word32 op1 = L_shr( mpy_diff_aab, sub( diff_aab_exp, minq ) );
+ Word32 op2 = L_shr( mpy_diff_c, sub( diff_c_exp, minq ) );
+ sqr_inp = L_add( op1, op2 );
+ sqr_exp = sub( 31, minq );
+ }
+ sqr = Sqrt32( sqr_inp, &sqr_exp ); /*Q(31-sqr_exp)*/
+ sqr = L_shr( sqr, 2 ); /*Q(31-sqr_exp)*/
+
+
+ IF( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] != 0 )
+ {
+ IF( GT_16( sqr_exp, cy_cross_dir_smooth_e ) )
+ {
+ h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_shr( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sub( sqr_exp, cy_cross_dir_smooth_e ) ); /*h_dirac_output_synthesis_state->q_cy_cross_dir_smooth->Q( 31- sqr_exp )*/
+ move32();
+ exp_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sqr_exp; // sub( 31, sqr_exp );
+ move16();
+ }
+ ELSE
+ {
+ sqr = L_shr( sqr, sub( cy_cross_dir_smooth_e, sqr_exp ) ); /*Q(31- sqr_exp)->h_dirac_output_synthesis_state->q_cy_cross_dir_smooth*/
+ }
+ h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*exp_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k]*/
+ move32();
+ }
+ ELSE
+ {
+ h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q(31- sqr_exp)*/
+ move32();
+ exp_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sqr_exp;
+ move16();
+ }
+ }
+
+#else
+ FOR( ; k < num_freq_bands; k++ )
+ {
+ a = h_dirac_output_synthesis_state->direct_responses_fx[ch_idx * num_freq_bands + k]; // Q = h_dirac_output_synthesis_state->q_direct_responses
+ move32();
+ IF( reference_power[k + num_freq_bands] == 0 )
+ {
+ b = 0;
+ move16();
+ b_exp = 0;
+ move16();
+ }
+ ELSE
+ {
+ IF( reference_power[k + ( ch_idx + 1 ) * num_freq_bands] == 0 )
+ {
+ b = MAX_16;
+ move16();
+ b_exp = 0;
+ move16();
+ }
+ ELSE
+ {
+ b = BASOP_Util_Divide3232_Scale( reference_power[k + num_freq_bands], reference_power[k + ( ch_idx + 1 ) * num_freq_bands], &b_exp ); /*q(15-b_exp)*/
+ }
+ }
+
+ mpy_a_a_b = Mpy_32_32( a, Mpy_32_16_1( a, b ) ); // Q = (h_dirac_output_synthesis_state->q_direct_responses + (15 - b_exp) - 15) + (h_dirac_output_synthesis_state->q_direct_responses) - 31
+ mpy_diff_aab = Mpy_32_32( L_sub( L_shl( 1, q_diffuseness ), diffuseness[k] ), mpy_a_a_b ); // Q = 2*(h_dirac_output_synthesis_state->q_direct_responses) - b_exp - 31 + q_diffuseness -31
+ mpy_diff_c = Mpy_32_32( diffuseness[k], c2 ); // Q = q_diffuseness - 4
+
+ q_diff_aab = add( add( h_dirac_output_synthesis_state->direct_responses_q, sub( sub( 15, b_exp ), 15 ) ), add( sub( h_dirac_output_synthesis_state->direct_responses_q, 31 ), sub( q_diffuseness, 31 ) ) );
+ q_diff_c = sub( q_diffuseness, 4 );
+ Word16 minq = sub( s_min( q_diff_aab, q_diff_c ), 1 );
+ Word32 op1 = L_shr( mpy_diff_aab, sub( q_diff_aab, minq ) );
+ Word32 op2 = L_shr( mpy_diff_c, sub( q_diff_c, minq ) );
+ sqr_inp = L_add( op1, op2 );
+ sqr_exp = sub( 31, minq );
+ sqr = Sqrt32( sqr_inp, &sqr_exp ); /*Q(31-sqr_exp)*/
+ sqr = L_shr( sqr, 2 ); /*Q(31-sqr_exp)*/
+ IF( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] != 0 )
+ {
+ IF( GT_16( sqr_exp, cy_cross_dir_smooth_e ) )
+ {
+ h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_shr( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sub( sqr_exp, cy_cross_dir_smooth_e ) ); /*h_dirac_output_synthesis_state->q_cy_cross_dir_smooth->Q( 31- sqr_exp )*/
+ move32();
+ Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sqr_exp; // sub( 31, sqr_exp );
+ move16();
+ }
+ ELSE
+ {
+ sqr = L_shr( sqr, sub( cy_cross_dir_smooth_e, sqr_exp ) ); /*Q(31- sqr_exp)->h_dirac_output_synthesis_state->q_cy_cross_dir_smooth*/
+ }
+ h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k]*/
+ move32();
+ }
+ ELSE
+ {
+ h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q(31- sqr_exp)*/
+ move32();
+ Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sqr_exp; // sub( 31, sqr_exp );
+ move16();
+ }
+ }
+#endif
+ }
+ ELSE
+ {
+ Word32 sqr_inp, sqr;
+ Word16 sqr_exp;
+ Word32 One_in_qdiff = L_shl( 1, sub( q_diffuseness, 1 ) );
+ Word32 diff = L_sub( h_dirac_output_synthesis_params->diffuse_compensation_factor_decorr_fx /*q29=0.5 * q30*/, ONE_IN_Q29 /*0.5 Q30*/ ); // Q30
+ Word16 sq_e = sub( 32, q_diffuseness ); // 31-(q_diffuseness-1)
+ /*Diffuseness modellling nrg compensation*/
+ FOR( k = 0; k < num_freq_bands_diff; k++ )
+ {
+ /*diffuseness[k] * 0.5f * ( h_dirac_output_synthesis_params->diffuse_compensation_factor_decorr - 1.f ) )*/
+ sqr_inp = Madd_32_32( One_in_qdiff, diffuseness[k], diff ); // Q = q_diffuseness - 1
+ sqr_exp = sq_e;
+ move16();
+ sqr = Sqrt32( sqr_inp, &sqr_exp ); /*Q(31-sqr_exp)*/
+ sqr = L_shr( sqr, 2 ); /*Q(31-sqr_exp)*/
+ IF( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] != 0 )
+ {
+ IF( LT_16( cy_cross_dir_smooth_e, sqr_exp ) )
+ {
+ h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_shr( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sub( sqr_exp, cy_cross_dir_smooth_e ) ); /*h_dirac_output_synthesis_state->q_cy_cross_dir_smooth->Q(31- sqr_exp)*/
+ move32();
+ exp_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sqr_exp; // sub( 31, sqr_exp );
+ move16();
+ }
+ ELSE
+ {
+ sqr = L_shr( sqr, sub( cy_cross_dir_smooth_e, sqr_exp ) ); /*Q(31-sqr_exp)->h_dirac_output_synthesis_state->q_cy_cross_dir_smooth*/
+ }
+ h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*exp_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k]*/
+ move32();
+ }
+ ELSE
+ {
+ h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sqr; /*Q(31-sqr_exp)*/
+ move32();
+ exp_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sqr_exp; // sub( 31, sqr_exp );
+ move16();
+ }
+ }
+ FOR( ; k < num_freq_bands; k++ )
+ {
+ sqr_inp = Madd_32_32( One_in_qdiff, diffuseness[k], L_sub( h_dirac_output_synthesis_params->diffuse_compensation_factor_decorr_fx, ONE_IN_Q29 /*1 Q29*/ ) ); // Q = q_diffuseness - 1
+ sqr_exp = sq_e;
+ move16();
+ sqr = Sqrt32( sqr_inp, &sqr_exp ); /*Q(31-sqr_exp)*/
+ sqr = L_shr( sqr, 2 ); /*Q(31-sqr_exp)*/
+ IF( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] != 0 )
+ {
+ IF( GT_16( sqr_exp, cy_cross_dir_smooth_e ) )
+ {
+ h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_shr( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sub( sqr_exp, cy_cross_dir_smooth_e ) ); /*h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, Q( 31- sqr_exp )*/
+ move32();
+ exp_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sqr_exp; // sub( 31, sqr_exp );
+ move16();
+ }
+ ELSE
+ {
+ sqr = L_shr( sqr, sub( cy_cross_dir_smooth_e, sqr_exp ) ); /*Q( 31- sqr_exp ), h_dirac_output_synthesis_state->q_cy_cross_dir_smooth*/
+ }
+ h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*exp_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k]*/
+ move32();
+ }
+ ELSE
+ {
+ h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q(31-sqr_exp)*/
+ move32();
+ exp_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sqr_exp;
+ move16();
+ }
+ }
+ }
+ }
+ Word16 temp = exp_temp_cy_cross_dir_smooth_fx[0]; /*q0*/
+ move16();
+ FOR( Word16 kk = 1; kk < ( num_freq_bands * num_channels_dir ); kk++ )
+ {
+ temp = s_max( exp_temp_cy_cross_dir_smooth_fx[kk], temp );
+ }
+
+
+ /*Directional gain (panning)*/
+ Word16 temp_q = sub( add( h_dirac_output_synthesis_state->direct_power_factor_q, h_dirac_output_synthesis_state->direct_responses_q ), 31 );
+ Word16 temp_exp = sub( 31, temp_q );
+
+ IF( LT_16( temp, temp_exp ) )
+ {
+ FOR( Word16 kk = 0; kk < ( num_freq_bands * num_channels_dir ); kk++ )
+ {
+ h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[kk] = L_shl( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[kk], sub( exp_temp_cy_cross_dir_smooth_fx[kk], temp_exp ) ); /*h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ->temp_q*/
+ move32();
+ }
+ h_dirac_output_synthesis_state->q_cy_cross_dir_smooth = temp_q;
+ move16();
+ }
+ ELSE
+ {
+ FOR( Word16 kk = 0; kk < ( num_freq_bands * num_channels_dir ); kk++ )
+ {
+ h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[kk] = L_shl( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[kk], sub( exp_temp_cy_cross_dir_smooth_fx[kk], temp ) ); /*exp_temp_cy_cross_dir_smooth_fx[kk]->temp*/
+ move32();
+ }
+ h_dirac_output_synthesis_state->q_cy_cross_dir_smooth = sub( 31, temp );
+ move16();
+ }
+ free( exp_temp_cy_cross_dir_smooth_fx );
+#else /* OPT_SBA_DEC_PATH */
/*Direct gain*/
Word16 *Q_temp_cy_cross_dir_smooth_fx = (Word16 *) malloc( num_freq_bands * num_channels_dir * sizeof( Word16 ) );
- tmp16 = imult1616( num_freq_bands, num_channels_dir );
+ Word16 tmp16 = imult1616( num_freq_bands, num_channels_dir );
FOR( Word16 kk = 0; kk < tmp16; kk++ )
{
- Q_temp_cy_cross_dir_smooth_fx[kk] = h_dirac_output_synthesis_state->q_cy_cross_dir_smooth;
+ h_dirac_output_synthesis_state->Q_temp_cy_cross_dir_smooth_fx[kk] = h_dirac_output_synthesis_state->q_cy_cross_dir_smooth;
move16();
}
@@ -901,13 +1241,13 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx(
{
h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_shr( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sub( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, sub( 31, sqr_exp ) ) ); /*h_dirac_output_synthesis_state->q_cy_cross_dir_smooth-> (31-sqr_exp) */
move32();
- Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp );
+ h_dirac_output_synthesis_state->Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp );
move16();
}
ELSE
{
sqr = L_shr( sqr, sub( sub( 31, sqr_exp ), h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ) ); /*( 31- sqr_exp )-> h_dirac_output_synthesis_state->q_cy_cross_dir_smooth*/
- Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = h_dirac_output_synthesis_state->q_cy_cross_dir_smooth;
+ h_dirac_output_synthesis_state->Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = h_dirac_output_synthesis_state->q_cy_cross_dir_smooth;
move16();
}
h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q_temp_cy_cross_dir_smooth_fx*/
@@ -917,7 +1257,7 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx(
{
h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*31-sqr_exp*/
move32();
- Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp );
+ h_dirac_output_synthesis_state->Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp );
move16();
}
}
@@ -969,13 +1309,13 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx(
{
h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_shr( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sub( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, sub( 31, sqr_exp ) ) ); /*h_dirac_output_synthesis_state->q_cy_cross_dir_smooth->Q( 31- sqr_exp )*/
move32();
- Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp );
+ h_dirac_output_synthesis_state->Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp );
move16();
}
ELSE
{
sqr = L_shr( sqr, sub( sub( 31, sqr_exp ), h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ) ); /*Q(31- sqr_exp)->h_dirac_output_synthesis_state->q_cy_cross_dir_smooth*/
- Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = h_dirac_output_synthesis_state->q_cy_cross_dir_smooth;
+ h_dirac_output_synthesis_state->Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = h_dirac_output_synthesis_state->q_cy_cross_dir_smooth;
move16();
}
h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k]*/
@@ -985,7 +1325,7 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx(
{
h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q(31- sqr_exp)*/
move32();
- Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp );
+ h_dirac_output_synthesis_state->Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp );
move16();
}
}
@@ -1051,13 +1391,13 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx(
{
h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_shr( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sub( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, sub( 31, sqr_exp ) ) ); /*h_dirac_output_synthesis_state->q_cy_cross_dir_smooth->Q( 31- sqr_exp )*/
move32();
- Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp );
+ h_dirac_output_synthesis_state->Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp );
move16();
}
ELSE
{
sqr = L_shr( sqr, sub( sub( 31, sqr_exp ), h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ) ); /*Q(31- sqr_exp)->h_dirac_output_synthesis_state->q_cy_cross_dir_smooth*/
- Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = h_dirac_output_synthesis_state->q_cy_cross_dir_smooth;
+ h_dirac_output_synthesis_state->Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = h_dirac_output_synthesis_state->q_cy_cross_dir_smooth;
move16();
}
h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k]*/
@@ -1067,7 +1407,7 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx(
{
h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q(31- sqr_exp)*/
move32();
- Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp );
+ h_dirac_output_synthesis_state->Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp );
move16();
}
}
@@ -1092,13 +1432,13 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx(
{
h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_shr( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sub( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, sub( 31, sqr_exp ) ) ); /*h_dirac_output_synthesis_state->q_cy_cross_dir_smooth->Q(31- sqr_exp)*/
move32();
- Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp );
+ h_dirac_output_synthesis_state->Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp );
move16();
}
ELSE
{
sqr = L_shr( sqr, sub( sub( 31, sqr_exp ), h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ) ); /*Q(31-sqr_exp)->h_dirac_output_synthesis_state->q_cy_cross_dir_smooth*/
- Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = h_dirac_output_synthesis_state->q_cy_cross_dir_smooth;
+ h_dirac_output_synthesis_state->Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = h_dirac_output_synthesis_state->q_cy_cross_dir_smooth;
move16();
}
h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k]*/
@@ -1108,7 +1448,7 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx(
{
h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q(31-sqr_exp)*/
move32();
- Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp );
+ h_dirac_output_synthesis_state->Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp );
move16();
}
}
@@ -1125,13 +1465,13 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx(
{
h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_shr( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sub( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, sub( 31, sqr_exp ) ) ); /*h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, Q( 31- sqr_exp )*/
move32();
- Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp );
+ h_dirac_output_synthesis_state->Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp );
move16();
}
ELSE
{
sqr = L_shr( sqr, sub( sub( 31, sqr_exp ), h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ) ); /*Q( 31- sqr_exp ), h_dirac_output_synthesis_state->q_cy_cross_dir_smooth*/
- Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = h_dirac_output_synthesis_state->q_cy_cross_dir_smooth;
+ h_dirac_output_synthesis_state->Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = h_dirac_output_synthesis_state->q_cy_cross_dir_smooth;
move16();
}
h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k]*/
@@ -1141,7 +1481,7 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx(
{
h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q(31-sqr_exp)*/
move32();
- Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp );
+ h_dirac_output_synthesis_state->Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp );
move16();
}
}
@@ -1152,16 +1492,15 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx(
tmp16 = imult1616( num_freq_bands, num_channels_dir );
FOR( Word16 kk = 0; kk < tmp16; kk++ )
{
- temp = s_min( Q_temp_cy_cross_dir_smooth_fx[kk], temp );
+ temp = s_min( h_dirac_output_synthesis_state->Q_temp_cy_cross_dir_smooth_fx[kk], temp );
}
h_dirac_output_synthesis_state->q_cy_cross_dir_smooth = temp;
move16();
FOR( Word16 kk = 0; kk < tmp16; kk++ )
{
- h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[kk] = L_shl( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[kk], sub( temp, Q_temp_cy_cross_dir_smooth_fx[kk] ) ); /*Q_temp_cy_cross_dir_smooth_fx[kk]->temp*/
+ h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[kk] = L_shl( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[kk], sub( temp, h_dirac_output_synthesis_state->Q_temp_cy_cross_dir_smooth_fx[kk] ) ); /*Q_temp_cy_cross_dir_smooth_fx[kk]->temp*/
move32();
}
- free( Q_temp_cy_cross_dir_smooth_fx );
/*Directional gain (panning)*/
Word16 temp_q = sub( add( h_dirac_output_synthesis_state->direct_power_factor_q, h_dirac_output_synthesis_state->direct_responses_q ), 31 );
IF( LT_16( temp_q, h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ) )
@@ -1175,6 +1514,8 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx(
h_dirac_output_synthesis_state->q_cy_cross_dir_smooth = temp_q;
move16();
}
+#endif /* OPT_SBA_DEC_PATH */
+
Word16 temp_q1 = sub( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, temp_q );
FOR( ch_idx = s_min( 4, nchan_transport ); ch_idx < num_channels_dir; ch_idx++ )
{
@@ -1570,7 +1911,6 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx(
}
q_shift = sub( 26, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev );
- move16();
/* Direct gains */
IF( hodirac_flag )
@@ -1686,11 +2026,20 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx(
/*Direct input->output*/
p_gains_dir = h_dirac_output_synthesis_state.cy_cross_dir_smooth_prev_fx; // (p_gains_dir_q)
p_gains_dir_prev = h_dirac_output_synthesis_state.gains_dir_prev_fx;
+#ifdef OPT_SBA_DEC_PATH
+ q_shift = sub( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, h_dirac_output_synthesis_state.gains_dir_prev_q );
+#endif /* OPT_SBA_DEC_PATH */
FOR( ch_idx = 0; ch_idx < num_channels_dir; ch_idx++ )
{
+#ifdef OPT_SBA_DEC_PATH
+ Scale_sig32( &h_dirac_output_synthesis_state.gains_dir_prev_fx[ch_idx * num_freq_bands],
+ num_freq_bands,
+ q_shift ); /*h_dirac_output_synthesis_state.gains_dir_prev_q->h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev*/
+#else /* OPT_SBA_DEC_PATH */
Scale_sig32( &h_dirac_output_synthesis_state.gains_dir_prev_fx[ch_idx * num_freq_bands],
num_freq_bands,
sub( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, h_dirac_output_synthesis_state.gains_dir_prev_q ) ); /*h_dirac_output_synthesis_state.gains_dir_prev_q->h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev*/
+#endif /* OPT_SBA_DEC_PATH */
}
h_dirac_output_synthesis_state.gains_dir_prev_q = h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev;
move16();
@@ -2134,9 +2483,6 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx(
move16();
}
- subtract_power_y = masa_stereo_type_detect->subtract_power_y_fx; // q_subtract_power_y
- move32();
-
a = 858993; /* ( 0.0004f in Q31 ); Temporal smoothing coefficient */
move32();
b = L_sub( ONE_IN_Q31, a ); /* Temporal smoothing coefficient */
@@ -2152,24 +2498,52 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx(
move32();
masa_stereo_type_detect->q_target_power_y_smooth = q_com;
move16();
- masa_stereo_type_detect->subtract_power_y_smooth_fx =
- L_add( Mpy_32_32( a, subtract_power_y ),
- Mpy_32_32( b, masa_stereo_type_detect->subtract_power_y_smooth_fx ) ); //(Q31, q_subtract_power_y) -> q_subtract_power_y
+
+ IF( NE_16( masa_stereo_type_detect->q_subtract_power_y, masa_stereo_type_detect->q_subtract_power_y_smooth ) )
+ {
+ exp = s_min( add( masa_stereo_type_detect->q_subtract_power_y, norm_l( masa_stereo_type_detect->subtract_power_y_fx ) ), add( masa_stereo_type_detect->q_subtract_power_y_smooth, norm_l( masa_stereo_type_detect->subtract_power_y_smooth_fx ) ) );
+ masa_stereo_type_detect->subtract_power_y_fx = L_shl( masa_stereo_type_detect->subtract_power_y_fx, sub( exp, masa_stereo_type_detect->q_subtract_power_y ) );
+ move32();
+ masa_stereo_type_detect->subtract_power_y_smooth_fx = L_shl( masa_stereo_type_detect->subtract_power_y_smooth_fx, sub( exp, masa_stereo_type_detect->q_subtract_power_y_smooth ) );
+ move32();
+ masa_stereo_type_detect->q_subtract_power_y = exp;
+ move16();
+ masa_stereo_type_detect->q_subtract_power_y_smooth = exp;
+ move16();
+ }
+ subtract_power_y = masa_stereo_type_detect->subtract_power_y_fx; // q_subtract_power_y
move32();
+ W_temp = W_add( W_mult0_32_32( a, subtract_power_y ), W_mult0_32_32( b, masa_stereo_type_detect->subtract_power_y_smooth_fx ) ); // Q31 + masa_stereo_type_detect->q_subtract_power_y_smooth
+ IF( W_temp )
+ {
+ exp = W_norm( W_temp );
+ masa_stereo_type_detect->subtract_power_y_smooth_fx = W_extract_h( W_shl( W_temp, exp ) ); // Q31 + masa_stereo_type_detect->q_subtract_power_y_smooth + exp - 32
+ move32();
+ masa_stereo_type_detect->q_subtract_power_y_smooth = sub( add( masa_stereo_type_detect->q_subtract_power_y_smooth, exp ), 1 );
+ move16();
+ }
+ ELSE
+ {
+ masa_stereo_type_detect->subtract_power_y_smooth_fx = 0; // Q31
+ move32();
+ masa_stereo_type_detect->q_subtract_power_y_smooth = Q31;
+ move16();
+ }
exp = 0;
move16();
- IF( masa_stereo_type_detect->target_power_y_smooth_fx != 0 )
+ test();
+ IF( masa_stereo_type_detect->target_power_y_smooth_fx && masa_stereo_type_detect->subtract_power_y_smooth_fx )
{
subtract_target_ratio = L_sub( BASOP_Util_Log2( masa_stereo_type_detect->subtract_power_y_smooth_fx ),
BASOP_Util_Log2( masa_stereo_type_detect->target_power_y_smooth_fx ) ); // Q25
- exp = sub( masa_stereo_type_detect->q_subtract_power_y, q_com );
+ exp = sub( masa_stereo_type_detect->q_subtract_power_y_smooth, q_com );
L_tmp = Mpy_32_32( L_sub( subtract_target_ratio, L_shl( exp, 25 ) ), LOG10_2_Q31 ); // Q25
}
ELSE
{
subtract_target_ratio = BASOP_Util_Log2( masa_stereo_type_detect->subtract_power_y_smooth_fx ); // Q25
- exp = sub( 31, masa_stereo_type_detect->q_subtract_power_y );
+ exp = sub( 31, masa_stereo_type_detect->q_subtract_power_y_smooth );
L_tmp = L_sub( Mpy_32_32( L_add( subtract_target_ratio, L_shl( exp, 25 ) ), LOG10_2_Q31 ), -503316480 /* L_shl( -15, 25 ) */ /*log(EPSILON)*/ ); // Q25
}
subtract_target_ratio_db = Mpy_32_32( 1342177280 /* 10.0f * in Q27*/, L_tmp ); // (Q27, (Q25, Q31)) -> (Q27, Q25) -> Q21
@@ -2178,6 +2552,8 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx(
move32();
masa_stereo_type_detect->subtract_power_y_fx = 0;
move32();
+ masa_stereo_type_detect->q_subtract_power_y = Q31;
+ move16();
}
/*-----------------------------------------------------------------*
@@ -2431,6 +2807,11 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx(
move16();
move16();
+#ifdef OPT_SBA_REND_V1_BE
+ Word32 cmp = W_shl_sat_l( DIRAC_GAIN_LIMIT_Q26, sub( h_dirac_output_synthesis_state->gains_dir_prev_q, 26 ) );
+ Word32 cmp2 = W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state->gains_diff_prev_q ) ), Q5 ) );
+#endif /* OPT_SBA_REND_V1_BE */
+
FOR( k = 0; k < nchan_out_woLFE; k++ )
{
Word32 power_smooth_temp;
@@ -2478,11 +2859,19 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx(
*( p_gains_dir ) = 0;
move32();
}
+#ifdef OPT_SBA_REND_V1_BE
+ ELSE IF( GT_32( *( p_gains_dir ), cmp ) )
+ {
+ *( p_gains_dir ) = cmp; /*26 + h_dirac_output_synthesis_state->gains_dir_prev_q + 1 + 5 - 32 -> h_dirac_output_synthesis_state->gains_dir_prev_q*/
+ move32();
+ }
+#else /* OPT_SBA_REND_V1_BE */
ELSE IF( GT_32( *( p_gains_dir ), W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state->gains_dir_prev_q ) ), Q5 ) ) ) )
{
*( p_gains_dir ) = W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state->gains_dir_prev_q ) ), Q5 ) ); /*26 + h_dirac_output_synthesis_state->gains_dir_prev_q + 1 + 5 - 32 -> h_dirac_output_synthesis_state->gains_dir_prev_q*/
move32();
}
+#endif /* OPT_SBA_REND_V1_BE */
IF( *( p_cy_cross_dir_smooth_prev++ ) < 0 )
{
@@ -2515,11 +2904,19 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx(
*( p_gains_diff ) = 0;
move32();
}
+#ifdef OPT_SBA_REND_V1_BE
+ ELSE IF( GT_32( *( p_gains_diff ), cmp2 ) ) /*h_dirac_output_synthesis_state->gains_diff_prev_q*/
+ {
+ *( p_gains_diff ) = cmp2; /*h_dirac_output_synthesis_state->gains_diff_prev_q*/
+ move32();
+ }
+#else /* OPT_SBA_REND_V1_BE */
ELSE IF( GT_32( *( p_gains_diff ), W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state->gains_diff_prev_q ) ), Q5 ) ) ) ) /*h_dirac_output_synthesis_state->gains_diff_prev_q*/
{
*( p_gains_diff ) = W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state->gains_diff_prev_q ) ), Q5 ) ); /*h_dirac_output_synthesis_state->gains_diff_prev_q*/
move32();
}
+#endif /* OPT_SBA_REND_V1_BE */
p_gains_diff++;
}
@@ -2530,15 +2927,25 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx(
g1 = alpha[l]; // Q31
move32();
g2 = L_sub( ONE_IN_Q31, g1 ); // Q31
+#ifdef OPT_SBA_REND_V1_BE
+ W_temp = W_mac_32_32( W_mult_32_32( g1, ( *( p_cy_auto_dir_smooth++ ) ) ),
+ g2, ( *( p_cy_auto_dir_smooth_prev ) ) ); /*32+q_cy_auto_dir_smooth_prev_local*/
+#else /* OPT_SBA_REND_V1_BE */
W_temp = W_add( W_mult_32_32( g1, ( *( p_cy_auto_dir_smooth++ ) ) ),
W_mult_32_32( g2, ( *( p_cy_auto_dir_smooth_prev ) ) ) ); /*32+q_cy_auto_dir_smooth_prev_local*/
+#endif /* OPT_SBA_REND_V1_BE */
q_tmp = W_norm( W_temp );
L_tmp = W_extract_h( W_shl( W_temp, q_tmp ) ); // q_cy_auto_dir_smooth_prev_local + q_tmp
*( p_cy_auto_dir_smooth_prev++ ) = L_shr_r( L_tmp, q_tmp ); // q_cy_auto_dir_smooth_prev_local
move32();
+#ifdef OPT_SBA_REND_V1_BE
+ *( p_cy_cross_dir_smooth_prev ) = Madd_32_32( Mpy_32_32( g1, ( *( p_cy_cross_dir_smooth ) ) ),
+ g2, ( *( p_cy_cross_dir_smooth_prev ) ) ); // (Q31, q_cy_cross_dir_smooth_prev) -> q_cy_cross_dir_smooth_prev
+#else /* OPT_SBA_REND_V1_BE */
*( p_cy_cross_dir_smooth_prev ) = L_add( Mpy_32_32( g1, ( *( p_cy_cross_dir_smooth ) ) ),
Mpy_32_32( g2, ( *( p_cy_cross_dir_smooth_prev ) ) ) ); // (Q31, q_cy_cross_dir_smooth_prev) -> q_cy_cross_dir_smooth_prev
+#endif /* OPT_SBA_REND_V1_BE */
move32();
test();
if ( *( p_cy_cross_dir_smooth_prev ) == 0 && ( *( p_cy_cross_dir_smooth ) != 0 ) )
@@ -2570,11 +2977,19 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx(
*( p_gains_dir ) = 0;
move32();
}
+#ifdef OPT_SBA_REND_V1_BE
+ ELSE IF( GT_32( *( p_gains_dir ), cmp ) ) /*gains_dir_prev_q*/
+ {
+ *( p_gains_dir ) = cmp; /*gains_dir_prev_q*/
+ move32();
+ }
+#else /* OPT_SBA_REND_V1_BE */
ELSE IF( GT_32( *( p_gains_dir ), W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state->gains_dir_prev_q ) ), Q5 ) ) ) ) /*gains_dir_prev_q*/
{
*( p_gains_dir ) = W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state->gains_dir_prev_q ) ), Q5 ) ); /*gains_dir_prev_q*/
move32();
}
+#endif /* OPT_SBA_REND_V1_BE */
IF( *( p_cy_cross_dir_smooth_prev++ ) < 0 )
{
@@ -2661,7 +3076,11 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx(
shl( i_mult( proto_direct_index[k], num_freq_bands ), Q1 );
FOR( l = 0; l < num_freq_bands; l++ )
{
- g = L_add( Mpy_32_32( g1, *( p_gain_1++ ) ), Mpy_32_32( g2, *( p_gain_2++ ) ) ); // (Q31, gains_dir_prev_q) -> gains_dir_prev_q
+#ifdef OPT_SBA_REND_V1_BE
+ g = Madd_32_32( Mpy_32_32( g1, *( p_gain_1++ ) ), g2, *( p_gain_2++ ) ); // (Q31, gains_dir_prev_q) -> gains_dir_prev_q
+#else /* OPT_SBA_REND_V1_BE */
+ g = L_add( Mpy_32_32( g1, *( p_gain_1++ ) ), Mpy_32_32( g2, *( p_gain_2++ ) ) ); // (Q31, gains_dir_prev_q) -> gains_dir_prev_q
+#endif /* OPT_SBA_REND_V1_BE */
Cldfb_RealBuffer64_fx[k][buf_idx][l] = W_mult0_32_32( g, ( *( p_power_smooth++ ) ) ); // (gains_dir_prev_q, q_proto_direct_buffer) -> gains_dir_prev_q + q_proto_direct_buffer
move64();
@@ -2683,7 +3102,12 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx(
{
FOR( l = 0; l < h_dirac_output_synthesis_params->max_band_decorr; l++ )
{
- g = L_add( Mpy_32_32( g1, *( p_gain_1++ ) ), Mpy_32_32( g2, *( p_gain_2++ ) ) ); // (Q31, gains_diff_prev_q) -> gains_diff_prev_q
+#ifdef OPT_SBA_REND_V1_BE
+ g = Madd_32_32( Mpy_32_32( g1, *( p_gain_1++ ) ), g2, *( p_gain_2++ ) ); // (Q31, gains_diff_prev_q) -> gains_diff_prev_q
+#else /* OPT_SBA_REND_V1_BE */
+ g = L_add( Mpy_32_32( g1, *( p_gain_1++ ) ), Mpy_32_32( g2, *( p_gain_2++ ) ) ); // (Q31, gains_diff_prev_q) -> gains_diff_prev_q
+
+#endif /* OPT_SBA_REND_V1_BE */
Cldfb_RealBuffer64_fx[k][buf_idx][l] = W_add( Cldfb_RealBuffer64_fx[k][buf_idx][l],
W_shr( W_mult0_32_32( g, ( *( p_power_smooth_diff++ ) ) ), negate( q_align ) ) ); // (gains_diff_prev_q, q_proto_direct_buffer) -> gains_diff_prev_q + q_proto_direct_buffer
move64();
@@ -2732,16 +3156,27 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx(
}
}
q_align = W_norm( W_temp );
+#ifdef OPT_SBA_REND_V1_BE
+ Word16 shift = sub( q_align, 32 );
+#endif /* OPT_SBA_REND_V1_BE */
+
FOR( buf_idx = 0; buf_idx < nbslots; ++buf_idx )
{
FOR( k = 0; k < nchan_out_woLFE; k++ )
{
FOR( l = 0; l < num_freq_bands; l++ )
{
+#ifdef OPT_SBA_REND_V1_BE
+ RealBuffer[k][buf_idx][l] = W_shl_sat_l( Cldfb_RealBuffer64_fx[k][buf_idx][l], shift ); /*( ( ( h_dirac_output_synthesis_state->proto_direct_buffer_f_q+h_dirac_output_synthesis_state->gains_dir_prev_q )+ q_align )- 32 )*/
+ move32();
+ ImagBuffer[k][buf_idx][l] = W_shl_sat_l( Cldfb_ImagBuffer64_fx[k][buf_idx][l], shift ); /*( ( ( h_dirac_output_synthesis_state->proto_direct_buffer_f_q+h_dirac_output_synthesis_state->gains_dir_prev_q )+ q_align )- 32 )*/
+ move32();
+#else /* OPT_SBA_REND_V1_BE */
RealBuffer[k][buf_idx][l] = W_extract_h( W_shl( Cldfb_RealBuffer64_fx[k][buf_idx][l], q_align ) ); /*( ( ( h_dirac_output_synthesis_state->proto_direct_buffer_f_q+h_dirac_output_synthesis_state->gains_dir_prev_q )+ q_align )- 32 )*/
move32();
ImagBuffer[k][buf_idx][l] = W_extract_h( W_shl( Cldfb_ImagBuffer64_fx[k][buf_idx][l], q_align ) ); /*( ( ( h_dirac_output_synthesis_state->proto_direct_buffer_f_q+h_dirac_output_synthesis_state->gains_dir_prev_q )+ q_align )- 32 )*/
move32();
+#endif /* OPT_SBA_REND_V1_BE */
}
}
}
@@ -3989,10 +4424,11 @@ void ivas_lfe_synth_with_filters_fx(
}
ELSE
{
+ Flag overFlow;
lfeGain_fx = extract_h( BASOP_Util_Divide3232_Scale_newton( hMasaLfeSynth->targetEneLfeSmooth_fx, L_add( EPSILON_FX, hMasaLfeSynth->transportEneSmooth_fx ), &lfeGain_fx_exp ) ); /*Q(31-(lfeGain_fx_exp+hMasaLfeSynth->transportEneSmooth_q-hMasaLfeSynth->targetEneLfeSmooth_q))-16*/
lfeGain_fx_exp = add( sub( hMasaLfeSynth->transportEneSmooth_q, hMasaLfeSynth->targetEneLfeSmooth_q ), lfeGain_fx_exp );
- lfeGain_fx = Sqrt16( lfeGain_fx, &lfeGain_fx_exp ); // Q15-lfeGain_fx_exp
- lfeGain_fx = shl_r( lfeGain_fx, lfeGain_fx_exp ); // Q15
+ lfeGain_fx = Sqrt16( lfeGain_fx, &lfeGain_fx_exp ); // Q15-lfeGain_fx_exp
+ lfeGain_fx = shl_ro( lfeGain_fx, lfeGain_fx_exp, &overFlow ); // Q15
}
IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( hMasaLfeSynth->targetEneTransSmooth_fx, sub( Q31, hMasaLfeSynth->targetEneTransSmooth_q ), /*EPSILON + */ hMasaLfeSynth->transportEneSmooth_fx, sub( Q31, hMasaLfeSynth->transportEneSmooth_q ) ), 1 ) )
{
diff --git a/lib_rend/ivas_dirac_rend_fx.c b/lib_rend/ivas_dirac_rend_fx.c
index 06b37ff5ae13f563e1aeabb6c5f161d0b73263a5..81db5703e33af5027bfc465088803b792da4786d 100644
--- a/lib_rend/ivas_dirac_rend_fx.c
+++ b/lib_rend/ivas_dirac_rend_fx.c
@@ -1754,22 +1754,24 @@ void protoSignalComputation2_fx(
Word32 RealSubtract_fx, ImagSubtract_fx;
Word32 left_bb_power_fx, right_bb_power_fx, total_bb_power_fx, lr_bb_power_fx;
Word32 left_hi_power_fx, right_hi_power_fx, total_hi_power_fx, lr_hi_power_fx;
- Word32 sum_power_fx, Left_power_fx, Right_power_fx;
+ Word32 sum_power_fx, Left_power_fx, Right_power_fx, Total_power_fx;
Word16 q_lr_bb_power, q_lr_hi_power;
Word32 lr_total_bb_ratio_fx, lr_total_hi_ratio_fx;
Word32 min_sum_total_ratio_fx, min_sum_total_ratio_db_fx;
Word32 sum_total_ratio_fx[MASA_SUM_FREQ_RANGE_BINS];
- Word16 q_sum_total_ratio;
+ Word16 exp_sum_total_ratio_fx[MASA_SUM_FREQ_RANGE_BINS];
+ Word16 q_sum_total_ratio = 0;
+ move16();
Word32 a_fx, b_fx, a2_fx, b2_fx;
Word16 interpolatorSpaced_fx, interpolatorDmx_fx;
Word32 tempSpaced_fx, tempDmx_fx;
#ifdef FIX_867_CLDFB_NRG_SCALE
- Word16 q_shift, min_q_shift[2], exp, q_temp[2], temp_q_shift, q_temp2;
+ Word16 q_shift, min_q_shift[2], exp, q_temp[2];
#else
Word16 q_shift, min_q_shift, exp, q_temp, temp_q_shift, q_temp2;
#endif
Word32 temp;
- Word64 W_tmp1, W_tmp2;
+ Word64 W_tmp1, W_tmp2, W_tmp3;
Word64 reference_power_64fx[CLDFB_NO_CHANNELS_MAX];
Word16 q_reference_power_64fx;
Word16 head_room, q_Left_Right_power;
@@ -1786,9 +1788,7 @@ void protoSignalComputation2_fx(
min_q_shift = Q31;
move16();
#endif
- temp_q_shift = Q31;
- move16();
- q_sum_total_ratio = Q31;
+ q_sum_total_ratio = 0;
move16();
exp = 0;
move16();
@@ -1813,7 +1813,6 @@ void protoSignalComputation2_fx(
min_q_shift = s_min( min_q_shift, q_shift );
#endif
q_shift = s_min( L_norm_arr( RealBuffer_fx[l][0], s_min( num_freq_bands, MASA_SUM_FREQ_RANGE_BINS ) ), L_norm_arr( ImagBuffer_fx[l][0], s_min( num_freq_bands, MASA_SUM_FREQ_RANGE_BINS ) ) );
- temp_q_shift = s_min( temp_q_shift, q_shift );
}
#ifdef FIX_867_CLDFB_NRG_SCALE
@@ -1822,7 +1821,6 @@ void protoSignalComputation2_fx(
#else
min_q_shift = sub( min_q_shift, 2 ); // guard bits
#endif
- temp_q_shift = sub( temp_q_shift, 2 ); // guard bits
/* Upscaling of the buffer proto_power_smooth_fx */
#ifdef FIX_867_CLDFB_NRG_SCALE
@@ -2072,7 +2070,7 @@ void protoSignalComputation2_fx(
}
#ifdef FIX_867_CLDFB_NRG_SCALE
- Word16 total_shift[2], q_temp_total;
+ Word16 total_shift[2];
/* total_shift shift required to get common Q of sum power values */
total_shift[0] = shl( s_max( 0, sub( min_q_shift[0], min_q_shift[1] ) ), 1 );
total_shift[1] = shl( s_max( 0, sub( min_q_shift[1], min_q_shift[0] ) ), 1 );
@@ -2080,13 +2078,11 @@ void protoSignalComputation2_fx(
min_q_shift[1] = sub( min_q_shift[1], idiv1616( find_guarded_bits_fx( num_freq_bands ), 2 ) );
q_temp[0] = sub( add( add( q_cldfb, min_q_shift[0] ), add( q_cldfb, min_q_shift[0] ) ), 31 );
q_temp[1] = sub( add( add( q_cldfb, min_q_shift[1] ), add( q_cldfb, min_q_shift[1] ) ), 31 );
- q_temp_total = s_min( q_temp[0], q_temp[1] );
#else
min_q_shift = sub( min_q_shift, idiv1616( find_guarded_bits_fx( num_freq_bands ), 2 ) );
q_temp = sub( add( add( q_cldfb, min_q_shift ), add( q_cldfb, min_q_shift ) ), 31 );
#endif
- q_temp2 = sub( add( add( q_cldfb, temp_q_shift ), add( q_cldfb, temp_q_shift ) ), 31 );
head_room = 63;
move16();
@@ -2120,7 +2116,10 @@ void protoSignalComputation2_fx(
#else
q_Left_Right_power = add( shl( add( q_cldfb, min_q_shift ), 1 ), sub( head_room, 32 ) );
#endif
-
+ Word16 exp_left_hi_power = 0, exp_right_hi_power = 0, exp_total_hi_power = 0, exp_temppp;
+ move16();
+ move16();
+ move16();
FOR( l = 0; l < num_freq_bands; l++ )
{
#ifdef FIX_867_CLDFB_NRG_SCALE
@@ -2164,94 +2163,78 @@ void protoSignalComputation2_fx(
left_bb_power_fx = L_add( left_bb_power_fx, Left_power_fx ); // q_Left_Right_power
right_bb_power_fx = L_add( right_bb_power_fx, Right_power_fx ); // q_Left_Right_power
// total_bb_power_fx = L_add( total_bb_power_fx, reference_power_fx[l] );
- total_bb_power_fx = L_add( total_bb_power_fx, W_extract_h( W_shl( reference_power_64fx[l], head_room ) ) ); // q_Left_Right_power
+ total_bb_power_fx = L_add( total_bb_power_fx, W_extract_h( W_shl( reference_power_64fx[l], head_room ) ) ); // q_Left_Right_power
#endif
-
IF( GT_16( l, MASA_HI_FREQ_START_BIN ) )
{
- left_hi_power_fx = L_add( left_hi_power_fx, Left_power_fx ); // q_Left_Right_power
- right_hi_power_fx = L_add( right_hi_power_fx, Right_power_fx ); // q_Left_Right_power
- // total_hi_power_fx = L_add( total_hi_power_fx, reference_power_fx[l] );
-#ifdef FIX_867_CLDFB_NRG_SCALE
- total_hi_power_fx = L_add( total_hi_power_fx, W_extract_h( W_shl( reference_power_64fx[l], sub( head_room, total_shift[qidx] ) ) ) ); // q_Left_Right_power
-#else
- total_hi_power_fx = L_add( total_hi_power_fx, W_extract_h( W_shl( reference_power_64fx[l], head_room ) ) ); // q_Left_Right_power
-#endif
+ W_tmp1 = W_add( W_mult0_32_32( RealBuffer_fx[0][0][l], RealBuffer_fx[0][0][l] ), W_mult0_32_32( ImagBuffer_fx[0][0][l], ImagBuffer_fx[0][0][l] ) );
+ q_shift = W_norm( W_tmp1 );
+ Left_power_fx = W_extract_h( W_shl( W_tmp1, q_shift ) );
+ exp_temppp = sub( 31, sub( add( shl( q_cldfb, 1 ), q_shift ), 32 ) );
+
+ left_hi_power_fx = BASOP_Util_Add_Mant32Exp( left_hi_power_fx, exp_left_hi_power, Left_power_fx, exp_temppp, &exp_left_hi_power ); // exp:exp_left_hi_power
+
+ W_tmp2 = W_add( W_mult0_32_32( RealBuffer_fx[1][0][l], RealBuffer_fx[1][0][l] ), W_mult0_32_32( ImagBuffer_fx[1][0][l], ImagBuffer_fx[1][0][l] ) );
+ q_shift = W_norm( W_tmp2 );
+ Right_power_fx = W_extract_h( W_shl( W_tmp2, q_shift ) );
+ exp_temppp = sub( 31, sub( add( shl( q_cldfb, 1 ), q_shift ), 32 ) );
+
+ right_hi_power_fx = BASOP_Util_Add_Mant32Exp( right_hi_power_fx, exp_right_hi_power, Right_power_fx, exp_temppp, &exp_right_hi_power ); // exp:exp_right_hi_power
+
+ W_tmp2 = W_add( W_tmp1, W_tmp2 );
+ q_shift = W_norm( W_tmp2 );
+ Total_power_fx = W_extract_h( W_shl( W_tmp2, q_shift ) );
+ exp_temppp = sub( 31, sub( add( shl( q_cldfb, 1 ), q_shift ), 32 ) );
+
+ total_hi_power_fx = BASOP_Util_Add_Mant32Exp( total_hi_power_fx, exp_total_hi_power, Total_power_fx, exp_temppp, &exp_total_hi_power ); // exp:exp_total_hi_power
}
IF( LT_16( l, s_min( num_freq_bands, MASA_SUM_FREQ_RANGE_BINS ) ) )
{
-#ifdef FIX_867_CLDFB_NRG_SCALE
- re_aux = L_shl( Real_aux_fx, sub( temp_q_shift, min_q_shift[0] ) ); // q_cldfb+temp_q_shift
- im_aux = L_shl( Imag_aux_fx, sub( temp_q_shift, min_q_shift[0] ) ); // q_cldfb+temp_q_shift
-#else
- re_aux = L_shl( Real_aux_fx, sub( temp_q_shift, min_q_shift ) ); // q_cldfb+temp_q_shift
- im_aux = L_shl( Imag_aux_fx, sub( temp_q_shift, min_q_shift ) ); // q_cldfb+temp_q_shift
-#endif
+ re_aux = L_add( L_shr( RealBuffer_fx[0][0][l], 1 ), L_shr( RealBuffer_fx[1][0][l], 1 ) );
+ im_aux = L_add( L_shr( ImagBuffer_fx[0][0][l], 1 ), L_shr( ImagBuffer_fx[1][0][l], 1 ) );
- sum_power_fx = Madd_32_32( Mpy_32_32( re_aux, re_aux ), im_aux, im_aux ); // 2*(q_cldfb+temp_q_shift)-31
- temp = Mpy_32_32( a_fx, sum_power_fx ); // 2*(q_cldfb+temp_q_shift)-31
+ W_tmp3 = W_add( W_mult0_32_32( re_aux, re_aux ), W_mult0_32_32( im_aux, im_aux ) );
+ q_shift = W_norm( W_tmp3 );
+ sum_power_fx = W_extract_h( W_shl( W_tmp3, q_shift ) );
+ exp_temppp = sub( 31, sub( add( shl( sub( q_cldfb, 1 ), 1 ), q_shift ), 32 ) );
- IF( LT_16( q_temp2, stereo_type_detect->q_sum_power ) )
- {
- stereo_type_detect->sum_power_fx[l] = L_add( temp, L_shr( Mpy_32_32( b_fx, stereo_type_detect->sum_power_fx[l] ), sub( stereo_type_detect->q_sum_power, q_temp2 ) ) ); // q_temp2
- move32();
- }
- ELSE
- {
- stereo_type_detect->sum_power_fx[l] = L_add( L_shr( temp, sub( q_temp2, stereo_type_detect->q_sum_power ) ), Mpy_32_32( b_fx, stereo_type_detect->sum_power_fx[l] ) ); // stereo_type_detect->q_sum_power
- move32();
- }
+ stereo_type_detect->sum_power_fx[l] = BASOP_Util_Add_Mant32Exp( Mpy_32_32( a_fx, sum_power_fx ), exp_temppp, Mpy_32_32( b_fx, stereo_type_detect->sum_power_fx[l] ), stereo_type_detect->exp_sum_power[l], &stereo_type_detect->exp_sum_power[l] );
+ move32();
+ W_tmp1 = W_add( W_mult0_32_32( RealBuffer_fx[0][0][l], RealBuffer_fx[0][0][l] ), W_mult0_32_32( ImagBuffer_fx[0][0][l], ImagBuffer_fx[0][0][l] ) );
+ W_tmp2 = W_add( W_mult0_32_32( RealBuffer_fx[1][0][l], RealBuffer_fx[1][0][l] ), W_mult0_32_32( ImagBuffer_fx[1][0][l], ImagBuffer_fx[1][0][l] ) );
-#ifdef FIX_867_CLDFB_NRG_SCALE
- temp = Mpy_32_32( a_fx, W_extract_l( W_shr( reference_power_64fx[l], add( 31, total_shift[qidx] ) ) ) ); // 2*(q_cldfb+min_q_shift) -31
- IF( LT_16( q_temp_total, stereo_type_detect->q_total_power ) )
- {
- stereo_type_detect->total_power_fx[l] = L_add( temp, L_shr( Mpy_32_32( b_fx, stereo_type_detect->total_power_fx[l] ), sub( stereo_type_detect->q_total_power, q_temp_total ) ) ); // q_temp
- move32();
- }
- ELSE
- {
- stereo_type_detect->total_power_fx[l] = L_add( L_shr( temp, sub( q_temp_total, stereo_type_detect->q_total_power ) ), Mpy_32_32( b_fx, stereo_type_detect->total_power_fx[l] ) ); // stereo_type_detect->q_total_power
- move32();
- }
-#else
- temp = Mpy_32_32( a_fx, W_extract_l( W_shr( reference_power_64fx[l], 31 ) ) ); // 2*(q_cldfb+min_q_shift) -31
- IF( LT_16( q_temp, stereo_type_detect->q_total_power ) )
- {
- stereo_type_detect->total_power_fx[l] = L_add( temp, L_shr( Mpy_32_32( b_fx, stereo_type_detect->total_power_fx[l] ), sub( stereo_type_detect->q_total_power, q_temp ) ) ); // q_temp
- move32();
- }
- ELSE
- {
- stereo_type_detect->total_power_fx[l] = L_add( L_shr( temp, sub( q_temp, stereo_type_detect->q_total_power ) ), Mpy_32_32( b_fx, stereo_type_detect->total_power_fx[l] ) ); // stereo_type_detect->q_total_power
- move32();
- }
-#endif
+ W_tmp2 = W_add( W_tmp1, W_tmp2 );
+ q_shift = W_norm( W_tmp2 );
+ Total_power_fx = W_extract_h( W_shl( W_tmp2, q_shift ) );
+ exp_temppp = sub( 31, sub( add( shl( q_cldfb, 1 ), q_shift ), 32 ) );
+
+ stereo_type_detect->total_power_fx[l] = BASOP_Util_Add_Mant32Exp( Mpy_32_32( a_fx, Total_power_fx ), exp_temppp, Mpy_32_32( b_fx, stereo_type_detect->total_power_fx[l] ), stereo_type_detect->exp_total_power[l], &stereo_type_detect->exp_total_power[l] );
+ move32();
test();
IF( ( stereo_type_detect->sum_power_fx[l] == 0 ) && ( stereo_type_detect->total_power_fx[l] == 0 ) )
{
sum_total_ratio_fx[l] = MAX_32; // q15
move32();
+ exp_sum_total_ratio_fx[l] = 16;
+ move16();
}
ELSE IF( stereo_type_detect->total_power_fx[l] == 0 )
{
sum_total_ratio_fx[l] = MAX_32; // q15
move32();
+ exp_sum_total_ratio_fx[l] = 16;
+ move16();
}
ELSE
{
- sum_total_ratio_fx[l] = BASOP_Util_Divide3232_Scale( stereo_type_detect->sum_power_fx[l], stereo_type_detect->total_power_fx[l], &exp ); // 15-(exp+s_min( stereo_type_detect->q_total_power, q_temp )-s_min( stereo_type_detect->q_sum_power, q_temp2 ))
- move32();
-#ifdef FIX_867_CLDFB_NRG_SCALE
- q_sum_total_ratio = add( sub( 15, exp ), sub( s_min( stereo_type_detect->q_sum_power, q_temp2 ), s_min( stereo_type_detect->q_total_power, q_temp_total ) ) );
-#else
- q_sum_total_ratio = add( sub( 15, exp ), sub( s_min( stereo_type_detect->q_sum_power, q_temp2 ), s_min( stereo_type_detect->q_total_power, q_temp ) ) );
-#endif
- sum_total_ratio_fx[l] = L_shl( sum_total_ratio_fx[l], sub( Q15, q_sum_total_ratio ) ); // q15
+ sum_total_ratio_fx[l] = BASOP_Util_Divide3232_Scale_newton( stereo_type_detect->sum_power_fx[l], stereo_type_detect->total_power_fx[l], &exp ); // 15-(exp+s_min( stereo_type_detect->q_total_power, q_temp )-s_min( stereo_type_detect->q_sum_power, q_temp2 ))
move32();
+ exp_sum_total_ratio_fx[l] = add( exp, sub( stereo_type_detect->exp_sum_power[l], stereo_type_detect->exp_total_power[l] ) );
+ move16();
}
+ q_sum_total_ratio = s_max( q_sum_total_ratio, exp_sum_total_ratio_fx[l] );
}
IF( l == 0 )
@@ -2612,18 +2595,6 @@ void protoSignalComputation2_fx(
move32();
}
- stereo_type_detect->q_sum_power = s_min( stereo_type_detect->q_sum_power, q_temp2 );
- move16();
-#ifdef FIX_867_CLDFB_NRG_SCALE
- stereo_type_detect->q_total_power = s_min( stereo_type_detect->q_total_power, q_temp_total );
- move16();
-#else
- stereo_type_detect->q_total_power = s_min( stereo_type_detect->q_total_power, q_temp );
- move16();
-#endif
- q_sum_total_ratio = Q15;
- move16();
-
IF( stereo_type_detect->interpolator > 0 )
{
stereo_type_detect->interpolator++;
@@ -2704,15 +2675,16 @@ void protoSignalComputation2_fx(
lr_total_bb_ratio_fx = Mpy_32_16_1( temp, 20480 ); // Q21
#ifdef FIX_867_CLDFB_NRG_SCALE
- stereo_type_detect->left_hi_power_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_32( a2_fx, left_hi_power_fx ), sub( 31, q_temp_total ), Mpy_32_32( b2_fx, stereo_type_detect->left_hi_power_fx ), sub( 31, stereo_type_detect->q_left_hi_power ), &stereo_type_detect->q_left_hi_power );
+ stereo_type_detect->left_hi_power_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_32( a2_fx, left_hi_power_fx ), exp_left_hi_power, Mpy_32_32( b2_fx, stereo_type_detect->left_hi_power_fx ), sub( 31, stereo_type_detect->q_left_hi_power ), &stereo_type_detect->q_left_hi_power );
move32();
stereo_type_detect->q_left_hi_power = sub( 31, stereo_type_detect->q_left_hi_power );
move16();
- stereo_type_detect->right_hi_power_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_32( a2_fx, right_hi_power_fx ), sub( 31, q_temp_total ), Mpy_32_32( b2_fx, stereo_type_detect->right_hi_power_fx ), sub( 31, stereo_type_detect->q_right_hi_power ), &stereo_type_detect->q_right_hi_power );
+
+ stereo_type_detect->right_hi_power_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_32( a2_fx, right_hi_power_fx ), exp_right_hi_power, Mpy_32_32( b2_fx, stereo_type_detect->right_hi_power_fx ), sub( 31, stereo_type_detect->q_right_hi_power ), &stereo_type_detect->q_right_hi_power );
move32();
stereo_type_detect->q_right_hi_power = sub( 31, stereo_type_detect->q_right_hi_power );
move16();
- stereo_type_detect->total_hi_power_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_32( a2_fx, total_hi_power_fx ), sub( 31, q_temp_total ), Mpy_32_32( b2_fx, stereo_type_detect->total_hi_power_fx ), sub( 31, stereo_type_detect->q_total_hi_power ), &stereo_type_detect->q_total_hi_power );
+ stereo_type_detect->total_hi_power_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_32( a2_fx, total_hi_power_fx ), exp_total_hi_power, Mpy_32_32( b2_fx, stereo_type_detect->total_hi_power_fx ), sub( 31, stereo_type_detect->q_total_hi_power ), &stereo_type_detect->q_total_hi_power );
move32();
#else
stereo_type_detect->left_hi_power_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_32( a2_fx, left_hi_power_fx ), sub( 31, q_temp ), Mpy_32_32( b2_fx, stereo_type_detect->left_hi_power_fx ), sub( 31, stereo_type_detect->q_left_hi_power ), &stereo_type_detect->q_left_hi_power );
@@ -2752,8 +2724,15 @@ void protoSignalComputation2_fx(
// 20480 = 10 in Q11
lr_total_hi_ratio_fx = Mpy_32_16_1( temp, 20480 ); // Q21
+ FOR( Word16 i = 0; i < s_min( num_freq_bands, MASA_SUM_FREQ_RANGE_BINS ); i++ )
+ {
+ sum_total_ratio_fx[i] = L_shl( sum_total_ratio_fx[i], sub( exp_sum_total_ratio_fx[i], q_sum_total_ratio ) );
+ move32();
+ }
+
minimum_l( sum_total_ratio_fx, s_min( num_freq_bands, MASA_SUM_FREQ_RANGE_BINS ), &min_sum_total_ratio_fx ); // q_sum_total_ratio
- exp = sub( 31, q_sum_total_ratio );
+ exp = q_sum_total_ratio;
+ move16();
temp = BASOP_Util_Log2( min_sum_total_ratio_fx ); // q25
IF( NE_32( temp, MIN_32 ) )
{
@@ -3176,7 +3155,11 @@ void protoSignalComputation4_fx(
sq_tmp_fx = Madd_32_32( Mpy_32_32( proto_frame_f_fx[idx], proto_frame_f_fx[idx] ), proto_frame_f_fx[idx + 1], proto_frame_f_fx[idx + 1] ); // 2*(proto_frame_f_q)-31
sq_tmp_q = sub( add( *proto_frame_f_q, *proto_frame_f_q ), 31 );
+#ifdef OPT_SBA_REND_V1_BE
+ proto_power_smooth_fx_q = s_min( *proto_power_smooth_q, sq_tmp_q );
+ proto_power_smooth_fx[l + ( k * num_freq_bands )] = L_add( L_shr( proto_power_smooth_fx[l + ( k * num_freq_bands )], sub( *proto_power_smooth_q, proto_power_smooth_fx_q ) ), L_shr( sq_tmp_fx, sub( sq_tmp_q, proto_power_smooth_fx_q ) ) ); // proto_power_smooth_fx_q
+#else /* OPT_SBA_REND_V1_BE */
IF( LT_16( *proto_power_smooth_q, sq_tmp_q ) )
{
proto_power_smooth_fx[l + ( k * num_freq_bands )] = L_add( proto_power_smooth_fx[l + ( k * num_freq_bands )], L_shr( sq_tmp_fx, sub( sq_tmp_q, *proto_power_smooth_q ) ) ); // proto_power_smooth_q
@@ -3191,8 +3174,8 @@ void protoSignalComputation4_fx(
proto_power_smooth_fx_q = sq_tmp_q;
move16();
}
-
- p_proto_buffer_fx[idx] = proto_frame_f_fx[idx]; // proto_frame_f_q
+#endif /* OPT_SBA_REND_V1_BE */
+ p_proto_buffer_fx[idx] = proto_frame_f_fx[idx]; // proto_frame_f_q
move32();
p_proto_buffer_fx[idx + 1] = proto_frame_f_fx[idx + 1]; // proto_frame_f_q
move32();
@@ -3522,10 +3505,8 @@ void ivas_masa_init_stereotype_detection_fx(
set32_fx( stereo_type_detect->sum_power_fx, 0, MASA_SUM_FREQ_RANGE_BINS );
set32_fx( stereo_type_detect->total_power_fx, 0, MASA_SUM_FREQ_RANGE_BINS );
- stereo_type_detect->q_sum_power = Q31;
- move16();
- stereo_type_detect->q_total_power = Q31;
- move16();
+ set16_fx( stereo_type_detect->exp_sum_power, 0, MASA_SUM_FREQ_RANGE_BINS );
+ set16_fx( stereo_type_detect->exp_total_power, 0, MASA_SUM_FREQ_RANGE_BINS );
stereo_type_detect->subtract_power_y_fx = 0;
move32();
@@ -5018,8 +4999,11 @@ static void ivas_masa_ext_dirac_render_sf_fx(
}
ELSE
{
- scale_sig32( Cldfb_RealBuffer_fx[idx_in][i], hSpatParamRendCom->num_freq_bands, sub( hMasaExtRend->cldfbSynRend[idx_in]->Q_cldfb_state, q_out ) );
- scale_sig32( Cldfb_ImagBuffer_fx[idx_in][i], hSpatParamRendCom->num_freq_bands, sub( hMasaExtRend->cldfbSynRend[idx_in]->Q_cldfb_state, q_out ) );
+ FOR( i = 0; i < hSpatParamRendCom->subframe_nbslots[subframe_idx]; i++ )
+ {
+ scale_sig32( Cldfb_RealBuffer_fx[idx_in][i], hSpatParamRendCom->num_freq_bands, sub( hMasaExtRend->cldfbSynRend[idx_in]->Q_cldfb_state, q_out ) );
+ scale_sig32( Cldfb_ImagBuffer_fx[idx_in][i], hSpatParamRendCom->num_freq_bands, sub( hMasaExtRend->cldfbSynRend[idx_in]->Q_cldfb_state, q_out ) );
+ }
}
FOR( i = 0; i < hSpatParamRendCom->subframe_nbslots[subframe_idx]; i++ )
{
diff --git a/lib_rend/ivas_efap_fx.c b/lib_rend/ivas_efap_fx.c
index 4fb88643bb143d6c704e885a0fcd4e0c3f0b4702..2ac397e2cb3bd0853b6531a7b914e5d045ee1b31 100644
--- a/lib_rend/ivas_efap_fx.c
+++ b/lib_rend/ivas_efap_fx.c
@@ -1528,7 +1528,7 @@ static void get_poly_gains_fx(
#ifdef VEC_ARITH_OPT_v1
v_sub_fixed_no_hdrm( P, A, P_minus_A, 2 ); /* Precalculate value of (P-A) q22*/
#else /* VEC_ARITH_OPT_v1 */
- v_sub_fixed( P, A, P_minus_A, 2, 0 ); /* Precalculate value of (P-A) q22*/
+ v_sub_fixed( P, A, P_minus_A, 2, 0 ); /* Precalculate value of (P-A) q22*/
#endif /* VEC_ARITH_OPT_v1 */
FOR( j = i; j < numChan - 2 + i; ++j )
@@ -1585,7 +1585,7 @@ static Word32 get_tri_gain_fx(
#ifdef VEC_ARITH_OPT_v1
v_sub_fixed_no_hdrm( B, A, tmpSub1, 2 ); // tmpSub1 q22
#else /* VEC_ARITH_OPT_v1 */
- v_sub_fixed( B, A, tmpSub1, 2, 0 ); // tmpSub1 q22
+ v_sub_fixed( B, A, tmpSub1, 2, 0 ); // tmpSub1 q22
#endif /* VEC_ARITH_OPT_v1 */
tmpDot1 = dotp_fixed( tmpN, tmpSub1, 2 ); // Q13
@@ -2248,7 +2248,7 @@ static void sort_channels_vertex_fx(
#ifdef VEC_ARITH_OPT_v1
v_sub_fixed_no_hdrm( tmpV1, tmpV2, tmpV3, 3 ); // tmpV3 Q30
#else /* VEC_ARITH_OPT_v1 */
- v_sub_fixed( tmpV1, tmpV2, tmpV3, 3, 0 ); // tmpV3 Q30
+ v_sub_fixed( tmpV1, tmpV2, tmpV3, 3, 0 ); // tmpV3 Q30
#endif /* VEC_ARITH_OPT_v1 */
Word16 exp2 = 2;
move16();
@@ -2434,7 +2434,7 @@ static Word16 in_poly_fx( /* Angles are in Q22 */
#ifdef VEC_ARITH_OPT_v1
v_sub_fixed_no_hdrm( P, A, P_minus_A, 2 ); /* Precalculate value of (P-A) q22*/
#else /* VEC_ARITH_OPT_v1 */
- v_sub_fixed( P, A, P_minus_A, 2, 0 ); /* Precalculate value of (P-A) q22*/
+ v_sub_fixed( P, A, P_minus_A, 2, 0 ); /* Precalculate value of (P-A) q22*/
#endif /* VEC_ARITH_OPT_v1 */
FOR( n = 1; n < sub( numVertices, 1 ); ++n )
@@ -2490,7 +2490,8 @@ static Word16 in_tri_fx(
Word32 tmpDot1[2], tmpDot2[2];
Word32 matInv[2][2];
Word32 invFactor;
- Word16 tmp16, tmp_e;
+ Word16 tmp_e;
+ Word32 tmp32;
Word64 S[2];
/* Threshold adjusted */
Word64 thresh_int = 35184640; // 1e-6f in Q45
@@ -2507,12 +2508,16 @@ static Word16 in_tri_fx(
v_sub_fixed_no_hdrm( B, A, tmpDot1, 2 ); // tmpDot1 q22
v_sub_fixed_no_hdrm( C, A, tmpDot2, 2 ); // tmpDot2 q22
#else /* VEC_ARITH_OPT_v1 */
- v_sub_fixed( B, A, tmpDot1, 2, 0 ); // tmpDot1 q22
- v_sub_fixed( C, A, tmpDot2, 2, 0 ); // tmpDot2 q22
+ v_sub_fixed( B, A, tmpDot1, 2, 0 ); // tmpDot1 q22
+ v_sub_fixed( C, A, tmpDot2, 2, 0 ); // tmpDot2 q22
#endif /* VEC_ARITH_OPT_v1 */
/* Verification of the non-colinearity : Q22 * Q22 = Q13 */
+#ifdef OPT_SBA_REND_V1_BE
+ invFactor = Msub_32_32( Mpy_32_32( tmpDot1[0], tmpDot2[1] ), tmpDot1[1], tmpDot2[0] ); /*q22+q22-q31->q13*/
+#else /* OPT_SBA_REND_V1_BE */
invFactor = L_sub( Mpy_32_32( tmpDot1[0], tmpDot2[1] ), Mpy_32_32( tmpDot1[1], tmpDot2[0] ) ); /*q22+q22-q31->q13*/
+#endif /* OPT_SBA_REND_V1_BE */
IF( invFactor == 0 )
{
@@ -2520,8 +2525,8 @@ static Word16 in_tri_fx(
}
/* invFactor = 1.f / invFactor; */
- tmp16 = BASOP_Util_Divide3232_Scale( ONE_IN_Q13, invFactor, &tmp_e ); /*15-tmp_e*/
- invFactor = L_shl_sat( tmp16, add( Q16, tmp_e ) ); /* Q31 */
+ tmp32 = BASOP_Util_Divide3232_Scale_newton( ONE_IN_Q13, invFactor, &tmp_e ); /*31-tmp_e*/
+ invFactor = L_shl_sat( tmp32, tmp_e ); /* Q31 */
Word16 invFactor_exp = norm_l( invFactor );
invFactor = L_shl( invFactor, invFactor_exp ); // 31+invFactor_exp
diff --git a/lib_rend/ivas_masa_merge_fx.c b/lib_rend/ivas_masa_merge_fx.c
index fd20a9fabb262fe00e70c28aa6319e405ec7707b..e0dd57afb5530fb604ce36fd92c3b9bc4cd09347 100644
--- a/lib_rend/ivas_masa_merge_fx.c
+++ b/lib_rend/ivas_masa_merge_fx.c
@@ -46,9 +46,25 @@
static void copy_masa_meta_tile_fx( MASA_DECODER_EXT_OUT_META_HANDLE outMeta, MASA_DECODER_EXT_OUT_META_HANDLE inMeta, const UWord8 sf, const UWord8 band );
-static void full_stream_merge_fx( MASA_DECODER_EXT_OUT_META_HANDLE outMeta, MASA_DECODER_EXT_OUT_META_HANDLE inMeta1, Word32 inEne1[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], Word16 *inEne1_e, MASA_DECODER_EXT_OUT_META_HANDLE inMeta2, Word32 inEne2[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], Word16 *inEne2_e );
+static void full_stream_merge_fx(
+ MASA_DECODER_EXT_OUT_META_HANDLE outMeta, /* o : Merged metadata output */
+ MASA_DECODER_EXT_OUT_META_HANDLE inMeta1, /* i : Input metadata 1 */
+ Word32 inEne1_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i/o: TF-energy of input 1. after merge, contains the energy of the merged signal */
+ Word16 inEne1_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i/o: TF-energy of input 1 Exponent */
+ MASA_DECODER_EXT_OUT_META_HANDLE inMeta2, /* i : Input metadata 2 */
+ Word32 inEne2_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : TF-energy of input 2 */
+ Word16 inEne2_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS] /* i : TF-energy of input 2 Exponent */
+);
-static void diffuse_meta_merge_1x1_fx( MASA_DECODER_EXT_OUT_META_HANDLE outMeta, MASA_DECODER_EXT_OUT_META_HANDLE inMeta, Word32 inEne_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], Word16 *inEne_e, MASA_DECODER_EXT_OUT_META_HANDLE inMetaISM, Word32 inEneISM_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], Word16 *inEneISM_e );
+static void diffuse_meta_merge_1x1_fx(
+ MASA_DECODER_EXT_OUT_META_HANDLE outMeta, /* o : Merged metadata output */
+ MASA_DECODER_EXT_OUT_META_HANDLE inMeta, /* i : Input metadata 1 */
+ Word32 inEne_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : TF-energy of input 1 */
+ Word16 inEne_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : TF-energy of input 1 Exponent */
+ MASA_DECODER_EXT_OUT_META_HANDLE inMetaISM, /* i : Input metadata 2 */
+ Word32 inEneISM_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : TF-energy of input 2 */
+ Word16 inEneISM_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS] /* i : TF-energy of input 2 Exponent */
+);
/*---------------------------------------------------------------------*
@@ -144,14 +160,13 @@ void diffuse_meta_merge_1x1_fx(
MASA_DECODER_EXT_OUT_META_HANDLE outMeta, /* o : Merged metadata output */
MASA_DECODER_EXT_OUT_META_HANDLE inMeta, /* i : Input metadata 1 */
Word32 inEne_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : TF-energy of input 1 */
- Word16 *inEne_e, /* i : TF-energy of input 1 Exponent */
+ Word16 inEne_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : TF-energy of input 1 Exponent */
MASA_DECODER_EXT_OUT_META_HANDLE inMetaISM, /* i : Input metadata 2 */
Word32 inEneISM_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : TF-energy of input 2 */
- Word16 *inEneISM_e /* i : TF-energy of input 2 Exponent */
+ Word16 inEneISM_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS] /* i : TF-energy of input 2 Exponent */
)
{
Word8 sf, band;
- Word16 max_e, in1_e[MASA_FREQUENCY_BANDS], i;
FOR( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES; sf++ )
{
FOR( band = 0; band < MASA_FREQUENCY_BANDS; band++ )
@@ -164,34 +179,30 @@ void diffuse_meta_merge_1x1_fx(
tmp = BASOP_Util_Divide1616_Scale( inMeta->directToTotalRatio[0][sf][band], UINT8_MAX, &scale );
energyTimesRatio_fx = Mpy_32_16_r( inEne_fx[sf][band], tmp ); /* Q( 31 - ( nEne_e[sf] + scale ) ) */
- energyTimesRatio_e = add( inEne_e[sf], scale );
+ energyTimesRatio_e = add( inEne_e[sf][band], scale );
+ total_nrg_fx = BASOP_Util_Add_Mant32Exp( inEne_fx[sf][band], inEne_e[sf][band], inEneISM_fx[sf][band], inEneISM_e[sf][band], &total_nrg_e );
- IF( GT_16( inEne_e[sf], inEneISM_e[sf] ) )
- {
- total_nrg_fx = L_add( L_shr( inEne_fx[sf][band], 1 ), L_shr( inEneISM_fx[sf][band], add( sub( inEne_e[sf], inEneISM_e[sf] ), 1 ) ) ); /* Q(30 - inEne_e[sf]) */
- total_nrg_e = add( inEne_e[sf], 1 );
- }
- ELSE
- {
- total_nrg_fx = L_add( L_shr( inEneISM_fx[sf][band], 1 ), L_shr( inEne_fx[sf][band], add( sub( inEneISM_e[sf], inEne_e[sf] ), 1 ) ) ); /* Q(30 - inEneISM_e[sf]) */
- total_nrg_e = add( inEneISM_e[sf], 1 );
- }
/* target is original MASA diffuseness */
tmp = BASOP_Util_Divide1616_Scale( inMeta->diffuseToTotalRatio[sf][band], UINT8_MAX, &scale );
total_diff_nrg_fx = Mpy_32_16_r( inEne_fx[sf][band], tmp ); /* Q( 31 - ( nEne_e[sf] + scale ) ) */
- total_diff_nrg_e = add( inEne_e[sf], scale );
+ total_diff_nrg_e = add( inEne_e[sf][band], scale );
/* criterion is mean of ISM ratio and new ratio */
dir_ratio_ism_fx = L_deposit_h( BASOP_Util_Divide1616_Scale( inMetaISM->directToTotalRatio[0][sf][band], UINT8_MAX, &dir_ratio_ism_e ) );
tmp = BASOP_Util_Divide3232_Scale( total_diff_nrg_fx, L_add( total_nrg_fx, EPSILON_FX ), &scale );
L_tmp1 = L_deposit_h( tmp ); /* Q( 31 - ( scale + total_nrg_e - total_diff_nrg_e ) ) */
scale = add( scale, sub( total_diff_nrg_e, total_nrg_e ) );
+ if ( L_tmp1 == 0 )
+ {
+ scale = 30;
+ move16();
+ }
L_tmp2 = L_sub( L_shl( 1, scale ), L_tmp1 );
L_tmp1 = BASOP_Util_Add_Mant32Exp( dir_ratio_ism_fx, dir_ratio_ism_e, L_tmp2, scale, &tmp );
L_tmp1 = L_shr( L_tmp1, 1 );
energyTimesRatioISM_fx = Mpy_32_32( L_tmp1, inEneISM_fx[sf][band] ); /* Q( 31 - ( tmp + inEneISM_e[sf] ) ) */
- energyTimesRatioISM_e = add( tmp, inEneISM_e[sf] );
+ energyTimesRatioISM_e = add( tmp, inEneISM_e[sf][band] );
IF( ( BASOP_Util_Cmp_Mant32Exp( energyTimesRatioISM_fx, energyTimesRatioISM_e, energyTimesRatio_fx, energyTimesRatio_e ) > 0 ) )
{
@@ -209,7 +220,7 @@ void diffuse_meta_merge_1x1_fx(
tmp = BASOP_Util_Divide3232_Scale( total_diff_nrg_fx, L_add( EPSILON_FX, total_nrg_fx ), &scale );
scale = add( scale, sub( total_diff_nrg_e, total_nrg_e ) );
- dir_nrg_ratio_fx = L_sub( L_shl( 1, scale ), L_deposit_h( tmp ) );
+ dir_nrg_ratio_fx = L_sub( L_shl_sat( 1, sub( 31, scale ) ), L_deposit_h( tmp ) );
dir_nrg_ratio_e = scale;
move16();
@@ -239,7 +250,7 @@ void diffuse_meta_merge_1x1_fx(
{
new_diff_ratio_fx = L_sub( L_shl( 1, sub( 31, new_dir_ratio_e ) ), new_dir_ratio_fx ); /* Q(31 - new_dir_ratiio_e) */
}
- outMeta->diffuseToTotalRatio[sf][band] = (UWord8) imult1616( extract_l( L_shr( new_diff_ratio_fx, new_dir_ratio_e ) ), UINT8_MAX );
+ outMeta->diffuseToTotalRatio[sf][band] = (UWord8) imult1616( extract_l( L_shr( new_diff_ratio_fx, sub( 31, new_dir_ratio_e ) ) ), UINT8_MAX );
move16();
}
ELSE
@@ -264,29 +275,9 @@ void diffuse_meta_merge_1x1_fx(
outMeta->spreadCoherence[1][sf][band] = 0u;
move16();
- inEne_fx[sf][band] = BASOP_Util_Add_Mant32Exp( inEne_fx[sf][band], inEne_e[sf], inEneISM_fx[sf][band], inEneISM_e[sf], &in1_e[band] ); /* Update energy for subsequent mergings */
- move16();
- }
-
- max_e = in1_e[0];
- move16();
- FOR( i = 1; i < MASA_FREQUENCY_BANDS; i++ )
- {
- if ( LT_16( max_e, in1_e[i] ) )
- {
- max_e = in1_e[i];
- move16();
- }
- }
-
- FOR( i = 0; i < MASA_FREQUENCY_BANDS; i++ )
- {
- inEne_fx[sf][i] = L_shr( inEne_fx[sf][i], sub( max_e, in1_e[i] ) ); /* Q(31 - max_e) */
+ inEne_fx[sf][band] = BASOP_Util_Add_Mant32Exp( inEne_fx[sf][band], inEne_e[sf][band], inEneISM_fx[sf][band], inEneISM_e[sf][band], &inEne_e[sf][band] ); /* Update energy for subsequent mergings */
move32();
}
-
- inEne_e[sf] = max_e;
- move16();
}
/* Set descriptive meta for mixed format */
@@ -318,16 +309,15 @@ void full_stream_merge_fx(
MASA_DECODER_EXT_OUT_META_HANDLE outMeta, /* o : Merged metadata output */
MASA_DECODER_EXT_OUT_META_HANDLE inMeta1, /* i : Input metadata 1 */
Word32 inEne1_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i/o: TF-energy of input 1. after merge, contains the energy of the merged signal */
- Word16 *inEne1_e, /* i/o: TF-energy of input 1 Exponent */
+ Word16 inEne1_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i/o: TF-energy of input 1 Exponent */
MASA_DECODER_EXT_OUT_META_HANDLE inMeta2, /* i : Input metadata 2 */
Word32 inEne2_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : TF-energy of input 2 */
- Word16 *inEne2_e /* i : TF-energy of input 2 Exponent */
+ Word16 inEne2_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS] /* i : TF-energy of input 2 Exponent */
)
{
UWord8 n_dirs_1, n_dirs_2;
UWord8 sf, band;
- Word16 scale, tmp, dir_nrg_1_e, dir_nrg_2_e, max_e, i;
- Word16 in1_e[MASA_FREQUENCY_BANDS];
+ Word16 scale, tmp, dir_nrg_1_e, dir_nrg_2_e;
Word32 dir_nrg_1_fx, dir_nrg_2_fx, L_tmp;
/* full stream select based on total direct energy */
@@ -340,17 +330,17 @@ void full_stream_merge_fx(
{
tmp = BASOP_Util_Divide1616_Scale( inMeta1->directToTotalRatio[0][sf][band], UINT8_MAX, &scale );
dir_nrg_1_fx = Mpy_32_32( L_deposit_h( tmp ), inEne1_fx[sf][band] ); /* Q( 31 - ( scale + inEne1_e[sf] ) ) */
- dir_nrg_1_e = add( scale, inEne1_e[sf] );
+ dir_nrg_1_e = add( scale, inEne1_e[sf][band] );
- tmp = BASOP_Util_Divide1616_Scale( inMeta1->directToTotalRatio[0][sf][band], UINT8_MAX, &scale );
+ tmp = BASOP_Util_Divide1616_Scale( inMeta2->directToTotalRatio[0][sf][band], UINT8_MAX, &scale );
dir_nrg_2_fx = Mpy_32_32( L_deposit_h( tmp ), inEne2_fx[sf][band] ); /* Q( 31 - ( scale + inEne2_e[sf] ) ) */
- dir_nrg_2_e = add( scale, inEne2_e[sf] );
+ dir_nrg_2_e = add( scale, inEne2_e[sf][band] );
IF( EQ_16( n_dirs_1, 2 ) )
{
tmp = BASOP_Util_Divide1616_Scale( inMeta1->directToTotalRatio[1][sf][band], UINT8_MAX, &scale );
L_tmp = Mpy_32_32( L_deposit_h( tmp ), inEne1_fx[sf][band] ); /* Q( 31 - ( scale + inEne1_e[sf] ) ) */
- scale = add( scale, inEne1_e[sf] );
+ scale = add( scale, inEne1_e[sf][band] );
dir_nrg_1_fx = BASOP_Util_Add_Mant32Exp( L_tmp, scale, dir_nrg_1_fx, dir_nrg_1_e, &dir_nrg_1_e );
}
@@ -358,7 +348,7 @@ void full_stream_merge_fx(
{
tmp = BASOP_Util_Divide1616_Scale( inMeta2->directToTotalRatio[1][sf][band], UINT8_MAX, &scale );
L_tmp = Mpy_32_32( L_deposit_h( tmp ), inEne2_fx[sf][band] ); /* Q( 31 - ( scale + inEne2_e[sf] ) ) */
- scale = add( scale, inEne2_e[sf] );
+ scale = add( scale, inEne2_e[sf][band] );
dir_nrg_2_fx = BASOP_Util_Add_Mant32Exp( L_tmp, scale, dir_nrg_2_fx, dir_nrg_2_e, &dir_nrg_2_e );
}
@@ -371,29 +361,9 @@ void full_stream_merge_fx(
copy_masa_meta_tile_fx( outMeta, inMeta2, sf, band );
}
- inEne1_fx[sf][band] = BASOP_Util_Add_Mant32Exp( inEne1_fx[sf][band], inEne1_e[sf], inEne2_fx[sf][band], inEne2_e[sf], &in1_e[band] );
- move32();
- }
-
- max_e = in1_e[0];
- move16();
- FOR( i = 1; i < MASA_FREQUENCY_BANDS; i++ )
- {
- if ( LT_16( max_e, in1_e[i] ) )
- {
- max_e = in1_e[i];
- move16();
- }
- }
-
- FOR( i = 0; i < MASA_FREQUENCY_BANDS; i++ )
- {
- inEne1_fx[sf][i] = L_shr( inEne1_fx[sf][i], sub( max_e, in1_e[i] ) ); /* Q( 31 - max_e ) */
+ inEne1_fx[sf][band] = BASOP_Util_Add_Mant32Exp( inEne1_fx[sf][band], inEne1_e[sf][band], inEne2_fx[sf][band], inEne2_e[sf][band], &inEne1_e[sf][band] );
move32();
}
-
- inEne1_e[sf] = max_e;
- move16();
}
/* Set descriptive meta for mixed format */
@@ -436,11 +406,11 @@ void ivas_prerend_merge_masa_metadata_fx(
MASA_DECODER_EXT_OUT_META_HANDLE inMeta1, /* i : Input metadata 1 */
IVAS_REND_AudioConfigType inType1, /* i : Type of input 1 */
Word32 inEne1_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i/o: TF-energy of input 1. after merge, contains the energy of the merged signal */
- Word16 *inEne1_e, /* i/o: TF-energy of input 1 Exponent */
+ Word16 inEne1_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i/o: TF-energy of input 1 Exponent */
MASA_DECODER_EXT_OUT_META_HANDLE inMeta2, /* i : Input metadata 2 */
IVAS_REND_AudioConfigType inType2, /* i : Type of input 2 */
Word32 inEne2_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : TF-energy of input 2 */
- Word16 *inEne2_e /* i : TF-energy of input 2 Exponent */
+ Word16 inEne2_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS] /* i : TF-energy of input 2 Exponent */
)
{
/* mixing ISMs with non-ISM use different merge */
diff --git a/lib_rend/ivas_mcmasa_ana_fx.c b/lib_rend/ivas_mcmasa_ana_fx.c
index cfdd431167d350a0d184b6b098b8122fa4836a23..b2b4039f3029078401dff71467da750ed4c3f03a 100644
--- a/lib_rend/ivas_mcmasa_ana_fx.c
+++ b/lib_rend/ivas_mcmasa_ana_fx.c
@@ -634,7 +634,7 @@ void ivas_mcmasa_param_est_ana_fx(
{
inp_q = q_data;
move16();
- cldfbAnalysis_ts_fx_fixed_q( &( data_fx[i][i_mult( l_ts, ts )] ), Chnl_RealBuffer_fx[i], Chnl_ImagBuffer_fx[i], l_ts, hMcMasa->cldfbAnaEnc[i], &inp_q );
+ cldfbAnalysis_ts_fx_var_q( &( data_fx[i][i_mult( l_ts, ts )] ), Chnl_RealBuffer_fx[i], Chnl_ImagBuffer_fx[i], l_ts, hMcMasa->cldfbAnaEnc[i], &inp_q );
cr_q = s_min( cr_q, getScaleFactor32( Chnl_ImagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX ) );
ci_q = s_min( ci_q, getScaleFactor32( Chnl_RealBuffer_fx[i], CLDFB_NO_CHANNELS_MAX ) );
}
@@ -952,7 +952,7 @@ void ivas_mcmasa_param_est_ana_fx(
temp2 = L_add( temp2, EPSILON_FX );
lsEnergyRelation_fx = BASOP_Util_Divide3232_Scale( temp1, temp2, &lsEnergyRelation_e );
lsEnergyRelation_e = add( lsEnergyRelation_e, sub( temp1_e, temp2_e ) );
- lsEnergyRelation_fx = L_shl( lsEnergyRelation_fx, add( 16, lsEnergyRelation_e ) ); // Q31
+ lsEnergyRelation_fx = L_shl_sat( lsEnergyRelation_fx, add( 16, lsEnergyRelation_e ) ); // Q31
stereoness_fx = Mult_32_32( stereoCoh_fx, lsEnergyRelation_fx );
stereoness_e = stereoCoh_e;
move16();
@@ -1105,12 +1105,12 @@ void ivas_mcmasa_param_est_ana_fx(
lsEnergySum_fx = L_add_sat( lsEnergySum_fx, EPSILON_FX );
lsEnergyRelation_fx = BASOP_Util_Divide3232_Scale( temp1, lsEnergySum_fx, &lsEnergyRelation_e );
lsEnergyRelation_e = add( lsEnergyRelation_e, sub( temp1_e, lsEnergySum_e ) );
- lsEnergyRelation_fx = L_shl( lsEnergyRelation_fx, add( 16, lsEnergyRelation_e ) ); // Q31
+ lsEnergyRelation_fx = L_shl_sat( lsEnergyRelation_fx, add( 16, lsEnergyRelation_e ) ); // Q31
stereoRatio_fx = L_sub( Mult_32_32( L_shl_sat( stereoCoh_fx, stereoCoh_e ), lsEnergyRelation_fx ), surrCoh_fx ); // Q31
-
+ temp2 = L_sub( temp2, EPSILON_FX );
lsEnergyRelation_fx = BASOP_Util_Divide3232_Scale( temp2, lsEnergySum_fx, &lsEnergyRelation_e );
lsEnergyRelation_e = add( lsEnergyRelation_e, sub( temp2_e, lsEnergySum_e ) );
- lsEnergyRelation_fx = L_shl( lsEnergyRelation_fx, add( 16, lsEnergyRelation_e ) ); // Q31
+ lsEnergyRelation_fx = L_shl_sat( lsEnergyRelation_fx, add( 16, lsEnergyRelation_e ) ); // Q31
cohPanRatio_fx = L_sub( Mult_32_32( cohPanCoh_fx, lsEnergyRelation_fx ), surrCoh_fx ); // Q31
IF( GT_32( stereoRatio_fx, cohPanRatio_fx ) )
@@ -1436,24 +1436,33 @@ static void computeVerticalDiffuseness_fx(
{
Word16 tmp_e1, tmp_e2;
tmp = BASOP_Util_Divide3232_Scale( intensity_slow_abs[i], L_add( energy_slow[i], EPSILON_FX_SMALL ), &tmp_e1 );
- tmp_e1 = add( tmp_e1, sub( intensity_slow_e[i], energy_slow_e[i] ) );
- tmp = BASOP_Util_Divide3232_Scale( L_sub( tmp, L_shr( VERTICAL_ENERGY_RATIO_OFFSET_FX, tmp_e1 ) ), L_sub( ONE_IN_Q15, VERTICAL_ENERGY_RATIO_OFFSET_FX ), &tmp_e2 ); /* Tuned to avoid effect due to ambience of vertically un-even setups */
- tmp_e2 = add( tmp_e2, tmp_e1 );
- tmp = L_sub( L_shl( 1, sub( 15, tmp_e2 ) ), tmp );
- IF( tmp < 0 )
+ IF( tmp != 0 )
{
- tmp = 0;
- move32();
+ tmp_e1 = add( tmp_e1, sub( intensity_slow_e[i], energy_slow_e[i] ) );
+ tmp = BASOP_Util_Divide3232_Scale( L_sub( tmp, L_shr( VERTICAL_ENERGY_RATIO_OFFSET_FX, tmp_e1 ) ), L_sub( ONE_IN_Q15, VERTICAL_ENERGY_RATIO_OFFSET_FX ), &tmp_e2 ); /* Tuned to avoid effect due to ambience of vertically un-even setups */
+ tmp_e2 = add( tmp_e2, tmp_e1 );
+ tmp = L_sub( L_shl( 1, sub( 15, tmp_e2 ) ), tmp );
+ IF( tmp < 0 )
+ {
+ tmp = 0;
+ move32();
+ }
+ ELSE IF( GE_32( tmp, L_shl( 1, sub( 15, tmp_e2 ) ) ) )
+ {
+ tmp = ONE_IN_Q31; // Q31
+ move32();
+ }
+ ELSE
+ {
+ tmp = L_shl( tmp, add( 16, tmp_e2 ) ); // Q31
+ }
}
- ELSE IF( GE_32( tmp, L_shl( 1, sub( 15, tmp_e2 ) ) ) )
+ ELSE
{
tmp = ONE_IN_Q31; // Q31
move32();
}
- ELSE
- {
- tmp = L_shl( tmp, add( 16, tmp_e2 ) ); // Q31
- }
+
diffuseness[i] = tmp; // Q31
move32();
}
diff --git a/lib_rend/ivas_objectRenderer_hrFilt_fx.c b/lib_rend/ivas_objectRenderer_hrFilt_fx.c
index 30bf8f00aaac87f2bbee5753662ab91eea5e3ad1..a098aaa25e23a3567661fc4be6bca4f218a72e59 100644
--- a/lib_rend/ivas_objectRenderer_hrFilt_fx.c
+++ b/lib_rend/ivas_objectRenderer_hrFilt_fx.c
@@ -97,7 +97,7 @@ ivas_error TDREND_REND_RenderSourceHRFilt_fx(
TDREND_firfilt_fx( RightOutputFrame_fx, Src_p->hrf_right_prev_fx, right_filter_e, hrf_right_delta_fx, intp_count, Src_p->mem_hrf_right_fx, subframe_length, Src_p->filterlength, Src_p->Gain_fx, Src_p->prevGain_fx );
Src_p->prevGain_fx = Src_p->Gain_fx;
- move16();
+ move32();
/* Copy to accumulative output frame */
v_add_32( LeftOutputFrame_fx, output_buf_fx[0], output_buf_fx[0], subframe_length ); // Same Q as Src_p->InputFrame_p_fx Q11
diff --git a/lib_rend/ivas_objectRenderer_sfx_fx.c b/lib_rend/ivas_objectRenderer_sfx_fx.c
index 210706d5be5ff42adb52c59029465e96f58dfdcf..a570273cfcc46e92c17c4184d7d7904307a02e53 100644
--- a/lib_rend/ivas_objectRenderer_sfx_fx.c
+++ b/lib_rend/ivas_objectRenderer_sfx_fx.c
@@ -278,8 +278,8 @@ void TDREND_firfilt_fx(
Word32 *mem_fx, /* i/o: filter memory Qx */
const Word16 subframe_length, /* i : Length of signal Q0 */
const Word16 filterlength, /* i : Filter length Q0 */
- const Word16 Gain_fx, /* i : Gain Q14 */
- const Word16 prevGain_fx /* i : Previous gain Q14 */
+ const Word32 Gain_fx, /* i : Gain Q30 */
+ const Word32 prevGain_fx /* i : Previous gain Q30 */
)
{
/* NOTE: this function is implemented with the assumption that the exponent/Q-factor of input signal will not change. */
@@ -289,15 +289,15 @@ void TDREND_firfilt_fx(
Word32 *p_filter_fx; // exp(filter_e)
Word16 i, j;
Word32 tmp_fx;
- Word16 step_fx /* Q15 */, gain_tmp_fx /* Q15 */, gain_delta_fx /* Q14 */;
+ Word32 step_fx /* Q31 */, gain_tmp_fx /* Q31 */, gain_delta_fx /* Q30 */;
Word16 tmp_e;
Word64 tmp64_fx;
- gain_delta_fx = sub( Gain_fx, prevGain_fx ); // Q14
- step_fx = BASOP_Util_Divide1616_Scale( gain_delta_fx, subframe_length, &tmp_e ); // exp(tmp_e)
- tmp_e = sub( tmp_e, Q14 );
- step_fx = shl_sat( step_fx, tmp_e ); // Q15
- gain_tmp_fx = shl_sat( prevGain_fx, 1 ); // Q15
+ gain_delta_fx = L_sub( Gain_fx, prevGain_fx ); // Q30
+ step_fx = L_deposit_h( BASOP_Util_Divide3232_Scale( gain_delta_fx, subframe_length, &tmp_e ) ); // exp(tmp_e)
+ tmp_e = sub( tmp_e, Q30 );
+ step_fx = L_shl_sat( step_fx, tmp_e ); // Q31
+ gain_tmp_fx = L_shl_sat( prevGain_fx, 1 ); // Q31
/* Handle memory */
p_signal_fx = buffer_fx + sub( filterlength, 1 ); // Qx
@@ -328,8 +328,8 @@ void TDREND_firfilt_fx(
tmp_fx = W_extract_h( tmp64_fx ); // Qx
/* Apply linear gain interpolation in case of abrupt gain changes */
- gain_tmp_fx = add( gain_tmp_fx, step_fx ); // Q15
- signal_fx[i] = Mpy_32_16_1( tmp_fx, gain_tmp_fx ); // Qx
+ gain_tmp_fx = L_add_sat( gain_tmp_fx, step_fx ); /* Saturating values which just exceeds 1, Q31*/
+ signal_fx[i] = Mpy_32_32( tmp_fx, gain_tmp_fx ); // Qx
move32();
IF( LT_16( i, intp_count ) )
{
diff --git a/lib_rend/ivas_objectRenderer_sources_fx.c b/lib_rend/ivas_objectRenderer_sources_fx.c
index 7e35b80b2c0c2eefa628c9266a19555fd25ca8cc..cdb2d98472c9f750d7d0e189b1a1a1febf2cf4a8 100644
--- a/lib_rend/ivas_objectRenderer_sources_fx.c
+++ b/lib_rend/ivas_objectRenderer_sources_fx.c
@@ -275,8 +275,8 @@ void TDREND_SRC_REND_UpdateFiltersFromSpatialParams_fx(
/* o : Length of filters */ // Q0
Word16 *itd,
/* o : ITD value */ // Q0
- Word16 *Gain,
- /* o : Gain value */ // Q14
+ Word32 *Gain,
+ /* o : Gain value */ // Q30
TDREND_SRC_t *Src_p, /* i/o: Source pointer */
const Word16 subframe_update_flag )
{
@@ -368,8 +368,8 @@ void TDREND_SRC_REND_UpdateFiltersFromSpatialParams_fx(
/* Update total gains */
- *Gain = extract_h( L_shl( Mpy_32_32( L_shl( L_mult( *SrcRend_p->SrcGain_p_fx, *SrcRend_p->DirGain_p_fx ), 1 ), L_shl( L_mult( *SrcRend_p->DistGain_p_fx, hBinRendererTd->Gain_fx ), 1 ) ), 1 ) ); // Q14
- move16();
+ *Gain = L_shl( Mpy_32_32( L_shl( L_mult( *SrcRend_p->SrcGain_p_fx, *SrcRend_p->DirGain_p_fx ), 1 ), L_shl( L_mult( *SrcRend_p->DistGain_p_fx, hBinRendererTd->Gain_fx ), 1 ) ), 1 ); // Q30
+ move32();
/* Delta for interpolation, in case the angular step exceeds MAX_ANGULAR_STEP */
Word32 ele_tmp = Src_p->elev_prev_fx; // Q22
move32();
@@ -417,8 +417,8 @@ void TDREND_SRC_REND_UpdateFiltersFromSpatialParams_fx(
{
*itd = 0; // Q0
move16();
- *Gain = ONE_IN_Q14; // Q14
- move16();
+ *Gain = ONE_IN_Q30; // Q30
+ move32();
set32_fx( hrf_left, 0, *filterlength );
set32_fx( hrf_right, 0, *filterlength );
hrf_left[0] = L_shr( L_add( SrcSpatial_p->Pos_p_fx[1], ONE_IN_Q25 ), 1 ); // Q25
@@ -886,9 +886,9 @@ void TDREND_SRC_Init_fx(
move32();
Src_p->elev_prev_fx = 0; // Q22
move32();
- Src_p->Gain_fx = ONE_IN_Q14; // Q14
- move16();
- Src_p->prevGain_fx = ONE_IN_Q14; // Q14
- move16();
+ Src_p->Gain_fx = ONE_IN_Q30; // Q30
+ move32();
+ Src_p->prevGain_fx = ONE_IN_Q30; // Q30
+ move32();
return;
}
diff --git a/lib_rend/ivas_omasa_ana_fx.c b/lib_rend/ivas_omasa_ana_fx.c
index 7b7f64c842dd0f57b94045da2fcdc29a554dd933..84f1ff3dcd1f755a3d39848d7bb8d58a56f5f54c 100644
--- a/lib_rend/ivas_omasa_ana_fx.c
+++ b/lib_rend/ivas_omasa_ana_fx.c
@@ -41,7 +41,6 @@
#include "ivas_rom_com.h"
#include "wmc_auto.h"
-
/*-------------------------------------------------------------------------
* Local function prototypes
*------------------------------------------------------------------------*/
@@ -159,6 +158,19 @@ ivas_error ivas_omasa_ana_open(
}
set_zero_fx( hOMasa->direction_vector_m_fx[i][j], MASA_FREQUENCY_BANDS );
}
+ IF( ( hOMasa->direction_vector_e[i] = (Word16 **) malloc( MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( Word16 * ) ) ) == NULL )
+ {
+ return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for OMASA data\n" ) );
+ }
+
+ FOR( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ )
+ {
+ IF( ( hOMasa->direction_vector_e[i][j] = (Word16 *) malloc( MASA_FREQUENCY_BANDS * sizeof( Word16 ) ) ) == NULL )
+ {
+ return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for OMASA data\n" ) );
+ }
+ set16_fx( hOMasa->direction_vector_e[i][j], 0, MASA_FREQUENCY_BANDS );
+ }
}
FOR( i = 0; i < DIRAC_NUM_DIMS; i++ )
@@ -172,7 +184,8 @@ ivas_error ivas_omasa_ana_open(
set_zero_fx( hOMasa->buffer_intensity_real_fx[i][j], MASA_FREQUENCY_BANDS );
}
}
-
+ set16_fx( hOMasa->buffer_intensity_real_q, 31, DIRAC_NO_COL_AVG_DIFF );
+ set16_fx( hOMasa->buffer_energy_q, 31, DIRAC_NO_COL_AVG_DIFF );
set_zero_fx( hOMasa->buffer_energy_fx, DIRAC_NO_COL_AVG_DIFF * MASA_FREQUENCY_BANDS );
FOR( i = 0; i < MAX_NUM_OBJECTS; i++ )
@@ -249,6 +262,12 @@ void ivas_omasa_ana_close(
( *hOMasa )->direction_vector_m_fx[i][j] = NULL;
}
+ FOR( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ )
+ {
+ free( ( *hOMasa )->direction_vector_e[i][j] );
+ ( *hOMasa )->direction_vector_e[i][j] = NULL;
+ }
+
FOR( j = 0; j < DIRAC_NO_COL_AVG_DIFF; j++ )
{
free( ( *hOMasa )->buffer_intensity_real_fx[i][j] );
@@ -257,6 +276,9 @@ void ivas_omasa_ana_close(
free( ( *hOMasa )->direction_vector_m_fx[i] );
( *hOMasa )->direction_vector_m_fx[i] = NULL;
+
+ free( ( *hOMasa )->direction_vector_e[i] );
+ ( *hOMasa )->direction_vector_e[i] = NULL;
}
free( ( *hOMasa )->hMasaOut );
@@ -297,11 +319,11 @@ void ivas_omasa_ana_fx(
ivas_omasa_param_est_ana_fx( hOMasa, data_in_f_fx, *data_in_q, elevation_m_values_fx, azimuth_m_values_fx, energyRatio_fx, &energyRatio_q, spreadCoherence_fx, &spreadCoherence_q, surroundingCoherence_fx, &sorroundingCoherence_q, input_frame, nchan_ism );
/* Create MASA metadata buffer from the estimated values */
-
- ivas_create_masa_out_meta_fx( hOMasa->hMasaOut, hOMasa->sph_grid16, nchan_transport, elevation_m_values_fx, azimuth_m_values_fx, energyRatio_fx, spreadCoherence_fx, surroundingCoherence_fx, energyRatio_q, spreadCoherence_q, sorroundingCoherence_q );
+ ivas_create_masa_out_meta_fx( hOMasa->hMasaOut, hOMasa->sph_grid16, nchan_transport, elevation_m_values_fx, azimuth_m_values_fx, energyRatio_fx, spreadCoherence_fx, surroundingCoherence_fx, Q31, Q31, Q31 );
/* Downmix */
ivas_omasa_dmx_fx( data_in_f_fx, data_in_q, input_frame, nchan_transport, nchan_ism, hOMasa->ism_azimuth_fx, hOMasa->ism_elevation_fx, hOMasa->prev_object_dm_gains_fx, hOMasa->interpolator_fx );
+
return;
}
@@ -332,7 +354,7 @@ static void ivas_omasa_param_est_ana_fx(
Word16 num_freq_bins, num_freq_bands, index;
Word16 l_ts;
- Word32 reference_power_fx[MASA_FREQUENCY_BANDS];
+ Word32 reference_power_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
Word32 Chnl_RealBuffer_fx[MAX_NUM_OBJECTS][CLDFB_NO_CHANNELS_MAX];
Word16 Chnl_RealBuffer_q[MAX_NUM_OBJECTS];
Word16 Chnl_ImagBuffer_q[MAX_NUM_OBJECTS];
@@ -344,20 +366,15 @@ static void ivas_omasa_param_est_ana_fx(
Word32 diffuseness_vector_fx[MASA_FREQUENCY_BANDS];
Word16 diffuseness_q = 0;
move16();
+ Word16 diffuseness_e[MASA_FREQUENCY_BANDS];
Word32 diffuseness_m_fx[MASA_FREQUENCY_BANDS];
- Word16 diffuseness_m_q = 0;
- move16();
+
Word32 renormalization_factor_diff_fx[MASA_FREQUENCY_BANDS];
- Word16 renormalization_factor_diff_q = 0;
- move16();
+ Word16 renormalization_factor_diff_e[MASA_FREQUENCY_BANDS];
Word32 norm_tmp_fx;
- Word16 scale;
- Word16 tmp_ener_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];
-
- Word32 dir_v_fx[DIRAC_NUM_DIMS], L_tmp1, L_tmp2;
- Word16 dir_v_q, norm_tmp_q;
- Word16 foa_q;
+ Word32 dir_v_fx[DIRAC_NUM_DIMS] /*, L_tmp1, L_tmp2*/;
+ Word16 dir_v_q /*, norm_tmp_q*/;
Word16 band_m_idx, block_m_idx;
Word16 mrange[2];
@@ -367,13 +384,10 @@ static void ivas_omasa_param_est_ana_fx(
move16();
num_freq_bands = hOMasa->nbands;
move16();
-
- // l_ts = input_frame / CLDFB_NO_COL_MAX;
l_ts = shr( input_frame, 4 );
- move16();
Word16 intensity_q;
- Word16 direction_q, reference_power_q;
+ Word16 reference_power_q;
set16_zero_fx( Chnl_RealBuffer_q, MAX_NUM_OBJECTS );
set16_zero_fx( Chnl_ImagBuffer_q, MAX_NUM_OBJECTS );
@@ -381,37 +395,14 @@ static void ivas_omasa_param_est_ana_fx(
/* Compute ISM to FOA matrices */
FOR( i = 0; i < nchan_ism; i++ )
{
- Word16 tmp, tmp1;
- // 180 in Q22 754974720
- hOMasa->chnlToFoaMtx_fx[0][i] = 32767; // 1 in Q15
- move16();
-
- tmp = BASOP_Util_Divide3232_Scale( hOMasa->ism_azimuth_fx[i], 754974720, &scale );
- tmp = mult( tmp, EVS_PI_FX ); // Q13 + Q15 - Q15 --> Q13
- tmp = getSinWord16( tmp ); // Q15 sine value
-
- tmp1 = BASOP_Util_Divide3232_Scale( hOMasa->ism_elevation_fx[i], 754974720, &scale );
- tmp1 = mult( tmp1, EVS_PI_FX );
- tmp1 = getCosWord16( tmp1 );
- hOMasa->chnlToFoaMtx_fx[1][i] = shl( mult( tmp, tmp1 ), 1 ); // Q14 + Q15 - Q15 + Q1 -> Q15
- move16();
-
- tmp = BASOP_Util_Divide3232_Scale( hOMasa->ism_elevation_fx[i], 754974720, &scale );
- tmp = mult( tmp, EVS_PI_FX ); // Q13 + Q15 - Q15 --> Q13
- hOMasa->chnlToFoaMtx_fx[2][i] = getSinWord16( tmp ); // Q15
- move16();
-
- tmp = BASOP_Util_Divide3232_Scale( hOMasa->ism_azimuth_fx[i], 754974720, &scale );
- tmp = mult( tmp, EVS_PI_FX ); // Q13 + Q15 - Q15 --> Q13
- tmp = getCosWord16( tmp ); // Q14
-
-
- tmp1 = BASOP_Util_Divide3232_Scale( hOMasa->ism_elevation_fx[i], 754974720, &scale );
- tmp1 = mult( tmp, EVS_PI_FX ); // Q13 + Q15 - Q15 --> Q13
- tmp1 = getCosWord16( tmp ); // Q14
-
- hOMasa->chnlToFoaMtx_fx[3][i] = shl( mult( tmp, tmp1 ), 2 ); // Q14 + Q14 - Q15 + Q2-> Q13 + Q2 -> Q15
- move16();
+ hOMasa->chnlToFoaMtx_fx[0][i] = ONE_IN_Q31;
+ move32();
+ hOMasa->chnlToFoaMtx_fx[1][i] = L_mult( getSineWord16R2( extract_l( Mpy_32_32( hOMasa->ism_azimuth_fx[i], 46603 /*32767/360*/ ) /*Q22+Q24-31=>Q15*/ ) ), getCosWord16R2( extract_l( Mpy_32_32( hOMasa->ism_elevation_fx[i], 46603 /*2^24/360*/ ) ) ) ); // Q31
+ move32();
+ hOMasa->chnlToFoaMtx_fx[2][i] = L_shl( getSineWord16R2( extract_l( Mpy_32_32( hOMasa->ism_elevation_fx[i], 46603 /*2^24/360*/ ) ) ), 16 ); // Q31
+ move32();
+ hOMasa->chnlToFoaMtx_fx[3][i] = L_mult( getCosWord16R2( extract_l( Mpy_32_32( hOMasa->ism_azimuth_fx[i], 46603 /*2^24/360*/ ) ) ), getCosWord16R2( extract_l( Mpy_32_32( hOMasa->ism_elevation_fx[i], 46603 /*2^24/360*/ ) ) ) ); // Q31
+ move32();
}
/* do processing over all CLDFB time slots */
@@ -430,75 +421,47 @@ static void ivas_omasa_param_est_ana_fx(
move32();
hOMasa->direction_vector_m_fx[2][block_m_idx][band_m_idx] = 0;
move32();
+
+ hOMasa->direction_vector_e[0][block_m_idx][band_m_idx] = 0;
+ move16();
+ hOMasa->direction_vector_e[1][block_m_idx][band_m_idx] = 0;
+ move16();
+ hOMasa->direction_vector_e[2][block_m_idx][band_m_idx] = 0;
+ move16();
}
/* Need to initialize renormalization_factors, and variables to be normalized */
set_zero_fx( renormalization_factor_diff_fx, hOMasa->nbands );
+ set16_fx( renormalization_factor_diff_e, 0, hOMasa->nbands );
set_zero_fx( diffuseness_m_fx, hOMasa->nbands );
+ set16_fx( diffuseness_e, 0, hOMasa->nbands );
set_zero_fx( hOMasa->energy_fx[block_m_idx], MASA_FREQUENCY_BANDS );
-
- set16_fx( tmp_ener_e[block_m_idx], 0, MASA_FREQUENCY_BANDS );
+ set16_fx( hOMasa->energy_e[block_m_idx], 0, MASA_FREQUENCY_BANDS );
FOR( ts = mrange[0]; ts < mrange[1]; ts++ )
{
+ Word16 cr_q = MAX_16, ci_q = MAX_16, sf, c_e;
+ move16();
+ move16();
+ Word16 inp_q = data_f_q;
+ move16();
FOR( i = 0; i < nchan_ism; i++ )
{
- Word16 in_q = Q11;
- move16();
+ inp_q = data_f_q;
+ cldfbAnalysis_ts_fx_var_q( &( data_f_fx[i][i_mult( l_ts, ts )] ), Chnl_RealBuffer_fx[i], Chnl_ImagBuffer_fx[i], l_ts, hOMasa->cldfbAnaEnc[i], &inp_q );
- /* Keep input to cldfbAnalysis_ts_fx in Q11 */
- IF( NE_16( in_q, data_f_q ) )
- {
- scale_sig32( &( data_f_fx[i][i_mult( l_ts, ts )] ), l_ts, sub( in_q, data_f_q ) ); /* Q11 */
- }
-
- cldfbAnalysis_ts_fx( &( data_f_fx[i][i_mult( l_ts, ts )] ), Chnl_RealBuffer_fx[i], Chnl_ImagBuffer_fx[i], l_ts, hOMasa->cldfbAnaEnc[i], &in_q );
-
- /* Restore data_f_fx to it's original Q */
- IF( NE_16( data_f_q, Q11 ) )
- {
- scale_sig32( &( data_f_fx[i][i_mult( l_ts, ts )] ), l_ts, sub( data_f_q, Q11 ) ); /* Q(data_f_q) */
- }
-
- FOR( Word16 ind = 0; ind < CLDFB_NO_CHANNELS_MAX; ind++ )
- {
- Chnl_RealBuffer_fx[i][ind] = L_shr( Chnl_RealBuffer_fx[i][ind], 4 ); // Q: in_q - 4
- move32();
- Chnl_ImagBuffer_fx[i][ind] = L_shr( Chnl_ImagBuffer_fx[i][ind], 4 ); // Q: in_q - 4
- move32();
- }
-
- Chnl_RealBuffer_q[i] = sub( in_q, 4 );
- move16();
- Chnl_ImagBuffer_q[i] = sub( in_q, 4 );
- move16();
+ cr_q = s_min( cr_q, L_norm_arr( Chnl_ImagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX ) );
+ ci_q = s_min( ci_q, L_norm_arr( Chnl_RealBuffer_fx[i], CLDFB_NO_CHANNELS_MAX ) );
}
-
- IF( GT_16( nchan_ism, 1 ) )
+ sf = sub( s_min( cr_q, ci_q ), 4 );
+ FOR( i = 0; i < nchan_ism; i++ )
{
- Word16 anaBuf_com_q;
- minimum_fx( Chnl_RealBuffer_q, nchan_ism, &anaBuf_com_q );
-
- FOR( i = 0; i < nchan_ism; i++ )
- {
- IF( NE_16( anaBuf_com_q, Chnl_RealBuffer_q[i] ) )
- {
- FOR( Word16 ind = 0; ind < CLDFB_NO_CHANNELS_MAX; ind++ )
- {
- Chnl_RealBuffer_fx[i][ind] = L_shr( Chnl_RealBuffer_fx[i][ind], sub( Chnl_RealBuffer_q[i], anaBuf_com_q ) ); // Q: anaBuf_com_q
- move32();
- Chnl_ImagBuffer_fx[i][ind] = L_shr( Chnl_ImagBuffer_fx[i][ind], sub( Chnl_ImagBuffer_q[i], anaBuf_com_q ) ); // Q: anaBuf_com_q
- move32();
- }
- Chnl_ImagBuffer_q[i] = anaBuf_com_q;
- move16();
- Chnl_RealBuffer_q[i] = anaBuf_com_q;
- move16();
- }
- }
+ scale_sig32( Chnl_RealBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, sf ); // Q-> inp_q + sf
+ scale_sig32( Chnl_ImagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, sf ); // Q-> inp_q + sf
}
-
+ inp_q = add( inp_q, sf );
+ c_e = sub( 31, inp_q );
/* Compute channel-based energy for metadata processing */
FOR( band_m_idx = 0; band_m_idx < num_freq_bands; band_m_idx++ )
@@ -511,20 +474,8 @@ static void ivas_omasa_param_est_ana_fx(
{
FOR( i = 0; i < nchan_ism; i++ )
{
- Word16 tmp_e, tmp_r_q, tmp_i_q;
- Word32 tmp_r, tmp_i, L_tmp_sum;
- tmp_r_q = norm_l( Chnl_RealBuffer_fx[i][j] );
- tmp_r = L_shl( Chnl_RealBuffer_fx[i][j], tmp_r_q ); /* Q(Chnl_RealBuffer_q[i] + tmp_r_q) */
- tmp_r_q = add( tmp_r_q, Chnl_RealBuffer_q[i] );
- L_tmp1 = Mpy_32_32( tmp_r, tmp_r ); /* Q(2*tmp_r_q - 31)*/
- tmp_r_q = sub( add( tmp_r_q, tmp_r_q ), 31 );
- tmp_i_q = norm_l( Chnl_ImagBuffer_fx[i][j] );
- tmp_i = L_shl( Chnl_ImagBuffer_fx[i][j], tmp_i_q ); /* Q(Chnl_ImagBuffer_q[i] + tmp_i_q)*/
- tmp_i_q = add( tmp_i_q, Chnl_ImagBuffer_q[i] );
- tmp_i_q = sub( add( tmp_i_q, tmp_i_q ), 31 );
- L_tmp2 = Mpy_32_32( tmp_i, tmp_i ); /* Q(2*tmp_i_q - 31) */
- L_tmp_sum = BASOP_Util_Add_Mant32Exp( L_tmp1, sub( 31, tmp_r_q ), L_tmp2, sub( 31, tmp_i_q ), &tmp_e ); /* Q(31 - tmp_e) */
- hOMasa->energy_fx[block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hOMasa->energy_fx[block_m_idx][band_m_idx], tmp_ener_e[block_m_idx][band_m_idx], L_tmp_sum, tmp_e, &tmp_ener_e[block_m_idx][band_m_idx] ); /* Q(31 - tmp_ener_e[block_m_idx][band_m_idx]) */
+ Word32 temp = L_add( Mult_32_32( Chnl_RealBuffer_fx[i][j], Chnl_RealBuffer_fx[i][j] ), Mult_32_32( Chnl_ImagBuffer_fx[i][j], Chnl_ImagBuffer_fx[i][j] ) ); // Q-> 2*inp_q - 31, e = 31 - (2*inp_q - 31) = 62 - 2*inp_q = 2*(31 - inp_q) = 2*c_e
+ hOMasa->energy_fx[block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hOMasa->energy_fx[block_m_idx][band_m_idx], hOMasa->energy_e[block_m_idx][band_m_idx], temp, shl( c_e, 1 ), &hOMasa->energy_e[block_m_idx][band_m_idx] );
move32();
}
}
@@ -533,8 +484,8 @@ static void ivas_omasa_param_est_ana_fx(
/* Compute FOA */
/* W */
- Copy32( Chnl_RealBuffer_fx[0], Foa_RealBuffer_fx[0], num_freq_bins );
- Copy32( Chnl_ImagBuffer_fx[0], Foa_ImagBuffer_fx[0], num_freq_bins );
+ Copy32( Chnl_RealBuffer_fx[0], Foa_RealBuffer_fx[0], num_freq_bins ); // inp_q
+ Copy32( Chnl_ImagBuffer_fx[0], Foa_ImagBuffer_fx[0], num_freq_bins ); // inp_q
FOR( i = 1; i < nchan_ism; i++ )
{
@@ -549,59 +500,42 @@ static void ivas_omasa_param_est_ana_fx(
/* Y */
- v_multc_fixed( Chnl_RealBuffer_fx[0], L_deposit_h( hOMasa->chnlToFoaMtx_fx[1][0] ), Foa_RealBuffer_fx[1], num_freq_bins ); // Q: Chnl_RealBuffer_q
- v_multc_fixed( Chnl_ImagBuffer_fx[0], L_deposit_h( hOMasa->chnlToFoaMtx_fx[1][0] ), Foa_ImagBuffer_fx[1], num_freq_bins ); // Q: Chnl_ImagBuffer_q
+ v_multc_fixed( Chnl_RealBuffer_fx[0], hOMasa->chnlToFoaMtx_fx[1][0], Foa_RealBuffer_fx[1], num_freq_bins ); // Q: Chnl_RealBuffer_q
+ v_multc_fixed( Chnl_ImagBuffer_fx[0], hOMasa->chnlToFoaMtx_fx[1][0], Foa_ImagBuffer_fx[1], num_freq_bins ); // Q: Chnl_ImagBuffer_q
FOR( i = 1; i < nchan_ism; i++ )
{
- v_multc_acc_32_16( Chnl_RealBuffer_fx[i], hOMasa->chnlToFoaMtx_fx[1][i], Foa_RealBuffer_fx[1], num_freq_bins ); // Q: Chnl_RealBuffer_q
- v_multc_acc_32_16( Chnl_ImagBuffer_fx[i], hOMasa->chnlToFoaMtx_fx[1][i], Foa_ImagBuffer_fx[1], num_freq_bins ); // Q: Chnl_ImagBuffer_q
+ v_multc_acc_32_32( Chnl_RealBuffer_fx[i], hOMasa->chnlToFoaMtx_fx[1][i], Foa_RealBuffer_fx[1], num_freq_bins ); // Q: Chnl_RealBuffer_q
+ v_multc_acc_32_32( Chnl_ImagBuffer_fx[i], hOMasa->chnlToFoaMtx_fx[1][i], Foa_ImagBuffer_fx[1], num_freq_bins ); // Q: Chnl_ImagBuffer_q
}
/* Z */
- v_multc_fixed( Chnl_RealBuffer_fx[0], L_deposit_h( hOMasa->chnlToFoaMtx_fx[2][0] ), Foa_RealBuffer_fx[2], num_freq_bins ); // Q: Chnl_RealBuffer_q
- v_multc_fixed( Chnl_ImagBuffer_fx[0], L_deposit_h( hOMasa->chnlToFoaMtx_fx[2][0] ), Foa_ImagBuffer_fx[2], num_freq_bins ); // Q: Chnl_ImagBuffer_q
+ v_multc_fixed( Chnl_RealBuffer_fx[0], hOMasa->chnlToFoaMtx_fx[2][0], Foa_RealBuffer_fx[2], num_freq_bins ); // Q: Chnl_RealBuffer_q
+ v_multc_fixed( Chnl_ImagBuffer_fx[0], hOMasa->chnlToFoaMtx_fx[2][0], Foa_ImagBuffer_fx[2], num_freq_bins ); // Q: Chnl_ImagBuffer_q
FOR( i = 1; i < nchan_ism; i++ )
{
- v_multc_acc_32_16( Chnl_RealBuffer_fx[i], hOMasa->chnlToFoaMtx_fx[2][i], Foa_RealBuffer_fx[2], num_freq_bins ); // Q: Chnl_RealBuffer_q
- v_multc_acc_32_16( Chnl_ImagBuffer_fx[i], hOMasa->chnlToFoaMtx_fx[2][i], Foa_ImagBuffer_fx[2], num_freq_bins ); // Q: Chnl_ImagBuffer_q
+ v_multc_acc_32_32( Chnl_RealBuffer_fx[i], hOMasa->chnlToFoaMtx_fx[2][i], Foa_RealBuffer_fx[2], num_freq_bins ); // Q: Chnl_RealBuffer_q
+ v_multc_acc_32_32( Chnl_ImagBuffer_fx[i], hOMasa->chnlToFoaMtx_fx[2][i], Foa_ImagBuffer_fx[2], num_freq_bins ); // Q: Chnl_ImagBuffer_q
}
- v_multc_fixed( Chnl_RealBuffer_fx[0], L_deposit_h( hOMasa->chnlToFoaMtx_fx[3][0] ), Foa_RealBuffer_fx[2], num_freq_bins ); // Q: Chnl_RealBuffer_q
- v_multc_fixed( Chnl_ImagBuffer_fx[0], L_deposit_h( hOMasa->chnlToFoaMtx_fx[3][0] ), Foa_ImagBuffer_fx[2], num_freq_bins ); // Q: Chnl_ImagBuffer_q
+ v_multc_fixed( Chnl_RealBuffer_fx[0], hOMasa->chnlToFoaMtx_fx[3][0], Foa_RealBuffer_fx[3], num_freq_bins ); // Q: Chnl_RealBuffer_q
+ v_multc_fixed( Chnl_ImagBuffer_fx[0], hOMasa->chnlToFoaMtx_fx[3][0], Foa_ImagBuffer_fx[3], num_freq_bins ); // Q: Chnl_ImagBuffer_q
FOR( i = 1; i < nchan_ism; i++ )
{
- v_multc_acc_32_16( Chnl_RealBuffer_fx[i], hOMasa->chnlToFoaMtx_fx[3][i], Foa_RealBuffer_fx[3], num_freq_bins ); // Q: Chnl_RealBuffer_q
- v_multc_acc_32_16( Chnl_ImagBuffer_fx[i], hOMasa->chnlToFoaMtx_fx[3][i], Foa_ImagBuffer_fx[3], num_freq_bins ); // Q: Chnl_ImagBuffer_q
+ v_multc_acc_32_32( Chnl_RealBuffer_fx[i], hOMasa->chnlToFoaMtx_fx[3][i], Foa_RealBuffer_fx[3], num_freq_bins ); // Q: Chnl_RealBuffer_q
+ v_multc_acc_32_32( Chnl_ImagBuffer_fx[i], hOMasa->chnlToFoaMtx_fx[3][i], Foa_ImagBuffer_fx[3], num_freq_bins ); // Q: Chnl_ImagBuffer_q
}
+ computeIntensityVector_ana_fx( hOMasa->band_grouping, Foa_RealBuffer_fx, Foa_ImagBuffer_fx, num_freq_bands, intensity_real_fx ); /* Q intensity_real_fx = 2*inp_q-31, e = 31 - 2*inp_q + 31 = 62 - 2*inp_q = 2*(31-inp_q)=2*c_e */
+ intensity_q = sub( 31, shl( c_e, 1 ) );
- /* Direction estimation */
- FOR( i = 0; i < FOA_CHANNELS; i++ )
- {
- FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ )
- {
- Foa_RealBuffer_fx[i][j] = L_shr( Foa_RealBuffer_fx[i][j], 5 ); // Q: ( Chnl_RealBuffer_q - 5 )
- move32();
- Foa_ImagBuffer_fx[i][j] = L_shr( Foa_ImagBuffer_fx[i][j], 5 ); // Q: ( Chnl_RealBuffer_q - 5 )
- move32();
- }
- }
- foa_q = sub( Chnl_ImagBuffer_q[0], 5 );
- computeIntensityVector_ana_fx( hOMasa->band_grouping, Foa_RealBuffer_fx, Foa_ImagBuffer_fx, num_freq_bands, intensity_real_fx );
-
- intensity_q = sub( shl( add( foa_q, Q1 ), 1 ), 31 );
- direction_q = intensity_q;
- move16();
-
- computeDirectionVectors_fx( 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], &direction_q );
-
+ computeDirectionVectors_fixed( intensity_real_fx[0], intensity_real_fx[1], intensity_real_fx[2], 0, num_freq_bands, direction_vector_fx[0], direction_vector_fx[1], direction_vector_fx[2], shl( c_e, 1 ), NULL ); /* Q direction_vector_fx = Q30*/
/* Power estimation for diffuseness */
- computeReferencePower_ana_fx( hOMasa->band_grouping, Foa_RealBuffer_fx, Foa_ImagBuffer_fx, reference_power_fx, num_freq_bands ); // 2 * inputq - 30
- reference_power_q = sub( shl( Chnl_ImagBuffer_q[0], 1 ), 30 );
+ computeReferencePower_ana_fx( hOMasa->band_grouping, Foa_RealBuffer_fx, Foa_ImagBuffer_fx, reference_power_fx[ts], num_freq_bands ); // 2 * inputq - 30
+ reference_power_q = sub( shl( inp_q, 1 ), 30 );
/* Fill buffers of length "averaging_length" time slots for intensity and energy */
hOMasa->index_buffer_intensity = add( ( hOMasa->index_buffer_intensity % DIRAC_NO_COL_AVG_DIFF ), 1 ); /* averaging_length = 32 */
@@ -616,68 +550,58 @@ static void ivas_omasa_param_est_ana_fx(
}
hOMasa->buffer_intensity_real_q[index - 1] = intensity_q;
move16();
- Copy32( reference_power_fx, &( hOMasa->buffer_energy_fx[( index - 1 ) * num_freq_bands] ), num_freq_bands );
+ Copy32( reference_power_fx[ts], &( hOMasa->buffer_energy_fx[( index - 1 ) * num_freq_bands] ), num_freq_bands );
hOMasa->buffer_energy_q[index - 1] = reference_power_q;
move16();
- computeDiffuseness_fixed( hOMasa->buffer_intensity_real_fx, hOMasa->buffer_energy_fx, num_freq_bands, diffuseness_vector_fx, hOMasa->buffer_intensity_real_q, hOMasa->buffer_energy_q, &diffuseness_q );
+ computeDiffuseness_fixed( hOMasa->buffer_intensity_real_fx, hOMasa->buffer_energy_fx, num_freq_bands, diffuseness_vector_fx, hOMasa->buffer_intensity_real_q, hOMasa->buffer_energy_q, &diffuseness_q ); // diffuseness_q=Q30
FOR( band_m_idx = 0; band_m_idx < hOMasa->nbands; band_m_idx++ )
{
- norm_tmp_fx = Mpy_32_32( reference_power_fx[band_m_idx], L_sub( ONE_IN_Q30, diffuseness_vector_fx[band_m_idx] ) ); // reference_power_q + 30 - 31
- norm_tmp_q = sub( add( reference_power_q, 30 ), 31 );
-
- hOMasa->direction_vector_m_fx[0][block_m_idx][band_m_idx] = L_add( hOMasa->direction_vector_m_fx[0][block_m_idx][band_m_idx], Mpy_32_32( norm_tmp_fx, direction_vector_fx[0][band_m_idx] ) ); // Q: hOMasa->direction_vector_m_q: ( ( norm_tmp_q + direction_q ) - 31 )
+ norm_tmp_fx = L_shl( Mult_32_32( reference_power_fx[ts][band_m_idx], L_sub( ONE_IN_Q30, diffuseness_vector_fx[band_m_idx] ) ), 1 ); /*2*inp_q-30*/
+ hOMasa->direction_vector_m_fx[0][block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hOMasa->direction_vector_m_fx[0][block_m_idx][band_m_idx], hOMasa->direction_vector_e[0][block_m_idx][band_m_idx], Mult_32_32( norm_tmp_fx, direction_vector_fx[0][band_m_idx] ), shl( c_e, 1 ), &hOMasa->direction_vector_e[0][block_m_idx][band_m_idx] );
move32();
-
- hOMasa->direction_vector_m_fx[1][block_m_idx][band_m_idx] = L_add( hOMasa->direction_vector_m_fx[0][block_m_idx][band_m_idx], Mpy_32_32( norm_tmp_fx, direction_vector_fx[1][band_m_idx] ) ); // Q: hOMasa->direction_vector_m_q: ( ( norm_tmp_q + direction_q ) - 31 )
+ hOMasa->direction_vector_m_fx[1][block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hOMasa->direction_vector_m_fx[1][block_m_idx][band_m_idx], hOMasa->direction_vector_e[1][block_m_idx][band_m_idx], Mult_32_32( norm_tmp_fx, direction_vector_fx[1][band_m_idx] ), shl( c_e, 1 ), &hOMasa->direction_vector_e[1][block_m_idx][band_m_idx] );
move32();
- hOMasa->direction_vector_m_fx[2][block_m_idx][band_m_idx] = L_add( hOMasa->direction_vector_m_fx[0][block_m_idx][band_m_idx], Mpy_32_32( norm_tmp_fx, direction_vector_fx[2][band_m_idx] ) ); // Q: hOMasa->direction_vector_m_q: ( ( norm_tmp_q + direction_q ) - 31 )
+ hOMasa->direction_vector_m_fx[2][block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hOMasa->direction_vector_m_fx[2][block_m_idx][band_m_idx], hOMasa->direction_vector_e[2][block_m_idx][band_m_idx], Mult_32_32( norm_tmp_fx, direction_vector_fx[2][band_m_idx] ), shl( c_e, 1 ), &hOMasa->direction_vector_e[2][block_m_idx][band_m_idx] );
move32();
- hOMasa->direction_vector_m_q = sub( add( norm_tmp_q, direction_q ), 31 );
-
-
- diffuseness_m_fx[band_m_idx] = L_add( diffuseness_m_fx[band_m_idx], Mpy_32_32( reference_power_fx[band_m_idx], diffuseness_vector_fx[band_m_idx] ) ); // diffuseness_m_q: ( ( reference_power_q + diffuseness_q ) - 31 );
+ diffuseness_m_fx[band_m_idx] = BASOP_Util_Add_Mant32Exp( diffuseness_m_fx[band_m_idx], diffuseness_e[band_m_idx], L_shl( Mult_32_32( reference_power_fx[ts][band_m_idx], diffuseness_vector_fx[band_m_idx] ), 1 ), sub( shl( c_e, 1 ), 1 ), &diffuseness_e[band_m_idx] );
move32();
- diffuseness_m_q = sub( add( reference_power_q, diffuseness_q ), 31 );
- renormalization_factor_diff_fx[band_m_idx] = L_add( renormalization_factor_diff_fx[band_m_idx], reference_power_fx[band_m_idx] );
+ renormalization_factor_diff_fx[band_m_idx] = BASOP_Util_Add_Mant32Exp( renormalization_factor_diff_fx[band_m_idx], renormalization_factor_diff_e[band_m_idx], reference_power_fx[ts][band_m_idx], sub( shl( c_e, 1 ), 1 ), &renormalization_factor_diff_e[band_m_idx] );
move32();
- renormalization_factor_diff_q = reference_power_q;
- move16();
}
}
FOR( band_m_idx = 0; band_m_idx < hOMasa->nbands; band_m_idx++ )
{
+ Word16 max_e = MIN_16;
+ move16();
FOR( d = 0; d < DIRAC_NUM_DIMS; d++ )
{
- dir_v_fx[d] = hOMasa->direction_vector_m_fx[d][block_m_idx][band_m_idx];
- move32();
+ max_e = s_max( max_e, hOMasa->direction_vector_e[d][block_m_idx][band_m_idx] );
}
- dir_v_q = hOMasa->direction_vector_m_q;
- move16();
-
- FOR( i = 0; i < DIRAC_NUM_DIMS; i++ )
+ max_e = add( max_e, 1 ); /*1 as guard bit to prevent overflow*/
+ FOR( d = 0; d < DIRAC_NUM_DIMS; d++ )
{
- dir_v_fx[i] = L_shr( dir_v_fx[i], 1 );
+ dir_v_fx[d] = L_shr( hOMasa->direction_vector_m_fx[d][block_m_idx][band_m_idx], sub( max_e, hOMasa->direction_vector_e[d][block_m_idx][band_m_idx] ) );
move32();
}
+ dir_v_q = sub( 31, max_e );
- dir_v_q = sub( dir_v_q, 1 );
ivas_qmetadata_direction_vector_to_azimuth_elevation_fx( dir_v_fx, dir_v_q, &azimuth_m_values_fx[block_m_idx][band_m_idx], &elevation_m_values_fx[block_m_idx][band_m_idx] );
}
/* Determine energy ratios */
FOR( band_m_idx = 0; band_m_idx < hOMasa->nbands; band_m_idx++ )
{
- IF( BASOP_Util_Cmp_Mant32Exp( renormalization_factor_diff_fx[band_m_idx], sub( 31, renormalization_factor_diff_q ), L_deposit_h( EPSILON_FX ), 2 ) > 0 )
+ Word16 diffuseness_m_e;
+ IF( GT_32( renormalization_factor_diff_fx[band_m_idx], EPSILON_FX ) )
{
- diffuseness_m_fx[band_m_idx] = BASOP_Util_Divide3232_Scale( diffuseness_m_fx[band_m_idx], renormalization_factor_diff_fx[band_m_idx], &scale );
+ diffuseness_m_fx[band_m_idx] = BASOP_Util_Divide3232_Scale( diffuseness_m_fx[band_m_idx], renormalization_factor_diff_fx[band_m_idx], &diffuseness_m_e );
move32();
- scale = add( scale, sub( sub( 31, diffuseness_m_q ), sub( 31, renormalization_factor_diff_q ) ) );
-
- diffuseness_m_fx[band_m_idx] = L_shr( diffuseness_m_fx[band_m_idx], sub( 31, add( scale, diffuseness_m_q ) ) );
+ diffuseness_m_e = add( diffuseness_m_e, sub( diffuseness_e[band_m_idx], renormalization_factor_diff_e[band_m_idx] ) );
+ diffuseness_m_fx[band_m_idx] = L_shl_sat( diffuseness_m_fx[band_m_idx], add( 16, diffuseness_m_e ) ); // Q31
move32();
}
ELSE
@@ -685,7 +609,7 @@ static void ivas_omasa_param_est_ana_fx(
diffuseness_m_fx[band_m_idx] = 0;
move32();
}
- energyRatio_fx[block_m_idx][band_m_idx] = L_sub( L_shl( 1, diffuseness_m_q ), diffuseness_m_fx[band_m_idx] ); // Q: diffuseness_m_q
+ energyRatio_fx[block_m_idx][band_m_idx] = L_sub( ONE_IN_Q31, diffuseness_m_fx[band_m_idx] );
move32();
}
@@ -698,40 +622,12 @@ static void ivas_omasa_param_est_ana_fx(
move32();
}
}
-
- Word16 q_ener_min = MAX_16;
+ *energyRatio_q = Q31;
+ *spreadCoherence_q = Q31;
+ *surroundingCoherence_q = Q31;
move16();
- FOR( block_m_idx = 0; block_m_idx < MAX_PARAM_SPATIAL_SUBFRAMES; block_m_idx++ )
- {
- Word16 e_max;
- maximum_fx( tmp_ener_e[block_m_idx], num_freq_bands, &e_max );
- e_max = sub( 31, e_max );
- if ( GT_16( q_ener_min, e_max ) )
- {
- q_ener_min = e_max;
- move16();
- }
- }
-
- FOR( block_m_idx = 0; block_m_idx < MAX_PARAM_SPATIAL_SUBFRAMES; block_m_idx++ )
- {
- FOR( band_m_idx = 0; band_m_idx < num_freq_bands; band_m_idx++ )
- {
- hOMasa->energy_fx[block_m_idx][band_m_idx] = L_shr( hOMasa->energy_fx[block_m_idx][band_m_idx], sub( sub( 31, tmp_ener_e[block_m_idx][band_m_idx] ), q_ener_min ) ); /* Q(q_ener_min) */
- move32();
- }
- }
-
- hOMasa->energy_q = q_ener_min;
move16();
-
- *spreadCoherence_q = 0;
- move16();
- *surroundingCoherence_q = 0;
move16();
- *energyRatio_q = 0;
- move16();
-
return;
}
@@ -801,25 +697,25 @@ static void ivas_omasa_dmx_fx(
data_out_f_fx[j][k] = BASOP_Util_Add_Mant32Exp( data_out_f_fx[j][k], data_e[j], L_tmp, scale, &in_e[k] );
move32();
}
- }
- max_e = in_e[0];
- move16();
- FOR( l = 1; l < L_FRAME48k; l++ )
- {
- IF( LT_16( max_e, in_e[l] ) )
+ max_e = in_e[0];
+ move16();
+ FOR( l = 1; l < L_FRAME48k; l++ )
{
- max_e = in_e[l];
- move16();
+ IF( LT_16( max_e, in_e[l] ) )
+ {
+ max_e = in_e[l];
+ move16();
+ }
}
- }
- FOR( l = 0; l < L_FRAME48k; l++ )
- {
- data_out_f_fx[j][l] = L_shr( data_out_f_fx[j][l], sub( max_e, in_e[l] ) ); // exponent: max_e, Q: ( 15 - max_e )
- move32();
+ FOR( l = 0; l < L_FRAME48k; l++ )
+ {
+ data_out_f_fx[j][l] = L_shr( data_out_f_fx[j][l], sub( max_e, in_e[l] ) ); // exponent: max_e, Q: ( 15 - max_e )
+ move32();
+ }
+ data_e[j] = max_e;
+ move16();
}
- data_e[j] = max_e;
- move16();
prev_gains_fx[i][j] = L_deposit_h( gains_fx[j] ); // Q31
move32();
diff --git a/lib_rend/ivas_output_init.c b/lib_rend/ivas_output_init.c
deleted file mode 100644
index 9945d630ed96dc9b354bb1b962713581a70ed7c9..0000000000000000000000000000000000000000
--- a/lib_rend/ivas_output_init.c
+++ /dev/null
@@ -1,489 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository. All Rights Reserved.
-
- This software is protected by copyright law and by international treaties.
- The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository retain full ownership rights in their respective contributions in
- the software. This notice grants no license of any kind, including but not limited to patent
- license, nor is any license granted by implication, estoppel or otherwise.
-
- Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
- contributions.
-
- This software is provided "AS IS", without any express or implied warranties. The software is in the
- development stage. It is intended exclusively for experts who have experience with such software and
- solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
- and fitness for a particular purpose are hereby disclaimed and excluded.
-
- Any dispute, controversy or claim arising under or in relation to providing this software shall be
- submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
- accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
- the United Nations Convention on Contracts on the International Sales of Goods.
-
-*******************************************************************************************************/
-
-#include
-#include "options.h"
-#include "ivas_cnst.h"
-#include "prot_fx.h"
-#include "ivas_prot_rend_fx.h"
-#include "ivas_rom_com.h"
-#include "ivas_rom_com_fx.h"
-#include "wmc_auto.h"
-#include "ivas_prot_fx.h"
-/*-------------------------------------------------------------------------*
- * audioCfg2channels()
- *
- * Map Audio configuration to number of channels
- *-------------------------------------------------------------------------*/
-
-/*! r: number of audio channels */
-Word16 audioCfg2channels(
- AUDIO_CONFIG output_config /* i : output audio configuration */
-)
-{
- Word16 nchan_out;
-
- SWITCH( output_config )
- {
- case IVAS_AUDIO_CONFIG_MONO:
- nchan_out = 1;
- move16();
- BREAK;
- case IVAS_AUDIO_CONFIG_STEREO:
- nchan_out = 2;
- move16();
- BREAK;
- case IVAS_AUDIO_CONFIG_5_1:
- nchan_out = 6;
- move16();
- BREAK;
- case IVAS_AUDIO_CONFIG_7_1:
- nchan_out = 8;
- move16();
- BREAK;
- case IVAS_AUDIO_CONFIG_5_1_2:
- nchan_out = 8;
- move16();
- BREAK;
- case IVAS_AUDIO_CONFIG_5_1_4:
- nchan_out = 10;
- move16();
- BREAK;
- case IVAS_AUDIO_CONFIG_7_1_4:
- nchan_out = 12;
- move16();
- BREAK;
- case IVAS_AUDIO_CONFIG_FOA:
- nchan_out = 4;
- move16();
- BREAK;
- case IVAS_AUDIO_CONFIG_HOA2:
- nchan_out = 9;
- move16();
- BREAK;
- case IVAS_AUDIO_CONFIG_HOA3:
- nchan_out = 16;
- move16();
- BREAK;
- case IVAS_AUDIO_CONFIG_OBA:
- nchan_out = 8;
- move16();
- BREAK;
- case IVAS_AUDIO_CONFIG_BINAURAL:
- case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR:
- case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB:
- nchan_out = 2;
- move16();
- BREAK;
- case IVAS_AUDIO_CONFIG_ISM1:
- nchan_out = 1;
- move16();
- BREAK;
- case IVAS_AUDIO_CONFIG_ISM2:
- nchan_out = 2;
- move16();
- BREAK;
- case IVAS_AUDIO_CONFIG_ISM3:
- nchan_out = 3;
- move16();
- BREAK;
- case IVAS_AUDIO_CONFIG_ISM4:
- nchan_out = 4;
- move16();
- BREAK;
- default:
- IVAS_ERROR( IVAS_ERR_INTERNAL, "Error: illegal output configuration\n" );
- nchan_out = -1;
- move16();
- BREAK;
- }
-
- return ( nchan_out );
-}
-
-/*-------------------------------------------------------------------------*
- * ivas_output_init()
- *
- * Initialize and configure IVAS output parameters
- *-------------------------------------------------------------------------*/
-void ivas_output_init(
- IVAS_OUTPUT_SETUP *hOutSetup, /* o : IVAS output setup structure */
- const AUDIO_CONFIG output_config /* i : output audio configuration */
-)
-{
- Word16 nchan_out;
-
- /* set general default values */
- hOutSetup->output_config = output_config;
- move16();
- hOutSetup->is_loudspeaker_setup = 0;
- move16();
- hOutSetup->is_binaural_setup = 0;
- move16();
- hOutSetup->ambisonics_order = -1;
- move16();
- hOutSetup->separateChannelEnabled = 0;
- move16();
- hOutSetup->separateChannelIndex = 0;
- move16();
-
- IF( EQ_16( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
- {
- hOutSetup->is_loudspeaker_setup = 1;
- move16();
- /* set in ivas_init_decoder: */
- /* hOutSetup->ls_azimuth */
- /* hOutSetup->ls_elevation */
- /* hOutSetup->num_lfe */
- /* hOutSetup->index_lfe[0] */
- /* hOutSetup->is_planar_setup */
- }
- ELSE
- {
- /* Set default values for all other than custom LS setup */
- hOutSetup->ls_azimuth_fx = NULL;
- hOutSetup->ls_elevation_fx = NULL;
- hOutSetup->num_lfe = 0;
- move16();
- hOutSetup->index_lfe[0] = -1;
- move16();
- hOutSetup->is_planar_setup = 0;
- move16();
-
- /* set output setup specific values */
- SWITCH( output_config )
- {
- case IVAS_AUDIO_CONFIG_MONO:
- hOutSetup->is_loudspeaker_setup = 1;
- move16();
- BREAK;
- case IVAS_AUDIO_CONFIG_STEREO:
- hOutSetup->is_loudspeaker_setup = 1;
- move16();
- hOutSetup->ls_azimuth_fx = ls_azimuth_CICP2_fx; // Q22
- hOutSetup->ls_elevation_fx = ls_elevation_CICP2_fx; // Q22
- BREAK;
- case IVAS_AUDIO_CONFIG_FOA:
- hOutSetup->ambisonics_order = SBA_FOA_ORDER;
- move16();
- BREAK;
- case IVAS_AUDIO_CONFIG_HOA2:
- hOutSetup->ambisonics_order = SBA_HOA2_ORDER;
- move16();
- BREAK;
- case IVAS_AUDIO_CONFIG_HOA3:
- hOutSetup->ambisonics_order = SBA_HOA3_ORDER;
- move16();
- BREAK;
- case IVAS_AUDIO_CONFIG_5_1:
- hOutSetup->num_lfe = 1;
- move16();
- hOutSetup->index_lfe[0] = 3;
- move16();
- hOutSetup->is_loudspeaker_setup = 1;
- move16();
- hOutSetup->ls_azimuth_fx = ls_azimuth_CICP6_fx; // Q22
- hOutSetup->ls_elevation_fx = ls_elevation_CICP6_fx; // Q22
- hOutSetup->is_planar_setup = 1;
- move16();
- BREAK;
- case IVAS_AUDIO_CONFIG_7_1:
- hOutSetup->num_lfe = 1;
- move16();
- hOutSetup->index_lfe[0] = 3;
- move16();
- hOutSetup->is_loudspeaker_setup = 1;
- move16();
- hOutSetup->ls_azimuth_fx = ls_azimuth_CICP12_fx; // Q22
- hOutSetup->ls_elevation_fx = ls_elevation_CICP12_fx; // Q22
- hOutSetup->is_planar_setup = 1;
- move16();
- BREAK;
- case IVAS_AUDIO_CONFIG_5_1_2:
- hOutSetup->num_lfe = 1;
- move16();
- hOutSetup->index_lfe[0] = 3;
- move16();
- hOutSetup->is_loudspeaker_setup = 1;
- move16();
- hOutSetup->ls_azimuth_fx = ls_azimuth_CICP14_fx; // Q22
- hOutSetup->ls_elevation_fx = ls_elevation_CICP14_fx; // Q22
- hOutSetup->is_planar_setup = 0;
- move16();
- BREAK;
- case IVAS_AUDIO_CONFIG_5_1_4:
- hOutSetup->num_lfe = 1;
- move16();
- hOutSetup->index_lfe[0] = 3;
- move16();
- hOutSetup->is_loudspeaker_setup = 1;
- move16();
- hOutSetup->ls_azimuth_fx = ls_azimuth_CICP16_fx; // Q22
- hOutSetup->ls_elevation_fx = ls_elevation_CICP16_fx; // Q22
- hOutSetup->is_planar_setup = 0;
- move16();
- BREAK;
- case IVAS_AUDIO_CONFIG_7_1_4:
- hOutSetup->num_lfe = 1;
- move16();
- hOutSetup->index_lfe[0] = 3;
- move16();
- hOutSetup->is_loudspeaker_setup = 1;
- move16();
- hOutSetup->ls_azimuth_fx = ls_azimuth_CICP19_fx; // Q22
- hOutSetup->ls_elevation_fx = ls_elevation_CICP19_fx; // Q22
- hOutSetup->is_planar_setup = 0;
- move16();
- BREAK;
- case IVAS_AUDIO_CONFIG_BINAURAL:
- case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR:
- case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB:
- case IVAS_AUDIO_CONFIG_ISM1:
- case IVAS_AUDIO_CONFIG_ISM2:
- case IVAS_AUDIO_CONFIG_ISM3:
- case IVAS_AUDIO_CONFIG_ISM4:
- hOutSetup->is_binaural_setup = 1;
- move16();
- case IVAS_AUDIO_CONFIG_EXTERNAL:
- /* Default values are used */
- BREAK;
- default:
- return;
- }
- }
-
- test();
- IF( NE_16( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) && NE_16( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
- {
- nchan_out = audioCfg2channels( output_config );
- hOutSetup->nchan_out_woLFE = sub( nchan_out, hOutSetup->num_lfe );
- move16();
- }
-
- return;
-}
-
-
-/*-----------------------------------------------------------------*
- * ivas_get_nchan_buffers_dec()
- *
- * Return number of decoder audio buffers
- *-----------------------------------------------------------------*/
-
-/*! r: number of decoder buffers */
-Word16 ivas_get_nchan_buffers_dec(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
- const Word16 sba_analysis_order, /* i : SBA order evaluated in SBA decoder */
- const Word32 ivas_total_brate /* i : total IVAS bitrate */
-)
-{
- Word16 nchan_out_buff;
- AUDIO_CONFIG output_config;
-
- output_config = st_ivas->hDecoderConfig->output_config;
- move16();
-
- nchan_out_buff = MAX_OUTPUT_CHANNELS;
- move16();
-
- IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) )
- {
- nchan_out_buff = st_ivas->hDecoderConfig->nchan_out;
- move16();
- }
- ELSE IF( EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) )
- {
- nchan_out_buff = s_max( st_ivas->hDecoderConfig->nchan_out, CPE_CHANNELS );
- }
- ELSE IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) )
- {
- nchan_out_buff = st_ivas->nchan_ism;
- move16();
-
- IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
- {
- nchan_out_buff = s_max( nchan_out_buff, add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) );
- }
- ELSE IF( NE_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
- {
- nchan_out_buff = s_max( audioCfg2channels( st_ivas->transport_config ), audioCfg2channels( st_ivas->intern_config ) );
- nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( output_config ) );
- }
- }
- ELSE IF( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) )
- {
- Word16 nchan_internal;
- nchan_internal = ivas_sba_get_nchan_metadata_fx( sba_analysis_order, ivas_total_brate );
- nchan_out_buff = st_ivas->hDecoderConfig->nchan_out;
- move16();
-
- IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
- {
- nchan_out_buff = s_max( nchan_out_buff, add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) );
- }
- ELSE
- {
- nchan_out_buff = s_max( audioCfg2channels( st_ivas->transport_config ), audioCfg2channels( st_ivas->intern_config ) );
- nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( output_config ) );
- }
- nchan_out_buff = s_max( nchan_out_buff, nchan_internal );
- }
- ELSE IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) )
- {
- nchan_out_buff = CPE_CHANNELS;
- move16();
-
- test();
- test();
- test();
- IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
- {
- nchan_out_buff = s_max( nchan_out_buff, add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) );
- }
- ELSE IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) )
- {
- nchan_out_buff = shl( CPE_CHANNELS, 1 );
- }
- ELSE IF( NE_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
- {
- nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( st_ivas->intern_config ) );
- nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( output_config ) );
- }
- }
- ELSE IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) )
- {
- nchan_out_buff = add( st_ivas->nchan_ism, CPE_CHANNELS );
-
- IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
- {
- nchan_out_buff = s_max( nchan_out_buff, add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) );
- }
- ELSE IF( NE_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
- {
- nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( st_ivas->intern_config ) );
- nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( output_config ) );
- }
- }
- ELSE IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) )
- {
- Word16 nchan_internal;
- nchan_internal = ivas_sba_get_nchan_metadata_fx( sba_analysis_order, ivas_total_brate );
- nchan_out_buff = add( st_ivas->nchan_ism, st_ivas->nchan_transport );
-
- IF( st_ivas->hMCT != NULL )
- {
- nchan_out_buff = shl( shr( add( nchan_out_buff, 1 ), 1 ), 1 ); /* ensure odd number of channels in MCT */
- }
-
- IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
- {
- nchan_out_buff = s_max( nchan_out_buff, add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) );
- }
- ELSE IF( NE_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
- {
- nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( st_ivas->intern_config ) );
- nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( output_config ) );
-
- test();
- IF( EQ_32( st_ivas->renderer_type, RENDERER_OSBA_AMBI ) || EQ_32( st_ivas->renderer_type, RENDERER_OSBA_LS ) )
- {
- nchan_out_buff = s_max( add( nchan_out_buff, st_ivas->nchan_ism ), audioCfg2channels( output_config ) ); /* needed for ivas_sba_upmixer_renderer() */
- }
- ELSE
- {
- nchan_out_buff = s_max( add( nchan_out_buff, st_ivas->nchan_ism ), audioCfg2channels( output_config ) ); /* needed for ivas_spar_dec_upmixer_sf() which is based on 'nchan_out' */
- }
- }
- ELSE IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
- {
- nchan_out_buff = add( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_ism ); /*take into account sba_ch_idx' in ivas_dec() */
- }
-
- test();
- IF( !( EQ_32( output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) )
- {
- nchan_out_buff = s_max( nchan_out_buff, add( nchan_internal, st_ivas->nchan_ism ) );
- }
- nchan_out_buff = s_min( nchan_out_buff, MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS );
- }
- ELSE IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) )
- {
- nchan_out_buff = st_ivas->hDecoderConfig->nchan_out;
-
- IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
- {
- nchan_out_buff = s_max( nchan_out_buff, add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) );
- }
- ELSE
- {
- nchan_out_buff = s_max( audioCfg2channels( st_ivas->transport_config ), audioCfg2channels( st_ivas->intern_config ) );
- nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( output_config ) );
- }
- }
-
-
- return nchan_out_buff;
-}
-
-/*-------------------------------------------------------------------*
- * ivas_output_buff_dec()
- *
- * Allocate/reallocate output audio buffers
- *-------------------------------------------------------------------*/
-ivas_error ivas_output_buff_dec_fx(
- Word32 *p_output_f[], /* i/o: output audio buffers */
- const Word16 nchan_out_buff_old, /* i : previous frame number of output channels */
- const Word16 nchan_out_buff /* i : number of output channels */
-)
-{
- Word16 ch;
- IF( GT_16( nchan_out_buff, nchan_out_buff_old ) )
- {
- FOR( ch = nchan_out_buff_old; ch < nchan_out_buff; ch++ )
- {
- /* note: these are intra-frame heap memories */
- IF( ( p_output_f[ch] = (Word32 *) malloc( ( 48000 / FRAMES_PER_SEC ) * sizeof( Word32 ) ) ) == NULL ) /* note: 32000 == max internal sampling rate */
- {
- return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for floating-point output audio buffer!\n" ) );
- }
- }
- }
- ELSE
- {
- FOR( ch = nchan_out_buff; ch < nchan_out_buff_old; ch++ )
- {
- free( p_output_f[ch] );
- p_output_f[ch] = NULL;
- }
- }
- return IVAS_ERR_OK;
-}
diff --git a/lib_rend/ivas_output_init_fx.c b/lib_rend/ivas_output_init_fx.c
index 3b01f62ca0af91b601d6b42e79f8426dfdd906c1..057161c7c4c366ae8b0b8a872d1fbd99af657fa6 100644
--- a/lib_rend/ivas_output_init_fx.c
+++ b/lib_rend/ivas_output_init_fx.c
@@ -1,7 +1,459 @@
+/******************************************************************************************************
-#include "ivas_prot_fx.h"
-#include "ivas_prot_rend_fx.h"
+ (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
+ Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
+ Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
+ contributors to this repository. All Rights Reserved.
+
+ This software is protected by copyright law and by international treaties.
+ The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
+ Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
+ Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
+ Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
+ contributors to this repository retain full ownership rights in their respective contributions in
+ the software. This notice grants no license of any kind, including but not limited to patent
+ license, nor is any license granted by implication, estoppel or otherwise.
+
+ Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
+ contributions.
+
+ This software is provided "AS IS", without any express or implied warranties. The software is in the
+ development stage. It is intended exclusively for experts who have experience with such software and
+ solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
+ and fitness for a particular purpose are hereby disclaimed and excluded.
+
+ Any dispute, controversy or claim arising under or in relation to providing this software shall be
+ submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
+ accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
+ the United Nations Convention on Contracts on the International Sales of Goods.
+
+*******************************************************************************************************/
+
+#include
#include
+#include "options.h"
+#include "ivas_cnst.h"
+#include "prot_fx.h"
+#include "ivas_prot_rend_fx.h"
+#include "ivas_rom_com.h"
+#include "ivas_rom_com_fx.h"
+#include "wmc_auto.h"
+#include "ivas_prot_fx.h"
+/*-------------------------------------------------------------------------*
+ * audioCfg2channels()
+ *
+ * Map Audio configuration to number of channels
+ *-------------------------------------------------------------------------*/
+
+/*! r: number of audio channels */
+Word16 audioCfg2channels(
+ AUDIO_CONFIG output_config /* i : output audio configuration */
+)
+{
+ Word16 nchan_out;
+
+ SWITCH( output_config )
+ {
+ case IVAS_AUDIO_CONFIG_MONO:
+ nchan_out = 1;
+ move16();
+ BREAK;
+ case IVAS_AUDIO_CONFIG_STEREO:
+ nchan_out = 2;
+ move16();
+ BREAK;
+ case IVAS_AUDIO_CONFIG_5_1:
+ nchan_out = 6;
+ move16();
+ BREAK;
+ case IVAS_AUDIO_CONFIG_7_1:
+ nchan_out = 8;
+ move16();
+ BREAK;
+ case IVAS_AUDIO_CONFIG_5_1_2:
+ nchan_out = 8;
+ move16();
+ BREAK;
+ case IVAS_AUDIO_CONFIG_5_1_4:
+ nchan_out = 10;
+ move16();
+ BREAK;
+ case IVAS_AUDIO_CONFIG_7_1_4:
+ nchan_out = 12;
+ move16();
+ BREAK;
+ case IVAS_AUDIO_CONFIG_FOA:
+ nchan_out = 4;
+ move16();
+ BREAK;
+ case IVAS_AUDIO_CONFIG_HOA2:
+ nchan_out = 9;
+ move16();
+ BREAK;
+ case IVAS_AUDIO_CONFIG_HOA3:
+ nchan_out = 16;
+ move16();
+ BREAK;
+ case IVAS_AUDIO_CONFIG_OBA:
+ nchan_out = 8;
+ move16();
+ BREAK;
+ case IVAS_AUDIO_CONFIG_BINAURAL:
+ case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR:
+ case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB:
+ nchan_out = 2;
+ move16();
+ BREAK;
+ case IVAS_AUDIO_CONFIG_ISM1:
+ nchan_out = 1;
+ move16();
+ BREAK;
+ case IVAS_AUDIO_CONFIG_ISM2:
+ nchan_out = 2;
+ move16();
+ BREAK;
+ case IVAS_AUDIO_CONFIG_ISM3:
+ nchan_out = 3;
+ move16();
+ BREAK;
+ case IVAS_AUDIO_CONFIG_ISM4:
+ nchan_out = 4;
+ move16();
+ BREAK;
+ default:
+ IVAS_ERROR( IVAS_ERR_INTERNAL, "Error: illegal output configuration\n" );
+ nchan_out = -1;
+ move16();
+ BREAK;
+ }
+
+ return ( nchan_out );
+}
+
+/*-------------------------------------------------------------------------*
+ * ivas_output_init()
+ *
+ * Initialize and configure IVAS output parameters
+ *-------------------------------------------------------------------------*/
+void ivas_output_init(
+ IVAS_OUTPUT_SETUP *hOutSetup, /* o : IVAS output setup structure */
+ const AUDIO_CONFIG output_config /* i : output audio configuration */
+)
+{
+ Word16 nchan_out;
+
+ /* set general default values */
+ hOutSetup->output_config = output_config;
+ move16();
+ hOutSetup->is_loudspeaker_setup = 0;
+ move16();
+ hOutSetup->is_binaural_setup = 0;
+ move16();
+ hOutSetup->ambisonics_order = -1;
+ move16();
+ hOutSetup->separateChannelEnabled = 0;
+ move16();
+ hOutSetup->separateChannelIndex = 0;
+ move16();
+
+ IF( EQ_16( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
+ {
+ hOutSetup->is_loudspeaker_setup = 1;
+ move16();
+ /* set in ivas_init_decoder: */
+ /* hOutSetup->ls_azimuth */
+ /* hOutSetup->ls_elevation */
+ /* hOutSetup->num_lfe */
+ /* hOutSetup->index_lfe[0] */
+ /* hOutSetup->is_planar_setup */
+ }
+ ELSE
+ {
+ /* Set default values for all other than custom LS setup */
+ hOutSetup->ls_azimuth_fx = NULL;
+ hOutSetup->ls_elevation_fx = NULL;
+ hOutSetup->num_lfe = 0;
+ move16();
+ hOutSetup->index_lfe[0] = -1;
+ move16();
+ hOutSetup->is_planar_setup = 0;
+ move16();
+
+ /* set output setup specific values */
+ SWITCH( output_config )
+ {
+ case IVAS_AUDIO_CONFIG_MONO:
+ hOutSetup->is_loudspeaker_setup = 1;
+ move16();
+ BREAK;
+ case IVAS_AUDIO_CONFIG_STEREO:
+ hOutSetup->is_loudspeaker_setup = 1;
+ move16();
+ hOutSetup->ls_azimuth_fx = ls_azimuth_CICP2_fx; // Q22
+ hOutSetup->ls_elevation_fx = ls_elevation_CICP2_fx; // Q22
+ BREAK;
+ case IVAS_AUDIO_CONFIG_FOA:
+ hOutSetup->ambisonics_order = SBA_FOA_ORDER;
+ move16();
+ BREAK;
+ case IVAS_AUDIO_CONFIG_HOA2:
+ hOutSetup->ambisonics_order = SBA_HOA2_ORDER;
+ move16();
+ BREAK;
+ case IVAS_AUDIO_CONFIG_HOA3:
+ hOutSetup->ambisonics_order = SBA_HOA3_ORDER;
+ move16();
+ BREAK;
+ case IVAS_AUDIO_CONFIG_5_1:
+ hOutSetup->num_lfe = 1;
+ move16();
+ hOutSetup->index_lfe[0] = 3;
+ move16();
+ hOutSetup->is_loudspeaker_setup = 1;
+ move16();
+ hOutSetup->ls_azimuth_fx = ls_azimuth_CICP6_fx; // Q22
+ hOutSetup->ls_elevation_fx = ls_elevation_CICP6_fx; // Q22
+ hOutSetup->is_planar_setup = 1;
+ move16();
+ BREAK;
+ case IVAS_AUDIO_CONFIG_7_1:
+ hOutSetup->num_lfe = 1;
+ move16();
+ hOutSetup->index_lfe[0] = 3;
+ move16();
+ hOutSetup->is_loudspeaker_setup = 1;
+ move16();
+ hOutSetup->ls_azimuth_fx = ls_azimuth_CICP12_fx; // Q22
+ hOutSetup->ls_elevation_fx = ls_elevation_CICP12_fx; // Q22
+ hOutSetup->is_planar_setup = 1;
+ move16();
+ BREAK;
+ case IVAS_AUDIO_CONFIG_5_1_2:
+ hOutSetup->num_lfe = 1;
+ move16();
+ hOutSetup->index_lfe[0] = 3;
+ move16();
+ hOutSetup->is_loudspeaker_setup = 1;
+ move16();
+ hOutSetup->ls_azimuth_fx = ls_azimuth_CICP14_fx; // Q22
+ hOutSetup->ls_elevation_fx = ls_elevation_CICP14_fx; // Q22
+ hOutSetup->is_planar_setup = 0;
+ move16();
+ BREAK;
+ case IVAS_AUDIO_CONFIG_5_1_4:
+ hOutSetup->num_lfe = 1;
+ move16();
+ hOutSetup->index_lfe[0] = 3;
+ move16();
+ hOutSetup->is_loudspeaker_setup = 1;
+ move16();
+ hOutSetup->ls_azimuth_fx = ls_azimuth_CICP16_fx; // Q22
+ hOutSetup->ls_elevation_fx = ls_elevation_CICP16_fx; // Q22
+ hOutSetup->is_planar_setup = 0;
+ move16();
+ BREAK;
+ case IVAS_AUDIO_CONFIG_7_1_4:
+ hOutSetup->num_lfe = 1;
+ move16();
+ hOutSetup->index_lfe[0] = 3;
+ move16();
+ hOutSetup->is_loudspeaker_setup = 1;
+ move16();
+ hOutSetup->ls_azimuth_fx = ls_azimuth_CICP19_fx; // Q22
+ hOutSetup->ls_elevation_fx = ls_elevation_CICP19_fx; // Q22
+ hOutSetup->is_planar_setup = 0;
+ move16();
+ BREAK;
+ case IVAS_AUDIO_CONFIG_BINAURAL:
+ case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR:
+ case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB:
+ case IVAS_AUDIO_CONFIG_ISM1:
+ case IVAS_AUDIO_CONFIG_ISM2:
+ case IVAS_AUDIO_CONFIG_ISM3:
+ case IVAS_AUDIO_CONFIG_ISM4:
+ hOutSetup->is_binaural_setup = 1;
+ move16();
+ case IVAS_AUDIO_CONFIG_EXTERNAL:
+ /* Default values are used */
+ BREAK;
+ default:
+ return;
+ }
+ }
+
+ test();
+ IF( NE_16( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) && NE_16( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
+ {
+ nchan_out = audioCfg2channels( output_config );
+ hOutSetup->nchan_out_woLFE = sub( nchan_out, hOutSetup->num_lfe );
+ move16();
+ }
+
+ return;
+}
+
+
+/*-----------------------------------------------------------------*
+ * ivas_get_nchan_buffers_dec()
+ *
+ * Return number of decoder audio buffers
+ *-----------------------------------------------------------------*/
+
+/*! r: number of decoder buffers */
+Word16 ivas_get_nchan_buffers_dec(
+ Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
+ const Word16 sba_analysis_order, /* i : SBA order evaluated in SBA decoder */
+ const Word32 ivas_total_brate /* i : total IVAS bitrate */
+)
+{
+ Word16 nchan_out_buff;
+ AUDIO_CONFIG output_config;
+
+ output_config = st_ivas->hDecoderConfig->output_config;
+ move16();
+
+ nchan_out_buff = MAX_OUTPUT_CHANNELS;
+ move16();
+
+ IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) )
+ {
+ nchan_out_buff = st_ivas->hDecoderConfig->nchan_out;
+ move16();
+ }
+ ELSE IF( EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) )
+ {
+ nchan_out_buff = s_max( st_ivas->hDecoderConfig->nchan_out, CPE_CHANNELS );
+ }
+ ELSE IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) )
+ {
+ nchan_out_buff = st_ivas->nchan_ism;
+ move16();
+
+ IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
+ {
+ nchan_out_buff = s_max( nchan_out_buff, add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) );
+ }
+ ELSE IF( NE_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
+ {
+ nchan_out_buff = s_max( audioCfg2channels( st_ivas->transport_config ), audioCfg2channels( st_ivas->intern_config ) );
+ nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( output_config ) );
+ }
+ }
+ ELSE IF( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) )
+ {
+ Word16 nchan_internal;
+ nchan_internal = ivas_sba_get_nchan_metadata_fx( sba_analysis_order, ivas_total_brate );
+ nchan_out_buff = st_ivas->hDecoderConfig->nchan_out;
+ move16();
+
+ IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
+ {
+ nchan_out_buff = s_max( nchan_out_buff, add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) );
+ }
+ ELSE
+ {
+ nchan_out_buff = s_max( audioCfg2channels( st_ivas->transport_config ), audioCfg2channels( st_ivas->intern_config ) );
+ nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( output_config ) );
+ }
+ nchan_out_buff = s_max( nchan_out_buff, nchan_internal );
+ }
+ ELSE IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) )
+ {
+ nchan_out_buff = CPE_CHANNELS;
+ move16();
+
+ test();
+ test();
+ test();
+ IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
+ {
+ nchan_out_buff = s_max( nchan_out_buff, add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) );
+ }
+ ELSE IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) )
+ {
+ nchan_out_buff = shl( CPE_CHANNELS, 1 );
+ }
+ ELSE IF( NE_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
+ {
+ nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( st_ivas->intern_config ) );
+ nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( output_config ) );
+ }
+ }
+ ELSE IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) )
+ {
+ nchan_out_buff = add( st_ivas->nchan_ism, CPE_CHANNELS );
+
+ IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
+ {
+ nchan_out_buff = s_max( nchan_out_buff, add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) );
+ }
+ ELSE IF( NE_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
+ {
+ nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( st_ivas->intern_config ) );
+ nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( output_config ) );
+ }
+ }
+ ELSE IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) )
+ {
+ Word16 nchan_internal;
+ nchan_internal = ivas_sba_get_nchan_metadata_fx( sba_analysis_order, ivas_total_brate );
+ nchan_out_buff = add( st_ivas->nchan_ism, st_ivas->nchan_transport );
+
+ IF( st_ivas->hMCT != NULL )
+ {
+ nchan_out_buff = shl( shr( add( nchan_out_buff, 1 ), 1 ), 1 ); /* ensure odd number of channels in MCT */
+ }
+
+ IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
+ {
+ nchan_out_buff = s_max( nchan_out_buff, add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) );
+ }
+ ELSE IF( NE_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
+ {
+ nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( st_ivas->intern_config ) );
+ nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( output_config ) );
+
+ test();
+ IF( EQ_32( st_ivas->renderer_type, RENDERER_OSBA_AMBI ) || EQ_32( st_ivas->renderer_type, RENDERER_OSBA_LS ) )
+ {
+ nchan_out_buff = s_max( add( nchan_out_buff, st_ivas->nchan_ism ), audioCfg2channels( output_config ) ); /* needed for ivas_sba_upmixer_renderer() */
+ }
+ ELSE
+ {
+ nchan_out_buff = s_max( add( nchan_out_buff, st_ivas->nchan_ism ), audioCfg2channels( output_config ) ); /* needed for ivas_spar_dec_upmixer_sf() which is based on 'nchan_out' */
+ }
+ }
+ ELSE IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
+ {
+ nchan_out_buff = add( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_ism ); /*take into account sba_ch_idx' in ivas_dec() */
+ }
+
+ test();
+ IF( !( EQ_32( output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) )
+ {
+ nchan_out_buff = s_max( nchan_out_buff, add( nchan_internal, st_ivas->nchan_ism ) );
+ }
+ nchan_out_buff = s_min( nchan_out_buff, MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS );
+ }
+ ELSE IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) )
+ {
+ nchan_out_buff = st_ivas->hDecoderConfig->nchan_out;
+
+ IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
+ {
+ nchan_out_buff = s_max( nchan_out_buff, add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) );
+ }
+ ELSE
+ {
+ nchan_out_buff = s_max( audioCfg2channels( st_ivas->transport_config ), audioCfg2channels( st_ivas->intern_config ) );
+ nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( output_config ) );
+ }
+ }
+
+
+ return nchan_out_buff;
+}
Word16 ivas_get_nchan_buffers_dec_ivas_fx(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
@@ -159,6 +611,42 @@ Word16 ivas_get_nchan_buffers_dec_ivas_fx(
return nchan_out_buff;
}
+
+/*-------------------------------------------------------------------*
+ * ivas_output_buff_dec()
+ *
+ * Allocate/reallocate output audio buffers
+ *-------------------------------------------------------------------*/
+ivas_error ivas_output_buff_dec_fx(
+ Word32 *p_output_f[], /* i/o: output audio buffers */
+ const Word16 nchan_out_buff_old, /* i : previous frame number of output channels */
+ const Word16 nchan_out_buff /* i : number of output channels */
+)
+{
+ Word16 ch;
+ IF( GT_16( nchan_out_buff, nchan_out_buff_old ) )
+ {
+ FOR( ch = nchan_out_buff_old; ch < nchan_out_buff; ch++ )
+ {
+ /* note: these are intra-frame heap memories */
+ IF( ( p_output_f[ch] = (Word32 *) malloc( ( 48000 / FRAMES_PER_SEC ) * sizeof( Word32 ) ) ) == NULL ) /* note: 32000 == max internal sampling rate */
+ {
+ return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for floating-point output audio buffer!\n" ) );
+ }
+ }
+ }
+ ELSE
+ {
+ FOR( ch = nchan_out_buff; ch < nchan_out_buff_old; ch++ )
+ {
+ free( p_output_f[ch] );
+ p_output_f[ch] = NULL;
+ }
+ }
+ return IVAS_ERR_OK;
+}
+
+
/*---------------------------------------------------------------------*
* get_channel_config()
*
diff --git a/lib_rend/ivas_prot_rend_fx.h b/lib_rend/ivas_prot_rend_fx.h
index 983c814aa51db73321d46dfebcaa290ad2bce5f9..8772b542e1e9297707a10ec1ec9c238579da21a2 100644
--- a/lib_rend/ivas_prot_rend_fx.h
+++ b/lib_rend/ivas_prot_rend_fx.h
@@ -755,7 +755,7 @@ void TDREND_SRC_REND_UpdateFiltersFromSpatialParams_fx(
Word16 *intp_count, /* o : Interpolation count */
Word16 *filterlength, /* o : Length of filters */
Word16 *itd, /* o : ITD value */
- Word16 *Gain, /* o : Gain value */
+ Word32 *Gain, /* o : Gain value Q30 */
TDREND_SRC_t *Src_p, /* i/o: Source pointer */
const Word16 subframe_update_flag);
@@ -842,8 +842,8 @@ void TDREND_firfilt_fx(
Word32 *mem_fx, /* i/o: filter memory Qx */
const Word16 subframe_length, /* i : Length of signal */
const Word16 filterlength, /* i : Filter length */
- const Word16 Gain_fx, /* i : Gain Q14 */
- const Word16 prevGain_fx /* i : Previous gain Q14 */
+ const Word32 Gain_fx, /* i : Gain Q30 */
+ const Word32 prevGain_fx /* i : Previous gain Q30 */
);
@@ -1478,11 +1478,11 @@ void ivas_prerend_merge_masa_metadata_fx(
MASA_DECODER_EXT_OUT_META_HANDLE inMeta1, /* i : Input metadata 1 */
IVAS_REND_AudioConfigType inType1, /* i : Type of input 1 */
Word32 inEne1_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i/o: TF-energy of input 1. after merge, contains the energy of the merged signal */
- Word16 *inEne1_e, /* i/o: TF-energy of input 1 Exponent */
+ Word16 inEne1_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i/o: TF-energy of input 1 Exponent */
MASA_DECODER_EXT_OUT_META_HANDLE inMeta2, /* i : Input metadata 2 */
IVAS_REND_AudioConfigType inType2, /* i : Type of input 2 */
Word32 inEne2_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : TF-energy of input 2 */
- Word16 *inEne2_e /* i : TF-energy of input 2 Exponent */
+ Word16 inEne2_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS] /* i : TF-energy of input 2 Exponent */
);
ivas_error masaPrerendOpen_fx(
diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c
index 12b94b1a2e306c2b1966dcb7a0d1190c4d5d7909..b9b897f4aaa4c9623712220325369162c5d33dfa 100644
--- a/lib_rend/ivas_reverb_fx.c
+++ b/lib_rend/ivas_reverb_fx.c
@@ -2271,6 +2271,16 @@ void ivas_binaural_reverb_processSubframe_fx(
{
Word32 leftRe_fx, rightRe_fx, leftIm_fx, rightIm_fx;
+#ifdef OPT_BIN_RENDERER_V2
+ leftRe_fx = Madd_32_32( Mpy_32_32( hReverb->binauralCoherenceDirectGains_fx[bin], hReverb->outputBufferReal_fx[bin][0][sample] ),
+ hReverb->binauralCoherenceCrossmixGains_fx[bin], hReverb->outputBufferReal_fx[bin][1][sample] ); // Q_in
+ rightRe_fx = Madd_32_32( Mpy_32_32( hReverb->binauralCoherenceDirectGains_fx[bin], hReverb->outputBufferReal_fx[bin][1][sample] ),
+ hReverb->binauralCoherenceCrossmixGains_fx[bin], hReverb->outputBufferReal_fx[bin][0][sample] ); // Q_in
+ leftIm_fx = Madd_32_32( Mpy_32_32( hReverb->binauralCoherenceDirectGains_fx[bin], hReverb->outputBufferImag_fx[bin][0][sample] ),
+ hReverb->binauralCoherenceCrossmixGains_fx[bin], hReverb->outputBufferImag_fx[bin][1][sample] ); // Q_in
+ rightIm_fx = Madd_32_32( Mpy_32_32( hReverb->binauralCoherenceDirectGains_fx[bin], hReverb->outputBufferImag_fx[bin][1][sample] ),
+ hReverb->binauralCoherenceCrossmixGains_fx[bin], hReverb->outputBufferImag_fx[bin][0][sample] ); // Q_in
+#else /* OPT_BIN_RENDERER_V2 */
leftRe_fx = L_add( Mpy_32_32( hReverb->binauralCoherenceDirectGains_fx[bin], hReverb->outputBufferReal_fx[bin][0][sample] ),
Mpy_32_32( hReverb->binauralCoherenceCrossmixGains_fx[bin], hReverb->outputBufferReal_fx[bin][1][sample] ) ); // Q_in
rightRe_fx = L_add( Mpy_32_32( hReverb->binauralCoherenceDirectGains_fx[bin], hReverb->outputBufferReal_fx[bin][1][sample] ),
@@ -2279,6 +2289,7 @@ void ivas_binaural_reverb_processSubframe_fx(
Mpy_32_32( hReverb->binauralCoherenceCrossmixGains_fx[bin], hReverb->outputBufferImag_fx[bin][1][sample] ) ); // Q_in
rightIm_fx = L_add( Mpy_32_32( hReverb->binauralCoherenceDirectGains_fx[bin], hReverb->outputBufferImag_fx[bin][1][sample] ),
Mpy_32_32( hReverb->binauralCoherenceCrossmixGains_fx[bin], hReverb->outputBufferImag_fx[bin][0][sample] ) ); // Q_in
+#endif /* OPT_BIN_RENDERER_V2 */
hReverb->outputBufferReal_fx[bin][0][sample] = leftRe_fx; // Q_in
move32();
diff --git a/lib_rend/ivas_rom_rend.h b/lib_rend/ivas_rom_rend.h
index e7d6c6293d71ef04fe62e4a2a84613ff5065030f..7f9cfb57adb40b59f5d130ccb44ac26c50c04c42 100644
--- a/lib_rend/ivas_rom_rend.h
+++ b/lib_rend/ivas_rom_rend.h
@@ -51,10 +51,10 @@ extern const Word16 diffuse_response_CICP16_fx[9]; /*Q-15*/
extern const Word16 ap_pre_delay[DIRAC_DECORR_NUM_SPLIT_BANDS];
extern const Word16 ap_filter_length[DIRAC_DECORR_NUM_SPLIT_BANDS];
extern const Word16 ap_lattice_delta_phi_fx[DIRAC_MAX_NUM_DECORR_FILTERS * DIRAC_MAX_DECORR_FILTER_LEN]; /*Q-14*/
-extern const Word16 ap_lattice_coeffs_1_fx[DIRAC_DECORR_FILTER_LEN_1 * DIRAC_MAX_NUM_DECORR_FILTERS]; /*Q-15*/
-extern const Word16 ap_lattice_coeffs_2_fx[DIRAC_DECORR_FILTER_LEN_2 * DIRAC_MAX_NUM_DECORR_FILTERS]; /*Q-15*/
-extern const Word16 ap_lattice_coeffs_3_fx[DIRAC_DECORR_FILTER_LEN_3 * DIRAC_MAX_NUM_DECORR_FILTERS]; /*Q-15*/
-extern const Word16 *const ap_lattice_coeffs_fx[DIRAC_DECORR_NUM_SPLIT_BANDS];
+extern const Word32 ap_lattice_coeffs_1_fx[DIRAC_DECORR_FILTER_LEN_1 * DIRAC_MAX_NUM_DECORR_FILTERS]; /*Q-15*/
+extern const Word32 ap_lattice_coeffs_2_fx[DIRAC_DECORR_FILTER_LEN_2 * DIRAC_MAX_NUM_DECORR_FILTERS]; /*Q-15*/
+extern const Word32 ap_lattice_coeffs_3_fx[DIRAC_DECORR_FILTER_LEN_3 * DIRAC_MAX_NUM_DECORR_FILTERS]; /*Q-15*/
+extern const Word32 *const ap_lattice_coeffs_fx[DIRAC_DECORR_NUM_SPLIT_BANDS];
extern const Word16 ap_split_frequencies_fx[DIRAC_DECORR_NUM_SPLIT_BANDS + 1]; /*Q-14*/
extern const Word16 sba_map_tc[11]; /*Q-0*/
@@ -121,10 +121,6 @@ extern const Word32 ivas_reverb_default_fc_fx[]; /*Q-16*/
extern const Word32 ivas_reverb_default_RT60_fx[]; /*Q-26*/
extern const Word32 ivas_reverb_default_DSR_fx[]; /*Q-30*/
-extern const float ivas_reverb_default_fc[];
-extern const float ivas_reverb_default_RT60[];
-extern const float ivas_reverb_default_DSR[];
-
extern const Word32 release_cnst_table[4][201]; // Q31
/*----------------------------------------------------------------------------------*
diff --git a/lib_rend/ivas_rom_rend_fx.c b/lib_rend/ivas_rom_rend_fx.c
index 2b46ff61137ad446f716adabec5072a7f9a9234e..d14be4afe9ba42309e1161e95b0740e249a70a62 100644
--- a/lib_rend/ivas_rom_rend_fx.c
+++ b/lib_rend/ivas_rom_rend_fx.c
@@ -76,11 +76,10 @@ const Word16 ap_lattice_delta_phi_fx[DIRAC_MAX_NUM_DECORR_FILTERS*DIRAC_MAX_DECO
29799 , 15800 , 24520 , 10977 , 25165 , 30177 , 16042 , 10060 , 30789 , 8397 , 19121 , 1339 , 29056 , 25160 , 12415 , 3611 , 25203 , 20991 , 4951 , 14580 , 13083 , 24188 ,
27295 , 14997 , 22841 , 12403 , 5735 , 19656 , 21619 , 18488 , 10360 , 12954 , 7563 , 27744 , 25189 , 5677 , 7107 , 28747 , 9026 , 11251 , 12524 , 29372 , 24412
};
-const Word16 ap_lattice_coeffs_1_fx[330] /* Q15 */ = { 26061, 16472, 6699, 13650, 15061, 8862, -6617, 917, 2222, -1724, -1270, -1880, 671, 12048, -19454, 17487, 6635, -63, 6392, -6044, -7663, 7474, -10790, -11098, -2611, 1716, -310, 5859, 6253, -15691, 1442, 25837, 4375, -5690, 17871, 22329, 10907, 9656, 10658, 1560, 5157, 3810, 7175, -6201, -10400, -24696, 25309, -16625, 9076, -22700, 7612, -11624, -511, -7309, 10174, -1147, 2810, -16383, 7053, 6599, -16238, -9884, 6439, 10687, -19476, 10319, 21911, 2511, 1497, -4089, -6660, -9738, 4122, -5881, -6611, 5279, 12977, 8745, 11684, 15995, -1843, 4563, -9712, -3697, 1225, -12039, -7087, -9088, 12760, 3772, -7879, -8880, 13982, -362, 4974, 8306, 7397, 16341, -4468, 14516, -9994, -1025, -352, 5581, 16268, -4583, -7929, -3435, 9645, -2219, -16128, -15978, 1192, 3584, 12981, -11562, -6747, -2719, -15172, -10135, 848, -3029, -4100, -5115, -160, 5847, 2935, 1468, 7805, -10227, -12802, -5850, 14890, 12681, -12742, -6481, 1164, 14922, -1782, 12452, 9534, 1599, 2576, 7265, -7128, 3974, -12998, -7159, -4170, -8831, -11279, -15238, -13808, -852, 7259, 11861, -11411, 9666, 11998, 2315, -2819, 8261, 5113, -2057, 13401, 7944, -9888, -2167, 12735, -15146, -5206, 7562, -3053, 1542, 2405, -10977, 751, 11619, 2372, 638, 11039, -15746, 5579, 8508, -12896, -11422, -3570, 9137, 12631, 11870, -10444, 11872, 9467, 9542, -9110, -14722, -9453, -13565, -13280, -9671, -8031, 82, 9433, 11410, -5844, -6767, 11504, -15800, 699, -16128, 1593, 14853, 3576, 7621, -15524, 4603, 11551, -3231, 4822, -1828, 3530, -7570, 11708, 11404, 7615, -10642, 5324, 1888, -1990, -319, -7346, -9252, -2144, 2119, 9187, -9335, -15417, 638, -14493, 12360, 14659, -9519, 11322, 12130, -10260, 3918, 9830, 13336, -9106, 14648, 6383, 5167, -7320, -4822, 12421, -7089, 4520, -13014, 2421, -8949, -14517, -5515, 11346, 1230, 2142, 5370, -4014, 11975, -10365, 3842, -9872, 5558, -11025, 8844, -13767, -10855, 16335, -12878, -15144, -10587, 15432, -11778, 8661, 7104, 16167, 4963, -10539, 15217, -11654, 13775, 6039, -9900, 4474, -8285, 6353, 9790, 7825, -12658, -5963, -2533, 4090, -8630, 12766, 147, 11134, 13605, 12378, 13114, 11548, -124, -6046, 14199, -7784, 4839, 13343, 2215, -8169, -11600, 10516, 13959, 10144, -6215, -6863, 5209, -2684, 12675, 5851, -13341, 7280, -4885, };
-const Word16 ap_lattice_coeffs_2_fx[132] /* Q15 */ = { 20764, 22321, -1619, 9395, 4784, 4436, -13439, -6775, -21527, -3334, 14296, 11135, -4305, -25354, -9883, 10733, 10886, 6745, 23514, -18100, -4919, 1787, 7848, -21249, -23653, 6205, 2234, 203, 2523, 1267, 13874, -3560, 14157, -13586, 9104, 13712, 2549, -9275, -11698, 151, -14504, -12200, 13216, 7963, 10301, 14565, 11387, 16254, 3552, 15380, -5579, 10692, 5641, 14428, 1914, 11130, -6388, 16096, -9217, -1412, -15810, -10977, -11015, 6437, -5394, 14499, -4429, -11612, 14815, -10198, -11391, 16329, -9469, 12334, -5830, 6407, 10940, -5003, 1744, 15000, 14499, 7708, -11310, -9374, 5093, 13283, 7113, -3537, 350, 12090, -16330, -16246, -7060, -3075, 10494, -453, 16036, 15427, -2157, 11366, 893, 4918, 15860, -16298, 5531, -16182, -5686, 10966, 8658, -13914, -10319, 8293, 13021, -16107, -14867, -15183, -626, 11, 10336, 15477, 3117, 9285, -7375, -3924, -15626, 1229, 11041, 16204, -2051, 5821, 15200, 16032, };
-const Word16 ap_lattice_coeffs_3_fx[66] /* Q15 */ = { 621, -6953, 13851, -13128, -3502, -805, 4587, 9161, 1060, 20726, 18957, -24071, 563, 433, -908, -11578, -15799, -16097, 14975, 5410, 15391, -6412, 14421, -15642, 11802, -16074, 15880, -5694, 247, 9115, 14234, 1977, -6347, -1104, 16260, 96, -15756, -3589, -760, 10639, -9570, -11670, -12012, 12481, -9887, 3614, 12575, 9960, -16373, -11455, 10969, -662, -14092, -5069, -12161, 10947, 11367, -5465, -7506, 3865, 11183, 16071, 16176, -12049, 13976, -1499, };
-
-const Word16 * const ap_lattice_coeffs_fx[DIRAC_DECORR_NUM_SPLIT_BANDS] =
+const Word32 ap_lattice_coeffs_1_fx[330] /* Q31 */ = { 1707955968, 1079539968, 439065920, 894568704, 987086592, 580795520, -433671424, 60123100, 145623008, -113015624, -83277272, -123237648, 43980464, 789623296, -1274971776, 1146041216, 434865440, -4194035, 418933248, -396120544, -502225568, 489841024, -707151360, -727382784, -171154448, 112504520, -20332376, 383985120, 409832224, -1028380544, 94536528, 1693286528, 286751360, -372925568, 1171218304, 1463361920, 714828608, 632831232, 698492672, 102256728, 338016064, 249692224, 470255968, -406406976, -681613440, -1618517632, 1658684160, -1089598848, 594810048, -1487723008, 498864736, -761839168, -33543694, -479015552, 666806528, -75234944, 184217584, -1073737536, 462267328, 432535424, -1064187648, -647809920, 422002016, 700395328, -1276386944, 676287680, 1435960064, 164589584, 98163624, -267984480, -436523296, -638210688, 270166336, -385436800, -433269856, 346019744, 850510912, 573156928, 765762624, 1048283392, -120804544, 299101536, -636524864, -242330640, 80326624, -789039168, -464483520, -595626048, 836273088, 247207584, -516360288, -582000256, 916374208, -23749022, 326015936, 544365632, 484824512, 1070984448, -292867392, 951343872, -655019008, -67237712, -23117662, 365821696, 1066178368, -300379264, -519686752, -225163664, 632096768, -145444768, -1056995776, -1047134528, 78157664, 234919680, 850736384, -757728896, -442194816, -178238992, -994355776, -664208128, 55589760, -198547744, -268733952, -335258720, -10494753, 383196992, 192384464, 96265248, 511571392, -670272576, -838996096, -383418176, 975855232, 831101952, -835100544, -424765824, 76321568, 977938304, -116844584, 816118976, 624840448, 104805792, 168871664, 476183040, -467180768, 260466144, -851865984, -469186528, -273299520, -578761856, -739202496, -998661504, -904981824, -55901148, 475768544, 777374080, -747846144, 633471168, 786354816, 151747632, -184790960, 541442880, 335149184, -134861968, 878260672, 520681024, -648033280, -142077520, 834621696, -992624896, -341192192, 495630624, -200100384, 101094944, 157629600, -719445696, 49263276, 761521344, 155458496, 41817948, 723487232, -1031938880, 365645600, 557622016, -845198016, -748587008, -233994112, 598808640, 827833472, 777923776, -684486784, 778044032, 620485312, 625355840, -597041280, -964868672, -619576960, -889000256, -870330048, -633834112, -526369728, 5433133, 618239040, 747816064, -383012288, -443491872, 753940736, -1035527360, 45870252, -1057006464, 104457896, 973415680, 234419312, 499502560, -1017436928, 301725760, 757045952, -211754768, 316049472, -119823144, 231367744, -496124544, 767317376, 747390912, 499083776, -697476928, 348923136, 123795992, -130425272, -20920786, -481433632, -606352768, -140537776, 138935744, 602089984, -611830976, -1010393216, 41841572, -949849216, 810060928, 960749824, -623839680, 742015744, 795013504, -672420096, 256821872, 644275136, 874015104, -596832960, 960008960, 418381344, 338664608, -479752128, -316038720, 814053056, -464590912, 296281888, -852937536, 158709776, -586499264, -951414720, -361479488, 743596288, 80622976, 140417520, 351974720, -263116144, 784855872, -679294144, 251841856, -646998144, 364266912, -722555264, 579635904, -902286720, -711452736, 1070569984, -843980416, -992532608, -693845504, 1011415424, -771940928, 567612160, 465568000, 1059568448, 325320160, -690744576, 997319296, -763801920, 902804288, 395774784, -648814912, 293208832, -542989120, 416409952, 641614400, 512836288, -829568640, -390839872, -166056320, 268091856, -565634304, 836672512, 9667971, 729723520, 891643776, 811214080, 859468032, 756829056, -8177617, -396275168, 930607744, -510143328, 317148960, 874476800, 145204256, -535395584, -760230656, 689206976, 914828032, 664809408, -407354016, -449784000, 341379040, -175941184, 830706816, 383501920, -874332928, 477147232, -320183360};
+const Word32 ap_lattice_coeffs_2_fx[132] /* Q31 */ = { 1360843264, 1462880896, -106124344, 615715776, 313579872, 290773568, -880779712, -444026592, -1410828032, -218497872, 936944960, 729753600, -282142848, -1661606912, -647739072, 703431872, 713452032, 442076704, 1541038592, -1186205568, -322414592, 117158120, 514363136, -1392593792, -1550156800, 406684000, 146426176, 13348758, 165409920, 83060376, 909276800, -233341280, 927820288, -890434752, 596656832, 898691840, 167097856, -607873152, -766668864, 9951439, -950562176, -799540352, 866157440, 521887904, 675097984, 954584384, 746287104, 1065244224, 232804400, 1007990144, -365686400, 700745408, 369704352, 945610048, 125449552, 729442240, -418684160, 1054884800, -604078592, -92599496, -1036132928, -719417728, -721895936, 421913952, -353525216, 950242176, -290318304, -761035968, 970948224, -668342016, -746551232, 1070181312, -620620608, 808379392, -382088896, 419923232, 716984640, -327914304, 114310552, 983047168, 950209984, 505204128, -741223296, -614390784, 333800576, 870574848, 466160704, -231842336, 22973780, 792393536, -1070215680, -1064756736, -462737632, -201582144, 687787456, -29725468, 1050991360, 1011065344, -141377440, 744899776, 58581208, 322307232, 1039409984, -1068139008, 362486656, -1060515456, -372648544, 718711232, 567440320, -911931072, -676298432, 543498048, 853369216, -1055627776, -974371328, -995053760, -41077068, 738734, 677385088, 1014353152, 204309440, 608543168, -483372800, -257186944, -1024072704, 80584320, 723596736, 1061954304, -134438912, 381504768, 996200512, 1050733696};
+const Word32 ap_lattice_coeffs_3_fx[66] /* Q31 */ = { 1360843264, 1462880896, -106124344, 615715776, 313579872, 290773568, -880779712, -444026592, -1410828032, -218497872, 936944960, 729753600, -282142848, -1661606912, -647739072, 703431872, 713452032, 442076704, 1541038592, -1186205568, -322414592, 117158120, 514363136, -1392593792, -1550156800, 406684000, 146426176, 13348758, 165409920, 83060376, 909276800, -233341280, 927820288, -890434752, 596656832, 898691840, 167097856, -607873152, -766668864, 9951439, -950562176, -799540352, 866157440, 521887904, 675097984, 954584384, 746287104, 1065244224, 232804400, 1007990144, -365686400, 700745408, 369704352, 945610048, 125449552, 729442240, -418684160, 1054884800, -604078592, -92599496, -1036132928, -719417728, -721895936, 421913952, -353525216, 950242176};
+const Word32 * const ap_lattice_coeffs_fx[DIRAC_DECORR_NUM_SPLIT_BANDS] =
{
&ap_lattice_coeffs_1_fx[0],
&ap_lattice_coeffs_2_fx[0],
@@ -562,42 +561,6 @@ const Word32 ivas_reverb_default_DSR_fx[IVAS_REVERB_DEFAULT_N_BANDS] /*Q30*/ =
66, 30, 28
};
-const float ivas_reverb_default_fc[IVAS_REVERB_DEFAULT_N_BANDS] =
-{
- 20.0f, 25.0f, 31.5f, 40.0f,
- 50.0f, 63.0f, 80.0f, 100.0f,
- 125.0f, 160.0f, 200.0f, 250.0f,
- 315.0f, 400.0f, 500.0f, 630.0f,
- 800.0f, 1000.0f, 1250.0f, 1600.0f,
- 2000.0f, 2500.0f, 3150.0f, 4000.0f,
- 5000.0f, 6300.0f, 8000.0f, 10000.0f,
- 12500.0f, 16000.0f, 20000.0f
-};
-
-const float ivas_reverb_default_RT60[IVAS_REVERB_DEFAULT_N_BANDS] =
-{
- 1.3622f, 1.4486f, 1.3168f, 1.5787f,
- 1.4766f, 1.3954f, 1.2889f, 1.3462f,
- 1.0759f, 1.0401f, 1.097f, 1.085f,
- 1.091f, 1.0404f, 1.0499f, 1.0699f,
- 1.1028f, 1.1714f, 1.1027f, 1.0666f,
- 1.055f, 1.0553f, 1.0521f, 1.0569f,
- 1.0421f, 0.97822f, 0.80487f, 0.75944f,
- 0.71945f, 0.61682f, 0.60031f
-};
-
-const float ivas_reverb_default_DSR[IVAS_REVERB_DEFAULT_N_BANDS] =
-{
- 1.8811e-08f, 2.1428e-08f, 1.3972e-08f, 1.51e-08f,
- 1.287e-08f, 1.8747e-08f, 2.413e-08f, 3.9927e-08f,
- 8.9719e-08f, 1.902e-07f, 3.702e-07f, 6.1341e-07f,
- 7.1432e-07f, 6.5331e-07f, 4.6094e-07f, 5.4683e-07f,
- 7.0134e-07f, 6.856e-07f, 7.114e-07f, 6.9604e-07f,
- 5.2939e-07f, 5.699e-07f, 6.1773e-07f, 5.7488e-07f,
- 4.7748e-07f, 2.7213e-07f, 1.3681e-07f, 1.0941e-07f,
- 6.2001e-08f, 2.8483e-08f, 2.6267e-08f
-};
-
const Word32 release_cnst_table[4][201] = // Q31
{
{
diff --git a/lib_rend/ivas_rotation_fx.c b/lib_rend/ivas_rotation_fx.c
index 1633f42d01cdc8314bf5e7ca4cc4be2a5929eb8c..d65dab4c1f5fb5c5f155142a5afde20489e2d7a9 100644
--- a/lib_rend/ivas_rotation_fx.c
+++ b/lib_rend/ivas_rotation_fx.c
@@ -1046,7 +1046,9 @@ void rotateFrame_shd_cldfb(
Word16 l = 0, m1 = 0, m2 = 0;
Word32 realRot[2 * HEADROT_ORDER + 1], imagRot[2 * HEADROT_ORDER + 1];
Word16 SHrotmat[HEADROT_SHMAT_DIM][HEADROT_SHMAT_DIM];
+#ifndef OPT_HEAD_ROT_REND_V1_BE
Word32 temp1, temp2;
+#endif /* OPT_HEAD_ROT_REND_V1_BE */
move16();
move16();
move16();
@@ -1095,12 +1097,19 @@ void rotateFrame_shd_cldfb(
move32();
FOR( m = m1; m < m2; m++ )
{
+#ifdef OPT_HEAD_ROT_REND_V1_BE
+ realRot[n - m1] = Madd_32_16_r( realRot[n - m1], Cldfb_RealBuffer[m][i][iBand], SHrotmat[n][m] ); // Q(x + 14 - 15)
+ move32();
+ imagRot[n - m1] = Madd_32_16_r( imagRot[n - m1], Cldfb_ImagBuffer[m][i][iBand], SHrotmat[n][m] ); // Q(x + 14 - 15)
+ move32();
+#else /* OPT_HEAD_ROT_REND_V1_BE */
temp1 = Mpy_32_16_r( Cldfb_RealBuffer[m][i][iBand], SHrotmat[n][m] ); // Q(x + 14 - 15)
temp2 = Mpy_32_16_r( Cldfb_ImagBuffer[m][i][iBand], SHrotmat[n][m] ); // Q(x + 14 - 15)
realRot[n - m1] = L_add( temp1, realRot[n - m1] ); // Q(x + 14 - 15)
move32();
imagRot[n - m1] = L_add( temp2, imagRot[n - m1] ); // Q(x + 14 - 15)
move32();
+#endif /* OPT_HEAD_ROT_REND_V1_BE */
}
}
/* write back the result */
@@ -1439,10 +1448,11 @@ ivas_error ivas_combined_orientation_open(
set_zero_fx( ( *hCombinedOrientationData )->chEneIIR_fx[1], MASA_FREQUENCY_BANDS );
set_zero_fx( ( *hCombinedOrientationData )->procChEneIIR_fx[0], MASA_FREQUENCY_BANDS );
set_zero_fx( ( *hCombinedOrientationData )->procChEneIIR_fx[1], MASA_FREQUENCY_BANDS );
- ( *hCombinedOrientationData )->q_chEneIIR = Q31;
- move16();
- ( *hCombinedOrientationData )->q_procChEneIIR = Q31;
- move16();
+ set16_fx( ( *hCombinedOrientationData )->q_chEneIIR[0], Q31, MASA_FREQUENCY_BANDS );
+ set16_fx( ( *hCombinedOrientationData )->q_chEneIIR[1], Q31, MASA_FREQUENCY_BANDS );
+ set16_fx( ( *hCombinedOrientationData )->q_procChEneIIR[0], Q31, MASA_FREQUENCY_BANDS );
+ set16_fx( ( *hCombinedOrientationData )->q_procChEneIIR[1], Q31, MASA_FREQUENCY_BANDS );
+
( *hCombinedOrientationData )->isExtOrientationFrozen = 0;
move16();
( *hCombinedOrientationData )->isHeadRotationFrozen = 0;
diff --git a/lib_rend/ivas_sba_rendering_fx.c b/lib_rend/ivas_sba_rendering_fx.c
index 5e097ab2bedc0622f73dbcc03bdb1431c21aeeab..8967421514c6e87aefe653eb5f38da671d270774 100644
--- a/lib_rend/ivas_sba_rendering_fx.c
+++ b/lib_rend/ivas_sba_rendering_fx.c
@@ -87,7 +87,11 @@ void ivas_sba_prototype_renderer_fx(
Word16 norm_q = 31; // to handle overflow
move16();
+#ifdef OPT_BIN_RENDERER_V1
+ FOR( Word16 i = 0; i < 2; i++ )
+#else /* OPT_BIN_RENDERER_V1 */
FOR( Word16 i = 0; i < 6; i++ )
+#endif /* OPT_BIN_RENDERER_V1 */
{
FOR( Word16 j = 0; j < CLDFB_SLOTS_PER_SUBFRAME; j++ )
{
@@ -95,22 +99,39 @@ void ivas_sba_prototype_renderer_fx(
}
}
norm_q = sub( sub( 31, norm_q ), 2 ); // to handle overflow
- Word16 q_inp[6][CLDFB_SLOTS_PER_SUBFRAME];
+ Word16 q_inp[2][CLDFB_SLOTS_PER_SUBFRAME];
+#ifdef OPT_BIN_RENDERER_V1
+ FOR( Word16 i = 0; i < 2; i++ )
+#else /* OPT_BIN_RENDERER_V1 */
FOR( Word16 i = 0; i < 6; i++ )
+#endif /* OPT_BIN_RENDERER_V1 */
{
FOR( Word16 j = 0; j < CLDFB_SLOTS_PER_SUBFRAME; j++ )
{
+#ifdef OPT_BIN_RENDERER_V1
+ q_inp[i][j] = s_min( L_norm_arr( inRe_fx[i][j], num_cldfb_bands ), L_norm_arr( inIm_fx[i][j], num_cldfb_bands ) );
+#else /* OPT_BIN_RENDERER_V1 */
q_inp[i][j] = s_min( L_norm_arr( inRe_fx[i][j], CLDFB_NO_CHANNELS_MAX ), L_norm_arr( inIm_fx[i][j], CLDFB_NO_CHANNELS_MAX ) );
+#endif /* OPT_BIN_RENDERER_V1 */
move16();
norm_q = s_min( q_inp[i][j], norm_q );
}
}
+#ifdef OPT_BIN_RENDERER_V1
+ FOR( Word16 i = 0; i < 2; i++ )
+#else /* OPT_BIN_RENDERER_V1 */
FOR( Word16 i = 0; i < 6; i++ )
+#endif /* OPT_BIN_RENDERER_V1 */
{
FOR( Word16 j = 0; j < CLDFB_SLOTS_PER_SUBFRAME; j++ )
{
- scale_sig32( inRe_fx[i][j], CLDFB_NO_CHANNELS_MAX, sub( norm_q, 2 ) ); // q_cldfb -> q_cldfb + 2 -norm_q
- scale_sig32( inIm_fx[i][j], CLDFB_NO_CHANNELS_MAX, sub( norm_q, 2 ) ); // q_cldfb -> q_cldfb + 2 -norm_q
+#ifdef OPT_BIN_RENDERER_V1
+ scale_sig32( inRe_fx[i][j], num_cldfb_bands, sub( norm_q, 2 ) ); // q_cldfb -> q_cldfb + 2 -norm_q
+ scale_sig32( inIm_fx[i][j], num_cldfb_bands, sub( norm_q, 2 ) ); // q_cldfb -> q_cldfb + 2 -norm_q
+#else /* OPT_BIN_RENDERER_V1 */
+ scale_sig32( inRe_fx[i][j], CLDFB_NO_CHANNELS_MAX, sub( norm_q, 2 ) ); // q_cldfb -> q_cldfb + 2 -norm_q
+ scale_sig32( inIm_fx[i][j], CLDFB_NO_CHANNELS_MAX, sub( norm_q, 2 ) ); // q_cldfb -> q_cldfb + 2 -norm_q
+#endif /* OPT_BIN_RENDERER_V1 */
q_cldfb[i][j] = sub( add( q_cldfb[i][j], norm_q ), 2 );
move16();
}
@@ -178,12 +199,21 @@ void ivas_sba_prototype_renderer_fx(
FOR( spar_band = bin2band->p_spar_start_bands[cldfb_band]; spar_band < num_spar_bands; spar_band++ )
{
/* accumulate contributions from all SPAR bands */
+#ifdef OPT_BIN_RENDERER_V1
+ cldfb_par_fx = Madd_32_32( cldfb_par_fx, mixer_mat_fx[out_ch][in_ch][spar_band], L_shl_sat( bin2band->pp_cldfb_weights_per_spar_band_fx[cldfb_band][spar_band], 9 ) ); // hMdDec->Q_mixer_matrix
+#else /* OPT_BIN_RENDERER_V1 */
cldfb_par_fx = L_add( cldfb_par_fx, Mpy_32_32( mixer_mat_fx[out_ch][in_ch][spar_band], bin2band->pp_cldfb_weights_per_spar_band_fx[cldfb_band][spar_band] ) ); // hMdDec->Q_mixer_matrix
+#endif /* OPT_BIN_RENDERER_V1 */
}
}
- out_re_fx[out_ch] = L_add( out_re_fx[out_ch], Mpy_32_32( inRe_fx[in_ch][ts][cldfb_band], cldfb_par_fx ) ); // hMdDec->Q_mixer_matrix+q_cldfb[i][j] -31
- out_im_fx[out_ch] = L_add( out_im_fx[out_ch], Mpy_32_32( inIm_fx[in_ch][ts][cldfb_band], cldfb_par_fx ) ); // hMdDec->Q_mixer_matrix+q_cldfb[i][j] -31
+#ifdef OPT_BIN_RENDERER_V1
+ out_re_fx[out_ch] = Madd_32_32( out_re_fx[out_ch], inRe_fx[in_ch][ts][cldfb_band], cldfb_par_fx ); // hMdDec->Q_mixer_matrix+q_cldfb[i][j] -31
+ out_im_fx[out_ch] = Madd_32_32( out_im_fx[out_ch], inIm_fx[in_ch][ts][cldfb_band], cldfb_par_fx ); // hMdDec->Q_mixer_matrix+q_cldfb[i][j] -31
+#else /* OPT_BIN_RENDERER_V1 */
+ out_re_fx[out_ch] = L_add( out_re_fx[out_ch], Mpy_32_32( inRe_fx[in_ch][ts][cldfb_band], cldfb_par_fx ) ); // hMdDec->Q_mixer_matrix+q_cldfb[i][j] -31
+ out_im_fx[out_ch] = L_add( out_im_fx[out_ch], Mpy_32_32( inIm_fx[in_ch][ts][cldfb_band], cldfb_par_fx ) ); // hMdDec->Q_mixer_matrix+q_cldfb[i][j] -31
+#endif /* OPT_BIN_RENDERER_V1 */
move32();
move32();
}
@@ -242,11 +272,41 @@ void ivas_sba_prototype_renderer_fx(
{
IF( EQ_16( st_ivas->nchan_transport, 1 ) ) /* Dual mono */
{
+#ifdef OPT_BIN_RENDERER_V1
+ Copy32( inRe_fx[0][ts], inRe_fx[1][ts], num_cldfb_bands );
+ Copy32( inIm_fx[0][ts], inIm_fx[1][ts], num_cldfb_bands );
+#else /* OPT_BIN_RENDERER_V1 */
Copy32( inRe_fx[0][ts], inRe_fx[1][ts], CLDFB_NO_CHANNELS_MAX );
Copy32( inIm_fx[0][ts], inIm_fx[1][ts], CLDFB_NO_CHANNELS_MAX );
+#endif /* OPT_BIN_RENDERER_V1 */
}
ELSE IF( EQ_16( st_ivas->nchan_transport, 2 ) ) /* Opposing cardioids */
{
+#ifdef OPT_BIN_RENDERER_V1
+ Word32 temp_signal_fx;
+ FOR( Word16 idx = 0; idx < num_cldfb_bands; idx++ )
+ {
+ Word32 op1 = L_shr( inRe_fx[0][ts][idx], 1 );
+ Word32 op2 = L_shr( inRe_fx[1][ts][idx], 1 );
+ temp_signal_fx = L_add( op1, op2 ); // q_cldfb[][]-1
+ inRe_fx[1][ts][idx] = L_sub( op1, op2 ); // q_cldfb[][]-1
+ move32();
+ inRe_fx[0][ts][idx] = temp_signal_fx;
+ move32();
+ }
+
+ FOR( Word16 idx = 0; idx < num_cldfb_bands; idx++ )
+ {
+ Word32 op1 = L_shr( inIm_fx[0][ts][idx], 1 );
+ Word32 op2 = L_shr( inIm_fx[1][ts][idx], 1 );
+ temp_signal_fx = L_add( op1, op2 ); // q_cldfb[][]-1
+ move32();
+ inIm_fx[1][ts][idx] = L_sub( op1, op2 ); // q_cldfb[][]-1
+ move32();
+ inIm_fx[0][ts][idx] = temp_signal_fx;
+ move32();
+ }
+#else /* OPT_BIN_RENDERER_V1 */
Word32 temp_signal_fx[CLDFB_NO_CHANNELS_MAX];
FOR( Word16 idx = 0; idx < CLDFB_NO_CHANNELS_MAX; idx++ )
{
@@ -267,6 +327,7 @@ void ivas_sba_prototype_renderer_fx(
inIm_fx[0][ts][idx] = temp_signal_fx[idx];
move32();
}
+#endif /* OPT_BIN_RENDERER_V1 */
}
}
}
diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h
index 0515e403885d5857306fb3683826d9e1994ece83..f8dad9a669187ca30ba2c63afc650d06ce6a72e6 100644
--- a/lib_rend/ivas_stat_rend.h
+++ b/lib_rend/ivas_stat_rend.h
@@ -120,8 +120,8 @@ typedef struct dirac_decorr_params_structure
Word16 *pre_delay;
Word16 *filter_length;
- Word16 *filter_coeff_num_real_fx; /* Q12 */
- Word16 *filter_coeff_den_real_fx; /* Q12 */
+ Word32 *filter_coeff_num_real_fx; /* Q28 */
+ Word32 *filter_coeff_den_real_fx; /* Q28 */
Word16 *phase_coeff_real_fx; /* Q14 */
Word16 *phase_coeff_imag_fx; /* Q14 */
Word16 *split_frequency_bands;
@@ -352,6 +352,8 @@ typedef struct dirac_output_synthesis_state_structure
Word16 q_cy_cross_dir_smooth; /* Target cross PSD of direct sound. Size: num_freq_bands*num_channels. */
Word16 q_cy_auto_diff_smooth; /* Target auto PSD of diffuse sound. Size: num_freq_bands*num_channels. */
+ Word16 *Q_temp_cy_cross_dir_smooth_fx;
+
Word16 cy_auto_dir_smooth_len; /* Target auto PSD of direct sound. Size: num_freq_bands*num_channels. */
Word16 cy_cross_dir_smooth_len; /* Target cross PSD of direct sound. Size: num_freq_bands*num_channels. */
Word16 cy_auto_diff_smooth_len; /* Target auto PSD of diffuse sound. Size: num_freq_bands*num_channels. */
@@ -395,9 +397,9 @@ typedef struct
Word16 q_total_hi_power;
Word32 sum_power_fx[MASA_SUM_FREQ_RANGE_BINS]; /* Q(q_sum_power) */
- Word16 q_sum_power;
+ Word16 exp_sum_power[MASA_SUM_FREQ_RANGE_BINS];
Word32 total_power_fx[MASA_SUM_FREQ_RANGE_BINS]; /* Q(q_total_power) */
- Word16 q_total_power;
+ Word16 exp_total_power[MASA_SUM_FREQ_RANGE_BINS];
Word32 subtract_power_y_fx; /* Q(q_subtract_power_y) */
Word16 q_subtract_power_y;
@@ -835,9 +837,9 @@ typedef struct ivas_combined_orientation_struct
Word32 Rmat_fx[MAX_PARAM_SPATIAL_SUBFRAMES][3][3]; /* Q30 */
Word32 Rmat_prev_fx[3][3]; /* Q30 */
Word32 chEneIIR_fx[2][MASA_FREQUENCY_BANDS]; /* independent of the format. MASA bands are suitable for the task and readily available in ROM. */ /* Q(q_chEneIIR) */
- Word16 q_chEneIIR;
+ Word16 q_chEneIIR[2][MASA_FREQUENCY_BANDS];
Word32 procChEneIIR_fx[2][MASA_FREQUENCY_BANDS]; /* Q(q_procChEneIIR) */
- Word16 q_procChEneIIR;
+ Word16 q_procChEneIIR[2][MASA_FREQUENCY_BANDS];
Word16 shd_rot_max_order;
IVAS_VECTOR3 listenerPos[MAX_PARAM_SPATIAL_SUBFRAMES];
IVAS_QUATERNION Quaternion_frozen_ext;
@@ -1259,8 +1261,8 @@ typedef struct
Word16 hrf_right_prev_e;
Word32 azim_prev_fx;
Word32 elev_prev_fx;
- Word16 Gain_fx; // Q14
- Word16 prevGain_fx; // Q14
+ Word32 Gain_fx; // Q30
+ Word32 prevGain_fx; // Q30
} TDREND_SRC_t;
@@ -1563,9 +1565,8 @@ typedef struct ivas_mcmasa_ana_data_structure
MASA_DECODER_EXT_OUT_META_HANDLE hMasaOut;
SPHERICAL_GRID_DATA *sph_grid16;
- Word32 energy_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];
+ Word32 energy_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; /*Exp :energy_e[][]*/
Word16 energy_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];
- Word16 energy_exp[MAX_PARAM_SPATIAL_SUBFRAMES];
} MCMASA_ANA_DATA, *MCMASA_ANA_HANDLE;
@@ -1594,14 +1595,13 @@ typedef struct ivas_omasa_ana_data_structure
MASA_DECODER_EXT_OUT_META_HANDLE hMasaOut;
SPHERICAL_GRID_DATA *sph_grid16;
- Word32 **direction_vector_m_fx[DIRAC_NUM_DIMS]; /* Average direction vector */
- Word16 direction_vector_m_q; /* Average direction vector */
+ Word32 **direction_vector_m_fx[DIRAC_NUM_DIMS]; /* Average direction vector */
+ Word16 **direction_vector_e[MAX_PARAM_SPATIAL_SUBFRAMES]; /* Average direction vector */
Word32 ism_azimuth_fx[MAX_NUM_OBJECTS];
Word32 ism_elevation_fx[MAX_NUM_OBJECTS];
- Word32 energy_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];
- Word16 energy_q;
- Word16 energy_e[MAX_PARAM_SPATIAL_SUBFRAMES];
+ Word32 energy_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; /*Exp :energy_e[][]*/
+ Word16 energy_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];
Word16 interpolator_fx[L_FRAME48k];
Word32 prev_object_dm_gains_fx[MAX_NUM_OBJECTS][MASA_MAX_TRANSPORT_CHANNELS];
@@ -1609,7 +1609,7 @@ typedef struct ivas_omasa_ana_data_structure
Word32 buffer_energy_fx[DIRAC_NO_COL_AVG_DIFF * MASA_FREQUENCY_BANDS];
Word16 buffer_intensity_real_q[DIRAC_NO_COL_AVG_DIFF];
Word16 buffer_energy_q[DIRAC_NO_COL_AVG_DIFF];
- Word16 chnlToFoaMtx_fx[FOA_CHANNELS][MCMASA_MAX_ANA_CHANS]; // Q15
+ Word32 chnlToFoaMtx_fx[FOA_CHANNELS][MCMASA_MAX_ANA_CHANS]; // Q15
} OMASA_ANA_DATA, *OMASA_ANA_HANDLE;
@@ -1626,20 +1626,22 @@ typedef struct ivas_dirac_ana_data_structure
HANDLE_CLDFB_FILTER_BANK cldfbAnaEnc[DIRAC_MAX_ANA_CHANS];
/* DirAC parameter estimation */
- Word32 **direction_vector_m_fx[DIRAC_NUM_DIMS]; /* Average direction vector */
+ Word32 **direction_vector_m_fx[DIRAC_NUM_DIMS]; /* Average direction vector */
+ Word16 **direction_vector_e[MAX_PARAM_SPATIAL_SUBFRAMES]; /* Average direction vector */
Word16 band_grouping[MASA_FREQUENCY_BANDS + 1];
Word16 block_grouping[5];
/* diffuseness */
Word16 index_buffer_intensity;
Word32 *buffer_intensity_real_fx[DIRAC_NUM_DIMS][DIRAC_NO_COL_AVG_DIFF];
+ Word16 buffer_intensity_real_q[DIRAC_NO_COL_AVG_DIFF];
Word32 buffer_energy_fx[DIRAC_NO_COL_AVG_DIFF * MASA_FREQUENCY_BANDS];
+ Word16 buffer_energy_q[DIRAC_NO_COL_AVG_DIFF];
MASA_DECODER_EXT_OUT_META_HANDLE hMasaOut;
SPHERICAL_GRID_DATA *sph_grid16;
Word32 energy_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];
Word16 energy_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];
- Word16 energy_exp[MAX_PARAM_SPATIAL_SUBFRAMES];
} DIRAC_ANA_DATA, *DIRAC_ANA_HANDLE;
/*----------------------------------------------------------------------------------*
@@ -1655,8 +1657,8 @@ typedef struct ivas_masa_prerend_data_structure
MASA_DECODER_EXT_OUT_META_HANDLE hMasaOut;
SPHERICAL_GRID_DATA *sph_grid16;
- Word32 energy_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];
- Word16 energy_e[MAX_PARAM_SPATIAL_SUBFRAMES];
+ Word32 energy_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; /*Exp :energy_e[][]*/
+ Word16 energy_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];
} MASA_PREREND_DATA, *MASA_PREREND_HANDLE;
diff --git a/lib_rend/ivas_vbap_fx.c b/lib_rend/ivas_vbap_fx.c
index 7495953e3e462f5eca9be008502a81e7be8a6656..cfcbc67603388e210e713d9b2f2ea406795f9867 100644
--- a/lib_rend/ivas_vbap_fx.c
+++ b/lib_rend/ivas_vbap_fx.c
@@ -578,7 +578,11 @@ void vbap_determine_gains_fx(
move32();
FOR( ch = 0; ch < 3; ch++ )
{
+#ifdef OPT_SBA_REND_V1_BE
+ gain_ene_fx = Madd_32_32( gain_ene_fx, gain_triplet_fx[ch], gain_triplet_fx[ch] ); /* Q(2 * VBAP_VS_TRIPLET.q_inverse_matrix - 31) */
+#else /* OPT_SBA_REND_V1_BE */
gain_ene_fx = L_add( gain_ene_fx, Mpy_32_32( gain_triplet_fx[ch], gain_triplet_fx[ch] ) ); /* Q(2 * VBAP_VS_TRIPLET.q_inverse_matrix - 31) */
+#endif /* OPT_SBA_REND_V1_BE */
}
norm_value_fx = Isqrt( L_shr( gain_ene_fx, 1 ) ); /* Q(31 - (2 * VBAP_VS_TRIPLET.q_inverse_matrix - 31 - 1) / 2 ) = Q(47 - VBAP_VS_TRIPLET.q_inverse_matrix) */
@@ -681,9 +685,35 @@ static UWord8 vector_matrix_multiply_3x3_fx(
Word32 *result, /* o : output vector Q(q_matrix) */
Word16 q_matrix )
{
- result[0] = Mpy_32_16_1( matrix[0][0], src_vector[0] ); /* Q(q_matrix) */
- result[0] = L_add( result[0], Mpy_32_16_1( matrix[1][0], src_vector[1] ) ); /* Q(q_matrix) */
- result[0] = L_add( result[0], Mpy_32_16_1( matrix[2][0], src_vector[2] ) ); /* Q(q_matrix) */
+#ifdef OPT_SBA_REND_V1_BE
+ Word32 pointzero_one = Mpy_32_16_1( L_lshl( 1, q_matrix ), -327 /* -0.01 in Q15 */ );
+ result[0] = Madd_32_16( Madd_32_16( Mpy_32_16_1( matrix[0][0], src_vector[0] ), matrix[1][0], src_vector[1] ), matrix[2][0], src_vector[2] ); /* Q(q_matrix) */
+ move32();
+
+ IF( LT_32( result[0], pointzero_one ) )
+ {
+ return 0;
+ }
+
+ result[1] = Madd_32_16( Madd_32_16( Mpy_32_16_1( matrix[0][1], src_vector[0] ), matrix[1][1], src_vector[1] ), matrix[2][1], src_vector[2] ); /* Q(q_matrix) */
+ move32();
+
+ IF( LT_32( result[1], pointzero_one ) )
+ {
+ return 0;
+ }
+
+ result[2] = Madd_32_16( Madd_32_16( Mpy_32_16_1( matrix[0][2], src_vector[0] ), matrix[1][2], src_vector[1] ), matrix[2][2], src_vector[2] ); /* Q(q_matrix) */
+ move32();
+
+ IF( LT_32( result[2], pointzero_one ) )
+ {
+ return 0;
+ }
+#else /* OPT_SBA_REND_V1_BE */
+ result[0] = Mpy_32_16_1( matrix[0][0], src_vector[0] ); /* Q(q_matrix) */
+ result[0] = L_add( result[0], Mpy_32_16_1( matrix[1][0], src_vector[1] ) ); /* Q(q_matrix) */
+ result[0] = L_add( result[0], Mpy_32_16_1( matrix[2][0], src_vector[2] ) ); /* Q(q_matrix) */
move32();
move32();
move32();
@@ -716,7 +746,7 @@ static UWord8 vector_matrix_multiply_3x3_fx(
{
return 0;
}
-
+#endif /* OPT_SBA_REND_V1_BE */
return 1;
}
diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend_fx.c
similarity index 99%
rename from lib_rend/lib_rend.c
rename to lib_rend/lib_rend_fx.c
index 6f85b8fa067269e868effe955823a26e969ab46f..a77dd1be4ee83d100317939be7e589cca92c3243 100644
--- a/lib_rend/lib_rend.c
+++ b/lib_rend/lib_rend_fx.c
@@ -4581,6 +4581,12 @@ static void renderBufferChannelLerp_fx(
move32();
move32();
BREAK;
+ case NUM_SAMPLES_640:
+ tmp = Q31_BY_NUM_SAMPLES_640;
+ tmp1 = 639; /* NUM_SAMPLES_640 - 1 */
+ move32();
+ move32();
+ BREAK;
case NUM_SAMPLES_320:
tmp = Q31_BY_NUM_SAMPLES_320;
tmp1 = 319; /* NUM_SAMPLES_320 - 1 */
@@ -5532,53 +5538,32 @@ static void renderIsmToMasa(
Word16 *exp )
{
Word32 tmpRendBuffer_fx[MAX_NUM_OBJECTS][L_FRAME48k];
- Word16 i, j;
- Word16 q_fact;
+ Word16 i, guard_bits, q_min, q_diff;
push_wmops( "renderIsmToMasa" );
- FOR( i = 0; i < MAX_NUM_OBJECTS; i++ )
- {
- set32_fx( tmpRendBuffer_fx[i], 0, L_FRAME48k );
- }
-
copyBufferTo2dArray_fx( ismInput->base.inputBuffer, tmpRendBuffer_fx );
- Word16 input_e[MAX_NUM_OBJECTS], max_e;
- FOR( i = 0; i < MAX_NUM_OBJECTS; i++ )
- {
- input_e[i] = sub( 31, add( getScaleFactor32( tmpRendBuffer_fx[i], L_FRAME48k ), *outAudio.pq_fact ) );
- move16();
- }
-
- Word16 guard_bits = find_guarded_bits_fx( L_FRAME48k );
- max_e = input_e[0];
+ q_min = MAX_16;
move16();
- FOR( i = 1; i < MAX_NUM_OBJECTS; i++ )
+ FOR( i = 0; i < ismInput->base.inputBuffer.config.numChannels; i++ )
{
- if ( LT_16( max_e, input_e[0] ) )
- {
- max_e = input_e[i];
- move16();
- }
+ q_min = s_min( q_min, L_norm_arr( tmpRendBuffer_fx[i], ismInput->base.inputBuffer.config.numSamplesPerChannel ) );
}
- FOR( i = 0; i < MAX_NUM_OBJECTS; i++ )
+ guard_bits = find_guarded_bits_fx( ismInput->base.inputBuffer.config.numSamplesPerChannel );
+ q_min = sub( add( q_min, *outAudio.pq_fact ), guard_bits );
+ q_diff = sub( q_min, *outAudio.pq_fact );
+
+ FOR( i = 0; i < ismInput->base.inputBuffer.config.numChannels; i++ )
{
- FOR( j = 0; j < L_FRAME48k; j++ )
- {
- tmpRendBuffer_fx[i][j] = L_shr( tmpRendBuffer_fx[i][j], add( sub( max_e, sub( 31, *outAudio.pq_fact ) ), guard_bits ) ); /* Q(31 - (max_e + guard_bits)) */
- move32();
- }
+ scale_sig32( tmpRendBuffer_fx[i], ismInput->base.inputBuffer.config.numSamplesPerChannel, q_diff ); // *outAudio.pq_fact -> q_min
}
- max_e = add( max_e, guard_bits );
- q_fact = sub( Q31, max_e );
-
- ivas_omasa_ana_fx( ismInput->hOMasa, tmpRendBuffer_fx, &q_fact, ismInput->base.inputBuffer.config.numSamplesPerChannel, outAudio.config.numChannels, ismInput->base.inputBuffer.config.numChannels );
+ ivas_omasa_ana_fx( ismInput->hOMasa, tmpRendBuffer_fx, &q_min, ismInput->base.inputBuffer.config.numSamplesPerChannel, outAudio.config.numChannels, ismInput->base.inputBuffer.config.numChannels );
- *exp = q_fact;
+ *exp = q_min;
move16();
accumulate2dArrayToBuffer_fx( tmpRendBuffer_fx, &outAudio );
@@ -5646,11 +5631,6 @@ static ivas_error renderInputIsm(
BREAK;
case IVAS_REND_AUDIO_CONFIG_TYPE_MASA:
renderIsmToMasa( ismInput, outAudio, &exp );
- FOR( Word16 block_m_idx = 0; block_m_idx < MAX_PARAM_SPATIAL_SUBFRAMES; block_m_idx++ )
- {
- ismInput->hOMasa->energy_e[block_m_idx] = sub( 31, ismInput->hOMasa->energy_q );
- move16();
- }
BREAK;
default:
return IVAS_ERR_INVALID_OUTPUT_FORMAT;
@@ -5737,6 +5717,9 @@ static ivas_error renderLfeToBinaural_fx(
ELSE
{
/* no LFE to render */
+#ifdef FIX_1740_MISING_POP_WMOPS
+ pop_wmops();
+#endif
return IVAS_ERR_OK;
}
@@ -6688,7 +6671,6 @@ static void renderMasaToMasa(
Word16 mrange[2];
Word16 brange[2];
Word16 numAnalysisChannels;
- Word16 tmp_energy_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];
copyBufferTo2dArray_fx( masaInput->base.inputBuffer, tmpBuffer_fx );
Word16 q_cldfb = *outAudio.pq_fact;
Word16 q_cldfb_out = *outAudio.pq_fact;
@@ -6711,6 +6693,7 @@ static void renderMasaToMasa(
move16();
set_zero_fx( masaInput->hMasaPrerend->energy_fx[block_m_idx], MASA_FREQUENCY_BANDS );
+ set16_fx( masaInput->hMasaPrerend->energy_e[block_m_idx], 0, MASA_FREQUENCY_BANDS );
FOR( ts = mrange[0]; ts < mrange[1]; ts++ )
{
@@ -6765,30 +6748,14 @@ static void renderMasaToMasa(
FOR( i = 0; i < numAnalysisChannels; i++ )
{
Word32 temp = L_add( Mpy_32_32( Chan_RealBuffer_fx[0][j], Chan_RealBuffer_fx[0][j] ), Mpy_32_32( Chan_ImagBuffer_fx[0][j], Chan_ImagBuffer_fx[0][j] ) ); /* 2 * Q(q_cldfb_out + scale_factor) - 31 */
- masaInput->hMasaPrerend->energy_fx[block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( masaInput->hMasaPrerend->energy_fx[block_m_idx][band_m_idx], tmp_energy_e[block_m_idx][band_m_idx], temp, shl( q_add, 1 ), &tmp_energy_e[block_m_idx][band_m_idx] );
+ masaInput->hMasaPrerend->energy_fx[block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( masaInput->hMasaPrerend->energy_fx[block_m_idx][band_m_idx], masaInput->hMasaPrerend->energy_e[block_m_idx][band_m_idx], temp, shl( q_add, 1 ), &masaInput->hMasaPrerend->energy_e[block_m_idx][band_m_idx] );
move32();
}
}
}
}
}
- FOR( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ )
- {
- Word16 max_e = MIN_16;
- move16();
- FOR( j = 0; j < MASA_FREQUENCY_BANDS; j++ )
- {
- max_e = s_max( max_e, tmp_energy_e[i][j] );
- }
- masaInput->hMasaPrerend->energy_e[i] = max_e;
- move16();
- FOR( j = 0; j < MASA_FREQUENCY_BANDS; j++ )
- {
- masaInput->hMasaPrerend->energy_fx[i][j] = L_shr( masaInput->hMasaPrerend->energy_fx[i][j], sub( max_e, tmp_energy_e[i][j] ) ); /* Q(31 - max_e) */
- move32();
- }
- }
/* Copy audio channels if mismatch in number of transports */
test();
test();
@@ -7086,8 +7053,8 @@ ivas_error IVAS_REND_MergeMasaMetadata(
MASA_DECODER_EXT_OUT_META_HANDLE inMeta2;
Word32( *inEne1_fx )[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];
Word32( *inEne2_fx )[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];
- Word16 *inEne1_e;
- Word16 *inEne2_e;
+ Word16( *inEne1_e )[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];
+ Word16( *inEne2_e )[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];
IF( hIvasRend == NULL )
{
@@ -7097,27 +7064,31 @@ ivas_error IVAS_REND_MergeMasaMetadata(
/* Input1 metadata and energy */
IF( EQ_32( inputType1, IVAS_REND_AUDIO_CONFIG_TYPE_OBJECT_BASED ) )
{
+
*hMasaExtOutMeta = hIvasRend->inputsIsm->hOMasa->hMasaOut;
inEne1_fx = &( hIvasRend->inputsIsm->hOMasa->energy_fx );
- inEne1_e = ( hIvasRend->inputsIsm->hOMasa->energy_e );
+ inEne1_e = &( hIvasRend->inputsIsm->hOMasa->energy_e );
}
ELSE IF( EQ_32( inputType1, IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) )
{
+
*hMasaExtOutMeta = hIvasRend->inputsMc->hMcMasa->hMasaOut;
inEne1_fx = &( hIvasRend->inputsMc->hMcMasa->energy_fx );
- inEne1_e = ( hIvasRend->inputsMc->hMcMasa->energy_exp );
+ inEne1_e = &( hIvasRend->inputsMc->hMcMasa->energy_e );
}
ELSE IF( EQ_32( inputType1, IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS ) )
{
+
*hMasaExtOutMeta = hIvasRend->inputsSba->hDirAC->hMasaOut;
inEne1_fx = &( hIvasRend->inputsSba->hDirAC->energy_fx );
- inEne1_e = ( hIvasRend->inputsSba->hDirAC->energy_exp );
+ inEne1_e = &( hIvasRend->inputsSba->hDirAC->energy_e );
}
ELSE IF( EQ_32( inputType1, IVAS_REND_AUDIO_CONFIG_TYPE_MASA ) )
{
+
*hMasaExtOutMeta = hIvasRend->inputsMasa->hMasaPrerend->hMasaOut;
inEne1_fx = &( hIvasRend->inputsMasa->hMasaPrerend->energy_fx );
- inEne1_e = ( hIvasRend->inputsMasa->hMasaPrerend->energy_e );
+ inEne1_e = &( hIvasRend->inputsMasa->hMasaPrerend->energy_e );
}
ELSE
{
@@ -7129,25 +7100,26 @@ ivas_error IVAS_REND_MergeMasaMetadata(
{
inMeta2 = hIvasRend->inputsIsm->hOMasa->hMasaOut;
inEne2_fx = &( hIvasRend->inputsIsm->hOMasa->energy_fx );
- inEne2_e = ( hIvasRend->inputsIsm->hOMasa->energy_e );
+ inEne2_e = &( hIvasRend->inputsIsm->hOMasa->energy_e );
}
ELSE IF( EQ_32( inputType2, IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) )
{
inMeta2 = hIvasRend->inputsMc->hMcMasa->hMasaOut;
inEne2_fx = &( hIvasRend->inputsMc->hMcMasa->energy_fx );
- inEne2_e = ( hIvasRend->inputsMc->hMcMasa->energy_exp );
+ inEne2_e = &( hIvasRend->inputsMc->hMcMasa->energy_e );
}
ELSE IF( EQ_32( inputType2, IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS ) )
{
inMeta2 = hIvasRend->inputsSba->hDirAC->hMasaOut;
inEne2_fx = &( hIvasRend->inputsSba->hDirAC->energy_fx );
- inEne2_e = ( hIvasRend->inputsSba->hDirAC->energy_exp );
+ inEne2_e = &( hIvasRend->inputsSba->hDirAC->energy_e );
}
ELSE IF( EQ_32( inputType2, IVAS_REND_AUDIO_CONFIG_TYPE_MASA ) )
{
+
inMeta2 = hIvasRend->inputsMasa->hMasaPrerend->hMasaOut;
inEne2_fx = &( hIvasRend->inputsMasa->hMasaPrerend->energy_fx );
- inEne2_e = ( hIvasRend->inputsMasa->hMasaPrerend->energy_e );
+ inEne2_e = &( hIvasRend->inputsMasa->hMasaPrerend->energy_e );
}
ELSE
{
@@ -7155,7 +7127,7 @@ ivas_error IVAS_REND_MergeMasaMetadata(
}
/* Merge metadata */
- ivas_prerend_merge_masa_metadata_fx( *hMasaExtOutMeta, *hMasaExtOutMeta, inputType1, *inEne1_fx, inEne1_e, inMeta2, inputType2, *inEne2_fx, inEne2_e );
+ ivas_prerend_merge_masa_metadata_fx( *hMasaExtOutMeta, *hMasaExtOutMeta, inputType1, *inEne1_fx, *inEne1_e, inMeta2, inputType2, *inEne2_fx, *inEne2_e );
IF( EQ_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_MASA1 ) )