diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000000000000000000000000000000000000..63eef4d68ff2e0e1b002d8415c21316d7698c67d
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,24 @@
+# Default behavior. Converts all text files to use LF in repository.
+* text=auto
+
+# List all known generic text files
+*.c text
+*.csv text
+*.h text
+*.json text
+*.m text
+*.md text
+*.prm text
+*.py text
+*.txt text
+
+# Set Windows specific text files to always use CRLF in working tree.
+*.bat text eol=crlf
+*.cmd text eol=crlf
+*.sln text eol=crlf
+*.vcxproj text eol=crlf
+*.vcxproj.filters text eol=crlf
+
+# Set Unix specific text files to always use LF (also covers Windows subsystem for Linux) in working tree
+*.sh text eol=lf
+
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 7e06c92b3ec9e993ed7680758fc214a2e3704874..d630d11ba03514442255c935617bc8f3183eaa2a 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1455,11 +1455,15 @@ split-rendering-pytest-on-merge-request:
# ---------------------------------------------------------------
.set-reference-for-basop-port-branch: &set-reference-for-basop-port-branch
- - if [ $CI_MERGE_REQUEST_TARGET_BRANCH_NAME = "main-pc" ] && [[ ! "$CI_MERGE_REQUEST_TITLE" =~ \[skip[[:space:]_-]name[[:space:]_-]check\] ]] && [[ ! "$CI_MERGE_REQUEST_TITLE" =~ \[CI\] ]]; then
- - *update-scripts-repo
+ - if [ $CI_MERGE_REQUEST_TARGET_BRANCH_NAME = "main-pc" ]; then
+ - if [[ ! "$CI_MERGE_REQUEST_TITLE" =~ \[skip[[:space:]_-]name[[:space:]_-]check\] ]] && [[ ! "$CI_MERGE_REQUEST_TITLE" =~ \[CI\] ]]; then
+ - *update-scripts-repo
# a bit awkward: write to file + standard out first so that the error message is visivle in case of failure. Then fill the variable from the file
- - ci/get_float_ref_branch_name.sh $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME | tee tmp_ref_branch.txt
- - FLOAT_REF_BRANCH=$(cat tmp_ref_branch.txt)
+ - ci/get_float_ref_branch_name.sh $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME | tee tmp_ref_branch.txt
+ - FLOAT_REF_BRANCH=$(cat tmp_ref_branch.txt)
+ - else
+ - FLOAT_REF_BRANCH="float-pc"
+ - fi
- fi
### jobs that check for bitexactness of fx encoder and decoder
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
new file mode 100644
index 0000000000000000000000000000000000000000..94bb71fb347b5349d9933564dbd35964e9daa0b7
--- /dev/null
+++ b/.gitlab-ci/variables.yml
@@ -0,0 +1,65 @@
+variables:
+ EVS_BE_TEST_DIR_BASOP: "/usr/local/be_2_evs_basop"
+ FLOAT_REF_BRANCH: "ivas-float-update"
+ SCRIPTS_DIR: "/usr/local/scripts"
+ LONG_TEST_SUITE: "tests/codec_be_on_mr_nonselection tests/renderer --param_file scripts/config/self_test_ltv.prm --use_ltv"
+ LONG_TEST_SUITE_NO_RENDERER: "tests/codec_be_on_mr_nonselection --param_file scripts/config/self_test_ltv.prm --use_ltv"
+ SHORT_TEST_SUITE: "tests/codec_be_on_mr_nonselection"
+ SHORT_TEST_SUITE_ENCODER: "tests/codec_be_on_mr_nonselection/test_param_file.py --param_file scripts/config/self_test_basop_encoder.prm"
+ LONG_TEST_SUITE_ENCODER: "tests/codec_be_on_mr_nonselection/test_param_file.py --param_file scripts/config/self_test_ltv_basop_encoder.prm"
+ TEST_SUITE: ""
+ # These path variables are used by the pytest calls.
+ # They can be overwritten in the job templates to e.g. only test encoder or decoder in the chain
+ DUT_ENCODER_PATH: "./IVAS_cod"
+ DUT_DECODER_PATH: "./IVAS_dec"
+ REF_ENCODER_PATH: "./IVAS_cod_ref"
+ REF_DECODER_PATH: "./IVAS_dec_ref"
+ MERGE_TARGET_ENCODER_PATH: "./IVAS_cod_merge_target"
+ MERGE_TARGET_DECODER_PATH: "./IVAS_dec_merge_target"
+ # These path variables are used for building the binaries
+ # They should never be overwritten!
+ REF_ENCODER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./IVAS_cod_ref"
+ REF_DECODER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./IVAS_dec_ref"
+ MERGE_TARGET_ENCODER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./IVAS_cod_merge_target"
+ MERGE_TARGET_DECODER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./IVAS_dec_merge_target"
+ LEVEL_SCALING: "1.0"
+ BASOP_CI_BRANCH_PC_REPO: "basop-ci-branch"
+ PRM_FILES: "scripts/config/self_test.prm scripts/config/self_test_ltv.prm"
+ TESTCASE_TIMEOUT_STV: 900
+ TESTCASE_TIMEOUT_LTV: 2400
+ TESTCASE_TIMEOUT_LTV_SANITIZERS: 10800
+ CI_REGRESSION_THRESH_MLD: "0.1"
+ CI_REGRESSION_THRESH_MAX_ABS_DIFF: "50"
+ CI_REGRESSION_THRESH_SSNR: "-1"
+ CI_REGRESSION_THRESH_ODG: "-0.05"
+ INSTR_DIR: "scripts/c-code_instrument"
+ BUILD_WITH_DEBUG_MODE_INFO: ""
+ ENCODER_TEST: ""
+ DELTA_ODG: ""
+ COMPARE_DMX: ""
+ SPLIT_COMPARISON: ""
+ SKIP_REGRESSION_CHECK: ""
+ FAILED_TESTCASES_LIST: "failed-testcases.txt"
+ ERRORS_TESTCASES_LIST: "errors-testcases.txt"
+ PYTEST_CACHE_ARTIFACT: "pytest_cache.zip"
+ MEASURES_FOR_REPORT: "MLD MAX_ABS_DIFF MIN_SSNR MIN_ODG"
+ FLOAT_REF_COMMIT_FILE: "float-ref-git-sha.txt"
+ CUT_COMMIT_FILE: "CuT-git-sha.txt"
+ MERGE_TARGET_COMMIT_FILE: "merge-target-git-sha.txt"
+ MANUAL_PIPELINE_TYPE:
+ description: "Type for the manual pipeline run. Use 'pytest-compare' to run comparison test against reference float codec."
+ value: 'default'
+ options:
+ - 'default'
+ - 'pytest-compare'
+ - 'pytest-compare-enc-dmx'
+ - 'pytest-compare-long'
+ - 'pytest-compare-to-input'
+ - 'pytest-saturation-smoke-test'
+ - 'evs-26444'
+ - 'sanitizer'
+ - 'pytest-renderer'
+ - 'complexity'
+ - 'coverage'
+ - 'voip-be-test'
+ - 'peaq-enc-passthrough'
diff --git a/Workspace_msvc/lib_com.vcxproj b/Workspace_msvc/lib_com.vcxproj
index b44f506e1087e79c05c8a5af879d00220246487d..8c91d39725f7c84c7f2efbffe0dc98408424b586 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 @@
-
+
@@ -237,8 +232,8 @@
-
-
+
+
@@ -250,9 +245,7 @@
-
-
@@ -260,7 +253,6 @@
-
@@ -285,9 +277,9 @@
-
+
-
+
@@ -299,7 +291,6 @@
-
diff --git a/Workspace_msvc/lib_com.vcxproj.filters b/Workspace_msvc/lib_com.vcxproj.filters
index fb912becb20bc6ec6b66c5497a8d666e20a5e1c2..f1d860f1afa391927a6fa4d1342e6318573ca10d 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,8 +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
+
@@ -643,4 +614,4 @@
{b95b7bed-a666-4a00-9332-2b528638503e}
-
\ No newline at end of file
+
diff --git a/Workspace_msvc/lib_dec.vcxproj b/Workspace_msvc/lib_dec.vcxproj
index 5c19bc811cc295a937124b8537dd239cb82d5758..e5998e672c249fb5f71b255d7a62af567e98fe35 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 eb9d1330e3142d06c6744a5dc771fe4e41b56d7a..1237541427184d6fe8470e1a0c0ab6fa04eccf03 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 17b82663162d0b2d58e628269ecbaef86ab3c4cc..f93b5f26d1673c005e7dca6083f5e794f4612ccf 100644
--- a/Workspace_msvc/lib_rend.vcxproj
+++ b/Workspace_msvc/lib_rend.vcxproj
@@ -142,7 +142,6 @@
-
@@ -158,7 +157,7 @@
-
+
@@ -175,7 +174,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/encoder.c b/apps/encoder.c
index 193587f313160c4ee7019dd3d824623bb0e29cd9..a7229dff54fbb688b1718fd803e8dfc84891ed90 100644
--- a/apps/encoder.c
+++ b/apps/encoder.c
@@ -762,7 +762,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/lib_com/basop32.c b/lib_com/basop32.c
index 20dbe663e6f5379f61062595a096af00c50480dc..fbe08a11f74d5a2afd466d351a5652b35d13f275 100644
--- a/lib_com/basop32.c
+++ b/lib_com/basop32.c
@@ -1575,7 +1575,7 @@ Word32 L_msuNs_co( Word32 L_var3, Word16 var1, Word16 var2, Flag *Carry, Flag *O
{
Word32 L_var_out;
- L_var_out = L_mult( var1, var2 );
+ L_var_out = L_mult_o( var1, var2, Overflow );
L_var_out = L_sub_co( L_var3, L_var_out, Carry, Overflow );
return ( L_var_out );
@@ -2038,6 +2038,7 @@ Word32 DEPR_L_sub_c( Word32 L_var1, Word32 L_var2, Flag *Carry )
return ( L_var_out );
}
+
Word32 L_sub_co( Word32 L_var1, Word32 L_var2, Flag *Carry, Flag *Overflow )
{
Word32 L_var_out;
@@ -2056,6 +2057,7 @@ Word32 L_sub_co( Word32 L_var1, Word32 L_var2, Flag *Carry, Flag *Overflow )
L_var_out = L_var1 - L_var2;
if ( L_var1 > 0L )
{
+ set_overflow( Overflow );
unset_carry( Carry );
}
}
@@ -2067,18 +2069,22 @@ Word32 L_sub_co( Word32 L_var1, Word32 L_var2, Flag *Carry, Flag *Overflow )
if ( ( L_test < 0 ) && ( L_var1 > 0 ) && ( L_var2 < 0 ) )
{
+ set_overflow( Overflow );
carry_int = 0;
}
else if ( ( L_test > 0 ) && ( L_var1 < 0 ) && ( L_var2 > 0 ) )
{
+ set_overflow( Overflow );
carry_int = 1;
}
else if ( ( L_test > 0 ) && ( ( L_var1 ^ L_var2 ) > 0 ) )
{
+ unset_overflow( Overflow );
carry_int = 1;
}
if ( L_test == MIN_32 )
{
+ set_overflow( Overflow );
carry_int ? set_carry( Carry ) : unset_carry( Carry );
}
else
diff --git a/lib_com/basop_util.c b/lib_com/basop_util.c
index ec15e9769bde64635ccb2196c7ec7932c6d08e5d..e52f404f6f83b00535931530c021d8e381dd072f 100644
--- a/lib_com/basop_util.c
+++ b/lib_com/basop_util.c
@@ -1409,15 +1409,6 @@ 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 );
- }
-#else
IF( EQ_32( y, 0x80000000 ) )
{
/* Division by -1.0: same as negation of numerator */
@@ -1429,7 +1420,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 +2640,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 +2670,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 8162a98d3fa3147ea128100fddad063e0f8cd18d..3bfcd0c20a7a8696fbc479e6363951de2f377807 100644
--- a/lib_com/bits_alloc_fx.c
+++ b/lib_com/bits_alloc_fx.c
@@ -434,173 +434,12 @@ static Word16 fcb_table(
}
/*-------------------------------------------------------------------*
- * acelp_FCB_allocator()
+ * acelp_FCB_allocator_fx()
*
* Routine to allocate fixed innovation codebook bit-budget
*--------------------------------------------------------------------*/
-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;
-}
-
-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 */
@@ -753,1140 +592,16 @@ static ivas_error acelp_FCB_allocator_ivas(
return error;
}
-/*-------------------------------------------------------------------*
- * config_acelp1()
- *
- * 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
- *--------------------------------------------------------------------*/
-
-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()
+ * 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
*--------------------------------------------------------------------*/
-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 */
@@ -2509,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();
}
@@ -2632,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;
@@ -2652,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;
@@ -2678,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 92%
rename from lib_com/cldfb.c
rename to lib_com/cldfb_fx.c
index d4a6d8ace63ae5b16928fcaa174771d58052fed4..bf832b6406227404a4b3ef4da5e6595bea4ae48e 100644
--- a/lib_com/cldfb.c
+++ b/lib_com/cldfb_fx.c
@@ -60,6 +60,20 @@ 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()
*
@@ -900,7 +914,7 @@ void cldfbAnalysis_ts_fx_fixed_q(
const Word16 *ptr_pf_fx;
Word16 ptr_pf_sf;
Word32 *timeBuffer_fx, buffer_fx[( CLDFB_NO_CHANNELS_MAX * CLDFB_NO_COL_MAX ) + ( 9 * CLDFB_NO_CHANNELS_MAX )];
- Word16 offset, frameSize;
+ Word16 offset, frameSize, gb, hr, shift;
offset = sub( h_cldfb->p_filter_length, h_cldfb->no_channels );
frameSize = i_mult( h_cldfb->no_channels, h_cldfb->no_col );
@@ -1070,18 +1084,42 @@ void cldfbAnalysis_ts_fx_fixed_q(
*q_cldfb = sub( *q_cldfb, 2 );
move16();
+ gb = find_guarded_bits_fx( M1 );
+ hr = L_norm_arr( iBuffer_fx, M1 );
+
+ IF( LT_16( hr, gb ) )
+ {
+ scale_sig32( iBuffer_fx, M1, sub( hr, gb ) );
+ }
+
/* FFT of DCT IV */
fft_cldfb_fx( iBuffer_fx, M2 );
/* post modulation of DCT IV */
- FOR( k = 0; k < M2; k++ )
+ IF( LT_16( hr, gb ) )
{
- /* do it inplace */
- /*cplxMult(&imagBuffer[2*k],&imagBuffer[M1-1-(2*k)],iBuffer[2*k],iBuffer[2*k+1],rot_vctr_re[k],rot_vctr_im[k]);*/
- imagBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_re_fx[k] ), iBuffer_fx[2 * k + 1], rot_vctr_im_fx[k] ); // q - 5
- imagBuffer_fx[( M1 - 1 ) - ( k * 2 )] = Madd_32_32( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_im_fx[k] ), iBuffer_fx[2 * k + 1], rot_vctr_re_fx[k] ); // q - 5
- move32();
- move32();
+ shift = sub( gb, hr );
+ FOR( k = 0; k < M2; k++ )
+ {
+ /* do it inplace */
+ /*cplxMult(&imagBuffer[2*k],&imagBuffer[M1-1-(2*k)],iBuffer[2*k],iBuffer[2*k+1],rot_vctr_re[k],rot_vctr_im[k]);*/
+ imagBuffer_fx[2 * k] = L_shl( 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] ), shift ); // q - 5
+ imagBuffer_fx[( M1 - 1 ) - ( k * 2 )] = L_shl( 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] ), shift ); // q - 5
+ move32();
+ move32();
+ }
+ }
+ ELSE
+ {
+ FOR( k = 0; k < M2; k++ )
+ {
+ /* do it inplace */
+ /*cplxMult(&imagBuffer[2*k],&imagBuffer[M1-1-(2*k)],iBuffer[2*k],iBuffer[2*k+1],rot_vctr_re[k],rot_vctr_im[k]);*/
+ imagBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_re_fx[k] ), iBuffer_fx[2 * k + 1], rot_vctr_im_fx[k] ); // q - 5
+ imagBuffer_fx[( M1 - 1 ) - ( k * 2 )] = Madd_32_32( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_im_fx[k] ), iBuffer_fx[2 * k + 1], rot_vctr_re_fx[k] ); // q - 5
+ move32();
+ move32();
+ }
}
IF( EQ_32( h_cldfb->prototype, CLDFB_PROTOTYPE_5_00MS ) )
@@ -1527,6 +1565,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 */
@@ -1588,7 +1788,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;
}
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 e7e511e0dce2cd1b8fa73bfda1f606c6f34b287a..5ffbb56e7b76aab664cc32da7a0f614df9a3b27c 100644
--- a/lib_com/cnst.h
+++ b/lib_com/cnst.h
@@ -533,12 +533,15 @@ enum
IND_STEREO_ICBWE_MSFLAG,
IND_SHB_ENER_SF,
IND_SHB_RES_GS,
+#ifndef FIX_1486_IND_SHB_RES
IND_SHB_RES_GS1,
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,
+#endif
IND_SHB_LSF,
IND_SHB_MIRROR = IND_SHB_LSF + 5,
IND_SHB_GRID,
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/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..2079257245fac4fa09babd2a22c751b868d0c2c7 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 );
@@ -1109,12 +1111,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 );
@@ -2624,18 +2620,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 +2655,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 +2669,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 +2688,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 +2750,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 54fef9e37ca4a881fd62c05b38e13e81d641476f..119811275e34a99e7b2f22226dc8385c9709fc6f 100644
--- a/lib_com/gs_inact_switching_fx.c
+++ b/lib_com/gs_inact_switching_fx.c
@@ -33,143 +33,24 @@
/*------------------------------------------------------------------------*/
/* OUTPUT ARGUMENTS : */
/*------------------------------------------------------------------------*/
-
/*------------------------------------------------------------------------*/
/* RETURN ARGUMENTS : */
/* _ None */
/*========================================================================*/
-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;
-}
-
-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];
@@ -250,31 +131,62 @@ void Inac_switch_ematch_ivas_fx(
exp = sub( exp, 14 );
IF( LT_16( i, 2 ) )
{
- FOR( j = 0; j < 8; j++ )
+ IF( EQ_16( element_mode, EVS_MONO ) )
{
- L_tmp = L_mult0( *pt_exc, ftmp );
- L_tmp = L_shl_sat( L_tmp, add( exp, 15 ) ); /* Q(Q_exc) -> Q(15+Q_exc)*/
- *pt_exc = round_fx_sat( L_tmp ); /*Q_exc - 1*/
- move16();
- pt_exc++;
+ FOR( j = 0; j < 8; j++ )
+ {
+ L_tmp = L_mult( *pt_exc, ftmp );
+ L_tmp = L_shl_sat( L_tmp, add( exp, 15 ) ); /* Q(Q_exc) -> Q(15+Q_exc)*/
+ *pt_exc = round_fx_sat( L_tmp ); /*Q_exc - 1*/
+ move16();
+ pt_exc++;
+ }
+ }
+ ELSE
+ {
+ FOR( j = 0; j < 8; j++ )
+ {
+ L_tmp = L_mult0( *pt_exc, ftmp );
+ L_tmp = L_shl_sat( L_tmp, add( exp, 15 ) ); /* Q(Q_exc) -> Q(15+Q_exc)*/
+ *pt_exc = round_fx_sat( L_tmp ); /*Q_exc - 1*/
+ move16();
+ pt_exc++;
+ }
}
}
ELSE
{
- FOR( j = 0; j < 16; j++ )
+ IF( EQ_16( element_mode, EVS_MONO ) )
+ {
+ FOR( j = 0; j < 16; j++ )
+ {
+ L_tmp = L_mult( *pt_exc, ftmp );
+ L_tmp = L_shl_sat( L_tmp, add( exp, 15 ) ); /* Q(Q_exc) -> Q(15+Q_exc)*/
+ *pt_exc = round_fx_sat( L_tmp ); /*Q_exc - 1*/
+ move16();
+ pt_exc++;
+ }
+ }
+ ELSE
{
- L_tmp = L_mult0( *pt_exc, ftmp );
- L_tmp = L_shl_sat( L_tmp, add( exp, 15 ) ); /* Q(Q_exc) -> Q(15+Q_exc)*/
- *pt_exc = round_fx_sat( L_tmp ); /*Q_exc - 1*/
- move16();
- pt_exc++;
+ FOR( j = 0; j < 16; j++ )
+ {
+ L_tmp = L_mult0( *pt_exc, ftmp );
+ L_tmp = L_shl_sat( L_tmp, add( exp, 15 ) ); /* Q(Q_exc) -> Q(15+Q_exc)*/
+ *pt_exc = round_fx_sat( L_tmp ); /*Q_exc - 1*/
+ move16();
+ pt_exc++;
+ }
}
}
}
/* Going back to time */
- Scale_sig( dct_exc_tmp, 240, 1 ); // Q_exc
- Scale_sig( exc2, 240, 1 ); // Q_exc
+ IF( GT_16( element_mode, EVS_MONO ) )
+ {
+ Scale_sig( dct_exc_tmp, 240, 1 ); // Q_exc
+ Scale_sig( exc2, 240, 1 ); // Q_exc
+ }
edct_16fx( dct_exc_tmp, exc2, L_frame, 5, element_mode );
}
diff --git a/lib_com/gs_noisefill_fx.c b/lib_com/gs_noisefill_fx.c
index 2e00e4641e177d2e17d2bbecbe6c93f93c522e1a..208f205693ce9d67d04e96870bfcf4a15ea12d12 100644
--- a/lib_com/gs_noisefill_fx.c
+++ b/lib_com/gs_noisefill_fx.c
@@ -1332,32 +1332,46 @@ void highband_exc_dct_in_ivas_fx(
}
}
- Word16 Q_tmp = *Q_exc;
- move16();
- Word16 Q_old = *Q_exc;
- move16();
- Comp_and_apply_gain_ivas_fx( exc_diffQ, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 0, Qexc_diffQ, Q_exc );
-
- IF( exc_wo_nf != NULL )
+ IF( EQ_16( element_mode, EVS_MONO ) )
{
- Comp_and_apply_gain_ivas_fx( exc_wo_nf, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 1, Qexc_diffQ, &Q_tmp );
- IF( GT_16( Q_tmp, *Q_exc ) )
+ Comp_and_apply_gain_fx( exc_diffQ, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 0, Qexc_diffQ, *Q_exc );
+
+ IF( exc_wo_nf != NULL )
{
- Scale_sig( exc_wo_nf, L_frame, sub( *Q_exc, Q_tmp ) );
+ Comp_and_apply_gain_fx( exc_wo_nf, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 1, Qexc_diffQ, *Q_exc );
+ Vr_add( exc_dct_in, exc_wo_nf, exc_wo_nf, L_frame );
}
- ELSE IF( LT_16( Q_tmp, *Q_exc ) )
- {
- Scale_sig( exc_diffQ, L_frame, sub( Q_tmp, *Q_exc ) );
- *Q_exc = Q_tmp;
- move16();
- }
- Scale_sig( exc_dct_in, L_frame, sub( *Q_exc, Q_old ) );
- Vr_add( exc_dct_in, exc_wo_nf, exc_wo_nf, L_frame );
}
ELSE
{
- Scale_sig( exc_dct_in, L_frame, sub( *Q_exc, Q_old ) );
+ Word16 Q_tmp = *Q_exc;
+ move16();
+ Word16 Q_old = *Q_exc;
+ move16();
+ Comp_and_apply_gain_ivas_fx( exc_diffQ, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 0, Qexc_diffQ, Q_exc );
+
+ IF( exc_wo_nf != NULL )
+ {
+ Comp_and_apply_gain_ivas_fx( exc_wo_nf, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 1, Qexc_diffQ, &Q_tmp );
+ IF( GT_16( Q_tmp, *Q_exc ) )
+ {
+ Scale_sig( exc_wo_nf, L_frame, sub( *Q_exc, Q_tmp ) );
+ }
+ ELSE IF( LT_16( Q_tmp, *Q_exc ) )
+ {
+ Scale_sig( exc_diffQ, L_frame, sub( Q_tmp, *Q_exc ) );
+ *Q_exc = Q_tmp;
+ move16();
+ }
+ Scale_sig( exc_dct_in, L_frame, sub( *Q_exc, Q_old ) );
+ Vr_add( exc_dct_in, exc_wo_nf, exc_wo_nf, L_frame );
+ }
+ ELSE
+ {
+ Scale_sig( exc_dct_in, L_frame, sub( *Q_exc, Q_old ) );
+ }
}
+
/*--------------------------------------------------------------------------------------*
* add the correction layer to the LF bins,
* and add the quantized pulses or the noise for the higher part of the spectrum
@@ -1397,7 +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 );
- IF( GT_16( *Q_exc, Q_hb_exc ) )
+
+ test();
+ 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/gs_preech_fx.c b/lib_com/gs_preech_fx.c
index 3b3eaa7776b9ff3c7403e4cb7f30decf8bf77a2b..16d3ce0e51bc79ee06acccdeaac96b3c6a8b737d 100644
--- a/lib_com/gs_preech_fx.c
+++ b/lib_com/gs_preech_fx.c
@@ -177,9 +177,10 @@ void pre_echo_att_ivas_fx(
move16();
Word16 ratio_fx;
Word16 attack_pos_fx, i;
- Word32 L_tmp, L_tmp1;
- Word16 tmp, n1, n2, exp, frac1, frac2;
+ Word32 L_tmp;
+ Word16 tmp, tmp_e;
Word32 etmp1_fx;
+ Word16 etmp_e;
Word16 att_len;
test();
@@ -220,32 +221,19 @@ void pre_echo_att_ivas_fx(
IF( GT_32( etmp_fx, *Last_frame_ener_fx ) && attack_pos_fx > 0 )
{
/* Find the average energy before the attack */
- L_tmp = sum32_fx( finc_fx, attack_pos_fx ); /*Q1 */
- L_tmp1 = L_shr( L_mult( attack_pos_fx, attack_pos_fx ), 1 ); /*Q0 */
- tmp = round_fx( Isqrt( L_tmp1 ) ); /*Q15 */
- L_tmp = L_shr( L_tmp, 2 ); /*Q1 ; ATT_SEG_LEN=4 */
- etmp_fx = Mult_32_16( L_tmp, tmp ); /*Q1 */
-
- etmp_fx = L_shr( etmp_fx, add( 1 - 4, shl( Q_new, 1 ) ) ); /* makes etmp i nQ4 as *Last_frame_ener_fx */
- /* Find the correction factor and apply it before the attack */
- /* ratio = (float)sqrt(*Last_frame_ener/etmp);*/
- /* = isqrt(etmp/(*Last_frame_ener)) */
- etmp_fx = L_max( etmp_fx, 1 );
- *Last_frame_ener_fx = L_max( *Last_frame_ener_fx, 1 );
- move32();
- n1 = norm_l( etmp_fx );
- n2 = norm_l( *Last_frame_ener_fx );
-
- n1 = sub( n1, 1 );
- exp = sub( n1, n2 );
-
- frac1 = round_fx( L_shl( etmp_fx, n1 ) );
- frac2 = round_fx_sat( L_shl_sat( *Last_frame_ener_fx, n2 ) );
- L_tmp = L_mult0( 128, div_s( frac1, frac2 ) ); /* s = gain_out / gain_in */
- L_tmp = L_shr( L_tmp, exp ); /* add exponent */
+ etmp_fx = sum32_fx( finc_fx, attack_pos_fx );
+ etmp_e = sub( 31, add( shl( Q_new, 1 ), 1 ) );
+ etmp_fx = L_add( etmp_fx, L_shr( 21474836 /*0.01 in Q31*/, etmp_e ) ); /* etmp = etmp + 0.01; (exp = etmp_e) */
+ etmp_fx = L_deposit_h( BASOP_Util_Divide3232_Scale( etmp_fx, L_mult0( attack_pos_fx, ATT_SEG_LEN ), &tmp_e ) );
+ tmp_e = add( tmp_e, sub( etmp_e, 31 ) );
+ etmp_e = tmp_e;
+ move16();
- L_tmp = Isqrt( L_tmp );
- ratio_fx = round_fx( L_shl( L_tmp, 9 ) );
+ /* Find the correction factor and apply it before the attack */
+ tmp = BASOP_Util_Divide3232_Scale( *Last_frame_ener_fx, etmp_fx, &tmp_e ); /* numerator Q = 2 * Q_new + 1; denominator Q = 31 - tmp_e */
+ tmp_e = add( tmp_e, sub( sub( 31, etmp_e ), add( shl( Q_new, 1 ), 1 ) ) ); /* tmp_e = tmp_e + (31 - tmp_e) - (2 * Q_new + 1) */
+ tmp = Sqrt16( tmp, &tmp_e );
+ ratio_fx = shr_sat( tmp, sub( 2, tmp_e ) ); /* Q13 */
/* Pre-echo atttenuation should never increase the energy */
ratio_fx = s_min( ratio_fx, 8192 /* 1 in Q13 */ ); /* Q13 */
diff --git a/lib_com/hp50_fx.c b/lib_com/hp50_fx.c
index f5e7105cfcf9dfeebad0e4bff0d5a262cc8a7dd8..f1864d7a792a27526a97321276cde5df053c8bb0 100644
--- a/lib_com/hp50_fx.c
+++ b/lib_com/hp50_fx.c
@@ -458,14 +458,8 @@ void hp20_fx_32(
{
Word16 i;
Word32 a1_fx, a2_fx, b1_fx, b2_fx;
-#ifdef OPT_STEREO_32KBPS_V1
- Word16 Qy1, Qy2, Qmin;
- Word64 y0_fx64, y1_fx64, y2_fx64;
- Word32 x0, x1, x2;
-#else /* OPT_STEREO_32KBPS_V1 */
Word16 Qx0, Qx1, Qx2, Qy1, Qprev_y1, Qy2, Qprev_y2, Qmin;
Word64 x0_fx64, x1_fx64, x2_fx64, y0_fx64, y1_fx64, y2_fx64, R1, R2, R3, R4, R5;
-#endif /* OPT_STEREO_32KBPS_V1 */
IF( EQ_32( Fs, 8000 ) )
{
@@ -516,64 +510,15 @@ void hp20_fx_32(
move32();
move32();
-#ifdef OPT_STEREO_32KBPS_V1
- y1_fx64 = W_add( W_deposit32_l( mem_fx[0] ), W_deposit32_h( mem_fx[1] ) );
- y2_fx64 = W_add( W_deposit32_l( mem_fx[2] ), W_deposit32_h( mem_fx[3] ) );
-
- x0 = mem_fx[4];
- move32();
- x1 = mem_fx[5];
- move32();
-#else /* OPT_STEREO_32KBPS_V1 */
Qprev_y1 = extract_l( mem_fx[4] );
Qprev_y2 = extract_l( mem_fx[5] );
y1_fx64 = W_deposit32_l( mem_fx[0] );
y2_fx64 = W_deposit32_l( mem_fx[1] );
x0_fx64 = W_deposit32_l( mem_fx[2] );
x1_fx64 = W_deposit32_l( mem_fx[3] );
-#endif /* OPT_STEREO_32KBPS_V1 */
FOR( i = 0; i < lg; i++ )
{
-#ifdef OPT_STEREO_32KBPS_V1
- x2 = x1;
- move32();
- x1 = x0;
- move32();
- x0 = signal_fx[i];
- move32();
-
- Qy1 = W_norm( y1_fx64 );
- if ( y1_fx64 == 0 )
- {
- Qy1 = 62;
- move16();
- }
-
- Qy2 = W_norm( y2_fx64 );
- if ( y2_fx64 == 0 )
- {
- Qy2 = 62;
- move16();
- }
-
- Qmin = s_min( Qy1, Qy2 );
-
- Qmin = sub( Qmin, 34 );
-
- y0_fx64 = W_mac_32_32( W_mult_32_32( W_shl_sat_l( y1_fx64, Qmin ), a1_fx ), W_shl_sat_l( y2_fx64, Qmin ), a2_fx ); // Qmin + Q29 + Q30 + 1
-
- Word64 temp = W_mac_32_32( W_mac_32_32( W_mult_32_32( x2, b2_fx ), x1, b1_fx ), x0, b2_fx ); // Q30
- Word64 y0_fx = W_shr( y0_fx64, add( Qmin, Q30 ) ); // Q30
- y0_fx64 = W_add( temp, y0_fx ); // Q30
- signal_fx[i] = W_shl_sat_l( y0_fx64, -Q30 );
- move32();
-
- y2_fx64 = y1_fx64;
- move64();
- y1_fx64 = y0_fx64;
- move64();
-#else /* OPT_STEREO_32KBPS_V1 */
x2_fx64 = x1_fx64;
move64();
x1_fx64 = x0_fx64;
@@ -587,7 +532,11 @@ void hp20_fx_32(
move16();
}
Qy1 = sub( Qy1, 34 );
+#ifdef OPT_STEREO_32KBPS_V1
+ R1 = W_mult0_32_32( W_shl_sat_l( y1_fx64, Qy1 ), a1_fx );
+#else /* OPT_STEREO_32KBPS_V1 */
R1 = W_mult0_32_32( W_extract_l( W_shl( y1_fx64, Qy1 ) ), a1_fx );
+#endif /* OPT_STEREO_32KBPS_V1 */
Qy1 = add( Qy1, Qprev_y1 );
Qy2 = W_norm( y2_fx64 );
@@ -597,7 +546,11 @@ void hp20_fx_32(
move16();
}
Qy2 = sub( Qy2, 34 );
+#ifdef OPT_STEREO_32KBPS_V1
+ R2 = W_mult0_32_32( W_shl_sat_l( y2_fx64, Qy2 ), a2_fx );
+#else /* OPT_STEREO_32KBPS_V1 */
R2 = W_mult0_32_32( W_extract_l( W_shl( y2_fx64, Qy2 ) ), a2_fx );
+#endif /* OPT_STEREO_32KBPS_V1 */
Qy2 = add( Qy2, Qprev_y2 );
Qx0 = W_norm( x0_fx64 );
@@ -607,7 +560,11 @@ void hp20_fx_32(
move16();
}
Qx0 = sub( Qx0, 34 );
+#ifdef OPT_STEREO_32KBPS_V1
+ R3 = W_mult0_32_32( W_shl_sat_l( x0_fx64, Qx0 ), b2_fx );
+#else /* OPT_STEREO_32KBPS_V1 */
R3 = W_mult0_32_32( W_extract_l( W_shl( x0_fx64, Qx0 ) ), b2_fx );
+#endif /* OPT_STEREO_32KBPS_V1 */
Qx1 = W_norm( x1_fx64 );
if ( x1_fx64 == 0 )
@@ -616,7 +573,11 @@ void hp20_fx_32(
move16();
}
Qx1 = sub( Qx1, 34 );
+#ifdef OPT_STEREO_32KBPS_V1
+ R4 = W_mult0_32_32( W_shl_sat_l( x1_fx64, Qx1 ), b1_fx );
+#else /* OPT_STEREO_32KBPS_V1 */
R4 = W_mult0_32_32( W_extract_l( W_shl( x1_fx64, Qx1 ) ), b1_fx );
+#endif /* OPT_STEREO_32KBPS_V1 */
Qx2 = W_norm( x2_fx64 );
if ( x2_fx64 == 0 )
@@ -625,7 +586,11 @@ void hp20_fx_32(
move16();
}
Qx2 = sub( Qx2, 34 );
+#ifdef OPT_STEREO_32KBPS_V1
+ R5 = W_mult0_32_32( W_shl_sat_l( x2_fx64, Qx2 ), b2_fx );
+#else /* OPT_STEREO_32KBPS_V1 */
R5 = W_mult0_32_32( W_extract_l( W_shl( x2_fx64, Qx2 ) ), b2_fx );
+#endif /* OPT_STEREO_32KBPS_V1 */
Qmin = s_min( Qy1, Qy2 );
@@ -655,17 +620,8 @@ void hp20_fx_32(
move64();
move16();
move16();
-#endif /* OPT_STEREO_32KBPS_V1 */
}
-#ifdef OPT_STEREO_32KBPS_V1
- mem_fx[0] = W_extract_l( y1_fx64 );
- mem_fx[1] = W_extract_h( y1_fx64 );
- mem_fx[2] = W_extract_l( y2_fx64 );
- mem_fx[3] = W_extract_h( y2_fx64 );
- mem_fx[4] = x0;
- mem_fx[5] = x1;
-#else /* OPT_STEREO_32KBPS_V1 */
Qy1 = W_norm( y1_fx64 );
test();
IF( y1_fx64 != 0 && LT_16( Qy1, 32 ) )
@@ -688,7 +644,6 @@ void hp20_fx_32(
mem_fx[3] = W_extract_l( x1_fx64 );
mem_fx[4] = Qprev_y1;
mem_fx[5] = Qprev_y2;
-#endif /* OPT_STEREO_32KBPS_V1 */
move32();
move32();
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 100%
rename from lib_com/interpol.c
rename to lib_com/interpol_fx.c
diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h
index 36f0bf57170d4df4d8ab00ba499ad31a53a676d2..24d396d2a64294249867d9cfd7ccce3228359788 100644
--- a/lib_com/ivas_cnst.h
+++ b/lib_com/ivas_cnst.h
@@ -511,8 +511,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 )
@@ -801,7 +801,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 )
@@ -1449,7 +1449,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 a5fd4821b5f24b2469c8c6ddd8cab87916637c2d..0c913499ba89ae3c25c16d8735be521f6d34019d 100644
--- a/lib_com/ivas_dirac_com_fx.c
+++ b/lib_com/ivas_dirac_com_fx.c
@@ -1038,7 +1038,7 @@ void computeDiffuseness_fixed(
exp1 = sub( 31, q_intensity_slow );
tmp = Sqrt32( p_tmp[i], &exp1 );
- tmp = BASOP_Util_Divide3232_Scale_cadence( tmp, L_add( energy_slow[i], EPSILLON_FX ), &exp2 );
+ tmp = BASOP_Util_Divide3232_Scale_newton( tmp, L_add( energy_slow[i], EPSILLON_FX ), &exp2 );
q_tmp = add( sub( 31, exp2 ), sub( sub( 31, exp1 ), q_ene ) );
IF( LT_16( q_tmp, Q30 ) )
diff --git a/lib_com/ivas_limiter_fx.c b/lib_com/ivas_limiter_fx.c
index 4250d7a7a46db4ebc5500b6754d015d1f25a601d..60982f3f2e3ad0bf854aba398859e416e89afc44 100644
--- a/lib_com/ivas_limiter_fx.c
+++ b/lib_com/ivas_limiter_fx.c
@@ -36,7 +36,7 @@
#include "prot_fx.h"
#include "ivas_prot_rend_fx.h"
#include "ivas_rom_rend.h"
-#include "ivas_rom_com.h"
+#include "ivas_rom_com_fx.h"
#include "wmc_auto.h"
#include
#include "ivas_prot_fx.h"
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 4f011abe804b92fa89e7659f0dcea72ed40b23ef..b1a03bd2ef9b681988e95cda9c974d178d01aa23 100644
--- a/lib_com/ivas_prot_fx.h
+++ b/lib_com/ivas_prot_fx.h
@@ -2129,13 +2129,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 */
@@ -2759,7 +2752,8 @@ void stereo_coder_tcx_fx(
Word32 *inv_spectrum_fx[CPE_CHANNELS][NB_DIV], /* i/o: inverse spectrum */
Word32 *inv_mdst_spectrum_fx[CPE_CHANNELS][NB_DIV], /* i/o: inverse MDST spectrum */
const Word16 mct_on, /* i : flag mct block (1) or stereo (0) */
- Word16 q_spec );
+ Word16 exp_spec,
+ Word16 exp_mdst_spec );
// bw_detect_fx.c
Word16 set_bw_mct_fx(
@@ -3388,7 +3382,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 */
);
@@ -4033,7 +4027,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*/
@@ -4811,7 +4805,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 );
@@ -6303,7 +6297,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_qspherical_com_fx.c b/lib_com/ivas_qspherical_com_fx.c
index 6661026a8cde298b8d2f618156313e3cdef73a1f..844c3ecdef2cdd60899fb73e3e549a35e4ee9e1b 100644
--- a/lib_com/ivas_qspherical_com_fx.c
+++ b/lib_com/ivas_qspherical_com_fx.c
@@ -314,9 +314,9 @@ Word16 quantize_phi_enc_fx(
Word32 temp_res;
Word16 temp_e;
- delta_phi_fx = BASOP_Util_Divide3232_Scale_cadence( 360, n, &temp_e );
+ delta_phi_fx = BASOP_Util_Divide3232_Scale_newton( 360, n, &temp_e );
delta_phi_fx = L_shl( delta_phi_fx, sub( temp_e, 9 ) );
- inv_delta_phi_fx = BASOP_Util_Divide3232_Scale_cadence( n, 360, &temp_e );
+ inv_delta_phi_fx = BASOP_Util_Divide3232_Scale_newton( n, 360, &temp_e );
IF( EQ_16( n, 1 ) )
{
@@ -661,7 +661,7 @@ Word16 quantize_phi_chan_compand_fx(
/* quantize companded value */
// delta_phi = 360.0f / (float) n;
- delta_phi = BASOP_Util_Divide3232_Scale_cadence( 360, n, &tmp_e );
+ delta_phi = BASOP_Util_Divide3232_Scale_newton( 360, n, &tmp_e );
delta_phi = L_shr( delta_phi, sub( 9, tmp_e ) ); // Q22
// id_phi = (int16_t) round_f( ( phi / (float) delta_phi ) );
id_phi = BASOP_Util_Divide3232_Scale( phi, delta_phi, &tmp_e ); // Q15
diff --git a/lib_com/ivas_rom_com.c b/lib_com/ivas_rom_com.c
index c7977001b7cfbd70c374a79c6ef97e6fee1a6f9c..5d4de33b4e9c3933724028c066232695088d6721 100644
--- a/lib_com/ivas_rom_com.c
+++ b/lib_com/ivas_rom_com.c
@@ -52,827 +52,6 @@ const Word32 ivas_brate_tbl[SIZE_IVAS_BRATE_TBL] =
IVAS_192k, IVAS_256k, IVAS_384k, IVAS_512k
};
-/*----------------------------------------------------------------------------------*
- * IVAS limiter table
- *----------------------------------------------------------------------------------*/
-const Word32 release_cnst_table[4][201] = // Q31
-{
- {
- 1913946752,
- 1919716352,
- 1925351680,
- 1930855552,
- 1936230784,
- 1941479808,
- 1946605312,
- 1951609728,
- 1956495744,
- 1961265792,
- 1965922304,
- 1970467584,
- 1974904320,
- 1979234560,
- 1983460736,
- 1987585024,
- 1991609856,
- 1995537280,
- 1999369344,
- 2003108480,
- 2006756480,
- 2010315520,
- 2013787520,
- 2017174528,
- 2020478464,
- 2023701248,
- 2026844672,
- 2029910656,
- 2032900992,
- 2035817344,
- 2038661376,
- 2041435008,
- 2044139648,
- 2046777088,
- 2049348864,
- 2051856384,
- 2054301440,
- 2056685312,
- 2059009536,
- 2061275520,
- 2063484672,
- 2065638272,
- 2067737856,
- 2069784448,
- 2071779584,
- 2073724416,
- 2075620096,
- 2077467904,
- 2079268992,
- 2081024512,
- 2082735488,
- 2084403200,
- 2086028416,
- 2087612544,
- 2089156352,
- 2090660864,
- 2092127104,
- 2093555968,
- 2094948480,
- 2096305408,
- 2097627776,
- 2098916352,
- 2100172032,
- 2101395584,
- 2102587776,
- 2103749504,
- 2104881408,
- 2105984384,
- 2107059072,
- 2108106112,
- 2109126400,
- 2110120448,
- 2111088896,
- 2112032512,
- 2112951808,
- 2113847552,
- 2114720128,
- 2115570304,
- 2116398592,
- 2117205504,
- 2117991552,
- 2118757504,
- 2119503616,
- 2120230400,
- 2120938496,
- 2121628288,
- 2122300288,
- 2122954880,
- 2123592576,
- 2124213760,
- 2124818944,
- 2125408384,
- 2125982592,
- 2126541952,
- 2127086848,
- 2127617664,
- 2128134656,
- 2128638336,
- 2129128832,
- 2129606784,
- 2130072192,
- 2130525568,
- 2130967296,
- 2131397376,
- 2131816448,
- 2132224640,
- 2132622080,
- 2133009408,
- 2133386496,
- 2133753856,
- 2134111744,
- 2134460288,
- 2134799744,
- 2135130368,
- 2135452416,
- 2135766144,
- 2136071680,
- 2136369152,
- 2136659072,
- 2136941312,
- 2137216256,
- 2137484160,
- 2137744896,
- 2137998976,
- 2138246400,
- 2138487424,
- 2138722176,
- 2138950656,
- 2139173376,
- 2139390208,
- 2139601408,
- 2139807104,
- 2140007424,
- 2140202624,
- 2140392576,
- 2140577664,
- 2140758016,
- 2140933504,
- 2141104512,
- 2141271040,
- 2141433216,
- 2141591168,
- 2141745024,
- 2141894912,
- 2142040832,
- 2142182912,
- 2142321408,
- 2142456192,
- 2142587392,
- 2142715264,
- 2142839808,
- 2142961152,
- 2143079296,
- 2143194240,
- 2143306240,
- 2143415424,
- 2143521664,
- 2143625216,
- 2143725952,
- 2143824128,
- 2143919744,
- 2144012800,
- 2144103424,
- 2144191744,
- 2144277760,
- 2144361472,
- 2144443136,
- 2144522496,
- 2144599936,
- 2144675200,
- 2144748544,
- 2144820096,
- 2144889600,
- 2144957440,
- 2145023488,
- 2145087744,
- 2145150336,
- 2145211264,
- 2145270656,
- 2145328512,
- 2145384832,
- 2145439616,
- 2145493120,
- 2145545088,
- 2145595776,
- 2145645056,
- 2145693184,
- 2145739904,
- 2145785472,
- 2145829888,
- 2145873152,
- 2145915136,
- 2145956224,
- 2145996032,
- 2146034944,
- 2146072832,
- 2146109696,
- 2146145664,
- 2146180608,
- 2146214656,
- 2146247808,
- },
- {
- 2027355264,
- 2030408704,
- 2033386624,
- 2036290944,
- 2039123328,
- 2041885440,
- 2044578944,
- 2047205376,
- 2049766528,
- 2052263680,
- 2054698496,
- 2057072384,
- 2059387008,
- 2061643520,
- 2063843328,
- 2065987968,
- 2068078720,
- 2070116864,
- 2072103552,
- 2074040192,
- 2075927936,
- 2077767936,
- 2079561472,
- 2081309568,
- 2083013376,
- 2084673920,
- 2086292352,
- 2087869696,
- 2089406976,
- 2090905216,
- 2092365184,
- 2093788032,
- 2095174528,
- 2096525824,
- 2097842432,
- 2099125632,
- 2100375808,
- 2101594240,
- 2102781312,
- 2103938048,
- 2105065216,
- 2106163456,
- 2107233536,
- 2108276096,
- 2109292032,
- 2110281728,
- 2111246080,
- 2112185728,
- 2113101056,
- 2113992960,
- 2114861824,
- 2115708288,
- 2116532992,
- 2117336448,
- 2118119168,
- 2118881792,
- 2119624704,
- 2120348416,
- 2121053440,
- 2121740288,
- 2122409344,
- 2123061120,
- 2123696128,
- 2124314624,
- 2124917120,
- 2125504128,
- 2126075776,
- 2126632832,
- 2127175296,
- 2127703808,
- 2128218624,
- 2128720000,
- 2129208448,
- 2129684352,
- 2130147712,
- 2130599168,
- 2131038976,
- 2131467264,
- 2131884416,
- 2132290816,
- 2132686592,
- 2133072256,
- 2133447680,
- 2133813504,
- 2134169856,
- 2134516864,
- 2134854784,
- 2135184000,
- 2135504640,
- 2135816960,
- 2136121216,
- 2136417536,
- 2136706048,
- 2136987136,
- 2137260928,
- 2137527552,
- 2137787264,
- 2138040192,
- 2138286592,
- 2138526464,
- 2138760192,
- 2138987776,
- 2139209472,
- 2139425408,
- 2139635712,
- 2139840512,
- 2140039936,
- 2140234240,
- 2140423424,
- 2140607744,
- 2140787200,
- 2140962048,
- 2141132288,
- 2141298048,
- 2141459584,
- 2141616896,
- 2141769984,
- 2141919232,
- 2142064512,
- 2142205952,
- 2142343808,
- 2142478080,
- 2142608768,
- 2142736128,
- 2142860032,
- 2142980864,
- 2143098368,
- 2143212928,
- 2143324544,
- 2143433088,
- 2143538944,
- 2143641984,
- 2143742336,
- 2143840000,
- 2143935232,
- 2144027904,
- 2144118144,
- 2144206080,
- 2144291712,
- 2144375168,
- 2144456320,
- 2144535424,
- 2144612480,
- 2144687488,
- 2144760448,
- 2144831616,
- 2144900992,
- 2144968448,
- 2145034112,
- 2145098112,
- 2145160448,
- 2145221248,
- 2145280256,
- 2145337856,
- 2145393920,
- 2145448576,
- 2145501696,
- 2145553536,
- 2145603968,
- 2145653120,
- 2145700992,
- 2145747456,
- 2145792896,
- 2145837056,
- 2145880064,
- 2145922048,
- 2145962880,
- 2146002560,
- 2146041344,
- 2146078976,
- 2146115712,
- 2146151424,
- 2146186240,
- 2146220160,
- 2146253184,
- 2146285312,
- 2146316672,
- 2146347136,
- 2146376832,
- 2146405760,
- 2146433920,
- 2146461440,
- 2146488192,
- 2146514176,
- 2146539520,
- 2146564224,
- 2146588160,
- 2146611584,
- 2146634368,
- 2146656640,
- 2146678272,
- 2146699264,
- 2146719744,
- 2146739712,
- 2146759168,
- 2146778112,
- 2146796544,
- 2146814464,
- 2146832000,
- 2146849024,
- 2146865664,
- },
- {
- 2086555136,
- 2088125824,
- 2089656576,
- 2091148416,
- 2092602240,
- 2094018944,
- 2095399680,
- 2096745088,
- 2098056192,
- 2099333888,
- 2100578816,
- 2101792000,
- 2102974080,
- 2104125824,
- 2105248128,
- 2106341760,
- 2107407232,
- 2108445440,
- 2109456896,
- 2110442496,
- 2111402624,
- 2112338176,
- 2113249664,
- 2114137728,
- 2115002880,
- 2115845760,
- 2116666880,
- 2117466880,
- 2118246272,
- 2119005568,
- 2119745280,
- 2120465920,
- 2121167872,
- 2121851776,
- 2122517888,
- 2123166976,
- 2123799168,
- 2124414976,
- 2125014912,
- 2125599360,
- 2126168704,
- 2126723200,
- 2127263360,
- 2127789568,
- 2128302208,
- 2128801408,
- 2129287808,
- 2129761536,
- 2130222976,
- 2130672512,
- 2131110272,
- 2131536768,
- 2131952128,
- 2132356736,
- 2132750848,
- 2133134720,
- 2133508736,
- 2133872896,
- 2134227584,
- 2134573184,
- 2134909696,
- 2135237504,
- 2135556736,
- 2135867648,
- 2136170624,
- 2136465536,
- 2136752896,
- 2137032832,
- 2137305344,
- 2137570816,
- 2137829376,
- 2138081280,
- 2138326528,
- 2138565504,
- 2138798080,
- 2139024768,
- 2139245440,
- 2139460480,
- 2139669888,
- 2139873792,
- 2140072320,
- 2140265856,
- 2140454144,
- 2140637696,
- 2140816384,
- 2140990464,
- 2141159936,
- 2141325056,
- 2141485824,
- 2141642368,
- 2141794944,
- 2141943424,
- 2142088064,
- 2142228992,
- 2142366208,
- 2142499840,
- 2142630016,
- 2142756736,
- 2142880128,
- 2143000448,
- 2143117440,
- 2143231488,
- 2143342592,
- 2143450752,
- 2143556096,
- 2143658624,
- 2143758592,
- 2143855872,
- 2143950592,
- 2144043008,
- 2144132864,
- 2144220416,
- 2144305664,
- 2144388608,
- 2144469504,
- 2144548224,
- 2144624896,
- 2144699648,
- 2144772352,
- 2144843264,
- 2144912256,
- 2144979328,
- 2145044864,
- 2145108480,
- 2145170560,
- 2145231104,
- 2145289856,
- 2145347200,
- 2145403008,
- 2145457408,
- 2145510400,
- 2145561984,
- 2145612160,
- 2145661056,
- 2145708672,
- 2145755136,
- 2145800192,
- 2145844224,
- 2145887104,
- 2145928832,
- 2145969408,
- 2146008960,
- 2146047616,
- 2146085120,
- 2146121600,
- 2146157184,
- 2146191872,
- 2146225664,
- 2146258560,
- 2146290560,
- 2146321792,
- 2146352128,
- 2146381696,
- 2146410496,
- 2146438528,
- 2146465920,
- 2146492416,
- 2146518400,
- 2146543616,
- 2146568192,
- 2146592128,
- 2146615424,
- 2146638080,
- 2146660224,
- 2146681728,
- 2146702720,
- 2146723072,
- 2146743040,
- 2146762368,
- 2146781184,
- 2146799616,
- 2146817408,
- 2146834816,
- 2146851840,
- 2146868352,
- 2146884352,
- 2146900096,
- 2146915328,
- 2146930176,
- 2146944640,
- 2146958720,
- 2146972416,
- 2146985856,
- 2146998784,
- 2147011456,
- 2147023872,
- 2147035904,
- 2147047552,
- 2147058944,
- 2147070080,
- 2147080832,
- 2147091456,
- 2147101696,
- 2147111680,
- 2147121408,
- 2147130880,
- 2147140096,
- 2147149056,
- 2147157760,
- 2147166336,
- 2147174656,
- },
- {
- 2106670080,
- 2107727232,
- 2108757120,
- 2109760640,
- 2110738432,
- 2111691008,
- 2112619136,
- 2113523328,
- 2114404352,
- 2115262592,
- 2116098816,
- 2116913408,
- 2117707136,
- 2118480256,
- 2119233536,
- 2119967360,
- 2120682240,
- 2121378688,
- 2122057088,
- 2122717952,
- 2123361792,
- 2123988992,
- 2124599936,
- 2125195136,
- 2125774848,
- 2126339584,
- 2126889728,
- 2127425536,
- 2127947520,
- 2128456064,
- 2128951296,
- 2129433856,
- 2129903744,
- 2130361600,
- 2130807424,
- 2131241728,
- 2131664768,
- 2132076928,
- 2132478208,
- 2132869248,
- 2133250048,
- 2133620992,
- 2133982208,
- 2134334080,
- 2134676864,
- 2135010688,
- 2135335936,
- 2135652608,
- 2135961088,
- 2136261504,
- 2136554112,
- 2136839168,
- 2137116800,
- 2137387136,
- 2137650560,
- 2137907072,
- 2138156928,
- 2138400256,
- 2138637184,
- 2138867968,
- 2139092864,
- 2139311744,
- 2139524992,
- 2139732736,
- 2139934976,
- 2140131968,
- 2140323840,
- 2140510720,
- 2140692736,
- 2140870016,
- 2141042688,
- 2141210752,
- 2141374592,
- 2141534080,
- 2141689344,
- 2141840640,
- 2141987968,
- 2142131456,
- 2142271232,
- 2142407424,
- 2142539904,
- 2142669056,
- 2142794752,
- 2142917248,
- 2143036544,
- 2143152640,
- 2143265792,
- 2143375872,
- 2143483264,
- 2143587712,
- 2143689472,
- 2143788544,
- 2143885056,
- 2143979136,
- 2144070656,
- 2144159872,
- 2144246656,
- 2144331264,
- 2144413568,
- 2144493824,
- 2144571904,
- 2144647936,
- 2144722048,
- 2144794240,
- 2144864512,
- 2144932864,
- 2144999552,
- 2145064448,
- 2145127680,
- 2145189248,
- 2145249152,
- 2145307520,
- 2145364480,
- 2145419776,
- 2145473792,
- 2145526272,
- 2145577472,
- 2145627264,
- 2145675776,
- 2145723008,
- 2145768960,
- 2145813760,
- 2145857408,
- 2145899904,
- 2145941376,
- 2145981696,
- 2146020864,
- 2146059136,
- 2146096384,
- 2146132608,
- 2146167936,
- 2146202368,
- 2146235776,
- 2146268416,
- 2146300160,
- 2146331136,
- 2146361216,
- 2146390528,
- 2146419200,
- 2146446976,
- 2146474112,
- 2146500480,
- 2146526208,
- 2146551168,
- 2146575488,
- 2146599296,
- 2146622464,
- 2146644864,
- 2146666880,
- 2146688128,
- 2146708992,
- 2146729216,
- 2146748928,
- 2146768128,
- 2146786816,
- 2146805120,
- 2146822784,
- 2146840064,
- 2146856960,
- 2146873344,
- 2146889216,
- 2146904832,
- 2146919936,
- 2146934656,
- 2146948992,
- 2146962944,
- 2146976640,
- 2146989824,
- 2147002752,
- 2147015296,
- 2147027584,
- 2147039488,
- 2147051136,
- 2147062400,
- 2147073408,
- 2147084160,
- 2147094528,
- 2147104768,
- 2147114624,
- 2147124352,
- 2147133696,
- 2147142912,
- 2147151744,
- 2147160448,
- 2147168896,
- 2147177088,
- 2147185152,
- 2147192960,
- 2147200512,
- 2147207936,
- 2147215104,
- 2147222144,
- 2147229056,
- 2147235712,
- 2147242112,
- 2147248384,
- 2147254656,
- 2147260544,
- 2147266432,
- 2147272064,
- 2147277568,
- },
-
-
-};
-
/*-------------------------------------------------------------------------
* DFT Stereo ROM tables
*------------------------------------------------------------------------*/
diff --git a/lib_com/ivas_rom_com.h b/lib_com/ivas_rom_com.h
index 6cd11215df85ee5f3beec5ccd7dce360e62407d3..86538241043bf53b4f1d870da759ad9899c44318 100644
--- a/lib_com/ivas_rom_com.h
+++ b/lib_com/ivas_rom_com.h
@@ -327,7 +327,5 @@ extern const Word16 sns_1st_means_32k[2][16];
extern const Word16 ivas_param_upmx_mx_qmap[33];
-extern const Word32 release_cnst_table[4][201]; // Q31
-
/* IVAS_ROM_COM_H */
#endif
diff --git a/lib_com/ivas_rom_com_fx.c b/lib_com/ivas_rom_com_fx.c
index a7a8bdcbfd6176743ab5f8571aa3cb82905bd5fc..3d85f546fbacfa27d4a608ae65b25255af0c5b8e 100644
--- a/lib_com/ivas_rom_com_fx.c
+++ b/lib_com/ivas_rom_com_fx.c
@@ -1545,6 +1545,7 @@ const Word16 ivas_param_mc_quant_icc_fx[PARAM_MC_SZ_ICC_QUANTIZER] = {
/* from 1 to 11 bits*/ /*q factor = 8*/
const Word32 no_phi_masa_inv_fx[NO_SPHERICAL_GRIDS][MAX_NO_THETA] = {
+#ifndef FIX_1379_MASA_ANGLE_ROUND
{ 1073741824 },
{ 536870912 },
{ 536870912, 1073741824 },
@@ -1556,8 +1557,22 @@ const Word32 no_phi_masa_inv_fx[NO_SPHERICAL_GRIDS][MAX_NO_THETA] = {
{ 44739242, 45691141, 47721858, 52377649, 61356675, 76695844, 107374182, 178956970, 1073741824, 2147483647 },
{ 35791394, 35791394, 37025580, 38347922, 39768215, 42949672, 46684427, 52377649, 59652323, 71582788, 93368854, 126322567, 214748364, 2147483647 },
{ 24129029, 24129029, 24403223, 24970740, 25565281, 26512143, 27889398, 29417584, 31580641, 34087042, 37675151, 42107522, 48806446, 56512727, 71582788, 93368854, 143165576, 268435456, 2147483647 }
+#else
+ { 1073741824 },
+ { 536870912 },
+ { 536870912, 1073741824 },
+ { 268435456, 536870912 },
+ { 178956971, 306783378, 1073741824, 2147483647 },
+ { 153391689, 165191050, 238609294, 1073741824, 2147483647 },
+ { 97612893, 102261126, 126322568, 195225786, 715827883, 2147483647 },
+ { 65075262, 67108864, 74051160, 93368854, 126322568, 238609294, 2147483647 },
+ { 44739243, 45691141, 47721859, 52377650, 61356676, 76695845, 107374182, 178956971, 1073741824, 2147483647 },
+ { 35791394, 35791394, 37025580, 38347922, 39768216, 42949673, 46684427, 52377650, 59652324, 71582788, 93368854, 126322568, 214748365, 2147483647 },
+ { 24129030, 24129030, 24403223, 24970740, 25565282, 26512144, 27889398, 29417584, 31580642, 34087042, 37675152, 42107523, 48806447, 56512728, 71582788, 93368854, 143165577, 268435456, 2147483647 },
+#endif
};
+
const Word32 azimuth_cb_fx[8] = {
0, -754974720, -377487360, 377487360, -188743680, 188743680, -566231040, 566231040
};
@@ -1589,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
@@ -1611,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 */
@@ -5101,4 +5125,822 @@ const Word32 ivas_fb_fr_12band_1ms_im_fx[IVAS_FB_12_1MS_LEN] = {
};
+const Word32 release_cnst_table[4][201] = // Q31
+ {
+ {
+ 1913946752,
+ 1919716352,
+ 1925351680,
+ 1930855552,
+ 1936230784,
+ 1941479808,
+ 1946605312,
+ 1951609728,
+ 1956495744,
+ 1961265792,
+ 1965922304,
+ 1970467584,
+ 1974904320,
+ 1979234560,
+ 1983460736,
+ 1987585024,
+ 1991609856,
+ 1995537280,
+ 1999369344,
+ 2003108480,
+ 2006756480,
+ 2010315520,
+ 2013787520,
+ 2017174528,
+ 2020478464,
+ 2023701248,
+ 2026844672,
+ 2029910656,
+ 2032900992,
+ 2035817344,
+ 2038661376,
+ 2041435008,
+ 2044139648,
+ 2046777088,
+ 2049348864,
+ 2051856384,
+ 2054301440,
+ 2056685312,
+ 2059009536,
+ 2061275520,
+ 2063484672,
+ 2065638272,
+ 2067737856,
+ 2069784448,
+ 2071779584,
+ 2073724416,
+ 2075620096,
+ 2077467904,
+ 2079268992,
+ 2081024512,
+ 2082735488,
+ 2084403200,
+ 2086028416,
+ 2087612544,
+ 2089156352,
+ 2090660864,
+ 2092127104,
+ 2093555968,
+ 2094948480,
+ 2096305408,
+ 2097627776,
+ 2098916352,
+ 2100172032,
+ 2101395584,
+ 2102587776,
+ 2103749504,
+ 2104881408,
+ 2105984384,
+ 2107059072,
+ 2108106112,
+ 2109126400,
+ 2110120448,
+ 2111088896,
+ 2112032512,
+ 2112951808,
+ 2113847552,
+ 2114720128,
+ 2115570304,
+ 2116398592,
+ 2117205504,
+ 2117991552,
+ 2118757504,
+ 2119503616,
+ 2120230400,
+ 2120938496,
+ 2121628288,
+ 2122300288,
+ 2122954880,
+ 2123592576,
+ 2124213760,
+ 2124818944,
+ 2125408384,
+ 2125982592,
+ 2126541952,
+ 2127086848,
+ 2127617664,
+ 2128134656,
+ 2128638336,
+ 2129128832,
+ 2129606784,
+ 2130072192,
+ 2130525568,
+ 2130967296,
+ 2131397376,
+ 2131816448,
+ 2132224640,
+ 2132622080,
+ 2133009408,
+ 2133386496,
+ 2133753856,
+ 2134111744,
+ 2134460288,
+ 2134799744,
+ 2135130368,
+ 2135452416,
+ 2135766144,
+ 2136071680,
+ 2136369152,
+ 2136659072,
+ 2136941312,
+ 2137216256,
+ 2137484160,
+ 2137744896,
+ 2137998976,
+ 2138246400,
+ 2138487424,
+ 2138722176,
+ 2138950656,
+ 2139173376,
+ 2139390208,
+ 2139601408,
+ 2139807104,
+ 2140007424,
+ 2140202624,
+ 2140392576,
+ 2140577664,
+ 2140758016,
+ 2140933504,
+ 2141104512,
+ 2141271040,
+ 2141433216,
+ 2141591168,
+ 2141745024,
+ 2141894912,
+ 2142040832,
+ 2142182912,
+ 2142321408,
+ 2142456192,
+ 2142587392,
+ 2142715264,
+ 2142839808,
+ 2142961152,
+ 2143079296,
+ 2143194240,
+ 2143306240,
+ 2143415424,
+ 2143521664,
+ 2143625216,
+ 2143725952,
+ 2143824128,
+ 2143919744,
+ 2144012800,
+ 2144103424,
+ 2144191744,
+ 2144277760,
+ 2144361472,
+ 2144443136,
+ 2144522496,
+ 2144599936,
+ 2144675200,
+ 2144748544,
+ 2144820096,
+ 2144889600,
+ 2144957440,
+ 2145023488,
+ 2145087744,
+ 2145150336,
+ 2145211264,
+ 2145270656,
+ 2145328512,
+ 2145384832,
+ 2145439616,
+ 2145493120,
+ 2145545088,
+ 2145595776,
+ 2145645056,
+ 2145693184,
+ 2145739904,
+ 2145785472,
+ 2145829888,
+ 2145873152,
+ 2145915136,
+ 2145956224,
+ 2145996032,
+ 2146034944,
+ 2146072832,
+ 2146109696,
+ 2146145664,
+ 2146180608,
+ 2146214656,
+ 2146247808,
+ },
+ {
+ 2027355264,
+ 2030408704,
+ 2033386624,
+ 2036290944,
+ 2039123328,
+ 2041885440,
+ 2044578944,
+ 2047205376,
+ 2049766528,
+ 2052263680,
+ 2054698496,
+ 2057072384,
+ 2059387008,
+ 2061643520,
+ 2063843328,
+ 2065987968,
+ 2068078720,
+ 2070116864,
+ 2072103552,
+ 2074040192,
+ 2075927936,
+ 2077767936,
+ 2079561472,
+ 2081309568,
+ 2083013376,
+ 2084673920,
+ 2086292352,
+ 2087869696,
+ 2089406976,
+ 2090905216,
+ 2092365184,
+ 2093788032,
+ 2095174528,
+ 2096525824,
+ 2097842432,
+ 2099125632,
+ 2100375808,
+ 2101594240,
+ 2102781312,
+ 2103938048,
+ 2105065216,
+ 2106163456,
+ 2107233536,
+ 2108276096,
+ 2109292032,
+ 2110281728,
+ 2111246080,
+ 2112185728,
+ 2113101056,
+ 2113992960,
+ 2114861824,
+ 2115708288,
+ 2116532992,
+ 2117336448,
+ 2118119168,
+ 2118881792,
+ 2119624704,
+ 2120348416,
+ 2121053440,
+ 2121740288,
+ 2122409344,
+ 2123061120,
+ 2123696128,
+ 2124314624,
+ 2124917120,
+ 2125504128,
+ 2126075776,
+ 2126632832,
+ 2127175296,
+ 2127703808,
+ 2128218624,
+ 2128720000,
+ 2129208448,
+ 2129684352,
+ 2130147712,
+ 2130599168,
+ 2131038976,
+ 2131467264,
+ 2131884416,
+ 2132290816,
+ 2132686592,
+ 2133072256,
+ 2133447680,
+ 2133813504,
+ 2134169856,
+ 2134516864,
+ 2134854784,
+ 2135184000,
+ 2135504640,
+ 2135816960,
+ 2136121216,
+ 2136417536,
+ 2136706048,
+ 2136987136,
+ 2137260928,
+ 2137527552,
+ 2137787264,
+ 2138040192,
+ 2138286592,
+ 2138526464,
+ 2138760192,
+ 2138987776,
+ 2139209472,
+ 2139425408,
+ 2139635712,
+ 2139840512,
+ 2140039936,
+ 2140234240,
+ 2140423424,
+ 2140607744,
+ 2140787200,
+ 2140962048,
+ 2141132288,
+ 2141298048,
+ 2141459584,
+ 2141616896,
+ 2141769984,
+ 2141919232,
+ 2142064512,
+ 2142205952,
+ 2142343808,
+ 2142478080,
+ 2142608768,
+ 2142736128,
+ 2142860032,
+ 2142980864,
+ 2143098368,
+ 2143212928,
+ 2143324544,
+ 2143433088,
+ 2143538944,
+ 2143641984,
+ 2143742336,
+ 2143840000,
+ 2143935232,
+ 2144027904,
+ 2144118144,
+ 2144206080,
+ 2144291712,
+ 2144375168,
+ 2144456320,
+ 2144535424,
+ 2144612480,
+ 2144687488,
+ 2144760448,
+ 2144831616,
+ 2144900992,
+ 2144968448,
+ 2145034112,
+ 2145098112,
+ 2145160448,
+ 2145221248,
+ 2145280256,
+ 2145337856,
+ 2145393920,
+ 2145448576,
+ 2145501696,
+ 2145553536,
+ 2145603968,
+ 2145653120,
+ 2145700992,
+ 2145747456,
+ 2145792896,
+ 2145837056,
+ 2145880064,
+ 2145922048,
+ 2145962880,
+ 2146002560,
+ 2146041344,
+ 2146078976,
+ 2146115712,
+ 2146151424,
+ 2146186240,
+ 2146220160,
+ 2146253184,
+ 2146285312,
+ 2146316672,
+ 2146347136,
+ 2146376832,
+ 2146405760,
+ 2146433920,
+ 2146461440,
+ 2146488192,
+ 2146514176,
+ 2146539520,
+ 2146564224,
+ 2146588160,
+ 2146611584,
+ 2146634368,
+ 2146656640,
+ 2146678272,
+ 2146699264,
+ 2146719744,
+ 2146739712,
+ 2146759168,
+ 2146778112,
+ 2146796544,
+ 2146814464,
+ 2146832000,
+ 2146849024,
+ 2146865664,
+ },
+ {
+ 2086555136,
+ 2088125824,
+ 2089656576,
+ 2091148416,
+ 2092602240,
+ 2094018944,
+ 2095399680,
+ 2096745088,
+ 2098056192,
+ 2099333888,
+ 2100578816,
+ 2101792000,
+ 2102974080,
+ 2104125824,
+ 2105248128,
+ 2106341760,
+ 2107407232,
+ 2108445440,
+ 2109456896,
+ 2110442496,
+ 2111402624,
+ 2112338176,
+ 2113249664,
+ 2114137728,
+ 2115002880,
+ 2115845760,
+ 2116666880,
+ 2117466880,
+ 2118246272,
+ 2119005568,
+ 2119745280,
+ 2120465920,
+ 2121167872,
+ 2121851776,
+ 2122517888,
+ 2123166976,
+ 2123799168,
+ 2124414976,
+ 2125014912,
+ 2125599360,
+ 2126168704,
+ 2126723200,
+ 2127263360,
+ 2127789568,
+ 2128302208,
+ 2128801408,
+ 2129287808,
+ 2129761536,
+ 2130222976,
+ 2130672512,
+ 2131110272,
+ 2131536768,
+ 2131952128,
+ 2132356736,
+ 2132750848,
+ 2133134720,
+ 2133508736,
+ 2133872896,
+ 2134227584,
+ 2134573184,
+ 2134909696,
+ 2135237504,
+ 2135556736,
+ 2135867648,
+ 2136170624,
+ 2136465536,
+ 2136752896,
+ 2137032832,
+ 2137305344,
+ 2137570816,
+ 2137829376,
+ 2138081280,
+ 2138326528,
+ 2138565504,
+ 2138798080,
+ 2139024768,
+ 2139245440,
+ 2139460480,
+ 2139669888,
+ 2139873792,
+ 2140072320,
+ 2140265856,
+ 2140454144,
+ 2140637696,
+ 2140816384,
+ 2140990464,
+ 2141159936,
+ 2141325056,
+ 2141485824,
+ 2141642368,
+ 2141794944,
+ 2141943424,
+ 2142088064,
+ 2142228992,
+ 2142366208,
+ 2142499840,
+ 2142630016,
+ 2142756736,
+ 2142880128,
+ 2143000448,
+ 2143117440,
+ 2143231488,
+ 2143342592,
+ 2143450752,
+ 2143556096,
+ 2143658624,
+ 2143758592,
+ 2143855872,
+ 2143950592,
+ 2144043008,
+ 2144132864,
+ 2144220416,
+ 2144305664,
+ 2144388608,
+ 2144469504,
+ 2144548224,
+ 2144624896,
+ 2144699648,
+ 2144772352,
+ 2144843264,
+ 2144912256,
+ 2144979328,
+ 2145044864,
+ 2145108480,
+ 2145170560,
+ 2145231104,
+ 2145289856,
+ 2145347200,
+ 2145403008,
+ 2145457408,
+ 2145510400,
+ 2145561984,
+ 2145612160,
+ 2145661056,
+ 2145708672,
+ 2145755136,
+ 2145800192,
+ 2145844224,
+ 2145887104,
+ 2145928832,
+ 2145969408,
+ 2146008960,
+ 2146047616,
+ 2146085120,
+ 2146121600,
+ 2146157184,
+ 2146191872,
+ 2146225664,
+ 2146258560,
+ 2146290560,
+ 2146321792,
+ 2146352128,
+ 2146381696,
+ 2146410496,
+ 2146438528,
+ 2146465920,
+ 2146492416,
+ 2146518400,
+ 2146543616,
+ 2146568192,
+ 2146592128,
+ 2146615424,
+ 2146638080,
+ 2146660224,
+ 2146681728,
+ 2146702720,
+ 2146723072,
+ 2146743040,
+ 2146762368,
+ 2146781184,
+ 2146799616,
+ 2146817408,
+ 2146834816,
+ 2146851840,
+ 2146868352,
+ 2146884352,
+ 2146900096,
+ 2146915328,
+ 2146930176,
+ 2146944640,
+ 2146958720,
+ 2146972416,
+ 2146985856,
+ 2146998784,
+ 2147011456,
+ 2147023872,
+ 2147035904,
+ 2147047552,
+ 2147058944,
+ 2147070080,
+ 2147080832,
+ 2147091456,
+ 2147101696,
+ 2147111680,
+ 2147121408,
+ 2147130880,
+ 2147140096,
+ 2147149056,
+ 2147157760,
+ 2147166336,
+ 2147174656,
+ },
+ {
+ 2106670080,
+ 2107727232,
+ 2108757120,
+ 2109760640,
+ 2110738432,
+ 2111691008,
+ 2112619136,
+ 2113523328,
+ 2114404352,
+ 2115262592,
+ 2116098816,
+ 2116913408,
+ 2117707136,
+ 2118480256,
+ 2119233536,
+ 2119967360,
+ 2120682240,
+ 2121378688,
+ 2122057088,
+ 2122717952,
+ 2123361792,
+ 2123988992,
+ 2124599936,
+ 2125195136,
+ 2125774848,
+ 2126339584,
+ 2126889728,
+ 2127425536,
+ 2127947520,
+ 2128456064,
+ 2128951296,
+ 2129433856,
+ 2129903744,
+ 2130361600,
+ 2130807424,
+ 2131241728,
+ 2131664768,
+ 2132076928,
+ 2132478208,
+ 2132869248,
+ 2133250048,
+ 2133620992,
+ 2133982208,
+ 2134334080,
+ 2134676864,
+ 2135010688,
+ 2135335936,
+ 2135652608,
+ 2135961088,
+ 2136261504,
+ 2136554112,
+ 2136839168,
+ 2137116800,
+ 2137387136,
+ 2137650560,
+ 2137907072,
+ 2138156928,
+ 2138400256,
+ 2138637184,
+ 2138867968,
+ 2139092864,
+ 2139311744,
+ 2139524992,
+ 2139732736,
+ 2139934976,
+ 2140131968,
+ 2140323840,
+ 2140510720,
+ 2140692736,
+ 2140870016,
+ 2141042688,
+ 2141210752,
+ 2141374592,
+ 2141534080,
+ 2141689344,
+ 2141840640,
+ 2141987968,
+ 2142131456,
+ 2142271232,
+ 2142407424,
+ 2142539904,
+ 2142669056,
+ 2142794752,
+ 2142917248,
+ 2143036544,
+ 2143152640,
+ 2143265792,
+ 2143375872,
+ 2143483264,
+ 2143587712,
+ 2143689472,
+ 2143788544,
+ 2143885056,
+ 2143979136,
+ 2144070656,
+ 2144159872,
+ 2144246656,
+ 2144331264,
+ 2144413568,
+ 2144493824,
+ 2144571904,
+ 2144647936,
+ 2144722048,
+ 2144794240,
+ 2144864512,
+ 2144932864,
+ 2144999552,
+ 2145064448,
+ 2145127680,
+ 2145189248,
+ 2145249152,
+ 2145307520,
+ 2145364480,
+ 2145419776,
+ 2145473792,
+ 2145526272,
+ 2145577472,
+ 2145627264,
+ 2145675776,
+ 2145723008,
+ 2145768960,
+ 2145813760,
+ 2145857408,
+ 2145899904,
+ 2145941376,
+ 2145981696,
+ 2146020864,
+ 2146059136,
+ 2146096384,
+ 2146132608,
+ 2146167936,
+ 2146202368,
+ 2146235776,
+ 2146268416,
+ 2146300160,
+ 2146331136,
+ 2146361216,
+ 2146390528,
+ 2146419200,
+ 2146446976,
+ 2146474112,
+ 2146500480,
+ 2146526208,
+ 2146551168,
+ 2146575488,
+ 2146599296,
+ 2146622464,
+ 2146644864,
+ 2146666880,
+ 2146688128,
+ 2146708992,
+ 2146729216,
+ 2146748928,
+ 2146768128,
+ 2146786816,
+ 2146805120,
+ 2146822784,
+ 2146840064,
+ 2146856960,
+ 2146873344,
+ 2146889216,
+ 2146904832,
+ 2146919936,
+ 2146934656,
+ 2146948992,
+ 2146962944,
+ 2146976640,
+ 2146989824,
+ 2147002752,
+ 2147015296,
+ 2147027584,
+ 2147039488,
+ 2147051136,
+ 2147062400,
+ 2147073408,
+ 2147084160,
+ 2147094528,
+ 2147104768,
+ 2147114624,
+ 2147124352,
+ 2147133696,
+ 2147142912,
+ 2147151744,
+ 2147160448,
+ 2147168896,
+ 2147177088,
+ 2147185152,
+ 2147192960,
+ 2147200512,
+ 2147207936,
+ 2147215104,
+ 2147222144,
+ 2147229056,
+ 2147235712,
+ 2147242112,
+ 2147248384,
+ 2147254656,
+ 2147260544,
+ 2147266432,
+ 2147272064,
+ 2147277568,
+ },
+
+
+ };
+
/* clang-format on */
diff --git a/lib_com/ivas_rom_com_fx.h b/lib_com/ivas_rom_com_fx.h
index 3344a35d208b8ed225895c9bab0f66db88ac7978..54a620b154dc0410d69c1bb5ef3befe6dfc97d75 100644
--- a/lib_com/ivas_rom_com_fx.h
+++ b/lib_com/ivas_rom_com_fx.h
@@ -292,4 +292,10 @@ extern const Word32 ivas_fb_fr_12band_1ms_re_fx[IVAS_FB_12_1MS_LEN];
extern const Word32 ivas_fb_fr_12band_1ms_im_fx[IVAS_FB_12_1MS_LEN];
+/*----------------------------------------------------------------------*
+ * Limiter tables
+ *-----------------------------------------------------------------------*/
+
+extern const Word32 release_cnst_table[4][201]; // Q31
+
#endif
diff --git a/lib_com/ivas_sns_com_fx.c b/lib_com/ivas_sns_com_fx.c
index fa64b0092d6de30d78c2199930ea32e99629cb3a..f1e44be78bdfea1016e77b24dd00e2433ca3d2cb 100644
--- a/lib_com/ivas_sns_com_fx.c
+++ b/lib_com/ivas_sns_com_fx.c
@@ -200,9 +200,16 @@ void sns_compute_scf_fx(
/* mean = sum / FDNS_NPTS;
-Q6 is for division with FDNS_NPTS and -Q1 is to reduce Q by one */
- mean = W_shl_sat_l( sum, -Q7 ); // q_out
- nf = Mpy_32_32( mean, 214748 /* powf( 10.0f, -4.0f ) in Q31 */ ); // q_out
- nf = L_max( nf, L_shl( 256, sub( q_out, 40 ) ) /* powf( 2.0f, -32.0f ) in Q40 */ ); // q_out
+ mean = W_shl_sat_l( sum, -Q7 ); // q_out
+ nf = Mpy_32_32( mean, 214748 /* powf( 10.0f, -4.0f ) in Q31 */ ); // q_out
+
+ IF( LE_32( nf, L_shl_sat( 256, sub( q_out, 40 ) ) ) ) /* powf( 2.0f, -32.0f ) in Q40 */
+ {
+ nf = 256;
+ move32();
+ q_out = 40;
+ move16();
+ }
FOR( i = 0; i < FDNS_NPTS; i++ )
{
diff --git a/lib_com/ivas_spar_com_fx.c b/lib_com/ivas_spar_com_fx.c
index 8aaeb7f63b97fdf8e81aa76c9798808e0569ea29..c2ad11e2614664529fae09ba2f0bb0256349b627 100644
--- a/lib_com/ivas_spar_com_fx.c
+++ b/lib_com/ivas_spar_com_fx.c
@@ -985,7 +985,7 @@ static void ivas_get_pred_coeffs_enc_fx(
move32();
dm_g_q[b] = Q29;
move16();
- DM_F[b] = BASOP_Util_Divide3232_Scale_cadence( Mpy_32_32( dm_g[b], num_f ), den_f, &s_dm_f ); // Q=(31-(s_dm_f+2+num_f_e-den_f_e))
+ DM_F[b] = BASOP_Util_Divide3232_Scale_newton( Mpy_32_32( dm_g[b], num_f ), den_f, &s_dm_f ); // Q=(31-(s_dm_f+2+num_f_e-den_f_e))
move32();
DM_F_q[b] = sub( 31, add( s_dm_f, sub( add( 2, num_f_e ), den_f_e ) ) );
move16();
@@ -1514,7 +1514,7 @@ static void ivas_get_pred_coeffs_fx(
den_f = L_max( den_f, 1 ); // Q=31-den_f_e
dm_g[b] = activew_quad_thresh; // Q29
move32();
- DM_F[b] = BASOP_Util_Divide3232_Scale_cadence( Mpy_32_32( dm_g[b], num_f ), den_f, &s_dm_f ); // s_dm_f+2+num_f_e-den_f_e
+ DM_F[b] = BASOP_Util_Divide3232_Scale_newton( Mpy_32_32( dm_g[b], num_f ), den_f, &s_dm_f ); // s_dm_f+2+num_f_e-den_f_e
move32();
s_dm_f = add( s_dm_f, sub( add( 2, num_f_e ), den_f_e ) ); /*Resultant exp for DM_F s_dm_f +( 2 + num_f_e ) - den_f_e*/
div_shift = sub( s_dm_f, 1 );
diff --git a/lib_com/ivas_transient_det_fx.c b/lib_com/ivas_transient_det_fx.c
index 3b9a8cfd7ebf1e22ec6513d4a5f5229e53c9d53d..fb8679ebc8e218ddcf1ce12ad0bcc59dcc899a35 100644
--- a/lib_com/ivas_transient_det_fx.c
+++ b/lib_com/ivas_transient_det_fx.c
@@ -353,7 +353,7 @@ static Word32 ivas_calc_duck_gain_fx(
test();
IF( ( env_1 != 0 ) && ( env_2 != 0 ) )
{
- L_tmp = BASOP_Util_Divide3232_Scale_cadence( env_1, env_2, &tmp_e );
+ L_tmp = BASOP_Util_Divide3232_Scale_newton( env_1, env_2, &tmp_e );
L_tmp = L_shl( L_tmp, add( sub( env1_e, env2_e ), tmp_e ) );
duck_gain_out = Mpy_32_32( duck_mult_fac, L_tmp ); /*Q29*/
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 5f0f5aaec035d6eeb5ff1785b03453e6bf58056c..4b3e200a4560e8568d04886fa6f6a97f7cc97798 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 cf2ad8a8a0df8a9294e4f0a13f57664441b19676..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
@@ -128,21 +133,31 @@ void init_lvq_fx(
FOR( i = 0; i < MAX_NO_MODES; i++ )
{
#ifdef OPT_STEREO_32KBPS_V1
- FOR( ( j = 0, k = 0 ); j < MAX_NO_SCALES; ( j++, k++ ) )
+ FOR( ( j = 0, k = 0 ); j < MAX_NO_SCALES; j++ )
{
- if ( ( no_lead_fx[i][j] <= 0 ) )
+ if ( no_lead_fx[i][j] > 0 )
{
- j = MAX_NO_SCALES;
+ k = add( k, 1 );
+ }
+ if ( no_lead_fx[i][j] <= 0 )
+ {
+ j = MAX_NO_SCALES - 1;
+ move16();
}
}
no_scales[i][0] = k;
move16();
- FOR( k = 0; j < MAX_NO_SCALES << 1; ( j++, k++ ) )
+ FOR( k = 0; j < MAX_NO_SCALES << 1; j++ )
{
+ if ( no_lead_fx[i][j] > 0 )
+ {
+ k = add( k, 1 );
+ }
if ( no_lead_fx[i][j] <= 0 )
{
j = MAX_NO_SCALES << 1;
+ move16();
}
}
no_scales[i][1] = k;
@@ -172,23 +187,32 @@ void init_lvq_fx(
FOR( i = 0; i < MAX_NO_MODES_p; i++ )
{
#ifdef OPT_STEREO_32KBPS_V1
- FOR( ( j = 0, k = 0 ); j < MAX_NO_SCALES; ( j++, k++ ) )
+ FOR( ( j = 0, k = 0 ); j < MAX_NO_SCALES; j++ )
{
-
+ if ( no_lead_p_fx[i][j] > 0 )
+ {
+ k = add( k, 1 );
+ }
if ( ( no_lead_p_fx[i][j] <= 0 ) )
{
- j = MAX_NO_SCALES;
+ j = MAX_NO_SCALES - 1;
+ move16();
}
}
no_scales_p[i][0] = k;
move16();
- FOR( k = 0; j < MAX_NO_SCALES << 1; ( j++, k++ ) )
+ FOR( k = 0; j < MAX_NO_SCALES << 1; j++ )
{
+ if ( no_lead_p_fx[i][j] > 0 )
+ {
+ k = add( k, 1 );
+ }
if ( ( no_lead_p_fx[i][j] <= 0 ) )
{
j = MAX_NO_SCALES << 1;
+ move16();
}
}
@@ -241,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*/
@@ -1291,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 f7f80f633575231975e88e1d49554cec81ad5abe..cc4eef5cc08f27bbf40a3df5633adff256fe65dd 100644
--- a/lib_com/options.h
+++ b/lib_com/options.h
@@ -43,6 +43,7 @@
/*#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 */
@@ -71,7 +72,10 @@
#define FIX_1378_ACELP_OUT_OF_BOUNDS
-//#define OPT_STEREO_32KBPS_V1 /* Optimization made in stereo decoding path for 32kbps decoding */
+#define FIX_1379_MASA_ANGLE_ROUND
+
+/* Note: each compile switch (FIX_1101_...) is independent from the other ones */
+#define OPT_STEREO_32KBPS_V1 /* Optimization made in stereo decoding path for 32kbps decoding */
#define OPT_AVOID_STATE_BUF_RESCALE /* Optimization made to avoid rescale of synth state buffer */
#define FIX_1310_SPEEDUP_ivas_dirac_dec_get_response_fx /*FhG: WMOPS tuning, nonbe*/
#define FIX_1310_SPEEDUP_ivas_dirac_dec_output_synthesis_process_slot /*FhG: WMOPS tuning, nonbe*/
@@ -83,6 +87,19 @@
//#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_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 TEST_HR
+#define REMOVE_EVS_DUPLICATES /* remove core-coder duplicated functions, ACELP low-band decoder */
/* #################### Start BASOP porting switches ############################ */
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/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 45641b3f8f6789c864216b5d78a78c3b7d747452..e899d32f9a9a66accde339fe97c2f9973c716c3e 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 */
@@ -3264,6 +3222,20 @@ void interp_code_4over2_fx(
void wb_tbe_extras_reset_synth_fx( Word16 state_lsyn_filt_shb[], Word16 state_lsyn_filt_dwn_shb[], Word16 state_32and48k_WB_upsample[], Word16 state_resamp_HB[] );
+#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 Word16 element_mode,
+#endif
+ Word16 IsUpsampled3,
+ Word16 input_fx[], /* i : input signal Q_input_fx*/
+ Word16 *Q_input_fx,
+ Word16 output_fx[], /* o : output signal */
+ Word32 memory_fx[][4], /* i/o: 4 arrays of 4 for memory memory_fx_Q */
+ Word16 memory_fx_Q[],
+ const Word16 full_band_bpf[][5] /* i : filter coefficients b0,b1,b2,a0,a1,a2 Q13 */
+);
+#else
void elliptic_bpf_48k_generic_fx(
const Word16 input_fx[], /* i : i signal Q_input_fx */
Word16 *Q_input_fx,
@@ -3272,6 +3244,7 @@ void elliptic_bpf_48k_generic_fx(
Word16 memory_fx_Q[],
const Word16 full_band_bpf[][5] /* i : filter coefficients b0,b1,b2,a0,a1,a2 Q13 */
);
+#endif
void synthesise_fb_high_band_fx(
const Word16 excitation_in[], /* i : full band excitation */
@@ -3284,67 +3257,40 @@ void synthesise_fb_high_band_fx(
Word16 *prev_fbbwe_ratio, /* o : previous frame energy for FEC */
Word32 bpf_memory[][4], /* i/o: memory for elliptic bpf 48k */
Word16 bpf_memory_Q[],
- Word16 Qout );
-
-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
+ Word16 Qout
+#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2
,
- 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
-);
-
-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 */
+ Word16 element_mode
#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 */
+void prep_tbe_exc_fx(
+ 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(
@@ -3781,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.
@@ -4147,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
@@ -4158,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(
@@ -4343,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[],
@@ -4708,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,
@@ -4856,34 +4795,6 @@ Word16 BITS_ALLOC_config_acelp(
const Word16 narrowband,
const Word16 nb_subfr );
-ivas_error config_acelp1(
- const Word16 enc_dec, /* i : encoder/decoder flag */
- const Word32 total_brate, /* i : total bitrate */
- const Word32 core_brate_inp, /* i : core bitrate */
- const Word16 core, /* i : core */
- const Word16 extl, /* i : extension layer */
- const Word32 extl_brate, /* i : extension layer bitrate */
- const Word16 L_frame, /* i : frame length at internal Fs */
- const Word16 GSC_noisy_speech, /* i : GSC on SWB noisy speech flag */
- ACELP_config *acelp_cfg, /* i : ACELP bit-allocation */
- const Word16 signalling_bits, /* i : number of signalling bits */
- const Word16 coder_type, /* i : coder type */
- const Word16 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 set_ACELP_flag(
const Word16 element_mode, /* i : element mode */
const Word32 element_brate, /* i : element bitrate */
@@ -5011,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(
@@ -5707,7 +5618,7 @@ 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 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 */
@@ -5830,33 +5741,19 @@ void tcx_ltp_post_fx32(
Word32 *tcx_buf, /* sig_q */
Word16 sig_q );
-// 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 */
-);
-
-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
@@ -6089,31 +5986,16 @@ void td_bwe_dec_init_fx(
const Word32 output_Fs /* i : output sampling rate */
);
-// 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*/
-);
-
-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 */
@@ -6158,6 +6040,15 @@ void v_add_fixed(
const Word16 hdrm /* i : headroom for when subtraction result > 1 or < -1 */
);
+#ifdef VEC_ARITH_OPT_v1
+void v_add_fixed_no_hdrm(
+ const Word32 x1[], /* i : Input vector 1 */
+ const Word32 x2[], /* i : Input vector 2 */
+ Word32 y[], /* o : Output vector that contains vector 1 + vector 2 */
+ const Word16 N /* i : Vector length */
+);
+#endif /* VEC_ARITH_OPT_v1 */
+
void v_add_fixed_me(
const Word32 x1[], /* i : Input vector 1 */
const Word16 x1_e, /* i : Exponent for input vector 1 */
@@ -6192,6 +6083,15 @@ void v_sub_fixed(
const Word16 hdrm /* i : headroom for when subtraction result > 1 or < -1 */
);
+#ifdef VEC_ARITH_OPT_v1
+void v_sub_fixed_no_hdrm(
+ const Word32 x1[], /* i : Input vector 1 */
+ const Word32 x2[], /* i : Input vector 2 */
+ Word32 y[], /* o : Output vector that contains vector 1 - vector 2 */
+ const Word16 N /* i : Vector length */
+);
+#endif /* VEC_ARITH_OPT_v1 */
+
/*! r: dot product of x[] and y[] */
Word32 dotp_fixed(
const Word32 x[], /* i : vector x[] */
@@ -6258,20 +6158,9 @@ void lsf_mid_dec_fx(
Word16 lsp_mid[] /* o : quantized LSPs Q15*/
);
-// 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 );
-
-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) */
@@ -6445,12 +6334,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[],
@@ -6470,12 +6354,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[],
@@ -6500,11 +6379,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
@@ -6532,12 +6411,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,
@@ -6562,20 +6436,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 */
@@ -6605,9 +6472,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(
@@ -6649,6 +6513,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 */
);
@@ -6681,12 +6557,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 */
@@ -6698,25 +6574,14 @@ void nb_post_filt_fx(
);
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 */
-);
-
-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) */
@@ -6882,33 +6747,17 @@ void PulseResynchronization_fx(
Word32 /*float*/ const pitchEnd /*i Q16*/
);
-// 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*/
-);
-
-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*/
@@ -6916,29 +6765,16 @@ void decod_audio_ivas_fx(
);
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 );
-
-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(
@@ -6949,18 +6785,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 */
@@ -7005,24 +6838,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 */
-);
-
-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(
@@ -7043,13 +6860,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(
@@ -7143,22 +6961,7 @@ void re8_PPV_fx(
Word16 y[] /* o : point in RE8 (8-dimensional integer vector) Q0 */
);
-// 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*/
-);
-
-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 */
@@ -7168,7 +6971,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 */
);
@@ -7212,23 +7015,8 @@ void Mode2_delta_pit_dec(
Word16 **pt_indice /* i/o: pointer to Vector of Q indexes */
);
-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 */
-);
-
/* 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 */
@@ -7589,21 +7377,7 @@ void configureFdCngDec_fx(
const Word16 Last_L_frame,
const Word16 element_mode );
-/* 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 );
-
-Word16 ApplyFdCng_ivas_fx(
Word16 *timeDomainInput, /* i : pointer to time domain input */
Word16 Q,
Word32 *powerSpectrum,
@@ -7619,9 +7393,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 */
);
@@ -8195,13 +7966,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 */
);
-// 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*/
@@ -8228,66 +7997,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 */
-);
-
-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,
- 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 */
@@ -8297,15 +8037,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(
@@ -8332,10 +8071,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
@@ -8387,18 +8122,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 */
@@ -8503,7 +8227,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 */
@@ -8537,38 +8261,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 */
);
-// dec_uv_fx.c
void decod_unvoiced_fx(
- Decoder_State *st_fx, /* i/o: decoder static memory */
- 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 );
-
-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
@@ -8600,37 +8314,20 @@ void gaus_L2_dec(
Word16 *seed_acelp /*i/o : random seed Q0 */
);
-// 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*/
-);
-
-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 */
);
@@ -8769,10 +8466,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,
@@ -8849,7 +8546,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 */
@@ -8950,28 +8647,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,
@@ -8987,11 +8674,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,
@@ -9011,10 +8698,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,
@@ -9025,18 +8712,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,
@@ -9157,15 +8844,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 */
@@ -9389,17 +9069,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
@@ -9559,31 +9228,6 @@ void d_gain_pred_fx(
Word16 *Es_pred, /* o : predicited scaled innovation energy */
Word16 **pt_indice /* i/o: pointer to the buffer of indices */
);
-// 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 */
-);
// evs_dec_fx.c
ivas_error evs_dec_fx(
@@ -9638,7 +9282,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(
@@ -9692,10 +9336,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(
@@ -9733,7 +9377,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 */
);
@@ -9752,7 +9396,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 );
@@ -9912,8 +9556,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(
@@ -9991,6 +9635,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*/
@@ -10502,6 +10152,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 );
@@ -10603,8 +10259,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(
@@ -10654,7 +10310,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 */
@@ -10754,10 +10410,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(
@@ -10765,10 +10421,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(
@@ -10857,32 +10513,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(
@@ -10951,6 +10607,7 @@ Word16 ari_decode_14bits_pow_ivas(
Word16 *res,
Tastat *s,
UWord16 base );
+
Word16 ari_decode_14bits_sign_ivas(
Word16 *ptr,
Word16 bp,
@@ -10964,22 +10621,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 */
@@ -11007,13 +10663,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 */
@@ -11150,7 +10825,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 */
);
@@ -11223,69 +10898,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(
@@ -11302,52 +10950,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(
@@ -11357,63 +10979,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(
@@ -11424,18 +11005,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 */
@@ -11448,8 +11035,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 */
@@ -11458,9 +11045,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(
@@ -11470,44 +11057,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(
@@ -11516,7 +11103,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 */
);
@@ -11543,13 +11130,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(
@@ -11562,8 +11149,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 */
@@ -11584,31 +11171,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)*/
@@ -11808,31 +11370,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 );
@@ -11885,7 +11447,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/pvq_com_fx.c b/lib_com/pvq_com_fx.c
index a6c0bc462d6757c2a53af013c84dff95f6b44461..1adcdb7ae6074f3f2b89dbd4883a144f48883b55 100644
--- a/lib_com/pvq_com_fx.c
+++ b/lib_com/pvq_com_fx.c
@@ -564,8 +564,8 @@ void fine_gain_quant_fx(
tmp1 = extract_l( Pow2( 14, tmp1 ) );
exp1 = sub( 14, exp1 );
- L_tmp = L_mult0( fg_pred[band], tmp1 ); /*12+exp1 */
- fg_pred[band] = round_fx( L_shl( L_tmp, sub( 16, exp1 ) ) ); /*12+exp1+16-exp1-16=12 */
+ L_tmp = L_mult0( fg_pred[band], tmp1 ); /*12+exp1 */
+ fg_pred[band] = round_fx_sat( L_shl_sat( L_tmp, sub( 16, exp1 ) ) ); /*12+exp1+16-exp1-16=12 */
move16();
}
}
diff --git a/lib_com/stat_com.h b/lib_com/stat_com.h
index f99d498027a98db71cfbed521e46712659506917..80822f59e999002977b27fcd97ab7095a469e10b 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;
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 238b478c5abce7058655ca0592e3f89969e1e201..96d07e7ef305ed4534d8dd4a3ae338a537a7dbda 100644
--- a/lib_com/swb_tbe_com_fx.c
+++ b/lib_com/swb_tbe_com_fx.c
@@ -1645,7 +1645,12 @@ void GenShapedWBExcitation_ivas_fx(
}
}
- Syn_filt_s( 0, lpc_shb, LPC_SHB_ORDER_WB, exc4kWhtnd, excSHB, L_FRAME16k / 4, state_lpc_syn, 1 );
+ Scale_sig( state_lpc_syn, LPC_SHB_ORDER, -Q2 ); /* Q(Q_bwe_exc) -> Q(Q_bwe_exc - 2) */
+
+ Syn_filt_s( Q2, lpc_shb, LPC_SHB_ORDER_WB, exc4kWhtnd, excSHB, L_FRAME16k / 4, state_lpc_syn, 1 );
+
+ Scale_sig( state_lpc_syn, LPC_SHB_ORDER, Q2 ); /* Q(Q_bwe_exc - 2) -> Q(Q_bwe_exc) */
+ Scale_sig( excSHB, L_FRAME16k / 4, Q2 ); /* Q(Q_bwe_exc - 2) -> Q(Q_bwe_exc) */
return;
}
@@ -2097,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];
@@ -2155,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 );
@@ -2200,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();
@@ -2239,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 */
@@ -2289,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 );
@@ -2320,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;
@@ -2371,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;
@@ -2434,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 );
@@ -2541,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 */
+ /* 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 );
- /*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 */
- }
-
- 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 );
+
+ /* 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*/
}
}
+}
-#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 */
- }
- ELSE
- {
- set16_fx( zero_mem, 0, LPC_SHB_ORDER );
+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, 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, 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 + ( 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 + 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 + 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 + 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 + 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 + 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();
- /* 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 );
+ /* 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 );
- /* 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) */
+ /* 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) */
- *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) */
-
- /* 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 */
- FOR( i = 0; i < 10; i++ )
- {
- 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();
- }
- }
+ 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) */
+}
- *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 );
+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) */
- deemph_fx( White_exc16k_FB, fb_deemph_fac, L_FRAME16k, fb_tbe_demph );
- }
- ELSE
+ FOR( i = 0; i < 10; i++ )
{
- set16_fx( White_exc16k_FB, 0, L_FRAME16k );
+ 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();
+ }
}
-#ifdef ADD_IVAS_TBE_CODE
- *prev_pow_exc16kWhtnd = pow1;
- *prev_mix_factor = mix_factor;
-#endif
- return;
+ *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 );
+}
+
+return;
}
void GenShapedSHBExcitation_ivas_enc_fx(
@@ -3283,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 ) )
{
@@ -3469,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 );
@@ -3998,7 +3720,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;
@@ -4013,7 +3734,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 )
@@ -4045,11 +3766,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();
@@ -4084,11 +3801,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 */
@@ -4134,12 +3848,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 );
@@ -4166,7 +3876,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;
@@ -4226,7 +3936,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 ) );
@@ -4252,7 +3962,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 ) )
{
@@ -4298,7 +4007,6 @@ void GenShapedSHBExcitation_ivas_dec_fx(
}
}
ELSE
-#endif
{
/* create a random excitation - Reuse exc16k memory */
White_exc16k = exc16k;
@@ -4347,20 +4055,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 ) )
{
@@ -4539,33 +4242,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 );
@@ -4583,7 +4259,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 )
@@ -4601,7 +4276,6 @@ void GenShapedSHBExcitation_ivas_dec_fx(
}
}
ELSE
-#endif
{
/* *vf_ind is an integer scale by 0.125f*/
tmp = shl( *vf_ind, ( 15 - 3 ) );
@@ -4614,10 +4288,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();
@@ -4974,10 +4646,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;
}
@@ -6301,7 +5971,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) */
@@ -6375,7 +6045,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) */
@@ -6695,7 +6365,15 @@ void wb_tbe_extras_reset_synth_fx(
*-------------------------------------------------------------------*/
void elliptic_bpf_48k_generic_fx(
+#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2
+ const int16_t element_mode,
+#endif
+#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic
+ Word16 IsUpsampled3,
+ Word16 input_fx[], /* i : input signal Q_input_fx*/
+#else
const Word16 input_fx[], /* i : input signal Q_input_fx*/
+#endif
Word16 *Q_input_fx,
Word16 output_fx[], /* o : output signal memory_fx_Q */
Word32 memory_fx2[][4], /* i/o: 4 arrays of 4 for memory */
@@ -6704,24 +6382,164 @@ void elliptic_bpf_48k_generic_fx(
)
{
Word16 i, j;
+#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic
+ Word16 memory_fx0, Q_temp, Q_temp2;
+ Word32 L_tmp_buffer[L_FRAME48k + 4], L_tmp2_buffer[L_FRAME48k + 4], L_output_buffer[L_FRAME48k + 4], L_tmpX;
+ Word32 L_tmpMax;
+#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2
+ Word64 W_tmpX;
+ Word64 W_tmpY;
+#endif
+
+ Word32 *L_tmp = &L_tmp_buffer[4];
+ Word32 *L_tmp2 = &L_tmp2_buffer[4];
+ Word32 *L_output = &L_output_buffer[4];
+#else
Word16 memory_fx0[4][4], memory_fx[4][4], Q_temp, Q_temp2;
Word32 L_tmp[L_FRAME48k], L_tmp2[L_FRAME48k], L_output[L_FRAME48k], L_tmpX, memory2_fx[4][4], L_tmpMax;
Word32 memory2_fx_2[4], memory2_fx_3[4];
+#endif
FOR( i = 0; i < 4; i++ )
{
+#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic
+ memory_fx0 = extract_l( memory_fx2[0][i] );
+ input_fx[i - 4] = shl_sat( memory_fx0, sub( *Q_input_fx, memory_fx_Q[0] ) );
+ L_tmp[i - 4] = L_shl_sat( memory_fx2[1][i], sub( add( *Q_input_fx, 11 ), memory_fx_Q[1] ) );
+ L_tmp2[i - 4] = L_shl_sat( memory_fx2[2][i], sub( add( *Q_input_fx, 6 ), memory_fx_Q[2] ) );
+ // memory2_fx[3][i] = L_shl_sat( memory_fx2[3][i], sub( add( *Q_input_fx, 1 ), memory_fx_Q[3] ) );
+ move32();
+ move32();
+ move32();
+ move32();
+ move32();
+#else
memory_fx0[0][i] = extract_l( memory_fx2[0][i] );
memory_fx[0][i] = shl_sat( memory_fx0[0][i], sub( *Q_input_fx, memory_fx_Q[0] ) );
memory2_fx[1][i] = L_shl_sat( memory_fx2[1][i], sub( add( *Q_input_fx, 11 ), memory_fx_Q[1] ) );
memory2_fx[2][i] = L_shl_sat( memory_fx2[2][i], sub( add( *Q_input_fx, 6 ), memory_fx_Q[2] ) );
- memory2_fx[3][i] = L_shl_sat( memory_fx2[3][i], sub( add( *Q_input_fx, 1 ), memory_fx_Q[3] ) );
move32();
move32();
move32();
move32();
move32();
+#endif
}
+#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic
+ L_tmpMax = L_add( 0, 0 );
+ IF( !IsUpsampled3 )
+ {
+#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2
+ IF( element_mode )
+ {
+ FOR( i = 0; i < L_FRAME48k; i++ )
+ {
+ /*duplicate this into unrolled loopsections in IsUpsampled3-path and dont forget to delete 0-set-input[1,2,4,5,7,8...]*/
+ W_tmpX = W_mac_16_16( 0, input_fx[i - 4], full_band_bpf_fx[0][4] );
+ W_tmpX = W_mac_16_16( W_tmpX, input_fx[i - 3], full_band_bpf_fx[0][3] );
+ W_tmpY = W_msu_32_16( 0, L_tmp[i - 1], full_band_bpf_fx[3][1] );
+ W_tmpX = W_mac_16_16( W_tmpX, input_fx[i - 2], full_band_bpf_fx[0][2] );
+ W_tmpY = W_msu_32_16( W_tmpY, L_tmp[i - 2], full_band_bpf_fx[3][2] );
+ W_tmpX = W_mac_16_16( W_tmpX, input_fx[i - 1], full_band_bpf_fx[0][1] );
+ W_tmpY = W_msu_32_16( W_tmpY, L_tmp[i - 3], full_band_bpf_fx[3][3] );
+ W_tmpX = W_mac_16_16( W_tmpX, input_fx[i], full_band_bpf_fx[0][0] );
+ W_tmpY = W_msu_32_16( W_tmpY, L_tmp[i - 4], full_band_bpf_fx[3][4] );
+ L_tmp[i] = W_sat_l( W_shr( W_add( W_tmpX, W_shl( W_tmpY, 2 - 16 + 3 ) ), 3 ) ); /*Q_input_fx + 11*/
+ move32();
+ }
+ }
+ ELSE
+#endif /*FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2*/
+ {
+ FOR( i = 0; i < L_FRAME48k; i++ )
+ {
+ L_tmpX = L_shr( L_mult( input_fx[i - 4], full_band_bpf_fx[0][4] ), 3 ); /*Q_input_fx + 13 + 1 - 3*/
+ L_tmpX = L_add_sat( L_shr( L_mult( input_fx[i - 3], full_band_bpf_fx[0][3] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/
+ L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp[i - 1], full_band_bpf_fx[3][1] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/
+ L_tmpX = L_add_sat( L_shr( L_mult( input_fx[i - 2], full_band_bpf_fx[0][2] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/
+ L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp[i - 2], full_band_bpf_fx[3][2] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/
+ L_tmpX = L_add_sat( L_shr( L_mult( input_fx[i - 1], full_band_bpf_fx[0][1] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/
+ L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp[i - 3], full_band_bpf_fx[3][3] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/
+ L_tmpX = L_add_sat( L_shr( L_mult( input_fx[i], full_band_bpf_fx[0][0] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/
+ L_tmp[i] = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp[i - 4], full_band_bpf_fx[3][4] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/
+ move32();
+ }
+ }
+ } /*IsUpsampled3*/
+ ELSE
+ {
+#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2
+ IF( element_mode )
+ {
+ FOR( i = 0; i < L_FRAME48k; )
+ {
+ W_tmpX = W_mac_16_16( 0, input_fx[i - 3], full_band_bpf_fx[0][3] );
+ W_tmpY = W_msu_32_16( 0, L_tmp[i - 1], full_band_bpf_fx[3][1] );
+ W_tmpY = W_msu_32_16( W_tmpY, L_tmp[i - 2], full_band_bpf_fx[3][2] );
+ W_tmpY = W_msu_32_16( W_tmpY, L_tmp[i - 3], full_band_bpf_fx[3][3] );
+ W_tmpX = W_mac_16_16( W_tmpX, input_fx[i], full_band_bpf_fx[0][0] );
+ W_tmpY = W_msu_32_16( W_tmpY, L_tmp[i - 4], full_band_bpf_fx[3][4] );
+ L_tmp[i] = W_sat_l( W_shr( W_add( W_tmpX, W_shl( W_tmpY, 2 - 16 + 3 ) ), 3 ) ); /*Q_input_fx + 11*/
+ move32();
+ i++;
+
+ W_tmpX = W_mac_16_16( 0, input_fx[i - 4], full_band_bpf_fx[0][4] );
+ W_tmpY = W_msu_32_16( 0, L_tmp[i - 1], full_band_bpf_fx[3][1] );
+ W_tmpY = W_msu_32_16( W_tmpY, L_tmp[i - 2], full_band_bpf_fx[3][2] );
+ W_tmpX = W_mac_16_16( W_tmpX, input_fx[i - 1], full_band_bpf_fx[0][1] );
+ W_tmpY = W_msu_32_16( W_tmpY, L_tmp[i - 3], full_band_bpf_fx[3][3] );
+ W_tmpY = W_msu_32_16( W_tmpY, L_tmp[i - 4], full_band_bpf_fx[3][4] );
+ L_tmp[i] = W_sat_l( W_shr( W_add( W_tmpX, W_shl( W_tmpY, 2 - 16 + 3 ) ), 3 ) ); /*Q_input_fx + 11*/
+ move32();
+ i++;
+
+ W_tmpY = W_msu_32_16( 0, L_tmp[i - 1], full_band_bpf_fx[3][1] );
+ W_tmpX = W_mac_16_16( 0, input_fx[i - 2], full_band_bpf_fx[0][2] );
+ W_tmpY = W_msu_32_16( W_tmpY, L_tmp[i - 2], full_band_bpf_fx[3][2] );
+ W_tmpY = W_msu_32_16( W_tmpY, L_tmp[i - 3], full_band_bpf_fx[3][3] );
+ W_tmpY = W_msu_32_16( W_tmpY, L_tmp[i - 4], full_band_bpf_fx[3][4] );
+ L_tmp[i] = W_sat_l( W_shr( W_add( W_tmpX, W_shl( W_tmpY, 2 - 16 + 3 ) ), 3 ) ); /*Q_input_fx + 11*/
+ move32();
+ i++;
+ }
+ }
+ ELSE
+#endif /*FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2*/
+ {
+ FOR( i = 0; i < L_FRAME48k; )
+ {
+ L_tmpX = L_add_sat( L_shr( L_mult( input_fx[i - 3], full_band_bpf_fx[0][3] ), 3 ), 0 ); /*Q_input_fx + 13 + 1 - 3*/
+ L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp[i - 1], full_band_bpf_fx[3][1] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/
+ L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp[i - 2], full_band_bpf_fx[3][2] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/
+ L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp[i - 3], full_band_bpf_fx[3][3] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/
+ L_tmpX = L_add_sat( L_shr( L_mult( input_fx[i], full_band_bpf_fx[0][0] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/
+ L_tmp[i] = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp[i - 4], full_band_bpf_fx[3][4] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/
+ move32();
+ i++;
+
+ L_tmpX = L_shr( L_mult( input_fx[i - 4], full_band_bpf_fx[0][4] ), 3 ); /*Q_input_fx + 13 + 1 - 3*/
+ L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp[i - 1], full_band_bpf_fx[3][1] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/
+ L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp[i - 2], full_band_bpf_fx[3][2] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/
+ L_tmpX = L_add_sat( L_shr( L_mult( input_fx[i - 1], full_band_bpf_fx[0][1] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/
+ L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp[i - 3], full_band_bpf_fx[3][3] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/
+ L_tmp[i] = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp[i - 4], full_band_bpf_fx[3][4] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/
+ move32();
+ i++;
+
+ L_tmpX = L_sub_sat( 0, L_shl_sat( Mult_32_16( L_tmp[i - 1], full_band_bpf_fx[3][1] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/
+ L_tmpX = L_add_sat( L_shr( L_mult( input_fx[i - 2], full_band_bpf_fx[0][2] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/
+ L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp[i - 2], full_band_bpf_fx[3][2] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/
+ L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp[i - 3], full_band_bpf_fx[3][3] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/
+ L_tmp[i] = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp[i - 4], full_band_bpf_fx[3][4] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/
+ move32();
+ i++;
+ }
+ }
+
+ } /*IsUpsampled3*/
+
+#else /*FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic*/
L_tmpX = L_shr( L_mult( memory_fx[0][0], full_band_bpf_fx[0][4] ), 3 ); /*Q_input_fx + 13 + 1 - 3*/
L_tmpX = L_add( L_shr( L_mult( memory_fx[0][1], full_band_bpf_fx[0][3] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/
L_tmpX = L_add( L_shr( L_mult( memory_fx[0][2], full_band_bpf_fx[0][2] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/
@@ -6777,6 +6595,7 @@ void elliptic_bpf_48k_generic_fx(
L_tmp[i] = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp[i - 4], full_band_bpf_fx[3][4] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/
move32();
}
+#endif /*FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic*/
memory_fx2[0][0] = input_fx[L_FRAME48k - 4];
memory_fx2[0][1] = input_fx[L_FRAME48k - 3];
@@ -6787,6 +6606,47 @@ void elliptic_bpf_48k_generic_fx(
move32();
move32();
move32();
+
+#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic
+ L_tmpMax = L_add( 0, 0 );
+#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2
+ IF( element_mode )
+ {
+ FOR( i = 0; i < L_FRAME48k; i++ )
+ {
+ W_tmpX = W_mac_32_16( 0, L_tmp[i - 4], full_band_bpf_fx[1][4] );
+ W_tmpX = W_mac_32_16( W_tmpX, L_tmp[i - 3], full_band_bpf_fx[1][3] );
+ W_tmpY = W_msu_32_16( 0, L_tmp2[i - 1], full_band_bpf_fx[4][1] );
+ W_tmpX = W_mac_32_16( W_tmpX, L_tmp[i - 2], full_band_bpf_fx[1][2] );
+ W_tmpY = W_msu_32_16( W_tmpY, L_tmp2[i - 2], full_band_bpf_fx[4][2] );
+ W_tmpX = W_mac_32_16( W_tmpX, L_tmp[i - 1], full_band_bpf_fx[1][1] );
+ W_tmpY = W_msu_32_16( W_tmpY, L_tmp2[i - 3], full_band_bpf_fx[4][3] );
+ W_tmpX = W_mac_32_16( W_tmpX, L_tmp[i], full_band_bpf_fx[1][0] );
+ W_tmpY = W_msu_32_16( W_tmpY, L_tmp2[i - 4], full_band_bpf_fx[4][4] );
+ L_tmp2[i] = W_sat_l( W_shr( W_add( W_tmpX, W_shl( W_tmpY, 2 - 16 + 3 + 16 ) ), 3 + 16 ) );
+ move32();
+ L_tmpMax = L_max( L_tmpMax, L_abs( L_tmp2[i] ) );
+ }
+ }
+ ELSE
+#endif /*FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2*/
+ {
+ FOR( i = 0; i < L_FRAME48k; i++ )
+ {
+ L_tmpX = L_shr( Mult_32_16( L_tmp[i - 4], full_band_bpf_fx[1][4] ), 3 ); /*Q_input_fx + 11 + 13 - 15 -3*/
+ L_tmpX = L_add_sat( L_shr( Mult_32_16( L_tmp[i - 3], full_band_bpf_fx[1][3] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/
+ L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp2[i - 1], full_band_bpf_fx[4][1] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */
+ L_tmpX = L_add_sat( L_shr( Mult_32_16( L_tmp[i - 2], full_band_bpf_fx[1][2] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/
+ L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp2[i - 2], full_band_bpf_fx[4][2] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */
+ L_tmpX = L_add_sat( L_shr( Mult_32_16( L_tmp[i - 1], full_band_bpf_fx[1][1] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/
+ L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp2[i - 3], full_band_bpf_fx[4][3] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */
+ L_tmpX = L_add_sat( L_shr( Mult_32_16( L_tmp[i], full_band_bpf_fx[1][0] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/
+ L_tmp2[i] = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp2[i - 4], full_band_bpf_fx[4][4] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */
+ move32();
+ L_tmpMax = L_max( L_tmpMax, L_abs( L_tmp2[i] ) );
+ }
+ }
+#else /*FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic*/
L_tmpX = L_shr( Mult_32_16( memory2_fx[1][0], full_band_bpf_fx[1][4] ), 3 ); /*Q_input_fx + 11 + 13 - 15 -3*/
L_tmpX = L_add( L_shr( Mult_32_16( memory2_fx[1][1], full_band_bpf_fx[1][3] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/
L_tmpX = L_add( L_shr( Mult_32_16( memory2_fx[1][2], full_band_bpf_fx[1][2] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/
@@ -6845,6 +6705,8 @@ void elliptic_bpf_48k_generic_fx(
move32();
L_tmpMax = L_max( L_tmpMax, L_abs( L_tmp2[i] ) );
}
+#endif
+
Q_temp = norm_l( L_tmpMax );
Q_temp = sub( Q_temp, 4 );
@@ -6859,6 +6721,16 @@ void elliptic_bpf_48k_generic_fx(
move32();
move32();
move32();
+#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic
+ FOR( j = 0; j < 4; j++ )
+ {
+ L_tmp2[j - 4] = L_shl_sat( memory_fx2[2][j], sub( add( add( *Q_input_fx, 6 ), Q_temp ), memory_fx_Q[2] ) );
+ L_output[j - 4] = L_shl_sat( memory_fx2[3][j], sub( add( add( *Q_input_fx, 1 ), Q_temp ), memory_fx_Q[3] ) );
+ move32();
+ move32();
+ move32();
+ }
+#else
FOR( j = 0; j < 4; j++ )
{
memory2_fx_2[j] = L_shl_sat( memory_fx2[2][j], sub( add( add( *Q_input_fx, 6 ), Q_temp ), memory_fx_Q[2] ) );
@@ -6867,6 +6739,51 @@ void elliptic_bpf_48k_generic_fx(
move32();
move32();
}
+#endif
+#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic
+ L_tmpMax = L_add( 0, 0 );
+#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2
+ IF( element_mode )
+ {
+ FOR( i = 0; i < L_FRAME48k; i++ )
+ {
+ W_tmpX = W_mac_32_16( 0, L_tmp2[i - 4], full_band_bpf_fx[2][4] );
+ W_tmpX = W_mac_32_16( W_tmpX, L_tmp2[i - 3], full_band_bpf_fx[2][3] );
+ W_tmpY = W_msu_32_16( 0, L_output[i - 1], full_band_bpf_fx[5][1] );
+ W_tmpX = W_mac_32_16( W_tmpX, L_tmp2[i - 2], full_band_bpf_fx[2][2] );
+ W_tmpY = W_msu_32_16( W_tmpY, L_output[i - 2], full_band_bpf_fx[5][2] );
+ W_tmpX = W_mac_32_16( W_tmpX, L_tmp2[i - 1], full_band_bpf_fx[2][1] );
+ W_tmpY = W_msu_32_16( W_tmpY, L_output[i - 3], full_band_bpf_fx[5][3] );
+ W_tmpX = W_mac_32_16( W_tmpX, L_tmp2[i], full_band_bpf_fx[2][0] );
+ W_tmpY = W_msu_32_16( W_tmpY, L_output[i - 4], full_band_bpf_fx[5][4] );
+ L_output[i] = W_sat_l( W_shr( W_add( W_tmpX, W_shl( W_tmpY, 2 - 16 + 3 + 16 ) ), 3 + 16 ) );
+ move32();
+ L_tmpMax = L_max( L_tmpMax, L_abs( L_output[i] ) );
+ }
+ }
+ ELSE
+#endif /*FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2*/
+ {
+ FOR( i = 0; i < L_FRAME48k; i++ )
+ {
+ L_tmpX = L_shr( Mult_32_16( L_tmp2[i - 4], full_band_bpf_fx[2][4] ), 3 ); /*Q_input_fx + 6 +Q_temp+13 -15 -3 */
+ L_tmpX = L_add_sat( L_shr( Mult_32_16( L_tmp2[i - 3], full_band_bpf_fx[2][3] ), 3 ), L_tmpX ); /*Q_input_fx + 6 +Q_temp +13 -15 -3*/
+ L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_output[i - 1], full_band_bpf_fx[5][1] ), 2 ) ); /*Q_input_fx + 1 +Q_temp+13 -15 + 2*/
+
+ L_tmpX = L_add_sat( L_shr( Mult_32_16( L_tmp2[i - 2], full_band_bpf_fx[2][2] ), 3 ), L_tmpX ); /*Q_input_fx + 6 +Q_temp+13 -15 -3*/
+ L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_output[i - 2], full_band_bpf_fx[5][2] ), 2 ) ); /*Q_input_fx + 1 +Q_temp+13 -15 + 2*/
+
+ L_tmpX = L_add_sat( L_shr( Mult_32_16( L_tmp2[i - 1], full_band_bpf_fx[2][1] ), 3 ), L_tmpX ); /*Q_input_fx + 6 +Q_temp +13 -15 -3*/
+ L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_output[i - 3], full_band_bpf_fx[5][3] ), 2 ) ); /*Q_input_fx + 1 +Q_temp+13 -15 + 2*/
+
+ L_tmpX = L_add_sat( L_shr( Mult_32_16( L_tmp2[i], full_band_bpf_fx[2][0] ), 3 ), L_tmpX ); /*Q_input_fx + 6 +Q_temp +13 -15 -3*/
+ L_output[i] = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_output[i - 4], full_band_bpf_fx[5][4] ), 2 ) ); /*Q_input_fx + 1 +Q_temp+13 -15 + 2*/
+ move32();
+ L_tmpMax = L_max( L_tmpMax, L_abs( L_output[i] ) );
+ }
+ }
+
+#else /*FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic*/
L_tmpX = L_shr( Mult_32_16( memory2_fx_2[0], full_band_bpf_fx[2][4] ), 3 ); /* *Q_input_fx+6 +Q_temp +13 -15 -3 */
L_tmpX = L_add_sat( L_shr( Mult_32_16( memory2_fx_2[1], full_band_bpf_fx[2][3] ), 3 ), L_tmpX ); /*Q_input_fx + 6 +Q_temp+13 -15 -3*/
L_tmpX = L_add_sat( L_shr( Mult_32_16( memory2_fx_2[2], full_band_bpf_fx[2][2] ), 3 ), L_tmpX ); /*Q_input_fx + 6 +Q_temp+13 -15 -3*/
@@ -6932,6 +6849,8 @@ void elliptic_bpf_48k_generic_fx(
move32();
L_tmpMax = L_max( L_tmpMax, L_abs( L_output[i] ) );
}
+#endif
+
memory_fx2[2][0] = L_tmp2[L_FRAME48k - 4];
memory_fx2[2][1] = L_tmp2[L_FRAME48k - 3];
memory_fx2[2][2] = L_tmp2[L_FRAME48k - 2];
@@ -6995,10 +6914,20 @@ void synthesise_fb_high_band_fx(
Word16 *prev_fbbwe_ratio, /* o : previous frame energy for FEC */
Word32 bpf_memory[][4], /* i/o: memory for elliptic bpf 48k */
Word16 bpf_memory_Q[],
- Word16 Qout )
+ Word16 Qout
+#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2
+ ,
+ int16_t element_mode
+#endif
+)
{
Word16 i, j;
+#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic
+ Word16 excitation_in_interp3_buffer[L_FRAME48k + 4];
+ Word16 *excitation_in_interp3 = &excitation_in_interp3_buffer[0] + 4;
+#else
Word16 excitation_in_interp3[L_FRAME48k];
+#endif
Word16 tmp[L_FRAME48k];
Word32 temp1;
Word32 ratio2;
@@ -7023,12 +6952,32 @@ void synthesise_fb_high_band_fx(
IF( EQ_16( L_frame, L_FRAME16k ) )
{
/* for 16kHz ACELP core */
+#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic
+ elliptic_bpf_48k_generic_fx(
+#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2
+ element_mode,
+#endif
+ 1, // IsUpsampled3
+ excitation_in_interp3, &exp_tmp, tmp, bpf_memory, bpf_memory_Q, full_band_bpf_3_fx
+
+ );
+#else
elliptic_bpf_48k_generic_fx( excitation_in_interp3, &exp_tmp, tmp, bpf_memory, bpf_memory_Q, full_band_bpf_3_fx );
+#endif
}
ELSE
{
/* for 12.8kHz ACELP core */
+#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic
+ elliptic_bpf_48k_generic_fx(
+#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2
+ element_mode,
+#endif
+ 1, // IsUpsampled3
+ excitation_in_interp3, &exp_tmp, tmp, bpf_memory, bpf_memory_Q, full_band_bpf_1_fx );
+#else
elliptic_bpf_48k_generic_fx( excitation_in_interp3, &exp_tmp, tmp, bpf_memory, bpf_memory_Q, full_band_bpf_1_fx );
+#endif
}
temp1 = sum2_fx_mod( tmp, L_FRAME48k );
@@ -7237,56 +7186,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() */
/*--------------------------------------------------------------------------------------*/
@@ -7308,7 +7208,6 @@ void tbe_celp_exc(
/* INPUT/OUTPUT ARGUMENTS : */
/* _ (Word16[]) bwe_exc_fx : excitation for TBE (Q_exc) */
/*--------------------------------------------------------------------------------------*/
-
/* _ None */
/*--------------------------------------------------------------------------------------*/
/* RETURN ARGUMENTS : */
@@ -7316,200 +7215,27 @@ void tbe_celp_exc(
/*======================================================================================*/
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) */
-/*--------------------------------------------------------------------------------------*/
-
-/* _ None */
-/*--------------------------------------------------------------------------------------*/
-/* RETURN ARGUMENTS : */
-/* _ None */
-/*======================================================================================*/
+ 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 */
-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;
@@ -7555,7 +7281,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 )
@@ -7568,7 +7294,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 */
@@ -7627,6 +7352,7 @@ void prep_tbe_exc_ivas_fx(
return;
}
+
/*=============================================================================*/
/* FUNCTION : void swb_formant_fac_fx ( ) */
/*------------------------------------------------------------------------------*/
@@ -7646,9 +7372,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;
@@ -7668,7 +7395,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 */
@@ -7688,6 +7414,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[] )
@@ -7704,7 +7436,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 b1a9f4d13f29a8e3b9e0d7e53c8cd5b0b51bfb6f..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 */
-)
-{
- 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 )
+Word16 norm_ul_float( UWord32 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 */
+ 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;
-
- 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 */
-)
-{
- 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,54 +752,50 @@ void v_add_w64(
return;
}
-
/*-------------------------------------------------------------------*
- * v_sub()
+ * v_sub_fixed()
*
* 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 */
+void v_sub_fixed(
+ const Word32 x1[], /* i : Input vector 1 */
+ const Word32 x2[], /* i : Input vector 2 */
+ Word32 y[], /* o : Output vector that contains vector 1 - vector 2 */
+ const Word16 N, /* i : Vector length */
+ const Word16 hdrm /* i : headroom for when subtraction result > 1 or < -1 */
)
{
- int16_t i;
+ Word16 i;
- for ( i = 0; i < N; i++ )
+ FOR( i = 0; i < N; i++ )
{
- y[i] = x1[i] - x2[i];
+ y[i] = L_sub( L_shr( x1[i], hdrm ), L_shr( x2[i], hdrm ) );
+ move32();
}
return;
}
-/*-------------------------------------------------------------------*
- * v_sub()
- *
- * Subtraction of two vectors sample by sample
- *-------------------------------------------------------------------*/
-
-void v_sub_fixed(
+#ifdef VEC_ARITH_OPT_v1
+void v_sub_fixed_no_hdrm(
const Word32 x1[], /* i : Input vector 1 */
const Word32 x2[], /* i : Input vector 2 */
Word32 y[], /* o : Output vector that contains vector 1 - vector 2 */
- const Word16 N, /* i : Vector length */
- const Word16 hdrm /* i : headroom for when subtraction result > 1 or < -1 */
+ const Word16 N /* i : Vector length */
)
{
Word16 i;
FOR( i = 0; i < N; i++ )
{
- y[i] = L_sub( L_shr( x1[i], hdrm ), L_shr( x2[i], hdrm ) );
+ y[i] = L_sub( x1[i], x2[i] );
move32();
}
return;
}
+#endif /* VEC_ARITH_OPT_v1 */
/*-------------------------------------------------------------------*
* v_multc_fixed()
@@ -957,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 59918a1eae80fa53cd600b229d26bcdca91dc1ee..8e803051d8dc674f0158098f03859a44a581ae72 100644
--- a/lib_com/tools_fx.c
+++ b/lib_com/tools_fx.c
@@ -264,6 +264,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()
*
@@ -774,13 +798,37 @@ void Copy_Scale_sig_16_32_no_sat(
}
return;
}
+#ifdef FIX_1439_SPEEDUP_Copy_Scale_sig_16_32_no_sat
+ L_tmp = L_shl_o( 1, exp0 - 1, &Overflow );
+
+ IF( L_tmp >= 0x7FFF )
+ {
+ FOR( i = 0; i < lg; i++ )
+ {
+ // y[i] = L_mult0(x[i], L_tmp);
+ y[i] = W_extract_l( W_mult_32_16( L_tmp, x[i] ) );
+ move32(); /* Overflow can occur here */
+ }
+ return;
+ }
+ // ELSE
+ {
+ Word16 tmp = extract_l( L_tmp );
+ FOR( i = 0; i < lg; i++ )
+ {
+ y[i] = L_mult( x[i], tmp );
+ move32();
+ }
+ }
+#else
L_tmp = L_shl_o( 1, exp0 - 1, &Overflow );
FOR( i = 0; i < lg; i++ )
{
// y[i] = L_mult0(x[i], L_tmp);
y[i] = W_extract_l( W_mult_32_16( L_tmp, x[i] ) );
- move32(); /* saturation can occur here */
+ move32(); /* Overflow can occur here */
}
+#endif
}
void Copy_Scale_sig_32_16(
@@ -929,7 +977,7 @@ void scale_sig(
}
/*---------------------------------------------------------------------*
- * mean()
+ * mean_fx()
*
*---------------------------------------------------------------------*/
Word16 mean_fx( /* o : mean of vector */
@@ -2103,7 +2151,7 @@ Word16 own_random2_fx( Word16 seed )
}
/*---------------------------------------------------------------------
- * sign()
+ * sign_fx()
*
*---------------------------------------------------------------------*/
@@ -3796,6 +3844,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];
@@ -4139,7 +4239,7 @@ Word16 lin_interp_ivas_fx(
}
/*---------------------------------------------------------------------
- * sign()
+ * sign_l()
*
*---------------------------------------------------------------------*/
@@ -4177,7 +4277,7 @@ void v_mult16_fixed(
}
/*---------------------------------------------------------------------*
- * set_zero()
+ * set_zero_fx()
*
* Set a vector vec[] of dimension lvec to zero
*---------------------------------------------------------------------*/
@@ -4480,6 +4580,26 @@ void v_add_fixed(
return;
}
+#ifdef VEC_ARITH_OPT_v1
+void v_add_fixed_no_hdrm(
+ const Word32 x1[], /* i : Input vector 1 */
+ const Word32 x2[], /* i : Input vector 2 */
+ Word32 y[], /* o : Output vector that contains vector 1 + vector 2 */
+ const Word16 N /* i : Vector length */
+)
+{
+ Word16 i;
+
+ FOR( i = 0; i < N; i++ )
+ {
+ y[i] = L_add( x1[i], x2[i] );
+ move32();
+ }
+
+ return;
+}
+#endif /* VEC_ARITH_OPT_v1 */
+
void v_add_fixed_me(
const Word32 x1[], /* i : Input vector 1 */
const Word16 x1_e, /* i : Exponent for input vector 1 */
@@ -4650,6 +4770,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_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 612816efd236c6ca1a51dcca0933ec4d1b7b6284..48d91a87a1956594ba84a662e33c8cc73d52d89f 100644
--- a/lib_dec/FEC_fx.c
+++ b/lib_dec/FEC_fx.c
@@ -510,15 +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 */
- 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 );
- }
+ 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 d664aa9fbb2ea39a35ea23477c0ec2e3517e40c9..7f4586083e938d9eecb623b325a54dcecad9e71a 100644
--- a/lib_dec/FEC_scale_syn_fx.c
+++ b/lib_dec/FEC_scale_syn_fx.c
@@ -76,6 +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 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 */
)
@@ -171,572 +172,10 @@ void FEC_scale_syn_fx(
* 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;
-}
-
-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,
- 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*/
+ tmp = sub( 3, getScaleFactor16( synth, L_frame ) );
- /*-----------------------------------------------------------------*
- * 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
- *-----------------------------------------------------------------*/
- tmp = sub( 3, getScaleFactor16( synth, L_frame ) );
- IF( tmp > 0 )
+ IF( tmp > 0 && GT_16( element_mode, EVS_MONO ) )
{
Word16 synth_tmp[L_FRAME16k];
Copy_Scale_sig( synth, synth_tmp, L_frame, -tmp ); // Q_synth - tmp
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 495ca5c006ecc49b9d7f3108d72d7bc55ef09912..fd0c8ce2d12688e55ecfdf169e8d9e1699e9cf84 100644
--- a/lib_dec/acelp_core_dec_fx.c
+++ b/lib_dec/acelp_core_dec_fx.c
@@ -1,154 +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 */
-/*==========================================================================*/
-/* 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];
}
/*----------------------------------------------------------------*
@@ -157,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();
@@ -212,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
@@ -236,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();
}
@@ -508,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();
}
}
@@ -545,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 );
}
}
@@ -636,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 ) )
{
@@ -658,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 );
}
}
@@ -680,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();
@@ -732,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 );
}
}
}
@@ -750,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 );
}
/*---------------------------------------------------------------*
@@ -768,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 );
}
@@ -778,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, 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 ) );
+ }
}
/*------------------------------------------------------------*
@@ -859,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();
}
}
@@ -942,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 );
}
}
@@ -987,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 );
- }
-
- /*------------------------------------------------------------*
- * 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_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();
}
@@ -1194,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 );
+ }
+ }
}
}
@@ -1338,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();
@@ -1384,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();
}
@@ -1410,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 )
+ {
+ 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 )
{
- generate_comfort_noise_dec_hf_fx( realBuffer, imagBuffer, &scaleFactor.hb_scale, st_fx );
+ tmp = 0;
+ move16();
+ }
+
+ addBassPostFilter_ivas_fx( tmp_bpf_error_signal_fx, tmp, realBuffer_fx, imagBuffer_fx, st->cldfbBPF );
- st_fx->cldfbSyn->bandsToZero = 0;
+ 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
{
- cldfbSynthesis_fx( st_fx->cldfbSyn, realBuffer, imagBuffer, &scaleFactor, synth_out, negate( st_fx->Q_syn2 ), CLDFB_NO_COL_MAX, workBuffer );
+ 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 );
}
- /* 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 );
+ /* 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_fx->hBWE_zero != NULL )
+
+ IF( st->hBWE_zero != NULL )
{
test();
test();
@@ -1459,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 );
+ }
}
}
@@ -1474,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();
@@ -1489,11 +2321,11 @@ 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 );
}
test();
@@ -1501,41 +2333,70 @@ 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 ), 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_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;
}
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 38999e99e4f462d9b9c0af182a5532afb935d672..0000000000000000000000000000000000000000
--- a/lib_dec/acelp_core_dec_ivas_fx.c
+++ /dev/null
@@ -1,2156 +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
- *-------------------------------------------------------------------*/
-static void rescale_fdCngDec( HANDLE_FD_CNG_DEC hFdCngDec, Word16 old_NoiseExp );
-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 local_element_mode;
- ivas_error error;
-
- Word32 bpf_error_signal_fx[L_FRAME16k];
- set32_fx( bpf_error_signal_fx, 0, L_FRAME16k );
- Word16 bpf_error_signal_16fx[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 ) );
- Word16 tmp;
-
- 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
- {
- Word16 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
- {
- Word16 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 ) )
- {
- Word16 old_NoiseEstExp = st->hFdCngDec->hFdCngCom->sidNoiseEstExp;
- move16();
- FdCng_decodeSID_ivas_fx( st );
- rescale_fdCngDec( st->hFdCngDec, 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();
- }
-
- 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();
- }
- }
-
- 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 )
- {
- 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 */
- 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 );
- st->Q_syn_cng = st->Q_syn;
- move16();
- st->Q_exc_cng = st->Q_exc;
- move16();
- /* reset the decoder */
- CNG_reset_dec_fx( st, pitch_buf_fx, voice_factors_fx );
-
- /* 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 )
- {
- /* SC-VBR - NELP frames */
- 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 */
- 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 */
- 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,
- 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 );
- 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,
- 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 );
- }
-
- /* 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();
- /*----ftf conversions---*/
- 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 ) )
- {
- 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];
- Word16 exp;
- 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 ) ) )
- {
- 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
- *----------------------------------------------------------------*/
-
- /* 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 */
- Word16 Q_real = 0, Q_imag = 0;
- Word32 max_real = 0, max_imag = 0;
- move16();
- move16();
- 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] ) );
- }
- }
- Word32 max_val = L_max( max_real, max_imag );
- Q_imag = sub( norm_l( max_val ), 3 ) /* Guard bits */;
- Q_real = Q_imag;
- move16();
- 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_imag ); // Q_imag
- }
-#ifndef OPT_AVOID_STATE_BUF_RESCALE
-#ifdef OPT_STEREO_32KBPS_V1
- scale_sig32( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->p_filter_length, sub( Q_real, Q11 ) ); // Q10 - > (Q_real-1)
-#else /* OPT_STEREO_32KBPS_V1 */
- scale_sig32_r( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); // (Q_real-1)
-#endif /* OPT_STEREO_32KBPS_V1 */
- st->cldfbSynHB->Q_cldfb_state = sub( Q_real, 1 );
- move16();
-#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 */
- Word16 Q_real, Q_imag;
- Word32 max_real, max_imag;
- Q_real = 0;
- Q_imag = 0;
- max_real = 0;
- max_imag = 0;
- move16();
- move16();
- 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] ) );
- }
- }
- Word32 max_val = L_max( max_real, max_imag );
- Q_imag = sub( norm_l( max_val ), 3 ) /* Guard bits */;
- Q_real = Q_imag;
- move16();
- 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 */
- Word16 Q_real, Q_imag;
- Word32 max_real, max_imag;
- Q_real = 0;
- Q_imag = 0;
- max_real = 0;
- max_imag = 0;
- move16();
- move16();
- 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] ) );
- }
- }
- Word32 max_val = L_max( max_real, max_imag );
- Q_imag = sub( norm_l( max_val ), 3 ) /* Guard bits */;
- Q_real = Q_imag;
- move16();
- 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 ) ) ) ) )
- {
- 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 );
- 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 ) ) )
- {
- 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 */
- 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();
- }
- }
-
- {
- 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;
-}
-
-
-static void rescale_fdCngDec( HANDLE_FD_CNG_DEC hFdCngDec, Word16 Exp_diff )
-{
- Scale_sig32( hFdCngDec->hFdCngCom->sidNoiseEstLp, NPART, Exp_diff );
-}
diff --git a/lib_dec/acelp_core_switch_dec_fx.c b/lib_dec/acelp_core_switch_dec_fx.c
index 7657491885adbc296ef9f41cfad150842b149f7e..363db82020cf81eefbdb2258c27eb77877faf380 100644
--- a/lib_dec/acelp_core_switch_dec_fx.c
+++ b/lib_dec/acelp_core_switch_dec_fx.c
@@ -128,7 +128,7 @@ ivas_error acelp_core_switch_dec_fx(
* Excitation decoding
*----------------------------------------------------------------*/
- 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 );
+ 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 );
@@ -916,7 +916,7 @@ static void decod_gen_voic_core_switch_fx(
* Decode pitch lag
*----------------------------------------------------------------------*/
- 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*/
+ 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.
diff --git a/lib_dec/amr_wb_dec_fx.c b/lib_dec/amr_wb_dec_fx.c
index db4ad2bb021122533aba2ec98cb77b9455a90804..96ae82ddee71c1e6a9a0115bce5ce2e84dea8334 100644
--- a/lib_dec/amr_wb_dec_fx.c
+++ b/lib_dec/amr_wb_dec_fx.c
@@ -628,7 +628,7 @@ ivas_error amr_wb_dec_fx(
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 );
+ 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 );
}
@@ -710,7 +710,7 @@ ivas_error amr_wb_dec_fx(
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 );
+ 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 );
@@ -792,12 +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
- ApplyFdCng_fx( syn_fx, st_fx->Q_syn, NULL, NULL, NULL, st_fx, 0, 0 );
-#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 945f0ca758ed89671ff73a19fe0ba7ff25ab0357..fdb6488db8232ce7f77edebb2a5ea5fbb61a84b6 100644
--- a/lib_dec/cng_dec_fx.c
+++ b/lib_dec/cng_dec_fx.c
@@ -22,18 +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
*-----------------------------------------------------------------*/
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;
@@ -71,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
@@ -107,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;
-}
-
-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 d5294eb7a0a9eed009f3475c4f24be9270a76377..b638a36e55bbc3de081e4667c74e8cc8c5be9b66 100644
--- a/lib_dec/dec_LPD_fx.c
+++ b/lib_dec/dec_LPD_fx.c
@@ -555,7 +555,8 @@ void decoder_LPD_fx(
st->relax_prev_lsf_interp = 2;
move16();
}
- int_lsp4_fx( L_frame, &lsp[0], lspmid, &lsp[M], Aq, M, st->relax_prev_lsf_interp );
+
+ int_lsp4_ivas_fx( L_frame, &lsp[0], lspmid, &lsp[M], Aq, M, st->relax_prev_lsf_interp );
}
ELSE
{
@@ -569,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();
@@ -773,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 e327d4cfb958cacf783da1add249812e3336ceab..9c366e3f3190c2138e9940a69e30a447609a0d1f 100644
--- a/lib_dec/dec_ace_fx.c
+++ b/lib_dec/dec_ace_fx.c
@@ -532,30 +532,24 @@ void decoder_acelp_fx(
move16();
IF( st->igf != 0 )
{
- 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
- );
+ 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 );
@@ -683,8 +677,9 @@ void decoder_acelp_fx(
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 );
+ 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 415b4584e53c884068ce8f194e63305bc2ed8dd9..500fe34bab921a2c385caf751d34616d63e0045f 100644
--- a/lib_dec/dec_amr_wb_fx.c
+++ b/lib_dec/dec_amr_wb_fx.c
@@ -71,7 +71,7 @@ void decod_amr_wb_fx(
* Decode pitch lag
*----------------------------------------------------------------------*/
- *pt_pitch_fx = pit_decode_fx( st_fx, st_fx->core_brate, 1, L_FRAME, i_subfr, -1, &pitch_limit_flag, &T0, &T0_frac, &T0_min, &T0_max, L_SUBFR );
+ *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 325beb9f3b347fc5183cd875e42b633dd0075449..3e42d953561ca8a04f7ffddc2076c6560c30bf1a 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,502 +28,30 @@
/* _ (Word16[]) exc_fx : adapt. excitation exc (Q_exc) */
/* _ (Word16[]) exc2_fx : adapt. excitation/total exc (Q_exc) */
/*----------------------------------------------------------------------*/
-
-
/*----------------------------------------------------------------------*/
/* RETURN ARGUMENTS : */
/* _ None */
/*======================================================================*/
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*/
-)
-{
-
-
- 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 */
-/*======================================================================*/
-
-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 */
+ 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 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 */
@@ -535,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 */
@@ -632,10 +159,8 @@ 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*/
/*--------------------------------------------------------------*
@@ -676,7 +201,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 ) )
{
@@ -699,7 +224,14 @@ ivas_error decod_gen_voic_ivas_fx(
}
/* update LP filtered gains for the case of frame erasures */
- 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 );
+ 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
+ {
+ 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 );
+ }
/*----------------------------------------------------------------------*
* Find the total excitation
@@ -780,10 +312,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();
@@ -792,10 +320,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 );
/*----------------------------------------------------------------*
@@ -809,8 +337,16 @@ ivas_error decod_gen_voic_ivas_fx(
}
ELSE
{
- 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 );
+ 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
+ {
+ 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 );
+ }
}
p_Aq_fx += ( M + 1 );
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 746b668198d4c2d0a3ff030739b0d40d82b23952..a18029cdccfe8bb1a5a2c0bd01a939c414b1adc9 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 */
@@ -29,436 +29,30 @@
/* RETURN ARGUMENTS : */
/* _ None */
/*==========================================================================*/
-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 */
-/*==========================================================================*/
-void dec_pit_exc_ivas_fx(
+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 : 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;
@@ -575,13 +169,14 @@ 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();
/*--------------------------------------------------------------*
@@ -618,7 +213,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 a4f618a3fd751dec1eeea852d8e26230a86f39c8..37d088a8f98d7049e8ed7d130e26f5e2deab8e22 100644
--- a/lib_dec/dec_post_fx.c
+++ b/lib_dec/dec_post_fx.c
@@ -35,8 +35,6 @@ static void modify_pst_param_fx( const Word16 lp_noise, Word16 *g1, Word16 *g2,
static void Dec_formant_postfilt_fx( PFSTAT_HANDLE hPFstat, Word16 *signal_ptr, Word16 *coeff, Word16 *sig_out, Word16 gamma1, Word16 gamma2 );
-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 );
@@ -81,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 */
@@ -255,21 +253,21 @@ static void Dec_postfilt_fx(
*
* Main routine to perform formant post filtering
*--------------------------------------------------------------------------*/
+
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 ) )
@@ -378,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 );
}
-}
-
-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 :
@@ -519,92 +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
*----------------------------------------------------------------------------*/
-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;
-}
-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..883024002ea4c2191cd20d7a5ac09c021b9e6c2f 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 );
}
}
diff --git a/lib_dec/dec_tran_fx.c b/lib_dec/dec_tran_fx.c
index e886fd33770a60b034c992b92348e9fdc33bb9e6..de3a1ff3fb8f8521004f0d0cb1d3dd1260e57e19 100644
--- a/lib_dec/dec_tran_fx.c
+++ b/lib_dec/dec_tran_fx.c
@@ -253,9 +253,11 @@ void decod_tran_fx(
{
tmp_idx_2 = idiv1616( i_subfr, L_SUBFR );
}
- 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 );
+ 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 bbec94d94f903d1116d84751f4a0c9e43223c012..f1ba21979228b1e0634efef8bf139c511869fc4f 100644
--- a/lib_dec/dec_uv_fx.c
+++ b/lib_dec/dec_uv_fx.c
@@ -26,90 +26,6 @@ static void gain_dec_gacelp_uv_fx(
*-------------------------------------------------------------------*/
void decod_unvoiced_fx(
- Decoder_State *st_fx, /* i/o: decoder static memory */
- 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;
- 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 );
- }
-
- 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 );
-
- 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
- *-------------------------------------------------------------------*/
-
-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 */
@@ -203,7 +119,14 @@ void decod_unvoiced_ivas_fx(
move16();
/* update LP filtered gains for the case of frame erasures */
- 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 );
+ 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
+ {
+ 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 );
+ }
/*-------------------------------------------------------*
* - Find the total excitation. *
@@ -236,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();
@@ -243,10 +167,16 @@ void decod_unvoiced_ivas_fx(
* 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);*/
- 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 );
+ 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
+ {
+ 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 );
+ }
Word16 tmp_idx;
tmp_idx = 0;
@@ -257,6 +187,7 @@ void decod_unvoiced_ivas_fx(
}
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 );
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_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 74340b530f6fe9cc1c2733664b854cc317f057cf..9c81fddf347529f42c78a49bbaae321ffc589306 100644
--- a/lib_dec/evs_dec_fx.c
+++ b/lib_dec/evs_dec_fx.c
@@ -953,11 +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
- ApplyFdCng_fx( output_sp, 0, realBuffer, imagBuffer, &st_fx->scaleFactor.hb_scale, st_fx, concealWholeFrame, 0 );
-#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 )
@@ -1147,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 e53c81209347109cc3bc5876da8532e7a63443d2..5c454591855e4f582172fc76de2c07dbac209905 100644
--- a/lib_dec/fd_cng_dec_fx.c
+++ b/lib_dec/fd_cng_dec_fx.c
@@ -554,571 +554,8 @@ void deleteFdCngDec_fx( HANDLE_FD_CNG_DEC *hFdCngDec )
Returns:
error
*/
-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 );
- 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 );
- }
-
- 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 ) )
- {
- }
-
- /* 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();
- }
-
- 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 );
-
- /* 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*/
-
- 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 */
- 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();
- }
- }
-
- 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 );
- }
-
- BREAK;
-
- default:
- return -1;
- }
-
- return 0;
-}
-
-Word16 ApplyFdCng_ivas_fx(
+Word16 ApplyFdCng_fx(
Word16 *timeDomainInput, /* i : pointer to time domain input Q*/
Word16 Q,
Word32 *powerSpectrum, /*Q_power_spectrum*/
@@ -1220,11 +657,22 @@ Word16 ApplyFdCng_ivas_fx(
( !st->BER_detect ) )
{
/* Perform noise estimation at the decoder */
- 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 );
+ IF( EQ_16( st->element_mode, EVS_MONO ) )
+ {
+ perform_noise_estimation_dec_fx( timeDomainInput, Q, hFdCngDec );
+ }
+ ELSE
+ {
+ 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();
- IF( NE_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->element_mode, IVAS_CPE_DFT ) )
+ 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 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 );
}
@@ -1460,7 +908,14 @@ Word16 ApplyFdCng_ivas_fx(
IF( hFdCngCom->active_frame_counter > 0 )
{
/* Perform noise estimation in active frames in the decoder for downward updates */
- 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 );
+ IF( EQ_16( st->element_mode, EVS_MONO ) )
+ {
+ perform_noise_estimation_dec_fx( timeDomainInput, Q, hFdCngDec );
+ }
+ ELSE
+ {
+ 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 );
+ }
}
}
@@ -1518,29 +973,48 @@ Word16 ApplyFdCng_ivas_fx(
IF( st != NULL && EQ_16( st->cng_type, LP_CNG ) )
{
/* Perform noise estimation on inactive phase at the decoder */
- 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 );
+ IF( EQ_16( st->element_mode, EVS_MONO ) )
+ {
+ perform_noise_estimation_dec_fx( timeDomainInput, Q, hFdCngDec );
+ }
+ ELSE
+ {
+ 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();
- IF( NE_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->element_mode, IVAS_CPE_DFT ) )
+ 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 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*/
- Word16 shift1 = L_norm_arr( cngNoiseLevel, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ) );
- Word16 shift2 = L_norm_arr( cngNoiseLevel + sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ), sub( FFTCLDFBLEN, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ) ) );
- Word16 shift = s_max( sub( hFdCngDec->bandNoiseShape_exp, shift1 ), sub( *cngNoiseLevel_exp, shift2 ) );
+ IF( EQ_16( st->element_mode, EVS_MONO ) )
+ {
+ *cngNoiseLevel_exp = hFdCngDec->bandNoiseShape_exp;
+ move16();
+ }
+ ELSE
+ {
+ Word16 shift1 = L_norm_arr( cngNoiseLevel, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ) );
+ Word16 shift2 = L_norm_arr( cngNoiseLevel + sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ), sub( FFTCLDFBLEN, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ) ) );
+ Word16 shift = s_max( sub( hFdCngDec->bandNoiseShape_exp, shift1 ), sub( *cngNoiseLevel_exp, shift2 ) );
- scale_sig32( cngNoiseLevel, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ), sub( sub( hFdCngDec->bandNoiseShape_exp, shift1 ), shift ) );
- scale_sig32( cngNoiseLevel + sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ), sub( FFTCLDFBLEN, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ) ), sub( sub( *cngNoiseLevel_exp, shift2 ), shift ) );
+ scale_sig32( cngNoiseLevel, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ), sub( hFdCngDec->bandNoiseShape_exp, shift ) );
+ scale_sig32( cngNoiseLevel + sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ), sub( FFTCLDFBLEN, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ) ), sub( *cngNoiseLevel_exp, shift ) );
- *cngNoiseLevel_exp = shift;
- move16();
+ *cngNoiseLevel_exp = shift;
+ move16();
+ }
/*st->cngTDLevel = (float)sqrt( (sumFLOAT(cngNoiseLevel, hFdCngCom->stopFFTbin - hFdCngCom->startBand) / 2 * hFdCngCom->fftlen) / st->Mode2_L_frame);*/
tmp_loop = sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand );
@@ -1610,8 +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 */
- scalebands_fx( hFdCngCom->sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband,
- hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), cngNoiseLevel, 1 );
+ 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
+ {
+ scalebands_fx( hFdCngCom->sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), cngNoiseLevel, 1 );
+ }
+
*cngNoiseLevel_exp = hFdCngCom->sidNoiseEstExp;
move16();
}
@@ -1624,8 +1105,14 @@ Word16 ApplyFdCng_ivas_fx(
/* Interpolate the CLDFB band levels from the SID (partition) levels */
IF( GT_16( hFdCngCom->regularStopBand, hFdCngCom->numCoreBands ) )
{
- scalebands_fx( sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband,
- hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), cngNoiseLevel, 0 );
+ 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
+ {
+ scalebands_fx( sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), cngNoiseLevel, 0 );
+ }
*cngNoiseLevel_exp = hFdCngCom->sidNoiseEstExp;
move16();
@@ -1688,17 +1175,34 @@ Word16 ApplyFdCng_ivas_fx(
move32();
}
}
- /* adapt scaling for rest of the buffer */
- s = sub( *cngNoiseLevel_exp, add( hFdCngDec->bandNoiseShape_exp, s2 ) );
- FOR( ; j < FFTCLDFBLEN; j++ )
+ IF( EQ_16( st->element_mode, EVS_MONO ) )
{
- cngNoiseLevel[j] = L_shl( cngNoiseLevel[j], s ); /*Q31 - hFdCngDec->bandNoiseShape_exp + s*/
- 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();
}
+ ELSE
+ {
+ Word16 shift1 = L_norm_arr( cngNoiseLevel, j );
+ Word16 shift2 = L_norm_arr( &cngNoiseLevel[j], sub( FFTCLDFBLEN, j ) );
+ Word16 shift = s_max( sub( add( hFdCngDec->bandNoiseShape_exp, s2 ), shift1 ), sub( *cngNoiseLevel_exp, shift2 ) );
- *cngNoiseLevel_exp = add( hFdCngDec->bandNoiseShape_exp, s2 );
- move16();
+ scale_sig32( cngNoiseLevel, j, sub( add( hFdCngDec->bandNoiseShape_exp, s2 ), shift ) );
+ scale_sig32( &cngNoiseLevel[j], sub( FFTCLDFBLEN, j ), sub( *cngNoiseLevel_exp, shift ) );
+
+ *cngNoiseLevel_exp = shift;
+ move16();
+ }
}
}
ELSE IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) )
@@ -1761,25 +1265,29 @@ Word16 ApplyFdCng_ivas_fx(
move32();
}
}
- /* adapt scaling for rest of the buffer */
- s = sub( *cngNoiseLevel_exp, add( hFdCngDec->bandNoiseShape_exp, s2 ) );
- FOR( ; j < FFTCLDFBLEN; j++ )
- {
- /* NOTE: saturation is added here as part of issue 1218 fix. after rescaling the fdcng noise estimation buffers, due to slight precision loss, values may slightly overflow */
- cngNoiseLevel[j] = L_shl_sat( cngNoiseLevel[j], s ); /*Q31 - hFdCngDec->bandNoiseShape_exp + s*/
- move32();
- }
+ Word16 shift1 = L_norm_arr( cngNoiseLevel, j );
+ Word16 shift2 = L_norm_arr( &cngNoiseLevel[j], sub( FFTCLDFBLEN, j ) );
+ Word16 shift = s_max( sub( add( hFdCngDec->bandNoiseShape_exp, s2 ), shift1 ), sub( *cngNoiseLevel_exp, shift2 ) );
+ scale_sig32( cngNoiseLevel, j, sub( add( hFdCngDec->bandNoiseShape_exp, s2 ), shift ) );
+ scale_sig32( &cngNoiseLevel[j], sub( FFTCLDFBLEN, j ), sub( *cngNoiseLevel_exp, shift ) );
- *cngNoiseLevel_exp = add( hFdCngDec->bandNoiseShape_exp, s2 );
+ *cngNoiseLevel_exp = shift;
move16();
}
}
IF( EQ_16( st->codec_mode, MODE2 ) )
{
/* Generate comfort noise during SID or zero frames */
- generate_comfort_noise_dec_ivas_fx( cldfbBufferReal, cldfbBufferImag, cldfbBufferScale, st, &( st->Q_exc ), 2, -1 );
+ IF( EQ_16( st->element_mode, EVS_MONO ) )
+ {
+ generate_comfort_noise_dec_fx( cldfbBufferReal, cldfbBufferImag, cldfbBufferScale, st, &( st->Q_exc ), 2, -1 );
+ }
+ ELSE
+ {
+ generate_comfort_noise_dec_ivas_fx( cldfbBufferReal, cldfbBufferImag, cldfbBufferScale, st, &( st->Q_exc ), 2, -1 );
+ }
}
BREAK;
@@ -1810,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 */
)
{
@@ -1843,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 );
@@ -1969,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 );
@@ -2399,8 +1861,15 @@ void perform_noise_estimation_dec_ivas_fx(
ELSE
{
Copy32( msPeriodog, msNoiseEst, npart );
- scale_sig32( &msNoiseEst[npart], sub( NPART_SHAPING, npart ), sub( hFdCngDec->msNoiseEst_exp, hFdCngDec->msPeriodog_exp ) );
- hFdCngDec->msNoiseEst_exp = hFdCngDec->msPeriodog_exp;
+
+ Word16 shift1 = L_norm_arr( msNoiseEst, npart );
+ Word16 shift2 = L_norm_arr( &msNoiseEst[npart], sub( NPART_SHAPING, npart ) );
+ Word16 shift = s_max( sub( hFdCngDec->msPeriodog_exp, shift1 ), sub( hFdCngDec->msNoiseEst_exp, shift2 ) );
+
+ scale_sig32( msNoiseEst, npart, sub( hFdCngDec->msPeriodog_exp, shift ) );
+ scale_sig32( &msNoiseEst[npart], sub( NPART_SHAPING, npart ), sub( hFdCngDec->msNoiseEst_exp, shift ) );
+
+ hFdCngDec->msNoiseEst_exp = shift;
move16();
}
@@ -3499,7 +2968,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;
@@ -3532,6 +3003,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();
@@ -3689,9 +3162,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;
@@ -5071,8 +4551,8 @@ void FdCng_decodeSID_ivas_fx(
Word16 shift2 = L_norm_arr( hFdCngCom->cngNoiseLevel + sub( hFdCngCom->stopBand, hFdCngCom->startBand ), sub( FFTCLDFBLEN, sub( hFdCngCom->stopBand, hFdCngCom->startBand ) ) );
Word16 shift = s_max( sub( hFdCngCom->sidNoiseEstExp, shift1 ), sub( hFdCngCom->cngNoiseLevelExp, shift2 ) );
- scale_sig32( hFdCngCom->cngNoiseLevel, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), sub( sub( hFdCngCom->sidNoiseEstExp, shift1 ), shift ) );
- scale_sig32( hFdCngCom->cngNoiseLevel + sub( hFdCngCom->stopBand, hFdCngCom->startBand ), sub( FFTCLDFBLEN, sub( hFdCngCom->stopBand, hFdCngCom->startBand ) ), sub( sub( hFdCngCom->cngNoiseLevelExp, shift2 ), shift ) );
+ scale_sig32( hFdCngCom->cngNoiseLevel, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), sub( hFdCngCom->sidNoiseEstExp, shift ) );
+ scale_sig32( hFdCngCom->cngNoiseLevel + sub( hFdCngCom->stopBand, hFdCngCom->startBand ), sub( FFTCLDFBLEN, sub( hFdCngCom->stopBand, hFdCngCom->startBand ) ), sub( hFdCngCom->cngNoiseLevelExp, shift ) );
hFdCngCom->cngNoiseLevelExp = shift;
move16();
@@ -5245,7 +4725,11 @@ void generate_masking_noise_ivas_fx(
}
ELSE
{
+#ifdef VEC_ARITH_OPT_v1
+ v_add_fixed_no_hdrm( maskingNoise_fx, timeDomainBuffer, timeDomainBuffer, s_min( hFdCngCom->frameSize, length ) ); /*Q31 - *exp_out*/
+#else /* VEC_ARITH_OPT_v1 */
v_add_fixed( maskingNoise_fx, timeDomainBuffer, timeDomainBuffer, s_min( hFdCngCom->frameSize, length ), 0 ); /*Q31 - *exp_out*/
+#endif /* VEC_ARITH_OPT_v1 */
}
return;
@@ -5689,7 +5173,7 @@ void generate_masking_noise_dirac_ivas_fx(
scale_fx = L_shl( scale_fx, q_shift ); /*q_scale+q_shift*/
q_scale = add( q_scale, q_shift );
scale_fx = Mpy_32_32( scale_fx, Mpy_32_16_1( L_mult( h_cldfb->scale, h_cldfb->scale ), CLDFB_SCALING ) ); // Q = q_scale + 2 * Q8 - 34
- q_scale = sub( add( q_scale, 2 * Q8 ), 31 );
+ q_scale = sub( add( q_scale, 2 * Q8 ), 31 + 3 );
ptr_level_fx = hFdCngCom->cngNoiseLevel + sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ); /*Q31 - hFdCngCom->cngNoiseLevelExp*/
q_ptr_level = sub( 31, hFdCngCom->cngNoiseLevelExp );
@@ -5700,8 +5184,8 @@ void generate_masking_noise_dirac_ivas_fx(
q_shift = norm_l( scale_fx );
scale_fx = L_shl( scale_fx, q_shift ); /*q_scale+q_shift*/
q_scale = add( q_scale, q_shift );
- num = Mpy_32_32( scale_fx, *ptr_level_fx ); /*q_num*/
- q_num = sub( add( q_scale, q_ptr_level ), 31 );
+ num = Mpy_32_32( scale_fx, *ptr_level_fx ); /*q_num*/
+ q_num = sub( add( q_scale, q_ptr_level ), 31 - 1 ); // num = ( scale * *ptr_level ) * 0.5f
exp = sub( 31, q_num );
num = Sqrt32( num, &exp ); /*Q31 - exp*/
/* Real part in CLDFB band */
diff --git a/lib_dec/gain_dec_fx.c b/lib_dec/gain_dec_fx.c
index 5e17122311bc97e7495aa9840fa7036d069b3c24..db325cd80b92a8be09722e96ce43d699613736e6 100644
--- a/lib_dec/gain_dec_fx.c
+++ b/lib_dec/gain_dec_fx.c
@@ -601,376 +601,8 @@ void gain_dec_mless_fx(
/* RETURN ARGUMENTS : */
/* _ None */
/*==================================================================================*/
-void gain_dec_lbr_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
- *-----------------------------------------------------------------*/
- 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;
-}
-
-void gain_dec_lbr_ivas_fx(
+void gain_dec_lbr_fx(
Decoder_State *st_fx, /* i/o: decoder state structure */
const Word16 coder_type, /* i : coding type */
const Word16 i_subfr, /* i : subframe index */
@@ -1581,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 8f29eb9d13ce53f72ad042cec7c6fe757ca09f7d..70639810c96f45a36538bd07ca0c86d911e3e6fa 100644
--- a/lib_dec/gs_dec_fx.c
+++ b/lib_dec/gs_dec_fx.c
@@ -23,440 +23,25 @@
/* _ (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) */
/*--------------------------------------------------------------------------*/
/* RETURN ARGUMENTS : */
/* _ None */
/*==========================================================================*/
-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 */
- 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 );
-
- /*---------------------------------------------------------------*
- * 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 */
-/*==========================================================================*/
-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*/
+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 : 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*/
@@ -518,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
@@ -728,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 ) )
{
@@ -884,9 +469,11 @@ 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 ) )
{
Q_exc_old = sub( Q_exc_old, st_fx->Q_exc );
@@ -966,248 +553,18 @@ void decod_audio_ivas_fx(
/* RETURN ARGUMENTS : */
/* _None */
/*==========================================================================*/
-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 */
-/*==========================================================================*/
-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*/
+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*/
+ 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;
@@ -1297,7 +654,15 @@ void gsc_dec_ivas_fx(
{
i--;
}
- 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 */
+
+ 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
+ {
+ 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 */
+ }
st_fx->lp_gainc_fx = mult_r( 640, mean_gain ); /*10 in Q6 x Q12 -> lp_gainc in Q3 */
move16();
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 5c2bff4e734aaae0f107ec51e57e00d68e294e14..79953aacaf2dd5ee9c9258bfb583d0589fe3d92c 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/init_dec_fx.c b/lib_dec/init_dec_fx.c
index b588fdce1bd047a957cc644092befc7ee5368519..11c108380ec274e2d901fddf50bf2890f9a5fef8 100644
--- a/lib_dec/init_dec_fx.c
+++ b/lib_dec/init_dec_fx.c
@@ -448,7 +448,6 @@ ivas_error init_decoder_fx(
}
/* TCX core */
- // VE: reduction possible for MCT_CHAN_MODE_LFE channel - see I1-172
IF( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) )
{
IF( ( st_fx->hTcxDec = (TCX_DEC_HANDLE) malloc( sizeof( TCX_DEC_DATA ) ) ) == NULL )
diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c
index 03f0e4b40a7904afa92be4f0e71e70df0845e214..40012175640da7963da6eb8fbda62bc83507ad23 100644
--- a/lib_dec/ivas_core_dec_fx.c
+++ b/lib_dec/ivas_core_dec_fx.c
@@ -266,11 +266,7 @@ ivas_error ivas_core_dec_fx(
test();
test();
test();
-#ifdef NONBE_MDCT_ST_PLC_DO_NOT_SCALE_OLD_OUT_IF_FIRST_GOOD_IS_SID
IF( !st->bfi && st->prev_bfi && GT_32( st->total_brate, SID_2k40 ) && ( EQ_16( st->last_core_bfi, TCX_20_CORE ) || EQ_16( st->last_core_bfi, TCX_10_CORE ) ) && st->hTcxDec != NULL )
-#else
- IF( !st->bfi && st->prev_bfi && ( EQ_16( st->last_core_bfi, TCX_20_CORE ) || EQ_16( st->last_core_bfi, TCX_10_CORE ) ) && st->hTcxDec != NULL )
-#endif
{
conceal_eof_gain32 = L_shr_sat( st->hTcxDec->conceal_eof_gain32, sub( 16, st->hTcxDec->conceal_eof_gain_e ) ); // e = 31 - Q , 16 - e => 16 - (31 - Q) => Q - 15,
// shr(16 -e ) = shr(Q -15) => 15 - Q ==> Q15
@@ -520,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;
}
@@ -604,7 +600,7 @@ ivas_error ivas_core_dec_fx(
st->hHQ_core->Q_old_wtda_LB = st->hHQ_core->Q_old_wtda;
move16();
- Copy_Scale_sig_16_32_DEPREC( output_16_fx[n], output_32_fx[n], L_FRAME48k, Q11 ); // Q11
+ Copy_Scale_sig_16_32_DEPREC( output_16_fx[n], output_32_fx[n], output_frame, Q11 ); // Q11
IF( st->hTcxDec )
{
@@ -771,13 +767,8 @@ ivas_error ivas_core_dec_fx(
test();
test();
-#ifdef NONBE_MDCT_ST_DTX_SKIP_DEWHITENING_OF_NOISE_SHAPES_ON_SID_FRAMES
/* On first good active frame after frameloss undo the whitening of the bg noise shape */
IF( GT_32( sts[0]->core_brate, SID_2k40 ) && sts[0]->bfi == 0 && EQ_16( sts[0]->prev_bfi, 1 ) )
-#else
- IF( sts[0]->bfi == 0 && EQ_16( sts[0]->prev_bfi, 1 ) )
- /* On first good frame after frameloss undo the whitening of the bg noise shape */
-#endif
{
FOR( n = 0; n < n_channels; ++n )
{
@@ -1039,7 +1030,7 @@ ivas_error ivas_core_dec_fx(
/* Memories Re-Scaling */
Copy_Scale_sig_16_32_no_sat( hb_synth_16_fx[n], hb_synth_32_fx[n], L_FRAME48k, sub( Q11, Q_hb_synth_fx ) ); // Q11
Copy_Scale_sig_16_32_no_sat( output_16_fx[n], output_32_fx[n], L_FRAME48k, sub( Q11, Q_input ) ); // Q11 // Q_input can get value <= -5
- Copy_Scale_sig_16_32_no_sat( synth_16_fx[n], synth_32_fx[n], L_FRAME48k, sub( Q11, Q_synth_fx ) ); // Q11
+ Copy_Scale_sig_16_32_no_sat( synth_16_fx[n], synth_32_fx[n], output_frame, sub( Q11, Q_synth_fx ) ); // Q11
IF( hBWE_FD != NULL )
{
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 cda02a24a8d005e17b6bb4ae591109563150eb52..ff02d813de09c65482c49db19275795c10c03e88 100644
--- a/lib_dec/ivas_dirac_dec_fx.c
+++ b/lib_dec/ivas_dirac_dec_fx.c
@@ -1508,10 +1508,27 @@ void ivas_qmetadata_to_dirac_fx(
{
FOR( b = MASA_band_grouping_24[band_mapping[band]]; b < MASA_band_grouping_24[band_mapping[band + 1]]; ++b )
{
- hSpatParamRendCom->azimuth[meta_write_index][b] = extract_h( L_shr( q_direction->band_data[band].azimuth_fx[block], 6 ) );
+ /* Right shifting -1 -> -1, Hence this change is done */
+ Word32 L_tmp = L_abs( q_direction->band_data[band].azimuth_fx[block] );
+ hSpatParamRendCom->azimuth[meta_write_index][b] = extract_h( L_shr( L_tmp, 6 ) );
move16();
- hSpatParamRendCom->elevation[meta_write_index][b] = extract_h( L_shr( q_direction->band_data[band].elevation_fx[block], 6 ) );
+
+ IF( q_direction->band_data[band].azimuth_fx[block] < 0 )
+ {
+ hSpatParamRendCom->azimuth[meta_write_index][b] = negate( hSpatParamRendCom->azimuth[meta_write_index][b] );
+ move16();
+ }
+
+ L_tmp = L_abs( q_direction->band_data[band].elevation_fx[block] );
+ hSpatParamRendCom->elevation[meta_write_index][b] = extract_h( L_shr( L_tmp, 6 ) );
move16();
+
+ IF( q_direction->band_data[band].elevation_fx[block] < 0 )
+ {
+ hSpatParamRendCom->elevation[meta_write_index][b] = negate( hSpatParamRendCom->elevation[meta_write_index][b] );
+ move16();
+ }
+
hSpatParamRendCom->energy_ratio1_fx[meta_write_index][b] = q_direction->band_data[band].energy_ratio_fx[block];
move32();
hSpatParamRendCom->diffuseness_vector_fx[meta_write_index][b] = L_sub( ONE_IN_Q30, q_direction->band_data[band].energy_ratio_fx[block] );
@@ -1556,10 +1573,25 @@ void ivas_qmetadata_to_dirac_fx(
{
FOR( b = MASA_band_grouping_24[band_mapping[band]]; b < MASA_band_grouping_24[band_mapping[band + 1]]; ++b )
{
- hSpatParamRendCom->azimuth2[meta_write_index][b] = extract_h( L_shr( q_direction->band_data[band].azimuth_fx[block], 6 ) );
+ /* Right shifting -1 -> -1, Hence this change is done */
+ Word32 L_tmp = L_abs( q_direction->band_data[band].azimuth_fx[block] );
+ hSpatParamRendCom->azimuth2[meta_write_index][b] = extract_h( L_shr( L_tmp, 6 ) );
move16();
- hSpatParamRendCom->elevation2[meta_write_index][b] = extract_h( L_shr( q_direction->band_data[band].elevation_fx[block], 6 ) );
+ IF( q_direction->band_data[band].azimuth_fx[block] < 0 )
+ {
+ hSpatParamRendCom->azimuth2[meta_write_index][b] = negate( hSpatParamRendCom->azimuth2[meta_write_index][b] );
+ move16();
+ }
+
+ L_tmp = L_abs( q_direction->band_data[band].elevation_fx[block] );
+ hSpatParamRendCom->elevation2[meta_write_index][b] = extract_h( L_shr( L_tmp, 6 ) );
move16();
+ IF( q_direction->band_data[band].elevation_fx[block] < 0 )
+ {
+ hSpatParamRendCom->elevation2[meta_write_index][b] = negate( hSpatParamRendCom->elevation2[meta_write_index][b] );
+ move16();
+ }
+
hSpatParamRendCom->energy_ratio2_fx[meta_write_index][b] = q_direction->band_data[band].energy_ratio_fx[block];
move32();
hSpatParamRendCom->diffuseness_vector_fx[meta_write_index][b] = L_sub( hSpatParamRendCom->diffuseness_vector_fx[meta_write_index][b], q_direction->band_data[band].energy_ratio_fx[block] );
@@ -2254,6 +2286,39 @@ 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 );
+ }
+ }
+
+#ifdef SPLIT_REND_WITH_HEAD_ROT
+ FOR( Word16 p = 0; p < MAX_HEAD_ROT_POSES; p++ )
+ {
+ FOR( i = 0; i < BINAURAL_CHANNELS; i++ )
+ {
+ FOR( Word16 j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ )
+ {
+ set32_fx( Cldfb_RealBuffer_Binaural_fx[p][i][j], 0, CLDFB_NO_CHANNELS_MAX );
+ set32_fx( Cldfb_RealBuffer_Binaural_fx[p][i][j], 0, CLDFB_NO_CHANNELS_MAX );
+ }
+ }
+ }
+#else
+ 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 );
+ }
+ }
+#endif
+
/* local copies of azi, ele, diffuseness */
Word16 azimuth[CLDFB_NO_CHANNELS_MAX];
Word16 elevation[CLDFB_NO_CHANNELS_MAX];
@@ -3150,7 +3215,11 @@ void ivas_dirac_dec_render_sf_fx(
v_multc_fixed( onset_filter_fx, 536870912 /* 0.25f in Q31 */, onset_filter_fx, hSpatParamRendCom->num_freq_bands );
+#ifdef VEC_ARITH_OPT_v1
+ v_add_fixed_no_hdrm( onset_filter_fx, onset_filter_subframe_fx, onset_filter_subframe_fx, hSpatParamRendCom->num_freq_bands ); /* Q31 */
+#else /* VEC_ARITH_OPT_v1 */
v_add_fixed( onset_filter_fx, onset_filter_subframe_fx, onset_filter_subframe_fx, hSpatParamRendCom->num_freq_bands, 0 ); /* Q31 */
+#endif /* VEC_ARITH_OPT_v1 */
p_onset_filter_fx = onset_filter_subframe_fx;
}
ELSE
@@ -3898,7 +3967,9 @@ void ivas_dirac_dec_render_sf_fx(
{
Word16 j, k, j2, l;
Word16 num_objects, nchan_out_woLFE, lfe_index;
+#ifndef FIX_1379_MASA_ANGLE_ROUND
Word16 az1, el1;
+#endif
Word16 n_slots_to_render;
Word16 n_samples_to_render;
Word16 interp_offset;
@@ -3932,13 +4003,20 @@ void ivas_dirac_dec_render_sf_fx(
Word16 el_q0 = extract_l( L_shr( st_ivas->hIsmMetaData[i]->elevation_fx, Q22 ) );
Word32 az1_32, el1_32;
rotateAziEle_fixed( az_q0, el_q0, &az1_32, &el1_32, st_ivas->hCombinedOrientationData->Rmat_fx[0], st_ivas->hIntSetup.is_planar_setup );
+#ifndef FIX_1379_MASA_ANGLE_ROUND
az1 = extract_h( az1_32 );
el1 = extract_h( el1_32 );
+#endif
IF( st_ivas->hEFAPdata != NULL )
{
+#ifdef FIX_1379_MASA_ANGLE_ROUND
+ 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
+#endif
efap_determine_gains_fx( st_ivas->hEFAPdata, st_ivas->hIsmRendererData->gains_fx[i], azi_fx, ele_fx, EFAP_MODE_EFAP );
}
}
diff --git a/lib_dec/ivas_dirac_output_synthesis_cov_fx.c b/lib_dec/ivas_dirac_output_synthesis_cov_fx.c
index 6d367538d26d575e27d55756a9222a5c96d5c322..caddb5c5cc9fe94936879def3f490ad0ae42ed6b 100644
--- a/lib_dec/ivas_dirac_output_synthesis_cov_fx.c
+++ b/lib_dec/ivas_dirac_output_synthesis_cov_fx.c
@@ -30,6 +30,8 @@
*******************************************************************************************************/
+#define MERGE_REQUEST_1564_SPEEDUP_ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx_NONBE
+
#include
#include
#include
@@ -516,10 +518,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 +533,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 +602,36 @@ 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;
+
+ shifter = 31 - mixing_matrix_res_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 < 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;
+ }
+ 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 ) );
+ }
+ }
+
+
+#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 +647,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 +671,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 +717,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 69eed516c41d1bc364d569a6735eb0dbd05f4d1e..0000000000000000000000000000000000000000
--- a/lib_dec/ivas_init_dec.c
+++ /dev/null
@@ -1,3565 +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"
-#ifdef SPLIT_REND_WITH_HEAD_ROT
-#include "lib_isar_pre_rend.h"
-#include "isar_prot.h"
-#include "isar_stat.h"
-#endif
-
-
-/*-------------------------------------------------------------------*
- * 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 );
-
-
-#ifdef SPLIT_REND_WITH_HEAD_ROT
-static ivas_error ivas_dec_reconfig_split_rend( Decoder_Struct *st_ivas );
-
-
-/*-------------------------------------------------------------------*
- * ivas_dec_reconfig_split_rend()
- *
- * IVAS decoder split rend reconfig
- *-------------------------------------------------------------------*/
-
-static ivas_error ivas_dec_reconfig_split_rend(
- Decoder_Struct *st_ivas /* i : IVAS decoder structure */
-)
-{
- ivas_error error;
- Word16 cldfb_in_flag, num_ch, ch, isCldfbNeeded, i, pcm_out_flag;
- SPLIT_REND_WRAPPER *hSplitRendWrapper;
-
- hSplitRendWrapper = &st_ivas->hSplitBinRend->splitrend;
- move16();
- pcm_out_flag = ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0;
- move16();
- cldfb_in_flag = 0;
- move16();
-
- IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) ||
- EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ||
- EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) ||
- EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) )
- {
- cldfb_in_flag = 1;
- move16();
- }
-
- ISAR_PRE_REND_GetMultiBinPoseData( &st_ivas->hRenderConfig->split_rend_config, &hSplitRendWrapper->multiBinPoseData, ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->sr_pose_pred_axis : DEFAULT_AXIS );
-
- isCldfbNeeded = 0;
- move16();
-
- IF( ( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) && EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) ||
- ( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) && EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) )
- {
- cldfb_in_flag = 0;
- move16();
- }
-
- IF( NE_16( st_ivas->renderer_type, RENDERER_DISABLE ) )
- {
- IF( EQ_16( cldfb_in_flag, 0 ) )
- {
- isCldfbNeeded = 1;
- move16();
- }
- ELSE IF( EQ_16( st_ivas->hRenderConfig->split_rend_config.codec, ISAR_SPLIT_REND_CODEC_LC3PLUS ) && cldfb_in_flag )
- {
- isCldfbNeeded = 1;
- move16();
- }
- ELSE IF( pcm_out_flag && cldfb_in_flag )
- {
- isCldfbNeeded = 1;
- move16();
- }
- }
- ELSE IF( st_ivas->hDecoderConfig->Opt_non_diegetic_pan )
- {
- isCldfbNeeded = 1;
- move16();
- }
-
- IF( EQ_16( isCldfbNeeded, 1 ) && hSplitRendWrapper->hCldfbHandles == NULL )
- {
- IF( ( hSplitRendWrapper->hCldfbHandles = (CLDFB_HANDLES_WRAPPER_HANDLE) malloc( sizeof( CLDFB_HANDLES_WRAPPER ) ) ) == NULL )
- {
- return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CLDFB handles\n" ) );
- }
-
- num_ch = i_mult( MAX_HEAD_ROT_POSES, BINAURAL_CHANNELS );
- move16();
- FOR( ch = 0; ch < num_ch; ch++ )
- {
- hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] = NULL;
- move16();
- }
-
- num_ch = i_mult( hSplitRendWrapper->multiBinPoseData.num_poses, BINAURAL_CHANNELS );
- move16();
-
- FOR( ch = 0; ch < num_ch; ch++ )
- {
- IF( ( error = openCldfb_ivas_fx( &( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] ), CLDFB_ANALYSIS, st_ivas->hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS, DEC ) ) != IVAS_ERR_OK )
- {
- return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not open CLDFB handles\n" ) );
- }
- }
-
- FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ )
- {
- if ( ( error = openCldfb_ivas_fx( &( hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] ), CLDFB_SYNTHESIS, st_ivas->hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS, DEC ) ) != IVAS_ERR_OK )
- {
- return error;
- }
- }
- }
- ELSE IF( EQ_16( isCldfbNeeded, 0 ) && hSplitRendWrapper->hCldfbHandles != NULL )
- {
- num_ch = i_mult( MAX_HEAD_ROT_POSES, BINAURAL_CHANNELS );
- move16();
- FOR( ch = 0; ch < num_ch; ch++ )
- {
- IF( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] != NULL )
- {
- deleteCldfb_ivas_fx( &hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] );
- hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] = NULL;
- move32();
- }
- }
-
- FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ )
- {
- IF( hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] != NULL )
- {
- deleteCldfb_ivas_fx( &hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] );
- hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] = NULL;
- move32();
- }
- }
-
- free( hSplitRendWrapper->hCldfbHandles );
- hSplitRendWrapper->hCldfbHandles = NULL;
- move32();
- }
-
- IF( ( NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_OBJECTS_TD ) ) &&
- ( NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || NE_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) &&
- !( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) && EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) ) /* td-rend not needed? */
- {
- FOR( i = 0; i < MAX_HEAD_ROT_POSES - 1; ++i )
- {
- IF( st_ivas->hTdRendHandles[i] != NULL )
- {
- st_ivas->hTdRendHandles[i]->HrFiltSet_p = NULL;
- move32();
- ivas_td_binaural_close_fx( &st_ivas->hTdRendHandles[i] );
- }
- }
- }
-
- return IVAS_ERR_OK;
-}
-
-
-/*-------------------------------------------------------------------*
- * ivas_dec_init_split_rend()
- *
- * IVAS decoder split rend init
- *-------------------------------------------------------------------*/
-
-static ivas_error ivas_dec_init_split_rend(
- Decoder_Struct *st_ivas /* i : IVAS decoder structure */
-)
-{
- ivas_error error;
- Word16 cldfb_in_flag, pcm_out_flag;
- Word16 mixed_td_cldfb_flag;
-
- pcm_out_flag = ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0;
- cldfb_in_flag = 0;
- move16();
-
- IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) ||
- EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ||
- EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) ||
- EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) )
- {
- cldfb_in_flag = 1;
- move16();
- }
-
- ISAR_PRE_REND_GetMultiBinPoseData( &st_ivas->hRenderConfig->split_rend_config, &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->sr_pose_pred_axis : DEFAULT_AXIS );
-
- IF( EQ_16( cldfb_in_flag, 1 ) && ( EQ_16( st_ivas->hSplitBinRend->splitrend.multiBinPoseData.poseCorrectionMode, ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) ) )
- {
- IF( ( st_ivas->hSplitBinRend->hCldfbDataOut = (ISAR_DEC_SPLIT_REND_CLDFB_OUT_DATA_HANDLE) malloc( sizeof( ISAR_DEC_SPLIT_REND_CLDFB_OUT_DATA ) ) ) == NULL )
- {
- return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for cldfb data out buffer\n" ) );
- }
- }
-
- mixed_td_cldfb_flag = 0;
- move16();
- IF( ( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) && EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) ||
- ( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) && EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) )
- {
- mixed_td_cldfb_flag = 1;
- move16();
- }
-
-#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
- error = ISAR_PRE_REND_open( &st_ivas->hSplitBinRend->splitrend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hDecoderConfig->output_Fs, cldfb_in_flag, pcm_out_flag, st_ivas->hDecoderConfig->render_framesize, mixed_td_cldfb_flag );
- move16();
-#else
- error = ISAR_PRE_REND_open( &st_ivas->hSplitBinRend->splitrend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hDecoderConfig->output_Fs, cldfb_in_flag, pcm_out_flag, (int16_t) st_ivas->hDecoderConfig->render_framesize, mixed_td_cldfb_flag );
- move16();
-#endif
- return error;
-}
-#endif
-
-/*-------------------------------------------------------------------*
- * 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;
- }
- }
-
-
-#ifdef SPLIT_REND_WITH_HEAD_ROT
- /*-----------------------------------------------------------------*
- * reconfig split rendering as renderer might change after bitrate switching
- *-----------------------------------------------------------------*/
-
- IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
- {
- if ( ( error = ivas_dec_reconfig_split_rend( st_ivas ) ) != IVAS_ERR_OK )
- {
- return error;
- }
- }
-#endif
-
- /*----------------------------------------------------------------*
- * 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();
-#ifdef SPLIT_REND_WITH_HEAD_ROT
- 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 ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ||
- ( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) && st_ivas->hDecoderConfig->Opt_non_diegetic_pan ) )
-#else
- 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 ) )
-#endif
- {
- 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;
- }
- }
- }
- }
- }
-
-#ifdef SPLIT_REND_WITH_HEAD_ROT
- /*-----------------------------------------------------------------*
- * Initialize binuaral split rendering
- *-----------------------------------------------------------------*/
-
- IF( st_ivas->hSplitBinRend != NULL && ( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ||
- ( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) && st_ivas->hDecoderConfig->Opt_non_diegetic_pan && EQ_16( st_ivas->hRenderConfig->split_rend_config.dof, 0 ) ) ) )
- {
- IF( ( error = ivas_dec_init_split_rend( st_ivas ) ) != IVAS_ERR_OK )
- {
- return error;
- }
- }
-#endif
-
- /*-----------------------------------------------------------------*
- * 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, 1 );
- }
-
- 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, 1 );
- }
-
- 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();
- }
-
-#ifdef NONBE_FIX_978_MC_TDREND_REVERB
- IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) )
-#else
- IF( EQ_32( st_ivas->hIntSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) )
-#endif
- {
- 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;
- }
- }
-
-#ifdef SPLIT_REND_WITH_HEAD_ROT
- 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, ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ),
- IVAS_ERR_OK ) )
-#else
- 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 ) )
-#endif
- {
- 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 )
- {
-#ifdef SPLIT_REND_WITH_HEAD_ROT
- IF( NE_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && NE_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
-#endif
- {
- /* 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;
-#ifdef SPLIT_REND_WITH_HEAD_ROT
- for ( i = 0; i < MAX_HEAD_ROT_POSES; i++ )
- {
- st_ivas->hDiracDecBin[i] = NULL;
- }
-#else
- st_ivas->hDiracDecBin = NULL;
-#endif
- 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;
-
-#ifdef SPLIT_REND_WITH_HEAD_ROT
- st_ivas->hSplitBinRend = NULL;
- for ( i = 0; i < MAX_HEAD_ROT_POSES - 1; ++i )
- {
- st_ivas->hTdRendHandles[i] = NULL;
- }
-#endif
- /* 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 );
-
-#ifdef SPLIT_REND_WITH_HEAD_ROT
- /* TD binaural renderer handles */
- for ( i = 0; i < MAX_HEAD_ROT_POSES - 1; ++i )
- {
- if ( st_ivas->hTdRendHandles[i] != NULL )
- {
- st_ivas->hTdRendHandles[i]->HrFiltSet_p = NULL;
- ivas_td_binaural_close_fx( &st_ivas->hTdRendHandles[i] );
- }
- }
-#endif
-
- /* Parametric binaural renderer handle */
-#ifdef SPLIT_REND_WITH_HEAD_ROT
- ivas_dirac_dec_close_binaural_data( st_ivas->hDiracDecBin );
-#else
- ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin );
-#endif
-
- /* Crend handle */
-#ifdef SPLIT_REND_WITH_HEAD_ROT
- ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ), ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses );
-#else
- ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ) );
-#endif
-
- /* 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 );
- }
- 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();
- }
- }
-
-#ifdef SPLIT_REND_WITH_HEAD_ROT
- if ( st_ivas->hDiracDecBin[0]->useTdDecorr )
-#else
- IF( st_ivas->hDiracDecBin->useTdDecorr )
-#endif
- {
- *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" );
- }
- }
-
-#ifdef SPLIT_REND_WITH_HEAD_ROT
- IF( ( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) && NE_32( output_Fs, 48000 ) )
- {
- return IVAS_ERROR( IVAS_ERR_INVALID_SAMPLING_RATE, "Error: Only 48kHz output sampling rate is supported for split rendering." );
- }
-#endif
-
- IF( st_ivas->hDecoderConfig->Opt_Headrotation )
- {
- test();
- test();
-#ifdef SPLIT_REND_WITH_HEAD_ROT
- 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 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) )
-#else
- 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 ) ) )
-#endif
- {
- 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 dac7d0da670a406e6151a14afebf2ed923038300..fea9c5b974b4b80e7c4885fdb447d6ef3b8ccfb8 100644
--- a/lib_dec/ivas_init_dec_fx.c
+++ b/lib_dec/ivas_init_dec_fx.c
@@ -1,4 +1,3414 @@
+/******************************************************************************************************
+
+ (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"
+#ifdef SPLIT_REND_WITH_HEAD_ROT
+#include "lib_isar_pre_rend.h"
+#include "isar_prot.h"
+#include "isar_stat.h"
+#endif
+
+
+/*-------------------------------------------------------------------*
+ * 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 );
+
+#ifdef SPLIT_REND_WITH_HEAD_ROT
+static ivas_error ivas_dec_reconfig_split_rend( Decoder_Struct *st_ivas );
+
+
+/*-------------------------------------------------------------------*
+ * ivas_dec_reconfig_split_rend()
+ *
+ * IVAS decoder split rend reconfig
+ *-------------------------------------------------------------------*/
+
+static ivas_error ivas_dec_reconfig_split_rend(
+ Decoder_Struct *st_ivas /* i : IVAS decoder structure */
+)
+{
+ ivas_error error;
+ Word16 cldfb_in_flag, num_ch, ch, isCldfbNeeded, i, pcm_out_flag;
+ SPLIT_REND_WRAPPER *hSplitRendWrapper;
+
+ hSplitRendWrapper = &st_ivas->hSplitBinRend->splitrend;
+ move16();
+ pcm_out_flag = ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0;
+ move16();
+ cldfb_in_flag = 0;
+ move16();
+
+ IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) ||
+ EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ||
+ EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) ||
+ EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) )
+ {
+ cldfb_in_flag = 1;
+ move16();
+ }
+
+ ISAR_PRE_REND_GetMultiBinPoseData( &st_ivas->hRenderConfig->split_rend_config, &hSplitRendWrapper->multiBinPoseData, ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->sr_pose_pred_axis : DEFAULT_AXIS );
+
+ isCldfbNeeded = 0;
+ move16();
+
+ IF( ( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) && EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) ||
+ ( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) && EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) )
+ {
+ cldfb_in_flag = 0;
+ move16();
+ }
+
+ IF( NE_16( st_ivas->renderer_type, RENDERER_DISABLE ) )
+ {
+ IF( EQ_16( cldfb_in_flag, 0 ) )
+ {
+ isCldfbNeeded = 1;
+ move16();
+ }
+ ELSE IF( EQ_16( st_ivas->hRenderConfig->split_rend_config.codec, ISAR_SPLIT_REND_CODEC_LC3PLUS ) && cldfb_in_flag )
+ {
+ isCldfbNeeded = 1;
+ move16();
+ }
+ ELSE IF( pcm_out_flag && cldfb_in_flag )
+ {
+ isCldfbNeeded = 1;
+ move16();
+ }
+ }
+ ELSE IF( st_ivas->hDecoderConfig->Opt_non_diegetic_pan )
+ {
+ isCldfbNeeded = 1;
+ move16();
+ }
+
+ IF( EQ_16( isCldfbNeeded, 1 ) && hSplitRendWrapper->hCldfbHandles == NULL )
+ {
+ IF( ( hSplitRendWrapper->hCldfbHandles = (CLDFB_HANDLES_WRAPPER_HANDLE) malloc( sizeof( CLDFB_HANDLES_WRAPPER ) ) ) == NULL )
+ {
+ return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CLDFB handles\n" ) );
+ }
+
+ num_ch = i_mult( MAX_HEAD_ROT_POSES, BINAURAL_CHANNELS );
+ move16();
+ FOR( ch = 0; ch < num_ch; ch++ )
+ {
+ hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] = NULL;
+ move16();
+ }
+
+ num_ch = i_mult( hSplitRendWrapper->multiBinPoseData.num_poses, BINAURAL_CHANNELS );
+ move16();
+
+ FOR( ch = 0; ch < num_ch; ch++ )
+ {
+ IF( ( error = openCldfb_ivas_fx( &( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] ), CLDFB_ANALYSIS, st_ivas->hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS, DEC ) ) != IVAS_ERR_OK )
+ {
+ return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not open CLDFB handles\n" ) );
+ }
+ }
+
+ FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ )
+ {
+ if ( ( error = openCldfb_ivas_fx( &( hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] ), CLDFB_SYNTHESIS, st_ivas->hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS, DEC ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+ }
+ }
+ ELSE IF( EQ_16( isCldfbNeeded, 0 ) && hSplitRendWrapper->hCldfbHandles != NULL )
+ {
+ num_ch = i_mult( MAX_HEAD_ROT_POSES, BINAURAL_CHANNELS );
+ move16();
+ FOR( ch = 0; ch < num_ch; ch++ )
+ {
+ IF( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] != NULL )
+ {
+ deleteCldfb_ivas_fx( &hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] );
+ hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] = NULL;
+ move32();
+ }
+ }
+
+ FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ )
+ {
+ IF( hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] != NULL )
+ {
+ deleteCldfb_ivas_fx( &hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] );
+ hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] = NULL;
+ move32();
+ }
+ }
+
+ free( hSplitRendWrapper->hCldfbHandles );
+ hSplitRendWrapper->hCldfbHandles = NULL;
+ move32();
+ }
+
+ IF( ( NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_OBJECTS_TD ) ) &&
+ ( NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || NE_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) &&
+ !( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) && EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) ) /* td-rend not needed? */
+ {
+ FOR( i = 0; i < MAX_HEAD_ROT_POSES - 1; ++i )
+ {
+ IF( st_ivas->hTdRendHandles[i] != NULL )
+ {
+ st_ivas->hTdRendHandles[i]->HrFiltSet_p = NULL;
+ move32();
+ ivas_td_binaural_close_fx( &st_ivas->hTdRendHandles[i] );
+ }
+ }
+ }
+
+ return IVAS_ERR_OK;
+}
+
+
+/*-------------------------------------------------------------------*
+ * ivas_dec_init_split_rend()
+ *
+ * IVAS decoder split rend init
+ *-------------------------------------------------------------------*/
+
+static ivas_error ivas_dec_init_split_rend(
+ Decoder_Struct *st_ivas /* i : IVAS decoder structure */
+)
+{
+ ivas_error error;
+ Word16 cldfb_in_flag, pcm_out_flag;
+ Word16 mixed_td_cldfb_flag;
+
+ pcm_out_flag = ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0;
+ cldfb_in_flag = 0;
+ move16();
+
+ IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) ||
+ EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ||
+ EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) ||
+ EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) )
+ {
+ cldfb_in_flag = 1;
+ move16();
+ }
+
+ ISAR_PRE_REND_GetMultiBinPoseData( &st_ivas->hRenderConfig->split_rend_config, &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->sr_pose_pred_axis : DEFAULT_AXIS );
+
+ IF( EQ_16( cldfb_in_flag, 1 ) && ( EQ_16( st_ivas->hSplitBinRend->splitrend.multiBinPoseData.poseCorrectionMode, ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) ) )
+ {
+ IF( ( st_ivas->hSplitBinRend->hCldfbDataOut = (ISAR_DEC_SPLIT_REND_CLDFB_OUT_DATA_HANDLE) malloc( sizeof( ISAR_DEC_SPLIT_REND_CLDFB_OUT_DATA ) ) ) == NULL )
+ {
+ return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for cldfb data out buffer\n" ) );
+ }
+ }
+
+ mixed_td_cldfb_flag = 0;
+ move16();
+ IF( ( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) && EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) ||
+ ( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) && EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) )
+ {
+ mixed_td_cldfb_flag = 1;
+ move16();
+ }
+
+#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
+ error = ISAR_PRE_REND_open( &st_ivas->hSplitBinRend->splitrend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hDecoderConfig->output_Fs, cldfb_in_flag, pcm_out_flag, st_ivas->hDecoderConfig->render_framesize, mixed_td_cldfb_flag );
+ move16();
+#else
+ error = ISAR_PRE_REND_open( &st_ivas->hSplitBinRend->splitrend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hDecoderConfig->output_Fs, cldfb_in_flag, pcm_out_flag, (int16_t) st_ivas->hDecoderConfig->render_framesize, mixed_td_cldfb_flag );
+ move16();
+#endif
+ return error;
+}
+#endif
+
+/*-------------------------------------------------------------------*
+ * 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;
+ }
+ }
+
+#ifdef SPLIT_REND_WITH_HEAD_ROT
+ /*-----------------------------------------------------------------*
+ * reconfig split rendering as renderer might change after bitrate switching
+ *-----------------------------------------------------------------*/
+
+ IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
+ {
+ if ( ( error = ivas_dec_reconfig_split_rend( st_ivas ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+ }
+#endif
+
+ /*----------------------------------------------------------------*
+ * 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();
+#ifdef SPLIT_REND_WITH_HEAD_ROT
+ 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 ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ||
+ ( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) && st_ivas->hDecoderConfig->Opt_non_diegetic_pan ) )
+#else
+ 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 ) )
+#endif
+ {
+ 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;
+ }
+ }
+ }
+ }
+ }
+
+#ifdef SPLIT_REND_WITH_HEAD_ROT
+ /*-----------------------------------------------------------------*
+ * Initialize binuaral split rendering
+ *-----------------------------------------------------------------*/
+
+ IF( st_ivas->hSplitBinRend != NULL && ( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ||
+ ( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) && st_ivas->hDecoderConfig->Opt_non_diegetic_pan && EQ_16( st_ivas->hRenderConfig->split_rend_config.dof, 0 ) ) ) )
+ {
+ IF( ( error = ivas_dec_init_split_rend( st_ivas ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+ }
+#endif
+
+ /*-----------------------------------------------------------------*
+ * 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, 1 );
+ }
+ 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, 1 );
+ }
+
+ 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();
+ }
+
+#ifdef NONBE_FIX_978_MC_TDREND_REVERB
+ IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) )
+#else
+ IF( EQ_32( st_ivas->hIntSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) )
+#endif
+ {
+ 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;
+ }
+ }
+
+#ifdef SPLIT_REND_WITH_HEAD_ROT
+ 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, ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ),
+ IVAS_ERR_OK ) )
+#else
+ 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 ) )
+#endif
+ {
+ 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 )
+ {
+#ifdef SPLIT_REND_WITH_HEAD_ROT
+ IF( NE_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && NE_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
+#endif
+ {
+ /* 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;
+#ifdef SPLIT_REND_WITH_HEAD_ROT
+ for ( i = 0; i < MAX_HEAD_ROT_POSES; i++ )
+ {
+ st_ivas->hDiracDecBin[i] = NULL;
+ }
+#else
+ st_ivas->hDiracDecBin = NULL;
+#endif
+ 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;
+
+#ifdef SPLIT_REND_WITH_HEAD_ROT
+ st_ivas->hSplitBinRend = NULL;
+ for ( i = 0; i < MAX_HEAD_ROT_POSES - 1; ++i )
+ {
+ st_ivas->hTdRendHandles[i] = NULL;
+ }
+#endif
+ /* 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 );
+
+#ifdef SPLIT_REND_WITH_HEAD_ROT
+ /* TD binaural renderer handles */
+ for ( i = 0; i < MAX_HEAD_ROT_POSES - 1; ++i )
+ {
+ if ( st_ivas->hTdRendHandles[i] != NULL )
+ {
+ st_ivas->hTdRendHandles[i]->HrFiltSet_p = NULL;
+ ivas_td_binaural_close_fx( &st_ivas->hTdRendHandles[i] );
+ }
+ }
+#endif
+
+ /* Parametric binaural renderer handle */
+#ifdef SPLIT_REND_WITH_HEAD_ROT
+ ivas_dirac_dec_close_binaural_data( st_ivas->hDiracDecBin );
+#else
+ ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin );
+#endif
+
+ /* Crend handle */
+#ifdef SPLIT_REND_WITH_HEAD_ROT
+ ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ), ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses );
+#else
+ ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ) );
+#endif
+
+ /* 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();
+ }
+ }
+#ifdef SPLIT_REND_WITH_HEAD_ROT
+ IF( st_ivas->hDiracDecBin[0]->useTdDecorr )
+#else
+ IF( st_ivas->hDiracDecBin->useTdDecorr )
+#endif
+ {
+ *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 */
@@ -264,3 +3674,152 @@ 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" );
+ }
+ }
+
+#ifdef SPLIT_REND_WITH_HEAD_ROT
+ IF( ( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) && NE_32( output_Fs, 48000 ) )
+ {
+ return IVAS_ERROR( IVAS_ERR_INVALID_SAMPLING_RATE, "Error: Only 48kHz output sampling rate is supported for split rendering." );
+ }
+#endif
+
+ IF( st_ivas->hDecoderConfig->Opt_Headrotation )
+ {
+ test();
+ test();
+#ifdef SPLIT_REND_WITH_HEAD_ROT
+ 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 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) )
+#else
+ 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 ) ) )
+#endif
+ {
+ 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 c184ef8c2898eed31c751bbc55912e4cb9ef49a7..beb6535a2489698e40cc4d66322f147c4d7d7871 100644
--- a/lib_dec/ivas_jbm_dec_fx.c
+++ b/lib_dec/ivas_jbm_dec_fx.c
@@ -2193,7 +2193,11 @@ ivas_error ivas_jbm_dec_render_fx(
/* add already rendered SBA part */
FOR( n = 0; n < nchan_out; n++ )
{
+#ifdef VEC_ARITH_OPT_v1
+ v_add_fixed_no_hdrm( p_output_fx[n], p_tc_fx[n + st_ivas->nchan_ism], p_output_fx[n], *nSamplesRendered );
+#else /* VEC_ARITH_OPT_v1 */
v_add_fixed( p_output_fx[n], p_tc_fx[n + st_ivas->nchan_ism], p_output_fx[n], *nSamplesRendered, 0 );
+#endif /* VEC_ARITH_OPT_v1 */
}
}
ELSE IF( 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_ROOM ) )
@@ -2667,6 +2671,9 @@ ivas_error ivas_jbm_dec_flush_renderer_fx(
Word32 output_fx[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS][L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES];
Word32 *p_output_fx[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS];
Word16 nchan_in, nchan_out;
+#ifndef SPLIT_REND_WITH_HEAD_ROT
+ Word16 gd_bits, shift, n_chan_inp, i;
+#endif
IF( !st_ivas->hDecoderConfig->Opt_tsm )
{
return IVAS_ERR_OK;
@@ -2749,7 +2756,7 @@ ivas_error ivas_jbm_dec_flush_renderer_fx(
/* Convert to CICPxx; used also for ISM->CICP19->binaural_room rendering */
set16_fx( st_ivas->hIsmRendererData->interpolator_fx, 32767, hTcBuffer->n_samples_granularity ); // 32767=1.0f in Q15
- ivas_ism_render_sf_fx( st_ivas, p_output_fx, *nSamplesRendered );
+ ivas_ism_render_sf_fx( st_ivas, p_output_fx, hTcBuffer->n_samples_granularity );
st_ivas->hCrendWrapper->p_io_qfactor = &st_ivas->hCrendWrapper->io_qfactor;
*st_ivas->hCrendWrapper->p_io_qfactor = 11;
@@ -2762,12 +2769,38 @@ ivas_error ivas_jbm_dec_flush_renderer_fx(
return error;
}
#else
+ shift = MAX_16;
+ move16();
+ n_chan_inp = add( st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hIntSetup.num_lfe );
+
+ FOR( i = 0; i < n_chan_inp; i++ )
+ {
+ shift = s_min( shift, L_norm_arr( p_output_fx[i], hTcBuffer->n_samples_granularity ) );
+ }
+
+ gd_bits = sub( find_guarded_bits_fx( imult1616( hTcBuffer->subframe_nbslots[0], hTcBuffer->n_samples_granularity ) ), shift );
+
+ *st_ivas->hCrendWrapper->p_io_qfactor = sub( *st_ivas->hCrendWrapper->p_io_qfactor, gd_bits );
+ move16();
+
+ FOR( i = 0; i < n_chan_inp; i++ )
+ {
+ scale_sig32( p_output_fx[i], hTcBuffer->n_samples_granularity, sub( *st_ivas->hCrendWrapper->p_io_qfactor, Q11 ) ); // Q(*st_ivas->hCrendWrapper->p_io_qfactor)
+ }
+
IF( NE_32( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, st_ivas->hDecoderConfig, NULL,
NULL, NULL, st_ivas->hTcBuffer, p_output_fx, p_output_fx, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs ) ),
IVAS_ERR_OK ) )
{
return error;
}
+
+ FOR( i = 0; i < n_chan_inp; i++ )
+ {
+ scale_sig32( p_output_fx[i], hTcBuffer->n_samples_granularity, sub( Q11, *st_ivas->hCrendWrapper->p_io_qfactor ) ); // Q(11)
+ }
+ *st_ivas->hCrendWrapper->p_io_qfactor = Q11;
+ move16();
#endif
}
}
diff --git a/lib_dec/ivas_masa_dec_fx.c b/lib_dec/ivas_masa_dec_fx.c
index 23653c53b91395bc70c561e636fd1506971bb40a..eb010c14619bc76efaddc332c62e2e085b516278 100644
--- a/lib_dec/ivas_masa_dec_fx.c
+++ b/lib_dec/ivas_masa_dec_fx.c
@@ -2620,13 +2620,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();
}
}
@@ -2685,12 +2681,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();
diff --git a/lib_dec/ivas_mc_param_dec_fx.c b/lib_dec/ivas_mc_param_dec_fx.c
index b5962311337b000a9acb56faddd40ba4853fdaa2..c499780584c145b441e800e5500964e8b9f0d499 100644
--- a/lib_dec/ivas_mc_param_dec_fx.c
+++ b/lib_dec/ivas_mc_param_dec_fx.c
@@ -2089,8 +2089,13 @@ void ivas_param_mc_dec_render_fx(
{
IF( hLsSetup.index_lfe[idx_lfe] != ch )
{
+#ifdef VEC_ARITH_OPT_v1
+ v_add_fixed_no_hdrm( Cldfb_RealBuffer_fx[ch][slot_idx], Cldfb_RealBuffer_fx[hLsSetup.index_lfe[idx_lfe]][slot_idx], Cldfb_RealBuffer_fx[ch][slot_idx], 1 );
+ v_add_fixed_no_hdrm( Cldfb_ImagBuffer_fx[ch][slot_idx], Cldfb_ImagBuffer_fx[hLsSetup.index_lfe[idx_lfe]][slot_idx], Cldfb_ImagBuffer_fx[ch][slot_idx], 1 );
+#else /* VEC_ARITH_OPT_v1 */
v_add_fixed( Cldfb_RealBuffer_fx[ch][slot_idx], Cldfb_RealBuffer_fx[hLsSetup.index_lfe[idx_lfe]][slot_idx], Cldfb_RealBuffer_fx[ch][slot_idx], 1, 0 );
v_add_fixed( Cldfb_ImagBuffer_fx[ch][slot_idx], Cldfb_ImagBuffer_fx[hLsSetup.index_lfe[idx_lfe]][slot_idx], Cldfb_ImagBuffer_fx[ch][slot_idx], 1, 0 );
+#endif /* VEC_ARITH_OPT_v1 */
}
}
}
diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c
index 5550c4ea13ac4ce80082eed67e0b2553226b967f..6b2cdff41a796d84f9ce29bed4696ecdc593e907 100644
--- a/lib_dec/ivas_mct_dec_fx.c
+++ b/lib_dec/ivas_mct_dec_fx.c
@@ -398,7 +398,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_qmetadata_dec_fx.c b/lib_dec/ivas_qmetadata_dec_fx.c
index 266389ea107fd4e6379448a03718d7bb03a6b543..182ed54abd6a38d87d513abcadd8f33ef049097b 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_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_dft_plc_fx.c b/lib_dec/ivas_stereo_dft_plc_fx.c
index 90d9c58235bda9d978657307b0547a9e1c8abda4..3fed308b21c3368cd93ec8880bc612d2a9bfde60 100644
--- a/lib_dec/ivas_stereo_dft_plc_fx.c
+++ b/lib_dec/ivas_stereo_dft_plc_fx.c
@@ -188,6 +188,8 @@ Word32 imax_pos_fx(
Word32 posi, y1, y2, y3, y3_y1, y2i;
Word32 ftmp_den1, ftmp_den2;
Word16 q_div_2i, q_div_posi;
+ Word64 W_tmp;
+ Word16 shift1, shift2;
/* Seek the extrema of the parabola P(x) defined by 3 consecutive points so that P([-1 0 1]) = [y1 y2 y3] */
y1 = y[0]; /* Qx */
move32();
@@ -195,9 +197,13 @@ Word32 imax_pos_fx(
move32();
y3 = y[2]; /* Qx */
move32();
- y3_y1 = L_sub( y3, y1 ); /* Qx */
- ftmp_den1 = L_sub( L_add( y1, y3 ), L_shl( y2, 1 ) ); /* Qx */
- ftmp_den2 = L_shl( L_sub( L_sub( L_shl( y2, 1 ), y1 ), y3 ), 1 ); /* Qx */
+ y3_y1 = L_sub( y3, y1 ); /* Qx */
+ W_tmp = W_sub( W_add( y1, y3 ), W_shl( y2, 1 ) ); /* Qx */
+ shift1 = W_norm( W_tmp );
+ ftmp_den1 = W_extract_h( W_shl( W_tmp, shift1 ) ); /* Qx + shift1 - 32 */
+ W_tmp = W_shl( W_sub( W_sub( W_shl( y2, 1 ), y1 ), y3 ), 1 ); /* Qx */
+ shift2 = W_norm( W_tmp );
+ ftmp_den2 = W_extract_h( W_shl( W_tmp, shift2 ) ); /* Qx + shift2 - 32 */
test();
IF( ( ftmp_den2 == 0 ) || ( ftmp_den1 == 0 ) )
@@ -206,6 +212,7 @@ Word32 imax_pos_fx(
}
y2i = Mpy_32_16_1( Mpy_32_16_1( y3_y1, BASOP_Util_Divide3232_Scale( y3_y1, ftmp_den1, &q_div_2i ) ), (Word16) ( 0xF000 ) ); /* q_div_2i */
+ q_div_2i = sub( add( q_div_2i, shift1 ), 32 );
IF( q_div_2i < 0 )
{
y2i = L_shl( y2i, q_div_2i );
@@ -219,6 +226,7 @@ Word32 imax_pos_fx(
}
/* their corresponding normalized locations */
posi = BASOP_Util_Divide3232_Scale( y3_y1, ( ftmp_den2 ), &q_div_posi ); /* q_div_posi */
+ q_div_posi = sub( add( q_div_posi, shift2 ), 32 );
IF( ( q_div_posi != 0 ) )
{
posi = L_shl( posi, q_div_posi );
diff --git a/lib_dec/ivas_stereo_icbwe_dec_fx.c b/lib_dec/ivas_stereo_icbwe_dec_fx.c
index c7bc98566326d456bc85283242ad1137e28fb4c6..772eb2d7d218c7061e3fd9208ac65f818c0ad218 100644
--- a/lib_dec/ivas_stereo_icbwe_dec_fx.c
+++ b/lib_dec/ivas_stereo_icbwe_dec_fx.c
@@ -904,6 +904,9 @@ void stereo_icBWE_dec_fx(
winSlope_fx = div_s( 1, winLen_fx ); /* Q15 */
alpha_fx = winSlope_fx; /* Q15 */
move16();
+#ifdef FIX_1439_SPEEDUP_stereo_icBWE_dec_fx
+ Word16 winSlope_fx_ = sub( 32767 /* 1.0 in Q15*/, winSlope_fx );
+#endif
FOR( i = 0; i < winLen_fx; i++ )
{
L_tmp = L_mult0( alpha_fx, icbweM2Ref_fx ); /* Q29 */
@@ -911,10 +914,17 @@ void stereo_icBWE_dec_fx(
tmp = shl( round_fx( L_tmp ), 1 ); /* Q14 */
synthRef_fx[i] = Mpy_32_16_1( synthRef_fx[i], tmp ); /* Qsyn - 1 */
move32();
+#ifdef FIX_1439_SPEEDUP_stereo_icBWE_dec_fx
+ if ( LE_16( alpha_fx, winSlope_fx_ ) )
+ {
+ alpha_fx = add( alpha_fx, winSlope_fx ); /* Q15 */
+ }
+#else
IF( LE_16( alpha_fx, sub( 32767 /* 1.0 in Q15*/, winSlope_fx ) ) )
{
alpha_fx = add( alpha_fx, winSlope_fx ); /* Q15 */
}
+#endif
}
FOR( ; i < NS2SA_FX2( st->output_Fs, FRAME_SIZE_NS ); i++ )
diff --git a/lib_dec/ivas_stereo_mdct_core_dec_fx.c b/lib_dec/ivas_stereo_mdct_core_dec_fx.c
index 890e5fc9ef6db902a60454e094612449ceac424c..89cb92a4d08c1b9f834610892fdd5ce2dc73c68c 100644
--- a/lib_dec/ivas_stereo_mdct_core_dec_fx.c
+++ b/lib_dec/ivas_stereo_mdct_core_dec_fx.c
@@ -1097,8 +1097,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_switching_dec_fx.c b/lib_dec/ivas_stereo_switching_dec_fx.c
index bcf714352d2e72e7f4c890d442651bd05648976f..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;
}
@@ -2351,7 +2351,7 @@ static Word32 ncross_corr_self_fx(
q_prod = sub( 81, add( add( headroom_left_x, headroom_left_y ), q_prod ) );
energy = Sqrt32( energy, &q_prod );
- IF( LT_32( energy, L_shl_sat( 1, sub( 31, q_prod ) ) ) )
+ IF( LE_32( energy, L_shl_sat( 1, sub( 31, q_prod ) ) ) )
{
c_c_fx_return = W_shl_sat_l( c_c_fx, 31 - ( 2 * OUTPUT_Q + 1 ) ); // Q31
}
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..6419f851707619786e1b829b5736688777677897 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();
@@ -295,7 +298,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 +315,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,6 +328,7 @@ 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 );
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 628256729435ec26bbf0ed05abba875a4f6646f0..1427b3681d4cb87bbd15a272db9801bc36509726 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.,
diff --git a/lib_dec/lsf_dec_fx.c b/lib_dec/lsf_dec_fx.c
index 21e8705f3aa64d7b7efcb4a8b7b929fbfe49a626..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 */
@@ -100,269 +101,15 @@ static void dqlsf_CNG_fx(
/*===========================================================================*/
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 */
-/*===========================================================================*/
-
-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 1d3e9649793cb0578063ec2b5235a452812ffe1d..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 */
/*=======================================================================*/
-
-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 */
-/*=======================================================================*/
-
-
-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 d581f810a7dd724424e19f9651b0a5c4a11e930c..cbcb225bc1c845d937119028fb6fcc025a19cfeb 100644
--- a/lib_dec/post_dec_fx.c
+++ b/lib_dec/post_dec_fx.c
@@ -168,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
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_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 1b51a29fb642cfffd08c7a39517f1f2d7224b226..bd8700063219b0729e0b9e8448d42aa98512e6c0 100644
--- a/lib_dec/swb_tbe_dec_fx.c
+++ b/lib_dec/swb_tbe_dec_fx.c
@@ -618,6 +618,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 +854,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 +905,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++ )
{
@@ -4644,7 +4648,12 @@ void fb_tbe_dec_fx(
fb_exc_energy = sum2_fx_mod( fb_exc, L_FRAME16k );
/* FB TBE synthesis */
- synthesise_fb_high_band_fx( fb_exc, Q_fb_exc, fb_synth, fb_exc_energy, ratio, st->L_frame, st->bfi, &( hBWE_TD->prev_fbbwe_ratio_fx ), hBWE_TD->fbbwe_hpf_mem_fx, hBWE_TD->fbbwe_hpf_mem_fx_Q, hb_synth_exp );
+ synthesise_fb_high_band_fx( fb_exc, Q_fb_exc, fb_synth, fb_exc_energy, ratio, st->L_frame, st->bfi, &( hBWE_TD->prev_fbbwe_ratio_fx ), hBWE_TD->fbbwe_hpf_mem_fx, hBWE_TD->fbbwe_hpf_mem_fx_Q, hb_synth_exp
+#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2
+ ,
+ st->element_mode
+#endif /*FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2*/
+ );
/* add the fb_synth component to the hb_synth component */
/* v_add_fx( hb_synth, fb_synth, hb_synth, L_FRAME48k );*/
@@ -4713,7 +4722,12 @@ void fb_tbe_dec_ivas_fx(
fb_exc_energy = sum2_fx_mod( fb_exc, L_FRAME16k );
/* FB TBE synthesis */
- synthesise_fb_high_band_fx( fb_exc, Q_fb_exc, fb_synth, fb_exc_energy, ratio, st->L_frame, st->bfi, &( hBWE_TD->prev_fbbwe_ratio_fx ), hBWE_TD->fbbwe_hpf_mem_fx, hBWE_TD->fbbwe_hpf_mem_fx_Q, hb_synth_exp );
+ synthesise_fb_high_band_fx( fb_exc, Q_fb_exc, fb_synth, fb_exc_energy, ratio, st->L_frame, st->bfi, &( hBWE_TD->prev_fbbwe_ratio_fx ), hBWE_TD->fbbwe_hpf_mem_fx, hBWE_TD->fbbwe_hpf_mem_fx_Q, hb_synth_exp
+#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2
+ ,
+ st->element_mode
+#endif /*FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2*/
+ );
test();
IF( GE_16( st->element_mode, IVAS_CPE_DFT ) && ( st->idchan == 0 ) )
@@ -6452,9 +6466,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 ) )
@@ -7022,14 +7036,24 @@ void ivas_swb_tbe_dec_fx(
tmp1 = 0;
move16();
+
+#ifdef FIX_1439_SPEEDUP_ivas_swb_tbe_dec_fx
+ Word32 idx32 = L_shr_r( 0x00333333, 10 ); /*NUM_SHB_SUBFR/L_FRAME16k*/ // Q16
+#endif
+
FOR( i = 0; i < L_FRAME16k; i++ )
{
+#ifndef FIX_1439_SPEEDUP_ivas_swb_tbe_dec_fx
Word16 idx = 0;
move16();
IF( i != 0 )
{
idx = idiv1616( i_mult( NUM_SHB_SUBFR, i ), L_FRAME16k );
}
+#else
+ Word16 idx;
+ idx = extract_h( imult3216( idx32, i ) ); /*Q0*/
+#endif
L_tmp1 = Mult_32_16( L_tmp, GainShape_fx[idx] ); /* Q : 18 + tmp +15 -15*/
White_exc16k_fx[i] = round_fx( Mult_32_16( L_tmp1, White_exc16k_fx[i] ) ); /* 18 + tmp +*Q_white_exc -15 -16 */
move16();
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/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..5003712b7ceda9821bc022dd7e0275be48282386 100644
--- a/lib_enc/ACcontextMapping_enc_fx.c
+++ b/lib_enc/ACcontextMapping_enc_fx.c
@@ -1826,519 +1826,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 795f03403e1355a49da0ffba61995e412aa6ad98..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,10 +391,10 @@ ivas_error acelp_core_enc_fx(
test();
IF( !nelp_mode && !ppp_mode )
{
- config_acelp1( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate,
- 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 );
}
/*-----------------------------------------------------------------*
@@ -460,15 +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 );
- 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,
- -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 );
@@ -513,9 +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 */
- 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,
- -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 );
@@ -1173,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 );
}
/*-----------------------------------------------------------------*
@@ -1310,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 );
}
/*---------------------------------------------------------------*
@@ -1369,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 );
@@ -1378,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 );
}
@@ -1447,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 8226748f745c1e5aa4ad7ce41b2a5e027a55b106..76fa6f151d2f431e7062f1a41b00a099016082d7 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,8 +135,8 @@ void acelp_core_switch_enc_fx(
* Excitation encoding
*----------------------------------------------------------------*/
- config_acelp1( ENC, st_fx->total_brate, cbrate, st_fx->core, -1, -1, st_fx->last_L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot,
- 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 );
@@ -275,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 );
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 c2f9d0585d356c513226ee2059d219e835976724..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,23 +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 */
+
+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 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 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 */
@@ -74,19 +76,22 @@ void analy_lp_ivas_fx(
/* Autocorrelations */
autocorr_fx( pt, M, r_h, r_l, &Q_r[1 - i_subfr], wind_length, wind, 0, 0 );
- /*if ( r[0] < 100.0f && no_thr == 0 )*/
- /*r[0] = 100.0f*/
- IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( L_Comp( r_h[0], r_l[0] ) /* Q_r[1 - i_subfr]*/, sub( 31, add( Q_r[1 - i_subfr], shl( Q_new, 1 ) ) ), 100 /*q0*/, 31 ), -1 ) )
+ IF( NE_16( element_mode, EVS_MONO ) )
{
- /*Q_min stores min of 24 and the actual Q for r*/
- Word16 Q_min = s_min( add( Q_r[1 - i_subfr], shl( Q_new, 1 ) ), 24 ); /* comparing q with 24 because exponent of 100 is 7 so max q should be 24*/
- L_Extract( L_shl( 100, Q_min ), &r_h[0], &r_l[0] ); /*extracting high and low components of r[0]*/
- FOR( i = 1; i < 17; i++ )
+ /*if ( r[0] < 100.0f && no_thr == 0 )*/
+ /*r[0] = 100.0f*/
+ IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( L_Comp( r_h[0], r_l[0] ) /* Q_r[1 - i_subfr]*/, sub( 31, add( Q_r[1 - i_subfr], shl( Q_new, 1 ) ) ), 100 /*q0*/, 31 ), -1 ) )
{
- L_Extract( L_shr( L_Comp( r_h[i], r_l[i] ), sub( add( Q_r[1 - i_subfr], shl( Q_new, 1 ) ), Q_min ) ), &r_h[i], &r_l[i] ); /*scaling all the values to q24*/
+ /*Q_min stores min of 24 and the actual Q for r*/
+ Word16 Q_min = s_min( add( Q_r[1 - i_subfr], shl( Q_new, 1 ) ), 24 ); /* comparing q with 24 because exponent of 100 is 7 so max q should be 24*/
+ L_Extract( L_shl( 100, Q_min ), &r_h[0], &r_l[0] ); /*extracting high and low components of r[0]*/
+ FOR( i = 1; i < 17; i++ )
+ {
+ L_Extract( L_shr( L_Comp( r_h[i], r_l[i] ), sub( add( Q_r[1 - i_subfr], shl( Q_new, 1 ) ), Q_min ) ), &r_h[i], &r_l[i] ); /*scaling all the values to q24*/
+ }
+ Q_r[1 - i_subfr] = sub( Q_min, shl( Q_new, 1 ) ); /*updating the q (subtracting shl( Q_new, 1 ) as in later part it is being added-> to maintain q24 )*/
+ move16();
}
- Q_r[1 - i_subfr] = sub( Q_min, shl( Q_new, 1 ) ); /*updating the q (subtracting shl( Q_new, 1 ) as in later part it is being added-> to maintain q24 )*/
- move16();
}
/* Lag windowing */
@@ -124,92 +129,6 @@ void analy_lp_ivas_fx(
return;
}
-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 */
- int_lsp4_fx( L_frame, lsp_old, lsp_mid, lsp_new, A, M, -2 );
- }
- ELSE
- {
- /* LSP interpolation */
- int_lsp4_fx( L_frame, lsp_old, lsp_mid, lsp_new, A, M, 0 );
- }
- Copy( lsp_new, lsp_old, M ); /* Q15 */
- *ener = L_Comp( epsP_h[M], epsP_l[M] ); /* Q_r */
- move32();
-
- return;
-}
-
-
/*-------------------------------------------------------------------*
* analy_lp_AMR_WB()
*
diff --git a/lib_enc/analy_sp_fx.c b/lib_enc/analy_sp_fx.c
index 4f96ea2d4872231719e0fdf89912fbdbfec04b0c..7062a30900dc52a2758064a42e9cf34d04fc4da7 100644
--- a/lib_enc/analy_sp_fx.c
+++ b/lib_enc/analy_sp_fx.c
@@ -438,7 +438,7 @@ void ivas_analy_sp_fx(
Word16 *q_fr_bands, /* o : energy in critical frequency bands Q0 */
Word32 *lf_E, /* o : per bin E for first... q_lf_E */
Word16 *q_lf_E, /* o : per bin E for first... Q0 */
- Word16 *Etot, /* o : total input energy Q8 */
+ Word32 *Etot, /* o : total input energy Q24 */
const Word16 min_band, /* i : minimum critical band Q0 */
const Word16 max_band, /* i : maximum critical band Q0 */
Word32 *Bin_E, /* o : per-bin energy spectrum q_Bin_E */
@@ -557,7 +557,7 @@ void ivas_analy_sp_fx(
/* Average total log energy over both half-frames */
/* *Etot = 10.0f * (float)log10(0.5f * *Etot); */
- *Etot = -12800 /* 10.f * logf(0.00001f) in Q8 */;
+ *Etot = -838860800 /* 10.f * log10f(0.00001f) in Q24 : This is when LEtot is 0*/;
move16();
IF( LEtot != 0 )
{
@@ -566,7 +566,7 @@ void ivas_analy_sp_fx(
LEtot = W_shl( LEtot, exp ); // q_fr_bands+2+exp
Ltmp = BASOP_Util_Log10( W_extract_h( LEtot ), sub( 61, add( *q_fr_bands, exp ) ) /* 31-(q_fr_bands+2+exp-32) */ ); // Q25
Ltmp = Mpy_32_32( Ltmp, 1342177280 /* 10.f in Q27 */ ); // (Q25, Q27) -> Q21
- *Etot = extract_h( L_shl( Ltmp, Q24 - Q21 ) ); // Q8
+ *Etot = L_shl( Ltmp, Q24 - Q21 ); // Q24
move16();
}
}
@@ -599,7 +599,7 @@ void ivas_analy_sp_fx(
}
/* Average total log energy over both half-frames */
- *Etot = -12800 /* 10.f * logf(0.00001f) in Q8 */;
+ *Etot = -838860800 /* 10.f * log10f(0.00001f) in Q24 : This is when LEtot is 0*/;
move16();
IF( LEtot != 0 )
{
@@ -607,7 +607,7 @@ void ivas_analy_sp_fx(
LEtot = W_shl( LEtot, exp ); // q_fr_bands+exp
Ltmp = BASOP_Util_Log10( W_extract_h( LEtot ), sub( 62, add( *q_fr_bands, exp ) ) /* 31-(q_fr_bands+1+exp-32) */ ); // Q25
Ltmp = Mpy_32_32( Ltmp, 1342177280 /* 10.f in Q27 */ ); // (Q25, Q27) -> Q21
- *Etot = extract_h( L_shl( Ltmp, Q24 - Q21 ) ); // Q8
+ *Etot = L_shl( Ltmp, Q24 - Q21 ); // Q24
move16();
}
}
@@ -620,7 +620,7 @@ void ivas_analy_sp_fx(
*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();
@@ -634,14 +634,14 @@ void ivas_analy_sp_fx(
move32();
Bin_E[L_FFT - 1] = Bin_E[L_FFT - 2]; // *q_Bin_E
move32();
-
+ Word32 add_const = 21475; // 1e-5 in Q31
FOR( i = 0; i < L_FFT / 2; i++ )
{
Bin_E_old[i] = Bin_E[i]; // *q_Bin_E
move32();
/* PS[i] = ( Bin_E[i] + 1e-5f + Bin_E[i + L_FFT / 2] + 1e-5f ) / 2.0f; */
- PS[i] = W_extract_h( W_mac_32_32( W_mult_32_32( Bin_E[i], ONE_IN_Q30 ), Bin_E[i + L_FFT / 2], ONE_IN_Q30 ) ); // *q_Bin_E
+ PS[i] = W_extract_h( W_add( W_mac_32_32( W_mult_32_32( Bin_E[i], ONE_IN_Q30 ), Bin_E[i + L_FFT / 2], ONE_IN_Q30 ), W_shr( W_shl( add_const, 32 ), sub( 31, *q_Bin_E ) ) ) ); // *q_Bin_E
move32();
/* Bin_E[i] = (float) ( 10.0f * log( PS[i] ) ); */
@@ -860,7 +860,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 c79931e45bce9d6dbfcc005e3d6cb5568f497394..819292a5099e6f80243e3a7ecdbbe23c230dc917 100644
--- a/lib_enc/bw_detect_fx.c
+++ b/lib_enc/bw_detect_fx.c
@@ -48,7 +48,7 @@ void bw_detect_fx(
const Word16 mct_on, /* i : flag MCT mode */
const Word16 Q_spec )
{
- Word16 Q_dct;
+ Word16 Q_dct, E_spect_bin, tmp_1;
Word16 i, j, k, bw_max, bin_width, n_bins;
Word16 max_NB, max_WB, max_SWB, max_FB, mean_NB, mean_WB, mean_SWB, mean_FB; /* Q11*/
const Word16 *pt, *pt1;
@@ -324,6 +324,7 @@ void bw_detect_fx(
set16_fx( spect_bin, 1, n_bins );
Q_dct = shl( Q_dct, 1 );
+ E_spect_bin = sub( Q31, Q_dct );
FOR( k = 0; k <= bw_max; k++ )
{
@@ -336,24 +337,33 @@ void bw_detect_fx(
sum32 = L_mac0_o( sum32, *pt1, *pt1, &Overflow );
pt1++;
}
-
- IF( LE_32( sum32, 1 ) )
+ tmp_1 = BASOP_Util_Cmp_Mant32Exp( sum32, E_spect_bin, MAX_32, Q31 - 41 ); /* Any sum32 in Q_dct if it is less than MAX_32 in Q41 will be less than 0.001 */
+ test();
+ IF( st->element_mode != EVS_MONO && tmp_1 < 0 )
{
- /*deal with zero spectrum*/
- spect_bin[i] = -1;
+ spect_bin[i] = -6144; /* log10f( 0.00100000005 ) in Q11 */
move16();
}
ELSE
{
- /* spect_bin[i] = (float)log10(spect_bin[i]);
- = log2(spect_bin[i])*log10(2); */
- e_tmp = norm_l( sum32 );
- L_tmp = L_shl( sum32, e_tmp );
- f_tmp = Log2_norm_lc( L_tmp );
- e_tmp = sub( sub( 30, e_tmp ), Q_dct );
- L_tmp = Mpy_32_16( e_tmp, f_tmp, 9864 ); /* Q16 */
- spect_bin[i] = round_fx( L_shl( L_tmp, 11 ) ); /* Q11 */
- move16();
+ IF( LE_32( sum32, 1 ) )
+ {
+ /*deal with zero spectrum*/
+ spect_bin[i] = -1;
+ move16();
+ }
+ ELSE
+ {
+ /* spect_bin[i] = (float)log10(spect_bin[i]);
+ = log2(spect_bin[i])*log10(2); */
+ e_tmp = norm_l( sum32 );
+ L_tmp = L_shl( sum32, e_tmp );
+ f_tmp = Log2_norm_lc( L_tmp );
+ e_tmp = sub( sub( 30, e_tmp ), Q_dct );
+ L_tmp = Mpy_32_16( e_tmp, f_tmp, 9864 ); /* Q16 */
+ spect_bin[i] = round_fx( L_shl( L_tmp, 11 ) ); /* Q11 */
+ move16();
+ }
}
}
}
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 100%
rename from lib_enc/cod4t64_fast.c
rename to lib_enc/cod4t64_fast_fx.c
diff --git a/lib_enc/cod_ace_fx.c b/lib_enc/cod_ace_fx.c
index d3725dcba73c1b1a10380ea33ca42f9abc403a74..e1914aeb5bb7b2e51f123b8f0ca042512c174644 100644
--- a/lib_enc/cod_ace_fx.c
+++ b/lib_enc/cod_ace_fx.c
@@ -366,8 +366,9 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision *
IF( st->igf != 0 )
{
- 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 );
+ 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..c40db66789c9f646ee7fb3a82c6ef5e8e6cdc0a5 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()
*
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/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c
index 22af9097ddb2a538140f180f0c87660a2b0d6971..a485a1bf39cca3e3b503ba25c80494a3c8d25231 100644
--- a/lib_enc/enc_gen_voic_fx.c
+++ b/lib_enc/enc_gen_voic_fx.c
@@ -363,13 +363,15 @@ void encod_gen_voic_fx(
exc_fx[i + i_subfr_fx] = round_fx_o( Ltmp, &Overflow ); /* Q0 */
}
}
+
/*-----------------------------------------------------------------*
* Prepare TBE excitation
*-----------------------------------------------------------------*/
- 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 );
+ 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[].
@@ -398,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 */
@@ -518,7 +522,12 @@ void encod_gen_voic_ivas_fx(
set16_fx( code_preQ_fx, 0, L_SUBFR );
shift_wsp = add( Q_new, shift );
-
+#ifdef TEST_HR
+ if ( LT_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) )
+ {
+ shift_wsp = sub( shift_wsp, 1 );
+ }
+#endif
/* set and write harmonicity flag */
harm_flag_acelp = 0;
move16();
@@ -550,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*/
@@ -621,18 +630,33 @@ void encod_gen_voic_ivas_fx(
IF( LE_32( st_fx->core_brate, ACELP_8k00 ) )
{
+#ifdef TEST_HR
+ gain_enc_lbr_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->coder_type, i_subfr_fx, xn_fx, y1_fx, shift_wsp, y2_fx, code_fx,
+ &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, gc_mem, gp_mem, clip_gain_fx, L_SUBFR );
+#else
gain_enc_lbr_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->coder_type, i_subfr_fx, xn_fx, y1_fx, sub( shift_wsp, 1 ), y2_fx, code_fx,
&gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, gc_mem, gp_mem, clip_gain_fx, L_SUBFR );
+#endif
}
ELSE IF( GT_32( st_fx->core_brate, ACELP_32k ) )
{
+#ifdef TEST_HR
+ gain_enc_SQ_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, i_subfr_fx, xn_fx, y1_fx, y2_fx, code_fx, Es_pred_fx,
+ &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, clip_gain_fx, shift_wsp );
+#else
gain_enc_SQ_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, i_subfr_fx, xn_fx, y1_fx, y2_fx, code_fx, Es_pred_fx,
&gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, clip_gain_fx, sub( shift_wsp, 1 ) );
+#endif
}
ELSE
{
+#ifdef TEST_HR
+ gain_enc_mless_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, L_frame, i_subfr_fx, -1, xn_fx, y1_fx, shift_wsp, y2_fx, code_fx, Es_pred_fx,
+ &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, clip_gain_fx );
+#else
gain_enc_mless_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, L_frame, i_subfr_fx, -1, xn_fx, y1_fx, sub( shift_wsp, 1 ), y2_fx, code_fx, Es_pred_fx,
&gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, clip_gain_fx );
+#endif
}
IF( st_fx->Opt_SC_VBR )
{
@@ -736,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..bfdf46ea07a7db5a2b3c6db64020d48167b02455 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*/
diff --git a/lib_enc/enc_tran_fx.c b/lib_enc/enc_tran_fx.c
index d6935dd0ce0cbbf841fc6f7917dba300dfd34f33..9802dc15b82071197c49514f3cfd2167ca4d2698 100644
--- a/lib_enc/enc_tran_fx.c
+++ b/lib_enc/enc_tran_fx.c
@@ -308,8 +308,8 @@ Word16 encod_tran_fx(
* Prepare TBE excitation
*-----------------------------------------------------------------*/
- 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 );
+ 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[].
@@ -520,7 +520,12 @@ Word16 encod_tran_ivas_fx(
move16();
set16_fx( code_preQ, 0, L_SUBFR );
shift_wsp = add( Q_new, shift );
-
+#ifdef TEST_HR
+ if ( LT_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) )
+ {
+ shift_wsp = sub( shift_wsp, 1 );
+ }
+#endif
/*----------------------------------------------------------------*
* ACELP subframe loop
*----------------------------------------------------------------*/
@@ -535,12 +540,17 @@ 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 );
q_h1 = sub( 14, norm_s( h1[0] ) );
Copy_Scale_sig( h1, h2_fx, L_SUBFR, sub( 11, q_h1 ) ); /*Q11*/
+#ifdef TEST_HR
+ Scale_sig( h1, L_SUBFR, sub( 14, q_h1 ) );
+#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 );
@@ -559,7 +569,9 @@ Word16 encod_tran_ivas_fx(
IF( GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) )
{
+#ifndef TEST_HR
Scale_sig( h1, L_SUBFR, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution */
+#endif
transf_cdbk_enc_ivas_fx( st_fx, 0, i_subfr, cn, exc_fx, p_Aq, Aw_fx, h1, xn, xn2, y1, y2, Es_pred_fx,
&gain_pit, gain_code, g_corr, clip_gain, &gain_preQ, code_preQ, unbits, Q_new, shift );
}
@@ -587,22 +599,37 @@ Word16 encod_tran_ivas_fx(
IF( Jopt_flag == 0 )
{
/* SQ gain_code */
+#ifdef TEST_HR
+ gain_enc_tc_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, i_subfr, xn, y2, code, Es_pred_fx,
+ &gain_pit, &gain_code, &gain_inov, &norm_gain_code, shift_wsp );
+#else
gain_enc_tc_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, i_subfr, xn, y2, code, Es_pred_fx,
&gain_pit, &gain_code, &gain_inov, &norm_gain_code, sub( shift_wsp, 1 ) );
+#endif
}
ELSE
{
IF( GT_32( st_fx->core_brate, ACELP_32k ) )
{
/* SQ gain_pit and gain_code */
+#ifdef TEST_HR
+ gain_enc_SQ_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, i_subfr, xn, y1, y2, code, Es_pred_fx,
+ &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, clip_gain, shift_wsp );
+#else
gain_enc_SQ_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, i_subfr, xn, y1, y2, code, Es_pred_fx,
&gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, clip_gain, sub( shift_wsp, 1 ) );
+#endif
}
ELSE
{
/* VQ gain_pit and gain_code */
+#ifdef TEST_HR
+ gain_enc_mless_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, L_frame_fx, i_subfr, tc_subfr, xn, y1, shift_wsp, y2, code, Es_pred_fx,
+ &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, clip_gain );
+#else
gain_enc_mless_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, L_frame_fx, i_subfr, tc_subfr, xn, y1, sub( shift_wsp, 1 ), y2, code, Es_pred_fx,
&gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, clip_gain );
+#endif
}
}
gp_clip_test_gain_pit_fx( st_fx->element_mode, st_fx->core_brate, gain_pit, st_fx->clip_var_fx );
@@ -687,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/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 200e7e8edc410168b73ffd26a52f84ac35c5bfe4..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 );
@@ -1401,7 +1249,7 @@ void core_signal_analysis_high_bitrate_ivas_fx(
IF( st->igf )
{
Word16 q_spectrum = sub( Q31, hTcxEnc->spectrum_e[frameno] );
- ProcessIGF_ivas_fx( st, N_MAX + L_MDCT_OVLP_MAX, hTcxEnc->spectrum_fx[frameno], hTcxEnc->spectrum_fx[frameno], &q_spectrum, powerSpec, powerSpec_e, transform_type[frameno] == TCX_20, frameno, 0, vad_hover_flag );
+ ProcessIGF_ivas_fx( st, N_MAX + L_MDCT_OVLP_MAX, hTcxEnc->spectrum_fx[frameno], &q_spectrum, hTcxEnc->spectrum_fx[frameno], q_spectrum, powerSpec, powerSpec_e, transform_type[frameno] == TCX_20, frameno, 0, vad_hover_flag );
}
}
}
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_tilt_fx.c b/lib_enc/find_tilt_fx.c
index ed8ff425efa6840f334b4f8ad70a35ac646f95a9..dc78719d2b6cbcf57c535a7f86b0fb0e229e00b9 100644
--- a/lib_enc/find_tilt_fx.c
+++ b/lib_enc/find_tilt_fx.c
@@ -329,7 +329,7 @@ void find_tilt_ivas_fx(
{
hp_bckr = L_deposit_l( 1 );
}
- Ltmp = BASOP_Util_Divide3232_Scale_cadence( lp_bckr, hp_bckr, &e_tmp );
+ Ltmp = BASOP_Util_Divide3232_Scale_newton( lp_bckr, hp_bckr, &e_tmp );
Ltmp = Mpy_32_16_r( Ltmp, 3277 /* 0.1f in Q15 */ );
Ltmp = L_shr_sat( Ltmp, sub( 15, e_tmp ) );
*bckr_tilt_lt = L_add_sat( Mpy_32_16_r( *bckr_tilt_lt, 29491 /* 0.9f in Q15 */ ), Ltmp ); // Q16
diff --git a/lib_enc/find_uv_fx.c b/lib_enc/find_uv_fx.c
index 79dc78c6d31dc23cf4e86ffa62c9fbd78f63a9e2..c4fe2e895db461d4cfc4a15ff6aaad577c146168 100644
--- a/lib_enc/find_uv_fx.c
+++ b/lib_enc/find_uv_fx.c
@@ -729,7 +729,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ
* Total frame energy difference (dE3)
*-----------------------------------------------------------------*/
- dE3 = sub( Etot, hNoiseEst->Etot_last_fx ); /*Q8*/
+ dE3 = sub( Etot, extract_h( hNoiseEst->Etot_last_32fx ) ); /*Q8*/
/*-----------------------------------------------------------------*
* Energy decrease after spike (dE2)
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 300e31e8e10c5c4c8183e5a0a31dabc01275a88f..aa2c319f1e9a936c00473a70f6caae499410ee37 100644
--- a/lib_enc/hq_classifier_enc_fx.c
+++ b/lib_enc/hq_classifier_enc_fx.c
@@ -141,9 +141,9 @@ static Word16 hf_spectrum_sparseness_fx(
}
}
Word16 l_shift = W_norm( inv_rms_fx );
- inv_rms32_fx = W_extract_h( W_shl( inv_rms_fx, l_shift ) ); // Q15+l_shift-32
- Word16 q_rms = sub( add( Q15, l_shift ), 32 ); // q_rms
- inv_rms32_div_fx = BASOP_Util_Divide3232_Scale_cadence( inv_rms32_fx, L_SPEC_HB, &inv_rms32_e ); /* Q31-inv_rms32_e */
+ inv_rms32_fx = W_extract_h( W_shl( inv_rms_fx, l_shift ) ); // Q15+l_shift-32
+ Word16 q_rms = sub( add( Q15, l_shift ), 32 ); // q_rms
+ inv_rms32_div_fx = BASOP_Util_Divide3232_Scale_newton( inv_rms32_fx, L_SPEC_HB, &inv_rms32_e ); /* Q31-inv_rms32_e */
inv_rms32_e = sub( 31, add( sub( Q31, inv_rms32_e ), q_rms ) );
// inv_rms = 1.0f / (float) sqrtf( inv_rms / L_SPEC_HB );
inv_rms32_fx = ISqrt32( inv_rms32_div_fx, &inv_rms32_e ); /* Q31-inv_rms32_e */
@@ -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 bfb4a7423ed63994a1b9dc655feb3880858bd88f..18995bd1de3d00953b78877e201c290f9b1c0f7b 100644
--- a/lib_enc/igf_enc.c
+++ b/lib_enc/igf_enc.c
@@ -1002,12 +1002,12 @@ static void IGF_CalculateStereoEnvelope_fx(
const Word32 *pPowerSpectrum_fx, /* i : MDCT^2 + MDST^2 spectrum, or estimate */
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;
@@ -1047,6 +1047,32 @@ static void IGF_CalculateStereoEnvelope_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];
@@ -1130,10 +1156,10 @@ static void IGF_CalculateStereoEnvelope_fx(
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[sub( strt_cpy, tmp )] = temp_pPowerSpectrumMsInv[strt_cpy]; /*resultant exponent is stored in tileSrcSpec_e*/
+ tileSrcSpec_e = sub( 31, q_temp_pPowerSpectrumMsInv );
}
ELSE
{
@@ -1171,13 +1197,13 @@ 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( &sfm_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( &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( &sfm_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( &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*/
@@ -1322,7 +1348,7 @@ 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( &sfm_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( &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 );
}
@@ -1331,7 +1357,7 @@ 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( &sfm_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( &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 );
}
@@ -2620,24 +2646,25 @@ 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 *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;
@@ -2681,6 +2708,8 @@ void IGFEncApplyStereo_fx(
pPowerSpectrumParameter_fx[1] = &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 +2717,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,7 +2727,7 @@ 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 ) )
{
diff --git a/lib_enc/igf_enc_fx.c b/lib_enc/igf_enc_fx.c
index f508b313f61988d03b1f5682a0b01de6d276c3ad..f78ad202578f0f29537006d5e6b7694c97b9fce4 100644
--- a/lib_enc/igf_enc_fx.c
+++ b/lib_enc/igf_enc_fx.c
@@ -895,6 +895,103 @@ Word16 IGF_getSFM( /**< out: Q15| SFM value
return SFM /*Q15*/;
}
+/*************************************************************************
+calculates spectral flatness measurment
+**************************************************************************/
+Word16 IGF_getSFM_ivas_fx( /**< out: Q15| SFM value */
+ Word16 *SFM_exp, /**< out: | exponent of SFM Factor */
+ const Word32 *energy, /**< in: Q31| energies */
+ const Word16 *energy_exp, /**< in: | exponent of energies */
+ const Word16 start, /**< in: Q0 | start subband index */
+ const Word16 stop /**< in: Q0 | stop subband index */
+)
+{
+ Word16 n, i, s;
+ Word32 num;
+ Word32 denom;
+ Word16 denom_exp;
+ Word16 invDenom_exp, numf_exp;
+ Word16 numf;
+ Word32 SFM32;
+ Word16 invDenom, SFM;
+
+ num = 0;
+ move32();
+ denom = 65536; // 1.f in Q16
+ denom_exp = 15;
+ *SFM_exp = 0;
+ move16();
+ SFM = 32767 /*1.0f Q15*/;
+ move16();
+
+ FOR( i = start; i < stop; i++ )
+ {
+ /*ln(x * 2^-Qx * 2^xExp) = ln(x) - Qx + xExp*/
+
+ /* n = sub(sub(31,norm_l(tmp32)),1); */ /*<- ld */
+ /* n = sub(n,31); */ /*<- -Qx */
+ /* n = add(n,*energy_exp); */ /*<- +xExp */
+
+ n = sub( sub( *energy_exp, norm_l( energy[i] ) ), 1 ); /*<-- short form*/
+
+ if ( energy[i] == 0 ) /*special case: energy is zero*/
+ {
+ n = 0;
+ move16();
+ }
+
+ 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 );
+ }
+
+ /* calculate SFM only if signal is present */
+ IF( denom != 0 )
+ {
+ /*numf = (float)num / (float)(stop - start);*/
+ numf = BASOP_Util_Divide3216_Scale( num, /*Q0*/
+ sub( stop, start ), /*Q0*/
+ &s ); /*Q-1 s*/
+ numf_exp = add( s, 16 ); /*-> numf Q15 numf_exp*/
+ /*denom /= (float)(stop - start);*/
+ /*return ((float)pow(2.0, numf + 0.5f) / denom);*/
+
+ /*SFM= ((float)pow(2.0, numf + 0.5f) * invDenom);*/
+ invDenom = BASOP_Util_Divide3232_uu_1616_Scale( L_deposit_l( sub( stop, start ) ) /*Q0*/,
+ denom /*Q31, denom_exp*/,
+ &s ); /*Q-16, s-denom_exp*/
+ invDenom_exp = add( sub( s, denom_exp ), 31 ); /*invDenom: Q15, invDenom_exp*/
+
+ /*add .5f to numf*/
+ SFM32 = L_add( L_shl( L_deposit_l( numf ), numf_exp ) /*16Q15*/, 16384l /*.5f Q15*/ ); /*16Q15*/
+ s = norm_l( SFM32 );
+ SFM32 = L_shl( SFM32, s );
+ s = sub( 16, s ); /*SFM32(numf) is Q31 now*/
+
+ /*do the pow2 and the mult*/
+ SFM32 = BASOP_util_Pow2( SFM32, s, &s );
+ SFM32 = Mpy_32_16_1( SFM32, invDenom );
+ *SFM_exp = add( s, invDenom_exp );
+
+ /*Transform to Q15*/
+ s = norm_l( SFM32 );
+ SFM = round_fx_sat( L_shl_sat( SFM32, s ) );
+ *SFM_exp = sub( *SFM_exp, s );
+ move16();
+ /**SFM_exp = s_min(*SFM_exp, 0);*/
+ IF( *SFM_exp > 0 )
+ {
+ *SFM_exp = 0;
+ move16();
+ SFM = 32767 /*1.0f Q15*/;
+ move16();
+ }
+ }
+
+ return SFM /*Q15*/;
+}
+
/**********************************************************************/ /*
calculates the IGF whitening levels by SFM and crest
**************************************************************************/
diff --git a/lib_enc/init_enc_fx.c b/lib_enc/init_enc_fx.c
index 21a99add798b804e4456ac8834e30ba70f93d65e..f46bcc61cc31b644a1a9b44cddbdce9358d8d8dd 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
{
@@ -749,7 +750,6 @@ ivas_error init_encoder_fx(
* TCX core
*-----------------------------------------------------------------*/
- // VE: reduction possible for MCT_CHAN_MODE_LFE channel - see I1-172
test();
IF( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) )
{
@@ -947,7 +947,7 @@ ivas_error init_encoder_fx(
move32();
return error;
}
-#endif
+
/*-----------------------------------------------------------------------*
* LPDmem_enc_init_fx()
*
@@ -1185,6 +1185,8 @@ ivas_error init_encoder_ivas_fx(
st->mem_preemph_fx = 0;
move16();
+ st->mem_preemph_fx_q_inp = 0;
+ move16();
st->mem_preemph16k_fx = 0;
move16();
st->mem_preemph_enc = 0;
@@ -1192,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();
@@ -1299,6 +1299,8 @@ ivas_error init_encoder_ivas_fx(
/* stereo switching memories */
st->mem_preemph_DFT_fx = 0;
move16();
+ st->mem_preemph_DFT_fx_q_inp = 0;
+ move16();
set16_fx( st->inp_12k8_mem_stereo_sw_fx, 0, sub( sub( STEREO_DFT_OVL_12k8, L_MEM_RECALC_12K8 ), L_FILT ) );
st->mem_preemph16k_DFT_fx = 0;
move16();
@@ -1398,6 +1400,7 @@ ivas_error init_encoder_ivas_fx(
st->q_Bin_E_old = Q31;
move16();
set16_fx( st->mem_decim_fx, 0, shl( L_FILT_MAX, 1 ) );
+ set16_fx( st->mem_decim_fx_q_inp, 0, shl( L_FILT_MAX, 1 ) );
set16_fx( st->mem_decim16k_fx, 0, shl( L_FILT_MAX, 1 ) );
set16_fx( st->old_inp_12k8_fx, 0, L_INP_MEM );
set16_fx( st->old_inp_16k_fx, 0, L_INP_MEM );
@@ -1411,12 +1414,19 @@ ivas_error init_encoder_ivas_fx(
set16_fx( st->input_buff_fx, 0, add( L_FRAME48k, add( L_FRAME48k, NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ) ) );
st->q_inp = Q15;
move16();
+ st->mem_preemph_q = Q15;
+ move16();
+ st->mem_q = Q15;
+ move16();
st->q_old_inp = Q15;
move16();
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 ) );
@@ -1427,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
{
@@ -1446,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
}
/*-----------------------------------------------------------------*
@@ -1948,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..d019bf4747d93ff71f71c6e414e1826c8572237b 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
diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c
index 3c62a0d184820697ae3019b943faf66aba8da570..6fcb8abd0304b5be804584d53549ffe60ac9ade9 100644
--- a/lib_enc/ivas_core_enc_fx.c
+++ b/lib_enc/ivas_core_enc_fx.c
@@ -419,7 +419,6 @@ ivas_error ivas_core_enc_fx(
}
}
-
/*---------------------------------------------------------------------*
* MDCT stereo: joint TCX Core Encoding
*---------------------------------------------------------------------*/
@@ -532,6 +531,12 @@ 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;
+ move16();
+ st->q_old_inp = -1;
+ move16();
}
Word16 Q_spec_old[2], L_spec;
@@ -612,6 +617,8 @@ ivas_error ivas_core_enc_fx(
* Postprocessing, BWEs and Updates
*---------------------------------------------------------------------*/
+ Word16 tmp_input_fx[L_FRAME48k], tmp_old_input_fx[L_FRAME48k], q_inp[2];
+
FOR( n = 0; n < n_CoreChannels; n++ )
{
st = sts[n];
@@ -626,6 +633,17 @@ ivas_error ivas_core_enc_fx(
move16();
}
+ Copy( st->input_fx - input_frame, tmp_old_input_fx, input_frame );
+ Copy( st->input_fx, tmp_input_fx, input_frame );
+ q_inp[0] = st->q_old_inp;
+ q_inp[1] = st->q_inp;
+
+ Scale_sig( st->input_fx - input_frame, 2 * input_frame, sub( -1, st->q_inp ) );
+ st->q_inp = -1;
+ move16();
+ st->q_old_inp = -1;
+ move16();
+
/*---------------------------------------------------------------------*
* Postprocessing for ACELP/HQ core switching
*---------------------------------------------------------------------*/
@@ -657,12 +675,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
@@ -707,8 +719,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();
@@ -726,17 +736,15 @@ ivas_error ivas_core_enc_fx(
IF( EQ_16( st->extl, FB_TBE ) )
{
/* FB TBE encoder */
- fb_tbe_enc_ivas_fx( st, st->input_fx, fb_exc_fx, Q_fb_exc );
+ fb_tbe_enc_ivas_fx( st, st->input_fx, fb_exc_fx, Q_fb_exc, st->q_inp );
}
}
}
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
@@ -758,6 +766,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 )
@@ -766,7 +777,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] );
@@ -787,6 +798,13 @@ ivas_error ivas_core_enc_fx(
}
}
+ Copy( tmp_old_input_fx, st->input_fx - input_frame, input_frame );
+ Copy( tmp_input_fx, st->input_fx, input_frame );
+ st->q_old_inp = q_inp[0];
+ move16();
+ st->q_inp = q_inp[1];
+ move16();
+
/*---------------------------------------------------------------------*
* Channel-aware mode - write signaling information into the bitstream
*---------------------------------------------------------------------*/
diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c
index 0d6a5901a1f81f12be0f48ff345d024303d55ca7..be208296dfa5d792ae08b9d2aa1a4f5fa1963597 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()
*
@@ -205,7 +201,7 @@ ivas_error pre_proc_front_ivas_fx(
Word16 S_map_fx[L_FFT / 2];
Word16 cor_map_sum_LR_fx[CPE_CHANNELS]; /* speech/music clasif. parameter */
Word16 S_map_LR_fx[L_FFT / 2]; /* short-term correlation map */
- Word16 Etot_fx; /* total energy Q8 */
+ Word32 Etot_fx; /* total energy Q8 */
Word32 tmpN_fx[NB_BANDS]; /* Temporary noise update */
Word32 tmpE_fx[NB_BANDS]; /* Temporary averaged energy of 2 sf. */
Word32 tmpN_LR_fx[CPE_CHANNELS][NB_BANDS]; /* Temporary noise update */
@@ -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;
@@ -499,15 +496,16 @@ ivas_error pre_proc_front_ivas_fx(
* Change the sampling frequency to 12.8 kHz
* (if not available from downsampled DMX)
*----------------------------------------------------------------*/
-
- Scale_sig( st->mem_decim_fx, 2 * L_FILT_MAX, sub( st->q_inp, Q_inp_const ) ); /* st->q_inp */
+ Scale_sig( st->mem_decim_fx_q_inp, 2 * L_FILT_MAX, sub( st->q_inp, st->mem_q ) ); /* st->q_inp */
test();
+
IF( EQ_16( element_mode, IVAS_SCE ) )
{
- new_inp_out_size = modify_Fs_ivas_fx( signal_in_fx, input_frame, input_Fs, new_inp_12k8_fx, INT_FS_12k8, st->mem_decim_fx, ( st->max_bwidth == NB ), &Q_new_inp, &mem_decim_size ); /* st->q_inp */
- Scale_sig( new_inp_12k8_fx, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to st->q_inp*/
-
- Copy( st->mem_decim_fx, mem_decim_dummy_fx, 2 * L_FILT_MAX ); /* Q(-1) */
+ new_inp_out_size = modify_Fs_ivas_fx( signal_in_fx, input_frame, input_Fs, new_inp_12k8_fx, INT_FS_12k8, st->mem_decim_fx_q_inp, ( st->max_bwidth == NB ), &Q_new_inp, &mem_decim_size ); /* st->q_inp */
+ Scale_sig( new_inp_12k8_fx, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to st->q_inp*/
+ st->mem_q = st->q_inp;
+ move16();
+ Copy( st->mem_decim_fx_q_inp, mem_decim_dummy_fx, 2 * L_FILT_MAX ); /* Q(-1) */
set16_fx( temp1F_icatdmResampBuf_fx, 0, L_FILT_MAX );
new_inp_out_size = modify_Fs_ivas_fx( temp1F_icatdmResampBuf_fx, NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS ), input_Fs, new_inp_12k8_fx + L_FRAME, INT_FS_12k8, mem_decim_dummy_fx, 0, &Q_new_inp, &mem_decim_size ); /* st->q_inp */
Scale_sig( new_inp_12k8_fx + L_FRAME, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to st->q_inp*/
@@ -521,13 +519,15 @@ ivas_error pre_proc_front_ivas_fx(
Word16 length_inp = NS2SA_FX2( input_Fs, L_MEM_RECALC_SCH_NS );
Word16 length_12k8 = NS2SA( INT_FS_12k8, L_MEM_RECALC_SCH_NS );
- new_inp_out_size = modify_Fs_ivas_fx( signal_in_fx - lMemRecalc - length_inp, length_inp, input_Fs, new_inp_12k8_fx - lMemRecalc_12k8 - length_12k8, INT_FS_12k8, st->mem_decim_fx, 0, &Q_new_inp, &mem_decim_size ); /* st->q_inp */
- Scale_sig( new_inp_12k8_fx - lMemRecalc_12k8 - length_12k8, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to st->q_inp*/
+ new_inp_out_size = modify_Fs_ivas_fx( signal_in_fx - lMemRecalc - length_inp, length_inp, input_Fs, new_inp_12k8_fx - lMemRecalc_12k8 - length_12k8, INT_FS_12k8, st->mem_decim_fx_q_inp, 0, &Q_new_inp, &mem_decim_size ); /* st->q_inp */
+ Scale_sig( new_inp_12k8_fx - lMemRecalc_12k8 - length_12k8, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to st->q_inp*/
}
- new_inp_out_size = modify_Fs_ivas_fx( signal_in_fx - lMemRecalc, input_frame, input_Fs, new_inp_12k8_fx - lMemRecalc_12k8, INT_FS_12k8, st->mem_decim_fx, ( st->max_bwidth == NB ), &Q_new_inp, &mem_decim_size ); /* st->q_inp */
- Copy( st->mem_decim_fx, mem_decim_dummy_fx, 2 * L_FILT_MAX ); /* st->q_inp */
- Scale_sig( new_inp_12k8_fx - lMemRecalc_12k8, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to st->q_inp*/
+ new_inp_out_size = modify_Fs_ivas_fx( signal_in_fx - lMemRecalc, input_frame, input_Fs, new_inp_12k8_fx - lMemRecalc_12k8, INT_FS_12k8, st->mem_decim_fx_q_inp, ( st->max_bwidth == NB ), &Q_new_inp, &mem_decim_size ); /* st->q_inp */
+ st->mem_q = st->q_inp;
+ move16();
+ Copy( st->mem_decim_fx_q_inp, mem_decim_dummy_fx, 2 * L_FILT_MAX ); /* st->q_inp */
+ Scale_sig( new_inp_12k8_fx - lMemRecalc_12k8, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to st->q_inp*/
IF( lMemRecalc > 0 )
{
@@ -541,10 +541,13 @@ ivas_error pre_proc_front_ivas_fx(
ELSE /* DFT stereo */
{
/* update the FIR resampling filter memory, needed for switching to time-domain (FIR) resampling */
- Copy( signal_in_fx + sub( input_frame, add( NS2SA_FX2( input_Fs, L_MEM_RECALC_NS ), 2 * NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS ) ) ), st->mem_decim_fx, 2 * NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS ) ); /* st->q_inp */
+ Copy( signal_in_fx + sub( input_frame, add( NS2SA_FX2( input_Fs, L_MEM_RECALC_NS ), 2 * NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS ) ) ), st->mem_decim_fx_q_inp, 2 * NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS ) ); /* st->q_inp */
+ st->mem_q = st->q_inp;
+ move16();
scale_sig( old_inp_12k8_fx, L_INP_MEM - STEREO_DFT_OVL_12k8, sub( Q_inp_const, st->q_inp ) );
scale_sig( st->input_fx - input_frame, input_frame_full, sub( Q_inp_const, st->q_inp ) );
- Scale_sig( st->mem_decim_fx, 2 * L_FILT_MAX, sub( Q_inp_const, st->q_inp ) ); /* Q(-1) */
+ Copy_Scale_sig( st->mem_decim_fx_q_inp, st->mem_decim_fx, 2 * L_FILT_MAX, sub( Q_inp_const, st->q_inp ) ); /* Q(-1) */
+ // Scale_sig( st->mem_decim_fx, 2 * L_FILT_MAX, sub( Q_inp_const, st->q_inp ) ); /* Q(-1) */
st->q_inp = Q_inp_const;
move16();
st->q_old_inp = Q_inp_const;
@@ -552,7 +555,7 @@ ivas_error pre_proc_front_ivas_fx(
}
IF( NE_16( Q_inp_const, st->q_inp ) )
{
- Scale_sig( st->mem_decim_fx, 2 * L_FILT_MAX, sub( Q_inp_const, st->q_inp ) ); /* Q(-1) */
+ Copy_Scale_sig( st->mem_decim_fx_q_inp, st->mem_decim_fx, 2 * L_FILT_MAX, sub( Q_inp_const, st->q_inp ) ); /* Q(-1) */
}
Scale_sig( st->buf_speech_enc, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, sub( -1, sub( 15, st->exp_buf_speech_enc ) ) ); /* Q(-1) */
@@ -585,24 +588,23 @@ ivas_error pre_proc_front_ivas_fx(
headroom = 2;
move16();
-
- st->mem_preemph_fx = shl_sat( st->mem_preemph_fx, sub( st->q_inp, -1 ) ); /*st->q_inp*/
+ st->mem_preemph_fx_q_inp = shl_sat( st->mem_preemph_fx_q_inp, sub( st->q_inp, st->mem_preemph_q ) ); /*st->q_inp*/
move16();
- st->mem_preemph_DFT_fx = shl_sat( st->mem_preemph_DFT_fx, sub( st->q_inp, -1 ) ); /*st->q_inp*/
+ st->mem_preemph_DFT_fx_q_inp = shl_sat( st->mem_preemph_DFT_fx_q_inp, sub( st->q_inp, st->mem_preemph_q ) ); /*st->q_inp*/
move16();
test();
IF( EQ_16( element_mode, IVAS_CPE_DFT ) )
{
Copy_Scale_sig( new_inp_12k8_fx - STEREO_DFT_OVL_12k8 + L_FRAME, st->inp_12k8_mem_stereo_sw_fx, STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT, sub( Q_inp_const, st->q_inp ) ); /* memory for TD/DFT stereo switching Q_inp_const*/
- st->mem_preemph_fx = st->mem_preemph_DFT_fx; /* st->q_inp */
+ st->mem_preemph_fx_q_inp = st->mem_preemph_DFT_fx_q_inp; /* st->q_inp */
move16();
- st->mem_preemph_DFT_fx = old_inp_12k8_fx[L_INP_MEM - STEREO_DFT_OVL_12k8 + L_FRAME - 1]; /* st->q_inp */
+ st->mem_preemph_DFT_fx_q_inp = old_inp_12k8_fx[L_INP_MEM - STEREO_DFT_OVL_12k8 + L_FRAME - 1]; /* st->q_inp */
move16();
// PREEMPH_FX( new_inp_12k8_fx - STEREO_DFT_OVL_12k8, PREEMPH_FAC, L_FRAME, &st->mem_preemph_fx );
- PREEMPH_32FX( new_inp_12k8_fx - STEREO_DFT_OVL_12k8, sig_out, PREEMPH_FAC, L_FRAME, &st->mem_preemph_fx );
- dummy_fx = st->mem_preemph_fx;
+ PREEMPH_32FX( new_inp_12k8_fx - STEREO_DFT_OVL_12k8, sig_out, PREEMPH_FAC, L_FRAME, &st->mem_preemph_fx_q_inp );
+ dummy_fx = st->mem_preemph_fx_q_inp;
move16();
// PREEMPH_FX( new_inp_12k8_fx - STEREO_DFT_OVL_12k8 + L_FRAME, PREEMPH_FAC, STEREO_DFT_OVL_12k8, &dummy_fx );
@@ -618,18 +620,18 @@ ivas_error pre_proc_front_ivas_fx(
{
IF( EQ_16( hCPE->last_element_mode, IVAS_CPE_DFT ) )
{
- st->mem_preemph_fx = st->mem_preemph_DFT_fx; /* st->q_inp */
+ st->mem_preemph_fx_q_inp = st->mem_preemph_DFT_fx_q_inp; /* st->q_inp */
move16();
Copy_Scale_sig( st->inp_12k8_mem_stereo_sw_fx, new_inp_12k8_fx - L_MEM_RECALC_12K8 - ( STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT ), STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT, sub( st->q_inp, Q_inp_const ) ); /* st->q_inp */
// PREEMPH_FX( new_inp_12k8_fx - L_MEM_RECALC_12K8 - ( STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT ), PREEMPH_FAC, STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT, &st->mem_preemph_fx );
- PREEMPH_32FX( new_inp_12k8_fx - L_MEM_RECALC_12K8 - ( STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT ), sig_out, PREEMPH_FAC, STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT, &st->mem_preemph_fx );
+ PREEMPH_32FX( new_inp_12k8_fx - L_MEM_RECALC_12K8 - ( STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT ), sig_out, PREEMPH_FAC, STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT, &st->mem_preemph_fx_q_inp );
preemp_start_idx = new_inp_12k8_fx - L_MEM_RECALC_12K8 - ( STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT );
move16();
preemp_len = STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT;
move16();
}
- st->mem_preemph_DFT_fx = old_inp_12k8_fx[L_INP_MEM - STEREO_DFT_OVL_12k8 + L_FRAME - 1]; /* st->q_inp */
+ st->mem_preemph_DFT_fx_q_inp = old_inp_12k8_fx[L_INP_MEM - STEREO_DFT_OVL_12k8 + L_FRAME - 1]; /* st->q_inp */
move16();
}
@@ -640,15 +642,15 @@ ivas_error pre_proc_front_ivas_fx(
Word16 length_12k8 = NS2SA( INT_FS_12k8, L_MEM_RECALC_SCH_NS );
move16();
// PREEMPH_FX( new_inp_12k8_fx - lMemRecalc_12k8 - length_12k8, PREEMPH_FAC, length_12k8, &st->mem_preemph_fx );
- PREEMPH_32FX( new_inp_12k8_fx - lMemRecalc_12k8 - length_12k8, sig_out, PREEMPH_FAC, length_12k8, &st->mem_preemph_fx );
+ PREEMPH_32FX( new_inp_12k8_fx - lMemRecalc_12k8 - length_12k8, sig_out, PREEMPH_FAC, length_12k8, &st->mem_preemph_fx_q_inp );
preemp_start_idx = new_inp_12k8_fx - lMemRecalc_12k8 - length_12k8;
preemp_len = length_12k8;
move16();
}
// PREEMPH_FX( new_inp_12k8_fx - lMemRecalc_12k8, PREEMPH_FAC, L_FRAME, &st->mem_preemph_fx );
- PREEMPH_32FX( new_inp_12k8_fx - lMemRecalc_12k8, sig_out + preemp_len, PREEMPH_FAC, L_FRAME, &st->mem_preemph_fx );
- dummy_fx = st->mem_preemph_fx; /* st->q_inp */
+ PREEMPH_32FX( new_inp_12k8_fx - lMemRecalc_12k8, sig_out + preemp_len, PREEMPH_FAC, L_FRAME, &st->mem_preemph_fx_q_inp );
+ dummy_fx = st->mem_preemph_fx_q_inp; /* st->q_inp */
move16();
// PREEMPH_FX( new_inp_12k8_fx - lMemRecalc_12k8 + L_FRAME, PREEMPH_FAC, lMemRecalc_12k8 + L_FILT, &dummy_fx );
PREEMPH_32FX( new_inp_12k8_fx - lMemRecalc_12k8 + L_FRAME, sig_out + preemp_len + L_FRAME, PREEMPH_FAC, lMemRecalc_12k8 + L_FILT, &dummy_fx );
@@ -669,8 +671,8 @@ ivas_error pre_proc_front_ivas_fx(
ELSE /* IVAS_SCE or IVAS_CPE_MDCT */
{
// PREEMPH_FX( new_inp_12k8_fx, PREEMPH_FAC, L_FRAME, &st->mem_preemph_fx );
- PREEMPH_32FX( new_inp_12k8_fx, sig_out, PREEMPH_FAC, L_FRAME, &st->mem_preemph_fx );
- dummy_fx = st->mem_preemph_fx;
+ PREEMPH_32FX( new_inp_12k8_fx, sig_out, PREEMPH_FAC, L_FRAME, &st->mem_preemph_fx_q_inp );
+ dummy_fx = st->mem_preemph_fx_q_inp;
move16();
// PREEMPH_FX( new_inp_12k8_fx + L_FRAME, PREEMPH_FAC, L_FILT, &dummy_fx );
PREEMPH_32FX( new_inp_12k8_fx + L_FRAME, sig_out + L_FRAME, PREEMPH_FAC, L_FILT, &dummy_fx );
@@ -678,11 +680,12 @@ ivas_error pre_proc_front_ivas_fx(
preemp_len = L_FRAME + L_FILT;
move16();
}
- st->mem_preemph_fx = shl_sat( st->mem_preemph_fx, sub( -1, st->q_inp ) ); /*Q(-1) saturation added as float value goes above 65536 for +10 dB test (ltv48_MC512.wav and ltv48_MC51.wav) */
+ 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, sub( -1, st->q_inp ) ); /*Q(-1)*/
+ st->mem_preemph_DFT_fx = shl( st->mem_preemph_DFT_fx_q_inp, sub( -1, st->q_inp ) ); /*Q(-1)*/
+ move16();
+ st->mem_preemph_q = st->q_inp;
move16();
-
maximum_abs_32_fx( sig_out, preemp_len, &max_32 );
inp_max = s_max( extract_h( max_32 ), 1 );
@@ -739,7 +742,7 @@ ivas_error pre_proc_front_ivas_fx(
IF( hStereoClassif != NULL )
{
- IF( GT_32( sub( st->lp_speech_fx, Etot_fx ), 25 << Q8 ) ) /*Q8*/
+ IF( GT_32( sub( st->lp_speech_fx, extract_h( Etot_fx ) ), 25 << Q8 ) ) /*Q8*/
{
hStereoClassif->silence_flag = 2;
move16();
@@ -759,11 +762,11 @@ ivas_error pre_proc_front_ivas_fx(
IF( hCPE != NULL )
{
- noise_est_pre_32fx( L_deposit_h( Etot_fx ), st->ini_frame, st->hNoiseEst, st->idchan, element_mode, hCPE->last_element_mode );
+ noise_est_pre_32fx( ( Etot_fx ), st->ini_frame, st->hNoiseEst, st->idchan, element_mode, hCPE->last_element_mode );
}
ELSE
{
- noise_est_pre_32fx( L_deposit_h( Etot_fx ), st->ini_frame, st->hNoiseEst, st->idchan, element_mode, element_mode );
+ noise_est_pre_32fx( ( Etot_fx ), st->ini_frame, st->hNoiseEst, st->idchan, element_mode, element_mode );
}
test();
@@ -775,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' )
{
@@ -913,18 +904,18 @@ 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_fx, &st->hNoiseEst->Etot_v_h2_fx );
+ &st->hNoiseEst->totalNoise_fx, 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, Etot_LR_fx[0], &hCPE->hFrontVad[0]->hNoiseEst->Etot_last_fx, &hCPE->hFrontVad[0]->hNoiseEst->Etot_v_h2_fx );
- noise_est_down_ivas_fx( fr_bands_LR_fx[1], fr_bands_LR_fx_q[1], hCPE->hFrontVad[1]->hNoiseEst->bckr_fx, &hCPE->hFrontVad[1]->hNoiseEst->q_bckr, tmpN_LR_fx[1], &q_tmpN_LR[1], tmpE_LR_fx[1], &q_tmpE_LR[1], st->min_band, st->max_band, &hCPE->hFrontVad[1]->hNoiseEst->totalNoise_fx, Etot_LR_fx[1], &hCPE->hFrontVad[1]->hNoiseEst->Etot_last_fx, &hCPE->hFrontVad[1]->hNoiseEst->Etot_v_h2_fx );
+ 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_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_fx, 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
}
- *relE_fx = sub( Etot_fx, st->lp_speech_fx ); // Q8
+ *relE_fx = sub( extract_h( Etot_fx ), st->lp_speech_fx ); // Q8
move16();
corr_shift_fx = correlation_shift_fx( st->hNoiseEst->totalNoise_fx ); /* Q15 */
@@ -939,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 )
+ norm = L_norm_arr( st->hFdCngEnc->hFdCngCom->periodog, PERIODOGLEN );
+ IF( NE_16( norm, Q31 ) )
{
- 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 )
- {
- 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 );
}
@@ -1150,8 +1104,7 @@ ivas_error pre_proc_front_ivas_fx(
move16();
}
- 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 );
+ 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++ )
{
@@ -1276,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 ) );
@@ -1303,9 +1256,9 @@ ivas_error pre_proc_front_ivas_fx(
move16();
move16();
- noise_est_ivas_fx( st, old_pitch1, tmpN_fx, epsP_fx, Etot_fx, *relE_fx, corr_shift_fx, tmpE_fx, q_tmpE, fr_bands_fx, fr_bands_fx_q, cor_map_sum_fx,
- &ncharX_fx, &sp_div_fx, &q_sp_div, &non_staX_fx, loc_harm, lf_E_fx, q_lf_E_fx, &st->hNoiseEst->harm_cor_cnt, st->hNoiseEst->Etot_l_lp_fx,
- st->hNoiseEst->Etot_v_h2_fx, &st->hNoiseEst->bg_cnt, st->lgBin_E_fx, &dummy_fx, S_map_fx,
+ 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 ),
+ extract_h( 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();
@@ -1348,14 +1301,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,
- hCPE->hFrontVad[0]->hNoiseEst->Etot_l_lp_fx, hCPE->hFrontVad[0]->hNoiseEst->Etot_v_h2_fx, &hCPE->hFrontVad[0]->hNoiseEst->bg_cnt,
+ extract_h( hCPE->hFrontVad[0]->hNoiseEst->Etot_l_lp_32fx ), extract_h( 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,
- hCPE->hFrontVad[1]->hNoiseEst->Etot_l_lp_fx, hCPE->hFrontVad[1]->hNoiseEst->Etot_v_h2_fx, &hCPE->hFrontVad[1]->hNoiseEst->bg_cnt,
+ extract_h( hCPE->hFrontVad[1]->hNoiseEst->Etot_l_lp_32fx ), extract_h( 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 );
}
@@ -1373,17 +1326,17 @@ 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, Etot_fx, hp_E_fx,
+ st->coder_type = find_uv_ivas_fx( st, pitch_fr_fx, voicing_fr_fx, inp_12k8_fx, ee_fx, &dE1X_fx, corr_shift_fx, *relE_fx, extract_h( Etot_fx ), hp_E_fx,
&flag_spitch, last_core_orig, hStereoClassif, *Q_new /*q_inp_12k8*/, fr_bands_fx_q ); // Q0
Copy_Scale_sig_16_32_no_sat( st->lgBin_E_fx, st->Bin_E_fx, L_FFT / 2, sub( st->q_Bin_E, Q7 ) );
@@ -1415,7 +1368,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 );
@@ -1457,7 +1410,7 @@ ivas_error pre_proc_front_ivas_fx(
scale_sig32( PS_fx, 128, shift );
Qfact_PS = add( Qfact_PS, shift );
- smc_dec = ivas_smc_gmm_fx( st, hStereoClassif, localVAD_HE_SAD, Etot_fx, lsp_new_fx, *cor_map_sum_fx /*Q8*/, epsP_fx, PS_fx, non_staX_fx, *relE_fx, &high_lpn_flag, flag_spitch, Qfact_PS, *epsP_fx_q, hSpMusClas->past_PS_Q ); /* Q0 */
+ smc_dec = ivas_smc_gmm_fx( st, hStereoClassif, localVAD_HE_SAD, extract_h( Etot_fx ), lsp_new_fx, *cor_map_sum_fx /*Q8*/, epsP_fx, PS_fx, non_staX_fx, *relE_fx, &high_lpn_flag, flag_spitch, Qfact_PS, *epsP_fx_q, hSpMusClas->past_PS_Q ); /* Q0 */
#ifdef DEBUG_FORCE_DIR
if ( st->force_dir[0] != '\0' )
@@ -1491,7 +1444,7 @@ ivas_error pre_proc_front_ivas_fx(
* Update of old per-band energy spectrum
*----------------------------------------------------------------*/
- ivas_long_enr_fx( st, Etot_fx, localVAD_HE_SAD, high_lpn_flag, NULL, 1, NULL, NULL );
+ ivas_long_enr_fx( st, extract_h( 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;
@@ -1500,7 +1453,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, -256 /*-1 q8*/, 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];
@@ -1575,12 +1528,6 @@ ivas_error pre_proc_front_ivas_fx(
move16();
IF( flag_16k_smc )
{
- Scale_sig( st->input_fx - input_frame, input_frame_full, sub( -1, st->q_inp ) ); /* Q(-1) */
- st->q_inp = -1;
- move16();
- st->q_old_inp = -1;
- move16();
-
Word16 Q_old_inp_16k = -1;
move16();
@@ -1678,7 +1625,7 @@ ivas_error pre_proc_front_ivas_fx(
st->q_Bin_E = add( *Q_new, Q_SCALE - 2 );
move16();
/* 2nd stage speech/music classification (ACELP/GSC/TCX core selection) */
- ivas_smc_mode_selection_fx( st, element_brate, smc_dec, *relE_fx, Etot_fx, attack_flag, inp_12k8_fx, *Q_new, S_map_fx, flag_spitch );
+ ivas_smc_mode_selection_fx( st, element_brate, smc_dec, *relE_fx, extract_h( Etot_fx ), attack_flag, inp_12k8_fx, *Q_new, S_map_fx, flag_spitch );
}
#ifdef DEBUG_FORCE_DIR
@@ -1718,13 +1665,6 @@ ivas_error pre_proc_front_ivas_fx(
st->exp_old_inp_12k8 = sub( Q15, add( *Q_new, shift ) );
move16();
- Scale_sig( st->input_fx - input_frame, input_frame_full, sub( -1, st->q_inp ) );
- st->q_inp = -1;
- move16();
- st->q_old_inp = -1;
- move16();
-
- // Scale_sig( old_inp_12k8_fx, L_INP_12k8, negate( add( *Q_new, 1 ) ) );
*Q_new = sub( *Q_new, Q_inp_const ); // ivas_core_enc will assume inp signal (12k8 and 16k) in Q_new - 1
move16();
@@ -1735,69 +1675,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 781d290aca75f4549ce757d98faad2c652464777..938ab9964f486fa5d721c01f325c3b217d1617c2 100644
--- a/lib_enc/ivas_core_pre_proc_fx.c
+++ b/lib_enc/ivas_core_pre_proc_fx.c
@@ -565,9 +565,6 @@ ivas_error pre_proc_ivas_fx(
Scale_sig( st->buf_speech_enc_pe, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, sub( Q_old_inp_16k, sub( Q15, st->exp_buf_speech_enc_pe ) ) ); /* Q15 - Q_old_inp_16k */
st->exp_buf_speech_enc_pe = sub( Q15, Q_old_inp_16k );
move16();
- Scale_sig( st->input_fx, input_frame, sub( -1, st->q_inp ) );
- st->q_inp = -1;
- move16();
Scale_sig( st->buf_wspeech_enc, L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320, sub( Q_old_inp_16k, sub( Q15, st->exp_buf_wspeech_enc ) ) ); /* Q15 - Q_old_inp_16k */
st->mem_wsp_enc = shl( st->mem_wsp_enc, sub( Q_old_inp_16k, sub( Q15, st->exp_buf_wspeech_enc ) ) ); // Q_old_inp_16k
move16();
@@ -713,7 +710,7 @@ ivas_error ivas_compute_core_buffers_fx(
Word16 *inp_16k_fx, *new_inp_16k_fx;
Word16 delay, element_mode;
Word16 temp1F_icatdmResampBuf_fx[L_FILT_MAX]; /* temp buffers for ICA TDM resamplers */
- Word16 mem_decim16k_dummy_fx[2 * L_FILT_MAX];
+ Word16 mem_decim16k_dummy_fx[2 * L_FILT_MAX], input_buf_fx[L_FRAME48k * 2];
Word16 *signal_in_fx;
Word16 lMemRecalc, lMemRecalc_16k, L_frame_tmp, L_look;
Word32 input_Fs;
@@ -733,7 +730,12 @@ ivas_error ivas_compute_core_buffers_fx(
set16_fx( new_inp_resamp16k_fx, 0, L_FRAME16k );
set16_fx( epsP_h, 0, M + 1 );
set16_fx( epsP_l, 0, M + 1 );
- signal_in_fx = st->input_fx; /* st->q_inp */
+ set16_fx( input_buf_fx, 0, L_FRAME48k * 2 );
+
+ Copy_Scale_sig( st->input_fx - input_frame, input_buf_fx, input_frame, sub( -1, st->q_old_inp ) );
+ Copy_Scale_sig( st->input_fx, input_buf_fx + input_frame, input_frame, sub( -1, st->q_inp ) );
+
+ signal_in_fx = &input_buf_fx[input_frame]; /* st->q_inp */
input_Fs = st->input_Fs; /* Q0 */
move32();
@@ -884,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 ) )
@@ -896,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 )
@@ -1132,11 +1140,11 @@ ivas_error ivas_compute_core_buffers_fx(
IF( Q_new )
{
- 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 );
+ 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
{
- 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 );
+ 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 );
}
/*--------------------------------------------------------------*
@@ -1163,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 849c7d7d52a30e9acc4598691069e3b5d8e6087d..fe247dbce68326df036046b9a9063462142a067d 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,58 +386,49 @@ 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 );
- shift = s_min( 0, sub( add( L_norm_arr( sts[0]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ), sts[0]->q_inp32 ), 16 ) );
+ shift = sub( add( L_norm_arr( sts[0]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ), sts[0]->q_inp32 ), 16 );
shift = s_min( shift, sub( add( L_norm_arr( sts[1]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ), sts[1]->q_inp32 ), 16 ) );
Copy_Scale_sig32_16( sts[0]->input_buff32_fx, sts[0]->input_buff_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), sub( add( Q16, shift ), sts[0]->q_inp32 ) ); // shift
Copy_Scale_sig32_16( sts[1]->input_buff32_fx, sts[1]->input_buff_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), sub( add( Q16, shift ), sts[1]->q_inp32 ) ); // shift
@@ -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] )
{
@@ -654,7 +653,7 @@ ivas_error ivas_cpe_enc_fx(
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]->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 ) )
@@ -667,7 +666,7 @@ ivas_error ivas_cpe_enc_fx(
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();
@@ -735,8 +734,8 @@ ivas_error ivas_cpe_enc_fx(
move16();
}
- Etot_last_fx[0] = sts[0]->hNoiseEst->Etot_last_fx; /* Q8 */
- Etot_last_fx[1] = sts[1]->hNoiseEst->Etot_last_fx; /* Q8 */
+ Etot_last_fx[0] = extract_h( sts[0]->hNoiseEst->Etot_last_32fx ); /* Q8 */
+ Etot_last_fx[1] = extract_h( sts[1]->hNoiseEst->Etot_last_32fx ); /* Q8 */
move16();
move16();
}
@@ -751,29 +750,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 +784,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 +814,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 +845,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();
@@ -1228,12 +1227,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 ) )
@@ -1241,7 +1240,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() */
{
@@ -1251,7 +1252,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_enc_cov_handler_fx.c b/lib_enc/ivas_enc_cov_handler_fx.c
index c05d59b9086289658e59e23ebab2248e3d9118f0..59c38aa5d75c5083b99a50ab60a4122fcdfd61b6 100644
--- a/lib_enc/ivas_enc_cov_handler_fx.c
+++ b/lib_enc/ivas_enc_cov_handler_fx.c
@@ -271,7 +271,7 @@ static Word16 ivas_spar_get_activeW_flag_fx(
}
ELSE
{
- L_tmp = BASOP_Util_Divide3232_Scale_cadence( hCovEnc->bb_var_lt_fx[0], side_ch_var, &exp_diff ); // (Q31 - exp_diff)
+ L_tmp = BASOP_Util_Divide3232_Scale_newton( hCovEnc->bb_var_lt_fx[0], side_ch_var, &exp_diff ); // (Q31 - exp_diff)
en_ratio = L_shl_sat( L_tmp, exp_diff ); // Q31
IF( LT_32( en_ratio, Mpy_32_32( IVAS_SPAR_DYN_ACTIVEW_THRESH_FX, IVAS_SPAR_DYN_ACTIVEW_THRESH_FX ) ) ) // LHS Q31 :: RHS Q31
{
diff --git a/lib_enc/ivas_front_vad_fx.c b/lib_enc/ivas_front_vad_fx.c
index b21a669528e03c94edff804b63e61db3c529f835..a4baf6a00f4d5645c9fe1e60954096d4b9137a3c 100644
--- a/lib_enc/ivas_front_vad_fx.c
+++ b/lib_enc/ivas_front_vad_fx.c
@@ -90,6 +90,7 @@ ivas_error front_vad_fx(
ivas_error error;
Word16 Q_new;
Word16 Qband, mem_decim_size;
+ Word32 Etot_LR_32fx;
error = IVAS_ERR_OK;
push_wmops( "front_vad" );
move16();
@@ -240,15 +241,15 @@ 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();
ivas_analy_sp_fx( IVAS_CPE_TD, hCPE, sts[0]->input_Fs, hFrontVad->buffer_12k8_fx + L_FFT / 2 - 3 * ( L_SUBFR / 2 ), Q_new, fr_bands_fx[n],
- &q_fr_bands[n], lf_E_fx[n], &q_lf_E[n], &Etot_LR_fx[n], sts[0]->min_band, sts[0]->max_band, Bin_E_fx, &q_Bin_E, Bin_E_old_fx,
+ &q_fr_bands[n], lf_E_fx[n], &q_lf_E[n], &Etot_LR_32fx, sts[0]->min_band, sts[0]->max_band, Bin_E_fx, &q_Bin_E, Bin_E_old_fx,
&q_Bin_E_old, PS_fx, q_PS_out, lgBin_E_fx, band_energies_fx, &q_band_energies, fft_buffLR_fx, &q_fft_buffLR );
if ( n == 0 )
{
@@ -275,21 +276,12 @@ ivas_error front_vad_fx(
/* add up energies for later calculating average of channel energies */
- Word32 Etot_fx = L_deposit_h( Etot_LR_fx[n] ); /* Q24 */
+ noise_est_pre_32fx( Etot_LR_32fx, hFrontVads[0]->ini_frame, hFrontVad->hNoiseEst, 0, 0, 0 );
- noise_est_pre_32fx( Etot_fx, hFrontVads[0]->ini_frame, hFrontVad->hNoiseEst, 0, 0, 0 );
-
- /* 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;
+ Etot_LR_fx[n] = extract_h( Etot_LR_32fx );
move16();
+ /* wb_vad */
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
@@ -611,7 +603,7 @@ 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_fx, &hFrontVad->hNoiseEst->Etot_v_h2_fx );
+ &hFrontVad->hNoiseEst->totalNoise_fx, 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 */
@@ -637,7 +629,8 @@ ivas_error front_vad_spar_fx(
hFrontVad->q_buffer_12k8 = Q_inp_12k8;
move16();
- 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 );
+ 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++ )
{
epsP_fx[i] = L_Comp( epsP_h[i], epsP_l[i] ); // Q_r[0]
@@ -748,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, hFrontVad->hNoiseEst->Etot_l_lp_fx, 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 ), extract_h( 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 );
@@ -765,7 +758,7 @@ ivas_error front_vad_spar_fx(
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 );
/* 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_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_masa_enc_fx.c b/lib_enc/ivas_masa_enc_fx.c
index 2b9ffef15f53806e0f56f6d3bbf06b0ea710c928..9d0579d1243d17cdf9058de82941b6f0c453d91f 100644
--- a/lib_enc/ivas_masa_enc_fx.c
+++ b/lib_enc/ivas_masa_enc_fx.c
@@ -1477,7 +1477,7 @@ static void combine_freqbands_and_subframes_fx(
move16();
hMeta->directional_meta[i].energy_ratio_fx[j][k] =
- BASOP_Util_Divide3232_Scale_cadence( vecLen, L_add( energySum, EPSILON_FX ), &exp_diff ); /*exp_diff+vecLen_e-energySum_e*/
+ BASOP_Util_Divide3232_Scale_newton( vecLen, L_add( energySum, EPSILON_FX ), &exp_diff ); /*exp_diff+vecLen_e-energySum_e*/
move32();
exp_diff = add( exp_diff, sub( vecLen_e, energySum_e ) );
hMeta->directional_meta[i].energy_ratio_fx[j][k] =
@@ -1585,7 +1585,7 @@ static void combine_freqbands_and_subframes_fx(
{
energyRatioSum = BASOP_Util_Add_Mant32Exp( energyRatioSum, energyRatioSum_e, Mpy_32_32( energy[j][k], hMeta->directional_meta[i].energy_ratio_fx[j][k] ), add( energy_e[j][k], 1 ), &energyRatioSum_e ); // 31-energyRatioSum_e
}
- energyRatioTemp = BASOP_Util_Divide3232_Scale_cadence( energyRatioSum, L_add( energySum, EPSILON_FX ), &exp_diff );
+ energyRatioTemp = BASOP_Util_Divide3232_Scale_newton( energyRatioSum, L_add( energySum, EPSILON_FX ), &exp_diff );
exp_diff = add( exp_diff, sub( energyRatioSum_e, energySum_e ) );
energyRatioTemp = L_shl( energyRatioTemp, sub( exp_diff, 1 ) ); // Q30
@@ -2264,13 +2264,13 @@ static void compensate_energy_ratios_fx(
FOR( dir = 0; dir < numDirs; dir++ )
{
hMeta->directional_meta[dir].energy_ratio_fx[sf][band] =
- BASOP_Util_Divide3232_Scale_cadence( hMeta->directional_meta[dir].energy_ratio_fx[sf][band], ratioSum, &exp_diff );
+ BASOP_Util_Divide3232_Scale_newton( hMeta->directional_meta[dir].energy_ratio_fx[sf][band], ratioSum, &exp_diff );
move32();
hMeta->directional_meta[dir].energy_ratio_fx[sf][band] = L_shl( hMeta->directional_meta[dir].energy_ratio_fx[sf][band], sub( exp_diff, Q1 ) ); // Q30
move32();
}
hMeta->common_meta.diffuse_to_total_ratio_fx[sf][band] =
- BASOP_Util_Divide3232_Scale_cadence( hMeta->common_meta.diffuse_to_total_ratio_fx[sf][band], ratioSum, &exp_diff );
+ BASOP_Util_Divide3232_Scale_newton( hMeta->common_meta.diffuse_to_total_ratio_fx[sf][band], ratioSum, &exp_diff );
move32();
hMeta->common_meta.diffuse_to_total_ratio_fx[sf][band] = L_shl( hMeta->common_meta.diffuse_to_total_ratio_fx[sf][band], sub( exp_diff, Q1 ) ); // Q30
move32();
@@ -2302,7 +2302,7 @@ static void reduce_metadata_further_fx(
Word16 bandEnergy_exp, shift;
UWord8 mergeOverFreqBands;
Word32 meanRatio;
- Word16 tmp, tmp2;
+ Word16 tmp, tmp2, q_totalEnergySum;
numCodingBands = hMasa->config.numCodingBands;
test();
@@ -2373,6 +2373,7 @@ static void reduce_metadata_further_fx(
tmp2 = s_min( 32, tmp2 );
totalEnergySum = W_extract_h( W_shl( W_tmp, tmp2 ) );
tmp2 = sub( tmp2, 32 );
+ q_totalEnergySum = add( hMasa->data.q_energy, tmp2 );
/* Determine onsets */
hMasa->data.onset_detector_1_fx = Mpy_32_32( hMasa->data.onset_detector_1_fx, LOWBITRATE_ONSET_ALPHA_Q31 );
@@ -2380,12 +2381,17 @@ static void reduce_metadata_further_fx(
tmp = hMasa->data.q_onset_detector;
move16();
- IF( BASOP_Util_Cmp_Mant32Exp( hMasa->data.onset_detector_1_fx, sub( 31, hMasa->data.q_onset_detector ), totalEnergySum, sub( 31, hMasa->data.q_energy ) ) < 0 )
+ IF( BASOP_Util_Cmp_Mant32Exp( hMasa->data.onset_detector_1_fx, sub( 31, hMasa->data.q_onset_detector ), totalEnergySum, sub( 31, q_totalEnergySum ) ) < 0 )
{
hMasa->data.onset_detector_1_fx = totalEnergySum; // hMasa->data.q_energy
hMasa->data.q_onset_detector = add( hMasa->data.q_energy, tmp2 );
move32();
move16();
+
+ shift = norm_l( hMasa->data.onset_detector_2_fx );
+ hMasa->data.onset_detector_2_fx = L_shl( hMasa->data.onset_detector_2_fx, shift );
+ move32();
+ tmp = add( tmp, shift );
}
IF( LT_16( tmp, hMasa->data.q_onset_detector ) )
{
@@ -2406,7 +2412,7 @@ static void reduce_metadata_further_fx(
IF( hMasa->data.onset_detector_1_fx != 0 )
{
- onset_filter = L_max( BASOP_Util_Divide3232_Scale_cadence( hMasa->data.onset_detector_2_fx, hMasa->data.onset_detector_1_fx, &onset_filter_e ), 0 );
+ onset_filter = L_max( BASOP_Util_Divide3232_Scale_newton( hMasa->data.onset_detector_2_fx, hMasa->data.onset_detector_1_fx, &onset_filter_e ), 0 );
IF( BASOP_Util_Cmp_Mant32Exp( onset_filter, onset_filter_e, ONE_IN_Q31, 0 ) > 0 )
{
@@ -2433,7 +2439,7 @@ static void reduce_metadata_further_fx(
Word32 bandRatio;
// threshold = totalEnergySum / ( MAX_PARAM_SPATIAL_SUBFRAMES * LOWBITRATE_NUM_BANDS ) * 0.5f; /* Average energy multiplied with energy ratio of 0.5f */
- threshold = BASOP_Util_Divide3232_Scale_cadence( totalEnergySum, ( MAX_PARAM_SPATIAL_SUBFRAMES * LOWBITRATE_NUM_BANDS ) * 2, &exp ); /* Average energy multiplied with energy ratio of 0.5f */
+ threshold = BASOP_Util_Divide3232_Scale_newton( totalEnergySum, ( MAX_PARAM_SPATIAL_SUBFRAMES * LOWBITRATE_NUM_BANDS ) * 2, &exp ); /* Average energy multiplied with energy ratio of 0.5f */
exp = add( exp, sub( sub( 31, add( hMasa->data.q_energy, tmp2 ) ), 31 ) );
bandRatio = hqmetadata->q_direction[0].band_data[band].energy_ratio_fx[0]; // Q30
move32();
@@ -2457,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_cadence( meanRatio, totalEnergySum, &exp );
- exp = add( add( exp, 1 ), tmp2 ); // 31 - (hMasa->data.q_energy - 1) - 31 - hMasa->data.q_energy - tmp2 => 1 + tmp2
+ meanRatio = BASOP_Util_Divide3232_Scale_newton( meanRatio, totalEnergySum, &exp );
+ exp = add( exp, sub( shift, sub( 31, add( hMasa->data.q_energy, tmp2 ) ) ) ); // exp + (shift - (31 - hMasa->data.q_energy - tmp2)) => 1 + tmp2
}
ELSE
{
@@ -4730,7 +4740,7 @@ static void ivas_encode_masaism_metadata_fx(
FOR( obj = 0; obj < nchan_ism; obj++ )
{
- hOmasaData->energy_ratio_ism_fx[sf][0][obj] = BASOP_Util_Divide3232_Scale_cadence( energy_ism_ind[obj], energy_ism, &L_tmp_e );
+ hOmasaData->energy_ratio_ism_fx[sf][0][obj] = BASOP_Util_Divide3232_Scale_newton( energy_ism_ind[obj], energy_ism, &L_tmp_e );
move32();
L_tmp_e = add( L_tmp_e, sub( energy_ism_ind_e[obj], energy_ism_e ) );
/* Scaling to Q30 */
@@ -4740,7 +4750,7 @@ static void ivas_encode_masaism_metadata_fx(
L_tmp = BASOP_Util_Add_Mant32Exp( eneBand32, eneBand_exp, energy_ism, energy_ism_e, &L_tmp_e );
IF( L_tmp != 0 )
{
- hOmasaData->masa_to_total_energy_ratio_fx[sf][0] = BASOP_Util_Divide3232_Scale_cadence( eneBand32, L_tmp, &tmp );
+ hOmasaData->masa_to_total_energy_ratio_fx[sf][0] = BASOP_Util_Divide3232_Scale_newton( eneBand32, L_tmp, &tmp );
move32();
tmp = add( tmp, sub( eneBand_exp, L_tmp_e ) );
/* Scaling to Q30 */
@@ -4791,7 +4801,7 @@ static void ivas_encode_masaism_metadata_fx(
{
FOR( obj = 0; obj < nchan_ism; obj++ )
{
- hOmasaData->energy_ratio_ism_fx[0][band][obj] = BASOP_Util_Divide3232_Scale_cadence( energy_ism_ind[obj], energy_ism, &L_tmp_e );
+ hOmasaData->energy_ratio_ism_fx[0][band][obj] = BASOP_Util_Divide3232_Scale_newton( energy_ism_ind[obj], energy_ism, &L_tmp_e );
move32();
L_tmp_e = add( L_tmp_e, sub( energy_ism_ind_e[obj], energy_ism_e ) );
/* Scaling to Q30 */
@@ -4819,7 +4829,7 @@ static void ivas_encode_masaism_metadata_fx(
L_tmp = BASOP_Util_Add_Mant32Exp( eneBand32, eneBand_exp, energy_ism, energy_ism_e, &L_tmp_e );
IF( L_tmp != 0 )
{
- hOmasaData->masa_to_total_energy_ratio_fx[0][band] = BASOP_Util_Divide3232_Scale_cadence( eneBand32, L_tmp, &tmp );
+ hOmasaData->masa_to_total_energy_ratio_fx[0][band] = BASOP_Util_Divide3232_Scale_newton( eneBand32, L_tmp, &tmp );
move32();
tmp = add( tmp, sub( eneBand_exp, L_tmp_e ) );
/* Scaling to Q30 */
@@ -4876,7 +4886,7 @@ static void ivas_encode_masaism_metadata_fx(
L_tmp = BASOP_Util_Add_Mant32Exp( eneBand32, eneBand_exp, hOmasaData->energy_ism_fx[sf][band], hOmasaData->energy_ism_fx_e[sf][band], &L_tmp_e );
IF( L_tmp != 0 )
{
- hOmasaData->masa_to_total_energy_ratio_fx[sf][band] = BASOP_Util_Divide3232_Scale_cadence( eneBand32, L_tmp, &tmp );
+ hOmasaData->masa_to_total_energy_ratio_fx[sf][band] = BASOP_Util_Divide3232_Scale_newton( eneBand32, L_tmp, &tmp );
move32();
tmp = add( tmp, sub( eneBand_exp, L_tmp_e ) );
/* Scaling to Q30 */
diff --git a/lib_enc/ivas_mc_param_enc_fx.c b/lib_enc/ivas_mc_param_enc_fx.c
index d0316be0ff0de173e84415dc2bfe26286c531749..7f74f78f922ecc40682f6bbe91214d0c9cd0376e 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];
@@ -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
@@ -2222,7 +2318,7 @@ static void ivas_param_mc_dec2bin_fx(
/* convert value to bitstream, MSB first */
FOR( idx = 0; idx < N; idx++ )
{
- bits[idx] = (UWord16) s_and( shr( val, sub( N, sub( 1, idx ) ) ), 1 );
+ bits[idx] = (UWord16) s_and( shr( val, sub( sub( N, 1 ), idx ) ), 1 );
move16();
}
diff --git a/lib_enc/ivas_mcmasa_enc_fx.c b/lib_enc/ivas_mcmasa_enc_fx.c
index 7a5718e9958d3eb7989f4168b4c8876fcc84f3c5..b89424e76a8dd84ee0b7019b562a7e0843f298b1 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 *exp_intensity_real,
+ 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();
@@ -938,7 +947,7 @@ void ivas_mcmasa_param_est_enc_fx(
Word32 renormalization_factor_coh_fx[MASA_FREQUENCY_BANDS]; // renormalization_factor_coh_e
Word16 renormalization_factor_coh_e[MASA_FREQUENCY_BANDS];
Word16 surroundingCoherence_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];
- Word16 numAnalysisChannels;
+ Word16 numAnalysisChannels, shift;
FOR( i = 0; i < MCMASA_MAX_ANA_CHANS; i++ )
{
@@ -1168,7 +1177,7 @@ void ivas_mcmasa_param_est_enc_fx(
Foa_ImagBuffer_fx,
0,
num_freq_bands,
- intensity_real_fx );
+ intensity_real_fx, &c_e, inp_q );
computeDirectionVectors_fixed(
intensity_real_fx[0],
@@ -1188,7 +1197,8 @@ void ivas_mcmasa_param_est_enc_fx(
FoaEven_ImagBuffer_fx,
0,
num_freq_bands,
- intensity_even_real_fx );
+ intensity_even_real_fx, &shift, inp_q );
+
Word16 ref_e = 0;
move16();
computeReferencePower_enc_fx( hMcMasa->band_grouping,
@@ -1211,7 +1221,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 +1237,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 );
@@ -2071,21 +2081,30 @@ static void compute_cov_mtx_fx(
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 *exp_intensity_real,
+ 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 brange[2], shift = 63;
+ move16();
+ Flag is_zero = 0;
+ move16();
+
+ 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 );
+ }
FOR( i = enc_param_start_band; i < enc_param_start_band + num_frequency_bands; i++ )
{
@@ -2108,17 +2127,51 @@ 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_add( W_mult0_32_32( Cldfb_RealBuffer[3][j], real ), W_mult0_32_32( Cldfb_ImagBuffer[3][j], img ) ) ); // output Q= 2* input_q
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_add( W_mult0_32_32( Cldfb_RealBuffer[1][j], real ), W_mult0_32_32( Cldfb_ImagBuffer[1][j], img ) ) ); // output Q= 2* input_q
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_add( W_mult0_32_32( Cldfb_RealBuffer[2][j], real ), W_mult0_32_32( Cldfb_ImagBuffer[2][j], img ) ) ); // output Q= 2* input_q
move32();
}
}
+ FOR( i = 0; i < DIRAC_NUM_DIMS; i++ )
+ {
+ is_zero = is_zero_arr64( intensity_real64[i], MASA_FREQUENCY_BANDS );
+ IF( is_zero == 0 )
+ {
+ BREAK;
+ }
+ }
+ IF( is_zero == 0 )
+ {
+ FOR( i = 0; i < DIRAC_NUM_DIMS; i++ )
+ {
+ shift = s_min( shift, W_norm_arr( intensity_real64[i], MASA_FREQUENCY_BANDS ) );
+ }
+
+ FOR( i = 0; i < DIRAC_NUM_DIMS; i++ )
+ {
+ FOR( j = 0; j < MASA_FREQUENCY_BANDS; j++ )
+ {
+ intensity_real[i][j] = W_extract_h( W_shl( intensity_real64[i][j], shift ) );
+ move32();
+ }
+ }
+
+ *exp_intensity_real = sub( 31, sub( add( shift, shl( inp_q, 1 ) ), 32 ) );
+ move16();
+ }
+ ELSE
+ {
+ *exp_intensity_real = 0;
+ 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 548a5671741574d9d44a77d61906e8c9e8c8e2e9..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
{
@@ -646,7 +639,7 @@ void ivas_mct_core_enc_fx(
q_spectrum = sub( 31, st->hTcxEnc->spectrum_e[n] );
set16_fx( exp_powerSpec[ch], sub( Q31, q_powSpec[ch] ), N_MAX + L_MDCT_OVLP_MAX );
- ProcessIGF_ivas_fx( st, L_FRAME48k, st->hTcxEnc->spectrum_fx[n], orig_spectrum_fx[ch][n], &q_spectrum, &powerSpec_fx[ch][n * L_subframeTCX], &exp_powerSpec[ch][n * L_subframeTCX], st->core == TCX_20_CORE, n, sp_aud_decision0[ch], 0 );
+ 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->hIGFEnc->spec_be_igf_e = sub( 31, q_origSpec );
st->hTcxEnc->spectrum_e[n] = sub( 31, q_spectrum );
diff --git a/lib_enc/ivas_mct_enc_fx.c b/lib_enc/ivas_mct_enc_fx.c
index bb98e61637e5d9d74b39ac980a4703d7c9452a68..e01387c37d7fffdd145b29b55d43de1adbfcdef1 100644
--- a/lib_enc/ivas_mct_enc_fx.c
+++ b/lib_enc/ivas_mct_enc_fx.c
@@ -482,6 +482,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 66bdb1235b492cfd383cd176295a6c5afbc656ee..8ff17ae01a6cd7bee24f079d5b95a72684b777fb 100644
--- a/lib_enc/ivas_mct_enc_mct_fx.c
+++ b/lib_enc/ivas_mct_enc_mct_fx.c
@@ -385,7 +385,7 @@ static void getBlockValues_fx(
p_st[0] = sts[ch1];
p_st[1] = sts[ch2];
- stereo_coder_tcx_fx( hBlock->hStereoMdct, p_st, hBlock->mask, p_mdst_spectrum, p_inv_spectrum, p_inv_mdst_spectrum, 1, q_spec );
+ stereo_coder_tcx_fx( hBlock->hStereoMdct, p_st, hBlock->mask, p_mdst_spectrum, p_inv_spectrum, p_inv_mdst_spectrum, 1, sub( 31, q_spec ), sub( 31, q_spec ) );
test();
test();
@@ -986,19 +986,19 @@ 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 b, nSubframes, L_subframeTCX;
- Word16 p_ch[2], n, ch, ch1, ch2, s = 31;
- Word16 q_pSI_ch[2];
+ Word16 p_ch[2], n, ch, ch1, ch2;
Word16 q_pS_ch[2];
Encoder_State *p_st[NB_DIV];
Encoder_State *st;
@@ -1059,12 +1059,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,35 +1072,18 @@ void mctStereoIGF_enc_fx(
IF( NE_16( hMCT->hBlockData[b]->hStereoMdct->mdct_stereo_mode[n], hMCT->hBlockData[b]->hStereoMdct->IGFStereoMode[n] ) ||
EQ_16( hMCT->hBlockData[b]->hStereoMdct->mdct_stereo_mode[n], SMDCT_BW_MS ) )
{
- Word16 exp_powerSpec_tmp[CPE_CHANNELS];
- FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
- {
- s = s_min( s, sub( 31, p_st[ch]->hTcxEnc->spectrum_e[n] ) );
- s = s_min( s, q_pS_ch[ch] );
- s = s_min( s, q_pSI_ch[ch] );
- }
+ Word16 exp_powerSpec_fx[CPE_CHANNELS], exp_inv_spectrum_fx[CPE_CHANNELS];
+
FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
{
- scale_sig32( p_st[ch]->hTcxEnc->spectrum_fx[0], N_MAX, sub( s, sub( 31, p_st[ch]->hTcxEnc->spectrum_e[0] ) ) );
- scale_sig32( p_inv_spectrum_fx[ch][0], L_FRAME48k, sub( s, sub( 31, p_st[ch]->hTcxEnc->spectrum_e[0] ) ) );
- p_st[ch]->hTcxEnc->spectrum_e[0] = sub( 31, s );
- p_st[ch]->hTcxEnc->spectrum_e[1] = sub( 31, s );
- move16();
- move16();
-
- scale_sig32( p_powerSpecMsInv_fx[ch][0], L_FRAME48k, sub( s, q_pSI_ch[ch] ) );
- scale_sig32( &p_powerSpec_fx[ch][0], sts[ch]->hTcxEnc->L_frameTCX, sub( s, q_pS_ch[ch] ) );
- q_powerSpec[ch1] = s;
- q_powerSpec[ch2] = s;
+ exp_powerSpec_fx[ch] = sub( Q31, q_pS_ch[ch] );
+ exp_inv_spectrum_fx[ch] = p_st[ch]->hTcxEnc->spectrum_e[n];
move16();
move16();
}
- exp_powerSpec_tmp[0] = p_st[0]->hTcxEnc->spectrum_e[0];
- exp_powerSpec_tmp[1] = p_st[1]->hTcxEnc->spectrum_e[0];
- move16();
- move16();
- ProcessStereoIGF_fx( hMCT->hBlockData[b]->hStereoMdct, p_st, hMCT->hBlockData[b]->mask, p_orig_spectrum_fx, q_origSpec, q_origSpec, p_powerSpec_fx, exp_powerSpec_tmp,
- p_powerSpecMsInv_fx, exp_powerSpec_tmp, p_inv_spectrum_fx, exp_powerSpec_tmp, n, sp_aud_decision0[ch1], p_st[0]->total_brate, 1 );
+
+ 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, q_p_powerSpecMsInv_fx, p_inv_spectrum_fx, exp_inv_spectrum_fx, n, sp_aud_decision0[ch1], p_st[0]->total_brate, 1 );
}
ELSE
{
@@ -1118,7 +1101,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 );
- ProcessIGF_ivas_fx( st, L_FRAME48k, st->hTcxEnc->spectrum_fx[n], orig_spectrum_fx[p_ch[ch]][n], &q_spectrum, &powerSpec_fx[p_ch[ch]][n * L_subframeTCX], &exp_powerSpec[p_ch[ch]][n * L_subframeTCX], st->core == TCX_20_CORE, n, sp_aud_decision0[ch], 0 );
+ 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 );
move16();
@@ -1159,7 +1142,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 );
- ProcessIGF_ivas_fx( st, L_FRAME48k, st->hTcxEnc->spectrum_fx[n], orig_spectrum_fx[ch][n], &q_spectrum, &powerSpec_fx[ch][n * L_subframeTCX], &exp_powerSpec[ch][n * L_subframeTCX], st->core == TCX_20_CORE, n, sp_aud_decision0[ch], 0 );
+ 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 );
move16();
diff --git a/lib_enc/ivas_mdct_core_enc_fx.c b/lib_enc/ivas_mdct_core_enc_fx.c
index e744c7f47379813ea4e9b180f2e91de1c8b0e821..4d8bc7b9979f5a8e60a9b8cbb79cc9c8e942020f 100644
--- a/lib_enc/ivas_mdct_core_enc_fx.c
+++ b/lib_enc/ivas_mdct_core_enc_fx.c
@@ -233,7 +233,7 @@ static Word16 kernel_switch_detect_fx(
L_tmp1 = Sqrt32( L_tmp1, &exp_tmp1 );
L_tmp = BASOP_Util_Add_Mant32Exp( L_tmp, exp_tmp, L_tmp1, exp_tmp1, &exp_tmp );
L_tmp = BASOP_Util_Add_Mant32Exp( L_tmp, exp_tmp, ONE_IN_Q30, 1, &exp_tmp );
- cov00 = BASOP_Util_Divide3232_Scale_cadence( cov00, L_tmp, &exp_tmp1 );
+ cov00 = BASOP_Util_Divide3232_Scale_newton( cov00, L_tmp, &exp_tmp1 );
exp_tmp = add( exp_tmp1, sub( sub( Q31, q_com ), exp_tmp ) );
/* Added saturation to handle overflows when value is very close to 1.f */
cov00 = L_shl_sat( cov00, exp_tmp ); // Q31
@@ -247,7 +247,7 @@ static Word16 kernel_switch_detect_fx(
L_tmp1 = Sqrt32( L_tmp1, &exp_tmp1 );
L_tmp = BASOP_Util_Add_Mant32Exp( L_tmp, exp_tmp, L_tmp1, exp_tmp1, &exp_tmp );
L_tmp = BASOP_Util_Add_Mant32Exp( L_tmp, exp_tmp, ONE_IN_Q30, 1, &exp_tmp );
- cov90 = BASOP_Util_Divide3232_Scale_cadence( cov90, L_tmp, &exp_tmp1 );
+ cov90 = BASOP_Util_Divide3232_Scale_newton( cov90, L_tmp, &exp_tmp1 );
exp_tmp = add( exp_tmp1, sub( sub( Q31, q_com ), exp_tmp ) );
/* Added saturation to handle overflows when value is very close to 1.f */
cov90 = L_shl_sat( cov90, exp_tmp ); // Q31
@@ -735,7 +735,7 @@ static void applyStereoPreProcessingCplx(
d_q = sub( 31, d_q );
deno = L_max( L_shl_sat( 1, d_q ), d_fx );
- sq_imp = BASOP_Util_Divide3232_Scale_cadence( n_fx, deno, &exp );
+ sq_imp = BASOP_Util_Divide3232_Scale_newton( n_fx, deno, &exp );
exp = add( exp, sub( d_q, n_q ) );
d_fx = Sqrt32( sq_imp, &exp );
*mdctSample1_fx = Mpy_32_32( dmxR1_fx, d_fx );
@@ -764,7 +764,7 @@ static void applyStereoPreProcessingCplx(
d_q = sub( 31, d_q );
deno = L_max( L_shl_sat( 1, d_q ), d_fx );
- sq_imp = BASOP_Util_Divide3232_Scale_cadence( n_fx, deno, &exp );
+ sq_imp = BASOP_Util_Divide3232_Scale_newton( n_fx, deno, &exp );
exp = add( exp, sub( d_q, n_q ) );
d_fx = Sqrt32( sq_imp, &exp );
*mdctSample2_fx = Mpy_32_32( dmxR2_fx, d_fx );
@@ -815,6 +815,7 @@ static UWord16 enc_ste_pre_mdct(
Word16 mdst_exp1[2 * 960], mdst_exp2[2 * 960];
Word16 x1, x2, x3, x4, ans, tmp;
Word32 maxSqrValue_fx;
+ Word64 sumL_64fx, sumR_64fx;
IF( LT_16( nSamplesMax, 512 ) )
{
@@ -885,7 +886,9 @@ static UWord16 enc_ste_pre_mdct(
{
return 0;
}
-
+ sumL_64fx = 0, sumR_64fx = 0;
+ move64();
+ move64();
FOR( s = fadeInOff; s < nSampProc; s++ )
{
Word32 absMagnL_fx, absMagnR_fx;
@@ -898,8 +901,8 @@ static UWord16 enc_ste_pre_mdct(
absMagnR_fx = Sqrt32( L_add( Mpy_32_32( sigR1_fx[s], sigR1_fx[s] ), Mpy_32_32( sigI1_fx[s], sigI1_fx[s] ) ), &absMagnR_e );
corr_fx = L_add( corr_fx, L_add( Mpy_32_32( sigR0_fx[s], sigR1_fx[s] ), Mpy_32_32( sigI0_fx[s], sigI1_fx[s] ) ) ); // q_com*2 - 31
- sumL_fx = L_add( sumL_fx, L_add( L_shr( sigR0_fx[s], 1 ), L_shr( sigI0_fx[s], 1 ) ) ); // q_com -1
- sumR_fx = L_add( sumR_fx, L_add( L_shr( sigR1_fx[s], 1 ), L_shr( sigI1_fx[s], 1 ) ) ); // q_com - 1
+ sumL_64fx = W_add( sumL_64fx, W_add( sigR0_fx[s], sigI0_fx[s] ) ); // q_com
+ sumR_64fx = W_add( sumR_64fx, W_add( sigR1_fx[s], sigI1_fx[s] ) ); // q_com
sumMagnL_fx = BASOP_Util_Add_Mant32Exp( sumMagnL_fx, sumMagnL_e, absMagnL_fx, absMagnL_e, &sumMagnL_e );
sumMagnR_fx = BASOP_Util_Add_Mant32Exp( sumMagnR_fx, sumMagnR_e, absMagnR_fx, absMagnR_e, &sumMagnR_e );
sumPrdLR_fx = BASOP_Util_Add_Mant32Exp( sumPrdLR_fx, sumPrdLR_e, Mpy_32_32( absMagnL_fx, absMagnR_fx ), add( absMagnL_e, absMagnR_e ), &sumPrdLR_e );
@@ -911,7 +914,14 @@ static UWord16 enc_ste_pre_mdct(
temp1 = L_shl( preproLen, x1 );
corr_fx = Mpy_32_32( corr_fx, temp1 );
x1 = sub( 62, add( shl( *q_com, 1 ), x1 ) );
- corr_fx = BASOP_Util_Add_Mant32Exp( corr_fx, x1, Mpy_32_32( sumL_fx, sumR_fx ), sub( 62, shl( sub( *q_com, 1 ), 1 ) ), &x1 );
+
+ x2 = W_norm( sumL_64fx );
+ sumL_fx = W_extract_h( W_shl( sumL_64fx, x2 ) );
+
+ x3 = W_norm( sumR_64fx );
+ sumR_fx = W_extract_h( W_shl( sumR_64fx, x3 ) );
+
+ corr_fx = BASOP_Util_Add_Mant32Exp( corr_fx, x1, Mpy_32_32( sumL_fx, sumR_fx ), sub( 62, add( sub( add( *q_com, x2 ), 32 ), sub( add( *q_com, x3 ), 32 ) ) ), &x1 );
IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( corr_fx, x1, -maxSqrValue_fx, 52 ), -1 ) )
{
@@ -956,7 +966,7 @@ static UWord16 enc_ste_pre_mdct(
ELSE
{
Word16 exp1;
- corr_fx = BASOP_Util_Divide3232_Scale_cadence( Mpy_32_32( corr_fx, corr_fx ), Mpy_32_32( sumL_fx, sumR_fx ), &exp1 );
+ corr_fx = BASOP_Util_Divide3232_Scale_newton( Mpy_32_32( corr_fx, corr_fx ), Mpy_32_32( sumL_fx, sumR_fx ), &exp1 );
corr_e = add( exp1, sub( shl( corr_e, 1 ), add( sumL_e, sumR_e ) ) );
}
test();
diff --git a/lib_enc/ivas_omasa_enc_fx.c b/lib_enc/ivas_omasa_enc_fx.c
index 265f2b601b4afc4af9c89895016542541f995fae..427935cb6217fd973661970c1a6539a321dd1104 100644
--- a/lib_enc/ivas_omasa_enc_fx.c
+++ b/lib_enc/ivas_omasa_enc_fx.c
@@ -1139,11 +1139,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 ) );
diff --git a/lib_enc/ivas_qmetadata_enc_fx.c b/lib_enc/ivas_qmetadata_enc_fx.c
index 10380f422357db94d0dd102c7e8b2dfc80a8faae..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
@@ -1069,8 +1072,12 @@ void ivas_qmetadata_enc_sid_encode_fx(
{
/*compute the average direction */
ivas_qmetadata_azimuth_elevation_to_direction_vector_fx( q_direction->band_data[b].azimuth_fx[m], q_direction->band_data[b].elevation_fx[m], direction_vector_fx );
- scale_sig32( direction_vector_fx, 3, Q22 - Q30 ); // Q30 -> Q22
+ scale_sig32( direction_vector_fx, 3, Q22 - Q30 ); // Q30 -> Q22
+#ifdef VEC_ARITH_OPT_v1
+ v_add_fixed_no_hdrm( avg_direction_vector_fx, direction_vector_fx, avg_direction_vector_fx, 3 ); // Q22
+#else /* VEC_ARITH_OPT_v1 */
v_add_fixed( avg_direction_vector_fx, direction_vector_fx, avg_direction_vector_fx, 3, 0 ); // Q22
+#endif /* VEC_ARITH_OPT_v1 */
}
ivas_qmetadata_direction_vector_to_azimuth_elevation_fx( avg_direction_vector_fx, Q22, &avg_azimuth_fx[b], &avg_elevation_fx[b] );
@@ -1188,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();
@@ -1332,12 +1348,12 @@ static void ivas_qmetadata_quantize_diffuseness_nrg_ratios_hr_512_fx(
ratioSum = L_add( hQMetaData->q_direction[0].band_data[j].energy_ratio_fx[k], hQMetaData->q_direction[1].band_data[j].energy_ratio_fx[k] );
IF( GT_32( ratioSum, ONE_IN_Q30 /*1.0f*/ ) )
{
- hQMetaData->q_direction[0].band_data[j].energy_ratio_fx[k] = BASOP_Util_Divide3232_Scale_cadence( hQMetaData->q_direction[0].band_data[j].energy_ratio_fx[k], ratioSum, &div_e );
+ hQMetaData->q_direction[0].band_data[j].energy_ratio_fx[k] = BASOP_Util_Divide3232_Scale_newton( hQMetaData->q_direction[0].band_data[j].energy_ratio_fx[k], ratioSum, &div_e );
hQMetaData->q_direction[0].band_data[j].energy_ratio_fx[k] = L_shl( hQMetaData->q_direction[0].band_data[j].energy_ratio_fx[k], sub( div_e, 1 ) );
move32();
move32();
- hQMetaData->q_direction[1].band_data[j].energy_ratio_fx[k] = BASOP_Util_Divide3232_Scale_cadence( hQMetaData->q_direction[1].band_data[j].energy_ratio_fx[k], ratioSum, &div_e );
+ hQMetaData->q_direction[1].band_data[j].energy_ratio_fx[k] = BASOP_Util_Divide3232_Scale_newton( hQMetaData->q_direction[1].band_data[j].energy_ratio_fx[k], ratioSum, &div_e );
hQMetaData->q_direction[1].band_data[j].energy_ratio_fx[k] = L_shl( hQMetaData->q_direction[1].band_data[j].energy_ratio_fx[k], sub( div_e, 1 ) );
move32();
move32();
@@ -1385,12 +1401,12 @@ static void ivas_qmetadata_quantize_diffuseness_nrg_ratios_hr_512_fx(
IF( GT_32( ratioSum, ONE_IN_Q30 /*1.0f*/ ) )
{
- hQMetaData->q_direction[0].band_data[pos_2dir_band[j]].energy_ratio_fx[k] = BASOP_Util_Divide3232_Scale_cadence( hQMetaData->q_direction[0].band_data[pos_2dir_band[j]].energy_ratio_fx[k], ratioSum, &div_e );
+ hQMetaData->q_direction[0].band_data[pos_2dir_band[j]].energy_ratio_fx[k] = BASOP_Util_Divide3232_Scale_newton( hQMetaData->q_direction[0].band_data[pos_2dir_band[j]].energy_ratio_fx[k], ratioSum, &div_e );
hQMetaData->q_direction[0].band_data[pos_2dir_band[j]].energy_ratio_fx[k] = L_shl( hQMetaData->q_direction[0].band_data[pos_2dir_band[j]].energy_ratio_fx[k], sub( div_e, 1 ) );
move32();
move32();
- hQMetaData->q_direction[1].band_data[j].energy_ratio_fx[k] = BASOP_Util_Divide3232_Scale_cadence( hQMetaData->q_direction[1].band_data[j].energy_ratio_fx[k], ratioSum, &div_e );
+ hQMetaData->q_direction[1].band_data[j].energy_ratio_fx[k] = BASOP_Util_Divide3232_Scale_newton( hQMetaData->q_direction[1].band_data[j].energy_ratio_fx[k], ratioSum, &div_e );
hQMetaData->q_direction[1].band_data[j].energy_ratio_fx[k] = L_shl( hQMetaData->q_direction[1].band_data[j].energy_ratio_fx[k], sub( div_e, 1 ) );
move32();
move32();
@@ -2003,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();
@@ -2402,7 +2421,11 @@ static Word16 ivas_qmetadata_entropy_encode_dir_fx(
/*compute the average direction */
ivas_qmetadata_azimuth_elevation_to_direction_vector_fx( q_direction->band_data[i].azimuth_fx[j], q_direction->band_data[i].elevation_fx[j], direction_vector );
scale_sig32( direction_vector, 3, -8 ); // Q30 -> Q22
+#ifdef VEC_ARITH_OPT_v1
+ v_add_fixed_no_hdrm( avg_direction_vector, direction_vector, avg_direction_vector, 3 );
+#else /* VEC_ARITH_OPT_v1 */
v_add_fixed( avg_direction_vector, direction_vector, avg_direction_vector, 3, 0 );
+#endif /* VEC_ARITH_OPT_v1 */
}
}
}
@@ -2665,7 +2688,11 @@ static Word16 ivas_qmetadata_entropy_encode_dir_fx(
IF( LT_16( idx, 4 ) )
{
+#ifdef VEC_ARITH_OPT_v1
+ v_add_fixed_no_hdrm( avg_direction_vector, direction_vector, avg_direction_vector, 3 );
+#else /* VEC_ARITH_OPT_v1 */
v_add_fixed( avg_direction_vector, direction_vector, avg_direction_vector, 3, 0 );
+#endif /* VEC_ARITH_OPT_v1 */
}
}
/* project the quantized average azimuth angle to the same grid as the current sample */
@@ -2696,7 +2723,11 @@ static Word16 ivas_qmetadata_entropy_encode_dir_fx(
ivas_qmetadata_azimuth_elevation_to_direction_vector_fx( q_direction->band_data[i].azimuth_fx[j], q_direction->band_data[i].elevation_fx[j], direction_vector );
scale_sig32( direction_vector, 3, -8 ); // Q30 -> Q22
+#ifdef VEC_ARITH_OPT_v1
+ v_add_fixed_no_hdrm( avg_direction_vector, direction_vector, avg_direction_vector, 3 );
+#else /* VEC_ARITH_OPT_v1 */
v_add_fixed( avg_direction_vector, direction_vector, avg_direction_vector, 3, 0 );
+#endif /* VEC_ARITH_OPT_v1 */
ivas_qmetadata_direction_vector_to_azimuth_elevation_fx( avg_direction_vector, Q22, &avg_azimuth, &avg_elevation );
avg_azimuth_index_upd = quantize_phi_enc_fx( L_add( avg_azimuth, 180 << Q22 ), 0, &avg_azimuth, avg_azimuth_alphabet );
@@ -6619,7 +6650,7 @@ void ivas_omasa_encode_masa_to_total_fx(
{
j = imult1616( k, len_stream );
/* quantize with fixed common step */
- L_tmp = BASOP_Util_Divide3232_Scale_cadence( dct_data[j], step, &tmp_e );
+ L_tmp = BASOP_Util_Divide3232_Scale_newton( dct_data[j], step, &tmp_e );
tmp_e = add( tmp_e, Q6 );
q_idx[j] = rint_new_fx( L_shr( L_tmp, sub( 15, tmp_e ) ) /* Q16 */ ); // Q0
move16();
@@ -6642,7 +6673,7 @@ void ivas_omasa_encode_masa_to_total_fx(
{
FOR( i = 1; i < len_stream; i++ )
{
- L_tmp = BASOP_Util_Divide3232_Scale_cadence( dct_data[j + i], step, &tmp_e );
+ L_tmp = BASOP_Util_Divide3232_Scale_newton( dct_data[j + i], step, &tmp_e );
tmp_e = add( tmp_e, Q6 );
q_idx[j + i] = rint_new_fx( L_shr( L_tmp, sub( 15, tmp_e ) ) );
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_sns_enc_fx.c b/lib_enc/ivas_sns_enc_fx.c
index b7de878a12a6e567f1b868deb3d55472a407d51f..2eaefb48358859a5c23cb148d781654a24b39a7b 100644
--- a/lib_enc/ivas_sns_enc_fx.c
+++ b/lib_enc/ivas_sns_enc_fx.c
@@ -672,7 +672,11 @@ Word16 quantize_sns_fx(
Word32 ener_side_fx;
Word16 ener_side_q;
+#ifdef VEC_ARITH_OPT_v1
+ v_sub_fixed_no_hdrm( snsQ_out_fx[0][k], snsQ_out_fx[1][k], side_fx, M );
+#else /* VEC_ARITH_OPT_v1 */
v_sub_fixed( snsQ_out_fx[0][k], snsQ_out_fx[1][k], side_fx, M, 0 );
+#endif /* VEC_ARITH_OPT_v1 */
Word64 L64_sum;
L64_sum = 1;
diff --git a/lib_enc/ivas_spar_md_enc_fx.c b/lib_enc/ivas_spar_md_enc_fx.c
index 63f1f344550d85dd552142c675b3b5c769fd4e0a..2a4953c2148e18d22ab0f6bf18f2b6590d4d5303 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 3e69a0ca660fbc73ad7cf1ca250e59d02d8a0997..3a040517a84649f0647394974932d5df16f9b9ed 100644
--- a/lib_enc/ivas_stereo_classifier_fx.c
+++ b/lib_enc/ivas_stereo_classifier_fx.c
@@ -890,7 +890,7 @@ void unclr_classifier_td_fx(
move16();
/* mean & std removal */
- fvn = BASOP_Util_Divide3232_Scale_cadence( L_sub( hStereoClassif->unclr_fv_fx[ind], unclr_mean_td[i] ), unclr_scale_td[i], &exp );
+ fvn = BASOP_Util_Divide3232_Scale_newton( L_sub( hStereoClassif->unclr_fv_fx[ind], unclr_mean_td[i] ), unclr_scale_td[i], &exp );
fvn = Mpy_32_32( fvn, unclr_coef_td[i] ); // Q = 31-exp+15-31 = 15-exp
exp = add( exp, 16 ); // exp = 31-(15-exp) = 16+exp
@@ -1016,7 +1016,7 @@ void unclr_classifier_dft_fx(
/* mean & std removal */
// fvn[i] = (hStereoClassif->unclr_fv[ind] - unclr_mean_dft[i]) / unclr_scale_dft[i];
- fvn[i] = BASOP_Util_Divide3232_Scale_cadence( L_sub( hStereoClassif->unclr_fv_fx[ind], unclr_mean_dft_Q15[i] ), unclr_scale_dft_Q15[i], &fvn_e[i] );
+ fvn[i] = BASOP_Util_Divide3232_Scale_newton( L_sub( hStereoClassif->unclr_fv_fx[ind], unclr_mean_dft_Q15[i] ), unclr_scale_dft_Q15[i], &fvn_e[i] );
move32();
/* LR */
@@ -1157,7 +1157,7 @@ void xtalk_classifier_td_fx(
move16();
/* mean & std removal */
- fvn = BASOP_Util_Divide3232_Scale_cadence( L_sub( hStereoClassif->xtalk_fv_fx[ind], xtalk_mean_td[i] ), xtalk_scale_td[i], &exp );
+ fvn = BASOP_Util_Divide3232_Scale_newton( L_sub( hStereoClassif->xtalk_fv_fx[ind], xtalk_mean_td[i] ), xtalk_scale_td[i], &exp );
fvn = Mpy_32_32( fvn, xtalk_coef_td[i] ); // Q = 31-exp+15-31 = 15-exp
exp = add( exp, 16 ); // exp = 31-(15-exp) = 16+exp
@@ -1372,7 +1372,7 @@ void xtalk_classifier_dft_fx(
// ratio_m1_m2 = fabsf( m1 * m2 ) / fabsf( m1 + m2 + 1.0f );
Word16 exp;
- ratio_m1_m2 = BASOP_Util_Divide3232_Scale_cadence( L_abs( Mpy_32_32( m1, m2 ) ), L_abs( L_add( L_add( L_shr( m1, 2 ), L_shr( m2, 2 ) ), ONE_IN_Q29 ) ), &exp );
+ ratio_m1_m2 = BASOP_Util_Divide3232_Scale_newton( L_abs( Mpy_32_32( m1, m2 ) ), L_abs( L_add( L_add( L_shr( m1, 2 ), L_shr( m2, 2 ) ), ONE_IN_Q29 ) ), &exp );
exp = sub( exp, 2 );
// m2_m2 = hItd->prev_m2 * m2;
m2_m2 = Mpy_32_32( hItd->prev_m2_fx, m2 );
@@ -1406,7 +1406,7 @@ void xtalk_classifier_dft_fx(
/* mean & std removal */
// fvn[i] = ( hStereoClassif->xtalk_fv[ind] - xtalk_mean_dft[i] ) / xtalk_scale_dft[i];
- fvn[i] = BASOP_Util_Divide3232_Scale_cadence( L_sub( hStereoClassif->xtalk_fv_fx[ind], xtalk_mean_dft_q15[i] ), xtalk_scale_dft_q15[i], &exp ); // Q15
+ fvn[i] = BASOP_Util_Divide3232_Scale_newton( L_sub( hStereoClassif->xtalk_fv_fx[ind], xtalk_mean_dft_q15[i] ), xtalk_scale_dft_q15[i], &exp ); // Q15
move32();
fvn[i] = L_shl_sat( fvn[i], sub( exp, 2 ) ); // Q29
move32();
@@ -1755,7 +1755,7 @@ static Word32 redge_detect_fx(
{
// edge_slope = ( inp_max - inp_min ) / i;
L_temp = BASOP_Util_Add_Mant32Exp( inp_max, 0, L_negate( inp_min ), 0, &L_temp_e );
- edge_slope = BASOP_Util_Divide3232_Scale_cadence( L_temp, i, &edge_slope_e );
+ edge_slope = BASOP_Util_Divide3232_Scale_newton( L_temp, i, &edge_slope_e );
edge_slope_e = add( edge_slope_e, sub( L_temp_e, 31 ) );
edge[i] = err0;
move32();
@@ -1788,7 +1788,7 @@ static Word32 redge_detect_fx(
}
// edge[i] /= i + 1;
- edge[i] = BASOP_Util_Divide3232_Scale_cadence( edge[i], add( i, 1 ), &L_temp_e );
+ edge[i] = BASOP_Util_Divide3232_Scale_newton( edge[i], add( i, 1 ), &L_temp_e );
move32();
edge_e[i] = add( L_temp_e, sub( edge_e[i], 31 ) );
move16();
diff --git a/lib_enc/ivas_stereo_cng_enc_fx.c b/lib_enc/ivas_stereo_cng_enc_fx.c
index aa7c2d0aa6d1211a5724d95e60d69deaacbfac59..b73a57f4690c86d566eb94bd7dadab969789f193 100644
--- a/lib_enc/ivas_stereo_cng_enc_fx.c
+++ b/lib_enc/ivas_stereo_cng_enc_fx.c
@@ -101,7 +101,7 @@ void stereo_dft_enc_sid_calc_coh_fx(
L_tmp1_e = sub( add( hStereoDft->Spd_L_smooth_fx_e, hStereoDft->Spd_R_smooth_fx_e ), W_tmp_q );
L_tmp2 = BASOP_Util_Add_Mant32Exp( Mpy_32_32( hStereoDft->xspec_smooth_fx[2 * k], hStereoDft->xspec_smooth_fx[2 * k] ), shl( hStereoDft->xspec_smooth_fx_e[2 * k], 1 ), Mpy_32_32( hStereoDft->xspec_smooth_fx[2 * k + 1], hStereoDft->xspec_smooth_fx[2 * k + 1] ), shl( hStereoDft->xspec_smooth_fx_e[2 * k + 1], 1 ), &L_tmp2_e );
L_tmp2 = BASOP_Util_Add_Mant32Exp( L_tmp2, L_tmp2_e, EPSILON_FX_M, EPSILON_FX_E, &L_tmp2_e );
- L_tmp3 = BASOP_Util_Divide3232_Scale_cadence( L_tmp1, L_tmp2, &L_tmp3_e );
+ L_tmp3 = BASOP_Util_Divide3232_Scale_newton( L_tmp1, L_tmp2, &L_tmp3_e );
L_tmp3_e = add( L_tmp3_e, sub( L_tmp1_e, L_tmp2_e ) );
L_tmp3 = Mpy_32_32( prev_cohBand[b], L_tmp3 );
xspec_scale = Sqrt32( L_tmp3, &L_tmp3_e );
@@ -137,7 +137,7 @@ void stereo_dft_enc_sid_calc_coh_fx(
L_tmp2 = W_extract_h( W_shl( W_tmp, W_tmp_q ) );
L_tmp2_e = sub( add( hStereoDft->Spd_L_smooth_fx_e, hStereoDft->Spd_R_smooth_fx_e ), W_tmp_q );
L_tmp2 = BASOP_Util_Add_Mant32Exp( L_tmp2, L_tmp2_e, EPSILON_FX_M, EPSILON_FX_E, &L_tmp2_e );
- L_tmp3 = BASOP_Util_Divide3232_Scale_cadence( L_tmp1, L_tmp2, &L_tmp3_e );
+ L_tmp3 = BASOP_Util_Divide3232_Scale_newton( L_tmp1, L_tmp2, &L_tmp3_e );
L_tmp3_e = add( L_tmp3_e, sub( L_tmp1_e, L_tmp2_e ) );
L_tmp3 = Mpy_32_32( coh_weight, L_tmp3 );
L_tmp3_e = add( coh_weight_e, L_tmp3_e );
@@ -150,7 +150,7 @@ void stereo_dft_enc_sid_calc_coh_fx(
IF( coh_weight_sum > 0 )
{
// cohBand[b] = cohBand[b] / coh_weight_sum;
- cohBand[b] = BASOP_Util_Divide3232_Scale_cadence( cohBand[b], coh_weight_sum, &L_tmp1_e );
+ cohBand[b] = BASOP_Util_Divide3232_Scale_newton( cohBand[b], coh_weight_sum, &L_tmp1_e );
move32();
cohBand_e[b] = add( L_tmp1_e, sub( cohBand_e[b], coh_weight_sum_e ) );
move16();
@@ -510,7 +510,7 @@ void stereo_dft_cng_side_gain_fx(
hStereoCng->prev_sg_average_fx[b] = hStereoCng->sg_average_fx[b];
move32();
// hStereoCng->sg_average[b] = hStereoCng->sg_average[b] / (float) hStereoCng->sg_average_counter;
- hStereoCng->sg_average_fx[b] = BASOP_Util_Divide3232_Scale_cadence( hStereoCng->sg_average_fx[b], hStereoCng->sg_average_counter, &tmp_e );
+ hStereoCng->sg_average_fx[b] = BASOP_Util_Divide3232_Scale_newton( hStereoCng->sg_average_fx[b], hStereoCng->sg_average_counter, &tmp_e );
move32();
tmp_e = sub( tmp_e, 31 - 5 );
hStereoCng->sg_average_fx[b] = L_shl_r( hStereoCng->sg_average_fx[b], sub( tmp_e, 5 ) ); // Q31
@@ -535,7 +535,7 @@ void stereo_dft_cng_side_gain_fx(
tmp = hStereoCng->sg_average_fx[b];
move32();
// hStereoCng->sg_average[b] = ( hStereoCng->sg_average[b] + prev_weight * hStereoCng->prev_sg_average[b] ) / ( (float) hStereoCng->sg_average_counter + prev_weight * (float) hStereoCng->prev_sg_average_counter );
- hStereoCng->sg_average_fx[b] = BASOP_Util_Divide3232_Scale_cadence( L_add( hStereoCng->sg_average_fx[b], Mpy_32_16_1( hStereoCng->prev_sg_average_fx[b], prev_weight ) ), L_add( L_shl( hStereoCng->sg_average_counter, Q15 ), L_mult0( prev_weight, hStereoCng->prev_sg_average_counter ) ), &tmp_e );
+ hStereoCng->sg_average_fx[b] = BASOP_Util_Divide3232_Scale_newton( L_add( hStereoCng->sg_average_fx[b], Mpy_32_16_1( hStereoCng->prev_sg_average_fx[b], prev_weight ) ), L_add( L_shl( hStereoCng->sg_average_counter, Q15 ), L_mult0( prev_weight, hStereoCng->prev_sg_average_counter ) ), &tmp_e );
move32();
tmp_e = sub( tmp_e, 16 - 5 );
hStereoCng->sg_average_fx[b] = L_shl_r( hStereoCng->sg_average_fx[b], sub( tmp_e, 5 ) ); // Q26
@@ -571,7 +571,7 @@ void stereo_dft_cng_side_gain_fx(
W_tmp_q = W_norm( W_tmp );
hStereoDft->sidSideGain_fx[b] = W_extract_h( W_shl( W_tmp, W_tmp_q ) );
move32();
- hStereoDft->sidSideGain_fx[b] = BASOP_Util_Divide3232_Scale_cadence( hStereoDft->sidSideGain_fx[b], sgSum, &tmp_e );
+ hStereoDft->sidSideGain_fx[b] = BASOP_Util_Divide3232_Scale_newton( hStereoDft->sidSideGain_fx[b], sgSum, &tmp_e );
move32();
tmp_e = sub( tmp_e, W_tmp_q );
hStereoDft->sidSideGain_fx[b] = L_shl_sat( hStereoDft->sidSideGain_fx[b], tmp_e ); // Q31: saturation is fine since stereo_dft_quantize_res_gains_fx limits value to 1.0
diff --git a/lib_enc/ivas_stereo_dft_enc_fx.c b/lib_enc/ivas_stereo_dft_enc_fx.c
index 01318af28c5aca29760bd9db19eba5c4905e1055..80c4b5a21c8d67576543e593b880993231f2e9b9 100644
--- a/lib_enc/ivas_stereo_dft_enc_fx.c
+++ b/lib_enc/ivas_stereo_dft_enc_fx.c
@@ -880,7 +880,7 @@ void stereo_dft_enc_update_fx(
// hStereoDft->res_cod_line_max = (int16_t) ( 0.5f + ( hStereoDft->band_limits[hStereoDft->res_cod_band_max] - 1 ) * 2.f * hStereoDft->N / (float) ( hStereoDft->NFFT ) );
Word32 tmp = L_shl( L_mult0( sub( hStereoDft->band_limits[hStereoDft->res_cod_band_max], 1 ), hStereoDft->N ), 1 );
Word16 exp;
- tmp = BASOP_Util_Divide3232_Scale_cadence( tmp, hStereoDft->NFFT, &exp );
+ tmp = BASOP_Util_Divide3232_Scale_newton( tmp, hStereoDft->NFFT, &exp );
hStereoDft->res_cod_line_max = extract_l( L_shr( tmp, sub( 31, exp ) ) );
move16();
// hStereoDft->res_cod_line_max = 8 * (hStereoDft->res_cod_line_max / 8);
@@ -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;
@@ -1226,7 +1218,7 @@ Word32 stereo_dft_enc_synthesize_fx(
zp = STEREO_DFT_ZP_12k8_ENC;
move16();
// fac = (float) ( NFFT ) / (float) ( hStereoDft->NFFT );
- fac_fx = BASOP_Util_Divide3232_Scale_cadence( NFFT, hStereoDft->NFFT, &temp_exp );
+ fac_fx = BASOP_Util_Divide3232_Scale_newton( NFFT, hStereoDft->NFFT, &temp_exp );
fac_fx = L_shl( fac_fx, temp_exp );
ovl = STEREO_DFT_OVL_12k8;
move16();
@@ -1250,7 +1242,7 @@ Word32 stereo_dft_enc_synthesize_fx(
zp = STEREO_DFT_ZP_16k_ENC;
move16();
// fac = (float) ( NFFT ) / (float) ( hStereoDft->NFFT );
- fac_fx = BASOP_Util_Divide3232_Scale_cadence( NFFT, hStereoDft->NFFT, &temp_exp );
+ fac_fx = BASOP_Util_Divide3232_Scale_newton( NFFT, hStereoDft->NFFT, &temp_exp );
fac_fx = L_shl( fac_fx, temp_exp );
ovl = STEREO_DFT_OVL_16k;
move16();
@@ -1283,7 +1275,7 @@ Word32 stereo_dft_enc_synthesize_fx(
zp = STEREO_DFT_ZP_32k_ENC;
move16();
// fac = (float) ( NFFT ) / (float) ( hStereoDft->NFFT );
- fac_fx = BASOP_Util_Divide3232_Scale_cadence( NFFT, hStereoDft->NFFT, &temp_exp );
+ fac_fx = BASOP_Util_Divide3232_Scale_newton( NFFT, hStereoDft->NFFT, &temp_exp );
fac_fx = L_shl( fac_fx, temp_exp );
ovl = STEREO_DFT_OVL_32k;
move16();
@@ -1307,7 +1299,7 @@ Word32 stereo_dft_enc_synthesize_fx(
zp = STEREO_DFT_ZP_8k_ENC;
move16();
// fac = (float) ( NFFT ) / (float) ( hStereoDft->NFFT );
- fac_fx = BASOP_Util_Divide3232_Scale_cadence( NFFT, hStereoDft->NFFT, &temp_exp );
+ fac_fx = BASOP_Util_Divide3232_Scale_newton( NFFT, hStereoDft->NFFT, &temp_exp );
fac_fx = L_shl( fac_fx, temp_exp );
ovl = STEREO_DFT_OVL_8k;
move16();
@@ -1511,7 +1503,7 @@ Word32 stereo_dft_enc_synthesize_fx(
move32();
// output[offset + N + i] = ( tmp[zp + N + i] - ifft_deviation ) / win_ana[ovl - 1 - i] + ifft_deviation;
Word16 L_temp_e;
- Word32 L_temp = BASOP_Util_Divide3232_Scale_cadence( L_sub_sat( tmp_fx[zp + N + i], ifft_deviation ), L_deposit_h( win_ana_fx[ovl - 1 - i] ), &L_temp_e );
+ Word32 L_temp = BASOP_Util_Divide3232_Scale_newton( L_sub_sat( tmp_fx[zp + N + i], ifft_deviation ), L_deposit_h( win_ana_fx[ovl - 1 - i] ), &L_temp_e );
L_temp = L_shl_sat( L_temp, L_temp_e );
output_fx[offset + N + i] = L_add_sat( L_temp, ifft_deviation ); // Q15
move32();
@@ -1733,7 +1725,7 @@ void stereo_dft_enc_process_fx(
}
// if ( fabsf( hStereoDft->hItd->deltaItd[k_offset] * 32000.f / input_Fs ) > 80.0f )
- tmp_32fx = L_abs( BASOP_Util_Divide3232_Scale_cadence( hStereoDft->hItd->deltaItd_fx[k_offset], input_Fs, &tmp_e ) );
+ tmp_32fx = L_abs( BASOP_Util_Divide3232_Scale_newton( hStereoDft->hItd->deltaItd_fx[k_offset], input_Fs, &tmp_e ) );
tmp_e = add( tmp_e, 15 - 31 );
IF( BASOP_Util_Cmp_Mant32Exp( tmp_32fx, tmp_e, 5368709 /* 80.0f / 32000.f in Q31 */, 0 ) > 0 )
{
@@ -2026,13 +2018,13 @@ void stereo_dft_enc_process_fx(
// wR = sqrtf( 0.5f * ( comb_nrgL + comb_nrgR ) + frac_dot_prod ) / sum_abs;
L_tmp1 = BASOP_Util_Add_Mant32Exp( L_tmp1, sub( L_tmp1_e, 1 ), frac_dot_prod, frac_dot_prod_e, &L_tmp1_e );
L_tmp1 = Sqrt32( L_tmp1, &L_tmp1_e );
- wR = BASOP_Util_Divide3232_Scale_cadence( L_tmp1, sum_abs, &wR_e );
+ wR = BASOP_Util_Divide3232_Scale_newton( L_tmp1, sum_abs, &wR_e );
wR_e = add( wR_e, sub( L_tmp1_e, sum_abs_e ) );
// wL = wR + sqrtf( 2.f ) * ( 1.f - ( sqrtf( Sr + Si ) / sum_abs ) );
L_tmp1 = BASOP_Util_Add_Mant32Exp( Sr, Sr_e, Si, Si_e, &L_tmp1_e );
L_tmp1 = Sqrt32( L_tmp1, &L_tmp1_e );
- L_tmp2 = BASOP_Util_Divide3232_Scale_cadence( L_tmp1, sum_abs, &L_tmp2_e );
+ L_tmp2 = BASOP_Util_Divide3232_Scale_newton( L_tmp1, sum_abs, &L_tmp2_e );
L_tmp2_e = add( L_tmp2_e, sub( L_tmp1_e, sum_abs_e ) );
L_tmp2 = L_shl_sat( L_tmp2, L_tmp2_e ); // Q31 saturation expected
L_tmp1 = L_sub( MAX_32, L_tmp2 ); // Q31
@@ -2111,13 +2103,13 @@ void stereo_dft_enc_process_fx(
// wR = sqrtf( 0.5f * ( comb_nrgL + comb_nrgR ) + frac_dot_prod ) / sum_abs;
L_tmp1 = BASOP_Util_Add_Mant32Exp( L_tmp1, sub( L_tmp1_e, 1 ), frac_dot_prod, frac_dot_prod_e, &L_tmp1_e );
L_tmp1 = Sqrt32( L_tmp1, &L_tmp1_e );
- wR = BASOP_Util_Divide3232_Scale_cadence( L_tmp1, sum_abs, &wR_e );
+ wR = BASOP_Util_Divide3232_Scale_newton( L_tmp1, sum_abs, &wR_e );
wR_e = add( wR_e, sub( L_tmp1_e, sum_abs_e ) );
// wL = wR + sqrtf( 2.f ) * ( 1.f - ( sqrtf( Sr + Si ) / sum_abs ) );
L_tmp1 = BASOP_Util_Add_Mant32Exp( Sr, Sr_e, Si, Si_e, &L_tmp1_e );
L_tmp1 = Sqrt32( L_tmp1, &L_tmp1_e );
- L_tmp2 = BASOP_Util_Divide3232_Scale_cadence( L_tmp1, sum_abs, &L_tmp2_e );
+ L_tmp2 = BASOP_Util_Divide3232_Scale_newton( L_tmp1, sum_abs, &L_tmp2_e );
L_tmp2_e = add( L_tmp2_e, sub( L_tmp1_e, sum_abs_e ) );
L_tmp2 = L_shl_sat( L_tmp2, L_tmp2_e ); // Q31 saturation expected
L_tmp1 = L_sub( MAX_32, L_tmp2 ); // Q31
@@ -2191,7 +2183,7 @@ void stereo_dft_enc_process_fx(
// wR = sqrtf( 0.5f * ( sum_nrg_L2 + sum_nrg_R2 ) + dot_prod_nrg_ratio[b] ) / sum_abs;
L_tmp1 = BASOP_Util_Add_Mant32Exp( L_tmp3, sub( L_tmp3_e, 1 ), dot_prod_nrg_ratio_fx[b], dot_prod_nrg_ratio_fx_e[b], &L_tmp1_e );
L_tmp1 = Sqrt32( L_tmp1, &L_tmp1_e );
- wR = BASOP_Util_Divide3232_Scale_cadence( L_tmp1, sum_abs, &wR_e );
+ wR = BASOP_Util_Divide3232_Scale_newton( L_tmp1, sum_abs, &wR_e );
wR_e = add( wR_e, sub( L_tmp1_e, sum_abs_e ) );
// wL = wR + sqrtf( 2.f ) * ( 1.f - sqrtf( sum_nrg_Mid ) / sum_abs );
@@ -2200,7 +2192,7 @@ void stereo_dft_enc_process_fx(
L_tmp1_e = sum_nrg_Mid_e;
move16();
L_tmp1 = Sqrt32( L_tmp1, &L_tmp1_e );
- L_tmp2 = BASOP_Util_Divide3232_Scale_cadence( L_tmp1, sum_abs, &L_tmp2_e );
+ L_tmp2 = BASOP_Util_Divide3232_Scale_newton( L_tmp1, sum_abs, &L_tmp2_e );
L_tmp2_e = add( L_tmp2_e, sub( L_tmp1_e, sum_abs_e ) );
L_tmp2 = L_shl_sat( L_tmp2, L_tmp2_e ); // Q31 saturation expected
L_tmp1 = L_sub( MAX_32, L_tmp2 ); // Q31
@@ -2478,7 +2470,7 @@ static void stereo_dft_enc_get_res_cod_mode_flag_fx(
L_tmp1 = L_sub( MAX_32, g ); // Q31
L_tmp2 = BASOP_Util_Add_Mant32Exp( hStereoDft->res_cod_NRG_S_fx[b], hStereoDft->res_cod_NRG_S_fx_e[b], Mpy_32_32( Mpy_32_32( L_tmp1, L_tmp1 ), hStereoDft->res_cod_NRG_M_fx[b] ), hStereoDft->res_cod_NRG_M_fx_e[b], &L_tmp2_e );
L_tmp2 = BASOP_Util_Add_Mant32Exp( L_tmp2, L_tmp2_e, MAX_32, 0, &L_tmp2_e );
- L_tmp1 = BASOP_Util_Divide3232_Scale_cadence( hStereoDft->res_cod_NRG_S_fx[b], L_tmp2, &L_tmp1_e );
+ L_tmp1 = BASOP_Util_Divide3232_Scale_newton( hStereoDft->res_cod_NRG_S_fx[b], L_tmp2, &L_tmp1_e );
L_tmp1_e = add( L_tmp1_e, sub( hStereoDft->res_cod_NRG_S_fx_e[b], L_tmp2_e ) );
L_tmp1 = L_shl( L_tmp1, L_tmp1_e ); // Q31
*res_dmx_ratio = L_max( L_tmp1, *res_dmx_ratio );
@@ -2494,7 +2486,7 @@ static void stereo_dft_enc_get_res_cod_mode_flag_fx(
/*Calculate the energy ratio of the inter-frame */
//*frame_nrg_ratio = dmx_res_all / hStereoDft->dmx_res_all_prev;
- *frame_nrg_ratio = BASOP_Util_Divide3232_Scale_cadence( dmx_res_all, hStereoDft->dmx_res_all_prev_fx, &L_tmp1_e );
+ *frame_nrg_ratio = BASOP_Util_Divide3232_Scale_newton( dmx_res_all, hStereoDft->dmx_res_all_prev_fx, &L_tmp1_e );
move32();
L_tmp1_e = add( L_tmp1_e, sub( dmx_res_all_e, hStereoDft->dmx_res_all_prev_fx_e ) );
*frame_nrg_ratio = L_shr_r_sat( *frame_nrg_ratio, sub( 3, L_tmp1_e ) ); // Q28
@@ -2741,7 +2733,7 @@ void stereo_dft_enc_res_fx(
L_tmp2_e = hStereoDft->res_cod_NRG_M_fx_e[b];
L_tmp2 = BASOP_Util_Add_Mant32Exp( L_tmp2, L_tmp2_e, hStereoDft->res_cod_NRG_S_fx[b], hStereoDft->res_cod_NRG_S_fx_e[b], &L_tmp2_e );
L_tmp2 = BASOP_Util_Add_Mant32Exp( L_tmp2, L_tmp2_e, MAX_32, 0, &L_tmp2_e );
- in_phase_ratio = BASOP_Util_Divide3232_Scale_cadence( L_tmp1, L_tmp2, &in_phase_ratio_e );
+ in_phase_ratio = BASOP_Util_Divide3232_Scale_newton( L_tmp1, L_tmp2, &in_phase_ratio_e );
in_phase_ratio_e = add( in_phase_ratio_e, sub( hStereoDft->res_cod_NRG_M_fx_e[b], L_tmp2_e ) );
in_phase_ratio = L_shl_sat( in_phase_ratio, in_phase_ratio_e ); // Q31 : bound from 0.0 to 1.0
in_phase_ratio = L_max( 0, in_phase_ratio );
@@ -3512,7 +3504,7 @@ static void stereo_dft_enc_compute_prm_fx(
W_shift = W_norm( W_tmp );
L_tmp2 = W_extract_h( W_shl( W_tmp, W_shift ) );
L_tmp2_e = sub( add( sub_nrg_DMX2_e, 31 ), W_shift );
- L_tmp = BASOP_Util_Divide3232_Scale_cadence( L_tmp1, L_tmp2, &L_tmp_e );
+ L_tmp = BASOP_Util_Divide3232_Scale_newton( L_tmp1, L_tmp2, &L_tmp_e );
L_tmp_e = add( L_tmp_e, sub( L_tmp1_e, L_tmp2_e ) );
L_tmp = L_shl( L_tmp, L_tmp_e ); // Q31hStereoDft->gainIPD_sm_fx = L_add( L_shr( hStereoDft->gainIPD_sm_fx, 1 ), L_
gain_IPD = L_add_sat( gain_IPD, L_tmp ); // Q31: saturation expected
@@ -3597,7 +3589,7 @@ static void stereo_dft_enc_compute_prm_fx(
// dot_prod_nrg_ratio[b2] = sum_past_dot_prod_abs2 / ( sum_past_nrgL2 + sum_past_nrgR2 + EPSILON );
L_tmp2 = BASOP_Util_Add_Mant32Exp( sum_past_nrgL2, sum_past_nrgL2_e, sum_past_nrgR2, sum_past_nrgR2_e, &L_tmp2_e );
L_tmp2 = BASOP_Util_Add_Mant32Exp( L_tmp2, L_tmp2_e, EPSILON_FX_M, EPSILON_FX_E, &L_tmp2_e );
- dot_prod_nrg_ratio_fx[b2] = BASOP_Util_Divide3232_Scale_cadence( sum_past_dot_prod_abs2, L_tmp2, &L_tmp_e );
+ dot_prod_nrg_ratio_fx[b2] = BASOP_Util_Divide3232_Scale_newton( sum_past_dot_prod_abs2, L_tmp2, &L_tmp_e );
move32();
L_tmp_e = add( L_tmp_e, sub( sum_past_dot_prod_abs2_e, L_tmp2_e ) );
dot_prod_nrg_ratio_fx[b2] = L_shl( dot_prod_nrg_ratio_fx[b2], L_tmp_e ); // Q31
@@ -3624,7 +3616,7 @@ static void stereo_dft_enc_compute_prm_fx(
// dot_prod_nrg_ratio[b2] /= ( sum_nrg_L2 + sum_nrg_R2 + EPSILON );
L_tmp2 = BASOP_Util_Add_Mant32Exp( sum_nrg_L2, sum_nrg_L2_e, sum_nrg_R2, sum_nrg_R2_e, &L_tmp2_e );
L_tmp2 = BASOP_Util_Add_Mant32Exp( L_tmp2, L_tmp2_e, EPSILON_FX_M, EPSILON_FX_E, &L_tmp2_e );
- dot_prod_nrg_ratio_fx[b2] = BASOP_Util_Divide3232_Scale_cadence( dot_prod_nrg_ratio_fx[b2], L_tmp2, &L_tmp_e );
+ dot_prod_nrg_ratio_fx[b2] = BASOP_Util_Divide3232_Scale_newton( dot_prod_nrg_ratio_fx[b2], L_tmp2, &L_tmp_e );
move32();
L_tmp_e = add( L_tmp_e, sub( dot_prod_nrg_ratio_fx_e[b2], L_tmp2_e ) );
dot_prod_nrg_ratio_fx[b2] = L_shl( dot_prod_nrg_ratio_fx[b2], L_tmp_e ); // Q31
@@ -3691,7 +3683,7 @@ static void stereo_dft_enc_compute_prm_fx(
}
// c = sqrtf( sum_past_nrgL / sum_past_nrgR );
- c = BASOP_Util_Divide3232_Scale_cadence( sum_past_nrgL, sum_past_nrgR, &c_e );
+ c = BASOP_Util_Divide3232_Scale_newton( sum_past_nrgL, sum_past_nrgR, &c_e );
c_e = add( c_e, sub( sum_past_nrgL_e, sum_past_nrgR_e ) );
c = Sqrt32( c, &c_e );
// sum_past_nrg_dmx = sum_past_nrgL + sum_past_nrgR + 2 * sum_past_dot_prod_abs;
@@ -3718,7 +3710,7 @@ static void stereo_dft_enc_compute_prm_fx(
{
// g = ( sum_past_nrgL - sum_past_nrgR ) / ( sum_past_nrg_dmx );
L_tmp1 = BASOP_Util_Add_Mant32Exp( sum_past_nrgL, sum_past_nrgL_e, L_negate( sum_past_nrgR ), sum_past_nrgR_e, &L_tmp1_e );
- L_tmp = BASOP_Util_Divide3232_Scale_cadence( L_tmp1, sum_past_nrg_dmx, &L_tmp_e );
+ L_tmp = BASOP_Util_Divide3232_Scale_newton( L_tmp1, sum_past_nrg_dmx, &L_tmp_e );
L_tmp_e = add( L_tmp_e, sub( L_tmp1_e, sum_past_nrg_dmx_e ) );
g = L_shl_sat( L_tmp, L_tmp_e ); // Q31 saturation expected
pSideGain[b] = g;
@@ -3731,7 +3723,7 @@ static void stereo_dft_enc_compute_prm_fx(
// pSideGain[b] = ( c - 1 ) / ( c + 1 );
L_tmp1 = BASOP_Util_Add_Mant32Exp( c, c_e, MIN_32, 0, &L_tmp1_e );
L_tmp2 = BASOP_Util_Add_Mant32Exp( c, c_e, MAX_32, 0, &L_tmp2_e );
- L_tmp = BASOP_Util_Divide3232_Scale_cadence( L_tmp1, L_tmp2, &L_tmp_e );
+ L_tmp = BASOP_Util_Divide3232_Scale_newton( L_tmp1, L_tmp2, &L_tmp_e );
L_tmp_e = add( L_tmp_e, sub( L_tmp1_e, L_tmp2_e ) );
pSideGain[b] = L_shl_sat( L_tmp, L_tmp_e ); // Q31 saturation expected
move32();
@@ -3774,7 +3766,7 @@ static void stereo_dft_enc_compute_prm_fx(
// pPredGain[b] = sqrtf( pPredGain[b] / ( reg + sum_past_nrg_dmx ) );
L_tmp2 = BASOP_Util_Add_Mant32Exp( reg, reg_e, sum_past_nrg_dmx, sum_past_nrg_dmx_e, &L_tmp2_e );
- L_tmp1 = BASOP_Util_Divide3232_Scale_cadence( L_tmp, L_tmp2, &L_tmp1_e );
+ L_tmp1 = BASOP_Util_Divide3232_Scale_newton( L_tmp, L_tmp2, &L_tmp1_e );
L_tmp1_e = add( L_tmp1_e, sub( L_tmp_e, L_tmp2_e ) );
L_tmp1 = Sqrt32( L_tmp1, &L_tmp1_e );
pPredGain[b] = L_shl( L_tmp1, L_tmp1_e ); // Q31
@@ -3913,14 +3905,14 @@ static void stereo_dft_enc_compute_prm_fx(
}
// c = sqrtf( sum_energy_L / sum_energy_R );
- c = BASOP_Util_Divide3232_Scale_cadence( sum_energy_L, sum_energy_R, &c_e );
+ c = BASOP_Util_Divide3232_Scale_newton( sum_energy_L, sum_energy_R, &c_e );
c_e = add( c_e, sub( sum_energy_L_e, sum_energy_R_e ) );
c = Sqrt32( c, &c_e );
// g = fabsf( ( c - 1 ) / ( c + 1 ) );
L_tmp1 = BASOP_Util_Add_Mant32Exp( c, c_e, MIN_32, 0, &L_tmp1_e );
L_tmp2 = BASOP_Util_Add_Mant32Exp( c, c_e, MAX_32, 0, &L_tmp2_e );
- g = L_abs( BASOP_Util_Divide3232_Scale_cadence( L_tmp1, L_tmp2, &L_tmp_e ) );
+ g = L_abs( BASOP_Util_Divide3232_Scale_newton( L_tmp1, L_tmp2, &L_tmp_e ) );
L_tmp_e = add( L_tmp_e, sub( L_tmp1_e, L_tmp2_e ) );
g = L_shl_sat( g, L_tmp_e ); // Q31 saturation expected
IF( GT_32( g, 1717986918 /*0.8f in Q31*/ ) )
@@ -4326,7 +4318,7 @@ static Word32 stereo_dft_calc_mean_ipd_change_fx(
ipd_mean_change = L_add( ipd_mean_change, ipd_change[b] );
}
// ipd_mean_change /= gipd_band_max;
- ipd_mean_change = BASOP_Util_Divide3232_Scale_cadence( ipd_mean_change, gipd_band_max, &ipd_mean_change_e );
+ ipd_mean_change = BASOP_Util_Divide3232_Scale_newton( ipd_mean_change, gipd_band_max, &ipd_mean_change_e );
ipd_mean_change_e = add( ipd_mean_change_e, 18 - 31 );
ipd_mean_change = L_shr( ipd_mean_change, sub( 18, ipd_mean_change_e ) ); // Q13
@@ -4510,13 +4502,13 @@ static void stereo_dft_enc_get_reverb_flag_fx(
FOR( b = 0; b <= s_min( hStereoDft->nbands, 6 ); b++ ) /* choose the subbands used for stereo filling */
{
// norm_dmx = ((hStereoDft->band_limits[b + 1] - hStereoDft->band_limits[b]) / sub_nrg_DMX[b]);
- norm_dmx = BASOP_Util_Divide3232_Scale_cadence( sub( hStereoDft->band_limits[b + 1], hStereoDft->band_limits[b] ), sub_nrg_DMX[b], &norm_dmx_e );
+ norm_dmx = BASOP_Util_Divide3232_Scale_newton( sub( hStereoDft->band_limits[b + 1], hStereoDft->band_limits[b] ), sub_nrg_DMX[b], &norm_dmx_e );
norm_dmx_e = add( norm_dmx_e, sub( 31, sub_nrg_DMX_e[b] ) );
// norm_l = ((hStereoDft->band_limits[b + 1] - hStereoDft->band_limits[b]) / sub_nrg_L[b]);
- norm_l = BASOP_Util_Divide3232_Scale_cadence( sub( hStereoDft->band_limits[b + 1], hStereoDft->band_limits[b] ), sub_nrg_L[b], &norm_l_e );
+ norm_l = BASOP_Util_Divide3232_Scale_newton( sub( hStereoDft->band_limits[b + 1], hStereoDft->band_limits[b] ), sub_nrg_L[b], &norm_l_e );
norm_l_e = add( norm_l_e, sub( 31, sub_nrg_L_e[b] ) );
// norm_r = ((hStereoDft->band_limits[b + 1] - hStereoDft->band_limits[b]) / sub_nrg_R[b]);
- norm_r = BASOP_Util_Divide3232_Scale_cadence( sub( hStereoDft->band_limits[b + 1], hStereoDft->band_limits[b] ), sub_nrg_R[b], &norm_r_e );
+ norm_r = BASOP_Util_Divide3232_Scale_newton( sub( hStereoDft->band_limits[b + 1], hStereoDft->band_limits[b] ), sub_nrg_R[b], &norm_r_e );
norm_r_e = add( norm_r_e, sub( 31, sub_nrg_R_e[b] ) );
FOR( i = hStereoDft->band_limits[b]; i < hStereoDft->band_limits[b + 1]; i++ ) /* normalization on each subbands */
@@ -4562,13 +4554,13 @@ static void stereo_dft_enc_get_reverb_flag_fx(
FOR( ; b < s_min( hStereoDft->nbands, 10 ); b++ ) /* choose the subbands used for stereo filling */
{
// norm_dmx = ((hStereoDft->band_limits[b + 1] - hStereoDft->band_limits[b]) / sub_nrg_DMX[b]);
- norm_dmx = BASOP_Util_Divide3232_Scale_cadence( sub( hStereoDft->band_limits[b + 1], hStereoDft->band_limits[b] ), sub_nrg_DMX[b], &norm_dmx_e );
+ norm_dmx = BASOP_Util_Divide3232_Scale_newton( sub( hStereoDft->band_limits[b + 1], hStereoDft->band_limits[b] ), sub_nrg_DMX[b], &norm_dmx_e );
norm_dmx_e = add( norm_dmx_e, sub( 31, sub_nrg_DMX_e[b] ) );
// norm_l = ((hStereoDft->band_limits[b + 1] - hStereoDft->band_limits[b]) / sub_nrg_L[b]);
- norm_l = BASOP_Util_Divide3232_Scale_cadence( sub( hStereoDft->band_limits[b + 1], hStereoDft->band_limits[b] ), sub_nrg_L[b], &norm_l_e );
+ norm_l = BASOP_Util_Divide3232_Scale_newton( sub( hStereoDft->band_limits[b + 1], hStereoDft->band_limits[b] ), sub_nrg_L[b], &norm_l_e );
norm_l_e = add( norm_l_e, sub( 31, sub_nrg_L_e[b] ) );
// norm_r = ((hStereoDft->band_limits[b + 1] - hStereoDft->band_limits[b]) / sub_nrg_R[b]);
- norm_r = BASOP_Util_Divide3232_Scale_cadence( sub( hStereoDft->band_limits[b + 1], hStereoDft->band_limits[b] ), sub_nrg_R[b], &norm_r_e );
+ norm_r = BASOP_Util_Divide3232_Scale_newton( sub( hStereoDft->band_limits[b + 1], hStereoDft->band_limits[b] ), sub_nrg_R[b], &norm_r_e );
norm_r_e = add( norm_r_e, sub( 31, sub_nrg_R_e[b] ) );
FOR( i = hStereoDft->band_limits[b]; i < hStereoDft->band_limits[b + 1]; i++ ) /* normalization on each subbands */
@@ -4614,7 +4606,7 @@ static void stereo_dft_enc_get_reverb_flag_fx(
FOR( b = 0; b < hStereoDft->nbands; b++ ) /* choose the subbands used for stereo filling */
{
// sub_nrg_DMX[b] /= (hStereoDft->band_limits[b + 1] - hStereoDft->band_limits[b]);
- sub_nrg_DMX[b] = BASOP_Util_Divide3232_Scale_cadence( sub_nrg_DMX[b], sub( hStereoDft->band_limits[b + 1], hStereoDft->band_limits[b] ), &L_tmp_e );
+ sub_nrg_DMX[b] = BASOP_Util_Divide3232_Scale_newton( sub_nrg_DMX[b], sub( hStereoDft->band_limits[b + 1], hStereoDft->band_limits[b] ), &L_tmp_e );
move32();
sub_nrg_DMX_e[b] = add( L_tmp_e, sub( sub_nrg_DMX_e[b], 31 ) );
move16();
@@ -4735,12 +4727,12 @@ static void stereo_dft_enc_get_reverb_flag_fx(
// fac = ((diff_l_l > diff_r_l) ? diff_r_l / diff_l_l : diff_l_l / diff_r_l);
IF( BASOP_Util_Cmp_Mant32Exp( diff_l_l, diff_l_l_e, diff_r_l, diff_r_l_e ) > 0 )
{
- fac = BASOP_Util_Divide3232_Scale_cadence( diff_r_l, diff_l_l, &L_tmp_e );
+ fac = BASOP_Util_Divide3232_Scale_newton( diff_r_l, diff_l_l, &L_tmp_e );
L_tmp_e = add( L_tmp_e, sub( diff_r_l_e, diff_l_l_e ) );
}
ELSE
{
- fac = BASOP_Util_Divide3232_Scale_cadence( diff_l_l, diff_r_l, &L_tmp_e );
+ fac = BASOP_Util_Divide3232_Scale_newton( diff_l_l, diff_r_l, &L_tmp_e );
L_tmp_e = add( L_tmp_e, sub( diff_l_l_e, diff_r_l_e ) );
}
fac = L_shl_sat( fac, L_tmp_e ); // Q31
@@ -4792,7 +4784,7 @@ static Word32 stereo_dft_gain_offset_fx(
* function @ 32kHz from which the values are interpolated: */
k0 = shr( tau, 3 );
// alpha = s_and(tau, 7) / 8.f;
- alpha = BASOP_Util_Divide3232_Scale_cadence( s_and( tau, 7 ), 8, &alpha_e );
+ alpha = BASOP_Util_Divide3232_Scale_newton( s_and( tau, 7 ), 8, &alpha_e );
alpha = L_shl( alpha, alpha_e ); // Q31
// wnt = (1 - alpha) * Wn_table[k0] + alpha * Wn_table[k0 + 1];
wnt = L_add( Mpy_32_32( L_sub( MAX_32, alpha ), Wn_table_fx[k0] ), Mpy_32_32( alpha, Wn_table_fx[k0 + 1] ) ); // Q31
@@ -4803,12 +4795,12 @@ static Word32 stereo_dft_gain_offset_fx(
L_tmp1 = BASOP_Util_Add_Mant32Exp( MAX_32, 0, c, c_e, &L_tmp1_e );
L_tmp1 = Mpy_32_32( L_tmp1, L_tmp1 );
L_tmp1_e = shl( L_tmp1_e, 1 );
- L_tmp2 = BASOP_Util_Divide3232_Scale_cadence( L_tmp, L_tmp1, &L_tmp2_e );
+ L_tmp2 = BASOP_Util_Divide3232_Scale_newton( L_tmp, L_tmp1, &L_tmp2_e );
L_tmp2_e = add( add( L_tmp2_e, sub( L_tmp_e, L_tmp1_e ) ), 3 /*multiply by 8*/ );
L_tmp2 = Mpy_32_32( L_tmp2, L_sub( MAX_32, wnt ) );
L_tmp1 = BASOP_Util_Add_Mant32Exp( MAX_32, 0, L_tmp, L_tmp_e, &L_tmp1_e );
L_tmp1 = BASOP_Util_Add_Mant32Exp( L_tmp1, L_tmp1_e, Mpy_32_32( c, wnt ), add( c_e, 1 ), &L_tmp1_e );
- L_tmp = BASOP_Util_Divide3232_Scale_cadence( L_tmp2, L_tmp1, &L_tmp_e );
+ L_tmp = BASOP_Util_Divide3232_Scale_newton( L_tmp2, L_tmp1, &L_tmp_e );
L_tmp_e = add( L_tmp_e, sub( L_tmp2_e, L_tmp1_e ) );
L_tmp = Sqrt32( L_tmp, &L_tmp_e );
go = L_shl( L_tmp, L_tmp_e );
@@ -4838,7 +4830,7 @@ static void stereo_dft_enc_calculate_nrg_for_icbwe_fx(
Word32 tmp;
// bandResDft = ( (float) input_Fs ) / hStereoDft->NFFT;
- bandResDft = BASOP_Util_Divide3232_Scale_cadence( input_Fs, hStereoDft->NFFT, &bandResDft_e );
+ bandResDft = BASOP_Util_Divide3232_Scale_newton( input_Fs, hStereoDft->NFFT, &bandResDft_e );
// shbBins[0] = (int16_t) ( 6400 / bandResDft );
shbBins[0] = BASOP_Util_Divide3232_Scale( 6400, bandResDft, &tmp_e );
move16();
diff --git a/lib_enc/ivas_stereo_dft_enc_itd_fx.c b/lib_enc/ivas_stereo_dft_enc_itd_fx.c
index 4e030ba010b24890822a992f8f93a5fa7eabf6d7..1beacd19a265a59b2acec77ecc942480f86abe82 100644
--- a/lib_enc/ivas_stereo_dft_enc_itd_fx.c
+++ b/lib_enc/ivas_stereo_dft_enc_itd_fx.c
@@ -232,7 +232,7 @@ static Word32 itd_vad_ms_snr_calc_fx(
move32();
}
// E_band[i] = E_band[i] / ( itd_vad_band_tbl[i + 1] - itd_vad_band_tbl[i] );
- E_band[i] = BASOP_Util_Divide3232_Scale_cadence( E_band[i], L_sub( itd_vad_band_tbl[i + 1], itd_vad_band_tbl[i] ), &exp );
+ E_band[i] = BASOP_Util_Divide3232_Scale_newton( E_band[i], L_sub( itd_vad_band_tbl[i + 1], itd_vad_band_tbl[i] ), &exp );
move32();
E_band_e[i] = add( exp, sub( E_band_e[i], 31 ) );
move16();
@@ -245,7 +245,7 @@ static Word32 itd_vad_ms_snr_calc_fx(
FOR( i = 0; i < STEREO_DFT_ITD_VAD_BAND_NUM; i++ )
{
// snr[i] = E_band[i] / E_band_n[i];
- snr[i] = BASOP_Util_Divide3232_Scale_cadence( E_band[i], E_band_n[i], &snr_e[i] );
+ snr[i] = BASOP_Util_Divide3232_Scale_newton( E_band[i], E_band_n[i], &snr_e[i] );
move32();
snr_e[i] = add( snr_e[i], sub( E_band_e[i], E_band_n_exp[i] ) );
move16();
@@ -327,7 +327,7 @@ static void itd_vad_background_update_fx(
L_temp = L_shl( *vad_frm_cnt, q_temp );
L_temp_e = sub( 31, q_temp );
L_temp = BASOP_Util_Add_Mant32Exp( Mpy_32_32( E_band_n[i], L_temp ), add( E_band_n_exp[i], L_temp_e ), E_band[i], E_band_e[i], &L_temp_e );
- E_band_n[i] = BASOP_Util_Divide3232_Scale_cadence( L_temp, L_add( *vad_frm_cnt, 1 ), &E_band_n_e_tmp );
+ E_band_n[i] = BASOP_Util_Divide3232_Scale_newton( L_temp, L_add( *vad_frm_cnt, 1 ), &E_band_n_e_tmp );
move32();
E_band_n_exp[i] = add( E_band_n_e_tmp, sub( L_temp_e, 31 ) );
move16();
@@ -536,7 +536,7 @@ static Word32 calc_mean_E_ratio_fx(
L_temp1 = BASOP_Util_Add_Mant32Exp( acorr, acorr_e, fi[b], fi_e[b], &L_temp1_e );
L_temp2 = BASOP_Util_Add_Mant32Exp( acorr, acorr_e, L_negate( fi[b] ), fi_e[b], &L_temp2_e );
L_temp2 = BASOP_Util_Add_Mant32Exp( L_temp2, L_temp2_e, EPSILON_FX_M, EPSILON_FX_E, &L_temp2_e );
- Er[b] = BASOP_Util_Divide3232_Scale_cadence( L_temp1, L_temp2, &Er_e[b] );
+ Er[b] = BASOP_Util_Divide3232_Scale_newton( L_temp1, L_temp2, &Er_e[b] );
move32();
Er_e[b] = add( Er_e[b], sub( L_temp1_e, L_temp2_e ) );
move16();
@@ -585,7 +585,7 @@ static Word32 calc_mean_E_ratio_fx(
L_temp1 = BASOP_Util_Add_Mant32Exp( acorr, acorr_e, total_fi, total_fi_e, &L_temp1_e );
L_temp2 = BASOP_Util_Add_Mant32Exp( acorr, acorr_e, L_negate( total_fi ), total_fi_e, &L_temp2_e );
L_temp2 = BASOP_Util_Add_Mant32Exp( L_temp2, L_temp2_e, EPSILON_FX_M, EPSILON_FX_E, &L_temp2_e );
- *total_mEr = BASOP_Util_Divide3232_Scale_cadence( L_temp1, L_temp2, total_mEr_e );
+ *total_mEr = BASOP_Util_Divide3232_Scale_newton( L_temp1, L_temp2, total_mEr_e );
move32();
*total_mEr_e = add( *total_mEr_e, sub( L_temp1_e, L_temp2_e ) );
move16();
@@ -1302,14 +1302,14 @@ void stereo_dft_enc_compute_itd_fx(
// g_ILD = sqrtf( sum_nrg_L / ( sum_nrg_R + 1.0f ) );
L_temp = BASOP_Util_Add_Mant32Exp( sum_nrg_R, sum_nrg_R_e, MAX_32, 0, &L_temp_e );
- g_ILD = BASOP_Util_Divide3232_Scale_cadence( sum_nrg_L, L_temp, &g_ILD_e );
+ g_ILD = BASOP_Util_Divide3232_Scale_newton( sum_nrg_L, L_temp, &g_ILD_e );
g_ILD_e = add( g_ILD_e, sub( sum_nrg_L_e, L_temp_e ) );
g_ILD = Sqrt32( g_ILD, &g_ILD_e );
// g_ILD = fabsf( ( g_ILD - 1 ) / ( g_ILD + 1 ) );
L_temp = BASOP_Util_Add_Mant32Exp( g_ILD, g_ILD_e, MIN_32, 0, &L_temp_e );
L_temp2 = BASOP_Util_Add_Mant32Exp( g_ILD, g_ILD_e, MAX_32, 0, &L_temp2_e );
- g_ILD = L_abs( BASOP_Util_Divide3232_Scale_cadence( L_temp, L_temp2, &g_ILD_e ) );
+ g_ILD = L_abs( BASOP_Util_Divide3232_Scale_newton( L_temp, L_temp2, &g_ILD_e ) );
g_ILD_e = add( g_ILD_e, sub( L_temp_e, L_temp2_e ) );
g_ILD = L_shl_sat( g_ILD, g_ILD_e ); // Q31
@@ -1339,7 +1339,7 @@ void stereo_dft_enc_compute_itd_fx(
// g_IPD = ( sum_nrg_L + sum_nrg_R + 2 * grand_dot_prod_real ) / grand_nrg_DMX;
L_temp = BASOP_Util_Add_Mant32Exp( sum_nrg_L, sum_nrg_L_e, sum_nrg_R, sum_nrg_R_e, &L_temp_e );
L_temp = BASOP_Util_Add_Mant32Exp( L_temp, L_temp_e, grand_dot_prod_real, add( grand_dot_prod_real_e, 1 ), &L_temp_e );
- g_IPD = BASOP_Util_Divide3232_Scale_cadence( L_temp, grand_nrg_DMX, &g_IPD_e );
+ g_IPD = BASOP_Util_Divide3232_Scale_newton( L_temp, grand_nrg_DMX, &g_IPD_e );
g_IPD_e = add( g_IPD_e, sub( L_temp_e, grand_nrg_DMX_e ) );
// if ( g_IPD >= 1.0f )
IF( BASOP_Util_Cmp_Mant32Exp( g_IPD, g_IPD_e, ONE_IN_Q29 - ONE_IN_Q14 /*Adjusting threshold for precision loss*/, 2 ) >= 0 )
@@ -1366,7 +1366,7 @@ void stereo_dft_enc_compute_itd_fx(
// angle_rot = fabsf( atanf( 2.0f * ( grand_dot_prod_real ) / ( sum_nrg_L - sum_nrg_R + 1.0f ) ) );
L_temp = BASOP_Util_Add_Mant32Exp( sum_nrg_L, sum_nrg_L_e, L_negate( sum_nrg_R ), sum_nrg_R_e, &L_temp_e );
L_temp = BASOP_Util_Add_Mant32Exp( L_temp, L_temp_e, MAX_32, 0, &L_temp_e );
- L_temp2 = BASOP_Util_Divide3232_Scale_cadence( grand_dot_prod_real, L_temp, &L_temp2_e );
+ L_temp2 = BASOP_Util_Divide3232_Scale_newton( grand_dot_prod_real, L_temp, &L_temp2_e );
L_temp2_e = add( L_temp2_e, sub( add( grand_dot_prod_real_e, 1 ), L_temp_e ) );
angle_rot = L_abs( BASOP_util_atan( L_shr_r_sat( L_temp2, ( sub( 6, L_temp2_e ) ) ) ) ); // Q14
// angle_rot = L_abs( BASOP_util_atan2( grand_dot_prod_real, L_temp, sub( add( grand_dot_prod_real_e, 1 ), L_temp_e ) ) ); // Q13
@@ -1378,7 +1378,7 @@ void stereo_dft_enc_compute_itd_fx(
// g_side = fabsf( sum_nrg_L - sum_nrg_R ) / ( grand_nrg_DMX );
L_temp = L_abs( BASOP_Util_Add_Mant32Exp( sum_nrg_L, sum_nrg_L_e, L_negate( sum_nrg_R ), sum_nrg_R_e, &L_temp_e ) );
- g_side = BASOP_Util_Divide3232_Scale_cadence( L_temp, grand_nrg_DMX, &g_side_e );
+ g_side = BASOP_Util_Divide3232_Scale_newton( L_temp, grand_nrg_DMX, &g_side_e );
g_side_e = add( g_side_e, sub( L_temp_e, grand_nrg_DMX_e ) );
g_side = L_shl_sat( g_side, g_side_e ); // Q31
g_side_e = 0;
@@ -1443,7 +1443,7 @@ void stereo_dft_enc_compute_itd_fx(
ELSE
{
// sfm_L = expf( log_prod_L / ( NFFT_mid ) ) / ( sum_abs_L / ( NFFT_mid ) );
- L_temp = BASOP_Util_Divide3232_Scale_cadence( log_prod_L, NFFT_mid, &L_temp_e );
+ L_temp = BASOP_Util_Divide3232_Scale_newton( log_prod_L, NFFT_mid, &L_temp_e );
L_temp_e = add( L_temp_e, sub( log_prod_L_e, 31 ) );
L_temp = BASOP_Util_fPow( 1459366444 /*2.718 in Q29*/, 2, L_temp, L_temp_e, &L_temp_e );
q_temp = norm_l( NFFT_mid );
@@ -1451,7 +1451,7 @@ void stereo_dft_enc_compute_itd_fx(
L_temp2_e = sub( 31, q_temp );
L_temp = Mpy_32_32( L_temp, L_temp2 );
L_temp_e = add( L_temp_e, L_temp2_e );
- sfm_L = BASOP_Util_Divide3232_Scale_cadence( L_temp, sum_abs_L, &sfm_L_e );
+ sfm_L = BASOP_Util_Divide3232_Scale_newton( L_temp, sum_abs_L, &sfm_L_e );
sfm_L_e = add( sfm_L_e, sub( L_temp_e, sum_abs_L_e ) );
sfm_L = L_shl_sat( sfm_L, sfm_L_e ); // Q31 - should be rechecked for -10dB tests
}
@@ -1467,7 +1467,7 @@ void stereo_dft_enc_compute_itd_fx(
ELSE
{
// sfm_R = expf( log_prod_R / ( NFFT_mid ) ) / ( sum_abs_R / ( NFFT_mid ) );
- L_temp = BASOP_Util_Divide3232_Scale_cadence( log_prod_R, NFFT_mid, &L_temp_e );
+ L_temp = BASOP_Util_Divide3232_Scale_newton( log_prod_R, NFFT_mid, &L_temp_e );
L_temp_e = add( L_temp_e, sub( log_prod_R_e, 31 ) );
L_temp = BASOP_Util_fPow( 1459366444 /*2.718 in Q29*/, 2, L_temp, L_temp_e, &L_temp_e );
q_temp = norm_l( NFFT_mid );
@@ -1475,7 +1475,7 @@ void stereo_dft_enc_compute_itd_fx(
L_temp2_e = sub( 31, q_temp );
L_temp = Mpy_32_32( L_temp, L_temp2 );
L_temp_e = add( L_temp_e, L_temp2_e );
- sfm_R = BASOP_Util_Divide3232_Scale_cadence( L_temp, sum_abs_R, &sfm_L_e );
+ sfm_R = BASOP_Util_Divide3232_Scale_newton( L_temp, sum_abs_R, &sfm_L_e );
sfm_R_e = add( sfm_L_e, sub( L_temp_e, sum_abs_R_e ) );
// sfm_R = L_shl_r( sfm_R, sfm_R_e ); // Q31
sfm_R = L_shl_sat( sfm_R, sfm_R_e ); // Q31
@@ -1662,18 +1662,11 @@ void stereo_dft_enc_compute_itd_fx(
move16();
}
// cng_xcorr_filt = max( min( CORR_FILT, 10.0f * CORR_FILT / ( hStereoDft->expectedNumUpdates + hStereoDft->currentNumUpdates ) ), sfm_L );
- IF( add( hStereoDft->expectedNumUpdates, hStereoDft->currentNumUpdates ) == 0 )
- {
- cng_xcorr_filt = CORR_FILT_Q31;
- move32();
- cng_xcorr_filt = L_max( cng_xcorr_filt, sfm_L ); // Q31
- }
- ELSE
- {
- cng_xcorr_filt = BASOP_Util_Divide3232_Scale_cadence( 8 /*10.0f * CORR_FILT*/, add( hStereoDft->expectedNumUpdates, hStereoDft->currentNumUpdates ), &cng_xcorr_filt_e );
- cng_xcorr_filt = L_shl_sat( cng_xcorr_filt, cng_xcorr_filt_e ); // Q31
- cng_xcorr_filt = L_max( L_min( CORR_FILT_Q31, cng_xcorr_filt ), sfm_L ); // Q31
- }
+
+ cng_xcorr_filt = BASOP_Util_Divide3232_Scale_newton( 8 /*10.0f * CORR_FILT*/, add( hStereoDft->expectedNumUpdates, hStereoDft->currentNumUpdates ), &cng_xcorr_filt_e );
+ cng_xcorr_filt = L_shl_sat( cng_xcorr_filt, cng_xcorr_filt_e ); // Q31
+ cng_xcorr_filt = L_max( L_min( CORR_FILT_Q31, cng_xcorr_filt ), sfm_L ); // Q31
+
hStereoDft->currentNumUpdates = add( hStereoDft->currentNumUpdates, 1 );
move16();
FOR( i = 1; i < NFFT / 4; i++ )
@@ -1729,17 +1722,17 @@ void stereo_dft_enc_compute_itd_fx(
{
/* expectedNumUpdates updated after call to dtx() in SID frames */
// cng_xcorr_filt = max( min( CORR_FILT, 10.0f * CORR_FILT / ( hStereoDft->expectedNumUpdates + hStereoDft->currentNumUpdates ) ), sfm_L );
- IF( add( hStereoDft->expectedNumUpdates, hStereoDft->currentNumUpdates ) == 0 )
+ IF( add( hStereoDft->expectedNumUpdates, hStereoDft->currentNumUpdates ) != 0 )
{
- cng_xcorr_filt = CORR_FILT_Q31;
- move32();
- cng_xcorr_filt = L_max( cng_xcorr_filt, sfm_L ); // Q31
+ cng_xcorr_filt = BASOP_Util_Divide3232_Scale_newton( 8 /*10.0f * CORR_FILT*/, add( hStereoDft->expectedNumUpdates, hStereoDft->currentNumUpdates ), &cng_xcorr_filt_e );
+ cng_xcorr_filt = L_shl_sat( cng_xcorr_filt, cng_xcorr_filt_e ); // Q31
+ cng_xcorr_filt = L_max( L_min( CORR_FILT_Q31, cng_xcorr_filt ), sfm_L ); // Q31
}
ELSE
{
- cng_xcorr_filt = BASOP_Util_Divide3232_Scale_cadence( 8 /*10.0f * CORR_FILT*/, add( hStereoDft->expectedNumUpdates, hStereoDft->currentNumUpdates ), &cng_xcorr_filt_e );
- cng_xcorr_filt = L_shl_sat( cng_xcorr_filt, cng_xcorr_filt_e ); // Q31
- cng_xcorr_filt = L_max( L_min( CORR_FILT_Q31, cng_xcorr_filt ), sfm_L ); // Q31
+ cng_xcorr_filt = CORR_FILT_Q31;
+ move32();
+ cng_xcorr_filt = L_max( cng_xcorr_filt, sfm_L ); // Q31
}
hStereoDft->currentNumUpdates = add( hStereoDft->currentNumUpdates, 1 );
move16();
@@ -1924,7 +1917,7 @@ void stereo_dft_enc_compute_itd_fx(
}
// tmpf1 = (float) ( NFFT / 2 + 1 ) / tmpf3;
- tmpf1 = BASOP_Util_Divide3232_Scale_cadence( add( shr( NFFT, 1 ), 1 ), tmpf3, &tmpf1_e );
+ tmpf1 = BASOP_Util_Divide3232_Scale_newton( add( shr( NFFT, 1 ), 1 ), tmpf3, &tmpf1_e );
tmpf1_e = add( tmpf1_e, sub( 31, tmpf3_e ) );
FOR( i = 0; i < NFFT; i++ )
{
@@ -2002,7 +1995,7 @@ void stereo_dft_enc_compute_itd_fx(
L_temp = L_abs( BASOP_Util_Add_Mant32Exp( sum_nrg_L, sum_nrg_L_e, L_negate( sum_nrg_R ), sum_nrg_R_e, &L_temp_e ) );
L_temp2 = BASOP_Util_Add_Mant32Exp( sum_nrg_L, sum_nrg_L_e, sum_nrg_R, sum_nrg_R_e, &L_temp2_e );
L_temp2 = BASOP_Util_Add_Mant32Exp( L_temp2, L_temp2_e, 1407374883, -16, &L_temp2_e );
- es_em = BASOP_Util_Divide3232_Scale_cadence( L_temp, L_temp2, &es_em_e );
+ es_em = BASOP_Util_Divide3232_Scale_newton( L_temp, L_temp2, &es_em_e );
es_em_e = add( es_em_e, sub( L_temp_e, L_temp2_e ) );
hStereoClassif->unclr_fv_fx[E_es_em] = L_shr_r( es_em, sub( 16, es_em_e ) ); // Q15
@@ -2034,7 +2027,7 @@ void stereo_dft_enc_compute_itd_fx(
move16();
}
L_temp2 = BASOP_Util_Add_Mant32Exp( L_temp2, L_temp2_e, 1407374883, -16, &L_temp2_e );
- d_prodL_prodR = BASOP_Util_Divide3232_Scale_cadence( L_temp, L_temp2, &d_prodL_prodR_e );
+ d_prodL_prodR = BASOP_Util_Divide3232_Scale_newton( L_temp, L_temp2, &d_prodL_prodR_e );
d_prodL_prodR_e = add( d_prodL_prodR_e, sub( L_temp_e, L_temp2_e ) );
d_prodL_prodR = BASOP_Util_Add_Mant32Exp( d_prodL_prodR, d_prodL_prodR_e, MAX_32, 0, &d_prodL_prodR_e );
d_prodL_prodR = BASOP_Util_Loge( d_prodL_prodR, d_prodL_prodR_e ); // Q25
@@ -2053,7 +2046,7 @@ void stereo_dft_enc_compute_itd_fx(
// xcorr_abs[i] = logf( xcorr_abs[i] / ( sum_nrg_L + sum_nrg_R + 1e-5f ) + 1e-5f );
L_temp = BASOP_Util_Add_Mant32Exp( sum_nrg_L, sum_nrg_L_e, sum_nrg_R, sum_nrg_R_e, &L_temp_e );
L_temp = BASOP_Util_Add_Mant32Exp( L_temp, L_temp_e, 1407374883, -16, &L_temp_e );
- L_temp2 = BASOP_Util_Divide3232_Scale_cadence( xcorr_abs[i], L_temp, &L_temp2_e );
+ L_temp2 = BASOP_Util_Divide3232_Scale_newton( xcorr_abs[i], L_temp, &L_temp2_e );
L_temp2_e = add( L_temp2_e, sub( xcorr_abs_e[i], L_temp_e ) );
L_temp2 = BASOP_Util_Add_Mant32Exp( L_temp2, L_temp2_e, 1407374883, -16, &L_temp2_e );
xcorr_abs[i] = BASOP_Util_Loge( L_temp2, L_temp2_e );
@@ -2119,12 +2112,12 @@ void stereo_dft_enc_compute_itd_fx(
move16();
// hStereoClassif->ave_ener_L = sum_nrg_L / ( NFFT_mid * NFFT_mid );
- hStereoClassif->ave_ener_L_fx = BASOP_Util_Divide3232_Scale_cadence( sum_nrg_L, L_mult0( NFFT_mid, NFFT_mid ), &hStereoClassif->ave_ener_L_fx_e );
+ hStereoClassif->ave_ener_L_fx = BASOP_Util_Divide3232_Scale_newton( sum_nrg_L, L_mult0( NFFT_mid, NFFT_mid ), &hStereoClassif->ave_ener_L_fx_e );
move32();
hStereoClassif->ave_ener_L_fx_e = add( hStereoClassif->ave_ener_L_fx_e, sub( sum_nrg_L_e, 31 ) );
move16();
// hStereoClassif->ave_ener_R = sum_nrg_R / ( NFFT_mid * NFFT_mid );
- hStereoClassif->ave_ener_R_fx = BASOP_Util_Divide3232_Scale_cadence( sum_nrg_R, L_mult0( NFFT_mid, NFFT_mid ), &hStereoClassif->ave_ener_R_fx_e );
+ hStereoClassif->ave_ener_R_fx = BASOP_Util_Divide3232_Scale_newton( sum_nrg_R, L_mult0( NFFT_mid, NFFT_mid ), &hStereoClassif->ave_ener_R_fx_e );
move32();
hStereoClassif->ave_ener_R_fx_e = add( hStereoClassif->ave_ener_R_fx_e, sub( sum_nrg_R_e, 31 ) );
move16();
@@ -2152,7 +2145,7 @@ void stereo_dft_enc_compute_itd_fx(
{
// thres *= 1.0f + 1.f * min( 1.f, max( 0.f, ( -1.0f * sfm_L + 0.5f ) / ( 0.5f - 0.2f ) ) );
L_temp = BASOP_Util_Add_Mant32Exp( L_negate( sfm_L ), 0, ONE_IN_Q30, 0, &L_temp_e );
- L_temp2 = BASOP_Util_Divide3232_Scale_cadence( L_temp, 644245094, &L_temp2_e );
+ L_temp2 = BASOP_Util_Divide3232_Scale_newton( L_temp, 644245094, &L_temp2_e );
L_temp2_e = add( L_temp2_e, L_temp_e - 0 );
L_temp2 = L_shl_sat( L_temp2, sub( L_temp2_e, 1 ) ); // Q30
L_temp2_e = 1;
@@ -2370,7 +2363,7 @@ void stereo_dft_enc_compute_itd_fx(
L_temp = Mpy_32_32( den_cor_cur, den_cor_prev );
L_temp_e = add( den_cor_cur_e, den_cor_prev_e );
L_temp = Sqrt32( L_temp, &L_temp_e );
- cor_lb[i] = BASOP_Util_Divide3232_Scale_cadence( num_cor, L_temp, &cor_lb_e[i] );
+ cor_lb[i] = BASOP_Util_Divide3232_Scale_newton( num_cor, L_temp, &cor_lb_e[i] );
move32();
cor_lb_e[i] = add( cor_lb_e[i], sub( num_cor_e, L_temp_e ) );
move16();
@@ -2382,7 +2375,7 @@ void stereo_dft_enc_compute_itd_fx(
// par_L[i] = xcorr_max / ( sum_nrg_L_tmp + FLT_MIN );
IF( xcorr_max )
{
- par_L[i] = BASOP_Util_Divide3232_Scale_cadence( xcorr_max, sum_nrg_L_tmp, &par_L_e[i] );
+ par_L[i] = BASOP_Util_Divide3232_Scale_newton( xcorr_max, sum_nrg_L_tmp, &par_L_e[i] );
move32();
par_L_e[i] = add( par_L_e[i], sub( xcorr_max_e, sum_nrg_L_tmp_e ) );
move16();
diff --git a/lib_enc/ivas_stereo_dft_td_itd_fx.c b/lib_enc/ivas_stereo_dft_td_itd_fx.c
index c457faa4f97bd09da06ee2738486bdab5e8aff4c..309ec3377d8505c7f3cfd058bd0dd3e764637d83 100644
--- a/lib_enc/ivas_stereo_dft_td_itd_fx.c
+++ b/lib_enc/ivas_stereo_dft_td_itd_fx.c
@@ -499,8 +499,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 +512,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 +532,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 +576,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 08dc2da2f8bf0aa90d0b3a810923c557e29d1c79..8e960d71e66dd172e8a0026d71a59dee3ba17c71 100644
--- a/lib_enc/ivas_stereo_dmx_evs_fx.c
+++ b/lib_enc/ivas_stereo_dmx_evs_fx.c
@@ -88,6 +88,7 @@
#define STEREO_DMX_EVS_SWTCH_PRC_THRES_48 29
#define STEREO_DMX_EVS_SWTCH_PRC_HYS_THRES 1
+#define STEREO_DMX_EVS_FADE_LEN_PRC_Q0 20
#define STEREO_DMX_EVS_NB_SBFRM 5
#define STEREO_DMX_EVS_TRNS_DTC_INST_Q0 75
@@ -895,7 +896,7 @@ static void calc_poc_fx(
// ICCr = (float) sqrt( ( Nr * Nr + Ni * Ni ) / ( eneL * eneR + EPSILON ) );
L_tmp1 = BASOP_Util_Add_Mant32Exp( Mpy_32_32_r( Nr, Nr ), shl( Nr_e, 1 ), Mpy_32_32_r( Ni, Ni ), shl( Ni_e, 1 ), &L_tmp1_e );
L_tmp2 = BASOP_Util_Add_Mant32Exp( Mpy_32_32_r( eneL, eneR ), add( eneL_e, eneR_e ), EPSILON_FX_M, EPSILON_FX_E, &L_tmp2_e );
- ICCr = BASOP_Util_Divide3232_Scale_cadence( L_tmp1, L_tmp2, &L_tmp_e );
+ ICCr = BASOP_Util_Divide3232_Scale_newton( L_tmp1, L_tmp2, &L_tmp_e );
L_tmp_e = add( L_tmp_e, sub( L_tmp1_e, L_tmp2_e ) );
ICCr = Sqrt32( ICCr, &L_tmp_e );
// Saturation to handle values close to 1.0f
@@ -2162,7 +2163,6 @@ void stereo_dmx_evs_enc_fx(
Word16 W_tmp_q;
push_wmops( "stereo_dmx_evs_enc" );
-
if ( is_binaural )
{
/* use of is_binaural flag is to be considered */
@@ -2252,8 +2252,8 @@ void stereo_dmx_evs_enc_fx(
move32();
}
- L_tmp1 = BASOP_Util_Add_Mant32Exp( hPHA->trns_aux_energy_fx[k], hPHA->trns_aux_energy_fx_e[k], EPSILON_FX_M, EPSILON_FX_E, &L_tmp1_e );
- L_tmp2 = BASOP_Util_Divide3232_Scale_cadence( subframe_energy[m], L_tmp1, &L_tmp2_e );
+ L_tmp1 = BASOP_Util_Add_Mant32Exp( hStereoDmxEVS->hPHA->trns_aux_energy_fx[k], hStereoDmxEVS->hPHA->trns_aux_energy_fx_e[k], EPSILON_FX_M, EPSILON_FX_E, &L_tmp1_e );
+ L_tmp2 = BASOP_Util_Divide3232_Scale_newton( subframe_energy[m], L_tmp1, &L_tmp2_e );
L_tmp2_e = add( L_tmp2_e, sub( subframe_energy_e[m], L_tmp1_e ) );
// if ( subframe_energy[m] / ( hPHA->trns_aux_energy[k] + EPSILON ) > hPHA->crst_fctr )
if ( BASOP_Util_Cmp_Mant32Exp( L_tmp2, L_tmp2_e, hPHA->crst_fctr_fx, 31 ) > 0 )
@@ -2269,8 +2269,8 @@ void stereo_dmx_evs_enc_fx(
FOR( m = 1; m < STEREO_DMX_EVS_NB_SBFRM; m++ )
{
- L_tmp1 = BASOP_Util_Add_Mant32Exp( subframe_energy[sub( m, 1 )], subframe_energy_e[sub( m, 1 )], EPSILON_FX_M, EPSILON_FX_E, &L_tmp1_e );
- L_tmp2 = BASOP_Util_Divide3232_Scale_cadence( subframe_energy[m], L_tmp1, &L_tmp2_e );
+ L_tmp1 = BASOP_Util_Add_Mant32Exp( subframe_energy[m - 1], subframe_energy_e[m - 1], EPSILON_FX_M, EPSILON_FX_E, &L_tmp1_e );
+ L_tmp2 = BASOP_Util_Divide3232_Scale_newton( subframe_energy[m], L_tmp1, &L_tmp2_e );
L_tmp2_e = add( L_tmp2_e, sub( subframe_energy_e[m], L_tmp1_e ) );
// if ( subframe_energy[m] / ( subframe_energy[m - 1] + EPSILON ) > STEREO_DMX_EVS_TRNS_DTC_INST )
if ( BASOP_Util_Cmp_Mant32Exp( L_tmp2, L_tmp2_e, STEREO_DMX_EVS_TRNS_DTC_INST_Q0, 31 ) > 0 )
@@ -2634,6 +2634,7 @@ void stereo_dmx_evs_enc_fx(
}
Copy_Scale_sig32_16( p_dmx_data, data, n_samples, 5 ); // Q26->Q15
+ pop_wmops();
pop_wmops();
@@ -2917,7 +2918,34 @@ ivas_error stereo_dmx_evs_init_encoder_fx(
fad_g = hStereoDmxEVS->hPHA->fad_g_fx;
// fad_r = 1.0f / (float) ( fad_len + 1 );
+#ifdef FIX_1481_HARDCODE_DIV
+ SWITCH( fad_len )
+ {
+ case STEREO_DMX_EVS_FAD_LEN_16:
+ fad_r = 853658096;
+ move32();
+ tmp_e = -6;
+ move16();
+ BREAK;
+ case STEREO_DMX_EVS_FAD_LEN_32:
+ fad_r = 856317467;
+ move32();
+ tmp_e = -7;
+ move16();
+ BREAK;
+ case STEREO_DMX_EVS_FAD_LEN_48:
+ fad_r = 571471740;
+ move32();
+ tmp_e = -7;
+ move16();
+ BREAK;
+ default:
+ fad_r = BASOP_Util_Divide3232_Scale_newton( 1, add( fad_len, 1 ), &tmp_e );
+ BREAK;
+ }
+#else
fad_r = BASOP_Util_Divide3232_Scale_cadence( 1, add( fad_len, 1 ), &tmp_e );
+#endif
fad_r = L_shl_r( fad_r, tmp_e );
fad_len2 = shr( fad_len, 1 );
FOR( ( n = 0, m = ( fad_len - 1 ) ); n < fad_len2; ( n++, m-- ) )
@@ -3013,7 +3041,34 @@ ivas_error stereo_dmx_evs_init_encoder_fx(
fad_g = hStereoDmxEVS->hPHA->fad_g_prc_fx;
move32();
// fad_r = 1.0f / (float) ( fad_len + 1 );
+#ifdef FIX_1481_HARDCODE_DIV
+ SWITCH( fad_len )
+ {
+ case STEREO_DMX_EVS_FADE_LEN_PRC_Q0 * 16:
+ fad_r = 856317467;
+ move32();
+ tmp_e = -7;
+ move16();
+ BREAK;
+ case STEREO_DMX_EVS_FADE_LEN_PRC_Q0 * 32:
+ fad_r = 857653375;
+ move32();
+ tmp_e = -8;
+ move16();
+ BREAK;
+ case STEREO_DMX_EVS_FADE_LEN_PRC_Q0 * 48:
+ fad_r = 572066403;
+ move32();
+ tmp_e = -8;
+ move16();
+ BREAK;
+ default:
+ fad_r = BASOP_Util_Divide3232_Scale_newton( 1, add( fad_len, 1 ), &tmp_e );
+ BREAK;
+ }
+#else
fad_r = BASOP_Util_Divide3232_Scale_cadence( 1, add( fad_len, 1 ), &tmp_e );
+#endif
fad_r = L_shl_r( fad_r, tmp_e );
fad_len2 = shr( fad_len, 1 );
FOR( ( n = 0, m = ( fad_len - 1 ) ); n < fad_len2; ( n++, m-- ) )
diff --git a/lib_enc/ivas_stereo_eclvq_enc_fx.c b/lib_enc/ivas_stereo_eclvq_enc_fx.c
index 3abc07811450ec80c6e98e508eef739e2d647f27..a09daffe033c27d824800c93d8e8855231389091 100644
--- a/lib_enc/ivas_stereo_eclvq_enc_fx.c
+++ b/lib_enc/ivas_stereo_eclvq_enc_fx.c
@@ -89,7 +89,7 @@ void ECSQ_quantize_vector_fx(
}
ELSE
{
- inv_global_gain = BASOP_Util_Divide3232_Scale_cadence( ONE_IN_Q15, global_gain, &inv_global_gain_e );
+ inv_global_gain = BASOP_Util_Divide3232_Scale_newton( ONE_IN_Q15, global_gain, &inv_global_gain_e );
inv_global_gain = L_shl( inv_global_gain, inv_global_gain_e ); // Q31
FOR( i = 0; i < N; ++i )
{
@@ -140,7 +140,7 @@ Word32 ECSQ_compute_optimal_gain_fx( // Q15
IF( sum_sq_output != 0 )
{
// optimal_global_gain = sum_input_output / sum_sq_output;
- optimal_global_gain = BASOP_Util_Divide3232_Scale_cadence( sum_input_output, sum_sq_output, &optimal_global_gain_e ); // 31 - ( sum_input_output_e - 31 + optimal_global_gain_e ) = 62 - ( sum_input_output_e + optimal_global_gain_e )
+ optimal_global_gain = BASOP_Util_Divide3232_Scale_newton( sum_input_output, sum_sq_output, &optimal_global_gain_e ); // 31 - ( sum_input_output_e - 31 + optimal_global_gain_e ) = 62 - ( sum_input_output_e + optimal_global_gain_e )
optimal_global_gain = L_shr( optimal_global_gain, sub( sub( 62, add( sum_input_output_e, optimal_global_gain_e ) ), 15 ) ); // Q15
}
@@ -427,7 +427,7 @@ static Word16 get_best_param_fx(
IF( LE_16( sub( count, count0 ), ECSQ_NONZERO_MAX ) && EQ_32( sum_abs, L_shl( sub( count, count0 ), 10 ) ) )
{
//*avg_abs_sum = ( sum_abs + 0.25f * count0 ) / count;
- *avg_abs_sum = BASOP_Util_Divide3232_Scale_cadence( L_add( sum_abs, L_shl( count0, 8 ) ), L_shl( count, 10 ), &L_tmp_e );
+ *avg_abs_sum = BASOP_Util_Divide3232_Scale_newton( L_add( sum_abs, L_shl( count0, 8 ) ), L_shl( count, 10 ), &L_tmp_e );
move32();
*avg_abs_sum = L_shr_r( *avg_abs_sum, sub( 21, L_tmp_e ) ); // Q10
move32();
@@ -438,7 +438,7 @@ static Word16 get_best_param_fx(
}
//*avg_abs_sum = ( sum_abs + 0.25f * count0 ) / count;
- *avg_abs_sum = BASOP_Util_Divide3232_Scale_cadence( L_add( sum_abs, L_shl( count0, 8 ) ), L_shl( count, 10 ), &L_tmp_e );
+ *avg_abs_sum = BASOP_Util_Divide3232_Scale_newton( L_add( sum_abs, L_shl( count0, 8 ) ), L_shl( count, 10 ), &L_tmp_e );
move32();
*avg_abs_sum = L_shr_r( *avg_abs_sum, sub( 21, L_tmp_e ) ); // Q10
move32();
@@ -478,7 +478,7 @@ static Word32 get_est_size_fx( // Q10
// if ( param < 0 )
//{
// //two_to_param = 1.0f / two_to_param;
- // two_to_param = BASOP_Util_Divide3232_Scale_cadence( 1, two_to_param,&two_to_param_e);
+ // two_to_param = BASOP_Util_Divide3232_Scale_newton( 1, two_to_param,&two_to_param_e);
// }
IF( NE_16( param, ECSQ_ALL_ZERO_PARAM ) ) /* not all values are zeros */
@@ -508,8 +508,8 @@ static Word32 get_est_size_fx( // Q10
nonzero = sub( N, N0 );
// required_avg_abs_sum = ( nonzero + 0.25f * N0 ) / N; /* the vector must have nonzero +-1 and N0 zeros */
- required_avg_abs_sum = BASOP_Util_Divide3232_Scale_cadence( L_add( L_shl( nonzero, 10 ), L_shl( N0, 8 ) ), L_shl( N, 10 ), &required_avg_abs_sum_e ); /* the vector must have nonzero +-1 and N0 zeros */
- required_avg_abs_sum = L_shr_r( required_avg_abs_sum, sub( 21, required_avg_abs_sum_e ) ); // Q10
+ required_avg_abs_sum = BASOP_Util_Divide3232_Scale_newton( L_add( L_shl( nonzero, 10 ), L_shl( N0, 8 ) ), L_shl( N, 10 ), &required_avg_abs_sum_e ); /* the vector must have nonzero +-1 and N0 zeros */
+ required_avg_abs_sum = L_shr_r( required_avg_abs_sum, sub( 21, required_avg_abs_sum_e ) ); // Q10
test();
IF( EQ_32( avg_abs_sum, required_avg_abs_sum ) && LE_16( nonzero, ECSQ_NONZERO_MAX ) )
@@ -847,18 +847,18 @@ Word32 ECSQ_encode_target_SNR_fx(
/* target_ratio is the target ratio between the sum squared values of input and sum squared values of quantization error */
// target_ratio = powf( 10.0f, target_SNR / 10.0f );
- L_tmp1 = BASOP_Util_Divide3232_Scale_cadence( target_SNR, 10, &L_tmp1_e );
+ L_tmp1 = BASOP_Util_Divide3232_Scale_newton( target_SNR, 10, &L_tmp1_e );
L_tmp1_e = add( L_tmp1_e, 6 - 31 );
target_ratio = BASOP_Util_fPow( 10 << 27, 4, L_tmp1, L_tmp1_e, &target_ratio_e );
// target_sum_squared_error = sum_squared / target_ratio;
- target_sum_squared_error = BASOP_Util_Divide3232_Scale_cadence( sum_squared, target_ratio, &target_sum_squared_error_e );
+ target_sum_squared_error = BASOP_Util_Divide3232_Scale_newton( sum_squared, target_ratio, &target_sum_squared_error_e );
target_sum_squared_error_e = add( target_sum_squared_error_e, sub( sum_squared_e, target_ratio_e ) );
/* the mean of squared quantization error for uniform scalar quantization is 1 / 12, approximately 0.0833 */
/* when including global_gain, the relationship is target_sum_squared_error ~ (0.0833 * N) * global_gain ^ 2 */
/* the representable range for global_gain is from 1 (global_gain_index 0) to 29145 (global_gain_index 126) inclusive */
// global_gain = sqrtf( target_sum_squared_error / ( 0.0833f * (float) N ) );
- global_gain = BASOP_Util_Divide3232_Scale_cadence( target_sum_squared_error, L_mult0( 5459 /*0.0833f in Q16*/, N ), &global_gain_e );
+ global_gain = BASOP_Util_Divide3232_Scale_newton( target_sum_squared_error, L_mult0( 5459 /*0.0833f in Q16*/, N ), &global_gain_e );
global_gain_e = add( global_gain_e, sub( target_sum_squared_error_e, 15 ) );
global_gain = Sqrt32( global_gain, &global_gain_e );
global_gain = L_shr( global_gain, sub( 16, global_gain_e ) ); // Q15
@@ -885,7 +885,7 @@ Word32 ECSQ_encode_target_SNR_fx(
adjust_size = L_sub( test_size, max_bits_fixpt );
/* assume doubling the quantization step size will reduce the entropy with (up to) one bit */
// adjust_global_gain_index = (int16_t) ceil( adjust_size / ( 1024.0f * N * log_base2( global_gain_step ) ) );
- adjust_global_gain_index = BASOP_Util_Divide3232_Scale_cadence( adjust_size, N, &tmp_e );
+ adjust_global_gain_index = BASOP_Util_Divide3232_Scale_newton( adjust_size, N, &tmp_e );
adjust_global_gain_index = Mpy_32_32( adjust_global_gain_index, 17816838 /*/ ( 1024.0f * log_base2( global_gain_step ) )*/ );
IF( NE_32( adjust_global_gain_index, L_shl( L_shr( adjust_global_gain_index, sub( 31, tmp_e ) ), sub( 31, tmp_e ) ) ) )
{
diff --git a/lib_enc/ivas_stereo_ica_enc_fx.c b/lib_enc/ivas_stereo_ica_enc_fx.c
index a8a088f209906e8817948a6de6915e0926e82a27..d0252a1f154a32df2845bea6d5c3dc695368e2a0 100644
--- a/lib_enc/ivas_stereo_ica_enc_fx.c
+++ b/lib_enc/ivas_stereo_ica_enc_fx.c
@@ -150,7 +150,7 @@ static void tcaTargetCh_LA_fx(
deno_exp = 0;
move16();
}
- gAdj = BASOP_Util_Divide3232_Scale_cadence( tempF2, deno, &gAdj_exp ); /* Q31-gAdj_exp */
+ gAdj = BASOP_Util_Divide3232_Scale_newton( tempF2, deno, &gAdj_exp ); /* Q31-gAdj_exp */
gAdj_exp = add( gAdj_exp, sub( tempF2_exp, deno_exp ) );
}
@@ -923,7 +923,7 @@ static void corrStatsEst_fx(
IF( tempF_fx != 0 )
{
temp32 = BASOP_Util_Add_Mant32Exp( XY_hat_fx, XY_hat_exp, L_negate( Mpy_32_32( X_hat_fx, Y_hat_fx ) ), add( X_hat_exp, Y_hat_exp ), &exp ); /* Q31-exp */
- beta_reg_fx = BASOP_Util_Divide3232_Scale_cadence( temp32, tempF_fx, &beta_reg_exp ); /* Q31-beta_reg_exp */
+ beta_reg_fx = BASOP_Util_Divide3232_Scale_newton( temp32, tempF_fx, &beta_reg_exp ); /* Q31-beta_reg_exp */
if ( beta_reg_fx )
{
beta_reg_exp = add( beta_reg_exp, sub( exp, tempF_exp ) );
@@ -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 */
@@ -2345,9 +2349,9 @@ static void unclr_calc_corr_features_fx(
move32();
}
- ic_Lm = BASOP_Util_Divide3232_Scale_cadence( corrL, ener, &exp1 ); /* Q31-exp1 */
+ ic_Lm = BASOP_Util_Divide3232_Scale_newton( corrL, ener, &exp1 ); /* Q31-exp1 */
exp1 = add( exp1, sub( corrL_exp, ener_exp ) );
- ic_Rm = BASOP_Util_Divide3232_Scale_cadence( corrR, ener, &exp2 ); /* Q31-exp2 */
+ ic_Rm = BASOP_Util_Divide3232_Scale_newton( corrR, ener, &exp2 ); /* Q31-exp2 */
exp2 = add( exp2, sub( corrR_exp, ener_exp ) );
m_corrL_corrR = L_sub( L_max( L_abs( L_shl( ic_Lm, sub( exp1, s_max( exp1, exp2 ) ) ) ), L_abs( L_shl( ic_Rm, sub( exp2, s_max( exp1, exp2 ) ) ) ) ), L_min( L_abs( L_shl( ic_Lm, sub( exp1, s_max( exp1, exp2 ) ) ) ), L_abs( L_shl( ic_Rm, sub( exp2, s_max( exp1, exp2 ) ) ) ) ) ); // s_max(exp1, exp2)
@@ -2405,7 +2409,7 @@ static void unclr_calc_corr_features_fx(
}
ELSE
{
- *corrEst_ncorr = BASOP_Util_Divide3232_Scale_cadence( num, den, &exp ); /* Q31-corrEst_ncorr_exp */
+ *corrEst_ncorr = BASOP_Util_Divide3232_Scale_newton( num, den, &exp ); /* Q31-corrEst_ncorr_exp */
*corrEst_ncorr_exp = add( exp, sub( num_exp, den_exp ) );
move32();
move16();
diff --git a/lib_enc/ivas_stereo_mdct_core_enc_fx.c b/lib_enc/ivas_stereo_mdct_core_enc_fx.c
index 46134a27003ae2e970766643382ee84a84056feb..2a71fc34dffdcc079e6195b14b4779c77da04ffc 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], q_spec, tmp_s;
- Word16 tmp_q_powSpecInv[N_MAX], *tmp_q_psi[2];
Word64 W_tmp;
Encoder_State *st, **sts;
STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct;
@@ -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 );
-
- tmp_q_psi[0] = tmp_q_powSpecInv;
- tmp_q_psi[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];
@@ -343,61 +341,59 @@ void stereo_mdct_core_enc_fx(
IF( !hStereoMdct->isSBAStereoMode )
{
/* Common q for mdst_spectrum and spectrum */
- Word16 k;
- q_spec = 0;
+ Word16 exp1, exp2;
Word16 length;
- FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
- {
- FOR( k = 0; k <= ( ( sts[ch]->core == TCX_20_CORE ) ? 1 : NB_DIV ) - 1; k++ )
- {
- q_spec = s_max( q_spec, sts[ch]->hTcxEnc->spectrum_e[k] );
- q_spec = s_max( q_spec, mdst_spectrum_e[ch][k] );
- }
- }
- q_spec = sub( Q31, q_spec );
/*find headroom to increase precision*/
- Word16 hdrm_min = MAX_16;
+ exp1 = MIN_16;
+ exp2 = MIN_16;
+ move16();
move16();
FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
{
length = sts[ch]->hTcxEnc->spectrum_length;
move16();
- IF( NE_16( sts[ch]->hTcxEnc->tcxMode, TCX_20 ) )
+ if ( NE_16( sts[ch]->hTcxEnc->tcxMode, TCX_20 ) )
{
length = shr( length, 1 );
}
- hdrm_min = s_min( hdrm_min, L_norm_arr( sts[ch]->hTcxEnc->spectrum_fx[0], length ) );
- hdrm_min = s_min( hdrm_min, L_norm_arr( mdst_spectrum_fx[ch][0], length ) );
+ exp1 = s_max( exp1, sub( sts[ch]->hTcxEnc->spectrum_e[0], L_norm_arr( sts[ch]->hTcxEnc->spectrum_fx[0], length ) ) );
+ exp2 = s_max( exp2, sub( mdst_spectrum_e[ch][0], L_norm_arr( mdst_spectrum_fx[ch][0], length ) ) );
IF( NE_16( sts[ch]->hTcxEnc->tcxMode, TCX_20 ) )
{
- hdrm_min = s_min( hdrm_min, L_norm_arr( sts[ch]->hTcxEnc->spectrum_fx[1], length ) );
- hdrm_min = s_min( hdrm_min, L_norm_arr( mdst_spectrum_fx[ch][1], length ) );
+ exp1 = s_max( exp1, sub( sts[ch]->hTcxEnc->spectrum_e[1], L_norm_arr( sts[ch]->hTcxEnc->spectrum_fx[1], length ) ) );
+ exp2 = s_max( exp2, sub( mdst_spectrum_e[ch][1], L_norm_arr( mdst_spectrum_fx[ch][1], length ) ) );
}
}
- q_spec = sub( add( hdrm_min, q_spec ), 1 ); /* 1 guard bit to avoid over-flows in stereo_coder_tcx_fx */
+ exp1 = add( exp1, 2 ); /* 2 guard bit to avoid over-flows in stereo_coder_tcx_fx */
+ exp2 = add( exp2, 2 ); /* 2 guard bit to avoid over-flows in stereo_coder_tcx_fx (ms_processing_fx) */
FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
{
length = sts[ch]->hTcxEnc->spectrum_length;
move16();
- IF( NE_16( sts[ch]->hTcxEnc->tcxMode, TCX_20 ) )
+ if ( NE_16( sts[ch]->hTcxEnc->tcxMode, TCX_20 ) )
{
length = shr( length, 1 );
}
- FOR( k = 0; k <= ( ( sts[ch]->core == TCX_20_CORE ) ? 1 : NB_DIV ) - 1; k++ )
+
+ scale_sig32( sts[ch]->hTcxEnc->spectrum_fx[0], length, sub( sts[ch]->hTcxEnc->spectrum_e[0], exp1 ) ); /* exp1 */
+ sts[ch]->hTcxEnc->spectrum_e[0] = exp1;
+ scale_sig32( mdst_spectrum_fx[ch][0], length, sub( mdst_spectrum_e[ch][0], exp2 ) ); /* exp2 */
+ mdst_spectrum_e[ch][0] = exp2;
+ IF( NE_16( sts[ch]->hTcxEnc->tcxMode, TCX_20 ) )
{
- Scale_sig32( sts[ch]->hTcxEnc->spectrum_fx[k], length, sub( q_spec, sub( Q31, sts[ch]->hTcxEnc->spectrum_e[k] ) ) ); /* q_spec */
- sts[ch]->hTcxEnc->spectrum_e[k] = sub( Q31, q_spec );
- Scale_sig32( mdst_spectrum_fx[ch][k], length, sub( q_spec, sub( Q31, mdst_spectrum_e[ch][k] ) ) ); /* q_spec */
- mdst_spectrum_e[ch][k] = sub( Q31, q_spec );
+ scale_sig32( sts[ch]->hTcxEnc->spectrum_fx[1], length, sub( sts[ch]->hTcxEnc->spectrum_e[1], exp1 ) ); /* exp1 */
+ sts[ch]->hTcxEnc->spectrum_e[1] = exp1;
+ scale_sig32( mdst_spectrum_fx[ch][1], length, sub( mdst_spectrum_e[ch][1], exp2 ) ); /* exp2 */
+ mdst_spectrum_e[ch][1] = exp2;
}
}
- stereo_coder_tcx_fx( hStereoMdct, sts, ms_mask, mdst_spectrum_fx, inv_spectrum_fx, inv_mdst_spectrum_fx, 0, q_spec );
- exp_inv_spectrum[0] = exp_inv_spectrum[1] = sub( Q31, q_spec );
+ stereo_coder_tcx_fx( hStereoMdct, sts, ms_mask, mdst_spectrum_fx, inv_spectrum_fx, inv_mdst_spectrum_fx, 0, sts[0]->hTcxEnc->spectrum_e[0], mdst_spectrum_e[0][0] );
+ exp_inv_spectrum[0] = exp_inv_spectrum[1] = sts[0]->hTcxEnc->spectrum_e[0];
move16();
move16();
}
@@ -406,10 +402,13 @@ void stereo_mdct_core_enc_fx(
* Power spectrum calculation
*---------------------------------------------------------------*/
Word16 length, exp, shift1, shift2, norm;
- Word32 mdct, mdst;
+ Word32 mdct, mdst, imdct, imdst;
FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
{
+ L_subframeTCX = shr( sts[ch]->hTcxEnc->L_frameTCX, 1 ); /* Q0 */
+ nSubframes = NB_DIV;
+ move16();
IF( EQ_16( sts[ch]->hTcxEnc->tcxMode, TCX_20 ) )
{
nSubframes = 1;
@@ -417,12 +416,6 @@ void stereo_mdct_core_enc_fx(
move16();
move16();
}
- ELSE
- {
- nSubframes = NB_DIV;
- move16();
- L_subframeTCX = shr( sts[ch]->hTcxEnc->L_frameTCX, 1 ); /* Q0 */
- }
/* in MCT only relevant for bitrate switching from non-MCT bitrates */
IF( EQ_16( sts[ch]->last_core, ACELP_CORE ) )
@@ -432,8 +425,6 @@ void stereo_mdct_core_enc_fx(
FOR( n = 0; n < nSubframes; n++ )
{
- q_spec = sub( 31, sts[ch]->hTcxEnc->spectrum_e[n] );
-
IF( sts[ch]->hTcxEnc->tns_ms_flag[n] )
{
exp = add( s_max( mdst_spectrum_e[ch][n], sts[ch]->hTcxEnc->spectrum_e[n] ), 1 );
@@ -443,16 +434,18 @@ void stereo_mdct_core_enc_fx(
/* power spectrum: MDCT^2 + MDST^2 */
FOR( i = 0; i < L_subframeTCX; i++ )
{
- W_tmp = W_mac_32_32( W_mult_32_32( inv_mdst_spectrum_fx[ch][n][i], inv_mdst_spectrum_fx[ch][n][i] ), inv_spectrum_fx[ch][n][i], inv_spectrum_fx[ch][n][i] ); /* 2*q_spec+1 */
- tmp_s = W_norm( W_tmp );
- W_tmp = W_shl( W_tmp, tmp_s ); /* 2*q_spec+1+tmp_s */
- powerSpecMsInv_fx[ch][n][i] = W_extract_h( W_tmp ); /* 2*q_spec+1+tmp_s-32 */
- tmp_q_psi[n][i] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32
+ mdst = L_shl( mdst_spectrum_fx[ch][n][i], shift1 ); // exp: exp
+ mdct = L_shl( sts[ch]->hTcxEnc->spectrum_fx[n][i], shift2 ); // exp: exp
+ imdst = L_shl( inv_mdst_spectrum_fx[ch][n][i], shift1 ); // exp: exp
+ imdct = L_shl( inv_spectrum_fx[ch][n][i], shift2 ); // exp: exp
+
+ 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
+ q_powerSpecMsInv_fx[ch][n][i] = sub( 31, sub( shl( exp, 1 ), norm ) );
move32();
move16();
- mdst = L_shl( mdst_spectrum_fx[ch][n][i], shift1 ); // exp: exp
- mdct = L_shl( sts[ch]->hTcxEnc->spectrum_fx[n][i], shift2 ); // exp: exp
powerSpec64[ch][i + n * L_subframeTCX] = W_mac_32_32( W_mult_32_32( mdct, mdct ), mdst, mdst ); // exp: 2*exp
move64();
}
@@ -463,33 +456,35 @@ void stereo_mdct_core_enc_fx(
{
IF( NE_16( hStereoMdct->mdct_stereo_mode[n], SMDCT_DUAL_MONO ) )
{
+ exp = shl( add( sts[ch]->hTcxEnc->spectrum_e[n], 1 ), 1 ); // 2*(sts[ch]->hTcxEnc->spectrum_e[n]+1)
/* power spectrum: MDCT^2 + MDST^2 */
- W_tmp = W_mult_32_32( inv_spectrum_fx[ch][n][0], inv_spectrum_fx[ch][n][0] ); /* 2*q_spec+1 */
- tmp_s = W_norm( W_tmp );
- W_tmp = W_shl( W_tmp, tmp_s ); /* 2*q_spec+1+tmp_s */
- powerSpecMsInv_fx[ch][n][0] = W_extract_h( W_tmp ); /* 2*q_spec+1+tmp_s-32 */
- tmp_q_psi[n][0] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32
+ mdct = L_shr( inv_spectrum_fx[ch][n][0], 1 ); // exp: sts[ch]->hTcxEnc->spectrum_e[n]+1
+ 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)
+ q_powerSpecMsInv_fx[ch][n][0] = sub( 31, sub( exp, norm ) );
move32();
move16();
FOR( i = 1; i < L_subframeTCX - 1; i++ )
{
- Word32 mdst_fx = L_sub( inv_spectrum_fx[ch][n][i + 1], inv_spectrum_fx[ch][n][i - 1] ); /* An MDST estimate q_spec*/
-
- W_tmp = W_mac_32_32( W_mult_32_32( mdst_fx, mdst_fx ), inv_spectrum_fx[ch][n][i], inv_spectrum_fx[ch][n][i] ); /* 2*q_spec+1 */
- tmp_s = W_norm( W_tmp );
- W_tmp = W_shl( W_tmp, tmp_s ); /* 2*q_spec+1+tmp_s */
- powerSpecMsInv_fx[ch][n][i] = W_extract_h( W_tmp ); /* 2*q_spec+1+tmp_s-32 */
- tmp_q_psi[n][i] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32
+ /* float mdst = ( inv_spectrum[ch][n][i + 1] - inv_spectrum[ch][n][i - 1] );
+ powerSpecMsInv[ch][n][i] = mdst * mdst + inv_spectrum[ch][n][i] * inv_spectrum[ch][n][i]; */
+ mdst = L_sub( L_shr( inv_spectrum_fx[ch][n][i + 1], 1 ), L_shr( inv_spectrum_fx[ch][n][i - 1], 1 ) ); // exp: sts[ch]->hTcxEnc->spectrum_e[n]+1
+ mdct = L_shr( inv_spectrum_fx[ch][n][i], 1 ); // exp: sts[ch]->hTcxEnc->spectrum_e[n]+1
+ 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)
+ q_powerSpecMsInv_fx[ch][n][i] = sub( 31, sub( exp, norm ) );
move32();
move16();
}
- W_tmp = W_mult_32_32( inv_spectrum_fx[ch][n][L_subframeTCX - 1], inv_spectrum_fx[ch][n][L_subframeTCX - 1] ); /* 2*q_spec+1 */
- tmp_s = W_norm( W_tmp );
- W_tmp = W_shl( W_tmp, tmp_s ); /* 2*q_spec+1+tmp_s */
- powerSpecMsInv_fx[ch][n][L_subframeTCX - 1] = W_extract_h( W_tmp ); /* 2*q_spec+1+tmp_s-32 */
- tmp_q_psi[n][L_subframeTCX - 1] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32
+ mdct = L_shr( inv_spectrum_fx[ch][n][L_subframeTCX - 1], 1 ); // exp: sts[ch]->hTcxEnc->spectrum_e[n]+1
+ 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)
+ q_powerSpecMsInv_fx[ch][n][L_subframeTCX - 1] = sub( 31, sub( exp, norm ) );
move32();
move16();
}
@@ -515,32 +510,6 @@ void stereo_mdct_core_enc_fx(
move16();
}
}
-
- /* Aligning the Q-factors */
- {
- Word16 q_temp = Q31;
- move16();
- FOR( n = 0; n < nSubframes; n++ )
- {
- FOR( i = 0; i < L_subframeTCX; i++ )
- {
- if ( powerSpecMsInv_fx[ch][n][i] != 0 )
- {
- q_temp = s_min( q_temp, tmp_q_psi[n][i] );
- }
- }
- }
- FOR( n = 0; n < nSubframes; n++ )
- {
- FOR( i = 0; i < L_subframeTCX; i++ )
- {
- powerSpecMsInv_fx[ch][n][i] = L_shr_sat( powerSpecMsInv_fx[ch][n][i], sub( tmp_q_psi[n][i], q_temp ) );
- move32();
- }
- }
- exp_powSpecMsInv[ch] = sub( Q31, q_temp );
- move16();
- }
}
FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
@@ -658,7 +627,7 @@ void stereo_mdct_core_enc_fx(
move16();
ProcessStereoIGF_fx( hStereoMdct, sts, ms_mask, orig_spectrum_fx, sub( Q31, p_orig_spectrum_e[0] ), sub( Q31, p_orig_spectrum_e[1] ),
- p_powerSpec_fx, exp_powSpec, powerSpecMsInv_fx, exp_powSpecMsInv, inv_spectrum_fx, exp_inv_spectrum,
+ p_powerSpec_fx, 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
@@ -718,7 +687,7 @@ void stereo_mdct_core_enc_fx(
q_spectrum = sub( Q31, st->hTcxEnc->spectrum_e[n] );
Scale_sig32( orig_spectrum_fx[ch][n], st->hIGFEnc->infoStopLine, sub( q_spectrum, sub( Q31, p_orig_spectrum_e[ch] ) ) ); /* q_spectrum */
- ProcessIGF_ivas_fx( st, N_MAX, st->hTcxEnc->spectrum_fx[n], orig_spectrum_fx[ch][n], &q_spectrum, &powerSpec_fx[ch][n * L_subframeTCX], &exp_powerSpec[ch][n * L_subframeTCX], st->core == TCX_20_CORE, n, hCPE->hCoreCoder[0]->sp_aud_decision0, 0 );
+ ProcessIGF_ivas_fx( st, N_MAX, st->hTcxEnc->spectrum_fx[n], &q_spectrum, orig_spectrum_fx[ch][n], q_spectrum, &powerSpec_fx[ch][n * L_subframeTCX], &exp_powerSpec[ch][n * L_subframeTCX], st->core == TCX_20_CORE, n, hCPE->hCoreCoder[0]->sp_aud_decision0, 0 );
}
}
}
@@ -795,7 +764,7 @@ void stereo_mdct_core_enc_fx(
Scale_sig32( orig_spectrum_fx[ch][n], st->hIGFEnc->infoStopLine, sub( q_spectrum, sub( Q31, p_orig_spectrum_e[ch] ) ) ); /* q_spectrum */
- ProcessIGF_ivas_fx( st, N_MAX, st->hTcxEnc->spectrum_fx[n], orig_spectrum_fx[ch][n], &q_spectrum, &powerSpec_fx[ch][n * L_subframeTCX], &exp_powerSpec[ch][n * L_subframeTCX], st->core == TCX_20_CORE, n, hCPE->hCoreCoder[0]->sp_aud_decision0, 0 );
+ ProcessIGF_ivas_fx( st, N_MAX, st->hTcxEnc->spectrum_fx[n], &q_spectrum, orig_spectrum_fx[ch][n], q_spectrum, &powerSpec_fx[ch][n * L_subframeTCX], &exp_powerSpec[ch][n * L_subframeTCX], st->core == TCX_20_CORE, n, hCPE->hCoreCoder[0]->sp_aud_decision0, 0 );
}
}
}
diff --git a/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c b/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c
index 9a1198e20608799d30d2c37da62da198d0eb75f0..2f1b7d6c8d6a37248247971dece778020c06e8e5 100644
--- a/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c
+++ b/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c
@@ -190,7 +190,8 @@ void stereo_coder_tcx_fx(
Word32 *inv_mdst_spectrum_fx[CPE_CHANNELS][NB_DIV],
/* i/o: inverse MDST spectrum */ // Q( q_spec ) (same as spectrum buffer in hTcxEnc)
const Word16 mct_on, /* i : flag mct block (1) or stereo (0) Q0*/
- Word16 q_spec )
+ Word16 exp_spec,
+ Word16 exp_mdct_spec )
{
STEREO_MDCT_BAND_PARAMETERS *sfbConf = NULL;
Word32 nrgRatio_fx[CPE_CHANNELS];
@@ -255,8 +256,8 @@ void stereo_coder_tcx_fx(
tmp = Inv16( extract_h( nrgRatio_fx[k] ), &e_tmp ); /* Q15-e_tmp */
tmp = shl( tmp, e_tmp ); /* Q15 */
- v_multc_fixed_16( sts[1]->hTcxEnc->spectrum_fx[k], tmp, sts[1]->hTcxEnc->spectrum_fx[k], L_frameTCX ); /* Q31-spectrum_e[k] */
- v_multc_fixed_16( mdst_spectrum_fx[1][k], tmp, mdst_spectrum_fx[1][k], L_frameTCX ); /* q_spec */
+ v_multc_fixed_16( sts[1]->hTcxEnc->spectrum_fx[k], tmp, sts[1]->hTcxEnc->spectrum_fx[k], L_frameTCX ); /* exp: exp_spec */
+ v_multc_fixed_16( mdst_spectrum_fx[1][k], tmp, mdst_spectrum_fx[1][k], L_frameTCX ); /* exp: exp_mdct_spec */
}
ELSE IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( nrgRatio_fx[k], nrgRatio_e[k], ONE_IN_Q27, 4 ), -1 ) && LT_16( k, EQ_16( sts[0]->core, TCX_20_CORE ) ? 1 : NB_DIV ) )
{
@@ -264,8 +265,8 @@ void stereo_coder_tcx_fx(
L_frameTCX = idiv1616( L_frameTCX, ( sts[0]->core == TCX_20_CORE ) ? 1 : NB_DIV ); /* Q0 */
/* This operation is resulting in some high MLDs in fixed point. */
- v_multc_fixed_16( sts[0]->hTcxEnc->spectrum_fx[k], extract_l( L_shr( nrgRatio_fx[k], 16 - nrgRatio_e[k] ) ), sts[0]->hTcxEnc->spectrum_fx[k], L_frameTCX ); /* Q31-spectrum_e[k] */
- v_multc_fixed_16( mdst_spectrum_fx[0][k], extract_l( L_shr( nrgRatio_fx[k], 16 - nrgRatio_e[k] ) ), mdst_spectrum_fx[0][k], L_frameTCX ); /* q_spec */
+ v_multc_fixed_16( sts[0]->hTcxEnc->spectrum_fx[k], extract_l( L_shr( nrgRatio_fx[k], 16 - nrgRatio_e[k] ) ), sts[0]->hTcxEnc->spectrum_fx[k], L_frameTCX ); /* exp: exp_spec */
+ v_multc_fixed_16( mdst_spectrum_fx[0][k], extract_l( L_shr( nrgRatio_fx[k], 16 - nrgRatio_e[k] ) ), mdst_spectrum_fx[0][k], L_frameTCX ); /* exp: exp_mdct_spec */
}
}
}
@@ -356,7 +357,7 @@ void stereo_coder_tcx_fx(
move16();
const Word16 sfbWidth = sub( endLine, startLine );
- nrgRatio_e[0] = nrgRatio_e[1] = sub( Q31, q_spec );
+ nrgRatio_e[0] = nrgRatio_e[1] = exp_spec;
move16();
move16();
@@ -370,10 +371,12 @@ void stereo_coder_tcx_fx(
{
Word32 tmp_fx;
Word16 tmp_e;
- tmp_e = sub( Q31, q_spec );
+ tmp_e = exp_mdct_spec;
+ move16();
tmp_fx = sum2_32_fx( &mdst_spectrum_fx[0][k][startLine], sfbWidth, &tmp_e ); /* Q31-tmp_e */
nrgRatio_fx[0] = BASOP_Util_Add_Mant32Exp( nrgRatio_fx[0], nrgRatio_e[0], tmp_fx, tmp_e, &nrgRatio_e[0] ); /* Q31-nrgRatio_e[0] */
- tmp_e = sub( Q31, q_spec );
+ tmp_e = exp_mdct_spec;
+ move16();
tmp_fx = sum2_32_fx( &mdst_spectrum_fx[1][k][startLine], sfbWidth, &tmp_e ); /* Q31-tmp_e */
nrgRatio_fx[1] = BASOP_Util_Add_Mant32Exp( nrgRatio_fx[1], nrgRatio_e[1], tmp_fx, tmp_e, &nrgRatio_e[1] ); /* Q31-nrgRatio_e[1] */
}
@@ -382,14 +385,14 @@ void stereo_coder_tcx_fx(
Word16 fTemp_e, tmp_e;
Word32 fTemp_fx = BASOP_Util_Add_Mant32Exp( nrgRatio_fx[0], nrgRatio_e[0], nrgRatio_fx[1], nrgRatio_e[1], &fTemp_e ); /* Q31-fTemp_e */
fTemp_e = sub( fTemp_e, 1 );
- nrgRatio_fx[0] = BASOP_Util_Divide3232_Scale_cadence( fTemp_fx, nrgRatio_fx[0], &tmp_e ); /* Q31 - tmp_e - fTemp_e + nrgRatio_e[0] */
+ nrgRatio_fx[0] = BASOP_Util_Divide3232_Scale_newton( fTemp_fx, nrgRatio_fx[0], &tmp_e ); /* Q31 - tmp_e - fTemp_e + nrgRatio_e[0] */
move32();
nrgRatio_e[0] = add( tmp_e, sub( fTemp_e, nrgRatio_e[0] ) );
move16();
nrgRatio_fx[0] = Sqrt32( nrgRatio_fx[0], &nrgRatio_e[0] ); /* Q31-nrgRatio_e[0] */
move32();
- nrgRatio_fx[1] = BASOP_Util_Divide3232_Scale_cadence( fTemp_fx, nrgRatio_fx[1], &tmp_e ); /* Q31 - tmp_e - fTemp_e + nrgRatio_e[1] */
+ nrgRatio_fx[1] = BASOP_Util_Divide3232_Scale_newton( fTemp_fx, nrgRatio_fx[1], &tmp_e ); /* Q31 - tmp_e - fTemp_e + nrgRatio_e[1] */
move32();
nrgRatio_e[1] = add( tmp_e, sub( fTemp_e, nrgRatio_e[1] ) );
move16();
@@ -426,15 +429,15 @@ void stereo_coder_tcx_fx(
move32();
- v_multc_fixed( &sts[0]->hTcxEnc->spectrum_fx[k][startLine], nrgRatio_fx[0], &sts[0]->hTcxEnc->spectrum_fx[k][startLine], sfbWidth ); /* q_spec+30-31 */
- v_multc_fixed( &mdst_spectrum_fx[0][k][startLine], nrgRatio_fx[0], &mdst_spectrum_fx[0][k][startLine], sfbWidth ); /* q_spec+30-31 */
- scale_sig32( &sts[0]->hTcxEnc->spectrum_fx[k][startLine], sfbWidth, Q1 ); // Scaling back to q_spec
- scale_sig32( &mdst_spectrum_fx[0][k][startLine], sfbWidth, Q1 ); // Scaling back to q_spec
+ v_multc_fixed( &sts[0]->hTcxEnc->spectrum_fx[k][startLine], nrgRatio_fx[0], &sts[0]->hTcxEnc->spectrum_fx[k][startLine], sfbWidth ); /* exp: exp_spec+1 */
+ v_multc_fixed( &mdst_spectrum_fx[0][k][startLine], nrgRatio_fx[0], &mdst_spectrum_fx[0][k][startLine], sfbWidth ); /* exp: exp_mdct_spec+1 */
+ scale_sig32( &sts[0]->hTcxEnc->spectrum_fx[k][startLine], sfbWidth, Q1 ); // exp: exp_spec
+ scale_sig32( &mdst_spectrum_fx[0][k][startLine], sfbWidth, Q1 ); // exp: exp_mdct_spec
- v_multc_fixed( &sts[1]->hTcxEnc->spectrum_fx[k][startLine], nrgRatio_fx[1], &sts[1]->hTcxEnc->spectrum_fx[k][startLine], sfbWidth ); /* q_spec+30-31 */
- v_multc_fixed( &mdst_spectrum_fx[1][k][startLine], nrgRatio_fx[1], &mdst_spectrum_fx[1][k][startLine], sfbWidth ); /* q_spec+30-31 */
- scale_sig32( &sts[1]->hTcxEnc->spectrum_fx[k][startLine], sfbWidth, Q1 ); // Scaling back to q_spec
- scale_sig32( &mdst_spectrum_fx[1][k][startLine], sfbWidth, Q1 ); // Scaling back to q_spec
+ v_multc_fixed( &sts[1]->hTcxEnc->spectrum_fx[k][startLine], nrgRatio_fx[1], &sts[1]->hTcxEnc->spectrum_fx[k][startLine], sfbWidth ); /* exp: exp_spec+1 */
+ v_multc_fixed( &mdst_spectrum_fx[1][k][startLine], nrgRatio_fx[1], &mdst_spectrum_fx[1][k][startLine], sfbWidth ); /* exp: exp_mdct_spec+1 */
+ scale_sig32( &sts[1]->hTcxEnc->spectrum_fx[k][startLine], sfbWidth, Q1 ); // exp: exp_spec
+ scale_sig32( &mdst_spectrum_fx[1][k][startLine], sfbWidth, Q1 ); // exp: exp_mdct_spec
}
}
}
@@ -469,11 +472,11 @@ void stereo_coder_tcx_fx(
nAvailBitsMS[k] = idiv1616( nAvailBitsMS[k], nSubframes ); /* Q0 */
move16();
- MsStereoDecision_fx( sfbConf, sts[0]->hTcxEnc->spectrum_fx[k], sts[1]->hTcxEnc->spectrum_fx[k], inv_spectrum_fx[0][k], inv_spectrum_fx[1][k], q_spec, &hStereoMdct->mdct_stereo_mode[k], &ms_mask[k][0], nAvailBitsMS[k] );
+ MsStereoDecision_fx( sfbConf, sts[0]->hTcxEnc->spectrum_fx[k], sts[1]->hTcxEnc->spectrum_fx[k], inv_spectrum_fx[0][k], inv_spectrum_fx[1][k], sub( Q31, exp_spec ), &hStereoMdct->mdct_stereo_mode[k], &ms_mask[k][0], nAvailBitsMS[k] );
IF( sts[0]->igf )
{
- IGFEncStereoEncoder_fx( sfbConf, sts[0]->hIGFEnc, sts[0]->hTcxEnc->spectrum_fx[k], sts[1]->hTcxEnc->spectrum_fx[k], q_spec, &ms_mask[k][0],
+ IGFEncStereoEncoder_fx( sfbConf, sts[0]->hIGFEnc, sts[0]->hTcxEnc->spectrum_fx[k], sts[1]->hTcxEnc->spectrum_fx[k], sub( Q31, exp_spec ), &ms_mask[k][0],
&hStereoMdct->IGFStereoMode[k], hStereoMdct->mdct_stereo_mode[k], (Word16) EQ_16( sts[0]->core, TCX_20_CORE ), (Word16) EQ_16( sts[0]->last_core, ACELP_CORE ) );
}
ELSE
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 6ffd05c0c488dcfb4e56c7a582c7f79c21ed4628..909d0c206f5dd2718f1a229b6d52ef6e42aba110 100644
--- a/lib_enc/ivas_stereo_td_analysis_fx.c
+++ b/lib_enc/ivas_stereo_td_analysis_fx.c
@@ -340,8 +340,8 @@ Word16 stereo_tdm_ener_analysis_fx(
test();
IF( ( LE_32( hStereoTD->tdm_lt_rms_L_fx, rms_thd_fx ) && LE_32( hStereoTD->tdm_lt_rms_R_fx, L_shl( rms_thd_fx, 1 ) ) ) ||
( LE_32( hStereoTD->tdm_lt_rms_R_fx, rms_thd_fx ) && LE_32( hStereoTD->tdm_lt_rms_L_fx, L_shl( rms_thd_fx, 1 ) ) ) ||
- ( sts[0]->hVAD->hangover_cnt != 0 && LT_16( sts[1]->hNoiseEst->Etot_last_fx, 3072 /*12 in Q8*/ ) ) ||
- ( sts[1]->hVAD->hangover_cnt != 0 && LT_16( sts[0]->hNoiseEst->Etot_last_fx, 3072 /*12 in Q8*/ ) ) ||
+ ( sts[0]->hVAD->hangover_cnt != 0 && LT_32( sts[1]->hNoiseEst->Etot_last_32fx, 201326592 /*12 in Q24*/ ) ) ||
+ ( sts[1]->hVAD->hangover_cnt != 0 && LT_32( sts[0]->hNoiseEst->Etot_last_32fx, 201326592 /*12 in Q24*/ ) ) ||
( NE_16( sts[0]->hSpMusClas->past_dec[0], sts[1]->hSpMusClas->past_dec[0] ) ) )
{
test();
@@ -873,8 +873,8 @@ static Word16 Get_dt_lt_ener_fx(
move32();
*tdm_lt_rms_R = L_shl( Mpy_32_32( 1932735282 /* 0.9f in Q31 */, rms_R ), sub( Q16, q_rms_R ) ); // (Q31, q_rms_R) -> q_rms_R -> Q16
move32();
- L_tmp = Mpy_32_16_1( 1932735282 /* 0.9f in Q31 */, sts[0]->hNoiseEst->Etot_last_fx ); //(Q31, Q8) -> Q24
- sts[1]->hNoiseEst->Etot_last_fx = extract_h( L_tmp ); // (Q24 >> Q16) -> Q8
+ L_tmp = Mpy_32_32( 1932735282 /* 0.9f in Q31 */, sts[0]->hNoiseEst->Etot_last_32fx ); //(Q31, Q24) -> Q24
+ sts[1]->hNoiseEst->Etot_last_32fx = L_tmp; // (Q24 >> Q16) -> Q8
sts[1]->hVAD->hangover_cnt = 0;
move16();
}
@@ -2013,7 +2013,7 @@ static void Get_corr_n_fx(
}
ELSE
{
- *ic_Lm = BASOP_Util_Divide3232_Scale_cadence( corrL, ener, &exp_diff ); // (Q31 - exp_diff)
+ *ic_Lm = BASOP_Util_Divide3232_Scale_newton( corrL, ener, &exp_diff ); // (Q31 - exp_diff)
move32();
IF( *ic_Lm == 0 )
{
@@ -2025,7 +2025,7 @@ static void Get_corr_n_fx(
*q_ic_Lm = sub( Q31, exp_diff );
move16();
}
- *ic_Rm = BASOP_Util_Divide3232_Scale_cadence( corrR, ener, &exp_diff ); // (Q31 - exp_diff)
+ *ic_Rm = BASOP_Util_Divide3232_Scale_newton( corrR, ener, &exp_diff ); // (Q31 - exp_diff)
move16();
IF( *ic_Rm == 0 )
{
@@ -2041,7 +2041,7 @@ static void Get_corr_n_fx(
/* *es_em = 10 * ( log10f( sqrtf( ener_side / len ) ) - log10f( sqrtf( ener / len ) ) );
is simplified to
*es_em = 10 * ( log10f( sqrtf( ener_side / ener ) ) ); */
- L_tmp = BASOP_Util_Divide3232_Scale_cadence( ener_side, ener, &exp_diff ); // (Q31 - exp_diff)
+ L_tmp = BASOP_Util_Divide3232_Scale_newton( ener_side, ener, &exp_diff ); // (Q31 - exp_diff)
L_tmp = Sqrt32( L_tmp, &exp_diff ); /* (Q31 - exp_diff) */
L_tmp = BASOP_Util_Log2( L_tmp ); /* Q25 */
*es_em = Mpy_32_32( Mpy_32_32( L_add( L_tmp, L_shl( exp_diff, Q25 ) ), LOG10_2_Q31 ), TEN_IN_Q27 ); // (Q25, Q27) -> Q21
diff --git a/lib_enc/ivas_tcx_core_enc_fx.c b/lib_enc/ivas_tcx_core_enc_fx.c
index fd84d2f214607c54aa281af61db11af3acfc41d6..5f2e9a8e094bc63e7bcff04b9133fe9530f4b5ff 100644
--- a/lib_enc/ivas_tcx_core_enc_fx.c
+++ b/lib_enc/ivas_tcx_core_enc_fx.c
@@ -1086,7 +1086,7 @@ Word16 ivas_acelp_tcx20_switching_fx(
nrg_s = BASOP_Util_Add_Mant32Exp( nrg_s, e_num, Mpy_32_32( y_fx[i], y_fx[i] ), shl( e_x, 1 ), &e_num ); /* Q31-e_num */
nrg_n = BASOP_Util_Add_Mant32Exp( nrg_n, e_den, Mpy_32_32( x_fx[i], x_fx[i] ), shl( temp_ene_e, 1 ), &e_den ); /* Q31-e_den */
}
- res_cod_SNR_M[iter] = BASOP_Util_Divide3232_Scale_cadence( nrg_s, nrg_n, &temp_e ); /* Q31-res_cod_SNR_M_e[iter] */
+ res_cod_SNR_M[iter] = BASOP_Util_Divide3232_Scale_newton( nrg_s, nrg_n, &temp_e ); /* Q31-res_cod_SNR_M_e[iter] */
move32();
res_cod_SNR_M_e[iter] = add( temp_e, sub( e_num, e_den ) );
move16();
diff --git a/lib_enc/ivas_td_low_rate_enc_fx.c b/lib_enc/ivas_td_low_rate_enc_fx.c
index 77ddb35aaf38b39ea89084727e9e325ef7dccb92..d10527a241855fcf154159a26d233abe764773e3 100644
--- a/lib_enc/ivas_td_low_rate_enc_fx.c
+++ b/lib_enc/ivas_td_low_rate_enc_fx.c
@@ -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 79b799c3887536503b820965373674f5d62ae5f9..8b20cab7d2478c43ebf051cddd88fbdfbcadcc41 100644
--- a/lib_enc/lib_enc.c
+++ b/lib_enc/lib_enc_fx.c
@@ -1665,6 +1665,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;
@@ -1788,7 +1792,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 )
{
@@ -1928,7 +1937,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;
@@ -2655,41 +2669,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 af57edd3bd4629ef64c1c16842bc91d572fd67c7..60c40b3fe770908e01a5e17cb49a89bd2c45f234 100644
--- a/lib_enc/long_enr_fx.c
+++ b/lib_enc/long_enr_fx.c
@@ -94,7 +94,7 @@ void ivas_long_enr_fx(
}
FOR( n = 0; n < n_chan; n++ )
{
- hFrontVad[n]->hNoiseEst->Etot_last_fx = Etot_LR[n]; /* Q8 */
+ hFrontVad[n]->hNoiseEst->Etot_last_32fx = L_deposit_h( Etot_LR[n] ); /* Q24 */
move16();
}
}
@@ -141,7 +141,7 @@ void ivas_long_enr_fx(
}
}
/* Update */
- st_fx->hNoiseEst->Etot_last_fx = Etot; /* Q8 */
+ st_fx->hNoiseEst->Etot_last_32fx = L_deposit_h( Etot ); /* Q24 */
move16();
}
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 c8f698da907bbefd41bbee045fe960fe0ab9a892..4f178214f47fe7d14821c7cdc9739a2c2de1a37f 100644
--- a/lib_enc/nois_est_fx.c
+++ b/lib_enc/nois_est_fx.c
@@ -359,17 +359,17 @@ void noise_est_init_ivas_fx(
hNoiseEst->Etot_lp_fx = 0;
hNoiseEst->Etot_h_fx = 0;
hNoiseEst->Etot_l_fx = 0;
- hNoiseEst->Etot_l_lp_fx = 0;
- hNoiseEst->Etot_last_fx = 0;
- hNoiseEst->Etot_v_h2_fx = 0;
+ hNoiseEst->Etot_l_lp_32fx = 0;
+ hNoiseEst->Etot_last_32fx = 0;
+ hNoiseEst->Etot_v_h2_32fx = 0;
hNoiseEst->sign_dyn_lp_fx = 0;
move16();
move16();
move16();
move16();
- move16();
- move16();
- move16();
+ move32();
+ move32();
+ move32();
return;
}
@@ -510,12 +510,12 @@ void noise_est_pre_32fx(
move32();
Etot_l_32fx = Etot;
move32();
- hNoiseEst->Etot_l_lp_fx = extract_h( Etot ); // Q8
- move16();
- hNoiseEst->Etot_last_fx = extract_h( Etot ); // Q8
- move16();
- hNoiseEst->Etot_v_h2_fx = 0;
- move16();
+ hNoiseEst->Etot_l_lp_32fx = Etot; // Q24
+ move32();
+ hNoiseEst->Etot_last_32fx = Etot; // Q24
+ move32();
+ hNoiseEst->Etot_v_h2_32fx = 0;
+ move32();
Etot_lp_32fx = Etot;
move32();
hNoiseEst->sign_dyn_lp_fx = 0;
@@ -538,20 +538,20 @@ void noise_est_pre_32fx(
)
{
/* *Etot_l += min(2,(*Etot_last-*Etot_l)*0.1f); */
- tmp = Mpy_32_32( L_sub( L_deposit_h( hNoiseEst->Etot_last_fx ), Etot_l_32fx ), 214748365 ); /* 0.1f factor in Q31 */
- tmp = L_min( 33554432, tmp ); /* 2.0 in Q24 is 33554432 */
- Etot_l_32fx = L_add( Etot_l_32fx, tmp ); /* Q24 */
+ tmp = Mpy_32_32( L_sub( ( hNoiseEst->Etot_last_32fx ), Etot_l_32fx ), 214748365 ); /* 0.1f factor in Q31 */
+ tmp = L_min( 33554432, tmp ); /* 2.0 in Q24 is 33554432 */
+ Etot_l_32fx = L_add( Etot_l_32fx, tmp ); /* Q24 */
}
/* Avoids large steps in short active segments */
test();
- IF( ( GT_32( L_sub( L_deposit_h( hNoiseEst->Etot_last_fx ), Etot_l_32fx ), 503316480 ) ) /* 30.0f*Q24 */
+ IF( ( GT_32( L_sub( hNoiseEst->Etot_last_32fx, Etot_l_32fx ), 503316480 ) ) /* 30.0f*Q24 */
&& ( GT_16( hNoiseEst->harm_cor_cnt, HE_LT_CNT_PRE_SHORT_FX ) ) )
{
/* *Etot_l += (*Etot_last-*Etot_l)*0.02f; */
- Etot_l_32fx = L_add( Etot_l_32fx, Mpy_32_32( L_sub( L_deposit_h( hNoiseEst->Etot_last_fx ), Etot_l_32fx ), 42949673 ) ); /* 0.02 in Q24*/
+ Etot_l_32fx = L_add( Etot_l_32fx, Mpy_32_32( L_sub( hNoiseEst->Etot_last_32fx, Etot_l_32fx ), 42949673 ) ); /* 0.02 in Q24*/
}
- ELSE IF( GT_32( L_sub( L_deposit_h( hNoiseEst->Etot_last_fx ), Etot_l_32fx ), 167772160 ) ) /* 10.0 in Q24*/
+ ELSE IF( GT_32( L_sub( hNoiseEst->Etot_last_32fx, Etot_l_32fx ), 167772160 ) ) /* 10.0 in Q24*/
{
Etot_l_32fx = L_add( Etot_l_32fx, 1342177 ); /* 0.08 in Q24*/
}
@@ -560,10 +560,10 @@ void noise_est_pre_32fx(
Etot_l_32fx = L_min( Etot_l_32fx, Etot ); // Q24
test();
- IF( LT_16( ini_frame_fx, 100 ) && LT_32( Etot_l_32fx, L_deposit_h( hNoiseEst->Etot_l_lp_fx ) ) )
+ IF( LT_16( ini_frame_fx, 100 ) && LT_32( Etot_l_32fx, ( hNoiseEst->Etot_l_lp_32fx ) ) )
{
/**Etot_l_lp = 0.1f * *Etot_l + (1.0f - 0.1) * *Etot_l_lp; */
- hNoiseEst->Etot_l_lp_fx = extract_h( L_add( Mpy_32_32( 214748364 /* 0.1f in Q31*/, Etot_l_32fx ), Mpy_32_32( 1932735283 /* 0.9f in Q31*/, L_deposit_h( hNoiseEst->Etot_l_lp_fx ) ) ) ); // Q8
+ hNoiseEst->Etot_l_lp_32fx = W_round64_L( W_add( W_mult_32_32( 214748364 /* 0.1f in Q31*/, Etot_l_32fx ), W_mult_32_32( 1932735283 /* 0.9f in Q31*/, hNoiseEst->Etot_l_lp_32fx ) ) ); // Q8
move16();
}
ELSE
@@ -572,16 +572,16 @@ void noise_est_pre_32fx(
test();
test();
test();
- IF( ( ( GT_16( hNoiseEst->harm_cor_cnt, HE_LT_CNT_FX ) ) && ( GT_32( L_sub_sat( L_deposit_h( hNoiseEst->Etot_last_fx ), Etot_l_32fx ), HE_LT_THR2_Q24 ) ) ) || ( ( sub( hNoiseEst->harm_cor_cnt, HE_LT_CNT_FX ) > 0 ) && ( LT_16( ini_frame_fx, HE_LT_CNT_INIT_FX ) ) ) || ( GT_32( L_sub_sat( L_deposit_h( hNoiseEst->Etot_l_lp_fx ), Etot_l_32fx ), HE_LT_THR2_Q24 ) ) )
+ IF( ( ( GT_16( hNoiseEst->harm_cor_cnt, HE_LT_CNT_FX ) ) && ( GT_32( L_sub_sat( hNoiseEst->Etot_last_32fx, Etot_l_32fx ), HE_LT_THR2_Q24 ) ) ) || ( ( sub( hNoiseEst->harm_cor_cnt, HE_LT_CNT_FX ) > 0 ) && ( LT_16( ini_frame_fx, HE_LT_CNT_INIT_FX ) ) ) || ( GT_32( L_sub_sat( hNoiseEst->Etot_l_lp_32fx, Etot_l_32fx ), HE_LT_THR2_Q24 ) ) )
{
/**Etot_l_lp = 0.03f * *Etot_l + (1.0f - 0.03f) * *Etot_l_lp; */
- hNoiseEst->Etot_l_lp_fx = extract_h( L_add( Mpy_32_32( 64424509 /* 0.03f in Q31*/, Etot_l_32fx ), Mpy_32_32( 2083059139 /* 0.97f in Q31*/, L_deposit_h( hNoiseEst->Etot_l_lp_fx ) ) ) ); // Q8
+ hNoiseEst->Etot_l_lp_32fx = W_extract_h( W_add( W_mult_32_32( 64424509 /* 0.03f in Q31*/, Etot_l_32fx ), W_mult_32_32( 2083059139 /* 0.97f in Q31*/, hNoiseEst->Etot_l_lp_32fx ) ) ); // Q24
move16();
}
ELSE
{
/* *Etot_l_lp = 0.02f * *Etot_l + (1.0f - 0.02f) * *Etot_l_lp; */
- hNoiseEst->Etot_l_lp_fx = extract_h( L_add( Mpy_32_32( 42949673 /* 0.02f in Q31*/, Etot_l_32fx ), Mpy_32_32( 2104533975 /* 0.98f in Q31*/, L_deposit_h( hNoiseEst->Etot_l_lp_fx ) ) ) ); // Q8
+ hNoiseEst->Etot_l_lp_32fx = W_extract_h( W_add( W_mult_32_32( 42949673 /* 0.02f in Q31*/, Etot_l_32fx ), W_mult_32_32( 2104533975 /* 0.98f in Q31*/, hNoiseEst->Etot_l_lp_32fx ) ) ); // Q24
move16();
}
}
@@ -748,9 +748,9 @@ void noise_est_down_ivas_fx(
const Word16 min_band, /* i : minimum critical band */
const Word16 max_band, /* i : maximum critical band */
Word16 *totalNoise, /* o : noise estimate over all critical bands */
- Word16 Etot, /* i : Energy of current frame */
- Word16 *Etot_last, /* i/o: Energy of last frame Q8 */
- Word16 *Etot_v_h2 /* i/o: Energy variations of noise frames Q8 */
+ Word32 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 */
)
{
@@ -770,9 +770,10 @@ void noise_est_down_ivas_fx(
Copy32( bckr, bckr32, NB_BANDS );
set16_fx( bckr_q, *q_bckr, NB_BANDS );
- L_Etot = L_shl( Etot, 16 ); /*Q24 for later AR1 computations*/
- L_Etot_last = L_shl( *Etot_last, 16 );
- L_Etot_v_h2 = L_shl( *Etot_v_h2, 16 );
+ L_Etot = Etot; /*Q24 for later AR1 computations*/
+ move32();
+ L_Etot_last = *Etot_last;
+ L_Etot_v_h2 = *Etot_v_h2;
/*-----------------------------------------------------------------*
* Estimate total noise energy
@@ -900,7 +901,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;
@@ -2253,6 +2254,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 */
@@ -2989,7 +2991,7 @@ void noise_est_ivas_fx(
move16();
/* st->lt_Ellp_dist = 0.03f* (Etot - st->Etot_l_lp) + 0.97f*st->lt_Ellp_dist;*/
- tmp = sub( Etot, hNoiseEst->Etot_l_lp_fx ); /* Q8 */
+ tmp = sub( Etot, extract_h( hNoiseEst->Etot_l_lp_32fx ) ); /* Q8 */
hNoiseEst->lt_Ellp_dist_fx = mac_r( L_mult( tmp, 983 /* 0.03 in Q15*/ ), hNoiseEst->lt_Ellp_dist_fx, 31785 /* 0.97 in Q15*/ ); // Q8
move16();
@@ -3001,7 +3003,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
@@ -3180,7 +3182,7 @@ void noise_est_ivas_fx(
{
tmp = shl( tmp, 1 ); /*1.5 + 1.5 Q13 */
}
- Ltmp = L_deposit_h( hNoiseEst->Etot_l_lp_fx );
+ 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*/
/* enr_bgd = Etot < Etot_l_lp_thr; */
@@ -3365,8 +3367,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, hNoiseEst->Etot_l_lp_fx ), 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_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*/
&& ( GT_16( *st_harm_cor_cnt, 20 ) ) )
{
sd1_bgd = 1;
@@ -3492,7 +3494,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( hNoiseEst->totalNoise_fx, 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;
@@ -3558,14 +3560,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_ol_fx.c b/lib_enc/pitch_ol_fx.c
index 91181714af9242f49697b8f221c167f31d525faf..fdadcd318be997001ac0ec11996edee7c1423496 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)
diff --git a/lib_enc/pre_proc_fx.c b/lib_enc/pre_proc_fx.c
index cbb2cf421564b73d0e51c62baef7b4988667fe3e..f7ebc8298cbff4ec232d23900b37bf55e03dea18 100644
--- a/lib_enc/pre_proc_fx.c
+++ b/lib_enc/pre_proc_fx.c
@@ -414,7 +414,7 @@ void pre_proc_fx(
alw_voicing[1] = st->voicing_fx[2];
move16();
- 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 );
+ 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 );
@@ -1127,7 +1127,7 @@ void pre_proc_fx(
Copy( st->lsp_old1_fx, st->lspold_enc_fx, M );
}
- 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 );
+ 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 d6532b207ae1558aa79c20ed75f88e56466df7d5..8e323af82452d586d670578d067b0cd1af1a2d5b 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,58 +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 */
- 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 : 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 );
-
-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] */
@@ -125,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] */
@@ -146,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(
@@ -165,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(
@@ -211,9 +195,10 @@ void fb_tbe_enc_fx(
void fb_tbe_enc_ivas_fx(
Encoder_State *st, /* i/o: encoder state structure */
- const Word16 new_input[], /* i : i speech at 48 kHz sample rate Q0*/
+ const Word16 new_input[], /* i : i speech at 48 kHz sample rate Q_new_input*/
const Word16 fb_exc[], /* i : FB excitation from the SWB part Q_fb_exc*/
- Word16 Q_fb_exc );
+ Word16 Q_fb_exc,
+ Word16 Q_new_input );
void fb_tbe_reset_enc_fx(
Word32 elliptic_bpf_2_48k_mem_fx[][4],
@@ -363,9 +348,9 @@ void noise_est_down_ivas_fx(
const Word16 min_band, /* i : minimum critical band */
const Word16 max_band, /* i : maximum critical band */
Word16 *totalNoise, /* o : noise estimate over all critical bands */
- Word16 Etot, /* i : Energy of current frame */
- Word16 *Etot_last, /* i/o: Energy of last frame Q8 */
- Word16 *Etot_v_h2 /* i/o: Energy variations of noise frames Q8 */
+ Word32 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(
@@ -564,6 +549,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 */
@@ -633,6 +627,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 );
@@ -1238,8 +1233,9 @@ void ProcessIGF_ivas_fx(
Encoder_State *st, /* i : Encoder state */
Word16 powerSpec_len, /* i : length of pPowerSpectrum buffer */
Word32 *pMDCTSpectrum, /* i : MDCT spectrum */
- const Word32 *pITFMDCTSpectrum, /* i : MDCT spectrum fir ITF */
Word16 *q_spectrum, /* i/o: Q of spectrum */
+ const Word32 *pITFMDCTSpectrum, /* i : MDCT spectrum fir ITF */
+ const Word16 q_ITFMDCTSpectrum, /* i : Q of MDCT spectrum fir ITF */
Word32 *pPowerSpectrum, /* i : MDCT^2 + MDST^2 spectrum, or estimate */
Word16 *q_powerSpec, /* i/o: Q of power spectrum */
const Word16 isTCX20, /* i : flag indicating if the input is TCX20 or TCX10/2xTCX5 */
@@ -2192,7 +2188,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 */
@@ -2223,7 +2219,7 @@ void ivas_analy_sp_fx(
Word16 *q_fr_bands, /* o : energy in critical frequency bands Q0 */
Word32 *lf_E, /* o : per bin E for first... q_lf_E */
Word16 *q_lf_E, /* o : per bin E for first... Q0 */
- Word16 *Etot, /* o : total input energy Q8 */
+ Word32 *Etot, /* o : total input energy Q24 */
const Word16 min_band, /* i : minimum critical band Q0 */
const Word16 max_band, /* i : maximum critical band Q0 */
Word32 *Bin_E, /* o : per-bin energy spectrum q_Bin_E */
@@ -2317,22 +2313,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 +3048,13 @@ Word16 IGF_getSFM( /**< out: Q15| SFM value
const Word16 start, /**< in: Q0 | start subband index */
const Word16 stop /**< in: Q0 | stop subband index */
);
+Word16 IGF_getSFM_ivas_fx( /**< out: Q15| SFM value */
+ Word16 *SFM_exp, /**< out: | exponent of SFM Factor */
+ const Word32 *energy, /**< in: Q31| energies */
+ const Word16 *energy_exp, /**< in: | exponent of energies */
+ const Word16 start, /**< in: Q0 | start subband index */
+ const Word16 stop /**< in: Q0 | stop subband index */
+);
/* IGFEnc.c */
void IGF_ErodeSpectrum( Word16 *highPassEner_exp, /**< out: | exponent of highPassEner */
const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Encoder */
@@ -4819,5 +4808,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 3f6449a0c833664e90dec64c1e959ea729483a92..817e5fb70a5782fc5c56d32aab9605d3abb3dc30 100644
--- a/lib_enc/speech_music_classif_fx.c
+++ b/lib_enc/speech_music_classif_fx.c
@@ -1937,6 +1937,7 @@ Word16 ivas_smc_gmm_fx(
/* calculation of differential normalized power spectrum */
sum_PS_fx = 0;
move32();
+ Word16 q_temp32;
Word16 sum_PS_e = 0;
move16();
Word64 sum = W_shl( 21475 /* 1e-5 in Q31 */, sub( Qfact_PS, 30 ) ); // Qfact_PS+1
@@ -1961,8 +1962,22 @@ Word16 ivas_smc_gmm_fx(
FOR( i = LOWEST_FBIN; i < HIGHEST_FBIN; i++ )
{
- temp32 = BASOP_Util_Divide3232_Scale_cadence( PS_fx[i], sum_PS_fx, &temp_exp ); // 31-temp_exp
- PS_norm_fx[i] = L_shl( temp32, sub( Qfact_PS_past, add( sub( 31, temp_exp ), sub( Qfact_PS, sub( 31, sum_PS_e ) ) ) ) ); // Qfact_PS_past
+ temp32 = BASOP_Util_Divide3232_Scale_newton( PS_fx[i], sum_PS_fx, &temp_exp ); // 31-temp_exp
+ q_temp32 = add( sub( 31, temp_exp ), sub( Qfact_PS, sub( 31, sum_PS_e ) ) );
+ test();
+ if ( temp32 == 0 )
+ {
+ q_temp32 = 31;
+ move16();
+ }
+ IF( LT_16( q_temp32, 31 ) && EQ_32( temp32, L_shl( 1, q_temp32 ) ) )
+ {
+ temp32 = ONE_IN_Q31;
+ move32();
+ q_temp32 = Q31;
+ move16();
+ }
+ PS_norm_fx[i] = L_shl( temp32, sub( Qfact_PS_past, q_temp32 ) ); // Qfact_PS_past
move32();
dPS_fx[i] = L_abs( L_sub( PS_norm_fx[i], hSpMusClas->past_PS_fx[i - LOWEST_FBIN] ) );
move32();
@@ -1991,8 +2006,8 @@ Word16 ivas_smc_gmm_fx(
{
Word32 tmp_max;
tmp_max = L_max( PS_norm_fx[i], hSpMusClas->past_PS_fx[i - LOWEST_FBIN] );
-
- temp32 = BASOP_Util_Divide3232_Scale_cadence( tmp_max, L_add( dPS_fx[i], avoid_divide_by_zero ), &temp_exp ); // 31-temp_exp
+ /* Saturation doesn't have a significant impact here, as a value of 1e-5 in Q31 format is added to prevent division by zero */
+ temp32 = BASOP_Util_Divide3232_Scale_newton( tmp_max, L_add_sat( dPS_fx[i], avoid_divide_by_zero ), &temp_exp ); // 31-temp_exp
ps_sta_fx = BASOP_Util_Add_Mant32Exp( temp32, temp_exp, ps_sta_fx, ps_sta_exp, &ps_sta_exp );
}
temp32_log = L_add( BASOP_Util_Log2( L_add_sat( ps_sta_fx, L_shr( 21475, ps_sta_exp ) ) ), L_shl( ps_sta_exp, Q25 ) );
@@ -2166,7 +2181,11 @@ Word16 ivas_smc_gmm_fx(
}
/* PCA */
+#ifdef VEC_ARITH_OPT_v1
+ v_sub_fixed_no_hdrm( FV_fx, pca_mean_fx, FV_fx, N_SMC_FEATURES );
+#else /* VEC_ARITH_OPT_v1 */
v_sub_fixed( FV_fx, pca_mean_fx, FV_fx, N_SMC_FEATURES, 0 );
+#endif /* VEC_ARITH_OPT_v1 */
v_mult_mat_fixed( FV_fx, FV_fx, pca_components_fx, N_SMC_FEATURES, N_PCA_COEF, 0 );
/*------------------------------------------------------------------*
* Calculation of posterior probability
@@ -2593,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;
@@ -2646,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;
@@ -2676,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;
diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h
index c6176709b2f4733d215c207e15f0a3b502358d4b..41383f109e706376c2f2a14a1941ae520149eac1 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 */
@@ -545,8 +549,10 @@ 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 */
- Word16 Etot_l_lp_fx; /* Q8 Noise estimator - Smoothed low energy */
- Word16 Etot_last_fx; /*Q8*/
+ 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*/
+ Word32 Etot_last_32fx; /* IVAS - Q24*/
Word16 Etot_lp_fx; /* Q8 Noise estimator - Filtered input energy */
Word16 lt_tn_track_fx; /* Q15 */
@@ -562,6 +568,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 } */
@@ -1011,7 +1018,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
@@ -1359,7 +1366,10 @@ typedef struct enc_core_structure
Word16 no_scales_fx[MAX_NO_MODES][2]; /* LSF LVQ structure Q0*/
Word16 no_scales_p_fx[MAX_NO_MODES_p][2]; /* LSF LVQ structure Q0*/
- Word16 mem_preemph_fx; /* preemphasis filter memory Q(-1) */
+ Word16 mem_preemph_fx; /* preemphasis filter memory Q(-1) */
+ Word16 mem_q; /* preemphasis filter memory Q(-1) */
+ Word16 mem_preemph_q; /* preemphasis filter memory Q(-1) */
+ Word16 mem_preemph_fx_q_inp; /* preemphasis filter memory Q(-1) */
Word16 old_wsp_fx[L_WSP_MEM]; /* old weighted signal vector */
Word16 exp_old_wsp;
@@ -1452,16 +1462,19 @@ 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;
Word32 *Bin_E_old_fx; /* per bin energy of old 2nd frames */
Word16 q_Bin_E_old;
- Word16 *mem_decim_fx; /* decimation filter memory Q(-1) */
- Word16 *mem_decim16k_fx; /* ACELP@16kHz - decimation filter memory @16kHz Q(-1) */
- Word16 *old_inp_12k8_fx; /* memory of input signal at 12.8kHz */
- Word16 *old_inp_16k_fx; /* ACELP@16kHz - memory of input signal @16 kHz */
+ Word16 *mem_decim_fx; /* decimation filter memory Q(-1) */
+ Word16 mem_decim_fx_q_inp[2 * L_FILT_MAX]; /* decimation filter memory Q(-1) */
+ Word16 *mem_decim16k_fx; /* ACELP@16kHz - decimation filter memory @16kHz Q(-1) */
+ Word16 *old_inp_12k8_fx; /* memory of input signal at 12.8kHz */
+ Word16 *old_inp_16k_fx; /* ACELP@16kHz - memory of input signal @16 kHz */
Word16 *buf_speech_enc_pe; // exp_buf_speech_enc_pe
Word16 *buf_synth; /*can be reduced to PIT_MAX_MAX+L_FRAME_MAX if no rate switching*/
@@ -1771,6 +1784,7 @@ typedef struct enc_core_structure
/* stereo switching memories */
Word16 mem_preemph_DFT_fx; /* Q(-1) */
+ Word16 mem_preemph_DFT_fx_q_inp; /* Q(-1) */
Word16 inp_12k8_mem_stereo_sw_fx[STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT]; /* Q(-1) */
Word16 mem_preemph16k_DFT_fx; /* Q(-1) */
Word16 inp_16k_mem_stereo_sw_fx[STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k]; /* Q(-1) */
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 316a5b5494e613ab5cf8ed39e651ca6c57ff478e..903f3a46c7f62292b1922a6ff7c7a51398098549 100644
--- a/lib_enc/swb_tbe_enc_fx.c
+++ b/lib_enc/swb_tbe_enc_fx.c
@@ -5683,7 +5683,11 @@ static void Quant_shb_res_gshape_fx(
move16();
IF( NE_16( st_fx->codec_mode, MODE2 ) )
{
+#ifdef FIX_1486_IND_SHB_RES
+ push_indice( st_fx->hBstr, IND_SHB_RES_GS + i, idxSubGain_fx[i], NUM_BITS_SHB_RES_GS );
+#else
push_indice( st_fx->hBstr, IND_SHB_RES_GS1 + i, idxSubGain_fx[i], NUM_BITS_SHB_RES_GS );
+#endif
}
}
}
@@ -5719,7 +5723,11 @@ static void Quant_shb_res_gshape_ivas_fx(
}
ELSE
{
+#ifdef FIX_1486_IND_SHB_RES
+ push_indice( st->hBstr, IND_SHB_RES_GS + i, idxSubGain_fx[i], NUM_BITS_SHB_RES_GS );
+#else
push_indice( st->hBstr, IND_SHB_RES_GS1 + i, idxSubGain_fx[i], NUM_BITS_SHB_RES_GS );
+#endif
}
}
}
@@ -7299,7 +7307,12 @@ void fb_tbe_enc_fx(
Word16 ratio;
Word16 tmp_vec[L_FRAME48k];
Word16 idxGain;
+#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic
+ Word16 input_fhb_buffer[L_FRAME48k + 4];
+ Word16 *input_fhb = &input_fhb_buffer[0] + 4;
+#else
Word16 input_fhb[L_FRAME48k];
+#endif
Word16 Sample_Delay_HP;
Word32 fb_exc_energy, temp2;
Word32 L_tmp;
@@ -7325,7 +7338,16 @@ void fb_tbe_enc_fx(
Copy_Scale_sig( new_input, input_fhb, L_FRAME48k, exp_temp );
+#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic
+ elliptic_bpf_48k_generic_fx(
+#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2
+ st->element_mode,
+#endif /*FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2*/
+ 0, // IsUpsampled3
+ input_fhb, &exp_temp, tmp_vec, hBWE_TD->elliptic_bpf_2_48k_mem_fx, hBWE_TD->elliptic_bpf_2_48k_mem_fx_Q, full_band_bpf_2_fx );
+#else
elliptic_bpf_48k_generic_fx( input_fhb, &exp_temp, tmp_vec, hBWE_TD->elliptic_bpf_2_48k_mem_fx, hBWE_TD->elliptic_bpf_2_48k_mem_fx_Q, full_band_bpf_2_fx );
+#endif
Sample_Delay_HP = NS2SA( 48000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ) - L_FRAME48k / 2;
IF( NE_16( st->last_extl, FB_TBE ) )
@@ -7415,14 +7437,20 @@ void fb_tbe_enc_fx(
void fb_tbe_enc_ivas_fx(
Encoder_State *st, /* i/o: encoder state structure */
- const Word16 new_input[], /* i : input speech at 48 kHz sample rate Q0 */
+ const Word16 new_input[], /* i : input speech at 48 kHz sample rate Q_new_input */
const Word16 fb_exc[], /* i : FB excitation from the SWB part Q_fb_exc */
- Word16 Q_fb_exc )
+ Word16 Q_fb_exc,
+ Word16 Q_new_input )
{
Word16 ratio;
Word16 tmp_vec[L_FRAME48k];
Word16 idxGain;
+#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic
+ Word16 input_fhb_new_buffer[L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) + 4];
+ Word16 *input_fhb_new = &input_fhb_new_buffer[0] + 4;
+#else
Word16 input_fhb_new[L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS )];
+#endif
Word16 input_fhb[L_FRAME48k];
Word16 Sample_Delay_HP;
Word64 fb_exc_energy;
@@ -7446,14 +7474,32 @@ void fb_tbe_enc_ivas_fx(
}
Copy_Scale_sig( new_input - NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_fhb_new, L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), exp_temp );
-
+ exp_temp = add( exp_temp, Q_new_input );
IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) )
{
+#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic
+ elliptic_bpf_48k_generic_fx(
+#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2
+ st->element_mode,
+#endif /*FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2*/
+ 0, // IsUpsampled3
+ input_fhb_new, &exp_temp, tmp_vec, hBWE_TD->elliptic_bpf_2_48k_mem_fx, hBWE_TD->elliptic_bpf_2_48k_mem_fx_Q, full_band_bpf_2_fx );
+#else
elliptic_bpf_48k_generic_fx( input_fhb_new, &exp_temp, tmp_vec, hBWE_TD->elliptic_bpf_2_48k_mem_fx, hBWE_TD->elliptic_bpf_2_48k_mem_fx_Q, full_band_bpf_2_fx );
+#endif
}
ELSE
{
+#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic
+ elliptic_bpf_48k_generic_fx(
+#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2
+ st->element_mode,
+#endif /*FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2*/
+ 0, // IsUpsampled3
+ input_fhb_new + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), &exp_temp, tmp_vec, hBWE_TD->elliptic_bpf_2_48k_mem_fx, hBWE_TD->elliptic_bpf_2_48k_mem_fx_Q, full_band_bpf_2_fx );
+#else
elliptic_bpf_48k_generic_fx( input_fhb_new + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), &exp_temp, tmp_vec, hBWE_TD->elliptic_bpf_2_48k_mem_fx, hBWE_TD->elliptic_bpf_2_48k_mem_fx_Q, full_band_bpf_2_fx );
+#endif
}
test();
diff --git a/lib_enc/tcx_utils_enc_fx.c b/lib_enc/tcx_utils_enc_fx.c
index 2abe538e445a952f02ea71d5d0f20dbe69988d01..680a69fa512fef1409147e308c1dd3280c5c839a 100644
--- a/lib_enc/tcx_utils_enc_fx.c
+++ b/lib_enc/tcx_utils_enc_fx.c
@@ -2786,7 +2786,7 @@ void tcx_noise_factor_ivas_fx(
/* noise level factor: average of segment magnitudes of noise bins */
IF( n > 0 )
{
- tmp4 = BASOP_Util_Divide3232_Scale_cadence( Mpy_32_16_1( sqErrorNrg, att ), n, &s );
+ tmp4 = BASOP_Util_Divide3232_Scale_newton( Mpy_32_16_1( sqErrorNrg, att ), n, &s );
s = add( add( exp_sqErrorNrg, -15 ), s );
BASOP_SATURATE_WARNING_OFF_EVS;
tmp4 = L_shl_o( tmp4, s, &Overflow );
@@ -3761,7 +3761,7 @@ Word16 tcx_res_Q_spec_ivas_fx(
return bits;
}
-#if 1 // TV
+
void ProcessIGF_fx(
IGF_ENC_INSTANCE_HANDLE const hInstance, /**< in: instance handle of IGF Encoder */
Encoder_State *st, /**< in: Encoder state */
@@ -3893,7 +3893,7 @@ void ProcessIGF_fx(
}
#endif
}
-#endif
+
void attenuateNbSpectrum_fx( Word16 L_frame, Word32 *spectrum )
{
Word16 i, length, att;
@@ -3926,8 +3926,9 @@ void ProcessIGF_ivas_fx(
Encoder_State *st, /* i : Encoder state */
Word16 powerSpec_len, /* i : length of pPowerSpectrum buffer */
Word32 *pMDCTSpectrum, /* i : MDCT spectrum (*q_spectrum) */
- const Word32 *pITFMDCTSpectrum, /* i : MDCT spectrum fir ITF */
Word16 *q_spectrum, /* i/o: Q of spectrum */
+ const Word32 *pITFMDCTSpectrum, /* i : MDCT spectrum fir ITF */
+ const Word16 q_ITFMDCTSpectrum, /* i : Q of MDCT spectrum fir ITF */
Word32 *pPowerSpectrum, /* i : MDCT^2 + MDST^2 spectrum, or estimate (*q_powerSpec) */
Word16 *exp_powerSpec, /* i/o: Q of power spectrum */
const Word16 isTCX20, /* i : flag indicating if the input is TCX20 or TCX10/2xTCX5 */
@@ -3969,7 +3970,7 @@ void ProcessIGF_ivas_fx(
}
}
- IGFSaveSpectrumForITF_ivas_fx( hIGFEnc, igfGridIdx, pITFMDCTSpectrum, sub( Q31, *q_spectrum ) );
+ IGFSaveSpectrumForITF_ivas_fx( hIGFEnc, igfGridIdx, pITFMDCTSpectrum, sub( Q31, q_ITFMDCTSpectrum ) );
IGFEncApplyMono_ivas_fx( st, powerSpec_len, igfGridIdx, pMDCTSpectrum, sub( Q31, *q_spectrum ), pPowerSpectrum, exp_powerSpec, isTCX20, st->hTcxEnc->fUseTns[frameno], sp_aud_decision0, vad_hover_flag );
@@ -4028,15 +4029,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;
@@ -4077,7 +4078,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 60d661db444fe5413372f79525dec4dfc24e032d..1ad69a3302b2c79e2879d313f98413b1a7eba2fc 100644
--- a/lib_enc/transient_detection_fx.c
+++ b/lib_enc/transient_detection_fx.c
@@ -458,7 +458,7 @@ Word32 GetTCXAvgTemporalFlatnessMeasure_ivas_fx( struct TransientDetection const
}
/* exponent = AVG_FLAT_E */
- i = BASOP_Util_Divide3232_Scale_cadence( sumTempFlatness, nTotBlocks, &exp );
+ i = BASOP_Util_Divide3232_Scale_newton( sumTempFlatness, nTotBlocks, &exp );
exp = add( exp, sub( sumTempFlatness_exp, 31 ) );
i = L_shl_sat( i, sub( exp, 10 ) ); // Can be saturated, since it is used for comparision againt 3.25/20.0f, Q21
return i;
@@ -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
}
@@ -1569,12 +1559,12 @@ static void CalculateSubblockEnergies_ivas_fx( Word16 const *input, Word16 nSamp
IF( GT_32( w0, w1 ) )
{
- pSubblockNrgChange[w] = BASOP_Util_Divide3232_Scale_cadence( w0, w1, &k );
+ pSubblockNrgChange[w] = BASOP_Util_Divide3232_Scale_newton( w0, w1, &k );
pSubblockNrgChange_exp[w] = k;
}
ELSE
{
- pSubblockNrgChange[w] = BASOP_Util_Divide3232_Scale_cadence( w1, w0, &k );
+ pSubblockNrgChange[w] = BASOP_Util_Divide3232_Scale_newton( w1, w0, &k );
pSubblockNrgChange_exp[w] = k;
}
move32();
@@ -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 6718552c50c293060c7af36aa7625249778aeb3b..d0d62769791a9dfe181c3452d45ef076c2b5167c 100644
--- a/lib_enc/transition_enc_fx.c
+++ b/lib_enc/transition_enc_fx.c
@@ -212,11 +212,11 @@ void transition_enc_fx(
IF( EQ_16( *tc_subfr, TC_0_0 ) )
{
/* this is called only to compute unused bits */
- config_acelp1( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate,
- 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 ) );
move16();
updt_tar_fx( xn_fx, xn2_fx, y1_fx, *gain_pit_fx, L_SUBFR );
@@ -324,10 +324,11 @@ void transition_enc_fx(
IF( LE_16( sub( i_subfr, *tc_subfr ), L_SUBFR ) )
{
- config_acelp1( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate,
- 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*/ );
}
+
/*-----------------------------------------------------------------*
* get number of bits for pitch encoding
*-----------------------------------------------------------------*/
@@ -915,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();
@@ -1033,11 +1032,12 @@ void transition_enc_ivas_fx(
IF( EQ_16( *tc_subfr, TC_0_0 ) )
{
/* this is called only to compute unused bits */
- config_acelp1( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate,
- 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 ) );
move16();
updt_tar_fx( xn_fx, xn2_fx, y1_fx, *gain_pit_fx, L_SUBFR );
@@ -1145,10 +1145,11 @@ void transition_enc_ivas_fx(
IF( LE_16( sub( i_subfr, *tc_subfr ), L_SUBFR ) )
{
- config_acelp1( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate,
- 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*/ );
}
+
/*-----------------------------------------------------------------*
* get number of bits for pitch encoding
*-----------------------------------------------------------------*/
@@ -1423,8 +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();
- Copy_Scale_sig( h1_fx, h1_fx_q15, L_SUBFR + ( M + 1 ), 1 );
- lp_select = lp_filt_exc_enc_ivas_fx( MODE1, TRANSITION, i_subfr, exc_fx, h1_fx_q15,
+ 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 ) )
@@ -1660,8 +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();
- Copy_Scale_sig( h1_fx, h1_fx_q15, L_SUBFR + ( M + 1 ), 1 );
- lp_select = lp_filt_exc_enc_ivas_fx( MODE1, TRANSITION, i_subfr, exc_fx, h1_fx_q15,
+ 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 ) )
{
@@ -2082,7 +2081,11 @@ static void tc_enc_ivas_fx(
/*--------------------------------------------------------------*
* compute glottal-shape codebook excitation
*--------------------------------------------------------------*/
+#ifdef TEST_HR
+ Copy( h1, h1_fx, L_SUBFR + ( M + 1 ) );
+#else
Copy_Scale_sig( h1, h1_fx, L_SUBFR + ( M + 1 ), 1 );
+#endif
/* create filtered glottal codebook contribution */
conv_fx( &exc_fx[i_subfr], h1_fx, yy1_fx, L_SUBFR );
diff --git a/lib_enc/updt_enc_fx.c b/lib_enc/updt_enc_fx.c
index fb2a6215b4509732b14ab9dcada955c97c4b8e3d..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 */
{
@@ -362,7 +331,14 @@ void updt_enc_common_fx(
move16();
st->last_bwidth = st->bwidth;
move16();
- st->hNoiseEst->Etot_last_fx = Etot;
+ IF( GT_16( st->element_mode, EVS_MONO ) )
+ {
+ st->hNoiseEst->Etot_last_32fx = L_deposit_h( Etot );
+ }
+ ELSE
+ {
+ st->hNoiseEst->Etot_last_fx = Etot;
+ }
move16();
st->last_coder_type_raw = st->coder_type_raw;
move16();
diff --git a/lib_enc/vad_fx.c b/lib_enc/vad_fx.c
index 1fdcb94fac335e5852dc782acc3a47dd2c9705c3..721a6e34875876d1a91f54b1a940fb20ea2de7d3 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*/
@@ -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 8124c4967cdeac890fdaf3c55d94f20489afe838..c2430d008f8f644170650776b450055cffa1c46b 100644
--- a/lib_rend/ivas_dirac_ana_fx.c
+++ b/lib_rend/ivas_dirac_ana_fx.c
@@ -578,7 +578,11 @@ static void ivas_dirac_dmx_fx(
v_add_fx( data_in_fx[0], data_in_fx[1], data_out_fx[0], input_frame );
v_multc_fixed( data_out_fx[0], ONE_IN_Q30, data_out_fx[0], input_frame ); // ONE_IN_Q30 = 0.5* ONE_IN_Q31
+#ifdef VEC_ARITH_OPT_v1
+ v_sub_fixed_no_hdrm( data_in_fx[0], data_in_fx[1], data_out_fx[1], input_frame );
+#else /* VEC_ARITH_OPT_v1 */
v_sub_fixed( data_in_fx[0], data_in_fx[1], data_out_fx[1], input_frame, 0 );
+#endif /* VEC_ARITH_OPT_v1 */
v_multc_fixed( data_out_fx[1], ONE_IN_Q30, data_out_fx[1], input_frame );
FOR( i = 0; i < nchan_transport; i++ )
diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c
index 79f506fd42f624466d5890372c9528b36cc63a49..ac387c5cc2f8fb48213d9af686defe0eb546930d 100644
--- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c
+++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c
@@ -852,6 +852,9 @@ static void ivas_dirac_dec_binaural_internal_fx(
( st_ivas->hSCE[0]->hCoreCoder[0]->core_brate == FRAME_NO_DATA || st_ivas->hSCE[0]->hCoreCoder[0]->core_brate == SID_2k40 ) && ( st_ivas->hSCE[0]->hCoreCoder[0]->cng_type == FD_CNG ) && st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag,
0, &q_cldfb[1][slot] );
+ scale_sig32( Cldfb_RealBuffer_in_fx[1][slot], CLDFB_NO_CHANNELS_MAX, negate( add( sub( q_cldfb[1][slot], q_input ), 5 ) ) );
+ scale_sig32( Cldfb_ImagBuffer_in_fx[1][slot], CLDFB_NO_CHANNELS_MAX, negate( add( sub( q_cldfb[1][slot], q_input ), 5 ) ) );
+
/* LB: Copy first channel + LB-CNG to first and second channels with same scaling (dual-mono)*/
FOR( b = 0; b < numCoreBands; b++ )
{
@@ -2274,12 +2277,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 ) )
{
@@ -2667,7 +2672,7 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric
move32();
/* Formulate average diffuseness over frame */
- frameMeanDiffuseness = BASOP_Util_Divide3232_Scale_cadence( frameMeanDiffuseness, L_max( EPSILLON_FX, frameMeanDiffusenessEneWeight_fx[bin] ), &exp ); // exp = exp + 31 - q_meanEnePerCh - exp1
+ frameMeanDiffuseness = BASOP_Util_Divide3232_Scale_newton( frameMeanDiffuseness, L_max( EPSILLON_FX, frameMeanDiffusenessEneWeight_fx[bin] ), &exp ); // exp = exp + 31 - q_meanEnePerCh - exp1
exp = sub( exp, sub( sub( 31, q_meanEnePerCh ), exp1 ) );
hDiracDecBin->frameMeanDiffuseness_fx[bin] = L_shl( frameMeanDiffuseness, sub( exp, 2 ) ); // Q29
move32();
@@ -2699,7 +2704,7 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric
move16();
den = BASOP_Util_Add_Mant32Exp( hDiracDecBin->ChEnePrev_fx[0][bin], hDiracDecBin->ChEnePrev_e[0][bin], hDiracDecBin->ChEnePrev_fx[1][bin], hDiracDecBin->ChEnePrev_e[1][bin], &den_e );
den = L_max( 1, den );
- IIReneLimiter_fx = BASOP_Util_Divide3232_Scale_cadence( num, den, &exp );
+ IIReneLimiter_fx = BASOP_Util_Divide3232_Scale_newton( num, den, &exp );
exp = add( sub( num_e, den_e ), add( 5, exp ) );
IF( L_shr_sat( IIReneLimiter_fx, sub( 31, exp ) ) > 0 )
{
@@ -3106,6 +3111,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 ) ) );
@@ -4416,17 +4436,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_cadence( ONE_IN_Q30, tmp3, &exp );
+ 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 ) )
{
@@ -4492,17 +4505,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_cadence( ONE_IN_Q30, tmp3, &exp );
+ 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 ) )
{
@@ -4687,24 +4693,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++ )
{
- 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] );
+ 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] = 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 ) ) )
{
@@ -4838,11 +4873,11 @@ static void chol2x2_fx(
// 4611686 = 1e-12 in Q62
IF( outRe[0][0] == 0 )
{
- outRe[1][0] = BASOP_Util_Divide3232_Scale_cadence( c_re, 4611686, &exp );
+ outRe[1][0] = BASOP_Util_Divide3232_Scale_newton( c_re, 4611686, &exp );
move32();
q_re2 = add( sub( 31, exp ), sub( q_c, 62 ) );
- outIm[1][0] = BASOP_Util_Divide3232_Scale_cadence( c_im, 4611686, &exp );
+ outIm[1][0] = BASOP_Util_Divide3232_Scale_newton( c_im, 4611686, &exp );
move32();
q_im = add( sub( 31, exp ), sub( q_c, 62 ) );
}
@@ -4899,7 +4934,7 @@ static void chol2x2_fx(
}
ELSE
{
- temp = BASOP_Util_Divide3232_Scale_cadence( temp, e1, &exp );
+ temp = BASOP_Util_Divide3232_Scale_newton( temp, e1, &exp );
q_tmp = add( sub( 31, exp ), sub( q_tmp, q_e ) );
}
if ( temp == 0 )
@@ -4944,7 +4979,7 @@ static void chol2x2_fx(
// 4611686 = Q62
IF( outRe[1][1] == 0 )
{
- // outRe[0][1] = BASOP_Util_Divide3232_Scale_cadence( c_re, 4611686, &exp );
+ // outRe[0][1] = BASOP_Util_Divide3232_Scale_newton( c_re, 4611686, &exp );
Word32 tmp1 = 1953125005; /* 1/4611686 Q62 */
exp = 9;
@@ -4952,7 +4987,7 @@ static void chol2x2_fx(
move32();
q_re2 = add( sub( 31, exp ), sub( q_c, 62 ) );
- // outIm[0][1] = BASOP_Util_Divide3232_Scale_cadence( -c_im, 4611686, &exp );
+ // outIm[0][1] = BASOP_Util_Divide3232_Scale_newton( -c_im, 4611686, &exp );
outIm[0][1] = Mpy_32_32( tmp1, -c_im );
move32();
q_im = add( sub( 31, exp ), sub( q_c, 62 ) );
@@ -4960,13 +4995,13 @@ static void chol2x2_fx(
ELSE
{
{
- // outRe[0][1] = BASOP_Util_Divide3232_Scale_cadence( c_re, outRe[1][1], &exp );
- Word32 tmp1 = BASOP_Util_Divide3232_Scale_cadence( 0x7FFFFFFF, outRe[1][1], &exp );
+ // outRe[0][1] = BASOP_Util_Divide3232_Scale_newton( c_re, outRe[1][1], &exp );
+ Word32 tmp1 = BASOP_Util_Divide3232_Scale_newton( 0x7FFFFFFF, outRe[1][1], &exp );
outRe[0][1] = Mpy_32_32( tmp1, c_re );
move32();
q_re2 = add( sub( 31, exp ), sub( q_c, q_re1 ) );
- // outIm[0][1] = BASOP_Util_Divide3232_Scale_cadence( -c_im, outRe[1][1], &exp );
+ // outIm[0][1] = BASOP_Util_Divide3232_Scale_newton( -c_im, outRe[1][1], &exp );
outIm[0][1] = Mpy_32_32( tmp1, -c_im );
move32();
q_im = add( sub( 31, exp ), sub( q_c, q_re1 ) );
@@ -4989,12 +5024,12 @@ static void chol2x2_fx(
// 4611686 = 1e-12 in Q62
IF( e2 == 0 )
{
- temp = BASOP_Util_Divide3232_Scale_cadence( temp, 4611686, &exp );
+ temp = BASOP_Util_Divide3232_Scale_newton( temp, 4611686, &exp );
q_tmp = add( sub( 31, exp ), sub( q_tmp, 62 ) );
}
ELSE
{
- temp = BASOP_Util_Divide3232_Scale_cadence( temp, e2, &exp );
+ temp = BASOP_Util_Divide3232_Scale_newton( temp, e2, &exp );
q_tmp = add( sub( 31, exp ), sub( q_tmp, q_e ) );
}
if ( temp == 0 )
@@ -5142,7 +5177,7 @@ static void formulate2x2MixingMatrix_fx(
}
ELSE
{
- maxEneDiv_fx = BASOP_Util_Divide3232_Scale_cadence( ONE_IN_Q30, maxEne_fx, &exp );
+ maxEneDiv_fx = BASOP_Util_Divide3232_Scale_newton( ONE_IN_Q30, maxEne_fx, &exp );
q_maxEneDiv = add( sub( 31, exp ), sub( Q30, q_maxEne ) );
}
exp = norm_l( maxEneDiv_fx );
@@ -5207,7 +5242,7 @@ static void formulate2x2MixingMatrix_fx(
}
ELSE
{
- temp = BASOP_Util_Divide3232_Scale_cadence( E_out1, 4611686, &exp ); // 4611686 = Q62
+ temp = BASOP_Util_Divide3232_Scale_newton( E_out1, 4611686, &exp ); // 4611686 = Q62
exp = sub( exp, sub( q_eout, 62 ) );
Ghat_fx[0] = Sqrt32( temp, &exp ); // Q = 31 - exp
}
@@ -5216,7 +5251,7 @@ static void formulate2x2MixingMatrix_fx(
{
temp = BASOP_Util_Add_Mant32Exp( temp, sub( 31, q_ein ), EPSILON_MANT, EPSILON_EXP, &exp_temp );
- temp = BASOP_Util_Divide3232_Scale_cadence( E_out1, temp, &exp );
+ temp = BASOP_Util_Divide3232_Scale_newton( E_out1, temp, &exp );
exp = sub( exp, sub( q_eout, sub( 31, exp_temp ) ) );
Ghat_fx[0] = Sqrt32( temp, &exp ); // Q = 31 - exp
}
@@ -5234,7 +5269,7 @@ static void formulate2x2MixingMatrix_fx(
}
ELSE
{
- temp = BASOP_Util_Divide3232_Scale_cadence( E_out2, 4611686, &exp1 ); // 4611686 = Q62
+ temp = BASOP_Util_Divide3232_Scale_newton( E_out2, 4611686, &exp1 ); // 4611686 = Q62
exp1 = sub( exp1, sub( q_eout, 62 ) );
Ghat_fx[1] = Sqrt32( temp, &exp1 ); // Q = 31 - exp1
}
@@ -5243,7 +5278,7 @@ static void formulate2x2MixingMatrix_fx(
{
temp = BASOP_Util_Add_Mant32Exp( temp, sub( 31, q_ein ), EPSILON_MANT, EPSILON_EXP, &exp_temp );
- temp = BASOP_Util_Divide3232_Scale_cadence( E_out2, temp, &exp1 );
+ temp = BASOP_Util_Divide3232_Scale_newton( E_out2, temp, &exp1 );
exp1 = sub( exp1, sub( q_eout, sub( 31, exp_temp ) ) );
Ghat_fx[1] = Sqrt32( temp, &exp1 ); // Q = 31 - exp1
}
@@ -5302,7 +5337,7 @@ static void formulate2x2MixingMatrix_fx(
}
ELSE
{
- temp = BASOP_Util_Divide3232_Scale_cadence( ONE_IN_Q30, D_fx[0], &exp );
+ temp = BASOP_Util_Divide3232_Scale_newton( ONE_IN_Q30, D_fx[0], &exp );
exp = sub( exp, sub( Q30, q_D ) );
}
div_fx[0] = Sqrt32( temp, &exp ); // Q = 31 - exp
@@ -5435,7 +5470,7 @@ static void formulate2x2MixingMatrix_fx(
Word16 Pre_shift, Pim_shift;
temp = BASOP_Util_Add_Mant32Exp( Sx_fx[chB], sub( 31, q_Sx ), EPSILON_MANT, EPSILON_EXP, &exp_temp );
- temp = BASOP_Util_Divide3232_Scale_cadence( ONE_IN_Q30, temp, &exp );
+ temp = BASOP_Util_Divide3232_Scale_newton( ONE_IN_Q30, temp, &exp );
Pre_shift = norm_l( Pre_fx[chA][chB] );
Pim_shift = norm_l( Pim_fx[chA][chB] );
Pre_fx[chA][chB] = Mpy_32_32( L_shl( Pre_fx[chA][chB], Pre_shift ), temp );
@@ -5479,7 +5514,7 @@ static void formulate2x2MixingMatrix_fx(
{
Word16 Pre_shift, Pim_shift;
temp = BASOP_Util_Add_Mant32Exp( Sx_fx[chB], sub( 31, q_Sx ), EPSILON_MANT, EPSILON_EXP, &exp_temp );
- temp = BASOP_Util_Divide3232_Scale_cadence( ONE_IN_Q30, temp, &exp );
+ temp = BASOP_Util_Divide3232_Scale_newton( ONE_IN_Q30, temp, &exp );
q_temp = add( sub( sub( q_P, exp ), sub( 31, Q30 ) ), exp_temp );
Pre_shift = norm_l( Pre_fx[0][chB] );
diff --git a/lib_rend/ivas_dirac_decorr_dec_fx.c b/lib_rend/ivas_dirac_decorr_dec_fx.c
index 1afac99c4157d81f9bba3dcdb70fd94669950391..9b2bf02d74943af89a58d3608a206131598894ed 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;
@@ -666,8 +667,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 +692,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 +1147,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 +1166,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 +1209,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 7b446a80e77b5a241d8c5d5494857461f6d1f885..622ebf89a5870bba79198fdd5f6c3aebf723be70 100644
--- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c
+++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c
@@ -1227,10 +1227,17 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx(
{
Scale_sig32( aux_buf, num_freq_bands, sub( h_dirac_output_synthesis_state->q_cy_auto_diff_smooth, temp_q ) ); /*temp_q->(h_dirac_output_synthesis_state->q_cy_auto_diff_smooth)*/
}
+#ifdef VEC_ARITH_OPT_v1
+ v_add_fixed_no_hdrm( aux_buf,
+ &h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx[ch_idx * num_freq_bands_diff],
+ &h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx[ch_idx * num_freq_bands_diff],
+ num_freq_bands_diff ); /*h_dirac_output_synthesis_state->q_cy_auto_diff_smooth*/
+#else /* VEC_ARITH_OPT_v1 */
v_add_fixed( aux_buf,
&h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx[ch_idx * num_freq_bands_diff],
&h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx[ch_idx * num_freq_bands_diff],
num_freq_bands_diff, 0 ); /*h_dirac_output_synthesis_state->q_cy_auto_diff_smooth*/
+#endif /* VEC_ARITH_OPT_v1 */
}
return;
@@ -2097,9 +2104,9 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx(
move16();
exp1 = 0;
move16();
- tmp32 = BASOP_Util_Divide3232_Scale_cadence( L_shl( p_cy_auto_dir_smooth[num_freq_bands], sub( q_com, q_cy_auto_dir_smooth_local[1] ) ),
- ( L_add( Sqrt32( h_dirac_output_synthesis_state->direct_power_factor_fx[0], &exp ), EPSILON_FX ) ), // (Q31 - exp)
- &exp1 );
+ tmp32 = BASOP_Util_Divide3232_Scale_newton( L_shl( p_cy_auto_dir_smooth[num_freq_bands], sub( q_com, q_cy_auto_dir_smooth_local[1] ) ),
+ ( L_add( Sqrt32( h_dirac_output_synthesis_state->direct_power_factor_fx[0], &exp ), EPSILON_FX ) ), // (Q31 - exp)
+ &exp1 );
target_power_y = L_shr( tmp32, 1 ); // Q31 + (q_com - (31 - exp))
q_target_power_y = add( sub( Q31, exp1 ), sub( q_com, sub( Q31, exp ) ) );
q_target_power_y = sub( q_target_power_y, 1 );
@@ -2108,9 +2115,9 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx(
move16();
exp1 = 0;
move16();
- tmp32 = BASOP_Util_Divide3232_Scale_cadence( L_shl( p_cy_auto_diff_smooth[num_freq_bands], sub( q_com, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth ) ),
- ( L_add( Sqrt32( h_dirac_output_synthesis_state->diffuse_power_factor_fx[0], &exp ), EPSILON_FX ) ), // (Q31 - exp)
- &exp1 );
+ tmp32 = BASOP_Util_Divide3232_Scale_newton( L_shl( p_cy_auto_diff_smooth[num_freq_bands], sub( q_com, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth ) ),
+ ( L_add( Sqrt32( h_dirac_output_synthesis_state->diffuse_power_factor_fx[0], &exp ), EPSILON_FX ) ), // (Q31 - exp)
+ &exp1 );
target_power_y1 = L_shr( tmp32, 1 ); // Q31 + (q_com - (31 - exp))
q_target_power_y1 = add( sub( Q31, exp1 ), sub( q_com, sub( Q31, exp ) ) );
q_target_power_y1 = sub( q_target_power_y1, 1 );
@@ -2127,9 +2134,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 */
@@ -2145,24 +2149,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
@@ -2171,6 +2203,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();
}
/*-----------------------------------------------------------------*
@@ -2268,7 +2302,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx(
IF( EQ_32( *( p_power_smooth_prev ), EPSILON_FX ) )
{
p_power_smooth_prev++;
- L_tmp = BASOP_Util_Divide3232_Scale_cadence( ONE_IN_Q31, EPSILON_FX, &exp ); /*Q=31-(exp-(31-q_proto_power_smooth))*/
+ L_tmp = BASOP_Util_Divide3232_Scale_newton( ONE_IN_Q31, EPSILON_FX, &exp ); /*Q=31-(exp-(31-q_proto_power_smooth))*/
exp_arr[k * num_freq_bands + l] = exp;
move16();
@@ -2277,7 +2311,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx(
}
ELSE
{
- L_tmp = BASOP_Util_Divide3232_Scale_cadence( ONE_IN_Q31, *( p_power_smooth_prev++ ), &exp ); /*Q=31-(exp-(31-q_proto_power_smooth))*/
+ L_tmp = BASOP_Util_Divide3232_Scale_newton( ONE_IN_Q31, *( p_power_smooth_prev++ ), &exp ); /*Q=31-(exp-(31-q_proto_power_smooth))*/
exp_arr[k * num_freq_bands + l] = exp;
move16();
@@ -2495,7 +2529,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx(
exp = 0;
move16();
- L_tmp = BASOP_Util_Divide3232_Scale_cadence( *( p_cy_auto_diff_smooth_prev++ ), ( *( p_power_diff_smooth_prev++ ) ), &exp ); // (Q31 - exp) + (q_a - q_b)
+ L_tmp = BASOP_Util_Divide3232_Scale_newton( *( p_cy_auto_diff_smooth_prev++ ), ( *( p_power_diff_smooth_prev++ ) ), &exp ); // (Q31 - exp) + (q_a - q_b)
exp = sub( Q31, add( sub( Q31, exp ), sub( h_dirac_output_synthesis_state->q_cy_auto_diff_smooth_prev, h_dirac_output_synthesis_state->proto_power_diff_smooth_q ) ) );
*( p_gains_diff ) = Sqrt32( L_tmp, &exp ); // (31 - exp)
@@ -3982,10 +4016,11 @@ void ivas_lfe_synth_with_filters_fx(
}
ELSE
{
- lfeGain_fx = extract_h( BASOP_Util_Divide3232_Scale_cadence( 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*/
+ 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 f67f3761bee66257e79a5fc22dce5e97b9af76c5..063c70f66a42525b55dc9b44fb319df3d4886d6f 100644
--- a/lib_rend/ivas_dirac_rend_fx.c
+++ b/lib_rend/ivas_dirac_rend_fx.c
@@ -986,6 +986,7 @@ ivas_error ivas_dirac_alloc_mem_fx(
}
hDirAC_mem->reference_power_len = imult1616( 5, num_freq_bands );
+ set16_fx( hDirAC_mem->reference_power_q, Q31, 2 );
}
IF( hDirACRend->proto_signal_decorr_on )
@@ -1753,7 +1754,7 @@ 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;
@@ -2119,7 +2120,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
@@ -2163,19 +2167,30 @@ 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 ) ) )
@@ -2184,8 +2199,8 @@ void protoSignalComputation2_fx(
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
+ re_aux = L_shl( Real_aux_fx, sub( temp_q_shift, min_q_shift ) ); // q_cldfb+temp_q_shift
+ im_aux = L_shl( Imag_aux_fx, sub( temp_q_shift, min_q_shift ) ); // q_cldfb+temp_q_shift
#endif
sum_power_fx = Madd_32_32( Mpy_32_32( re_aux, re_aux ), im_aux, im_aux ); // 2*(q_cldfb+temp_q_shift)-31
@@ -2215,7 +2230,7 @@ void protoSignalComputation2_fx(
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
+ 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
@@ -2691,8 +2706,8 @@ void protoSignalComputation2_fx(
q_lr_bb_power = stereo_type_detect->q_right_bb_power;
move16();
}
- q_lr_bb_power = sub( q_lr_bb_power, 1 ); /* = (lr_bb_power_fx * 2) */
- temp = BASOP_Util_Divide3232_Scale_cadence( lr_bb_power_fx, L_add( stereo_type_detect->total_bb_power_fx, EPSILON_FX ), &exp ); // Q(31-(exp+stereo_type_detect->q_total_bb_power-q_lr_bb_power))
+ q_lr_bb_power = sub( q_lr_bb_power, 1 ); /* = (lr_bb_power_fx * 2) */
+ temp = BASOP_Util_Divide3232_Scale_newton( lr_bb_power_fx, L_add( stereo_type_detect->total_bb_power_fx, EPSILON_FX ), &exp ); // Q(31-(exp+stereo_type_detect->q_total_bb_power-q_lr_bb_power))
exp = sub( 31, add( sub( 31, exp ), sub( q_lr_bb_power, stereo_type_detect->q_total_bb_power ) ) );
temp = BASOP_Util_Log2( temp ); // q25
IF( NE_32( temp, MIN_32 ) )
@@ -2703,15 +2718,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 );
@@ -2740,8 +2756,8 @@ void protoSignalComputation2_fx(
move32();
q_lr_hi_power = stereo_type_detect->q_right_hi_power;
}
- q_lr_hi_power = sub( q_lr_hi_power, 1 ); /* = (q_lr_hi_power * 2) */
- temp = BASOP_Util_Divide3232_Scale_cadence( lr_hi_power_fx, L_add( stereo_type_detect->total_hi_power_fx, EPSILON_FX ), &exp ); // Q=31-(exp+ stereo_type_detect->q_total_hi_power-q_lr_hi_power)
+ q_lr_hi_power = sub( q_lr_hi_power, 1 ); /* = (q_lr_hi_power * 2) */
+ temp = BASOP_Util_Divide3232_Scale_newton( lr_hi_power_fx, L_add( stereo_type_detect->total_hi_power_fx, EPSILON_FX ), &exp ); // Q=31-(exp+ stereo_type_detect->q_total_hi_power-q_lr_hi_power)
exp = sub( 31, add( sub( 31, exp ), sub( q_lr_hi_power, stereo_type_detect->q_total_hi_power ) ) );
temp = BASOP_Util_Log2( temp ); // q25
IF( NE_32( temp, MIN_32 ) )
@@ -3419,7 +3435,7 @@ void computeDirectionAngles_fx(
}
ELSE
{
- temp = BASOP_Util_Divide3232_Scale_cadence( ONE_IN_Q30, intensityNorm, &exp ); // Q=31-(exp-(30-q_intensityNorm))
+ temp = BASOP_Util_Divide3232_Scale_newton( ONE_IN_Q30, intensityNorm, &exp ); // Q=31-(exp-(30-q_intensityNorm))
exp = sub( exp, sub( Q30, q_intensityNorm ) );
temp = Sqrt32( temp, &exp ); // Q=31-exp
q_temp = sub( 31, exp );
@@ -4165,7 +4181,7 @@ static void ivas_masa_ext_dirac_render_sf_fx(
hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx[i] = L_add( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx[i], surCohEner_fx ); // q29
move32();
- surCohRatio_fx[i] = L_deposit_h( BASOP_Util_Divide3232_Scale( surCohEner_fx, L_add( L_add( 1, dirEne_fx ), surCohEner_fx ), &surCohRatio_exp[i] ) ); // 31-surCohRatio_exp
+ surCohRatio_fx[i] = BASOP_Util_Divide3232_Scale_newton( surCohEner_fx, L_add( L_add( 1, dirEne_fx ), surCohEner_fx ), &surCohRatio_exp[i] ); // 31-surCohRatio_exp
move32();
temp_exp = s_max( temp_exp, surCohRatio_exp[i] );
}
@@ -4527,9 +4543,13 @@ static void ivas_masa_ext_dirac_render_sf_fx(
hDirACRend->h_freq_domain_decorr_ap_params,
hDirACRend->h_freq_domain_decorr_ap_state );
- v_multc_fixed( onset_filter_fx, 536870912 /* 0.25f in Q31 */, onset_filter_fx, hSpatParamRendCom->num_freq_bands ); /* Q31 */
+ v_multc_fixed( onset_filter_fx, 536870912 /* 0.25f in Q31 */, onset_filter_fx, hSpatParamRendCom->num_freq_bands ); /* Q31 */
+#ifdef VEC_ARITH_OPT_v1
+ v_add_fixed_no_hdrm( onset_filter_fx, onset_filter_subframe_fx, onset_filter_subframe_fx, hSpatParamRendCom->num_freq_bands ); /* Q31 */
+#else /* VEC_ARITH_OPT_v1 */
v_add_fixed( onset_filter_fx, onset_filter_subframe_fx, onset_filter_subframe_fx, hSpatParamRendCom->num_freq_bands, 0 ); /* Q31 */
- p_onset_filter_fx = onset_filter_subframe_fx; /*q31*/
+#endif /* VEC_ARITH_OPT_v1 */
+ p_onset_filter_fx = onset_filter_subframe_fx; /*q31*/
}
ELSE
{
@@ -4626,7 +4646,11 @@ static void ivas_masa_ext_dirac_render_sf_fx(
DirAC_mem.reference_power_smooth_q = DirAC_mem.reference_power_q;
move16();
#endif
+#ifdef VEC_ARITH_OPT_v1
+ v_add_fixed_no_hdrm( reference_power_fix, reference_power_smooth_fx, reference_power_smooth_fx, hSpatParamRendCom->num_freq_bands ); // DirAC_mem.reference_power_smooth_q
+#else /* VEC_ARITH_OPT_v1 */
v_add_fixed( reference_power_fix, reference_power_smooth_fx, reference_power_smooth_fx, hSpatParamRendCom->num_freq_bands, 0 ); // DirAC_mem.reference_power_smooth_q
+#endif /* VEC_ARITH_OPT_v1 */
}
}
/*Rescaling proto_direct_buffer_f*/
@@ -4960,7 +4984,7 @@ static void ivas_masa_ext_dirac_render_sf_fx(
hSpatParamRendCom->num_freq_bands ) );
}
}
- scale_factor = sub( scale_factor, 3 ); // guard bits
+ scale_factor = sub( scale_factor, find_guarded_bits_fx( hSpatParamRendCom->num_freq_bands ) ); // guard bits
FOR( ch = 0; ch < hDirACRend->num_outputs_dir; ch++ )
{
@@ -4998,10 +5022,20 @@ static void ivas_masa_ext_dirac_render_sf_fx(
ELSE
{
/* open CLDFB buffer up to CLDFB_NO_CHANNELS_MAX bands for 48kHz */
+ /* cldfb_state_fx should be in 1 less q-factor compared to cld buffers for cldfbSynthesis_ivas_fx function */
Word16 q_out = sub( q_cldfb, 1 );
- scale_sig32( hMasaExtRend->cldfbSynRend[idx_in]->cldfb_state_fx, hMasaExtRend->cldfbSynRend[idx_in]->cldfb_state_length, sub( q_out, hMasaExtRend->cldfbSynRend[idx_in]->Q_cldfb_state ) ); // q_out
- hMasaExtRend->cldfbSynRend[idx_in]->Q_cldfb_state = q_out;
- move16();
+ Word16 max_shift = L_norm_arr( hMasaExtRend->cldfbSynRend[idx_in]->cldfb_state_fx, hMasaExtRend->cldfbSynRend[idx_in]->cldfb_state_length );
+ IF( GT_16( max_shift, sub( q_out, hMasaExtRend->cldfbSynRend[idx_in]->Q_cldfb_state ) ) )
+ {
+ scale_sig32( hMasaExtRend->cldfbSynRend[idx_in]->cldfb_state_fx, hMasaExtRend->cldfbSynRend[idx_in]->cldfb_state_length, sub( q_out, hMasaExtRend->cldfbSynRend[idx_in]->Q_cldfb_state ) ); // q_out
+ hMasaExtRend->cldfbSynRend[idx_in]->Q_cldfb_state = q_out;
+ move16();
+ }
+ 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++ )
{
RealBuffer_fx[i] = Cldfb_RealBuffer_fx[idx_in][i]; // q_cldfb
diff --git a/lib_rend/ivas_efap_fx.c b/lib_rend/ivas_efap_fx.c
index 543decbddee50bf407465f629883234eb976979b..4fb88643bb143d6c704e885a0fcd4e0c3f0b4702 100644
--- a/lib_rend/ivas_efap_fx.c
+++ b/lib_rend/ivas_efap_fx.c
@@ -1525,7 +1525,11 @@ static void get_poly_gains_fx(
A[1] = elePoly[i - 1]; // q22
move32();
+#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*/
+#endif /* VEC_ARITH_OPT_v1 */
FOR( j = i; j < numChan - 2 + i; ++j )
{
@@ -1578,7 +1582,11 @@ static Word32 get_tri_gain_fx(
tmpN[1] = L_sub( C[0], B[0] ); // q22
move32();
- v_sub_fixed( B, A, tmpSub1, 2, 0 ); // tmpSub1 q22
+#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
+#endif /* VEC_ARITH_OPT_v1 */
tmpDot1 = dotp_fixed( tmpN, tmpSub1, 2 ); // Q13
@@ -2237,7 +2245,11 @@ static void sort_channels_vertex_fx(
move32();
}
+#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
+#endif /* VEC_ARITH_OPT_v1 */
Word16 exp2 = 2;
move16();
normV = ISqrt32( dotp_fixed( tmpV3, tmpV3, 3 ) /*q29*/, &exp2 ); // q=31-exp2
@@ -2419,7 +2431,11 @@ static Word16 in_poly_fx( /* Angles are in Q22 */
A[1] = poly.polyEle[0]; // q22
move32();
- v_sub_fixed( P, A, P_minus_A, 2, 0 ); /* Precalculate value of (P-A) 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*/
+#endif /* VEC_ARITH_OPT_v1 */
FOR( n = 1; n < sub( numVertices, 1 ); ++n )
{
@@ -2487,8 +2503,13 @@ static Word16 in_tri_fx(
I'll just compute the determinant and if it's equal to 0, that means the two vectors are colinear
*/
- v_sub_fixed( B, A, tmpDot1, 2, 0 ); // tmpDot1 q22
- v_sub_fixed( C, A, tmpDot2, 2, 0 ); // tmpDot2 q22
+#ifdef VEC_ARITH_OPT_v1
+ 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
+#endif /* VEC_ARITH_OPT_v1 */
/* Verification of the non-colinearity : Q22 * Q22 = Q13 */
invFactor = L_sub( Mpy_32_32( tmpDot1[0], tmpDot2[1] ), Mpy_32_32( tmpDot1[1], tmpDot2[0] ) ); /*q22+q22-q31->q13*/
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 ba632c6ba13d6c9cb6cfda1d137ad77445dcd078..7b7f64c842dd0f57b94045da2fcdc29a554dd933 100644
--- a/lib_rend/ivas_omasa_ana_fx.c
+++ b/lib_rend/ivas_omasa_ana_fx.c
@@ -538,8 +538,13 @@ static void ivas_omasa_param_est_ana_fx(
FOR( i = 1; i < nchan_ism; i++ )
{
+#ifdef VEC_ARITH_OPT_v1
+ v_add_fixed_no_hdrm( Chnl_RealBuffer_fx[i], Foa_RealBuffer_fx[0], Foa_RealBuffer_fx[0], num_freq_bins ); // Q: Chnl_RealBuffer_q
+ v_add_fixed_no_hdrm( Chnl_ImagBuffer_fx[i], Foa_ImagBuffer_fx[0], Foa_ImagBuffer_fx[0], num_freq_bins ); // Q: Chnl_ImagBuffer_q
+#else /* VEC_ARITH_OPT_v1 */
v_add_fixed( Chnl_RealBuffer_fx[i], Foa_RealBuffer_fx[0], Foa_RealBuffer_fx[0], num_freq_bins, 0 ); // Q: Chnl_RealBuffer_q
v_add_fixed( Chnl_ImagBuffer_fx[i], Foa_ImagBuffer_fx[0], Foa_ImagBuffer_fx[0], num_freq_bins, 0 ); // Q: Chnl_ImagBuffer_q
+#endif /* VEC_ARITH_OPT_v1 */
}
/* Y */
diff --git a/lib_rend/ivas_orient_trk_fx.c b/lib_rend/ivas_orient_trk_fx.c
index 16d2fcc73e18b18f402269116f276e184e1af7d2..5ea170a783751ecdc78eec6b0defab050e79b056 100644
--- a/lib_rend/ivas_orient_trk_fx.c
+++ b/lib_rend/ivas_orient_trk_fx.c
@@ -141,22 +141,22 @@ static void QuaternionDivision_fx(
{
Word16 scale_e, result_e = 0, w_q, x_q, y_q, z_q, result_q;
- r->w_fx = BASOP_Util_Divide3232_Scale_cadence( ( q.w_fx ), d, &scale_e );
+ r->w_fx = BASOP_Util_Divide3232_Scale_newton( ( q.w_fx ), d, &scale_e );
move32();
result_e = add( scale_e, sub( sub( Q31, q.q_fact ), den_e ) ); // e+e1-e2//
w_q = sub( Q31, result_e );
- r->x_fx = BASOP_Util_Divide3232_Scale_cadence( ( q.x_fx ), d, &scale_e );
+ r->x_fx = BASOP_Util_Divide3232_Scale_newton( ( q.x_fx ), d, &scale_e );
move32();
result_e = add( scale_e, sub( sub( Q31, q.q_fact ), den_e ) );
x_q = sub( Q31, result_e );
- r->y_fx = BASOP_Util_Divide3232_Scale_cadence( ( q.y_fx ), d, &scale_e );
+ r->y_fx = BASOP_Util_Divide3232_Scale_newton( ( q.y_fx ), d, &scale_e );
move32();
result_e = add( scale_e, sub( sub( Q31, q.q_fact ), den_e ) );
y_q = sub( Q31, result_e );
- r->z_fx = BASOP_Util_Divide3232_Scale_cadence( ( q.z_fx ), d, &scale_e );
+ r->z_fx = BASOP_Util_Divide3232_Scale_newton( ( q.z_fx ), d, &scale_e );
move32();
result_e = add( scale_e, sub( sub( Q31, q.q_fact ), den_e ) );
z_q = sub( Q31, result_e );
@@ -506,15 +506,15 @@ static IVAS_VECTOR3 VectorNormalize_fx(
move16();
length_fx = VectorLength_fx( p, &q_len );
- result_fx.x_fx = BASOP_Util_Divide3232_Scale_cadence( p.x_fx, length_fx, &scale );
+ result_fx.x_fx = BASOP_Util_Divide3232_Scale_newton( p.x_fx, length_fx, &scale );
move32();
x_qfact = sub( Q31, add( scale, sub( q_len, p.q_fact ) ) ); // e+(e1-e2)//
- result_fx.y_fx = BASOP_Util_Divide3232_Scale_cadence( p.y_fx, length_fx, &scale );
+ result_fx.y_fx = BASOP_Util_Divide3232_Scale_newton( p.y_fx, length_fx, &scale );
move32();
y_qfact = sub( Q31, add( scale, sub( q_len, p.q_fact ) ) );
- result_fx.z_fx = BASOP_Util_Divide3232_Scale_cadence( p.z_fx, length_fx, &scale );
+ result_fx.z_fx = BASOP_Util_Divide3232_Scale_newton( p.z_fx, length_fx, &scale );
move32();
z_qfact = sub( Q31, add( scale, sub( q_len, p.q_fact ) ) );
diff --git a/lib_rend/ivas_output_init.c b/lib_rend/ivas_output_init.c
deleted file mode 100644
index 816193253012641d4ba2eb6cf9b0e8eac96e3448..0000000000000000000000000000000000000000
--- a/lib_rend/ivas_output_init.c
+++ /dev/null
@@ -1,512 +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:
-#ifdef SPLIT_REND_WITH_HEAD_ROT
- case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED:
- case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM:
-#endif
- 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:
-#ifdef SPLIT_REND_WITH_HEAD_ROT
- case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED:
- case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM:
-#endif
- 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 )
-#ifdef SPLIT_REND_WITH_HEAD_ROT
- || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ||
- EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
-#endif
- )
- {
- nchan_out_buff = shl( CPE_CHANNELS, 1 );
- }
- else if ( 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 ) )
- {
- nchan_out_buff = s_max( nchan_out_buff, add( shl( BINAURAL_CHANNELS, 1 ), 2 ) );
- }
- 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 ) );
- }
- }
-
-#ifdef SPLIT_REND_WITH_HEAD_ROT
- IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
- {
- nchan_out_buff = max( nchan_out_buff, st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses * BINAURAL_CHANNELS );
- }
-#endif
-
- 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..7bcf6e37dc2987b9edc600935d18e46dc76643a0 100644
--- a/lib_rend/ivas_output_init_fx.c
+++ b/lib_rend/ivas_output_init_fx.c
@@ -1,7 +1,478 @@
+/******************************************************************************************************
-#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:
+#ifdef SPLIT_REND_WITH_HEAD_ROT
+ case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED:
+ case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM:
+#endif
+ 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:
+#ifdef SPLIT_REND_WITH_HEAD_ROT
+ case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED:
+ case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM:
+#endif
+ 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 )
+#ifdef SPLIT_REND_WITH_HEAD_ROT
+ || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ||
+ EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
+#endif
+ )
+ {
+ 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 ) );
+ }
+ }
+
+#ifdef SPLIT_REND_WITH_HEAD_ROT
+ IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
+ {
+ nchan_out_buff = max( nchan_out_buff, st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses * BINAURAL_CHANNELS );
+ }
+#endif
+
+ return nchan_out_buff;
+}
Word16 ivas_get_nchan_buffers_dec_ivas_fx(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
@@ -159,6 +630,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 4e23011b47814863f848ef9019b4b447c455a005..7ab5288cc7caa2522c4db197e51f80601d7b4f98 100644
--- a/lib_rend/ivas_prot_rend_fx.h
+++ b/lib_rend/ivas_prot_rend_fx.h
@@ -763,7 +763,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);
@@ -850,8 +850,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 */
);
diff --git a/lib_rend/ivas_reverb_filter_design_fx.c b/lib_rend/ivas_reverb_filter_design_fx.c
index 62c97f88f4b4c78c399967ee85854c694ac44929..c70e8d6675810ace15423786df165f98e72313d4 100644
--- a/lib_rend/ivas_reverb_filter_design_fx.c
+++ b/lib_rend/ivas_reverb_filter_design_fx.c
@@ -411,7 +411,7 @@ static void response_step_limit_fx(
IF( X[i] )
{
- desiredChange = BASOP_Util_Divide3232_Scale_cadence( X[i], X[i - 1], &div_e );
+ desiredChange = BASOP_Util_Divide3232_Scale_newton( X[i], X[i - 1], &div_e );
desiredChange_q = sub( 31, ( div_e ) );
}
@@ -459,7 +459,7 @@ static void response_step_limit_fx(
IF( X[i] )
{
- desiredChange = BASOP_Util_Divide3232_Scale_cadence( X[i], X[i + 1], &div_e );
+ desiredChange = BASOP_Util_Divide3232_Scale_newton( X[i], X[i + 1], &div_e );
desiredChange_q = sub( 31, ( div_e ) );
}
IF( GT_16( desiredChange_q, 30 ) )
@@ -742,9 +742,9 @@ void ivas_reverb_calc_color_levels_fx(
move16();
cos_w = getCosWord16R2( (Word16) L_abs( L_shl( Mpy_32_32( pFc[freq_idx], fs_inverted ), 3 ) ) ); // q = 15
H_filter = L_add( L_shr( L_add( L_shr( Mpy_32_32( coefB[0], coefB[0] ), 1 ), L_shr( Mpy_32_32( coefB[1], coefB[1] ), 1 ) ), 2 ), L_shr( Mpy_32_32( coefB[0], Mpy_32_32( coefB[1], L_shl( cos_w, 15 ) ) ), 1 ) ); // q = 28
- H_filter = BASOP_Util_Divide3232_Scale_cadence( H_filter, L_add( ONE_IN_Q28, L_shr( L_add( L_shr( Mpy_32_32( coefA[1], coefA[1] ), 2 ), Mpy_32_32( coefA[1], L_shl( cos_w, 15 ) ) ), 1 ) ), &temp );
+ H_filter = BASOP_Util_Divide3232_Scale_newton( H_filter, L_add( ONE_IN_Q28, L_shr( L_add( L_shr( Mpy_32_32( coefA[1], coefA[1] ), 2 ), Mpy_32_32( coefA[1], L_shl( cos_w, 15 ) ) ), 1 ) ), &temp );
H_filter = Sqrt32( H_filter, &temp );
- T60_est = BASOP_Util_Divide3232_Scale_cadence( L_shl( i_mult( -3, pLoop_delays[loop_idx] ), 2 ), Mpy_32_32( Mpy_32_32( L_add( BASOP_Util_Log2( H_filter ), L_shl( temp, 25 ) ), LOG10_2_Q31 ), L_shl( output_Fs, 8 ) ), &temp ); // conversion of log2 to log10.
+ T60_est = BASOP_Util_Divide3232_Scale_newton( L_shl( i_mult( -3, pLoop_delays[loop_idx] ), 2 ), Mpy_32_32( Mpy_32_32( L_add( BASOP_Util_Log2( H_filter ), L_shl( temp, 25 ) ), LOG10_2_Q31 ), L_shl( output_Fs, 8 ) ), &temp ); // conversion of log2 to log10.
t60[freq_idx] = BASOP_Util_Add_Mant32Exp( T60_est, temp, t60[freq_idx], t60_e[freq_idx], &result_e );
move16();
t60_e[freq_idx] = result_e;
@@ -775,14 +775,14 @@ void ivas_reverb_calc_color_levels_fx(
{
Word16 temp, temp1, temp2, temp3 = 0, temp4, temp5;
move16();
- Word32 var1 = BASOP_Util_Divide3232_Scale_cadence( (Word32) i_mult( -6, minDelay ), L_shr( Mpy_32_32( t60[freq_idx], L_shl( output_Fs, 11 ) ), sub( 11, t60_e[freq_idx] ) ), &temp );
+ Word32 var1 = BASOP_Util_Divide3232_Scale_newton( (Word32) i_mult( -6, minDelay ), L_shr( Mpy_32_32( t60[freq_idx], L_shl( output_Fs, 11 ) ), sub( 11, t60_e[freq_idx] ) ), &temp );
var1 = Mpy_32_32( var1, LOG2_10_Q29 ); // e = temp + (31 - 29)
Word32 A0_square_est = BASOP_util_Pow2( var1, add( temp, 31 - 29 ), &temp );
Word16 alpha_e;
- Word32 alpha = BASOP_Util_Divide3232_Scale_cadence( -log__0_001, t60[freq_idx], &alpha_e ); // alpha_e = 1 + alpha_e + (3 - t60_e[257])
+ Word32 alpha = BASOP_Util_Divide3232_Scale_newton( -log__0_001, t60[freq_idx], &alpha_e ); // alpha_e = 1 + alpha_e + (3 - t60_e[257])
- Word32 div11 = BASOP_Util_Divide3232_Scale_cadence( A0_square_est, alpha, &temp1 ); // e = temp1 + (temp - alpha_e)
- Word32 div2 = BASOP_Util_Divide3232_Scale_cadence( L_shl( output_Fs, 11 ), L_shr( L_add( Mpy_32_16_1( 1884631649, shl( minDelayDiff, 3 ) ), 14037339 ), 8 ), &temp2 ); // e = temp2, 26.7741 in Q19, 0.8776 in Q31
+ Word32 div11 = BASOP_Util_Divide3232_Scale_newton( A0_square_est, alpha, &temp1 ); // e = temp1 + (temp - alpha_e)
+ Word32 div2 = BASOP_Util_Divide3232_Scale_newton( L_shl( output_Fs, 11 ), L_shr( L_add( Mpy_32_16_1( 1884631649, shl( minDelayDiff, 3 ) ), 14037339 ), 8 ), &temp2 ); // e = temp2, 26.7741 in Q19, 0.8776 in Q31
const Word32 revPredNormEnergy = Mpy_32_32( div2, div11 ); // q = (15 - temp2) + (15 - temp1) - 15 + 1
// L_max
@@ -794,7 +794,7 @@ void ivas_reverb_calc_color_levels_fx(
L_tmp = W_extract_h( W_shl( W_tmp1, W_shift ) );
temp4 = sub( 3, W_shift );
div2 = Sqrt32( L_tmp, &temp4 );
- pTarget_color_L[freq_idx] = BASOP_Util_Divide3232_Scale_cadence( div2, div1, &temp5 );
+ pTarget_color_L[freq_idx] = BASOP_Util_Divide3232_Scale_newton( div2, div1, &temp5 );
move32();
temp5 = add( temp5, sub( temp4, temp3 ) );
pTarget_color_L_e[freq_idx] = temp5;
@@ -807,7 +807,7 @@ void ivas_reverb_calc_color_levels_fx(
L_tmp = W_extract_h( W_shl( W_tmp2, W_shift ) );
temp4 = sub( 3, W_shift );
div2 = Sqrt32( L_tmp, &temp4 );
- pTarget_color_R[freq_idx] = BASOP_Util_Divide3232_Scale_cadence( div2, div1, &temp5 );
+ pTarget_color_R[freq_idx] = BASOP_Util_Divide3232_Scale_newton( div2, div1, &temp5 );
move32();
temp5 = add( temp5, sub( temp4, temp3 ) );
pTarget_color_R_e[freq_idx] = temp5;
@@ -825,7 +825,7 @@ void ivas_reverb_calc_color_levels_fx(
Word32 div1;
Word16 temp = 0;
move16();
- div1 = BASOP_Util_Divide3232_Scale_cadence( L_mult0( 1000, sub( freq_count, 1 ) ), L_shr( output_Fs, 1 ), &temp );
+ div1 = BASOP_Util_Divide3232_Scale_newton( L_mult0( 1000, sub( freq_count, 1 ) ), L_shr( output_Fs, 1 ), &temp );
div1 = BASOP_Util_Add_Mant32Exp( div1, temp, ONE_IN_Q30, 1, &temp );
idx_pivot = extract_l( L_shr( div1, sub( 31, temp ) ) );
/* Perform step limiting */
diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c
index 9b149940c08947d8a2548fe6ba486729f34fd7fa..12b94b1a2e306c2b1966dcb7a0d1190c4d5d7909 100644
--- a/lib_rend/ivas_reverb_fx.c
+++ b/lib_rend/ivas_reverb_fx.c
@@ -2177,13 +2177,23 @@ void ivas_binaural_reverb_processSubframe_fx(
{
IF( s_and( ch, 1 ) )
{
+#ifdef VEC_ARITH_OPT_v1
+ v_add_fixed_no_hdrm( hReverb->preDelayBufferReal_fx[idx], inReal[ch][sample], hReverb->preDelayBufferReal_fx[idx], hReverb->numBins );
+ v_add_fixed_no_hdrm( hReverb->preDelayBufferImag_fx[idx], inImag[ch][sample], hReverb->preDelayBufferImag_fx[idx], hReverb->numBins );
+#else /* VEC_ARITH_OPT_v1 */
v_add_fixed( hReverb->preDelayBufferReal_fx[idx], inReal[ch][sample], hReverb->preDelayBufferReal_fx[idx], hReverb->numBins, 0 );
v_add_fixed( hReverb->preDelayBufferImag_fx[idx], inImag[ch][sample], hReverb->preDelayBufferImag_fx[idx], hReverb->numBins, 0 );
+#endif /* VEC_ARITH_OPT_v1 */
}
ELSE
{
+#ifdef VEC_ARITH_OPT_v1
+ v_sub_fixed_no_hdrm( hReverb->preDelayBufferReal_fx[idx], inImag[ch][sample], hReverb->preDelayBufferReal_fx[idx], hReverb->numBins );
+ v_add_fixed_no_hdrm( hReverb->preDelayBufferImag_fx[idx], inReal[ch][sample], hReverb->preDelayBufferImag_fx[idx], hReverb->numBins );
+#else /* VEC_ARITH_OPT_v1 */
v_sub_fixed( hReverb->preDelayBufferReal_fx[idx], inImag[ch][sample], hReverb->preDelayBufferReal_fx[idx], hReverb->numBins, 0 );
v_add_fixed( hReverb->preDelayBufferImag_fx[idx], inReal[ch][sample], hReverb->preDelayBufferImag_fx[idx], hReverb->numBins, 0 );
+#endif /* VEC_ARITH_OPT_v1 */
}
}
idx = add( idx, 1 ) % hReverb->preDelayBufferLength;
@@ -2213,20 +2223,40 @@ void ivas_binaural_reverb_processSubframe_fx(
SWITCH( phaseShiftTypePr[tapIdx] )
{
case 0: /* 0 degrees phase */
+#ifdef VEC_ARITH_OPT_v1
+ v_add_fixed_no_hdrm( hReverb->outputBufferReal_fx[bin][ch], tapRealPr_fx[tapIdx], hReverb->outputBufferReal_fx[bin][ch], numSlots );
+ v_add_fixed_no_hdrm( hReverb->outputBufferImag_fx[bin][ch], tapImagPr_fx[tapIdx], hReverb->outputBufferImag_fx[bin][ch], numSlots );
+#else /* VEC_ARITH_OPT_v1 */
v_add_fixed( hReverb->outputBufferReal_fx[bin][ch], tapRealPr_fx[tapIdx], hReverb->outputBufferReal_fx[bin][ch], numSlots, 0 );
v_add_fixed( hReverb->outputBufferImag_fx[bin][ch], tapImagPr_fx[tapIdx], hReverb->outputBufferImag_fx[bin][ch], numSlots, 0 );
+#endif /* VEC_ARITH_OPT_v1 */
BREAK;
case 1: /* 90 degrees phase */
+#ifdef VEC_ARITH_OPT_v1
+ v_sub_fixed_no_hdrm( hReverb->outputBufferReal_fx[bin][ch], tapImagPr_fx[tapIdx], hReverb->outputBufferReal_fx[bin][ch], numSlots );
+ v_add_fixed_no_hdrm( hReverb->outputBufferImag_fx[bin][ch], tapRealPr_fx[tapIdx], hReverb->outputBufferImag_fx[bin][ch], numSlots );
+#else /* VEC_ARITH_OPT_v1 */
v_sub_fixed( hReverb->outputBufferReal_fx[bin][ch], tapImagPr_fx[tapIdx], hReverb->outputBufferReal_fx[bin][ch], numSlots, 0 );
v_add_fixed( hReverb->outputBufferImag_fx[bin][ch], tapRealPr_fx[tapIdx], hReverb->outputBufferImag_fx[bin][ch], numSlots, 0 );
+#endif /* VEC_ARITH_OPT_v1 */
BREAK;
case 2: /* 180 degrees phase */
+#ifdef VEC_ARITH_OPT_v1
+ v_sub_fixed_no_hdrm( hReverb->outputBufferReal_fx[bin][ch], tapRealPr_fx[tapIdx], hReverb->outputBufferReal_fx[bin][ch], numSlots );
+ v_sub_fixed_no_hdrm( hReverb->outputBufferImag_fx[bin][ch], tapImagPr_fx[tapIdx], hReverb->outputBufferImag_fx[bin][ch], numSlots );
+#else /* VEC_ARITH_OPT_v1 */
v_sub_fixed( hReverb->outputBufferReal_fx[bin][ch], tapRealPr_fx[tapIdx], hReverb->outputBufferReal_fx[bin][ch], numSlots, 0 );
v_sub_fixed( hReverb->outputBufferImag_fx[bin][ch], tapImagPr_fx[tapIdx], hReverb->outputBufferImag_fx[bin][ch], numSlots, 0 );
+#endif /* VEC_ARITH_OPT_v1 */
BREAK;
default: /* 270 degrees phase */
+#ifdef VEC_ARITH_OPT_v1
+ v_add_fixed_no_hdrm( hReverb->outputBufferReal_fx[bin][ch], tapImagPr_fx[tapIdx], hReverb->outputBufferReal_fx[bin][ch], numSlots );
+ v_sub_fixed_no_hdrm( hReverb->outputBufferImag_fx[bin][ch], tapRealPr_fx[tapIdx], hReverb->outputBufferImag_fx[bin][ch], numSlots );
+#else /* VEC_ARITH_OPT_v1 */
v_add_fixed( hReverb->outputBufferReal_fx[bin][ch], tapImagPr_fx[tapIdx], hReverb->outputBufferReal_fx[bin][ch], numSlots, 0 );
v_sub_fixed( hReverb->outputBufferImag_fx[bin][ch], tapRealPr_fx[tapIdx], hReverb->outputBufferImag_fx[bin][ch], numSlots, 0 );
+#endif /* VEC_ARITH_OPT_v1 */
BREAK;
}
}
diff --git a/lib_rend/ivas_rom_rend.h b/lib_rend/ivas_rom_rend.h
index 2a661121b66a34d9df11511eaba324dc4d36b89d..f4aecc8378d072127134521ac4571407bd523c46 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*/
@@ -129,10 +129,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[];
-
/*----------------------------------------------------------------------------------*
* Renderer SBA & MC enc/dec matrices
*----------------------------------------------------------------------------------*/
diff --git a/lib_rend/ivas_rom_rend_fx.c b/lib_rend/ivas_rom_rend_fx.c
index df3dc4e2259621851c7a865414695a1871da9127..75bd017565775a1e6d88011477457931dc04eebd 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],
@@ -564,44 +563,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
-};
-
-
-
/*----------------------------------------------------------------------------------*
* Renderer SBA & MC enc/dec matrices
*----------------------------------------------------------------------------------*/
diff --git a/lib_rend/ivas_rotation_fx.c b/lib_rend/ivas_rotation_fx.c
index 91a60eac8f31c80e99cacdd352ccaa931f28da07..aaae3e199d7a0aa7d26512ad20834b4755b75793 100644
--- a/lib_rend/ivas_rotation_fx.c
+++ b/lib_rend/ivas_rotation_fx.c
@@ -2018,7 +2018,7 @@ static void external_target_interpolation_fx(
move16();
Word32 tmp;
/* Calculate the interpolation increment and coefficient */
- tmp = BASOP_Util_Divide3232_Scale_cadence( ONE_IN_Q30, L_shl( L_deposit_l( hExtOrientationData->numFramesToTargetOrientation[i] ), 2 ), &tmp_e );
+ tmp = BASOP_Util_Divide3232_Scale_newton( ONE_IN_Q30, L_shl( L_deposit_l( hExtOrientationData->numFramesToTargetOrientation[i] ), 2 ), &tmp_e );
hCombinedOrientationData->interpolationIncrement_fx = L_shl( tmp, sub( tmp_e, 31 ) ); /* Q30 */
move32();
hCombinedOrientationData->interpolationCoefficient_fx = hCombinedOrientationData->interpolationIncrement_fx;
diff --git a/lib_rend/ivas_shoebox_fx.c b/lib_rend/ivas_shoebox_fx.c
index 1a1339f5d36a68accb819f417bd681d2fcaed54e..fb580de75d104ee5fde02b1f3c39652b9ead6984 100644
--- a/lib_rend/ivas_shoebox_fx.c
+++ b/lib_rend/ivas_shoebox_fx.c
@@ -388,7 +388,7 @@ static Word32 shoebox_get_euclidian_distance_internal_fx(
{
q = Q22;
move16();
- t = (Word32) BASOP_Util_Divide3232_Scale_cadence( *scale, absxk, &q );
+ t = (Word32) BASOP_Util_Divide3232_Scale_newton( *scale, absxk, &q );
out_tmp = W_extract_h( W_shl( W_mult_32_32( out_tmp, t ), q ) ); // Q22 + Q31 + Q1 - 32 = Q22
out_tmp = W_extract_h( W_shl( W_mult_32_32( out_tmp, t ), q ) ); // Q22 + Q31 + Q1 - 32 = Q22
@@ -398,7 +398,7 @@ static Word32 shoebox_get_euclidian_distance_internal_fx(
}
ELSE
{
- t = (Word32) BASOP_Util_Divide3232_Scale_cadence( absxk, *scale, &q );
+ t = (Word32) BASOP_Util_Divide3232_Scale_newton( absxk, *scale, &q );
t = W_extract_h( W_shl( W_mult_32_32( t, t ), sub( shl( q, 1 ), 9 ) ) ); // Q31 + Q31 + Q1 - 9 - 32 = Q22
out_tmp = L_add( out_tmp, t ); // Q22
move32();
@@ -408,7 +408,7 @@ static Word32 shoebox_get_euclidian_distance_internal_fx(
IF( GE_32( absxk, *scale ) )
{
- t = (Word32) BASOP_Util_Divide3232_Scale_cadence( *scale, absxk, &q );
+ t = (Word32) BASOP_Util_Divide3232_Scale_newton( *scale, absxk, &q );
out_tmp = W_extract_h( W_shl( W_mult_32_32( out_tmp, t ), q ) ); // Q22 + Q31 + Q1 - 32 = Q22
out_tmp = W_extract_h( W_shl( W_mult_32_32( out_tmp, t ), q ) ); // Q22 + Q31 + Q1 - 32 = Q22
@@ -418,7 +418,7 @@ static Word32 shoebox_get_euclidian_distance_internal_fx(
}
ELSE
{
- t = (Word32) BASOP_Util_Divide3232_Scale_cadence( absxk, *scale, &q );
+ t = (Word32) BASOP_Util_Divide3232_Scale_newton( absxk, *scale, &q );
t = W_extract_h( W_shl( W_mult_32_32( t, t ), sub( shl( q, 1 ), 9 ) ) ); // Q31 + Q31 + Q1 - 9 - 32 = Q22
out_tmp = L_add( out_tmp, t ); // Q22
}
diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h
index cc15659439b9373e3fff9fafa1970e22bb79761d..b7acbca2cdba57720c7d563171d7c2877550de65 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;
@@ -1278,8 +1278,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;
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 12fb2c5241ad3d915da64df7f98597b1666d084a..4276b8146d1f741eaecaf4b80da0c7ea23b8592e 100644
--- a/lib_rend/lib_rend.c
+++ b/lib_rend/lib_rend_fx.c
@@ -6824,7 +6824,11 @@ static ivas_error renderLfeToBinaural_fx(
{
writePtr = getSmplPtr_fx( outAudio, ear_idx, 0 );
move32();
+#ifdef VEC_ARITH_OPT_v1
+ v_add_fixed_no_hdrm( writePtr, tmpLfeBuffer, writePtr, frame_size ); /* Q(out_q) */
+#else /* VEC_ARITH_OPT_v1 */
v_add_fixed( writePtr, tmpLfeBuffer, writePtr, frame_size, 0 ); /* Q(out_q) */
+#endif /* VEC_ARITH_OPT_v1 */
}
#endif
@@ -8376,7 +8380,11 @@ static void renderMasaToMasa(
ELSE IF( EQ_16( masaInput->base.inputBuffer.config.numChannels, 2 ) && EQ_16( outAudio.config.numChannels, 1 ) )
{
// v_add( tmpBuffer[0], tmpBuffer[1], tmpBuffer[0], masaInput->base.inputBuffer.config.numSamplesPerChannel );
+#ifdef VEC_ARITH_OPT_v1
+ v_add_fixed_no_hdrm( tmpBuffer_fx[0], tmpBuffer_fx[1], tmpBuffer_fx[0], masaInput->base.inputBuffer.config.numSamplesPerChannel );
+#else /* VEC_ARITH_OPT_v1 */
v_add_fixed( tmpBuffer_fx[0], tmpBuffer_fx[1], tmpBuffer_fx[0], masaInput->base.inputBuffer.config.numSamplesPerChannel, 0 );
+#endif /* VEC_ARITH_OPT_v1 */
}
/* Copy metadata */
@@ -8419,7 +8427,7 @@ static void renderMasaToMasa(
move32();
FOR( dir = 0; dir < numDirs; dir++ )
{
- tmp = BASOP_Util_Divide3232_Scale_cadence( inMeta->directional_meta[dir].energy_ratio_fx[sf][band], ratioSum_fx, &tmp_e );
+ tmp = BASOP_Util_Divide3232_Scale_newton( inMeta->directional_meta[dir].energy_ratio_fx[sf][band], ratioSum_fx, &tmp_e );
inMeta->directional_meta[dir].energy_ratio_fx[sf][band] = L_shl( tmp, sub( tmp_e, 1 ) ); /* Q30 */
move32();
}
@@ -8427,7 +8435,7 @@ static void renderMasaToMasa(
move16();
tmp = 0;
move32();
- tmp = BASOP_Util_Divide3232_Scale_cadence( inMeta->common_meta.diffuse_to_total_ratio_fx[sf][band], ratioSum_fx, &tmp_e );
+ tmp = BASOP_Util_Divide3232_Scale_newton( inMeta->common_meta.diffuse_to_total_ratio_fx[sf][band], ratioSum_fx, &tmp_e );
inMeta->common_meta.diffuse_to_total_ratio_fx[sf][band] = L_shl( tmp, sub( tmp_e, 1 ) ); /* Q30 */
move32();
}
@@ -10680,13 +10688,16 @@ static void intermidiate_ext_dirac_render(
move16();
#endif
}
+ IF( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_fx != NULL )
+ {
- tmp = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_len );
- scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_len, tmp ); /* Q(hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_q + tmp) */
- hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_q = add( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_q, tmp );
- move16();
+ tmp = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_len );
+ scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_len, tmp ); /* Q(hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_q + tmp) */
+ hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_q = add( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_q, tmp );
+ move16();
+ }
- IF( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_fx != 0 )
+ IF( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_fx != NULL )
{
tmp = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_len );
scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_len, tmp ); /* Q(hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_q + tmp) */